From 8c26fad663f74fa992505e6ed9dfbefca8b02f82 Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 3 Oct 2024 14:00:51 +0200 Subject: [PATCH 01/99] e2e custom fee token --- .github/workflows/e2e-tests.yml | 18 ++- .github/workflows/formatSpecfiles.js | 6 +- .../arb-token-bridge-ui/src/util/networks.ts | 101 ++++++++++----- .../src/util/wagmi/wagmiAdditionalNetworks.ts | 9 +- .../arb-token-bridge-ui/synpress.config.ts | 120 +++++++++++++++++- 5 files changed, 208 insertions(+), 46 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 298639ae9a..41cf707e39 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -28,8 +28,7 @@ jobs: run: echo "e2eFiles=$(node .github/workflows/formatSpecfiles.js ${{ inputs.test_type }} | jq . --compact-output)" >> $GITHUB_OUTPUT test-e2e: - name: "Test E2E - ${{ matrix.test.name }}${{ matrix.test.type == 'orbit' && ' with L3' || ''}}" - needs: [load-e2e-files] + name: "Test E2E - ${{ matrix.test.name }}${{ matrix.test.type == 'orbit-eth' && ' with L3' matrix.test.type == 'orbit-custom' && ' with custom fee token' || ''}}" needs: [load-e2e-files] runs-on: ubuntu-latest strategy: fail-fast: false @@ -92,14 +91,19 @@ jobs: uses: OffchainLabs/actions/run-nitro-test-node@a20a76172ce524832ac897bef2fa10a62ed81c29 with: nitro-testnode-ref: aab133aceadec2e622f15fa438f6327e3165392d - l3-node: ${{ matrix.test.type == 'orbit' }} - no-l3-token-bridge: ${{ matrix.test.type != 'orbit' }} + l3-node: ${{ matrix.test.type != 'regular' }} + no-l3-token-bridge: ${{ matrix.test.type == 'regular' }} + args: ${{ matrix.test.type == 'orbit-custom' && '--l3-fee-token' || '' }} - name: Run e2e tests via cypress-io/github-action uses: cypress-io/github-action@0da3c06ed8217b912deea9d8ee69630baed1737e # pin@v6.7.6 with: - start: yarn start - command: "yarn test:e2e${{ (matrix.test.type == 'cctp' && ':cctp') || (matrix.test.type == 'orbit' && ':orbit') || '' }} --browser chrome" + start: ${{ matrix.test.type == 'orbit-custom' && 'NEXT_PUBLIC_CUSTOM_FEE_TOKEN=true yarn start' || 'yarn start' }} + command: >- + ${{ + (matrix.test.type != 'regular') && 'yarn test:e2e:orbit --browser chromium' || + 'yarn test:e2e --browser chromium' + }} wait-on: http://127.0.0.1:3000 wait-on-timeout: 120 spec: ./packages/arb-token-bridge-ui/tests/e2e/specs/* @@ -121,7 +125,7 @@ jobs: uses: actions/upload-artifact@v4 if: always() with: - name: e2e-artifacts-${{ github.sha }}-${{ matrix.test.name }}-${{ (matrix.test.type == 'cctp' && 'cctp') || (matrix.test.type == 'orbit' && 'l3') || 'regular'}} + name: e2e-artifacts-${{ github.sha }}-${{ matrix.test.name }}-${{ (matrix.test.type == 'cctp' && 'cctp') || (matrix.test.type == 'orbit-eth' && 'l3') || (matrix.test.type == 'orbit-custom' && 'custom-fee-token') || 'regular'}} path: | ./packages/arb-token-bridge-ui/cypress/videos ./packages/arb-token-bridge-ui/cypress/screenshots diff --git a/.github/workflows/formatSpecfiles.js b/.github/workflows/formatSpecfiles.js index fac4b2f6c2..bb6b23e1ef 100644 --- a/.github/workflows/formatSpecfiles.js +++ b/.github/workflows/formatSpecfiles.js @@ -14,7 +14,11 @@ switch (testType) { }); tests.push({ ...spec, - type: "orbit", + type: "orbit-eth", + }); + tests.push({ + ...spec, + type: "orbit-custom", }); }); break; diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts index 06252531de..fbc60f3b0d 100644 --- a/packages/arb-token-bridge-ui/src/util/networks.ts +++ b/packages/arb-token-bridge-ui/src/util/networks.ts @@ -310,40 +310,73 @@ export const defaultL2Network: ArbitrumNetwork = { } } -export const defaultL3Network: ArbitrumNetwork = { - chainId: 333333, - parentChainId: ChainId.ArbitrumLocal, - confirmPeriodBlocks: 20, - ethBridge: { - bridge: '0xA584795e24628D9c067A6480b033C9E96281fcA3', - inbox: '0xDcA690902d3154886Ec259308258D10EA5450996', - outbox: '0xda243bD61B011024FC923164db75Dde198AC6175', - rollup: process.env.NEXT_PUBLIC_IS_E2E_TEST - ? '0xdeD540257498027B1De7DFD4fe6cc4CeC030F355' - : '0xf9B0F86aCc3e42B7DF373c9a8adb2803BF0a7662', - sequencerInbox: '0x16c54EE2015CD824415c2077F4103f444E00A8cb' - }, - isCustom: true, - isTestnet: true, - name: 'L3 Local', - retryableLifetimeSeconds: 604800, - tokenBridge: { - parentCustomGateway: '0xA191D519260A06b32f8D04c84b9F457B8Caa0514', - parentErc20Gateway: '0x6B0805Fc6e275ef66a0901D0CE68805631E271e5', - parentGatewayRouter: '0xfE03DBdf7A126994dBd749631D7fbaB58C618c58', - parentMultiCall: '0x20a3627Dcc53756E38aE3F92717DE9B23617b422', - parentProxyAdmin: '0x1A61102c26ad3f64bA715B444C93388491fd8E68', - parentWeth: '0xA1abD387192e3bb4e84D3109181F9f005aBaF5CA', - parentWethGateway: '0x77603b0ea6a797C74Fa9ef11b5BdE04A4E03D550', - childCustomGateway: '0xD4816AeF8f85A3C1E01Cd071a81daD4fa941625f', - childErc20Gateway: '0xaa7d51aFFEeB32d99b1CB2fd6d81D7adA4a896e8', - childGatewayRouter: '0x8B6BC759226f8Fe687c8aD8Cc0DbF85E095e9297', - childMultiCall: '0x052B15c8Ff0544287AE689C4F2FC53A3905d7Db3', - childProxyAdmin: '0x36C56eC2CF3a3f53db9F01d0A5Ae84b36fb0A1e2', - childWeth: '0x582a8dBc77f665dF2c49Ce0a138978e9267dd968', - childWethGateway: '0xA6AB233B3c7bfd0399834897b5073974A3D467e2' - } -} +export const defaultL3Network: ArbitrumNetwork = + process.env.NEXT_PUBLIC_CUSTOM_FEE_TOKEN === 'true' + ? { + chainId: 333333, + parentChainId: ChainId.ArbitrumLocal, + confirmPeriodBlocks: 20, + ethBridge: { + bridge: '0xA584795e24628D9c067A6480b033C9E96281fcA3', + inbox: '0xDcA690902d3154886Ec259308258D10EA5450996', + outbox: '0xda243bD61B011024FC923164db75Dde198AC6175', + rollup: '0x7a23F33C1C384eFc11b8Cf207420c464ba2959CC', + sequencerInbox: '0x16c54EE2015CD824415c2077F4103f444E00A8cb' + }, + nativeToken: '0xE069078bA9ACCE4eeAE609d8754515Cf13dd6706', + isCustom: true, + isTestnet: true, + name: 'L3 Local', + retryableLifetimeSeconds: 604800, + tokenBridge: { + parentCustomGateway: '0xCe02eA568090ae7d5184B0a98df90f6aa69C1552', + parentErc20Gateway: '0x59156b0596689D965Ba707E160e5370AF22461a0', + parentGatewayRouter: '0x0C085152C2799834fc1603533ff6916fa1FdA302', + parentMultiCall: '0x20a3627Dcc53756E38aE3F92717DE9B23617b422', + parentProxyAdmin: '0x1A61102c26ad3f64bA715B444C93388491fd8E68', + parentWeth: '0x0000000000000000000000000000000000000000', + parentWethGateway: '0x59156b0596689D965Ba707E160e5370AF22461a0', + childCustomGateway: '0xD4816AeF8f85A3C1E01Cd071a81daD4fa941625f', + childErc20Gateway: '0xaa7d51aFFEeB32d99b1CB2fd6d81D7adA4a896e8', + childGatewayRouter: '0x8B6BC759226f8Fe687c8aD8Cc0DbF85E095e9297', + childMultiCall: '0x052B15c8Ff0544287AE689C4F2FC53A3905d7Db3', + childProxyAdmin: '0x36C56eC2CF3a3f53db9F01d0A5Ae84b36fb0A1e2', + childWeth: '0x0000000000000000000000000000000000000000', + childWethGateway: '0x0000000000000000000000000000000000000000' + } + } + : { + chainId: 333333, + parentChainId: ChainId.ArbitrumLocal, + confirmPeriodBlocks: 20, + ethBridge: { + bridge: '0xA584795e24628D9c067A6480b033C9E96281fcA3', + inbox: '0xDcA690902d3154886Ec259308258D10EA5450996', + outbox: '0xda243bD61B011024FC923164db75Dde198AC6175', + rollup: '0xf9B0F86aCc3e42B7DF373c9a8adb2803BF0a7662', + sequencerInbox: '0x16c54EE2015CD824415c2077F4103f444E00A8cb' + }, + isCustom: true, + isTestnet: true, + name: 'L3 Local', + retryableLifetimeSeconds: 604800, + tokenBridge: { + parentCustomGateway: '0xA191D519260A06b32f8D04c84b9F457B8Caa0514', + parentErc20Gateway: '0x6B0805Fc6e275ef66a0901D0CE68805631E271e5', + parentGatewayRouter: '0xfE03DBdf7A126994dBd749631D7fbaB58C618c58', + parentMultiCall: '0x20a3627Dcc53756E38aE3F92717DE9B23617b422', + parentProxyAdmin: '0x1A61102c26ad3f64bA715B444C93388491fd8E68', + parentWeth: '0xA1abD387192e3bb4e84D3109181F9f005aBaF5CA', + parentWethGateway: '0x77603b0ea6a797C74Fa9ef11b5BdE04A4E03D550', + childCustomGateway: '0xD4816AeF8f85A3C1E01Cd071a81daD4fa941625f', + childErc20Gateway: '0xaa7d51aFFEeB32d99b1CB2fd6d81D7adA4a896e8', + childGatewayRouter: '0x8B6BC759226f8Fe687c8aD8Cc0DbF85E095e9297', + childMultiCall: '0x052B15c8Ff0544287AE689C4F2FC53A3905d7Db3', + childProxyAdmin: '0x36C56eC2CF3a3f53db9F01d0A5Ae84b36fb0A1e2', + childWeth: '0x582a8dBc77f665dF2c49Ce0a138978e9267dd968', + childWethGateway: '0xA6AB233B3c7bfd0399834897b5073974A3D467e2' + } + } export const localL1NetworkRpcUrl = loadEnvironmentVariableWithFallback({ env: process.env.NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL, diff --git a/packages/arb-token-bridge-ui/src/util/wagmi/wagmiAdditionalNetworks.ts b/packages/arb-token-bridge-ui/src/util/wagmi/wagmiAdditionalNetworks.ts index 4ab0f3b6a9..5f4f4e7ef8 100644 --- a/packages/arb-token-bridge-ui/src/util/wagmi/wagmiAdditionalNetworks.ts +++ b/packages/arb-token-bridge-ui/src/util/wagmi/wagmiAdditionalNetworks.ts @@ -11,7 +11,14 @@ export function chainToWagmiChain(chain: ChainWithRpcUrl): Chain { id: chain.chainId, name: chain.name, network: chain.name.toLowerCase().split(' ').join('-'), - nativeCurrency: nativeTokenData ?? ether, + nativeCurrency: + nativeTokenData || process.env.NEXT_PUBLIC_CUSTOM_FEE_TOKEN === 'true' + ? { + name: 'testnode', + symbol: 'TN', + decimals: 18 + } + : ether, rpcUrls: { default: { http: [chain.rpcUrl] diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 7b85b3ede7..1f33282a96 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -10,8 +10,9 @@ import { formatUnits, parseUnits } from 'ethers/lib/utils' import { defineConfig } from 'cypress' import { StaticJsonRpcProvider } from '@ethersproject/providers' import synpressPlugins from '@synthetixio/synpress/plugins' +import { TestERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestERC20__factory' import { TestWETH9__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestWETH9__factory' -import { Erc20Bridger } from '@arbitrum/sdk' +import { Erc20Bridger, EthBridger } from '@arbitrum/sdk' import logsPrinter from 'cypress-terminal-report/src/installLogsPrinter' import { getL2ERC20Address } from './src/util/TokenUtils' import specFiles from './tests/e2e/specfiles.json' @@ -46,11 +47,11 @@ const l1WethGateway = isOrbitTest ? defaultL3Network.tokenBridge!.parentWethGateway : defaultL2Network.tokenBridge!.parentWethGateway -const l1WethAddress = isOrbitTest +let l1WethAddress = isOrbitTest ? defaultL3Network.tokenBridge!.parentWeth : defaultL2Network.tokenBridge!.parentWeth -const l2WethAddress = isOrbitTest +let l2WethAddress = isOrbitTest ? defaultL3Network.tokenBridge!.childWeth : defaultL2Network.tokenBridge!.childWeth @@ -98,10 +99,41 @@ export default defineConfig({ // Deploy and fund ERC20 to Parent and Child chains const l1ERC20Token = await deployERC20ToParentChain() + + // Approve custom fee token if not ETH + await approveCustomFeeToken( + localWallet.connect(parentProvider), + l1ERC20Token.address + ) + await fundUserWalletNativeCurrency() + await fundErc20ToParentChain(l1ERC20Token) await fundErc20ToChildChain(l1ERC20Token) await approveErc20(l1ERC20Token) + if ( + !isNonZeroAddress(l1WethAddress) || + !isNonZeroAddress(l2WethAddress) + ) { + const wethAddresses = await deployWeth(parentProvider) + l1WethAddress = wethAddresses.l1WethAddress + l2WethAddress = wethAddresses.l2WethAddress + } + + const bridger = await Erc20Bridger.fromProvider(childProvider) + const isCustomFeeToken = typeof bridger.nativeToken !== 'undefined' + + const ethBridger = await EthBridger.fromProvider(childProvider) + + await approveCustomFeeToken( + userWallet.connect(parentProvider), + bridger.nativeToken! + ) + + await ethBridger.approveGasToken({ + parentSigner: userWallet.connect(parentProvider) + }) + // Wrap ETH to test WETH transactions and approve it's usage await fundWeth('parentChain') await fundWeth('childChain') @@ -199,6 +231,57 @@ if (!process.env.PRIVATE_KEY_USER) { const localWallet = new Wallet(process.env.PRIVATE_KEY_CUSTOM) const userWallet = new Wallet(process.env.PRIVATE_KEY_USER) +async function approveCustomFeeToken( + signer: Wallet, + erc20ParentAddress: string +) { + const childEthBridger = await EthBridger.fromProvider(childProvider) + const isCustomFeeToken = typeof childEthBridger.nativeToken !== 'undefined' + + if (!isCustomFeeToken) { + return + } + + console.log('Approving custom fee token...') + const childErc20Bridger = await Erc20Bridger.fromProvider(childProvider) + + await childErc20Bridger.approveGasToken({ + parentSigner: signer, + erc20ParentAddress + }) +} + +async function fundUserWalletNativeCurrency() { + const childEthBridger = await EthBridger.fromProvider(childProvider) + const isCustomFeeToken = typeof childEthBridger.nativeToken !== 'undefined' + + if (!isCustomFeeToken) { + return + } + + const address = await userWallet.getAddress() + + const tokenContract = TestERC20__factory.connect( + childEthBridger.nativeToken, + localWallet.connect(parentProvider) + ) + + const userBalance = await tokenContract.balanceOf(address) + const shouldFund = userBalance.lt(utils.parseEther('0.3')) + + if (!shouldFund) { + console.log( + `User wallet has enough L3 native currency for testing, skip funding...` + ) + return + } + + console.log(`Funding native currency to user wallet on L2...`) + + const tx = await tokenContract.transfer(address, utils.parseEther('3')) + await tx.wait() +} + async function deployERC20ToParentChain() { console.log('Deploying ERC20...') const signer = localWallet.connect(parentProvider) @@ -219,6 +302,37 @@ async function deployERC20ToParentChain() { return l1TokenContract } +function isNonZeroAddress(address: string) { + return address !== constants.AddressZero && utils.isAddress(address) +} + +async function deployWeth(provider: StaticJsonRpcProvider) { + const wethFactory = new TestWETH9__factory(localWallet.connect(provider)) + const weth = await wethFactory.deploy('Wrapped Ether', 'WETH') + await weth.deployed() + + const bridger = await Erc20Bridger.fromProvider(childProvider) + const deployOnChildChain = await bridger.deposit({ + amount: BigNumber.from(0), + erc20ParentAddress: weth.address, + parentSigner: localWallet.connect(parentProvider), + childProvider + }) + + await deployOnChildChain.wait() + + const l2WethAddress = await getL2ERC20Address({ + erc20L1Address: weth.address, + l1Provider: parentProvider, + l2Provider: childProvider + }) + + return { + l1WethAddress: weth.address, + l2WethAddress + } +} + async function deployERC20ToChildChain(erc20L1Address: string) { const bridger = await Erc20Bridger.fromProvider(childProvider) const deploy = await bridger.deposit({ From d58b2e8d41c3f89818b3f757b5a7bd8700c03db6 Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 3 Oct 2024 14:44:52 +0200 Subject: [PATCH 02/99] fix --- .github/workflows/e2e-tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 41cf707e39..00fdfe6804 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -28,7 +28,8 @@ jobs: run: echo "e2eFiles=$(node .github/workflows/formatSpecfiles.js ${{ inputs.test_type }} | jq . --compact-output)" >> $GITHUB_OUTPUT test-e2e: - name: "Test E2E - ${{ matrix.test.name }}${{ matrix.test.type == 'orbit-eth' && ' with L3' matrix.test.type == 'orbit-custom' && ' with custom fee token' || ''}}" needs: [load-e2e-files] + name: "Test E2E - ${{ matrix.test.name }}${{ matrix.test.type == 'orbit-eth' && ' with L3' || matrix.test.type == 'orbit-custom' && ' with custom fee token' || ''}}" + needs: [load-e2e-files] runs-on: ubuntu-latest strategy: fail-fast: false From 591f93095fbf30714cff71e12fd34cb707359283 Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 3 Oct 2024 18:30:17 +0200 Subject: [PATCH 03/99] fixes --- .github/workflows/e2e-tests.yml | 5 +- package.json | 3 +- .../arb-token-bridge-ui/src/util/networks.ts | 149 ++++++++++-------- .../src/util/wagmi/wagmiAdditionalNetworks.ts | 21 +-- .../arb-token-bridge-ui/synpress.config.ts | 27 +++- 5 files changed, 116 insertions(+), 89 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 00fdfe6804..4f0adc22ec 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -99,10 +99,11 @@ jobs: - name: Run e2e tests via cypress-io/github-action uses: cypress-io/github-action@0da3c06ed8217b912deea9d8ee69630baed1737e # pin@v6.7.6 with: - start: ${{ matrix.test.type == 'orbit-custom' && 'NEXT_PUBLIC_CUSTOM_FEE_TOKEN=true yarn start' || 'yarn start' }} + start: yarn start command: >- ${{ - (matrix.test.type != 'regular') && 'yarn test:e2e:orbit --browser chromium' || + (matrix.test.type == 'orbit-eth') && 'yarn test:e2e:orbit --browser chromium' || + (matrix.test.type == 'orbit-custom' && 'yarn test:e2e:orbit:custom-gas-token --browser chromium') || 'yarn test:e2e --browser chromium' }} wait-on: http://127.0.0.1:3000 diff --git a/package.json b/package.json index c60ae31523..28b20b0721 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "lint:fix": "yarn workspace arb-token-bridge-ui lint:fix", "test:e2e": "yarn workspace arb-token-bridge-ui env-cmd --silent --file .e2e.env yarn synpress run --configFile synpress.config.ts", "test:e2e:cctp": "yarn test:e2e --configFile synpress.cctp.config.ts", - "test:e2e:orbit": "E2E_ORBIT=true yarn test:e2e" + "test:e2e:orbit": "E2E_ORBIT=true yarn test:e2e", + "test:e2e:orbit:custom-gas-token": "E2E_ORBIT_CUSTOM_GAS_TOKEN=true yarn test:e2e" }, "resolutions": { "**/@walletconnect/ethereum-provider": "2.13.1", diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts index fbc60f3b0d..59f3b36eda 100644 --- a/packages/arb-token-bridge-ui/src/util/networks.ts +++ b/packages/arb-token-bridge-ui/src/util/networks.ts @@ -5,10 +5,12 @@ import { getArbitrumNetworks, registerCustomArbitrumNetwork } from '@arbitrum/sdk' +import { getProviderForChainId } from '@/token-bridge-sdk/utils' import { loadEnvironmentVariableWithFallback } from './index' import { getBridgeUiConfigForChain } from './bridgeUiConfig' import { chainIdToInfuraUrl } from './infura' +import { fetchNativeCurrency } from '../hooks/useNativeCurrency' export enum ChainId { // L1 @@ -310,73 +312,72 @@ export const defaultL2Network: ArbitrumNetwork = { } } -export const defaultL3Network: ArbitrumNetwork = - process.env.NEXT_PUBLIC_CUSTOM_FEE_TOKEN === 'true' - ? { - chainId: 333333, - parentChainId: ChainId.ArbitrumLocal, - confirmPeriodBlocks: 20, - ethBridge: { - bridge: '0xA584795e24628D9c067A6480b033C9E96281fcA3', - inbox: '0xDcA690902d3154886Ec259308258D10EA5450996', - outbox: '0xda243bD61B011024FC923164db75Dde198AC6175', - rollup: '0x7a23F33C1C384eFc11b8Cf207420c464ba2959CC', - sequencerInbox: '0x16c54EE2015CD824415c2077F4103f444E00A8cb' - }, - nativeToken: '0xE069078bA9ACCE4eeAE609d8754515Cf13dd6706', - isCustom: true, - isTestnet: true, - name: 'L3 Local', - retryableLifetimeSeconds: 604800, - tokenBridge: { - parentCustomGateway: '0xCe02eA568090ae7d5184B0a98df90f6aa69C1552', - parentErc20Gateway: '0x59156b0596689D965Ba707E160e5370AF22461a0', - parentGatewayRouter: '0x0C085152C2799834fc1603533ff6916fa1FdA302', - parentMultiCall: '0x20a3627Dcc53756E38aE3F92717DE9B23617b422', - parentProxyAdmin: '0x1A61102c26ad3f64bA715B444C93388491fd8E68', - parentWeth: '0x0000000000000000000000000000000000000000', - parentWethGateway: '0x59156b0596689D965Ba707E160e5370AF22461a0', - childCustomGateway: '0xD4816AeF8f85A3C1E01Cd071a81daD4fa941625f', - childErc20Gateway: '0xaa7d51aFFEeB32d99b1CB2fd6d81D7adA4a896e8', - childGatewayRouter: '0x8B6BC759226f8Fe687c8aD8Cc0DbF85E095e9297', - childMultiCall: '0x052B15c8Ff0544287AE689C4F2FC53A3905d7Db3', - childProxyAdmin: '0x36C56eC2CF3a3f53db9F01d0A5Ae84b36fb0A1e2', - childWeth: '0x0000000000000000000000000000000000000000', - childWethGateway: '0x0000000000000000000000000000000000000000' - } - } - : { - chainId: 333333, - parentChainId: ChainId.ArbitrumLocal, - confirmPeriodBlocks: 20, - ethBridge: { - bridge: '0xA584795e24628D9c067A6480b033C9E96281fcA3', - inbox: '0xDcA690902d3154886Ec259308258D10EA5450996', - outbox: '0xda243bD61B011024FC923164db75Dde198AC6175', - rollup: '0xf9B0F86aCc3e42B7DF373c9a8adb2803BF0a7662', - sequencerInbox: '0x16c54EE2015CD824415c2077F4103f444E00A8cb' - }, - isCustom: true, - isTestnet: true, - name: 'L3 Local', - retryableLifetimeSeconds: 604800, - tokenBridge: { - parentCustomGateway: '0xA191D519260A06b32f8D04c84b9F457B8Caa0514', - parentErc20Gateway: '0x6B0805Fc6e275ef66a0901D0CE68805631E271e5', - parentGatewayRouter: '0xfE03DBdf7A126994dBd749631D7fbaB58C618c58', - parentMultiCall: '0x20a3627Dcc53756E38aE3F92717DE9B23617b422', - parentProxyAdmin: '0x1A61102c26ad3f64bA715B444C93388491fd8E68', - parentWeth: '0xA1abD387192e3bb4e84D3109181F9f005aBaF5CA', - parentWethGateway: '0x77603b0ea6a797C74Fa9ef11b5BdE04A4E03D550', - childCustomGateway: '0xD4816AeF8f85A3C1E01Cd071a81daD4fa941625f', - childErc20Gateway: '0xaa7d51aFFEeB32d99b1CB2fd6d81D7adA4a896e8', - childGatewayRouter: '0x8B6BC759226f8Fe687c8aD8Cc0DbF85E095e9297', - childMultiCall: '0x052B15c8Ff0544287AE689C4F2FC53A3905d7Db3', - childProxyAdmin: '0x36C56eC2CF3a3f53db9F01d0A5Ae84b36fb0A1e2', - childWeth: '0x582a8dBc77f665dF2c49Ce0a138978e9267dd968', - childWethGateway: '0xA6AB233B3c7bfd0399834897b5073974A3D467e2' - } - } +export const defaultL3Network: ArbitrumNetwork = { + chainId: 333333, + parentChainId: ChainId.ArbitrumLocal, + confirmPeriodBlocks: 20, + ethBridge: { + bridge: '0xA584795e24628D9c067A6480b033C9E96281fcA3', + inbox: '0xDcA690902d3154886Ec259308258D10EA5450996', + outbox: '0xda243bD61B011024FC923164db75Dde198AC6175', + rollup: '0x7a23F33C1C384eFc11b8Cf207420c464ba2959CC', + sequencerInbox: '0x16c54EE2015CD824415c2077F4103f444E00A8cb' + }, + nativeToken: '0xE069078bA9ACCE4eeAE609d8754515Cf13dd6706', + isCustom: true, + isTestnet: true, + name: 'L3 Local', + retryableLifetimeSeconds: 604800, + tokenBridge: { + parentCustomGateway: '0xCe02eA568090ae7d5184B0a98df90f6aa69C1552', + parentErc20Gateway: '0x59156b0596689D965Ba707E160e5370AF22461a0', + parentGatewayRouter: '0x0C085152C2799834fc1603533ff6916fa1FdA302', + parentMultiCall: '0x20a3627Dcc53756E38aE3F92717DE9B23617b422', + parentProxyAdmin: '0x1A61102c26ad3f64bA715B444C93388491fd8E68', + parentWeth: '0x0000000000000000000000000000000000000000', + parentWethGateway: '0x59156b0596689D965Ba707E160e5370AF22461a0', + childCustomGateway: '0xD4816AeF8f85A3C1E01Cd071a81daD4fa941625f', + childErc20Gateway: '0xaa7d51aFFEeB32d99b1CB2fd6d81D7adA4a896e8', + childGatewayRouter: '0x8B6BC759226f8Fe687c8aD8Cc0DbF85E095e9297', + childMultiCall: '0x052B15c8Ff0544287AE689C4F2FC53A3905d7Db3', + childProxyAdmin: '0x36C56eC2CF3a3f53db9F01d0A5Ae84b36fb0A1e2', + childWeth: '0x0000000000000000000000000000000000000000', + childWethGateway: '0x0000000000000000000000000000000000000000' + } +} + +export const defaultL3CustomGasTokenNetwork = { + chainId: 333333, + parentChainId: ChainId.ArbitrumLocal, + confirmPeriodBlocks: 20, + ethBridge: { + bridge: '0xA584795e24628D9c067A6480b033C9E96281fcA3', + inbox: '0xDcA690902d3154886Ec259308258D10EA5450996', + outbox: '0xda243bD61B011024FC923164db75Dde198AC6175', + rollup: '0xf9B0F86aCc3e42B7DF373c9a8adb2803BF0a7662', + sequencerInbox: '0x16c54EE2015CD824415c2077F4103f444E00A8cb' + }, + isCustom: true, + isTestnet: true, + name: 'L3 Local', + retryableLifetimeSeconds: 604800, + tokenBridge: { + parentCustomGateway: '0xA191D519260A06b32f8D04c84b9F457B8Caa0514', + parentErc20Gateway: '0x6B0805Fc6e275ef66a0901D0CE68805631E271e5', + parentGatewayRouter: '0xfE03DBdf7A126994dBd749631D7fbaB58C618c58', + parentMultiCall: '0x20a3627Dcc53756E38aE3F92717DE9B23617b422', + parentProxyAdmin: '0x1A61102c26ad3f64bA715B444C93388491fd8E68', + parentWeth: '0xA1abD387192e3bb4e84D3109181F9f005aBaF5CA', + parentWethGateway: '0x77603b0ea6a797C74Fa9ef11b5BdE04A4E03D550', + childCustomGateway: '0xD4816AeF8f85A3C1E01Cd071a81daD4fa941625f', + childErc20Gateway: '0xaa7d51aFFEeB32d99b1CB2fd6d81D7adA4a896e8', + childGatewayRouter: '0x8B6BC759226f8Fe687c8aD8Cc0DbF85E095e9297', + childMultiCall: '0x052B15c8Ff0544287AE689C4F2FC53A3905d7Db3', + childProxyAdmin: '0x36C56eC2CF3a3f53db9F01d0A5Ae84b36fb0A1e2', + childWeth: '0x582a8dBc77f665dF2c49Ce0a138978e9267dd968', + childWethGateway: '0xA6AB233B3c7bfd0399834897b5073974A3D467e2' + } +} export const localL1NetworkRpcUrl = loadEnvironmentVariableWithFallback({ env: process.env.NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL, @@ -391,14 +392,24 @@ export const localL3NetworkRpcUrl = loadEnvironmentVariableWithFallback({ fallback: 'http://127.0.0.1:3347' }) -export function registerLocalNetwork() { +export async function registerLocalNetwork() { try { rpcURLs[defaultL1Network.chainId] = localL1NetworkRpcUrl rpcURLs[defaultL2Network.chainId] = localL2NetworkRpcUrl + + const l3LocalProvider = getProviderForChainId(ChainId.L3Local) + const nativeCurrency = await fetchNativeCurrency({ + provider: l3LocalProvider + }) + rpcURLs[defaultL3Network.chainId] = localL3NetworkRpcUrl registerCustomArbitrumNetwork(defaultL2Network) - registerCustomArbitrumNetwork(defaultL3Network) + registerCustomArbitrumNetwork( + nativeCurrency.isCustom + ? defaultL3CustomGasTokenNetwork + : defaultL3Network + ) } catch (error: any) { console.error(`Failed to register local network: ${error.message}`) } diff --git a/packages/arb-token-bridge-ui/src/util/wagmi/wagmiAdditionalNetworks.ts b/packages/arb-token-bridge-ui/src/util/wagmi/wagmiAdditionalNetworks.ts index 5f4f4e7ef8..bc063d4e82 100644 --- a/packages/arb-token-bridge-ui/src/util/wagmi/wagmiAdditionalNetworks.ts +++ b/packages/arb-token-bridge-ui/src/util/wagmi/wagmiAdditionalNetworks.ts @@ -5,20 +5,23 @@ import { ChainId, ChainWithRpcUrl, explorerUrls, rpcURLs } from '../networks' import { getBridgeUiConfigForChain } from '../bridgeUiConfig' export function chainToWagmiChain(chain: ChainWithRpcUrl): Chain { - const { nativeTokenData } = getBridgeUiConfigForChain(chain.chainId) + let { nativeTokenData } = getBridgeUiConfigForChain(chain.chainId) + + if (chain.chainId === ChainId.L3Local) { + nativeTokenData = chain.nativeToken + ? { + name: 'testnode', + symbol: 'TN', + decimals: 18 + } + : ether + } return { id: chain.chainId, name: chain.name, network: chain.name.toLowerCase().split(' ').join('-'), - nativeCurrency: - nativeTokenData || process.env.NEXT_PUBLIC_CUSTOM_FEE_TOKEN === 'true' - ? { - name: 'testnode', - symbol: 'TN', - decimals: 18 - } - : ether, + nativeCurrency: nativeTokenData || ether, rpcUrls: { default: { http: [chain.rpcUrl] diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 1f33282a96..5e7af3a6f7 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -32,6 +32,7 @@ import { import { defaultL2Network, defaultL3Network, + defaultL3CustomGasTokenNetwork, registerLocalNetwork } from './src/util/networks' import { getCommonSynpressConfig } from './tests/e2e/getCommonSynpressConfig' @@ -40,19 +41,27 @@ const tests = process.env.TEST_FILE ? [process.env.TEST_FILE] : specFiles.map(file => file.file) -const isOrbitTest = process.env.E2E_ORBIT == 'true' +const isOrbitTest = [ + process.env.E2E_ORBIT, + process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN +].includes('true') const shouldRecordVideo = process.env.CYPRESS_RECORD_VIDEO === 'true' +const l3Network = + process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' + ? defaultL3CustomGasTokenNetwork + : defaultL3Network + const l1WethGateway = isOrbitTest - ? defaultL3Network.tokenBridge!.parentWethGateway + ? l3Network.tokenBridge!.parentWethGateway : defaultL2Network.tokenBridge!.parentWethGateway let l1WethAddress = isOrbitTest - ? defaultL3Network.tokenBridge!.parentWeth + ? l3Network.tokenBridge!.parentWeth : defaultL2Network.tokenBridge!.parentWeth let l2WethAddress = isOrbitTest - ? defaultL3Network.tokenBridge!.childWeth + ? l3Network.tokenBridge!.childWeth : defaultL2Network.tokenBridge!.childWeth export default defineConfig({ @@ -60,7 +69,7 @@ export default defineConfig({ e2e: { async setupNodeEvents(on, config) { logsPrinter(on) - registerLocalNetwork() + await registerLocalNetwork() if (!ethRpcUrl && !isOrbitTest) { throw new Error('NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL variable missing.') @@ -130,9 +139,11 @@ export default defineConfig({ bridger.nativeToken! ) - await ethBridger.approveGasToken({ - parentSigner: userWallet.connect(parentProvider) - }) + if (isCustomFeeToken) { + await ethBridger.approveGasToken({ + parentSigner: userWallet.connect(parentProvider) + }) + } // Wrap ETH to test WETH transactions and approve it's usage await fundWeth('parentChain') From b8826602eb98f3a47891f1869bfe0a21ded11164 Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 3 Oct 2024 18:58:18 +0200 Subject: [PATCH 04/99] fix --- packages/arb-token-bridge-ui/src/util/networks.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts index 59f3b36eda..b0272c0fdd 100644 --- a/packages/arb-token-bridge-ui/src/util/networks.ts +++ b/packages/arb-token-bridge-ui/src/util/networks.ts @@ -5,7 +5,7 @@ import { getArbitrumNetworks, registerCustomArbitrumNetwork } from '@arbitrum/sdk' -import { getProviderForChainId } from '@/token-bridge-sdk/utils' +import { StaticJsonRpcProvider } from '@ethersproject/providers' import { loadEnvironmentVariableWithFallback } from './index' import { getBridgeUiConfigForChain } from './bridgeUiConfig' @@ -396,14 +396,16 @@ export async function registerLocalNetwork() { try { rpcURLs[defaultL1Network.chainId] = localL1NetworkRpcUrl rpcURLs[defaultL2Network.chainId] = localL2NetworkRpcUrl + rpcURLs[defaultL3Network.chainId] = localL3NetworkRpcUrl - const l3LocalProvider = getProviderForChainId(ChainId.L3Local) + const l3LocalProvider = new StaticJsonRpcProvider( + localL3NetworkRpcUrl, + ChainId.L3Local + ) const nativeCurrency = await fetchNativeCurrency({ provider: l3LocalProvider }) - rpcURLs[defaultL3Network.chainId] = localL3NetworkRpcUrl - registerCustomArbitrumNetwork(defaultL2Network) registerCustomArbitrumNetwork( nativeCurrency.isCustom From 56ff3a2b903983603803b8a9555d879e32101e4b Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 3 Oct 2024 20:30:38 +0200 Subject: [PATCH 05/99] bump nitro ref --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 4f0adc22ec..ee10d7ac63 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -91,7 +91,7 @@ jobs: if: inputs.test_type != 'cctp' uses: OffchainLabs/actions/run-nitro-test-node@a20a76172ce524832ac897bef2fa10a62ed81c29 with: - nitro-testnode-ref: aab133aceadec2e622f15fa438f6327e3165392d + nitro-testnode-ref: badbcbea9b43d46e115da4d7c9f2f57c31af8431 l3-node: ${{ matrix.test.type != 'regular' }} no-l3-token-bridge: ${{ matrix.test.type == 'regular' }} args: ${{ matrix.test.type == 'orbit-custom' && '--l3-fee-token' || '' }} From 803da84ad76b1c2aa7b25f53a040956caca501d4 Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 4 Oct 2024 11:44:50 +0200 Subject: [PATCH 06/99] use different deployer wallet --- packages/arb-token-bridge-ui/synpress.config.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 5e7af3a6f7..6d61d1dc85 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -239,7 +239,10 @@ if (!process.env.PRIVATE_KEY_USER) { throw new Error('PRIVATE_KEY_USER variable missing.') } -const localWallet = new Wallet(process.env.PRIVATE_KEY_CUSTOM) +// const localWallet = new Wallet(process.env.PRIVATE_KEY_CUSTOM) +const localWallet = new Wallet( + utils.sha256(utils.toUtf8Bytes('user_fee_token_deployer')) +) const userWallet = new Wallet(process.env.PRIVATE_KEY_USER) async function approveCustomFeeToken( From 9ae9435cc2f8fe58d49e40edad98dba4355907ce Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 4 Oct 2024 12:17:18 +0200 Subject: [PATCH 07/99] fix --- packages/arb-token-bridge-ui/synpress.config.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 6d61d1dc85..1540cca687 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -182,6 +182,13 @@ export default defineConfig({ config.env.L1_WETH_ADDRESS = l1WethAddress config.env.L2_WETH_ADDRESS = l2WethAddress + if (isCustomFeeToken) { + await approveCustomFeeToken( + localWallet, + l3Network.tokenBridge?.childWethGateway! + ) + } + config.env.REDEEM_RETRYABLE_TEST_TX = await generateTestTxForRedeemRetryable() @@ -239,9 +246,10 @@ if (!process.env.PRIVATE_KEY_USER) { throw new Error('PRIVATE_KEY_USER variable missing.') } -// const localWallet = new Wallet(process.env.PRIVATE_KEY_CUSTOM) const localWallet = new Wallet( - utils.sha256(utils.toUtf8Bytes('user_fee_token_deployer')) + process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN + ? utils.sha256(utils.toUtf8Bytes('user_fee_token_deployer')) + : process.env.PRIVATE_KEY_CUSTOM ) const userWallet = new Wallet(process.env.PRIVATE_KEY_USER) From a664e5455f424697c9a7f9c6eaf89ddf1c6ad31b Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 4 Oct 2024 12:37:31 +0200 Subject: [PATCH 08/99] fix --- packages/arb-token-bridge-ui/synpress.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 1540cca687..7a55e1d189 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -184,7 +184,7 @@ export default defineConfig({ if (isCustomFeeToken) { await approveCustomFeeToken( - localWallet, + userWallet.connect(parentProvider), l3Network.tokenBridge?.childWethGateway! ) } From 6972d526af7ec524af029ca116e3088a9b1d6409 Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 4 Oct 2024 13:28:55 +0200 Subject: [PATCH 09/99] fixes --- .../arb-token-bridge-ui/synpress.config.ts | 10 ++++++- .../tests/support/common.ts | 27 ++++++++++++++----- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 7a55e1d189..50760bd872 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -157,7 +157,15 @@ export default defineConfig({ wallet: localWallet }) // Also keep watching assertions since they will act as a proof of activity and claims for withdrawals - checkForAssertions({ parentProvider, isOrbitTest }) + checkForAssertions({ + parentProvider, + testType: + process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' + ? 'orbit-custom' + : process.env.E2E_ORBIT === 'true' + ? 'orbit-eth' + : 'regular' + }) // Set Cypress variables config.env.ETH_RPC_URL = isOrbitTest ? arbRpcUrl : ethRpcUrl diff --git a/packages/arb-token-bridge-ui/tests/support/common.ts b/packages/arb-token-bridge-ui/tests/support/common.ts index 575bba6e4d..bf4956abcf 100644 --- a/packages/arb-token-bridge-ui/tests/support/common.ts +++ b/packages/arb-token-bridge-ui/tests/support/common.ts @@ -6,7 +6,11 @@ import { Provider, StaticJsonRpcProvider } from '@ethersproject/providers' import { BigNumber, Signer, Wallet, ethers, utils } from 'ethers' import { MultiCaller } from '@arbitrum/sdk' import { MULTICALL_TESTNET_ADDRESS } from '../../src/constants' -import { defaultL2Network, defaultL3Network } from '../../src/util/networks' +import { + defaultL2Network, + defaultL3Network, + defaultL3CustomGasTokenNetwork +} from '../../src/util/networks' import { getChainIdFromProvider } from '../../src/token-bridge-sdk/utils' export type NetworkType = 'parentChain' | 'childChain' @@ -229,19 +233,30 @@ export async function generateActivityOnChains({ export async function checkForAssertions({ parentProvider, - isOrbitTest + testType }: { parentProvider: Provider - isOrbitTest: boolean + testType: 'regular' | 'orbit-eth' | 'orbit-custom' }) { + console.log('Checking for assertions...') + const abi = [ 'function latestConfirmed() public view returns (uint64)', 'function latestNodeCreated() public view returns (uint64)' ] - const rollupAddress = isOrbitTest - ? defaultL3Network.ethBridge.rollup - : defaultL2Network.ethBridge.rollup + let rollupAddress: string + + switch (testType) { + case 'orbit-eth': + rollupAddress = defaultL3Network.ethBridge.rollup + break + case 'orbit-custom': + rollupAddress = defaultL3CustomGasTokenNetwork.ethBridge.rollup + break + default: + rollupAddress = defaultL2Network.ethBridge.rollup + } const rollupContract = new ethers.Contract(rollupAddress, abi, parentProvider) From ed7b34d5408808b2d99b4e383427e4e150737740 Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 4 Oct 2024 13:55:44 +0200 Subject: [PATCH 10/99] fix --- packages/arb-token-bridge-ui/synpress.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 50760bd872..9a9e5a8067 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -193,7 +193,7 @@ export default defineConfig({ if (isCustomFeeToken) { await approveCustomFeeToken( userWallet.connect(parentProvider), - l3Network.tokenBridge?.childWethGateway! + l3Network.tokenBridge?.childWeth! ) } From d2eca8717f662fd664b60bc4807301704d2e0cfb Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 4 Oct 2024 14:13:05 +0200 Subject: [PATCH 11/99] fix weth --- packages/arb-token-bridge-ui/synpress.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 9a9e5a8067..3d4454a70f 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -193,7 +193,7 @@ export default defineConfig({ if (isCustomFeeToken) { await approveCustomFeeToken( userWallet.connect(parentProvider), - l3Network.tokenBridge?.childWeth! + l1WethAddress ) } From 3c84690624acf70244d07e78920e0abdd6d0c688 Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 4 Oct 2024 14:56:38 +0200 Subject: [PATCH 12/99] logs --- .../arb-token-bridge-ui/synpress.config.ts | 46 +++++++++++-------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 3d4454a70f..0dba2ff37a 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -109,11 +109,18 @@ export default defineConfig({ // Deploy and fund ERC20 to Parent and Child chains const l1ERC20Token = await deployERC20ToParentChain() + const bridger = await Erc20Bridger.fromProvider(childProvider) + const isCustomFeeToken = isNonZeroAddress(bridger.nativeToken) + + console.log('native token: ', bridger.nativeToken) + // Approve custom fee token if not ETH - await approveCustomFeeToken( - localWallet.connect(parentProvider), - l1ERC20Token.address - ) + if (isCustomFeeToken) { + await approveCustomFeeToken( + localWallet.connect(parentProvider), + l1ERC20Token.address + ) + } await fundUserWalletNativeCurrency() await fundErc20ToParentChain(l1ERC20Token) @@ -129,15 +136,14 @@ export default defineConfig({ l2WethAddress = wethAddresses.l2WethAddress } - const bridger = await Erc20Bridger.fromProvider(childProvider) - const isCustomFeeToken = typeof bridger.nativeToken !== 'undefined' - const ethBridger = await EthBridger.fromProvider(childProvider) - await approveCustomFeeToken( - userWallet.connect(parentProvider), - bridger.nativeToken! - ) + if (isCustomFeeToken) { + await approveCustomFeeToken( + userWallet.connect(parentProvider), + bridger.nativeToken! + ) + } if (isCustomFeeToken) { await ethBridger.approveGasToken({ @@ -145,6 +151,8 @@ export default defineConfig({ }) } + console.log({ l3Network }) + // Wrap ETH to test WETH transactions and approve it's usage await fundWeth('parentChain') await fundWeth('childChain') @@ -265,13 +273,6 @@ async function approveCustomFeeToken( signer: Wallet, erc20ParentAddress: string ) { - const childEthBridger = await EthBridger.fromProvider(childProvider) - const isCustomFeeToken = typeof childEthBridger.nativeToken !== 'undefined' - - if (!isCustomFeeToken) { - return - } - console.log('Approving custom fee token...') const childErc20Bridger = await Erc20Bridger.fromProvider(childProvider) @@ -332,8 +333,12 @@ async function deployERC20ToParentChain() { return l1TokenContract } -function isNonZeroAddress(address: string) { - return address !== constants.AddressZero && utils.isAddress(address) +function isNonZeroAddress(address: string | undefined) { + return ( + typeof address === 'string' && + address !== constants.AddressZero && + utils.isAddress(address) + ) } async function deployWeth(provider: StaticJsonRpcProvider) { @@ -395,6 +400,7 @@ async function fundWeth(networkType: NetworkType) { async function approveWeth() { console.log('Approving WETH...') + console.log({ l1WethAddress }) const tx = await getWethContract(parentProvider, l1WethAddress).approve( l1WethGateway, constants.MaxInt256 From d2e18e23579d93aa5ad989aebfbb44c9955c6132 Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 4 Oct 2024 15:21:39 +0200 Subject: [PATCH 13/99] fix network --- .../arb-token-bridge-ui/src/util/networks.ts | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts index 821239016c..1be0f4ddb2 100644 --- a/packages/arb-token-bridge-ui/src/util/networks.ts +++ b/packages/arb-token-bridge-ui/src/util/networks.ts @@ -320,29 +320,28 @@ export const defaultL3Network: ArbitrumNetwork = { bridge: '0xA584795e24628D9c067A6480b033C9E96281fcA3', inbox: '0xDcA690902d3154886Ec259308258D10EA5450996', outbox: '0xda243bD61B011024FC923164db75Dde198AC6175', - rollup: '0x7a23F33C1C384eFc11b8Cf207420c464ba2959CC', + rollup: '0xf9B0F86aCc3e42B7DF373c9a8adb2803BF0a7662', sequencerInbox: '0x16c54EE2015CD824415c2077F4103f444E00A8cb' }, - nativeToken: '0xE069078bA9ACCE4eeAE609d8754515Cf13dd6706', isCustom: true, isTestnet: true, name: 'L3 Local', retryableLifetimeSeconds: 604800, tokenBridge: { - parentCustomGateway: '0xCe02eA568090ae7d5184B0a98df90f6aa69C1552', - parentErc20Gateway: '0x59156b0596689D965Ba707E160e5370AF22461a0', - parentGatewayRouter: '0x0C085152C2799834fc1603533ff6916fa1FdA302', + parentCustomGateway: '0xA191D519260A06b32f8D04c84b9F457B8Caa0514', + parentErc20Gateway: '0x6B0805Fc6e275ef66a0901D0CE68805631E271e5', + parentGatewayRouter: '0xfE03DBdf7A126994dBd749631D7fbaB58C618c58', parentMultiCall: '0x20a3627Dcc53756E38aE3F92717DE9B23617b422', parentProxyAdmin: '0x1A61102c26ad3f64bA715B444C93388491fd8E68', - parentWeth: '0x0000000000000000000000000000000000000000', - parentWethGateway: '0x59156b0596689D965Ba707E160e5370AF22461a0', + parentWeth: '0xA1abD387192e3bb4e84D3109181F9f005aBaF5CA', + parentWethGateway: '0x77603b0ea6a797C74Fa9ef11b5BdE04A4E03D550', childCustomGateway: '0xD4816AeF8f85A3C1E01Cd071a81daD4fa941625f', childErc20Gateway: '0xaa7d51aFFEeB32d99b1CB2fd6d81D7adA4a896e8', childGatewayRouter: '0x8B6BC759226f8Fe687c8aD8Cc0DbF85E095e9297', childMultiCall: '0x052B15c8Ff0544287AE689C4F2FC53A3905d7Db3', childProxyAdmin: '0x36C56eC2CF3a3f53db9F01d0A5Ae84b36fb0A1e2', - childWeth: '0x0000000000000000000000000000000000000000', - childWethGateway: '0x0000000000000000000000000000000000000000' + childWeth: '0x582a8dBc77f665dF2c49Ce0a138978e9267dd968', + childWethGateway: '0xA6AB233B3c7bfd0399834897b5073974A3D467e2' } } @@ -354,28 +353,29 @@ export const defaultL3CustomGasTokenNetwork = { bridge: '0xA584795e24628D9c067A6480b033C9E96281fcA3', inbox: '0xDcA690902d3154886Ec259308258D10EA5450996', outbox: '0xda243bD61B011024FC923164db75Dde198AC6175', - rollup: '0xf9B0F86aCc3e42B7DF373c9a8adb2803BF0a7662', + rollup: '0x7a23F33C1C384eFc11b8Cf207420c464ba2959CC', sequencerInbox: '0x16c54EE2015CD824415c2077F4103f444E00A8cb' }, + nativeToken: '0xE069078bA9ACCE4eeAE609d8754515Cf13dd6706', isCustom: true, isTestnet: true, name: 'L3 Local', retryableLifetimeSeconds: 604800, tokenBridge: { - parentCustomGateway: '0xA191D519260A06b32f8D04c84b9F457B8Caa0514', - parentErc20Gateway: '0x6B0805Fc6e275ef66a0901D0CE68805631E271e5', - parentGatewayRouter: '0xfE03DBdf7A126994dBd749631D7fbaB58C618c58', + parentCustomGateway: '0xCe02eA568090ae7d5184B0a98df90f6aa69C1552', + parentErc20Gateway: '0x59156b0596689D965Ba707E160e5370AF22461a0', + parentGatewayRouter: '0x0C085152C2799834fc1603533ff6916fa1FdA302', parentMultiCall: '0x20a3627Dcc53756E38aE3F92717DE9B23617b422', parentProxyAdmin: '0x1A61102c26ad3f64bA715B444C93388491fd8E68', - parentWeth: '0xA1abD387192e3bb4e84D3109181F9f005aBaF5CA', - parentWethGateway: '0x77603b0ea6a797C74Fa9ef11b5BdE04A4E03D550', + parentWeth: '0x0000000000000000000000000000000000000000', + parentWethGateway: '0x59156b0596689D965Ba707E160e5370AF22461a0', childCustomGateway: '0xD4816AeF8f85A3C1E01Cd071a81daD4fa941625f', childErc20Gateway: '0xaa7d51aFFEeB32d99b1CB2fd6d81D7adA4a896e8', childGatewayRouter: '0x8B6BC759226f8Fe687c8aD8Cc0DbF85E095e9297', childMultiCall: '0x052B15c8Ff0544287AE689C4F2FC53A3905d7Db3', childProxyAdmin: '0x36C56eC2CF3a3f53db9F01d0A5Ae84b36fb0A1e2', - childWeth: '0x582a8dBc77f665dF2c49Ce0a138978e9267dd968', - childWethGateway: '0xA6AB233B3c7bfd0399834897b5073974A3D467e2' + childWeth: '0x0000000000000000000000000000000000000000', + childWethGateway: '0x0000000000000000000000000000000000000000' } } From d313756f9a3895917c5521009f10638699834e0c Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 4 Oct 2024 15:53:53 +0200 Subject: [PATCH 14/99] logs --- packages/arb-token-bridge-ui/synpress.config.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 0dba2ff37a..86b51f58c6 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -112,7 +112,10 @@ export default defineConfig({ const bridger = await Erc20Bridger.fromProvider(childProvider) const isCustomFeeToken = isNonZeroAddress(bridger.nativeToken) + console.log({ l3Network }) console.log('native token: ', bridger.nativeToken) + console.log('process.env.E2E_ORBIT: ', process.env.E2E_ORBIT) + console.log('process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN: ', process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN) // Approve custom fee token if not ETH if (isCustomFeeToken) { @@ -151,8 +154,6 @@ export default defineConfig({ }) } - console.log({ l3Network }) - // Wrap ETH to test WETH transactions and approve it's usage await fundWeth('parentChain') await fundWeth('childChain') From 12a227053b08988311e78ccddbcb49578ce8100e Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 4 Oct 2024 16:16:30 +0200 Subject: [PATCH 15/99] fix --- packages/arb-token-bridge-ui/synpress.config.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 86b51f58c6..971263c2a6 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -110,7 +110,8 @@ export default defineConfig({ const l1ERC20Token = await deployERC20ToParentChain() const bridger = await Erc20Bridger.fromProvider(childProvider) - const isCustomFeeToken = isNonZeroAddress(bridger.nativeToken) + const ethBridger = await EthBridger.fromProvider(childProvider) + const isCustomFeeToken = isNonZeroAddress(ethBridger.nativeToken) console.log({ l3Network }) console.log('native token: ', bridger.nativeToken) @@ -139,8 +140,6 @@ export default defineConfig({ l2WethAddress = wethAddresses.l2WethAddress } - const ethBridger = await EthBridger.fromProvider(childProvider) - if (isCustomFeeToken) { await approveCustomFeeToken( userWallet.connect(parentProvider), From 8283fdd313f654b9b8df93c5025c388ba3e3bed1 Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 4 Oct 2024 17:08:18 +0200 Subject: [PATCH 16/99] fix --- packages/arb-token-bridge-ui/synpress.config.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 971263c2a6..6209d0af7d 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -112,9 +112,11 @@ export default defineConfig({ const bridger = await Erc20Bridger.fromProvider(childProvider) const ethBridger = await EthBridger.fromProvider(childProvider) const isCustomFeeToken = isNonZeroAddress(ethBridger.nativeToken) - + + console.log({ childProvider }) + console.log({ isOrbitTest }) console.log({ l3Network }) - console.log('native token: ', bridger.nativeToken) + console.log('native token: ', ethBridger.nativeToken) console.log('process.env.E2E_ORBIT: ', process.env.E2E_ORBIT) console.log('process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN: ', process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN) From a4c18a5d9c6687b0433839576d44496a98707234 Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 4 Oct 2024 17:36:11 +0200 Subject: [PATCH 17/99] try --- packages/arb-token-bridge-ui/src/util/networks.ts | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts index 1be0f4ddb2..56bac239c4 100644 --- a/packages/arb-token-bridge-ui/src/util/networks.ts +++ b/packages/arb-token-bridge-ui/src/util/networks.ts @@ -5,12 +5,10 @@ import { getArbitrumNetworks, registerCustomArbitrumNetwork } from '@arbitrum/sdk' -import { StaticJsonRpcProvider } from '@ethersproject/providers' import { loadEnvironmentVariableWithFallback } from './index' import { getBridgeUiConfigForChain } from './bridgeUiConfig' import { chainIdToInfuraUrl } from './infura' -import { fetchNativeCurrency } from '../hooks/useNativeCurrency' export enum ChainId { // L1 @@ -398,17 +396,9 @@ export async function registerLocalNetwork() { rpcURLs[defaultL2Network.chainId] = localL2NetworkRpcUrl rpcURLs[defaultL3Network.chainId] = localL3NetworkRpcUrl - const l3LocalProvider = new StaticJsonRpcProvider( - localL3NetworkRpcUrl, - ChainId.L3Local - ) - const nativeCurrency = await fetchNativeCurrency({ - provider: l3LocalProvider - }) - registerCustomArbitrumNetwork(defaultL2Network) registerCustomArbitrumNetwork( - nativeCurrency.isCustom + process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' ? defaultL3CustomGasTokenNetwork : defaultL3Network ) From 65918a405d6d98a1869486607b71701df05d80fd Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 4 Oct 2024 18:04:44 +0200 Subject: [PATCH 18/99] fix --- .../arb-token-bridge-ui/synpress.config.ts | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 6209d0af7d..0acacc33be 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -12,6 +12,7 @@ import { StaticJsonRpcProvider } from '@ethersproject/providers' import synpressPlugins from '@synthetixio/synpress/plugins' import { TestERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestERC20__factory' import { TestWETH9__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestWETH9__factory' +import { TestWETH9 } from '@arbitrum/sdk/dist/lib/abi/TestWETH9' import { Erc20Bridger, EthBridger } from '@arbitrum/sdk' import logsPrinter from 'cypress-terminal-report/src/installLogsPrinter' import { getL2ERC20Address } from './src/util/TokenUtils' @@ -112,13 +113,16 @@ export default defineConfig({ const bridger = await Erc20Bridger.fromProvider(childProvider) const ethBridger = await EthBridger.fromProvider(childProvider) const isCustomFeeToken = isNonZeroAddress(ethBridger.nativeToken) - + console.log({ childProvider }) console.log({ isOrbitTest }) console.log({ l3Network }) console.log('native token: ', ethBridger.nativeToken) console.log('process.env.E2E_ORBIT: ', process.env.E2E_ORBIT) - console.log('process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN: ', process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN) + console.log( + 'process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN: ', + process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN + ) // Approve custom fee token if not ETH if (isCustomFeeToken) { @@ -130,7 +134,7 @@ export default defineConfig({ await fundUserWalletNativeCurrency() await fundErc20ToParentChain(l1ERC20Token) - await fundErc20ToChildChain(l1ERC20Token) + await fundErc20ToChildChain(l1ERC20Token, '5') await approveErc20(l1ERC20Token) if ( @@ -157,8 +161,12 @@ export default defineConfig({ // Wrap ETH to test WETH transactions and approve it's usage await fundWeth('parentChain') - await fundWeth('childChain') await approveWeth() + // await fundWeth('childChain') + await fundErc20ToChildChain( + getWethContract(parentProvider, l1WethAddress), + '0.1' + ) // Generate activity on chains so that assertions get posted and claims can be made generateActivityOnChains({ @@ -390,7 +398,7 @@ function getWethContract( async function fundWeth(networkType: NetworkType) { console.log(`Funding WETH: ${networkType}...`) - const amount = networkType === 'parentChain' ? '0.2' : '0.1' + const amount = networkType === 'parentChain' ? '0.3' : '0.1' const address = networkType === 'parentChain' ? l1WethAddress : l2WethAddress const provider = networkType === 'parentChain' ? parentProvider : childProvider @@ -400,6 +408,10 @@ async function fundWeth(networkType: NetworkType) { await tx.wait() } +async function depositWeth() { + console.log(`Depositing WETH...`) +} + async function approveWeth() { console.log('Approving WETH...') console.log({ l1WethAddress }) @@ -430,7 +442,10 @@ async function fundErc20ToParentChain(l1ERC20Token: Contract) { await transferTx.wait() } -async function fundErc20ToChildChain(l1ERC20Token: Contract) { +async function fundErc20ToChildChain( + l1ERC20Token: Contract | TestWETH9, + amount: string +) { console.log('Funding ERC20 on Child Chain...') // first deploy the ERC20 to L2 (if not, it might throw a gas error later) await deployERC20ToChildChain(l1ERC20Token.address) @@ -450,7 +465,7 @@ async function fundErc20ToChildChain(l1ERC20Token: Contract) { parentSigner, childProvider, erc20ParentAddress: l1ERC20Token.address, - amount: parseUnits('5', ERC20TokenDecimals), + amount: parseUnits(amount, ERC20TokenDecimals), destinationAddress: userWallet.address }) const depositRec = await depositTx.wait() From 48861133e96ce2c86b459b10ea0550854041113b Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 4 Oct 2024 18:28:47 +0200 Subject: [PATCH 19/99] fix --- packages/arb-token-bridge-ui/synpress.config.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 0acacc33be..459c4f6bcf 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -134,7 +134,7 @@ export default defineConfig({ await fundUserWalletNativeCurrency() await fundErc20ToParentChain(l1ERC20Token) - await fundErc20ToChildChain(l1ERC20Token, '5') + await fundErc20ToChildChain(l1ERC20Token, '5', true) await approveErc20(l1ERC20Token) if ( @@ -165,7 +165,8 @@ export default defineConfig({ // await fundWeth('childChain') await fundErc20ToChildChain( getWethContract(parentProvider, l1WethAddress), - '0.1' + '0.1', + false ) // Generate activity on chains so that assertions get posted and claims can be made @@ -444,14 +445,18 @@ async function fundErc20ToParentChain(l1ERC20Token: Contract) { async function fundErc20ToChildChain( l1ERC20Token: Contract | TestWETH9, - amount: string + amount: string, + deploy: boolean ) { console.log('Funding ERC20 on Child Chain...') - // first deploy the ERC20 to L2 (if not, it might throw a gas error later) - await deployERC20ToChildChain(l1ERC20Token.address) + if (deploy) { + // first deploy the ERC20 to L2 (if not, it might throw a gas error later) + await deployERC20ToChildChain(l1ERC20Token.address) + } const erc20Bridger = await Erc20Bridger.fromProvider(childProvider) const parentSigner = localWallet.connect(parentProvider) + console.log('approving..') // approve the ERC20 token for spending const approvalTx = await erc20Bridger.approveToken({ erc20ParentAddress: l1ERC20Token.address, @@ -460,6 +465,8 @@ async function fundErc20ToChildChain( }) await approvalTx.wait() + console.log('depositing..') + // deposit the ERC20 token to L2 (fund the L2 account) const depositTx = await erc20Bridger.deposit({ parentSigner, From 37a7ef11e4a15b3a02cc95914627d23dd87fcdbe Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 4 Oct 2024 19:01:16 +0200 Subject: [PATCH 20/99] fix --- packages/arb-token-bridge-ui/synpress.config.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 459c4f6bcf..c1644bf746 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -157,6 +157,10 @@ export default defineConfig({ await ethBridger.approveGasToken({ parentSigner: userWallet.connect(parentProvider) }) + await bridger.approveGasToken({ + parentSigner: userWallet.connect(parentProvider), + erc20ParentAddress: l1WethAddress + }) } // Wrap ETH to test WETH transactions and approve it's usage From 067b64c808ab6ba018e7ffdd180eaed5f6466fe0 Mon Sep 17 00:00:00 2001 From: Bartek Date: Mon, 7 Oct 2024 14:16:28 +0200 Subject: [PATCH 21/99] fixes --- package.json | 2 +- .../arb-token-bridge-ui/src/util/networks.ts | 4 +- .../arb-token-bridge-ui/synpress.config.ts | 74 ++++---- .../tests/e2e/specs/approveToken.cy.ts | 11 +- .../tests/e2e/specs/batchDeposit.cy.ts | 30 +-- .../tests/e2e/specs/depositCctp.cy.ts | 9 +- .../tests/e2e/specs/depositERC20.cy.ts | 33 +++- .../tests/e2e/specs/depositETH.cy.ts | 17 +- .../tests/e2e/specs/importToken.cy.ts | 9 +- .../tests/e2e/specs/login.cy.ts | 5 +- .../tests/e2e/specs/readClassicDeposits.cy.ts | 6 +- .../tests/e2e/specs/withdrawERC20.cy.ts | 21 ++- .../tests/e2e/specs/withdrawETH.cy.ts | 177 +++++++++--------- .../tests/support/common.ts | 5 +- 14 files changed, 234 insertions(+), 169 deletions(-) diff --git a/package.json b/package.json index 28b20b0721..2e655465d3 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "test:e2e": "yarn workspace arb-token-bridge-ui env-cmd --silent --file .e2e.env yarn synpress run --configFile synpress.config.ts", "test:e2e:cctp": "yarn test:e2e --configFile synpress.cctp.config.ts", "test:e2e:orbit": "E2E_ORBIT=true yarn test:e2e", - "test:e2e:orbit:custom-gas-token": "E2E_ORBIT_CUSTOM_GAS_TOKEN=true yarn test:e2e" + "test:e2e:orbit:custom-gas-token": "NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN=true yarn test:e2e" }, "resolutions": { "**/@walletconnect/ethereum-provider": "2.13.1", diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts index 56bac239c4..60ce2abf3f 100644 --- a/packages/arb-token-bridge-ui/src/util/networks.ts +++ b/packages/arb-token-bridge-ui/src/util/networks.ts @@ -396,9 +396,11 @@ export async function registerLocalNetwork() { rpcURLs[defaultL2Network.chainId] = localL2NetworkRpcUrl rpcURLs[defaultL3Network.chainId] = localL3NetworkRpcUrl + + console.log('process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN: ', process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true') registerCustomArbitrumNetwork(defaultL2Network) registerCustomArbitrumNetwork( - process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' + process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' ? defaultL3CustomGasTokenNetwork : defaultL3Network ) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index c1644bf746..37deca73c6 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -44,12 +44,12 @@ const tests = process.env.TEST_FILE const isOrbitTest = [ process.env.E2E_ORBIT, - process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN + process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN ].includes('true') const shouldRecordVideo = process.env.CYPRESS_RECORD_VIDEO === 'true' const l3Network = - process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' + process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' ? defaultL3CustomGasTokenNetwork : defaultL3Network @@ -114,27 +114,28 @@ export default defineConfig({ const ethBridger = await EthBridger.fromProvider(childProvider) const isCustomFeeToken = isNonZeroAddress(ethBridger.nativeToken) - console.log({ childProvider }) - console.log({ isOrbitTest }) - console.log({ l3Network }) - console.log('native token: ', ethBridger.nativeToken) - console.log('process.env.E2E_ORBIT: ', process.env.E2E_ORBIT) - console.log( - 'process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN: ', - process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN - ) - // Approve custom fee token if not ETH if (isCustomFeeToken) { await approveCustomFeeToken( localWallet.connect(parentProvider), l1ERC20Token.address ) + await approveCustomFeeToken( + localWallet.connect(parentProvider), + bridger.nativeToken! + ) + await ethBridger.approveGasToken({ + parentSigner: localWallet.connect(parentProvider) + }) } await fundUserWalletNativeCurrency() await fundErc20ToParentChain(l1ERC20Token) - await fundErc20ToChildChain(l1ERC20Token, '5', true) + await fundErc20ToChildChain( + l1ERC20Token.address, + localWallet.connect(parentProvider), + '5' + ) await approveErc20(l1ERC20Token) if ( @@ -167,10 +168,22 @@ export default defineConfig({ await fundWeth('parentChain') await approveWeth() // await fundWeth('childChain') + if (isCustomFeeToken) { + await approveCustomFeeToken( + userWallet.connect(parentProvider), + l1WethAddress + ) + } + + const wethBal = await getWethContract( + parentProvider, + l1WethAddress + ).balanceOf(userWallet.address) + await fundErc20ToChildChain( - getWethContract(parentProvider, l1WethAddress), - '0.1', - false + l1WethAddress, + userWallet.connect(parentProvider), + '0.1' ) // Generate activity on chains so that assertions get posted and claims can be made @@ -183,7 +196,7 @@ export default defineConfig({ checkForAssertions({ parentProvider, testType: - process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' + process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' ? 'orbit-custom' : process.env.E2E_ORBIT === 'true' ? 'orbit-eth' @@ -201,6 +214,7 @@ export default defineConfig({ config.env.ERC20_TOKEN_ADDRESS_PARENT_CHAIN = l1ERC20Token.address config.env.LOCAL_WALLET_PRIVATE_KEY = localWallet.privateKey config.env.ORBIT_TEST = isOrbitTest ? '1' : '0' + config.env.NATIVE_TOKEN_SYMBOL = isCustomFeeToken ? 'TN' : 'ETH' config.env.CUSTOM_DESTINATION_ADDRESS = await getCustomDestinationAddress() @@ -278,7 +292,7 @@ if (!process.env.PRIVATE_KEY_USER) { } const localWallet = new Wallet( - process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN + process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN ? utils.sha256(utils.toUtf8Bytes('user_fee_token_deployer')) : process.env.PRIVATE_KEY_CUSTOM ) @@ -448,34 +462,28 @@ async function fundErc20ToParentChain(l1ERC20Token: Contract) { } async function fundErc20ToChildChain( - l1ERC20Token: Contract | TestWETH9, - amount: string, - deploy: boolean + parentErc20Address: string, + signer: Wallet, + amount: string ) { - console.log('Funding ERC20 on Child Chain...') - if (deploy) { - // first deploy the ERC20 to L2 (if not, it might throw a gas error later) - await deployERC20ToChildChain(l1ERC20Token.address) - } + // first deploy the ERC20 to L2 (if not, it might throw a gas error later) + await deployERC20ToChildChain(parentErc20Address) + const erc20Bridger = await Erc20Bridger.fromProvider(childProvider) - const parentSigner = localWallet.connect(parentProvider) + const parentSigner = signer - console.log('approving..') // approve the ERC20 token for spending const approvalTx = await erc20Bridger.approveToken({ - erc20ParentAddress: l1ERC20Token.address, + erc20ParentAddress: parentErc20Address, parentSigner, amount: constants.MaxUint256 }) await approvalTx.wait() - console.log('depositing..') - - // deposit the ERC20 token to L2 (fund the L2 account) const depositTx = await erc20Bridger.deposit({ parentSigner, childProvider, - erc20ParentAddress: l1ERC20Token.address, + erc20ParentAddress: parentErc20Address, amount: parseUnits(amount, ERC20TokenDecimals), destinationAddress: userWallet.address }) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts index ad6c3aa8c4..8713c5bc13 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts @@ -2,7 +2,7 @@ import { importTokenThroughUI, ERC20TokenName, ERC20TokenSymbol, - zeroToLessThanOneETH, + getZeroToLessThanOneNativeToken, getL1NetworkName, getL2NetworkName } from '../../support/common' @@ -11,6 +11,9 @@ const ERC20TokenAddressL1 = Cypress.env('ERC20_TOKEN_ADDRESS_PARENT_CHAIN') describe('Approve token for deposit', () => { // log in to metamask + const zeroToLessThanOneNativeToken = getZeroToLessThanOneNativeToken( + Cypress.env('NATIVE_TOKEN_SYMBOL') + ) it('should approve and deposit ERC-20 token', () => { context('Approve token', () => { @@ -26,9 +29,9 @@ describe('Approve token for deposit', () => { cy.findByText('MAX').click() - cy.findGasFeeSummary(zeroToLessThanOneETH) - cy.findGasFeeForChain(getL1NetworkName(), zeroToLessThanOneETH) - cy.findGasFeeForChain(getL2NetworkName(), zeroToLessThanOneETH) + cy.findGasFeeSummary(zeroToLessThanOneNativeToken) + cy.findGasFeeForChain(getL1NetworkName(), zeroToLessThanOneNativeToken) + cy.findGasFeeForChain(getL2NetworkName(), zeroToLessThanOneNativeToken) cy.waitUntil(() => cy.findMoveFundsButton().should('not.be.disabled'), { errorMsg: 'move funds button is disabled (expected to be enabled)', diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/batchDeposit.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/batchDeposit.cy.ts index 08f768bc31..5f5a17b18c 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/batchDeposit.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/batchDeposit.cy.ts @@ -6,7 +6,7 @@ import { getL1NetworkName, getL2NetworkConfig, getL2NetworkName, - zeroToLessThanOneETH + getZeroToLessThanOneNativeToken } from '../../support/common' import { formatAmount } from '../../../src/util/NumberUtils' @@ -16,6 +16,10 @@ describe('Batch Deposit', () => { childNativeTokenBalance, childErc20Balance: string + const nativeTokenSymbol = Cypress.env('NATIVE_TOKEN_SYMBOL') + const zeroToLessThanOneNativeToken = + getZeroToLessThanOneNativeToken(nativeTokenSymbol) + beforeEach(() => { getInitialERC20Balance({ tokenAddress: Cypress.env('ERC20_TOKEN_ADDRESS_CHILD_CHAIN'), @@ -49,7 +53,7 @@ describe('Batch Deposit', () => { }) cy.findSourceChainButton(getL1NetworkName()) cy.findDestinationChainButton(getL2NetworkName()) - cy.findSelectTokenButton('ETH') + cy.findSelectTokenButton(nativeTokenSymbol) }) it('should deposit erc-20 and native currency to the same address', () => { @@ -81,7 +85,9 @@ describe('Batch Deposit', () => { }) context('native currency balance on child chain should not exist', () => { - cy.findByLabelText(`ETH balance amount on childChain`).should('not.exist') + cy.findByLabelText( + `${nativeTokenSymbol} balance amount on childChain` + ).should('not.exist') }) context('amount2 input should not exist', () => { @@ -99,7 +105,7 @@ describe('Batch Deposit', () => { }) context('native currency balance on child chain should show', () => { - cy.findByLabelText(`ETH balance amount on childChain`) + cy.findByLabelText(`${nativeTokenSymbol} balance amount on childChain`) .should('be.visible') .contains(childNativeTokenBalance) }) @@ -111,9 +117,9 @@ describe('Batch Deposit', () => { context('should show gas estimations and summary', () => { cy.typeAmount(ERC20AmountToSend) cy.typeAmount2(nativeCurrencyAmountToSend) - cy.findGasFeeSummary(zeroToLessThanOneETH) - cy.findGasFeeForChain(getL1NetworkName(), zeroToLessThanOneETH) - cy.findGasFeeForChain(getL2NetworkName(), zeroToLessThanOneETH) + cy.findGasFeeSummary(zeroToLessThanOneNativeToken) + cy.findGasFeeForChain(getL1NetworkName(), zeroToLessThanOneNativeToken) + cy.findGasFeeForChain(getL2NetworkName(), zeroToLessThanOneNativeToken) }) const txData = { @@ -154,7 +160,7 @@ describe('Batch Deposit', () => { .invoke('text') .then(parseFloat) .should('be.gt', Number(parentErc20Balance)) - cy.findByLabelText(`ETH balance amount on childChain`) + cy.findByLabelText(`${nativeTokenSymbol} balance amount on childChain`) .invoke('text') .then(parseFloat) .should( @@ -217,14 +223,14 @@ describe('Batch Deposit', () => { context('should show gas estimations and summary', () => { cy.typeAmount(ERC20AmountToSend) cy.typeAmount2(nativeCurrencyAmountToSend) - cy.findGasFeeSummary(zeroToLessThanOneETH) - cy.findGasFeeForChain(getL1NetworkName(), zeroToLessThanOneETH) - cy.findGasFeeForChain(getL2NetworkName(), zeroToLessThanOneETH) + cy.findGasFeeSummary(zeroToLessThanOneNativeToken) + cy.findGasFeeForChain(getL1NetworkName(), zeroToLessThanOneNativeToken) + cy.findGasFeeForChain(getL2NetworkName(), zeroToLessThanOneNativeToken) }) const txData = { symbol: ERC20TokenSymbol, - symbol2: 'ETH', + symbol2: nativeTokenSymbol, amount: ERC20AmountToSend, amount2: nativeCurrencyAmountToSend } diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts index f1d39bbf2d..81432d54ae 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts @@ -2,7 +2,7 @@ * When user wants to bridge USDC through CCTP from L1 to L2 */ -import { zeroToLessThanOneETH } from '../../support/common' +import { getZeroToLessThanOneNativeToken } from '../../support/common' import { CommonAddress } from '../../../src/util/CommonAddressUtils' import { formatAmount } from 'packages/arb-token-bridge-ui/src/util/NumberUtils' @@ -65,6 +65,9 @@ const confirmAndApproveCctpDeposit = () => { describe('Deposit USDC through CCTP', () => { // Happy Path const USDCAmountToSend = 0.0001 + const zeroToLessThanOneNativeToken = getZeroToLessThanOneNativeToken( + Cypress.env('NATIVE_TOKEN_SYMBOL') + ) beforeEach(() => { cy.login({ networkType: 'parentChain', networkName: 'sepolia' }) @@ -78,8 +81,8 @@ describe('Deposit USDC through CCTP', () => { }) cy.typeAmount(USDCAmountToSend) - cy.findGasFeeSummary(zeroToLessThanOneETH) - cy.findGasFeeForChain('Sepolia', zeroToLessThanOneETH) + cy.findGasFeeSummary(zeroToLessThanOneNativeToken) + cy.findGasFeeForChain('Sepolia', zeroToLessThanOneNativeToken) cy.findGasFeeForChain( /You'll have to pay Arbitrum Sepolia gas fee upon claiming./i ) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/depositERC20.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/depositERC20.cy.ts index 2568bfbef9..b2632efeb0 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/depositERC20.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/depositERC20.cy.ts @@ -6,7 +6,7 @@ import { formatAmount } from '../../../src/util/NumberUtils' import { getInitialERC20Balance, getL1NetworkConfig, - zeroToLessThanOneETH, + getZeroToLessThanOneNativeToken, moreThanZeroBalance, getL1NetworkName, getL2NetworkName, @@ -33,6 +33,9 @@ describe('Deposit Token', () => { const isOrbitTest = Cypress.env('ORBIT_TEST') == '1' const depositTime = isOrbitTest ? 'Less than a minute' : '9 minutes' + const nativeTokenSymbol = Cypress.env('NATIVE_TOKEN_SYMBOL') + const zeroToLessThanOneNativeToken = + getZeroToLessThanOneNativeToken(nativeTokenSymbol) // Happy Path Object.keys(depositTestCases).forEach(tokenType => { @@ -50,11 +53,11 @@ describe('Deposit Token', () => { }).then(val => (l1ERC20bal = formatAmount(val))) }) - it('should show L1 and L2 chains, and ETH correctly', () => { + it('should show L1 and L2 chains, and native token correctly', () => { cy.login({ networkType: 'parentChain' }) cy.findSourceChainButton(getL1NetworkName()) cy.findDestinationChainButton(getL2NetworkName()) - cy.findSelectTokenButton('ETH') + cy.findSelectTokenButton(nativeTokenSymbol) }) it(`should deposit ${tokenType} successfully to the same address`, () => { @@ -76,9 +79,15 @@ describe('Deposit Token', () => { context('should show gas estimations', () => { cy.typeAmount(ERC20AmountToSend) - cy.findGasFeeSummary(zeroToLessThanOneETH) - cy.findGasFeeForChain(getL1NetworkName(), zeroToLessThanOneETH) - cy.findGasFeeForChain(getL2NetworkName(), zeroToLessThanOneETH) + cy.findGasFeeSummary(zeroToLessThanOneNativeToken) + cy.findGasFeeForChain( + getL1NetworkName(), + zeroToLessThanOneNativeToken + ) + cy.findGasFeeForChain( + getL2NetworkName(), + zeroToLessThanOneNativeToken + ) }) context('should deposit successfully', () => { @@ -111,9 +120,15 @@ describe('Deposit Token', () => { context('should show summary', () => { cy.typeAmount(ERC20AmountToSend) - cy.findGasFeeSummary(zeroToLessThanOneETH) - cy.findGasFeeForChain(getL1NetworkName(), zeroToLessThanOneETH) - cy.findGasFeeForChain(getL2NetworkName(), zeroToLessThanOneETH) + cy.findGasFeeSummary(zeroToLessThanOneNativeToken) + cy.findGasFeeForChain( + getL1NetworkName(), + zeroToLessThanOneNativeToken + ) + cy.findGasFeeForChain( + getL2NetworkName(), + zeroToLessThanOneNativeToken + ) }) context('should fill custom destination address successfully', () => { diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/depositETH.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/depositETH.cy.ts index 5de9ab52a4..b791dd4aeb 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/depositETH.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/depositETH.cy.ts @@ -1,15 +1,18 @@ /** - * When user wants to bridge ETH from L1 to L2 + * When user wants to bridge native token from L1 to L2 */ import { getL1NetworkName, getL2NetworkName, - zeroToLessThanOneETH + getZeroToLessThanOneNativeToken } from '../../support/common' -describe('Deposit ETH', () => { +describe('Deposit native token', () => { const ETHAmountToDeposit = 0.0001 + const nativeTokenSymbol = Cypress.env('NATIVE_TOKEN_SYMBOL') + const zeroToLessThanOneNativeToken = + getZeroToLessThanOneNativeToken(nativeTokenSymbol) const isOrbitTest = Cypress.env('ORBIT_TEST') == '1' const depositTime = isOrbitTest ? 'Less than a minute' : '9 minutes' @@ -24,15 +27,15 @@ describe('Deposit ETH', () => { it('should show gas estimations and bridge successfully', () => { cy.login({ networkType: 'parentChain' }) cy.typeAmount(ETHAmountToDeposit) - cy.findGasFeeSummary(zeroToLessThanOneETH) - cy.findGasFeeForChain(getL1NetworkName(), zeroToLessThanOneETH) - cy.findGasFeeForChain(getL2NetworkName(), zeroToLessThanOneETH) + cy.findGasFeeSummary(zeroToLessThanOneNativeToken) + cy.findGasFeeForChain(getL1NetworkName(), zeroToLessThanOneNativeToken) + cy.findGasFeeForChain(getL2NetworkName(), zeroToLessThanOneNativeToken) cy.findMoveFundsButton().click() cy.confirmMetamaskTransaction() cy.findTransactionInTransactionHistory({ duration: depositTime, amount: ETHAmountToDeposit, - symbol: 'ETH' + symbol: nativeTokenSymbol }) cy.closeTransactionHistoryPanel() cy.findAmountInput().should('have.value', '') diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/importToken.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/importToken.cy.ts index 3946254dbf..44aa1e15da 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/importToken.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/importToken.cy.ts @@ -15,6 +15,7 @@ const ERC20TokenAddressL2: string = Cypress.env( ) describe('Import token', () => { + const nativeTokenSymbol = Cypress.env('NATIVE_TOKEN_SYMBOL') // we use mainnet to test token lists context('User import token through UI', () => { @@ -76,7 +77,7 @@ describe('Import token', () => { networkName: 'mainnet' }) - cy.findSelectTokenButton('ETH').click() + cy.findSelectTokenButton(nativeTokenSymbol).click() // Check that token list is imported cy.findByRole('button', { name: 'Manage token lists' }) @@ -100,7 +101,7 @@ describe('Import token', () => { networkName: 'mainnet' }) - cy.findSelectTokenButton('ETH').click() + cy.findSelectTokenButton(nativeTokenSymbol).click() // Check that token list is imported cy.findByRole('button', { name: 'Manage token lists' }) @@ -136,7 +137,7 @@ describe('Import token', () => { const addressWithoutLastChar = ERC20TokenAddressL1.slice(0, -1) // Remove the last character cy.login({ networkType: 'parentChain' }) - cy.findSelectTokenButton('ETH').click() + cy.findSelectTokenButton(nativeTokenSymbol).click() // open the Select Token popup cy.findByPlaceholderText(/Search by token name/i) @@ -261,7 +262,7 @@ describe('Import token', () => { .trigger('click', { force: true }) - cy.findSelectTokenButton('ETH') + cy.findSelectTokenButton(nativeTokenSymbol) // Modal is closed cy.findByRole('button', { name: 'Dialog Cancel' }).should('not.exist') diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts index 0b6286f7e3..475bf26bb8 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts @@ -18,7 +18,10 @@ describe('Login Account', () => { val => (l1ETHbal = formatAmount(val)) ) getInitialETHBalance(Cypress.env('ARB_RPC_URL')).then( - val => (l2ETHbal = formatAmount(val, { symbol: 'ETH' })) + val => + (l2ETHbal = formatAmount(val, { + symbol: Cypress.env('NATIVE_TOKEN_SYMBOL') + })) ) }) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/readClassicDeposits.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/readClassicDeposits.cy.ts index 6725952d49..727778240c 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/readClassicDeposits.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/readClassicDeposits.cy.ts @@ -22,7 +22,7 @@ function mockClassicDepositTransaction( childChainId: 42161, status: 'success', isClassic: true, - assetName: 'ETH', + assetName: Cypress.env('NATIVE_TOKEN_SYMBOL'), assetType: AssetType.ETH, sender: Cypress.env('ADDRESS'), l1NetworkID: '1', @@ -44,8 +44,8 @@ describe('Read classic deposit messages', () => { window.localStorage.clear() }) - context('User has classic ETH deposit transaction', () => { - it('can read successful ETH deposit', () => { + context('User has classic native token deposit transaction', () => { + it('can read successful native token deposit', () => { // log in to metamask cy.login({ networkType: 'parentChain', diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawERC20.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawERC20.cy.ts index 54233ff35b..3ee878e90b 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawERC20.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawERC20.cy.ts @@ -9,7 +9,7 @@ import { getL2NetworkConfig, getL1NetworkName, getL2NetworkName, - zeroToLessThanOneETH, + getZeroToLessThanOneNativeToken, ERC20TokenSymbol } from '../../support/common' @@ -27,6 +27,9 @@ const withdrawalTestCases = { } describe('Withdraw ERC20 Token', () => { + const nativeTokenSymbol = Cypress.env('NATIVE_TOKEN_SYMBOL') + const zeroToLessThanOneNativeToken = + getZeroToLessThanOneNativeToken(nativeTokenSymbol) let ERC20AmountToSend = Number((Math.random() * 0.001).toFixed(5)) // randomize the amount to be sure that previous transactions are not checked in e2e // when all of our tests need to run in a logged-in state // we have to make sure we preserve a healthy LocalStorage state @@ -70,7 +73,7 @@ describe('Withdraw ERC20 Token', () => { cy.findSourceChainButton(getL2NetworkName()) cy.findDestinationChainButton(getL1NetworkName()) cy.findMoveFundsButton().should('be.disabled') - cy.findSelectTokenButton('ETH') + cy.findSelectTokenButton(nativeTokenSymbol) }) it(`should withdraw ${tokenType} to the same address successfully`, () => { @@ -86,8 +89,11 @@ describe('Withdraw ERC20 Token', () => { context('should show summary', () => { cy.typeAmount(ERC20AmountToSend) - cy.findGasFeeSummary(zeroToLessThanOneETH) - cy.findGasFeeForChain(getL2NetworkName(), zeroToLessThanOneETH) + cy.findGasFeeSummary(zeroToLessThanOneNativeToken) + cy.findGasFeeForChain( + getL2NetworkName(), + zeroToLessThanOneNativeToken + ) cy.findGasFeeForChain( new RegExp( `You'll have to pay ${getL1NetworkName()} gas fee upon claiming.`, @@ -196,8 +202,11 @@ describe('Withdraw ERC20 Token', () => { context('should show summary', () => { cy.typeAmount(ERC20AmountToSend) - cy.findGasFeeSummary(zeroToLessThanOneETH) - cy.findGasFeeForChain(getL2NetworkName(), zeroToLessThanOneETH) + cy.findGasFeeSummary(zeroToLessThanOneNativeToken) + cy.findGasFeeForChain( + getL2NetworkName(), + zeroToLessThanOneNativeToken + ) cy.findGasFeeForChain( new RegExp( `You'll have to pay ${getL1NetworkName()} gas fee upon claiming.`, diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawETH.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawETH.cy.ts index 1f45382c16..e98e0da531 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawETH.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawETH.cy.ts @@ -1,16 +1,19 @@ /** - * When user wants to bridge ETH from L2 to L1 + * When user wants to bridge native token from L2 to L1 */ import { getInitialETHBalance, getL1NetworkName, getL2NetworkName, - zeroToLessThanOneETH + getZeroToLessThanOneNativeToken } from '../../support/common' import { formatAmount } from '../../../src/util/NumberUtils' -describe('Withdraw ETH', () => { +describe('Withdraw native token', () => { + const nativeTokenSymbol = Cypress.env('NATIVE_TOKEN_SYMBOL') + const zeroToLessThanOneNativeToken = + getZeroToLessThanOneNativeToken(nativeTokenSymbol) let ETHToWithdraw = Number((Math.random() * 0.001).toFixed(5)) // randomize the amount to be sure that previous transactions are not checked in e2e let l1EthBal: string @@ -21,13 +24,13 @@ describe('Withdraw ETH', () => { ).then( val => (l1EthBal = formatAmount(val, { - symbol: 'ETH' + symbol: nativeTokenSymbol })) ) }) // Happy Path - context('user has some ETH and is on L2', () => { + context('user has some native token and is on L2', () => { it('should show form fields correctly', () => { cy.login({ networkType: 'childChain' }) cy.findSourceChainButton(getL2NetworkName()) @@ -35,100 +38,106 @@ describe('Withdraw ETH', () => { cy.findMoveFundsButton().should('be.disabled') }) - context("bridge amount is lower than user's L2 ETH balance value", () => { - it('should show gas estimations', () => { - cy.login({ networkType: 'childChain' }) - cy.typeAmount(ETHToWithdraw) - cy.findGasFeeSummary(zeroToLessThanOneETH) - cy.findGasFeeForChain(getL2NetworkName(), zeroToLessThanOneETH) - cy.findGasFeeForChain( - new RegExp( - `You'll have to pay ${getL1NetworkName()} gas fee upon claiming.`, - 'i' + context( + "bridge amount is lower than user's L2 native token balance value", + () => { + it('should show gas estimations', () => { + cy.login({ networkType: 'childChain' }) + cy.typeAmount(ETHToWithdraw) + cy.findGasFeeSummary(zeroToLessThanOneNativeToken) + cy.findGasFeeForChain( + getL2NetworkName(), + zeroToLessThanOneNativeToken + ) + cy.findGasFeeForChain( + new RegExp( + `You'll have to pay ${getL1NetworkName()} gas fee upon claiming.`, + 'i' + ) ) - ) - }) - - it('should show withdrawal confirmation and withdraw', () => { - ETHToWithdraw = Number((Math.random() * 0.001).toFixed(5)) // generate a new withdrawal amount for each test-run attempt so that findAllByText doesn't stall coz of prev transactions - cy.login({ networkType: 'childChain' }) - cy.typeAmount(ETHToWithdraw) - cy.findMoveFundsButton().click() - cy.findByText(/Arbitrum’s bridge/i).should('be.visible') - - // the Continue withdrawal button should be disabled at first - cy.findByRole('button', { - name: /Continue/i - }).should('be.disabled') - - cy.findByRole('switch', { - name: /before I can claim my funds/i }) - .should('be.visible') - .click() - cy.findByRole('switch', { - name: /after claiming my funds/i - }) - .should('be.visible') - .click() - // the Continue withdrawal button should not be disabled now - cy.findByRole('button', { - name: /Continue/i - }) - .should('be.enabled') - .click() + it('should show withdrawal confirmation and withdraw', () => { + ETHToWithdraw = Number((Math.random() * 0.001).toFixed(5)) // generate a new withdrawal amount for each test-run attempt so that findAllByText doesn't stall coz of prev transactions + cy.login({ networkType: 'childChain' }) + cy.typeAmount(ETHToWithdraw) + cy.findMoveFundsButton().click() + cy.findByText(/Arbitrum’s bridge/i).should('be.visible') - cy.confirmMetamaskTransaction() + // the Continue withdrawal button should be disabled at first + cy.findByRole('button', { + name: /Continue/i + }).should('be.disabled') - cy.findTransactionInTransactionHistory({ - duration: 'an hour', - amount: ETHToWithdraw, - symbol: 'ETH' - }) + cy.findByRole('switch', { + name: /before I can claim my funds/i + }) + .should('be.visible') + .click() - context('transfer panel amount should be reset', () => { - cy.closeTransactionHistoryPanel() - cy.findAmountInput().should('have.value', '') - cy.findMoveFundsButton().should('be.disabled') - }) - }) + cy.findByRole('switch', { + name: /after claiming my funds/i + }) + .should('be.visible') + .click() + // the Continue withdrawal button should not be disabled now + cy.findByRole('button', { + name: /Continue/i + }) + .should('be.enabled') + .click() - it('should claim funds', { defaultCommandTimeout: 200_000 }, () => { - // increase the timeout for this test as claim button can take ~(20 blocks *10 blocks/sec) to activate - cy.login({ networkType: 'parentChain' }) // login to L1 to claim the funds (otherwise would need to change network after clicking on claim) + cy.confirmMetamaskTransaction() - cy.findByLabelText('Open Transaction History') - .should('be.visible') - .click() + cy.findTransactionInTransactionHistory({ + duration: 'an hour', + amount: ETHToWithdraw, + symbol: nativeTokenSymbol + }) - cy.findClaimButton( - formatAmount(ETHToWithdraw, { - symbol: 'ETH' + context('transfer panel amount should be reset', () => { + cy.closeTransactionHistoryPanel() + cy.findAmountInput().should('have.value', '') + cy.findMoveFundsButton().should('be.disabled') }) - ).click() + }) - cy.confirmMetamaskTransaction() + it('should claim funds', { defaultCommandTimeout: 200_000 }, () => { + // increase the timeout for this test as claim button can take ~(20 blocks *10 blocks/sec) to activate + cy.login({ networkType: 'parentChain' }) // login to L1 to claim the funds (otherwise would need to change network after clicking on claim) - cy.findByLabelText('show settled transactions') - .should('be.visible') - .click() + cy.findByLabelText('Open Transaction History') + .should('be.visible') + .click() - cy.findByText( - `${formatAmount(ETHToWithdraw, { - symbol: 'ETH' - })}` - ).should('be.visible') + cy.findClaimButton( + formatAmount(ETHToWithdraw, { + symbol: nativeTokenSymbol + }) + ).click() - cy.closeTransactionHistoryPanel() + cy.confirmMetamaskTransaction() - // the balance on the destination chain should not be the same as before - cy.findByLabelText('ETH balance amount on parentChain') - .should('be.visible') - .its('text') - .should('not.eq', l1EthBal) - }) - }) + cy.findByLabelText('show settled transactions') + .should('be.visible') + .click() + + cy.findByText( + `${formatAmount(ETHToWithdraw, { + symbol: nativeTokenSymbol + })}` + ).should('be.visible') + + cy.closeTransactionHistoryPanel() + + // the balance on the destination chain should not be the same as before + cy.findByLabelText('native token balance amount on parentChain') + .should('be.visible') + .its('text') + .should('not.eq', l1EthBal) + }) + } + ) // TODO => test for bridge amount higher than user's L2 ETH balance }) diff --git a/packages/arb-token-bridge-ui/tests/support/common.ts b/packages/arb-token-bridge-ui/tests/support/common.ts index bf4956abcf..83c65bd234 100644 --- a/packages/arb-token-bridge-ui/tests/support/common.ts +++ b/packages/arb-token-bridge-ui/tests/support/common.ts @@ -98,9 +98,12 @@ export const ERC20TokenSymbol = 'TESTARB' export const ERC20TokenDecimals = 18 export const invalidTokenAddress = '0x0000000000000000000000000000000000000000' -export const zeroToLessThanOneETH = /0(\.\d+)*( ETH)/ export const moreThanZeroBalance = /0(\.\d+)/ +export function getZeroToLessThanOneNativeToken(symbol: string) { + return new RegExp(`0(\\.\\d+)*( ${symbol})`) +} + export const importTokenThroughUI = (address: string) => { // Click on the ETH dropdown (Select token button) cy.findSelectTokenButton('ETH').click() From bc2c217f27146f8a820b3cebc1b23b877152f756 Mon Sep 17 00:00:00 2001 From: Bartek Date: Mon, 7 Oct 2024 14:21:26 +0200 Subject: [PATCH 22/99] fix --- packages/arb-token-bridge-ui/src/util/networks.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts index 60ce2abf3f..8b3566621f 100644 --- a/packages/arb-token-bridge-ui/src/util/networks.ts +++ b/packages/arb-token-bridge-ui/src/util/networks.ts @@ -396,8 +396,6 @@ export async function registerLocalNetwork() { rpcURLs[defaultL2Network.chainId] = localL2NetworkRpcUrl rpcURLs[defaultL3Network.chainId] = localL3NetworkRpcUrl - - console.log('process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN: ', process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true') registerCustomArbitrumNetwork(defaultL2Network) registerCustomArbitrumNetwork( process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' From 59575c8f70e9b50034347864435542eec3591ad2 Mon Sep 17 00:00:00 2001 From: Bartek Date: Mon, 7 Oct 2024 14:51:57 +0200 Subject: [PATCH 23/99] fix --- packages/arb-token-bridge-ui/tests/support/common.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/arb-token-bridge-ui/tests/support/common.ts b/packages/arb-token-bridge-ui/tests/support/common.ts index 83c65bd234..c76d3fe72a 100644 --- a/packages/arb-token-bridge-ui/tests/support/common.ts +++ b/packages/arb-token-bridge-ui/tests/support/common.ts @@ -58,15 +58,21 @@ export const getL1NetworkConfig = (): NetworkConfig => { export const getL2NetworkConfig = (): NetworkConfig => { const isOrbitTest = Cypress.env('ORBIT_TEST') == '1' + const nativeTokenSymbol = Cypress.env('NATIVE_TOKEN_SYMBOL') + const isCustomFeeToken = nativeTokenSymbol !== 'ETH' + + const l3Network = isCustomFeeToken + ? defaultL3CustomGasTokenNetwork + : defaultL3Network return { networkName: isOrbitTest ? 'l3-localhost' : 'arbitrum-localhost', rpcUrl: Cypress.env('ARB_RPC_URL'), chainId: isOrbitTest ? 333333 : 412346, - symbol: 'ETH', + symbol: nativeTokenSymbol, isTestnet: true, multiCall: isOrbitTest - ? defaultL3Network.tokenBridge!.childMultiCall + ? l3Network.tokenBridge!.childMultiCall : defaultL2Network.tokenBridge!.childMultiCall } } From b4b650f75c5f5e232b7b133d828cbf5e742059c1 Mon Sep 17 00:00:00 2001 From: Bartek Date: Mon, 7 Oct 2024 16:14:08 +0200 Subject: [PATCH 24/99] fixes --- .github/workflows/e2e-tests.yml | 6 +++--- packages/arb-token-bridge-ui/src/util/networks.ts | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index ee10d7ac63..8f98f389e4 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -102,9 +102,9 @@ jobs: start: yarn start command: >- ${{ - (matrix.test.type == 'orbit-eth') && 'yarn test:e2e:orbit --browser chromium' || - (matrix.test.type == 'orbit-custom' && 'yarn test:e2e:orbit:custom-gas-token --browser chromium') || - 'yarn test:e2e --browser chromium' + (matrix.test.type == 'orbit-eth') && 'yarn test:e2e:orbit --browser chrome' || + (matrix.test.type == 'orbit-custom' && 'yarn test:e2e:orbit:custom-gas-token --browser chrome') || + 'yarn test:e2e --browser chrome' }} wait-on: http://127.0.0.1:3000 wait-on-timeout: 120 diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts index 8b3566621f..d591d80a9e 100644 --- a/packages/arb-token-bridge-ui/src/util/networks.ts +++ b/packages/arb-token-bridge-ui/src/util/networks.ts @@ -318,7 +318,9 @@ export const defaultL3Network: ArbitrumNetwork = { bridge: '0xA584795e24628D9c067A6480b033C9E96281fcA3', inbox: '0xDcA690902d3154886Ec259308258D10EA5450996', outbox: '0xda243bD61B011024FC923164db75Dde198AC6175', - rollup: '0xf9B0F86aCc3e42B7DF373c9a8adb2803BF0a7662', + rollup: process.env.NEXT_PUBLIC_IS_E2E_TEST + ? '0xdeD540257498027B1De7DFD4fe6cc4CeC030F355' + : '0xf9B0F86aCc3e42B7DF373c9a8adb2803BF0a7662', sequencerInbox: '0x16c54EE2015CD824415c2077F4103f444E00A8cb' }, isCustom: true, From 05f2bbdd5aef41bc9f15b014c336e947ed99ca6d Mon Sep 17 00:00:00 2001 From: Bartek Date: Mon, 7 Oct 2024 16:39:42 +0200 Subject: [PATCH 25/99] fix --- .github/workflows/e2e-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 8f98f389e4..744be639ef 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -122,6 +122,7 @@ jobs: NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL: http://127.0.0.1:8545 NEXT_PUBLIC_LOCAL_ARBITRUM_RPC_URL: http://127.0.0.1:8547 NEXT_PUBLIC_LOCAL_L3_RPC_URL: http://127.0.0.1:3347 + NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN: ${{ matrix.test.type == 'orbit-custom' && 'true' }} - name: Archive e2e artifacts uses: actions/upload-artifact@v4 From 9b5ca657af6a9d38e781389e00fe2e69dcddde9d Mon Sep 17 00:00:00 2001 From: Bartek Date: Mon, 7 Oct 2024 17:23:38 +0200 Subject: [PATCH 26/99] try --- .../src/components/TransferPanel/TransferPanelSummary.tsx | 6 ++++++ packages/arb-token-bridge-ui/src/util/networks.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelSummary.tsx b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelSummary.tsx index 0a5200018c..85688bebc0 100644 --- a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelSummary.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelSummary.tsx @@ -222,6 +222,12 @@ export function TransferPanelSummary({ token }: TransferPanelSummaryProps) { 'grid grid-cols-[260px_auto] items-center text-sm font-light' )} > + + custom gas token?:{' '} + {process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' + ? 'true' + : 'false'} + You will pay in gas fees: diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts index d591d80a9e..75a7fa24e8 100644 --- a/packages/arb-token-bridge-ui/src/util/networks.ts +++ b/packages/arb-token-bridge-ui/src/util/networks.ts @@ -345,7 +345,7 @@ export const defaultL3Network: ArbitrumNetwork = { } } -export const defaultL3CustomGasTokenNetwork = { +export const defaultL3CustomGasTokenNetwork: ArbitrumNetwork = { chainId: 333333, parentChainId: ChainId.ArbitrumLocal, confirmPeriodBlocks: 20, From 9b7e66557df54427b962c55dd7089b7edf7596b7 Mon Sep 17 00:00:00 2001 From: Bartek Date: Mon, 7 Oct 2024 17:47:35 +0200 Subject: [PATCH 27/99] fix --- .github/workflows/e2e-tests.yml | 3 +-- package.json | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 744be639ef..ead1b83c12 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -99,7 +99,7 @@ jobs: - name: Run e2e tests via cypress-io/github-action uses: cypress-io/github-action@0da3c06ed8217b912deea9d8ee69630baed1737e # pin@v6.7.6 with: - start: yarn start + start: NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN=${{ matrix.test.type == 'orbit-custom' && 'true' || 'false' }} yarn start command: >- ${{ (matrix.test.type == 'orbit-eth') && 'yarn test:e2e:orbit --browser chrome' || @@ -122,7 +122,6 @@ jobs: NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL: http://127.0.0.1:8545 NEXT_PUBLIC_LOCAL_ARBITRUM_RPC_URL: http://127.0.0.1:8547 NEXT_PUBLIC_LOCAL_L3_RPC_URL: http://127.0.0.1:3347 - NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN: ${{ matrix.test.type == 'orbit-custom' && 'true' }} - name: Archive e2e artifacts uses: actions/upload-artifact@v4 diff --git a/package.json b/package.json index 2e655465d3..cdba235e7c 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "test:e2e": "yarn workspace arb-token-bridge-ui env-cmd --silent --file .e2e.env yarn synpress run --configFile synpress.config.ts", "test:e2e:cctp": "yarn test:e2e --configFile synpress.cctp.config.ts", "test:e2e:orbit": "E2E_ORBIT=true yarn test:e2e", - "test:e2e:orbit:custom-gas-token": "NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN=true yarn test:e2e" + "test:e2e:orbit:custom-gas-token": "yarn test:e2e" }, "resolutions": { "**/@walletconnect/ethereum-provider": "2.13.1", From 3125d8e5407e1fc33083c856515f5b1b9b4755ad Mon Sep 17 00:00:00 2001 From: Bartek Date: Mon, 7 Oct 2024 18:06:49 +0200 Subject: [PATCH 28/99] fix --- .github/workflows/e2e-tests.yml | 3 ++- .../src/components/TransferPanel/TransferPanelSummary.tsx | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index ead1b83c12..9868a6cfb1 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -99,7 +99,7 @@ jobs: - name: Run e2e tests via cypress-io/github-action uses: cypress-io/github-action@0da3c06ed8217b912deea9d8ee69630baed1737e # pin@v6.7.6 with: - start: NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN=${{ matrix.test.type == 'orbit-custom' && 'true' || 'false' }} yarn start + start: yarn start command: >- ${{ (matrix.test.type == 'orbit-eth') && 'yarn test:e2e:orbit --browser chrome' || @@ -122,6 +122,7 @@ jobs: NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL: http://127.0.0.1:8545 NEXT_PUBLIC_LOCAL_ARBITRUM_RPC_URL: http://127.0.0.1:8547 NEXT_PUBLIC_LOCAL_L3_RPC_URL: http://127.0.0.1:3347 + NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN=${{ matrix.test.type == 'orbit-custom' && 'true' || 'false' }} - name: Archive e2e artifacts uses: actions/upload-artifact@v4 diff --git a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelSummary.tsx b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelSummary.tsx index 85688bebc0..586624e974 100644 --- a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelSummary.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelSummary.tsx @@ -228,6 +228,10 @@ export function TransferPanelSummary({ token }: TransferPanelSummaryProps) { ? 'true' : 'false'} + + custom gas token value:{' '} + {process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN} + You will pay in gas fees: From f28912a293337cb5b2319c9fd33632eb19e43f88 Mon Sep 17 00:00:00 2001 From: Bartek Date: Mon, 7 Oct 2024 18:23:53 +0200 Subject: [PATCH 29/99] fix --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 9868a6cfb1..5b235bc37c 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -122,7 +122,7 @@ jobs: NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL: http://127.0.0.1:8545 NEXT_PUBLIC_LOCAL_ARBITRUM_RPC_URL: http://127.0.0.1:8547 NEXT_PUBLIC_LOCAL_L3_RPC_URL: http://127.0.0.1:3347 - NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN=${{ matrix.test.type == 'orbit-custom' && 'true' || 'false' }} + NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN: ${{ matrix.test.type == 'orbit-custom' && 'true' || 'false' }} - name: Archive e2e artifacts uses: actions/upload-artifact@v4 From 52eb29edb303442dee378a70b91185594917e1b8 Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 8 Oct 2024 11:46:55 +0200 Subject: [PATCH 30/99] fix --- .github/workflows/e2e-tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 5b235bc37c..902236ede3 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -99,7 +99,9 @@ jobs: - name: Run e2e tests via cypress-io/github-action uses: cypress-io/github-action@0da3c06ed8217b912deea9d8ee69630baed1737e # pin@v6.7.6 with: - start: yarn start + start: | + export NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN=${{ matrix.test.type == 'orbit-custom' && 'true' || 'false' }} + yarn start command: >- ${{ (matrix.test.type == 'orbit-eth') && 'yarn test:e2e:orbit --browser chrome' || From 1053116dc7ec310cd9b03e607a185448410d2a67 Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 8 Oct 2024 12:10:26 +0200 Subject: [PATCH 31/99] fix --- .github/workflows/e2e-tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 902236ede3..8e61afd071 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -99,9 +99,9 @@ jobs: - name: Run e2e tests via cypress-io/github-action uses: cypress-io/github-action@0da3c06ed8217b912deea9d8ee69630baed1737e # pin@v6.7.6 with: - start: | - export NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN=${{ matrix.test.type == 'orbit-custom' && 'true' || 'false' }} - yarn start + start: | + export NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN=${{ matrix.test.type == 'orbit-custom' && 'true' || 'false' }} + yarn start command: >- ${{ (matrix.test.type == 'orbit-eth') && 'yarn test:e2e:orbit --browser chrome' || From ecd415dd7d601fec9eb87465c1516cf0b0bae64a Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 8 Oct 2024 12:34:47 +0200 Subject: [PATCH 32/99] fix --- .github/workflows/e2e-tests.yml | 5 +---- package.json | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 8e61afd071..8f98f389e4 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -99,9 +99,7 @@ jobs: - name: Run e2e tests via cypress-io/github-action uses: cypress-io/github-action@0da3c06ed8217b912deea9d8ee69630baed1737e # pin@v6.7.6 with: - start: | - export NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN=${{ matrix.test.type == 'orbit-custom' && 'true' || 'false' }} - yarn start + start: yarn start command: >- ${{ (matrix.test.type == 'orbit-eth') && 'yarn test:e2e:orbit --browser chrome' || @@ -124,7 +122,6 @@ jobs: NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL: http://127.0.0.1:8545 NEXT_PUBLIC_LOCAL_ARBITRUM_RPC_URL: http://127.0.0.1:8547 NEXT_PUBLIC_LOCAL_L3_RPC_URL: http://127.0.0.1:3347 - NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN: ${{ matrix.test.type == 'orbit-custom' && 'true' || 'false' }} - name: Archive e2e artifacts uses: actions/upload-artifact@v4 diff --git a/package.json b/package.json index cdba235e7c..f5615b58c8 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "dev": "yarn workspace arb-token-bridge-ui dev", "build": "yarn workspace arb-token-bridge-ui build", "start": "yarn workspace arb-token-bridge-ui start", + "start:orbit-custom": "NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN=true yarn workspace arb-token-bridge-ui start", "audit:ci": "audit-ci --config ./audit-ci.jsonc", "test:ci": "yarn workspace arb-token-bridge-ui test:ci", "prettier:check": "./node_modules/.bin/prettier --check .", @@ -18,7 +19,7 @@ "test:e2e": "yarn workspace arb-token-bridge-ui env-cmd --silent --file .e2e.env yarn synpress run --configFile synpress.config.ts", "test:e2e:cctp": "yarn test:e2e --configFile synpress.cctp.config.ts", "test:e2e:orbit": "E2E_ORBIT=true yarn test:e2e", - "test:e2e:orbit:custom-gas-token": "yarn test:e2e" + "test:e2e:orbit:custom-gas-token": "NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN=true yarn test:e2e" }, "resolutions": { "**/@walletconnect/ethereum-provider": "2.13.1", From 3f3b88d2c4f9e80023dbf4faf19d7213cd95a702 Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 8 Oct 2024 12:59:11 +0200 Subject: [PATCH 33/99] fix --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 8f98f389e4..b385daded9 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -99,7 +99,7 @@ jobs: - name: Run e2e tests via cypress-io/github-action uses: cypress-io/github-action@0da3c06ed8217b912deea9d8ee69630baed1737e # pin@v6.7.6 with: - start: yarn start + start: ${{ matrix.test.type == 'orbit-custom' && 'yarn start:orbit-custom' || 'yarn start' }} command: >- ${{ (matrix.test.type == 'orbit-eth') && 'yarn test:e2e:orbit --browser chrome' || From e7583be51cac55ad8d4655d8177c756a6ce14169 Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 8 Oct 2024 13:53:23 +0200 Subject: [PATCH 34/99] fix --- .github/workflows/e2e-tests.yml | 1 + packages/arb-token-bridge-ui/next.config.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index b385daded9..c6daede41d 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -122,6 +122,7 @@ jobs: NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL: http://127.0.0.1:8545 NEXT_PUBLIC_LOCAL_ARBITRUM_RPC_URL: http://127.0.0.1:8547 NEXT_PUBLIC_LOCAL_L3_RPC_URL: http://127.0.0.1:3347 + NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN: ${{ matrix.test.type == 'orbit-custom' && 'true' || 'false' }} - name: Archive e2e artifacts uses: actions/upload-artifact@v4 diff --git a/packages/arb-token-bridge-ui/next.config.js b/packages/arb-token-bridge-ui/next.config.js index 957dae6ba5..f4124bd142 100644 --- a/packages/arb-token-bridge-ui/next.config.js +++ b/packages/arb-token-bridge-ui/next.config.js @@ -8,6 +8,10 @@ module.exports = { distDir: 'build', productionBrowserSourceMaps: true, reactStrictMode: true, + env: { + NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN: + process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN + }, async headers() { return [ { From 83d290aea30711058bea6458df5884a785a48ca9 Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 8 Oct 2024 14:44:59 +0200 Subject: [PATCH 35/99] fix --- .github/workflows/build-test.yml | 6 ++++++ .github/workflows/e2e-tests.yml | 3 ++- package.json | 4 ++-- packages/arb-token-bridge-ui/synpress.config.ts | 8 ++++---- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 00a3a4f2cd..f9365d49bd 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -38,6 +38,9 @@ jobs: name: "Build" runs-on: ubuntu-latest if: needs.check-files.outputs.run_tests == 'true' && ${{ !contains(github.event.pull_request.title, 'hotfix') }} + strategy: + matrix: + build-type: ['regular', 'orbit-custom'] steps: - name: Checkout uses: actions/checkout@v4 @@ -52,9 +55,12 @@ jobs: NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }} NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID }} THE_GRAPH_NETWORK_API_KEY: ${{ secrets.THE_GRAPH_NETWORK_API_KEY }} + NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN: ${{ matrix.build-type == 'orbit-custom' && 'true' || 'false' }} - name: Cache build artifacts uses: ./.github/actions/build-artifacts/cache + with: + key: build-${{ matrix.build-type }}-${{ github.sha }} test-ui: name: "Test UI" diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index c6daede41d..417708f7af 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -70,6 +70,8 @@ jobs: - name: Restore build artifacts uses: ./.github/actions/build-artifacts/restore + with: + key: build-${{ matrix.test.type == 'orbit-custom' && 'orbit-custom' || 'regular' }}-${{ github.sha }} - name: Install cypress run: yarn cypress install @@ -122,7 +124,6 @@ jobs: NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL: http://127.0.0.1:8545 NEXT_PUBLIC_LOCAL_ARBITRUM_RPC_URL: http://127.0.0.1:8547 NEXT_PUBLIC_LOCAL_L3_RPC_URL: http://127.0.0.1:3347 - NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN: ${{ matrix.test.type == 'orbit-custom' && 'true' || 'false' }} - name: Archive e2e artifacts uses: actions/upload-artifact@v4 diff --git a/package.json b/package.json index f5615b58c8..b210971fe1 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "dev": "yarn workspace arb-token-bridge-ui dev", "build": "yarn workspace arb-token-bridge-ui build", "start": "yarn workspace arb-token-bridge-ui start", - "start:orbit-custom": "NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN=true yarn workspace arb-token-bridge-ui start", + "start:orbit-custom": "yarn workspace arb-token-bridge-ui start", "audit:ci": "audit-ci --config ./audit-ci.jsonc", "test:ci": "yarn workspace arb-token-bridge-ui test:ci", "prettier:check": "./node_modules/.bin/prettier --check .", @@ -19,7 +19,7 @@ "test:e2e": "yarn workspace arb-token-bridge-ui env-cmd --silent --file .e2e.env yarn synpress run --configFile synpress.config.ts", "test:e2e:cctp": "yarn test:e2e --configFile synpress.cctp.config.ts", "test:e2e:orbit": "E2E_ORBIT=true yarn test:e2e", - "test:e2e:orbit:custom-gas-token": "NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN=true yarn test:e2e" + "test:e2e:orbit:custom-gas-token": "E2E_ORBIT_CUSTOM_GAS_TOKEN=true yarn test:e2e" }, "resolutions": { "**/@walletconnect/ethereum-provider": "2.13.1", diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 37deca73c6..57e5f9040c 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -44,12 +44,12 @@ const tests = process.env.TEST_FILE const isOrbitTest = [ process.env.E2E_ORBIT, - process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN + process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN ].includes('true') const shouldRecordVideo = process.env.CYPRESS_RECORD_VIDEO === 'true' const l3Network = - process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' + process.env.ORBIT_CUSTOM_GAS_TOKEN === 'true' ? defaultL3CustomGasTokenNetwork : defaultL3Network @@ -196,7 +196,7 @@ export default defineConfig({ checkForAssertions({ parentProvider, testType: - process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' + process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' ? 'orbit-custom' : process.env.E2E_ORBIT === 'true' ? 'orbit-eth' @@ -292,7 +292,7 @@ if (!process.env.PRIVATE_KEY_USER) { } const localWallet = new Wallet( - process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN + process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN ? utils.sha256(utils.toUtf8Bytes('user_fee_token_deployer')) : process.env.PRIVATE_KEY_CUSTOM ) From 25dfa4cbb20c30e846c625d652b3c2762cd7d3d1 Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 8 Oct 2024 15:08:53 +0200 Subject: [PATCH 36/99] fixes --- .github/workflows/e2e-tests.yml | 1 + packages/arb-token-bridge-ui/synpress.config.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 417708f7af..b04dffd142 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -119,6 +119,7 @@ jobs: PRIVATE_KEY_CUSTOM: ${{ secrets.E2E_PRIVATE_KEY }} PRIVATE_KEY_USER: ${{ secrets.E2E_PRIVATE_KEY_USER }} PRIVATE_KEY_CCTP: ${{ secrets.E2E_PRIVATE_KEY_CCTP }} + E2E_ORBIT_CUSTOM_GAS_TOKEN: ${{ matrix.build-type == 'orbit-custom' && 'true' || 'false' }} NEXT_PUBLIC_IS_E2E_TEST: true NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }} NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL: http://127.0.0.1:8545 diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 57e5f9040c..8cb4370b8c 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -292,7 +292,7 @@ if (!process.env.PRIVATE_KEY_USER) { } const localWallet = new Wallet( - process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN + process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' ? utils.sha256(utils.toUtf8Bytes('user_fee_token_deployer')) : process.env.PRIVATE_KEY_CUSTOM ) From f9f632cd164ece0af98d2408713ce6da4e5ea410 Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 8 Oct 2024 15:35:08 +0200 Subject: [PATCH 37/99] logs --- .github/workflows/e2e-tests.yml | 2 +- packages/arb-token-bridge-ui/synpress.config.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index b04dffd142..723b18e945 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -119,7 +119,7 @@ jobs: PRIVATE_KEY_CUSTOM: ${{ secrets.E2E_PRIVATE_KEY }} PRIVATE_KEY_USER: ${{ secrets.E2E_PRIVATE_KEY_USER }} PRIVATE_KEY_CCTP: ${{ secrets.E2E_PRIVATE_KEY_CCTP }} - E2E_ORBIT_CUSTOM_GAS_TOKEN: ${{ matrix.build-type == 'orbit-custom' && 'true' || 'false' }} + NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN: ${{ matrix.build-type == 'orbit-custom' && 'true' || 'false' }} NEXT_PUBLIC_IS_E2E_TEST: true NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }} NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL: http://127.0.0.1:8545 diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 8cb4370b8c..51bbf1caf0 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -48,6 +48,13 @@ const isOrbitTest = [ ].includes('true') const shouldRecordVideo = process.env.CYPRESS_RECORD_VIDEO === 'true' +console.log({ isOrbitTest }) +console.log('process.env.E2E_ORBIT: ', process.env.E2E_ORBIT) +console.log( + 'process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN: ', + process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN +) + const l3Network = process.env.ORBIT_CUSTOM_GAS_TOKEN === 'true' ? defaultL3CustomGasTokenNetwork From ebb974f76e338be3fa11e205752db38d9c2ee1fb Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 8 Oct 2024 16:00:30 +0200 Subject: [PATCH 38/99] fixes --- package.json | 2 +- packages/arb-token-bridge-ui/synpress.config.ts | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index b210971fe1..b9213b2bbd 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "test:e2e": "yarn workspace arb-token-bridge-ui env-cmd --silent --file .e2e.env yarn synpress run --configFile synpress.config.ts", "test:e2e:cctp": "yarn test:e2e --configFile synpress.cctp.config.ts", "test:e2e:orbit": "E2E_ORBIT=true yarn test:e2e", - "test:e2e:orbit:custom-gas-token": "E2E_ORBIT_CUSTOM_GAS_TOKEN=true yarn test:e2e" + "test:e2e:orbit:custom-gas-token": "NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN=true yarn test:e2e" }, "resolutions": { "**/@walletconnect/ethereum-provider": "2.13.1", diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 51bbf1caf0..5c83790814 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -44,17 +44,10 @@ const tests = process.env.TEST_FILE const isOrbitTest = [ process.env.E2E_ORBIT, - process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN + process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN ].includes('true') const shouldRecordVideo = process.env.CYPRESS_RECORD_VIDEO === 'true' -console.log({ isOrbitTest }) -console.log('process.env.E2E_ORBIT: ', process.env.E2E_ORBIT) -console.log( - 'process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN: ', - process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN -) - const l3Network = process.env.ORBIT_CUSTOM_GAS_TOKEN === 'true' ? defaultL3CustomGasTokenNetwork @@ -203,7 +196,7 @@ export default defineConfig({ checkForAssertions({ parentProvider, testType: - process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' + process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' ? 'orbit-custom' : process.env.E2E_ORBIT === 'true' ? 'orbit-eth' @@ -299,7 +292,7 @@ if (!process.env.PRIVATE_KEY_USER) { } const localWallet = new Wallet( - process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' + process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' ? utils.sha256(utils.toUtf8Bytes('user_fee_token_deployer')) : process.env.PRIVATE_KEY_CUSTOM ) From 84f1d2efebde86be1a189f1d8c26cf6c45860249 Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 8 Oct 2024 17:07:09 +0200 Subject: [PATCH 39/99] fixes --- .github/workflows/e2e-tests.yml | 2 +- package.json | 2 +- packages/arb-token-bridge-ui/next.config.js | 8 ++++---- packages/arb-token-bridge-ui/src/util/networks.ts | 5 +++-- packages/arb-token-bridge-ui/synpress.config.ts | 14 ++++++++++---- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 723b18e945..b0aadb1c88 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -119,7 +119,7 @@ jobs: PRIVATE_KEY_CUSTOM: ${{ secrets.E2E_PRIVATE_KEY }} PRIVATE_KEY_USER: ${{ secrets.E2E_PRIVATE_KEY_USER }} PRIVATE_KEY_CCTP: ${{ secrets.E2E_PRIVATE_KEY_CCTP }} - NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN: ${{ matrix.build-type == 'orbit-custom' && 'true' || 'false' }} + E2E_ORBIT_CUSTOM_GAS_TOKEN: ${{ matrix.test.type == 'orbit-custom' && 'true' || 'false' }} NEXT_PUBLIC_IS_E2E_TEST: true NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }} NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL: http://127.0.0.1:8545 diff --git a/package.json b/package.json index b9213b2bbd..b210971fe1 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "test:e2e": "yarn workspace arb-token-bridge-ui env-cmd --silent --file .e2e.env yarn synpress run --configFile synpress.config.ts", "test:e2e:cctp": "yarn test:e2e --configFile synpress.cctp.config.ts", "test:e2e:orbit": "E2E_ORBIT=true yarn test:e2e", - "test:e2e:orbit:custom-gas-token": "NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN=true yarn test:e2e" + "test:e2e:orbit:custom-gas-token": "E2E_ORBIT_CUSTOM_GAS_TOKEN=true yarn test:e2e" }, "resolutions": { "**/@walletconnect/ethereum-provider": "2.13.1", diff --git a/packages/arb-token-bridge-ui/next.config.js b/packages/arb-token-bridge-ui/next.config.js index f4124bd142..8517131d79 100644 --- a/packages/arb-token-bridge-ui/next.config.js +++ b/packages/arb-token-bridge-ui/next.config.js @@ -8,10 +8,10 @@ module.exports = { distDir: 'build', productionBrowserSourceMaps: true, reactStrictMode: true, - env: { - NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN: - process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN - }, + // env: { + // NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN: + // process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN + // }, async headers() { return [ { diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts index 75a7fa24e8..a9aa6733ec 100644 --- a/packages/arb-token-bridge-ui/src/util/networks.ts +++ b/packages/arb-token-bridge-ui/src/util/networks.ts @@ -392,7 +392,7 @@ export const localL3NetworkRpcUrl = loadEnvironmentVariableWithFallback({ fallback: 'http://127.0.0.1:3347' }) -export async function registerLocalNetwork() { +export async function registerLocalNetwork(isCustomGasToken = false) { try { rpcURLs[defaultL1Network.chainId] = localL1NetworkRpcUrl rpcURLs[defaultL2Network.chainId] = localL2NetworkRpcUrl @@ -400,7 +400,8 @@ export async function registerLocalNetwork() { registerCustomArbitrumNetwork(defaultL2Network) registerCustomArbitrumNetwork( - process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' + process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' || + isCustomGasToken ? defaultL3CustomGasTokenNetwork : defaultL3Network ) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 5c83790814..b16ee39a99 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -44,7 +44,7 @@ const tests = process.env.TEST_FILE const isOrbitTest = [ process.env.E2E_ORBIT, - process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN + process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN ].includes('true') const shouldRecordVideo = process.env.CYPRESS_RECORD_VIDEO === 'true' @@ -70,7 +70,13 @@ export default defineConfig({ e2e: { async setupNodeEvents(on, config) { logsPrinter(on) - await registerLocalNetwork() + console.log( + 'process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN: ', + process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN + ) + await registerLocalNetwork( + process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' + ) if (!ethRpcUrl && !isOrbitTest) { throw new Error('NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL variable missing.') @@ -196,7 +202,7 @@ export default defineConfig({ checkForAssertions({ parentProvider, testType: - process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' + process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' ? 'orbit-custom' : process.env.E2E_ORBIT === 'true' ? 'orbit-eth' @@ -292,7 +298,7 @@ if (!process.env.PRIVATE_KEY_USER) { } const localWallet = new Wallet( - process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' + process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' ? utils.sha256(utils.toUtf8Bytes('user_fee_token_deployer')) : process.env.PRIVATE_KEY_CUSTOM ) From d021e89f2557ce3633a2e540cb3dbccb681ff9da Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 8 Oct 2024 18:08:31 +0200 Subject: [PATCH 40/99] fixes --- .../arb-token-bridge-ui/src/util/networks.ts | 21 ++++++++++-- .../arb-token-bridge-ui/synpress.config.ts | 32 +++++++------------ 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts index a9aa6733ec..264d610a68 100644 --- a/packages/arb-token-bridge-ui/src/util/networks.ts +++ b/packages/arb-token-bridge-ui/src/util/networks.ts @@ -1,3 +1,4 @@ +import { StaticJsonRpcProvider } from '@ethersproject/providers' import { ArbitrumNetwork, getChildrenForNetwork, @@ -9,6 +10,7 @@ import { import { loadEnvironmentVariableWithFallback } from './index' import { getBridgeUiConfigForChain } from './bridgeUiConfig' import { chainIdToInfuraUrl } from './infura' +import { fetchErc20Data } from './TokenUtils' export enum ChainId { // L1 @@ -392,16 +394,29 @@ export const localL3NetworkRpcUrl = loadEnvironmentVariableWithFallback({ fallback: 'http://127.0.0.1:3347' }) -export async function registerLocalNetwork(isCustomGasToken = false) { +export async function registerLocalNetwork() { try { rpcURLs[defaultL1Network.chainId] = localL1NetworkRpcUrl rpcURLs[defaultL2Network.chainId] = localL2NetworkRpcUrl rpcURLs[defaultL3Network.chainId] = localL3NetworkRpcUrl registerCustomArbitrumNetwork(defaultL2Network) + + let isLocalCustomNativeToken = false + try { + const data = await fetchErc20Data({ + address: defaultL3CustomGasTokenNetwork.nativeToken!, + provider: new StaticJsonRpcProvider(localL2NetworkRpcUrl) + }) + if (data.symbol === 'TN') { + isLocalCustomNativeToken = true + } + } catch (e) { + // not the native token + } + registerCustomArbitrumNetwork( - process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' || - isCustomGasToken + isLocalCustomNativeToken ? defaultL3CustomGasTokenNetwork : defaultL3Network ) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index b16ee39a99..47c9f11f45 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -42,10 +42,7 @@ const tests = process.env.TEST_FILE ? [process.env.TEST_FILE] : specFiles.map(file => file.file) -const isOrbitTest = [ - process.env.E2E_ORBIT, - process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN -].includes('true') +const isOrbitTest = process.env.E2E_ORBIT === 'true' const shouldRecordVideo = process.env.CYPRESS_RECORD_VIDEO === 'true' const l3Network = @@ -70,13 +67,11 @@ export default defineConfig({ e2e: { async setupNodeEvents(on, config) { logsPrinter(on) - console.log( - 'process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN: ', - process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN - ) - await registerLocalNetwork( - process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' - ) + await registerLocalNetwork() + + const bridger = await Erc20Bridger.fromProvider(childProvider) + const ethBridger = await EthBridger.fromProvider(childProvider) + const isCustomFeeToken = isNonZeroAddress(ethBridger.nativeToken) if (!ethRpcUrl && !isOrbitTest) { throw new Error('NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL variable missing.') @@ -116,10 +111,6 @@ export default defineConfig({ // Deploy and fund ERC20 to Parent and Child chains const l1ERC20Token = await deployERC20ToParentChain() - const bridger = await Erc20Bridger.fromProvider(childProvider) - const ethBridger = await EthBridger.fromProvider(childProvider) - const isCustomFeeToken = isNonZeroAddress(ethBridger.nativeToken) - // Approve custom fee token if not ETH if (isCustomFeeToken) { await approveCustomFeeToken( @@ -201,12 +192,11 @@ export default defineConfig({ // Also keep watching assertions since they will act as a proof of activity and claims for withdrawals checkForAssertions({ parentProvider, - testType: - process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' - ? 'orbit-custom' - : process.env.E2E_ORBIT === 'true' - ? 'orbit-eth' - : 'regular' + testType: isCustomFeeToken + ? 'orbit-custom' + : process.env.E2E_ORBIT === 'true' + ? 'orbit-eth' + : 'regular' }) // Set Cypress variables From 39dd637c8d679fda3a2cf39f6f4f09c96d3f78d6 Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 8 Oct 2024 18:49:26 +0200 Subject: [PATCH 41/99] clean up --- .github/workflows/build-test.yml | 6 - .github/workflows/e2e-tests.yml | 5 +- package.json | 1 - packages/arb-token-bridge-ui/next.config.js | 4 - .../TransferPanel/TransferPanelSummary.tsx | 10 -- .../src/util/wagmi/wagmiAdditionalNetworks.ts | 2 +- .../arb-token-bridge-ui/synpress.config.ts | 123 +++++++++++------- .../tests/support/common.ts | 2 - 8 files changed, 75 insertions(+), 78 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index f9365d49bd..00a3a4f2cd 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -38,9 +38,6 @@ jobs: name: "Build" runs-on: ubuntu-latest if: needs.check-files.outputs.run_tests == 'true' && ${{ !contains(github.event.pull_request.title, 'hotfix') }} - strategy: - matrix: - build-type: ['regular', 'orbit-custom'] steps: - name: Checkout uses: actions/checkout@v4 @@ -55,12 +52,9 @@ jobs: NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }} NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID }} THE_GRAPH_NETWORK_API_KEY: ${{ secrets.THE_GRAPH_NETWORK_API_KEY }} - NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN: ${{ matrix.build-type == 'orbit-custom' && 'true' || 'false' }} - name: Cache build artifacts uses: ./.github/actions/build-artifacts/cache - with: - key: build-${{ matrix.build-type }}-${{ github.sha }} test-ui: name: "Test UI" diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index b0aadb1c88..8f98f389e4 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -70,8 +70,6 @@ jobs: - name: Restore build artifacts uses: ./.github/actions/build-artifacts/restore - with: - key: build-${{ matrix.test.type == 'orbit-custom' && 'orbit-custom' || 'regular' }}-${{ github.sha }} - name: Install cypress run: yarn cypress install @@ -101,7 +99,7 @@ jobs: - name: Run e2e tests via cypress-io/github-action uses: cypress-io/github-action@0da3c06ed8217b912deea9d8ee69630baed1737e # pin@v6.7.6 with: - start: ${{ matrix.test.type == 'orbit-custom' && 'yarn start:orbit-custom' || 'yarn start' }} + start: yarn start command: >- ${{ (matrix.test.type == 'orbit-eth') && 'yarn test:e2e:orbit --browser chrome' || @@ -119,7 +117,6 @@ jobs: PRIVATE_KEY_CUSTOM: ${{ secrets.E2E_PRIVATE_KEY }} PRIVATE_KEY_USER: ${{ secrets.E2E_PRIVATE_KEY_USER }} PRIVATE_KEY_CCTP: ${{ secrets.E2E_PRIVATE_KEY_CCTP }} - E2E_ORBIT_CUSTOM_GAS_TOKEN: ${{ matrix.test.type == 'orbit-custom' && 'true' || 'false' }} NEXT_PUBLIC_IS_E2E_TEST: true NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }} NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL: http://127.0.0.1:8545 diff --git a/package.json b/package.json index b210971fe1..28b20b0721 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ "dev": "yarn workspace arb-token-bridge-ui dev", "build": "yarn workspace arb-token-bridge-ui build", "start": "yarn workspace arb-token-bridge-ui start", - "start:orbit-custom": "yarn workspace arb-token-bridge-ui start", "audit:ci": "audit-ci --config ./audit-ci.jsonc", "test:ci": "yarn workspace arb-token-bridge-ui test:ci", "prettier:check": "./node_modules/.bin/prettier --check .", diff --git a/packages/arb-token-bridge-ui/next.config.js b/packages/arb-token-bridge-ui/next.config.js index 8517131d79..957dae6ba5 100644 --- a/packages/arb-token-bridge-ui/next.config.js +++ b/packages/arb-token-bridge-ui/next.config.js @@ -8,10 +8,6 @@ module.exports = { distDir: 'build', productionBrowserSourceMaps: true, reactStrictMode: true, - // env: { - // NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN: - // process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN - // }, async headers() { return [ { diff --git a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelSummary.tsx b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelSummary.tsx index 586624e974..0a5200018c 100644 --- a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelSummary.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelSummary.tsx @@ -222,16 +222,6 @@ export function TransferPanelSummary({ token }: TransferPanelSummaryProps) { 'grid grid-cols-[260px_auto] items-center text-sm font-light' )} > - - custom gas token?:{' '} - {process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' - ? 'true' - : 'false'} - - - custom gas token value:{' '} - {process.env.NEXT_PUBLIC_E2E_ORBIT_CUSTOM_GAS_TOKEN} - You will pay in gas fees: diff --git a/packages/arb-token-bridge-ui/src/util/wagmi/wagmiAdditionalNetworks.ts b/packages/arb-token-bridge-ui/src/util/wagmi/wagmiAdditionalNetworks.ts index bc063d4e82..6a915e10e0 100644 --- a/packages/arb-token-bridge-ui/src/util/wagmi/wagmiAdditionalNetworks.ts +++ b/packages/arb-token-bridge-ui/src/util/wagmi/wagmiAdditionalNetworks.ts @@ -21,7 +21,7 @@ export function chainToWagmiChain(chain: ChainWithRpcUrl): Chain { id: chain.chainId, name: chain.name, network: chain.name.toLowerCase().split(' ').join('-'), - nativeCurrency: nativeTokenData || ether, + nativeCurrency: nativeTokenData ?? ether, rpcUrls: { default: { http: [chain.rpcUrl] diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 47c9f11f45..06aba076f8 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -12,7 +12,6 @@ import { StaticJsonRpcProvider } from '@ethersproject/providers' import synpressPlugins from '@synthetixio/synpress/plugins' import { TestERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestERC20__factory' import { TestWETH9__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestWETH9__factory' -import { TestWETH9 } from '@arbitrum/sdk/dist/lib/abi/TestWETH9' import { Erc20Bridger, EthBridger } from '@arbitrum/sdk' import logsPrinter from 'cypress-terminal-report/src/installLogsPrinter' import { getL2ERC20Address } from './src/util/TokenUtils' @@ -113,14 +112,14 @@ export default defineConfig({ // Approve custom fee token if not ETH if (isCustomFeeToken) { - await approveCustomFeeToken( - localWallet.connect(parentProvider), - l1ERC20Token.address - ) - await approveCustomFeeToken( - localWallet.connect(parentProvider), - bridger.nativeToken! - ) + await approveCustomFeeToken({ + signer: localWallet.connect(parentProvider), + erc20ParentAddress: l1ERC20Token.address + }) + await approveCustomFeeToken({ + signer: localWallet.connect(parentProvider), + erc20ParentAddress: bridger.nativeToken! + }) await ethBridger.approveGasToken({ parentSigner: localWallet.connect(parentProvider) }) @@ -128,11 +127,11 @@ export default defineConfig({ await fundUserWalletNativeCurrency() await fundErc20ToParentChain(l1ERC20Token) - await fundErc20ToChildChain( - l1ERC20Token.address, - localWallet.connect(parentProvider), - '5' - ) + await fundErc20ToChildChain({ + signer: localWallet.connect(parentProvider), + parentErc20Address: l1ERC20Token.address, + amount: parseUnits('5', ERC20TokenDecimals) + }) await approveErc20(l1ERC20Token) if ( @@ -145,13 +144,10 @@ export default defineConfig({ } if (isCustomFeeToken) { - await approveCustomFeeToken( - userWallet.connect(parentProvider), - bridger.nativeToken! - ) - } - - if (isCustomFeeToken) { + await approveCustomFeeToken({ + signer: userWallet.connect(parentProvider), + erc20ParentAddress: bridger.nativeToken! + }) await ethBridger.approveGasToken({ parentSigner: userWallet.connect(parentProvider) }) @@ -164,24 +160,18 @@ export default defineConfig({ // Wrap ETH to test WETH transactions and approve it's usage await fundWeth('parentChain') await approveWeth() - // await fundWeth('childChain') if (isCustomFeeToken) { - await approveCustomFeeToken( - userWallet.connect(parentProvider), - l1WethAddress - ) + await approveCustomFeeToken({ + signer: userWallet.connect(parentProvider), + erc20ParentAddress: l1WethAddress + }) } - const wethBal = await getWethContract( - parentProvider, - l1WethAddress - ).balanceOf(userWallet.address) - - await fundErc20ToChildChain( - l1WethAddress, - userWallet.connect(parentProvider), - '0.1' - ) + await fundErc20ToChildChain({ + signer: userWallet.connect(parentProvider), + parentErc20Address: l1WethAddress, + amount: utils.parseEther('0.1') + }) // Generate activity on chains so that assertions get posted and claims can be made generateActivityOnChains({ @@ -224,10 +214,10 @@ export default defineConfig({ config.env.L2_WETH_ADDRESS = l2WethAddress if (isCustomFeeToken) { - await approveCustomFeeToken( - userWallet.connect(parentProvider), - l1WethAddress - ) + await approveCustomFeeToken({ + signer: userWallet.connect(parentProvider), + erc20ParentAddress: l1WethAddress + }) } config.env.REDEEM_RETRYABLE_TEST_TX = @@ -235,6 +225,29 @@ export default defineConfig({ synpressPlugins(on, config) setupCypressTasks(on, { requiresNetworkSetup: true }) + + // after everything is done, revoke approvals so e2e runs properly + if (isCustomFeeToken) { + await approveCustomFeeToken({ + signer: userWallet.connect(parentProvider), + erc20ParentAddress: bridger.nativeToken!, + amount: BigNumber.from(0) + }) + await ethBridger.approveGasToken({ + parentSigner: userWallet.connect(parentProvider), + amount: BigNumber.from(0) + }) + await bridger.approveGasToken({ + parentSigner: userWallet.connect(parentProvider), + erc20ParentAddress: l1WethAddress, + amount: BigNumber.from(0) + }) + await approveCustomFeeToken({ + signer: userWallet.connect(parentProvider), + erc20ParentAddress: l1WethAddress, + amount: BigNumber.from(0) + }) + } return config }, baseUrl: 'http://localhost:3000', @@ -294,16 +307,22 @@ const localWallet = new Wallet( ) const userWallet = new Wallet(process.env.PRIVATE_KEY_USER) -async function approveCustomFeeToken( - signer: Wallet, +async function approveCustomFeeToken({ + signer, + erc20ParentAddress, + amount +}: { + signer: Wallet erc20ParentAddress: string -) { + amount?: BigNumber +}) { console.log('Approving custom fee token...') const childErc20Bridger = await Erc20Bridger.fromProvider(childProvider) await childErc20Bridger.approveGasToken({ parentSigner: signer, - erc20ParentAddress + erc20ParentAddress, + amount }) } @@ -457,11 +476,15 @@ async function fundErc20ToParentChain(l1ERC20Token: Contract) { await transferTx.wait() } -async function fundErc20ToChildChain( - parentErc20Address: string, - signer: Wallet, - amount: string -) { +async function fundErc20ToChildChain({ + parentErc20Address, + signer, + amount +}: { + parentErc20Address: string + signer: Wallet + amount: BigNumber +}) { // first deploy the ERC20 to L2 (if not, it might throw a gas error later) await deployERC20ToChildChain(parentErc20Address) @@ -480,7 +503,7 @@ async function fundErc20ToChildChain( parentSigner, childProvider, erc20ParentAddress: parentErc20Address, - amount: parseUnits(amount, ERC20TokenDecimals), + amount, destinationAddress: userWallet.address }) const depositRec = await depositTx.wait() diff --git a/packages/arb-token-bridge-ui/tests/support/common.ts b/packages/arb-token-bridge-ui/tests/support/common.ts index c76d3fe72a..c8ea56473e 100644 --- a/packages/arb-token-bridge-ui/tests/support/common.ts +++ b/packages/arb-token-bridge-ui/tests/support/common.ts @@ -247,8 +247,6 @@ export async function checkForAssertions({ parentProvider: Provider testType: 'regular' | 'orbit-eth' | 'orbit-custom' }) { - console.log('Checking for assertions...') - const abi = [ 'function latestConfirmed() public view returns (uint64)', 'function latestNodeCreated() public view returns (uint64)' From b3a797dfc0ce4a20edd3748ac217042c808a177c Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 8 Oct 2024 19:25:57 +0200 Subject: [PATCH 42/99] clean up --- .../arb-token-bridge-ui/src/util/networks.ts | 1 + .../arb-token-bridge-ui/synpress.config.ts | 29 ------------------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts index 264d610a68..88785f42ba 100644 --- a/packages/arb-token-bridge-ui/src/util/networks.ts +++ b/packages/arb-token-bridge-ui/src/util/networks.ts @@ -413,6 +413,7 @@ export async function registerLocalNetwork() { } } catch (e) { // not the native token + isLocalCustomNativeToken = false } registerCustomArbitrumNetwork( diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 06aba076f8..6d333c3ac9 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -213,41 +213,12 @@ export default defineConfig({ config.env.L1_WETH_ADDRESS = l1WethAddress config.env.L2_WETH_ADDRESS = l2WethAddress - if (isCustomFeeToken) { - await approveCustomFeeToken({ - signer: userWallet.connect(parentProvider), - erc20ParentAddress: l1WethAddress - }) - } - config.env.REDEEM_RETRYABLE_TEST_TX = await generateTestTxForRedeemRetryable() synpressPlugins(on, config) setupCypressTasks(on, { requiresNetworkSetup: true }) - // after everything is done, revoke approvals so e2e runs properly - if (isCustomFeeToken) { - await approveCustomFeeToken({ - signer: userWallet.connect(parentProvider), - erc20ParentAddress: bridger.nativeToken!, - amount: BigNumber.from(0) - }) - await ethBridger.approveGasToken({ - parentSigner: userWallet.connect(parentProvider), - amount: BigNumber.from(0) - }) - await bridger.approveGasToken({ - parentSigner: userWallet.connect(parentProvider), - erc20ParentAddress: l1WethAddress, - amount: BigNumber.from(0) - }) - await approveCustomFeeToken({ - signer: userWallet.connect(parentProvider), - erc20ParentAddress: l1WethAddress, - amount: BigNumber.from(0) - }) - } return config }, baseUrl: 'http://localhost:3000', From b02242c1267879c38b854d4c41195e47ed13a21e Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 8 Oct 2024 20:26:33 +0200 Subject: [PATCH 43/99] fix --- .../arb-token-bridge-ui/tests/e2e/specs/withdrawETH.cy.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawETH.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawETH.cy.ts index e98e0da531..da9ad51646 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawETH.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawETH.cy.ts @@ -131,7 +131,9 @@ describe('Withdraw native token', () => { cy.closeTransactionHistoryPanel() // the balance on the destination chain should not be the same as before - cy.findByLabelText('native token balance amount on parentChain') + cy.findByLabelText( + `${nativeTokenSymbol} balance amount on parentChain` + ) .should('be.visible') .its('text') .should('not.eq', l1EthBal) From 30ee75251f0641f11e377aaf75076d4d0d954dd9 Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 8 Oct 2024 20:44:54 +0200 Subject: [PATCH 44/99] fix --- .../arb-token-bridge-ui/synpress.config.ts | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 6d333c3ac9..0b31f09452 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -41,7 +41,10 @@ const tests = process.env.TEST_FILE ? [process.env.TEST_FILE] : specFiles.map(file => file.file) -const isOrbitTest = process.env.E2E_ORBIT === 'true' +const isOrbitTest = [ + process.env.E2E_ORBIT, + process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN +].includes('true') const shouldRecordVideo = process.env.CYPRESS_RECORD_VIDEO === 'true' const l3Network = @@ -68,7 +71,7 @@ export default defineConfig({ logsPrinter(on) await registerLocalNetwork() - const bridger = await Erc20Bridger.fromProvider(childProvider) + const erc20Bridger = await Erc20Bridger.fromProvider(childProvider) const ethBridger = await EthBridger.fromProvider(childProvider) const isCustomFeeToken = isNonZeroAddress(ethBridger.nativeToken) @@ -118,17 +121,19 @@ export default defineConfig({ }) await approveCustomFeeToken({ signer: localWallet.connect(parentProvider), - erc20ParentAddress: bridger.nativeToken! + erc20ParentAddress: erc20Bridger.nativeToken! }) await ethBridger.approveGasToken({ parentSigner: localWallet.connect(parentProvider) }) } - await fundUserWalletNativeCurrency() + if (isCustomFeeToken) { + await fundUserWalletNativeCurrency() + } await fundErc20ToParentChain(l1ERC20Token) await fundErc20ToChildChain({ - signer: localWallet.connect(parentProvider), + parentSigner: localWallet.connect(parentProvider), parentErc20Address: l1ERC20Token.address, amount: parseUnits('5', ERC20TokenDecimals) }) @@ -146,12 +151,12 @@ export default defineConfig({ if (isCustomFeeToken) { await approveCustomFeeToken({ signer: userWallet.connect(parentProvider), - erc20ParentAddress: bridger.nativeToken! + erc20ParentAddress: erc20Bridger.nativeToken! }) await ethBridger.approveGasToken({ parentSigner: userWallet.connect(parentProvider) }) - await bridger.approveGasToken({ + await erc20Bridger.approveGasToken({ parentSigner: userWallet.connect(parentProvider), erc20ParentAddress: l1WethAddress }) @@ -168,7 +173,7 @@ export default defineConfig({ } await fundErc20ToChildChain({ - signer: userWallet.connect(parentProvider), + parentSigner: userWallet.connect(parentProvider), parentErc20Address: l1WethAddress, amount: utils.parseEther('0.1') }) @@ -218,7 +223,6 @@ export default defineConfig({ synpressPlugins(on, config) setupCypressTasks(on, { requiresNetworkSetup: true }) - return config }, baseUrl: 'http://localhost:3000', @@ -299,16 +303,11 @@ async function approveCustomFeeToken({ async function fundUserWalletNativeCurrency() { const childEthBridger = await EthBridger.fromProvider(childProvider) - const isCustomFeeToken = typeof childEthBridger.nativeToken !== 'undefined' - - if (!isCustomFeeToken) { - return - } const address = await userWallet.getAddress() const tokenContract = TestERC20__factory.connect( - childEthBridger.nativeToken, + childEthBridger.nativeToken!, localWallet.connect(parentProvider) ) @@ -413,10 +412,6 @@ async function fundWeth(networkType: NetworkType) { await tx.wait() } -async function depositWeth() { - console.log(`Depositing WETH...`) -} - async function approveWeth() { console.log('Approving WETH...') console.log({ l1WethAddress }) @@ -449,18 +444,17 @@ async function fundErc20ToParentChain(l1ERC20Token: Contract) { async function fundErc20ToChildChain({ parentErc20Address, - signer, + parentSigner, amount }: { parentErc20Address: string - signer: Wallet + parentSigner: Wallet amount: BigNumber }) { // first deploy the ERC20 to L2 (if not, it might throw a gas error later) await deployERC20ToChildChain(parentErc20Address) const erc20Bridger = await Erc20Bridger.fromProvider(childProvider) - const parentSigner = signer // approve the ERC20 token for spending const approvalTx = await erc20Bridger.approveToken({ From a7eb5e9935023605fbe6232007feee85f7688d80 Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 8 Oct 2024 21:21:49 +0200 Subject: [PATCH 45/99] logs --- packages/arb-token-bridge-ui/synpress.config.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 0b31f09452..f01d2095cb 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -14,7 +14,7 @@ import { TestERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestERC import { TestWETH9__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestWETH9__factory' import { Erc20Bridger, EthBridger } from '@arbitrum/sdk' import logsPrinter from 'cypress-terminal-report/src/installLogsPrinter' -import { getL2ERC20Address } from './src/util/TokenUtils' +import { fetchErc20Data, getL2ERC20Address } from './src/util/TokenUtils' import specFiles from './tests/e2e/specfiles.json' import { contractAbi, contractByteCode } from './testErc20Token' import { @@ -71,6 +71,16 @@ export default defineConfig({ logsPrinter(on) await registerLocalNetwork() + try { + const data = await fetchErc20Data({ + address: defaultL3CustomGasTokenNetwork.nativeToken!, + provider: new StaticJsonRpcProvider(ethRpcUrl) + }) + console.log({ data }) + } catch (err) { + console.log({ err }) + } + const erc20Bridger = await Erc20Bridger.fromProvider(childProvider) const ethBridger = await EthBridger.fromProvider(childProvider) const isCustomFeeToken = isNonZeroAddress(ethBridger.nativeToken) @@ -414,7 +424,6 @@ async function fundWeth(networkType: NetworkType) { async function approveWeth() { console.log('Approving WETH...') - console.log({ l1WethAddress }) const tx = await getWethContract(parentProvider, l1WethAddress).approve( l1WethGateway, constants.MaxInt256 From 10a11ae0df44eed5e3a2afb4464d328eee44840d Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 8 Oct 2024 21:44:59 +0200 Subject: [PATCH 46/99] logs --- .../arb-token-bridge-ui/src/util/networks.ts | 25 ++++++++++--------- .../arb-token-bridge-ui/synpress.config.ts | 4 +-- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts index 88785f42ba..7e1f73f531 100644 --- a/packages/arb-token-bridge-ui/src/util/networks.ts +++ b/packages/arb-token-bridge-ui/src/util/networks.ts @@ -394,7 +394,7 @@ export const localL3NetworkRpcUrl = loadEnvironmentVariableWithFallback({ fallback: 'http://127.0.0.1:3347' }) -export async function registerLocalNetwork() { +export async function registerLocalNetwork(isLocalCustomNativeToken?: boolean) { try { rpcURLs[defaultL1Network.chainId] = localL1NetworkRpcUrl rpcURLs[defaultL2Network.chainId] = localL2NetworkRpcUrl @@ -402,18 +402,19 @@ export async function registerLocalNetwork() { registerCustomArbitrumNetwork(defaultL2Network) - let isLocalCustomNativeToken = false - try { - const data = await fetchErc20Data({ - address: defaultL3CustomGasTokenNetwork.nativeToken!, - provider: new StaticJsonRpcProvider(localL2NetworkRpcUrl) - }) - if (data.symbol === 'TN') { - isLocalCustomNativeToken = true + if (typeof isLocalCustomNativeToken === 'undefined') { + try { + const data = await fetchErc20Data({ + address: defaultL3CustomGasTokenNetwork.nativeToken!, + provider: new StaticJsonRpcProvider(localL2NetworkRpcUrl) + }) + if (data.symbol === 'TN') { + isLocalCustomNativeToken = true + } + } catch (e) { + // not the native token + isLocalCustomNativeToken = false } - } catch (e) { - // not the native token - isLocalCustomNativeToken = false } registerCustomArbitrumNetwork( diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index f01d2095cb..8761b31200 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -69,12 +69,12 @@ export default defineConfig({ e2e: { async setupNodeEvents(on, config) { logsPrinter(on) - await registerLocalNetwork() + await registerLocalNetwork(process.env.ORBIT_CUSTOM_GAS_TOKEN === 'true') try { const data = await fetchErc20Data({ address: defaultL3CustomGasTokenNetwork.nativeToken!, - provider: new StaticJsonRpcProvider(ethRpcUrl) + provider: new StaticJsonRpcProvider(arbRpcUrl) }) console.log({ data }) } catch (err) { From 5dba15f8a157d36b104934ecba24216c796c1ce5 Mon Sep 17 00:00:00 2001 From: Bartek Date: Wed, 9 Oct 2024 10:28:01 +0200 Subject: [PATCH 47/99] fix --- packages/arb-token-bridge-ui/synpress.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 8761b31200..4f79eac352 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -69,7 +69,7 @@ export default defineConfig({ e2e: { async setupNodeEvents(on, config) { logsPrinter(on) - await registerLocalNetwork(process.env.ORBIT_CUSTOM_GAS_TOKEN === 'true') + await registerLocalNetwork(process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true') try { const data = await fetchErc20Data({ From 6a2962f2b1cec3b4e95ff8d0a79ffa53802764fe Mon Sep 17 00:00:00 2001 From: Bartek Date: Wed, 9 Oct 2024 10:28:33 +0200 Subject: [PATCH 48/99] formatting --- packages/arb-token-bridge-ui/synpress.config.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 4f79eac352..0bb0bf7bb0 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -69,7 +69,9 @@ export default defineConfig({ e2e: { async setupNodeEvents(on, config) { logsPrinter(on) - await registerLocalNetwork(process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true') + await registerLocalNetwork( + process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' + ) try { const data = await fetchErc20Data({ From ae8ee3f6b6ab7c4fda4cc6486fb950496aa27c02 Mon Sep 17 00:00:00 2001 From: Bartek Date: Wed, 9 Oct 2024 11:37:29 +0200 Subject: [PATCH 49/99] fixes --- .../TransferPanelMain/TokenBalance.tsx | 4 +- .../arb-token-bridge-ui/src/pages/_app.tsx | 8 --- .../arb-token-bridge-ui/src/pages/index.tsx | 54 +++++++++++++------ .../arb-token-bridge-ui/synpress.config.ts | 3 ++ .../tests/e2e/specs/approveToken.cy.ts | 5 +- .../tests/e2e/specs/batchDeposit.cy.ts | 11 ++-- .../tests/e2e/specs/depositETH.cy.ts | 5 +- .../tests/e2e/specs/login.cy.ts | 20 +++---- 8 files changed, 64 insertions(+), 46 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMain/TokenBalance.tsx b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMain/TokenBalance.tsx index 1e56d31e81..0cbcfd4e15 100644 --- a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMain/TokenBalance.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMain/TokenBalance.tsx @@ -43,9 +43,9 @@ export function TokenBalance({ {prefix} {formatAmount(balance, { - decimals: forToken.decimals + decimals: forToken.decimals, })} - {' '} + {' ss'} import('../components/App/App'), { - ssr: false, - loading: () => ( - <> -
-
- -
- - ) -}) +const App = dynamic( + () => { + return new Promise<{ default: ComponentType<{}> }>(async resolve => { + if ( + process.env.NODE_ENV !== 'production' || + process.env.NEXT_PUBLIC_IS_E2E_TEST + ) { + await registerLocalNetwork() + } + + const AppComponent = await import('../components/App/App') + resolve(AppComponent) + }) + }, + { + ssr: false, + loading: () => ( + <> +
+
+ +
+ + ) + } +) function getDestinationWithSanitizedQueryParams( sanitized: { @@ -89,9 +105,11 @@ function addOrbitChainsToArbitrumSDK() { ) } -export function getServerSideProps({ +export async function getServerSideProps({ query -}: GetServerSidePropsContext): GetServerSidePropsResult> { +}: GetServerSidePropsContext): Promise< + GetServerSidePropsResult> +> { const sourceChainId = decodeChainQueryParam(query.sourceChain) const destinationChainId = decodeChainQueryParam(query.destinationChain) const experiments = decodeString(query.experiments) @@ -103,6 +121,12 @@ export function getServerSideProps({ } } + if ( + process.env.NODE_ENV !== 'production' || + process.env.NEXT_PUBLIC_IS_E2E_TEST + ) { + await registerLocalNetwork() + } // it's necessary to call this before sanitization to make sure all chains are registered addOrbitChainsToArbitrumSDK() diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 0bb0bf7bb0..5d6c884002 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -87,6 +87,9 @@ export default defineConfig({ const ethBridger = await EthBridger.fromProvider(childProvider) const isCustomFeeToken = isNonZeroAddress(ethBridger.nativeToken) + console.log({ isCustomFeeToken }) + throw 'e' + if (!ethRpcUrl && !isOrbitTest) { throw new Error('NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL variable missing.') } diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts index 8713c5bc13..e338075cf4 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts @@ -11,6 +11,7 @@ const ERC20TokenAddressL1 = Cypress.env('ERC20_TOKEN_ADDRESS_PARENT_CHAIN') describe('Approve token for deposit', () => { // log in to metamask + const zeroToLessThanOneEth = getZeroToLessThanOneNativeToken('ETH') const zeroToLessThanOneNativeToken = getZeroToLessThanOneNativeToken( Cypress.env('NATIVE_TOKEN_SYMBOL') ) @@ -29,8 +30,8 @@ describe('Approve token for deposit', () => { cy.findByText('MAX').click() - cy.findGasFeeSummary(zeroToLessThanOneNativeToken) - cy.findGasFeeForChain(getL1NetworkName(), zeroToLessThanOneNativeToken) + cy.findGasFeeSummary(zeroToLessThanOneEth) + cy.findGasFeeForChain(getL1NetworkName(), zeroToLessThanOneEth) cy.findGasFeeForChain(getL2NetworkName(), zeroToLessThanOneNativeToken) cy.waitUntil(() => cy.findMoveFundsButton().should('not.be.disabled'), { diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/batchDeposit.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/batchDeposit.cy.ts index 5f5a17b18c..a3d4a52b5a 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/batchDeposit.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/batchDeposit.cy.ts @@ -17,6 +17,7 @@ describe('Batch Deposit', () => { childErc20Balance: string const nativeTokenSymbol = Cypress.env('NATIVE_TOKEN_SYMBOL') + const zeroToLessThanOneEth = getZeroToLessThanOneNativeToken('ETH') const zeroToLessThanOneNativeToken = getZeroToLessThanOneNativeToken(nativeTokenSymbol) @@ -117,14 +118,14 @@ describe('Batch Deposit', () => { context('should show gas estimations and summary', () => { cy.typeAmount(ERC20AmountToSend) cy.typeAmount2(nativeCurrencyAmountToSend) - cy.findGasFeeSummary(zeroToLessThanOneNativeToken) - cy.findGasFeeForChain(getL1NetworkName(), zeroToLessThanOneNativeToken) + cy.findGasFeeSummary(zeroToLessThanOneEth) + cy.findGasFeeForChain(getL1NetworkName(), zeroToLessThanOneEth) cy.findGasFeeForChain(getL2NetworkName(), zeroToLessThanOneNativeToken) }) const txData = { symbol: ERC20TokenSymbol, - symbol2: 'ETH', + symbol2: nativeTokenSymbol, amount: ERC20AmountToSend, amount2: nativeCurrencyAmountToSend } @@ -223,8 +224,8 @@ describe('Batch Deposit', () => { context('should show gas estimations and summary', () => { cy.typeAmount(ERC20AmountToSend) cy.typeAmount2(nativeCurrencyAmountToSend) - cy.findGasFeeSummary(zeroToLessThanOneNativeToken) - cy.findGasFeeForChain(getL1NetworkName(), zeroToLessThanOneNativeToken) + cy.findGasFeeSummary(zeroToLessThanOneEth) + cy.findGasFeeForChain(getL1NetworkName(), zeroToLessThanOneEth) cy.findGasFeeForChain(getL2NetworkName(), zeroToLessThanOneNativeToken) }) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/depositETH.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/depositETH.cy.ts index b791dd4aeb..eb4886ac9a 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/depositETH.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/depositETH.cy.ts @@ -11,6 +11,7 @@ import { describe('Deposit native token', () => { const ETHAmountToDeposit = 0.0001 const nativeTokenSymbol = Cypress.env('NATIVE_TOKEN_SYMBOL') + const zeroToLessThanOneEth = getZeroToLessThanOneNativeToken('ETH') const zeroToLessThanOneNativeToken = getZeroToLessThanOneNativeToken(nativeTokenSymbol) @@ -27,8 +28,8 @@ describe('Deposit native token', () => { it('should show gas estimations and bridge successfully', () => { cy.login({ networkType: 'parentChain' }) cy.typeAmount(ETHAmountToDeposit) - cy.findGasFeeSummary(zeroToLessThanOneNativeToken) - cy.findGasFeeForChain(getL1NetworkName(), zeroToLessThanOneNativeToken) + cy.findGasFeeSummary(zeroToLessThanOneEth) + cy.findGasFeeForChain(getL1NetworkName(), zeroToLessThanOneEth) cy.findGasFeeForChain(getL2NetworkName(), zeroToLessThanOneNativeToken) cy.findMoveFundsButton().click() cy.confirmMetamaskTransaction() diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts index 475bf26bb8..46537c37e0 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts @@ -13,15 +13,14 @@ describe('Login Account', () => { let l1ETHbal let l2ETHbal + const nativeTokenSymbol = Cypress.env('NATIVE_TOKEN_SYMBOL') + before(() => { getInitialETHBalance(Cypress.env('ETH_RPC_URL')).then( val => (l1ETHbal = formatAmount(val)) ) getInitialETHBalance(Cypress.env('ARB_RPC_URL')).then( - val => - (l2ETHbal = formatAmount(val, { - symbol: Cypress.env('NATIVE_TOKEN_SYMBOL') - })) + val => (l2ETHbal = formatAmount(val)) ) }) @@ -36,16 +35,13 @@ describe('Login Account', () => { it('should connect wallet using MetaMask and display L1 and L2 balances', () => { cy.login({ networkType: 'parentChain' }) - // Balance: is in a different element so we check for siblings - cy.findByText(l1ETHbal) + cy.findByLabelText(`${nativeTokenSymbol} balance amount on parentChain`) .should('be.visible') - .siblings() - .contains('Balance: ') - // Balance: is in a different element so we check for siblings - cy.findByText(l2ETHbal) + .contains(l1ETHbal) + cy.findByLabelText(`${nativeTokenSymbol} balance amount on childChain`) .should('be.visible') - .siblings() - .contains('Balance: ') + .contains(l2ETHbal) + cy.findSourceChainButton(getL1NetworkName()) cy.findDestinationChainButton(getL2NetworkName()) }) From 57b706334337f140e1afb6c51dace69fa9bb8811 Mon Sep 17 00:00:00 2001 From: Bartek Date: Wed, 9 Oct 2024 12:03:51 +0200 Subject: [PATCH 50/99] fix --- packages/arb-token-bridge-ui/src/pages/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/src/pages/index.tsx b/packages/arb-token-bridge-ui/src/pages/index.tsx index a7d047db10..325bc493f4 100644 --- a/packages/arb-token-bridge-ui/src/pages/index.tsx +++ b/packages/arb-token-bridge-ui/src/pages/index.tsx @@ -20,7 +20,7 @@ import { sanitizeExperimentalFeaturesQueryParam } from '../util' const App = dynamic( () => { - return new Promise<{ default: ComponentType<{}> }>(async resolve => { + return new Promise<{ default: ComponentType }>(async resolve => { if ( process.env.NODE_ENV !== 'production' || process.env.NEXT_PUBLIC_IS_E2E_TEST From 7e575cea57ea519310b156422bc13b648c30573c Mon Sep 17 00:00:00 2001 From: Bartek Date: Wed, 9 Oct 2024 12:12:27 +0200 Subject: [PATCH 51/99] fix --- .../TransferPanel/TransferPanelMain/TokenBalance.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMain/TokenBalance.tsx b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMain/TokenBalance.tsx index 0cbcfd4e15..1e56d31e81 100644 --- a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMain/TokenBalance.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMain/TokenBalance.tsx @@ -43,9 +43,9 @@ export function TokenBalance({ {prefix} {formatAmount(balance, { - decimals: forToken.decimals, + decimals: forToken.decimals })} - {' ss'} + {' '} Date: Wed, 9 Oct 2024 12:28:13 +0200 Subject: [PATCH 52/99] whoops --- packages/arb-token-bridge-ui/synpress.config.ts | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 5d6c884002..91a7f17a06 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -73,23 +73,10 @@ export default defineConfig({ process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' ) - try { - const data = await fetchErc20Data({ - address: defaultL3CustomGasTokenNetwork.nativeToken!, - provider: new StaticJsonRpcProvider(arbRpcUrl) - }) - console.log({ data }) - } catch (err) { - console.log({ err }) - } - const erc20Bridger = await Erc20Bridger.fromProvider(childProvider) const ethBridger = await EthBridger.fromProvider(childProvider) const isCustomFeeToken = isNonZeroAddress(ethBridger.nativeToken) - console.log({ isCustomFeeToken }) - throw 'e' - if (!ethRpcUrl && !isOrbitTest) { throw new Error('NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL variable missing.') } From f5d180fc910ae930daca7bc3886c143d2dd76c76 Mon Sep 17 00:00:00 2001 From: Bartek Date: Wed, 9 Oct 2024 13:37:12 +0200 Subject: [PATCH 53/99] fixes --- .../arb-token-bridge-ui/src/util/networks.ts | 2 +- .../arb-token-bridge-ui/synpress.config.ts | 47 ++++--------------- .../tests/e2e/specs/depositERC20.cy.ts | 8 ++-- .../tests/e2e/specs/importToken.cy.ts | 4 +- .../tests/e2e/specs/login.cy.ts | 18 +++++-- 5 files changed, 31 insertions(+), 48 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts index 7e1f73f531..3291c29b7d 100644 --- a/packages/arb-token-bridge-ui/src/util/networks.ts +++ b/packages/arb-token-bridge-ui/src/util/networks.ts @@ -369,7 +369,7 @@ export const defaultL3CustomGasTokenNetwork: ArbitrumNetwork = { parentGatewayRouter: '0x0C085152C2799834fc1603533ff6916fa1FdA302', parentMultiCall: '0x20a3627Dcc53756E38aE3F92717DE9B23617b422', parentProxyAdmin: '0x1A61102c26ad3f64bA715B444C93388491fd8E68', - parentWeth: '0x0000000000000000000000000000000000000000', + parentWeth: '0xA1abD387192e3bb4e84D3109181F9f005aBaF5CA', parentWethGateway: '0x59156b0596689D965Ba707E160e5370AF22461a0', childCustomGateway: '0xD4816AeF8f85A3C1E01Cd071a81daD4fa941625f', childErc20Gateway: '0xaa7d51aFFEeB32d99b1CB2fd6d81D7adA4a896e8', diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 91a7f17a06..b641704ff6 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -14,7 +14,7 @@ import { TestERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestERC import { TestWETH9__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestWETH9__factory' import { Erc20Bridger, EthBridger } from '@arbitrum/sdk' import logsPrinter from 'cypress-terminal-report/src/installLogsPrinter' -import { fetchErc20Data, getL2ERC20Address } from './src/util/TokenUtils' +import { getL2ERC20Address } from './src/util/TokenUtils' import specFiles from './tests/e2e/specfiles.json' import { contractAbi, contractByteCode } from './testErc20Token' import { @@ -141,15 +141,6 @@ export default defineConfig({ }) await approveErc20(l1ERC20Token) - if ( - !isNonZeroAddress(l1WethAddress) || - !isNonZeroAddress(l2WethAddress) - ) { - const wethAddresses = await deployWeth(parentProvider) - l1WethAddress = wethAddresses.l1WethAddress - l2WethAddress = wethAddresses.l2WethAddress - } - if (isCustomFeeToken) { await approveCustomFeeToken({ signer: userWallet.connect(parentProvider), @@ -208,6 +199,7 @@ export default defineConfig({ config.env.LOCAL_WALLET_PRIVATE_KEY = localWallet.privateKey config.env.ORBIT_TEST = isOrbitTest ? '1' : '0' config.env.NATIVE_TOKEN_SYMBOL = isCustomFeeToken ? 'TN' : 'ETH' + config.env.NATIVE_TOKEN_ADDRESS = ethBridger.nativeToken config.env.CUSTOM_DESTINATION_ADDRESS = await getCustomDestinationAddress() @@ -357,33 +349,6 @@ function isNonZeroAddress(address: string | undefined) { ) } -async function deployWeth(provider: StaticJsonRpcProvider) { - const wethFactory = new TestWETH9__factory(localWallet.connect(provider)) - const weth = await wethFactory.deploy('Wrapped Ether', 'WETH') - await weth.deployed() - - const bridger = await Erc20Bridger.fromProvider(childProvider) - const deployOnChildChain = await bridger.deposit({ - amount: BigNumber.from(0), - erc20ParentAddress: weth.address, - parentSigner: localWallet.connect(parentProvider), - childProvider - }) - - await deployOnChildChain.wait() - - const l2WethAddress = await getL2ERC20Address({ - erc20L1Address: weth.address, - l1Provider: parentProvider, - l2Provider: childProvider - }) - - return { - l1WethAddress: weth.address, - l2WethAddress - } -} - async function deployERC20ToChildChain(erc20L1Address: string) { const bridger = await Erc20Bridger.fromProvider(childProvider) const deploy = await bridger.deposit({ @@ -393,6 +358,14 @@ async function deployERC20ToChildChain(erc20L1Address: string) { childProvider }) await deploy.wait() + + if (erc20L1Address === l1WethAddress) { + l2WethAddress = await getL2ERC20Address({ + erc20L1Address: l1WethAddress, + l1Provider: parentProvider, + l2Provider: childProvider + }) + } } function getWethContract( diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/depositERC20.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/depositERC20.cy.ts index b2632efeb0..affcc0ca2f 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/depositERC20.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/depositERC20.cy.ts @@ -34,6 +34,7 @@ describe('Deposit Token', () => { const isOrbitTest = Cypress.env('ORBIT_TEST') == '1' const depositTime = isOrbitTest ? 'Less than a minute' : '9 minutes' const nativeTokenSymbol = Cypress.env('NATIVE_TOKEN_SYMBOL') + const zeroToLessThanOneEth = getZeroToLessThanOneNativeToken('ETH') const zeroToLessThanOneNativeToken = getZeroToLessThanOneNativeToken(nativeTokenSymbol) @@ -79,11 +80,8 @@ describe('Deposit Token', () => { context('should show gas estimations', () => { cy.typeAmount(ERC20AmountToSend) - cy.findGasFeeSummary(zeroToLessThanOneNativeToken) - cy.findGasFeeForChain( - getL1NetworkName(), - zeroToLessThanOneNativeToken - ) + cy.findGasFeeSummary(zeroToLessThanOneEth) + cy.findGasFeeForChain(getL1NetworkName(), zeroToLessThanOneEth) cy.findGasFeeForChain( getL2NetworkName(), zeroToLessThanOneNativeToken diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/importToken.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/importToken.cy.ts index 44aa1e15da..02629454dd 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/importToken.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/importToken.cy.ts @@ -77,7 +77,7 @@ describe('Import token', () => { networkName: 'mainnet' }) - cy.findSelectTokenButton(nativeTokenSymbol).click() + cy.findSelectTokenButton('ETH').click() // Check that token list is imported cy.findByRole('button', { name: 'Manage token lists' }) @@ -101,7 +101,7 @@ describe('Import token', () => { networkName: 'mainnet' }) - cy.findSelectTokenButton(nativeTokenSymbol).click() + cy.findSelectTokenButton('ETH').click() // Check that token list is imported cy.findByRole('button', { name: 'Manage token lists' }) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts index 46537c37e0..f5c685228a 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts @@ -4,8 +4,10 @@ import { formatAmount } from '../../../src/util/NumberUtils' import { + getInitialERC20Balance, getInitialETHBalance, getL1NetworkName, + getL2NetworkConfig, getL2NetworkName } from './../../support/common' @@ -14,11 +16,21 @@ describe('Login Account', () => { let l2ETHbal const nativeTokenSymbol = Cypress.env('NATIVE_TOKEN_SYMBOL') + const isCustomFeeToken = nativeTokenSymbol !== 'ETH' before(() => { - getInitialETHBalance(Cypress.env('ETH_RPC_URL')).then( - val => (l1ETHbal = formatAmount(val)) - ) + if (isCustomFeeToken) { + getInitialERC20Balance({ + tokenAddress: Cypress.env('NATIVE_TOKEN_ADDRESS'), + multiCallerAddress: getL2NetworkConfig().multiCall, + address: Cypress.env('ADDRESS'), + rpcURL: Cypress.env('ETH_RPC_URL') + }).then(val => (l1ETHbal = formatAmount(val))) + } else { + getInitialETHBalance(Cypress.env('ETH_RPC_URL')).then( + val => (l1ETHbal = formatAmount(val)) + ) + } getInitialETHBalance(Cypress.env('ARB_RPC_URL')).then( val => (l2ETHbal = formatAmount(val)) ) From 23b4c73de2ae1f98f20c4ba3fd8e21882ca3922d Mon Sep 17 00:00:00 2001 From: Bartek Date: Wed, 9 Oct 2024 14:25:22 +0200 Subject: [PATCH 54/99] fixes --- packages/arb-token-bridge-ui/src/util/networks.ts | 4 ++-- packages/arb-token-bridge-ui/synpress.config.ts | 14 +++++++------- .../tests/e2e/specs/depositERC20.cy.ts | 7 ++----- .../tests/e2e/specs/login.cy.ts | 4 ++-- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts index 3291c29b7d..08f159a5ce 100644 --- a/packages/arb-token-bridge-ui/src/util/networks.ts +++ b/packages/arb-token-bridge-ui/src/util/networks.ts @@ -376,8 +376,8 @@ export const defaultL3CustomGasTokenNetwork: ArbitrumNetwork = { childGatewayRouter: '0x8B6BC759226f8Fe687c8aD8Cc0DbF85E095e9297', childMultiCall: '0x052B15c8Ff0544287AE689C4F2FC53A3905d7Db3', childProxyAdmin: '0x36C56eC2CF3a3f53db9F01d0A5Ae84b36fb0A1e2', - childWeth: '0x0000000000000000000000000000000000000000', - childWethGateway: '0x0000000000000000000000000000000000000000' + childWeth: '0x582a8dBc77f665dF2c49Ce0a138978e9267dd968', + childWethGateway: '0xA6AB233B3c7bfd0399834897b5073974A3D467e2' } } diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index b641704ff6..e7551c1e0e 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -359,13 +359,13 @@ async function deployERC20ToChildChain(erc20L1Address: string) { }) await deploy.wait() - if (erc20L1Address === l1WethAddress) { - l2WethAddress = await getL2ERC20Address({ - erc20L1Address: l1WethAddress, - l1Provider: parentProvider, - l2Provider: childProvider - }) - } + // if (erc20L1Address === l1WethAddress) { + // l2WethAddress = await getL2ERC20Address({ + // erc20L1Address: l1WethAddress, + // l1Provider: parentProvider, + // l2Provider: childProvider + // }) + // } } function getWethContract( diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/depositERC20.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/depositERC20.cy.ts index affcc0ca2f..8b214f4c55 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/depositERC20.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/depositERC20.cy.ts @@ -118,11 +118,8 @@ describe('Deposit Token', () => { context('should show summary', () => { cy.typeAmount(ERC20AmountToSend) - cy.findGasFeeSummary(zeroToLessThanOneNativeToken) - cy.findGasFeeForChain( - getL1NetworkName(), - zeroToLessThanOneNativeToken - ) + cy.findGasFeeSummary(zeroToLessThanOneEth) + cy.findGasFeeForChain(getL1NetworkName(), zeroToLessThanOneEth) cy.findGasFeeForChain( getL2NetworkName(), zeroToLessThanOneNativeToken diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts index f5c685228a..5c627e2344 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts @@ -6,8 +6,8 @@ import { formatAmount } from '../../../src/util/NumberUtils' import { getInitialERC20Balance, getInitialETHBalance, + getL1NetworkConfig, getL1NetworkName, - getL2NetworkConfig, getL2NetworkName } from './../../support/common' @@ -22,7 +22,7 @@ describe('Login Account', () => { if (isCustomFeeToken) { getInitialERC20Balance({ tokenAddress: Cypress.env('NATIVE_TOKEN_ADDRESS'), - multiCallerAddress: getL2NetworkConfig().multiCall, + multiCallerAddress: getL1NetworkConfig().multiCall, address: Cypress.env('ADDRESS'), rpcURL: Cypress.env('ETH_RPC_URL') }).then(val => (l1ETHbal = formatAmount(val))) From 07a25fc6a062261c1e3d3622b2f10b523a10cbda Mon Sep 17 00:00:00 2001 From: Bartek Date: Wed, 9 Oct 2024 15:37:47 +0200 Subject: [PATCH 55/99] fixes --- .../arb-token-bridge-ui/src/util/networks.ts | 4 +-- .../arb-token-bridge-ui/synpress.config.ts | 30 +++++++++++-------- .../tests/e2e/specs/importToken.cy.ts | 2 ++ 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts index 08f159a5ce..3291c29b7d 100644 --- a/packages/arb-token-bridge-ui/src/util/networks.ts +++ b/packages/arb-token-bridge-ui/src/util/networks.ts @@ -376,8 +376,8 @@ export const defaultL3CustomGasTokenNetwork: ArbitrumNetwork = { childGatewayRouter: '0x8B6BC759226f8Fe687c8aD8Cc0DbF85E095e9297', childMultiCall: '0x052B15c8Ff0544287AE689C4F2FC53A3905d7Db3', childProxyAdmin: '0x36C56eC2CF3a3f53db9F01d0A5Ae84b36fb0A1e2', - childWeth: '0x582a8dBc77f665dF2c49Ce0a138978e9267dd968', - childWethGateway: '0xA6AB233B3c7bfd0399834897b5073974A3D467e2' + childWeth: '0x0000000000000000000000000000000000000000', + childWethGateway: '0x0000000000000000000000000000000000000000' } } diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index e7551c1e0e..9fc5e5f77c 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -137,7 +137,8 @@ export default defineConfig({ await fundErc20ToChildChain({ parentSigner: localWallet.connect(parentProvider), parentErc20Address: l1ERC20Token.address, - amount: parseUnits('5', ERC20TokenDecimals) + amount: parseUnits('5', ERC20TokenDecimals), + isCustomFeeToken }) await approveErc20(l1ERC20Token) @@ -168,7 +169,8 @@ export default defineConfig({ await fundErc20ToChildChain({ parentSigner: userWallet.connect(parentProvider), parentErc20Address: l1WethAddress, - amount: utils.parseEther('0.1') + amount: utils.parseEther('0.1'), + isCustomFeeToken }) // Generate activity on chains so that assertions get posted and claims can be made @@ -359,13 +361,13 @@ async function deployERC20ToChildChain(erc20L1Address: string) { }) await deploy.wait() - // if (erc20L1Address === l1WethAddress) { - // l2WethAddress = await getL2ERC20Address({ - // erc20L1Address: l1WethAddress, - // l1Provider: parentProvider, - // l2Provider: childProvider - // }) - // } + if (erc20L1Address === l1WethAddress) { + l2WethAddress = await getL2ERC20Address({ + erc20L1Address: l1WethAddress, + l1Provider: parentProvider, + l2Provider: childProvider + }) + } } function getWethContract( @@ -419,14 +421,18 @@ async function fundErc20ToParentChain(l1ERC20Token: Contract) { async function fundErc20ToChildChain({ parentErc20Address, parentSigner, - amount + amount, + isCustomFeeToken }: { parentErc20Address: string parentSigner: Wallet amount: BigNumber + isCustomFeeToken: boolean }) { - // first deploy the ERC20 to L2 (if not, it might throw a gas error later) - await deployERC20ToChildChain(parentErc20Address) + if (parentErc20Address !== l1WethAddress || isCustomFeeToken) { + // first deploy the ERC20 to L2 (if not, it might throw a gas error later) + await deployERC20ToChildChain(parentErc20Address) + } const erc20Bridger = await Erc20Bridger.fromProvider(childProvider) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/importToken.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/importToken.cy.ts index 02629454dd..86c712c350 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/importToken.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/importToken.cy.ts @@ -247,6 +247,8 @@ describe('Import token', () => { visitAfterSomeDelay('/', { qs: { + sourceChain: 'arbitrum-localhost', + destinationChain: 'l3-localhost', token: invalidTokenAddress } }) From d72ee4d1b25ba487992d1697098490e30b28cddf Mon Sep 17 00:00:00 2001 From: Bartek Date: Wed, 9 Oct 2024 17:26:08 +0200 Subject: [PATCH 56/99] fix --- .../tests/e2e/specs/withdrawERC20.cy.ts | 2 +- .../tests/e2e/specs/withdrawETH.cy.ts | 2 +- .../tests/support/common.ts | 22 +++++++++++-------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawERC20.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawERC20.cy.ts index 3ee878e90b..2145a493dd 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawERC20.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawERC20.cy.ts @@ -148,7 +148,7 @@ describe('Withdraw ERC20 Token', () => { }) }) - it('should claim funds', { defaultCommandTimeout: 200_000 }, () => { + it('should claim funds', { defaultCommandTimeout: 500_000 }, () => { // increase the timeout for this test as claim button can take ~(20 blocks *10 blocks/sec) to activate cy.login({ networkType: 'parentChain' }) // login to L1 to claim the funds (otherwise would need to change network after clicking on claim) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawETH.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawETH.cy.ts index da9ad51646..449418154f 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawETH.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawETH.cy.ts @@ -102,7 +102,7 @@ describe('Withdraw native token', () => { }) }) - it('should claim funds', { defaultCommandTimeout: 200_000 }, () => { + it('should claim funds', { defaultCommandTimeout: 500_000 }, () => { // increase the timeout for this test as claim button can take ~(20 blocks *10 blocks/sec) to activate cy.login({ networkType: 'parentChain' }) // login to L1 to claim the funds (otherwise would need to change network after clicking on claim) diff --git a/packages/arb-token-bridge-ui/tests/support/common.ts b/packages/arb-token-bridge-ui/tests/support/common.ts index c8ea56473e..e871f2cbca 100644 --- a/packages/arb-token-bridge-ui/tests/support/common.ts +++ b/packages/arb-token-bridge-ui/tests/support/common.ts @@ -102,7 +102,7 @@ export const getL2TestnetNetworkConfig = (): NetworkConfig => { export const ERC20TokenName = 'Test Arbitrum Token' export const ERC20TokenSymbol = 'TESTARB' export const ERC20TokenDecimals = 18 -export const invalidTokenAddress = '0x0000000000000000000000000000000000000000' +export const invalidTokenAddress = utils.computeAddress(utils.randomBytes(32)) export const moreThanZeroBalance = /0(\.\d+)/ @@ -206,14 +206,18 @@ export async function generateActivityOnChains({ }) { const keepMining = async (miner: Signer) => { while (true) { - await ( - await miner.sendTransaction({ - to: await miner.getAddress(), - value: 0, - // random data to make the tx heavy, so that batches are posted sooner (since they're posted according to calldata size) - data: '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000010c3c627574746f6e20636c6173733d226e61766261722d746f67676c65722220747970653d22627574746f6e2220646174612d746f67676c653d22636f6c6c617073652220646174612d7461726765743d22236e6176626172537570706f72746564436f6e74656e742220617269612d636f6e74726f6c733d226e6176626172537570706f72746564436f6e74656e742220617269612d657870616e6465643d2266616c73652220617269612d6c6162656c3d223c253d20676574746578742822546f67676c65206e617669676174696f6e222920253e223e203c7370616e20636c6173733d226e61766261722d746f67676c65722d69636f6e223e3c2f7370616e3e203c2f627574746f6e3e0000000000000000000000000000000000000000' - }) - ).wait() + try { + await ( + await miner.sendTransaction({ + to: await miner.getAddress(), + value: 0, + // random data to make the tx heavy, so that batches are posted sooner (since they're posted according to calldata size) + data: '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000010c3c627574746f6e20636c6173733d226e61766261722d746f67676c65722220747970653d22627574746f6e2220646174612d746f67676c653d22636f6c6c617073652220646174612d7461726765743d22236e6176626172537570706f72746564436f6e74656e742220617269612d636f6e74726f6c733d226e6176626172537570706f72746564436f6e74656e742220617269612d657870616e6465643d2266616c73652220617269612d6c6162656c3d223c253d20676574746578742822546f67676c65206e617669676174696f6e222920253e223e203c7370616e20636c6173733d226e61766261722d746f67676c65722d69636f6e223e3c2f7370616e3e203c2f627574746f6e3e0000000000000000000000000000000000000000' + }) + ).wait() + } catch (ere) { + console.log({ ere }) + } await wait(100) } From 4cdd22811778d970af25bfadc1a1109b95e4a72b Mon Sep 17 00:00:00 2001 From: Bartek Date: Wed, 9 Oct 2024 18:45:20 +0200 Subject: [PATCH 57/99] bump nitro --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 8f98f389e4..19416b91e4 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -91,7 +91,7 @@ jobs: if: inputs.test_type != 'cctp' uses: OffchainLabs/actions/run-nitro-test-node@a20a76172ce524832ac897bef2fa10a62ed81c29 with: - nitro-testnode-ref: badbcbea9b43d46e115da4d7c9f2f57c31af8431 + nitro-testnode-ref: fa19e2210403ad24519ea46c2d337f54a9f47593 l3-node: ${{ matrix.test.type != 'regular' }} no-l3-token-bridge: ${{ matrix.test.type == 'regular' }} args: ${{ matrix.test.type == 'orbit-custom' && '--l3-fee-token' || '' }} From ef465738874d1554ef3d4d42523867b2aa30c1ce Mon Sep 17 00:00:00 2001 From: Bartek Date: Wed, 9 Oct 2024 19:46:40 +0200 Subject: [PATCH 58/99] update rollup address, revert nitro ref --- .github/workflows/e2e-tests.yml | 2 +- packages/arb-token-bridge-ui/src/util/networks.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 19416b91e4..8f98f389e4 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -91,7 +91,7 @@ jobs: if: inputs.test_type != 'cctp' uses: OffchainLabs/actions/run-nitro-test-node@a20a76172ce524832ac897bef2fa10a62ed81c29 with: - nitro-testnode-ref: fa19e2210403ad24519ea46c2d337f54a9f47593 + nitro-testnode-ref: badbcbea9b43d46e115da4d7c9f2f57c31af8431 l3-node: ${{ matrix.test.type != 'regular' }} no-l3-token-bridge: ${{ matrix.test.type == 'regular' }} args: ${{ matrix.test.type == 'orbit-custom' && '--l3-fee-token' || '' }} diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts index 3291c29b7d..18bd4eda7b 100644 --- a/packages/arb-token-bridge-ui/src/util/networks.ts +++ b/packages/arb-token-bridge-ui/src/util/networks.ts @@ -355,7 +355,9 @@ export const defaultL3CustomGasTokenNetwork: ArbitrumNetwork = { bridge: '0xA584795e24628D9c067A6480b033C9E96281fcA3', inbox: '0xDcA690902d3154886Ec259308258D10EA5450996', outbox: '0xda243bD61B011024FC923164db75Dde198AC6175', - rollup: '0x7a23F33C1C384eFc11b8Cf207420c464ba2959CC', + rollup: process.env.NEXT_PUBLIC_IS_E2E_TEST + ? '0x7d98BA231d29D5C202981542C0291718A7358c63' + : '0x7a23F33C1C384eFc11b8Cf207420c464ba2959CC', sequencerInbox: '0x16c54EE2015CD824415c2077F4103f444E00A8cb' }, nativeToken: '0xE069078bA9ACCE4eeAE609d8754515Cf13dd6706', From c67dcd58bec01992cb33239075fe28749d0b7503 Mon Sep 17 00:00:00 2001 From: Bartek Date: Wed, 9 Oct 2024 21:35:11 +0200 Subject: [PATCH 59/99] fix --- packages/arb-token-bridge-ui/src/util/networks.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts index 18bd4eda7b..d234bee411 100644 --- a/packages/arb-token-bridge-ui/src/util/networks.ts +++ b/packages/arb-token-bridge-ui/src/util/networks.ts @@ -356,7 +356,7 @@ export const defaultL3CustomGasTokenNetwork: ArbitrumNetwork = { inbox: '0xDcA690902d3154886Ec259308258D10EA5450996', outbox: '0xda243bD61B011024FC923164db75Dde198AC6175', rollup: process.env.NEXT_PUBLIC_IS_E2E_TEST - ? '0x7d98BA231d29D5C202981542C0291718A7358c63' + ? '0x17d70d77AAEe46ACDF8b87BB2f085f36f63eC638' : '0x7a23F33C1C384eFc11b8Cf207420c464ba2959CC', sequencerInbox: '0x16c54EE2015CD824415c2077F4103f444E00A8cb' }, From 89004d15b6f8808b63f5f3a014c7a9975d91f616 Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 10 Oct 2024 10:25:52 +0200 Subject: [PATCH 60/99] fix --- packages/arb-token-bridge-ui/tests/support/commands.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/arb-token-bridge-ui/tests/support/commands.ts b/packages/arb-token-bridge-ui/tests/support/commands.ts index 767668fb92..fd17e9ace8 100644 --- a/packages/arb-token-bridge-ui/tests/support/commands.ts +++ b/packages/arb-token-bridge-ui/tests/support/commands.ts @@ -140,8 +140,8 @@ export const searchAndSelectToken = ({ tokenName: string tokenAddress: string }) => { - // Click on the ETH dropdown (Select token button) - cy.findSelectTokenButton('ETH').click() + // Click on the native token dropdown (Select token button) + cy.findSelectTokenButton(Cypress.env('NATIVE_TOKEN_SYMBOL')).click() // open the Select Token popup cy.findByPlaceholderText(/Search by token name/i) From b9f89f7fc577ac3fc0e623475f1e34b581f38693 Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 10 Oct 2024 11:14:18 +0200 Subject: [PATCH 61/99] clean up --- packages/arb-token-bridge-ui/synpress.config.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 9fc5e5f77c..640291e524 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -157,7 +157,7 @@ export default defineConfig({ } // Wrap ETH to test WETH transactions and approve it's usage - await fundWeth('parentChain') + await fundWethOnParentChain() await approveWeth() if (isCustomFeeToken) { await approveCustomFeeToken({ @@ -361,6 +361,7 @@ async function deployERC20ToChildChain(erc20L1Address: string) { }) await deploy.wait() + // store deployed weth address if (erc20L1Address === l1WethAddress) { l2WethAddress = await getL2ERC20Address({ erc20L1Address: l1WethAddress, @@ -377,14 +378,10 @@ function getWethContract( return TestWETH9__factory.connect(tokenAddress, userWallet.connect(provider)) } -async function fundWeth(networkType: NetworkType) { - console.log(`Funding WETH: ${networkType}...`) - const amount = networkType === 'parentChain' ? '0.3' : '0.1' - const address = networkType === 'parentChain' ? l1WethAddress : l2WethAddress - const provider = - networkType === 'parentChain' ? parentProvider : childProvider - const tx = await getWethContract(provider, address).deposit({ - value: utils.parseEther(amount) +async function fundWethOnParentChain() { + console.log(`Funding WETH...`) + const tx = await getWethContract(parentProvider, l1WethAddress).deposit({ + value: utils.parseEther('0.3') }) await tx.wait() } @@ -429,6 +426,8 @@ async function fundErc20ToChildChain({ amount: BigNumber isCustomFeeToken: boolean }) { + // deploy any token that's not WETH + // only deploy with for custom fee token chains because it's not deployed there if (parentErc20Address !== l1WethAddress || isCustomFeeToken) { // first deploy the ERC20 to L2 (if not, it might throw a gas error later) await deployERC20ToChildChain(parentErc20Address) From 3a8362966f379171343831133278d907eb24f363 Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 10 Oct 2024 11:16:12 +0200 Subject: [PATCH 62/99] typo --- packages/arb-token-bridge-ui/synpress.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 640291e524..a221bb6467 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -427,7 +427,7 @@ async function fundErc20ToChildChain({ isCustomFeeToken: boolean }) { // deploy any token that's not WETH - // only deploy with for custom fee token chains because it's not deployed there + // only deploy WETH for custom fee token chains because it's not deployed there if (parentErc20Address !== l1WethAddress || isCustomFeeToken) { // first deploy the ERC20 to L2 (if not, it might throw a gas error later) await deployERC20ToChildChain(parentErc20Address) From 01a7d8ee2ec0173cf464c1aa379738016619e8a6 Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 10 Oct 2024 11:18:55 +0200 Subject: [PATCH 63/99] revert default timeout --- .../arb-token-bridge-ui/tests/e2e/specs/withdrawERC20.cy.ts | 2 +- packages/arb-token-bridge-ui/tests/e2e/specs/withdrawETH.cy.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawERC20.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawERC20.cy.ts index 2145a493dd..3ee878e90b 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawERC20.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawERC20.cy.ts @@ -148,7 +148,7 @@ describe('Withdraw ERC20 Token', () => { }) }) - it('should claim funds', { defaultCommandTimeout: 500_000 }, () => { + it('should claim funds', { defaultCommandTimeout: 200_000 }, () => { // increase the timeout for this test as claim button can take ~(20 blocks *10 blocks/sec) to activate cy.login({ networkType: 'parentChain' }) // login to L1 to claim the funds (otherwise would need to change network after clicking on claim) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawETH.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawETH.cy.ts index 449418154f..da9ad51646 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawETH.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawETH.cy.ts @@ -102,7 +102,7 @@ describe('Withdraw native token', () => { }) }) - it('should claim funds', { defaultCommandTimeout: 500_000 }, () => { + it('should claim funds', { defaultCommandTimeout: 200_000 }, () => { // increase the timeout for this test as claim button can take ~(20 blocks *10 blocks/sec) to activate cy.login({ networkType: 'parentChain' }) // login to L1 to claim the funds (otherwise would need to change network after clicking on claim) From 3bb33086077115f1fa7b9a8792181f3b9d1dbab3 Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 10 Oct 2024 11:21:17 +0200 Subject: [PATCH 64/99] revert --- .../tests/support/common.ts | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/packages/arb-token-bridge-ui/tests/support/common.ts b/packages/arb-token-bridge-ui/tests/support/common.ts index e871f2cbca..8a4156016b 100644 --- a/packages/arb-token-bridge-ui/tests/support/common.ts +++ b/packages/arb-token-bridge-ui/tests/support/common.ts @@ -206,18 +206,14 @@ export async function generateActivityOnChains({ }) { const keepMining = async (miner: Signer) => { while (true) { - try { - await ( - await miner.sendTransaction({ - to: await miner.getAddress(), - value: 0, - // random data to make the tx heavy, so that batches are posted sooner (since they're posted according to calldata size) - data: '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000010c3c627574746f6e20636c6173733d226e61766261722d746f67676c65722220747970653d22627574746f6e2220646174612d746f67676c653d22636f6c6c617073652220646174612d7461726765743d22236e6176626172537570706f72746564436f6e74656e742220617269612d636f6e74726f6c733d226e6176626172537570706f72746564436f6e74656e742220617269612d657870616e6465643d2266616c73652220617269612d6c6162656c3d223c253d20676574746578742822546f67676c65206e617669676174696f6e222920253e223e203c7370616e20636c6173733d226e61766261722d746f67676c65722d69636f6e223e3c2f7370616e3e203c2f627574746f6e3e0000000000000000000000000000000000000000' - }) - ).wait() - } catch (ere) { - console.log({ ere }) - } + await ( + await miner.sendTransaction({ + to: await miner.getAddress(), + value: 0, + // random data to make the tx heavy, so that batches are posted sooner (since they're posted according to calldata size) + data: '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000010c3c627574746f6e20636c6173733d226e61766261722d746f67676c65722220747970653d22627574746f6e2220646174612d746f67676c653d22636f6c6c617073652220646174612d7461726765743d22236e6176626172537570706f72746564436f6e74656e742220617269612d636f6e74726f6c733d226e6176626172537570706f72746564436f6e74656e742220617269612d657870616e6465643d2266616c73652220617269612d6c6162656c3d223c253d20676574746578742822546f67676c65206e617669676174696f6e222920253e223e203c7370616e20636c6173733d226e61766261722d746f67676c65722d69636f6e223e3c2f7370616e3e203c2f627574746f6e3e0000000000000000000000000000000000000000' + }) + ).wait() await wait(100) } From 88e4e90901f5f792b8aa5ad182c4887459db86e0 Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 17 Oct 2024 13:30:38 +0200 Subject: [PATCH 65/99] non18 decimals e2e --- .github/workflows/e2e-tests.yml | 14 ++++---- .github/workflows/formatSpecfiles.js | 22 ++++++++++++- .../src/components/TransferPanel/TokenRow.tsx | 12 ++++++- .../TransferPanel/TransferPanel.tsx | 24 +++++++++++--- .../TransferPanelMain/SourceNetworkBox.tsx | 16 +++++++-- .../TransferPanelMain/TokenBalance.tsx | 27 +++++++++++++-- .../TransferPanelMain/useMaxAmount.ts | 8 +++-- .../TransferPanel/TransferPanelMainInput.tsx | 13 +++++++- .../TransferPanel/hooks/useAmountBigNumber.ts | 13 +++----- .../useNativeCurrencyDecimalsOnSourceChain.ts | 21 ++++++++++++ .../src/util/TokenUtils.ts | 33 ++++++++++++++++++- .../src/util/withdrawals/helpers.ts | 12 +++++-- .../arb-token-bridge-ui/synpress.config.ts | 4 +++ .../tests/e2e/specs/login.cy.ts | 3 +- 14 files changed, 188 insertions(+), 34 deletions(-) create mode 100644 packages/arb-token-bridge-ui/src/hooks/useNativeCurrencyDecimalsOnSourceChain.ts diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 8f98f389e4..7a0af855f5 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -28,7 +28,7 @@ jobs: run: echo "e2eFiles=$(node .github/workflows/formatSpecfiles.js ${{ inputs.test_type }} | jq . --compact-output)" >> $GITHUB_OUTPUT test-e2e: - name: "Test E2E - ${{ matrix.test.name }}${{ matrix.test.type == 'orbit-eth' && ' with L3' || matrix.test.type == 'orbit-custom' && ' with custom fee token' || ''}}" + name: "Test E2E - ${{ matrix.test.name }} ${{ matrix.test.typeName }}" needs: [load-e2e-files] runs-on: ubuntu-latest strategy: @@ -92,18 +92,18 @@ jobs: uses: OffchainLabs/actions/run-nitro-test-node@a20a76172ce524832ac897bef2fa10a62ed81c29 with: nitro-testnode-ref: badbcbea9b43d46e115da4d7c9f2f57c31af8431 - l3-node: ${{ matrix.test.type != 'regular' }} - no-l3-token-bridge: ${{ matrix.test.type == 'regular' }} - args: ${{ matrix.test.type == 'orbit-custom' && '--l3-fee-token' || '' }} + args: ${{ matrix.test.testnodeArgs }} - name: Run e2e tests via cypress-io/github-action uses: cypress-io/github-action@0da3c06ed8217b912deea9d8ee69630baed1737e # pin@v6.7.6 with: start: yarn start command: >- - ${{ + ${{ (matrix.test.type == 'orbit-eth') && 'yarn test:e2e:orbit --browser chrome' || - (matrix.test.type == 'orbit-custom' && 'yarn test:e2e:orbit:custom-gas-token --browser chrome') || + (matrix.test.type == 'orbit-custom-16dec' && 'yarn test:e2e:orbit:custom-gas-token --browser chrome') || + (matrix.test.type == 'orbit-custom-18dec' && 'yarn test:e2e:orbit:custom-gas-token --browser chrome') || + (matrix.test.type == 'orbit-custom-20dec' && 'yarn test:e2e:orbit:custom-gas-token --browser chrome') || 'yarn test:e2e --browser chrome' }} wait-on: http://127.0.0.1:3000 @@ -127,7 +127,7 @@ jobs: uses: actions/upload-artifact@v4 if: always() with: - name: e2e-artifacts-${{ github.sha }}-${{ matrix.test.name }}-${{ (matrix.test.type == 'cctp' && 'cctp') || (matrix.test.type == 'orbit-eth' && 'l3') || (matrix.test.type == 'orbit-custom' && 'custom-fee-token') || 'regular'}} + name: e2e-artifacts-${{ github.sha }}-${{ matrix.test.name }}-${{ matrix.test.type }} path: | ./packages/arb-token-bridge-ui/cypress/videos ./packages/arb-token-bridge-ui/cypress/screenshots diff --git a/.github/workflows/formatSpecfiles.js b/.github/workflows/formatSpecfiles.js index bb6b23e1ef..7494cdd251 100644 --- a/.github/workflows/formatSpecfiles.js +++ b/.github/workflows/formatSpecfiles.js @@ -11,14 +11,32 @@ switch (testType) { tests.push({ ...spec, type: "regular", + typeName: "", + testnodeArgs: "", }); tests.push({ ...spec, type: "orbit-eth", + typeName: "with L3 (ETH)", + testnodeArgs: "--l3node --l3-token-bridge", }); tests.push({ ...spec, - type: "orbit-custom", + type: "orbit-custom-16dec", + typeName: "with L3 (16 decimals custom)", + testnodeArgs: "--l3node --l3-token-bridge --l3-fee-token --l3-fee-token-decimals 16", + }); + tests.push({ + ...spec, + type: "orbit-custom-18dec", + typeName: "with L3 (18 decimals custom)", + testnodeArgs: "--l3node --l3-token-bridge --l3-fee-token", + }); + tests.push({ + ...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; @@ -27,6 +45,8 @@ switch (testType) { // Running CCTP tests in parallel cause nonce issues, we're running the two tests sequentially 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/TokenRow.tsx b/packages/arb-token-bridge-ui/src/components/TransferPanel/TokenRow.tsx index 6017331763..3cc1bbe3d2 100644 --- a/packages/arb-token-bridge-ui/src/components/TransferPanel/TokenRow.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransferPanel/TokenRow.tsx @@ -32,6 +32,7 @@ import { useNetworks } from '../../hooks/useNetworks' import { useNetworksRelationship } from '../../hooks/useNetworksRelationship' import { TokenLogoFallback } from './TokenInfo' import { useBalanceOnSourceChain } from '../../hooks/useBalanceOnSourceChain' +import { useNativeCurrencyDecimalsOnSourceChain } from '../../hooks/useNativeCurrencyDecimalsOnSourceChain' function tokenListIdsToNames(ids: number[]): string { return ids @@ -244,6 +245,8 @@ function TokenBalance({ token }: { token: ERC20BridgeToken | null }) { } = useAppState() const { isLoading: isLoadingAccountType } = useAccountType() const { balance, symbol } = useTokenInfo(token) + const nativeCurrencyDecimalsOnSourceChain = + useNativeCurrencyDecimalsOnSourceChain() const isArbitrumNativeUSDC = isTokenArbitrumOneNativeUSDC(token?.address) || @@ -266,6 +269,13 @@ function TokenBalance({ token }: { token: ERC20BridgeToken | null }) { return typeof bridgeTokens[token.address] !== 'undefined' }, [bridgeTokens, isArbitrumNativeUSDC, token]) + const decimals = useMemo(() => { + if (token) { + return token.decimals + } + return nativeCurrencyDecimalsOnSourceChain + }, [nativeCurrencyDecimalsOnSourceChain, token]) + if (!tokenIsAddedToTheBridge) { return Import } @@ -279,7 +289,7 @@ function TokenBalance({ token }: { token: ERC20BridgeToken | null }) { {balance ? ( formatAmount(balance, { - decimals: token?.decimals, + decimals, symbol }) ) : ( 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 74c4a4c788..74e80b3d29 100644 --- a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanel.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanel.tsx @@ -22,7 +22,10 @@ import { TransferPanelSummary } from './TransferPanelSummary' import { useAppContextActions } from '../App/AppContext' import { trackEvent } from '../../util/AnalyticsUtils' import { TransferPanelMain } from './TransferPanelMain' -import { isGatewayRegistered } from '../../util/TokenUtils' +import { + isGatewayRegistered, + scaleToNativeTokenDecimals +} from '../../util/TokenUtils' import { useSwitchNetworkWithConfig } from '../../hooks/useSwitchNetworkWithConfig' import { errorToast, warningToast } from '../common/atoms/Toast' import { useAccountType } from '../../hooks/useAccountType' @@ -77,6 +80,7 @@ import { useIsTransferAllowed } from './hooks/useIsTransferAllowed' import { MoveFundsButton } from './MoveFundsButton' import { ProjectsListing } from '../common/ProjectsListing' import { useAmountBigNumber } from './hooks/useAmountBigNumber' +import { useNativeCurrencyDecimalsOnSourceChain } from '../../hooks/useNativeCurrencyDecimalsOnSourceChain' const signerUndefinedError = 'Signer is undefined' const transferNotAllowedError = 'Transfer not allowed' @@ -131,6 +135,8 @@ export function TransferPanel() { } } = useLatest(useNetworksRelationship(latestNetworks.current)) const isBatchTransferSupported = useIsBatchTransferSupported() + const nativeCurrencyDecimalsOnSourceChain = + useNativeCurrencyDecimalsOnSourceChain() const nativeCurrency = useNativeCurrency({ provider: childChainProvider }) @@ -616,7 +622,7 @@ export function TransferPanel() { amount: amountBigNumber, options: { approvalAmountIncrease: isCustomNativeTokenAmount2 - ? utils.parseUnits(amount2, nativeCurrency.decimals) + ? utils.parseUnits(amount2, nativeCurrencyDecimalsOnSourceChain) : undefined } }) @@ -631,7 +637,7 @@ export function TransferPanel() { amount: amountBigNumber, options: { approvalAmountIncrease: isCustomNativeTokenAmount2 - ? utils.parseUnits(amount2, nativeCurrency.decimals) + ? utils.parseUnits(amount2, nativeCurrencyDecimalsOnSourceChain) : undefined } }) @@ -744,6 +750,7 @@ export function TransferPanel() { } overrides.maxSubmissionCost = utils + // we are not scaling these to native decimals because arbitrum-sdk does it for us .parseEther(amount2) .add(gasEstimates.estimatedChildChainSubmissionCost) overrides.excessFeeRefundAddress = destinationAddress @@ -798,6 +805,13 @@ export function TransferPanel() { const timestampCreated = String(normalizeTimestamp(Date.now())) + const scaledAmount = selectedToken + ? amountBigNumber + : scaleToNativeTokenDecimals({ + amount: amountBigNumber, + decimals: nativeCurrencyDecimalsOnSourceChain + }) + const txHistoryCompatibleObject = convertBridgeSdkToMergedTransaction({ bridgeTransfer, parentChainId: parentChain.id, @@ -806,7 +820,7 @@ export function TransferPanel() { walletAddress, destinationAddress, nativeCurrency, - amount: amountBigNumber, + amount: scaledAmount, amount2: isBatchTransfer ? utils.parseEther(amount2) : undefined, timestampCreated }) @@ -825,7 +839,7 @@ export function TransferPanel() { walletAddress, destinationAddress, nativeCurrency, - amount: amountBigNumber, + amount: scaledAmount, amount2: isBatchTransfer ? utils.parseEther(amount2) : undefined, timestampCreated }) diff --git a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMain/SourceNetworkBox.tsx b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMain/SourceNetworkBox.tsx index 48d493e25c..36f858e22d 100644 --- a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMain/SourceNetworkBox.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMain/SourceNetworkBox.tsx @@ -33,6 +33,7 @@ import { Button } from '../../common/Button' import { useSelectedTokenDecimals } from '../../../hooks/TransferPanel/useSelectedTokenDecimals' import { useNativeCurrencyBalances } from './useNativeCurrencyBalances' import { useIsCctpTransfer } from '../hooks/useIsCctpTransfer' +import { useNativeCurrencyDecimalsOnSourceChain } from '../../../hooks/useNativeCurrencyDecimalsOnSourceChain' function Amount2ToggleButton({ onClick @@ -92,6 +93,8 @@ export function SourceNetworkBox() { const decimals = useSelectedTokenDecimals() const { errorMessages } = useTransferReadiness() const nativeCurrencyBalances = useNativeCurrencyBalances() + const nativeCurrencyDecimalsOnSourceChain = + useNativeCurrencyDecimalsOnSourceChain() const isCctpTransfer = useIsCctpTransfer() @@ -145,10 +148,19 @@ export function SourceNetworkBox() { symbol: nativeCurrency.symbol, disabled: true, balance: nativeCurrencyBalances.sourceBalance - ? Number(utils.formatEther(nativeCurrencyBalances.sourceBalance)) + ? Number( + utils.formatUnits( + nativeCurrencyBalances.sourceBalance, + nativeCurrencyDecimalsOnSourceChain + ) + ) : undefined }), - [nativeCurrencyBalances, nativeCurrency.symbol] + [ + nativeCurrencyBalances, + nativeCurrency.symbol, + nativeCurrencyDecimalsOnSourceChain + ] ) return ( diff --git a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMain/TokenBalance.tsx b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMain/TokenBalance.tsx index 1e56d31e81..24f66b7437 100644 --- a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMain/TokenBalance.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMain/TokenBalance.tsx @@ -1,12 +1,18 @@ +import { useMemo } from 'react' import { BigNumber } from 'ethers' import { ERC20BridgeToken } from '../../../hooks/arbTokenBridge.types' -import { NativeCurrencyErc20 } from '../../../hooks/useNativeCurrency' +import { + NativeCurrencyErc20, + useNativeCurrency +} from '../../../hooks/useNativeCurrency' import { Loader } from '../../common/atoms/Loader' import { TokenSymbolWithExplorerLink } from '../../common/TokenSymbolWithExplorerLink' import { formatAmount } from '../../../util/NumberUtils' import { NetworkType } from './utils' +import { useNetworks } from '../../../hooks/useNetworks' +import { useNetworksRelationship } from '../../../hooks/useNetworksRelationship' export function TokenBalance({ forToken, @@ -22,6 +28,23 @@ export function TokenBalance({ tokenSymbolOverride?: string }) { const isParentChain = on === NetworkType.parentChain + const [networks] = useNetworks() + const { childChainProvider } = useNetworksRelationship(networks) + const nativeCurrency = useNativeCurrency({ + provider: childChainProvider + }) + + const isCustomNativeCurrency = + nativeCurrency.isCustom && + forToken?.address.toLowerCase() === nativeCurrency.address.toLowerCase() + + const decimals = useMemo(() => { + if (!isParentChain && isCustomNativeCurrency) { + // Native currency on Orbit chain, always 18 decimals + return 18 + } + return forToken?.decimals + }, [forToken?.decimals, isCustomNativeCurrency, isParentChain]) if (!forToken) { return null @@ -43,7 +66,7 @@ export function TokenBalance({ {prefix} {formatAmount(balance, { - decimals: forToken.decimals + decimals })} {' '} { diff --git a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMainInput.tsx b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMainInput.tsx index 414dc3303f..a0fc311e7f 100644 --- a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMainInput.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMainInput.tsx @@ -21,6 +21,7 @@ import { Loader } from '../common/atoms/Loader' import { sanitizeAmountQueryParam } from '../../hooks/useArbQueryParams' import { truncateExtraDecimals } from '../../util/NumberUtils' import { useNativeCurrencyBalances } from './TransferPanelMain/useNativeCurrencyBalances' +import { useNativeCurrencyDecimalsOnSourceChain } from '../../hooks/useNativeCurrencyDecimalsOnSourceChain' function MaxButton({ className = '', @@ -86,6 +87,8 @@ function SourceChainTokenBalance({ const [networks] = useNetworks() const { isDepositMode, childChainProvider } = useNetworksRelationship(networks) + const nativeCurrencyDecimalsOnSourceChain = + useNativeCurrencyDecimalsOnSourceChain() const nativeCurrencyBalances = useNativeCurrencyBalances() const selectedTokenBalances = useSelectedTokenBalances() @@ -96,6 +99,14 @@ function SourceChainTokenBalance({ ? selectedTokenBalances.parentBalance : selectedTokenBalances.childBalance + const selectedTokenDecimals = useMemo(() => { + if (selectedToken) { + return selectedToken.decimals + } + + return nativeCurrencyDecimalsOnSourceChain + }, [nativeCurrencyDecimalsOnSourceChain, selectedToken]) + const balance = balanceOverride ?? (selectedToken ? tokenBalance : nativeCurrencyBalances.sourceBalance) @@ -103,7 +114,7 @@ function SourceChainTokenBalance({ const formattedBalance = balance !== null ? formatAmount(balance, { - decimals: selectedToken?.decimals ?? nativeCurrency.decimals + decimals: selectedTokenDecimals }) : null diff --git a/packages/arb-token-bridge-ui/src/components/TransferPanel/hooks/useAmountBigNumber.ts b/packages/arb-token-bridge-ui/src/components/TransferPanel/hooks/useAmountBigNumber.ts index eb25a1680e..d578996588 100644 --- a/packages/arb-token-bridge-ui/src/components/TransferPanel/hooks/useAmountBigNumber.ts +++ b/packages/arb-token-bridge-ui/src/components/TransferPanel/hooks/useAmountBigNumber.ts @@ -2,18 +2,15 @@ import { useMemo } from 'react' import { useArbQueryParams } from '../../../hooks/useArbQueryParams' import { useAppState } from '../../../state' import { constants, utils } from 'ethers' -import { useNetworks } from '../../../hooks/useNetworks' -import { useNetworksRelationship } from '../../../hooks/useNetworksRelationship' -import { useNativeCurrency } from '../../../hooks/useNativeCurrency' +import { useNativeCurrencyDecimalsOnSourceChain } from '../../../hooks/useNativeCurrencyDecimalsOnSourceChain' export function useAmountBigNumber() { const { app: { selectedToken } } = useAppState() const [{ amount }] = useArbQueryParams() - const [networks] = useNetworks() - const { childChainProvider } = useNetworksRelationship(networks) - const nativeCurrency = useNativeCurrency({ provider: childChainProvider }) + const nativeCurrencyDecimalsOnSourceChain = + useNativeCurrencyDecimalsOnSourceChain() return useMemo(() => { try { @@ -23,9 +20,9 @@ export function useAmountBigNumber() { return utils.parseUnits(amountSafe, selectedToken.decimals) } - return utils.parseUnits(amountSafe, nativeCurrency.decimals) + return utils.parseUnits(amountSafe, nativeCurrencyDecimalsOnSourceChain) } catch (error) { return constants.Zero } - }, [amount, selectedToken, nativeCurrency]) + }, [amount, selectedToken, nativeCurrencyDecimalsOnSourceChain]) } diff --git a/packages/arb-token-bridge-ui/src/hooks/useNativeCurrencyDecimalsOnSourceChain.ts b/packages/arb-token-bridge-ui/src/hooks/useNativeCurrencyDecimalsOnSourceChain.ts new file mode 100644 index 0000000000..d03aba45ea --- /dev/null +++ b/packages/arb-token-bridge-ui/src/hooks/useNativeCurrencyDecimalsOnSourceChain.ts @@ -0,0 +1,21 @@ +import { isNetwork } from '../util/networks' +import { useNativeCurrency } from './useNativeCurrency' +import { useNetworks } from './useNetworks' +import { useNetworksRelationship } from './useNetworksRelationship' + +export const useNativeCurrencyDecimalsOnSourceChain = () => { + const [networks] = useNetworks() + const { childChainProvider } = useNetworksRelationship(networks) + const nativeCurrency = useNativeCurrency({ + provider: childChainProvider + }) + const { isOrbitChain: isSourceChainOrbit } = isNetwork( + networks.sourceChain.id + ) + + if (isSourceChainOrbit) { + return 18 + } + + return nativeCurrency.decimals +} diff --git a/packages/arb-token-bridge-ui/src/util/TokenUtils.ts b/packages/arb-token-bridge-ui/src/util/TokenUtils.ts index 91318f35e7..3b27c16633 100644 --- a/packages/arb-token-bridge-ui/src/util/TokenUtils.ts +++ b/packages/arb-token-bridge-ui/src/util/TokenUtils.ts @@ -1,4 +1,4 @@ -import { constants } from 'ethers' +import { BigNumber, constants } from 'ethers' import { Provider } from '@ethersproject/providers' import { Erc20Bridger, @@ -495,3 +495,34 @@ 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 82e7706695..7fca2fa10a 100644 --- a/packages/arb-token-bridge-ui/src/util/withdrawals/helpers.ts +++ b/packages/arb-token-bridge-ui/src/util/withdrawals/helpers.ts @@ -6,7 +6,7 @@ import { ChildTransactionReceipt } from '@arbitrum/sdk' import { FetchWithdrawalsFromSubgraphResult } from './fetchWithdrawalsFromSubgraph' -import { fetchErc20Data } from '../TokenUtils' +import { fetchErc20Data, scaleToNativeTokenDecimals } from '../TokenUtils' import { AssetType, L2ToL1EventResult, @@ -87,7 +87,10 @@ export async function mapETHWithdrawalToL2ToL1EventResult({ sender: event.caller, destinationAddress: event.destination, type: AssetType.ETH, - value: callvalue, + value: scaleToNativeTokenDecimals({ + amount: callvalue, + decimals: nativeCurrency.decimals + }), symbol: nativeCurrency.symbol, outgoingMessageState, l2TxHash: event.l2TxHash || event.transactionHash, @@ -314,7 +317,10 @@ export async function mapWithdrawalToL2ToL1EventResult({ sender: withdrawal.sender, destinationAddress: withdrawal.receiver, type: AssetType.ETH, - value: BigNumber.from(withdrawal.ethValue), + value: scaleToNativeTokenDecimals({ + amount: BigNumber.from(withdrawal.ethValue), + decimals: nativeCurrency.decimals + }), outgoingMessageState, l2TxHash: l2TxReceipt.transactionHash, symbol: nativeCurrency.symbol, diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index a221bb6467..851dcdf296 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -36,6 +36,7 @@ import { registerLocalNetwork } from './src/util/networks' import { getCommonSynpressConfig } from './tests/e2e/getCommonSynpressConfig' +import { fetchNativeCurrency } from './src/hooks/useNativeCurrency' const tests = process.env.TEST_FILE ? [process.env.TEST_FILE] @@ -77,6 +78,8 @@ export default defineConfig({ const ethBridger = await EthBridger.fromProvider(childProvider) const isCustomFeeToken = isNonZeroAddress(ethBridger.nativeToken) + const nativeToken = await fetchNativeCurrency({ provider: childProvider }) + if (!ethRpcUrl && !isOrbitTest) { throw new Error('NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL variable missing.') } @@ -202,6 +205,7 @@ export default defineConfig({ config.env.ORBIT_TEST = isOrbitTest ? '1' : '0' config.env.NATIVE_TOKEN_SYMBOL = isCustomFeeToken ? 'TN' : 'ETH' config.env.NATIVE_TOKEN_ADDRESS = ethBridger.nativeToken + config.env.NATIVE_TOKEN_DECIMALS = nativeToken.decimals config.env.CUSTOM_DESTINATION_ADDRESS = await getCustomDestinationAddress() diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts index 5c627e2344..bbab2432c4 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts @@ -16,6 +16,7 @@ describe('Login Account', () => { let l2ETHbal const nativeTokenSymbol = Cypress.env('NATIVE_TOKEN_SYMBOL') + const nativeTokenDecimals = Cypress.env('NATIVE_TOKEN_DECIMALS') const isCustomFeeToken = nativeTokenSymbol !== 'ETH' before(() => { @@ -28,7 +29,7 @@ describe('Login Account', () => { }).then(val => (l1ETHbal = formatAmount(val))) } else { getInitialETHBalance(Cypress.env('ETH_RPC_URL')).then( - val => (l1ETHbal = formatAmount(val)) + val => (l1ETHbal = formatAmount(val, { decimals: nativeTokenDecimals })) ) } getInitialETHBalance(Cypress.env('ARB_RPC_URL')).then( From a9825d451acd4b0fea0c20487e21d71fd66310fc Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 17 Oct 2024 14:26:51 +0200 Subject: [PATCH 66/99] logs --- packages/arb-token-bridge-ui/synpress.config.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 851dcdf296..5bc13d3646 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -20,7 +20,6 @@ import { contractAbi, contractByteCode } from './testErc20Token' import { checkForAssertions, generateActivityOnChains, - NetworkType, fundEth, setupCypressTasks, getCustomDestinationAddress, @@ -74,12 +73,6 @@ export default defineConfig({ process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' ) - const erc20Bridger = await Erc20Bridger.fromProvider(childProvider) - const ethBridger = await EthBridger.fromProvider(childProvider) - const isCustomFeeToken = isNonZeroAddress(ethBridger.nativeToken) - - const nativeToken = await fetchNativeCurrency({ provider: childProvider }) - if (!ethRpcUrl && !isOrbitTest) { throw new Error('NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL variable missing.') } @@ -95,6 +88,16 @@ export default defineConfig({ ) } + const erc20Bridger = await Erc20Bridger.fromProvider(childProvider) + const ethBridger = await EthBridger.fromProvider(childProvider) + const isCustomFeeToken = isNonZeroAddress(ethBridger.nativeToken) + + console.log({ isCustomFeeToken §}) + + const nativeToken = await fetchNativeCurrency({ provider: childProvider }) + + console.group({ nativeToken }) + const userWalletAddress = await userWallet.getAddress() // Fund the userWallet. We do this to run tests on a small amount of ETH. From f760bc9a0b3935163543ab729d84929e543e9ab8 Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 17 Oct 2024 15:26:16 +0200 Subject: [PATCH 67/99] fixes --- .../arb-token-bridge-ui/synpress.config.ts | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 5bc13d3646..e38bf72a3c 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -12,7 +12,7 @@ import { StaticJsonRpcProvider } from '@ethersproject/providers' import synpressPlugins from '@synthetixio/synpress/plugins' import { TestERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestERC20__factory' import { TestWETH9__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestWETH9__factory' -import { Erc20Bridger, EthBridger } from '@arbitrum/sdk' +import { Erc20Bridger, EthBridger, MultiCaller } from '@arbitrum/sdk' import logsPrinter from 'cypress-terminal-report/src/installLogsPrinter' import { getL2ERC20Address } from './src/util/TokenUtils' import specFiles from './tests/e2e/specfiles.json' @@ -92,12 +92,20 @@ export default defineConfig({ const ethBridger = await EthBridger.fromProvider(childProvider) const isCustomFeeToken = isNonZeroAddress(ethBridger.nativeToken) - console.log({ isCustomFeeToken §}) + console.log({ isCustomFeeToken }) - const nativeToken = await fetchNativeCurrency({ provider: childProvider }) + const multiCaller = await MultiCaller.fromProvider(parentProvider) + + const nativeToken = isCustomFeeToken + ? ( + await multiCaller.getTokenData([ethBridger.nativeToken!], { + decimals: true + }) + )[0] + : undefined + + console.log({ nativeToken }) - console.group({ nativeToken }) - const userWalletAddress = await userWallet.getAddress() // Fund the userWallet. We do this to run tests on a small amount of ETH. @@ -208,7 +216,7 @@ export default defineConfig({ config.env.ORBIT_TEST = isOrbitTest ? '1' : '0' config.env.NATIVE_TOKEN_SYMBOL = isCustomFeeToken ? 'TN' : 'ETH' config.env.NATIVE_TOKEN_ADDRESS = ethBridger.nativeToken - config.env.NATIVE_TOKEN_DECIMALS = nativeToken.decimals + config.env.NATIVE_TOKEN_DECIMALS = nativeToken?.decimals ?? 18 config.env.CUSTOM_DESTINATION_ADDRESS = await getCustomDestinationAddress() From 9200dbec4b429cf07a6a52b28f0d2e31933de579 Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 17 Oct 2024 15:38:18 +0200 Subject: [PATCH 68/99] updates --- .github/workflows/e2e-tests.yml | 2 +- README.md | 6 ++++++ packages/arb-token-bridge-ui/tests/e2e/specfiles.json | 8 ++++---- .../tests/e2e/specs/approveToken.cy.ts | 6 +++--- .../tests/e2e/specs/batchDeposit.cy.ts | 6 +++--- .../arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts | 4 ++-- .../tests/e2e/specs/depositERC20.cy.ts | 6 +++--- .../specs/{depositETH.cy.ts => depositNativeToken.cy.ts} | 6 +++--- .../tests/e2e/specs/withdrawERC20.cy.ts | 4 ++-- .../{withdrawETH.cy.ts => withdrawNativeToken.cy.ts} | 4 ++-- packages/arb-token-bridge-ui/tests/support/common.ts | 2 +- 11 files changed, 30 insertions(+), 24 deletions(-) rename packages/arb-token-bridge-ui/tests/e2e/specs/{depositETH.cy.ts => depositNativeToken.cy.ts} (91%) rename packages/arb-token-bridge-ui/tests/e2e/specs/{withdrawETH.cy.ts => withdrawNativeToken.cy.ts} (98%) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 8f98f389e4..c4c82bac77 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -28,7 +28,7 @@ jobs: run: echo "e2eFiles=$(node .github/workflows/formatSpecfiles.js ${{ inputs.test_type }} | jq . --compact-output)" >> $GITHUB_OUTPUT test-e2e: - name: "Test E2E - ${{ matrix.test.name }}${{ matrix.test.type == 'orbit-eth' && ' with L3' || matrix.test.type == 'orbit-custom' && ' with custom fee token' || ''}}" + name: "${{ matrix.test.name }}${{ matrix.test.type == 'orbit-eth' && ' with L3' || matrix.test.type == 'orbit-custom' && ' with custom fee token' || ''}}" needs: [load-e2e-files] runs-on: ubuntu-latest strategy: diff --git a/README.md b/README.md index 73f9acd030..74739c0054 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,12 @@ It is important for any code change to pass both unit and end-to-end tests. This ./test-node.bash --init --no-simple --tokenbridge --l3node --l3-token-bridge ``` + To run with a custom fee token also include the following flags: + + ```bash + --l3-fee-token --l3-fee-token-decimals 18 + ``` + 2. When the Nitro test-node is up and running you should see logs like `sequencer_1` and `staker-unsafe_1` in the terminal. This can take up to 10 minutes. 2. At the root of the token bridge UI: diff --git a/packages/arb-token-bridge-ui/tests/e2e/specfiles.json b/packages/arb-token-bridge-ui/tests/e2e/specfiles.json index 8e740d8962..fd907011e2 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specfiles.json +++ b/packages/arb-token-bridge-ui/tests/e2e/specfiles.json @@ -5,13 +5,13 @@ "recordVideo": "false" }, { - "name": "Deposit ETH", - "file": "tests/e2e/specs/**/depositETH.cy.{js,jsx,ts,tsx}", + "name": "Deposit native token", + "file": "tests/e2e/specs/**/depositNativeToken.cy.{js,jsx,ts,tsx}", "recordVideo": "false" }, { - "name": "Withdraw ETH", - "file": "tests/e2e/specs/**/withdrawETH.cy.{js,jsx,ts,tsx}", + "name": "Withdraw native token", + "file": "tests/e2e/specs/**/withdrawNativeToken.cy.{js,jsx,ts,tsx}", "recordVideo": "false" }, { diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts index e338075cf4..c96ceb903c 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts @@ -2,7 +2,7 @@ import { importTokenThroughUI, ERC20TokenName, ERC20TokenSymbol, - getZeroToLessThanOneNativeToken, + getZeroToLessThanOneToken, getL1NetworkName, getL2NetworkName } from '../../support/common' @@ -11,8 +11,8 @@ const ERC20TokenAddressL1 = Cypress.env('ERC20_TOKEN_ADDRESS_PARENT_CHAIN') describe('Approve token for deposit', () => { // log in to metamask - const zeroToLessThanOneEth = getZeroToLessThanOneNativeToken('ETH') - const zeroToLessThanOneNativeToken = getZeroToLessThanOneNativeToken( + const zeroToLessThanOneEth = getZeroToLessThanOneToken('ETH') + const zeroToLessThanOneNativeToken = getZeroToLessThanOneToken( Cypress.env('NATIVE_TOKEN_SYMBOL') ) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/batchDeposit.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/batchDeposit.cy.ts index a3d4a52b5a..6f002c0385 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/batchDeposit.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/batchDeposit.cy.ts @@ -6,7 +6,7 @@ import { getL1NetworkName, getL2NetworkConfig, getL2NetworkName, - getZeroToLessThanOneNativeToken + getZeroToLessThanOneToken } from '../../support/common' import { formatAmount } from '../../../src/util/NumberUtils' @@ -17,9 +17,9 @@ describe('Batch Deposit', () => { childErc20Balance: string const nativeTokenSymbol = Cypress.env('NATIVE_TOKEN_SYMBOL') - const zeroToLessThanOneEth = getZeroToLessThanOneNativeToken('ETH') + const zeroToLessThanOneEth = getZeroToLessThanOneToken('ETH') const zeroToLessThanOneNativeToken = - getZeroToLessThanOneNativeToken(nativeTokenSymbol) + getZeroToLessThanOneToken(nativeTokenSymbol) beforeEach(() => { getInitialERC20Balance({ diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts index 81432d54ae..2192f46816 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts @@ -2,7 +2,7 @@ * When user wants to bridge USDC through CCTP from L1 to L2 */ -import { getZeroToLessThanOneNativeToken } from '../../support/common' +import { getZeroToLessThanOneToken } from '../../support/common' import { CommonAddress } from '../../../src/util/CommonAddressUtils' import { formatAmount } from 'packages/arb-token-bridge-ui/src/util/NumberUtils' @@ -65,7 +65,7 @@ const confirmAndApproveCctpDeposit = () => { describe('Deposit USDC through CCTP', () => { // Happy Path const USDCAmountToSend = 0.0001 - const zeroToLessThanOneNativeToken = getZeroToLessThanOneNativeToken( + const zeroToLessThanOneNativeToken = getZeroToLessThanOneToken( Cypress.env('NATIVE_TOKEN_SYMBOL') ) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/depositERC20.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/depositERC20.cy.ts index 8b214f4c55..1cd9ac5c13 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/depositERC20.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/depositERC20.cy.ts @@ -6,7 +6,7 @@ import { formatAmount } from '../../../src/util/NumberUtils' import { getInitialERC20Balance, getL1NetworkConfig, - getZeroToLessThanOneNativeToken, + getZeroToLessThanOneToken, moreThanZeroBalance, getL1NetworkName, getL2NetworkName, @@ -34,9 +34,9 @@ describe('Deposit Token', () => { const isOrbitTest = Cypress.env('ORBIT_TEST') == '1' const depositTime = isOrbitTest ? 'Less than a minute' : '9 minutes' const nativeTokenSymbol = Cypress.env('NATIVE_TOKEN_SYMBOL') - const zeroToLessThanOneEth = getZeroToLessThanOneNativeToken('ETH') + const zeroToLessThanOneEth = getZeroToLessThanOneToken('ETH') const zeroToLessThanOneNativeToken = - getZeroToLessThanOneNativeToken(nativeTokenSymbol) + getZeroToLessThanOneToken(nativeTokenSymbol) // Happy Path Object.keys(depositTestCases).forEach(tokenType => { diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/depositETH.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/depositNativeToken.cy.ts similarity index 91% rename from packages/arb-token-bridge-ui/tests/e2e/specs/depositETH.cy.ts rename to packages/arb-token-bridge-ui/tests/e2e/specs/depositNativeToken.cy.ts index eb4886ac9a..7e674337b4 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/depositETH.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/depositNativeToken.cy.ts @@ -5,15 +5,15 @@ import { getL1NetworkName, getL2NetworkName, - getZeroToLessThanOneNativeToken + getZeroToLessThanOneToken } from '../../support/common' describe('Deposit native token', () => { const ETHAmountToDeposit = 0.0001 const nativeTokenSymbol = Cypress.env('NATIVE_TOKEN_SYMBOL') - const zeroToLessThanOneEth = getZeroToLessThanOneNativeToken('ETH') + const zeroToLessThanOneEth = getZeroToLessThanOneToken('ETH') const zeroToLessThanOneNativeToken = - getZeroToLessThanOneNativeToken(nativeTokenSymbol) + getZeroToLessThanOneToken(nativeTokenSymbol) const isOrbitTest = Cypress.env('ORBIT_TEST') == '1' const depositTime = isOrbitTest ? 'Less than a minute' : '9 minutes' diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawERC20.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawERC20.cy.ts index 3ee878e90b..bbc0ff696f 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawERC20.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawERC20.cy.ts @@ -9,7 +9,7 @@ import { getL2NetworkConfig, getL1NetworkName, getL2NetworkName, - getZeroToLessThanOneNativeToken, + getZeroToLessThanOneToken, ERC20TokenSymbol } from '../../support/common' @@ -29,7 +29,7 @@ const withdrawalTestCases = { describe('Withdraw ERC20 Token', () => { const nativeTokenSymbol = Cypress.env('NATIVE_TOKEN_SYMBOL') const zeroToLessThanOneNativeToken = - getZeroToLessThanOneNativeToken(nativeTokenSymbol) + getZeroToLessThanOneToken(nativeTokenSymbol) let ERC20AmountToSend = Number((Math.random() * 0.001).toFixed(5)) // randomize the amount to be sure that previous transactions are not checked in e2e // when all of our tests need to run in a logged-in state // we have to make sure we preserve a healthy LocalStorage state diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawETH.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawNativeToken.cy.ts similarity index 98% rename from packages/arb-token-bridge-ui/tests/e2e/specs/withdrawETH.cy.ts rename to packages/arb-token-bridge-ui/tests/e2e/specs/withdrawNativeToken.cy.ts index da9ad51646..bee9061c24 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawETH.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawNativeToken.cy.ts @@ -6,14 +6,14 @@ import { getInitialETHBalance, getL1NetworkName, getL2NetworkName, - getZeroToLessThanOneNativeToken + getZeroToLessThanOneToken } from '../../support/common' import { formatAmount } from '../../../src/util/NumberUtils' describe('Withdraw native token', () => { const nativeTokenSymbol = Cypress.env('NATIVE_TOKEN_SYMBOL') const zeroToLessThanOneNativeToken = - getZeroToLessThanOneNativeToken(nativeTokenSymbol) + getZeroToLessThanOneToken(nativeTokenSymbol) let ETHToWithdraw = Number((Math.random() * 0.001).toFixed(5)) // randomize the amount to be sure that previous transactions are not checked in e2e let l1EthBal: string diff --git a/packages/arb-token-bridge-ui/tests/support/common.ts b/packages/arb-token-bridge-ui/tests/support/common.ts index 8a4156016b..8635435968 100644 --- a/packages/arb-token-bridge-ui/tests/support/common.ts +++ b/packages/arb-token-bridge-ui/tests/support/common.ts @@ -106,7 +106,7 @@ export const invalidTokenAddress = utils.computeAddress(utils.randomBytes(32)) export const moreThanZeroBalance = /0(\.\d+)/ -export function getZeroToLessThanOneNativeToken(symbol: string) { +export function getZeroToLessThanOneToken(symbol: string) { return new RegExp(`0(\\.\\d+)*( ${symbol})`) } From f52f409f27b8a201d40937255dc9aa3c68c4dc05 Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 17 Oct 2024 16:28:24 +0200 Subject: [PATCH 69/99] updates --- .github/workflows/e2e-tests.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 7a0af855f5..c41fe2c1e7 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -92,7 +92,14 @@ jobs: uses: OffchainLabs/actions/run-nitro-test-node@a20a76172ce524832ac897bef2fa10a62ed81c29 with: nitro-testnode-ref: badbcbea9b43d46e115da4d7c9f2f57c31af8431 - args: ${{ matrix.test.testnodeArgs }} + args: >- + ${{ + (matrix.test.type == 'orbit-eth') && '--l3node --l3-token-bridge' || + (matrix.test.type == 'orbit-custom-16dec' && '--l3node --l3-token-bridge --l3-fee-token --l3-fee-token-decimals 16') || + (matrix.test.type == 'orbit-custom-18dec' && '--l3node --l3-token-bridge --l3-fee-token') || + (matrix.test.type == 'orbit-custom-20dec' && '--l3node --l3-token-bridge --l3-fee-token --l3-fee-token-decimals 20') || + '' + }} - name: Run e2e tests via cypress-io/github-action uses: cypress-io/github-action@0da3c06ed8217b912deea9d8ee69630baed1737e # pin@v6.7.6 From cfe3aacd3f216416d965117d329aec242feb692f Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 17 Oct 2024 17:03:28 +0200 Subject: [PATCH 70/99] updates --- .github/workflows/e2e-tests.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index c41fe2c1e7..9f465350ac 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -92,12 +92,14 @@ jobs: uses: OffchainLabs/actions/run-nitro-test-node@a20a76172ce524832ac897bef2fa10a62ed81c29 with: nitro-testnode-ref: badbcbea9b43d46e115da4d7c9f2f57c31af8431 + l3-node: ${{ matrix.test.type != 'regular' }} + no-l3-token-bridge: ${{ matrix.test.type == 'regular' }} args: >- ${{ (matrix.test.type == 'orbit-eth') && '--l3node --l3-token-bridge' || - (matrix.test.type == 'orbit-custom-16dec' && '--l3node --l3-token-bridge --l3-fee-token --l3-fee-token-decimals 16') || - (matrix.test.type == 'orbit-custom-18dec' && '--l3node --l3-token-bridge --l3-fee-token') || - (matrix.test.type == 'orbit-custom-20dec' && '--l3node --l3-token-bridge --l3-fee-token --l3-fee-token-decimals 20') || + (matrix.test.type == 'orbit-custom-16dec' && '--l3-fee-token --l3-fee-token-decimals 16') || + (matrix.test.type == 'orbit-custom-18dec' && '--l3-fee-token') || + (matrix.test.type == 'orbit-custom-20dec' && '--l3-fee-token --l3-fee-token-decimals 20') || '' }} From 0cede9357f9cab354bef69f4660d070f83621a0b Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 17 Oct 2024 18:41:03 +0200 Subject: [PATCH 71/99] updates --- .../arb-token-bridge-ui/synpress.config.ts | 36 ++++++++-------- .../tests/e2e/specs/login.cy.ts | 6 ++- .../tests/support/common.ts | 41 ++++++++++++++++--- 3 files changed, 57 insertions(+), 26 deletions(-) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index e38bf72a3c..d42707dbaa 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -12,7 +12,7 @@ import { StaticJsonRpcProvider } from '@ethersproject/providers' import synpressPlugins from '@synthetixio/synpress/plugins' import { TestERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestERC20__factory' import { TestWETH9__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestWETH9__factory' -import { Erc20Bridger, EthBridger, MultiCaller } from '@arbitrum/sdk' +import { Erc20Bridger, EthBridger } from '@arbitrum/sdk' import logsPrinter from 'cypress-terminal-report/src/installLogsPrinter' import { getL2ERC20Address } from './src/util/TokenUtils' import specFiles from './tests/e2e/specfiles.json' @@ -25,7 +25,8 @@ import { getCustomDestinationAddress, ERC20TokenSymbol, ERC20TokenDecimals, - ERC20TokenName + ERC20TokenName, + getNativeTokenDecimals } from './tests/support/common' import { @@ -35,7 +36,6 @@ import { registerLocalNetwork } from './src/util/networks' import { getCommonSynpressConfig } from './tests/e2e/getCommonSynpressConfig' -import { fetchNativeCurrency } from './src/hooks/useNativeCurrency' const tests = process.env.TEST_FILE ? [process.env.TEST_FILE] @@ -94,18 +94,6 @@ export default defineConfig({ console.log({ isCustomFeeToken }) - const multiCaller = await MultiCaller.fromProvider(parentProvider) - - const nativeToken = isCustomFeeToken - ? ( - await multiCaller.getTokenData([ethBridger.nativeToken!], { - decimals: true - }) - )[0] - : undefined - - console.log({ nativeToken }) - const userWalletAddress = await userWallet.getAddress() // Fund the userWallet. We do this to run tests on a small amount of ETH. @@ -216,7 +204,10 @@ export default defineConfig({ config.env.ORBIT_TEST = isOrbitTest ? '1' : '0' config.env.NATIVE_TOKEN_SYMBOL = isCustomFeeToken ? 'TN' : 'ETH' config.env.NATIVE_TOKEN_ADDRESS = ethBridger.nativeToken - config.env.NATIVE_TOKEN_DECIMALS = nativeToken?.decimals ?? 18 + config.env.NATIVE_TOKEN_DECIMALS = await getNativeTokenDecimals({ + parentProvider, + childProvider + }) config.env.CUSTOM_DESTINATION_ADDRESS = await getCustomDestinationAddress() @@ -314,6 +305,10 @@ async function approveCustomFeeToken({ async function fundUserWalletNativeCurrency() { const childEthBridger = await EthBridger.fromProvider(childProvider) + const decimals = await getNativeTokenDecimals({ + parentProvider, + childProvider + }) const address = await userWallet.getAddress() @@ -323,18 +318,21 @@ async function fundUserWalletNativeCurrency() { ) const userBalance = await tokenContract.balanceOf(address) - const shouldFund = userBalance.lt(utils.parseEther('0.3')) + const shouldFund = userBalance.lt(utils.parseUnits('0.3', decimals)) if (!shouldFund) { console.log( - `User wallet has enough L3 native currency for testing, skip funding...` + `User wallet has enough custom native currency for testing, skip funding...` ) return } console.log(`Funding native currency to user wallet on L2...`) - const tx = await tokenContract.transfer(address, utils.parseEther('3')) + const tx = await tokenContract.transfer( + address, + utils.parseUnits('3', decimals) + ) await tx.wait() } diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts index bbab2432c4..ce8413b0cc 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/login.cy.ts @@ -26,10 +26,12 @@ describe('Login Account', () => { multiCallerAddress: getL1NetworkConfig().multiCall, address: Cypress.env('ADDRESS'), rpcURL: Cypress.env('ETH_RPC_URL') - }).then(val => (l1ETHbal = formatAmount(val))) + }).then( + val => (l1ETHbal = formatAmount(val, { decimals: nativeTokenDecimals })) + ) } else { getInitialETHBalance(Cypress.env('ETH_RPC_URL')).then( - val => (l1ETHbal = formatAmount(val, { decimals: nativeTokenDecimals })) + val => (l1ETHbal = formatAmount(val)) ) } getInitialETHBalance(Cypress.env('ARB_RPC_URL')).then( diff --git a/packages/arb-token-bridge-ui/tests/support/common.ts b/packages/arb-token-bridge-ui/tests/support/common.ts index 8a4156016b..e9ca75c4a2 100644 --- a/packages/arb-token-bridge-ui/tests/support/common.ts +++ b/packages/arb-token-bridge-ui/tests/support/common.ts @@ -4,7 +4,7 @@ import { Provider, StaticJsonRpcProvider } from '@ethersproject/providers' import { BigNumber, Signer, Wallet, ethers, utils } from 'ethers' -import { MultiCaller } from '@arbitrum/sdk' +import { EthBridger, MultiCaller } from '@arbitrum/sdk' import { MULTICALL_TESTNET_ADDRESS } from '../../src/constants' import { defaultL2Network, @@ -183,6 +183,28 @@ export const startWebApp = (url = '/', qs: { [s: string]: string } = {}) => { }) } +export async function getNativeTokenDecimals({ + parentProvider, + childProvider +}: { + parentProvider: Provider + childProvider: Provider +}) { + const multiCaller = await MultiCaller.fromProvider(parentProvider) + const ethBridger = await EthBridger.fromProvider(childProvider) + const isCustomFeeToken = typeof ethBridger.nativeToken !== 'undefined' + + const nativeToken = isCustomFeeToken + ? ( + await multiCaller.getTokenData([ethBridger.nativeToken!], { + decimals: true + }) + )[0] + : undefined + + return nativeToken?.decimals ?? 18 +} + export const visitAfterSomeDelay = ( url: string, options?: Partial @@ -221,20 +243,29 @@ export async function generateActivityOnChains({ // whilst waiting for status we mine on both parentChain and childChain console.log('Generating activity on parentChain...') const minerParent = Wallet.createRandom().connect(parentProvider) + + const decimals = await getNativeTokenDecimals({ + parentProvider, + childProvider + }) + await fundEth({ address: await minerParent.getAddress(), provider: parentProvider, sourceWallet: wallet, - networkType: 'parentChain' + networkType: 'parentChain', + amount: utils.parseUnits('0.2', decimals) }) console.log('Generating activity on childChain...') const minerChild = Wallet.createRandom().connect(childProvider) + await fundEth({ address: await minerChild.getAddress(), provider: childProvider, sourceWallet: wallet, - networkType: 'childChain' + networkType: 'childChain', + amount: utils.parseEther('0.2') }) await Promise.allSettled([keepMining(minerParent), keepMining(minerChild)]) @@ -293,13 +324,13 @@ export async function fundEth({ provider, sourceWallet, // source wallet that will fund the `address`, networkType, - amount = utils.parseEther('2') + amount }: { address: string provider: Provider sourceWallet: Wallet networkType: NetworkType - amount?: BigNumber + amount: BigNumber }) { console.log(`Funding ETH ${address} on ${networkType}...`) const balance = await provider.getBalance(address) From 14f446e952e4b3ce73695d6f67291683590464ab Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 17 Oct 2024 19:07:41 +0200 Subject: [PATCH 72/99] bump sdk --- packages/arb-token-bridge-ui/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/package.json b/packages/arb-token-bridge-ui/package.json index cce5d024fa..b059682055 100644 --- a/packages/arb-token-bridge-ui/package.json +++ b/packages/arb-token-bridge-ui/package.json @@ -5,7 +5,7 @@ "private": true, "dependencies": { "@apollo/client": "^3.7.11", - "@arbitrum/sdk": "^4.0.1", + "@arbitrum/sdk": "^4.0.2-beta.0", "@ethersproject/providers": "^5.7.0", "@headlessui/react": "^1.7.8", "@headlessui/tailwindcss": "^0.1.2", From 91c35b64eb4c898b252e405cbf31630233800f3f Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 18 Oct 2024 12:10:19 +0200 Subject: [PATCH 73/99] fix --- .../TransferPanel/TransferPanel.tsx | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) 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 74e80b3d29..24adf1aa4c 100644 --- a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanel.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanel.tsx @@ -805,12 +805,19 @@ export function TransferPanel() { const timestampCreated = String(normalizeTimestamp(Date.now())) - const scaledAmount = selectedToken - ? amountBigNumber - : scaleToNativeTokenDecimals({ - amount: amountBigNumber, - decimals: nativeCurrencyDecimalsOnSourceChain - }) + const { isOrbitChain: isSourceOrbitChain } = isNetwork( + latestNetworks.current.sourceChain.id + ) + + const scaledAmount = + // only scale for native tokens, and + // only scale if sent from Orbit, because it's always 18 decimals there but the UI needs scaled amount + selectedToken || !isSourceOrbitChain + ? amountBigNumber + : scaleToNativeTokenDecimals({ + amount: amountBigNumber, + decimals: nativeCurrencyDecimalsOnSourceChain + }) const txHistoryCompatibleObject = convertBridgeSdkToMergedTransaction({ bridgeTransfer, From b4dc19b916247f637197fbb37bfdecf00b213f7b Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 18 Oct 2024 12:41:52 +0200 Subject: [PATCH 74/99] fix --- .../src/components/TransferPanel/TransferPanel.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 24adf1aa4c..b2b8357b65 100644 --- a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanel.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanel.tsx @@ -816,7 +816,7 @@ export function TransferPanel() { ? amountBigNumber : scaleToNativeTokenDecimals({ amount: amountBigNumber, - decimals: nativeCurrencyDecimalsOnSourceChain + decimals: nativeCurrency.decimals }) const txHistoryCompatibleObject = convertBridgeSdkToMergedTransaction({ From 801021246e311a50b28b713aa269430ac8baf384 Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 18 Oct 2024 14:52:10 +0200 Subject: [PATCH 75/99] fix --- .github/workflows/e2e-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index c4c82bac77..86f1317786 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -92,8 +92,8 @@ jobs: uses: OffchainLabs/actions/run-nitro-test-node@a20a76172ce524832ac897bef2fa10a62ed81c29 with: nitro-testnode-ref: badbcbea9b43d46e115da4d7c9f2f57c31af8431 - l3-node: ${{ matrix.test.type != 'regular' }} - no-l3-token-bridge: ${{ matrix.test.type == 'regular' }} + l3-node: ${{ matrix.test.type != 'regular' && inputs.test_type.type != 'cctp' }} + no-l3-token-bridge: ${{ matrix.test.type == 'regular' || inputs.test_type.type == 'cctp' }} args: ${{ matrix.test.type == 'orbit-custom' && '--l3-fee-token' || '' }} - name: Run e2e tests via cypress-io/github-action From c85a086de0395d07768241ee9f4eb2e076b274bb Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 18 Oct 2024 15:07:39 +0200 Subject: [PATCH 76/99] fix --- .github/workflows/e2e-tests.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 86f1317786..533bc916ed 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -92,8 +92,8 @@ jobs: uses: OffchainLabs/actions/run-nitro-test-node@a20a76172ce524832ac897bef2fa10a62ed81c29 with: nitro-testnode-ref: badbcbea9b43d46e115da4d7c9f2f57c31af8431 - l3-node: ${{ matrix.test.type != 'regular' && inputs.test_type.type != 'cctp' }} - no-l3-token-bridge: ${{ matrix.test.type == 'regular' || inputs.test_type.type == 'cctp' }} + l3-node: ${{ matrix.test.type != 'regular' }} + no-l3-token-bridge: ${{ matrix.test.type == 'regular' }} args: ${{ matrix.test.type == 'orbit-custom' && '--l3-fee-token' || '' }} - name: Run e2e tests via cypress-io/github-action @@ -104,6 +104,7 @@ jobs: ${{ (matrix.test.type == 'orbit-eth') && 'yarn test:e2e:orbit --browser chrome' || (matrix.test.type == 'orbit-custom' && 'yarn test:e2e:orbit:custom-gas-token --browser chrome') || + (matrix.test.type == 'cctp' && 'yarn test:e2e:cctp --browser chrome') 'yarn test:e2e --browser chrome' }} wait-on: http://127.0.0.1:3000 From a0d7974b1c147d48ec35cd699ed7f59ccca6714d Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 18 Oct 2024 15:09:16 +0200 Subject: [PATCH 77/99] fix --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 533bc916ed..0c10ac5227 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -104,7 +104,7 @@ jobs: ${{ (matrix.test.type == 'orbit-eth') && 'yarn test:e2e:orbit --browser chrome' || (matrix.test.type == 'orbit-custom' && 'yarn test:e2e:orbit:custom-gas-token --browser chrome') || - (matrix.test.type == 'cctp' && 'yarn test:e2e:cctp --browser chrome') + (matrix.test.type == 'cctp' && 'yarn test:e2e:cctp --browser chrome') || 'yarn test:e2e --browser chrome' }} wait-on: http://127.0.0.1:3000 From c3e86de8a0cdb6b6478047fcd967b138dcfe06bc Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 18 Oct 2024 15:36:27 +0200 Subject: [PATCH 78/99] fix --- .../tests/e2e/specs/depositCctp.cy.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts index 2192f46816..f655a787ce 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts @@ -4,7 +4,6 @@ import { getZeroToLessThanOneToken } from '../../support/common' import { CommonAddress } from '../../../src/util/CommonAddressUtils' -import { formatAmount } from 'packages/arb-token-bridge-ui/src/util/NumberUtils' // common function for this cctp deposit const confirmAndApproveCctpDeposit = () => { @@ -65,9 +64,7 @@ const confirmAndApproveCctpDeposit = () => { describe('Deposit USDC through CCTP', () => { // Happy Path const USDCAmountToSend = 0.0001 - const zeroToLessThanOneNativeToken = getZeroToLessThanOneToken( - Cypress.env('NATIVE_TOKEN_SYMBOL') - ) + const zeroToLessThanOneETH = getZeroToLessThanOneToken('ETH') beforeEach(() => { cy.login({ networkType: 'parentChain', networkName: 'sepolia' }) @@ -81,8 +78,8 @@ describe('Deposit USDC through CCTP', () => { }) cy.typeAmount(USDCAmountToSend) - cy.findGasFeeSummary(zeroToLessThanOneNativeToken) - cy.findGasFeeForChain('Sepolia', zeroToLessThanOneNativeToken) + cy.findGasFeeSummary(zeroToLessThanOneETH) + cy.findGasFeeForChain('Sepolia', zeroToLessThanOneETH) cy.findGasFeeForChain( /You'll have to pay Arbitrum Sepolia gas fee upon claiming./i ) From 18c66d2fcf03662d63303ec4bba1ca31573f068b Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 18 Oct 2024 16:25:30 +0200 Subject: [PATCH 79/99] fix --- packages/arb-token-bridge-ui/tests/support/commands.ts | 2 +- packages/arb-token-bridge-ui/tests/support/common.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/arb-token-bridge-ui/tests/support/commands.ts b/packages/arb-token-bridge-ui/tests/support/commands.ts index fd17e9ace8..a3ae2a0dea 100644 --- a/packages/arb-token-bridge-ui/tests/support/commands.ts +++ b/packages/arb-token-bridge-ui/tests/support/commands.ts @@ -141,7 +141,7 @@ export const searchAndSelectToken = ({ tokenAddress: string }) => { // Click on the native token dropdown (Select token button) - cy.findSelectTokenButton(Cypress.env('NATIVE_TOKEN_SYMBOL')).click() + cy.findSelectTokenButton(Cypress.env('NATIVE_TOKEN_SYMBOL') ?? 'ETH').click() // open the Select Token popup cy.findByPlaceholderText(/Search by token name/i) diff --git a/packages/arb-token-bridge-ui/tests/support/common.ts b/packages/arb-token-bridge-ui/tests/support/common.ts index 8635435968..76664a8e91 100644 --- a/packages/arb-token-bridge-ui/tests/support/common.ts +++ b/packages/arb-token-bridge-ui/tests/support/common.ts @@ -58,7 +58,7 @@ export const getL1NetworkConfig = (): NetworkConfig => { export const getL2NetworkConfig = (): NetworkConfig => { const isOrbitTest = Cypress.env('ORBIT_TEST') == '1' - const nativeTokenSymbol = Cypress.env('NATIVE_TOKEN_SYMBOL') + const nativeTokenSymbol = Cypress.env('NATIVE_TOKEN_SYMBOL') ?? 'ETH' const isCustomFeeToken = nativeTokenSymbol !== 'ETH' const l3Network = isCustomFeeToken From 816c3e089161a856d5ddec28d7336d2bc9edc977 Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 22 Oct 2024 11:13:24 +0200 Subject: [PATCH 80/99] try --- .../arb-token-bridge-ui/src/util/networks.ts | 29 ++++++++++--------- .../arb-token-bridge-ui/synpress.config.ts | 4 +-- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts index 8b61d28133..7aab4494f5 100644 --- a/packages/arb-token-bridge-ui/src/util/networks.ts +++ b/packages/arb-token-bridge-ui/src/util/networks.ts @@ -436,7 +436,7 @@ export const localL3NetworkRpcUrl = loadEnvironmentVariableWithFallback({ fallback: 'http://127.0.0.1:3347' }) -export async function registerLocalNetwork(isLocalCustomNativeToken?: boolean) { +export async function registerLocalNetwork() { try { rpcURLs[defaultL1Network.chainId] = localL1NetworkRpcUrl rpcURLs[defaultL2Network.chainId] = localL2NetworkRpcUrl @@ -444,19 +444,22 @@ export async function registerLocalNetwork(isLocalCustomNativeToken?: boolean) { registerCustomArbitrumNetwork(defaultL2Network) - if (typeof isLocalCustomNativeToken === 'undefined') { - try { - const data = await fetchErc20Data({ - address: defaultL3CustomGasTokenNetwork.nativeToken!, - provider: new StaticJsonRpcProvider(localL2NetworkRpcUrl) - }) - if (data.symbol === 'TN') { - isLocalCustomNativeToken = true - } - } catch (e) { - // not the native token - isLocalCustomNativeToken = false + let isLocalCustomNativeToken = false + + try { + const data = await fetchErc20Data({ + address: defaultL3CustomGasTokenNetwork.nativeToken!, + provider: new StaticJsonRpcProvider( + process.env.NEXT_PUBLIC_LOCAL_ARBITRUM_RPC_URL || + 'http://127.0.0.1:8547' + ) + }) + if (data.symbol === 'TN') { + isLocalCustomNativeToken = true } + } catch (e) { + // not the native token + isLocalCustomNativeToken = false } registerCustomArbitrumNetwork( diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index a221bb6467..9baf8dc246 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -69,9 +69,7 @@ export default defineConfig({ e2e: { async setupNodeEvents(on, config) { logsPrinter(on) - await registerLocalNetwork( - process.env.E2E_ORBIT_CUSTOM_GAS_TOKEN === 'true' - ) + await registerLocalNetwork() const erc20Bridger = await Erc20Bridger.fromProvider(childProvider) const ethBridger = await EthBridger.fromProvider(childProvider) From eb14269ba410aad81d7c7279197d419d14abb1aa Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 22 Oct 2024 11:33:18 +0200 Subject: [PATCH 81/99] logs --- packages/arb-token-bridge-ui/synpress.config.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 9baf8dc246..2c4dc619f0 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -14,7 +14,7 @@ import { TestERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestERC import { TestWETH9__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestWETH9__factory' import { Erc20Bridger, EthBridger } from '@arbitrum/sdk' import logsPrinter from 'cypress-terminal-report/src/installLogsPrinter' -import { getL2ERC20Address } from './src/util/TokenUtils' +import { fetchErc20Data, getL2ERC20Address } from './src/util/TokenUtils' import specFiles from './tests/e2e/specfiles.json' import { contractAbi, contractByteCode } from './testErc20Token' import { @@ -69,6 +69,17 @@ export default defineConfig({ e2e: { async setupNodeEvents(on, config) { logsPrinter(on) + + try { + const data = await fetchErc20Data({ + address: defaultL3CustomGasTokenNetwork.nativeToken!, + provider: new StaticJsonRpcProvider('http://127.0.0.1:8547') + }) + console.log({ data }) + } catch (e) { + console.log({ e }) + } + await registerLocalNetwork() const erc20Bridger = await Erc20Bridger.fromProvider(childProvider) From 702f39194ff0c369b7933392d064c1807568d895 Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 22 Oct 2024 12:00:58 +0200 Subject: [PATCH 82/99] fix --- .../arb-token-bridge-ui/src/util/networks.ts | 17 ++++++++--------- packages/arb-token-bridge-ui/synpress.config.ts | 13 +------------ 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts index 7aab4494f5..39dbed99d2 100644 --- a/packages/arb-token-bridge-ui/src/util/networks.ts +++ b/packages/arb-token-bridge-ui/src/util/networks.ts @@ -6,11 +6,11 @@ import { getArbitrumNetworks, registerCustomArbitrumNetwork } from '@arbitrum/sdk' +import { ERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/ERC20__factory' import { loadEnvironmentVariableWithFallback } from './index' import { getBridgeUiConfigForChain } from './bridgeUiConfig' import { chainIdToInfuraUrl } from './infura' -import { fetchErc20Data } from './TokenUtils' export enum ChainId { // L1 @@ -447,14 +447,13 @@ export async function registerLocalNetwork() { let isLocalCustomNativeToken = false try { - const data = await fetchErc20Data({ - address: defaultL3CustomGasTokenNetwork.nativeToken!, - provider: new StaticJsonRpcProvider( - process.env.NEXT_PUBLIC_LOCAL_ARBITRUM_RPC_URL || - 'http://127.0.0.1:8547' - ) - }) - if (data.symbol === 'TN') { + const erc20 = ERC20__factory.connect( + defaultL3CustomGasTokenNetwork.nativeToken!, + new StaticJsonRpcProvider(localL2NetworkRpcUrl) + ) + const symbol = await erc20.symbol() + + if (symbol === 'TN') { isLocalCustomNativeToken = true } } catch (e) { diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 2c4dc619f0..2150d747e3 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -14,13 +14,12 @@ import { TestERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestERC import { TestWETH9__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestWETH9__factory' import { Erc20Bridger, EthBridger } from '@arbitrum/sdk' import logsPrinter from 'cypress-terminal-report/src/installLogsPrinter' -import { fetchErc20Data, getL2ERC20Address } from './src/util/TokenUtils' +import { getL2ERC20Address } from './src/util/TokenUtils' import specFiles from './tests/e2e/specfiles.json' import { contractAbi, contractByteCode } from './testErc20Token' import { checkForAssertions, generateActivityOnChains, - NetworkType, fundEth, setupCypressTasks, getCustomDestinationAddress, @@ -70,16 +69,6 @@ export default defineConfig({ async setupNodeEvents(on, config) { logsPrinter(on) - try { - const data = await fetchErc20Data({ - address: defaultL3CustomGasTokenNetwork.nativeToken!, - provider: new StaticJsonRpcProvider('http://127.0.0.1:8547') - }) - console.log({ data }) - } catch (e) { - console.log({ e }) - } - await registerLocalNetwork() const erc20Bridger = await Erc20Bridger.fromProvider(childProvider) From 4f040ff30641a091728ca1b89dd770c115522e08 Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 22 Oct 2024 12:39:40 +0200 Subject: [PATCH 83/99] fix --- .../arb-token-bridge-ui/src/util/TokenUtils.ts | 4 ++++ .../arb-token-bridge-ui/src/util/networks.ts | 17 +++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/util/TokenUtils.ts b/packages/arb-token-bridge-ui/src/util/TokenUtils.ts index 91318f35e7..3069298c15 100644 --- a/packages/arb-token-bridge-ui/src/util/TokenUtils.ts +++ b/packages/arb-token-bridge-ui/src/util/TokenUtils.ts @@ -66,6 +66,10 @@ function getErc20DataCache(params: GetErc20DataCacheParams): Erc20Data | null function getErc20DataCache( params?: GetErc20DataCacheParams ): Erc20DataCache | (Erc20Data | null) { + if (typeof window.localStorage === 'undefined') { + return null + } + const cache: Erc20DataCache = JSON.parse( // intentionally using || instead of ?? for it to work with an empty string localStorage.getItem(erc20DataCacheLocalStorageKey) || '{}' diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts index 39dbed99d2..7aab4494f5 100644 --- a/packages/arb-token-bridge-ui/src/util/networks.ts +++ b/packages/arb-token-bridge-ui/src/util/networks.ts @@ -6,11 +6,11 @@ import { getArbitrumNetworks, registerCustomArbitrumNetwork } from '@arbitrum/sdk' -import { ERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/ERC20__factory' import { loadEnvironmentVariableWithFallback } from './index' import { getBridgeUiConfigForChain } from './bridgeUiConfig' import { chainIdToInfuraUrl } from './infura' +import { fetchErc20Data } from './TokenUtils' export enum ChainId { // L1 @@ -447,13 +447,14 @@ export async function registerLocalNetwork() { let isLocalCustomNativeToken = false try { - const erc20 = ERC20__factory.connect( - defaultL3CustomGasTokenNetwork.nativeToken!, - new StaticJsonRpcProvider(localL2NetworkRpcUrl) - ) - const symbol = await erc20.symbol() - - if (symbol === 'TN') { + const data = await fetchErc20Data({ + address: defaultL3CustomGasTokenNetwork.nativeToken!, + provider: new StaticJsonRpcProvider( + process.env.NEXT_PUBLIC_LOCAL_ARBITRUM_RPC_URL || + 'http://127.0.0.1:8547' + ) + }) + if (data.symbol === 'TN') { isLocalCustomNativeToken = true } } catch (e) { From a3ab2169ded17c49acfafd25fa4508915d6ad010 Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 22 Oct 2024 13:07:42 +0200 Subject: [PATCH 84/99] fix --- packages/arb-token-bridge-ui/src/util/TokenUtils.ts | 2 +- packages/arb-token-bridge-ui/synpress.config.ts | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/util/TokenUtils.ts b/packages/arb-token-bridge-ui/src/util/TokenUtils.ts index 3069298c15..cdda328dc7 100644 --- a/packages/arb-token-bridge-ui/src/util/TokenUtils.ts +++ b/packages/arb-token-bridge-ui/src/util/TokenUtils.ts @@ -66,7 +66,7 @@ function getErc20DataCache(params: GetErc20DataCacheParams): Erc20Data | null function getErc20DataCache( params?: GetErc20DataCacheParams ): Erc20DataCache | (Erc20Data | null) { - if (typeof window.localStorage === 'undefined') { + if (typeof window?.localStorage === 'undefined') { return null } diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 2150d747e3..2c4dc619f0 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -14,12 +14,13 @@ import { TestERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestERC import { TestWETH9__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestWETH9__factory' import { Erc20Bridger, EthBridger } from '@arbitrum/sdk' import logsPrinter from 'cypress-terminal-report/src/installLogsPrinter' -import { getL2ERC20Address } from './src/util/TokenUtils' +import { fetchErc20Data, getL2ERC20Address } from './src/util/TokenUtils' import specFiles from './tests/e2e/specfiles.json' import { contractAbi, contractByteCode } from './testErc20Token' import { checkForAssertions, generateActivityOnChains, + NetworkType, fundEth, setupCypressTasks, getCustomDestinationAddress, @@ -69,6 +70,16 @@ export default defineConfig({ async setupNodeEvents(on, config) { logsPrinter(on) + try { + const data = await fetchErc20Data({ + address: defaultL3CustomGasTokenNetwork.nativeToken!, + provider: new StaticJsonRpcProvider('http://127.0.0.1:8547') + }) + console.log({ data }) + } catch (e) { + console.log({ e }) + } + await registerLocalNetwork() const erc20Bridger = await Erc20Bridger.fromProvider(childProvider) From 583752185a404b911b19a3fe54167f43a09a80db Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 22 Oct 2024 13:52:18 +0200 Subject: [PATCH 85/99] fix --- packages/arb-token-bridge-ui/src/util/TokenUtils.ts | 5 ++++- packages/arb-token-bridge-ui/synpress.config.ts | 13 +------------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/util/TokenUtils.ts b/packages/arb-token-bridge-ui/src/util/TokenUtils.ts index cdda328dc7..99eaf03aaa 100644 --- a/packages/arb-token-bridge-ui/src/util/TokenUtils.ts +++ b/packages/arb-token-bridge-ui/src/util/TokenUtils.ts @@ -66,7 +66,10 @@ function getErc20DataCache(params: GetErc20DataCacheParams): Erc20Data | null function getErc20DataCache( params?: GetErc20DataCacheParams ): Erc20DataCache | (Erc20Data | null) { - if (typeof window?.localStorage === 'undefined') { + if ( + typeof window === 'undefined' || + typeof window.localStorage === 'undefined' + ) { return null } diff --git a/packages/arb-token-bridge-ui/synpress.config.ts b/packages/arb-token-bridge-ui/synpress.config.ts index 2c4dc619f0..2150d747e3 100644 --- a/packages/arb-token-bridge-ui/synpress.config.ts +++ b/packages/arb-token-bridge-ui/synpress.config.ts @@ -14,13 +14,12 @@ import { TestERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestERC import { TestWETH9__factory } from '@arbitrum/sdk/dist/lib/abi/factories/TestWETH9__factory' import { Erc20Bridger, EthBridger } from '@arbitrum/sdk' import logsPrinter from 'cypress-terminal-report/src/installLogsPrinter' -import { fetchErc20Data, getL2ERC20Address } from './src/util/TokenUtils' +import { getL2ERC20Address } from './src/util/TokenUtils' import specFiles from './tests/e2e/specfiles.json' import { contractAbi, contractByteCode } from './testErc20Token' import { checkForAssertions, generateActivityOnChains, - NetworkType, fundEth, setupCypressTasks, getCustomDestinationAddress, @@ -70,16 +69,6 @@ export default defineConfig({ async setupNodeEvents(on, config) { logsPrinter(on) - try { - const data = await fetchErc20Data({ - address: defaultL3CustomGasTokenNetwork.nativeToken!, - provider: new StaticJsonRpcProvider('http://127.0.0.1:8547') - }) - console.log({ data }) - } catch (e) { - console.log({ e }) - } - await registerLocalNetwork() const erc20Bridger = await Erc20Bridger.fromProvider(childProvider) From 05d02e438033f68955fd89e4f2425985fa1d0b48 Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 22 Oct 2024 14:11:19 +0200 Subject: [PATCH 86/99] clean up --- packages/arb-token-bridge-ui/src/util/networks.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts index 7aab4494f5..02d26cdeb3 100644 --- a/packages/arb-token-bridge-ui/src/util/networks.ts +++ b/packages/arb-token-bridge-ui/src/util/networks.ts @@ -449,10 +449,7 @@ export async function registerLocalNetwork() { try { const data = await fetchErc20Data({ address: defaultL3CustomGasTokenNetwork.nativeToken!, - provider: new StaticJsonRpcProvider( - process.env.NEXT_PUBLIC_LOCAL_ARBITRUM_RPC_URL || - 'http://127.0.0.1:8547' - ) + provider: new StaticJsonRpcProvider(localL2NetworkRpcUrl) }) if (data.symbol === 'TN') { isLocalCustomNativeToken = true From 91ffc0a7f5bbf7d8b3d574359a59980db19b6f4f Mon Sep 17 00:00:00 2001 From: Bartek Date: Tue, 22 Oct 2024 19:27:39 +0200 Subject: [PATCH 87/99] fix --- packages/arb-token-bridge-ui/tests/support/common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/arb-token-bridge-ui/tests/support/common.ts b/packages/arb-token-bridge-ui/tests/support/common.ts index 4ddfe2f3b0..874000ada9 100644 --- a/packages/arb-token-bridge-ui/tests/support/common.ts +++ b/packages/arb-token-bridge-ui/tests/support/common.ts @@ -112,7 +112,7 @@ export function getZeroToLessThanOneToken(symbol: string) { export const importTokenThroughUI = (address: string) => { // Click on the ETH dropdown (Select token button) - cy.findSelectTokenButton('ETH').click() + cy.findSelectTokenButton(Cypress.env('NATIVE_TOKEN_SYMBOL') ?? 'ETH').click() // open the Select Token popup cy.findByPlaceholderText(/Search by token name/i) From a14966e403fc483b1cb91b33b8de9706e7022119 Mon Sep 17 00:00:00 2001 From: Bartek Date: Wed, 23 Oct 2024 11:15:22 +0200 Subject: [PATCH 88/99] logs --- .../src/components/TransferPanel/TransferPanel.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 b2b8357b65..09622e02a4 100644 --- a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanel.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanel.tsx @@ -692,6 +692,8 @@ export function TransferPanel() { if (!withdrawalConfirmation) return false } + console.warn('decimals: ', nativeCurrencyDecimalsOnSourceChain) + // token approval if (selectedToken) { const isTokenApprovalRequired = @@ -718,6 +720,15 @@ 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() @@ -777,6 +788,7 @@ export function TransferPanel() { } : { transfer_type: 'native currency' } }) + console.warn({ error }) } finally { setTransferring(false) } From 1d5a12f126e05aa70e77742099af5b797c09c774 Mon Sep 17 00:00:00 2001 From: Bartek Date: Wed, 23 Oct 2024 14:51:43 +0200 Subject: [PATCH 89/99] bump nitro --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index c30d5ba3d6..b265b7a827 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: badbcbea9b43d46e115da4d7c9f2f57c31af8431 + nitro-testnode-ref: adapt-bridge-amount l3-node: ${{ matrix.test.type != 'regular' }} no-l3-token-bridge: ${{ matrix.test.type == 'regular' }} args: >- From 69cba21f381afb6a0b274148df892274aff6019f Mon Sep 17 00:00:00 2001 From: Bartek Date: Wed, 23 Oct 2024 15:59:03 +0200 Subject: [PATCH 90/99] 6 decimals --- .github/workflows/e2e-tests.yml | 4 ++-- .github/workflows/formatSpecfiles.js | 8 ++------ yarn.lock | 11 +++++++++++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index b265b7a827..a4c5c1e01b 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -102,7 +102,7 @@ jobs: args: >- ${{ (matrix.test.type == 'orbit-eth') && '--l3node --l3-token-bridge' || - (matrix.test.type == 'orbit-custom-16dec' && '--l3-fee-token --l3-fee-token-decimals 16') || + (matrix.test.type == 'orbit-custom-6dec' && '--l3-fee-token --l3-fee-token-decimals 6') || (matrix.test.type == 'orbit-custom-18dec' && '--l3-fee-token') || (matrix.test.type == 'orbit-custom-20dec' && '--l3-fee-token --l3-fee-token-decimals 20') || '' @@ -115,7 +115,7 @@ jobs: command: >- ${{ (matrix.test.type == 'orbit-eth') && 'yarn test:e2e:orbit --browser chrome' || - (matrix.test.type == 'orbit-custom-16dec' && 'yarn test:e2e:orbit:custom-gas-token --browser chrome') || + (matrix.test.type == 'orbit-custom-6dec' && 'yarn test:e2e:orbit:custom-gas-token --browser chrome') || (matrix.test.type == 'orbit-custom-18dec' && 'yarn test:e2e:orbit:custom-gas-token --browser chrome') || (matrix.test.type == 'orbit-custom-20dec' && 'yarn test:e2e:orbit:custom-gas-token --browser chrome') || (matrix.test.type == 'cctp' && 'yarn test:e2e:cctp --browser chrome') || diff --git a/.github/workflows/formatSpecfiles.js b/.github/workflows/formatSpecfiles.js index 7494cdd251..9948ac5b19 100644 --- a/.github/workflows/formatSpecfiles.js +++ b/.github/workflows/formatSpecfiles.js @@ -12,25 +12,21 @@ switch (testType) { ...spec, type: "regular", typeName: "", - testnodeArgs: "", }); tests.push({ ...spec, type: "orbit-eth", typeName: "with L3 (ETH)", - testnodeArgs: "--l3node --l3-token-bridge", }); tests.push({ ...spec, - type: "orbit-custom-16dec", - typeName: "with L3 (16 decimals custom)", - testnodeArgs: "--l3node --l3-token-bridge --l3-fee-token --l3-fee-token-decimals 16", + type: "orbit-custom-6dec", + typeName: "with L3 (6 decimals custom)", }); tests.push({ ...spec, type: "orbit-custom-18dec", typeName: "with L3 (18 decimals custom)", - testnodeArgs: "--l3node --l3-token-bridge --l3-fee-token", }); tests.push({ ...spec, diff --git a/yarn.lock b/yarn.lock index 30f2747718..9325a88327 100644 --- a/yarn.lock +++ b/yarn.lock @@ -89,6 +89,17 @@ async-mutex "^0.4.0" ethers "^5.1.0" +"@arbitrum/sdk@^4.0.2-beta.0": + version "4.0.2-beta.0" + resolved "https://registry.yarnpkg.com/@arbitrum/sdk/-/sdk-4.0.2-beta.0.tgz#864e38797d9f25e0b0d6a5f0147d60bd5b5db3b6" + integrity sha512-Q22DqEYzlkspvx6h9LUgTFgpUr9PNtPiyp4hTaODOdNl+cbpVAz6G9x04iMAnNia9sP0KffhDD5WxS4CzFrFFw== + dependencies: + "@ethersproject/address" "^5.0.8" + "@ethersproject/bignumber" "^5.1.1" + "@ethersproject/bytes" "^5.0.8" + async-mutex "^0.4.0" + ethers "^5.1.0" + "@babel/code-frame@7.12.11": version "7.12.11" resolved "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz" From 21f925b7855168826a0f167f7e21a6c751db17fe Mon Sep 17 00:00:00 2001 From: Bartek Date: Wed, 23 Oct 2024 16:27:33 +0200 Subject: [PATCH 91/99] fix approval gas scaling --- .../token-bridge-sdk/Erc20DepositStarter.ts | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/token-bridge-sdk/Erc20DepositStarter.ts b/packages/arb-token-bridge-ui/src/token-bridge-sdk/Erc20DepositStarter.ts index 3934103f21..62271dcf66 100644 --- a/packages/arb-token-bridge-ui/src/token-bridge-sdk/Erc20DepositStarter.ts +++ b/packages/arb-token-bridge-ui/src/token-bridge-sdk/Erc20DepositStarter.ts @@ -91,11 +91,6 @@ export class Erc20DepositStarter extends BridgeTransferStarter { return false // native currency doesn't require approval } - const nativeCurrency = ERC20__factory.connect( - l2Network.nativeToken, - this.sourceChainProvider - ) - const customFeeTokenAllowanceForSourceChainGateway = await fetchErc20Allowance({ address: l2Network.nativeToken, @@ -121,9 +116,9 @@ export class Erc20DepositStarter extends BridgeTransferStarter { .add(gasEstimates.estimatedChildChainSubmissionCost) ) ) - const estimatedDestinationChainGasFee = utils.parseUnits( - String(estimatedDestinationChainGasFeeEth), - await nativeCurrency.decimals() + + const estimatedDestinationChainGasFee = utils.parseEther( + String(estimatedDestinationChainGasFeeEth) ) // We want to bridge a certain amount of an ERC-20 token, but the Retryable fees on the destination chain will be paid in the custom fee token @@ -171,11 +166,6 @@ export class Erc20DepositStarter extends BridgeTransferStarter { throw Error('Network does not have a custom native token') } - const nativeCurrency = ERC20__factory.connect( - l2Network.nativeToken, - this.sourceChainProvider - ) - const gasEstimates = await this.transferEstimateGas({ amount, signer }) const destinationChainGasPrice = @@ -194,9 +184,8 @@ export class Erc20DepositStarter extends BridgeTransferStarter { ) ) - const estimatedDestinationChainGasFee = utils.parseUnits( - String(estimatedDestinationChainGasFeeEth), - await nativeCurrency.decimals() + const estimatedDestinationChainGasFee = utils.parseEther( + String(estimatedDestinationChainGasFeeEth) ) return erc20Bridger.approveGasToken({ From 171eea0040e5417e14b1f77ca8f4c9f0464ec9dd Mon Sep 17 00:00:00 2001 From: Bartek Date: Wed, 23 Oct 2024 17:32:40 +0200 Subject: [PATCH 92/99] 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. From 3ab56f0848c2de54f70b2234a0af19be98d8cba2 Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 24 Oct 2024 11:27:29 +0200 Subject: [PATCH 93/99] update comments --- .../TransferPanelMain/useMaxAmount.ts | 3 +-- .../TransferPanel/TransferPanelMainInput.tsx | 13 ++----------- .../TransferPanel/useSelectedTokenDecimals.ts | 14 ++++++-------- 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMain/useMaxAmount.ts b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMain/useMaxAmount.ts index 15fcd1017c..f033c91313 100644 --- a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMain/useMaxAmount.ts +++ b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMain/useMaxAmount.ts @@ -46,7 +46,7 @@ export function useMaxAmount() { // ETH deposits and ETH/custom fee token withdrawals const nativeCurrencyBalanceFormatted = utils.formatUnits( nativeCurrencySourceBalance, - nativeCurrency.decimals + nativeCurrencyDecimalsOnSourceChain ) if ( @@ -73,7 +73,6 @@ export function useMaxAmount() { estimatedChildChainGasFees, estimatedParentChainGasFees, isDepositMode, - nativeCurrency.decimals, nativeCurrency.isCustom, nativeCurrencyBalances.sourceBalance, nativeCurrencyDecimalsOnSourceChain diff --git a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMainInput.tsx b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMainInput.tsx index a0fc311e7f..e6365719d6 100644 --- a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMainInput.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanelMainInput.tsx @@ -21,7 +21,7 @@ import { Loader } from '../common/atoms/Loader' import { sanitizeAmountQueryParam } from '../../hooks/useArbQueryParams' import { truncateExtraDecimals } from '../../util/NumberUtils' import { useNativeCurrencyBalances } from './TransferPanelMain/useNativeCurrencyBalances' -import { useNativeCurrencyDecimalsOnSourceChain } from '../../hooks/useNativeCurrencyDecimalsOnSourceChain' +import { useSelectedTokenDecimals } from '../../hooks/TransferPanel/useSelectedTokenDecimals' function MaxButton({ className = '', @@ -87,8 +87,7 @@ function SourceChainTokenBalance({ const [networks] = useNetworks() const { isDepositMode, childChainProvider } = useNetworksRelationship(networks) - const nativeCurrencyDecimalsOnSourceChain = - useNativeCurrencyDecimalsOnSourceChain() + const selectedTokenDecimals = useSelectedTokenDecimals() const nativeCurrencyBalances = useNativeCurrencyBalances() const selectedTokenBalances = useSelectedTokenBalances() @@ -99,14 +98,6 @@ function SourceChainTokenBalance({ ? selectedTokenBalances.parentBalance : selectedTokenBalances.childBalance - const selectedTokenDecimals = useMemo(() => { - if (selectedToken) { - return selectedToken.decimals - } - - return nativeCurrencyDecimalsOnSourceChain - }, [nativeCurrencyDecimalsOnSourceChain, selectedToken]) - const balance = balanceOverride ?? (selectedToken ? tokenBalance : nativeCurrencyBalances.sourceBalance) diff --git a/packages/arb-token-bridge-ui/src/hooks/TransferPanel/useSelectedTokenDecimals.ts b/packages/arb-token-bridge-ui/src/hooks/TransferPanel/useSelectedTokenDecimals.ts index 13a59dd41f..c17b8fa1cd 100644 --- a/packages/arb-token-bridge-ui/src/hooks/TransferPanel/useSelectedTokenDecimals.ts +++ b/packages/arb-token-bridge-ui/src/hooks/TransferPanel/useSelectedTokenDecimals.ts @@ -1,16 +1,14 @@ import { useAppState } from '../../state' -import { useNativeCurrency } from '../useNativeCurrency' -import { useNetworksRelationship } from '../useNetworksRelationship' -import { useNetworks } from '../useNetworks' +import { useNativeCurrencyDecimalsOnSourceChain } from '../useNativeCurrencyDecimalsOnSourceChain' export function useSelectedTokenDecimals() { const { app: { selectedToken } } = useAppState() - const [networks] = useNetworks() - const { childChainProvider } = useNetworksRelationship(networks) + const nativeCurrencyDecimalsOnSourceChain = + useNativeCurrencyDecimalsOnSourceChain() - const nativeCurrency = useNativeCurrency({ provider: childChainProvider }) - - return selectedToken ? selectedToken.decimals : nativeCurrency.decimals + return selectedToken + ? selectedToken.decimals + : nativeCurrencyDecimalsOnSourceChain } From 93a30720708137dbd79715eae18de20de5e49df5 Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 24 Oct 2024 12:14:22 +0200 Subject: [PATCH 94/99] fix approvals --- .../token-bridge-sdk/Erc20DepositStarter.ts | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/token-bridge-sdk/Erc20DepositStarter.ts b/packages/arb-token-bridge-ui/src/token-bridge-sdk/Erc20DepositStarter.ts index 62271dcf66..2593a8378a 100644 --- a/packages/arb-token-bridge-ui/src/token-bridge-sdk/Erc20DepositStarter.ts +++ b/packages/arb-token-bridge-ui/src/token-bridge-sdk/Erc20DepositStarter.ts @@ -117,8 +117,14 @@ export class Erc20DepositStarter extends BridgeTransferStarter { ) ) - const estimatedDestinationChainGasFee = utils.parseEther( - String(estimatedDestinationChainGasFeeEth) + const nativeCurrency = ERC20__factory.connect( + l2Network.nativeToken, + this.sourceChainProvider + ) + + const estimatedDestinationChainGasFee = utils.parseUnits( + String(estimatedDestinationChainGasFeeEth), + await nativeCurrency.decimals() ) // We want to bridge a certain amount of an ERC-20 token, but the Retryable fees on the destination chain will be paid in the custom fee token @@ -184,8 +190,14 @@ export class Erc20DepositStarter extends BridgeTransferStarter { ) ) - const estimatedDestinationChainGasFee = utils.parseEther( - String(estimatedDestinationChainGasFeeEth) + const nativeCurrency = ERC20__factory.connect( + l2Network.nativeToken, + this.sourceChainProvider + ) + + const estimatedDestinationChainGasFee = utils.parseUnits( + String(estimatedDestinationChainGasFeeEth), + await nativeCurrency.decimals() ) return erc20Bridger.approveGasToken({ From c6ba658c5fc72d68da7bb9ea656a828a6ded3c21 Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 24 Oct 2024 14:22:55 +0200 Subject: [PATCH 95/99] logs --- .../src/components/TransferPanel/TransferPanel.tsx | 7 +++++++ 1 file changed, 7 insertions(+) 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 0ee92a9000..ec7f23d15a 100644 --- a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanel.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanel.tsx @@ -625,6 +625,8 @@ export function TransferPanel() { } }) + console.warn({ isNativeCurrencyApprovalRequired }) + if (isNativeCurrencyApprovalRequired) { // show native currency approval dialog const userConfirmation = await customFeeTokenApproval() @@ -643,6 +645,8 @@ export function TransferPanel() { if (approvalTx) { await approvalTx.wait() } + + console.warn('approved') } // checks for the selected token @@ -698,6 +702,7 @@ export function TransferPanel() { signer, destinationAddress }) + console.warn({ isTokenApprovalRequired }) if (isTokenApprovalRequired) { const userConfirmation = await tokenAllowanceApproval() if (!userConfirmation) return false @@ -713,6 +718,7 @@ export function TransferPanel() { if (approvalTx) { await approvalTx.wait() } + console.warn('token approved') } } @@ -765,6 +771,7 @@ export function TransferPanel() { // transaction submitted callback onTxSubmit(transfer) } catch (error) { + console.warn({ error }) captureSentryErrorWithExtraData({ error, originFunction: 'bridgeTransferStarter.transfer', From 1abd383dc1f70a18dd81916332c062400f6656ca Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 24 Oct 2024 14:38:51 +0200 Subject: [PATCH 96/99] fixes --- .../components/TransferPanel/TransferPanel.tsx | 7 ------- .../src/token-bridge-sdk/Erc20DepositStarter.ts | 17 +++++++++-------- 2 files changed, 9 insertions(+), 15 deletions(-) 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 ec7f23d15a..0ee92a9000 100644 --- a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanel.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanel.tsx @@ -625,8 +625,6 @@ export function TransferPanel() { } }) - console.warn({ isNativeCurrencyApprovalRequired }) - if (isNativeCurrencyApprovalRequired) { // show native currency approval dialog const userConfirmation = await customFeeTokenApproval() @@ -645,8 +643,6 @@ export function TransferPanel() { if (approvalTx) { await approvalTx.wait() } - - console.warn('approved') } // checks for the selected token @@ -702,7 +698,6 @@ export function TransferPanel() { signer, destinationAddress }) - console.warn({ isTokenApprovalRequired }) if (isTokenApprovalRequired) { const userConfirmation = await tokenAllowanceApproval() if (!userConfirmation) return false @@ -718,7 +713,6 @@ export function TransferPanel() { if (approvalTx) { await approvalTx.wait() } - console.warn('token approved') } } @@ -771,7 +765,6 @@ export function TransferPanel() { // transaction submitted callback onTxSubmit(transfer) } catch (error) { - console.warn({ error }) captureSentryErrorWithExtraData({ error, originFunction: 'bridgeTransferStarter.transfer', diff --git a/packages/arb-token-bridge-ui/src/token-bridge-sdk/Erc20DepositStarter.ts b/packages/arb-token-bridge-ui/src/token-bridge-sdk/Erc20DepositStarter.ts index 2593a8378a..088b1630cb 100644 --- a/packages/arb-token-bridge-ui/src/token-bridge-sdk/Erc20DepositStarter.ts +++ b/packages/arb-token-bridge-ui/src/token-bridge-sdk/Erc20DepositStarter.ts @@ -1,6 +1,7 @@ import { Erc20Bridger } from '@arbitrum/sdk' import { BigNumber, constants, utils } from 'ethers' import { ERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/ERC20__factory' +import { scaleToNativeTokenDecimals } from '@arbitrum/sdk/dist/lib/utils/lib' import { ApproveNativeCurrencyEstimateGasProps, ApproveNativeCurrencyProps, @@ -122,10 +123,10 @@ export class Erc20DepositStarter extends BridgeTransferStarter { this.sourceChainProvider ) - const estimatedDestinationChainGasFee = utils.parseUnits( - String(estimatedDestinationChainGasFeeEth), - await nativeCurrency.decimals() - ) + const estimatedDestinationChainGasFee = scaleToNativeTokenDecimals({ + amount: utils.parseEther(String(estimatedDestinationChainGasFeeEth)), + decimals: await nativeCurrency.decimals() + }) // We want to bridge a certain amount of an ERC-20 token, but the Retryable fees on the destination chain will be paid in the custom fee token // We have to check if the native-token spending allowance is enough to cover the fees @@ -195,10 +196,10 @@ export class Erc20DepositStarter extends BridgeTransferStarter { this.sourceChainProvider ) - const estimatedDestinationChainGasFee = utils.parseUnits( - String(estimatedDestinationChainGasFeeEth), - await nativeCurrency.decimals() - ) + const estimatedDestinationChainGasFee = scaleToNativeTokenDecimals({ + amount: utils.parseEther(String(estimatedDestinationChainGasFeeEth)), + decimals: await nativeCurrency.decimals() + }) return erc20Bridger.approveGasToken({ erc20ParentAddress: this.sourceChainErc20Address, From 79061b9828b97b8f255fea8079241d12587824c9 Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 24 Oct 2024 14:47:04 +0200 Subject: [PATCH 97/99] clean up --- .../token-bridge-sdk/Erc20DepositStarter.ts | 20 +++++++++---------- .../src/util/TokenUtils.ts | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/token-bridge-sdk/Erc20DepositStarter.ts b/packages/arb-token-bridge-ui/src/token-bridge-sdk/Erc20DepositStarter.ts index 088b1630cb..0966bd35e6 100644 --- a/packages/arb-token-bridge-ui/src/token-bridge-sdk/Erc20DepositStarter.ts +++ b/packages/arb-token-bridge-ui/src/token-bridge-sdk/Erc20DepositStarter.ts @@ -92,6 +92,11 @@ export class Erc20DepositStarter extends BridgeTransferStarter { return false // native currency doesn't require approval } + const nativeCurrency = ERC20__factory.connect( + l2Network.nativeToken, + this.sourceChainProvider + ) + const customFeeTokenAllowanceForSourceChainGateway = await fetchErc20Allowance({ address: l2Network.nativeToken, @@ -118,11 +123,6 @@ export class Erc20DepositStarter extends BridgeTransferStarter { ) ) - const nativeCurrency = ERC20__factory.connect( - l2Network.nativeToken, - this.sourceChainProvider - ) - const estimatedDestinationChainGasFee = scaleToNativeTokenDecimals({ amount: utils.parseEther(String(estimatedDestinationChainGasFeeEth)), decimals: await nativeCurrency.decimals() @@ -173,6 +173,11 @@ export class Erc20DepositStarter extends BridgeTransferStarter { throw Error('Network does not have a custom native token') } + const nativeCurrency = ERC20__factory.connect( + l2Network.nativeToken, + this.sourceChainProvider + ) + const gasEstimates = await this.transferEstimateGas({ amount, signer }) const destinationChainGasPrice = @@ -191,11 +196,6 @@ export class Erc20DepositStarter extends BridgeTransferStarter { ) ) - const nativeCurrency = ERC20__factory.connect( - l2Network.nativeToken, - this.sourceChainProvider - ) - const estimatedDestinationChainGasFee = scaleToNativeTokenDecimals({ amount: utils.parseEther(String(estimatedDestinationChainGasFeeEth)), decimals: await nativeCurrency.decimals() diff --git a/packages/arb-token-bridge-ui/src/util/TokenUtils.ts b/packages/arb-token-bridge-ui/src/util/TokenUtils.ts index fe3ddb12ee..99eaf03aaa 100644 --- a/packages/arb-token-bridge-ui/src/util/TokenUtils.ts +++ b/packages/arb-token-bridge-ui/src/util/TokenUtils.ts @@ -1,4 +1,4 @@ -import { BigNumber, constants } from 'ethers' +import { constants } from 'ethers' import { Provider } from '@ethersproject/providers' import { Erc20Bridger, From ed7c2243e40e6359ac73c882b2ef2dc2e7f46fa5 Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 24 Oct 2024 15:33:20 +0200 Subject: [PATCH 98/99] clean up --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index c48b496c40..bb9224d0ea 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -34,7 +34,7 @@ jobs: test-e2e: name: "Test E2E - ${{ matrix.test.name }} ${{ matrix.test.typeName }}" - needs: [load-e2e-files] + needs: [build, load-e2e-files] runs-on: ubuntu-latest strategy: fail-fast: false From 607a2517762800a350e022ec54c82d349fc1617b Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 31 Oct 2024 12:57:47 +0100 Subject: [PATCH 99/99] bump sdk --- packages/arb-token-bridge-ui/package.json | 2 +- .../TransferPanel/TransferPanel.tsx | 4 ++-- .../token-bridge-sdk/Erc20DepositStarter.ts | 24 +++++++++++-------- .../src/util/withdrawals/helpers.ts | 8 +++---- yarn.lock | 8 +++---- 5 files changed, 25 insertions(+), 21 deletions(-) diff --git a/packages/arb-token-bridge-ui/package.json b/packages/arb-token-bridge-ui/package.json index 608c92cf15..e8d292c70b 100644 --- a/packages/arb-token-bridge-ui/package.json +++ b/packages/arb-token-bridge-ui/package.json @@ -5,7 +5,7 @@ "private": true, "dependencies": { "@apollo/client": "^3.7.11", - "@arbitrum/sdk": "^4.0.2-beta.0", + "@arbitrum/sdk": "^4.0.2-beta.1", "@ethersproject/providers": "^5.7.0", "@headlessui/react": "^1.7.8", "@headlessui/tailwindcss": "^0.1.2", 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 0ee92a9000..a631d602f7 100644 --- a/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanel.tsx +++ b/packages/arb-token-bridge-ui/src/components/TransferPanel/TransferPanel.tsx @@ -6,7 +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 { scaleFrom18DecimalsToNativeTokenDecimals } from '@arbitrum/sdk' import { useAppState } from '../../state' import { getNetworkName, isNetwork } from '../../util/networks' @@ -812,7 +812,7 @@ export function TransferPanel() { // only scale if sent from Orbit, because it's always 18 decimals there but the UI needs scaled amount selectedToken || !isSourceOrbitChain ? amountBigNumber - : scaleToNativeTokenDecimals({ + : scaleFrom18DecimalsToNativeTokenDecimals({ amount: amountBigNumber, decimals: nativeCurrency.decimals }) diff --git a/packages/arb-token-bridge-ui/src/token-bridge-sdk/Erc20DepositStarter.ts b/packages/arb-token-bridge-ui/src/token-bridge-sdk/Erc20DepositStarter.ts index 0966bd35e6..a5f5200cbe 100644 --- a/packages/arb-token-bridge-ui/src/token-bridge-sdk/Erc20DepositStarter.ts +++ b/packages/arb-token-bridge-ui/src/token-bridge-sdk/Erc20DepositStarter.ts @@ -1,7 +1,9 @@ -import { Erc20Bridger } from '@arbitrum/sdk' +import { + Erc20Bridger, + scaleFrom18DecimalsToNativeTokenDecimals +} from '@arbitrum/sdk' import { BigNumber, constants, utils } from 'ethers' import { ERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/ERC20__factory' -import { scaleToNativeTokenDecimals } from '@arbitrum/sdk/dist/lib/utils/lib' import { ApproveNativeCurrencyEstimateGasProps, ApproveNativeCurrencyProps, @@ -123,10 +125,11 @@ export class Erc20DepositStarter extends BridgeTransferStarter { ) ) - const estimatedDestinationChainGasFee = scaleToNativeTokenDecimals({ - amount: utils.parseEther(String(estimatedDestinationChainGasFeeEth)), - decimals: await nativeCurrency.decimals() - }) + const estimatedDestinationChainGasFee = + scaleFrom18DecimalsToNativeTokenDecimals({ + amount: utils.parseEther(String(estimatedDestinationChainGasFeeEth)), + decimals: await nativeCurrency.decimals() + }) // We want to bridge a certain amount of an ERC-20 token, but the Retryable fees on the destination chain will be paid in the custom fee token // We have to check if the native-token spending allowance is enough to cover the fees @@ -196,10 +199,11 @@ export class Erc20DepositStarter extends BridgeTransferStarter { ) ) - const estimatedDestinationChainGasFee = scaleToNativeTokenDecimals({ - amount: utils.parseEther(String(estimatedDestinationChainGasFeeEth)), - decimals: await nativeCurrency.decimals() - }) + const estimatedDestinationChainGasFee = + scaleFrom18DecimalsToNativeTokenDecimals({ + amount: utils.parseEther(String(estimatedDestinationChainGasFeeEth)), + decimals: await nativeCurrency.decimals() + }) return erc20Bridger.approveGasToken({ erc20ParentAddress: this.sourceChainErc20Address, 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 546bffdd8f..89ab0369be 100644 --- a/packages/arb-token-bridge-ui/src/util/withdrawals/helpers.ts +++ b/packages/arb-token-bridge-ui/src/util/withdrawals/helpers.ts @@ -3,9 +3,9 @@ import { Provider } from '@ethersproject/providers' import { BigNumber } from '@ethersproject/bignumber' import { ChildToParentMessageReader, - ChildTransactionReceipt + ChildTransactionReceipt, + scaleFrom18DecimalsToNativeTokenDecimals } from '@arbitrum/sdk' -import { scaleToNativeTokenDecimals } from '@arbitrum/sdk/dist/lib/utils/lib' import { FetchWithdrawalsFromSubgraphResult } from './fetchWithdrawalsFromSubgraph' import { fetchErc20Data } from '../TokenUtils' import { @@ -88,7 +88,7 @@ export async function mapETHWithdrawalToL2ToL1EventResult({ sender: event.caller, destinationAddress: event.destination, type: AssetType.ETH, - value: scaleToNativeTokenDecimals({ + value: scaleFrom18DecimalsToNativeTokenDecimals({ amount: callvalue, decimals: nativeCurrency.decimals }), @@ -318,7 +318,7 @@ export async function mapWithdrawalToL2ToL1EventResult({ sender: withdrawal.sender, destinationAddress: withdrawal.receiver, type: AssetType.ETH, - value: scaleToNativeTokenDecimals({ + value: scaleFrom18DecimalsToNativeTokenDecimals({ amount: BigNumber.from(withdrawal.ethValue), decimals: nativeCurrency.decimals }), diff --git a/yarn.lock b/yarn.lock index b6e2788c03..eba2169b8c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -89,10 +89,10 @@ async-mutex "^0.4.0" ethers "^5.1.0" -"@arbitrum/sdk@^4.0.2-beta.0": - version "4.0.2-beta.0" - resolved "https://registry.yarnpkg.com/@arbitrum/sdk/-/sdk-4.0.2-beta.0.tgz#864e38797d9f25e0b0d6a5f0147d60bd5b5db3b6" - integrity sha512-Q22DqEYzlkspvx6h9LUgTFgpUr9PNtPiyp4hTaODOdNl+cbpVAz6G9x04iMAnNia9sP0KffhDD5WxS4CzFrFFw== +"@arbitrum/sdk@^4.0.2-beta.1": + version "4.0.2-beta.1" + resolved "https://registry.yarnpkg.com/@arbitrum/sdk/-/sdk-4.0.2-beta.1.tgz#c6c6c5784a8eaa6a4edab3600f765e9f82ce5988" + integrity sha512-a5DG6+Ld3X4L8H3CTUl3gc27Bj/Pqjo+5UZiCI97SM2mHtHKWF1BgQ+FCk/8bgFUP5nS9dXBl5tPJRtCFfOe0A== dependencies: "@ethersproject/address" "^5.0.8" "@ethersproject/bignumber" "^5.1.1"