From 45be381e9e6c6a3ed84881966bd4da2d6181d028 Mon Sep 17 00:00:00 2001 From: petarTxFusion Date: Thu, 6 Jun 2024 01:22:57 +0200 Subject: [PATCH 01/15] feat: provide support for Bridgehub --- scripts/setup.py | 26 +- tests/integration/test_config.py | 2 +- tests/integration/test_wallet.py | 619 +++-- tests/integration/test_zksync_contract.py | 18 - tests/integration/test_zksync_web3.py | 16 +- zksync2/account/utils.py | 10 +- zksync2/account/wallet_l1.py | 1252 ++++++--- zksync2/account/wallet_l2.py | 79 +- zksync2/core/types.py | 10 +- zksync2/core/utils.py | 45 +- .../contract_abi/ContractDeployer.json | 425 --- .../contract_abi/IBridgehub.json | 634 +++++ .../contract_abi/IContractDeployer.json | 412 +++ .../contract_abi/IERC1271.json | 53 +- .../manage_contracts/contract_abi/IERC20.json | 448 +-- .../contract_abi/IEthToken.json | 490 ++-- .../contract_abi/IL1Bridge.json | 775 ++++-- .../contract_abi/IL1ERC20Bridge.json | 392 +++ .../contract_abi/IL1Messenger.json | 291 +- .../contract_abi/IL1SharedBridge.json | 695 +++++ .../contract_abi/IL2Bridge.json | 1 + .../contract_abi/INonceHolder.json | 2 +- .../contract_abi/IPaymasterFlow.json | 76 +- .../contract_abi/ITestnetERC20Token.json | 41 + .../contract_abi/IZkSyncStateTransition.json | 2406 +++++++++++++++++ zksync2/manage_contracts/utils.py | 41 +- zksync2/module/response_types.py | 1 + zksync2/module/zksync_module.py | 169 +- zksync2/transaction/transaction_builders.py | 62 +- 29 files changed, 7331 insertions(+), 2160 deletions(-) delete mode 100644 zksync2/manage_contracts/contract_abi/ContractDeployer.json create mode 100644 zksync2/manage_contracts/contract_abi/IBridgehub.json create mode 100644 zksync2/manage_contracts/contract_abi/IContractDeployer.json create mode 100644 zksync2/manage_contracts/contract_abi/IL1ERC20Bridge.json create mode 100644 zksync2/manage_contracts/contract_abi/IL1SharedBridge.json create mode 100644 zksync2/manage_contracts/contract_abi/ITestnetERC20Token.json create mode 100644 zksync2/manage_contracts/contract_abi/IZkSyncStateTransition.json diff --git a/scripts/setup.py b/scripts/setup.py index 305fc50..6a056ee 100644 --- a/scripts/setup.py +++ b/scripts/setup.py @@ -21,8 +21,8 @@ def main(): from zksync2.module.module_builder import ZkSyncBuilder from zksync2.signer.eth_signer import PrivateKeyEthSigner - zksync = ZkSyncBuilder.build("http://127.0.0.1:3050") - eth_web3 = Web3(Web3.HTTPProvider("http://127.0.0.1:8545")) + zksync = ZkSyncBuilder.build("http://127.0.0.1:15100") + eth_web3 = Web3(Web3.HTTPProvider("http://127.0.0.1:15045")) account: LocalAccount = Account.from_key( "0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110" ) @@ -41,10 +41,30 @@ def main(): def deposit_token(wallet, eth_web3: Web3, zksync: Web3, zksync_contract): from zksync2.core.types import DepositTransaction + from zksync2.manage_contracts.utils import get_test_net_erc20_token + from zksync2.core.types import EthBlockParams - amount = 50 + amount = 100 l1_address = load_token() + token_contract = eth_web3.eth.contract( + Web3.to_checksum_address(l1_address), abi=get_test_net_erc20_token() + ) + mint_tx = token_contract.functions.mint(wallet.address, 10000).build_transaction( + { + "nonce": eth_web3.eth.get_transaction_count( + wallet.address, EthBlockParams.LATEST.value + ), + "from": wallet.address, + "maxPriorityFeePerGas": 1_000_000, + "maxFeePerGas": eth_web3.eth.gas_price, + } + ) + + signed = wallet.sign_transaction(mint_tx) + tx_hash = eth_web3.eth.send_raw_transaction(signed.rawTransaction) + eth_web3.eth.wait_for_transaction_receipt(tx_hash, timeout=240, poll_latency=0.5) + tx_hash = wallet.deposit( DepositTransaction( Web3.to_checksum_address(l1_address), diff --git a/tests/integration/test_config.py b/tests/integration/test_config.py index d328b13..a47fe5e 100644 --- a/tests/integration/test_config.py +++ b/tests/integration/test_config.py @@ -31,5 +31,5 @@ class TestEnvironment: LOCAL_ENV = TestEnvironment( - EnvType.LOCAL_HOST, "http://127.0.0.1:3050", "http://127.0.0.1:8545" + EnvType.LOCAL_HOST, "http://localhost:3050", "http://127.0.0.1:8545" ) diff --git a/tests/integration/test_wallet.py b/tests/integration/test_wallet.py index 215e223..0429816 100644 --- a/tests/integration/test_wallet.py +++ b/tests/integration/test_wallet.py @@ -1,7 +1,6 @@ import json -import os +from asyncio import sleep from pathlib import Path -from time import sleep from unittest import TestCase, skip from eth_account import Account @@ -16,7 +15,6 @@ Token, DepositTransaction, ADDRESS_DEFAULT, - FullDepositFee, RequestExecuteCallMsg, TransactionOptions, TransferTransaction, @@ -25,30 +23,33 @@ PaymasterParams, ZkBlockParams, ) +from zksync2.core.utils import ( + LEGACY_ETH_ADDRESS, + ETH_ADDRESS_IN_CONTRACTS, + L2_BASE_TOKEN_ADDRESS, +) from zksync2.manage_contracts.contract_encoder_base import ( ContractEncoder, JsonConfiguration, ) -from zksync2.manage_contracts.deploy_addresses import ZkSyncAddresses from zksync2.manage_contracts.paymaster_utils import PaymasterFlowEncoder -from zksync2.manage_contracts.precompute_contract_deployer import ( - PrecomputeContractDeployer, +from zksync2.manage_contracts.utils import ( + zksync_abi_default, + get_erc20_abi, + get_test_net_erc20_token, ) -from zksync2.manage_contracts.utils import zksync_abi_default, get_erc20_abi from zksync2.module.module_builder import ZkSyncBuilder -from zksync2.signer.eth_signer import PrivateKeyEthSigner -from zksync2.transaction.transaction_builders import ( - TxCreate2Contract, - TxCreateContract, - TxFunctionCall, -) class TestWallet(TestCase): def setUp(self) -> None: + self.DAI_L1 = Web3.to_checksum_address( + "0x70a0F165d6f8054d0d0CF8dFd4DD2005f0AF6B55" + ) self.token_address = "0x0183Fe07a98bc036d6eb23C3943d823bcD66a90F" self.paymaster_address = "0x594E77D36eB367b3AbAb98775c99eB383079F966" self.address2 = "0xa61464658AfeAf65CccaaFD3a512b69A83B77618" + self.CONTRACT_ADDRESS = "0x36615Cf349d7F6344891B1e7CA7C72883F5dc049" self.env = LOCAL_ENV env_key = EnvPrivateKey("ZKSYNC_KEY1") self.zksync = ZkSyncBuilder.build("http://127.0.0.1:3050") @@ -59,6 +60,7 @@ def setUp(self) -> None: Web3.to_checksum_address(self.zksync.zksync.main_contract_address), abi=zksync_abi_default(), ) + self.is_eth_based_chain = self.wallet.is_eth_based_chain() def load_token(self): directory = Path(__file__).parent @@ -70,9 +72,17 @@ def load_token(self): l2_address = self.zksync.zksync.l2_token_address(l1_address) return l1_address, l2_address - def test_get_main_contract(self): - main_contract = self.wallet.main_contract - self.assertIsNotNone(main_contract, "Should return main contract") + def test_get_bridgehub_contract(self): + result = self.wallet.get_bridgehub_contract() + self.assertIsNotNone(result) + + def test_get_base_token(self): + result = self.wallet.get_base_token() + self.assertIsNotNone(result) + + def test_is_eth_based_chain(self): + result = self.wallet.is_eth_based_chain() + self.assertIsNotNone(result) def test_l1_bridge_contracts(self): contracts = self.wallet.get_l1_bridge_contracts() @@ -88,8 +98,15 @@ def test_get_allowance_l1(self): self.assertGreaterEqual(result, 0) def test_get_l2_token_address(self): - address = self.wallet.l2_token_address(ADDRESS_DEFAULT) - self.assertEqual(address, ADDRESS_DEFAULT, "Should return l2 token address") + base_token = self.wallet.get_base_token() + address = self.wallet.l2_token_address(base_token) + self.assertEqual( + L2_BASE_TOKEN_ADDRESS, address, "Should return l2 token address" + ) + + def test_get_l2_token_address_dai(self): + address = self.wallet.l2_token_address(self.DAI_L1) + self.assertIsNotNone(address) def test_approve_erc20(self): usdc_token = Token( @@ -132,148 +149,387 @@ def test_get_deployment_nonce(self): self.assertIsNotNone(nonce, "Should return deployment nonce") def test_prepare_deposit_transaction(self): - options = TransactionOptions( - gas_price=1_000_000_007, - max_fee_per_gas=1_000_000_010, - value=288_992_007_000_000, - max_priority_fee_per_gas=1_000_000_000, - ) - tx = DepositTransaction( - token=ADDRESS_DEFAULT, - amount=0.000000007, - to=self.wallet.address, + tx = RequestExecuteCallMsg( + contract_address=self.CONTRACT_ADDRESS, + call_data="0x", operator_tip=0, - l2_gas_limit=int("0x8d1c0", 16), + l2_value=7_000_000, gas_per_pubdata_byte=800, refund_recipient=self.wallet.address, - l2_value=7_000_000, - options=options, ) - transaction = self.wallet.prepare_deposit_tx(tx) + transaction = self.wallet.prepare_deposit_tx( + DepositTransaction( + token=LEGACY_ETH_ADDRESS, + amount=7_000_000, + refund_recipient=self.wallet.address, + ) + ) + self.assertGreater(transaction.l2_gas_limit, 0) + self.assertGreater(transaction.mint_value, 0) + self.assertGreater(transaction.options.max_fee_per_gas, 0) + self.assertGreater(transaction.options.max_priority_fee_per_gas, 0) + self.assertGreater(transaction.options.value, 0) + + del transaction.l2_gas_limit + del transaction.mint_value + del transaction.options + + del tx.l2_gas_limit + del tx.mint_value + del tx.options self.assertEqual(tx, transaction) def test_prepare_deposit_transaction_token(self): l1_address, l2_address = self.load_token() - tx = DepositTransaction( - token=HexStr(l1_address), - amount=5, - refund_recipient=self.wallet.address, - to=self.wallet.get_l2_bridge_contracts().erc20.address, - custom_bridge_data=HexBytes( - "0xe8b99b1b00000000000000000000000036615cf349d7f6344891b1e7ca7c72883f5dc049000000000000000000000000881567b68502e6d7a7a3556ff4313b637ba47f4e0000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000008e0f6000000000000000000000000000000000000000000000000000000000000032000000000000000000000000036615cf349d7f6344891b1e7ca7c72883f5dc049" - ), - ) - transaction = self.wallet.prepare_deposit_tx(tx) - self.assertEqual(tx, transaction) + print(self.wallet.get_l1_balance(l1_address)) - def test_estimate_gas_deposit(self): - estimated_gas = self.wallet.estimate_gas_deposit( + transaction = self.wallet.prepare_deposit_tx( DepositTransaction( - token=ADDRESS_DEFAULT, - to=self.wallet.address, - amount=5, - refund_recipient=self.wallet.address, + token=l1_address, amount=5, refund_recipient=self.wallet.address, approve_erc20=True ) ) - self.assertGreaterEqual(estimated_gas, 110_581) + + self.assertGreater(transaction["maxFeePerGas"], 0) + self.assertGreater(transaction["maxPriorityFeePerGas"], 0) + self.assertGreater(transaction["value"], 0) + + def test_estimate_eth_gas_deposit(self): + if self.is_eth_based_chain: + estimated_gas = self.wallet.estimate_gas_deposit( + DepositTransaction( + token=ADDRESS_DEFAULT, + to=self.wallet.address, + amount=5, + refund_recipient=self.wallet.address, + ) + ) + self.assertGreater(estimated_gas, 0) + else: + amount = 5 + approve_params = self.wallet.get_deposit_allowance_params( + LEGACY_ETH_ADDRESS, amount + ) + self.wallet.approve_erc20( + approve_params[0]["token"], approve_params[0]["allowance"] + ) + estimated_gas = self.wallet.estimate_gas_deposit( + DepositTransaction( + token=ADDRESS_DEFAULT, + to=self.wallet.address, + amount=amount, + refund_recipient=self.wallet.address, + ) + ) + self.assertGreater(estimated_gas, 0) + + def test_estimate_token_gas_deposit(self): + l1_address, l2_address = self.load_token() + if self.is_eth_based_chain: + is_approved = self.wallet.approve_erc20( + Web3.to_checksum_address(l1_address), 5 + ) + estimated_gas = self.wallet.estimate_gas_deposit( + DepositTransaction( + token=l1_address, + to=self.wallet.address, + amount=5, + refund_recipient=self.wallet.address, + approve_erc20=True, + ) + ) + self.assertGreater(estimated_gas, 0) + else: + amount = 5 + approve_params = self.wallet.get_deposit_allowance_params( + l1_address, amount + ) + + self.wallet.approve_erc20( + approve_params[0]["token"], approve_params[0]["allowance"] + ) + self.wallet.approve_erc20( + approve_params[1]["token"], approve_params[1]["allowance"] + ) + + estimated_gas = self.wallet.estimate_gas_deposit( + DepositTransaction( + token=l1_address, + to=self.wallet.address, + amount=amount, + refund_recipient=self.wallet.address, + ) + ) + self.assertGreater(estimated_gas, 0) + + def test_estimate_base_token_gas_deposit(self): + if not self.is_eth_based_chain: + token = self.wallet.get_base_token() + amount = 5 + approve_params = self.wallet.get_deposit_allowance_params(token, amount) + + self.wallet.approve_erc20( + approve_params[0]["token"], approve_params[0]["allowance"] + ) + + estimated_gas = self.wallet.estimate_gas_deposit( + DepositTransaction( + token=token, + to=self.wallet.address, + amount=amount, + refund_recipient=self.wallet.address, + ) + ) + self.assertGreater(estimated_gas, 0) def test_deposit_eth(self): - amount = 7_000_000_000 - l2_balance_before = self.wallet.get_balance() + if self.is_eth_based_chain: + amount = 7_000_000_000 + l2_balance_before = self.wallet.get_balance() - tx_hash = self.wallet.deposit( - DepositTransaction(token=Token.create_eth().l1_address, amount=amount) - ) + tx_hash = self.wallet.deposit( + DepositTransaction(token=Token.create_eth().l1_address, amount=amount) + ) - tx_receipt = self.eth_web3.eth.wait_for_transaction_receipt(tx_hash) - l2_hash = self.zksync.zksync.get_l2_hash_from_priority_op( - tx_receipt, self.zksync_contract - ) - self.zksync.zksync.wait_for_transaction_receipt( - transaction_hash=l2_hash, timeout=360, poll_latency=10 - ) - l2_balance_after = self.wallet.get_balance() - self.assertEqual(1, tx_receipt["status"], "L1 transaction should be successful") - self.assertGreaterEqual( - l2_balance_after - l2_balance_before, - amount, - "Balance on L2 should be increased", - ) + tx_receipt = self.eth_web3.eth.wait_for_transaction_receipt(tx_hash) + l2_hash = self.zksync.zksync.get_l2_hash_from_priority_op( + tx_receipt, self.zksync_contract + ) + self.zksync.zksync.wait_for_transaction_receipt( + transaction_hash=l2_hash, timeout=360, poll_latency=10 + ) + l2_balance_after = self.wallet.get_balance() + self.assertEqual( + 1, tx_receipt["status"], "L1 transaction should be successful" + ) + self.assertGreaterEqual( + l2_balance_after - l2_balance_before, + amount, + "Balance on L2 should be increased", + ) + else: + amount = 7_000_000_000 + l2_balance_before = self.wallet.get_balance() + l1_balance_before = self.wallet.get_l1_balance() + + tx_hash = self.wallet.deposit( + DepositTransaction( + token=Token.create_eth().l1_address, + amount=amount, + approve_base_erc20=True, + ) + ) - # @skip("Integration test, used for develop purposes only") - def test_deposit_token(self): - amount = 100 - l1_address, l2_address = self.load_token() - is_approved = self.wallet.approve_erc20( - Web3.to_checksum_address(l1_address), amount - ) - self.assertTrue(is_approved) + tx_receipt = self.eth_web3.eth.wait_for_transaction_receipt(tx_hash) + l2_hash = self.zksync.zksync.get_l2_hash_from_priority_op( + tx_receipt, self.zksync_contract + ) + self.zksync.zksync.wait_for_transaction_receipt( + transaction_hash=l2_hash, timeout=360, poll_latency=10 + ) - balance_l2_beore = self.wallet.get_balance( - token_address=Web3.to_checksum_address(l2_address) - ) + l2_balance_after = self.wallet.get_balance() + l1_balance_after = self.wallet.get_l1_balance() - tx_hash = self.wallet.deposit( - DepositTransaction( - Web3.to_checksum_address(l1_address), + self.assertEqual( + 1, tx_receipt["status"], "L1 transaction should be successful" + ) + self.assertGreaterEqual( + l2_balance_after - l2_balance_before, amount, - self.account.address, - approve_erc20=True, - refund_recipient=self.wallet.address, + "Balance on L2 should be increased", + ) + self.assertGreaterEqual(l1_balance_before - l1_balance_after, amount) + + def test_deposit_base_token(self): + if not self.is_eth_based_chain: + amount = 5 + base_token_l1 = self.wallet.get_base_token() + l2_balance_before = self.wallet.get_balance() + l1_balance_before = self.wallet.get_l1_balance(base_token_l1) + + tx_hash = self.wallet.deposit( + DepositTransaction( + token=base_token_l1, amount=amount, approve_erc20=True + ) ) - ) - l1_tx_receipt = self.eth_web3.eth.wait_for_transaction_receipt(tx_hash) + tx_receipt = self.eth_web3.eth.wait_for_transaction_receipt(tx_hash) + l2_hash = self.zksync.zksync.get_l2_hash_from_priority_op( + tx_receipt, self.zksync_contract + ) + self.zksync.zksync.wait_for_transaction_receipt( + transaction_hash=l2_hash, timeout=360, poll_latency=10 + ) - l2_hash = self.zksync.zksync.get_l2_hash_from_priority_op( - l1_tx_receipt, self.zksync_contract - ) - self.zksync.zksync.wait_for_transaction_receipt( - transaction_hash=l2_hash, timeout=360, poll_latency=10 - ) + l2_balance_after = self.wallet.get_balance() + l1_balance_after = self.wallet.get_l1_balance(base_token_l1) - balance_l2_after = self.wallet.get_balance( - token_address=Web3.to_checksum_address(l2_address) - ) - self.assertGreater(balance_l2_after, balance_l2_beore) + self.assertEqual( + 1, tx_receipt["status"], "L1 transaction should be successful" + ) + self.assertGreaterEqual( + l2_balance_after - l2_balance_before, + amount, + "Balance on L2 should be increased", + ) + self.assertGreaterEqual(l1_balance_before - l1_balance_after, amount) + + def test_deposit_erc_20_token(self): + if self.is_eth_based_chain: + amount = 100 + l1_address, l2_address = self.load_token() + # is_approved = self.wallet.approve_erc20( + # Web3.to_checksum_address(l1_address), amount + # ) + # self.assertTrue(is_approved) + + balance_l2_beore = self.wallet.get_balance( + token_address=Web3.to_checksum_address(l2_address) + ) - def test_full_required_deposit_fee(self): - fee = self.wallet.get_full_required_deposit_fee( - DepositTransaction(token=ADDRESS_DEFAULT, to=self.wallet.address) - ) - self.assertTrue(fee.base_cost > 0) - self.assertTrue(fee.l1_gas_limit > 0) - self.assertTrue(fee.l2_gas_limit > 0) - self.assertTrue(fee.max_fee_per_gas > 0) - self.assertTrue(fee.max_priority_fee_per_gas > 0) + tx_hash = self.wallet.deposit( + DepositTransaction( + Web3.to_checksum_address(l1_address), + amount, + self.account.address, + approve_erc20=True, + approve_base_erc20=True, + refund_recipient=self.wallet.address, + ) + ) - def test_transfer_eth(self): - amount = 7_000_000_000 - balance_before_transfer = self.zksync.zksync.get_balance( - Web3.to_checksum_address(self.address2) - ) - tx_hash = self.wallet.transfer( - TransferTransaction( - to=Web3.to_checksum_address(self.address2), - token_address=ADDRESS_DEFAULT, - amount=amount, + l1_tx_receipt = self.eth_web3.eth.wait_for_transaction_receipt(tx_hash) + + l2_hash = self.zksync.zksync.get_l2_hash_from_priority_op( + l1_tx_receipt, self.zksync_contract + ) + self.zksync.zksync.wait_for_transaction_receipt( + transaction_hash=l2_hash, timeout=360, poll_latency=10 ) - ) - self.zksync.zksync.wait_for_transaction_receipt( - tx_hash, timeout=240, poll_latency=0.5 - ) - balance_after_transfer = self.zksync.zksync.get_balance( - Web3.to_checksum_address(self.address2) - ) + balance_l2_after = self.wallet.get_balance( + token_address=Web3.to_checksum_address(l2_address) + ) + self.assertGreater(balance_l2_after, balance_l2_beore) + else: + amount = 100 + l1_address, l2_address = self.load_token() + is_approved = self.wallet.approve_erc20( + Web3.to_checksum_address(l1_address), amount + ) + self.assertTrue(is_approved) - self.assertEqual(balance_after_transfer - balance_before_transfer, amount) + balance_l2_beore = self.wallet.get_balance( + token_address=Web3.to_checksum_address(l2_address) + ) + + tx_hash = self.wallet.deposit( + DepositTransaction( + Web3.to_checksum_address(l1_address), + amount, + self.account.address, + approve_erc20=True, + approve_base_erc20=True, + refund_recipient=self.wallet.address, + ) + ) + + l1_tx_receipt = self.eth_web3.eth.wait_for_transaction_receipt(tx_hash) + + l2_hash = self.zksync.zksync.get_l2_hash_from_priority_op( + l1_tx_receipt, self.zksync_contract + ) + self.zksync.zksync.wait_for_transaction_receipt( + transaction_hash=l2_hash, timeout=360, poll_latency=10 + ) + + balance_l2_after = self.wallet.get_balance( + token_address=Web3.to_checksum_address(l2_address) + ) + self.assertGreater(balance_l2_after, balance_l2_beore) - def test_transfer_eth_with_non_zero_gas_limit(self): - gas_limit = 500_000 - options = TransactionOptions(gas_limit=gas_limit) + def test_full_required_deposit_fee_eth(self): + if self.is_eth_based_chain: + fee = self.wallet.get_full_required_deposit_fee( + DepositTransaction(token=LEGACY_ETH_ADDRESS, to=self.wallet.address) + ) + + self.assertTrue(fee.base_cost > 0) + self.assertTrue(fee.l1_gas_limit > 0) + self.assertTrue(fee.l2_gas_limit > 0) + self.assertTrue(fee.max_fee_per_gas > 0) + self.assertTrue(fee.max_priority_fee_per_gas > 0) + else: + approve_params = self.wallet.get_deposit_allowance_params( + LEGACY_ETH_ADDRESS, 1 + ) + self.wallet.approve_erc20( + approve_params[0]["token"], approve_params[0]["allowance"] + ) + + fee = self.wallet.get_full_required_deposit_fee( + DepositTransaction(token=LEGACY_ETH_ADDRESS, to=self.wallet.address) + ) + self.assertTrue(fee.base_cost > 0) + self.assertTrue(fee.l1_gas_limit > 0) + self.assertTrue(fee.l2_gas_limit > 0) + self.assertTrue(fee.max_fee_per_gas > 0) + self.assertTrue(fee.max_priority_fee_per_gas > 0) + + def test_full_required_deposit_fee_erc_20_token(self): + if self.is_eth_based_chain: + amount = 5 + l1_address, l2_address = self.load_token() + self.wallet.approve_erc20(l1_address, amount) + + fee = self.wallet.get_full_required_deposit_fee( + DepositTransaction(token=l1_address, to=self.wallet.address) + ) + + self.assertTrue(fee.base_cost > 0) + self.assertTrue(fee.l1_gas_limit > 0) + self.assertTrue(fee.l2_gas_limit > 0) + self.assertTrue(fee.max_fee_per_gas > 0) + self.assertTrue(fee.max_priority_fee_per_gas > 0) + else: + l1_address, l2_address = self.load_token() + approve_params = self.wallet.get_deposit_allowance_params(l1_address, 1) + self.wallet.approve_erc20( + approve_params[0]["token"], approve_params[0]["allowance"] + ) + self.wallet.approve_erc20( + approve_params[1]["token"], approve_params[1]["allowance"] + ) + + fee = self.wallet.get_full_required_deposit_fee( + DepositTransaction(token=l1_address, to=self.wallet.address) + ) + self.assertTrue(fee.base_cost > 0) + self.assertTrue(fee.l1_gas_limit > 0) + self.assertTrue(fee.l2_gas_limit > 0) + self.assertTrue(fee.max_fee_per_gas > 0) + self.assertTrue(fee.max_priority_fee_per_gas > 0) + + def test_full_required_deposit_fee_base_token(self): + if not self.is_eth_based_chain: + token = self.wallet.get_base_token() + approve_params = self.wallet.get_deposit_allowance_params(token, 1) + self.wallet.approve_erc20( + approve_params[0]["token"], approve_params[0]["allowance"] + ) + + fee = self.wallet.get_full_required_deposit_fee( + DepositTransaction(token=token, to=self.wallet.address) + ) + self.assertTrue(fee.base_cost > 0) + self.assertTrue(fee.l1_gas_limit > 0) + self.assertTrue(fee.l2_gas_limit > 0) + self.assertTrue(fee.max_fee_per_gas > 0) + self.assertTrue(fee.max_priority_fee_per_gas > 0) + + def test_transfer_eth(self): amount = 7_000_000_000 balance_before_transfer = self.zksync.zksync.get_balance( Web3.to_checksum_address(self.address2) @@ -283,16 +539,12 @@ def test_transfer_eth_with_non_zero_gas_limit(self): to=Web3.to_checksum_address(self.address2), token_address=ADDRESS_DEFAULT, amount=amount, - options=options, ) ) - receipt = self.zksync.zksync.wait_for_transaction_receipt( + self.zksync.zksync.wait_for_transaction_receipt( tx_hash, timeout=240, poll_latency=0.5 ) - self.assertNotEqual(receipt["gasUsed"], gas_limit) - tx = self.zksync.eth.get_transaction(tx_hash) - self.assertEqual(tx["gas"], gas_limit) balance_after_transfer = self.zksync.zksync.get_balance( Web3.to_checksum_address(self.address2) ) @@ -300,7 +552,7 @@ def test_transfer_eth_with_non_zero_gas_limit(self): self.assertEqual(balance_after_transfer - balance_before_transfer, amount) def test_transfer_eth_paymaster(self): - amount = 1 + amount = 7_000_000_000 paymaster_address = self.zksync.to_checksum_address(self.paymaster_address) token_address = self.zksync.to_checksum_address(self.token_address) @@ -374,7 +626,7 @@ def test_mint_paymaster(self): ) balance_before = self.wallet.get_balance( - Web3.to_checksum_address(self.token_address) + token_address=Web3.to_checksum_address(self.token_address) ) mint_tx = token_contract.functions.mint( self.wallet.address, 15 @@ -395,7 +647,7 @@ def test_mint_paymaster(self): tx_hash, timeout=240, poll_latency=0.5 ) balance_after = self.wallet.get_balance( - Web3.to_checksum_address(self.token_address) + token_address=Web3.to_checksum_address(self.token_address) ) self.assertEqual(15, balance_after - balance_before) @@ -433,45 +685,6 @@ def test_transfer_token(self): self.assertEqual(amount, sender_before - sender_after) self.assertEqual(amount, balance_after - balance_before) - def test_transfer_token_with_non_zero_gas_limit(self): - gas_limit = 500_000 - options = TransactionOptions(gas_limit=gas_limit) - amount = 5 - _, l2_address = self.load_token() - - sender_before = self.wallet.get_balance(token_address=l2_address) - balance_before = self.zksync.zksync.zks_get_balance( - self.address2, - token_address=l2_address, - block_tag=ZkBlockParams.LATEST.value, - ) - tx_hash = self.wallet.transfer( - TransferTransaction( - to=Web3.to_checksum_address(self.address2), - token_address=Web3.to_checksum_address(l2_address), - amount=amount, - options=options, - ) - ) - - result = self.zksync.zksync.wait_for_transaction_receipt( - tx_hash, timeout=240, poll_latency=0.5 - ) - self.assertIsNotNone(result) - self.assertNotEqual(result["gasUsed"], gas_limit) - tx = self.zksync.eth.get_transaction(tx_hash) - self.assertEqual(tx["gas"], gas_limit) - sender_after = self.wallet.get_balance(token_address=l2_address) - - balance_after = self.zksync.zksync.zks_get_balance( - self.address2, - token_address=l2_address, - block_tag=ZkBlockParams.LATEST.value, - ) - - self.assertEqual(amount, sender_before - sender_after) - self.assertEqual(amount, balance_after - balance_before) - def test_transfer_token_paymaster(self): amount = 5 l1_address, l2_address = self.load_token() @@ -550,21 +763,34 @@ def test_transfer_token_paymaster(self): self.assertEqual(reciever_balance_after - reciever_balance_before, 5) def test_withdraw_eth(self): + token = ( + ETH_ADDRESS_IN_CONTRACTS + if self.is_eth_based_chain + else self.wallet.l2_token_address(ETH_ADDRESS_IN_CONTRACTS) + ) l2_balance_before = self.wallet.get_balance() - amount = 1 + amount = 7_000_000_000 withdraw_tx_hash = self.wallet.withdraw( - WithdrawTransaction( - token=Token.create_eth().l1_address, amount=Web3.to_wei(amount, "ether") - ) + WithdrawTransaction(token=token, amount=amount) ) - self.zksync.zksync.wait_for_transaction_receipt( + withdraw_receipt = self.zksync.zksync.wait_finalized( withdraw_tx_hash, timeout=240, poll_latency=0.5 ) + # self.assertFalse( + # self.wallet.is_withdrawal_finalized(withdraw_receipt["transactionHash"]) + # ) + finalized_hash = self.wallet.finalize_withdrawal( + withdraw_receipt["transactionHash"] + ) + result = self.eth_web3.eth.wait_for_transaction_receipt( + finalized_hash, timeout=240, poll_latency=0.5 + ) l2_balance_after = self.wallet.get_balance() + self.assertIsNotNone(result) self.assertGreater( l2_balance_before, l2_balance_after, @@ -572,14 +798,14 @@ def test_withdraw_eth(self): ) def test_withdraw_eth_paymaster(self): - amount = 1 + amount = 7_000_000_000 paymaster_address = self.zksync.to_checksum_address(self.paymaster_address) token_address = self.zksync.to_checksum_address(self.token_address) paymaster_balance_before = self.zksync.zksync.zks_get_balance(paymaster_address) paymaster_token_balance_before = self.zksync.zksync.zks_get_balance( - paymaster_address, token_address=token_address + paymaster_address, token_address=token_address, block_tag=ZkBlockParams.LATEST ) sender_balance_before = self.wallet.get_balance() @@ -597,11 +823,10 @@ def test_withdraw_eth_paymaster(self): ), } ) - withdraw_tx_hash = self.wallet.withdraw( WithdrawTransaction( token=Token.create_eth().l1_address, - amount=Web3.to_wei(amount, "ether"), + amount=amount, paymaster_params=paymaster_params, ) ) @@ -609,9 +834,9 @@ def test_withdraw_eth_paymaster(self): withdraw_receipt = self.zksync.zksync.wait_finalized( withdraw_tx_hash, timeout=240, poll_latency=0.5 ) - self.assertFalse( - self.wallet.is_withdrawal_finalized(withdraw_receipt["transactionHash"]) - ) + # self.assertFalse( + # self.wallet.is_withdrawal_finalized(withdraw_receipt["transactionHash"]) + # ) finalized_hash = self.wallet.finalize_withdrawal( withdraw_receipt["transactionHash"] @@ -621,7 +846,7 @@ def test_withdraw_eth_paymaster(self): ) paymaster_balance_after = self.zksync.zksync.zks_get_balance(paymaster_address) paymaster_token_balance_after = self.zksync.zksync.zks_get_balance( - paymaster_address, token_address=token_address + paymaster_address, token_address=token_address, block_tag=ZkBlockParams.LATEST ) sender_balance_after = self.wallet.get_balance() sender_approval_token_balance_after = self.wallet.get_balance( @@ -633,7 +858,7 @@ def test_withdraw_eth_paymaster(self): paymaster_token_balance_after - paymaster_token_balance_before, 1 ) self.assertEqual( - sender_balance_before - sender_balance_after, Web3.to_wei(amount, "ether") + sender_balance_before - sender_balance_after, amount ) self.assertEqual( sender_approval_token_balance_after, @@ -715,15 +940,25 @@ def test_withdraw_token(self): withdraw_tx_hash = self.wallet.withdraw( WithdrawTransaction(Web3.to_checksum_address(l2_address), 5) ) - - self.zksync.zksync.wait_for_transaction_receipt( + withdraw_receipt = self.zksync.zksync.wait_finalized( withdraw_tx_hash, timeout=240, poll_latency=0.5 ) + # self.assertFalse( + # self.wallet.is_withdrawal_finalized(withdraw_receipt["transactionHash"]) + # ) + + finalized_hash = self.wallet.finalize_withdrawal( + withdraw_receipt["transactionHash"] + ) + result = self.eth_web3.eth.wait_for_transaction_receipt( + finalized_hash, timeout=240, poll_latency=0.5 + ) l2_balance_after = self.wallet.get_balance( token_address=Web3.to_checksum_address(l2_address) ) + self.assertIsNotNone(result) self.assertGreater( l2_balance_before, l2_balance_after, @@ -759,7 +994,7 @@ def test_request_execute(self): tx_hash = self.wallet.request_execute( RequestExecuteCallMsg( contract_address=Web3.to_checksum_address( - self.zksync.zksync.main_contract_address + self.zksync.zksync.zks_get_bridgehub_contract_address() ), call_data=HexStr("0x"), l2_value=amount, diff --git a/tests/integration/test_zksync_contract.py b/tests/integration/test_zksync_contract.py index 843ab14..7884e16 100644 --- a/tests/integration/test_zksync_contract.py +++ b/tests/integration/test_zksync_contract.py @@ -48,15 +48,6 @@ def test_get_first_unprocessed_priority_tx(self): } ) - def test_get_governor(self): - governor = self.zksync_contract.functions.getGovernor().call( - { - "chainId": self.eth_web3.eth.chain_id, - "from": self.account.address, - "nonce": self.eth_web3.eth.get_transaction_count(self.account.address), - } - ) - def test_get_l2_bootloader_bytecode_hash(self): bytecode_hash = ( self.zksync_contract.functions.getL2BootloaderBytecodeHash().call( @@ -83,15 +74,6 @@ def test_get_l2_default_account_bytecode_hash(self): ) ) - def test_get_proposed_upgrade_hash(self): - upgrade_hash = self.zksync_contract.functions.getPendingGovernor().call( - { - "chainId": self.eth_web3.eth.chain_id, - "from": self.account.address, - "nonce": self.eth_web3.eth.get_transaction_count(self.account.address), - } - ) - def test_get_proposed_upgrade_timestamp(self): upgrade_timestamp = self.zksync_contract.functions.getPriorityQueueSize().call( { diff --git a/tests/integration/test_zksync_web3.py b/tests/integration/test_zksync_web3.py index 1729414..ffbd011 100644 --- a/tests/integration/test_zksync_web3.py +++ b/tests/integration/test_zksync_web3.py @@ -19,7 +19,7 @@ ADDRESS_DEFAULT, StorageProof, ) -from zksync2.core.utils import pad_front_bytes, to_bytes, pad_back_bytes +from zksync2.core.utils import pad_front_bytes, to_bytes, pad_back_bytes, L2_BASE_TOKEN_ADDRESS from zksync2.manage_contracts.contract_encoder_base import ( ContractEncoder, JsonConfiguration, @@ -768,13 +768,15 @@ def test_contract_factory(self): def test_get_all_account_balances(self): balances = self.web3.zksync.zks_get_all_account_balances(self.account.address) + # @skip("Integration test, used for develop purposes only") def test_get_l1_chain_id(self): self.assertIsInstance(self.web3.zksync.zks_l1_chain_id(), int) # @skip("Integration test, used for develop purposes only") def test_get_bridge_addresses(self): - addresses = self.web3.zksync.zks_get_bridge_contracts() + result = self.web3.zksync.zks_get_bridge_contracts() + self.assertIsNotNone(result) def test_get_account_info(self): TESTNET_PAYMASTER = "0x0f9acdb01827403765458b4685de6d9007580d15" @@ -788,4 +790,12 @@ def test_get_l1_token_address(self): def test_get_l2_token_address(self): result = self.web3.zksync.l2_token_address(ADDRESS_DEFAULT) - self.assertEqual(result, ADDRESS_DEFAULT) + self.assertEqual(result, L2_BASE_TOKEN_ADDRESS) + + def test_get_bridgehub_contract(self): + result = self.web3.zksync.zks_get_bridgehub_contract_address() + self.assertIsNotNone(result) + + def test_zks_get_base_token_contract_address(self): + result = self.web3.zksync.zks_get_base_token_contract_address() + self.assertIsNotNone(result) diff --git a/zksync2/account/utils.py b/zksync2/account/utils.py index 7994ec4..50bd7da 100644 --- a/zksync2/account/utils.py +++ b/zksync2/account/utils.py @@ -1,4 +1,6 @@ +import web3 from eth_typing import HexStr +from web3 import Web3 from web3.types import Nonce from zksync2.core.types import ( @@ -35,7 +37,9 @@ def options_from_712(tx: Transaction712) -> TransactionOptions: ) -def prepare_transaction_options(options: TransactionOptions, from_: HexStr = None): +def prepare_transaction_options( + options: TransactionOptions, from_: HexStr = None, provider: Web3 = None +): opt = {} if options.value is not None: opt["value"] = options.value @@ -55,6 +59,10 @@ def prepare_transaction_options(options: TransactionOptions, from_: HexStr = Non opt["gas"] = options.gas_limit if options.nonce is not None: opt["nonce"] = options.nonce + elif provider is not None: + opt["nonce"] = provider.eth.get_transaction_count( + Web3.to_checksum_address(from_) + ) if options.chain_id is not None: opt["chainId"] = options.chain_id if from_ is not None: diff --git a/zksync2/account/wallet_l1.py b/zksync2/account/wallet_l1.py index a709fb1..a62bb13 100644 --- a/zksync2/account/wallet_l1.py +++ b/zksync2/account/wallet_l1.py @@ -1,5 +1,6 @@ from typing import Union, Type +from eth_abi import encode from eth_account.signers.base import BaseAccount from eth_typing import HexStr, Address from eth_utils import event_signature_to_log_topic, add_0x_prefix @@ -33,6 +34,10 @@ BOOTLOADER_FORMAL_ADDRESS, undo_l1_to_l2_alias, DEPOSIT_GAS_PER_PUBDATA_LIMIT, + ETH_ADDRESS_IN_CONTRACTS, + LEGACY_ETH_ADDRESS, + scale_gas_limit, + is_address_eq, ) from zksync2.manage_contracts.deploy_addresses import ZkSyncAddresses from zksync2.manage_contracts.utils import ( @@ -40,6 +45,8 @@ l1_bridge_abi_default, get_erc20_abi, l2_bridge_abi_default, + l1_shared_bridge_abi_default, + bridgehub_abi_default, ) from zksync2.module.request_types import EIP712Meta from zksync2.transaction.transaction_builders import TxFunctionCall @@ -126,6 +133,14 @@ def _finalize_withdrawal_params(self, withdraw_hash, index: int) -> dict: "proof": proof.proof, } + def get_bridgehub_contract(self) -> Union[Type[Contract], Contract]: + """Returns Contract wrapper of the bridgehub smart contract.""" + address = self._zksync_web3.zksync.zks_get_bridgehub_contract_address() + + return self._eth_web3.eth.contract( + address=Web3.to_checksum_address(address), abi=bridgehub_abi_default() + ) + def get_l1_bridge_contracts(self) -> L1BridgeContracts: """Returns L1 bridge contract wrappers.""" return L1BridgeContracts( @@ -135,12 +150,30 @@ def get_l1_bridge_contracts(self) -> L1BridgeContracts: ), abi=l1_bridge_abi_default(), ), + shared=self._eth_web3.eth.contract( + address=Web3.to_checksum_address( + self.bridge_addresses.shared_l1_default_bridge + ), + abi=l1_shared_bridge_abi_default(), + ), weth=self._eth_web3.eth.contract( address=Web3.to_checksum_address(self.bridge_addresses.weth_bridge_l1), abi=l1_bridge_abi_default(), ), ) + def get_base_token(self) -> HexStr: + """Returns the address of the base token on L1.""" + + bridgehub = self.get_bridgehub_contract() + chain_id = self._zksync_web3.eth.chain_id + + return bridgehub.functions.baseToken(chain_id).call() + + def is_eth_based_chain(self) -> bool: + """Returns whether the chain is ETH-based.""" + return self._zksync_web3.zksync.is_eth_based_chain() + def get_l1_balance( self, token: HexStr = ADDRESS_DEFAULT, @@ -149,7 +182,8 @@ def get_l1_balance( """ Returns the amount of the token the Wallet has on Ethereum. :param token: Token address. ETH by default. - :param block: The block the balance should be checked on. committed, i.e. the latest processed one is the default option. + :param block: The block the balance should be checked on. committed, + i.e. the latest processed one is the default option. """ if is_eth(token): return self._eth_web3.eth.get_balance(self.address, block.value) @@ -166,25 +200,15 @@ def get_allowance_l1(self, token: HexStr, bridge_address: Address = None): Returns the amount of approved tokens for a specific L1 bridge. :param token: The address of the token on L1. - :param bridge_address: The address of the bridge contract to be used. Defaults to the default zkSync bridge (either L1EthBridge or L1Erc20Bridge). + :param bridge_address: The address of the bridge contract to be used. + Defaults to the default zkSync bridge (either L1EthBridge or L1Erc20Bridge). """ token_contract = self._eth_web3.eth.contract( address=Web3.to_checksum_address(token), abi=get_erc20_abi() ) if bridge_address is None: - l2_weth_token = ADDRESS_DEFAULT - try: - l2_weth_token = ( - self.get_l1_bridge_contracts() - .weth.functions.l2TokenAddress(token) - .call() - ) - except: - pass - if l2_weth_token == ADDRESS_DEFAULT: - bridge_address = self.bridge_addresses.erc20_l1_default_bridge - else: - bridge_address = self.bridge_addresses.weth_bridge_l1 + bridge_contracts = self.get_l1_bridge_contracts() + bridge_address = bridge_contracts.shared.address return token_contract.functions.allowance(self.address, bridge_address).call( { "chainId": self._eth_web3.eth.chain_id, @@ -194,21 +218,12 @@ def get_allowance_l1(self, token: HexStr, bridge_address: Address = None): def l2_token_address(self, address: HexStr) -> HexStr: """ - Returns the L2 token address equivalent for a L1 token address as they are not equal. ETH's address is set to zero address. + Returns the L2 token address equivalent for a L1 token address as they are not necessarily equal. + The ETH address is set to the zero address. :param address: The address of the token on L1. """ - if is_eth(address): - return ADDRESS_DEFAULT - - contracts = self.get_l1_bridge_contracts() - try: - l2_weth_token = contracts.weth.functions.l2TokenAddress(address).call() - if l2_weth_token != ADDRESS_DEFAULT: - return l2_weth_token - except: - pass - return contracts.erc20.functions.l2TokenAddress(address).call() + return self._zksync_web3.zksync.l2_token_address(address) def approve_erc20( self, @@ -222,7 +237,8 @@ def approve_erc20( :param token: The Ethereum address of the token. :param amount: The amount of the token to be approved. - :param bridge_address: The address of the bridge contract to be used. Defaults to the default zkSync bridge (either L1EthBridge or L1Erc20Bridge). + :param bridge_address: The address of the bridge contract to be used. + Defaults to the default zkSync bridge (either L1EthBridge or L1Erc20Bridge). :param gas_limit: """ if is_eth(token): @@ -233,21 +249,17 @@ def approve_erc20( erc20 = self._eth_web3.eth.contract( address=Web3.to_checksum_address(token), abi=get_erc20_abi() ) + base_token = self.get_base_token() + is_eth_based_chain = self.is_eth_based_chain() if bridge_address is None: - l2_weth_token = ADDRESS_DEFAULT - try: - l2_weth_token = ( - self.get_l1_bridge_contracts() - .weth.functions.l2TokenAddress(token) - .call() + if is_eth_based_chain is False and token.lower() == base_token.lower(): + bridge_address = ( + self.get_bridgehub_contract().functions.sharedBridge().call() ) - except: - pass - if l2_weth_token == ADDRESS_DEFAULT: - bridge_address = self.bridge_addresses.erc20_l1_default_bridge else: - bridge_address = self.bridge_addresses.weth_bridge_l1 + bridge_contracts = self.get_l1_bridge_contracts() + bridge_address = bridge_contracts.shared.address if gas_limit is None: # TODO: get the approve(bridgeAddress, amount) estimateGas transaction to put correct gas_limit gas_limit = RecommendedGasLimit.ERC20_APPROVE @@ -279,244 +291,659 @@ def get_base_cost( :param gas_per_pubdata_byte: The L2 gas price for each published L1 calldata byte (optional). :param gas_price: The L1 gas price of the L1 transaction that will send the request for an execute call (optional). """ + bridge_hub = self.get_bridgehub_contract() if gas_price is None: gas_price = self._eth_web3.eth.gas_price options = TransactionOptions( chain_id=self._eth_web3.eth.chain_id, nonce=self._eth_web3.eth.get_transaction_count(self.address), ) - return self.contract.functions.l2TransactionBaseCost( - gas_price, l2_gas_limit, gas_per_pubdata_byte + return bridge_hub.functions.l2TransactionBaseCost( + self._zksync_web3.eth.chain_id, + gas_price, + l2_gas_limit, + gas_per_pubdata_byte, ).call(prepare_transaction_options(options, self.address)) - def prepare_deposit_tx(self, transaction: DepositTransaction) -> DepositTransaction: + def get_deposit_allowance_params(self, token: HexStr, amount: int): + if is_address_eq(token, LEGACY_ETH_ADDRESS): + token = ETH_ADDRESS_IN_CONTRACTS + + base_token_address = self.get_base_token() + is_eth_based_chain = self.is_eth_based_chain() + + if is_eth_based_chain and is_address_eq(token, ETH_ADDRESS_IN_CONTRACTS): + raise RuntimeError( + "ETH token can't be approved! The address of the token does not exist on L1." + ) + elif is_address_eq(base_token_address, ETH_ADDRESS_IN_CONTRACTS): + return [{"token": token, "allowance": amount}] + elif is_address_eq(token, ETH_ADDRESS_IN_CONTRACTS): + mint_value = self._get_deposit_mint_value_eth_on_non_eth_based_chain_tx( + DepositTransaction(token=token, amount=amount) + ) + return [{"token": base_token_address, "allowance": mint_value}] + elif is_address_eq(token, base_token_address): + _, mint_value = self._get_deposit_base_token_on_non_eth_based_chain_tx( + DepositTransaction(token=token, amount=amount) + ) + return [{"token": base_token_address, "allowance": mint_value}] + # A deposit of a non-base token to a non-ETH-based chain requires two approvals. + base_token_mint = ( + self._get_deposit_mint_value_non_base_token_to_non_eth_based_chain_tx( + DepositTransaction(token=token, amount=amount) + ) + ) + return [ + {"token": base_token_address, "allowance": base_token_mint}, + {"token": token, "allowance": amount}, + ] + + def _deposit_non_base_token_to_non_eth_based_chain( + self, transaction: DepositTransaction + ): + tx, _ = self._get_deposit_non_base_token_to_non_eth_based_chain_tx(transaction) + + if transaction.options.gas_limit is None: + tx["gas"] = scale_gas_limit(tx["gas"]) + + signed_tx = self._l1_account.sign_transaction(tx) + txn_hash = self._eth_web3.eth.send_raw_transaction(signed_tx.rawTransaction) + + return txn_hash + + def _deposit_base_token_to_non_eth_based_chain( + self, transaction: DepositTransaction + ): + nonce = transaction.options.nonce if transaction.options is not None else None + bridge_hub = self.get_bridgehub_contract() + chain_id = self._zksync_web3.zksync.chain_id + base_token_address = bridge_hub.functions.baseToken(chain_id).call() + bridge_contracts = self.get_l1_bridge_contracts() + + tx, mint_value = self._get_deposit_base_token_on_non_eth_based_chain_tx( + transaction + ) + + if transaction.approve_erc20 or transaction.approve_base_erc20: + approve_options = ( + transaction.approve_base_options + if transaction.approve_base_options is not None + else transaction.approve_options + ) + allowance = self.get_allowance_l1( + base_token_address, bridge_contracts.shared.address + ) + + if approve_options is None: + approve_options = TransactionOptions() + + if allowance < mint_value: + approve_tx = self.approve_erc20( + base_token_address, + mint_value, + bridge_contracts.shared.address, + approve_options.gas_limit, + ) + if nonce is None: + tx.options.nonce = self._eth_web3.eth.get_transaction_count( + self.address + ) + + if tx.options.gas_limit is None: + base_gas_limit = self.estimate_gas_request_execute(tx) + tx.options.gas_limit = scale_gas_limit(base_gas_limit) + + return self.request_execute(tx) + + def _deposit_eth_to_non_eth_based_chain(self, transaction: DepositTransaction): + tx, _ = self._get_deposit_eth_on_non_eth_based_chain_tx(transaction) + + if transaction.options.gas_limit is None: + tx["gas"] = scale_gas_limit(tx["gas"]) + + signed_tx = self._l1_account.sign_transaction(tx) + txn_hash = self._eth_web3.eth.send_raw_transaction(signed_tx.rawTransaction) + + return txn_hash + + def _deposit_token_to_eth_based_chain(self, transaction: DepositTransaction): + tx = self._get_deposit_token_on_eth_based_chain_tx(transaction) + + if transaction.options.gas_limit is None: + base_gas_limit = self._eth_web3.eth.estimate_gas(tx) + tx["gas"] = scale_gas_limit(base_gas_limit) + + signed_tx = self._l1_account.sign_transaction(tx) + txn_hash = self._eth_web3.eth.send_raw_transaction(signed_tx.rawTransaction) + + return txn_hash + + def _deposit_eth_to_eth_based_chain(self, transaction: DepositTransaction): + tx = self._get_deposit_eth_on_eth_based_chain_tx(transaction) + + if tx.options.gas_limit is None: + base_gas_limit = self.estimate_gas_request_execute(tx) + tx.options.gas_limit = scale_gas_limit(base_gas_limit) + + return self.request_execute(tx) + + def prepare_deposit_tx(self, transaction: DepositTransaction): """ Returns populated deposit transaction. :param transaction: DepositTransaction class. Not optional arguments are token(L1 token address) and amount. """ - if transaction.options is None: - transaction.options = TransactionOptions() - if transaction.to is None: - transaction.to = self.address - if transaction.options.chain_id is None: - transaction.options.chain_id = self._eth_web3.eth.chain_id - if transaction.bridge_address is not None: - bridge_contract = self._eth_web3.eth.contract( - address=Web3.to_checksum_address(transaction.bridge_address), - abi=l1_bridge_abi_default(), + if transaction.token.lower() == LEGACY_ETH_ADDRESS: + transaction.token = ETH_ADDRESS_IN_CONTRACTS + + bridge_hub = self.get_bridgehub_contract() + chain_id = self._zksync_web3.zksync.chain_id + base_token_address = bridge_hub.functions.baseToken(chain_id).call() + is_eth_base_chain = base_token_address == ETH_ADDRESS_IN_CONTRACTS + + if is_eth_base_chain and is_address_eq( + transaction.token, ETH_ADDRESS_IN_CONTRACTS + ): + return self._get_deposit_eth_on_eth_based_chain_tx(transaction) + elif is_eth_base_chain: + return self._get_deposit_token_on_eth_based_chain_tx(transaction) + elif is_address_eq(transaction.token, ETH_ADDRESS_IN_CONTRACTS): + tx, _ = self._get_deposit_eth_on_non_eth_based_chain_tx(transaction) + return tx + elif is_address_eq(transaction.token, base_token_address): + tx, _ = self._get_deposit_base_token_on_non_eth_based_chain_tx(transaction) + return tx + else: + tx, _ = self._get_deposit_non_base_token_to_non_eth_based_chain_tx( + transaction ) + return tx - if transaction.custom_bridge_data is None: - if transaction.bridge_address == self.bridge_addresses.weth_bridge_l1: - transaction.custom_bridge_data = "0x" - else: - token_contract = self._zksync_web3.zksync.contract( - transaction.token, abi=get_erc20_abi() - ) - transaction.custom_bridge_data = get_custom_bridge_data( - token_contract + def _get_deposit_mint_value_non_base_token_to_non_eth_based_chain_tx( + self, transaction: DepositTransaction + ): + tx = self._get_deposit_tx_with_defaults(transaction) + + gas_price_for_estimation: int + if tx.options.max_priority_fee_per_gas is not None: + gas_price_for_estimation = tx.options.max_fee_per_gas + else: + gas_price_for_estimation = tx.options.gas_price + + base_cost = self.get_base_cost( + tx.l2_gas_limit, + tx.gas_per_pubdata_byte, + gas_price_for_estimation, + ) + mint_value = base_cost + tx.operator_tip + check_base_cost(base_cost, mint_value) + + return mint_value + + def _get_deposit_non_base_token_to_non_eth_based_chain_tx( + self, transaction: DepositTransaction + ): + nonce = transaction.options.nonce if transaction.options is not None else None + bridge_hub = self.get_bridgehub_contract() + chain_id = self._zksync_web3.zksync.chain_id + bridge_contracts = self.get_l1_bridge_contracts() + base_token_address = bridge_hub.functions.baseToken(chain_id).call() + + tx = self._get_deposit_tx_with_defaults(transaction) + + mint_value = ( + self._get_deposit_mint_value_non_base_token_to_non_eth_based_chain_tx(tx) + ) + tx.options.value = tx.options.value or 0 + + if transaction.approve_base_erc20: + allowance = self.get_allowance_l1( + base_token_address, bridge_contracts.shared.address + ) + + if transaction.approve_base_options is None: + transaction.approve_base_options = TransactionOptions() + + if allowance < mint_value: + approve_tx = self.approve_erc20( + base_token_address, + mint_value, + bridge_contracts.shared.address, + transaction.approve_base_options.gas_limit, + ) + if nonce is None: + tx.options.nonce = self._eth_web3.eth.get_transaction_count( + self.address ) - if transaction.l2_gas_limit is None: - l2_address = bridge_contract.functions.l2TokenAddress( - transaction.token - ).call() - transaction.l2_gas_limit = self.estimate_custom_bridge_deposit_l2_gas( - transaction.bridge_address, - l2_address, - transaction.token, + if transaction.approve_erc20: + bridge_address = ( + transaction.bridge_address + if transaction.bridge_address is not None + else bridge_contracts.shared.address + ) + allowance = self.get_allowance_l1(transaction.token, bridge_address) + + if transaction.approve_options is None: + transaction.approve_options = TransactionOptions() + + if allowance < transaction.amount: + approve_tx = self.approve_erc20( + base_token_address, transaction.amount, - transaction.to, - transaction.custom_bridge_data, - self.address, - transaction.gas_per_pubdata_byte, + bridge_address, + transaction.approve_options.gas_limit, ) - elif transaction.l2_gas_limit is None: - transaction.l2_gas_limit = self.estimate_default_bridge_deposit_l2_gas( - transaction.token, - transaction.amount, - transaction.to, - transaction.gas_per_pubdata_byte, - self.address, - ) - if ( - transaction.options.gas_price is None - and transaction.options.max_fee_per_gas is None - ): - isReady, head = self.check_if_l1_chain_is_london_ready() - if isReady: - if transaction.options.max_priority_fee_per_gas is None: - transaction.options.max_priority_fee_per_gas = ( - self._eth_web3.eth.max_priority_fee + if nonce is None: + tx.options.nonce = self._eth_web3.eth.get_transaction_count( + self.address ) - transaction.options.max_fee_per_gas = int( - ((head["baseFeePerGas"] * 3) / 2) - + transaction.options.max_priority_fee_per_gas - ) - else: - transaction.options.gas_price = self._eth_web3.eth.gas_price + + transaction_data = { + "chainId": chain_id, + "mintValue": mint_value, + "l2Value": 0, + "l2GasLimit": transaction.l2_gas_limit, + "l2GasPerPubdataByteLimit": transaction.gas_per_pubdata_byte, + "refundRecipient": transaction.refund_recipient or self.address, + "secondBridgeAddress": bridge_contracts.shared.address, + "secondBridgeValue": 0, + "secondBridgeCalldata": encode( + ["address", "uint256", "address"], [tx.token, tx.amount, tx.to] + ), + } + + return ( + bridge_hub.functions.requestL2TransactionTwoBridges( + transaction_data + ).build_transaction( + prepare_transaction_options(tx.options, self.address, self._eth_web3) + ), + mint_value, + ) + + def _get_deposit_base_token_on_non_eth_based_chain_tx( + self, transaction: DepositTransaction + ): + tx = self._get_deposit_tx_with_defaults(transaction) gas_price_for_estimation: int - if transaction.options.max_priority_fee_per_gas is not None: - gas_price_for_estimation = transaction.options.max_fee_per_gas + if tx.options.max_priority_fee_per_gas is not None: + gas_price_for_estimation = tx.options.max_fee_per_gas else: - gas_price_for_estimation = transaction.options.gas_price + gas_price_for_estimation = tx.options.gas_price base_cost = self.get_base_cost( - transaction.l2_gas_limit, - transaction.gas_per_pubdata_byte, + tx.l2_gas_limit, + tx.gas_per_pubdata_byte, gas_price_for_estimation, ) - if is_eth(transaction.token): - transaction.options.value = ( - base_cost + transaction.operator_tip + transaction.amount - ) + tx.options.value = 0 + + return ( + RequestExecuteCallMsg( + contract_address=tx.to, + call_data=HexStr("0x"), + mint_value=base_cost + tx.operator_tip + tx.amount, + l2_value=tx.amount, + operator_tip=tx.operator_tip, + l2_gas_limit=tx.l2_gas_limit, + gas_per_pubdata_byte=tx.gas_per_pubdata_byte, + options=tx.options, + ), + base_cost + tx.operator_tip + tx.amount, + ) + + def _get_deposit_mint_value_eth_on_non_eth_based_chain_tx( + self, tx: DepositTransaction + ): + tx = self._get_deposit_tx_with_defaults(tx) + + gas_price_for_estimation: int + if tx.options.max_priority_fee_per_gas is not None: + gas_price_for_estimation = tx.options.max_fee_per_gas else: - if transaction.refund_recipient is None: - transaction.refund_recipient = ADDRESS_DEFAULT - transaction.options.value = base_cost + transaction.operator_tip + gas_price_for_estimation = tx.options.gas_price - check_base_cost(base_cost, transaction.options.value) + base_cost = self.get_base_cost( + tx.l2_gas_limit, + tx.gas_per_pubdata_byte, + gas_price_for_estimation, + ) - return transaction + mint_value = base_cost + tx.operator_tip + check_base_cost(base_cost, mint_value) - def get_full_required_deposit_fee( + return mint_value + + def _get_deposit_eth_on_non_eth_based_chain_tx( self, transaction: DepositTransaction - ) -> FullDepositFee: - """ - Retrieves the full needed ETH fee for the deposit. Returns the L1 fee and the L2 fee FullDepositFee(core/types.py). + ): + nonce = transaction.options.nonce if transaction.options is not None else None + bridge_hub = self.get_bridgehub_contract() + chain_id = self._zksync_web3.zksync.chain_id + shared_bridge = self.get_l1_bridge_contracts().shared + base_token_address = bridge_hub.functions.baseToken(chain_id).call() - :param transaction: DepositTransaction: DepositTransaction class. Not optional argument is amount. - """ - dummy_amount = 1 + tx = self._get_deposit_tx_with_defaults(transaction) + mint_value = self._get_deposit_mint_value_eth_on_non_eth_based_chain_tx(tx) + tx.options.value = tx.options.value or tx.amount - if transaction.options is None: - transaction.options = TransactionOptions() + if transaction.approve_base_erc20: + allowance = self.get_allowance_l1( + Web3.to_checksum_address(base_token_address), shared_bridge.address + ) - if transaction.to is None: - transaction.to = self.address + if transaction.approve_base_options is None: + transaction.approve_base_options = TransactionOptions() - if transaction.bridge_address is not None: - bridge_contract = self._eth_web3.eth.contract( - address=Web3.to_checksum_address(transaction.bridge_address), - abi=l1_bridge_abi_default(), + if allowance < mint_value: + approve_tx = self.approve_erc20( + base_token_address, + mint_value, + shared_bridge.address, + transaction.approve_base_options.gas_limit, + ) + if nonce is None: + tx.options.nonce = self._eth_web3.eth.get_transaction_count( + self.address + ) + + transaction_data = { + "chainId": chain_id, + "mintValue": mint_value, + "l2Value": 0, + "l2GasLimit": transaction.l2_gas_limit, + "l2GasPerPubdataByteLimit": transaction.gas_per_pubdata_byte, + "refundRecipient": transaction.refund_recipient, + "secondBridgeAddress": shared_bridge.address, + "secondBridgeValue": transaction.amount, + "secondBridgeCalldata": encode( + ["address", "uint256", "address"], [ETH_ADDRESS_IN_CONTRACTS, 0, tx.to] + ), + } + + return ( + bridge_hub.functions.requestL2TransactionTwoBridges( + transaction_data + ).build_transaction( + prepare_transaction_options(tx.options, self.address, self._eth_web3) + ), + mint_value, + ) + + def _get_deposit_token_on_eth_based_chain_tx(self, transaction: DepositTransaction): + nonce = transaction.options.nonce if transaction.options is not None else None + bridge_hub = self.get_bridgehub_contract() + chain_id = self._zksync_web3.zksync.chain_id + bridge_contracts = self.get_l1_bridge_contracts() + + tx = self._get_deposit_tx_with_defaults(transaction) + + if transaction.approve_erc20: + proposed_bridge = bridge_contracts.shared.address + bridge_address = ( + transaction.bridge_address + if transaction.bridge_address is not None + else proposed_bridge ) - if transaction.custom_bridge_data is None: - if transaction.bridge_address == self.bridge_addresses.weth_bridge_l1: - transaction.custom_bridge_data = "0x" - else: - token_contract = self._zksync_web3.zksync.contract( - transaction.token, abi=get_erc20_abi() - ) - transaction.custom_bridge_data = get_custom_bridge_data( - token_contract - ) + allowance = self.get_allowance_l1( + Web3.to_checksum_address(transaction.token), bridge_address + ) + + if transaction.approve_options is None: + transaction.approve_options = TransactionOptions() - if transaction.l2_gas_limit is None: - l2_address = bridge_contract.functions.l2TokenAddress( - transaction.token - ).call() - transaction.l2_gas_limit = self.estimate_custom_bridge_deposit_l2_gas( - transaction.bridge_address, - l2_address, + if allowance < transaction.amount: + approve_tx = self.approve_erc20( transaction.token, - dummy_amount, - transaction.to, - transaction.custom_bridge_data, - self.address, - transaction.gas_per_pubdata_byte, + transaction.amount, + bridge_contracts.shared.address, + transaction.approve_options.gas_limit, ) - elif transaction.l2_gas_limit is None: - transaction.l2_gas_limit = self.estimate_default_bridge_deposit_l2_gas( - transaction.token, - dummy_amount, - transaction.to, - transaction.gas_per_pubdata_byte, - self.address, - ) - if ( - transaction.options.gas_price is None - and transaction.options.max_fee_per_gas is None - ): - isReady, head = self.check_if_l1_chain_is_london_ready() - if isReady: - if transaction.options.max_priority_fee_per_gas is None: - transaction.options.max_priority_fee_per_gas = ( - self._eth_web3.eth.max_priority_fee + if nonce is None: + tx.options.nonce = self._eth_web3.eth.get_transaction_count( + self.address ) - transaction.options.max_fee_per_gas = int( - ((head["baseFeePerGas"] * 3) / 2) - + transaction.options.max_priority_fee_per_gas - ) - else: - transaction.options.gas_price = self._eth_web3.eth.gas_price gas_price_for_estimation: int - if transaction.options.max_priority_fee_per_gas is not None: - gas_price_for_estimation = transaction.options.max_fee_per_gas + if tx.options.max_priority_fee_per_gas is not None: + gas_price_for_estimation = tx.options.max_fee_per_gas else: - gas_price_for_estimation = transaction.options.gas_price + gas_price_for_estimation = tx.options.gas_price base_cost = self.get_base_cost( - transaction.l2_gas_limit, - transaction.gas_per_pubdata_byte, + tx.l2_gas_limit, + tx.gas_per_pubdata_byte, gas_price_for_estimation, ) - self_balance_eth = self.get_l1_balance() - # We could use 0, because the final fee will anyway be bigger than - if base_cost >= (self_balance_eth + dummy_amount): - recommended_eth_balance = ( - RecommendedGasLimit.L1_RECOMMENDED_ETH_DEPOSIT_GAS_LIMIT + mint_value = base_cost + tx.operator_tip + tx.options.value = tx.options.value or mint_value + check_base_cost(base_cost, mint_value) + + second_bridge_address: str + second_bridge_calldata: bytes + if tx.bridge_address is not None: + second_bridge_address = tx.bridge_address + token_contract = self._eth_web3.eth.contract( + address=Web3.to_checksum_address(tx.token), abi=get_erc20_abi() ) - if not is_eth(transaction.token): - recommended_eth_balance = ( - RecommendedGasLimit.L1_RECOMMENDED_MIN_ERC_20_DEPOSIT_GAS_LIMIT - ) - recommended_eth_balance = ( - recommended_eth_balance * gas_price_for_estimation + base_cost + second_bridge_calldata = get_custom_bridge_data(token_contract) + else: + second_bridge_address = self.get_l1_bridge_contracts().shared.address + second_bridge_calldata = encode( + ["address", "uint256", "address"], [tx.token, tx.amount, tx.to] ) - RuntimeError( - "Not enough balance for deposit. Under the provided gas price, " - + f"the recommended balance to perform a deposit is ${recommended_eth_balance} ETH" + transaction_data = { + "chainId": chain_id, + "mintValue": mint_value, + "l2Value": transaction.l2_value, + "l2GasLimit": transaction.l2_gas_limit, + "l2GasPerPubdataByteLimit": transaction.gas_per_pubdata_byte, + "refundRecipient": transaction.refund_recipient, + "secondBridgeAddress": second_bridge_address, + "secondBridgeValue": 0, + "secondBridgeCalldata": second_bridge_calldata, + } + + return bridge_hub.functions.requestL2TransactionTwoBridges( + transaction_data + ).build_transaction(prepare_transaction_options(tx.options, self.address)) + + def _get_deposit_eth_on_eth_based_chain_tx(self, transaction: DepositTransaction): + tx = self._get_deposit_tx_with_defaults(transaction) + + gas_price_for_estimation: int + if tx.options.max_priority_fee_per_gas is not None: + gas_price_for_estimation = tx.options.max_fee_per_gas + else: + gas_price_for_estimation = tx.options.gas_price + + base_cost = self.get_base_cost( + tx.l2_gas_limit, + tx.gas_per_pubdata_byte, + gas_price_for_estimation, + ) + + tx.options.value = ( + base_cost + tx.operator_tip + tx.amount + if tx.options.value is None + else tx.options.value + ) + + return RequestExecuteCallMsg( + contract_address=tx.to, + call_data=HexStr("0x"), + mint_value=tx.options.value, + l2_value=tx.amount, + operator_tip=tx.operator_tip, + l2_gas_limit=tx.l2_gas_limit, + gas_per_pubdata_byte=tx.gas_per_pubdata_byte, + options=tx.options, + refund_recipient=tx.refund_recipient, + ) + + def _get_deposit_tx_with_defaults(self, transaction: DepositTransaction): + if transaction.options is None: + transaction.options = TransactionOptions() + if transaction.to is None: + transaction.to = self.address + if transaction.options.chain_id is None: + transaction.options.chain_id = self._eth_web3.eth.chain_id + if transaction.l2_gas_limit is None: + transaction.l2_gas_limit = self._get_l2_gas_limit(transaction) + if transaction.refund_recipient is None: + transaction.refund_recipient = self.address + if transaction.options.nonce is None: + transaction.options.nonce = self._eth_web3.eth.get_transaction_count( + self.address ) + self.insert_gas_price_in_transaction_options(transaction.options) - if not is_eth(transaction.token): - allowance = self.get_allowance_l1( - transaction.token, transaction.bridge_address + return transaction + + def _get_l2_gas_limit(self, transaction: DepositTransaction): + if transaction.bridge_address is not None: + return self._get_l2_gas_limit_from_custom_bridge(transaction) + + return self.estimate_default_bridge_deposit_l2_gas( + transaction.token, + transaction.amount, + transaction.to, + transaction.gas_per_pubdata_byte, + self.address, + ) + + def _get_l2_gas_limit_from_custom_bridge(self, transaction: DepositTransaction): + if transaction.custom_bridge_data is None: + token_contract = self._zksync_web3.zksync.contract( + transaction.token, abi=get_erc20_abi() ) - if allowance < dummy_amount: - RuntimeError("Not enough allowance to cover the deposit") + transaction.custom_bridge_data = get_custom_bridge_data(token_contract) - # Deleting the explicit gas limits in the fee estimation - # in order to prevent the situation where the transaction - # fails because the user does not have enough balance - del transaction.options.gas_price - del transaction.options.max_fee_per_gas - del transaction.options.max_priority_fee_per_gas + bridge = self._zksync_web3.zksync.contract( + transaction.bridge_address, abi=l1_bridge_abi_default() + ) + + if transaction.options.chain_id is None: + transaction.options.chain_id = self._eth_web3.eth.chain_id + + l2_address = bridge.functions.l2TokenAddress(transaction.token).call() + + return self.estimate_custom_bridge_deposit_l2_gas( + transaction.bridge_address, + l2_address, + transaction.token, + transaction.amount, + transaction.to, + transaction.custom_bridge_data, + self.address, + transaction.gas_per_pubdata_byte, + ) + def get_full_required_deposit_fee( + self, transaction: DepositTransaction + ) -> FullDepositFee: + """ + Retrieves the full needed ETH fee for the deposit. + Returns the L1 fee and the L2 fee FullDepositFee(core/types.py). + + :param transaction: DepositTransaction: DepositTransaction class. Not optional argument is amount. + """ + if is_address_eq(transaction.token, LEGACY_ETH_ADDRESS): + transaction.token = ETH_ADDRESS_IN_CONTRACTS + dummy_amount = 1 transaction.amount = dummy_amount - l1_gas_limit = self.estimate_gas_deposit(transaction) + bridge_hub = self.get_bridgehub_contract() + chain_id = self._zksync_web3.zksync.chain_id + base_token_address = bridge_hub.functions.baseToken(chain_id).call() + is_eth_based_chain = is_address_eq(base_token_address, ETH_ADDRESS_IN_CONTRACTS) + + tx = self._get_deposit_tx_with_defaults(transaction) + + gas_price_for_estimation = ( + tx.options.max_fee_per_gas + if tx.options.max_fee_per_gas is not None + else tx.options.gas_price + ) + + base_cost = self.get_base_cost( + tx.l2_gas_limit, + tx.gas_per_pubdata_byte, + gas_price_for_estimation, + ) + + if is_eth_based_chain: + self_balance_eth = self.get_l1_balance() + # We could use 0, because the final fee will anyway be bigger than + if base_cost >= (self_balance_eth + dummy_amount): + recommended_eth_balance = ( + RecommendedGasLimit.L1_RECOMMENDED_ETH_DEPOSIT_GAS_LIMIT + ) + if not is_address_eq(tx.token, LEGACY_ETH_ADDRESS): + recommended_eth_balance = ( + RecommendedGasLimit.L1_RECOMMENDED_MIN_ERC_20_DEPOSIT_GAS_LIMIT + ) + + RuntimeError( + "Not enough balance for deposit. Under the provided gas price, " + + f"the recommended balance to perform a deposit is ${recommended_eth_balance} ETH" + ) + if ( + not is_address_eq(tx.token, ETH_ADDRESS_IN_CONTRACTS) + and self.get_allowance_l1(tx.token, tx.bridge_address) < dummy_amount + ): + RuntimeError("Not enough allowance to cover the deposit!") + else: + mint_value = base_cost + tx.operator_tip + if self.get_allowance_l1(base_token_address) < mint_value: + RuntimeError("Not enough base token allowance to cover the deposit!") + if is_address_eq(tx.token, ETH_ADDRESS_IN_CONTRACTS) or is_address_eq( + tx.token, base_token_address + ): + tx.options.value = tx.amount + else: + tx.options.value = 0 if tx.options.value is None else tx.options.value + if self.get_allowance_l1(tx.token) < dummy_amount: + RuntimeError("Not enough token allowance to cover the deposit!") full_cost: FullDepositFee = FullDepositFee( base_cost=base_cost, - l1_gas_limit=l1_gas_limit, + l1_gas_limit=0, l2_gas_limit=transaction.l2_gas_limit, ) - if transaction.options.gas_price is not None: - full_cost.gas_price = transaction.options.gas_price + if tx.options.gas_price is not None: + full_cost.gas_price = tx.options.gas_price else: - full_cost.max_priority_fee_per_gas = ( - transaction.options.max_priority_fee_per_gas - ) - full_cost.max_fee_per_gas = transaction.options.max_fee_per_gas + full_cost.max_priority_fee_per_gas = tx.options.max_priority_fee_per_gas + full_cost.max_fee_per_gas = tx.options.max_fee_per_gas + + # Deleting the explicit gas limits in the fee estimation + # in order to prevent the situation where the transaction + # fails because the user does not have enough balance + del tx.options.gas_price + del tx.options.max_fee_per_gas + del tx.options.max_priority_fee_per_gas + + full_cost.l1_gas_limit = self.estimate_gas_deposit(tx) return full_cost + def get_priority_op_confirmation(self, tx_hash: HexStr, index: int = 0): + """ + Returns the transaction confirmation data that is part of `L2->L1` message. + + :param tx_hash: The hash of the L2 transaction where the message was initiated. + :param index: In case there were multiple transactions in one message, you may pass an index of the + transaction which confirmation data should be fetched. + """ + return self._zksync_web3.zksync.get_priority_op_confirmation(tx_hash, index) + def deposit(self, transaction: DepositTransaction): """ Transfers the specified token from the associated account on the L1 network to the target account on the L2 network. @@ -528,111 +955,49 @@ def deposit(self, transaction: DepositTransaction): :param transaction: DepositTransaction class. Not optional arguments are token(L1 token address) and amount. """ - transaction = self.prepare_deposit_tx(transaction) + if transaction.token.lower() == LEGACY_ETH_ADDRESS: + transaction.token = ETH_ADDRESS_IN_CONTRACTS - if is_eth(transaction.token): - tx = deposit_to_request_execute(transaction) - return self.request_execute(tx) - else: - if transaction.approve_erc20: - self.approve_erc20( - transaction.token, - transaction.amount, - transaction.bridge_address, - transaction.options.gas_limit, - ) - - if transaction.bridge_address is not None: - l1_bridge = self._eth_web3.eth.contract( - address=Web3.to_checksum_address(transaction.bridge_address), - abi=l1_bridge_abi_default(), - ) - else: - l2_weth_token = ADDRESS_DEFAULT - try: - l2_weth_token = ( - self.get_l1_bridge_contracts() - .weth.functions.l2TokenAddress(transaction.token) - .call() - ) - except: - pass - if l2_weth_token == ADDRESS_DEFAULT: - bridge_address = self.bridge_addresses.erc20_l1_default_bridge - else: - bridge_address = self.bridge_addresses.weth_bridge_l1 - l1_bridge = self._eth_web3.eth.contract( - address=Web3.to_checksum_address(bridge_address), - abi=l1_bridge_abi_default(), - ) - if transaction.options.nonce is None: - transaction.options.nonce = self._eth_web3.eth.get_transaction_count( - self.address - ) - tx = l1_bridge.functions.deposit( - transaction.to, - transaction.token, - transaction.amount, - transaction.l2_gas_limit, - transaction.gas_per_pubdata_byte, - transaction.refund_recipient, - ).build_transaction( - { - "from": self.address, - "maxFeePerGas": transaction.options.max_fee_per_gas, - "maxPriorityFeePerGas": transaction.options.max_priority_fee_per_gas, - "nonce": self._eth_web3.eth.get_transaction_count(self.address), - "value": transaction.options.value, - } - ) - signed_tx = self._l1_account.sign_transaction(tx) - txn_hash = self._eth_web3.eth.send_raw_transaction(signed_tx.rawTransaction) + bridge_hub = self.get_bridgehub_contract() + chain_id = self._zksync_web3.zksync.chain_id + base_token_address = bridge_hub.functions.baseToken(chain_id).call() + is_eth_base_chain = base_token_address == ETH_ADDRESS_IN_CONTRACTS - return txn_hash + if is_eth_base_chain and is_address_eq( + transaction.token, ETH_ADDRESS_IN_CONTRACTS + ): + return self._deposit_eth_to_eth_based_chain(transaction) + elif is_eth_base_chain: + return self._deposit_token_to_eth_based_chain(transaction) + elif is_address_eq(transaction.token, ETH_ADDRESS_IN_CONTRACTS): + tx = self._deposit_eth_to_non_eth_based_chain(transaction) + return tx + elif is_address_eq(transaction.token, base_token_address): + tx = self._deposit_base_token_to_non_eth_based_chain(transaction) + return tx + else: + tx = self._deposit_non_base_token_to_non_eth_based_chain(transaction) + return tx - def estimate_gas_deposit(self, transaction: DepositTransaction): + def estimate_gas_deposit(self, transaction: DepositTransaction) -> int: """ Estimates the amount of gas required for a deposit transaction on L1 network. Gas of approving ERC20 token is not included in estimation. :param transaction: DepositTransaction class. Not optional arguments are token(L1 token address) and amount. """ - transaction = self.prepare_deposit_tx(transaction) - if is_eth(transaction.token): - tx = self.contract.functions.requestL2Transaction( - Web3.to_checksum_address(transaction.to), - transaction.l2_value, - HexStr("0x"), - transaction.l2_gas_limit, - transaction.gas_per_pubdata_byte, - list(), - self.address, - ).build_transaction( - prepare_transaction_options(transaction.options, self.address) - ) + if is_address_eq(transaction.token, LEGACY_ETH_ADDRESS): + transaction.token = ETH_ADDRESS_IN_CONTRACTS - return self._eth_web3.eth.estimate_gas(tx) - else: - if transaction.bridge_address is None: - bridge = self.get_l1_bridge_contracts().erc20 - else: - bridge = self._eth_web3.eth.contract( - Web3.to_checksum_address(transaction.bridge_address), - abi=get_erc20_abi(), - ) + tx = self.prepare_deposit_tx(transaction) - tx = bridge.functions.deposit( - transaction.to, - transaction.token, - transaction.amount, - transaction.l2_gas_limit, - transaction.gas_per_pubdata_byte, - self.address, - ).build_transaction( - prepare_transaction_options(transaction.options, self.address) - ) + base_gas_limit: int + if is_address_eq(transaction.token, self.get_base_token()): + base_gas_limit = self.estimate_gas_request_execute(tx) + else: + base_gas_limit = self._eth_web3.eth.estimate_gas(tx) - return self._eth_web3.eth.estimate_gas(tx) + return scale_gas_limit(base_gas_limit) def claim_failed_deposit(self, deposit_hash: HexStr): """ @@ -697,46 +1062,37 @@ def estimate_default_bridge_deposit_l2_gas( from_ = self._l1_account.address if gas_per_pubdata_byte is None: gas_per_pubdata_byte = DEPOSIT_GAS_PER_PUBDATA_LIMIT - if is_eth(token): + if self._zksync_web3.zksync.is_base_token(token): func_call = TxFunctionCall( to=to, from_=from_, value=amount, gas_per_pub_data=gas_per_pubdata_byte ) return self._zksync_web3.zksync.zks_estimate_l1_to_l2_execute(func_call.tx) else: - l2_weth_token = ADDRESS_DEFAULT - try: - l2_weth_token = ( - self.get_l1_bridge_contracts() - .weth.functions.l2TokenAddress(token) - .call() - ) - except: - pass - if l2_weth_token == ADDRESS_DEFAULT: - value = 0 - l1_bridge_address = self.bridge_addresses.erc20_l1_default_bridge - l2_bridge_address = self.bridge_addresses.erc20_l2_default_bridge - token_contract = self._eth_web3.eth.contract( - Web3.to_checksum_address(token), abi=get_erc20_abi() - ) - bridge_data = get_custom_bridge_data(token_contract) - else: - value = amount - l1_bridge_address = self.bridge_addresses.weth_bridge_l1 - l2_bridge_address = self.bridge_addresses.weth_bridge_l2 - bridge_data = "0x" - - return self.estimate_custom_bridge_deposit_l2_gas( - l1_bridge_address, - l2_bridge_address, - token, - amount, - to, - bridge_data, - from_, - gas_per_pubdata_byte, - value, - ) + bridge_addresses = self._zksync_web3.zksync.zks_get_bridge_contracts() + + value = 0 + l1_bridge_address = bridge_addresses.shared_l1_default_bridge + l2_bridge_address = bridge_addresses.shared_l2_default_bridge + token_contract = self._eth_web3.eth.contract( + Web3.to_checksum_address(token), abi=get_erc20_abi() + ) + bridge_data = get_custom_bridge_data(token_contract) + + return self.estimate_custom_bridge_deposit_l2_gas( + l1_bridge_address, + l2_bridge_address, + ( + ETH_ADDRESS_IN_CONTRACTS + if is_address_eq(token, LEGACY_ETH_ADDRESS) + else token + ), + amount, + to, + bridge_data, + from_, + gas_per_pubdata_byte, + value, + ) def estimate_custom_bridge_deposit_l2_gas( self, @@ -791,58 +1147,19 @@ def finalize_withdrawal(self, withdraw_hash, index: int = 0): nonce=self._eth_web3.eth.get_transaction_count(self.address), ) - if is_eth(params["sender"]): - withdraw_to = HexStr("0x" + params["message"][4:24].hex()) - if withdraw_to.lower() == self.bridge_addresses.weth_bridge_l1.lower(): - tx = ( - self.get_l1_bridge_contracts() - .weth.functions.finalizeEthWithdrawal( - params["l1_batch_number"], - params["l2_message_index"], - params["l2_tx_number_in_block"], - params["message"], - merkle_proof, - ) - .build_transaction( - prepare_transaction_options(options, self.address) - ) - ) - else: - tx = self.contract.functions.finalizeEthWithdrawal( - params["l1_batch_number"], - params["l2_message_index"], - params["l2_tx_number_in_block"], - params["message"], - merkle_proof, - ).build_transaction(prepare_transaction_options(options, self.address)) - signed = self._l1_account.sign_transaction(tx) - tx_hash = self._eth_web3.eth.send_raw_transaction(signed.rawTransaction) - return tx_hash - else: - l2_bridge = self._zksync_web3.zksync.contract( - address=Web3.to_checksum_address(params["sender"]), - abi=l2_bridge_abi_default(), - ) - l1_bridge = self._eth_web3.eth.contract( - address=Web3.to_checksum_address(l2_bridge.functions.l1Bridge().call()), - abi=l1_bridge_abi_default(), - ) - l1_batch_number = params["l1_batch_number"] - l2_message_index = params["l2_message_index"] - l2_tx_number_in_block = params["l2_tx_number_in_block"] - message = params["message"] - - tx = l1_bridge.functions.finalizeWithdrawal( - params["l1_batch_number"], - params["l2_message_index"], - params["l2_tx_number_in_block"], - params["message"], - merkle_proof, - ).build_transaction(prepare_transaction_options(options, self.address)) - - signed = self._l1_account.sign_transaction(tx) - tx_hash = self._eth_web3.eth.send_raw_transaction(signed.rawTransaction) - return tx_hash + shared_bridge = self.get_l1_bridge_contracts().shared + tx = shared_bridge.functions.finalizeWithdrawal( + self._zksync_web3.eth.chain_id, + params["l1_batch_number"], + params["l2_message_index"], + params["l2_tx_number_in_block"], + params["message"], + merkle_proof, + ).build_transaction(prepare_transaction_options(options, self.address)) + + signed = self._l1_account.sign_transaction(tx) + tx_hash = self._eth_web3.eth.send_raw_transaction(signed.rawTransaction) + return tx_hash def is_withdrawal_finalized(self, withdraw_hash, index: int = 0): """ @@ -860,25 +1177,27 @@ def is_withdrawal_finalized(self, withdraw_hash, index: int = 0): hex_hash, l2_to_l1_log_index ) - l2_block_number = log["l1BatchNumber"] options = TransactionOptions( chain_id=self._eth_web3.eth.chain_id, nonce=self._eth_web3.eth.get_transaction_count(self.address), ) - if is_eth(sender): - return self.contract.functions.isEthWithdrawalFinalized( - int(l2_block_number, 16), proof.id - ).call(prepare_transaction_options(options, self.address)) + + l1_bridge: Contract + if self._zksync_web3.zksync.is_base_token(sender): + l1_bridge = self.get_l1_bridge_contracts().shared else: + l2_bridge = self._zksync_web3.eth.contract( + Web3.to_checksum_address(sender), abi=l2_bridge_abi_default() + ) l1_bridge = self._eth_web3.eth.contract( - address=Web3.to_checksum_address( - self.bridge_addresses.erc20_l1_default_bridge - ), - abi=l1_bridge_abi_default(), + Web3.to_checksum_address(l2_bridge.functions.l1Bridge().call()), + abi=l1_shared_bridge_abi_default(), ) - return l1_bridge.functions.isWithdrawalFinalized( - int(l2_block_number, 16), proof.id - ).call() + + a = l1_bridge.functions.isWithdrawalFinalized( + self._zksync_web3.eth.chain_id, int(log["l1BatchNumber"], 16), proof.id + ).call() + return a def request_execute(self, transaction: RequestExecuteCallMsg): """ @@ -896,18 +1215,7 @@ def request_execute(self, transaction: RequestExecuteCallMsg): ) """ transaction = self.get_request_execute_transaction(transaction) - tx = self.contract.functions.requestL2Transaction( - transaction.contract_address, - transaction.l2_value, - transaction.call_data, - transaction.l2_gas_limit, - transaction.gas_per_pubdata_byte, - transaction.factory_deps, - transaction.refund_recipient, - ).build_transaction( - prepare_transaction_options(transaction.options, transaction.from_) - ) - signed_tx = self._l1_account.sign_transaction(tx) + signed_tx = self._l1_account.sign_transaction(transaction) tx_hash = self._eth_web3.eth.send_raw_transaction(signed_tx.rawTransaction) return tx_hash @@ -918,19 +1226,21 @@ def check_if_l1_chain_is_london_ready(self): return True, head return False, head - def get_request_execute_transaction( - self, transaction: RequestExecuteCallMsg - ) -> RequestExecuteCallMsg: + def get_request_execute_transaction(self, transaction: RequestExecuteCallMsg): """ Returns populated deposit transaction. :param transaction: RequestExecuteCallMsg class, required parameters are: contract_address(L2 contract to be called) and call_data (the input of the L2 transaction). """ + bridgehub = self.get_bridgehub_contract() + chain_id = self._zksync_web3.zksync.chain_id + is_eth_based_chain = self.is_eth_based_chain() + if transaction.options is None: transaction.options = TransactionOptions() if transaction.factory_deps is None: - transaction.factory_deps = list() + transaction.factory_deps = [] if transaction.refund_recipient is None: transaction.refund_recipient = self.address if transaction.from_ is None: @@ -957,8 +1267,8 @@ def get_request_execute_transaction( transaction.options.gas_price is None and transaction.options.max_fee_per_gas is None ): - isReady, head = self.check_if_l1_chain_is_london_ready() - if isReady: + is_ready, head = self.check_if_l1_chain_is_london_ready() + if is_ready: if transaction.options.max_priority_fee_per_gas is None: transaction.options.max_priority_fee_per_gas = ( self._eth_web3.eth.max_priority_fee @@ -982,14 +1292,37 @@ def get_request_execute_transaction( gas_price_for_estimation, ) - if transaction.options.value is None: - transaction.options.value = ( - base_cost + transaction.operator_tip + transaction.l2_value - ) + l2_costs = base_cost + transaction.operator_tip + transaction.l2_value + provided_value = ( + transaction.options.value if is_eth_based_chain else transaction.mint_value + ) - check_base_cost(base_cost, transaction.options.value) + if provided_value == 0 or provided_value is None: + provided_value = l2_costs + if is_eth_based_chain: + transaction.options.value = provided_value + + transaction.mint_value = provided_value + + check_base_cost(base_cost, provided_value) + + transaction_data = { + "chainId": chain_id, + "mintValue": provided_value, + "l2Contract": Web3.to_checksum_address(transaction.contract_address), + "l2Value": transaction.l2_value, + "l2Calldata": to_bytes(transaction.call_data), + "l2GasLimit": transaction.l2_gas_limit, + "l2GasPerPubdataByteLimit": transaction.gas_per_pubdata_byte, + "factoryDeps": transaction.factory_deps, + "refundRecipient": transaction.refund_recipient, + } - return transaction + return bridgehub.functions.requestL2TransactionDirect( + transaction_data + ).build_transaction( + prepare_transaction_options(transaction.options, self.address) + ) def estimate_gas_request_execute(self, transaction: RequestExecuteCallMsg) -> int: """ @@ -999,16 +1332,69 @@ def estimate_gas_request_execute(self, transaction: RequestExecuteCallMsg) -> in contract_address(L2 contract to be called) and call_data (the input of the L2 transaction). """ transaction = self.get_request_execute_transaction(transaction) - tx = self.contract.functions.requestL2Transaction( - Web3.to_checksum_address(transaction.contract_address), - transaction.l2_value, - transaction.call_data, + + return self._eth_web3.eth.estimate_gas(transaction) + + def get_request_execute_allowance_params(self, transaction: RequestExecuteCallMsg): + bridge_hub = self.get_bridgehub_contract() + chain_id = self._zksync_web3.zksync.chain_id + base_token_address = bridge_hub.functions.baseToken(chain_id).call() + is_eth_base_chain = base_token_address == ETH_ADDRESS_IN_CONTRACTS + + if is_eth_base_chain: + raise RuntimeError( + "ETH token can't be approved! The address of the token does not exist on L1." + ) + + if transaction.from_ is None: + transaction.from_ = self.address + if transaction.refund_recipient is None: + transaction.refund_recipient = self.address + if transaction.l2_gas_limit == 0: + func_call = TxFunctionCall( + to=transaction.contract_address, + from_=transaction.from_, + gas_per_pub_data=transaction.gas_per_pubdata_byte, + data=transaction.call_data, + ) + transaction.l2_gas_limit = ( + self._zksync_web3.zksync.zks_estimate_l1_to_l2_execute(func_call.tx) + ) + + transaction.options = self.insert_gas_price_in_transaction_options( + transaction.options + ) + gas_price_for_estimation = ( + transaction.options.max_fee_per_gas + if transaction.options.max_fee_per_gas is not None + else transaction.options.gas_price + ) + + base_cost = self.get_base_cost( transaction.l2_gas_limit, transaction.gas_per_pubdata_byte, - transaction.factory_deps, - transaction.refund_recipient, - ).build_transaction( - prepare_transaction_options(transaction.options, self.address) + gas_price_for_estimation, + ) + + return ( + self.get_base_token(), + base_cost + transaction.operator_tip + transaction.l2_value, ) - return self._eth_web3.eth.estimate_gas(tx) + def insert_gas_price_in_transaction_options( + self, options: TransactionOptions + ) -> TransactionOptions: + if options.gas_price is None and options.max_fee_per_gas is None: + is_ready, head = self.check_if_l1_chain_is_london_ready() + if is_ready: + if options.max_priority_fee_per_gas is None: + options.max_priority_fee_per_gas = ( + self._eth_web3.eth.max_priority_fee + ) + options.max_fee_per_gas = int( + ((head["baseFeePerGas"] * 3) / 2) + options.max_priority_fee_per_gas + ) + else: + options.gas_price = self._eth_web3.eth.gas_price + + return options diff --git a/zksync2/account/wallet_l2.py b/zksync2/account/wallet_l2.py index 8cdcde1..4eb6f1a 100644 --- a/zksync2/account/wallet_l2.py +++ b/zksync2/account/wallet_l2.py @@ -1,31 +1,22 @@ from eth_account.signers.base import BaseAccount -from web3 import Web3 - from eth_typing import HexStr from web3 import Web3 -from zksync2.account.utils import prepare_transaction_options, options_from_712 from zksync2.core.types import ( ZkBlockParams, L2BridgeContracts, TransferTransaction, - TransactionOptions, WithdrawTransaction, - ADDRESS_DEFAULT, ) -from zksync2.core.utils import is_eth from zksync2.manage_contracts.deploy_addresses import ZkSyncAddresses from zksync2.manage_contracts.utils import ( zksync_abi_default, nonce_holder_abi_default, l2_bridge_abi_default, - get_erc20_abi, ) -from zksync2.module.request_types import EIP712Meta from zksync2.module.response_types import ZksAccountBalances from zksync2.signer.eth_signer import PrivateKeyEthSigner from zksync2.transaction.transaction712 import Transaction712 -from zksync2.transaction.transaction_builders import TxFunctionCall, TxWithdraw class WalletL2: @@ -83,8 +74,8 @@ def get_l2_bridge_contracts(self) -> L2BridgeContracts: address=Web3.to_checksum_address(addresses.erc20_l2_default_bridge), abi=l2_bridge_abi_default(), ), - weth=self._zksync_web3.eth.contract( - address=Web3.to_checksum_address(addresses.weth_bridge_l2), + shared=self._zksync_web3.eth.contract( + address=Web3.to_checksum_address(addresses.shared_l2_default_bridge), abi=l2_bridge_abi_default(), ), ) @@ -101,12 +92,11 @@ def transfer(self, tx: TransferTransaction) -> HexStr: tx_fun_call = self._zksync_web3.zksync.get_transfer_transaction( tx, self._l1_account.address ) - estimated_gas = self._zksync_web3.zksync.zks_estimate_gas_transfer( - tx_fun_call.tx - ) - tx_712 = tx_fun_call.tx712( - estimated_gas if tx.options.gas_limit == 0 else tx.options.gas_limit - ) + + if tx.options.gas_limit is None or tx.options.gas_limit == 0: + tx.options.gas_limit = self._zksync_web3.zksync.eth_estimate_gas(tx_fun_call.tx) + + tx_712 = tx_fun_call.tx712(tx.options.gas_limit) signer = PrivateKeyEthSigner(self._l1_account, tx.options.chain_id) signed_message = signer.sign_typed_data(tx_712.to_eip712_struct()) @@ -125,54 +115,15 @@ def withdraw(self, tx: WithdrawTransaction): Returns: - Withdrawal hash. """ - if tx.options is None: - tx.options = TransactionOptions() - if tx.options.chain_id is None: - tx.options.chain_id = self._zksync_web3.zksync.chain_id - if tx.options.nonce is None: - tx.options.nonce = self._zksync_web3.zksync.get_transaction_count( - Web3.to_checksum_address(self._l1_account.address), - ZkBlockParams.LATEST.value, - ) - if tx.options.gas_price is None: - tx.options.gas_price = self._zksync_web3.zksync.gas_price - - if not is_eth(tx.token): - if tx.bridge_address is None: - l2_weth_token = ADDRESS_DEFAULT - try: - l2_weth_token = ( - self.get_l2_bridge_contracts() - .weth.functions.l1TokenAddress(tx.token) - .call() - ) - except: - pass - if l2_weth_token == ADDRESS_DEFAULT: - tx.bridge_address = Web3.to_checksum_address( - self.get_l2_bridge_contracts().erc20.address - ) - else: - tx.bridge_address = Web3.to_checksum_address( - self.get_l2_bridge_contracts().weth.address - ) - - transaction = TxWithdraw( - web3=self._zksync_web3, - account=self._l1_account, - chain_id=tx.options.chain_id, - nonce=tx.options.nonce, - to=tx.to, - amount=tx.amount, - gas_limit=0 if tx.options.gas_limit is None else tx.options.gas_limit, - gas_price=tx.options.gas_price, - token=tx.token, - bridge_address=tx.bridge_address, - paymaster_params=tx.paymaster_params, + transaction = self._zksync_web3.zksync.get_withdraw_transaction( + tx, from_=self._l1_account.address ) - signer = PrivateKeyEthSigner(self._l1_account, tx.options.chain_id) - estimated_gas = self._zksync_web3.zksync.eth_estimate_gas(transaction.tx) - tx_712 = transaction.tx712(estimated_gas) + if tx.options.gas_limit is None: + transaction.tx['gas'] = self._zksync_web3.zksync.eth_estimate_gas(transaction.tx) + else: + transaction.tx['gas'] = tx.options.gas_limit + tx_712 = transaction.tx712() + signer = PrivateKeyEthSigner(self._l1_account, self._zksync_web3.eth.chain_id) signed_message = signer.sign_typed_data(tx_712.to_eip712_struct()) msg = tx_712.encode(signed_message) diff --git a/zksync2/core/types.py b/zksync2/core/types.py index e34c947..fadd7c3 100644 --- a/zksync2/core/types.py +++ b/zksync2/core/types.py @@ -20,6 +20,7 @@ class RecommendedGasLimit(IntEnum): ADDRESS_DEFAULT = HexStr("0x" + "0" * 40) +ETH_ADDRESS_IN_CONTRACTS = HexStr("0x0000000000000000000000000000000000000001") L2_ETH_TOKEN_ADDRESS = HexStr("0x000000000000000000000000000000000000800a") TokenAddress = NewType("token_address", HexStr) @@ -82,6 +83,8 @@ class Fee: @dataclass class BridgeAddresses: erc20_l1_default_bridge: HexStr + shared_l1_default_bridge: HexStr + shared_l2_default_bridge: HexStr erc20_l2_default_bridge: HexStr weth_bridge_l1: HexStr weth_bridge_l2: HexStr @@ -90,13 +93,14 @@ class BridgeAddresses: @dataclass class L1BridgeContracts: erc20: Contract + shared: Contract weth: Contract @dataclass class L2BridgeContracts: erc20: Contract - weth: Contract + shared: Contract @dataclass @@ -226,12 +230,15 @@ class DepositTransaction: operator_tip: int = 0 bridge_address: HexStr = None approve_erc20: bool = False + approve_base_erc20: bool = False l2_gas_limit: int = None gas_per_pubdata_byte: int = DEPOSIT_GAS_PER_PUBDATA_LIMIT custom_bridge_data: bytes = None refund_recipient: HexStr = None l2_value: int = 0 options: TransactionOptions = None + approve_options: TransactionOptions = None + approve_base_options: TransactionOptions = None @dataclass @@ -256,6 +263,7 @@ class RequestExecuteCallMsg: call_data: Union[bytes, HexStr] from_: HexStr = None l2_gas_limit: int = 0 + mint_value: int = 0 l2_value: int = 0 factory_deps: List[bytes] = None operator_tip: int = 0 diff --git a/zksync2/core/utils.py b/zksync2/core/utils.py index 556ef38..fbff44c 100644 --- a/zksync2/core/utils.py +++ b/zksync2/core/utils.py @@ -1,3 +1,4 @@ +import math import sys from enum import IntEnum from hashlib import sha256 @@ -12,13 +13,20 @@ ADDRESS_MODULO = pow(2, 160) L1_TO_L2_ALIAS_OFFSET = "0x1111000000000000000000000000000000001111" +ETH_ADDRESS_IN_CONTRACTS = "0x0000000000000000000000000000000000000001" + +LEGACY_ETH_ADDRESS = HexStr("0x" + "0" * 40) ADDRESS_DEFAULT = HexStr("0x" + "0" * 40) +L2_BASE_TOKEN_ADDRESS = HexStr("0x000000000000000000000000000000000000800a") L2_ETH_TOKEN_ADDRESS = HexStr("0x000000000000000000000000000000000000800a") BOOTLOADER_FORMAL_ADDRESS = HexStr("0x0000000000000000000000000000000000008001") DEPOSIT_GAS_PER_PUBDATA_LIMIT = 800 MAX_PRIORITY_FEE_PER_GAS = 100_000_000 +L1_FEE_ESTIMATION_COEF_NUMERATOR = 12 +L1_FEE_ESTIMATION_COEF_DENOMINATOR = 10 + def int_to_bytes(x: int) -> bytes: return x.to_bytes((x.bit_length() + 7) // 8, byteorder=sys.byteorder) @@ -31,7 +39,15 @@ def to_bytes(data: Union[bytes, HexStr]) -> bytes: def is_eth(address: HexStr) -> bool: - return address.lower() == ADDRESS_DEFAULT or address.lower() == L2_ETH_TOKEN_ADDRESS + return ( + address.lower() == LEGACY_ETH_ADDRESS + or address.lower() == L2_BASE_TOKEN_ADDRESS + or address.lower() == ETH_ADDRESS_IN_CONTRACTS + ) + + +def is_address_eq(a: HexStr, b: HexStr) -> bool: + return a.lower() == b.lower() def encode_address(addr: Union[Address, ChecksumAddress, str]) -> bytes: @@ -61,9 +77,23 @@ def pad_front_bytes(bs: bytes, needed_length: int): def get_custom_bridge_data(token_contract) -> bytes: - name = token_contract.functions.name().call() - symbol = token_contract.functions.symbol().call() - decimals = token_contract.functions.decimals().call() + address = token_contract.address + name = ( + "Ether" + if address.lower() == ETH_ADDRESS_IN_CONTRACTS.lower() + else token_contract.functions.name().call() + ) + symbol = ( + "ETH" + if address.lower() == ETH_ADDRESS_IN_CONTRACTS.lower() + else token_contract.functions.symbol().call() + ) + decimals = ( + 18 + if address.lower() == ETH_ADDRESS_IN_CONTRACTS.lower() + else token_contract.functions.decimals().call() + ) + name_encoded = encode(["string"], [name]) symbol_encoded = encode(["string"], [symbol]) decimals_encoded = encode(["uint256"], [decimals]) @@ -93,8 +123,11 @@ def undo_l1_to_l2_alias(address: HexStr): return Web3.to_hex(result) -class RequestExecuteTransaction: - pass +def scale_gas_limit(base_gas: int): + return math.trunc( + (base_gas * L1_FEE_ESTIMATION_COEF_NUMERATOR) + / L1_FEE_ESTIMATION_COEF_DENOMINATOR + ) class RecommendedGasLimit(IntEnum): diff --git a/zksync2/manage_contracts/contract_abi/ContractDeployer.json b/zksync2/manage_contracts/contract_abi/ContractDeployer.json deleted file mode 100644 index 4b0a5eb..0000000 --- a/zksync2/manage_contracts/contract_abi/ContractDeployer.json +++ /dev/null @@ -1,425 +0,0 @@ -{ - "abi": [ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "accountAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "enum IContractDeployer.AccountNonceOrdering", - "name": "nonceOrdering", - "type": "uint8" - } - ], - "name": "AccountNonceOrderingUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "accountAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "enum IContractDeployer.AccountAbstractionVersion", - "name": "aaVersion", - "type": "uint8" - } - ], - "name": "AccountVersionUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "deployerAddress", - "type": "address" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "bytecodeHash", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "contractAddress", - "type": "address" - } - ], - "name": "ContractDeployed", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "_salt", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "_bytecodeHash", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "_input", - "type": "bytes" - } - ], - "name": "create", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "_salt", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "_bytecodeHash", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "_input", - "type": "bytes" - } - ], - "name": "create2", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "_salt", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "_bytecodeHash", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "_input", - "type": "bytes" - }, - { - "internalType": "enum IContractDeployer.AccountAbstractionVersion", - "name": "_aaVersion", - "type": "uint8" - } - ], - "name": "create2Account", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "_bytecodeHash", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "_input", - "type": "bytes" - }, - { - "internalType": "enum IContractDeployer.AccountAbstractionVersion", - "name": "_aaVersion", - "type": "uint8" - } - ], - "name": "createAccount", - "outputs": [ - { - "internalType": "address", - "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": [ - { - "internalType": "bytes32", - "name": "_keccak256BytecodeHash", - "type": "bytes32" - } - ], - "name": "forceDeployKeccak256", - "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": "_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" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_address", - "type": "address" - } - ], - "name": "getAccountInfo", - "outputs": [ - { - "components": [ - { - "internalType": "enum IContractDeployer.AccountAbstractionVersion", - "name": "supportedAAVersion", - "type": "uint8" - }, - { - "internalType": "enum IContractDeployer.AccountNonceOrdering", - "name": "nonceOrdering", - "type": "uint8" - } - ], - "internalType": "struct IContractDeployer.AccountInfo", - "name": "info", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_sender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_senderNonce", - "type": "uint256" - } - ], - "name": "getNewAddressCreate", - "outputs": [ - { - "internalType": "address", - "name": "newAddress", - "type": "address" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_sender", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "_bytecodeHash", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "_salt", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "_input", - "type": "bytes" - } - ], - "name": "getNewAddressCreate2", - "outputs": [ - { - "internalType": "address", - "name": "newAddress", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "enum IContractDeployer.AccountAbstractionVersion", - "name": "_version", - "type": "uint8" - } - ], - "name": "updateAccountVersion", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "enum IContractDeployer.AccountNonceOrdering", - "name": "_nonceOrdering", - "type": "uint8" - } - ], - "name": "updateNonceOrdering", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } - ] -} \ No newline at end of file diff --git a/zksync2/manage_contracts/contract_abi/IBridgehub.json b/zksync2/manage_contracts/contract_abi/IBridgehub.json new file mode 100644 index 0000000..6cb2d4a --- /dev/null +++ b/zksync2/manage_contracts/contract_abi/IBridgehub.json @@ -0,0 +1,634 @@ +{ + "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" + } +] + +} \ No newline at end of file diff --git a/zksync2/manage_contracts/contract_abi/IContractDeployer.json b/zksync2/manage_contracts/contract_abi/IContractDeployer.json new file mode 100644 index 0000000..e8817d0 --- /dev/null +++ b/zksync2/manage_contracts/contract_abi/IContractDeployer.json @@ -0,0 +1,412 @@ +{ + "abi":[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "accountAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "enum IContractDeployer.AccountNonceOrdering", + "name": "nonceOrdering", + "type": "uint8" + } + ], + "name": "AccountNonceOrderingUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "accountAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "enum IContractDeployer.AccountAbstractionVersion", + "name": "aaVersion", + "type": "uint8" + } + ], + "name": "AccountVersionUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "deployerAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "bytecodeHash", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "contractAddress", + "type": "address" + } + ], + "name": "ContractDeployed", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_salt", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_bytecodeHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "_input", + "type": "bytes" + } + ], + "name": "create", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_salt", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_bytecodeHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "_input", + "type": "bytes" + } + ], + "name": "create2", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_salt", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_bytecodeHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "_input", + "type": "bytes" + }, + { + "internalType": "enum IContractDeployer.AccountAbstractionVersion", + "name": "_aaVersion", + "type": "uint8" + } + ], + "name": "create2Account", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_bytecodeHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "_input", + "type": "bytes" + }, + { + "internalType": "enum IContractDeployer.AccountAbstractionVersion", + "name": "_aaVersion", + "type": "uint8" + } + ], + "name": "createAccount", + "outputs": [ + { + "internalType": "address", + "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" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "getAccountInfo", + "outputs": [ + { + "components": [ + { + "internalType": "enum IContractDeployer.AccountAbstractionVersion", + "name": "supportedAAVersion", + "type": "uint8" + }, + { + "internalType": "enum IContractDeployer.AccountNonceOrdering", + "name": "nonceOrdering", + "type": "uint8" + } + ], + "internalType": "struct IContractDeployer.AccountInfo", + "name": "info", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_senderNonce", + "type": "uint256" + } + ], + "name": "getNewAddressCreate", + "outputs": [ + { + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_sender", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "_bytecodeHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_salt", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "_input", + "type": "bytes" + } + ], + "name": "getNewAddressCreate2", + "outputs": [ + { + "internalType": "address", + "name": "newAddress", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "enum IContractDeployer.AccountAbstractionVersion", + "name": "_version", + "type": "uint8" + } + ], + "name": "updateAccountVersion", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "enum IContractDeployer.AccountNonceOrdering", + "name": "_nonceOrdering", + "type": "uint8" + } + ], + "name": "updateNonceOrdering", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] +} \ No newline at end of file diff --git a/zksync2/manage_contracts/contract_abi/IERC1271.json b/zksync2/manage_contracts/contract_abi/IERC1271.json index 5e15311..84e7f51 100644 --- a/zksync2/manage_contracts/contract_abi/IERC1271.json +++ b/zksync2/manage_contracts/contract_abi/IERC1271.json @@ -1,28 +1,29 @@ { - "abi": [ - { - "inputs": [ - { - "internalType": "bytes32", - "name": "hash", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "signature", - "type": "bytes" - } - ], - "name": "isValidSignature", - "outputs": [ - { - "internalType": "bytes4", - "name": "magicValue", - "type": "bytes4" - } - ], - "stateMutability": "view", - "type": "function" - } - ] + "abi": [ + { + "inputs": [ + { + "internalType": "bytes32", + "name": "hash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "name": "isValidSignature", + "outputs": [ + { + "internalType": "bytes4", + "name": "magicValue", + "type": "bytes4" + } + ], + "stateMutability": "view", + "type": "function" + } +] + } \ No newline at end of file diff --git a/zksync2/manage_contracts/contract_abi/IERC20.json b/zksync2/manage_contracts/contract_abi/IERC20.json index 2fc7246..cc41b7b 100644 --- a/zksync2/manage_contracts/contract_abi/IERC20.json +++ b/zksync2/manage_contracts/contract_abi/IERC20.json @@ -1,226 +1,226 @@ { "abi": [ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } - ] -} + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } +] +} \ No newline at end of file diff --git a/zksync2/manage_contracts/contract_abi/IEthToken.json b/zksync2/manage_contracts/contract_abi/IEthToken.json index 4cb68cd..c4f2ae8 100644 --- a/zksync2/manage_contracts/contract_abi/IEthToken.json +++ b/zksync2/manage_contracts/contract_abi/IEthToken.json @@ -1,247 +1,247 @@ { - "abi": [ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "Mint", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_l2Sender", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "_l1Receiver", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "Withdrawal", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_l2Sender", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "_l1Receiver", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "_additionalData", - "type": "bytes" - } - ], - "name": "WithdrawalWithMessage", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_account", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "mint", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_from", - "type": "address" - }, - { - "internalType": "address", - "name": "_to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "transferFromTo", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_l1Receiver", - "type": "address" - } - ], - "name": "withdraw", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_l1Receiver", - "type": "address" - }, - { - "internalType": "bytes", - "name": "_additionalData", - "type": "bytes" - } - ], - "name": "withdrawWithMessage", - "outputs": [], - "stateMutability": "payable", - "type": "function" - } - ] + "abi":[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_l2Sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_l1Receiver", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "Withdrawal", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_l2Sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_l1Receiver", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "_additionalData", + "type": "bytes" + } + ], + "name": "WithdrawalWithMessage", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "transferFromTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_l1Receiver", + "type": "address" + } + ], + "name": "withdraw", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_l1Receiver", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_additionalData", + "type": "bytes" + } + ], + "name": "withdrawWithMessage", + "outputs": [], + "stateMutability": "payable", + "type": "function" + } +] } \ No newline at end of file diff --git a/zksync2/manage_contracts/contract_abi/IL1Bridge.json b/zksync2/manage_contracts/contract_abi/IL1Bridge.json index dd39bb0..d10d514 100644 --- a/zksync2/manage_contracts/contract_abi/IL1Bridge.json +++ b/zksync2/manage_contracts/contract_abi/IL1Bridge.json @@ -1,267 +1,514 @@ { "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" - }, - { - "internalType": "address", - "name": "_refundRecipient", - "type": "address" - } - ], - "name": "deposit", - "outputs": [ - { - "internalType": "bytes32", - "name": "txHash", - "type": "bytes32" - } - ], - "stateMutability": "payable", - "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" - } - ] + { + "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", + "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": "DepositInitiatedSharedBridge", + "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": "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": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_l2Receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "_l1Token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_mintValue", + "type": "uint256" + }, + { + "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": "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", + "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": "_chainId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2BatchNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_l2MessageIndex", + "type": "uint256" + } + ], + "name": "isWithdrawalFinalizedShared", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + } + ], + "name": "l2BridgeAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } +] } \ No newline at end of file diff --git a/zksync2/manage_contracts/contract_abi/IL1ERC20Bridge.json b/zksync2/manage_contracts/contract_abi/IL1ERC20Bridge.json new file mode 100644 index 0000000..e437e92 --- /dev/null +++ b/zksync2/manage_contracts/contract_abi/IL1ERC20Bridge.json @@ -0,0 +1,392 @@ +{ + "abi": [ + { + "inputs": [ + { + "internalType": "contract IL1SharedBridge", + "name": "_sharedBridge", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "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": "l2TxHash", + "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": "l2TxHash", + "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": "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": "finalizeWithdrawal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "l2BatchNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "l2ToL1MessageNumber", + "type": "uint256" + } + ], + "name": "isWithdrawalFinalized", + "outputs": [ + { + "internalType": "bool", + "name": "isFinalized", + "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": "l2TokenProxyBytecodeHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "sharedBridge", + "outputs": [ + { + "internalType": "contract IL1SharedBridge", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } +] +} \ No newline at end of file diff --git a/zksync2/manage_contracts/contract_abi/IL1Messenger.json b/zksync2/manage_contracts/contract_abi/IL1Messenger.json index 22412c0..3f1c24a 100644 --- a/zksync2/manage_contracts/contract_abi/IL1Messenger.json +++ b/zksync2/manage_contracts/contract_abi/IL1Messenger.json @@ -1,148 +1,149 @@ { "abi": [ - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "_bytecodeHash", - "type": "bytes32" - } - ], - "name": "BytecodeL1PublicationRequested", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "_sender", - "type": "address" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "_hash", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "_message", - "type": "bytes" - } - ], - "name": "L1MessageSent", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "components": [ - { - "internalType": "uint8", - "name": "l2ShardId", - "type": "uint8" - }, - { - "internalType": "bool", - "name": "isService", - "type": "bool" - }, - { - "internalType": "uint16", - "name": "txNumberInBlock", - "type": "uint16" - }, - { - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "key", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "value", - "type": "bytes32" - } - ], - "indexed": false, - "internalType": "struct L2ToL1Log", - "name": "_l2log", - "type": "tuple" - } - ], - "name": "L2ToL1LogSent", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "_bytecodeHash", - "type": "bytes32" - } - ], - "name": "requestBytecodeL1Publication", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bool", - "name": "_isService", - "type": "bool" - }, - { - "internalType": "bytes32", - "name": "_key", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "_value", - "type": "bytes32" - } - ], - "name": "sendL2ToL1Log", - "outputs": [ - { - "internalType": "uint256", - "name": "logIdInMerkleTree", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "_message", - "type": "bytes" - } - ], - "name": "sendToL1", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } - ] + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "_bytecodeHash", + "type": "bytes32" + } + ], + "name": "BytecodeL1PublicationRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "_hash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "_message", + "type": "bytes" + } + ], + "name": "L1MessageSent", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "uint8", + "name": "l2ShardId", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "isService", + "type": "bool" + }, + { + "internalType": "uint16", + "name": "txNumberInBlock", + "type": "uint16" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "key", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "value", + "type": "bytes32" + } + ], + "indexed": false, + "internalType": "struct L2ToL1Log", + "name": "_l2log", + "type": "tuple" + } + ], + "name": "L2ToL1LogSent", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_bytecodeHash", + "type": "bytes32" + } + ], + "name": "requestBytecodeL1Publication", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "_isService", + "type": "bool" + }, + { + "internalType": "bytes32", + "name": "_key", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_value", + "type": "bytes32" + } + ], + "name": "sendL2ToL1Log", + "outputs": [ + { + "internalType": "uint256", + "name": "logIdInMerkleTree", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "_message", + "type": "bytes" + } + ], + "name": "sendToL1", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } +] + } \ No newline at end of file diff --git a/zksync2/manage_contracts/contract_abi/IL1SharedBridge.json b/zksync2/manage_contracts/contract_abi/IL1SharedBridge.json new file mode 100644 index 0000000..9b526e2 --- /dev/null +++ b/zksync2/manage_contracts/contract_abi/IL1SharedBridge.json @@ -0,0 +1,695 @@ +{ + "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" + } +] + +} \ No newline at end of file diff --git a/zksync2/manage_contracts/contract_abi/IL2Bridge.json b/zksync2/manage_contracts/contract_abi/IL2Bridge.json index e1f8926..8af4158 100644 --- a/zksync2/manage_contracts/contract_abi/IL2Bridge.json +++ b/zksync2/manage_contracts/contract_abi/IL2Bridge.json @@ -108,4 +108,5 @@ "type": "function" } ] + } \ No newline at end of file diff --git a/zksync2/manage_contracts/contract_abi/INonceHolder.json b/zksync2/manage_contracts/contract_abi/INonceHolder.json index c9bdbef..1ee9c5c 100644 --- a/zksync2/manage_contracts/contract_abi/INonceHolder.json +++ b/zksync2/manage_contracts/contract_abi/INonceHolder.json @@ -216,4 +216,4 @@ "stateMutability": "view", "type": "function" } -] \ No newline at end of file +] diff --git a/zksync2/manage_contracts/contract_abi/IPaymasterFlow.json b/zksync2/manage_contracts/contract_abi/IPaymasterFlow.json index c78e121..4f12e74 100644 --- a/zksync2/manage_contracts/contract_abi/IPaymasterFlow.json +++ b/zksync2/manage_contracts/contract_abi/IPaymasterFlow.json @@ -1,40 +1,40 @@ { "abi": [ - { - "inputs": [ - { - "internalType": "address", - "name": "_token", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_minAllowance", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "_innerInput", - "type": "bytes" - } - ], - "name": "approvalBased", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "input", - "type": "bytes" - } - ], - "name": "general", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } - ] -} + { + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_minAllowance", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "_innerInput", + "type": "bytes" + } + ], + "name": "approvalBased", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "input", + "type": "bytes" + } + ], + "name": "general", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] +} \ No newline at end of file diff --git a/zksync2/manage_contracts/contract_abi/ITestnetERC20Token.json b/zksync2/manage_contracts/contract_abi/ITestnetERC20Token.json new file mode 100644 index 0000000..c7d4c07 --- /dev/null +++ b/zksync2/manage_contracts/contract_abi/ITestnetERC20Token.json @@ -0,0 +1,41 @@ +{ + "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" + } +] +} \ No newline at end of file diff --git a/zksync2/manage_contracts/contract_abi/IZkSyncStateTransition.json b/zksync2/manage_contracts/contract_abi/IZkSyncStateTransition.json new file mode 100644 index 0000000..19386e8 --- /dev/null +++ b/zksync2/manage_contracts/contract_abi/IZkSyncStateTransition.json @@ -0,0 +1,2406 @@ +{ + "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" + } +] + +} \ No newline at end of file diff --git a/zksync2/manage_contracts/utils.py b/zksync2/manage_contracts/utils.py index a1d4f78..9e726da 100644 --- a/zksync2/manage_contracts/utils.py +++ b/zksync2/manage_contracts/utils.py @@ -15,6 +15,8 @@ l1_bridge_abi_cache = None eth_token_abi_cache = None erc_20_abi_cache = None +eth_token_abi_cache = None +test_net_erc_20_abi_cache = None def zksync_abi_default(): @@ -32,7 +34,7 @@ def icontract_deployer_abi_default(): global icontract_deployer_abi_cache if icontract_deployer_abi_cache is None: - with pkg_resources.path(contract_abi, "ContractDeployer.json") as p: + with pkg_resources.path(contract_abi, "IContractDeployer.json") as p: with p.open(mode="r") as json_file: data = json.load(json_file) icontract_deployer_abi_cache = data["abi"] @@ -82,6 +84,28 @@ def l1_bridge_abi_default(): return l1_bridge_abi_cache +def bridgehub_abi_default(): + global l1_bridge_abi_cache + + if l1_bridge_abi_cache is None: + with pkg_resources.path(contract_abi, "IBridgehub.json") as p: + with p.open(mode="r") as json_file: + data = json.load(json_file) + l1_bridge_abi_cache = data["abi"] + return l1_bridge_abi_cache + + +def l1_shared_bridge_abi_default(): + global l1_bridge_abi_cache + + if l1_bridge_abi_cache is None: + with pkg_resources.path(contract_abi, "IL1SharedBridge.json") as p: + with p.open(mode="r") as json_file: + data = json.load(json_file) + l1_bridge_abi_cache = data["abi"] + return l1_bridge_abi_cache + + def eth_token_abi_default(): global eth_token_abi_cache @@ -89,8 +113,8 @@ def eth_token_abi_default(): with pkg_resources.path(contract_abi, "IEthToken.json") as p: with p.open(mode="r") as json_file: data = json.load(json_file) - erc_20_abi_cache = data["abi"] - return erc_20_abi_cache + eth_token_abi_cache = data["abi"] + return eth_token_abi_cache def get_erc20_abi(): @@ -104,6 +128,17 @@ def get_erc20_abi(): return erc_20_abi_cache +def get_test_net_erc20_token(): + global test_net_erc_20_abi_cache + + if test_net_erc_20_abi_cache is None: + with pkg_resources.path(contract_abi, "ITestnetERC20Token.json") as p: + with p.open(mode="r") as json_file: + data = json.load(json_file) + test_net_erc_20_abi_cache = data["abi"] + return test_net_erc_20_abi_cache + + class ERC20Encoder(BaseContractEncoder): def __init__(self, web3: Web3, abi: Optional[dict] = None): if abi is None: diff --git a/zksync2/module/response_types.py b/zksync2/module/response_types.py index d29bbc3..1042c51 100644 --- a/zksync2/module/response_types.py +++ b/zksync2/module/response_types.py @@ -113,6 +113,7 @@ ZksL1ChainId = NewType("ZksL1ChainId", int) ZksL1BatchNumber = NewType("ZksL1BatchNumber", int) ZksMainContract = HexStr +ZksBaseToken = HexStr ZksSetContractDebugInfoResult = NewType("ZksSetContractDebugInfoResult", bool) ZksTokenPrice = NewType("ZksTokenPrice", Decimal) ZksTokens = NewType("ZksTokens", List[Token]) diff --git a/zksync2/module/zksync_module.py b/zksync2/module/zksync_module.py index 4768396..2047cff 100644 --- a/zksync2/module/zksync_module.py +++ b/zksync2/module/zksync_module.py @@ -50,8 +50,16 @@ WithdrawTransaction, ContractAccountInfo, StorageProof, + ETH_ADDRESS_IN_CONTRACTS, +) +from zksync2.core.utils import ( + is_eth, + MAX_PRIORITY_FEE_PER_GAS, + LEGACY_ETH_ADDRESS, + L2_BASE_TOKEN_ADDRESS, + is_address_eq, + BOOTLOADER_FORMAL_ADDRESS, ) -from zksync2.core.utils import is_eth, MAX_PRIORITY_FEE_PER_GAS from zksync2.manage_contracts.deploy_addresses import ZkSyncAddresses from zksync2.manage_contracts.utils import ( ERC20Encoder, @@ -91,6 +99,8 @@ zks_get_l2_to_l1_msg_proof_prc = RPCEndpoint("zks_getL2ToL1MsgProof") zks_get_l2_to_l1_log_proof_prc = RPCEndpoint("zks_getL2ToL1LogProof") zks_get_proof_rpc = RPCEndpoint("zks_getProof") +zks_get_base_token_l1_address_rpc = RPCEndpoint("zks_getBaseTokenL1Address") +zks_get_bridgehub_contract_rpc = RPCEndpoint("zks_getBridgehubContract") eth_estimate_gas_rpc = RPCEndpoint("eth_estimateGas") eth_get_transaction_receipt_rpc = RPCEndpoint("eth_getTransactionReceipt") eth_get_transaction_by_hash_rpc = RPCEndpoint("eth_getTransactionByHash") @@ -167,6 +177,12 @@ def to_token(t: dict) -> Token: def to_bridge_address(t: dict) -> BridgeAddresses: return BridgeAddresses( erc20_l1_default_bridge=HexStr(to_checksum_address(t["l1Erc20DefaultBridge"])), + shared_l1_default_bridge=HexStr( + to_checksum_address(t["l1SharedDefaultBridge"]) + ), + shared_l2_default_bridge=HexStr( + to_checksum_address(t["l2SharedDefaultBridge"]) + ), erc20_l2_default_bridge=HexStr(to_checksum_address(t["l2Erc20DefaultBridge"])), weth_bridge_l1=HexStr(to_checksum_address(t["l1WethBridge"])), weth_bridge_l2=HexStr(to_checksum_address(t["l2WethBridge"])), @@ -392,6 +408,10 @@ class ZkSync(Eth, ABC): zks_main_contract_rpc, mungers=None ) + _zks_get_base_token_contract_address: Method[Callable[[], ZksBaseToken]] = Method( + zks_get_base_token_l1_address_rpc, mungers=None + ) + _zks_get_token_price: Method[Callable[[TokenAddress], ZksTokenPrice]] = Method( zks_get_token_price_rpc, mungers=[default_root_munger] ) @@ -423,6 +443,13 @@ class ZkSync(Eth, ABC): result_formatters=zksync_get_result_formatters, ) + _zks_get_bridgehub_contract_address: Method[ + Callable[[int, Address, str, Optional[int]], ZksMessageProof] + ] = Method( + zks_get_bridgehub_contract_rpc, + mungers=[default_root_munger], + ) + _zks_get_l2_to_l1_log_proof: Method[ Callable[[Address, Optional[int]], ZksMessageProof] ] = Method( @@ -468,7 +495,9 @@ class ZkSync(Eth, ABC): def __init__(self, web3: "Web3"): super(ZkSync, self).__init__(web3) self.main_contract_address = None + self.bridgehub_contract_address = None self.bridge_addresses = None + self.base_token = None def zks_l1_batch_number(self) -> int: return int(self._zks_l1_batch_number(), 16) @@ -521,6 +550,22 @@ def zks_main_contract(self) -> HexStr: self.main_contract_address = self._zks_main_contract() return self.main_contract_address + def zks_get_base_token_contract_address(self): + """Returns the L1 base token address.""" + if self.base_token is None: + self.base_token = self._zks_get_base_token_contract_address() + return self.base_token + + def is_eth_based_chain(self) -> bool: + return is_address_eq( + self.zks_get_base_token_contract_address(), ETH_ADDRESS_IN_CONTRACTS + ) + + def zks_get_bridgehub_contract_address(self) -> HexStr: + if self.bridgehub_contract_address is None: + self.bridgehub_contract_address = self._zks_get_bridgehub_contract_address() + return self.bridgehub_contract_address + def zks_get_token_price(self, token_address: TokenAddress) -> Decimal: return self._zks_get_token_price(token_address) @@ -544,49 +589,49 @@ def zks_get_balance( except: return 0 + def is_base_token(self, token: HexStr): + return is_address_eq( + token, self.zks_get_base_token_contract_address() + ) or is_address_eq(token, L2_BASE_TOKEN_ADDRESS) + def l1_token_address(self, token: HexStr) -> HexStr: - if is_eth(token): - return ADDRESS_DEFAULT - bridge_address = self.zks_get_bridge_contracts() - l2_weth_bridge = self.contract( - Web3.to_checksum_address(bridge_address.weth_bridge_l2), - abi=l2_bridge_abi_default(), - ) - try: - l1_weth_token = l2_weth_bridge.functions.l1TokenAddress(token).call() - if not is_eth(l1_weth_token): - return l1_weth_token - except: - pass + """ + Returns the L1 token address equivalent for a L2 token address as they are not equal. + ETH address is set to zero address. - erc20_bridge = self.contract( - Web3.to_checksum_address(bridge_address.erc20_l2_default_bridge), + :param token: The address of the token on L2. + """ + if token == LEGACY_ETH_ADDRESS: + return LEGACY_ETH_ADDRESS + + bridge_address = self.zks_get_bridge_contracts() + shared_bridge = self.contract( + Web3.to_checksum_address(bridge_address.shared_l2_default_bridge), abi=l2_bridge_abi_default(), ) - return erc20_bridge.functions.l1TokenAddress(token).call() + return shared_bridge.functions.l1TokenAddress(token).call() def l2_token_address(self, token: HexStr) -> HexStr: - if is_eth(token): - return ADDRESS_DEFAULT - bridge_address = self.zks_get_bridge_contracts() - l2_weth_bridge = self.contract( - Web3.to_checksum_address(bridge_address.weth_bridge_l2), - abi=l2_bridge_abi_default(), - ) - try: - l1_weth_token = l2_weth_bridge.functions.l2TokenAddress(token).call() - if not is_eth(l1_weth_token): - return l1_weth_token - except: - pass + """ + Returns the L2 token address equivalent for a L1 token address as they are not equal. + ETH address is set to zero address. + + :param token: The address of the token on L1. + """ + if token == ADDRESS_DEFAULT: + token = ETH_ADDRESS_IN_CONTRACTS + base_token = self.zks_get_base_token_contract_address() + if token == base_token: + return L2_BASE_TOKEN_ADDRESS - erc20_bridge = self.contract( - Web3.to_checksum_address(bridge_address.erc20_l2_default_bridge), + bridge_address = self.zks_get_bridge_contracts() + l2_shared_bridge = self.contract( + Web3.to_checksum_address(bridge_address.shared_l2_default_bridge), abi=l2_bridge_abi_default(), ) - return erc20_bridge.functions.l2TokenAddress(token).call() + return l2_shared_bridge.functions.l2TokenAddress(token).call() def zks_get_all_account_balances(self, addr: Address) -> ZksAccountBalances: return self._zks_get_all_account_balances(addr) @@ -629,6 +674,27 @@ def get_l2_transaction_from_priority_op(self, tx_receipt, main_contract: Contrac self.wait_for_transaction_receipt(l2_hash) return self.get_transaction(l2_hash) + def _get_priority_op_confirmation_l2_to_l1_log( + self, tx_hash: HexStr, index: int = 0 + ): + receipt = self.eth_get_transaction_receipt(tx_hash) + msgs = [] + for i, e in enumerate(receipt.l2_to_l1_logs): + if e.sender.lower() == BOOTLOADER_FORMAL_ADDRESS: + msgs.append((i, e)) + + l2_to_l1_log_index, log = msgs[index] + + return l2_to_l1_log_index, log, receipt.l1_batch_tx_index + + def get_priority_op_confirmation(self, tx_hash: HexStr, index: int = 0): + l2_to_l1_log_index, log, l1_batch_tx_index = ( + self._get_priority_op_confirmation_l2_to_l1_log(tx_hash, index) + ) + proof = self.zks_get_log_proof(tx_hash, l2_to_l1_log_index) + + return log.l1_batch_number, proof.id, l1_batch_tx_index, proof.proof + def wait_for_transaction_receipt( self, transaction_hash: _Hash32, timeout: float = 120, poll_latency: float = 0.1 ) -> TxReceipt: @@ -679,28 +745,32 @@ def get_withdraw_transaction( tx: WithdrawTransaction, from_: HexStr, ) -> TxWithdraw: + is_eth_based_chain = self.is_eth_based_chain() + + if ( + tx.token is not None + and is_address_eq(tx.token, LEGACY_ETH_ADDRESS) + and not is_eth_based_chain + ): + tx.token = self.l2_token_address(ETH_ADDRESS_IN_CONTRACTS) + elif tx.token is None or self.is_base_token(tx.token): + tx.token = L2_BASE_TOKEN_ADDRESS if tx.options is None: tx.options = TransactionOptions() - if tx.options.chain_id is None: - tx.options.chain_id = self.chain_id - if tx.options.nonce is None: - tx.options.nonce = self.get_transaction_count( - Web3.to_checksum_address(from_), ZkBlockParams.LATEST.value - ) - if tx.options.gas_price is None: - tx.options.gas_price = self.gas_price - if tx.options.gas_limit is None: - tx.options.gas_limit = 0 transaction = TxWithdraw( + web3=self, chain_id=tx.options.chain_id, nonce=tx.options.nonce, to=tx.to, amount=tx.amount, gas_limit=tx.options.gas_limit, - gas_price=tx.options.gas_price, + max_fee_per_gas=tx.options.max_fee_per_gas, + max_priority_fee_per_gas=tx.options.max_priority_fee_per_gas, token=tx.token, bridge_address=tx.bridge_address, + from_=from_, + paymaster_params=tx.paymaster_params ) return transaction @@ -708,6 +778,17 @@ def get_withdraw_transaction( def get_transfer_transaction( self, tx: TransferTransaction, from_: HexStr ) -> TxTransfer: + is_eth_based_chain = self.is_eth_based_chain() + + if ( + tx.token_address is not None + and is_address_eq(tx.token_address, LEGACY_ETH_ADDRESS) + and not is_eth_based_chain + ): + tx.token_address = self.l2_token_address(ETH_ADDRESS_IN_CONTRACTS) + elif tx.token_address is None or self.is_base_token(tx.token_address): + tx.token_address = L2_BASE_TOKEN_ADDRESS + if tx.options is None: tx.options = TransactionOptions() if tx.options.chain_id is None: diff --git a/zksync2/transaction/transaction_builders.py b/zksync2/transaction/transaction_builders.py index 48d35b4..d390449 100644 --- a/zksync2/transaction/transaction_builders.py +++ b/zksync2/transaction/transaction_builders.py @@ -7,7 +7,7 @@ from web3.types import Nonce from zksync2.core.types import Token, BridgeAddresses, TransactionOptions -from zksync2.core.utils import is_eth, MAX_PRIORITY_FEE_PER_GAS +from zksync2.core.utils import is_eth, MAX_PRIORITY_FEE_PER_GAS, L2_BASE_TOKEN_ADDRESS from zksync2.manage_contracts.deploy_addresses import ZkSyncAddresses from zksync2.manage_contracts.precompute_contract_deployer import ( PrecomputeContractDeployer, @@ -298,9 +298,11 @@ def __init__( web3: Web3, token: HexStr, amount: int, - gas_limit: int, - account: BaseAccount, - gas_price: int = None, + gas_limit: int = 0, + account: BaseAccount = None, + from_: HexStr = None, + max_fee_per_gas: int = 0, + max_priority_fee_per_gas: int = 0, to: HexStr = None, bridge_address: HexStr = None, chain_id: int = None, @@ -308,12 +310,18 @@ def __init__( paymaster_params=None, ): # INFO: send to self + if from_ is None: + from_ = account.address if to is None: - to = account.address - if gas_price is None: - gas_price = web3.zksync.gas_price + to = from_ + if max_priority_fee_per_gas is None: + max_priority_fee_per_gas = 0 + if max_fee_per_gas is None: + max_fee_per_gas = web3.max_priority_fee if nonce is None: - web3.zksync.get_transaction_count(account.address) + nonce = web3.get_transaction_count(from_) + if chain_id is None: + chain_id = web3.chain_id eip712_meta = EIP712Meta( gas_per_pub_data=50000, @@ -323,50 +331,58 @@ def __init__( ) if is_eth(token): - if chain_id is None: - chain_id = web3.zksync.chain_id - contract = web3.zksync.contract( - Web3.to_checksum_address(L2_ETH_TOKEN_ADDRESS), + contract = web3.contract( + Web3.to_checksum_address(L2_BASE_TOKEN_ADDRESS), abi=eth_token_abi_default(), ) tx = contract.functions.withdraw(to).build_transaction( { "nonce": nonce, "chainId": chain_id, - "gas": gas_limit, - "gasPrice": gas_price, + "maxFeePerGas": max_fee_per_gas, + "maxPriorityFeePerGas": max_priority_fee_per_gas, "value": amount, - "from": account.address, + "from": from_, } ) else: - l2_bridge = web3.eth.contract( + if bridge_address is None: + bridge_address = ( + web3.zks_get_bridge_contracts().shared_l2_default_bridge + ) + l2_bridge = web3.contract( address=Web3.to_checksum_address(bridge_address), abi=l2_bridge_abi_default(), ) + options = TransactionOptions( + nonce=nonce, + chain_id=chain_id, + gas_limit=gas_limit, + max_fee_per_gas=max_fee_per_gas, + max_priority_fee_per_gas=max_priority_fee_per_gas, + value=0, + ) tx = l2_bridge.functions.withdraw(to, token, amount).build_transaction( { "nonce": nonce, "chainId": chain_id, - "gas": gas_limit, - "gasPrice": gas_price, "value": 0, - "from": account.address, + "from": from_, } ) tx["eip712Meta"] = eip712_meta super(TxWithdraw, self).__init__(trans=tx) - def tx712(self, estimated_gas: int) -> Transaction712: + def tx712(self, estimated_gas: int = None) -> Transaction712: return Transaction712( chain_id=self.tx["chainId"], nonce=Nonce(self.tx["nonce"]), - gas_limit=estimated_gas, + gas_limit=estimated_gas or self.tx["gas"], to=self.tx["to"], value=self.tx["value"], data=self.tx["data"], - maxPriorityFeePerGas=0, - maxFeePerGas=self.tx["gasPrice"], + maxPriorityFeePerGas=self.tx["maxPriorityFeePerGas"], + maxFeePerGas=self.tx["maxFeePerGas"], from_=self.tx["from"], meta=self.tx["eip712Meta"], ) From 4fd9652284be0cd22c87170f5f869e25d8ce162d Mon Sep 17 00:00:00 2001 From: petarTxFusion Date: Thu, 6 Jun 2024 01:29:32 +0200 Subject: [PATCH 02/15] test: fix test setup --- scripts/setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/setup.py b/scripts/setup.py index 6a056ee..f252dff 100644 --- a/scripts/setup.py +++ b/scripts/setup.py @@ -21,8 +21,8 @@ def main(): from zksync2.module.module_builder import ZkSyncBuilder from zksync2.signer.eth_signer import PrivateKeyEthSigner - zksync = ZkSyncBuilder.build("http://127.0.0.1:15100") - eth_web3 = Web3(Web3.HTTPProvider("http://127.0.0.1:15045")) + zksync = ZkSyncBuilder.build("http://127.0.0.1:3050") + eth_web3 = Web3(Web3.HTTPProvider("http://127.0.0.1:8545")) account: LocalAccount = Account.from_key( "0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110" ) From bcb417f0683681c6342672ec7f9c33b7eb2fbf92 Mon Sep 17 00:00:00 2001 From: petarTxFusion Date: Thu, 6 Jun 2024 08:12:48 +0200 Subject: [PATCH 03/15] test: fix setup test --- .github/workflows/test.yml | 2 +- scripts/setup.py | 4 ++-- tests/integration/test_config.py | 2 +- tests/integration/test_wallet.py | 4 ++-- zksync2/account/wallet_l1.py | 8 +------- 5 files changed, 7 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ee7ad79..444c643 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,7 +30,7 @@ jobs: run: | git clone https://github.com/matter-labs/local-setup.git pushd local-setup - ./start.sh + ./start-zk-chains.sh popd - name: Prepare environment run: make prepare-environment diff --git a/scripts/setup.py b/scripts/setup.py index f252dff..6a056ee 100644 --- a/scripts/setup.py +++ b/scripts/setup.py @@ -21,8 +21,8 @@ def main(): from zksync2.module.module_builder import ZkSyncBuilder from zksync2.signer.eth_signer import PrivateKeyEthSigner - zksync = ZkSyncBuilder.build("http://127.0.0.1:3050") - eth_web3 = Web3(Web3.HTTPProvider("http://127.0.0.1:8545")) + zksync = ZkSyncBuilder.build("http://127.0.0.1:15100") + eth_web3 = Web3(Web3.HTTPProvider("http://127.0.0.1:15045")) account: LocalAccount = Account.from_key( "0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110" ) diff --git a/tests/integration/test_config.py b/tests/integration/test_config.py index a47fe5e..ba0bd00 100644 --- a/tests/integration/test_config.py +++ b/tests/integration/test_config.py @@ -31,5 +31,5 @@ class TestEnvironment: LOCAL_ENV = TestEnvironment( - EnvType.LOCAL_HOST, "http://localhost:3050", "http://127.0.0.1:8545" + EnvType.LOCAL_HOST, "http://localhost:15100", "http://127.0.0.1:15045" ) diff --git a/tests/integration/test_wallet.py b/tests/integration/test_wallet.py index 0429816..280c778 100644 --- a/tests/integration/test_wallet.py +++ b/tests/integration/test_wallet.py @@ -52,8 +52,8 @@ def setUp(self) -> None: self.CONTRACT_ADDRESS = "0x36615Cf349d7F6344891B1e7CA7C72883F5dc049" self.env = LOCAL_ENV env_key = EnvPrivateKey("ZKSYNC_KEY1") - self.zksync = ZkSyncBuilder.build("http://127.0.0.1:3050") - self.eth_web3 = Web3(Web3.HTTPProvider("http://127.0.0.1:8545")) + self.zksync = ZkSyncBuilder.build("http://127.0.0.1:15100") + self.eth_web3 = Web3(Web3.HTTPProvider("http://127.0.0.1:15045")) self.account: LocalAccount = Account.from_key(env_key.key) self.wallet = Wallet(self.zksync, self.eth_web3, self.account) self.zksync_contract = self.eth_web3.eth.contract( diff --git a/zksync2/account/wallet_l1.py b/zksync2/account/wallet_l1.py index a62bb13..b0c5d86 100644 --- a/zksync2/account/wallet_l1.py +++ b/zksync2/account/wallet_l1.py @@ -1177,11 +1177,6 @@ def is_withdrawal_finalized(self, withdraw_hash, index: int = 0): hex_hash, l2_to_l1_log_index ) - options = TransactionOptions( - chain_id=self._eth_web3.eth.chain_id, - nonce=self._eth_web3.eth.get_transaction_count(self.address), - ) - l1_bridge: Contract if self._zksync_web3.zksync.is_base_token(sender): l1_bridge = self.get_l1_bridge_contracts().shared @@ -1194,10 +1189,9 @@ def is_withdrawal_finalized(self, withdraw_hash, index: int = 0): abi=l1_shared_bridge_abi_default(), ) - a = l1_bridge.functions.isWithdrawalFinalized( + return l1_bridge.functions.isWithdrawalFinalizedShared( self._zksync_web3.eth.chain_id, int(log["l1BatchNumber"], 16), proof.id ).call() - return a def request_execute(self, transaction: RequestExecuteCallMsg): """ From 00d973035b01701f7762201fdda270eb29f6786c Mon Sep 17 00:00:00 2001 From: petarTxFusion Date: Thu, 6 Jun 2024 08:22:33 +0200 Subject: [PATCH 04/15] test: remove wait script --- Makefile | 5 +---- scripts/wait.py | 41 ----------------------------------------- 2 files changed, 1 insertion(+), 45 deletions(-) delete mode 100644 scripts/wait.py diff --git a/Makefile b/Makefile index 8a08912..8c1ae61 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,4 @@ check-code-format: black --check zksync2 scripts tests format-code: - black zksync2 scripts tests - -wait: - python scripts/wait.py \ No newline at end of file + black zksync2 scripts tests \ No newline at end of file diff --git a/scripts/wait.py b/scripts/wait.py deleted file mode 100644 index b37ce30..0000000 --- a/scripts/wait.py +++ /dev/null @@ -1,41 +0,0 @@ -# Waiting for local setup to be ready - - -import time - -import os -import sys - - -def is_node_ready(w3): - try: - w3.zksync.get_block_number() - return True - except Exception as _: - return False - - -def wait_for_node(): - print("Waiting for node to be ready") - from zksync2.module.module_builder import ZkSyncBuilder - - max_attempts = 30 - w3 = ZkSyncBuilder.build("http://localhost:3050") - - for i in range(max_attempts): - if is_node_ready(w3): - print("Node is ready") - return - time.sleep(20) - raise Exception("Maximum retries exceeded.") - - -if __name__ == "__main__": - current_directory = os.path.dirname(os.path.abspath(__file__)) - parent_directory = os.path.join(current_directory, "..") - sys.path.append(parent_directory) - try: - wait_for_node() - except Exception as e: - print(f"Error: {e}") - sys.path.remove(parent_directory) From 05b471a5f672c7b15eb1213ffc5132c5ad48ed6c Mon Sep 17 00:00:00 2001 From: petarTxFusion Date: Thu, 6 Jun 2024 08:45:17 +0200 Subject: [PATCH 05/15] fix: fix abi contract cache --- tests/integration/test_config.py | 2 +- tests/integration/test_wallet.py | 4 ++-- zksync2/account/wallet_l1.py | 3 ++- zksync2/manage_contracts/utils.py | 18 ++++++++++-------- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/tests/integration/test_config.py b/tests/integration/test_config.py index ba0bd00..a47fe5e 100644 --- a/tests/integration/test_config.py +++ b/tests/integration/test_config.py @@ -31,5 +31,5 @@ class TestEnvironment: LOCAL_ENV = TestEnvironment( - EnvType.LOCAL_HOST, "http://localhost:15100", "http://127.0.0.1:15045" + EnvType.LOCAL_HOST, "http://localhost:3050", "http://127.0.0.1:8545" ) diff --git a/tests/integration/test_wallet.py b/tests/integration/test_wallet.py index 280c778..0429816 100644 --- a/tests/integration/test_wallet.py +++ b/tests/integration/test_wallet.py @@ -52,8 +52,8 @@ def setUp(self) -> None: self.CONTRACT_ADDRESS = "0x36615Cf349d7F6344891B1e7CA7C72883F5dc049" self.env = LOCAL_ENV env_key = EnvPrivateKey("ZKSYNC_KEY1") - self.zksync = ZkSyncBuilder.build("http://127.0.0.1:15100") - self.eth_web3 = Web3(Web3.HTTPProvider("http://127.0.0.1:15045")) + self.zksync = ZkSyncBuilder.build("http://127.0.0.1:3050") + self.eth_web3 = Web3(Web3.HTTPProvider("http://127.0.0.1:8545")) self.account: LocalAccount = Account.from_key(env_key.key) self.wallet = Wallet(self.zksync, self.eth_web3, self.account) self.zksync_contract = self.eth_web3.eth.contract( diff --git a/zksync2/account/wallet_l1.py b/zksync2/account/wallet_l1.py index b0c5d86..e61d907 100644 --- a/zksync2/account/wallet_l1.py +++ b/zksync2/account/wallet_l1.py @@ -1147,7 +1147,8 @@ def finalize_withdrawal(self, withdraw_hash, index: int = 0): nonce=self._eth_web3.eth.get_transaction_count(self.address), ) - shared_bridge = self.get_l1_bridge_contracts().shared + shared_bridge_address = self._zksync_web3.zksync.zks_get_bridge_contracts().shared_l1_default_bridge + shared_bridge = self._eth_web3.eth.contract(address=shared_bridge_address, abi=l1_shared_bridge_abi_default()) tx = shared_bridge.functions.finalizeWithdrawal( self._zksync_web3.eth.chain_id, params["l1_batch_number"], diff --git a/zksync2/manage_contracts/utils.py b/zksync2/manage_contracts/utils.py index 9e726da..b311fc0 100644 --- a/zksync2/manage_contracts/utils.py +++ b/zksync2/manage_contracts/utils.py @@ -17,6 +17,8 @@ erc_20_abi_cache = None eth_token_abi_cache = None test_net_erc_20_abi_cache = None +l1_shared_bridge_abi_cache = None +bridgehub_abi_cache = None def zksync_abi_default(): @@ -85,25 +87,25 @@ def l1_bridge_abi_default(): def bridgehub_abi_default(): - global l1_bridge_abi_cache + global bridgehub_abi_cache - if l1_bridge_abi_cache is None: + if bridgehub_abi_cache is None: with pkg_resources.path(contract_abi, "IBridgehub.json") as p: with p.open(mode="r") as json_file: data = json.load(json_file) - l1_bridge_abi_cache = data["abi"] - return l1_bridge_abi_cache + bridgehub_abi_cache = data["abi"] + return bridgehub_abi_cache def l1_shared_bridge_abi_default(): - global l1_bridge_abi_cache + global l1_shared_bridge_abi_cache - if l1_bridge_abi_cache is None: + if l1_shared_bridge_abi_cache is None: with pkg_resources.path(contract_abi, "IL1SharedBridge.json") as p: with p.open(mode="r") as json_file: data = json.load(json_file) - l1_bridge_abi_cache = data["abi"] - return l1_bridge_abi_cache + l1_shared_bridge_abi_cache = data["abi"] + return l1_shared_bridge_abi_cache def eth_token_abi_default(): From eb3834d8d87a7f3ab8cbde607bddd74e4b10d0d3 Mon Sep 17 00:00:00 2001 From: petarTxFusion Date: Thu, 6 Jun 2024 08:46:39 +0200 Subject: [PATCH 06/15] chore: lint code --- tests/integration/test_wallet.py | 17 +++++++++++------ tests/integration/test_zksync_web3.py | 8 ++++++-- zksync2/account/wallet_l1.py | 10 +++++++--- zksync2/account/wallet_l2.py | 10 +++++++--- zksync2/module/zksync_module.py | 2 +- 5 files changed, 32 insertions(+), 15 deletions(-) diff --git a/tests/integration/test_wallet.py b/tests/integration/test_wallet.py index 0429816..07b1708 100644 --- a/tests/integration/test_wallet.py +++ b/tests/integration/test_wallet.py @@ -187,7 +187,10 @@ def test_prepare_deposit_transaction_token(self): transaction = self.wallet.prepare_deposit_tx( DepositTransaction( - token=l1_address, amount=5, refund_recipient=self.wallet.address, approve_erc20=True + token=l1_address, + amount=5, + refund_recipient=self.wallet.address, + approve_erc20=True, ) ) @@ -805,7 +808,9 @@ def test_withdraw_eth_paymaster(self): paymaster_balance_before = self.zksync.zksync.zks_get_balance(paymaster_address) paymaster_token_balance_before = self.zksync.zksync.zks_get_balance( - paymaster_address, token_address=token_address, block_tag=ZkBlockParams.LATEST + paymaster_address, + token_address=token_address, + block_tag=ZkBlockParams.LATEST, ) sender_balance_before = self.wallet.get_balance() @@ -846,7 +851,9 @@ def test_withdraw_eth_paymaster(self): ) paymaster_balance_after = self.zksync.zksync.zks_get_balance(paymaster_address) paymaster_token_balance_after = self.zksync.zksync.zks_get_balance( - paymaster_address, token_address=token_address, block_tag=ZkBlockParams.LATEST + paymaster_address, + token_address=token_address, + block_tag=ZkBlockParams.LATEST, ) sender_balance_after = self.wallet.get_balance() sender_approval_token_balance_after = self.wallet.get_balance( @@ -857,9 +864,7 @@ def test_withdraw_eth_paymaster(self): self.assertEqual( paymaster_token_balance_after - paymaster_token_balance_before, 1 ) - self.assertEqual( - sender_balance_before - sender_balance_after, amount - ) + self.assertEqual(sender_balance_before - sender_balance_after, amount) self.assertEqual( sender_approval_token_balance_after, sender_approval_token_balance_before - 1, diff --git a/tests/integration/test_zksync_web3.py b/tests/integration/test_zksync_web3.py index ffbd011..6cb6e7d 100644 --- a/tests/integration/test_zksync_web3.py +++ b/tests/integration/test_zksync_web3.py @@ -19,7 +19,12 @@ ADDRESS_DEFAULT, StorageProof, ) -from zksync2.core.utils import pad_front_bytes, to_bytes, pad_back_bytes, L2_BASE_TOKEN_ADDRESS +from zksync2.core.utils import ( + pad_front_bytes, + to_bytes, + pad_back_bytes, + L2_BASE_TOKEN_ADDRESS, +) from zksync2.manage_contracts.contract_encoder_base import ( ContractEncoder, JsonConfiguration, @@ -768,7 +773,6 @@ def test_contract_factory(self): def test_get_all_account_balances(self): balances = self.web3.zksync.zks_get_all_account_balances(self.account.address) - # @skip("Integration test, used for develop purposes only") def test_get_l1_chain_id(self): self.assertIsInstance(self.web3.zksync.zks_l1_chain_id(), int) diff --git a/zksync2/account/wallet_l1.py b/zksync2/account/wallet_l1.py index e61d907..747c493 100644 --- a/zksync2/account/wallet_l1.py +++ b/zksync2/account/wallet_l1.py @@ -1147,8 +1147,12 @@ def finalize_withdrawal(self, withdraw_hash, index: int = 0): nonce=self._eth_web3.eth.get_transaction_count(self.address), ) - shared_bridge_address = self._zksync_web3.zksync.zks_get_bridge_contracts().shared_l1_default_bridge - shared_bridge = self._eth_web3.eth.contract(address=shared_bridge_address, abi=l1_shared_bridge_abi_default()) + shared_bridge_address = ( + self._zksync_web3.zksync.zks_get_bridge_contracts().shared_l1_default_bridge + ) + shared_bridge = self._eth_web3.eth.contract( + address=shared_bridge_address, abi=l1_shared_bridge_abi_default() + ) tx = shared_bridge.functions.finalizeWithdrawal( self._zksync_web3.eth.chain_id, params["l1_batch_number"], @@ -1190,7 +1194,7 @@ def is_withdrawal_finalized(self, withdraw_hash, index: int = 0): abi=l1_shared_bridge_abi_default(), ) - return l1_bridge.functions.isWithdrawalFinalizedShared( + return l1_bridge.functions.isWithdrawalFinalizedShared( self._zksync_web3.eth.chain_id, int(log["l1BatchNumber"], 16), proof.id ).call() diff --git a/zksync2/account/wallet_l2.py b/zksync2/account/wallet_l2.py index 4eb6f1a..bfec180 100644 --- a/zksync2/account/wallet_l2.py +++ b/zksync2/account/wallet_l2.py @@ -94,7 +94,9 @@ def transfer(self, tx: TransferTransaction) -> HexStr: ) if tx.options.gas_limit is None or tx.options.gas_limit == 0: - tx.options.gas_limit = self._zksync_web3.zksync.eth_estimate_gas(tx_fun_call.tx) + tx.options.gas_limit = self._zksync_web3.zksync.eth_estimate_gas( + tx_fun_call.tx + ) tx_712 = tx_fun_call.tx712(tx.options.gas_limit) signer = PrivateKeyEthSigner(self._l1_account, tx.options.chain_id) @@ -119,9 +121,11 @@ def withdraw(self, tx: WithdrawTransaction): tx, from_=self._l1_account.address ) if tx.options.gas_limit is None: - transaction.tx['gas'] = self._zksync_web3.zksync.eth_estimate_gas(transaction.tx) + transaction.tx["gas"] = self._zksync_web3.zksync.eth_estimate_gas( + transaction.tx + ) else: - transaction.tx['gas'] = tx.options.gas_limit + transaction.tx["gas"] = tx.options.gas_limit tx_712 = transaction.tx712() signer = PrivateKeyEthSigner(self._l1_account, self._zksync_web3.eth.chain_id) signed_message = signer.sign_typed_data(tx_712.to_eip712_struct()) diff --git a/zksync2/module/zksync_module.py b/zksync2/module/zksync_module.py index 2047cff..6bb0e76 100644 --- a/zksync2/module/zksync_module.py +++ b/zksync2/module/zksync_module.py @@ -770,7 +770,7 @@ def get_withdraw_transaction( token=tx.token, bridge_address=tx.bridge_address, from_=from_, - paymaster_params=tx.paymaster_params + paymaster_params=tx.paymaster_params, ) return transaction From 5046d49dcf7d37a28956739599baac1f8bc618f3 Mon Sep 17 00:00:00 2001 From: petarTxFusion Date: Thu, 6 Jun 2024 18:26:00 +0200 Subject: [PATCH 07/15] refactor: update contract abi --- .../contract_abi/IAllowList.json | 308 -- .../contract_abi/IBridgehub.json | 3 +- .../contract_abi/IContractDeployer.json | 116 +- .../contract_abi/IERC1271.json | 1 - .../contract_abi/IEthToken.json | 2 +- .../contract_abi/IL1ERC20Bridge.json | 74 +- .../contract_abi/IL1Messenger.json | 1 - .../contract_abi/IL1SharedBridge.json | 64 +- .../contract_abi/IL2Bridge.json | 3 +- .../contract_abi/IL2SharedBridge.json | 186 + .../contract_abi/INonceHolder.json | 2 +- .../contract_abi/IZkSync.json | 3255 ++++++++--------- ...Transition.json => IZkSyncHyperchain.json} | 77 +- zksync2/manage_contracts/utils.py | 25 +- 14 files changed, 1955 insertions(+), 2162 deletions(-) delete mode 100644 zksync2/manage_contracts/contract_abi/IAllowList.json create mode 100644 zksync2/manage_contracts/contract_abi/IL2SharedBridge.json rename zksync2/manage_contracts/contract_abi/{IZkSyncStateTransition.json => IZkSyncHyperchain.json} (99%) diff --git a/zksync2/manage_contracts/contract_abi/IAllowList.json b/zksync2/manage_contracts/contract_abi/IAllowList.json deleted file mode 100644 index edbf2d4..0000000 --- a/zksync2/manage_contracts/contract_abi/IAllowList.json +++ /dev/null @@ -1,308 +0,0 @@ -{ - "abi": [ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "indexed": false, - "internalType": "enum IAllowList.AccessMode", - "name": "previousMode", - "type": "uint8" - }, - { - "indexed": false, - "internalType": "enum IAllowList.AccessMode", - "name": "newMode", - "type": "uint8" - } - ], - "name": "UpdateAccessMode", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "caller", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "target", - "type": "address" - }, - { - "indexed": true, - "internalType": "bytes4", - "name": "functionSig", - "type": "bytes4" - }, - { - "indexed": false, - "internalType": "bool", - "name": "status", - "type": "bool" - } - ], - "name": "UpdateCallPermission", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "l1Token", - "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "depositLimitation", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "depositCap", - "type": "uint256" - } - ], - "name": "UpdateDepositLimit", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_caller", - "type": "address" - }, - { - "internalType": "address", - "name": "_target", - "type": "address" - }, - { - "internalType": "bytes4", - "name": "_functionSig", - "type": "bytes4" - } - ], - "name": "canCall", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_target", - "type": "address" - } - ], - "name": "getAccessMode", - "outputs": [ - { - "internalType": "enum IAllowList.AccessMode", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_l1Token", - "type": "address" - } - ], - "name": "getTokenDepositLimitData", - "outputs": [ - { - "components": [ - { - "internalType": "bool", - "name": "depositLimitation", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "depositCap", - "type": "uint256" - } - ], - "internalType": "struct IAllowList.Deposit", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_caller", - "type": "address" - }, - { - "internalType": "address", - "name": "_target", - "type": "address" - }, - { - "internalType": "bytes4", - "name": "_functionSig", - "type": "bytes4" - } - ], - "name": "hasSpecialAccessToCall", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_target", - "type": "address" - }, - { - "internalType": "enum IAllowList.AccessMode", - "name": "_accessMode", - "type": "uint8" - } - ], - "name": "setAccessMode", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address[]", - "name": "_targets", - "type": "address[]" - }, - { - "internalType": "enum IAllowList.AccessMode[]", - "name": "_accessMode", - "type": "uint8[]" - } - ], - "name": "setBatchAccessMode", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address[]", - "name": "_callers", - "type": "address[]" - }, - { - "internalType": "address[]", - "name": "_targets", - "type": "address[]" - }, - { - "internalType": "bytes4[]", - "name": "_functionSigs", - "type": "bytes4[]" - }, - { - "internalType": "bool[]", - "name": "_enables", - "type": "bool[]" - } - ], - "name": "setBatchPermissionToCall", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_l1Token", - "type": "address" - }, - { - "internalType": "bool", - "name": "_depositLimitation", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "_depositCap", - "type": "uint256" - } - ], - "name": "setDepositLimit", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_caller", - "type": "address" - }, - { - "internalType": "address", - "name": "_target", - "type": "address" - }, - { - "internalType": "bytes4", - "name": "_functionSig", - "type": "bytes4" - }, - { - "internalType": "bool", - "name": "_enable", - "type": "bool" - } - ], - "name": "setPermissionToCall", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } - ] -} \ No newline at end of file diff --git a/zksync2/manage_contracts/contract_abi/IBridgehub.json b/zksync2/manage_contracts/contract_abi/IBridgehub.json index 6cb2d4a..49220b8 100644 --- a/zksync2/manage_contracts/contract_abi/IBridgehub.json +++ b/zksync2/manage_contracts/contract_abi/IBridgehub.json @@ -167,7 +167,7 @@ "type": "uint256" } ], - "name": "getStateTransition", + "name": "getHyperchain", "outputs": [ { "internalType": "address", @@ -630,5 +630,4 @@ "type": "function" } ] - } \ No newline at end of file diff --git a/zksync2/manage_contracts/contract_abi/IContractDeployer.json b/zksync2/manage_contracts/contract_abi/IContractDeployer.json index e8817d0..296e69d 100644 --- a/zksync2/manage_contracts/contract_abi/IContractDeployer.json +++ b/zksync2/manage_contracts/contract_abi/IContractDeployer.json @@ -1,5 +1,5 @@ { - "abi":[ + "abi": [ { "anonymous": false, "inputs": [ @@ -85,7 +85,7 @@ "outputs": [ { "internalType": "address", - "name": "", + "name": "newAddress", "type": "address" } ], @@ -114,7 +114,7 @@ "outputs": [ { "internalType": "address", - "name": "", + "name": "newAddress", "type": "address" } ], @@ -148,7 +148,7 @@ "outputs": [ { "internalType": "address", - "name": "", + "name": "newAddress", "type": "address" } ], @@ -159,7 +159,7 @@ "inputs": [ { "internalType": "bytes32", - "name": "", + "name": "_salt", "type": "bytes32" }, { @@ -182,114 +182,10 @@ "outputs": [ { "internalType": "address", - "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", + "name": "newAddress", "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/zksync2/manage_contracts/contract_abi/IERC1271.json b/zksync2/manage_contracts/contract_abi/IERC1271.json index 84e7f51..0d15e7b 100644 --- a/zksync2/manage_contracts/contract_abi/IERC1271.json +++ b/zksync2/manage_contracts/contract_abi/IERC1271.json @@ -25,5 +25,4 @@ "type": "function" } ] - } \ No newline at end of file diff --git a/zksync2/manage_contracts/contract_abi/IEthToken.json b/zksync2/manage_contracts/contract_abi/IEthToken.json index c4f2ae8..51dda4e 100644 --- a/zksync2/manage_contracts/contract_abi/IEthToken.json +++ b/zksync2/manage_contracts/contract_abi/IEthToken.json @@ -1,5 +1,5 @@ { - "abi":[ + "abi": [ { "anonymous": false, "inputs": [ diff --git a/zksync2/manage_contracts/contract_abi/IL1ERC20Bridge.json b/zksync2/manage_contracts/contract_abi/IL1ERC20Bridge.json index e437e92..e435afd 100644 --- a/zksync2/manage_contracts/contract_abi/IL1ERC20Bridge.json +++ b/zksync2/manage_contracts/contract_abi/IL1ERC20Bridge.json @@ -1,16 +1,5 @@ { "abi": [ - { - "inputs": [ - { - "internalType": "contract IL1SharedBridge", - "name": "_sharedBridge", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, { "anonymous": false, "inputs": [ @@ -98,6 +87,19 @@ "name": "WithdrawalFinalized", "type": "event" }, + { + "inputs": [], + "name": "SHARED_BRIDGE", + "outputs": [ + { + "internalType": "contract IL1SharedBridge", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { @@ -173,7 +175,7 @@ "outputs": [ { "internalType": "bytes32", - "name": "l2TxHash", + "name": "txHash", "type": "bytes32" } ], @@ -217,7 +219,7 @@ "outputs": [ { "internalType": "bytes32", - "name": "l2TxHash", + "name": "txHash", "type": "bytes32" } ], @@ -228,17 +230,17 @@ "inputs": [ { "internalType": "address", - "name": "account", + "name": "_account", "type": "address" }, { "internalType": "address", - "name": "l1Token", + "name": "_l1Token", "type": "address" }, { "internalType": "bytes32", - "name": "depositL2TxHash", + "name": "_depositL2TxHash", "type": "bytes32" } ], @@ -250,7 +252,7 @@ "type": "uint256" } ], - "stateMutability": "view", + "stateMutability": "nonpayable", "type": "function" }, { @@ -286,23 +288,16 @@ "stateMutability": "nonpayable", "type": "function" }, - { - "inputs": [], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, { "inputs": [ { "internalType": "uint256", - "name": "l2BatchNumber", + "name": "_l2BatchNumber", "type": "uint256" }, { "internalType": "uint256", - "name": "l2ToL1MessageNumber", + "name": "_l2MessageIndex", "type": "uint256" } ], @@ -310,7 +305,7 @@ "outputs": [ { "internalType": "bool", - "name": "isFinalized", + "name": "", "type": "bool" } ], @@ -363,29 +358,16 @@ "type": "function" }, { - "inputs": [], - "name": "l2TokenProxyBytecodeHash", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "sharedBridge", - "outputs": [ + "inputs": [ { - "internalType": "contract IL1SharedBridge", - "name": "", + "internalType": "address", + "name": "_token", "type": "address" } ], - "stateMutability": "view", + "name": "transferTokenToSharedBridge", + "outputs": [], + "stateMutability": "nonpayable", "type": "function" } ] diff --git a/zksync2/manage_contracts/contract_abi/IL1Messenger.json b/zksync2/manage_contracts/contract_abi/IL1Messenger.json index 3f1c24a..6d8af33 100644 --- a/zksync2/manage_contracts/contract_abi/IL1Messenger.json +++ b/zksync2/manage_contracts/contract_abi/IL1Messenger.json @@ -145,5 +145,4 @@ "type": "function" } ] - } \ No newline at end of file diff --git a/zksync2/manage_contracts/contract_abi/IL1SharedBridge.json b/zksync2/manage_contracts/contract_abi/IL1SharedBridge.json index 9b526e2..cba2121 100644 --- a/zksync2/manage_contracts/contract_abi/IL1SharedBridge.json +++ b/zksync2/manage_contracts/contract_abi/IL1SharedBridge.json @@ -206,7 +206,7 @@ }, { "inputs": [], - "name": "bridgehub", + "name": "BRIDGE_HUB", "outputs": [ { "internalType": "contract IBridgehub", @@ -217,6 +217,19 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [], + "name": "L1_WETH_TOKEN", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { @@ -619,19 +632,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [], - "name": "l1WethAddress", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [ { @@ -681,15 +681,45 @@ "inputs": [ { "internalType": "uint256", - "name": "_eraFirstPostUpgradeBatch", + "name": "_eraLegacyBridgeLastDepositBatch", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_eraLegacyBridgeLastDepositTxNumber", + "type": "uint256" + } + ], + "name": "setEraLegacyBridgeLastDepositTime", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_eraPostDiamondUpgradeFirstBatch", + "type": "uint256" + } + ], + "name": "setEraPostDiamondUpgradeFirstBatch", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_eraPostLegacyBridgeUpgradeFirstBatch", "type": "uint256" } ], - "name": "setEraFirstPostUpgradeBatch", + "name": "setEraPostLegacyBridgeUpgradeFirstBatch", "outputs": [], "stateMutability": "nonpayable", "type": "function" } ] - } \ No newline at end of file diff --git a/zksync2/manage_contracts/contract_abi/IL2Bridge.json b/zksync2/manage_contracts/contract_abi/IL2Bridge.json index 8af4158..5d70eaa 100644 --- a/zksync2/manage_contracts/contract_abi/IL2Bridge.json +++ b/zksync2/manage_contracts/contract_abi/IL2Bridge.json @@ -30,7 +30,7 @@ ], "name": "finalizeDeposit", "outputs": [], - "stateMutability": "payable", + "stateMutability": "nonpayable", "type": "function" }, { @@ -108,5 +108,4 @@ "type": "function" } ] - } \ No newline at end of file diff --git a/zksync2/manage_contracts/contract_abi/IL2SharedBridge.json b/zksync2/manage_contracts/contract_abi/IL2SharedBridge.json new file mode 100644 index 0000000..76afde8 --- /dev/null +++ b/zksync2/manage_contracts/contract_abi/IL2SharedBridge.json @@ -0,0 +1,186 @@ +{ + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "l1Sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "l2Receiver", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "l2Token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "FinalizeDeposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "l2Sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "l1Receiver", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "l2Token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "WithdrawalInitiated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_l1Sender", + "type": "address" + }, + { + "internalType": "address", + "name": "_l2Receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "_l1Token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "finalizeDeposit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "l1Bridge", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "l1SharedBridge", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_l2Token", + "type": "address" + } + ], + "name": "l1TokenAddress", + "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": [ + { + "internalType": "address", + "name": "_l1Receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "_l2Token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] +} \ No newline at end of file diff --git a/zksync2/manage_contracts/contract_abi/INonceHolder.json b/zksync2/manage_contracts/contract_abi/INonceHolder.json index 1ee9c5c..c9bdbef 100644 --- a/zksync2/manage_contracts/contract_abi/INonceHolder.json +++ b/zksync2/manage_contracts/contract_abi/INonceHolder.json @@ -216,4 +216,4 @@ "stateMutability": "view", "type": "function" } -] +] \ No newline at end of file diff --git a/zksync2/manage_contracts/contract_abi/IZkSync.json b/zksync2/manage_contracts/contract_abi/IZkSync.json index 1244e4f..61e2846 100644 --- a/zksync2/manage_contracts/contract_abi/IZkSync.json +++ b/zksync2/manage_contracts/contract_abi/IZkSync.json @@ -1,1637 +1,1624 @@ { "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": true, - "internalType": "address", - "name": "oldGovernor", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newGovernor", - "type": "address" - } - ], - "name": "NewGovernor", - "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": true, - "internalType": "address", - "name": "oldPendingGovernor", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newPendingGovernor", - "type": "address" - } - ], - "name": "NewPendingGovernor", - "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 IMailbox.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": [], - "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" - }, - { - "inputs": [], - "name": "acceptAdmin", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "acceptGovernor", - "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": "totalL2ToL1Pubdata", - "type": "bytes" - } - ], - "internalType": "struct IExecutor.CommitBatchInfo[]", - "name": "_newBatchesData", - "type": "tuple[]" - } - ], - "name": "commitBatches", - "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": [ - { - "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": "getAllowList", - "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": "getGovernor", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "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": "getPendingGovernor", - "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": "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": "hash", - "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": "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": "_l2BatchNumber", - "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": "_l2BatchNumber", - "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": "address", - "name": "_newPendingAdmin", - "type": "address" - } - ], - "name": "setPendingAdmin", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_newPendingGovernor", - "type": "address" - } - ], - "name": "setPendingGovernor", - "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": "address", - "name": "_validator", - "type": "address" - }, - { - "internalType": "bool", - "name": "_active", - "type": "bool" - } - ], - "name": "setValidator", - "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": "unfreezeDiamond", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } - ] + { + "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": true, + "internalType": "address", + "name": "oldGovernor", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newGovernor", + "type": "address" + } + ], + "name": "NewGovernor", + "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": true, + "internalType": "address", + "name": "oldPendingGovernor", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newPendingGovernor", + "type": "address" + } + ], + "name": "NewPendingGovernor", + "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 IMailbox.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": [], + "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" + }, + { + "inputs": [], + "name": "acceptAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "acceptGovernor", + "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": "totalL2ToL1Pubdata", + "type": "bytes" + } + ], + "internalType": "struct IExecutor.CommitBatchInfo[]", + "name": "_newBatchesData", + "type": "tuple[]" + } + ], + "name": "commitBatches", + "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": [ + { + "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": "getFirstUnprocessedPriorityTx", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getGovernor", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "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": "getPendingGovernor", + "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": "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": "hash", + "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": "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": "_l2BatchNumber", + "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": "_l2BatchNumber", + "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": "address", + "name": "_newPendingAdmin", + "type": "address" + } + ], + "name": "setPendingAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_newPendingGovernor", + "type": "address" + } + ], + "name": "setPendingGovernor", + "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": "address", + "name": "_validator", + "type": "address" + }, + { + "internalType": "bool", + "name": "_active", + "type": "bool" + } + ], + "name": "setValidator", + "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": "unfreezeDiamond", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] } \ No newline at end of file diff --git a/zksync2/manage_contracts/contract_abi/IZkSyncStateTransition.json b/zksync2/manage_contracts/contract_abi/IZkSyncHyperchain.json similarity index 99% rename from zksync2/manage_contracts/contract_abi/IZkSyncStateTransition.json rename to zksync2/manage_contracts/contract_abi/IZkSyncHyperchain.json index 19386e8..9abe615 100644 --- a/zksync2/manage_contracts/contract_abi/IZkSyncStateTransition.json +++ b/zksync2/manage_contracts/contract_abi/IZkSyncHyperchain.json @@ -1,5 +1,4 @@ -{ - "abi": [ +[ { "anonymous": false, "inputs": [ @@ -94,25 +93,6 @@ "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": [ @@ -691,7 +671,7 @@ "type": "bytes32" } ], - "stateMutability": "payable", + "stateMutability": "nonpayable", "type": "function" }, { @@ -1446,6 +1426,29 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [], + "name": "getSemverProtocolVersion", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "getStateTransitionManager", @@ -2249,6 +2252,19 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "enum PubdataPricingMode", + "name": "_pricingMode", + "type": "uint8" + } + ], + "name": "setPubdataPricingMode", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { @@ -2298,19 +2314,6 @@ "stateMutability": "nonpayable", "type": "function" }, - { - "inputs": [ - { - "internalType": "enum PubdataPricingMode", - "name": "_validiumMode", - "type": "uint8" - } - ], - "name": "setValidiumMode", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, { "inputs": [ { @@ -2401,6 +2404,4 @@ "stateMutability": "nonpayable", "type": "function" } -] - -} \ No newline at end of file +] \ No newline at end of file diff --git a/zksync2/manage_contracts/utils.py b/zksync2/manage_contracts/utils.py index b311fc0..b1325bc 100644 --- a/zksync2/manage_contracts/utils.py +++ b/zksync2/manage_contracts/utils.py @@ -15,10 +15,11 @@ l1_bridge_abi_cache = None eth_token_abi_cache = None erc_20_abi_cache = None -eth_token_abi_cache = None test_net_erc_20_abi_cache = None l1_shared_bridge_abi_cache = None +l2_shared_bridge_abi_cache = None bridgehub_abi_cache = None +zksync_hyperchain_cache = None def zksync_abi_default(): @@ -108,6 +109,17 @@ def l1_shared_bridge_abi_default(): return l1_shared_bridge_abi_cache +def l2_shared_bridge_abi_default(): + global l2_shared_bridge_abi_cache + + if l2_shared_bridge_abi_cache is None: + with pkg_resources.path(contract_abi, "IL2SharedBridge.json") as p: + with p.open(mode="r") as json_file: + data = json.load(json_file) + l2_shared_bridge_abi_cache = data["abi"] + return l2_shared_bridge_abi_cache + + def eth_token_abi_default(): global eth_token_abi_cache @@ -141,6 +153,17 @@ def get_test_net_erc20_token(): return test_net_erc_20_abi_cache +def get_zksync_hyperchain(): + global zksync_hyperchain_cache + + if zksync_hyperchain_cache is None: + with pkg_resources.path(contract_abi, "IZkSyncHyperchain.json") as p: + with p.open(mode="r") as json_file: + data = json.load(json_file) + zksync_hyperchain_cache = data["abi"] + return zksync_hyperchain_cache + + class ERC20Encoder(BaseContractEncoder): def __init__(self, web3: Web3, abi: Optional[dict] = None): if abi is None: From 7098d32e63574c54706347bb70c82a3d1ea9f33f Mon Sep 17 00:00:00 2001 From: petarTxFusion Date: Thu, 6 Jun 2024 18:28:38 +0200 Subject: [PATCH 08/15] refactor: use L2_BASE_TOKEN_ADDRESS as a address when working with base token --- scripts/setup.py | 1 + tests/integration/test_config.py | 2 +- tests/integration/test_wallet.py | 42 ++++++++---------- zksync2/account/wallet_l1.py | 8 ++-- zksync2/module/zksync_module.py | 48 +++++++++------------ zksync2/transaction/transaction_builders.py | 11 ++--- 6 files changed, 48 insertions(+), 64 deletions(-) diff --git a/scripts/setup.py b/scripts/setup.py index 6a056ee..c19e2a7 100644 --- a/scripts/setup.py +++ b/scripts/setup.py @@ -71,6 +71,7 @@ def deposit_token(wallet, eth_web3: Web3, zksync: Web3, zksync_contract): amount, wallet.address, approve_erc20=True, + approve_base_erc20=True, refund_recipient=wallet.address, ) ) diff --git a/tests/integration/test_config.py b/tests/integration/test_config.py index a47fe5e..ba0bd00 100644 --- a/tests/integration/test_config.py +++ b/tests/integration/test_config.py @@ -31,5 +31,5 @@ class TestEnvironment: LOCAL_ENV = TestEnvironment( - EnvType.LOCAL_HOST, "http://localhost:3050", "http://127.0.0.1:8545" + EnvType.LOCAL_HOST, "http://localhost:15100", "http://127.0.0.1:15045" ) diff --git a/tests/integration/test_wallet.py b/tests/integration/test_wallet.py index 07b1708..820e172 100644 --- a/tests/integration/test_wallet.py +++ b/tests/integration/test_wallet.py @@ -52,8 +52,8 @@ def setUp(self) -> None: self.CONTRACT_ADDRESS = "0x36615Cf349d7F6344891B1e7CA7C72883F5dc049" self.env = LOCAL_ENV env_key = EnvPrivateKey("ZKSYNC_KEY1") - self.zksync = ZkSyncBuilder.build("http://127.0.0.1:3050") - self.eth_web3 = Web3(Web3.HTTPProvider("http://127.0.0.1:8545")) + self.zksync = ZkSyncBuilder.build("http://127.0.0.1:15100") + self.eth_web3 = Web3(Web3.HTTPProvider("http://127.0.0.1:15045")) self.account: LocalAccount = Account.from_key(env_key.key) self.wallet = Wallet(self.zksync, self.eth_web3, self.account) self.zksync_contract = self.eth_web3.eth.contract( @@ -534,8 +534,8 @@ def test_full_required_deposit_fee_base_token(self): def test_transfer_eth(self): amount = 7_000_000_000 - balance_before_transfer = self.zksync.zksync.get_balance( - Web3.to_checksum_address(self.address2) + balance_before_transfer = self.zksync.zksync.zks_get_balance( + Web3.to_checksum_address(self.address2), token_address=LEGACY_ETH_ADDRESS ) tx_hash = self.wallet.transfer( TransferTransaction( @@ -548,8 +548,8 @@ def test_transfer_eth(self): self.zksync.zksync.wait_for_transaction_receipt( tx_hash, timeout=240, poll_latency=0.5 ) - balance_after_transfer = self.zksync.zksync.get_balance( - Web3.to_checksum_address(self.address2) + balance_after_transfer = self.zksync.zksync.zks_get_balance( + Web3.to_checksum_address(self.address2), token_address=LEGACY_ETH_ADDRESS ) self.assertEqual(balance_after_transfer - balance_before_transfer, amount) @@ -766,24 +766,20 @@ def test_transfer_token_paymaster(self): self.assertEqual(reciever_balance_after - reciever_balance_before, 5) def test_withdraw_eth(self): - token = ( - ETH_ADDRESS_IN_CONTRACTS - if self.is_eth_based_chain - else self.wallet.l2_token_address(ETH_ADDRESS_IN_CONTRACTS) - ) - l2_balance_before = self.wallet.get_balance() + l2_balance_before = self.wallet.get_balance(token_address=LEGACY_ETH_ADDRESS) amount = 7_000_000_000 withdraw_tx_hash = self.wallet.withdraw( - WithdrawTransaction(token=token, amount=amount) + WithdrawTransaction(token=LEGACY_ETH_ADDRESS, amount=amount) ) withdraw_receipt = self.zksync.zksync.wait_finalized( withdraw_tx_hash, timeout=240, poll_latency=0.5 ) - # self.assertFalse( - # self.wallet.is_withdrawal_finalized(withdraw_receipt["transactionHash"]) - # ) + print (withdraw_receipt["transactionHash"]) + self.assertFalse( + self.wallet.is_withdrawal_finalized(withdraw_receipt["transactionHash"]) + ) finalized_hash = self.wallet.finalize_withdrawal( withdraw_receipt["transactionHash"] ) @@ -791,7 +787,7 @@ def test_withdraw_eth(self): finalized_hash, timeout=240, poll_latency=0.5 ) - l2_balance_after = self.wallet.get_balance() + l2_balance_after = self.wallet.get_balance(token_address=LEGACY_ETH_ADDRESS) self.assertIsNotNone(result) self.assertGreater( @@ -839,9 +835,9 @@ def test_withdraw_eth_paymaster(self): withdraw_receipt = self.zksync.zksync.wait_finalized( withdraw_tx_hash, timeout=240, poll_latency=0.5 ) - # self.assertFalse( - # self.wallet.is_withdrawal_finalized(withdraw_receipt["transactionHash"]) - # ) + self.assertFalse( + self.wallet.is_withdrawal_finalized(withdraw_receipt["transactionHash"]) + ) finalized_hash = self.wallet.finalize_withdrawal( withdraw_receipt["transactionHash"] @@ -948,9 +944,9 @@ def test_withdraw_token(self): withdraw_receipt = self.zksync.zksync.wait_finalized( withdraw_tx_hash, timeout=240, poll_latency=0.5 ) - # self.assertFalse( - # self.wallet.is_withdrawal_finalized(withdraw_receipt["transactionHash"]) - # ) + self.assertFalse( + self.wallet.is_withdrawal_finalized(withdraw_receipt["transactionHash"]) + ) finalized_hash = self.wallet.finalize_withdrawal( withdraw_receipt["transactionHash"] diff --git a/zksync2/account/wallet_l1.py b/zksync2/account/wallet_l1.py index 747c493..f947c3a 100644 --- a/zksync2/account/wallet_l1.py +++ b/zksync2/account/wallet_l1.py @@ -46,7 +46,7 @@ get_erc20_abi, l2_bridge_abi_default, l1_shared_bridge_abi_default, - bridgehub_abi_default, + bridgehub_abi_default, get_zksync_hyperchain, l2_shared_bridge_abi_default, ) from zksync2.module.request_types import EIP712Meta from zksync2.transaction.transaction_builders import TxFunctionCall @@ -75,7 +75,7 @@ def __init__(self, zksync_web3: Web3, eth_web3: Web3, l1_account: BaseAccount): self._zksync_web3.zksync.zks_main_contract() ) self.contract = self._eth_web3.eth.contract( - self._main_contract_address, abi=zksync_abi_default() + self._main_contract_address, abi=get_zksync_hyperchain() ) self._l1_account = l1_account self.bridge_addresses: BridgeAddresses = ( @@ -1187,14 +1187,14 @@ def is_withdrawal_finalized(self, withdraw_hash, index: int = 0): l1_bridge = self.get_l1_bridge_contracts().shared else: l2_bridge = self._zksync_web3.eth.contract( - Web3.to_checksum_address(sender), abi=l2_bridge_abi_default() + Web3.to_checksum_address(sender), abi=l2_shared_bridge_abi_default() ) l1_bridge = self._eth_web3.eth.contract( Web3.to_checksum_address(l2_bridge.functions.l1Bridge().call()), abi=l1_shared_bridge_abi_default(), ) - return l1_bridge.functions.isWithdrawalFinalizedShared( + return l1_bridge.functions.isWithdrawalFinalized( self._zksync_web3.eth.chain_id, int(log["l1BatchNumber"], 16), proof.id ).call() diff --git a/zksync2/module/zksync_module.py b/zksync2/module/zksync_module.py index 6bb0e76..a9fef65 100644 --- a/zksync2/module/zksync_module.py +++ b/zksync2/module/zksync_module.py @@ -578,7 +578,11 @@ def zks_get_balance( block_tag=ZkBlockParams.COMMITTED.value, token_address: HexStr = None, ) -> int: - if token_address is None or is_eth(token_address): + if token_address is None: + token_address = L2_BASE_TOKEN_ADDRESS + elif token_address == LEGACY_ETH_ADDRESS or token_address == ETH_ADDRESS_IN_CONTRACTS: + token_address = self.l2_token_address(ETH_ADDRESS_IN_CONTRACTS) + if token_address == L2_BASE_TOKEN_ADDRESS: return self.get_balance(to_checksum_address(address), block_tag) try: @@ -745,49 +749,37 @@ def get_withdraw_transaction( tx: WithdrawTransaction, from_: HexStr, ) -> TxWithdraw: - is_eth_based_chain = self.is_eth_based_chain() - - if ( - tx.token is not None - and is_address_eq(tx.token, LEGACY_ETH_ADDRESS) - and not is_eth_based_chain - ): - tx.token = self.l2_token_address(ETH_ADDRESS_IN_CONTRACTS) - elif tx.token is None or self.is_base_token(tx.token): - tx.token = L2_BASE_TOKEN_ADDRESS + token = tx.token + if token is None: + token = L2_BASE_TOKEN_ADDRESS + if token == LEGACY_ETH_ADDRESS or token == ETH_ADDRESS_IN_CONTRACTS: + token = self.l2_token_address(ETH_ADDRESS_IN_CONTRACTS) if tx.options is None: tx.options = TransactionOptions() - transaction = TxWithdraw( + return TxWithdraw( web3=self, - chain_id=tx.options.chain_id, + chain_id=tx.options.chain_id , nonce=tx.options.nonce, to=tx.to, amount=tx.amount, gas_limit=tx.options.gas_limit, max_fee_per_gas=tx.options.max_fee_per_gas, max_priority_fee_per_gas=tx.options.max_priority_fee_per_gas, - token=tx.token, + token=token, bridge_address=tx.bridge_address, from_=from_, paymaster_params=tx.paymaster_params, ) - return transaction - def get_transfer_transaction( self, tx: TransferTransaction, from_: HexStr ) -> TxTransfer: - is_eth_based_chain = self.is_eth_based_chain() - - if ( - tx.token_address is not None - and is_address_eq(tx.token_address, LEGACY_ETH_ADDRESS) - and not is_eth_based_chain - ): - tx.token_address = self.l2_token_address(ETH_ADDRESS_IN_CONTRACTS) - elif tx.token_address is None or self.is_base_token(tx.token_address): - tx.token_address = L2_BASE_TOKEN_ADDRESS + token = tx.token_address + if token is None: + token = L2_BASE_TOKEN_ADDRESS + elif token == LEGACY_ETH_ADDRESS or token == ETH_ADDRESS_IN_CONTRACTS: + token = self.l2_token_address(ETH_ADDRESS_IN_CONTRACTS) if tx.options is None: tx.options = TransactionOptions() @@ -805,7 +797,7 @@ def get_transfer_transaction( tx.options.gas_limit = 0 call_data = "0x" - if tx.token_address is not None and not is_eth(tx.token_address): + if not is_eth(token): transfer_params = (tx.to, tx.amount) contract = self.contract( Web3.to_checksum_address(tx.token_address), abi=get_erc20_abi() @@ -814,7 +806,7 @@ def get_transfer_transaction( transaction = TxTransfer( web3=self, - token=tx.token_address, + token=token, chain_id=tx.options.chain_id, nonce=tx.options.nonce, from_=from_, diff --git a/zksync2/transaction/transaction_builders.py b/zksync2/transaction/transaction_builders.py index d390449..9235c69 100644 --- a/zksync2/transaction/transaction_builders.py +++ b/zksync2/transaction/transaction_builders.py @@ -5,6 +5,7 @@ from eth_typing import HexStr from web3 import Web3 from web3.types import Nonce +from zksync2.account.utils import prepare_transaction_options from zksync2.core.types import Token, BridgeAddresses, TransactionOptions from zksync2.core.utils import is_eth, MAX_PRIORITY_FEE_PER_GAS, L2_BASE_TOKEN_ADDRESS @@ -330,7 +331,7 @@ def __init__( paymaster_params=paymaster_params, ) - if is_eth(token): + if token == L2_BASE_TOKEN_ADDRESS: contract = web3.contract( Web3.to_checksum_address(L2_BASE_TOKEN_ADDRESS), abi=eth_token_abi_default(), @@ -357,18 +358,12 @@ def __init__( options = TransactionOptions( nonce=nonce, chain_id=chain_id, - gas_limit=gas_limit, max_fee_per_gas=max_fee_per_gas, max_priority_fee_per_gas=max_priority_fee_per_gas, value=0, ) tx = l2_bridge.functions.withdraw(to, token, amount).build_transaction( - { - "nonce": nonce, - "chainId": chain_id, - "value": 0, - "from": from_, - } + prepare_transaction_options(from_=from_, options=options) ) tx["eip712Meta"] = eip712_meta super(TxWithdraw, self).__init__(trans=tx) From b844ec400974e815ffc1e00b4a57e50822790f59 Mon Sep 17 00:00:00 2001 From: petarTxFusion Date: Thu, 6 Jun 2024 18:30:41 +0200 Subject: [PATCH 09/15] chore: lint code --- tests/integration/test_wallet.py | 2 +- zksync2/account/wallet_l1.py | 4 +++- zksync2/module/zksync_module.py | 7 +++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/integration/test_wallet.py b/tests/integration/test_wallet.py index 820e172..eea89ff 100644 --- a/tests/integration/test_wallet.py +++ b/tests/integration/test_wallet.py @@ -776,7 +776,7 @@ def test_withdraw_eth(self): withdraw_receipt = self.zksync.zksync.wait_finalized( withdraw_tx_hash, timeout=240, poll_latency=0.5 ) - print (withdraw_receipt["transactionHash"]) + print(withdraw_receipt["transactionHash"]) self.assertFalse( self.wallet.is_withdrawal_finalized(withdraw_receipt["transactionHash"]) ) diff --git a/zksync2/account/wallet_l1.py b/zksync2/account/wallet_l1.py index f947c3a..76be85e 100644 --- a/zksync2/account/wallet_l1.py +++ b/zksync2/account/wallet_l1.py @@ -46,7 +46,9 @@ get_erc20_abi, l2_bridge_abi_default, l1_shared_bridge_abi_default, - bridgehub_abi_default, get_zksync_hyperchain, l2_shared_bridge_abi_default, + bridgehub_abi_default, + get_zksync_hyperchain, + l2_shared_bridge_abi_default, ) from zksync2.module.request_types import EIP712Meta from zksync2.transaction.transaction_builders import TxFunctionCall diff --git a/zksync2/module/zksync_module.py b/zksync2/module/zksync_module.py index a9fef65..2159cfd 100644 --- a/zksync2/module/zksync_module.py +++ b/zksync2/module/zksync_module.py @@ -580,7 +580,10 @@ def zks_get_balance( ) -> int: if token_address is None: token_address = L2_BASE_TOKEN_ADDRESS - elif token_address == LEGACY_ETH_ADDRESS or token_address == ETH_ADDRESS_IN_CONTRACTS: + elif ( + token_address == LEGACY_ETH_ADDRESS + or token_address == ETH_ADDRESS_IN_CONTRACTS + ): token_address = self.l2_token_address(ETH_ADDRESS_IN_CONTRACTS) if token_address == L2_BASE_TOKEN_ADDRESS: return self.get_balance(to_checksum_address(address), block_tag) @@ -759,7 +762,7 @@ def get_withdraw_transaction( return TxWithdraw( web3=self, - chain_id=tx.options.chain_id , + chain_id=tx.options.chain_id, nonce=tx.options.nonce, to=tx.to, amount=tx.amount, From 3f6f4b86c27f5fb83be38353824b15e5c13ff51b Mon Sep 17 00:00:00 2001 From: petarTxFusion Date: Thu, 6 Jun 2024 18:33:46 +0200 Subject: [PATCH 10/15] ci: trigger test on push against main --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 444c643..6f99bdf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,10 +1,10 @@ name: Run tests on: push: - branches: [ main, beta ] + branches: [ master, beta ] workflow_dispatch: pull_request: - branches: [ main, beta ] + branches: [ master, beta ] types: [ opened, reopened, synchronize ] permissions: From 49c94f3857dc4a3d82db133254525a68c27b5e39 Mon Sep 17 00:00:00 2001 From: petarTxFusion Date: Thu, 6 Jun 2024 18:43:41 +0200 Subject: [PATCH 11/15] refactor: update `IZkSyncHyperchain.json` --- .../manage_contracts/contract_abi/IZkSyncHyperchain.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zksync2/manage_contracts/contract_abi/IZkSyncHyperchain.json b/zksync2/manage_contracts/contract_abi/IZkSyncHyperchain.json index 9abe615..27841d4 100644 --- a/zksync2/manage_contracts/contract_abi/IZkSyncHyperchain.json +++ b/zksync2/manage_contracts/contract_abi/IZkSyncHyperchain.json @@ -1,4 +1,5 @@ -[ +{ + "abi": [ { "anonymous": false, "inputs": [ @@ -2404,4 +2405,5 @@ "stateMutability": "nonpayable", "type": "function" } -] \ No newline at end of file +] +} \ No newline at end of file From 46fa9c07f461d093e1ab52f422936f49782ce42b Mon Sep 17 00:00:00 2001 From: petarTxFusion Date: Thu, 6 Jun 2024 19:01:06 +0200 Subject: [PATCH 12/15] test: update test port --- tests/unit/test_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py index e18ae05..7a2cb7d 100644 --- a/tests/unit/test_config.py +++ b/tests/unit/test_config.py @@ -31,5 +31,5 @@ class TestEnvironment: LOCAL_ENV = TestEnvironment( - EnvType.LOCAL_HOST, "http://127.0.0.1:3050", "http://127.0.0.1:8545" + EnvType.LOCAL_HOST, "http://127.0.0.1:15100", "http://127.0.0.1:15045" ) From 9e53d34df93b71ee521047498ba7d56172be73fa Mon Sep 17 00:00:00 2001 From: petarTxFusion Date: Thu, 6 Jun 2024 22:32:48 +0200 Subject: [PATCH 13/15] refactor: refactor `isWithdrawFinalized` to use l2SharedBridge --- zksync2/account/wallet_l1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zksync2/account/wallet_l1.py b/zksync2/account/wallet_l1.py index 76be85e..fdc71ae 100644 --- a/zksync2/account/wallet_l1.py +++ b/zksync2/account/wallet_l1.py @@ -1192,7 +1192,7 @@ def is_withdrawal_finalized(self, withdraw_hash, index: int = 0): Web3.to_checksum_address(sender), abi=l2_shared_bridge_abi_default() ) l1_bridge = self._eth_web3.eth.contract( - Web3.to_checksum_address(l2_bridge.functions.l1Bridge().call()), + Web3.to_checksum_address(l2_bridge.functions.l1SharedBridge().call()), abi=l1_shared_bridge_abi_default(), ) From 5818450e8300f1b1939ba96ef54189b720f7d0b6 Mon Sep 17 00:00:00 2001 From: petarTxFusion Date: Fri, 7 Jun 2024 00:33:11 +0200 Subject: [PATCH 14/15] refactor: refactor `get_l2_bridge_contracts` to return `IL2SharedBridge` --- zksync2/account/wallet_l2.py | 8 ++++++-- zksync2/core/types.py | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/zksync2/account/wallet_l2.py b/zksync2/account/wallet_l2.py index bfec180..e9e90c6 100644 --- a/zksync2/account/wallet_l2.py +++ b/zksync2/account/wallet_l2.py @@ -12,7 +12,7 @@ from zksync2.manage_contracts.utils import ( zksync_abi_default, nonce_holder_abi_default, - l2_bridge_abi_default, + l2_bridge_abi_default, l2_shared_bridge_abi_default, ) from zksync2.module.response_types import ZksAccountBalances from zksync2.signer.eth_signer import PrivateKeyEthSigner @@ -74,9 +74,13 @@ def get_l2_bridge_contracts(self) -> L2BridgeContracts: address=Web3.to_checksum_address(addresses.erc20_l2_default_bridge), abi=l2_bridge_abi_default(), ), + weth=self._zksync_web3.eth.contract( + address=Web3.to_checksum_address(addresses.weth_bridge_l2), + abi=l2_bridge_abi_default(), + ), shared=self._zksync_web3.eth.contract( address=Web3.to_checksum_address(addresses.shared_l2_default_bridge), - abi=l2_bridge_abi_default(), + abi=l2_shared_bridge_abi_default(), ), ) diff --git a/zksync2/core/types.py b/zksync2/core/types.py index fadd7c3..e9c2609 100644 --- a/zksync2/core/types.py +++ b/zksync2/core/types.py @@ -100,6 +100,7 @@ class L1BridgeContracts: @dataclass class L2BridgeContracts: erc20: Contract + weth: Contract shared: Contract From f3edcc3cfe6021cc40cdd246bd0174042b0152cd Mon Sep 17 00:00:00 2001 From: petarTxFusion Date: Fri, 7 Jun 2024 00:33:49 +0200 Subject: [PATCH 15/15] chore: lint code --- zksync2/account/wallet_l2.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zksync2/account/wallet_l2.py b/zksync2/account/wallet_l2.py index e9e90c6..1f4be66 100644 --- a/zksync2/account/wallet_l2.py +++ b/zksync2/account/wallet_l2.py @@ -12,7 +12,8 @@ from zksync2.manage_contracts.utils import ( zksync_abi_default, nonce_holder_abi_default, - l2_bridge_abi_default, l2_shared_bridge_abi_default, + l2_bridge_abi_default, + l2_shared_bridge_abi_default, ) from zksync2.module.response_types import ZksAccountBalances from zksync2.signer.eth_signer import PrivateKeyEthSigner