diff --git a/.circleci/config.yml b/.circleci/config.yml index 8eeb24f2f7..7aa1510bdd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,4 +1,4 @@ -version: 2.0 +version: 2.1 # heavily inspired by https://raw.githubusercontent.com/pinax/pinax-wiki/6bd2a99ab6f702e300d708532a6d1d9aa638b9f8/.circleci/config.yml @@ -116,7 +116,7 @@ ethpm_steps: ðpm_steps - checkout - restore_cache: keys: - - cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} + - ethpm-cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} - run: name: install ipfs command: @@ -142,10 +142,34 @@ ethpm_steps: ðpm_steps - .tox - ~/.cache/pip - ~/.local - - ./eggs - - ~/.ethash - - ~/.py-geth - key: cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} + key: ethpm-cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} + +orbs: + win: circleci/windows@2.2.0 + +windows_steps: &windows_steps + executor: + name: win/default + shell: bash.exe + working_directory: C:\Users\circleci\project\web3py + steps: + - checkout + - restore_cache: + keys: + - windows-cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} + - run: + name: checkout ethpm-spec submodule + command: git submodule update --init --recursive + - run: + name: install dependencies + command: pip install --user tox + - run: + name: run tox + command: 'C:/Users/circleci/AppData/Roaming/Python/Python37/Scripts/tox.exe -r' + - save_cache: + paths: + - .tox + key: windows-cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} jobs: @@ -189,29 +213,29 @@ jobs: # Please don't use this key for any shenanigans WEB3_INFURA_PROJECT_ID: 7707850c2fb7465ebe6f150d67182e22 - py36-integration-goethereum-ipc-1.9.19: + py36-integration-goethereum-ipc: <<: *geth_steps docker: - image: circleci/python:3.6 environment: TOXENV: py36-integration-goethereum-ipc - GETH_VERSION: v1.9.19 + GETH_VERSION: v1.10.1 - py36-integration-goethereum-http-1.9.19: + py36-integration-goethereum-http: <<: *geth_steps docker: - image: circleci/python:3.6 environment: TOXENV: py36-integration-goethereum-http - GETH_VERSION: v1.9.19 + GETH_VERSION: v1.10.1 - py36-integration-goethereum-ws-1.9.19: + py36-integration-goethereum-ws: <<: *geth_steps docker: - image: circleci/python:3.6 environment: TOXENV: py36-integration-goethereum-ws - GETH_VERSION: v1.9.19 + GETH_VERSION: v1.10.1 # py36-integration-parity-ipc: # <<: *parity_steps @@ -247,12 +271,14 @@ jobs: environment: TOXENV: py36-integration-ethtester ETHEREUM_TESTER_CHAIN_BACKEND: eth_tester.backends.PyEVMBackend + py36-wheel-cli: <<: *common docker: - image: circleci/python:3.6 - environment: - TOXENV: py36-wheel-cli + environment: + TOXENV: py36-wheel-cli + # # Python 3.7 # @@ -279,29 +305,29 @@ jobs: # Please don't use this key for any shenanigans WEB3_INFURA_PROJECT_ID: 7707850c2fb7465ebe6f150d67182e22 - py37-integration-goethereum-ipc-1.9.19: + py37-integration-goethereum-ipc: <<: *geth_steps docker: - image: circleci/python:3.7 environment: TOXENV: py37-integration-goethereum-ipc - GETH_VERSION: v1.9.19 + GETH_VERSION: v1.10.1 - py37-integration-goethereum-http-1.9.19: + py37-integration-goethereum-http: <<: *geth_steps docker: - image: circleci/python:3.7 environment: TOXENV: py37-integration-goethereum-http - GETH_VERSION: v1.9.19 + GETH_VERSION: v1.10.1 - py37-integration-goethereum-ws-1.9.19: + py37-integration-goethereum-ws: <<: *geth_steps docker: - image: circleci/python:3.7 environment: TOXENV: py37-integration-goethereum-ws - GETH_VERSION: v1.9.19 + GETH_VERSION: v1.10.1 # py37-integration-parity-ipc: # <<: *parity_steps @@ -337,12 +363,19 @@ jobs: environment: TOXENV: py37-integration-ethtester ETHEREUM_TESTER_CHAIN_BACKEND: eth_tester.backends.PyEVMBackend + py37-wheel-cli: <<: *common docker: - image: circleci/python:3.7 - environment: - TOXENV: py37-wheel-cli + environment: + TOXENV: py37-wheel-cli + + py37-wheel-cli-windows: + <<: *windows_steps + environment: + TOXENV: py37-wheel-cli-windows + # # Python 3.8 # @@ -369,29 +402,29 @@ jobs: # Please don't use this key for any shenanigans WEB3_INFURA_PROJECT_ID: 7707850c2fb7465ebe6f150d67182e22 - py38-integration-goethereum-ipc-1.9.19: + py38-integration-goethereum-ipc: <<: *geth_steps docker: - image: circleci/python:3.8 environment: TOXENV: py38-integration-goethereum-ipc - GETH_VERSION: v1.9.19 + GETH_VERSION: v1.10.1 - py38-integration-goethereum-http-1.9.19: + py38-integration-goethereum-http: <<: *geth_steps docker: - image: circleci/python:3.8 environment: TOXENV: py38-integration-goethereum-http - GETH_VERSION: v1.9.19 + GETH_VERSION: v1.10.1 - py38-integration-goethereum-ws-1.9.19: + py38-integration-goethereum-ws: <<: *geth_steps docker: - image: circleci/python:3.8 environment: TOXENV: py38-integration-goethereum-ws - GETH_VERSION: v1.9.19 + GETH_VERSION: v1.10.1 # py38-integration-parity-ipc: # <<: *parity_steps @@ -432,11 +465,11 @@ jobs: <<: *common docker: - image: circleci/python:3.8 - environment: - TOXENV: py38-wheel-cli + environment: + TOXENV: py38-wheel-cli workflows: - version: 2 + version: 2.1 test: jobs: # These are the longest running tests, start them first @@ -447,9 +480,9 @@ workflows: - docs - py36-ens - py36-ethpm - - py36-integration-goethereum-ipc-1.9.19 - - py36-integration-goethereum-http-1.9.19 - - py36-integration-goethereum-ws-1.9.19 + - py36-integration-goethereum-ipc + - py36-integration-goethereum-http + - py36-integration-goethereum-ws # - py36-integration-parity-ipc # - py36-integration-parity-http # - py36-integration-parity-ws @@ -457,19 +490,20 @@ workflows: - py36-wheel-cli - py37-ens - py37-ethpm - - py37-integration-goethereum-ipc-1.9.19 - - py37-integration-goethereum-http-1.9.19 - - py37-integration-goethereum-ws-1.9.19 + - py37-integration-goethereum-ipc + - py37-integration-goethereum-http + - py37-integration-goethereum-ws # - py37-integration-parity-ipc # - py37-integration-parity-http # - py37-integration-parity-ws - py37-integration-ethtester-pyevm - py37-wheel-cli + - py37-wheel-cli-windows - py38-ens - py38-ethpm - - py38-integration-goethereum-ipc-1.9.19 - - py38-integration-goethereum-http-1.9.19 - - py38-integration-goethereum-ws-1.9.19 + - py38-integration-goethereum-ipc + - py38-integration-goethereum-http + - py38-integration-goethereum-ws # - py38-integration-parity-ipc # - py38-integration-parity-http # - py38-integration-parity-ws diff --git a/docs/contracts.rst b/docs/contracts.rst index fb04470f10..3d83f12459 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -84,7 +84,7 @@ To run this example, you will need to install a few extra features: >>> tx_hash = Greeter.constructor().transact() # Wait for the transaction to be mined, and get the transaction receipt - >>> tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash) + >>> tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash) >>> greeter = w3.eth.contract( ... address=tx_receipt.contractAddress, @@ -95,7 +95,7 @@ To run this example, you will need to install a few extra features: 'Hello' >>> tx_hash = greeter.functions.setGreeting('Nihao').transact() - >>> tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash) + >>> tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash) >>> greeter.functions.greet().call() 'Nihao' @@ -686,7 +686,7 @@ Taking the following contract code as an example: >>> ArraysContract = w3.eth.contract(abi=abi, bytecode=bytecode) >>> tx_hash = ArraysContract.constructor([b'b']).transact() - >>> tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash) + >>> tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash) >>> array_contract = w3.eth.contract( ... address=tx_receipt.contractAddress, @@ -1069,7 +1069,7 @@ Event Log Object assert bob == '0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF', bob tx_hash = my_token_contract.constructor(1000000).transact({'from': alice, 'gas': 899000, 'gasPrice': 320000}) assert tx_hash == HexBytes('0x611aa2d5c3e51f08d0665c4529c5520ed32520d8a48ba2cf2aff3f2fce3f26e4'), tx_hash - txn_receipt = w3.eth.waitForTransactionReceipt(tx_hash) + txn_receipt = w3.eth.wait_for_transaction_receipt(tx_hash) assert txn_receipt['contractAddress'] == '0xF2E246BB76DF876Cef8b38ae84130F4F55De395b', txn_receipt['contractAddress'] contract_address = txn_receipt['contractAddress'] contract = w3.eth.contract(contract_address, abi=ABI) @@ -1077,7 +1077,7 @@ Event Log Object decimals = 10 ** 18 assert total_supply == 1000000 * decimals, total_supply tx_hash = contract.functions.transfer(alice, 10).transact({'gas': 899000, 'gasPrice': 200000}) - tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash) + tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash) .. doctest:: createFilter @@ -1096,7 +1096,7 @@ Event Log Object >>> transfer_filter.get_new_entries() [] >>> tx_hash = contract.functions.transfer(alice, 10).transact({'gas': 899000, 'gasPrice': 200000}) - >>> tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash) + >>> tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash) >>> transfer_filter.get_new_entries() [AttributeDict({'args': AttributeDict({'from': '0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf', 'to': '0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf', @@ -1173,7 +1173,7 @@ For example: 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"}]') contract = w3.eth.contract(abi=ABI, bytecode=bytecode) deploy_txn = contract.constructor().transact() - deploy_receipt = w3.eth.waitForTransactionReceipt(deploy_txn) + deploy_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) address = deploy_receipt.contractAddress .. doctest:: contractcaller diff --git a/docs/contributing.rst b/docs/contributing.rst index fc26fcda4f..9f0173048f 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -272,22 +272,28 @@ generated. Geth fixtures ^^^^^^^^^^^^^ -1. Install the desired Geth version on your machine locally. The Geth team only - explicitly supports the current version of their client at any given point, - so older versions are best installed via `py-geth`_. Note that ``py-geth`` - will need updating to support each new version as well. +1. Install the desired Geth version on your machine locally. We recommend `py-geth`_ for + this purpose, because it enables you to easily manage multiple versions of Geth. -2. Specify the Geth binary and run the fixture creation script: + Note that ``py-geth`` will need updating to support each new Geth version as well. + Add newer Geth version to py-geth is straightforward; see past commits for a template. + + If py-geth has the Geth version you need, install that version locally. For example: + + .. code:: sh + + $ python -m geth.install v1.10.1 + +2. Specify the Geth binary and run the fixture creation script (from within the web3.py directory): .. code:: sh - $ GETH_BINARY=/path/to/py-geth/bin python /tests/integration/generate_fixtures/go_ethereum.py /tests/integration/geth-X.Y.Z-fixture + $ GETH_BINARY=~/.py-geth/geth-v1.10.1/bin/geth python ./tests/integration/generate_fixtures/go_ethereum.py ./tests/integration/geth-1.10.1-fixture -3. The output of this script is your fixture, a zip file. Store the fixture in the - ``/tests/integration/`` directory and update the ``/tests/integration/go_ethereum/conftest.py`` - file to point to the new fixture. +3. The output of this script is your fixture, a zip file, which is now stored in ``/tests/integration/``. + Update the ``/tests/integration/go_ethereum/conftest.py`` file to point to this new fixture. Delete the old fixture. -4. Run the tests. To ensure that the tests run with the correct Geth version, +4. Run the tests. To ensure that the tests run with the correct Geth version locally, you may again include the ``GETH_BINARY`` environment variable. diff --git a/docs/ethpm.rst b/docs/ethpm.rst index aae46ab076..43ccd0f27f 100644 --- a/docs/ethpm.rst +++ b/docs/ethpm.rst @@ -109,13 +109,13 @@ LinkableContract >>> # Deploy SafeSendLib >>> SafeSendFactory = EscrowPackage.get_contract_factory("SafeSendLib") >>> safe_send_tx_hash = SafeSendFactory.constructor().transact() - >>> safe_send_tx_receipt = w3.eth.waitForTransactionReceipt(safe_send_tx_hash) + >>> safe_send_tx_receipt = w3.eth.wait_for_transaction_receipt(safe_send_tx_hash) >>> # Link Escrow factory to deployed SafeSendLib instance >>> LinkedEscrowFactory = EscrowFactory.link_bytecode({"SafeSendLib": safe_send_tx_receipt.contractAddress}) >>> assert LinkedEscrowFactory.needs_bytecode_linking is False >>> escrow_tx_hash = LinkedEscrowFactory.constructor(w3.eth.accounts[0]).transact() - >>> escrow_tx_receipt = w3.eth.waitForTransactionReceipt(escrow_tx_hash) + >>> escrow_tx_receipt = w3.eth.wait_for_transaction_receipt(escrow_tx_hash) >>> assert is_address(escrow_tx_receipt.contractAddress) diff --git a/docs/examples.rst b/docs/examples.rst index 442b1da719..0e6642cd19 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -339,7 +339,7 @@ The following example demonstrates a few things: if gas_estimate < 100000: print("Sending transaction to setVar(255)\n") tx_hash = store_var_contract.functions.setVar(255).transact() - receipt = w3.eth.waitForTransactionReceipt(tx_hash) + receipt = w3.eth.wait_for_transaction_receipt(tx_hash) print("Transaction receipt mined:") pprint.pprint(dict(receipt)) print("\nWas transaction successful?") @@ -466,7 +466,7 @@ contract which conforms to this standard. assert bob == '0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF', bob tx_hash = factory.constructor(1000000).transact({'from': alice, 'gas': 899000, 'gasPrice': 320000}) assert tx_hash == HexBytes('0x611aa2d5c3e51f08d0665c4529c5520ed32520d8a48ba2cf2aff3f2fce3f26e4'), tx_hash - txn_receipt = w3.eth.waitForTransactionReceipt(tx_hash) + txn_receipt = w3.eth.wait_for_transaction_receipt(tx_hash) assert txn_receipt['contractAddress'] == '0xF2E246BB76DF876Cef8b38ae84130F4F55De395b', txn_receipt['contractAddress'] contract_address = txn_receipt['contractAddress'] contract = w3.eth.contract(contract_address, abi=ABI) @@ -549,7 +549,7 @@ Next we can transfer some tokens from ``alice`` to ``bob`` using the contract's .. doctest:: >>> tx_hash = contract.functions.transfer(bob, 100).transact({'from': alice}) - >>> tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash) + >>> tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash) >>> contract.functions.balanceOf(alice).call() 999999999999999999999900 >>> contract.functions.balanceOf(bob).call() @@ -568,7 +568,7 @@ spend using the ``allowance`` function. >>> contract.functions.allowance(alice, bob).call() 0 >>> tx_hash = contract.functions.approve(bob, 200).transact({'from': alice}) - >>> tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash) + >>> tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash) >>> contract.functions.allowance(alice, bob).call() 200 @@ -586,7 +586,7 @@ When someone has an allowance they can transfer those tokens using the >>> contract.functions.balanceOf(bob).call() 100 >>> tx_hash = contract.functions.transferFrom(alice, bob, 75).transact({'from': bob}) - >>> tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash) + >>> tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash) >>> contract.functions.allowance(alice, bob).call() 125 >>> contract.functions.balanceOf(bob).call() @@ -658,13 +658,49 @@ And finally, send the transaction .. code-block:: python txn_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction) - txn_receipt = w3.eth.waitForTransactionReceipt(txn_hash) + txn_receipt = w3.eth.wait_for_transaction_receipt(txn_hash) Tip : afterwards you can use the value stored in ``txn_hash``, in an explorer like `etherscan`_ to view the transaction's details .. _etherscan: https://rinkeby.etherscan.io +Adjusting log levels +-------------------- + +Web3.py internally uses `Python logging subsystem `_. + +If you want to run your application logging in debug mode, below is an example of how to make some JSON-RPC traffic quieter. + +.. code-block:: python + + import logging + import coloredlogs + + def setup_logging(log_level=logging.DEBUG): + """Setup root logger and quiet some levels.""" + logger = logging.getLogger() + + # Set log format to dislay the logger name to hunt down verbose logging modules + fmt = "%(name)-25s %(levelname)-8s %(message)s" + + # Use colored logging output for console with the coloredlogs package + # https://pypi.org/project/coloredlogs/ + coloredlogs.install(level=log_level, fmt=fmt, logger=logger) + + # Disable logging of JSON-RPC requests and replies + logging.getLogger("web3.RequestManager").setLevel(logging.WARNING) + logging.getLogger("web3.providers.HTTPProvider").setLevel(logging.WARNING) + # logging.getLogger("web3.RequestManager").propagate = False + + # Disable all internal debug logging of requests and urllib3 + # E.g. HTTP traffic + logging.getLogger("requests").setLevel(logging.WARNING) + logging.getLogger("urllib3").setLevel(logging.WARNING) + + return logger + + Advanced example: Fetching all token transfer events ---------------------------------------------------- @@ -1114,8 +1150,8 @@ The script can be run with: ``python ./eventscanner.py `` logger.debug("Querying eth_getLogs with the following parameters: %s", event_filter_params) # Call JSON-RPC API on your Ethereum node. - # getLogs() returns raw AttributedDict entries - logs = web3.eth.getLogs(event_filter_params) + # get_logs() returns raw AttributedDict entries + logs = web3.eth.get_logs(event_filter_params) # Convert raw binary data to Python proxy objects as described by ABI all_events = [] diff --git a/docs/filters.rst b/docs/filters.rst index e7a6e4528a..390859f3d1 100644 --- a/docs/filters.rst +++ b/docs/filters.rst @@ -73,7 +73,7 @@ Filter Class Retrieve all entries for this filter. Logs will be retrieved using the - :func:`web3.eth.Eth.getFilterLogs` which returns all entries that match the given + :func:`web3.eth.Eth.get_filter_logs` which returns all entries that match the given filter. diff --git a/docs/gas_price.rst b/docs/gas_price.rst index fe4139aa1b..25e280a473 100644 --- a/docs/gas_price.rst +++ b/docs/gas_price.rst @@ -16,11 +16,11 @@ Retrieving gas price -------------------- To retreive the gas price using the selected strategy simply call -:meth:`~web3.eth.Eth.generateGasPrice` +:meth:`~web3.eth.Eth.generate_gas_price` .. code-block:: python - >>> Web3.eth.generateGasPrice() + >>> web3.eth.generate_gas_price() 20000000000 Creating a gas price strategy diff --git a/docs/overview.rst b/docs/overview.rst index b3c9baf318..891e9f77f1 100644 --- a/docs/overview.rst +++ b/docs/overview.rst @@ -175,12 +175,12 @@ API - :meth:`web3.eth.send_raw_transaction() ` - :meth:`web3.eth.replace_transaction() ` - :meth:`web3.eth.modify_transaction() ` -- :meth:`web3.eth.waitForTransactionReceipt() ` +- :meth:`web3.eth.wait_for_transaction_receipt() ` - :meth:`web3.eth.get_transaction_receipt() ` - :meth:`web3.eth.sign() ` -- :meth:`web3.eth.signTypedData() ` +- :meth:`web3.eth.sign_typed_data() ` - :meth:`web3.eth.estimateGas() ` -- :meth:`web3.eth.generateGasPrice() ` +- :meth:`web3.eth.generate_gas_price() ` - :meth:`web3.eth.setGasPriceStrategy() ` @@ -205,7 +205,7 @@ instance of the contract: >>> ExampleContract = w3.eth.contract(abi=abi, bytecode=bytecode) >>> tx_hash = ExampleContract.constructor().transact() - >>> tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash) + >>> tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash) >>> tx_receipt.contractAddress '0x8a22225eD7eD460D7ee3842bce2402B9deaD23D3' @@ -279,9 +279,9 @@ API - :meth:`web3.eth.filter() ` - :meth:`web3.eth.get_filter_changes() ` -- :meth:`web3.eth.getFilterLogs() ` -- :meth:`web3.eth.uninstallFilter() ` -- :meth:`web3.eth.getLogs() ` +- :meth:`web3.eth.get_filter_logs() ` +- :meth:`web3.eth.uninstall_filter() ` +- :meth:`web3.eth.get_logs() ` - :meth:`Contract.events.your_event_name.createFilter() ` - :meth:`Contract.events.your_event_name.build_filter() ` - :meth:`Filter.get_new_entries() ` diff --git a/docs/web3.eth.rst b/docs/web3.eth.rst index 2b1808b03e..fe457f5593 100644 --- a/docs/web3.eth.rst +++ b/docs/web3.eth.rst @@ -613,18 +613,18 @@ The following methods are available on the ``web3.eth`` namespace. .. warning:: Deprecated: This method is deprecated in favor of :attr:`~web3.eth.Eth.get_transaction_by_block` -.. py:method:: Eth.waitForTransactionReceipt(transaction_hash, timeout=120, poll_latency=0.1) +.. py:method:: Eth.wait_for_transaction_receipt(transaction_hash, timeout=120, poll_latency=0.1) Waits for the transaction specified by ``transaction_hash`` to be included in a block, then returns its transaction receipt. Optionally, specify a ``timeout`` in seconds. If timeout elapses before the transaction - is added to a block, then :meth:`~Eth.waitForTransactionReceipt` raises a + is added to a block, then :meth:`~Eth.wait_for_transaction_receipt` raises a :class:`web3.exceptions.TimeExhausted` exception. .. code-block:: python - >>> web3.eth.waitForTransactionReceipt('0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060') + >>> web3.eth.wait_for_transaction_receipt('0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060') # If transaction is not yet in a block, time passes, while the thread sleeps... # ... # Then when the transaction is added to a block, its receipt is returned: @@ -644,6 +644,11 @@ The following methods are available on the ``web3.eth`` namespace. }) +.. py:method:: Eth.waitForTransactionReceipt(transaction_hash, timeout=120, poll_latency=0.1) + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.eth.Eth.wait_for_transaction_receipt()` + .. py:method:: Eth.get_transaction_receipt(transaction_hash) * Delegates to ``eth_getTransactionReceipt`` RPC Method @@ -902,7 +907,7 @@ The following methods are available on the ``web3.eth`` namespace. '0x1a8bbe6eab8c72a219385681efefe565afd3accee35f516f8edf5ae82208fbd45a58f9f9116d8d88ba40fcd29076d6eada7027a3b412a9db55a0164547810cc401' -.. py:method:: Eth.signTypedData(account, jsonMessage) +.. py:method:: Eth.sign_typed_data(account, jsonMessage) * Delegates to ``eth_signTypedData`` RPC Method @@ -914,6 +919,10 @@ The following methods are available on the ``web3.eth`` namespace. ``account`` may be a checksum address or an ENS name +.. py:method:: Eth.signTypedData(account, jsonMessage) + + .. warning:: Deprecated: This property is deprecated in favor of + :meth:`~web3.eth.Eth.sign_typed_data()` .. py:method:: Eth.call(transaction, block_identifier=web3.eth.default_block) @@ -960,7 +969,7 @@ The following methods are available on the ``web3.eth`` namespace. nodes would result in an error like: ``ValueError: {'code': -32602, 'message': 'too many arguments, want at most 1'}`` -.. py:method:: Eth.generateGasPrice(transaction_params=None) +.. py:method:: Eth.generate_gas_price(transaction_params=None) Uses the selected gas price strategy to calculate a gas price. This method returns the gas price denominated in wei. @@ -970,13 +979,18 @@ The following methods are available on the ``web3.eth`` namespace. .. code-block:: python - >>> Web3.eth.generateGasPrice() + >>> web3.eth.generate_gas_price() 20000000000 .. note:: For information about how gas price can be customized in web3 see :ref:`Gas_Price`. +.. py:method:: Eth.generateGasPrice(transaction_params=None) + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.eth.Eth.generate_gas_price()` + .. py:method:: Eth.setGasPriceStrategy(gas_price_strategy) Set the selected gas price strategy. It must be a method of the signature @@ -1074,7 +1088,7 @@ with the filtering API. .. warning:: Deprecated: This property is deprecated in favor of :attr:`~web3.eth.Eth.get_filter_changes()` -.. py:method:: Eth.getFilterLogs(self, filter_id) +.. py:method:: Eth.get_filter_logs(self, filter_id) * Delegates to ``eth_getFilterLogs`` RPC Method. @@ -1083,7 +1097,7 @@ with the filtering API. .. code-block:: python >>> filt = web3.eth.filter() - >>> web3.eth.getFilterLogs(filt.filter_id) + >>> web3.eth.get_filter_logs(filt.filter_id) [ { 'address': '0xDc3A9Db694BCdd55EBaE4A89B22aC6D12b3F0c24', @@ -1101,7 +1115,13 @@ with the filtering API. ] -.. py:method:: Eth.uninstallFilter(self, filter_id) +.. py:method:: Eth.getFilterLogs(self, filter_id) + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.eth.Eth.get_filter_logs` + + +.. py:method:: Eth.uninstall_filter(self, filter_id) * Delegates to ``eth_uninstallFilter`` RPC Method. @@ -1111,43 +1131,60 @@ with the filtering API. .. code-block:: python >>> filt = web3.eth.filter() - >>> web3.eth.uninstallFilter(filt.filter_id) + >>> web3.eth.uninstall_filter(filt.filter_id) True - >>> web3.eth.uninstallFilter(filt.filter_id) + >>> web3.eth.uninstall_filter(filt.filter_id) False # already uninstalled. +.. py:method:: Eth.uninstallFilter(self, filter_id) -.. py:method:: Eth.getLogs(filter_params) + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.eth.Eth.uninstall_filter` + + +.. py:method:: Eth.get_logs(filter_params) This is the equivalent of: creating a new - filter, running :meth:`~Eth.getFilterLogs`, and then uninstalling the filter. See + filter, running :meth:`~Eth.get_filter_logs`, and then uninstalling the filter. See :meth:`~Eth.filter` for details on allowed filter parameters. +.. py:method:: Eth.getLogs(filter_params) -.. py:method:: Eth.submitHashrate(hashrate, nodeid) + .. warning:: Deprecated: This property is deprecated in favor of + :attr:`~web3.eth.Eth.get_logs()` + +.. py:method:: Eth.submit_hashrate(hashrate, nodeid) * Delegates to ``eth_submitHashrate`` RPC Method .. code-block:: python >>> node_id = '59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c' - >>> web3.eth.submitHashrate(5000, node_id) + >>> web3.eth.submit_hashrate(5000, node_id) True +.. py:method:: Eth.submitHashrate(hashrate, nodeid) -.. py:method:: Eth.submitWork(nonce, pow_hash, mix_digest) + .. warning:: Deprecated: This property is deprecated in favor of + :attr:`~web3.eth.Eth.submit_hashrate()` + +.. py:method:: Eth.submit_work(nonce, pow_hash, mix_digest) * Delegates to ``eth_submitWork`` RPC Method. .. code-block:: python - >>> web3.eth.submitWork( + >>> web3.eth.submit_work( 1, '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef', '0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000', ) True +.. py:method:: Eth.submitWork(nonce, pow_hash, mix_digest) + + .. warning:: Deprecated: This property is deprecated in favor of + :attr:`~web3.eth.Eth.submit_work()` Contracts --------- diff --git a/newsfragments/1887.misc.rst b/newsfragments/1887.misc.rst new file mode 100644 index 0000000000..aedecb6485 --- /dev/null +++ b/newsfragments/1887.misc.rst @@ -0,0 +1 @@ +Upgrade Geth test fixture to v1.10.1. diff --git a/newsfragments/1896.feature.rst b/newsfragments/1896.feature.rst new file mode 100644 index 0000000000..787744a006 --- /dev/null +++ b/newsfragments/1896.feature.rst @@ -0,0 +1 @@ +Add ``w3.eth.wait_for_transaction_receipt`` deprecate ``w3.eth.waitForTransactionReceipt`` diff --git a/newsfragments/1905.feature.rst b/newsfragments/1905.feature.rst new file mode 100644 index 0000000000..6a44121c61 --- /dev/null +++ b/newsfragments/1905.feature.rst @@ -0,0 +1 @@ +Add ``w3.eth.generate_gas_price`` deprecate ``w3.eth.generateGasPrice`` diff --git a/newsfragments/1907.misc.rst b/newsfragments/1907.misc.rst new file mode 100644 index 0000000000..a864b993fc --- /dev/null +++ b/newsfragments/1907.misc.rst @@ -0,0 +1 @@ +Add windows CI job diff --git a/newsfragments/1915.feature.rst b/newsfragments/1915.feature.rst new file mode 100644 index 0000000000..1982463ba4 --- /dev/null +++ b/newsfragments/1915.feature.rst @@ -0,0 +1 @@ +Add ``w3.eth.sign_typed_data`` deprecate ``w3.eth.signTypedData`` diff --git a/newsfragments/1919.feature.rst b/newsfragments/1919.feature.rst new file mode 100644 index 0000000000..93ba280894 --- /dev/null +++ b/newsfragments/1919.feature.rst @@ -0,0 +1 @@ +Add ``eth.get_filter_logs``, deprecate ``eth.getFilterLogs`` diff --git a/newsfragments/1920.feature.rst b/newsfragments/1920.feature.rst new file mode 100644 index 0000000000..8b29fd6e17 --- /dev/null +++ b/newsfragments/1920.feature.rst @@ -0,0 +1 @@ +Add ``eth.uninstall_filter``, deprecate ``eth.uninstallFilter`` diff --git a/newsfragments/1925.feature.rst b/newsfragments/1925.feature.rst new file mode 100644 index 0000000000..76931f8697 --- /dev/null +++ b/newsfragments/1925.feature.rst @@ -0,0 +1 @@ +Add ``w3.eth.get_logs`` deprecate ``w3.eth.getLogs`` diff --git a/newsfragments/1926.feature.rst b/newsfragments/1926.feature.rst new file mode 100644 index 0000000000..aa6d95baf5 --- /dev/null +++ b/newsfragments/1926.feature.rst @@ -0,0 +1 @@ +Add ``w3.eth.submit_hashrate`` deprecate ``w3.eth.submitHashrate`` diff --git a/newsfragments/1927.feature.rst b/newsfragments/1927.feature.rst new file mode 100644 index 0000000000..bc0d8fb393 --- /dev/null +++ b/newsfragments/1927.feature.rst @@ -0,0 +1 @@ +Add ``w3.eth.submit_work`` deprecate ``w3.eth.submitWork`` diff --git a/newsfragments/1928.doc.rst b/newsfragments/1928.doc.rst new file mode 100644 index 0000000000..6baa417761 --- /dev/null +++ b/newsfragments/1928.doc.rst @@ -0,0 +1 @@ +Add docs example for tuning log levels. diff --git a/newsfragments/1930.misc.rst b/newsfragments/1930.misc.rst new file mode 100644 index 0000000000..8a5b9b1fad --- /dev/null +++ b/newsfragments/1930.misc.rst @@ -0,0 +1 @@ +Removed the unsupported pypiwin32 in favor of the supported pywin32. diff --git a/setup.py b/setup.py index 17328ca80c..914b3cf73c 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ extras_require = { 'tester': [ "eth-tester[py-evm]==v0.5.0-beta.3", - "py-geth>=2.4.0,<3", + "py-geth>=3.0.0,<4", ], 'linter': [ "flake8==3.8.3", @@ -82,7 +82,7 @@ "jsonschema>=3.2.0,<4.0.0", "lru-dict>=1.1.6,<2.0.0", "protobuf>=3.10.0,<4", - "pypiwin32>=223;platform_system=='Windows'", + "pywin32>=223;platform_system=='Windows'", "requests>=2.16.0,<3.0.0", # remove typing_extensions after python_requires>=3.8, see web3._utils.compat "typing-extensions>=3.7.4.1,<4;python_version<'3.8'", diff --git a/tests/core/contracts/test_concise_contract.py b/tests/core/contracts/test_concise_contract.py index 4b926bec99..82cb5a3693 100644 --- a/tests/core/contracts/test_concise_contract.py +++ b/tests/core/contracts/test_concise_contract.py @@ -17,7 +17,7 @@ def deploy(web3, Contract, args=None): args = args or [] deploy_txn = Contract.constructor(*args).transact() - deploy_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None contract = Contract(address=deploy_receipt['contractAddress']) assert len(web3.eth.get_code(contract.address)) > 0 @@ -35,7 +35,7 @@ def zero_address_contract(web3, WithConstructorAddressArgumentsContract, EMPTY_A deploy_txn = WithConstructorAddressArgumentsContract.constructor( EMPTY_ADDR, ).transact() - deploy_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None _address_contract = WithConstructorAddressArgumentsContract( address=deploy_receipt['contractAddress'], diff --git a/tests/core/contracts/test_contract_ambiguous_functions.py b/tests/core/contracts/test_contract_ambiguous_functions.py index 6dd22f4717..dfbff370e5 100644 --- a/tests/core/contracts/test_contract_ambiguous_functions.py +++ b/tests/core/contracts/test_contract_ambiguous_functions.py @@ -42,7 +42,7 @@ @pytest.fixture() def string_contract(web3, StringContract, address_conversion_func): deploy_txn = StringContract.constructor("Caqalai").transact() - deploy_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + deploy_receipt = web3.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) diff --git a/tests/core/contracts/test_contract_buildTransaction.py b/tests/core/contracts/test_contract_buildTransaction.py index 18ade12c7f..24b3bb0b2d 100644 --- a/tests/core/contracts/test_contract_buildTransaction.py +++ b/tests/core/contracts/test_contract_buildTransaction.py @@ -14,7 +14,7 @@ @pytest.fixture() def math_contract(web3, MathContract, address_conversion_func): deploy_txn = MathContract.constructor().transact() - deploy_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None math_contract_address = address_conversion_func(deploy_receipt['contractAddress']) _math_contract = MathContract(address=math_contract_address) @@ -25,7 +25,7 @@ def math_contract(web3, MathContract, address_conversion_func): @pytest.fixture() def fallback_function_contract(web3, FallbackFunctionContract, address_conversion_func): deploy_txn = FallbackFunctionContract.constructor().transact() - deploy_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None fallback_contract_address = address_conversion_func(deploy_receipt['contractAddress']) _fallback_contract = FallbackFunctionContract(address=fallback_contract_address) @@ -36,7 +36,7 @@ def fallback_function_contract(web3, FallbackFunctionContract, address_conversio @pytest.fixture() def payable_tester_contract(web3, PayableTesterContract, address_conversion_func): deploy_txn = PayableTesterContract.constructor().transact() - deploy_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None payable_tester_address = address_conversion_func(deploy_receipt['contractAddress']) _payable_tester = PayableTesterContract(address=payable_tester_address) diff --git a/tests/core/contracts/test_contract_call_interface.py b/tests/core/contracts/test_contract_call_interface.py index 63c7c4d269..1c6b0d91d2 100644 --- a/tests/core/contracts/test_contract_call_interface.py +++ b/tests/core/contracts/test_contract_call_interface.py @@ -40,7 +40,7 @@ def deploy(web3, Contract, apply_func=identity, args=None): args = args or [] deploy_txn = Contract.constructor(*args).transact() - deploy_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None address = apply_func(deploy_receipt['contractAddress']) contract = Contract(address=address) @@ -159,7 +159,7 @@ def undeployed_math_contract(web3, MathContract, address_conversion_func): @pytest.fixture() def mismatched_math_contract(web3, StringContract, MathContract, address_conversion_func): deploy_txn = StringContract.constructor("Caqalai").transact() - deploy_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + deploy_receipt = web3.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) diff --git a/tests/core/contracts/test_contract_caller_interface.py b/tests/core/contracts/test_contract_caller_interface.py index ded00f7ca8..5a4ee96344 100644 --- a/tests/core/contracts/test_contract_caller_interface.py +++ b/tests/core/contracts/test_contract_caller_interface.py @@ -14,7 +14,7 @@ def deploy(web3, Contract, apply_func=identity, args=None): args = args or [] deploy_txn = Contract.constructor(*args).transact() - deploy_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None address = apply_func(deploy_receipt['contractAddress']) contract = Contract(address=address) diff --git a/tests/core/contracts/test_contract_constructor.py b/tests/core/contracts/test_contract_constructor.py index 075ce2b2be..b762853092 100644 --- a/tests/core/contracts/test_contract_constructor.py +++ b/tests/core/contracts/test_contract_constructor.py @@ -19,7 +19,7 @@ def test_contract_constructor_gas_estimate_no_constructor(web3, MathContract): gas_estimate = MathContract.constructor().estimateGas() deploy_txn = MathContract.constructor().transact() - txn_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) gas_used = txn_receipt.get('gasUsed') assert abs(gas_estimate - gas_used) < 21000 @@ -29,7 +29,7 @@ def test_contract_constructor_gas_estimate_with_block_id(web3, MathContract): block_identifier = None gas_estimate = MathContract.constructor().estimateGas(block_identifier=block_identifier) deploy_txn = MathContract.constructor().transact() - txn_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) gas_used = txn_receipt.get('gasUsed') assert abs(gas_estimate - gas_used) < 21000 @@ -41,7 +41,7 @@ def test_contract_constructor_gas_estimate_with_constructor_without_arguments( gas_estimate = SimpleConstructorContract.constructor().estimateGas() deploy_txn = SimpleConstructorContract.constructor().transact() - txn_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) gas_used = txn_receipt.get('gasUsed') assert abs(gas_estimate - gas_used) < 21000 @@ -66,7 +66,7 @@ def test_contract_constructor_gas_estimate_with_constructor_with_arguments( deploy_txn = WithConstructorArgumentsContract.constructor( *constructor_args, **constructor_kwargs).transact() - txn_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) gas_used = txn_receipt.get('gasUsed') assert abs(gas_estimate - gas_used) < 21000 @@ -81,7 +81,7 @@ def test_contract_constructor_gas_estimate_with_constructor_with_address_argumen deploy_txn = WithConstructorAddressArgumentsContract.constructor( address_conversion_func("0x16D9983245De15E7A9A73bC586E01FF6E08dE737")).transact() - txn_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) gas_used = txn_receipt.get('gasUsed') assert abs(gas_estimate - gas_used) < 21000 @@ -94,7 +94,7 @@ def test_contract_constructor_transact_no_constructor( address_conversion_func): deploy_txn = MathContract.constructor().transact() - txn_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) assert txn_receipt is not None assert txn_receipt['contractAddress'] @@ -111,7 +111,7 @@ def test_contract_constructor_transact_with_constructor_without_arguments( address_conversion_func): deploy_txn = SimpleConstructorContract.constructor().transact() - txn_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) assert txn_receipt is not None assert txn_receipt['contractAddress'] @@ -142,7 +142,7 @@ def test_contract_constructor_transact_with_constructor_with_arguments( deploy_txn = WithConstructorArgumentsContract.constructor( *constructor_args, **constructor_kwargs).transact() - txn_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) assert txn_receipt is not None assert txn_receipt['contractAddress'] @@ -162,7 +162,7 @@ def test_contract_constructor_transact_with_constructor_with_address_arguments( WITH_CONSTRUCTOR_ADDRESS_RUNTIME, address_conversion_func): deploy_txn = WithConstructorAddressArgumentsContract.constructor(TEST_ADDRESS).transact() - txn_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) assert txn_receipt is not None assert txn_receipt['contractAddress'] contract_address = address_conversion_func(txn_receipt['contractAddress']) diff --git a/tests/core/contracts/test_contract_deployment.py b/tests/core/contracts/test_contract_deployment.py index 420767f24d..deacf2eaa4 100644 --- a/tests/core/contracts/test_contract_deployment.py +++ b/tests/core/contracts/test_contract_deployment.py @@ -10,7 +10,7 @@ def test_contract_deployment_no_constructor(web3, MathContract, MATH_RUNTIME): deploy_txn = MathContract.constructor().transact() - txn_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) assert txn_receipt is not None assert txn_receipt['contractAddress'] @@ -25,7 +25,7 @@ def test_contract_deployment_with_constructor_without_args(web3, SIMPLE_CONSTRUCTOR_RUNTIME): deploy_txn = SimpleConstructorContract.constructor().transact() - txn_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) assert txn_receipt is not None assert txn_receipt['contractAddress'] @@ -44,7 +44,7 @@ def test_contract_deployment_with_constructor_with_arguments(web3, ): deploy_txn = WithConstructorArgumentsContract.constructor(1234, 'abcd').transact() - txn_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) assert txn_receipt is not None assert txn_receipt['contractAddress'] @@ -66,7 +66,7 @@ def test_contract_deployment_with_constructor_with_arguments_strict(w3_strict_ab 1234, constructor_arg ).transact() - txn_receipt = w3_strict_abi.eth.waitForTransactionReceipt(deploy_txn) + txn_receipt = w3_strict_abi.eth.wait_for_transaction_receipt(deploy_txn) assert txn_receipt is not None assert txn_receipt['contractAddress'] @@ -93,7 +93,7 @@ def test_contract_deployment_with_constructor_with_address_argument(web3, "0x16D9983245De15E7A9A73bC586E01FF6E08dE737", ).transact() - txn_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) assert txn_receipt is not None assert txn_receipt['contractAddress'] diff --git a/tests/core/contracts/test_contract_estimateGas.py b/tests/core/contracts/test_contract_estimateGas.py index 0dd768e1e8..e3226f02fa 100644 --- a/tests/core/contracts/test_contract_estimateGas.py +++ b/tests/core/contracts/test_contract_estimateGas.py @@ -23,7 +23,7 @@ def math_contract(web3, bytecode_runtime=MATH_RUNTIME, ) deploy_txn = MathContract.constructor().transact({'from': web3.eth.coinbase}) - deploy_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None contract_address = address_conversion_func(deploy_receipt['contractAddress']) @@ -47,7 +47,7 @@ def fallback_function_contract(web3, bytecode_runtime=FALLBACK_FUNCTION_RUNTIME ) deploy_txn = fallback_contract.constructor().transact({'from': web3.eth.coinbase}) - deploy_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None contract_address = address_conversion_func(deploy_receipt['contractAddress']) @@ -61,7 +61,7 @@ def fallback_function_contract(web3, @pytest.fixture() def payable_tester_contract(web3, PayableTesterContract, address_conversion_func): deploy_txn = PayableTesterContract.constructor().transact({'from': web3.eth.coinbase}) - deploy_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None payable_tester_address = address_conversion_func(deploy_receipt['contractAddress']) @@ -79,7 +79,7 @@ def test_contract_estimateGas(web3, math_contract, estimateGas, transact): contract=math_contract, contract_function='increment') - txn_receipt = web3.eth.waitForTransactionReceipt(txn_hash) + txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) gas_used = txn_receipt.get('gasUsed') assert abs(gas_estimate - gas_used) < 21000 @@ -90,7 +90,7 @@ def test_contract_fallback_estimateGas(web3, fallback_function_contract): txn_hash = fallback_function_contract.fallback.transact() - txn_receipt = web3.eth.waitForTransactionReceipt(txn_hash) + txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) gas_used = txn_receipt.get('gasUsed') assert abs(gas_estimate - gas_used) < 21000 @@ -105,7 +105,7 @@ def test_contract_estimateGas_with_arguments(web3, math_contract, estimateGas, t contract=math_contract, contract_function='add', func_args=[5, 6]) - txn_receipt = web3.eth.waitForTransactionReceipt(txn_hash) + txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) gas_used = txn_receipt.get('gasUsed') assert abs(gas_estimate - gas_used) < 21000 @@ -123,7 +123,7 @@ def test_estimateGas_not_sending_ether_to_nonpayable_function( contract=payable_tester_contract, contract_function='doNoValueCall') - txn_receipt = web3.eth.waitForTransactionReceipt(txn_hash) + txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) gas_used = txn_receipt.get('gasUsed') assert abs(gas_estimate - gas_used) < 21000 @@ -146,7 +146,7 @@ def test_estimateGas_accepts_latest_block(web3, math_contract, transact): contract=math_contract, contract_function='increment') - txn_receipt = web3.eth.waitForTransactionReceipt(txn_hash) + txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) gas_used = txn_receipt.get('gasUsed') assert abs(gas_estimate - gas_used) < 21000 @@ -154,7 +154,7 @@ def test_estimateGas_accepts_latest_block(web3, math_contract, transact): def test_estimateGas_block_identifier_unique_estimates(web3, math_contract, transact): txn_hash = transact(contract=math_contract, contract_function="increment") - web3.eth.waitForTransactionReceipt(txn_hash) + web3.eth.wait_for_transaction_receipt(txn_hash) latest_gas_estimate = math_contract.functions.counter().estimateGas( block_identifier="latest" diff --git a/tests/core/contracts/test_contract_example.py b/tests/core/contracts/test_contract_example.py index 43427e1561..60e1b05cf6 100644 --- a/tests/core/contracts/test_contract_example.py +++ b/tests/core/contracts/test_contract_example.py @@ -60,7 +60,7 @@ def foo_contract(eth_tester, w3): 'from': deploy_address, }) # wait for the transaction to be mined - tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash, 180) + tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash, 180) # instantiate and return an instance of our contract. return FooContract(tx_receipt.contractAddress) @@ -77,7 +77,7 @@ def test_can_update_greeting(w3, foo_contract): ).transact({ 'from': w3.eth.accounts[1], }) - w3.eth.waitForTransactionReceipt(tx_hash, 180) + w3.eth.wait_for_transaction_receipt(tx_hash, 180) # verify that the contract is now using the updated greeting hw = foo_contract.caller.bar() @@ -91,7 +91,7 @@ def test_updating_greeting_emits_event(w3, foo_contract): ).transact({ 'from': w3.eth.accounts[1], }) - receipt = w3.eth.waitForTransactionReceipt(tx_hash, 180) + receipt = w3.eth.wait_for_transaction_receipt(tx_hash, 180) # get all of the `barred` logs for the contract logs = foo_contract.events.barred.getLogs() diff --git a/tests/core/contracts/test_contract_init.py b/tests/core/contracts/test_contract_init.py index e2c0dd576a..cdf202205f 100644 --- a/tests/core/contracts/test_contract_init.py +++ b/tests/core/contracts/test_contract_init.py @@ -14,7 +14,7 @@ def math_addr(MathContract, address_conversion_func): web3 = MathContract.web3 deploy_txn = MathContract.constructor().transact({'from': web3.eth.coinbase}) - deploy_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None return address_conversion_func(deploy_receipt['contractAddress']) diff --git a/tests/core/contracts/test_contract_transact_interface.py b/tests/core/contracts/test_contract_transact_interface.py index 43c7337d46..f34037d285 100644 --- a/tests/core/contracts/test_contract_transact_interface.py +++ b/tests/core/contracts/test_contract_transact_interface.py @@ -20,7 +20,7 @@ def deploy(web3, Contract, apply_func=identity, args=None): args = args or [] deploy_txn = Contract.constructor(*args).transact() - deploy_receipt = web3.eth.waitForTransactionReceipt(deploy_txn) + deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None address = apply_func(deploy_receipt['contractAddress']) contract = Contract(address=address) @@ -71,7 +71,7 @@ def test_transacting_with_contract_no_arguments(web3, math_contract, transact, c txn_hash = transact(contract=math_contract, contract_function='increment') - txn_receipt = web3.eth.waitForTransactionReceipt(txn_hash) + txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) assert txn_receipt is not None final_value = call(contract=math_contract, @@ -91,7 +91,7 @@ def test_transact_not_sending_ether_to_nonpayable_function( assert initial_value is False txn_hash = transact(contract=payable_tester_contract, contract_function='doNoValueCall') - txn_receipt = web3.eth.waitForTransactionReceipt(txn_hash) + txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) assert txn_receipt is not None final_value = call(contract=payable_tester_contract, @@ -113,7 +113,7 @@ def test_transact_sending_ether_to_nonpayable_function( txn_hash = transact(contract=payable_tester_contract, contract_function='doNoValueCall', tx_params={'value': 1}) - txn_receipt = web3.eth.waitForTransactionReceipt(txn_hash) + txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) assert txn_receipt is not None final_value = call(contract=payable_tester_contract, @@ -143,7 +143,7 @@ def test_transacting_with_contract_with_arguments(web3, func_args=transact_args, func_kwargs=transact_kwargs) - txn_receipt = web3.eth.waitForTransactionReceipt(txn_hash) + txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) assert txn_receipt is not None final_value = call(contract=math_contract, @@ -161,7 +161,7 @@ def test_deploy_when_default_account_is_set(web3, StringContract = web3.eth.contract(**STRING_CONTRACT) deploy_txn = StringContract.constructor("Caqalai").transact() - web3.eth.waitForTransactionReceipt(deploy_txn) + web3.eth.wait_for_transaction_receipt(deploy_txn) txn_after = web3.eth.get_transaction(deploy_txn) assert txn_after['from'] == web3.eth.default_account @@ -186,7 +186,7 @@ def test_transacting_with_contract_with_string_argument(web3, string_contract, t txn_hash = transact(contract=string_contract, contract_function='setValue', func_args=["ÄLÄMÖLÖ".encode('utf8')]) - txn_receipt = web3.eth.waitForTransactionReceipt(txn_hash) + txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) assert txn_receipt is not None final_value = call(contract=string_contract, @@ -208,7 +208,7 @@ def test_transacting_with_contract_with_bytes32_array_argument(web3, txn_hash = transact(contract=arrays_contract, contract_function="setBytes32Value", func_args=[new_bytes32_array]) - txn_receipt = web3.eth.waitForTransactionReceipt(txn_hash) + txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) assert txn_receipt is not None final_value = call(contract=arrays_contract, @@ -221,7 +221,7 @@ def test_transacting_with_contract_with_byte_array_argument(web3, arrays_contrac txn_hash = transact(contract=arrays_contract, contract_function='setByteValue', func_args=[new_byte_array]) - txn_receipt = web3.eth.waitForTransactionReceipt(txn_hash) + txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) assert txn_receipt is not None final_value = call(contract=arrays_contract, @@ -242,7 +242,7 @@ def test_transacting_with_contract_respects_explicit_gas(web3, StringContract = web3.eth.contract(**STRING_CONTRACT) deploy_txn = StringContract.constructor("Caqalai").transact() - deploy_receipt = web3.eth.waitForTransactionReceipt(deploy_txn, 30) + deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn, 30) assert deploy_receipt is not None string_contract = StringContract(address=deploy_receipt['contractAddress']) @@ -252,7 +252,7 @@ def test_transacting_with_contract_respects_explicit_gas(web3, contract_function='setValue', func_args=[to_bytes(text="ÄLÄMÖLÖ")], tx_kwargs={'gas': 200000}) - txn_receipt = web3.eth.waitForTransactionReceipt(txn_hash, 30) + txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash, 30) assert txn_receipt is not None final_value = call(contract=string_contract, @@ -276,7 +276,7 @@ def test_auto_gas_computation_when_transacting(web3, StringContract = web3.eth.contract(**STRING_CONTRACT) deploy_txn = StringContract.constructor("Caqalai").transact() - deploy_receipt = web3.eth.waitForTransactionReceipt(deploy_txn, 30) + deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn, 30) assert deploy_receipt is not None string_contract = StringContract(address=deploy_receipt['contractAddress']) @@ -287,7 +287,7 @@ def test_auto_gas_computation_when_transacting(web3, txn_hash = transact(contract=string_contract, contract_function="setValue", func_args=[to_bytes(text="ÄLÄMÖLÖ")]) - txn_receipt = web3.eth.waitForTransactionReceipt(txn_hash, 30) + txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash, 30) assert txn_receipt is not None final_value = call(contract=string_contract, @@ -302,7 +302,7 @@ def test_fallback_transacting_with_contract(web3, fallback_function_contract, ca initial_value = call(contract=fallback_function_contract, contract_function='getData') txn_hash = fallback_function_contract.fallback.transact() - txn_receipt = web3.eth.waitForTransactionReceipt(txn_hash) + txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) assert txn_receipt is not None final_value = call(contract=fallback_function_contract, diff --git a/tests/core/contracts/test_extracting_event_data.py b/tests/core/contracts/test_extracting_event_data.py index 8bdb726863..f503986985 100644 --- a/tests/core/contracts/test_extracting_event_data.py +++ b/tests/core/contracts/test_extracting_event_data.py @@ -32,7 +32,7 @@ def Emitter(web3, EMITTER): def emitter(web3, Emitter, wait_for_transaction, wait_for_block, address_conversion_func): wait_for_block(web3) deploy_txn_hash = Emitter.constructor().transact({'from': web3.eth.coinbase, 'gas': 1000000}) - deploy_receipt = web3.eth.waitForTransactionReceipt(deploy_txn_hash) + deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn_hash) contract_address = address_conversion_func(deploy_receipt['contractAddress']) bytecode = web3.eth.get_code(contract_address) diff --git a/tests/core/contracts/test_extracting_event_data_old.py b/tests/core/contracts/test_extracting_event_data_old.py index 7fa4b56ed1..f3e0905f0a 100644 --- a/tests/core/contracts/test_extracting_event_data_old.py +++ b/tests/core/contracts/test_extracting_event_data_old.py @@ -18,7 +18,7 @@ def Emitter(web3, EMITTER): def emitter(web3, Emitter, wait_for_transaction, wait_for_block, address_conversion_func): wait_for_block(web3) deploy_txn_hash = Emitter.constructor().transact({'from': web3.eth.coinbase, 'gas': 1000000}) - deploy_receipt = web3.eth.waitForTransactionReceipt(deploy_txn_hash) + deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn_hash) contract_address = address_conversion_func(deploy_receipt['contractAddress']) bytecode = web3.eth.get_code(contract_address) diff --git a/tests/core/contracts/test_implicit_contract.py b/tests/core/contracts/test_implicit_contract.py index 2bc709a8fb..6701c0f175 100644 --- a/tests/core/contracts/test_implicit_contract.py +++ b/tests/core/contracts/test_implicit_contract.py @@ -19,7 +19,7 @@ def math_contract(web3, MATH_ABI, MATH_CODE, MATH_RUNTIME, address_conversion_fu bytecode_runtime=MATH_RUNTIME, ) tx_hash = MathContract.constructor().transact() - tx_receipt = web3.eth.waitForTransactionReceipt(tx_hash) + tx_receipt = web3.eth.wait_for_transaction_receipt(tx_hash) math_address = address_conversion_func(tx_receipt['contractAddress']) # Return interactive contract instance at deployed address # TODO Does parent class not implement 'deploy()' for a reason? diff --git a/tests/core/eth-module/test_gas_pricing.py b/tests/core/eth-module/test_gas_pricing.py index 550f620d20..b9ab957476 100644 --- a/tests/core/eth-module/test_gas_pricing.py +++ b/tests/core/eth-module/test_gas_pricing.py @@ -14,14 +14,21 @@ def test_get_set_gasPrice(web3): def test_no_gas_price_strategy_returns_none(web3): - assert web3.eth.generateGasPrice() is None + assert web3.eth.generate_gas_price() is None + + +def test_generateGasPrice_deprecated(web3): + with pytest.warns(DeprecationWarning, + match='generateGasPrice is deprecated in favor of generate_gas_price'): + gas_price = web3.eth.generateGasPrice() + assert gas_price is None def test_set_gas_price_strategy(web3): def my_gas_price_strategy(web3, transaction_params): return 5 web3.eth.setGasPriceStrategy(my_gas_price_strategy) - assert web3.eth.generateGasPrice() == 5 + assert web3.eth.generate_gas_price() == 5 def test_gas_price_strategy_calls(web3): @@ -31,5 +38,5 @@ def test_gas_price_strategy_calls(web3): } my_gas_price_strategy = Mock(return_value=5) web3.eth.setGasPriceStrategy(my_gas_price_strategy) - assert web3.eth.generateGasPrice(transaction) == 5 + assert web3.eth.generate_gas_price(transaction) == 5 my_gas_price_strategy.assert_called_once_with(web3, transaction) diff --git a/tests/core/eth-module/test_transactions.py b/tests/core/eth-module/test_transactions.py index 412a1f70eb..cbdc7b927d 100644 --- a/tests/core/eth-module/test_transactions.py +++ b/tests/core/eth-module/test_transactions.py @@ -36,7 +36,7 @@ def test_send_transaction_with_valid_chain_id(web3, make_chain_id, expect_succes } if expect_success: txn_hash = web3.eth.send_transaction(transaction) - receipt = web3.eth.waitForTransactionReceipt(txn_hash, timeout=RECEIPT_TIMEOUT) + receipt = web3.eth.wait_for_transaction_receipt(txn_hash, timeout=RECEIPT_TIMEOUT) assert receipt.get('blockNumber') is not None else: with pytest.raises(ValidationError) as exc_info: @@ -84,13 +84,13 @@ def test_send_transaction_with_ens_names(web3): } txn_hash = web3.eth.send_transaction(transaction) - receipt = web3.eth.waitForTransactionReceipt(txn_hash, timeout=RECEIPT_TIMEOUT) + receipt = web3.eth.wait_for_transaction_receipt(txn_hash, timeout=RECEIPT_TIMEOUT) assert receipt.get('blockNumber') is not None def test_wait_for_missing_receipt(web3): with pytest.raises(TimeExhausted): - web3.eth.waitForTransactionReceipt(b'\0' * 32, timeout=RECEIPT_TIMEOUT) + web3.eth.wait_for_transaction_receipt(b'\0' * 32, timeout=RECEIPT_TIMEOUT) def test_unmined_transaction_wait_for_receipt(web3): @@ -103,6 +103,6 @@ def test_unmined_transaction_wait_for_receipt(web3): with pytest.raises(TransactionNotFound): web3.eth.get_transaction_receipt(txn_hash) - txn_receipt = web3.eth.waitForTransactionReceipt(txn_hash) + txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) assert txn_receipt['transactionHash'] == txn_hash assert txn_receipt['blockHash'] is not None diff --git a/tests/core/gas-strategies/test_time_based_gas_price_strategy.py b/tests/core/gas-strategies/test_time_based_gas_price_strategy.py index 14908876cb..721302b3fb 100644 --- a/tests/core/gas-strategies/test_time_based_gas_price_strategy.py +++ b/tests/core/gas-strategies/test_time_based_gas_price_strategy.py @@ -164,7 +164,7 @@ def test_time_based_gas_price_strategy(strategy_params, expected): **strategy_params, ) w3.eth.setGasPriceStrategy(time_based_gas_price_strategy) - actual = w3.eth.generateGasPrice() + actual = w3.eth.generate_gas_price() assert actual == expected @@ -217,5 +217,5 @@ def test_time_based_gas_price_strategy_zero_sample(strategy_params_zero, **strategy_params_zero, ) w3.eth.setGasPriceStrategy(time_based_gas_price_strategy_zero) - w3.eth.generateGasPrice() + w3.eth.generate_gas_price() assert str(excinfo.value) == expected_exception_message diff --git a/tests/core/middleware/test_filter_middleware.py b/tests/core/middleware/test_filter_middleware.py index 7046be111b..b81a1476e0 100644 --- a/tests/core/middleware/test_filter_middleware.py +++ b/tests/core/middleware/test_filter_middleware.py @@ -155,7 +155,7 @@ def test_local_filter_middleware(w3, iter_block_number): results = w3.eth.get_filter_changes(log_filter.filter_id) assert results == FILTER_LOG - assert w3.eth.getFilterLogs(log_filter.filter_id) == FILTER_LOG + assert w3.eth.get_filter_logs(log_filter.filter_id) == FILTER_LOG filter_ids = ( block_filter.filter_id, diff --git a/tests/core/middleware/test_gas_price_strategy.py b/tests/core/middleware/test_gas_price_strategy.py index 106e5363c5..14bb9bd8c4 100644 --- a/tests/core/middleware/test_gas_price_strategy.py +++ b/tests/core/middleware/test_gas_price_strategy.py @@ -18,14 +18,14 @@ def the_gas_price_strategy_middleware(web3): def test_gas_price_generated(the_gas_price_strategy_middleware): - the_gas_price_strategy_middleware.web3.eth.generateGasPrice.return_value = 5 + the_gas_price_strategy_middleware.web3.eth.generate_gas_price.return_value = 5 method = 'eth_sendTransaction' params = [{ 'to': '0x0', 'value': 1, }] the_gas_price_strategy_middleware(method, params) - the_gas_price_strategy_middleware.web3.eth.generateGasPrice.assert_called_once_with({ + the_gas_price_strategy_middleware.web3.eth.generate_gas_price.assert_called_once_with({ 'to': '0x0', 'value': 1, }) @@ -37,7 +37,7 @@ def test_gas_price_generated(the_gas_price_strategy_middleware): def test_gas_price_not_overridden(the_gas_price_strategy_middleware): - the_gas_price_strategy_middleware.web3.eth.generateGasPrice.return_value = 5 + the_gas_price_strategy_middleware.web3.eth.generate_gas_price.return_value = 5 method = 'eth_sendTransaction' params = [{ 'to': '0x0', @@ -53,7 +53,7 @@ def test_gas_price_not_overridden(the_gas_price_strategy_middleware): def test_gas_price_not_set_without_gas_price_strategy(the_gas_price_strategy_middleware): - the_gas_price_strategy_middleware.web3.eth.generateGasPrice.return_value = None + the_gas_price_strategy_middleware.web3.eth.generate_gas_price.return_value = None method = 'eth_sendTransaction' params = [{ 'to': '0x0', diff --git a/tests/core/pm-module/test_pm_init.py b/tests/core/pm-module/test_pm_init.py index ea234ae91f..6a8bfc33ea 100644 --- a/tests/core/pm-module/test_pm_init.py +++ b/tests/core/pm-module/test_pm_init.py @@ -34,7 +34,7 @@ def test_get_contract_factory_with_valid_owned_manifest(w3): owned_package = w3.pm.get_package_from_manifest(owned_manifest) owned_factory = owned_package.get_contract_factory('Owned') tx_hash = owned_factory.constructor().transact() - tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash) + tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash) owned_address = tx_receipt.contractAddress owned_instance = owned_package.get_contract_instance("Owned", owned_address) assert owned_instance.abi == owned_factory.abi @@ -45,7 +45,7 @@ def test_get_contract_factory_with_valid_safe_math_lib_manifest(w3): safe_math_package = w3.pm.get_package_from_manifest(safe_math_lib_manifest) safe_math_factory = safe_math_package.get_contract_factory("SafeMathLib") tx_hash = safe_math_factory.constructor().transact() - tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash) + tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash) safe_math_address = tx_receipt.contractAddress safe_math_instance = safe_math_package.get_contract_instance("SafeMathLib", safe_math_address) assert safe_math_instance.functions.safeAdd(1, 2).call() == 3 @@ -58,12 +58,12 @@ def test_get_contract_factory_with_valid_escrow_manifest(w3): assert escrow_factory.needs_bytecode_linking safe_send_factory = escrow_package.get_contract_factory('SafeSendLib') safe_send_tx_hash = safe_send_factory.constructor().transact() - safe_send_tx_receipt = w3.eth.waitForTransactionReceipt(safe_send_tx_hash) + safe_send_tx_receipt = w3.eth.wait_for_transaction_receipt(safe_send_tx_hash) safe_send_address = safe_send_tx_receipt.contractAddress linked_escrow_factory = escrow_factory.link_bytecode({"SafeSendLib": safe_send_address}) assert linked_escrow_factory.needs_bytecode_linking is False escrow_tx_hash = linked_escrow_factory.constructor(w3.eth.accounts[0]).transact() - escrow_tx_receipt = w3.eth.waitForTransactionReceipt(escrow_tx_hash) + escrow_tx_receipt = w3.eth.wait_for_transaction_receipt(escrow_tx_hash) escrow_address = escrow_tx_receipt.contractAddress escrow_instance = linked_escrow_factory(address=escrow_address) assert escrow_instance.functions.sender().call() == w3.eth.accounts[0] diff --git a/tests/core/tools/pytest_ethereum/test_linker.py b/tests/core/tools/pytest_ethereum/test_linker.py index ca14194664..97514bc082 100644 --- a/tests/core/tools/pytest_ethereum/test_linker.py +++ b/tests/core/tools/pytest_ethereum/test_linker.py @@ -62,7 +62,7 @@ def test_linker_with_callback(escrow_deployer, w3): def callback_fn(package): escrow_instance = package.deployments.get_instance("Escrow") tx_hash = escrow_instance.functions.releaseFunds().transact({"from": sender}) - w3.eth.waitForTransactionReceipt(tx_hash) + w3.eth.wait_for_transaction_receipt(tx_hash) escrow_strategy = linker( deploy("SafeSendLib", transaction={"from": sender}), diff --git a/tests/ens/conftest.py b/tests/ens/conftest.py index 16e8e92d7e..88c58cd2f6 100644 --- a/tests/ens/conftest.py +++ b/tests/ens/conftest.py @@ -45,7 +45,7 @@ def deploy(w3, Factory, from_address, args=None): args = args or [] factory = Factory(w3) deploy_txn = factory.constructor(*args).transact({'from': from_address}) - deploy_receipt = w3.eth.waitForTransactionReceipt(deploy_txn) + deploy_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None return factory(address=deploy_receipt['contractAddress']) diff --git a/tests/ethpm/integration/test_escrow_manifest.py b/tests/ethpm/integration/test_escrow_manifest.py index 62b4004140..15d13e29c5 100644 --- a/tests/ethpm/integration/test_escrow_manifest.py +++ b/tests/ethpm/integration/test_escrow_manifest.py @@ -38,7 +38,7 @@ def test_deployed_escrow_and_safe_send(escrow_manifest, w3): escrow_tx_hash = LinkedEscrowFactory.constructor( "0x4F5B11c860b37b68DE6D14Fb7e7b5f18A9A1bdC0" ).transact() - escrow_tx_receipt = w3.eth.waitForTransactionReceipt(escrow_tx_hash) + escrow_tx_receipt = w3.eth.wait_for_transaction_receipt(escrow_tx_hash) escrow_address = escrow_tx_receipt.contractAddress # Cannot deploy with an unlinked factory diff --git a/tests/ethpm/test_package.py b/tests/ethpm/test_package.py index 8dab04a030..1202b54715 100644 --- a/tests/ethpm/test_package.py +++ b/tests/ethpm/test_package.py @@ -24,7 +24,7 @@ def safe_math_package(get_manifest, w3): def deployed_safe_math(safe_math_package, w3): SafeMath = safe_math_package.get_contract_factory("SafeMathLib") tx_hash = SafeMath.constructor().transact() - tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash) + tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash) return safe_math_package, tx_receipt.contractAddress diff --git a/tests/integration/generate_fixtures/go_ethereum.py b/tests/integration/generate_fixtures/go_ethereum.py index 8b528c0462..41ff0682e0 100644 --- a/tests/integration/generate_fixtures/go_ethereum.py +++ b/tests/integration/generate_fixtures/go_ethereum.py @@ -74,7 +74,7 @@ def get_geth_process(geth_binary, '--gcmode', 'archive', '--nodiscover', '--port', geth_port, - '--etherbase', common.COINBASE[2:], + '--miner.etherbase', common.COINBASE[2:], ) popen_proc = subprocess.Popen( @@ -167,7 +167,7 @@ def generate_go_ethereum_fixture(destination_dir): def verify_chain_state(web3, chain_data): - receipt = web3.eth.waitForTransactionReceipt(chain_data['mined_txn_hash']) + receipt = web3.eth.wait_for_transaction_receipt(chain_data['mined_txn_hash']) latest = web3.eth.get_block('latest') assert receipt.blockNumber <= latest.number @@ -175,7 +175,7 @@ def verify_chain_state(web3, chain_data): def mine_transaction_hash(web3, txn_hash): web3.geth.miner.start(1) try: - return web3.eth.waitForTransactionReceipt(txn_hash, timeout=120) + return web3.eth.wait_for_transaction_receipt(txn_hash, timeout=120) finally: web3.geth.miner.stop() diff --git a/tests/integration/geth-1.10.1-fixture.zip b/tests/integration/geth-1.10.1-fixture.zip new file mode 100644 index 0000000000..f762086ed2 Binary files /dev/null and b/tests/integration/geth-1.10.1-fixture.zip differ diff --git a/tests/integration/geth-1.9.19-fixture.zip b/tests/integration/geth-1.9.19-fixture.zip deleted file mode 100644 index 16a515e6a5..0000000000 Binary files a/tests/integration/geth-1.9.19-fixture.zip and /dev/null differ diff --git a/tests/integration/go_ethereum/common.py b/tests/integration/go_ethereum/common.py index 586e55d479..ff747167dd 100644 --- a/tests/integration/go_ethereum/common.py +++ b/tests/integration/go_ethereum/common.py @@ -20,9 +20,14 @@ def _check_web3_clientVersion(self, client_version): class GoEthereumEthModuleTest(EthModuleTest): @pytest.mark.xfail(reason='eth_submitHashrate deprecated in 1.8.22 for ethash_submitHashRate') - def test_eth_submitHashrate(self, web3): + def test_eth_submit_hashrate(self, web3): # https://github.com/ethereum/go-ethereum/commit/51db5975cc5fb88db6a0dba1826b534fd4df29d7 - super().test_eth_submitHashrate(web3) + super().test_eth_submit_hashrate(web3) + + @pytest.mark.xfail(reason='eth_submitHashrate deprecated in 1.8.22 for ethash_submitHashRate') + def test_eth_submitHashrate_deprecated(self, web3): + # https://github.com/ethereum/go-ethereum/commit/51db5975cc5fb88db6a0dba1826b534fd4df29d7 + super().test_eth_submitHashrate_deprecated(web3) @pytest.mark.xfail( strict=False, @@ -34,33 +39,35 @@ def test_eth_replace_transaction_already_mined(self, web3, unlocked_account_dual super().test_eth_replace_transaction_already_mined(web3, unlocked_account_dual_type) web3.geth.miner.stop() - @pytest.mark.xfail(reason='Block identifier has not been implemented in geth') - def test_eth_estimateGas_with_block(self, - web3, - unlocked_account_dual_type): - super().test_eth_estimateGas_with_block( - web3, unlocked_account_dual_type - ) + @pytest.mark.xfail(reason='eth_signTypedData has not been released in geth') + def test_eth_sign_typed_data(self, web3, unlocked_account_dual_type): + super().test_eth_sign_typed_data(web3, unlocked_account_dual_type) @pytest.mark.xfail(reason='eth_signTypedData has not been released in geth') - def test_eth_signTypedData(self, - web3, - unlocked_account_dual_type): - super().test_eth_signTypedData( - web3, unlocked_account_dual_type - ) + def test_eth_signTypedData_deprecated(self, web3, unlocked_account_dual_type): + super().test_eth_signTypedData_deprecated(web3, unlocked_account_dual_type) @pytest.mark.xfail(reason='eth_signTypedData has not been released in geth') - def test_invalid_eth_signTypedData(self, - web3, - unlocked_account_dual_type): - super().test_invalid_eth_signTypedData( - web3, unlocked_account_dual_type - ) + def test_invalid_eth_sign_typed_data(self, web3, unlocked_account_dual_type): + super().test_invalid_eth_sign_typed_data(web3, unlocked_account_dual_type) + + @pytest.mark.xfail(reason='eth_protocolVersion was removed in Geth 1.10.0') + def test_eth_protocol_version(self, web3): + super().test_eth_protocol_version(web3) + + @pytest.mark.xfail(reason='eth_protocolVersion was removed in Geth 1.10.0') + def test_eth_protocolVersion(self, web3): + super().test_eth_protocolVersion(web3) class GoEthereumVersionModuleTest(VersionModuleTest): - pass + @pytest.mark.xfail(reason='eth_protocolVersion was removed in Geth 1.10.0') + def test_eth_protocol_version(self, web3): + super().test_eth_protocol_version(web3) + + @pytest.mark.xfail(reason='eth_protocolVersion was removed in Geth 1.10.0') + def test_eth_protocolVersion(self, web3): + super().test_eth_protocolVersion(web3) class GoEthereumNetModuleTest(NetModuleTest): diff --git a/tests/integration/go_ethereum/conftest.py b/tests/integration/go_ethereum/conftest.py index 4bcb092ae1..3a07634872 100644 --- a/tests/integration/go_ethereum/conftest.py +++ b/tests/integration/go_ethereum/conftest.py @@ -19,7 +19,7 @@ KEYFILE_PW = 'web3py-test' -GETH_1919_ZIP = 'geth-1.9.19-fixture.zip' +GETH_FIXTURE_ZIP = 'geth-1.10.1-fixture.zip' @pytest.fixture(scope='module') @@ -68,8 +68,8 @@ def base_geth_command_arguments(geth_binary, datadir): @pytest.fixture(scope="module") def geth_zipfile_version(get_geth_version): - if get_geth_version.major == 1 and get_geth_version.minor == 9: - return GETH_1919_ZIP + if get_geth_version.major == 1 and get_geth_version.minor == 10: + return GETH_FIXTURE_ZIP raise AssertionError("Unsupported geth version") diff --git a/tests/integration/go_ethereum/test_goethereum_ws.py b/tests/integration/go_ethereum/test_goethereum_ws.py index 8678f31439..449fd64179 100644 --- a/tests/integration/go_ethereum/test_goethereum_ws.py +++ b/tests/integration/go_ethereum/test_goethereum_ws.py @@ -42,7 +42,7 @@ def _geth_command_arguments(ws_port, '--ipcdisable', '--allow-insecure-unlock', ) - if geth_version.minor not in [9]: + if geth_version.minor not in [10]: raise AssertionError("Unsupported Geth version") else: raise AssertionError("Unsupported Geth version") diff --git a/tests/integration/parity/common.py b/tests/integration/parity/common.py index 287bcc98c7..17c8a1133f 100644 --- a/tests/integration/parity/common.py +++ b/tests/integration/parity/common.py @@ -50,9 +50,13 @@ def test_eth_estimateGas_revert_without_msg( def test_eth_getBlockByNumber_pending(self, web3): super().test_eth_getBlockByNumber_pending(web3) - def test_eth_uninstallFilter(self, web3): + def test_eth_uninstall_filter(self, web3): pytest.xfail('eth_uninstallFilter calls to parity always return true') - super().test_eth_uninstallFilter(web3) + super().test_eth_uninstall_filter(web3) + + def test_eth_uninstallFilter_deprecated(self, web3): + pytest.xfail('eth_uninstallFilter calls to parity always return true') + super().test_eth_uninstallFilter_deprecated(web3) @pytest.mark.xfail(reason='Parity is not setup to auto mine') def test_eth_replace_transaction_already_mined(self, web3, unlocked_account): @@ -74,8 +78,8 @@ def test_eth_get_transaction_receipt_unmined(self, web3, unlocked_account): assert receipt['blockHash'] is None @pytest.mark.xfail(reason="Parity matches None to asbent values") - def test_eth_getLogs_with_logs_none_topic_args(self, web3): - super().test_eth_getLogs_with_logs_none_topic_args(web3) + def test_eth_get_logs_with_logs_none_topic_args(self, web3): + super().test_eth_get_logs_with_logs_none_topic_args(web3) @flaky(max_runs=MAX_FLAKY_RUNS) def test_eth_call_old_contract_state(self, web3, math_contract, unlocked_account): @@ -108,14 +112,14 @@ def test_eth_call_old_contract_state(self, web3, math_contract, unlocked_account if pending_call_result not in range(1, MAX_FLAKY_RUNS + 1): raise AssertionError("pending call result was %d!" % pending_call_result) - def test_eth_getLogs_without_logs(self, web3, block_with_txn_with_log): + def test_eth_get_logs_without_logs(self, web3, block_with_txn_with_log): # Test with block range filter_params = { "fromBlock": 0, "toBlock": block_with_txn_with_log['number'] - 1, } - result = web3.eth.getLogs(filter_params) + result = web3.eth.get_logs(filter_params) assert len(result) == 0 # the range is wrong, parity returns error message @@ -124,7 +128,7 @@ def test_eth_getLogs_without_logs(self, web3, block_with_txn_with_log): "toBlock": block_with_txn_with_log['number'] - 1, } with pytest.raises(ValueError): - web3.eth.getLogs(filter_params) + web3.eth.get_logs(filter_params) # Test with `address` @@ -133,7 +137,7 @@ def test_eth_getLogs_without_logs(self, web3, block_with_txn_with_log): "fromBlock": 0, "address": UNKNOWN_ADDRESS, } - result = web3.eth.getLogs(filter_params) + result = web3.eth.get_logs(filter_params) assert len(result) == 0 # Test with multiple `address` @@ -143,24 +147,16 @@ def test_eth_getLogs_without_logs(self, web3, block_with_txn_with_log): "fromBlock": 0, "address": [UNKNOWN_ADDRESS, UNKNOWN_ADDRESS], } - result = web3.eth.getLogs(filter_params) + result = web3.eth.get_logs(filter_params) assert len(result) == 0 @pytest.mark.xfail(reason='eth_signTypedData has not been released in Parity') - def test_eth_signTypedData(self, - web3, - unlocked_account_dual_type): - super().test_eth_signTypedData( - web3, unlocked_account_dual_type - ) + def test_eth_sign_typed_data(self, web3, unlocked_account_dual_type): + super().test_eth_sign_typed_data(web3, unlocked_account_dual_type) @pytest.mark.xfail(reason='eth_signTypedData has not been released in Parity') - def test_invalid_eth_signTypedData(self, - web3, - unlocked_account_dual_type): - super().test_invalid_eth_signTypedData( - web3, unlocked_account_dual_type - ) + def test_invalid_eth_sign_typed_data(self, web3, unlocked_account_dual_type): + super().test_invalid_eth_sign_typed_data(web3, unlocked_account_dual_type) class ParityTraceModuleTest(ParityTraceModuleTest): diff --git a/tests/integration/test_ethereum_tester.py b/tests/integration/test_ethereum_tester.py index b0be994d15..7b98b08f66 100644 --- a/tests/integration/test_ethereum_tester.py +++ b/tests/integration/test_ethereum_tester.py @@ -61,7 +61,7 @@ def math_contract_deploy_txn_hash(web3, math_contract_factory): @pytest.fixture(scope="module") def math_contract(web3, math_contract_factory, math_contract_deploy_txn_hash): - deploy_receipt = web3.eth.waitForTransactionReceipt(math_contract_deploy_txn_hash) + deploy_receipt = web3.eth.wait_for_transaction_receipt(math_contract_deploy_txn_hash) assert is_dict(deploy_receipt) contract_address = deploy_receipt['contractAddress'] assert is_checksum_address(contract_address) @@ -85,7 +85,7 @@ def emitter_contract_deploy_txn_hash(web3, emitter_contract_factory): @pytest.fixture(scope="module") def emitter_contract(web3, emitter_contract_factory, emitter_contract_deploy_txn_hash): - deploy_receipt = web3.eth.waitForTransactionReceipt(emitter_contract_deploy_txn_hash) + deploy_receipt = web3.eth.wait_for_transaction_receipt(emitter_contract_deploy_txn_hash) assert is_dict(deploy_receipt) contract_address = deploy_receipt['contractAddress'] assert is_checksum_address(contract_address) @@ -152,7 +152,7 @@ def revert_contract_deploy_txn_hash(web3, revert_contract_factory): @pytest.fixture(scope="module") def revert_contract(web3, revert_contract_factory, revert_contract_deploy_txn_hash): - deploy_receipt = web3.eth.waitForTransactionReceipt(revert_contract_deploy_txn_hash) + deploy_receipt = web3.eth.wait_for_transaction_receipt(revert_contract_deploy_txn_hash) assert is_dict(deploy_receipt) contract_address = deploy_receipt['contractAddress'] assert is_checksum_address(contract_address) @@ -242,7 +242,14 @@ class TestEthereumTesterEthModule(EthModuleTest): test_eth_sign_ens_names = not_implemented( EthModuleTest.test_eth_sign_ens_names, ValueError ) - test_eth_signTypedData = not_implemented(EthModuleTest.test_eth_signTypedData, ValueError) + test_eth_signTypedData_deprecated = not_implemented( + EthModuleTest.test_eth_signTypedData_deprecated, + ValueError + ) + test_eth_sign_typed_data = not_implemented( + EthModuleTest.test_eth_sign_typed_data, + ValueError + ) test_eth_signTransaction_deprecated = not_implemented( EthModuleTest.test_eth_signTransaction_deprecated, ValueError @@ -251,8 +258,12 @@ class TestEthereumTesterEthModule(EthModuleTest): test_eth_sign_transaction_ens_names = not_implemented( EthModuleTest.test_eth_sign_transaction_ens_names, ValueError ) - test_eth_submitHashrate = not_implemented(EthModuleTest.test_eth_submitHashrate, ValueError) - test_eth_submitWork = not_implemented(EthModuleTest.test_eth_submitWork, ValueError) + test_eth_submitHashrate_deprecated = not_implemented( + EthModuleTest.test_eth_submitHashrate_deprecated, ValueError) + test_eth_submit_hashrate = not_implemented(EthModuleTest.test_eth_submit_hashrate, ValueError) + test_eth_submitWork_deprecated = not_implemented( + EthModuleTest.test_eth_submitWork_deprecated, ValueError) + test_eth_submit_work = not_implemented(EthModuleTest.test_eth_submit_work, ValueError) def test_eth_getBlockByHash_pending( self, web3: "Web3" diff --git a/tox.ini b/tox.ini index a9eb9087b3..9754521585 100644 --- a/tox.ini +++ b/tox.ini @@ -94,3 +94,19 @@ deps={[common-wheel-cli]deps} whitelist_externals={[common-wheel-cli]whitelist_externals} commands={[common-wheel-cli]commands} skip_install=true + +[common-wheel-cli-windows] +deps=wheel +whitelist_externals= + bash.exe +commands= + bash.exe -c "rm -rf build dist" + python setup.py sdist bdist_wheel + bash.exe -c 'pip install --upgrade "$(ls dist/web3-*-py3-none-any.whl)" --progress-bar off' + python -c "from web3.auto import w3" + +[testenv:py37-wheel-cli-windows] +deps={[common-wheel-cli]deps} +whitelist_externals={[common-wheel-cli-windows]whitelist_externals} +commands={[common-wheel-cli-windows]commands} +skip_install=true diff --git a/web3/_utils/filters.py b/web3/_utils/filters.py index 7b5dbfe654..56a639a7ff 100644 --- a/web3/_utils/filters.py +++ b/web3/_utils/filters.py @@ -165,7 +165,7 @@ def get_new_entries(self) -> List[LogReceipt]: return self._format_log_entries(log_entries) def get_all_entries(self) -> List[LogReceipt]: - log_entries = self._filter_valid_entries(self.eth_module.getFilterLogs(self.filter_id)) + log_entries = self._filter_valid_entries(self.eth_module.get_filter_logs(self.filter_id)) return self._format_log_entries(log_entries) def _format_log_entries(self, diff --git a/web3/_utils/module_testing/eth_module.py b/web3/_utils/module_testing/eth_module.py index 41ba729e59..632b47e1fe 100644 --- a/web3/_utils/module_testing/eth_module.py +++ b/web3/_utils/module_testing/eth_module.py @@ -413,7 +413,59 @@ def test_eth_sign_ens_names( assert is_bytes(signature) assert len(signature) == 32 + 32 + 1 - def test_eth_signTypedData( + def test_eth_sign_typed_data( + self, + web3: "Web3", + unlocked_account_dual_type: ChecksumAddress, + skip_if_testrpc: Callable[["Web3"], None], + ) -> None: + validJSONMessage = ''' + { + "types": { + "EIP712Domain": [ + {"name": "name", "type": "string"}, + {"name": "version", "type": "string"}, + {"name": "chainId", "type": "uint256"}, + {"name": "verifyingContract", "type": "address"} + ], + "Person": [ + {"name": "name", "type": "string"}, + {"name": "wallet", "type": "address"} + ], + "Mail": [ + {"name": "from", "type": "Person"}, + {"name": "to", "type": "Person"}, + {"name": "contents", "type": "string"} + ] + }, + "primaryType": "Mail", + "domain": { + "name": "Ether Mail", + "version": "1", + "chainId": "0x01", + "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC" + }, + "message": { + "from": { + "name": "Cow", + "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826" + }, + "to": { + "name": "Bob", + "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB" + }, + "contents": "Hello, Bob!" + } + } + ''' + skip_if_testrpc(web3) + signature = HexBytes(web3.eth.sign_typed_data( + unlocked_account_dual_type, + json.loads(validJSONMessage) + )) + assert len(signature) == 32 + 32 + 1 + + def test_eth_signTypedData_deprecated( self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress, @@ -465,7 +517,7 @@ def test_eth_signTypedData( )) assert len(signature) == 32 + 32 + 1 - def test_invalid_eth_signTypedData( + def test_invalid_eth_sign_typed_data( self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress, @@ -513,7 +565,7 @@ def test_invalid_eth_signTypedData( ''' with pytest.raises(ValueError, match=r".*Expected 2 items for array type Person\[2\], got 1 items.*"): - web3.eth.signTypedData( + web3.eth.sign_typed_data( unlocked_account_dual_type, json.loads(invalid_typed_message) ) @@ -736,7 +788,7 @@ def test_eth_replace_transaction_already_mined( 'gasPrice': web3.eth.gas_price, } txn_hash = web3.eth.send_transaction(txn_params) - web3.eth.waitForTransactionReceipt(txn_hash) + web3.eth.wait_for_transaction_receipt(txn_hash) txn_params['gasPrice'] = Wei(web3.eth.gas_price * 2) with pytest.raises(ValueError, match="Supplied transaction with hash"): @@ -889,17 +941,13 @@ def test_eth_modifyTransaction_deprecated( @pytest.mark.parametrize( 'raw_transaction, expected_hash', [ - ( - # address 0x39EEed73fb1D3855E90Cbd42f348b3D7b340aAA6 - '0xf8648085174876e8008252089439eeed73fb1d3855e90cbd42f348b3d7b340aaa601801ba0ec1295f00936acd0c2cb90ab2cdaacb8bf5e11b3d9957833595aca9ceedb7aada05dfc8937baec0e26029057abd3a1ef8c505dca2cdc07ffacb046d090d2bea06a', # noqa: E501 - '0x1f80f8ab5f12a45be218f76404bda64d37270a6f4f86ededd0eb599f80548c13', - ), ( # private key 0x3c2ab4e8f17a7dea191b8c991522660126d681039509dc3bb31af7c9bdb63518 # This is an unfunded account, but the transaction has a 0 gas price, so is valid. # It never needs to be mined, we just want the transaction hash back to confirm. - HexBytes('0xf85f808082c35094d898d5e829717c72e7438bad593076686d7d164a80801ba005c2e99ecee98a12fbf28ab9577423f42e9e88f2291b3acc8228de743884c874a077d6bc77a47ad41ec85c96aac2ad27f05a039c4787fca8a1e5ee2d8c7ec1bb6a'), # noqa: E501 - '0x98eeadb99454427f6aad7b558bac13e9d225512a6f5e5c11cf48e8d4067e51b5', + # tx = {'to': '0x0000000000000000000000000000000000000000', 'value': 0, 'nonce': 0, 'gas': 21000, 'gasPrice': 0, 'chainId': 131277322940537} # noqa: E501 + HexBytes('0xf8658080825208940000000000000000000000000000000000000000808086eecac466e115a038176e5f9f1c25ce470ce77856bacbc02dd728ad647bb8b18434ac62c3e8e14fa03279bb3ee1e5202580668ec62b66a7d01355de3d5c4ef18fcfcb88fac56d5f90'), # noqa: E501 + '0x6ab943e675003de610b4e94f2e289dc711688df6e150da2bc57bd03811ad0f63', ), ] ) @@ -1242,13 +1290,29 @@ def test_eth_newFilter(self, web3: "Web3") -> None: assert is_list_like(changes) assert not changes - logs = web3.eth.getFilterLogs(filter.filter_id) + logs = web3.eth.get_filter_logs(filter.filter_id) assert is_list_like(logs) assert not logs result = web3.eth.uninstallFilter(filter.filter_id) assert result is True + def test_eth_newFilter_deprecated(self, web3: "Web3") -> None: + filter = web3.eth.filter({}) + + changes = web3.eth.getFilterChanges(filter.filter_id) + assert is_list_like(changes) + assert not changes + + with pytest.warns(DeprecationWarning, + match="getFilterLogs is deprecated in favor of get_filter_logs"): + logs = web3.eth.getFilterLogs(filter.filter_id) + assert is_list_like(logs) + assert not logs + + result = web3.eth.uninstall_filter(filter.filter_id) + assert result is True + def test_eth_newBlockFilter(self, web3: "Web3") -> None: filter = web3.eth.filter('latest') assert is_string(filter.filter_id) @@ -1258,11 +1322,11 @@ def test_eth_newBlockFilter(self, web3: "Web3") -> None: assert not changes # TODO: figure out why this fails in go-ethereum - # logs = web3.eth.getFilterLogs(filter.filter_id) + # logs = web3.eth.get_filter_logs(filter.filter_id) # assert is_list_like(logs) # assert not logs - result = web3.eth.uninstallFilter(filter.filter_id) + result = web3.eth.uninstall_filter(filter.filter_id) assert result is True def test_eth_newPendingTransactionFilter(self, web3: "Web3") -> None: @@ -1274,14 +1338,14 @@ def test_eth_newPendingTransactionFilter(self, web3: "Web3") -> None: assert not changes # TODO: figure out why this fails in go-ethereum - # logs = web3.eth.getFilterLogs(filter.filter_id) + # logs = web3.eth.get_filter_logs(filter.filter_id) # assert is_list_like(logs) # assert not logs - result = web3.eth.uninstallFilter(filter.filter_id) + result = web3.eth.uninstall_filter(filter.filter_id) assert result is True - def test_eth_getLogs_without_logs( + def test_eth_get_logs_without_logs( self, web3: "Web3", block_with_txn_with_log: BlockData ) -> None: # Test with block range @@ -1290,7 +1354,7 @@ def test_eth_getLogs_without_logs( "fromBlock": BlockNumber(0), "toBlock": BlockNumber(block_with_txn_with_log['number'] - 1), } - result = web3.eth.getLogs(filter_params) + result = web3.eth.get_logs(filter_params) assert len(result) == 0 # the range is wrong @@ -1298,7 +1362,7 @@ def test_eth_getLogs_without_logs( "fromBlock": block_with_txn_with_log['number'], "toBlock": BlockNumber(block_with_txn_with_log['number'] - 1), } - result = web3.eth.getLogs(filter_params) + result = web3.eth.get_logs(filter_params) assert len(result) == 0 # Test with `address` @@ -1308,7 +1372,7 @@ def test_eth_getLogs_without_logs( "fromBlock": BlockNumber(0), "address": UNKNOWN_ADDRESS, } - result = web3.eth.getLogs(filter_params) + result = web3.eth.get_logs(filter_params) assert len(result) == 0 # Test with multiple `address` @@ -1318,10 +1382,10 @@ def test_eth_getLogs_without_logs( "fromBlock": BlockNumber(0), "address": [UNKNOWN_ADDRESS, UNKNOWN_ADDRESS], } - result = web3.eth.getLogs(filter_params) + result = web3.eth.get_logs(filter_params) assert len(result) == 0 - def test_eth_getLogs_with_logs( + def test_eth_get_logs_with_logs( self, web3: "Web3", block_with_txn_with_log: BlockData, @@ -1345,14 +1409,14 @@ def assert_contains_log(result: Sequence[LogReceipt]) -> None: "fromBlock": block_with_txn_with_log['number'], "toBlock": block_with_txn_with_log['number'], } - result = web3.eth.getLogs(filter_params) + result = web3.eth.get_logs(filter_params) assert_contains_log(result) # specify only `from_block`. by default `to_block` should be 'latest' filter_params = { "fromBlock": BlockNumber(0), } - result = web3.eth.getLogs(filter_params) + result = web3.eth.get_logs(filter_params) assert_contains_log(result) # Test with `address` @@ -1363,7 +1427,7 @@ def assert_contains_log(result: Sequence[LogReceipt]) -> None: "address": emitter_contract_address, } - def test_eth_getLogs_with_logs_topic_args( + def test_eth_get_logs_with_logs_topic_args( self, web3: "Web3", block_with_txn_with_log: BlockData, @@ -1389,7 +1453,7 @@ def assert_contains_log(result: Sequence[LogReceipt]) -> None: HexStr('0x000000000000000000000000000000000000000000000000000000000000d431')], } - result = web3.eth.getLogs(filter_params) + result = web3.eth.get_logs(filter_params) assert_contains_log(result) # Test with None indexed arg @@ -1399,17 +1463,17 @@ def assert_contains_log(result: Sequence[LogReceipt]) -> None: HexStr('0x057bc32826fbe161da1c110afcdcae7c109a8b69149f727fc37a603c60ef94ca'), None], } - result = web3.eth.getLogs(filter_params) + result = web3.eth.get_logs(filter_params) assert_contains_log(result) - def test_eth_getLogs_with_logs_none_topic_args(self, web3: "Web3") -> None: + def test_eth_get_logs_with_logs_none_topic_args(self, web3: "Web3") -> None: # Test with None overflowing filter_params: FilterParams = { "fromBlock": BlockNumber(0), "topics": [None, None, None], } - result = web3.eth.getLogs(filter_params) + result = web3.eth.get_logs(filter_params) assert len(result) == 0 def test_eth_call_old_contract_state( @@ -1441,14 +1505,28 @@ def test_eth_call_old_contract_state( if pending_call_result != 1: raise AssertionError("pending call result was %d instead of 1" % pending_call_result) - def test_eth_uninstallFilter(self, web3: "Web3") -> None: + def test_eth_uninstallFilter_deprecated(self, web3: "Web3") -> None: + filter = web3.eth.filter({}) + assert is_string(filter.filter_id) + + with pytest.warns(DeprecationWarning, + match="uninstallFilter is deprecated in favor of uninstall_filter"): + success = web3.eth.uninstallFilter(filter.filter_id) + assert success is True + + with pytest.warns(DeprecationWarning, + match="uninstallFilter is deprecated in favor of uninstall_filter"): + failure = web3.eth.uninstallFilter(filter.filter_id) + assert failure is False + + def test_eth_uninstall_filter(self, web3: "Web3") -> None: filter = web3.eth.filter({}) assert is_string(filter.filter_id) - success = web3.eth.uninstallFilter(filter.filter_id) + success = web3.eth.uninstall_filter(filter.filter_id) assert success is True - failure = web3.eth.uninstallFilter(filter.filter_id) + failure = web3.eth.uninstall_filter(filter.filter_id) assert failure is False def test_eth_getTransactionFromBlock_deprecation( @@ -1461,15 +1539,30 @@ def test_eth_getCompilers_deprecation(self, web3: "Web3") -> None: with pytest.raises(DeprecationWarning): web3.eth.getCompilers() - def test_eth_submitHashrate(self, web3: "Web3") -> None: + def test_eth_submit_hashrate(self, web3: "Web3") -> None: + # node_id from EIP 1474: https://github.com/ethereum/EIPs/pull/1474/files + node_id = HexStr('59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c') + result = web3.eth.submit_hashrate(5000, node_id) + assert result is True + + def test_eth_submitHashrate_deprecated(self, web3: "Web3") -> None: # node_id from EIP 1474: https://github.com/ethereum/EIPs/pull/1474/files node_id = HexStr('59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c') result = web3.eth.submitHashrate(5000, node_id) assert result is True - def test_eth_submitWork(self, web3: "Web3") -> None: + def test_eth_submit_work(self, web3: "Web3") -> None: + nonce = 1 + pow_hash = HexStr('0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef') + mix_digest = HexStr('0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000') + result = web3.eth.submit_work(nonce, pow_hash, mix_digest) + assert result is False + + def test_eth_submitWork_deprecated(self, web3: "Web3") -> None: nonce = 1 pow_hash = HexStr('0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef') mix_digest = HexStr('0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000') - result = web3.eth.submitWork(nonce, pow_hash, mix_digest) + with pytest.warns(DeprecationWarning, + match="submitWork is deprecated in favor of submit_work"): + result = web3.eth.submitWork(nonce, pow_hash, mix_digest) assert result is False diff --git a/web3/_utils/module_testing/personal_module.py b/web3/_utils/module_testing/personal_module.py index 25c22dd529..20f3793dfc 100644 --- a/web3/_utils/module_testing/personal_module.py +++ b/web3/_utils/module_testing/personal_module.py @@ -327,7 +327,7 @@ def test_personal_sign_typed_data_deprecated( } } ''' - signature = HexBytes(web3.geth.personal.signTypedData( + signature = HexBytes(web3.geth.personal.sign_typed_data( json.loads(typed_message), unlockable_account_dual_type, unlockable_account_pw @@ -639,7 +639,7 @@ def test_personal_sign_typed_data_deprecated( } } ''' - signature = HexBytes(web3.parity.personal.signTypedData( + signature = HexBytes(web3.parity.personal.sign_typed_data( json.loads(typed_message), unlockable_account_dual_type, unlockable_account_pw @@ -755,7 +755,7 @@ def test_invalid_personal_sign_typed_data_deprecated( with pytest.raises(ValueError, match=r".*Expected 2 items for array type Person\[2\], got 1 items.*" ): - web3.parity.personal.signTypedData( + web3.parity.personal.sign_typed_data( json.loads(invalid_typed_message), unlockable_account_dual_type, unlockable_account_pw diff --git a/web3/_utils/transactions.py b/web3/_utils/transactions.py index 1623b1aa8d..a50d65b1f8 100644 --- a/web3/_utils/transactions.py +++ b/web3/_utils/transactions.py @@ -53,7 +53,7 @@ 'value': 0, 'data': b'', 'gas': lambda web3, tx: web3.eth.estimateGas(tx), - 'gasPrice': lambda web3, tx: web3.eth.generateGasPrice(tx) or web3.eth.gas_price, + 'gasPrice': lambda web3, tx: web3.eth.generate_gas_price(tx) or web3.eth.gas_price, 'chainId': lambda web3, tx: web3.eth.chain_id, } @@ -198,7 +198,7 @@ def prepare_replacement_transaction( if new_transaction['gasPrice'] <= current_transaction['gasPrice']: raise ValueError('Supplied gas price must exceed existing transaction gas price') else: - generated_gas_price = web3.eth.generateGasPrice(new_transaction) + generated_gas_price = web3.eth.generate_gas_price(new_transaction) minimum_gas_price = int(math.ceil(current_transaction['gasPrice'] * gas_multiplier)) if generated_gas_price and generated_gas_price > minimum_gas_price: new_transaction = assoc(new_transaction, 'gasPrice', generated_gas_price) diff --git a/web3/contract.py b/web3/contract.py index fee19f51a1..1463715bd8 100644 --- a/web3/contract.py +++ b/web3/contract.py @@ -1334,7 +1334,7 @@ def getLogs(self, event_filter_params['blockHash'] = blockHash # Call JSON-RPC API - logs = self.web3.eth.getLogs(event_filter_params) + logs = self.web3.eth.get_logs(event_filter_params) # Convert raw binary data to Python proxy objects as described by ABI return tuple(get_event_data(self.web3.codec, abi, entry) for entry in logs) diff --git a/web3/eth.py b/web3/eth.py index 0b5177e10a..10a1550d56 100644 --- a/web3/eth.py +++ b/web3/eth.py @@ -125,6 +125,10 @@ def icapNamereg(self) -> NoReturn: @property def protocol_version(self) -> str: + warnings.warn( + "This method has been deprecated in some clients.", + category=DeprecationWarning, + ) return self._protocol_version() @property @@ -417,8 +421,14 @@ def getTransactionFromBlock( mungers=[default_root_munger] ) + @deprecated_for("wait_for_transaction_receipt") def waitForTransactionReceipt( self, transaction_hash: _Hash32, timeout: int = 120, poll_latency: float = 0.1 + ) -> TxReceipt: + return self.wait_for_transaction_receipt(transaction_hash, timeout, poll_latency) + + def wait_for_transaction_receipt( + self, transaction_hash: _Hash32, timeout: int = 120, poll_latency: float = 0.1 ) -> TxReceipt: try: return wait_for_transaction_receipt(self.web3, transaction_hash, timeout, poll_latency) @@ -509,7 +519,7 @@ def sign_munger( mungers=[default_root_munger], ) - signTypedData: Method[Callable[..., HexStr]] = Method( + sign_typed_data: Method[Callable[..., HexStr]] = Method( RPC.eth_signTypedData, mungers=[default_root_munger], ) @@ -595,27 +605,27 @@ def filter_munger( mungers=[default_root_munger] ) - getFilterLogs: Method[Callable[[HexStr], List[LogReceipt]]] = Method( + get_filter_logs: Method[Callable[[HexStr], List[LogReceipt]]] = Method( RPC.eth_getFilterLogs, mungers=[default_root_munger] ) - getLogs: Method[Callable[[FilterParams], List[LogReceipt]]] = Method( + get_logs: Method[Callable[[FilterParams], List[LogReceipt]]] = Method( RPC.eth_getLogs, mungers=[default_root_munger] ) - submitHashrate: Method[Callable[[int, _Hash32], bool]] = Method( + submit_hashrate: Method[Callable[[int, _Hash32], bool]] = Method( RPC.eth_submitHashrate, mungers=[default_root_munger], ) - submitWork: Method[Callable[[int, _Hash32, _Hash32], bool]] = Method( + submit_work: Method[Callable[[int, _Hash32, _Hash32], bool]] = Method( RPC.eth_submitWork, mungers=[default_root_munger], ) - uninstallFilter: Method[Callable[[HexStr], bool]] = Method( + uninstall_filter: Method[Callable[[HexStr], bool]] = Method( RPC.eth_uninstallFilter, mungers=[default_root_munger], ) @@ -657,7 +667,11 @@ def getCompilers(self) -> NoReturn: mungers=None, ) + @deprecated_for("generate_gas_price") def generateGasPrice(self, transaction_params: Optional[TxParams] = None) -> Optional[Wei]: + return self.generate_gas_price(transaction_params) + + def generate_gas_price(self, transaction_params: Optional[TxParams] = None) -> Optional[Wei]: if self.gasPriceStrategy: return self.gasPriceStrategy(self.web3, transaction_params) return None @@ -688,9 +702,15 @@ def setGasPriceStrategy(self, gas_price_strategy: GasPriceStrategy) -> None: getFilterChanges = DeprecatedMethod(get_filter_changes, 'getFilterChanges', 'get_filter_changes') + signTypedData = DeprecatedMethod(sign_typed_data, 'signTypedData', 'sign_typed_data') + submitHashrate = DeprecatedMethod(submit_hashrate, 'submitHashrate', 'submit_hashrate') + submitWork = DeprecatedMethod(submit_work, 'submitWork', 'submit_work') + getLogs = DeprecatedMethod(get_logs, 'getLogs', 'get_logs') sendRawTransaction = DeprecatedMethod(send_raw_transaction, 'sendRawTransaction', 'send_raw_transaction') getTransactionReceipt = DeprecatedMethod(get_transaction_receipt, 'getTransactionReceipt', 'get_transaction_receipt') + uninstallFilter = DeprecatedMethod(uninstall_filter, 'uninstallFilter', 'uninstall_filter') + getFilterLogs = DeprecatedMethod(get_filter_logs, 'getFilterLogs', 'get_filter_logs') diff --git a/web3/middleware/filter.py b/web3/middleware/filter.py index 344ccc646d..b1ec26b1a7 100644 --- a/web3/middleware/filter.py +++ b/web3/middleware/filter.py @@ -215,7 +215,7 @@ def get_logs_multipart( "address": address, "topics": topics } - yield w3.eth.getLogs(cast(FilterParams, drop_items_with_none_value(params))) + yield w3.eth.get_logs(cast(FilterParams, drop_items_with_none_value(params))) class RequestLogs: diff --git a/web3/middleware/gas_price_strategy.py b/web3/middleware/gas_price_strategy.py index 6497f265eb..6593356128 100644 --- a/web3/middleware/gas_price_strategy.py +++ b/web3/middleware/gas_price_strategy.py @@ -27,7 +27,7 @@ def middleware(method: RPCEndpoint, params: Any) -> RPCResponse: if method == 'eth_sendTransaction': transaction = params[0] if 'gasPrice' not in transaction: - generated_gas_price = web3.eth.generateGasPrice(transaction) + generated_gas_price = web3.eth.generate_gas_price(transaction) if generated_gas_price is not None: transaction = assoc(transaction, 'gasPrice', generated_gas_price) return make_request(method, [transaction]) diff --git a/web3/pm.py b/web3/pm.py index c225e5cca7..5257db22bd 100644 --- a/web3/pm.py +++ b/web3/pm.py @@ -250,7 +250,7 @@ def _release(self, package_name: str, version: str, manifest_uri: str) -> bytes: tx_hash = self.registry.functions.release( package_name, version, manifest_uri ).transact() - self.w3.eth.waitForTransactionReceipt(tx_hash) + self.w3.eth.wait_for_transaction_receipt(tx_hash) return self._get_release_id(package_name, version) def _get_package_name(self, package_id: bytes) -> str: @@ -308,7 +308,7 @@ def deploy_new_instance(cls, w3: Web3) -> 'SimpleRegistry': registry_package = Package(manifest, w3) registry_factory = registry_package.get_contract_factory(ContractName("PackageRegistry")) tx_hash = registry_factory.constructor().transact() - tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash) + tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash) return cls(tx_receipt["contractAddress"], w3) diff --git a/web3/tools/pytest_ethereum/linker.py b/web3/tools/pytest_ethereum/linker.py index 99ce97dbb5..c0804d0136 100644 --- a/web3/tools/pytest_ethereum/linker.py +++ b/web3/tools/pytest_ethereum/linker.py @@ -70,7 +70,7 @@ def _deploy( "builder tool, use `contract_type(..., runtime_bytecode=True)`." ) tx_hash = factory.constructor(*args).transact(transaction) - tx_receipt = package.w3.eth.waitForTransactionReceipt(tx_hash) + tx_receipt = package.w3.eth.wait_for_transaction_receipt(tx_hash) # Create manifest copy with new deployment instance latest_block_uri = create_latest_block_uri(package.w3, 0) deployment_data = create_deployment_data(