From bf234e3e40fa86a577b30b63d7a2e4a93544603b Mon Sep 17 00:00:00 2001 From: danijelTxFusion Date: Sun, 7 Jan 2024 11:22:38 +0100 Subject: [PATCH] feat: provide support for Bridgehub --- .github/workflows/test.yml | 8 +- abi/IBridgehub.json | 631 ++ abi/IContractDeployer.json | 114 +- abi/IL1Bridge.json | 291 +- abi/IL1ERC20Bridge.json | 377 ++ abi/IL1SharedBridge.json | 692 +++ abi/ITestnetERC20Token.json | 39 + abi/IZkSyncStateTransition.json | 2403 +++++++ scripts/entrypoint.sh | 12 +- src/adapters.ts | 1421 +++-- src/provider.ts | 260 +- src/signer.ts | 338 +- src/typechain/IBridgehub.d.ts | 1737 ++++++ src/typechain/IBridgehubFactory.ts | 649 ++ src/typechain/IContractDeployer.d.ts | 348 +- src/typechain/IContractDeployerFactory.ts | 114 +- src/typechain/ITestnetErc20Token.d.ts | 143 + src/typechain/ITestnetErc20TokenFactory.ts | 57 + src/typechain/IZkSyncStateTransition.d.ts | 5495 +++++++++++++++++ .../IZkSyncStateTransitionFactory.ts | 2425 ++++++++ src/typechain/Il1Bridge.d.ts | 641 +- src/typechain/Il1BridgeFactory.ts | 291 +- src/typechain/Il1Erc20Bridge.d.ts | 784 +++ src/typechain/Il1Erc20BridgeFactory.ts | 395 ++ src/typechain/Il1SharedBridge.d.ts | 1469 +++++ src/typechain/Il1SharedBridgeFactory.ts | 710 +++ src/utils.ts | 119 +- src/wallet.ts | 349 +- tests/custom-matchers.ts | 50 + tests/integration/account-abstraction.test.ts | 26 +- tests/integration/contract.test.ts | 9 +- tests/integration/paymaster.test.ts | 120 - tests/integration/provider.test.ts | 270 +- tests/integration/signer.test.ts | 918 ++- tests/integration/smart-account.test.ts | 198 +- tests/integration/utils.test.ts | 88 +- tests/integration/wallet.test.ts | 1294 ++-- tests/setup.ts | 91 +- tests/unit/signer.test.ts | 20 +- tests/unit/smart-account.test.ts | 59 +- tests/unit/util.test.ts | 35 +- tests/utils.ts | 13 + 42 files changed, 23761 insertions(+), 1742 deletions(-) create mode 100644 abi/IBridgehub.json create mode 100644 abi/IL1ERC20Bridge.json create mode 100644 abi/IL1SharedBridge.json create mode 100644 abi/ITestnetERC20Token.json create mode 100644 abi/IZkSyncStateTransition.json create mode 100644 src/typechain/IBridgehub.d.ts create mode 100644 src/typechain/IBridgehubFactory.ts create mode 100644 src/typechain/ITestnetErc20Token.d.ts create mode 100644 src/typechain/ITestnetErc20TokenFactory.ts create mode 100644 src/typechain/IZkSyncStateTransition.d.ts create mode 100644 src/typechain/IZkSyncStateTransitionFactory.ts create mode 100644 src/typechain/Il1Erc20Bridge.d.ts create mode 100644 src/typechain/Il1Erc20BridgeFactory.ts create mode 100644 src/typechain/Il1SharedBridge.d.ts create mode 100644 src/typechain/Il1SharedBridgeFactory.ts delete mode 100644 tests/integration/paymaster.test.ts create mode 100644 tests/utils.ts diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6b0bcca3..910a6d1d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,10 +1,10 @@ name: Run tests on: push: - branches: [ ethers-v5 ] + branches: [ethers-v5, ethers-v5-beta] workflow_dispatch: pull_request: - branches: [ ethers-v5 ] + branches: [ethers-v5, ethers-v5-beta] types: [ opened, reopened, synchronize ] permissions: @@ -31,10 +31,8 @@ jobs: run: | git clone https://github.com/matter-labs/local-setup.git pushd local-setup - ./start.sh v22-before-shared-bridge + ./start.sh popd - - name: Wait for local-setup to be ready - run: yarn test:wait - name: Prepare environment run: yarn test:prepare - name: Run tests diff --git a/abi/IBridgehub.json b/abi/IBridgehub.json new file mode 100644 index 00000000..22db2fd4 --- /dev/null +++ b/abi/IBridgehub.json @@ -0,0 +1,631 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldAdmin", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "NewAdmin", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "stateTransitionManager", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "chainGovernance", + "type": "address" + } + ], + "name": "NewChain", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldPendingAdmin", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newPendingAdmin", + "type": "address" + } + ], + "name": "NewPendingAdmin", + "type": "event" + }, + { + "inputs": [], + "name": "acceptAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_stateTransitionManager", + "type": "address" + } + ], + "name": "addStateTransitionManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + } + ], + "name": "addToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + } + ], + "name": "baseToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_stateTransitionManager", + "type": "address" + }, + { + "internalType": "address", + "name": "_baseToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_salt", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_admin", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_initData", + "type": "bytes" + } + ], + "name": "createNewChain", + "outputs": [ + { + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + } + ], + "name": "getStateTransition", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_gasPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2GasLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2GasPerPubdataByteLimit", + "type": "uint256" + } + ], + "name": "l2TransactionBaseCost", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "_l2TxHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_l2BatchNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2MessageIndex", + "type": "uint256" + }, + { + "internalType": "uint16", + "name": "_l2TxNumberInBatch", + "type": "uint16" + }, + { + "internalType": "bytes32[]", + "name": "_merkleProof", + "type": "bytes32[]" + }, + { + "internalType": "enum TxStatus", + "name": "_status", + "type": "uint8" + } + ], + "name": "proveL1ToL2TransactionStatus", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_batchNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_index", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint8", + "name": "l2ShardId", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "isService", + "type": "bool" + }, + { + "internalType": "uint16", + "name": "txNumberInBatch", + "type": "uint16" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "value", + "type": "bytes32" + } + ], + "internalType": "struct L2Log", + "name": "_log", + "type": "tuple" + }, + { + "internalType": "bytes32[]", + "name": "_proof", + "type": "bytes32[]" + } + ], + "name": "proveL2LogInclusion", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_batchNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_index", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint16", + "name": "txNumberInBatch", + "type": "uint16" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct L2Message", + "name": "_message", + "type": "tuple" + }, + { + "internalType": "bytes32[]", + "name": "_proof", + "type": "bytes32[]" + } + ], + "name": "proveL2MessageInclusion", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_stateTransitionManager", + "type": "address" + } + ], + "name": "removeStateTransitionManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "mintValue", + "type": "uint256" + }, + { + "internalType": "address", + "name": "l2Contract", + "type": "address" + }, + { + "internalType": "uint256", + "name": "l2Value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "l2Calldata", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "l2GasLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "l2GasPerPubdataByteLimit", + "type": "uint256" + }, + { + "internalType": "bytes[]", + "name": "factoryDeps", + "type": "bytes[]" + }, + { + "internalType": "address", + "name": "refundRecipient", + "type": "address" + } + ], + "internalType": "struct L2TransactionRequestDirect", + "name": "_request", + "type": "tuple" + } + ], + "name": "requestL2TransactionDirect", + "outputs": [ + { + "internalType": "bytes32", + "name": "canonicalTxHash", + "type": "bytes32" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "mintValue", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "l2Value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "l2GasLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "l2GasPerPubdataByteLimit", + "type": "uint256" + }, + { + "internalType": "address", + "name": "refundRecipient", + "type": "address" + }, + { + "internalType": "address", + "name": "secondBridgeAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "secondBridgeValue", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "secondBridgeCalldata", + "type": "bytes" + } + ], + "internalType": "struct L2TransactionRequestTwoBridgesOuter", + "name": "_request", + "type": "tuple" + } + ], + "name": "requestL2TransactionTwoBridges", + "outputs": [ + { + "internalType": "bytes32", + "name": "canonicalTxHash", + "type": "bytes32" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_newPendingAdmin", + "type": "address" + } + ], + "name": "setPendingAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_sharedBridge", + "type": "address" + } + ], + "name": "setSharedBridge", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "sharedBridge", + "outputs": [ + { + "internalType": "contract IL1SharedBridge", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + } + ], + "name": "stateTransitionManager", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_stateTransitionManager", + "type": "address" + } + ], + "name": "stateTransitionManagerIsRegistered", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_baseToken", + "type": "address" + } + ], + "name": "tokenIsRegistered", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/abi/IContractDeployer.json b/abi/IContractDeployer.json index 8f54565c..2525a786 100644 --- a/abi/IContractDeployer.json +++ b/abi/IContractDeployer.json @@ -84,7 +84,7 @@ "outputs": [ { "internalType": "address", - "name": "newAddress", + "name": "", "type": "address" } ], @@ -113,7 +113,7 @@ "outputs": [ { "internalType": "address", - "name": "newAddress", + "name": "", "type": "address" } ], @@ -147,7 +147,7 @@ "outputs": [ { "internalType": "address", - "name": "newAddress", + "name": "", "type": "address" } ], @@ -158,7 +158,7 @@ "inputs": [ { "internalType": "bytes32", - "name": "_salt", + "name": "", "type": "bytes32" }, { @@ -181,10 +181,114 @@ "outputs": [ { "internalType": "address", - "name": "newAddress", + "name": "", + "type": "address" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "extendedAccountVersion", + "outputs": [ + { + "internalType": "enum IContractDeployer.AccountAbstractionVersion", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "bytecodeHash", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "newAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "callConstructor", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "input", + "type": "bytes" + } + ], + "internalType": "struct ContractDeployer.ForceDeployment", + "name": "_deployment", + "type": "tuple" + }, + { + "internalType": "address", + "name": "_sender", "type": "address" } ], + "name": "forceDeployOnAddress", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "bytecodeHash", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "newAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "callConstructor", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "input", + "type": "bytes" + } + ], + "internalType": "struct ContractDeployer.ForceDeployment[]", + "name": "_deployments", + "type": "tuple[]" + } + ], + "name": "forceDeployOnAddresses", + "outputs": [], "stateMutability": "payable", "type": "function" }, diff --git a/abi/IL1Bridge.json b/abi/IL1Bridge.json index 36bc6b52..7069b2de 100644 --- a/abi/IL1Bridge.json +++ b/abi/IL1Bridge.json @@ -2,6 +2,80 @@ { "anonymous": false, "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "txDataHash", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "l2DepositTxHash", + "type": "bytes32" + } + ], + "name": "BridgehubDepositFinalized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "txDataHash", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "l1Token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "BridgehubDepositInitiatedSharedBridge", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, { "indexed": true, "internalType": "address", @@ -21,12 +95,18 @@ "type": "uint256" } ], - "name": "ClaimedFailedDeposit", + "name": "ClaimedFailedDepositSharedBridge", "type": "event" }, { "anonymous": false, "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, { "indexed": true, "internalType": "bytes32", @@ -40,7 +120,7 @@ "type": "address" }, { - "indexed": true, + "indexed": false, "internalType": "address", "name": "to", "type": "address" @@ -58,12 +138,18 @@ "type": "uint256" } ], - "name": "DepositInitiated", + "name": "DepositInitiatedSharedBridge", "type": "event" }, { "anonymous": false, "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, { "indexed": true, "internalType": "address", @@ -83,11 +169,136 @@ "type": "uint256" } ], - "name": "WithdrawalFinalized", + "name": "WithdrawalFinalizedSharedBridge", "type": "event" }, + { + "inputs": [], + "name": "bridgehub", + "outputs": [ + { + "internalType": "contract IBridgehub", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "_txDataHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_txHash", + "type": "bytes32" + } + ], + "name": "bridgehubConfirmL2Transaction", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_prevMsgSender", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "bridgehubDeposit", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "magicValue", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "l2Contract", + "type": "address" + }, + { + "internalType": "bytes", + "name": "l2Calldata", + "type": "bytes" + }, + { + "internalType": "bytes[]", + "name": "factoryDeps", + "type": "bytes[]" + }, + { + "internalType": "bytes32", + "name": "txDataHash", + "type": "bytes32" + } + ], + "internalType": "struct L2TransactionRequestTwoBridgesInner", + "name": "request", + "type": "tuple" + } + ], + "stateMutability": "payable", + "type": "function" + }, { "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_prevMsgSender", + "type": "address" + }, + { + "internalType": "address", + "name": "_l1Token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "bridgehubDepositBaseToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, { "internalType": "address", "name": "_depositSender", @@ -98,6 +309,11 @@ "name": "_l1Token", "type": "address" }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, { "internalType": "bytes32", "name": "_l2TxHash", @@ -131,6 +347,11 @@ }, { "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, { "internalType": "address", "name": "_l2Receiver", @@ -141,6 +362,11 @@ "name": "_l1Token", "type": "address" }, + { + "internalType": "uint256", + "name": "_mintValue", + "type": "uint256" + }, { "internalType": "uint256", "name": "_amount", @@ -175,6 +401,35 @@ }, { "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "_l2TxHash", + "type": "bytes32" + } + ], + "name": "depositHappened", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, { "internalType": "uint256", "name": "_l2BatchNumber", @@ -208,6 +463,11 @@ }, { "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, { "internalType": "uint256", "name": "_l2BatchNumber", @@ -219,7 +479,7 @@ "type": "uint256" } ], - "name": "isWithdrawalFinalized", + "name": "isWithdrawalFinalizedShared", "outputs": [ { "internalType": "bool", @@ -230,28 +490,15 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [], - "name": "l2Bridge", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [ { - "internalType": "address", - "name": "_l1Token", - "type": "address" + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" } ], - "name": "l2TokenAddress", + "name": "l2BridgeAddress", "outputs": [ { "internalType": "address", diff --git a/abi/IL1ERC20Bridge.json b/abi/IL1ERC20Bridge.json new file mode 100644 index 00000000..bdade3c8 --- /dev/null +++ b/abi/IL1ERC20Bridge.json @@ -0,0 +1,377 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "l1Token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "ClaimedFailedDeposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "l2DepositTxHash", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "l1Token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "DepositInitiated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "l1Token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "WithdrawalFinalized", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_depositSender", + "type": "address" + }, + { + "internalType": "address", + "name": "_l1Token", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "_l2TxHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_l2BatchNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2MessageIndex", + "type": "uint256" + }, + { + "internalType": "uint16", + "name": "_l2TxNumberInBatch", + "type": "uint16" + }, + { + "internalType": "bytes32[]", + "name": "_merkleProof", + "type": "bytes32[]" + } + ], + "name": "claimFailedDeposit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_l2Receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "_l1Token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2TxGasLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2TxGasPerPubdataByte", + "type": "uint256" + } + ], + "name": "deposit", + "outputs": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_l2Receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "_l1Token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2TxGasLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2TxGasPerPubdataByte", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_refundRecipient", + "type": "address" + } + ], + "name": "deposit", + "outputs": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "address", + "name": "_l1Token", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "_depositL2TxHash", + "type": "bytes32" + } + ], + "name": "depositAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_l2BatchNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2MessageIndex", + "type": "uint256" + }, + { + "internalType": "uint16", + "name": "_l2TxNumberInBatch", + "type": "uint16" + }, + { + "internalType": "bytes", + "name": "_message", + "type": "bytes" + }, + { + "internalType": "bytes32[]", + "name": "_merkleProof", + "type": "bytes32[]" + } + ], + "name": "finalizeWithdrawal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_l2BatchNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2MessageIndex", + "type": "uint256" + } + ], + "name": "isWithdrawalFinalized", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "l2Bridge", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_l1Token", + "type": "address" + } + ], + "name": "l2TokenAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "l2TokenBeacon", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "sharedBridge", + "outputs": [ + { + "internalType": "contract IL1SharedBridge", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "transferTokenToSharedBridge", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/abi/IL1SharedBridge.json b/abi/IL1SharedBridge.json new file mode 100644 index 00000000..a56f86eb --- /dev/null +++ b/abi/IL1SharedBridge.json @@ -0,0 +1,692 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "l1Token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "BridgehubDepositBaseTokenInitiated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "txDataHash", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "l2DepositTxHash", + "type": "bytes32" + } + ], + "name": "BridgehubDepositFinalized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "txDataHash", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "l1Token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "BridgehubDepositInitiated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "l1Token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "ClaimedFailedDepositSharedBridge", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "l2DepositTxHash", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "l1Token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "LegacyDepositInitiated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "l1Token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "WithdrawalFinalizedSharedBridge", + "type": "event" + }, + { + "inputs": [], + "name": "bridgehub", + "outputs": [ + { + "internalType": "contract IBridgehub", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "_txDataHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_txHash", + "type": "bytes32" + } + ], + "name": "bridgehubConfirmL2Transaction", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_prevMsgSender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_l2Value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "bridgehubDeposit", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "magicValue", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "l2Contract", + "type": "address" + }, + { + "internalType": "bytes", + "name": "l2Calldata", + "type": "bytes" + }, + { + "internalType": "bytes[]", + "name": "factoryDeps", + "type": "bytes[]" + }, + { + "internalType": "bytes32", + "name": "txDataHash", + "type": "bytes32" + } + ], + "internalType": "struct L2TransactionRequestTwoBridgesInner", + "name": "request", + "type": "tuple" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_prevMsgSender", + "type": "address" + }, + { + "internalType": "address", + "name": "_l1Token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "bridgehubDepositBaseToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_depositSender", + "type": "address" + }, + { + "internalType": "address", + "name": "_l1Token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "_l2TxHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_l2BatchNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2MessageIndex", + "type": "uint256" + }, + { + "internalType": "uint16", + "name": "_l2TxNumberInBatch", + "type": "uint16" + }, + { + "internalType": "bytes32[]", + "name": "_merkleProof", + "type": "bytes32[]" + } + ], + "name": "claimFailedDeposit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_depositSender", + "type": "address" + }, + { + "internalType": "address", + "name": "_l1Token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "_l2TxHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_l2BatchNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2MessageIndex", + "type": "uint256" + }, + { + "internalType": "uint16", + "name": "_l2TxNumberInBatch", + "type": "uint16" + }, + { + "internalType": "bytes32[]", + "name": "_merkleProof", + "type": "bytes32[]" + } + ], + "name": "claimFailedDepositLegacyErc20Bridge", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "_l2TxHash", + "type": "bytes32" + } + ], + "name": "depositHappened", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_msgSender", + "type": "address" + }, + { + "internalType": "address", + "name": "_l2Receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "_l1Token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2TxGasLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2TxGasPerPubdataByte", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_refundRecipient", + "type": "address" + } + ], + "name": "depositLegacyErc20Bridge", + "outputs": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2BatchNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2MessageIndex", + "type": "uint256" + }, + { + "internalType": "uint16", + "name": "_l2TxNumberInBatch", + "type": "uint16" + }, + { + "internalType": "bytes", + "name": "_message", + "type": "bytes" + }, + { + "internalType": "bytes32[]", + "name": "_merkleProof", + "type": "bytes32[]" + } + ], + "name": "finalizeWithdrawal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_l2BatchNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2MessageIndex", + "type": "uint256" + }, + { + "internalType": "uint16", + "name": "_l2TxNumberInBatch", + "type": "uint16" + }, + { + "internalType": "bytes", + "name": "_message", + "type": "bytes" + }, + { + "internalType": "bytes32[]", + "name": "_merkleProof", + "type": "bytes32[]" + } + ], + "name": "finalizeWithdrawalLegacyErc20Bridge", + "outputs": [ + { + "internalType": "address", + "name": "l1Receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "l1Token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2BatchNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2MessageIndex", + "type": "uint256" + } + ], + "name": "isWithdrawalFinalized", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "l1WethAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + } + ], + "name": "l2BridgeAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "legacyBridge", + "outputs": [ + { + "internalType": "contract IL1ERC20Bridge", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + } + ], + "name": "receiveEth", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_eraFirstPostUpgradeBatch", + "type": "uint256" + } + ], + "name": "setEraFirstPostUpgradeBatch", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/abi/ITestnetERC20Token.json b/abi/ITestnetERC20Token.json new file mode 100644 index 00000000..3c4bbc4e --- /dev/null +++ b/abi/ITestnetERC20Token.json @@ -0,0 +1,39 @@ +[ + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/abi/IZkSyncStateTransition.json b/abi/IZkSyncStateTransition.json new file mode 100644 index 00000000..d7f8622d --- /dev/null +++ b/abi/IZkSyncStateTransition.json @@ -0,0 +1,2403 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "batchNumber", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "batchHash", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "commitment", + "type": "bytes32" + } + ], + "name": "BlockCommit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "batchNumber", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "batchHash", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "commitment", + "type": "bytes32" + } + ], + "name": "BlockExecution", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "totalBatchesCommitted", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalBatchesVerified", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalBatchesExecuted", + "type": "uint256" + } + ], + "name": "BlocksRevert", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "previousLastVerifiedBatch", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "currentLastVerifiedBatch", + "type": "uint256" + } + ], + "name": "BlocksVerification", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "EthWithdrawalFinalized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "address", + "name": "facet", + "type": "address" + }, + { + "internalType": "enum Diamond.Action", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "isFreezable", + "type": "bool" + }, + { + "internalType": "bytes4[]", + "name": "selectors", + "type": "bytes4[]" + } + ], + "internalType": "struct Diamond.FacetCut[]", + "name": "facetCuts", + "type": "tuple[]" + }, + { + "internalType": "address", + "name": "initAddress", + "type": "address" + }, + { + "internalType": "bytes", + "name": "initCalldata", + "type": "bytes" + } + ], + "indexed": false, + "internalType": "struct Diamond.DiamondCutData", + "name": "diamondCut", + "type": "tuple" + } + ], + "name": "ExecuteUpgrade", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "Freeze", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bool", + "name": "isPorterAvailable", + "type": "bool" + } + ], + "name": "IsPorterAvailableStatusUpdate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldAdmin", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "NewAdmin", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint128", + "name": "oldNominator", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "oldDenominator", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "newNominator", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "newDenominator", + "type": "uint128" + } + ], + "name": "NewBaseTokenMultiplier", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "enum PubdataPricingMode", + "name": "pubdataPricingMode", + "type": "uint8" + }, + { + "internalType": "uint32", + "name": "batchOverheadL1Gas", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "maxPubdataPerBatch", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "maxL2GasPerBatch", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "priorityTxMaxPubdata", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "minimalL2GasPrice", + "type": "uint64" + } + ], + "indexed": false, + "internalType": "struct FeeParams", + "name": "oldFeeParams", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "enum PubdataPricingMode", + "name": "pubdataPricingMode", + "type": "uint8" + }, + { + "internalType": "uint32", + "name": "batchOverheadL1Gas", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "maxPubdataPerBatch", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "maxL2GasPerBatch", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "priorityTxMaxPubdata", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "minimalL2GasPrice", + "type": "uint64" + } + ], + "indexed": false, + "internalType": "struct FeeParams", + "name": "newFeeParams", + "type": "tuple" + } + ], + "name": "NewFeeParams", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldPendingAdmin", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newPendingAdmin", + "type": "address" + } + ], + "name": "NewPendingAdmin", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "txId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "expirationTimestamp", + "type": "uint64" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "txType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "from", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "to", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "gasLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "gasPerPubdataByteLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxFeePerGas", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxPriorityFeePerGas", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "paymaster", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256[4]", + "name": "reserved", + "type": "uint256[4]" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + }, + { + "internalType": "uint256[]", + "name": "factoryDeps", + "type": "uint256[]" + }, + { + "internalType": "bytes", + "name": "paymasterInput", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "reservedDynamic", + "type": "bytes" + } + ], + "indexed": false, + "internalType": "struct L2CanonicalTransaction", + "name": "transaction", + "type": "tuple" + }, + { + "indexed": false, + "internalType": "bytes[]", + "name": "factoryDeps", + "type": "bytes[]" + } + ], + "name": "NewPriorityRequest", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldPriorityTxMaxGasLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newPriorityTxMaxGasLimit", + "type": "uint256" + } + ], + "name": "NewPriorityTxMaxGasLimit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldTransactionFilterer", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newTransactionFilterer", + "type": "address" + } + ], + "name": "NewTransactionFilterer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "address", + "name": "facet", + "type": "address" + }, + { + "internalType": "enum Diamond.Action", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "isFreezable", + "type": "bool" + }, + { + "internalType": "bytes4[]", + "name": "selectors", + "type": "bytes4[]" + } + ], + "internalType": "struct Diamond.FacetCut[]", + "name": "facetCuts", + "type": "tuple[]" + }, + { + "internalType": "address", + "name": "initAddress", + "type": "address" + }, + { + "internalType": "bytes", + "name": "initCalldata", + "type": "bytes" + } + ], + "indexed": false, + "internalType": "struct Diamond.DiamondCutData", + "name": "diamondCut", + "type": "tuple" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "proposalId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "proposalSalt", + "type": "bytes32" + } + ], + "name": "ProposeTransparentUpgrade", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "Unfreeze", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "validatorAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isActive", + "type": "bool" + } + ], + "name": "ValidatorStatusUpdate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "enum PubdataPricingMode", + "name": "validiumMode", + "type": "uint8" + } + ], + "name": "ValidiumModeStatusUpdate", + "type": "event" + }, + { + "inputs": [], + "name": "acceptAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "baseTokenGasPriceMultiplierDenominator", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "baseTokenGasPriceMultiplierNominator", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "contractL2", + "type": "address" + }, + { + "internalType": "uint256", + "name": "mintValue", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "l2Value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "l2Calldata", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "l2GasLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "l2GasPerPubdataByteLimit", + "type": "uint256" + }, + { + "internalType": "bytes[]", + "name": "factoryDeps", + "type": "bytes[]" + }, + { + "internalType": "address", + "name": "refundRecipient", + "type": "address" + } + ], + "internalType": "struct BridgehubL2TransactionRequest", + "name": "_request", + "type": "tuple" + } + ], + "name": "bridgehubRequestL2Transaction", + "outputs": [ + { + "internalType": "bytes32", + "name": "canonicalTxHash", + "type": "bytes32" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "enum PubdataPricingMode", + "name": "pubdataPricingMode", + "type": "uint8" + }, + { + "internalType": "uint32", + "name": "batchOverheadL1Gas", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "maxPubdataPerBatch", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "maxL2GasPerBatch", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "priorityTxMaxPubdata", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "minimalL2GasPrice", + "type": "uint64" + } + ], + "internalType": "struct FeeParams", + "name": "_newFeeParams", + "type": "tuple" + } + ], + "name": "changeFeeParams", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint64", + "name": "batchNumber", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "batchHash", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "indexRepeatedStorageChanges", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "numberOfLayer1Txs", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "priorityOperationsHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "l2LogsTreeRoot", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "commitment", + "type": "bytes32" + } + ], + "internalType": "struct IExecutor.StoredBatchInfo", + "name": "_lastCommittedBatchData", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint64", + "name": "batchNumber", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "timestamp", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "indexRepeatedStorageChanges", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "newStateRoot", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "numberOfLayer1Txs", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "priorityOperationsHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "bootloaderHeapInitialContentsHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "eventsQueueStateHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "systemLogs", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "pubdataCommitments", + "type": "bytes" + } + ], + "internalType": "struct IExecutor.CommitBatchInfo[]", + "name": "_newBatchesData", + "type": "tuple[]" + } + ], + "name": "commitBatches", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint64", + "name": "batchNumber", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "batchHash", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "indexRepeatedStorageChanges", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "numberOfLayer1Txs", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "priorityOperationsHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "l2LogsTreeRoot", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "commitment", + "type": "bytes32" + } + ], + "internalType": "struct IExecutor.StoredBatchInfo", + "name": "_lastCommittedBatchData", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint64", + "name": "batchNumber", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "timestamp", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "indexRepeatedStorageChanges", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "newStateRoot", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "numberOfLayer1Txs", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "priorityOperationsHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "bootloaderHeapInitialContentsHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "eventsQueueStateHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "systemLogs", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "pubdataCommitments", + "type": "bytes" + } + ], + "internalType": "struct IExecutor.CommitBatchInfo[]", + "name": "_newBatchesData", + "type": "tuple[]" + } + ], + "name": "commitBatchesSharedBridge", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint64", + "name": "batchNumber", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "batchHash", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "indexRepeatedStorageChanges", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "numberOfLayer1Txs", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "priorityOperationsHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "l2LogsTreeRoot", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "commitment", + "type": "bytes32" + } + ], + "internalType": "struct IExecutor.StoredBatchInfo[]", + "name": "_batchesData", + "type": "tuple[]" + } + ], + "name": "executeBatches", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint64", + "name": "batchNumber", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "batchHash", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "indexRepeatedStorageChanges", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "numberOfLayer1Txs", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "priorityOperationsHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "l2LogsTreeRoot", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "commitment", + "type": "bytes32" + } + ], + "internalType": "struct IExecutor.StoredBatchInfo[]", + "name": "_batchesData", + "type": "tuple[]" + } + ], + "name": "executeBatchesSharedBridge", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "address", + "name": "facet", + "type": "address" + }, + { + "internalType": "enum Diamond.Action", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "isFreezable", + "type": "bool" + }, + { + "internalType": "bytes4[]", + "name": "selectors", + "type": "bytes4[]" + } + ], + "internalType": "struct Diamond.FacetCut[]", + "name": "facetCuts", + "type": "tuple[]" + }, + { + "internalType": "address", + "name": "initAddress", + "type": "address" + }, + { + "internalType": "bytes", + "name": "initCalldata", + "type": "bytes" + } + ], + "internalType": "struct Diamond.DiamondCutData", + "name": "_diamondCut", + "type": "tuple" + } + ], + "name": "executeUpgrade", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_selector", + "type": "bytes4" + } + ], + "name": "facetAddress", + "outputs": [ + { + "internalType": "address", + "name": "facet", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "facetAddresses", + "outputs": [ + { + "internalType": "address[]", + "name": "facets", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_facet", + "type": "address" + } + ], + "name": "facetFunctionSelectors", + "outputs": [ + { + "internalType": "bytes4[]", + "name": "", + "type": "bytes4[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "facets", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "internalType": "bytes4[]", + "name": "selectors", + "type": "bytes4[]" + } + ], + "internalType": "struct IGetters.Facet[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_l2BatchNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2MessageIndex", + "type": "uint256" + }, + { + "internalType": "uint16", + "name": "_l2TxNumberInBatch", + "type": "uint16" + }, + { + "internalType": "bytes", + "name": "_message", + "type": "bytes" + }, + { + "internalType": "bytes32[]", + "name": "_merkleProof", + "type": "bytes32[]" + } + ], + "name": "finalizeEthWithdrawal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "freezeDiamond", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBaseToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBaseTokenBridge", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBridgehub", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getFirstUnprocessedPriorityTx", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getL2BootloaderBytecodeHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getL2DefaultAccountBytecodeHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getL2SystemContractsUpgradeBatchNumber", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getL2SystemContractsUpgradeTxHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getName", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPendingAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPriorityQueueSize", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPriorityTxMaxGasLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getProtocolVersion", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPubdataPricingMode", + "outputs": [ + { + "internalType": "enum PubdataPricingMode", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getStateTransitionManager", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTotalBatchesCommitted", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTotalBatchesExecuted", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTotalBatchesVerified", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTotalPriorityTxs", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVerifier", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVerifierParams", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "recursionNodeLevelVkHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "recursionLeafLevelVkHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "recursionCircuitsSetVksHash", + "type": "bytes32" + } + ], + "internalType": "struct VerifierParams", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isDiamondStorageFrozen", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_l2BatchNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2MessageIndex", + "type": "uint256" + } + ], + "name": "isEthWithdrawalFinalized", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_facet", + "type": "address" + } + ], + "name": "isFacetFreezable", + "outputs": [ + { + "internalType": "bool", + "name": "isFreezable", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_selector", + "type": "bytes4" + } + ], + "name": "isFunctionFreezable", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "isValidator", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_batchNumber", + "type": "uint256" + } + ], + "name": "l2LogsRootHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "merkleRoot", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_gasPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2GasLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2GasPerPubdataByteLimit", + "type": "uint256" + } + ], + "name": "l2TransactionBaseCost", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "priorityQueueFrontOperation", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "canonicalTxHash", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "expirationTimestamp", + "type": "uint64" + }, + { + "internalType": "uint192", + "name": "layer2Tip", + "type": "uint192" + } + ], + "internalType": "struct PriorityOperation", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint64", + "name": "batchNumber", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "batchHash", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "indexRepeatedStorageChanges", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "numberOfLayer1Txs", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "priorityOperationsHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "l2LogsTreeRoot", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "commitment", + "type": "bytes32" + } + ], + "internalType": "struct IExecutor.StoredBatchInfo", + "name": "_prevBatch", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint64", + "name": "batchNumber", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "batchHash", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "indexRepeatedStorageChanges", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "numberOfLayer1Txs", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "priorityOperationsHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "l2LogsTreeRoot", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "commitment", + "type": "bytes32" + } + ], + "internalType": "struct IExecutor.StoredBatchInfo[]", + "name": "_committedBatches", + "type": "tuple[]" + }, + { + "components": [ + { + "internalType": "uint256[]", + "name": "recursiveAggregationInput", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "serializedProof", + "type": "uint256[]" + } + ], + "internalType": "struct IExecutor.ProofInput", + "name": "_proof", + "type": "tuple" + } + ], + "name": "proveBatches", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint64", + "name": "batchNumber", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "batchHash", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "indexRepeatedStorageChanges", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "numberOfLayer1Txs", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "priorityOperationsHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "l2LogsTreeRoot", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "commitment", + "type": "bytes32" + } + ], + "internalType": "struct IExecutor.StoredBatchInfo", + "name": "_prevBatch", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint64", + "name": "batchNumber", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "batchHash", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "indexRepeatedStorageChanges", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "numberOfLayer1Txs", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "priorityOperationsHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "l2LogsTreeRoot", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "commitment", + "type": "bytes32" + } + ], + "internalType": "struct IExecutor.StoredBatchInfo[]", + "name": "_committedBatches", + "type": "tuple[]" + }, + { + "components": [ + { + "internalType": "uint256[]", + "name": "recursiveAggregationInput", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "serializedProof", + "type": "uint256[]" + } + ], + "internalType": "struct IExecutor.ProofInput", + "name": "_proof", + "type": "tuple" + } + ], + "name": "proveBatchesSharedBridge", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_l2TxHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_l2BatchNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2MessageIndex", + "type": "uint256" + }, + { + "internalType": "uint16", + "name": "_l2TxNumberInBatch", + "type": "uint16" + }, + { + "internalType": "bytes32[]", + "name": "_merkleProof", + "type": "bytes32[]" + }, + { + "internalType": "enum TxStatus", + "name": "_status", + "type": "uint8" + } + ], + "name": "proveL1ToL2TransactionStatus", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_batchNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_index", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint8", + "name": "l2ShardId", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "isService", + "type": "bool" + }, + { + "internalType": "uint16", + "name": "txNumberInBatch", + "type": "uint16" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "value", + "type": "bytes32" + } + ], + "internalType": "struct L2Log", + "name": "_log", + "type": "tuple" + }, + { + "internalType": "bytes32[]", + "name": "_proof", + "type": "bytes32[]" + } + ], + "name": "proveL2LogInclusion", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_batchNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_index", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint16", + "name": "txNumberInBatch", + "type": "uint16" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct L2Message", + "name": "_message", + "type": "tuple" + }, + { + "internalType": "bytes32[]", + "name": "_proof", + "type": "bytes32[]" + } + ], + "name": "proveL2MessageInclusion", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_contractL2", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_l2Value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "_calldata", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "_l2GasLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2GasPerPubdataByteLimit", + "type": "uint256" + }, + { + "internalType": "bytes[]", + "name": "_factoryDeps", + "type": "bytes[]" + }, + { + "internalType": "address", + "name": "_refundRecipient", + "type": "address" + } + ], + "name": "requestL2Transaction", + "outputs": [ + { + "internalType": "bytes32", + "name": "canonicalTxHash", + "type": "bytes32" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_newLastBatch", + "type": "uint256" + } + ], + "name": "revertBatches", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_newLastBatch", + "type": "uint256" + } + ], + "name": "revertBatchesSharedBridge", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_newPendingAdmin", + "type": "address" + } + ], + "name": "setPendingAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "_zkPorterIsAvailable", + "type": "bool" + } + ], + "name": "setPorterAvailability", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_newPriorityTxMaxGasLimit", + "type": "uint256" + } + ], + "name": "setPriorityTxMaxGasLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "_nominator", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "_denominator", + "type": "uint128" + } + ], + "name": "setTokenMultiplier", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_transactionFilterer", + "type": "address" + } + ], + "name": "setTransactionFilterer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_validator", + "type": "address" + }, + { + "internalType": "bool", + "name": "_active", + "type": "bool" + } + ], + "name": "setValidator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "enum PubdataPricingMode", + "name": "_validiumMode", + "type": "uint8" + } + ], + "name": "setValidiumMode", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_batchNumber", + "type": "uint256" + } + ], + "name": "storedBatchHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "transferEthToSharedBridge", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unfreezeDiamond", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_protocolVersion", + "type": "uint256" + }, + { + "components": [ + { + "components": [ + { + "internalType": "address", + "name": "facet", + "type": "address" + }, + { + "internalType": "enum Diamond.Action", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "isFreezable", + "type": "bool" + }, + { + "internalType": "bytes4[]", + "name": "selectors", + "type": "bytes4[]" + } + ], + "internalType": "struct Diamond.FacetCut[]", + "name": "facetCuts", + "type": "tuple[]" + }, + { + "internalType": "address", + "name": "initAddress", + "type": "address" + }, + { + "internalType": "bytes", + "name": "initCalldata", + "type": "bytes" + } + ], + "internalType": "struct Diamond.DiamondCutData", + "name": "_cutData", + "type": "tuple" + } + ], + "name": "upgradeChainFromVersion", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index ede263b0..bfa96e0c 100755 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -16,11 +16,15 @@ yarn install echo "Generate ABIs" solc --base-path l1-contracts/ \ - --include-path ./node_modules/ \ + --include-path l1-contracts/node_modules/ \ -o l1-abi \ --abi \ - l1-contracts/contracts/zksync/interfaces/IZkSync.sol \ - l1-contracts/contracts/bridge/interfaces/IL1Bridge.sol \ + l1-contracts/contracts/bridgehub/IBridgehub.sol \ + l1-contracts/contracts/state-transition/chain-interfaces/IZkSyncStateTransition.sol \ + l1-contracts/contracts/dev-contracts/interfaces/ITestnetERC20Token.sol \ + l1-contracts/contracts/bridge/interfaces/IL1ERC20Bridge.sol \ + l1-contracts/contracts/bridge/interfaces/IL1WethBridge.sol \ + l1-contracts/contracts/bridge/interfaces/IL1Erc20Bridge.sol \ l1-contracts/contracts/bridge/interfaces/IL2Bridge.sol solc --base-path system-contracts \ @@ -35,7 +39,7 @@ solc --base-path system-contracts \ mkdir abi /abi mv l1-abi/* system-contracts-abi/* abi -contracts="IZkSync.abi IL1Bridge.abi IL2Bridge.abi IContractDeployer.abi IEthToken.abi IL1Messenger.abi INonceHolder.abi IPaymasterFlow.abi" +contracts="IBridgehub.abi IZkSyncStateTransition.abi IL1ERC20Bridge.abi IL1WethBridge.abi IL1Erc20Bridge.abi IL2Bridge.abi IContractDeployer.abi IEthToken.abi IL1Messenger.abi INonceHolder.abi IPaymasterFlow.abi ITestnetERC20Token.abi" for filename in $contracts; do jq '.' "abi/$filename" > "/abi/${filename%.abi}.json" diff --git a/src/adapters.ts b/src/adapters.ts index a4d336f0..62c1c34f 100644 --- a/src/adapters.ts +++ b/src/adapters.ts @@ -1,12 +1,16 @@ import {BigNumber, BigNumberish, BytesLike, ethers} from 'ethers'; import {Ierc20Factory as IERC20Factory} from './typechain/Ierc20Factory'; -import {Il1BridgeFactory as IL1BridgeFactory} from './typechain/Il1BridgeFactory'; +import {Il1Erc20BridgeFactory as IL1ERC20BridgeFactory} from './typechain/Il1Erc20BridgeFactory'; +import {Il1Erc20Bridge as IL1ERC20Bridge} from './typechain/Il1Erc20Bridge'; import {Il2BridgeFactory as IL2BridgeFactory} from './typechain/Il2BridgeFactory'; -import {IZkSyncFactory} from './typechain/IZkSyncFactory'; +import {Il2Bridge as IL2Bridge} from './typechain/Il2Bridge'; +import {IBridgehubFactory} from './typechain/IBridgehubFactory'; +import {IBridgehub} from './typechain/IBridgehub'; +import {Il1SharedBridge as IL1SharedBridge} from './typechain/Il1SharedBridge'; +import {Il1SharedBridgeFactory as IL1SharedBridgeFactory} from './typechain/Il1SharedBridgeFactory'; import {INonceHolderFactory} from './typechain/INonceHolderFactory'; -import {Il2Bridge} from './typechain/Il2Bridge'; -import {IZkSync} from './typechain/IZkSync'; -import {Il1Bridge} from './typechain/Il1Bridge'; +import {IZkSyncStateTransitionFactory} from './typechain/IZkSyncStateTransitionFactory'; +import {IZkSyncStateTransition} from './typechain/IZkSyncStateTransition'; import {Provider} from './provider'; import { Address, @@ -25,17 +29,19 @@ import { DEFAULT_GAS_PER_PUBDATA_LIMIT, estimateCustomBridgeDepositL2Gas, estimateDefaultBridgeDepositL2Gas, - ETH_ADDRESS, + LEGACY_ETH_ADDRESS, + ETH_ADDRESS_IN_CONTRACTS, getERC20DefaultBridgeData, isETH, L1_MESSENGER_ADDRESS, L1_RECOMMENDED_MIN_ERC20_DEPOSIT_GAS_LIMIT, L1_RECOMMENDED_MIN_ETH_DEPOSIT_GAS_LIMIT, layer1TxDefaults, + NONCE_HOLDER_ADDRESS, REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_LIMIT, scaleGasLimit, undoL1ToL2Alias, - NONCE_HOLDER_ADDRESS, + isAddressEq, } from './utils'; type Constructor = new (...args: any[]) => T; @@ -73,24 +79,59 @@ export function AdapterL1>(Base: TBase) { /** * Returns `Contract` wrapper of the zkSync Era smart contract. */ - async getMainContract(): Promise { + async getMainContract(): Promise { const address = await this._providerL2().getMainContractAddress(); - return IZkSyncFactory.connect(address, this._signerL1()); + return IZkSyncStateTransitionFactory.connect(address, this._signerL1()); + } + + /** + * Returns `Contract` wrapper of the Bridgehub smart contract. + */ + async getBridgehubContract(): Promise { + const address = await this._providerL2().getBridgehubContractAddress(); + return IBridgehubFactory.connect(address, this._signerL1()); } /** * Returns L1 bridge contracts. * - * @remarks There is no separate Ether bridge contract, {@link getMainContract Main contract} is used instead. + * @remarks There is no separate Ether bridge contract, {@link getBridgehubContract Bridgehub} is used instead. */ - async getL1BridgeContracts(): Promise<{erc20: Il1Bridge; weth: Il1Bridge}> { + async getL1BridgeContracts(): Promise<{ + erc20: IL1ERC20Bridge; + weth: IL1ERC20Bridge; + shared: IL1SharedBridge; + }> { const addresses = await this._providerL2().getDefaultBridgeAddresses(); return { - erc20: IL1BridgeFactory.connect(addresses.erc20L1!, this._signerL1()), - weth: IL1BridgeFactory.connect(addresses.wethL1!, this._signerL1()), + erc20: IL1ERC20BridgeFactory.connect( + addresses.erc20L1, + this._signerL1() + ), + weth: IL1ERC20BridgeFactory.connect(addresses.wethL1, this._signerL1()), + shared: IL1SharedBridgeFactory.connect( + addresses.sharedL1, + this._signerL1() + ), }; } + /** + * Returns the address of the base token on L1. + */ + async getBaseToken(): Promise { + const bridgehub = await this.getBridgehubContract(); + const chainId = (await this._providerL2().getNetwork()).chainId; + return await bridgehub.baseToken(chainId); + } + + /** + * Returns whether the chain is ETH-based. + */ + async isETHBasedChain(): Promise { + return this._providerL2().isEthBasedChain(); + } + /** * Returns the amount of the token held by the account on the L1 network. * @@ -102,7 +143,7 @@ export function AdapterL1>(Base: TBase) { token?: Address, blockTag?: ethers.providers.BlockTag ): Promise { - token ??= ETH_ADDRESS; + token ??= LEGACY_ETH_ADDRESS; if (isETH(token)) { return await this._providerL1().getBalance( await this.getAddress(), @@ -119,7 +160,7 @@ export function AdapterL1>(Base: TBase) { * * @param token The Ethereum address of the token. * @param [bridgeAddress] The address of the bridge contract to be used. - * Defaults to the default zkSync Era bridge, either `L1EthBridge` or `L1Erc20Bridge`. + * Defaults to the default zkSync Era bridge, either `L1EthBridge` or `L1ERC20Bridge`. * @param [blockTag] The block in which an allowance should be checked. * Defaults to 'committed', i.e., the latest processed block. */ @@ -130,18 +171,7 @@ export function AdapterL1>(Base: TBase) { ): Promise { if (!bridgeAddress) { const bridgeContracts = await this.getL1BridgeContracts(); - let l2WethToken = ethers.constants.AddressZero; - try { - l2WethToken = await bridgeContracts.weth.l2TokenAddress(token); - } catch (e) { - // skip - } - - // If the token is Wrapped Ether, return allowance to its own bridge, otherwise to the default ERC20 bridge. - bridgeAddress = - l2WethToken !== ethers.constants.AddressZero - ? bridgeContracts.weth.address - : bridgeContracts.erc20.address; + bridgeAddress = bridgeContracts.shared.address; } const erc20contract = IERC20Factory.connect(token, this._providerL1()); @@ -163,21 +193,7 @@ export function AdapterL1>(Base: TBase) { * @param token The address of the token on L1. */ async l2TokenAddress(token: Address): Promise { - if (token === ETH_ADDRESS) { - return ETH_ADDRESS; - } - - const bridgeContracts = await this.getL1BridgeContracts(); - try { - const l2WethToken = await bridgeContracts.weth.l2TokenAddress(token); - // If the token is Wrapped Ether, return its L2 token address. - if (l2WethToken !== ethers.constants.AddressZero) { - return l2WethToken; - } - } catch (e) { - // skip - } - return await bridgeContracts.erc20.l2TokenAddress(token); + return this._providerL2().l2TokenAddress(token); } /** @@ -200,28 +216,16 @@ export function AdapterL1>(Base: TBase) { ); } - let bridgeAddress = overrides?.bridgeAddress; + overrides ??= {}; + let bridgeAddress = overrides.bridgeAddress; const erc20contract = IERC20Factory.connect(token, this._signerL1()); if (!bridgeAddress) { - const bridgeContracts = await this.getL1BridgeContracts(); - let l2WethToken = ethers.constants.AddressZero; - try { - l2WethToken = await bridgeContracts.weth.l2TokenAddress(token); - } catch (e) { - // skip - } - // If the token is Wrapped Ether, return corresponding bridge, otherwise return default ERC20 bridge - bridgeAddress = - l2WethToken !== ethers.constants.AddressZero - ? bridgeContracts.weth.address - : bridgeContracts.erc20.address; + bridgeAddress = (await this.getL1BridgeContracts()).shared.address; } else { - delete overrides!.bridgeAddress; + delete overrides.bridgeAddress; } - overrides ??= {}; - return await erc20contract.approve(bridgeAddress, amount, overrides); } @@ -238,13 +242,14 @@ export function AdapterL1>(Base: TBase) { gasPerPubdataByte?: BigNumberish; gasPrice?: BigNumberish; }): Promise { - const zksyncContract = await this.getMainContract(); + const bridgehub = await this.getBridgehubContract(); const parameters = {...layer1TxDefaults(), ...params}; parameters.gasPrice ??= await this._providerL1().getGasPrice(); parameters.gasPerPubdataByte ??= REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_LIMIT; return BigNumber.from( - await zksyncContract.l2TransactionBaseCost( + await bridgehub.l2TransactionBaseCost( + (await this._providerL2().getNetwork()).chainId, parameters.gasPrice, parameters.gasLimit, parameters.gasPerPubdataByte @@ -252,13 +257,79 @@ export function AdapterL1>(Base: TBase) { ); } + /** + * Returns the parameters for the approval token transaction based on the deposit token and amount. + * Some deposit transactions require multiple approvals. Existing allowance for the bridge is not checked; + * allowance is calculated solely based on the specified amount. + * + * @param token The address of the token to deposit. + * @param amount The amount of the token to deposit. + */ + async getDepositAllowanceParams( + token: Address, + amount: BigNumberish + ): Promise<{token: Address; allowance: BigNumberish}[]> { + if (isAddressEq(token, LEGACY_ETH_ADDRESS)) { + token = ETH_ADDRESS_IN_CONTRACTS; + } + const baseTokenAddress = await this.getBaseToken(); + const isEthBasedChain = await this.isETHBasedChain(); + + if (isEthBasedChain && isAddressEq(token, ETH_ADDRESS_IN_CONTRACTS)) { + throw new Error( + "ETH token can't be approved! The address of the token does not exist on L1." + ); + } else if (isAddressEq(baseTokenAddress, ETH_ADDRESS_IN_CONTRACTS)) { + return [{token, allowance: amount}]; + } else if (isAddressEq(token, ETH_ADDRESS_IN_CONTRACTS)) { + return [ + { + token: baseTokenAddress, + allowance: ( + await this._getDepositETHOnNonETHBasedChainTx({token, amount}) + ).mintValue, + }, + ]; + } else if (isAddressEq(token, baseTokenAddress)) { + return [ + { + token: baseTokenAddress, + allowance: ( + await this._getDepositBaseTokenOnNonETHBasedChainTx({ + token, + amount, + }) + ).mintValue, + }, + ]; + } else { + // A deposit of a non-base token to a non-ETH-based chain requires two approvals. + return [ + { + token: baseTokenAddress, + allowance: ( + await this._getDepositNonBaseTokenToNonETHBasedChainTx({ + token, + amount, + }) + ).mintValue, + }, + { + token: token, + allowance: amount, + }, + ]; + } + } + /** * Transfers the specified token from the associated account on the L1 network to the target account on the L2 network. * The token can be either ETH or any ERC20 token. For ERC20 tokens, enough approved tokens must be associated with * the specified L1 bridge (default one or the one defined in `transaction.bridgeAddress`). - * In this case, `transaction.approveERC20` can be enabled to perform token approval. If there are already enough - * approved tokens for the L1 bridge, token approval will be skipped. - * To check the amount of approved tokens for a specific bridge, use the {@link getAllowanceL1} method. + * In this case, depending on is the chain ETH-based or not `transaction.approveERC20` or `transaction.approveBaseERC20` + * can be enabled to perform token approval. If there are already enough approved tokens for the L1 bridge, + * token approval will be skipped. To check the amount of approved tokens for a specific bridge, + * use the {@link getAllowanceL1} method. * * @param transaction The transaction object containing deposit details. * @param transaction.token The address of the token to deposit. ETH by default. @@ -270,13 +341,19 @@ export function AdapterL1>(Base: TBase) { * @param [transaction.bridgeAddress] The address of the bridge contract to be used. * Defaults to the default zkSync Era bridge (either `L1EthBridge` or `L1Erc20Bridge`). * @param [transaction.approveERC20] Whether or not token approval should be performed under the hood. - * Set this flag to true if you bridge an ERC20 token and didn't call the {@link approveERC20} function beforehand. + * Set this flag to true if you bridge an ERC20 token and didn't call the {@link approveERC20} function beforehand. + * @param [transaction.approveBaseERC20] Whether or not base token approval should be performed under the hood. + * Set this flag to true if you bridge a base token and didn't call the {@link approveERC20} function beforehand. * @param [transaction.l2GasLimit] Maximum amount of L2 gas that the transaction can consume during execution on L2. * @param [transaction.gasPerPubdataByte] The L2 gas price for each published L1 calldata byte. * @param [transaction.refundRecipient] The address on L2 that will receive the refund for the transaction. * If the transaction fails, it will also be the address to receive `l2Value`. - * @param [transaction.overrides] Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. - * @param [transaction.approveOverrides] Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. + * @param [transaction.overrides] Transaction's overrides for deposit which may be used to pass + * L1 `gasLimit`, `gasPrice`, `value`, etc. + * @param [transaction.approveOverrides] Transaction's overrides for approval of an ERC20 token which may be used + * to pass L1 `gasLimit`, `gasPrice`, `value`, etc. + * @param [transaction.approveBaseOverrides] Transaction's overrides for approval of a base token which may be used + * to pass L1 `gasLimit`, `gasPrice`, `value`, etc. * @param [transaction.customBridgeData] Additional data that can be sent to a bridge. */ async deposit(transaction: { @@ -286,76 +363,315 @@ export function AdapterL1>(Base: TBase) { operatorTip?: BigNumberish; bridgeAddress?: Address; approveERC20?: boolean; + approveBaseERC20?: boolean; l2GasLimit?: BigNumberish; gasPerPubdataByte?: BigNumberish; refundRecipient?: Address; overrides?: ethers.PayableOverrides; approveOverrides?: ethers.Overrides; + approveBaseOverrides?: ethers.Overrides; customBridgeData?: BytesLike; }): Promise { - const depositTx = await this.getDepositTx(transaction); + if (isAddressEq(transaction.token, LEGACY_ETH_ADDRESS)) { + transaction.token = ETH_ADDRESS_IN_CONTRACTS; + } + const bridgehub = await this.getBridgehubContract(); + const chainId = (await this._providerL2().getNetwork()).chainId; + const baseTokenAddress = await bridgehub.baseToken(chainId); + const isEthBasedChain = isAddressEq( + baseTokenAddress, + ETH_ADDRESS_IN_CONTRACTS + ); + + if ( + isEthBasedChain && + isAddressEq(transaction.token, ETH_ADDRESS_IN_CONTRACTS) + ) { + return await this._depositETHToETHBasedChain(transaction); + } else if (isAddressEq(baseTokenAddress, ETH_ADDRESS_IN_CONTRACTS)) { + return await this._depositTokenToETHBasedChain(transaction); + } else if (isAddressEq(transaction.token, ETH_ADDRESS_IN_CONTRACTS)) { + return await this._depositETHToNonETHBasedChain(transaction); + } else if (isAddressEq(transaction.token, baseTokenAddress)) { + return await this._depositBaseTokenToNonETHBasedChain(transaction); + } else { + return await this._depositNonBaseTokenToNonETHBasedChain(transaction); + } + } - if (transaction.token === ETH_ADDRESS) { - const baseGasLimit = await this.estimateGasRequestExecute(depositTx); - const gasLimit = scaleGasLimit(baseGasLimit); + async _depositNonBaseTokenToNonETHBasedChain(transaction: { + token: Address; + amount: BigNumberish; + to?: Address; + operatorTip?: BigNumberish; + bridgeAddress?: Address; + approveERC20?: boolean; + approveBaseERC20?: boolean; + l2GasLimit?: BigNumberish; + gasPerPubdataByte?: BigNumberish; + refundRecipient?: Address; + overrides?: ethers.PayableOverrides; + approveOverrides?: ethers.Overrides; + approveBaseOverrides?: ethers.Overrides; + customBridgeData?: BytesLike; + }): Promise { + // Deposit a non-ETH and non-base token to a non-ETH-based chain. + // Go through the BridgeHub and obtain approval for both tokens. + const bridgehub = await this.getBridgehubContract(); + const chainId = (await this._providerL2().getNetwork()).chainId; + const baseTokenAddress = await bridgehub.baseToken(chainId); + const bridgeContracts = await this.getL1BridgeContracts(); + const {tx, mintValue} = + await this._getDepositNonBaseTokenToNonETHBasedChainTx(transaction); + + if (transaction.approveBaseERC20) { + // Only request the allowance if the current one is not enough. + const allowance = await this.getAllowanceL1( + baseTokenAddress, + bridgeContracts.shared.address + ); + if (allowance.lt(mintValue)) { + const approveTx = await this.approveERC20( + baseTokenAddress, + mintValue, + { + bridgeAddress: bridgeContracts.shared.address, + ...transaction.approveBaseOverrides, + } + ); + await approveTx.wait(); + } + } - depositTx.overrides ??= {}; - depositTx.overrides.gasLimit ??= gasLimit; + if (transaction.approveERC20) { + const bridgeAddress = transaction.bridgeAddress + ? transaction.bridgeAddress + : bridgeContracts.shared.address; - return this.requestExecute(depositTx); - } else { - const bridgeContracts = await this.getL1BridgeContracts(); - if (transaction.approveERC20) { - let l2WethToken = ethers.constants.AddressZero; - try { - l2WethToken = await bridgeContracts.weth.l2TokenAddress( - transaction.token - ); - } catch (e) { - // skip - } - // If the token is Wrapped Ether, use its bridge. - const proposedBridge = - l2WethToken !== ethers.constants.AddressZero - ? bridgeContracts.weth.address - : bridgeContracts.erc20.address; - const bridgeAddress = transaction.bridgeAddress - ? transaction.bridgeAddress - : proposedBridge; - - // We only request the allowance if the current one is not enough. - const allowance = await this.getAllowanceL1( + // Only request the allowance if the current one is not enough. + const allowance = await this.getAllowanceL1( + transaction.token, + bridgeAddress + ); + if (allowance.lt(transaction.amount)) { + const approveTx = await this.approveERC20( transaction.token, - bridgeAddress + transaction.amount, + { + bridgeAddress, + ...transaction.approveOverrides, + } ); - if (allowance.lt(transaction.amount)) { - const approveTx = await this.approveERC20( - transaction.token, - transaction.amount, - { - bridgeAddress, - ...transaction.approveOverrides, - } - ); - await approveTx.wait(); - } + await approveTx.wait(); + } + } + + const baseGasLimit = await this._providerL1().estimateGas(tx); + const gasLimit = scaleGasLimit(baseGasLimit); + + tx.gasLimit ??= gasLimit; + + return await this._providerL2().getPriorityOpResponse( + await this._signerL1().sendTransaction(tx) + ); + } + + async _depositBaseTokenToNonETHBasedChain(transaction: { + token: Address; + amount: BigNumberish; + to?: Address; + operatorTip?: BigNumberish; + bridgeAddress?: Address; + approveERC20?: boolean; + approveBaseERC20?: boolean; + l2GasLimit?: BigNumberish; + gasPerPubdataByte?: BigNumberish; + refundRecipient?: Address; + overrides?: ethers.PayableOverrides; + approveOverrides?: ethers.Overrides; + approveBaseOverrides?: ethers.Overrides; + customBridgeData?: BytesLike; + }): Promise { + // Bridging the base token to a non-ETH-based chain. + // Go through the BridgeHub, and give approval. + const bridgehub = await this.getBridgehubContract(); + const chainId = (await this._providerL2().getNetwork()).chainId; + const baseTokenAddress = await bridgehub.baseToken(chainId); + const sharedBridge = (await this.getL1BridgeContracts()).shared.address; + const {tx, mintValue} = + await this._getDepositBaseTokenOnNonETHBasedChainTx(transaction); + + if (transaction.approveERC20 || transaction.approveBaseERC20) { + const approveOverrides = + transaction.approveBaseOverrides ?? transaction.approveOverrides!; + // Only request the allowance if the current one is not enough. + const allowance = await this.getAllowanceL1( + baseTokenAddress, + sharedBridge + ); + if (allowance.lt(mintValue)) { + const approveTx = await this.approveERC20( + baseTokenAddress, + mintValue, + { + bridgeAddress: sharedBridge, + ...approveOverrides, + } + ); + await approveTx.wait(); } + } + const baseGasLimit = await this.estimateGasRequestExecute(tx); + const gasLimit = scaleGasLimit(baseGasLimit); - const baseGasLimit = await this._providerL1().estimateGas(depositTx); - const gasLimit = scaleGasLimit(baseGasLimit); + tx.overrides ??= {}; + tx.overrides.gasLimit ??= gasLimit; - depositTx.gasLimit ??= gasLimit; + return this.requestExecute(tx); + } - return await this._providerL2().getPriorityOpResponse( - await this._signerL1().sendTransaction(depositTx) + async _depositETHToNonETHBasedChain(transaction: { + token: Address; + amount: BigNumberish; + to?: Address; + operatorTip?: BigNumberish; + bridgeAddress?: Address; + approveERC20?: boolean; + approveBaseERC20?: boolean; + l2GasLimit?: BigNumberish; + gasPerPubdataByte?: BigNumberish; + refundRecipient?: Address; + overrides?: ethers.PayableOverrides; + approveOverrides?: ethers.Overrides; + approveBaseOverrides?: ethers.Overrides; + customBridgeData?: BytesLike; + }): Promise { + // Depositing ETH into a non-ETH-based chain. + // Use requestL2TransactionTwoBridges, secondBridge is the wETH bridge. + const bridgehub = await this.getBridgehubContract(); + const chainId = (await this._providerL2().getNetwork()).chainId; + const baseTokenAddress = await bridgehub.baseToken(chainId); + const sharedBridge = (await this.getL1BridgeContracts()).shared.address; + const {tx, mintValue} = + await this._getDepositETHOnNonETHBasedChainTx(transaction); + + if (transaction.approveBaseERC20) { + // Only request the allowance if the current one is not enough. + const allowance = await this.getAllowanceL1( + baseTokenAddress, + sharedBridge ); + if (allowance.lt(mintValue)) { + const approveTx = await this.approveERC20( + baseTokenAddress, + mintValue, + { + bridgeAddress: sharedBridge, + ...transaction.approveBaseOverrides, + } + ); + await approveTx.wait(); + } } + + const baseGasLimit = await this._providerL1().estimateGas(tx); + const gasLimit = scaleGasLimit(baseGasLimit); + + tx.gasLimit ??= gasLimit; + + return await this._providerL2().getPriorityOpResponse( + await this._signerL1().sendTransaction(tx) + ); + } + + async _depositTokenToETHBasedChain(transaction: { + token: Address; + amount: BigNumberish; + to?: Address; + operatorTip?: BigNumberish; + bridgeAddress?: Address; + approveERC20?: boolean; + approveBaseERC20?: boolean; + l2GasLimit?: BigNumberish; + gasPerPubdataByte?: BigNumberish; + refundRecipient?: Address; + overrides?: ethers.PayableOverrides; + approveOverrides?: ethers.Overrides; + approveBaseOverrides?: ethers.Overrides; + customBridgeData?: BytesLike; + }): Promise { + const bridgeContracts = await this.getL1BridgeContracts(); + const tx = await this._getDepositTokenOnETHBasedChainTx(transaction); + + if (transaction.approveERC20) { + const proposedBridge = bridgeContracts.shared.address; + const bridgeAddress = transaction.bridgeAddress + ? transaction.bridgeAddress + : proposedBridge; + + // Only request the allowance if the current one is not enough. + const allowance = await this.getAllowanceL1( + transaction.token, + bridgeAddress + ); + if (allowance.lt(transaction.amount)) { + const approveTx = await this.approveERC20( + transaction.token, + transaction.amount, + { + bridgeAddress, + ...transaction.approveOverrides, + } + ); + await approveTx.wait(); + } + } + + const baseGasLimit = await this._providerL1().estimateGas(tx); + const gasLimit = scaleGasLimit(baseGasLimit); + + tx.gasLimit ??= gasLimit; + + return await this._providerL2().getPriorityOpResponse( + await this._signerL1().sendTransaction(tx) + ); + } + + async _depositETHToETHBasedChain(transaction: { + token: Address; + amount: BigNumberish; + to?: Address; + operatorTip?: BigNumberish; + bridgeAddress?: Address; + approveERC20?: boolean; + approveBaseERC20?: boolean; + l2GasLimit?: BigNumberish; + gasPerPubdataByte?: BigNumberish; + refundRecipient?: Address; + overrides?: ethers.PayableOverrides; + approveOverrides?: ethers.Overrides; + approveBaseOverrides?: ethers.Overrides; + customBridgeData?: BytesLike; + }): Promise { + const tx = await this._getDepositETHOnETHBasedChainTx(transaction); + + const baseGasLimit = await this.estimateGasRequestExecute(tx); + const gasLimit = scaleGasLimit(baseGasLimit); + + tx.overrides ??= {}; + tx.overrides.gasLimit ??= gasLimit; + + return this.requestExecute(tx); } /** * Estimates the amount of gas required for a deposit transaction on the L1 network. * Gas for approving ERC20 tokens is not included in the estimation. * + * In order for estimation to work, enough token allowance is required in the following cases: + * - Depositing ERC20 tokens on an ETH-based chain. + * - Depositing any token (including ETH) on a non-ETH-based chain. + * * @param transaction The transaction details. * @param transaction.token The address of the token to deposit. ETH by default. * @param transaction.amount The amount of the token to deposit. @@ -384,13 +700,16 @@ export function AdapterL1>(Base: TBase) { refundRecipient?: Address; overrides?: ethers.PayableOverrides; }): Promise { - const depositTx = await this.getDepositTx(transaction); + if (isAddressEq(transaction.token, LEGACY_ETH_ADDRESS)) { + transaction.token = ETH_ADDRESS_IN_CONTRACTS; + } + const tx = await this.getDepositTx(transaction); let baseGasLimit: BigNumber; - if (transaction.token === ETH_ADDRESS) { - baseGasLimit = await this.estimateGasRequestExecute(depositTx); + if (tx.token && isAddressEq(tx.token, await this.getBaseToken())) { + baseGasLimit = await this.estimateGasRequestExecute(tx); } else { - baseGasLimit = await this._providerL1().estimateGas(depositTx); + baseGasLimit = await this._providerL1().estimateGas(tx); } return scaleGasLimit(baseGasLimit); @@ -427,112 +746,443 @@ export function AdapterL1>(Base: TBase) { refundRecipient?: Address; overrides?: ethers.PayableOverrides; }): Promise { - const bridgeContracts = await this.getL1BridgeContracts(); - if (transaction.bridgeAddress) { - bridgeContracts.erc20 = bridgeContracts.erc20.attach( - transaction.bridgeAddress - ); + if (isAddressEq(transaction.token, LEGACY_ETH_ADDRESS)) { + transaction.token = ETH_ADDRESS_IN_CONTRACTS; } + const bridgehub = await this.getBridgehubContract(); + const chainId = (await this._providerL2().getNetwork()).chainId; + const baseTokenAddress = await bridgehub.baseToken(chainId); + const isEthBasedChain = isAddressEq( + baseTokenAddress, + ETH_ADDRESS_IN_CONTRACTS + ); - const {...tx} = transaction; - tx.to ??= await this.getAddress(); - tx.operatorTip ??= BigNumber.from(0); - tx.overrides ??= {}; - tx.gasPerPubdataByte ??= REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_LIMIT; - if (tx.bridgeAddress) { - const customBridgeData = - tx.customBridgeData ?? - bridgeContracts.weth.address === tx.bridgeAddress - ? '0x' - : await getERC20DefaultBridgeData(tx.token, this._providerL1()); - const bridge = IL1BridgeFactory.connect( - tx.bridgeAddress, - this._signerL1() - ); - const l2Address = await bridge.l2Bridge(); - tx.l2GasLimit ??= await estimateCustomBridgeDepositL2Gas( - this._providerL2(), - tx.bridgeAddress, - l2Address, - tx.token, - tx.amount, - tx.to, - customBridgeData, - await this.getAddress(), - tx.gasPerPubdataByte - ); + if ( + isEthBasedChain && + isAddressEq(transaction.token, ETH_ADDRESS_IN_CONTRACTS) + ) { + return await this._getDepositETHOnETHBasedChainTx(transaction); + } else if (isEthBasedChain) { + return await this._getDepositTokenOnETHBasedChainTx(transaction); + } else if (isAddressEq(transaction.token, ETH_ADDRESS_IN_CONTRACTS)) { + return (await this._getDepositETHOnNonETHBasedChainTx(transaction)).tx; + } else if (isAddressEq(transaction.token, baseTokenAddress)) { + return ( + await this._getDepositBaseTokenOnNonETHBasedChainTx(transaction) + ).tx; } else { - tx.l2GasLimit ??= await estimateDefaultBridgeDepositL2Gas( - this._providerL1(), - this._providerL2(), - tx.token, - tx.amount, - tx.to, - await this.getAddress(), - tx.gasPerPubdataByte - ); + return ( + await this._getDepositNonBaseTokenToNonETHBasedChainTx(transaction) + ).tx; } + } - const {to, token, amount, operatorTip, overrides} = tx; + async _getDepositNonBaseTokenToNonETHBasedChainTx(transaction: { + token: Address; + amount: BigNumberish; + to?: Address; + operatorTip?: BigNumberish; + bridgeAddress?: Address; + l2GasLimit?: BigNumberish; + gasPerPubdataByte?: BigNumberish; + customBridgeData?: BytesLike; + refundRecipient?: Address; + overrides?: ethers.PayableOverrides; + }) { + const bridgehub = await this.getBridgehubContract(); + const chainId = (await this._providerL2().getNetwork()).chainId; + const bridgeContracts = await this.getL1BridgeContracts(); + + const tx = await this._getDepositTxWithDefaults(transaction); + const { + token, + operatorTip, + amount, + overrides, + l2GasLimit, + to, + refundRecipient, + gasPerPubdataByte, + } = tx; - await insertGasPrice(this._providerL1(), overrides); const gasPriceForEstimation = - overrides.maxFeePerGas || overrides.gasPrice; + (await overrides.maxFeePerGas) || (await overrides.gasPrice); + const baseCost = await bridgehub.l2TransactionBaseCost( + chainId, + gasPriceForEstimation!, + l2GasLimit, + gasPerPubdataByte + ); - const zksyncContract = await this.getMainContract(); + const mintValue = baseCost.add(operatorTip); + await checkBaseCost(baseCost, mintValue); + overrides.value ??= 0; - const baseCost = await zksyncContract.l2TransactionBaseCost( - await gasPriceForEstimation!, - tx.l2GasLimit, - tx.gasPerPubdataByte - ); + return { + tx: await bridgehub.populateTransaction.requestL2TransactionTwoBridges( + { + chainId: chainId, + mintValue, + l2Value: 0, + l2GasLimit: l2GasLimit, + l2GasPerPubdataByteLimit: gasPerPubdataByte, + refundRecipient: refundRecipient ?? ethers.constants.AddressZero, + secondBridgeAddress: bridgeContracts.shared.address, + secondBridgeValue: 0, + secondBridgeCalldata: ethers.utils.defaultAbiCoder.encode( + ['address', 'uint256', 'address'], + [token, amount, to] + ), + }, + overrides + ), + mintValue: mintValue, + }; + } - if (token === ETH_ADDRESS) { - overrides.value ??= baseCost.add(operatorTip).add(amount); + async _getDepositBaseTokenOnNonETHBasedChainTx(transaction: { + token: Address; + amount: BigNumberish; + to?: Address; + operatorTip?: BigNumberish; + bridgeAddress?: Address; + l2GasLimit?: BigNumberish; + gasPerPubdataByte?: BigNumberish; + customBridgeData?: BytesLike; + refundRecipient?: Address; + overrides?: ethers.PayableOverrides; + }) { + // Depositing the base token to a non-ETH-based chain. + // Goes through the BridgeHub. + // Have to give approvals for the sharedBridge. + const bridgehub = await this.getBridgehubContract(); + const chainId = (await this._providerL2().getNetwork()).chainId; + + const tx = await this._getDepositTxWithDefaults(transaction); + const { + operatorTip, + amount, + to, + overrides, + l2GasLimit, + gasPerPubdataByte, + } = tx; + + const gasPriceForEstimation = + (await overrides.maxFeePerGas) || (await overrides.gasPrice); + const baseCost = await bridgehub.l2TransactionBaseCost( + chainId, + gasPriceForEstimation!, + l2GasLimit, + gasPerPubdataByte + ); - return { + tx.overrides.value = 0; + return { + tx: { contractAddress: to, calldata: '0x', + mintValue: baseCost.add(operatorTip).add(amount), l2Value: amount, ...tx, - }; + }, + mintValue: baseCost.add(operatorTip).add(amount), + }; + } + + async _getDepositETHOnNonETHBasedChainTx(transaction: { + token: Address; + amount: BigNumberish; + to?: Address; + operatorTip?: BigNumberish; + bridgeAddress?: Address; + l2GasLimit?: BigNumberish; + gasPerPubdataByte?: BigNumberish; + customBridgeData?: BytesLike; + refundRecipient?: Address; + overrides?: ethers.PayableOverrides; + }) { + const bridgehub = await this.getBridgehubContract(); + const chainId = (await this._providerL2().getNetwork()).chainId; + const sharedBridge = (await this.getL1BridgeContracts()).shared.address; + + const tx = await this._getDepositTxWithDefaults(transaction); + const { + operatorTip, + amount, + overrides, + l2GasLimit, + to, + refundRecipient, + gasPerPubdataByte, + } = tx; + + const gasPriceForEstimation = + (await overrides.maxFeePerGas) || (await overrides.gasPrice); + const baseCost = await bridgehub.l2TransactionBaseCost( + chainId, + gasPriceForEstimation!, + l2GasLimit, + gasPerPubdataByte + ); + + overrides.value ??= amount; + const mintValue = baseCost.add(operatorTip); + await checkBaseCost(baseCost, mintValue); + + return { + tx: await bridgehub.populateTransaction.requestL2TransactionTwoBridges( + { + chainId, + mintValue, + l2Value: 0, + l2GasLimit: l2GasLimit, + l2GasPerPubdataByteLimit: gasPerPubdataByte, + refundRecipient: refundRecipient ?? ethers.constants.AddressZero, + secondBridgeAddress: sharedBridge, + secondBridgeValue: amount, + secondBridgeCalldata: ethers.utils.defaultAbiCoder.encode( + ['address', 'uint256', 'address'], + [ETH_ADDRESS_IN_CONTRACTS, 0, to] + ), + }, + overrides + ), + mintValue: mintValue, + }; + } + + async _getDepositTokenOnETHBasedChainTx(transaction: { + token: Address; + amount: BigNumberish; + to?: Address; + operatorTip?: BigNumberish; + bridgeAddress?: Address; + l2GasLimit?: BigNumberish; + gasPerPubdataByte?: BigNumberish; + customBridgeData?: BytesLike; + refundRecipient?: Address; + overrides?: ethers.PayableOverrides; + }): Promise { + // Depositing token to an ETH-based chain. Use the ERC20 bridge as done before. + const bridgehub = await this.getBridgehubContract(); + const chainId = (await this._providerL2().getNetwork()).chainId; + + const tx = await this._getDepositTxWithDefaults(transaction); + const { + token, + operatorTip, + amount, + overrides, + l2GasLimit, + to, + refundRecipient, + gasPerPubdataByte, + } = tx; + + const gasPriceForEstimation = + (await overrides.maxFeePerGas) || (await overrides.gasPrice); + const baseCost = await bridgehub.l2TransactionBaseCost( + chainId, + gasPriceForEstimation!, + tx.l2GasLimit, + tx.gasPerPubdataByte + ); + + const mintValue = baseCost.add(operatorTip); + overrides.value ??= mintValue; + await checkBaseCost(baseCost, mintValue); + + let secondBridgeAddress: string; + let secondBridgeCalldata: BytesLike; + if (tx.bridgeAddress) { + secondBridgeAddress = tx.bridgeAddress; + secondBridgeCalldata = await getERC20DefaultBridgeData( + transaction.token, + this._providerL1() + ); } else { - const refundRecipient = - tx.refundRecipient ?? ethers.constants.AddressZero; - const args: [ - Address, - Address, - BigNumberish, - BigNumberish, - BigNumberish, - Address, - ] = [ - to, - token, - amount, - tx.l2GasLimit, - tx.gasPerPubdataByte, - refundRecipient, - ]; + secondBridgeAddress = (await this.getL1BridgeContracts()).shared + .address; + secondBridgeCalldata = ethers.utils.defaultAbiCoder.encode( + ['address', 'uint256', 'address'], + [token, amount, to] + ); + } - overrides.value ??= baseCost.add(operatorTip); - await checkBaseCost(baseCost, overrides.value); + return await bridgehub.populateTransaction.requestL2TransactionTwoBridges( + { + chainId, + mintValue, + l2Value: 0, + l2GasLimit, + l2GasPerPubdataByteLimit: gasPerPubdataByte, + refundRecipient: refundRecipient ?? ethers.constants.AddressZero, + secondBridgeAddress, + secondBridgeValue: 0, + secondBridgeCalldata, + }, + overrides + ); + } - let l2WethToken = ethers.constants.AddressZero; - try { - l2WethToken = await bridgeContracts.weth.l2TokenAddress(tx.token); - } catch (e) { - // skip - } + async _getDepositETHOnETHBasedChainTx(transaction: { + token: Address; + amount: BigNumberish; + to?: Address; + operatorTip?: BigNumberish; + bridgeAddress?: Address; + l2GasLimit?: BigNumberish; + gasPerPubdataByte?: BigNumberish; + customBridgeData?: BytesLike; + refundRecipient?: Address; + overrides?: ethers.PayableOverrides; + }) { + // Call the BridgeHub directly, like it's done with the DiamondProxy. + const bridgehub = await this.getBridgehubContract(); + const chainId = (await this._providerL2().getNetwork()).chainId; - const bridge = - l2WethToken !== ethers.constants.AddressZero - ? bridgeContracts.weth - : bridgeContracts.erc20; - return await bridge.populateTransaction.deposit(...args, overrides); + const tx = await this._getDepositTxWithDefaults(transaction); + const { + operatorTip, + amount, + overrides, + l2GasLimit, + gasPerPubdataByte, + to, + } = tx; + + const gasPriceForEstimation = + (await overrides.maxFeePerGas) || (await overrides.gasPrice); + const baseCost = await bridgehub.l2TransactionBaseCost( + chainId, + gasPriceForEstimation!, + l2GasLimit, + gasPerPubdataByte + ); + + overrides.value ??= baseCost.add(operatorTip).add(amount); + + return { + contractAddress: to, + calldata: '0x', + mintValue: await overrides.value, + l2Value: amount, + ...tx, + }; + } + + // Creates a shallow copy of a transaction and populates missing fields with defaults. + async _getDepositTxWithDefaults(transaction: { + token: Address; + amount: BigNumberish; + to?: Address; + operatorTip?: BigNumberish; + bridgeAddress?: Address; + l2GasLimit?: BigNumberish; + gasPerPubdataByte?: BigNumberish; + customBridgeData?: BytesLike; + refundRecipient?: Address; + overrides?: ethers.PayableOverrides; + }): Promise<{ + token: Address; + amount: BigNumberish; + to: Address; + operatorTip: BigNumberish; + bridgeAddress?: Address; + l2GasLimit: BigNumberish; + gasPerPubdataByte: BigNumberish; + customBridgeData?: BytesLike; + refundRecipient?: Address; + overrides: ethers.PayableOverrides; + }> { + const {...tx} = transaction; + tx.to ??= await this.getAddress(); + tx.operatorTip ??= BigNumber.from(0); + tx.overrides ??= {}; + tx.gasPerPubdataByte ??= REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_LIMIT; + tx.l2GasLimit ??= await this._getL2GasLimit(tx); + await insertGasPrice(this._providerL1(), tx.overrides); + + return tx as { + token: Address; + amount: BigNumberish; + to: Address; + operatorTip: BigNumberish; + bridgeAddress?: Address; + l2GasLimit: BigNumberish; + gasPerPubdataByte: BigNumberish; + customBridgeData?: BytesLike; + refundRecipient?: Address; + overrides: ethers.PayableOverrides; + }; + } + + // Default behaviour for calculating l2GasLimit of deposit transaction. + async _getL2GasLimit(transaction: { + token: Address; + amount: BigNumberish; + to?: Address; + operatorTip?: BigNumberish; + bridgeAddress?: Address; + l2GasLimit?: BigNumberish; + gasPerPubdataByte?: BigNumberish; + customBridgeData?: BytesLike; + refundRecipient?: Address; + overrides?: ethers.PayableOverrides; + }): Promise { + if (transaction.bridgeAddress) { + return await this._getL2GasLimitFromCustomBridge(transaction); + } else { + return await estimateDefaultBridgeDepositL2Gas( + this._providerL1(), + this._providerL2(), + transaction.token, + transaction.amount, + transaction.to!, + await this.getAddress(), + transaction.gasPerPubdataByte + ); } } + // Calculates the l2GasLimit of deposit transaction using custom bridge. + async _getL2GasLimitFromCustomBridge(transaction: { + token: Address; + amount: BigNumberish; + to?: Address; + operatorTip?: BigNumberish; + bridgeAddress?: Address; + l2GasLimit?: BigNumberish; + gasPerPubdataByte?: BigNumberish; + customBridgeData?: BytesLike; + refundRecipient?: Address; + overrides?: ethers.PayableOverrides; + }): Promise { + const customBridgeData = + transaction.customBridgeData ?? + (await getERC20DefaultBridgeData( + transaction.token, + this._providerL1() + )); + const bridge = IL1SharedBridgeFactory.connect( + transaction.bridgeAddress!, + this._signerL1() + ); + const l2Address = await bridge.l2Bridge(); + return await estimateCustomBridgeDepositL2Gas( + this._providerL2(), + transaction.bridgeAddress!, + l2Address, + transaction.token, + transaction.amount, + transaction.to!, + customBridgeData, + await this.getAddress(), + transaction.gasPerPubdataByte + ); + } + /** * Retrieves the full needed ETH fee for the deposit. Returns the L1 fee and the L2 fee {@link FullDepositFee}. * @@ -556,92 +1206,82 @@ export function AdapterL1>(Base: TBase) { gasPerPubdataByte?: BigNumberish; overrides?: ethers.PayableOverrides; }): Promise { + if (isAddressEq(transaction.token, LEGACY_ETH_ADDRESS)) { + transaction.token = ETH_ADDRESS_IN_CONTRACTS; + } // It is assumed that the L2 fee for the transaction does not depend on its value. - const dummyAmount = '1'; + const token = transaction.token.toLowerCase(); + const dummyAmount = BigNumber.from(1); + const bridgehub = await this.getBridgehubContract(); + const chainId = (await this._providerL2().getNetwork()).chainId; + const baseTokenAddress = ( + await bridgehub.baseToken(chainId) + ).toLowerCase(); + const isEthBasedChain = isAddressEq( + baseTokenAddress, + ETH_ADDRESS_IN_CONTRACTS + ); - const {...tx} = transaction; - const zksyncContract = await this.getMainContract(); + const tx = await this._getDepositTxWithDefaults({ + ...transaction, + amount: dummyAmount, + }); - tx.overrides ??= {}; - await insertGasPrice(this._providerL1(), tx.overrides); - const gasPriceForMessages = + const gasPriceForEstimation = (await tx.overrides.maxFeePerGas) || (await tx.overrides.gasPrice); - - tx.to ??= await this.getAddress(); - tx.gasPerPubdataByte ??= REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_LIMIT; - - let l2GasLimit = null; - if (tx.bridgeAddress) { - const bridgeContracts = await this.getL1BridgeContracts(); - const customBridgeData = - tx.customBridgeData ?? - bridgeContracts.weth.address === tx.bridgeAddress - ? '0x' - : await getERC20DefaultBridgeData(tx.token, this._providerL1()); - const bridge = IL1BridgeFactory.connect( - tx.bridgeAddress, - this._signerL1() - ); - const l2Address = await bridge.l2Bridge(); - l2GasLimit ??= await estimateCustomBridgeDepositL2Gas( - this._providerL2(), - tx.bridgeAddress, - l2Address, - tx.token, - dummyAmount, - tx.to, - customBridgeData, - await this.getAddress(), - tx.gasPerPubdataByte - ); - } else { - l2GasLimit ??= await estimateDefaultBridgeDepositL2Gas( - this._providerL1(), - this._providerL2(), - tx.token, - dummyAmount, - tx.to, - await this.getAddress(), - tx.gasPerPubdataByte - ); - } - - const baseCost = await zksyncContract.l2TransactionBaseCost( - gasPriceForMessages!, - l2GasLimit, + const baseCost = await bridgehub.l2TransactionBaseCost( + chainId, + gasPriceForEstimation!, + tx.l2GasLimit, tx.gasPerPubdataByte ); - const selfBalanceETH = await this.getBalanceL1(); - - // We could use 0, because the final fee will anyway be bigger than - if (baseCost.gte(selfBalanceETH.add(dummyAmount))) { - const recommendedETHBalance = BigNumber.from( - tx.token === ETH_ADDRESS + if (isEthBasedChain) { + // To ensure that L1 gas estimation succeeds when using estimateGasDeposit, + // the account needs to have a sufficient ETH balance. + const selfBalanceETH = await this.getBalanceL1(); + if (baseCost.gte(selfBalanceETH.add(dummyAmount))) { + const recommendedL1GasLimit = isAddressEq( + tx.token, + ETH_ADDRESS_IN_CONTRACTS + ) ? L1_RECOMMENDED_MIN_ETH_DEPOSIT_GAS_LIMIT - : L1_RECOMMENDED_MIN_ERC20_DEPOSIT_GAS_LIMIT - ) - .mul(gasPriceForMessages!) - .add(baseCost); - const formattedRecommendedBalance = ethers.utils.formatEther( - recommendedETHBalance - ); - throw new Error( - `Not enough balance for deposit! Under the provided gas price, the recommended balance to perform a deposit is ${formattedRecommendedBalance} ETH.` - ); - } - - // For ETH token the value that the user passes to the estimation is the one which has the - // value for the L2 commission subtracted. - let amountForEstimate: BigNumber; - if (isETH(tx.token)) { - amountForEstimate = BigNumber.from(dummyAmount); - } else { - amountForEstimate = BigNumber.from(dummyAmount); - - if ((await this.getAllowanceL1(tx.token)) < amountForEstimate) { + : L1_RECOMMENDED_MIN_ERC20_DEPOSIT_GAS_LIMIT; + const recommendedETHBalance = BigNumber.from(recommendedL1GasLimit) + .mul(gasPriceForEstimation!) + .add(baseCost); + const formattedRecommendedBalance = ethers.utils.formatEther( + recommendedETHBalance + ); + throw new Error( + `Not enough balance for deposit! Under the provided gas price, the recommended balance to perform a deposit is ${formattedRecommendedBalance} ETH` + ); + } + // In case of token deposit, a sufficient token allowance is also required. + if ( + !isAddressEq(token, ETH_ADDRESS_IN_CONTRACTS) && + (await this.getAllowanceL1(tx.token, tx.bridgeAddress)) < dummyAmount + ) { throw new Error('Not enough allowance to cover the deposit!'); } + } else { + const mintValue = baseCost.add(tx.operatorTip); + if ((await this.getAllowanceL1(baseTokenAddress)) < mintValue) { + throw new Error( + 'Not enough base token allowance to cover the deposit!' + ); + } + if ( + isAddressEq(token, ETH_ADDRESS_IN_CONTRACTS) || + isAddressEq(token, baseTokenAddress) + ) { + tx.overrides.value ??= tx.amount; + } else { + tx.overrides.value ??= 0; + if ((await this.getAllowanceL1(tx.token)) < dummyAmount) { + throw new Error('Not enough token allowance to cover the deposit!'); + } + } } // Deleting the explicit gas limits in the fee estimation @@ -654,15 +1294,15 @@ export function AdapterL1>(Base: TBase) { const l1GasLimit = await this.estimateGasDeposit({ ...tx, - amount: amountForEstimate, + amount: dummyAmount, overrides: estimationOverrides, - l2GasLimit, + l2GasLimit: tx.l2GasLimit, }); const fullCost: FullDepositFee = { baseCost, l1GasLimit, - l2GasLimit, + l2GasLimit: BigNumber.from(tx.l2GasLimit), }; if (tx.overrides.gasPrice) { @@ -677,12 +1317,24 @@ export function AdapterL1>(Base: TBase) { return fullCost; } + /** + * Returns the transaction confirmation data that is part of `L2->L1` message. + * + * @param txHash The hash of the L2 transaction where the message was initiated. + * @param [index=0] In case there were multiple transactions in one message, you may pass an index of the + * transaction which confirmation data should be fetched. + * @throws {Error} If log proof can not be found. + */ + async getPriorityOpConfirmation(txHash: string, index = 0) { + return this._providerL2().getPriorityOpConfirmation(txHash, index); + } + async _getWithdrawalLog(withdrawalHash: BytesLike, index = 0) { const hash = ethers.utils.hexlify(withdrawalHash); const receipt = await this._providerL2().getTransactionReceipt(hash); const log = receipt.logs.filter( log => - log.address === L1_MESSENGER_ADDRESS && + isAddressEq(log.address, L1_MESSENGER_ADDRESS) && log.topics[0] === ethers.utils.id('L1MessageSent(address,bytes32,bytes)') )[index]; @@ -697,7 +1349,7 @@ export function AdapterL1>(Base: TBase) { const hash = ethers.utils.hexlify(withdrawalHash); const receipt = await this._providerL2().getTransactionReceipt(hash); const messages = Array.from(receipt.l2ToL1Logs.entries()).filter( - ([, log]) => log.sender === L1_MESSENGER_ADDRESS + ([, log]) => isAddressEq(log.sender, L1_MESSENGER_ADDRESS) ); const [l2ToL1LogIndex, l2ToL1Log] = messages[index]; @@ -765,54 +1417,16 @@ export function AdapterL1>(Base: TBase) { index = 0, overrides?: ethers.Overrides ): Promise { - const { - l1BatchNumber, - l2MessageIndex, - l2TxNumberInBlock, - message, - sender, - proof, - } = await this.finalizeWithdrawalParams(withdrawalHash, index); - - if (isETH(sender)) { - const withdrawTo = ethers.utils.hexDataSlice(message, 4, 24); - const l1Bridges = await this.getL1BridgeContracts(); - // If the destination address matches the address of the L1 WETH contract, - // the withdrawal request is processed through the WETH bridge. - if (withdrawTo.toLowerCase() === l1Bridges.weth.address.toLowerCase()) { - return await l1Bridges.weth.finalizeWithdrawal( - l1BatchNumber!, - l2MessageIndex, - l2TxNumberInBlock!, - message, - proof, - overrides ?? {} - ); - } + const {l1BatchNumber, l2MessageIndex, l2TxNumberInBlock, message, proof} = + await this.finalizeWithdrawalParams(withdrawalHash, index); - const contractAddress = - await this._providerL2().getMainContractAddress(); - const zksync = IZkSyncFactory.connect( - contractAddress, - this._signerL1() - ); - - return await zksync.finalizeEthWithdrawal( - l1BatchNumber!, - l2MessageIndex, - l2TxNumberInBlock!, - message, - proof, - overrides ?? {} - ); - } - - const l2Bridge = IL2BridgeFactory.connect(sender, this._providerL2()); - const l1Bridge = IL1BridgeFactory.connect( - await l2Bridge.l1Bridge(), + const l1SharedBridge = IL1SharedBridgeFactory.connect( + (await this.getL1BridgeContracts()).shared.address, this._signerL1() ); - return await l1Bridge.finalizeWithdrawal( + + return await l1SharedBridge.finalizeWithdrawal( + (await this._providerL2().getNetwork()).chainId, l1BatchNumber!, l2MessageIndex, l2TxNumberInBlock!, @@ -851,27 +1465,25 @@ export function AdapterL1>(Base: TBase) { throw new Error('Log proof not found!'); } - if (isETH(sender)) { - const contractAddress = - await this._providerL2().getMainContractAddress(); - const zksync = IZkSyncFactory.connect( - contractAddress, - this._signerL1() - ); + const chainId = (await this._providerL2().getNetwork()).chainId; + + let l1Bridge: IL1SharedBridge; - return await zksync.isEthWithdrawalFinalized( - log.l1BatchNumber, - proof.id + if (await this._providerL2().isBaseToken(sender)) { + l1Bridge = (await this.getL1BridgeContracts()).shared; + } else { + const l2Bridge = IL2BridgeFactory.connect(sender, this._providerL2()); + l1Bridge = IL1SharedBridgeFactory.connect( + await l2Bridge.l1Bridge(), + this._providerL1() ); } - const l2Bridge = IL2BridgeFactory.connect(sender, this._providerL2()); - const l1Bridge = IL1BridgeFactory.connect( - await l2Bridge.l1Bridge(), - this._providerL1() + return await l1Bridge.isWithdrawalFinalized( + chainId, + log.l1BatchNumber, + proof.id ); - - return await l1Bridge.isWithdrawalFinalized(log.l1BatchNumber, proof.id); } /** @@ -893,12 +1505,12 @@ export function AdapterL1>(Base: TBase) { ); const successL2ToL1LogIndex = receipt.l2ToL1Logs.findIndex( l2ToL1log => - l2ToL1log.sender === BOOTLOADER_FORMAL_ADDRESS && + isAddressEq(l2ToL1log.sender, BOOTLOADER_FORMAL_ADDRESS) && l2ToL1log.key === depositHash ); const successL2ToL1Log = receipt.l2ToL1Logs[successL2ToL1LogIndex]; if (successL2ToL1Log.value !== ethers.constants.HashZero) { - throw new Error('Cannot claim successful deposit!'); + throw new Error('Cannot claim successful deposit'); } const tx = await this._providerL2().getTransaction( @@ -909,7 +1521,7 @@ export function AdapterL1>(Base: TBase) { const l1BridgeAddress = undoL1ToL2Alias(receipt.from); const l2BridgeAddress = receipt.to; - const l1Bridge = IL1BridgeFactory.connect( + const l1Bridge = IL1SharedBridgeFactory.connect( l1BridgeAddress, this._signerL1() ); @@ -932,8 +1544,10 @@ export function AdapterL1>(Base: TBase) { } return await l1Bridge.claimFailedDeposit( + (await this._providerL2().getNetwork()).chainId, calldata['_l1Sender'], calldata['_l1Token'], + calldata['_amount'], depositHash, receipt.l1BatchNumber, proof.id, @@ -950,6 +1564,7 @@ export function AdapterL1>(Base: TBase) { * @param transaction.contractAddress The L2 contract to be called. * @param transaction.calldata The input of the L2 transaction. * @param [transaction.l2GasLimit] Maximum amount of L2 gas that transaction can consume during execution on L2. + * @param [transaction.mintValue] The amount of base token that needs to be minted on non-ETH-based L2. * @param [transaction.l2Value] `msg.value` of L2 transaction. * @param [transaction.factoryDeps] An array of L2 bytecodes that will be marked as known on L2. * @param [transaction.operatorTip] (currently not used) If the ETH value passed with the transaction is not @@ -965,6 +1580,7 @@ export function AdapterL1>(Base: TBase) { contractAddress: Address; calldata: BytesLike; l2GasLimit?: BigNumberish; + mintValue?: BigNumberish; l2Value?: BigNumberish; factoryDeps?: ethers.BytesLike[]; operatorTip?: BigNumberish; @@ -985,6 +1601,7 @@ export function AdapterL1>(Base: TBase) { * @param transaction.contractAddress The L2 contract to be called. * @param transaction.calldata The input of the L2 transaction. * @param [transaction.l2GasLimit] Maximum amount of L2 gas that transaction can consume during execution on L2. + * @param [transaction.mintValue] The amount of base token that needs to be minted on non-ETH-based L2. * @param [transaction.l2Value] `msg.value` of L2 transaction. * @param [transaction.factoryDeps] An array of L2 bytecodes that will be marked as known on L2. * @param [transaction.operatorTip] (currently not used) If the ETH value passed with the transaction is not @@ -999,6 +1616,7 @@ export function AdapterL1>(Base: TBase) { contractAddress: Address; calldata: BytesLike; l2GasLimit?: BigNumberish; + mintValue?: BigNumberish; l2Value?: BigNumberish; factoryDeps?: ethers.BytesLike[]; operatorTip?: BigNumberish; @@ -1015,6 +1633,65 @@ export function AdapterL1>(Base: TBase) { return this._providerL1().estimateGas(requestExecuteTx); } + /** + * Returns the parameters for the approval token transaction based on the request execute transaction. + * Existing allowance for the bridge is not checked; allowance is calculated solely based on the specified transaction. + * + * @param transaction The request execute transaction on which approval parameters are calculated. + */ + async getRequestExecuteAllowanceParams(transaction: { + contractAddress: Address; + calldata: BytesLike; + l2GasLimit?: BigNumberish; + l2Value?: BigNumberish; + factoryDeps?: ethers.BytesLike[]; + operatorTip?: BigNumberish; + gasPerPubdataByte?: BigNumberish; + refundRecipient?: Address; + overrides?: ethers.PayableOverrides; + }): Promise<{token: Address; allowance: BigNumberish}> { + const bridgehub = await this.getBridgehubContract(); + const chainId = (await this._providerL2().getNetwork()).chainId; + const isETHBaseToken = isAddressEq( + await bridgehub.baseToken(chainId), + ETH_ADDRESS_IN_CONTRACTS + ); + + if (isETHBaseToken) { + throw new Error( + "ETH token can't be approved! The address of the token does not exist on L1." + ); + } + + const {...tx} = transaction; + tx.l2Value ??= BigNumber.from(0); + tx.operatorTip ??= BigNumber.from(0); + tx.factoryDeps ??= []; + tx.overrides ??= {}; + tx.gasPerPubdataByte ??= REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_LIMIT; + tx.refundRecipient ??= await this.getAddress(); + tx.l2GasLimit ??= + await this._providerL2().estimateL1ToL2Execute(transaction); + + const {l2Value, l2GasLimit, operatorTip, overrides, gasPerPubdataByte} = + tx; + + await insertGasPrice(this._providerL1(), overrides); + const gasPriceForEstimation = + (await overrides.maxFeePerGas) || (await overrides.gasPrice); + + const baseCost = await this.getBaseCost({ + gasPrice: gasPriceForEstimation, + gasPerPubdataByte, + gasLimit: l2GasLimit, + }); + + return { + token: await this.getBaseToken(), + allowance: baseCost.add(operatorTip).add(l2Value), + }; + } + /** * Returns a populated request execute transaction. * @@ -1022,6 +1699,7 @@ export function AdapterL1>(Base: TBase) { * @param transaction.contractAddress The L2 contract to be called. * @param transaction.calldata The input of the L2 transaction. * @param [transaction.l2GasLimit] Maximum amount of L2 gas that transaction can consume during execution on L2. + * @param [transaction.mintValue] The amount of base token that needs to be minted on non-ETH-based L2. * @param [transaction.l2Value] `msg.value` of L2 transaction. * @param [transaction.factoryDeps] An array of L2 bytecodes that will be marked as known on L2. * @param [transaction.operatorTip] (currently not used) If the ETH value passed with the transaction is not @@ -1036,6 +1714,7 @@ export function AdapterL1>(Base: TBase) { contractAddress: Address; calldata: BytesLike; l2GasLimit?: BigNumberish; + mintValue?: BigNumberish; l2Value?: BigNumberish; factoryDeps?: ethers.BytesLike[]; operatorTip?: BigNumberish; @@ -1043,7 +1722,12 @@ export function AdapterL1>(Base: TBase) { refundRecipient?: Address; overrides?: ethers.PayableOverrides; }): Promise { - const zksyncContract = await this.getMainContract(); + const bridgehub = await this.getBridgehubContract(); + const chainId = (await this._providerL2().getNetwork()).chainId; + const isETHBaseToken = isAddressEq( + await bridgehub.baseToken(chainId), + ETH_ADDRESS_IN_CONTRACTS + ); const {...tx} = transaction; tx.l2Value ??= BigNumber.from(0); @@ -1058,6 +1742,7 @@ export function AdapterL1>(Base: TBase) { const { contractAddress, l2Value, + mintValue, calldata, l2GasLimit, factoryDeps, @@ -1069,26 +1754,35 @@ export function AdapterL1>(Base: TBase) { await insertGasPrice(this._providerL1(), overrides); const gasPriceForEstimation = - overrides.maxFeePerGas || overrides.gasPrice; + (await overrides.maxFeePerGas) || (await overrides.gasPrice); const baseCost = await this.getBaseCost({ - gasPrice: await gasPriceForEstimation, + gasPrice: gasPriceForEstimation, gasPerPubdataByte, gasLimit: l2GasLimit, }); - overrides.value ??= baseCost.add(operatorTip).add(l2Value); + const l2Costs = baseCost.add(operatorTip).add(l2Value); + let providedValue = isETHBaseToken ? overrides.value : mintValue; + if (providedValue === undefined || providedValue === null) { + providedValue = l2Costs; + if (isETHBaseToken) overrides.value = providedValue; + } - await checkBaseCost(baseCost, overrides.value); + await checkBaseCost(baseCost, providedValue); - return await zksyncContract.populateTransaction.requestL2Transaction( - contractAddress, - l2Value, - calldata, - l2GasLimit, - REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_LIMIT, - factoryDeps, - refundRecipient, + return await bridgehub.populateTransaction.requestL2TransactionDirect( + { + chainId, + mintValue: await providedValue, + l2Contract: contractAddress, + l2Value: l2Value, + l2Calldata: calldata, + l2GasLimit: l2GasLimit, + l2GasPerPubdataByteLimit: REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_LIMIT, + factoryDeps: factoryDeps, + refundRecipient: refundRecipient, + }, overrides ); } @@ -1150,11 +1844,16 @@ export function AdapterL2>(Base: TBase) { /** * Returns L2 bridge contracts. */ - async getL2BridgeContracts(): Promise<{erc20: Il2Bridge; weth: Il2Bridge}> { + async getL2BridgeContracts(): Promise<{ + erc20: IL2Bridge; + weth: IL2Bridge; + shared: IL2Bridge; + }> { const addresses = await this._providerL2().getDefaultBridgeAddresses(); return { - erc20: IL2BridgeFactory.connect(addresses.erc20L2!, this._signerL2()), - weth: IL2BridgeFactory.connect(addresses.wethL2!, this._signerL2()), + erc20: IL2BridgeFactory.connect(addresses.erc20L2, this._signerL2()), + weth: IL2BridgeFactory.connect(addresses.wethL2, this._signerL2()), + shared: IL2BridgeFactory.connect(addresses.sharedL2, this._signerL2()), }; } diff --git a/src/provider.ts b/src/provider.ts index d29014fc..e9110bea 100644 --- a/src/provider.ts +++ b/src/provider.ts @@ -10,7 +10,7 @@ import { import {ExternalProvider} from '@ethersproject/providers'; import {ConnectionInfo, poll} from '@ethersproject/web'; import {Ierc20Factory as IERC20Factory} from './typechain/Ierc20Factory'; -import {IEthTokenFactory as IEthTokenFactory} from './typechain/IEthTokenFactory'; +import {IEthTokenFactory} from './typechain/IEthTokenFactory'; import {Il2BridgeFactory as IL2BridgeFactory} from './typechain/Il2BridgeFactory'; import { Address, @@ -38,16 +38,19 @@ import { Eip712Meta, } from './types'; import { + BOOTLOADER_FORMAL_ADDRESS, CONTRACT_DEPLOYER, CONTRACT_DEPLOYER_ADDRESS, EIP712_TX_TYPE, - ETH_ADDRESS, + LEGACY_ETH_ADDRESS, + ETH_ADDRESS_IN_CONTRACTS, getL2HashFromPriorityOp, - isETH, - L2_ETH_TOKEN_ADDRESS, + L2_BASE_TOKEN_ADDRESS, parseTransaction, REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_LIMIT, sleep, + isETH, + isAddressEq, } from './utils'; import {Signer} from './signer'; import Formatter = providers.Formatter; @@ -61,11 +64,15 @@ let defaultFormatter: Formatter | null = null; export class Provider extends ethers.providers.JsonRpcProvider { private static _nextPollId = 1; protected contractAddresses: { + bridgehubContract?: Address; mainContract?: Address; erc20BridgeL1?: Address; erc20BridgeL2?: Address; wethBridgeL1?: Address; wethBridgeL2?: Address; + sharedBridgeL1?: Address; + sharedBridgeL2?: Address; + baseToken?: Address; }; // NOTE: this is almost a complete copy-paste of the parent poll method @@ -493,8 +500,8 @@ export class Provider extends ethers.providers.JsonRpcProvider { tokenAddress?: Address ): Promise { const tag = this.formatter.blockTag(blockTag); - if (!tokenAddress || isETH(tokenAddress)) { - // requesting ETH balance + if (!tokenAddress || (await this.isBaseToken(tokenAddress))) { + // requesting base token balance return await super.getBalance(address, tag); } else { try { @@ -522,29 +529,21 @@ export class Provider extends ethers.providers.JsonRpcProvider { * console.log(`L2 token address: ${await provider.l2TokenAddress("0x5C221E77624690fff6dd741493D735a17716c26B")}`); */ async l2TokenAddress(token: Address): Promise { - if (token === ETH_ADDRESS) { - return ETH_ADDRESS; + if (isAddressEq(token, LEGACY_ETH_ADDRESS)) { + token = ETH_ADDRESS_IN_CONTRACTS; } - const bridgeAddresses = await this.getDefaultBridgeAddresses(); - const l2WethBridge = IL2BridgeFactory.connect( - bridgeAddresses.wethL2!, - this - ); - try { - const l2WethToken = await l2WethBridge.l2TokenAddress(token); - // If the token is Wrapped Ether, return its L2 token address - if (l2WethToken !== ethers.constants.AddressZero) { - return l2WethToken; - } - } catch (e) { - // skip + const baseToken = await this.getBaseTokenContractAddress(); + if (isAddressEq(token, baseToken)) { + return L2_BASE_TOKEN_ADDRESS; } - const l2Erc20Bridge = IL2BridgeFactory.connect( - bridgeAddresses.erc20L2!, + + const bridgeAddresses = await this.getDefaultBridgeAddresses(); + const l2SharedBridge = IL2BridgeFactory.connect( + bridgeAddresses.sharedL2, this ); - return await l2Erc20Bridge.l2TokenAddress(token); + return await l2SharedBridge.l2TokenAddress(token); } /** @@ -562,30 +561,18 @@ export class Provider extends ethers.providers.JsonRpcProvider { * const provider = Provider.getDefaultProvider(types.Network.Sepolia); * console.log(`L1 token address: ${await provider.l1TokenAddress("0x3e7676937A7E96CFB7616f255b9AD9FF47363D4b")}`); */ - async l1TokenAddress(token: Address): Promise { - if (token === ETH_ADDRESS) { - return ETH_ADDRESS; + async l1TokenAddress(token: Address) { + if (isAddressEq(token, LEGACY_ETH_ADDRESS)) { + return LEGACY_ETH_ADDRESS; } const bridgeAddresses = await this.getDefaultBridgeAddresses(); - const l2WethBridge = IL2BridgeFactory.connect( - bridgeAddresses.wethL2!, - this - ); - try { - const l1WethToken = await l2WethBridge.l1TokenAddress(token); - // If the token is Wrapped Ether, return its L1 token address - if (l1WethToken !== ethers.constants.AddressZero) { - return l1WethToken; - } - } catch (e) { - // skip - } - const erc20Bridge = IL2BridgeFactory.connect( - bridgeAddresses.erc20L2!, + + const sharedBridge = IL2BridgeFactory.connect( + bridgeAddresses.sharedL2, this ); - return await erc20Bridge.l1TokenAddress(token); + return await sharedBridge.l1TokenAddress(token); } /** @@ -834,6 +821,28 @@ export class Provider extends ethers.providers.JsonRpcProvider { return [parseInt(range[0], 16), parseInt(range[1], 16)]; } + /** + * Returns the Bridgehub smart contract address. + * + * Calls the {@link https://docs.zksync.io/build/api.html#zks-getbridgehubcontract zks_getBridgehubContract} JSON-RPC method. + * + * @example + * + * import { Provider, types } from "zksync-ethers"; + * + * const provider = Provider.getDefaultProvider(types.Network.Sepolia); + * console.log(`Bridgehub: ${await provider.getBridgehubContractAddress()}`); + */ + async getBridgehubContractAddress(): Promise
{ + if (!this.contractAddresses.bridgehubContract) { + this.contractAddresses.bridgehubContract = await this.send( + 'zks_getBridgehubContract', + [] + ); + } + return this.contractAddresses.bridgehubContract!; + } + /** * Returns the main zkSync Era smart contract address. * @@ -844,6 +853,7 @@ export class Provider extends ethers.providers.JsonRpcProvider { * import { Provider, types } from "zksync-ethers"; * * const provider = Provider.getDefaultProvider(types.Network.Sepolia); + * console.log(`Main contract: ${await provider.getMainContractAddress()}`); */ async getMainContractAddress(): Promise
{ if (!this.contractAddresses.mainContract) { @@ -855,6 +865,62 @@ export class Provider extends ethers.providers.JsonRpcProvider { return this.contractAddresses.mainContract!; } + /** + * Returns the L1 base token address. + * + * Calls the {@link https://docs.zksync.io/build/api.html#zks-getbasetokenl1address zks_getBaseTokenL1Address} JSON-RPC method. + * + * @example + * + * import { Provider, types } from "zksync-ethers"; + * + * const provider = Provider.getDefaultProvider(types.Network.Sepolia); + * console.log(`Base token: ${await provider.getBaseTokenContractAddress()}`); + */ + async getBaseTokenContractAddress(): Promise
{ + if (!this.contractAddresses.baseToken) { + this.contractAddresses.baseToken = await this.send( + 'zks_getBaseTokenL1Address', + [] + ); + } + return ethers.utils.getAddress(this.contractAddresses.baseToken!); + } + + /** + * Returns whether the chain is ETH-based. + * + * @example + * + * import { Provider, types } from "zksync-ethers"; + * + * const provider = Provider.getDefaultProvider(types.Network.Sepolia); + * console.log(`Is ETH based chain: ${await provider.isEthBasedChain()}`); + */ + async isEthBasedChain(): Promise { + return isAddressEq( + await this.getBaseTokenContractAddress(), + ETH_ADDRESS_IN_CONTRACTS + ); + } + + /** + * Returns whether the `token` is the base token. + * + * @example + * + * import { Provider, types } from "zksync-ethers"; + * + * const provider = Provider.getDefaultProvider(types.Network.Sepolia); + * console.log(`Is base token: ${await provider.isBaseToken("0x5C221E77624690fff6dd741493D735a17716c26B")}`); + */ + async isBaseToken(token: Address): Promise { + return ( + isAddressEq(token, await this.getBaseTokenContractAddress()) || + isAddressEq(token, L2_BASE_TOKEN_ADDRESS) + ); + } + /** * Returns the testnet {@link https://docs.zksync.io/build/developer-reference/account-abstraction.html#paymasters paymaster address} * if available, or `null`. @@ -887,10 +953,12 @@ export class Provider extends ethers.providers.JsonRpcProvider { * console.log(`Default bridges: ${utils.toJSON(await provider.getDefaultBridgeAddresses())}`); */ async getDefaultBridgeAddresses(): Promise<{ - erc20L1: string | undefined; - erc20L2: string | undefined; - wethL1: string | undefined; - wethL2: string | undefined; + erc20L1: string; + erc20L2: string; + wethL1: string; + wethL2: string; + sharedL1: string; + sharedL2: string; }> { if (!this.contractAddresses.erc20BridgeL1) { const addresses: { @@ -898,17 +966,23 @@ export class Provider extends ethers.providers.JsonRpcProvider { l2Erc20DefaultBridge: string; l1WethBridge: string; l2WethBridge: string; + l1SharedDefaultBridge: string; + l2SharedDefaultBridge: string; } = await this.send('zks_getBridgeContracts', []); this.contractAddresses.erc20BridgeL1 = addresses.l1Erc20DefaultBridge; this.contractAddresses.erc20BridgeL2 = addresses.l2Erc20DefaultBridge; this.contractAddresses.wethBridgeL1 = addresses.l1WethBridge; this.contractAddresses.wethBridgeL2 = addresses.l2WethBridge; + this.contractAddresses.sharedBridgeL1 = addresses.l1SharedDefaultBridge; + this.contractAddresses.sharedBridgeL2 = addresses.l2SharedDefaultBridge; } return { erc20L1: this.contractAddresses.erc20BridgeL1, - erc20L2: this.contractAddresses.erc20BridgeL2, - wethL1: this.contractAddresses.wethBridgeL1, - wethL2: this.contractAddresses.wethBridgeL2, + erc20L2: this.contractAddresses.erc20BridgeL2!, + wethL1: this.contractAddresses.wethBridgeL1!, + wethL2: this.contractAddresses.wethBridgeL2!, + sharedL1: this.contractAddresses.sharedBridgeL1!, + sharedL2: this.contractAddresses.sharedBridgeL2!, }; } @@ -1174,6 +1248,9 @@ export class Provider extends ethers.providers.JsonRpcProvider { overrides?: ethers.CallOverrides; }): Promise { const {...tx} = transaction; + if (isAddressEq(tx.token, LEGACY_ETH_ADDRESS)) { + tx.token = ETH_ADDRESS_IN_CONTRACTS; + } if (!tx.to && !tx.from) { throw new Error('Withdrawal target address is undefined!'); @@ -1196,7 +1273,7 @@ export class Provider extends ethers.providers.JsonRpcProvider { throw new Error('The tx.value is not equal to the value withdrawn!'); } - const ethL2Token = IEthTokenFactory.connect(L2_ETH_TOKEN_ADDRESS, this); + const ethL2Token = IEthTokenFactory.connect(L2_BASE_TOKEN_ADDRESS, this); const populatedTx = await ethL2Token.populateTransaction.withdraw( tx.to!, tx.overrides @@ -1214,20 +1291,7 @@ export class Provider extends ethers.providers.JsonRpcProvider { if (!tx.bridgeAddress) { const bridgeAddresses = await this.getDefaultBridgeAddresses(); - const l2WethBridge = IL2BridgeFactory.connect( - bridgeAddresses.wethL2!, - this - ); - let l1WethToken = ethers.constants.AddressZero; - try { - l1WethToken = await l2WethBridge.l1TokenAddress(tx.token); - } catch (e) { - // skip - } - tx.bridgeAddress = - l1WethToken !== ethers.constants.AddressZero - ? bridgeAddresses.wethL2 - : bridgeAddresses.erc20L2; + tx.bridgeAddress = bridgeAddresses.sharedL2; } const bridge = IL2BridgeFactory.connect(tx.bridgeAddress!, this); @@ -1344,7 +1408,11 @@ export class Provider extends ethers.providers.JsonRpcProvider { tx.overrides ??= {}; tx.overrides.from ??= tx.from; - if (!tx.token || tx.token === ETH_ADDRESS) { + if ( + !tx.token || + isAddressEq(tx.token, LEGACY_ETH_ADDRESS) || + (await this.isBaseToken(tx.token)) + ) { if (tx.paymasterParams) { return { ...(await ethers.utils.resolveProperties(tx.overrides)), @@ -1729,6 +1797,54 @@ export class Provider extends ethers.providers.JsonRpcProvider { return l2Response; } + async _getPriorityOpConfirmationL2ToL1Log(txHash: string, index = 0) { + const hash = ethers.utils.hexlify(txHash); + const receipt = await this.getTransactionReceipt(hash); + const messages = Array.from(receipt.l2ToL1Logs.entries()).filter( + ([, log]) => isAddressEq(log.sender, BOOTLOADER_FORMAL_ADDRESS) + ); + const [l2ToL1LogIndex, l2ToL1Log] = messages[index]; + + return { + l2ToL1LogIndex, + l2ToL1Log, + l1BatchTxId: receipt.l1BatchTxIndex, + }; + } + + /** + * Returns the transaction confirmation data that is part of `L2->L1` message. + * + * @param txHash The hash of the L2 transaction where the message was initiated. + * @param [index=0] In case there were multiple transactions in one message, you may pass an index of the + * transaction which confirmation data should be fetched. + * @throws {Error} If log proof can not be found. + * + * @example + * + * import { Provider, types, utils } from "zksync-ethers"; + * + * const provider = Provider.getDefaultProvider(types.Network.Sepolia); + * // Any L2 -> L1 transaction can be used. + * // In this case, withdrawal transaction is used. + * const tx = "0x2a1c6c74b184965c0cb015aae9ea134fd96215d2e4f4979cfec12563295f610e"; + * console.log(`Confirmation data: ${utils.toJSON(await provider.getPriorityOpConfirmation(tx, 0))}`); + */ + async getPriorityOpConfirmation(txHash: string, index = 0) { + const {l2ToL1LogIndex, l2ToL1Log, l1BatchTxId} = + await this._getPriorityOpConfirmationL2ToL1Log(txHash, index); + const proof = await this.getLogProof(txHash, l2ToL1LogIndex); + if (!proof) { + throw new Error('Log proof not found!'); + } + return { + l1BatchNumber: l2ToL1Log.l1BatchNumber, + l2MessageIndex: proof.id, + l2TxNumberInBlock: l1BatchTxId, + proof: proof.proof, + }; + } + /** * Returns the version of the supported account abstraction and nonce ordering from a given contract address. * @@ -2121,13 +2237,15 @@ export class Web3Provider extends Provider { * import { Web3Provider } from "zksync-ethers"; * * const provider = new Web3Provider(window.ethereum); - * console.log(`Default bridges: ${await provider.getDefaultBridgeAddresses()}`); + * console.log(`Bridge addresses: ${await provider.getDefaultBridgeAddresses()}`); */ override async getDefaultBridgeAddresses(): Promise<{ - erc20L1: string | undefined; - erc20L2: string | undefined; - wethL1: string | undefined; - wethL2: string | undefined; + erc20L1: string; + erc20L2: string; + wethL1: string; + wethL2: string; + sharedL1: string; + sharedL2: string; }> { return super.getDefaultBridgeAddresses(); } diff --git a/src/signer.ts b/src/signer.ts index 9ede871f..a93ffd46 100644 --- a/src/signer.ts +++ b/src/signer.ts @@ -1,9 +1,17 @@ -import {BigNumber, BigNumberish, BytesLike, ethers, Overrides} from 'ethers'; +import { + BigNumber, + BigNumberish, + BytesLike, + ethers, + Overrides, + PopulatedTransaction, +} from 'ethers'; import {Provider} from './provider'; import { DEFAULT_GAS_PER_PUBDATA_LIMIT, EIP712_TX_TYPE, hashBytecode, + isAddressEq, serialize, } from './utils'; import { @@ -21,9 +29,11 @@ import { import {TypedDataDomain, TypedDataSigner} from '@ethersproject/abstract-signer'; import {_TypedDataEncoder as TypedDataEncoder} from '@ethersproject/hash'; import {AdapterL1, AdapterL2} from './adapters'; -import {Il2Bridge} from './typechain/Il2Bridge'; -import {IZkSync} from './typechain/IZkSync'; -import {Il1Bridge} from './typechain/Il1Bridge'; +import {Il2Bridge as IL2Bridge} from './typechain/Il2Bridge'; +import {Il1Erc20Bridge as IL1ERC20Bridge} from './typechain/Il1Erc20Bridge'; +import {Il1SharedBridge as IL1SharedBridge} from './typechain/Il1SharedBridge'; +import {IZkSyncStateTransition} from './typechain/IZkSyncStateTransition'; +import {IBridgehub} from './typechain/IBridgehub'; /** * All typed data conforming to the EIP712 standard within zkSync Era. @@ -268,8 +278,9 @@ export class Signer extends AdapterL2(ethers.providers.JsonRpcSigner) { * const l2BridgeContracts = await signer.getL2BridgeContracts(); */ override async getL2BridgeContracts(): Promise<{ - erc20: Il2Bridge; - weth: Il2Bridge; + erc20: IL2Bridge; + weth: IL2Bridge; + shared: IL2Bridge; }> { return super.getL2BridgeContracts(); } @@ -277,7 +288,7 @@ export class Signer extends AdapterL2(ethers.providers.JsonRpcSigner) { /** * @inheritDoc * - * @example Withdraw ETH. + * @example Withdraw token. * * import { Web3Provider, Provider, types, utils } from "zksync-ethers"; * @@ -565,7 +576,7 @@ export class Signer extends AdapterL2(ethers.providers.JsonRpcSigner) { } else { const address = await this.getAddress(); transaction.from ??= address; - if (transaction.from.toLowerCase() !== address.toLowerCase()) { + if (!isAddressEq(transaction.from, address)) { throw new Error('Transaction `from` address mismatch!'); } transaction.type = EIP712_TX_TYPE; @@ -622,12 +633,31 @@ export class L1Signer extends AdapterL1(ethers.providers.JsonRpcSigner) { * ); * * const mainContract = await signer.getMainContract(); - * console.log(mainContract.address); */ - override async getMainContract(): Promise { + override async getMainContract(): Promise { return super.getMainContract(); } + /** + * @inheritDoc + * + * @example + * + * import { Provider, L1Signer, types } from "zksync-ethers"; + * import { ethers } from "ethers"; + * + * const browserProvider = new ethers.providers.Web3Provider(window.ethereum); + * const signer = L1Signer.from( + * browserProvider.getSigner(), + * Provider.getDefaultProvider(types.Network.Sepolia) + * ); + * + * const bridgehub = await signer.getBridgehubContract(); + */ + override async getBridgehubContract(): Promise { + return super.getBridgehubContract(); + } + /** * @inheritDoc * @@ -645,8 +675,9 @@ export class L1Signer extends AdapterL1(ethers.providers.JsonRpcSigner) { * const l1BridgeContracts = await signer.getL1BridgeContracts(); */ override async getL1BridgeContracts(): Promise<{ - erc20: Il1Bridge; - weth: Il1Bridge; + erc20: IL1ERC20Bridge; + weth: IL1ERC20Bridge; + shared: IL1SharedBridge; }> { return super.getL1BridgeContracts(); } @@ -789,7 +820,167 @@ export class L1Signer extends AdapterL1(ethers.providers.JsonRpcSigner) { /** * @inheritDoc * - * @example Deposit ETH. + * @example + * + * import { Provider, L1Signer, types } from "zksync-ethers"; + * import { ethers } from "ethers"; + * + * const browserProvider = new ethers.providers.Web3Provider(window.ethereum); + * const signer = L1Signer.from( + * browserProvider.getSigner(), + * Provider.getDefaultProvider(types.Network.Sepolia) + * ); + * + * console.log(`Base token: ${await signer.getBaseToken()}`); + */ + override async getBaseToken(): Promise { + return super.getBaseToken(); + } + + /** + * @inheritDoc + * + * @example + * + * import { Provider, L1Signer, types } from "zksync-ethers"; + * import { ethers } from "ethers"; + * + * const browserProvider = new ethers.providers.Web3Provider(window.ethereum); + * const signer = L1Signer.from( + * browserProvider.getSigner(), + * Provider.getDefaultProvider(types.Network.Sepolia) + * ); + * + * console.log(`Is ETH-based chain: ${await signer.isETHBasedChain()}`); + */ + override async isETHBasedChain(): Promise { + return super.isETHBasedChain(); + } + + /** + * @inheritDoc + * + * @example Get allowance parameters for depositing ETH on non-ETH-based chain. + * + * import { Provider, L1Signer, types } from "zksync-ethers"; + * import { ethers } from "ethers"; + * + * const browserProvider = new ethers.providers.Web3Provider(window.ethereum); + * const signer = L1Signer.from( + * browserProvider.getSigner(), + * Provider.getDefaultProvider(types.Network.Sepolia) + * ); + * + * const token = utils.LEGACY_ETH_ADDRESS; + * const amount = 5; + * const approveParams = await signer.getDepositAllowanceParams(token, amount); + * await ( + * await signer.approveERC20( + * approveParams[0].token, + * approveParams[0].allowance + * ) + * ).wait(); + * + * @example Get allowance parameters for depositing base token on non-ETH-based chain. + * + * import { Provider, L1Signer, types } from "zksync-ethers"; + * import { ethers } from "ethers"; + * + * const browserProvider = new ethers.providers.Web3Provider(window.ethereum); + * const signer = L1Signer.from( + * browserProvider.getSigner(), + * Provider.getDefaultProvider(types.Network.Sepolia) + * ); + * + * const token = await signer.getBaseToken(); + * const amount = 5; + * const approveParams = await signer.getDepositAllowanceParams(token, amount); + * await ( + * await signer.approveERC20( + * approveParams[0].token, + * approveParams[0].allowance + * ) + * ).wait(); + * + * @example Get allowance parameters for depositing non-base token on non-ETH-based chain. + * + * import { Provider, L1Signer, types } from "zksync-ethers"; + * import { ethers } from "ethers"; + * + * const browserProvider = new ethers.providers.Web3Provider(window.ethereum); + * const signer = L1Signer.from( + * browserProvider.getSigner(), + * Provider.getDefaultProvider(types.Network.Sepolia) + * ); + * + * const token = ""; + * const amount = 5; + * const approveParams = await signer.getDepositAllowanceParams(token, amount); + * + * await ( + * await signer.approveERC20( + * approveParams[0].token, + * approveParams[0].allowance + * ) + * ).wait(); + * + * await ( + * await signer.approveERC20( + * approveParams[1].token, + * approveParams[1].allowance + * ) + * ).wait(); + */ + override async getDepositAllowanceParams( + token: Address, + amount: BigNumberish + ): Promise< + { + token: Address; + allowance: BigNumberish; + }[] + > { + return super.getDepositAllowanceParams(token, amount); + } + + /** + * @inheritDoc + * + * @example Deposit ETH on ETH-based chain. + * + * import { Provider, L1Signer, types } from "zksync-ethers"; + * import { ethers } from "ethers"; + * + * const browserProvider = new ethers.providers.Web3Provider(window.ethereum); + * const signer = L1Signer.from( + * browserProvider.getSigner(), + * Provider.getDefaultProvider(types.Network.Sepolia) + * ); + * + * await signer.deposit({ + * token: utils.ETH_ADDRESS, + * amount: 10_000_000, + * }); + * + * @example Deposit token on ETH-based chain. + * + * import { Provider, L1Signer, types } from "zksync-ethers"; + * import { ethers } from "ethers"; + * + * const browserProvider = new ethers.providers.Web3Provider(window.ethereum); + * const signer = L1Signer.from( + * browserProvider.getSigner(), + * Provider.getDefaultProvider(types.Network.Sepolia) + * ); + * + * const tokenL1 = "0x56E69Fa1BB0d1402c89E3A4E3417882DeA6B14Be"; + * await signer.deposit({ + * token: tokenL1, + * amount: 10_000_000, + * approveERC20: true, + * }); + * + * @example Deposit ETH on non-ETH-chain. * * import { Provider, L1Signer, types } from "zksync-ethers"; * import { ethers } from "ethers"; @@ -803,9 +994,27 @@ export class L1Signer extends AdapterL1(ethers.providers.JsonRpcSigner) { * await signer.deposit({ * token: utils.ETH_ADDRESS, * amount: 10_000_000, + * approveBaseERC20: true, * }); * - * @example Deposit token. + * @example Deposit base token on non-ETH-based chain. + * + * import { Provider, L1Signer, types } from "zksync-ethers"; + * import { ethers } from "ethers"; + * + * const browserProvider = new ethers.providers.Web3Provider(window.ethereum); + * const signer = L1Signer.from( + * browserProvider.getSigner(), + * Provider.getDefaultProvider(types.Network.Sepolia) + * ); + * + * await signer.deposit({ + * token: await signer.getBaseToken(), + * amount: 10_000_000, + * approveERC20: true, // or approveBaseERC20: true + * }); + * + * @example Deposit non-base token on non-ETH-based chain. * * import { Provider, L1Signer, types } from "zksync-ethers"; * import { ethers } from "ethers"; @@ -821,6 +1030,7 @@ export class L1Signer extends AdapterL1(ethers.providers.JsonRpcSigner) { * token: tokenL1, * amount: 10_000_000, * approveERC20: true, + * approveBaseERC20: true, * }); */ override async deposit(transaction: { @@ -830,11 +1040,13 @@ export class L1Signer extends AdapterL1(ethers.providers.JsonRpcSigner) { operatorTip?: BigNumberish; bridgeAddress?: Address; approveERC20?: boolean; + approveBaseERC20?: boolean; l2GasLimit?: BigNumberish; gasPerPubdataByte?: BigNumberish; refundRecipient?: Address; - overrides?: Overrides; + overrides?: ethers.PayableOverrides; approveOverrides?: Overrides; + approveBaseOverrides?: Overrides; customBridgeData?: BytesLike; }): Promise { return super.deposit(transaction); @@ -871,7 +1083,7 @@ export class L1Signer extends AdapterL1(ethers.providers.JsonRpcSigner) { l2GasLimit?: BigNumberish; gasPerPubdataByte?: BigNumberish; refundRecipient?: Address; - overrides?: Overrides; + overrides?: ethers.PayableOverrides; }): Promise { return super.estimateGasDeposit(transaction); } @@ -906,7 +1118,7 @@ export class L1Signer extends AdapterL1(ethers.providers.JsonRpcSigner) { gasPerPubdataByte?: BigNumberish; customBridgeData?: BytesLike; refundRecipient?: Address; - overrides?: Overrides; + overrides?: ethers.PayableOverrides; }): Promise { return super.getDepositTx(transaction); } @@ -938,7 +1150,7 @@ export class L1Signer extends AdapterL1(ethers.providers.JsonRpcSigner) { bridgeAddress?: Address; customBridgeData?: BytesLike; gasPerPubdataByte?: BigNumberish; - overrides?: Overrides; + overrides?: ethers.PayableOverrides; }): Promise { return super.getFullRequiredDepositFee(transaction); } @@ -1040,6 +1252,48 @@ export class L1Signer extends AdapterL1(ethers.providers.JsonRpcSigner) { return super.claimFailedDeposit(depositHash, overrides); } + /** + * @inheritDoc + * + * @example + * + * import { Provider, L1Signer, types } from "zksync-ethers"; + * import { ethers } from "ethers"; + * + * const browserProvider = new ethers.providers.Web3Provider(window.ethereum); + * const signer = L1Signer.from( + * browserProvider.getSigner(), + * Provider.getDefaultProvider(types.Network.Sepolia) + * ); + * + * const tx = { + * contractAddress: await signer.getAddress(), + * calldata: '0x', + * l2Value: 7_000_000_000, + * }; + * + * const approveParams = await signer.getRequestExecuteAllowanceParams(tx); + * await ( + * await signer.approveERC20( + * approveParams.token, + * approveParams.allowance + * ) + * ).wait(); + */ + override async getRequestExecuteAllowanceParams(transaction: { + contractAddress: Address; + calldata: BytesLike; + l2GasLimit?: BigNumberish; + l2Value?: BigNumberish; + factoryDeps?: BytesLike[]; + operatorTip?: BigNumberish; + gasPerPubdataByte?: BigNumberish; + refundRecipient?: Address; + overrides?: ethers.PayableOverrides; + }): Promise<{token: Address; allowance: BigNumberish}> { + return super.getRequestExecuteAllowanceParams(transaction); + } + /** * @inheritDoc * @@ -1062,14 +1316,15 @@ export class L1Signer extends AdapterL1(ethers.providers.JsonRpcSigner) { */ override async requestExecute(transaction: { contractAddress: Address; - calldata: string; + calldata: BytesLike; l2GasLimit?: BigNumberish; + mintValue?: BigNumberish; l2Value?: BigNumberish; factoryDeps?: BytesLike[]; operatorTip?: BigNumberish; gasPerPubdataByte?: BigNumberish; refundRecipient?: Address; - overrides?: Overrides; + overrides?: ethers.PayableOverrides; }): Promise { return super.requestExecute(transaction); } @@ -1098,14 +1353,15 @@ export class L1Signer extends AdapterL1(ethers.providers.JsonRpcSigner) { */ override async estimateGasRequestExecute(transaction: { contractAddress: Address; - calldata: string; + calldata: BytesLike; l2GasLimit?: BigNumberish; + mintValue?: BigNumberish; l2Value?: BigNumberish; factoryDeps?: BytesLike[]; operatorTip?: BigNumberish; gasPerPubdataByte?: BigNumberish; refundRecipient?: Address; - overrides?: Overrides; + overrides?: ethers.PayableOverrides; }): Promise { return super.estimateGasRequestExecute(transaction); } @@ -1132,18 +1388,50 @@ export class L1Signer extends AdapterL1(ethers.providers.JsonRpcSigner) { */ override async getRequestExecuteTx(transaction: { contractAddress: Address; - calldata: string; + calldata: BytesLike; l2GasLimit?: BigNumberish; + mintValue?: BigNumberish; l2Value?: BigNumberish; factoryDeps?: BytesLike[]; operatorTip?: BigNumberish; gasPerPubdataByte?: BigNumberish; refundRecipient?: Address; - overrides?: Overrides; - }): Promise { + overrides?: ethers.PayableOverrides; + }): Promise { return super.getRequestExecuteTx(transaction); } + /** + * @inheritDoc + * + * @example + * + * import { Provider, L1Signer, types } from "zksync-ethers"; + * import { ethers } from "ethers"; + * + * const browserProvider = new ethers.providers.Web3Provider(window.ethereum); + * const signer = L1Signer.from( + * browserProvider.getSigner(), + * Provider.getDefaultProvider(types.Network.Sepolia) + * ); + * + * // Any L2 -> L1 transaction can be used. + * // In this case, withdrawal transaction is used. + * const tx = "0x2a1c6c74b184965c0cb015aae9ea134fd96215d2e4f4979cfec12563295f610e"; + * console.log(`Confirmation data: ${utils.toJSON(await signer.getPriorityOpConfirmation(tx, 0))}`); + */ + override async getPriorityOpConfirmation( + txHash: string, + index = 0 + ): Promise<{ + l1BatchNumber: number; + l2MessageIndex: number; + l2TxNumberInBlock: number; + proof: string[]; + }> { + return super.getPriorityOpConfirmation(txHash, index); + } + /** * Creates a new L1Singer with provided `signer` and `zksyncProvider`. * diff --git a/src/typechain/IBridgehub.d.ts b/src/typechain/IBridgehub.d.ts new file mode 100644 index 00000000..282a145c --- /dev/null +++ b/src/typechain/IBridgehub.d.ts @@ -0,0 +1,1737 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { + ethers, + EventFilter, + Signer, + BigNumber, + BigNumberish, + PopulatedTransaction, +} from "ethers"; +import { + Contract, + ContractTransaction, + Overrides, + PayableOverrides, + CallOverrides, +} from "@ethersproject/contracts"; +import { BytesLike } from "@ethersproject/bytes"; +import { Listener, Provider } from "@ethersproject/providers"; +import { FunctionFragment, EventFragment, Result } from "@ethersproject/abi"; + +interface IBridgehubInterface extends ethers.utils.Interface { + functions: { + "acceptAdmin()": FunctionFragment; + "addStateTransitionManager(address)": FunctionFragment; + "addToken(address)": FunctionFragment; + "baseToken(uint256)": FunctionFragment; + "createNewChain(uint256,address,address,uint256,address,bytes)": FunctionFragment; + "getStateTransition(uint256)": FunctionFragment; + "l2TransactionBaseCost(uint256,uint256,uint256,uint256)": FunctionFragment; + "proveL1ToL2TransactionStatus(uint256,bytes32,uint256,uint256,uint16,bytes32[],uint8)": FunctionFragment; + "proveL2LogInclusion(uint256,uint256,uint256,tuple,bytes32[])": FunctionFragment; + "proveL2MessageInclusion(uint256,uint256,uint256,tuple,bytes32[])": FunctionFragment; + "removeStateTransitionManager(address)": FunctionFragment; + "requestL2TransactionDirect(tuple)": FunctionFragment; + "requestL2TransactionTwoBridges(tuple)": FunctionFragment; + "setPendingAdmin(address)": FunctionFragment; + "setSharedBridge(address)": FunctionFragment; + "sharedBridge()": FunctionFragment; + "stateTransitionManager(uint256)": FunctionFragment; + "stateTransitionManagerIsRegistered(address)": FunctionFragment; + "tokenIsRegistered(address)": FunctionFragment; + }; + + encodeFunctionData( + functionFragment: "acceptAdmin", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "addStateTransitionManager", + values: [string] + ): string; + encodeFunctionData(functionFragment: "addToken", values: [string]): string; + encodeFunctionData( + functionFragment: "baseToken", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "createNewChain", + values: [BigNumberish, string, string, BigNumberish, string, BytesLike] + ): string; + encodeFunctionData( + functionFragment: "getStateTransition", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "l2TransactionBaseCost", + values: [BigNumberish, BigNumberish, BigNumberish, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "proveL1ToL2TransactionStatus", + values: [ + BigNumberish, + BytesLike, + BigNumberish, + BigNumberish, + BigNumberish, + BytesLike[], + BigNumberish + ] + ): string; + encodeFunctionData( + functionFragment: "proveL2LogInclusion", + values: [ + BigNumberish, + BigNumberish, + BigNumberish, + { + l2ShardId: BigNumberish; + isService: boolean; + txNumberInBatch: BigNumberish; + sender: string; + key: BytesLike; + value: BytesLike; + }, + BytesLike[] + ] + ): string; + encodeFunctionData( + functionFragment: "proveL2MessageInclusion", + values: [ + BigNumberish, + BigNumberish, + BigNumberish, + { txNumberInBatch: BigNumberish; sender: string; data: BytesLike }, + BytesLike[] + ] + ): string; + encodeFunctionData( + functionFragment: "removeStateTransitionManager", + values: [string] + ): string; + encodeFunctionData( + functionFragment: "requestL2TransactionDirect", + values: [ + { + chainId: BigNumberish; + mintValue: BigNumberish; + l2Contract: string; + l2Value: BigNumberish; + l2Calldata: BytesLike; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + factoryDeps: BytesLike[]; + refundRecipient: string; + } + ] + ): string; + encodeFunctionData( + functionFragment: "requestL2TransactionTwoBridges", + values: [ + { + chainId: BigNumberish; + mintValue: BigNumberish; + l2Value: BigNumberish; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + refundRecipient: string; + secondBridgeAddress: string; + secondBridgeValue: BigNumberish; + secondBridgeCalldata: BytesLike; + } + ] + ): string; + encodeFunctionData( + functionFragment: "setPendingAdmin", + values: [string] + ): string; + encodeFunctionData( + functionFragment: "setSharedBridge", + values: [string] + ): string; + encodeFunctionData( + functionFragment: "sharedBridge", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "stateTransitionManager", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "stateTransitionManagerIsRegistered", + values: [string] + ): string; + encodeFunctionData( + functionFragment: "tokenIsRegistered", + values: [string] + ): string; + + decodeFunctionResult( + functionFragment: "acceptAdmin", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "addStateTransitionManager", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "addToken", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "baseToken", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "createNewChain", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getStateTransition", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "l2TransactionBaseCost", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "proveL1ToL2TransactionStatus", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "proveL2LogInclusion", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "proveL2MessageInclusion", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "removeStateTransitionManager", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "requestL2TransactionDirect", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "requestL2TransactionTwoBridges", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "setPendingAdmin", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "setSharedBridge", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "sharedBridge", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "stateTransitionManager", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "stateTransitionManagerIsRegistered", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "tokenIsRegistered", + data: BytesLike + ): Result; + + events: { + "NewAdmin(address,address)": EventFragment; + "NewChain(uint256,address,address)": EventFragment; + "NewPendingAdmin(address,address)": EventFragment; + }; + + getEvent(nameOrSignatureOrTopic: "NewAdmin"): EventFragment; + getEvent(nameOrSignatureOrTopic: "NewChain"): EventFragment; + getEvent(nameOrSignatureOrTopic: "NewPendingAdmin"): EventFragment; +} + +export class IBridgehub extends Contract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + on(event: EventFilter | string, listener: Listener): this; + once(event: EventFilter | string, listener: Listener): this; + addListener(eventName: EventFilter | string, listener: Listener): this; + removeAllListeners(eventName: EventFilter | string): this; + removeListener(eventName: any, listener: Listener): this; + + interface: IBridgehubInterface; + + functions: { + acceptAdmin(overrides?: Overrides): Promise; + + "acceptAdmin()"(overrides?: Overrides): Promise; + + addStateTransitionManager( + _stateTransitionManager: string, + overrides?: Overrides + ): Promise; + + "addStateTransitionManager(address)"( + _stateTransitionManager: string, + overrides?: Overrides + ): Promise; + + addToken( + _token: string, + overrides?: Overrides + ): Promise; + + "addToken(address)"( + _token: string, + overrides?: Overrides + ): Promise; + + baseToken( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: string; + }>; + + "baseToken(uint256)"( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: string; + }>; + + createNewChain( + _chainId: BigNumberish, + _stateTransitionManager: string, + _baseToken: string, + _salt: BigNumberish, + _admin: string, + _initData: BytesLike, + overrides?: Overrides + ): Promise; + + "createNewChain(uint256,address,address,uint256,address,bytes)"( + _chainId: BigNumberish, + _stateTransitionManager: string, + _baseToken: string, + _salt: BigNumberish, + _admin: string, + _initData: BytesLike, + overrides?: Overrides + ): Promise; + + getStateTransition( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: string; + }>; + + "getStateTransition(uint256)"( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: string; + }>; + + l2TransactionBaseCost( + _chainId: BigNumberish, + _gasPrice: BigNumberish, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: BigNumber; + }>; + + "l2TransactionBaseCost(uint256,uint256,uint256,uint256)"( + _chainId: BigNumberish, + _gasPrice: BigNumberish, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: BigNumber; + }>; + + proveL1ToL2TransactionStatus( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + _status: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + "proveL1ToL2TransactionStatus(uint256,bytes32,uint256,uint256,uint16,bytes32[],uint8)"( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + _status: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + proveL2LogInclusion( + _chainId: BigNumberish, + _batchNumber: BigNumberish, + _index: BigNumberish, + _log: { + l2ShardId: BigNumberish; + isService: boolean; + txNumberInBatch: BigNumberish; + sender: string; + key: BytesLike; + value: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + "proveL2LogInclusion(uint256,uint256,uint256,tuple,bytes32[])"( + _chainId: BigNumberish, + _batchNumber: BigNumberish, + _index: BigNumberish, + _log: { + l2ShardId: BigNumberish; + isService: boolean; + txNumberInBatch: BigNumberish; + sender: string; + key: BytesLike; + value: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + proveL2MessageInclusion( + _chainId: BigNumberish, + _batchNumber: BigNumberish, + _index: BigNumberish, + _message: { + txNumberInBatch: BigNumberish; + sender: string; + data: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + "proveL2MessageInclusion(uint256,uint256,uint256,tuple,bytes32[])"( + _chainId: BigNumberish, + _batchNumber: BigNumberish, + _index: BigNumberish, + _message: { + txNumberInBatch: BigNumberish; + sender: string; + data: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + removeStateTransitionManager( + _stateTransitionManager: string, + overrides?: Overrides + ): Promise; + + "removeStateTransitionManager(address)"( + _stateTransitionManager: string, + overrides?: Overrides + ): Promise; + + requestL2TransactionDirect( + _request: { + chainId: BigNumberish; + mintValue: BigNumberish; + l2Contract: string; + l2Value: BigNumberish; + l2Calldata: BytesLike; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + factoryDeps: BytesLike[]; + refundRecipient: string; + }, + overrides?: PayableOverrides + ): Promise; + + "requestL2TransactionDirect(tuple)"( + _request: { + chainId: BigNumberish; + mintValue: BigNumberish; + l2Contract: string; + l2Value: BigNumberish; + l2Calldata: BytesLike; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + factoryDeps: BytesLike[]; + refundRecipient: string; + }, + overrides?: PayableOverrides + ): Promise; + + requestL2TransactionTwoBridges( + _request: { + chainId: BigNumberish; + mintValue: BigNumberish; + l2Value: BigNumberish; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + refundRecipient: string; + secondBridgeAddress: string; + secondBridgeValue: BigNumberish; + secondBridgeCalldata: BytesLike; + }, + overrides?: PayableOverrides + ): Promise; + + "requestL2TransactionTwoBridges(tuple)"( + _request: { + chainId: BigNumberish; + mintValue: BigNumberish; + l2Value: BigNumberish; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + refundRecipient: string; + secondBridgeAddress: string; + secondBridgeValue: BigNumberish; + secondBridgeCalldata: BytesLike; + }, + overrides?: PayableOverrides + ): Promise; + + setPendingAdmin( + _newPendingAdmin: string, + overrides?: Overrides + ): Promise; + + "setPendingAdmin(address)"( + _newPendingAdmin: string, + overrides?: Overrides + ): Promise; + + setSharedBridge( + _sharedBridge: string, + overrides?: Overrides + ): Promise; + + "setSharedBridge(address)"( + _sharedBridge: string, + overrides?: Overrides + ): Promise; + + sharedBridge(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + "sharedBridge()"(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + stateTransitionManager( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: string; + }>; + + "stateTransitionManager(uint256)"( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: string; + }>; + + stateTransitionManagerIsRegistered( + _stateTransitionManager: string, + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + "stateTransitionManagerIsRegistered(address)"( + _stateTransitionManager: string, + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + tokenIsRegistered( + _baseToken: string, + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + "tokenIsRegistered(address)"( + _baseToken: string, + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + }; + + acceptAdmin(overrides?: Overrides): Promise; + + "acceptAdmin()"(overrides?: Overrides): Promise; + + addStateTransitionManager( + _stateTransitionManager: string, + overrides?: Overrides + ): Promise; + + "addStateTransitionManager(address)"( + _stateTransitionManager: string, + overrides?: Overrides + ): Promise; + + addToken(_token: string, overrides?: Overrides): Promise; + + "addToken(address)"( + _token: string, + overrides?: Overrides + ): Promise; + + baseToken(_chainId: BigNumberish, overrides?: CallOverrides): Promise; + + "baseToken(uint256)"( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + createNewChain( + _chainId: BigNumberish, + _stateTransitionManager: string, + _baseToken: string, + _salt: BigNumberish, + _admin: string, + _initData: BytesLike, + overrides?: Overrides + ): Promise; + + "createNewChain(uint256,address,address,uint256,address,bytes)"( + _chainId: BigNumberish, + _stateTransitionManager: string, + _baseToken: string, + _salt: BigNumberish, + _admin: string, + _initData: BytesLike, + overrides?: Overrides + ): Promise; + + getStateTransition( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "getStateTransition(uint256)"( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + l2TransactionBaseCost( + _chainId: BigNumberish, + _gasPrice: BigNumberish, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "l2TransactionBaseCost(uint256,uint256,uint256,uint256)"( + _chainId: BigNumberish, + _gasPrice: BigNumberish, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + overrides?: CallOverrides + ): Promise; + + proveL1ToL2TransactionStatus( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + _status: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "proveL1ToL2TransactionStatus(uint256,bytes32,uint256,uint256,uint16,bytes32[],uint8)"( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + _status: BigNumberish, + overrides?: CallOverrides + ): Promise; + + proveL2LogInclusion( + _chainId: BigNumberish, + _batchNumber: BigNumberish, + _index: BigNumberish, + _log: { + l2ShardId: BigNumberish; + isService: boolean; + txNumberInBatch: BigNumberish; + sender: string; + key: BytesLike; + value: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + "proveL2LogInclusion(uint256,uint256,uint256,tuple,bytes32[])"( + _chainId: BigNumberish, + _batchNumber: BigNumberish, + _index: BigNumberish, + _log: { + l2ShardId: BigNumberish; + isService: boolean; + txNumberInBatch: BigNumberish; + sender: string; + key: BytesLike; + value: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + proveL2MessageInclusion( + _chainId: BigNumberish, + _batchNumber: BigNumberish, + _index: BigNumberish, + _message: { + txNumberInBatch: BigNumberish; + sender: string; + data: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + "proveL2MessageInclusion(uint256,uint256,uint256,tuple,bytes32[])"( + _chainId: BigNumberish, + _batchNumber: BigNumberish, + _index: BigNumberish, + _message: { + txNumberInBatch: BigNumberish; + sender: string; + data: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + removeStateTransitionManager( + _stateTransitionManager: string, + overrides?: Overrides + ): Promise; + + "removeStateTransitionManager(address)"( + _stateTransitionManager: string, + overrides?: Overrides + ): Promise; + + requestL2TransactionDirect( + _request: { + chainId: BigNumberish; + mintValue: BigNumberish; + l2Contract: string; + l2Value: BigNumberish; + l2Calldata: BytesLike; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + factoryDeps: BytesLike[]; + refundRecipient: string; + }, + overrides?: PayableOverrides + ): Promise; + + "requestL2TransactionDirect(tuple)"( + _request: { + chainId: BigNumberish; + mintValue: BigNumberish; + l2Contract: string; + l2Value: BigNumberish; + l2Calldata: BytesLike; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + factoryDeps: BytesLike[]; + refundRecipient: string; + }, + overrides?: PayableOverrides + ): Promise; + + requestL2TransactionTwoBridges( + _request: { + chainId: BigNumberish; + mintValue: BigNumberish; + l2Value: BigNumberish; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + refundRecipient: string; + secondBridgeAddress: string; + secondBridgeValue: BigNumberish; + secondBridgeCalldata: BytesLike; + }, + overrides?: PayableOverrides + ): Promise; + + "requestL2TransactionTwoBridges(tuple)"( + _request: { + chainId: BigNumberish; + mintValue: BigNumberish; + l2Value: BigNumberish; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + refundRecipient: string; + secondBridgeAddress: string; + secondBridgeValue: BigNumberish; + secondBridgeCalldata: BytesLike; + }, + overrides?: PayableOverrides + ): Promise; + + setPendingAdmin( + _newPendingAdmin: string, + overrides?: Overrides + ): Promise; + + "setPendingAdmin(address)"( + _newPendingAdmin: string, + overrides?: Overrides + ): Promise; + + setSharedBridge( + _sharedBridge: string, + overrides?: Overrides + ): Promise; + + "setSharedBridge(address)"( + _sharedBridge: string, + overrides?: Overrides + ): Promise; + + sharedBridge(overrides?: CallOverrides): Promise; + + "sharedBridge()"(overrides?: CallOverrides): Promise; + + stateTransitionManager( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "stateTransitionManager(uint256)"( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + stateTransitionManagerIsRegistered( + _stateTransitionManager: string, + overrides?: CallOverrides + ): Promise; + + "stateTransitionManagerIsRegistered(address)"( + _stateTransitionManager: string, + overrides?: CallOverrides + ): Promise; + + tokenIsRegistered( + _baseToken: string, + overrides?: CallOverrides + ): Promise; + + "tokenIsRegistered(address)"( + _baseToken: string, + overrides?: CallOverrides + ): Promise; + + callStatic: { + acceptAdmin(overrides?: CallOverrides): Promise; + + "acceptAdmin()"(overrides?: CallOverrides): Promise; + + addStateTransitionManager( + _stateTransitionManager: string, + overrides?: CallOverrides + ): Promise; + + "addStateTransitionManager(address)"( + _stateTransitionManager: string, + overrides?: CallOverrides + ): Promise; + + addToken(_token: string, overrides?: CallOverrides): Promise; + + "addToken(address)"( + _token: string, + overrides?: CallOverrides + ): Promise; + + baseToken( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "baseToken(uint256)"( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + createNewChain( + _chainId: BigNumberish, + _stateTransitionManager: string, + _baseToken: string, + _salt: BigNumberish, + _admin: string, + _initData: BytesLike, + overrides?: CallOverrides + ): Promise; + + "createNewChain(uint256,address,address,uint256,address,bytes)"( + _chainId: BigNumberish, + _stateTransitionManager: string, + _baseToken: string, + _salt: BigNumberish, + _admin: string, + _initData: BytesLike, + overrides?: CallOverrides + ): Promise; + + getStateTransition( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "getStateTransition(uint256)"( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + l2TransactionBaseCost( + _chainId: BigNumberish, + _gasPrice: BigNumberish, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "l2TransactionBaseCost(uint256,uint256,uint256,uint256)"( + _chainId: BigNumberish, + _gasPrice: BigNumberish, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + overrides?: CallOverrides + ): Promise; + + proveL1ToL2TransactionStatus( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + _status: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "proveL1ToL2TransactionStatus(uint256,bytes32,uint256,uint256,uint16,bytes32[],uint8)"( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + _status: BigNumberish, + overrides?: CallOverrides + ): Promise; + + proveL2LogInclusion( + _chainId: BigNumberish, + _batchNumber: BigNumberish, + _index: BigNumberish, + _log: { + l2ShardId: BigNumberish; + isService: boolean; + txNumberInBatch: BigNumberish; + sender: string; + key: BytesLike; + value: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + "proveL2LogInclusion(uint256,uint256,uint256,tuple,bytes32[])"( + _chainId: BigNumberish, + _batchNumber: BigNumberish, + _index: BigNumberish, + _log: { + l2ShardId: BigNumberish; + isService: boolean; + txNumberInBatch: BigNumberish; + sender: string; + key: BytesLike; + value: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + proveL2MessageInclusion( + _chainId: BigNumberish, + _batchNumber: BigNumberish, + _index: BigNumberish, + _message: { + txNumberInBatch: BigNumberish; + sender: string; + data: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + "proveL2MessageInclusion(uint256,uint256,uint256,tuple,bytes32[])"( + _chainId: BigNumberish, + _batchNumber: BigNumberish, + _index: BigNumberish, + _message: { + txNumberInBatch: BigNumberish; + sender: string; + data: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + removeStateTransitionManager( + _stateTransitionManager: string, + overrides?: CallOverrides + ): Promise; + + "removeStateTransitionManager(address)"( + _stateTransitionManager: string, + overrides?: CallOverrides + ): Promise; + + requestL2TransactionDirect( + _request: { + chainId: BigNumberish; + mintValue: BigNumberish; + l2Contract: string; + l2Value: BigNumberish; + l2Calldata: BytesLike; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + factoryDeps: BytesLike[]; + refundRecipient: string; + }, + overrides?: CallOverrides + ): Promise; + + "requestL2TransactionDirect(tuple)"( + _request: { + chainId: BigNumberish; + mintValue: BigNumberish; + l2Contract: string; + l2Value: BigNumberish; + l2Calldata: BytesLike; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + factoryDeps: BytesLike[]; + refundRecipient: string; + }, + overrides?: CallOverrides + ): Promise; + + requestL2TransactionTwoBridges( + _request: { + chainId: BigNumberish; + mintValue: BigNumberish; + l2Value: BigNumberish; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + refundRecipient: string; + secondBridgeAddress: string; + secondBridgeValue: BigNumberish; + secondBridgeCalldata: BytesLike; + }, + overrides?: CallOverrides + ): Promise; + + "requestL2TransactionTwoBridges(tuple)"( + _request: { + chainId: BigNumberish; + mintValue: BigNumberish; + l2Value: BigNumberish; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + refundRecipient: string; + secondBridgeAddress: string; + secondBridgeValue: BigNumberish; + secondBridgeCalldata: BytesLike; + }, + overrides?: CallOverrides + ): Promise; + + setPendingAdmin( + _newPendingAdmin: string, + overrides?: CallOverrides + ): Promise; + + "setPendingAdmin(address)"( + _newPendingAdmin: string, + overrides?: CallOverrides + ): Promise; + + setSharedBridge( + _sharedBridge: string, + overrides?: CallOverrides + ): Promise; + + "setSharedBridge(address)"( + _sharedBridge: string, + overrides?: CallOverrides + ): Promise; + + sharedBridge(overrides?: CallOverrides): Promise; + + "sharedBridge()"(overrides?: CallOverrides): Promise; + + stateTransitionManager( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "stateTransitionManager(uint256)"( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + stateTransitionManagerIsRegistered( + _stateTransitionManager: string, + overrides?: CallOverrides + ): Promise; + + "stateTransitionManagerIsRegistered(address)"( + _stateTransitionManager: string, + overrides?: CallOverrides + ): Promise; + + tokenIsRegistered( + _baseToken: string, + overrides?: CallOverrides + ): Promise; + + "tokenIsRegistered(address)"( + _baseToken: string, + overrides?: CallOverrides + ): Promise; + }; + + filters: { + NewAdmin(oldAdmin: string | null, newAdmin: string | null): EventFilter; + + NewChain( + chainId: BigNumberish | null, + stateTransitionManager: null, + chainGovernance: string | null + ): EventFilter; + + NewPendingAdmin( + oldPendingAdmin: string | null, + newPendingAdmin: string | null + ): EventFilter; + }; + + estimateGas: { + acceptAdmin(overrides?: Overrides): Promise; + + "acceptAdmin()"(overrides?: Overrides): Promise; + + addStateTransitionManager( + _stateTransitionManager: string, + overrides?: Overrides + ): Promise; + + "addStateTransitionManager(address)"( + _stateTransitionManager: string, + overrides?: Overrides + ): Promise; + + addToken(_token: string, overrides?: Overrides): Promise; + + "addToken(address)"( + _token: string, + overrides?: Overrides + ): Promise; + + baseToken( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "baseToken(uint256)"( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + createNewChain( + _chainId: BigNumberish, + _stateTransitionManager: string, + _baseToken: string, + _salt: BigNumberish, + _admin: string, + _initData: BytesLike, + overrides?: Overrides + ): Promise; + + "createNewChain(uint256,address,address,uint256,address,bytes)"( + _chainId: BigNumberish, + _stateTransitionManager: string, + _baseToken: string, + _salt: BigNumberish, + _admin: string, + _initData: BytesLike, + overrides?: Overrides + ): Promise; + + getStateTransition( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "getStateTransition(uint256)"( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + l2TransactionBaseCost( + _chainId: BigNumberish, + _gasPrice: BigNumberish, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "l2TransactionBaseCost(uint256,uint256,uint256,uint256)"( + _chainId: BigNumberish, + _gasPrice: BigNumberish, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + overrides?: CallOverrides + ): Promise; + + proveL1ToL2TransactionStatus( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + _status: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "proveL1ToL2TransactionStatus(uint256,bytes32,uint256,uint256,uint16,bytes32[],uint8)"( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + _status: BigNumberish, + overrides?: CallOverrides + ): Promise; + + proveL2LogInclusion( + _chainId: BigNumberish, + _batchNumber: BigNumberish, + _index: BigNumberish, + _log: { + l2ShardId: BigNumberish; + isService: boolean; + txNumberInBatch: BigNumberish; + sender: string; + key: BytesLike; + value: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + "proveL2LogInclusion(uint256,uint256,uint256,tuple,bytes32[])"( + _chainId: BigNumberish, + _batchNumber: BigNumberish, + _index: BigNumberish, + _log: { + l2ShardId: BigNumberish; + isService: boolean; + txNumberInBatch: BigNumberish; + sender: string; + key: BytesLike; + value: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + proveL2MessageInclusion( + _chainId: BigNumberish, + _batchNumber: BigNumberish, + _index: BigNumberish, + _message: { + txNumberInBatch: BigNumberish; + sender: string; + data: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + "proveL2MessageInclusion(uint256,uint256,uint256,tuple,bytes32[])"( + _chainId: BigNumberish, + _batchNumber: BigNumberish, + _index: BigNumberish, + _message: { + txNumberInBatch: BigNumberish; + sender: string; + data: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + removeStateTransitionManager( + _stateTransitionManager: string, + overrides?: Overrides + ): Promise; + + "removeStateTransitionManager(address)"( + _stateTransitionManager: string, + overrides?: Overrides + ): Promise; + + requestL2TransactionDirect( + _request: { + chainId: BigNumberish; + mintValue: BigNumberish; + l2Contract: string; + l2Value: BigNumberish; + l2Calldata: BytesLike; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + factoryDeps: BytesLike[]; + refundRecipient: string; + }, + overrides?: PayableOverrides + ): Promise; + + "requestL2TransactionDirect(tuple)"( + _request: { + chainId: BigNumberish; + mintValue: BigNumberish; + l2Contract: string; + l2Value: BigNumberish; + l2Calldata: BytesLike; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + factoryDeps: BytesLike[]; + refundRecipient: string; + }, + overrides?: PayableOverrides + ): Promise; + + requestL2TransactionTwoBridges( + _request: { + chainId: BigNumberish; + mintValue: BigNumberish; + l2Value: BigNumberish; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + refundRecipient: string; + secondBridgeAddress: string; + secondBridgeValue: BigNumberish; + secondBridgeCalldata: BytesLike; + }, + overrides?: PayableOverrides + ): Promise; + + "requestL2TransactionTwoBridges(tuple)"( + _request: { + chainId: BigNumberish; + mintValue: BigNumberish; + l2Value: BigNumberish; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + refundRecipient: string; + secondBridgeAddress: string; + secondBridgeValue: BigNumberish; + secondBridgeCalldata: BytesLike; + }, + overrides?: PayableOverrides + ): Promise; + + setPendingAdmin( + _newPendingAdmin: string, + overrides?: Overrides + ): Promise; + + "setPendingAdmin(address)"( + _newPendingAdmin: string, + overrides?: Overrides + ): Promise; + + setSharedBridge( + _sharedBridge: string, + overrides?: Overrides + ): Promise; + + "setSharedBridge(address)"( + _sharedBridge: string, + overrides?: Overrides + ): Promise; + + sharedBridge(overrides?: CallOverrides): Promise; + + "sharedBridge()"(overrides?: CallOverrides): Promise; + + stateTransitionManager( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "stateTransitionManager(uint256)"( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + stateTransitionManagerIsRegistered( + _stateTransitionManager: string, + overrides?: CallOverrides + ): Promise; + + "stateTransitionManagerIsRegistered(address)"( + _stateTransitionManager: string, + overrides?: CallOverrides + ): Promise; + + tokenIsRegistered( + _baseToken: string, + overrides?: CallOverrides + ): Promise; + + "tokenIsRegistered(address)"( + _baseToken: string, + overrides?: CallOverrides + ): Promise; + }; + + populateTransaction: { + acceptAdmin(overrides?: Overrides): Promise; + + "acceptAdmin()"(overrides?: Overrides): Promise; + + addStateTransitionManager( + _stateTransitionManager: string, + overrides?: Overrides + ): Promise; + + "addStateTransitionManager(address)"( + _stateTransitionManager: string, + overrides?: Overrides + ): Promise; + + addToken( + _token: string, + overrides?: Overrides + ): Promise; + + "addToken(address)"( + _token: string, + overrides?: Overrides + ): Promise; + + baseToken( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "baseToken(uint256)"( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + createNewChain( + _chainId: BigNumberish, + _stateTransitionManager: string, + _baseToken: string, + _salt: BigNumberish, + _admin: string, + _initData: BytesLike, + overrides?: Overrides + ): Promise; + + "createNewChain(uint256,address,address,uint256,address,bytes)"( + _chainId: BigNumberish, + _stateTransitionManager: string, + _baseToken: string, + _salt: BigNumberish, + _admin: string, + _initData: BytesLike, + overrides?: Overrides + ): Promise; + + getStateTransition( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "getStateTransition(uint256)"( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + l2TransactionBaseCost( + _chainId: BigNumberish, + _gasPrice: BigNumberish, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "l2TransactionBaseCost(uint256,uint256,uint256,uint256)"( + _chainId: BigNumberish, + _gasPrice: BigNumberish, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + overrides?: CallOverrides + ): Promise; + + proveL1ToL2TransactionStatus( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + _status: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "proveL1ToL2TransactionStatus(uint256,bytes32,uint256,uint256,uint16,bytes32[],uint8)"( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + _status: BigNumberish, + overrides?: CallOverrides + ): Promise; + + proveL2LogInclusion( + _chainId: BigNumberish, + _batchNumber: BigNumberish, + _index: BigNumberish, + _log: { + l2ShardId: BigNumberish; + isService: boolean; + txNumberInBatch: BigNumberish; + sender: string; + key: BytesLike; + value: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + "proveL2LogInclusion(uint256,uint256,uint256,tuple,bytes32[])"( + _chainId: BigNumberish, + _batchNumber: BigNumberish, + _index: BigNumberish, + _log: { + l2ShardId: BigNumberish; + isService: boolean; + txNumberInBatch: BigNumberish; + sender: string; + key: BytesLike; + value: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + proveL2MessageInclusion( + _chainId: BigNumberish, + _batchNumber: BigNumberish, + _index: BigNumberish, + _message: { + txNumberInBatch: BigNumberish; + sender: string; + data: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + "proveL2MessageInclusion(uint256,uint256,uint256,tuple,bytes32[])"( + _chainId: BigNumberish, + _batchNumber: BigNumberish, + _index: BigNumberish, + _message: { + txNumberInBatch: BigNumberish; + sender: string; + data: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + removeStateTransitionManager( + _stateTransitionManager: string, + overrides?: Overrides + ): Promise; + + "removeStateTransitionManager(address)"( + _stateTransitionManager: string, + overrides?: Overrides + ): Promise; + + requestL2TransactionDirect( + _request: { + chainId: BigNumberish; + mintValue: BigNumberish; + l2Contract: string; + l2Value: BigNumberish; + l2Calldata: BytesLike; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + factoryDeps: BytesLike[]; + refundRecipient: string; + }, + overrides?: PayableOverrides + ): Promise; + + "requestL2TransactionDirect(tuple)"( + _request: { + chainId: BigNumberish; + mintValue: BigNumberish; + l2Contract: string; + l2Value: BigNumberish; + l2Calldata: BytesLike; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + factoryDeps: BytesLike[]; + refundRecipient: string; + }, + overrides?: PayableOverrides + ): Promise; + + requestL2TransactionTwoBridges( + _request: { + chainId: BigNumberish; + mintValue: BigNumberish; + l2Value: BigNumberish; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + refundRecipient: string; + secondBridgeAddress: string; + secondBridgeValue: BigNumberish; + secondBridgeCalldata: BytesLike; + }, + overrides?: PayableOverrides + ): Promise; + + "requestL2TransactionTwoBridges(tuple)"( + _request: { + chainId: BigNumberish; + mintValue: BigNumberish; + l2Value: BigNumberish; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + refundRecipient: string; + secondBridgeAddress: string; + secondBridgeValue: BigNumberish; + secondBridgeCalldata: BytesLike; + }, + overrides?: PayableOverrides + ): Promise; + + setPendingAdmin( + _newPendingAdmin: string, + overrides?: Overrides + ): Promise; + + "setPendingAdmin(address)"( + _newPendingAdmin: string, + overrides?: Overrides + ): Promise; + + setSharedBridge( + _sharedBridge: string, + overrides?: Overrides + ): Promise; + + "setSharedBridge(address)"( + _sharedBridge: string, + overrides?: Overrides + ): Promise; + + sharedBridge(overrides?: CallOverrides): Promise; + + "sharedBridge()"(overrides?: CallOverrides): Promise; + + stateTransitionManager( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "stateTransitionManager(uint256)"( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + stateTransitionManagerIsRegistered( + _stateTransitionManager: string, + overrides?: CallOverrides + ): Promise; + + "stateTransitionManagerIsRegistered(address)"( + _stateTransitionManager: string, + overrides?: CallOverrides + ): Promise; + + tokenIsRegistered( + _baseToken: string, + overrides?: CallOverrides + ): Promise; + + "tokenIsRegistered(address)"( + _baseToken: string, + overrides?: CallOverrides + ): Promise; + }; +} diff --git a/src/typechain/IBridgehubFactory.ts b/src/typechain/IBridgehubFactory.ts new file mode 100644 index 00000000..97fa46d8 --- /dev/null +++ b/src/typechain/IBridgehubFactory.ts @@ -0,0 +1,649 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer } from "ethers"; +import { Provider } from "@ethersproject/providers"; + +import type { IBridgehub } from "./IBridgehub"; + +export class IBridgehubFactory { + static connect( + address: string, + signerOrProvider: Signer | Provider + ): IBridgehub { + return new Contract(address, _abi, signerOrProvider) as IBridgehub; + } +} + +const _abi = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "oldAdmin", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "newAdmin", + type: "address", + }, + ], + name: "NewAdmin", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + indexed: false, + internalType: "address", + name: "stateTransitionManager", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "chainGovernance", + type: "address", + }, + ], + name: "NewChain", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "oldPendingAdmin", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "newPendingAdmin", + type: "address", + }, + ], + name: "NewPendingAdmin", + type: "event", + }, + { + inputs: [], + name: "acceptAdmin", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_stateTransitionManager", + type: "address", + }, + ], + name: "addStateTransitionManager", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_token", + type: "address", + }, + ], + name: "addToken", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + ], + name: "baseToken", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "address", + name: "_stateTransitionManager", + type: "address", + }, + { + internalType: "address", + name: "_baseToken", + type: "address", + }, + { + internalType: "uint256", + name: "_salt", + type: "uint256", + }, + { + internalType: "address", + name: "_admin", + type: "address", + }, + { + internalType: "bytes", + name: "_initData", + type: "bytes", + }, + ], + name: "createNewChain", + outputs: [ + { + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + ], + name: "getStateTransition", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "uint256", + name: "_gasPrice", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2GasLimit", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2GasPerPubdataByteLimit", + type: "uint256", + }, + ], + name: "l2TransactionBaseCost", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "bytes32", + name: "_l2TxHash", + type: "bytes32", + }, + { + internalType: "uint256", + name: "_l2BatchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2MessageIndex", + type: "uint256", + }, + { + internalType: "uint16", + name: "_l2TxNumberInBatch", + type: "uint16", + }, + { + internalType: "bytes32[]", + name: "_merkleProof", + type: "bytes32[]", + }, + { + internalType: "enum TxStatus", + name: "_status", + type: "uint8", + }, + ], + name: "proveL1ToL2TransactionStatus", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "uint256", + name: "_batchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_index", + type: "uint256", + }, + { + components: [ + { + internalType: "uint8", + name: "l2ShardId", + type: "uint8", + }, + { + internalType: "bool", + name: "isService", + type: "bool", + }, + { + internalType: "uint16", + name: "txNumberInBatch", + type: "uint16", + }, + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "bytes32", + name: "key", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "value", + type: "bytes32", + }, + ], + internalType: "struct L2Log", + name: "_log", + type: "tuple", + }, + { + internalType: "bytes32[]", + name: "_proof", + type: "bytes32[]", + }, + ], + name: "proveL2LogInclusion", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "uint256", + name: "_batchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_index", + type: "uint256", + }, + { + components: [ + { + internalType: "uint16", + name: "txNumberInBatch", + type: "uint16", + }, + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "bytes", + name: "data", + type: "bytes", + }, + ], + internalType: "struct L2Message", + name: "_message", + type: "tuple", + }, + { + internalType: "bytes32[]", + name: "_proof", + type: "bytes32[]", + }, + ], + name: "proveL2MessageInclusion", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_stateTransitionManager", + type: "address", + }, + ], + name: "removeStateTransitionManager", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + components: [ + { + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + internalType: "uint256", + name: "mintValue", + type: "uint256", + }, + { + internalType: "address", + name: "l2Contract", + type: "address", + }, + { + internalType: "uint256", + name: "l2Value", + type: "uint256", + }, + { + internalType: "bytes", + name: "l2Calldata", + type: "bytes", + }, + { + internalType: "uint256", + name: "l2GasLimit", + type: "uint256", + }, + { + internalType: "uint256", + name: "l2GasPerPubdataByteLimit", + type: "uint256", + }, + { + internalType: "bytes[]", + name: "factoryDeps", + type: "bytes[]", + }, + { + internalType: "address", + name: "refundRecipient", + type: "address", + }, + ], + internalType: "struct L2TransactionRequestDirect", + name: "_request", + type: "tuple", + }, + ], + name: "requestL2TransactionDirect", + outputs: [ + { + internalType: "bytes32", + name: "canonicalTxHash", + type: "bytes32", + }, + ], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + components: [ + { + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + internalType: "uint256", + name: "mintValue", + type: "uint256", + }, + { + internalType: "uint256", + name: "l2Value", + type: "uint256", + }, + { + internalType: "uint256", + name: "l2GasLimit", + type: "uint256", + }, + { + internalType: "uint256", + name: "l2GasPerPubdataByteLimit", + type: "uint256", + }, + { + internalType: "address", + name: "refundRecipient", + type: "address", + }, + { + internalType: "address", + name: "secondBridgeAddress", + type: "address", + }, + { + internalType: "uint256", + name: "secondBridgeValue", + type: "uint256", + }, + { + internalType: "bytes", + name: "secondBridgeCalldata", + type: "bytes", + }, + ], + internalType: "struct L2TransactionRequestTwoBridgesOuter", + name: "_request", + type: "tuple", + }, + ], + name: "requestL2TransactionTwoBridges", + outputs: [ + { + internalType: "bytes32", + name: "canonicalTxHash", + type: "bytes32", + }, + ], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_newPendingAdmin", + type: "address", + }, + ], + name: "setPendingAdmin", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_sharedBridge", + type: "address", + }, + ], + name: "setSharedBridge", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "sharedBridge", + outputs: [ + { + internalType: "contract IL1SharedBridge", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + ], + name: "stateTransitionManager", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_stateTransitionManager", + type: "address", + }, + ], + name: "stateTransitionManagerIsRegistered", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_baseToken", + type: "address", + }, + ], + name: "tokenIsRegistered", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, +]; diff --git a/src/typechain/IContractDeployer.d.ts b/src/typechain/IContractDeployer.d.ts index 7cd88871..c36845b7 100644 --- a/src/typechain/IContractDeployer.d.ts +++ b/src/typechain/IContractDeployer.d.ts @@ -27,6 +27,9 @@ interface IContractDeployerInterface extends ethers.utils.Interface { "create2(bytes32,bytes32,bytes)": FunctionFragment; "create2Account(bytes32,bytes32,bytes,uint8)": FunctionFragment; "createAccount(bytes32,bytes32,bytes,uint8)": FunctionFragment; + "extendedAccountVersion(address)": FunctionFragment; + "forceDeployOnAddress(tuple,address)": FunctionFragment; + "forceDeployOnAddresses(tuple[])": FunctionFragment; "getAccountInfo(address)": FunctionFragment; "getNewAddressCreate(address,uint256)": FunctionFragment; "getNewAddressCreate2(address,bytes32,bytes32,bytes)": FunctionFragment; @@ -50,6 +53,35 @@ interface IContractDeployerInterface extends ethers.utils.Interface { functionFragment: "createAccount", values: [BytesLike, BytesLike, BytesLike, BigNumberish] ): string; + encodeFunctionData( + functionFragment: "extendedAccountVersion", + values: [string] + ): string; + encodeFunctionData( + functionFragment: "forceDeployOnAddress", + values: [ + { + bytecodeHash: BytesLike; + newAddress: string; + callConstructor: boolean; + value: BigNumberish; + input: BytesLike; + }, + string + ] + ): string; + encodeFunctionData( + functionFragment: "forceDeployOnAddresses", + values: [ + { + bytecodeHash: BytesLike; + newAddress: string; + callConstructor: boolean; + value: BigNumberish; + input: BytesLike; + }[] + ] + ): string; encodeFunctionData( functionFragment: "getAccountInfo", values: [string] @@ -81,6 +113,18 @@ interface IContractDeployerInterface extends ethers.utils.Interface { functionFragment: "createAccount", data: BytesLike ): Result; + decodeFunctionResult( + functionFragment: "extendedAccountVersion", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "forceDeployOnAddress", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "forceDeployOnAddresses", + data: BytesLike + ): Result; decodeFunctionResult( functionFragment: "getAccountInfo", data: BytesLike @@ -174,7 +218,7 @@ export class IContractDeployer extends Contract { ): Promise; createAccount( - _salt: BytesLike, + arg0: BytesLike, _bytecodeHash: BytesLike, _input: BytesLike, _aaVersion: BigNumberish, @@ -182,13 +226,73 @@ export class IContractDeployer extends Contract { ): Promise; "createAccount(bytes32,bytes32,bytes,uint8)"( - _salt: BytesLike, + arg0: BytesLike, _bytecodeHash: BytesLike, _input: BytesLike, _aaVersion: BigNumberish, overrides?: PayableOverrides ): Promise; + extendedAccountVersion( + _address: string, + overrides?: CallOverrides + ): Promise<{ + 0: number; + }>; + + "extendedAccountVersion(address)"( + _address: string, + overrides?: CallOverrides + ): Promise<{ + 0: number; + }>; + + forceDeployOnAddress( + _deployment: { + bytecodeHash: BytesLike; + newAddress: string; + callConstructor: boolean; + value: BigNumberish; + input: BytesLike; + }, + _sender: string, + overrides?: PayableOverrides + ): Promise; + + "forceDeployOnAddress(tuple,address)"( + _deployment: { + bytecodeHash: BytesLike; + newAddress: string; + callConstructor: boolean; + value: BigNumberish; + input: BytesLike; + }, + _sender: string, + overrides?: PayableOverrides + ): Promise; + + forceDeployOnAddresses( + _deployments: { + bytecodeHash: BytesLike; + newAddress: string; + callConstructor: boolean; + value: BigNumberish; + input: BytesLike; + }[], + overrides?: PayableOverrides + ): Promise; + + "forceDeployOnAddresses(tuple[])"( + _deployments: { + bytecodeHash: BytesLike; + newAddress: string; + callConstructor: boolean; + value: BigNumberish; + input: BytesLike; + }[], + overrides?: PayableOverrides + ): Promise; + getAccountInfo( _address: string, overrides?: CallOverrides @@ -331,7 +435,7 @@ export class IContractDeployer extends Contract { ): Promise; createAccount( - _salt: BytesLike, + arg0: BytesLike, _bytecodeHash: BytesLike, _input: BytesLike, _aaVersion: BigNumberish, @@ -339,13 +443,69 @@ export class IContractDeployer extends Contract { ): Promise; "createAccount(bytes32,bytes32,bytes,uint8)"( - _salt: BytesLike, + arg0: BytesLike, _bytecodeHash: BytesLike, _input: BytesLike, _aaVersion: BigNumberish, overrides?: PayableOverrides ): Promise; + extendedAccountVersion( + _address: string, + overrides?: CallOverrides + ): Promise; + + "extendedAccountVersion(address)"( + _address: string, + overrides?: CallOverrides + ): Promise; + + forceDeployOnAddress( + _deployment: { + bytecodeHash: BytesLike; + newAddress: string; + callConstructor: boolean; + value: BigNumberish; + input: BytesLike; + }, + _sender: string, + overrides?: PayableOverrides + ): Promise; + + "forceDeployOnAddress(tuple,address)"( + _deployment: { + bytecodeHash: BytesLike; + newAddress: string; + callConstructor: boolean; + value: BigNumberish; + input: BytesLike; + }, + _sender: string, + overrides?: PayableOverrides + ): Promise; + + forceDeployOnAddresses( + _deployments: { + bytecodeHash: BytesLike; + newAddress: string; + callConstructor: boolean; + value: BigNumberish; + input: BytesLike; + }[], + overrides?: PayableOverrides + ): Promise; + + "forceDeployOnAddresses(tuple[])"( + _deployments: { + bytecodeHash: BytesLike; + newAddress: string; + callConstructor: boolean; + value: BigNumberish; + input: BytesLike; + }[], + overrides?: PayableOverrides + ): Promise; + getAccountInfo( _address: string, overrides?: CallOverrides @@ -460,7 +620,7 @@ export class IContractDeployer extends Contract { ): Promise; createAccount( - _salt: BytesLike, + arg0: BytesLike, _bytecodeHash: BytesLike, _input: BytesLike, _aaVersion: BigNumberish, @@ -468,13 +628,69 @@ export class IContractDeployer extends Contract { ): Promise; "createAccount(bytes32,bytes32,bytes,uint8)"( - _salt: BytesLike, + arg0: BytesLike, _bytecodeHash: BytesLike, _input: BytesLike, _aaVersion: BigNumberish, overrides?: CallOverrides ): Promise; + extendedAccountVersion( + _address: string, + overrides?: CallOverrides + ): Promise; + + "extendedAccountVersion(address)"( + _address: string, + overrides?: CallOverrides + ): Promise; + + forceDeployOnAddress( + _deployment: { + bytecodeHash: BytesLike; + newAddress: string; + callConstructor: boolean; + value: BigNumberish; + input: BytesLike; + }, + _sender: string, + overrides?: CallOverrides + ): Promise; + + "forceDeployOnAddress(tuple,address)"( + _deployment: { + bytecodeHash: BytesLike; + newAddress: string; + callConstructor: boolean; + value: BigNumberish; + input: BytesLike; + }, + _sender: string, + overrides?: CallOverrides + ): Promise; + + forceDeployOnAddresses( + _deployments: { + bytecodeHash: BytesLike; + newAddress: string; + callConstructor: boolean; + value: BigNumberish; + input: BytesLike; + }[], + overrides?: CallOverrides + ): Promise; + + "forceDeployOnAddresses(tuple[])"( + _deployments: { + bytecodeHash: BytesLike; + newAddress: string; + callConstructor: boolean; + value: BigNumberish; + input: BytesLike; + }[], + overrides?: CallOverrides + ): Promise; + getAccountInfo( _address: string, overrides?: CallOverrides @@ -608,7 +824,7 @@ export class IContractDeployer extends Contract { ): Promise; createAccount( - _salt: BytesLike, + arg0: BytesLike, _bytecodeHash: BytesLike, _input: BytesLike, _aaVersion: BigNumberish, @@ -616,13 +832,69 @@ export class IContractDeployer extends Contract { ): Promise; "createAccount(bytes32,bytes32,bytes,uint8)"( - _salt: BytesLike, + arg0: BytesLike, _bytecodeHash: BytesLike, _input: BytesLike, _aaVersion: BigNumberish, overrides?: PayableOverrides ): Promise; + extendedAccountVersion( + _address: string, + overrides?: CallOverrides + ): Promise; + + "extendedAccountVersion(address)"( + _address: string, + overrides?: CallOverrides + ): Promise; + + forceDeployOnAddress( + _deployment: { + bytecodeHash: BytesLike; + newAddress: string; + callConstructor: boolean; + value: BigNumberish; + input: BytesLike; + }, + _sender: string, + overrides?: PayableOverrides + ): Promise; + + "forceDeployOnAddress(tuple,address)"( + _deployment: { + bytecodeHash: BytesLike; + newAddress: string; + callConstructor: boolean; + value: BigNumberish; + input: BytesLike; + }, + _sender: string, + overrides?: PayableOverrides + ): Promise; + + forceDeployOnAddresses( + _deployments: { + bytecodeHash: BytesLike; + newAddress: string; + callConstructor: boolean; + value: BigNumberish; + input: BytesLike; + }[], + overrides?: PayableOverrides + ): Promise; + + "forceDeployOnAddresses(tuple[])"( + _deployments: { + bytecodeHash: BytesLike; + newAddress: string; + callConstructor: boolean; + value: BigNumberish; + input: BytesLike; + }[], + overrides?: PayableOverrides + ): Promise; + getAccountInfo( _address: string, overrides?: CallOverrides @@ -728,7 +1000,7 @@ export class IContractDeployer extends Contract { ): Promise; createAccount( - _salt: BytesLike, + arg0: BytesLike, _bytecodeHash: BytesLike, _input: BytesLike, _aaVersion: BigNumberish, @@ -736,13 +1008,69 @@ export class IContractDeployer extends Contract { ): Promise; "createAccount(bytes32,bytes32,bytes,uint8)"( - _salt: BytesLike, + arg0: BytesLike, _bytecodeHash: BytesLike, _input: BytesLike, _aaVersion: BigNumberish, overrides?: PayableOverrides ): Promise; + extendedAccountVersion( + _address: string, + overrides?: CallOverrides + ): Promise; + + "extendedAccountVersion(address)"( + _address: string, + overrides?: CallOverrides + ): Promise; + + forceDeployOnAddress( + _deployment: { + bytecodeHash: BytesLike; + newAddress: string; + callConstructor: boolean; + value: BigNumberish; + input: BytesLike; + }, + _sender: string, + overrides?: PayableOverrides + ): Promise; + + "forceDeployOnAddress(tuple,address)"( + _deployment: { + bytecodeHash: BytesLike; + newAddress: string; + callConstructor: boolean; + value: BigNumberish; + input: BytesLike; + }, + _sender: string, + overrides?: PayableOverrides + ): Promise; + + forceDeployOnAddresses( + _deployments: { + bytecodeHash: BytesLike; + newAddress: string; + callConstructor: boolean; + value: BigNumberish; + input: BytesLike; + }[], + overrides?: PayableOverrides + ): Promise; + + "forceDeployOnAddresses(tuple[])"( + _deployments: { + bytecodeHash: BytesLike; + newAddress: string; + callConstructor: boolean; + value: BigNumberish; + input: BytesLike; + }[], + overrides?: PayableOverrides + ): Promise; + getAccountInfo( _address: string, overrides?: CallOverrides diff --git a/src/typechain/IContractDeployerFactory.ts b/src/typechain/IContractDeployerFactory.ts index 3905e602..8b52f966 100644 --- a/src/typechain/IContractDeployerFactory.ts +++ b/src/typechain/IContractDeployerFactory.ts @@ -102,7 +102,7 @@ const _abi = [ outputs: [ { internalType: "address", - name: "newAddress", + name: "", type: "address", }, ], @@ -131,7 +131,7 @@ const _abi = [ outputs: [ { internalType: "address", - name: "newAddress", + name: "", type: "address", }, ], @@ -165,7 +165,7 @@ const _abi = [ outputs: [ { internalType: "address", - name: "newAddress", + name: "", type: "address", }, ], @@ -176,7 +176,7 @@ const _abi = [ inputs: [ { internalType: "bytes32", - name: "_salt", + name: "", type: "bytes32", }, { @@ -199,10 +199,114 @@ const _abi = [ outputs: [ { internalType: "address", - name: "newAddress", + name: "", + type: "address", + }, + ], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_address", + type: "address", + }, + ], + name: "extendedAccountVersion", + outputs: [ + { + internalType: "enum IContractDeployer.AccountAbstractionVersion", + name: "", + type: "uint8", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + components: [ + { + internalType: "bytes32", + name: "bytecodeHash", + type: "bytes32", + }, + { + internalType: "address", + name: "newAddress", + type: "address", + }, + { + internalType: "bool", + name: "callConstructor", + type: "bool", + }, + { + internalType: "uint256", + name: "value", + type: "uint256", + }, + { + internalType: "bytes", + name: "input", + type: "bytes", + }, + ], + internalType: "struct ContractDeployer.ForceDeployment", + name: "_deployment", + type: "tuple", + }, + { + internalType: "address", + name: "_sender", type: "address", }, ], + name: "forceDeployOnAddress", + outputs: [], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + components: [ + { + internalType: "bytes32", + name: "bytecodeHash", + type: "bytes32", + }, + { + internalType: "address", + name: "newAddress", + type: "address", + }, + { + internalType: "bool", + name: "callConstructor", + type: "bool", + }, + { + internalType: "uint256", + name: "value", + type: "uint256", + }, + { + internalType: "bytes", + name: "input", + type: "bytes", + }, + ], + internalType: "struct ContractDeployer.ForceDeployment[]", + name: "_deployments", + type: "tuple[]", + }, + ], + name: "forceDeployOnAddresses", + outputs: [], stateMutability: "payable", type: "function", }, diff --git a/src/typechain/ITestnetErc20Token.d.ts b/src/typechain/ITestnetErc20Token.d.ts new file mode 100644 index 00000000..dd70f4d1 --- /dev/null +++ b/src/typechain/ITestnetErc20Token.d.ts @@ -0,0 +1,143 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { + ethers, + EventFilter, + Signer, + BigNumber, + BigNumberish, + PopulatedTransaction, +} from "ethers"; +import { + Contract, + ContractTransaction, + Overrides, + CallOverrides, +} from "@ethersproject/contracts"; +import { BytesLike } from "@ethersproject/bytes"; +import { Listener, Provider } from "@ethersproject/providers"; +import { FunctionFragment, EventFragment, Result } from "@ethersproject/abi"; + +interface ITestnetErc20TokenInterface extends ethers.utils.Interface { + functions: { + "decimals()": FunctionFragment; + "mint(address,uint256)": FunctionFragment; + }; + + encodeFunctionData(functionFragment: "decimals", values?: undefined): string; + encodeFunctionData( + functionFragment: "mint", + values: [string, BigNumberish] + ): string; + + decodeFunctionResult(functionFragment: "decimals", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "mint", data: BytesLike): Result; + + events: {}; +} + +export class ITestnetErc20Token extends Contract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + on(event: EventFilter | string, listener: Listener): this; + once(event: EventFilter | string, listener: Listener): this; + addListener(eventName: EventFilter | string, listener: Listener): this; + removeAllListeners(eventName: EventFilter | string): this; + removeListener(eventName: any, listener: Listener): this; + + interface: ITestnetErc20TokenInterface; + + functions: { + decimals(overrides?: Overrides): Promise; + + "decimals()"(overrides?: Overrides): Promise; + + mint( + _to: string, + _amount: BigNumberish, + overrides?: Overrides + ): Promise; + + "mint(address,uint256)"( + _to: string, + _amount: BigNumberish, + overrides?: Overrides + ): Promise; + }; + + decimals(overrides?: Overrides): Promise; + + "decimals()"(overrides?: Overrides): Promise; + + mint( + _to: string, + _amount: BigNumberish, + overrides?: Overrides + ): Promise; + + "mint(address,uint256)"( + _to: string, + _amount: BigNumberish, + overrides?: Overrides + ): Promise; + + callStatic: { + decimals(overrides?: CallOverrides): Promise; + + "decimals()"(overrides?: CallOverrides): Promise; + + mint( + _to: string, + _amount: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "mint(address,uint256)"( + _to: string, + _amount: BigNumberish, + overrides?: CallOverrides + ): Promise; + }; + + filters: {}; + + estimateGas: { + decimals(overrides?: Overrides): Promise; + + "decimals()"(overrides?: Overrides): Promise; + + mint( + _to: string, + _amount: BigNumberish, + overrides?: Overrides + ): Promise; + + "mint(address,uint256)"( + _to: string, + _amount: BigNumberish, + overrides?: Overrides + ): Promise; + }; + + populateTransaction: { + decimals(overrides?: Overrides): Promise; + + "decimals()"(overrides?: Overrides): Promise; + + mint( + _to: string, + _amount: BigNumberish, + overrides?: Overrides + ): Promise; + + "mint(address,uint256)"( + _to: string, + _amount: BigNumberish, + overrides?: Overrides + ): Promise; + }; +} diff --git a/src/typechain/ITestnetErc20TokenFactory.ts b/src/typechain/ITestnetErc20TokenFactory.ts new file mode 100644 index 00000000..b4c3d7c6 --- /dev/null +++ b/src/typechain/ITestnetErc20TokenFactory.ts @@ -0,0 +1,57 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer } from "ethers"; +import { Provider } from "@ethersproject/providers"; + +import type { ITestnetErc20Token } from "./ITestnetErc20Token"; + +export class ITestnetErc20TokenFactory { + static connect( + address: string, + signerOrProvider: Signer | Provider + ): ITestnetErc20Token { + return new Contract(address, _abi, signerOrProvider) as ITestnetErc20Token; + } +} + +const _abi = [ + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_to", + type: "address", + }, + { + internalType: "uint256", + name: "_amount", + type: "uint256", + }, + ], + name: "mint", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, +]; diff --git a/src/typechain/IZkSyncStateTransition.d.ts b/src/typechain/IZkSyncStateTransition.d.ts new file mode 100644 index 00000000..d0a709cb --- /dev/null +++ b/src/typechain/IZkSyncStateTransition.d.ts @@ -0,0 +1,5495 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { + ethers, + EventFilter, + Signer, + BigNumber, + BigNumberish, + PopulatedTransaction, +} from "ethers"; +import { + Contract, + ContractTransaction, + Overrides, + PayableOverrides, + CallOverrides, +} from "@ethersproject/contracts"; +import { BytesLike } from "@ethersproject/bytes"; +import { Listener, Provider } from "@ethersproject/providers"; +import { FunctionFragment, EventFragment, Result } from "@ethersproject/abi"; + +interface IZkSyncStateTransitionInterface extends ethers.utils.Interface { + functions: { + "acceptAdmin()": FunctionFragment; + "baseTokenGasPriceMultiplierDenominator()": FunctionFragment; + "baseTokenGasPriceMultiplierNominator()": FunctionFragment; + "bridgehubRequestL2Transaction(tuple)": FunctionFragment; + "changeFeeParams(tuple)": FunctionFragment; + "commitBatches(tuple,tuple[])": FunctionFragment; + "commitBatchesSharedBridge(uint256,tuple,tuple[])": FunctionFragment; + "executeBatches(tuple[])": FunctionFragment; + "executeBatchesSharedBridge(uint256,tuple[])": FunctionFragment; + "executeUpgrade(tuple)": FunctionFragment; + "facetAddress(bytes4)": FunctionFragment; + "facetAddresses()": FunctionFragment; + "facetFunctionSelectors(address)": FunctionFragment; + "facets()": FunctionFragment; + "finalizeEthWithdrawal(uint256,uint256,uint16,bytes,bytes32[])": FunctionFragment; + "freezeDiamond()": FunctionFragment; + "getAdmin()": FunctionFragment; + "getBaseToken()": FunctionFragment; + "getBaseTokenBridge()": FunctionFragment; + "getBridgehub()": FunctionFragment; + "getFirstUnprocessedPriorityTx()": FunctionFragment; + "getL2BootloaderBytecodeHash()": FunctionFragment; + "getL2DefaultAccountBytecodeHash()": FunctionFragment; + "getL2SystemContractsUpgradeBatchNumber()": FunctionFragment; + "getL2SystemContractsUpgradeTxHash()": FunctionFragment; + "getName()": FunctionFragment; + "getPendingAdmin()": FunctionFragment; + "getPriorityQueueSize()": FunctionFragment; + "getPriorityTxMaxGasLimit()": FunctionFragment; + "getProtocolVersion()": FunctionFragment; + "getPubdataPricingMode()": FunctionFragment; + "getStateTransitionManager()": FunctionFragment; + "getTotalBatchesCommitted()": FunctionFragment; + "getTotalBatchesExecuted()": FunctionFragment; + "getTotalBatchesVerified()": FunctionFragment; + "getTotalPriorityTxs()": FunctionFragment; + "getVerifier()": FunctionFragment; + "getVerifierParams()": FunctionFragment; + "isDiamondStorageFrozen()": FunctionFragment; + "isEthWithdrawalFinalized(uint256,uint256)": FunctionFragment; + "isFacetFreezable(address)": FunctionFragment; + "isFunctionFreezable(bytes4)": FunctionFragment; + "isValidator(address)": FunctionFragment; + "l2LogsRootHash(uint256)": FunctionFragment; + "l2TransactionBaseCost(uint256,uint256,uint256)": FunctionFragment; + "priorityQueueFrontOperation()": FunctionFragment; + "proveBatches(tuple,tuple[],tuple)": FunctionFragment; + "proveBatchesSharedBridge(uint256,tuple,tuple[],tuple)": FunctionFragment; + "proveL1ToL2TransactionStatus(bytes32,uint256,uint256,uint16,bytes32[],uint8)": FunctionFragment; + "proveL2LogInclusion(uint256,uint256,tuple,bytes32[])": FunctionFragment; + "proveL2MessageInclusion(uint256,uint256,tuple,bytes32[])": FunctionFragment; + "requestL2Transaction(address,uint256,bytes,uint256,uint256,bytes[],address)": FunctionFragment; + "revertBatches(uint256)": FunctionFragment; + "revertBatchesSharedBridge(uint256,uint256)": FunctionFragment; + "setPendingAdmin(address)": FunctionFragment; + "setPorterAvailability(bool)": FunctionFragment; + "setPriorityTxMaxGasLimit(uint256)": FunctionFragment; + "setTokenMultiplier(uint128,uint128)": FunctionFragment; + "setTransactionFilterer(address)": FunctionFragment; + "setValidator(address,bool)": FunctionFragment; + "setValidiumMode(uint8)": FunctionFragment; + "storedBatchHash(uint256)": FunctionFragment; + "transferEthToSharedBridge()": FunctionFragment; + "unfreezeDiamond()": FunctionFragment; + "upgradeChainFromVersion(uint256,tuple)": FunctionFragment; + }; + + encodeFunctionData( + functionFragment: "acceptAdmin", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "baseTokenGasPriceMultiplierDenominator", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "baseTokenGasPriceMultiplierNominator", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "bridgehubRequestL2Transaction", + values: [ + { + sender: string; + contractL2: string; + mintValue: BigNumberish; + l2Value: BigNumberish; + l2Calldata: BytesLike; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + factoryDeps: BytesLike[]; + refundRecipient: string; + } + ] + ): string; + encodeFunctionData( + functionFragment: "changeFeeParams", + values: [ + { + pubdataPricingMode: BigNumberish; + batchOverheadL1Gas: BigNumberish; + maxPubdataPerBatch: BigNumberish; + maxL2GasPerBatch: BigNumberish; + priorityTxMaxPubdata: BigNumberish; + minimalL2GasPrice: BigNumberish; + } + ] + ): string; + encodeFunctionData( + functionFragment: "commitBatches", + values: [ + { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + { + batchNumber: BigNumberish; + timestamp: BigNumberish; + indexRepeatedStorageChanges: BigNumberish; + newStateRoot: BytesLike; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + bootloaderHeapInitialContentsHash: BytesLike; + eventsQueueStateHash: BytesLike; + systemLogs: BytesLike; + pubdataCommitments: BytesLike; + }[] + ] + ): string; + encodeFunctionData( + functionFragment: "commitBatchesSharedBridge", + values: [ + BigNumberish, + { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + { + batchNumber: BigNumberish; + timestamp: BigNumberish; + indexRepeatedStorageChanges: BigNumberish; + newStateRoot: BytesLike; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + bootloaderHeapInitialContentsHash: BytesLike; + eventsQueueStateHash: BytesLike; + systemLogs: BytesLike; + pubdataCommitments: BytesLike; + }[] + ] + ): string; + encodeFunctionData( + functionFragment: "executeBatches", + values: [ + { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[] + ] + ): string; + encodeFunctionData( + functionFragment: "executeBatchesSharedBridge", + values: [ + BigNumberish, + { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[] + ] + ): string; + encodeFunctionData( + functionFragment: "executeUpgrade", + values: [ + { + facetCuts: { + facet: string; + action: BigNumberish; + isFreezable: boolean; + selectors: BytesLike[]; + }[]; + initAddress: string; + initCalldata: BytesLike; + } + ] + ): string; + encodeFunctionData( + functionFragment: "facetAddress", + values: [BytesLike] + ): string; + encodeFunctionData( + functionFragment: "facetAddresses", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "facetFunctionSelectors", + values: [string] + ): string; + encodeFunctionData(functionFragment: "facets", values?: undefined): string; + encodeFunctionData( + functionFragment: "finalizeEthWithdrawal", + values: [BigNumberish, BigNumberish, BigNumberish, BytesLike, BytesLike[]] + ): string; + encodeFunctionData( + functionFragment: "freezeDiamond", + values?: undefined + ): string; + encodeFunctionData(functionFragment: "getAdmin", values?: undefined): string; + encodeFunctionData( + functionFragment: "getBaseToken", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getBaseTokenBridge", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getBridgehub", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getFirstUnprocessedPriorityTx", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getL2BootloaderBytecodeHash", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getL2DefaultAccountBytecodeHash", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getL2SystemContractsUpgradeBatchNumber", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getL2SystemContractsUpgradeTxHash", + values?: undefined + ): string; + encodeFunctionData(functionFragment: "getName", values?: undefined): string; + encodeFunctionData( + functionFragment: "getPendingAdmin", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getPriorityQueueSize", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getPriorityTxMaxGasLimit", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getProtocolVersion", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getPubdataPricingMode", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getStateTransitionManager", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getTotalBatchesCommitted", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getTotalBatchesExecuted", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getTotalBatchesVerified", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getTotalPriorityTxs", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getVerifier", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "getVerifierParams", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "isDiamondStorageFrozen", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "isEthWithdrawalFinalized", + values: [BigNumberish, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "isFacetFreezable", + values: [string] + ): string; + encodeFunctionData( + functionFragment: "isFunctionFreezable", + values: [BytesLike] + ): string; + encodeFunctionData(functionFragment: "isValidator", values: [string]): string; + encodeFunctionData( + functionFragment: "l2LogsRootHash", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "l2TransactionBaseCost", + values: [BigNumberish, BigNumberish, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "priorityQueueFrontOperation", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "proveBatches", + values: [ + { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + { + recursiveAggregationInput: BigNumberish[]; + serializedProof: BigNumberish[]; + } + ] + ): string; + encodeFunctionData( + functionFragment: "proveBatchesSharedBridge", + values: [ + BigNumberish, + { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + { + recursiveAggregationInput: BigNumberish[]; + serializedProof: BigNumberish[]; + } + ] + ): string; + encodeFunctionData( + functionFragment: "proveL1ToL2TransactionStatus", + values: [ + BytesLike, + BigNumberish, + BigNumberish, + BigNumberish, + BytesLike[], + BigNumberish + ] + ): string; + encodeFunctionData( + functionFragment: "proveL2LogInclusion", + values: [ + BigNumberish, + BigNumberish, + { + l2ShardId: BigNumberish; + isService: boolean; + txNumberInBatch: BigNumberish; + sender: string; + key: BytesLike; + value: BytesLike; + }, + BytesLike[] + ] + ): string; + encodeFunctionData( + functionFragment: "proveL2MessageInclusion", + values: [ + BigNumberish, + BigNumberish, + { txNumberInBatch: BigNumberish; sender: string; data: BytesLike }, + BytesLike[] + ] + ): string; + encodeFunctionData( + functionFragment: "requestL2Transaction", + values: [ + string, + BigNumberish, + BytesLike, + BigNumberish, + BigNumberish, + BytesLike[], + string + ] + ): string; + encodeFunctionData( + functionFragment: "revertBatches", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "revertBatchesSharedBridge", + values: [BigNumberish, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "setPendingAdmin", + values: [string] + ): string; + encodeFunctionData( + functionFragment: "setPorterAvailability", + values: [boolean] + ): string; + encodeFunctionData( + functionFragment: "setPriorityTxMaxGasLimit", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "setTokenMultiplier", + values: [BigNumberish, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "setTransactionFilterer", + values: [string] + ): string; + encodeFunctionData( + functionFragment: "setValidator", + values: [string, boolean] + ): string; + encodeFunctionData( + functionFragment: "setValidiumMode", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "storedBatchHash", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "transferEthToSharedBridge", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "unfreezeDiamond", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "upgradeChainFromVersion", + values: [ + BigNumberish, + { + facetCuts: { + facet: string; + action: BigNumberish; + isFreezable: boolean; + selectors: BytesLike[]; + }[]; + initAddress: string; + initCalldata: BytesLike; + } + ] + ): string; + + decodeFunctionResult( + functionFragment: "acceptAdmin", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "baseTokenGasPriceMultiplierDenominator", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "baseTokenGasPriceMultiplierNominator", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "bridgehubRequestL2Transaction", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "changeFeeParams", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "commitBatches", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "commitBatchesSharedBridge", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "executeBatches", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "executeBatchesSharedBridge", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "executeUpgrade", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "facetAddress", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "facetAddresses", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "facetFunctionSelectors", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "facets", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "finalizeEthWithdrawal", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "freezeDiamond", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "getAdmin", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "getBaseToken", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getBaseTokenBridge", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getBridgehub", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getFirstUnprocessedPriorityTx", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getL2BootloaderBytecodeHash", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getL2DefaultAccountBytecodeHash", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getL2SystemContractsUpgradeBatchNumber", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getL2SystemContractsUpgradeTxHash", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "getName", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "getPendingAdmin", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getPriorityQueueSize", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getPriorityTxMaxGasLimit", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getProtocolVersion", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getPubdataPricingMode", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getStateTransitionManager", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getTotalBatchesCommitted", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getTotalBatchesExecuted", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getTotalBatchesVerified", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getTotalPriorityTxs", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getVerifier", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getVerifierParams", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "isDiamondStorageFrozen", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "isEthWithdrawalFinalized", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "isFacetFreezable", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "isFunctionFreezable", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "isValidator", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "l2LogsRootHash", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "l2TransactionBaseCost", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "priorityQueueFrontOperation", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "proveBatches", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "proveBatchesSharedBridge", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "proveL1ToL2TransactionStatus", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "proveL2LogInclusion", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "proveL2MessageInclusion", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "requestL2Transaction", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "revertBatches", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "revertBatchesSharedBridge", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "setPendingAdmin", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "setPorterAvailability", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "setPriorityTxMaxGasLimit", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "setTokenMultiplier", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "setTransactionFilterer", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "setValidator", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "setValidiumMode", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "storedBatchHash", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "transferEthToSharedBridge", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "unfreezeDiamond", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "upgradeChainFromVersion", + data: BytesLike + ): Result; + + events: { + "BlockCommit(uint256,bytes32,bytes32)": EventFragment; + "BlockExecution(uint256,bytes32,bytes32)": EventFragment; + "BlocksRevert(uint256,uint256,uint256)": EventFragment; + "BlocksVerification(uint256,uint256)": EventFragment; + "EthWithdrawalFinalized(address,uint256)": EventFragment; + "ExecuteUpgrade(tuple)": EventFragment; + "Freeze()": EventFragment; + "IsPorterAvailableStatusUpdate(bool)": EventFragment; + "NewAdmin(address,address)": EventFragment; + "NewBaseTokenMultiplier(uint128,uint128,uint128,uint128)": EventFragment; + "NewFeeParams(tuple,tuple)": EventFragment; + "NewPendingAdmin(address,address)": EventFragment; + "NewPriorityRequest(uint256,bytes32,uint64,tuple,bytes[])": EventFragment; + "NewPriorityTxMaxGasLimit(uint256,uint256)": EventFragment; + "NewTransactionFilterer(address,address)": EventFragment; + "ProposeTransparentUpgrade(tuple,uint256,bytes32)": EventFragment; + "Unfreeze()": EventFragment; + "ValidatorStatusUpdate(address,bool)": EventFragment; + "ValidiumModeStatusUpdate(uint8)": EventFragment; + }; + + getEvent(nameOrSignatureOrTopic: "BlockCommit"): EventFragment; + getEvent(nameOrSignatureOrTopic: "BlockExecution"): EventFragment; + getEvent(nameOrSignatureOrTopic: "BlocksRevert"): EventFragment; + getEvent(nameOrSignatureOrTopic: "BlocksVerification"): EventFragment; + getEvent(nameOrSignatureOrTopic: "EthWithdrawalFinalized"): EventFragment; + getEvent(nameOrSignatureOrTopic: "ExecuteUpgrade"): EventFragment; + getEvent(nameOrSignatureOrTopic: "Freeze"): EventFragment; + getEvent( + nameOrSignatureOrTopic: "IsPorterAvailableStatusUpdate" + ): EventFragment; + getEvent(nameOrSignatureOrTopic: "NewAdmin"): EventFragment; + getEvent(nameOrSignatureOrTopic: "NewBaseTokenMultiplier"): EventFragment; + getEvent(nameOrSignatureOrTopic: "NewFeeParams"): EventFragment; + getEvent(nameOrSignatureOrTopic: "NewPendingAdmin"): EventFragment; + getEvent(nameOrSignatureOrTopic: "NewPriorityRequest"): EventFragment; + getEvent(nameOrSignatureOrTopic: "NewPriorityTxMaxGasLimit"): EventFragment; + getEvent(nameOrSignatureOrTopic: "NewTransactionFilterer"): EventFragment; + getEvent(nameOrSignatureOrTopic: "ProposeTransparentUpgrade"): EventFragment; + getEvent(nameOrSignatureOrTopic: "Unfreeze"): EventFragment; + getEvent(nameOrSignatureOrTopic: "ValidatorStatusUpdate"): EventFragment; + getEvent(nameOrSignatureOrTopic: "ValidiumModeStatusUpdate"): EventFragment; +} + +export class IZkSyncStateTransition extends Contract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + on(event: EventFilter | string, listener: Listener): this; + once(event: EventFilter | string, listener: Listener): this; + addListener(eventName: EventFilter | string, listener: Listener): this; + removeAllListeners(eventName: EventFilter | string): this; + removeListener(eventName: any, listener: Listener): this; + + interface: IZkSyncStateTransitionInterface; + + functions: { + acceptAdmin(overrides?: Overrides): Promise; + + "acceptAdmin()"(overrides?: Overrides): Promise; + + baseTokenGasPriceMultiplierDenominator(overrides?: CallOverrides): Promise<{ + 0: BigNumber; + }>; + + "baseTokenGasPriceMultiplierDenominator()"( + overrides?: CallOverrides + ): Promise<{ + 0: BigNumber; + }>; + + baseTokenGasPriceMultiplierNominator(overrides?: CallOverrides): Promise<{ + 0: BigNumber; + }>; + + "baseTokenGasPriceMultiplierNominator()"( + overrides?: CallOverrides + ): Promise<{ + 0: BigNumber; + }>; + + bridgehubRequestL2Transaction( + _request: { + sender: string; + contractL2: string; + mintValue: BigNumberish; + l2Value: BigNumberish; + l2Calldata: BytesLike; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + factoryDeps: BytesLike[]; + refundRecipient: string; + }, + overrides?: PayableOverrides + ): Promise; + + "bridgehubRequestL2Transaction(tuple)"( + _request: { + sender: string; + contractL2: string; + mintValue: BigNumberish; + l2Value: BigNumberish; + l2Calldata: BytesLike; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + factoryDeps: BytesLike[]; + refundRecipient: string; + }, + overrides?: PayableOverrides + ): Promise; + + changeFeeParams( + _newFeeParams: { + pubdataPricingMode: BigNumberish; + batchOverheadL1Gas: BigNumberish; + maxPubdataPerBatch: BigNumberish; + maxL2GasPerBatch: BigNumberish; + priorityTxMaxPubdata: BigNumberish; + minimalL2GasPrice: BigNumberish; + }, + overrides?: Overrides + ): Promise; + + "changeFeeParams(tuple)"( + _newFeeParams: { + pubdataPricingMode: BigNumberish; + batchOverheadL1Gas: BigNumberish; + maxPubdataPerBatch: BigNumberish; + maxL2GasPerBatch: BigNumberish; + priorityTxMaxPubdata: BigNumberish; + minimalL2GasPrice: BigNumberish; + }, + overrides?: Overrides + ): Promise; + + commitBatches( + _lastCommittedBatchData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _newBatchesData: { + batchNumber: BigNumberish; + timestamp: BigNumberish; + indexRepeatedStorageChanges: BigNumberish; + newStateRoot: BytesLike; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + bootloaderHeapInitialContentsHash: BytesLike; + eventsQueueStateHash: BytesLike; + systemLogs: BytesLike; + pubdataCommitments: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + "commitBatches(tuple,tuple[])"( + _lastCommittedBatchData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _newBatchesData: { + batchNumber: BigNumberish; + timestamp: BigNumberish; + indexRepeatedStorageChanges: BigNumberish; + newStateRoot: BytesLike; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + bootloaderHeapInitialContentsHash: BytesLike; + eventsQueueStateHash: BytesLike; + systemLogs: BytesLike; + pubdataCommitments: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + commitBatchesSharedBridge( + _chainId: BigNumberish, + _lastCommittedBatchData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _newBatchesData: { + batchNumber: BigNumberish; + timestamp: BigNumberish; + indexRepeatedStorageChanges: BigNumberish; + newStateRoot: BytesLike; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + bootloaderHeapInitialContentsHash: BytesLike; + eventsQueueStateHash: BytesLike; + systemLogs: BytesLike; + pubdataCommitments: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + "commitBatchesSharedBridge(uint256,tuple,tuple[])"( + _chainId: BigNumberish, + _lastCommittedBatchData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _newBatchesData: { + batchNumber: BigNumberish; + timestamp: BigNumberish; + indexRepeatedStorageChanges: BigNumberish; + newStateRoot: BytesLike; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + bootloaderHeapInitialContentsHash: BytesLike; + eventsQueueStateHash: BytesLike; + systemLogs: BytesLike; + pubdataCommitments: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + executeBatches( + _batchesData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + "executeBatches(tuple[])"( + _batchesData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + executeBatchesSharedBridge( + _chainId: BigNumberish, + _batchesData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + "executeBatchesSharedBridge(uint256,tuple[])"( + _chainId: BigNumberish, + _batchesData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + executeUpgrade( + _diamondCut: { + facetCuts: { + facet: string; + action: BigNumberish; + isFreezable: boolean; + selectors: BytesLike[]; + }[]; + initAddress: string; + initCalldata: BytesLike; + }, + overrides?: Overrides + ): Promise; + + "executeUpgrade(tuple)"( + _diamondCut: { + facetCuts: { + facet: string; + action: BigNumberish; + isFreezable: boolean; + selectors: BytesLike[]; + }[]; + initAddress: string; + initCalldata: BytesLike; + }, + overrides?: Overrides + ): Promise; + + facetAddress( + _selector: BytesLike, + overrides?: CallOverrides + ): Promise<{ + facet: string; + 0: string; + }>; + + "facetAddress(bytes4)"( + _selector: BytesLike, + overrides?: CallOverrides + ): Promise<{ + facet: string; + 0: string; + }>; + + facetAddresses(overrides?: CallOverrides): Promise<{ + facets: string[]; + 0: string[]; + }>; + + "facetAddresses()"(overrides?: CallOverrides): Promise<{ + facets: string[]; + 0: string[]; + }>; + + facetFunctionSelectors( + _facet: string, + overrides?: CallOverrides + ): Promise<{ + 0: string[]; + }>; + + "facetFunctionSelectors(address)"( + _facet: string, + overrides?: CallOverrides + ): Promise<{ + 0: string[]; + }>; + + facets(overrides?: CallOverrides): Promise<{ + 0: { addr: string; selectors: string[]; 0: string; 1: string[] }[]; + }>; + + "facets()"(overrides?: CallOverrides): Promise<{ + 0: { addr: string; selectors: string[]; 0: string; 1: string[] }[]; + }>; + + finalizeEthWithdrawal( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "finalizeEthWithdrawal(uint256,uint256,uint16,bytes,bytes32[])"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + freezeDiamond(overrides?: Overrides): Promise; + + "freezeDiamond()"(overrides?: Overrides): Promise; + + getAdmin(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + "getAdmin()"(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + getBaseToken(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + "getBaseToken()"(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + getBaseTokenBridge(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + "getBaseTokenBridge()"(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + getBridgehub(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + "getBridgehub()"(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + getFirstUnprocessedPriorityTx(overrides?: CallOverrides): Promise<{ + 0: BigNumber; + }>; + + "getFirstUnprocessedPriorityTx()"(overrides?: CallOverrides): Promise<{ + 0: BigNumber; + }>; + + getL2BootloaderBytecodeHash(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + "getL2BootloaderBytecodeHash()"(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + getL2DefaultAccountBytecodeHash(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + "getL2DefaultAccountBytecodeHash()"(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + getL2SystemContractsUpgradeBatchNumber(overrides?: CallOverrides): Promise<{ + 0: BigNumber; + }>; + + "getL2SystemContractsUpgradeBatchNumber()"( + overrides?: CallOverrides + ): Promise<{ + 0: BigNumber; + }>; + + getL2SystemContractsUpgradeTxHash(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + "getL2SystemContractsUpgradeTxHash()"(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + getName(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + "getName()"(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + getPendingAdmin(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + "getPendingAdmin()"(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + getPriorityQueueSize(overrides?: CallOverrides): Promise<{ + 0: BigNumber; + }>; + + "getPriorityQueueSize()"(overrides?: CallOverrides): Promise<{ + 0: BigNumber; + }>; + + getPriorityTxMaxGasLimit(overrides?: CallOverrides): Promise<{ + 0: BigNumber; + }>; + + "getPriorityTxMaxGasLimit()"(overrides?: CallOverrides): Promise<{ + 0: BigNumber; + }>; + + getProtocolVersion(overrides?: CallOverrides): Promise<{ + 0: BigNumber; + }>; + + "getProtocolVersion()"(overrides?: CallOverrides): Promise<{ + 0: BigNumber; + }>; + + getPubdataPricingMode(overrides?: CallOverrides): Promise<{ + 0: number; + }>; + + "getPubdataPricingMode()"(overrides?: CallOverrides): Promise<{ + 0: number; + }>; + + getStateTransitionManager(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + "getStateTransitionManager()"(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + getTotalBatchesCommitted(overrides?: CallOverrides): Promise<{ + 0: BigNumber; + }>; + + "getTotalBatchesCommitted()"(overrides?: CallOverrides): Promise<{ + 0: BigNumber; + }>; + + getTotalBatchesExecuted(overrides?: CallOverrides): Promise<{ + 0: BigNumber; + }>; + + "getTotalBatchesExecuted()"(overrides?: CallOverrides): Promise<{ + 0: BigNumber; + }>; + + getTotalBatchesVerified(overrides?: CallOverrides): Promise<{ + 0: BigNumber; + }>; + + "getTotalBatchesVerified()"(overrides?: CallOverrides): Promise<{ + 0: BigNumber; + }>; + + getTotalPriorityTxs(overrides?: CallOverrides): Promise<{ + 0: BigNumber; + }>; + + "getTotalPriorityTxs()"(overrides?: CallOverrides): Promise<{ + 0: BigNumber; + }>; + + getVerifier(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + "getVerifier()"(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + getVerifierParams(overrides?: CallOverrides): Promise<{ + 0: { + recursionNodeLevelVkHash: string; + recursionLeafLevelVkHash: string; + recursionCircuitsSetVksHash: string; + 0: string; + 1: string; + 2: string; + }; + }>; + + "getVerifierParams()"(overrides?: CallOverrides): Promise<{ + 0: { + recursionNodeLevelVkHash: string; + recursionLeafLevelVkHash: string; + recursionCircuitsSetVksHash: string; + 0: string; + 1: string; + 2: string; + }; + }>; + + isDiamondStorageFrozen(overrides?: CallOverrides): Promise<{ + 0: boolean; + }>; + + "isDiamondStorageFrozen()"(overrides?: CallOverrides): Promise<{ + 0: boolean; + }>; + + isEthWithdrawalFinalized( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + "isEthWithdrawalFinalized(uint256,uint256)"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + isFacetFreezable( + _facet: string, + overrides?: CallOverrides + ): Promise<{ + isFreezable: boolean; + 0: boolean; + }>; + + "isFacetFreezable(address)"( + _facet: string, + overrides?: CallOverrides + ): Promise<{ + isFreezable: boolean; + 0: boolean; + }>; + + isFunctionFreezable( + _selector: BytesLike, + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + "isFunctionFreezable(bytes4)"( + _selector: BytesLike, + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + isValidator( + _address: string, + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + "isValidator(address)"( + _address: string, + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + l2LogsRootHash( + _batchNumber: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + merkleRoot: string; + 0: string; + }>; + + "l2LogsRootHash(uint256)"( + _batchNumber: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + merkleRoot: string; + 0: string; + }>; + + l2TransactionBaseCost( + _gasPrice: BigNumberish, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: BigNumber; + }>; + + "l2TransactionBaseCost(uint256,uint256,uint256)"( + _gasPrice: BigNumberish, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: BigNumber; + }>; + + priorityQueueFrontOperation(overrides?: CallOverrides): Promise<{ + 0: { + canonicalTxHash: string; + expirationTimestamp: BigNumber; + layer2Tip: BigNumber; + 0: string; + 1: BigNumber; + 2: BigNumber; + }; + }>; + + "priorityQueueFrontOperation()"(overrides?: CallOverrides): Promise<{ + 0: { + canonicalTxHash: string; + expirationTimestamp: BigNumber; + layer2Tip: BigNumber; + 0: string; + 1: BigNumber; + 2: BigNumber; + }; + }>; + + proveBatches( + _prevBatch: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _committedBatches: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + _proof: { + recursiveAggregationInput: BigNumberish[]; + serializedProof: BigNumberish[]; + }, + overrides?: Overrides + ): Promise; + + "proveBatches(tuple,tuple[],tuple)"( + _prevBatch: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _committedBatches: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + _proof: { + recursiveAggregationInput: BigNumberish[]; + serializedProof: BigNumberish[]; + }, + overrides?: Overrides + ): Promise; + + proveBatchesSharedBridge( + _chainId: BigNumberish, + _prevBatch: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _committedBatches: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + _proof: { + recursiveAggregationInput: BigNumberish[]; + serializedProof: BigNumberish[]; + }, + overrides?: Overrides + ): Promise; + + "proveBatchesSharedBridge(uint256,tuple,tuple[],tuple)"( + _chainId: BigNumberish, + _prevBatch: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _committedBatches: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + _proof: { + recursiveAggregationInput: BigNumberish[]; + serializedProof: BigNumberish[]; + }, + overrides?: Overrides + ): Promise; + + proveL1ToL2TransactionStatus( + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + _status: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + "proveL1ToL2TransactionStatus(bytes32,uint256,uint256,uint16,bytes32[],uint8)"( + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + _status: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + proveL2LogInclusion( + _batchNumber: BigNumberish, + _index: BigNumberish, + _log: { + l2ShardId: BigNumberish; + isService: boolean; + txNumberInBatch: BigNumberish; + sender: string; + key: BytesLike; + value: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + "proveL2LogInclusion(uint256,uint256,tuple,bytes32[])"( + _batchNumber: BigNumberish, + _index: BigNumberish, + _log: { + l2ShardId: BigNumberish; + isService: boolean; + txNumberInBatch: BigNumberish; + sender: string; + key: BytesLike; + value: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + proveL2MessageInclusion( + _batchNumber: BigNumberish, + _index: BigNumberish, + _message: { + txNumberInBatch: BigNumberish; + sender: string; + data: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + "proveL2MessageInclusion(uint256,uint256,tuple,bytes32[])"( + _batchNumber: BigNumberish, + _index: BigNumberish, + _message: { + txNumberInBatch: BigNumberish; + sender: string; + data: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + requestL2Transaction( + _contractL2: string, + _l2Value: BigNumberish, + _calldata: BytesLike, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + _factoryDeps: BytesLike[], + _refundRecipient: string, + overrides?: PayableOverrides + ): Promise; + + "requestL2Transaction(address,uint256,bytes,uint256,uint256,bytes[],address)"( + _contractL2: string, + _l2Value: BigNumberish, + _calldata: BytesLike, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + _factoryDeps: BytesLike[], + _refundRecipient: string, + overrides?: PayableOverrides + ): Promise; + + revertBatches( + _newLastBatch: BigNumberish, + overrides?: Overrides + ): Promise; + + "revertBatches(uint256)"( + _newLastBatch: BigNumberish, + overrides?: Overrides + ): Promise; + + revertBatchesSharedBridge( + _chainId: BigNumberish, + _newLastBatch: BigNumberish, + overrides?: Overrides + ): Promise; + + "revertBatchesSharedBridge(uint256,uint256)"( + _chainId: BigNumberish, + _newLastBatch: BigNumberish, + overrides?: Overrides + ): Promise; + + setPendingAdmin( + _newPendingAdmin: string, + overrides?: Overrides + ): Promise; + + "setPendingAdmin(address)"( + _newPendingAdmin: string, + overrides?: Overrides + ): Promise; + + setPorterAvailability( + _zkPorterIsAvailable: boolean, + overrides?: Overrides + ): Promise; + + "setPorterAvailability(bool)"( + _zkPorterIsAvailable: boolean, + overrides?: Overrides + ): Promise; + + setPriorityTxMaxGasLimit( + _newPriorityTxMaxGasLimit: BigNumberish, + overrides?: Overrides + ): Promise; + + "setPriorityTxMaxGasLimit(uint256)"( + _newPriorityTxMaxGasLimit: BigNumberish, + overrides?: Overrides + ): Promise; + + setTokenMultiplier( + _nominator: BigNumberish, + _denominator: BigNumberish, + overrides?: Overrides + ): Promise; + + "setTokenMultiplier(uint128,uint128)"( + _nominator: BigNumberish, + _denominator: BigNumberish, + overrides?: Overrides + ): Promise; + + setTransactionFilterer( + _transactionFilterer: string, + overrides?: Overrides + ): Promise; + + "setTransactionFilterer(address)"( + _transactionFilterer: string, + overrides?: Overrides + ): Promise; + + setValidator( + _validator: string, + _active: boolean, + overrides?: Overrides + ): Promise; + + "setValidator(address,bool)"( + _validator: string, + _active: boolean, + overrides?: Overrides + ): Promise; + + setValidiumMode( + _validiumMode: BigNumberish, + overrides?: Overrides + ): Promise; + + "setValidiumMode(uint8)"( + _validiumMode: BigNumberish, + overrides?: Overrides + ): Promise; + + storedBatchHash( + _batchNumber: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: string; + }>; + + "storedBatchHash(uint256)"( + _batchNumber: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: string; + }>; + + transferEthToSharedBridge( + overrides?: Overrides + ): Promise; + + "transferEthToSharedBridge()"( + overrides?: Overrides + ): Promise; + + unfreezeDiamond(overrides?: Overrides): Promise; + + "unfreezeDiamond()"(overrides?: Overrides): Promise; + + upgradeChainFromVersion( + _protocolVersion: BigNumberish, + _cutData: { + facetCuts: { + facet: string; + action: BigNumberish; + isFreezable: boolean; + selectors: BytesLike[]; + }[]; + initAddress: string; + initCalldata: BytesLike; + }, + overrides?: Overrides + ): Promise; + + "upgradeChainFromVersion(uint256,tuple)"( + _protocolVersion: BigNumberish, + _cutData: { + facetCuts: { + facet: string; + action: BigNumberish; + isFreezable: boolean; + selectors: BytesLike[]; + }[]; + initAddress: string; + initCalldata: BytesLike; + }, + overrides?: Overrides + ): Promise; + }; + + acceptAdmin(overrides?: Overrides): Promise; + + "acceptAdmin()"(overrides?: Overrides): Promise; + + baseTokenGasPriceMultiplierDenominator( + overrides?: CallOverrides + ): Promise; + + "baseTokenGasPriceMultiplierDenominator()"( + overrides?: CallOverrides + ): Promise; + + baseTokenGasPriceMultiplierNominator( + overrides?: CallOverrides + ): Promise; + + "baseTokenGasPriceMultiplierNominator()"( + overrides?: CallOverrides + ): Promise; + + bridgehubRequestL2Transaction( + _request: { + sender: string; + contractL2: string; + mintValue: BigNumberish; + l2Value: BigNumberish; + l2Calldata: BytesLike; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + factoryDeps: BytesLike[]; + refundRecipient: string; + }, + overrides?: PayableOverrides + ): Promise; + + "bridgehubRequestL2Transaction(tuple)"( + _request: { + sender: string; + contractL2: string; + mintValue: BigNumberish; + l2Value: BigNumberish; + l2Calldata: BytesLike; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + factoryDeps: BytesLike[]; + refundRecipient: string; + }, + overrides?: PayableOverrides + ): Promise; + + changeFeeParams( + _newFeeParams: { + pubdataPricingMode: BigNumberish; + batchOverheadL1Gas: BigNumberish; + maxPubdataPerBatch: BigNumberish; + maxL2GasPerBatch: BigNumberish; + priorityTxMaxPubdata: BigNumberish; + minimalL2GasPrice: BigNumberish; + }, + overrides?: Overrides + ): Promise; + + "changeFeeParams(tuple)"( + _newFeeParams: { + pubdataPricingMode: BigNumberish; + batchOverheadL1Gas: BigNumberish; + maxPubdataPerBatch: BigNumberish; + maxL2GasPerBatch: BigNumberish; + priorityTxMaxPubdata: BigNumberish; + minimalL2GasPrice: BigNumberish; + }, + overrides?: Overrides + ): Promise; + + commitBatches( + _lastCommittedBatchData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _newBatchesData: { + batchNumber: BigNumberish; + timestamp: BigNumberish; + indexRepeatedStorageChanges: BigNumberish; + newStateRoot: BytesLike; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + bootloaderHeapInitialContentsHash: BytesLike; + eventsQueueStateHash: BytesLike; + systemLogs: BytesLike; + pubdataCommitments: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + "commitBatches(tuple,tuple[])"( + _lastCommittedBatchData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _newBatchesData: { + batchNumber: BigNumberish; + timestamp: BigNumberish; + indexRepeatedStorageChanges: BigNumberish; + newStateRoot: BytesLike; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + bootloaderHeapInitialContentsHash: BytesLike; + eventsQueueStateHash: BytesLike; + systemLogs: BytesLike; + pubdataCommitments: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + commitBatchesSharedBridge( + _chainId: BigNumberish, + _lastCommittedBatchData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _newBatchesData: { + batchNumber: BigNumberish; + timestamp: BigNumberish; + indexRepeatedStorageChanges: BigNumberish; + newStateRoot: BytesLike; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + bootloaderHeapInitialContentsHash: BytesLike; + eventsQueueStateHash: BytesLike; + systemLogs: BytesLike; + pubdataCommitments: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + "commitBatchesSharedBridge(uint256,tuple,tuple[])"( + _chainId: BigNumberish, + _lastCommittedBatchData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _newBatchesData: { + batchNumber: BigNumberish; + timestamp: BigNumberish; + indexRepeatedStorageChanges: BigNumberish; + newStateRoot: BytesLike; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + bootloaderHeapInitialContentsHash: BytesLike; + eventsQueueStateHash: BytesLike; + systemLogs: BytesLike; + pubdataCommitments: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + executeBatches( + _batchesData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + "executeBatches(tuple[])"( + _batchesData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + executeBatchesSharedBridge( + _chainId: BigNumberish, + _batchesData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + "executeBatchesSharedBridge(uint256,tuple[])"( + _chainId: BigNumberish, + _batchesData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + executeUpgrade( + _diamondCut: { + facetCuts: { + facet: string; + action: BigNumberish; + isFreezable: boolean; + selectors: BytesLike[]; + }[]; + initAddress: string; + initCalldata: BytesLike; + }, + overrides?: Overrides + ): Promise; + + "executeUpgrade(tuple)"( + _diamondCut: { + facetCuts: { + facet: string; + action: BigNumberish; + isFreezable: boolean; + selectors: BytesLike[]; + }[]; + initAddress: string; + initCalldata: BytesLike; + }, + overrides?: Overrides + ): Promise; + + facetAddress( + _selector: BytesLike, + overrides?: CallOverrides + ): Promise; + + "facetAddress(bytes4)"( + _selector: BytesLike, + overrides?: CallOverrides + ): Promise; + + facetAddresses(overrides?: CallOverrides): Promise; + + "facetAddresses()"(overrides?: CallOverrides): Promise; + + facetFunctionSelectors( + _facet: string, + overrides?: CallOverrides + ): Promise; + + "facetFunctionSelectors(address)"( + _facet: string, + overrides?: CallOverrides + ): Promise; + + facets( + overrides?: CallOverrides + ): Promise<{ addr: string; selectors: string[]; 0: string; 1: string[] }[]>; + + "facets()"( + overrides?: CallOverrides + ): Promise<{ addr: string; selectors: string[]; 0: string; 1: string[] }[]>; + + finalizeEthWithdrawal( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "finalizeEthWithdrawal(uint256,uint256,uint16,bytes,bytes32[])"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + freezeDiamond(overrides?: Overrides): Promise; + + "freezeDiamond()"(overrides?: Overrides): Promise; + + getAdmin(overrides?: CallOverrides): Promise; + + "getAdmin()"(overrides?: CallOverrides): Promise; + + getBaseToken(overrides?: CallOverrides): Promise; + + "getBaseToken()"(overrides?: CallOverrides): Promise; + + getBaseTokenBridge(overrides?: CallOverrides): Promise; + + "getBaseTokenBridge()"(overrides?: CallOverrides): Promise; + + getBridgehub(overrides?: CallOverrides): Promise; + + "getBridgehub()"(overrides?: CallOverrides): Promise; + + getFirstUnprocessedPriorityTx(overrides?: CallOverrides): Promise; + + "getFirstUnprocessedPriorityTx()"( + overrides?: CallOverrides + ): Promise; + + getL2BootloaderBytecodeHash(overrides?: CallOverrides): Promise; + + "getL2BootloaderBytecodeHash()"(overrides?: CallOverrides): Promise; + + getL2DefaultAccountBytecodeHash(overrides?: CallOverrides): Promise; + + "getL2DefaultAccountBytecodeHash()"( + overrides?: CallOverrides + ): Promise; + + getL2SystemContractsUpgradeBatchNumber( + overrides?: CallOverrides + ): Promise; + + "getL2SystemContractsUpgradeBatchNumber()"( + overrides?: CallOverrides + ): Promise; + + getL2SystemContractsUpgradeTxHash(overrides?: CallOverrides): Promise; + + "getL2SystemContractsUpgradeTxHash()"( + overrides?: CallOverrides + ): Promise; + + getName(overrides?: CallOverrides): Promise; + + "getName()"(overrides?: CallOverrides): Promise; + + getPendingAdmin(overrides?: CallOverrides): Promise; + + "getPendingAdmin()"(overrides?: CallOverrides): Promise; + + getPriorityQueueSize(overrides?: CallOverrides): Promise; + + "getPriorityQueueSize()"(overrides?: CallOverrides): Promise; + + getPriorityTxMaxGasLimit(overrides?: CallOverrides): Promise; + + "getPriorityTxMaxGasLimit()"(overrides?: CallOverrides): Promise; + + getProtocolVersion(overrides?: CallOverrides): Promise; + + "getProtocolVersion()"(overrides?: CallOverrides): Promise; + + getPubdataPricingMode(overrides?: CallOverrides): Promise; + + "getPubdataPricingMode()"(overrides?: CallOverrides): Promise; + + getStateTransitionManager(overrides?: CallOverrides): Promise; + + "getStateTransitionManager()"(overrides?: CallOverrides): Promise; + + getTotalBatchesCommitted(overrides?: CallOverrides): Promise; + + "getTotalBatchesCommitted()"(overrides?: CallOverrides): Promise; + + getTotalBatchesExecuted(overrides?: CallOverrides): Promise; + + "getTotalBatchesExecuted()"(overrides?: CallOverrides): Promise; + + getTotalBatchesVerified(overrides?: CallOverrides): Promise; + + "getTotalBatchesVerified()"(overrides?: CallOverrides): Promise; + + getTotalPriorityTxs(overrides?: CallOverrides): Promise; + + "getTotalPriorityTxs()"(overrides?: CallOverrides): Promise; + + getVerifier(overrides?: CallOverrides): Promise; + + "getVerifier()"(overrides?: CallOverrides): Promise; + + getVerifierParams( + overrides?: CallOverrides + ): Promise<{ + recursionNodeLevelVkHash: string; + recursionLeafLevelVkHash: string; + recursionCircuitsSetVksHash: string; + 0: string; + 1: string; + 2: string; + }>; + + "getVerifierParams()"( + overrides?: CallOverrides + ): Promise<{ + recursionNodeLevelVkHash: string; + recursionLeafLevelVkHash: string; + recursionCircuitsSetVksHash: string; + 0: string; + 1: string; + 2: string; + }>; + + isDiamondStorageFrozen(overrides?: CallOverrides): Promise; + + "isDiamondStorageFrozen()"(overrides?: CallOverrides): Promise; + + isEthWithdrawalFinalized( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "isEthWithdrawalFinalized(uint256,uint256)"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + isFacetFreezable(_facet: string, overrides?: CallOverrides): Promise; + + "isFacetFreezable(address)"( + _facet: string, + overrides?: CallOverrides + ): Promise; + + isFunctionFreezable( + _selector: BytesLike, + overrides?: CallOverrides + ): Promise; + + "isFunctionFreezable(bytes4)"( + _selector: BytesLike, + overrides?: CallOverrides + ): Promise; + + isValidator(_address: string, overrides?: CallOverrides): Promise; + + "isValidator(address)"( + _address: string, + overrides?: CallOverrides + ): Promise; + + l2LogsRootHash( + _batchNumber: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "l2LogsRootHash(uint256)"( + _batchNumber: BigNumberish, + overrides?: CallOverrides + ): Promise; + + l2TransactionBaseCost( + _gasPrice: BigNumberish, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "l2TransactionBaseCost(uint256,uint256,uint256)"( + _gasPrice: BigNumberish, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + overrides?: CallOverrides + ): Promise; + + priorityQueueFrontOperation( + overrides?: CallOverrides + ): Promise<{ + canonicalTxHash: string; + expirationTimestamp: BigNumber; + layer2Tip: BigNumber; + 0: string; + 1: BigNumber; + 2: BigNumber; + }>; + + "priorityQueueFrontOperation()"( + overrides?: CallOverrides + ): Promise<{ + canonicalTxHash: string; + expirationTimestamp: BigNumber; + layer2Tip: BigNumber; + 0: string; + 1: BigNumber; + 2: BigNumber; + }>; + + proveBatches( + _prevBatch: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _committedBatches: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + _proof: { + recursiveAggregationInput: BigNumberish[]; + serializedProof: BigNumberish[]; + }, + overrides?: Overrides + ): Promise; + + "proveBatches(tuple,tuple[],tuple)"( + _prevBatch: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _committedBatches: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + _proof: { + recursiveAggregationInput: BigNumberish[]; + serializedProof: BigNumberish[]; + }, + overrides?: Overrides + ): Promise; + + proveBatchesSharedBridge( + _chainId: BigNumberish, + _prevBatch: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _committedBatches: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + _proof: { + recursiveAggregationInput: BigNumberish[]; + serializedProof: BigNumberish[]; + }, + overrides?: Overrides + ): Promise; + + "proveBatchesSharedBridge(uint256,tuple,tuple[],tuple)"( + _chainId: BigNumberish, + _prevBatch: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _committedBatches: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + _proof: { + recursiveAggregationInput: BigNumberish[]; + serializedProof: BigNumberish[]; + }, + overrides?: Overrides + ): Promise; + + proveL1ToL2TransactionStatus( + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + _status: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "proveL1ToL2TransactionStatus(bytes32,uint256,uint256,uint16,bytes32[],uint8)"( + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + _status: BigNumberish, + overrides?: CallOverrides + ): Promise; + + proveL2LogInclusion( + _batchNumber: BigNumberish, + _index: BigNumberish, + _log: { + l2ShardId: BigNumberish; + isService: boolean; + txNumberInBatch: BigNumberish; + sender: string; + key: BytesLike; + value: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + "proveL2LogInclusion(uint256,uint256,tuple,bytes32[])"( + _batchNumber: BigNumberish, + _index: BigNumberish, + _log: { + l2ShardId: BigNumberish; + isService: boolean; + txNumberInBatch: BigNumberish; + sender: string; + key: BytesLike; + value: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + proveL2MessageInclusion( + _batchNumber: BigNumberish, + _index: BigNumberish, + _message: { + txNumberInBatch: BigNumberish; + sender: string; + data: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + "proveL2MessageInclusion(uint256,uint256,tuple,bytes32[])"( + _batchNumber: BigNumberish, + _index: BigNumberish, + _message: { + txNumberInBatch: BigNumberish; + sender: string; + data: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + requestL2Transaction( + _contractL2: string, + _l2Value: BigNumberish, + _calldata: BytesLike, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + _factoryDeps: BytesLike[], + _refundRecipient: string, + overrides?: PayableOverrides + ): Promise; + + "requestL2Transaction(address,uint256,bytes,uint256,uint256,bytes[],address)"( + _contractL2: string, + _l2Value: BigNumberish, + _calldata: BytesLike, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + _factoryDeps: BytesLike[], + _refundRecipient: string, + overrides?: PayableOverrides + ): Promise; + + revertBatches( + _newLastBatch: BigNumberish, + overrides?: Overrides + ): Promise; + + "revertBatches(uint256)"( + _newLastBatch: BigNumberish, + overrides?: Overrides + ): Promise; + + revertBatchesSharedBridge( + _chainId: BigNumberish, + _newLastBatch: BigNumberish, + overrides?: Overrides + ): Promise; + + "revertBatchesSharedBridge(uint256,uint256)"( + _chainId: BigNumberish, + _newLastBatch: BigNumberish, + overrides?: Overrides + ): Promise; + + setPendingAdmin( + _newPendingAdmin: string, + overrides?: Overrides + ): Promise; + + "setPendingAdmin(address)"( + _newPendingAdmin: string, + overrides?: Overrides + ): Promise; + + setPorterAvailability( + _zkPorterIsAvailable: boolean, + overrides?: Overrides + ): Promise; + + "setPorterAvailability(bool)"( + _zkPorterIsAvailable: boolean, + overrides?: Overrides + ): Promise; + + setPriorityTxMaxGasLimit( + _newPriorityTxMaxGasLimit: BigNumberish, + overrides?: Overrides + ): Promise; + + "setPriorityTxMaxGasLimit(uint256)"( + _newPriorityTxMaxGasLimit: BigNumberish, + overrides?: Overrides + ): Promise; + + setTokenMultiplier( + _nominator: BigNumberish, + _denominator: BigNumberish, + overrides?: Overrides + ): Promise; + + "setTokenMultiplier(uint128,uint128)"( + _nominator: BigNumberish, + _denominator: BigNumberish, + overrides?: Overrides + ): Promise; + + setTransactionFilterer( + _transactionFilterer: string, + overrides?: Overrides + ): Promise; + + "setTransactionFilterer(address)"( + _transactionFilterer: string, + overrides?: Overrides + ): Promise; + + setValidator( + _validator: string, + _active: boolean, + overrides?: Overrides + ): Promise; + + "setValidator(address,bool)"( + _validator: string, + _active: boolean, + overrides?: Overrides + ): Promise; + + setValidiumMode( + _validiumMode: BigNumberish, + overrides?: Overrides + ): Promise; + + "setValidiumMode(uint8)"( + _validiumMode: BigNumberish, + overrides?: Overrides + ): Promise; + + storedBatchHash( + _batchNumber: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "storedBatchHash(uint256)"( + _batchNumber: BigNumberish, + overrides?: CallOverrides + ): Promise; + + transferEthToSharedBridge( + overrides?: Overrides + ): Promise; + + "transferEthToSharedBridge()"( + overrides?: Overrides + ): Promise; + + unfreezeDiamond(overrides?: Overrides): Promise; + + "unfreezeDiamond()"(overrides?: Overrides): Promise; + + upgradeChainFromVersion( + _protocolVersion: BigNumberish, + _cutData: { + facetCuts: { + facet: string; + action: BigNumberish; + isFreezable: boolean; + selectors: BytesLike[]; + }[]; + initAddress: string; + initCalldata: BytesLike; + }, + overrides?: Overrides + ): Promise; + + "upgradeChainFromVersion(uint256,tuple)"( + _protocolVersion: BigNumberish, + _cutData: { + facetCuts: { + facet: string; + action: BigNumberish; + isFreezable: boolean; + selectors: BytesLike[]; + }[]; + initAddress: string; + initCalldata: BytesLike; + }, + overrides?: Overrides + ): Promise; + + callStatic: { + acceptAdmin(overrides?: CallOverrides): Promise; + + "acceptAdmin()"(overrides?: CallOverrides): Promise; + + baseTokenGasPriceMultiplierDenominator( + overrides?: CallOverrides + ): Promise; + + "baseTokenGasPriceMultiplierDenominator()"( + overrides?: CallOverrides + ): Promise; + + baseTokenGasPriceMultiplierNominator( + overrides?: CallOverrides + ): Promise; + + "baseTokenGasPriceMultiplierNominator()"( + overrides?: CallOverrides + ): Promise; + + bridgehubRequestL2Transaction( + _request: { + sender: string; + contractL2: string; + mintValue: BigNumberish; + l2Value: BigNumberish; + l2Calldata: BytesLike; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + factoryDeps: BytesLike[]; + refundRecipient: string; + }, + overrides?: CallOverrides + ): Promise; + + "bridgehubRequestL2Transaction(tuple)"( + _request: { + sender: string; + contractL2: string; + mintValue: BigNumberish; + l2Value: BigNumberish; + l2Calldata: BytesLike; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + factoryDeps: BytesLike[]; + refundRecipient: string; + }, + overrides?: CallOverrides + ): Promise; + + changeFeeParams( + _newFeeParams: { + pubdataPricingMode: BigNumberish; + batchOverheadL1Gas: BigNumberish; + maxPubdataPerBatch: BigNumberish; + maxL2GasPerBatch: BigNumberish; + priorityTxMaxPubdata: BigNumberish; + minimalL2GasPrice: BigNumberish; + }, + overrides?: CallOverrides + ): Promise; + + "changeFeeParams(tuple)"( + _newFeeParams: { + pubdataPricingMode: BigNumberish; + batchOverheadL1Gas: BigNumberish; + maxPubdataPerBatch: BigNumberish; + maxL2GasPerBatch: BigNumberish; + priorityTxMaxPubdata: BigNumberish; + minimalL2GasPrice: BigNumberish; + }, + overrides?: CallOverrides + ): Promise; + + commitBatches( + _lastCommittedBatchData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _newBatchesData: { + batchNumber: BigNumberish; + timestamp: BigNumberish; + indexRepeatedStorageChanges: BigNumberish; + newStateRoot: BytesLike; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + bootloaderHeapInitialContentsHash: BytesLike; + eventsQueueStateHash: BytesLike; + systemLogs: BytesLike; + pubdataCommitments: BytesLike; + }[], + overrides?: CallOverrides + ): Promise; + + "commitBatches(tuple,tuple[])"( + _lastCommittedBatchData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _newBatchesData: { + batchNumber: BigNumberish; + timestamp: BigNumberish; + indexRepeatedStorageChanges: BigNumberish; + newStateRoot: BytesLike; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + bootloaderHeapInitialContentsHash: BytesLike; + eventsQueueStateHash: BytesLike; + systemLogs: BytesLike; + pubdataCommitments: BytesLike; + }[], + overrides?: CallOverrides + ): Promise; + + commitBatchesSharedBridge( + _chainId: BigNumberish, + _lastCommittedBatchData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _newBatchesData: { + batchNumber: BigNumberish; + timestamp: BigNumberish; + indexRepeatedStorageChanges: BigNumberish; + newStateRoot: BytesLike; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + bootloaderHeapInitialContentsHash: BytesLike; + eventsQueueStateHash: BytesLike; + systemLogs: BytesLike; + pubdataCommitments: BytesLike; + }[], + overrides?: CallOverrides + ): Promise; + + "commitBatchesSharedBridge(uint256,tuple,tuple[])"( + _chainId: BigNumberish, + _lastCommittedBatchData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _newBatchesData: { + batchNumber: BigNumberish; + timestamp: BigNumberish; + indexRepeatedStorageChanges: BigNumberish; + newStateRoot: BytesLike; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + bootloaderHeapInitialContentsHash: BytesLike; + eventsQueueStateHash: BytesLike; + systemLogs: BytesLike; + pubdataCommitments: BytesLike; + }[], + overrides?: CallOverrides + ): Promise; + + executeBatches( + _batchesData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + overrides?: CallOverrides + ): Promise; + + "executeBatches(tuple[])"( + _batchesData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + overrides?: CallOverrides + ): Promise; + + executeBatchesSharedBridge( + _chainId: BigNumberish, + _batchesData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + overrides?: CallOverrides + ): Promise; + + "executeBatchesSharedBridge(uint256,tuple[])"( + _chainId: BigNumberish, + _batchesData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + overrides?: CallOverrides + ): Promise; + + executeUpgrade( + _diamondCut: { + facetCuts: { + facet: string; + action: BigNumberish; + isFreezable: boolean; + selectors: BytesLike[]; + }[]; + initAddress: string; + initCalldata: BytesLike; + }, + overrides?: CallOverrides + ): Promise; + + "executeUpgrade(tuple)"( + _diamondCut: { + facetCuts: { + facet: string; + action: BigNumberish; + isFreezable: boolean; + selectors: BytesLike[]; + }[]; + initAddress: string; + initCalldata: BytesLike; + }, + overrides?: CallOverrides + ): Promise; + + facetAddress( + _selector: BytesLike, + overrides?: CallOverrides + ): Promise; + + "facetAddress(bytes4)"( + _selector: BytesLike, + overrides?: CallOverrides + ): Promise; + + facetAddresses(overrides?: CallOverrides): Promise; + + "facetAddresses()"(overrides?: CallOverrides): Promise; + + facetFunctionSelectors( + _facet: string, + overrides?: CallOverrides + ): Promise; + + "facetFunctionSelectors(address)"( + _facet: string, + overrides?: CallOverrides + ): Promise; + + facets( + overrides?: CallOverrides + ): Promise<{ addr: string; selectors: string[]; 0: string; 1: string[] }[]>; + + "facets()"( + overrides?: CallOverrides + ): Promise<{ addr: string; selectors: string[]; 0: string; 1: string[] }[]>; + + finalizeEthWithdrawal( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + "finalizeEthWithdrawal(uint256,uint256,uint16,bytes,bytes32[])"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + freezeDiamond(overrides?: CallOverrides): Promise; + + "freezeDiamond()"(overrides?: CallOverrides): Promise; + + getAdmin(overrides?: CallOverrides): Promise; + + "getAdmin()"(overrides?: CallOverrides): Promise; + + getBaseToken(overrides?: CallOverrides): Promise; + + "getBaseToken()"(overrides?: CallOverrides): Promise; + + getBaseTokenBridge(overrides?: CallOverrides): Promise; + + "getBaseTokenBridge()"(overrides?: CallOverrides): Promise; + + getBridgehub(overrides?: CallOverrides): Promise; + + "getBridgehub()"(overrides?: CallOverrides): Promise; + + getFirstUnprocessedPriorityTx( + overrides?: CallOverrides + ): Promise; + + "getFirstUnprocessedPriorityTx()"( + overrides?: CallOverrides + ): Promise; + + getL2BootloaderBytecodeHash(overrides?: CallOverrides): Promise; + + "getL2BootloaderBytecodeHash()"(overrides?: CallOverrides): Promise; + + getL2DefaultAccountBytecodeHash(overrides?: CallOverrides): Promise; + + "getL2DefaultAccountBytecodeHash()"( + overrides?: CallOverrides + ): Promise; + + getL2SystemContractsUpgradeBatchNumber( + overrides?: CallOverrides + ): Promise; + + "getL2SystemContractsUpgradeBatchNumber()"( + overrides?: CallOverrides + ): Promise; + + getL2SystemContractsUpgradeTxHash( + overrides?: CallOverrides + ): Promise; + + "getL2SystemContractsUpgradeTxHash()"( + overrides?: CallOverrides + ): Promise; + + getName(overrides?: CallOverrides): Promise; + + "getName()"(overrides?: CallOverrides): Promise; + + getPendingAdmin(overrides?: CallOverrides): Promise; + + "getPendingAdmin()"(overrides?: CallOverrides): Promise; + + getPriorityQueueSize(overrides?: CallOverrides): Promise; + + "getPriorityQueueSize()"(overrides?: CallOverrides): Promise; + + getPriorityTxMaxGasLimit(overrides?: CallOverrides): Promise; + + "getPriorityTxMaxGasLimit()"(overrides?: CallOverrides): Promise; + + getProtocolVersion(overrides?: CallOverrides): Promise; + + "getProtocolVersion()"(overrides?: CallOverrides): Promise; + + getPubdataPricingMode(overrides?: CallOverrides): Promise; + + "getPubdataPricingMode()"(overrides?: CallOverrides): Promise; + + getStateTransitionManager(overrides?: CallOverrides): Promise; + + "getStateTransitionManager()"(overrides?: CallOverrides): Promise; + + getTotalBatchesCommitted(overrides?: CallOverrides): Promise; + + "getTotalBatchesCommitted()"(overrides?: CallOverrides): Promise; + + getTotalBatchesExecuted(overrides?: CallOverrides): Promise; + + "getTotalBatchesExecuted()"(overrides?: CallOverrides): Promise; + + getTotalBatchesVerified(overrides?: CallOverrides): Promise; + + "getTotalBatchesVerified()"(overrides?: CallOverrides): Promise; + + getTotalPriorityTxs(overrides?: CallOverrides): Promise; + + "getTotalPriorityTxs()"(overrides?: CallOverrides): Promise; + + getVerifier(overrides?: CallOverrides): Promise; + + "getVerifier()"(overrides?: CallOverrides): Promise; + + getVerifierParams( + overrides?: CallOverrides + ): Promise<{ + recursionNodeLevelVkHash: string; + recursionLeafLevelVkHash: string; + recursionCircuitsSetVksHash: string; + 0: string; + 1: string; + 2: string; + }>; + + "getVerifierParams()"( + overrides?: CallOverrides + ): Promise<{ + recursionNodeLevelVkHash: string; + recursionLeafLevelVkHash: string; + recursionCircuitsSetVksHash: string; + 0: string; + 1: string; + 2: string; + }>; + + isDiamondStorageFrozen(overrides?: CallOverrides): Promise; + + "isDiamondStorageFrozen()"(overrides?: CallOverrides): Promise; + + isEthWithdrawalFinalized( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "isEthWithdrawalFinalized(uint256,uint256)"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + isFacetFreezable( + _facet: string, + overrides?: CallOverrides + ): Promise; + + "isFacetFreezable(address)"( + _facet: string, + overrides?: CallOverrides + ): Promise; + + isFunctionFreezable( + _selector: BytesLike, + overrides?: CallOverrides + ): Promise; + + "isFunctionFreezable(bytes4)"( + _selector: BytesLike, + overrides?: CallOverrides + ): Promise; + + isValidator(_address: string, overrides?: CallOverrides): Promise; + + "isValidator(address)"( + _address: string, + overrides?: CallOverrides + ): Promise; + + l2LogsRootHash( + _batchNumber: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "l2LogsRootHash(uint256)"( + _batchNumber: BigNumberish, + overrides?: CallOverrides + ): Promise; + + l2TransactionBaseCost( + _gasPrice: BigNumberish, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "l2TransactionBaseCost(uint256,uint256,uint256)"( + _gasPrice: BigNumberish, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + overrides?: CallOverrides + ): Promise; + + priorityQueueFrontOperation( + overrides?: CallOverrides + ): Promise<{ + canonicalTxHash: string; + expirationTimestamp: BigNumber; + layer2Tip: BigNumber; + 0: string; + 1: BigNumber; + 2: BigNumber; + }>; + + "priorityQueueFrontOperation()"( + overrides?: CallOverrides + ): Promise<{ + canonicalTxHash: string; + expirationTimestamp: BigNumber; + layer2Tip: BigNumber; + 0: string; + 1: BigNumber; + 2: BigNumber; + }>; + + proveBatches( + _prevBatch: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _committedBatches: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + _proof: { + recursiveAggregationInput: BigNumberish[]; + serializedProof: BigNumberish[]; + }, + overrides?: CallOverrides + ): Promise; + + "proveBatches(tuple,tuple[],tuple)"( + _prevBatch: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _committedBatches: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + _proof: { + recursiveAggregationInput: BigNumberish[]; + serializedProof: BigNumberish[]; + }, + overrides?: CallOverrides + ): Promise; + + proveBatchesSharedBridge( + _chainId: BigNumberish, + _prevBatch: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _committedBatches: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + _proof: { + recursiveAggregationInput: BigNumberish[]; + serializedProof: BigNumberish[]; + }, + overrides?: CallOverrides + ): Promise; + + "proveBatchesSharedBridge(uint256,tuple,tuple[],tuple)"( + _chainId: BigNumberish, + _prevBatch: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _committedBatches: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + _proof: { + recursiveAggregationInput: BigNumberish[]; + serializedProof: BigNumberish[]; + }, + overrides?: CallOverrides + ): Promise; + + proveL1ToL2TransactionStatus( + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + _status: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "proveL1ToL2TransactionStatus(bytes32,uint256,uint256,uint16,bytes32[],uint8)"( + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + _status: BigNumberish, + overrides?: CallOverrides + ): Promise; + + proveL2LogInclusion( + _batchNumber: BigNumberish, + _index: BigNumberish, + _log: { + l2ShardId: BigNumberish; + isService: boolean; + txNumberInBatch: BigNumberish; + sender: string; + key: BytesLike; + value: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + "proveL2LogInclusion(uint256,uint256,tuple,bytes32[])"( + _batchNumber: BigNumberish, + _index: BigNumberish, + _log: { + l2ShardId: BigNumberish; + isService: boolean; + txNumberInBatch: BigNumberish; + sender: string; + key: BytesLike; + value: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + proveL2MessageInclusion( + _batchNumber: BigNumberish, + _index: BigNumberish, + _message: { + txNumberInBatch: BigNumberish; + sender: string; + data: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + "proveL2MessageInclusion(uint256,uint256,tuple,bytes32[])"( + _batchNumber: BigNumberish, + _index: BigNumberish, + _message: { + txNumberInBatch: BigNumberish; + sender: string; + data: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + requestL2Transaction( + _contractL2: string, + _l2Value: BigNumberish, + _calldata: BytesLike, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + _factoryDeps: BytesLike[], + _refundRecipient: string, + overrides?: CallOverrides + ): Promise; + + "requestL2Transaction(address,uint256,bytes,uint256,uint256,bytes[],address)"( + _contractL2: string, + _l2Value: BigNumberish, + _calldata: BytesLike, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + _factoryDeps: BytesLike[], + _refundRecipient: string, + overrides?: CallOverrides + ): Promise; + + revertBatches( + _newLastBatch: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "revertBatches(uint256)"( + _newLastBatch: BigNumberish, + overrides?: CallOverrides + ): Promise; + + revertBatchesSharedBridge( + _chainId: BigNumberish, + _newLastBatch: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "revertBatchesSharedBridge(uint256,uint256)"( + _chainId: BigNumberish, + _newLastBatch: BigNumberish, + overrides?: CallOverrides + ): Promise; + + setPendingAdmin( + _newPendingAdmin: string, + overrides?: CallOverrides + ): Promise; + + "setPendingAdmin(address)"( + _newPendingAdmin: string, + overrides?: CallOverrides + ): Promise; + + setPorterAvailability( + _zkPorterIsAvailable: boolean, + overrides?: CallOverrides + ): Promise; + + "setPorterAvailability(bool)"( + _zkPorterIsAvailable: boolean, + overrides?: CallOverrides + ): Promise; + + setPriorityTxMaxGasLimit( + _newPriorityTxMaxGasLimit: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "setPriorityTxMaxGasLimit(uint256)"( + _newPriorityTxMaxGasLimit: BigNumberish, + overrides?: CallOverrides + ): Promise; + + setTokenMultiplier( + _nominator: BigNumberish, + _denominator: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "setTokenMultiplier(uint128,uint128)"( + _nominator: BigNumberish, + _denominator: BigNumberish, + overrides?: CallOverrides + ): Promise; + + setTransactionFilterer( + _transactionFilterer: string, + overrides?: CallOverrides + ): Promise; + + "setTransactionFilterer(address)"( + _transactionFilterer: string, + overrides?: CallOverrides + ): Promise; + + setValidator( + _validator: string, + _active: boolean, + overrides?: CallOverrides + ): Promise; + + "setValidator(address,bool)"( + _validator: string, + _active: boolean, + overrides?: CallOverrides + ): Promise; + + setValidiumMode( + _validiumMode: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "setValidiumMode(uint8)"( + _validiumMode: BigNumberish, + overrides?: CallOverrides + ): Promise; + + storedBatchHash( + _batchNumber: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "storedBatchHash(uint256)"( + _batchNumber: BigNumberish, + overrides?: CallOverrides + ): Promise; + + transferEthToSharedBridge(overrides?: CallOverrides): Promise; + + "transferEthToSharedBridge()"(overrides?: CallOverrides): Promise; + + unfreezeDiamond(overrides?: CallOverrides): Promise; + + "unfreezeDiamond()"(overrides?: CallOverrides): Promise; + + upgradeChainFromVersion( + _protocolVersion: BigNumberish, + _cutData: { + facetCuts: { + facet: string; + action: BigNumberish; + isFreezable: boolean; + selectors: BytesLike[]; + }[]; + initAddress: string; + initCalldata: BytesLike; + }, + overrides?: CallOverrides + ): Promise; + + "upgradeChainFromVersion(uint256,tuple)"( + _protocolVersion: BigNumberish, + _cutData: { + facetCuts: { + facet: string; + action: BigNumberish; + isFreezable: boolean; + selectors: BytesLike[]; + }[]; + initAddress: string; + initCalldata: BytesLike; + }, + overrides?: CallOverrides + ): Promise; + }; + + filters: { + BlockCommit( + batchNumber: BigNumberish | null, + batchHash: BytesLike | null, + commitment: BytesLike | null + ): EventFilter; + + BlockExecution( + batchNumber: BigNumberish | null, + batchHash: BytesLike | null, + commitment: BytesLike | null + ): EventFilter; + + BlocksRevert( + totalBatchesCommitted: null, + totalBatchesVerified: null, + totalBatchesExecuted: null + ): EventFilter; + + BlocksVerification( + previousLastVerifiedBatch: BigNumberish | null, + currentLastVerifiedBatch: BigNumberish | null + ): EventFilter; + + EthWithdrawalFinalized(to: string | null, amount: null): EventFilter; + + ExecuteUpgrade(diamondCut: null): EventFilter; + + Freeze(): EventFilter; + + IsPorterAvailableStatusUpdate(isPorterAvailable: null): EventFilter; + + NewAdmin(oldAdmin: string | null, newAdmin: string | null): EventFilter; + + NewBaseTokenMultiplier( + oldNominator: null, + oldDenominator: null, + newNominator: null, + newDenominator: null + ): EventFilter; + + NewFeeParams(oldFeeParams: null, newFeeParams: null): EventFilter; + + NewPendingAdmin( + oldPendingAdmin: string | null, + newPendingAdmin: string | null + ): EventFilter; + + NewPriorityRequest( + txId: null, + txHash: null, + expirationTimestamp: null, + transaction: null, + factoryDeps: null + ): EventFilter; + + NewPriorityTxMaxGasLimit( + oldPriorityTxMaxGasLimit: null, + newPriorityTxMaxGasLimit: null + ): EventFilter; + + NewTransactionFilterer( + oldTransactionFilterer: null, + newTransactionFilterer: null + ): EventFilter; + + ProposeTransparentUpgrade( + diamondCut: null, + proposalId: BigNumberish | null, + proposalSalt: null + ): EventFilter; + + Unfreeze(): EventFilter; + + ValidatorStatusUpdate( + validatorAddress: string | null, + isActive: null + ): EventFilter; + + ValidiumModeStatusUpdate(validiumMode: null): EventFilter; + }; + + estimateGas: { + acceptAdmin(overrides?: Overrides): Promise; + + "acceptAdmin()"(overrides?: Overrides): Promise; + + baseTokenGasPriceMultiplierDenominator( + overrides?: CallOverrides + ): Promise; + + "baseTokenGasPriceMultiplierDenominator()"( + overrides?: CallOverrides + ): Promise; + + baseTokenGasPriceMultiplierNominator( + overrides?: CallOverrides + ): Promise; + + "baseTokenGasPriceMultiplierNominator()"( + overrides?: CallOverrides + ): Promise; + + bridgehubRequestL2Transaction( + _request: { + sender: string; + contractL2: string; + mintValue: BigNumberish; + l2Value: BigNumberish; + l2Calldata: BytesLike; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + factoryDeps: BytesLike[]; + refundRecipient: string; + }, + overrides?: PayableOverrides + ): Promise; + + "bridgehubRequestL2Transaction(tuple)"( + _request: { + sender: string; + contractL2: string; + mintValue: BigNumberish; + l2Value: BigNumberish; + l2Calldata: BytesLike; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + factoryDeps: BytesLike[]; + refundRecipient: string; + }, + overrides?: PayableOverrides + ): Promise; + + changeFeeParams( + _newFeeParams: { + pubdataPricingMode: BigNumberish; + batchOverheadL1Gas: BigNumberish; + maxPubdataPerBatch: BigNumberish; + maxL2GasPerBatch: BigNumberish; + priorityTxMaxPubdata: BigNumberish; + minimalL2GasPrice: BigNumberish; + }, + overrides?: Overrides + ): Promise; + + "changeFeeParams(tuple)"( + _newFeeParams: { + pubdataPricingMode: BigNumberish; + batchOverheadL1Gas: BigNumberish; + maxPubdataPerBatch: BigNumberish; + maxL2GasPerBatch: BigNumberish; + priorityTxMaxPubdata: BigNumberish; + minimalL2GasPrice: BigNumberish; + }, + overrides?: Overrides + ): Promise; + + commitBatches( + _lastCommittedBatchData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _newBatchesData: { + batchNumber: BigNumberish; + timestamp: BigNumberish; + indexRepeatedStorageChanges: BigNumberish; + newStateRoot: BytesLike; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + bootloaderHeapInitialContentsHash: BytesLike; + eventsQueueStateHash: BytesLike; + systemLogs: BytesLike; + pubdataCommitments: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + "commitBatches(tuple,tuple[])"( + _lastCommittedBatchData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _newBatchesData: { + batchNumber: BigNumberish; + timestamp: BigNumberish; + indexRepeatedStorageChanges: BigNumberish; + newStateRoot: BytesLike; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + bootloaderHeapInitialContentsHash: BytesLike; + eventsQueueStateHash: BytesLike; + systemLogs: BytesLike; + pubdataCommitments: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + commitBatchesSharedBridge( + _chainId: BigNumberish, + _lastCommittedBatchData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _newBatchesData: { + batchNumber: BigNumberish; + timestamp: BigNumberish; + indexRepeatedStorageChanges: BigNumberish; + newStateRoot: BytesLike; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + bootloaderHeapInitialContentsHash: BytesLike; + eventsQueueStateHash: BytesLike; + systemLogs: BytesLike; + pubdataCommitments: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + "commitBatchesSharedBridge(uint256,tuple,tuple[])"( + _chainId: BigNumberish, + _lastCommittedBatchData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _newBatchesData: { + batchNumber: BigNumberish; + timestamp: BigNumberish; + indexRepeatedStorageChanges: BigNumberish; + newStateRoot: BytesLike; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + bootloaderHeapInitialContentsHash: BytesLike; + eventsQueueStateHash: BytesLike; + systemLogs: BytesLike; + pubdataCommitments: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + executeBatches( + _batchesData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + "executeBatches(tuple[])"( + _batchesData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + executeBatchesSharedBridge( + _chainId: BigNumberish, + _batchesData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + "executeBatchesSharedBridge(uint256,tuple[])"( + _chainId: BigNumberish, + _batchesData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + executeUpgrade( + _diamondCut: { + facetCuts: { + facet: string; + action: BigNumberish; + isFreezable: boolean; + selectors: BytesLike[]; + }[]; + initAddress: string; + initCalldata: BytesLike; + }, + overrides?: Overrides + ): Promise; + + "executeUpgrade(tuple)"( + _diamondCut: { + facetCuts: { + facet: string; + action: BigNumberish; + isFreezable: boolean; + selectors: BytesLike[]; + }[]; + initAddress: string; + initCalldata: BytesLike; + }, + overrides?: Overrides + ): Promise; + + facetAddress( + _selector: BytesLike, + overrides?: CallOverrides + ): Promise; + + "facetAddress(bytes4)"( + _selector: BytesLike, + overrides?: CallOverrides + ): Promise; + + facetAddresses(overrides?: CallOverrides): Promise; + + "facetAddresses()"(overrides?: CallOverrides): Promise; + + facetFunctionSelectors( + _facet: string, + overrides?: CallOverrides + ): Promise; + + "facetFunctionSelectors(address)"( + _facet: string, + overrides?: CallOverrides + ): Promise; + + facets(overrides?: CallOverrides): Promise; + + "facets()"(overrides?: CallOverrides): Promise; + + finalizeEthWithdrawal( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "finalizeEthWithdrawal(uint256,uint256,uint16,bytes,bytes32[])"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + freezeDiamond(overrides?: Overrides): Promise; + + "freezeDiamond()"(overrides?: Overrides): Promise; + + getAdmin(overrides?: CallOverrides): Promise; + + "getAdmin()"(overrides?: CallOverrides): Promise; + + getBaseToken(overrides?: CallOverrides): Promise; + + "getBaseToken()"(overrides?: CallOverrides): Promise; + + getBaseTokenBridge(overrides?: CallOverrides): Promise; + + "getBaseTokenBridge()"(overrides?: CallOverrides): Promise; + + getBridgehub(overrides?: CallOverrides): Promise; + + "getBridgehub()"(overrides?: CallOverrides): Promise; + + getFirstUnprocessedPriorityTx( + overrides?: CallOverrides + ): Promise; + + "getFirstUnprocessedPriorityTx()"( + overrides?: CallOverrides + ): Promise; + + getL2BootloaderBytecodeHash(overrides?: CallOverrides): Promise; + + "getL2BootloaderBytecodeHash()"( + overrides?: CallOverrides + ): Promise; + + getL2DefaultAccountBytecodeHash( + overrides?: CallOverrides + ): Promise; + + "getL2DefaultAccountBytecodeHash()"( + overrides?: CallOverrides + ): Promise; + + getL2SystemContractsUpgradeBatchNumber( + overrides?: CallOverrides + ): Promise; + + "getL2SystemContractsUpgradeBatchNumber()"( + overrides?: CallOverrides + ): Promise; + + getL2SystemContractsUpgradeTxHash( + overrides?: CallOverrides + ): Promise; + + "getL2SystemContractsUpgradeTxHash()"( + overrides?: CallOverrides + ): Promise; + + getName(overrides?: CallOverrides): Promise; + + "getName()"(overrides?: CallOverrides): Promise; + + getPendingAdmin(overrides?: CallOverrides): Promise; + + "getPendingAdmin()"(overrides?: CallOverrides): Promise; + + getPriorityQueueSize(overrides?: CallOverrides): Promise; + + "getPriorityQueueSize()"(overrides?: CallOverrides): Promise; + + getPriorityTxMaxGasLimit(overrides?: CallOverrides): Promise; + + "getPriorityTxMaxGasLimit()"(overrides?: CallOverrides): Promise; + + getProtocolVersion(overrides?: CallOverrides): Promise; + + "getProtocolVersion()"(overrides?: CallOverrides): Promise; + + getPubdataPricingMode(overrides?: CallOverrides): Promise; + + "getPubdataPricingMode()"(overrides?: CallOverrides): Promise; + + getStateTransitionManager(overrides?: CallOverrides): Promise; + + "getStateTransitionManager()"( + overrides?: CallOverrides + ): Promise; + + getTotalBatchesCommitted(overrides?: CallOverrides): Promise; + + "getTotalBatchesCommitted()"(overrides?: CallOverrides): Promise; + + getTotalBatchesExecuted(overrides?: CallOverrides): Promise; + + "getTotalBatchesExecuted()"(overrides?: CallOverrides): Promise; + + getTotalBatchesVerified(overrides?: CallOverrides): Promise; + + "getTotalBatchesVerified()"(overrides?: CallOverrides): Promise; + + getTotalPriorityTxs(overrides?: CallOverrides): Promise; + + "getTotalPriorityTxs()"(overrides?: CallOverrides): Promise; + + getVerifier(overrides?: CallOverrides): Promise; + + "getVerifier()"(overrides?: CallOverrides): Promise; + + getVerifierParams(overrides?: CallOverrides): Promise; + + "getVerifierParams()"(overrides?: CallOverrides): Promise; + + isDiamondStorageFrozen(overrides?: CallOverrides): Promise; + + "isDiamondStorageFrozen()"(overrides?: CallOverrides): Promise; + + isEthWithdrawalFinalized( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "isEthWithdrawalFinalized(uint256,uint256)"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + isFacetFreezable( + _facet: string, + overrides?: CallOverrides + ): Promise; + + "isFacetFreezable(address)"( + _facet: string, + overrides?: CallOverrides + ): Promise; + + isFunctionFreezable( + _selector: BytesLike, + overrides?: CallOverrides + ): Promise; + + "isFunctionFreezable(bytes4)"( + _selector: BytesLike, + overrides?: CallOverrides + ): Promise; + + isValidator( + _address: string, + overrides?: CallOverrides + ): Promise; + + "isValidator(address)"( + _address: string, + overrides?: CallOverrides + ): Promise; + + l2LogsRootHash( + _batchNumber: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "l2LogsRootHash(uint256)"( + _batchNumber: BigNumberish, + overrides?: CallOverrides + ): Promise; + + l2TransactionBaseCost( + _gasPrice: BigNumberish, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "l2TransactionBaseCost(uint256,uint256,uint256)"( + _gasPrice: BigNumberish, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + overrides?: CallOverrides + ): Promise; + + priorityQueueFrontOperation(overrides?: CallOverrides): Promise; + + "priorityQueueFrontOperation()"( + overrides?: CallOverrides + ): Promise; + + proveBatches( + _prevBatch: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _committedBatches: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + _proof: { + recursiveAggregationInput: BigNumberish[]; + serializedProof: BigNumberish[]; + }, + overrides?: Overrides + ): Promise; + + "proveBatches(tuple,tuple[],tuple)"( + _prevBatch: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _committedBatches: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + _proof: { + recursiveAggregationInput: BigNumberish[]; + serializedProof: BigNumberish[]; + }, + overrides?: Overrides + ): Promise; + + proveBatchesSharedBridge( + _chainId: BigNumberish, + _prevBatch: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _committedBatches: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + _proof: { + recursiveAggregationInput: BigNumberish[]; + serializedProof: BigNumberish[]; + }, + overrides?: Overrides + ): Promise; + + "proveBatchesSharedBridge(uint256,tuple,tuple[],tuple)"( + _chainId: BigNumberish, + _prevBatch: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _committedBatches: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + _proof: { + recursiveAggregationInput: BigNumberish[]; + serializedProof: BigNumberish[]; + }, + overrides?: Overrides + ): Promise; + + proveL1ToL2TransactionStatus( + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + _status: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "proveL1ToL2TransactionStatus(bytes32,uint256,uint256,uint16,bytes32[],uint8)"( + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + _status: BigNumberish, + overrides?: CallOverrides + ): Promise; + + proveL2LogInclusion( + _batchNumber: BigNumberish, + _index: BigNumberish, + _log: { + l2ShardId: BigNumberish; + isService: boolean; + txNumberInBatch: BigNumberish; + sender: string; + key: BytesLike; + value: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + "proveL2LogInclusion(uint256,uint256,tuple,bytes32[])"( + _batchNumber: BigNumberish, + _index: BigNumberish, + _log: { + l2ShardId: BigNumberish; + isService: boolean; + txNumberInBatch: BigNumberish; + sender: string; + key: BytesLike; + value: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + proveL2MessageInclusion( + _batchNumber: BigNumberish, + _index: BigNumberish, + _message: { + txNumberInBatch: BigNumberish; + sender: string; + data: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + "proveL2MessageInclusion(uint256,uint256,tuple,bytes32[])"( + _batchNumber: BigNumberish, + _index: BigNumberish, + _message: { + txNumberInBatch: BigNumberish; + sender: string; + data: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + requestL2Transaction( + _contractL2: string, + _l2Value: BigNumberish, + _calldata: BytesLike, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + _factoryDeps: BytesLike[], + _refundRecipient: string, + overrides?: PayableOverrides + ): Promise; + + "requestL2Transaction(address,uint256,bytes,uint256,uint256,bytes[],address)"( + _contractL2: string, + _l2Value: BigNumberish, + _calldata: BytesLike, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + _factoryDeps: BytesLike[], + _refundRecipient: string, + overrides?: PayableOverrides + ): Promise; + + revertBatches( + _newLastBatch: BigNumberish, + overrides?: Overrides + ): Promise; + + "revertBatches(uint256)"( + _newLastBatch: BigNumberish, + overrides?: Overrides + ): Promise; + + revertBatchesSharedBridge( + _chainId: BigNumberish, + _newLastBatch: BigNumberish, + overrides?: Overrides + ): Promise; + + "revertBatchesSharedBridge(uint256,uint256)"( + _chainId: BigNumberish, + _newLastBatch: BigNumberish, + overrides?: Overrides + ): Promise; + + setPendingAdmin( + _newPendingAdmin: string, + overrides?: Overrides + ): Promise; + + "setPendingAdmin(address)"( + _newPendingAdmin: string, + overrides?: Overrides + ): Promise; + + setPorterAvailability( + _zkPorterIsAvailable: boolean, + overrides?: Overrides + ): Promise; + + "setPorterAvailability(bool)"( + _zkPorterIsAvailable: boolean, + overrides?: Overrides + ): Promise; + + setPriorityTxMaxGasLimit( + _newPriorityTxMaxGasLimit: BigNumberish, + overrides?: Overrides + ): Promise; + + "setPriorityTxMaxGasLimit(uint256)"( + _newPriorityTxMaxGasLimit: BigNumberish, + overrides?: Overrides + ): Promise; + + setTokenMultiplier( + _nominator: BigNumberish, + _denominator: BigNumberish, + overrides?: Overrides + ): Promise; + + "setTokenMultiplier(uint128,uint128)"( + _nominator: BigNumberish, + _denominator: BigNumberish, + overrides?: Overrides + ): Promise; + + setTransactionFilterer( + _transactionFilterer: string, + overrides?: Overrides + ): Promise; + + "setTransactionFilterer(address)"( + _transactionFilterer: string, + overrides?: Overrides + ): Promise; + + setValidator( + _validator: string, + _active: boolean, + overrides?: Overrides + ): Promise; + + "setValidator(address,bool)"( + _validator: string, + _active: boolean, + overrides?: Overrides + ): Promise; + + setValidiumMode( + _validiumMode: BigNumberish, + overrides?: Overrides + ): Promise; + + "setValidiumMode(uint8)"( + _validiumMode: BigNumberish, + overrides?: Overrides + ): Promise; + + storedBatchHash( + _batchNumber: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "storedBatchHash(uint256)"( + _batchNumber: BigNumberish, + overrides?: CallOverrides + ): Promise; + + transferEthToSharedBridge(overrides?: Overrides): Promise; + + "transferEthToSharedBridge()"(overrides?: Overrides): Promise; + + unfreezeDiamond(overrides?: Overrides): Promise; + + "unfreezeDiamond()"(overrides?: Overrides): Promise; + + upgradeChainFromVersion( + _protocolVersion: BigNumberish, + _cutData: { + facetCuts: { + facet: string; + action: BigNumberish; + isFreezable: boolean; + selectors: BytesLike[]; + }[]; + initAddress: string; + initCalldata: BytesLike; + }, + overrides?: Overrides + ): Promise; + + "upgradeChainFromVersion(uint256,tuple)"( + _protocolVersion: BigNumberish, + _cutData: { + facetCuts: { + facet: string; + action: BigNumberish; + isFreezable: boolean; + selectors: BytesLike[]; + }[]; + initAddress: string; + initCalldata: BytesLike; + }, + overrides?: Overrides + ): Promise; + }; + + populateTransaction: { + acceptAdmin(overrides?: Overrides): Promise; + + "acceptAdmin()"(overrides?: Overrides): Promise; + + baseTokenGasPriceMultiplierDenominator( + overrides?: CallOverrides + ): Promise; + + "baseTokenGasPriceMultiplierDenominator()"( + overrides?: CallOverrides + ): Promise; + + baseTokenGasPriceMultiplierNominator( + overrides?: CallOverrides + ): Promise; + + "baseTokenGasPriceMultiplierNominator()"( + overrides?: CallOverrides + ): Promise; + + bridgehubRequestL2Transaction( + _request: { + sender: string; + contractL2: string; + mintValue: BigNumberish; + l2Value: BigNumberish; + l2Calldata: BytesLike; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + factoryDeps: BytesLike[]; + refundRecipient: string; + }, + overrides?: PayableOverrides + ): Promise; + + "bridgehubRequestL2Transaction(tuple)"( + _request: { + sender: string; + contractL2: string; + mintValue: BigNumberish; + l2Value: BigNumberish; + l2Calldata: BytesLike; + l2GasLimit: BigNumberish; + l2GasPerPubdataByteLimit: BigNumberish; + factoryDeps: BytesLike[]; + refundRecipient: string; + }, + overrides?: PayableOverrides + ): Promise; + + changeFeeParams( + _newFeeParams: { + pubdataPricingMode: BigNumberish; + batchOverheadL1Gas: BigNumberish; + maxPubdataPerBatch: BigNumberish; + maxL2GasPerBatch: BigNumberish; + priorityTxMaxPubdata: BigNumberish; + minimalL2GasPrice: BigNumberish; + }, + overrides?: Overrides + ): Promise; + + "changeFeeParams(tuple)"( + _newFeeParams: { + pubdataPricingMode: BigNumberish; + batchOverheadL1Gas: BigNumberish; + maxPubdataPerBatch: BigNumberish; + maxL2GasPerBatch: BigNumberish; + priorityTxMaxPubdata: BigNumberish; + minimalL2GasPrice: BigNumberish; + }, + overrides?: Overrides + ): Promise; + + commitBatches( + _lastCommittedBatchData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _newBatchesData: { + batchNumber: BigNumberish; + timestamp: BigNumberish; + indexRepeatedStorageChanges: BigNumberish; + newStateRoot: BytesLike; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + bootloaderHeapInitialContentsHash: BytesLike; + eventsQueueStateHash: BytesLike; + systemLogs: BytesLike; + pubdataCommitments: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + "commitBatches(tuple,tuple[])"( + _lastCommittedBatchData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _newBatchesData: { + batchNumber: BigNumberish; + timestamp: BigNumberish; + indexRepeatedStorageChanges: BigNumberish; + newStateRoot: BytesLike; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + bootloaderHeapInitialContentsHash: BytesLike; + eventsQueueStateHash: BytesLike; + systemLogs: BytesLike; + pubdataCommitments: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + commitBatchesSharedBridge( + _chainId: BigNumberish, + _lastCommittedBatchData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _newBatchesData: { + batchNumber: BigNumberish; + timestamp: BigNumberish; + indexRepeatedStorageChanges: BigNumberish; + newStateRoot: BytesLike; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + bootloaderHeapInitialContentsHash: BytesLike; + eventsQueueStateHash: BytesLike; + systemLogs: BytesLike; + pubdataCommitments: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + "commitBatchesSharedBridge(uint256,tuple,tuple[])"( + _chainId: BigNumberish, + _lastCommittedBatchData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _newBatchesData: { + batchNumber: BigNumberish; + timestamp: BigNumberish; + indexRepeatedStorageChanges: BigNumberish; + newStateRoot: BytesLike; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + bootloaderHeapInitialContentsHash: BytesLike; + eventsQueueStateHash: BytesLike; + systemLogs: BytesLike; + pubdataCommitments: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + executeBatches( + _batchesData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + "executeBatches(tuple[])"( + _batchesData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + executeBatchesSharedBridge( + _chainId: BigNumberish, + _batchesData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + "executeBatchesSharedBridge(uint256,tuple[])"( + _chainId: BigNumberish, + _batchesData: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + overrides?: Overrides + ): Promise; + + executeUpgrade( + _diamondCut: { + facetCuts: { + facet: string; + action: BigNumberish; + isFreezable: boolean; + selectors: BytesLike[]; + }[]; + initAddress: string; + initCalldata: BytesLike; + }, + overrides?: Overrides + ): Promise; + + "executeUpgrade(tuple)"( + _diamondCut: { + facetCuts: { + facet: string; + action: BigNumberish; + isFreezable: boolean; + selectors: BytesLike[]; + }[]; + initAddress: string; + initCalldata: BytesLike; + }, + overrides?: Overrides + ): Promise; + + facetAddress( + _selector: BytesLike, + overrides?: CallOverrides + ): Promise; + + "facetAddress(bytes4)"( + _selector: BytesLike, + overrides?: CallOverrides + ): Promise; + + facetAddresses(overrides?: CallOverrides): Promise; + + "facetAddresses()"( + overrides?: CallOverrides + ): Promise; + + facetFunctionSelectors( + _facet: string, + overrides?: CallOverrides + ): Promise; + + "facetFunctionSelectors(address)"( + _facet: string, + overrides?: CallOverrides + ): Promise; + + facets(overrides?: CallOverrides): Promise; + + "facets()"(overrides?: CallOverrides): Promise; + + finalizeEthWithdrawal( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "finalizeEthWithdrawal(uint256,uint256,uint16,bytes,bytes32[])"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + freezeDiamond(overrides?: Overrides): Promise; + + "freezeDiamond()"(overrides?: Overrides): Promise; + + getAdmin(overrides?: CallOverrides): Promise; + + "getAdmin()"(overrides?: CallOverrides): Promise; + + getBaseToken(overrides?: CallOverrides): Promise; + + "getBaseToken()"(overrides?: CallOverrides): Promise; + + getBaseTokenBridge( + overrides?: CallOverrides + ): Promise; + + "getBaseTokenBridge()"( + overrides?: CallOverrides + ): Promise; + + getBridgehub(overrides?: CallOverrides): Promise; + + "getBridgehub()"(overrides?: CallOverrides): Promise; + + getFirstUnprocessedPriorityTx( + overrides?: CallOverrides + ): Promise; + + "getFirstUnprocessedPriorityTx()"( + overrides?: CallOverrides + ): Promise; + + getL2BootloaderBytecodeHash( + overrides?: CallOverrides + ): Promise; + + "getL2BootloaderBytecodeHash()"( + overrides?: CallOverrides + ): Promise; + + getL2DefaultAccountBytecodeHash( + overrides?: CallOverrides + ): Promise; + + "getL2DefaultAccountBytecodeHash()"( + overrides?: CallOverrides + ): Promise; + + getL2SystemContractsUpgradeBatchNumber( + overrides?: CallOverrides + ): Promise; + + "getL2SystemContractsUpgradeBatchNumber()"( + overrides?: CallOverrides + ): Promise; + + getL2SystemContractsUpgradeTxHash( + overrides?: CallOverrides + ): Promise; + + "getL2SystemContractsUpgradeTxHash()"( + overrides?: CallOverrides + ): Promise; + + getName(overrides?: CallOverrides): Promise; + + "getName()"(overrides?: CallOverrides): Promise; + + getPendingAdmin(overrides?: CallOverrides): Promise; + + "getPendingAdmin()"( + overrides?: CallOverrides + ): Promise; + + getPriorityQueueSize( + overrides?: CallOverrides + ): Promise; + + "getPriorityQueueSize()"( + overrides?: CallOverrides + ): Promise; + + getPriorityTxMaxGasLimit( + overrides?: CallOverrides + ): Promise; + + "getPriorityTxMaxGasLimit()"( + overrides?: CallOverrides + ): Promise; + + getProtocolVersion( + overrides?: CallOverrides + ): Promise; + + "getProtocolVersion()"( + overrides?: CallOverrides + ): Promise; + + getPubdataPricingMode( + overrides?: CallOverrides + ): Promise; + + "getPubdataPricingMode()"( + overrides?: CallOverrides + ): Promise; + + getStateTransitionManager( + overrides?: CallOverrides + ): Promise; + + "getStateTransitionManager()"( + overrides?: CallOverrides + ): Promise; + + getTotalBatchesCommitted( + overrides?: CallOverrides + ): Promise; + + "getTotalBatchesCommitted()"( + overrides?: CallOverrides + ): Promise; + + getTotalBatchesExecuted( + overrides?: CallOverrides + ): Promise; + + "getTotalBatchesExecuted()"( + overrides?: CallOverrides + ): Promise; + + getTotalBatchesVerified( + overrides?: CallOverrides + ): Promise; + + "getTotalBatchesVerified()"( + overrides?: CallOverrides + ): Promise; + + getTotalPriorityTxs( + overrides?: CallOverrides + ): Promise; + + "getTotalPriorityTxs()"( + overrides?: CallOverrides + ): Promise; + + getVerifier(overrides?: CallOverrides): Promise; + + "getVerifier()"(overrides?: CallOverrides): Promise; + + getVerifierParams(overrides?: CallOverrides): Promise; + + "getVerifierParams()"( + overrides?: CallOverrides + ): Promise; + + isDiamondStorageFrozen( + overrides?: CallOverrides + ): Promise; + + "isDiamondStorageFrozen()"( + overrides?: CallOverrides + ): Promise; + + isEthWithdrawalFinalized( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "isEthWithdrawalFinalized(uint256,uint256)"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + isFacetFreezable( + _facet: string, + overrides?: CallOverrides + ): Promise; + + "isFacetFreezable(address)"( + _facet: string, + overrides?: CallOverrides + ): Promise; + + isFunctionFreezable( + _selector: BytesLike, + overrides?: CallOverrides + ): Promise; + + "isFunctionFreezable(bytes4)"( + _selector: BytesLike, + overrides?: CallOverrides + ): Promise; + + isValidator( + _address: string, + overrides?: CallOverrides + ): Promise; + + "isValidator(address)"( + _address: string, + overrides?: CallOverrides + ): Promise; + + l2LogsRootHash( + _batchNumber: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "l2LogsRootHash(uint256)"( + _batchNumber: BigNumberish, + overrides?: CallOverrides + ): Promise; + + l2TransactionBaseCost( + _gasPrice: BigNumberish, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "l2TransactionBaseCost(uint256,uint256,uint256)"( + _gasPrice: BigNumberish, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + overrides?: CallOverrides + ): Promise; + + priorityQueueFrontOperation( + overrides?: CallOverrides + ): Promise; + + "priorityQueueFrontOperation()"( + overrides?: CallOverrides + ): Promise; + + proveBatches( + _prevBatch: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _committedBatches: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + _proof: { + recursiveAggregationInput: BigNumberish[]; + serializedProof: BigNumberish[]; + }, + overrides?: Overrides + ): Promise; + + "proveBatches(tuple,tuple[],tuple)"( + _prevBatch: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _committedBatches: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + _proof: { + recursiveAggregationInput: BigNumberish[]; + serializedProof: BigNumberish[]; + }, + overrides?: Overrides + ): Promise; + + proveBatchesSharedBridge( + _chainId: BigNumberish, + _prevBatch: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _committedBatches: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + _proof: { + recursiveAggregationInput: BigNumberish[]; + serializedProof: BigNumberish[]; + }, + overrides?: Overrides + ): Promise; + + "proveBatchesSharedBridge(uint256,tuple,tuple[],tuple)"( + _chainId: BigNumberish, + _prevBatch: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }, + _committedBatches: { + batchNumber: BigNumberish; + batchHash: BytesLike; + indexRepeatedStorageChanges: BigNumberish; + numberOfLayer1Txs: BigNumberish; + priorityOperationsHash: BytesLike; + l2LogsTreeRoot: BytesLike; + timestamp: BigNumberish; + commitment: BytesLike; + }[], + _proof: { + recursiveAggregationInput: BigNumberish[]; + serializedProof: BigNumberish[]; + }, + overrides?: Overrides + ): Promise; + + proveL1ToL2TransactionStatus( + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + _status: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "proveL1ToL2TransactionStatus(bytes32,uint256,uint256,uint16,bytes32[],uint8)"( + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + _status: BigNumberish, + overrides?: CallOverrides + ): Promise; + + proveL2LogInclusion( + _batchNumber: BigNumberish, + _index: BigNumberish, + _log: { + l2ShardId: BigNumberish; + isService: boolean; + txNumberInBatch: BigNumberish; + sender: string; + key: BytesLike; + value: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + "proveL2LogInclusion(uint256,uint256,tuple,bytes32[])"( + _batchNumber: BigNumberish, + _index: BigNumberish, + _log: { + l2ShardId: BigNumberish; + isService: boolean; + txNumberInBatch: BigNumberish; + sender: string; + key: BytesLike; + value: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + proveL2MessageInclusion( + _batchNumber: BigNumberish, + _index: BigNumberish, + _message: { + txNumberInBatch: BigNumberish; + sender: string; + data: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + "proveL2MessageInclusion(uint256,uint256,tuple,bytes32[])"( + _batchNumber: BigNumberish, + _index: BigNumberish, + _message: { + txNumberInBatch: BigNumberish; + sender: string; + data: BytesLike; + }, + _proof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + requestL2Transaction( + _contractL2: string, + _l2Value: BigNumberish, + _calldata: BytesLike, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + _factoryDeps: BytesLike[], + _refundRecipient: string, + overrides?: PayableOverrides + ): Promise; + + "requestL2Transaction(address,uint256,bytes,uint256,uint256,bytes[],address)"( + _contractL2: string, + _l2Value: BigNumberish, + _calldata: BytesLike, + _l2GasLimit: BigNumberish, + _l2GasPerPubdataByteLimit: BigNumberish, + _factoryDeps: BytesLike[], + _refundRecipient: string, + overrides?: PayableOverrides + ): Promise; + + revertBatches( + _newLastBatch: BigNumberish, + overrides?: Overrides + ): Promise; + + "revertBatches(uint256)"( + _newLastBatch: BigNumberish, + overrides?: Overrides + ): Promise; + + revertBatchesSharedBridge( + _chainId: BigNumberish, + _newLastBatch: BigNumberish, + overrides?: Overrides + ): Promise; + + "revertBatchesSharedBridge(uint256,uint256)"( + _chainId: BigNumberish, + _newLastBatch: BigNumberish, + overrides?: Overrides + ): Promise; + + setPendingAdmin( + _newPendingAdmin: string, + overrides?: Overrides + ): Promise; + + "setPendingAdmin(address)"( + _newPendingAdmin: string, + overrides?: Overrides + ): Promise; + + setPorterAvailability( + _zkPorterIsAvailable: boolean, + overrides?: Overrides + ): Promise; + + "setPorterAvailability(bool)"( + _zkPorterIsAvailable: boolean, + overrides?: Overrides + ): Promise; + + setPriorityTxMaxGasLimit( + _newPriorityTxMaxGasLimit: BigNumberish, + overrides?: Overrides + ): Promise; + + "setPriorityTxMaxGasLimit(uint256)"( + _newPriorityTxMaxGasLimit: BigNumberish, + overrides?: Overrides + ): Promise; + + setTokenMultiplier( + _nominator: BigNumberish, + _denominator: BigNumberish, + overrides?: Overrides + ): Promise; + + "setTokenMultiplier(uint128,uint128)"( + _nominator: BigNumberish, + _denominator: BigNumberish, + overrides?: Overrides + ): Promise; + + setTransactionFilterer( + _transactionFilterer: string, + overrides?: Overrides + ): Promise; + + "setTransactionFilterer(address)"( + _transactionFilterer: string, + overrides?: Overrides + ): Promise; + + setValidator( + _validator: string, + _active: boolean, + overrides?: Overrides + ): Promise; + + "setValidator(address,bool)"( + _validator: string, + _active: boolean, + overrides?: Overrides + ): Promise; + + setValidiumMode( + _validiumMode: BigNumberish, + overrides?: Overrides + ): Promise; + + "setValidiumMode(uint8)"( + _validiumMode: BigNumberish, + overrides?: Overrides + ): Promise; + + storedBatchHash( + _batchNumber: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "storedBatchHash(uint256)"( + _batchNumber: BigNumberish, + overrides?: CallOverrides + ): Promise; + + transferEthToSharedBridge( + overrides?: Overrides + ): Promise; + + "transferEthToSharedBridge()"( + overrides?: Overrides + ): Promise; + + unfreezeDiamond(overrides?: Overrides): Promise; + + "unfreezeDiamond()"(overrides?: Overrides): Promise; + + upgradeChainFromVersion( + _protocolVersion: BigNumberish, + _cutData: { + facetCuts: { + facet: string; + action: BigNumberish; + isFreezable: boolean; + selectors: BytesLike[]; + }[]; + initAddress: string; + initCalldata: BytesLike; + }, + overrides?: Overrides + ): Promise; + + "upgradeChainFromVersion(uint256,tuple)"( + _protocolVersion: BigNumberish, + _cutData: { + facetCuts: { + facet: string; + action: BigNumberish; + isFreezable: boolean; + selectors: BytesLike[]; + }[]; + initAddress: string; + initCalldata: BytesLike; + }, + overrides?: Overrides + ): Promise; + }; +} diff --git a/src/typechain/IZkSyncStateTransitionFactory.ts b/src/typechain/IZkSyncStateTransitionFactory.ts new file mode 100644 index 00000000..aa175388 --- /dev/null +++ b/src/typechain/IZkSyncStateTransitionFactory.ts @@ -0,0 +1,2425 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer } from "ethers"; +import { Provider } from "@ethersproject/providers"; + +import type { IZkSyncStateTransition } from "./IZkSyncStateTransition"; + +export class IZkSyncStateTransitionFactory { + static connect( + address: string, + signerOrProvider: Signer | Provider + ): IZkSyncStateTransition { + return new Contract( + address, + _abi, + signerOrProvider + ) as IZkSyncStateTransition; + } +} + +const _abi = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "batchNumber", + type: "uint256", + }, + { + indexed: true, + internalType: "bytes32", + name: "batchHash", + type: "bytes32", + }, + { + indexed: true, + internalType: "bytes32", + name: "commitment", + type: "bytes32", + }, + ], + name: "BlockCommit", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "batchNumber", + type: "uint256", + }, + { + indexed: true, + internalType: "bytes32", + name: "batchHash", + type: "bytes32", + }, + { + indexed: true, + internalType: "bytes32", + name: "commitment", + type: "bytes32", + }, + ], + name: "BlockExecution", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "totalBatchesCommitted", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "totalBatchesVerified", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "totalBatchesExecuted", + type: "uint256", + }, + ], + name: "BlocksRevert", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "previousLastVerifiedBatch", + type: "uint256", + }, + { + indexed: true, + internalType: "uint256", + name: "currentLastVerifiedBatch", + type: "uint256", + }, + ], + name: "BlocksVerification", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "to", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "EthWithdrawalFinalized", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + components: [ + { + components: [ + { + internalType: "address", + name: "facet", + type: "address", + }, + { + internalType: "enum Diamond.Action", + name: "action", + type: "uint8", + }, + { + internalType: "bool", + name: "isFreezable", + type: "bool", + }, + { + internalType: "bytes4[]", + name: "selectors", + type: "bytes4[]", + }, + ], + internalType: "struct Diamond.FacetCut[]", + name: "facetCuts", + type: "tuple[]", + }, + { + internalType: "address", + name: "initAddress", + type: "address", + }, + { + internalType: "bytes", + name: "initCalldata", + type: "bytes", + }, + ], + indexed: false, + internalType: "struct Diamond.DiamondCutData", + name: "diamondCut", + type: "tuple", + }, + ], + name: "ExecuteUpgrade", + type: "event", + }, + { + anonymous: false, + inputs: [], + name: "Freeze", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "bool", + name: "isPorterAvailable", + type: "bool", + }, + ], + name: "IsPorterAvailableStatusUpdate", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "oldAdmin", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "newAdmin", + type: "address", + }, + ], + name: "NewAdmin", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint128", + name: "oldNominator", + type: "uint128", + }, + { + indexed: false, + internalType: "uint128", + name: "oldDenominator", + type: "uint128", + }, + { + indexed: false, + internalType: "uint128", + name: "newNominator", + type: "uint128", + }, + { + indexed: false, + internalType: "uint128", + name: "newDenominator", + type: "uint128", + }, + ], + name: "NewBaseTokenMultiplier", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + components: [ + { + internalType: "enum PubdataPricingMode", + name: "pubdataPricingMode", + type: "uint8", + }, + { + internalType: "uint32", + name: "batchOverheadL1Gas", + type: "uint32", + }, + { + internalType: "uint32", + name: "maxPubdataPerBatch", + type: "uint32", + }, + { + internalType: "uint32", + name: "maxL2GasPerBatch", + type: "uint32", + }, + { + internalType: "uint32", + name: "priorityTxMaxPubdata", + type: "uint32", + }, + { + internalType: "uint64", + name: "minimalL2GasPrice", + type: "uint64", + }, + ], + indexed: false, + internalType: "struct FeeParams", + name: "oldFeeParams", + type: "tuple", + }, + { + components: [ + { + internalType: "enum PubdataPricingMode", + name: "pubdataPricingMode", + type: "uint8", + }, + { + internalType: "uint32", + name: "batchOverheadL1Gas", + type: "uint32", + }, + { + internalType: "uint32", + name: "maxPubdataPerBatch", + type: "uint32", + }, + { + internalType: "uint32", + name: "maxL2GasPerBatch", + type: "uint32", + }, + { + internalType: "uint32", + name: "priorityTxMaxPubdata", + type: "uint32", + }, + { + internalType: "uint64", + name: "minimalL2GasPrice", + type: "uint64", + }, + ], + indexed: false, + internalType: "struct FeeParams", + name: "newFeeParams", + type: "tuple", + }, + ], + name: "NewFeeParams", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "oldPendingAdmin", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "newPendingAdmin", + type: "address", + }, + ], + name: "NewPendingAdmin", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "txId", + type: "uint256", + }, + { + indexed: false, + internalType: "bytes32", + name: "txHash", + type: "bytes32", + }, + { + indexed: false, + internalType: "uint64", + name: "expirationTimestamp", + type: "uint64", + }, + { + components: [ + { + internalType: "uint256", + name: "txType", + type: "uint256", + }, + { + internalType: "uint256", + name: "from", + type: "uint256", + }, + { + internalType: "uint256", + name: "to", + type: "uint256", + }, + { + internalType: "uint256", + name: "gasLimit", + type: "uint256", + }, + { + internalType: "uint256", + name: "gasPerPubdataByteLimit", + type: "uint256", + }, + { + internalType: "uint256", + name: "maxFeePerGas", + type: "uint256", + }, + { + internalType: "uint256", + name: "maxPriorityFeePerGas", + type: "uint256", + }, + { + internalType: "uint256", + name: "paymaster", + type: "uint256", + }, + { + internalType: "uint256", + name: "nonce", + type: "uint256", + }, + { + internalType: "uint256", + name: "value", + type: "uint256", + }, + { + internalType: "uint256[4]", + name: "reserved", + type: "uint256[4]", + }, + { + internalType: "bytes", + name: "data", + type: "bytes", + }, + { + internalType: "bytes", + name: "signature", + type: "bytes", + }, + { + internalType: "uint256[]", + name: "factoryDeps", + type: "uint256[]", + }, + { + internalType: "bytes", + name: "paymasterInput", + type: "bytes", + }, + { + internalType: "bytes", + name: "reservedDynamic", + type: "bytes", + }, + ], + indexed: false, + internalType: "struct L2CanonicalTransaction", + name: "transaction", + type: "tuple", + }, + { + indexed: false, + internalType: "bytes[]", + name: "factoryDeps", + type: "bytes[]", + }, + ], + name: "NewPriorityRequest", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "oldPriorityTxMaxGasLimit", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "newPriorityTxMaxGasLimit", + type: "uint256", + }, + ], + name: "NewPriorityTxMaxGasLimit", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "oldTransactionFilterer", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "newTransactionFilterer", + type: "address", + }, + ], + name: "NewTransactionFilterer", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + components: [ + { + components: [ + { + internalType: "address", + name: "facet", + type: "address", + }, + { + internalType: "enum Diamond.Action", + name: "action", + type: "uint8", + }, + { + internalType: "bool", + name: "isFreezable", + type: "bool", + }, + { + internalType: "bytes4[]", + name: "selectors", + type: "bytes4[]", + }, + ], + internalType: "struct Diamond.FacetCut[]", + name: "facetCuts", + type: "tuple[]", + }, + { + internalType: "address", + name: "initAddress", + type: "address", + }, + { + internalType: "bytes", + name: "initCalldata", + type: "bytes", + }, + ], + indexed: false, + internalType: "struct Diamond.DiamondCutData", + name: "diamondCut", + type: "tuple", + }, + { + indexed: true, + internalType: "uint256", + name: "proposalId", + type: "uint256", + }, + { + indexed: false, + internalType: "bytes32", + name: "proposalSalt", + type: "bytes32", + }, + ], + name: "ProposeTransparentUpgrade", + type: "event", + }, + { + anonymous: false, + inputs: [], + name: "Unfreeze", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "validatorAddress", + type: "address", + }, + { + indexed: false, + internalType: "bool", + name: "isActive", + type: "bool", + }, + ], + name: "ValidatorStatusUpdate", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "enum PubdataPricingMode", + name: "validiumMode", + type: "uint8", + }, + ], + name: "ValidiumModeStatusUpdate", + type: "event", + }, + { + inputs: [], + name: "acceptAdmin", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "baseTokenGasPriceMultiplierDenominator", + outputs: [ + { + internalType: "uint128", + name: "", + type: "uint128", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "baseTokenGasPriceMultiplierNominator", + outputs: [ + { + internalType: "uint128", + name: "", + type: "uint128", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + components: [ + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "address", + name: "contractL2", + type: "address", + }, + { + internalType: "uint256", + name: "mintValue", + type: "uint256", + }, + { + internalType: "uint256", + name: "l2Value", + type: "uint256", + }, + { + internalType: "bytes", + name: "l2Calldata", + type: "bytes", + }, + { + internalType: "uint256", + name: "l2GasLimit", + type: "uint256", + }, + { + internalType: "uint256", + name: "l2GasPerPubdataByteLimit", + type: "uint256", + }, + { + internalType: "bytes[]", + name: "factoryDeps", + type: "bytes[]", + }, + { + internalType: "address", + name: "refundRecipient", + type: "address", + }, + ], + internalType: "struct BridgehubL2TransactionRequest", + name: "_request", + type: "tuple", + }, + ], + name: "bridgehubRequestL2Transaction", + outputs: [ + { + internalType: "bytes32", + name: "canonicalTxHash", + type: "bytes32", + }, + ], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + components: [ + { + internalType: "enum PubdataPricingMode", + name: "pubdataPricingMode", + type: "uint8", + }, + { + internalType: "uint32", + name: "batchOverheadL1Gas", + type: "uint32", + }, + { + internalType: "uint32", + name: "maxPubdataPerBatch", + type: "uint32", + }, + { + internalType: "uint32", + name: "maxL2GasPerBatch", + type: "uint32", + }, + { + internalType: "uint32", + name: "priorityTxMaxPubdata", + type: "uint32", + }, + { + internalType: "uint64", + name: "minimalL2GasPrice", + type: "uint64", + }, + ], + internalType: "struct FeeParams", + name: "_newFeeParams", + type: "tuple", + }, + ], + name: "changeFeeParams", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + components: [ + { + internalType: "uint64", + name: "batchNumber", + type: "uint64", + }, + { + internalType: "bytes32", + name: "batchHash", + type: "bytes32", + }, + { + internalType: "uint64", + name: "indexRepeatedStorageChanges", + type: "uint64", + }, + { + internalType: "uint256", + name: "numberOfLayer1Txs", + type: "uint256", + }, + { + internalType: "bytes32", + name: "priorityOperationsHash", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "l2LogsTreeRoot", + type: "bytes32", + }, + { + internalType: "uint256", + name: "timestamp", + type: "uint256", + }, + { + internalType: "bytes32", + name: "commitment", + type: "bytes32", + }, + ], + internalType: "struct IExecutor.StoredBatchInfo", + name: "_lastCommittedBatchData", + type: "tuple", + }, + { + components: [ + { + internalType: "uint64", + name: "batchNumber", + type: "uint64", + }, + { + internalType: "uint64", + name: "timestamp", + type: "uint64", + }, + { + internalType: "uint64", + name: "indexRepeatedStorageChanges", + type: "uint64", + }, + { + internalType: "bytes32", + name: "newStateRoot", + type: "bytes32", + }, + { + internalType: "uint256", + name: "numberOfLayer1Txs", + type: "uint256", + }, + { + internalType: "bytes32", + name: "priorityOperationsHash", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "bootloaderHeapInitialContentsHash", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "eventsQueueStateHash", + type: "bytes32", + }, + { + internalType: "bytes", + name: "systemLogs", + type: "bytes", + }, + { + internalType: "bytes", + name: "pubdataCommitments", + type: "bytes", + }, + ], + internalType: "struct IExecutor.CommitBatchInfo[]", + name: "_newBatchesData", + type: "tuple[]", + }, + ], + name: "commitBatches", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + components: [ + { + internalType: "uint64", + name: "batchNumber", + type: "uint64", + }, + { + internalType: "bytes32", + name: "batchHash", + type: "bytes32", + }, + { + internalType: "uint64", + name: "indexRepeatedStorageChanges", + type: "uint64", + }, + { + internalType: "uint256", + name: "numberOfLayer1Txs", + type: "uint256", + }, + { + internalType: "bytes32", + name: "priorityOperationsHash", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "l2LogsTreeRoot", + type: "bytes32", + }, + { + internalType: "uint256", + name: "timestamp", + type: "uint256", + }, + { + internalType: "bytes32", + name: "commitment", + type: "bytes32", + }, + ], + internalType: "struct IExecutor.StoredBatchInfo", + name: "_lastCommittedBatchData", + type: "tuple", + }, + { + components: [ + { + internalType: "uint64", + name: "batchNumber", + type: "uint64", + }, + { + internalType: "uint64", + name: "timestamp", + type: "uint64", + }, + { + internalType: "uint64", + name: "indexRepeatedStorageChanges", + type: "uint64", + }, + { + internalType: "bytes32", + name: "newStateRoot", + type: "bytes32", + }, + { + internalType: "uint256", + name: "numberOfLayer1Txs", + type: "uint256", + }, + { + internalType: "bytes32", + name: "priorityOperationsHash", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "bootloaderHeapInitialContentsHash", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "eventsQueueStateHash", + type: "bytes32", + }, + { + internalType: "bytes", + name: "systemLogs", + type: "bytes", + }, + { + internalType: "bytes", + name: "pubdataCommitments", + type: "bytes", + }, + ], + internalType: "struct IExecutor.CommitBatchInfo[]", + name: "_newBatchesData", + type: "tuple[]", + }, + ], + name: "commitBatchesSharedBridge", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + components: [ + { + internalType: "uint64", + name: "batchNumber", + type: "uint64", + }, + { + internalType: "bytes32", + name: "batchHash", + type: "bytes32", + }, + { + internalType: "uint64", + name: "indexRepeatedStorageChanges", + type: "uint64", + }, + { + internalType: "uint256", + name: "numberOfLayer1Txs", + type: "uint256", + }, + { + internalType: "bytes32", + name: "priorityOperationsHash", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "l2LogsTreeRoot", + type: "bytes32", + }, + { + internalType: "uint256", + name: "timestamp", + type: "uint256", + }, + { + internalType: "bytes32", + name: "commitment", + type: "bytes32", + }, + ], + internalType: "struct IExecutor.StoredBatchInfo[]", + name: "_batchesData", + type: "tuple[]", + }, + ], + name: "executeBatches", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + components: [ + { + internalType: "uint64", + name: "batchNumber", + type: "uint64", + }, + { + internalType: "bytes32", + name: "batchHash", + type: "bytes32", + }, + { + internalType: "uint64", + name: "indexRepeatedStorageChanges", + type: "uint64", + }, + { + internalType: "uint256", + name: "numberOfLayer1Txs", + type: "uint256", + }, + { + internalType: "bytes32", + name: "priorityOperationsHash", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "l2LogsTreeRoot", + type: "bytes32", + }, + { + internalType: "uint256", + name: "timestamp", + type: "uint256", + }, + { + internalType: "bytes32", + name: "commitment", + type: "bytes32", + }, + ], + internalType: "struct IExecutor.StoredBatchInfo[]", + name: "_batchesData", + type: "tuple[]", + }, + ], + name: "executeBatchesSharedBridge", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + components: [ + { + components: [ + { + internalType: "address", + name: "facet", + type: "address", + }, + { + internalType: "enum Diamond.Action", + name: "action", + type: "uint8", + }, + { + internalType: "bool", + name: "isFreezable", + type: "bool", + }, + { + internalType: "bytes4[]", + name: "selectors", + type: "bytes4[]", + }, + ], + internalType: "struct Diamond.FacetCut[]", + name: "facetCuts", + type: "tuple[]", + }, + { + internalType: "address", + name: "initAddress", + type: "address", + }, + { + internalType: "bytes", + name: "initCalldata", + type: "bytes", + }, + ], + internalType: "struct Diamond.DiamondCutData", + name: "_diamondCut", + type: "tuple", + }, + ], + name: "executeUpgrade", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes4", + name: "_selector", + type: "bytes4", + }, + ], + name: "facetAddress", + outputs: [ + { + internalType: "address", + name: "facet", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "facetAddresses", + outputs: [ + { + internalType: "address[]", + name: "facets", + type: "address[]", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_facet", + type: "address", + }, + ], + name: "facetFunctionSelectors", + outputs: [ + { + internalType: "bytes4[]", + name: "", + type: "bytes4[]", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "facets", + outputs: [ + { + components: [ + { + internalType: "address", + name: "addr", + type: "address", + }, + { + internalType: "bytes4[]", + name: "selectors", + type: "bytes4[]", + }, + ], + internalType: "struct IGetters.Facet[]", + name: "", + type: "tuple[]", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_l2BatchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2MessageIndex", + type: "uint256", + }, + { + internalType: "uint16", + name: "_l2TxNumberInBatch", + type: "uint16", + }, + { + internalType: "bytes", + name: "_message", + type: "bytes", + }, + { + internalType: "bytes32[]", + name: "_merkleProof", + type: "bytes32[]", + }, + ], + name: "finalizeEthWithdrawal", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "freezeDiamond", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "getAdmin", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getBaseToken", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getBaseTokenBridge", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getBridgehub", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getFirstUnprocessedPriorityTx", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getL2BootloaderBytecodeHash", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getL2DefaultAccountBytecodeHash", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getL2SystemContractsUpgradeBatchNumber", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getL2SystemContractsUpgradeTxHash", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getName", + outputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getPendingAdmin", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getPriorityQueueSize", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getPriorityTxMaxGasLimit", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getProtocolVersion", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getPubdataPricingMode", + outputs: [ + { + internalType: "enum PubdataPricingMode", + name: "", + type: "uint8", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getStateTransitionManager", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getTotalBatchesCommitted", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getTotalBatchesExecuted", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getTotalBatchesVerified", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getTotalPriorityTxs", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getVerifier", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getVerifierParams", + outputs: [ + { + components: [ + { + internalType: "bytes32", + name: "recursionNodeLevelVkHash", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "recursionLeafLevelVkHash", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "recursionCircuitsSetVksHash", + type: "bytes32", + }, + ], + internalType: "struct VerifierParams", + name: "", + type: "tuple", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "isDiamondStorageFrozen", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_l2BatchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2MessageIndex", + type: "uint256", + }, + ], + name: "isEthWithdrawalFinalized", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_facet", + type: "address", + }, + ], + name: "isFacetFreezable", + outputs: [ + { + internalType: "bool", + name: "isFreezable", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes4", + name: "_selector", + type: "bytes4", + }, + ], + name: "isFunctionFreezable", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_address", + type: "address", + }, + ], + name: "isValidator", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_batchNumber", + type: "uint256", + }, + ], + name: "l2LogsRootHash", + outputs: [ + { + internalType: "bytes32", + name: "merkleRoot", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_gasPrice", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2GasLimit", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2GasPerPubdataByteLimit", + type: "uint256", + }, + ], + name: "l2TransactionBaseCost", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "priorityQueueFrontOperation", + outputs: [ + { + components: [ + { + internalType: "bytes32", + name: "canonicalTxHash", + type: "bytes32", + }, + { + internalType: "uint64", + name: "expirationTimestamp", + type: "uint64", + }, + { + internalType: "uint192", + name: "layer2Tip", + type: "uint192", + }, + ], + internalType: "struct PriorityOperation", + name: "", + type: "tuple", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + components: [ + { + internalType: "uint64", + name: "batchNumber", + type: "uint64", + }, + { + internalType: "bytes32", + name: "batchHash", + type: "bytes32", + }, + { + internalType: "uint64", + name: "indexRepeatedStorageChanges", + type: "uint64", + }, + { + internalType: "uint256", + name: "numberOfLayer1Txs", + type: "uint256", + }, + { + internalType: "bytes32", + name: "priorityOperationsHash", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "l2LogsTreeRoot", + type: "bytes32", + }, + { + internalType: "uint256", + name: "timestamp", + type: "uint256", + }, + { + internalType: "bytes32", + name: "commitment", + type: "bytes32", + }, + ], + internalType: "struct IExecutor.StoredBatchInfo", + name: "_prevBatch", + type: "tuple", + }, + { + components: [ + { + internalType: "uint64", + name: "batchNumber", + type: "uint64", + }, + { + internalType: "bytes32", + name: "batchHash", + type: "bytes32", + }, + { + internalType: "uint64", + name: "indexRepeatedStorageChanges", + type: "uint64", + }, + { + internalType: "uint256", + name: "numberOfLayer1Txs", + type: "uint256", + }, + { + internalType: "bytes32", + name: "priorityOperationsHash", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "l2LogsTreeRoot", + type: "bytes32", + }, + { + internalType: "uint256", + name: "timestamp", + type: "uint256", + }, + { + internalType: "bytes32", + name: "commitment", + type: "bytes32", + }, + ], + internalType: "struct IExecutor.StoredBatchInfo[]", + name: "_committedBatches", + type: "tuple[]", + }, + { + components: [ + { + internalType: "uint256[]", + name: "recursiveAggregationInput", + type: "uint256[]", + }, + { + internalType: "uint256[]", + name: "serializedProof", + type: "uint256[]", + }, + ], + internalType: "struct IExecutor.ProofInput", + name: "_proof", + type: "tuple", + }, + ], + name: "proveBatches", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + components: [ + { + internalType: "uint64", + name: "batchNumber", + type: "uint64", + }, + { + internalType: "bytes32", + name: "batchHash", + type: "bytes32", + }, + { + internalType: "uint64", + name: "indexRepeatedStorageChanges", + type: "uint64", + }, + { + internalType: "uint256", + name: "numberOfLayer1Txs", + type: "uint256", + }, + { + internalType: "bytes32", + name: "priorityOperationsHash", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "l2LogsTreeRoot", + type: "bytes32", + }, + { + internalType: "uint256", + name: "timestamp", + type: "uint256", + }, + { + internalType: "bytes32", + name: "commitment", + type: "bytes32", + }, + ], + internalType: "struct IExecutor.StoredBatchInfo", + name: "_prevBatch", + type: "tuple", + }, + { + components: [ + { + internalType: "uint64", + name: "batchNumber", + type: "uint64", + }, + { + internalType: "bytes32", + name: "batchHash", + type: "bytes32", + }, + { + internalType: "uint64", + name: "indexRepeatedStorageChanges", + type: "uint64", + }, + { + internalType: "uint256", + name: "numberOfLayer1Txs", + type: "uint256", + }, + { + internalType: "bytes32", + name: "priorityOperationsHash", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "l2LogsTreeRoot", + type: "bytes32", + }, + { + internalType: "uint256", + name: "timestamp", + type: "uint256", + }, + { + internalType: "bytes32", + name: "commitment", + type: "bytes32", + }, + ], + internalType: "struct IExecutor.StoredBatchInfo[]", + name: "_committedBatches", + type: "tuple[]", + }, + { + components: [ + { + internalType: "uint256[]", + name: "recursiveAggregationInput", + type: "uint256[]", + }, + { + internalType: "uint256[]", + name: "serializedProof", + type: "uint256[]", + }, + ], + internalType: "struct IExecutor.ProofInput", + name: "_proof", + type: "tuple", + }, + ], + name: "proveBatchesSharedBridge", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "_l2TxHash", + type: "bytes32", + }, + { + internalType: "uint256", + name: "_l2BatchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2MessageIndex", + type: "uint256", + }, + { + internalType: "uint16", + name: "_l2TxNumberInBatch", + type: "uint16", + }, + { + internalType: "bytes32[]", + name: "_merkleProof", + type: "bytes32[]", + }, + { + internalType: "enum TxStatus", + name: "_status", + type: "uint8", + }, + ], + name: "proveL1ToL2TransactionStatus", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_batchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_index", + type: "uint256", + }, + { + components: [ + { + internalType: "uint8", + name: "l2ShardId", + type: "uint8", + }, + { + internalType: "bool", + name: "isService", + type: "bool", + }, + { + internalType: "uint16", + name: "txNumberInBatch", + type: "uint16", + }, + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "bytes32", + name: "key", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "value", + type: "bytes32", + }, + ], + internalType: "struct L2Log", + name: "_log", + type: "tuple", + }, + { + internalType: "bytes32[]", + name: "_proof", + type: "bytes32[]", + }, + ], + name: "proveL2LogInclusion", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_batchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_index", + type: "uint256", + }, + { + components: [ + { + internalType: "uint16", + name: "txNumberInBatch", + type: "uint16", + }, + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "bytes", + name: "data", + type: "bytes", + }, + ], + internalType: "struct L2Message", + name: "_message", + type: "tuple", + }, + { + internalType: "bytes32[]", + name: "_proof", + type: "bytes32[]", + }, + ], + name: "proveL2MessageInclusion", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_contractL2", + type: "address", + }, + { + internalType: "uint256", + name: "_l2Value", + type: "uint256", + }, + { + internalType: "bytes", + name: "_calldata", + type: "bytes", + }, + { + internalType: "uint256", + name: "_l2GasLimit", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2GasPerPubdataByteLimit", + type: "uint256", + }, + { + internalType: "bytes[]", + name: "_factoryDeps", + type: "bytes[]", + }, + { + internalType: "address", + name: "_refundRecipient", + type: "address", + }, + ], + name: "requestL2Transaction", + outputs: [ + { + internalType: "bytes32", + name: "canonicalTxHash", + type: "bytes32", + }, + ], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_newLastBatch", + type: "uint256", + }, + ], + name: "revertBatches", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "uint256", + name: "_newLastBatch", + type: "uint256", + }, + ], + name: "revertBatchesSharedBridge", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_newPendingAdmin", + type: "address", + }, + ], + name: "setPendingAdmin", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bool", + name: "_zkPorterIsAvailable", + type: "bool", + }, + ], + name: "setPorterAvailability", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_newPriorityTxMaxGasLimit", + type: "uint256", + }, + ], + name: "setPriorityTxMaxGasLimit", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint128", + name: "_nominator", + type: "uint128", + }, + { + internalType: "uint128", + name: "_denominator", + type: "uint128", + }, + ], + name: "setTokenMultiplier", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_transactionFilterer", + type: "address", + }, + ], + name: "setTransactionFilterer", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_validator", + type: "address", + }, + { + internalType: "bool", + name: "_active", + type: "bool", + }, + ], + name: "setValidator", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "enum PubdataPricingMode", + name: "_validiumMode", + type: "uint8", + }, + ], + name: "setValidiumMode", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_batchNumber", + type: "uint256", + }, + ], + name: "storedBatchHash", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "transferEthToSharedBridge", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "unfreezeDiamond", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_protocolVersion", + type: "uint256", + }, + { + components: [ + { + components: [ + { + internalType: "address", + name: "facet", + type: "address", + }, + { + internalType: "enum Diamond.Action", + name: "action", + type: "uint8", + }, + { + internalType: "bool", + name: "isFreezable", + type: "bool", + }, + { + internalType: "bytes4[]", + name: "selectors", + type: "bytes4[]", + }, + ], + internalType: "struct Diamond.FacetCut[]", + name: "facetCuts", + type: "tuple[]", + }, + { + internalType: "address", + name: "initAddress", + type: "address", + }, + { + internalType: "bytes", + name: "initCalldata", + type: "bytes", + }, + ], + internalType: "struct Diamond.DiamondCutData", + name: "_cutData", + type: "tuple", + }, + ], + name: "upgradeChainFromVersion", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, +]; diff --git a/src/typechain/Il1Bridge.d.ts b/src/typechain/Il1Bridge.d.ts index 5ac8c671..6834942b 100644 --- a/src/typechain/Il1Bridge.d.ts +++ b/src/typechain/Il1Bridge.d.ts @@ -23,19 +23,38 @@ import { FunctionFragment, EventFragment, Result } from "@ethersproject/abi"; interface Il1BridgeInterface extends ethers.utils.Interface { functions: { - "claimFailedDeposit(address,address,bytes32,uint256,uint256,uint16,bytes32[])": FunctionFragment; - "deposit(address,address,uint256,uint256,uint256,address)": FunctionFragment; - "finalizeWithdrawal(uint256,uint256,uint16,bytes,bytes32[])": FunctionFragment; - "isWithdrawalFinalized(uint256,uint256)": FunctionFragment; - "l2Bridge()": FunctionFragment; - "l2TokenAddress(address)": FunctionFragment; + "bridgehub()": FunctionFragment; + "bridgehubConfirmL2Transaction(uint256,bytes32,bytes32)": FunctionFragment; + "bridgehubDeposit(uint256,address,bytes)": FunctionFragment; + "bridgehubDepositBaseToken(uint256,address,address,uint256)": FunctionFragment; + "claimFailedDeposit(uint256,address,address,uint256,bytes32,uint256,uint256,uint16,bytes32[])": FunctionFragment; + "deposit(uint256,address,address,uint256,uint256,uint256,uint256,address)": FunctionFragment; + "depositHappened(uint256,bytes32)": FunctionFragment; + "finalizeWithdrawal(uint256,uint256,uint256,uint16,bytes,bytes32[])": FunctionFragment; + "isWithdrawalFinalizedShared(uint256,uint256,uint256)": FunctionFragment; + "l2BridgeAddress(uint256)": FunctionFragment; }; + encodeFunctionData(functionFragment: "bridgehub", values?: undefined): string; + encodeFunctionData( + functionFragment: "bridgehubConfirmL2Transaction", + values: [BigNumberish, BytesLike, BytesLike] + ): string; + encodeFunctionData( + functionFragment: "bridgehubDeposit", + values: [BigNumberish, string, BytesLike] + ): string; + encodeFunctionData( + functionFragment: "bridgehubDepositBaseToken", + values: [BigNumberish, string, string, BigNumberish] + ): string; encodeFunctionData( functionFragment: "claimFailedDeposit", values: [ + BigNumberish, string, string, + BigNumberish, BytesLike, BigNumberish, BigNumberish, @@ -45,50 +64,97 @@ interface Il1BridgeInterface extends ethers.utils.Interface { ): string; encodeFunctionData( functionFragment: "deposit", - values: [string, string, BigNumberish, BigNumberish, BigNumberish, string] + values: [ + BigNumberish, + string, + string, + BigNumberish, + BigNumberish, + BigNumberish, + BigNumberish, + string + ] + ): string; + encodeFunctionData( + functionFragment: "depositHappened", + values: [BigNumberish, BytesLike] ): string; encodeFunctionData( functionFragment: "finalizeWithdrawal", - values: [BigNumberish, BigNumberish, BigNumberish, BytesLike, BytesLike[]] + values: [ + BigNumberish, + BigNumberish, + BigNumberish, + BigNumberish, + BytesLike, + BytesLike[] + ] ): string; encodeFunctionData( - functionFragment: "isWithdrawalFinalized", - values: [BigNumberish, BigNumberish] + functionFragment: "isWithdrawalFinalizedShared", + values: [BigNumberish, BigNumberish, BigNumberish] ): string; - encodeFunctionData(functionFragment: "l2Bridge", values?: undefined): string; encodeFunctionData( - functionFragment: "l2TokenAddress", - values: [string] + functionFragment: "l2BridgeAddress", + values: [BigNumberish] ): string; + decodeFunctionResult(functionFragment: "bridgehub", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "bridgehubConfirmL2Transaction", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "bridgehubDeposit", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "bridgehubDepositBaseToken", + data: BytesLike + ): Result; decodeFunctionResult( functionFragment: "claimFailedDeposit", data: BytesLike ): Result; decodeFunctionResult(functionFragment: "deposit", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "depositHappened", + data: BytesLike + ): Result; decodeFunctionResult( functionFragment: "finalizeWithdrawal", data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "isWithdrawalFinalized", + functionFragment: "isWithdrawalFinalizedShared", data: BytesLike ): Result; - decodeFunctionResult(functionFragment: "l2Bridge", data: BytesLike): Result; decodeFunctionResult( - functionFragment: "l2TokenAddress", + functionFragment: "l2BridgeAddress", data: BytesLike ): Result; events: { - "ClaimedFailedDeposit(address,address,uint256)": EventFragment; - "DepositInitiated(bytes32,address,address,address,uint256)": EventFragment; - "WithdrawalFinalized(address,address,uint256)": EventFragment; + "BridgehubDepositFinalized(uint256,bytes32,bytes32)": EventFragment; + "BridgehubDepositInitiatedSharedBridge(uint256,bytes32,address,address,address,uint256)": EventFragment; + "ClaimedFailedDepositSharedBridge(uint256,address,address,uint256)": EventFragment; + "DepositInitiatedSharedBridge(uint256,bytes32,address,address,address,uint256)": EventFragment; + "WithdrawalFinalizedSharedBridge(uint256,address,address,uint256)": EventFragment; }; - getEvent(nameOrSignatureOrTopic: "ClaimedFailedDeposit"): EventFragment; - getEvent(nameOrSignatureOrTopic: "DepositInitiated"): EventFragment; - getEvent(nameOrSignatureOrTopic: "WithdrawalFinalized"): EventFragment; + getEvent(nameOrSignatureOrTopic: "BridgehubDepositFinalized"): EventFragment; + getEvent( + nameOrSignatureOrTopic: "BridgehubDepositInitiatedSharedBridge" + ): EventFragment; + getEvent( + nameOrSignatureOrTopic: "ClaimedFailedDepositSharedBridge" + ): EventFragment; + getEvent( + nameOrSignatureOrTopic: "DepositInitiatedSharedBridge" + ): EventFragment; + getEvent( + nameOrSignatureOrTopic: "WithdrawalFinalizedSharedBridge" + ): EventFragment; } export class Il1Bridge extends Contract { @@ -105,9 +171,63 @@ export class Il1Bridge extends Contract { interface: Il1BridgeInterface; functions: { + bridgehub(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + "bridgehub()"(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + bridgehubConfirmL2Transaction( + _chainId: BigNumberish, + _txDataHash: BytesLike, + _txHash: BytesLike, + overrides?: Overrides + ): Promise; + + "bridgehubConfirmL2Transaction(uint256,bytes32,bytes32)"( + _chainId: BigNumberish, + _txDataHash: BytesLike, + _txHash: BytesLike, + overrides?: Overrides + ): Promise; + + bridgehubDeposit( + _chainId: BigNumberish, + _prevMsgSender: string, + _data: BytesLike, + overrides?: PayableOverrides + ): Promise; + + "bridgehubDeposit(uint256,address,bytes)"( + _chainId: BigNumberish, + _prevMsgSender: string, + _data: BytesLike, + overrides?: PayableOverrides + ): Promise; + + bridgehubDepositBaseToken( + _chainId: BigNumberish, + _prevMsgSender: string, + _l1Token: string, + _amount: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + "bridgehubDepositBaseToken(uint256,address,address,uint256)"( + _chainId: BigNumberish, + _prevMsgSender: string, + _l1Token: string, + _amount: BigNumberish, + overrides?: PayableOverrides + ): Promise; + claimFailedDeposit( + _chainId: BigNumberish, _depositSender: string, _l1Token: string, + _amount: BigNumberish, _l2TxHash: BytesLike, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, @@ -116,9 +236,11 @@ export class Il1Bridge extends Contract { overrides?: Overrides ): Promise; - "claimFailedDeposit(address,address,bytes32,uint256,uint256,uint16,bytes32[])"( + "claimFailedDeposit(uint256,address,address,uint256,bytes32,uint256,uint256,uint16,bytes32[])"( + _chainId: BigNumberish, _depositSender: string, _l1Token: string, + _amount: BigNumberish, _l2TxHash: BytesLike, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, @@ -128,8 +250,10 @@ export class Il1Bridge extends Contract { ): Promise; deposit( + _chainId: BigNumberish, _l2Receiver: string, _l1Token: string, + _mintValue: BigNumberish, _amount: BigNumberish, _l2TxGasLimit: BigNumberish, _l2TxGasPerPubdataByte: BigNumberish, @@ -137,9 +261,11 @@ export class Il1Bridge extends Contract { overrides?: PayableOverrides ): Promise; - "deposit(address,address,uint256,uint256,uint256,address)"( + "deposit(uint256,address,address,uint256,uint256,uint256,uint256,address)"( + _chainId: BigNumberish, _l2Receiver: string, _l1Token: string, + _mintValue: BigNumberish, _amount: BigNumberish, _l2TxGasLimit: BigNumberish, _l2TxGasPerPubdataByte: BigNumberish, @@ -147,7 +273,24 @@ export class Il1Bridge extends Contract { overrides?: PayableOverrides ): Promise; + depositHappened( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + overrides?: CallOverrides + ): Promise<{ + 0: string; + }>; + + "depositHappened(uint256,bytes32)"( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + overrides?: CallOverrides + ): Promise<{ + 0: string; + }>; + finalizeWithdrawal( + _chainId: BigNumberish, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, _l2TxNumberInBatch: BigNumberish, @@ -156,7 +299,8 @@ export class Il1Bridge extends Contract { overrides?: Overrides ): Promise; - "finalizeWithdrawal(uint256,uint256,uint16,bytes,bytes32[])"( + "finalizeWithdrawal(uint256,uint256,uint256,uint16,bytes,bytes32[])"( + _chainId: BigNumberish, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, _l2TxNumberInBatch: BigNumberish, @@ -165,7 +309,8 @@ export class Il1Bridge extends Contract { overrides?: Overrides ): Promise; - isWithdrawalFinalized( + isWithdrawalFinalizedShared( + _chainId: BigNumberish, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, overrides?: CallOverrides @@ -173,7 +318,8 @@ export class Il1Bridge extends Contract { 0: boolean; }>; - "isWithdrawalFinalized(uint256,uint256)"( + "isWithdrawalFinalizedShared(uint256,uint256,uint256)"( + _chainId: BigNumberish, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, overrides?: CallOverrides @@ -181,32 +327,74 @@ export class Il1Bridge extends Contract { 0: boolean; }>; - l2Bridge(overrides?: CallOverrides): Promise<{ - 0: string; - }>; - - "l2Bridge()"(overrides?: CallOverrides): Promise<{ - 0: string; - }>; - - l2TokenAddress( - _l1Token: string, + l2BridgeAddress( + _chainId: BigNumberish, overrides?: CallOverrides ): Promise<{ 0: string; }>; - "l2TokenAddress(address)"( - _l1Token: string, + "l2BridgeAddress(uint256)"( + _chainId: BigNumberish, overrides?: CallOverrides ): Promise<{ 0: string; }>; }; + bridgehub(overrides?: CallOverrides): Promise; + + "bridgehub()"(overrides?: CallOverrides): Promise; + + bridgehubConfirmL2Transaction( + _chainId: BigNumberish, + _txDataHash: BytesLike, + _txHash: BytesLike, + overrides?: Overrides + ): Promise; + + "bridgehubConfirmL2Transaction(uint256,bytes32,bytes32)"( + _chainId: BigNumberish, + _txDataHash: BytesLike, + _txHash: BytesLike, + overrides?: Overrides + ): Promise; + + bridgehubDeposit( + _chainId: BigNumberish, + _prevMsgSender: string, + _data: BytesLike, + overrides?: PayableOverrides + ): Promise; + + "bridgehubDeposit(uint256,address,bytes)"( + _chainId: BigNumberish, + _prevMsgSender: string, + _data: BytesLike, + overrides?: PayableOverrides + ): Promise; + + bridgehubDepositBaseToken( + _chainId: BigNumberish, + _prevMsgSender: string, + _l1Token: string, + _amount: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + "bridgehubDepositBaseToken(uint256,address,address,uint256)"( + _chainId: BigNumberish, + _prevMsgSender: string, + _l1Token: string, + _amount: BigNumberish, + overrides?: PayableOverrides + ): Promise; + claimFailedDeposit( + _chainId: BigNumberish, _depositSender: string, _l1Token: string, + _amount: BigNumberish, _l2TxHash: BytesLike, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, @@ -215,9 +403,11 @@ export class Il1Bridge extends Contract { overrides?: Overrides ): Promise; - "claimFailedDeposit(address,address,bytes32,uint256,uint256,uint16,bytes32[])"( + "claimFailedDeposit(uint256,address,address,uint256,bytes32,uint256,uint256,uint16,bytes32[])"( + _chainId: BigNumberish, _depositSender: string, _l1Token: string, + _amount: BigNumberish, _l2TxHash: BytesLike, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, @@ -227,8 +417,10 @@ export class Il1Bridge extends Contract { ): Promise; deposit( + _chainId: BigNumberish, _l2Receiver: string, _l1Token: string, + _mintValue: BigNumberish, _amount: BigNumberish, _l2TxGasLimit: BigNumberish, _l2TxGasPerPubdataByte: BigNumberish, @@ -236,9 +428,11 @@ export class Il1Bridge extends Contract { overrides?: PayableOverrides ): Promise; - "deposit(address,address,uint256,uint256,uint256,address)"( + "deposit(uint256,address,address,uint256,uint256,uint256,uint256,address)"( + _chainId: BigNumberish, _l2Receiver: string, _l1Token: string, + _mintValue: BigNumberish, _amount: BigNumberish, _l2TxGasLimit: BigNumberish, _l2TxGasPerPubdataByte: BigNumberish, @@ -246,7 +440,20 @@ export class Il1Bridge extends Contract { overrides?: PayableOverrides ): Promise; + depositHappened( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + overrides?: CallOverrides + ): Promise; + + "depositHappened(uint256,bytes32)"( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + overrides?: CallOverrides + ): Promise; + finalizeWithdrawal( + _chainId: BigNumberish, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, _l2TxNumberInBatch: BigNumberish, @@ -255,7 +462,8 @@ export class Il1Bridge extends Contract { overrides?: Overrides ): Promise; - "finalizeWithdrawal(uint256,uint256,uint16,bytes,bytes32[])"( + "finalizeWithdrawal(uint256,uint256,uint256,uint16,bytes,bytes32[])"( + _chainId: BigNumberish, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, _l2TxNumberInBatch: BigNumberish, @@ -264,33 +472,106 @@ export class Il1Bridge extends Contract { overrides?: Overrides ): Promise; - isWithdrawalFinalized( + isWithdrawalFinalizedShared( + _chainId: BigNumberish, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, overrides?: CallOverrides ): Promise; - "isWithdrawalFinalized(uint256,uint256)"( + "isWithdrawalFinalizedShared(uint256,uint256,uint256)"( + _chainId: BigNumberish, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, overrides?: CallOverrides ): Promise; - l2Bridge(overrides?: CallOverrides): Promise; - - "l2Bridge()"(overrides?: CallOverrides): Promise; - - l2TokenAddress(_l1Token: string, overrides?: CallOverrides): Promise; + l2BridgeAddress( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; - "l2TokenAddress(address)"( - _l1Token: string, + "l2BridgeAddress(uint256)"( + _chainId: BigNumberish, overrides?: CallOverrides ): Promise; callStatic: { + bridgehub(overrides?: CallOverrides): Promise; + + "bridgehub()"(overrides?: CallOverrides): Promise; + + bridgehubConfirmL2Transaction( + _chainId: BigNumberish, + _txDataHash: BytesLike, + _txHash: BytesLike, + overrides?: CallOverrides + ): Promise; + + "bridgehubConfirmL2Transaction(uint256,bytes32,bytes32)"( + _chainId: BigNumberish, + _txDataHash: BytesLike, + _txHash: BytesLike, + overrides?: CallOverrides + ): Promise; + + bridgehubDeposit( + _chainId: BigNumberish, + _prevMsgSender: string, + _data: BytesLike, + overrides?: CallOverrides + ): Promise<{ + magicValue: string; + l2Contract: string; + l2Calldata: string; + factoryDeps: string[]; + txDataHash: string; + 0: string; + 1: string; + 2: string; + 3: string[]; + 4: string; + }>; + + "bridgehubDeposit(uint256,address,bytes)"( + _chainId: BigNumberish, + _prevMsgSender: string, + _data: BytesLike, + overrides?: CallOverrides + ): Promise<{ + magicValue: string; + l2Contract: string; + l2Calldata: string; + factoryDeps: string[]; + txDataHash: string; + 0: string; + 1: string; + 2: string; + 3: string[]; + 4: string; + }>; + + bridgehubDepositBaseToken( + _chainId: BigNumberish, + _prevMsgSender: string, + _l1Token: string, + _amount: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "bridgehubDepositBaseToken(uint256,address,address,uint256)"( + _chainId: BigNumberish, + _prevMsgSender: string, + _l1Token: string, + _amount: BigNumberish, + overrides?: CallOverrides + ): Promise; + claimFailedDeposit( + _chainId: BigNumberish, _depositSender: string, _l1Token: string, + _amount: BigNumberish, _l2TxHash: BytesLike, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, @@ -299,9 +580,11 @@ export class Il1Bridge extends Contract { overrides?: CallOverrides ): Promise; - "claimFailedDeposit(address,address,bytes32,uint256,uint256,uint16,bytes32[])"( + "claimFailedDeposit(uint256,address,address,uint256,bytes32,uint256,uint256,uint16,bytes32[])"( + _chainId: BigNumberish, _depositSender: string, _l1Token: string, + _amount: BigNumberish, _l2TxHash: BytesLike, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, @@ -311,8 +594,10 @@ export class Il1Bridge extends Contract { ): Promise; deposit( + _chainId: BigNumberish, _l2Receiver: string, _l1Token: string, + _mintValue: BigNumberish, _amount: BigNumberish, _l2TxGasLimit: BigNumberish, _l2TxGasPerPubdataByte: BigNumberish, @@ -320,9 +605,11 @@ export class Il1Bridge extends Contract { overrides?: CallOverrides ): Promise; - "deposit(address,address,uint256,uint256,uint256,address)"( + "deposit(uint256,address,address,uint256,uint256,uint256,uint256,address)"( + _chainId: BigNumberish, _l2Receiver: string, _l1Token: string, + _mintValue: BigNumberish, _amount: BigNumberish, _l2TxGasLimit: BigNumberish, _l2TxGasPerPubdataByte: BigNumberish, @@ -330,7 +617,20 @@ export class Il1Bridge extends Contract { overrides?: CallOverrides ): Promise; + depositHappened( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + overrides?: CallOverrides + ): Promise; + + "depositHappened(uint256,bytes32)"( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + overrides?: CallOverrides + ): Promise; + finalizeWithdrawal( + _chainId: BigNumberish, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, _l2TxNumberInBatch: BigNumberish, @@ -339,7 +639,8 @@ export class Il1Bridge extends Contract { overrides?: CallOverrides ): Promise; - "finalizeWithdrawal(uint256,uint256,uint16,bytes,bytes32[])"( + "finalizeWithdrawal(uint256,uint256,uint256,uint16,bytes,bytes32[])"( + _chainId: BigNumberish, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, _l2TxNumberInBatch: BigNumberish, @@ -348,49 +649,65 @@ export class Il1Bridge extends Contract { overrides?: CallOverrides ): Promise; - isWithdrawalFinalized( + isWithdrawalFinalizedShared( + _chainId: BigNumberish, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, overrides?: CallOverrides ): Promise; - "isWithdrawalFinalized(uint256,uint256)"( + "isWithdrawalFinalizedShared(uint256,uint256,uint256)"( + _chainId: BigNumberish, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, overrides?: CallOverrides ): Promise; - l2Bridge(overrides?: CallOverrides): Promise; - - "l2Bridge()"(overrides?: CallOverrides): Promise; - - l2TokenAddress( - _l1Token: string, + l2BridgeAddress( + _chainId: BigNumberish, overrides?: CallOverrides ): Promise; - "l2TokenAddress(address)"( - _l1Token: string, + "l2BridgeAddress(uint256)"( + _chainId: BigNumberish, overrides?: CallOverrides ): Promise; }; filters: { - ClaimedFailedDeposit( + BridgehubDepositFinalized( + chainId: BigNumberish | null, + txDataHash: BytesLike | null, + l2DepositTxHash: BytesLike | null + ): EventFilter; + + BridgehubDepositInitiatedSharedBridge( + chainId: BigNumberish | null, + txDataHash: BytesLike | null, + from: string | null, + to: null, + l1Token: null, + amount: null + ): EventFilter; + + ClaimedFailedDepositSharedBridge( + chainId: BigNumberish | null, to: string | null, l1Token: string | null, amount: null ): EventFilter; - DepositInitiated( + DepositInitiatedSharedBridge( + chainId: BigNumberish | null, l2DepositTxHash: BytesLike | null, from: string | null, - to: string | null, + to: null, l1Token: null, amount: null ): EventFilter; - WithdrawalFinalized( + WithdrawalFinalizedSharedBridge( + chainId: BigNumberish | null, to: string | null, l1Token: string | null, amount: null @@ -398,9 +715,59 @@ export class Il1Bridge extends Contract { }; estimateGas: { + bridgehub(overrides?: CallOverrides): Promise; + + "bridgehub()"(overrides?: CallOverrides): Promise; + + bridgehubConfirmL2Transaction( + _chainId: BigNumberish, + _txDataHash: BytesLike, + _txHash: BytesLike, + overrides?: Overrides + ): Promise; + + "bridgehubConfirmL2Transaction(uint256,bytes32,bytes32)"( + _chainId: BigNumberish, + _txDataHash: BytesLike, + _txHash: BytesLike, + overrides?: Overrides + ): Promise; + + bridgehubDeposit( + _chainId: BigNumberish, + _prevMsgSender: string, + _data: BytesLike, + overrides?: PayableOverrides + ): Promise; + + "bridgehubDeposit(uint256,address,bytes)"( + _chainId: BigNumberish, + _prevMsgSender: string, + _data: BytesLike, + overrides?: PayableOverrides + ): Promise; + + bridgehubDepositBaseToken( + _chainId: BigNumberish, + _prevMsgSender: string, + _l1Token: string, + _amount: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + "bridgehubDepositBaseToken(uint256,address,address,uint256)"( + _chainId: BigNumberish, + _prevMsgSender: string, + _l1Token: string, + _amount: BigNumberish, + overrides?: PayableOverrides + ): Promise; + claimFailedDeposit( + _chainId: BigNumberish, _depositSender: string, _l1Token: string, + _amount: BigNumberish, _l2TxHash: BytesLike, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, @@ -409,9 +776,11 @@ export class Il1Bridge extends Contract { overrides?: Overrides ): Promise; - "claimFailedDeposit(address,address,bytes32,uint256,uint256,uint16,bytes32[])"( + "claimFailedDeposit(uint256,address,address,uint256,bytes32,uint256,uint256,uint16,bytes32[])"( + _chainId: BigNumberish, _depositSender: string, _l1Token: string, + _amount: BigNumberish, _l2TxHash: BytesLike, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, @@ -421,8 +790,10 @@ export class Il1Bridge extends Contract { ): Promise; deposit( + _chainId: BigNumberish, _l2Receiver: string, _l1Token: string, + _mintValue: BigNumberish, _amount: BigNumberish, _l2TxGasLimit: BigNumberish, _l2TxGasPerPubdataByte: BigNumberish, @@ -430,9 +801,11 @@ export class Il1Bridge extends Contract { overrides?: PayableOverrides ): Promise; - "deposit(address,address,uint256,uint256,uint256,address)"( + "deposit(uint256,address,address,uint256,uint256,uint256,uint256,address)"( + _chainId: BigNumberish, _l2Receiver: string, _l1Token: string, + _mintValue: BigNumberish, _amount: BigNumberish, _l2TxGasLimit: BigNumberish, _l2TxGasPerPubdataByte: BigNumberish, @@ -440,7 +813,20 @@ export class Il1Bridge extends Contract { overrides?: PayableOverrides ): Promise; + depositHappened( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + overrides?: CallOverrides + ): Promise; + + "depositHappened(uint256,bytes32)"( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + overrides?: CallOverrides + ): Promise; + finalizeWithdrawal( + _chainId: BigNumberish, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, _l2TxNumberInBatch: BigNumberish, @@ -449,7 +835,8 @@ export class Il1Bridge extends Contract { overrides?: Overrides ): Promise; - "finalizeWithdrawal(uint256,uint256,uint16,bytes,bytes32[])"( + "finalizeWithdrawal(uint256,uint256,uint256,uint16,bytes,bytes32[])"( + _chainId: BigNumberish, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, _l2TxNumberInBatch: BigNumberish, @@ -458,37 +845,85 @@ export class Il1Bridge extends Contract { overrides?: Overrides ): Promise; - isWithdrawalFinalized( + isWithdrawalFinalizedShared( + _chainId: BigNumberish, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, overrides?: CallOverrides ): Promise; - "isWithdrawalFinalized(uint256,uint256)"( + "isWithdrawalFinalizedShared(uint256,uint256,uint256)"( + _chainId: BigNumberish, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, overrides?: CallOverrides ): Promise; - l2Bridge(overrides?: CallOverrides): Promise; - - "l2Bridge()"(overrides?: CallOverrides): Promise; - - l2TokenAddress( - _l1Token: string, + l2BridgeAddress( + _chainId: BigNumberish, overrides?: CallOverrides ): Promise; - "l2TokenAddress(address)"( - _l1Token: string, + "l2BridgeAddress(uint256)"( + _chainId: BigNumberish, overrides?: CallOverrides ): Promise; }; populateTransaction: { + bridgehub(overrides?: CallOverrides): Promise; + + "bridgehub()"(overrides?: CallOverrides): Promise; + + bridgehubConfirmL2Transaction( + _chainId: BigNumberish, + _txDataHash: BytesLike, + _txHash: BytesLike, + overrides?: Overrides + ): Promise; + + "bridgehubConfirmL2Transaction(uint256,bytes32,bytes32)"( + _chainId: BigNumberish, + _txDataHash: BytesLike, + _txHash: BytesLike, + overrides?: Overrides + ): Promise; + + bridgehubDeposit( + _chainId: BigNumberish, + _prevMsgSender: string, + _data: BytesLike, + overrides?: PayableOverrides + ): Promise; + + "bridgehubDeposit(uint256,address,bytes)"( + _chainId: BigNumberish, + _prevMsgSender: string, + _data: BytesLike, + overrides?: PayableOverrides + ): Promise; + + bridgehubDepositBaseToken( + _chainId: BigNumberish, + _prevMsgSender: string, + _l1Token: string, + _amount: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + "bridgehubDepositBaseToken(uint256,address,address,uint256)"( + _chainId: BigNumberish, + _prevMsgSender: string, + _l1Token: string, + _amount: BigNumberish, + overrides?: PayableOverrides + ): Promise; + claimFailedDeposit( + _chainId: BigNumberish, _depositSender: string, _l1Token: string, + _amount: BigNumberish, _l2TxHash: BytesLike, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, @@ -497,9 +932,11 @@ export class Il1Bridge extends Contract { overrides?: Overrides ): Promise; - "claimFailedDeposit(address,address,bytes32,uint256,uint256,uint16,bytes32[])"( + "claimFailedDeposit(uint256,address,address,uint256,bytes32,uint256,uint256,uint16,bytes32[])"( + _chainId: BigNumberish, _depositSender: string, _l1Token: string, + _amount: BigNumberish, _l2TxHash: BytesLike, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, @@ -509,8 +946,10 @@ export class Il1Bridge extends Contract { ): Promise; deposit( + _chainId: BigNumberish, _l2Receiver: string, _l1Token: string, + _mintValue: BigNumberish, _amount: BigNumberish, _l2TxGasLimit: BigNumberish, _l2TxGasPerPubdataByte: BigNumberish, @@ -518,9 +957,11 @@ export class Il1Bridge extends Contract { overrides?: PayableOverrides ): Promise; - "deposit(address,address,uint256,uint256,uint256,address)"( + "deposit(uint256,address,address,uint256,uint256,uint256,uint256,address)"( + _chainId: BigNumberish, _l2Receiver: string, _l1Token: string, + _mintValue: BigNumberish, _amount: BigNumberish, _l2TxGasLimit: BigNumberish, _l2TxGasPerPubdataByte: BigNumberish, @@ -528,7 +969,20 @@ export class Il1Bridge extends Contract { overrides?: PayableOverrides ): Promise; + depositHappened( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + overrides?: CallOverrides + ): Promise; + + "depositHappened(uint256,bytes32)"( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + overrides?: CallOverrides + ): Promise; + finalizeWithdrawal( + _chainId: BigNumberish, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, _l2TxNumberInBatch: BigNumberish, @@ -537,7 +991,8 @@ export class Il1Bridge extends Contract { overrides?: Overrides ): Promise; - "finalizeWithdrawal(uint256,uint256,uint16,bytes,bytes32[])"( + "finalizeWithdrawal(uint256,uint256,uint256,uint16,bytes,bytes32[])"( + _chainId: BigNumberish, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, _l2TxNumberInBatch: BigNumberish, @@ -546,29 +1001,27 @@ export class Il1Bridge extends Contract { overrides?: Overrides ): Promise; - isWithdrawalFinalized( + isWithdrawalFinalizedShared( + _chainId: BigNumberish, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, overrides?: CallOverrides ): Promise; - "isWithdrawalFinalized(uint256,uint256)"( + "isWithdrawalFinalizedShared(uint256,uint256,uint256)"( + _chainId: BigNumberish, _l2BatchNumber: BigNumberish, _l2MessageIndex: BigNumberish, overrides?: CallOverrides ): Promise; - l2Bridge(overrides?: CallOverrides): Promise; - - "l2Bridge()"(overrides?: CallOverrides): Promise; - - l2TokenAddress( - _l1Token: string, + l2BridgeAddress( + _chainId: BigNumberish, overrides?: CallOverrides ): Promise; - "l2TokenAddress(address)"( - _l1Token: string, + "l2BridgeAddress(uint256)"( + _chainId: BigNumberish, overrides?: CallOverrides ): Promise; }; diff --git a/src/typechain/Il1BridgeFactory.ts b/src/typechain/Il1BridgeFactory.ts index c6afb2d2..e0f2b9fc 100644 --- a/src/typechain/Il1BridgeFactory.ts +++ b/src/typechain/Il1BridgeFactory.ts @@ -20,6 +20,80 @@ const _abi = [ { anonymous: false, inputs: [ + { + indexed: true, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + indexed: true, + internalType: "bytes32", + name: "txDataHash", + type: "bytes32", + }, + { + indexed: true, + internalType: "bytes32", + name: "l2DepositTxHash", + type: "bytes32", + }, + ], + name: "BridgehubDepositFinalized", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + indexed: true, + internalType: "bytes32", + name: "txDataHash", + type: "bytes32", + }, + { + indexed: true, + internalType: "address", + name: "from", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "to", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "l1Token", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "BridgehubDepositInitiatedSharedBridge", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, { indexed: true, internalType: "address", @@ -39,12 +113,18 @@ const _abi = [ type: "uint256", }, ], - name: "ClaimedFailedDeposit", + name: "ClaimedFailedDepositSharedBridge", type: "event", }, { anonymous: false, inputs: [ + { + indexed: true, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, { indexed: true, internalType: "bytes32", @@ -58,7 +138,7 @@ const _abi = [ type: "address", }, { - indexed: true, + indexed: false, internalType: "address", name: "to", type: "address", @@ -76,12 +156,18 @@ const _abi = [ type: "uint256", }, ], - name: "DepositInitiated", + name: "DepositInitiatedSharedBridge", type: "event", }, { anonymous: false, inputs: [ + { + indexed: true, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, { indexed: true, internalType: "address", @@ -101,11 +187,136 @@ const _abi = [ type: "uint256", }, ], - name: "WithdrawalFinalized", + name: "WithdrawalFinalizedSharedBridge", type: "event", }, + { + inputs: [], + name: "bridgehub", + outputs: [ + { + internalType: "contract IBridgehub", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "bytes32", + name: "_txDataHash", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "_txHash", + type: "bytes32", + }, + ], + name: "bridgehubConfirmL2Transaction", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "address", + name: "_prevMsgSender", + type: "address", + }, + { + internalType: "bytes", + name: "_data", + type: "bytes", + }, + ], + name: "bridgehubDeposit", + outputs: [ + { + components: [ + { + internalType: "bytes32", + name: "magicValue", + type: "bytes32", + }, + { + internalType: "address", + name: "l2Contract", + type: "address", + }, + { + internalType: "bytes", + name: "l2Calldata", + type: "bytes", + }, + { + internalType: "bytes[]", + name: "factoryDeps", + type: "bytes[]", + }, + { + internalType: "bytes32", + name: "txDataHash", + type: "bytes32", + }, + ], + internalType: "struct L2TransactionRequestTwoBridgesInner", + name: "request", + type: "tuple", + }, + ], + stateMutability: "payable", + type: "function", + }, { inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "address", + name: "_prevMsgSender", + type: "address", + }, + { + internalType: "address", + name: "_l1Token", + type: "address", + }, + { + internalType: "uint256", + name: "_amount", + type: "uint256", + }, + ], + name: "bridgehubDepositBaseToken", + outputs: [], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, { internalType: "address", name: "_depositSender", @@ -116,6 +327,11 @@ const _abi = [ name: "_l1Token", type: "address", }, + { + internalType: "uint256", + name: "_amount", + type: "uint256", + }, { internalType: "bytes32", name: "_l2TxHash", @@ -149,6 +365,11 @@ const _abi = [ }, { inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, { internalType: "address", name: "_l2Receiver", @@ -159,6 +380,11 @@ const _abi = [ name: "_l1Token", type: "address", }, + { + internalType: "uint256", + name: "_mintValue", + type: "uint256", + }, { internalType: "uint256", name: "_amount", @@ -193,6 +419,35 @@ const _abi = [ }, { inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "bytes32", + name: "_l2TxHash", + type: "bytes32", + }, + ], + name: "depositHappened", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, { internalType: "uint256", name: "_l2BatchNumber", @@ -226,6 +481,11 @@ const _abi = [ }, { inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, { internalType: "uint256", name: "_l2BatchNumber", @@ -237,7 +497,7 @@ const _abi = [ type: "uint256", }, ], - name: "isWithdrawalFinalized", + name: "isWithdrawalFinalizedShared", outputs: [ { internalType: "bool", @@ -248,28 +508,15 @@ const _abi = [ stateMutability: "view", type: "function", }, - { - inputs: [], - name: "l2Bridge", - outputs: [ - { - internalType: "address", - name: "", - type: "address", - }, - ], - stateMutability: "view", - type: "function", - }, { inputs: [ { - internalType: "address", - name: "_l1Token", - type: "address", + internalType: "uint256", + name: "_chainId", + type: "uint256", }, ], - name: "l2TokenAddress", + name: "l2BridgeAddress", outputs: [ { internalType: "address", diff --git a/src/typechain/Il1Erc20Bridge.d.ts b/src/typechain/Il1Erc20Bridge.d.ts new file mode 100644 index 00000000..4d8b8f16 --- /dev/null +++ b/src/typechain/Il1Erc20Bridge.d.ts @@ -0,0 +1,784 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { + ethers, + EventFilter, + Signer, + BigNumber, + BigNumberish, + PopulatedTransaction, +} from "ethers"; +import { + Contract, + ContractTransaction, + Overrides, + PayableOverrides, + CallOverrides, +} from "@ethersproject/contracts"; +import { BytesLike } from "@ethersproject/bytes"; +import { Listener, Provider } from "@ethersproject/providers"; +import { FunctionFragment, EventFragment, Result } from "@ethersproject/abi"; + +interface Il1Erc20BridgeInterface extends ethers.utils.Interface { + functions: { + "claimFailedDeposit(address,address,bytes32,uint256,uint256,uint16,bytes32[])": FunctionFragment; + "deposit(address,address,uint256,uint256,uint256)": FunctionFragment; + "depositAmount(address,address,bytes32)": FunctionFragment; + "finalizeWithdrawal(uint256,uint256,uint16,bytes,bytes32[])": FunctionFragment; + "isWithdrawalFinalized(uint256,uint256)": FunctionFragment; + "l2Bridge()": FunctionFragment; + "l2TokenAddress(address)": FunctionFragment; + "l2TokenBeacon()": FunctionFragment; + "sharedBridge()": FunctionFragment; + "transferTokenToSharedBridge(address,uint256)": FunctionFragment; + }; + + encodeFunctionData( + functionFragment: "claimFailedDeposit", + values: [ + string, + string, + BytesLike, + BigNumberish, + BigNumberish, + BigNumberish, + BytesLike[] + ] + ): string; + encodeFunctionData( + functionFragment: "deposit", + values: [string, string, BigNumberish, BigNumberish, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "depositAmount", + values: [string, string, BytesLike] + ): string; + encodeFunctionData( + functionFragment: "finalizeWithdrawal", + values: [BigNumberish, BigNumberish, BigNumberish, BytesLike, BytesLike[]] + ): string; + encodeFunctionData( + functionFragment: "isWithdrawalFinalized", + values: [BigNumberish, BigNumberish] + ): string; + encodeFunctionData(functionFragment: "l2Bridge", values?: undefined): string; + encodeFunctionData( + functionFragment: "l2TokenAddress", + values: [string] + ): string; + encodeFunctionData( + functionFragment: "l2TokenBeacon", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "sharedBridge", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "transferTokenToSharedBridge", + values: [string, BigNumberish] + ): string; + + decodeFunctionResult( + functionFragment: "claimFailedDeposit", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "deposit", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "depositAmount", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "finalizeWithdrawal", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "isWithdrawalFinalized", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "l2Bridge", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "l2TokenAddress", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "l2TokenBeacon", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "sharedBridge", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "transferTokenToSharedBridge", + data: BytesLike + ): Result; + + events: { + "ClaimedFailedDeposit(address,address,uint256)": EventFragment; + "DepositInitiated(bytes32,address,address,address,uint256)": EventFragment; + "WithdrawalFinalized(address,address,uint256)": EventFragment; + }; + + getEvent(nameOrSignatureOrTopic: "ClaimedFailedDeposit"): EventFragment; + getEvent(nameOrSignatureOrTopic: "DepositInitiated"): EventFragment; + getEvent(nameOrSignatureOrTopic: "WithdrawalFinalized"): EventFragment; +} + +export class Il1Erc20Bridge extends Contract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + on(event: EventFilter | string, listener: Listener): this; + once(event: EventFilter | string, listener: Listener): this; + addListener(eventName: EventFilter | string, listener: Listener): this; + removeAllListeners(eventName: EventFilter | string): this; + removeListener(eventName: any, listener: Listener): this; + + interface: Il1Erc20BridgeInterface; + + functions: { + claimFailedDeposit( + _depositSender: string, + _l1Token: string, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "claimFailedDeposit(address,address,bytes32,uint256,uint256,uint16,bytes32[])"( + _depositSender: string, + _l1Token: string, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "deposit(address,address,uint256,uint256,uint256)"( + _l2Receiver: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxGasLimit: BigNumberish, + _l2TxGasPerPubdataByte: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + "deposit(address,address,uint256,uint256,uint256,address)"( + _l2Receiver: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxGasLimit: BigNumberish, + _l2TxGasPerPubdataByte: BigNumberish, + _refundRecipient: string, + overrides?: PayableOverrides + ): Promise; + + depositAmount( + _account: string, + _l1Token: string, + _depositL2TxHash: BytesLike, + overrides?: Overrides + ): Promise; + + "depositAmount(address,address,bytes32)"( + _account: string, + _l1Token: string, + _depositL2TxHash: BytesLike, + overrides?: Overrides + ): Promise; + + finalizeWithdrawal( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "finalizeWithdrawal(uint256,uint256,uint16,bytes,bytes32[])"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + isWithdrawalFinalized( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + "isWithdrawalFinalized(uint256,uint256)"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + l2Bridge(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + "l2Bridge()"(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + l2TokenAddress( + _l1Token: string, + overrides?: CallOverrides + ): Promise<{ + 0: string; + }>; + + "l2TokenAddress(address)"( + _l1Token: string, + overrides?: CallOverrides + ): Promise<{ + 0: string; + }>; + + l2TokenBeacon(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + "l2TokenBeacon()"(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + sharedBridge(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + "sharedBridge()"(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + transferTokenToSharedBridge( + _token: string, + _amount: BigNumberish, + overrides?: Overrides + ): Promise; + + "transferTokenToSharedBridge(address,uint256)"( + _token: string, + _amount: BigNumberish, + overrides?: Overrides + ): Promise; + }; + + claimFailedDeposit( + _depositSender: string, + _l1Token: string, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "claimFailedDeposit(address,address,bytes32,uint256,uint256,uint16,bytes32[])"( + _depositSender: string, + _l1Token: string, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "deposit(address,address,uint256,uint256,uint256)"( + _l2Receiver: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxGasLimit: BigNumberish, + _l2TxGasPerPubdataByte: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + "deposit(address,address,uint256,uint256,uint256,address)"( + _l2Receiver: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxGasLimit: BigNumberish, + _l2TxGasPerPubdataByte: BigNumberish, + _refundRecipient: string, + overrides?: PayableOverrides + ): Promise; + + depositAmount( + _account: string, + _l1Token: string, + _depositL2TxHash: BytesLike, + overrides?: Overrides + ): Promise; + + "depositAmount(address,address,bytes32)"( + _account: string, + _l1Token: string, + _depositL2TxHash: BytesLike, + overrides?: Overrides + ): Promise; + + finalizeWithdrawal( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "finalizeWithdrawal(uint256,uint256,uint16,bytes,bytes32[])"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + isWithdrawalFinalized( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "isWithdrawalFinalized(uint256,uint256)"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + l2Bridge(overrides?: CallOverrides): Promise; + + "l2Bridge()"(overrides?: CallOverrides): Promise; + + l2TokenAddress(_l1Token: string, overrides?: CallOverrides): Promise; + + "l2TokenAddress(address)"( + _l1Token: string, + overrides?: CallOverrides + ): Promise; + + l2TokenBeacon(overrides?: CallOverrides): Promise; + + "l2TokenBeacon()"(overrides?: CallOverrides): Promise; + + sharedBridge(overrides?: CallOverrides): Promise; + + "sharedBridge()"(overrides?: CallOverrides): Promise; + + transferTokenToSharedBridge( + _token: string, + _amount: BigNumberish, + overrides?: Overrides + ): Promise; + + "transferTokenToSharedBridge(address,uint256)"( + _token: string, + _amount: BigNumberish, + overrides?: Overrides + ): Promise; + + callStatic: { + claimFailedDeposit( + _depositSender: string, + _l1Token: string, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + "claimFailedDeposit(address,address,bytes32,uint256,uint256,uint16,bytes32[])"( + _depositSender: string, + _l1Token: string, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + "deposit(address,address,uint256,uint256,uint256)"( + _l2Receiver: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxGasLimit: BigNumberish, + _l2TxGasPerPubdataByte: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "deposit(address,address,uint256,uint256,uint256,address)"( + _l2Receiver: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxGasLimit: BigNumberish, + _l2TxGasPerPubdataByte: BigNumberish, + _refundRecipient: string, + overrides?: CallOverrides + ): Promise; + + depositAmount( + _account: string, + _l1Token: string, + _depositL2TxHash: BytesLike, + overrides?: CallOverrides + ): Promise; + + "depositAmount(address,address,bytes32)"( + _account: string, + _l1Token: string, + _depositL2TxHash: BytesLike, + overrides?: CallOverrides + ): Promise; + + finalizeWithdrawal( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + "finalizeWithdrawal(uint256,uint256,uint16,bytes,bytes32[])"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + isWithdrawalFinalized( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "isWithdrawalFinalized(uint256,uint256)"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + l2Bridge(overrides?: CallOverrides): Promise; + + "l2Bridge()"(overrides?: CallOverrides): Promise; + + l2TokenAddress( + _l1Token: string, + overrides?: CallOverrides + ): Promise; + + "l2TokenAddress(address)"( + _l1Token: string, + overrides?: CallOverrides + ): Promise; + + l2TokenBeacon(overrides?: CallOverrides): Promise; + + "l2TokenBeacon()"(overrides?: CallOverrides): Promise; + + sharedBridge(overrides?: CallOverrides): Promise; + + "sharedBridge()"(overrides?: CallOverrides): Promise; + + transferTokenToSharedBridge( + _token: string, + _amount: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "transferTokenToSharedBridge(address,uint256)"( + _token: string, + _amount: BigNumberish, + overrides?: CallOverrides + ): Promise; + }; + + filters: { + ClaimedFailedDeposit( + to: string | null, + l1Token: string | null, + amount: null + ): EventFilter; + + DepositInitiated( + l2DepositTxHash: BytesLike | null, + from: string | null, + to: string | null, + l1Token: null, + amount: null + ): EventFilter; + + WithdrawalFinalized( + to: string | null, + l1Token: string | null, + amount: null + ): EventFilter; + }; + + estimateGas: { + claimFailedDeposit( + _depositSender: string, + _l1Token: string, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "claimFailedDeposit(address,address,bytes32,uint256,uint256,uint16,bytes32[])"( + _depositSender: string, + _l1Token: string, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "deposit(address,address,uint256,uint256,uint256)"( + _l2Receiver: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxGasLimit: BigNumberish, + _l2TxGasPerPubdataByte: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + "deposit(address,address,uint256,uint256,uint256,address)"( + _l2Receiver: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxGasLimit: BigNumberish, + _l2TxGasPerPubdataByte: BigNumberish, + _refundRecipient: string, + overrides?: PayableOverrides + ): Promise; + + depositAmount( + _account: string, + _l1Token: string, + _depositL2TxHash: BytesLike, + overrides?: Overrides + ): Promise; + + "depositAmount(address,address,bytes32)"( + _account: string, + _l1Token: string, + _depositL2TxHash: BytesLike, + overrides?: Overrides + ): Promise; + + finalizeWithdrawal( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "finalizeWithdrawal(uint256,uint256,uint16,bytes,bytes32[])"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + isWithdrawalFinalized( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "isWithdrawalFinalized(uint256,uint256)"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + l2Bridge(overrides?: CallOverrides): Promise; + + "l2Bridge()"(overrides?: CallOverrides): Promise; + + l2TokenAddress( + _l1Token: string, + overrides?: CallOverrides + ): Promise; + + "l2TokenAddress(address)"( + _l1Token: string, + overrides?: CallOverrides + ): Promise; + + l2TokenBeacon(overrides?: CallOverrides): Promise; + + "l2TokenBeacon()"(overrides?: CallOverrides): Promise; + + sharedBridge(overrides?: CallOverrides): Promise; + + "sharedBridge()"(overrides?: CallOverrides): Promise; + + transferTokenToSharedBridge( + _token: string, + _amount: BigNumberish, + overrides?: Overrides + ): Promise; + + "transferTokenToSharedBridge(address,uint256)"( + _token: string, + _amount: BigNumberish, + overrides?: Overrides + ): Promise; + }; + + populateTransaction: { + claimFailedDeposit( + _depositSender: string, + _l1Token: string, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "claimFailedDeposit(address,address,bytes32,uint256,uint256,uint16,bytes32[])"( + _depositSender: string, + _l1Token: string, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "deposit(address,address,uint256,uint256,uint256)"( + _l2Receiver: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxGasLimit: BigNumberish, + _l2TxGasPerPubdataByte: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + "deposit(address,address,uint256,uint256,uint256,address)"( + _l2Receiver: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxGasLimit: BigNumberish, + _l2TxGasPerPubdataByte: BigNumberish, + _refundRecipient: string, + overrides?: PayableOverrides + ): Promise; + + depositAmount( + _account: string, + _l1Token: string, + _depositL2TxHash: BytesLike, + overrides?: Overrides + ): Promise; + + "depositAmount(address,address,bytes32)"( + _account: string, + _l1Token: string, + _depositL2TxHash: BytesLike, + overrides?: Overrides + ): Promise; + + finalizeWithdrawal( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "finalizeWithdrawal(uint256,uint256,uint16,bytes,bytes32[])"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + isWithdrawalFinalized( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "isWithdrawalFinalized(uint256,uint256)"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + l2Bridge(overrides?: CallOverrides): Promise; + + "l2Bridge()"(overrides?: CallOverrides): Promise; + + l2TokenAddress( + _l1Token: string, + overrides?: CallOverrides + ): Promise; + + "l2TokenAddress(address)"( + _l1Token: string, + overrides?: CallOverrides + ): Promise; + + l2TokenBeacon(overrides?: CallOverrides): Promise; + + "l2TokenBeacon()"(overrides?: CallOverrides): Promise; + + sharedBridge(overrides?: CallOverrides): Promise; + + "sharedBridge()"(overrides?: CallOverrides): Promise; + + transferTokenToSharedBridge( + _token: string, + _amount: BigNumberish, + overrides?: Overrides + ): Promise; + + "transferTokenToSharedBridge(address,uint256)"( + _token: string, + _amount: BigNumberish, + overrides?: Overrides + ): Promise; + }; +} diff --git a/src/typechain/Il1Erc20BridgeFactory.ts b/src/typechain/Il1Erc20BridgeFactory.ts new file mode 100644 index 00000000..d8597ceb --- /dev/null +++ b/src/typechain/Il1Erc20BridgeFactory.ts @@ -0,0 +1,395 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer } from "ethers"; +import { Provider } from "@ethersproject/providers"; + +import type { Il1Erc20Bridge } from "./Il1Erc20Bridge"; + +export class Il1Erc20BridgeFactory { + static connect( + address: string, + signerOrProvider: Signer | Provider + ): Il1Erc20Bridge { + return new Contract(address, _abi, signerOrProvider) as Il1Erc20Bridge; + } +} + +const _abi = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "to", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "l1Token", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "ClaimedFailedDeposit", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "l2DepositTxHash", + type: "bytes32", + }, + { + indexed: true, + internalType: "address", + name: "from", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "l1Token", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "DepositInitiated", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "to", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "l1Token", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "WithdrawalFinalized", + type: "event", + }, + { + inputs: [ + { + internalType: "address", + name: "_depositSender", + type: "address", + }, + { + internalType: "address", + name: "_l1Token", + type: "address", + }, + { + internalType: "bytes32", + name: "_l2TxHash", + type: "bytes32", + }, + { + internalType: "uint256", + name: "_l2BatchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2MessageIndex", + type: "uint256", + }, + { + internalType: "uint16", + name: "_l2TxNumberInBatch", + type: "uint16", + }, + { + internalType: "bytes32[]", + name: "_merkleProof", + type: "bytes32[]", + }, + ], + name: "claimFailedDeposit", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_l2Receiver", + type: "address", + }, + { + internalType: "address", + name: "_l1Token", + type: "address", + }, + { + internalType: "uint256", + name: "_amount", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2TxGasLimit", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2TxGasPerPubdataByte", + type: "uint256", + }, + ], + name: "deposit", + outputs: [ + { + internalType: "bytes32", + name: "txHash", + type: "bytes32", + }, + ], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_l2Receiver", + type: "address", + }, + { + internalType: "address", + name: "_l1Token", + type: "address", + }, + { + internalType: "uint256", + name: "_amount", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2TxGasLimit", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2TxGasPerPubdataByte", + type: "uint256", + }, + { + internalType: "address", + name: "_refundRecipient", + type: "address", + }, + ], + name: "deposit", + outputs: [ + { + internalType: "bytes32", + name: "txHash", + type: "bytes32", + }, + ], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_account", + type: "address", + }, + { + internalType: "address", + name: "_l1Token", + type: "address", + }, + { + internalType: "bytes32", + name: "_depositL2TxHash", + type: "bytes32", + }, + ], + name: "depositAmount", + outputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_l2BatchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2MessageIndex", + type: "uint256", + }, + { + internalType: "uint16", + name: "_l2TxNumberInBatch", + type: "uint16", + }, + { + internalType: "bytes", + name: "_message", + type: "bytes", + }, + { + internalType: "bytes32[]", + name: "_merkleProof", + type: "bytes32[]", + }, + ], + name: "finalizeWithdrawal", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_l2BatchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2MessageIndex", + type: "uint256", + }, + ], + name: "isWithdrawalFinalized", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "l2Bridge", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_l1Token", + type: "address", + }, + ], + name: "l2TokenAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "l2TokenBeacon", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "sharedBridge", + outputs: [ + { + internalType: "contract IL1SharedBridge", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_token", + type: "address", + }, + { + internalType: "uint256", + name: "_amount", + type: "uint256", + }, + ], + name: "transferTokenToSharedBridge", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, +]; diff --git a/src/typechain/Il1SharedBridge.d.ts b/src/typechain/Il1SharedBridge.d.ts new file mode 100644 index 00000000..6ff4242d --- /dev/null +++ b/src/typechain/Il1SharedBridge.d.ts @@ -0,0 +1,1469 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { + ethers, + EventFilter, + Signer, + BigNumber, + BigNumberish, + PopulatedTransaction, +} from "ethers"; +import { + Contract, + ContractTransaction, + Overrides, + PayableOverrides, + CallOverrides, +} from "@ethersproject/contracts"; +import { BytesLike } from "@ethersproject/bytes"; +import { Listener, Provider } from "@ethersproject/providers"; +import { FunctionFragment, EventFragment, Result } from "@ethersproject/abi"; + +interface Il1SharedBridgeInterface extends ethers.utils.Interface { + functions: { + "bridgehub()": FunctionFragment; + "bridgehubConfirmL2Transaction(uint256,bytes32,bytes32)": FunctionFragment; + "bridgehubDeposit(uint256,address,uint256,bytes)": FunctionFragment; + "bridgehubDepositBaseToken(uint256,address,address,uint256)": FunctionFragment; + "claimFailedDeposit(uint256,address,address,uint256,bytes32,uint256,uint256,uint16,bytes32[])": FunctionFragment; + "claimFailedDepositLegacyErc20Bridge(address,address,uint256,bytes32,uint256,uint256,uint16,bytes32[])": FunctionFragment; + "depositHappened(uint256,bytes32)": FunctionFragment; + "depositLegacyErc20Bridge(address,address,address,uint256,uint256,uint256,address)": FunctionFragment; + "finalizeWithdrawal(uint256,uint256,uint256,uint16,bytes,bytes32[])": FunctionFragment; + "finalizeWithdrawalLegacyErc20Bridge(uint256,uint256,uint16,bytes,bytes32[])": FunctionFragment; + "isWithdrawalFinalized(uint256,uint256,uint256)": FunctionFragment; + "l1WethAddress()": FunctionFragment; + "l2BridgeAddress(uint256)": FunctionFragment; + "legacyBridge()": FunctionFragment; + "receiveEth(uint256)": FunctionFragment; + "setEraFirstPostUpgradeBatch(uint256)": FunctionFragment; + }; + + encodeFunctionData(functionFragment: "bridgehub", values?: undefined): string; + encodeFunctionData( + functionFragment: "bridgehubConfirmL2Transaction", + values: [BigNumberish, BytesLike, BytesLike] + ): string; + encodeFunctionData( + functionFragment: "bridgehubDeposit", + values: [BigNumberish, string, BigNumberish, BytesLike] + ): string; + encodeFunctionData( + functionFragment: "bridgehubDepositBaseToken", + values: [BigNumberish, string, string, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "claimFailedDeposit", + values: [ + BigNumberish, + string, + string, + BigNumberish, + BytesLike, + BigNumberish, + BigNumberish, + BigNumberish, + BytesLike[] + ] + ): string; + encodeFunctionData( + functionFragment: "claimFailedDepositLegacyErc20Bridge", + values: [ + string, + string, + BigNumberish, + BytesLike, + BigNumberish, + BigNumberish, + BigNumberish, + BytesLike[] + ] + ): string; + encodeFunctionData( + functionFragment: "depositHappened", + values: [BigNumberish, BytesLike] + ): string; + encodeFunctionData( + functionFragment: "depositLegacyErc20Bridge", + values: [ + string, + string, + string, + BigNumberish, + BigNumberish, + BigNumberish, + string + ] + ): string; + encodeFunctionData( + functionFragment: "finalizeWithdrawal", + values: [ + BigNumberish, + BigNumberish, + BigNumberish, + BigNumberish, + BytesLike, + BytesLike[] + ] + ): string; + encodeFunctionData( + functionFragment: "finalizeWithdrawalLegacyErc20Bridge", + values: [BigNumberish, BigNumberish, BigNumberish, BytesLike, BytesLike[]] + ): string; + encodeFunctionData( + functionFragment: "isWithdrawalFinalized", + values: [BigNumberish, BigNumberish, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "l1WethAddress", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "l2BridgeAddress", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "legacyBridge", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "receiveEth", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "setEraFirstPostUpgradeBatch", + values: [BigNumberish] + ): string; + + decodeFunctionResult(functionFragment: "bridgehub", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "bridgehubConfirmL2Transaction", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "bridgehubDeposit", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "bridgehubDepositBaseToken", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "claimFailedDeposit", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "claimFailedDepositLegacyErc20Bridge", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "depositHappened", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "depositLegacyErc20Bridge", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "finalizeWithdrawal", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "finalizeWithdrawalLegacyErc20Bridge", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "isWithdrawalFinalized", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "l1WethAddress", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "l2BridgeAddress", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "legacyBridge", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "receiveEth", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "setEraFirstPostUpgradeBatch", + data: BytesLike + ): Result; + + events: { + "BridgehubDepositBaseTokenInitiated(uint256,address,address,uint256)": EventFragment; + "BridgehubDepositFinalized(uint256,bytes32,bytes32)": EventFragment; + "BridgehubDepositInitiated(uint256,bytes32,address,address,address,uint256)": EventFragment; + "ClaimedFailedDepositSharedBridge(uint256,address,address,uint256)": EventFragment; + "LegacyDepositInitiated(uint256,bytes32,address,address,address,uint256)": EventFragment; + "WithdrawalFinalizedSharedBridge(uint256,address,address,uint256)": EventFragment; + }; + + getEvent( + nameOrSignatureOrTopic: "BridgehubDepositBaseTokenInitiated" + ): EventFragment; + getEvent(nameOrSignatureOrTopic: "BridgehubDepositFinalized"): EventFragment; + getEvent(nameOrSignatureOrTopic: "BridgehubDepositInitiated"): EventFragment; + getEvent( + nameOrSignatureOrTopic: "ClaimedFailedDepositSharedBridge" + ): EventFragment; + getEvent(nameOrSignatureOrTopic: "LegacyDepositInitiated"): EventFragment; + getEvent( + nameOrSignatureOrTopic: "WithdrawalFinalizedSharedBridge" + ): EventFragment; +} + +export class Il1SharedBridge extends Contract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + on(event: EventFilter | string, listener: Listener): this; + once(event: EventFilter | string, listener: Listener): this; + addListener(eventName: EventFilter | string, listener: Listener): this; + removeAllListeners(eventName: EventFilter | string): this; + removeListener(eventName: any, listener: Listener): this; + + interface: Il1SharedBridgeInterface; + + functions: { + bridgehub(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + "bridgehub()"(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + bridgehubConfirmL2Transaction( + _chainId: BigNumberish, + _txDataHash: BytesLike, + _txHash: BytesLike, + overrides?: Overrides + ): Promise; + + "bridgehubConfirmL2Transaction(uint256,bytes32,bytes32)"( + _chainId: BigNumberish, + _txDataHash: BytesLike, + _txHash: BytesLike, + overrides?: Overrides + ): Promise; + + bridgehubDeposit( + _chainId: BigNumberish, + _prevMsgSender: string, + _l2Value: BigNumberish, + _data: BytesLike, + overrides?: PayableOverrides + ): Promise; + + "bridgehubDeposit(uint256,address,uint256,bytes)"( + _chainId: BigNumberish, + _prevMsgSender: string, + _l2Value: BigNumberish, + _data: BytesLike, + overrides?: PayableOverrides + ): Promise; + + bridgehubDepositBaseToken( + _chainId: BigNumberish, + _prevMsgSender: string, + _l1Token: string, + _amount: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + "bridgehubDepositBaseToken(uint256,address,address,uint256)"( + _chainId: BigNumberish, + _prevMsgSender: string, + _l1Token: string, + _amount: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + claimFailedDeposit( + _chainId: BigNumberish, + _depositSender: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "claimFailedDeposit(uint256,address,address,uint256,bytes32,uint256,uint256,uint16,bytes32[])"( + _chainId: BigNumberish, + _depositSender: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + claimFailedDepositLegacyErc20Bridge( + _depositSender: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "claimFailedDepositLegacyErc20Bridge(address,address,uint256,bytes32,uint256,uint256,uint16,bytes32[])"( + _depositSender: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + depositHappened( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + overrides?: CallOverrides + ): Promise<{ + 0: string; + }>; + + "depositHappened(uint256,bytes32)"( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + overrides?: CallOverrides + ): Promise<{ + 0: string; + }>; + + depositLegacyErc20Bridge( + _msgSender: string, + _l2Receiver: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxGasLimit: BigNumberish, + _l2TxGasPerPubdataByte: BigNumberish, + _refundRecipient: string, + overrides?: PayableOverrides + ): Promise; + + "depositLegacyErc20Bridge(address,address,address,uint256,uint256,uint256,address)"( + _msgSender: string, + _l2Receiver: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxGasLimit: BigNumberish, + _l2TxGasPerPubdataByte: BigNumberish, + _refundRecipient: string, + overrides?: PayableOverrides + ): Promise; + + finalizeWithdrawal( + _chainId: BigNumberish, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "finalizeWithdrawal(uint256,uint256,uint256,uint16,bytes,bytes32[])"( + _chainId: BigNumberish, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + finalizeWithdrawalLegacyErc20Bridge( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "finalizeWithdrawalLegacyErc20Bridge(uint256,uint256,uint16,bytes,bytes32[])"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + isWithdrawalFinalized( + _chainId: BigNumberish, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + "isWithdrawalFinalized(uint256,uint256,uint256)"( + _chainId: BigNumberish, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: boolean; + }>; + + l1WethAddress(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + "l1WethAddress()"(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + l2BridgeAddress( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: string; + }>; + + "l2BridgeAddress(uint256)"( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise<{ + 0: string; + }>; + + legacyBridge(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + "legacyBridge()"(overrides?: CallOverrides): Promise<{ + 0: string; + }>; + + receiveEth( + _chainId: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + "receiveEth(uint256)"( + _chainId: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + setEraFirstPostUpgradeBatch( + _eraFirstPostUpgradeBatch: BigNumberish, + overrides?: Overrides + ): Promise; + + "setEraFirstPostUpgradeBatch(uint256)"( + _eraFirstPostUpgradeBatch: BigNumberish, + overrides?: Overrides + ): Promise; + }; + + bridgehub(overrides?: CallOverrides): Promise; + + "bridgehub()"(overrides?: CallOverrides): Promise; + + bridgehubConfirmL2Transaction( + _chainId: BigNumberish, + _txDataHash: BytesLike, + _txHash: BytesLike, + overrides?: Overrides + ): Promise; + + "bridgehubConfirmL2Transaction(uint256,bytes32,bytes32)"( + _chainId: BigNumberish, + _txDataHash: BytesLike, + _txHash: BytesLike, + overrides?: Overrides + ): Promise; + + bridgehubDeposit( + _chainId: BigNumberish, + _prevMsgSender: string, + _l2Value: BigNumberish, + _data: BytesLike, + overrides?: PayableOverrides + ): Promise; + + "bridgehubDeposit(uint256,address,uint256,bytes)"( + _chainId: BigNumberish, + _prevMsgSender: string, + _l2Value: BigNumberish, + _data: BytesLike, + overrides?: PayableOverrides + ): Promise; + + bridgehubDepositBaseToken( + _chainId: BigNumberish, + _prevMsgSender: string, + _l1Token: string, + _amount: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + "bridgehubDepositBaseToken(uint256,address,address,uint256)"( + _chainId: BigNumberish, + _prevMsgSender: string, + _l1Token: string, + _amount: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + claimFailedDeposit( + _chainId: BigNumberish, + _depositSender: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "claimFailedDeposit(uint256,address,address,uint256,bytes32,uint256,uint256,uint16,bytes32[])"( + _chainId: BigNumberish, + _depositSender: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + claimFailedDepositLegacyErc20Bridge( + _depositSender: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "claimFailedDepositLegacyErc20Bridge(address,address,uint256,bytes32,uint256,uint256,uint16,bytes32[])"( + _depositSender: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + depositHappened( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + overrides?: CallOverrides + ): Promise; + + "depositHappened(uint256,bytes32)"( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + overrides?: CallOverrides + ): Promise; + + depositLegacyErc20Bridge( + _msgSender: string, + _l2Receiver: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxGasLimit: BigNumberish, + _l2TxGasPerPubdataByte: BigNumberish, + _refundRecipient: string, + overrides?: PayableOverrides + ): Promise; + + "depositLegacyErc20Bridge(address,address,address,uint256,uint256,uint256,address)"( + _msgSender: string, + _l2Receiver: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxGasLimit: BigNumberish, + _l2TxGasPerPubdataByte: BigNumberish, + _refundRecipient: string, + overrides?: PayableOverrides + ): Promise; + + finalizeWithdrawal( + _chainId: BigNumberish, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "finalizeWithdrawal(uint256,uint256,uint256,uint16,bytes,bytes32[])"( + _chainId: BigNumberish, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + finalizeWithdrawalLegacyErc20Bridge( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "finalizeWithdrawalLegacyErc20Bridge(uint256,uint256,uint16,bytes,bytes32[])"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + isWithdrawalFinalized( + _chainId: BigNumberish, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "isWithdrawalFinalized(uint256,uint256,uint256)"( + _chainId: BigNumberish, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + l1WethAddress(overrides?: CallOverrides): Promise; + + "l1WethAddress()"(overrides?: CallOverrides): Promise; + + l2BridgeAddress( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "l2BridgeAddress(uint256)"( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + legacyBridge(overrides?: CallOverrides): Promise; + + "legacyBridge()"(overrides?: CallOverrides): Promise; + + receiveEth( + _chainId: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + "receiveEth(uint256)"( + _chainId: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + setEraFirstPostUpgradeBatch( + _eraFirstPostUpgradeBatch: BigNumberish, + overrides?: Overrides + ): Promise; + + "setEraFirstPostUpgradeBatch(uint256)"( + _eraFirstPostUpgradeBatch: BigNumberish, + overrides?: Overrides + ): Promise; + + callStatic: { + bridgehub(overrides?: CallOverrides): Promise; + + "bridgehub()"(overrides?: CallOverrides): Promise; + + bridgehubConfirmL2Transaction( + _chainId: BigNumberish, + _txDataHash: BytesLike, + _txHash: BytesLike, + overrides?: CallOverrides + ): Promise; + + "bridgehubConfirmL2Transaction(uint256,bytes32,bytes32)"( + _chainId: BigNumberish, + _txDataHash: BytesLike, + _txHash: BytesLike, + overrides?: CallOverrides + ): Promise; + + bridgehubDeposit( + _chainId: BigNumberish, + _prevMsgSender: string, + _l2Value: BigNumberish, + _data: BytesLike, + overrides?: CallOverrides + ): Promise<{ + magicValue: string; + l2Contract: string; + l2Calldata: string; + factoryDeps: string[]; + txDataHash: string; + 0: string; + 1: string; + 2: string; + 3: string[]; + 4: string; + }>; + + "bridgehubDeposit(uint256,address,uint256,bytes)"( + _chainId: BigNumberish, + _prevMsgSender: string, + _l2Value: BigNumberish, + _data: BytesLike, + overrides?: CallOverrides + ): Promise<{ + magicValue: string; + l2Contract: string; + l2Calldata: string; + factoryDeps: string[]; + txDataHash: string; + 0: string; + 1: string; + 2: string; + 3: string[]; + 4: string; + }>; + + bridgehubDepositBaseToken( + _chainId: BigNumberish, + _prevMsgSender: string, + _l1Token: string, + _amount: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "bridgehubDepositBaseToken(uint256,address,address,uint256)"( + _chainId: BigNumberish, + _prevMsgSender: string, + _l1Token: string, + _amount: BigNumberish, + overrides?: CallOverrides + ): Promise; + + claimFailedDeposit( + _chainId: BigNumberish, + _depositSender: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + "claimFailedDeposit(uint256,address,address,uint256,bytes32,uint256,uint256,uint16,bytes32[])"( + _chainId: BigNumberish, + _depositSender: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + claimFailedDepositLegacyErc20Bridge( + _depositSender: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + "claimFailedDepositLegacyErc20Bridge(address,address,uint256,bytes32,uint256,uint256,uint16,bytes32[])"( + _depositSender: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + depositHappened( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + overrides?: CallOverrides + ): Promise; + + "depositHappened(uint256,bytes32)"( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + overrides?: CallOverrides + ): Promise; + + depositLegacyErc20Bridge( + _msgSender: string, + _l2Receiver: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxGasLimit: BigNumberish, + _l2TxGasPerPubdataByte: BigNumberish, + _refundRecipient: string, + overrides?: CallOverrides + ): Promise; + + "depositLegacyErc20Bridge(address,address,address,uint256,uint256,uint256,address)"( + _msgSender: string, + _l2Receiver: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxGasLimit: BigNumberish, + _l2TxGasPerPubdataByte: BigNumberish, + _refundRecipient: string, + overrides?: CallOverrides + ): Promise; + + finalizeWithdrawal( + _chainId: BigNumberish, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + "finalizeWithdrawal(uint256,uint256,uint256,uint16,bytes,bytes32[])"( + _chainId: BigNumberish, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: CallOverrides + ): Promise; + + finalizeWithdrawalLegacyErc20Bridge( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: CallOverrides + ): Promise<{ + l1Receiver: string; + l1Token: string; + amount: BigNumber; + 0: string; + 1: string; + 2: BigNumber; + }>; + + "finalizeWithdrawalLegacyErc20Bridge(uint256,uint256,uint16,bytes,bytes32[])"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: CallOverrides + ): Promise<{ + l1Receiver: string; + l1Token: string; + amount: BigNumber; + 0: string; + 1: string; + 2: BigNumber; + }>; + + isWithdrawalFinalized( + _chainId: BigNumberish, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "isWithdrawalFinalized(uint256,uint256,uint256)"( + _chainId: BigNumberish, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + l1WethAddress(overrides?: CallOverrides): Promise; + + "l1WethAddress()"(overrides?: CallOverrides): Promise; + + l2BridgeAddress( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "l2BridgeAddress(uint256)"( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + legacyBridge(overrides?: CallOverrides): Promise; + + "legacyBridge()"(overrides?: CallOverrides): Promise; + + receiveEth( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "receiveEth(uint256)"( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + setEraFirstPostUpgradeBatch( + _eraFirstPostUpgradeBatch: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "setEraFirstPostUpgradeBatch(uint256)"( + _eraFirstPostUpgradeBatch: BigNumberish, + overrides?: CallOverrides + ): Promise; + }; + + filters: { + BridgehubDepositBaseTokenInitiated( + chainId: BigNumberish | null, + from: string | null, + l1Token: null, + amount: null + ): EventFilter; + + BridgehubDepositFinalized( + chainId: BigNumberish | null, + txDataHash: BytesLike | null, + l2DepositTxHash: BytesLike | null + ): EventFilter; + + BridgehubDepositInitiated( + chainId: BigNumberish | null, + txDataHash: BytesLike | null, + from: string | null, + to: null, + l1Token: null, + amount: null + ): EventFilter; + + ClaimedFailedDepositSharedBridge( + chainId: BigNumberish | null, + to: string | null, + l1Token: string | null, + amount: null + ): EventFilter; + + LegacyDepositInitiated( + chainId: BigNumberish | null, + l2DepositTxHash: BytesLike | null, + from: string | null, + to: null, + l1Token: null, + amount: null + ): EventFilter; + + WithdrawalFinalizedSharedBridge( + chainId: BigNumberish | null, + to: string | null, + l1Token: string | null, + amount: null + ): EventFilter; + }; + + estimateGas: { + bridgehub(overrides?: CallOverrides): Promise; + + "bridgehub()"(overrides?: CallOverrides): Promise; + + bridgehubConfirmL2Transaction( + _chainId: BigNumberish, + _txDataHash: BytesLike, + _txHash: BytesLike, + overrides?: Overrides + ): Promise; + + "bridgehubConfirmL2Transaction(uint256,bytes32,bytes32)"( + _chainId: BigNumberish, + _txDataHash: BytesLike, + _txHash: BytesLike, + overrides?: Overrides + ): Promise; + + bridgehubDeposit( + _chainId: BigNumberish, + _prevMsgSender: string, + _l2Value: BigNumberish, + _data: BytesLike, + overrides?: PayableOverrides + ): Promise; + + "bridgehubDeposit(uint256,address,uint256,bytes)"( + _chainId: BigNumberish, + _prevMsgSender: string, + _l2Value: BigNumberish, + _data: BytesLike, + overrides?: PayableOverrides + ): Promise; + + bridgehubDepositBaseToken( + _chainId: BigNumberish, + _prevMsgSender: string, + _l1Token: string, + _amount: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + "bridgehubDepositBaseToken(uint256,address,address,uint256)"( + _chainId: BigNumberish, + _prevMsgSender: string, + _l1Token: string, + _amount: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + claimFailedDeposit( + _chainId: BigNumberish, + _depositSender: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "claimFailedDeposit(uint256,address,address,uint256,bytes32,uint256,uint256,uint16,bytes32[])"( + _chainId: BigNumberish, + _depositSender: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + claimFailedDepositLegacyErc20Bridge( + _depositSender: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "claimFailedDepositLegacyErc20Bridge(address,address,uint256,bytes32,uint256,uint256,uint16,bytes32[])"( + _depositSender: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + depositHappened( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + overrides?: CallOverrides + ): Promise; + + "depositHappened(uint256,bytes32)"( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + overrides?: CallOverrides + ): Promise; + + depositLegacyErc20Bridge( + _msgSender: string, + _l2Receiver: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxGasLimit: BigNumberish, + _l2TxGasPerPubdataByte: BigNumberish, + _refundRecipient: string, + overrides?: PayableOverrides + ): Promise; + + "depositLegacyErc20Bridge(address,address,address,uint256,uint256,uint256,address)"( + _msgSender: string, + _l2Receiver: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxGasLimit: BigNumberish, + _l2TxGasPerPubdataByte: BigNumberish, + _refundRecipient: string, + overrides?: PayableOverrides + ): Promise; + + finalizeWithdrawal( + _chainId: BigNumberish, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "finalizeWithdrawal(uint256,uint256,uint256,uint16,bytes,bytes32[])"( + _chainId: BigNumberish, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + finalizeWithdrawalLegacyErc20Bridge( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "finalizeWithdrawalLegacyErc20Bridge(uint256,uint256,uint16,bytes,bytes32[])"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + isWithdrawalFinalized( + _chainId: BigNumberish, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "isWithdrawalFinalized(uint256,uint256,uint256)"( + _chainId: BigNumberish, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + l1WethAddress(overrides?: CallOverrides): Promise; + + "l1WethAddress()"(overrides?: CallOverrides): Promise; + + l2BridgeAddress( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "l2BridgeAddress(uint256)"( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + legacyBridge(overrides?: CallOverrides): Promise; + + "legacyBridge()"(overrides?: CallOverrides): Promise; + + receiveEth( + _chainId: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + "receiveEth(uint256)"( + _chainId: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + setEraFirstPostUpgradeBatch( + _eraFirstPostUpgradeBatch: BigNumberish, + overrides?: Overrides + ): Promise; + + "setEraFirstPostUpgradeBatch(uint256)"( + _eraFirstPostUpgradeBatch: BigNumberish, + overrides?: Overrides + ): Promise; + }; + + populateTransaction: { + bridgehub(overrides?: CallOverrides): Promise; + + "bridgehub()"(overrides?: CallOverrides): Promise; + + bridgehubConfirmL2Transaction( + _chainId: BigNumberish, + _txDataHash: BytesLike, + _txHash: BytesLike, + overrides?: Overrides + ): Promise; + + "bridgehubConfirmL2Transaction(uint256,bytes32,bytes32)"( + _chainId: BigNumberish, + _txDataHash: BytesLike, + _txHash: BytesLike, + overrides?: Overrides + ): Promise; + + bridgehubDeposit( + _chainId: BigNumberish, + _prevMsgSender: string, + _l2Value: BigNumberish, + _data: BytesLike, + overrides?: PayableOverrides + ): Promise; + + "bridgehubDeposit(uint256,address,uint256,bytes)"( + _chainId: BigNumberish, + _prevMsgSender: string, + _l2Value: BigNumberish, + _data: BytesLike, + overrides?: PayableOverrides + ): Promise; + + bridgehubDepositBaseToken( + _chainId: BigNumberish, + _prevMsgSender: string, + _l1Token: string, + _amount: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + "bridgehubDepositBaseToken(uint256,address,address,uint256)"( + _chainId: BigNumberish, + _prevMsgSender: string, + _l1Token: string, + _amount: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + claimFailedDeposit( + _chainId: BigNumberish, + _depositSender: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "claimFailedDeposit(uint256,address,address,uint256,bytes32,uint256,uint256,uint16,bytes32[])"( + _chainId: BigNumberish, + _depositSender: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + claimFailedDepositLegacyErc20Bridge( + _depositSender: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "claimFailedDepositLegacyErc20Bridge(address,address,uint256,bytes32,uint256,uint256,uint16,bytes32[])"( + _depositSender: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxHash: BytesLike, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + depositHappened( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + overrides?: CallOverrides + ): Promise; + + "depositHappened(uint256,bytes32)"( + _chainId: BigNumberish, + _l2TxHash: BytesLike, + overrides?: CallOverrides + ): Promise; + + depositLegacyErc20Bridge( + _msgSender: string, + _l2Receiver: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxGasLimit: BigNumberish, + _l2TxGasPerPubdataByte: BigNumberish, + _refundRecipient: string, + overrides?: PayableOverrides + ): Promise; + + "depositLegacyErc20Bridge(address,address,address,uint256,uint256,uint256,address)"( + _msgSender: string, + _l2Receiver: string, + _l1Token: string, + _amount: BigNumberish, + _l2TxGasLimit: BigNumberish, + _l2TxGasPerPubdataByte: BigNumberish, + _refundRecipient: string, + overrides?: PayableOverrides + ): Promise; + + finalizeWithdrawal( + _chainId: BigNumberish, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "finalizeWithdrawal(uint256,uint256,uint256,uint16,bytes,bytes32[])"( + _chainId: BigNumberish, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + finalizeWithdrawalLegacyErc20Bridge( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + "finalizeWithdrawalLegacyErc20Bridge(uint256,uint256,uint16,bytes,bytes32[])"( + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + _l2TxNumberInBatch: BigNumberish, + _message: BytesLike, + _merkleProof: BytesLike[], + overrides?: Overrides + ): Promise; + + isWithdrawalFinalized( + _chainId: BigNumberish, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "isWithdrawalFinalized(uint256,uint256,uint256)"( + _chainId: BigNumberish, + _l2BatchNumber: BigNumberish, + _l2MessageIndex: BigNumberish, + overrides?: CallOverrides + ): Promise; + + l1WethAddress(overrides?: CallOverrides): Promise; + + "l1WethAddress()"(overrides?: CallOverrides): Promise; + + l2BridgeAddress( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + "l2BridgeAddress(uint256)"( + _chainId: BigNumberish, + overrides?: CallOverrides + ): Promise; + + legacyBridge(overrides?: CallOverrides): Promise; + + "legacyBridge()"(overrides?: CallOverrides): Promise; + + receiveEth( + _chainId: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + "receiveEth(uint256)"( + _chainId: BigNumberish, + overrides?: PayableOverrides + ): Promise; + + setEraFirstPostUpgradeBatch( + _eraFirstPostUpgradeBatch: BigNumberish, + overrides?: Overrides + ): Promise; + + "setEraFirstPostUpgradeBatch(uint256)"( + _eraFirstPostUpgradeBatch: BigNumberish, + overrides?: Overrides + ): Promise; + }; +} diff --git a/src/typechain/Il1SharedBridgeFactory.ts b/src/typechain/Il1SharedBridgeFactory.ts new file mode 100644 index 00000000..1a02566b --- /dev/null +++ b/src/typechain/Il1SharedBridgeFactory.ts @@ -0,0 +1,710 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer } from "ethers"; +import { Provider } from "@ethersproject/providers"; + +import type { Il1SharedBridge } from "./Il1SharedBridge"; + +export class Il1SharedBridgeFactory { + static connect( + address: string, + signerOrProvider: Signer | Provider + ): Il1SharedBridge { + return new Contract(address, _abi, signerOrProvider) as Il1SharedBridge; + } +} + +const _abi = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + indexed: true, + internalType: "address", + name: "from", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "l1Token", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "BridgehubDepositBaseTokenInitiated", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + indexed: true, + internalType: "bytes32", + name: "txDataHash", + type: "bytes32", + }, + { + indexed: true, + internalType: "bytes32", + name: "l2DepositTxHash", + type: "bytes32", + }, + ], + name: "BridgehubDepositFinalized", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + indexed: true, + internalType: "bytes32", + name: "txDataHash", + type: "bytes32", + }, + { + indexed: true, + internalType: "address", + name: "from", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "to", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "l1Token", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "BridgehubDepositInitiated", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "l1Token", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "ClaimedFailedDepositSharedBridge", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + indexed: true, + internalType: "bytes32", + name: "l2DepositTxHash", + type: "bytes32", + }, + { + indexed: true, + internalType: "address", + name: "from", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "to", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "l1Token", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "LegacyDepositInitiated", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "chainId", + type: "uint256", + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "l1Token", + type: "address", + }, + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "WithdrawalFinalizedSharedBridge", + type: "event", + }, + { + inputs: [], + name: "bridgehub", + outputs: [ + { + internalType: "contract IBridgehub", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "bytes32", + name: "_txDataHash", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "_txHash", + type: "bytes32", + }, + ], + name: "bridgehubConfirmL2Transaction", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "address", + name: "_prevMsgSender", + type: "address", + }, + { + internalType: "uint256", + name: "_l2Value", + type: "uint256", + }, + { + internalType: "bytes", + name: "_data", + type: "bytes", + }, + ], + name: "bridgehubDeposit", + outputs: [ + { + components: [ + { + internalType: "bytes32", + name: "magicValue", + type: "bytes32", + }, + { + internalType: "address", + name: "l2Contract", + type: "address", + }, + { + internalType: "bytes", + name: "l2Calldata", + type: "bytes", + }, + { + internalType: "bytes[]", + name: "factoryDeps", + type: "bytes[]", + }, + { + internalType: "bytes32", + name: "txDataHash", + type: "bytes32", + }, + ], + internalType: "struct L2TransactionRequestTwoBridgesInner", + name: "request", + type: "tuple", + }, + ], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "address", + name: "_prevMsgSender", + type: "address", + }, + { + internalType: "address", + name: "_l1Token", + type: "address", + }, + { + internalType: "uint256", + name: "_amount", + type: "uint256", + }, + ], + name: "bridgehubDepositBaseToken", + outputs: [], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "address", + name: "_depositSender", + type: "address", + }, + { + internalType: "address", + name: "_l1Token", + type: "address", + }, + { + internalType: "uint256", + name: "_amount", + type: "uint256", + }, + { + internalType: "bytes32", + name: "_l2TxHash", + type: "bytes32", + }, + { + internalType: "uint256", + name: "_l2BatchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2MessageIndex", + type: "uint256", + }, + { + internalType: "uint16", + name: "_l2TxNumberInBatch", + type: "uint16", + }, + { + internalType: "bytes32[]", + name: "_merkleProof", + type: "bytes32[]", + }, + ], + name: "claimFailedDeposit", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_depositSender", + type: "address", + }, + { + internalType: "address", + name: "_l1Token", + type: "address", + }, + { + internalType: "uint256", + name: "_amount", + type: "uint256", + }, + { + internalType: "bytes32", + name: "_l2TxHash", + type: "bytes32", + }, + { + internalType: "uint256", + name: "_l2BatchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2MessageIndex", + type: "uint256", + }, + { + internalType: "uint16", + name: "_l2TxNumberInBatch", + type: "uint16", + }, + { + internalType: "bytes32[]", + name: "_merkleProof", + type: "bytes32[]", + }, + ], + name: "claimFailedDepositLegacyErc20Bridge", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "bytes32", + name: "_l2TxHash", + type: "bytes32", + }, + ], + name: "depositHappened", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_msgSender", + type: "address", + }, + { + internalType: "address", + name: "_l2Receiver", + type: "address", + }, + { + internalType: "address", + name: "_l1Token", + type: "address", + }, + { + internalType: "uint256", + name: "_amount", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2TxGasLimit", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2TxGasPerPubdataByte", + type: "uint256", + }, + { + internalType: "address", + name: "_refundRecipient", + type: "address", + }, + ], + name: "depositLegacyErc20Bridge", + outputs: [ + { + internalType: "bytes32", + name: "txHash", + type: "bytes32", + }, + ], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2BatchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2MessageIndex", + type: "uint256", + }, + { + internalType: "uint16", + name: "_l2TxNumberInBatch", + type: "uint16", + }, + { + internalType: "bytes", + name: "_message", + type: "bytes", + }, + { + internalType: "bytes32[]", + name: "_merkleProof", + type: "bytes32[]", + }, + ], + name: "finalizeWithdrawal", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_l2BatchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2MessageIndex", + type: "uint256", + }, + { + internalType: "uint16", + name: "_l2TxNumberInBatch", + type: "uint16", + }, + { + internalType: "bytes", + name: "_message", + type: "bytes", + }, + { + internalType: "bytes32[]", + name: "_merkleProof", + type: "bytes32[]", + }, + ], + name: "finalizeWithdrawalLegacyErc20Bridge", + outputs: [ + { + internalType: "address", + name: "l1Receiver", + type: "address", + }, + { + internalType: "address", + name: "l1Token", + type: "address", + }, + { + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2BatchNumber", + type: "uint256", + }, + { + internalType: "uint256", + name: "_l2MessageIndex", + type: "uint256", + }, + ], + name: "isWithdrawalFinalized", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "l1WethAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + ], + name: "l2BridgeAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "legacyBridge", + outputs: [ + { + internalType: "contract IL1ERC20Bridge", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256", + }, + ], + name: "receiveEth", + outputs: [], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_eraFirstPostUpgradeBatch", + type: "uint256", + }, + ], + name: "setEraFirstPostUpgradeBatch", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, +]; diff --git a/src/utils.ts b/src/utils.ts index 80641f84..d9052163 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -13,19 +13,19 @@ import {TypedDataDomain, TypedDataField} from '@ethersproject/abstract-signer'; import {Provider} from './provider'; import {EIP712Signer} from './signer'; import {Ierc20Factory as IERC20Factory} from './typechain/Ierc20Factory'; -import {Il1BridgeFactory as IL1BridgeFactory} from './typechain/Il1BridgeFactory'; import {AbiCoder} from 'ethers/lib/utils'; export * from './paymaster-utils'; export * from './smart-account-utils'; export {EIP712_TYPES} from './signer'; -import IZkSyncABI from '../abi/IZkSync.json'; +import IZkSyncABI from '../abi/IZkSyncStateTransition.json'; +import IBridgehubABI from '../abi/IBridgehub.json'; import IContractDeployerABI from '../abi/IContractDeployer.json'; import IL1MessengerABI from '../abi/IL1Messenger.json'; import IERC20ABI from '../abi/IERC20.json'; import IERC1271ABI from '../abi/IERC1271.json'; -import IL1BridgeABI from '../abi/IL1Bridge.json'; +import IL1BridgeABI from '../abi/IL1ERC20Bridge.json'; import IL2BridgeABI from '../abi/IL2Bridge.json'; import INonceHolderABI from '../abi/INonceHolder.json'; @@ -35,6 +35,12 @@ import INonceHolderABI from '../abi/INonceHolder.json'; */ export const ZKSYNC_MAIN_ABI = new utils.Interface(IZkSyncABI); +/** + * The ABI of the `Bridgehub` interface. + * @constant + */ +export const BRIDGEHUB_ABI = new utils.Interface(IBridgehubABI); + /** * The ABI for the `IContractDeployer` interface, which is utilized for deploying smart contracts. * @constant @@ -83,6 +89,19 @@ export const NONCE_HOLDER_ABI = new utils.Interface(INonceHolderABI); */ export const ETH_ADDRESS = '0x0000000000000000000000000000000000000000'; +/** + * The address of the L1 `ETH` token. + * @constant + */ +export const LEGACY_ETH_ADDRESS = '0x0000000000000000000000000000000000000000'; + +/** + * In the contracts the zero address can not be used, use one instead. + * @constant + */ +export const ETH_ADDRESS_IN_CONTRACTS = + '0x0000000000000000000000000000000000000001'; + /** * The formal address for the `Bootloader`. * @constant @@ -107,10 +126,18 @@ export const L1_MESSENGER_ADDRESS = /** * The address of the L2 `ETH` token. * @constant + * @deprecated In favor of {@link L2_BASE_TOKEN_ADDRESS}. */ export const L2_ETH_TOKEN_ADDRESS = '0x000000000000000000000000000000000000800a'; +/** + * The address of the base token. + * @constant + */ +export const L2_BASE_TOKEN_ADDRESS = + '0x000000000000000000000000000000000000800a'; + /** * The address of the Nonce holder. * @constant @@ -222,12 +249,13 @@ export const REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_LIMIT = 800; * @example * * const isL1ETH = utils.isETH(utils.ETH_ADDRESS); // true - * const isL2ETH = utils.isETH(utils.L2_ETH_TOKEN_ADDRESS); // true + * const isL2ETH = utils.isETH(utils.ETH_ADDRESS_IN_CONTRACTS); // true */ -export function isETH(token: Address): boolean { +export function isETH(token: Address) { return ( - token.toLowerCase() === ETH_ADDRESS || - token.toLowerCase() === L2_ETH_TOKEN_ADDRESS + isAddressEq(token, LEGACY_ETH_ADDRESS) || + isAddressEq(token, L2_BASE_TOKEN_ADDRESS) || + isAddressEq(token.toLowerCase(), ETH_ADDRESS_IN_CONTRACTS) ); } @@ -307,7 +335,7 @@ export function getDeployedContracts( log => log.topics[0] === utils.id('ContractDeployed(address,bytes32,address)') && - log.address === CONTRACT_DEPLOYER_ADDRESS + isAddressEq(log.address, CONTRACT_DEPLOYER_ADDRESS) ) // Take the last topic (deployed contract address as U256) and extract address from it (U160). .map(log => { @@ -783,7 +811,7 @@ export function getL2HashFromPriorityOp( ): string { let txHash: string | null = null; for (const log of txReceipt.logs) { - if (log.address.toLowerCase() !== zkSyncAddress.toLowerCase()) { + if (!isAddressEq(log.address, zkSyncAddress)) { continue; } @@ -871,11 +899,20 @@ export async function getERC20DefaultBridgeData( l1TokenAddress: string, provider: ethers.providers.Provider ): Promise { + if (isAddressEq(l1TokenAddress, LEGACY_ETH_ADDRESS)) { + l1TokenAddress = ETH_ADDRESS_IN_CONTRACTS; + } const token = IERC20Factory.connect(l1TokenAddress, provider); - const name = await token.name(); - const symbol = await token.symbol(); - const decimals = await token.decimals(); + const name = isAddressEq(l1TokenAddress, ETH_ADDRESS_IN_CONTRACTS) + ? 'Ether' + : await token.name(); + const symbol = isAddressEq(l1TokenAddress, ETH_ADDRESS_IN_CONTRACTS) + ? 'ETH' + : await token.symbol(); + const decimals = isAddressEq(l1TokenAddress, ETH_ADDRESS_IN_CONTRACTS) + ? 18 + : await token.decimals(); const coder = new AbiCoder(); @@ -950,7 +987,10 @@ function isECDSASignatureCorrect( signature: SignatureLike ): boolean { try { - return address === ethers.utils.recoverAddress(msgHash, signature); + return isAddressEq( + address, + ethers.utils.recoverAddress(msgHash, signature) + ); } catch { // In case ECDSA signature verification has thrown an error, // we simply consider the signature as incorrect. @@ -1006,10 +1046,8 @@ async function isSignatureCorrect( msgHash: string, signature: SignatureLike ): Promise { - let isContractAccount = false; - const code = await provider.getCode(address); - isContractAccount = ethers.utils.arrayify(code).length !== 0; + const isContractAccount = ethers.utils.arrayify(code).length !== 0; if (!isContractAccount) { return isECDSASignatureCorrect(address, msgHash, signature); @@ -1137,8 +1175,7 @@ export async function estimateDefaultBridgeDepositL2Gas( // due to storage slot aggregation, the gas estimation will depend on the address // and so estimation for the zero address may be smaller than for the sender. from ??= ethers.Wallet.createRandom().address; - - if (token === ETH_ADDRESS) { + if (await providerL2.isBaseToken(token)) { return await providerL2.estimateL1ToL2Execute({ contractAddress: to, gasPerPubdataByte: gasPerPubdataByte, @@ -1147,36 +1184,18 @@ export async function estimateDefaultBridgeDepositL2Gas( l2Value: amount, }); } else { - let value, l1BridgeAddress, l2BridgeAddress, bridgeData; const bridgeAddresses = await providerL2.getDefaultBridgeAddresses(); - const l1WethBridge = IL1BridgeFactory.connect( - bridgeAddresses.wethL1!, - providerL1 - ); - let l2WethToken = ethers.constants.AddressZero; - try { - l2WethToken = await l1WethBridge.l2TokenAddress(token); - } catch (e) { - // skip - } - if (l2WethToken !== ethers.constants.AddressZero) { - value = amount; - l1BridgeAddress = bridgeAddresses.wethL1; - l2BridgeAddress = bridgeAddresses.wethL2; - bridgeData = '0x'; - } else { - value = 0; - l1BridgeAddress = bridgeAddresses.erc20L1; - l2BridgeAddress = bridgeAddresses.erc20L2; - bridgeData = await getERC20DefaultBridgeData(token, providerL1); - } + const value = 0; + const l1BridgeAddress = bridgeAddresses.sharedL1; + const l2BridgeAddress = bridgeAddresses.sharedL2; + const bridgeData = await getERC20DefaultBridgeData(token, providerL1); return await estimateCustomBridgeDepositL2Gas( providerL2, - l1BridgeAddress!, - l2BridgeAddress!, - token, + l1BridgeAddress, + l2BridgeAddress, + isAddressEq(token, LEGACY_ETH_ADDRESS) ? ETH_ADDRESS_IN_CONTRACTS : token, amount, to, bridgeData, @@ -1263,7 +1282,7 @@ export async function estimateCustomBridgeDepositL2Gas( export function toJSON(object: any): string { return JSON.stringify( object, - (key, value) => { + (_, value) => { if (typeof value === 'bigint') { return value.toString(); // Convert BigInt to string } @@ -1272,3 +1291,15 @@ export function toJSON(object: any): string { 2 ); } + +/** + * Compares stringified addresses, taking into account the fact that + * addresses might be represented in different casing. + * + * @param a - The first address to compare. + * @param b - The second address to compare. + * @returns A boolean indicating whether the addresses are equal. + */ +export function isAddressEq(a: Address, b: Address): boolean { + return a.toLowerCase() === b.toLowerCase(); +} diff --git a/src/wallet.ts b/src/wallet.ts index b6bf3e5d..aa0d5f0b 100644 --- a/src/wallet.ts +++ b/src/wallet.ts @@ -8,6 +8,7 @@ import { BytesLike, ethers, Overrides, + PopulatedTransaction, utils, } from 'ethers'; import { @@ -23,9 +24,11 @@ import { } from './types'; import {ProgressCallback} from '@ethersproject/json-wallets'; import {AdapterL1, AdapterL2} from './adapters'; -import {IZkSync} from './typechain/IZkSync'; -import {Il1Bridge} from './typechain/Il1Bridge'; -import {Il2Bridge} from './typechain/Il2Bridge'; +import {IZkSyncStateTransition} from './typechain/IZkSyncStateTransition'; +import {Il1Erc20Bridge as IL1ERC20Bridge} from './typechain/Il1Erc20Bridge'; +import {Il1SharedBridge as IL1SharedBridge} from './typechain/Il1SharedBridge'; +import {Il2Bridge as IL2Bridge} from './typechain/Il2Bridge'; +import {IBridgehub} from './typechain/IBridgehub'; /** * A `Wallet` is an extension of {@link ethers.Wallet} with additional features for interacting with zkSync Era. @@ -39,7 +42,9 @@ export class Wallet extends AdapterL2(AdapterL1(ethers.Wallet)) { override _providerL1(): ethers.providers.Provider { if (!this.providerL1) { - throw new Error('L1 provider missing: use `connectToL1` to specify!'); + throw new Error( + 'L1 provider is missing! Use `Wallet.connectToL1()` to connect to L1!' + ); } return this.providerL1; } @@ -70,12 +75,32 @@ export class Wallet extends AdapterL2(AdapterL1(ethers.Wallet)) { * const ethProvider = ethers.getDefaultProvider("sepolia"); * const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider); * - * console.log(`Main contract: ${await wallet.getMainContract()}`); + * const mainContract = await wallet.getMainContract(); */ - override async getMainContract(): Promise { + override async getMainContract(): Promise { return super.getMainContract(); } + /** + * @inheritDoc + * + * @example + * + * import { Wallet, Provider, types, utils } from "zksync-ethers"; + * import { ethers } from "ethers"; + * + * const PRIVATE_KEY = ""; + * + * const provider = Provider.getDefaultProvider(types.Network.Sepolia); + * const ethProvider = ethers.getDefaultProvider("sepolia"); + * const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider); + * + * const bridgehub = await wallet.getBridgehubContract(); + */ + override async getBridgehubContract(): Promise { + return super.getBridgehubContract(); + } + /** * @inheritDoc * @@ -93,8 +118,9 @@ export class Wallet extends AdapterL2(AdapterL1(ethers.Wallet)) { * const l1BridgeContracts = await wallet.getL1BridgeContracts(); */ override async getL1BridgeContracts(): Promise<{ - erc20: Il1Bridge; - weth: Il1Bridge; + erc20: IL1ERC20Bridge; + weth: IL1ERC20Bridge; + shared: IL1SharedBridge; }> { return super.getL1BridgeContracts(); } @@ -238,16 +264,144 @@ export class Wallet extends AdapterL2(AdapterL1(ethers.Wallet)) { * const ethProvider = ethers.getDefaultProvider("sepolia"); * const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider); * + * console.log(`Base token: ${await wallet.getBaseToken()}`); + */ + override async getBaseToken(): Promise { + return super.getBaseToken(); + } + + /** + * @inheritDoc + * + * @example + * + * import { Wallet, Provider, types, utils } from "zksync-ethers"; + * import { ethers } from "ethers"; + * + * const PRIVATE_KEY = ""; + * + * const provider = Provider.getDefaultProvider(types.Network.Sepolia); + * const ethProvider = ethers.getDefaultProvider("sepolia"); + * const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider); + * + * console.log(`Is ETH-based chain: ${await wallet.isETHBasedChain()}`); + */ + override async isETHBasedChain(): Promise { + return super.isETHBasedChain(); + } + + /** + * @inheritDoc + * + * @example Get allowance parameters for depositing ETH on non-ETH-based chain. + * + * import { Wallet, Provider, types, utils } from "zksync-ethers"; + * import { ethers } from "ethers"; + * + * const PRIVATE_KEY = ""; + * + * const provider = Provider.getDefaultProvider(types.Network.Sepolia); + * const ethProvider = ethers.getDefaultProvider("sepolia"); + * const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider); + * + * const token = utils.LEGACY_ETH_ADDRESS; + * const amount = 5; + * const approveParams = await wallet.getDepositAllowanceParams(token, amount); + * + * await ( + * await wallet.approveERC20( + * approveParams[0].token, + * approveParams[0].allowance + * ) + * ).wait(); + * + * @example Get allowance parameters for depositing base token on non-ETH-based chain. + * + * import { Wallet, Provider, types, utils } from "zksync-ethers"; + * import { ethers } from "ethers"; + * + * const PRIVATE_KEY = ""; + * + * const provider = Provider.getDefaultProvider(types.Network.Sepolia); + * const ethProvider = ethers.getDefaultProvider("sepolia"); + * const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider); + * + * const token = await wallet.getBaseToken(); + * const amount = 5; + * const approveParams = await wallet.getDepositAllowanceParams(token, amount); + * + * await ( + * await wallet.approveERC20( + * approveParams[0].token, + * approveParams[0].allowance + * ) + * ).wait(); + * + * @example Get allowance parameters for depositing non-base token on non-ETH-based chain. + * + * import { Wallet, Provider, types, utils } from "zksync-ethers"; + * import { ethers } from "ethers"; + * + * const PRIVATE_KEY = ""; + * + * const provider = Provider.getDefaultProvider(types.Network.Sepolia); + * const ethProvider = ethers.getDefaultProvider("sepolia"); + * const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider); + * + * const token = ""; + * const amount = 5; + * const approveParams = await wallet.getDepositAllowanceParams(token, amount); + * + * await ( + * await wallet.approveERC20( + * approveParams[0].token, + * approveParams[0].allowance + * ) + * ).wait(); + * + * await ( + * await wallet.approveERC20( + * approveParams[1].token, + * approveParams[1].allowance + * ) + * ).wait(); + */ + override async getDepositAllowanceParams( + token: Address, + amount: BigNumberish + ): Promise< + { + token: Address; + allowance: BigNumberish; + }[] + > { + return super.getDepositAllowanceParams(token, amount); + } + + /** + * @inheritDoc + * + * @example Deposit ETH on ETH-based chain. + * + * import { Wallet, Provider, types, utils } from "zksync-ethers"; + * import { ethers } from "ethers"; + * + * const PRIVATE_KEY = ""; + * + * const provider = Provider.getDefaultProvider(types.Network.Sepolia); + * const ethProvider = ethers.getDefaultProvider("sepolia"); + * const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider); + * * const depositTx = await wallet.deposit({ * token: utils.ETH_ADDRESS, - * amount: "10000000", + * amount: 10_000_000, * }); * // Note that we wait not only for the L1 transaction to complete but also for it to be * // processed by zkSync. If we want to wait only for the transaction to be processed on L1, * // we can use `await depositTx.waitL1Commit()` * await depositTx.wait(); * - * @example Deposit token. + * @example Deposit token on ETH-based chain. * * import { Wallet, Provider, types, utils } from "zksync-ethers"; * import { ethers } from "ethers"; @@ -261,8 +415,73 @@ export class Wallet extends AdapterL2(AdapterL1(ethers.Wallet)) { * const tokenL1 = "0x56E69Fa1BB0d1402c89E3A4E3417882DeA6B14Be"; * const depositTx = await wallet.deposit({ * token: tokenL1, - * amount: "10000000", + * amount: 10_000_000, + * approveERC20: true, + * }); + * // Note that we wait not only for the L1 transaction to complete but also for it to be + * // processed by zkSync. If we want to wait only for the transaction to be processed on L1, + * // we can use `await depositTx.waitL1Commit()` + * await depositTx.wait(); + * + * @example Deposit ETH on non-ETH-based chain. + * + * import { Wallet, Provider, types, utils } from "zksync-ethers"; + * import { ethers } from "ethers"; + * + * const PRIVATE_KEY = ""; + * + * const provider = Provider.getDefaultProvider(types.Network.Sepolia); + * const ethProvider = ethers.getDefaultProvider("sepolia"); + * const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider); + * + * const depositTx = await wallet.deposit({ + * token: utils.ETH_ADDRESS, + * amount: 10_000_000, + * approveBaseERC20: true, + * }); + * // Note that we wait not only for the L1 transaction to complete but also for it to be + * // processed by zkSync. If we want to wait only for the transaction to be processed on L1, + * // we can use `await depositTx.waitL1Commit()` + * await depositTx.wait(); + * + * @example Deposit base token on non-ETH-based chain. + * + * import { Wallet, Provider, types, utils } from "zksync-ethers"; + * import { ethers } from "ethers"; + * + * const PRIVATE_KEY = ""; + * + * const provider = Provider.getDefaultProvider(types.Network.Sepolia); + * const ethProvider = ethers.getDefaultProvider("sepolia"); + * const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider); + * + * const depositTx = await wallet.deposit({ + * token: await wallet.getBaseToken(), + * amount: 10_000_000, + * approveERC20: true, // or approveBaseERC20: true + * }); + * // Note that we wait not only for the L1 transaction to complete but also for it to be + * // processed by zkSync. If we want to wait only for the transaction to be processed on L1, + * // we can use `await depositTx.waitL1Commit()` + * await depositTx.wait(); + * + * @example Deposit non-base token on non-ETH-based chain. + * + * import { Wallet, Provider, types, utils } from "zksync-ethers"; + * import { ethers } from "ethers"; + * + * const PRIVATE_KEY = ""; + * + * const provider = Provider.getDefaultProvider(types.Network.Sepolia); + * const ethProvider = ethers.getDefaultProvider("sepolia"); + * const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider); + * + * const tokenL1 = "0x56E69Fa1BB0d1402c89E3A4E3417882DeA6B14Be"; + * const depositTx = await wallet.deposit({ + * token: tokenL1, + * amount: 10_000_000, * approveERC20: true, + * approveBaseERC20: true, * }); * // Note that we wait not only for the L1 transaction to complete but also for it to be * // processed by zkSync. If we want to wait only for the transaction to be processed on L1, @@ -276,11 +495,13 @@ export class Wallet extends AdapterL2(AdapterL1(ethers.Wallet)) { operatorTip?: BigNumberish; bridgeAddress?: Address; approveERC20?: boolean; + approveBaseERC20?: boolean; l2GasLimit?: BigNumberish; gasPerPubdataByte?: BigNumberish; refundRecipient?: Address; - overrides?: Overrides; - approveOverrides?: Overrides; + overrides?: ethers.PayableOverrides; + approveOverrides?: ethers.Overrides; + approveBaseOverrides?: ethers.Overrides; customBridgeData?: BytesLike; }): Promise { return super.deposit(transaction); @@ -317,7 +538,7 @@ export class Wallet extends AdapterL2(AdapterL1(ethers.Wallet)) { l2GasLimit?: BigNumberish; gasPerPubdataByte?: BigNumberish; refundRecipient?: Address; - overrides?: Overrides; + overrides?: ethers.PayableOverrides; }): Promise { return super.estimateGasDeposit(transaction); } @@ -352,7 +573,7 @@ export class Wallet extends AdapterL2(AdapterL1(ethers.Wallet)) { gasPerPubdataByte?: BigNumberish; customBridgeData?: BytesLike; refundRecipient?: Address; - overrides?: Overrides; + overrides?: ethers.PayableOverrides; }): Promise { return super.getDepositTx(transaction); } @@ -384,7 +605,7 @@ export class Wallet extends AdapterL2(AdapterL1(ethers.Wallet)) { bridgeAddress?: Address; customBridgeData?: BytesLike; gasPerPubdataByte?: BigNumberish; - overrides?: Overrides; + overrides?: ethers.PayableOverrides; }): Promise { return super.getFullRequiredDepositFee(transaction); } @@ -486,6 +707,48 @@ export class Wallet extends AdapterL2(AdapterL1(ethers.Wallet)) { return super.claimFailedDeposit(depositHash, overrides); } + /** + * @inheritDoc + * + * @example + * + * import { Wallet, Provider, types, utils } from "zksync-ethers"; + * import { ethers } from "ethers"; + * + * const PRIVATE_KEY = ""; + * + * const provider = Provider.getDefaultProvider(types.Network.Sepolia); + * const ethProvider = ethers.getDefaultProvider("sepolia"); + * const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider); + * + * const tx = { + * contractAddress: await wallet.getAddress(), + * calldata: '0x', + * l2Value: 7_000_000_000, + * }; + * + * const approveParams = await wallet.getRequestExecuteAllowanceParams(tx); + * await ( + * await wallet.approveERC20( + * approveParams.token, + * approveParams.allowance + * ) + * ).wait(); + */ + override async getRequestExecuteAllowanceParams(transaction: { + contractAddress: Address; + calldata: BytesLike; + l2GasLimit?: BigNumberish; + l2Value?: BigNumberish; + factoryDeps?: BytesLike[]; + operatorTip?: BigNumberish; + gasPerPubdataByte?: BigNumberish; + refundRecipient?: Address; + overrides?: ethers.PayableOverrides; + }): Promise<{token: Address; allowance: BigNumberish}> { + return super.getRequestExecuteAllowanceParams(transaction); + } + /** * @inheritDoc * @@ -541,14 +804,15 @@ export class Wallet extends AdapterL2(AdapterL1(ethers.Wallet)) { */ override async requestExecute(transaction: { contractAddress: Address; - calldata: string; + calldata: BytesLike; l2GasLimit?: BigNumberish; + mintValue?: BigNumberish; l2Value?: BigNumberish; factoryDeps?: BytesLike[]; operatorTip?: BigNumberish; gasPerPubdataByte?: BigNumberish; refundRecipient?: Address; - overrides?: Overrides; + overrides?: ethers.PayableOverrides; }): Promise { return super.requestExecute(transaction); } @@ -606,14 +870,15 @@ export class Wallet extends AdapterL2(AdapterL1(ethers.Wallet)) { */ override async estimateGasRequestExecute(transaction: { contractAddress: Address; - calldata: string; + calldata: BytesLike; l2GasLimit?: BigNumberish; + mintValue?: BigNumberish; l2Value?: BigNumberish; factoryDeps?: BytesLike[]; operatorTip?: BigNumberish; gasPerPubdataByte?: BigNumberish; refundRecipient?: Address; - overrides?: Overrides; + overrides?: ethers.PayableOverrides; }): Promise { return super.estimateGasRequestExecute(transaction); } @@ -671,15 +936,16 @@ export class Wallet extends AdapterL2(AdapterL1(ethers.Wallet)) { */ override async getRequestExecuteTx(transaction: { contractAddress: Address; - calldata: string; + calldata: BytesLike; l2GasLimit?: BigNumberish; + mintValue?: BigNumberish; l2Value?: BigNumberish; factoryDeps?: BytesLike[]; operatorTip?: BigNumberish; gasPerPubdataByte?: BigNumberish; refundRecipient?: Address; - overrides?: Overrides; - }): Promise { + overrides?: ethers.PayableOverrides; + }): Promise { return super.getRequestExecuteTx(transaction); } @@ -779,8 +1045,9 @@ export class Wallet extends AdapterL2(AdapterL1(ethers.Wallet)) { * const l2BridgeContracts = await wallet.getL2BridgeContracts(); */ override async getL2BridgeContracts(): Promise<{ - erc20: Il2Bridge; - weth: Il2Bridge; + erc20: IL2Bridge; + weth: IL2Bridge; + shared: IL2Bridge; }> { return super.getL2BridgeContracts(); } @@ -982,6 +1249,36 @@ export class Wallet extends AdapterL2(AdapterL1(ethers.Wallet)) { return super.transfer(transaction); } + /** + * @inheritDoc + * + * @example + * + * import { Wallet, Provider, types, utils } from "zksync-ethers"; + * import { ethers } from "ethers"; + * + * const PRIVATE_KEY = ""; + * + * const provider = Provider.getDefaultProvider(types.Network.Sepolia); + * const wallet = new Wallet(PRIVATE_KEY, provider); + * + * // Any L2 -> L1 transaction can be used. + * // In this case, withdrawal transaction is used. + * const tx = "0x2a1c6c74b184965c0cb015aae9ea134fd96215d2e4f4979cfec12563295f610e"; + * console.log(`Confirmation data: ${utils.toJSON(await wallet.getPriorityOpConfirmation(tx, 0))}`); + */ + override async getPriorityOpConfirmation( + txHash: string, + index = 0 + ): Promise<{ + l1BatchNumber: number; + l2MessageIndex: number; + l2TxNumberInBlock: number; + proof: string[]; + }> { + return super.getPriorityOpConfirmation(txHash, index); + } + /** * Returns `ethers.Wallet` object with the same private key. * @@ -1145,7 +1442,7 @@ export class Wallet extends AdapterL2(AdapterL1(ethers.Wallet)) { } /** - * Static methods to create Wallet instances. + * Creates random `Wallet`. * @param options Additional options. * * @example diff --git a/tests/custom-matchers.ts b/tests/custom-matchers.ts index c3c5fb15..492f07a9 100644 --- a/tests/custom-matchers.ts +++ b/tests/custom-matchers.ts @@ -1,4 +1,8 @@ import * as chai from 'chai'; +import {BigNumber} from 'ethers'; +import {types} from '../src'; + +const {expect} = chai; declare global { // eslint-disable-next-line @typescript-eslint/no-namespace @@ -24,3 +28,49 @@ chai.Assertion.addMethod( } } ); + +// Custom assertion function for BigNumber values with a percentage tolerance +export function expectBigNumberCloseTo( + actual: BigNumber, + expected: BigNumber, + tolerancePercentage: number +) { + const actualPercentageDiff = actual + .sub(expected) + .mul(100) + .div(expected) + .abs(); + expect(actualPercentageDiff.lte(tolerancePercentage)).to.be.true; +} + +export function expectFeeDataCloseToExpected( + result: types.FullDepositFee, + expected: types.FullDepositFee, + tolerancePercentage: number +) { + expectBigNumberCloseTo( + result.baseCost, + expected.baseCost, + tolerancePercentage + ); + expectBigNumberCloseTo( + result.l1GasLimit, + expected.l1GasLimit, + tolerancePercentage + ); + expectBigNumberCloseTo( + result.l2GasLimit, + expected.l2GasLimit, + tolerancePercentage + ); + expectBigNumberCloseTo( + result.maxFeePerGas!, + expected.maxFeePerGas!, + tolerancePercentage + ); + expectBigNumberCloseTo( + result.maxPriorityFeePerGas!, + expected.maxPriorityFeePerGas!, + tolerancePercentage + ); +} diff --git a/tests/integration/account-abstraction.test.ts b/tests/integration/account-abstraction.test.ts index 1a7d2058..a5ac3871 100644 --- a/tests/integration/account-abstraction.test.ts +++ b/tests/integration/account-abstraction.test.ts @@ -3,6 +3,7 @@ import '../custom-matchers'; import {Provider, types, utils, Wallet, ContractFactory} from '../../src'; import {BigNumber, Contract, ethers} from 'ethers'; import {ECDSASmartAccount, MultisigECDSASmartAccount} from '../../src'; +import {PRIVATE_KEY1, ADDRESS1, APPROVAL_TOKEN, PAYMASTER} from '../utils'; const {expect} = chai; @@ -12,15 +13,8 @@ import Storage from '../files/Storage.json'; import MultisigAccount from '../files/TwoUserMultisig.json'; describe('Account Abstraction', () => { - const ADDRESS = '0x36615Cf349d7F6344891B1e7CA7C72883F5dc049'; - const PRIVATE_KEY = - '0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110'; - const provider = Provider.getDefaultProvider(types.Network.Localhost); - const wallet = new Wallet(PRIVATE_KEY, provider); - - const TOKEN = '0x841c43Fa5d8fFfdB9efE3358906f7578d8700Dd4'; - const PAYMASTER = '0xa222f0c183AFA73a8Bc1AFb48D34C88c9Bf7A174'; + const wallet = new Wallet(PRIVATE_KEY1, provider); it('use the ERC20 token for paying transaction fee', async () => { const InitMintAmount = BigNumber.from(10); @@ -114,7 +108,7 @@ describe('Account Abstraction', () => { it('use multisig account', async () => { const storageValue = BigNumber.from(500); - const account = ECDSASmartAccount.create(ADDRESS, PRIVATE_KEY, provider); + const account = ECDSASmartAccount.create(ADDRESS1, PRIVATE_KEY1, provider); const multisigAccountAbi = MultisigAccount.abi; const multisigAccountBytecode: string = MultisigAccount.bytecode; @@ -143,11 +137,11 @@ describe('Account Abstraction', () => { // send paymaster approval token to multisig account const sendApprovalTokenTx = await new Wallet( - PRIVATE_KEY, + PRIVATE_KEY1, provider ).transfer({ to: multisigAddress, - token: TOKEN, + token: APPROVAL_TOKEN, amount: 5, }); await sendApprovalTokenTx.wait(); @@ -191,7 +185,7 @@ describe('Account Abstraction', () => { const minimalAllowance = BigNumber.from(1); const storageValue = BigNumber.from(700); - const account = ECDSASmartAccount.create(ADDRESS, PRIVATE_KEY, provider); + const account = ECDSASmartAccount.create(ADDRESS1, PRIVATE_KEY1, provider); const storageAbi = Storage.contracts['Storage.sol:Storage'].abi; const storageBytecode: string = @@ -204,13 +198,14 @@ describe('Account Abstraction', () => { const storage = (await storageFactory.deploy()) as Contract; const accountBalanceBeforeTx = await account.getBalance(); - const accountApprovalTokenBalanceBeforeTx = await account.getBalance(TOKEN); + const accountApprovalTokenBalanceBeforeTx = + await account.getBalance(APPROVAL_TOKEN); const paymasterSetTx = await storage.set(storageValue, { customData: { paymasterParams: utils.getPaymasterParams(PAYMASTER, { type: 'ApprovalBased', - token: TOKEN, + token: APPROVAL_TOKEN, minimalAllowance: minimalAllowance, innerInput: new Uint8Array(), }), @@ -219,7 +214,8 @@ describe('Account Abstraction', () => { await paymasterSetTx.wait(); const accountBalanceAfterTx = await account.getBalance(); - const accountApprovalTokenBalanceAfterTx = await account.getBalance(TOKEN); + const accountApprovalTokenBalanceAfterTx = + await account.getBalance(APPROVAL_TOKEN); expect(accountBalanceBeforeTx.eq(accountBalanceAfterTx)).to.be.true; expect( diff --git a/tests/integration/contract.test.ts b/tests/integration/contract.test.ts index 75c7ddcf..9de736ac 100644 --- a/tests/integration/contract.test.ts +++ b/tests/integration/contract.test.ts @@ -2,23 +2,18 @@ import * as chai from 'chai'; import '../custom-matchers'; import {ContractFactory, Provider, types, Wallet, Contract} from '../../src'; import {ethers} from 'ethers'; +import {PRIVATE_KEY1, DAI_L1} from '../utils'; const {expect} = chai; -import TokensL1 from '../files/tokens.json'; import Token from '../files/Token.json'; import Paymaster from '../files/Paymaster.json'; import Storage from '../files/Storage.json'; import Demo from '../files/Demo.json'; describe('ContractFactory', () => { - const PRIVATE_KEY = - '0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110'; - const provider = Provider.getDefaultProvider(types.Network.Localhost); - const wallet = new Wallet(PRIVATE_KEY, provider); - - const DAI_L1 = TokensL1[0].address; + const wallet = new Wallet(PRIVATE_KEY1, provider); describe('#constructor()', () => { it('`ContractFactory(abi, bytecode, runner)` should return a `ContractFactory` with `create` deployment', async () => { diff --git a/tests/integration/paymaster.test.ts b/tests/integration/paymaster.test.ts deleted file mode 100644 index f4d19684..00000000 --- a/tests/integration/paymaster.test.ts +++ /dev/null @@ -1,120 +0,0 @@ -import * as chai from 'chai'; -import '../custom-matchers'; -import {Provider, types, utils, Wallet, ContractFactory} from '../../src'; -import {Contract, ethers, BigNumber} from 'ethers'; - -const {expect} = chai; - -import Token from '../files/Token.json'; -import Paymaster from '../files/Paymaster.json'; - -describe('Paymaster', () => { - const PRIVATE_KEY = - '0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110'; - - const provider = Provider.getDefaultProvider(types.Network.Localhost); - const wallet = new Wallet(PRIVATE_KEY, provider); - - describe('#ApprovalBased', () => { - it('use ERC20 token to pay transaction fee', async () => { - const INIT_MINT_AMOUNT = 10; - const MINT_AMOUNT = 3; - const MINIMAL_ALLOWANCE = 1; - - const abi = Token.abi; - const bytecode: string = Token.bytecode; - const factory = new ContractFactory(abi, bytecode, wallet); - const tokenContract = (await factory.deploy( - 'Ducat', - 'Ducat', - 18 - )) as Contract; - const tokenAddress = tokenContract.address; - - // mint tokens to wallet, so it could pay fee with tokens - await tokenContract.mint(await wallet.getAddress(), INIT_MINT_AMOUNT); - - const paymasterAbi = Paymaster.abi; - const paymasterBytecode = Paymaster.bytecode; - const accountFactory = new ContractFactory( - paymasterAbi, - paymasterBytecode, - wallet, - 'createAccount' - ); - const paymasterContract = await accountFactory.deploy(tokenAddress); - const paymasterAddress = paymasterContract.address; - - // transfer ETH to paymaster so it could pay fee - const faucetTx = await wallet.transfer({ - token: utils.ETH_ADDRESS, - to: paymasterAddress, - amount: ethers.utils.parseEther('0.01'), - }); - await faucetTx.wait(); - - const paymasterBalanceBeforeTx = - await provider.getBalance(paymasterAddress); - const paymasterTokenBalanceBeforeTx = await provider.getBalance( - paymasterAddress, - 'latest', - tokenAddress - ); - const walletBalanceBeforeTx = await wallet.getBalance(); - const walletTokenBalanceBeforeTx = await wallet.getBalance(tokenAddress); - - // perform tx using paymaster - const tokenAbi = new ethers.utils.Interface(Token.abi); - const tx = await wallet.sendTransaction({ - to: tokenAddress, - data: tokenAbi.encodeFunctionData('mint', [ - await wallet.getAddress(), - MINT_AMOUNT, - ]), - customData: { - gasPerPubdata: utils.DEFAULT_GAS_PER_PUBDATA_LIMIT, - paymasterParams: utils.getPaymasterParams(paymasterAddress, { - type: 'ApprovalBased', - token: tokenAddress, - minimalAllowance: BigNumber.from(MINIMAL_ALLOWANCE), - innerInput: new Uint8Array(), - }), - }, - }); - await tx.wait(); - - const paymasterBalanceAfterTx = - await provider.getBalance(paymasterAddress); - const paymasterTokenBalanceAfterTx = await provider.getBalance( - paymasterAddress, - 'latest', - tokenAddress - ); - const walletBalanceAfterTx = await wallet.getBalance(); - const walletTokenBalanceAfterTx = await wallet.getBalance(tokenAddress); - - expect(paymasterTokenBalanceBeforeTx.isZero()).to.be.true; - expect(walletTokenBalanceBeforeTx.eq(BigNumber.from(INIT_MINT_AMOUNT))).to - .be.true; - - expect( - paymasterBalanceBeforeTx - .sub(paymasterBalanceAfterTx) - .gte(BigNumber.from(0)) - ).to.be.true; - expect(paymasterTokenBalanceAfterTx.eq(BigNumber.from(MINIMAL_ALLOWANCE))) - .to.be.true; - - expect( - walletBalanceBeforeTx.sub(walletBalanceAfterTx).gte(BigNumber.from(0)) - ).to.be.true; - expect( - walletTokenBalanceAfterTx.eq( - walletTokenBalanceBeforeTx - .sub(BigNumber.from(MINIMAL_ALLOWANCE)) - .add(BigNumber.from(MINT_AMOUNT)) - ) - ).to.be.true; - }).timeout(30_000); - }); -}); diff --git a/tests/integration/provider.test.ts b/tests/integration/provider.test.ts index 2c2aad95..d2609ec8 100644 --- a/tests/integration/provider.test.ts +++ b/tests/integration/provider.test.ts @@ -2,35 +2,78 @@ import {expect} from 'chai'; import '../custom-matchers'; import {Provider, types, utils, Wallet} from '../../src'; import {BigNumber, ethers} from 'ethers'; - -import TokensL1 from '../files/tokens.json'; +import { + IS_ETH_BASED, + PRIVATE_KEY1, + ADDRESS1, + ADDRESS2, + DAI_L1, + APPROVAL_TOKEN, + PAYMASTER, +} from '../utils'; describe('Provider', () => { - const ADDRESS = '0x36615Cf349d7F6344891B1e7CA7C72883F5dc049'; - const PRIVATE_KEY = - '0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110'; - const RECEIVER = '0xa61464658AfeAf65CccaaFD3a512b69A83B77618'; - const provider = Provider.getDefaultProvider(); - const wallet = new Wallet(PRIVATE_KEY, provider); - - const DAI_L1 = TokensL1[0].address; - - const TOKEN = '0x841c43Fa5d8fFfdB9efE3358906f7578d8700Dd4'; - const PAYMASTER = '0xa222f0c183AFA73a8Bc1AFb48D34C88c9Bf7A174'; + const wallet = new Wallet(PRIVATE_KEY1, provider); let receipt: types.TransactionReceipt; + let baseToken: string; before('setup', async function () { this.timeout(25_000); + baseToken = await provider.getBaseTokenContractAddress(); const tx = await wallet.transfer({ - token: utils.ETH_ADDRESS, - to: RECEIVER, + token: utils.LEGACY_ETH_ADDRESS, + to: ADDRESS2, amount: 1_000_000, }); receipt = await tx.wait(); }); + it('should correctly initialize and assign function properties in getPriorityOpResponse', async () => { + const provider = new Provider(); + const l1TxResponse: ethers.providers.TransactionResponse = { + hash: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef', + from: '0xabcdef1234567890abcdef1234567890abcdef1234', + blockHash: + '0xabcd1234567890abcdef1234567890abcdef1234567890abcdef1234567890', + blockNumber: 123456, + to: '0xabcdef1234567890abcdef1234567890abcdef1234', + type: 2, + nonce: 42, + gasLimit: BigNumber.from(2_000_000), + gasPrice: BigNumber.from(1_000_000_000), + data: '0x', + value: BigNumber.from(0), + chainId: 1337, + // not used in tested code, keep the test simple + maxPriorityFeePerGas: undefined, + maxFeePerGas: undefined, + accessList: undefined, + confirmations: 0, + wait: (): Promise => { + return Promise.resolve( + {} as ethers.providers.TransactionReceipt + ); + }, + }; + + const priorityOpResponse = + await provider.getPriorityOpResponse(l1TxResponse); + expect(typeof priorityOpResponse.waitL1Commit).to.equal( + 'function', + 'The waitL1Commit function should be properly initialized' + ); + expect(typeof priorityOpResponse.wait).to.equal( + 'function', + 'The wait function should be properly initialized' + ); + expect(typeof priorityOpResponse.waitFinalize).to.equal( + 'function', + 'The waitFinalize function should be properly initialized' + ); + }); + describe('#constructor()', () => { it('Provider() should return a `Provider` connected to local network when URL is not defined', async () => { const provider = new Provider(); @@ -72,11 +115,17 @@ describe('Provider', () => { }); }); + describe('#getBridgehubContractAddress()', () => { + it('should return the address of main contract', async () => { + const result = await provider.getBridgehubContractAddress(); + expect(result).not.to.be.null; + }); + }); + describe('#getTestnetPaymasterAddress()', () => { it('should return the address of testnet paymaster', async () => { - const TESTNET_PAYMASTER = '0x2d348ebb27d2624178c6a8a358d1ea064e67fd47'; const result = await provider.getTestnetPaymasterAddress(); - expect(result).to.be.equal(TESTNET_PAYMASTER); + expect(result).not.to.be.null; }); }); @@ -104,13 +153,13 @@ describe('Provider', () => { describe('#getBalance()', () => { it('should return balance of the account at `address`', async () => { - const result = await provider.getBalance(ADDRESS); + const result = await provider.getBalance(ADDRESS1); expect(result.isZero()).to.be.false; }); it('should return a DAI balance of the account at `address`', async () => { const result = await provider.getBalance( - ADDRESS, + ADDRESS1, 'latest', await provider.l2TokenAddress(DAI_L1) ); @@ -120,8 +169,9 @@ describe('Provider', () => { describe('#getAllAccountBalances()', () => { it('should return all balances of the account at `address`', async () => { - const result = await provider.getAllAccountBalances(ADDRESS); - expect(Object.keys(result)).to.have.lengthOf(2); // ETH and DAI + const result = await provider.getAllAccountBalances(ADDRESS1); + const expected = IS_ETH_BASED ? 2 : 3; + expect(Object.keys(result)).to.have.lengthOf(expected); }); }); @@ -148,13 +198,13 @@ describe('Provider', () => { ); const tokenFactoryDepsHash = ethers.utils.hexlify( utils.hashBytecode(testnetPaymasterBytecode) - ); // "0x0100012539970918b0ab79e00660723a76fed0d6dac333c9298fdbb8628407f2"; + ); const result = await provider.getBytecodeByHash(tokenFactoryDepsHash); expect(result).to.be.deep.equal( Array.from(ethers.utils.arrayify(testnetPaymasterBytecode)) ); }); - }); + }).timeout(10_000); describe('#getRawBlockTransactions()', () => { it('should return a raw transactions', async () => { @@ -252,7 +302,7 @@ describe('Provider', () => { const result = await provider.newFilter({ fromBlock: 0, toBlock: 5, - address: utils.L2_ETH_TOKEN_ADDRESS, + address: utils.L2_BASE_TOKEN_ADDRESS, }); expect(result).not.to.be.null; }); @@ -267,9 +317,16 @@ describe('Provider', () => { }); describe('#l2TokenAddress()', () => { - it('should return L2 token address', async () => { - const result = await provider.l2TokenAddress(utils.ETH_ADDRESS); - expect(result).to.be.equal(utils.ETH_ADDRESS); + it('should return the L2 base address', async () => { + const result = await provider.l2TokenAddress(baseToken); + expect(result).to.be.equal(utils.L2_BASE_TOKEN_ADDRESS); + }); + + it('should return the L2 ETH address', async () => { + if (!IS_ETH_BASED) { + const result = await provider.l2TokenAddress(utils.LEGACY_ETH_ADDRESS); + expect(result).not.to.be.null; + } }); it('should return the L2 DAI address', async () => { @@ -280,8 +337,8 @@ describe('Provider', () => { describe('#l1TokenAddress()', () => { it('should return L1 token address', async () => { - const result = await provider.l1TokenAddress(utils.ETH_ADDRESS); - expect(result).to.be.equal(utils.ETH_ADDRESS); + const result = await provider.l1TokenAddress(utils.LEGACY_ETH_ADDRESS); + expect(result).to.be.equal(utils.LEGACY_ETH_ADDRESS); }); it('should return the L1 DAI address', async () => { @@ -376,7 +433,7 @@ describe('Provider', () => { const result = await provider.getLogs({ fromBlock: 0, toBlock: 5, - address: utils.L2_ETH_TOKEN_ADDRESS, + address: utils.L2_BASE_TOKEN_ADDRESS, }); expect(result).not.to.be.null; }); @@ -385,29 +442,25 @@ describe('Provider', () => { describe('#getWithdrawTx()', () => { it('should return withdraw transaction', async () => { const tx = { - from: ADDRESS, + from: ADDRESS1, value: BigNumber.from(7_000_000_000), - to: ethers.utils.getAddress( - '0x000000000000000000000000000000000000800a' - ), + to: ethers.utils.getAddress(utils.L2_BASE_TOKEN_ADDRESS), data: '0x51cff8d900000000000000000000000036615cf349d7f6344891b1e7ca7c72883f5dc049', }; const result = await provider.getWithdrawTx({ - token: utils.ETH_ADDRESS, + token: utils.LEGACY_ETH_ADDRESS, amount: 7_000_000_000, - to: ADDRESS, - from: ADDRESS, + to: ADDRESS1, + from: ADDRESS1, }); expect(result).to.be.deep.equal(tx); }); - it('should return an ETH withdraw transaction with paymaster parameters', async () => { + it('should return a withdraw transaction of the base token with paymaster parameters', async () => { const tx = { - from: ADDRESS, + from: ADDRESS1, value: BigNumber.from(7_000_000_000), - to: ethers.utils.getAddress( - '0x000000000000000000000000000000000000800a' - ), + to: ethers.utils.getAddress(utils.L2_BASE_TOKEN_ADDRESS), data: '0x51cff8d900000000000000000000000036615cf349d7f6344891b1e7ca7c72883f5dc049', customData: { paymasterParams: { @@ -418,13 +471,13 @@ describe('Provider', () => { }, }; const result = await provider.getWithdrawTx({ - token: utils.ETH_ADDRESS, + token: utils.LEGACY_ETH_ADDRESS, amount: 7_000_000_000, - to: ADDRESS, - from: ADDRESS, + to: ADDRESS1, + from: ADDRESS1, paymasterParams: utils.getPaymasterParams(PAYMASTER, { type: 'ApprovalBased', - token: TOKEN, + token: APPROVAL_TOKEN, minimalAllowance: BigNumber.from(1), innerInput: new Uint8Array(), }), @@ -434,26 +487,26 @@ describe('Provider', () => { it('should return a DAI withdraw transaction', async () => { const tx = { - from: ADDRESS, + from: ADDRESS1, to: ethers.utils.getAddress( - (await provider.getDefaultBridgeAddresses()).erc20L2 as string + (await provider.getDefaultBridgeAddresses()).sharedL2 as string ), data: '0xd9caed1200000000000000000000000036615cf349d7f6344891b1e7ca7c72883f5dc04900000000000000000000000082b5ea13260346f4251c0940067a9117a6cf13840000000000000000000000000000000000000000000000000000000000000005', }; const result = await provider.getWithdrawTx({ token: await provider.l2TokenAddress(DAI_L1), amount: 5, - to: ADDRESS, - from: ADDRESS, + to: ADDRESS1, + from: ADDRESS1, }); expect(result).to.be.deepEqualExcluding(tx, ['data']); }); it('should return a DAI withdraw transaction with paymaster parameters', async () => { const tx = { - from: ADDRESS, + from: ADDRESS1, to: ethers.utils.getAddress( - (await provider.getDefaultBridgeAddresses()).erc20L2 as string + (await provider.getDefaultBridgeAddresses()).sharedL2 as string ), data: '0xd9caed1200000000000000000000000036615cf349d7f6344891b1e7ca7c72883f5dc04900000000000000000000000082b5ea13260346f4251c0940067a9117a6cf13840000000000000000000000000000000000000000000000000000000000000005', customData: { @@ -467,11 +520,11 @@ describe('Provider', () => { const result = await provider.getWithdrawTx({ token: await provider.l2TokenAddress(DAI_L1), amount: 5, - to: ADDRESS, - from: ADDRESS, + to: ADDRESS1, + from: ADDRESS1, paymasterParams: utils.getPaymasterParams(PAYMASTER, { type: 'ApprovalBased', - token: TOKEN, + token: APPROVAL_TOKEN, minimalAllowance: BigNumber.from(1), innerInput: new Uint8Array(), }), @@ -481,15 +534,15 @@ describe('Provider', () => { it('should return a withdraw transaction with `tx.from==tx.to` when `tx.to` is not provided', async () => { const tx = { - from: ADDRESS, + from: ADDRESS1, value: BigNumber.from(7_000_000_000), - to: '0x000000000000000000000000000000000000800A', + to: ethers.utils.getAddress(utils.L2_BASE_TOKEN_ADDRESS), data: '0x51cff8d900000000000000000000000036615cf349d7f6344891b1e7ca7c72883f5dc049', }; const result = await provider.getWithdrawTx({ - token: utils.ETH_ADDRESS, + token: utils.LEGACY_ETH_ADDRESS, amount: 7_000_000_000, - from: ADDRESS, + from: ADDRESS1, }); expect(result).to.be.deep.equal(tx); }); @@ -497,7 +550,7 @@ describe('Provider', () => { it('should throw an error when `tx.to` and `tx.from` are not provided', async () => { try { await provider.getWithdrawTx({ - token: utils.ETH_ADDRESS, + token: utils.LEGACY_ETH_ADDRESS, amount: 5, }); } catch (e) { @@ -510,10 +563,10 @@ describe('Provider', () => { it('should throw an error when `tx.amount!=tx.overrides.value', async () => { try { await provider.getWithdrawTx({ - token: utils.ETH_ADDRESS, + token: utils.LEGACY_ETH_ADDRESS, amount: 5, - to: ADDRESS, - from: ADDRESS, + to: ADDRESS1, + from: ADDRESS1, overrides: {value: 7}, }); } catch (e) { @@ -527,15 +580,15 @@ describe('Provider', () => { describe('#getTransferTx()', () => { it('should return transfer transaction', async () => { const tx = { - from: ADDRESS, - to: RECEIVER, + from: ADDRESS1, + to: ADDRESS2, value: 7_000_000_000, }; const result = await provider.getTransferTx({ - token: utils.ETH_ADDRESS, + token: utils.LEGACY_ETH_ADDRESS, amount: 7_000_000_000, - to: RECEIVER, - from: ADDRESS, + to: ADDRESS2, + from: ADDRESS1, }); expect(result).to.be.deep.equal(tx); }); @@ -543,8 +596,8 @@ describe('Provider', () => { it('should return an ETH transfer transaction with paymaster parameters', async () => { const tx = { type: utils.EIP712_TX_TYPE, - from: ADDRESS, - to: RECEIVER, + from: ADDRESS1, + to: ADDRESS2, value: 7_000_000_000, customData: { paymasterParams: { @@ -555,13 +608,13 @@ describe('Provider', () => { }, }; const result = await provider.getTransferTx({ - token: utils.ETH_ADDRESS, + token: utils.LEGACY_ETH_ADDRESS, amount: 7_000_000_000, - to: RECEIVER, - from: ADDRESS, + to: ADDRESS2, + from: ADDRESS1, paymasterParams: utils.getPaymasterParams(PAYMASTER, { type: 'ApprovalBased', - token: TOKEN, + token: APPROVAL_TOKEN, minimalAllowance: BigNumber.from(1), innerInput: new Uint8Array(), }), @@ -571,22 +624,22 @@ describe('Provider', () => { it('should return a DAI transfer transaction', async () => { const tx = { - from: ADDRESS, + from: ADDRESS1, to: await provider.l2TokenAddress(DAI_L1), data: '0xa9059cbb000000000000000000000000a61464658afeaf65cccaafd3a512b69a83b776180000000000000000000000000000000000000000000000000000000000000005', }; const result = await provider.getTransferTx({ token: await provider.l2TokenAddress(DAI_L1), amount: 5, - to: RECEIVER, - from: ADDRESS, + to: ADDRESS2, + from: ADDRESS1, }); expect(result).to.be.deep.equal(tx); }); it('should return a DAI transfer transaction with paymaster parameters', async () => { const tx = { - from: ADDRESS, + from: ADDRESS1, to: await provider.l2TokenAddress(DAI_L1), data: '0xa9059cbb000000000000000000000000a61464658afeaf65cccaafd3a512b69a83b776180000000000000000000000000000000000000000000000000000000000000005', customData: { @@ -600,11 +653,11 @@ describe('Provider', () => { const result = await provider.getTransferTx({ token: await provider.l2TokenAddress(DAI_L1), amount: 5, - to: RECEIVER, - from: ADDRESS, + to: ADDRESS2, + from: ADDRESS1, paymasterParams: utils.getPaymasterParams(PAYMASTER, { type: 'ApprovalBased', - token: TOKEN, + token: APPROVAL_TOKEN, minimalAllowance: BigNumber.from(1), innerInput: new Uint8Array(), }), @@ -616,23 +669,26 @@ describe('Provider', () => { describe('#estimateGasWithdraw()', () => { it('should return gas estimation of withdraw transaction', async () => { const result = await provider.estimateGasWithdraw({ - token: utils.ETH_ADDRESS, + token: utils.LEGACY_ETH_ADDRESS, amount: 7_000_000_000, - to: ADDRESS, - from: ADDRESS, + to: ADDRESS1, + from: ADDRESS1, }); expect(result.isZero()).to.be.false; }); it('should return a gas estimation of the withdraw transaction with paymaster', async () => { + const token = IS_ETH_BASED + ? utils.ETH_ADDRESS_IN_CONTRACTS + : await wallet.l2TokenAddress(utils.ETH_ADDRESS_IN_CONTRACTS); const result = await provider.estimateGasWithdraw({ - token: utils.ETH_ADDRESS, + token: token, amount: 7_000_000_000, - to: ADDRESS, - from: ADDRESS, + to: ADDRESS1, + from: ADDRESS1, paymasterParams: utils.getPaymasterParams(PAYMASTER, { type: 'ApprovalBased', - token: TOKEN, + token: APPROVAL_TOKEN, minimalAllowance: BigNumber.from(1), innerInput: new Uint8Array(), }), @@ -644,23 +700,23 @@ describe('Provider', () => { describe('#estimateGasTransfer()', () => { it('should return gas estimation of transfer transaction', async () => { const result = await provider.estimateGasTransfer({ - token: utils.ETH_ADDRESS, + token: utils.LEGACY_ETH_ADDRESS, amount: 7_000_000_000, - to: RECEIVER, - from: ADDRESS, + to: ADDRESS2, + from: ADDRESS1, }); expect(result.isZero()).to.be.false; }); it('should return a gas estimation of the transfer transaction with paymaster', async () => { const result = await provider.estimateGasTransfer({ - token: utils.ETH_ADDRESS, + token: utils.LEGACY_ETH_ADDRESS, amount: 7_000_000_000, - to: RECEIVER, - from: ADDRESS, + to: ADDRESS2, + from: ADDRESS1, paymasterParams: utils.getPaymasterParams(PAYMASTER, { type: 'ApprovalBased', - token: TOKEN, + token: APPROVAL_TOKEN, minimalAllowance: BigNumber.from(1), innerInput: new Uint8Array(), }), @@ -672,8 +728,8 @@ describe('Provider', () => { describe('#estimateGasL1()', () => { it('should return gas estimation of L1 transaction', async () => { const result = await provider.estimateGasL1({ - from: ADDRESS, - to: await provider.getMainContractAddress(), + from: ADDRESS1, + to: await provider.getBridgehubContractAddress(), value: 7_000_000_000, customData: { gasPerPubdata: 800, @@ -686,9 +742,9 @@ describe('Provider', () => { describe('#estimateL1ToL2Execute()', () => { it('should return gas estimation of L1 to L2 transaction', async () => { const result = await provider.estimateL1ToL2Execute({ - contractAddress: await provider.getMainContractAddress(), + contractAddress: await provider.getBridgehubContractAddress(), calldata: '0x', - caller: ADDRESS, + caller: ADDRESS1, l2Value: 7_000_000_000, }); expect(result.isZero()).to.be.false; @@ -698,8 +754,8 @@ describe('Provider', () => { describe('#estimateFee()', () => { it('should return gas estimation of transaction', async () => { const result = await provider.estimateFee({ - from: ADDRESS, - to: RECEIVER, + from: ADDRESS1, + to: ADDRESS2, value: BigNumber.from(7_000_000_000).toHexString(), }); expect(result).not.to.be.null; @@ -709,18 +765,18 @@ describe('Provider', () => { describe('#estimateGas()', () => { it('should return gas estimation of transaction', async () => { const result = await provider.estimateGas({ - from: ADDRESS, + from: ADDRESS1, to: await provider.l2TokenAddress(DAI_L1), - data: utils.IERC20.encodeFunctionData('approve', [RECEIVER, 1]), + data: utils.IERC20.encodeFunctionData('approve', [ADDRESS2, 1]), }); expect(result.isZero()).to.be.false; }); it('should return a gas estimation of the EIP712 transaction', async () => { const result = await provider.estimateGas({ - from: ADDRESS, + from: ADDRESS1, to: await provider.l2TokenAddress(DAI_L1), - data: utils.IERC20.encodeFunctionData('approve', [RECEIVER, 1]), + data: utils.IERC20.encodeFunctionData('approve', [ADDRESS2, 1]), customData: { gasPerPubdata: utils.DEFAULT_GAS_PER_PUBDATA_LIMIT, }, @@ -732,11 +788,11 @@ describe('Provider', () => { describe('#getFilterChanges()', () => { it('should return filtered logs', async () => { const filter = await provider.newFilter({ - address: utils.L2_ETH_TOKEN_ADDRESS, + address: utils.L2_BASE_TOKEN_ADDRESS, topics: [ethers.utils.id('Transfer(address,address,uint256)')], }); const result = await provider.getFilterChanges(filter); expect(result).not.to.be.null; - }); + }).timeout(10_000); }); }); diff --git a/tests/integration/signer.test.ts b/tests/integration/signer.test.ts index 059fa411..84c492bc 100644 --- a/tests/integration/signer.test.ts +++ b/tests/integration/signer.test.ts @@ -2,30 +2,34 @@ import * as chai from 'chai'; import '../custom-matchers'; import {Provider, utils, Wallet, L2VoidSigner, L1VoidSigner} from '../../src'; import {ethers, BigNumber} from 'ethers'; - -import TokensL1 from '../files/tokens.json'; +import {ITestnetErc20TokenFactory} from '../../src/typechain/ITestnetErc20TokenFactory'; +import {IS_ETH_BASED, ADDRESS1, PRIVATE_KEY1, DAI_L1, ADDRESS2} from '../utils'; const {expect} = chai; describe('L2VoidSigner', () => { - const ADDRESS = '0x36615Cf349d7F6344891B1e7CA7C72883F5dc049'; - const RECEIVER = '0xa61464658AfeAf65CccaaFD3a512b69A83B77618'; - const provider = Provider.getDefaultProvider(); - const signer = new L2VoidSigner(ADDRESS, provider); + const signer = new L2VoidSigner(ADDRESS1, provider); + + let baseToken: string; + + before('setup', async function () { + baseToken = await provider.getBaseTokenContractAddress(); + this.timeout(25_000); + }); describe('#constructor()', () => { it('`L2VoidSigner(address, provider)` should return a `L2VoidSigner` with L2 provider', async () => { - const signer = new L2VoidSigner(ADDRESS, provider); + const signer = new L2VoidSigner(ADDRESS1, provider); - expect(signer.address).to.be.equal(ADDRESS); + expect(signer.address).to.be.equal(ADDRESS1); expect(signer.provider).to.be.equal(provider); }); it('`L2VoidSigner(address)` should return a `L2VoidSigner` without L2 provider', async () => { - const signer = new L2VoidSigner(ADDRESS); + const signer = new L2VoidSigner(ADDRESS1); - expect(signer.address).to.be.equal(ADDRESS); + expect(signer.address).to.be.equal(ADDRESS1); expect(signer.provider).to.be.null; }); }); @@ -40,7 +44,8 @@ describe('L2VoidSigner', () => { describe('#getAllBalances()', () => { it('should return all balances', async () => { const result = await signer.getAllBalances(); - expect(Object.keys(result)).to.have.lengthOf(2); + const expected = IS_ETH_BASED ? 2 : 3; + expect(Object.keys(result)).to.have.lengthOf(expected); }); }); @@ -54,16 +59,16 @@ describe('L2VoidSigner', () => { describe('#getAddress()', () => { it('should return a `L2VoidSigner` address', async () => { const result = await signer.getAddress(); - expect(result).to.be.equal(ADDRESS); + expect(result).to.be.equal(ADDRESS1); }); }); describe('#connect()', () => { it('should return a `L2VoidSigner` with provided `provider` as L2 provider', async () => { - let signer = new L2VoidSigner(ADDRESS); + let signer = new L2VoidSigner(ADDRESS1); signer = signer.connect(provider); - expect(signer.address).to.be.equal(ADDRESS); + expect(signer.address).to.be.equal(ADDRESS1); expect(signer.provider).to.be.equal(provider); }); }); @@ -78,15 +83,17 @@ describe('L2VoidSigner', () => { describe('#populateTransaction()', () => { it('should return populated transaction with default values if are omitted', async () => { const tx = { - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, type: 2, - from: ADDRESS, + from: ADDRESS1, nonce: await signer.getNonce('pending'), chainId: 270, + maxFeePerGas: BigNumber.from(1_700_000_000), + maxPriorityFeePerGas: BigNumber.from(1_500_000_000), }; const result = await signer.populateTransaction({ - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, }); expect(result).to.be.deepEqualExcluding(tx, [ @@ -94,16 +101,17 @@ describe('L2VoidSigner', () => { 'maxFeePerGas', 'maxPriorityFeePerGas', ]); + expect(BigNumber.from(result.gasLimit).isZero()).to.be.false; expect(BigNumber.from(result.maxFeePerGas).isZero()).to.be.false; expect(BigNumber.from(result.maxPriorityFeePerGas).isZero()).to.be.false; }); it('should return populated transaction when `maxFeePerGas` and `maxPriorityFeePerGas` and `customData` are provided', async () => { const tx = { - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, type: 113, - from: ADDRESS, + from: ADDRESS1, nonce: await signer.getNonce('pending'), data: '0x', chainId: 270, @@ -115,7 +123,7 @@ describe('L2VoidSigner', () => { }, }; const result = await signer.populateTransaction({ - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, maxFeePerGas: BigNumber.from(3_500_000_000), maxPriorityFeePerGas: BigNumber.from(2_000_000_000), @@ -125,14 +133,15 @@ describe('L2VoidSigner', () => { }, }); expect(result).to.be.deepEqualExcluding(tx, ['gasLimit']); + expect(BigNumber.from(result.gasLimit).isZero()).to.be.false; }); it('should return populated transaction when `maxPriorityFeePerGas` and `customData` are provided', async () => { const tx = { - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, type: 113, - from: ADDRESS, + from: ADDRESS1, nonce: await signer.getNonce('pending'), data: '0x', chainId: 270, @@ -143,7 +152,7 @@ describe('L2VoidSigner', () => { }, }; const result = await signer.populateTransaction({ - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, maxPriorityFeePerGas: BigNumber.from(2_000_000_000), customData: { @@ -151,14 +160,15 @@ describe('L2VoidSigner', () => { }, }); expect(result).to.be.deepEqualExcluding(tx, ['gasLimit']); + expect(BigNumber.from(result.gasLimit).isZero()).to.be.false; }); it('should return populated transaction when `maxFeePerGas` and `customData` are provided', async () => { const tx = { - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, type: 113, - from: ADDRESS, + from: ADDRESS1, nonce: await signer.getNonce('pending'), data: '0x', chainId: 270, @@ -169,7 +179,7 @@ describe('L2VoidSigner', () => { }, }; const result = await signer.populateTransaction({ - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, maxFeePerGas: BigNumber.from(3_500_000_000), customData: { @@ -177,62 +187,67 @@ describe('L2VoidSigner', () => { }, }); expect(result).to.be.deepEqualExcluding(tx, ['gasLimit']); + expect(BigNumber.from(result.gasLimit).isZero()).to.be.false; }); it('should return populated EIP1559 transaction when `maxFeePerGas` and `maxPriorityFeePerGas` are provided', async () => { const tx = { - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, type: 2, - from: ADDRESS, + from: ADDRESS1, nonce: await signer.getNonce('pending'), chainId: 270, maxFeePerGas: BigNumber.from(3_500_000_000), maxPriorityFeePerGas: BigNumber.from(2_000_000_000), }; const result = await signer.populateTransaction({ - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, maxFeePerGas: BigNumber.from(3_500_000_000), maxPriorityFeePerGas: BigNumber.from(2_000_000_000), }); expect(result).to.be.deepEqualExcluding(tx, ['gasLimit']); + expect(BigNumber.from(result.gasLimit).isZero()).to.be.false; }); it('should return populated EIP1559 transaction with `maxFeePerGas` and `maxPriorityFeePerGas` same as provided `gasPrice`', async () => { const tx = { - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, type: 2, - from: ADDRESS, + from: ADDRESS1, nonce: await signer.getNonce('pending'), chainId: 270, maxFeePerGas: BigNumber.from(3_500_000_000), maxPriorityFeePerGas: BigNumber.from(3_500_000_000), }; const result = await signer.populateTransaction({ - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, gasPrice: BigNumber.from(3_500_000_000), }); expect(result).to.be.deepEqualExcluding(tx, ['gasLimit']); + expect(BigNumber.from(result.gasLimit).isZero()).to.be.false; }); it('should return populated legacy transaction when `type = 0`', async () => { const tx = { - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, type: 0, - from: ADDRESS, + from: ADDRESS1, nonce: await signer.getNonce('pending'), chainId: 270, + gasPrice: BigNumber.from(100_000_000), }; const result = await signer.populateTransaction({ type: 0, - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, }); expect(result).to.be.deepEqualExcluding(tx, ['gasLimit', 'gasPrice']); + expect(BigNumber.from(result.gasLimit).isZero()).to.be.false; expect(BigNumber.from(result.gasPrice).isZero()).to.be.false; }); }); @@ -241,7 +256,7 @@ describe('L2VoidSigner', () => { it('should throw an error when trying to send transaction', async () => { try { await signer.sendTransaction({ - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, maxFeePerGas: BigNumber.from(3_500_000_000), maxPriorityFeePerGas: BigNumber.from(2_000_000_000), @@ -258,7 +273,7 @@ describe('L2VoidSigner', () => { it('should throw an error when tyring to withdraw assets', async () => { try { await signer.withdraw({ - token: utils.ETH_ADDRESS, + token: utils.LEGACY_ETH_ADDRESS, to: await signer.getAddress(), amount: 7_000_000_000, }); @@ -274,8 +289,8 @@ describe('L2VoidSigner', () => { it('should throw an error when tyring to transfer assets', async () => { try { await signer.transfer({ - token: utils.ETH_ADDRESS, - to: RECEIVER, + token: baseToken, + to: ADDRESS2, amount: 7_000_000_000, }); } catch (e) { @@ -291,7 +306,7 @@ describe('L2VoidSigner', () => { try { await signer.signTransaction({ type: 2, - to: RECEIVER, + to: ADDRESS2, value: BigNumber.from(7_000_000_000), }); } catch (e) { @@ -304,36 +319,38 @@ describe('L2VoidSigner', () => { }); describe('L1VoidSigner', () => { - const ADDRESS = '0x36615Cf349d7F6344891B1e7CA7C72883F5dc049'; - const RECEIVER = '0xa61464658AfeAf65CccaaFD3a512b69A83B77618'; - const provider = Provider.getDefaultProvider(); const ethProvider = ethers.getDefaultProvider('http://localhost:8545'); - const signer = new L1VoidSigner(ADDRESS, ethProvider, provider); + const signer = new L1VoidSigner(ADDRESS1, ethProvider, provider); + + let baseToken: string; - const DAI_L1 = TokensL1[0].address; + before('setup', async function () { + this.timeout(25_000); + baseToken = await provider.getBaseTokenContractAddress(); + }); describe('#constructor()', () => { it('`L1VoidSigner(privateKey, providerL1, providerL2)` should return a `L1VoidSigner` with L1 and L2 provider', async () => { - const signer = new L1VoidSigner(ADDRESS, ethProvider, provider); + const signer = new L1VoidSigner(ADDRESS1, ethProvider, provider); - expect(signer.address).to.be.equal(ADDRESS); + expect(signer.address).to.be.equal(ADDRESS1); expect(signer.provider).to.be.equal(ethProvider); expect(signer.providerL2).to.be.equal(provider); }); it('`L1VoidSigner(privateKey, providerL1)` should return a `L1VoidSigner` with L1 provider', async () => { - const signer = new L1VoidSigner(ADDRESS, ethProvider); + const signer = new L1VoidSigner(ADDRESS1, ethProvider); - expect(signer.address).to.be.equal(ADDRESS); + expect(signer.address).to.be.equal(ADDRESS1); expect(signer.provider).to.be.equal(ethProvider); expect(signer.providerL2).to.be.undefined; }); it('`L1VoidSigner(privateKey)` should return a `L1VoidSigner` without providers', async () => { - const signer = new L1VoidSigner(ADDRESS); + const signer = new L1VoidSigner(ADDRESS1); - expect(signer.address).to.be.equal(ADDRESS); + expect(signer.address).to.be.equal(ADDRESS1); expect(signer.provider).to.be.null; expect(signer.providerL2).to.be.undefined; }); @@ -369,20 +386,27 @@ describe('L1VoidSigner', () => { describe('#l2TokenAddress()', () => { it('should return the L2 ETH address', async () => { - const result = await signer.l2TokenAddress(utils.ETH_ADDRESS); - expect(result).to.be.equal(utils.ETH_ADDRESS); + const result = await signer.l2TokenAddress(baseToken); + expect(result).to.be.equal(utils.L2_BASE_TOKEN_ADDRESS); }); it('should return the L2 DAI address', async () => { const result = await signer.l2TokenAddress(DAI_L1); expect(result).not.to.be.null; }); + + if (!IS_ETH_BASED) { + it('should return the L2 ETH address', async () => { + const result = await signer.l2TokenAddress(utils.LEGACY_ETH_ADDRESS); + expect(result).not.to.be.null; + }); + } }); describe('#approveERC20()', () => { it('should throw an error when approving token', async () => { try { - await signer.approveERC20(utils.ETH_ADDRESS, 5); + await signer.approveERC20(utils.LEGACY_ETH_ADDRESS, 5); } catch (e) { expect((e as Error).message).to.be.equal( "ETH token can't be approved! The address of the token does not exist on L1." @@ -408,24 +432,24 @@ describe('L1VoidSigner', () => { describe('#getAddress()', () => { it('should return a `L1VoidSigner` address', async () => { const result = await signer.getAddress(); - expect(result).to.be.equal(ADDRESS); + expect(result).to.be.equal(ADDRESS1); }); }); describe('#connect()', () => { it('should return a `L1VoidSigner` with provided `provider` as L1 provider', async () => { - let singer = new L1VoidSigner(ADDRESS); + let singer = new L1VoidSigner(ADDRESS1); singer = singer.connect(ethProvider); - expect(singer.address).to.be.equal(ADDRESS); + expect(singer.address).to.be.equal(ADDRESS1); expect(singer.provider).to.be.equal(ethProvider); }); }); describe('#connectL2()', () => { it('should return a `L1VoidSigner` with provided `provider` as L2 provider', async () => { - let singer = new L1VoidSigner(ADDRESS); + let singer = new L1VoidSigner(ADDRESS1); singer = singer.connectToL2(provider); - expect(singer.address).to.be.equal(ADDRESS); + expect(singer.address).to.be.equal(ADDRESS1); expect(singer.providerL2).to.be.equal(provider); }); }); @@ -433,15 +457,17 @@ describe('L1VoidSigner', () => { describe('#populateTransaction()', () => { it('should return populated transaction with default values if are omitted', async () => { const tx = { - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, type: 2, - from: ADDRESS, + from: ADDRESS1, nonce: await signer.getNonce('pending'), chainId: 9, + maxFeePerGas: BigNumber.from(1_500_000_002), + maxPriorityFeePerGas: BigNumber.from(1_500_000_000), }; const result = await signer.populateTransaction({ - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, }); expect(result).to.be.deepEqualExcluding(tx, [ @@ -449,64 +475,69 @@ describe('L1VoidSigner', () => { 'maxFeePerGas', 'maxPriorityFeePerGas', ]); + expect(BigNumber.from(result.gasLimit).isZero()).to.be.false; expect(BigNumber.from(result.maxFeePerGas).isZero()).to.be.false; expect(BigNumber.from(result.maxPriorityFeePerGas).isZero()).to.be.false; }); it('should return populated EIP1559 transaction when `maxFeePerGas` and `maxPriorityFeePerGas` are provided', async () => { const tx = { - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, type: 2, - from: ADDRESS, + from: ADDRESS1, nonce: await signer.getNonce('pending'), chainId: 9, maxFeePerGas: BigNumber.from(3_500_000_000), maxPriorityFeePerGas: BigNumber.from(2_000_000_000), }; const result = await signer.populateTransaction({ - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, maxFeePerGas: BigNumber.from(3_500_000_000), maxPriorityFeePerGas: BigNumber.from(2_000_000_000), }); expect(result).to.be.deepEqualExcluding(tx, ['gasLimit']); + expect(BigNumber.from(result.gasLimit).isZero()).to.be.false; }); it('should return populated EIP1559 transaction with `maxFeePerGas` and `maxPriorityFeePerGas` same as provided `gasPrice`', async () => { const tx = { - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, type: 2, - from: ADDRESS, + from: ADDRESS1, nonce: await signer.getNonce('pending'), chainId: 9, maxFeePerGas: BigNumber.from(3_500_000_000), maxPriorityFeePerGas: BigNumber.from(3_500_000_000), }; const result = await signer.populateTransaction({ - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, gasPrice: BigNumber.from(3_500_000_000), }); expect(result).to.be.deepEqualExcluding(tx, ['gasLimit']); + expect(BigNumber.from(result.gasLimit).isZero()).to.be.false; }); it('should return populated legacy transaction when `type = 0`', async () => { const tx = { - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, type: 0, - from: ADDRESS, + from: ADDRESS1, nonce: await signer.getNonce('pending'), chainId: 9, + gasPrice: BigNumber.from(1000000001), }; const result = await signer.populateTransaction({ type: 0, - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, }); expect(result).to.be.deepEqualExcluding(tx, ['gasLimit', 'gasPrice']); + expect(BigNumber.from(result.gasLimit).isZero()).to.be.false; expect(BigNumber.from(result.gasPrice).isZero()).to.be.false; }); }); @@ -515,7 +546,7 @@ describe('L1VoidSigner', () => { it('should throw an error when trying to send transaction', async () => { try { await signer.sendTransaction({ - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, maxFeePerGas: BigNumber.from(3_500_000_000), maxPriorityFeePerGas: BigNumber.from(2_000_000_000), @@ -529,118 +560,321 @@ describe('L1VoidSigner', () => { }); describe('#getDepositTx()', () => { - it('should return ETH deposit transaction', async () => { - const tx = { - contractAddress: ADDRESS, - calldata: '0x', - l2Value: 7_000_000, - token: '0x0000000000000000000000000000000000000000', - to: ADDRESS, - amount: 7_000_000, - refundRecipient: ADDRESS, - operatorTip: BigNumber.from(0), - gasPerPubdataByte: 800, - }; - const result = await signer.getDepositTx({ - token: utils.ETH_ADDRESS, - to: await signer.getAddress(), - amount: 7_000_000, - refundRecipient: await signer.getAddress(), + if (IS_ETH_BASED) { + it('should return ETH deposit transaction', async () => { + const tx = { + contractAddress: ADDRESS1, + calldata: '0x', + l2Value: 7_000_000, + l2GasLimit: BigNumber.from(355_704), + mintValue: BigNumber.from(95_595_457_000_000), + token: utils.ETH_ADDRESS_IN_CONTRACTS, + to: ADDRESS1, + amount: 7_000_000, + refundRecipient: ADDRESS1, + operatorTip: BigNumber.from(0), + overrides: { + maxFeePerGas: BigNumber.from(1_500_000_001), + maxPriorityFeePerGas: BigNumber.from(1_500_000_000), + value: BigNumber.from(95_595_457_000_000), + }, + gasPerPubdataByte: 800, + }; + const result = await signer.getDepositTx({ + token: utils.LEGACY_ETH_ADDRESS, + to: await signer.getAddress(), + amount: 7_000_000, + refundRecipient: await signer.getAddress(), + }); + expect(result).to.be.deepEqualExcluding(tx, [ + 'mintValue', + 'overrides', + 'l2GasLimit', + ]); + expect(BigNumber.from(result.mintValue).isZero()).to.be.false; + expect(BigNumber.from(result.overrides.maxPriorityFeePerGas).isZero()) + .to.be.false; + expect(BigNumber.from(result.overrides.maxFeePerGas).isZero()).to.be + .false; + expect(BigNumber.from(result.overrides.value).isZero()).to.be.false; + expect(BigNumber.from(result.l2GasLimit).isZero()).to.be.false; }); - expect(result).to.be.deepEqualExcluding(tx, ['overrides', 'l2GasLimit']); - expect(BigNumber.from(result.overrides.maxPriorityFeePerGas).isZero()).to - .be.false; - expect(BigNumber.from(result.overrides.maxFeePerGas).isZero()).to.be - .false; - expect(BigNumber.from(result.overrides.value).isZero()).to.be.false; - expect(BigNumber.from(result.l2GasLimit).isZero()).to.be.false; - }); - it('should return a deposit transaction with `tx.to == L1VoidSigner.getAddress()` when `tx.to` is not specified', async () => { - const tx = { - contractAddress: ADDRESS, - calldata: '0x', - l2Value: 7_000_000, - token: '0x0000000000000000000000000000000000000000', - to: ADDRESS, - amount: 7_000_000, - refundRecipient: ADDRESS, - operatorTip: BigNumber.from(0), - gasPerPubdataByte: 800, - }; - const result = await signer.getDepositTx({ - token: utils.ETH_ADDRESS, - amount: 7_000_000, - refundRecipient: await signer.getAddress(), + it('should return a deposit transaction with `tx.to == L1VoidSigner.getAddress()` when `tx.to` is not specified', async () => { + const tx = { + contractAddress: ADDRESS1, + calldata: '0x', + l2Value: 7_000_000, + l2GasLimit: BigNumber.from(355_704), + mintValue: BigNumber.from(95_595_457_000_000), + token: utils.ETH_ADDRESS_IN_CONTRACTS, + to: ADDRESS1, + amount: 7_000_000, + refundRecipient: ADDRESS1, + operatorTip: BigNumber.from(0), + overrides: { + maxFeePerGas: BigNumber.from(1_500_000_001), + maxPriorityFeePerGas: BigNumber.from(1_500_000_000), + value: BigNumber.from(95_595_457_000_000), + }, + gasPerPubdataByte: 800, + }; + const result = await signer.getDepositTx({ + token: utils.LEGACY_ETH_ADDRESS, + amount: 7_000_000, + refundRecipient: await signer.getAddress(), + }); + expect(result).to.be.deepEqualExcluding(tx, [ + 'mintValue', + 'overrides', + 'l2GasLimit', + ]); + expect(BigNumber.from(result.mintValue).isZero()).to.be.false; + expect(BigNumber.from(result.overrides.maxPriorityFeePerGas).isZero()) + .to.be.false; + expect(BigNumber.from(result.overrides.maxFeePerGas).isZero()).to.be + .false; + expect(BigNumber.from(result.overrides.value).isZero()).to.be.false; + expect(BigNumber.from(result.l2GasLimit).isZero()).to.be.false; }); - expect(result).to.be.deepEqualExcluding(tx, ['overrides', 'l2GasLimit']); - expect(BigNumber.from(result.overrides.maxPriorityFeePerGas).isZero()).to - .be.false; - expect(BigNumber.from(result.overrides.maxFeePerGas).isZero()).to.be - .false; - expect(BigNumber.from(result.overrides.value).isZero()).to.be.false; - expect(BigNumber.from(result.l2GasLimit).isZero()).to.be.false; - }); - it('should return DAI deposit transaction', async () => { - const tx = { - from: ADDRESS, - to: (await signer.getL1BridgeContracts()).erc20.address, - }; - const result = await signer.getDepositTx({ - token: DAI_L1, - to: await signer.getAddress(), - amount: 5, - refundRecipient: await signer.getAddress(), + it('should return DAI deposit transaction', async () => { + const tx = { + maxFeePerGas: BigNumber.from(1_500_000_001), + maxPriorityFeePerGas: BigNumber.from(1_500_000_000), + value: BigNumber.from(107_602_662_500_000), + from: ADDRESS1, + to: (await provider.getBridgehubContractAddress()).toLowerCase(), + }; + const result = await signer.getDepositTx({ + token: DAI_L1, + to: await signer.getAddress(), + amount: 5, + refundRecipient: await signer.getAddress(), + }); + result.to = result.to.toLowerCase(); + expect(result).to.be.deepEqualExcluding(tx, [ + 'data', + 'maxFeePerGas', + 'maxPriorityFeePerGas', + 'value', + ]); + expect(BigNumber.from(result.maxFeePerGas).isZero()).to.be.false; + expect(BigNumber.from(result.maxPriorityFeePerGas).isZero()).to.be + .false; + expect(BigNumber.from(result.value).isZero()).to.be.false; }); - result.to = result.to.toLowerCase(); - expect(result).to.be.deepEqualExcluding(tx, [ - 'data', - 'maxFeePerGas', - 'maxPriorityFeePerGas', - 'value', - ]); - expect(BigNumber.from(result.maxFeePerGas).isZero()).to.be.false; - expect(BigNumber.from(result.maxPriorityFeePerGas).isZero()).to.be.false; - expect(BigNumber.from(result.value).isZero()).to.be.false; - }); + } else { + it('should return ETH deposit transaction', async () => { + const tx = { + from: ADDRESS1, + to: (await provider.getBridgehubContractAddress()).toLowerCase(), + value: BigNumber.from(7_000_000), + data: '0x24fd57fb0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000010e0000000000000000000000000000000000000000000000000000bf1aaa17ee7000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000062e3d000000000000000000000000000000000000000000000000000000000000032000000000000000000000000036615cf349d7f6344891b1e7ca7c72883f5dc049000000000000000000000000842deab39809094bf5e4b77a7f97ae308adc5e5500000000000000000000000000000000000000000000000000000000006acfc0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000036615cf349d7f6344891b1e7ca7c72883f5dc049', + maxFeePerGas: BigNumber.from(1_500_000_001), + maxPriorityFeePerGas: BigNumber.from(1_500_000_000), + }; + const result = await signer.getDepositTx({ + token: utils.LEGACY_ETH_ADDRESS, + to: await signer.getAddress(), + amount: 7_000_000, + refundRecipient: await signer.getAddress(), + }); + result.to = result.to.toLowerCase(); + expect(result).to.be.deepEqualExcluding(tx, [ + 'data', + 'maxFeePerGas', + 'maxPriorityFeePerGas', + 'value', + ]); + expect(BigNumber.from(result.maxFeePerGas).isZero()).to.be.false; + expect(BigNumber.from(result.maxPriorityFeePerGas).isZero()).to.be + .false; + expect(BigNumber.from(result.value).isZero()).to.be.false; + }); + + it('should return a deposit transaction with `tx.to == Wallet.getAddress()` when `tx.to` is not specified', async () => { + const tx = { + from: ADDRESS1, + to: (await provider.getBridgehubContractAddress()).toLowerCase(), + value: BigNumber.from(7_000_000), + maxFeePerGas: BigNumber.from(1_500_000_001), + maxPriorityFeePerGas: BigNumber.from(1_500_000_000), + }; + const result = await signer.getDepositTx({ + token: utils.LEGACY_ETH_ADDRESS, + amount: 7_000_000, + refundRecipient: await signer.getAddress(), + }); + result.to = result.to.toLowerCase(); + expect(result).to.be.deepEqualExcluding(tx, [ + 'data', + 'maxFeePerGas', + 'maxPriorityFeePerGas', + 'value', + ]); + expect(BigNumber.from(result.maxFeePerGas).isZero()).to.be.false; + expect(BigNumber.from(result.maxPriorityFeePerGas).isZero()).to.be + .false; + expect(BigNumber.from(result.value).isZero()).to.be.false; + }); + + it('should return DAI deposit transaction', async () => { + const tx = { + maxFeePerGas: BigNumber.from(1_500_000_001), + maxPriorityFeePerGas: BigNumber.from(1_500_000_000), + from: ADDRESS1, + to: (await provider.getBridgehubContractAddress()).toLowerCase(), + }; + + const result = await signer.getDepositTx({ + token: DAI_L1, + to: await signer.getAddress(), + amount: 5, + refundRecipient: await signer.getAddress(), + }); + result.to = result.to.toLowerCase(); + expect(result).to.be.deepEqualExcluding(tx, [ + 'data', + 'maxFeePerGas', + 'maxPriorityFeePerGas', + ]); + expect(BigNumber.from(result.maxFeePerGas).isZero()).to.be.false; + expect(BigNumber.from(result.maxPriorityFeePerGas).isZero()).to.be + .false; + }); + } }); describe('#estimateGasDeposit()', () => { - it('should return gas estimation for ETH deposit transaction', async () => { - const result = await signer.estimateGasDeposit({ - token: utils.ETH_ADDRESS, - to: await signer.getAddress(), - amount: 5, - refundRecipient: await signer.getAddress(), + if (IS_ETH_BASED) { + it('should return gas estimation for ETH deposit transaction', async () => { + const result = await signer.estimateGasDeposit({ + token: utils.LEGACY_ETH_ADDRESS, + to: await signer.getAddress(), + amount: 5, + refundRecipient: await signer.getAddress(), + }); + expect(result.isZero()).to.be.false; }); - expect(result.isZero()).to.be.false; - }); - it('should return gas estimation for DAI deposit transaction', async () => { - const wallet = new Wallet( - '0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110', - provider, - ethProvider - ); - const tx = await wallet.approveERC20(DAI_L1, 5); - await tx.wait(); - - const result = await signer.estimateGasDeposit({ - token: DAI_L1, - to: await signer.getAddress(), - amount: 5, - refundRecipient: await signer.getAddress(), - }); - expect(result.isZero()).to.be.false; - }).timeout(10_000); + it('should return gas estimation for DAI deposit transaction', async () => { + const wallet = new Wallet(PRIVATE_KEY1, provider, ethProvider); + await (await wallet.approveERC20(DAI_L1, 5)).wait(); + + const result = await signer.estimateGasDeposit({ + token: DAI_L1, + to: await signer.getAddress(), + amount: 5, + refundRecipient: await signer.getAddress(), + }); + expect(result.isZero()).to.be.false; + }).timeout(10_000); + } else { + it('should throw an error for insufficient allowance when estimating gas for ETH deposit transaction', async () => { + try { + await signer.estimateGasDeposit({ + token: utils.LEGACY_ETH_ADDRESS, + to: await signer.getAddress(), + amount: 5, + refundRecipient: await signer.getAddress(), + }); + } catch (e) { + expect((e as any).reason).to.include('ERC20: insufficient allowance'); + } + }).timeout(10_000); + + it('should return gas estimation for ETH deposit transaction', async () => { + const wallet = new Wallet(PRIVATE_KEY1, provider, ethProvider); + + const token = utils.LEGACY_ETH_ADDRESS; + const amount = 5; + const approveParams = await signer.getDepositAllowanceParams( + token, + amount + ); + + await ( + await wallet.approveERC20( + approveParams[0].token, + approveParams[0].allowance + ) + ).wait(); + + const result = await signer.estimateGasDeposit({ + token: token, + to: await signer.getAddress(), + amount: amount, + refundRecipient: await signer.getAddress(), + }); + expect(result.isZero()).to.be.false; + }).timeout(10_000); + + it('should return gas estimation for base token deposit transaction', async () => { + const wallet = new Wallet(PRIVATE_KEY1, provider, ethProvider); + + const token = await signer.getBaseToken(); + const amount = 5; + const approveParams = await signer.getDepositAllowanceParams( + token, + amount + ); + + await ( + await wallet.approveERC20( + approveParams[0].token, + approveParams[0].allowance + ) + ).wait(); + + const result = await signer.estimateGasDeposit({ + token: token, + to: await signer.getAddress(), + amount: amount, + refundRecipient: await signer.getAddress(), + }); + expect(result.isZero()).to.be.false; + }).timeout(10_000); + + it('should return gas estimation for DAI deposit transaction', async () => { + const wallet = new Wallet(PRIVATE_KEY1, provider, ethProvider); + + const token = DAI_L1; + const amount = 5; + const approveParams = await signer.getDepositAllowanceParams( + token, + amount + ); + + await ( + await wallet.approveERC20( + approveParams[0].token, + approveParams[0].allowance + ) + ).wait(); + await ( + await wallet.approveERC20( + approveParams[1].token, + approveParams[1].allowance + ) + ).wait(); + + const result = await signer.estimateGasDeposit({ + token: token, + to: await signer.getAddress(), + amount: amount, + refundRecipient: await signer.getAddress(), + }); + expect(result.isZero()).to.be.false; + }).timeout(10_000); + } }); describe('#deposit()', () => { it('should throw an error when trying to deposit assets', async () => { try { await signer.deposit({ - token: utils.ETH_ADDRESS, + token: utils.LEGACY_ETH_ADDRESS, to: await signer.getAddress(), amount: 7_000_000_000, refundRecipient: await signer.getAddress(), @@ -657,7 +891,7 @@ describe('L1VoidSigner', () => { it('should throw an error when trying to claim successful deposit', async () => { try { const response = await signer.deposit({ - token: utils.ETH_ADDRESS, + token: utils.LEGACY_ETH_ADDRESS, to: await signer.getAddress(), amount: 7_000_000_000, refundRecipient: await signer.getAddress(), @@ -674,78 +908,244 @@ describe('L1VoidSigner', () => { }); describe('#getFullRequiredDepositFee()', () => { - it('should return fee for ETH token deposit', async () => { - const result = await signer.getFullRequiredDepositFee({ - token: utils.ETH_ADDRESS, - to: await signer.getAddress(), - }); - expect(BigNumber.from(result.baseCost).isZero()).to.be.false; - expect(BigNumber.from(result.l1GasLimit).isZero()).to.be.false; - expect(BigNumber.from(result.l2GasLimit).isZero()).to.be.false; - expect(BigNumber.from(result.maxFeePerGas).isZero()).to.be.false; - expect(BigNumber.from(result.maxPriorityFeePerGas).isZero()).to.be.false; - }); - - it('should throw an error when there is not enough allowance to cover the deposit', async () => { - try { - await signer.getFullRequiredDepositFee({ + if (IS_ETH_BASED) { + it('should return fee for ETH token deposit', async () => { + const result = await signer.getFullRequiredDepositFee({ + token: utils.LEGACY_ETH_ADDRESS, + to: await signer.getAddress(), + }); + expect(BigNumber.from(result.baseCost).isZero()).to.be.false; + expect(BigNumber.from(result.l1GasLimit).isZero()).to.be.false; + expect(BigNumber.from(result.l2GasLimit).isZero()).to.be.false; + expect(BigNumber.from(result.maxFeePerGas).isZero()).to.be.false; + expect(BigNumber.from(result.maxPriorityFeePerGas).isZero()).to.be + .false; + }).timeout(10_000); + + it('should throw an error when there is not enough allowance to cover the deposit', async () => { + try { + await signer.getFullRequiredDepositFee({ + token: DAI_L1, + to: await signer.getAddress(), + }); + } catch (e) { + expect((e as Error).message).to.be.equal( + 'Not enough allowance to cover the deposit!' + ); + } + }).timeout(10_000); + + it('should return fee for DAI token deposit', async () => { + const wallet = new Wallet(PRIVATE_KEY1, provider, ethProvider); + const tx = await wallet.approveERC20(DAI_L1, 5); + await tx.wait(); + + const result = await signer.getFullRequiredDepositFee({ token: DAI_L1, to: await signer.getAddress(), }); - } catch (e) { - expect((e as Error).message).to.be.equal( - 'Not enough allowance to cover the deposit!' + expect(BigNumber.from(result.baseCost).isZero()).to.be.false; + expect(BigNumber.from(result.l1GasLimit).isZero()).to.be.false; + expect(BigNumber.from(result.l2GasLimit).isZero()).to.be.false; + expect(BigNumber.from(result.maxFeePerGas).isZero()).to.be.false; + expect(BigNumber.from(result.maxPriorityFeePerGas).isZero()).to.be + .false; + }).timeout(10_000); + + it('should throw an error when there is not enough balance for the deposit', async () => { + try { + await new L1VoidSigner( + ethers.Wallet.createRandom().address, + ethProvider, + provider + ).getFullRequiredDepositFee({ + token: DAI_L1, + to: await signer.getAddress(), + }); + } catch (e) { + expect((e as Error).message).to.include( + 'Not enough balance for deposit!' + ); + } + }).timeout(10_000); + } else { + it('should throw an error when there is not enough base token allowance to cover the deposit', async () => { + try { + await new L1VoidSigner( + ethers.Wallet.createRandom().address, + ethProvider, + provider + ).getFullRequiredDepositFee({ + token: utils.LEGACY_ETH_ADDRESS, + to: await signer.getAddress(), + }); + } catch (e) { + expect((e as Error).message).to.be.equal( + 'Not enough base token allowance to cover the deposit!' + ); + } + }).timeout(10_000); + + it('should return fee for ETH token deposit', async () => { + const wallet = new Wallet(PRIVATE_KEY1, provider, ethProvider); + const token = utils.LEGACY_ETH_ADDRESS; + const approveParams = await signer.getDepositAllowanceParams(token, 1); + + await ( + await wallet.approveERC20( + approveParams[0].token, + approveParams[0].allowance + ) + ).wait(); + + const result = await signer.getFullRequiredDepositFee({ + token: token, + to: await signer.getAddress(), + }); + expect(BigNumber.from(result.baseCost).isZero()).to.be.false; + expect(BigNumber.from(result.l1GasLimit).isZero()).to.be.false; + expect(BigNumber.from(result.l2GasLimit).isZero()).to.be.false; + expect(BigNumber.from(result.maxFeePerGas).isZero()).to.be.false; + expect(BigNumber.from(result.maxPriorityFeePerGas).isZero()).to.be + .false; + }).timeout(10_000); + + it('should return fee for base token deposit', async () => { + const wallet = new Wallet(PRIVATE_KEY1, provider, ethProvider); + const token = await signer.getBaseToken(); + const approveParams = await signer.getDepositAllowanceParams(token, 1); + + await ( + await wallet.approveERC20( + approveParams[0].token, + approveParams[0].allowance + ) + ).wait(); + + const result = await signer.getFullRequiredDepositFee({ + token: token, + to: await signer.getAddress(), + }); + expect(result).not.to.be.null; + }).timeout(10_000); + + it('should return fee for DAI token deposit', async () => { + const wallet = new Wallet(PRIVATE_KEY1, provider, ethProvider); + const token = DAI_L1; + const approveParams = await signer.getDepositAllowanceParams(token, 1); + + await ( + await wallet.approveERC20( + approveParams[0].token, + approveParams[0].allowance + ) + ).wait(); + await ( + await wallet.approveERC20( + approveParams[1].token, + approveParams[1].allowance + ) + ).wait(); + + const result = await signer.getFullRequiredDepositFee({ + token: token, + to: await signer.getAddress(), + }); + expect(BigNumber.from(result.baseCost).isZero()).to.be.false; + expect(BigNumber.from(result.l1GasLimit).isZero()).to.be.false; + expect(BigNumber.from(result.l2GasLimit).isZero()).to.be.false; + expect(BigNumber.from(result.maxFeePerGas).isZero()).to.be.false; + expect(BigNumber.from(result.maxPriorityFeePerGas).isZero()).to.be + .false; + }).timeout(10_000); + + it('should throw an error when there is not enough token allowance to cover the deposit', async () => { + const wallet = new Wallet(PRIVATE_KEY1, provider, ethProvider); + + const token = DAI_L1; + const randomWallet = Wallet.createRandom() + .connectToL1(ethProvider) + .connect(provider); + + // mint base token to random wallet + const baseToken = ITestnetErc20TokenFactory.connect( + await wallet.getBaseToken(), + wallet._signerL1() ); - } - }).timeout(10_000); - - it('should return fee for DAI token deposit', async () => { - const result = await signer.getFullRequiredDepositFee({ - token: DAI_L1, - to: await signer.getAddress(), - }); - expect(BigNumber.from(result.baseCost).isZero()).to.be.false; - expect(BigNumber.from(result.l1GasLimit).isZero()).to.be.false; - expect(BigNumber.from(result.l2GasLimit).isZero()).to.be.false; - expect(BigNumber.from(result.maxFeePerGas).isZero()).to.be.false; - expect(BigNumber.from(result.maxPriorityFeePerGas).isZero()).to.be.false; - }).timeout(10_000); - - it('should throw an error when there is not enough balance for the deposit', async () => { - try { - const randomSigner = new L1VoidSigner( - ethers.Wallet.createRandom().address, - ethProvider, - provider + const baseTokenMintTx = await baseToken.mint( + await randomWallet.getAddress(), + ethers.utils.parseEther('0.5') ); - - await randomSigner.getFullRequiredDepositFee({ - token: DAI_L1, - to: await randomSigner.getAddress(), + await baseTokenMintTx.wait(); + + // transfer ETH to random wallet so that base token approval tx can be performed + const transferTx = await new ethers.Wallet( + PRIVATE_KEY1, + ethProvider + ).sendTransaction({ + to: await randomWallet.getAddress(), + value: ethers.utils.parseEther('0.1'), }); - } catch (e) { - expect((e as Error).message).to.include( - 'Not enough balance for deposit!' + await transferTx.wait(); + + const approveParams = await randomWallet.getDepositAllowanceParams( + token, + 1 ); - } - }).timeout(10_000); + // only approve base token + await ( + await randomWallet.approveERC20( + approveParams[0].token, + approveParams[0].allowance + ) + ).wait(); + + try { + await new L1VoidSigner( + randomWallet.address, + ethProvider, + provider + ).getFullRequiredDepositFee({ + token: token, + to: await wallet.getAddress(), + }); + } catch (e) { + expect((e as Error).message).to.be.equal( + 'Not enough token allowance to cover the deposit!' + ); + } + }).timeout(20_000); + } }); describe('#getRequestExecuteTx()', () => { - it('should return request execute transaction', async () => { - const result = await signer.getRequestExecuteTx({ - contractAddress: await provider.getMainContractAddress(), - calldata: '0x', - l2Value: 7_000_000_000, + const amount = 7_000_000_000; + if (IS_ETH_BASED) { + it('should return request execute transaction', async () => { + const result = await signer.getRequestExecuteTx({ + contractAddress: await provider.getBridgehubContractAddress(), + calldata: '0x', + l2Value: amount, + }); + expect(result).not.to.be.null; }); - expect(result).not.to.be.null; - }); + } else { + it('should return request execute transaction', async () => { + const result = await signer.getRequestExecuteTx({ + contractAddress: await signer.getAddress(), + calldata: '0x', + l2Value: amount, + overrides: {nonce: 0}, + }); + expect(result).not.to.be.null; + }); + } }); describe('#estimateGasRequestExecute()', () => { it('should return gas estimation for request execute transaction', async () => { const result = await signer.estimateGasRequestExecute({ - contractAddress: await provider.getMainContractAddress(), + contractAddress: await provider.getBridgehubContractAddress(), calldata: '0x', l2Value: 7_000_000_000, }); @@ -754,27 +1154,67 @@ describe('L1VoidSigner', () => { }); describe('#requestExecute()', () => { - it('should request transaction execution on L2 network', async () => { - try { - await signer.requestExecute({ - contractAddress: await provider.getMainContractAddress(), + if (IS_ETH_BASED) { + it('should request transaction execution on L2 network', async () => { + try { + await signer.requestExecute({ + contractAddress: await provider.getBridgehubContractAddress(), + calldata: '0x', + l2Value: 7_000_000_000, + l2GasLimit: 900_000, + }); + } catch (e) { + expect((e as Error).message).to.contain( + 'VoidSigner cannot sign transactions' + ); + } + }).timeout(10_000); + } else { + it('should request transaction execution on L2 network', async () => { + const wallet = new Wallet(PRIVATE_KEY1, provider, ethProvider); + + const amount = 7_000_000_000; + const request = { + contractAddress: await signer.getAddress(), calldata: '0x', - l2Value: 7_000_000_000, - l2GasLimit: 900_000, - }); - } catch (e) { - expect((e as Error).message).to.contain( - 'VoidSigner cannot sign transactions' - ); - } - }).timeout(10_000); + l2Value: amount, + l2GasLimit: BigNumber.from(1_319_957), + operatorTip: 0, + gasPerPubdataByte: 800, + refundRecipient: await signer.getAddress(), + overrides: { + maxFeePerGas: BigNumber.from(1_500_000_010), + maxPriorityFeePerGas: BigNumber.from(1_500_000_000), + gasLimit: BigNumber.from(238_654), + value: 0, + }, + }; + + const approveParams = + await signer.getRequestExecuteAllowanceParams(request); + await ( + await wallet.approveERC20( + approveParams.token, + approveParams.allowance + ) + ).wait(); + + try { + await signer.requestExecute(request); + } catch (e) { + expect((e as Error).message).to.contain( + 'VoidSigner cannot sign transactions' + ); + } + }).timeout(10_000); + } }); describe('#signTransaction()', () => { it('should throw an error when trying to send transaction', async () => { try { await signer.sendTransaction({ - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, maxFeePerGas: BigNumber.from(3_500_000_000), maxPriorityFeePerGas: BigNumber.from(2_000_000_000), diff --git a/tests/integration/smart-account.test.ts b/tests/integration/smart-account.test.ts index 50b672c5..71b3268e 100644 --- a/tests/integration/smart-account.test.ts +++ b/tests/integration/smart-account.test.ts @@ -10,46 +10,46 @@ import { } from '../../src'; import {BigNumber, ethers} from 'ethers'; import {ECDSASmartAccount, MultisigECDSASmartAccount} from '../../src'; +import { + IS_ETH_BASED, + ADDRESS1, + PRIVATE_KEY1, + ADDRESS2, + PRIVATE_KEY2, + APPROVAL_TOKEN, + PAYMASTER, + DAI_L1, +} from '../utils'; const {expect} = chai; -import TokensL1 from '../files/tokens.json'; import MultisigAccount from '../files/TwoUserMultisig.json'; describe('SmartAccount', async () => { - const ADDRESS = '0x36615Cf349d7F6344891B1e7CA7C72883F5dc049'; - const PRIVATE_KEY = - '0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110'; - const RECEIVER = '0xa61464658AfeAf65CccaaFD3a512b69A83B77618'; - const provider = Provider.getDefaultProvider(types.Network.Localhost); const ethProvider = ethers.getDefaultProvider('http://localhost:8545'); - const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider); + ethProvider.pollingInterval = 300; + const wallet = new Wallet(PRIVATE_KEY1, provider, ethProvider); const account = new SmartAccount( - {address: ADDRESS, secret: PRIVATE_KEY}, + {address: ADDRESS1, secret: PRIVATE_KEY1}, provider ); - const DAI_L1 = TokensL1[0].address; - - const TOKEN = '0x841c43Fa5d8fFfdB9efE3358906f7578d8700Dd4'; - const PAYMASTER = '0xa222f0c183AFA73a8Bc1AFb48D34C88c9Bf7A174'; - describe('#constructor()', () => { it('`SmartAccount(address, {address, secret}, provider)` should return a `SmartAccount` with signer and provider', () => { const account = new SmartAccount( - {address: ADDRESS, secret: PRIVATE_KEY}, + {address: ADDRESS1, secret: PRIVATE_KEY1}, provider ); - expect(account.address).to.be.equal(ADDRESS); - expect(account.secret).to.be.equal(PRIVATE_KEY); + expect(account.address).to.be.equal(ADDRESS1); + expect(account.secret).to.be.equal(PRIVATE_KEY1); expect(account.provider).to.be.equal(provider); }); it('`SmartWallet(address, {address, secret, payloadSigner, transactionBuilder}, provider)` should return a `SmartAccount` with custom payload signing method', async () => { const account = new SmartAccount( { - address: ADDRESS, - secret: PRIVATE_KEY, + address: ADDRESS1, + secret: PRIVATE_KEY1, payloadSigner: async () => { return '0x'; }, @@ -60,8 +60,8 @@ describe('SmartAccount', async () => { provider ); - expect(account.address).to.be.equal(ADDRESS); - expect(account.secret).to.be.equal(PRIVATE_KEY); + expect(account.address).to.be.equal(ADDRESS1); + expect(account.secret).to.be.equal(PRIVATE_KEY1); expect(account.provider).to.be.equal(provider); }); }); @@ -70,12 +70,12 @@ describe('SmartAccount', async () => { it('should return a `SmartAccount` with provided `provider` as a provider', async () => { const newProvider = Provider.getDefaultProvider(types.Network.Localhost); let account = new SmartAccount( - {address: ADDRESS, secret: PRIVATE_KEY}, + {address: ADDRESS1, secret: PRIVATE_KEY1}, provider ); account = account.connect(newProvider); - expect(account.address).to.be.equal(ADDRESS); - expect(account.secret).to.be.equal(PRIVATE_KEY); + expect(account.address).to.be.equal(ADDRESS1); + expect(account.secret).to.be.equal(PRIVATE_KEY1); expect(account.provider).to.be.equal(newProvider); }); }); @@ -83,25 +83,26 @@ describe('SmartAccount', async () => { describe('#getAddress()', () => { it('should return the `SmartAccount` address', async () => { const account = new SmartAccount( - {address: ADDRESS, secret: PRIVATE_KEY}, + {address: ADDRESS1, secret: PRIVATE_KEY1}, provider ); const result = await account.getAddress(); - expect(result).to.be.equal(ADDRESS); + expect(result).to.be.equal(ADDRESS1); }); }); describe('#getBalance()', () => { it('should return a `SmartAccount` balance', async () => { const result = await account.getBalance(); - expect(result.gte(0)).to.be.true; + expect(result.isZero()).to.be.false; }); }); describe('#getAllBalances()', () => { it('should return all balances', async () => { const result = await account.getAllBalances(); - expect(Object.keys(result)).to.have.lengthOf(2); + const expected = IS_ETH_BASED ? 2 : 3; + expect(Object.keys(result)).to.have.lengthOf(expected); }); }); @@ -115,51 +116,54 @@ describe('SmartAccount', async () => { describe('#populateTransaction()', () => { it('should return a populated transaction', async () => { const tx = { - to: '0xa61464658AfeAf65CccaaFD3a512b69A83B77618', + to: ADDRESS2, value: BigNumber.from(7_000_000_000), type: utils.EIP712_TX_TYPE, - from: '0x36615Cf349d7F6344891B1e7CA7C72883F5dc049', + from: ADDRESS1, nonce: await account.getNonce('pending'), + gasLimit: BigNumber.from(156_726), chainId: 270, data: '0x', customData: {gasPerPubdata: 50_000, factoryDeps: []}, + gasPrice: BigNumber.from(100_000_000), }; const result = await account.populateTransaction({ type: utils.EIP712_TX_TYPE, - to: RECEIVER, + to: ADDRESS2, value: 7_000_000_000, }); expect(result).to.be.deepEqualExcluding(tx, ['gasLimit', 'gasPrice']); - expect(BigNumber.from(result.gasPrice!).gt(BigNumber.from(0))).to.be.true; - expect(BigNumber.from(result.gasLimit!).gt(BigNumber.from(0))).to.be.true; + expect(BigNumber.from(result.gasPrice).isZero()).to.be.false; + expect(BigNumber.from(result.gasLimit).isZero()).to.be.false; }).timeout(25_000); it('should return a populated transaction with default values if are omitted', async () => { const tx = { - to: RECEIVER, + to: ADDRESS2, value: BigNumber.from(7_000_000), type: utils.EIP712_TX_TYPE, - from: '0x36615Cf349d7F6344891B1e7CA7C72883F5dc049', + from: ADDRESS1, nonce: await account.getNonce('pending'), chainId: 270, + gasPrice: BigNumber.from(100_000_000), data: '0x', customData: {gasPerPubdata: 50_000, factoryDeps: []}, }; const result = await account.populateTransaction({ - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, }); expect(result).to.be.deepEqualExcluding(tx, ['gasLimit', 'gasPrice']); - expect(BigNumber.from(result.gasPrice!).gt(BigNumber.from(0))).to.be.true; - expect(BigNumber.from(result.gasLimit!).gt(BigNumber.from(0))).to.be.true; + expect(BigNumber.from(result.gasPrice).isZero()).to.be.false; + expect(BigNumber.from(result.gasLimit).isZero()).to.be.false; }); }); describe('#signTransaction()', () => { it('should return a signed EIP712 transaction', async () => { const result = await account.signTransaction({ - to: RECEIVER, + to: ADDRESS2, value: ethers.utils.parseEther('1'), }); expect(result).not.to.be.null; @@ -196,14 +200,14 @@ describe('SmartAccount', async () => { describe('#transfer()', () => { it('should transfer ETH', async () => { const amount = 7_000_000_000; - const balanceBeforeTransfer = await provider.getBalance(RECEIVER); + const balanceBeforeTransfer = await provider.getBalance(ADDRESS2); const tx = await account.transfer({ token: utils.ETH_ADDRESS, - to: RECEIVER, + to: ADDRESS2, amount: amount, }); const result = await tx.wait(); - const balanceAfterTransfer = await provider.getBalance(RECEIVER); + const balanceAfterTransfer = await provider.getBalance(ADDRESS2); expect(result).not.to.be.null; expect(balanceAfterTransfer.sub(balanceBeforeTransfer).eq(amount)).to.be .true; @@ -218,20 +222,20 @@ describe('SmartAccount', async () => { const paymasterTokenBalanceBeforeTransfer = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const senderBalanceBeforeTransfer = await account.getBalance(); const senderApprovalTokenBalanceBeforeTransfer = - await account.getBalance(TOKEN); - const receiverBalanceBeforeTransfer = await provider.getBalance(RECEIVER); + await account.getBalance(APPROVAL_TOKEN); + const receiverBalanceBeforeTransfer = await provider.getBalance(ADDRESS2); const tx = await account.transfer({ token: utils.ETH_ADDRESS, - to: RECEIVER, + to: ADDRESS2, amount: amount, paymasterParams: utils.getPaymasterParams(PAYMASTER, { type: 'ApprovalBased', - token: TOKEN, + token: APPROVAL_TOKEN, minimalAllowance: minimalAllowance, innerInput: new Uint8Array(), }), @@ -243,12 +247,12 @@ describe('SmartAccount', async () => { const paymasterTokenBalanceAfterTransfer = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const senderBalanceAfterTransfer = await account.getBalance(); const senderApprovalTokenBalanceAfterTransfer = - await account.getBalance(TOKEN); - const receiverBalanceAfterTransfer = await provider.getBalance(RECEIVER); + await account.getBalance(APPROVAL_TOKEN); + const receiverBalanceAfterTransfer = await provider.getBalance(ADDRESS2); expect( paymasterBalanceBeforeTransfer.sub(paymasterBalanceAfterTransfer).gte(0) @@ -280,18 +284,18 @@ describe('SmartAccount', async () => { const amount = 5; const l2DAI = await provider.l2TokenAddress(DAI_L1); const balanceBeforeTransfer = await provider.getBalance( - RECEIVER, + ADDRESS2, 'latest', l2DAI ); const tx = await account.transfer({ token: l2DAI, - to: RECEIVER, + to: ADDRESS2, amount: amount, }); const result = await tx.wait(); const balanceAfterTransfer = await provider.getBalance( - RECEIVER, + ADDRESS2, 'latest', l2DAI ); @@ -310,24 +314,24 @@ describe('SmartAccount', async () => { const paymasterTokenBalanceBeforeTransfer = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const senderBalanceBeforeTransfer = await account.getBalance(l2DAI); const senderApprovalTokenBalanceBeforeTransfer = - await account.getBalance(TOKEN); + await account.getBalance(APPROVAL_TOKEN); const receiverBalanceBeforeTransfer = await provider.getBalance( - RECEIVER, + ADDRESS2, 'latest', l2DAI ); const tx = await account.transfer({ token: l2DAI, - to: RECEIVER, + to: ADDRESS2, amount: amount, paymasterParams: utils.getPaymasterParams(PAYMASTER, { type: 'ApprovalBased', - token: TOKEN, + token: APPROVAL_TOKEN, minimalAllowance: minimalAllowance, innerInput: new Uint8Array(), }), @@ -339,13 +343,13 @@ describe('SmartAccount', async () => { const paymasterTokenBalanceAfterTransfer = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const senderBalanceAfterTransfer = await account.getBalance(l2DAI); const senderApprovalTokenBalanceAfterTransfer = - await account.getBalance(TOKEN); + await account.getBalance(APPROVAL_TOKEN); const receiverBalanceAfterTransfer = await provider.getBalance( - RECEIVER, + ADDRESS2, 'latest', l2DAI ); @@ -409,11 +413,11 @@ describe('SmartAccount', async () => { const paymasterTokenBalanceBeforeWithdrawal = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const l2BalanceBeforeWithdrawal = await account.getBalance(); const l2ApprovalTokenBalanceBeforeWithdrawal = - await account.getBalance(TOKEN); + await account.getBalance(APPROVAL_TOKEN); const withdrawTx = await account.withdraw({ token: utils.ETH_ADDRESS, @@ -421,7 +425,7 @@ describe('SmartAccount', async () => { amount: amount, paymasterParams: utils.getPaymasterParams(PAYMASTER, { type: 'ApprovalBased', - token: TOKEN, + token: APPROVAL_TOKEN, minimalAllowance: minimalAllowance, innerInput: new Uint8Array(), }), @@ -439,11 +443,11 @@ describe('SmartAccount', async () => { const paymasterTokenBalanceAfterWithdrawal = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const l2BalanceAfterWithdrawal = await account.getBalance(); const l2ApprovalTokenBalanceAfterWithdrawal = - await account.getBalance(TOKEN); + await account.getBalance(APPROVAL_TOKEN); expect( paymasterBalanceBeforeWithdrawal @@ -505,12 +509,12 @@ describe('SmartAccount', async () => { const paymasterTokenBalanceBeforeWithdrawal = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const l2BalanceBeforeWithdrawal = await account.getBalance(l2DAI); const l1BalanceBeforeWithdrawal = await wallet.getBalanceL1(DAI_L1); const l2ApprovalTokenBalanceBeforeWithdrawal = - await account.getBalance(TOKEN); + await account.getBalance(APPROVAL_TOKEN); const withdrawTx = await account.withdraw({ token: l2DAI, @@ -518,7 +522,7 @@ describe('SmartAccount', async () => { amount: amount, paymasterParams: utils.getPaymasterParams(PAYMASTER, { type: 'ApprovalBased', - token: TOKEN, + token: APPROVAL_TOKEN, minimalAllowance: minimalAllowance, innerInput: new Uint8Array(), }), @@ -536,12 +540,12 @@ describe('SmartAccount', async () => { const paymasterTokenBalanceAfterWithdrawal = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const l2BalanceAfterWithdrawal = await account.getBalance(l2DAI); const l1BalanceAfterWithdrawal = await wallet.getBalanceL1(DAI_L1); const l2ApprovalTokenBalanceAfterWithdrawal = - await account.getBalance(TOKEN); + await account.getBalance(APPROVAL_TOKEN); expect( paymasterBalanceBeforeWithdrawal @@ -570,23 +574,11 @@ describe('SmartAccount', async () => { }); describe('MultisigECDSASmartAccount', async () => { - const ADDRESS1 = '0x36615Cf349d7F6344891B1e7CA7C72883F5dc049'; - const PRIVATE_KEY1 = - '0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110'; - const ADDRESS2 = '0xa61464658AfeAf65CccaaFD3a512b69A83B77618'; - const PRIVATE_KEY2 = - '0xac1e735be8536c6534bb4f17f06f6afc73b2b5ba84ac2cfb12f7461b20c0bbe3'; - const provider = Provider.getDefaultProvider(types.Network.Localhost); const ethProvider = ethers.getDefaultProvider('http://localhost:8545'); const wallet = new Wallet(PRIVATE_KEY1, provider, ethProvider); let account: SmartAccount; - const DAI_L1 = TokensL1[0].address; - - const TOKEN = '0x841c43Fa5d8fFfdB9efE3358906f7578d8700Dd4'; - const PAYMASTER = '0xa222f0c183AFA73a8Bc1AFb48D34C88c9Bf7A174'; - before('setup', async function () { this.timeout(25_000); @@ -619,7 +611,7 @@ describe('MultisigECDSASmartAccount', async () => { // send paymaster approval token to multisig account const sendApprovalTokenTx = await deployer.transfer({ to: multisigAddress, - token: TOKEN, + token: APPROVAL_TOKEN, amount: 5, }); await sendApprovalTokenTx.wait(); @@ -664,11 +656,11 @@ describe('MultisigECDSASmartAccount', async () => { const paymasterTokenBalanceBeforeTransfer = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const senderBalanceBeforeTransfer = await account.getBalance(); const senderApprovalTokenBalanceBeforeTransfer = - await account.getBalance(TOKEN); + await account.getBalance(APPROVAL_TOKEN); const receiverBalanceBeforeTransfer = await provider.getBalance(ADDRESS2); const tx = await account.transfer({ @@ -677,7 +669,7 @@ describe('MultisigECDSASmartAccount', async () => { amount: amount, paymasterParams: utils.getPaymasterParams(PAYMASTER, { type: 'ApprovalBased', - token: TOKEN, + token: APPROVAL_TOKEN, minimalAllowance: minimalAllowance, innerInput: new Uint8Array(), }), @@ -689,11 +681,11 @@ describe('MultisigECDSASmartAccount', async () => { const paymasterTokenBalanceAfterTransfer = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const senderBalanceAfterTransfer = await account.getBalance(); const senderApprovalTokenBalanceAfterTransfer = - await account.getBalance(TOKEN); + await account.getBalance(APPROVAL_TOKEN); const receiverBalanceAfterTransfer = await provider.getBalance(ADDRESS2); expect( @@ -756,11 +748,11 @@ describe('MultisigECDSASmartAccount', async () => { const paymasterTokenBalanceBeforeTransfer = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const senderBalanceBeforeTransfer = await account.getBalance(l2DAI); const senderApprovalTokenBalanceBeforeTransfer = - await account.getBalance(TOKEN); + await account.getBalance(APPROVAL_TOKEN); const receiverBalanceBeforeTransfer = await provider.getBalance( ADDRESS2, 'latest', @@ -773,7 +765,7 @@ describe('MultisigECDSASmartAccount', async () => { amount: amount, paymasterParams: utils.getPaymasterParams(PAYMASTER, { type: 'ApprovalBased', - token: TOKEN, + token: APPROVAL_TOKEN, minimalAllowance: minimalAllowance, innerInput: new Uint8Array(), }), @@ -785,11 +777,11 @@ describe('MultisigECDSASmartAccount', async () => { const paymasterTokenBalanceAfterTransfer = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const senderBalanceAfterTransfer = await account.getBalance(l2DAI); const senderApprovalTokenBalanceAfterTransfer = - await account.getBalance(TOKEN); + await account.getBalance(APPROVAL_TOKEN); const receiverBalanceAfterTransfer = await provider.getBalance( ADDRESS2, 'latest', @@ -855,11 +847,11 @@ describe('MultisigECDSASmartAccount', async () => { const paymasterTokenBalanceBeforeWithdrawal = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const l2BalanceBeforeWithdrawal = await account.getBalance(); const l2ApprovalTokenBalanceBeforeWithdrawal = - await account.getBalance(TOKEN); + await account.getBalance(APPROVAL_TOKEN); const withdrawTx = await account.withdraw({ token: utils.ETH_ADDRESS, @@ -867,7 +859,7 @@ describe('MultisigECDSASmartAccount', async () => { amount: amount, paymasterParams: utils.getPaymasterParams(PAYMASTER, { type: 'ApprovalBased', - token: TOKEN, + token: APPROVAL_TOKEN, minimalAllowance: minimalAllowance, innerInput: new Uint8Array(), }), @@ -885,11 +877,11 @@ describe('MultisigECDSASmartAccount', async () => { const paymasterTokenBalanceAfterWithdrawal = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const l2BalanceAfterWithdrawal = await account.getBalance(); const l2ApprovalTokenBalanceAfterWithdrawal = - await account.getBalance(TOKEN); + await account.getBalance(APPROVAL_TOKEN); expect( paymasterBalanceBeforeWithdrawal @@ -952,12 +944,12 @@ describe('MultisigECDSASmartAccount', async () => { const paymasterTokenBalanceBeforeWithdrawal = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const l2BalanceBeforeWithdrawal = await account.getBalance(l2DAI); const l1BalanceBeforeWithdrawal = await wallet.getBalanceL1(DAI_L1); const l2ApprovalTokenBalanceBeforeWithdrawal = - await account.getBalance(TOKEN); + await account.getBalance(APPROVAL_TOKEN); const withdrawTx = await account.withdraw({ token: l2DAI, @@ -965,7 +957,7 @@ describe('MultisigECDSASmartAccount', async () => { amount: amount, paymasterParams: utils.getPaymasterParams(PAYMASTER, { type: 'ApprovalBased', - token: TOKEN, + token: APPROVAL_TOKEN, minimalAllowance: minimalAllowance, innerInput: new Uint8Array(), }), @@ -983,12 +975,12 @@ describe('MultisigECDSASmartAccount', async () => { const paymasterTokenBalanceAfterWithdrawal = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const l2BalanceAfterWithdrawal = await account.getBalance(l2DAI); const l1BalanceAfterWithdrawal = await wallet.getBalanceL1(DAI_L1); const l2ApprovalTokenBalanceAfterWithdrawal = - await account.getBalance(TOKEN); + await account.getBalance(APPROVAL_TOKEN); expect( paymasterBalanceBeforeWithdrawal diff --git a/tests/integration/utils.test.ts b/tests/integration/utils.test.ts index 7566ce1f..8df81ce4 100644 --- a/tests/integration/utils.test.ts +++ b/tests/integration/utils.test.ts @@ -2,26 +2,24 @@ import * as chai from 'chai'; import '../custom-matchers'; import {Provider, types, utils, EIP712Signer} from '../../src'; import {BigNumber, ethers} from 'ethers'; +import {PRIVATE_KEY1, ADDRESS1, IS_ETH_BASED, ADDRESS2, DAI_L1} from '../utils'; const {expect} = chai; describe('utils', () => { - const ADDRESS = '0x36615Cf349d7F6344891B1e7CA7C72883F5dc049'; - const PRIVATE_KEY = - '0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110'; - const provider = Provider.getDefaultProvider(types.Network.Localhost); + const ethProvider = ethers.getDefaultProvider('http://localhost:8545'); describe('#isMessageSignatureCorrect()', () => { it('should return true for a valid message signature', async () => { const message = 'Hello, world!'; - const signature = await new ethers.Wallet(PRIVATE_KEY).signMessage( + const signature = await new ethers.Wallet(PRIVATE_KEY1).signMessage( message ); const result = await utils.isMessageSignatureCorrect( provider, - ADDRESS, + ADDRESS1, message, signature ); @@ -35,7 +33,7 @@ describe('utils', () => { const result = await utils.isMessageSignatureCorrect( provider, - ADDRESS, + ADDRESS1, message, invalidSignature ); @@ -48,13 +46,13 @@ describe('utils', () => { const tx: types.TransactionRequest = { type: 113, chainId: 270, - from: ADDRESS, + from: ADDRESS1, to: '0xa61464658AfeAf65CccaaFD3a512b69A83B77618', value: BigNumber.from(7_000_000), }; const eip712Signer = new EIP712Signer( - new ethers.Wallet(PRIVATE_KEY), + new ethers.Wallet(PRIVATE_KEY1), Number((await provider.getNetwork()).chainId) ); @@ -62,7 +60,7 @@ describe('utils', () => { const result = await utils.isTypedDataSignatureCorrect( provider, - ADDRESS, + ADDRESS1, await eip712Signer.getDomain(), utils.EIP712_TYPES, EIP712Signer.getSignInput(tx), @@ -79,19 +77,19 @@ describe('utils', () => { const tx: types.TransactionRequest = { type: 113, chainId: 270, - from: ADDRESS, + from: ADDRESS1, to: '0xa61464658AfeAf65CccaaFD3a512b69A83B77618', value: BigNumber.from(1_000_000), }; const eip712Signer = new EIP712Signer( - new ethers.Wallet(PRIVATE_KEY), + new ethers.Wallet(PRIVATE_KEY1), Number((await provider.getNetwork()).chainId) ); const result = await utils.isTypedDataSignatureCorrect( provider, - ADDRESS, + ADDRESS1, await eip712Signer.getDomain(), utils.EIP712_TYPES, EIP712Signer.getSignInput(tx), @@ -100,4 +98,68 @@ describe('utils', () => { expect(result).to.be.false; }); }); + + describe('#estimateDefaultBridgeDepositL2Gas()', () => { + if (IS_ETH_BASED) { + it('should return estimation for ETH token', async () => { + const result = await utils.estimateDefaultBridgeDepositL2Gas( + ethProvider, + provider, + utils.LEGACY_ETH_ADDRESS, + ethers.utils.parseEther('1'), + ADDRESS2, + ADDRESS1 + ); + expect(result.isZero()).to.be.false; + }); + + it('should return estimation for DAI token', async () => { + const result = await utils.estimateDefaultBridgeDepositL2Gas( + ethProvider, + provider, + DAI_L1, + 5, + ADDRESS2, + ADDRESS1 + ); + expect(result.isZero()).to.be.false; + }); + } else { + it('should return estimation for ETH token', async () => { + const result = await utils.estimateDefaultBridgeDepositL2Gas( + ethProvider, + provider, + utils.LEGACY_ETH_ADDRESS, + ethers.utils.parseEther('1'), + ADDRESS2, + ADDRESS1 + ); + expect(result.isZero()).to.be.false; + }); + + it('should return estimation for base token', async () => { + const result = await utils.estimateDefaultBridgeDepositL2Gas( + ethProvider, + provider, + await provider.getBaseTokenContractAddress(), + ethers.utils.parseEther('1'), + ADDRESS2, + ADDRESS1 + ); + expect(result.isZero()).to.be.false; + }); + + it('should return estimation for DAI token', async () => { + const result = await utils.estimateDefaultBridgeDepositL2Gas( + ethProvider, + provider, + DAI_L1, + 5, + ADDRESS2, + ADDRESS1 + ); + expect(result.isZero()).to.be.false; + }); + } + }); }); diff --git a/tests/integration/wallet.test.ts b/tests/integration/wallet.test.ts index 9202fa4c..daceb9ae 100644 --- a/tests/integration/wallet.test.ts +++ b/tests/integration/wallet.test.ts @@ -1,42 +1,40 @@ import * as chai from 'chai'; import '../custom-matchers'; -import {Provider, utils, Wallet} from '../../src'; +import {Provider, Wallet, utils, types} from '../../src'; import {ethers, BigNumber} from 'ethers'; import * as fs from 'fs'; - -import TokensL1 from '../files/tokens.json'; +import {ITestnetErc20TokenFactory} from '../../src/typechain/ITestnetErc20TokenFactory'; +import { + MNEMONIC1, + PRIVATE_KEY1, + ADDRESS1, + ADDRESS2, + DAI_L1, + IS_ETH_BASED, + APPROVAL_TOKEN, + PAYMASTER, +} from '../utils'; const {expect} = chai; describe('Wallet', () => { - const ADDRESS = '0x36615Cf349d7F6344891B1e7CA7C72883F5dc049'; - const PRIVATE_KEY = - '0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110'; - const MNEMONIC = - 'stuff slice staff easily soup parent arm payment cotton trade scatter struggle'; - const RECEIVER = '0xa61464658AfeAf65CccaaFD3a512b69A83B77618'; - const provider = Provider.getDefaultProvider(); const ethProvider = ethers.getDefaultProvider('http://localhost:8545'); - const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider); - - const DAI_L1 = TokensL1[0].address; - - const TOKEN = '0x841c43Fa5d8fFfdB9efE3358906f7578d8700Dd4'; - const PAYMASTER = '0xa222f0c183AFA73a8Bc1AFb48D34C88c9Bf7A174'; + ethProvider.pollingInterval = 300; + const wallet = new Wallet(PRIVATE_KEY1, provider, ethProvider); describe('#constructor()', () => { it('`Wallet(privateKey, provider)` should return a `Wallet` with L2 provider', async () => { - const wallet = new Wallet(PRIVATE_KEY, provider); + const wallet = new Wallet(PRIVATE_KEY1, provider); - expect(wallet.privateKey).to.be.equal(PRIVATE_KEY); + expect(wallet.privateKey).to.be.equal(PRIVATE_KEY1); expect(wallet.provider).to.be.equal(provider); }); it('`Wallet(privateKey, provider, ethProvider)` should return a `Wallet` with L1 and L2 provider', async () => { - const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider); + const wallet = new Wallet(PRIVATE_KEY1, provider, ethProvider); - expect(wallet.privateKey).to.be.equal(PRIVATE_KEY); + expect(wallet.privateKey).to.be.equal(PRIVATE_KEY1); expect(wallet.provider).to.be.equal(provider); expect(wallet.providerL1).to.be.equal(ethProvider); }); @@ -44,7 +42,7 @@ describe('Wallet', () => { describe('#getMainContract()', () => { it('should return the main contract', async () => { - const result = await wallet.getMainContract(); + const result = await wallet.getBridgehubContract(); expect(result).not.to.be.null; }); }); @@ -56,6 +54,22 @@ describe('Wallet', () => { }); }); + describe('#isEthBasedChain()', () => { + it('should return whether the chain is ETH-based or not', async () => { + const result = await wallet.isETHBasedChain(); + expect(result).to.be.equal(IS_ETH_BASED); + }); + }); + + describe('#getBaseToken()', () => { + it('should return base token', async () => { + const result = await wallet.getBaseToken(); + IS_ETH_BASED + ? expect(result).to.be.equal(utils.ETH_ADDRESS_IN_CONTRACTS) + : expect(result).not.to.be.null; + }); + }); + describe('#getBalanceL1()', () => { it('should return a L1 balance', async () => { const result = await wallet.getBalanceL1(); @@ -71,9 +85,17 @@ describe('Wallet', () => { }); describe('#l2TokenAddress()', () => { + it('should return the L2 base address', async () => { + const baseToken = await provider.getBaseTokenContractAddress(); + const result = await wallet.l2TokenAddress(baseToken); + expect(result).to.be.equal(utils.L2_BASE_TOKEN_ADDRESS); + }); + it('should return the L2 ETH address', async () => { - const result = await wallet.l2TokenAddress(utils.ETH_ADDRESS); - expect(result).to.be.equal(utils.ETH_ADDRESS); + if (!IS_ETH_BASED) { + const result = await wallet.l2TokenAddress(utils.LEGACY_ETH_ADDRESS); + expect(result).not.to.be.null; + } }); it('should return the L2 DAI address', async () => { @@ -91,7 +113,7 @@ describe('Wallet', () => { it('should throw an error when approving ETH token', async () => { try { - await wallet.approveERC20(utils.ETH_ADDRESS, 5); + await wallet.approveERC20(utils.LEGACY_ETH_ADDRESS, 5); } catch (e) { expect((e as Error).message).to.be.equal( "ETH token can't be approved! The address of the token does not exist on L1." @@ -117,7 +139,8 @@ describe('Wallet', () => { describe('#getAllBalances()', () => { it('should return all balances', async () => { const result = await wallet.getAllBalances(); - expect(Object.keys(result)).to.have.lengthOf(2); + const expected = IS_ETH_BASED ? 2 : 3; + expect(Object.keys(result)).to.have.lengthOf(expected); }); }); @@ -131,25 +154,25 @@ describe('Wallet', () => { describe('#getAddress()', () => { it('should return a `Wallet` address', async () => { const result = await wallet.getAddress(); - expect(result).to.be.equal(ADDRESS); + expect(result).to.be.equal(ADDRESS1); }); }); describe('#ethWallet()', () => { it('should return a L1 `Wallet`', async () => { - const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider); + const wallet = new Wallet(PRIVATE_KEY1, provider, ethProvider); const ethWallet = wallet.ethWallet(); - expect(ethWallet.privateKey).to.be.equal(PRIVATE_KEY); + expect(ethWallet.privateKey).to.be.equal(PRIVATE_KEY1); expect(ethWallet.provider).to.be.equal(ethProvider); }); it('should throw an error when L1 `Provider` is not specified in constructor', async () => { - const wallet = new Wallet(PRIVATE_KEY, provider); + const wallet = new Wallet(PRIVATE_KEY1, provider); try { wallet.ethWallet(); } catch (e) { expect((e as Error).message).to.be.equal( - 'L1 provider missing: use `connectToL1` to specify!' + 'L1 provider is missing! Use `Wallet.connectToL1()` to connect to L1!' ); } }); @@ -157,18 +180,18 @@ describe('Wallet', () => { describe('#connect()', () => { it('should return a `Wallet` with provided `provider` as L2 provider', async () => { - let wallet = new Wallet(PRIVATE_KEY); + let wallet = new Wallet(PRIVATE_KEY1); wallet = wallet.connect(provider); - expect(wallet.privateKey).to.be.equal(PRIVATE_KEY); + expect(wallet.privateKey).to.be.equal(PRIVATE_KEY1); expect(wallet.provider).to.be.equal(provider); }); }); describe('#connectL1()', () => { it('should return a `Wallet` with provided `provider` as L1 provider', async () => { - let wallet = new Wallet(PRIVATE_KEY); + let wallet = new Wallet(PRIVATE_KEY1); wallet = wallet.connectToL1(ethProvider); - expect(wallet.privateKey).to.be.equal(PRIVATE_KEY); + expect(wallet.privateKey).to.be.equal(PRIVATE_KEY1); expect(wallet.providerL1).to.be.equal(ethProvider); }); }); @@ -183,15 +206,17 @@ describe('Wallet', () => { describe('#populateTransaction()', () => { it('should return populated transaction with default values if are omitted', async () => { const tx = { - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, type: 2, - from: ADDRESS, + from: ADDRESS1, nonce: await wallet.getNonce('pending'), chainId: 270, + maxFeePerGas: BigNumber.from(1_700_000_000), + maxPriorityFeePerGas: BigNumber.from(1_500_000_000), }; const result = await wallet.populateTransaction({ - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, }); expect(result).to.be.deepEqualExcluding(tx, [ @@ -199,16 +224,17 @@ describe('Wallet', () => { 'maxFeePerGas', 'maxPriorityFeePerGas', ]); + expect(BigNumber.from(result.gasLimit).isZero()).to.be.false; expect(BigNumber.from(result.maxPriorityFeePerGas).isZero()).to.be.false; expect(BigNumber.from(result.maxFeePerGas).isZero()).to.be.false; }); it('should return populated transaction when `maxFeePerGas` and `maxPriorityFeePerGas` and `customData` are provided', async () => { const tx = { - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, type: 113, - from: ADDRESS, + from: ADDRESS1, nonce: await wallet.getNonce('pending'), data: '0x', chainId: 270, @@ -220,7 +246,7 @@ describe('Wallet', () => { }, }; const result = await wallet.populateTransaction({ - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, maxFeePerGas: BigNumber.from(3_500_000_000), maxPriorityFeePerGas: BigNumber.from(2_000_000_000), @@ -230,14 +256,15 @@ describe('Wallet', () => { }, }); expect(result).to.be.deepEqualExcluding(tx, ['gasLimit']); + expect(BigNumber.from(result.gasLimit).isZero()).to.be.false; }); it('should return populated transaction when `maxPriorityFeePerGas` and `customData` are provided', async () => { const tx = { - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, type: 113, - from: ADDRESS, + from: ADDRESS1, nonce: await wallet.getNonce('pending'), data: '0x', chainId: 270, @@ -248,7 +275,7 @@ describe('Wallet', () => { }, }; const result = await wallet.populateTransaction({ - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, maxPriorityFeePerGas: BigNumber.from(2_000_000_000), customData: { @@ -256,14 +283,15 @@ describe('Wallet', () => { }, }); expect(result).to.be.deepEqualExcluding(tx, ['gasLimit']); + expect(BigNumber.from(result.gasLimit).isZero()).to.be.false; }); it('should return populated transaction when `maxFeePerGas` and `customData` are provided', async () => { const tx = { - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, type: 113, - from: ADDRESS, + from: ADDRESS1, nonce: await wallet.getNonce('pending'), data: '0x', chainId: 270, @@ -274,7 +302,7 @@ describe('Wallet', () => { }, }; const result = await wallet.populateTransaction({ - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, maxFeePerGas: BigNumber.from(3_500_000_000), customData: { @@ -282,70 +310,79 @@ describe('Wallet', () => { }, }); expect(result).to.be.deepEqualExcluding(tx, ['gasLimit']); + expect(BigNumber.from(result.gasLimit).isZero()).to.be.false; }); it('should return populated EIP1559 transaction when `maxFeePerGas` and `maxPriorityFeePerGas` are provided', async () => { const tx = { - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, type: 2, - from: ADDRESS, + from: ADDRESS1, nonce: await wallet.getNonce('pending'), chainId: 270, maxFeePerGas: BigNumber.from(3_500_000_000), maxPriorityFeePerGas: BigNumber.from(2_000_000_000), }; const result = await wallet.populateTransaction({ - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, maxFeePerGas: BigNumber.from(3_500_000_000), maxPriorityFeePerGas: BigNumber.from(2_000_000_000), }); expect(result).to.be.deepEqualExcluding(tx, ['gasLimit']); + expect(BigNumber.from(result.gasLimit).isZero()).to.be.false; }); it('should return populated EIP1559 transaction with `maxFeePerGas` and `maxPriorityFeePerGas` same as provided `gasPrice`', async () => { const tx = { - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, type: 2, - from: ADDRESS, + from: ADDRESS1, nonce: await wallet.getNonce('pending'), chainId: 270, maxFeePerGas: BigNumber.from(3_500_000_000), maxPriorityFeePerGas: BigNumber.from(3_500_000_000), }; const result = await wallet.populateTransaction({ - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, gasPrice: BigNumber.from(3_500_000_000), }); expect(result).to.be.deepEqualExcluding(tx, ['gasLimit']); + expect(BigNumber.from(result.gasLimit).isZero()).to.be.false; }); it('should return populated legacy transaction when `type = 0`', async () => { const tx = { - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, type: 0, - from: ADDRESS, + from: ADDRESS1, nonce: await wallet.getNonce('pending'), + gasPrice: BigNumber.from(100_000_000), chainId: 270, }; const result = await wallet.populateTransaction({ type: 0, - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, }); - expect(result).to.be.deepEqualExcluding(tx, ['gasLimit', 'gasPrice']); + expect(result).to.be.deepEqualExcluding(tx, [ + 'gasLimit', + 'gasPrice', + 'chainId', + ]); expect(BigNumber.from(result.gasPrice).isZero()).to.be.false; + expect(BigNumber.from(result.gasLimit).isZero()).to.be.false; }); }); describe('#sendTransaction()', () => { it('should send already populated transaction with provided `maxFeePerGas` and `maxPriorityFeePerGas` and `customData` fields', async () => { const populatedTx = await wallet.populateTransaction({ - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, maxFeePerGas: BigNumber.from(3_500_000_000), maxPriorityFeePerGas: BigNumber.from(2_000_000_000), @@ -360,7 +397,7 @@ describe('Wallet', () => { it('should send EIP1559 transaction when `maxFeePerGas` and `maxPriorityFeePerGas` are provided', async () => { const tx = await wallet.sendTransaction({ - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, maxFeePerGas: BigNumber.from(3_500_000_000), maxPriorityFeePerGas: BigNumber.from(2_000_000_000), @@ -372,7 +409,7 @@ describe('Wallet', () => { it('should return already populated EIP1559 transaction with `maxFeePerGas` and `maxPriorityFeePerGas`', async () => { const populatedTx = await wallet.populateTransaction({ - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, maxFeePerGas: BigNumber.from(3_500_000_000), maxPriorityFeePerGas: BigNumber.from(2_000_000_000), @@ -386,7 +423,7 @@ describe('Wallet', () => { it('should send EIP1559 transaction with `maxFeePerGas` and `maxPriorityFeePerGas` same as provided `gasPrice`', async () => { const tx = await wallet.sendTransaction({ - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, gasPrice: BigNumber.from(3_500_000_000), }); @@ -398,7 +435,7 @@ describe('Wallet', () => { it('should send legacy transaction when `type = 0`', async () => { const tx = await wallet.sendTransaction({ type: 0, - to: RECEIVER, + to: ADDRESS2, value: 7_000_000, }); const result = await tx.wait(); @@ -409,8 +446,8 @@ describe('Wallet', () => { describe('#fromMnemonic()', () => { it('should return a `Wallet` with the `provider` as L1 provider and a private key that is built from the `mnemonic` passphrase', async () => { - const wallet = Wallet.fromMnemonic(MNEMONIC); - expect(wallet.privateKey).to.be.equal(PRIVATE_KEY); + const wallet = Wallet.fromMnemonic(MNEMONIC1); + expect(wallet.privateKey).to.be.equal(PRIVATE_KEY1); }); }); @@ -420,7 +457,7 @@ describe('Wallet', () => { fs.readFileSync('tests/files/wallet.json', 'utf8'), 'password' ); - expect(wallet.privateKey).to.be.equal(PRIVATE_KEY); + expect(wallet.privateKey).to.be.equal(PRIVATE_KEY1); }).timeout(10_000); }); @@ -430,7 +467,7 @@ describe('Wallet', () => { fs.readFileSync('tests/files/wallet.json', 'utf8'), 'password' ); - expect(wallet.privateKey).to.be.equal(PRIVATE_KEY); + expect(wallet.privateKey).to.be.equal(PRIVATE_KEY1); }).timeout(10_000); }); @@ -442,272 +479,703 @@ describe('Wallet', () => { }); describe('#getDepositTx()', () => { - it('should return ETH deposit transaction', async () => { - const tx = { - contractAddress: ADDRESS, - calldata: '0x', - l2Value: 7_000_000, - token: '0x0000000000000000000000000000000000000000', - to: ADDRESS, - amount: 7_000_000, - refundRecipient: ADDRESS, - operatorTip: BigNumber.from(0), - gasPerPubdataByte: 800, - }; - const result = await wallet.getDepositTx({ - token: utils.ETH_ADDRESS, - to: await wallet.getAddress(), - amount: 7_000_000, - refundRecipient: await wallet.getAddress(), + if (IS_ETH_BASED) { + it('should return ETH deposit transaction', async () => { + const tx = { + contractAddress: ADDRESS1, + calldata: '0x', + l2Value: 7_000_000, + l2GasLimit: BigNumber.from(415_035), + mintValue: BigNumber.from(111_540_663_250_000), + token: utils.ETH_ADDRESS_IN_CONTRACTS, + to: ADDRESS1, + amount: 7_000_000, + refundRecipient: '0x36615Cf349d7F6344891B1e7CA7C72883F5dc049', + operatorTip: BigNumber.from(0), + overrides: { + maxFeePerGas: BigNumber.from(1_500_000_001), + maxPriorityFeePerGas: BigNumber.from(1_500_000_000), + value: BigNumber.from(111_540_663_250_000), + }, + gasPerPubdataByte: 800, + }; + const result = await wallet.getDepositTx({ + token: utils.LEGACY_ETH_ADDRESS, + to: await wallet.getAddress(), + amount: 7_000_000, + refundRecipient: await wallet.getAddress(), + }); + expect(result).to.be.deepEqualExcluding(tx, [ + 'l2GasLimit', + 'mintValue', + 'overrides', + ]); + expect(BigNumber.from(result.overrides.maxPriorityFeePerGas).isZero()) + .to.be.false; + expect(BigNumber.from(result.overrides.maxFeePerGas).isZero()).to.be + .false; + expect(BigNumber.from(result.overrides.value).isZero()).to.be.false; + expect(BigNumber.from(result.l2GasLimit).isZero()).to.be.false; + expect(BigNumber.from(result.mintValue).isZero()).to.be.false; }); - expect(result).to.be.deepEqualExcluding(tx, ['overrides', 'l2GasLimit']); - expect(BigNumber.from(result.overrides.maxPriorityFeePerGas).isZero()).to - .be.false; - expect(BigNumber.from(result.overrides.maxFeePerGas).isZero()).to.be - .false; - expect(BigNumber.from(result.overrides.value).isZero()).to.be.false; - expect(BigNumber.from(result.l2GasLimit).isZero()).to.be.false; - }); - it('should return a deposit transaction with `tx.to == Wallet.getAddress()` when `tx.to` is not specified', async () => { - const tx = { - contractAddress: ADDRESS, - calldata: '0x', - l2Value: 7_000_000, - token: '0x0000000000000000000000000000000000000000', - to: ADDRESS, - amount: 7_000_000, - refundRecipient: ADDRESS, - operatorTip: BigNumber.from(0), - gasPerPubdataByte: 800, - }; - const result = await wallet.getDepositTx({ - token: utils.ETH_ADDRESS, - amount: 7_000_000, - refundRecipient: await wallet.getAddress(), + it('should return a deposit transaction with `tx.to == Wallet.getAddress()` when `tx.to` is not specified', async () => { + const tx = { + contractAddress: '0x36615Cf349d7F6344891B1e7CA7C72883F5dc049', + calldata: '0x', + l2Value: 7_000_000, + l2GasLimit: BigNumber.from(415_035), + mintValue: BigNumber.from(111_540_663_250_000), + token: '0x0000000000000000000000000000000000000001', + to: ADDRESS1, + amount: 7_000_000, + refundRecipient: '0x36615Cf349d7F6344891B1e7CA7C72883F5dc049', + operatorTip: BigNumber.from(0), + overrides: { + maxFeePerGas: BigNumber.from(1_500_000_001), + maxPriorityFeePerGas: BigNumber.from(1_500_000_000), + value: BigNumber.from(111_540_663_250_000), + }, + gasPerPubdataByte: 800, + }; + const result = await wallet.getDepositTx({ + token: utils.LEGACY_ETH_ADDRESS, + amount: 7_000_000, + refundRecipient: await wallet.getAddress(), + }); + expect(result).to.be.deepEqualExcluding(tx, [ + 'l2GasLimit', + 'mintValue', + 'overrides', + ]); + expect(BigNumber.from(result.overrides.maxPriorityFeePerGas).isZero()) + .to.be.false; + expect(BigNumber.from(result.overrides.maxFeePerGas).isZero()).to.be + .false; + expect(BigNumber.from(result.overrides.value).isZero()).to.be.false; + expect(BigNumber.from(result.l2GasLimit).isZero()).to.be.false; + expect(BigNumber.from(result.mintValue).isZero()).to.be.false; }); - expect(result).to.be.deepEqualExcluding(tx, ['overrides', 'l2GasLimit']); - expect(BigNumber.from(result.overrides.maxPriorityFeePerGas).isZero()).to - .be.false; - expect(BigNumber.from(result.overrides.maxFeePerGas).isZero()).to.be - .false; - expect(BigNumber.from(result.overrides.value).isZero()).to.be.false; - expect(BigNumber.from(result.l2GasLimit).isZero()).to.be.false; - }); - it('should return DAI deposit transaction', async () => { - const tx = { - from: ADDRESS, - to: (await wallet.getL1BridgeContracts()).erc20.address, - }; - const result = await wallet.getDepositTx({ - token: DAI_L1, - to: await wallet.getAddress(), - amount: 5, - refundRecipient: await wallet.getAddress(), + it('should return DAI deposit transaction', async () => { + const tx = { + maxFeePerGas: BigNumber.from(1_500_000_001), + maxPriorityFeePerGas: BigNumber.from(1_500_000_000), + value: BigNumber.from(123_164_093_750_000), + from: ADDRESS1, + to: await provider.getBridgehubContractAddress(), + }; + const result = await wallet.getDepositTx({ + token: DAI_L1, + to: await wallet.getAddress(), + amount: 5, + refundRecipient: await wallet.getAddress(), + }); + result.to = result.to.toLowerCase(); + expect(result).to.be.deepEqualExcluding(tx, [ + 'data', + 'maxFeePerGas', + 'maxPriorityFeePerGas', + 'value', + ]); + expect(BigNumber.from(result.maxFeePerGas).isZero()).to.be.false; + expect(BigNumber.from(result.maxPriorityFeePerGas).isZero()).to.be + .false; + expect(BigNumber.from(result.value).isZero()).to.be.false; + }); + } else { + it('should return ETH deposit transaction', async () => { + const tx = { + from: ADDRESS1, + to: (await provider.getBridgehubContractAddress()).toLowerCase(), + value: BigNumber.from(7_000_000), + data: '0x24fd57fb0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000010e0000000000000000000000000000000000000000000000000000bf1aaa17ee7000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000062e3d000000000000000000000000000000000000000000000000000000000000032000000000000000000000000036615cf349d7f6344891b1e7ca7c72883f5dc049000000000000000000000000842deab39809094bf5e4b77a7f97ae308adc5e5500000000000000000000000000000000000000000000000000000000006acfc0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000036615cf349d7f6344891b1e7ca7c72883f5dc049', + maxFeePerGas: BigNumber.from(1_500_000_001), + maxPriorityFeePerGas: BigNumber.from(1_500_000_000), + }; + const result = await wallet.getDepositTx({ + token: utils.LEGACY_ETH_ADDRESS, + to: await wallet.getAddress(), + amount: 7_000_000, + refundRecipient: await wallet.getAddress(), + }); + result.to = result.to.toLowerCase(); + expect(result).to.be.deepEqualExcluding(tx, ['data', 'value']); + expect(BigNumber.from(result.value).isZero()).to.be.false; }); - result.to = result.to.toLowerCase(); - expect(result).to.be.deepEqualExcluding(tx, [ - 'data', - 'maxFeePerGas', - 'maxPriorityFeePerGas', - 'value', - ]); - expect(BigNumber.from(result.maxFeePerGas).isZero()).to.be.false; - expect(BigNumber.from(result.maxPriorityFeePerGas).isZero()).to.be.false; - expect(BigNumber.from(result.value).isZero()).to.be.false; - }); - }); - describe('#estimateGasDeposit()', () => { - it('should return gas estimation for ETH deposit transaction', async () => { - const result = await wallet.estimateGasDeposit({ - token: utils.ETH_ADDRESS, - to: await wallet.getAddress(), - amount: 5, - refundRecipient: await wallet.getAddress(), + it('should return a deposit transaction with `tx.to == Wallet.getAddress()` when `tx.to` is not specified', async () => { + const tx = { + from: ADDRESS1, + to: (await provider.getBridgehubContractAddress()).toLowerCase(), + value: BigNumber.from(7_000_000), + maxFeePerGas: BigNumber.from(1_500_000_001), + maxPriorityFeePerGas: BigNumber.from(1_500_000_000), + }; + const result = await wallet.getDepositTx({ + token: utils.LEGACY_ETH_ADDRESS, + amount: 7_000_000, + refundRecipient: await wallet.getAddress(), + }); + result.to = result.to.toLowerCase(); + expect(result).to.be.deepEqualExcluding(tx, ['data', 'value']); + expect(BigNumber.from(result.value).isZero()).to.be.false; }); - expect(result.isZero()).to.be.false; - }); - it('should return gas estimation for DAI deposit transaction', async () => { - const result = await wallet.estimateGasDeposit({ - token: DAI_L1, - to: await wallet.getAddress(), - amount: 5, - refundRecipient: await wallet.getAddress(), + it('should return DAI deposit transaction', async () => { + const tx = { + maxFeePerGas: BigNumber.from(1_500_000_001), + maxPriorityFeePerGas: BigNumber.from(1_500_000_000), + from: ADDRESS1, + to: (await provider.getBridgehubContractAddress()).toLowerCase(), + }; + const result = await wallet.getDepositTx({ + token: DAI_L1, + to: await wallet.getAddress(), + amount: 5, + refundRecipient: await wallet.getAddress(), + }); + result.to = result.to.toLowerCase(); + expect(result).to.be.deepEqualExcluding(tx, ['data']); }); - expect(result.isZero()).to.be.false; - }); + } }); - describe('#deposit()', () => { - it('should deposit ETH to L2 network', async () => { - const amount = 7_000_000_000; - const l2BalanceBeforeDeposit = await wallet.getBalance(); - const l1BalanceBeforeDeposit = await wallet.getBalanceL1(); - const tx = await wallet.deposit({ - token: utils.ETH_ADDRESS, - to: await wallet.getAddress(), - amount: amount, - refundRecipient: await wallet.getAddress(), + describe('#estimateGasDeposit()', () => { + if (IS_ETH_BASED) { + it('should return gas estimation for ETH deposit transaction', async () => { + const result = await wallet.estimateGasDeposit({ + token: utils.LEGACY_ETH_ADDRESS, + to: await wallet.getAddress(), + amount: 5, + refundRecipient: await wallet.getAddress(), + }); + expect(result.isZero()).to.be.false; }); - const result = await tx.wait(); - const l2BalanceAfterDeposit = await wallet.getBalance(); - const l1BalanceAfterDeposit = await wallet.getBalanceL1(); - expect(result).not.to.be.null; - expect(l2BalanceAfterDeposit.sub(l2BalanceBeforeDeposit).gte(amount)).to - .be.true; - expect(l1BalanceBeforeDeposit.sub(l1BalanceAfterDeposit).gte(amount)).to - .be.true; - }).timeout(60_000); - it('should deposit DAI to L2 network', async () => { - const amount = 5; - const l2DAI = await provider.l2TokenAddress(DAI_L1); - const l2BalanceBeforeDeposit = await wallet.getBalance(l2DAI); - const l1BalanceBeforeDeposit = await wallet.getBalanceL1(DAI_L1); - const tx = await wallet.deposit({ - token: DAI_L1, - to: await wallet.getAddress(), - amount: amount, - approveERC20: true, - refundRecipient: await wallet.getAddress(), + it('should return gas estimation for DAI deposit transaction', async () => { + const result = await wallet.estimateGasDeposit({ + token: DAI_L1, + to: await wallet.getAddress(), + amount: 5, + refundRecipient: await wallet.getAddress(), + }); + expect(result.isZero()).to.be.false; }); - const result = await tx.wait(); - const l2BalanceAfterDeposit = await wallet.getBalance(l2DAI); - const l1BalanceAfterDeposit = await wallet.getBalanceL1(DAI_L1); - expect(result).not.to.be.null; - expect(l2BalanceAfterDeposit.sub(l2BalanceBeforeDeposit).eq(amount)).to.be - .true; - expect(l1BalanceBeforeDeposit.sub(l1BalanceAfterDeposit).eq(amount)).to.be - .true; - }).timeout(60_000); + } else { + it('should throw an error for insufficient allowance when estimating gas for ETH deposit transaction', async () => { + try { + await wallet.estimateGasDeposit({ + token: utils.LEGACY_ETH_ADDRESS, + to: await wallet.getAddress(), + amount: 5, + refundRecipient: await wallet.getAddress(), + }); + } catch (e) { + expect((e as any).reason).to.include('ERC20: insufficient allowance'); + } + }).timeout(10_000); + + it('should return gas estimation for ETH deposit transaction', async () => { + const token = utils.LEGACY_ETH_ADDRESS; + const amount = 5; + const approveParams = await wallet.getDepositAllowanceParams( + token, + amount + ); - it('should deposit DAI to the L2 network with approve transaction for allowance', async () => { - const amount = 7; - const l2DAI = await provider.l2TokenAddress(DAI_L1); - const l2BalanceBeforeDeposit = await wallet.getBalance(l2DAI); - const l1BalanceBeforeDeposit = await wallet.getBalanceL1(DAI_L1); - const tx = await wallet.deposit({ - token: DAI_L1, - to: await wallet.getAddress(), - amount: amount, - approveERC20: true, - refundRecipient: await wallet.getAddress(), - }); - const result = await tx.wait(); - await tx.waitFinalize(); - const l2BalanceAfterDeposit = await wallet.getBalance(l2DAI); - const l1BalanceAfterDeposit = await wallet.getBalanceL1(DAI_L1); - expect(result).not.to.be.null; - expect(l2BalanceAfterDeposit.sub(l2BalanceBeforeDeposit).eq(amount)).to.be - .true; - expect(l1BalanceBeforeDeposit.sub(l1BalanceAfterDeposit).eq(amount)).to.be - .true; - }).timeout(60_000); - }); + await ( + await wallet.approveERC20( + approveParams[0].token, + approveParams[0].allowance + ) + ).wait(); - describe('#claimFailedDeposit()', () => { - // it("should claim failed deposit", async () => { - // const response = await wallet.deposit({ - // token: utils.ETH_ADDRESS, - // to: await wallet.getAddress(), - // amount: 7_000_000_000, - // refundRecipient: await wallet.getAddress(), - // gasPerPubdataByte: 500 // make it fail because of low gas - // }); - // - // const tx = await response.waitFinalize(); // fails, sames goes with response.wait() - // const result = await wallet.claimFailedDeposit(tx.hash); - // - // }).timeout(30_000); - - it('should throw an error when trying to claim successful deposit', async () => { - const response = await wallet.deposit({ - token: utils.ETH_ADDRESS, - to: await wallet.getAddress(), - amount: 7_000_000_000, - refundRecipient: await wallet.getAddress(), - }); + const result = await wallet.estimateGasDeposit({ + token: token, + to: await wallet.getAddress(), + amount: amount, + refundRecipient: await wallet.getAddress(), + }); + expect(result.isZero()).to.be.false; + }).timeout(10_000); + + it('should return gas estimation for base token deposit transaction', async () => { + const token = await wallet.getBaseToken(); + const amount = 5; + const approveParams = await wallet.getDepositAllowanceParams( + token, + amount + ); - const tx = await response.waitFinalize(); - try { - await wallet.claimFailedDeposit(tx.transactionHash); - } catch (e) { - expect((e as Error).message).to.be.equal( - 'Cannot claim successful deposit!' + await ( + await wallet.approveERC20( + approveParams[0].token, + approveParams[0].allowance + ) + ).wait(); + + const result = await wallet.estimateGasDeposit({ + token: token, + to: await wallet.getAddress(), + amount: amount, + refundRecipient: await wallet.getAddress(), + }); + expect(result.isZero()).to.be.false; + }).timeout(10_000); + + it('should return gas estimation for DAI deposit transaction', async () => { + const token = DAI_L1; + const amount = 5; + const approveParams = await wallet.getDepositAllowanceParams( + token, + amount ); - } - }).timeout(30_000); + + await ( + await wallet.approveERC20( + approveParams[0].token, + approveParams[0].allowance + ) + ).wait(); + await ( + await wallet.approveERC20( + approveParams[1].token, + approveParams[1].allowance + ) + ).wait(); + + const result = await wallet.estimateGasDeposit({ + token: token, + to: await wallet.getAddress(), + amount: amount, + refundRecipient: await wallet.getAddress(), + }); + expect(result.isZero()).to.be.false; + }).timeout(10_000); + } }); - describe('#getFullRequiredDepositFee()', () => { - it('should return fee for ETH token deposit', async () => { - const result = await wallet.getFullRequiredDepositFee({ - token: utils.ETH_ADDRESS, - to: await wallet.getAddress(), - }); - expect(BigNumber.from(result.baseCost).isZero()).to.be.false; - expect(BigNumber.from(result.l1GasLimit).isZero()).to.be.false; - expect(BigNumber.from(result.l2GasLimit).isZero()).to.be.false; - expect(BigNumber.from(result.maxFeePerGas).isZero()).to.be.false; - expect(BigNumber.from(result.maxPriorityFeePerGas).isZero()).to.be.false; - }); + describe('#deposit()', () => { + if (IS_ETH_BASED) { + it('should deposit ETH to L2 network', async () => { + const amount = 7_000_000_000; + const l2BalanceBeforeDeposit = await wallet.getBalance(); + const l1BalanceBeforeDeposit = await wallet.getBalanceL1(); + const tx = await wallet.deposit({ + token: utils.LEGACY_ETH_ADDRESS, + to: await wallet.getAddress(), + amount: amount, + refundRecipient: await wallet.getAddress(), + }); + const result = await tx.wait(); + const l2BalanceAfterDeposit = await wallet.getBalance(); + const l1BalanceAfterDeposit = await wallet.getBalanceL1(); + expect(result).not.to.be.null; + expect(l2BalanceAfterDeposit.sub(l2BalanceBeforeDeposit).gte(amount)).to + .be.true; + expect(l1BalanceBeforeDeposit.sub(l1BalanceAfterDeposit).gte(amount)).to + .be.true; + }).timeout(10_000); + + it('should deposit DAI to L2 network', async () => { + const amount = 5; + const l2DAI = await provider.l2TokenAddress(DAI_L1); + const l2BalanceBeforeDeposit = await wallet.getBalance(l2DAI); + const l1BalanceBeforeDeposit = await wallet.getBalanceL1(DAI_L1); + const tx = await wallet.deposit({ + token: DAI_L1, + to: await wallet.getAddress(), + amount: amount, + approveERC20: true, + refundRecipient: await wallet.getAddress(), + }); + const result = await tx.wait(); + const l2BalanceAfterDeposit = await wallet.getBalance(l2DAI); + const l1BalanceAfterDeposit = await wallet.getBalanceL1(DAI_L1); + expect(result).not.to.be.null; + expect(l2BalanceAfterDeposit.sub(l2BalanceBeforeDeposit).eq(amount)).to + .be.true; + expect(l1BalanceBeforeDeposit.sub(l1BalanceAfterDeposit).eq(amount)).to + .be.true; + }).timeout(10_000); + + it('should deposit DAI to the L2 network with approve transaction for allowance', async () => { + const amount = 7; + const l2DAI = await provider.l2TokenAddress(DAI_L1); + const l2BalanceBeforeDeposit = await wallet.getBalance(l2DAI); + const l1BalanceBeforeDeposit = await wallet.getBalanceL1(DAI_L1); + const tx = await wallet.deposit({ + token: DAI_L1, + to: await wallet.getAddress(), + amount: amount, + approveERC20: true, + refundRecipient: await wallet.getAddress(), + }); + const result = await tx.wait(); + await tx.waitFinalize(); + const l2BalanceAfterDeposit = await wallet.getBalance(l2DAI); + const l1BalanceAfterDeposit = await wallet.getBalanceL1(DAI_L1); + expect(result).not.to.be.null; + expect(l2BalanceAfterDeposit.sub(l2BalanceBeforeDeposit).eq(amount)).to + .be.true; + expect(l1BalanceBeforeDeposit.sub(l1BalanceAfterDeposit).eq(amount)).to + .be.true; + }).timeout(30_000); + } else { + it('should deposit ETH to L2 network', async () => { + const amount = 7_000_000_000; + const l2BalanceBeforeDeposit = await wallet.getBalance(); + const l1BalanceBeforeDeposit = await wallet.getBalanceL1(); + const tx = await wallet.deposit({ + token: utils.LEGACY_ETH_ADDRESS, + to: await wallet.getAddress(), + amount: amount, + approveBaseERC20: true, + refundRecipient: await wallet.getAddress(), + }); + const result = await tx.wait(); + const l2BalanceAfterDeposit = await wallet.getBalance(); + const l1BalanceAfterDeposit = await wallet.getBalanceL1(); + expect(result).not.to.be.null; + expect(l2BalanceAfterDeposit.sub(l2BalanceBeforeDeposit).gte(amount)).to + .be.true; + expect(l1BalanceBeforeDeposit.sub(l1BalanceAfterDeposit).gte(amount)).to + .be.true; + }).timeout(20_000); + + it('should deposit base token to L2 network', async () => { + const amount = 5; + const baseTokenL1 = await wallet.getBaseToken(); + const l2BalanceBeforeDeposit = await wallet.getBalance(); + const l1BalanceBeforeDeposit = await wallet.getBalanceL1(baseTokenL1); + const tx = await wallet.deposit({ + token: baseTokenL1, + to: await wallet.getAddress(), + amount: amount, + approveERC20: true, + refundRecipient: await wallet.getAddress(), + }); + const result = await tx.wait(); + const l2BalanceAfterDeposit = await wallet.getBalance(); + const l1BalanceAfterDeposit = await wallet.getBalanceL1(baseTokenL1); + expect(result).not.to.be.null; + expect(l2BalanceAfterDeposit.sub(l2BalanceBeforeDeposit).gt(0)).to.be + .true; + expect(l1BalanceBeforeDeposit.sub(l1BalanceAfterDeposit).gt(0)).to.be + .true; + }).timeout(20_000); + + it('should deposit DAI to L2 network', async () => { + const amount = 5; + const l2DAI = await provider.l2TokenAddress(DAI_L1); + const l2BalanceBeforeDeposit = await wallet.getBalance(l2DAI); + const l1BalanceBeforeDeposit = await wallet.getBalanceL1(DAI_L1); + const tx = await wallet.deposit({ + token: DAI_L1, + to: await wallet.getAddress(), + amount: amount, + approveERC20: true, + approveBaseERC20: true, + refundRecipient: await wallet.getAddress(), + }); + const result = await tx.wait(); + const l2BalanceAfterDeposit = await wallet.getBalance(l2DAI); + const l1BalanceAfterDeposit = await wallet.getBalanceL1(DAI_L1); + expect(result).not.to.be.null; + expect(l2BalanceAfterDeposit.sub(l2BalanceBeforeDeposit).eq(amount)).to + .be.true; + expect(l1BalanceBeforeDeposit.sub(l1BalanceAfterDeposit).eq(amount)).to + .be.true; + }).timeout(20_000); + } + }); - it('should throw an error when there is not enough allowance to cover the deposit', async () => { - try { - await wallet.getFullRequiredDepositFee({ + describe('#claimFailedDeposit()', () => { + if (IS_ETH_BASED) { + it('should claim failed deposit', async () => { + const response = await wallet.deposit({ token: DAI_L1, to: await wallet.getAddress(), + amount: 5, + approveERC20: true, + refundRecipient: await wallet.getAddress(), + l2GasLimit: 300_000, // make it fail because of low gas }); - } catch (e) { - expect((e as Error).message).to.be.equal( - 'Not enough allowance to cover the deposit!' - ); - } - }).timeout(10_000); + try { + await response.waitFinalize(); + } catch (error) { + const blockNumber = ( + await wallet + ._providerL2() + .getTransaction((error as any).transactionHash) + ).blockNumber!; + // Now wait for block number to be executed. + let blockDetails: types.BlockDetails; + do { + // still not executed. + await utils.sleep(500); + blockDetails = await wallet + ._providerL2() + .getBlockDetails(blockNumber); + } while (!blockDetails || !blockDetails.executeTxHash); + const tx = await wallet.claimFailedDeposit( + (error as any).transactionHash + ); + const result = await tx.wait(); + expect(result.blockHash).to.be.not.null; + } + }).timeout(1000000_000); + + it('should throw an error when trying to claim successful deposit', async () => { + const response = await wallet.deposit({ + token: utils.LEGACY_ETH_ADDRESS, + to: await wallet.getAddress(), + amount: 7_000_000_000, + refundRecipient: await wallet.getAddress(), + }); + const tx = await response.waitFinalize(); + try { + await wallet.claimFailedDeposit(tx.transactionHash); + } catch (e) { + expect((e as Error).message).to.be.equal( + 'Cannot claim successful deposit' + ); + } + }).timeout(30_000); + } else { + it('should throw an error when trying to claim successful deposit', async () => { + const response = await wallet.deposit({ + token: await wallet.getBaseToken(), + to: await wallet.getAddress(), + amount: 5, + approveERC20: true, + refundRecipient: await wallet.getAddress(), + }); + const tx = await response.waitFinalize(); + try { + await wallet.claimFailedDeposit(tx.transactionHash); + } catch (e) { + expect((e as Error).message).to.be.equal( + 'Cannot claim successful deposit' + ); + } + }).timeout(30_000); + } + }); - it('should return fee for DAI token deposit', async () => { - const tx = await wallet.approveERC20(DAI_L1, 5); - await tx.wait(); + describe('#getFullRequiredDepositFee()', () => { + if (IS_ETH_BASED) { + it('should return fee for ETH token deposit', async () => { + const result = await wallet.getFullRequiredDepositFee({ + token: utils.LEGACY_ETH_ADDRESS, + to: await wallet.getAddress(), + }); - const result = await wallet.getFullRequiredDepositFee({ - token: DAI_L1, - to: await wallet.getAddress(), + expect(BigNumber.from(result.baseCost).isZero()).to.be.false; + expect(BigNumber.from(result.l1GasLimit).isZero()).to.be.false; + expect(BigNumber.from(result.l2GasLimit).isZero()).to.be.false; + expect(BigNumber.from(result.maxFeePerGas).isZero()).to.be.false; + expect(BigNumber.from(result.maxPriorityFeePerGas).isZero()).to.be + .false; }); - expect(BigNumber.from(result.baseCost).isZero()).to.be.false; - expect(BigNumber.from(result.l1GasLimit).isZero()).to.be.false; - expect(BigNumber.from(result.l2GasLimit).isZero()).to.be.false; - expect(BigNumber.from(result.maxFeePerGas).isZero()).to.be.false; - expect(BigNumber.from(result.maxPriorityFeePerGas).isZero()).to.be.false; - }).timeout(10_000); - it('should throw an error when there is not enough balance for the deposit', async () => { - try { - const randomWallet = new Wallet( - ethers.Wallet.createRandom().privateKey, - provider, - ethProvider - ); - await randomWallet.getFullRequiredDepositFee({ + it('should throw an error when there is not enough allowance to cover the deposit', async () => { + try { + await wallet.getFullRequiredDepositFee({ + token: DAI_L1, + to: await wallet.getAddress(), + }); + } catch (e) { + expect((e as Error).message).to.be.equal( + 'Not enough allowance to cover the deposit!' + ); + } + }).timeout(10_000); + + it('should return fee for DAI token deposit', async () => { + const tx = await wallet.approveERC20(DAI_L1, 5); + await tx.wait(); + + const result = await wallet.getFullRequiredDepositFee({ token: DAI_L1, to: await wallet.getAddress(), }); - } catch (e) { - expect((e as Error).message).to.include( - 'Not enough balance for deposit!' + expect(BigNumber.from(result.baseCost).isZero()).to.be.false; + expect(BigNumber.from(result.l1GasLimit).isZero()).to.be.false; + expect(BigNumber.from(result.l2GasLimit).isZero()).to.be.false; + expect(BigNumber.from(result.maxFeePerGas).isZero()).to.be.false; + expect(BigNumber.from(result.maxPriorityFeePerGas).isZero()).to.be + .false; + }).timeout(10_000); + + it('should throw an error when there is not enough balance for the deposit', async () => { + try { + const randomWallet = new Wallet( + ethers.Wallet.createRandom().privateKey, + provider, + ethProvider + ); + await randomWallet.getFullRequiredDepositFee({ + token: DAI_L1, + to: await wallet.getAddress(), + }); + } catch (e) { + expect((e as Error).message).to.include( + 'Not enough balance for deposit!' + ); + } + }).timeout(10_000); + } else { + it('should throw an error when there is not enough base token allowance to cover the deposit', async () => { + try { + await Wallet.createRandom() + .connectToL1(ethProvider) + .connect(provider) + .getFullRequiredDepositFee({ + token: utils.LEGACY_ETH_ADDRESS, + to: await wallet.getAddress(), + }); + } catch (e) { + expect((e as Error).message).to.be.equal( + 'Not enough base token allowance to cover the deposit!' + ); + } + }).timeout(10_000); + + it('should return fee for ETH token deposit', async () => { + const token = utils.LEGACY_ETH_ADDRESS; + const approveParams = await wallet.getDepositAllowanceParams(token, 1); + + await ( + await wallet.approveERC20( + approveParams[0].token, + approveParams[0].allowance + ) + ).wait(); + + const result = await wallet.getFullRequiredDepositFee({ + token: token, + to: await wallet.getAddress(), + }); + + expect(BigNumber.from(result.baseCost).isZero()).to.be.false; + expect(BigNumber.from(result.l1GasLimit).isZero()).to.be.false; + expect(BigNumber.from(result.l2GasLimit).isZero()).to.be.false; + expect(BigNumber.from(result.maxFeePerGas).isZero()).to.be.false; + expect(BigNumber.from(result.maxPriorityFeePerGas).isZero()).to.be + .false; + }).timeout(10_000); + + it('should return fee for base token deposit', async () => { + const token = await wallet.getBaseToken(); + const approveParams = await wallet.getDepositAllowanceParams(token, 1); + + await ( + await wallet.approveERC20( + approveParams[0].token, + approveParams[0].allowance + ) + ).wait(); + + const result = await wallet.getFullRequiredDepositFee({ + token: token, + to: await wallet.getAddress(), + }); + expect(result).not.to.be.null; + }).timeout(10_000); + + it('should return fee for DAI token deposit', async () => { + const token = DAI_L1; + const approveParams = await wallet.getDepositAllowanceParams(token, 1); + + await ( + await wallet.approveERC20( + approveParams[0].token, + approveParams[0].allowance + ) + ).wait(); + await ( + await wallet.approveERC20( + approveParams[1].token, + approveParams[1].allowance + ) + ).wait(); + + const result = await wallet.getFullRequiredDepositFee({ + token: token, + to: await wallet.getAddress(), + }); + expect(BigNumber.from(result.baseCost).isZero()).to.be.false; + expect(BigNumber.from(result.l1GasLimit).isZero()).to.be.false; + expect(BigNumber.from(result.l2GasLimit).isZero()).to.be.false; + expect(BigNumber.from(result.maxFeePerGas).isZero()).to.be.false; + expect(BigNumber.from(result.maxPriorityFeePerGas).isZero()).to.be + .false; + }).timeout(10_000); + + it('should throw an error when there is not enough token allowance to cover the deposit', async () => { + const token = DAI_L1; + const randomWallet = Wallet.createRandom() + .connectToL1(ethProvider) + .connect(provider); + + // mint base token to random wallet + const baseToken = ITestnetErc20TokenFactory.connect( + await wallet.getBaseToken(), + wallet._signerL1() ); - } - }).timeout(10_000); + const baseTokenMintTx = await baseToken.mint( + await randomWallet.getAddress(), + ethers.utils.parseEther('0.5') + ); + await baseTokenMintTx.wait(); + + // transfer ETH to random wallet so that base token approval tx can be performed + const transferTx = await new ethers.Wallet( + PRIVATE_KEY1, + ethProvider + ).sendTransaction({ + to: await randomWallet.getAddress(), + value: ethers.utils.parseEther('0.1'), + }); + await transferTx.wait(); + + const approveParams = await randomWallet.getDepositAllowanceParams( + token, + 1 + ); + // only approve base token + await ( + await randomWallet.approveERC20( + approveParams[0].token, + approveParams[0].allowance + ) + ).wait(); + + try { + await randomWallet.getFullRequiredDepositFee({ + token: token, + to: await wallet.getAddress(), + }); + } catch (e) { + expect((e as Error).message).to.be.equal( + 'Not enough token allowance to cover the deposit!' + ); + } + }).timeout(20_000); + } }); describe('#withdraw()', () => { it('should withdraw ETH to L1 network', async () => { const amount = 7_000_000_000; const l2BalanceBeforeWithdrawal = await wallet.getBalance(); + const token = IS_ETH_BASED + ? utils.ETH_ADDRESS_IN_CONTRACTS + : await wallet.l2TokenAddress(utils.ETH_ADDRESS_IN_CONTRACTS); const withdrawTx = await wallet.withdraw({ - token: utils.ETH_ADDRESS, + token: token, to: await wallet.getAddress(), amount: amount, }); @@ -734,19 +1202,19 @@ describe('Wallet', () => { const paymasterTokenBalanceBeforeWithdrawal = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const l2BalanceBeforeWithdrawal = await wallet.getBalance(); const l2ApprovalTokenBalanceBeforeWithdrawal = - await wallet.getBalance(TOKEN); + await wallet.getBalance(APPROVAL_TOKEN); const withdrawTx = await wallet.withdraw({ - token: utils.ETH_ADDRESS, + token: utils.LEGACY_ETH_ADDRESS, to: await wallet.getAddress(), amount: amount, paymasterParams: utils.getPaymasterParams(PAYMASTER, { type: 'ApprovalBased', - token: TOKEN, + token: APPROVAL_TOKEN, minimalAllowance: BigNumber.from(1), innerInput: new Uint8Array(), }), @@ -764,11 +1232,11 @@ describe('Wallet', () => { const paymasterTokenBalanceAfterWithdrawal = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const l2BalanceAfterWithdrawal = await wallet.getBalance(); const l2ApprovalTokenBalanceAfterWithdrawal = - await wallet.getBalance(TOKEN); + await wallet.getBalance(APPROVAL_TOKEN); expect( paymasterBalanceBeforeWithdrawal @@ -828,12 +1296,12 @@ describe('Wallet', () => { const paymasterTokenBalanceBeforeWithdrawal = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const l2BalanceBeforeWithdrawal = await wallet.getBalance(l2DAI); const l1BalanceBeforeWithdrawal = await wallet.getBalanceL1(DAI_L1); const l2ApprovalTokenBalanceBeforeWithdrawal = - await wallet.getBalance(TOKEN); + await wallet.getBalance(APPROVAL_TOKEN); const withdrawTx = await wallet.withdraw({ token: l2DAI, @@ -841,7 +1309,7 @@ describe('Wallet', () => { amount: amount, paymasterParams: utils.getPaymasterParams(PAYMASTER, { type: 'ApprovalBased', - token: TOKEN, + token: APPROVAL_TOKEN, minimalAllowance: BigNumber.from(1), innerInput: new Uint8Array(), }), @@ -859,12 +1327,12 @@ describe('Wallet', () => { const paymasterTokenBalanceAfterWithdrawal = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const l2BalanceAfterWithdrawal = await wallet.getBalance(l2DAI); const l1BalanceAfterWithdrawal = await wallet.getBalanceL1(DAI_L1); const l2ApprovalTokenBalanceAfterWithdrawal = - await wallet.getBalance(TOKEN); + await wallet.getBalance(APPROVAL_TOKEN); expect( paymasterBalanceBeforeWithdrawal @@ -892,60 +1360,141 @@ describe('Wallet', () => { }); describe('#getRequestExecuteTx()', () => { - it('should return request execute transaction', async () => { - const result = await wallet.getRequestExecuteTx({ - contractAddress: await provider.getMainContractAddress(), - calldata: '0x', - l2Value: 7_000_000_000, + const amount = 7_000_000_000; + if (IS_ETH_BASED) { + it('should return request execute transaction', async () => { + const result = await wallet.getRequestExecuteTx({ + contractAddress: await provider.getBridgehubContractAddress(), + calldata: '0x', + l2Value: amount, + }); + expect(result).not.to.be.null; }); - expect(result).not.to.be.null; - }); + } else { + it('should return request execute transaction', async () => { + const result = await wallet.getRequestExecuteTx({ + contractAddress: await wallet.getAddress(), + calldata: '0x', + l2Value: amount, + overrides: {nonce: 0}, + }); + expect(result).not.to.be.null; + }); + } }); describe('#estimateGasRequestExecute()', () => { - it('should return gas estimation for request execute transaction', async () => { - const result = await wallet.estimateGasRequestExecute({ - contractAddress: await provider.getMainContractAddress(), - calldata: '0x', - l2Value: 7_000_000_000, + if (IS_ETH_BASED) { + it('should return gas estimation for request execute transaction', async () => { + const result = await wallet.estimateGasRequestExecute({ + contractAddress: await provider.getBridgehubContractAddress(), + calldata: '0x', + l2Value: 7_000_000_000, + }); + expect(result.isZero()).to.be.false; }); - expect(result.isZero()).to.be.false; - }); + } else { + it('should return gas estimation for request execute transaction', async () => { + const tx = { + contractAddress: await wallet.getAddress(), + calldata: '0x', + l2Value: 7_000_000_000, + }; + + const approveParams = await wallet.getRequestExecuteAllowanceParams(tx); + await ( + await wallet.approveERC20( + approveParams.token, + approveParams.allowance + ) + ).wait(); + + const result = await wallet.estimateGasRequestExecute(tx); + expect(result.isZero()).to.be.false; + }).timeout(10_000); + } }); describe('#requestExecute()', () => { - it('should request transaction execution on L2 network', async () => { - const amount = 7_000_000_000; - const l2BalanceBeforeExecution = await wallet.getBalance(); - const l1BalanceBeforeExecution = await wallet.getBalanceL1(); - const tx = await wallet.requestExecute({ - contractAddress: await provider.getMainContractAddress(), - calldata: '0x', - l2Value: amount, - l2GasLimit: 900_000, - }); - const result = await tx.wait(); - const l2BalanceAfterExecution = await wallet.getBalance(); - const l1BalanceAfterExecution = await wallet.getBalanceL1(); - expect(result).not.to.be.null; - expect(l2BalanceAfterExecution.sub(l2BalanceBeforeExecution).gte(amount)) - .to.be.true; - expect(l1BalanceBeforeExecution.sub(l1BalanceAfterExecution).gte(amount)) - .to.be.true; - }).timeout(10_000); + if (IS_ETH_BASED) { + it('should request transaction execution on L2 network', async () => { + const amount = 7_000_000_000; + const l2BalanceBeforeExecution = await wallet.getBalance(); + const l1BalanceBeforeExecution = await wallet.getBalanceL1(); + const tx = await wallet.requestExecute({ + contractAddress: await provider.getBridgehubContractAddress(), + calldata: '0x', + l2Value: amount, + l2GasLimit: 900_000, + }); + const result = await tx.wait(); + const l2BalanceAfterExecution = await wallet.getBalance(); + const l1BalanceAfterExecution = await wallet.getBalanceL1(); + expect(result).not.to.be.null; + expect( + l2BalanceAfterExecution.sub(l2BalanceBeforeExecution).gte(amount) + ).to.be.true; + expect( + l1BalanceBeforeExecution.sub(l1BalanceAfterExecution).gte(amount) + ).to.be.true; + }).timeout(10_000); + } else { + it('should request transaction execution on L2 network', async () => { + const amount = 7_000_000_000; + const request = { + contractAddress: await wallet.getAddress(), + calldata: '0x', + l2Value: amount, + l2GasLimit: BigNumber.from(1_319_957), + operatorTip: 0, + gasPerPubdataByte: 800, + refundRecipient: await wallet.getAddress(), + overrides: { + maxFeePerGas: BigNumber.from(1_500_000_010), + maxPriorityFeePerGas: BigNumber.from(1_500_000_000), + gasLimit: BigNumber.from(238_654), + value: 0, + }, + }; + + const approveParams = + await wallet.getRequestExecuteAllowanceParams(request); + await ( + await wallet.approveERC20( + approveParams.token, + approveParams.allowance + ) + ).wait(); + + const l2BalanceBeforeExecution = await wallet.getBalance(); + const l1BalanceBeforeExecution = await wallet.getBalanceL1(); + + const tx = await wallet.requestExecute(request); + const result = await tx.wait(); + const l2BalanceAfterExecution = await wallet.getBalance(); + const l1BalanceAfterExecution = await wallet.getBalanceL1(); + expect(result).not.to.be.null; + expect( + l2BalanceAfterExecution.sub(l2BalanceBeforeExecution).gte(amount) + ).to.be.true; + expect( + l1BalanceBeforeExecution.sub(l1BalanceAfterExecution).gte(amount) + ).to.be.true; + }).timeout(10_000); + } }); describe('#transfer()', () => { it('should transfer ETH', async () => { const amount = 7_000_000_000; - const balanceBeforeTransfer = await provider.getBalance(RECEIVER); + const balanceBeforeTransfer = await provider.getBalance(ADDRESS2); const tx = await wallet.transfer({ - token: utils.ETH_ADDRESS, - to: RECEIVER, + token: utils.LEGACY_ETH_ADDRESS, + to: ADDRESS2, amount: amount, }); const result = await tx.wait(); - const balanceAfterTransfer = await provider.getBalance(RECEIVER); + const balanceAfterTransfer = await provider.getBalance(ADDRESS2); expect(result).not.to.be.null; expect(balanceAfterTransfer.sub(balanceBeforeTransfer).eq(amount)).to.be .true; @@ -960,20 +1509,20 @@ describe('Wallet', () => { const paymasterTokenBalanceBeforeTransfer = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const senderBalanceBeforeTransfer = await wallet.getBalance(); const senderApprovalTokenBalanceBeforeTransfer = - await wallet.getBalance(TOKEN); - const receiverBalanceBeforeTransfer = await provider.getBalance(RECEIVER); + await wallet.getBalance(APPROVAL_TOKEN); + const receiverBalanceBeforeTransfer = await provider.getBalance(ADDRESS2); const tx = await wallet.transfer({ - token: utils.ETH_ADDRESS, - to: RECEIVER, + token: utils.LEGACY_ETH_ADDRESS, + to: ADDRESS2, amount: amount, paymasterParams: utils.getPaymasterParams(PAYMASTER, { type: 'ApprovalBased', - token: TOKEN, + token: APPROVAL_TOKEN, minimalAllowance: BigNumber.from(1), innerInput: new Uint8Array(), }), @@ -985,12 +1534,12 @@ describe('Wallet', () => { const paymasterTokenBalanceAfterTransfer = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const senderBalanceAfterTransfer = await wallet.getBalance(); const senderApprovalTokenBalanceAfterTransfer = - await wallet.getBalance(TOKEN); - const receiverBalanceAfterTransfer = await provider.getBalance(RECEIVER); + await wallet.getBalance(APPROVAL_TOKEN); + const receiverBalanceAfterTransfer = await provider.getBalance(ADDRESS2); expect( paymasterBalanceBeforeTransfer.sub(paymasterBalanceAfterTransfer).gte(0) @@ -1022,18 +1571,18 @@ describe('Wallet', () => { const amount = 5; const l2DAI = await provider.l2TokenAddress(DAI_L1); const balanceBeforeTransfer = await provider.getBalance( - RECEIVER, + ADDRESS2, 'latest', l2DAI ); const tx = await wallet.transfer({ token: l2DAI, - to: RECEIVER, + to: ADDRESS2, amount: amount, }); const result = await tx.wait(); const balanceAfterTransfer = await provider.getBalance( - RECEIVER, + ADDRESS2, 'latest', l2DAI ); @@ -1052,24 +1601,24 @@ describe('Wallet', () => { const paymasterTokenBalanceBeforeTransfer = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const senderBalanceBeforeTransfer = await wallet.getBalance(l2DAI); const senderApprovalTokenBalanceBeforeTransfer = - await wallet.getBalance(TOKEN); + await wallet.getBalance(APPROVAL_TOKEN); const receiverBalanceBeforeTransfer = await provider.getBalance( - RECEIVER, + ADDRESS2, 'latest', l2DAI ); const tx = await wallet.transfer({ token: l2DAI, - to: RECEIVER, + to: ADDRESS2, amount: amount, paymasterParams: utils.getPaymasterParams(PAYMASTER, { type: 'ApprovalBased', - token: TOKEN, + token: APPROVAL_TOKEN, minimalAllowance: BigNumber.from(1), innerInput: new Uint8Array(), }), @@ -1081,13 +1630,13 @@ describe('Wallet', () => { const paymasterTokenBalanceAfterTransfer = await provider.getBalance( PAYMASTER, 'latest', - TOKEN + APPROVAL_TOKEN ); const senderBalanceAfterTransfer = await wallet.getBalance(l2DAI); const senderApprovalTokenBalanceAfterTransfer = - await wallet.getBalance(TOKEN); + await wallet.getBalance(APPROVAL_TOKEN); const receiverBalanceAfterTransfer = await provider.getBalance( - RECEIVER, + ADDRESS2, 'latest', l2DAI ); @@ -1117,13 +1666,30 @@ describe('Wallet', () => { .eq(amount) ).to.be.true; }).timeout(25_000); + + if (!IS_ETH_BASED) { + it('should transfer base token', async () => { + const amount = 7_000_000_000; + const balanceBeforeTransfer = await provider.getBalance(ADDRESS2); + const tx = await wallet.transfer({ + token: await wallet.getBaseToken(), + to: ADDRESS2, + amount: amount, + }); + const result = await tx.wait(); + const balanceAfterTransfer = await provider.getBalance(ADDRESS2); + expect(result).not.to.be.null; + expect(balanceAfterTransfer.sub(balanceBeforeTransfer).eq(amount)).to.be + .true; + }).timeout(25_000); + } }); describe('#signTransaction()', () => { it('should return a signed type EIP1559 transaction', async () => { const result = await wallet.signTransaction({ type: 2, - to: RECEIVER, + to: ADDRESS2, value: BigNumber.from(7_000_000_000), }); expect(result).not.to.be.null; @@ -1132,7 +1698,7 @@ describe('Wallet', () => { it('should return a signed EIP712 transaction', async () => { const result = await wallet.signTransaction({ type: utils.EIP712_TX_TYPE, - to: RECEIVER, + to: ADDRESS2, value: ethers.utils.parseEther('1'), }); expect(result).not.to.be.null; @@ -1142,8 +1708,8 @@ describe('Wallet', () => { try { await wallet.signTransaction({ type: utils.EIP712_TX_TYPE, - from: RECEIVER, - to: RECEIVER, + from: ADDRESS2, + to: ADDRESS2, value: 7_000_000_000, }); } catch (e) { diff --git a/tests/setup.ts b/tests/setup.ts index b8147699..7bb85260 100644 --- a/tests/setup.ts +++ b/tests/setup.ts @@ -1,14 +1,14 @@ import { Provider, - types, Wallet, ContractFactory, Contract, + types, utils, } from '../src'; import {ethers} from 'ethers'; +import {ITestnetErc20TokenFactory} from '../src/typechain/ITestnetErc20TokenFactory'; -import TokensL1 from './files/tokens.json'; import Token from './files/Token.json'; import Paymaster from './files/Paymaster.json'; @@ -20,6 +20,7 @@ const ethProvider = ethers.getDefaultProvider('http://127.0.0.1:8545'); const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider); +const DAI_L1 = '0x70a0F165d6f8054d0d0CF8dFd4DD2005f0AF6B55'; const SALT = '0x293328ad84b118194c65a0dc0defdb6483740d3163fd99b260907e15f2e2f642'; const TOKEN = '0x841c43Fa5d8fFfdB9efE3358906f7578d8700Dd4'; // deployed by using create2 and SALT @@ -82,27 +83,89 @@ async function deployPaymasterAndToken(): Promise<{ return {token: tokenAddress, paymaster: paymasterAddress}; } -// Creates token on L2 by depositing -async function createTokenL2(l1TokenAddress: string): Promise { +/* +Mints tokens on L1 in case L2 is non-ETH based chain. +It mints based token, provided alternative tokens (different from base token) and wETH. +*/ +async function mintTokensOnL1(l1Token: string) { + if (l1Token !== utils.ETH_ADDRESS_IN_CONTRACTS) { + const to = ITestnetErc20TokenFactory.connect(l1Token, wallet._signerL1()); + const mintTx = await to.mint( + await wallet.getAddress(), + ethers.utils.parseEther('20000') + ); + await mintTx.wait(); + } +} + +/* +Send base token to L2 in case L2 in non-ETH base chain. +*/ +async function sendTokenToL2(l1TokenAddress: string) { const priorityOpResponse = await wallet.deposit({ token: l1TokenAddress, to: await wallet.getAddress(), - amount: 100, + amount: ethers.utils.parseEther('10000'), approveERC20: true, + approveBaseERC20: true, refundRecipient: await wallet.getAddress(), }); - await priorityOpResponse.waitFinalize(); - return await wallet.l2TokenAddress(l1TokenAddress); + const receipt = await priorityOpResponse.waitFinalize(); + console.log(`Send funds tx: ${receipt.transactionHash}`); } -/* -Deploy token to the L2 network through deposit transaction. -Deploy approval token and it's paymaster. - */ async function main() { - console.log('===== Depositing DAI to L2 ====='); - const l2TokenAddress = await createTokenL2(TokensL1[0].address); - console.log(`L2 DAI address: ${l2TokenAddress}`); + const baseToken = await wallet.getBaseToken(); + console.log(`Wallet address: ${await wallet.getAddress()}`); + console.log(`Base token L1: ${baseToken}`); + + console.log( + `L1 base token balance before: ${await wallet.getBalanceL1(baseToken)}` + ); + console.log(`L2 base token balance before: ${await wallet.getBalance()}`); + + await mintTokensOnL1(baseToken); + await sendTokenToL2(baseToken); + + console.log( + `L1 base token balance after: ${await wallet.getBalanceL1(baseToken)}` + ); + console.log(`L2 base token balance after: ${await wallet.getBalance()} \n`); + + if (baseToken !== utils.ETH_ADDRESS_IN_CONTRACTS) { + const l2EthAddress = await wallet.l2TokenAddress( + utils.ETH_ADDRESS_IN_CONTRACTS + ); + console.log(`ETH L1: ${utils.ETH_ADDRESS_IN_CONTRACTS}`); + console.log(`ETH L2: ${l2EthAddress}`); + + console.log(`L1 ETH balance before: ${await wallet.getBalanceL1()}`); + console.log( + `L2 ETH balance before: ${await wallet.getBalance(l2EthAddress)}` + ); + + await mintTokensOnL1(utils.ETH_ADDRESS_IN_CONTRACTS); + await sendTokenToL2(utils.ETH_ADDRESS_IN_CONTRACTS); + + console.log(`L1 ETH balance after: ${await wallet.getBalanceL1()}`); + console.log( + `L2 ETH balance after: ${await wallet.getBalance(l2EthAddress)}\n` + ); + } + + const l2DAIAddress = await wallet.l2TokenAddress(DAI_L1); + console.log(`DAI L1: ${DAI_L1}`); + console.log(`DAI L2: ${l2DAIAddress}`); + + console.log(`L1 DAI balance before: ${await wallet.getBalanceL1(DAI_L1)}`); + console.log( + `L2 DAI balance before: ${await wallet.getBalance(l2DAIAddress)}` + ); + + await mintTokensOnL1(DAI_L1); + await sendTokenToL2(DAI_L1); + console.log(`L1 DAI balance after: ${await wallet.getBalanceL1(DAI_L1)}`); + console.log(`L2 DAI balance after: ${await wallet.getBalance(l2DAIAddress)}`); console.log('===== Deploying token and paymaster ====='); const {token, paymaster} = await deployPaymasterAndToken(); diff --git a/tests/unit/signer.test.ts b/tests/unit/signer.test.ts index c9b65ad1..7cdc30f9 100644 --- a/tests/unit/signer.test.ts +++ b/tests/unit/signer.test.ts @@ -2,19 +2,17 @@ import * as chai from 'chai'; import '../custom-matchers'; import {utils, EIP712Signer} from '../../src'; import {ethers, BigNumber} from 'ethers'; +import {ADDRESS1, ADDRESS2} from '../utils'; const {expect} = chai; describe('EIP712Signer', () => { - const ADDRESS = '0x36615Cf349d7F6344891B1e7CA7C72883F5dc049'; - const RECEIVER = '0xa61464658AfeAf65CccaaFD3a512b69A83B77618'; - describe('#getSignInput()', () => { it('should return a populated transaction', async () => { const tx = { txType: utils.EIP712_TX_TYPE, - from: ADDRESS, - to: RECEIVER, + from: ADDRESS1, + to: ADDRESS2, gasLimit: BigNumber.from(21_000), gasPerPubdataByteLimit: utils.DEFAULT_GAS_PER_PUBDATA_LIMIT, maxFeePerGas: BigNumber.from(250_000_000), @@ -29,9 +27,9 @@ describe('EIP712Signer', () => { const result = EIP712Signer.getSignInput({ type: utils.EIP712_TX_TYPE, - to: RECEIVER, + to: ADDRESS2, value: BigNumber.from(7_000_000), - from: ADDRESS, + from: ADDRESS1, nonce: 0, chainId: 270, gasPrice: BigNumber.from(250_000_000), @@ -44,8 +42,8 @@ describe('EIP712Signer', () => { it('should return a populated transaction with default values', async () => { const tx = { txType: utils.EIP712_TX_TYPE, - from: ADDRESS, - to: RECEIVER, + from: ADDRESS1, + to: ADDRESS2, gasLimit: 0, gasPerPubdataByteLimit: utils.DEFAULT_GAS_PER_PUBDATA_LIMIT, maxFeePerGas: 0, @@ -60,8 +58,8 @@ describe('EIP712Signer', () => { const result = EIP712Signer.getSignInput({ type: utils.EIP712_TX_TYPE, - to: RECEIVER, - from: ADDRESS, + to: ADDRESS2, + from: ADDRESS1, }); expect(result).to.be.deep.equal(tx); }); diff --git a/tests/unit/smart-account.test.ts b/tests/unit/smart-account.test.ts index 82a978d7..df018c68 100644 --- a/tests/unit/smart-account.test.ts +++ b/tests/unit/smart-account.test.ts @@ -10,26 +10,22 @@ import { } from '../../src/smart-account-utils'; import {BigNumber} from 'ethers'; import {_TypedDataEncoder, hashMessage} from '@ethersproject/hash'; +import {PRIVATE_KEY1, ADDRESS1, PRIVATE_KEY2, ADDRESS2} from '../utils'; const {expect} = chai; describe('signPayloadWithECDSA()', () => { - const ADDRESS = '0x36615Cf349d7F6344891B1e7CA7C72883F5dc049'; - const PRIVATE_KEY = - '0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110'; - const RECEIVER = '0xa61464658AfeAf65CccaaFD3a512b69A83B77618'; - it('should return signature by signing EIP712 transaction hash', async () => { const tx: types.TransactionRequest = { chainId: 270, - from: ADDRESS, - to: RECEIVER, + from: ADDRESS1, + to: ADDRESS2, value: 7_000_000_000, }; const txHash = EIP712Signer.getSignedDigest(tx); - const result = await signPayloadWithECDSA(txHash, PRIVATE_KEY); + const result = await signPayloadWithECDSA(txHash, PRIVATE_KEY1); expect(result).to.be.equal( '0x89905d36a3cdde117445d6c58627061a53f09cf0535d73719d82d4d96fe332541167e2e3d38ce3cb2751a0203eff2a71f55ad45dc91623587f5480ec1883281b1b' ); @@ -39,7 +35,7 @@ describe('signPayloadWithECDSA()', () => { const message = 'Hello World!'; const messageHash = hashMessage(message); - const result = await signPayloadWithECDSA(messageHash, PRIVATE_KEY); + const result = await signPayloadWithECDSA(messageHash, PRIVATE_KEY1); expect(result).to.be.equal( '0x7c15eb760c394b0ca49496e71d841378d8bfd4f9fb67e930eb5531485329ab7c67068d1f8ef4b480ec327214ee6ed203687e3fbe74b92367b259281e340d16fd1c' ); @@ -56,7 +52,7 @@ describe('signPayloadWithECDSA()', () => { }, {name: 'John', age: 30} ); - const result = await signPayloadWithECDSA(typedDataHash, PRIVATE_KEY); + const result = await signPayloadWithECDSA(typedDataHash, PRIVATE_KEY1); expect(result).to.be.equal( '0xbcaf0673c0c2b0e120165d207d42281d0c6e85f0a7f6b8044b0578a91cf5bda66b4aeb62aca4ae17012a38d71c9943e27285792fa7d788d848f849e3ea2e614b1b' ); @@ -64,13 +60,6 @@ describe('signPayloadWithECDSA()', () => { }); describe('signPayloadWithMultipleECDSA()', () => { - const ADDRESS1 = '0x36615Cf349d7F6344891B1e7CA7C72883F5dc049'; - const PRIVATE_KEY1 = - '0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110'; - const ADDRESS2 = '0xa61464658AfeAf65CccaaFD3a512b69A83B77618'; - const PRIVATE_KEY2 = - '0xac1e735be8536c6534bb4f17f06f6afc73b2b5ba84ac2cfb12f7461b20c0bbe3'; - it('should return signature by signing EIP712 transaction hash', async () => { const tx: TransactionRequest = { chainId: 270, @@ -125,34 +114,31 @@ describe('signPayloadWithMultipleECDSA()', () => { }); describe('populateTransaction()', () => { - const ADDRESS = '0x36615Cf349d7F6344891B1e7CA7C72883F5dc049'; - const PRIVATE_KEY = - '0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110'; - const RECEIVER = '0xa61464658AfeAf65CccaaFD3a512b69A83B77618'; - const provider = Provider.getDefaultProvider(types.Network.Localhost); it('should populate `tx.from` to address derived from private key if it not set', async () => { const tx: TransactionRequest = { chainId: 270, - to: '0xa61464658AfeAf65CccaaFD3a512b69A83B77618', + to: ADDRESS2, value: BigNumber.from(7_000_000_000), type: 113, data: '0x', + gasPrice: BigNumber.from(100_000_000), + gasLimit: BigNumber.from(190_560), customData: { gasPerPubdata: 50_000, factoryDeps: [], }, - from: '0x36615Cf349d7F6344891B1e7CA7C72883F5dc049', + from: ADDRESS1, }; const result = await populateTransactionECDSA( { chainId: 270, - to: RECEIVER, + to: ADDRESS2, value: 7_000_000_000, }, - PRIVATE_KEY, + PRIVATE_KEY1, provider ); expect(result).to.be.deepEqualExcluding(tx, [ @@ -160,20 +146,20 @@ describe('populateTransaction()', () => { 'gasPrice', 'gasLimit', ]); - expect(BigNumber.from(result.gasPrice).gt(BigNumber.from(0))).to.be.true; - expect(BigNumber.from(result.gasLimit).gt(BigNumber.from(0))).to.be.true; + expect(BigNumber.from(result.gasPrice).isZero()).to.be.false; + expect(BigNumber.from(result.gasLimit).isZero()).to.be.false; }); it('should throw an error when provider is not set', async () => { const tx: TransactionRequest = { chainId: 270, - from: ADDRESS, - to: RECEIVER, + from: ADDRESS1, + to: ADDRESS2, value: 7_000_000_000, }; try { - await populateTransactionECDSA(tx, PRIVATE_KEY); + await populateTransactionECDSA(tx, PRIVATE_KEY1); } catch (error) { expect((error as Error).message).to.be.equal( 'Provider is required but is not provided!' @@ -183,21 +169,16 @@ describe('populateTransaction()', () => { }); describe('populateTransactionMultisig()', () => { - const ADDRESS = '0x36615Cf349d7F6344891B1e7CA7C72883F5dc049'; - const PRIVATE_KEY = - '0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110'; - const RECEIVER = '0xa61464658AfeAf65CccaaFD3a512b69A83B77618'; - it('should throw an error when multiple keys are not provided', async () => { const tx: TransactionRequest = { chainId: 270, - from: ADDRESS, - to: RECEIVER, + from: ADDRESS1, + to: ADDRESS2, value: 7_000_000_000, }; try { - await populateTransactionMultisigECDSA(tx, PRIVATE_KEY); + await populateTransactionMultisigECDSA(tx, PRIVATE_KEY1); } catch (error) { expect((error as Error).message).to.be.equal( 'Multiple keys are required to build the transaction!' diff --git a/tests/unit/util.test.ts b/tests/unit/util.test.ts index dd201ecf..9905ef31 100644 --- a/tests/unit/util.test.ts +++ b/tests/unit/util.test.ts @@ -1,37 +1,40 @@ import {expect} from 'chai'; import {utils} from '../../src'; import {ethers, BigNumber} from 'ethers'; +import {ADDRESS1, ADDRESS2} from '../utils'; describe('utils', () => { - const ADDRESS = '0x36615Cf349d7F6344891B1e7CA7C72883F5dc049'; - const RECEIVER = '0xa61464658AfeAf65CccaaFD3a512b69A83B77618'; - describe('#getHashedL2ToL1Msg()', () => { it('should return a hashed L2 to L1 message', async () => { const withdrawETHMessage = '0x6c0960f936615cf349d7f6344891b1e7ca7c72883f5dc04900000000000000000000000000000000000000000000000000000001a13b8600'; const withdrawETHMessageHash = '0x521bd25904766c83fe868d6a29cbffa011afd8a1754f6c9a52b053b693e42f18'; - const result = utils.getHashedL2ToL1Msg(ADDRESS, withdrawETHMessage, 0); + const result = utils.getHashedL2ToL1Msg(ADDRESS1, withdrawETHMessage, 0); expect(result).to.be.equal(withdrawETHMessageHash); }); }); describe('#isETH()', () => { + it('should return true for legacy L1 ETH address', async () => { + const result = utils.isETH(utils.LEGACY_ETH_ADDRESS); + expect(result).to.be.true; + }); + it('should return true for L1 ETH address', async () => { - const result = utils.isETH(utils.ETH_ADDRESS); + const result = utils.isETH(utils.ETH_ADDRESS_IN_CONTRACTS); expect(result).to.be.true; }); it('should return true for L2 ETH address', async () => { - const result = utils.isETH(utils.L2_ETH_TOKEN_ADDRESS); + const result = utils.isETH(utils.L2_BASE_TOKEN_ADDRESS); expect(result).to.be.true; }); }); describe('#createAddress()', () => { it('should return the correct address', async () => { - const address = utils.createAddress(ADDRESS, 1); + const address = utils.createAddress(ADDRESS1, 1); expect(address).to.be.equal('0x4B5DF730c2e6b28E17013A1485E5d9BC41Efe021'); }); }); @@ -39,7 +42,7 @@ describe('utils', () => { describe('#create2Address()', () => { it('should return the correct address', async () => { const address = utils.create2Address( - ADDRESS, + ADDRESS1, '0x010001cb6a6e8d5f6829522f19fa9568660e0a9cd53b2e8be4deb0a679452e41', '0x01', '0x01' @@ -132,7 +135,7 @@ describe('utils', () => { try { utils.serialize({ chainId: 270, - from: ADDRESS, + from: ADDRESS1, customData: { customSignature: '', }, @@ -150,7 +153,7 @@ describe('utils', () => { const result = utils.serialize({ type: 113, chainId: 270, - from: ADDRESS, + from: ADDRESS1, }); expect(result).to.be.equal(tx); }); @@ -165,8 +168,8 @@ describe('utils', () => { { type: 113, chainId: 270, - from: ADDRESS, - to: RECEIVER, + from: ADDRESS1, + to: ADDRESS2, value: 1_000_000, }, signature @@ -238,11 +241,11 @@ describe('utils', () => { maxPriorityFeePerGas: BigNumber.from(0), maxFeePerGas: BigNumber.from(0), gasLimit: BigNumber.from(0), - to: RECEIVER, + to: ADDRESS2, value: BigNumber.from(1000000), data: '0x', chainId: BigNumber.from(270), - from: ADDRESS, + from: ADDRESS1, customData: { gasPerPubdata: BigNumber.from(50000), factoryDeps: [], @@ -265,11 +268,11 @@ describe('utils', () => { maxPriorityFeePerGas: BigNumber.from(0), maxFeePerGas: BigNumber.from(0), gasLimit: BigNumber.from(0), - to: RECEIVER, + to: ADDRESS2, value: BigNumber.from(0), data: '0x', chainId: BigNumber.from(270), - from: ADDRESS, + from: ADDRESS1, customData: { gasPerPubdata: BigNumber.from(50000), factoryDeps: [], diff --git a/tests/utils.ts b/tests/utils.ts new file mode 100644 index 00000000..0a72a7d3 --- /dev/null +++ b/tests/utils.ts @@ -0,0 +1,13 @@ +export const ADDRESS1 = '0x36615Cf349d7F6344891B1e7CA7C72883F5dc049'; +export const PRIVATE_KEY1 = + '0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110'; +export const MNEMONIC1 = + 'stuff slice staff easily soup parent arm payment cotton trade scatter struggle'; +export const ADDRESS2 = '0xa61464658AfeAf65CccaaFD3a512b69A83B77618'; +export const PRIVATE_KEY2 = + '0xac1e735be8536c6534bb4f17f06f6afc73b2b5ba84ac2cfb12f7461b20c0bbe3'; +export const DAI_L1 = '0x70a0F165d6f8054d0d0CF8dFd4DD2005f0AF6B55'; +export const APPROVAL_TOKEN = '0x841c43Fa5d8fFfdB9efE3358906f7578d8700Dd4'; // Crown token +export const PAYMASTER = '0xa222f0c183AFA73a8Bc1AFb48D34C88c9Bf7A174'; // Crown token paymaster + +export const IS_ETH_BASED = true;