Skip to content

Commit

Permalink
fix: check status of uncompleted withdrawals
Browse files Browse the repository at this point in the history
  • Loading branch information
JackHamer09 committed Apr 1, 2024
1 parent 15df249 commit 37bc723
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions store/zksync/withdrawals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Api.Response.Transfer>[] = 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<Api.Response.Transfer> = 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(() =>
Expand Down

0 comments on commit 37bc723

Please sign in to comment.