1import { ApiPromise } from "@polkadot/api";23export default function waitNewBlocks(api: ApiPromise, blocksCount: number = 1): Promise<void> {4 const promise = new Promise<void>(async (resolve, reject) => {5 6 const unsubscribe = await api.rpc.chain.subscribeNewHeads(head => {7 if(blocksCount > 0) {8 blocksCount--;9 }else {10 unsubscribe();11 resolve();12 }13 });14 });1516 return promise;17}difftreelog
source
tests/src/substrate/wait-new-blocks.ts433 Bsourcehistory