From 8ec6b170bc101ed53148f9cac2133ebf9159c20b Mon Sep 17 00:00:00 2001 From: spsjvc Date: Tue, 10 Dec 2024 18:29:09 +0100 Subject: [PATCH] fetch eth and token withdrawals sequentially --- .../src/util/withdrawals/fetchWithdrawals.ts | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/util/withdrawals/fetchWithdrawals.ts b/packages/arb-token-bridge-ui/src/util/withdrawals/fetchWithdrawals.ts index a8e977faf3..fba6ff77e9 100644 --- a/packages/arb-token-bridge-ui/src/util/withdrawals/fetchWithdrawals.ts +++ b/packages/arb-token-bridge-ui/src/util/withdrawals/fetchWithdrawals.ts @@ -12,6 +12,7 @@ import { Withdrawal } from '../../hooks/useTransactionHistory' import { attachTimestampToTokenWithdrawal } from './helpers' import { WithdrawalInitiated } from '../../hooks/arbTokenBridge.types' import { fetchTokenWithdrawalsFromEventLogsSequentially } from './fetchTokenWithdrawalsFromEventLogsSequentially' +import { wait } from '../ExponentialBackoffUtils' export type FetchWithdrawalsParams = { sender?: string @@ -83,22 +84,23 @@ export async function fetchWithdrawals({ console.log('Error fetching withdrawals from subgraph', error) } - const [ethWithdrawalsFromEventLogs, tokenWithdrawalsFromEventLogs] = - await Promise.all([ - fetchETHWithdrawalsFromEventLogs({ - receiver, - fromBlock: toBlock + 1, - toBlock: 'latest', - l2Provider: l2Provider - }), - fetchTokenWithdrawalsFromEventLogsSequentially({ - sender, - receiver, - fromBlock: toBlock + 1, - toBlock: 'latest', - provider: l2Provider - }) - ]) + const ethWithdrawalsFromEventLogs = await fetchETHWithdrawalsFromEventLogs({ + receiver, + fromBlock: toBlock + 1, + toBlock: 'latest', + l2Provider: l2Provider + }) + + await wait(2_000) + + const tokenWithdrawalsFromEventLogs = + await fetchTokenWithdrawalsFromEventLogsSequentially({ + sender, + receiver, + fromBlock: toBlock + 1, + toBlock: 'latest', + provider: l2Provider + }) const mappedEthWithdrawalsFromEventLogs: Withdrawal[] = ethWithdrawalsFromEventLogs.map(tx => {