From 35b5bb66dc15616c80fd5f66afd47261804768bf Mon Sep 17 00:00:00 2001 From: Shadab Khan Date: Mon, 13 Mar 2023 20:01:30 +0530 Subject: [PATCH] fix(bridge-ui): transaction ordering --- packages/bridge-ui/src/relayer-api/service.ts | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/packages/bridge-ui/src/relayer-api/service.ts b/packages/bridge-ui/src/relayer-api/service.ts index 4f7cf7f8500..e0ca0856530 100644 --- a/packages/bridge-ui/src/relayer-api/service.ts +++ b/packages/bridge-ui/src/relayer-api/service.ts @@ -43,10 +43,6 @@ class RelayerAPIService implements RelayerAPI { } const txs: BridgeTransaction[] = data.map((tx) => { - const depositValue = ethers.utils.parseUnits( - tx.data.Message.DepositValue.toString(), - 'wei', - ); return { status: tx.status, message: { @@ -60,8 +56,8 @@ class RelayerAPIService implements RelayerAPI { callValue: tx.data.Message.CallValue, srcChainId: BigNumber.from(tx.data.Message.SrcChainId), destChainId: BigNumber.from(tx.data.Message.DestChainId), - depositValue: depositValue, - processingFee: BigNumber.from(tx.data.Message.ProcessingFee), + depositValue: BigNumber.from(`${tx.data.Message.DepositValue}`), + processingFee: BigNumber.from(`${tx.data.Message.ProcessingFee}`), refundAddress: tx.data.Message.RefundAddress, }, amountInWei: tx.amount, @@ -73,9 +69,7 @@ class RelayerAPIService implements RelayerAPI { }; }); - const bridgeTxs: BridgeTransaction[] = []; - - await Promise.all( + const bridgeTxs: BridgeTransaction[] = await Promise.all( (txs || []).map(async (tx) => { if (tx.message.owner.toLowerCase() !== address.toLowerCase()) return; @@ -116,7 +110,9 @@ class RelayerAPIService implements RelayerAPI { ); const event = events.find( - (e) => e.args.message.owner.toLowerCase() === address.toLowerCase(), + (e) => + e.args.message.owner.toLowerCase() === address.toLowerCase() && + e.args.message.depositValue.eq(tx.message.depositValue), ); if (!event) { @@ -172,12 +168,12 @@ class RelayerAPIService implements RelayerAPI { from: tx.from, }; - bridgeTxs.push(bridgeTx); + return bridgeTx; }), ); + bridgeTxs.reverse(); bridgeTxs.sort((tx) => (tx.status === MessageStatus.New ? -1 : 1)); - return bridgeTxs; }