Skip to content

Commit

Permalink
Update sendExtrinsic.ts...
Browse files Browse the repository at this point in the history
Add `InBlock` as an acceptable state, to resolve the promise as quickly as possible, in case waiting for `Finalized` state taking too long.
  • Loading branch information
ken-futureverse authored Mar 13, 2024
1 parent 7260d23 commit ee4f286
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/utils/src/sendExtrinsic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ export async function sendExtrinsic(
const { status, dispatchError, txHash, txIndex, blockNumber } =
result as SubmittableResultValue;
log?.info(`extrinsic status="${status.type}"`);
if (!status.isFinalized) return;
if (!status.isInBlock && !status.isFinalized) return;
if (!txIndex || !blockNumber) return;

if (!dispatchError) {
unsubscribe?.();
const blockHash = status.asFinalized.toString();
const blockHash: status.isFinalized
? status.asFinalized.toString()
: status.asInBlock.toString(),
const height = blockNumber.toString().padStart(10, "0");
const index = txIndex.toString().padStart(6, "0");
const hash = blockHash.slice(2, 7);
Expand Down

0 comments on commit ee4f286

Please sign in to comment.