diff --git a/src/mappings/common.ts b/src/mappings/common.ts index 65e1a794..047f6c84 100644 --- a/src/mappings/common.ts +++ b/src/mappings/common.ts @@ -282,24 +282,24 @@ function exportFeeFromTransactionFeePaidEvent( extrinsic: SubstrateExtrinsic, from: string = "", ): bigint | undefined { - const eventRecord = extrinsic.events.find( - (event) => + for (let i = extrinsic.events.length - 1; i >= 0; i--) { + const event = extrinsic.events[i]; + if ( event.event.method == "TransactionFeePaid" && - event.event.section == "transactionPayment", - ); - - if (eventRecord !== undefined) { - const { - event: { - data: [accountid, fee, tip], - }, - } = eventRecord; - - const fullFee = (fee as Balance).toBigInt() + (tip as Balance).toBigInt(); - - const extrinsicSigner = from || extrinsic.extrinsic.signer.toString(); - const withdrawAccountId = accountid.toString(); - return extrinsicSigner === withdrawAccountId ? fullFee : undefined; + event.event.section == "transactionPayment" + ) { + const { + event: { + data: [accountid, fee, tip], + }, + } = event; + + const fullFee = (fee as Balance).toBigInt() + (tip as Balance).toBigInt(); + + const extrinsicSigner = from || extrinsic.extrinsic.signer.toString(); + const withdrawAccountId = accountid.toString(); + return extrinsicSigner === withdrawAccountId ? fullFee : undefined; + } } return undefined;