diff --git a/docs/contributing.rst b/docs/contributing.rst index c3c2235c99..71438543e3 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -195,18 +195,16 @@ Within the ``pytest`` scope, :file:`conftest.py` files are used for common code shared between modules that exist within the same directory as that particular :file:`conftest.py` file. -Unit Testing -^^^^^^^^^^^^ +Unit Testing and eth-tester Tests +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Unit tests are meant to test the logic of smaller chunks (or units) of the -codebase without having to be wired up to a client. Most of the time this -means testing selected methods on their own. They are meant to test the logic -of your code and make sure that you get expected outputs out of selected inputs. +Our unit tests are grouped together with tests against the ``eth-tester`` library, +using the ``py-evm`` library as a backend, via the ``EthereumTesterProvider``. -Our unit tests live under appropriately named child directories within the -``/tests`` directory. The core of the unit tests live under ``/tests/core``. -Do your best to follow the existing structure when choosing where to add -your unit test. +These tests live under appropriately named child directories within the +``/tests`` directory. The core of these tests live under ``/tests/core``. +Do your best to follow the existing structure when adding a test and make sure +that its location makes sense. Integration Testing ^^^^^^^^^^^^^^^^^^^ @@ -217,25 +215,80 @@ confused with pytest fixtures). These zip file fixtures, which also live in the ``/tests/integration`` directory, are configured to run the specific client we are testing against along with a genesis configuration that gives our tests some pre-determined useful objects (like unlocked, pre-loaded accounts) to be able to -interact with the client and run our tests. +interact with the client when we run our tests. -Though the setup lives in ``/tests/integration``, our integration module tests are -written across different files within ``/web3/_utils/module_testing``. The tests -are written there but run configurations exist across the different files within -``/tests/integration/``. The parent ``/integration`` directory houses some common -configuration shared across all client tests, whereas the ``/go_ethereum`` directory -houses common code to be shared among respective client tests. +The parent ``/integration`` directory houses some common configuration shared across +all client tests, whereas the ``/go_ethereum`` directory houses common code to be +shared across geth-specific provider tests. Though the setup and run configurations +exist across the different files within ``/tests/integration``, our integration module +tests are written across different files within ``/web3/_utils/module_testing``. * :file:`common.py` files within the client directories contain code that is shared across all provider tests (http, ipc, and ws). This is mostly used to override tests that span across all providers. -* :file:`conftest.py` files within each of these directories contain mostly code that can - be *used* by all test files that exist within the same directory as the :file:`conftest.py` - file. This is mostly used to house pytest fixtures to be shared among our tests. Refer to - the `pytest documentation on fixtures`_ for more information. -* :file:`test_{client}_{provider}.py` (e.g. :file:`test_goethereum_http.py`) files are where - client-and-provider-specific test configurations exist. This is mostly used to override tests - specific to the provider type for the respective client. +* :file:`conftest.py` files within each of these directories contain mostly code that + can be *used* by all test files that exist within the same directory or subdirectories + of the :file:`conftest.py` file. This is mostly used to house pytest fixtures to be + shared among our tests. Refer to the `pytest documentation on fixtures`_ for more + information. +* ``test_{client}_{provider}.py`` files (e.g. :file:`test_goethereum_http.py`) are where + client-and-provider-specific test configurations exist. This is mostly used to + override tests specific to the provider type for the respective client. + + +Working With Test Contracts +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Contracts used for testing exist under ``web3/_utils/contract_sources``. These contracts +get compiled via the ``compile_contracts.py`` script in the same directory. To use +this script, simply pass the Solidity version to be used to compile the contracts as an +argument at the command line. + +Arguments for the script are: + -v or --version Solidity version to be used to compile the contracts. If + blank, the script uses the latest hard-coded version + specified within the script. + + -f or --filename If left blank, all .sol files will be compiled and the + respective contract data will be generated. Pass in a + specific ``.sol`` filename here to compile just one file. + + +To run the script, you will need the ``py-solc-x`` library for compiling the files +as well as ``black`` for code formatting. You can install those independently or +install the full ``[dev]`` package extra as shown below. + +.. code:: sh + + $ pip install "web3[dev]" + +The following example compiles all the contracts and generates their respective +contract data that is used across our test files for the test suites. This data gets +generated within the ``contract_data`` subdirectory within the ``contract_sources`` +folder. + +.. code-block:: bash + + $ cd ../web3.py/web3/_utils/contract_sources + $ python compile_contracts.py -v 0.8.17 + Compiling OffchainLookup + ... + ... + reformatted ... + +To compile and generate contract data for only one ``.sol`` file, specify using the +filename with the ``-f`` (or ``--filename``) argument flag. + +.. code-block:: bash + + $ cd ../web3.py/web3/_utils/contract_sources + $ python compile_contracts.py -v 0.8.17 -f OffchainLookup.sol + Compiling OffchainLookup.sol + reformatted ... + +If there is any contract data that is not generated via the script but is is important +to pass on to the test suites, the ``_custom_data.py`` can be used to store that +information. Manual Testing @@ -246,7 +299,7 @@ you can install it from your development directory: .. code:: sh - $ pip install -e ../path/to/web3py + $ pip install -e ../path/to/web3py Documentation diff --git a/docs/web3.contract.rst b/docs/web3.contract.rst index 3e23a79523..bd08aa8edb 100644 --- a/docs/web3.contract.rst +++ b/docs/web3.contract.rst @@ -610,51 +610,51 @@ Taking the following contract code as an example: .. doctest:: arrayscontract - >>> ArraysContract = w3.eth.contract(abi=abi, bytecode=bytecode) + >>> arrays_contract_instance = w3.eth.contract(abi=abi, bytecode=bytecode) - >>> tx_hash = ArraysContract.constructor([b'bb']).transact() + >>> tx_hash = arrays_contract_instance.constructor([b'bb']).transact() >>> tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash) - >>> array_contract = w3.eth.contract( + >>> arrays_contract = w3.eth.contract( ... address=tx_receipt.contractAddress, ... abi=abi ... ) - >>> array_contract.functions.getBytes2Value().call() + >>> arrays_contract.functions.getBytes2Value().call() [b'bb'] >>> # set value with appropriate byte size - >>> array_contract.functions.setBytes2Value([b'aa']).transact({'gas': 420000, "maxPriorityFeePerGas": 10 ** 9, "maxFeePerGas": 10 ** 9}) + >>> arrays_contract.functions.setBytes2Value([b'aa']).transact({'gas': 420000, "maxPriorityFeePerGas": 10 ** 9, "maxFeePerGas": 10 ** 9}) HexBytes('0xcb95151142ea56dbf2753d70388aef202a7bb5a1e323d448bc19f1d2e1fe3dc9') >>> # check value - >>> array_contract.functions.getBytes2Value().call() + >>> arrays_contract.functions.getBytes2Value().call() [b'aa'] >>> # trying to set value without appropriate size (bytes2) is not valid - >>> array_contract.functions.setBytes2Value([b'b']).transact() + >>> arrays_contract.functions.setBytes2Value([b'b']).transact() Traceback (most recent call last): ... web3.exceptions.Web3ValidationError: Could not identify the intended function with name >>> # check value is still b'aa' - >>> array_contract.functions.getBytes2Value().call() + >>> arrays_contract.functions.getBytes2Value().call() [b'aa'] >>> # disabling strict byte checking... >>> w3.strict_bytes_type_checking = False - >>> tx_hash = ArraysContract.constructor([b'b']).transact() + >>> tx_hash = arrays_contract_instance.constructor([b'b']).transact() >>> tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash) - >>> array_contract = w3.eth.contract( + >>> arrays_contract = w3.eth.contract( ... address=tx_receipt.contractAddress, ... abi=abi ... ) >>> # check value is zero-padded... i.e. b'b\x00' - >>> array_contract.functions.getBytes2Value().call() + >>> arrays_contract.functions.getBytes2Value().call() [b'b\x00'] >>> # set the flag back to True >>> w3.strict_bytes_type_checking = True - >>> array_contract.functions.setBytes2Value([b'a']).transact() + >>> arrays_contract.functions.setBytes2Value([b'a']).transact() Traceback (most recent call last): ... web3.exceptions.Web3ValidationError: diff --git a/newsfragments/2797.internal.rst b/newsfragments/2797.internal.rst new file mode 100644 index 0000000000..49f7ef9223 --- /dev/null +++ b/newsfragments/2797.internal.rst @@ -0,0 +1,2 @@ +Re-compile all test contracts with latest Solidity version. Refactor test fixtures. Adds a script that compiles all test contracts to the same directory with selected Solidity version. + diff --git a/setup.py b/setup.py index ad1472e22b..138bbe7210 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ "configparser==3.5.0", "contextlib2>=0.5.4", "py-geth>=3.9.1", - "py-solc>=0.4.0", + "py-solc-x>=1.1.1", "pytest>=6.2.5", "sphinx>=4.2.0", "sphinx_rtd_theme>=0.5.2", diff --git a/tests/conftest.py b/tests/conftest.py index cbd85933b9..b549100e82 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,12 +1,17 @@ import pytest from eth_utils import ( + event_signature_to_log_topic, to_bytes, ) from eth_utils.toolz import ( identity, ) +from web3._utils.contract_sources.contract_data.emitter_contract import ( + EMITTER_CONTRACT_DATA, +) + from .utils import ( get_open_port, ) @@ -24,3 +29,78 @@ def open_port(): def pytest_addoption(parser): parser.addoption("--flaky", action="store_true") + + +# --- session-scoped constants --- # + + +@pytest.fixture(scope="session") +def emitter_contract_data(): + return EMITTER_CONTRACT_DATA + + +class LogFunctions: + LogAnonymous = 0 + LogNoArguments = 1 + LogSingleArg = 2 + LogDoubleArg = 3 + LogTripleArg = 4 + LogQuadrupleArg = 5 + LogSingleAnonymous = 6 + LogSingleWithIndex = 7 + LogDoubleAnonymous = 8 + LogDoubleWithIndex = 9 + LogTripleWithIndex = 10 + LogQuadrupleWithIndex = 11 + LogBytes = 12 + LogString = 13 + LogDynamicArgs = 14 + LogListArgs = 15 + LogAddressIndexed = 16 + LogAddressNotIndexed = 17 + + +@pytest.fixture(scope="session") +def emitter_contract_event_ids(): + return LogFunctions + + +class LogTopics: + LogAnonymous = event_signature_to_log_topic("LogAnonymous()") + LogNoArguments = event_signature_to_log_topic("LogNoArguments()") + LogSingleArg = event_signature_to_log_topic("LogSingleArg(uint256)") + LogSingleAnonymous = event_signature_to_log_topic("LogSingleAnonymous(uint256)") + LogSingleWithIndex = event_signature_to_log_topic("LogSingleWithIndex(uint256)") + LogDoubleArg = event_signature_to_log_topic("LogDoubleArg(uint256,uint256)") + LogDoubleAnonymous = event_signature_to_log_topic( + "LogDoubleAnonymous(uint256,uint256)" + ) + LogDoubleWithIndex = event_signature_to_log_topic( + "LogDoubleWithIndex(uint256,uint256)" + ) + LogTripleArg = event_signature_to_log_topic("LogTripleArg(uint256,uint256,uint256)") + LogTripleWithIndex = event_signature_to_log_topic( + "LogTripleWithIndex(uint256,uint256,uint256)" + ) + LogQuadrupleArg = event_signature_to_log_topic( + "LogQuadrupleArg(uint256,uint256,uint256,uint256)" + ) + LogQuadrupleWithIndex = event_signature_to_log_topic( + "LogQuadrupleWithIndex(uint256,uint256,uint256,uint256)", + ) + LogBytes = event_signature_to_log_topic("LogBytes(bytes)") + LogString = event_signature_to_log_topic("LogString(string)") + LogDynamicArgs = event_signature_to_log_topic("LogDynamicArgs(string,string)") + LogListArgs = event_signature_to_log_topic("LogListArgs(bytes2[],bytes2[])") + LogAddressIndexed = event_signature_to_log_topic( + "LogAddressIndexed(address,address)" + ) + LogAddressNotIndexed = event_signature_to_log_topic( + "LogAddressNotIndexed(address,address)" + ) + LogStructArgs = event_signature_to_log_topic("LogStructArgs(uint256,tuple)") + + +@pytest.fixture(scope="session") +def emitter_contract_log_topics(): + return LogTopics diff --git a/tests/core/contracts/conftest.py b/tests/core/contracts/conftest.py index 630f49d3e7..fd297e4c1d 100644 --- a/tests/core/contracts/conftest.py +++ b/tests/core/contracts/conftest.py @@ -1,10 +1,6 @@ import functools -import json import pytest -from eth_utils import ( - event_signature_to_log_topic, -) import pytest_asyncio from tests.core.contracts.utils import ( @@ -14,804 +10,259 @@ from tests.utils import ( async_partial, ) -from web3._utils.module_testing.emitter_contract import ( - CONTRACT_EMITTER_ABI, - CONTRACT_EMITTER_CODE, - CONTRACT_EMITTER_RUNTIME, +from web3._utils.contract_sources.contract_data.arrays_contract import ( + ARRAYS_CONTRACT_DATA, ) -from web3._utils.module_testing.event_contract import ( - EVNT_CONTRACT_ABI, - EVNT_CONTRACT_CODE, - EVNT_CONTRACT_RUNTIME, +from web3._utils.contract_sources.contract_data.constructor_contracts import ( + CONSTRUCTOR_WITH_ADDRESS_ARGUMENT_CONTRACT_DATA, + CONSTRUCTOR_WITH_ARGUMENTS_CONTRACT_DATA, + SIMPLE_CONSTRUCTOR_CONTRACT_DATA, ) -from web3._utils.module_testing.fallback_contract import ( - CONTRACT_FALLBACK_FUNCTION_ABI, - CONTRACT_FALLBACK_FUNCTION_CODE, - CONTRACT_FALLBACK_FUNCTION_RUNTIME, +from web3._utils.contract_sources.contract_data.contract_caller_tester import ( + CONTRACT_CALLER_TESTER_DATA, ) -from web3._utils.module_testing.indexed_event_contract import ( - IND_EVENT_CONTRACT_ABI, - IND_EVENT_CONTRACT_CODE, - IND_EVENT_CONTRACT_RUNTIME, +from web3._utils.contract_sources.contract_data.event_contracts import ( + EVENT_CONTRACT_DATA, + INDEXED_EVENT_CONTRACT_DATA, ) -from web3._utils.module_testing.no_receive_contract import ( - CONTRACT_NO_RECEIVE_FUNCTION_ABI, - CONTRACT_NO_RECEIVE_FUNCTION_CODE, - CONTRACT_NO_RECEIVE_FUNCTION_RUNTIME, +from web3._utils.contract_sources.contract_data.fallback_function_contract import ( + FALLBACK_FUNCTION_CONTRACT_DATA, ) -from web3._utils.module_testing.receive_contract import ( - CONTRACT_RECEIVE_FUNCTION_ABI, - CONTRACT_RECEIVE_FUNCTION_CODE, - CONTRACT_RECEIVE_FUNCTION_RUNTIME, +from web3._utils.contract_sources.contract_data.math_contract import ( + MATH_CONTRACT_ABI, + MATH_CONTRACT_BYTECODE, + MATH_CONTRACT_DATA, + MATH_CONTRACT_RUNTIME, ) -from web3._utils.module_testing.revert_contract import ( - _REVERT_CONTRACT_ABI, - REVERT_CONTRACT_BYTECODE, - REVERT_CONTRACT_RUNTIME_CODE, +from web3._utils.contract_sources.contract_data.payable_tester import ( + PAYABLE_TESTER_CONTRACT_DATA, ) - -CONTRACT_NESTED_TUPLE_SOURCE = """ -pragma solidity >=0.4.19 <0.6.0; -pragma experimental ABIEncoderV2; - -contract Tuple { - struct U { int x; int y; } - struct T { U[] u; } - struct S { T[] t; } - - function method(S memory s) public pure returns (S memory) { - return s; - } -} -""" -CONTRACT_NESTED_TUPLE_CODE = "0x608060405234801561001057600080fd5b50610575806100206000396000f300608060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632655aef114610046575b600080fd5b34801561005257600080fd5b5061006d600480360361006891908101906102a2565b610083565b60405161007a919061043e565b60405180910390f35b61008b610093565b819050919050565b602060405190810160405280606081525090565b600082601f83011215156100ba57600080fd5b81356100cd6100c88261048d565b610460565b9150818183526020840193506020810190508360005b8381101561011357813586016100f98882610206565b8452602084019350602083019250506001810190506100e3565b5050505092915050565b600082601f830112151561013057600080fd5b813561014361013e826104b5565b610460565b9150818183526020840193506020810190508385604084028201111561016857600080fd5b60005b83811015610198578161017e8882610256565b84526020840193506040830192505060018101905061016b565b5050505092915050565b60006101ae8235610531565b905092915050565b6000602082840312156101c857600080fd5b6101d26020610460565b9050600082013567ffffffffffffffff8111156101ee57600080fd5b6101fa848285016100a7565b60008301525092915050565b60006020828403121561021857600080fd5b6102226020610460565b9050600082013567ffffffffffffffff81111561023e57600080fd5b61024a8482850161011d565b60008301525092915050565b60006040828403121561026857600080fd5b6102726040610460565b90506000610282848285016101a2565b6000830152506020610296848285016101a2565b60208301525092915050565b6000602082840312156102b457600080fd5b600082013567ffffffffffffffff8111156102ce57600080fd5b6102da848285016101b6565b91505092915050565b60006102ee826104f7565b80845260208401935083602082028501610307856104dd565b60005b848110156103405783830388526103228383516103e5565b925061032d8261050d565b915060208801975060018101905061030a565b508196508694505050505092915050565b600061035c82610502565b80845260208401935061036e836104ea565b60005b828110156103a05761038486835161040f565b61038d8261051a565b9150604086019550600181019050610371565b50849250505092915050565b6103b581610527565b82525050565b600060208301600083015184820360008601526103d882826102e3565b9150508091505092915050565b600060208301600083015184820360008601526104028282610351565b9150508091505092915050565b60408201600082015161042560008501826103ac565b50602082015161043860208501826103ac565b50505050565b6000602082019050818103600083015261045881846103bb565b905092915050565b6000604051905081810181811067ffffffffffffffff8211171561048357600080fd5b8060405250919050565b600067ffffffffffffffff8211156104a457600080fd5b602082029050602081019050919050565b600067ffffffffffffffff8211156104cc57600080fd5b602082029050602081019050919050565b6000602082019050919050565b6000602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b6000819050919050565b60008190509190505600a265627a7a7230582011dc176b6cffda1d2e58827bca1a16178776c2d8efcd6adf48bc0223f14f891a6c6578706572696d656e74616cf50037" # noqa: E501 -CONTRACT_NESTED_TUPLE_RUNTIME = "0x608060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632655aef114610046575b600080fd5b34801561005257600080fd5b5061006d600480360361006891908101906102a2565b610083565b60405161007a919061043e565b60405180910390f35b61008b610093565b819050919050565b602060405190810160405280606081525090565b600082601f83011215156100ba57600080fd5b81356100cd6100c88261048d565b610460565b9150818183526020840193506020810190508360005b8381101561011357813586016100f98882610206565b8452602084019350602083019250506001810190506100e3565b5050505092915050565b600082601f830112151561013057600080fd5b813561014361013e826104b5565b610460565b9150818183526020840193506020810190508385604084028201111561016857600080fd5b60005b83811015610198578161017e8882610256565b84526020840193506040830192505060018101905061016b565b5050505092915050565b60006101ae8235610531565b905092915050565b6000602082840312156101c857600080fd5b6101d26020610460565b9050600082013567ffffffffffffffff8111156101ee57600080fd5b6101fa848285016100a7565b60008301525092915050565b60006020828403121561021857600080fd5b6102226020610460565b9050600082013567ffffffffffffffff81111561023e57600080fd5b61024a8482850161011d565b60008301525092915050565b60006040828403121561026857600080fd5b6102726040610460565b90506000610282848285016101a2565b6000830152506020610296848285016101a2565b60208301525092915050565b6000602082840312156102b457600080fd5b600082013567ffffffffffffffff8111156102ce57600080fd5b6102da848285016101b6565b91505092915050565b60006102ee826104f7565b80845260208401935083602082028501610307856104dd565b60005b848110156103405783830388526103228383516103e5565b925061032d8261050d565b915060208801975060018101905061030a565b508196508694505050505092915050565b600061035c82610502565b80845260208401935061036e836104ea565b60005b828110156103a05761038486835161040f565b61038d8261051a565b9150604086019550600181019050610371565b50849250505092915050565b6103b581610527565b82525050565b600060208301600083015184820360008601526103d882826102e3565b9150508091505092915050565b600060208301600083015184820360008601526104028282610351565b9150508091505092915050565b60408201600082015161042560008501826103ac565b50602082015161043860208501826103ac565b50505050565b6000602082019050818103600083015261045881846103bb565b905092915050565b6000604051905081810181811067ffffffffffffffff8211171561048357600080fd5b8060405250919050565b600067ffffffffffffffff8211156104a457600080fd5b602082029050602081019050919050565b600067ffffffffffffffff8211156104cc57600080fd5b602082029050602081019050919050565b6000602082019050919050565b6000602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b6000819050919050565b60008190509190505600a265627a7a7230582011dc176b6cffda1d2e58827bca1a16178776c2d8efcd6adf48bc0223f14f891a6c6578706572696d656e74616cf50037" # noqa: E501 -CONTRACT_NESTED_TUPLE_ABI = json.loads( - '[{"constant":true,"inputs":[{"components":[{"components":[{"components":[{"name":"x","type":"int256"},{"name":"y","type":"int256"}],"name":"u","type":"tuple[]"}],"name":"t","type":"tuple[]"}],"name":"s","type":"tuple"}],"name":"method","outputs":[{"components":[{"components":[{"components":[{"name":"x","type":"int256"},{"name":"y","type":"int256"}],"name":"u","type":"tuple[]"}],"name":"t","type":"tuple[]"}],"name":"","type":"tuple"}],"payable":false,"stateMutability":"pure","type":"function"}]' # noqa: E501 +from web3._utils.contract_sources.contract_data.receive_function_contracts import ( + NO_RECEIVE_FUNCTION_CONTRACT_DATA, + RECEIVE_FUNCTION_CONTRACT_DATA, ) - - -@pytest.fixture() -def NESTED_TUPLE_CODE(): - return CONTRACT_NESTED_TUPLE_CODE - - -@pytest.fixture() -def NESTED_TUPLE_RUNTIME(): - return CONTRACT_NESTED_TUPLE_RUNTIME - - -@pytest.fixture() -def NESTED_TUPLE_ABI(): - return CONTRACT_NESTED_TUPLE_ABI - - -@pytest.fixture() -def NESTED_TUPLE_CONTRACT(NESTED_TUPLE_CODE, NESTED_TUPLE_RUNTIME, NESTED_TUPLE_ABI): - return { - "bytecode": NESTED_TUPLE_CODE, - "bytecode_runtime": NESTED_TUPLE_RUNTIME, - "abi": NESTED_TUPLE_ABI, - } - - -@pytest.fixture() -def NestedTupleContract(w3, NESTED_TUPLE_CONTRACT): - return w3.eth.contract(**NESTED_TUPLE_CONTRACT) - - -CONTRACT_TUPLE_SOURCE = """ -pragma solidity >=0.4.19 <0.6.0; -pragma experimental ABIEncoderV2; - -contract Tuple { - struct T { int x; bool[2] y; address[] z; } - struct S { uint a; uint[] b; T[] c; } - - function method(S memory s) public pure returns (S memory) { - return s; - } -} -""" -CONTRACT_TUPLE_CODE = "0x608060405234801561001057600080fd5b506108ca806100206000396000f300608060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680638e1ae3c714610046575b600080fd5b34801561005257600080fd5b5061006d60048036036100689190810190610403565b610083565b60405161007a9190610696565b60405180910390f35b61008b610093565b819050919050565b6060604051908101604052806000815260200160608152602001606081525090565b60006100c18235610850565b905092915050565b600082601f83011215156100dc57600080fd5b81356100ef6100ea826106e5565b6106b8565b9150818183526020840193506020810190508385602084028201111561011457600080fd5b60005b83811015610144578161012a88826100b5565b845260208401935060208301925050600181019050610117565b5050505092915050565b600082601f830112151561016157600080fd5b600261017461016f8261070d565b6106b8565b9150818385602084028201111561018a57600080fd5b60005b838110156101ba57816101a088826102bf565b84526020840193506020830192505060018101905061018d565b5050505092915050565b600082601f83011215156101d757600080fd5b81356101ea6101e58261072f565b6106b8565b9150818183526020840193506020810190508360005b8381101561023057813586016102168882610377565b845260208401935060208301925050600181019050610200565b5050505092915050565b600082601f830112151561024d57600080fd5b813561026061025b82610757565b6106b8565b9150818183526020840193506020810190508385602084028201111561028557600080fd5b60005b838110156102b5578161029b88826103ef565b845260208401935060208301925050600181019050610288565b5050505092915050565b60006102cb8235610870565b905092915050565b60006102df823561087c565b905092915050565b6000606082840312156102f957600080fd5b61030360606106b8565b90506000610313848285016103ef565b600083015250602082013567ffffffffffffffff81111561033357600080fd5b61033f8482850161023a565b602083015250604082013567ffffffffffffffff81111561035f57600080fd5b61036b848285016101c4565b60408301525092915050565b60006080828403121561038957600080fd5b61039360606106b8565b905060006103a3848285016102d3565b60008301525060206103b78482850161014e565b602083015250606082013567ffffffffffffffff8111156103d757600080fd5b6103e3848285016100c9565b60408301525092915050565b60006103fb8235610886565b905092915050565b60006020828403121561041557600080fd5b600082013567ffffffffffffffff81111561042f57600080fd5b61043b848285016102e7565b91505092915050565b61044d81610810565b82525050565b600061045e826107b0565b8084526020840193506104708361077f565b60005b828110156104a257610486868351610444565b61048f826107dc565b9150602086019550600181019050610473565b50849250505092915050565b6104b7816107bb565b6104c08261078c565b60005b828110156104f2576104d68583516105c2565b6104df826107e9565b91506020850194506001810190506104c3565b5050505050565b6000610504826107c6565b8084526020840193508360208202850161051d85610796565b60005b84811015610556578383038852610538838351610637565b9250610543826107f6565b9150602088019750600181019050610520565b508196508694505050505092915050565b6000610572826107d1565b808452602084019350610584836107a3565b60005b828110156105b65761059a868351610687565b6105a382610803565b9150602086019550600181019050610587565b50849250505092915050565b6105cb81610830565b82525050565b6105da8161083c565b82525050565b60006060830160008301516105f86000860182610687565b50602083015184820360208601526106108282610567565b9150506040830151848203604086015261062a82826104f9565b9150508091505092915050565b600060808301600083015161064f60008601826105d1565b50602083015161066260208601826104ae565b506040830151848203606086015261067a8282610453565b9150508091505092915050565b61069081610846565b82525050565b600060208201905081810360008301526106b081846105e0565b905092915050565b6000604051905081810181811067ffffffffffffffff821117156106db57600080fd5b8060405250919050565b600067ffffffffffffffff8211156106fc57600080fd5b602082029050602081019050919050565b600067ffffffffffffffff82111561072457600080fd5b602082029050919050565b600067ffffffffffffffff82111561074657600080fd5b602082029050602081019050919050565b600067ffffffffffffffff82111561076e57600080fd5b602082029050602081019050919050565b6000602082019050919050565b6000819050919050565b6000602082019050919050565b6000602082019050919050565b600081519050919050565b600060029050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b6000602082019050919050565b6000602082019050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60008115159050919050565b6000819050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60008115159050919050565b6000819050919050565b60008190509190505600a265627a7a72305820fb4abae14c4bcd2cd8a12f35862cb09a2e0f9004eb5fdbfdb76658a753570c8c6c6578706572696d656e74616cf50037" # noqa: E501 -CONTRACT_TUPLE_RUNTIME = "0x608060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680638e1ae3c714610046575b600080fd5b34801561005257600080fd5b5061006d60048036036100689190810190610403565b610083565b60405161007a9190610696565b60405180910390f35b61008b610093565b819050919050565b6060604051908101604052806000815260200160608152602001606081525090565b60006100c18235610850565b905092915050565b600082601f83011215156100dc57600080fd5b81356100ef6100ea826106e5565b6106b8565b9150818183526020840193506020810190508385602084028201111561011457600080fd5b60005b83811015610144578161012a88826100b5565b845260208401935060208301925050600181019050610117565b5050505092915050565b600082601f830112151561016157600080fd5b600261017461016f8261070d565b6106b8565b9150818385602084028201111561018a57600080fd5b60005b838110156101ba57816101a088826102bf565b84526020840193506020830192505060018101905061018d565b5050505092915050565b600082601f83011215156101d757600080fd5b81356101ea6101e58261072f565b6106b8565b9150818183526020840193506020810190508360005b8381101561023057813586016102168882610377565b845260208401935060208301925050600181019050610200565b5050505092915050565b600082601f830112151561024d57600080fd5b813561026061025b82610757565b6106b8565b9150818183526020840193506020810190508385602084028201111561028557600080fd5b60005b838110156102b5578161029b88826103ef565b845260208401935060208301925050600181019050610288565b5050505092915050565b60006102cb8235610870565b905092915050565b60006102df823561087c565b905092915050565b6000606082840312156102f957600080fd5b61030360606106b8565b90506000610313848285016103ef565b600083015250602082013567ffffffffffffffff81111561033357600080fd5b61033f8482850161023a565b602083015250604082013567ffffffffffffffff81111561035f57600080fd5b61036b848285016101c4565b60408301525092915050565b60006080828403121561038957600080fd5b61039360606106b8565b905060006103a3848285016102d3565b60008301525060206103b78482850161014e565b602083015250606082013567ffffffffffffffff8111156103d757600080fd5b6103e3848285016100c9565b60408301525092915050565b60006103fb8235610886565b905092915050565b60006020828403121561041557600080fd5b600082013567ffffffffffffffff81111561042f57600080fd5b61043b848285016102e7565b91505092915050565b61044d81610810565b82525050565b600061045e826107b0565b8084526020840193506104708361077f565b60005b828110156104a257610486868351610444565b61048f826107dc565b9150602086019550600181019050610473565b50849250505092915050565b6104b7816107bb565b6104c08261078c565b60005b828110156104f2576104d68583516105c2565b6104df826107e9565b91506020850194506001810190506104c3565b5050505050565b6000610504826107c6565b8084526020840193508360208202850161051d85610796565b60005b84811015610556578383038852610538838351610637565b9250610543826107f6565b9150602088019750600181019050610520565b508196508694505050505092915050565b6000610572826107d1565b808452602084019350610584836107a3565b60005b828110156105b65761059a868351610687565b6105a382610803565b9150602086019550600181019050610587565b50849250505092915050565b6105cb81610830565b82525050565b6105da8161083c565b82525050565b60006060830160008301516105f86000860182610687565b50602083015184820360208601526106108282610567565b9150506040830151848203604086015261062a82826104f9565b9150508091505092915050565b600060808301600083015161064f60008601826105d1565b50602083015161066260208601826104ae565b506040830151848203606086015261067a8282610453565b9150508091505092915050565b61069081610846565b82525050565b600060208201905081810360008301526106b081846105e0565b905092915050565b6000604051905081810181811067ffffffffffffffff821117156106db57600080fd5b8060405250919050565b600067ffffffffffffffff8211156106fc57600080fd5b602082029050602081019050919050565b600067ffffffffffffffff82111561072457600080fd5b602082029050919050565b600067ffffffffffffffff82111561074657600080fd5b602082029050602081019050919050565b600067ffffffffffffffff82111561076e57600080fd5b602082029050602081019050919050565b6000602082019050919050565b6000819050919050565b6000602082019050919050565b6000602082019050919050565b600081519050919050565b600060029050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b6000602082019050919050565b6000602082019050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60008115159050919050565b6000819050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60008115159050919050565b6000819050919050565b60008190509190505600a265627a7a72305820fb4abae14c4bcd2cd8a12f35862cb09a2e0f9004eb5fdbfdb76658a753570c8c6c6578706572696d656e74616cf50037" # noqa: E501 -CONTRACT_TUPLE_ABI = json.loads( - '[{"constant":true,"inputs":[{"components":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256[]"},{"components":[{"name":"x","type":"int256"},{"name":"y","type":"bool[2]"},{"name":"z","type":"address[]"}],"name":"c","type":"tuple[]"}],"name":"s","type":"tuple"}],"name":"method","outputs":[{"components":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256[]"},{"components":[{"name":"x","type":"int256"},{"name":"y","type":"bool[2]"},{"name":"z","type":"address[]"}],"name":"c","type":"tuple[]"}],"name":"","type":"tuple"}],"payable":false,"stateMutability":"pure","type":"function"}]' # noqa: E501 +from web3._utils.contract_sources.contract_data.reflector_contracts import ( + ADDRESS_REFLECTOR_CONTRACT_DATA, ) - - -@pytest.fixture() -def TUPLE_CODE(): - return CONTRACT_TUPLE_CODE - - -@pytest.fixture() -def TUPLE_RUNTIME(): - return CONTRACT_TUPLE_RUNTIME - - -@pytest.fixture() -def TUPLE_ABI(): - return CONTRACT_TUPLE_ABI - - -@pytest.fixture() -def TUPLE_CONTRACT(TUPLE_CODE, TUPLE_RUNTIME, TUPLE_ABI): - return { - "bytecode": TUPLE_CODE, - "bytecode_runtime": TUPLE_RUNTIME, - "abi": TUPLE_ABI, - } - - -@pytest.fixture() -def TupleContract(w3, TUPLE_CONTRACT): - return w3.eth.contract(**TUPLE_CONTRACT) - - -CONTRACT_CODE = "0x606060405261022e806100126000396000f360606040523615610074576000357c01000000000000000000000000000000000000000000000000000000009004806316216f391461007657806361bc221a146100995780637cf5dab0146100bc578063a5f3c23b146100e8578063d09de08a1461011d578063dcf537b11461014057610074565b005b610083600480505061016c565b6040518082815260200191505060405180910390f35b6100a6600480505061017f565b6040518082815260200191505060405180910390f35b6100d26004808035906020019091905050610188565b6040518082815260200191505060405180910390f35b61010760048080359060200190919080359060200190919050506101ea565b6040518082815260200191505060405180910390f35b61012a6004805050610201565b6040518082815260200191505060405180910390f35b6101566004808035906020019091905050610217565b6040518082815260200191505060405180910390f35b6000600d9050805080905061017c565b90565b60006000505481565b6000816000600082828250540192505081905550600060005054905080507f3496c3ede4ec3ab3686712aa1c238593ea6a42df83f98a5ec7df9834cfa577c5816040518082815260200191505060405180910390a18090506101e5565b919050565b6000818301905080508090506101fb565b92915050565b600061020d6001610188565b9050610214565b90565b60006007820290508050809050610229565b91905056" # noqa: E501 -CONTRACT_RUNTIME = "0x60606040523615610074576000357c01000000000000000000000000000000000000000000000000000000009004806316216f391461007657806361bc221a146100995780637cf5dab0146100bc578063a5f3c23b146100e8578063d09de08a1461011d578063dcf537b11461014057610074565b005b610083600480505061016c565b6040518082815260200191505060405180910390f35b6100a6600480505061017f565b6040518082815260200191505060405180910390f35b6100d26004808035906020019091905050610188565b6040518082815260200191505060405180910390f35b61010760048080359060200190919080359060200190919050506101ea565b6040518082815260200191505060405180910390f35b61012a6004805050610201565b6040518082815260200191505060405180910390f35b6101566004808035906020019091905050610217565b6040518082815260200191505060405180910390f35b6000600d9050805080905061017c565b90565b60006000505481565b6000816000600082828250540192505081905550600060005054905080507f3496c3ede4ec3ab3686712aa1c238593ea6a42df83f98a5ec7df9834cfa577c5816040518082815260200191505060405180910390a18090506101e5565b919050565b6000818301905080508090506101fb565b92915050565b600061020d6001610188565b9050610214565b90565b60006007820290508050809050610229565b91905056" # noqa: E501 -CONTRACT_ABI = json.loads( - '[{"constant":false,"inputs":[],"name":"return13","outputs":[{"name":"result","type":"int256"}],"type":"function"},{"constant":true,"inputs":[],"name":"counter","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"amt","type":"uint256"}],"name":"increment","outputs":[{"name":"result","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"a","type":"int256"},{"name":"b","type":"int256"}],"name":"add","outputs":[{"name":"result","type":"int256"}],"type":"function"},{"constant":false,"inputs":[],"name":"increment","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"a","type":"int256"}],"name":"multiply7","outputs":[{"name":"result","type":"int256"}],"type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"value","type":"uint256"}],"name":"Increased","type":"event"}]' # noqa: E501 +from web3._utils.contract_sources.contract_data.revert_contract import ( + REVERT_CONTRACT_DATA, ) - - -@pytest.fixture(scope="session") -def MATH_CODE(): - return CONTRACT_CODE - - -@pytest.fixture(scope="session") -def MATH_RUNTIME(): - return CONTRACT_RUNTIME - - -@pytest.fixture(scope="session") -def MATH_ABI(): - return CONTRACT_ABI - - -@pytest.fixture() -def MathContract(w3, MATH_ABI, MATH_CODE, MATH_RUNTIME): - return w3.eth.contract( - abi=MATH_ABI, - bytecode=MATH_CODE, - bytecode_runtime=MATH_RUNTIME, - ) - - -@pytest.fixture() -def math_contract(w3, MathContract, address_conversion_func): - return deploy(w3, MathContract, address_conversion_func) - - -CONTRACT_SIMPLE_CONSTRUCTOR_CODE = "0x60606040526003600055602c8060156000396000f3606060405260e060020a600035046373d4a13a8114601a575b005b602260005481565b6060908152602090f3" # noqa: E501 -CONTRACT_SIMPLE_CONSTRUCTOR_RUNTIME = "0x606060405260e060020a600035046373d4a13a8114601a575b005b602260005481565b6060908152602090f3" # noqa: E501 -CONTRACT_SIMPLE_CONSTRUCTOR_ABI = json.loads( - '[{"constant":true,"inputs":[],"name":"data","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"inputs":[],"type":"constructor"}]' # noqa: E501 +from web3._utils.contract_sources.contract_data.string_contract import ( + STRING_CONTRACT_DATA, ) @pytest.fixture(scope="session") -def SIMPLE_CONSTRUCTOR_CODE(): - return CONTRACT_SIMPLE_CONSTRUCTOR_CODE +def math_contract_bytecode(): + return MATH_CONTRACT_BYTECODE @pytest.fixture(scope="session") -def SIMPLE_CONSTRUCTOR_RUNTIME(): - return CONTRACT_SIMPLE_CONSTRUCTOR_RUNTIME +def math_contract_runtime(): + return MATH_CONTRACT_RUNTIME @pytest.fixture(scope="session") -def SIMPLE_CONSTRUCTOR_ABI(): - return CONTRACT_SIMPLE_CONSTRUCTOR_ABI +def math_contract_abi(): + return MATH_CONTRACT_ABI -@pytest.fixture() -def SimpleConstructorContract( - w3, SIMPLE_CONSTRUCTOR_CODE, SIMPLE_CONSTRUCTOR_RUNTIME, SIMPLE_CONSTRUCTOR_ABI -): - return w3.eth.contract( - abi=SIMPLE_CONSTRUCTOR_ABI, - bytecode=SIMPLE_CONSTRUCTOR_CODE, - bytecode_runtime=SIMPLE_CONSTRUCTOR_RUNTIME, - ) - - -CONTRACT_WITH_CONSTRUCTOR_ARGUMENTS_CODE = "0x60606040818152806066833960a09052516080516000918255600155603e908190602890396000f3606060405260e060020a600035046388ec134681146024578063d4c46c7614602c575b005b603460005481565b603460015481565b6060908152602090f3" # noqa: E501 -CONTRACT_WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME = "0x606060405260e060020a600035046388ec134681146024578063d4c46c7614602c575b005b603460005481565b603460015481565b6060908152602090f3" # noqa: E501 -CONTRACT_WITH_CONSTRUCTOR_ARGUMENTS_ABI = json.loads( - '[{"constant":true,"inputs":[],"name":"data_a","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"data_b","outputs":[{"name":"","type":"bytes32"}],"type":"function"},{"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"bytes32"}],"type":"constructor"}]' # noqa: E501 -) - - -@pytest.fixture() -def WITH_CONSTRUCTOR_ARGUMENTS_CODE(): - return CONTRACT_WITH_CONSTRUCTOR_ARGUMENTS_CODE - - -@pytest.fixture() -def WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME(): - return CONTRACT_WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME - - -@pytest.fixture() -def WITH_CONSTRUCTOR_ARGUMENTS_ABI(): - return CONTRACT_WITH_CONSTRUCTOR_ARGUMENTS_ABI - - -@pytest.fixture() -def WithConstructorArgumentsContract( - w3, - WITH_CONSTRUCTOR_ARGUMENTS_CODE, - WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME, - WITH_CONSTRUCTOR_ARGUMENTS_ABI, -): - return w3.eth.contract( - abi=WITH_CONSTRUCTOR_ARGUMENTS_ABI, - bytecode=WITH_CONSTRUCTOR_ARGUMENTS_CODE, - bytecode_runtime=WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME, - ) - - -@pytest.fixture() -def NonStrictWithConstructorArgumentsContract( - w3_non_strict_abi, - WITH_CONSTRUCTOR_ARGUMENTS_CODE, - WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME, - WITH_CONSTRUCTOR_ARGUMENTS_ABI, -): - return w3_non_strict_abi.eth.contract( - abi=WITH_CONSTRUCTOR_ARGUMENTS_ABI, - bytecode=WITH_CONSTRUCTOR_ARGUMENTS_CODE, - bytecode_runtime=WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME, - ) +@pytest.fixture +def math_contract_factory(w3): + return w3.eth.contract(**MATH_CONTRACT_DATA) -CONTRACT_WITH_CONSTRUCTOR_ADDRESS_CODE = "0x6060604052604051602080607683395060806040525160008054600160a060020a031916821790555060428060346000396000f3606060405260e060020a600035046334664e3a8114601a575b005b603860005473ffffffffffffffffffffffffffffffffffffffff1681565b6060908152602090f3" # noqa: E501 -CONTRACT_WITH_CONSTRUCTOR_ADDRESS_RUNTIME = "0x606060405260e060020a600035046334664e3a8114601a575b005b603860005473ffffffffffffffffffffffffffffffffffffffff1681565b6060908152602090f3" # noqa: E501 -CONTRACT_WITH_CONSTRUCTOR_ADDRESS_ABI = json.loads( - '[{"constant":true,"inputs":[],"name":"testAddr","outputs":[{"name":"","type":"address"}],"type":"function"},{"inputs":[{"name":"_testAddr","type":"address"}],"type":"constructor"}]' # noqa: E501 -) +@pytest.fixture +def math_contract(w3, math_contract_factory, address_conversion_func): + return deploy(w3, math_contract_factory, address_conversion_func) -@pytest.fixture() -def WITH_CONSTRUCTOR_ADDRESS_CODE(): - return CONTRACT_WITH_CONSTRUCTOR_ADDRESS_CODE +@pytest.fixture +def simple_constructor_contract_factory(w3): + return w3.eth.contract(**SIMPLE_CONSTRUCTOR_CONTRACT_DATA) -@pytest.fixture() -def WITH_CONSTRUCTOR_ADDRESS_RUNTIME(): - return CONTRACT_WITH_CONSTRUCTOR_ADDRESS_RUNTIME +@pytest.fixture +def contract_with_constructor_args_factory(w3): + return w3.eth.contract(**CONSTRUCTOR_WITH_ARGUMENTS_CONTRACT_DATA) -@pytest.fixture() -def WITH_CONSTRUCTOR_ADDRESS_ABI(): - return CONTRACT_WITH_CONSTRUCTOR_ADDRESS_ABI +@pytest.fixture +def non_strict_contract_with_constructor_args_factory(w3_non_strict_abi): + return w3_non_strict_abi.eth.contract(**CONSTRUCTOR_WITH_ARGUMENTS_CONTRACT_DATA) -@pytest.fixture() -def WithConstructorAddressArgumentsContract( - w3, - WITH_CONSTRUCTOR_ADDRESS_CODE, - WITH_CONSTRUCTOR_ADDRESS_RUNTIME, - WITH_CONSTRUCTOR_ADDRESS_ABI, -): - return w3.eth.contract( - abi=WITH_CONSTRUCTOR_ADDRESS_ABI, - bytecode=WITH_CONSTRUCTOR_ADDRESS_CODE, - bytecode_runtime=WITH_CONSTRUCTOR_ADDRESS_RUNTIME, - ) +@pytest.fixture +def contract_with_constructor_address_factory(w3): + return w3.eth.contract(**CONSTRUCTOR_WITH_ADDRESS_ARGUMENT_CONTRACT_DATA) -@pytest.fixture() -def address_contract( - w3, WithConstructorAddressArgumentsContract, address_conversion_func +@pytest.fixture +def contract_with_constructor_address( + w3, contract_with_constructor_address_factory, address_conversion_func ): return deploy( w3, - WithConstructorAddressArgumentsContract, + contract_with_constructor_address_factory, address_conversion_func, args=["0xd3CdA913deB6f67967B99D67aCDFa1712C293601"], ) -CONTRACT_ADDRESS_REFLECTOR_CODE = "6060604052341561000f57600080fd5b6101ca8061001e6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630b816c1614610048578063c04d11fc146100c157600080fd5b341561005357600080fd5b61007f600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610170565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156100cc57600080fd5b61011960048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190505061017a565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561015c578082015181840152602081019050610141565b505050509050019250505060405180910390f35b6000819050919050565b61018261018a565b819050919050565b6020604051908101604052806000815250905600a165627a7a723058206b15d98a803b91327d94f943e9712291539701b2f7370e10f5873633941484930029" # noqa: 501 -CONTRACT_ADDRESS_REFLECTOR_RUNTIME = "60606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630b816c1614610048578063c04d11fc146100c157600080fd5b341561005357600080fd5b61007f600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610170565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156100cc57600080fd5b61011960048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190505061017a565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561015c578082015181840152602081019050610141565b505050509050019250505060405180910390f35b6000819050919050565b61018261018a565b819050919050565b6020604051908101604052806000815250905600a165627a7a723058206b15d98a803b91327d94f943e9712291539701b2f7370e10f5873633941484930029" # noqa: 501 -CONTRACT_ADDRESS_REFLECTOR_ABI = json.loads( - '[{"constant":true,"inputs":[{"name":"arg","type":"address"}],"name":"reflect","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"name":"arg","type":"address[]"}],"name":"reflect","outputs":[{"name":"","type":"address[]"}],"payable":false,"stateMutability":"pure","type":"function"}]' # noqa: 501 -) - - -@pytest.fixture() -def AddressReflectorContract(w3): - return w3.eth.contract( - abi=CONTRACT_ADDRESS_REFLECTOR_ABI, - bytecode=CONTRACT_ADDRESS_REFLECTOR_CODE, - bytecode_runtime=CONTRACT_ADDRESS_REFLECTOR_RUNTIME, +@pytest.fixture +def address_reflector_contract(w3, address_conversion_func): + address_reflector_contract_factory = w3.eth.contract( + **ADDRESS_REFLECTOR_CONTRACT_DATA ) + return deploy(w3, address_reflector_contract_factory, address_conversion_func) -@pytest.fixture() -def address_reflector_contract(w3, AddressReflectorContract, address_conversion_func): - return deploy(w3, AddressReflectorContract, address_conversion_func) - - -CONTRACT_STRING_CODE = "0x6060604052604051610496380380610496833981016040528051018060006000509080519060200190828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10608d57805160ff19168380011785555b50607c9291505b8082111560ba57838155600101606b565b5050506103d8806100be6000396000f35b828001600101855582156064579182015b828111156064578251826000505591602001919060010190609e565b509056606060405260e060020a600035046320965255811461003c57806330de3cee1461009f5780633fa4f245146100c457806393a0935214610121575b005b6101c7600060608181528154602060026001831615610100026000190190921691909104601f810182900490910260a0908101604052608082815292939190828280156102605780601f1061023557610100808354040283529160200191610260565b6101c7600060609081526101a06040526101006080818152906102d860a03990505b90565b6101c760008054602060026001831615610100026000190190921691909104601f810182900490910260809081016040526060828152929190828280156102975780601f1061026c57610100808354040283529160200191610297565b60206004803580820135601f81018490049093026080908101604052606084815261003a946024939192918401918190838280828437509496505050505050508060006000509080519060200190828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061029f57805160ff19168380011785555b506102cf9291505b808211156102d4578381556001016101b4565b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600f02600301f150905090810190601f1680156102275780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b820191906000526020600020905b81548152906001019060200180831161024357829003601f168201915b505050505090506100c1565b820191906000526020600020905b81548152906001019060200180831161027a57829003601f168201915b505050505081565b828001600101855582156101ac579182015b828111156101ac5782518260005055916020019190600101906102b1565b505050565b509056000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff" # noqa: E501 -CONTRACT_STRING_RUNTIME = "0x606060405260e060020a600035046320965255811461003c57806330de3cee1461009f5780633fa4f245146100c457806393a0935214610121575b005b6101c7600060608181528154602060026001831615610100026000190190921691909104601f810182900490910260a0908101604052608082815292939190828280156102605780601f1061023557610100808354040283529160200191610260565b6101c7600060609081526101a06040526101006080818152906102d860a03990505b90565b6101c760008054602060026001831615610100026000190190921691909104601f810182900490910260809081016040526060828152929190828280156102975780601f1061026c57610100808354040283529160200191610297565b60206004803580820135601f81018490049093026080908101604052606084815261003a946024939192918401918190838280828437509496505050505050508060006000509080519060200190828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061029f57805160ff19168380011785555b506102cf9291505b808211156102d4578381556001016101b4565b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600f02600301f150905090810190601f1680156102275780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b820191906000526020600020905b81548152906001019060200180831161024357829003601f168201915b505050505090506100c1565b820191906000526020600020905b81548152906001019060200180831161027a57829003601f168201915b505050505081565b828001600101855582156101ac579182015b828111156101ac5782518260005055916020019190600101906102b1565b505050565b509056000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff" # noqa: E501 -CONTRACT_STRING_ABI = json.loads( - '[{"constant":false,"inputs":[],"name":"getValue","outputs":[{"name":"","type":"string"}],"type":"function"},{"constant":false,"inputs":[],"name":"constValue","outputs":[{"name":"","type":"string"}],"type":"function"},{"constant":true,"inputs":[],"name":"value","outputs":[{"name":"","type":"string"}],"type":"function"},{"constant":false,"inputs":[{"name":"_value","type":"string"}],"name":"setValue","outputs":[],"type":"function"},{"inputs":[{"name":"_value","type":"string"}],"type":"constructor"}]' # noqa: E501 -) - - -@pytest.fixture() -def STRING_CODE(): - return CONTRACT_STRING_CODE - - -@pytest.fixture() -def STRING_RUNTIME(): - return CONTRACT_STRING_RUNTIME - - -@pytest.fixture() -def STRING_ABI(): - return CONTRACT_STRING_ABI - - -@pytest.fixture() -def STRING_CONTRACT(STRING_CODE, STRING_RUNTIME, STRING_ABI): - return { - "bytecode": STRING_CODE, - "bytecode_runtime": STRING_RUNTIME, - "abi": STRING_ABI, - } +@pytest.fixture(scope="session") +def string_contract_data(): + return STRING_CONTRACT_DATA -@pytest.fixture() -def StringContract(w3, STRING_CONTRACT): - return w3.eth.contract(**STRING_CONTRACT) +@pytest.fixture +def string_contract_factory(w3, string_contract_data): + return w3.eth.contract(**STRING_CONTRACT_DATA) -@pytest.fixture() -def string_contract(w3, StringContract, address_conversion_func): - return deploy(w3, StringContract, address_conversion_func, args=["Caqalai"]) +@pytest.fixture +def string_contract(w3, string_contract_factory, address_conversion_func): + return deploy( + w3, string_contract_factory, address_conversion_func, args=["Caqalai"] + ) @pytest.fixture def non_strict_string_contract( - w3_non_strict_abi, STRING_CONTRACT, address_conversion_func + w3_non_strict_abi, string_contract_data, address_conversion_func ): - _non_strict_string_contract = w3_non_strict_abi.eth.contract(**STRING_CONTRACT) + _non_strict_string_contract_factory = w3_non_strict_abi.eth.contract( + **string_contract_data + ) return deploy( w3_non_strict_abi, - _non_strict_string_contract, + _non_strict_string_contract_factory, address_conversion_func, args=["Caqalai"], ) -CONTRACT_BYTES_CODE = "60606040526040805190810160405280600281526020017f01230000000000000000000000000000000000000000000000000000000000008152506000908051906020019061004f929190610096565b50341561005b57600080fd5b604051610723380380610723833981016040528080518201919050505b806001908051906020019061008e929190610116565b505b506101bb565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100d757805160ff1916838001178555610105565b82800160010185558215610105579182015b828111156101045782518255916020019190600101906100e9565b5b5090506101129190610196565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061015757805160ff1916838001178555610185565b82800160010185558215610185579182015b82811115610184578251825591602001919060010190610169565b5b5090506101929190610196565b5090565b6101b891905b808211156101b457600081600090555060010161019c565b5090565b90565b610559806101ca6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063209652551461005f57806330de3cee146100ee5780633fa4f2451461017d578063439970aa1461020c575b600080fd5b341561006a57600080fd5b610072610269565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100b35780820151818401525b602081019050610097565b50505050905090810190601f1680156100e05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156100f957600080fd5b610101610312565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101425780820151818401525b602081019050610126565b50505050905090810190601f16801561016f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561018857600080fd5b6101906103bb565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101d15780820151818401525b6020810190506101b5565b50505050905090810190601f1680156101fe5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561021757600080fd5b610267600480803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610459565b005b610271610474565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103075780601f106102dc57610100808354040283529160200191610307565b820191906000526020600020905b8154815290600101906020018083116102ea57829003601f168201915b505050505090505b90565b61031a610474565b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103b05780601f10610385576101008083540402835291602001916103b0565b820191906000526020600020905b81548152906001019060200180831161039357829003601f168201915b505050505090505b90565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104515780601f1061042657610100808354040283529160200191610451565b820191906000526020600020905b81548152906001019060200180831161043457829003601f168201915b505050505081565b806001908051906020019061046f929190610488565b505b50565b602060405190810160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106104c957805160ff19168380011785556104f7565b828001600101855582156104f7579182015b828111156104f65782518255916020019190600101906104db565b5b5090506105049190610508565b5090565b61052a91905b8082111561052657600081600090555060010161050e565b5090565b905600a165627a7a723058203ff916ee91add6247b20793745d1c6a8d8dcaa49d8c84fbbabb5c966fd9b6fc90029" # noqa: E501 -CONTRACT_BYTES_RUNTIME = "60606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063209652551461005f57806330de3cee146100ee5780633fa4f2451461017d578063439970aa1461020c575b600080fd5b341561006a57600080fd5b610072610269565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100b35780820151818401525b602081019050610097565b50505050905090810190601f1680156100e05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156100f957600080fd5b610101610312565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101425780820151818401525b602081019050610126565b50505050905090810190601f16801561016f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561018857600080fd5b6101906103bb565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101d15780820151818401525b6020810190506101b5565b50505050905090810190601f1680156101fe5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561021757600080fd5b610267600480803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610459565b005b610271610474565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103075780601f106102dc57610100808354040283529160200191610307565b820191906000526020600020905b8154815290600101906020018083116102ea57829003601f168201915b505050505090505b90565b61031a610474565b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103b05780601f10610385576101008083540402835291602001916103b0565b820191906000526020600020905b81548152906001019060200180831161039357829003601f168201915b505050505090505b90565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104515780601f1061042657610100808354040283529160200191610451565b820191906000526020600020905b81548152906001019060200180831161043457829003601f168201915b505050505081565b806001908051906020019061046f929190610488565b505b50565b602060405190810160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106104c957805160ff19168380011785556104f7565b828001600101855582156104f7579182015b828111156104f65782518255916020019190600101906104db565b5b5090506105049190610508565b5090565b61052a91905b8082111561052657600081600090555060010161050e565b5090565b905600a165627a7a723058203ff916ee91add6247b20793745d1c6a8d8dcaa49d8c84fbbabb5c966fd9b6fc90029" # noqa: E501 -CONTRACT_BYTES_ABI = json.loads( - '[{"constant":false,"inputs":[],"name":"getValue","outputs":[{"name":"","type":"bytes"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"constValue","outputs":[{"name":"","type":"bytes"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"value","outputs":[{"name":"","type":"bytes"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_value","type":"bytes"}],"name":"setValue","outputs":[],"payable":false,"type":"function"},{"inputs":[{"name":"_value","type":"bytes"}],"payable":false,"type":"constructor"}]' # noqa: E501 -) - - -@pytest.fixture() -def BYTES_CODE(): - return CONTRACT_BYTES_CODE - - -@pytest.fixture() -def BYTES_RUNTIME(): - return CONTRACT_BYTES_RUNTIME - - -@pytest.fixture() -def BYTES_ABI(): - return CONTRACT_BYTES_ABI - - -@pytest.fixture() -def BYTES_CONTRACT(BYTES_CODE, BYTES_RUNTIME, BYTES_ABI): - return { - "bytecode": BYTES_CODE, - "bytecode_runtime": BYTES_RUNTIME, - "abi": BYTES_ABI, - } - - -@pytest.fixture() -def BytesContract(w3, BYTES_CONTRACT): - return w3.eth.contract(**BYTES_CONTRACT) - - -@pytest.fixture() -def NonStrictBytesContract(w3_non_strict_abi, BYTES_CONTRACT): - return w3_non_strict_abi.eth.contract(**BYTES_CONTRACT) - - -CONTRACT_BYTES32_CODE = "60606040527f0123012301230123012301230123012301230123012301230123012301230123600090600019169055341561003957600080fd5b6040516020806101e2833981016040528080519060200190919050505b80600181600019169055505b505b61016f806100736000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063209652551461005f57806330de3cee146100905780633fa4f245146100c157806358825b10146100f2575b600080fd5b341561006a57600080fd5b610072610119565b60405180826000191660001916815260200191505060405180910390f35b341561009b57600080fd5b6100a3610124565b60405180826000191660001916815260200191505060405180910390f35b34156100cc57600080fd5b6100d461012e565b60405180826000191660001916815260200191505060405180910390f35b34156100fd57600080fd5b610117600480803560001916906020019091905050610134565b005b600060015490505b90565b6000805490505b90565b60015481565b80600181600019169055505b505600a165627a7a7230582043b15c20378b1603d330561258ccf291d08923a4c25fa8af0d590a010a6322180029" # noqa: E501 -CONTRACT_BYTES32_RUNTIME = "60606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063209652551461005f57806330de3cee146100905780633fa4f245146100c157806358825b10146100f2575b600080fd5b341561006a57600080fd5b610072610119565b60405180826000191660001916815260200191505060405180910390f35b341561009b57600080fd5b6100a3610124565b60405180826000191660001916815260200191505060405180910390f35b34156100cc57600080fd5b6100d461012e565b60405180826000191660001916815260200191505060405180910390f35b34156100fd57600080fd5b610117600480803560001916906020019091905050610134565b005b600060015490505b90565b6000805490505b90565b60015481565b80600181600019169055505b505600a165627a7a7230582043b15c20378b1603d330561258ccf291d08923a4c25fa8af0d590a010a6322180029" # noqa: E501 -CONTRACT_BYTES32_ABI = json.loads( - '[{"constant":false,"inputs":[],"name":"getValue","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"constValue","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"value","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_value","type":"bytes32"}],"name":"setValue","outputs":[],"payable":false,"type":"function"},{"inputs":[{"name":"_value","type":"bytes32"}],"payable":false,"type":"constructor"}]' # noqa: E501 -) - - -@pytest.fixture() -def BYTES32_CODE(): - return CONTRACT_BYTES32_CODE - - -@pytest.fixture() -def BYTES32_RUNTIME(): - return CONTRACT_BYTES32_RUNTIME - - -@pytest.fixture() -def BYTES32_ABI(): - return CONTRACT_BYTES32_ABI - - -@pytest.fixture() -def BYTES32_CONTRACT(BYTES32_CODE, BYTES32_RUNTIME, BYTES32_ABI): - return { - "bytecode": BYTES32_CODE, - "bytecode_runtime": BYTES32_RUNTIME, - "abi": BYTES32_ABI, - } - - -@pytest.fixture() -def Bytes32Contract(w3, BYTES32_CONTRACT): - return w3.eth.contract(**BYTES32_CONTRACT) - - -@pytest.fixture() -def EMITTER_CODE(): - return CONTRACT_EMITTER_CODE - - -@pytest.fixture() -def EMITTER_RUNTIME(): - return CONTRACT_EMITTER_RUNTIME - - -@pytest.fixture() -def EMITTER_ABI(): - return CONTRACT_EMITTER_ABI - - -@pytest.fixture() -def EMITTER(EMITTER_CODE, EMITTER_RUNTIME, EMITTER_ABI): - return { - "bytecode": EMITTER_CODE, - "bytecode_runtime": EMITTER_RUNTIME, - "abi": EMITTER_ABI, - } - - -@pytest.fixture -def NON_STRICT_EMITTER(EMITTER_CODE, EMITTER_RUNTIME, EMITTER_ABI): - return { - "bytecode": EMITTER_CODE, - "bytecode_runtime": EMITTER_RUNTIME, - "abi": EMITTER_ABI, - } - - -@pytest.fixture -def NonStrictEmitter(w3_non_strict_abi, NON_STRICT_EMITTER): - return w3_non_strict_abi.eth.contract(**NON_STRICT_EMITTER) - - @pytest.fixture def non_strict_emitter( w3_non_strict_abi, - NonStrictEmitter, + emitter_contract_data, wait_for_transaction, wait_for_block, address_conversion_func, ): + non_strict_emitter_contract_factory = w3_non_strict_abi.eth.contract( + **emitter_contract_data + ) w3 = w3_non_strict_abi wait_for_block(w3) - deploy_txn_hash = NonStrictEmitter.constructor().transact({"gas": 10000000}) + deploy_txn_hash = non_strict_emitter_contract_factory.constructor().transact( + {"gas": 10000000} + ) deploy_receipt = wait_for_transaction(w3, deploy_txn_hash) contract_address = address_conversion_func(deploy_receipt["contractAddress"]) bytecode = w3.eth.get_code(contract_address) - assert bytecode == NonStrictEmitter.bytecode_runtime - emitter_contract = NonStrictEmitter(address=contract_address) + assert bytecode == non_strict_emitter_contract_factory.bytecode_runtime + emitter_contract = non_strict_emitter_contract_factory(address=contract_address) assert emitter_contract.address == contract_address return emitter_contract -@pytest.fixture() -def EVENT_CONTRACT_CODE(): - return EVNT_CONTRACT_CODE - - -@pytest.fixture() -def EVENT_CONTRACT_RUNTIME(): - return EVNT_CONTRACT_RUNTIME - - -@pytest.fixture() -def EVENT_CONTRACT_ABI(): - return EVNT_CONTRACT_ABI - - -@pytest.fixture() -def EVENT_CONTRACT(EVENT_CONTRACT_CODE, EVENT_CONTRACT_RUNTIME, EVENT_CONTRACT_ABI): - return { - "bytecode": EVENT_CONTRACT_CODE, - "bytecode_runtime": EVENT_CONTRACT_RUNTIME, - "abi": EVENT_CONTRACT_ABI, - } - - -@pytest.fixture() -def EventContract(w3_empty, EVENT_CONTRACT): - w3 = w3_empty - return w3.eth.contract(**EVENT_CONTRACT) - - -@pytest.fixture() +@pytest.fixture def event_contract( - w3_empty, - EventContract, + w3, wait_for_transaction, wait_for_block, address_conversion_func, ): - - w3 = w3_empty - wait_for_block(w3) - deploy_txn_hash = EventContract.constructor().transact( + + event_contract_factory = w3.eth.contract(**EVENT_CONTRACT_DATA) + deploy_txn_hash = event_contract_factory.constructor().transact( {"from": w3.eth.coinbase, "gas": 1000000} ) deploy_receipt = wait_for_transaction(w3, deploy_txn_hash) contract_address = address_conversion_func(deploy_receipt["contractAddress"]) bytecode = w3.eth.get_code(contract_address) - assert bytecode == EventContract.bytecode_runtime - event_contract = EventContract(address=contract_address) + assert bytecode == event_contract_factory.bytecode_runtime + event_contract = event_contract_factory(address=contract_address) assert event_contract.address == contract_address return event_contract -@pytest.fixture() -def INDEXED_EVENT_CONTRACT_CODE(): - return IND_EVENT_CONTRACT_CODE - - -@pytest.fixture() -def INDEXED_EVENT_CONTRACT_RUNTIME(): - return IND_EVENT_CONTRACT_RUNTIME - - -@pytest.fixture() -def INDEXED_EVENT_CONTRACT_ABI(): - return IND_EVENT_CONTRACT_ABI - - -@pytest.fixture() -def INDEXED_EVENT_CONTRACT( - INDEXED_EVENT_CONTRACT_CODE, - INDEXED_EVENT_CONTRACT_RUNTIME, - INDEXED_EVENT_CONTRACT_ABI, -): - return { - "bytecode": INDEXED_EVENT_CONTRACT_CODE, - "bytecode_runtime": INDEXED_EVENT_CONTRACT_RUNTIME, - "abi": INDEXED_EVENT_CONTRACT_ABI, - } - - -@pytest.fixture() -def IndexedEventContract(w3_empty, INDEXED_EVENT_CONTRACT): - w3 = w3_empty - return w3.eth.contract(**INDEXED_EVENT_CONTRACT) - - -@pytest.fixture() -def indexed_event( - w3_empty, - IndexedEventContract, - wait_for_transaction, - wait_for_block, - address_conversion_func, +@pytest.fixture +def indexed_event_contract( + w3, wait_for_block, wait_for_transaction, address_conversion_func ): - - w3 = w3_empty - wait_for_block(w3) - deploy_txn_hash = IndexedEventContract.constructor().transact( + + indexed_event_contract_factory = w3.eth.contract(**INDEXED_EVENT_CONTRACT_DATA) + deploy_txn_hash = indexed_event_contract_factory.constructor().transact( {"from": w3.eth.coinbase, "gas": 1000000} ) deploy_receipt = wait_for_transaction(w3, deploy_txn_hash) contract_address = address_conversion_func(deploy_receipt["contractAddress"]) bytecode = w3.eth.get_code(contract_address) - assert bytecode == IndexedEventContract.bytecode_runtime - indexed_event_contract = IndexedEventContract(address=contract_address) + assert bytecode == indexed_event_contract_factory.bytecode_runtime + indexed_event_contract = indexed_event_contract_factory(address=contract_address) assert indexed_event_contract.address == contract_address return indexed_event_contract -CONTRACT_ARRAYS_SOURCE = """ - contract ArraysContract { - - bytes32[] public bytes32Value; - bytes32[] public bytes32ConstValue; - byte[] public byteValue; - byte[] public byteConstValue; - - function ArraysContract(bytes32[] _bytes32Value, byte[] _byteValue) { - bytes32Value = _bytes32Value; - byteValue = _byteValue; - bytes32ConstValue = [keccak256('A'), keccak256('B')]; - byteConstValue = [bytes1(0), bytes1(1)]; - } - - function setBytes32Value(bytes32[] _bytes32Value) { - bytes32Value = _bytes32Value; - } - - function getBytes32Value() returns (bytes32[]) { - return bytes32Value; - } - - function getBytes32ConstValue() returns (bytes32[]) { - return bytes32ConstValue; - } - - function setByteValue(byte[] _byteValue) { - byteValue = _byteValue; - } - - function getByteValue() returns (byte[]) { - return byteValue; - } - - function getByteConstValue() returns (byte[]) { - return byteConstValue; - } -} -""" -CONTRACT_ARRAYS_CODE = "606060405234156200001057600080fd5b60405162000e6238038062000e628339810160405280805182019190602001805182019190505081600090805190602001906200004f92919062000209565b5080600290805190602001906200006892919062000261565b50604080519081016040528060405180807f4100000000000000000000000000000000000000000000000000000000000000815250600101905060405180910390206000191660001916815260200160405180807f420000000000000000000000000000000000000000000000000000000000000081525060010190506040518091039020600019166000191681525060019060026200010a9291906200032f565b50604080519081016040528060007f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200160017f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191681525060039060026200020092919062000387565b505050620004b0565b8280548282559060005260206000209081019282156200024e579160200282015b828111156200024d5782518290600019169055916020019190600101906200022a565b5b5090506200025d919062000455565b5090565b82805482825590600052602060002090601f016020900481019282156200031c5791602002820160005b83821115620002eb57835183826101000a81548160ff02191690837f01000000000000000000000000000000000000000000000000000000000000009004021790555092602001926001016020816000010492830192600103026200028b565b80156200031a5782816101000a81549060ff0219169055600101602081600001049283019260010302620002eb565b505b5090506200032b91906200047d565b5090565b82805482825590600052602060002090810192821562000374579160200282015b828111156200037357825182906000191690559160200191906001019062000350565b5b50905062000383919062000455565b5090565b82805482825590600052602060002090601f01602090048101928215620004425791602002820160005b838211156200041157835183826101000a81548160ff02191690837f0100000000000000000000000000000000000000000000000000000000000000900402179055509260200192600101602081600001049283019260010302620003b1565b8015620004405782816101000a81549060ff021916905560010160208160000104928301926001030262000411565b505b5090506200045191906200047d565b5090565b6200047a91905b80821115620004765760008160009055506001016200045c565b5090565b90565b620004ad91905b80821115620004a957600081816101000a81549060ff02191690555060010162000484565b5090565b90565b6109a280620004c06000396000f300606060405236156100a2576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630afe5e33146100a757806312c9dcc8146101115780631579bf661461018c5780633ddcea2f146101f657806351b4878814610250578063542d83de1461028f578063605ba271146102ce5780638abe51fd14610338578063962e450c146103a2578063bb69679b1461041d575b600080fd5b34156100b257600080fd5b6100ba610477565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156100fd5780820151818401526020810190506100e2565b505050509050019250505060405180910390f35b341561011c57600080fd5b61013260048080359060200190919050506104d9565b60405180827effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200191505060405180910390f35b341561019757600080fd5b61019f61052b565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156101e25780820151818401526020810190506101c7565b505050509050019250505060405180910390f35b341561020157600080fd5b61024e6004808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919050506105ed565b005b341561025b57600080fd5b6102716004808035906020019091905050610607565b60405180826000191660001916815260200191505060405180910390f35b341561029a57600080fd5b6102b0600480803590602001909190505061062b565b60405180826000191660001916815260200191505060405180910390f35b34156102d957600080fd5b6102e161064f565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015610324578082015181840152602081019050610309565b505050509050019250505060405180910390f35b341561034357600080fd5b61034b6106b1565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561038e578082015181840152602081019050610373565b505050509050019250505060405180910390f35b34156103ad57600080fd5b6103c36004808035906020019091905050610773565b60405180827effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200191505060405180910390f35b341561042857600080fd5b6104756004808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919050506107c5565b005b61047f6107df565b60018054806020026020016040519081016040528092919081815260200182805480156104cf57602002820191906000526020600020905b815460001916815260200190600101908083116104b7575b5050505050905090565b6002818154811015156104e857fe5b9060005260206000209060209182820401919006915054906101000a90047f01000000000000000000000000000000000000000000000000000000000000000281565b6105336107f3565b60038054806020026020016040519081016040528092919081815260200182805480156105e357602002820191906000526020600020906000905b82829054906101000a90047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152602001906001019060208260000104928301926001038202915080841161056e5790505b5050505050905090565b8060029080519060200190610603929190610807565b5050565b60018181548110151561061657fe5b90600052602060002090016000915090505481565b60008181548110151561063a57fe5b90600052602060002090016000915090505481565b6106576107df565b60008054806020026020016040519081016040528092919081815260200182805480156106a757602002820191906000526020600020905b8154600019168152602001906001019080831161068f575b5050505050905090565b6106b96107f3565b600280548060200260200160405190810160405280929190818152602001828054801561076957602002820191906000526020600020906000905b82829054906101000a90047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190600101906020826000010492830192600103820291508084116106f45790505b5050505050905090565b60038181548110151561078257fe5b9060005260206000209060209182820401919006915054906101000a90047f01000000000000000000000000000000000000000000000000000000000000000281565b80600090805190602001906107db9291906108ce565b5050565b602060405190810160405280600081525090565b602060405190810160405280600081525090565b82805482825590600052602060002090601f016020900481019282156108bd5791602002820160005b8382111561088e57835183826101000a81548160ff02191690837f0100000000000000000000000000000000000000000000000000000000000000900402179055509260200192600101602081600001049283019260010302610830565b80156108bb5782816101000a81549060ff021916905560010160208160000104928301926001030261088e565b505b5090506108ca9190610921565b5090565b828054828255906000526020600020908101928215610910579160200282015b8281111561090f5782518290600019169055916020019190600101906108ee565b5b50905061091d9190610951565b5090565b61094e91905b8082111561094a57600081816101000a81549060ff021916905550600101610927565b5090565b90565b61097391905b8082111561096f576000816000905550600101610957565b5090565b905600a165627a7a72305820d0caf89bd0d39b343a907ac9d0f0b9bcddb1b8dc910706160d9d26fdc552afa40029" # noqa: E501 -CONTRACT_ARRAYS_RUNTIME = "0x606060405236156100a2576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630afe5e33146100a757806312c9dcc8146101115780631579bf661461018c5780633ddcea2f146101f657806351b4878814610250578063542d83de1461028f578063605ba271146102ce5780638abe51fd14610338578063962e450c146103a2578063bb69679b1461041d575b600080fd5b34156100b257600080fd5b6100ba610477565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156100fd5780820151818401526020810190506100e2565b505050509050019250505060405180910390f35b341561011c57600080fd5b61013260048080359060200190919050506104d9565b60405180827effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200191505060405180910390f35b341561019757600080fd5b61019f61052b565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156101e25780820151818401526020810190506101c7565b505050509050019250505060405180910390f35b341561020157600080fd5b61024e6004808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919050506105ed565b005b341561025b57600080fd5b6102716004808035906020019091905050610607565b60405180826000191660001916815260200191505060405180910390f35b341561029a57600080fd5b6102b0600480803590602001909190505061062b565b60405180826000191660001916815260200191505060405180910390f35b34156102d957600080fd5b6102e161064f565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015610324578082015181840152602081019050610309565b505050509050019250505060405180910390f35b341561034357600080fd5b61034b6106b1565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561038e578082015181840152602081019050610373565b505050509050019250505060405180910390f35b34156103ad57600080fd5b6103c36004808035906020019091905050610773565b60405180827effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200191505060405180910390f35b341561042857600080fd5b6104756004808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919050506107c5565b005b61047f6107df565b60018054806020026020016040519081016040528092919081815260200182805480156104cf57602002820191906000526020600020905b815460001916815260200190600101908083116104b7575b5050505050905090565b6002818154811015156104e857fe5b9060005260206000209060209182820401919006915054906101000a90047f01000000000000000000000000000000000000000000000000000000000000000281565b6105336107f3565b60038054806020026020016040519081016040528092919081815260200182805480156105e357602002820191906000526020600020906000905b82829054906101000a90047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152602001906001019060208260000104928301926001038202915080841161056e5790505b5050505050905090565b8060029080519060200190610603929190610807565b5050565b60018181548110151561061657fe5b90600052602060002090016000915090505481565b60008181548110151561063a57fe5b90600052602060002090016000915090505481565b6106576107df565b60008054806020026020016040519081016040528092919081815260200182805480156106a757602002820191906000526020600020905b8154600019168152602001906001019080831161068f575b5050505050905090565b6106b96107f3565b600280548060200260200160405190810160405280929190818152602001828054801561076957602002820191906000526020600020906000905b82829054906101000a90047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190600101906020826000010492830192600103820291508084116106f45790505b5050505050905090565b60038181548110151561078257fe5b9060005260206000209060209182820401919006915054906101000a90047f01000000000000000000000000000000000000000000000000000000000000000281565b80600090805190602001906107db9291906108ce565b5050565b602060405190810160405280600081525090565b602060405190810160405280600081525090565b82805482825590600052602060002090601f016020900481019282156108bd5791602002820160005b8382111561088e57835183826101000a81548160ff02191690837f0100000000000000000000000000000000000000000000000000000000000000900402179055509260200192600101602081600001049283019260010302610830565b80156108bb5782816101000a81549060ff021916905560010160208160000104928301926001030261088e565b505b5090506108ca9190610921565b5090565b828054828255906000526020600020908101928215610910579160200282015b8281111561090f5782518290600019169055916020019190600101906108ee565b5b50905061091d9190610951565b5090565b61094e91905b8082111561094a57600081816101000a81549060ff021916905550600101610927565b5090565b90565b61097391905b8082111561096f576000816000905550600101610957565b5090565b905600a165627a7a72305820d0caf89bd0d39b343a907ac9d0f0b9bcddb1b8dc910706160d9d26fdc552afa40029" # noqa: E501 -CONTRACT_ARRAYS_ABI = json.loads( - '[{"constant": false, "inputs": [], "name": "getBytes32ConstValue", "outputs": [{"name": "", "type": "bytes32[]"}], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": true, "inputs": [{"name": "", "type": "uint256"}], "name": "byteValue", "outputs": [{"name": "", "type": "bytes1"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": false, "inputs": [], "name": "getByteConstValue", "outputs": [{"name": "", "type": "bytes1[]"}], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": false, "inputs": [{"name": "_byteValue", "type": "bytes1[]"}], "name": "setByteValue", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": true, "inputs": [{"name": "", "type": "uint256"}], "name": "bytes32ConstValue", "outputs": [{"name": "", "type": "bytes32"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": true, "inputs": [{"name": "", "type": "uint256"}], "name": "bytes32Value", "outputs": [{"name": "", "type": "bytes32"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": false, "inputs": [], "name": "getBytes32Value", "outputs": [{"name": "", "type": "bytes32[]"}], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": false, "inputs": [], "name": "getByteValue", "outputs": [{"name": "", "type": "bytes1[]"}], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"constant": true, "inputs": [{"name": "", "type": "uint256"}], "name": "byteConstValue", "outputs": [{"name": "", "type": "bytes1"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": false, "inputs": [{"name": "_bytes32Value", "type": "bytes32[]"}], "name": "setBytes32Value", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"name": "_bytes32Value", "type": "bytes32[]"}, {"name": "_byteValue", "type": "bytes1[]"}], "payable": false, "stateMutability": "nonpayable", "type": "constructor"}]' # noqa: E501 -) - - -@pytest.fixture() -def ARRAYS_CODE(): - return CONTRACT_ARRAYS_CODE - - -@pytest.fixture() -def ARRAYS_RUNTIME(): - return CONTRACT_ARRAYS_RUNTIME - - -@pytest.fixture() -def ARRAYS_ABI(): - return CONTRACT_ARRAYS_ABI - - -@pytest.fixture() -def ARRAYS_CONTRACT(ARRAYS_CODE, ARRAYS_RUNTIME, ARRAYS_ABI): - return { - "bytecode": ARRAYS_CODE, - "bytecode_runtime": ARRAYS_RUNTIME, - "abi": ARRAYS_ABI, - } - - -@pytest.fixture() -def ArraysContract(w3, ARRAYS_CONTRACT): - return w3.eth.contract(**ARRAYS_CONTRACT) +# bytes_32 = [keccak('0'), keccak('1')] +BYTES32_ARRAY = [ + b"\x04HR\xb2\xa6p\xad\xe5@~x\xfb(c\xc5\x1d\xe9\xfc\xb9eB\xa0q\x86\xfe:\xed\xa6\xbb\x8a\x11m", # noqa: E501 + b"\xc8\x9e\xfd\xaaT\xc0\xf2\x0cz\xdfa(\x82\xdf\tP\xf5\xa9Qc~\x03\x07\xcd\xcbLg/)\x8b\x8b\xc6", # noqa: E501 +] +BYTES1_ARRAY = [b"\xff", b"\xff", b"\xff", b"\xff"] -@pytest.fixture() -def arrays_contract(w3, ArraysContract, address_conversion_func): - # bytes_32 = [keccak('0'), keccak('1')] - bytes32_array = [ - b"\x04HR\xb2\xa6p\xad\xe5@~x\xfb(c\xc5\x1d\xe9\xfc\xb9eB\xa0q\x86\xfe:\xed\xa6\xbb\x8a\x11m", # noqa: E501 - b"\xc8\x9e\xfd\xaaT\xc0\xf2\x0cz\xdfa(\x82\xdf\tP\xf5\xa9Qc~\x03\x07\xcd\xcbLg/)\x8b\x8b\xc6", # noqa: E501 - ] - byte_arr = [b"\xff", b"\xff", b"\xff", b"\xff"] +@pytest.fixture +def arrays_contract(w3, address_conversion_func): + arrays_contract_factory = w3.eth.contract(**ARRAYS_CONTRACT_DATA) return deploy( - w3, ArraysContract, address_conversion_func, args=[bytes32_array, byte_arr] + w3, + arrays_contract_factory, + address_conversion_func, + args=[BYTES32_ARRAY, BYTES1_ARRAY], ) -@pytest.fixture() -def NonStrictArraysContract(w3_non_strict_abi, ARRAYS_CONTRACT): - return w3_non_strict_abi.eth.contract(**ARRAYS_CONTRACT) - - -@pytest.fixture() -def non_strict_arrays_contract( - w3_non_strict_abi, NonStrictArraysContract, address_conversion_func -): - # bytes_32 = [keccak('0'), keccak('1')] - bytes32_array = [ - b"\x04HR\xb2\xa6p\xad\xe5@~x\xfb(c\xc5\x1d\xe9\xfc\xb9eB\xa0q\x86\xfe:\xed\xa6\xbb\x8a\x11m", # noqa: E501 - b"\xc8\x9e\xfd\xaaT\xc0\xf2\x0cz\xdfa(\x82\xdf\tP\xf5\xa9Qc~\x03\x07\xcd\xcbLg/)\x8b\x8b\xc6", # noqa: E501 - ] - byte_arr = [b"\xff", b"\xff", b"\xff", b"\xff"] +@pytest.fixture +def non_strict_arrays_contract(w3_non_strict_abi, address_conversion_func): + non_strict_arrays_contract_factory = w3_non_strict_abi.eth.contract( + **ARRAYS_CONTRACT_DATA + ) return deploy( w3_non_strict_abi, - NonStrictArraysContract, + non_strict_arrays_contract_factory, address_conversion_func, - args=[bytes32_array, byte_arr], + args=[BYTES32_ARRAY, BYTES1_ARRAY], ) -CONTRACT_PAYABLE_TESTER_SOURCE = """ -contract PayableTester { - bool public wasCalled; - - function doNoValueCall() public { - wasCalled = true; - } -} -""" -CONTRACT_PAYABLE_TESTER_CODE = "608060405234801561001057600080fd5b5060e88061001f6000396000f3006080604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063c680362214604e578063e4cb8f5c14607a575b600080fd5b348015605957600080fd5b506060608e565b604051808215151515815260200191505060405180910390f35b348015608557600080fd5b50608c60a0565b005b6000809054906101000a900460ff1681565b60016000806101000a81548160ff0219169083151502179055505600a165627a7a723058205362c7376eda918b0dc3a75d0ffab904a241c9b10b68d5268af6ca405242303e0029" # noqa: E501 -CONTRACT_PAYABLE_TESTER_RUNTIME = "6080604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063c680362214604e578063e4cb8f5c14607a575b600080fd5b348015605957600080fd5b506060608e565b604051808215151515815260200191505060405180910390f35b348015608557600080fd5b50608c60a0565b005b6000809054906101000a900460ff1681565b60016000806101000a81548160ff0219169083151502179055505600a165627a7a723058205362c7376eda918b0dc3a75d0ffab904a241c9b10b68d5268af6ca405242303e0029" # noqa: E501 -CONTRACT_PAYABLE_TESTER_ABI = json.loads( - '[{"constant": true, "inputs": [], "name": "wasCalled", "outputs": [{"name": "", "type": "bool"}], "payable": false, "stateMutability": "view", "type": "function"}, {"constant": false, "inputs": [], "name": "doNoValueCall", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function"}]' # noqa: E501 -) - - -@pytest.fixture() -def PAYABLE_TESTER_CODE(): - return CONTRACT_PAYABLE_TESTER_CODE - - -@pytest.fixture() -def PAYABLE_TESTER_RUNTIME(): - return CONTRACT_PAYABLE_TESTER_RUNTIME - - -@pytest.fixture() -def PAYABLE_TESTER_ABI(): - return CONTRACT_PAYABLE_TESTER_ABI - - -@pytest.fixture() -def PAYABLE_TESTER_CONTRACT( - PAYABLE_TESTER_CODE, PAYABLE_TESTER_RUNTIME, PAYABLE_TESTER_ABI -): - return { - "bytecode": PAYABLE_TESTER_CODE, - "bytecode_runtime": PAYABLE_TESTER_RUNTIME, - "abi": PAYABLE_TESTER_ABI, - } - - -@pytest.fixture() -def PayableTesterContract(w3, PAYABLE_TESTER_CONTRACT): - return w3.eth.contract(**PAYABLE_TESTER_CONTRACT) - - -@pytest.fixture() -def payable_tester_contract(w3, PayableTesterContract, address_conversion_func): - return deploy(w3, PayableTesterContract, address_conversion_func) +@pytest.fixture +def payable_tester_contract(w3, address_conversion_func): + payable_tester_contract_factory = w3.eth.contract(**PAYABLE_TESTER_CONTRACT_DATA) + return deploy(w3, payable_tester_contract_factory, address_conversion_func) # no matter the function selector, this will return back the 32 bytes of data supplied -CONTRACT_REFLECTION_CODE = "0x610011566020600460003760206000f3005b61000461001103610004600039610004610011036000f3" # noqa: E501 +FIXED_REFLECTOR_CONTRACT_BYTECODE = "0x610011566020600460003760206000f3005b61000461001103610004600039610004610011036000f3" # noqa: E501 # reference source used to generate it: LLL_SOURCE = "['seq', ['return', 0, ['lll', ['seq', ['calldatacopy', 0, 4, 32], ['return', 0, 32], 'stop' ], 0]]])" # noqa: E501 -CONTRACT_FIXED_ABI = [ +FIXED_REFLECTOR_CONTRACT_ABI = [ { "type": "function", "constant": False, @@ -844,274 +295,52 @@ def payable_tester_contract(w3, PayableTesterContract, address_conversion_func): @pytest.fixture -def FixedReflectionContract(w3): - return w3.eth.contract(abi=CONTRACT_FIXED_ABI, bytecode=CONTRACT_REFLECTION_CODE) - - -@pytest.fixture() -def FALLBACK_FUNCTION_CODE(): - return CONTRACT_FALLBACK_FUNCTION_CODE - - -@pytest.fixture() -def FALLBACK_FUNCTION_RUNTIME(): - return CONTRACT_FALLBACK_FUNCTION_RUNTIME - - -@pytest.fixture() -def FALLBACK_FUNCTION_ABI(): - return CONTRACT_FALLBACK_FUNCTION_ABI - - -@pytest.fixture() -def FALLBACK_FUNCTION_CONTRACT( - FALLBACK_FUNCTION_CODE, FALLBACK_FUNCTION_RUNTIME, FALLBACK_FUNCTION_ABI -): - return { - "bytecode": FALLBACK_FUNCTION_CODE, - "bytecode_runtime": FALLBACK_FUNCTION_RUNTIME, - "abi": FALLBACK_FUNCTION_ABI, - } - - -@pytest.fixture() -def FallbackFunctionContract(w3, FALLBACK_FUNCTION_CONTRACT): - return w3.eth.contract(**FALLBACK_FUNCTION_CONTRACT) - - -@pytest.fixture() -def fallback_function_contract(w3, FallbackFunctionContract, address_conversion_func): - return deploy(w3, FallbackFunctionContract, address_conversion_func) - - -@pytest.fixture() -def RECEIVE_FUNCTION_CODE(): - return CONTRACT_RECEIVE_FUNCTION_CODE - - -@pytest.fixture() -def RECEIVE_FUNCTION_RUNTIME(): - return CONTRACT_RECEIVE_FUNCTION_RUNTIME - - -@pytest.fixture() -def RECEIVE_FUNCTION_ABI(): - return CONTRACT_RECEIVE_FUNCTION_ABI - - -@pytest.fixture() -def RECEIVE_FUNCTION_CONTRACT( - RECEIVE_FUNCTION_CODE, RECEIVE_FUNCTION_RUNTIME, RECEIVE_FUNCTION_ABI -): - return { - "bytecode": RECEIVE_FUNCTION_CODE, - "bytecode_runtime": RECEIVE_FUNCTION_RUNTIME, - "abi": RECEIVE_FUNCTION_ABI, - } - - -@pytest.fixture() -def NO_RECEIVE_FUNCTION_CODE(): - return CONTRACT_NO_RECEIVE_FUNCTION_CODE - - -@pytest.fixture() -def NO_RECEIVE_FUNCTION_RUNTIME(): - return CONTRACT_NO_RECEIVE_FUNCTION_RUNTIME - - -@pytest.fixture() -def NO_RECEIVE_FUNCTION_ABI(): - return CONTRACT_NO_RECEIVE_FUNCTION_ABI - - -@pytest.fixture() -def NO_RECEIVE_FUNCTION_CONTRACT( - NO_RECEIVE_FUNCTION_CODE, NO_RECEIVE_FUNCTION_RUNTIME, NO_RECEIVE_FUNCTION_ABI -): - return { - "bytecode": NO_RECEIVE_FUNCTION_CODE, - "bytecode_runtime": NO_RECEIVE_FUNCTION_RUNTIME, - "abi": NO_RECEIVE_FUNCTION_ABI, - } - - -@pytest.fixture() -def NoReceiveFunctionContract(w3, NO_RECEIVE_FUNCTION_CONTRACT): - return w3.eth.contract(**NO_RECEIVE_FUNCTION_CONTRACT) - - -@pytest.fixture() -def no_receive_function_contract( - w3, NoReceiveFunctionContract, address_conversion_func -): - return deploy(w3, NoReceiveFunctionContract, address_conversion_func) - - -@pytest.fixture() -def ReceiveFunctionContract(w3, RECEIVE_FUNCTION_CONTRACT): - return w3.eth.contract(**RECEIVE_FUNCTION_CONTRACT) - - -@pytest.fixture() -def receive_function_contract(w3, ReceiveFunctionContract, address_conversion_func): - return deploy(w3, ReceiveFunctionContract, address_conversion_func) - - -CONTRACT_CALLER_TESTER_SOURCE = """ -contract CallerTester { - int public count; - - function add(int256 a, int256 b) public payable returns (int256) { - return a + b; - } - - function increment() public returns (int256) { - return count += 1; - } - - function counter() public payable returns (int256) { - return count; - } - - function returnMeta() public payable returns (address, bytes memory, uint256, uint, uint) { # noqa: E501 - return (msg.sender, msg.data, gasleft(), msg.value, block.number); - } -} -""" - - -CONTRACT_CALLER_TESTER_CODE = "608060405234801561001057600080fd5b50610241806100206000396000f3fe608060405260043610610066577c0100000000000000000000000000000000000000000000000000000000600035046306661abd811461006b57806361bc221a14610092578063a5f3c23b1461009a578063c7fa7d66146100bd578063d09de08a14610185575b600080fd5b34801561007757600080fd5b5061008061019a565b60408051918252519081900360200190f35b6100806101a0565b610080600480360360408110156100b057600080fd5b50803590602001356101a6565b6100c56101aa565b604051808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001858152602001848152602001838152602001828103825286818151815260200191508051906020019080838360005b8381101561014657818101518382015260200161012e565b50505050905090810190601f1680156101735780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390f35b34801561019157600080fd5b50610080610207565b60005481565b60005490565b0190565b600060606000806000336000365a344385955084848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250989e929d50949b5092995090975095505050505050565b60008054600101908190559056fea165627a7a72305820ffe1620e420efa326b9c5e4ef9f93cac71cf986196246c7966d71a39259899b10029" # noqa: E501 -CONTRACT_CALLER_TESTER_RUNTIME = "608060405260043610610066577c0100000000000000000000000000000000000000000000000000000000600035046306661abd811461006b57806361bc221a14610092578063a5f3c23b1461009a578063c7fa7d66146100bd578063d09de08a14610185575b600080fd5b34801561007757600080fd5b5061008061019a565b60408051918252519081900360200190f35b6100806101a0565b610080600480360360408110156100b057600080fd5b50803590602001356101a6565b6100c56101aa565b604051808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001858152602001848152602001838152602001828103825286818151815260200191508051906020019080838360005b8381101561014657818101518382015260200161012e565b50505050905090810190601f1680156101735780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390f35b34801561019157600080fd5b50610080610207565b60005481565b60005490565b0190565b600060606000806000336000365a344385955084848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250989e929d50949b5092995090975095505050505050565b60008054600101908190559056fea165627a7a72305820ffe1620e420efa326b9c5e4ef9f93cac71cf986196246c7966d71a39259899b10029" # noqa: E501 -CONTRACT_CALLER_TESTER_ABI = json.loads( - '[ { "constant": true, "inputs": [], "name": "count", "outputs": [ { "name": "", "type": "int256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [], "name": "counter", "outputs": [ { "name": "", "type": "int256" } ], "payable": true, "stateMutability": "payable", "type": "function" }, { "constant": false, "inputs": [ { "name": "a", "type": "int256" }, { "name": "b", "type": "int256" } ], "name": "add", "outputs": [ { "name": "", "type": "int256" } ], "payable": true, "stateMutability": "payable", "type": "function" }, { "constant": false, "inputs": [], "name": "returnMeta", "outputs": [ { "name": "", "type": "address" }, { "name": "", "type": "bytes" }, { "name": "", "type": "uint256" }, { "name": "", "type": "uint256" }, { "name": "", "type": "uint256" } ], "payable": true, "stateMutability": "payable", "type": "function" }, { "constant": false, "inputs": [], "name": "increment", "outputs": [ { "name": "", "type": "int256" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" } ]' # noqa: E501 -) - - -@pytest.fixture() -def CALLER_TESTER_CODE(): - return CONTRACT_CALLER_TESTER_CODE - - -@pytest.fixture() -def CALLER_TESTER_RUNTIME(): - return CONTRACT_CALLER_TESTER_RUNTIME - - -@pytest.fixture() -def CALLER_TESTER_ABI(): - return CONTRACT_CALLER_TESTER_ABI - - -@pytest.fixture() -def CALLER_TESTER_CONTRACT( - CALLER_TESTER_CODE, CALLER_TESTER_RUNTIME, CALLER_TESTER_ABI -): - return { - "bytecode": CALLER_TESTER_CODE, - "bytecode_runtime": CALLER_TESTER_RUNTIME, - "abi": CALLER_TESTER_ABI, - } - - -@pytest.fixture() -def CallerTesterContract(w3, CALLER_TESTER_CONTRACT): - return w3.eth.contract(**CALLER_TESTER_CONTRACT) +def fixed_reflector_contract(w3, address_conversion_func): + fixed_reflector_contract_factory = w3.eth.contract( + abi=FIXED_REFLECTOR_CONTRACT_ABI, bytecode=FIXED_REFLECTOR_CONTRACT_BYTECODE + ) + return deploy(w3, fixed_reflector_contract_factory, address_conversion_func) -@pytest.fixture() -def REVERT_CONTRACT_CODE(): - return REVERT_CONTRACT_BYTECODE +@pytest.fixture +def fallback_function_contract(w3, address_conversion_func): + fallback_function_contract_factory = w3.eth.contract( + **FALLBACK_FUNCTION_CONTRACT_DATA + ) + return deploy(w3, fallback_function_contract_factory, address_conversion_func) -@pytest.fixture() -def REVERT_CONTRACT_RUNTIME(): - return REVERT_CONTRACT_RUNTIME_CODE +@pytest.fixture +def receive_function_contract(w3, address_conversion_func): + receive_function_contract_factory = w3.eth.contract( + **RECEIVE_FUNCTION_CONTRACT_DATA + ) + return deploy(w3, receive_function_contract_factory, address_conversion_func) -@pytest.fixture() -def REVERT_CONTRACT_ABI(): - return _REVERT_CONTRACT_ABI +@pytest.fixture +def no_receive_function_contract(w3, address_conversion_func): + no_receive_function_contract_factory = w3.eth.contract( + **NO_RECEIVE_FUNCTION_CONTRACT_DATA + ) + return deploy(w3, no_receive_function_contract_factory, address_conversion_func) -@pytest.fixture() -def REVERT_FUNCTION_CONTRACT( - REVERT_CONTRACT_CODE, REVERT_CONTRACT_RUNTIME, REVERT_CONTRACT_ABI -): - return { - "bytecode": REVERT_CONTRACT_CODE, - "bytecode_runtime": REVERT_CONTRACT_RUNTIME, - "abi": REVERT_CONTRACT_ABI, - } - - -@pytest.fixture() -def RevertContract(w3, REVERT_FUNCTION_CONTRACT): - return w3.eth.contract(**REVERT_FUNCTION_CONTRACT) - - -@pytest.fixture() -def revert_contract(w3, RevertContract, address_conversion_func): - return deploy(w3, RevertContract, address_conversion_func) - - -class LogFunctions: - LogAnonymous = 0 - LogNoArguments = 1 - LogSingleArg = 2 - LogDoubleArg = 3 - LogTripleArg = 4 - LogQuadrupleArg = 5 - LogSingleAnonymous = 6 - LogSingleWithIndex = 7 - LogDoubleAnonymous = 8 - LogDoubleWithIndex = 9 - LogTripleWithIndex = 10 - LogQuadrupleWithIndex = 11 - LogBytes = 12 - - -@pytest.fixture() -def emitter_event_ids(): - return LogFunctions - - -def _encode_to_topic(event_signature): - return event_signature_to_log_topic(event_signature) - - -class LogTopics: - LogAnonymous = _encode_to_topic("LogAnonymous()") - LogNoArguments = _encode_to_topic("LogNoArguments()") - LogSingleArg = _encode_to_topic("LogSingleArg(uint256)") - LogSingleAnonymous = _encode_to_topic("LogSingleAnonymous(uint256)") - LogSingleWithIndex = _encode_to_topic("LogSingleWithIndex(uint256)") - LogDoubleArg = _encode_to_topic("LogDoubleArg(uint256,uint256)") - LogDoubleAnonymous = _encode_to_topic("LogDoubleAnonymous(uint256,uint256)") - LogDoubleWithIndex = _encode_to_topic("LogDoubleWithIndex(uint256,uint256)") - LogTripleArg = _encode_to_topic("LogTripleArg(uint256,uint256,uint256)") - LogTripleWithIndex = _encode_to_topic("LogTripleWithIndex(uint256,uint256,uint256)") - LogQuadrupleArg = _encode_to_topic( - "LogQuadrupleArg(uint256,uint256,uint256,uint256)" - ) - LogQuadrupleWithIndex = _encode_to_topic( - "LogQuadrupleWithIndex(uint256,uint256,uint256,uint256)", +@pytest.fixture +def contract_caller_tester_contract(w3, address_conversion_func): + contract_caller_tester_contract_factory = w3.eth.contract( + **CONTRACT_CALLER_TESTER_DATA ) - LogBytes = _encode_to_topic("LogBytes(bytes)") - LogString = _encode_to_topic("LogString(string)") - LogDynamicArgs = _encode_to_topic("LogDynamicArgs(string,string)") - LogListArgs = _encode_to_topic("LogListArgs(bytes2[],bytes2[])") - LogAddressIndexed = _encode_to_topic("LogAddressIndexed(address,address)") - LogAddressNotIndexed = _encode_to_topic("LogAddressNotIndexed(address,address)") - LogStructArgs = _encode_to_topic("LogStructArgs(uint256,tuple)") + return deploy(w3, contract_caller_tester_contract_factory, address_conversion_func) -@pytest.fixture() -def emitter_log_topics(): - return LogTopics +@pytest.fixture +def revert_contract(w3, address_conversion_func): + revert_contract_factory = w3.eth.contract(**REVERT_CONTRACT_DATA) + return deploy(w3, revert_contract_factory, address_conversion_func) -@pytest.fixture() +@pytest.fixture def some_address(address_conversion_func): return address_conversion_func("0x5B2063246F2191f18F2675ceDB8b28102e957458") @@ -1159,261 +388,179 @@ def estimate_gas(request): # --- async --- # -@pytest.fixture() -def AsyncNestedTupleContract(async_w3, NESTED_TUPLE_CONTRACT): - return async_w3.eth.contract(**NESTED_TUPLE_CONTRACT) - - -@pytest.fixture() -def AsyncTupleContract(async_w3, TUPLE_CONTRACT): - return async_w3.eth.contract(**TUPLE_CONTRACT) +@pytest.fixture +def async_math_contract_factory(async_w3): + return async_w3.eth.contract(**MATH_CONTRACT_DATA) -@pytest.fixture() -def AsyncMathContract(async_w3, MATH_ABI, MATH_CODE, MATH_RUNTIME): - return async_w3.eth.contract( - abi=MATH_ABI, bytecode=MATH_CODE, bytecode_runtime=MATH_RUNTIME +@pytest_asyncio.fixture +async def async_math_contract( + async_w3, async_math_contract_factory, address_conversion_func +): + return await async_deploy( + async_w3, async_math_contract_factory, address_conversion_func ) -@pytest_asyncio.fixture() -async def async_math_contract(async_w3, AsyncMathContract, address_conversion_func): - return await async_deploy(async_w3, AsyncMathContract, address_conversion_func) +@pytest.fixture +def async_simple_constructor_contract_factory(async_w3): + return async_w3.eth.contract(**SIMPLE_CONSTRUCTOR_CONTRACT_DATA) -@pytest.fixture() -def AsyncSimpleConstructorContract( - async_w3, - SIMPLE_CONSTRUCTOR_CODE, - SIMPLE_CONSTRUCTOR_RUNTIME, - SIMPLE_CONSTRUCTOR_ABI, -): - return async_w3.eth.contract( - abi=SIMPLE_CONSTRUCTOR_ABI, - bytecode=SIMPLE_CONSTRUCTOR_CODE, - bytecode_runtime=SIMPLE_CONSTRUCTOR_RUNTIME, - ) +@pytest.fixture +def async_constructor_with_args_contract_factory(async_w3): + return async_w3.eth.contract(**CONSTRUCTOR_WITH_ARGUMENTS_CONTRACT_DATA) -@pytest.fixture() -def AsyncWithConstructorArgumentsContract( - async_w3, - WITH_CONSTRUCTOR_ARGUMENTS_CODE, - WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME, - WITH_CONSTRUCTOR_ARGUMENTS_ABI, -): - return async_w3.eth.contract( - abi=WITH_CONSTRUCTOR_ARGUMENTS_ABI, - bytecode=WITH_CONSTRUCTOR_ARGUMENTS_CODE, - bytecode_runtime=WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME, +@pytest.fixture +def async_non_strict_constructor_with_args_contract_factory(async_w3_non_strict_abi): + return async_w3_non_strict_abi.eth.contract( + **CONSTRUCTOR_WITH_ARGUMENTS_CONTRACT_DATA ) -@pytest.fixture() -def AsyncNonStrictWithConstructorArgumentsContract( - async_w3_non_strict_abi, - WITH_CONSTRUCTOR_ARGUMENTS_CODE, - WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME, - WITH_CONSTRUCTOR_ARGUMENTS_ABI, -): - return async_w3_non_strict_abi.eth.contract( - abi=WITH_CONSTRUCTOR_ARGUMENTS_ABI, - bytecode=WITH_CONSTRUCTOR_ARGUMENTS_CODE, - bytecode_runtime=WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME, - ) +@pytest.fixture +def async_constructor_with_address_arg_contract_factory(async_w3): + return async_w3.eth.contract(**CONSTRUCTOR_WITH_ADDRESS_ARGUMENT_CONTRACT_DATA) -@pytest.fixture() -def AsyncWithConstructorAddressArgumentsContract( +@pytest_asyncio.fixture +async def async_constructor_with_address_argument_contract( async_w3, - WITH_CONSTRUCTOR_ADDRESS_CODE, - WITH_CONSTRUCTOR_ADDRESS_RUNTIME, - WITH_CONSTRUCTOR_ADDRESS_ABI, + address_conversion_func, ): - return async_w3.eth.contract( - abi=WITH_CONSTRUCTOR_ADDRESS_ABI, - bytecode=WITH_CONSTRUCTOR_ADDRESS_CODE, - bytecode_runtime=WITH_CONSTRUCTOR_ADDRESS_RUNTIME, + async_constructor_with_address_arg_factory = async_w3.eth.contract( + **CONSTRUCTOR_WITH_ADDRESS_ARGUMENT_CONTRACT_DATA ) - - -@pytest_asyncio.fixture() -async def async_address_contract( - async_w3, AsyncWithConstructorAddressArgumentsContract, address_conversion_func -): return await async_deploy( async_w3, - AsyncWithConstructorAddressArgumentsContract, + async_constructor_with_address_arg_factory, address_conversion_func, args=["0xd3CdA913deB6f67967B99D67aCDFa1712C293601"], ) -@pytest.fixture() -def AsyncAddressReflectorContract(async_w3): - return async_w3.eth.contract( - abi=CONTRACT_ADDRESS_REFLECTOR_ABI, - bytecode=CONTRACT_ADDRESS_REFLECTOR_CODE, - bytecode_runtime=CONTRACT_ADDRESS_REFLECTOR_RUNTIME, +@pytest_asyncio.fixture +async def async_address_reflector_contract(async_w3, address_conversion_func): + async_address_reflector_contract_factory = async_w3.eth.contract( + **ADDRESS_REFLECTOR_CONTRACT_DATA, ) - - -@pytest_asyncio.fixture() -async def async_address_reflector_contract( - async_w3, AsyncAddressReflectorContract, address_conversion_func -): return await async_deploy( - async_w3, AsyncAddressReflectorContract, address_conversion_func + async_w3, async_address_reflector_contract_factory, address_conversion_func ) -@pytest.fixture() -def AsyncStringContract(async_w3, STRING_CONTRACT): - return async_w3.eth.contract(**STRING_CONTRACT) +@pytest.fixture +def async_string_contract_factory(async_w3): + return async_w3.eth.contract(**STRING_CONTRACT_DATA) -@pytest_asyncio.fixture() -async def async_string_contract(async_w3, AsyncStringContract, address_conversion_func): +@pytest_asyncio.fixture +async def async_string_contract( + async_w3, async_string_contract_factory, address_conversion_func +): return await async_deploy( - async_w3, AsyncStringContract, address_conversion_func, args=["Caqalai"] + async_w3, + async_string_contract_factory, + address_conversion_func, + args=["Caqalai"], ) -@pytest.fixture() -def AsyncBytesContract(async_w3, BYTES_CONTRACT): - return async_w3.eth.contract(**BYTES_CONTRACT) - - -@pytest.fixture() -def AsyncNonStrictBytesContract(async_w3_non_strict_abi, BYTES_CONTRACT): - return async_w3_non_strict_abi.eth.contract(**BYTES_CONTRACT) - - -@pytest.fixture() -def AsyncBytes32Contract(async_w3, BYTES32_CONTRACT): - return async_w3.eth.contract(**BYTES32_CONTRACT) - - -@pytest.fixture() -def AsyncArraysContract(async_w3, ARRAYS_CONTRACT): - return async_w3.eth.contract(**ARRAYS_CONTRACT) - - -@pytest_asyncio.fixture() -async def async_arrays_contract(async_w3, AsyncArraysContract, address_conversion_func): - # bytes_32 = [keccak('0'), keccak('1')] - bytes32_array = [ - b"\x04HR\xb2\xa6p\xad\xe5@~x\xfb(c\xc5\x1d\xe9\xfc\xb9eB\xa0q\x86\xfe:\xed\xa6\xbb\x8a\x11m", # noqa: E501 - b"\xc8\x9e\xfd\xaaT\xc0\xf2\x0cz\xdfa(\x82\xdf\tP\xf5\xa9Qc~\x03\x07\xcd\xcbLg/)\x8b\x8b\xc6", # noqa: E501 - ] - byte_arr = [b"\xff", b"\xff", b"\xff", b"\xff"] +@pytest_asyncio.fixture +async def async_arrays_contract(async_w3, address_conversion_func): + async_arrays_contract_factory = async_w3.eth.contract(**ARRAYS_CONTRACT_DATA) return await async_deploy( async_w3, - AsyncArraysContract, + async_arrays_contract_factory, address_conversion_func, - args=[bytes32_array, byte_arr], + args=[BYTES32_ARRAY, BYTES1_ARRAY], ) -@pytest.fixture() -def AsyncNonStrictArraysContract(async_w3_non_strict_abi, ARRAYS_CONTRACT): - return async_w3_non_strict_abi.eth.contract(**ARRAYS_CONTRACT) - - -@pytest_asyncio.fixture() +@pytest_asyncio.fixture async def async_non_strict_arrays_contract( - async_w3_non_strict_abi, AsyncNonStrictArraysContract, address_conversion_func + async_w3_non_strict_abi, address_conversion_func ): - # bytes_32 = [keccak('0'), keccak('1')] - bytes32_array = [ - b"\x04HR\xb2\xa6p\xad\xe5@~x\xfb(c\xc5\x1d\xe9\xfc\xb9eB\xa0q\x86\xfe:\xed\xa6\xbb\x8a\x11m", # noqa: E501 - b"\xc8\x9e\xfd\xaaT\xc0\xf2\x0cz\xdfa(\x82\xdf\tP\xf5\xa9Qc~\x03\x07\xcd\xcbLg/)\x8b\x8b\xc6", # noqa: E501 - ] - byte_arr = [b"\xff", b"\xff", b"\xff", b"\xff"] + async_non_strict_arrays_contract_factory = async_w3_non_strict_abi.eth.contract( + **ARRAYS_CONTRACT_DATA, + ) return await async_deploy( async_w3_non_strict_abi, - AsyncNonStrictArraysContract, + async_non_strict_arrays_contract_factory, address_conversion_func, - args=[bytes32_array, byte_arr], + args=[BYTES32_ARRAY, BYTES1_ARRAY], ) -@pytest.fixture() -def AsyncPayableTesterContract(async_w3, PAYABLE_TESTER_CONTRACT): - return async_w3.eth.contract(**PAYABLE_TESTER_CONTRACT) - - -@pytest_asyncio.fixture() -async def async_payable_tester_contract( - async_w3, AsyncPayableTesterContract, address_conversion_func -): +@pytest_asyncio.fixture +async def async_payable_tester_contract(async_w3, address_conversion_func): + async_payable_tester_contract_factory = async_w3.eth.contract( + **PAYABLE_TESTER_CONTRACT_DATA + ) return await async_deploy( - async_w3, AsyncPayableTesterContract, address_conversion_func + async_w3, async_payable_tester_contract_factory, address_conversion_func ) -@pytest.fixture -def AsyncFixedReflectionContract(async_w3): - return async_w3.eth.contract( - abi=CONTRACT_FIXED_ABI, bytecode=CONTRACT_REFLECTION_CODE +@pytest_asyncio.fixture +async def async_fixed_reflector_contract(async_w3, address_conversion_func): + async_fixed_reflector_contract_factory = async_w3.eth.contract( + abi=FIXED_REFLECTOR_CONTRACT_ABI, bytecode=FIXED_REFLECTOR_CONTRACT_BYTECODE ) - - -@pytest.fixture() -def AsyncFallbackFunctionContract(async_w3, FALLBACK_FUNCTION_CONTRACT): - return async_w3.eth.contract(**FALLBACK_FUNCTION_CONTRACT) - - -@pytest_asyncio.fixture() -async def async_fallback_function_contract( - async_w3, AsyncFallbackFunctionContract, address_conversion_func -): return await async_deploy( - async_w3, AsyncFallbackFunctionContract, address_conversion_func + async_w3, async_fixed_reflector_contract_factory, address_conversion_func ) -@pytest.fixture() -def AsyncNoReceiveFunctionContract(async_w3, NO_RECEIVE_FUNCTION_CONTRACT): - return async_w3.eth.contract(**NO_RECEIVE_FUNCTION_CONTRACT) - - -@pytest_asyncio.fixture() -async def async_no_receive_function_contract( - async_w3, AsyncNoReceiveFunctionContract, address_conversion_func -): +@pytest_asyncio.fixture +async def async_fallback_function_contract(async_w3, address_conversion_func): + async_fallback_function_contract_factory = async_w3.eth.contract( + **FALLBACK_FUNCTION_CONTRACT_DATA + ) return await async_deploy( - async_w3, AsyncNoReceiveFunctionContract, address_conversion_func + async_w3, async_fallback_function_contract_factory, address_conversion_func ) -@pytest.fixture() -def AsyncReceiveFunctionContract(async_w3, RECEIVE_FUNCTION_CONTRACT): - return async_w3.eth.contract(**RECEIVE_FUNCTION_CONTRACT) - - -@pytest_asyncio.fixture() -async def async_receive_function_contract( - async_w3, AsyncReceiveFunctionContract, address_conversion_func -): +@pytest_asyncio.fixture +async def async_no_receive_function_contract(async_w3, address_conversion_func): + async_no_receive_function_contract_factory = async_w3.eth.contract( + **NO_RECEIVE_FUNCTION_CONTRACT_DATA + ) return await async_deploy( - async_w3, AsyncReceiveFunctionContract, address_conversion_func + async_w3, async_no_receive_function_contract_factory, address_conversion_func ) -@pytest.fixture() -def AsyncCallerTesterContract(async_w3, CALLER_TESTER_CONTRACT): - return async_w3.eth.contract(**CALLER_TESTER_CONTRACT) +@pytest_asyncio.fixture +async def async_receive_function_contract(async_w3, address_conversion_func): + async_receive_function_contract_factory = async_w3.eth.contract( + **RECEIVE_FUNCTION_CONTRACT_DATA + ) + return await async_deploy( + async_w3, async_receive_function_contract_factory, address_conversion_func + ) -@pytest.fixture() -def AsyncRevertContract(async_w3, REVERT_FUNCTION_CONTRACT): - return async_w3.eth.contract(**REVERT_FUNCTION_CONTRACT) +@pytest_asyncio.fixture +async def async_contract_caller_tester_contract(async_w3, address_conversion_func): + async_contract_caller_tester_contract_factory = async_w3.eth.contract( + **CONTRACT_CALLER_TESTER_DATA + ) + return await async_deploy( + async_w3, + async_contract_caller_tester_contract_factory, + address_conversion_func, + ) -@pytest_asyncio.fixture() -async def async_revert_contract(async_w3, AsyncRevertContract, address_conversion_func): - return await async_deploy(async_w3, AsyncRevertContract, address_conversion_func) +@pytest_asyncio.fixture +async def async_revert_contract(async_w3, address_conversion_func): + async_revert_contract_factory = async_w3.eth.contract(**REVERT_CONTRACT_DATA) + return await async_deploy( + async_w3, async_revert_contract_factory, address_conversion_func + ) async def async_invoke_contract( @@ -1438,21 +585,21 @@ async def async_invoke_contract( return result -@pytest.fixture() +@pytest.fixture def async_build_transaction(request): return async_partial(async_invoke_contract, api_call_desig="build_transaction") -@pytest.fixture() +@pytest.fixture def async_transact(request): return async_partial(async_invoke_contract, api_call_desig="transact") -@pytest.fixture() +@pytest.fixture def async_call(request): return async_partial(async_invoke_contract, api_call_desig="call") -@pytest.fixture() +@pytest.fixture def async_estimate_gas(request): return async_partial(async_invoke_contract, api_call_desig="estimate_gas") diff --git a/tests/core/contracts/test_contract_ambiguous_functions.py b/tests/core/contracts/test_contract_ambiguous_functions.py index 9508e6c9fe..037d892a8c 100644 --- a/tests/core/contracts/test_contract_ambiguous_functions.py +++ b/tests/core/contracts/test_contract_ambiguous_functions.py @@ -45,13 +45,13 @@ ] -@pytest.fixture() -def string_contract(w3, StringContract, address_conversion_func): - deploy_txn = StringContract.constructor("Caqalai").transact() +@pytest.fixture +def string_contract(w3, string_contract_factory, address_conversion_func): + deploy_txn = string_contract_factory.constructor("Caqalai").transact() deploy_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None contract_address = address_conversion_func(deploy_receipt["contractAddress"]) - contract = StringContract(address=contract_address) + contract = string_contract_factory(address=contract_address) assert contract.address == contract_address assert len(w3.eth.get_code(contract.address)) > 0 return contract diff --git a/tests/core/contracts/test_contract_build_transaction.py b/tests/core/contracts/test_contract_build_transaction.py index 3d05e59894..754f5999d6 100644 --- a/tests/core/contracts/test_contract_build_transaction.py +++ b/tests/core/contracts/test_contract_build_transaction.py @@ -39,10 +39,12 @@ def test_build_transaction_paying_to_nonpayable_function( def test_build_transaction_with_contract_no_arguments( w3, math_contract, build_transaction ): - txn = build_transaction(contract=math_contract, contract_function="increment") + txn = build_transaction( + contract=math_contract, contract_function="incrementCounter" + ) assert dissoc(txn, "gas") == { "to": math_contract.address, - "data": "0xd09de08a", + "data": "0x5b34b966", "value": 0, "maxFeePerGas": 2750000000, "maxPriorityFeePerGas": 10**9, @@ -65,16 +67,16 @@ def test_build_transaction_with_contract_fallback_function( def test_build_transaction_with_contract_class_method( - w3, MathContract, math_contract, build_transaction + w3, math_contract_factory, math_contract, build_transaction ): txn = build_transaction( - contract=MathContract, - contract_function="increment", + contract=math_contract_factory, + contract_function="incrementCounter", tx_params={"to": math_contract.address}, ) assert dissoc(txn, "gas") == { "to": math_contract.address, - "data": "0xd09de08a", + "data": "0x5b34b966", "value": 0, "maxFeePerGas": 2750000000, "maxPriorityFeePerGas": 10**9, @@ -85,10 +87,12 @@ def test_build_transaction_with_contract_class_method( def test_build_transaction_with_contract_default_account_is_set( w3, math_contract, build_transaction ): - txn = build_transaction(contract=math_contract, contract_function="increment") + txn = build_transaction( + contract=math_contract, contract_function="incrementCounter" + ) assert dissoc(txn, "gas") == { "to": math_contract.address, - "data": "0xd09de08a", + "data": "0x5b34b966", "value": 0, "maxFeePerGas": 2750000000, "maxPriorityFeePerGas": 10**9, @@ -103,10 +107,12 @@ def my_gas_price_strategy(w3, transaction_params): return 5 w3.eth.set_gas_price_strategy(my_gas_price_strategy) - txn = build_transaction(contract=math_contract, contract_function="increment") + txn = build_transaction( + contract=math_contract, contract_function="incrementCounter" + ) assert dissoc(txn, "gas") == { "to": math_contract.address, - "data": "0xd09de08a", + "data": "0x5b34b966", "value": 0, "gasPrice": 5, "chainId": 131277322940537, @@ -119,7 +125,7 @@ def test_build_transaction_with_contract_data_supplied_errors( with pytest.raises(ValueError): build_transaction( contract=math_contract, - contract_function="increment", + contract_function="incrementCounter", tx_params={"data": "0x000"}, ) @@ -130,7 +136,7 @@ def test_build_transaction_with_contract_to_address_supplied_errors( with pytest.raises(ValueError): build_transaction( contract=math_contract, - contract_function="increment", + contract_function="incrementCounter", tx_params={"to": "0xb2930B35844a230f00E51431aCAe96Fe543a0347"}, ) @@ -143,7 +149,7 @@ def test_build_transaction_with_contract_to_address_supplied_errors( (5,), {}, { - "data": "0x7cf5dab00000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 + "data": "0x6abbb3b40000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 "value": 0, "maxFeePerGas": 2750000000, "maxPriorityFeePerGas": 1000000000, @@ -156,7 +162,7 @@ def test_build_transaction_with_contract_to_address_supplied_errors( (5,), {}, { - "data": "0x7cf5dab00000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 + "data": "0x6abbb3b40000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 "value": 0, "maxFeePerGas": 2750000000, "maxPriorityFeePerGas": 1000000000, @@ -169,7 +175,7 @@ def test_build_transaction_with_contract_to_address_supplied_errors( (5,), {}, { - "data": "0x7cf5dab00000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 + "data": "0x6abbb3b40000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 "value": 0, "gasPrice": 22**8, "chainId": 131277322940537, @@ -181,7 +187,7 @@ def test_build_transaction_with_contract_to_address_supplied_errors( (5,), {}, { - "data": "0x7cf5dab00000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 + "data": "0x6abbb3b40000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 "value": 0, "maxFeePerGas": 22**8, "maxPriorityFeePerGas": 22**8, @@ -194,7 +200,7 @@ def test_build_transaction_with_contract_to_address_supplied_errors( (5,), {}, { - "data": "0x7cf5dab00000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 + "data": "0x6abbb3b40000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 "value": 0, "maxFeePerGas": 2750000000, "maxPriorityFeePerGas": 1000000000, @@ -208,7 +214,7 @@ def test_build_transaction_with_contract_to_address_supplied_errors( (5,), {}, { - "data": "0x7cf5dab00000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 + "data": "0x6abbb3b40000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 "value": 20000, "maxFeePerGas": 2750000000, "maxPriorityFeePerGas": 1000000000, @@ -226,7 +232,7 @@ def test_build_transaction_with_contract_to_address_supplied_errors( "With Value", ], ) -def test_build_transaction_with_contract_with_arguments( +def test_build_transaction_with_contract_arguments( w3, skip_if_testrpc, math_contract, @@ -242,7 +248,7 @@ def test_build_transaction_with_contract_with_arguments( txn = build_transaction( contract=math_contract, - contract_function="increment", + contract_function="incrementCounter", func_args=method_args, func_kwargs=method_kwargs, tx_params=transaction_args, @@ -290,11 +296,11 @@ async def test_async_build_transaction_with_contract_no_arguments( async_w3, async_math_contract, async_build_transaction ): txn = await async_build_transaction( - contract=async_math_contract, contract_function="increment" + contract=async_math_contract, contract_function="incrementCounter" ) assert dissoc(txn, "gas") == { "to": async_math_contract.address, - "data": "0xd09de08a", + "data": "0x5b34b966", "value": 0, "maxFeePerGas": 2750000000, "maxPriorityFeePerGas": 10**9, @@ -319,16 +325,19 @@ async def test_async_build_transaction_with_contract_fallback_function( @pytest.mark.asyncio async def test_async_build_transaction_with_contract_class_method( - async_w3, AsyncMathContract, async_math_contract, async_build_transaction + async_w3, + async_math_contract_factory, + async_math_contract, + async_build_transaction, ): txn = await async_build_transaction( - contract=AsyncMathContract, - contract_function="increment", + contract=async_math_contract_factory, + contract_function="incrementCounter", tx_params={"to": async_math_contract.address}, ) assert dissoc(txn, "gas") == { "to": async_math_contract.address, - "data": "0xd09de08a", + "data": "0x5b34b966", "value": 0, "maxFeePerGas": 2750000000, "maxPriorityFeePerGas": 10**9, @@ -341,11 +350,11 @@ async def test_async_build_transaction_with_contract_default_account_is_set( async_w3, async_math_contract, async_build_transaction ): txn = await async_build_transaction( - contract=async_math_contract, contract_function="increment" + contract=async_math_contract, contract_function="incrementCounter" ) assert dissoc(txn, "gas") == { "to": async_math_contract.address, - "data": "0xd09de08a", + "data": "0x5b34b966", "value": 0, "maxFeePerGas": 2750000000, "maxPriorityFeePerGas": 10**9, @@ -362,11 +371,11 @@ def my_gas_price_strategy(async_w3, transaction_params): async_w3.eth.set_gas_price_strategy(my_gas_price_strategy) txn = await async_build_transaction( - contract=async_math_contract, contract_function="increment" + contract=async_math_contract, contract_function="incrementCounter" ) assert dissoc(txn, "gas") == { "to": async_math_contract.address, - "data": "0xd09de08a", + "data": "0x5b34b966", "value": 0, "gasPrice": 5, "chainId": 131277322940537, @@ -380,7 +389,7 @@ async def test_async_build_transaction_with_contract_data_supplied_errors( with pytest.raises(ValueError): await async_build_transaction( contract=async_math_contract, - contract_function="increment", + contract_function="incrementCounter", tx_params={"data": "0x000"}, ) @@ -392,9 +401,9 @@ async def test_async_build_transaction_with_contract_to_address_supplied_errors( with pytest.raises(ValueError): await async_build_transaction( contract=async_math_contract, - contract_function="increment", + contract_function="incrementCounter", tx_params={"to": "0xb2930B35844a230f00E51431aCAe96Fe543a0347"}, - ) # noqa: E501 + ) @pytest.mark.asyncio @@ -406,7 +415,7 @@ async def test_async_build_transaction_with_contract_to_address_supplied_errors( (5,), {}, { - "data": "0x7cf5dab00000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 + "data": "0x6abbb3b40000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 "value": 0, "maxFeePerGas": 2750000000, "maxPriorityFeePerGas": 1000000000, @@ -419,7 +428,7 @@ async def test_async_build_transaction_with_contract_to_address_supplied_errors( (5,), {}, { - "data": "0x7cf5dab00000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 + "data": "0x6abbb3b40000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 "value": 0, "maxFeePerGas": 2750000000, "maxPriorityFeePerGas": 1000000000, @@ -432,7 +441,7 @@ async def test_async_build_transaction_with_contract_to_address_supplied_errors( (5,), {}, { - "data": "0x7cf5dab00000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 + "data": "0x6abbb3b40000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 "value": 0, "gasPrice": 22**8, "chainId": 131277322940537, @@ -444,7 +453,7 @@ async def test_async_build_transaction_with_contract_to_address_supplied_errors( (5,), {}, { - "data": "0x7cf5dab00000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 + "data": "0x6abbb3b40000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 "value": 0, "maxFeePerGas": 22**8, "maxPriorityFeePerGas": 22**8, @@ -457,7 +466,7 @@ async def test_async_build_transaction_with_contract_to_address_supplied_errors( (5,), {}, { - "data": "0x7cf5dab00000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 + "data": "0x6abbb3b40000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 "value": 0, "maxFeePerGas": 2750000000, "maxPriorityFeePerGas": 1000000000, @@ -471,7 +480,7 @@ async def test_async_build_transaction_with_contract_to_address_supplied_errors( (5,), {}, { - "data": "0x7cf5dab00000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 + "data": "0x6abbb3b40000000000000000000000000000000000000000000000000000000000000005", # noqa: E501 "value": 20000, "maxFeePerGas": 2750000000, "maxPriorityFeePerGas": 1000000000, @@ -505,7 +514,7 @@ async def test_async_build_transaction_with_contract_with_arguments( txn = await async_build_transaction( contract=async_math_contract, - contract_function="increment", + contract_function="incrementCounter", func_args=method_args, func_kwargs=method_kwargs, tx_params=transaction_args, diff --git a/tests/core/contracts/test_contract_call_interface.py b/tests/core/contracts/test_contract_call_interface.py index fb22f482cf..4236d0766d 100644 --- a/tests/core/contracts/test_contract_call_interface.py +++ b/tests/core/contracts/test_contract_call_interface.py @@ -20,6 +20,14 @@ async_deploy, deploy, ) +from web3._utils.contract_sources.contract_data.bytes_contracts import ( + BYTES32_CONTRACT_DATA, + BYTES_CONTRACT_DATA, +) +from web3._utils.contract_sources.contract_data.tuple_contracts import ( + NESTED_TUPLE_CONTRACT_DATA, + TUPLE_CONTRACT_DATA, +) from web3._utils.ens import ( contract_ens_addresses, ) @@ -40,87 +48,101 @@ ) +@pytest.fixture +def tuple_contract(w3, address_conversion_func): + tuple_contract_factory = w3.eth.contract(**TUPLE_CONTRACT_DATA) + return deploy(w3, tuple_contract_factory, address_conversion_func) + + +@pytest.fixture +def nested_tuple_contract(w3, address_conversion_func): + nested_tuple_contract_factory = w3.eth.contract(**NESTED_TUPLE_CONTRACT_DATA) + return deploy(w3, nested_tuple_contract_factory, address_conversion_func) + + @pytest.fixture(params=[b"\x04\x06", "0x0406"]) -def bytes_contract(w3, BytesContract, request, address_conversion_func): - return deploy(w3, BytesContract, address_conversion_func, args=[request.param]) +def bytes_contract(w3, request, address_conversion_func): + bytes_contract_factory = w3.eth.contract(**BYTES_CONTRACT_DATA) + return deploy( + w3, bytes_contract_factory, address_conversion_func, args=[request.param] + ) @pytest.fixture(params=[b"\x04\x06", "0x0406"]) def non_strict_bytes_contract( - w3_non_strict_abi, NonStrictBytesContract, request, address_conversion_func + w3_non_strict_abi, + request, + address_conversion_func, ): + non_strict_bytes_contract_factory = w3_non_strict_abi.eth.contract( + **BYTES_CONTRACT_DATA + ) return deploy( w3_non_strict_abi, - NonStrictBytesContract, + non_strict_bytes_contract_factory, address_conversion_func, args=[request.param], ) -@pytest.fixture() -def fixed_reflection_contract(w3, FixedReflectionContract, address_conversion_func): - return deploy(w3, FixedReflectionContract, address_conversion_func) - - -@pytest.fixture() +@pytest.fixture def call_transaction(): return {"data": "0x61bc221a", "to": "0xc305c901078781C232A2a521C2aF7980f8385ee9"} +@pytest.fixture +def bytes32_contract_factory(w3): + return w3.eth.contract(**BYTES32_CONTRACT_DATA) + + @pytest.fixture( params=[ "0x0406040604060406040604060406040604060406040604060406040604060406", HexBytes("0406040604060406040604060406040604060406040604060406040604060406"), ] ) -def bytes32_contract(w3, Bytes32Contract, request, address_conversion_func): - return deploy(w3, Bytes32Contract, address_conversion_func, args=[request.param]) +def bytes32_contract(w3, bytes32_contract_factory, request, address_conversion_func): + return deploy( + w3, bytes32_contract_factory, address_conversion_func, args=[request.param] + ) -@pytest.fixture() -def undeployed_math_contract(MathContract, address_conversion_func): +@pytest.fixture +def undeployed_math_contract(math_contract_factory, address_conversion_func): empty_address = address_conversion_func( "0x000000000000000000000000000000000000dEaD" ) - _undeployed_math_contract = MathContract(address=empty_address) + _undeployed_math_contract = math_contract_factory(address=empty_address) return _undeployed_math_contract -@pytest.fixture() -def mismatched_math_contract(w3, StringContract, MathContract, address_conversion_func): - deploy_txn = StringContract.constructor("Caqalai").transact() +@pytest.fixture +def mismatched_math_contract( + w3, string_contract_factory, math_contract_factory, address_conversion_func +): + deploy_txn = string_contract_factory.constructor("Caqalai").transact() deploy_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None address = address_conversion_func(deploy_receipt["contractAddress"]) - _mismatched_math_contract = MathContract(address=address) + _mismatched_math_contract = math_contract_factory(address=address) return _mismatched_math_contract -@pytest.fixture() -def tuple_contract(w3, TupleContract, address_conversion_func): - return deploy(w3, TupleContract, address_conversion_func) - - -@pytest.fixture() -def nested_tuple_contract(w3, NestedTupleContract, address_conversion_func): - return deploy(w3, NestedTupleContract, address_conversion_func) - - def test_deploy_raises_due_to_strict_byte_checking_by_default( - w3, Bytes32Contract, address_conversion_func + w3, bytes32_contract_factory, address_conversion_func ): with pytest.raises(TypeError): deploy( w3, - Bytes32Contract, + bytes32_contract_factory, address_conversion_func, args=["0406040604060406040604060406040604060406040604060406040604060406"], ) -def test_invalid_address_in_deploy_arg(WithConstructorAddressArgumentsContract): +def test_invalid_address_in_deploy_arg(contract_with_constructor_address_factory): with pytest.raises(InvalidAddress): - WithConstructorAddressArgumentsContract.constructor( + contract_with_constructor_address_factory.constructor( "0xd3cda913deb6f67967b99d67acdfa1712c293601", ).transact() @@ -275,19 +297,21 @@ def test_call_get_byte_const_array_non_strict(non_strict_arrays_contract, call): assert result == expected_byte_arr -def test_call_read_address_variable(address_contract, call): - result = call(contract=address_contract, contract_function="testAddr") +def test_call_read_address_variable(contract_with_constructor_address, call): + result = call( + contract=contract_with_constructor_address, contract_function="testAddr" + ) assert result == "0xd3CdA913deB6f67967B99D67aCDFa1712C293601" -def test_init_with_ens_name_arg(w3, WithConstructorAddressArgumentsContract, call): +def test_init_with_ens_name_arg(w3, contract_with_constructor_address_factory, call): with contract_ens_addresses( - WithConstructorAddressArgumentsContract, + contract_with_constructor_address_factory, [("arg-name.eth", "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413")], ): address_contract = deploy( w3, - WithConstructorAddressArgumentsContract, + contract_with_constructor_address_factory, args=[ "arg-name.eth", ], @@ -451,6 +475,8 @@ def test_call_rejects_invalid_ens_name(address_reflector_contract, call): def test_call_missing_function(mismatched_math_contract, call): + # note: contract being called needs to have a fallback function + # (StringContract in this case) expected_missing_function_error_message = "Could not decode contract function call" with pytest.raises(BadFunctionCallOutput) as exception_info: call(contract=mismatched_math_contract, contract_function="return13") @@ -520,7 +546,7 @@ def test_throws_error_if_block_out_of_range(w3, math_contract): def test_accepts_latest_block(w3, math_contract): w3.provider.make_request(method="evm_mine", params=[5]) - math_contract.functions.increment().transact() + math_contract.functions.incrementCounter().transact() late = math_contract.functions.counter().call(block_identifier="latest") pend = math_contract.functions.counter().call(block_identifier="pending") @@ -531,7 +557,7 @@ def test_accepts_latest_block(w3, math_contract): def test_accepts_block_hash_as_identifier(w3, math_contract): blocks = w3.provider.make_request(method="evm_mine", params=[5]) - math_contract.functions.increment().transact() + math_contract.functions.incrementCounter().transact() more_blocks = w3.provider.make_request(method="evm_mine", params=[5]) old = math_contract.functions.counter().call(block_identifier=blocks["result"][2]) @@ -545,8 +571,8 @@ def test_accepts_block_hash_as_identifier(w3, math_contract): def test_neg_block_indexes_from_the_end(w3, math_contract): w3.provider.make_request(method="evm_mine", params=[5]) - math_contract.functions.increment().transact() - math_contract.functions.increment().transact() + math_contract.functions.incrementCounter().transact() + math_contract.functions.incrementCounter().transact() w3.provider.make_request(method="evm_mine", params=[5]) output1 = math_contract.functions.counter().call(block_identifier=-7) @@ -559,8 +585,8 @@ def test_neg_block_indexes_from_the_end(w3, math_contract): def test_returns_data_from_specified_block(w3, math_contract): start_num = w3.eth.get_block("latest").number w3.provider.make_request(method="evm_mine", params=[5]) - math_contract.functions.increment().transact() - math_contract.functions.increment().transact() + math_contract.functions.incrementCounter().transact() + math_contract.functions.incrementCounter().transact() output1 = math_contract.functions.counter().call(block_identifier=start_num + 6) output2 = math_contract.functions.counter().call(block_identifier=start_num + 7) @@ -724,8 +750,8 @@ def test_call_sending_ether_to_nonpayable_function(payable_tester_contract, call ("reflect_short_u", Decimal("25.5")), ), ) -def test_reflect_fixed_value(fixed_reflection_contract, function, value): - contract_func = fixed_reflection_contract.functions[function] +def test_reflect_fixed_value(fixed_reflector_contract, function, value): + contract_func = fixed_reflector_contract.functions[function] reflected = contract_func(value).call({"gas": 420000}) assert reflected == value @@ -763,9 +789,9 @@ def test_reflect_fixed_value(fixed_reflection_contract, function, value): ), ) def test_invalid_fixed_value_reflections( - fixed_reflection_contract, function, value, error + fixed_reflector_contract, function, value, error ): - contract_func = fixed_reflection_contract.functions[function] + contract_func = fixed_reflector_contract.functions[function] with pytest.raises(Web3ValidationError, match=error): contract_func(value).call({"gas": 420000}) @@ -974,7 +1000,7 @@ def test_changing_default_block_identifier(w3, math_contract): assert math_contract.caller.counter() == 0 assert w3.eth.default_block == "latest" - math_contract.functions.increment(7).transact() + math_contract.functions.incrementCounter(7).transact() assert math_contract.caller.counter() == 7 assert math_contract.functions.counter().call(block_identifier=1) == 0 @@ -988,18 +1014,40 @@ def test_changing_default_block_identifier(w3, math_contract): @pytest_asyncio.fixture -async def async_bytes_contract(async_w3, AsyncBytesContract, address_conversion_func): +async def async_tuple_contract(async_w3, address_conversion_func): + async_tuple_contract_factory = async_w3.eth.contract(**TUPLE_CONTRACT_DATA) + return await async_deploy( + async_w3, async_tuple_contract_factory, address_conversion_func + ) + + +@pytest_asyncio.fixture +async def async_nested_tuple_contract(async_w3, address_conversion_func): + async_nested_tuple_contract_factory = async_w3.eth.contract( + **NESTED_TUPLE_CONTRACT_DATA + ) return await async_deploy( - async_w3, AsyncBytesContract, address_conversion_func, args=[b"\x04\x06"] + async_w3, async_nested_tuple_contract_factory, address_conversion_func ) -@pytest_asyncio.fixture() -async def async_fixed_reflection_contract( - async_w3, AsyncFixedReflectionContract, address_conversion_func +@pytest.fixture +def async_bytes_contract_factory(async_w3): + return async_w3.eth.contract(**BYTES_CONTRACT_DATA) + + +@pytest_asyncio.fixture(params=[b"\x04\x06", "0x0406"]) +async def async_bytes_contract( + async_w3, + request, + async_bytes_contract_factory, + address_conversion_func, ): return await async_deploy( - async_w3, AsyncFixedReflectionContract, address_conversion_func + async_w3, + async_bytes_contract_factory, + address_conversion_func, + args=[request.param], ) @@ -1007,57 +1055,48 @@ async def async_fixed_reflection_contract( params=[ "0x0406040604060406040604060406040604060406040604060406040604060406", HexBytes("0406040604060406040604060406040604060406040604060406040604060406"), - ] + ], ) -async def async_bytes32_contract( - async_w3, AsyncBytes32Contract, request, address_conversion_func -): +async def async_bytes32_contract(async_w3, request, address_conversion_func): + async_bytes32_contract_factory = async_w3.eth.contract(**BYTES32_CONTRACT_DATA) return await async_deploy( async_w3, - AsyncBytes32Contract, + async_bytes32_contract_factory, address_conversion_func, args=[request.param], ) -@pytest_asyncio.fixture() -async def async_undeployed_math_contract(AsyncMathContract, address_conversion_func): +@pytest_asyncio.fixture +async def async_undeployed_math_contract( + async_math_contract_factory, address_conversion_func +): empty_address = address_conversion_func( "0x000000000000000000000000000000000000dEaD" ) - _undeployed_math_contract = AsyncMathContract(address=empty_address) + _undeployed_math_contract = async_math_contract_factory(address=empty_address) return _undeployed_math_contract -@pytest_asyncio.fixture() +@pytest_asyncio.fixture async def async_mismatched_math_contract( - async_w3, AsyncStringContract, AsyncMathContract, address_conversion_func + async_w3, + async_string_contract_factory, + async_math_contract_factory, + address_conversion_func, ): - deploy_txn = await AsyncStringContract.constructor("Caqalai").transact() + deploy_txn = await async_string_contract_factory.constructor("Caqalai").transact() deploy_receipt = await async_w3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None address = address_conversion_func(deploy_receipt["contractAddress"]) - _mismatched_math_contract = AsyncMathContract(address=address) + _mismatched_math_contract = async_math_contract_factory(address=address) return _mismatched_math_contract -@pytest_asyncio.fixture() -async def async_tuple_contract(async_w3, AsyncTupleContract, address_conversion_func): - return await async_deploy(async_w3, AsyncTupleContract, address_conversion_func) - - -@pytest_asyncio.fixture() -async def async_nested_tuple_contract( - async_w3, AsyncNestedTupleContract, address_conversion_func -): - return await async_deploy( - async_w3, AsyncNestedTupleContract, address_conversion_func - ) - - +@pytest.fixture @pytest.mark.asyncio async def test_async_deploy_raises_due_to_strict_byte_checking_by_default( - async_w3, AsyncBytesContract, address_conversion_func + async_w3, async_bytes_contract_factory, address_conversion_func ): with pytest.raises( TypeError, @@ -1065,7 +1104,10 @@ async def test_async_deploy_raises_due_to_strict_byte_checking_by_default( "Expected types are: bytes", ): await async_deploy( - async_w3, AsyncBytesContract, address_conversion_func, args=["0406"] + async_w3, + async_bytes_contract_factory, + address_conversion_func, + args=["0406"], ) @@ -1073,13 +1115,15 @@ async def test_async_deploy_raises_due_to_strict_byte_checking_by_default( @pytest.mark.parametrize("args", ("0x0406", "0406", HexBytes("0406"), b"\x04\x06")) async def test_async_deploy_with_non_strict_abi_check( async_w3_non_strict_abi, - AsyncNonStrictBytesContract, address_conversion_func, args, ): + async_non_strict_bytes_contract_factory = async_w3_non_strict_abi.eth.contract( + **BYTES_CONTRACT_DATA + ) deployed_contract = await async_deploy( async_w3_non_strict_abi, - AsyncNonStrictBytesContract, + async_non_strict_bytes_contract_factory, address_conversion_func, args=[args], ) @@ -1089,10 +1133,10 @@ async def test_async_deploy_with_non_strict_abi_check( @pytest.mark.asyncio async def test_async_invalid_address_in_deploy_arg( - AsyncWithConstructorAddressArgumentsContract, + async_constructor_with_address_arg_contract_factory, ): with pytest.raises(InvalidAddress): - await AsyncWithConstructorAddressArgumentsContract.constructor( + await async_constructor_with_address_arg_contract_factory.constructor( "0xd3cda913deb6f67967b99d67acdfa1712c293601", ).transact() @@ -1251,9 +1295,12 @@ async def test_async_call_get_byte_const_array_non_strict( @pytest.mark.asyncio -async def test_async_call_read_address_variable(async_address_contract, async_call): +async def test_async_call_read_address_variable( + async_constructor_with_address_argument_contract, async_call +): result = await async_call( - contract=async_address_contract, contract_function="testAddr" + contract=async_constructor_with_address_argument_contract, + contract_function="testAddr", ) assert result == "0xd3CdA913deB6f67967B99D67aCDFa1712C293601" @@ -1261,15 +1308,15 @@ async def test_async_call_read_address_variable(async_address_contract, async_ca @pytest.mark.xfail @pytest.mark.asyncio async def test_async_init_with_ens_name_arg( - async_w3, AsyncWithConstructorAddressArgumentsContract, async_call + async_w3, async_constructor_with_address_arg_contract_factory, async_call ): with contract_ens_addresses( - AsyncWithConstructorAddressArgumentsContract, + async_constructor_with_address_arg_contract_factory, [("arg-name.eth", "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413")], ): address_contract = await async_deploy( async_w3, - AsyncWithConstructorAddressArgumentsContract, + async_constructor_with_address_arg_contract_factory, args=[ "arg-name.eth", ], @@ -1457,6 +1504,8 @@ async def test_async_call_rejects_invalid_ens_name( @pytest.mark.asyncio async def test_async_call_missing_function(async_mismatched_math_contract, async_call): + # note: contract being called needs to have a fallback function + # (StringContract in this case) expected_missing_function_error_message = "Could not decode contract function call" with pytest.raises(BadFunctionCallOutput) as exception_info: await async_call( @@ -1540,7 +1589,7 @@ async def test_async_throws_error_if_block_out_of_range(async_w3, async_math_con @pytest.mark.asyncio async def test_async_accepts_latest_block(async_w3, async_math_contract): await async_w3.provider.make_request(method="evm_mine", params=[5]) - await async_math_contract.functions.increment().transact() + await async_math_contract.functions.incrementCounter().transact() late = await async_math_contract.functions.counter().call(block_identifier="latest") pend = await async_math_contract.functions.counter().call( @@ -1554,7 +1603,7 @@ async def test_async_accepts_latest_block(async_w3, async_math_contract): @pytest.mark.asyncio async def test_async_accepts_block_hash_as_identifier(async_w3, async_math_contract): blocks = await async_w3.provider.make_request(method="evm_mine", params=[5]) - await async_math_contract.functions.increment().transact() + await async_math_contract.functions.incrementCounter().transact() more_blocks = await async_w3.provider.make_request(method="evm_mine", params=[5]) old = await async_math_contract.functions.counter().call( @@ -1571,8 +1620,8 @@ async def test_async_accepts_block_hash_as_identifier(async_w3, async_math_contr @pytest.mark.asyncio async def test_async_neg_block_indexes_from_the_end(async_w3, async_math_contract): await async_w3.provider.make_request(method="evm_mine", params=[5]) - await async_math_contract.functions.increment().transact() - await async_math_contract.functions.increment().transact() + await async_math_contract.functions.incrementCounter().transact() + await async_math_contract.functions.incrementCounter().transact() await async_w3.provider.make_request(method="evm_mine", params=[5]) output1 = await async_math_contract.functions.counter().call(block_identifier=-7) @@ -1683,9 +1732,9 @@ async def test_async_call_sending_ether_to_nonpayable_function( ), ) async def test_async_reflect_fixed_value( - async_fixed_reflection_contract, function, value + async_fixed_reflector_contract, function, value ): - contract_func = async_fixed_reflection_contract.functions[function] + contract_func = async_fixed_reflector_contract.functions[function] reflected = await contract_func(value).call({"gas": 420000}) assert reflected == value @@ -1724,9 +1773,9 @@ async def test_async_reflect_fixed_value( ), ) async def test_async_invalid_fixed_value_reflections( - async_fixed_reflection_contract, function, value, error + async_fixed_reflector_contract, function, value, error ): - contract_func = async_fixed_reflection_contract.functions[function] + contract_func = async_fixed_reflector_contract.functions[function] with pytest.raises(Web3ValidationError, match=error): await contract_func(value).call({"gas": 420000}) @@ -1952,8 +2001,8 @@ async def test_async_call_with_one_argument(async_math_contract, call): async def test_async_returns_data_from_specified_block(async_w3, async_math_contract): start_num = await async_w3.eth.get_block("latest") await async_w3.provider.make_request(method="evm_mine", params=[5]) - await async_math_contract.functions.increment().transact() - await async_math_contract.functions.increment().transact() + await async_math_contract.functions.incrementCounter().transact() + await async_math_contract.functions.incrementCounter().transact() output1 = await async_math_contract.functions.counter().call( block_identifier=start_num.number + 6 @@ -1971,7 +2020,7 @@ async def test_async_changing_default_block_identifier(async_w3, async_math_cont assert await async_math_contract.caller.counter() == 0 assert async_w3.eth.default_block == "latest" - await async_math_contract.functions.increment(7).transact() + await async_math_contract.functions.incrementCounter(7).transact() assert await async_math_contract.caller.counter() == 7 assert await async_math_contract.functions.counter().call(block_identifier=1) == 0 diff --git a/tests/core/contracts/test_contract_caller_interface.py b/tests/core/contracts/test_contract_caller_interface.py index ebda46b5a3..a644f3b081 100644 --- a/tests/core/contracts/test_contract_caller_interface.py +++ b/tests/core/contracts/test_contract_caller_interface.py @@ -1,11 +1,5 @@ import pytest -import pytest_asyncio - -from tests.core.contracts.utils import ( - async_deploy, - deploy, -) from web3.exceptions import ( MismatchedABI, NoABIFound, @@ -18,20 +12,6 @@ def address(w3): return w3.eth.accounts[1] -@pytest.fixture() -def caller_tester_contract(w3, CallerTesterContract, address_conversion_func): - return deploy(w3, CallerTesterContract, address_conversion_func) - - -@pytest_asyncio.fixture() -async def async_caller_tester_contract( - async_w3, AsyncCallerTesterContract, address_conversion_func -): - return await async_deploy( - async_w3, AsyncCallerTesterContract, address_conversion_func - ) - - @pytest.fixture() def transaction_dict(w3, address): return { @@ -98,8 +78,8 @@ def test_caller_with_block_identifier(w3, math_contract): assert math_contract.caller.counter() == 0 w3.provider.make_request(method="evm_mine", params=[5]) - math_contract.functions.increment().transact() - math_contract.functions.increment().transact() + math_contract.functions.incrementCounter().transact() + math_contract.functions.incrementCounter().transact() output1 = math_contract.caller(block_identifier=start_num + 6).counter() output2 = math_contract.caller(block_identifier=start_num + 7).counter() @@ -109,16 +89,16 @@ def test_caller_with_block_identifier(w3, math_contract): def test_caller_with_block_identifier_and_transaction_dict( - w3, caller_tester_contract, transaction_dict, address + w3, contract_caller_tester_contract, transaction_dict, address ): start_num = w3.eth.get_block("latest").number - assert caller_tester_contract.caller.counter() == 0 + assert contract_caller_tester_contract.caller.counter() == 0 w3.provider.make_request(method="evm_mine", params=[5]) - caller_tester_contract.functions.increment().transact() + contract_caller_tester_contract.functions.increment().transact() block_id = start_num + 6 - contract = caller_tester_contract.caller( + contract = contract_caller_tester_contract.caller( transaction=transaction_dict, block_identifier=block_id ) @@ -133,9 +113,9 @@ def test_caller_with_block_identifier_and_transaction_dict( def test_caller_with_transaction_keyword( - w3, caller_tester_contract, transaction_dict, address + w3, contract_caller_tester_contract, transaction_dict, address ): - contract = caller_tester_contract.caller(transaction=transaction_dict) + contract = contract_caller_tester_contract.caller(transaction=transaction_dict) sender, _, gasLeft, value, _ = contract.returnMeta() @@ -145,9 +125,9 @@ def test_caller_with_transaction_keyword( def test_caller_with_dict_but_no_transaction_keyword( - w3, caller_tester_contract, transaction_dict, address + w3, contract_caller_tester_contract, transaction_dict, address ): - contract = caller_tester_contract.caller(transaction_dict) + contract = contract_caller_tester_contract.caller(transaction_dict) sender, _, gasLeft, value, _ = contract.returnMeta() @@ -157,9 +137,9 @@ def test_caller_with_dict_but_no_transaction_keyword( def test_caller_with_args_and_no_transaction_keyword( - w3, caller_tester_contract, transaction_dict, address + w3, contract_caller_tester_contract, transaction_dict, address ): - contract = caller_tester_contract.caller(transaction_dict) + contract = contract_caller_tester_contract.caller(transaction_dict) sender, _, gasLeft, value, _ = contract.returnMeta() @@ -237,8 +217,8 @@ async def test_async_caller_with_block_identifier(async_w3, async_math_contract) assert await async_math_contract.caller.counter() == 0 await async_w3.provider.make_request(method="evm_mine", params=[5]) - await async_math_contract.functions.increment().transact() - await async_math_contract.functions.increment().transact() + await async_math_contract.functions.incrementCounter().transact() + await async_math_contract.functions.incrementCounter().transact() output1 = await async_math_contract.caller(block_identifier=start_num + 6).counter() output2 = await async_math_contract.caller(block_identifier=start_num + 7).counter() @@ -249,17 +229,17 @@ async def test_async_caller_with_block_identifier(async_w3, async_math_contract) @pytest.mark.asyncio async def test_async_caller_with_block_identifier_and_transaction_dict( - async_w3, async_caller_tester_contract, transaction_dict, address + async_w3, async_contract_caller_tester_contract, transaction_dict, address ): start = await async_w3.eth.get_block("latest") start_num = start.number - assert await async_caller_tester_contract.caller.counter() == 0 + assert await async_contract_caller_tester_contract.caller.counter() == 0 await async_w3.provider.make_request(method="evm_mine", params=[5]) - await async_caller_tester_contract.functions.increment().transact() + await async_contract_caller_tester_contract.functions.increment().transact() block_id = start_num + 6 - contract = async_caller_tester_contract.caller( + contract = async_contract_caller_tester_contract.caller( transaction=transaction_dict, block_identifier=block_id ) @@ -275,9 +255,11 @@ async def test_async_caller_with_block_identifier_and_transaction_dict( @pytest.mark.asyncio async def test_async_caller_with_transaction_keyword( - async_w3, async_caller_tester_contract, transaction_dict, address + async_w3, async_contract_caller_tester_contract, transaction_dict, address ): - contract = async_caller_tester_contract.caller(transaction=transaction_dict) + contract = async_contract_caller_tester_contract.caller( + transaction=transaction_dict + ) sender, _, gasLeft, value, _ = await contract.returnMeta() @@ -288,9 +270,9 @@ async def test_async_caller_with_transaction_keyword( @pytest.mark.asyncio async def test_async_caller_with_dict_but_no_transaction_keyword( - async_w3, async_caller_tester_contract, transaction_dict, address + async_w3, async_contract_caller_tester_contract, transaction_dict, address ): - contract = async_caller_tester_contract.caller(transaction_dict) + contract = async_contract_caller_tester_contract.caller(transaction_dict) sender, _, gasLeft, value, _ = await contract.returnMeta() @@ -301,9 +283,9 @@ async def test_async_caller_with_dict_but_no_transaction_keyword( @pytest.mark.asyncio async def test_async_caller_with_args_and_no_transaction_keyword( - async_w3, async_caller_tester_contract, transaction_dict, address + async_w3, async_contract_caller_tester_contract, transaction_dict, address ): - contract = async_caller_tester_contract.caller(transaction_dict) + contract = async_contract_caller_tester_contract.caller(transaction_dict) sender, _, gasLeft, value, _ = await contract.returnMeta() diff --git a/tests/core/contracts/test_contract_class_construction.py b/tests/core/contracts/test_contract_class_construction.py index 022a27b796..b0d0c296c1 100644 --- a/tests/core/contracts/test_contract_class_construction.py +++ b/tests/core/contracts/test_contract_class_construction.py @@ -13,16 +13,18 @@ ) -def test_class_construction_sets_class_vars(w3, MATH_ABI, MATH_CODE, MATH_RUNTIME): - MathContract = w3.eth.contract( - abi=MATH_ABI, - bytecode=MATH_CODE, - bytecode_runtime=MATH_RUNTIME, +def test_class_construction_sets_class_vars( + w3, math_contract_abi, math_contract_bytecode, math_contract_runtime +): + math_contract_factory = w3.eth.contract( + abi=math_contract_abi, + bytecode=math_contract_bytecode, + bytecode_runtime=math_contract_runtime, ) - assert MathContract.w3 == w3 - assert MathContract.bytecode == decode_hex(MATH_CODE) - assert MathContract.bytecode_runtime == decode_hex(MATH_RUNTIME) + assert math_contract_factory.w3 == w3 + assert math_contract_factory.bytecode == decode_hex(math_contract_bytecode) + assert math_contract_factory.bytecode_runtime == decode_hex(math_contract_runtime) def test_error_to_instantiate_base_class(): @@ -30,21 +32,23 @@ def test_error_to_instantiate_base_class(): Contract() -def test_abi_as_json_string(w3, MATH_ABI, some_address): - abi_str = json.dumps(MATH_ABI) +def test_abi_as_json_string(w3, math_contract_abi, some_address): + abi_str = json.dumps(math_contract_abi) - MathContract = w3.eth.contract(abi=abi_str) - assert MathContract.abi == MATH_ABI + math_contract_factory = w3.eth.contract(abi=abi_str) + assert math_contract_factory.abi == math_contract_abi - math = MathContract(some_address) - assert math.abi == MATH_ABI + math = math_contract_factory(some_address) + assert math.abi == math_contract_abi -def test_error_to_call_non_existent_fallback(w3, MATH_ABI, MATH_CODE, MATH_RUNTIME): +def test_error_to_call_non_existent_fallback( + w3, math_contract_abi, math_contract_bytecode, math_contract_runtime +): math_contract = w3.eth.contract( - abi=MATH_ABI, - bytecode=MATH_CODE, - bytecode_runtime=MATH_RUNTIME, + abi=math_contract_abi, + bytecode=math_contract_bytecode, + bytecode_runtime=math_contract_runtime, ) with pytest.raises(FallbackNotFound): math_contract.fallback.estimate_gas() diff --git a/tests/core/contracts/test_contract_constructor.py b/tests/core/contracts/test_contract_constructor.py index 796c567266..7c66703926 100644 --- a/tests/core/contracts/test_contract_constructor.py +++ b/tests/core/contracts/test_contract_constructor.py @@ -4,6 +4,12 @@ decode_hex, ) +from web3._utils.contract_sources.contract_data.constructor_contracts import ( + CONSTRUCTOR_WITH_ADDRESS_ARGUMENT_CONTRACT_RUNTIME, + CONSTRUCTOR_WITH_ARGUMENTS_CONTRACT_RUNTIME, + SIMPLE_CONSTRUCTOR_CONTRACT_RUNTIME, +) + TEST_ADDRESS = "0x16D9983245De15E7A9A73bC586E01FF6E08dE737" EXPECTED_DATA_A = 1234 EXPECTED_DATA_B = ( @@ -13,28 +19,28 @@ def test_contract_constructor_abi_encoding_with_no_constructor_fn( - MathContract, MATH_CODE + math_contract_factory, math_contract_bytecode ): - deploy_data = MathContract.constructor()._encode_data_in_transaction() - assert deploy_data == MATH_CODE + deploy_data = math_contract_factory.constructor()._encode_data_in_transaction() + assert deploy_data == math_contract_bytecode -def test_contract_constructor_gas_estimate_no_constructor(w3, MathContract): - gas_estimate = MathContract.constructor().estimate_gas() +def test_contract_constructor_gas_estimate_no_constructor(w3, math_contract_factory): + gas_estimate = math_contract_factory.constructor().estimate_gas() - deploy_txn = MathContract.constructor().transact() + deploy_txn = math_contract_factory.constructor().transact() txn_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) gas_used = txn_receipt.get("gasUsed") assert abs(gas_estimate - gas_used) < 21000 -def test_contract_constructor_gas_estimate_with_block_id(w3, MathContract): +def test_contract_constructor_gas_estimate_with_block_id(w3, math_contract_factory): block_identifier = None - gas_estimate = MathContract.constructor().estimate_gas( + gas_estimate = math_contract_factory.constructor().estimate_gas( block_identifier=block_identifier ) - deploy_txn = MathContract.constructor().transact() + deploy_txn = math_contract_factory.constructor().transact() txn_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) gas_used = txn_receipt.get("gasUsed") @@ -42,11 +48,11 @@ def test_contract_constructor_gas_estimate_with_block_id(w3, MathContract): def test_contract_constructor_gas_estimate_without_arguments( - w3, SimpleConstructorContract + w3, simple_constructor_contract_factory ): - gas_estimate = SimpleConstructorContract.constructor().estimate_gas() + gas_estimate = simple_constructor_contract_factory.constructor().estimate_gas() - deploy_txn = SimpleConstructorContract.constructor().transact() + deploy_txn = simple_constructor_contract_factory.constructor().transact() txn_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) gas_used = txn_receipt.get("gasUsed") @@ -64,15 +70,15 @@ def test_contract_constructor_gas_estimate_without_arguments( ) def test_contract_constructor_gas_estimate_with_arguments_non_strict( w3_non_strict_abi, - NonStrictWithConstructorArgumentsContract, + non_strict_contract_with_constructor_args_factory, constructor_args, constructor_kwargs, ): - gas_estimate = NonStrictWithConstructorArgumentsContract.constructor( + gas_estimate = non_strict_contract_with_constructor_args_factory.constructor( *constructor_args, **constructor_kwargs ).estimate_gas() - deploy_txn = NonStrictWithConstructorArgumentsContract.constructor( + deploy_txn = non_strict_contract_with_constructor_args_factory.constructor( *constructor_args, **constructor_kwargs ).transact() txn_receipt = w3_non_strict_abi.eth.wait_for_transaction_receipt(deploy_txn) @@ -82,13 +88,13 @@ def test_contract_constructor_gas_estimate_with_arguments_non_strict( def test_contract_constructor_gas_estimate_with_address_argument( - w3, WithConstructorAddressArgumentsContract, address_conversion_func + w3, contract_with_constructor_address_factory, address_conversion_func ): - gas_estimate = WithConstructorAddressArgumentsContract.constructor( + gas_estimate = contract_with_constructor_address_factory.constructor( address_conversion_func("0x16D9983245De15E7A9A73bC586E01FF6E08dE737") ).estimate_gas() - deploy_txn = WithConstructorAddressArgumentsContract.constructor( + deploy_txn = contract_with_constructor_address_factory.constructor( address_conversion_func("0x16D9983245De15E7A9A73bC586E01FF6E08dE737") ).transact() txn_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) @@ -98,9 +104,9 @@ def test_contract_constructor_gas_estimate_with_address_argument( def test_contract_constructor_transact_no_constructor( - w3, MathContract, MATH_RUNTIME, address_conversion_func + w3, math_contract_factory, math_contract_runtime, address_conversion_func ): - deploy_txn = MathContract.constructor().transact() + deploy_txn = math_contract_factory.constructor().transact() txn_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) assert txn_receipt is not None @@ -109,13 +115,15 @@ def test_contract_constructor_transact_no_constructor( contract_address = address_conversion_func(txn_receipt["contractAddress"]) blockchain_code = w3.eth.get_code(contract_address) - assert blockchain_code == decode_hex(MATH_RUNTIME) + assert blockchain_code == decode_hex(math_contract_runtime) def test_contract_constructor_transact_without_arguments( - w3, SimpleConstructorContract, SIMPLE_CONSTRUCTOR_RUNTIME, address_conversion_func + w3, + simple_constructor_contract_factory, + address_conversion_func, ): - deploy_txn = SimpleConstructorContract.constructor().transact() + deploy_txn = simple_constructor_contract_factory.constructor().transact() txn_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) assert txn_receipt is not None @@ -124,7 +132,7 @@ def test_contract_constructor_transact_without_arguments( contract_address = address_conversion_func(txn_receipt["contractAddress"]) blockchain_code = w3.eth.get_code(contract_address) - assert blockchain_code == decode_hex(SIMPLE_CONSTRUCTOR_RUNTIME) + assert blockchain_code == decode_hex(SIMPLE_CONSTRUCTOR_CONTRACT_RUNTIME) @pytest.mark.parametrize( @@ -138,15 +146,14 @@ def test_contract_constructor_transact_without_arguments( ) def test_contract_constructor_transact_with_arguments_non_strict( w3_non_strict_abi, - NonStrictWithConstructorArgumentsContract, - WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME, + non_strict_contract_with_constructor_args_factory, constructor_args, constructor_kwargs, expected_a, expected_b, address_conversion_func, ): - deploy_txn = NonStrictWithConstructorArgumentsContract.constructor( + deploy_txn = non_strict_contract_with_constructor_args_factory.constructor( *constructor_args, **constructor_kwargs ).transact() @@ -157,16 +164,16 @@ def test_contract_constructor_transact_with_arguments_non_strict( contract_address = address_conversion_func(txn_receipt["contractAddress"]) blockchain_code = w3_non_strict_abi.eth.get_code(contract_address) - assert blockchain_code == decode_hex(WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME) + assert blockchain_code == decode_hex(CONSTRUCTOR_WITH_ARGUMENTS_CONTRACT_RUNTIME) assert ( expected_a - == NonStrictWithConstructorArgumentsContract(address=contract_address) + == non_strict_contract_with_constructor_args_factory(address=contract_address) .functions.data_a() .call() ) assert ( expected_b - == NonStrictWithConstructorArgumentsContract(address=contract_address) + == non_strict_contract_with_constructor_args_factory(address=contract_address) .functions.data_b() .call() ) @@ -174,11 +181,10 @@ def test_contract_constructor_transact_with_arguments_non_strict( def test_contract_constructor_transact_with_address_argument( w3, - WithConstructorAddressArgumentsContract, - WITH_CONSTRUCTOR_ADDRESS_RUNTIME, + contract_with_constructor_address_factory, address_conversion_func, ): - deploy_txn = WithConstructorAddressArgumentsContract.constructor( + deploy_txn = contract_with_constructor_address_factory.constructor( TEST_ADDRESS ).transact() txn_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) @@ -186,29 +192,31 @@ def test_contract_constructor_transact_with_address_argument( assert txn_receipt["contractAddress"] contract_address = address_conversion_func(txn_receipt["contractAddress"]) blockchain_code = w3.eth.get_code(contract_address) - assert blockchain_code == decode_hex(WITH_CONSTRUCTOR_ADDRESS_RUNTIME) + assert blockchain_code == decode_hex( + CONSTRUCTOR_WITH_ADDRESS_ARGUMENT_CONTRACT_RUNTIME + ) assert ( TEST_ADDRESS - == WithConstructorAddressArgumentsContract(address=contract_address) + == contract_with_constructor_address_factory(address=contract_address) .functions.testAddr() .call() ) -def test_contract_constructor_build_transaction_to_field_error(MathContract): +def test_contract_constructor_build_transaction_to_field_error(math_contract_factory): with pytest.raises(ValueError): - MathContract.constructor().build_transaction({"to": "123"}) + math_contract_factory.constructor().build_transaction({"to": "123"}) def test_contract_constructor_build_transaction_no_constructor( - w3, MathContract, address_conversion_func + w3, math_contract_factory, address_conversion_func ): - txn_hash = MathContract.constructor().transact( + txn_hash = math_contract_factory.constructor().transact( {"from": address_conversion_func(w3.eth.accounts[0])} ) txn = w3.eth.get_transaction(txn_hash) nonce = w3.eth.get_transaction_count(w3.eth.coinbase) - unsent_txn = MathContract.constructor().build_transaction({"nonce": nonce}) + unsent_txn = math_contract_factory.constructor().build_transaction({"nonce": nonce}) assert txn["data"] == unsent_txn["data"] new_txn_hash = w3.eth.send_transaction(unsent_txn) @@ -218,14 +226,14 @@ def test_contract_constructor_build_transaction_no_constructor( def test_contract_constructor_build_transaction_without_arguments( - w3, MathContract, address_conversion_func + w3, math_contract_factory, address_conversion_func ): - txn_hash = MathContract.constructor().transact( + txn_hash = math_contract_factory.constructor().transact( {"from": address_conversion_func(w3.eth.accounts[0])} ) txn = w3.eth.get_transaction(txn_hash) nonce = w3.eth.get_transaction_count(w3.eth.coinbase) - unsent_txn = MathContract.constructor().build_transaction({"nonce": nonce}) + unsent_txn = math_contract_factory.constructor().build_transaction({"nonce": nonce}) assert txn["data"] == unsent_txn["data"] new_txn_hash = w3.eth.send_transaction(unsent_txn) @@ -245,17 +253,17 @@ def test_contract_constructor_build_transaction_without_arguments( ) def test_contract_constructor_build_transaction_with_arguments( w3_non_strict_abi, - NonStrictWithConstructorArgumentsContract, + non_strict_contract_with_constructor_args_factory, constructor_args, constructor_kwargs, address_conversion_func, ): - txn_hash = NonStrictWithConstructorArgumentsContract.constructor( + txn_hash = non_strict_contract_with_constructor_args_factory.constructor( *constructor_args, **constructor_kwargs ).transact({"from": address_conversion_func(w3_non_strict_abi.eth.accounts[0])}) txn = w3_non_strict_abi.eth.get_transaction(txn_hash) nonce = w3_non_strict_abi.eth.get_transaction_count(w3_non_strict_abi.eth.coinbase) - unsent_txn = NonStrictWithConstructorArgumentsContract.constructor( + unsent_txn = non_strict_contract_with_constructor_args_factory.constructor( *constructor_args, **constructor_kwargs ).build_transaction({"nonce": nonce}) assert txn["data"] == unsent_txn["data"] @@ -267,19 +275,21 @@ def test_contract_constructor_build_transaction_with_arguments( def test_async_contract_constructor_abi_encoding_with_no_constructor_fn( - AsyncMathContract, MATH_CODE + async_math_contract_factory, math_contract_bytecode ): - deploy_data = AsyncMathContract.constructor()._encode_data_in_transaction() - assert deploy_data == MATH_CODE + deploy_data = ( + async_math_contract_factory.constructor()._encode_data_in_transaction() + ) + assert deploy_data == math_contract_bytecode @pytest.mark.asyncio async def test_async_contract_constructor_gas_estimate_no_constructor( - async_w3, AsyncMathContract + async_w3, async_math_contract_factory ): - gas_estimate = await AsyncMathContract.constructor().estimate_gas() + gas_estimate = await async_math_contract_factory.constructor().estimate_gas() - deploy_txn = await AsyncMathContract.constructor().transact() + deploy_txn = await async_math_contract_factory.constructor().transact() txn_receipt = await async_w3.eth.wait_for_transaction_receipt(deploy_txn) gas_used = txn_receipt.get("gasUsed") @@ -288,13 +298,13 @@ async def test_async_contract_constructor_gas_estimate_no_constructor( @pytest.mark.asyncio async def test_async_contract_constructor_gas_estimate_with_block_id( - async_w3, AsyncMathContract + async_w3, async_math_contract_factory ): block_identifier = None - gas_estimate = await AsyncMathContract.constructor().estimate_gas( + gas_estimate = await async_math_contract_factory.constructor().estimate_gas( block_identifier=block_identifier ) - deploy_txn = await AsyncMathContract.constructor().transact() + deploy_txn = await async_math_contract_factory.constructor().transact() txn_receipt = await async_w3.eth.wait_for_transaction_receipt(deploy_txn) gas_used = txn_receipt.get("gasUsed") @@ -303,11 +313,15 @@ async def test_async_contract_constructor_gas_estimate_with_block_id( @pytest.mark.asyncio async def test_async_contract_constructor_gas_estimate_without_arguments( - async_w3, AsyncSimpleConstructorContract + async_w3, async_simple_constructor_contract_factory ): - gas_estimate = await AsyncSimpleConstructorContract.constructor().estimate_gas() + gas_estimate = ( + await async_simple_constructor_contract_factory.constructor().estimate_gas() + ) - deploy_txn = await AsyncSimpleConstructorContract.constructor().transact() + deploy_txn = ( + await async_simple_constructor_contract_factory.constructor().transact() + ) txn_receipt = await async_w3.eth.wait_for_transaction_receipt(deploy_txn) gas_used = txn_receipt.get("gasUsed") @@ -326,17 +340,21 @@ async def test_async_contract_constructor_gas_estimate_without_arguments( ) async def test_async_contract_constructor_gas_estimate_with_arguments_non_strict( async_w3_non_strict_abi, - AsyncNonStrictWithConstructorArgumentsContract, + async_non_strict_constructor_with_args_contract_factory, constructor_args, constructor_kwargs, ): - gas_estimate = await AsyncNonStrictWithConstructorArgumentsContract.constructor( - *constructor_args, **constructor_kwargs - ).estimate_gas() + gas_estimate = ( + await async_non_strict_constructor_with_args_contract_factory.constructor( + *constructor_args, **constructor_kwargs + ).estimate_gas() + ) - deploy_txn = await AsyncNonStrictWithConstructorArgumentsContract.constructor( - *constructor_args, **constructor_kwargs - ).transact() + deploy_txn = ( + await async_non_strict_constructor_with_args_contract_factory.constructor( + *constructor_args, **constructor_kwargs + ).transact() + ) txn_receipt = await async_w3_non_strict_abi.eth.wait_for_transaction_receipt( deploy_txn ) @@ -346,14 +364,18 @@ async def test_async_contract_constructor_gas_estimate_with_arguments_non_strict @pytest.mark.asyncio -async def test_async_contract_constructor_gas_estimate_with_address_argument( - async_w3, AsyncWithConstructorAddressArgumentsContract, address_conversion_func +async def test_async_contract_constructor_with_address_argument_gas_estimate( + async_w3, + async_constructor_with_address_arg_contract_factory, + address_conversion_func, ): - gas_estimate = await AsyncWithConstructorAddressArgumentsContract.constructor( - address_conversion_func("0x16D9983245De15E7A9A73bC586E01FF6E08dE737") - ).estimate_gas() + gas_estimate = ( + await async_constructor_with_address_arg_contract_factory.constructor( + address_conversion_func("0x16D9983245De15E7A9A73bC586E01FF6E08dE737") + ).estimate_gas() + ) - deploy_txn = await AsyncWithConstructorAddressArgumentsContract.constructor( + deploy_txn = await async_constructor_with_address_arg_contract_factory.constructor( address_conversion_func("0x16D9983245De15E7A9A73bC586E01FF6E08dE737") ).transact() txn_receipt = await async_w3.eth.wait_for_transaction_receipt(deploy_txn) @@ -364,9 +386,12 @@ async def test_async_contract_constructor_gas_estimate_with_address_argument( @pytest.mark.asyncio async def test_async_contract_constructor_transact_no_constructor( - async_w3, AsyncMathContract, MATH_RUNTIME, address_conversion_func + async_w3, + async_math_contract_factory, + math_contract_runtime, + address_conversion_func, ): - deploy_txn = await AsyncMathContract.constructor().transact() + deploy_txn = await async_math_contract_factory.constructor().transact() txn_receipt = await async_w3.eth.wait_for_transaction_receipt(deploy_txn) assert txn_receipt is not None @@ -375,17 +400,18 @@ async def test_async_contract_constructor_transact_no_constructor( contract_address = address_conversion_func(txn_receipt["contractAddress"]) blockchain_code = await async_w3.eth.get_code(contract_address) - assert blockchain_code == decode_hex(MATH_RUNTIME) + assert blockchain_code == decode_hex(math_contract_runtime) @pytest.mark.asyncio async def test_async_contract_constructor_transact_without_arguments( async_w3, - AsyncSimpleConstructorContract, - SIMPLE_CONSTRUCTOR_RUNTIME, + async_simple_constructor_contract_factory, address_conversion_func, ): - deploy_txn = await AsyncSimpleConstructorContract.constructor().transact() + deploy_txn = ( + await async_simple_constructor_contract_factory.constructor().transact() + ) txn_receipt = await async_w3.eth.wait_for_transaction_receipt(deploy_txn) assert txn_receipt is not None @@ -394,7 +420,7 @@ async def test_async_contract_constructor_transact_without_arguments( contract_address = address_conversion_func(txn_receipt["contractAddress"]) blockchain_code = await async_w3.eth.get_code(contract_address) - assert blockchain_code == decode_hex(SIMPLE_CONSTRUCTOR_RUNTIME) + assert blockchain_code == decode_hex(SIMPLE_CONSTRUCTOR_CONTRACT_RUNTIME) @pytest.mark.asyncio @@ -409,17 +435,18 @@ async def test_async_contract_constructor_transact_without_arguments( ) async def test_async_contract_constructor_transact_with_arguments_non_strict( async_w3_non_strict_abi, - AsyncNonStrictWithConstructorArgumentsContract, - WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME, + async_non_strict_constructor_with_args_contract_factory, constructor_args, constructor_kwargs, expected_a, expected_b, address_conversion_func, ): - deploy_txn = await AsyncNonStrictWithConstructorArgumentsContract.constructor( - *constructor_args, **constructor_kwargs - ).transact() + deploy_txn = ( + await async_non_strict_constructor_with_args_contract_factory.constructor( + *constructor_args, **constructor_kwargs + ).transact() + ) txn_receipt = await async_w3_non_strict_abi.eth.wait_for_transaction_receipt( deploy_txn @@ -430,10 +457,10 @@ async def test_async_contract_constructor_transact_with_arguments_non_strict( contract_address = address_conversion_func(txn_receipt["contractAddress"]) blockchain_code = await async_w3_non_strict_abi.eth.get_code(contract_address) - assert blockchain_code == decode_hex(WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME) + assert blockchain_code == decode_hex(CONSTRUCTOR_WITH_ARGUMENTS_CONTRACT_RUNTIME) assert ( expected_a - == await AsyncNonStrictWithConstructorArgumentsContract( + == await async_non_strict_constructor_with_args_contract_factory( address=contract_address ) .functions.data_a() @@ -441,7 +468,7 @@ async def test_async_contract_constructor_transact_with_arguments_non_strict( ) assert ( expected_b - == await AsyncNonStrictWithConstructorArgumentsContract( + == await async_non_strict_constructor_with_args_contract_factory( address=contract_address ) .functions.data_b() @@ -452,11 +479,10 @@ async def test_async_contract_constructor_transact_with_arguments_non_strict( @pytest.mark.asyncio async def test_async_contract_constructor_transact_with_address_arguments( async_w3, - AsyncWithConstructorAddressArgumentsContract, - WITH_CONSTRUCTOR_ADDRESS_RUNTIME, + async_constructor_with_address_arg_contract_factory, address_conversion_func, ): - deploy_txn = await AsyncWithConstructorAddressArgumentsContract.constructor( + deploy_txn = await async_constructor_with_address_arg_contract_factory.constructor( TEST_ADDRESS ).transact() txn_receipt = await async_w3.eth.wait_for_transaction_receipt(deploy_txn) @@ -464,10 +490,14 @@ async def test_async_contract_constructor_transact_with_address_arguments( assert txn_receipt["contractAddress"] contract_address = address_conversion_func(txn_receipt["contractAddress"]) blockchain_code = await async_w3.eth.get_code(contract_address) - assert blockchain_code == decode_hex(WITH_CONSTRUCTOR_ADDRESS_RUNTIME) + assert blockchain_code == decode_hex( + CONSTRUCTOR_WITH_ADDRESS_ARGUMENT_CONTRACT_RUNTIME + ) assert ( TEST_ADDRESS - == await AsyncWithConstructorAddressArgumentsContract(address=contract_address) + == await async_constructor_with_address_arg_contract_factory( + address=contract_address + ) .functions.testAddr() .call() ) @@ -475,24 +505,24 @@ async def test_async_contract_constructor_transact_with_address_arguments( @pytest.mark.asyncio async def test_async_contract_constructor_build_transaction_to_field_error( - AsyncMathContract, + async_math_contract_factory, ): with pytest.raises(ValueError): - await AsyncMathContract.constructor().build_transaction({"to": "123"}) + await async_math_contract_factory.constructor().build_transaction({"to": "123"}) @pytest.mark.asyncio async def test_async_contract_constructor_build_transaction_no_constructor( - async_w3, AsyncMathContract, address_conversion_func + async_w3, async_math_contract_factory, address_conversion_func ): async_w3_accounts = await async_w3.eth.accounts - txn_hash = await AsyncMathContract.constructor().transact( + txn_hash = await async_math_contract_factory.constructor().transact( {"from": address_conversion_func(async_w3_accounts[0])} ) txn = await async_w3.eth.get_transaction(txn_hash) async_w3_coinbase = await async_w3.eth.coinbase nonce = await async_w3.eth.get_transaction_count(async_w3_coinbase) - unsent_txn = await AsyncMathContract.constructor().build_transaction( + unsent_txn = await async_math_contract_factory.constructor().build_transaction( {"nonce": nonce} ) assert txn["data"] == unsent_txn["data"] @@ -505,16 +535,16 @@ async def test_async_contract_constructor_build_transaction_no_constructor( @pytest.mark.asyncio async def test_async_contract_constructor_build_transaction_without_arguments( - async_w3, AsyncMathContract, address_conversion_func + async_w3, async_math_contract_factory, address_conversion_func ): async_w3_accounts = await async_w3.eth.accounts - txn_hash = await AsyncMathContract.constructor().transact( + txn_hash = await async_math_contract_factory.constructor().transact( {"from": address_conversion_func(async_w3_accounts[0])} ) txn = await async_w3.eth.get_transaction(txn_hash) async_w3_coinbase = await async_w3.eth.coinbase nonce = await async_w3.eth.get_transaction_count(async_w3_coinbase) - unsent_txn = await AsyncMathContract.constructor().build_transaction( + unsent_txn = await async_math_contract_factory.constructor().build_transaction( {"nonce": nonce} ) assert txn["data"] == unsent_txn["data"] @@ -537,21 +567,25 @@ async def test_async_contract_constructor_build_transaction_without_arguments( ) async def test_async_contract_constructor_build_transaction_with_arguments( async_w3_non_strict_abi, - AsyncNonStrictWithConstructorArgumentsContract, + async_non_strict_constructor_with_args_contract_factory, constructor_args, constructor_kwargs, address_conversion_func, ): async_w3_accounts = await async_w3_non_strict_abi.eth.accounts - txn_hash = await AsyncNonStrictWithConstructorArgumentsContract.constructor( - *constructor_args, **constructor_kwargs - ).transact({"from": address_conversion_func(async_w3_accounts[0])}) + txn_hash = ( + await async_non_strict_constructor_with_args_contract_factory.constructor( + *constructor_args, **constructor_kwargs + ).transact({"from": address_conversion_func(async_w3_accounts[0])}) + ) txn = await async_w3_non_strict_abi.eth.get_transaction(txn_hash) async_w3_coinbase = await async_w3_non_strict_abi.eth.coinbase nonce = await async_w3_non_strict_abi.eth.get_transaction_count(async_w3_coinbase) - unsent_txn = await AsyncNonStrictWithConstructorArgumentsContract.constructor( - *constructor_args, **constructor_kwargs - ).build_transaction({"nonce": nonce}) + unsent_txn = ( + await async_non_strict_constructor_with_args_contract_factory.constructor( + *constructor_args, **constructor_kwargs + ).build_transaction({"nonce": nonce}) + ) assert txn["data"] == unsent_txn["data"] new_txn_hash = await async_w3_non_strict_abi.eth.send_transaction(unsent_txn) diff --git a/tests/core/contracts/test_contract_constructor_encoding.py b/tests/core/contracts/test_contract_constructor_encoding.py index 4c7ce53edc..ed8e9946a2 100644 --- a/tests/core/contracts/test_contract_constructor_encoding.py +++ b/tests/core/contracts/test_contract_constructor_encoding.py @@ -5,19 +5,23 @@ remove_0x_prefix, ) +from web3._utils.contract_sources.contract_data.constructor_contracts import ( + SIMPLE_CONSTRUCTOR_CONTRACT_BYTECODE, +) + def test_contract_constructor_abi_encoding_with_no_constructor_fn( - MathContract, MATH_CODE + math_contract_factory, math_contract_bytecode ): - deploy_data = MathContract._encode_constructor_data() - assert deploy_data == MATH_CODE + deploy_data = math_contract_factory._encode_constructor_data() + assert deploy_data == math_contract_bytecode def test_contract_constructor_abi_encoding_with_constructor_with_no_args( - SimpleConstructorContract, SIMPLE_CONSTRUCTOR_CODE + simple_constructor_contract_factory, ): - deploy_data = SimpleConstructorContract._encode_constructor_data() - assert deploy_data == SIMPLE_CONSTRUCTOR_CODE + deploy_data = simple_constructor_contract_factory._encode_constructor_data() + assert deploy_data == SIMPLE_CONSTRUCTOR_CONTRACT_BYTECODE @pytest.mark.parametrize( @@ -28,10 +32,10 @@ def test_contract_constructor_abi_encoding_with_constructor_with_no_args( ), ) def test_contract_error_if_additional_args_are_supplied_with_no_constructor_fn( - MathContract, args, kwargs + math_contract_factory, args, kwargs ): with pytest.raises(TypeError, match="Constructor args"): - MathContract._encode_constructor_data(args, kwargs) + math_contract_factory._encode_constructor_data(args, kwargs) @pytest.mark.parametrize( @@ -46,10 +50,10 @@ def test_contract_error_if_additional_args_are_supplied_with_no_constructor_fn( ), ) def test_error_if_invalid_arguments_supplied( - WithConstructorArgumentsContract, arguments + contract_with_constructor_args_factory, arguments ): with pytest.raises(TypeError): - WithConstructorArgumentsContract._encode_constructor_data(arguments) + contract_with_constructor_args_factory._encode_constructor_data(arguments) @pytest.mark.parametrize( @@ -67,11 +71,11 @@ def test_error_if_invalid_arguments_supplied( ) def test_contract_constructor_encoding( w3, - WithConstructorArgumentsContract, + contract_with_constructor_args_factory, encoded_args, bytes_arg, ): - deploy_data = WithConstructorArgumentsContract._encode_constructor_data( + deploy_data = contract_with_constructor_args_factory._encode_constructor_data( [1234, bytes_arg] ) expected_ending = encode_hex( @@ -90,10 +94,12 @@ def test_contract_constructor_encoding( ), ) def test_contract_constructor_encoding_non_strict( - w3_non_strict_abi, NonStrictWithConstructorArgumentsContract, bytes_arg + w3_non_strict_abi, non_strict_contract_with_constructor_args_factory, bytes_arg ): - deploy_data = NonStrictWithConstructorArgumentsContract._encode_constructor_data( - [1234, bytes_arg] + deploy_data = ( + non_strict_contract_with_constructor_args_factory._encode_constructor_data( + [1234, bytes_arg] + ) ) encoded_args = "0x00000000000000000000000000000000000000000000000000000000000004d26162636400000000000000000000000000000000000000000000000000000000" # noqa: E501 expected_ending = encode_hex( @@ -113,10 +119,12 @@ def test_contract_constructor_encoding_non_strict( ), ) def test_contract_constructor_encoding_strict_errors( - WithConstructorArgumentsContract, bytes_arg + contract_with_constructor_args_factory, bytes_arg ): with pytest.raises( TypeError, match="One or more arguments could not be encoded to the necessary ABI type.", ): - WithConstructorArgumentsContract._encode_constructor_data([1234, bytes_arg]) + contract_with_constructor_args_factory._encode_constructor_data( + [1234, bytes_arg] + ) diff --git a/tests/core/contracts/test_contract_deployment.py b/tests/core/contracts/test_contract_deployment.py index 302ed8ccc1..956e646a3c 100644 --- a/tests/core/contracts/test_contract_deployment.py +++ b/tests/core/contracts/test_contract_deployment.py @@ -7,10 +7,17 @@ from web3 import ( constants, ) +from web3._utils.contract_sources.contract_data.constructor_contracts import ( + CONSTRUCTOR_WITH_ADDRESS_ARGUMENT_CONTRACT_RUNTIME, + CONSTRUCTOR_WITH_ARGUMENTS_CONTRACT_RUNTIME, + SIMPLE_CONSTRUCTOR_CONTRACT_RUNTIME, +) -def test_contract_deployment_no_constructor(w3, MathContract, MATH_RUNTIME): - deploy_txn = MathContract.constructor().transact() +def test_contract_deployment_no_constructor( + w3, math_contract_factory, math_contract_runtime +): + deploy_txn = math_contract_factory.constructor().transact() txn_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) assert txn_receipt is not None @@ -19,13 +26,14 @@ def test_contract_deployment_no_constructor(w3, MathContract, MATH_RUNTIME): contract_address = txn_receipt["contractAddress"] blockchain_code = w3.eth.get_code(contract_address) - assert blockchain_code == decode_hex(MATH_RUNTIME) + assert blockchain_code == decode_hex(math_contract_runtime) def test_contract_deployment_with_constructor_without_args( - w3, SimpleConstructorContract, SIMPLE_CONSTRUCTOR_RUNTIME + w3, + simple_constructor_contract_factory, ): - deploy_txn = SimpleConstructorContract.constructor().transact() + deploy_txn = simple_constructor_contract_factory.constructor().transact() txn_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) assert txn_receipt is not None @@ -34,7 +42,7 @@ def test_contract_deployment_with_constructor_without_args( contract_address = txn_receipt["contractAddress"] blockchain_code = w3.eth.get_code(contract_address) - assert blockchain_code == decode_hex(SIMPLE_CONSTRUCTOR_RUNTIME) + assert blockchain_code == decode_hex(SIMPLE_CONSTRUCTOR_CONTRACT_RUNTIME) @pytest.mark.parametrize( @@ -46,11 +54,10 @@ def test_contract_deployment_with_constructor_without_args( ) def test_contract_deployment_with_constructor_with_arguments_strict_by_default( w3, - WithConstructorArgumentsContract, - WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME, + contract_with_constructor_args_factory, constructor_arg, ): - deploy_txn = WithConstructorArgumentsContract.constructor( + deploy_txn = contract_with_constructor_args_factory.constructor( 1234, constructor_arg ).transact() @@ -61,15 +68,14 @@ def test_contract_deployment_with_constructor_with_arguments_strict_by_default( contract_address = txn_receipt["contractAddress"] blockchain_code = w3.eth.get_code(contract_address) - assert blockchain_code == decode_hex(WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME) + assert blockchain_code == decode_hex(CONSTRUCTOR_WITH_ARGUMENTS_CONTRACT_RUNTIME) def test_contract_deployment_with_constructor_with_arguments_non_strict( w3_non_strict_abi, - NonStrictWithConstructorArgumentsContract, - WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME, + non_strict_contract_with_constructor_args_factory, ): - deploy_txn = NonStrictWithConstructorArgumentsContract.constructor( + deploy_txn = non_strict_contract_with_constructor_args_factory.constructor( 1234, "abcd" ).transact() @@ -80,26 +86,24 @@ def test_contract_deployment_with_constructor_with_arguments_non_strict( contract_address = txn_receipt["contractAddress"] blockchain_code = w3_non_strict_abi.eth.get_code(contract_address) - assert blockchain_code == decode_hex(WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME) + assert blockchain_code == decode_hex(CONSTRUCTOR_WITH_ARGUMENTS_CONTRACT_RUNTIME) def test_contract_deployment_with_constructor_with_arguments_strict_error( - WithConstructorArgumentsContract, - WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME, + contract_with_constructor_args_factory, ): with pytest.raises( TypeError, match="One or more arguments could not be encoded to the necessary ABI type. Expected types are: uint256, bytes32", # noqa: E501 ): - WithConstructorArgumentsContract.constructor(1234, "abcd").transact() + contract_with_constructor_args_factory.constructor(1234, "abcd").transact() def test_contract_deployment_with_constructor_with_address_argument( w3, - WithConstructorAddressArgumentsContract, # noqa: E501 - WITH_CONSTRUCTOR_ADDRESS_RUNTIME, -): # noqa: E501 - deploy_txn = WithConstructorAddressArgumentsContract.constructor( + contract_with_constructor_address_factory, +): + deploy_txn = contract_with_constructor_address_factory.constructor( "0x16D9983245De15E7A9A73bC586E01FF6E08dE737", ).transact() @@ -110,14 +114,16 @@ def test_contract_deployment_with_constructor_with_address_argument( contract_address = txn_receipt["contractAddress"] blockchain_code = w3.eth.get_code(contract_address) - assert blockchain_code == decode_hex(WITH_CONSTRUCTOR_ADDRESS_RUNTIME) + assert blockchain_code == decode_hex( + CONSTRUCTOR_WITH_ADDRESS_ARGUMENT_CONTRACT_RUNTIME + ) @pytest.mark.asyncio async def test_async_contract_deployment_no_constructor( - async_w3, AsyncMathContract, MATH_RUNTIME + async_w3, async_math_contract_factory, math_contract_runtime ): - deploy_txn = await AsyncMathContract.constructor().transact() + deploy_txn = await async_math_contract_factory.constructor().transact() txn_receipt = await async_w3.eth.wait_for_transaction_receipt(deploy_txn) assert txn_receipt is not None @@ -126,14 +132,17 @@ async def test_async_contract_deployment_no_constructor( contract_address = txn_receipt["contractAddress"] blockchain_code = await async_w3.eth.get_code(contract_address) - assert blockchain_code == decode_hex(MATH_RUNTIME) + assert blockchain_code == decode_hex(math_contract_runtime) @pytest.mark.asyncio async def test_async_contract_deployment_with_constructor_no_args( - async_w3, AsyncSimpleConstructorContract, SIMPLE_CONSTRUCTOR_RUNTIME + async_w3, + async_simple_constructor_contract_factory, ): - deploy_txn = await AsyncSimpleConstructorContract.constructor().transact() + deploy_txn = ( + await async_simple_constructor_contract_factory.constructor().transact() + ) txn_receipt = await async_w3.eth.wait_for_transaction_receipt(deploy_txn) assert txn_receipt is not None @@ -142,7 +151,7 @@ async def test_async_contract_deployment_with_constructor_no_args( contract_address = txn_receipt["contractAddress"] blockchain_code = await async_w3.eth.get_code(contract_address) - assert blockchain_code == decode_hex(SIMPLE_CONSTRUCTOR_RUNTIME) + assert blockchain_code == decode_hex(SIMPLE_CONSTRUCTOR_CONTRACT_RUNTIME) @pytest.mark.asyncio @@ -155,12 +164,11 @@ async def test_async_contract_deployment_with_constructor_no_args( ) async def test_async_contract_deployment_with_constructor_arguments( async_w3, - AsyncWithConstructorArgumentsContract, - WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME, + async_constructor_with_args_contract_factory, constructor_arg, ): - deploy_txn = await AsyncWithConstructorArgumentsContract.constructor( + deploy_txn = await async_constructor_with_args_contract_factory.constructor( 1234, constructor_arg ).transact() @@ -171,18 +179,19 @@ async def test_async_contract_deployment_with_constructor_arguments( contract_address = txn_receipt["contractAddress"] blockchain_code = await async_w3.eth.get_code(contract_address) - assert blockchain_code == decode_hex(WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME) + assert blockchain_code == decode_hex(CONSTRUCTOR_WITH_ARGUMENTS_CONTRACT_RUNTIME) @pytest.mark.asyncio async def test_async_contract_deployment_with_constructor_with_arguments_non_strict( async_w3_non_strict_abi, - AsyncNonStrictWithConstructorArgumentsContract, - WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME, + async_non_strict_constructor_with_args_contract_factory, ): - deploy_txn = await AsyncNonStrictWithConstructorArgumentsContract.constructor( - 1234, "abcd" - ).transact() # noqa: E501 + deploy_txn = ( + await async_non_strict_constructor_with_args_contract_factory.constructor( + 1234, "abcd" + ).transact() + ) txn_receipt = await async_w3_non_strict_abi.eth.wait_for_transaction_receipt( deploy_txn @@ -193,28 +202,28 @@ async def test_async_contract_deployment_with_constructor_with_arguments_non_str contract_address = txn_receipt["contractAddress"] blockchain_code = await async_w3_non_strict_abi.eth.get_code(contract_address) - assert blockchain_code == decode_hex(WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME) + assert blockchain_code == decode_hex(CONSTRUCTOR_WITH_ARGUMENTS_CONTRACT_RUNTIME) @pytest.mark.asyncio async def test_async_contract_deployment_with_constructor_arguments_strict_error( - AsyncWithConstructorArgumentsContract, - WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME, + async_constructor_with_args_contract_factory, ): with pytest.raises( TypeError, match="One or more arguments could not be encoded to the necessary ABI type. Expected types are: uint256, bytes32", # noqa: E501 ): - await AsyncWithConstructorArgumentsContract.constructor(1234, "abcd").transact() + await async_constructor_with_args_contract_factory.constructor( + 1234, "abcd" + ).transact() @pytest.mark.asyncio async def test_async_contract_deployment_with_constructor_with_address_argument( async_w3, - AsyncWithConstructorAddressArgumentsContract, # noqa: E501 - WITH_CONSTRUCTOR_ADDRESS_RUNTIME, -): # noqa: E501 - deploy_txn = await AsyncWithConstructorAddressArgumentsContract.constructor( + async_constructor_with_address_arg_contract_factory, +): + deploy_txn = await async_constructor_with_address_arg_contract_factory.constructor( "0x16D9983245De15E7A9A73bC586E01FF6E08dE737", ).transact() @@ -225,4 +234,6 @@ async def test_async_contract_deployment_with_constructor_with_address_argument( contract_address = txn_receipt["contractAddress"] blockchain_code = await async_w3.eth.get_code(contract_address) - assert blockchain_code == decode_hex(WITH_CONSTRUCTOR_ADDRESS_RUNTIME) + assert blockchain_code == decode_hex( + CONSTRUCTOR_WITH_ADDRESS_ARGUMENT_CONTRACT_RUNTIME + ) diff --git a/tests/core/contracts/test_contract_estimate_gas.py b/tests/core/contracts/test_contract_estimate_gas.py index 045ce1a641..730b2353cd 100644 --- a/tests/core/contracts/test_contract_estimate_gas.py +++ b/tests/core/contracts/test_contract_estimate_gas.py @@ -6,9 +6,11 @@ def test_contract_estimate_gas(w3, math_contract, estimate_gas, transact): - gas_estimate = estimate_gas(contract=math_contract, contract_function="increment") + gas_estimate = estimate_gas( + contract=math_contract, contract_function="incrementCounter" + ) - txn_hash = transact(contract=math_contract, contract_function="increment") + txn_hash = transact(contract=math_contract, contract_function="incrementCounter") txn_receipt = w3.eth.wait_for_transaction_receipt(txn_hash) gas_used = txn_receipt.get("gasUsed") @@ -76,7 +78,7 @@ def test_estimate_gas_accepts_latest_block(w3, math_contract, transact): block_identifier="latest" ) - txn_hash = transact(contract=math_contract, contract_function="increment") + txn_hash = transact(contract=math_contract, contract_function="incrementCounter") txn_receipt = w3.eth.wait_for_transaction_receipt(txn_hash) gas_used = txn_receipt.get("gasUsed") @@ -85,7 +87,7 @@ def test_estimate_gas_accepts_latest_block(w3, math_contract, transact): def test_estimate_gas_block_identifier_unique_estimates(w3, math_contract, transact): - txn_hash = transact(contract=math_contract, contract_function="increment") + txn_hash = transact(contract=math_contract, contract_function="incrementCounter") w3.eth.wait_for_transaction_receipt(txn_hash) latest_gas_estimate = math_contract.functions.counter().estimate_gas( @@ -103,11 +105,11 @@ async def test_async_contract_estimate_gas( async_w3, async_math_contract, async_estimate_gas, async_transact ): gas_estimate = await async_estimate_gas( - contract=async_math_contract, contract_function="increment" + contract=async_math_contract, contract_function="incrementCounter" ) txn_hash = await async_transact( - contract=async_math_contract, contract_function="increment" + contract=async_math_contract, contract_function="incrementCounter" ) txn_receipt = await async_w3.eth.wait_for_transaction_receipt(txn_hash) @@ -186,7 +188,7 @@ async def test_async_estimate_gas_accepts_latest_block( ) txn_hash = await async_transact( - contract=async_math_contract, contract_function="increment" + contract=async_math_contract, contract_function="incrementCounter" ) txn_receipt = await async_w3.eth.wait_for_transaction_receipt(txn_hash) @@ -200,7 +202,7 @@ async def test_async_estimate_gas_block_identifier_unique_estimates( async_w3, async_math_contract, async_transact ): txn_hash = await async_transact( - contract=async_math_contract, contract_function="increment" + contract=async_math_contract, contract_function="incrementCounter" ) await async_w3.eth.wait_for_transaction_receipt(txn_hash) diff --git a/tests/core/contracts/test_contract_events_build_filter.py b/tests/core/contracts/test_contract_events_build_filter.py index 50986f145f..0b2a82dd93 100644 --- a/tests/core/contracts/test_contract_events_build_filter.py +++ b/tests/core/contracts/test_contract_events_build_filter.py @@ -1,4 +1,3 @@ -import json import pytest from eth_utils import ( @@ -8,13 +7,9 @@ HexBytes, ) -CONTRACT_ABI = json.loads( - '[{"constant":false,"inputs":[],"name":"return13","outputs":[{"name":"result","type":"int256"}],"type":"function"},{"constant":true,"inputs":[],"name":"counter","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"amt","type":"uint256"}],"name":"increment","outputs":[{"name":"result","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"a","type":"int256"},{"name":"b","type":"int256"}],"name":"add","outputs":[{"name":"result","type":"int256"}],"type":"function"},{"constant":false,"inputs":[],"name":"increment","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"a","type":"int256"}],"name":"multiply7","outputs":[{"name":"result","type":"int256"}],"type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"value","type":"uint256"}],"name":"Increased","type":"event"}]' # noqa: E501 -) - -def test_build_filter_topic_signature(w3): - contract = w3.eth.contract(abi=CONTRACT_ABI) +def test_build_filter_topic_signature(w3, math_contract_abi): + contract = w3.eth.contract(abi=math_contract_abi) filter_builder = contract.events.Increased.build_filter() filter_builder.args["value"].match_any(100, 200, 300) _filter = filter_builder.deploy(w3) @@ -24,8 +19,8 @@ def test_build_filter_topic_signature(w3): assert _filter.data_filter_set == (("uint256", (100, 200, 300)),) -def test_build_filter_resetting_build_filter_properties(w3): - contract = w3.eth.contract(abi=CONTRACT_ABI) +def test_build_filter_resetting_build_filter_properties(w3, math_contract_abi): + contract = w3.eth.contract(abi=math_contract_abi) filter_builder = contract.events.Increased.build_filter() # Address is setable from undeployed contract class filter_builder.address = b"\x10" * 40 @@ -40,24 +35,24 @@ def test_build_filter_resetting_build_filter_properties(w3): filter_builder.toBlock = 50 -def test_build_filter_argument_match_single_can_only_be_set_once(w3): - contract = w3.eth.contract(abi=CONTRACT_ABI) +def test_build_filter_argument_match_single_can_only_be_set_once(w3, math_contract_abi): + contract = w3.eth.contract(abi=math_contract_abi) filter_builder = contract.events.Increased.build_filter() filter_builder.args["value"].match_single(100) with pytest.raises(ValueError): filter_builder.args["value"].match_single(200) -def test_build_filter_argument_match_any_can_only_be_set_once(w3): - contract = w3.eth.contract(abi=CONTRACT_ABI) +def test_build_filter_argument_match_any_can_only_be_set_once(w3, math_contract_abi): + contract = w3.eth.contract(abi=math_contract_abi) filter_builder = contract.events.Increased.build_filter() filter_builder.args["value"].match_any(100, 200) with pytest.raises(ValueError): filter_builder.args["value"].match_any(200, 300) -def test_deployed_build_filter_can_have_no_values_set(w3): - contract = w3.eth.contract(abi=CONTRACT_ABI) +def test_deployed_build_filter_can_have_no_values_set(w3, math_contract_abi): + contract = w3.eth.contract(abi=math_contract_abi) filter_builder = contract.events.Increased.build_filter() filter_builder.deploy(w3) with pytest.raises(ValueError): diff --git a/tests/core/contracts/test_contract_init.py b/tests/core/contracts/test_contract_init.py index e8f9934ed3..e297dd5113 100644 --- a/tests/core/contracts/test_contract_init.py +++ b/tests/core/contracts/test_contract_init.py @@ -11,23 +11,23 @@ @pytest.fixture() -def math_addr(MathContract, address_conversion_func): - w3 = MathContract.w3 - deploy_txn = MathContract.constructor().transact({"from": w3.eth.coinbase}) +def math_addr(math_contract_factory, address_conversion_func): + w3 = math_contract_factory.w3 + deploy_txn = math_contract_factory.constructor().transact({"from": w3.eth.coinbase}) deploy_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None return address_conversion_func(deploy_receipt["contractAddress"]) -def test_contract_with_unset_address(MathContract): - with contract_ens_addresses(MathContract, []): +def test_contract_with_unset_address(math_contract_factory): + with contract_ens_addresses(math_contract_factory, []): with pytest.raises(NameNotFound): - MathContract(address="unsetname.eth") + math_contract_factory(address="unsetname.eth") -def test_contract_with_name_address(MathContract, math_addr): - with contract_ens_addresses(MathContract, [("thedao.eth", math_addr)]): - mc = MathContract(address="thedao.eth") +def test_contract_with_name_address(math_contract_factory, math_addr): + with contract_ens_addresses(math_contract_factory, [("thedao.eth", math_addr)]): + mc = math_contract_factory(address="thedao.eth") caller = mc.w3.eth.coinbase assert mc.address == "thedao.eth" assert mc.functions.return13().call({"from": caller}) == 13 @@ -35,17 +35,17 @@ def test_contract_with_name_address(MathContract, math_addr): def test_contract_with_name_address_from_eth_contract( w3, - MATH_ABI, - MATH_CODE, - MATH_RUNTIME, + math_contract_abi, + math_contract_bytecode, + math_contract_runtime, math_addr, ): with ens_addresses(w3, [("thedao.eth", math_addr)]): mc = w3.eth.contract( address="thedao.eth", - abi=MATH_ABI, - bytecode=MATH_CODE, - bytecode_runtime=MATH_RUNTIME, + abi=math_contract_abi, + bytecode=math_contract_bytecode, + bytecode_runtime=math_contract_runtime, ) caller = mc.w3.eth.coinbase @@ -53,10 +53,10 @@ def test_contract_with_name_address_from_eth_contract( assert mc.functions.return13().call({"from": caller}) == 13 -def test_contract_with_name_address_changing(MathContract, math_addr): +def test_contract_with_name_address_changing(math_contract_factory, math_addr): # Contract address is validated once on creation - with contract_ens_addresses(MathContract, [("thedao.eth", math_addr)]): - mc = MathContract(address="thedao.eth") + with contract_ens_addresses(math_contract_factory, [("thedao.eth", math_addr)]): + mc = math_contract_factory(address="thedao.eth") caller = mc.w3.eth.coinbase assert mc.address == "thedao.eth" diff --git a/tests/core/contracts/test_contract_transact_interface.py b/tests/core/contracts/test_contract_transact_interface.py index e6a4014e02..4c58d9ab88 100644 --- a/tests/core/contracts/test_contract_transact_interface.py +++ b/tests/core/contracts/test_contract_transact_interface.py @@ -11,7 +11,7 @@ def test_transacting_with_contract_no_arguments(w3, math_contract, transact, call): initial_value = call(contract=math_contract, contract_function="counter") - txn_hash = transact(contract=math_contract, contract_function="increment") + txn_hash = transact(contract=math_contract, contract_function="incrementCounter") txn_receipt = w3.eth.wait_for_transaction_receipt(txn_hash) assert txn_receipt is not None @@ -65,7 +65,7 @@ def test_transact_sending_ether_to_nonpayable_function( "transact_args,transact_kwargs", ( ((5,), {}), - (tuple(), {"amt": 5}), + (tuple(), {"amount": 5}), ), ) def test_transacting_with_contract_with_arguments( @@ -75,7 +75,7 @@ def test_transacting_with_contract_with_arguments( txn_hash = transact( contract=math_contract, - contract_function="increment", + contract_function="incrementCounter", func_args=transact_args, func_kwargs=transact_kwargs, ) @@ -88,11 +88,11 @@ def test_transacting_with_contract_with_arguments( assert final_value - initial_value == 5 -def test_deploy_when_default_account_is_set(w3, STRING_CONTRACT): +def test_deploy_when_default_account_is_set(w3, string_contract_data): w3.eth.default_account = w3.eth.accounts[1] assert w3.eth.default_account is not empty - StringContract = w3.eth.contract(**STRING_CONTRACT) + StringContract = w3.eth.contract(**string_contract_data) deploy_txn = StringContract.constructor("Caqalai").transact() w3.eth.wait_for_transaction_receipt(deploy_txn) @@ -104,7 +104,7 @@ def test_transact_when_default_account_is_set(w3, math_contract, transact): w3.eth.default_account = w3.eth.accounts[1] assert w3.eth.default_account is not empty - txn_hash = transact(contract=math_contract, contract_function="increment") + txn_hash = transact(contract=math_contract, contract_function="incrementCounter") txn_after = w3.eth.get_transaction(txn_hash) assert txn_after["from"] == w3.eth.default_account @@ -166,7 +166,7 @@ def test_transacting_with_contract_with_bytes32_array_argument( assert final_value == new_bytes32_array -def test_transacting_with_contract_with_byte_array_argument( +def test_transacting_with_contract_with_byte_array_argument_strict( w3, arrays_contract, transact, call ): new_byte_array = [b"\x03", b"\x03", b"\x03", b"\x03", b"\x03", b"\x03"] @@ -201,9 +201,9 @@ def test_transacting_with_contract_with_byte_array_argument_non_strict( def test_transacting_with_contract_respects_explicit_gas( - w3, STRING_CONTRACT, wait_for_block, call, transact + w3, string_contract_data, wait_for_block, call, transact ): - StringContract = w3.eth.contract(**STRING_CONTRACT) + StringContract = w3.eth.contract(**string_contract_data) deploy_txn = StringContract.constructor("Caqalai").transact() deploy_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn, 30) @@ -227,9 +227,9 @@ def test_transacting_with_contract_respects_explicit_gas( def test_auto_gas_computation_when_transacting( - w3, STRING_CONTRACT, wait_for_block, call, transact + w3, string_contract_data, wait_for_block, call, transact ): - StringContract = w3.eth.contract(**STRING_CONTRACT) + StringContract = w3.eth.contract(**string_contract_data) deploy_txn = StringContract.constructor("Caqalai").transact() deploy_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn, 30) @@ -294,7 +294,7 @@ async def test_async_transacting_with_contract_no_arguments( ) txn_hash = await async_transact( - contract=async_math_contract, contract_function="increment" + contract=async_math_contract, contract_function="incrementCounter" ) txn_receipt = await async_w3.eth.wait_for_transaction_receipt(txn_hash) assert txn_receipt is not None @@ -358,7 +358,7 @@ async def test_async_transact_sending_ether_to_nonpayable_function( "transact_args,transact_kwargs", ( ((5,), {}), - (tuple(), {"amt": 5}), + (tuple(), {"amount": 5}), ), ) async def test_async_transacting_with_contract_with_arguments( @@ -375,7 +375,7 @@ async def test_async_transacting_with_contract_with_arguments( txn_hash = await async_transact( contract=async_math_contract, - contract_function="increment", + contract_function="incrementCounter", func_args=transact_args, func_kwargs=transact_kwargs, ) @@ -391,12 +391,12 @@ async def test_async_transacting_with_contract_with_arguments( @pytest.mark.asyncio -async def test_async_deploy_when_default_account_is_set(async_w3, STRING_CONTRACT): +async def test_async_deploy_when_default_account_is_set(async_w3, string_contract_data): async_w3_accounts = await async_w3.eth.accounts async_w3.eth.default_account = async_w3_accounts[1] assert async_w3.eth.default_account is not empty - StringContract = async_w3.eth.contract(**STRING_CONTRACT) + StringContract = async_w3.eth.contract(**string_contract_data) deploy_txn = await StringContract.constructor("Caqalai").transact() await async_w3.eth.wait_for_transaction_receipt(deploy_txn) @@ -413,7 +413,7 @@ async def test_async_transact_when_default_account_is_set( assert async_w3.eth.default_account is not empty txn_hash = await async_transact( - contract=async_math_contract, contract_function="increment" + contract=async_math_contract, contract_function="incrementCounter" ) txn_after = await async_w3.eth.get_transaction(txn_hash) assert txn_after["from"] == async_w3.eth.default_account @@ -509,10 +509,10 @@ async def test_async_transacting_with_contract_with_byte_array_argument_non_stri @pytest.mark.asyncio async def test_async_transacting_with_contract_respects_explicit_gas( - async_w3, STRING_CONTRACT, async_call, async_transact + async_w3, string_contract_data, async_call, async_transact ): - StringContract = async_w3.eth.contract(**STRING_CONTRACT) + StringContract = async_w3.eth.contract(**string_contract_data) deploy_txn = await StringContract.constructor("Caqalai").transact() deploy_receipt = await async_w3.eth.wait_for_transaction_receipt(deploy_txn, 30) @@ -539,10 +539,10 @@ async def test_async_transacting_with_contract_respects_explicit_gas( @pytest.mark.asyncio async def test_async_auto_gas_computation_when_transacting( - async_w3, STRING_CONTRACT, async_call, async_transact + async_w3, string_contract_data, async_call, async_transact ): - StringContract = async_w3.eth.contract(**STRING_CONTRACT) + StringContract = async_w3.eth.contract(**string_contract_data) deploy_txn = await StringContract.constructor("Caqalai").transact() deploy_receipt = await async_w3.eth.wait_for_transaction_receipt(deploy_txn, 30) diff --git a/tests/core/contracts/test_extracting_event_data.py b/tests/core/contracts/test_extracting_event_data.py index 69d9e11078..bc06909b58 100644 --- a/tests/core/contracts/test_extracting_event_data.py +++ b/tests/core/contracts/test_extracting_event_data.py @@ -24,87 +24,38 @@ @pytest.fixture() -def Emitter(w3, EMITTER): - return w3.eth.contract(**EMITTER) - - -@pytest.fixture() -def emitter(w3, Emitter, wait_for_transaction, wait_for_block, address_conversion_func): - wait_for_block(w3) - deploy_txn_hash = Emitter.constructor().transact({"gas": 30029121}) - deploy_receipt = wait_for_transaction(w3, deploy_txn_hash) - contract_address = address_conversion_func(deploy_receipt["contractAddress"]) - - bytecode = w3.eth.get_code(contract_address) - assert bytecode == Emitter.bytecode_runtime - _emitter = Emitter(address=contract_address) - assert _emitter.address == contract_address - return _emitter - - -@pytest.fixture() -def EventContract(w3, EVENT_CONTRACT): - return w3.eth.contract(**EVENT_CONTRACT) - - -@pytest.fixture() -def event_contract( - w3, EventContract, wait_for_transaction, wait_for_block, address_conversion_func -): - - wait_for_block(w3) - deploy_txn_hash = EventContract.constructor().transact( - {"from": w3.eth.coinbase, "gas": 1000000} - ) - deploy_receipt = wait_for_transaction(w3, deploy_txn_hash) - contract_address = address_conversion_func(deploy_receipt["contractAddress"]) +def dup_txn_receipt(w3, indexed_event_contract, wait_for_transaction, event_contract): - bytecode = w3.eth.get_code(contract_address) - assert bytecode == EventContract.bytecode_runtime - event_contract = EventContract(address=contract_address) - assert event_contract.address == contract_address - return event_contract + emitter_fn = indexed_event_contract.functions.logTwoEvents + txn_hash = emitter_fn(12345).transact() + wait_for_transaction(w3, txn_hash) -@pytest.fixture() -def IndexedEventContract(w3, INDEXED_EVENT_CONTRACT): - return w3.eth.contract(**INDEXED_EVENT_CONTRACT) + event_contract_fn = event_contract.functions.logTwoEvents + dup_txn_hash = event_contract_fn(12345).transact() + return wait_for_transaction(w3, dup_txn_hash) -@pytest.fixture() -def indexed_event_contract( +@pytest.fixture +def emitter( w3, - IndexedEventContract, + emitter_contract_data, wait_for_transaction, wait_for_block, address_conversion_func, ): + emitter_contract_factory = w3.eth.contract(**emitter_contract_data) wait_for_block(w3) - deploy_txn_hash = IndexedEventContract.constructor().transact( - {"from": w3.eth.coinbase, "gas": 1000000} - ) + deploy_txn_hash = emitter_contract_factory.constructor().transact({"gas": 30029121}) deploy_receipt = wait_for_transaction(w3, deploy_txn_hash) contract_address = address_conversion_func(deploy_receipt["contractAddress"]) bytecode = w3.eth.get_code(contract_address) - assert bytecode == IndexedEventContract.bytecode_runtime - indexed_event_contract = IndexedEventContract(address=contract_address) - assert indexed_event_contract.address == contract_address - return indexed_event_contract - - -@pytest.fixture() -def dup_txn_receipt(w3, indexed_event_contract, wait_for_transaction, event_contract): - - emitter_fn = indexed_event_contract.functions.logTwoEvents - - txn_hash = emitter_fn(12345).transact() - wait_for_transaction(w3, txn_hash) - - event_contract_fn = event_contract.functions.logTwoEvents - dup_txn_hash = event_contract_fn(12345).transact() - return wait_for_transaction(w3, dup_txn_hash) + assert bytecode == emitter_contract_factory.bytecode_runtime + _emitter = emitter_contract_factory(address=contract_address) + assert _emitter.address == contract_address + return _emitter @pytest.mark.parametrize( @@ -158,15 +109,15 @@ def test_event_data_extraction( w3, emitter, wait_for_transaction, - emitter_log_topics, - emitter_event_ids, + emitter_contract_log_topics, + emitter_contract_event_ids, contract_fn, event_name, call_args, expected_args, ): emitter_fn = emitter.functions[contract_fn] - event_id = getattr(emitter_event_ids, event_name) + event_id = getattr(emitter_contract_event_ids, event_name) txn_hash = emitter_fn(event_id, *call_args).transact() txn_receipt = wait_for_transaction(w3, txn_hash) @@ -175,7 +126,7 @@ def test_event_data_extraction( event_abi = emitter._find_matching_event_abi(event_name) - event_topic = getattr(emitter_log_topics, event_name) + event_topic = getattr(emitter_contract_log_topics, event_name) is_anonymous = event_abi["anonymous"] if is_anonymous: @@ -213,7 +164,12 @@ def test_event_data_extraction( ), ) def test_event_data_extraction_bytes( - w3, emitter, wait_for_transaction, emitter_log_topics, call_args, expected_args + w3, + emitter, + wait_for_transaction, + emitter_contract_log_topics, + call_args, + expected_args, ): emitter_fn = emitter.functions.logListArgs txn_hash = emitter_fn(*call_args).transact() @@ -225,7 +181,7 @@ def test_event_data_extraction_bytes( event_name = "LogListArgs" event_abi = emitter._find_matching_event_abi(event_name) - event_topic = getattr(emitter_log_topics, event_name) + event_topic = getattr(emitter_contract_log_topics, event_name) assert event_topic in log_entry["topics"] @@ -262,7 +218,7 @@ def test_event_data_extraction_bytes_non_strict( w3_non_strict_abi, non_strict_emitter, wait_for_transaction, - emitter_log_topics, + emitter_contract_log_topics, call_args, expected_args, ): @@ -276,7 +232,7 @@ def test_event_data_extraction_bytes_non_strict( event_name = "LogListArgs" event_abi = non_strict_emitter._find_matching_event_abi(event_name) - event_topic = getattr(emitter_log_topics, event_name) + event_topic = getattr(emitter_contract_log_topics, event_name) assert event_topic in log_entry["topics"] @@ -305,7 +261,11 @@ def test_event_data_extraction_bytes_strict_with_errors(emitter, call_args): def test_dynamic_length_argument_extraction( - w3, emitter, wait_for_transaction, emitter_log_topics, emitter_event_ids + w3, + emitter, + wait_for_transaction, + emitter_contract_log_topics, + emitter_contract_event_ids, ): string_0 = "this-is-the-first-string-which-exceeds-32-bytes-in-length" string_1 = "this-is-the-second-string-which-exceeds-32-bytes-in-length" @@ -317,7 +277,7 @@ def test_dynamic_length_argument_extraction( event_abi = emitter._find_matching_event_abi("LogDynamicArgs") - event_topic = emitter_log_topics.LogDynamicArgs + event_topic = emitter_contract_log_topics.LogDynamicArgs assert event_topic in log_entry["topics"] string_0_topic = w3.keccak(text=string_0) @@ -339,7 +299,7 @@ def test_dynamic_length_argument_extraction( def test_argument_extraction_strict_bytes_types( - w3, emitter, wait_for_transaction, emitter_log_topics + w3, emitter, wait_for_transaction, emitter_contract_log_topics ): arg_0 = [b"12"] arg_1 = [b"12"] @@ -352,7 +312,7 @@ def test_argument_extraction_strict_bytes_types( event_abi = emitter._find_matching_event_abi("LogListArgs") - event_topic = emitter_log_topics.LogListArgs + event_topic = emitter_contract_log_topics.LogListArgs assert event_topic in log_entry["topics"] encoded_arg_0 = w3.codec.encode(["bytes2"], arg_0) @@ -588,7 +548,7 @@ def test_argument_extraction_strict_bytes_types( def test_event_rich_log( w3, emitter, - emitter_event_ids, + emitter_contract_event_ids, wait_for_transaction, contract_fn, event_name, @@ -599,8 +559,8 @@ def test_event_rich_log( ): emitter_fn = emitter.functions[contract_fn] - if hasattr(emitter_event_ids, event_name): - event_id = getattr(emitter_event_ids, event_name) + if hasattr(emitter_contract_event_ids, event_name): + event_id = getattr(emitter_contract_event_ids, event_name) txn_hash = emitter_fn(event_id, *call_args).transact() else: # Some tests do not rely on the event_id. Rather than @@ -852,7 +812,7 @@ def test_event_rich_log( def test_event_rich_log_non_strict( w3_non_strict_abi, non_strict_emitter, - emitter_event_ids, + emitter_contract_event_ids, wait_for_transaction, contract_fn, event_name, @@ -863,8 +823,8 @@ def test_event_rich_log_non_strict( ): emitter_fn = non_strict_emitter.functions[contract_fn] - if hasattr(emitter_event_ids, event_name): - event_id = getattr(emitter_event_ids, event_name) + if hasattr(emitter_contract_event_ids, event_name): + event_id = getattr(emitter_contract_event_ids, event_name) txn_hash = emitter_fn(event_id, *call_args).transact() else: # Some tests do not rely on the event_id. Rather than @@ -902,7 +862,7 @@ def test_event_rich_log_non_strict( @pytest.mark.parametrize("process_receipt", (True, False)) def test_event_rich_log_with_byte_args( - w3, emitter, emitter_event_ids, wait_for_transaction, process_receipt + w3, emitter, emitter_contract_event_ids, wait_for_transaction, process_receipt ): txn_hash = emitter.functions.logListArgs([b"13"], [b"54"]).transact() txn_receipt = wait_for_transaction(w3, txn_hash) @@ -936,7 +896,6 @@ def test_event_rich_log_with_byte_args( def test_receipt_processing_with_discard_flag( event_contract, indexed_event_contract, dup_txn_receipt, wait_for_transaction ): - event_instance = indexed_event_contract.events.LogSingleWithIndex() returned_logs = event_instance.process_receipt(dup_txn_receipt, errors=DISCARD) @@ -946,21 +905,21 @@ def test_receipt_processing_with_discard_flag( def test_receipt_processing_with_ignore_flag( event_contract, indexed_event_contract, dup_txn_receipt, wait_for_transaction ): - event_instance = indexed_event_contract.events.LogSingleWithIndex() + returned_logs = event_instance.process_receipt(dup_txn_receipt, errors=IGNORE) assert len(returned_logs) == 2 - # Check that the correct error is appended to the log - first_log = returned_logs[0] - log_error = re.compile("Expected 1 log topics. Got 0") - assert log_error.search(str(first_log.errors)) is not None - # Then, do the same with the other log: second_log = returned_logs[1] abi_error = re.compile("The event signature did not match the provided ABI") assert abi_error.search(str(second_log.errors)) is not None + # Check that the correct error is appended to the log + first_log = returned_logs[0] + log_error = re.compile("Expected 1 log topics. Got 0") + assert log_error.search(str(first_log.errors)) is not None + for log in returned_logs: # Check that the returned log is the same as what got sent in, # except for the added errors field diff --git a/tests/core/contracts/test_extracting_event_data_old.py b/tests/core/contracts/test_extracting_event_data_old.py index 15145cf416..a2bf1cb747 100644 --- a/tests/core/contracts/test_extracting_event_data_old.py +++ b/tests/core/contracts/test_extracting_event_data_old.py @@ -10,20 +10,23 @@ @pytest.fixture() -def Emitter(w3, EMITTER): - return w3.eth.contract(**EMITTER) - +def emitter( + w3, + emitter_contract_data, + wait_for_transaction, + wait_for_block, + address_conversion_func, +): + emitter_contract_factory = w3.eth.contract(**emitter_contract_data) -@pytest.fixture() -def emitter(w3, Emitter, wait_for_transaction, wait_for_block, address_conversion_func): wait_for_block(w3) - deploy_txn_hash = Emitter.constructor().transact({"gas": 10000000}) + deploy_txn_hash = emitter_contract_factory.constructor().transact({"gas": 10000000}) deploy_receipt = wait_for_transaction(w3, deploy_txn_hash) contract_address = address_conversion_func(deploy_receipt["contractAddress"]) bytecode = w3.eth.get_code(contract_address) - assert bytecode == Emitter.bytecode_runtime - _emitter = Emitter(address=contract_address) + assert bytecode == emitter_contract_factory.bytecode_runtime + _emitter = emitter_contract_factory(address=contract_address) assert _emitter.address == contract_address return _emitter @@ -79,15 +82,15 @@ def test_event_data_extraction( w3, emitter, wait_for_transaction, - emitter_log_topics, - emitter_event_ids, + emitter_contract_log_topics, + emitter_contract_event_ids, contract_fn, event_name, call_args, expected_args, ): function = getattr(emitter.functions, contract_fn) - event_id = getattr(emitter_event_ids, event_name) + event_id = getattr(emitter_contract_event_ids, event_name) txn_hash = function(event_id, *call_args).transact() txn_receipt = wait_for_transaction(w3, txn_hash) @@ -96,7 +99,7 @@ def test_event_data_extraction( event_abi = emitter._find_matching_event_abi(event_name) - event_topic = getattr(emitter_log_topics, event_name) + event_topic = getattr(emitter_contract_log_topics, event_name) is_anonymous = event_abi["anonymous"] if is_anonymous: @@ -115,7 +118,11 @@ def test_event_data_extraction( def test_dynamic_length_argument_extraction( - w3, emitter, wait_for_transaction, emitter_log_topics, emitter_event_ids + w3, + emitter, + wait_for_transaction, + emitter_contract_log_topics, + emitter_contract_event_ids, ): string_0 = "this-is-the-first-string-which-exceeds-32-bytes-in-length" string_1 = "this-is-the-second-string-which-exceeds-32-bytes-in-length" @@ -127,7 +134,7 @@ def test_dynamic_length_argument_extraction( event_abi = emitter._find_matching_event_abi("LogDynamicArgs") - event_topic = emitter_log_topics.LogDynamicArgs + event_topic = emitter_contract_log_topics.LogDynamicArgs assert event_topic in log_entry["topics"] string_0_topic = w3.keccak(text=string_0) diff --git a/tests/core/contracts/test_offchain_lookup.py b/tests/core/contracts/test_offchain_lookup.py index cb7dfd2c56..a077ebf93b 100644 --- a/tests/core/contracts/test_offchain_lookup.py +++ b/tests/core/contracts/test_offchain_lookup.py @@ -4,14 +4,12 @@ abi, ) +from web3._utils.contract_sources.contract_data.offchain_lookup import ( + OFFCHAIN_LOOKUP_DATA, +) from web3._utils.module_testing.module_testing_utils import ( mock_offchain_lookup_request_response, ) -from web3._utils.module_testing.offchain_lookup_contract import ( - OFFCHAIN_LOOKUP_ABI, - OFFCHAIN_LOOKUP_BYTECODE, - OFFCHAIN_LOOKUP_BYTECODE_RUNTIME, -) from web3._utils.type_conversion import ( to_hex_if_bytes, ) @@ -22,19 +20,14 @@ ) # "test offchain lookup" as an abi-encoded string -OFFCHAIN_LOOKUP_TEST_DATA = "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001474657374206f6666636861696e206c6f6f6b7570000000000000000000000000" # noqa: E501 +OFFCHAIN_LOOKUP_CONTRACT_TEST_DATA = "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001474657374206f6666636861696e206c6f6f6b7570000000000000000000000000" # noqa: E501 # "web3py" as an abi-encoded string WEB3PY_AS_HEXBYTES = "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000067765623370790000000000000000000000000000000000000000000000000000" # noqa: E501 @pytest.fixture def offchain_lookup_contract_factory(w3): - # compiled from `web3/_utils/module_testing/contract_sources/OffchainLookup.sol` - return w3.eth.contract( - abi=OFFCHAIN_LOOKUP_ABI, - bytecode=OFFCHAIN_LOOKUP_BYTECODE, - bytecode_runtime=OFFCHAIN_LOOKUP_BYTECODE_RUNTIME, - ) + return w3.eth.contract(**OFFCHAIN_LOOKUP_DATA) @pytest.fixture @@ -68,11 +61,11 @@ def test_offchain_lookup_functionality( normalized_address = to_hex_if_bytes(offchain_lookup_contract.address) mock_offchain_lookup_request_response( monkeypatch, - mocked_request_url=f"https://web3.py/gateway/{normalized_address}/{OFFCHAIN_LOOKUP_TEST_DATA}.json", # noqa: E501 + mocked_request_url=f"https://web3.py/gateway/{normalized_address}/{OFFCHAIN_LOOKUP_CONTRACT_TEST_DATA}.json", # noqa: E501 mocked_json_data=WEB3PY_AS_HEXBYTES, ) response = offchain_lookup_contract.caller.testOffchainLookup( - OFFCHAIN_LOOKUP_TEST_DATA + OFFCHAIN_LOOKUP_CONTRACT_TEST_DATA ) assert abi.decode(["string"], response)[0] == "web3py" @@ -83,24 +76,26 @@ def test_eth_call_offchain_lookup_raises_when_ccip_read_is_disabled( # test ContractFunction call with pytest.raises(OffchainLookup): offchain_lookup_contract.functions.testOffchainLookup( - OFFCHAIN_LOOKUP_TEST_DATA + OFFCHAIN_LOOKUP_CONTRACT_TEST_DATA ).call(ccip_read_enabled=False) # test ContractCaller call with pytest.raises(OffchainLookup): offchain_lookup_contract.caller(ccip_read_enabled=False).testOffchainLookup( - OFFCHAIN_LOOKUP_TEST_DATA + OFFCHAIN_LOOKUP_CONTRACT_TEST_DATA ) # test global flag on the provider w3.provider.global_ccip_read_enabled = False with pytest.raises(OffchainLookup): - offchain_lookup_contract.caller.testOffchainLookup(OFFCHAIN_LOOKUP_TEST_DATA) + offchain_lookup_contract.caller.testOffchainLookup( + OFFCHAIN_LOOKUP_CONTRACT_TEST_DATA + ) with pytest.raises(OffchainLookup): offchain_lookup_contract.caller(ccip_read_enabled=False).testOffchainLookup( - OFFCHAIN_LOOKUP_TEST_DATA + OFFCHAIN_LOOKUP_CONTRACT_TEST_DATA ) w3.provider.global_ccip_read_enabled = True # cleanup @@ -114,14 +109,14 @@ def test_offchain_lookup_call_flag_overrides_provider_flag( normalized_address = to_hex_if_bytes(offchain_lookup_contract.address) mock_offchain_lookup_request_response( monkeypatch, - mocked_request_url=f"https://web3.py/gateway/{normalized_address}/{OFFCHAIN_LOOKUP_TEST_DATA}.json", # noqa: E501 + mocked_request_url=f"https://web3.py/gateway/{normalized_address}/{OFFCHAIN_LOOKUP_CONTRACT_TEST_DATA}.json", # noqa: E501 mocked_json_data=WEB3PY_AS_HEXBYTES, ) w3.provider.global_ccip_read_enabled = False response = offchain_lookup_contract.functions.testOffchainLookup( - OFFCHAIN_LOOKUP_TEST_DATA + OFFCHAIN_LOOKUP_CONTRACT_TEST_DATA ).call(ccip_read_enabled=True) assert abi.decode(["string"], response)[0] == "web3py" @@ -135,12 +130,14 @@ def test_offchain_lookup_raises_for_improperly_formatted_rest_request_response( normalized_address = to_hex_if_bytes(offchain_lookup_contract.address) mock_offchain_lookup_request_response( monkeypatch, - mocked_request_url=f"https://web3.py/gateway/{normalized_address}/{OFFCHAIN_LOOKUP_TEST_DATA}.json", # noqa: E501 + mocked_request_url=f"https://web3.py/gateway/{normalized_address}/{OFFCHAIN_LOOKUP_CONTRACT_TEST_DATA}.json", # noqa: E501 mocked_json_data=WEB3PY_AS_HEXBYTES, json_data_field="not_data", ) with pytest.raises(Web3ValidationError, match="missing 'data' field"): - offchain_lookup_contract.caller.testOffchainLookup(OFFCHAIN_LOOKUP_TEST_DATA) + offchain_lookup_contract.caller.testOffchainLookup( + OFFCHAIN_LOOKUP_CONTRACT_TEST_DATA + ) @pytest.mark.parametrize("status_code_non_4xx_error", [100, 300, 500, 600]) @@ -160,7 +157,7 @@ def test_eth_call_offchain_lookup_tries_next_url_for_non_4xx_error_status_and_te # non 4xx status and that the POST logic is also working as expected. mock_offchain_lookup_request_response( monkeypatch, - mocked_request_url=f"https://web3.py/gateway/{normalized_contract_address}/{OFFCHAIN_LOOKUP_TEST_DATA}.json", # noqa: E501 + mocked_request_url=f"https://web3.py/gateway/{normalized_contract_address}/{OFFCHAIN_LOOKUP_CONTRACT_TEST_DATA}.json", # noqa: E501 mocked_status_code=status_code_non_4xx_error, mocked_json_data=WEB3PY_AS_HEXBYTES, ) @@ -171,10 +168,10 @@ def test_eth_call_offchain_lookup_tries_next_url_for_non_4xx_error_status_and_te mocked_status_code=200, mocked_json_data=WEB3PY_AS_HEXBYTES, sender=normalized_contract_address, - calldata=OFFCHAIN_LOOKUP_TEST_DATA, + calldata=OFFCHAIN_LOOKUP_CONTRACT_TEST_DATA, ) response = offchain_lookup_contract.caller.testOffchainLookup( - OFFCHAIN_LOOKUP_TEST_DATA + OFFCHAIN_LOOKUP_CONTRACT_TEST_DATA ) assert abi.decode(["string"], response)[0] == "web3py" @@ -190,12 +187,14 @@ def test_eth_call_offchain_lookup_calls_raise_for_status_for_4xx_status_code( ).lower() mock_offchain_lookup_request_response( monkeypatch, - mocked_request_url=f"https://web3.py/gateway/{normalized_contract_address}/{OFFCHAIN_LOOKUP_TEST_DATA}.json", # noqa: E501 + mocked_request_url=f"https://web3.py/gateway/{normalized_contract_address}/{OFFCHAIN_LOOKUP_CONTRACT_TEST_DATA}.json", # noqa: E501 mocked_status_code=status_code_4xx_error, mocked_json_data=WEB3PY_AS_HEXBYTES, ) with pytest.raises(Exception, match="called raise_for_status\\(\\)"): - offchain_lookup_contract.caller.testOffchainLookup(OFFCHAIN_LOOKUP_TEST_DATA) + offchain_lookup_contract.caller.testOffchainLookup( + OFFCHAIN_LOOKUP_CONTRACT_TEST_DATA + ) def test_offchain_lookup_raises_on_continuous_redirect( diff --git a/tests/core/contracts/utils.py b/tests/core/contracts/utils.py index 75ba472fe2..165939cf86 100644 --- a/tests/core/contracts/utils.py +++ b/tests/core/contracts/utils.py @@ -3,25 +3,25 @@ ) -def deploy(w3, Contract, apply_func=identity, args=None): +def deploy(w3, contract_factory, apply_func=identity, args=None): args = args or [] - deploy_txn = Contract.constructor(*args).transact() + deploy_txn = contract_factory.constructor(*args).transact() deploy_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None address = apply_func(deploy_receipt["contractAddress"]) - contract = Contract(address=address) + contract = contract_factory(address=address) assert contract.address == address assert len(w3.eth.get_code(contract.address)) > 0 return contract -async def async_deploy(async_web3, Contract, apply_func=identity, args=None): +async def async_deploy(async_web3, contract_factory, apply_func=identity, args=None): args = args or [] - deploy_txn = await Contract.constructor(*args).transact() + deploy_txn = await contract_factory.constructor(*args).transact() deploy_receipt = await async_web3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None address = apply_func(deploy_receipt["contractAddress"]) - contract = Contract(address=address) + contract = contract_factory(address=address) assert contract.address == address assert len(await async_web3.eth.get_code(contract.address)) > 0 return contract diff --git a/tests/core/eth-module/conftest.py b/tests/core/eth-module/conftest.py index 46812af762..36e93a3dd1 100644 --- a/tests/core/eth-module/conftest.py +++ b/tests/core/eth-module/conftest.py @@ -1,4 +1,3 @@ -import json import pytest @@ -15,29 +14,3 @@ def extra_accounts(w3, account_password): w3.personal.new_account(account_password) return w3.eth.accounts - - -CONTRACT_CODE = b"606060405261022e806100126000396000f360606040523615610074576000357c01000000000000000000000000000000000000000000000000000000009004806316216f391461007657806361bc221a146100995780637cf5dab0146100bc578063a5f3c23b146100e8578063d09de08a1461011d578063dcf537b11461014057610074565b005b610083600480505061016c565b6040518082815260200191505060405180910390f35b6100a6600480505061017f565b6040518082815260200191505060405180910390f35b6100d26004808035906020019091905050610188565b6040518082815260200191505060405180910390f35b61010760048080359060200190919080359060200190919050506101ea565b6040518082815260200191505060405180910390f35b61012a6004805050610201565b6040518082815260200191505060405180910390f35b6101566004808035906020019091905050610217565b6040518082815260200191505060405180910390f35b6000600d9050805080905061017c565b90565b60006000505481565b6000816000600082828250540192505081905550600060005054905080507f3496c3ede4ec3ab3686712aa1c238593ea6a42df83f98a5ec7df9834cfa577c5816040518082815260200191505060405180910390a18090506101e5565b919050565b6000818301905080508090506101fb565b92915050565b600061020d6001610188565b9050610214565b90565b60006007820290508050809050610229565b91905056" # noqa: E501 - - -CONTRACT_RUNTIME = b"0x60606040523615610074576000357c01000000000000000000000000000000000000000000000000000000009004806316216f391461007657806361bc221a146100995780637cf5dab0146100bc578063a5f3c23b146100e8578063d09de08a1461011d578063dcf537b11461014057610074565b005b610083600480505061016c565b6040518082815260200191505060405180910390f35b6100a6600480505061017f565b6040518082815260200191505060405180910390f35b6100d26004808035906020019091905050610188565b6040518082815260200191505060405180910390f35b61010760048080359060200190919080359060200190919050506101ea565b6040518082815260200191505060405180910390f35b61012a6004805050610201565b6040518082815260200191505060405180910390f35b6101566004808035906020019091905050610217565b6040518082815260200191505060405180910390f35b6000600d9050805080905061017c565b90565b60006000505481565b6000816000600082828250540192505081905550600060005054905080507f3496c3ede4ec3ab3686712aa1c238593ea6a42df83f98a5ec7df9834cfa577c5816040518082815260200191505060405180910390a18090506101e5565b919050565b6000818301905080508090506101fb565b92915050565b600061020d6001610188565b9050610214565b90565b60006007820290508050809050610229565b91905056" # noqa: E501 - - -CONTRACT_ABI = json.loads( - '[{"constant":false,"inputs":[],"name":"return13","outputs":[{"name":"result","type":"int256"}],"type":"function"},{"constant":true,"inputs":[],"name":"counter","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"amt","type":"uint256"}],"name":"increment","outputs":[{"name":"result","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"a","type":"int256"},{"name":"b","type":"int256"}],"name":"add","outputs":[{"name":"result","type":"int256"}],"type":"function"},{"constant":false,"inputs":[],"name":"increment","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"a","type":"int256"}],"name":"multiply7","outputs":[{"name":"result","type":"int256"}],"type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"value","type":"uint256"}],"name":"Increased","type":"event"}]' # noqa: E501 -) - - -@pytest.fixture(scope="session") -def MATH_CODE(): - return CONTRACT_CODE - - -@pytest.fixture(scope="session") -def MATH_RUNTIME(): - return CONTRACT_RUNTIME - - -@pytest.fixture(scope="session") -def MATH_ABI(): - return CONTRACT_ABI diff --git a/tests/core/filtering/conftest.py b/tests/core/filtering/conftest.py index 58457e856c..331381be2a 100644 --- a/tests/core/filtering/conftest.py +++ b/tests/core/filtering/conftest.py @@ -3,8 +3,6 @@ from eth_utils import ( apply_key_map, - encode_hex, - event_signature_to_log_topic, ) import pytest_asyncio @@ -17,11 +15,6 @@ from tests.utils import ( async_partial, ) -from web3._utils.module_testing.emitter_contract import ( - CONTRACT_EMITTER_ABI, - CONTRACT_EMITTER_CODE, - CONTRACT_EMITTER_RUNTIME, -) @pytest.fixture( @@ -33,122 +26,28 @@ def w3(request): return _w3_fixture_logic(request) -@pytest.fixture() -def EMITTER_CODE(): - return CONTRACT_EMITTER_CODE - - -@pytest.fixture() -def EMITTER_RUNTIME(): - return CONTRACT_EMITTER_RUNTIME - - -@pytest.fixture() -def EMITTER_ABI(): - return CONTRACT_EMITTER_ABI - - -@pytest.fixture() -def EMITTER(EMITTER_CODE, EMITTER_RUNTIME, EMITTER_ABI): - return { - "bytecode": EMITTER_CODE, - "bytecode_runtime": EMITTER_RUNTIME, - "abi": EMITTER_ABI, - } - +@pytest.fixture +def emitter_contract_factory(w3, emitter_contract_data): + return w3.eth.contract(**emitter_contract_data) -@pytest.fixture() -def Emitter(w3, EMITTER): - return w3.eth.contract(**EMITTER) - -@pytest.fixture() -def emitter(w3, Emitter, wait_for_transaction, wait_for_block, address_conversion_func): +@pytest.fixture +def emitter( + w3, + emitter_contract_factory, + wait_for_transaction, + wait_for_block, + address_conversion_func, +): return _emitter_fixture_logic( - w3, Emitter, wait_for_transaction, wait_for_block, address_conversion_func - ) - - -class LogFunctions: - LogAnonymous = 0 - LogNoArguments = 1 - LogSingleArg = 2 - LogDoubleArg = 3 - LogTripleArg = 4 - LogQuadrupleArg = 5 - LogSingleAnonymous = 6 - LogSingleWithIndex = 7 - LogDoubleAnonymous = 8 - LogDoubleWithIndex = 9 - LogTripleWithIndex = 10 - LogQuadrupleWithIndex = 11 - LogBytes = 12 - LogString = 13 - LogDynamicArgs = 14 - LogListArgs = 15 - LogAddressIndexed = 16 - LogAddressNotIndexed = 17 - - -@pytest.fixture(scope="module") -def emitter_event_ids(): - return LogFunctions - - -class LogTopics: - LogAnonymous = encode_hex(event_signature_to_log_topic("LogAnonymous()")) - LogNoArguments = encode_hex(event_signature_to_log_topic("LogNoArguments()")) - LogSingleArg = encode_hex(event_signature_to_log_topic("LogSingleArg(uint256)")) - LogSingleAnonymous = encode_hex( - event_signature_to_log_topic("LogSingleAnonymous(uint256)") - ) - LogSingleWithIndex = encode_hex( - event_signature_to_log_topic("LogSingleWithIndex(uint256)") - ) - LogDoubleArg = encode_hex( - event_signature_to_log_topic("LogDoubleArg(uint256,uint256)") - ) - LogDoubleAnonymous = encode_hex( - event_signature_to_log_topic("LogDoubleAnonymous(uint256,uint256)") - ) # noqa: E501 - LogDoubleWithIndex = encode_hex( - event_signature_to_log_topic("LogDoubleWithIndex(uint256,uint256)") - ) # noqa: E501 - LogTripleArg = encode_hex( - event_signature_to_log_topic("LogTripleArg(uint256,uint256,uint256)") - ) - LogTripleWithIndex = encode_hex( - event_signature_to_log_topic("LogTripleWithIndex(uint256,uint256,uint256)") - ) # noqa: E501 - LogQuadrupleArg = encode_hex( - event_signature_to_log_topic("LogQuadrupleArg(uint256,uint256,uint256,uint256)") - ) # noqa: E501 - LogQuadrupleWithIndex = encode_hex( - event_signature_to_log_topic( - "LogQuadrupleWithIndex(uint256,uint256,uint256,uint256)" - ) - ) # noqa: E501 - LogBytes = encode_hex(event_signature_to_log_topic("LogBytes(bytes)")) - LogString = encode_hex(event_signature_to_log_topic("LogString(string)")) - LogDynamicArgs = encode_hex( - event_signature_to_log_topic("LogDynamicArgs(string,string)") - ) - LogListArgs = encode_hex( - event_signature_to_log_topic("LogListArgs(bytes2[],bytes2[])") - ) - LogAddressIndexed = encode_hex( - event_signature_to_log_topic("LogAddressIndexed(address,address)") - ) - LogAddressNotIndexed = encode_hex( - event_signature_to_log_topic("LogAddressNotIndexed(address,address)") + w3, + emitter_contract_factory, + wait_for_transaction, + wait_for_block, + address_conversion_func, ) -@pytest.fixture() -def emitter_log_topics(): - return LogTopics - - def return_filter(contract, args): event_name = args[0] kwargs = apply_key_map({"filter": "argument_filters"}, args[1]) @@ -174,22 +73,22 @@ def async_w3(request): return _async_w3_fixture_logic(request) -@pytest.fixture() -def AsyncEmitter(async_w3, EMITTER): - return async_w3.eth.contract(**EMITTER) +@pytest.fixture +def async_emitter_contract_factory(async_w3, emitter_contract_data): + return async_w3.eth.contract(**emitter_contract_data) -@pytest_asyncio.fixture() +@pytest_asyncio.fixture async def async_emitter( async_w3, - AsyncEmitter, + async_emitter_contract_factory, async_wait_for_transaction, async_wait_for_block, address_conversion_func, ): return await _async_emitter_fixture_logic( async_w3, - AsyncEmitter, + async_emitter_contract_factory, async_wait_for_transaction, async_wait_for_block, address_conversion_func, diff --git a/tests/core/filtering/test_basic_filter_tests.py b/tests/core/filtering/test_basic_filter_tests.py index cb47271de3..77ad7bcf35 100644 --- a/tests/core/filtering/test_basic_filter_tests.py +++ b/tests/core/filtering/test_basic_filter_tests.py @@ -2,7 +2,7 @@ def test_filtering_sequential_blocks_with_bounded_range( - w3, emitter, Emitter, wait_for_transaction + w3, emitter, wait_for_transaction ): builder = emitter.events.LogNoArguments.build_filter() builder.fromBlock = "latest" @@ -17,7 +17,7 @@ def test_filtering_sequential_blocks_with_bounded_range( assert len(filter_.get_new_entries()) == 100 -def test_filtering_starting_block_range(w3, emitter, Emitter, wait_for_transaction): +def test_filtering_starting_block_range(w3, emitter, wait_for_transaction): for i in range(10): emitter.functions.logNoArgs(which=1).transact() builder = emitter.events.LogNoArguments.build_filter() diff --git a/tests/core/filtering/test_contract_data_filters.py b/tests/core/filtering/test_contract_data_filters.py index 4ac35346a9..d35457ca5e 100644 --- a/tests/core/filtering/test_contract_data_filters.py +++ b/tests/core/filtering/test_contract_data_filters.py @@ -18,35 +18,6 @@ _async_wait_for_block_fixture_logic, _async_wait_for_transaction_fixture_logic, ) -from web3._utils.module_testing.emitter_contract import ( - CONTRACT_EMITTER_ABI, - CONTRACT_EMITTER_CODE, - CONTRACT_EMITTER_RUNTIME, -) - - -@pytest.fixture(scope="module") -def EMITTER_CODE(): - return CONTRACT_EMITTER_CODE - - -@pytest.fixture(scope="module") -def EMITTER_RUNTIME(): - return CONTRACT_EMITTER_RUNTIME - - -@pytest.fixture(scope="module") -def EMITTER_ABI(): - return CONTRACT_EMITTER_ABI - - -@pytest.fixture(scope="module") -def EMITTER(EMITTER_CODE, EMITTER_RUNTIME, EMITTER_ABI): - return { - "bytecode": EMITTER_CODE, - "bytecode_runtime": EMITTER_RUNTIME, - "abi": EMITTER_ABI, - } def not_empty_string(x): @@ -115,14 +86,20 @@ def w3(request): @pytest.fixture(scope="module") -def Emitter(w3, EMITTER): - return w3.eth.contract(**EMITTER) - - -@pytest.fixture(scope="module") -def emitter(w3, Emitter, wait_for_transaction, wait_for_block, address_conversion_func): +def emitter( + w3, + emitter_contract_data, + wait_for_transaction, + wait_for_block, + address_conversion_func, +): + emitter_contract_factory = w3.eth.contract(**emitter_contract_data) return _emitter_fixture_logic( - w3, Emitter, wait_for_transaction, wait_for_block, address_conversion_func + w3, + emitter_contract_factory, + wait_for_transaction, + wait_for_block, + address_conversion_func, ) @@ -228,7 +205,7 @@ def test_data_filters_with_fixed_arguments( assert log_entries[0]["transactionHash"] == txn_hashes[0] -@pytest.mark.parametrize("call_as_instance", (True, False)) +@pytest.mark.parametrize("call_deployed_contract", (True, False)) @pytest.mark.parametrize("api_style", ("v4", "build_filter")) @given(vals=array_values()) @settings(max_examples=5, deadline=None) @@ -236,7 +213,7 @@ def test_data_filters_with_list_arguments( w3, emitter, wait_for_transaction, - call_as_instance, + call_deployed_contract, create_filter, api_style, vals, @@ -312,21 +289,22 @@ def async_w3(request): @pytest.fixture(scope="module") -def AsyncEmitter(async_w3, EMITTER): - return async_w3.eth.contract(**EMITTER) +def async_emitter_contract_factory(async_w3, emitter_contract_data): + async_w3.eth.contract(**emitter_contract_data) @pytest_asyncio.fixture(scope="module") async def async_emitter( async_w3, - AsyncEmitter, + emitter_contract_data, async_wait_for_transaction, async_wait_for_block, address_conversion_func, ): + async_emitter_contract_factory = async_w3.eth.contract(**emitter_contract_data) return await _async_emitter_fixture_logic( async_w3, - AsyncEmitter, + async_emitter_contract_factory, async_wait_for_transaction, async_wait_for_block, address_conversion_func, diff --git a/tests/core/filtering/test_contract_get_logs.py b/tests/core/filtering/test_contract_get_logs.py index 3b73fa3cb3..c9abc013de 100644 --- a/tests/core/filtering/test_contract_get_logs.py +++ b/tests/core/filtering/test_contract_get_logs.py @@ -14,10 +14,10 @@ def test_contract_get_logs_all( w3, emitter, wait_for_transaction, - emitter_event_ids, + emitter_contract_event_ids, ): contract = emitter - event_id = emitter_event_ids.LogNoArguments + event_id = emitter_contract_event_ids.LogNoArguments txn_hash = contract.functions.logNoArgs(event_id).transact() wait_for_transaction(w3, txn_hash) @@ -31,10 +31,10 @@ def test_contract_get_logs_range( w3, emitter, wait_for_transaction, - emitter_event_ids, + emitter_contract_event_ids, ): contract = emitter - event_id = emitter_event_ids.LogNoArguments + event_id = emitter_contract_event_ids.LogNoArguments assert w3.eth.block_number == 2 txn_hash = contract.functions.logNoArgs(event_id).transact() @@ -53,13 +53,13 @@ def test_contract_get_logs_range( def test_contract_get_logs_argument_filter( - w3, emitter, wait_for_transaction, emitter_event_ids + w3, emitter, wait_for_transaction, emitter_contract_event_ids ): contract = emitter txn_hashes = [] - event_id = emitter_event_ids.LogTripleWithIndex + event_id = emitter_contract_event_ids.LogTripleWithIndex # 1 = arg0 # 4 = arg1 # 1 = arg2 @@ -105,10 +105,10 @@ async def test_async_contract_get_logs_all( async_w3, async_emitter, async_wait_for_transaction, - emitter_event_ids, + emitter_contract_event_ids, ): contract = async_emitter - event_id = emitter_event_ids.LogNoArguments + event_id = emitter_contract_event_ids.LogNoArguments txn_hash = await contract.functions.logNoArgs(event_id).transact() await async_wait_for_transaction(async_w3, txn_hash) @@ -124,10 +124,10 @@ async def test_async_contract_get_logs_range( async_w3, async_emitter, async_wait_for_transaction, - emitter_event_ids, + emitter_contract_event_ids, ): contract = async_emitter - event_id = emitter_event_ids.LogNoArguments + event_id = emitter_contract_event_ids.LogNoArguments eth_block_number = await async_w3.eth.block_number assert eth_block_number == 2 @@ -156,13 +156,13 @@ async def test_async_contract_get_logs_range( @pytest.mark.asyncio async def test_async_contract_get_logs_argument_filter( - async_w3, async_emitter, async_wait_for_transaction, emitter_event_ids + async_w3, async_emitter, async_wait_for_transaction, emitter_contract_event_ids ): contract = async_emitter txn_hashes = [] - event_id = emitter_event_ids.LogTripleWithIndex + event_id = emitter_contract_event_ids.LogTripleWithIndex # 1 = arg0 # 4 = arg1 # 1 = arg2 diff --git a/tests/core/filtering/test_contract_on_event_filtering.py b/tests/core/filtering/test_contract_on_event_filtering.py index a5907eca31..d9fb47ad0d 100644 --- a/tests/core/filtering/test_contract_on_event_filtering.py +++ b/tests/core/filtering/test_contract_on_event_filtering.py @@ -6,14 +6,18 @@ ) -@pytest.mark.parametrize("call_as_instance", (True, False)) -def test_create_filter_address_parameter(emitter, Emitter, call_as_instance): - if call_as_instance: +@pytest.mark.parametrize("call_deployed_contract", (True, False)) +def test_create_filter_address_parameter( + emitter, emitter_contract_factory, call_deployed_contract +): + if call_deployed_contract: event_filter = emitter.events.LogNoArguments.create_filter(fromBlock="latest") else: - event_filter = Emitter.events.LogNoArguments.create_filter(fromBlock="latest") + event_filter = emitter_contract_factory.events.LogNoArguments.create_filter( + fromBlock="latest" + ) - if call_as_instance: + if call_deployed_contract: # Assert this is a single string value, and not a list of addresses assert is_address(event_filter.filter_params["address"]) else: @@ -21,30 +25,32 @@ def test_create_filter_address_parameter(emitter, Emitter, call_as_instance): assert "address" not in event_filter.filter_params -@pytest.mark.parametrize("call_as_instance", (True, False)) +@pytest.mark.parametrize("call_deployed_contract", (True, False)) @pytest.mark.parametrize("api_style", ("v4", "build_filter")) def test_on_filter_using_get_entries_interface( w3, emitter, - Emitter, + emitter_contract_factory, wait_for_transaction, - emitter_event_ids, - call_as_instance, + emitter_contract_event_ids, + call_deployed_contract, api_style, create_filter, ): - if call_as_instance: + if call_deployed_contract: contract = emitter else: - contract = Emitter + contract = emitter_contract_factory if api_style == "build_filter": event_filter = contract.events.LogNoArguments.build_filter().deploy(w3) else: event_filter = create_filter(emitter, ["LogNoArguments", {}]) - txn_hash = emitter.functions.logNoArgs(emitter_event_ids.LogNoArguments).transact() + txn_hash = emitter.functions.logNoArgs( + emitter_contract_event_ids.LogNoArguments + ).transact() wait_for_transaction(w3, txn_hash) log_entries = event_filter.get_new_entries() @@ -56,23 +62,23 @@ def test_on_filter_using_get_entries_interface( assert len(new_entries) == 0 -@pytest.mark.parametrize("call_as_instance", (True, False)) +@pytest.mark.parametrize("call_deployed_contract", (True, False)) @pytest.mark.parametrize("api_style", ("v4", "build_filter")) def test_on_sync_filter_with_event_name_and_single_argument( w3, emitter, - Emitter, + emitter_contract_factory, wait_for_transaction, - emitter_event_ids, - call_as_instance, + emitter_contract_event_ids, + call_deployed_contract, api_style, create_filter, ): - if call_as_instance: + if call_deployed_contract: contract = emitter else: - contract = Emitter + contract = emitter_contract_factory if api_style == "build_filter": builder = contract.events.LogTripleWithIndex.build_filter() @@ -92,7 +98,7 @@ def test_on_sync_filter_with_event_name_and_single_argument( ) txn_hashes = [] - event_id = emitter_event_ids.LogTripleWithIndex + event_id = emitter_contract_event_ids.LogTripleWithIndex txn_hashes.append(emitter.functions.logTriple(event_id, 2, 1, 3).transact()) txn_hashes.append(emitter.functions.logTriple(event_id, 1, 2, 3).transact()) txn_hashes.append(emitter.functions.logTriple(event_id, 12345, 2, 54321).transact()) @@ -104,23 +110,23 @@ def test_on_sync_filter_with_event_name_and_single_argument( assert {log["transactionHash"] for log in seen_logs} == set(txn_hashes[1:]) -@pytest.mark.parametrize("call_as_instance", (True, False)) +@pytest.mark.parametrize("call_deployed_contract", (True, False)) @pytest.mark.parametrize("api_style", ("v4", "build_filter")) def test_on_sync_filter_with_event_name_and_non_indexed_argument( w3, emitter, - Emitter, + emitter_contract_factory, wait_for_transaction, - emitter_event_ids, - call_as_instance, + emitter_contract_event_ids, + call_deployed_contract, api_style, create_filter, ): - if call_as_instance: + if call_deployed_contract: contract = emitter else: - contract = Emitter + contract = emitter_contract_factory if api_style == "build_filter": builder = contract.events.LogTripleWithIndex.build_filter() @@ -142,7 +148,7 @@ def test_on_sync_filter_with_event_name_and_non_indexed_argument( ) txn_hashes = [] - event_id = emitter_event_ids.LogTripleWithIndex + event_id = emitter_contract_event_ids.LogTripleWithIndex txn_hashes.append(emitter.functions.logTriple(event_id, 2, 1, 3).transact()) txn_hashes.append(emitter.functions.logTriple(event_id, 1, 2, 3).transact()) txn_hashes.append(emitter.functions.logTriple(event_id, 12345, 2, 54321).transact()) @@ -164,38 +170,40 @@ def test_on_sync_filter_with_event_name_and_non_indexed_argument( def test_filter_with_contract_address( - w3, emitter, emitter_event_ids, wait_for_transaction + w3, emitter, emitter_contract_event_ids, wait_for_transaction ): event_filter = w3.eth.filter(filter_params={"address": emitter.address}) - txn_hash = emitter.functions.logNoArgs(emitter_event_ids.LogNoArguments).transact() + txn_hash = emitter.functions.logNoArgs( + emitter_contract_event_ids.LogNoArguments + ).transact() wait_for_transaction(w3, txn_hash) seen_logs = event_filter.get_new_entries() assert len(seen_logs) == 1 assert seen_logs[0]["transactionHash"] == txn_hash -@pytest.mark.parametrize("call_as_instance", (True, False)) +@pytest.mark.parametrize("call_deployed_contract", (True, False)) def test_on_sync_filter_with_topic_filter_options_on_old_apis( w3, emitter, - Emitter, + emitter_contract_factory, wait_for_transaction, - emitter_event_ids, - call_as_instance, + emitter_contract_event_ids, + call_deployed_contract, create_filter, ): - if call_as_instance: + if call_deployed_contract: contract = emitter else: - contract = Emitter + contract = emitter_contract_factory event_filter = create_filter( contract, ["LogTripleWithIndex", {"filter": {"arg1": [1, 2], "arg2": [1, 2]}}] ) txn_hashes = [] - event_id = emitter_event_ids.LogTripleWithIndex + event_id = emitter_contract_event_ids.LogTripleWithIndex txn_hashes.append(emitter.functions.logTriple(event_id, 1, 1, 1).transact()) txn_hashes.append(emitter.functions.logTriple(event_id, 1, 1, 2).transact()) txn_hashes.append(emitter.functions.logTriple(event_id, 1, 2, 2).transact()) @@ -226,20 +234,22 @@ def event_loop(): @pytest.mark.asyncio -@pytest.mark.parametrize("call_as_instance", (True, False)) +@pytest.mark.parametrize("call_deployed_contract", (True, False)) async def test_async_create_filter_address_parameter( - async_emitter, AsyncEmitter, call_as_instance + async_emitter, async_emitter_contract_factory, call_deployed_contract ): - if call_as_instance: + if call_deployed_contract: event_filter = await async_emitter.events.LogNoArguments.create_filter( fromBlock="latest" ) else: - event_filter = await AsyncEmitter.events.LogNoArguments.create_filter( - fromBlock="latest" + event_filter = ( + await async_emitter_contract_factory.events.LogNoArguments.create_filter( + fromBlock="latest" + ) ) - if call_as_instance: + if call_deployed_contract: # Assert this is a single string value, and not a list of addresses assert is_address(event_filter.filter_params["address"]) else: @@ -248,23 +258,23 @@ async def test_async_create_filter_address_parameter( @pytest.mark.asyncio -@pytest.mark.parametrize("call_as_instance", (True, False)) +@pytest.mark.parametrize("call_deployed_contract", (True, False)) @pytest.mark.parametrize("api_style", ("v4", "build_filter")) async def test_on_async_filter_using_get_entries_interface( async_w3, async_emitter, - AsyncEmitter, + async_emitter_contract_factory, async_wait_for_transaction, - emitter_event_ids, - call_as_instance, + emitter_contract_event_ids, + call_deployed_contract, api_style, async_create_filter, ): - if call_as_instance: + if call_deployed_contract: contract = async_emitter else: - contract = AsyncEmitter + contract = async_emitter_contract_factory if api_style == "build_filter": event_filter = await contract.events.LogNoArguments.build_filter().deploy( @@ -274,7 +284,7 @@ async def test_on_async_filter_using_get_entries_interface( event_filter = await async_create_filter(async_emitter, ["LogNoArguments", {}]) txn_hash = await async_emitter.functions.logNoArgs( - emitter_event_ids.LogNoArguments + emitter_contract_event_ids.LogNoArguments ).transact() await async_wait_for_transaction(async_w3, txn_hash) @@ -288,23 +298,23 @@ async def test_on_async_filter_using_get_entries_interface( @pytest.mark.asyncio -@pytest.mark.parametrize("call_as_instance", (True, False)) +@pytest.mark.parametrize("call_deployed_contract", (True, False)) @pytest.mark.parametrize("api_style", ("v4", "build_filter")) async def test_on_async_filter_with_event_name_and_single_argument( async_w3, async_emitter, - AsyncEmitter, + async_emitter_contract_factory, async_wait_for_transaction, - emitter_event_ids, - call_as_instance, + emitter_contract_event_ids, + call_deployed_contract, api_style, async_create_filter, ): - if call_as_instance: + if call_deployed_contract: contract = async_emitter else: - contract = AsyncEmitter + contract = async_emitter_contract_factory if api_style == "build_filter": builder = contract.events.LogTripleWithIndex.build_filter() @@ -324,7 +334,7 @@ async def test_on_async_filter_with_event_name_and_single_argument( ) txn_hashes = [] - event_id = emitter_event_ids.LogTripleWithIndex + event_id = emitter_contract_event_ids.LogTripleWithIndex txn_hashes.append( await async_emitter.functions.logTriple(event_id, 2, 1, 3).transact() ) @@ -343,23 +353,23 @@ async def test_on_async_filter_with_event_name_and_single_argument( @pytest.mark.asyncio -@pytest.mark.parametrize("call_as_instance", (True, False)) +@pytest.mark.parametrize("call_deployed_contract", (True, False)) @pytest.mark.parametrize("api_style", ("v4", "build_filter")) async def test_on_async_filter_with_event_name_and_non_indexed_argument( async_w3, async_emitter, - AsyncEmitter, + async_emitter_contract_factory, async_wait_for_transaction, - emitter_event_ids, - call_as_instance, + emitter_contract_event_ids, + call_deployed_contract, api_style, async_create_filter, ): - if call_as_instance: + if call_deployed_contract: contract = async_emitter else: - contract = AsyncEmitter + contract = async_emitter_contract_factory if api_style == "build_filter": builder = contract.events.LogTripleWithIndex.build_filter() @@ -381,7 +391,7 @@ async def test_on_async_filter_with_event_name_and_non_indexed_argument( ) txn_hashes = [] - event_id = emitter_event_ids.LogTripleWithIndex + event_id = emitter_contract_event_ids.LogTripleWithIndex txn_hashes.append( await async_emitter.functions.logTriple(event_id, 2, 1, 3).transact() ) @@ -410,13 +420,13 @@ async def test_on_async_filter_with_event_name_and_non_indexed_argument( @pytest.mark.asyncio async def test_async_filter_with_contract_address( - async_w3, async_emitter, emitter_event_ids, async_wait_for_transaction + async_w3, async_emitter, emitter_contract_event_ids, async_wait_for_transaction ): event_filter = await async_w3.eth.filter( filter_params={"address": async_emitter.address} ) txn_hash = await async_emitter.functions.logNoArgs( - emitter_event_ids.LogNoArguments + emitter_contract_event_ids.LogNoArguments ).transact() await async_wait_for_transaction(async_w3, txn_hash) seen_logs = await event_filter.get_new_entries() @@ -425,28 +435,28 @@ async def test_async_filter_with_contract_address( @pytest.mark.asyncio -@pytest.mark.parametrize("call_as_instance", (True, False)) +@pytest.mark.parametrize("call_deployed_contract", (True, False)) async def test_on_async_filter_with_topic_filter_options_on_old_apis( async_w3, async_emitter, - AsyncEmitter, + async_emitter_contract_factory, async_wait_for_transaction, - emitter_event_ids, - call_as_instance, + emitter_contract_event_ids, + call_deployed_contract, async_create_filter, ): - if call_as_instance: + if call_deployed_contract: contract = async_emitter else: - contract = AsyncEmitter + contract = async_emitter_contract_factory event_filter = await async_create_filter( contract, ["LogTripleWithIndex", {"filter": {"arg1": [1, 2], "arg2": [1, 2]}}] ) txn_hashes = [] - event_id = emitter_event_ids.LogTripleWithIndex + event_id = emitter_contract_event_ids.LogTripleWithIndex txn_hashes.append( await async_emitter.functions.logTriple(event_id, 1, 1, 1).transact() ) diff --git a/tests/core/filtering/test_contract_past_event_filtering.py b/tests/core/filtering/test_contract_past_event_filtering.py index 40e8f13b4a..011b4f2248 100644 --- a/tests/core/filtering/test_contract_past_event_filtering.py +++ b/tests/core/filtering/test_contract_past_event_filtering.py @@ -6,22 +6,22 @@ ) -@pytest.mark.parametrize("call_as_instance", (True, False)) +@pytest.mark.parametrize("call_deployed_contract", (True, False)) @pytest.mark.parametrize("api_style", ("v4", "build_filter")) def test_on_filter_using_get_all_entries_interface( w3, emitter, - Emitter, + emitter_contract_factory, wait_for_transaction, - emitter_event_ids, - call_as_instance, + emitter_contract_event_ids, + call_deployed_contract, api_style, create_filter, ): - if call_as_instance: + if call_deployed_contract: contract = emitter else: - contract = Emitter + contract = emitter_contract_factory if api_style == "build_filter": builder = contract.events.LogNoArguments.build_filter() @@ -32,7 +32,9 @@ def test_on_filter_using_get_all_entries_interface( contract, ["LogNoArguments", {"fromBlock": "latest"}] ) - txn_hash = emitter.functions.logNoArgs(emitter_event_ids.LogNoArguments).transact() + txn_hash = emitter.functions.logNoArgs( + emitter_contract_event_ids.LogNoArguments + ).transact() wait_for_transaction(w3, txn_hash) log_entries = event_filter.get_all_entries() @@ -47,25 +49,27 @@ def test_on_filter_using_get_all_entries_interface( assert log_entries_2[0]["transactionHash"] == txn_hash -@pytest.mark.parametrize("call_as_instance", (True, False)) +@pytest.mark.parametrize("call_deployed_contract", (True, False)) @pytest.mark.parametrize("api_style", ("v4", "build_filter")) def test_get_all_entries_returned_block_data( w3, emitter, - Emitter, + emitter_contract_factory, wait_for_transaction, - emitter_event_ids, - call_as_instance, + emitter_contract_event_ids, + call_deployed_contract, api_style, create_filter, ): - txn_hash = emitter.functions.logNoArgs(emitter_event_ids.LogNoArguments).transact() + txn_hash = emitter.functions.logNoArgs( + emitter_contract_event_ids.LogNoArguments + ).transact() txn_receipt = wait_for_transaction(w3, txn_hash) - if call_as_instance: + if call_deployed_contract: contract = emitter else: - contract = Emitter + contract = emitter_contract_factory if api_style == "build_filter": builder = contract.events.LogNoArguments.build_filter() @@ -99,22 +103,22 @@ def event_loop(): @pytest.mark.asyncio -@pytest.mark.parametrize("call_as_instance", (True, False)) +@pytest.mark.parametrize("call_deployed_contract", (True, False)) @pytest.mark.parametrize("api_style", ("v4", "build_filter")) async def test_on_async_filter_using_get_all_entries_interface( async_w3, async_emitter, - AsyncEmitter, + async_emitter_contract_factory, async_wait_for_transaction, - emitter_event_ids, - call_as_instance, + emitter_contract_event_ids, + call_deployed_contract, api_style, async_create_filter, ): - if call_as_instance: + if call_deployed_contract: contract = async_emitter else: - contract = AsyncEmitter + contract = async_emitter_contract_factory if api_style == "build_filter": builder = contract.events.LogNoArguments.build_filter() @@ -126,7 +130,7 @@ async def test_on_async_filter_using_get_all_entries_interface( ) txn_hash = await async_emitter.functions.logNoArgs( - emitter_event_ids.LogNoArguments + emitter_contract_event_ids.LogNoArguments ).transact() await async_wait_for_transaction(async_w3, txn_hash) @@ -143,27 +147,27 @@ async def test_on_async_filter_using_get_all_entries_interface( @pytest.mark.asyncio -@pytest.mark.parametrize("call_as_instance", (True, False)) +@pytest.mark.parametrize("call_deployed_contract", (True, False)) @pytest.mark.parametrize("api_style", ("v4", "build_filter")) async def test_async_get_all_entries_returned_block_data( async_w3, async_emitter, - AsyncEmitter, + async_emitter_contract_factory, async_wait_for_transaction, - emitter_event_ids, - call_as_instance, + emitter_contract_event_ids, + call_deployed_contract, api_style, async_create_filter, ): txn_hash = await async_emitter.functions.logNoArgs( - emitter_event_ids.LogNoArguments + emitter_contract_event_ids.LogNoArguments ).transact() txn_receipt = await async_wait_for_transaction(async_w3, txn_hash) - if call_as_instance: + if call_deployed_contract: contract = async_emitter else: - contract = AsyncEmitter + contract = async_emitter_contract_factory if api_style == "build_filter": builder = contract.events.LogNoArguments.build_filter() diff --git a/tests/core/filtering/test_contract_topic_filters.py b/tests/core/filtering/test_contract_topic_filters.py index 9712978828..6ba4673520 100644 --- a/tests/core/filtering/test_contract_topic_filters.py +++ b/tests/core/filtering/test_contract_topic_filters.py @@ -18,35 +18,6 @@ _async_wait_for_block_fixture_logic, _async_wait_for_transaction_fixture_logic, ) -from web3._utils.module_testing.emitter_contract import ( - CONTRACT_EMITTER_ABI, - CONTRACT_EMITTER_CODE, - CONTRACT_EMITTER_RUNTIME, -) - - -@pytest.fixture(scope="module") -def EMITTER_CODE(): - return CONTRACT_EMITTER_CODE - - -@pytest.fixture(scope="module") -def EMITTER_RUNTIME(): - return CONTRACT_EMITTER_RUNTIME - - -@pytest.fixture(scope="module") -def EMITTER_ABI(): - return CONTRACT_EMITTER_ABI - - -@pytest.fixture(scope="module") -def EMITTER(EMITTER_CODE, EMITTER_RUNTIME, EMITTER_ABI): - return { - "bytecode": EMITTER_CODE, - "bytecode_runtime": EMITTER_RUNTIME, - "abi": EMITTER_ABI, - } def not_empty_string(x): @@ -115,14 +86,20 @@ def w3(request): @pytest.fixture(scope="module") -def Emitter(w3, EMITTER): - return w3.eth.contract(**EMITTER) - - -@pytest.fixture(scope="module") -def emitter(w3, Emitter, wait_for_transaction, wait_for_block, address_conversion_func): +def emitter( + w3, + emitter_contract_data, + wait_for_transaction, + wait_for_block, + address_conversion_func, +): + emitter_contract_factory = w3.eth.contract(**emitter_contract_data) return _emitter_fixture_logic( - w3, Emitter, wait_for_transaction, wait_for_block, address_conversion_func + w3, + emitter_contract_factory, + wait_for_transaction, + wait_for_block, + address_conversion_func, ) @@ -292,22 +269,19 @@ def async_w3(request): return _async_w3_fixture_logic(request) -@pytest_asyncio.fixture(scope="module") -def AsyncEmitter(async_w3, EMITTER): - return async_w3.eth.contract(**EMITTER) - - @pytest_asyncio.fixture(scope="module") async def async_emitter( async_w3, - AsyncEmitter, + emitter_contract_data, async_wait_for_transaction, async_wait_for_block, address_conversion_func, ): + async_emitter_contract_factory = async_w3.eth.contract(**emitter_contract_data) + return await _async_emitter_fixture_logic( async_w3, - AsyncEmitter, + async_emitter_contract_factory, async_wait_for_transaction, async_wait_for_block, address_conversion_func, @@ -327,7 +301,6 @@ async def test_async_topic_filters_with_dynamic_arguments( vals, ): if api_style == "build_filter": - filter_builder = async_emitter.events.LogDynamicArgs.build_filter() filter_builder.args["arg0"].match_single(vals["matching"]) event_filter = await filter_builder.deploy(async_w3) diff --git a/tests/core/filtering/test_filter_against_transaction_logs.py b/tests/core/filtering/test_filter_against_transaction_logs.py index 49172f0891..d97f06c1fe 100644 --- a/tests/core/filtering/test_filter_against_transaction_logs.py +++ b/tests/core/filtering/test_filter_against_transaction_logs.py @@ -2,12 +2,14 @@ def test_sync_filter_against_log_events( - w3, emitter, wait_for_transaction, emitter_event_ids + w3, emitter, wait_for_transaction, emitter_contract_event_ids ): txn_filter = w3.eth.filter({}) txn_hashes = set() txn_hashes.add( - emitter.functions.logNoArgs(emitter_event_ids.LogNoArguments).transact() + emitter.functions.logNoArgs( + emitter_contract_event_ids.LogNoArguments + ).transact() ) for txn_hash in txn_hashes: @@ -20,13 +22,13 @@ def test_sync_filter_against_log_events( @pytest.mark.asyncio async def test_async_filter_against_log_events( - async_w3, async_emitter, async_wait_for_transaction, emitter_event_ids + async_w3, async_emitter, async_wait_for_transaction, emitter_contract_event_ids ): txn_filter = await async_w3.eth.filter({}) txn_hashes = set() txn_hashes.add( await async_emitter.functions.logNoArgs( - emitter_event_ids.LogNoArguments + emitter_contract_event_ids.LogNoArguments ).transact() ) diff --git a/tests/core/filtering/test_filters_against_many_blocks.py b/tests/core/filtering/test_filters_against_many_blocks.py index 9a8633d230..1a31532060 100644 --- a/tests/core/filtering/test_filters_against_many_blocks.py +++ b/tests/core/filtering/test_filters_against_many_blocks.py @@ -36,9 +36,9 @@ def single_transaction(w3): def test_event_filter_new_events( w3, emitter, - Emitter, + emitter_contract_factory, wait_for_transaction, - emitter_event_ids, + emitter_contract_event_ids, api_style, create_filter, ): @@ -103,16 +103,18 @@ def test_transaction_filter_without_mining(w3): def test_event_filter_new_events_many_deployed_contracts( w3, emitter, - Emitter, + emitter_contract_factory, wait_for_transaction, - emitter_event_ids, + emitter_contract_event_ids, api_style, create_filter, ): matching_transact = emitter.functions.logNoArgs(which=1).transact - deployed_contract_addresses = deploy_contracts(w3, Emitter, wait_for_transaction) + deployed_contract_addresses = deploy_contracts( + w3, emitter_contract_factory, wait_for_transaction + ) def gen_non_matching_transact(): while True: @@ -120,7 +122,7 @@ def gen_non_matching_transact(): random.randint(0, len(deployed_contract_addresses) - 1) ] yield w3.eth.contract( - address=contract_address, abi=Emitter.abi + address=contract_address, abi=emitter_contract_factory.abi ).functions.logNoArgs(which=1).transact non_matching_transact = gen_non_matching_transact() @@ -265,7 +267,7 @@ async def test_async_transaction_filter_without_mining(async_w3): async def test_async_event_filter_new_events_many_deployed_contracts( async_w3, async_emitter, - AsyncEmitter, + async_emitter_contract_factory, async_wait_for_transaction, api_style, ): @@ -273,7 +275,7 @@ async def test_async_event_filter_new_events_many_deployed_contracts( matching_transact = async_emitter.functions.logNoArgs(which=1).transact deployed_contract_addresses = await async_deploy_contracts( - async_w3, AsyncEmitter, async_wait_for_transaction + async_w3, async_emitter_contract_factory, async_wait_for_transaction ) async def gen_non_matching_transact(): @@ -282,7 +284,7 @@ async def gen_non_matching_transact(): random.randint(0, len(deployed_contract_addresses) - 1) ] yield async_w3.eth.contract( - address=contract_address, abi=AsyncEmitter.abi + address=contract_address, abi=async_emitter_contract_factory.abi ).functions.logNoArgs(which=1).transact non_matching_transact = gen_non_matching_transact() diff --git a/tests/core/filtering/utils.py b/tests/core/filtering/utils.py index 5c38af984d..ef54e97869 100644 --- a/tests/core/filtering/utils.py +++ b/tests/core/filtering/utils.py @@ -22,16 +22,20 @@ def _w3_fixture_logic(request): def _emitter_fixture_logic( - w3, Emitter, wait_for_transaction, wait_for_block, address_conversion_func + w3, + emitter_contract_factory, + wait_for_transaction, + wait_for_block, + address_conversion_func, ): wait_for_block(w3) - deploy_txn_hash = Emitter.constructor().transact({"gas": 10000000}) + deploy_txn_hash = emitter_contract_factory.constructor().transact({"gas": 10000000}) deploy_receipt = wait_for_transaction(w3, deploy_txn_hash) contract_address = address_conversion_func(deploy_receipt["contractAddress"]) bytecode = w3.eth.get_code(contract_address) - assert bytecode == Emitter.bytecode_runtime - _emitter = Emitter(address=contract_address) + assert bytecode == emitter_contract_factory.bytecode_runtime + _emitter = emitter_contract_factory(address=contract_address) assert _emitter.address == contract_address return _emitter @@ -51,18 +55,20 @@ def _async_w3_fixture_logic(request): async def _async_emitter_fixture_logic( async_w3, - AsyncEmitter, + async_emitter_contract_factory, async_wait_for_transaction, async_wait_for_block, address_conversion_func, ): await async_wait_for_block(async_w3) - deploy_txn_hash = await AsyncEmitter.constructor().transact({"gas": 10000000}) + deploy_txn_hash = await async_emitter_contract_factory.constructor().transact( + {"gas": 10000000} + ) deploy_receipt = await async_wait_for_transaction(async_w3, deploy_txn_hash) contract_address = address_conversion_func(deploy_receipt["contractAddress"]) bytecode = await async_w3.eth.get_code(contract_address) - assert bytecode == AsyncEmitter.bytecode_runtime - _emitter = AsyncEmitter(address=contract_address) + assert bytecode == async_emitter_contract_factory.bytecode_runtime + _emitter = async_emitter_contract_factory(address=contract_address) assert _emitter.address == contract_address return _emitter diff --git a/tests/ens/conftest.py b/tests/ens/conftest.py index 7fe0eb23e1..cc00a4a5f9 100644 --- a/tests/ens/conftest.py +++ b/tests/ens/conftest.py @@ -173,7 +173,7 @@ def ens_setup(): ) reverse_tld_namehash = bytes32( 0xA097F6721CE401E757D1223A763FEF49B8B5F90BB18567DDB86FD205DFF71D34 - ) # noqa: E501 + ) reverser_namehash = bytes32( 0x91D1777781884D03A6757A803996E38DE2A42967FB37EEACA72729271025A9E2 ) diff --git a/tests/integration/README.md b/tests/integration/README.md index 8d55dcd396..70999a6f8f 100644 --- a/tests/integration/README.md +++ b/tests/integration/README.md @@ -39,7 +39,7 @@ A block as returned by `web3.eth.get_block` that has a single transaction. #### `math_contract` An deployed Contract instance of the *Math* contract found in -`web3._utils.module_testing.math_contract`. +`web3._utils.contract_sources.MathContract.sol`. #### `unlocked_account` @@ -65,8 +65,8 @@ The transaction hash of a transaction which has been mined. #### `emitter_contract` -An deployed Contract instance of the *Emitter* contract found in -`web3._utils.module_testing.emitter_contract`. +A deployed Contract instance of the *EmitterContract* contract found in +`web3._utils.contract_sources.EmitterContract.sol`. #### `block_with_txn_with_log` diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index cddb026238..78d12b6481 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -1,20 +1,20 @@ import asyncio import pytest -from web3._utils.module_testing.emitter_contract import ( - CONTRACT_EMITTER_ABI, - CONTRACT_EMITTER_CODE, +from web3._utils.contract_sources.contract_data.emitter_contract import ( + EMITTER_CONTRACT_ABI, + EMITTER_CONTRACT_BYTECODE, ) -from web3._utils.module_testing.math_contract import ( - MATH_ABI, - MATH_BYTECODE, +from web3._utils.contract_sources.contract_data.math_contract import ( + MATH_CONTRACT_ABI, + MATH_CONTRACT_BYTECODE, ) -from web3._utils.module_testing.offchain_lookup_contract import ( +from web3._utils.contract_sources.contract_data.offchain_lookup import ( OFFCHAIN_LOOKUP_ABI, OFFCHAIN_LOOKUP_BYTECODE, ) -from web3._utils.module_testing.revert_contract import ( - _REVERT_CONTRACT_ABI, +from web3._utils.contract_sources.contract_data.revert_contract import ( + REVERT_CONTRACT_ABI, REVERT_CONTRACT_BYTECODE, ) @@ -58,14 +58,16 @@ def pytest_collection_modifyitems(items, config): @pytest.fixture(scope="module") def math_contract_factory(w3): - contract_factory = w3.eth.contract(abi=MATH_ABI, bytecode=MATH_BYTECODE) + contract_factory = w3.eth.contract( + abi=MATH_CONTRACT_ABI, bytecode=MATH_CONTRACT_BYTECODE + ) return contract_factory @pytest.fixture(scope="module") def emitter_contract_factory(w3): contract_factory = w3.eth.contract( - abi=CONTRACT_EMITTER_ABI, bytecode=CONTRACT_EMITTER_CODE + abi=EMITTER_CONTRACT_ABI, bytecode=EMITTER_CONTRACT_BYTECODE ) return contract_factory @@ -73,7 +75,7 @@ def emitter_contract_factory(w3): @pytest.fixture(scope="module") def revert_contract_factory(w3): contract_factory = w3.eth.contract( - abi=_REVERT_CONTRACT_ABI, bytecode=REVERT_CONTRACT_BYTECODE + abi=REVERT_CONTRACT_ABI, bytecode=REVERT_CONTRACT_BYTECODE ) return contract_factory diff --git a/tests/integration/generate_fixtures/go_ethereum.py b/tests/integration/generate_fixtures/go_ethereum.py index f1093422bd..af9c03d44f 100644 --- a/tests/integration/generate_fixtures/go_ethereum.py +++ b/tests/integration/generate_fixtures/go_ethereum.py @@ -23,21 +23,23 @@ import common from web3 import Web3 -from web3._utils.module_testing.emitter_contract import ( - CONTRACT_EMITTER_ABI, - CONTRACT_EMITTER_CODE, +from web3._utils.contract_sources.contract_data._custom_contract_data import ( EMITTER_ENUM, ) -from web3._utils.module_testing.math_contract import ( - MATH_ABI, - MATH_BYTECODE, +from web3._utils.contract_sources.contract_data.emitter_contract import ( + EMITTER_CONTRACT_ABI, + EMITTER_CONTRACT_BYTECODE, ) -from web3._utils.module_testing.offchain_lookup_contract import ( +from web3._utils.contract_sources.contract_data.math_contract import ( + MATH_CONTRACT_ABI, + MATH_CONTRACT_BYTECODE, +) +from web3._utils.contract_sources.contract_data.offchain_lookup import ( OFFCHAIN_LOOKUP_ABI, OFFCHAIN_LOOKUP_BYTECODE, ) -from web3._utils.module_testing.revert_contract import ( - _REVERT_CONTRACT_ABI, +from web3._utils.contract_sources.contract_data.revert_contract import ( + REVERT_CONTRACT_ABI, REVERT_CONTRACT_BYTECODE, ) @@ -217,8 +219,8 @@ def setup_chain_state(w3): # Math Contract # math_contract_factory = w3.eth.contract( - abi=MATH_ABI, - bytecode=MATH_BYTECODE, + abi=MATH_CONTRACT_ABI, + bytecode=MATH_CONTRACT_BYTECODE, ) math_deploy_receipt = common.deploy_contract(w3, "math", math_contract_factory) assert is_dict(math_deploy_receipt) @@ -227,8 +229,8 @@ def setup_chain_state(w3): # Emitter Contract # emitter_contract_factory = w3.eth.contract( - abi=CONTRACT_EMITTER_ABI, - bytecode=CONTRACT_EMITTER_CODE, + abi=EMITTER_CONTRACT_ABI, + bytecode=EMITTER_CONTRACT_BYTECODE, ) emitter_deploy_receipt = common.deploy_contract( w3, "emitter", emitter_contract_factory @@ -255,7 +257,7 @@ def setup_chain_state(w3): # Revert Contract # revert_contract_factory = w3.eth.contract( - abi=_REVERT_CONTRACT_ABI, + abi=REVERT_CONTRACT_ABI, bytecode=REVERT_CONTRACT_BYTECODE, ) revert_deploy_receipt = common.deploy_contract( diff --git a/tests/integration/geth-1.10.25-fixture.zip b/tests/integration/geth-1.10.25-fixture.zip index bef01879a5..71a6e55971 100644 Binary files a/tests/integration/geth-1.10.25-fixture.zip and b/tests/integration/geth-1.10.25-fixture.zip differ diff --git a/tests/integration/test_ethereum_tester.py b/tests/integration/test_ethereum_tester.py index e22c9e1b4a..3c08e3308f 100644 --- a/tests/integration/test_ethereum_tester.py +++ b/tests/integration/test_ethereum_tester.py @@ -14,15 +14,15 @@ ) from web3 import Web3 +from web3._utils.contract_sources.contract_data._custom_contract_data import ( + EMITTER_ENUM, +) from web3._utils.module_testing import ( EthModuleTest, GoEthereumPersonalModuleTest, NetModuleTest, Web3ModuleTest, ) -from web3._utils.module_testing.emitter_contract import ( - EMITTER_ENUM, -) from web3.providers.eth_tester import ( EthereumTesterProvider, ) diff --git a/web3/_utils/contract_sources/ArraysContract.sol b/web3/_utils/contract_sources/ArraysContract.sol new file mode 100644 index 0000000000..199bd58c5b --- /dev/null +++ b/web3/_utils/contract_sources/ArraysContract.sol @@ -0,0 +1,37 @@ +pragma solidity >=0.7.0; + +contract ArraysContract { + bytes32[] public bytes32Value; + bytes32[] public bytes32ConstValue = [keccak256('A'), keccak256('B')]; + bytes1[] public byteValue; + bytes1[] public byteConstValue = [bytes1(hex"00"), bytes1(hex"01")]; + + constructor(bytes32[] memory _bytes32Value, bytes1[] memory _byteValue) { + bytes32Value = _bytes32Value; + byteValue = _byteValue; + } + + function getBytes32ConstValue() public view returns (bytes32[] memory) { + return bytes32ConstValue; + } + + function getByteConstValue() public view returns (bytes1[] memory){ + return byteConstValue; + } + + function setBytes32Value(bytes32[] memory _bytes32Value) public { + bytes32Value = _bytes32Value; + } + + function getBytes32Value() public view returns (bytes32[] memory) { + return bytes32Value; + } + + function setByteValue(bytes1[] memory _byteValue) public { + byteValue = _byteValue; + } + + function getByteValue() public view returns (bytes1[] memory) { + return byteValue; + } +} \ No newline at end of file diff --git a/web3/_utils/contract_sources/BytesContracts.sol b/web3/_utils/contract_sources/BytesContracts.sol new file mode 100644 index 0000000000..c4735703c1 --- /dev/null +++ b/web3/_utils/contract_sources/BytesContracts.sol @@ -0,0 +1,43 @@ +pragma solidity >=0.7.0; + +contract BytesContract { + bytes const = hex"0123"; + bytes value; + + constructor (bytes memory _value) { + value = _value; + } + + function constValue() public view returns(bytes memory) { + return const; + } + + function getValue() public view returns(bytes memory) { + return value; + } + + function setValue(bytes memory _value) public { + value = _value; + } +} + +contract Bytes32Contract { + bytes32 const = hex"0123012301230123012301230123012301230123012301230123012301230123"; + bytes32 value; + + constructor (bytes32 _value) { + value = _value; + } + + function constValue() public view returns(bytes32) { + return const; + } + + function getValue() public view returns(bytes32) { + return value; + } + + function setValue(bytes32 _value) public { + value = _value; + } +} diff --git a/web3/_utils/contract_sources/ConstructorContracts.sol b/web3/_utils/contract_sources/ConstructorContracts.sol new file mode 100644 index 0000000000..32d0e87850 --- /dev/null +++ b/web3/_utils/contract_sources/ConstructorContracts.sol @@ -0,0 +1,23 @@ +pragma solidity >=0.7.0; + +contract SimpleConstructorContract { + constructor() {} +} + +contract ConstructorWithArgumentsContract { + uint256 public data_a; + bytes32 public data_b; + + constructor(uint256 a, bytes32 b) { + data_a = a; + data_b = b; + } +} + +contract ConstructorWithAddressArgumentContract { + address public testAddr; + + constructor(address _testAddr) { + testAddr = _testAddr; + } +} diff --git a/web3/_utils/contract_sources/ContractCallerTester.sol b/web3/_utils/contract_sources/ContractCallerTester.sol new file mode 100644 index 0000000000..62e06dc719 --- /dev/null +++ b/web3/_utils/contract_sources/ContractCallerTester.sol @@ -0,0 +1,21 @@ +pragma solidity >=0.7.0; + +contract ContractCallerTester { + int public count; + + function add(int256 a, int256 b) public payable returns (int256) { + return a + b; + } + + function increment() public returns (int256) { + return count += 1; + } + + function counter() public payable returns (int256) { + return count; + } + + function returnMeta() public payable returns (address, bytes memory, uint256, uint, uint) { + return (msg.sender, msg.data, gasleft(), msg.value, block.number); + } +} \ No newline at end of file diff --git a/web3/_utils/contract_sources/Emitter.sol b/web3/_utils/contract_sources/EmitterContract.sol similarity index 98% rename from web3/_utils/contract_sources/Emitter.sol rename to web3/_utils/contract_sources/EmitterContract.sol index d0558be2d8..798bd940fe 100644 --- a/web3/_utils/contract_sources/Emitter.sol +++ b/web3/_utils/contract_sources/EmitterContract.sol @@ -1,7 +1,7 @@ -pragma solidity ^0.8.11; +pragma solidity >=0.8.0; -contract Emitter { +contract EmitterContract { event LogAnonymous() anonymous; event LogNoArguments(); event LogSingleArg(uint arg0); @@ -10,7 +10,6 @@ contract Emitter { event LogQuadrupleArg(uint arg0, uint arg1, uint arg2, uint arg3); event LogString(string v); event LogBytes(bytes v); - event LogSingleWithIndex(uint indexed arg0); event LogSingleAnonymous(uint indexed arg0) anonymous; event LogDoubleWithIndex(uint arg0, uint indexed arg1); diff --git a/web3/_utils/contract_sources/EventContracts.sol b/web3/_utils/contract_sources/EventContracts.sol new file mode 100644 index 0000000000..87230b4d14 --- /dev/null +++ b/web3/_utils/contract_sources/EventContracts.sol @@ -0,0 +1,21 @@ +pragma solidity >=0.6.0; + +contract EventContract { + event LogSingleArg(uint256 arg0); + event LogSingleWithIndex(uint256 arg0); + + function logTwoEvents(uint256 _arg0) public { + emit LogSingleWithIndex(_arg0); + emit LogSingleArg(_arg0); + } +} + +contract IndexedEventContract { + event LogSingleArg(uint256 arg0); + event LogSingleWithIndex(uint256 indexed arg0); + + function logTwoEvents(uint256 _arg0) public { + emit LogSingleWithIndex(_arg0); + emit LogSingleArg(_arg0); + } +} diff --git a/web3/_utils/contract_sources/FallbackFunctionContract.sol b/web3/_utils/contract_sources/FallbackFunctionContract.sol new file mode 100644 index 0000000000..2b061e7b33 --- /dev/null +++ b/web3/_utils/contract_sources/FallbackFunctionContract.sol @@ -0,0 +1,8 @@ +pragma solidity >=0.5.4; + +contract FallbackFunctionContract { + uint data; + constructor() payable { data = 0; } + function getData() public view returns (uint r) { return data; } + fallback() external { data = 1; } +} diff --git a/web3/_utils/contract_sources/MathContract.sol b/web3/_utils/contract_sources/MathContract.sol new file mode 100644 index 0000000000..11c28deace --- /dev/null +++ b/web3/_utils/contract_sources/MathContract.sol @@ -0,0 +1,31 @@ +pragma solidity >=0.7.0; + +contract MathContract { + uint256 public counter = 0; + + event Increased(uint256 value); + + function incrementCounter() public payable returns(uint256 result) { + counter = counter + 1; + emit Increased(1); + return counter; + } + + function incrementCounter(uint256 amount) public payable returns(uint256 result) { + counter = counter + amount; + emit Increased(amount); + return counter; + } + + function return13() public returns(int256 result) { + return 13; + } + + function multiply7(int256 a) public payable returns(int256 result) { + return a * 7; + } + + function add(int256 a, int256 b) public payable returns(int256 result) { + return a + b; + } +} diff --git a/web3/_utils/contract_sources/OffchainLookup.sol b/web3/_utils/contract_sources/OffchainLookup.sol index 3d2a1649d7..ef199f126a 100644 --- a/web3/_utils/contract_sources/OffchainLookup.sol +++ b/web3/_utils/contract_sources/OffchainLookup.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.13; -contract OffchainLookupTests { +contract OffchainLookup { string[] urls = ["https://web3.py/gateway/{sender}/{data}.json", "https://web3.py/gateway/{sender}.json"]; error OffchainLookup(address sender, string[] urls, bytes callData, bytes4 callbackFunction, bytes extraData); diff --git a/web3/_utils/contract_sources/PayableTester.sol b/web3/_utils/contract_sources/PayableTester.sol new file mode 100644 index 0000000000..5de0407e76 --- /dev/null +++ b/web3/_utils/contract_sources/PayableTester.sol @@ -0,0 +1,10 @@ +pragma solidity >=0.6.0; + + +contract PayableTesterContract { + bool public wasCalled; + + function doNoValueCall() external { + wasCalled = true; + } +} diff --git a/web3/_utils/contract_sources/ReceiveFunctionContracts.sol b/web3/_utils/contract_sources/ReceiveFunctionContracts.sol new file mode 100644 index 0000000000..739ecaefc3 --- /dev/null +++ b/web3/_utils/contract_sources/ReceiveFunctionContracts.sol @@ -0,0 +1,38 @@ +pragma solidity >=0.6.0; + + +contract ReceiveFunctionContract { + string text; + + fallback() external payable { + text = 'fallback'; + } + + receive() external payable { + text = 'receive'; + } + + function getText() public view returns (string memory) { + return text; + } + + function setText(string memory new_text) public returns (string memory) { + return text = new_text; + } +} + +contract NoReceiveFunctionContract { + string text; + + fallback() external { + text = 'fallback'; + } + + function getText() public view returns (string memory) { + return text; + } + + function setText(string memory new_text) public returns (string memory) { + return text = new_text; + } +} diff --git a/web3/_utils/contract_sources/ReflectorContracts.sol b/web3/_utils/contract_sources/ReflectorContracts.sol new file mode 100644 index 0000000000..c7c4772872 --- /dev/null +++ b/web3/_utils/contract_sources/ReflectorContracts.sol @@ -0,0 +1,11 @@ +pragma solidity >=0.4.0; + +contract AddressReflectorContract { + function reflect(address arg) public pure returns(address) { + return arg; + } + + function reflect(address[] memory arg) public pure returns(address[] memory) { + return arg; + } +} diff --git a/web3/_utils/contract_sources/RevertContract.sol b/web3/_utils/contract_sources/RevertContract.sol new file mode 100644 index 0000000000..07f24a7d9b --- /dev/null +++ b/web3/_utils/contract_sources/RevertContract.sol @@ -0,0 +1,15 @@ +pragma solidity >=0.6.1; + +contract RevertContract { + function normalFunction() public pure returns (bool) { + return true; + } + + function revertWithMessage() public pure { + revert('Function has been reverted.'); + } + + function revertWithoutMessage() public pure { + revert(); + } +} diff --git a/web3/_utils/contract_sources/StringContract.sol b/web3/_utils/contract_sources/StringContract.sol new file mode 100644 index 0000000000..acd852d4e3 --- /dev/null +++ b/web3/_utils/contract_sources/StringContract.sol @@ -0,0 +1,22 @@ +pragma solidity >=0.6.0; + +contract StringContract { + string public value; + + constructor (string memory _value) { + value = _value; + } + + function getValue() external payable returns(string memory) { + return value; + } + + function setValue(string memory _value) external { + value = _value; + } + + // for testing contract call to unknown function selector + fallback(bytes calldata _calldata) external returns(bytes memory) { + return _calldata; + } +} diff --git a/web3/_utils/contract_sources/TupleContracts.sol b/web3/_utils/contract_sources/TupleContracts.sol new file mode 100644 index 0000000000..23ca6e99f4 --- /dev/null +++ b/web3/_utils/contract_sources/TupleContracts.sol @@ -0,0 +1,20 @@ +pragma solidity >=0.6.0; + +contract TupleContract { + struct T { int x; bool[2] y; address[] z; } + struct S { uint a; uint[] b; T[] c; } + + function method(S memory s) public pure returns (S memory) { + return s; + } +} + +contract NestedTupleContract { + struct U { int x; int y; } + struct T { U[] u; } + struct S { T[] t; } + + function method(S memory s) public pure returns (S memory) { + return s; + } +} diff --git a/web3/_utils/contract_sources/__init__.py b/web3/_utils/contract_sources/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/web3/_utils/contract_sources/compile_contracts.py b/web3/_utils/contract_sources/compile_contracts.py new file mode 100644 index 0000000000..cd27a7ec4c --- /dev/null +++ b/web3/_utils/contract_sources/compile_contracts.py @@ -0,0 +1,180 @@ +""" +Arguments for the script are: + -v or --version Solidity version to be used to compile the contracts. If + blank, the script uses the latest hard-coded version + specified within the script. + + -f or --filename If left blank, all .sol files will be compiled and the + respective contract data will be generated. Pass in a + specific ``.sol`` filename here to compile just one file. + + +To run the script, you will need the ``py-solc-x`` library for compiling the files +as well as ``black`` for linting. You can install those independently or install the +full ``[dev]`` package extra as shown below. + +.. code:: sh + + $ pip install "web3[dev]" + +The following example compiles all the contracts and generates their respective +contract data that is used across our test files for the test suites. This data gets +generated within the ``contract_data`` subdirectory within the ``contract_sources`` +folder. + +.. code-block:: bash + + $ cd ../web3.py/web3/_utils/contract_sources + $ python compile_contracts.py -v 0.8.17 + Compiling OffchainLookup + ... + ... + reformatted ... + +To compile and generate contract data for only one ``.sol`` file, specify using the +filename with the ``-f`` (or ``--filename``) argument flag. + +.. code-block:: bash + + $ cd ../web3.py/web3/_utils/contract_sources + $ python compile_contracts.py -v 0.8.17 -f OffchainLookup.sol + Compiling OffchainLookup.sol + reformatted ... +""" + + +import argparse +import os +import re +from typing import ( + Any, +) + +import solcx + +arg_parser = argparse.ArgumentParser() +arg_parser.add_argument( + "-v", "--version", help="Solidity version for compiling contracts." +) +arg_parser.add_argument( + "-f", + "--filename", + help="(optional) The filename if only one file is to be compiled - " + "otherwise all .sol files will be compiled at once.", +) +user_args = arg_parser.parse_args() + +CONFIGURED_SOLIDITY_VERSION = "0.8.17" +# establish Solidity version from user-provided arg or use hard-coded version +user_sol_version = user_args.version + +solidity_version = user_sol_version if user_sol_version else CONFIGURED_SOLIDITY_VERSION +solcx.install_solc(solidity_version) +solcx.set_solc_version(solidity_version) + + +# compile just the .sol file specified or all .sol files +all_dot_sol_files = [f for f in os.listdir(os.getcwd()) if f.endswith(".sol")] +user_filename = user_args.filename +files_to_compile = [user_filename] if user_filename else all_dot_sol_files + + +def _compile_dot_sol_files(dot_sol_filename: str) -> dict[str, Any]: + compiled = solcx.compile_files( + [f"./{dot_sol_filename}"], + output_values=["abi", "bin", "bin-runtime"], + ) + return compiled + + +def _get_compiled_contract_data( + sol_file_output: dict[str, dict[str, str]], + dot_sol_filename: str, + contract_name: str = None, +) -> dict[str, str]: + if not contract_name: + contract_name = dot_sol_filename.replace(".sol", "") + + contract_data = None + for key in sol_file_output.keys(): + if f":{contract_name}" in key: + contract_data = sol_file_output[key] + if not contract_data: + raise Exception(f"Could not find compiled data for contract: {contract_name}") + + contract_data["bin"] = f"0x{contract_data['bin']}" + contract_data["bin-runtime"] = f"0x{contract_data['bin-runtime']}" + + return contract_data + + +contracts_in_file = {} + + +def compile_files(file_list: list[str]) -> None: + for filename in file_list: + with open(os.path.join(os.getcwd(), filename), "r") as f: + dot_sol_file = f.readlines() + + contract_names = [] + + for line in dot_sol_file: + if all(_ in line for _ in ["contract", "{"]) and "abstract" not in line: + start_index = line.find("contract ") + len("contract ") + end_index = line[start_index:].find(" ") + start_index + contract_name = line[start_index:end_index] + contract_names.append(contract_name) + + contracts_in_file[filename] = contract_names + + for dot_sol_filename in contracts_in_file.keys(): + filename_no_extension = dot_sol_filename.replace(".sol", "") + split_and_lowercase = [ + i.lower() for i in re.split(r"([A-Z][a-z]*)", filename_no_extension) if i + ] + python_filename = f"{'_'.join(split_and_lowercase)}.py" + python_file_path = os.path.join(os.getcwd(), "contract_data", python_filename) + try: + # clean up existing files + os.remove(python_file_path) + except FileNotFoundError: + pass + print(f"compiling {dot_sol_filename}") + compiled_dot_sol_data = _compile_dot_sol_files(dot_sol_filename) + with open(python_file_path, "w") as f: + f.write(f'"""\nGenerated by `{os.path.basename(__file__)}` script.\n') + f.write(f'Compiled with Solidity v{solidity_version}.\n"""\n\n') + + for c in contracts_in_file[dot_sol_filename]: + c_name_split_and_uppercase = [ + i.upper() for i in re.split(r"([A-Z0-9][a-z0-9]*)", c) if i + ] + contract_upper = "_".join(c_name_split_and_uppercase) + + c_data = _get_compiled_contract_data( + compiled_dot_sol_data, dot_sol_filename, c + ) + + contract_source = ( + f"# source: web3/_utils/contract_sources/{dot_sol_filename}:{c}" + ) + if len(contract_source) > 88: + contract_source += " # noqa: E501" + + f.write(f"{contract_source}\n") + f.write( + f'{contract_upper}_BYTECODE = "{c_data["bin"]}" # noqa: E501\n' + ) + f.write( + f'{contract_upper}_RUNTIME = "{c_data["bin-runtime"]}" # noqa: E501\n' + ) + f.write(f"{contract_upper}_ABI = {c_data['abi']}\n") + f.write(contract_upper + "_DATA = {\n") + f.write(f' "bytecode": {contract_upper}_BYTECODE,\n') + f.write(f' "bytecode_runtime": {contract_upper}_RUNTIME,\n') + f.write(f' "abi": {contract_upper}_ABI,\n') + f.write("}\n\n\n") + + +compile_files(files_to_compile) +os.system(f"black {os.getcwd()}") diff --git a/web3/_utils/contract_sources/contract_data/__init__.py b/web3/_utils/contract_sources/contract_data/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/web3/_utils/contract_sources/contract_data/_custom_contract_data.py b/web3/_utils/contract_sources/contract_data/_custom_contract_data.py new file mode 100644 index 0000000000..af6c64736f --- /dev/null +++ b/web3/_utils/contract_sources/contract_data/_custom_contract_data.py @@ -0,0 +1,21 @@ +EMITTER_ENUM = { + "LogAnonymous": 0, + "LogNoArguments": 1, + "LogSingleArg": 2, + "LogDoubleArg": 3, + "LogTripleArg": 4, + "LogQuadrupleArg": 5, + "LogSingleAnonymous": 6, + "LogSingleWithIndex": 7, + "LogDoubleAnonymous": 8, + "LogDoubleWithIndex": 9, + "LogTripleWithIndex": 10, + "LogQuadrupleWithIndex": 11, + "LogBytes": 12, + "LogString": 13, + "LogDynamicArgs": 14, + "LogListArgs": 15, + "LogAddressIndexed": 16, + "LogAddressNotIndexed": 17, + "LogStructArgs": 18, +} diff --git a/web3/_utils/contract_sources/contract_data/address_reflector.py b/web3/_utils/contract_sources/contract_data/address_reflector.py new file mode 100644 index 0000000000..e82f121f75 --- /dev/null +++ b/web3/_utils/contract_sources/contract_data/address_reflector.py @@ -0,0 +1,29 @@ +""" +Generated by `compile_contract_sources.py` script. +Compiled with Solidity v0.8.17. +""" + +# source: web3/_utils/contract_sources/AddressReflector.sol:AddressReflector +ADDRESS_REFLECTOR_BYTECODE = "0x608060405234801561001057600080fd5b50610430806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80630b816c161461003b578063c04d11fc1461006b575b600080fd5b61005560048036038101906100509190610121565b61009b565b604051610062919061015d565b60405180910390f35b610085600480360381019061008091906102d1565b6100a5565b60405161009291906103d8565b60405180910390f35b6000819050919050565b6060819050919050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100ee826100c3565b9050919050565b6100fe816100e3565b811461010957600080fd5b50565b60008135905061011b816100f5565b92915050565b600060208284031215610137576101366100b9565b5b60006101458482850161010c565b91505092915050565b610157816100e3565b82525050565b6000602082019050610172600083018461014e565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6101c68261017d565b810181811067ffffffffffffffff821117156101e5576101e461018e565b5b80604052505050565b60006101f86100af565b905061020482826101bd565b919050565b600067ffffffffffffffff8211156102245761022361018e565b5b602082029050602081019050919050565b600080fd5b600061024d61024884610209565b6101ee565b905080838252602082019050602084028301858111156102705761026f610235565b5b835b818110156102995780610285888261010c565b845260208401935050602081019050610272565b5050509392505050565b600082601f8301126102b8576102b7610178565b5b81356102c884826020860161023a565b91505092915050565b6000602082840312156102e7576102e66100b9565b5b600082013567ffffffffffffffff811115610305576103046100be565b5b610311848285016102a3565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b61034f816100e3565b82525050565b60006103618383610346565b60208301905092915050565b6000602082019050919050565b60006103858261031a565b61038f8185610325565b935061039a83610336565b8060005b838110156103cb5781516103b28882610355565b97506103bd8361036d565b92505060018101905061039e565b5085935050505092915050565b600060208201905081810360008301526103f2818461037a565b90509291505056fea264697066735822122035083763a0f4c4f5a71055f0da2f3d4f78e64159a8f3bc215c430daec7ac5e2064736f6c63430008110033" # noqa: E501 +ADDRESS_REFLECTOR_RUNTIME = "0x608060405234801561001057600080fd5b50600436106100365760003560e01c80630b816c161461003b578063c04d11fc1461006b575b600080fd5b61005560048036038101906100509190610121565b61009b565b604051610062919061015d565b60405180910390f35b610085600480360381019061008091906102d1565b6100a5565b60405161009291906103d8565b60405180910390f35b6000819050919050565b6060819050919050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100ee826100c3565b9050919050565b6100fe816100e3565b811461010957600080fd5b50565b60008135905061011b816100f5565b92915050565b600060208284031215610137576101366100b9565b5b60006101458482850161010c565b91505092915050565b610157816100e3565b82525050565b6000602082019050610172600083018461014e565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6101c68261017d565b810181811067ffffffffffffffff821117156101e5576101e461018e565b5b80604052505050565b60006101f86100af565b905061020482826101bd565b919050565b600067ffffffffffffffff8211156102245761022361018e565b5b602082029050602081019050919050565b600080fd5b600061024d61024884610209565b6101ee565b905080838252602082019050602084028301858111156102705761026f610235565b5b835b818110156102995780610285888261010c565b845260208401935050602081019050610272565b5050509392505050565b600082601f8301126102b8576102b7610178565b5b81356102c884826020860161023a565b91505092915050565b6000602082840312156102e7576102e66100b9565b5b600082013567ffffffffffffffff811115610305576103046100be565b5b610311848285016102a3565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b61034f816100e3565b82525050565b60006103618383610346565b60208301905092915050565b6000602082019050919050565b60006103858261031a565b61038f8185610325565b935061039a83610336565b8060005b838110156103cb5781516103b28882610355565b97506103bd8361036d565b92505060018101905061039e565b5085935050505092915050565b600060208201905081810360008301526103f2818461037a565b90509291505056fea264697066735822122035083763a0f4c4f5a71055f0da2f3d4f78e64159a8f3bc215c430daec7ac5e2064736f6c63430008110033" # noqa: E501 +ADDRESS_REFLECTOR_ABI = [ + { + "inputs": [{"internalType": "address", "name": "arg", "type": "address"}], + "name": "reflect", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "pure", + "type": "function", + }, + { + "inputs": [{"internalType": "address[]", "name": "arg", "type": "address[]"}], + "name": "reflect", + "outputs": [{"internalType": "address[]", "name": "", "type": "address[]"}], + "stateMutability": "pure", + "type": "function", + }, +] +ADDRESS_REFLECTOR_DATA = { + "bytecode": ADDRESS_REFLECTOR_BYTECODE, + "bytecode_runtime": ADDRESS_REFLECTOR_RUNTIME, + "abi": ADDRESS_REFLECTOR_ABI, +} diff --git a/web3/_utils/contract_sources/contract_data/arrays_contract.py b/web3/_utils/contract_sources/contract_data/arrays_contract.py new file mode 100644 index 0000000000..bbd86f8c0e --- /dev/null +++ b/web3/_utils/contract_sources/contract_data/arrays_contract.py @@ -0,0 +1,97 @@ +""" +Generated by `compile_contracts.py` script. +Compiled with Solidity v0.8.17. +""" + +# source: web3/_utils/contract_sources/ArraysContract.sol:ArraysContract +ARRAYS_CONTRACT_BYTECODE = "0x608060405260405180604001604052807f03783fac2efed8fbc9ad443e592ee30e61d65f471140c10ca155e937b435b76081526020017f1f675bff07515f5df96737194ea945c36c41e7b4fcef307b7cd4d0e602a6911181525060019060026200006b929190620001aa565b50604051806040016040528060007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191681526020017f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191681525060039060026200013c929190620001fc565b503480156200014a57600080fd5b5060405162001380380380620013808339818101604052810190620001709190620006df565b816000908051906020019062000188929190620002aa565b508060029080519060200190620001a1929190620002fc565b50505062000764565b828054828255906000526020600020908101928215620001e9579160200282015b82811115620001e8578251825591602001919060010190620001cb565b5b509050620001f89190620003aa565b5090565b82805482825590600052602060002090601f01602090048101928215620002975791602002820160005b838211156200026657835183826101000a81548160ff021916908360f81c0217905550926020019260010160208160000104928301926001030262000226565b8015620002955782816101000a81549060ff021916905560010160208160000104928301926001030262000266565b505b509050620002a69190620003c9565b5090565b828054828255906000526020600020908101928215620002e9579160200282015b82811115620002e8578251825591602001919060010190620002cb565b5b509050620002f89190620003aa565b5090565b82805482825590600052602060002090601f01602090048101928215620003975791602002820160005b838211156200036657835183826101000a81548160ff021916908360f81c0217905550926020019260010160208160000104928301926001030262000326565b8015620003955782816101000a81549060ff021916905560010160208160000104928301926001030262000366565b505b509050620003a69190620003c9565b5090565b5b80821115620003c5576000816000905550600101620003ab565b5090565b5b80821115620003e4576000816000905550600101620003ca565b5090565b6000604051905090565b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6200044c8262000401565b810181811067ffffffffffffffff821117156200046e576200046d62000412565b5b80604052505050565b600062000483620003e8565b905062000491828262000441565b919050565b600067ffffffffffffffff821115620004b457620004b362000412565b5b602082029050602081019050919050565b600080fd5b6000819050919050565b620004df81620004ca565b8114620004eb57600080fd5b50565b600081519050620004ff81620004d4565b92915050565b60006200051c620005168462000496565b62000477565b90508083825260208201905060208402830185811115620005425762000541620004c5565b5b835b818110156200056f57806200055a8882620004ee565b84526020840193505060208101905062000544565b5050509392505050565b600082601f830112620005915762000590620003fc565b5b8151620005a384826020860162000505565b91505092915050565b600067ffffffffffffffff821115620005ca57620005c962000412565b5b602082029050602081019050919050565b60007fff0000000000000000000000000000000000000000000000000000000000000082169050919050565b6200061281620005db565b81146200061e57600080fd5b50565b600081519050620006328162000607565b92915050565b60006200064f6200064984620005ac565b62000477565b90508083825260208201905060208402830185811115620006755762000674620004c5565b5b835b81811015620006a257806200068d888262000621565b84526020840193505060208101905062000677565b5050509392505050565b600082601f830112620006c457620006c3620003fc565b5b8151620006d684826020860162000638565b91505092915050565b60008060408385031215620006f957620006f8620003f2565b5b600083015167ffffffffffffffff8111156200071a5762000719620003f7565b5b620007288582860162000579565b925050602083015167ffffffffffffffff8111156200074c576200074b620003f7565b5b6200075a85828601620006ac565b9150509250929050565b610c0c80620007746000396000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c8063542d83de11610066578063542d83de1461015b578063605ba2711461018b5780638abe51fd146101a9578063962e450c146101c7578063bb69679b146101f75761009e565b80630afe5e33146100a357806312c9dcc8146100c15780631579bf66146100f15780633ddcea2f1461010f57806351b487881461012b575b600080fd5b6100ab610213565b6040516100b891906106d7565b60405180910390f35b6100db60048036038101906100d69190610743565b61026b565b6040516100e891906107ab565b60405180910390f35b6100f961029f565b6040516101069190610884565b60405180910390f35b61012960048036038101906101249190610a2b565b61033c565b005b61014560048036038101906101409190610743565b610356565b6040516101529190610a83565b60405180910390f35b61017560048036038101906101709190610743565b61037a565b6040516101829190610a83565b60405180910390f35b61019361039e565b6040516101a091906106d7565b60405180910390f35b6101b16103f6565b6040516101be9190610884565b60405180910390f35b6101e160048036038101906101dc9190610743565b610493565b6040516101ee91906107ab565b60405180910390f35b610211600480360381019061020c9190610b8d565b6104c7565b005b6060600180548060200260200160405190810160405280929190818152602001828054801561026157602002820191906000526020600020905b81548152602001906001019080831161024d575b5050505050905090565b6002818154811061027b57600080fd5b9060005260206000209060209182820401919006915054906101000a900460f81b81565b6060600380548060200260200160405190810160405280929190818152602001828054801561033257602002820191906000526020600020906000905b82829054906101000a900460f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190600101906020826000010492830192600103820291508084116102dc5790505b5050505050905090565b80600290805190602001906103529291906104e1565b5050565b6001818154811061036657600080fd5b906000526020600020016000915090505481565b6000818154811061038a57600080fd5b906000526020600020016000915090505481565b606060008054806020026020016040519081016040528092919081815260200182805480156103ec57602002820191906000526020600020905b8154815260200190600101908083116103d8575b5050505050905090565b6060600280548060200260200160405190810160405280929190818152602001828054801561048957602002820191906000526020600020906000905b82829054906101000a900460f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190600101906020826000010492830192600103820291508084116104335790505b5050505050905090565b600381815481106104a357600080fd5b9060005260206000209060209182820401919006915054906101000a900460f81b81565b80600090805190602001906104dd929190610588565b5050565b82805482825590600052602060002090601f016020900481019282156105775791602002820160005b8382111561054857835183826101000a81548160ff021916908360f81c0217905550926020019260010160208160000104928301926001030261050a565b80156105755782816101000a81549060ff0219169055600101602081600001049283019260010302610548565b505b50905061058491906105d5565b5090565b8280548282559060005260206000209081019282156105c4579160200282015b828111156105c35782518255916020019190600101906105a8565b5b5090506105d191906105f2565b5090565b5b808211156105ee5760008160009055506001016105d6565b5090565b5b8082111561060b5760008160009055506001016105f3565b5090565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000819050919050565b61064e8161063b565b82525050565b60006106608383610645565b60208301905092915050565b6000602082019050919050565b60006106848261060f565b61068e818561061a565b93506106998361062b565b8060005b838110156106ca5781516106b18882610654565b97506106bc8361066c565b92505060018101905061069d565b5085935050505092915050565b600060208201905081810360008301526106f18184610679565b905092915050565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b6107208161070d565b811461072b57600080fd5b50565b60008135905061073d81610717565b92915050565b60006020828403121561075957610758610703565b5b60006107678482850161072e565b91505092915050565b60007fff0000000000000000000000000000000000000000000000000000000000000082169050919050565b6107a581610770565b82525050565b60006020820190506107c0600083018461079c565b92915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6107fb81610770565b82525050565b600061080d83836107f2565b60208301905092915050565b6000602082019050919050565b6000610831826107c6565b61083b81856107d1565b9350610846836107e2565b8060005b8381101561087757815161085e8882610801565b975061086983610819565b92505060018101905061084a565b5085935050505092915050565b6000602082019050818103600083015261089e8184610826565b905092915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6108f4826108ab565b810181811067ffffffffffffffff82111715610913576109126108bc565b5b80604052505050565b60006109266106f9565b905061093282826108eb565b919050565b600067ffffffffffffffff821115610952576109516108bc565b5b602082029050602081019050919050565b600080fd5b61097181610770565b811461097c57600080fd5b50565b60008135905061098e81610968565b92915050565b60006109a76109a284610937565b61091c565b905080838252602082019050602084028301858111156109ca576109c9610963565b5b835b818110156109f357806109df888261097f565b8452602084019350506020810190506109cc565b5050509392505050565b600082601f830112610a1257610a116108a6565b5b8135610a22848260208601610994565b91505092915050565b600060208284031215610a4157610a40610703565b5b600082013567ffffffffffffffff811115610a5f57610a5e610708565b5b610a6b848285016109fd565b91505092915050565b610a7d8161063b565b82525050565b6000602082019050610a986000830184610a74565b92915050565b600067ffffffffffffffff821115610ab957610ab86108bc565b5b602082029050602081019050919050565b610ad38161063b565b8114610ade57600080fd5b50565b600081359050610af081610aca565b92915050565b6000610b09610b0484610a9e565b61091c565b90508083825260208201905060208402830185811115610b2c57610b2b610963565b5b835b81811015610b555780610b418882610ae1565b845260208401935050602081019050610b2e565b5050509392505050565b600082601f830112610b7457610b736108a6565b5b8135610b84848260208601610af6565b91505092915050565b600060208284031215610ba357610ba2610703565b5b600082013567ffffffffffffffff811115610bc157610bc0610708565b5b610bcd84828501610b5f565b9150509291505056fea26469706673582212208c21ac9e510a097aed789e8e3d64755d3ee254c3b6b641a72843a1d910822fc364736f6c63430008110033" # noqa: E501 +ARRAYS_CONTRACT_RUNTIME = "0x608060405234801561001057600080fd5b506004361061009e5760003560e01c8063542d83de11610066578063542d83de1461015b578063605ba2711461018b5780638abe51fd146101a9578063962e450c146101c7578063bb69679b146101f75761009e565b80630afe5e33146100a357806312c9dcc8146100c15780631579bf66146100f15780633ddcea2f1461010f57806351b487881461012b575b600080fd5b6100ab610213565b6040516100b891906106d7565b60405180910390f35b6100db60048036038101906100d69190610743565b61026b565b6040516100e891906107ab565b60405180910390f35b6100f961029f565b6040516101069190610884565b60405180910390f35b61012960048036038101906101249190610a2b565b61033c565b005b61014560048036038101906101409190610743565b610356565b6040516101529190610a83565b60405180910390f35b61017560048036038101906101709190610743565b61037a565b6040516101829190610a83565b60405180910390f35b61019361039e565b6040516101a091906106d7565b60405180910390f35b6101b16103f6565b6040516101be9190610884565b60405180910390f35b6101e160048036038101906101dc9190610743565b610493565b6040516101ee91906107ab565b60405180910390f35b610211600480360381019061020c9190610b8d565b6104c7565b005b6060600180548060200260200160405190810160405280929190818152602001828054801561026157602002820191906000526020600020905b81548152602001906001019080831161024d575b5050505050905090565b6002818154811061027b57600080fd5b9060005260206000209060209182820401919006915054906101000a900460f81b81565b6060600380548060200260200160405190810160405280929190818152602001828054801561033257602002820191906000526020600020906000905b82829054906101000a900460f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190600101906020826000010492830192600103820291508084116102dc5790505b5050505050905090565b80600290805190602001906103529291906104e1565b5050565b6001818154811061036657600080fd5b906000526020600020016000915090505481565b6000818154811061038a57600080fd5b906000526020600020016000915090505481565b606060008054806020026020016040519081016040528092919081815260200182805480156103ec57602002820191906000526020600020905b8154815260200190600101908083116103d8575b5050505050905090565b6060600280548060200260200160405190810160405280929190818152602001828054801561048957602002820191906000526020600020906000905b82829054906101000a900460f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190600101906020826000010492830192600103820291508084116104335790505b5050505050905090565b600381815481106104a357600080fd5b9060005260206000209060209182820401919006915054906101000a900460f81b81565b80600090805190602001906104dd929190610588565b5050565b82805482825590600052602060002090601f016020900481019282156105775791602002820160005b8382111561054857835183826101000a81548160ff021916908360f81c0217905550926020019260010160208160000104928301926001030261050a565b80156105755782816101000a81549060ff0219169055600101602081600001049283019260010302610548565b505b50905061058491906105d5565b5090565b8280548282559060005260206000209081019282156105c4579160200282015b828111156105c35782518255916020019190600101906105a8565b5b5090506105d191906105f2565b5090565b5b808211156105ee5760008160009055506001016105d6565b5090565b5b8082111561060b5760008160009055506001016105f3565b5090565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000819050919050565b61064e8161063b565b82525050565b60006106608383610645565b60208301905092915050565b6000602082019050919050565b60006106848261060f565b61068e818561061a565b93506106998361062b565b8060005b838110156106ca5781516106b18882610654565b97506106bc8361066c565b92505060018101905061069d565b5085935050505092915050565b600060208201905081810360008301526106f18184610679565b905092915050565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b6107208161070d565b811461072b57600080fd5b50565b60008135905061073d81610717565b92915050565b60006020828403121561075957610758610703565b5b60006107678482850161072e565b91505092915050565b60007fff0000000000000000000000000000000000000000000000000000000000000082169050919050565b6107a581610770565b82525050565b60006020820190506107c0600083018461079c565b92915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6107fb81610770565b82525050565b600061080d83836107f2565b60208301905092915050565b6000602082019050919050565b6000610831826107c6565b61083b81856107d1565b9350610846836107e2565b8060005b8381101561087757815161085e8882610801565b975061086983610819565b92505060018101905061084a565b5085935050505092915050565b6000602082019050818103600083015261089e8184610826565b905092915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6108f4826108ab565b810181811067ffffffffffffffff82111715610913576109126108bc565b5b80604052505050565b60006109266106f9565b905061093282826108eb565b919050565b600067ffffffffffffffff821115610952576109516108bc565b5b602082029050602081019050919050565b600080fd5b61097181610770565b811461097c57600080fd5b50565b60008135905061098e81610968565b92915050565b60006109a76109a284610937565b61091c565b905080838252602082019050602084028301858111156109ca576109c9610963565b5b835b818110156109f357806109df888261097f565b8452602084019350506020810190506109cc565b5050509392505050565b600082601f830112610a1257610a116108a6565b5b8135610a22848260208601610994565b91505092915050565b600060208284031215610a4157610a40610703565b5b600082013567ffffffffffffffff811115610a5f57610a5e610708565b5b610a6b848285016109fd565b91505092915050565b610a7d8161063b565b82525050565b6000602082019050610a986000830184610a74565b92915050565b600067ffffffffffffffff821115610ab957610ab86108bc565b5b602082029050602081019050919050565b610ad38161063b565b8114610ade57600080fd5b50565b600081359050610af081610aca565b92915050565b6000610b09610b0484610a9e565b61091c565b90508083825260208201905060208402830185811115610b2c57610b2b610963565b5b835b81811015610b555780610b418882610ae1565b845260208401935050602081019050610b2e565b5050509392505050565b600082601f830112610b7457610b736108a6565b5b8135610b84848260208601610af6565b91505092915050565b600060208284031215610ba357610ba2610703565b5b600082013567ffffffffffffffff811115610bc157610bc0610708565b5b610bcd84828501610b5f565b9150509291505056fea26469706673582212208c21ac9e510a097aed789e8e3d64755d3ee254c3b6b641a72843a1d910822fc364736f6c63430008110033" # noqa: E501 +ARRAYS_CONTRACT_ABI = [ + { + "inputs": [ + {"internalType": "bytes32[]", "name": "_bytes32Value", "type": "bytes32[]"}, + {"internalType": "bytes1[]", "name": "_byteValue", "type": "bytes1[]"}, + ], + "stateMutability": "nonpayable", + "type": "constructor", + }, + { + "inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "name": "byteConstValue", + "outputs": [{"internalType": "bytes1", "name": "", "type": "bytes1"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "name": "byteValue", + "outputs": [{"internalType": "bytes1", "name": "", "type": "bytes1"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "name": "bytes32ConstValue", + "outputs": [{"internalType": "bytes32", "name": "", "type": "bytes32"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "name": "bytes32Value", + "outputs": [{"internalType": "bytes32", "name": "", "type": "bytes32"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getByteConstValue", + "outputs": [{"internalType": "bytes1[]", "name": "", "type": "bytes1[]"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getByteValue", + "outputs": [{"internalType": "bytes1[]", "name": "", "type": "bytes1[]"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getBytes32ConstValue", + "outputs": [{"internalType": "bytes32[]", "name": "", "type": "bytes32[]"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getBytes32Value", + "outputs": [{"internalType": "bytes32[]", "name": "", "type": "bytes32[]"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "bytes1[]", "name": "_byteValue", "type": "bytes1[]"} + ], + "name": "setByteValue", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "bytes32[]", "name": "_bytes32Value", "type": "bytes32[]"} + ], + "name": "setBytes32Value", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, +] +ARRAYS_CONTRACT_DATA = { + "bytecode": ARRAYS_CONTRACT_BYTECODE, + "bytecode_runtime": ARRAYS_CONTRACT_RUNTIME, + "abi": ARRAYS_CONTRACT_ABI, +} diff --git a/web3/_utils/contract_sources/contract_data/bytes_contracts.py b/web3/_utils/contract_sources/contract_data/bytes_contracts.py new file mode 100644 index 0000000000..4b535a170f --- /dev/null +++ b/web3/_utils/contract_sources/contract_data/bytes_contracts.py @@ -0,0 +1,79 @@ +""" +Generated by `compile_contracts.py` script. +Compiled with Solidity v0.8.17. +""" + +# source: web3/_utils/contract_sources/BytesContracts.sol:BytesContract +BYTES_CONTRACT_BYTECODE = "0x60806040526040518060400160405280600281526020017f0123000000000000000000000000000000000000000000000000000000000000815250600090816200004a919062000311565b503480156200005857600080fd5b5060405162000de638038062000de683398181016040528101906200007e91906200055c565b80600190816200008f9190620005b8565b50506200069f565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806200011957607f821691505b6020821081036200012f576200012e620000d1565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b600060088302620001997fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826200015a565b620001a586836200015a565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b6000620001f2620001ec620001e684620001bd565b620001c7565b620001bd565b9050919050565b6000819050919050565b6200020e83620001d1565b620002266200021d82620001f9565b84845462000167565b825550505050565b600090565b6200023d6200022e565b6200024a81848462000203565b505050565b5b8181101562000272576200026660008262000233565b60018101905062000250565b5050565b601f821115620002c1576200028b8162000135565b62000296846200014a565b81016020851015620002a6578190505b620002be620002b5856200014a565b8301826200024f565b50505b505050565b600082821c905092915050565b6000620002e660001984600802620002c6565b1980831691505092915050565b6000620003018383620002d3565b9150826002028217905092915050565b6200031c8262000097565b67ffffffffffffffff811115620003385762000337620000a2565b5b62000344825462000100565b6200035182828562000276565b600060209050601f83116001811462000389576000841562000374578287015190505b620003808582620002f3565b865550620003f0565b601f198416620003998662000135565b60005b82811015620003c3578489015182556001820191506020850194506020810190506200039c565b86831015620003e35784890151620003df601f891682620002d3565b8355505b6001600288020188555050505b505050505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b620004328262000416565b810181811067ffffffffffffffff82111715620004545762000453620000a2565b5b80604052505050565b600062000469620003f8565b905062000477828262000427565b919050565b600067ffffffffffffffff8211156200049a5762000499620000a2565b5b620004a58262000416565b9050602081019050919050565b60005b83811015620004d2578082015181840152602081019050620004b5565b60008484015250505050565b6000620004f5620004ef846200047c565b6200045d565b90508281526020810184848401111562000514576200051362000411565b5b62000521848285620004b2565b509392505050565b600082601f8301126200054157620005406200040c565b5b815162000553848260208601620004de565b91505092915050565b60006020828403121562000575576200057462000402565b5b600082015167ffffffffffffffff81111562000596576200059562000407565b5b620005a48482850162000529565b91505092915050565b600081519050919050565b620005c382620005ad565b67ffffffffffffffff811115620005df57620005de620000a2565b5b620005eb825462000100565b620005f882828562000276565b600060209050601f8311600181146200063057600084156200061b578287015190505b620006278582620002f3565b86555062000697565b601f198416620006408662000135565b60005b828110156200066a5784890151825560018201915060208501945060208101905062000643565b868310156200068a578489015162000686601f891682620002d3565b8355505b6001600288020188555050505b505050505050565b61073780620006af6000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063209652551461004657806330de3cee14610064578063439970aa14610082575b600080fd5b61004e61009e565b60405161005b9190610265565b60405180910390f35b61006c610130565b6040516100799190610265565b60405180910390f35b61009c600480360381019061009791906103d0565b6101c2565b005b6060600180546100ad90610448565b80601f01602080910402602001604051908101604052809291908181526020018280546100d990610448565b80156101265780601f106100fb57610100808354040283529160200191610126565b820191906000526020600020905b81548152906001019060200180831161010957829003601f168201915b5050505050905090565b60606000805461013f90610448565b80601f016020809104026020016040519081016040528092919081815260200182805461016b90610448565b80156101b85780601f1061018d576101008083540402835291602001916101b8565b820191906000526020600020905b81548152906001019060200180831161019b57829003601f168201915b5050505050905090565b80600190816101d1919061062f565b5050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561020f5780820151818401526020810190506101f4565b60008484015250505050565b6000601f19601f8301169050919050565b6000610237826101d5565b61024181856101e0565b93506102518185602086016101f1565b61025a8161021b565b840191505092915050565b6000602082019050818103600083015261027f818461022c565b905092915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6102dd8261021b565b810181811067ffffffffffffffff821117156102fc576102fb6102a5565b5b80604052505050565b600061030f610287565b905061031b82826102d4565b919050565b600067ffffffffffffffff82111561033b5761033a6102a5565b5b6103448261021b565b9050602081019050919050565b82818337600083830152505050565b600061037361036e84610320565b610305565b90508281526020810184848401111561038f5761038e6102a0565b5b61039a848285610351565b509392505050565b600082601f8301126103b7576103b661029b565b5b81356103c7848260208601610360565b91505092915050565b6000602082840312156103e6576103e5610291565b5b600082013567ffffffffffffffff81111561040457610403610296565b5b610410848285016103a2565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061046057607f821691505b60208210810361047357610472610419565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026104db7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8261049e565b6104e5868361049e565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b600061052c610527610522846104fd565b610507565b6104fd565b9050919050565b6000819050919050565b61054683610511565b61055a61055282610533565b8484546104ab565b825550505050565b600090565b61056f610562565b61057a81848461053d565b505050565b5b8181101561059e57610593600082610567565b600181019050610580565b5050565b601f8211156105e3576105b481610479565b6105bd8461048e565b810160208510156105cc578190505b6105e06105d88561048e565b83018261057f565b50505b505050565b600082821c905092915050565b6000610606600019846008026105e8565b1980831691505092915050565b600061061f83836105f5565b9150826002028217905092915050565b610638826101d5565b67ffffffffffffffff811115610651576106506102a5565b5b61065b8254610448565b6106668282856105a2565b600060209050601f8311600181146106995760008415610687578287015190505b6106918582610613565b8655506106f9565b601f1984166106a786610479565b60005b828110156106cf578489015182556001820191506020850194506020810190506106aa565b868310156106ec57848901516106e8601f8916826105f5565b8355505b6001600288020188555050505b50505050505056fea264697066735822122079b820450b5fde98cf8014fef032b7c988897fb9315212b570ae68a3b64084a064736f6c63430008110033" # noqa: E501 +BYTES_CONTRACT_RUNTIME = "0x608060405234801561001057600080fd5b50600436106100415760003560e01c8063209652551461004657806330de3cee14610064578063439970aa14610082575b600080fd5b61004e61009e565b60405161005b9190610265565b60405180910390f35b61006c610130565b6040516100799190610265565b60405180910390f35b61009c600480360381019061009791906103d0565b6101c2565b005b6060600180546100ad90610448565b80601f01602080910402602001604051908101604052809291908181526020018280546100d990610448565b80156101265780601f106100fb57610100808354040283529160200191610126565b820191906000526020600020905b81548152906001019060200180831161010957829003601f168201915b5050505050905090565b60606000805461013f90610448565b80601f016020809104026020016040519081016040528092919081815260200182805461016b90610448565b80156101b85780601f1061018d576101008083540402835291602001916101b8565b820191906000526020600020905b81548152906001019060200180831161019b57829003601f168201915b5050505050905090565b80600190816101d1919061062f565b5050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561020f5780820151818401526020810190506101f4565b60008484015250505050565b6000601f19601f8301169050919050565b6000610237826101d5565b61024181856101e0565b93506102518185602086016101f1565b61025a8161021b565b840191505092915050565b6000602082019050818103600083015261027f818461022c565b905092915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6102dd8261021b565b810181811067ffffffffffffffff821117156102fc576102fb6102a5565b5b80604052505050565b600061030f610287565b905061031b82826102d4565b919050565b600067ffffffffffffffff82111561033b5761033a6102a5565b5b6103448261021b565b9050602081019050919050565b82818337600083830152505050565b600061037361036e84610320565b610305565b90508281526020810184848401111561038f5761038e6102a0565b5b61039a848285610351565b509392505050565b600082601f8301126103b7576103b661029b565b5b81356103c7848260208601610360565b91505092915050565b6000602082840312156103e6576103e5610291565b5b600082013567ffffffffffffffff81111561040457610403610296565b5b610410848285016103a2565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061046057607f821691505b60208210810361047357610472610419565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026104db7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8261049e565b6104e5868361049e565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b600061052c610527610522846104fd565b610507565b6104fd565b9050919050565b6000819050919050565b61054683610511565b61055a61055282610533565b8484546104ab565b825550505050565b600090565b61056f610562565b61057a81848461053d565b505050565b5b8181101561059e57610593600082610567565b600181019050610580565b5050565b601f8211156105e3576105b481610479565b6105bd8461048e565b810160208510156105cc578190505b6105e06105d88561048e565b83018261057f565b50505b505050565b600082821c905092915050565b6000610606600019846008026105e8565b1980831691505092915050565b600061061f83836105f5565b9150826002028217905092915050565b610638826101d5565b67ffffffffffffffff811115610651576106506102a5565b5b61065b8254610448565b6106668282856105a2565b600060209050601f8311600181146106995760008415610687578287015190505b6106918582610613565b8655506106f9565b601f1984166106a786610479565b60005b828110156106cf578489015182556001820191506020850194506020810190506106aa565b868310156106ec57848901516106e8601f8916826105f5565b8355505b6001600288020188555050505b50505050505056fea264697066735822122079b820450b5fde98cf8014fef032b7c988897fb9315212b570ae68a3b64084a064736f6c63430008110033" # noqa: E501 +BYTES_CONTRACT_ABI = [ + { + "inputs": [{"internalType": "bytes", "name": "_value", "type": "bytes"}], + "stateMutability": "nonpayable", + "type": "constructor", + }, + { + "inputs": [], + "name": "constValue", + "outputs": [{"internalType": "bytes", "name": "", "type": "bytes"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getValue", + "outputs": [{"internalType": "bytes", "name": "", "type": "bytes"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [{"internalType": "bytes", "name": "_value", "type": "bytes"}], + "name": "setValue", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, +] +BYTES_CONTRACT_DATA = { + "bytecode": BYTES_CONTRACT_BYTECODE, + "bytecode_runtime": BYTES_CONTRACT_RUNTIME, + "abi": BYTES_CONTRACT_ABI, +} + + +# source: web3/_utils/contract_sources/BytesContracts.sol:Bytes32Contract +BYTES32_CONTRACT_BYTECODE = "0x60806040527f012301230123012301230123012301230123012301230123012301230123012360005534801561003457600080fd5b5060405161025d38038061025d8339818101604052810190610056919061009e565b80600181905550506100cb565b600080fd5b6000819050919050565b61007b81610068565b811461008657600080fd5b50565b60008151905061009881610072565b92915050565b6000602082840312156100b4576100b3610063565b5b60006100c284828501610089565b91505092915050565b610183806100da6000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063209652551461004657806330de3cee1461006457806358825b1014610082575b600080fd5b61004e61009e565b60405161005b91906100d4565b60405180910390f35b61006c6100a8565b60405161007991906100d4565b60405180910390f35b61009c60048036038101906100979190610120565b6100b1565b005b6000600154905090565b60008054905090565b8060018190555050565b6000819050919050565b6100ce816100bb565b82525050565b60006020820190506100e960008301846100c5565b92915050565b600080fd5b6100fd816100bb565b811461010857600080fd5b50565b60008135905061011a816100f4565b92915050565b600060208284031215610136576101356100ef565b5b60006101448482850161010b565b9150509291505056fea26469706673582212207f2269970fdd74807e2d21ccbbe4bae3f852e5fedde98719a243f48bca6b1fa964736f6c63430008110033" # noqa: E501 +BYTES32_CONTRACT_RUNTIME = "0x608060405234801561001057600080fd5b50600436106100415760003560e01c8063209652551461004657806330de3cee1461006457806358825b1014610082575b600080fd5b61004e61009e565b60405161005b91906100d4565b60405180910390f35b61006c6100a8565b60405161007991906100d4565b60405180910390f35b61009c60048036038101906100979190610120565b6100b1565b005b6000600154905090565b60008054905090565b8060018190555050565b6000819050919050565b6100ce816100bb565b82525050565b60006020820190506100e960008301846100c5565b92915050565b600080fd5b6100fd816100bb565b811461010857600080fd5b50565b60008135905061011a816100f4565b92915050565b600060208284031215610136576101356100ef565b5b60006101448482850161010b565b9150509291505056fea26469706673582212207f2269970fdd74807e2d21ccbbe4bae3f852e5fedde98719a243f48bca6b1fa964736f6c63430008110033" # noqa: E501 +BYTES32_CONTRACT_ABI = [ + { + "inputs": [{"internalType": "bytes32", "name": "_value", "type": "bytes32"}], + "stateMutability": "nonpayable", + "type": "constructor", + }, + { + "inputs": [], + "name": "constValue", + "outputs": [{"internalType": "bytes32", "name": "", "type": "bytes32"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "getValue", + "outputs": [{"internalType": "bytes32", "name": "", "type": "bytes32"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [{"internalType": "bytes32", "name": "_value", "type": "bytes32"}], + "name": "setValue", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, +] +BYTES32_CONTRACT_DATA = { + "bytecode": BYTES32_CONTRACT_BYTECODE, + "bytecode_runtime": BYTES32_CONTRACT_RUNTIME, + "abi": BYTES32_CONTRACT_ABI, +} diff --git a/web3/_utils/contract_sources/contract_data/constructor_contracts.py b/web3/_utils/contract_sources/contract_data/constructor_contracts.py new file mode 100644 index 0000000000..ef4190e704 --- /dev/null +++ b/web3/_utils/contract_sources/contract_data/constructor_contracts.py @@ -0,0 +1,74 @@ +""" +Generated by `compile_contracts.py` script. +Compiled with Solidity v0.8.17. +""" + +# source: web3/_utils/contract_sources/ConstructorContracts.sol:SimpleConstructorContract # noqa: E501 +SIMPLE_CONSTRUCTOR_CONTRACT_BYTECODE = "0x6080604052348015600f57600080fd5b50603f80601d6000396000f3fe6080604052600080fdfea2646970667358221220da06e0463d6a8580cff9f1e7934ce1b2f5b8b2bae8de664662738c02f755ee4564736f6c63430008110033" # noqa: E501 +SIMPLE_CONSTRUCTOR_CONTRACT_RUNTIME = "0x6080604052600080fdfea2646970667358221220da06e0463d6a8580cff9f1e7934ce1b2f5b8b2bae8de664662738c02f755ee4564736f6c63430008110033" # noqa: E501 +SIMPLE_CONSTRUCTOR_CONTRACT_ABI = [ + {"inputs": [], "stateMutability": "nonpayable", "type": "constructor"} +] +SIMPLE_CONSTRUCTOR_CONTRACT_DATA = { + "bytecode": SIMPLE_CONSTRUCTOR_CONTRACT_BYTECODE, + "bytecode_runtime": SIMPLE_CONSTRUCTOR_CONTRACT_RUNTIME, + "abi": SIMPLE_CONSTRUCTOR_CONTRACT_ABI, +} + + +# source: web3/_utils/contract_sources/ConstructorContracts.sol:ConstructorWithArgumentsContract # noqa: E501 +CONSTRUCTOR_WITH_ARGUMENTS_CONTRACT_BYTECODE = "0x608060405234801561001057600080fd5b50604051610214380380610214833981810160405281019061003291906100b8565b816000819055508060018190555050506100f8565b600080fd5b6000819050919050565b61005f8161004c565b811461006a57600080fd5b50565b60008151905061007c81610056565b92915050565b6000819050919050565b61009581610082565b81146100a057600080fd5b50565b6000815190506100b28161008c565b92915050565b600080604083850312156100cf576100ce610047565b5b60006100dd8582860161006d565b92505060206100ee858286016100a3565b9150509250929050565b61010d806101076000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c806388ec1346146037578063d4c46c76146051575b600080fd5b603d606b565b60405160489190608e565b60405180910390f35b60576071565b6040516062919060be565b60405180910390f35b60005481565b60015481565b6000819050919050565b6088816077565b82525050565b600060208201905060a160008301846081565b92915050565b6000819050919050565b60b88160a7565b82525050565b600060208201905060d1600083018460b1565b9291505056fea264697066735822122042e6d559441ea02e39756bdc74c95f4da95672f703694cad4bc6568dcfa32d7664736f6c63430008110033" # noqa: E501 +CONSTRUCTOR_WITH_ARGUMENTS_CONTRACT_RUNTIME = "0x6080604052348015600f57600080fd5b506004361060325760003560e01c806388ec1346146037578063d4c46c76146051575b600080fd5b603d606b565b60405160489190608e565b60405180910390f35b60576071565b6040516062919060be565b60405180910390f35b60005481565b60015481565b6000819050919050565b6088816077565b82525050565b600060208201905060a160008301846081565b92915050565b6000819050919050565b60b88160a7565b82525050565b600060208201905060d1600083018460b1565b9291505056fea264697066735822122042e6d559441ea02e39756bdc74c95f4da95672f703694cad4bc6568dcfa32d7664736f6c63430008110033" # noqa: E501 +CONSTRUCTOR_WITH_ARGUMENTS_CONTRACT_ABI = [ + { + "inputs": [ + {"internalType": "uint256", "name": "a", "type": "uint256"}, + {"internalType": "bytes32", "name": "b", "type": "bytes32"}, + ], + "stateMutability": "nonpayable", + "type": "constructor", + }, + { + "inputs": [], + "name": "data_a", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "data_b", + "outputs": [{"internalType": "bytes32", "name": "", "type": "bytes32"}], + "stateMutability": "view", + "type": "function", + }, +] +CONSTRUCTOR_WITH_ARGUMENTS_CONTRACT_DATA = { + "bytecode": CONSTRUCTOR_WITH_ARGUMENTS_CONTRACT_BYTECODE, + "bytecode_runtime": CONSTRUCTOR_WITH_ARGUMENTS_CONTRACT_RUNTIME, + "abi": CONSTRUCTOR_WITH_ARGUMENTS_CONTRACT_ABI, +} + + +# source: web3/_utils/contract_sources/ConstructorContracts.sol:ConstructorWithAddressArgumentContract # noqa: E501 +CONSTRUCTOR_WITH_ADDRESS_ARGUMENT_CONTRACT_BYTECODE = "0x608060405234801561001057600080fd5b5060405161020d38038061020d833981810160405281019061003291906100db565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610108565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100a88261007d565b9050919050565b6100b88161009d565b81146100c357600080fd5b50565b6000815190506100d5816100af565b92915050565b6000602082840312156100f1576100f0610078565b5b60006100ff848285016100c6565b91505092915050565b60f7806101166000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c806334664e3a14602d575b600080fd5b60336047565b604051603e919060a8565b60405180910390f35b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000609482606b565b9050919050565b60a281608b565b82525050565b600060208201905060bb6000830184609b565b9291505056fea2646970667358221220a2033400b3f8a2ff265192f4234996bca3b25af27a799ddb8d1ae2e2bcc165a664736f6c63430008110033" # noqa: E501 +CONSTRUCTOR_WITH_ADDRESS_ARGUMENT_CONTRACT_RUNTIME = "0x6080604052348015600f57600080fd5b506004361060285760003560e01c806334664e3a14602d575b600080fd5b60336047565b604051603e919060a8565b60405180910390f35b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000609482606b565b9050919050565b60a281608b565b82525050565b600060208201905060bb6000830184609b565b9291505056fea2646970667358221220a2033400b3f8a2ff265192f4234996bca3b25af27a799ddb8d1ae2e2bcc165a664736f6c63430008110033" # noqa: E501 +CONSTRUCTOR_WITH_ADDRESS_ARGUMENT_CONTRACT_ABI = [ + { + "inputs": [{"internalType": "address", "name": "_testAddr", "type": "address"}], + "stateMutability": "nonpayable", + "type": "constructor", + }, + { + "inputs": [], + "name": "testAddr", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function", + }, +] +CONSTRUCTOR_WITH_ADDRESS_ARGUMENT_CONTRACT_DATA = { + "bytecode": CONSTRUCTOR_WITH_ADDRESS_ARGUMENT_CONTRACT_BYTECODE, + "bytecode_runtime": CONSTRUCTOR_WITH_ADDRESS_ARGUMENT_CONTRACT_RUNTIME, + "abi": CONSTRUCTOR_WITH_ADDRESS_ARGUMENT_CONTRACT_ABI, +} diff --git a/web3/_utils/contract_sources/contract_data/contract_caller_tester.py b/web3/_utils/contract_sources/contract_data/contract_caller_tester.py new file mode 100644 index 0000000000..3f9bc7a834 --- /dev/null +++ b/web3/_utils/contract_sources/contract_data/contract_caller_tester.py @@ -0,0 +1,59 @@ +""" +Generated by `compile_contracts.py` script. +Compiled with Solidity v0.8.17. +""" + +# source: web3/_utils/contract_sources/ContractCallerTester.sol:ContractCallerTester +CONTRACT_CALLER_TESTER_BYTECODE = "0x608060405234801561001057600080fd5b50610458806100206000396000f3fe60806040526004361061004a5760003560e01c806306661abd1461004f57806361bc221a1461007a578063a5f3c23b14610098578063c7fa7d66146100c8578063d09de08a146100ea575b600080fd5b34801561005b57600080fd5b50610064610115565b60405161007191906101df565b60405180910390f35b61008261011b565b60405161008f91906101df565b60405180910390f35b6100b260048036038101906100ad919061022b565b610124565b6040516100bf91906101df565b60405180910390f35b6100d061013a565b6040516100e1959493929190610355565b60405180910390f35b3480156100f657600080fd5b506100ff6101a7565b60405161010c91906101df565b60405180910390f35b60005481565b60008054905090565b6000818361013291906103de565b905092915050565b600060606000806000336000365a344384848080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505093509091929350945094509450945094509091929394565b600060016000808282546101bb91906103de565b925050819055905090565b6000819050919050565b6101d9816101c6565b82525050565b60006020820190506101f460008301846101d0565b92915050565b600080fd5b610208816101c6565b811461021357600080fd5b50565b600081359050610225816101ff565b92915050565b60008060408385031215610242576102416101fa565b5b600061025085828601610216565b925050602061026185828601610216565b9150509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006102968261026b565b9050919050565b6102a68161028b565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b838110156102e65780820151818401526020810190506102cb565b60008484015250505050565b6000601f19601f8301169050919050565b600061030e826102ac565b61031881856102b7565b93506103288185602086016102c8565b610331816102f2565b840191505092915050565b6000819050919050565b61034f8161033c565b82525050565b600060a08201905061036a600083018861029d565b818103602083015261037c8187610303565b905061038b6040830186610346565b6103986060830185610346565b6103a56080830184610346565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006103e9826101c6565b91506103f4836101c6565b92508282019050828112156000831216838212600084121516171561041c5761041b6103af565b5b9291505056fea26469706673582212204625bd56480b2c7c4d0164f97398e5d871be2d10c7ff6251d9c31837585b51aa64736f6c63430008110033" # noqa: E501 +CONTRACT_CALLER_TESTER_RUNTIME = "0x60806040526004361061004a5760003560e01c806306661abd1461004f57806361bc221a1461007a578063a5f3c23b14610098578063c7fa7d66146100c8578063d09de08a146100ea575b600080fd5b34801561005b57600080fd5b50610064610115565b60405161007191906101df565b60405180910390f35b61008261011b565b60405161008f91906101df565b60405180910390f35b6100b260048036038101906100ad919061022b565b610124565b6040516100bf91906101df565b60405180910390f35b6100d061013a565b6040516100e1959493929190610355565b60405180910390f35b3480156100f657600080fd5b506100ff6101a7565b60405161010c91906101df565b60405180910390f35b60005481565b60008054905090565b6000818361013291906103de565b905092915050565b600060606000806000336000365a344384848080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505093509091929350945094509450945094509091929394565b600060016000808282546101bb91906103de565b925050819055905090565b6000819050919050565b6101d9816101c6565b82525050565b60006020820190506101f460008301846101d0565b92915050565b600080fd5b610208816101c6565b811461021357600080fd5b50565b600081359050610225816101ff565b92915050565b60008060408385031215610242576102416101fa565b5b600061025085828601610216565b925050602061026185828601610216565b9150509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006102968261026b565b9050919050565b6102a68161028b565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b838110156102e65780820151818401526020810190506102cb565b60008484015250505050565b6000601f19601f8301169050919050565b600061030e826102ac565b61031881856102b7565b93506103288185602086016102c8565b610331816102f2565b840191505092915050565b6000819050919050565b61034f8161033c565b82525050565b600060a08201905061036a600083018861029d565b818103602083015261037c8187610303565b905061038b6040830186610346565b6103986060830185610346565b6103a56080830184610346565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006103e9826101c6565b91506103f4836101c6565b92508282019050828112156000831216838212600084121516171561041c5761041b6103af565b5b9291505056fea26469706673582212204625bd56480b2c7c4d0164f97398e5d871be2d10c7ff6251d9c31837585b51aa64736f6c63430008110033" # noqa: E501 +CONTRACT_CALLER_TESTER_ABI = [ + { + "inputs": [ + {"internalType": "int256", "name": "a", "type": "int256"}, + {"internalType": "int256", "name": "b", "type": "int256"}, + ], + "name": "add", + "outputs": [{"internalType": "int256", "name": "", "type": "int256"}], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [], + "name": "count", + "outputs": [{"internalType": "int256", "name": "", "type": "int256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "counter", + "outputs": [{"internalType": "int256", "name": "", "type": "int256"}], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [], + "name": "increment", + "outputs": [{"internalType": "int256", "name": "", "type": "int256"}], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "returnMeta", + "outputs": [ + {"internalType": "address", "name": "", "type": "address"}, + {"internalType": "bytes", "name": "", "type": "bytes"}, + {"internalType": "uint256", "name": "", "type": "uint256"}, + {"internalType": "uint256", "name": "", "type": "uint256"}, + {"internalType": "uint256", "name": "", "type": "uint256"}, + ], + "stateMutability": "payable", + "type": "function", + }, +] +CONTRACT_CALLER_TESTER_DATA = { + "bytecode": CONTRACT_CALLER_TESTER_BYTECODE, + "bytecode_runtime": CONTRACT_CALLER_TESTER_RUNTIME, + "abi": CONTRACT_CALLER_TESTER_ABI, +} diff --git a/web3/_utils/contract_sources/contract_data/emitter_contract.py b/web3/_utils/contract_sources/contract_data/emitter_contract.py new file mode 100644 index 0000000000..2e41aa4bc8 --- /dev/null +++ b/web3/_utils/contract_sources/contract_data/emitter_contract.py @@ -0,0 +1,503 @@ +""" +Generated by `compile_contracts.py` script. +Compiled with Solidity v0.8.17. +""" + +# source: web3/_utils/contract_sources/EmitterContract.sol:EmitterContract +EMITTER_CONTRACT_BYTECODE = "0x608060405234801561001057600080fd5b50611757806100206000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c80639c377053116100715780639c37705314610161578063aa6fd8221461017d578063acabb9ed14610199578063b2ddc449146101b5578063e17bf956146101d1578063f82ef69e146101ed576100b4565b80630bb563d6146100b957806317c0c180146100d557806320f0256e146100f15780635da86c171461010d57806390b41d8b14610129578063966b50e014610145575b600080fd5b6100d360048036038101906100ce9190610af3565b610209565b005b6100ef60048036038101906100ea9190610b61565b610243565b005b61010b60048036038101906101069190610bc4565b61031b565b005b61012760048036038101906101229190610ce4565b610438565b005b610143600480360381019061013e9190610d24565b610475565b005b61015f600480360381019061015a9190610e97565b6105d2565b005b61017b60048036038101906101769190610f0f565b610623565b005b61019760048036038101906101929190610f76565b61073b565b005b6101b360048036038101906101ae9190610fb6565b61087f565b005b6101cf60048036038101906101ca919061108c565b6108d0565b005b6101eb60048036038101906101e6919061116d565b610922565b005b6102076004803603810190610202919061108c565b61095c565b005b7fa95e6e2a182411e7a6f9ed114a85c3761d87f9b8f453d842c71235aa64fff99f816040516102389190611235565b60405180910390a150565b6001601281111561025757610256611257565b5b81601281111561026a57610269611257565b5b036102a0577f1e86022f78f8d04f8e3dfd13a2bdb280403e6632877c0dbee5e4eeb259908a5c60405160405180910390a1610318565b600060128111156102b4576102b3611257565b5b8160128111156102c7576102c6611257565b5b036102dc5760405160405180910390a0610317565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161030e906112f8565b60405180910390fd5b5b50565b6005601281111561032f5761032e611257565b5b85601281111561034257610341611257565b5b03610389577ff039d147f23fe975a4254bdf6b1502b8c79132ae1833986b7ccef2638e73fdf98484848460405161037c9493929190611327565b60405180910390a1610431565b600b601281111561039d5761039c611257565b5b8560128111156103b0576103af611257565b5b036103f55780827fa30ece802b64cd2b7e57dabf4010aabf5df26d1556977affb07b98a77ad955b586866040516103e892919061136c565b60405180910390a3610430565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610427906112f8565b60405180910390fd5b5b5050505050565b7f8ccce2523cca5f3851d20df50b5a59509bc4ac7d9ddba344f5e331969d09b8e78282604051610469929190611402565b60405180910390a15050565b6003601281111561048957610488611257565b5b83601281111561049c5761049b611257565b5b036104df577fdf0cb1dea99afceb3ea698d62e705b736f1345a7eee9eb07e63d1f8f556c1bc582826040516104d292919061136c565b60405180910390a16105cd565b600960128111156104f3576104f2611257565b5b83601281111561050657610505611257565b5b0361054857807f057bc32826fbe161da1c110afcdcae7c109a8b69149f727fc37a603c60ef94ca8360405161053b919061142b565b60405180910390a26105cc565b6008601281111561055c5761055b611257565b5b83601281111561056f5761056e611257565b5b03610590578082604051610583919061142b565b60405180910390a16105cb565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105c2906112f8565b60405180910390fd5b5b5b505050565b816040516105e091906114fe565b60405180910390207fdbc4c1d1d2f0d84e58d36ca767ec9ba2ec2f933c055e50e5ccdd57697f7b58b08260405161061791906115ab565b60405180910390a25050565b6004601281111561063757610636611257565b5b84601281111561064a57610649611257565b5b0361068f577f4a25b279c7c585f25eda9788ac9420ebadae78ca6b206a0e6ab488fd81f55062838383604051610682939291906115cd565b60405180910390a1610735565b600a60128111156106a3576106a2611257565b5b8460128111156106b6576106b5611257565b5b036106f95780827ff16c999b533366ca5138d78e85da51611089cd05749f098d6c225d4cd42ee6ec856040516106ec919061142b565b60405180910390a3610734565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161072b906112f8565b60405180910390fd5b5b50505050565b6002601281111561074f5761074e611257565b5b82601281111561076257610761611257565b5b036107a3577f56d2ef3c5228bf5d88573621e325a4672ab50e033749a601e4f4a5e1dce905d481604051610796919061142b565b60405180910390a161087b565b600760128111156107b7576107b6611257565b5b8260128111156107ca576107c9611257565b5b0361080157807ff70fe689e290d8ce2b2a388ac28db36fbb0e16a6d89c6804c461f65a1b40bb1560405160405180910390a261087a565b6006601281111561081557610814611257565b5b82601281111561082857610827611257565b5b0361083e578060405160405180910390a1610879565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610870906112f8565b60405180910390fd5b5b5b5050565b8160405161088d9190611640565b60405180910390207fe77cf33df73da7bc2e253a2dae617e6f15e4e337eaa462a108903af4643d1b75826040516108c49190611235565b60405180910390a25050565b8173ffffffffffffffffffffffffffffffffffffffff167ff922c215689548d72c3d2fe4ea8dafb2a30c43312c9b43fe5d10f713181f991c826040516109169190611666565b60405180910390a25050565b7f532fd6ea96cfb78bb46e09279a26828b8b493de1a2b8b1ee1face527978a15a58160405161095191906116d6565b60405180910390a150565b7f06029e18f16caae06a69281f35b00ed3fcf47950e6c99dafa1bdd8c4b93479a0828260405161098d9291906116f8565b60405180910390a15050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610a00826109b7565b810181811067ffffffffffffffff82111715610a1f57610a1e6109c8565b5b80604052505050565b6000610a32610999565b9050610a3e82826109f7565b919050565b600067ffffffffffffffff821115610a5e57610a5d6109c8565b5b610a67826109b7565b9050602081019050919050565b82818337600083830152505050565b6000610a96610a9184610a43565b610a28565b905082815260208101848484011115610ab257610ab16109b2565b5b610abd848285610a74565b509392505050565b600082601f830112610ada57610ad96109ad565b5b8135610aea848260208601610a83565b91505092915050565b600060208284031215610b0957610b086109a3565b5b600082013567ffffffffffffffff811115610b2757610b266109a8565b5b610b3384828501610ac5565b91505092915050565b60138110610b4957600080fd5b50565b600081359050610b5b81610b3c565b92915050565b600060208284031215610b7757610b766109a3565b5b6000610b8584828501610b4c565b91505092915050565b6000819050919050565b610ba181610b8e565b8114610bac57600080fd5b50565b600081359050610bbe81610b98565b92915050565b600080600080600060a08688031215610be057610bdf6109a3565b5b6000610bee88828901610b4c565b9550506020610bff88828901610baf565b9450506040610c1088828901610baf565b9350506060610c2188828901610baf565b9250506080610c3288828901610baf565b9150509295509295909350565b600080fd5b600060208284031215610c5a57610c59610c3f565b5b610c646020610a28565b90506000610c7484828501610baf565b60008301525092915050565b600060608284031215610c9657610c95610c3f565b5b610ca06060610a28565b90506000610cb084828501610baf565b6000830152506020610cc484828501610baf565b6020830152506040610cd884828501610c44565b60408301525092915050565b60008060808385031215610cfb57610cfa6109a3565b5b6000610d0985828601610baf565b9250506020610d1a85828601610c80565b9150509250929050565b600080600060608486031215610d3d57610d3c6109a3565b5b6000610d4b86828701610b4c565b9350506020610d5c86828701610baf565b9250506040610d6d86828701610baf565b9150509250925092565b600067ffffffffffffffff821115610d9257610d916109c8565b5b602082029050602081019050919050565b600080fd5b60007fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b610ddd81610da8565b8114610de857600080fd5b50565b600081359050610dfa81610dd4565b92915050565b6000610e13610e0e84610d77565b610a28565b90508083825260208201905060208402830185811115610e3657610e35610da3565b5b835b81811015610e5f5780610e4b8882610deb565b845260208401935050602081019050610e38565b5050509392505050565b600082601f830112610e7e57610e7d6109ad565b5b8135610e8e848260208601610e00565b91505092915050565b60008060408385031215610eae57610ead6109a3565b5b600083013567ffffffffffffffff811115610ecc57610ecb6109a8565b5b610ed885828601610e69565b925050602083013567ffffffffffffffff811115610ef957610ef86109a8565b5b610f0585828601610e69565b9150509250929050565b60008060008060808587031215610f2957610f286109a3565b5b6000610f3787828801610b4c565b9450506020610f4887828801610baf565b9350506040610f5987828801610baf565b9250506060610f6a87828801610baf565b91505092959194509250565b60008060408385031215610f8d57610f8c6109a3565b5b6000610f9b85828601610b4c565b9250506020610fac85828601610baf565b9150509250929050565b60008060408385031215610fcd57610fcc6109a3565b5b600083013567ffffffffffffffff811115610feb57610fea6109a8565b5b610ff785828601610ac5565b925050602083013567ffffffffffffffff811115611018576110176109a8565b5b61102485828601610ac5565b9150509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006110598261102e565b9050919050565b6110698161104e565b811461107457600080fd5b50565b60008135905061108681611060565b92915050565b600080604083850312156110a3576110a26109a3565b5b60006110b185828601611077565b92505060206110c285828601611077565b9150509250929050565b600067ffffffffffffffff8211156110e7576110e66109c8565b5b6110f0826109b7565b9050602081019050919050565b600061111061110b846110cc565b610a28565b90508281526020810184848401111561112c5761112b6109b2565b5b611137848285610a74565b509392505050565b600082601f830112611154576111536109ad565b5b81356111648482602086016110fd565b91505092915050565b600060208284031215611183576111826109a3565b5b600082013567ffffffffffffffff8111156111a1576111a06109a8565b5b6111ad8482850161113f565b91505092915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156111f05780820151818401526020810190506111d5565b60008484015250505050565b6000611207826111b6565b61121181856111c1565b93506112218185602086016111d2565b61122a816109b7565b840191505092915050565b6000602082019050818103600083015261124f81846111fc565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f4469646e2774206d6174636820616e7920616c6c6f7761626c65206576656e7460008201527f20696e6465780000000000000000000000000000000000000000000000000000602082015250565b60006112e26026836111c1565b91506112ed82611286565b604082019050919050565b60006020820190508181036000830152611311816112d5565b9050919050565b61132181610b8e565b82525050565b600060808201905061133c6000830187611318565b6113496020830186611318565b6113566040830185611318565b6113636060830184611318565b95945050505050565b60006040820190506113816000830185611318565b61138e6020830184611318565b9392505050565b61139e81610b8e565b82525050565b6020820160008201516113ba6000850182611395565b50505050565b6060820160008201516113d66000850182611395565b5060208201516113e96020850182611395565b5060408201516113fc60408501826113a4565b50505050565b60006080820190506114176000830185611318565b61142460208301846113c0565b9392505050565b60006020820190506114406000830184611318565b92915050565b600081519050919050565b600081905092915050565b6000819050602082019050919050565b61147581610da8565b82525050565b6000611487838361146c565b60208301905092915050565b6000602082019050919050565b60006114ab82611446565b6114b58185611451565b93506114c08361145c565b8060005b838110156114f15781516114d8888261147b565b97506114e383611493565b9250506001810190506114c4565b5085935050505092915050565b600061150a82846114a0565b915081905092915050565b600082825260208201905092915050565b61152f81610da8565b82525050565b60006115418383611526565b60208301905092915050565b600061155882611446565b6115628185611515565b935061156d8361145c565b8060005b8381101561159e5781516115858882611535565b975061159083611493565b925050600181019050611571565b5085935050505092915050565b600060208201905081810360008301526115c5818461154d565b905092915050565b60006060820190506115e26000830186611318565b6115ef6020830185611318565b6115fc6040830184611318565b949350505050565b600081905092915050565b600061161a826111b6565b6116248185611604565b93506116348185602086016111d2565b80840191505092915050565b600061164c828461160f565b915081905092915050565b6116608161104e565b82525050565b600060208201905061167b6000830184611657565b92915050565b600081519050919050565b600082825260208201905092915050565b60006116a882611681565b6116b2818561168c565b93506116c28185602086016111d2565b6116cb816109b7565b840191505092915050565b600060208201905081810360008301526116f0818461169d565b905092915050565b600060408201905061170d6000830185611657565b61171a6020830184611657565b939250505056fea2646970667358221220c7fe1cb35e1edd22692be334329b7e6d9569a4321e3ad8a71942932ca8cf0fde64736f6c63430008110033" # noqa: E501 +EMITTER_CONTRACT_RUNTIME = "0x608060405234801561001057600080fd5b50600436106100b45760003560e01c80639c377053116100715780639c37705314610161578063aa6fd8221461017d578063acabb9ed14610199578063b2ddc449146101b5578063e17bf956146101d1578063f82ef69e146101ed576100b4565b80630bb563d6146100b957806317c0c180146100d557806320f0256e146100f15780635da86c171461010d57806390b41d8b14610129578063966b50e014610145575b600080fd5b6100d360048036038101906100ce9190610af3565b610209565b005b6100ef60048036038101906100ea9190610b61565b610243565b005b61010b60048036038101906101069190610bc4565b61031b565b005b61012760048036038101906101229190610ce4565b610438565b005b610143600480360381019061013e9190610d24565b610475565b005b61015f600480360381019061015a9190610e97565b6105d2565b005b61017b60048036038101906101769190610f0f565b610623565b005b61019760048036038101906101929190610f76565b61073b565b005b6101b360048036038101906101ae9190610fb6565b61087f565b005b6101cf60048036038101906101ca919061108c565b6108d0565b005b6101eb60048036038101906101e6919061116d565b610922565b005b6102076004803603810190610202919061108c565b61095c565b005b7fa95e6e2a182411e7a6f9ed114a85c3761d87f9b8f453d842c71235aa64fff99f816040516102389190611235565b60405180910390a150565b6001601281111561025757610256611257565b5b81601281111561026a57610269611257565b5b036102a0577f1e86022f78f8d04f8e3dfd13a2bdb280403e6632877c0dbee5e4eeb259908a5c60405160405180910390a1610318565b600060128111156102b4576102b3611257565b5b8160128111156102c7576102c6611257565b5b036102dc5760405160405180910390a0610317565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161030e906112f8565b60405180910390fd5b5b50565b6005601281111561032f5761032e611257565b5b85601281111561034257610341611257565b5b03610389577ff039d147f23fe975a4254bdf6b1502b8c79132ae1833986b7ccef2638e73fdf98484848460405161037c9493929190611327565b60405180910390a1610431565b600b601281111561039d5761039c611257565b5b8560128111156103b0576103af611257565b5b036103f55780827fa30ece802b64cd2b7e57dabf4010aabf5df26d1556977affb07b98a77ad955b586866040516103e892919061136c565b60405180910390a3610430565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610427906112f8565b60405180910390fd5b5b5050505050565b7f8ccce2523cca5f3851d20df50b5a59509bc4ac7d9ddba344f5e331969d09b8e78282604051610469929190611402565b60405180910390a15050565b6003601281111561048957610488611257565b5b83601281111561049c5761049b611257565b5b036104df577fdf0cb1dea99afceb3ea698d62e705b736f1345a7eee9eb07e63d1f8f556c1bc582826040516104d292919061136c565b60405180910390a16105cd565b600960128111156104f3576104f2611257565b5b83601281111561050657610505611257565b5b0361054857807f057bc32826fbe161da1c110afcdcae7c109a8b69149f727fc37a603c60ef94ca8360405161053b919061142b565b60405180910390a26105cc565b6008601281111561055c5761055b611257565b5b83601281111561056f5761056e611257565b5b03610590578082604051610583919061142b565b60405180910390a16105cb565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105c2906112f8565b60405180910390fd5b5b5b505050565b816040516105e091906114fe565b60405180910390207fdbc4c1d1d2f0d84e58d36ca767ec9ba2ec2f933c055e50e5ccdd57697f7b58b08260405161061791906115ab565b60405180910390a25050565b6004601281111561063757610636611257565b5b84601281111561064a57610649611257565b5b0361068f577f4a25b279c7c585f25eda9788ac9420ebadae78ca6b206a0e6ab488fd81f55062838383604051610682939291906115cd565b60405180910390a1610735565b600a60128111156106a3576106a2611257565b5b8460128111156106b6576106b5611257565b5b036106f95780827ff16c999b533366ca5138d78e85da51611089cd05749f098d6c225d4cd42ee6ec856040516106ec919061142b565b60405180910390a3610734565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161072b906112f8565b60405180910390fd5b5b50505050565b6002601281111561074f5761074e611257565b5b82601281111561076257610761611257565b5b036107a3577f56d2ef3c5228bf5d88573621e325a4672ab50e033749a601e4f4a5e1dce905d481604051610796919061142b565b60405180910390a161087b565b600760128111156107b7576107b6611257565b5b8260128111156107ca576107c9611257565b5b0361080157807ff70fe689e290d8ce2b2a388ac28db36fbb0e16a6d89c6804c461f65a1b40bb1560405160405180910390a261087a565b6006601281111561081557610814611257565b5b82601281111561082857610827611257565b5b0361083e578060405160405180910390a1610879565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610870906112f8565b60405180910390fd5b5b5b5050565b8160405161088d9190611640565b60405180910390207fe77cf33df73da7bc2e253a2dae617e6f15e4e337eaa462a108903af4643d1b75826040516108c49190611235565b60405180910390a25050565b8173ffffffffffffffffffffffffffffffffffffffff167ff922c215689548d72c3d2fe4ea8dafb2a30c43312c9b43fe5d10f713181f991c826040516109169190611666565b60405180910390a25050565b7f532fd6ea96cfb78bb46e09279a26828b8b493de1a2b8b1ee1face527978a15a58160405161095191906116d6565b60405180910390a150565b7f06029e18f16caae06a69281f35b00ed3fcf47950e6c99dafa1bdd8c4b93479a0828260405161098d9291906116f8565b60405180910390a15050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610a00826109b7565b810181811067ffffffffffffffff82111715610a1f57610a1e6109c8565b5b80604052505050565b6000610a32610999565b9050610a3e82826109f7565b919050565b600067ffffffffffffffff821115610a5e57610a5d6109c8565b5b610a67826109b7565b9050602081019050919050565b82818337600083830152505050565b6000610a96610a9184610a43565b610a28565b905082815260208101848484011115610ab257610ab16109b2565b5b610abd848285610a74565b509392505050565b600082601f830112610ada57610ad96109ad565b5b8135610aea848260208601610a83565b91505092915050565b600060208284031215610b0957610b086109a3565b5b600082013567ffffffffffffffff811115610b2757610b266109a8565b5b610b3384828501610ac5565b91505092915050565b60138110610b4957600080fd5b50565b600081359050610b5b81610b3c565b92915050565b600060208284031215610b7757610b766109a3565b5b6000610b8584828501610b4c565b91505092915050565b6000819050919050565b610ba181610b8e565b8114610bac57600080fd5b50565b600081359050610bbe81610b98565b92915050565b600080600080600060a08688031215610be057610bdf6109a3565b5b6000610bee88828901610b4c565b9550506020610bff88828901610baf565b9450506040610c1088828901610baf565b9350506060610c2188828901610baf565b9250506080610c3288828901610baf565b9150509295509295909350565b600080fd5b600060208284031215610c5a57610c59610c3f565b5b610c646020610a28565b90506000610c7484828501610baf565b60008301525092915050565b600060608284031215610c9657610c95610c3f565b5b610ca06060610a28565b90506000610cb084828501610baf565b6000830152506020610cc484828501610baf565b6020830152506040610cd884828501610c44565b60408301525092915050565b60008060808385031215610cfb57610cfa6109a3565b5b6000610d0985828601610baf565b9250506020610d1a85828601610c80565b9150509250929050565b600080600060608486031215610d3d57610d3c6109a3565b5b6000610d4b86828701610b4c565b9350506020610d5c86828701610baf565b9250506040610d6d86828701610baf565b9150509250925092565b600067ffffffffffffffff821115610d9257610d916109c8565b5b602082029050602081019050919050565b600080fd5b60007fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b610ddd81610da8565b8114610de857600080fd5b50565b600081359050610dfa81610dd4565b92915050565b6000610e13610e0e84610d77565b610a28565b90508083825260208201905060208402830185811115610e3657610e35610da3565b5b835b81811015610e5f5780610e4b8882610deb565b845260208401935050602081019050610e38565b5050509392505050565b600082601f830112610e7e57610e7d6109ad565b5b8135610e8e848260208601610e00565b91505092915050565b60008060408385031215610eae57610ead6109a3565b5b600083013567ffffffffffffffff811115610ecc57610ecb6109a8565b5b610ed885828601610e69565b925050602083013567ffffffffffffffff811115610ef957610ef86109a8565b5b610f0585828601610e69565b9150509250929050565b60008060008060808587031215610f2957610f286109a3565b5b6000610f3787828801610b4c565b9450506020610f4887828801610baf565b9350506040610f5987828801610baf565b9250506060610f6a87828801610baf565b91505092959194509250565b60008060408385031215610f8d57610f8c6109a3565b5b6000610f9b85828601610b4c565b9250506020610fac85828601610baf565b9150509250929050565b60008060408385031215610fcd57610fcc6109a3565b5b600083013567ffffffffffffffff811115610feb57610fea6109a8565b5b610ff785828601610ac5565b925050602083013567ffffffffffffffff811115611018576110176109a8565b5b61102485828601610ac5565b9150509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006110598261102e565b9050919050565b6110698161104e565b811461107457600080fd5b50565b60008135905061108681611060565b92915050565b600080604083850312156110a3576110a26109a3565b5b60006110b185828601611077565b92505060206110c285828601611077565b9150509250929050565b600067ffffffffffffffff8211156110e7576110e66109c8565b5b6110f0826109b7565b9050602081019050919050565b600061111061110b846110cc565b610a28565b90508281526020810184848401111561112c5761112b6109b2565b5b611137848285610a74565b509392505050565b600082601f830112611154576111536109ad565b5b81356111648482602086016110fd565b91505092915050565b600060208284031215611183576111826109a3565b5b600082013567ffffffffffffffff8111156111a1576111a06109a8565b5b6111ad8482850161113f565b91505092915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156111f05780820151818401526020810190506111d5565b60008484015250505050565b6000611207826111b6565b61121181856111c1565b93506112218185602086016111d2565b61122a816109b7565b840191505092915050565b6000602082019050818103600083015261124f81846111fc565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f4469646e2774206d6174636820616e7920616c6c6f7761626c65206576656e7460008201527f20696e6465780000000000000000000000000000000000000000000000000000602082015250565b60006112e26026836111c1565b91506112ed82611286565b604082019050919050565b60006020820190508181036000830152611311816112d5565b9050919050565b61132181610b8e565b82525050565b600060808201905061133c6000830187611318565b6113496020830186611318565b6113566040830185611318565b6113636060830184611318565b95945050505050565b60006040820190506113816000830185611318565b61138e6020830184611318565b9392505050565b61139e81610b8e565b82525050565b6020820160008201516113ba6000850182611395565b50505050565b6060820160008201516113d66000850182611395565b5060208201516113e96020850182611395565b5060408201516113fc60408501826113a4565b50505050565b60006080820190506114176000830185611318565b61142460208301846113c0565b9392505050565b60006020820190506114406000830184611318565b92915050565b600081519050919050565b600081905092915050565b6000819050602082019050919050565b61147581610da8565b82525050565b6000611487838361146c565b60208301905092915050565b6000602082019050919050565b60006114ab82611446565b6114b58185611451565b93506114c08361145c565b8060005b838110156114f15781516114d8888261147b565b97506114e383611493565b9250506001810190506114c4565b5085935050505092915050565b600061150a82846114a0565b915081905092915050565b600082825260208201905092915050565b61152f81610da8565b82525050565b60006115418383611526565b60208301905092915050565b600061155882611446565b6115628185611515565b935061156d8361145c565b8060005b8381101561159e5781516115858882611535565b975061159083611493565b925050600181019050611571565b5085935050505092915050565b600060208201905081810360008301526115c5818461154d565b905092915050565b60006060820190506115e26000830186611318565b6115ef6020830185611318565b6115fc6040830184611318565b949350505050565b600081905092915050565b600061161a826111b6565b6116248185611604565b93506116348185602086016111d2565b80840191505092915050565b600061164c828461160f565b915081905092915050565b6116608161104e565b82525050565b600060208201905061167b6000830184611657565b92915050565b600081519050919050565b600082825260208201905092915050565b60006116a882611681565b6116b2818561168c565b93506116c28185602086016111d2565b6116cb816109b7565b840191505092915050565b600060208201905081810360008301526116f0818461169d565b905092915050565b600060408201905061170d6000830185611657565b61171a6020830184611657565b939250505056fea2646970667358221220c7fe1cb35e1edd22692be334329b7e6d9569a4321e3ad8a71942932ca8cf0fde64736f6c63430008110033" # noqa: E501 +EMITTER_CONTRACT_ABI = [ + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "arg0", + "type": "address", + }, + { + "indexed": False, + "internalType": "address", + "name": "arg1", + "type": "address", + }, + ], + "name": "LogAddressIndexed", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "address", + "name": "arg0", + "type": "address", + }, + { + "indexed": False, + "internalType": "address", + "name": "arg1", + "type": "address", + }, + ], + "name": "LogAddressNotIndexed", + "type": "event", + }, + {"anonymous": True, "inputs": [], "name": "LogAnonymous", "type": "event"}, + { + "anonymous": False, + "inputs": [ + {"indexed": False, "internalType": "bytes", "name": "v", "type": "bytes"} + ], + "name": "LogBytes", + "type": "event", + }, + { + "anonymous": True, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "arg0", + "type": "uint256", + }, + { + "indexed": True, + "internalType": "uint256", + "name": "arg1", + "type": "uint256", + }, + ], + "name": "LogDoubleAnonymous", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "arg0", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "arg1", + "type": "uint256", + }, + ], + "name": "LogDoubleArg", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "arg0", + "type": "uint256", + }, + { + "indexed": True, + "internalType": "uint256", + "name": "arg1", + "type": "uint256", + }, + ], + "name": "LogDoubleWithIndex", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "string", + "name": "arg0", + "type": "string", + }, + { + "indexed": False, + "internalType": "string", + "name": "arg1", + "type": "string", + }, + ], + "name": "LogDynamicArgs", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "bytes2[]", + "name": "arg0", + "type": "bytes2[]", + }, + { + "indexed": False, + "internalType": "bytes2[]", + "name": "arg1", + "type": "bytes2[]", + }, + ], + "name": "LogListArgs", + "type": "event", + }, + {"anonymous": False, "inputs": [], "name": "LogNoArguments", "type": "event"}, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "arg0", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "arg1", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "arg2", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "arg3", + "type": "uint256", + }, + ], + "name": "LogQuadrupleArg", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "arg0", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "arg1", + "type": "uint256", + }, + { + "indexed": True, + "internalType": "uint256", + "name": "arg2", + "type": "uint256", + }, + { + "indexed": True, + "internalType": "uint256", + "name": "arg3", + "type": "uint256", + }, + ], + "name": "LogQuadrupleWithIndex", + "type": "event", + }, + { + "anonymous": True, + "inputs": [ + { + "indexed": True, + "internalType": "uint256", + "name": "arg0", + "type": "uint256", + } + ], + "name": "LogSingleAnonymous", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "arg0", + "type": "uint256", + } + ], + "name": "LogSingleArg", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "uint256", + "name": "arg0", + "type": "uint256", + } + ], + "name": "LogSingleWithIndex", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + {"indexed": False, "internalType": "string", "name": "v", "type": "string"} + ], + "name": "LogString", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "arg0", + "type": "uint256", + }, + { + "components": [ + {"internalType": "uint256", "name": "a", "type": "uint256"}, + {"internalType": "uint256", "name": "b", "type": "uint256"}, + { + "components": [ + {"internalType": "uint256", "name": "c", "type": "uint256"} + ], + "internalType": "struct EmitterContract.NestedTestTuple", + "name": "nested", + "type": "tuple", + }, + ], + "indexed": False, + "internalType": "struct EmitterContract.TestTuple", + "name": "arg1", + "type": "tuple", + }, + ], + "name": "LogStructArgs", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "arg0", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "arg1", + "type": "uint256", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "arg2", + "type": "uint256", + }, + ], + "name": "LogTripleArg", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "arg0", + "type": "uint256", + }, + { + "indexed": True, + "internalType": "uint256", + "name": "arg1", + "type": "uint256", + }, + { + "indexed": True, + "internalType": "uint256", + "name": "arg2", + "type": "uint256", + }, + ], + "name": "LogTripleWithIndex", + "type": "event", + }, + { + "inputs": [ + {"internalType": "address", "name": "arg0", "type": "address"}, + {"internalType": "address", "name": "arg1", "type": "address"}, + ], + "name": "logAddressIndexedArgs", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "arg0", "type": "address"}, + {"internalType": "address", "name": "arg1", "type": "address"}, + ], + "name": "logAddressNotIndexedArgs", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [{"internalType": "bytes", "name": "v", "type": "bytes"}], + "name": "logBytes", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "enum EmitterContract.WhichEvent", + "name": "which", + "type": "uint8", + }, + {"internalType": "uint256", "name": "arg0", "type": "uint256"}, + {"internalType": "uint256", "name": "arg1", "type": "uint256"}, + ], + "name": "logDouble", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "string", "name": "arg0", "type": "string"}, + {"internalType": "string", "name": "arg1", "type": "string"}, + ], + "name": "logDynamicArgs", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "bytes2[]", "name": "arg0", "type": "bytes2[]"}, + {"internalType": "bytes2[]", "name": "arg1", "type": "bytes2[]"}, + ], + "name": "logListArgs", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "enum EmitterContract.WhichEvent", + "name": "which", + "type": "uint8", + } + ], + "name": "logNoArgs", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "enum EmitterContract.WhichEvent", + "name": "which", + "type": "uint8", + }, + {"internalType": "uint256", "name": "arg0", "type": "uint256"}, + {"internalType": "uint256", "name": "arg1", "type": "uint256"}, + {"internalType": "uint256", "name": "arg2", "type": "uint256"}, + {"internalType": "uint256", "name": "arg3", "type": "uint256"}, + ], + "name": "logQuadruple", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "enum EmitterContract.WhichEvent", + "name": "which", + "type": "uint8", + }, + {"internalType": "uint256", "name": "arg0", "type": "uint256"}, + ], + "name": "logSingle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [{"internalType": "string", "name": "v", "type": "string"}], + "name": "logString", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "uint256", "name": "arg0", "type": "uint256"}, + { + "components": [ + {"internalType": "uint256", "name": "a", "type": "uint256"}, + {"internalType": "uint256", "name": "b", "type": "uint256"}, + { + "components": [ + {"internalType": "uint256", "name": "c", "type": "uint256"} + ], + "internalType": "struct EmitterContract.NestedTestTuple", + "name": "nested", + "type": "tuple", + }, + ], + "internalType": "struct EmitterContract.TestTuple", + "name": "arg1", + "type": "tuple", + }, + ], + "name": "logStruct", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + { + "internalType": "enum EmitterContract.WhichEvent", + "name": "which", + "type": "uint8", + }, + {"internalType": "uint256", "name": "arg0", "type": "uint256"}, + {"internalType": "uint256", "name": "arg1", "type": "uint256"}, + {"internalType": "uint256", "name": "arg2", "type": "uint256"}, + ], + "name": "logTriple", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, +] +EMITTER_CONTRACT_DATA = { + "bytecode": EMITTER_CONTRACT_BYTECODE, + "bytecode_runtime": EMITTER_CONTRACT_RUNTIME, + "abi": EMITTER_CONTRACT_ABI, +} diff --git a/web3/_utils/contract_sources/contract_data/event_contracts.py b/web3/_utils/contract_sources/contract_data/event_contracts.py new file mode 100644 index 0000000000..2a6ce1efe9 --- /dev/null +++ b/web3/_utils/contract_sources/contract_data/event_contracts.py @@ -0,0 +1,93 @@ +""" +Generated by `compile_contracts.py` script. +Compiled with Solidity v0.8.17. +""" + +# source: web3/_utils/contract_sources/EventContracts.sol:EventContract +EVENT_CONTRACT_BYTECODE = "0x608060405234801561001057600080fd5b50610185806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80635818fad714610030575b600080fd5b61004a600480360381019061004591906100f8565b61004c565b005b7ff70fe689e290d8ce2b2a388ac28db36fbb0e16a6d89c6804c461f65a1b40bb158160405161007b9190610134565b60405180910390a17f56d2ef3c5228bf5d88573621e325a4672ab50e033749a601e4f4a5e1dce905d4816040516100b29190610134565b60405180910390a150565b600080fd5b6000819050919050565b6100d5816100c2565b81146100e057600080fd5b50565b6000813590506100f2816100cc565b92915050565b60006020828403121561010e5761010d6100bd565b5b600061011c848285016100e3565b91505092915050565b61012e816100c2565b82525050565b60006020820190506101496000830184610125565b9291505056fea2646970667358221220285ccfbee395caf55e50744594b87d1c7fa4057a4a32e3da56ee5e0f1e1a13e164736f6c63430008110033" # noqa: E501 +EVENT_CONTRACT_RUNTIME = "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c80635818fad714610030575b600080fd5b61004a600480360381019061004591906100f8565b61004c565b005b7ff70fe689e290d8ce2b2a388ac28db36fbb0e16a6d89c6804c461f65a1b40bb158160405161007b9190610134565b60405180910390a17f56d2ef3c5228bf5d88573621e325a4672ab50e033749a601e4f4a5e1dce905d4816040516100b29190610134565b60405180910390a150565b600080fd5b6000819050919050565b6100d5816100c2565b81146100e057600080fd5b50565b6000813590506100f2816100cc565b92915050565b60006020828403121561010e5761010d6100bd565b5b600061011c848285016100e3565b91505092915050565b61012e816100c2565b82525050565b60006020820190506101496000830184610125565b9291505056fea2646970667358221220285ccfbee395caf55e50744594b87d1c7fa4057a4a32e3da56ee5e0f1e1a13e164736f6c63430008110033" # noqa: E501 +EVENT_CONTRACT_ABI = [ + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "arg0", + "type": "uint256", + } + ], + "name": "LogSingleArg", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "arg0", + "type": "uint256", + } + ], + "name": "LogSingleWithIndex", + "type": "event", + }, + { + "inputs": [{"internalType": "uint256", "name": "_arg0", "type": "uint256"}], + "name": "logTwoEvents", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, +] +EVENT_CONTRACT_DATA = { + "bytecode": EVENT_CONTRACT_BYTECODE, + "bytecode_runtime": EVENT_CONTRACT_RUNTIME, + "abi": EVENT_CONTRACT_ABI, +} + + +# source: web3/_utils/contract_sources/EventContracts.sol:IndexedEventContract +INDEXED_EVENT_CONTRACT_BYTECODE = "0x608060405234801561001057600080fd5b5061017b806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80635818fad714610030575b600080fd5b61004a600480360381019061004591906100ee565b61004c565b005b807ff70fe689e290d8ce2b2a388ac28db36fbb0e16a6d89c6804c461f65a1b40bb1560405160405180910390a27f56d2ef3c5228bf5d88573621e325a4672ab50e033749a601e4f4a5e1dce905d4816040516100a8919061012a565b60405180910390a150565b600080fd5b6000819050919050565b6100cb816100b8565b81146100d657600080fd5b50565b6000813590506100e8816100c2565b92915050565b600060208284031215610104576101036100b3565b5b6000610112848285016100d9565b91505092915050565b610124816100b8565b82525050565b600060208201905061013f600083018461011b565b9291505056fea2646970667358221220310b5be141da1807e098de48bd777aa0b15a88c8b4fb8c54c2275366856f16d264736f6c63430008110033" # noqa: E501 +INDEXED_EVENT_CONTRACT_RUNTIME = "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c80635818fad714610030575b600080fd5b61004a600480360381019061004591906100ee565b61004c565b005b807ff70fe689e290d8ce2b2a388ac28db36fbb0e16a6d89c6804c461f65a1b40bb1560405160405180910390a27f56d2ef3c5228bf5d88573621e325a4672ab50e033749a601e4f4a5e1dce905d4816040516100a8919061012a565b60405180910390a150565b600080fd5b6000819050919050565b6100cb816100b8565b81146100d657600080fd5b50565b6000813590506100e8816100c2565b92915050565b600060208284031215610104576101036100b3565b5b6000610112848285016100d9565b91505092915050565b610124816100b8565b82525050565b600060208201905061013f600083018461011b565b9291505056fea2646970667358221220310b5be141da1807e098de48bd777aa0b15a88c8b4fb8c54c2275366856f16d264736f6c63430008110033" # noqa: E501 +INDEXED_EVENT_CONTRACT_ABI = [ + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "arg0", + "type": "uint256", + } + ], + "name": "LogSingleArg", + "type": "event", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "uint256", + "name": "arg0", + "type": "uint256", + } + ], + "name": "LogSingleWithIndex", + "type": "event", + }, + { + "inputs": [{"internalType": "uint256", "name": "_arg0", "type": "uint256"}], + "name": "logTwoEvents", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, +] +INDEXED_EVENT_CONTRACT_DATA = { + "bytecode": INDEXED_EVENT_CONTRACT_BYTECODE, + "bytecode_runtime": INDEXED_EVENT_CONTRACT_RUNTIME, + "abi": INDEXED_EVENT_CONTRACT_ABI, +} diff --git a/web3/_utils/contract_sources/contract_data/extended_resolver.py b/web3/_utils/contract_sources/contract_data/extended_resolver.py new file mode 100644 index 0000000000..dd83d04b1f --- /dev/null +++ b/web3/_utils/contract_sources/contract_data/extended_resolver.py @@ -0,0 +1,90 @@ +""" +Generated by `compile_contracts.py` script. +Compiled with Solidity v0.8.17. +""" + +# source: web3/_utils/contract_sources/ExtendedResolver.sol:ExtendedResolver +EXTENDED_RESOLVER_BYTECODE = "0x608060405234801561001057600080fd5b50604051610d90380380610d90833981810160405281019061003291906100ed565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505061011a565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100a88261007d565b9050919050565b60006100ba8261009d565b9050919050565b6100ca816100af565b81146100d557600080fd5b50565b6000815190506100e7816100c1565b92915050565b60006020828403121561010357610102610078565b5b6000610111848285016100d8565b91505092915050565b610c67806101296000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c806301ffc9a7146100515780633e9ce794146100815780639061b9231461009d578063f86bc879146100cd575b600080fd5b61006b60048036038101906100669190610554565b6100fd565b604051610078919061059c565b60405180910390f35b61009b60048036038101906100969190610677565b61015e565b005b6100b760048036038101906100b2919061072f565b610245565b6040516100c49190610840565b60405180910390f35b6100e760048036038101906100e29190610862565b610465565b6040516100f4919061059c565b60405180910390f35b6000639061b92360e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806101575750610156826104a1565b5b9050919050565b806001600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507fe1c5610a6e0cbe10764ecd182adcef1ec338dc4e199c99c32ce98f38e12791df8333848460405161023894939291906108d3565b60405180910390a1505050565b60606040518060400160405280601781526020017f11657874656e6465642d7265736f6c7665720365746800000000000000000000815250805190602001208585604051610294929190610957565b60405180910390201480156102ad575060248383905010155b1561035e577ff0a378cc2afe91730d0105e67d6bb037cc5b8b6bfec5b5962d9b637ff6497e5560001b83836004906024926102ea9392919061097a565b906102f591906109cd565b14610335576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161032c90610aaf565b60405180910390fd5b61beef6040516020016103489190610acf565b604051602081830303815290604052905061045d565b60008585600081811061037457610373610aea565b5b9050013560f81c60f81b60f81c60ff1690506040518060400160405280601781526020017f11657874656e6465642d7265736f6c76657203657468000000000000000000008152508051906020012086868360016103d29190610b52565b9080926103e19392919061097a565b6040516103ef929190610b86565b604051809103902014610437576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042e90610c11565b60405180910390fd5b61dead60405160200161044a9190610acf565b6040516020818303038152906040529150505b949350505050565b6001602052826000526040600020602052816000526040600020602052806000526040600020600092509250509054906101000a900460ff1681565b60006301ffc9a760e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610531816104fc565b811461053c57600080fd5b50565b60008135905061054e81610528565b92915050565b60006020828403121561056a576105696104f2565b5b60006105788482850161053f565b91505092915050565b60008115159050919050565b61059681610581565b82525050565b60006020820190506105b1600083018461058d565b92915050565b6000819050919050565b6105ca816105b7565b81146105d557600080fd5b50565b6000813590506105e7816105c1565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610618826105ed565b9050919050565b6106288161060d565b811461063357600080fd5b50565b6000813590506106458161061f565b92915050565b61065481610581565b811461065f57600080fd5b50565b6000813590506106718161064b565b92915050565b6000806000606084860312156106905761068f6104f2565b5b600061069e868287016105d8565b93505060206106af86828701610636565b92505060406106c086828701610662565b9150509250925092565b600080fd5b600080fd5b600080fd5b60008083601f8401126106ef576106ee6106ca565b5b8235905067ffffffffffffffff81111561070c5761070b6106cf565b5b602083019150836001820283011115610728576107276106d4565b5b9250929050565b60008060008060408587031215610749576107486104f2565b5b600085013567ffffffffffffffff811115610767576107666104f7565b5b610773878288016106d9565b9450945050602085013567ffffffffffffffff811115610796576107956104f7565b5b6107a2878288016106d9565b925092505092959194509250565b600081519050919050565b600082825260208201905092915050565b60005b838110156107ea5780820151818401526020810190506107cf565b60008484015250505050565b6000601f19601f8301169050919050565b6000610812826107b0565b61081c81856107bb565b935061082c8185602086016107cc565b610835816107f6565b840191505092915050565b6000602082019050818103600083015261085a8184610807565b905092915050565b60008060006060848603121561087b5761087a6104f2565b5b6000610889868287016105d8565b935050602061089a86828701610636565b92505060406108ab86828701610636565b9150509250925092565b6108be816105b7565b82525050565b6108cd8161060d565b82525050565b60006080820190506108e860008301876108b5565b6108f560208301866108c4565b61090260408301856108c4565b61090f606083018461058d565b95945050505050565b600081905092915050565b82818337600083830152505050565b600061093e8385610918565b935061094b838584610923565b82840190509392505050565b6000610964828486610932565b91508190509392505050565b600080fd5b600080fd5b6000808585111561098e5761098d610970565b5b8386111561099f5761099e610975565b5b6001850283019150848603905094509492505050565b600082905092915050565b600082821b905092915050565b60006109d983836109b5565b826109e481356105b7565b92506020821015610a2457610a1f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff836020036008026109c0565b831692505b505092915050565b600082825260208201905092915050565b7f706172656e7420646f6d61696e206e6f742076616c696461746564206170707260008201527f6f7072696174656c790000000000000000000000000000000000000000000000602082015250565b6000610a99602983610a2c565b9150610aa482610a3d565b604082019050919050565b60006020820190508181036000830152610ac881610a8c565b9050919050565b6000602082019050610ae460008301846108c4565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610b5d82610b19565b9150610b6883610b19565b9250828201905080821115610b8057610b7f610b23565b5b92915050565b6000610b93828486610932565b91508190509392505050565b7f737562646f6d61696e206e6f742076616c69646174656420617070726f70726960008201527f6174656c79000000000000000000000000000000000000000000000000000000602082015250565b6000610bfb602583610a2c565b9150610c0682610b9f565b604082019050919050565b60006020820190508181036000830152610c2a81610bee565b905091905056fea26469706673582212208f62d2c403baa9ee8d72c46149cb2780f23481615f9d3d5631826b50eb38588d64736f6c63430008110033" # noqa: E501 +EXTENDED_RESOLVER_RUNTIME = "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806301ffc9a7146100515780633e9ce794146100815780639061b9231461009d578063f86bc879146100cd575b600080fd5b61006b60048036038101906100669190610554565b6100fd565b604051610078919061059c565b60405180910390f35b61009b60048036038101906100969190610677565b61015e565b005b6100b760048036038101906100b2919061072f565b610245565b6040516100c49190610840565b60405180910390f35b6100e760048036038101906100e29190610862565b610465565b6040516100f4919061059c565b60405180910390f35b6000639061b92360e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806101575750610156826104a1565b5b9050919050565b806001600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507fe1c5610a6e0cbe10764ecd182adcef1ec338dc4e199c99c32ce98f38e12791df8333848460405161023894939291906108d3565b60405180910390a1505050565b60606040518060400160405280601781526020017f11657874656e6465642d7265736f6c7665720365746800000000000000000000815250805190602001208585604051610294929190610957565b60405180910390201480156102ad575060248383905010155b1561035e577ff0a378cc2afe91730d0105e67d6bb037cc5b8b6bfec5b5962d9b637ff6497e5560001b83836004906024926102ea9392919061097a565b906102f591906109cd565b14610335576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161032c90610aaf565b60405180910390fd5b61beef6040516020016103489190610acf565b604051602081830303815290604052905061045d565b60008585600081811061037457610373610aea565b5b9050013560f81c60f81b60f81c60ff1690506040518060400160405280601781526020017f11657874656e6465642d7265736f6c76657203657468000000000000000000008152508051906020012086868360016103d29190610b52565b9080926103e19392919061097a565b6040516103ef929190610b86565b604051809103902014610437576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042e90610c11565b60405180910390fd5b61dead60405160200161044a9190610acf565b6040516020818303038152906040529150505b949350505050565b6001602052826000526040600020602052816000526040600020602052806000526040600020600092509250509054906101000a900460ff1681565b60006301ffc9a760e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610531816104fc565b811461053c57600080fd5b50565b60008135905061054e81610528565b92915050565b60006020828403121561056a576105696104f2565b5b60006105788482850161053f565b91505092915050565b60008115159050919050565b61059681610581565b82525050565b60006020820190506105b1600083018461058d565b92915050565b6000819050919050565b6105ca816105b7565b81146105d557600080fd5b50565b6000813590506105e7816105c1565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610618826105ed565b9050919050565b6106288161060d565b811461063357600080fd5b50565b6000813590506106458161061f565b92915050565b61065481610581565b811461065f57600080fd5b50565b6000813590506106718161064b565b92915050565b6000806000606084860312156106905761068f6104f2565b5b600061069e868287016105d8565b93505060206106af86828701610636565b92505060406106c086828701610662565b9150509250925092565b600080fd5b600080fd5b600080fd5b60008083601f8401126106ef576106ee6106ca565b5b8235905067ffffffffffffffff81111561070c5761070b6106cf565b5b602083019150836001820283011115610728576107276106d4565b5b9250929050565b60008060008060408587031215610749576107486104f2565b5b600085013567ffffffffffffffff811115610767576107666104f7565b5b610773878288016106d9565b9450945050602085013567ffffffffffffffff811115610796576107956104f7565b5b6107a2878288016106d9565b925092505092959194509250565b600081519050919050565b600082825260208201905092915050565b60005b838110156107ea5780820151818401526020810190506107cf565b60008484015250505050565b6000601f19601f8301169050919050565b6000610812826107b0565b61081c81856107bb565b935061082c8185602086016107cc565b610835816107f6565b840191505092915050565b6000602082019050818103600083015261085a8184610807565b905092915050565b60008060006060848603121561087b5761087a6104f2565b5b6000610889868287016105d8565b935050602061089a86828701610636565b92505060406108ab86828701610636565b9150509250925092565b6108be816105b7565b82525050565b6108cd8161060d565b82525050565b60006080820190506108e860008301876108b5565b6108f560208301866108c4565b61090260408301856108c4565b61090f606083018461058d565b95945050505050565b600081905092915050565b82818337600083830152505050565b600061093e8385610918565b935061094b838584610923565b82840190509392505050565b6000610964828486610932565b91508190509392505050565b600080fd5b600080fd5b6000808585111561098e5761098d610970565b5b8386111561099f5761099e610975565b5b6001850283019150848603905094509492505050565b600082905092915050565b600082821b905092915050565b60006109d983836109b5565b826109e481356105b7565b92506020821015610a2457610a1f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff836020036008026109c0565b831692505b505092915050565b600082825260208201905092915050565b7f706172656e7420646f6d61696e206e6f742076616c696461746564206170707260008201527f6f7072696174656c790000000000000000000000000000000000000000000000602082015250565b6000610a99602983610a2c565b9150610aa482610a3d565b604082019050919050565b60006020820190508181036000830152610ac881610a8c565b9050919050565b6000602082019050610ae460008301846108c4565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610b5d82610b19565b9150610b6883610b19565b9250828201905080821115610b8057610b7f610b23565b5b92915050565b6000610b93828486610932565b91508190509392505050565b7f737562646f6d61696e206e6f742076616c69646174656420617070726f70726960008201527f6174656c79000000000000000000000000000000000000000000000000000000602082015250565b6000610bfb602583610a2c565b9150610c0682610b9f565b604082019050919050565b60006020820190508181036000830152610c2a81610bee565b905091905056fea26469706673582212208f62d2c403baa9ee8d72c46149cb2780f23481615f9d3d5631826b50eb38588d64736f6c63430008110033" # noqa: E501 +EXTENDED_RESOLVER_ABI = [ + { + "inputs": [{"internalType": "contract ENS", "name": "_ens", "type": "address"}], + "stateMutability": "nonpayable", + "type": "constructor", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "bytes32", + "name": "node", + "type": "bytes32", + }, + { + "indexed": False, + "internalType": "address", + "name": "owner", + "type": "address", + }, + { + "indexed": False, + "internalType": "address", + "name": "target", + "type": "address", + }, + { + "indexed": False, + "internalType": "bool", + "name": "isAuthorised", + "type": "bool", + }, + ], + "name": "AuthorisationChanged", + "type": "event", + }, + { + "inputs": [ + {"internalType": "bytes32", "name": "", "type": "bytes32"}, + {"internalType": "address", "name": "", "type": "address"}, + {"internalType": "address", "name": "", "type": "address"}, + ], + "name": "authorisations", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "bytes", "name": "dnsName", "type": "bytes"}, + {"internalType": "bytes", "name": "data", "type": "bytes"}, + ], + "name": "resolve", + "outputs": [{"internalType": "bytes", "name": "", "type": "bytes"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "bytes32", "name": "node", "type": "bytes32"}, + {"internalType": "address", "name": "target", "type": "address"}, + {"internalType": "bool", "name": "isAuthorised", "type": "bool"}, + ], + "name": "setAuthorisation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [{"internalType": "bytes4", "name": "interfaceID", "type": "bytes4"}], + "name": "supportsInterface", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "pure", + "type": "function", + }, +] +EXTENDED_RESOLVER_DATA = { + "bytecode": EXTENDED_RESOLVER_BYTECODE, + "bytecode_runtime": EXTENDED_RESOLVER_RUNTIME, + "abi": EXTENDED_RESOLVER_ABI, +} diff --git a/web3/_utils/contract_sources/contract_data/fallback_function_contract.py b/web3/_utils/contract_sources/contract_data/fallback_function_contract.py new file mode 100644 index 0000000000..ea5e7e8652 --- /dev/null +++ b/web3/_utils/contract_sources/contract_data/fallback_function_contract.py @@ -0,0 +1,24 @@ +""" +Generated by `compile_contracts.py` script. +Compiled with Solidity v0.8.17. +""" + +# source: web3/_utils/contract_sources/FallbackFunctionContract.sol:FallbackFunctionContract # noqa: E501 +FALLBACK_FUNCTION_CONTRACT_BYTECODE = "0x60806040526000808190555060be806100196000396000f3fe6080604052348015600f57600080fd5b5060043610602b5760003560e01c80633bc5de3014603557602c565b5b60016000819055005b603b604f565b60405160469190606f565b60405180910390f35b60008054905090565b6000819050919050565b6069816058565b82525050565b6000602082019050608260008301846062565b9291505056fea2646970667358221220e68e49e1327532e8eeed55e60110d01e6d3f2ea93607400e02eb7d30766f3c3e64736f6c63430008110033" # noqa: E501 +FALLBACK_FUNCTION_CONTRACT_RUNTIME = "0x6080604052348015600f57600080fd5b5060043610602b5760003560e01c80633bc5de3014603557602c565b5b60016000819055005b603b604f565b60405160469190606f565b60405180910390f35b60008054905090565b6000819050919050565b6069816058565b82525050565b6000602082019050608260008301846062565b9291505056fea2646970667358221220e68e49e1327532e8eeed55e60110d01e6d3f2ea93607400e02eb7d30766f3c3e64736f6c63430008110033" # noqa: E501 +FALLBACK_FUNCTION_CONTRACT_ABI = [ + {"inputs": [], "stateMutability": "payable", "type": "constructor"}, + {"stateMutability": "nonpayable", "type": "fallback"}, + { + "inputs": [], + "name": "getData", + "outputs": [{"internalType": "uint256", "name": "r", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, +] +FALLBACK_FUNCTION_CONTRACT_DATA = { + "bytecode": FALLBACK_FUNCTION_CONTRACT_BYTECODE, + "bytecode_runtime": FALLBACK_FUNCTION_CONTRACT_RUNTIME, + "abi": FALLBACK_FUNCTION_CONTRACT_ABI, +} diff --git a/web3/_utils/contract_sources/contract_data/math_contract.py b/web3/_utils/contract_sources/contract_data/math_contract.py new file mode 100644 index 0000000000..4aba391cfe --- /dev/null +++ b/web3/_utils/contract_sources/contract_data/math_contract.py @@ -0,0 +1,73 @@ +""" +Generated by `compile_contracts.py` script. +Compiled with Solidity v0.8.17. +""" + +# source: web3/_utils/contract_sources/MathContract.sol:MathContract +MATH_CONTRACT_BYTECODE = "0x60806040526000805534801561001457600080fd5b5061055b806100246000396000f3fe6080604052600436106100555760003560e01c806316216f391461005a5780635b34b9661461008557806361bc221a146100a35780636abbb3b4146100ce578063a5f3c23b146100fe578063dcf537b11461012e575b600080fd5b34801561006657600080fd5b5061006f61015e565b60405161007c9190610260565b60405180910390f35b61008d610167565b60405161009a9190610294565b60405180910390f35b3480156100af57600080fd5b506100b86101be565b6040516100c59190610294565b60405180910390f35b6100e860048036038101906100e391906102e0565b6101c4565b6040516100f59190610294565b60405180910390f35b61011860048036038101906101139190610339565b61021b565b6040516101259190610260565b60405180910390f35b61014860048036038101906101439190610379565b610231565b6040516101559190610260565b60405180910390f35b6000600d905090565b6000600160005461017891906103d5565b6000819055507f3496c3ede4ec3ab3686712aa1c238593ea6a42df83f98a5ec7df9834cfa577c560016040516101ae919061044e565b60405180910390a1600054905090565b60005481565b6000816000546101d491906103d5565b6000819055507f3496c3ede4ec3ab3686712aa1c238593ea6a42df83f98a5ec7df9834cfa577c5826040516102099190610294565b60405180910390a16000549050919050565b600081836102299190610469565b905092915050565b600060078261024091906104ad565b9050919050565b6000819050919050565b61025a81610247565b82525050565b60006020820190506102756000830184610251565b92915050565b6000819050919050565b61028e8161027b565b82525050565b60006020820190506102a96000830184610285565b92915050565b600080fd5b6102bd8161027b565b81146102c857600080fd5b50565b6000813590506102da816102b4565b92915050565b6000602082840312156102f6576102f56102af565b5b6000610304848285016102cb565b91505092915050565b61031681610247565b811461032157600080fd5b50565b6000813590506103338161030d565b92915050565b600080604083850312156103505761034f6102af565b5b600061035e85828601610324565b925050602061036f85828601610324565b9150509250929050565b60006020828403121561038f5761038e6102af565b5b600061039d84828501610324565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006103e08261027b565b91506103eb8361027b565b9250828201905080821115610403576104026103a6565b5b92915050565b6000819050919050565b6000819050919050565b600061043861043361042e84610409565b610413565b61027b565b9050919050565b6104488161041d565b82525050565b6000602082019050610463600083018461043f565b92915050565b600061047482610247565b915061047f83610247565b9250828201905082811215600083121683821260008412151617156104a7576104a66103a6565b5b92915050565b60006104b882610247565b91506104c383610247565b92508282026104d181610247565b91507f80000000000000000000000000000000000000000000000000000000000000008414600084121615610509576105086103a6565b5b828205841483151761051e5761051d6103a6565b5b509291505056fea2646970667358221220607cd99eabba12e9d39e526a2c5ee82f4af77472608174275cd751b1d4bc047164736f6c63430008110033" # noqa: E501 +MATH_CONTRACT_RUNTIME = "0x6080604052600436106100555760003560e01c806316216f391461005a5780635b34b9661461008557806361bc221a146100a35780636abbb3b4146100ce578063a5f3c23b146100fe578063dcf537b11461012e575b600080fd5b34801561006657600080fd5b5061006f61015e565b60405161007c9190610260565b60405180910390f35b61008d610167565b60405161009a9190610294565b60405180910390f35b3480156100af57600080fd5b506100b86101be565b6040516100c59190610294565b60405180910390f35b6100e860048036038101906100e391906102e0565b6101c4565b6040516100f59190610294565b60405180910390f35b61011860048036038101906101139190610339565b61021b565b6040516101259190610260565b60405180910390f35b61014860048036038101906101439190610379565b610231565b6040516101559190610260565b60405180910390f35b6000600d905090565b6000600160005461017891906103d5565b6000819055507f3496c3ede4ec3ab3686712aa1c238593ea6a42df83f98a5ec7df9834cfa577c560016040516101ae919061044e565b60405180910390a1600054905090565b60005481565b6000816000546101d491906103d5565b6000819055507f3496c3ede4ec3ab3686712aa1c238593ea6a42df83f98a5ec7df9834cfa577c5826040516102099190610294565b60405180910390a16000549050919050565b600081836102299190610469565b905092915050565b600060078261024091906104ad565b9050919050565b6000819050919050565b61025a81610247565b82525050565b60006020820190506102756000830184610251565b92915050565b6000819050919050565b61028e8161027b565b82525050565b60006020820190506102a96000830184610285565b92915050565b600080fd5b6102bd8161027b565b81146102c857600080fd5b50565b6000813590506102da816102b4565b92915050565b6000602082840312156102f6576102f56102af565b5b6000610304848285016102cb565b91505092915050565b61031681610247565b811461032157600080fd5b50565b6000813590506103338161030d565b92915050565b600080604083850312156103505761034f6102af565b5b600061035e85828601610324565b925050602061036f85828601610324565b9150509250929050565b60006020828403121561038f5761038e6102af565b5b600061039d84828501610324565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006103e08261027b565b91506103eb8361027b565b9250828201905080821115610403576104026103a6565b5b92915050565b6000819050919050565b6000819050919050565b600061043861043361042e84610409565b610413565b61027b565b9050919050565b6104488161041d565b82525050565b6000602082019050610463600083018461043f565b92915050565b600061047482610247565b915061047f83610247565b9250828201905082811215600083121683821260008412151617156104a7576104a66103a6565b5b92915050565b60006104b882610247565b91506104c383610247565b92508282026104d181610247565b91507f80000000000000000000000000000000000000000000000000000000000000008414600084121615610509576105086103a6565b5b828205841483151761051e5761051d6103a6565b5b509291505056fea2646970667358221220607cd99eabba12e9d39e526a2c5ee82f4af77472608174275cd751b1d4bc047164736f6c63430008110033" # noqa: E501 +MATH_CONTRACT_ABI = [ + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "value", + "type": "uint256", + } + ], + "name": "Increased", + "type": "event", + }, + { + "inputs": [ + {"internalType": "int256", "name": "a", "type": "int256"}, + {"internalType": "int256", "name": "b", "type": "int256"}, + ], + "name": "add", + "outputs": [{"internalType": "int256", "name": "result", "type": "int256"}], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [], + "name": "counter", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [], + "name": "incrementCounter", + "outputs": [{"internalType": "uint256", "name": "result", "type": "uint256"}], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [{"internalType": "uint256", "name": "amount", "type": "uint256"}], + "name": "incrementCounter", + "outputs": [{"internalType": "uint256", "name": "result", "type": "uint256"}], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [{"internalType": "int256", "name": "a", "type": "int256"}], + "name": "multiply7", + "outputs": [{"internalType": "int256", "name": "result", "type": "int256"}], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [], + "name": "return13", + "outputs": [{"internalType": "int256", "name": "result", "type": "int256"}], + "stateMutability": "nonpayable", + "type": "function", + }, +] +MATH_CONTRACT_DATA = { + "bytecode": MATH_CONTRACT_BYTECODE, + "bytecode_runtime": MATH_CONTRACT_RUNTIME, + "abi": MATH_CONTRACT_ABI, +} diff --git a/web3/_utils/contract_sources/contract_data/offchain_lookup.py b/web3/_utils/contract_sources/contract_data/offchain_lookup.py new file mode 100644 index 0000000000..db22da5a01 --- /dev/null +++ b/web3/_utils/contract_sources/contract_data/offchain_lookup.py @@ -0,0 +1,52 @@ +""" +Generated by `compile_contracts.py` script. +Compiled with Solidity v0.8.17. +""" + +# source: web3/_utils/contract_sources/OffchainLookup.sol:OffchainLookup +OFFCHAIN_LOOKUP_BYTECODE = "0x608060405260405180604001604052806040518060600160405280602c815260200162001129602c91398152602001604051806060016040528060258152602001620011556025913981525060009060026200005d92919062000072565b503480156200006b57600080fd5b50620004c0565b828054828255906000526020600020908101928215620000bf579160200282015b82811115620000be578251829081620000ad9190620003d9565b509160200191906001019062000093565b5b509050620000ce9190620000d2565b5090565b5b80821115620000f65760008181620000ec9190620000fa565b50600101620000d3565b5090565b5080546200010890620001c8565b6000825580601f106200011c57506200013d565b601f0160209004906000526020600020908101906200013c919062000140565b5b50565b5b808211156200015b57600081600090555060010162000141565b5090565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680620001e157607f821691505b602082108103620001f757620001f662000199565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b600060088302620002617fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8262000222565b6200026d868362000222565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b6000620002ba620002b4620002ae8462000285565b6200028f565b62000285565b9050919050565b6000819050919050565b620002d68362000299565b620002ee620002e582620002c1565b8484546200022f565b825550505050565b600090565b62000305620002f6565b62000312818484620002cb565b505050565b5b818110156200033a576200032e600082620002fb565b60018101905062000318565b5050565b601f82111562000389576200035381620001fd565b6200035e8462000212565b810160208510156200036e578190505b620003866200037d8562000212565b83018262000317565b50505b505050565b600082821c905092915050565b6000620003ae600019846008026200038e565b1980831691505092915050565b6000620003c983836200039b565b9150826002028217905092915050565b620003e4826200015f565b67ffffffffffffffff8111156200040057620003ff6200016a565b5b6200040c8254620001c8565b620004198282856200033e565b600060209050601f8311600181146200045157600084156200043c578287015190505b620004488582620003bb565b865550620004b8565b601f1984166200046186620001fd565b60005b828110156200048b5784890151825560018201915060208501945060208101905062000464565b86831015620004ab5784890151620004a7601f8916826200039b565b8355505b6001600288020188555050505b505050505050565b610c5980620004d06000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806309a3c01b146100465780636337ed5814610064578063da96d05a14610094575b600080fd5b61004e6100c4565b60405161005b919061041b565b60405180910390f35b61007e600480360381019061007991906104b6565b610114565b60405161008b919061041b565b60405180910390f35b6100ae60048036038101906100a99190610503565b610202565b6040516100bb919061041b565b60405180910390f35b606080306000826309a3c01b60e01b846040517f556f183000000000000000000000000000000000000000000000000000000000815260040161010b9594939291906107d0565b60405180910390fd5b6060600083838101906101279190610968565b90507fd9bdd1345ca2a00d0c1413137c1b2b1d0a35e5b0e11508f3b3eff856286af0758160405160200161015b91906109f8565b60405160208183030381529060405280519060200120146101b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101a890610a6c565b60405180910390fd5b306000858563da96d05a60e01b88886040517f556f18300000000000000000000000000000000000000000000000000000000081526004016101f99796959493929190610ab9565b60405180910390fd5b6060600085858101906102159190610968565b90507faed76f463930323372899e36460e078e5292aac45f645bbe567be6fca83ede108160405160200161024991906109f8565b604051602081830303815290604052805190602001201461029f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161029690610b97565b60405180910390fd5b600084848101906102b09190610968565b90507fd9bdd1345ca2a00d0c1413137c1b2b1d0a35e5b0e11508f3b3eff856286af075816040516020016102e491906109f8565b604051602081830303815290604052805190602001201461033a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161033190610c03565b60405180910390fd5b86868080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505092505050949350505050565b600081519050919050565b600082825260208201905092915050565b60005b838110156103c55780820151818401526020810190506103aa565b60008484015250505050565b6000601f19601f8301169050919050565b60006103ed8261038b565b6103f78185610396565b93506104078185602086016103a7565b610410816103d1565b840191505092915050565b6000602082019050818103600083015261043581846103e2565b905092915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f84011261047657610475610451565b5b8235905067ffffffffffffffff81111561049357610492610456565b5b6020830191508360018202830111156104af576104ae61045b565b5b9250929050565b600080602083850312156104cd576104cc610447565b5b600083013567ffffffffffffffff8111156104eb576104ea61044c565b5b6104f785828601610460565b92509250509250929050565b6000806000806040858703121561051d5761051c610447565b5b600085013567ffffffffffffffff81111561053b5761053a61044c565b5b61054787828801610460565b9450945050602085013567ffffffffffffffff81111561056a5761056961044c565b5b61057687828801610460565b925092505092959194509250565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006105af82610584565b9050919050565b6105bf816105a4565b82525050565b600081549050919050565b600082825260208201905092915050565b60008190508160005260206000209050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061063d57607f821691505b6020821081036106505761064f6105f6565b5b50919050565b600082825260208201905092915050565b60008190508160005260206000209050919050565b6000815461068981610625565b6106938186610656565b945060018216600081146106ae57600181146106c4576106f7565b60ff1983168652811515602002860193506106f7565b6106cd85610667565b60005b838110156106ef578154818901526001820191506020810190506106d0565b808801955050505b50505092915050565b600061070c838361067c565b905092915050565b6000600182019050919050565b600061072c826105c5565b61073681856105d0565b935083602082028501610748856105e1565b8060005b85811015610783578484038952816107648582610700565b945061076f83610714565b925060208a0199505060018101905061074c565b50829750879550505050505092915050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6107ca81610795565b82525050565b600060a0820190506107e560008301886105b6565b81810360208301526107f78187610721565b9050818103604083015261080b81866103e2565b905061081a60608301856107c1565b818103608083015261082c81846103e2565b90509695505050505050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610875826103d1565b810181811067ffffffffffffffff821117156108945761089361083d565b5b80604052505050565b60006108a761043d565b90506108b3828261086c565b919050565b600067ffffffffffffffff8211156108d3576108d261083d565b5b6108dc826103d1565b9050602081019050919050565b82818337600083830152505050565b600061090b610906846108b8565b61089d565b90508281526020810184848401111561092757610926610838565b5b6109328482856108e9565b509392505050565b600082601f83011261094f5761094e610451565b5b813561095f8482602086016108f8565b91505092915050565b60006020828403121561097e5761097d610447565b5b600082013567ffffffffffffffff81111561099c5761099b61044c565b5b6109a88482850161093a565b91505092915050565b600081519050919050565b600081905092915050565b60006109d2826109b1565b6109dc81856109bc565b93506109ec8185602086016103a7565b80840191505092915050565b6000610a0482846109c7565b915081905092915050565b600082825260208201905092915050565b7f7465737420646174612076616c69646174696f6e206661696c65642e00000000600082015250565b6000610a56601c83610a0f565b9150610a6182610a20565b602082019050919050565b60006020820190508181036000830152610a8581610a49565b9050919050565b6000610a988385610396565b9350610aa58385846108e9565b610aae836103d1565b840190509392505050565b600060a082019050610ace600083018a6105b6565b8181036020830152610ae08189610721565b90508181036040830152610af5818789610a8c565b9050610b0460608301866107c1565b8181036080830152610b17818486610a8c565b905098975050505050505050565b7f68747470207265717565737420726573756c742076616c69646174696f6e206660008201527f61696c65642e0000000000000000000000000000000000000000000000000000602082015250565b6000610b81602683610a0f565b9150610b8c82610b25565b604082019050919050565b60006020820190508181036000830152610bb081610b74565b9050919050565b7f6578747261446174612076616c69646174696f6e206661696c65642e00000000600082015250565b6000610bed601c83610a0f565b9150610bf882610bb7565b602082019050919050565b60006020820190508181036000830152610c1c81610be0565b905091905056fea2646970667358221220a6ddff0532d8c075835989ee350520340d5f2067000d63649f49fde354c983a064736f6c6343000811003368747470733a2f2f776562332e70792f676174657761792f7b73656e6465727d2f7b646174617d2e6a736f6e68747470733a2f2f776562332e70792f676174657761792f7b73656e6465727d2e6a736f6e" # noqa: E501 +OFFCHAIN_LOOKUP_RUNTIME = "0x608060405234801561001057600080fd5b50600436106100415760003560e01c806309a3c01b146100465780636337ed5814610064578063da96d05a14610094575b600080fd5b61004e6100c4565b60405161005b919061041b565b60405180910390f35b61007e600480360381019061007991906104b6565b610114565b60405161008b919061041b565b60405180910390f35b6100ae60048036038101906100a99190610503565b610202565b6040516100bb919061041b565b60405180910390f35b606080306000826309a3c01b60e01b846040517f556f183000000000000000000000000000000000000000000000000000000000815260040161010b9594939291906107d0565b60405180910390fd5b6060600083838101906101279190610968565b90507fd9bdd1345ca2a00d0c1413137c1b2b1d0a35e5b0e11508f3b3eff856286af0758160405160200161015b91906109f8565b60405160208183030381529060405280519060200120146101b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101a890610a6c565b60405180910390fd5b306000858563da96d05a60e01b88886040517f556f18300000000000000000000000000000000000000000000000000000000081526004016101f99796959493929190610ab9565b60405180910390fd5b6060600085858101906102159190610968565b90507faed76f463930323372899e36460e078e5292aac45f645bbe567be6fca83ede108160405160200161024991906109f8565b604051602081830303815290604052805190602001201461029f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161029690610b97565b60405180910390fd5b600084848101906102b09190610968565b90507fd9bdd1345ca2a00d0c1413137c1b2b1d0a35e5b0e11508f3b3eff856286af075816040516020016102e491906109f8565b604051602081830303815290604052805190602001201461033a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161033190610c03565b60405180910390fd5b86868080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505092505050949350505050565b600081519050919050565b600082825260208201905092915050565b60005b838110156103c55780820151818401526020810190506103aa565b60008484015250505050565b6000601f19601f8301169050919050565b60006103ed8261038b565b6103f78185610396565b93506104078185602086016103a7565b610410816103d1565b840191505092915050565b6000602082019050818103600083015261043581846103e2565b905092915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f84011261047657610475610451565b5b8235905067ffffffffffffffff81111561049357610492610456565b5b6020830191508360018202830111156104af576104ae61045b565b5b9250929050565b600080602083850312156104cd576104cc610447565b5b600083013567ffffffffffffffff8111156104eb576104ea61044c565b5b6104f785828601610460565b92509250509250929050565b6000806000806040858703121561051d5761051c610447565b5b600085013567ffffffffffffffff81111561053b5761053a61044c565b5b61054787828801610460565b9450945050602085013567ffffffffffffffff81111561056a5761056961044c565b5b61057687828801610460565b925092505092959194509250565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006105af82610584565b9050919050565b6105bf816105a4565b82525050565b600081549050919050565b600082825260208201905092915050565b60008190508160005260206000209050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061063d57607f821691505b6020821081036106505761064f6105f6565b5b50919050565b600082825260208201905092915050565b60008190508160005260206000209050919050565b6000815461068981610625565b6106938186610656565b945060018216600081146106ae57600181146106c4576106f7565b60ff1983168652811515602002860193506106f7565b6106cd85610667565b60005b838110156106ef578154818901526001820191506020810190506106d0565b808801955050505b50505092915050565b600061070c838361067c565b905092915050565b6000600182019050919050565b600061072c826105c5565b61073681856105d0565b935083602082028501610748856105e1565b8060005b85811015610783578484038952816107648582610700565b945061076f83610714565b925060208a0199505060018101905061074c565b50829750879550505050505092915050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6107ca81610795565b82525050565b600060a0820190506107e560008301886105b6565b81810360208301526107f78187610721565b9050818103604083015261080b81866103e2565b905061081a60608301856107c1565b818103608083015261082c81846103e2565b90509695505050505050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610875826103d1565b810181811067ffffffffffffffff821117156108945761089361083d565b5b80604052505050565b60006108a761043d565b90506108b3828261086c565b919050565b600067ffffffffffffffff8211156108d3576108d261083d565b5b6108dc826103d1565b9050602081019050919050565b82818337600083830152505050565b600061090b610906846108b8565b61089d565b90508281526020810184848401111561092757610926610838565b5b6109328482856108e9565b509392505050565b600082601f83011261094f5761094e610451565b5b813561095f8482602086016108f8565b91505092915050565b60006020828403121561097e5761097d610447565b5b600082013567ffffffffffffffff81111561099c5761099b61044c565b5b6109a88482850161093a565b91505092915050565b600081519050919050565b600081905092915050565b60006109d2826109b1565b6109dc81856109bc565b93506109ec8185602086016103a7565b80840191505092915050565b6000610a0482846109c7565b915081905092915050565b600082825260208201905092915050565b7f7465737420646174612076616c69646174696f6e206661696c65642e00000000600082015250565b6000610a56601c83610a0f565b9150610a6182610a20565b602082019050919050565b60006020820190508181036000830152610a8581610a49565b9050919050565b6000610a988385610396565b9350610aa58385846108e9565b610aae836103d1565b840190509392505050565b600060a082019050610ace600083018a6105b6565b8181036020830152610ae08189610721565b90508181036040830152610af5818789610a8c565b9050610b0460608301866107c1565b8181036080830152610b17818486610a8c565b905098975050505050505050565b7f68747470207265717565737420726573756c742076616c69646174696f6e206660008201527f61696c65642e0000000000000000000000000000000000000000000000000000602082015250565b6000610b81602683610a0f565b9150610b8c82610b25565b604082019050919050565b60006020820190508181036000830152610bb081610b74565b9050919050565b7f6578747261446174612076616c69646174696f6e206661696c65642e00000000600082015250565b6000610bed601c83610a0f565b9150610bf882610bb7565b602082019050919050565b60006020820190508181036000830152610c1c81610be0565b905091905056fea2646970667358221220a6ddff0532d8c075835989ee350520340d5f2067000d63649f49fde354c983a064736f6c63430008110033" # noqa: E501 +OFFCHAIN_LOOKUP_ABI = [ + { + "inputs": [ + {"internalType": "address", "name": "sender", "type": "address"}, + {"internalType": "string[]", "name": "urls", "type": "string[]"}, + {"internalType": "bytes", "name": "callData", "type": "bytes"}, + {"internalType": "bytes4", "name": "callbackFunction", "type": "bytes4"}, + {"internalType": "bytes", "name": "extraData", "type": "bytes"}, + ], + "name": "OffchainLookup", + "type": "error", + }, + { + "inputs": [], + "name": "continuousOffchainLookup", + "outputs": [{"internalType": "bytes", "name": "", "type": "bytes"}], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "bytes", "name": "specifiedDataFromTest", "type": "bytes"} + ], + "name": "testOffchainLookup", + "outputs": [{"internalType": "bytes", "name": "", "type": "bytes"}], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "bytes", "name": "result", "type": "bytes"}, + {"internalType": "bytes", "name": "extraData", "type": "bytes"}, + ], + "name": "testOffchainLookupWithProof", + "outputs": [{"internalType": "bytes", "name": "", "type": "bytes"}], + "stateMutability": "nonpayable", + "type": "function", + }, +] +OFFCHAIN_LOOKUP_DATA = { + "bytecode": OFFCHAIN_LOOKUP_BYTECODE, + "bytecode_runtime": OFFCHAIN_LOOKUP_RUNTIME, + "abi": OFFCHAIN_LOOKUP_ABI, +} diff --git a/web3/_utils/contract_sources/contract_data/offchain_resolver.py b/web3/_utils/contract_sources/contract_data/offchain_resolver.py new file mode 100644 index 0000000000..9a845a6706 --- /dev/null +++ b/web3/_utils/contract_sources/contract_data/offchain_resolver.py @@ -0,0 +1,100 @@ +""" +Generated by `compile_contracts.py` script. +Compiled with Solidity v0.8.17. +""" + +# source: web3/_utils/contract_sources/OffchainResolver.sol:OffchainResolver +OFFCHAIN_RESOLVER_BYTECODE = "0x60806040523480156200001157600080fd5b506040516200230538038062002305833981810160405281019062000037919062000637565b81600090805190602001906200004f92919062000180565b5060005b8151811015620000e7576001806000848481518110620000785762000077620006bc565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080620000de9062000724565b91505062000053565b5060018060003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507fab0b9cc3a46b568cb08d985497cde8ab7e18892d01f58db7dc7f0d2af859b2d7816040516200017091906200083f565b60405180910390a1505062000b8b565b828054828255906000526020600020908101928215620001cd579160200282015b82811115620001cc578251829081620001bb919062000aa4565b5091602001919060010190620001a1565b5b509050620001dc9190620001e0565b5090565b5b80821115620002045760008181620001fa919062000208565b50600101620001e1565b5090565b50805462000216906200089d565b6000825580601f106200022a57506200024b565b601f0160209004906000526020600020908101906200024a91906200024e565b5b50565b5b80821115620002695760008160009055506001016200024f565b5090565b6000604051905090565b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b620002d18262000286565b810181811067ffffffffffffffff82111715620002f357620002f262000297565b5b80604052505050565b6000620003086200026d565b9050620003168282620002c6565b919050565b600067ffffffffffffffff82111562000339576200033862000297565b5b602082029050602081019050919050565b600080fd5b600080fd5b600067ffffffffffffffff82111562000372576200037162000297565b5b6200037d8262000286565b9050602081019050919050565b60005b83811015620003aa5780820151818401526020810190506200038d565b60008484015250505050565b6000620003cd620003c78462000354565b620002fc565b905082815260208101848484011115620003ec57620003eb6200034f565b5b620003f98482856200038a565b509392505050565b600082601f83011262000419576200041862000281565b5b81516200042b848260208601620003b6565b91505092915050565b60006200044b62000445846200031b565b620002fc565b905080838252602082019050602084028301858111156200047157620004706200034a565b5b835b81811015620004bf57805167ffffffffffffffff8111156200049a576200049962000281565b5b808601620004a9898262000401565b8552602085019450505060208101905062000473565b5050509392505050565b600082601f830112620004e157620004e062000281565b5b8151620004f384826020860162000434565b91505092915050565b600067ffffffffffffffff8211156200051a576200051962000297565b5b602082029050602081019050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600062000558826200052b565b9050919050565b6200056a816200054b565b81146200057657600080fd5b50565b6000815190506200058a816200055f565b92915050565b6000620005a7620005a184620004fc565b620002fc565b90508083825260208201905060208402830185811115620005cd57620005cc6200034a565b5b835b81811015620005fa5780620005e5888262000579565b845260208401935050602081019050620005cf565b5050509392505050565b600082601f8301126200061c576200061b62000281565b5b81516200062e84826020860162000590565b91505092915050565b6000806040838503121562000651576200065062000277565b5b600083015167ffffffffffffffff8111156200067257620006716200027c565b5b6200068085828601620004c9565b925050602083015167ffffffffffffffff811115620006a457620006a36200027c565b5b620006b28582860162000604565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000819050919050565b600062000731826200071a565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203620007665762000765620006eb565b5b600182019050919050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b620007a8816200054b565b82525050565b6000620007bc83836200079d565b60208301905092915050565b6000602082019050919050565b6000620007e28262000771565b620007ee81856200077c565b9350620007fb836200078d565b8060005b8381101562000832578151620008168882620007ae565b97506200082383620007c8565b925050600181019050620007ff565b5085935050505092915050565b600060208201905081810360008301526200085b8184620007d5565b905092915050565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680620008b657607f821691505b602082108103620008cc57620008cb6200086e565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b600060088302620009367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82620008f7565b620009428683620008f7565b95508019841693508086168417925050509392505050565b6000819050919050565b6000620009856200097f62000979846200071a565b6200095a565b6200071a565b9050919050565b6000819050919050565b620009a18362000964565b620009b9620009b0826200098c565b84845462000904565b825550505050565b600090565b620009d0620009c1565b620009dd81848462000996565b505050565b5b8181101562000a0557620009f9600082620009c6565b600181019050620009e3565b5050565b601f82111562000a545762000a1e81620008d2565b62000a2984620008e7565b8101602085101562000a39578190505b62000a5162000a4885620008e7565b830182620009e2565b50505b505050565b600082821c905092915050565b600062000a796000198460080262000a59565b1980831691505092915050565b600062000a94838362000a66565b9150826002028217905092915050565b62000aaf8262000863565b67ffffffffffffffff81111562000acb5762000aca62000297565b5b62000ad782546200089d565b62000ae482828562000a09565b600060209050601f83116001811462000b1c576000841562000b07578287015190505b62000b13858262000a86565b86555062000b83565b601f19841662000b2c86620008d2565b60005b8281101562000b565784890151825560018201915060208501945060208101905062000b2f565b8683101562000b76578489015162000b72601f89168262000a66565b8355505b6001600288020188555050505b505050505050565b61176a8062000b9b6000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c806301ffc9a7146100675780631dcfea0914610097578063736c0d5b146100c7578063796676be146100f75780639061b92314610127578063f4d4d2f814610157575b600080fd5b610081600480360381019061007c91906109db565b610187565b60405161008e9190610a23565b60405180910390f35b6100b160048036038101906100ac9190610c22565b610201565b6040516100be9190610cda565b60405180910390f35b6100e160048036038101906100dc9190610cf5565b610219565b6040516100ee9190610a23565b60405180910390f35b610111600480360381019061010c9190610d58565b610239565b60405161011e9190610e04565b60405180910390f35b610141600480360381019061013c9190610e86565b6102e5565b60405161014e9190610f5c565b60405180910390f35b610171600480360381019061016c9190610e86565b6103b4565b60405161017e9190610f5c565b60405180910390f35b60007f9061b923000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806101fa57506101f982610462565b5b9050919050565b600061020f858585856104cc565b9050949350505050565b60016020528060005260406000206000915054906101000a900460ff1681565b6000818154811061024957600080fd5b90600052602060002001600091509050805461026490610fad565b80601f016020809104026020016040519081016040528092919081815260200182805461029090610fad565b80156102dd5780601f106102b2576101008083540402835291602001916102dd565b820191906000526020600020905b8154815290600101906020018083116102c057829003601f168201915b505050505081565b60606000639061b92360e01b86868686604051602401610308949392919061100b565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090503060008263f4d4d2f860e01b846040517f556f18300000000000000000000000000000000000000000000000000000000081526004016103ab9594939291906111d4565b60405180910390fd5b60606000806103c585858989610513565b91509150600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610455576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161044c906112ae565b60405180910390fd5b8092505050949350505050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008484848051906020012084805190602001206040516020016104f394939291906113c4565b604051602081830303815290604052805190602001209050949350505050565b600060606000806000868681019061052b919061141d565b925092509250600061058c61058630858d8d8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050886104cc565b836105a1565b90508084955095505050505094509492505050565b60008060006105b085856105c8565b915091506105bd81610649565b819250505092915050565b60008060418351036106095760008060006020860151925060408601519150606086015160001a90506105fd87828585610815565b94509450505050610642565b604083510361063957600080602085015191506040850151905061062e868383610921565b935093505050610642565b60006002915091505b9250929050565b6000600481111561065d5761065c6114a8565b5b8160048111156106705761066f6114a8565b5b0315610812576001600481111561068a576106896114a8565b5b81600481111561069d5761069c6114a8565b5b036106dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d490611523565b60405180910390fd5b600260048111156106f1576106f06114a8565b5b816004811115610704576107036114a8565b5b03610744576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161073b9061158f565b60405180910390fd5b60036004811115610758576107576114a8565b5b81600481111561076b5761076a6114a8565b5b036107ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107a290611621565b60405180910390fd5b6004808111156107be576107bd6114a8565b5b8160048111156107d1576107d06114a8565b5b03610811576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610808906116b3565b60405180910390fd5b5b50565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08360001c1115610850576000600391509150610918565b601b8560ff16141580156108685750601c8560ff1614155b1561087a576000600491509150610918565b60006001878787876040516000815260200160405260405161089f94939291906116ef565b6020604051602081039080840390855afa1580156108c1573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361090f57600060019250925050610918565b80600092509250505b94509492505050565b6000806000807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85169150601b8560ff1c01905061096187828885610815565b935093505050935093915050565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6109b881610983565b81146109c357600080fd5b50565b6000813590506109d5816109af565b92915050565b6000602082840312156109f1576109f0610979565b5b60006109ff848285016109c6565b91505092915050565b60008115159050919050565b610a1d81610a08565b82525050565b6000602082019050610a386000830184610a14565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610a6982610a3e565b9050919050565b610a7981610a5e565b8114610a8457600080fd5b50565b600081359050610a9681610a70565b92915050565b600067ffffffffffffffff82169050919050565b610ab981610a9c565b8114610ac457600080fd5b50565b600081359050610ad681610ab0565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610b2f82610ae6565b810181811067ffffffffffffffff82111715610b4e57610b4d610af7565b5b80604052505050565b6000610b6161096f565b9050610b6d8282610b26565b919050565b600067ffffffffffffffff821115610b8d57610b8c610af7565b5b610b9682610ae6565b9050602081019050919050565b82818337600083830152505050565b6000610bc5610bc084610b72565b610b57565b905082815260208101848484011115610be157610be0610ae1565b5b610bec848285610ba3565b509392505050565b600082601f830112610c0957610c08610adc565b5b8135610c19848260208601610bb2565b91505092915050565b60008060008060808587031215610c3c57610c3b610979565b5b6000610c4a87828801610a87565b9450506020610c5b87828801610ac7565b935050604085013567ffffffffffffffff811115610c7c57610c7b61097e565b5b610c8887828801610bf4565b925050606085013567ffffffffffffffff811115610ca957610ca861097e565b5b610cb587828801610bf4565b91505092959194509250565b6000819050919050565b610cd481610cc1565b82525050565b6000602082019050610cef6000830184610ccb565b92915050565b600060208284031215610d0b57610d0a610979565b5b6000610d1984828501610a87565b91505092915050565b6000819050919050565b610d3581610d22565b8114610d4057600080fd5b50565b600081359050610d5281610d2c565b92915050565b600060208284031215610d6e57610d6d610979565b5b6000610d7c84828501610d43565b91505092915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610dbf578082015181840152602081019050610da4565b60008484015250505050565b6000610dd682610d85565b610de08185610d90565b9350610df0818560208601610da1565b610df981610ae6565b840191505092915050565b60006020820190508181036000830152610e1e8184610dcb565b905092915050565b600080fd5b600080fd5b60008083601f840112610e4657610e45610adc565b5b8235905067ffffffffffffffff811115610e6357610e62610e26565b5b602083019150836001820283011115610e7f57610e7e610e2b565b5b9250929050565b60008060008060408587031215610ea057610e9f610979565b5b600085013567ffffffffffffffff811115610ebe57610ebd61097e565b5b610eca87828801610e30565b9450945050602085013567ffffffffffffffff811115610eed57610eec61097e565b5b610ef987828801610e30565b925092505092959194509250565b600081519050919050565b600082825260208201905092915050565b6000610f2e82610f07565b610f388185610f12565b9350610f48818560208601610da1565b610f5181610ae6565b840191505092915050565b60006020820190508181036000830152610f768184610f23565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680610fc557607f821691505b602082108103610fd857610fd7610f7e565b5b50919050565b6000610fea8385610f12565b9350610ff7838584610ba3565b61100083610ae6565b840190509392505050565b60006040820190508181036000830152611026818688610fde565b9050818103602083015261103b818486610fde565b905095945050505050565b61104f81610a5e565b82525050565b600081549050919050565b600082825260208201905092915050565b60008190508160005260206000209050919050565b600082825260208201905092915050565b60008190508160005260206000209050919050565b600081546110b981610fad565b6110c38186611086565b945060018216600081146110de57600181146110f457611127565b60ff198316865281151560200286019350611127565b6110fd85611097565b60005b8381101561111f57815481890152600182019150602081019050611100565b808801955050505b50505092915050565b600061113c83836110ac565b905092915050565b6000600182019050919050565b600061115c82611055565b6111668185611060565b93508360208202850161117885611071565b8060005b858110156111b3578484038952816111948582611130565b945061119f83611144565b925060208a0199505060018101905061117c565b50829750879550505050505092915050565b6111ce81610983565b82525050565b600060a0820190506111e96000830188611046565b81810360208301526111fb8187611151565b9050818103604083015261120f8186610f23565b905061121e60608301856111c5565b81810360808301526112308184610f23565b90509695505050505050565b7f5369676e617475726556657269666965723a20496e76616c6964207369676e6160008201527f7475726500000000000000000000000000000000000000000000000000000000602082015250565b6000611298602483610d90565b91506112a38261123c565b604082019050919050565b600060208201905081810360008301526112c78161128b565b9050919050565b600081905092915050565b7f1900000000000000000000000000000000000000000000000000000000000000600082015250565b600061130f6002836112ce565b915061131a826112d9565b600282019050919050565b60008160601b9050919050565b600061133d82611325565b9050919050565b600061134f82611332565b9050919050565b61136761136282610a5e565b611344565b82525050565b60008160c01b9050919050565b60006113858261136d565b9050919050565b61139d61139882610a9c565b61137a565b82525050565b6000819050919050565b6113be6113b982610cc1565b6113a3565b82525050565b60006113cf82611302565b91506113db8287611356565b6014820191506113eb828661138c565b6008820191506113fb82856113ad565b60208201915061140b82846113ad565b60208201915081905095945050505050565b60008060006060848603121561143657611435610979565b5b600084013567ffffffffffffffff8111156114545761145361097e565b5b61146086828701610bf4565b935050602061147186828701610ac7565b925050604084013567ffffffffffffffff8111156114925761149161097e565b5b61149e86828701610bf4565b9150509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f45434453413a20696e76616c6964207369676e61747572650000000000000000600082015250565b600061150d601883610d90565b9150611518826114d7565b602082019050919050565b6000602082019050818103600083015261153c81611500565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265206c656e67746800600082015250565b6000611579601f83610d90565b915061158482611543565b602082019050919050565b600060208201905081810360008301526115a88161156c565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265202773272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b600061160b602283610d90565b9150611616826115af565b604082019050919050565b6000602082019050818103600083015261163a816115fe565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265202776272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b600061169d602283610d90565b91506116a882611641565b604082019050919050565b600060208201905081810360008301526116cc81611690565b9050919050565b600060ff82169050919050565b6116e9816116d3565b82525050565b60006080820190506117046000830187610ccb565b61171160208301866116e0565b61171e6040830185610ccb565b61172b6060830184610ccb565b9594505050505056fea2646970667358221220926d54cf87c2ee927634d1a46e75088d8df28c8ee843b4fb4c2c16196a914f1c64736f6c63430008110033" # noqa: E501 +OFFCHAIN_RESOLVER_RUNTIME = "0x608060405234801561001057600080fd5b50600436106100625760003560e01c806301ffc9a7146100675780631dcfea0914610097578063736c0d5b146100c7578063796676be146100f75780639061b92314610127578063f4d4d2f814610157575b600080fd5b610081600480360381019061007c91906109db565b610187565b60405161008e9190610a23565b60405180910390f35b6100b160048036038101906100ac9190610c22565b610201565b6040516100be9190610cda565b60405180910390f35b6100e160048036038101906100dc9190610cf5565b610219565b6040516100ee9190610a23565b60405180910390f35b610111600480360381019061010c9190610d58565b610239565b60405161011e9190610e04565b60405180910390f35b610141600480360381019061013c9190610e86565b6102e5565b60405161014e9190610f5c565b60405180910390f35b610171600480360381019061016c9190610e86565b6103b4565b60405161017e9190610f5c565b60405180910390f35b60007f9061b923000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806101fa57506101f982610462565b5b9050919050565b600061020f858585856104cc565b9050949350505050565b60016020528060005260406000206000915054906101000a900460ff1681565b6000818154811061024957600080fd5b90600052602060002001600091509050805461026490610fad565b80601f016020809104026020016040519081016040528092919081815260200182805461029090610fad565b80156102dd5780601f106102b2576101008083540402835291602001916102dd565b820191906000526020600020905b8154815290600101906020018083116102c057829003601f168201915b505050505081565b60606000639061b92360e01b86868686604051602401610308949392919061100b565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090503060008263f4d4d2f860e01b846040517f556f18300000000000000000000000000000000000000000000000000000000081526004016103ab9594939291906111d4565b60405180910390fd5b60606000806103c585858989610513565b91509150600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610455576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161044c906112ae565b60405180910390fd5b8092505050949350505050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008484848051906020012084805190602001206040516020016104f394939291906113c4565b604051602081830303815290604052805190602001209050949350505050565b600060606000806000868681019061052b919061141d565b925092509250600061058c61058630858d8d8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050886104cc565b836105a1565b90508084955095505050505094509492505050565b60008060006105b085856105c8565b915091506105bd81610649565b819250505092915050565b60008060418351036106095760008060006020860151925060408601519150606086015160001a90506105fd87828585610815565b94509450505050610642565b604083510361063957600080602085015191506040850151905061062e868383610921565b935093505050610642565b60006002915091505b9250929050565b6000600481111561065d5761065c6114a8565b5b8160048111156106705761066f6114a8565b5b0315610812576001600481111561068a576106896114a8565b5b81600481111561069d5761069c6114a8565b5b036106dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d490611523565b60405180910390fd5b600260048111156106f1576106f06114a8565b5b816004811115610704576107036114a8565b5b03610744576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161073b9061158f565b60405180910390fd5b60036004811115610758576107576114a8565b5b81600481111561076b5761076a6114a8565b5b036107ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107a290611621565b60405180910390fd5b6004808111156107be576107bd6114a8565b5b8160048111156107d1576107d06114a8565b5b03610811576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610808906116b3565b60405180910390fd5b5b50565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08360001c1115610850576000600391509150610918565b601b8560ff16141580156108685750601c8560ff1614155b1561087a576000600491509150610918565b60006001878787876040516000815260200160405260405161089f94939291906116ef565b6020604051602081039080840390855afa1580156108c1573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361090f57600060019250925050610918565b80600092509250505b94509492505050565b6000806000807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85169150601b8560ff1c01905061096187828885610815565b935093505050935093915050565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6109b881610983565b81146109c357600080fd5b50565b6000813590506109d5816109af565b92915050565b6000602082840312156109f1576109f0610979565b5b60006109ff848285016109c6565b91505092915050565b60008115159050919050565b610a1d81610a08565b82525050565b6000602082019050610a386000830184610a14565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610a6982610a3e565b9050919050565b610a7981610a5e565b8114610a8457600080fd5b50565b600081359050610a9681610a70565b92915050565b600067ffffffffffffffff82169050919050565b610ab981610a9c565b8114610ac457600080fd5b50565b600081359050610ad681610ab0565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610b2f82610ae6565b810181811067ffffffffffffffff82111715610b4e57610b4d610af7565b5b80604052505050565b6000610b6161096f565b9050610b6d8282610b26565b919050565b600067ffffffffffffffff821115610b8d57610b8c610af7565b5b610b9682610ae6565b9050602081019050919050565b82818337600083830152505050565b6000610bc5610bc084610b72565b610b57565b905082815260208101848484011115610be157610be0610ae1565b5b610bec848285610ba3565b509392505050565b600082601f830112610c0957610c08610adc565b5b8135610c19848260208601610bb2565b91505092915050565b60008060008060808587031215610c3c57610c3b610979565b5b6000610c4a87828801610a87565b9450506020610c5b87828801610ac7565b935050604085013567ffffffffffffffff811115610c7c57610c7b61097e565b5b610c8887828801610bf4565b925050606085013567ffffffffffffffff811115610ca957610ca861097e565b5b610cb587828801610bf4565b91505092959194509250565b6000819050919050565b610cd481610cc1565b82525050565b6000602082019050610cef6000830184610ccb565b92915050565b600060208284031215610d0b57610d0a610979565b5b6000610d1984828501610a87565b91505092915050565b6000819050919050565b610d3581610d22565b8114610d4057600080fd5b50565b600081359050610d5281610d2c565b92915050565b600060208284031215610d6e57610d6d610979565b5b6000610d7c84828501610d43565b91505092915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610dbf578082015181840152602081019050610da4565b60008484015250505050565b6000610dd682610d85565b610de08185610d90565b9350610df0818560208601610da1565b610df981610ae6565b840191505092915050565b60006020820190508181036000830152610e1e8184610dcb565b905092915050565b600080fd5b600080fd5b60008083601f840112610e4657610e45610adc565b5b8235905067ffffffffffffffff811115610e6357610e62610e26565b5b602083019150836001820283011115610e7f57610e7e610e2b565b5b9250929050565b60008060008060408587031215610ea057610e9f610979565b5b600085013567ffffffffffffffff811115610ebe57610ebd61097e565b5b610eca87828801610e30565b9450945050602085013567ffffffffffffffff811115610eed57610eec61097e565b5b610ef987828801610e30565b925092505092959194509250565b600081519050919050565b600082825260208201905092915050565b6000610f2e82610f07565b610f388185610f12565b9350610f48818560208601610da1565b610f5181610ae6565b840191505092915050565b60006020820190508181036000830152610f768184610f23565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680610fc557607f821691505b602082108103610fd857610fd7610f7e565b5b50919050565b6000610fea8385610f12565b9350610ff7838584610ba3565b61100083610ae6565b840190509392505050565b60006040820190508181036000830152611026818688610fde565b9050818103602083015261103b818486610fde565b905095945050505050565b61104f81610a5e565b82525050565b600081549050919050565b600082825260208201905092915050565b60008190508160005260206000209050919050565b600082825260208201905092915050565b60008190508160005260206000209050919050565b600081546110b981610fad565b6110c38186611086565b945060018216600081146110de57600181146110f457611127565b60ff198316865281151560200286019350611127565b6110fd85611097565b60005b8381101561111f57815481890152600182019150602081019050611100565b808801955050505b50505092915050565b600061113c83836110ac565b905092915050565b6000600182019050919050565b600061115c82611055565b6111668185611060565b93508360208202850161117885611071565b8060005b858110156111b3578484038952816111948582611130565b945061119f83611144565b925060208a0199505060018101905061117c565b50829750879550505050505092915050565b6111ce81610983565b82525050565b600060a0820190506111e96000830188611046565b81810360208301526111fb8187611151565b9050818103604083015261120f8186610f23565b905061121e60608301856111c5565b81810360808301526112308184610f23565b90509695505050505050565b7f5369676e617475726556657269666965723a20496e76616c6964207369676e6160008201527f7475726500000000000000000000000000000000000000000000000000000000602082015250565b6000611298602483610d90565b91506112a38261123c565b604082019050919050565b600060208201905081810360008301526112c78161128b565b9050919050565b600081905092915050565b7f1900000000000000000000000000000000000000000000000000000000000000600082015250565b600061130f6002836112ce565b915061131a826112d9565b600282019050919050565b60008160601b9050919050565b600061133d82611325565b9050919050565b600061134f82611332565b9050919050565b61136761136282610a5e565b611344565b82525050565b60008160c01b9050919050565b60006113858261136d565b9050919050565b61139d61139882610a9c565b61137a565b82525050565b6000819050919050565b6113be6113b982610cc1565b6113a3565b82525050565b60006113cf82611302565b91506113db8287611356565b6014820191506113eb828661138c565b6008820191506113fb82856113ad565b60208201915061140b82846113ad565b60208201915081905095945050505050565b60008060006060848603121561143657611435610979565b5b600084013567ffffffffffffffff8111156114545761145361097e565b5b61146086828701610bf4565b935050602061147186828701610ac7565b925050604084013567ffffffffffffffff8111156114925761149161097e565b5b61149e86828701610bf4565b9150509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f45434453413a20696e76616c6964207369676e61747572650000000000000000600082015250565b600061150d601883610d90565b9150611518826114d7565b602082019050919050565b6000602082019050818103600083015261153c81611500565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265206c656e67746800600082015250565b6000611579601f83610d90565b915061158482611543565b602082019050919050565b600060208201905081810360008301526115a88161156c565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265202773272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b600061160b602283610d90565b9150611616826115af565b604082019050919050565b6000602082019050818103600083015261163a816115fe565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265202776272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b600061169d602283610d90565b91506116a882611641565b604082019050919050565b600060208201905081810360008301526116cc81611690565b9050919050565b600060ff82169050919050565b6116e9816116d3565b82525050565b60006080820190506117046000830187610ccb565b61171160208301866116e0565b61171e6040830185610ccb565b61172b6060830184610ccb565b9594505050505056fea2646970667358221220926d54cf87c2ee927634d1a46e75088d8df28c8ee843b4fb4c2c16196a914f1c64736f6c63430008110033" # noqa: E501 +OFFCHAIN_RESOLVER_ABI = [ + { + "inputs": [ + {"internalType": "string[]", "name": "_urls", "type": "string[]"}, + {"internalType": "address[]", "name": "_signers", "type": "address[]"}, + ], + "stateMutability": "nonpayable", + "type": "constructor", + }, + { + "inputs": [ + {"internalType": "address", "name": "sender", "type": "address"}, + {"internalType": "string[]", "name": "urls", "type": "string[]"}, + {"internalType": "bytes", "name": "callData", "type": "bytes"}, + {"internalType": "bytes4", "name": "callbackFunction", "type": "bytes4"}, + {"internalType": "bytes", "name": "extraData", "type": "bytes"}, + ], + "name": "OffchainLookup", + "type": "error", + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "address[]", + "name": "signers", + "type": "address[]", + } + ], + "name": "NewSigners", + "type": "event", + }, + { + "inputs": [ + {"internalType": "address", "name": "target", "type": "address"}, + {"internalType": "uint64", "name": "expires", "type": "uint64"}, + {"internalType": "bytes", "name": "request", "type": "bytes"}, + {"internalType": "bytes", "name": "result", "type": "bytes"}, + ], + "name": "makeSignatureHash", + "outputs": [{"internalType": "bytes32", "name": "", "type": "bytes32"}], + "stateMutability": "pure", + "type": "function", + }, + { + "inputs": [ + {"internalType": "bytes", "name": "name", "type": "bytes"}, + {"internalType": "bytes", "name": "data", "type": "bytes"}, + ], + "name": "resolve", + "outputs": [{"internalType": "bytes", "name": "", "type": "bytes"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [ + {"internalType": "bytes", "name": "response", "type": "bytes"}, + {"internalType": "bytes", "name": "extraData", "type": "bytes"}, + ], + "name": "resolveWithProof", + "outputs": [{"internalType": "bytes", "name": "", "type": "bytes"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [{"internalType": "address", "name": "", "type": "address"}], + "name": "signers", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [{"internalType": "bytes4", "name": "interfaceID", "type": "bytes4"}], + "name": "supportsInterface", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "pure", + "type": "function", + }, + { + "inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "name": "urls", + "outputs": [{"internalType": "string", "name": "", "type": "string"}], + "stateMutability": "view", + "type": "function", + }, +] +OFFCHAIN_RESOLVER_DATA = { + "bytecode": OFFCHAIN_RESOLVER_BYTECODE, + "bytecode_runtime": OFFCHAIN_RESOLVER_RUNTIME, + "abi": OFFCHAIN_RESOLVER_ABI, +} diff --git a/web3/_utils/contract_sources/contract_data/payable_tester.py b/web3/_utils/contract_sources/contract_data/payable_tester.py new file mode 100644 index 0000000000..807bb4c529 --- /dev/null +++ b/web3/_utils/contract_sources/contract_data/payable_tester.py @@ -0,0 +1,29 @@ +""" +Generated by `compile_contracts.py` script. +Compiled with Solidity v0.8.17. +""" + +# source: web3/_utils/contract_sources/PayableTester.sol:PayableTesterContract +PAYABLE_TESTER_CONTRACT_BYTECODE = "0x608060405234801561001057600080fd5b5060ee8061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c8063c6803622146037578063e4cb8f5c146051575b600080fd5b603d6059565b60405160489190609f565b60405180910390f35b6057606a565b005b60008054906101000a900460ff1681565b60016000806101000a81548160ff021916908315150217905550565b60008115159050919050565b6099816086565b82525050565b600060208201905060b260008301846092565b9291505056fea264697066735822122000b51898fbc08d97b14a5a31d9c7fa634a58531d88a18c6a31c981fd5e52334e64736f6c63430008110033" # noqa: E501 +PAYABLE_TESTER_CONTRACT_RUNTIME = "0x6080604052348015600f57600080fd5b506004361060325760003560e01c8063c6803622146037578063e4cb8f5c146051575b600080fd5b603d6059565b60405160489190609f565b60405180910390f35b6057606a565b005b60008054906101000a900460ff1681565b60016000806101000a81548160ff021916908315150217905550565b60008115159050919050565b6099816086565b82525050565b600060208201905060b260008301846092565b9291505056fea264697066735822122000b51898fbc08d97b14a5a31d9c7fa634a58531d88a18c6a31c981fd5e52334e64736f6c63430008110033" # noqa: E501 +PAYABLE_TESTER_CONTRACT_ABI = [ + { + "inputs": [], + "name": "doNoValueCall", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "wasCalled", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "view", + "type": "function", + }, +] +PAYABLE_TESTER_CONTRACT_DATA = { + "bytecode": PAYABLE_TESTER_CONTRACT_BYTECODE, + "bytecode_runtime": PAYABLE_TESTER_CONTRACT_RUNTIME, + "abi": PAYABLE_TESTER_CONTRACT_ABI, +} diff --git a/web3/_utils/contract_sources/contract_data/receive_function_contracts.py b/web3/_utils/contract_sources/contract_data/receive_function_contracts.py new file mode 100644 index 0000000000..340ee56f55 --- /dev/null +++ b/web3/_utils/contract_sources/contract_data/receive_function_contracts.py @@ -0,0 +1,58 @@ +""" +Generated by `compile_contracts.py` script. +Compiled with Solidity v0.8.17. +""" + +# source: web3/_utils/contract_sources/ReceiveFunctionContracts.sol:ReceiveFunctionContract # noqa: E501 +RECEIVE_FUNCTION_CONTRACT_BYTECODE = "0x608060405234801561001057600080fd5b506107bb806100206000396000f3fe60806040526004361061002d5760003560e01c80635d3a1f9d146100be578063e00fe2eb146100fb57610078565b36610078576040518060400160405280600781526020017f72656365697665000000000000000000000000000000000000000000000000008152506000908161007691906104a9565b005b6040518060400160405280600881526020017f66616c6c6261636b000000000000000000000000000000000000000000000000815250600090816100bc91906104a9565b005b3480156100ca57600080fd5b506100e560048036038101906100e091906106a6565b610126565b6040516100f29190610763565b60405180910390f35b34801561010757600080fd5b506101106101c7565b60405161011d9190610763565b60405180910390f35b6060816000908161013791906104a9565b8054610142906102c2565b80601f016020809104026020016040519081016040528092919081815260200182805461016e906102c2565b80156101bb5780601f10610190576101008083540402835291602001916101bb565b820191906000526020600020905b81548152906001019060200180831161019e57829003601f168201915b50505050509050919050565b6060600080546101d6906102c2565b80601f0160208091040260200160405190810160405280929190818152602001828054610202906102c2565b801561024f5780601f106102245761010080835404028352916020019161024f565b820191906000526020600020905b81548152906001019060200180831161023257829003601f168201915b5050505050905090565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806102da57607f821691505b6020821081036102ed576102ec610293565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026103557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82610318565b61035f8683610318565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b60006103a66103a161039c84610377565b610381565b610377565b9050919050565b6000819050919050565b6103c08361038b565b6103d46103cc826103ad565b848454610325565b825550505050565b600090565b6103e96103dc565b6103f48184846103b7565b505050565b5b818110156104185761040d6000826103e1565b6001810190506103fa565b5050565b601f82111561045d5761042e816102f3565b61043784610308565b81016020851015610446578190505b61045a61045285610308565b8301826103f9565b50505b505050565b600082821c905092915050565b600061048060001984600802610462565b1980831691505092915050565b6000610499838361046f565b9150826002028217905092915050565b6104b282610259565b67ffffffffffffffff8111156104cb576104ca610264565b5b6104d582546102c2565b6104e082828561041c565b600060209050601f8311600181146105135760008415610501578287015190505b61050b858261048d565b865550610573565b601f198416610521866102f3565b60005b8281101561054957848901518255600182019150602085019450602081019050610524565b868310156105665784890151610562601f89168261046f565b8355505b6001600288020188555050505b505050505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b6105b382610599565b810181811067ffffffffffffffff821117156105d2576105d1610264565b5b80604052505050565b60006105e561057b565b90506105f182826105aa565b919050565b600067ffffffffffffffff82111561061157610610610264565b5b61061a82610599565b9050602081019050919050565b82818337600083830152505050565b6000610649610644846105f6565b6105db565b90508281526020810184848401111561066557610664610594565b5b610670848285610627565b509392505050565b600082601f83011261068d5761068c61058f565b5b813561069d848260208601610636565b91505092915050565b6000602082840312156106bc576106bb610585565b5b600082013567ffffffffffffffff8111156106da576106d961058a565b5b6106e684828501610678565b91505092915050565b600082825260208201905092915050565b60005b8381101561071e578082015181840152602081019050610703565b60008484015250505050565b600061073582610259565b61073f81856106ef565b935061074f818560208601610700565b61075881610599565b840191505092915050565b6000602082019050818103600083015261077d818461072a565b90509291505056fea264697066735822122038c1ccb29287dbfea00d3e9b9c59d5a19fdcb228f06f7e39792bfcd2351193cf64736f6c63430008110033" # noqa: E501 +RECEIVE_FUNCTION_CONTRACT_RUNTIME = "0x60806040526004361061002d5760003560e01c80635d3a1f9d146100be578063e00fe2eb146100fb57610078565b36610078576040518060400160405280600781526020017f72656365697665000000000000000000000000000000000000000000000000008152506000908161007691906104a9565b005b6040518060400160405280600881526020017f66616c6c6261636b000000000000000000000000000000000000000000000000815250600090816100bc91906104a9565b005b3480156100ca57600080fd5b506100e560048036038101906100e091906106a6565b610126565b6040516100f29190610763565b60405180910390f35b34801561010757600080fd5b506101106101c7565b60405161011d9190610763565b60405180910390f35b6060816000908161013791906104a9565b8054610142906102c2565b80601f016020809104026020016040519081016040528092919081815260200182805461016e906102c2565b80156101bb5780601f10610190576101008083540402835291602001916101bb565b820191906000526020600020905b81548152906001019060200180831161019e57829003601f168201915b50505050509050919050565b6060600080546101d6906102c2565b80601f0160208091040260200160405190810160405280929190818152602001828054610202906102c2565b801561024f5780601f106102245761010080835404028352916020019161024f565b820191906000526020600020905b81548152906001019060200180831161023257829003601f168201915b5050505050905090565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806102da57607f821691505b6020821081036102ed576102ec610293565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026103557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82610318565b61035f8683610318565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b60006103a66103a161039c84610377565b610381565b610377565b9050919050565b6000819050919050565b6103c08361038b565b6103d46103cc826103ad565b848454610325565b825550505050565b600090565b6103e96103dc565b6103f48184846103b7565b505050565b5b818110156104185761040d6000826103e1565b6001810190506103fa565b5050565b601f82111561045d5761042e816102f3565b61043784610308565b81016020851015610446578190505b61045a61045285610308565b8301826103f9565b50505b505050565b600082821c905092915050565b600061048060001984600802610462565b1980831691505092915050565b6000610499838361046f565b9150826002028217905092915050565b6104b282610259565b67ffffffffffffffff8111156104cb576104ca610264565b5b6104d582546102c2565b6104e082828561041c565b600060209050601f8311600181146105135760008415610501578287015190505b61050b858261048d565b865550610573565b601f198416610521866102f3565b60005b8281101561054957848901518255600182019150602085019450602081019050610524565b868310156105665784890151610562601f89168261046f565b8355505b6001600288020188555050505b505050505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b6105b382610599565b810181811067ffffffffffffffff821117156105d2576105d1610264565b5b80604052505050565b60006105e561057b565b90506105f182826105aa565b919050565b600067ffffffffffffffff82111561061157610610610264565b5b61061a82610599565b9050602081019050919050565b82818337600083830152505050565b6000610649610644846105f6565b6105db565b90508281526020810184848401111561066557610664610594565b5b610670848285610627565b509392505050565b600082601f83011261068d5761068c61058f565b5b813561069d848260208601610636565b91505092915050565b6000602082840312156106bc576106bb610585565b5b600082013567ffffffffffffffff8111156106da576106d961058a565b5b6106e684828501610678565b91505092915050565b600082825260208201905092915050565b60005b8381101561071e578082015181840152602081019050610703565b60008484015250505050565b600061073582610259565b61073f81856106ef565b935061074f818560208601610700565b61075881610599565b840191505092915050565b6000602082019050818103600083015261077d818461072a565b90509291505056fea264697066735822122038c1ccb29287dbfea00d3e9b9c59d5a19fdcb228f06f7e39792bfcd2351193cf64736f6c63430008110033" # noqa: E501 +RECEIVE_FUNCTION_CONTRACT_ABI = [ + {"stateMutability": "payable", "type": "fallback"}, + { + "inputs": [], + "name": "getText", + "outputs": [{"internalType": "string", "name": "", "type": "string"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [{"internalType": "string", "name": "new_text", "type": "string"}], + "name": "setText", + "outputs": [{"internalType": "string", "name": "", "type": "string"}], + "stateMutability": "nonpayable", + "type": "function", + }, + {"stateMutability": "payable", "type": "receive"}, +] +RECEIVE_FUNCTION_CONTRACT_DATA = { + "bytecode": RECEIVE_FUNCTION_CONTRACT_BYTECODE, + "bytecode_runtime": RECEIVE_FUNCTION_CONTRACT_RUNTIME, + "abi": RECEIVE_FUNCTION_CONTRACT_ABI, +} + + +# source: web3/_utils/contract_sources/ReceiveFunctionContracts.sol:NoReceiveFunctionContract # noqa: E501 +NO_RECEIVE_FUNCTION_CONTRACT_BYTECODE = "0x608060405234801561001057600080fd5b50610764806100206000396000f3fe608060405234801561001057600080fd5b506004361061003a5760003560e01c80635d3a1f9d14610081578063e00fe2eb146100b15761003b565b5b6040518060400160405280600881526020017f66616c6c6261636b0000000000000000000000000000000000000000000000008152506000908161007f9190610452565b005b61009b6004803603810190610096919061064f565b6100cf565b6040516100a8919061070c565b60405180910390f35b6100b9610170565b6040516100c6919061070c565b60405180910390f35b606081600090816100e09190610452565b80546100eb9061026b565b80601f01602080910402602001604051908101604052809291908181526020018280546101179061026b565b80156101645780601f1061013957610100808354040283529160200191610164565b820191906000526020600020905b81548152906001019060200180831161014757829003601f168201915b50505050509050919050565b60606000805461017f9061026b565b80601f01602080910402602001604051908101604052809291908181526020018280546101ab9061026b565b80156101f85780601f106101cd576101008083540402835291602001916101f8565b820191906000526020600020905b8154815290600101906020018083116101db57829003601f168201915b5050505050905090565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061028357607f821691505b6020821081036102965761029561023c565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026102fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826102c1565b61030886836102c1565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b600061034f61034a61034584610320565b61032a565b610320565b9050919050565b6000819050919050565b61036983610334565b61037d61037582610356565b8484546102ce565b825550505050565b600090565b610392610385565b61039d818484610360565b505050565b5b818110156103c1576103b660008261038a565b6001810190506103a3565b5050565b601f821115610406576103d78161029c565b6103e0846102b1565b810160208510156103ef578190505b6104036103fb856102b1565b8301826103a2565b50505b505050565b600082821c905092915050565b60006104296000198460080261040b565b1980831691505092915050565b60006104428383610418565b9150826002028217905092915050565b61045b82610202565b67ffffffffffffffff8111156104745761047361020d565b5b61047e825461026b565b6104898282856103c5565b600060209050601f8311600181146104bc57600084156104aa578287015190505b6104b48582610436565b86555061051c565b601f1984166104ca8661029c565b60005b828110156104f2578489015182556001820191506020850194506020810190506104cd565b8683101561050f578489015161050b601f891682610418565b8355505b6001600288020188555050505b505050505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b61055c82610542565b810181811067ffffffffffffffff8211171561057b5761057a61020d565b5b80604052505050565b600061058e610524565b905061059a8282610553565b919050565b600067ffffffffffffffff8211156105ba576105b961020d565b5b6105c382610542565b9050602081019050919050565b82818337600083830152505050565b60006105f26105ed8461059f565b610584565b90508281526020810184848401111561060e5761060d61053d565b5b6106198482856105d0565b509392505050565b600082601f83011261063657610635610538565b5b81356106468482602086016105df565b91505092915050565b6000602082840312156106655761066461052e565b5b600082013567ffffffffffffffff81111561068357610682610533565b5b61068f84828501610621565b91505092915050565b600082825260208201905092915050565b60005b838110156106c75780820151818401526020810190506106ac565b60008484015250505050565b60006106de82610202565b6106e88185610698565b93506106f88185602086016106a9565b61070181610542565b840191505092915050565b6000602082019050818103600083015261072681846106d3565b90509291505056fea2646970667358221220b9f5d8e3526abab8fb79e1fec33978f4e30ed8b1c0dc91e05979b570430812b764736f6c63430008110033" # noqa: E501 +NO_RECEIVE_FUNCTION_CONTRACT_RUNTIME = "0x608060405234801561001057600080fd5b506004361061003a5760003560e01c80635d3a1f9d14610081578063e00fe2eb146100b15761003b565b5b6040518060400160405280600881526020017f66616c6c6261636b0000000000000000000000000000000000000000000000008152506000908161007f9190610452565b005b61009b6004803603810190610096919061064f565b6100cf565b6040516100a8919061070c565b60405180910390f35b6100b9610170565b6040516100c6919061070c565b60405180910390f35b606081600090816100e09190610452565b80546100eb9061026b565b80601f01602080910402602001604051908101604052809291908181526020018280546101179061026b565b80156101645780601f1061013957610100808354040283529160200191610164565b820191906000526020600020905b81548152906001019060200180831161014757829003601f168201915b50505050509050919050565b60606000805461017f9061026b565b80601f01602080910402602001604051908101604052809291908181526020018280546101ab9061026b565b80156101f85780601f106101cd576101008083540402835291602001916101f8565b820191906000526020600020905b8154815290600101906020018083116101db57829003601f168201915b5050505050905090565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061028357607f821691505b6020821081036102965761029561023c565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026102fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826102c1565b61030886836102c1565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b600061034f61034a61034584610320565b61032a565b610320565b9050919050565b6000819050919050565b61036983610334565b61037d61037582610356565b8484546102ce565b825550505050565b600090565b610392610385565b61039d818484610360565b505050565b5b818110156103c1576103b660008261038a565b6001810190506103a3565b5050565b601f821115610406576103d78161029c565b6103e0846102b1565b810160208510156103ef578190505b6104036103fb856102b1565b8301826103a2565b50505b505050565b600082821c905092915050565b60006104296000198460080261040b565b1980831691505092915050565b60006104428383610418565b9150826002028217905092915050565b61045b82610202565b67ffffffffffffffff8111156104745761047361020d565b5b61047e825461026b565b6104898282856103c5565b600060209050601f8311600181146104bc57600084156104aa578287015190505b6104b48582610436565b86555061051c565b601f1984166104ca8661029c565b60005b828110156104f2578489015182556001820191506020850194506020810190506104cd565b8683101561050f578489015161050b601f891682610418565b8355505b6001600288020188555050505b505050505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b61055c82610542565b810181811067ffffffffffffffff8211171561057b5761057a61020d565b5b80604052505050565b600061058e610524565b905061059a8282610553565b919050565b600067ffffffffffffffff8211156105ba576105b961020d565b5b6105c382610542565b9050602081019050919050565b82818337600083830152505050565b60006105f26105ed8461059f565b610584565b90508281526020810184848401111561060e5761060d61053d565b5b6106198482856105d0565b509392505050565b600082601f83011261063657610635610538565b5b81356106468482602086016105df565b91505092915050565b6000602082840312156106655761066461052e565b5b600082013567ffffffffffffffff81111561068357610682610533565b5b61068f84828501610621565b91505092915050565b600082825260208201905092915050565b60005b838110156106c75780820151818401526020810190506106ac565b60008484015250505050565b60006106de82610202565b6106e88185610698565b93506106f88185602086016106a9565b61070181610542565b840191505092915050565b6000602082019050818103600083015261072681846106d3565b90509291505056fea2646970667358221220b9f5d8e3526abab8fb79e1fec33978f4e30ed8b1c0dc91e05979b570430812b764736f6c63430008110033" # noqa: E501 +NO_RECEIVE_FUNCTION_CONTRACT_ABI = [ + {"stateMutability": "nonpayable", "type": "fallback"}, + { + "inputs": [], + "name": "getText", + "outputs": [{"internalType": "string", "name": "", "type": "string"}], + "stateMutability": "view", + "type": "function", + }, + { + "inputs": [{"internalType": "string", "name": "new_text", "type": "string"}], + "name": "setText", + "outputs": [{"internalType": "string", "name": "", "type": "string"}], + "stateMutability": "nonpayable", + "type": "function", + }, +] +NO_RECEIVE_FUNCTION_CONTRACT_DATA = { + "bytecode": NO_RECEIVE_FUNCTION_CONTRACT_BYTECODE, + "bytecode_runtime": NO_RECEIVE_FUNCTION_CONTRACT_RUNTIME, + "abi": NO_RECEIVE_FUNCTION_CONTRACT_ABI, +} diff --git a/web3/_utils/contract_sources/contract_data/reflector_contracts.py b/web3/_utils/contract_sources/contract_data/reflector_contracts.py new file mode 100644 index 0000000000..bff6f93597 --- /dev/null +++ b/web3/_utils/contract_sources/contract_data/reflector_contracts.py @@ -0,0 +1,29 @@ +""" +Generated by `compile_contracts.py` script. +Compiled with Solidity v0.8.17. +""" + +# source: web3/_utils/contract_sources/ReflectorContracts.sol:AddressReflectorContract +ADDRESS_REFLECTOR_CONTRACT_BYTECODE = "0x608060405234801561001057600080fd5b50610430806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80630b816c161461003b578063c04d11fc1461006b575b600080fd5b61005560048036038101906100509190610121565b61009b565b604051610062919061015d565b60405180910390f35b610085600480360381019061008091906102d1565b6100a5565b60405161009291906103d8565b60405180910390f35b6000819050919050565b6060819050919050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100ee826100c3565b9050919050565b6100fe816100e3565b811461010957600080fd5b50565b60008135905061011b816100f5565b92915050565b600060208284031215610137576101366100b9565b5b60006101458482850161010c565b91505092915050565b610157816100e3565b82525050565b6000602082019050610172600083018461014e565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6101c68261017d565b810181811067ffffffffffffffff821117156101e5576101e461018e565b5b80604052505050565b60006101f86100af565b905061020482826101bd565b919050565b600067ffffffffffffffff8211156102245761022361018e565b5b602082029050602081019050919050565b600080fd5b600061024d61024884610209565b6101ee565b905080838252602082019050602084028301858111156102705761026f610235565b5b835b818110156102995780610285888261010c565b845260208401935050602081019050610272565b5050509392505050565b600082601f8301126102b8576102b7610178565b5b81356102c884826020860161023a565b91505092915050565b6000602082840312156102e7576102e66100b9565b5b600082013567ffffffffffffffff811115610305576103046100be565b5b610311848285016102a3565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b61034f816100e3565b82525050565b60006103618383610346565b60208301905092915050565b6000602082019050919050565b60006103858261031a565b61038f8185610325565b935061039a83610336565b8060005b838110156103cb5781516103b28882610355565b97506103bd8361036d565b92505060018101905061039e565b5085935050505092915050565b600060208201905081810360008301526103f2818461037a565b90509291505056fea2646970667358221220056b3254d1a97ff397098f071b13bec0adf8cba16d3a86a3750a624ad36dd82d64736f6c63430008110033" # noqa: E501 +ADDRESS_REFLECTOR_CONTRACT_RUNTIME = "0x608060405234801561001057600080fd5b50600436106100365760003560e01c80630b816c161461003b578063c04d11fc1461006b575b600080fd5b61005560048036038101906100509190610121565b61009b565b604051610062919061015d565b60405180910390f35b610085600480360381019061008091906102d1565b6100a5565b60405161009291906103d8565b60405180910390f35b6000819050919050565b6060819050919050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100ee826100c3565b9050919050565b6100fe816100e3565b811461010957600080fd5b50565b60008135905061011b816100f5565b92915050565b600060208284031215610137576101366100b9565b5b60006101458482850161010c565b91505092915050565b610157816100e3565b82525050565b6000602082019050610172600083018461014e565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6101c68261017d565b810181811067ffffffffffffffff821117156101e5576101e461018e565b5b80604052505050565b60006101f86100af565b905061020482826101bd565b919050565b600067ffffffffffffffff8211156102245761022361018e565b5b602082029050602081019050919050565b600080fd5b600061024d61024884610209565b6101ee565b905080838252602082019050602084028301858111156102705761026f610235565b5b835b818110156102995780610285888261010c565b845260208401935050602081019050610272565b5050509392505050565b600082601f8301126102b8576102b7610178565b5b81356102c884826020860161023a565b91505092915050565b6000602082840312156102e7576102e66100b9565b5b600082013567ffffffffffffffff811115610305576103046100be565b5b610311848285016102a3565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b61034f816100e3565b82525050565b60006103618383610346565b60208301905092915050565b6000602082019050919050565b60006103858261031a565b61038f8185610325565b935061039a83610336565b8060005b838110156103cb5781516103b28882610355565b97506103bd8361036d565b92505060018101905061039e565b5085935050505092915050565b600060208201905081810360008301526103f2818461037a565b90509291505056fea2646970667358221220056b3254d1a97ff397098f071b13bec0adf8cba16d3a86a3750a624ad36dd82d64736f6c63430008110033" # noqa: E501 +ADDRESS_REFLECTOR_CONTRACT_ABI = [ + { + "inputs": [{"internalType": "address", "name": "arg", "type": "address"}], + "name": "reflect", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "pure", + "type": "function", + }, + { + "inputs": [{"internalType": "address[]", "name": "arg", "type": "address[]"}], + "name": "reflect", + "outputs": [{"internalType": "address[]", "name": "", "type": "address[]"}], + "stateMutability": "pure", + "type": "function", + }, +] +ADDRESS_REFLECTOR_CONTRACT_DATA = { + "bytecode": ADDRESS_REFLECTOR_CONTRACT_BYTECODE, + "bytecode_runtime": ADDRESS_REFLECTOR_CONTRACT_RUNTIME, + "abi": ADDRESS_REFLECTOR_CONTRACT_ABI, +} diff --git a/web3/_utils/contract_sources/contract_data/revert_contract.py b/web3/_utils/contract_sources/contract_data/revert_contract.py new file mode 100644 index 0000000000..ff750a1790 --- /dev/null +++ b/web3/_utils/contract_sources/contract_data/revert_contract.py @@ -0,0 +1,36 @@ +""" +Generated by `compile_contracts.py` script. +Compiled with Solidity v0.8.17. +""" + +# source: web3/_utils/contract_sources/RevertContract.sol:RevertContract +REVERT_CONTRACT_BYTECODE = "0x608060405234801561001057600080fd5b506101aa806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063185c38a414610046578063c06a97cb14610050578063d67e4b841461005a575b600080fd5b61004e610078565b005b6100586100b3565b005b6100626100b8565b60405161006f91906100dc565b60405180910390f35b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100aa90610154565b60405180910390fd5b600080fd5b60006001905090565b60008115159050919050565b6100d6816100c1565b82525050565b60006020820190506100f160008301846100cd565b92915050565b600082825260208201905092915050565b7f46756e6374696f6e20686173206265656e2072657665727465642e0000000000600082015250565b600061013e601b836100f7565b915061014982610108565b602082019050919050565b6000602082019050818103600083015261016d81610131565b905091905056fea26469706673582212201d78337cb1f5b9893fb5f0475796452dd157799030c248939f27cd3b98ec46ce64736f6c63430008110033" # noqa: E501 +REVERT_CONTRACT_RUNTIME = "0x608060405234801561001057600080fd5b50600436106100415760003560e01c8063185c38a414610046578063c06a97cb14610050578063d67e4b841461005a575b600080fd5b61004e610078565b005b6100586100b3565b005b6100626100b8565b60405161006f91906100dc565b60405180910390f35b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100aa90610154565b60405180910390fd5b600080fd5b60006001905090565b60008115159050919050565b6100d6816100c1565b82525050565b60006020820190506100f160008301846100cd565b92915050565b600082825260208201905092915050565b7f46756e6374696f6e20686173206265656e2072657665727465642e0000000000600082015250565b600061013e601b836100f7565b915061014982610108565b602082019050919050565b6000602082019050818103600083015261016d81610131565b905091905056fea26469706673582212201d78337cb1f5b9893fb5f0475796452dd157799030c248939f27cd3b98ec46ce64736f6c63430008110033" # noqa: E501 +REVERT_CONTRACT_ABI = [ + { + "inputs": [], + "name": "normalFunction", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "pure", + "type": "function", + }, + { + "inputs": [], + "name": "revertWithMessage", + "outputs": [], + "stateMutability": "pure", + "type": "function", + }, + { + "inputs": [], + "name": "revertWithoutMessage", + "outputs": [], + "stateMutability": "pure", + "type": "function", + }, +] +REVERT_CONTRACT_DATA = { + "bytecode": REVERT_CONTRACT_BYTECODE, + "bytecode_runtime": REVERT_CONTRACT_RUNTIME, + "abi": REVERT_CONTRACT_ABI, +} diff --git a/web3/_utils/contract_sources/contract_data/simple_resolver.py b/web3/_utils/contract_sources/contract_data/simple_resolver.py new file mode 100644 index 0000000000..3b59cc55ce --- /dev/null +++ b/web3/_utils/contract_sources/contract_data/simple_resolver.py @@ -0,0 +1,29 @@ +""" +Generated by `compile_contracts.py` script. +Compiled with Solidity v0.8.17. +""" + +# source: web3/_utils/contract_sources/SimpleResolver.sol:SimpleResolver +SIMPLE_RESOLVER_BYTECODE = "0x608060405234801561001057600080fd5b5061028c806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806301ffc9a71461003b5780633b3b57de1461006b575b600080fd5b61005560048036038101906100509190610134565b61009b565b604051610062919061017c565b60405180910390f35b610085600480360381019061008091906101cd565b6100cd565b604051610092919061023b565b60405180910390f35b6000633b3b57de60e01b827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6000309050919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610111816100dc565b811461011c57600080fd5b50565b60008135905061012e81610108565b92915050565b60006020828403121561014a576101496100d7565b5b60006101588482850161011f565b91505092915050565b60008115159050919050565b61017681610161565b82525050565b6000602082019050610191600083018461016d565b92915050565b6000819050919050565b6101aa81610197565b81146101b557600080fd5b50565b6000813590506101c7816101a1565b92915050565b6000602082840312156101e3576101e26100d7565b5b60006101f1848285016101b8565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610225826101fa565b9050919050565b6102358161021a565b82525050565b6000602082019050610250600083018461022c565b9291505056fea2646970667358221220ee3cec68b65444c456e61bd90c00df515cf26610d83bf930b4daa7444a5a033964736f6c63430008110033" # noqa: E501 +SIMPLE_RESOLVER_RUNTIME = "0x608060405234801561001057600080fd5b50600436106100365760003560e01c806301ffc9a71461003b5780633b3b57de1461006b575b600080fd5b61005560048036038101906100509190610134565b61009b565b604051610062919061017c565b60405180910390f35b610085600480360381019061008091906101cd565b6100cd565b604051610092919061023b565b60405180910390f35b6000633b3b57de60e01b827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6000309050919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610111816100dc565b811461011c57600080fd5b50565b60008135905061012e81610108565b92915050565b60006020828403121561014a576101496100d7565b5b60006101588482850161011f565b91505092915050565b60008115159050919050565b61017681610161565b82525050565b6000602082019050610191600083018461016d565b92915050565b6000819050919050565b6101aa81610197565b81146101b557600080fd5b50565b6000813590506101c7816101a1565b92915050565b6000602082840312156101e3576101e26100d7565b5b60006101f1848285016101b8565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610225826101fa565b9050919050565b6102358161021a565b82525050565b6000602082019050610250600083018461022c565b9291505056fea2646970667358221220ee3cec68b65444c456e61bd90c00df515cf26610d83bf930b4daa7444a5a033964736f6c63430008110033" # noqa: E501 +SIMPLE_RESOLVER_ABI = [ + { + "inputs": [{"internalType": "bytes32", "name": "nodeID", "type": "bytes32"}], + "name": "addr", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [{"internalType": "bytes4", "name": "interfaceID", "type": "bytes4"}], + "name": "supportsInterface", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "nonpayable", + "type": "function", + }, +] +SIMPLE_RESOLVER_DATA = { + "bytecode": SIMPLE_RESOLVER_BYTECODE, + "bytecode_runtime": SIMPLE_RESOLVER_RUNTIME, + "abi": SIMPLE_RESOLVER_ABI, +} diff --git a/web3/_utils/contract_sources/contract_data/string_contract.py b/web3/_utils/contract_sources/contract_data/string_contract.py new file mode 100644 index 0000000000..fe6a112a87 --- /dev/null +++ b/web3/_utils/contract_sources/contract_data/string_contract.py @@ -0,0 +1,42 @@ +""" +Generated by `compile_contracts.py` script. +Compiled with Solidity v0.8.17. +""" + +# source: web3/_utils/contract_sources/StringContract.sol:StringContract +STRING_CONTRACT_BYTECODE = "0x60806040523480156200001157600080fd5b5060405162000d1a38038062000d1a8339818101604052810190620000379190620001e3565b80600090816200004891906200047f565b505062000566565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b620000b9826200006e565b810181811067ffffffffffffffff82111715620000db57620000da6200007f565b5b80604052505050565b6000620000f062000050565b9050620000fe8282620000ae565b919050565b600067ffffffffffffffff8211156200012157620001206200007f565b5b6200012c826200006e565b9050602081019050919050565b60005b83811015620001595780820151818401526020810190506200013c565b60008484015250505050565b60006200017c620001768462000103565b620000e4565b9050828152602081018484840111156200019b576200019a62000069565b5b620001a884828562000139565b509392505050565b600082601f830112620001c857620001c762000064565b5b8151620001da84826020860162000165565b91505092915050565b600060208284031215620001fc57620001fb6200005a565b5b600082015167ffffffffffffffff8111156200021d576200021c6200005f565b5b6200022b84828501620001b0565b91505092915050565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806200028757607f821691505b6020821081036200029d576200029c6200023f565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b600060088302620003077fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82620002c8565b620003138683620002c8565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b6000620003606200035a62000354846200032b565b62000335565b6200032b565b9050919050565b6000819050919050565b6200037c836200033f565b620003946200038b8262000367565b848454620002d5565b825550505050565b600090565b620003ab6200039c565b620003b881848462000371565b505050565b5b81811015620003e057620003d4600082620003a1565b600181019050620003be565b5050565b601f8211156200042f57620003f981620002a3565b6200040484620002b8565b8101602085101562000414578190505b6200042c6200042385620002b8565b830182620003bd565b50505b505050565b600082821c905092915050565b6000620004546000198460080262000434565b1980831691505092915050565b60006200046f838362000441565b9150826002028217905092915050565b6200048a8262000234565b67ffffffffffffffff811115620004a657620004a56200007f565b5b620004b282546200026e565b620004bf828285620003e4565b600060209050601f831160018114620004f75760008415620004e2578287015190505b620004ee858262000461565b8655506200055e565b601f1984166200050786620002a3565b60005b8281101562000531578489015182556001820191506020850194506020810190506200050a565b868310156200055157848901516200054d601f89168262000441565b8355505b6001600288020188555050505b505050505050565b6107a480620005766000396000f3fe6080604052600436106100385760003560e01c8063209652551461009d5780633fa4f245146100bb57806393a09352146100e657610039565b5b34801561004557600080fd5b50600036606082828080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509050915050805190602001f35b6100a561010f565b6040516100b291906102d2565b60405180910390f35b3480156100c757600080fd5b506100d06101a1565b6040516100dd91906102d2565b60405180910390f35b3480156100f257600080fd5b5061010d6004803603810190610108919061043d565b61022f565b005b60606000805461011e906104b5565b80601f016020809104026020016040519081016040528092919081815260200182805461014a906104b5565b80156101975780601f1061016c57610100808354040283529160200191610197565b820191906000526020600020905b81548152906001019060200180831161017a57829003601f168201915b5050505050905090565b600080546101ae906104b5565b80601f01602080910402602001604051908101604052809291908181526020018280546101da906104b5565b80156102275780601f106101fc57610100808354040283529160200191610227565b820191906000526020600020905b81548152906001019060200180831161020a57829003601f168201915b505050505081565b806000908161023e919061069c565b5050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561027c578082015181840152602081019050610261565b60008484015250505050565b6000601f19601f8301169050919050565b60006102a482610242565b6102ae818561024d565b93506102be81856020860161025e565b6102c781610288565b840191505092915050565b600060208201905081810360008301526102ec8184610299565b905092915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61034a82610288565b810181811067ffffffffffffffff8211171561036957610368610312565b5b80604052505050565b600061037c6102f4565b90506103888282610341565b919050565b600067ffffffffffffffff8211156103a8576103a7610312565b5b6103b182610288565b9050602081019050919050565b82818337600083830152505050565b60006103e06103db8461038d565b610372565b9050828152602081018484840111156103fc576103fb61030d565b5b6104078482856103be565b509392505050565b600082601f83011261042457610423610308565b5b81356104348482602086016103cd565b91505092915050565b600060208284031215610453576104526102fe565b5b600082013567ffffffffffffffff81111561047157610470610303565b5b61047d8482850161040f565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806104cd57607f821691505b6020821081036104e0576104df610486565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026105487fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8261050b565b610552868361050b565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b600061059961059461058f8461056a565b610574565b61056a565b9050919050565b6000819050919050565b6105b38361057e565b6105c76105bf826105a0565b848454610518565b825550505050565b600090565b6105dc6105cf565b6105e78184846105aa565b505050565b5b8181101561060b576106006000826105d4565b6001810190506105ed565b5050565b601f82111561065057610621816104e6565b61062a846104fb565b81016020851015610639578190505b61064d610645856104fb565b8301826105ec565b50505b505050565b600082821c905092915050565b600061067360001984600802610655565b1980831691505092915050565b600061068c8383610662565b9150826002028217905092915050565b6106a582610242565b67ffffffffffffffff8111156106be576106bd610312565b5b6106c882546104b5565b6106d382828561060f565b600060209050601f83116001811461070657600084156106f4578287015190505b6106fe8582610680565b865550610766565b601f198416610714866104e6565b60005b8281101561073c57848901518255600182019150602085019450602081019050610717565b868310156107595784890151610755601f891682610662565b8355505b6001600288020188555050505b50505050505056fea2646970667358221220aafbcf0e5a2ec94028472c741edd4684c7624a15507c1b3aadf20145fdc73db464736f6c63430008110033" # noqa: E501 +STRING_CONTRACT_RUNTIME = "0x6080604052600436106100385760003560e01c8063209652551461009d5780633fa4f245146100bb57806393a09352146100e657610039565b5b34801561004557600080fd5b50600036606082828080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509050915050805190602001f35b6100a561010f565b6040516100b291906102d2565b60405180910390f35b3480156100c757600080fd5b506100d06101a1565b6040516100dd91906102d2565b60405180910390f35b3480156100f257600080fd5b5061010d6004803603810190610108919061043d565b61022f565b005b60606000805461011e906104b5565b80601f016020809104026020016040519081016040528092919081815260200182805461014a906104b5565b80156101975780601f1061016c57610100808354040283529160200191610197565b820191906000526020600020905b81548152906001019060200180831161017a57829003601f168201915b5050505050905090565b600080546101ae906104b5565b80601f01602080910402602001604051908101604052809291908181526020018280546101da906104b5565b80156102275780601f106101fc57610100808354040283529160200191610227565b820191906000526020600020905b81548152906001019060200180831161020a57829003601f168201915b505050505081565b806000908161023e919061069c565b5050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561027c578082015181840152602081019050610261565b60008484015250505050565b6000601f19601f8301169050919050565b60006102a482610242565b6102ae818561024d565b93506102be81856020860161025e565b6102c781610288565b840191505092915050565b600060208201905081810360008301526102ec8184610299565b905092915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61034a82610288565b810181811067ffffffffffffffff8211171561036957610368610312565b5b80604052505050565b600061037c6102f4565b90506103888282610341565b919050565b600067ffffffffffffffff8211156103a8576103a7610312565b5b6103b182610288565b9050602081019050919050565b82818337600083830152505050565b60006103e06103db8461038d565b610372565b9050828152602081018484840111156103fc576103fb61030d565b5b6104078482856103be565b509392505050565b600082601f83011261042457610423610308565b5b81356104348482602086016103cd565b91505092915050565b600060208284031215610453576104526102fe565b5b600082013567ffffffffffffffff81111561047157610470610303565b5b61047d8482850161040f565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806104cd57607f821691505b6020821081036104e0576104df610486565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026105487fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8261050b565b610552868361050b565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b600061059961059461058f8461056a565b610574565b61056a565b9050919050565b6000819050919050565b6105b38361057e565b6105c76105bf826105a0565b848454610518565b825550505050565b600090565b6105dc6105cf565b6105e78184846105aa565b505050565b5b8181101561060b576106006000826105d4565b6001810190506105ed565b5050565b601f82111561065057610621816104e6565b61062a846104fb565b81016020851015610639578190505b61064d610645856104fb565b8301826105ec565b50505b505050565b600082821c905092915050565b600061067360001984600802610655565b1980831691505092915050565b600061068c8383610662565b9150826002028217905092915050565b6106a582610242565b67ffffffffffffffff8111156106be576106bd610312565b5b6106c882546104b5565b6106d382828561060f565b600060209050601f83116001811461070657600084156106f4578287015190505b6106fe8582610680565b865550610766565b601f198416610714866104e6565b60005b8281101561073c57848901518255600182019150602085019450602081019050610717565b868310156107595784890151610755601f891682610662565b8355505b6001600288020188555050505b50505050505056fea2646970667358221220aafbcf0e5a2ec94028472c741edd4684c7624a15507c1b3aadf20145fdc73db464736f6c63430008110033" # noqa: E501 +STRING_CONTRACT_ABI = [ + { + "inputs": [{"internalType": "string", "name": "_value", "type": "string"}], + "stateMutability": "nonpayable", + "type": "constructor", + }, + {"stateMutability": "nonpayable", "type": "fallback"}, + { + "inputs": [], + "name": "getValue", + "outputs": [{"internalType": "string", "name": "", "type": "string"}], + "stateMutability": "payable", + "type": "function", + }, + { + "inputs": [{"internalType": "string", "name": "_value", "type": "string"}], + "name": "setValue", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [], + "name": "value", + "outputs": [{"internalType": "string", "name": "", "type": "string"}], + "stateMutability": "view", + "type": "function", + }, +] +STRING_CONTRACT_DATA = { + "bytecode": STRING_CONTRACT_BYTECODE, + "bytecode_runtime": STRING_CONTRACT_RUNTIME, + "abi": STRING_CONTRACT_ABI, +} diff --git a/web3/_utils/contract_sources/contract_data/tuple_contracts.py b/web3/_utils/contract_sources/contract_data/tuple_contracts.py new file mode 100644 index 0000000000..4c2d99ac39 --- /dev/null +++ b/web3/_utils/contract_sources/contract_data/tuple_contracts.py @@ -0,0 +1,153 @@ +""" +Generated by `compile_contracts.py` script. +Compiled with Solidity v0.8.17. +""" + +# source: web3/_utils/contract_sources/TupleContracts.sol:TupleContract +TUPLE_CONTRACT_BYTECODE = "0x608060405234801561001057600080fd5b50610abb806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80638e1ae3c714610030575b600080fd5b61004a6004803603810190610045919061067b565b610060565b6040516100579190610a63565b60405180910390f35b610068610070565b819050919050565b60405180606001604052806000815260200160608152602001606081525090565b6000604051905090565b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6100f3826100aa565b810181811067ffffffffffffffff82111715610112576101116100bb565b5b80604052505050565b6000610125610091565b905061013182826100ea565b919050565b600080fd5b6000819050919050565b61014e8161013b565b811461015957600080fd5b50565b60008135905061016b81610145565b92915050565b600080fd5b600067ffffffffffffffff821115610191576101906100bb565b5b602082029050602081019050919050565b600080fd5b60006101ba6101b584610176565b61011b565b905080838252602082019050602084028301858111156101dd576101dc6101a2565b5b835b8181101561020657806101f2888261015c565b8452602084019350506020810190506101df565b5050509392505050565b600082601f83011261022557610224610171565b5b81356102358482602086016101a7565b91505092915050565b600067ffffffffffffffff821115610259576102586100bb565b5b602082029050602081019050919050565b6000819050919050565b61027d8161026a565b811461028857600080fd5b50565b60008135905061029a81610274565b92915050565b600067ffffffffffffffff8211156102bb576102ba6100bb565b5b602082029050919050565b60008115159050919050565b6102db816102c6565b81146102e657600080fd5b50565b6000813590506102f8816102d2565b92915050565b600061031161030c846102a0565b61011b565b9050806020840283018581111561032b5761032a6101a2565b5b835b81811015610354578061034088826102e9565b84526020840193505060208101905061032d565b5050509392505050565b600082601f83011261037357610372610171565b5b60026103808482856102fe565b91505092915050565b600067ffffffffffffffff8211156103a4576103a36100bb565b5b602082029050602081019050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006103e0826103b5565b9050919050565b6103f0816103d5565b81146103fb57600080fd5b50565b60008135905061040d816103e7565b92915050565b600061042661042184610389565b61011b565b90508083825260208201905060208402830185811115610449576104486101a2565b5b835b81811015610472578061045e88826103fe565b84526020840193505060208101905061044b565b5050509392505050565b600082601f83011261049157610490610171565b5b81356104a1848260208601610413565b91505092915050565b6000608082840312156104c0576104bf6100a5565b5b6104ca606061011b565b905060006104da8482850161028b565b60008301525060206104ee8482850161035e565b602083015250606082013567ffffffffffffffff81111561051257610511610136565b5b61051e8482850161047c565b60408301525092915050565b600061053d6105388461023e565b61011b565b905080838252602082019050602084028301858111156105605761055f6101a2565b5b835b818110156105a757803567ffffffffffffffff81111561058557610584610171565b5b80860161059289826104aa565b85526020850194505050602081019050610562565b5050509392505050565b600082601f8301126105c6576105c5610171565b5b81356105d684826020860161052a565b91505092915050565b6000606082840312156105f5576105f46100a5565b5b6105ff606061011b565b9050600061060f8482850161015c565b600083015250602082013567ffffffffffffffff81111561063357610632610136565b5b61063f84828501610210565b602083015250604082013567ffffffffffffffff81111561066357610662610136565b5b61066f848285016105b1565b60408301525092915050565b6000602082840312156106915761069061009b565b5b600082013567ffffffffffffffff8111156106af576106ae6100a0565b5b6106bb848285016105df565b91505092915050565b6106cd8161013b565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b600061070b83836106c4565b60208301905092915050565b6000602082019050919050565b600061072f826106d3565b61073981856106de565b9350610744836106ef565b8060005b8381101561077557815161075c88826106ff565b975061076783610717565b925050600181019050610748565b5085935050505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6107b78161026a565b82525050565b600060029050919050565b600081905092915050565b6000819050919050565b6107e6816102c6565b82525050565b60006107f883836107dd565b60208301905092915050565b6000602082019050919050565b61081a816107bd565b61082481846107c8565b925061082f826107d3565b8060005b8381101561086057815161084787826107ec565b965061085283610804565b925050600181019050610833565b505050505050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b61089d816103d5565b82525050565b60006108af8383610894565b60208301905092915050565b6000602082019050919050565b60006108d382610868565b6108dd8185610873565b93506108e883610884565b8060005b8381101561091957815161090088826108a3565b975061090b836108bb565b9250506001810190506108ec565b5085935050505092915050565b600060808301600083015161093e60008601826107ae565b5060208301516109516020860182610811565b506040830151848203606086015261096982826108c8565b9150508091505092915050565b60006109828383610926565b905092915050565b6000602082019050919050565b60006109a282610782565b6109ac818561078d565b9350836020820285016109be8561079e565b8060005b858110156109fa57848403895281516109db8582610976565b94506109e68361098a565b925060208a019950506001810190506109c2565b50829750879550505050505092915050565b6000606083016000830151610a2460008601826106c4565b5060208301518482036020860152610a3c8282610724565b91505060408301518482036040860152610a568282610997565b9150508091505092915050565b60006020820190508181036000830152610a7d8184610a0c565b90509291505056fea26469706673582212207fc0320c27056d217ded8d2ecf14abee55713bc9098553460cc0d30f6cd93ccd64736f6c63430008110033" # noqa: E501 +TUPLE_CONTRACT_RUNTIME = "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c80638e1ae3c714610030575b600080fd5b61004a6004803603810190610045919061067b565b610060565b6040516100579190610a63565b60405180910390f35b610068610070565b819050919050565b60405180606001604052806000815260200160608152602001606081525090565b6000604051905090565b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6100f3826100aa565b810181811067ffffffffffffffff82111715610112576101116100bb565b5b80604052505050565b6000610125610091565b905061013182826100ea565b919050565b600080fd5b6000819050919050565b61014e8161013b565b811461015957600080fd5b50565b60008135905061016b81610145565b92915050565b600080fd5b600067ffffffffffffffff821115610191576101906100bb565b5b602082029050602081019050919050565b600080fd5b60006101ba6101b584610176565b61011b565b905080838252602082019050602084028301858111156101dd576101dc6101a2565b5b835b8181101561020657806101f2888261015c565b8452602084019350506020810190506101df565b5050509392505050565b600082601f83011261022557610224610171565b5b81356102358482602086016101a7565b91505092915050565b600067ffffffffffffffff821115610259576102586100bb565b5b602082029050602081019050919050565b6000819050919050565b61027d8161026a565b811461028857600080fd5b50565b60008135905061029a81610274565b92915050565b600067ffffffffffffffff8211156102bb576102ba6100bb565b5b602082029050919050565b60008115159050919050565b6102db816102c6565b81146102e657600080fd5b50565b6000813590506102f8816102d2565b92915050565b600061031161030c846102a0565b61011b565b9050806020840283018581111561032b5761032a6101a2565b5b835b81811015610354578061034088826102e9565b84526020840193505060208101905061032d565b5050509392505050565b600082601f83011261037357610372610171565b5b60026103808482856102fe565b91505092915050565b600067ffffffffffffffff8211156103a4576103a36100bb565b5b602082029050602081019050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006103e0826103b5565b9050919050565b6103f0816103d5565b81146103fb57600080fd5b50565b60008135905061040d816103e7565b92915050565b600061042661042184610389565b61011b565b90508083825260208201905060208402830185811115610449576104486101a2565b5b835b81811015610472578061045e88826103fe565b84526020840193505060208101905061044b565b5050509392505050565b600082601f83011261049157610490610171565b5b81356104a1848260208601610413565b91505092915050565b6000608082840312156104c0576104bf6100a5565b5b6104ca606061011b565b905060006104da8482850161028b565b60008301525060206104ee8482850161035e565b602083015250606082013567ffffffffffffffff81111561051257610511610136565b5b61051e8482850161047c565b60408301525092915050565b600061053d6105388461023e565b61011b565b905080838252602082019050602084028301858111156105605761055f6101a2565b5b835b818110156105a757803567ffffffffffffffff81111561058557610584610171565b5b80860161059289826104aa565b85526020850194505050602081019050610562565b5050509392505050565b600082601f8301126105c6576105c5610171565b5b81356105d684826020860161052a565b91505092915050565b6000606082840312156105f5576105f46100a5565b5b6105ff606061011b565b9050600061060f8482850161015c565b600083015250602082013567ffffffffffffffff81111561063357610632610136565b5b61063f84828501610210565b602083015250604082013567ffffffffffffffff81111561066357610662610136565b5b61066f848285016105b1565b60408301525092915050565b6000602082840312156106915761069061009b565b5b600082013567ffffffffffffffff8111156106af576106ae6100a0565b5b6106bb848285016105df565b91505092915050565b6106cd8161013b565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b600061070b83836106c4565b60208301905092915050565b6000602082019050919050565b600061072f826106d3565b61073981856106de565b9350610744836106ef565b8060005b8381101561077557815161075c88826106ff565b975061076783610717565b925050600181019050610748565b5085935050505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6107b78161026a565b82525050565b600060029050919050565b600081905092915050565b6000819050919050565b6107e6816102c6565b82525050565b60006107f883836107dd565b60208301905092915050565b6000602082019050919050565b61081a816107bd565b61082481846107c8565b925061082f826107d3565b8060005b8381101561086057815161084787826107ec565b965061085283610804565b925050600181019050610833565b505050505050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b61089d816103d5565b82525050565b60006108af8383610894565b60208301905092915050565b6000602082019050919050565b60006108d382610868565b6108dd8185610873565b93506108e883610884565b8060005b8381101561091957815161090088826108a3565b975061090b836108bb565b9250506001810190506108ec565b5085935050505092915050565b600060808301600083015161093e60008601826107ae565b5060208301516109516020860182610811565b506040830151848203606086015261096982826108c8565b9150508091505092915050565b60006109828383610926565b905092915050565b6000602082019050919050565b60006109a282610782565b6109ac818561078d565b9350836020820285016109be8561079e565b8060005b858110156109fa57848403895281516109db8582610976565b94506109e68361098a565b925060208a019950506001810190506109c2565b50829750879550505050505092915050565b6000606083016000830151610a2460008601826106c4565b5060208301518482036020860152610a3c8282610724565b91505060408301518482036040860152610a568282610997565b9150508091505092915050565b60006020820190508181036000830152610a7d8184610a0c565b90509291505056fea26469706673582212207fc0320c27056d217ded8d2ecf14abee55713bc9098553460cc0d30f6cd93ccd64736f6c63430008110033" # noqa: E501 +TUPLE_CONTRACT_ABI = [ + { + "inputs": [ + { + "components": [ + {"internalType": "uint256", "name": "a", "type": "uint256"}, + {"internalType": "uint256[]", "name": "b", "type": "uint256[]"}, + { + "components": [ + {"internalType": "int256", "name": "x", "type": "int256"}, + {"internalType": "bool[2]", "name": "y", "type": "bool[2]"}, + { + "internalType": "address[]", + "name": "z", + "type": "address[]", + }, + ], + "internalType": "struct TupleContract.T[]", + "name": "c", + "type": "tuple[]", + }, + ], + "internalType": "struct TupleContract.S", + "name": "s", + "type": "tuple", + } + ], + "name": "method", + "outputs": [ + { + "components": [ + {"internalType": "uint256", "name": "a", "type": "uint256"}, + {"internalType": "uint256[]", "name": "b", "type": "uint256[]"}, + { + "components": [ + {"internalType": "int256", "name": "x", "type": "int256"}, + {"internalType": "bool[2]", "name": "y", "type": "bool[2]"}, + { + "internalType": "address[]", + "name": "z", + "type": "address[]", + }, + ], + "internalType": "struct TupleContract.T[]", + "name": "c", + "type": "tuple[]", + }, + ], + "internalType": "struct TupleContract.S", + "name": "", + "type": "tuple", + } + ], + "stateMutability": "pure", + "type": "function", + } +] +TUPLE_CONTRACT_DATA = { + "bytecode": TUPLE_CONTRACT_BYTECODE, + "bytecode_runtime": TUPLE_CONTRACT_RUNTIME, + "abi": TUPLE_CONTRACT_ABI, +} + + +# source: web3/_utils/contract_sources/TupleContracts.sol:NestedTupleContract +NESTED_TUPLE_CONTRACT_BYTECODE = "0x608060405234801561001057600080fd5b506106b5806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80632655aef114610030575b600080fd5b61004a60048036038101906100459190610411565b610060565b604051610057919061065d565b60405180910390f35b610068610070565b819050919050565b6040518060200160405280606081525090565b6000604051905090565b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6100e58261009c565b810181811067ffffffffffffffff82111715610104576101036100ad565b5b80604052505050565b6000610117610083565b905061012382826100dc565b919050565b600080fd5b600080fd5b600067ffffffffffffffff82111561014d5761014c6100ad565b5b602082029050602081019050919050565b600080fd5b600067ffffffffffffffff82111561017e5761017d6100ad565b5b602082029050602081019050919050565b6000819050919050565b6101a28161018f565b81146101ad57600080fd5b50565b6000813590506101bf81610199565b92915050565b6000604082840312156101db576101da610097565b5b6101e5604061010d565b905060006101f5848285016101b0565b6000830152506020610209848285016101b0565b60208301525092915050565b600061022861022384610163565b61010d565b9050808382526020820190506040840283018581111561024b5761024a61015e565b5b835b81811015610274578061026088826101c5565b84526020840193505060408101905061024d565b5050509392505050565b600082601f8301126102935761029261012d565b5b81356102a3848260208601610215565b91505092915050565b6000602082840312156102c2576102c1610097565b5b6102cc602061010d565b9050600082013567ffffffffffffffff8111156102ec576102eb610128565b5b6102f88482850161027e565b60008301525092915050565b600061031761031284610132565b61010d565b9050808382526020820190506020840283018581111561033a5761033961015e565b5b835b8181101561038157803567ffffffffffffffff81111561035f5761035e61012d565b5b80860161036c89826102ac565b8552602085019450505060208101905061033c565b5050509392505050565b600082601f8301126103a05761039f61012d565b5b81356103b0848260208601610304565b91505092915050565b6000602082840312156103cf576103ce610097565b5b6103d9602061010d565b9050600082013567ffffffffffffffff8111156103f9576103f8610128565b5b6104058482850161038b565b60008301525092915050565b6000602082840312156104275761042661008d565b5b600082013567ffffffffffffffff81111561044557610444610092565b5b610451848285016103b9565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6104bb8161018f565b82525050565b6040820160008201516104d760008501826104b2565b5060208201516104ea60208501826104b2565b50505050565b60006104fc83836104c1565b60408301905092915050565b6000602082019050919050565b600061052082610486565b61052a8185610491565b9350610535836104a2565b8060005b8381101561056657815161054d88826104f0565b975061055883610508565b925050600181019050610539565b5085935050505092915050565b600060208301600083015184820360008601526105908282610515565b9150508091505092915050565b60006105a98383610573565b905092915050565b6000602082019050919050565b60006105c98261045a565b6105d38185610465565b9350836020820285016105e585610476565b8060005b858110156106215784840389528151610602858261059d565b945061060d836105b1565b925060208a019950506001810190506105e9565b50829750879550505050505092915050565b6000602083016000830151848203600086015261065082826105be565b9150508091505092915050565b600060208201905081810360008301526106778184610633565b90509291505056fea26469706673582212208ea70f899bda98545e145e7a333a0ae15bd8ae26961c9b8ec53f480310e88a7764736f6c63430008110033" # noqa: E501 +NESTED_TUPLE_CONTRACT_RUNTIME = "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c80632655aef114610030575b600080fd5b61004a60048036038101906100459190610411565b610060565b604051610057919061065d565b60405180910390f35b610068610070565b819050919050565b6040518060200160405280606081525090565b6000604051905090565b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6100e58261009c565b810181811067ffffffffffffffff82111715610104576101036100ad565b5b80604052505050565b6000610117610083565b905061012382826100dc565b919050565b600080fd5b600080fd5b600067ffffffffffffffff82111561014d5761014c6100ad565b5b602082029050602081019050919050565b600080fd5b600067ffffffffffffffff82111561017e5761017d6100ad565b5b602082029050602081019050919050565b6000819050919050565b6101a28161018f565b81146101ad57600080fd5b50565b6000813590506101bf81610199565b92915050565b6000604082840312156101db576101da610097565b5b6101e5604061010d565b905060006101f5848285016101b0565b6000830152506020610209848285016101b0565b60208301525092915050565b600061022861022384610163565b61010d565b9050808382526020820190506040840283018581111561024b5761024a61015e565b5b835b81811015610274578061026088826101c5565b84526020840193505060408101905061024d565b5050509392505050565b600082601f8301126102935761029261012d565b5b81356102a3848260208601610215565b91505092915050565b6000602082840312156102c2576102c1610097565b5b6102cc602061010d565b9050600082013567ffffffffffffffff8111156102ec576102eb610128565b5b6102f88482850161027e565b60008301525092915050565b600061031761031284610132565b61010d565b9050808382526020820190506020840283018581111561033a5761033961015e565b5b835b8181101561038157803567ffffffffffffffff81111561035f5761035e61012d565b5b80860161036c89826102ac565b8552602085019450505060208101905061033c565b5050509392505050565b600082601f8301126103a05761039f61012d565b5b81356103b0848260208601610304565b91505092915050565b6000602082840312156103cf576103ce610097565b5b6103d9602061010d565b9050600082013567ffffffffffffffff8111156103f9576103f8610128565b5b6104058482850161038b565b60008301525092915050565b6000602082840312156104275761042661008d565b5b600082013567ffffffffffffffff81111561044557610444610092565b5b610451848285016103b9565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6104bb8161018f565b82525050565b6040820160008201516104d760008501826104b2565b5060208201516104ea60208501826104b2565b50505050565b60006104fc83836104c1565b60408301905092915050565b6000602082019050919050565b600061052082610486565b61052a8185610491565b9350610535836104a2565b8060005b8381101561056657815161054d88826104f0565b975061055883610508565b925050600181019050610539565b5085935050505092915050565b600060208301600083015184820360008601526105908282610515565b9150508091505092915050565b60006105a98383610573565b905092915050565b6000602082019050919050565b60006105c98261045a565b6105d38185610465565b9350836020820285016105e585610476565b8060005b858110156106215784840389528151610602858261059d565b945061060d836105b1565b925060208a019950506001810190506105e9565b50829750879550505050505092915050565b6000602083016000830151848203600086015261065082826105be565b9150508091505092915050565b600060208201905081810360008301526106778184610633565b90509291505056fea26469706673582212208ea70f899bda98545e145e7a333a0ae15bd8ae26961c9b8ec53f480310e88a7764736f6c63430008110033" # noqa: E501 +NESTED_TUPLE_CONTRACT_ABI = [ + { + "inputs": [ + { + "components": [ + { + "components": [ + { + "components": [ + { + "internalType": "int256", + "name": "x", + "type": "int256", + }, + { + "internalType": "int256", + "name": "y", + "type": "int256", + }, + ], + "internalType": "struct NestedTupleContract.U[]", + "name": "u", + "type": "tuple[]", + } + ], + "internalType": "struct NestedTupleContract.T[]", + "name": "t", + "type": "tuple[]", + } + ], + "internalType": "struct NestedTupleContract.S", + "name": "s", + "type": "tuple", + } + ], + "name": "method", + "outputs": [ + { + "components": [ + { + "components": [ + { + "components": [ + { + "internalType": "int256", + "name": "x", + "type": "int256", + }, + { + "internalType": "int256", + "name": "y", + "type": "int256", + }, + ], + "internalType": "struct NestedTupleContract.U[]", + "name": "u", + "type": "tuple[]", + } + ], + "internalType": "struct NestedTupleContract.T[]", + "name": "t", + "type": "tuple[]", + } + ], + "internalType": "struct NestedTupleContract.S", + "name": "", + "type": "tuple", + } + ], + "stateMutability": "pure", + "type": "function", + } +] +NESTED_TUPLE_CONTRACT_DATA = { + "bytecode": NESTED_TUPLE_CONTRACT_BYTECODE, + "bytecode_runtime": NESTED_TUPLE_CONTRACT_RUNTIME, + "abi": NESTED_TUPLE_CONTRACT_ABI, +} diff --git a/web3/_utils/contracts.py b/web3/_utils/contracts.py index 96922af080..63313c8212 100644 --- a/web3/_utils/contracts.py +++ b/web3/_utils/contracts.py @@ -366,7 +366,12 @@ def validate_payable(transaction: TxParams, abi: ABIFunction) -> None: """ if "value" in transaction: if to_integer_if_hex(transaction["value"]) != 0: - if "payable" in abi and not abi["payable"]: + if ( + "payable" in abi + and not abi["payable"] + or "stateMutability" in abi + and abi["stateMutability"] == "nonpayable" + ): raise Web3ValidationError( "Sending non-zero ether to a contract function " "with payable=False. Please ensure that " diff --git a/web3/_utils/module_testing/emitter_contract.py b/web3/_utils/module_testing/emitter_contract.py deleted file mode 100644 index 5a33931e8a..0000000000 --- a/web3/_utils/module_testing/emitter_contract.py +++ /dev/null @@ -1,509 +0,0 @@ -CONTRACT_EMITTER_CODE = "608060405234801561001057600080fd5b50611757806100206000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c80639c377053116100715780639c37705314610161578063aa6fd8221461017d578063acabb9ed14610199578063b2ddc449146101b5578063e17bf956146101d1578063f82ef69e146101ed576100b4565b80630bb563d6146100b957806317c0c180146100d557806320f0256e146100f15780635da86c171461010d57806390b41d8b14610129578063966b50e014610145575b600080fd5b6100d360048036038101906100ce9190610af3565b610209565b005b6100ef60048036038101906100ea9190610b61565b610243565b005b61010b60048036038101906101069190610bc4565b61031b565b005b61012760048036038101906101229190610ce4565b610438565b005b610143600480360381019061013e9190610d24565b610475565b005b61015f600480360381019061015a9190610e97565b6105d2565b005b61017b60048036038101906101769190610f0f565b610623565b005b61019760048036038101906101929190610f76565b61073b565b005b6101b360048036038101906101ae9190610fb6565b61087f565b005b6101cf60048036038101906101ca919061108c565b6108d0565b005b6101eb60048036038101906101e6919061116d565b610922565b005b6102076004803603810190610202919061108c565b61095c565b005b7fa95e6e2a182411e7a6f9ed114a85c3761d87f9b8f453d842c71235aa64fff99f816040516102389190611235565b60405180910390a150565b6001601281111561025757610256611257565b5b81601281111561026a57610269611257565b5b036102a0577f1e86022f78f8d04f8e3dfd13a2bdb280403e6632877c0dbee5e4eeb259908a5c60405160405180910390a1610318565b600060128111156102b4576102b3611257565b5b8160128111156102c7576102c6611257565b5b036102dc5760405160405180910390a0610317565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161030e906112f8565b60405180910390fd5b5b50565b6005601281111561032f5761032e611257565b5b85601281111561034257610341611257565b5b03610389577ff039d147f23fe975a4254bdf6b1502b8c79132ae1833986b7ccef2638e73fdf98484848460405161037c9493929190611327565b60405180910390a1610431565b600b601281111561039d5761039c611257565b5b8560128111156103b0576103af611257565b5b036103f55780827fa30ece802b64cd2b7e57dabf4010aabf5df26d1556977affb07b98a77ad955b586866040516103e892919061136c565b60405180910390a3610430565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610427906112f8565b60405180910390fd5b5b5050505050565b7f8ccce2523cca5f3851d20df50b5a59509bc4ac7d9ddba344f5e331969d09b8e78282604051610469929190611402565b60405180910390a15050565b6003601281111561048957610488611257565b5b83601281111561049c5761049b611257565b5b036104df577fdf0cb1dea99afceb3ea698d62e705b736f1345a7eee9eb07e63d1f8f556c1bc582826040516104d292919061136c565b60405180910390a16105cd565b600960128111156104f3576104f2611257565b5b83601281111561050657610505611257565b5b0361054857807f057bc32826fbe161da1c110afcdcae7c109a8b69149f727fc37a603c60ef94ca8360405161053b919061142b565b60405180910390a26105cc565b6008601281111561055c5761055b611257565b5b83601281111561056f5761056e611257565b5b03610590578082604051610583919061142b565b60405180910390a16105cb565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105c2906112f8565b60405180910390fd5b5b5b505050565b816040516105e091906114fe565b60405180910390207fdbc4c1d1d2f0d84e58d36ca767ec9ba2ec2f933c055e50e5ccdd57697f7b58b08260405161061791906115ab565b60405180910390a25050565b6004601281111561063757610636611257565b5b84601281111561064a57610649611257565b5b0361068f577f4a25b279c7c585f25eda9788ac9420ebadae78ca6b206a0e6ab488fd81f55062838383604051610682939291906115cd565b60405180910390a1610735565b600a60128111156106a3576106a2611257565b5b8460128111156106b6576106b5611257565b5b036106f95780827ff16c999b533366ca5138d78e85da51611089cd05749f098d6c225d4cd42ee6ec856040516106ec919061142b565b60405180910390a3610734565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161072b906112f8565b60405180910390fd5b5b50505050565b6002601281111561074f5761074e611257565b5b82601281111561076257610761611257565b5b036107a3577f56d2ef3c5228bf5d88573621e325a4672ab50e033749a601e4f4a5e1dce905d481604051610796919061142b565b60405180910390a161087b565b600760128111156107b7576107b6611257565b5b8260128111156107ca576107c9611257565b5b0361080157807ff70fe689e290d8ce2b2a388ac28db36fbb0e16a6d89c6804c461f65a1b40bb1560405160405180910390a261087a565b6006601281111561081557610814611257565b5b82601281111561082857610827611257565b5b0361083e578060405160405180910390a1610879565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610870906112f8565b60405180910390fd5b5b5b5050565b8160405161088d9190611640565b60405180910390207fe77cf33df73da7bc2e253a2dae617e6f15e4e337eaa462a108903af4643d1b75826040516108c49190611235565b60405180910390a25050565b8173ffffffffffffffffffffffffffffffffffffffff167ff922c215689548d72c3d2fe4ea8dafb2a30c43312c9b43fe5d10f713181f991c826040516109169190611666565b60405180910390a25050565b7f532fd6ea96cfb78bb46e09279a26828b8b493de1a2b8b1ee1face527978a15a58160405161095191906116d6565b60405180910390a150565b7f06029e18f16caae06a69281f35b00ed3fcf47950e6c99dafa1bdd8c4b93479a0828260405161098d9291906116f8565b60405180910390a15050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610a00826109b7565b810181811067ffffffffffffffff82111715610a1f57610a1e6109c8565b5b80604052505050565b6000610a32610999565b9050610a3e82826109f7565b919050565b600067ffffffffffffffff821115610a5e57610a5d6109c8565b5b610a67826109b7565b9050602081019050919050565b82818337600083830152505050565b6000610a96610a9184610a43565b610a28565b905082815260208101848484011115610ab257610ab16109b2565b5b610abd848285610a74565b509392505050565b600082601f830112610ada57610ad96109ad565b5b8135610aea848260208601610a83565b91505092915050565b600060208284031215610b0957610b086109a3565b5b600082013567ffffffffffffffff811115610b2757610b266109a8565b5b610b3384828501610ac5565b91505092915050565b60138110610b4957600080fd5b50565b600081359050610b5b81610b3c565b92915050565b600060208284031215610b7757610b766109a3565b5b6000610b8584828501610b4c565b91505092915050565b6000819050919050565b610ba181610b8e565b8114610bac57600080fd5b50565b600081359050610bbe81610b98565b92915050565b600080600080600060a08688031215610be057610bdf6109a3565b5b6000610bee88828901610b4c565b9550506020610bff88828901610baf565b9450506040610c1088828901610baf565b9350506060610c2188828901610baf565b9250506080610c3288828901610baf565b9150509295509295909350565b600080fd5b600060208284031215610c5a57610c59610c3f565b5b610c646020610a28565b90506000610c7484828501610baf565b60008301525092915050565b600060608284031215610c9657610c95610c3f565b5b610ca06060610a28565b90506000610cb084828501610baf565b6000830152506020610cc484828501610baf565b6020830152506040610cd884828501610c44565b60408301525092915050565b60008060808385031215610cfb57610cfa6109a3565b5b6000610d0985828601610baf565b9250506020610d1a85828601610c80565b9150509250929050565b600080600060608486031215610d3d57610d3c6109a3565b5b6000610d4b86828701610b4c565b9350506020610d5c86828701610baf565b9250506040610d6d86828701610baf565b9150509250925092565b600067ffffffffffffffff821115610d9257610d916109c8565b5b602082029050602081019050919050565b600080fd5b60007fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b610ddd81610da8565b8114610de857600080fd5b50565b600081359050610dfa81610dd4565b92915050565b6000610e13610e0e84610d77565b610a28565b90508083825260208201905060208402830185811115610e3657610e35610da3565b5b835b81811015610e5f5780610e4b8882610deb565b845260208401935050602081019050610e38565b5050509392505050565b600082601f830112610e7e57610e7d6109ad565b5b8135610e8e848260208601610e00565b91505092915050565b60008060408385031215610eae57610ead6109a3565b5b600083013567ffffffffffffffff811115610ecc57610ecb6109a8565b5b610ed885828601610e69565b925050602083013567ffffffffffffffff811115610ef957610ef86109a8565b5b610f0585828601610e69565b9150509250929050565b60008060008060808587031215610f2957610f286109a3565b5b6000610f3787828801610b4c565b9450506020610f4887828801610baf565b9350506040610f5987828801610baf565b9250506060610f6a87828801610baf565b91505092959194509250565b60008060408385031215610f8d57610f8c6109a3565b5b6000610f9b85828601610b4c565b9250506020610fac85828601610baf565b9150509250929050565b60008060408385031215610fcd57610fcc6109a3565b5b600083013567ffffffffffffffff811115610feb57610fea6109a8565b5b610ff785828601610ac5565b925050602083013567ffffffffffffffff811115611018576110176109a8565b5b61102485828601610ac5565b9150509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006110598261102e565b9050919050565b6110698161104e565b811461107457600080fd5b50565b60008135905061108681611060565b92915050565b600080604083850312156110a3576110a26109a3565b5b60006110b185828601611077565b92505060206110c285828601611077565b9150509250929050565b600067ffffffffffffffff8211156110e7576110e66109c8565b5b6110f0826109b7565b9050602081019050919050565b600061111061110b846110cc565b610a28565b90508281526020810184848401111561112c5761112b6109b2565b5b611137848285610a74565b509392505050565b600082601f830112611154576111536109ad565b5b81356111648482602086016110fd565b91505092915050565b600060208284031215611183576111826109a3565b5b600082013567ffffffffffffffff8111156111a1576111a06109a8565b5b6111ad8482850161113f565b91505092915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156111f05780820151818401526020810190506111d5565b60008484015250505050565b6000611207826111b6565b61121181856111c1565b93506112218185602086016111d2565b61122a816109b7565b840191505092915050565b6000602082019050818103600083015261124f81846111fc565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f4469646e2774206d6174636820616e7920616c6c6f7761626c65206576656e7460008201527f20696e6465780000000000000000000000000000000000000000000000000000602082015250565b60006112e26026836111c1565b91506112ed82611286565b604082019050919050565b60006020820190508181036000830152611311816112d5565b9050919050565b61132181610b8e565b82525050565b600060808201905061133c6000830187611318565b6113496020830186611318565b6113566040830185611318565b6113636060830184611318565b95945050505050565b60006040820190506113816000830185611318565b61138e6020830184611318565b9392505050565b61139e81610b8e565b82525050565b6020820160008201516113ba6000850182611395565b50505050565b6060820160008201516113d66000850182611395565b5060208201516113e96020850182611395565b5060408201516113fc60408501826113a4565b50505050565b60006080820190506114176000830185611318565b61142460208301846113c0565b9392505050565b60006020820190506114406000830184611318565b92915050565b600081519050919050565b600081905092915050565b6000819050602082019050919050565b61147581610da8565b82525050565b6000611487838361146c565b60208301905092915050565b6000602082019050919050565b60006114ab82611446565b6114b58185611451565b93506114c08361145c565b8060005b838110156114f15781516114d8888261147b565b97506114e383611493565b9250506001810190506114c4565b5085935050505092915050565b600061150a82846114a0565b915081905092915050565b600082825260208201905092915050565b61152f81610da8565b82525050565b60006115418383611526565b60208301905092915050565b600061155882611446565b6115628185611515565b935061156d8361145c565b8060005b8381101561159e5781516115858882611535565b975061159083611493565b925050600181019050611571565b5085935050505092915050565b600060208201905081810360008301526115c5818461154d565b905092915050565b60006060820190506115e26000830186611318565b6115ef6020830185611318565b6115fc6040830184611318565b949350505050565b600081905092915050565b600061161a826111b6565b6116248185611604565b93506116348185602086016111d2565b80840191505092915050565b600061164c828461160f565b915081905092915050565b6116608161104e565b82525050565b600060208201905061167b6000830184611657565b92915050565b600081519050919050565b600082825260208201905092915050565b60006116a882611681565b6116b2818561168c565b93506116c28185602086016111d2565b6116cb816109b7565b840191505092915050565b600060208201905081810360008301526116f0818461169d565b905092915050565b600060408201905061170d6000830185611657565b61171a6020830184611657565b939250505056fea264697066735822122063a7112e511779f573f2441f6b2969827a2e6c29c105b6b3f6dbb1727d3078ac64736f6c63430008110033" # noqa: E501 -CONTRACT_EMITTER_RUNTIME = "608060405234801561001057600080fd5b50600436106100b45760003560e01c80639c377053116100715780639c37705314610161578063aa6fd8221461017d578063acabb9ed14610199578063b2ddc449146101b5578063e17bf956146101d1578063f82ef69e146101ed576100b4565b80630bb563d6146100b957806317c0c180146100d557806320f0256e146100f15780635da86c171461010d57806390b41d8b14610129578063966b50e014610145575b600080fd5b6100d360048036038101906100ce9190610af3565b610209565b005b6100ef60048036038101906100ea9190610b61565b610243565b005b61010b60048036038101906101069190610bc4565b61031b565b005b61012760048036038101906101229190610ce4565b610438565b005b610143600480360381019061013e9190610d24565b610475565b005b61015f600480360381019061015a9190610e97565b6105d2565b005b61017b60048036038101906101769190610f0f565b610623565b005b61019760048036038101906101929190610f76565b61073b565b005b6101b360048036038101906101ae9190610fb6565b61087f565b005b6101cf60048036038101906101ca919061108c565b6108d0565b005b6101eb60048036038101906101e6919061116d565b610922565b005b6102076004803603810190610202919061108c565b61095c565b005b7fa95e6e2a182411e7a6f9ed114a85c3761d87f9b8f453d842c71235aa64fff99f816040516102389190611235565b60405180910390a150565b6001601281111561025757610256611257565b5b81601281111561026a57610269611257565b5b036102a0577f1e86022f78f8d04f8e3dfd13a2bdb280403e6632877c0dbee5e4eeb259908a5c60405160405180910390a1610318565b600060128111156102b4576102b3611257565b5b8160128111156102c7576102c6611257565b5b036102dc5760405160405180910390a0610317565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161030e906112f8565b60405180910390fd5b5b50565b6005601281111561032f5761032e611257565b5b85601281111561034257610341611257565b5b03610389577ff039d147f23fe975a4254bdf6b1502b8c79132ae1833986b7ccef2638e73fdf98484848460405161037c9493929190611327565b60405180910390a1610431565b600b601281111561039d5761039c611257565b5b8560128111156103b0576103af611257565b5b036103f55780827fa30ece802b64cd2b7e57dabf4010aabf5df26d1556977affb07b98a77ad955b586866040516103e892919061136c565b60405180910390a3610430565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610427906112f8565b60405180910390fd5b5b5050505050565b7f8ccce2523cca5f3851d20df50b5a59509bc4ac7d9ddba344f5e331969d09b8e78282604051610469929190611402565b60405180910390a15050565b6003601281111561048957610488611257565b5b83601281111561049c5761049b611257565b5b036104df577fdf0cb1dea99afceb3ea698d62e705b736f1345a7eee9eb07e63d1f8f556c1bc582826040516104d292919061136c565b60405180910390a16105cd565b600960128111156104f3576104f2611257565b5b83601281111561050657610505611257565b5b0361054857807f057bc32826fbe161da1c110afcdcae7c109a8b69149f727fc37a603c60ef94ca8360405161053b919061142b565b60405180910390a26105cc565b6008601281111561055c5761055b611257565b5b83601281111561056f5761056e611257565b5b03610590578082604051610583919061142b565b60405180910390a16105cb565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105c2906112f8565b60405180910390fd5b5b5b505050565b816040516105e091906114fe565b60405180910390207fdbc4c1d1d2f0d84e58d36ca767ec9ba2ec2f933c055e50e5ccdd57697f7b58b08260405161061791906115ab565b60405180910390a25050565b6004601281111561063757610636611257565b5b84601281111561064a57610649611257565b5b0361068f577f4a25b279c7c585f25eda9788ac9420ebadae78ca6b206a0e6ab488fd81f55062838383604051610682939291906115cd565b60405180910390a1610735565b600a60128111156106a3576106a2611257565b5b8460128111156106b6576106b5611257565b5b036106f95780827ff16c999b533366ca5138d78e85da51611089cd05749f098d6c225d4cd42ee6ec856040516106ec919061142b565b60405180910390a3610734565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161072b906112f8565b60405180910390fd5b5b50505050565b6002601281111561074f5761074e611257565b5b82601281111561076257610761611257565b5b036107a3577f56d2ef3c5228bf5d88573621e325a4672ab50e033749a601e4f4a5e1dce905d481604051610796919061142b565b60405180910390a161087b565b600760128111156107b7576107b6611257565b5b8260128111156107ca576107c9611257565b5b0361080157807ff70fe689e290d8ce2b2a388ac28db36fbb0e16a6d89c6804c461f65a1b40bb1560405160405180910390a261087a565b6006601281111561081557610814611257565b5b82601281111561082857610827611257565b5b0361083e578060405160405180910390a1610879565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610870906112f8565b60405180910390fd5b5b5b5050565b8160405161088d9190611640565b60405180910390207fe77cf33df73da7bc2e253a2dae617e6f15e4e337eaa462a108903af4643d1b75826040516108c49190611235565b60405180910390a25050565b8173ffffffffffffffffffffffffffffffffffffffff167ff922c215689548d72c3d2fe4ea8dafb2a30c43312c9b43fe5d10f713181f991c826040516109169190611666565b60405180910390a25050565b7f532fd6ea96cfb78bb46e09279a26828b8b493de1a2b8b1ee1face527978a15a58160405161095191906116d6565b60405180910390a150565b7f06029e18f16caae06a69281f35b00ed3fcf47950e6c99dafa1bdd8c4b93479a0828260405161098d9291906116f8565b60405180910390a15050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610a00826109b7565b810181811067ffffffffffffffff82111715610a1f57610a1e6109c8565b5b80604052505050565b6000610a32610999565b9050610a3e82826109f7565b919050565b600067ffffffffffffffff821115610a5e57610a5d6109c8565b5b610a67826109b7565b9050602081019050919050565b82818337600083830152505050565b6000610a96610a9184610a43565b610a28565b905082815260208101848484011115610ab257610ab16109b2565b5b610abd848285610a74565b509392505050565b600082601f830112610ada57610ad96109ad565b5b8135610aea848260208601610a83565b91505092915050565b600060208284031215610b0957610b086109a3565b5b600082013567ffffffffffffffff811115610b2757610b266109a8565b5b610b3384828501610ac5565b91505092915050565b60138110610b4957600080fd5b50565b600081359050610b5b81610b3c565b92915050565b600060208284031215610b7757610b766109a3565b5b6000610b8584828501610b4c565b91505092915050565b6000819050919050565b610ba181610b8e565b8114610bac57600080fd5b50565b600081359050610bbe81610b98565b92915050565b600080600080600060a08688031215610be057610bdf6109a3565b5b6000610bee88828901610b4c565b9550506020610bff88828901610baf565b9450506040610c1088828901610baf565b9350506060610c2188828901610baf565b9250506080610c3288828901610baf565b9150509295509295909350565b600080fd5b600060208284031215610c5a57610c59610c3f565b5b610c646020610a28565b90506000610c7484828501610baf565b60008301525092915050565b600060608284031215610c9657610c95610c3f565b5b610ca06060610a28565b90506000610cb084828501610baf565b6000830152506020610cc484828501610baf565b6020830152506040610cd884828501610c44565b60408301525092915050565b60008060808385031215610cfb57610cfa6109a3565b5b6000610d0985828601610baf565b9250506020610d1a85828601610c80565b9150509250929050565b600080600060608486031215610d3d57610d3c6109a3565b5b6000610d4b86828701610b4c565b9350506020610d5c86828701610baf565b9250506040610d6d86828701610baf565b9150509250925092565b600067ffffffffffffffff821115610d9257610d916109c8565b5b602082029050602081019050919050565b600080fd5b60007fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b610ddd81610da8565b8114610de857600080fd5b50565b600081359050610dfa81610dd4565b92915050565b6000610e13610e0e84610d77565b610a28565b90508083825260208201905060208402830185811115610e3657610e35610da3565b5b835b81811015610e5f5780610e4b8882610deb565b845260208401935050602081019050610e38565b5050509392505050565b600082601f830112610e7e57610e7d6109ad565b5b8135610e8e848260208601610e00565b91505092915050565b60008060408385031215610eae57610ead6109a3565b5b600083013567ffffffffffffffff811115610ecc57610ecb6109a8565b5b610ed885828601610e69565b925050602083013567ffffffffffffffff811115610ef957610ef86109a8565b5b610f0585828601610e69565b9150509250929050565b60008060008060808587031215610f2957610f286109a3565b5b6000610f3787828801610b4c565b9450506020610f4887828801610baf565b9350506040610f5987828801610baf565b9250506060610f6a87828801610baf565b91505092959194509250565b60008060408385031215610f8d57610f8c6109a3565b5b6000610f9b85828601610b4c565b9250506020610fac85828601610baf565b9150509250929050565b60008060408385031215610fcd57610fcc6109a3565b5b600083013567ffffffffffffffff811115610feb57610fea6109a8565b5b610ff785828601610ac5565b925050602083013567ffffffffffffffff811115611018576110176109a8565b5b61102485828601610ac5565b9150509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006110598261102e565b9050919050565b6110698161104e565b811461107457600080fd5b50565b60008135905061108681611060565b92915050565b600080604083850312156110a3576110a26109a3565b5b60006110b185828601611077565b92505060206110c285828601611077565b9150509250929050565b600067ffffffffffffffff8211156110e7576110e66109c8565b5b6110f0826109b7565b9050602081019050919050565b600061111061110b846110cc565b610a28565b90508281526020810184848401111561112c5761112b6109b2565b5b611137848285610a74565b509392505050565b600082601f830112611154576111536109ad565b5b81356111648482602086016110fd565b91505092915050565b600060208284031215611183576111826109a3565b5b600082013567ffffffffffffffff8111156111a1576111a06109a8565b5b6111ad8482850161113f565b91505092915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156111f05780820151818401526020810190506111d5565b60008484015250505050565b6000611207826111b6565b61121181856111c1565b93506112218185602086016111d2565b61122a816109b7565b840191505092915050565b6000602082019050818103600083015261124f81846111fc565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f4469646e2774206d6174636820616e7920616c6c6f7761626c65206576656e7460008201527f20696e6465780000000000000000000000000000000000000000000000000000602082015250565b60006112e26026836111c1565b91506112ed82611286565b604082019050919050565b60006020820190508181036000830152611311816112d5565b9050919050565b61132181610b8e565b82525050565b600060808201905061133c6000830187611318565b6113496020830186611318565b6113566040830185611318565b6113636060830184611318565b95945050505050565b60006040820190506113816000830185611318565b61138e6020830184611318565b9392505050565b61139e81610b8e565b82525050565b6020820160008201516113ba6000850182611395565b50505050565b6060820160008201516113d66000850182611395565b5060208201516113e96020850182611395565b5060408201516113fc60408501826113a4565b50505050565b60006080820190506114176000830185611318565b61142460208301846113c0565b9392505050565b60006020820190506114406000830184611318565b92915050565b600081519050919050565b600081905092915050565b6000819050602082019050919050565b61147581610da8565b82525050565b6000611487838361146c565b60208301905092915050565b6000602082019050919050565b60006114ab82611446565b6114b58185611451565b93506114c08361145c565b8060005b838110156114f15781516114d8888261147b565b97506114e383611493565b9250506001810190506114c4565b5085935050505092915050565b600061150a82846114a0565b915081905092915050565b600082825260208201905092915050565b61152f81610da8565b82525050565b60006115418383611526565b60208301905092915050565b600061155882611446565b6115628185611515565b935061156d8361145c565b8060005b8381101561159e5781516115858882611535565b975061159083611493565b925050600181019050611571565b5085935050505092915050565b600060208201905081810360008301526115c5818461154d565b905092915050565b60006060820190506115e26000830186611318565b6115ef6020830185611318565b6115fc6040830184611318565b949350505050565b600081905092915050565b600061161a826111b6565b6116248185611604565b93506116348185602086016111d2565b80840191505092915050565b600061164c828461160f565b915081905092915050565b6116608161104e565b82525050565b600060208201905061167b6000830184611657565b92915050565b600081519050919050565b600082825260208201905092915050565b60006116a882611681565b6116b2818561168c565b93506116c28185602086016111d2565b6116cb816109b7565b840191505092915050565b600060208201905081810360008301526116f0818461169d565b905092915050565b600060408201905061170d6000830185611657565b61171a6020830184611657565b939250505056fea264697066735822122063a7112e511779f573f2441f6b2969827a2e6c29c105b6b3f6dbb1727d3078ac64736f6c63430008110033" # noqa: E501 -CONTRACT_EMITTER_ABI = [ - { - "anonymous": False, - "inputs": [ - { - "indexed": True, - "internalType": "address", - "name": "arg0", - "type": "address", - }, - { - "indexed": False, - "internalType": "address", - "name": "arg1", - "type": "address", - }, - ], - "name": "LogAddressIndexed", - "type": "event", - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": False, - "internalType": "address", - "name": "arg0", - "type": "address", - }, - { - "indexed": False, - "internalType": "address", - "name": "arg1", - "type": "address", - }, - ], - "name": "LogAddressNotIndexed", - "type": "event", - }, - {"anonymous": True, "inputs": [], "name": "LogAnonymous", "type": "event"}, - { - "anonymous": False, - "inputs": [ - {"indexed": False, "internalType": "bytes", "name": "v", "type": "bytes"} - ], - "name": "LogBytes", - "type": "event", - }, - { - "anonymous": True, - "inputs": [ - { - "indexed": False, - "internalType": "uint256", - "name": "arg0", - "type": "uint256", - }, - { - "indexed": True, - "internalType": "uint256", - "name": "arg1", - "type": "uint256", - }, - ], - "name": "LogDoubleAnonymous", - "type": "event", - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": False, - "internalType": "uint256", - "name": "arg0", - "type": "uint256", - }, - { - "indexed": False, - "internalType": "uint256", - "name": "arg1", - "type": "uint256", - }, - ], - "name": "LogDoubleArg", - "type": "event", - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": False, - "internalType": "uint256", - "name": "arg0", - "type": "uint256", - }, - { - "indexed": True, - "internalType": "uint256", - "name": "arg1", - "type": "uint256", - }, - ], - "name": "LogDoubleWithIndex", - "type": "event", - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": True, - "internalType": "string", - "name": "arg0", - "type": "string", - }, - { - "indexed": False, - "internalType": "string", - "name": "arg1", - "type": "string", - }, - ], - "name": "LogDynamicArgs", - "type": "event", - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": True, - "internalType": "bytes2[]", - "name": "arg0", - "type": "bytes2[]", - }, - { - "indexed": False, - "internalType": "bytes2[]", - "name": "arg1", - "type": "bytes2[]", - }, - ], - "name": "LogListArgs", - "type": "event", - }, - {"anonymous": False, "inputs": [], "name": "LogNoArguments", "type": "event"}, - { - "anonymous": False, - "inputs": [ - { - "indexed": False, - "internalType": "uint256", - "name": "arg0", - "type": "uint256", - }, - { - "indexed": False, - "internalType": "uint256", - "name": "arg1", - "type": "uint256", - }, - { - "indexed": False, - "internalType": "uint256", - "name": "arg2", - "type": "uint256", - }, - { - "indexed": False, - "internalType": "uint256", - "name": "arg3", - "type": "uint256", - }, - ], - "name": "LogQuadrupleArg", - "type": "event", - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": False, - "internalType": "uint256", - "name": "arg0", - "type": "uint256", - }, - { - "indexed": False, - "internalType": "uint256", - "name": "arg1", - "type": "uint256", - }, - { - "indexed": True, - "internalType": "uint256", - "name": "arg2", - "type": "uint256", - }, - { - "indexed": True, - "internalType": "uint256", - "name": "arg3", - "type": "uint256", - }, - ], - "name": "LogQuadrupleWithIndex", - "type": "event", - }, - { - "anonymous": True, - "inputs": [ - { - "indexed": True, - "internalType": "uint256", - "name": "arg0", - "type": "uint256", - } - ], - "name": "LogSingleAnonymous", - "type": "event", - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": False, - "internalType": "uint256", - "name": "arg0", - "type": "uint256", - } - ], - "name": "LogSingleArg", - "type": "event", - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": True, - "internalType": "uint256", - "name": "arg0", - "type": "uint256", - } - ], - "name": "LogSingleWithIndex", - "type": "event", - }, - { - "anonymous": False, - "inputs": [ - {"indexed": False, "internalType": "string", "name": "v", "type": "string"} - ], - "name": "LogString", - "type": "event", - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": False, - "internalType": "uint256", - "name": "arg0", - "type": "uint256", - }, - { - "components": [ - {"internalType": "uint256", "name": "a", "type": "uint256"}, - {"internalType": "uint256", "name": "b", "type": "uint256"}, - { - "components": [ - {"internalType": "uint256", "name": "c", "type": "uint256"} - ], - "internalType": "struct Emitter.NestedTestTuple", - "name": "nested", - "type": "tuple", - }, - ], - "indexed": False, - "internalType": "struct Emitter.TestTuple", - "name": "arg1", - "type": "tuple", - }, - ], - "name": "LogStructArgs", - "type": "event", - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": False, - "internalType": "uint256", - "name": "arg0", - "type": "uint256", - }, - { - "indexed": False, - "internalType": "uint256", - "name": "arg1", - "type": "uint256", - }, - { - "indexed": False, - "internalType": "uint256", - "name": "arg2", - "type": "uint256", - }, - ], - "name": "LogTripleArg", - "type": "event", - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": False, - "internalType": "uint256", - "name": "arg0", - "type": "uint256", - }, - { - "indexed": True, - "internalType": "uint256", - "name": "arg1", - "type": "uint256", - }, - { - "indexed": True, - "internalType": "uint256", - "name": "arg2", - "type": "uint256", - }, - ], - "name": "LogTripleWithIndex", - "type": "event", - }, - { - "inputs": [ - {"internalType": "address", "name": "arg0", "type": "address"}, - {"internalType": "address", "name": "arg1", "type": "address"}, - ], - "name": "logAddressIndexedArgs", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function", - }, - { - "inputs": [ - {"internalType": "address", "name": "arg0", "type": "address"}, - {"internalType": "address", "name": "arg1", "type": "address"}, - ], - "name": "logAddressNotIndexedArgs", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function", - }, - { - "inputs": [{"internalType": "bytes", "name": "v", "type": "bytes"}], - "name": "logBytes", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function", - }, - { - "inputs": [ - { - "internalType": "enum Emitter.WhichEvent", - "name": "which", - "type": "uint8", - }, - {"internalType": "uint256", "name": "arg0", "type": "uint256"}, - {"internalType": "uint256", "name": "arg1", "type": "uint256"}, - ], - "name": "logDouble", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function", - }, - { - "inputs": [ - {"internalType": "string", "name": "arg0", "type": "string"}, - {"internalType": "string", "name": "arg1", "type": "string"}, - ], - "name": "logDynamicArgs", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function", - }, - { - "inputs": [ - {"internalType": "bytes2[]", "name": "arg0", "type": "bytes2[]"}, - {"internalType": "bytes2[]", "name": "arg1", "type": "bytes2[]"}, - ], - "name": "logListArgs", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function", - }, - { - "inputs": [ - { - "internalType": "enum Emitter.WhichEvent", - "name": "which", - "type": "uint8", - } - ], - "name": "logNoArgs", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function", - }, - { - "inputs": [ - { - "internalType": "enum Emitter.WhichEvent", - "name": "which", - "type": "uint8", - }, - {"internalType": "uint256", "name": "arg0", "type": "uint256"}, - {"internalType": "uint256", "name": "arg1", "type": "uint256"}, - {"internalType": "uint256", "name": "arg2", "type": "uint256"}, - {"internalType": "uint256", "name": "arg3", "type": "uint256"}, - ], - "name": "logQuadruple", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function", - }, - { - "inputs": [ - { - "internalType": "enum Emitter.WhichEvent", - "name": "which", - "type": "uint8", - }, - {"internalType": "uint256", "name": "arg0", "type": "uint256"}, - ], - "name": "logSingle", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function", - }, - { - "inputs": [{"internalType": "string", "name": "v", "type": "string"}], - "name": "logString", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function", - }, - { - "inputs": [ - {"internalType": "uint256", "name": "arg0", "type": "uint256"}, - { - "components": [ - {"internalType": "uint256", "name": "a", "type": "uint256"}, - {"internalType": "uint256", "name": "b", "type": "uint256"}, - { - "components": [ - {"internalType": "uint256", "name": "c", "type": "uint256"} - ], - "internalType": "struct Emitter.NestedTestTuple", - "name": "nested", - "type": "tuple", - }, - ], - "internalType": "struct Emitter.TestTuple", - "name": "arg1", - "type": "tuple", - }, - ], - "name": "logStruct", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function", - }, - { - "inputs": [ - { - "internalType": "enum Emitter.WhichEvent", - "name": "which", - "type": "uint8", - }, - {"internalType": "uint256", "name": "arg0", "type": "uint256"}, - {"internalType": "uint256", "name": "arg1", "type": "uint256"}, - {"internalType": "uint256", "name": "arg2", "type": "uint256"}, - ], - "name": "logTriple", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function", - }, -] - - -EMITTER_ENUM = { - "LogAnonymous": 0, - "LogNoArguments": 1, - "LogSingleArg": 2, - "LogDoubleArg": 3, - "LogTripleArg": 4, - "LogQuadrupleArg": 5, - "LogSingleAnonymous": 6, - "LogSingleWithIndex": 7, - "LogDoubleAnonymous": 8, - "LogDoubleWithIndex": 9, - "LogTripleWithIndex": 10, - "LogQuadrupleWithIndex": 11, - "LogStructArg": 12, -} diff --git a/web3/_utils/module_testing/eth_module.py b/web3/_utils/module_testing/eth_module.py index 69753adca6..7f9a12b896 100644 --- a/web3/_utils/module_testing/eth_module.py +++ b/web3/_utils/module_testing/eth_module.py @@ -712,7 +712,9 @@ async def test_eth_get_code( @pytest.mark.asyncio async def test_eth_get_code_invalid_address( - self, async_w3: "Web3", math_contract: "Contract" + self, + async_w3: "Web3", + math_contract: "Contract", ) -> None: with pytest.raises(InvalidAddress): await async_w3.eth.get_code( # type: ignore @@ -3400,7 +3402,7 @@ def test_eth_call_old_contract_state( block_num = start_block["number"] block_hash = start_block["hash"] - math_contract.functions.increment().transact({"from": unlocked_account}) + math_contract.functions.incrementCounter().transact({"from": unlocked_account}) # This isn't an incredibly convincing test since we can't mine, and # the default resolved block is latest, So if block_identifier was ignored diff --git a/web3/_utils/module_testing/event_contract.py b/web3/_utils/module_testing/event_contract.py deleted file mode 100644 index c3425abc69..0000000000 --- a/web3/_utils/module_testing/event_contract.py +++ /dev/null @@ -1,46 +0,0 @@ -EVNT_CONTRACT_CODE = ( - "6080604052348015600f57600080fd5b5061010b8061001f6000396000f30060806040526004361" - "0603f576000357c0100000000000000000000000000000000000000000000000000000000900463" - "ffffffff1680635818fad7146044575b600080fd5b348015604f57600080fd5b50606c600480360" - "38101908080359060200190929190505050606e565b005b7ff70fe689e290d8ce2b2a388ac28db3" - "6fbb0e16a6d89c6804c461f65a1b40bb15816040518082815260200191505060405180910390a17" - "f56d2ef3c5228bf5d88573621e325a4672ab50e033749a601e4f4a5e1dce905d481604051808281" - "5260200191505060405180910390a1505600a165627a7a72305820ff79430a04cf654d7b46edc52" - "9ccaa5d7f77607f54bb58210be0c48455292c810029" -) - - -EVNT_CONTRACT_RUNTIME = ( - "608060405260043610603f576000357c01000000000000000000000000000000000000000000000" - "00000000000900463ffffffff1680635818fad7146044575b600080fd5b348015604f57600080fd" - "5b50606c60048036038101908080359060200190929190505050606e565b005b7ff70fe689e290d" - "8ce2b2a388ac28db36fbb0e16a6d89c6804c461f65a1b40bb158160405180828152602001915050" - "60405180910390a17f56d2ef3c5228bf5d88573621e325a4672ab50e033749a601e4f4a5e1dce90" - "5d4816040518082815260200191505060405180910390a1505600a165627a7a72305820ff79430a" - "04cf654d7b46edc529ccaa5d7f77607f54bb58210be0c48455292c810029" -) - - -EVNT_CONTRACT_ABI = [ - { - "constant": False, - "inputs": [{"name": "arg0", "type": "uint256"}], - "name": "logTwoEvents", - "outputs": [], - "payable": False, - "stateMutability": "nonpayable", - "type": "function", - }, - { - "anonymous": False, - "inputs": [{"indexed": False, "name": "arg0", "type": "uint256"}], - "name": "LogSingleWithIndex", - "type": "event", - }, - { - "anonymous": False, - "inputs": [{"indexed": False, "name": "arg0", "type": "uint256"}], - "name": "LogSingleArg", - "type": "event", - }, -] diff --git a/web3/_utils/module_testing/fallback_contract.py b/web3/_utils/module_testing/fallback_contract.py deleted file mode 100644 index 7c2213488c..0000000000 --- a/web3/_utils/module_testing/fallback_contract.py +++ /dev/null @@ -1,14 +0,0 @@ -CONTRACT_FALLBACK_FUNCTION_SOURCE = """ -contract A { - uint data; - function A() public payable { data = 0; } - function getData() returns (uint r) { return data; } - function() { data = 1; } -} -""" - -CONTRACT_FALLBACK_FUNCTION_CODE = "60606040526000808190555060ae806100196000396000f300606060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633bc5de30146053575b3415604957600080fd5b6001600081905550005b3415605d57600080fd5b60636079565b6040518082815260200191505060405180910390f35b600080549050905600a165627a7a72305820045439389e4742569ec078687e6a0c81997709778a0097adbe07ccfd9f7b1a330029" # noqa: E501 - -CONTRACT_FALLBACK_FUNCTION_RUNTIME = "606060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633bc5de30146053575b3415604957600080fd5b6001600081905550005b3415605d57600080fd5b60636079565b6040518082815260200191505060405180910390f35b600080549050905600a165627a7a72305820045439389e4742569ec078687e6a0c81997709778a0097adbe07ccfd9f7b1a330029" # noqa: E501 - -CONTRACT_FALLBACK_FUNCTION_ABI = '[{"constant": false, "inputs": [], "name": "getData", "outputs": [{"name": "r", "type": "uint256"}], "payable": false, "stateMutability": "nonpayable", "type": "function"}, {"inputs": [], "payable": true, "stateMutability": "payable", "type": "constructor"}, {"payable": false, "stateMutability": "nonpayable", "type": "fallback"}]' # noqa: E501 diff --git a/web3/_utils/module_testing/indexed_event_contract.py b/web3/_utils/module_testing/indexed_event_contract.py deleted file mode 100644 index 1f090b6474..0000000000 --- a/web3/_utils/module_testing/indexed_event_contract.py +++ /dev/null @@ -1,46 +0,0 @@ -IND_EVENT_CONTRACT_CODE = ( - "6080604052348015600f57600080fd5b506101018061001f6000396000f30060806040526004361" - "0603f576000357c0100000000000000000000000000000000000000000000000000000000900463" - "ffffffff1680635818fad7146044575b600080fd5b348015604f57600080fd5b50606c600480360" - "38101908080359060200190929190505050606e565b005b807ff70fe689e290d8ce2b2a388ac28d" - "b36fbb0e16a6d89c6804c461f65a1b40bb1560405160405180910390a27f56d2ef3c5228bf5d885" - "73621e325a4672ab50e033749a601e4f4a5e1dce905d48160405180828152602001915050604051" - "80910390a1505600a165627a7a72305820afa2dc55cd3a55a914793a583c3284fc5f8dc8ebec94e" - "6ec7fe1ad6d604daf350029" -) - - -IND_EVENT_CONTRACT_RUNTIME = ( - "608060405260043610603f576000357c01000000000000000000000000000000000000000000000" - "00000000000900463ffffffff1680635818fad7146044575b600080fd5b348015604f57600080fd" - "5b50606c60048036038101908080359060200190929190505050606e565b005b807ff70fe689e29" - "0d8ce2b2a388ac28db36fbb0e16a6d89c6804c461f65a1b40bb1560405160405180910390a27f56" - "d2ef3c5228bf5d88573621e325a4672ab50e033749a601e4f4a5e1dce905d481604051808281526" - "0200191505060405180910390a1505600a165627a7a72305820afa2dc55cd3a55a914793a583c32" - "84fc5f8dc8ebec94e6ec7fe1ad6d604daf350029" -) - - -IND_EVENT_CONTRACT_ABI = [ - { - "constant": False, - "inputs": [{"name": "arg0", "type": "uint256"}], - "name": "logTwoEvents", - "outputs": [], - "payable": False, - "stateMutability": "nonpayable", - "type": "function", - }, - { - "anonymous": False, - "inputs": [{"indexed": True, "name": "arg0", "type": "uint256"}], - "name": "LogSingleWithIndex", - "type": "event", - }, - { - "anonymous": False, - "inputs": [{"indexed": False, "name": "arg0", "type": "uint256"}], - "name": "LogSingleArg", - "type": "event", - }, -] diff --git a/web3/_utils/module_testing/math_contract.py b/web3/_utils/module_testing/math_contract.py deleted file mode 100644 index 0f3c428f61..0000000000 --- a/web3/_utils/module_testing/math_contract.py +++ /dev/null @@ -1,192 +0,0 @@ -MATH_BYTECODE = ( - "606060405261022e806100126000396000f360606040523615610074576000357c01000000000000" - "000000000000000000000000000000000000000000009004806316216f391461007657806361bc22" - "1a146100995780637cf5dab0146100bc578063a5f3c23b146100e8578063d09de08a1461011d5780" - "63dcf537b11461014057610074565b005b610083600480505061016c565b60405180828152602001" - "91505060405180910390f35b6100a6600480505061017f565b604051808281526020019150506040" - "5180910390f35b6100d26004808035906020019091905050610188565b6040518082815260200191" - "505060405180910390f35b61010760048080359060200190919080359060200190919050506101ea" - "565b6040518082815260200191505060405180910390f35b61012a6004805050610201565b604051" - "8082815260200191505060405180910390f35b610156600480803590602001909190505061021756" - "5b6040518082815260200191505060405180910390f35b6000600d9050805080905061017c565b90" - "565b60006000505481565b6000816000600082828250540192505081905550600060005054905080" - "507f3496c3ede4ec3ab3686712aa1c238593ea6a42df83f98a5ec7df9834cfa577c5816040518082" - "815260200191505060405180910390a18090506101e5565b919050565b6000818301905080508090" - "506101fb565b92915050565b600061020d6001610188565b9050610214565b90565b600060078202" - "90508050809050610229565b91905056" -) - - -MATH_ABI = [ - { - "constant": False, - "inputs": [], - "name": "return13", - "outputs": [ - {"name": "result", "type": "int256"}, - ], - "type": "function", - }, - { - "constant": True, - "inputs": [], - "name": "counter", - "outputs": [ - {"name": "", "type": "uint256"}, - ], - "type": "function", - }, - { - "constant": False, - "inputs": [ - {"name": "amt", "type": "uint256"}, - ], - "name": "increment", - "outputs": [ - {"name": "result", "type": "uint256"}, - ], - "type": "function", - }, - { - "constant": False, - "inputs": [ - {"name": "a", "type": "int256"}, - {"name": "b", "type": "int256"}, - ], - "name": "add", - "outputs": [ - {"name": "result", "type": "int256"}, - ], - "type": "function", - }, - { - "constant": False, - "inputs": [], - "name": "increment", - "outputs": [ - {"name": "", "type": "uint256"}, - ], - "type": "function", - }, - { - "constant": False, - "inputs": [ - {"name": "a", "type": "int256"}, - ], - "name": "multiply7", - "outputs": [ - {"name": "result", "type": "int256"}, - ], - "type": "function", - }, - { - "anonymous": False, - "inputs": [ - {"indexed": False, "name": "value", "type": "uint256"}, - ], - "name": "Increased", - "type": "event", - }, -] - -# The de-compiled math contract, for reference: -""" -contract Contract { - function main() { - memory[0x40:0x60] = 0x60; - - if (!msg.data.length) { stop(); } - - var var0 = - msg.data[0x00:0x20] / 0x0100000000000000000000000000000000000000000000000000000000; # noqa: E501 - - if (var0 == 0x16216f39) { - // Dispatch table entry for return13() - var var1 = 0x0083; - var1 = return13(); - var temp0 = memory[0x40:0x60]; - memory[temp0:temp0 + 0x20] = var1; - var temp1 = memory[0x40:0x60]; - return memory[temp1:temp1 + (temp0 + 0x20) - temp1]; - } else if (var0 == 0x61bc221a) { - // Dispatch table entry for counter() - var1 = 0x00a6; - var var2 = counter(); - var temp2 = memory[0x40:0x60]; - memory[temp2:temp2 + 0x20] = var2; - var temp3 = memory[0x40:0x60]; - return memory[temp3:temp3 + (temp2 + 0x20) - temp3]; - } else if (var0 == 0x7cf5dab0) { - // Dispatch table entry for increment(uint256) - var1 = 0x00d2; - var2 = msg.data[0x04:0x24]; - var1 = increment(var2); - var temp4 = memory[0x40:0x60]; - memory[temp4:temp4 + 0x20] = var1; - var temp5 = memory[0x40:0x60]; - return memory[temp5:temp5 + (temp4 + 0x20) - temp5]; - } else if (var0 == 0xa5f3c23b) { - // Dispatch table entry for add(int256,int256) - var1 = 0x0107; - var2 = msg.data[0x04:0x24]; - var var3 = msg.data[0x24:0x44]; - var1 = add(var2, var3); - var temp6 = memory[0x40:0x60]; - memory[temp6:temp6 + 0x20] = var1; - var temp7 = memory[0x40:0x60]; - return memory[temp7:temp7 + (temp6 + 0x20) - temp7]; - } else if (var0 == 0xd09de08a) { - // Dispatch table entry for increment() - var1 = 0x012a; - var1 = increment(); - var temp8 = memory[0x40:0x60]; - memory[temp8:temp8 + 0x20] = var1; - var temp9 = memory[0x40:0x60]; - return memory[temp9:temp9 + (temp8 + 0x20) - temp9]; - } else if (var0 == 0xdcf537b1) { - // Dispatch table entry for multiply7(int256) - var1 = 0x0156; - var2 = msg.data[0x04:0x24]; - var1 = multiply7(var2); - var temp10 = memory[0x40:0x60]; - memory[temp10:temp10 + 0x20] = var1; - var temp11 = memory[0x40:0x60]; - return memory[temp11:temp11 + (temp10 + 0x20) - temp11]; - } else { stop(); } - } - - function return13() returns (var r0) { - var var0 = 0x0d; - return var0; - } - - function counter() returns (var r0) { return storage[0x00]; } - - function increment(var arg0) returns (var r0) { - storage[0x00] = storage[0x00] + arg0; - var temp0 = memory[0x40:0x60]; - memory[temp0:temp0 + 0x20] = storage[0x00]; - var temp1 = memory[0x40:0x60]; - log(memory[temp1:temp1 + (temp0 + 0x20) - temp1], - [0x3496c3ede4ec3ab3686712aa1c238593ea6a42df83f98a5ec7df9834cfa577c5]); - var var0 = storage[0x00]; - return var0;} - - function add(var arg0, var arg1) returns (var r0) { - var var0 = arg0 + arg1; - return var0; - } - - function increment() returns (var r0) { - var var0 = 0x00; - var var1 = 0x020d; - var var2 = 0x01; - return increment(var2); - } - - function multiply7(var arg0) returns (var r0) { - var var0 = arg0 * 0x07; - return var0; - } -} -""" diff --git a/web3/_utils/module_testing/no_receive_contract.py b/web3/_utils/module_testing/no_receive_contract.py deleted file mode 100644 index 2afeb62353..0000000000 --- a/web3/_utils/module_testing/no_receive_contract.py +++ /dev/null @@ -1,69 +0,0 @@ -CONTRACT_NO_RECEIVE_SOURCE_CODE = """ -pragma solidity ^0.6.0; - - -contract Receive { - string text; - - fallback() external { - text = 'fallback'; - } - - function getText() public view returns (string memory) { - return text; - } - - function setText(string memory new_text) public returns (string memory) { - return text = new_text; - } -} - -""" - - -CONTRACT_NO_RECEIVE_FUNCTION_ABI = """ -[ - { - "stateMutability": "nonpayable", - "type": "fallback" - }, - { - "inputs": [], - "name": "getText", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "new_text", - "type": "string" - } - ], - "name": "setText", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } -] -""" - - -CONTRACT_NO_RECEIVE_FUNCTION_CODE = "608060405234801561001057600080fd5b50610396806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80635d3a1f9d14610068578063e00fe2eb14610183575b6040805180820190915260088082526766616c6c6261636b60c01b6020909201918252610065916000916102c8565b50005b61010e6004803603602081101561007e57600080fd5b81019060208101813564010000000081111561009957600080fd5b8201836020820111156100ab57600080fd5b803590602001918460018302840111640100000000831117156100cd57600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955061018b945050505050565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610148578181015183820152602001610130565b50505050905090810190601f1680156101755780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61010e610231565b80516060906101a19060009060208501906102c8565b805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156102255780601f106101fa57610100808354040283529160200191610225565b820191906000526020600020905b81548152906001019060200180831161020857829003601f168201915b50505050509050919050565b60008054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156102bd5780601f10610292576101008083540402835291602001916102bd565b820191906000526020600020905b8154815290600101906020018083116102a057829003601f168201915b505050505090505b90565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061030957805160ff1916838001178555610336565b82800160010185558215610336579182015b8281111561033657825182559160200191906001019061031b565b50610342929150610346565b5090565b6102c591905b80821115610342576000815560010161034c56fea26469706673582212208c33db8b08eb0abda95d96bba0df24cf6356f47eb17c4f556a3427dc161852db64736f6c63430006010033" # noqa: E501 - - -CONTRACT_NO_RECEIVE_FUNCTION_RUNTIME = "608060405234801561001057600080fd5b50600436106100365760003560e01c80635d3a1f9d14610068578063e00fe2eb14610183575b6040805180820190915260088082526766616c6c6261636b60c01b6020909201918252610065916000916102c8565b50005b61010e6004803603602081101561007e57600080fd5b81019060208101813564010000000081111561009957600080fd5b8201836020820111156100ab57600080fd5b803590602001918460018302840111640100000000831117156100cd57600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955061018b945050505050565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610148578181015183820152602001610130565b50505050905090810190601f1680156101755780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61010e610231565b80516060906101a19060009060208501906102c8565b805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156102255780601f106101fa57610100808354040283529160200191610225565b820191906000526020600020905b81548152906001019060200180831161020857829003601f168201915b50505050509050919050565b60008054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156102bd5780601f10610292576101008083540402835291602001916102bd565b820191906000526020600020905b8154815290600101906020018083116102a057829003601f168201915b505050505090505b90565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061030957805160ff1916838001178555610336565b82800160010185558215610336579182015b8281111561033657825182559160200191906001019061031b565b50610342929150610346565b5090565b6102c591905b80821115610342576000815560010161034c56fea26469706673582212208c33db8b08eb0abda95d96bba0df24cf6356f47eb17c4f556a3427dc161852db64736f6c63430006010033" # noqa: E501 diff --git a/web3/_utils/module_testing/offchain_lookup_contract.py b/web3/_utils/module_testing/offchain_lookup_contract.py deleted file mode 100644 index 7f7e1f35e7..0000000000 --- a/web3/_utils/module_testing/offchain_lookup_contract.py +++ /dev/null @@ -1,106 +0,0 @@ -import json - -# contract source at .contract_sources/OffchainLookup.sol -OFFCHAIN_LOOKUP_BYTECODE = "608060405260405180604001604052806040518060600160405280602c815260200162000ec9602c9139815260200160405180606001604052806025815260200162000ef56025913981525060009060026200005d92919062000072565b503480156200006b57600080fd5b506200025b565b828054828255906000526020600020908101928215620000c6579160200282015b82811115620000c5578251829080519060200190620000b4929190620000d9565b509160200191906001019062000093565b5b509050620000d591906200016a565b5090565b828054620000e79062000226565b90600052602060002090601f0160209004810192826200010b576000855562000157565b82601f106200012657805160ff191683800117855562000157565b8280016001018555821562000157579182015b828111156200015657825182559160200191906001019062000139565b5b50905062000166919062000192565b5090565b5b808211156200018e5760008181620001849190620001b1565b506001016200016b565b5090565b5b80821115620001ad57600081600090555060010162000193565b5090565b508054620001bf9062000226565b6000825580601f10620001d35750620001f4565b601f016020900490600052602060002090810190620001f3919062000192565b5b50565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806200023f57607f821691505b602082108103620002555762000254620001f7565b5b50919050565b610c5e806200026b6000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806309a3c01b146100465780636337ed5814610064578063da96d05a14610094575b600080fd5b61004e6100c4565b60405161005b9190610424565b60405180910390f35b61007e600480360381019061007991906104bf565b610114565b60405161008b9190610424565b60405180910390f35b6100ae60048036038101906100a9919061050c565b610202565b6040516100bb9190610424565b60405180910390f35b606080306000826309a3c01b60e01b846040517f556f183000000000000000000000000000000000000000000000000000000000815260040161010b9594939291906107d5565b60405180910390fd5b606060008383810190610127919061096d565b90507fd9bdd1345ca2a00d0c1413137c1b2b1d0a35e5b0e11508f3b3eff856286af0758160405160200161015b91906109fd565b60405160208183030381529060405280519060200120146101b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101a890610a71565b60405180910390fd5b306000858563da96d05a60e01b88886040517f556f18300000000000000000000000000000000000000000000000000000000081526004016101f99796959493929190610abe565b60405180910390fd5b606060008585810190610215919061096d565b90507faed76f463930323372899e36460e078e5292aac45f645bbe567be6fca83ede108160405160200161024991906109fd565b604051602081830303815290604052805190602001201461029f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161029690610b9c565b60405180910390fd5b600084848101906102b0919061096d565b90507fd9bdd1345ca2a00d0c1413137c1b2b1d0a35e5b0e11508f3b3eff856286af075816040516020016102e491906109fd565b604051602081830303815290604052805190602001201461033a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161033190610c08565b60405180910390fd5b86868080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505092505050949350505050565b600081519050919050565b600082825260208201905092915050565b60005b838110156103c55780820151818401526020810190506103aa565b838111156103d4576000848401525b50505050565b6000601f19601f8301169050919050565b60006103f68261038b565b6104008185610396565b93506104108185602086016103a7565b610419816103da565b840191505092915050565b6000602082019050818103600083015261043e81846103eb565b905092915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f84011261047f5761047e61045a565b5b8235905067ffffffffffffffff81111561049c5761049b61045f565b5b6020830191508360018202830111156104b8576104b7610464565b5b9250929050565b600080602083850312156104d6576104d5610450565b5b600083013567ffffffffffffffff8111156104f4576104f3610455565b5b61050085828601610469565b92509250509250929050565b6000806000806040858703121561052657610525610450565b5b600085013567ffffffffffffffff81111561054457610543610455565b5b61055087828801610469565b9450945050602085013567ffffffffffffffff81111561057357610572610455565b5b61057f87828801610469565b925092505092959194509250565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006105b88261058d565b9050919050565b6105c8816105ad565b82525050565b600081549050919050565b600082825260208201905092915050565b60008190508160005260206000209050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061064657607f821691505b602082108103610659576106586105ff565b5b50919050565b600082825260208201905092915050565b60008190508160005260206000209050919050565b600081546106928161062e565b61069c818661065f565b945060018216600081146106b757600181146106c9576106fc565b60ff19831686526020860193506106fc565b6106d285610670565b60005b838110156106f4578154818901526001820191506020810190506106d5565b808801955050505b50505092915050565b60006107118383610685565b905092915050565b6000600182019050919050565b6000610731826105ce565b61073b81856105d9565b93508360208202850161074d856105ea565b8060005b85811015610788578484038952816107698582610705565b945061077483610719565b925060208a01995050600181019050610751565b50829750879550505050505092915050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6107cf8161079a565b82525050565b600060a0820190506107ea60008301886105bf565b81810360208301526107fc8187610726565b9050818103604083015261081081866103eb565b905061081f60608301856107c6565b818103608083015261083181846103eb565b90509695505050505050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61087a826103da565b810181811067ffffffffffffffff8211171561089957610898610842565b5b80604052505050565b60006108ac610446565b90506108b88282610871565b919050565b600067ffffffffffffffff8211156108d8576108d7610842565b5b6108e1826103da565b9050602081019050919050565b82818337600083830152505050565b600061091061090b846108bd565b6108a2565b90508281526020810184848401111561092c5761092b61083d565b5b6109378482856108ee565b509392505050565b600082601f8301126109545761095361045a565b5b81356109648482602086016108fd565b91505092915050565b60006020828403121561098357610982610450565b5b600082013567ffffffffffffffff8111156109a1576109a0610455565b5b6109ad8482850161093f565b91505092915050565b600081519050919050565b600081905092915050565b60006109d7826109b6565b6109e181856109c1565b93506109f18185602086016103a7565b80840191505092915050565b6000610a0982846109cc565b915081905092915050565b600082825260208201905092915050565b7f7465737420646174612076616c69646174696f6e206661696c65642e00000000600082015250565b6000610a5b601c83610a14565b9150610a6682610a25565b602082019050919050565b60006020820190508181036000830152610a8a81610a4e565b9050919050565b6000610a9d8385610396565b9350610aaa8385846108ee565b610ab3836103da565b840190509392505050565b600060a082019050610ad3600083018a6105bf565b8181036020830152610ae58189610726565b90508181036040830152610afa818789610a91565b9050610b0960608301866107c6565b8181036080830152610b1c818486610a91565b905098975050505050505050565b7f68747470207265717565737420726573756c742076616c69646174696f6e206660008201527f61696c65642e0000000000000000000000000000000000000000000000000000602082015250565b6000610b86602683610a14565b9150610b9182610b2a565b604082019050919050565b60006020820190508181036000830152610bb581610b79565b9050919050565b7f6578747261446174612076616c69646174696f6e206661696c65642e00000000600082015250565b6000610bf2601c83610a14565b9150610bfd82610bbc565b602082019050919050565b60006020820190508181036000830152610c2181610be5565b905091905056fea2646970667358221220528c32029f8724a4e2b6a2a469880824c952eae5971f18628559629192c102b164736f6c634300080d003368747470733a2f2f776562332e70792f676174657761792f7b73656e6465727d2f7b646174617d2e6a736f6e68747470733a2f2f776562332e70792f676174657761792f7b73656e6465727d2e6a736f6e" # noqa: E501 -OFFCHAIN_LOOKUP_BYTECODE_RUNTIME = "608060405234801561001057600080fd5b50600436106100415760003560e01c806309a3c01b146100465780636337ed5814610064578063da96d05a14610094575b600080fd5b61004e6100c4565b60405161005b9190610424565b60405180910390f35b61007e600480360381019061007991906104bf565b610114565b60405161008b9190610424565b60405180910390f35b6100ae60048036038101906100a9919061050c565b610202565b6040516100bb9190610424565b60405180910390f35b606080306000826309a3c01b60e01b846040517f556f183000000000000000000000000000000000000000000000000000000000815260040161010b9594939291906107d5565b60405180910390fd5b606060008383810190610127919061096d565b90507fd9bdd1345ca2a00d0c1413137c1b2b1d0a35e5b0e11508f3b3eff856286af0758160405160200161015b91906109fd565b60405160208183030381529060405280519060200120146101b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101a890610a71565b60405180910390fd5b306000858563da96d05a60e01b88886040517f556f18300000000000000000000000000000000000000000000000000000000081526004016101f99796959493929190610abe565b60405180910390fd5b606060008585810190610215919061096d565b90507faed76f463930323372899e36460e078e5292aac45f645bbe567be6fca83ede108160405160200161024991906109fd565b604051602081830303815290604052805190602001201461029f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161029690610b9c565b60405180910390fd5b600084848101906102b0919061096d565b90507fd9bdd1345ca2a00d0c1413137c1b2b1d0a35e5b0e11508f3b3eff856286af075816040516020016102e491906109fd565b604051602081830303815290604052805190602001201461033a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161033190610c08565b60405180910390fd5b86868080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505092505050949350505050565b600081519050919050565b600082825260208201905092915050565b60005b838110156103c55780820151818401526020810190506103aa565b838111156103d4576000848401525b50505050565b6000601f19601f8301169050919050565b60006103f68261038b565b6104008185610396565b93506104108185602086016103a7565b610419816103da565b840191505092915050565b6000602082019050818103600083015261043e81846103eb565b905092915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f84011261047f5761047e61045a565b5b8235905067ffffffffffffffff81111561049c5761049b61045f565b5b6020830191508360018202830111156104b8576104b7610464565b5b9250929050565b600080602083850312156104d6576104d5610450565b5b600083013567ffffffffffffffff8111156104f4576104f3610455565b5b61050085828601610469565b92509250509250929050565b6000806000806040858703121561052657610525610450565b5b600085013567ffffffffffffffff81111561054457610543610455565b5b61055087828801610469565b9450945050602085013567ffffffffffffffff81111561057357610572610455565b5b61057f87828801610469565b925092505092959194509250565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006105b88261058d565b9050919050565b6105c8816105ad565b82525050565b600081549050919050565b600082825260208201905092915050565b60008190508160005260206000209050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061064657607f821691505b602082108103610659576106586105ff565b5b50919050565b600082825260208201905092915050565b60008190508160005260206000209050919050565b600081546106928161062e565b61069c818661065f565b945060018216600081146106b757600181146106c9576106fc565b60ff19831686526020860193506106fc565b6106d285610670565b60005b838110156106f4578154818901526001820191506020810190506106d5565b808801955050505b50505092915050565b60006107118383610685565b905092915050565b6000600182019050919050565b6000610731826105ce565b61073b81856105d9565b93508360208202850161074d856105ea565b8060005b85811015610788578484038952816107698582610705565b945061077483610719565b925060208a01995050600181019050610751565b50829750879550505050505092915050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6107cf8161079a565b82525050565b600060a0820190506107ea60008301886105bf565b81810360208301526107fc8187610726565b9050818103604083015261081081866103eb565b905061081f60608301856107c6565b818103608083015261083181846103eb565b90509695505050505050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61087a826103da565b810181811067ffffffffffffffff8211171561089957610898610842565b5b80604052505050565b60006108ac610446565b90506108b88282610871565b919050565b600067ffffffffffffffff8211156108d8576108d7610842565b5b6108e1826103da565b9050602081019050919050565b82818337600083830152505050565b600061091061090b846108bd565b6108a2565b90508281526020810184848401111561092c5761092b61083d565b5b6109378482856108ee565b509392505050565b600082601f8301126109545761095361045a565b5b81356109648482602086016108fd565b91505092915050565b60006020828403121561098357610982610450565b5b600082013567ffffffffffffffff8111156109a1576109a0610455565b5b6109ad8482850161093f565b91505092915050565b600081519050919050565b600081905092915050565b60006109d7826109b6565b6109e181856109c1565b93506109f18185602086016103a7565b80840191505092915050565b6000610a0982846109cc565b915081905092915050565b600082825260208201905092915050565b7f7465737420646174612076616c69646174696f6e206661696c65642e00000000600082015250565b6000610a5b601c83610a14565b9150610a6682610a25565b602082019050919050565b60006020820190508181036000830152610a8a81610a4e565b9050919050565b6000610a9d8385610396565b9350610aaa8385846108ee565b610ab3836103da565b840190509392505050565b600060a082019050610ad3600083018a6105bf565b8181036020830152610ae58189610726565b90508181036040830152610afa818789610a91565b9050610b0960608301866107c6565b8181036080830152610b1c818486610a91565b905098975050505050505050565b7f68747470207265717565737420726573756c742076616c69646174696f6e206660008201527f61696c65642e0000000000000000000000000000000000000000000000000000602082015250565b6000610b86602683610a14565b9150610b9182610b2a565b604082019050919050565b60006020820190508181036000830152610bb581610b79565b9050919050565b7f6578747261446174612076616c69646174696f6e206661696c65642e00000000600082015250565b6000610bf2601c83610a14565b9150610bfd82610bbc565b602082019050919050565b60006020820190508181036000830152610c2181610be5565b905091905056fea2646970667358221220528c32029f8724a4e2b6a2a469880824c952eae5971f18628559629192c102b164736f6c634300080d0033" # noqa: E501 -OFFCHAIN_LOOKUP_ABI = json.loads( - """[ - { - "inputs": [ - { - "internalType": "address", - "name": "sender", "type": "address" - }, - { - "internalType": "string[]", - "name": "urls", - "type": "string[]" - }, - { - "internalType": "bytes", - "name": "callData", - "type": "bytes"}, - { - "internalType": "bytes4", - "name": "callbackFunction", - "type":"bytes4" - }, - { - "internalType": "bytes", - "name": "extraData", - "type": "bytes" - } - ], - "name": "OffchainLookup", - "type": "error" - }, - { - "inputs": [], - "name": "continuousOffchainLookup", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type":"bytes" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "testOffchainLookupData", - "outputs": [ - { - "internalType": "bytes", - "name": "", "type": "bytes" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "specifiedDataFromTest", - "type": "bytes" - } - ], - "name": "testOffchainLookup", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "result", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "extraData", - "type": "bytes" - } - ], - "name": "testOffchainLookupWithProof", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } -]""" -) diff --git a/web3/_utils/module_testing/receive_contract.py b/web3/_utils/module_testing/receive_contract.py deleted file mode 100644 index fbc264b335..0000000000 --- a/web3/_utils/module_testing/receive_contract.py +++ /dev/null @@ -1,76 +0,0 @@ -CONTRACT_RECEIVE_FUNCTION_SOURCE = """ -pragma solidity ^0.6.0; - - -contract Receive { - string text; - - fallback() external payable { - text = 'fallback'; - } - - receive() external payable { - text = 'receive'; - } - - function getText() public view returns (string memory) { - return text; - } - - function setText(string memory new_text) public returns (string memory) { - return text = new_text; - } -} -""" - - -CONTRACT_RECEIVE_FUNCTION_ABI = """ -[ - { - "stateMutability": "payable", - "type": "fallback" - }, - { - "inputs": [], - "name": "getText", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "new_text", - "type": "string" - } - ], - "name": "setText", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "stateMutability": "payable", - "type": "receive" - } -] -""" - - -CONTRACT_RECEIVE_FUNCTION_CODE = "608060405234801561001057600080fd5b506103da806100206000396000f3fe60806040526004361061002d5760003560e01c80635d3a1f9d14610092578063e00fe2eb146101ba57610063565b3661006357604080518082019091526007808252667265636569766560c81b60209092019182526100609160009161030c565b50005b6040805180820190915260088082526766616c6c6261636b60c01b60209092019182526100609160009161030c565b34801561009e57600080fd5b50610145600480360360208110156100b557600080fd5b8101906020810181356401000000008111156100d057600080fd5b8201836020820111156100e257600080fd5b8035906020019184600183028401116401000000008311171561010457600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506101cf945050505050565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561017f578181015183820152602001610167565b50505050905090810190601f1680156101ac5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101c657600080fd5b50610145610275565b80516060906101e590600090602085019061030c565b805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156102695780601f1061023e57610100808354040283529160200191610269565b820191906000526020600020905b81548152906001019060200180831161024c57829003601f168201915b50505050509050919050565b60008054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156103015780601f106102d657610100808354040283529160200191610301565b820191906000526020600020905b8154815290600101906020018083116102e457829003601f168201915b505050505090505b90565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061034d57805160ff191683800117855561037a565b8280016001018555821561037a579182015b8281111561037a57825182559160200191906001019061035f565b5061038692915061038a565b5090565b61030991905b80821115610386576000815560010161039056fea2646970667358221220b93632f6dd6614e84675a1453e32b49de37a5d658a6e73173705c5a7dffc0bdd64736f6c63430006010033" # noqa: E501 - - -CONTRACT_RECEIVE_FUNCTION_RUNTIME = "60806040526004361061002d5760003560e01c80635d3a1f9d14610092578063e00fe2eb146101ba57610063565b3661006357604080518082019091526007808252667265636569766560c81b60209092019182526100609160009161030c565b50005b6040805180820190915260088082526766616c6c6261636b60c01b60209092019182526100609160009161030c565b34801561009e57600080fd5b50610145600480360360208110156100b557600080fd5b8101906020810181356401000000008111156100d057600080fd5b8201836020820111156100e257600080fd5b8035906020019184600183028401116401000000008311171561010457600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506101cf945050505050565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561017f578181015183820152602001610167565b50505050905090810190601f1680156101ac5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101c657600080fd5b50610145610275565b80516060906101e590600090602085019061030c565b805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156102695780601f1061023e57610100808354040283529160200191610269565b820191906000526020600020905b81548152906001019060200180831161024c57829003601f168201915b50505050509050919050565b60008054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156103015780601f106102d657610100808354040283529160200191610301565b820191906000526020600020905b8154815290600101906020018083116102e457829003601f168201915b505050505090505b90565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061034d57805160ff191683800117855561037a565b8280016001018555821561037a579182015b8281111561037a57825182559160200191906001019061035f565b5061038692915061038a565b5090565b61030991905b80821115610386576000815560010161039056fea2646970667358221220b93632f6dd6614e84675a1453e32b49de37a5d658a6e73173705c5a7dffc0bdd64736f6c63430006010033" # noqa: E501 diff --git a/web3/_utils/module_testing/revert_contract.py b/web3/_utils/module_testing/revert_contract.py deleted file mode 100644 index 3295d6375d..0000000000 --- a/web3/_utils/module_testing/revert_contract.py +++ /dev/null @@ -1,61 +0,0 @@ -import json - -REVERT_CONTRACT_SOURCE = """ -pragma solidity ^0.6.1; - -contract RevertContract { - function normalFunction() public pure returns (bool) { - return true; - } - - function revertWithMessage() public pure { - revert('Function has been reverted.'); - } - - function revertWithoutMessage() public pure { - revert(); - } -} -""" - - -REVERT_CONTRACT_BYTECODE = "608060405234801561001057600080fd5b50610123806100206000396000f3fe6080604052348015600f57600080fd5b5060043610603c5760003560e01c8063185c38a4146041578063c06a97cb146049578063d67e4b84146051575b600080fd5b60476071565b005b604f60df565b005b605760e4565b604051808215151515815260200191505060405180910390f35b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f46756e6374696f6e20686173206265656e2072657665727465642e000000000081525060200191505060405180910390fd5b600080fd5b6000600190509056fea264697066735822122062c811906544562ea796d11199e2d956938f2a76c2aa3053dc7ab2470d854c0a64736f6c63430006060033" # noqa: E501 - - -REVERT_CONTRACT_RUNTIME_CODE = "6080604052348015600f57600080fd5b5060043610603c5760003560e01c8063185c38a4146041578063c06a97cb146049578063d67e4b84146051575b600080fd5b60476071565b005b604f60df565b005b605760e4565b604051808215151515815260200191505060405180910390f35b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f46756e6374696f6e20686173206265656e2072657665727465642e000000000081525060200191505060405180910390fd5b600080fd5b6000600190509056fea264697066735822122062c811906544562ea796d11199e2d956938f2a76c2aa3053dc7ab2470d854c0a64736f6c63430006060033" # noqa: E501 - - -_REVERT_CONTRACT_ABI = json.loads( - """[ - { - "inputs": [], - "name": "normalFunction", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [], - "name": "revertWithMessage", - "outputs": [], - "payable": false, - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [], - "name": "revertWithoutMessage", - "outputs": [], - "payable": false, - "stateMutability": "pure", - "type": "function" - } -]""" -)