From ee4f28622391ae653f6854f936c770042fc9fd21 Mon Sep 17 00:00:00 2001 From: Ken Vu <97480229+ken-futureverse@users.noreply.github.com> Date: Thu, 14 Mar 2024 10:11:08 +1300 Subject: [PATCH] Update sendExtrinsic.ts... Add `InBlock` as an acceptable state, to resolve the promise as quickly as possible, in case waiting for `Finalized` state taking too long. --- packages/utils/src/sendExtrinsic.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/utils/src/sendExtrinsic.ts b/packages/utils/src/sendExtrinsic.ts index 968ab53..ec4bac8 100644 --- a/packages/utils/src/sendExtrinsic.ts +++ b/packages/utils/src/sendExtrinsic.ts @@ -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);