Skip to content

Commit

Permalink
fix(bridge-ui): transaction ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
shadab-taiko committed Mar 13, 2023
1 parent f43101b commit 35b5bb6
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions packages/bridge-ui/src/relayer-api/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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,
Expand All @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 35b5bb6

Please sign in to comment.