From 8c26fad663f74fa992505e6ed9dfbefca8b02f82 Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 3 Oct 2024 14:00:51 +0200 Subject: [PATCH 01/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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/77] 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 9200dbec4b429cf07a6a52b28f0d2e31933de579 Mon Sep 17 00:00:00 2001 From: Bartek Date: Thu, 17 Oct 2024 15:38:18 +0200 Subject: [PATCH 65/77] 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 801021246e311a50b28b713aa269430ac8baf384 Mon Sep 17 00:00:00 2001 From: Bartek Date: Fri, 18 Oct 2024 14:52:10 +0200 Subject: [PATCH 66/77] 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 67/77] 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 68/77] 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 69/77] 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 70/77] 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 71/77] 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 72/77] 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 73/77] 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 74/77] 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 75/77] 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 76/77] 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 77/77] 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