From 16afab5a2df41a2275490c3b4cdea2e4f719f175 Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 22 Feb 2024 12:53:06 +0100 Subject: [PATCH 1/3] orbit deposit times --- .../components/common/DepositCountdown.tsx | 39 ++++++++++++++----- .../src/util/orbitChainsList.ts | 7 +++- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/components/common/DepositCountdown.tsx b/packages/arb-token-bridge-ui/src/components/common/DepositCountdown.tsx index 9ed432067b..416819fa91 100644 --- a/packages/arb-token-bridge-ui/src/components/common/DepositCountdown.tsx +++ b/packages/arb-token-bridge-ui/src/components/common/DepositCountdown.tsx @@ -2,8 +2,15 @@ import dayjs from 'dayjs' import { DepositStatus, MergedTransaction } from '../../state/app/state' import { isNetwork } from '../../util/networks' +import { getBridgeUiConfigForChain } from '../../util/bridgeUiConfig' -function getMinutesRemainingText(minutesRemaining: number): string { +function getMinutesRemainingText({ + minutesRemaining, + unknownCompletionTime +}: { + minutesRemaining: number + unknownCompletionTime: boolean +}): string { if (minutesRemaining <= 1) { if (minutesRemaining <= 0) { return 'Almost there...' @@ -12,23 +19,25 @@ function getMinutesRemainingText(minutesRemaining: number): string { return 'Less than a minute...' } - return `~${minutesRemaining} mins remaining` + const prefix = unknownCompletionTime ? 'up to ' : '~' + + return `${prefix}${minutesRemaining} mins remaining` } function getEstimatedDepositDurationInMinutes( - parentChainId: number | undefined + childChainId: number | undefined ) { - if (!parentChainId) { + if (!childChainId) { return 15 } - const { isEthereumMainnetOrTestnet, isTestnet } = isNetwork(parentChainId) + const { isOrbitChain, isTestnet } = isNetwork(childChainId) - // this covers orbit chains - if (!isEthereumMainnetOrTestnet) { - return 1 + if (isOrbitChain) { + return getBridgeUiConfigForChain(childChainId).depositTimeMinutes ?? 15 } + // L2 chains return isTestnet ? 10 : 15 } @@ -48,11 +57,21 @@ export function DepositCountdown({ ) { // Subtract the diff from the initial deposit time const minutesRemaining = - getEstimatedDepositDurationInMinutes(tx.parentChainId) - + getEstimatedDepositDurationInMinutes(tx.childChainId) - now.diff(whenCreated, 'minutes') + + const { isOrbitChain } = isNetwork(tx.childChainId) + + // we can't estimate how much time certain Orbit chain will take to finalize a deposit + // if this time is not specified by us, then it is an unknown completion time and we will display it a bit differently in the UI + const unknownCompletionTime = + isOrbitChain && + typeof getBridgeUiConfigForChain(tx.childChainId).depositTimeMinutes === + 'undefined' + return ( - {getMinutesRemainingText(minutesRemaining)} + {getMinutesRemainingText({ minutesRemaining, unknownCompletionTime })} ) } diff --git a/packages/arb-token-bridge-ui/src/util/orbitChainsList.ts b/packages/arb-token-bridge-ui/src/util/orbitChainsList.ts index 84f8f1508e..427b88f08e 100644 --- a/packages/arb-token-bridge-ui/src/util/orbitChainsList.ts +++ b/packages/arb-token-bridge-ui/src/util/orbitChainsList.ts @@ -20,6 +20,7 @@ export type BridgeUiConfig = { description?: string } nativeTokenData?: NativeCurrencyBase + depositTimeMinutes?: number } type OrbitChainConfig = ChainWithRpcUrl & { bridgeUiConfig: BridgeUiConfig } @@ -83,7 +84,8 @@ export const orbitMainnets: { symbol: 'XAI', decimals: 18, logoUrl: '/images/XaiLogo.svg' - } + }, + depositTimeMinutes: 1 } }, 1380012617: { @@ -240,7 +242,8 @@ export const orbitTestnets: { [key in number]: OrbitChainConfig } = { name: 'Xai Testnet', logo: '/images/XaiLogo.svg', description: 'The testnet for Xai’s gaming chain.' - } + }, + depositTimeMinutes: 1 } } } From 17b1d0214b17aba7f4833f7a3027041f120297f4 Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 22 Feb 2024 12:57:28 +0100 Subject: [PATCH 2/3] stylus testnet --- packages/arb-token-bridge-ui/src/util/bridgeUiConfig.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/src/util/bridgeUiConfig.ts b/packages/arb-token-bridge-ui/src/util/bridgeUiConfig.ts index c1ecd3eea5..77cb8c5d2f 100644 --- a/packages/arb-token-bridge-ui/src/util/bridgeUiConfig.ts +++ b/packages/arb-token-bridge-ui/src/util/bridgeUiConfig.ts @@ -129,7 +129,8 @@ export function getBridgeUiConfigForChain( logo: '/images/StylusLogo.svg', description: 'An experimental playground for Arbitrum Stylus smart contracts.' - } + }, + depositTimeMinutes: 1 } default: { // added Orbit chains From 73967bf7e03fd553f1c0d4b0d6ad5a58a81b27fc Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 3 May 2024 12:21:01 +0200 Subject: [PATCH 3/3] fix --- .../TransactionHistory/TransactionsTableDetailsSteps.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/src/components/TransactionHistory/TransactionsTableDetailsSteps.tsx b/packages/arb-token-bridge-ui/src/components/TransactionHistory/TransactionsTableDetailsSteps.tsx index c355491974..25cc640e17 100644 --- a/packages/arb-token-bridge-ui/src/components/TransactionHistory/TransactionsTableDetailsSteps.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransactionHistory/TransactionsTableDetailsSteps.tsx @@ -27,6 +27,7 @@ import { DepositCountdown } from '../common/DepositCountdown' import { useRemainingTime } from '../../state/cctpState' import { isDepositReadyToRedeem } from '../../state/app/utils' import { Address } from '../../util/AddressUtils' +import { getBridgeUiConfigForChain } from '../../util/bridgeUiConfig' function getTransferDurationText(tx: MergedTransaction) { const { isTestnet, isOrbitChain } = isNetwork(tx.childChainId) @@ -37,7 +38,10 @@ function getTransferDurationText(tx: MergedTransaction) { if (!tx.isWithdrawal) { if (isOrbitChain) { - return 'a minute' + const { depositTimeMinutes } = getBridgeUiConfigForChain(tx.childChainId) + return depositTimeMinutes + ? `${depositTimeMinutes} minute${depositTimeMinutes > 1 ? 's' : ''}` + : '15 minutes' } return isTestnet ? '10 minutes' : '15 minutes' }