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 delay limit for check claimable status #175

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion components/loaders/Connecting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</template>

<script lang="ts" setup>
import { computed } from "vue";
import { computed, onMounted } from "vue";

import { storeToRefs } from "pinia";

Expand Down
2 changes: 1 addition & 1 deletion layouts/default.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<!-- <LoadersConnecting /> -->
<LoadersConnecting />
<ModalConnectingWalletError />
<!-- <ModalNetworkChangedWarning v-if="!isConnectingWallet" /> -->
<ModalLegalNotice />
Expand Down
12 changes: 9 additions & 3 deletions store/zksync/withdrawals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ export const useZkSyncWithdrawalsStore = defineStore("zkSyncWithdrawals", () =>
const { destinations } = storeToRefs(useDestinationsStore());
const eraWalletStore = useZkSyncWalletStore();

const TRANSACTIONS_FETCH_LIMIT = 50;
const TRANSACTIONS_FETCH_LIMIT = 100;

const DELAY_DAYS = process.env.NODE_TYPE === "nexus-sepolia" ? 1 : 7;

const isWithinDelayDays = (timestamp: number | string) => {
return Date.now() - new Date(timestamp).getTime() < DELAY_DAYS * 24 * 60 * 60 * 1000;
};

function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
Expand Down Expand Up @@ -126,7 +132,7 @@ export const useZkSyncWithdrawalsStore = defineStore("zkSyncWithdrawals", () =>
const totalBatchesExecuted = await getTotalBatchesExecuted(withdrawal);
if (withdrawal.token.symbol === "ETH") {
const status = await isEthWithdrawalFinalizedOnPrimary(withdrawal.transactionHash);
console.log("status: ", status);
console.log("status: ", status, withdrawal);
claimable = status && totalBatchesExecuted >= l1BatchNumber;
} else {
claimable = totalBatchesExecuted >= l1BatchNumber;
Expand Down Expand Up @@ -187,8 +193,8 @@ export const useZkSyncWithdrawalsStore = defineStore("zkSyncWithdrawals", () =>
);
const withdrawals = transfers.items.filter((e) => e.type === "withdrawal" && e.token && e.amount);
for (const withdrawal of withdrawals) {
if (isWithinDelayDays(withdrawal.timestamp)) continue;
const { primaryNetwork, zkSyncNetworks, getNetworkInfo } = useNetworks();

const transactionFromStorage = transactionStatusStore.getTransaction(withdrawal.transactionHash);
if (transactionFromStorage) {
if (!transactionFromStorage.info.withdrawalFinalizationAvailable) {
Expand Down
Loading