From 75d9823fc75ceef6eea94b9537eaf78bfdc612dd Mon Sep 17 00:00:00 2001 From: spsjvc Date: Tue, 10 Dec 2024 12:51:36 +0100 Subject: [PATCH] clean up --- ...kenWithdrawalsFromEventLogsSequentially.ts | 55 ++++++------------- 1 file changed, 17 insertions(+), 38 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/util/withdrawals/fetchTokenWithdrawalsFromEventLogsSequentially.ts b/packages/arb-token-bridge-ui/src/util/withdrawals/fetchTokenWithdrawalsFromEventLogsSequentially.ts index f4433e384e..f367cb8bd1 100644 --- a/packages/arb-token-bridge-ui/src/util/withdrawals/fetchTokenWithdrawalsFromEventLogsSequentially.ts +++ b/packages/arb-token-bridge-ui/src/util/withdrawals/fetchTokenWithdrawalsFromEventLogsSequentially.ts @@ -37,21 +37,23 @@ export async function fetchTokenWithdrawalsFromEventLogsSequentially({ fromBlock = 0, toBlock = 'latest' }: FetchTokenWithdrawalsFromEventLogsSequentiallyParams): Promise { + // function here so we can reuse common params function buildQueryParams({ sender, receiver, - l2GatewayAddresses - }: Pick< - FetchTokenWithdrawalsFromEventLogsParams, - 'sender' | 'receiver' | 'l2GatewayAddresses' - >) { + gateways = [] + }: { + sender?: string + receiver?: string + gateways?: string[] + }) { return { sender, receiver, fromBlock, toBlock, l2Provider: provider, - l2GatewayAddresses + l2GatewayAddresses: gateways } } @@ -70,73 +72,50 @@ export async function fetchTokenWithdrawalsFromEventLogsSequentially({ const queries: WithdrawalQuery[] = [] + // only add queries for sender if account has activity if (senderNonce > 0) { queries.push({ - params: buildQueryParams({ - sender, - l2GatewayAddresses: [standardGateway] - }), + params: buildQueryParams({ sender, gateways: [standardGateway] }), priority: prio }) prio++ if (wethGateway !== constants.AddressZero) { queries.push({ - params: buildQueryParams({ - sender, - l2GatewayAddresses: [wethGateway] - }), + params: buildQueryParams({ sender, gateways: [wethGateway] }), priority: prio }) prio++ } queries.push({ - params: buildQueryParams({ - sender, - l2GatewayAddresses: [customGateway] - }), + params: buildQueryParams({ sender, gateways: [customGateway] }), priority: prio }) prio++ queries.push({ - params: buildQueryParams({ - sender, - l2GatewayAddresses: customCustomGateways - }), + params: buildQueryParams({ sender, gateways: customCustomGateways }), priority: prio }) prio++ } queries.push({ - params: buildQueryParams({ - receiver, - l2GatewayAddresses: [standardGateway] - }), + params: buildQueryParams({ receiver, gateways: [standardGateway] }), priority: prio }) prio++ if (wethGateway !== constants.AddressZero) { queries.push({ - params: buildQueryParams({ - receiver, - l2GatewayAddresses: [wethGateway] - }), + params: buildQueryParams({ receiver, gateways: [wethGateway] }), priority: prio }) prio++ } queries.push({ - params: buildQueryParams({ - receiver, - l2GatewayAddresses: [customGateway] - }), + params: buildQueryParams({ receiver, gateways: [customGateway] }), priority: prio }) prio++ queries.push({ - params: buildQueryParams({ - receiver, - l2GatewayAddresses: customCustomGateways - }), + params: buildQueryParams({ receiver, gateways: customCustomGateways }), priority: prio }) prio++