Skip to content

Commit

Permalink
add re-check claimable status
Browse files Browse the repository at this point in the history
  • Loading branch information
MickWang committed Apr 29, 2024
1 parent 3b126db commit 4083c7d
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions store/zksync/withdrawals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,7 @@ export const useZkSyncWithdrawalsStore = defineStore("zkSyncWithdrawals", () =>
return !!ethBalance.value && ethBalance.value > Number(withdrawal.token.amount);
};

const checkWithdrawalFinalizeAvailable = async (withdrawal: {
transactionHash: ethers.utils.BytesLike;
status: string;
gateway: string;
[key: string]: any;
}) => {
const checkWithdrawalFinalizeAvailable = async (withdrawal: TransactionInfo) => {
const { primaryNetwork, zkSyncNetworks, getNetworkInfo } = useNetworks();
const { selectedNetwork } = storeToRefs(useNetworkStore());
let provider: Provider | undefined;
Expand Down Expand Up @@ -249,7 +244,21 @@ export const useZkSyncWithdrawalsStore = defineStore("zkSyncWithdrawals", () =>
},
});
}
} else if (!transactionFromStorage.info.completed) {
} else {
// recheck claimable status
const status = await checkWithdrawalFinalizeAvailable(transactionFromStorage);
if (!status) {
transactionStatusStore.updateTransactionData(withdrawal.transactionHash, {
...transactionFromStorage,
info: {
...transactionFromStorage.info,
withdrawalFinalizationAvailable: false,
},
});
}
}

if (!transactionFromStorage.info.completed) {
await setStatus(withdrawal);
await sleep(200);
if (withdrawal.status === "Finalized") {
Expand Down

0 comments on commit 4083c7d

Please sign in to comment.