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 450c1d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/bridge-ui/src/components/Transactions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</tr>
</thead>
<tbody class="text-sm md:text-base">
{#each $transactions as transaction}
{#each $transactions as transaction (transaction.hash)}
<Transaction
toChain={chains[transaction.toChainId]}
fromChain={chains[transaction.fromChainId]}
Expand Down
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 450c1d8

Please sign in to comment.