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

About the callback issue encountered by nodejs when using @ polkadot/API #5783

Open
HanSXY opened this issue Jan 17, 2024 · 0 comments
Open

Comments

@HanSXY
Copy link

HanSXY commented Jan 17, 2024

Using nodejs to call @ polkadot/API version "^ 10.11.1"

There were some occasional issues during use, please refer to the following code snippet

import { ApiPromise, WsProvider, Keyring } from '@polkadot/api';
import { cryptoWaitReady } from '@polkadot/util-crypto';
const api = await ApiPromise.create();
await api.tx.utility
  .batch(Array)
  .signAndSend( accountFromKeyring, async ( { events = [], status , dispatchError  } ) => {
    if (status.isInBlock) {
      console.log('number1');
      events.forEach( async ({ event: { method, data: [error] } }) => {
        if (method == 'BatchInterrupted') {
          console.log('number2');
        } else if(method == 'BatchCompleted'){
          console.log('number3');
        }
      });
    }
  })

In the above code execution, I can obtain the print log of number1, but sometimes I cannot obtain the print log of number2 or number3. Is there a problem with my writing style?

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