Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Batch Transactions Status in Polkadot JS API Callback #463

Open
harish-h27 opened this issue Jan 23, 2024 · 0 comments
Open

Issue with Batch Transactions Status in Polkadot JS API Callback #463

harish-h27 opened this issue Jan 23, 2024 · 0 comments

Comments

@harish-h27
Copy link

harish-h27 commented Jan 23, 2024

Description:

I am facing an issue when using the Polkadot JS API to handle batch transactions. In the normal case, when I call individual functions, I receive multiple status updates such as Ready, Broadcast, InBlock, and Finalized. However, when I aggregate these individual transactions into an array and pass them to the batchAll function, the callback only returns Ready and Broadcast status. This makes it challenging to determine whether the entire batch failed or succeeded.

Problem:

When using the batchAll function, the callback only provides Ready and Broadcast status.
It is difficult to identify whether the batch of transactions failed or succeeded within the callback function.

Scenario:
Each transaction in the batch calls a different function.
The goal is to notify users about the success or failure of their transactions.
A single wallet is used for multiple users.

Desired Solution:
Need a way to check if the batch of transactions failed or succeeded within the callback function.
Information about the block status or any relevant details to identify the success or failure of the batch would be helpful.

Additional Context:
I am currently maintaining a separate array for the same transactions in a different batch to notify users based on the transactions they have in batch.

Code:

`const dex = await api.rpc.system.accountNextIndex(
    REGISTRAR_KEYRING.address,
);
const result = await api.tx.utility
    .batchAll(array)
    .signAndSend(REGISTRAR_KEYRING, { nonce: dex }, ({ status, events }) => {
        console.log('Status:', status.toHuman());
        console.log('Is events:', events);
        if (status.isInBlock || status.isFinalized) {
            console.log('Transaction Included in Block or Finalized');
        }
        // Need a way to determine if the batch failed or succeeded.
        // Additional information about the block status would be helpful.
    });`

output:
Screenshot from 2024-01-23 22-12-08

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant