From 37bc72343c74d1503621db32233f201d0098fb31 Mon Sep 17 00:00:00 2001 From: Jack Hamer Date: Mon, 1 Apr 2024 23:39:30 +0300 Subject: [PATCH] fix: check status of uncompleted withdrawals --- store/zksync/withdrawals.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/store/zksync/withdrawals.ts b/store/zksync/withdrawals.ts index e1dfaaafe..4f8f9638f 100644 --- a/store/zksync/withdrawals.ts +++ b/store/zksync/withdrawals.ts @@ -18,21 +18,15 @@ export const useZkSyncWithdrawalsStore = defineStore("zkSyncWithdrawals", () => if (!eraNetwork.value.blockExplorerApi) throw new Error(`Block Explorer API is not available on ${eraNetwork.value.name}`); - const responses: Api.Response.Collection[] = await Promise.all([ - $fetch(`${eraNetwork.value.blockExplorerApi}/address/${account.value.address}/transfers?limit=100&page=1`), - $fetch(`${eraNetwork.value.blockExplorerApi}/address/${account.value.address}/transfers?limit=100&page=2`), - $fetch(`${eraNetwork.value.blockExplorerApi}/address/${account.value.address}/transfers?limit=100&page=3`), - ]); - const withdrawalTransfers = responses - .map((response) => response.items.map(mapApiTransfer)) - .flat() - .filter((e) => e.type === "withdrawal"); + const response: Api.Response.Collection = await $fetch( + `${eraNetwork.value.blockExplorerApi}/address/${account.value.address}/transfers?type=withdrawal` + ); - for (const withdrawal of withdrawalTransfers) { + for (const withdrawal of response.items.map(mapApiTransfer)) { if (!withdrawal.transactionHash) continue; const transactionFromStorage = transactionStatusStore.getTransaction(withdrawal.transactionHash); - if (transactionFromStorage) continue; + if (transactionFromStorage?.info.completed) continue; if (new Date(withdrawal.timestamp).getTime() < Date.now() - FETCH_TIME_LIMIT) break; const transactionDetails = await retry(() =>