From cd032c8f140c36e0da109eef9b3811f36c90355c Mon Sep 17 00:00:00 2001 From: Edward Amor Date: Fri, 16 Apr 2021 09:12:00 -0400 Subject: [PATCH 1/6] feat: constrain requirements-dev.in Using the -r option previously only appended the packages listed in the base requirements.in file to the requirements-dev.in. However, this leads to incompatibilities between the two set of requirements as when compiling the requirements-dev we get the most up to date packages available instead of the constrained ones. --- requirements-dev.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.in b/requirements-dev.in index 363bb5886..f61897275 100644 --- a/requirements-dev.in +++ b/requirements-dev.in @@ -1,4 +1,4 @@ --r requirements.in +-c requirements.txt bumpversion coverage From 2ea75cc878cf9e9c858dd66adb000a16176c8013 Mon Sep 17 00:00:00 2001 From: Edward Amor Date: Fri, 16 Apr 2021 10:12:00 -0400 Subject: [PATCH 2/6] feat: upgrade web3.py to 5.18.0 --- requirements.txt | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/requirements.txt b/requirements.txt index de5efb07b..e1a5489a1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ # This file is autogenerated by pip-compile # To update, run: # -# pip-compile +# pip-compile requirements.in # apipkg==1.5 # via execnet @@ -38,7 +38,7 @@ eth-abi==2.1.1 # eth-account # eth-event # web3 -eth-account==0.5.2 +eth-account==0.5.4 # via # -r requirements.in # web3 @@ -88,20 +88,13 @@ hypothesis==5.41.3 # via -r requirements.in idna==2.10 # via requests -importlib-metadata==3.10.0 - # via - # jsonschema - # pluggy - # pytest -importlib-resources==5.1.2 - # via netaddr inflection==0.5.0 # via # mythx-models # pythx iniconfig==1.1.1 # via pytest -ipfshttpclient==0.7.0 +ipfshttpclient==0.7.0a1 # via web3 jsonschema==3.2.0 # via @@ -218,10 +211,6 @@ tqdm==4.53.0 # via -r requirements.in typed-ast==1.4.2 # via black -typing-extensions==3.7.4.3 - # via - # importlib-metadata - # web3 urllib3==1.26.4 # via requests varint==1.0.2 @@ -232,14 +221,10 @@ vyper==0.2.12 # via -r requirements.in wcwidth==0.2.5 # via prompt-toolkit -web3==5.11.1 +web3==5.18.0 # via -r requirements.in websockets==8.1 # via web3 -zipp==3.4.1 - # via - # importlib-metadata - # importlib-resources # The following packages are considered to be unsafe in a requirements file: # setuptools From 4e5ae236c3ff1e38fd254bdd50d786825926d211 Mon Sep 17 00:00:00 2001 From: Edward Amor Date: Fri, 16 Apr 2021 10:35:00 -0400 Subject: [PATCH 3/6] fix: compile requirements-dev.txt Newly constrained dev requirements. --- requirements-dev.txt | 244 +++++++++---------------------------------- 1 file changed, 51 insertions(+), 193 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 955a8584e..b61f5a482 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -6,28 +6,16 @@ # alabaster==0.7.12 # via sphinx -apipkg==1.5 - # via execnet appdirs==1.4.4 # via - # black + # -c requirements.txt # virtualenv -asttokens==2.0.4 - # via vyper attrs==20.3.0 # via - # black - # hypothesis - # jsonschema + # -c requirements.txt # pytest babel==2.9.0 # via sphinx -base58==2.1.0 - # via multiaddr -bitarray==1.2.2 - # via eth-account -black==19.10b0 - # via -r requirements.in bleach==3.3.0 # via readme-renderer bump2version==1.0.1 @@ -35,138 +23,78 @@ bump2version==1.0.1 bumpversion==0.6.0 # via -r requirements-dev.in certifi==2020.12.5 - # via requests -chardet==3.0.4 - # via requests + # via + # -c requirements.txt + # requests +cffi==1.14.5 + # via cryptography +chardet==4.0.0 + # via + # -c requirements.txt + # requests click==7.1.2 # via - # black + # -c requirements.txt # pip-tools coverage==5.2.1 # via # -r requirements-dev.in # pytest-cov -cytoolz==0.11.0 - # via - # eth-keyfile - # eth-utils +cryptography==3.4.7 + # via secretstorage distlib==0.3.1 # via virtualenv docutils==0.16 # via # readme-renderer # sphinx -eth-abi==2.1.1 - # via - # -r requirements.in - # eth-account - # eth-event - # web3 -eth-account==0.5.4 - # via - # -r requirements.in - # web3 -eth-event==1.2.3 - # via -r requirements.in -eth-hash[pycryptodome]==0.3.1 - # via - # -r requirements.in - # eth-event - # eth-utils - # web3 -eth-keyfile==0.5.1 - # via eth-account -eth-keys==0.3.3 - # via - # eth-account - # eth-keyfile -eth-rlp==0.2.1 - # via eth-account -eth-typing==2.2.2 - # via - # eth-abi - # eth-keys - # eth-utils - # web3 -eth-utils==1.10.0 - # via - # -r requirements.in - # eth-abi - # eth-account - # eth-event - # eth-hash - # eth-keyfile - # eth-keys - # eth-rlp - # rlp - # web3 -execnet==1.8.0 - # via pytest-xdist filelock==3.0.12 # via # tox # virtualenv flake8==3.8.3 # via -r requirements-dev.in -hexbytes==0.2.1 - # via - # -r requirements.in - # eth-account - # eth-event - # eth-rlp - # web3 -hypothesis==5.49.0 - # via -r requirements.in idna==2.10 - # via requests + # via + # -c requirements.txt + # requests imagesize==1.2.0 # via sphinx importlib-metadata==3.7.3 # via keyring -inflection==0.5.1 - # via - # mythx-models - # pythx iniconfig==1.1.1 - # via pytest -ipfshttpclient==0.7.0a1 - # via web3 + # via + # -c requirements.txt + # pytest isort==4.3.21 # via -r requirements-dev.in +jeepney==0.6.0 + # via + # keyring + # secretstorage jinja2==2.11.3 # via sphinx -jsonschema==3.2.0 - # via - # mythx-models - # web3 keyring==23.0.0 # via twine -lru-dict==1.1.7 - # via web3 markupsafe==1.1.1 # via jinja2 mccabe==0.6.1 # via flake8 -multiaddr==0.0.9 - # via ipfshttpclient +more-itertools==8.7.0 + # via + # -c requirements.txt + # pytest mypy-extensions==0.4.3 # via mypy mypy==0.720 # via -r requirements-dev.in -mythx-models==2.0.1 - # via pythx -netaddr==0.8.0 - # via multiaddr packaging==20.9 # via + # -c requirements.txt # bleach # pytest # sphinx # tox -parsimonious==0.8.1 - # via eth-abi -pathspec==0.8.1 - # via black pep517==0.10.0 # via pip-tools pip-tools==6.0.1 @@ -175,119 +103,61 @@ pkginfo==1.7.0 # via twine pluggy==0.13.1 # via + # -c requirements.txt # pytest # tox -prompt-toolkit==3.0.17 - # via -r requirements.in -protobuf==3.15.6 - # via web3 -psutil==5.8.0 - # via -r requirements.in -py-solc-ast==1.2.8 - # via -r requirements.in -py-solc-x==1.1.0 - # via -r requirements.in py==1.10.0 # via - # -r requirements.in + # -c requirements.txt # pytest - # pytest-forked # tox pycodestyle==2.6.0 # via flake8 -pycryptodome==3.10.1 - # via - # eth-hash - # eth-keyfile - # vyper -pydantic==1.7.3 - # via mythx-models +pycparser==2.20 + # via cffi pyflakes==2.2.0 # via flake8 -pygments-lexer-solidity==0.5.1 - # via -r requirements.in pygments==2.8.1 # via - # -r requirements.in - # pygments-lexer-solidity + # -c requirements.txt # readme-renderer # sphinx -pyjwt==1.7.1 - # via pythx pyparsing==2.4.7 - # via packaging -pyrsistent==0.17.3 - # via jsonschema + # via + # -c requirements.txt + # packaging pytest-cov==2.10.1 # via -r requirements-dev.in -pytest-forked==1.3.0 - # via pytest-xdist pytest-mock==3.3.1 # via -r requirements-dev.in -pytest-xdist==1.34.0 - # via -r requirements.in -pytest==6.2.2 +pytest==6.0.1 # via - # -r requirements.in + # -c requirements.txt # pytest-cov - # pytest-forked # pytest-mock - # pytest-xdist -python-dateutil==2.8.1 - # via - # mythx-models - # pythx -pythx==1.7.1 - # via -r requirements.in pytz==2021.1 # via babel -pyyaml==5.4.1 - # via -r requirements.in readme-renderer==29.0 # via twine -regex==2020.11.13 - # via black requests-toolbelt==0.9.1 # via twine -requests==2.25.0 +requests==2.25.1 # via - # -r requirements.in - # ipfshttpclient - # py-solc-x - # pythx + # -c requirements.txt # requests-toolbelt # sphinx # twine - # vvm - # web3 -rlp==1.2.0 - # via - # -r requirements.in - # eth-account - # eth-rlp -semantic-version==2.8.5 - # via - # -r requirements.in - # py-solc-x - # vvm - # vyper +secretstorage==3.3.1 + # via keyring six==1.15.0 # via - # asttokens + # -c requirements.txt # bleach - # jsonschema - # multiaddr - # parsimonious - # protobuf - # pytest-xdist - # python-dateutil # readme-renderer # tox # virtualenv snowballstemmer==2.1.0 # via sphinx -sortedcontainers==2.3.0 - # via hypothesis sphinx-rtd-theme==0.5.0 # via -r requirements-dev.in sphinx==3.2.1 @@ -308,44 +178,32 @@ sphinxcontrib-serializinghtml==1.1.4 # via sphinx toml==0.10.2 # via - # black + # -c requirements.txt # pep517 # pytest # tox -toolz==0.11.1 - # via cytoolz tox==3.19.0 # via -r requirements-dev.in -tqdm==4.59.0 +tqdm==4.53.0 # via - # -r requirements.in + # -c requirements.txt # twine twine==3.1.1 # via -r requirements-dev.in typed-ast==1.4.2 # via - # black + # -c requirements.txt # mypy typing-extensions==3.7.4.3 # via mypy urllib3==1.26.4 - # via requests -varint==1.0.2 - # via multiaddr + # via + # -c requirements.txt + # requests virtualenv==20.4.3 # via tox -vvm==0.1.0 - # via -r requirements.in -vyper==0.2.12 - # via -r requirements.in -wcwidth==0.2.5 - # via prompt-toolkit -web3==5.17.0 - # via -r requirements.in webencodings==0.5.1 # via bleach -websockets==8.1 - # via web3 wheel==0.35.1 # via -r requirements-dev.in zipp==3.4.1 From 99df7c878a4c07fafca25bc761b335a1c75ae5e6 Mon Sep 17 00:00:00 2001 From: Edward Amor Date: Fri, 16 Apr 2021 10:45:00 -0400 Subject: [PATCH 4/6] fix: constrain requirements-windows.{in,txt} --- requirements-windows.in | 2 +- requirements-windows.txt | 235 ++++++++++++++++++++++++++------------- 2 files changed, 160 insertions(+), 77 deletions(-) diff --git a/requirements-windows.in b/requirements-windows.in index 9e3e99147..2b695f4c5 100644 --- a/requirements-windows.in +++ b/requirements-windows.in @@ -1,3 +1,3 @@ --r requirements.in +-r requirements.txt colorama>=0.4.1,<1 diff --git a/requirements-windows.txt b/requirements-windows.txt index 11e55c15d..ee85d9e39 100644 --- a/requirements-windows.txt +++ b/requirements-windows.txt @@ -5,176 +5,243 @@ # pip-compile requirements-windows.in # apipkg==1.5 - # via execnet + # via + # -r requirements.txt + # execnet appdirs==1.4.4 - # via black + # via + # -r requirements.txt + # black asttokens==2.0.4 - # via vyper + # via + # -r requirements.txt + # vyper attrs==20.3.0 # via + # -r requirements.txt # black # hypothesis # jsonschema # pytest base58==2.1.0 - # via multiaddr + # via + # -r requirements.txt + # multiaddr bitarray==1.2.2 - # via eth-account + # via + # -r requirements.txt + # eth-account black==19.10b0 - # via -r requirements.in + # via -r requirements.txt certifi==2020.12.5 - # via requests -chardet==3.0.4 - # via requests + # via + # -r requirements.txt + # requests +chardet==4.0.0 + # via + # -r requirements.txt + # requests click==7.1.2 - # via black + # via + # -r requirements.txt + # black colorama==0.4.4 # via -r requirements-windows.in cytoolz==0.11.0 # via + # -r requirements.txt # eth-keyfile # eth-utils eth-abi==2.1.1 # via - # -r requirements.in + # -r requirements.txt # eth-account # eth-event # web3 eth-account==0.5.4 # via - # -r requirements.in + # -r requirements.txt # web3 eth-event==1.2.3 - # via -r requirements.in -eth-hash[pycryptodome]==0.3.1 + # via -r requirements.txt +eth-hash[pycryptodome]==0.2.0 # via - # -r requirements.in + # -r requirements.txt # eth-event # eth-utils # web3 eth-keyfile==0.5.1 - # via eth-account + # via + # -r requirements.txt + # eth-account eth-keys==0.3.3 # via + # -r requirements.txt # eth-account # eth-keyfile eth-rlp==0.2.1 - # via eth-account + # via + # -r requirements.txt + # eth-account eth-typing==2.2.2 # via + # -r requirements.txt # eth-abi # eth-keys # eth-utils # web3 -eth-utils==1.10.0 +eth-utils==1.9.5 # via - # -r requirements.in + # -r requirements.txt # eth-abi # eth-account # eth-event - # eth-hash # eth-keyfile # eth-keys # eth-rlp # rlp # web3 execnet==1.8.0 - # via pytest-xdist + # via + # -r requirements.txt + # pytest-xdist hexbytes==0.2.1 # via - # -r requirements.in + # -r requirements.txt # eth-account # eth-event # eth-rlp # web3 -hypothesis==5.49.0 - # via -r requirements.in +hypothesis==5.41.3 + # via -r requirements.txt idna==2.10 - # via requests -inflection==0.5.1 # via + # -r requirements.txt + # requests +inflection==0.5.0 + # via + # -r requirements.txt # mythx-models # pythx iniconfig==1.1.1 - # via pytest + # via + # -r requirements.txt + # pytest ipfshttpclient==0.7.0a1 - # via web3 + # via + # -r requirements.txt + # web3 jsonschema==3.2.0 # via + # -r requirements.txt # mythx-models # web3 lru-dict==1.1.7 - # via web3 + # via + # -r requirements.txt + # web3 +more-itertools==8.7.0 + # via + # -r requirements.txt + # pytest multiaddr==0.0.9 - # via ipfshttpclient -mythx-models==2.0.1 - # via pythx + # via + # -r requirements.txt + # ipfshttpclient +mythx-models==1.9.1 + # via + # -r requirements.txt + # pythx netaddr==0.8.0 - # via multiaddr + # via + # -r requirements.txt + # multiaddr packaging==20.9 - # via pytest + # via + # -r requirements.txt + # pytest parsimonious==0.8.1 - # via eth-abi + # via + # -r requirements.txt + # eth-abi pathspec==0.8.1 - # via black + # via + # -r requirements.txt + # black pluggy==0.13.1 - # via pytest -prompt-toolkit==3.0.17 - # via -r requirements.in + # via + # -r requirements.txt + # pytest +prompt-toolkit==3.0.8 + # via -r requirements.txt protobuf==3.15.6 - # via web3 + # via + # -r requirements.txt + # web3 psutil==5.8.0 - # via -r requirements.in + # via -r requirements.txt py-solc-ast==1.2.8 - # via -r requirements.in + # via -r requirements.txt py-solc-x==1.1.0 - # via -r requirements.in + # via -r requirements.txt py==1.10.0 # via - # -r requirements.in + # -r requirements.txt # pytest # pytest-forked pycryptodome==3.10.1 # via + # -r requirements.txt # eth-hash # eth-keyfile # vyper -pydantic==1.7.3 - # via mythx-models pygments-lexer-solidity==0.5.1 - # via -r requirements.in + # via -r requirements.txt pygments==2.8.1 # via - # -r requirements.in + # -r requirements.txt # pygments-lexer-solidity pyjwt==1.7.1 - # via pythx + # via + # -r requirements.txt + # pythx pyparsing==2.4.7 - # via packaging + # via + # -r requirements.txt + # packaging pyrsistent==0.17.3 - # via jsonschema + # via + # -r requirements.txt + # jsonschema pytest-forked==1.3.0 - # via pytest-xdist + # via + # -r requirements.txt + # pytest-xdist pytest-xdist==1.34.0 - # via -r requirements.in -pytest==6.2.2 + # via -r requirements.txt +pytest==6.0.1 # via - # -r requirements.in + # -r requirements.txt # pytest-forked # pytest-xdist python-dateutil==2.8.1 # via + # -r requirements.txt # mythx-models # pythx -pythx==1.7.1 - # via -r requirements.in +python-dotenv==0.16.0 + # via -r requirements.txt +pythx==1.6.1 + # via -r requirements.txt pyyaml==5.4.1 - # via -r requirements.in + # via -r requirements.txt regex==2020.11.13 - # via black -requests==2.25.0 # via - # -r requirements.in + # -r requirements.txt + # black +requests==2.25.1 + # via + # -r requirements.txt # ipfshttpclient # py-solc-x # pythx @@ -182,17 +249,18 @@ requests==2.25.0 # web3 rlp==1.2.0 # via - # -r requirements.in + # -r requirements.txt # eth-account # eth-rlp semantic-version==2.8.5 # via - # -r requirements.in + # -r requirements.txt # py-solc-x # vvm # vyper six==1.15.0 # via + # -r requirements.txt # asttokens # jsonschema # multiaddr @@ -201,31 +269,46 @@ six==1.15.0 # pytest-xdist # python-dateutil sortedcontainers==2.3.0 - # via hypothesis + # via + # -r requirements.txt + # hypothesis toml==0.10.2 # via + # -r requirements.txt # black # pytest toolz==0.11.1 - # via cytoolz -tqdm==4.59.0 - # via -r requirements.in + # via + # -r requirements.txt + # cytoolz +tqdm==4.53.0 + # via -r requirements.txt typed-ast==1.4.2 - # via black + # via + # -r requirements.txt + # black urllib3==1.26.4 - # via requests + # via + # -r requirements.txt + # requests varint==1.0.2 - # via multiaddr + # via + # -r requirements.txt + # multiaddr vvm==0.1.0 - # via -r requirements.in + # via -r requirements.txt vyper==0.2.12 - # via -r requirements.in + # via -r requirements.txt wcwidth==0.2.5 - # via prompt-toolkit -web3==5.17.0 - # via -r requirements.in + # via + # -r requirements.txt + # prompt-toolkit +web3==5.18.0 + # via -r requirements.txt websockets==8.1 - # via web3 + # via + # -r requirements.txt + # web3 # The following packages are considered to be unsafe in a requirements file: # setuptools From 14bc28f92c5a5b94a0c0aab6d35ce4da61cb2155 Mon Sep 17 00:00:00 2001 From: Edward Amor Date: Fri, 16 Apr 2021 16:18:00 -0400 Subject: [PATCH 5/6] feat: add TxRevertCatcher Middleware --- .../network/middlewares/catch_tx_revert.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 brownie/network/middlewares/catch_tx_revert.py diff --git a/brownie/network/middlewares/catch_tx_revert.py b/brownie/network/middlewares/catch_tx_revert.py new file mode 100644 index 000000000..5f6ad9589 --- /dev/null +++ b/brownie/network/middlewares/catch_tx_revert.py @@ -0,0 +1,28 @@ +from typing import Callable, Dict, List, Optional + +from web3 import Web3 + +from brownie.network.middlewares import BrownieMiddlewareABC + + +class TxRevertCatcherMiddleware(BrownieMiddlewareABC): + + """ + Middleware to handle reverting transactions, bypasses web3 error formatting. + + As of web3.py version 5.13.0, a new error formatting middleware was added by default + `raise_solidity_error_on_revert` which when a `eth_call` or `eth_estimateGas` tx + raises a `ContractLogicError` instead of providing us with an RPCError dictionary. + """ + + @classmethod + def get_layer(cls, w3: Web3, network_type: str) -> Optional[int]: + return -1 + + def process_request(self, make_request: Callable, method: str, params: List) -> Dict: + """Raise a ValueError when RPC.eth_call or RPC.eth_estimateGas errors.""" + result = make_request(method, params) + if method in ("eth_call", "eth_estimateGas"): + if "error" in result: + raise ValueError(result["error"]) + return result From 4b134d4be9d3dde14f93f389cef9651910c9520e Mon Sep 17 00:00:00 2001 From: Edward Amor Date: Fri, 16 Apr 2021 18:46:00 -0400 Subject: [PATCH 6/6] fix: replace deprecated web3.eth methods Replace all instances of deprecated web3.eth methods with their new methods. --- brownie/network/account.py | 14 ++++---- brownie/network/contract.py | 16 ++++----- brownie/network/gas/bases.py | 6 ++-- brownie/network/main.py | 4 +-- brownie/network/middlewares/caching.py | 4 +-- brownie/network/middlewares/geth_poa.py | 2 +- brownie/network/rpc/__init__.py | 4 +-- brownie/network/state.py | 34 +++++++++---------- brownie/network/transaction.py | 20 +++++------ brownie/network/web3.py | 8 ++--- docs/api-network.rst | 32 ++++++++--------- docs/config.rst | 6 ++-- docs/core-chain.rst | 14 ++++---- docs/core-contracts.rst | 8 ++--- docs/tests-pytest-fixtures.rst | 4 +-- tests/network/account/test_account_deploy.py | 6 ++-- .../network/account/test_account_transfer.py | 16 ++++----- tests/network/contract/test_contractcall.py | 10 +++--- .../contract/test_contractconstructor.py | 6 ++-- tests/network/contract/test_contracttx.py | 8 ++--- tests/network/rpc/test_cache.py | 4 +-- tests/network/state/test_blocks.py | 8 ++--- tests/network/state/test_calls.py | 14 ++++---- tests/network/state/test_redo.py | 2 +- tests/network/state/test_undo.py | 6 ++-- tests/network/test_main_network.py | 2 +- tests/network/test_web3.py | 4 +-- tests/network/transaction/test_attributes.py | 2 +- .../test_required_confirmations.py | 20 +++++------ tests/project/test_brownie_config.py | 2 +- tests/test/plugin/test_conftest.py | 4 +-- tests/test/plugin/test_coverage.py | 8 ++--- tests/test/plugin/test_given.py | 2 +- tests/test/plugin/test_isolation_fixtures.py | 8 ++--- tests/test/stateful/test_setup.py | 2 +- 35 files changed, 155 insertions(+), 155 deletions(-) diff --git a/brownie/network/account.py b/brownie/network/account.py index 7371b1f59..f15c8e71d 100644 --- a/brownie/network/account.py +++ b/brownie/network/account.py @@ -293,7 +293,7 @@ def __eq__(self, other: Union[object, str]) -> bool: def balance(self) -> Wei: """Returns the current balance at the address, in wei.""" - balance = web3.eth.getBalance(self.address) + balance = web3.eth.get_balance(self.address) return Wei(balance) @property @@ -303,7 +303,7 @@ def gas_used(self) -> int: @property def nonce(self) -> int: - return web3.eth.getTransactionCount(self.address) + return web3.eth.get_transaction_count(self.address) def get_deployment_address(self, nonce: Optional[int] = None) -> EthAddress: """ @@ -391,7 +391,7 @@ def _gas_price(self, gas_price: Any = None) -> Tuple[Wei, Optional[GasABC], Opti return gas_price, None, None if isinstance(gas_price, bool) or gas_price in (None, "auto"): - return web3.eth.generateGasPrice(), None, None + return web3.eth.generate_gas_price(), None, None return Wei(gas_price), None, None @@ -547,11 +547,11 @@ def estimate_gas( if gas_price is not None: tx["gasPrice"] = gas_price try: - return web3.eth.estimateGas(tx) + return web3.eth.estimate_gas(tx) except ValueError as exc: revert_gas_limit = CONFIG.active_network["settings"]["reverting_tx_gas_limit"] if revert_gas_limit == "max": - revert_gas_limit = web3.eth.getBlock("latest")["gasLimit"] + revert_gas_limit = web3.eth.get_block("latest")["gasLimit"] CONFIG.active_network["settings"]["reverting_tx_gas_limit"] = revert_gas_limit if revert_gas_limit: return revert_gas_limit @@ -708,7 +708,7 @@ def _transact(self, tx: Dict, allow_revert: bool) -> Any: allow_revert = bool(CONFIG.network_type == "development") if not allow_revert: self._check_for_revert(tx) - return web3.eth.sendTransaction(tx) + return web3.eth.send_transaction(tx) class LocalAccount(_PrivateKeyAccount): @@ -764,4 +764,4 @@ def _transact(self, tx: Dict, allow_revert: bool) -> None: self._check_for_revert(tx) tx["chainId"] = web3.chain_id signed_tx = self._acct.sign_transaction(tx).rawTransaction # type: ignore - return web3.eth.sendRawTransaction(signed_tx) + return web3.eth.send_raw_transaction(signed_tx) diff --git a/brownie/network/contract.py b/brownie/network/contract.py index 2a9dd3e16..81f5bba37 100644 --- a/brownie/network/contract.py +++ b/brownie/network/contract.py @@ -180,7 +180,7 @@ def _revert(self, height: int) -> None: i for i in self._contracts if (i.tx and i.tx.block_number is not None and i.tx.block_number > height) - or len(web3.eth.getCode(i.address).hex()) <= 4 + or len(web3.eth.get_code(i.address).hex()) <= 4 ] for contract in reverted: self.remove(contract) @@ -745,7 +745,7 @@ def __init__( self, address: str, owner: Optional[AccountsType] = None, tx: TransactionReceiptType = None ) -> None: address = _resolve_address(address) - self.bytecode = web3.eth.getCode(address).hex()[2:] + self.bytecode = web3.eth.get_code(address).hex()[2:] if not self.bytecode: raise ContractNotFound(f"No contract deployed at {address}") self._owner = owner @@ -845,7 +845,7 @@ def get_method_object(self, calldata: str) -> Optional["_ContractMethod"]: def balance(self) -> Wei: """Returns the current ether balance of the contract, in wei.""" - balance = web3.eth.getBalance(self.address) + balance = web3.eth.get_balance(self.address) return Wei(balance) def _deployment_path(self) -> Optional[Path]: @@ -867,7 +867,7 @@ def _save_deployment(self) -> None: deployment_build["deployment"] = { "address": self.address, "chainid": chainid, - "blockHeight": web3.eth.blockNumber, + "blockHeight": web3.eth.block_number, } if path: self._project._add_to_deployment_map(self) @@ -1110,11 +1110,11 @@ def from_explorer( if as_proxy_for is None: # always check for an EIP1967 proxy - https://eips.ethereum.org/EIPS/eip-1967 - implementation_eip1967 = web3.eth.getStorageAt( + implementation_eip1967 = web3.eth.get_storage_at( address, int(web3.keccak(text="eip1967.proxy.implementation").hex(), 16) - 1 ) # always check for an EIP1822 proxy - https://eips.ethereum.org/EIPS/eip-1822 - implementation_eip1822 = web3.eth.getStorageAt(address, web3.keccak(text="PROXIABLE")) + implementation_eip1822 = web3.eth.get_storage_at(address, web3.keccak(text="PROXIABLE")) if len(implementation_eip1967) > 0 and int(implementation_eip1967.hex(), 16): as_proxy_for = _resolve_address(implementation_eip1967[-20:]) elif len(implementation_eip1822) > 0 and int(implementation_eip1822.hex(), 16): @@ -1791,7 +1791,7 @@ def _inputs(abi: Dict) -> str: def _verify_deployed_code(address: str, expected_bytecode: str, language: str) -> bool: - actual_bytecode = web3.eth.getCode(address).hex()[2:] + actual_bytecode = web3.eth.get_code(address).hex()[2:] expected_bytecode = remove_0x_prefix(expected_bytecode) # type: ignore if expected_bytecode.startswith("730000000000000000000000000000000000000000"): @@ -1846,7 +1846,7 @@ def _fetch_from_explorer(address: str, action: str, silent: bool) -> Dict: if address in _unverified_addresses: raise ValueError(f"Source for {address} has not been verified") - code = web3.eth.getCode(address).hex()[2:] + code = web3.eth.get_code(address).hex()[2:] # EIP-1167: Minimal Proxy Contract if code[:20] == "363d3d373d3d3d363d73" and code[60:] == "5af43d82803e903d91602b57fd5bf3": address = _resolve_address(code[20:60]) diff --git a/brownie/network/gas/bases.py b/brownie/network/gas/bases.py index 7286ba750..69dd993f4 100644 --- a/brownie/network/gas/bases.py +++ b/brownie/network/gas/bases.py @@ -52,13 +52,13 @@ def _loop(self, receipt: Any, gas_iter: Iterator) -> None: # silenced by the 2nd replacement silent = receipt._silent - while web3.eth.getTransactionCount(str(receipt.sender)) < receipt.nonce: + while web3.eth.get_transaction_count(str(receipt.sender)) < receipt.nonce: # do not run scaling strategy while prior tx's are still pending time.sleep(5) latest_interval = self.interval() while True: - if web3.eth.getTransactionCount(str(receipt.sender)) > receipt.nonce: + if web3.eth.get_transaction_count(str(receipt.sender)) > receipt.nonce: break if self.interval() - latest_interval >= self.duration: @@ -122,7 +122,7 @@ def __init__(self, block_duration: int = 2) -> None: self.duration = block_duration def interval(self) -> int: - return web3.eth.blockNumber + return web3.eth.block_number @abstractmethod def get_gas_price(self) -> Generator[int, None, None]: diff --git a/brownie/network/main.py b/brownie/network/main.py index b7ca4b853..2cdb81b27 100644 --- a/brownie/network/main.py +++ b/brownie/network/main.py @@ -40,9 +40,9 @@ def connect(network: str = None, launch_rpc: bool = True) -> None: web3.connect(host, active.get("timeout", 30)) if CONFIG.network_type == "development" and launch_rpc and not rpc.is_active(): if is_connected(): - if web3.eth.blockNumber != 0: + if web3.eth.block_number != 0: warnings.warn( - f"Development network has a block height of {web3.eth.blockNumber}", + f"Development network has a block height of {web3.eth.block_number}", BrownieEnvironmentWarning, ) rpc.attach(host) diff --git a/brownie/network/middlewares/caching.py b/brownie/network/middlewares/caching.py index a8ef9bea4..17363e7da 100644 --- a/brownie/network/middlewares/caching.py +++ b/brownie/network/middlewares/caching.py @@ -76,7 +76,7 @@ def is_cacheable_bytecode(web3: Web3, bytecode: HexBytes) -> bool: if not int(address.hex(), 16): # if the delegatecall targets 0x00 this is a factory pattern, we can ignore continue - target_bytecode = web3.eth.getCode(address) + target_bytecode = web3.eth.get_code(address) if not is_cacheable_bytecode(web3, target_bytecode): return False @@ -96,7 +96,7 @@ def __init__(self, w3: Web3) -> None: self.cur = Cursor(_get_data_folder().joinpath("cache.db")) self.cur.execute(f"CREATE TABLE IF NOT EXISTS {self.table_key} (method, params, result)") - latest = w3.eth.getBlock("latest") + latest = w3.eth.get_block("latest") self.last_block = latest.hash self.last_block_seen = latest.timestamp self.last_request = 0.0 diff --git a/brownie/network/middlewares/geth_poa.py b/brownie/network/middlewares/geth_poa.py index 95d92cdd2..15f367f09 100644 --- a/brownie/network/middlewares/geth_poa.py +++ b/brownie/network/middlewares/geth_poa.py @@ -11,7 +11,7 @@ class GethPOAMiddleware(BrownieMiddlewareABC): @classmethod def get_layer(cls, w3: Web3, network_type: str) -> Optional[int]: try: - w3.eth.getBlock("latest") + w3.eth.get_block("latest") return None except ExtraDataLengthError: return -1 diff --git a/brownie/network/rpc/__init__.py b/brownie/network/rpc/__init__.py index e34c98948..d79789fb1 100644 --- a/brownie/network/rpc/__init__.py +++ b/brownie/network/rpc/__init__.py @@ -171,7 +171,7 @@ def sleep(self, seconds: int) -> int: @internal def mine(self, timestamp: int = None) -> int: self.backend.mine(timestamp) - return web3.eth.blockNumber + return web3.eth.block_number @internal def snapshot(self) -> int: @@ -180,7 +180,7 @@ def snapshot(self) -> int: @internal def revert(self, snapshot_id: int) -> int: self.backend.revert(snapshot_id) - return web3.eth.blockNumber + return web3.eth.block_number def unlock_account(self, address: str) -> None: self.backend.unlock_account(address) diff --git a/brownie/network/state.py b/brownie/network/state.py index cfbd094a6..4cb16280d 100644 --- a/brownie/network/state.py +++ b/brownie/network/state.py @@ -203,7 +203,7 @@ def __len__(self) -> int: """ Return the current number of blocks. """ - return web3.eth.blockNumber + 1 + return web3.eth.block_number + 1 def __getitem__(self, block_number: int) -> BlockData: """ @@ -224,15 +224,15 @@ def __getitem__(self, block_number: int) -> BlockData: if not isinstance(block_number, int): raise TypeError("Block height must be given as an integer") if block_number < 0: - block_number = web3.eth.blockNumber + 1 + block_number - block = web3.eth.getBlock(block_number) + block_number = web3.eth.block_number + 1 + block_number + block = web3.eth.get_block(block_number) if block["timestamp"] > self._block_gas_time: self._block_gas_limit = block["gasLimit"] self._block_gas_time = block["timestamp"] return block def __iter__(self) -> Iterator: - return iter(web3.eth.getBlock(i) for i in range(web3.eth.blockNumber + 1)) + return iter(web3.eth.get_block(i) for i in range(web3.eth.block_number + 1)) def new_blocks(self, height_buffer: int = 0, poll_interval: int = 5) -> Iterator: """ @@ -255,9 +255,9 @@ def new_blocks(self, height_buffer: int = 0, poll_interval: int = 5) -> Iterator last_poll = 0.0 while True: - if last_poll + poll_interval < time.time() or last_height != web3.eth.blockNumber: - last_height = web3.eth.blockNumber - block = web3.eth.getBlock(last_height - height_buffer) + if last_poll + poll_interval < time.time() or last_height != web3.eth.block_number: + last_height = web3.eth.block_number + block = web3.eth.get_block(last_height - height_buffer) last_poll = time.time() if block != last_block: @@ -268,25 +268,25 @@ def new_blocks(self, height_buffer: int = 0, poll_interval: int = 5) -> Iterator @property def height(self) -> int: - return web3.eth.blockNumber + return web3.eth.block_number @property def id(self) -> int: if self._chainid is None: - self._chainid = web3.eth.chainId + self._chainid = web3.eth.chain_id return self._chainid @property def block_gas_limit(self) -> Wei: if time.time() > self._block_gas_time + 3600: - block = web3.eth.getBlock("latest") + block = web3.eth.get_block("latest") self._block_gas_limit = block["gasLimit"] self._block_gas_time = block["timestamp"] return Wei(self._block_gas_limit) def _revert(self, id_: int) -> int: rpc_client = rpc.Rpc() - if web3.isConnected() and not web3.eth.blockNumber and not self._time_offset: + if web3.isConnected() and not web3.eth.block_number and not self._time_offset: _notify_registry(0) return rpc_client.snapshot() rpc_client.revert(id_) @@ -402,7 +402,7 @@ def mine(self, blocks: int = 1, timestamp: int = None, timedelta: int = None) -> self._redo_buffer.clear() self._current_id = rpc.Rpc().snapshot() - return web3.eth.blockNumber + return web3.eth.block_number def snapshot(self) -> None: """ @@ -430,7 +430,7 @@ def revert(self) -> int: self._undo_buffer.clear() self._redo_buffer.clear() self._snapshot_id = self._current_id = self._revert(self._snapshot_id) - return web3.eth.blockNumber + return web3.eth.block_number def reset(self) -> int: """ @@ -451,7 +451,7 @@ def reset(self) -> int: _notify_registry(0) else: self._reset_id = self._current_id = self._revert(self._reset_id) - return web3.eth.blockNumber + return web3.eth.block_number def undo(self, num: int = 1) -> int: """ @@ -480,7 +480,7 @@ def undo(self, num: int = 1) -> int: self._redo_buffer.append((fn, args, kwargs)) self._current_id = self._revert(id_) - return web3.eth.blockNumber + return web3.eth.block_number def redo(self, num: int = 1) -> int: """ @@ -508,7 +508,7 @@ def redo(self, num: int = 1) -> int: fn, args, kwargs = self._redo_buffer.pop() fn(*args, **kwargs) - return web3.eth.blockNumber + return web3.eth.block_number # objects that will update whenever the RPC is reset or reverted must register @@ -521,7 +521,7 @@ def _revert_register(obj: object) -> None: def _notify_registry(height: int = None) -> None: gc.collect() if height is None: - height = web3.eth.blockNumber + height = web3.eth.block_number for ref in _revert_refs.copy(): obj = ref() if obj is None: diff --git a/brownie/network/transaction.py b/brownie/network/transaction.py index 0aea7578f..86cb72e4a 100644 --- a/brownie/network/transaction.py +++ b/brownie/network/transaction.py @@ -283,13 +283,13 @@ def trace(self) -> Optional[List]: def timestamp(self) -> Optional[int]: if self.status < 0: return None - return web3.eth.getBlock(self.block_number)["timestamp"] + return web3.eth.get_block(self.block_number)["timestamp"] @property def confirmations(self) -> int: if not self.block_number: return 0 - return web3.eth.blockNumber - self.block_number + 1 + return web3.eth.block_number - self.block_number + 1 def replace( self, @@ -361,11 +361,11 @@ def wait(self, required_confs: int) -> None: while True: try: - tx: Dict = web3.eth.getTransaction(self.txid) + tx: Dict = web3.eth.get_transaction(self.txid) break except TransactionNotFound: if self.nonce is not None: - sender_nonce = web3.eth.getTransactionCount(str(self.sender)) + sender_nonce = web3.eth.get_transaction_count(str(self.sender)) if sender_nonce > self.nonce: self.status = Status(-2) self._confirmed.set() @@ -398,7 +398,7 @@ def _await_transaction(self, required_confs: int, is_blocking: bool) -> None: # await tx showing in mempool while True: try: - tx: Dict = web3.eth.getTransaction(HexBytes(self.txid)) + tx: Dict = web3.eth.get_transaction(HexBytes(self.txid)) break except (TransactionNotFound, ValueError): if self.sender is None: @@ -406,7 +406,7 @@ def _await_transaction(self, required_confs: int, is_blocking: bool) -> None: # not broadcasted locally and so likely doesn't exist raise if self.nonce is not None: - sender_nonce = web3.eth.getTransactionCount(str(self.sender)) + sender_nonce = web3.eth.get_transaction_count(str(self.sender)) if sender_nonce > self.nonce: self.status = Status(-2) return @@ -444,10 +444,10 @@ def _await_confirmation(self, block_number: int = None, required_confs: int = 1) # await first confirmation while True: # if sender nonce is greater than tx nonce, the tx should be confirmed - sender_nonce = web3.eth.getTransactionCount(str(self.sender)) + sender_nonce = web3.eth.get_transaction_count(str(self.sender)) expect_confirmed = bool(sender_nonce > self.nonce) # type: ignore try: - receipt = web3.eth.waitForTransactionReceipt( + receipt = web3.eth.wait_for_transaction_receipt( HexBytes(self.txid), timeout=15, poll_latency=1 ) break @@ -463,14 +463,14 @@ def _await_confirmation(self, block_number: int = None, required_confs: int = 1) remaining_confs = required_confs while remaining_confs > 0 and required_confs > 1: try: - receipt = web3.eth.getTransactionReceipt(self.txid) + receipt = web3.eth.get_transaction_receipt(self.txid) self.block_number = receipt["blockNumber"] except TransactionNotFound: if not self._silent: sys.stdout.write(f"\r{color('red')}Transaction was lost...{color}{' ' * 8}") sys.stdout.flush() # check if tx is still in mempool, this will raise otherwise - tx = web3.eth.getTransaction(self.txid) + tx = web3.eth.get_transaction(self.txid) self.block_number = None return self._await_confirmation(tx["blockNumber"], required_confs) if required_confs - self.confirmations != remaining_confs: diff --git a/brownie/network/web3.py b/brownie/network/web3.py index 6bbc4ab63..c8f4138fc 100644 --- a/brownie/network/web3.py +++ b/brownie/network/web3.py @@ -149,7 +149,7 @@ def genesis_hash(self) -> str: if self.provider is None: raise ConnectionError("web3 is not currently connected") if self._genesis_hash is None: - self._genesis_hash = self.eth.getBlock(0)["hash"].hex()[2:] + self._genesis_hash = self.eth.get_block(0)["hash"].hex()[2:] return self._genesis_hash @property @@ -157,8 +157,8 @@ def chain_uri(self) -> str: if self.provider is None: raise ConnectionError("web3 is not currently connected") if self.genesis_hash not in _chain_uri_cache: - block_number = max(self.eth.blockNumber - 16, 0) - block_hash = self.eth.getBlock(block_number)["hash"].hex()[2:] + block_number = max(self.eth.block_number - 16, 0) + block_hash = self.eth.get_block(block_number)["hash"].hex()[2:] chain_uri = f"blockchain://{self.genesis_hash}/block/{block_hash}" _chain_uri_cache[self.genesis_hash] = chain_uri return _chain_uri_cache[self.genesis_hash] @@ -170,7 +170,7 @@ def chain_id(self) -> int: if self.provider is None: raise ConnectionError("web3 is not currently connected") if self._chain_id is None: - self._chain_id = self.eth.chainId + self._chain_id = self.eth.chain_id return self._chain_id diff --git a/docs/api-network.rst b/docs/api-network.rst index fee4d25b0..eb163bb41 100644 --- a/docs/api-network.rst +++ b/docs/api-network.rst @@ -62,7 +62,7 @@ The ``main`` module contains methods for conncting to or disconnecting from the * If no argument is given, the current default is displayed. * If an integer value is given, this will be the default gas limit. - * If set to ``auto``, the gas limit is determined automatically via :meth:`web3.eth.estimateGas `. + * If set to ``auto``, the gas limit is determined automatically via :meth:`web3.eth.estimate_gas `. Returns ``False`` if the gas limit is set automatically, or an ``int`` if it is set to a fixed value. @@ -99,7 +99,7 @@ The ``main`` module contains methods for conncting to or disconnecting from the Gets and optionally sets the default gas price. * If an integer value is given, this will be the default gas price. - * If set to ``auto``, the gas price is determined automatically via :attr:`web3.eth.gasPrice `. + * If set to ``auto``, the gas price is determined automatically via :attr:`web3.eth.gas_price `. Returns ``False`` if the gas price is set automatically, or an ``int`` if it is set to a fixed value. @@ -304,10 +304,10 @@ Account Methods * ``contract``: A :func:`ContractContainer ` instance of the contract to be deployed. * ``*args``: Contract constructor arguments. * ``amount``: Amount of ether to send with the transaction. The given value is converted to :func:`Wei `. - * ``gas_limit``: Gas limit for the transaction. The given value is converted to :func:`Wei `. If none is given, the price is set using :meth:`web3.eth.estimateGas `. - * ``gas_buffer``: A multiplier applied to :meth:`web3.eth.estimateGas ` when setting gas limit automatically. ``gas_limit`` and ``gas_buffer`` cannot be given at the same time. - * ``gas_price``: Gas price for the transaction. The given value is converted to :func:`Wei `. If none is given, the price is set using :attr:`web3.eth.gasPrice `. - * ``nonce``: Nonce for the transaction. If none is given, the nonce is set using :meth:`web3.eth.getTransactionCount ` while also considering any pending transactions of the Account. + * ``gas_limit``: Gas limit for the transaction. The given value is converted to :func:`Wei `. If none is given, the price is set using :meth:`web3.eth.estimate_gas `. + * ``gas_buffer``: A multiplier applied to :meth:`web3.eth.estimate_gas ` when setting gas limit automatically. ``gas_limit`` and ``gas_buffer`` cannot be given at the same time. + * ``gas_price``: Gas price for the transaction. The given value is converted to :func:`Wei `. If none is given, the price is set using :attr:`web3.eth.gas_price `. + * ``nonce``: Nonce for the transaction. If none is given, the nonce is set using :meth:`web3.eth.get_transaction_count ` while also considering any pending transactions of the Account. * ``required_confs``: The required :attr:`confirmations` before the :func:`TransactionReceipt ` is processed. If none is given, defaults to 1 confirmation. If 0 is given, immediately returns a pending :func:`TransactionReceipt ` instead of a :func:`Contract ` instance, while waiting for a confirmation in a separate thread. * ``allow_revert``: When ``True``, forces the deployment of a contract, even if a revert reason is detected. * ``silent``: When ``True``, suppresses any console output for the deployment. @@ -366,11 +366,11 @@ Account Methods * ``to``: Recipient address. Can be an :func:`Account ` instance or string. * ``amount``: Amount of ether to send. The given value is converted to :func:`Wei `. - * ``gas_limit``: Gas limit for the transaction. The given value is converted to :func:`Wei `. If none is given, the price is set using :meth:`web3.eth.estimateGas `. - * ``gas_buffer``: A multiplier applied to :meth:`web3.eth.estimateGas ` when setting gas limit automatically. ``gas_limit`` and ``gas_buffer`` cannot be given at the same time. - * ``gas_price``: Gas price for the transaction. The given value is converted to :func:`Wei `. If none is given, the price is set using :attr:`web3.eth.gasPrice `. + * ``gas_limit``: Gas limit for the transaction. The given value is converted to :func:`Wei `. If none is given, the price is set using :meth:`web3.eth.estimate_gas `. + * ``gas_buffer``: A multiplier applied to :meth:`web3.eth.estimate_gas ` when setting gas limit automatically. ``gas_limit`` and ``gas_buffer`` cannot be given at the same time. + * ``gas_price``: Gas price for the transaction. The given value is converted to :func:`Wei `. If none is given, the price is set using :attr:`web3.eth.gas_price `. * ``data``: Transaction data hexstring. - * ``nonce``: Nonce for the transaction. If none is given, the nonce is set using :meth:`web3.eth.getTransactionCount ` while also considering any pending transactions of the Account. + * ``nonce``: Nonce for the transaction. If none is given, the nonce is set using :meth:`web3.eth.get_transaction_count ` while also considering any pending transactions of the Account. * ``required_confs``: The required :attr:`confirmations` before the :func:`TransactionReceipt ` is processed. If none is given, defaults to 1 confirmation. If 0 is given, immediately returns a pending :func:`TransactionReceipt `, while waiting for a confirmation in a separate thread. * ``allow_revert``: Boolean indicating whether the transaction should be broadacsted when it is expected to revert. If not set, the default behaviour is to allow reverting transactions in development and disallow them in a live environment. * ``silent``: Toggles console verbosity. If ``True`` is given, suppresses all console output for this transaction. @@ -1768,16 +1768,16 @@ Chain .. code-block:: python - >>> web3.eth.blockNumber + >>> web3.eth.block_number 10451202 >>> len(chain) 10451203 # always +1 to the current block number, because the first block is zero - >>> chain[0] == web3.eth.getBlock(0) + >>> chain[0] == web3.eth.get_block(0) True - >>> chain[-1] == web3.eth.getBlock('latest') + >>> chain[-1] == web3.eth.get_block('latest') True Chain Attributes @@ -1866,7 +1866,7 @@ Chain Methods .. code-block:: python - >>> web3.eth.blockNumber + >>> web3.eth.block_number 0 >>> chain.mine() 1 @@ -1925,7 +1925,7 @@ Chain Methods .. code-block:: python - >>> web3.eth.blockNumber + >>> web3.eth.block_number 3 >>> chain.undo() 2 @@ -1940,7 +1940,7 @@ Chain Methods .. code-block:: python - >>> web3.eth.blockNumber + >>> web3.eth.block_number 2 >>> chain.redo() Transaction sent: 0x8c166b66b356ad7f5c58337973b89950f03105cdae896ac66f16cdd4fc395d05 diff --git a/docs/config.rst b/docs/config.rst index c26ea69f1..c5b5875f3 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -135,7 +135,7 @@ Networks .. py:attribute:: gas_limit - The default gas limit for all transactions. If set to ``auto`` the gas limit is determined using ``web3.eth.estimateGas``. If set to ``max``, the block gas limit is used. + The default gas limit for all transactions. If set to ``auto`` the gas limit is determined using ``web3.eth.estimate_gas``. If set to ``max``, the block gas limit is used. development default: ``max`` @@ -143,7 +143,7 @@ Networks .. py:attribute:: gas_buffer - A modifier applied to ``web3.eth.estimateGas`` when determining gas price automatically. + A modifier applied to ``web3.eth.estimate_gas`` when determining gas price automatically. development default: ``1`` @@ -151,7 +151,7 @@ Networks .. py:attribute:: gas_price - The default gas price for all transactions. If set to ``auto`` the gas price is determined using ``web3.eth.gasPrice``. + The default gas price for all transactions. If set to ``auto`` the gas price is determined using ``web3.eth.gas_price``. development default: ``0`` diff --git a/docs/core-chain.rst b/docs/core-chain.rst index d31a5908a..3c58a4a80 100644 --- a/docs/core-chain.rst +++ b/docs/core-chain.rst @@ -37,17 +37,17 @@ The :func:`Chain ` object, available as ``chain``, 'uncles': [], }) - >>> web3.eth.blockNumber + >>> web3.eth.block_number 10451202 >>> len(chain) 10451203 # always +1 to the current block number, because the first block is zero - >>> chain[0] == web3.eth.getBlock(0) + >>> chain[0] == web3.eth.get_block(0) True # for negative index values, the block returned is relative to the most recently mined block - >>> chain[-1] == web3.eth.getBlock('latest') + >>> chain[-1] == web3.eth.get_block('latest') True Accessing Transaction Data @@ -102,11 +102,11 @@ Ganache's default behavior is to mine a new block each time you broadcast a tran .. code-block:: python - >>> web3.eth.blockNumber + >>> web3.eth.block_number 0 >>> chain.mine(50) 50 - >>> web3.eth.blockNumber + >>> web3.eth.block_number 50 Time Travel @@ -164,10 +164,10 @@ To return to the genesis state, use :func:`chain.reset `. .. code-block:: python - >>> web3.eth.blockNumber + >>> web3.eth.block_number 6 >>> chain.reset() - >>> web3.eth.blockNumber + >>> web3.eth.block_number 0 Undo / Redo diff --git a/docs/core-contracts.rst b/docs/core-contracts.rst index 922c4113b..87a61068e 100644 --- a/docs/core-contracts.rst +++ b/docs/core-contracts.rst @@ -140,11 +140,11 @@ Transaction Parameters When executing a transaction to a contract, you can optionally include a :py:class:`dict` of transaction parameters as the final input. It may contain the following values: * ``from``: the :func:`Account ` that the transaction it sent from. If not given, the transaction is sent from the account that deployed the contract. - * ``gas_limit``: The amount of gas provided for transaction execution, in wei. If not given, the gas limit is determined using :meth:`web3.eth.estimateGas `. - * ``gas_buffer``: A multiplier applied to :meth:`web3.eth.estimateGas ` when setting gas limit automatically. ``gas_limit`` and ``gas_buffer`` cannot be given at the same time. - * ``gas_price``: The gas price for the transaction, in wei. If not given, the gas price is set according to :attr:`web3.eth.gasPrice `. + * ``gas_limit``: The amount of gas provided for transaction execution, in wei. If not given, the gas limit is determined using :meth:`web3.eth.estimate_gas `. + * ``gas_buffer``: A multiplier applied to :meth:`web3.eth.estimate_gas ` when setting gas limit automatically. ``gas_limit`` and ``gas_buffer`` cannot be given at the same time. + * ``gas_price``: The gas price for the transaction, in wei. If not given, the gas price is set according to :attr:`web3.eth.gas_price `. * ``amount``: The amount of Ether to include with the transaction, in wei. - * ``nonce``: The nonce for the transaction. If not given, the nonce is set according to :meth:`web3.eth.getTransactionCount ` while taking pending transactions from the sender into account. + * ``nonce``: The nonce for the transaction. If not given, the nonce is set according to :meth:`web3.eth.get_transaction_count ` while taking pending transactions from the sender into account. * ``required_confs``: The required :attr:`confirmations` before the :func:`TransactionReceipt ` is processed. If none is given, defaults to 1 confirmation. If 0 is given, immediately returns a pending :func:`TransactionReceipt `, while waiting for a confirmation in a separate thread. * ``allow_revert``: Boolean indicating whether the transaction should be broadacsted when it is expected to revert. If not set, the default behaviour is to allow reverting transactions in development and disallow them in a live environment. diff --git a/docs/tests-pytest-fixtures.rst b/docs/tests-pytest-fixtures.rst index 426cadc54..b3ff4cc7a 100644 --- a/docs/tests-pytest-fixtures.rst +++ b/docs/tests-pytest-fixtures.rst @@ -114,9 +114,9 @@ These fixtures provide quick access to Brownie objects that are frequently used :linenos: def test_account_balance(accounts, web3): - height = web3.eth.blockNumber + height = web3.eth.block_number accounts[0].transfer(accounts[1], "10 ether") - assert web3.eth.blockNumber == height + 1 + assert web3.eth.block_number == height + 1 Contract Fixtures ================= diff --git a/tests/network/account/test_account_deploy.py b/tests/network/account/test_account_deploy.py index e2c2d5040..369ea1a4a 100644 --- a/tests/network/account/test_account_deploy.py +++ b/tests/network/account/test_account_deploy.py @@ -46,11 +46,11 @@ def test_gas_price_manual(BrownieTester, accounts): @pytest.mark.parametrize("auto", (True, False, None, "auto")) def test_gas_price_automatic(BrownieTester, accounts, config, web3, auto): - """gas price is set correctly using web3.eth.gasPrice""" + """gas price is set correctly using web3.eth.gas_price""" config.active_network["settings"]["gas_price"] = auto balance = accounts[0].balance() tx = accounts[0].deploy(BrownieTester, True).tx - assert tx.gas_price == web3.eth.gasPrice + assert tx.gas_price == web3.eth.gas_price assert accounts[0].balance() == balance - (tx.gas_price * tx.gas_used) @@ -80,7 +80,7 @@ def test_gas_limit_manual(BrownieTester, accounts): @pytest.mark.parametrize("auto", (True, False, None, "auto")) def test_gas_limit_automatic(BrownieTester, accounts, config, auto): - """gas limit is set correctly using web3.eth.estimateGas""" + """gas limit is set correctly using web3.eth.estimate_gas""" config.active_network["settings"]["gas_limit"] = auto tx = accounts[0].deploy(BrownieTester, True).tx assert tx.gas_limit == tx.gas_used diff --git a/tests/network/account/test_account_transfer.py b/tests/network/account/test_account_transfer.py index d169ac424..bfbaa0fbc 100644 --- a/tests/network/account/test_account_transfer.py +++ b/tests/network/account/test_account_transfer.py @@ -87,21 +87,21 @@ def test_nonce(accounts): def test_balance_int(accounts, web3, chain): """transfers use the correct balance""" balance = accounts[0].balance() - assert web3.eth.getBalance(accounts[0].address) == balance + assert web3.eth.get_balance(accounts[0].address) == balance accounts[1].transfer(accounts[0], 1000) assert accounts[0].balance() == balance + 1000 chain.reset() - assert web3.eth.getBalance(accounts[0].address) == balance + assert web3.eth.get_balance(accounts[0].address) == balance def test_balance_wei(accounts, web3, chain): """transfer balances are converted using wei""" balance = accounts[0].balance() - assert web3.eth.getBalance(accounts[0].address) == balance + assert web3.eth.get_balance(accounts[0].address) == balance accounts[1].transfer(accounts[0], "1 ether") assert accounts[0].balance() == balance + 1000000000000000000 chain.reset() - assert web3.eth.getBalance(accounts[0].address) == balance + assert web3.eth.get_balance(accounts[0].address) == balance def test_gas_price_manual(accounts): @@ -114,11 +114,11 @@ def test_gas_price_manual(accounts): @pytest.mark.parametrize("auto", (True, False, None, "auto")) def test_gas_price_automatic(accounts, config, web3, auto): - """gas price is set correctly using web3.eth.gasPrice""" + """gas price is set correctly using web3.eth.gas_price""" config.active_network["settings"]["gas_price"] = auto balance = accounts[0].balance() tx = accounts[0].transfer(accounts[1], 0) - assert tx.gas_price == web3.eth.gasPrice + assert tx.gas_price == web3.eth.gas_price assert accounts[0].balance() == balance - (tx.gas_price * 21000) @@ -164,7 +164,7 @@ def test_gas_buffer_send_to_eoa(accounts, config): @pytest.mark.parametrize("gas_limit", (True, False, None, "auto")) @pytest.mark.parametrize("gas_buffer", (1, 1.25)) def test_gas_limit_automatic(accounts, config, gas_limit, gas_buffer): - """gas limit is set correctly using web3.eth.estimateGas""" + """gas limit is set correctly using web3.eth.estimate_gas""" config.active_network["settings"]["gas_limit"] = gas_limit config.active_network["settings"]["gas_buffer"] = gas_buffer foo = compile_source(code).Foo.deploy({"from": accounts[0]}) @@ -221,7 +221,7 @@ def test_deploy_via_transfer(accounts, web3): bytecode = "0x3660006000376110006000366000732157a7894439191e520825fe9399ab8655e0f7085af41558576110006000f3" # NOQA: E501 tx = accounts[0].transfer(data=bytecode) assert tx.contract_name == "UnknownContract" - assert web3.eth.getCode(tx.contract_address) + assert web3.eth.get_code(tx.contract_address) def test_gas_limit_and_buffer(accounts): diff --git a/tests/network/contract/test_contractcall.py b/tests/network/contract/test_contractcall.py index 57fee0a80..5abaac533 100644 --- a/tests/network/contract/test_contractcall.py +++ b/tests/network/contract/test_contractcall.py @@ -47,31 +47,31 @@ def set_foo(_foo: int128): def test_always_transact(accounts, tester, argv, web3, monkeypatch, history): owner = tester.owner() argv["always_transact"] = True - height = web3.eth.blockNumber + height = web3.eth.block_number result = tester.owner() assert owner == result - assert web3.eth.blockNumber == height == len(history) + assert web3.eth.block_number == height == len(history) monkeypatch.setattr("brownie.network.chain.undo", lambda: None) result = tester.owner() tx = history[-1] assert owner == result - assert web3.eth.blockNumber == height + 1 == len(history) + assert web3.eth.block_number == height + 1 == len(history) assert tx.fn_name == "owner" def test_always_transact_block_identifier(accounts, tester, argv, web3, monkeypatch, history): argv["always_transact"] = True - height = web3.eth.blockNumber + height = web3.eth.block_number last_tx = history[-1] monkeypatch.setattr("brownie.network.chain.undo", lambda: None) tester.owner(block_identifier="latest") # using `block_identifier` should take priority over `always_transact` - assert web3.eth.blockNumber == height + assert web3.eth.block_number == height assert last_tx == history[-1] diff --git a/tests/network/contract/test_contractconstructor.py b/tests/network/contract/test_contractconstructor.py index f2ab789bd..1b3a6639e 100644 --- a/tests/network/contract/test_contractconstructor.py +++ b/tests/network/contract/test_contractconstructor.py @@ -45,11 +45,11 @@ def test_gas_price_manual(BrownieTester, accounts): @pytest.mark.parametrize("auto", (True, False, None, "auto")) def test_gas_price_automatic(BrownieTester, accounts, config, web3, auto): - """gas price is set correctly using web3.eth.gasPrice""" + """gas price is set correctly using web3.eth.gas_price""" config.active_network["settings"]["gas_price"] = auto balance = accounts[0].balance() tx = BrownieTester.deploy(True, {"from": accounts[0]}).tx - assert tx.gas_price == web3.eth.gasPrice + assert tx.gas_price == web3.eth.gas_price assert accounts[0].balance() == balance - (tx.gas_price * tx.gas_used) @@ -70,7 +70,7 @@ def test_gas_limit_manual(BrownieTester, accounts): @pytest.mark.parametrize("auto", (True, False, None, "auto")) def test_gas_limit_automatic(BrownieTester, accounts, config, auto): - """gas limit is set correctly using web3.eth.estimateGas""" + """gas limit is set correctly using web3.eth.estimate_gas""" config.active_network["settings"]["gas_limit"] = auto tx = BrownieTester.deploy(True, {"from": accounts[0]}).tx assert tx.gas_limit == tx.gas_used diff --git a/tests/network/contract/test_contracttx.py b/tests/network/contract/test_contracttx.py index 9a8a7ab91..0f4d1100f 100644 --- a/tests/network/contract/test_contracttx.py +++ b/tests/network/contract/test_contracttx.py @@ -84,7 +84,7 @@ def test_balance_int(tester, accounts, web3): """transfers use the correct balance""" tester.receiveEth({"from": accounts[0], "amount": 1000000}) assert tester.balance() == 1000000 - assert web3.eth.getBalance(tester.address) == 1000000 + assert web3.eth.get_balance(tester.address) == 1000000 def test_balance_wei(tester, accounts): @@ -103,11 +103,11 @@ def test_gas_price_manual(tester, accounts): @pytest.mark.parametrize("auto", (True, False, None, "auto")) def test_gas_price_automatic(tester, accounts, config, web3, auto): - """gas price is set correctly using web3.eth.gasPrice""" + """gas price is set correctly using web3.eth.gas_price""" config.active_network["settings"]["gas_price"] = auto balance = accounts[0].balance() tx = tester.doNothing({"from": accounts[0]}) - assert tx.gas_price == web3.eth.gasPrice + assert tx.gas_price == web3.eth.gas_price assert accounts[0].balance() == balance - (tx.gas_price * tx.gas_used) @@ -129,7 +129,7 @@ def test_gas_limit_manual(tester, accounts): @pytest.mark.parametrize("gas_limit", (True, False, None, "auto")) @pytest.mark.parametrize("gas_buffer", (1, 1.25)) def test_gas_limit_automatic(tester, accounts, config, gas_limit, gas_buffer): - """gas limit is set correctly using web3.eth.estimateGas""" + """gas limit is set correctly using web3.eth.estimate_gas""" config.active_network["settings"]["gas_limit"] = gas_limit config.active_network["settings"]["gas_buffer"] = gas_buffer tx = tester.doNothing({"from": accounts[0]}) diff --git a/tests/network/rpc/test_cache.py b/tests/network/rpc/test_cache.py index b9dc058fb..e185c8acf 100644 --- a/tests/network/rpc/test_cache.py +++ b/tests/network/rpc/test_cache.py @@ -59,7 +59,7 @@ def test_forwarder_to_good_code(accounts, web3): target = compile_source(good_code).Vyper.deploy({"from": accounts[0]}) tx = factory.make_forwarder(target, {"from": accounts[0]}) - bytecode = web3.eth.getCode(tx.return_value) + bytecode = web3.eth.get_code(tx.return_value) assert is_cacheable_bytecode(web3, bytecode) @@ -68,5 +68,5 @@ def test_forwarder_to_bad_code(accounts, web3): target = compile_source(selfdestruct_code).Boom.deploy({"from": accounts[0]}) tx = factory.make_forwarder(target, {"from": accounts[0]}) - bytecode = web3.eth.getCode(tx.return_value) + bytecode = web3.eth.get_code(tx.return_value) assert not is_cacheable_bytecode(web3, bytecode) diff --git a/tests/network/state/test_blocks.py b/tests/network/state/test_blocks.py index 2e1c47456..10731a1ba 100644 --- a/tests/network/state/test_blocks.py +++ b/tests/network/state/test_blocks.py @@ -30,22 +30,22 @@ def test_timestamp_multiple_blocks(devnetwork, chain): def test_getitem_negative_index(devnetwork, accounts, chain, web3): block = chain[-1] - assert block == web3.eth.getBlock("latest") + assert block == web3.eth.get_block("latest") accounts[0].transfer(accounts[1], 1000) assert chain[-1] != block - assert chain[-1] == web3.eth.getBlock("latest") + assert chain[-1] == web3.eth.get_block("latest") def test_getitem_positive_index(devnetwork, accounts, chain, web3): block = chain[0] - assert block == web3.eth.getBlock("latest") + assert block == web3.eth.get_block("latest") accounts[0].transfer(accounts[1], 1000) assert chain[0] == block - assert chain[0] != web3.eth.getBlock("latest") + assert chain[0] != web3.eth.get_block("latest") def test_mine_timestamp(devnetwork, chain): diff --git a/tests/network/state/test_calls.py b/tests/network/state/test_calls.py index ef11ee525..0fdb6c259 100644 --- a/tests/network/state/test_calls.py +++ b/tests/network/state/test_calls.py @@ -31,11 +31,11 @@ def test_time_exceptions(devnetwork, chain): def test_mine(devnetwork, chain, web3): - height = web3.eth.blockNumber + height = web3.eth.block_number chain.mine() - assert web3.eth.blockNumber == height + 1 + assert web3.eth.block_number == height + 1 chain.mine(5) - assert web3.eth.blockNumber == height + 6 + assert web3.eth.block_number == height + 6 def test_mine_exceptions(devnetwork, chain): @@ -46,18 +46,18 @@ def test_mine_exceptions(devnetwork, chain): def test_snapshot_revert(BrownieTester, accounts, chain, web3): - height = web3.eth.blockNumber + height = web3.eth.block_number balance = accounts[0].balance() count = len(BrownieTester) chain.snapshot() accounts[0].transfer(accounts[1], "1 ether") BrownieTester.deploy(True, {"from": accounts[0]}) chain.revert() - assert height == web3.eth.blockNumber + assert height == web3.eth.block_number assert balance == accounts[0].balance() assert count == len(BrownieTester) chain.revert() - assert height == web3.eth.blockNumber + assert height == web3.eth.block_number assert balance == accounts[0].balance() assert count == len(BrownieTester) @@ -72,6 +72,6 @@ def test_reset(BrownieTester, accounts, chain, web3): accounts[0].transfer(accounts[1], "1 ether") BrownieTester.deploy(True, {"from": accounts[0]}) chain.reset() - assert web3.eth.blockNumber == 0 + assert web3.eth.block_number == 0 assert accounts[0].balance() == 100000000000000000000 assert len(BrownieTester) == 0 diff --git a/tests/network/state/test_redo.py b/tests/network/state/test_redo.py index 5e2eabd67..53c566d26 100644 --- a/tests/network/state/test_redo.py +++ b/tests/network/state/test_redo.py @@ -9,7 +9,7 @@ def test_redo(accounts, chain, web3): result = accounts[0].balance() chain.undo() chain.redo() - assert web3.eth.blockNumber == 1 + assert web3.eth.block_number == 1 assert accounts[0].balance() == result diff --git a/tests/network/state/test_undo.py b/tests/network/state/test_undo.py index 03eff1b67..ffbdfa56c 100644 --- a/tests/network/state/test_undo.py +++ b/tests/network/state/test_undo.py @@ -7,7 +7,7 @@ def test_undo(accounts, chain, web3): initial = accounts[0].balance() accounts[0].transfer(accounts[1], "1 ether") chain.undo() - assert web3.eth.blockNumber == 0 + assert web3.eth.block_number == 0 assert accounts[0].balance() == initial @@ -64,7 +64,7 @@ def test_does_not_undo_sleep(accounts, chain): def test_does_not_undo_mining(accounts, chain, web3): accounts[0].transfer(accounts[1], 100) chain.mine() - height = web3.eth.blockNumber + height = web3.eth.block_number accounts[0].transfer(accounts[1], 100) chain.undo() - assert web3.eth.blockNumber == height + assert web3.eth.block_number == height diff --git a/tests/network/test_main_network.py b/tests/network/test_main_network.py index a7f249ba1..a0c1cba82 100644 --- a/tests/network/test_main_network.py +++ b/tests/network/test_main_network.py @@ -82,7 +82,7 @@ def test_gas_price_manual(devnetwork, accounts): def test_gas_price_auto(devnetwork, accounts, web3): devnetwork.gas_price(None) tx = accounts[0].transfer(accounts[1], 0) - assert tx.gas_price == web3.eth.gasPrice + assert tx.gas_price == web3.eth.gas_price def test_gas_price_raises(devnetwork): diff --git a/tests/network/test_web3.py b/tests/network/test_web3.py index 84f325c2e..0d1d46e78 100755 --- a/tests/network/test_web3.py +++ b/tests/network/test_web3.py @@ -65,7 +65,7 @@ def test_disconnect(web3): def test_genesis_hash(web3, devnetwork): - assert web3.genesis_hash == web3.eth.getBlock(0)["hash"].hex()[2:] + assert web3.genesis_hash == web3.eth.get_block(0)["hash"].hex()[2:] def test_genesis_hash_different_networks(devnetwork, web3): @@ -99,7 +99,7 @@ def test_rinkeby(web3, network): network.connect("rinkeby") # this should work because we automatically add the POA middleware - web3.eth.getBlock("latest") + web3.eth.get_block("latest") def test_supports_traces_development(web3, devnetwork): diff --git a/tests/network/transaction/test_attributes.py b/tests/network/transaction/test_attributes.py index d0832de5d..64775fe94 100755 --- a/tests/network/transaction/test_attributes.py +++ b/tests/network/transaction/test_attributes.py @@ -106,7 +106,7 @@ def test_hash(tester): def test_timestamp(accounts, web3): tx = accounts[0].transfer(accounts[1], "1 ether") - assert tx.timestamp == web3.eth.getBlock(web3.eth.blockNumber)["timestamp"] + assert tx.timestamp == web3.eth.get_block(web3.eth.block_number)["timestamp"] def test_timestamp_pending(accounts, web3): diff --git a/tests/network/transaction/test_required_confirmations.py b/tests/network/transaction/test_required_confirmations.py index 217c6d546..e29852bbb 100644 --- a/tests/network/transaction/test_required_confirmations.py +++ b/tests/network/transaction/test_required_confirmations.py @@ -26,34 +26,34 @@ def block_time_network(devnetwork, config): def test_required_confirmations_deploy(accounts, BrownieTester, block_time_network, web3): - block = web3.eth.blockNumber + block = web3.eth.block_number accounts[0].deploy(BrownieTester, True, required_confs=3) - assert web3.eth.blockNumber - block >= 3 + assert web3.eth.block_number - block >= 3 def test_required_confirmations_transfer(accounts, block_time_network, web3): - block = web3.eth.blockNumber + block = web3.eth.block_number tx = accounts[0].transfer(accounts[1], "1 ether", required_confs=3) assert tx.confirmations >= 3 - assert web3.eth.blockNumber - block >= 3 + assert web3.eth.block_number - block >= 3 def test_required_confirmations_transact(accounts, BrownieTester, block_time_network, web3): - block = web3.eth.blockNumber + block = web3.eth.block_number brownieTester = BrownieTester.deploy(True, {"from": accounts[0], "required_confs": 2}) - assert web3.eth.blockNumber - block >= 2 + assert web3.eth.block_number - block >= 2 - block = web3.eth.blockNumber + block = web3.eth.block_number tx = brownieTester.doNothing({"from": accounts[0], "required_confs": 4}) assert tx.confirmations >= 4 - assert web3.eth.blockNumber - block >= 4 + assert web3.eth.block_number - block >= 4 def test_required_confirmations_zero(accounts, block_time_network, web3): - block = web3.eth.blockNumber + block = web3.eth.block_number tx = accounts[0].transfer(accounts[1], "1 ether", required_confs=0) assert tx.status == -1 - assert web3.eth.blockNumber - block == 0 + assert web3.eth.block_number - block == 0 time.sleep(1.5) assert tx.status == 1 assert tx.confirmations >= 1 diff --git a/tests/project/test_brownie_config.py b/tests/project/test_brownie_config.py index 993919ef7..4bee0ddf1 100644 --- a/tests/project/test_brownie_config.py +++ b/tests/project/test_brownie_config.py @@ -99,7 +99,7 @@ def test_rpc_project_cmd_settings(devnetwork, testproject, config, project_setti # Test if chain ID and network ID can be properly queried assert web3.isConnected() - assert web3.eth.chainId == 666 + assert web3.eth.chain_id == 666 assert web3.net.version == "777" devnetwork.rpc.kill() diff --git a/tests/test/plugin/test_conftest.py b/tests/test/plugin/test_conftest.py index a5fbee5b2..29df4346c 100644 --- a/tests/test/plugin/test_conftest.py +++ b/tests/test/plugin/test_conftest.py @@ -17,9 +17,9 @@ def brownie_tester(request): def test_call_and_transact(brownie_tester, accounts, web3, fn_isolation): c = accounts[0].deploy(brownie_tester, True) c.setNum(12, {'from': accounts[0]}) - assert web3.eth.blockNumber == 2 + assert web3.eth.block_number == 2 c.getTuple(accounts[0]) - assert web3.eth.blockNumber == 2""" + assert web3.eth.block_number == 2""" ) result = plugintester.runpytest("-n 2") diff --git a/tests/test/plugin/test_coverage.py b/tests/test/plugin/test_coverage.py index e6f919a49..1fb9b7b0a 100644 --- a/tests/test/plugin/test_coverage.py +++ b/tests/test/plugin/test_coverage.py @@ -9,17 +9,17 @@ def test_call_and_transact(BrownieTester, accounts, web3, fn_isolation): c = accounts[0].deploy(BrownieTester, True) c.setNum(12, {'from': accounts[0]}) - assert web3.eth.blockNumber == 2 + assert web3.eth.block_number == 2 c.getTuple(accounts[0]) - assert web3.eth.blockNumber == 2 + assert web3.eth.block_number == 2 def test_call_and_transact_without_decorator(BrownieTester, accounts, web3, fn_isolation): c = accounts[0].deploy(BrownieTester, True) c.setNum(12, {'from': accounts[0]}) - assert web3.eth.blockNumber == 2 + assert web3.eth.block_number == 2 c.getTuple(accounts[0]) - assert web3.eth.blockNumber == 2 + assert web3.eth.block_number == 2 """ diff --git a/tests/test/plugin/test_given.py b/tests/test/plugin/test_given.py index ed9d451fa..2aa6e5967 100644 --- a/tests/test/plugin/test_given.py +++ b/tests/test/plugin/test_given.py @@ -12,7 +12,7 @@ def tester(BrownieTester, accounts): @given(value=strategy('uint256', min_value=5, exclude=31337)) def test_given(tester, web3, value): tester.revertStrings(value) - assert web3.eth.blockNumber == 2 + assert web3.eth.block_number == 2 @given(value=strategy('bool')) def test_given_fails(web3): diff --git a/tests/test/plugin/test_isolation_fixtures.py b/tests/test/plugin/test_isolation_fixtures.py index f2fd1a444..7d85d7cd1 100644 --- a/tests/test/plugin/test_isolation_fixtures.py +++ b/tests/test/plugin/test_isolation_fixtures.py @@ -13,12 +13,12 @@ def setup(accounts): accounts[0].transfer(accounts[1], "1 ether") def test_isolation_first(accounts, web3): - assert web3.eth.blockNumber == 1 + assert web3.eth.block_number == 1 assert accounts[1].balance() == "101 ether" accounts[0].transfer(accounts[1], "1 ether") def test_isolation_second(accounts, web3): - assert web3.eth.blockNumber == {1} + assert web3.eth.block_number == {1} assert accounts[1].balance() == "10{1} ether"''' @@ -27,7 +27,7 @@ def test_fn_isolation(plugintester, web3, arg): plugintester.makepyfile(isolation_source.format("fn", 1)) result = plugintester.runpytest_inprocess(arg) result.assert_outcomes(passed=2) - assert web3.eth.blockNumber == 0 + assert web3.eth.block_number == 0 @pytest.mark.parametrize("arg", ["", "-n 2"]) @@ -35,7 +35,7 @@ def test_module_isolation(plugintester, web3, arg): plugintester.makepyfile(isolation_source.format("module", 2)) result = plugintester.runpytest_inprocess(arg) result.assert_outcomes(passed=2) - assert web3.eth.blockNumber == 0 + assert web3.eth.block_number == 0 def test_xdist_no_isolation(plugintester): diff --git a/tests/test/stateful/test_setup.py b/tests/test/stateful/test_setup.py index 9e010456d..c25ad80df 100644 --- a/tests/test/stateful/test_setup.py +++ b/tests/test/stateful/test_setup.py @@ -65,7 +65,7 @@ def __init__(self, foo, bar=42, baz=31337): def test_rpc_reverts_between_runs(SMTestBase, accounts, web3): class StateMachine(SMTestBase): def initialize_one(self): - assert web3.eth.blockNumber == 1 + assert web3.eth.block_number == 1 accounts[0].transfer(accounts[1], 100) accounts[0].transfer(accounts[1], 100)