From 171eea0040e5417e14b1f77ca8f4c9f0464ec9dd Mon Sep 17 00:00:00 2001 From: Bartek Date: Wed, 23 Oct 2024 17:32:40 +0200 Subject: [PATCH] clean up --- .github/workflows/e2e-tests.yml | 2 +- .github/workflows/formatSpecfiles.js | 2 -- .../TransferPanel/TransferPanel.tsx | 18 ++--------- .../src/util/TokenUtils.ts | 31 ------------------- .../src/util/withdrawals/helpers.ts | 3 +- .../arb-token-bridge-ui/synpress.config.ts | 2 -- 6 files changed, 5 insertions(+), 53 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index a4c5c1e01b..c48b496c40 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -96,7 +96,7 @@ jobs: if: inputs.test_type != 'cctp' uses: OffchainLabs/actions/run-nitro-test-node@a20a76172ce524832ac897bef2fa10a62ed81c29 with: - nitro-testnode-ref: adapt-bridge-amount + nitro-testnode-ref: badbcbea9b43d46e115da4d7c9f2f57c31af8431 l3-node: ${{ matrix.test.type != 'regular' }} no-l3-token-bridge: ${{ matrix.test.type == 'regular' }} args: >- diff --git a/.github/workflows/formatSpecfiles.js b/.github/workflows/formatSpecfiles.js index 9948ac5b19..3d1976daae 100644 --- a/.github/workflows/formatSpecfiles.js +++ b/.github/workflows/formatSpecfiles.js @@ -32,7 +32,6 @@ switch (testType) { ...spec, type: "orbit-custom-20dec", typeName: "with L3 (20 decimals custom)", - testnodeArgs: "--l3node --l3-token-bridge --l3-fee-token --l3-fee-token-decimals 20", }); }); break; @@ -42,7 +41,6 @@ switch (testType) { tests.push({ name: "cctp", typeName: "", - testnodeArgs: "", file: "tests/e2e/specs/**/*Cctp.cy.{js,jsx,ts,tsx}", recordVideo: false, type: "cctp", diff --git a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanel.tsx b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanel.tsx index 09622e02a4..0ee92a9000 100644 --- a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanel.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanel.tsx @@ -6,6 +6,7 @@ import { useLatest } from 'react-use' import { useAccount, useNetwork, useSigner } from 'wagmi' import { TransactionResponse } from '@ethersproject/providers' import { twMerge } from 'tailwind-merge' +import { scaleToNativeTokenDecimals } from '@arbitrum/sdk/dist/lib/utils/lib' import { useAppState } from '../../state' import { getNetworkName, isNetwork } from '../../util/networks' @@ -22,10 +23,7 @@ import { TransferPanelSummary } from './TransferPanelSummary' import { useAppContextActions } from '../App/AppContext' import { trackEvent } from '../../util/AnalyticsUtils' import { TransferPanelMain } from './TransferPanelMain' -import { - isGatewayRegistered, - scaleToNativeTokenDecimals -} from '../../util/TokenUtils' +import { isGatewayRegistered } from '../../util/TokenUtils' import { useSwitchNetworkWithConfig } from '../../hooks/useSwitchNetworkWithConfig' import { errorToast, warningToast } from '../common/atoms/Toast' import { useAccountType } from '../../hooks/useAccountType' @@ -692,8 +690,6 @@ export function TransferPanel() { if (!withdrawalConfirmation) return false } - console.warn('decimals: ', nativeCurrencyDecimalsOnSourceChain) - // token approval if (selectedToken) { const isTokenApprovalRequired = @@ -720,15 +716,6 @@ export function TransferPanel() { } } - const isTokenApprovalRequired_TestCheck = - await bridgeTransferStarter.requiresTokenApproval({ - amount: amountBigNumber, - signer, - destinationAddress - }) - - console.warn({ isTokenApprovalRequired_TestCheck }) - // show a delay in case of SCW because tx is executed in an external app if (isSmartContractWallet) { showDelayInSmartContractTransaction() @@ -788,7 +775,6 @@ export function TransferPanel() { } : { transfer_type: 'native currency' } }) - console.warn({ error }) } finally { setTransferring(false) } diff --git a/packages/arb-token-bridge-ui/src/util/TokenUtils.ts b/packages/arb-token-bridge-ui/src/util/TokenUtils.ts index 7c79df9893..fe3ddb12ee 100644 --- a/packages/arb-token-bridge-ui/src/util/TokenUtils.ts +++ b/packages/arb-token-bridge-ui/src/util/TokenUtils.ts @@ -502,34 +502,3 @@ export async function isGatewayRegistered({ childProvider: childChainProvider }) } - -export function scaleToNativeTokenDecimals({ - amount, - decimals -}: { - amount: BigNumber - decimals: number -}) { - // do nothing for 18 decimals - if (decimals === 18) { - return amount - } - - if (decimals < 18) { - const scaledAmount = amount.div( - BigNumber.from(10).pow(BigNumber.from(18 - decimals)) - ) - // round up if necessary - if ( - scaledAmount - .mul(BigNumber.from(10).pow(BigNumber.from(18 - decimals))) - .lt(amount) - ) { - return scaledAmount.add(BigNumber.from(1)) - } - return scaledAmount - } - - // decimals > 18 - return amount.mul(BigNumber.from(10).pow(BigNumber.from(decimals - 18))) -} diff --git a/packages/arb-token-bridge-ui/src/util/withdrawals/helpers.ts b/packages/arb-token-bridge-ui/src/util/withdrawals/helpers.ts index 7fca2fa10a..546bffdd8f 100644 --- a/packages/arb-token-bridge-ui/src/util/withdrawals/helpers.ts +++ b/packages/arb-token-bridge-ui/src/util/withdrawals/helpers.ts @@ -5,8 +5,9 @@ import { ChildToParentMessageReader, ChildTransactionReceipt } from '@arbitrum/sdk' +import { scaleToNativeTokenDecimals } from '@arbitrum/sdk/dist/lib/utils/lib' import { FetchWithdrawalsFromSubgraphResult } from './fetchWithdrawalsFromSubgraph' -import { fetchErc20Data, scaleToNativeTokenDecimals } from '../TokenUtils' +import { fetchErc20Data } from '../TokenUtils' import { AssetType, L2ToL1EventResult, diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index c583f2ecaf..84a332c1b0 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -91,8 +91,6 @@ export default defineConfig({ ) } - console.log({ isCustomFeeToken }) - const userWalletAddress = await userWallet.getAddress() // Fund the userWallet. We do this to run tests on a small amount of ETH.