From c6f40368ccb2496ec7786abbc15b63bd6dfeb4b2 Mon Sep 17 00:00:00 2001 From: Lukas Rosario <36800180+lukasrosario@users.noreply.github.com> Date: Fri, 24 Nov 2023 18:22:11 -0500 Subject: [PATCH] l2 tests --- src/hooks/L1/useWriteDepositERC20.test.ts | 1 + src/hooks/L2/useSimulateWithdrawERC20.test.ts | 121 ++++ src/hooks/L2/useSimulateWithdrawETH.test.ts | 122 ++++ src/hooks/L2/useWriteWithdrawERC20.test.ts | 657 +++++++++++++++++ src/hooks/L2/useWriteWithdrawETH.test.ts | 658 ++++++++++++++++++ 5 files changed, 1559 insertions(+) create mode 100644 src/hooks/L2/useSimulateWithdrawERC20.test.ts create mode 100644 src/hooks/L2/useSimulateWithdrawETH.test.ts create mode 100644 src/hooks/L2/useWriteWithdrawERC20.test.ts create mode 100644 src/hooks/L2/useWriteWithdrawETH.test.ts diff --git a/src/hooks/L1/useWriteDepositERC20.test.ts b/src/hooks/L1/useWriteDepositERC20.test.ts index 367f812..4202d9b 100644 --- a/src/hooks/L1/useWriteDepositERC20.test.ts +++ b/src/hooks/L1/useWriteDepositERC20.test.ts @@ -775,6 +775,7 @@ test('useWriteDepositERC20', async () => { "type": "receive", }, ], + "account": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "address": "0x3154Cf16ccdb4C6d922629664174b904d80F2C35", "args": [ "0xbe9895146f7af43049ca1c1ae358b0541ea49704", diff --git a/src/hooks/L2/useSimulateWithdrawERC20.test.ts b/src/hooks/L2/useSimulateWithdrawERC20.test.ts new file mode 100644 index 0000000..b472c3f --- /dev/null +++ b/src/hooks/L2/useSimulateWithdrawERC20.test.ts @@ -0,0 +1,121 @@ +import { expect, test } from 'vitest' +import { accounts } from '../../_test/constants.js' +import { renderHook, waitFor } from '../../_test/react.js' +import { useSimulateWithdrawERC20 } from './useSimulateWithdrawERC20.js' + +test('useSimulateWithdrawERC20', async () => { + const { result } = renderHook(() => + useSimulateWithdrawERC20({ + args: { + l2Token: '0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22', + to: accounts[0], + amount: 0n, + }, + chainId: 8453, + dataSuffix: '0x1234', + }) + ) + + await waitFor(() => expect(result.current.isSuccess).toBeTruthy()) + + expect(result.current).toMatchInlineSnapshot(` + { + "data": { + "request": { + "__mode": "prepared", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_l2Token", + "type": "address", + }, + { + "internalType": "address", + "name": "_to", + "type": "address", + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256", + }, + { + "internalType": "uint32", + "name": "_minGasLimit", + "type": "uint32", + }, + { + "internalType": "bytes", + "name": "_extraData", + "type": "bytes", + }, + ], + "name": "withdrawTo", + "outputs": [], + "stateMutability": "payable", + "type": "function", + }, + ], + "account": { + "address": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "type": "json-rpc", + }, + "address": "0x4200000000000000000000000000000000000010", + "args": [ + "0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22", + "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + 0n, + 0, + "0x", + ], + "chainId": 8453, + "dataSuffix": "0x1234", + "functionName": "withdrawTo", + }, + "result": undefined, + }, + "dataUpdatedAt": 1700438400000, + "error": null, + "errorUpdateCount": 0, + "errorUpdatedAt": 0, + "failureCount": 0, + "failureReason": null, + "fetchStatus": "idle", + "isError": false, + "isFetched": true, + "isFetchedAfterMount": true, + "isFetching": false, + "isInitialLoading": false, + "isLoading": false, + "isLoadingError": false, + "isPaused": false, + "isPending": false, + "isPlaceholderData": false, + "isRefetchError": false, + "isRefetching": false, + "isStale": true, + "isSuccess": true, + "queryKey": [ + "simulateContract", + { + "account": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "address": "0x4200000000000000000000000000000000000010", + "args": [ + "0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22", + "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + 0n, + 0, + "0x", + ], + "chainId": 8453, + "dataSuffix": "0x1234", + "functionName": "withdrawTo", + }, + ], + "refetch": [Function], + "status": "success", + } + `) +}, { retry: 3 }) diff --git a/src/hooks/L2/useSimulateWithdrawETH.test.ts b/src/hooks/L2/useSimulateWithdrawETH.test.ts new file mode 100644 index 0000000..af1cda6 --- /dev/null +++ b/src/hooks/L2/useSimulateWithdrawETH.test.ts @@ -0,0 +1,122 @@ +import { expect, test } from 'vitest' +import { accounts } from '../../_test/constants.js' +import { renderHook, waitFor } from '../../_test/react.js' +import { useSimulateWithdrawETH } from './useSimulateWithdrawETH.js' + +test('useSimulateWithdrawETH', async () => { + const { result } = renderHook(() => + useSimulateWithdrawETH({ + args: { + to: accounts[0], + amount: 1n, + }, + chainId: 8453, + dataSuffix: '0x1234', + }) + ) + + await waitFor(() => expect(result.current.isSuccess).toBeTruthy()) + + expect(result.current).toMatchInlineSnapshot(` + { + "data": { + "request": { + "__mode": "prepared", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_l2Token", + "type": "address", + }, + { + "internalType": "address", + "name": "_to", + "type": "address", + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256", + }, + { + "internalType": "uint32", + "name": "_minGasLimit", + "type": "uint32", + }, + { + "internalType": "bytes", + "name": "_extraData", + "type": "bytes", + }, + ], + "name": "withdrawTo", + "outputs": [], + "stateMutability": "payable", + "type": "function", + }, + ], + "account": { + "address": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "type": "json-rpc", + }, + "address": "0x4200000000000000000000000000000000000010", + "args": [ + "0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000", + "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + 1n, + 0, + "0x", + ], + "chainId": 8453, + "dataSuffix": "0x1234", + "functionName": "withdrawTo", + "value": 1n, + }, + "result": undefined, + }, + "dataUpdatedAt": 1700438400000, + "error": null, + "errorUpdateCount": 0, + "errorUpdatedAt": 0, + "failureCount": 0, + "failureReason": null, + "fetchStatus": "idle", + "isError": false, + "isFetched": true, + "isFetchedAfterMount": true, + "isFetching": false, + "isInitialLoading": false, + "isLoading": false, + "isLoadingError": false, + "isPaused": false, + "isPending": false, + "isPlaceholderData": false, + "isRefetchError": false, + "isRefetching": false, + "isStale": true, + "isSuccess": true, + "queryKey": [ + "simulateContract", + { + "account": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "address": "0x4200000000000000000000000000000000000010", + "args": [ + "0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000", + "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + 1n, + 0, + "0x", + ], + "chainId": 8453, + "dataSuffix": "0x1234", + "functionName": "withdrawTo", + "value": 1n, + }, + ], + "refetch": [Function], + "status": "success", + } + `) +}) diff --git a/src/hooks/L2/useWriteWithdrawERC20.test.ts b/src/hooks/L2/useWriteWithdrawERC20.test.ts new file mode 100644 index 0000000..afce93b --- /dev/null +++ b/src/hooks/L2/useWriteWithdrawERC20.test.ts @@ -0,0 +1,657 @@ +import { expect, test } from 'vitest' +import { useSwitchChain } from 'wagmi' +import { accounts } from '../../_test/constants.js' +import { renderHook, waitFor } from '../../_test/react.js' +import { useWriteWithdrawERC20 } from './useWriteWithdrawERC20.js' + +test('useWriteWithdrawERC20', async () => { + const { result } = renderHook(() => ({ + useWriteWithdrawERC20: useWriteWithdrawERC20(), + useSwitchChain: useSwitchChain(), + })) + + // Mocked account is connected to L1 by default, so switch to L2 first. + await result.current.useSwitchChain.switchChainAsync({ chainId: 8453 }) + + expect(result.current.useWriteWithdrawERC20.writeWithdrawERC20).toBeDefined() + expect(result.current.useWriteWithdrawERC20.writeWithdrawERC20).toBeDefined() + expect(result.current.useWriteWithdrawERC20.data).toBeUndefined() + expect(result.current.useWriteWithdrawERC20.isIdle).toBe(true) + + result.current.useWriteWithdrawERC20.writeWithdrawERC20({ + args: { + to: accounts[0], + l2Token: '0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22', + amount: 0n, + }, + chainId: 8453, + }) + + await waitFor(() => { + expect(result.current.useWriteWithdrawERC20.error).toBeNull() + expect(result.current.useWriteWithdrawERC20.isSuccess).toBeTruthy() + }) + + expect(result.current.useWriteWithdrawERC20).toMatchInlineSnapshot(` + { + "context": undefined, + "data": "${result.current.useWriteWithdrawERC20.data}", + "error": null, + "failureCount": 0, + "failureReason": null, + "isError": false, + "isIdle": false, + "isPaused": false, + "isPending": false, + "isSuccess": true, + "reset": [Function], + "status": "success", + "submittedAt": 1700438400000, + "variables": { + "abi": [ + { + "inputs": [ + { + "internalType": "address payable", + "name": "_otherBridge", + "type": "address", + }, + ], + "stateMutability": "nonpayable", + "type": "constructor", + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "l1Token", + "type": "address", + }, + { + "indexed": true, + "internalType": "address", + "name": "l2Token", + "type": "address", + }, + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address", + }, + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address", + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + { + "indexed": false, + "internalType": "bytes", + "name": "extraData", + "type": "bytes", + }, + ], + "name": "DepositFinalized", + "type": "event", + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "localToken", + "type": "address", + }, + { + "indexed": true, + "internalType": "address", + "name": "remoteToken", + "type": "address", + }, + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address", + }, + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address", + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + { + "indexed": false, + "internalType": "bytes", + "name": "extraData", + "type": "bytes", + }, + ], + "name": "ERC20BridgeFinalized", + "type": "event", + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "localToken", + "type": "address", + }, + { + "indexed": true, + "internalType": "address", + "name": "remoteToken", + "type": "address", + }, + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address", + }, + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address", + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + { + "indexed": false, + "internalType": "bytes", + "name": "extraData", + "type": "bytes", + }, + ], + "name": "ERC20BridgeInitiated", + "type": "event", + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address", + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address", + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + { + "indexed": false, + "internalType": "bytes", + "name": "extraData", + "type": "bytes", + }, + ], + "name": "ETHBridgeFinalized", + "type": "event", + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address", + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address", + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + { + "indexed": false, + "internalType": "bytes", + "name": "extraData", + "type": "bytes", + }, + ], + "name": "ETHBridgeInitiated", + "type": "event", + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "l1Token", + "type": "address", + }, + { + "indexed": true, + "internalType": "address", + "name": "l2Token", + "type": "address", + }, + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address", + }, + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address", + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + { + "indexed": false, + "internalType": "bytes", + "name": "extraData", + "type": "bytes", + }, + ], + "name": "WithdrawalInitiated", + "type": "event", + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_localToken", + "type": "address", + }, + { + "internalType": "address", + "name": "_remoteToken", + "type": "address", + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256", + }, + { + "internalType": "uint32", + "name": "_minGasLimit", + "type": "uint32", + }, + { + "internalType": "bytes", + "name": "_extraData", + "type": "bytes", + }, + ], + "name": "bridgeERC20", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_localToken", + "type": "address", + }, + { + "internalType": "address", + "name": "_remoteToken", + "type": "address", + }, + { + "internalType": "address", + "name": "_to", + "type": "address", + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256", + }, + { + "internalType": "uint32", + "name": "_minGasLimit", + "type": "uint32", + }, + { + "internalType": "bytes", + "name": "_extraData", + "type": "bytes", + }, + ], + "name": "bridgeERC20To", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "_minGasLimit", + "type": "uint32", + }, + { + "internalType": "bytes", + "name": "_extraData", + "type": "bytes", + }, + ], + "name": "bridgeETH", + "outputs": [], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_to", + "type": "address", + }, + { + "internalType": "uint32", + "name": "_minGasLimit", + "type": "uint32", + }, + { + "internalType": "bytes", + "name": "_extraData", + "type": "bytes", + }, + ], + "name": "bridgeETHTo", + "outputs": [], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address", + }, + { + "internalType": "address", + "name": "", + "type": "address", + }, + ], + "name": "deposits", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256", + }, + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_localToken", + "type": "address", + }, + { + "internalType": "address", + "name": "_remoteToken", + "type": "address", + }, + { + "internalType": "address", + "name": "_from", + "type": "address", + }, + { + "internalType": "address", + "name": "_to", + "type": "address", + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256", + }, + { + "internalType": "bytes", + "name": "_extraData", + "type": "bytes", + }, + ], + "name": "finalizeBridgeERC20", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_from", + "type": "address", + }, + { + "internalType": "address", + "name": "_to", + "type": "address", + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256", + }, + { + "internalType": "bytes", + "name": "_extraData", + "type": "bytes", + }, + ], + "name": "finalizeBridgeETH", + "outputs": [], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_l1Token", + "type": "address", + }, + { + "internalType": "address", + "name": "_l2Token", + "type": "address", + }, + { + "internalType": "address", + "name": "_from", + "type": "address", + }, + { + "internalType": "address", + "name": "_to", + "type": "address", + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256", + }, + { + "internalType": "bytes", + "name": "_extraData", + "type": "bytes", + }, + ], + "name": "finalizeDeposit", + "outputs": [], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [], + "name": "l1TokenBridge", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address", + }, + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "messenger", + "outputs": [ + { + "internalType": "contract CrossDomainMessenger", + "name": "", + "type": "address", + }, + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string", + }, + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_l2Token", + "type": "address", + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256", + }, + { + "internalType": "uint32", + "name": "_minGasLimit", + "type": "uint32", + }, + { + "internalType": "bytes", + "name": "_extraData", + "type": "bytes", + }, + ], + "name": "withdraw", + "outputs": [], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_l2Token", + "type": "address", + }, + { + "internalType": "address", + "name": "_to", + "type": "address", + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256", + }, + { + "internalType": "uint32", + "name": "_minGasLimit", + "type": "uint32", + }, + { + "internalType": "bytes", + "name": "_extraData", + "type": "bytes", + }, + ], + "name": "withdrawTo", + "outputs": [], + "stateMutability": "payable", + "type": "function", + }, + { + "stateMutability": "payable", + "type": "receive", + }, + ], + "address": "0x4200000000000000000000000000000000000010", + "args": [ + "0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22", + "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + 0n, + 0, + "0x", + ], + "chainId": 8453, + "functionName": "withdrawTo", + }, + "writeWithdrawERC20": [Function], + "writeWithdrawERC20Async": [Function], + } + `) +}, { retry: 3 }) diff --git a/src/hooks/L2/useWriteWithdrawETH.test.ts b/src/hooks/L2/useWriteWithdrawETH.test.ts new file mode 100644 index 0000000..8807d50 --- /dev/null +++ b/src/hooks/L2/useWriteWithdrawETH.test.ts @@ -0,0 +1,658 @@ +import { expect, test } from 'vitest' +import { useSwitchChain } from 'wagmi' +import { accounts } from '../../_test/constants.js' +import { renderHook, waitFor } from '../../_test/react.js' +import { useWriteWithdrawETH } from './useWriteWithdrawETH.js' + +test('useWriteWithdrawETH', async () => { + const { result } = renderHook(() => ({ + useWriteWithdrawETH: useWriteWithdrawETH(), + useSwitchChain: useSwitchChain(), + })) + + // Mocked account is connected to L1 by default, so switch to L2 first. + await result.current.useSwitchChain.switchChainAsync({ chainId: 8453 }) + + expect(result.current.useWriteWithdrawETH.writeWithdrawETH).toBeDefined() + expect(result.current.useWriteWithdrawETH.writeWithdrawETH).toBeDefined() + expect(result.current.useWriteWithdrawETH.data).toBeUndefined() + expect(result.current.useWriteWithdrawETH.isIdle).toBe(true) + + result.current.useWriteWithdrawETH.writeWithdrawETH({ + args: { + to: accounts[0], + amount: 0n, + }, + chainId: 8453, + }) + + await waitFor(() => { + expect(result.current.useWriteWithdrawETH.error).toBeNull() + expect(result.current.useWriteWithdrawETH.isSuccess).toBeTruthy() + }) + + expect(result.current.useWriteWithdrawETH).toMatchInlineSnapshot(` + { + "context": undefined, + "data": "${result.current.useWriteWithdrawETH.data}", + "error": null, + "failureCount": 0, + "failureReason": null, + "isError": false, + "isIdle": false, + "isPaused": false, + "isPending": false, + "isSuccess": true, + "reset": [Function], + "status": "success", + "submittedAt": 1700438400000, + "variables": { + "abi": [ + { + "inputs": [ + { + "internalType": "address payable", + "name": "_otherBridge", + "type": "address", + }, + ], + "stateMutability": "nonpayable", + "type": "constructor", + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "l1Token", + "type": "address", + }, + { + "indexed": true, + "internalType": "address", + "name": "l2Token", + "type": "address", + }, + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address", + }, + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address", + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + { + "indexed": false, + "internalType": "bytes", + "name": "extraData", + "type": "bytes", + }, + ], + "name": "DepositFinalized", + "type": "event", + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "localToken", + "type": "address", + }, + { + "indexed": true, + "internalType": "address", + "name": "remoteToken", + "type": "address", + }, + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address", + }, + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address", + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + { + "indexed": false, + "internalType": "bytes", + "name": "extraData", + "type": "bytes", + }, + ], + "name": "ERC20BridgeFinalized", + "type": "event", + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "localToken", + "type": "address", + }, + { + "indexed": true, + "internalType": "address", + "name": "remoteToken", + "type": "address", + }, + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address", + }, + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address", + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + { + "indexed": false, + "internalType": "bytes", + "name": "extraData", + "type": "bytes", + }, + ], + "name": "ERC20BridgeInitiated", + "type": "event", + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address", + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address", + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + { + "indexed": false, + "internalType": "bytes", + "name": "extraData", + "type": "bytes", + }, + ], + "name": "ETHBridgeFinalized", + "type": "event", + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address", + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address", + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + { + "indexed": false, + "internalType": "bytes", + "name": "extraData", + "type": "bytes", + }, + ], + "name": "ETHBridgeInitiated", + "type": "event", + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "l1Token", + "type": "address", + }, + { + "indexed": true, + "internalType": "address", + "name": "l2Token", + "type": "address", + }, + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address", + }, + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address", + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256", + }, + { + "indexed": false, + "internalType": "bytes", + "name": "extraData", + "type": "bytes", + }, + ], + "name": "WithdrawalInitiated", + "type": "event", + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_localToken", + "type": "address", + }, + { + "internalType": "address", + "name": "_remoteToken", + "type": "address", + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256", + }, + { + "internalType": "uint32", + "name": "_minGasLimit", + "type": "uint32", + }, + { + "internalType": "bytes", + "name": "_extraData", + "type": "bytes", + }, + ], + "name": "bridgeERC20", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_localToken", + "type": "address", + }, + { + "internalType": "address", + "name": "_remoteToken", + "type": "address", + }, + { + "internalType": "address", + "name": "_to", + "type": "address", + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256", + }, + { + "internalType": "uint32", + "name": "_minGasLimit", + "type": "uint32", + }, + { + "internalType": "bytes", + "name": "_extraData", + "type": "bytes", + }, + ], + "name": "bridgeERC20To", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "_minGasLimit", + "type": "uint32", + }, + { + "internalType": "bytes", + "name": "_extraData", + "type": "bytes", + }, + ], + "name": "bridgeETH", + "outputs": [], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_to", + "type": "address", + }, + { + "internalType": "uint32", + "name": "_minGasLimit", + "type": "uint32", + }, + { + "internalType": "bytes", + "name": "_extraData", + "type": "bytes", + }, + ], + "name": "bridgeETHTo", + "outputs": [], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address", + }, + { + "internalType": "address", + "name": "", + "type": "address", + }, + ], + "name": "deposits", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256", + }, + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_localToken", + "type": "address", + }, + { + "internalType": "address", + "name": "_remoteToken", + "type": "address", + }, + { + "internalType": "address", + "name": "_from", + "type": "address", + }, + { + "internalType": "address", + "name": "_to", + "type": "address", + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256", + }, + { + "internalType": "bytes", + "name": "_extraData", + "type": "bytes", + }, + ], + "name": "finalizeBridgeERC20", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_from", + "type": "address", + }, + { + "internalType": "address", + "name": "_to", + "type": "address", + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256", + }, + { + "internalType": "bytes", + "name": "_extraData", + "type": "bytes", + }, + ], + "name": "finalizeBridgeETH", + "outputs": [], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_l1Token", + "type": "address", + }, + { + "internalType": "address", + "name": "_l2Token", + "type": "address", + }, + { + "internalType": "address", + "name": "_from", + "type": "address", + }, + { + "internalType": "address", + "name": "_to", + "type": "address", + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256", + }, + { + "internalType": "bytes", + "name": "_extraData", + "type": "bytes", + }, + ], + "name": "finalizeDeposit", + "outputs": [], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [], + "name": "l1TokenBridge", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address", + }, + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "messenger", + "outputs": [ + { + "internalType": "contract CrossDomainMessenger", + "name": "", + "type": "address", + }, + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string", + }, + ], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_l2Token", + "type": "address", + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256", + }, + { + "internalType": "uint32", + "name": "_minGasLimit", + "type": "uint32", + }, + { + "internalType": "bytes", + "name": "_extraData", + "type": "bytes", + }, + ], + "name": "withdraw", + "outputs": [], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_l2Token", + "type": "address", + }, + { + "internalType": "address", + "name": "_to", + "type": "address", + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256", + }, + { + "internalType": "uint32", + "name": "_minGasLimit", + "type": "uint32", + }, + { + "internalType": "bytes", + "name": "_extraData", + "type": "bytes", + }, + ], + "name": "withdrawTo", + "outputs": [], + "stateMutability": "payable", + "type": "function", + }, + { + "stateMutability": "payable", + "type": "receive", + }, + ], + "account": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "address": "0x4200000000000000000000000000000000000010", + "args": [ + "0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000", + "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + 0n, + 0, + "0x", + ], + "chainId": 8453, + "functionName": "withdrawTo", + "value": 0n, + }, + "writeWithdrawETH": [Function], + "writeWithdrawETHAsync": [Function], + } + `) +}, { retry: 3 })