From b921957025a128801479c250480f36bdc41b3119 Mon Sep 17 00:00:00 2001 From: Dewansh Date: Mon, 27 Nov 2023 19:49:58 +0530 Subject: [PATCH 1/3] chore: add RDNT to withdraw only list (#1309) --- .../arb-token-bridge-ui/src/util/WithdrawOnlyUtils.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/arb-token-bridge-ui/src/util/WithdrawOnlyUtils.ts b/packages/arb-token-bridge-ui/src/util/WithdrawOnlyUtils.ts index 881eca1cca..81f806d798 100644 --- a/packages/arb-token-bridge-ui/src/util/WithdrawOnlyUtils.ts +++ b/packages/arb-token-bridge-ui/src/util/WithdrawOnlyUtils.ts @@ -1,3 +1,6 @@ +// tokens that can't be bridged to Arbitrum (maybe coz they have their native protocol bridges and custom implementation or they are being discontinued) +// the UI doesn't let users deposit such tokens. If bridged already, these can only be withdrawn. + import { ChainId } from '../util/networks' export type WithdrawOnlyToken = { @@ -116,6 +119,12 @@ const withdrawOnlyTokens: { [chainId: number]: WithdrawOnlyToken[] } = { l2CustomAddr: '0x6c84a8f1c29108F47a79964b5Fe888D4f4D0dE40', l1Address: '0x18084fba666a33d37592fa2633fd49a74dd93a88', l2Address: '0x7E2a1eDeE171C5B19E6c54D73752396C0A572594' + }, + { + symbol: 'RDNT', + l2CustomAddr: '0x3082CC23568eA640225c2467653dB90e9250AaA0', + l1Address: '0x137dDB47Ee24EaA998a535Ab00378d6BFa84F893', + l2Address: '0xa4431f62db9955bfd056c30e5ae703bf0d0eaec8' } ], [ChainId.ArbitrumNova]: [] From 0c61396e233281c112311aec48cd76a882978907 Mon Sep 17 00:00:00 2001 From: Fionna Chan <13184582+fionnachan@users.noreply.github.com> Date: Tue, 28 Nov 2023 13:51:16 +0000 Subject: [PATCH 2/3] build: update tailwind merge (#1315) --- packages/arb-token-bridge-ui/package.json | 2 +- yarn.lock | 27 ++++++++++++++--------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/packages/arb-token-bridge-ui/package.json b/packages/arb-token-bridge-ui/package.json index bdd360c880..1700bb8918 100644 --- a/packages/arb-token-bridge-ui/package.json +++ b/packages/arb-token-bridge-ui/package.json @@ -41,7 +41,7 @@ "react-use": "^17.2.4", "react-virtualized": "^9.22.3", "swr": "^2.1.2", - "tailwind-merge": "^0.9.0", + "tailwind-merge": "^2.0.0", "use-query-params": "^2.1.1", "wagmi": "^0.12.18", "zod": "^3.22.4", diff --git a/yarn.lock b/yarn.lock index a380daa7c0..9d8cf41497 100644 --- a/yarn.lock +++ b/yarn.lock @@ -378,6 +378,13 @@ dependencies: regenerator-runtime "^0.13.11" +"@babel/runtime@^7.23.1": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.23.4.tgz#36fa1d2b36db873d25ec631dcc4923fdc1cf2e2e" + integrity sha512-2Yv65nlWnWlSpe3fXEyX5i7fx5kIKo4Qbcj+hMO0odwaneFjfXw5fdum+4yL20O0QiaHpia0cYQ9xpNMqrBwHg== + dependencies: + regenerator-runtime "^0.14.0" + "@babel/template@^7.22.15": version "7.22.15" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.22.15.tgz#09576efc3830f0430f4548ef971dde1350ef2f38" @@ -6578,11 +6585,6 @@ hasha@^5.0.0: is-stream "^2.0.0" type-fest "^0.8.0" -hashlru@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/hashlru/-/hashlru-2.3.0.tgz#5dc15928b3f6961a2056416bb3a4910216fdfb51" - integrity sha512-0cMsjjIC8I+D3M44pOQdsy0OHXGLVz6Z0beRuufhKa0KfaD2wGwAev6jILzXsd3/vpnNQJmWyZtIILqM1N+n5A== - he@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" @@ -9672,6 +9674,11 @@ regenerator-runtime@^0.13.11: resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9" integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg== +regenerator-runtime@^0.14.0: + version "0.14.0" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.14.0.tgz#5e19d68eb12d486f797e15a3c6a918f7cec5eb45" + integrity sha512-srw17NI0TUWHuGa5CFGGmhfNIeja30WMBfbslPNhf6JrqQlLN5gcrvig1oqPxiVaXb0oW0XRKtH6Nngs5lKCIA== + regexp.prototype.flags@^1.4.3, regexp.prototype.flags@^1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.5.0.tgz#fe7ce25e7e4cca8db37b6634c8a2c7009199b9cb" @@ -10674,12 +10681,12 @@ table@^6.0.9: string-width "^4.2.3" strip-ansi "^6.0.1" -tailwind-merge@^0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/tailwind-merge/-/tailwind-merge-0.9.0.tgz#3c7df4983515d291cc1136dd9269c7e8d8d37c7e" - integrity sha512-nHI0CoAAais8+0lwIiDposkhmdr4ejRVZxJH8bzZFbB7d6/jkciyl9lgHmkNpCJ0MMYi4Xg8JjHXZX7/67g3Tw== +tailwind-merge@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/tailwind-merge/-/tailwind-merge-2.0.0.tgz#a0f3a8c874ebae5feec5595614d08245a5f88a39" + integrity sha512-WO8qghn9yhsldLSg80au+3/gY9E4hFxIvQ3qOmlpXnqpDKoMruKfi/56BbbMg6fHTQJ9QD3cc79PoWqlaQE4rw== dependencies: - hashlru "^2.3.0" + "@babel/runtime" "^7.23.1" tailwindcss@^3.2.4: version "3.3.2" From 33d0fcd31314b43e7654045827b86351ca4c351b Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 28 Nov 2023 17:37:12 +0100 Subject: [PATCH 3/3] refactor: transform single tx instead of array (#1310) --- .../src/hooks/useDeposits.ts | 4 +- .../src/hooks/useWithdrawals.ts | 8 +- .../src/state/app/state.ts | 12 +- .../src/state/app/utils.ts | 124 +++++++++--------- 4 files changed, 71 insertions(+), 77 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/hooks/useDeposits.ts b/packages/arb-token-bridge-ui/src/hooks/useDeposits.ts index 15d479fa4c..5e3fba5c5c 100644 --- a/packages/arb-token-bridge-ui/src/hooks/useDeposits.ts +++ b/packages/arb-token-bridge-ui/src/hooks/useDeposits.ts @@ -4,7 +4,7 @@ import { useAccount, useChainId } from 'wagmi' import { PageParams } from '../components/TransactionHistory/TransactionsTable/TransactionsTable' import { MergedTransaction } from '../state/app/state' -import { isPending, transformDeposits } from '../state/app/utils' +import { isPending, transformDeposit } from '../state/app/utils' import { FetchDepositParams, fetchDeposits @@ -31,7 +31,7 @@ export const fetchCompleteDepositData = async ( // filter out pending deposits const pendingDepositsMap = new Map() // get their complete transformed data (so that we get their exact status) - const completeDepositData = transformDeposits(deposits) + const completeDepositData = deposits.map(transformDeposit) completeDepositData.forEach(completeTxData => { if (isPending(completeTxData)) { pendingDepositsMap.set(completeTxData.txId, true) diff --git a/packages/arb-token-bridge-ui/src/hooks/useWithdrawals.ts b/packages/arb-token-bridge-ui/src/hooks/useWithdrawals.ts index 10a5e6852a..c10a00edd3 100644 --- a/packages/arb-token-bridge-ui/src/hooks/useWithdrawals.ts +++ b/packages/arb-token-bridge-ui/src/hooks/useWithdrawals.ts @@ -4,7 +4,7 @@ import { useAccount, useChainId } from 'wagmi' import { PageParams } from '../components/TransactionHistory/TransactionsTable/TransactionsTable' import { MergedTransaction } from '../state/app/state' -import { isPending, transformWithdrawals } from '../state/app/utils' +import { isPending, transformWithdrawal } from '../state/app/utils' import { FetchWithdrawalsParams, fetchWithdrawals @@ -31,9 +31,9 @@ const fetchCompleteWithdrawalData = async ( // filter out pending withdrawals const pendingWithdrawalMap = new Map() - const completeWithdrawalData = transformWithdrawals( - withdrawals.sort((msgA, msgB) => +msgB.timestamp - +msgA.timestamp) - ) + const completeWithdrawalData = withdrawals + .sort((msgA, msgB) => +msgB.timestamp - +msgA.timestamp) + .map(transformWithdrawal) completeWithdrawalData.forEach(completeTxData => { if (isPending(completeTxData)) { 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 738543d022..0a3d72d717 100644 --- a/packages/arb-token-bridge-ui/src/state/app/state.ts +++ b/packages/arb-token-bridge-ui/src/state/app/state.ts @@ -11,8 +11,8 @@ import dayjs from 'dayjs' import { filterTransactions, - transformDeposits, - transformWithdrawals + transformDeposit, + transformWithdrawal } from './utils' import { @@ -150,19 +150,19 @@ export const defaultState: AppState = { ) }), depositsTransformed: derived((s: AppState) => { - return transformDeposits( - s.sortedTransactions.filter( + return s.sortedTransactions + .filter( // only take the deposit transactions, rest `outbox`, `approve` etc should not come tx => tx.type === 'deposit' || tx.type === 'deposit-l1' ) - ) + .map(transformDeposit) }), withdrawalsTransformed: derived((s: AppState) => { const withdrawals = Object.values( s.arbTokenBridge?.pendingWithdrawalsMap || [] ) as L2ToL1EventResultPlus[] - return transformWithdrawals(withdrawals) + return withdrawals.map(transformWithdrawal) }), mergedTransactions: derived((s: AppState) => { return _reverse( 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 405c689c01..6599107508 100644 --- a/packages/arb-token-bridge-ui/src/state/app/utils.ts +++ b/packages/arb-token-bridge-ui/src/state/app/utils.ts @@ -54,70 +54,64 @@ export const getDepositStatus = (tx: Transaction) => { } } -export const transformDeposits = ( - deposits: Transaction[] -): MergedTransaction[] => { - return deposits.map(tx => { - return { - sender: tx.sender, - destination: tx.destination, - direction: tx.type, - status: tx.status, - createdAt: tx.timestampCreated - ? getStandardizedTimestamp(tx.timestampCreated) - : null, - resolvedAt: tx.timestampResolved - ? getStandardizedTimestamp(tx.timestampResolved) - : null, - txId: tx.txID, - asset: tx.assetName || '', - assetType: tx.assetType, - value: tx.value, - uniqueId: null, // not needed - isWithdrawal: false, - blockNum: tx.blockNumber || null, - tokenAddress: tx.tokenAddress || null, - l1ToL2MsgData: tx.l1ToL2MsgData, - l2ToL1MsgData: tx.l2ToL1MsgData, - depositStatus: getDepositStatus(tx), - chainId: Number(tx.l2NetworkID), - parentChainId: Number(tx.l1NetworkID) - } - }) +export const transformDeposit = (tx: Transaction): MergedTransaction => { + return { + sender: tx.sender, + destination: tx.destination, + direction: tx.type, + status: tx.status, + createdAt: tx.timestampCreated + ? getStandardizedTimestamp(tx.timestampCreated) + : null, + resolvedAt: tx.timestampResolved + ? getStandardizedTimestamp(tx.timestampResolved) + : null, + txId: tx.txID, + asset: tx.assetName || '', + assetType: tx.assetType, + value: tx.value, + uniqueId: null, // not needed + isWithdrawal: false, + blockNum: tx.blockNumber || null, + tokenAddress: tx.tokenAddress || null, + l1ToL2MsgData: tx.l1ToL2MsgData, + l2ToL1MsgData: tx.l2ToL1MsgData, + depositStatus: getDepositStatus(tx), + chainId: Number(tx.l2NetworkID), + parentChainId: Number(tx.l1NetworkID) + } } -export const transformWithdrawals = ( - withdrawals: L2ToL1EventResultPlus[] -): MergedTransaction[] => { - return withdrawals.map(tx => { - const uniqueIdOrHash = getUniqueIdOrHashFromEvent(tx) - - return { - sender: tx.sender, - destination: tx.destinationAddress, - direction: 'outbox', - status: - tx.nodeBlockDeadline === - NodeBlockDeadlineStatusTypes.EXECUTE_CALL_EXCEPTION - ? 'Failure' - : outgoingStateToString[tx.outgoingMessageState], - createdAt: getStandardizedTimestamp( - String(BigNumber.from(tx.timestamp).toNumber() * 1000) - ), - resolvedAt: null, - txId: tx.l2TxHash || 'l2-tx-hash-not-found', - asset: tx.symbol || '', - assetType: tx.type, - value: ethers.utils.formatUnits(tx.value?.toString(), tx.decimals), - uniqueId: uniqueIdOrHash, - isWithdrawal: true, - blockNum: tx.ethBlockNum.toNumber(), - tokenAddress: tx.tokenAddress || null, - nodeBlockDeadline: tx.nodeBlockDeadline, - chainId: tx.chainId, - parentChainId: tx.parentChainId - } - }) +export const transformWithdrawal = ( + tx: L2ToL1EventResultPlus +): MergedTransaction => { + const uniqueIdOrHash = getUniqueIdOrHashFromEvent(tx) + + return { + sender: tx.sender, + destination: tx.destinationAddress, + direction: 'outbox', + status: + tx.nodeBlockDeadline === + NodeBlockDeadlineStatusTypes.EXECUTE_CALL_EXCEPTION + ? 'Failure' + : outgoingStateToString[tx.outgoingMessageState], + createdAt: getStandardizedTimestamp( + String(BigNumber.from(tx.timestamp).toNumber() * 1000) + ), + resolvedAt: null, + txId: tx.l2TxHash || 'l2-tx-hash-not-found', + asset: tx.symbol || '', + assetType: tx.type, + value: ethers.utils.formatUnits(tx.value?.toString(), tx.decimals), + uniqueId: uniqueIdOrHash, + isWithdrawal: true, + blockNum: tx.ethBlockNum.toNumber(), + tokenAddress: tx.tokenAddress || null, + nodeBlockDeadline: tx.nodeBlockDeadline, + chainId: tx.chainId, + parentChainId: tx.parentChainId + } } // filter the transactions based on current wallet address and network ID's @@ -234,9 +228,9 @@ export const findMatchingL1TxForWithdrawal = ( const cachedTransactions: Transaction[] = JSON.parse( window.localStorage.getItem('arbTransactions') || '[]' ) - const outboxTransactions = transformDeposits( - cachedTransactions.filter(tx => tx.type === 'outbox') - ) + const outboxTransactions = cachedTransactions + .filter(tx => tx.type === 'outbox') + .map(transformDeposit) return outboxTransactions.find(_tx => { const l2ToL1MsgData = _tx.l2ToL1MsgData