Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add re-check claimable status #203

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading