From 456ca48f97485fd8eba671c936717cdb35c218de Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 10 Dec 2024 17:23:50 +0100 Subject: [PATCH 1/2] feat: make cbBTC withdraw-only (#2108) --- packages/arb-token-bridge-ui/src/util/WithdrawOnlyUtils.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/arb-token-bridge-ui/src/util/WithdrawOnlyUtils.ts b/packages/arb-token-bridge-ui/src/util/WithdrawOnlyUtils.ts index 6b0ac37e7b..9b07e9b47d 100644 --- a/packages/arb-token-bridge-ui/src/util/WithdrawOnlyUtils.ts +++ b/packages/arb-token-bridge-ui/src/util/WithdrawOnlyUtils.ts @@ -223,6 +223,12 @@ export const withdrawOnlyTokens: { [chainId: number]: WithdrawOnlyToken[] } = { l2CustomAddr: '', l1Address: '0x6982508145454Ce325dDbE47a25d4ec3d2311933', l2Address: '0x35E6A59F786d9266c7961eA28c7b768B33959cbB' + }, + { + symbol: 'cbBTC', + l2CustomAddr: '', + l1Address: '0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf', + l2Address: '0x4A605F93288e95db40cE72934b888641D9689a48' } ], [ChainId.ArbitrumNova]: [] From 90f3aa4faf00e50b46a8be2c2d3e93db879d2bf7 Mon Sep 17 00:00:00 2001 From: Fionna Chan <13184582+fionnachan@users.noreply.github.com> Date: Wed, 11 Dec 2024 02:57:16 +0800 Subject: [PATCH 2/2] refactor: delete unused code and rename hook file (#2123) --- .../TransactionsTableDetailsSteps.tsx | 2 +- .../TransactionsTableRowAction.tsx | 2 +- .../components/TransactionHistory/helpers.ts | 2 +- .../components/common/TransferCountdown.tsx | 2 +- .../src/hooks/useRedeemTeleporter.ts | 2 +- .../src/hooks/useTransactionHistory.ts | 2 +- .../src/state/app/state.ts | 2 +- .../src/state/app/utils.ts | 2 +- .../Transactions.ts} | 33 ++----------------- .../src/util/RetryableUtils.ts | 2 +- .../src/util/deposits/fetchDeposits.ts | 2 +- .../src/util/deposits/helpers.ts | 2 +- .../src/util/teleports/helpers.ts | 2 +- 13 files changed, 14 insertions(+), 43 deletions(-) rename packages/arb-token-bridge-ui/src/{hooks/useTransactions.ts => types/Transactions.ts} (75%) 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 9e662640ab..7eff130e15 100644 --- a/packages/arb-token-bridge-ui/src/components/TransactionHistory/TransactionsTableDetailsSteps.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransactionHistory/TransactionsTableDetailsSteps.tsx @@ -21,7 +21,7 @@ import { ExternalLink } from '../common/ExternalLink' import { TransferCountdown } from '../common/TransferCountdown' import { isDepositReadyToRedeem } from '../../state/app/utils' import { Address } from '../../util/AddressUtils' -import { isTeleportTx } from '../../hooks/useTransactions' +import { isTeleportTx } from '../../types/Transactions' import { firstRetryableLegRequiresRedeem, secondRetryableLegForTeleportRequiresRedeem diff --git a/packages/arb-token-bridge-ui/src/components/TransactionHistory/TransactionsTableRowAction.tsx b/packages/arb-token-bridge-ui/src/components/TransactionHistory/TransactionsTableRowAction.tsx index b698597a3a..629aec8aaa 100644 --- a/packages/arb-token-bridge-ui/src/components/TransactionHistory/TransactionsTableRowAction.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransactionHistory/TransactionsTableRowAction.tsx @@ -18,7 +18,7 @@ import { isDepositReadyToRedeem } from '../../state/app/utils' import { useRedeemRetryable } from '../../hooks/useRedeemRetryable' import { TransferCountdown } from '../common/TransferCountdown' import { getChainIdForRedeemingRetryable } from '../../util/RetryableUtils' -import { isTeleportTx } from '../../hooks/useTransactions' +import { isTeleportTx } from '../../types/Transactions' import { useRedeemTeleporter } from '../../hooks/useRedeemTeleporter' import { sanitizeTokenSymbol } from '../../util/TokenUtils' import { formatAmount } from '../../util/NumberUtils' diff --git a/packages/arb-token-bridge-ui/src/components/TransactionHistory/helpers.ts b/packages/arb-token-bridge-ui/src/components/TransactionHistory/helpers.ts index bc44d3cec3..929a90388e 100644 --- a/packages/arb-token-bridge-ui/src/components/TransactionHistory/helpers.ts +++ b/packages/arb-token-bridge-ui/src/components/TransactionHistory/helpers.ts @@ -31,7 +31,7 @@ import { getAttestationHashAndMessageFromReceipt } from '../../util/cctp/getAtte import { getOutgoingMessageState } from '../../util/withdrawals/helpers' import { getUniqueIdOrHashFromEvent } from '../../hooks/useArbTokenBridge' import { getProviderForChainId } from '../../token-bridge-sdk/utils' -import { isTeleportTx } from '../../hooks/useTransactions' +import { isTeleportTx } from '../../types/Transactions' const PARENT_CHAIN_TX_DETAILS_OF_CLAIM_TX = 'arbitrum:bridge:claim:parent:tx:details' diff --git a/packages/arb-token-bridge-ui/src/components/common/TransferCountdown.tsx b/packages/arb-token-bridge-ui/src/components/common/TransferCountdown.tsx index 5806342bc8..d19c8c2e5b 100644 --- a/packages/arb-token-bridge-ui/src/components/common/TransferCountdown.tsx +++ b/packages/arb-token-bridge-ui/src/components/common/TransferCountdown.tsx @@ -5,7 +5,7 @@ import { useTransferDuration } from '../../hooks/useTransferDuration' import { isNetwork } from '../../util/networks' -import { isTeleportTx } from '../../hooks/useTransactions' +import { isTeleportTx } from '../../types/Transactions' /** * Displays a transfer countdown for a deposit, withdrawal, or cctp. diff --git a/packages/arb-token-bridge-ui/src/hooks/useRedeemTeleporter.ts b/packages/arb-token-bridge-ui/src/hooks/useRedeemTeleporter.ts index 4845c0e67f..20edd6715d 100644 --- a/packages/arb-token-bridge-ui/src/hooks/useRedeemTeleporter.ts +++ b/packages/arb-token-bridge-ui/src/hooks/useRedeemTeleporter.ts @@ -26,7 +26,7 @@ import { isUserRejectedError } from '../util/isUserRejectedError' import { errorToast } from '../components/common/atoms/Toast' import { useTransactionHistory } from './useTransactionHistory' import { Address } from '../util/AddressUtils' -import { isTeleportTx, L2ToL3MessageData } from './useTransactions' +import { isTeleportTx, L2ToL3MessageData } from '../types/Transactions' import { UseRedeemRetryableResult } from './useRedeemRetryable' import { getUpdatedTeleportTransfer } from '../components/TransactionHistory/helpers' diff --git a/packages/arb-token-bridge-ui/src/hooks/useTransactionHistory.ts b/packages/arb-token-bridge-ui/src/hooks/useTransactionHistory.ts index 940eb0181b..428722771e 100644 --- a/packages/arb-token-bridge-ui/src/hooks/useTransactionHistory.ts +++ b/packages/arb-token-bridge-ui/src/hooks/useTransactionHistory.ts @@ -17,7 +17,7 @@ import { L2ToL1EventResultPlus, WithdrawalInitiated } from './arbTokenBridge.types' -import { isTeleportTx, Transaction } from './useTransactions' +import { isTeleportTx, Transaction } from '../types/Transactions' import { MergedTransaction } from '../state/app/state' import { isCustomDestinationAddressTx, diff --git a/packages/arb-token-bridge-ui/src/state/app/state.ts b/packages/arb-token-bridge-ui/src/state/app/state.ts index e2b723a676..d962b01372 100644 --- a/packages/arb-token-bridge-ui/src/state/app/state.ts +++ b/packages/arb-token-bridge-ui/src/state/app/state.ts @@ -10,7 +10,7 @@ import { ChildToParentMessageData, L2ToL3MessageData, TxnType -} from '../../hooks/useTransactions' +} from '../../types/Transactions' import { ConnectionState } from '../../util' import { CCTPSupportedChainId } from '../cctpState' import { Address } from '../../util/AddressUtils' diff --git a/packages/arb-token-bridge-ui/src/state/app/utils.ts b/packages/arb-token-bridge-ui/src/state/app/utils.ts index b2a14492df..bb3037d373 100644 --- a/packages/arb-token-bridge-ui/src/state/app/utils.ts +++ b/packages/arb-token-bridge-ui/src/state/app/utils.ts @@ -17,7 +17,7 @@ import { isTeleportTx, TeleporterTransaction, Transaction -} from '../../hooks/useTransactions' +} from '../../types/Transactions' import { getUniqueIdOrHashFromEvent } from '../../hooks/useArbTokenBridge' import { firstRetryableLegRequiresRedeem, diff --git a/packages/arb-token-bridge-ui/src/hooks/useTransactions.ts b/packages/arb-token-bridge-ui/src/types/Transactions.ts similarity index 75% rename from packages/arb-token-bridge-ui/src/hooks/useTransactions.ts rename to packages/arb-token-bridge-ui/src/types/Transactions.ts index f09e4b2662..8fa341fa26 100644 --- a/packages/arb-token-bridge-ui/src/hooks/useTransactions.ts +++ b/packages/arb-token-bridge-ui/src/types/Transactions.ts @@ -1,6 +1,7 @@ -import { AssetType } from './arbTokenBridge.types' import { BigNumber } from 'ethers' import { ParentToChildMessageStatus } from '@arbitrum/sdk' + +import { AssetType } from '../hooks/arbTokenBridge.types' import { MergedTransaction, TeleporterMergedTransaction @@ -24,22 +25,6 @@ export type TxnType = | 'deposit-l2-ticket-created' // unused; keeping for cache backwrads compatability | 'approve-l2' -export const txnTypeToLayer = (txnType: TxnType): 1 | 2 => { - switch (txnType) { - case 'deposit': - case 'deposit-l1': - case 'outbox': - case 'approve': - return 1 - case 'deposit-l2': - case 'withdraw': - case 'deposit-l2-auto-redeem': - case 'deposit-l2-ticket-created': - case 'approve-l2': - return 2 - } -} - export interface ParentToChildMessageData { status: ParentToChildMessageStatus retryableCreationTxID: string @@ -93,20 +78,6 @@ export interface TeleporterTransaction extends Transaction { l2ToL3MsgData: L2ToL3MessageData } -export interface NewTransaction extends TransactionBase { - status: 'pending' -} - -export interface FailedTransaction extends TransactionBase { - status: 'failure' -} - -// TODO: enforce this type restriction -export interface DepositTransaction extends Transaction { - parentToChildMsgData: ParentToChildMessageData - type: 'deposit' | 'deposit-l1' -} - export function isTeleportTx( tx: Transaction | MergedTransaction ): tx is TeleporterTransaction | TeleporterMergedTransaction { diff --git a/packages/arb-token-bridge-ui/src/util/RetryableUtils.ts b/packages/arb-token-bridge-ui/src/util/RetryableUtils.ts index f65d704ccb..ad7f89ba80 100644 --- a/packages/arb-token-bridge-ui/src/util/RetryableUtils.ts +++ b/packages/arb-token-bridge-ui/src/util/RetryableUtils.ts @@ -12,7 +12,7 @@ import { TeleporterMergedTransaction } from '../state/app/state' import { normalizeTimestamp } from '../state/app/utils' -import { isTeleportTx } from '../hooks/useTransactions' +import { isTeleportTx } from '../types/Transactions' type GetRetryableTicketParams = { parentChainTxHash: string diff --git a/packages/arb-token-bridge-ui/src/util/deposits/fetchDeposits.ts b/packages/arb-token-bridge-ui/src/util/deposits/fetchDeposits.ts index b2ec571855..17acc4dd64 100644 --- a/packages/arb-token-bridge-ui/src/util/deposits/fetchDeposits.ts +++ b/packages/arb-token-bridge-ui/src/util/deposits/fetchDeposits.ts @@ -6,7 +6,7 @@ import { FetchDepositsFromSubgraphResult } from './fetchDepositsFromSubgraph' import { AssetType } from '../../hooks/arbTokenBridge.types' -import { Transaction } from '../../hooks/useTransactions' +import { Transaction } from '../../types/Transactions' import { defaultErc20Decimals } from '../../defaults' import { fetchNativeCurrency } from '../../hooks/useNativeCurrency' import { diff --git a/packages/arb-token-bridge-ui/src/util/deposits/helpers.ts b/packages/arb-token-bridge-ui/src/util/deposits/helpers.ts index 53781fd739..59d14ced25 100644 --- a/packages/arb-token-bridge-ui/src/util/deposits/helpers.ts +++ b/packages/arb-token-bridge-ui/src/util/deposits/helpers.ts @@ -18,7 +18,7 @@ import { Transaction, TxnStatus, TeleporterTransaction -} from '../../hooks/useTransactions' +} from '../../types/Transactions' import { fetchErc20Data } from '../TokenUtils' import { getL2ConfigForTeleport, diff --git a/packages/arb-token-bridge-ui/src/util/teleports/helpers.ts b/packages/arb-token-bridge-ui/src/util/teleports/helpers.ts index dbab4fd3bf..b648950f18 100644 --- a/packages/arb-token-bridge-ui/src/util/teleports/helpers.ts +++ b/packages/arb-token-bridge-ui/src/util/teleports/helpers.ts @@ -10,7 +10,7 @@ import { MergedTransaction } from '../../state/app/state' import { FetchEthTeleportsFromSubgraphResult } from './fetchEthTeleportsFromSubgraph' import { TeleportFromSubgraph } from './fetchTeleports' import { AssetType } from '../../hooks/arbTokenBridge.types' -import { Transaction } from '../../hooks/useTransactions' +import { Transaction } from '../../types/Transactions' import { transformDeposit } from '../../state/app/utils' import { updateAdditionalDepositData } from '../deposits/helpers' import { fetchErc20Data } from '../TokenUtils'