From 54c296036b4691bcd2c17595784dc0bbc700e4ca Mon Sep 17 00:00:00 2001 From: MickWang <1244134672@qq.com> Date: Mon, 22 Apr 2024 18:27:23 +0800 Subject: [PATCH] update for estimate withdray delay time --- store/zksync/transactionStatus.ts | 2 +- utils/helpers.ts | 2 +- views/transactions/Withdraw.vue | 22 ++++++++++------------ views/transactions/WithdrawalSubmitted.vue | 2 -- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/store/zksync/transactionStatus.ts b/store/zksync/transactionStatus.ts index bf36dd6b8..d85eb85fb 100644 --- a/store/zksync/transactionStatus.ts +++ b/store/zksync/transactionStatus.ts @@ -44,7 +44,7 @@ export const getEstmatdDepositDelay = (networkKey: string): number => { return ESTIMATED_DEPOSIT_DELAY_SECONDARY; } }; -export const WITHDRAWAL_DELAY = 14 * 24 * 60 * 60 * 1000; // 7 * 24 hours +export const WITHDRAWAL_DELAY = 7 * 24 * 60 * 60 * 1000; // 7 * 24 hours export type Address = Hash; export type ForwardL2Request = { gateway: Address; diff --git a/utils/helpers.ts b/utils/helpers.ts index de9bd2d8b..c04cc2669 100644 --- a/utils/helpers.ts +++ b/utils/helpers.ts @@ -55,7 +55,7 @@ export async function retry(func: () => Promise, options: RetryOptions = { } } -export const getEstimateWithdrawalDelayDays = (txTime: string) => { +export const getEstimateWithdrawalDelayDays = (txTime: string | number) => { const transactionTime = new Date(txTime).getTime(); if (transactionTime < LAST_BLAST_SYNCL2_TIME) { return 14; diff --git a/views/transactions/Withdraw.vue b/views/transactions/Withdraw.vue index fd41ac6bb..722d4f3bc 100644 --- a/views/transactions/Withdraw.vue +++ b/views/transactions/Withdraw.vue @@ -184,11 +184,12 @@ class="mb-block-padding-1/2 sm:mb-block-gap" >

- You will be able to claim your withdrawal only after a {{ WITHDRAWAL_DELAY_DAYS }}-day withdrawal delay. + You will be able to claim your withdrawal only after a {{ displayEstimateWithdrawalDelayDays }}-day + withdrawal delay.

- You will receive funds only after a {{ WITHDRAWAL_DELAY_DAYS }}-day withdrawal delay. + You will receive funds only after a {{ displayEstimateWithdrawalDelayDays }}-day withdrawal delay.

@@ -487,20 +488,13 @@ import { useOnboardStore } from "@/store/onboard"; import { usePreferencesStore } from "@/store/preferences"; import { useZkSyncProviderStore } from "@/store/zksync/provider"; import { useZkSyncTokensStore } from "@/store/zksync/tokens"; -import { WITHDRAWAL_DELAY } from "@/store/zksync/transactionStatus"; import { useZkSyncTransactionStatusStore } from "@/store/zksync/transactionStatus"; import { useZkSyncTransfersHistoryStore } from "@/store/zksync/transfersHistory"; import { useZkSyncWalletStore } from "@/store/zksync/wallet"; -import { - ETH_TOKEN, - isMergeToken, - isSupportedMergeToken, - MergeTokenContractUrl, - WITHDRAWAL_DELAY_DAYS, -} from "@/utils/constants"; +import { ETH_TOKEN, isMergeToken, isSupportedMergeToken } from "@/utils/constants"; import { ZKSYNC_WITHDRAWAL_DELAY } from "@/utils/doc-links"; import { checksumAddress, decimalToBigNumber, formatRawTokenPrice, parseTokenAmount } from "@/utils/formatters"; -import { calculateFee } from "@/utils/helpers"; +import { calculateFee, getEstimateWithdrawalDelayDays } from "@/utils/helpers"; import { silentRouterChange } from "@/utils/helpers"; import { TransitionAlertScaleInOutTransition, TransitionOpacity } from "@/utils/transitions"; import TransferSubmitted from "@/views/transactions/TransferSubmitted.vue"; @@ -595,6 +589,8 @@ const fromNetworkSelected = (networkKey?: string) => { const step = ref<"form" | "withdrawal-finalization-warning" | "confirm" | "submitted">("form"); const destination = computed(() => (props.type === "transfer" ? destinations.value.nova : destinations.value.arbitrum)); +const displayEstimateWithdrawalDelayDays = getEstimateWithdrawalDelayDays(Date.now()); + const availableTokens = computed(() => { if (!tokens.value) return []; if (props.type === "withdrawal") { @@ -1067,7 +1063,9 @@ const makeTransaction = async () => { info: { expectedCompleteTimestamp: transaction.value?.type === "withdrawal" - ? new Date(new Date().getTime() + WITHDRAWAL_DELAY).toISOString() + ? new Date( + new Date().getTime() + getEstimateWithdrawalDelayDays(Date.now()) * 24 * 60 * 60 * 1000 + ).toISOString() : undefined, completed: false, }, diff --git a/views/transactions/WithdrawalSubmitted.vue b/views/transactions/WithdrawalSubmitted.vue index 7300db521..c2fa0521b 100644 --- a/views/transactions/WithdrawalSubmitted.vue +++ b/views/transactions/WithdrawalSubmitted.vue @@ -159,8 +159,6 @@ import { useNetworkStore } from "@/store/network"; import { useOnboardStore } from "@/store/onboard"; import { useZkSyncProviderStore } from "@/store/zksync/provider"; import { useZkSyncTransactionStatusStore } from "@/store/zksync/transactionStatus"; -import { LAST_BLAST_SYNCL2_TIME, WITHDRAWAL_DELAY_DAYS } from "@/utils/constants"; - import { getEstimateWithdrawalDelayDays } from "@/utils/helpers"; const props = defineProps({