From f93336a054a62fceb16748ad4177af0d4dee1590 Mon Sep 17 00:00:00 2001 From: kclowes Date: Thu, 10 Feb 2022 10:42:52 -0700 Subject: [PATCH 01/57] Add 'Breaking Changes' and 'Deprecation' to our valid newsfragment types (#2340) * Add 'Breaking Change' and 'Deprecation' to our valid newsfragment types * Add newsfragment for new newsfragment categories * Remove removal section of release notes --- newsfragments/2340.feature.rst | 1 + newsfragments/validate_files.py | 3 ++- pyproject.toml | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 newsfragments/2340.feature.rst diff --git a/newsfragments/2340.feature.rst b/newsfragments/2340.feature.rst new file mode 100644 index 0000000000..208a28c40d --- /dev/null +++ b/newsfragments/2340.feature.rst @@ -0,0 +1 @@ +Added 'Breaking Changes' and 'Deprecations' categories to our release notes diff --git a/newsfragments/validate_files.py b/newsfragments/validate_files.py index ba3bae96b2..391483249c 100755 --- a/newsfragments/validate_files.py +++ b/newsfragments/validate_files.py @@ -11,7 +11,8 @@ '.doc.rst', '.feature.rst', '.misc.rst', - '.removal.rst', + '.breaking-change.rst', + '.deprecation.rst', } ALLOWED_FILES = { diff --git a/pyproject.toml b/pyproject.toml index 97533d0116..804cc73713 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,3 +5,13 @@ underlines = ["-", "~", "^"] issue_format = "`#{issue} `__" title_format = "v{version} ({project_date})" + +[[tool.towncrier.type]] +directory = "breaking-change" +name="Breaking Changes" +showcontent=true + +[[tool.towncrier.type]] +directory = "deprecation" +name = "Deprecations" +showcontent = true From 1284329406d8ae34766de65561229598129a1d19 Mon Sep 17 00:00:00 2001 From: kclowes Date: Fri, 11 Feb 2022 11:38:03 -0700 Subject: [PATCH 02/57] Drop python 3.6 (#2343) * Drop python 3.6 * Remove parity tests * Add newsfragment for py36 drop --- .circleci/config.yml | 231 +------------------------ newsfragments/2343.breaking-change.rst | 2 + setup.py | 3 +- tox.ini | 19 +- 4 files changed, 11 insertions(+), 244 deletions(-) create mode 100644 newsfragments/2343.breaking-change.rst diff --git a/.circleci/config.yml b/.circleci/config.yml index 1f730c3539..c76ed67ab7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -57,44 +57,6 @@ docs_steps: &docs_steps - ~/.py-geth key: cache-docs-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} -# parity_steps: &parity_steps - # working_directory: ~/repo - # steps: - # - checkout - # - restore_cache: - # keys: - # - cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} - # - run: - # name: install dependencies - # command: pip install --user tox - # - run: - # name: install parity if needed - # command: | - # pip install --user requests eth_utils tqdm eth-hash[pycryptodome] - # echo "Job specifies Parity version $PARITY_VERSION" - # python tests/integration/parity/install_parity.py $PARITY_VERSION - # - run: - # name: update parity deps from testing repo if needed - # command: | - # [ "`cat /etc/*release | grep jessie`" != "" ] && echo "On Jessie - installing missing deps..." || echo "Not on Jessie - doing nothing." - # [ "`cat /etc/*release | grep jessie`" != "" ] || exit 0 - # echo "deb http://ftp.debian.org/debian testing main" > testing.list && sudo mv testing.list /etc/apt/sources.list.d/ - # sudo apt update - # sudo apt-get -t testing install libstdc++6 - # - run: - # name: run tox - # command: ~/.local/bin/tox -r - # - save_cache: - # paths: - # - .tox - # - ~/.cache/pip - # - ~/.local - # - ./eggs - # - ~/.ethash - # - ~/.py-geth - # - ~/.parity-bin - # key: cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} - geth_steps: &geth_steps working_directory: ~/repo steps: @@ -247,105 +209,17 @@ jobs: lint: <<: *common docker: - - image: circleci/python:3.6 + - image: circleci/python:3.9 environment: TOXENV: lint docs: <<: *docs_steps docker: - - image: circleci/python:3.6 + - image: circleci/python:3.9 environment: TOXENV: docs - py36-core: - <<: *common - docker: - - image: circleci/python:3.6 - environment: - TOXENV: py36-core - - py36-ens: - <<: *common - docker: - - image: circleci/python:3.6 - environment: - TOXENV: py36-ens - - py36-ethpm: - <<: *ethpm_steps - docker: - - image: circleci/python:3.6 - environment: - TOXENV: py36-ethpm - # Please don't use this key for any shenanigans - WEB3_INFURA_PROJECT_ID: 7707850c2fb7465ebe6f150d67182e22 - - py36-integration-goethereum-ipc: - <<: *geth_steps - docker: - - image: circleci/python:3.6 - environment: - TOXENV: py36-integration-goethereum-ipc - GETH_VERSION: v1.10.13 - - py36-integration-goethereum-http: - <<: *geth_steps - docker: - - image: circleci/python:3.6 - environment: - TOXENV: py36-integration-goethereum-http - GETH_VERSION: v1.10.13 - - py36-integration-goethereum-ws: - <<: *geth_steps - docker: - - image: circleci/python:3.6 - environment: - TOXENV: py36-integration-goethereum-ws - GETH_VERSION: v1.10.13 - - # py36-integration-parity-ipc: - # <<: *parity_steps - # docker: - # - image: circleci/python:3.6-stretch - # environment: - # TOXENV: py36-integration-parity-ipc - # PARITY_VERSION: v2.3.5 - # PARITY_OS: linux - - # py36-integration-parity-http: - # <<: *parity_steps - # docker: - # - image: circleci/python:3.6-stretch - # environment: - # TOXENV: py36-integration-parity-http - # PARITY_VERSION: v2.3.5 - # PARITY_OS: linux - - # py36-integration-parity-ws: - # <<: *parity_steps - # docker: - # - image: circleci/python:3.6-stretch - # environment: - # TOXENV: py36-integration-parity-ws - # PARITY_VERSION: v2.3.5 - # PARITY_OS: linux - - py36-integration-ethtester-pyevm: - <<: *common - docker: - - image: circleci/python:3.6 - 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 # # Python 3.7 @@ -397,33 +271,6 @@ jobs: TOXENV: py37-integration-goethereum-ws GETH_VERSION: v1.10.13 - # py37-integration-parity-ipc: - # <<: *parity_steps - # docker: - # - image: circleci/python:3.7-stretch - # environment: - # TOXENV: py37-integration-parity-ipc - # PARITY_VERSION: v2.3.5 - # PARITY_OS: linux - - # py37-integration-parity-http: - # <<: *parity_steps - # docker: - # - image: circleci/python:3.7-stretch - # environment: - # TOXENV: py37-integration-parity-http - # PARITY_VERSION: v2.3.5 - # PARITY_OS: linux - - # py37-integration-parity-ws: - # <<: *parity_steps - # docker: - # - image: circleci/python:3.7-stretch - # environment: - # TOXENV: py37-integration-parity-ws - # PARITY_VERSION: v2.3.5 - # PARITY_OS: linux - py37-integration-ethtester-pyevm: <<: *common docker: @@ -494,33 +341,6 @@ jobs: TOXENV: py38-integration-goethereum-ws GETH_VERSION: v1.10.13 - # py38-integration-parity-ipc: - # <<: *parity_steps - # docker: - # - image: circleci/python:3.8 - # environment: - # TOXENV: py38-integration-parity-ipc - # PARITY_VERSION: v2.3.5 - # PARITY_OS: linux - - # py38-integration-parity-http: - # <<: *parity_steps - # docker: - # - image: circleci/python:3.8 - # environment: - # TOXENV: py38-integration-parity-http - # PARITY_VERSION: v2.3.5 - # PARITY_OS: linux - - # py38-integration-parity-ws: - # <<: *parity_steps - # docker: - # - image: circleci/python:3.8 - # environment: - # TOXENV: py38-integration-parity-ws - # PARITY_VERSION: v2.3.5 - # PARITY_OS: linux - py38-integration-ethtester-pyevm: <<: *common docker: @@ -586,33 +406,6 @@ jobs: TOXENV: py39-integration-goethereum-ws GETH_VERSION: v1.10.13 - # py39-integration-parity-ipc: - # <<: *parity_steps - # docker: - # - image: circleci/python:3.9 - # environment: - # TOXENV: py39-integration-parity-ipc - # PARITY_VERSION: v2.3.5 - # PARITY_OS: linux - - # py39-integration-parity-http: - # <<: *parity_steps - # docker: - # - image: circleci/python:3.9 - # environment: - # TOXENV: py39-integration-parity-http - # PARITY_VERSION: v2.3.5 - # PARITY_OS: linux - - # py39-integration-parity-ws: - # <<: *parity_steps - # docker: - # - image: circleci/python:3.9 - # environment: - # TOXENV: py39-integration-parity-ws - # PARITY_VERSION: v2.3.5 - # PARITY_OS: linux - py39-integration-ethtester-pyevm: <<: *common docker: @@ -641,31 +434,17 @@ workflows: test: jobs: # These are the longest running tests, start them first - - py36-core - py37-core - py38-core - py39-core - lint - docs - benchmark - - py36-ens - - py36-ethpm - - py36-integration-goethereum-ipc - - py36-integration-goethereum-http - - py36-integration-goethereum-ws - # - py36-integration-parity-ipc - # - py36-integration-parity-http - # - py36-integration-parity-ws - - py36-integration-ethtester-pyevm - - py36-wheel-cli - py37-ens - py37-ethpm - 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 @@ -674,9 +453,6 @@ workflows: - py38-integration-goethereum-ipc - py38-integration-goethereum-http - py38-integration-goethereum-ws - # - py38-integration-parity-ipc - # - py38-integration-parity-http - # - py38-integration-parity-ws - py38-integration-ethtester-pyevm - py38-wheel-cli - py39-ens @@ -684,8 +460,5 @@ workflows: - py39-integration-goethereum-ipc - py39-integration-goethereum-http - py39-integration-goethereum-ws - # - py39-integration-parity-ipc - # - py39-integration-parity-http - # - py39-integration-parity-ws - py39-integration-ethtester-pyevm - py39-wheel-cli diff --git a/newsfragments/2343.breaking-change.rst b/newsfragments/2343.breaking-change.rst new file mode 100644 index 0000000000..4a4c5fcb12 --- /dev/null +++ b/newsfragments/2343.breaking-change.rst @@ -0,0 +1,2 @@ +Remove support for the unsupported Python 3.6 +Also removes outdated Parity tests diff --git a/setup.py b/setup.py index 72b10700bb..2df5580452 100644 --- a/setup.py +++ b/setup.py @@ -92,7 +92,7 @@ "typing-extensions>=3.7.4.1,<5;python_version<'3.8'", "websockets>=9.1,<10", ], - python_requires='>=3.6,<4', + python_requires='>=3.7,<3.10', extras_require=extras_require, py_modules=['web3', 'ens', 'ethpm'], entry_points={"pytest11": ["pytest_ethereum = web3.tools.pytest_ethereum.plugins"]}, @@ -107,7 +107,6 @@ 'License :: OSI Approved :: MIT License', 'Natural Language :: English', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', diff --git a/tox.ini b/tox.ini index 75b1637e78..f91ecfe023 100644 --- a/tox.ini +++ b/tox.ini @@ -1,13 +1,13 @@ [tox] envlist= - py{36,37,38,39}-ens - py{36,37,38,39}-ethpm - py{36,37,38,39}-core - py{36,37,38,39}-integration-{goethereum,ethtester} + py{37,38,39}-ens + py{37,38,39}-ethpm + py{37,38,39}-core + py{37,38,39}-integration-{goethereum,ethtester} lint docs benchmark - py{36,37,38,39}-wheel-cli + py{37,38,39}-wheel-cli [isort] combine_as_imports=True @@ -48,8 +48,7 @@ passenv = WEB3_INFURA_PROJECT_ID WEB3_INFURA_API_SECRET basepython = - docs: python3.6 - py36: python3.6 + docs: python3.9 py37: python3.7 py38: python3.8 py39: python3.9 @@ -80,12 +79,6 @@ commands= /bin/bash -c 'pip install --upgrade "$(ls dist/web3-*-py3-none-any.whl)" --progress-bar off' python -c "from web3.auto import w3" -[testenv:py36-wheel-cli] -deps={[common-wheel-cli]deps} -whitelist_externals={[common-wheel-cli]whitelist_externals} -commands={[common-wheel-cli]commands} -skip_install=true - [testenv:py37-wheel-cli] deps={[common-wheel-cli]deps} whitelist_externals={[common-wheel-cli]whitelist_externals} From e2ffabf2e3f1928d0a17b2798cf7362f254cf0d9 Mon Sep 17 00:00:00 2001 From: coccoinomane Date: Fri, 11 Feb 2022 20:02:51 +0100 Subject: [PATCH 03/57] Fix gas types (#2330) * fix: correct type for effectiveGasPrice (Wei, not int) * fix: correct type for gas and gas_limit (int, not Wei) * lint: removed unused type imports of Wei * Add newsfragment for Wei/int typing fixes Co-authored-by: kclowes --- docs/middleware.rst | 2 +- newsfragments/2330.bugfix.rst | 2 + web3/_utils/async_transactions.py | 9 +- web3/_utils/module_testing/eth_module.py | 94 +++++++++---------- .../go_ethereum_personal_module.py | 4 +- web3/_utils/transactions.py | 9 +- web3/eth.py | 6 +- web3/types.py | 12 +-- 8 files changed, 69 insertions(+), 69 deletions(-) create mode 100644 newsfragments/2330.bugfix.rst diff --git a/docs/middleware.rst b/docs/middleware.rst index 64fabf150e..6448c2e745 100644 --- a/docs/middleware.rst +++ b/docs/middleware.rst @@ -78,7 +78,7 @@ Buffered Gas Estimate This adds a gas estimate to transactions if ``gas`` is not present in the transaction parameters. Sets gas to: ``min(w3.eth.estimate_gas + gas_buffer, gas_limit)`` - where the gas_buffer default is 100,000 Wei + where the gas_buffer default is 100,000 HTTPRequestRetry ~~~~~~~~~~~~~~~~~~ diff --git a/newsfragments/2330.bugfix.rst b/newsfragments/2330.bugfix.rst new file mode 100644 index 0000000000..f4588ea93e --- /dev/null +++ b/newsfragments/2330.bugfix.rst @@ -0,0 +1,2 @@ +- Fix types for ``gas``, and ``gasLimit`` (``Wei`` to ``int``) +- Fix types for ``effectiveGasPrice``, (``int`` to ``Wei``) diff --git a/web3/_utils/async_transactions.py b/web3/_utils/async_transactions.py index 2b3124a18b..be5fa6c391 100644 --- a/web3/_utils/async_transactions.py +++ b/web3/_utils/async_transactions.py @@ -7,7 +7,6 @@ from web3.types import ( BlockIdentifier, TxParams, - Wei, ) if TYPE_CHECKING: @@ -17,7 +16,7 @@ async def get_block_gas_limit( web3_eth: "AsyncEth", block_identifier: Optional[BlockIdentifier] = None -) -> Wei: +) -> int: if block_identifier is None: block_identifier = await web3_eth.block_number block = await web3_eth.get_block(block_identifier) @@ -25,8 +24,8 @@ async def get_block_gas_limit( async def get_buffered_gas_estimate( - web3: "Web3", transaction: TxParams, gas_buffer: Wei = Wei(100000) -) -> Wei: + web3: "Web3", transaction: TxParams, gas_buffer: int = 100000 +) -> int: gas_estimate_transaction = cast(TxParams, dict(**transaction)) gas_estimate = await web3.eth.estimate_gas(gas_estimate_transaction) # type: ignore @@ -40,4 +39,4 @@ async def get_buffered_gas_estimate( "limit: {1}".format(gas_estimate, gas_limit) ) - return Wei(min(gas_limit, gas_estimate + gas_buffer)) + return min(gas_limit, gas_estimate + gas_buffer) diff --git a/web3/_utils/module_testing/eth_module.py b/web3/_utils/module_testing/eth_module.py index 1b88175b6f..b3f9b788f1 100644 --- a/web3/_utils/module_testing/eth_module.py +++ b/web3/_utils/module_testing/eth_module.py @@ -128,7 +128,7 @@ async def test_eth_send_transaction_legacy( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'gasPrice': await async_w3.eth.gas_price, # type: ignore } txn_hash = await async_w3.eth.send_transaction(txn_params) # type: ignore @@ -148,7 +148,7 @@ async def test_eth_send_transaction( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': async_w3.toWei(3, 'gwei'), 'maxPriorityFeePerGas': async_w3.toWei(1, 'gwei'), } @@ -171,7 +171,7 @@ async def test_eth_send_transaction_default_fees( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, } txn_hash = await async_w3.eth.send_transaction(txn_params) # type: ignore txn = await async_w3.eth.get_transaction(txn_hash) # type: ignore @@ -192,7 +192,7 @@ async def test_eth_send_transaction_hex_fees( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': hex(250 * 10**9), 'maxPriorityFeePerGas': hex(2 * 10**9), } @@ -233,7 +233,7 @@ async def test_eth_send_transaction_with_gas_price( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'gasPrice': Wei(1), 'maxFeePerGas': Wei(250 * 10**9), 'maxPriorityFeePerGas': Wei(2 * 10**9), @@ -249,7 +249,7 @@ async def test_eth_send_transaction_no_priority_fee( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': Wei(250 * 10**9), } with pytest.raises(InvalidTransaction, match='maxPriorityFeePerGas must be defined'): @@ -264,7 +264,7 @@ async def test_eth_send_transaction_no_max_fee( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxPriorityFeePerGas': maxPriorityFeePerGas, } txn_hash = await async_w3.eth.send_transaction(txn_params) # type: ignore @@ -286,7 +286,7 @@ async def test_eth_send_transaction_max_fee_less_than_tip( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': Wei(1 * 10**9), 'maxPriorityFeePerGas': Wei(2 * 10**9), } @@ -356,7 +356,7 @@ async def test_gas_price_strategy_middleware( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, } two_gwei_in_wei = async_w3.toWei(2, 'gwei') @@ -385,7 +385,7 @@ async def test_gas_price_from_strategy_bypassed_for_dynamic_fee_txn( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxPriorityFeePerGas': max_priority_fee, } if max_fee is not None: @@ -414,7 +414,7 @@ async def test_gas_price_from_strategy_bypassed_for_dynamic_fee_txn_no_tip( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': Wei(1000000000), } @@ -824,7 +824,7 @@ async def test_async_eth_get_transaction_receipt_unmined( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': async_w3.toWei(3, 'gwei'), 'maxPriorityFeePerGas': async_w3.toWei(1, 'gwei') }) @@ -885,7 +885,7 @@ async def test_async_eth_wait_for_transaction_receipt_unmined( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': async_w3.toWei(3, 'gwei'), 'maxPriorityFeePerGas': async_w3.toWei(1, 'gwei') }) @@ -1704,7 +1704,7 @@ def test_eth_sign_transaction_legacy( 'from': unlocked_account, 'to': unlocked_account, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'gasPrice': web3.eth.gas_price, 'nonce': Nonce(0), } @@ -1726,7 +1726,7 @@ def test_eth_sign_transaction( 'from': unlocked_account, 'to': unlocked_account, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': web3.toWei(2, 'gwei'), 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), 'nonce': Nonce(0), @@ -1750,7 +1750,7 @@ def test_eth_sign_transaction_hex_fees( 'from': unlocked_account, 'to': unlocked_account, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': hex(web3.toWei(2, 'gwei')), 'maxPriorityFeePerGas': hex(web3.toWei(1, 'gwei')), 'nonce': Nonce(0), @@ -1774,7 +1774,7 @@ def test_eth_signTransaction_deprecated(self, 'from': unlocked_account, 'to': unlocked_account, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'gasPrice': web3.eth.gas_price, 'nonce': Nonce(0), } @@ -1797,7 +1797,7 @@ def test_eth_sign_transaction_ens_names( 'from': 'unlocked-account.eth', 'to': 'unlocked-account.eth', 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': web3.toWei(2, 'gwei'), 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), 'nonce': Nonce(0), @@ -1820,7 +1820,7 @@ def test_eth_send_transaction_addr_checksum_required( 'from': unlocked_account, 'to': unlocked_account, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': web3.toWei(2, 'gwei'), 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), } @@ -1840,7 +1840,7 @@ def test_eth_send_transaction_legacy( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'gasPrice': web3.toWei(1, 'gwei'), # post-london needs to be more than the base fee } txn_hash = web3.eth.send_transaction(txn_params) @@ -1859,7 +1859,7 @@ def test_eth_send_transaction( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': web3.toWei(3, 'gwei'), 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), } @@ -1881,7 +1881,7 @@ def test_eth_sendTransaction_deprecated( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': web3.toWei(3, 'gwei'), 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), } @@ -1907,7 +1907,7 @@ def test_eth_send_transaction_with_nonce( 'from': unlocked_account, 'to': unlocked_account, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, # unique maxFeePerGas to ensure transaction hash different from other tests 'maxFeePerGas': web3.toWei(4.321, 'gwei'), 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), @@ -1932,7 +1932,7 @@ def test_eth_send_transaction_default_fees( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, } txn_hash = web3.eth.send_transaction(txn_params) txn = web3.eth.get_transaction(txn_hash) @@ -1952,7 +1952,7 @@ def test_eth_send_transaction_hex_fees( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': hex(250 * 10**9), 'maxPriorityFeePerGas': hex(2 * 10**9), } @@ -1991,7 +1991,7 @@ def test_eth_send_transaction_with_gas_price( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'gasPrice': Wei(1), 'maxFeePerGas': Wei(250 * 10**9), 'maxPriorityFeePerGas': Wei(2 * 10**9), @@ -2006,7 +2006,7 @@ def test_eth_send_transaction_no_priority_fee( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': Wei(250 * 10**9), } with pytest.raises(InvalidTransaction, match='maxPriorityFeePerGas must be defined'): @@ -2020,7 +2020,7 @@ def test_eth_send_transaction_no_max_fee( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxPriorityFeePerGas': maxPriorityFeePerGas, } txn_hash = web3.eth.send_transaction(txn_params) @@ -2041,7 +2041,7 @@ def test_eth_send_transaction_max_fee_less_than_tip( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': Wei(1 * 10**9), 'maxPriorityFeePerGas': Wei(2 * 10**9), } @@ -2086,7 +2086,7 @@ def test_gas_price_from_strategy_bypassed_for_dynamic_fee_txn( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxPriorityFeePerGas': max_priority_fee, } if max_fee is not None: @@ -2114,7 +2114,7 @@ def test_gas_price_from_strategy_bypassed_for_dynamic_fee_txn_no_tip( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': Wei(1000000000), } @@ -2134,7 +2134,7 @@ def test_eth_replace_transaction_legacy( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'gasPrice': web3.toWei(1, 'gwei'), # must be greater than base_fee post London } txn_hash = web3.eth.send_transaction(txn_params) @@ -2159,7 +2159,7 @@ def test_eth_replace_transaction( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': two_gwei_in_wei, 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), } @@ -2185,7 +2185,7 @@ def test_eth_replace_transaction_underpriced( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': web3.toWei(3, 'gwei'), 'maxPriorityFeePerGas': web3.toWei(2, 'gwei'), } @@ -2208,7 +2208,7 @@ def test_eth_replaceTransaction_deprecated( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': two_gwei_in_wei, 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), } @@ -2237,7 +2237,7 @@ def test_eth_replace_transaction_non_existing_transaction( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': web3.toWei(3, 'gwei'), 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), } @@ -2254,7 +2254,7 @@ def test_eth_replace_transaction_already_mined( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': web3.toWei(2, 'gwei'), 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), } @@ -2277,7 +2277,7 @@ def test_eth_replace_transaction_incorrect_nonce( 'from': unlocked_account, 'to': unlocked_account, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': web3.toWei(2, 'gwei'), 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), } @@ -2297,7 +2297,7 @@ def test_eth_replace_transaction_gas_price_too_low( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'gasPrice': web3.toWei(2, 'gwei'), } txn_hash = web3.eth.send_transaction(txn_params) @@ -2315,7 +2315,7 @@ def test_eth_replace_transaction_gas_price_defaulting_minimum( 'from': unlocked_account, 'to': unlocked_account, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'gasPrice': gas_price, } txn_hash = web3.eth.send_transaction(txn_params) @@ -2333,7 +2333,7 @@ def test_eth_replace_transaction_gas_price_defaulting_strategy_higher( 'from': unlocked_account, 'to': unlocked_account, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'gasPrice': web3.toWei(1, 'gwei'), } txn_hash = web3.eth.send_transaction(txn_params) @@ -2360,7 +2360,7 @@ def test_eth_replace_transaction_gas_price_defaulting_strategy_lower( 'from': unlocked_account, 'to': unlocked_account, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'gasPrice': gas_price, } txn_hash = web3.eth.send_transaction(txn_params) @@ -2384,7 +2384,7 @@ def test_eth_modify_transaction_legacy( 'from': unlocked_account, 'to': unlocked_account, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'gasPrice': web3.toWei(1, 'gwei'), # must be greater than base_fee post London } txn_hash = web3.eth.send_transaction(txn_params) @@ -2407,7 +2407,7 @@ def test_eth_modify_transaction( 'from': unlocked_account, 'to': unlocked_account, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), 'maxFeePerGas': web3.toWei(2, 'gwei'), } @@ -2436,7 +2436,7 @@ def test_eth_modifyTransaction_deprecated( 'from': unlocked_account, 'to': unlocked_account, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'gasPrice': web3.toWei(1, 'gwei'), } txn_hash = web3.eth.send_transaction(txn_params) @@ -2795,7 +2795,7 @@ def test_eth_get_transaction_receipt_unmined( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': web3.toWei(3, 'gwei'), 'maxPriorityFeePerGas': web3.toWei(1, 'gwei') }) @@ -2853,7 +2853,7 @@ def test_eth_wait_for_transaction_receipt_unmined( 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), - 'gas': Wei(21000), + 'gas': 21000, 'maxFeePerGas': web3.toWei(3, 'gwei'), 'maxPriorityFeePerGas': web3.toWei(1, 'gwei') }) diff --git a/web3/_utils/module_testing/go_ethereum_personal_module.py b/web3/_utils/module_testing/go_ethereum_personal_module.py index e39a1b177c..1e7fb35f06 100644 --- a/web3/_utils/module_testing/go_ethereum_personal_module.py +++ b/web3/_utils/module_testing/go_ethereum_personal_module.py @@ -154,7 +154,7 @@ def test_personal_send_transaction( txn_params: TxParams = { 'from': unlockable_account_dual_type, 'to': unlockable_account_dual_type, - 'gas': Wei(21000), + 'gas': 21000, 'value': Wei(1), 'gasPrice': web3.toWei(1, 'gwei'), } @@ -178,7 +178,7 @@ def test_personal_sendTransaction_deprecated( txn_params: TxParams = { 'from': unlockable_account_dual_type, 'to': unlockable_account_dual_type, - 'gas': Wei(21000), + 'gas': 21000, 'value': Wei(1), 'gasPrice': web3.toWei(1, 'gwei'), } diff --git a/web3/_utils/transactions.py b/web3/_utils/transactions.py index 27a285182c..13d43ffea7 100644 --- a/web3/_utils/transactions.py +++ b/web3/_utils/transactions.py @@ -32,7 +32,6 @@ BlockIdentifier, TxData, TxParams, - Wei, _Hash32, ) @@ -119,7 +118,7 @@ def fill_transaction_defaults(web3: "Web3", transaction: TxParams) -> TxParams: return merge(defaults, transaction) -def get_block_gas_limit(web3: "Web3", block_identifier: Optional[BlockIdentifier] = None) -> Wei: +def get_block_gas_limit(web3: "Web3", block_identifier: Optional[BlockIdentifier] = None) -> int: if block_identifier is None: block_identifier = web3.eth.block_number block = web3.eth.get_block(block_identifier) @@ -127,8 +126,8 @@ def get_block_gas_limit(web3: "Web3", block_identifier: Optional[BlockIdentifier def get_buffered_gas_estimate( - web3: "Web3", transaction: TxParams, gas_buffer: Wei = Wei(100000) -) -> Wei: + web3: "Web3", transaction: TxParams, gas_buffer: int = 100000 +) -> int: gas_estimate_transaction = cast(TxParams, dict(**transaction)) gas_estimate = web3.eth.estimate_gas(gas_estimate_transaction) @@ -142,7 +141,7 @@ def get_buffered_gas_estimate( "limit: {1}".format(gas_estimate, gas_limit) ) - return Wei(min(gas_limit, gas_estimate + gas_buffer)) + return min(gas_limit, gas_estimate + gas_buffer) def get_required_transaction(web3: "Web3", transaction_hash: _Hash32) -> TxData: diff --git a/web3/eth.py b/web3/eth.py index 1e644609e6..48eb0c86c3 100644 --- a/web3/eth.py +++ b/web3/eth.py @@ -231,7 +231,7 @@ def estimate_gas_munger( return params - _estimate_gas: Method[Callable[..., Wei]] = Method( + _estimate_gas: Method[Callable[..., int]] = Method( RPC.eth_estimateGas, mungers=[estimate_gas_munger] ) @@ -426,7 +426,7 @@ async def estimate_gas( self, transaction: TxParams, block_identifier: Optional[BlockIdentifier] = None - ) -> Wei: + ) -> int: # types ignored b/c mypy conflict with BlockingEth properties return await self._estimate_gas(transaction, block_identifier) # type: ignore @@ -851,7 +851,7 @@ def estimate_gas( self, transaction: TxParams, block_identifier: Optional[BlockIdentifier] = None - ) -> Wei: + ) -> int: return self._estimate_gas(transaction, block_identifier) def fee_history( diff --git a/web3/types.py b/web3/types.py index fa9ddac284..ffdda4fe58 100644 --- a/web3/types.py +++ b/web3/types.py @@ -183,7 +183,7 @@ class LogReceipt(TypedDict): "chainId": int, "data": Union[bytes, HexStr], "from": ChecksumAddress, - "gas": Wei, + "gas": int, "gasPrice": Wei, "maxFeePerGas": Wei, "maxPriorityFeePerGas": Wei, @@ -206,7 +206,7 @@ class LogReceipt(TypedDict): "data": Union[bytes, HexStr], # addr or ens "from": Union[Address, ChecksumAddress, str], - "gas": Wei, + "gas": int, # legacy pricing "gasPrice": Wei, # dynamic fee pricing @@ -237,8 +237,8 @@ class CallOverrideParams(TypedDict): "blockNumber": BlockNumber, "contractAddress": Optional[ChecksumAddress], "cumulativeGasUsed": int, - "effectiveGasPrice": int, - "gasUsed": Wei, + "effectiveGasPrice": Wei, + "gasUsed": int, "from": ChecksumAddress, "logs": List[LogReceipt], "logsBloom": HexBytes, @@ -308,8 +308,8 @@ class BlockData(TypedDict, total=False): baseFeePerGas: Wei difficulty: int extraData: HexBytes - gasLimit: Wei - gasUsed: Wei + gasLimit: int + gasUsed: int hash: HexBytes logsBloom: HexBytes miner: ChecksumAddress From 26c6d8fdcadcf65e6e8ba0984f4b41c89febed34 Mon Sep 17 00:00:00 2001 From: kclowes Date: Fri, 11 Feb 2022 13:29:13 -0700 Subject: [PATCH 04/57] Upgrade websockets dependency to v10+ (#2324) * Require websockets v10+ - Remove event loop parameter * Add newsfragment for websockets upgrade --- newsfragments/2324.breaking-change.rst | 1 + setup.py | 2 +- tests/core/providers/test_websocket_provider.py | 6 ++++-- tests/integration/go_ethereum/test_goethereum_ws.py | 6 ++++-- tests/utils.py | 4 ++-- web3/providers/websocket.py | 7 +++---- 6 files changed, 15 insertions(+), 11 deletions(-) create mode 100644 newsfragments/2324.breaking-change.rst diff --git a/newsfragments/2324.breaking-change.rst b/newsfragments/2324.breaking-change.rst new file mode 100644 index 0000000000..9bcbb72602 --- /dev/null +++ b/newsfragments/2324.breaking-change.rst @@ -0,0 +1 @@ +Update ``websockets`` dependency to v10+ diff --git a/setup.py b/setup.py index 2df5580452..dc1c816c54 100644 --- a/setup.py +++ b/setup.py @@ -90,7 +90,7 @@ "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,<5;python_version<'3.8'", - "websockets>=9.1,<10", + "websockets>=10.0.0,<11", ], python_requires='>=3.7,<3.10', extras_require=extras_require, diff --git a/tests/core/providers/test_websocket_provider.py b/tests/core/providers/test_websocket_provider.py index 1036b38fe1..562225fa1a 100644 --- a/tests/core/providers/test_websocket_provider.py +++ b/tests/core/providers/test_websocket_provider.py @@ -37,7 +37,9 @@ async def empty_server(websocket, path): data = await websocket.recv() await asyncio.sleep(0.02) await websocket.send(data) - server = websockets.serve(empty_server, '127.0.0.1', open_port, loop=event_loop) + + asyncio.set_event_loop(event_loop) + server = websockets.serve(empty_server, '127.0.0.1', open_port) event_loop.run_until_complete(server) event_loop.run_forever() @@ -54,7 +56,7 @@ def w3(open_port, start_websocket_server): # need new event loop as the one used by server is already running event_loop = asyncio.new_event_loop() endpoint_uri = 'ws://127.0.0.1:{}'.format(open_port) - event_loop.run_until_complete(wait_for_ws(endpoint_uri, event_loop)) + event_loop.run_until_complete(wait_for_ws(endpoint_uri)) provider = WebsocketProvider(endpoint_uri, websocket_timeout=0.01) return Web3(provider) diff --git a/tests/integration/go_ethereum/test_goethereum_ws.py b/tests/integration/go_ethereum/test_goethereum_ws.py index 7de95ba63c..9014f4fc1d 100644 --- a/tests/integration/go_ethereum/test_goethereum_ws.py +++ b/tests/integration/go_ethereum/test_goethereum_ws.py @@ -1,3 +1,4 @@ +import asyncio import pytest from tests.integration.common import ( @@ -63,8 +64,9 @@ def geth_command_arguments(geth_binary, @pytest.fixture(scope="module") -def web3(geth_process, endpoint_uri, event_loop): - event_loop.run_until_complete(wait_for_ws(endpoint_uri, event_loop)) +def web3(geth_process, endpoint_uri): + event_loop = asyncio.new_event_loop() + event_loop.run_until_complete(wait_for_ws(endpoint_uri)) _web3 = Web3(Web3.WebsocketProvider(endpoint_uri, websocket_timeout=30)) return _web3 diff --git a/tests/utils.py b/tests/utils.py index 05f2899621..268d33d6be 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -13,11 +13,11 @@ def get_open_port(): return str(port) -async def wait_for_ws(endpoint_uri, event_loop, timeout=60): +async def wait_for_ws(endpoint_uri, timeout=10): start = time.time() while time.time() < start + timeout: try: - async with websockets.connect(uri=endpoint_uri, loop=event_loop): + async with websockets.connect(uri=endpoint_uri): pass except (ConnectionRefusedError, OSError): await asyncio.sleep(0.01) diff --git a/web3/providers/websocket.py b/web3/providers/websocket.py index 3e4f7e036c..e999d56d3f 100644 --- a/web3/providers/websocket.py +++ b/web3/providers/websocket.py @@ -60,17 +60,16 @@ def get_default_endpoint() -> URI: class PersistentWebSocket: def __init__( - self, endpoint_uri: URI, loop: asyncio.AbstractEventLoop, websocket_kwargs: Any + self, endpoint_uri: URI, websocket_kwargs: Any ) -> None: self.ws: WebSocketClientProtocol = None self.endpoint_uri = endpoint_uri - self.loop = loop self.websocket_kwargs = websocket_kwargs async def __aenter__(self) -> WebSocketClientProtocol: if self.ws is None: self.ws = await connect( - uri=self.endpoint_uri, loop=self.loop, **self.websocket_kwargs + uri=self.endpoint_uri, **self.websocket_kwargs ) return self.ws @@ -113,7 +112,7 @@ def __init__( 'found: {1}'.format(RESTRICTED_WEBSOCKET_KWARGS, found_restricted_keys) ) self.conn = PersistentWebSocket( - self.endpoint_uri, WebsocketProvider._loop, websocket_kwargs + self.endpoint_uri, websocket_kwargs ) super().__init__() From 16aff7e80a6bc089051c154b5079213317c27da8 Mon Sep 17 00:00:00 2001 From: Mahmoud Harmouch Date: Mon, 14 Feb 2022 20:05:02 +0200 Subject: [PATCH 05/57] :heavy_plus_sign: Add Python 3.10 support (#2175) * :heavy_plus_sign: Add Python 3.10 support to CI * Dropped support for all parities * Change docker image to use 3.10 * Update pytest-asyncio plugin * Mark async fixture as such, clean up pytest DeprecationWarnings Signed-off-by: Harmouch101 Co-authored-by: Felipe Selmo Co-authored-by: kclowes --- .circleci/config.yml | 75 ++++++++++++++++++- newsfragments/2175.feature.rst | 1 + pytest.ini | 1 + setup.py | 9 ++- .../core/providers/test_websocket_provider.py | 4 +- tests/integration/conftest.py | 2 +- tests/integration/go_ethereum/conftest.py | 2 +- .../go_ethereum/test_goethereum_http.py | 4 +- tox.ini | 17 +++-- web3/_utils/module_testing/web3_module.py | 2 +- 10 files changed, 101 insertions(+), 16 deletions(-) create mode 100644 newsfragments/2175.feature.rst diff --git a/.circleci/config.yml b/.circleci/config.yml index c76ed67ab7..08c9b05884 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -421,10 +421,75 @@ jobs: environment: TOXENV: py39-wheel-cli + # + # Python 3.10 + # + py310-core: + <<: *common + docker: + - image: circleci/python:3.10 + environment: + TOXENV: py310-core + + py310-ens: + <<: *common + docker: + - image: circleci/python:3.10 + environment: + TOXENV: py310-ens + + py310-ethpm: + <<: *ethpm_steps + docker: + - image: circleci/python:3.10 + environment: + TOXENV: py310-ethpm + # Please don't use this key for any shenanigans + WEB3_INFURA_PROJECT_ID: 7707850c2fb7465ebe6f150d67182e22 + + py310-integration-goethereum-ipc: + <<: *geth_steps + docker: + - image: circleci/python:3.10 + environment: + TOXENV: py310-integration-goethereum-ipc + GETH_VERSION: v1.10.11 + + py310-integration-goethereum-http: + <<: *geth_steps + docker: + - image: circleci/python:3.10 + environment: + TOXENV: py310-integration-goethereum-http + GETH_VERSION: v1.10.11 + + py310-integration-goethereum-ws: + <<: *geth_steps + docker: + - image: circleci/python:3.10 + environment: + TOXENV: py310-integration-goethereum-ws + GETH_VERSION: v1.10.11 + + py310-integration-ethtester-pyevm: + <<: *common + docker: + - image: circleci/python:3.10 + environment: + TOXENV: py310-integration-ethtester + ETHEREUM_TESTER_CHAIN_BACKEND: eth_tester.backends.PyEVMBackend + + py310-wheel-cli: + <<: *common + docker: + - image: circleci/python:3.10 + environment: + TOXENV: py310-wheel-cli + benchmark: <<: *geth_steps docker: - - image: circleci/python:3.9 + - image: circleci/python:3.10 environment: TOXENV: benchmark GETH_VERSION: v1.10.13 @@ -437,6 +502,7 @@ workflows: - py37-core - py38-core - py39-core + - py310-core - lint - docs - benchmark @@ -462,3 +528,10 @@ workflows: - py39-integration-goethereum-ws - py39-integration-ethtester-pyevm - py39-wheel-cli + - py310-ens + - py310-ethpm + - py310-integration-goethereum-ipc + - py310-integration-goethereum-http + - py310-integration-goethereum-ws + - py310-integration-ethtester-pyevm + - py310-wheel-cli diff --git a/newsfragments/2175.feature.rst b/newsfragments/2175.feature.rst new file mode 100644 index 0000000000..dd5d94db98 --- /dev/null +++ b/newsfragments/2175.feature.rst @@ -0,0 +1 @@ +Add support for Python 3.10 diff --git a/pytest.ini b/pytest.ini index f5fdc0ec93..f4b46a1453 100644 --- a/pytest.ini +++ b/pytest.ini @@ -2,6 +2,7 @@ addopts= -v --showlocals --durations 10 python_paths= . xfail_strict=true +asyncio_mode=strict [pytest-watch] runner= pytest --failed-first --maxfail=1 --no-success-flaky-report diff --git a/setup.py b/setup.py index dc1c816c54..e4b28448d5 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ "contextlib2>=0.5.4", "py-geth>=3.6.0,<4", "py-solc>=0.4.0", - "pytest>=4.4.0,<5.0.0", + "pytest>=6.2.5,<7", "sphinx>=3.0,<4", "sphinx_rtd_theme>=0.1.9", "toposort>=1.4", @@ -38,8 +38,8 @@ "bumpversion", "flaky>=3.7.0,<4", "hypothesis>=3.31.2,<6", - "pytest>=4.4.0,<5.0.0", - "pytest-asyncio>=0.10.0,<0.11", + "pytest>=6.2.5,<7", + "pytest-asyncio>=0.18.1,<0.19", "pytest-mock>=1.10,<2", "pytest-pythonpath>=0.3", "pytest-watch>=4.2,<5", @@ -92,7 +92,7 @@ "typing-extensions>=3.7.4.1,<5;python_version<'3.8'", "websockets>=10.0.0,<11", ], - python_requires='>=3.7,<3.10', + python_requires='>=3.7,<3.11', extras_require=extras_require, py_modules=['web3', 'ens', 'ethpm'], entry_points={"pytest11": ["pytest_ethereum = web3.tools.pytest_ethereum.plugins"]}, @@ -110,5 +110,6 @@ 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', ], ) diff --git a/tests/core/providers/test_websocket_provider.py b/tests/core/providers/test_websocket_provider.py index 562225fa1a..0cf475d31e 100644 --- a/tests/core/providers/test_websocket_provider.py +++ b/tests/core/providers/test_websocket_provider.py @@ -28,7 +28,7 @@ ) -@pytest.yield_fixture +@pytest.fixture def start_websocket_server(open_port): event_loop = asyncio.new_event_loop() @@ -51,7 +51,7 @@ async def empty_server(websocket, path): event_loop.call_soon_threadsafe(event_loop.stop) -@pytest.fixture() +@pytest.fixture def w3(open_port, start_websocket_server): # need new event loop as the one used by server is already running event_loop = asyncio.new_event_loop() diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index a9ddbbd19e..dd254c6876 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -37,7 +37,7 @@ def revert_contract_factory(web3): return contract_factory -@pytest.yield_fixture(scope="module") +@pytest.fixture(scope="module") def event_loop(request): loop = asyncio.get_event_loop_policy().new_event_loop() yield loop diff --git a/tests/integration/go_ethereum/conftest.py b/tests/integration/go_ethereum/conftest.py index 7851b2e4a5..59934890c7 100644 --- a/tests/integration/go_ethereum/conftest.py +++ b/tests/integration/go_ethereum/conftest.py @@ -181,7 +181,7 @@ def unlockable_account_dual_type(unlockable_account, address_conversion_func): return address_conversion_func(unlockable_account) -@pytest.yield_fixture +@pytest.fixture def unlocked_account_dual_type(web3, unlockable_account_dual_type, unlockable_account_pw): web3.geth.personal.unlock_account(unlockable_account_dual_type, unlockable_account_pw) yield unlockable_account_dual_type diff --git a/tests/integration/go_ethereum/test_goethereum_http.py b/tests/integration/go_ethereum/test_goethereum_http.py index a94dc8b7f7..a3ea078cac 100644 --- a/tests/integration/go_ethereum/test_goethereum_http.py +++ b/tests/integration/go_ethereum/test_goethereum_http.py @@ -1,5 +1,7 @@ import pytest +import pytest_asyncio + from tests.utils import ( get_open_port, ) @@ -94,7 +96,7 @@ def web3(geth_process, endpoint_uri): return _web3 -@pytest.fixture(scope="module") +@pytest_asyncio.fixture(scope="module") async def async_w3(geth_process, endpoint_uri): await wait_for_aiohttp(endpoint_uri) _web3 = Web3( diff --git a/tox.ini b/tox.ini index f91ecfe023..ada9f14247 100644 --- a/tox.ini +++ b/tox.ini @@ -1,13 +1,13 @@ [tox] envlist= - py{37,38,39}-ens - py{37,38,39}-ethpm - py{37,38,39}-core - py{37,38,39}-integration-{goethereum,ethtester} + py{37,38,39,310}-ens + py{37,38,39,310}-ethpm + py{37,38,39,310}-core + py{37,38,39,310}-integration-{goethereum,ethtester} lint docs benchmark - py{37,38,39}-wheel-cli + py{37,38,39,310}-wheel-cli [isort] combine_as_imports=True @@ -52,6 +52,7 @@ basepython = py37: python3.7 py38: python3.8 py39: python3.9 + py310: python3.10 [testenv:lint] basepython=python @@ -97,6 +98,12 @@ whitelist_externals={[common-wheel-cli]whitelist_externals} commands={[common-wheel-cli]commands} skip_install=true +[testenv:py310-wheel-cli] +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= diff --git a/web3/_utils/module_testing/web3_module.py b/web3/_utils/module_testing/web3_module.py index a8eb73f332..17e25e1ff7 100644 --- a/web3/_utils/module_testing/web3_module.py +++ b/web3/_utils/module_testing/web3_module.py @@ -179,7 +179,7 @@ def test_solidityKeccak( self, web3: "Web3", types: Sequence[TypeStr], values: Sequence[Any], expected: HexBytes ) -> None: if isinstance(expected, type) and issubclass(expected, Exception): - with pytest.raises(expected): + with pytest.raises(expected): # type: ignore web3.solidityKeccak(types, values) return From e36bffa2140edfdd35ef430ab387b0c4b749ba4b Mon Sep 17 00:00:00 2001 From: Mahmoud Harmouch Date: Wed, 23 Feb 2022 19:36:03 +0200 Subject: [PATCH 06/57] Remove unnecessary utf-8 encoding declarations (#2353) * :broom: clean unnecessary utf-8 encoding declaration * :memo: add newsfragment.rst Signed-off-by: Harmouch101 --- docs/conf.py | 1 - newsfragments/2353.misc.rst | 1 + setup.py | 1 - tests/core/contracts/test_contract_buildTransaction.py | 2 -- tests/core/contracts/test_contract_transact_interface.py | 2 -- web3/_utils/module_testing/eth_module.py | 2 -- 6 files changed, 1 insertion(+), 8 deletions(-) create mode 100644 newsfragments/2353.misc.rst diff --git a/docs/conf.py b/docs/conf.py index ca8d8a4945..fd50c0c203 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Web3.py documentation build configuration file, created by # sphinx-quickstart on Thu Oct 16 20:43:24 2014. diff --git a/newsfragments/2353.misc.rst b/newsfragments/2353.misc.rst new file mode 100644 index 0000000000..6716a9bd3d --- /dev/null +++ b/newsfragments/2353.misc.rst @@ -0,0 +1 @@ +Clean up unnecessary UTF-8 encoding declarations. \ No newline at end of file diff --git a/setup.py b/setup.py index e4b28448d5..87476f8cd5 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- from setuptools import ( find_packages, setup, diff --git a/tests/core/contracts/test_contract_buildTransaction.py b/tests/core/contracts/test_contract_buildTransaction.py index 85a8ffe324..4713061e99 100644 --- a/tests/core/contracts/test_contract_buildTransaction.py +++ b/tests/core/contracts/test_contract_buildTransaction.py @@ -8,8 +8,6 @@ ValidationError, ) -# -*- coding: utf-8 -*- - @pytest.fixture() def math_contract(web3, MathContract, address_conversion_func): diff --git a/tests/core/contracts/test_contract_transact_interface.py b/tests/core/contracts/test_contract_transact_interface.py index f34037d285..0e506be5f7 100644 --- a/tests/core/contracts/test_contract_transact_interface.py +++ b/tests/core/contracts/test_contract_transact_interface.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import pytest from eth_utils import ( diff --git a/web3/_utils/module_testing/eth_module.py b/web3/_utils/module_testing/eth_module.py index b3f9b788f1..4d71b8669c 100644 --- a/web3/_utils/module_testing/eth_module.py +++ b/web3/_utils/module_testing/eth_module.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import json import math import pytest From 363e65aabd1507a4975b8d90ec715aa66376874b Mon Sep 17 00:00:00 2001 From: pmadhikar Date: Wed, 23 Feb 2022 23:30:03 +0100 Subject: [PATCH 07/57] asyncify get_storage_at (#2350) --- docs/providers.rst | 1 + newsfragments/2350.feature.rst | 1 + web3/_utils/module_testing/eth_module.py | 24 ++++++++++++++++ web3/eth.py | 35 ++++++++++++++++-------- 4 files changed, 50 insertions(+), 11 deletions(-) create mode 100644 newsfragments/2350.feature.rst diff --git a/docs/providers.rst b/docs/providers.rst index 6b13f88aa3..90d6439857 100644 --- a/docs/providers.rst +++ b/docs/providers.rst @@ -429,6 +429,7 @@ Eth - :meth:`web3.eth.get_transaction() ` - :meth:`web3.eth.get_transaction_count() ` - :meth:`web3.eth.get_transaction_receipt() ` +- :meth:`web3.eth.get_storage_at() ` - :meth:`web3.eth.send_transaction() ` - :meth:`web3.eth.send_raw_transaction() ` - :meth:`web3.eth.wait_for_transaction_receipt() ` diff --git a/newsfragments/2350.feature.rst b/newsfragments/2350.feature.rst new file mode 100644 index 0000000000..979d048c0d --- /dev/null +++ b/newsfragments/2350.feature.rst @@ -0,0 +1 @@ ++ Add async `eth.get_storage_at` method diff --git a/web3/_utils/module_testing/eth_module.py b/web3/_utils/module_testing/eth_module.py index 4d71b8669c..30a504a293 100644 --- a/web3/_utils/module_testing/eth_module.py +++ b/web3/_utils/module_testing/eth_module.py @@ -1094,6 +1094,30 @@ async def test_async_eth_syncing(self, async_w3: "Web3") -> None: assert is_integer(sync_dict['currentBlock']) assert is_integer(sync_dict['highestBlock']) + @pytest.mark.asyncio + async def test_async_eth_get_storage_at( + self, async_w3: "Web3", emitter_contract_address: ChecksumAddress + ) -> None: + storage = await async_w3.eth.get_storage_at(emitter_contract_address, 0) # type: ignore + assert isinstance(storage, HexBytes) + + @pytest.mark.asyncio + @pytest.mark.xfail + async def test_async_eth_get_storage_at_ens_name( + self, async_w3: "Web3", emitter_contract_address: ChecksumAddress + ) -> None: + with ens_addresses(async_w3, {'emitter.eth': emitter_contract_address}): + storage = await async_w3.eth.get_storage_at('emitter.eth', 0) # type: ignore + assert isinstance(storage, HexBytes) + + @pytest.mark.asyncio + async def test_async_eth_get_storage_at_invalid_address(self, async_w3: "Web3") -> None: + coinbase = await async_w3.eth.coinbase # type: ignore + with pytest.raises(InvalidAddress): + await async_w3.eth.get_storage_at( + ChecksumAddress(HexAddress(HexStr(coinbase.lower()))), + 0) # type: ignore + def test_async_provider_default_account( self, async_w3: "Web3", diff --git a/web3/eth.py b/web3/eth.py index 48eb0c86c3..95473c0bc2 100644 --- a/web3/eth.py +++ b/web3/eth.py @@ -283,6 +283,16 @@ def block_id_munger( block_identifier = self.default_block return (account, block_identifier) + def get_storage_at_munger( + self, + account: Union[Address, ChecksumAddress, ENS], + position: int, + block_identifier: Optional[BlockIdentifier] = None + ) -> Tuple[Union[Address, ChecksumAddress, ENS], int, BlockIdentifier]: + if block_identifier is None: + block_identifier = self.default_block + return (account, position, block_identifier) + def call_munger( self, transaction: TxParams, @@ -519,6 +529,19 @@ async def _wait_for_tx_receipt_with_timeout( f"after {timeout} seconds" ) + _get_storage_at: Method[Callable[..., Awaitable[HexBytes]]] = Method( + RPC.eth_getStorageAt, + mungers=[BaseEth.get_storage_at_munger], + ) + + async def get_storage_at( + self, + account: Union[Address, ChecksumAddress, ENS], + position: int, + block_identifier: Optional[BlockIdentifier] = None + ) -> HexBytes: + return await self._get_storage_at(account, position, block_identifier) + async def call( self, transaction: TxParams, @@ -636,19 +659,9 @@ def max_priority_fee(self) -> Wei: ) return fee_history_priority_fee(self) - def get_storage_at_munger( - self, - account: Union[Address, ChecksumAddress, ENS], - position: int, - block_identifier: Optional[BlockIdentifier] = None - ) -> Tuple[Union[Address, ChecksumAddress, ENS], int, BlockIdentifier]: - if block_identifier is None: - block_identifier = self.default_block - return (account, position, block_identifier) - get_storage_at: Method[Callable[..., HexBytes]] = Method( RPC.eth_getStorageAt, - mungers=[get_storage_at_munger], + mungers=[BaseEth.get_storage_at_munger], ) def get_proof_munger( From ed305e381b9cc0646ae45d33786a707c10a57c03 Mon Sep 17 00:00:00 2001 From: Felipe Selmo Date: Thu, 24 Feb 2022 11:34:25 -0700 Subject: [PATCH 08/57] Upgrade `jsonschema` to version range `>=4<5` --- newsfragments/2361.feature.rst | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 newsfragments/2361.feature.rst diff --git a/newsfragments/2361.feature.rst b/newsfragments/2361.feature.rst new file mode 100644 index 0000000000..248c63e542 --- /dev/null +++ b/newsfragments/2361.feature.rst @@ -0,0 +1 @@ +Upgrade ``jsonschema`` version to ``>=4.0.0<5`` \ No newline at end of file diff --git a/setup.py b/setup.py index 87476f8cd5..16148d7b06 100644 --- a/setup.py +++ b/setup.py @@ -82,7 +82,7 @@ "eth-utils>=1.9.5,<2.0.0", "hexbytes>=0.1.0,<1.0.0", "ipfshttpclient==0.8.0a2", - "jsonschema>=3.2.0,<4.0.0", + "jsonschema>=4.0.0,<5", "lru-dict>=1.1.6,<2.0.0", "protobuf>=3.10.0,<4", "pywin32>=223;platform_system=='Windows'", From 313d919efa43fee6cbb3f5b28c30e6be50e93660 Mon Sep 17 00:00:00 2001 From: kclowes Date: Thu, 24 Feb 2022 13:21:55 -0700 Subject: [PATCH 09/57] Update Sphinx (#2362) --- newsfragments/2362.breaking-change.rst | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 newsfragments/2362.breaking-change.rst diff --git a/newsfragments/2362.breaking-change.rst b/newsfragments/2362.breaking-change.rst new file mode 100644 index 0000000000..8862d80c29 --- /dev/null +++ b/newsfragments/2362.breaking-change.rst @@ -0,0 +1 @@ +Update Sphinx requirement to ``>=4.2.0,<5`` diff --git a/setup.py b/setup.py index 16148d7b06..5f1cd1f1c3 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ "py-geth>=3.6.0,<4", "py-solc>=0.4.0", "pytest>=6.2.5,<7", - "sphinx>=3.0,<4", + "sphinx>=4.2.0,<5", "sphinx_rtd_theme>=0.1.9", "toposort>=1.4", "towncrier==18.5.0", From eed1ae4134c727384bbcd7f307c06e49392d9cae Mon Sep 17 00:00:00 2001 From: AlwaysData Date: Thu, 24 Feb 2022 18:10:40 -0500 Subject: [PATCH 10/57] Added caching to the async session in request.py and AsyncHTTPProvider (#2254) * Added caching to the async session in request.py and AsyncHTTPProvider --- docs/providers.rst | 7 +- newsfragments/2016.feature.rst | 1 + .../providers/test_async_http_provider.py | 22 ++++++ tests/core/utilities/test_request.py | 52 ++++++++++++++ web3/_utils/request.py | 67 +++++++++++++++++-- web3/providers/async_rpc.py | 7 ++ 6 files changed, 149 insertions(+), 7 deletions(-) create mode 100644 newsfragments/2016.feature.rst create mode 100644 tests/core/providers/test_async_http_provider.py diff --git a/docs/providers.rst b/docs/providers.rst index 90d6439857..cb1395ecd7 100644 --- a/docs/providers.rst +++ b/docs/providers.rst @@ -379,9 +379,11 @@ AsyncHTTPProvider be omitted from the URI. * ``request_kwargs`` should be a dictionary of keyword arguments which will be passed onto each http/https POST request made to your node. + * the ``cache_async_session()`` method allows you to use your own ``aiohttp.ClientSession`` object. This is an async method and not part of the constructor .. code-block:: python + >>> from aiohttp import ClientSession >>> from web3 import Web3, AsyncHTTPProvider >>> from web3.eth import AsyncEth >>> from web3.net import AsyncNet @@ -396,7 +398,10 @@ AsyncHTTPProvider ... 'personal': (AsyncGethPersonal,), ... 'admin' : (AsyncGethAdmin,)}) ... }, - ... middlewares=[]) # See supported middleware section below for middleware options + ... middlewares=[] # See supported middleware section below for middleware options + ... ) + >>> custom_session = ClientSession() # If you want to pass in your own session + >>> await w3.provider.cache_async_session(custom_session) # This method is an async method so it needs to be handled accordingly Under the hood, the ``AsyncHTTPProvider`` uses the python `aiohttp `_ library for making requests. diff --git a/newsfragments/2016.feature.rst b/newsfragments/2016.feature.rst new file mode 100644 index 0000000000..fb34134740 --- /dev/null +++ b/newsfragments/2016.feature.rst @@ -0,0 +1 @@ +Added session caching to the AsyncHTTPProvider \ No newline at end of file diff --git a/tests/core/providers/test_async_http_provider.py b/tests/core/providers/test_async_http_provider.py new file mode 100644 index 0000000000..bceea41e54 --- /dev/null +++ b/tests/core/providers/test_async_http_provider.py @@ -0,0 +1,22 @@ + +import pytest + +from aiohttp import ( + ClientSession, +) + +from web3._utils import ( + request, +) +from web3.providers.async_rpc import ( + AsyncHTTPProvider, +) + + +@pytest.mark.asyncio +async def test_user_provided_session() -> None: + + session = ClientSession() + provider = AsyncHTTPProvider(endpoint_uri="http://mynode.local:8545") + await provider.cache_async_session(session) + assert len(request._async_session_cache) == 1 diff --git a/tests/core/utilities/test_request.py b/tests/core/utilities/test_request.py index 6947da4eb9..32d4cf9baa 100644 --- a/tests/core/utilities/test_request.py +++ b/tests/core/utilities/test_request.py @@ -1,3 +1,8 @@ +import pytest + +from aiohttp import ( + ClientSession, +) from requests import ( Session, adapters, @@ -10,6 +15,9 @@ from web3._utils import ( request, ) +from web3._utils.request import ( + SessionCache, +) class MockedResponse: @@ -80,3 +88,47 @@ def test_precached_session(mocker): assert isinstance(adapter, HTTPAdapter) assert adapter._pool_connections == 100 assert adapter._pool_maxsize == 100 + + +@pytest.mark.asyncio +async def test_async_precached_session(mocker): + # Add a session + session = ClientSession() + await request.cache_async_session(URI, session) + assert len(request._async_session_cache) == 1 + + # Make sure the session isn't duplicated + await request.cache_async_session(URI, session) + assert len(request._async_session_cache) == 1 + + # Make sure a request with a different URI adds another cached session + await request.cache_async_session(f"{URI}/test", session) + assert len(request._async_session_cache) == 2 + + +def test_cache_session_class(): + + cache = SessionCache(2) + evicted_items = cache.cache("1", "Hello1") + assert cache.get_cache_entry("1") == "Hello1" + assert evicted_items is None + + evicted_items = cache.cache("2", "Hello2") + assert cache.get_cache_entry("2") == "Hello2" + assert evicted_items is None + + # Changing what is stored at a given cache key should not cause the + # anything to be evicted + evicted_items = cache.cache("1", "HelloChanged") + assert cache.get_cache_entry("1") == "HelloChanged" + assert evicted_items is None + + evicted_items = cache.cache("3", "Hello3") + assert "2" in cache + assert "3" in cache + assert "1" not in cache + + with pytest.raises(KeyError): + # This should throw a KeyError since the cache size was 2 and 3 were inserted + # the first inserted cached item was removed and returned in evicted items + cache.get_cache_entry("1") diff --git a/web3/_utils/request.py b/web3/_utils/request.py index 0ddfc81354..fadafe5ed9 100644 --- a/web3/_utils/request.py +++ b/web3/_utils/request.py @@ -1,6 +1,11 @@ +from collections import ( + OrderedDict, +) import os +import threading from typing import ( Any, + Dict, ) from aiohttp import ( @@ -18,6 +23,37 @@ ) +class SessionCache: + + def __init__(self, size: int): + self._size = size + self._data: OrderedDict[str, Any] = OrderedDict() + + def cache(self, key: str, value: Any) -> Dict[str, Any]: + evicted_items = None + # If the key is already in the OrderedDict just update it + # and don't evict any values. Ideally, we could still check to see + # if there are too many items in the OrderedDict but that may rearrange + # the order it should be unlikely that the size could grow over the limit + if key not in self._data: + while len(self._data) >= self._size: + if evicted_items is None: + evicted_items = {} + k, v = self._data.popitem(last=False) + evicted_items[k] = v + self._data[key] = value + return evicted_items + + def get_cache_entry(self, key: str) -> Any: + return self._data[key] + + def __contains__(self, item: str) -> bool: + return item in self._data + + def __len__(self) -> int: + return len(self._data) + + def get_default_http_endpoint() -> URI: return URI(os.environ.get('WEB3_HTTP_PROVIDER_URI', 'http://localhost:8545')) @@ -27,11 +63,22 @@ def cache_session(endpoint_uri: URI, session: requests.Session) -> None: _session_cache[cache_key] = session +async def cache_async_session(endpoint_uri: URI, session: ClientSession) -> None: + cache_key = generate_cache_key(endpoint_uri) + with _async_session_cache_lock: + evicted_items = _async_session_cache.cache(cache_key, session) + if evicted_items is not None: + for key, session in evicted_items.items(): + await session.close() + + def _remove_session(key: str, session: requests.Session) -> None: session.close() _session_cache = lru.LRU(8, callback=_remove_session) +_async_session_cache_lock = threading.Lock() +_async_session_cache = SessionCache(size=8) def _get_session(endpoint_uri: URI) -> requests.Session: @@ -41,6 +88,13 @@ def _get_session(endpoint_uri: URI) -> requests.Session: return _session_cache[cache_key] +async def _get_async_session(endpoint_uri: URI) -> ClientSession: + cache_key = generate_cache_key(endpoint_uri) + if cache_key not in _async_session_cache: + await cache_async_session(endpoint_uri, ClientSession(raise_for_status=True)) + return _async_session_cache.get_cache_entry(cache_key) + + def make_post_request(endpoint_uri: URI, data: bytes, *args: Any, **kwargs: Any) -> bytes: kwargs.setdefault('timeout', 10) session = _get_session(endpoint_uri) @@ -55,9 +109,10 @@ async def async_make_post_request( endpoint_uri: URI, data: bytes, *args: Any, **kwargs: Any ) -> bytes: kwargs.setdefault('timeout', ClientTimeout(10)) - async with ClientSession(raise_for_status=True) as session: - async with session.post(endpoint_uri, - data=data, - *args, - **kwargs) as response: - return await response.read() + # https://github.com/ethereum/go-ethereum/issues/17069 + session = await _get_async_session(endpoint_uri) + async with session.post(endpoint_uri, + data=data, + *args, + **kwargs) as response: + return await response.read() diff --git a/web3/providers/async_rpc.py b/web3/providers/async_rpc.py index 82f945a4d9..d3229c71de 100644 --- a/web3/providers/async_rpc.py +++ b/web3/providers/async_rpc.py @@ -8,6 +8,9 @@ Union, ) +from aiohttp import ( + ClientSession, +) from eth_typing import ( URI, ) @@ -20,6 +23,7 @@ ) from web3._utils.request import ( async_make_post_request, + cache_async_session as _cache_async_session, get_default_http_endpoint, ) from web3.types import ( @@ -50,6 +54,9 @@ def __init__( super().__init__() + async def cache_async_session(self, session: ClientSession) -> None: + await _cache_async_session(self.endpoint_uri, session) + def __str__(self) -> str: return "RPC connection {0}".format(self.endpoint_uri) From c3bfd894bff1f6f1aca5bc96ecb99dab100436f3 Mon Sep 17 00:00:00 2001 From: kclowes Date: Fri, 25 Feb 2022 14:55:08 -0700 Subject: [PATCH 11/57] Add all types of towncrier documents to pyproject.toml (#2365) * Add all types of towncrier documents to pyproject.toml * Fix formatting for old newsfragments * Don't show Misc content for consistency --- newsfragments/2330.bugfix.rst | 3 +-- newsfragments/2350.feature.rst | 2 +- newsfragments/2365.misc.rst | 1 + pyproject.toml | 20 ++++++++++++++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 newsfragments/2365.misc.rst diff --git a/newsfragments/2330.bugfix.rst b/newsfragments/2330.bugfix.rst index f4588ea93e..e427705d2e 100644 --- a/newsfragments/2330.bugfix.rst +++ b/newsfragments/2330.bugfix.rst @@ -1,2 +1 @@ -- Fix types for ``gas``, and ``gasLimit`` (``Wei`` to ``int``) -- Fix types for ``effectiveGasPrice``, (``int`` to ``Wei``) +Fix types for ``gas``, and ``gasLimit``: ``Wei -> int``. Also fix types for ``effectiveGasPrice``: (``int -> Wei``) diff --git a/newsfragments/2350.feature.rst b/newsfragments/2350.feature.rst index 979d048c0d..e78320e699 100644 --- a/newsfragments/2350.feature.rst +++ b/newsfragments/2350.feature.rst @@ -1 +1 @@ -+ Add async `eth.get_storage_at` method +Add async `eth.get_storage_at` method diff --git a/newsfragments/2365.misc.rst b/newsfragments/2365.misc.rst new file mode 100644 index 0000000000..454861040a --- /dev/null +++ b/newsfragments/2365.misc.rst @@ -0,0 +1 @@ +Towncrier stopped printing original types of newsfragments when the ``breaking-change`` and ``deprecation`` were added. Added them back. diff --git a/pyproject.toml b/pyproject.toml index 804cc73713..2f5e3368a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,3 +15,23 @@ showcontent=true directory = "deprecation" name = "Deprecations" showcontent = true + +[[tool.towncrier.type]] +directory = "bugfix" +name="Bugfixes" +showcontent=true + +[[tool.towncrier.type]] +directory = "doc" +name="Documentation Updates" +showcontent=true + +[[tool.towncrier.type]] +directory = "feature" +name="Features" +showcontent=true + +[[tool.towncrier.type]] +directory = "misc" +name="Misc" +showcontent=false From fbf2f6be67738509aa6e7c794f748627773bd4be Mon Sep 17 00:00:00 2001 From: kclowes Date: Mon, 28 Feb 2022 10:58:36 -0700 Subject: [PATCH 12/57] Compile release notes --- docs/releases.rst | 44 ++++++++++++++++++++++++++ newsfragments/2016.feature.rst | 1 - newsfragments/2175.feature.rst | 1 - newsfragments/2324.breaking-change.rst | 1 - newsfragments/2330.bugfix.rst | 1 - newsfragments/2340.feature.rst | 1 - newsfragments/2343.breaking-change.rst | 2 -- newsfragments/2350.feature.rst | 1 - newsfragments/2353.misc.rst | 1 - newsfragments/2361.feature.rst | 1 - newsfragments/2362.breaking-change.rst | 1 - newsfragments/2365.misc.rst | 1 - 12 files changed, 44 insertions(+), 12 deletions(-) delete mode 100644 newsfragments/2016.feature.rst delete mode 100644 newsfragments/2175.feature.rst delete mode 100644 newsfragments/2324.breaking-change.rst delete mode 100644 newsfragments/2330.bugfix.rst delete mode 100644 newsfragments/2340.feature.rst delete mode 100644 newsfragments/2343.breaking-change.rst delete mode 100644 newsfragments/2350.feature.rst delete mode 100644 newsfragments/2353.misc.rst delete mode 100644 newsfragments/2361.feature.rst delete mode 100644 newsfragments/2362.breaking-change.rst delete mode 100644 newsfragments/2365.misc.rst diff --git a/docs/releases.rst b/docs/releases.rst index d65a9a9a7d..56329d346d 100644 --- a/docs/releases.rst +++ b/docs/releases.rst @@ -3,6 +3,50 @@ Release Notes .. towncrier release notes start +v6.0.0-beta.1 (2022-02-28) +-------------------------- + +Breaking Changes +~~~~~~~~~~~~~~~~ + +- Update ``websockets`` dependency to v10+ (`#2324 + `__) +- Remove support for the unsupported Python 3.6 Also removes outdated Parity + tests (`#2343 `__) +- Update Sphinx requirement to ``>=4.2.0,<5`` (`#2362 + `__) + + +Bugfixes +~~~~~~~~ + +- Fix types for ``gas``, and ``gasLimit``: ``Wei -> int``. Also fix types for + ``effectiveGasPrice``: (``int -> Wei``) (`#2330 + `__) + + +Features +~~~~~~~~ + +- Added session caching to the AsyncHTTPProvider (`#2016 + `__) +- Add support for Python 3.10 (`#2175 + `__) +- Added 'Breaking Changes' and 'Deprecations' categories to our release notes + (`#2340 `__) +- Add async `eth.get_storage_at` method (`#2350 + `__) +- Upgrade ``jsonschema`` version to ``>=4.0.0<5`` (`#2361 + `__) + + +Misc +~~~~ + +- `#2353 `__, `#2365 + `__ + + v5.28.0 (2022-02-09) -------------------- diff --git a/newsfragments/2016.feature.rst b/newsfragments/2016.feature.rst deleted file mode 100644 index fb34134740..0000000000 --- a/newsfragments/2016.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Added session caching to the AsyncHTTPProvider \ No newline at end of file diff --git a/newsfragments/2175.feature.rst b/newsfragments/2175.feature.rst deleted file mode 100644 index dd5d94db98..0000000000 --- a/newsfragments/2175.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Add support for Python 3.10 diff --git a/newsfragments/2324.breaking-change.rst b/newsfragments/2324.breaking-change.rst deleted file mode 100644 index 9bcbb72602..0000000000 --- a/newsfragments/2324.breaking-change.rst +++ /dev/null @@ -1 +0,0 @@ -Update ``websockets`` dependency to v10+ diff --git a/newsfragments/2330.bugfix.rst b/newsfragments/2330.bugfix.rst deleted file mode 100644 index e427705d2e..0000000000 --- a/newsfragments/2330.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fix types for ``gas``, and ``gasLimit``: ``Wei -> int``. Also fix types for ``effectiveGasPrice``: (``int -> Wei``) diff --git a/newsfragments/2340.feature.rst b/newsfragments/2340.feature.rst deleted file mode 100644 index 208a28c40d..0000000000 --- a/newsfragments/2340.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Added 'Breaking Changes' and 'Deprecations' categories to our release notes diff --git a/newsfragments/2343.breaking-change.rst b/newsfragments/2343.breaking-change.rst deleted file mode 100644 index 4a4c5fcb12..0000000000 --- a/newsfragments/2343.breaking-change.rst +++ /dev/null @@ -1,2 +0,0 @@ -Remove support for the unsupported Python 3.6 -Also removes outdated Parity tests diff --git a/newsfragments/2350.feature.rst b/newsfragments/2350.feature.rst deleted file mode 100644 index e78320e699..0000000000 --- a/newsfragments/2350.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Add async `eth.get_storage_at` method diff --git a/newsfragments/2353.misc.rst b/newsfragments/2353.misc.rst deleted file mode 100644 index 6716a9bd3d..0000000000 --- a/newsfragments/2353.misc.rst +++ /dev/null @@ -1 +0,0 @@ -Clean up unnecessary UTF-8 encoding declarations. \ No newline at end of file diff --git a/newsfragments/2361.feature.rst b/newsfragments/2361.feature.rst deleted file mode 100644 index 248c63e542..0000000000 --- a/newsfragments/2361.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Upgrade ``jsonschema`` version to ``>=4.0.0<5`` \ No newline at end of file diff --git a/newsfragments/2362.breaking-change.rst b/newsfragments/2362.breaking-change.rst deleted file mode 100644 index 8862d80c29..0000000000 --- a/newsfragments/2362.breaking-change.rst +++ /dev/null @@ -1 +0,0 @@ -Update Sphinx requirement to ``>=4.2.0,<5`` diff --git a/newsfragments/2365.misc.rst b/newsfragments/2365.misc.rst deleted file mode 100644 index 454861040a..0000000000 --- a/newsfragments/2365.misc.rst +++ /dev/null @@ -1 +0,0 @@ -Towncrier stopped printing original types of newsfragments when the ``breaking-change`` and ``deprecation`` were added. Added them back. From 315c9febd5a98c7f3becba310a86eac7fbbd36d9 Mon Sep 17 00:00:00 2001 From: kclowes Date: Mon, 28 Feb 2022 10:59:49 -0700 Subject: [PATCH 13/57] =?UTF-8?q?Bump=20version:=205.28.0=20=E2=86=92=206.?= =?UTF-8?q?0.0-beta.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index fea9a4d2fe..f001726537 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 5.28.0 +current_version = 6.0.0-beta.1 commit = True tag = True parse = (?P\d+)\.(?P\d+)\.(?P\d+)(-(?P[^.]*)\.(?P\d+))? diff --git a/setup.py b/setup.py index 5f1cd1f1c3..bad20731fe 100644 --- a/setup.py +++ b/setup.py @@ -65,7 +65,7 @@ setup( name='web3', # *IMPORTANT*: Don't manually change the version here. Use the 'bumpversion' utility. - version='5.28.0', + version='6.0.0-beta.1', description="""Web3.py""", long_description_content_type='text/markdown', long_description=long_description, From f5601c9420e978f7d8b884fa86a63088a0ed5bd7 Mon Sep 17 00:00:00 2001 From: kclowes Date: Mon, 28 Feb 2022 11:13:37 -0700 Subject: [PATCH 14/57] Update dependencies - v6 (#2342) * Update dependencies * Add newsfragment for dep upgrades --- newsfragments/2342.breaking-change.rst | 6 ++++++ setup.py | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 newsfragments/2342.breaking-change.rst diff --git a/newsfragments/2342.breaking-change.rst b/newsfragments/2342.breaking-change.rst new file mode 100644 index 0000000000..e33b6b533e --- /dev/null +++ b/newsfragments/2342.breaking-change.rst @@ -0,0 +1,6 @@ +Update dependency requirements: +- eth-utils +- eth-abi +- eth-tester +- eth-account +- eth-typing diff --git a/setup.py b/setup.py index bad20731fe..84ff7a5190 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ extras_require = { 'tester': [ - "eth-tester[py-evm]==v0.6.0-beta.6", + "eth-tester[py-evm]==v0.6.0-beta.5", "py-geth>=3.7.0,<4", ], 'linter': [ @@ -75,11 +75,11 @@ include_package_data=True, install_requires=[ "aiohttp>=3.7.4.post0,<4", - "eth-abi>=2.0.0b6,<3.0.0", - "eth-account>=0.5.7,<0.6.0", + "eth-abi>=3.0.0,<4.0.0", + "eth-account>=0.6.0,<0.7.0", "eth-hash[pycryptodome]>=0.2.0,<1.0.0", - "eth-typing>=2.0.0,<3.0.0", - "eth-utils>=1.9.5,<2.0.0", + "eth-typing>=3.0.0,<4.0.0", + "eth-utils>=2.0.0,<3.0.0", "hexbytes>=0.1.0,<1.0.0", "ipfshttpclient==0.8.0a2", "jsonschema>=4.0.0,<5", From 32f537971d5da8a854a38d14de5f4a5a3833ae82 Mon Sep 17 00:00:00 2001 From: kclowes Date: Mon, 28 Feb 2022 12:04:55 -0700 Subject: [PATCH 15/57] Fix test for the web3_api (#2368) --- tests/core/web3-module/test_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core/web3-module/test_api.py b/tests/core/web3-module/test_api.py index 1f404e695e..d5ccdd84cb 100644 --- a/tests/core/web3-module/test_api.py +++ b/tests/core/web3-module/test_api.py @@ -1,2 +1,2 @@ def test_web3_api(web3): - assert web3.api.startswith("5") + assert web3.api.startswith("6") From bdf0d93c9373beab10b3bc22e53b78c6280807ec Mon Sep 17 00:00:00 2001 From: Mahmoud Harmouch Date: Tue, 1 Mar 2022 06:06:59 +0200 Subject: [PATCH 16/57] replace all instances of Web3 with w3 (#2357) * :memo: replace all instances of Web3 with w3 Signed-off-by: Harmouch101 * Remove unnecessary w3 arguments to tests while reviewing PR #2357 Co-authored-by: Felipe Selmo --- conftest.py | 22 +- docs/examples.rst | 24 +- ens/main.py | 18 +- ethpm/_utils/chains.py | 4 +- ethpm/contract.py | 6 +- ethpm/uri.py | 6 +- newsfragments/1183.breaking-change.rst | 1 + tests/core/admin-module/test_admin_addPeer.py | 12 +- .../core/admin-module/test_admin_nodeInfo.py | 12 +- tests/core/admin-module/test_admin_peers.py | 6 +- tests/core/contracts/conftest.py | 108 +- tests/core/contracts/test_concise_contract.py | 28 +- .../test_contract_ambiguous_functions.py | 14 +- .../contracts/test_contract_attributes.py | 12 +- .../test_contract_buildTransaction.py | 38 +- .../contracts/test_contract_call_interface.py | 136 +-- .../test_contract_caller_interface.py | 58 +- .../test_contract_class_construction.py | 14 +- .../contracts/test_contract_constructor.py | 80 +- .../test_contract_constructor_encoding.py | 8 +- .../contracts/test_contract_deployment.py | 24 +- .../contracts/test_contract_estimateGas.py | 56 +- .../test_contract_events_buildFilter.py | 24 +- tests/core/contracts/test_contract_init.py | 18 +- .../test_contract_method_abi_decoding.py | 8 +- .../test_contract_method_abi_encoding.py | 12 +- ...st_contract_method_to_argument_matching.py | 32 +- .../test_contract_transact_interface.py | 116 +-- .../contracts/test_contract_util_functions.py | 6 +- .../contracts/test_extracting_event_data.py | 93 +- .../test_extracting_event_data_old.py | 26 +- .../core/contracts/test_implicit_contract.py | 14 +- tests/core/eth-module/conftest.py | 8 +- tests/core/eth-module/test_accounts.py | 4 +- tests/core/eth-module/test_block_api.py | 26 +- .../eth-module/test_default_account_api.py | 50 +- tests/core/eth-module/test_eth_contract.py | 14 +- tests/core/eth-module/test_eth_mining.py | 12 +- tests/core/eth-module/test_eth_properties.py | 16 +- tests/core/eth-module/test_gas_pricing.py | 38 +- tests/core/eth-module/test_iban.py | 20 +- tests/core/eth-module/test_poa.py | 28 +- tests/core/eth-module/test_transactions.py | 66 +- tests/core/filtering/conftest.py | 18 +- .../core/filtering/test_basic_filter_tests.py | 20 +- ...est_contract_createFilter_topic_merging.py | 6 +- .../filtering/test_contract_data_filters.py | 32 +- tests/core/filtering/test_contract_getLogs.py | 16 +- .../test_contract_on_event_filtering.py | 30 +- .../test_contract_past_event_filtering.py | 12 +- .../filtering/test_contract_topic_filters.py | 36 +- .../test_existing_filter_instance.py | 24 +- .../test_filter_against_latest_blocks.py | 14 +- ...est_filter_against_pending_transactions.py | 44 +- .../test_filter_against_transaction_logs.py | 20 +- .../test_filters_against_many_blocks.py | 56 +- tests/core/filtering/test_utils_functions.py | 12 +- .../test_rpc_gas_pricing_strategies.py | 8 +- tests/core/manager/conftest.py | 2 +- .../test_middleware_can_be_stateful.py | 2 +- .../core/manager/test_response_formatters.py | 24 +- .../middleware/test_gas_price_strategy.py | 20 +- .../middleware/test_http_request_retry.py | 14 +- tests/core/mining-module/conftest.py | 10 +- .../core/mining-module/test_miner_hashrate.py | 6 +- tests/core/mining-module/test_miner_start.py | 24 +- tests/core/mining-module/test_miner_stop.py | 16 +- tests/core/pm-module/test_ens_integration.py | 8 +- tests/core/providers/test_http_provider.py | 12 +- tests/core/providers/test_provider.py | 8 +- .../core/testing-module/test_testing_mine.py | 20 +- .../test_testing_snapshot_and_revert.py | 46 +- .../testing-module/test_testing_timeTravel.py | 8 +- tests/core/txpool-module/conftest.py | 10 +- tests/core/utilities/conftest.py | 2 +- tests/core/utilities/test_abi_is_encodable.py | 8 +- tests/core/utilities/test_attach_modules.py | 2 +- .../test_construct_event_data_set.py | 4 +- .../test_construct_event_filter_params.py | 8 +- .../utilities/test_construct_event_topics.py | 4 +- .../utilities/test_event_filter_builder.py | 12 +- tests/core/utilities/test_event_interface.py | 12 +- tests/core/utilities/test_fee_utils.py | 12 +- .../test_prepare_transaction_replacement.py | 42 +- .../test_valid_transaction_params.py | 12 +- tests/core/web3-module/test_api.py | 4 +- tests/core/web3-module/test_attach_modules.py | 66 +- tests/core/web3-module/test_clientVersion.py | 4 +- tests/core/web3-module/test_providers.py | 6 +- tests/ens/conftest.py | 2 +- tests/ens/test_ens.py | 8 +- tests/ens/test_setup_address.py | 4 +- tests/ens/test_setup_name.py | 10 +- tests/integration/common.py | 2 +- tests/integration/conftest.py | 12 +- tests/integration/generate_fixtures/common.py | 26 +- .../generate_fixtures/go_ethereum.py | 86 +- tests/integration/go_ethereum/common.py | 28 +- tests/integration/go_ethereum/conftest.py | 36 +- .../go_ethereum/test_goethereum_http.py | 34 +- .../go_ethereum/test_goethereum_ipc.py | 14 +- .../go_ethereum/test_goethereum_ws.py | 18 +- tests/integration/test_ethereum_tester.py | 264 ++--- web3/_utils/async_transactions.py | 6 +- web3/_utils/contracts.py | 20 +- web3/_utils/ens.py | 2 +- web3/_utils/module_testing/eth_module.py | 972 +++++++++--------- .../go_ethereum_admin_module.py | 68 +- .../go_ethereum_personal_module.py | 92 +- .../go_ethereum_txpool_module.py | 12 +- web3/_utils/module_testing/net_module.py | 20 +- web3/_utils/module_testing/version_module.py | 8 +- web3/_utils/module_testing/web3_module.py | 24 +- web3/_utils/transactions.py | 52 +- web3/contract.py | 208 ++-- web3/eth.py | 12 +- web3/gas_strategies/rpc.py | 4 +- web3/gas_strategies/time_based.py | 8 +- web3/manager.py | 16 +- web3/method.py | 2 +- web3/middleware/__init__.py | 8 +- web3/middleware/attrdict.py | 2 +- web3/middleware/buffered_gas_estimate.py | 8 +- web3/middleware/cache.py | 14 +- web3/middleware/exception_handling.py | 2 +- web3/middleware/exception_retry_request.py | 6 +- web3/middleware/gas_price_strategy.py | 12 +- web3/middleware/geth_poa.py | 4 +- .../simulate_unmined_transaction.py | 2 +- web3/middleware/stalecheck.py | 4 +- web3/middleware/validation.py | 4 +- web3/module.py | 10 +- web3/parity.py | 4 +- web3/pm.py | 18 +- web3/providers/async_base.py | 8 +- web3/providers/base.py | 8 +- web3/providers/eth_tester/middleware.py | 14 +- web3/testing.py | 10 +- web3/tools/benchmark/main.py | 8 +- 139 files changed, 2150 insertions(+), 2160 deletions(-) create mode 100644 newsfragments/1183.breaking-change.rst diff --git a/conftest.py b/conftest.py index 28aaa762c6..17ccc39dd6 100644 --- a/conftest.py +++ b/conftest.py @@ -47,18 +47,18 @@ def is_testrpc_provider(provider): @pytest.fixture() def skip_if_testrpc(): - def _skip_if_testrpc(web3): - if is_testrpc_provider(web3.provider): + def _skip_if_testrpc(w3): + if is_testrpc_provider(w3.provider): pytest.skip() return _skip_if_testrpc @pytest.fixture() def wait_for_miner_start(): - def _wait_for_miner_start(web3, timeout=60): + def _wait_for_miner_start(w3, timeout=60): poll_delay_counter = PollDelayCounter() with Timeout(timeout) as timeout: - while not web3.eth.mining or not web3.eth.hashrate: + while not w3.eth.mining or not w3.eth.hashrate: time.sleep(poll_delay_counter()) timeout.check() return _wait_for_miner_start @@ -66,24 +66,24 @@ def _wait_for_miner_start(web3, timeout=60): @pytest.fixture(scope="module") def wait_for_block(): - def _wait_for_block(web3, block_number=1, timeout=None): + def _wait_for_block(w3, block_number=1, timeout=None): if not timeout: - timeout = (block_number - web3.eth.block_number) * 3 + timeout = (block_number - w3.eth.block_number) * 3 poll_delay_counter = PollDelayCounter() with Timeout(timeout) as timeout: - while web3.eth.block_number < block_number: - web3.manager.request_blocking("evm_mine", []) + while w3.eth.block_number < block_number: + w3.manager.request_blocking("evm_mine", []) timeout.sleep(poll_delay_counter()) return _wait_for_block @pytest.fixture(scope="module") def wait_for_transaction(): - def _wait_for_transaction(web3, txn_hash, timeout=120): + def _wait_for_transaction(w3, txn_hash, timeout=120): poll_delay_counter = PollDelayCounter() with Timeout(timeout) as timeout: while True: - txn_receipt = web3.eth.get_transaction_receipt(txn_hash) + txn_receipt = w3.eth.get_transaction_receipt(txn_hash) if txn_receipt is not None: break time.sleep(poll_delay_counter()) @@ -94,7 +94,7 @@ def _wait_for_transaction(web3, txn_hash, timeout=120): @pytest.fixture() -def web3(): +def w3(): provider = EthereumTesterProvider() return Web3(provider) diff --git a/docs/examples.rst b/docs/examples.rst index 05dd4b7a27..e54ed70d43 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -865,7 +865,7 @@ The script can be run with: ``python ./eventscanner.py `` because it cannot correctly throttle and decrease the `eth_getLogs` block number range. """ - def __init__(self, web3: Web3, contract: Contract, state: EventScannerState, events: List, filters: {}, + def __init__(self, w3: Web3, contract: Contract, state: EventScannerState, events: List, filters: {}, max_chunk_scan_size: int = 10000, max_request_retries: int = 30, request_retry_seconds: float = 3.0): """ :param contract: Contract @@ -878,7 +878,7 @@ The script can be run with: ``python ./eventscanner.py `` self.logger = logger self.contract = contract - self.web3 = web3 + self.w3 = w3 self.state = state self.events = events self.filters = filters @@ -903,7 +903,7 @@ The script can be run with: ``python ./eventscanner.py `` def get_block_timestamp(self, block_num) -> datetime.datetime: """Get Ethereum block timestamp""" try: - block_info = self.web3.eth.getBlock(block_num) + block_info = self.w3.eth.getBlock(block_num) except BlockNotFound: # Block was not mined yet, # minor chain reorganisation? @@ -931,7 +931,7 @@ The script can be run with: ``python ./eventscanner.py `` # Do not scan all the way to the final block, as this # block might not be mined yet - return self.web3.eth.blockNumber - 1 + return self.w3.eth.blockNumber - 1 def get_last_scanned_block(self) -> int: return self.state.get_last_scanned_block() @@ -964,7 +964,7 @@ The script can be run with: ``python ./eventscanner.py `` # Callable that takes care of the underlying web3 call def _fetch_events(_start_block, _end_block): - return _fetch_events_for_all_contracts(self.web3, + return _fetch_events_for_all_contracts(self.w3, event_type, self.filters, from_block=_start_block, @@ -1133,7 +1133,7 @@ The script can be run with: ``python ./eventscanner.py `` def _fetch_events_for_all_contracts( - web3, + w3, event, argument_filters: dict, from_block: int, @@ -1158,7 +1158,7 @@ The script can be run with: ``python ./eventscanner.py `` # it might have Solidity ABI encoding v1 or v2. # We just assume the default that you set on Web3 object here. # More information here https://eth-abi.readthedocs.io/en/latest/index.html - codec: ABICodec = web3.codec + codec: ABICodec = w3.codec # Here we need to poke a bit into Web3 internals, as this # functionality is not exposed by default. @@ -1179,7 +1179,7 @@ The script can be run with: ``python ./eventscanner.py `` # Call JSON-RPC API on your Ethereum node. # get_logs() returns raw AttributedDict entries - logs = web3.eth.get_logs(event_filter_params) + logs = w3.eth.get_logs(event_filter_params) # Convert raw binary data to Python proxy objects as described by ABI all_events = [] @@ -1358,19 +1358,19 @@ The script can be run with: ``python ./eventscanner.py `` # throttle down. provider.middlewares.clear() - web3 = Web3(provider) + w3 = Web3(provider) # Prepare stub ERC-20 contract object abi = json.loads(ABI) - ERC20 = web3.eth.contract(abi=abi) + ERC20 = w3.eth.contract(abi=abi) # Restore/create our persistent state state = JSONifiedState() state.restore() - # chain_id: int, web3: Web3, abi: dict, state: EventScannerState, events: List, filters: {}, max_chunk_scan_size: int=10000 + # chain_id: int, w3: Web3, abi: dict, state: EventScannerState, events: List, filters: {}, max_chunk_scan_size: int=10000 scanner = EventScanner( - web3=web3, + w3=w3, contract=ERC20, state=state, events=[ERC20.events.Transfer], diff --git a/ens/main.py b/ens/main.py index 2c8360682a..928a3106a4 100644 --- a/ens/main.py +++ b/ens/main.py @@ -112,23 +112,23 @@ def __init__( :param hex-string addr: the address of the ENS registry on-chain. If not provided, ENS.py will default to the mainnet ENS registry address. """ - self.web3 = init_web3(provider, middlewares) + self.w3 = init_web3(provider, middlewares) ens_addr = addr if addr else ENS_MAINNET_ADDR - self.ens = self.web3.eth.contract(abi=abis.ENS, address=ens_addr) - self._resolverContract = self.web3.eth.contract(abi=abis.RESOLVER) + self.ens = self.w3.eth.contract(abi=abis.ENS, address=ens_addr) + self._resolverContract = self.w3.eth.contract(abi=abis.RESOLVER) @classmethod - def fromWeb3(cls, web3: 'Web3', addr: ChecksumAddress = None) -> 'ENS': + def fromWeb3(cls, w3: 'Web3', addr: ChecksumAddress = None) -> 'ENS': """ Generate an ENS instance with web3 - :param `web3.Web3` web3: to infer connection information + :param `web3.Web3` w3: to infer connection information :param hex-string addr: the address of the ENS registry on-chain. If not provided, ENS.py will default to the mainnet ENS registry address. """ - provider = web3.manager.provider - middlewares = web3.middleware_onion.middlewares + provider = w3.manager.provider + middlewares = w3.middleware_onion.middlewares return cls(provider, addr=addr, middlewares=middlewares) def address(self, name: str) -> Optional[ChecksumAddress]: @@ -333,7 +333,7 @@ def setup_owner( def _assert_control(self, account: ChecksumAddress, name: str, parent_owned: Optional[str] = None) -> None: - if not address_in(account, self.web3.eth.accounts): + if not address_in(account, self.w3.eth.accounts): raise UnauthorizedError( "in order to modify %r, you must control account %r, which owns %r" % ( name, account, parent_owned or name @@ -410,4 +410,4 @@ def _setup_reverse( def _reverse_registrar(self) -> 'Contract': addr = self.ens.caller.owner(normal_name_to_hash(REVERSE_REGISTRAR_DOMAIN)) - return self.web3.eth.contract(address=addr, abi=abis.REVERSE_REGISTRAR) + return self.w3.eth.contract(address=addr, abi=abis.REVERSE_REGISTRAR) diff --git a/ethpm/_utils/chains.py b/ethpm/_utils/chains.py index cbdaee7a61..3928a6b529 100644 --- a/ethpm/_utils/chains.py +++ b/ethpm/_utils/chains.py @@ -30,8 +30,8 @@ from web3 import Web3 # noqa: F401 -def get_genesis_block_hash(web3: "Web3") -> HexBytes: - return web3.eth.get_block(BlockNumber(0))["hash"] +def get_genesis_block_hash(w3: "Web3") -> HexBytes: + return w3.eth.get_block(BlockNumber(0))["hash"] BLOCK = "block" diff --git a/ethpm/contract.py b/ethpm/contract.py index 92dfa2faaf..d9b226d392 100644 --- a/ethpm/contract.py +++ b/ethpm/contract.py @@ -60,7 +60,7 @@ def __init__(self, address: bytes, **kwargs: Any) -> None: @classmethod def factory( - cls, web3: "Web3", class_name: str = None, **kwargs: Any + cls, w3: "Web3", class_name: str = None, **kwargs: Any ) -> Contract: dep_link_refs = kwargs.get("unlinked_references") bytecode = kwargs.get("bytecode") @@ -69,7 +69,7 @@ def factory( if not is_prelinked_bytecode(to_bytes(hexstr=bytecode), dep_link_refs): needs_bytecode_linking = True kwargs = assoc(kwargs, "needs_bytecode_linking", needs_bytecode_linking) - return super(LinkableContract, cls).factory(web3, class_name, **kwargs) + return super(LinkableContract, cls).factory(w3, class_name, **kwargs) @classmethod def constructor(cls, *args: Any, **kwargs: Any) -> ContractConstructor: @@ -98,7 +98,7 @@ def link_bytecode(cls, attr_dict: Dict[str, str]) -> Type["LinkableContract"]: cls.bytecode_runtime, cls.linked_references, attr_dict ) linked_class = cls.factory( - cls.web3, bytecode_runtime=runtime, bytecode=bytecode + cls.w3, bytecode_runtime=runtime, bytecode=bytecode ) if linked_class.needs_bytecode_linking: raise BytecodeLinkingError( diff --git a/ethpm/uri.py b/ethpm/uri.py index 35c8288399..45de062618 100644 --- a/ethpm/uri.py +++ b/ethpm/uri.py @@ -120,15 +120,15 @@ def create_latest_block_uri(w3: "Web3", from_blocks_ago: int = 3) -> URI: @curry -def check_if_chain_matches_chain_uri(web3: "Web3", blockchain_uri: URI) -> bool: +def check_if_chain_matches_chain_uri(w3: "Web3", blockchain_uri: URI) -> bool: chain_id, resource_type, resource_hash = parse_BIP122_uri(blockchain_uri) - genesis_block = web3.eth.get_block("earliest") + genesis_block = w3.eth.get_block("earliest") if encode_hex(genesis_block["hash"]) != chain_id: return False if resource_type == BLOCK: - resource = web3.eth.get_block(resource_hash) + resource = w3.eth.get_block(resource_hash) else: raise ValueError(f"Unsupported resource type: {resource_type}") diff --git a/newsfragments/1183.breaking-change.rst b/newsfragments/1183.breaking-change.rst new file mode 100644 index 0000000000..2486e9fd65 --- /dev/null +++ b/newsfragments/1183.breaking-change.rst @@ -0,0 +1 @@ +Audit ``.rst`` and ``.py`` files and convert all Web3 instance variable names to ``w3`` to avoid confusion with the ``web3`` module. \ No newline at end of file diff --git a/tests/core/admin-module/test_admin_addPeer.py b/tests/core/admin-module/test_admin_addPeer.py index 92b7be1505..896821ef95 100644 --- a/tests/core/admin-module/test_admin_addPeer.py +++ b/tests/core/admin-module/test_admin_addPeer.py @@ -1,20 +1,20 @@ import pytest -def test_admin_addPeer(web3, skip_if_testrpc): - skip_if_testrpc(web3) +def test_admin_addPeer(w3, skip_if_testrpc): + skip_if_testrpc(w3) with pytest.warns(DeprecationWarning): - result = web3.geth.admin.addPeer( + result = w3.geth.admin.addPeer( 'enode://44826a5d6a55f88a18298bca4773fca5749cdc3a5c9f308aa7d810e9b31123f3e7c5fba0b1d70aac5308426f47df2a128a6747040a3815cc7dd7167d03be320d@127.0.0.1:30304', # noqa: E501 ) assert result is True -def test_admin_add_peer(web3, skip_if_testrpc): - skip_if_testrpc(web3) +def test_admin_add_peer(w3, skip_if_testrpc): + skip_if_testrpc(w3) - result = web3.geth.admin.add_peer( + result = w3.geth.admin.add_peer( 'enode://44826a5d6a55f88a18298bca4773fca5749cdc3a5c9f308aa7d810e9b31123f3e7c5fba0b1d70aac5308426f47df2a128a6747040a3815cc7dd7167d03be320d@127.0.0.1:30304', # noqa: E501 ) assert result is True diff --git a/tests/core/admin-module/test_admin_nodeInfo.py b/tests/core/admin-module/test_admin_nodeInfo.py index 52977a76cb..7c209418aa 100644 --- a/tests/core/admin-module/test_admin_nodeInfo.py +++ b/tests/core/admin-module/test_admin_nodeInfo.py @@ -1,20 +1,20 @@ import pytest -def test_admin_nodeInfo(web3, skip_if_testrpc): - skip_if_testrpc(web3) +def test_admin_nodeInfo(w3, skip_if_testrpc): + skip_if_testrpc(w3) with pytest.warns(DeprecationWarning): - node_info = web3.geth.admin.nodeInfo + node_info = w3.geth.admin.nodeInfo assert 'enode' in node_info assert 'id' in node_info -def test_admin_node_info(web3, skip_if_testrpc): - skip_if_testrpc(web3) +def test_admin_node_info(w3, skip_if_testrpc): + skip_if_testrpc(w3) - node_info = web3.geth.admin.node_info + node_info = w3.geth.admin.node_info assert 'enode' in node_info assert 'id' in node_info diff --git a/tests/core/admin-module/test_admin_peers.py b/tests/core/admin-module/test_admin_peers.py index 38766a04e9..fb207327b6 100644 --- a/tests/core/admin-module/test_admin_peers.py +++ b/tests/core/admin-module/test_admin_peers.py @@ -1,4 +1,4 @@ -def test_admin_peers(web3, skip_if_testrpc): - skip_if_testrpc(web3) +def test_admin_peers(w3, skip_if_testrpc): + skip_if_testrpc(w3) - assert web3.geth.admin.peers == [] + assert w3.geth.admin.peers == [] diff --git a/tests/core/contracts/conftest.py b/tests/core/contracts/conftest.py index a36d08ff78..2941572be8 100644 --- a/tests/core/contracts/conftest.py +++ b/tests/core/contracts/conftest.py @@ -91,8 +91,8 @@ def NESTED_TUPLE_CONTRACT(NESTED_TUPLE_CODE, NESTED_TUPLE_RUNTIME, NESTED_TUPLE_ @pytest.fixture() -def NestedTupleContract(web3, NESTED_TUPLE_CONTRACT): - return web3.eth.contract(**NESTED_TUPLE_CONTRACT) +def NestedTupleContract(w3, NESTED_TUPLE_CONTRACT): + return w3.eth.contract(**NESTED_TUPLE_CONTRACT) CONTRACT_TUPLE_SOURCE = """ @@ -138,8 +138,8 @@ def TUPLE_CONTRACT(TUPLE_CODE, TUPLE_RUNTIME, TUPLE_ABI): @pytest.fixture() -def TupleContract(web3, TUPLE_CONTRACT): - return web3.eth.contract(**TUPLE_CONTRACT) +def TupleContract(w3, TUPLE_CONTRACT): + return w3.eth.contract(**TUPLE_CONTRACT) CONTRACT_CODE = "0x606060405261022e806100126000396000f360606040523615610074576000357c01000000000000000000000000000000000000000000000000000000009004806316216f391461007657806361bc221a146100995780637cf5dab0146100bc578063a5f3c23b146100e8578063d09de08a1461011d578063dcf537b11461014057610074565b005b610083600480505061016c565b6040518082815260200191505060405180910390f35b6100a6600480505061017f565b6040518082815260200191505060405180910390f35b6100d26004808035906020019091905050610188565b6040518082815260200191505060405180910390f35b61010760048080359060200190919080359060200190919050506101ea565b6040518082815260200191505060405180910390f35b61012a6004805050610201565b6040518082815260200191505060405180910390f35b6101566004808035906020019091905050610217565b6040518082815260200191505060405180910390f35b6000600d9050805080905061017c565b90565b60006000505481565b6000816000600082828250540192505081905550600060005054905080507f3496c3ede4ec3ab3686712aa1c238593ea6a42df83f98a5ec7df9834cfa577c5816040518082815260200191505060405180910390a18090506101e5565b919050565b6000818301905080508090506101fb565b92915050565b600061020d6001610188565b9050610214565b90565b60006007820290508050809050610229565b91905056" # noqa: E501 @@ -167,8 +167,8 @@ def MATH_ABI(): @pytest.fixture() -def MathContract(web3, MATH_ABI, MATH_CODE, MATH_RUNTIME): - return web3.eth.contract( +def MathContract(w3, MATH_ABI, MATH_CODE, MATH_RUNTIME): + return w3.eth.contract( abi=MATH_ABI, bytecode=MATH_CODE, bytecode_runtime=MATH_RUNTIME, @@ -196,11 +196,11 @@ def SIMPLE_CONSTRUCTOR_ABI(): @pytest.fixture() -def SimpleConstructorContract(web3, +def SimpleConstructorContract(w3, SIMPLE_CONSTRUCTOR_CODE, SIMPLE_CONSTRUCTOR_RUNTIME, SIMPLE_CONSTRUCTOR_ABI): - return web3.eth.contract( + return w3.eth.contract( abi=SIMPLE_CONSTRUCTOR_ABI, bytecode=SIMPLE_CONSTRUCTOR_CODE, bytecode_runtime=SIMPLE_CONSTRUCTOR_RUNTIME, @@ -228,11 +228,11 @@ def WITH_CONSTRUCTOR_ARGUMENTS_ABI(): @pytest.fixture() -def WithConstructorArgumentsContract(web3, +def WithConstructorArgumentsContract(w3, WITH_CONSTRUCTOR_ARGUMENTS_CODE, WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME, WITH_CONSTRUCTOR_ARGUMENTS_ABI): - return web3.eth.contract( + return w3.eth.contract( abi=WITH_CONSTRUCTOR_ARGUMENTS_ABI, bytecode=WITH_CONSTRUCTOR_ARGUMENTS_CODE, bytecode_runtime=WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME, @@ -272,11 +272,11 @@ def WITH_CONSTRUCTOR_ADDRESS_ABI(): @pytest.fixture() -def WithConstructorAddressArgumentsContract(web3, +def WithConstructorAddressArgumentsContract(w3, WITH_CONSTRUCTOR_ADDRESS_CODE, WITH_CONSTRUCTOR_ADDRESS_RUNTIME, WITH_CONSTRUCTOR_ADDRESS_ABI): - return web3.eth.contract( + return w3.eth.contract( abi=WITH_CONSTRUCTOR_ADDRESS_ABI, bytecode=WITH_CONSTRUCTOR_ADDRESS_CODE, bytecode_runtime=WITH_CONSTRUCTOR_ADDRESS_RUNTIME, @@ -284,8 +284,8 @@ def WithConstructorAddressArgumentsContract(web3, @pytest.fixture() -def AddressReflectorContract(web3): - return web3.eth.contract( +def AddressReflectorContract(w3): + return w3.eth.contract( abi=json.loads('[{"constant":true,"inputs":[{"name":"arg","type":"address"}],"name":"reflect","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"name":"arg","type":"address[]"}],"name":"reflect","outputs":[{"name":"","type":"address[]"}],"payable":false,"stateMutability":"pure","type":"function"}]'), # noqa: 501 bytecode="6060604052341561000f57600080fd5b6101ca8061001e6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630b816c1614610048578063c04d11fc146100c157600080fd5b341561005357600080fd5b61007f600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610170565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156100cc57600080fd5b61011960048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190505061017a565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561015c578082015181840152602081019050610141565b505050509050019250505060405180910390f35b6000819050919050565b61018261018a565b819050919050565b6020604051908101604052806000815250905600a165627a7a723058206b15d98a803b91327d94f943e9712291539701b2f7370e10f5873633941484930029", # noqa: 501 bytecode_runtime="60606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630b816c1614610048578063c04d11fc146100c157600080fd5b341561005357600080fd5b61007f600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610170565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156100cc57600080fd5b61011960048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190505061017a565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561015c578082015181840152602081019050610141565b505050509050019250505060405180910390f35b6000819050919050565b61018261018a565b819050919050565b6020604051908101604052806000815250905600a165627a7a723058206b15d98a803b91327d94f943e9712291539701b2f7370e10f5873633941484930029", # noqa: 501 @@ -324,8 +324,8 @@ def STRING_CONTRACT(STRING_CODE, STRING_RUNTIME, STRING_ABI): @pytest.fixture() -def StringContract(web3, STRING_CONTRACT): - return web3.eth.contract(**STRING_CONTRACT) +def StringContract(w3, STRING_CONTRACT): + return w3.eth.contract(**STRING_CONTRACT) CONTRACT_BYTES_CODE = "60606040526040805190810160405280600281526020017f01230000000000000000000000000000000000000000000000000000000000008152506000908051906020019061004f929190610096565b50341561005b57600080fd5b604051610723380380610723833981016040528080518201919050505b806001908051906020019061008e929190610116565b505b506101bb565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100d757805160ff1916838001178555610105565b82800160010185558215610105579182015b828111156101045782518255916020019190600101906100e9565b5b5090506101129190610196565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061015757805160ff1916838001178555610185565b82800160010185558215610185579182015b82811115610184578251825591602001919060010190610169565b5b5090506101929190610196565b5090565b6101b891905b808211156101b457600081600090555060010161019c565b5090565b90565b610559806101ca6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063209652551461005f57806330de3cee146100ee5780633fa4f2451461017d578063439970aa1461020c575b600080fd5b341561006a57600080fd5b610072610269565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100b35780820151818401525b602081019050610097565b50505050905090810190601f1680156100e05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156100f957600080fd5b610101610312565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101425780820151818401525b602081019050610126565b50505050905090810190601f16801561016f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561018857600080fd5b6101906103bb565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101d15780820151818401525b6020810190506101b5565b50505050905090810190601f1680156101fe5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561021757600080fd5b610267600480803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610459565b005b610271610474565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103075780601f106102dc57610100808354040283529160200191610307565b820191906000526020600020905b8154815290600101906020018083116102ea57829003601f168201915b505050505090505b90565b61031a610474565b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103b05780601f10610385576101008083540402835291602001916103b0565b820191906000526020600020905b81548152906001019060200180831161039357829003601f168201915b505050505090505b90565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104515780601f1061042657610100808354040283529160200191610451565b820191906000526020600020905b81548152906001019060200180831161043457829003601f168201915b505050505081565b806001908051906020019061046f929190610488565b505b50565b602060405190810160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106104c957805160ff19168380011785556104f7565b828001600101855582156104f7579182015b828111156104f65782518255916020019190600101906104db565b5b5090506105049190610508565b5090565b61052a91905b8082111561052657600081600090555060010161050e565b5090565b905600a165627a7a723058203ff916ee91add6247b20793745d1c6a8d8dcaa49d8c84fbbabb5c966fd9b6fc90029" # noqa: E501 @@ -360,8 +360,8 @@ def BYTES_CONTRACT(BYTES_CODE, BYTES_RUNTIME, BYTES_ABI): @pytest.fixture() -def BytesContract(web3, BYTES_CONTRACT): - return web3.eth.contract(**BYTES_CONTRACT) +def BytesContract(w3, BYTES_CONTRACT): + return w3.eth.contract(**BYTES_CONTRACT) CONTRACT_BYTES32_CODE = "60606040527f0123012301230123012301230123012301230123012301230123012301230123600090600019169055341561003957600080fd5b6040516020806101e2833981016040528080519060200190919050505b80600181600019169055505b505b61016f806100736000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063209652551461005f57806330de3cee146100905780633fa4f245146100c157806358825b10146100f2575b600080fd5b341561006a57600080fd5b610072610119565b60405180826000191660001916815260200191505060405180910390f35b341561009b57600080fd5b6100a3610124565b60405180826000191660001916815260200191505060405180910390f35b34156100cc57600080fd5b6100d461012e565b60405180826000191660001916815260200191505060405180910390f35b34156100fd57600080fd5b610117600480803560001916906020019091905050610134565b005b600060015490505b90565b6000805490505b90565b60015481565b80600181600019169055505b505600a165627a7a7230582043b15c20378b1603d330561258ccf291d08923a4c25fa8af0d590a010a6322180029" # noqa: E501 @@ -396,8 +396,8 @@ def BYTES32_CONTRACT(BYTES32_CODE, BYTES32_RUNTIME, BYTES32_ABI): @pytest.fixture() -def Bytes32Contract(web3, BYTES32_CONTRACT): - return web3.eth.contract(**BYTES32_CONTRACT) +def Bytes32Contract(w3, BYTES32_CONTRACT): + return w3.eth.contract(**BYTES32_CONTRACT) @pytest.fixture() @@ -491,29 +491,29 @@ def EVENT_CONTRACT( @pytest.fixture() -def EventContract(web3_empty, EVENT_CONTRACT): - web3 = web3_empty - return web3.eth.contract(**EVENT_CONTRACT) +def EventContract(w3_empty, EVENT_CONTRACT): + w3 = w3_empty + return w3.eth.contract(**EVENT_CONTRACT) @pytest.fixture() def event_contract( - web3_empty, + w3_empty, EventContract, wait_for_transaction, wait_for_block, address_conversion_func): - web3 = web3_empty + w3 = w3_empty - wait_for_block(web3) + wait_for_block(w3) deploy_txn_hash = EventContract.constructor().transact({ - 'from': web3.eth.coinbase, 'gas': 1000000 + 'from': w3.eth.coinbase, 'gas': 1000000 }) - deploy_receipt = wait_for_transaction(web3, deploy_txn_hash) + deploy_receipt = wait_for_transaction(w3, deploy_txn_hash) contract_address = address_conversion_func(deploy_receipt['contractAddress']) - bytecode = web3.eth.get_code(contract_address) + bytecode = w3.eth.get_code(contract_address) assert bytecode == EventContract.bytecode_runtime event_contract = EventContract(address=contract_address) assert event_contract.address == contract_address @@ -548,30 +548,30 @@ def INDEXED_EVENT_CONTRACT( @pytest.fixture() -def IndexedEventContract(web3_empty, INDEXED_EVENT_CONTRACT): - web3 = web3_empty - return web3.eth.contract(**INDEXED_EVENT_CONTRACT) +def IndexedEventContract(w3_empty, INDEXED_EVENT_CONTRACT): + w3 = w3_empty + return w3.eth.contract(**INDEXED_EVENT_CONTRACT) @pytest.fixture() def indexed_event( - web3_empty, + w3_empty, IndexedEventContract, wait_for_transaction, wait_for_block, address_conversion_func): - web3 = web3_empty + w3 = w3_empty - wait_for_block(web3) + wait_for_block(w3) deploy_txn_hash = IndexedEventContract.constructor().transact({ - 'from': web3.eth.coinbase, + 'from': w3.eth.coinbase, 'gas': 1000000 }) - deploy_receipt = wait_for_transaction(web3, deploy_txn_hash) + deploy_receipt = wait_for_transaction(w3, deploy_txn_hash) contract_address = address_conversion_func(deploy_receipt['contractAddress']) - bytecode = web3.eth.get_code(contract_address) + bytecode = w3.eth.get_code(contract_address) assert bytecode == IndexedEventContract.bytecode_runtime indexed_event_contract = IndexedEventContract(address=contract_address) assert indexed_event_contract.address == contract_address @@ -654,8 +654,8 @@ def ARRAYS_CONTRACT(ARRAYS_CODE, @pytest.fixture() -def ArraysContract(web3, ARRAYS_CONTRACT): - return web3.eth.contract(**ARRAYS_CONTRACT) +def ArraysContract(w3, ARRAYS_CONTRACT): + return w3.eth.contract(**ARRAYS_CONTRACT) @pytest.fixture() @@ -707,8 +707,8 @@ def PAYABLE_TESTER_CONTRACT(PAYABLE_TESTER_CODE, @pytest.fixture() -def PayableTesterContract(web3, PAYABLE_TESTER_CONTRACT): - return web3.eth.contract(**PAYABLE_TESTER_CONTRACT) +def PayableTesterContract(w3, PAYABLE_TESTER_CONTRACT): + return w3.eth.contract(**PAYABLE_TESTER_CONTRACT) # no matter the function selector, this will return back the 32 bytes of data supplied @@ -752,8 +752,8 @@ def PayableTesterContract(web3, PAYABLE_TESTER_CONTRACT): @pytest.fixture -def FixedReflectionContract(web3): - return web3.eth.contract(abi=CONTRACT_FIXED_ABI, bytecode=CONTRACT_REFLECTION_CODE) +def FixedReflectionContract(w3): + return w3.eth.contract(abi=CONTRACT_FIXED_ABI, bytecode=CONTRACT_REFLECTION_CODE) @pytest.fixture() @@ -783,8 +783,8 @@ def FALLBACK_FUNCTION_CONTRACT(FALLBACK_FUNCTION_CODE, @pytest.fixture() -def FallbackFunctionContract(web3, FALLBACK_FUNCTION_CONTRACT): - return web3.eth.contract(**FALLBACK_FUNCTION_CONTRACT) +def FallbackFunctionContract(w3, FALLBACK_FUNCTION_CONTRACT): + return w3.eth.contract(**FALLBACK_FUNCTION_CONTRACT) @pytest.fixture() @@ -814,8 +814,8 @@ def RECEIVE_FUNCTION_CONTRACT(RECEIVE_FUNCTION_CODE, @pytest.fixture() -def NoReceiveFunctionContract(web3, NO_RECEIVE_FUNCTION_CONTRACT): - return web3.eth.contract(**NO_RECEIVE_FUNCTION_CONTRACT) +def NoReceiveFunctionContract(w3, NO_RECEIVE_FUNCTION_CONTRACT): + return w3.eth.contract(**NO_RECEIVE_FUNCTION_CONTRACT) @pytest.fixture() @@ -845,8 +845,8 @@ def NO_RECEIVE_FUNCTION_CONTRACT(NO_RECEIVE_FUNCTION_CODE, @pytest.fixture() -def ReceiveFunctionContract(web3, RECEIVE_FUNCTION_CONTRACT): - return web3.eth.contract(**RECEIVE_FUNCTION_CONTRACT) +def ReceiveFunctionContract(w3, RECEIVE_FUNCTION_CONTRACT): + return w3.eth.contract(**RECEIVE_FUNCTION_CONTRACT) CONTRACT_CALLER_TESTER_SOURCE = """ @@ -908,8 +908,8 @@ def CALLER_TESTER_CONTRACT(CALLER_TESTER_CODE, @pytest.fixture() -def CallerTesterContract(web3, CALLER_TESTER_CONTRACT): - return web3.eth.contract(**CALLER_TESTER_CONTRACT) +def CallerTesterContract(w3, CALLER_TESTER_CONTRACT): + return w3.eth.contract(**CALLER_TESTER_CONTRACT) @pytest.fixture() @@ -939,8 +939,8 @@ def REVERT_FUNCTION_CONTRACT(REVERT_CONTRACT_CODE, @pytest.fixture() -def RevertContract(web3, REVERT_FUNCTION_CONTRACT): - return web3.eth.contract(**REVERT_FUNCTION_CONTRACT) +def RevertContract(w3, REVERT_FUNCTION_CONTRACT): + return w3.eth.contract(**REVERT_FUNCTION_CONTRACT) class LogFunctions: diff --git a/tests/core/contracts/test_concise_contract.py b/tests/core/contracts/test_concise_contract.py index 82cb5a3693..c54e4932f1 100644 --- a/tests/core/contracts/test_concise_contract.py +++ b/tests/core/contracts/test_concise_contract.py @@ -14,13 +14,13 @@ ) -def deploy(web3, Contract, args=None): +def deploy(w3, Contract, args=None): args = args or [] deploy_txn = Contract.constructor(*args).transact() - deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + deploy_receipt = w3.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 + assert len(w3.eth.get_code(contract.address)) > 0 return contract @@ -31,11 +31,11 @@ def EMPTY_ADDR(address_conversion_func): @pytest.fixture() -def zero_address_contract(web3, WithConstructorAddressArgumentsContract, EMPTY_ADDR): +def zero_address_contract(w3, WithConstructorAddressArgumentsContract, EMPTY_ADDR): deploy_txn = WithConstructorAddressArgumentsContract.constructor( EMPTY_ADDR, ).transact() - deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + deploy_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None _address_contract = WithConstructorAddressArgumentsContract( address=deploy_receipt['contractAddress'], @@ -81,26 +81,26 @@ def test_concisecontract_returns_none_for_0addr(zero_address_contract): assert result is None -def test_class_construction_sets_class_vars(web3, +def test_class_construction_sets_class_vars(w3, MATH_ABI, MATH_CODE, MATH_RUNTIME, some_address, ): - MathContract = web3.eth.contract( + MathContract = w3.eth.contract( abi=MATH_ABI, bytecode=MATH_CODE, bytecode_runtime=MATH_RUNTIME, ) classic = MathContract(some_address) - assert classic.web3 == web3 + assert classic.w3 == w3 assert classic.bytecode == decode_hex(MATH_CODE) assert classic.bytecode_runtime == decode_hex(MATH_RUNTIME) -def test_conciscecontract_keeps_custom_normalizers_on_base(web3, MATH_ABI): - base_contract = web3.eth.contract(abi=MATH_ABI) +def test_conciscecontract_keeps_custom_normalizers_on_base(w3, MATH_ABI): + base_contract = w3.eth.contract(abi=MATH_ABI) # give different normalizers to this base instance base_contract._return_data_normalizers = base_contract._return_data_normalizers + tuple([None]) @@ -116,10 +116,10 @@ def test_conciscecontract_keeps_custom_normalizers_on_base(web3, MATH_ABI): def test_conciscecontract_function_collision( - web3, + w3, StringContract): - contract = deploy(web3, StringContract, args=["blarg"]) + contract = deploy(w3, StringContract, args=["blarg"]) def getValue(): assert 'getValue' in [ @@ -138,7 +138,7 @@ def getValue(): concise_contract.getValue() -def test_concisecontract_deprecation_warning(web3, StringContract): - contract = deploy(web3, StringContract, args=["blarg"]) +def test_concisecontract_deprecation_warning(w3, StringContract): + contract = deploy(w3, StringContract, args=["blarg"]) with pytest.warns(DeprecationWarning): ConciseContract(contract) diff --git a/tests/core/contracts/test_contract_ambiguous_functions.py b/tests/core/contracts/test_contract_ambiguous_functions.py index dfbff370e5..69e15e4ff6 100644 --- a/tests/core/contracts/test_contract_ambiguous_functions.py +++ b/tests/core/contracts/test_contract_ambiguous_functions.py @@ -40,14 +40,14 @@ @pytest.fixture() -def string_contract(web3, StringContract, address_conversion_func): +def string_contract(w3, StringContract, address_conversion_func): deploy_txn = StringContract.constructor("Caqalai").transact() - deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + deploy_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None contract_address = address_conversion_func(deploy_receipt['contractAddress']) contract = StringContract(address=contract_address) assert contract.address == contract_address - assert len(web3.eth.get_code(contract.address)) > 0 + assert len(w3.eth.get_code(contract.address)) > 0 return contract @@ -123,8 +123,8 @@ def string_contract(web3, StringContract, address_conversion_func): ), ), ) -def test_find_or_get_functions_by_type(web3, method, args, repr_func, expected): - contract = web3.eth.contract(abi=AMBIGUOUS_CONTRACT_ABI) +def test_find_or_get_functions_by_type(w3, method, args, repr_func, expected): + contract = w3.eth.contract(abi=AMBIGUOUS_CONTRACT_ABI) function = getattr(contract, method)(*args) assert repr_func(function) == expected @@ -170,8 +170,8 @@ def test_find_or_get_functions_by_type(web3, method, args, repr_func, expected): ), ) ) -def test_functions_error_messages(web3, method, args, expected_message, expected_error): - contract = web3.eth.contract(abi=AMBIGUOUS_CONTRACT_ABI) +def test_functions_error_messages(w3, method, args, expected_message, expected_error): + contract = w3.eth.contract(abi=AMBIGUOUS_CONTRACT_ABI) with pytest.raises(expected_error, match=expected_message): getattr(contract, method)(*args) diff --git a/tests/core/contracts/test_contract_attributes.py b/tests/core/contracts/test_contract_attributes.py index db360357fe..25fffa4a6c 100644 --- a/tests/core/contracts/test_contract_attributes.py +++ b/tests/core/contracts/test_contract_attributes.py @@ -15,8 +15,8 @@ def abi(): 'attribute', ('functions', 'events', 'caller') ) -def test_getattr(web3, abi, attribute): - contract = web3.eth.contract(abi=abi) +def test_getattr(w3, abi, attribute): + contract = w3.eth.contract(abi=abi) contract_attribute = getattr(contract, attribute) assert getattr(contract_attribute, "Increased") @@ -28,8 +28,8 @@ def test_getattr(web3, abi, attribute): ('caller', ABIFunctionNotFound), ) ) -def test_getattr_raises_error(web3, abi, attribute, error): - contract = web3.eth.contract(abi=abi) +def test_getattr_raises_error(w3, abi, attribute, error): + contract = w3.eth.contract(abi=abi) contract_attribute = getattr(contract, attribute) with pytest.raises(error): @@ -40,8 +40,8 @@ def test_getattr_raises_error(web3, abi, attribute, error): 'attribute', ('functions', 'events', 'caller') ) -def test_hasattr(web3, abi, attribute): - contract = web3.eth.contract(abi=abi) +def test_hasattr(w3, abi, attribute): + contract = w3.eth.contract(abi=abi) contract_attribute = getattr(contract, attribute) assert hasattr(contract_attribute, "Increased") is True diff --git a/tests/core/contracts/test_contract_buildTransaction.py b/tests/core/contracts/test_contract_buildTransaction.py index 4713061e99..13b6727ed0 100644 --- a/tests/core/contracts/test_contract_buildTransaction.py +++ b/tests/core/contracts/test_contract_buildTransaction.py @@ -10,9 +10,9 @@ @pytest.fixture() -def math_contract(web3, MathContract, address_conversion_func): +def math_contract(w3, MathContract, address_conversion_func): deploy_txn = MathContract.constructor().transact() - deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + deploy_receipt = w3.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) @@ -21,9 +21,9 @@ def math_contract(web3, MathContract, address_conversion_func): @pytest.fixture() -def fallback_function_contract(web3, FallbackFunctionContract, address_conversion_func): +def fallback_function_contract(w3, FallbackFunctionContract, address_conversion_func): deploy_txn = FallbackFunctionContract.constructor().transact() - deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + deploy_receipt = w3.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) @@ -32,9 +32,9 @@ def fallback_function_contract(web3, FallbackFunctionContract, address_conversio @pytest.fixture() -def payable_tester_contract(web3, PayableTesterContract, address_conversion_func): +def payable_tester_contract(w3, PayableTesterContract, address_conversion_func): deploy_txn = PayableTesterContract.constructor().transact() - deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + deploy_receipt = w3.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) @@ -43,7 +43,7 @@ def payable_tester_contract(web3, PayableTesterContract, address_conversion_func def test_build_transaction_not_paying_to_nonpayable_function( - web3, + w3, payable_tester_contract, buildTransaction): txn = buildTransaction(contract=payable_tester_contract, @@ -59,7 +59,7 @@ def test_build_transaction_not_paying_to_nonpayable_function( def test_build_transaction_paying_to_nonpayable_function( - web3, + w3, payable_tester_contract, buildTransaction): with pytest.raises(ValidationError): @@ -68,7 +68,7 @@ def test_build_transaction_paying_to_nonpayable_function( tx_params={'value': 1}) -def test_build_transaction_with_contract_no_arguments(web3, math_contract, buildTransaction): +def test_build_transaction_with_contract_no_arguments(w3, math_contract, buildTransaction): txn = buildTransaction(contract=math_contract, contract_function='increment') assert dissoc(txn, 'gas') == { 'to': math_contract.address, @@ -80,7 +80,7 @@ def test_build_transaction_with_contract_no_arguments(web3, math_contract, build } -def test_build_transaction_with_contract_fallback_function(web3, fallback_function_contract): +def test_build_transaction_with_contract_fallback_function(w3, fallback_function_contract): txn = fallback_function_contract.fallback.buildTransaction() assert dissoc(txn, 'gas') == { 'to': fallback_function_contract.address, @@ -93,7 +93,7 @@ def test_build_transaction_with_contract_fallback_function(web3, fallback_functi def test_build_transaction_with_contract_class_method( - web3, + w3, MathContract, math_contract, buildTransaction): @@ -113,7 +113,7 @@ def test_build_transaction_with_contract_class_method( def test_build_transaction_with_contract_default_account_is_set( - web3, + w3, math_contract, buildTransaction): txn = buildTransaction(contract=math_contract, contract_function='increment') @@ -127,10 +127,10 @@ def test_build_transaction_with_contract_default_account_is_set( } -def test_build_transaction_with_gas_price_strategy_set(web3, math_contract, buildTransaction): - def my_gas_price_strategy(web3, transaction_params): +def test_build_transaction_with_gas_price_strategy_set(w3, math_contract, buildTransaction): + def my_gas_price_strategy(w3, transaction_params): return 5 - web3.eth.set_gas_price_strategy(my_gas_price_strategy) + w3.eth.set_gas_price_strategy(my_gas_price_strategy) txn = buildTransaction(contract=math_contract, contract_function='increment') assert dissoc(txn, 'gas') == { 'to': math_contract.address, @@ -141,7 +141,7 @@ def my_gas_price_strategy(web3, transaction_params): } -def test_build_transaction_with_contract_data_supplied_errors(web3, +def test_build_transaction_with_contract_data_supplied_errors(w3, math_contract, buildTransaction): with pytest.raises(ValueError): @@ -150,7 +150,7 @@ def test_build_transaction_with_contract_data_supplied_errors(web3, tx_params={'data': '0x000'}) -def test_build_transaction_with_contract_to_address_supplied_errors(web3, +def test_build_transaction_with_contract_to_address_supplied_errors(w3, math_contract, buildTransaction): with pytest.raises(ValueError): @@ -213,7 +213,7 @@ def test_build_transaction_with_contract_to_address_supplied_errors(web3, 'With Value', ] ) -def test_build_transaction_with_contract_with_arguments(web3, skip_if_testrpc, math_contract, +def test_build_transaction_with_contract_with_arguments(w3, skip_if_testrpc, math_contract, transaction_args, method_args, method_kwargs, @@ -221,7 +221,7 @@ def test_build_transaction_with_contract_with_arguments(web3, skip_if_testrpc, m skip_testrpc, buildTransaction): if skip_testrpc: - skip_if_testrpc(web3) + skip_if_testrpc(w3) txn = buildTransaction(contract=math_contract, contract_function='increment', diff --git a/tests/core/contracts/test_contract_call_interface.py b/tests/core/contracts/test_contract_call_interface.py index 1c6b0d91d2..6b1c1809b8 100644 --- a/tests/core/contracts/test_contract_call_interface.py +++ b/tests/core/contracts/test_contract_call_interface.py @@ -37,42 +37,42 @@ ) -def deploy(web3, Contract, apply_func=identity, args=None): +def deploy(w3, Contract, apply_func=identity, args=None): args = args or [] deploy_txn = Contract.constructor(*args).transact() - deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + deploy_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None address = apply_func(deploy_receipt['contractAddress']) contract = Contract(address=address) assert contract.address == address - assert len(web3.eth.get_code(contract.address)) > 0 + assert len(w3.eth.get_code(contract.address)) > 0 return contract @pytest.fixture() -def address_reflector_contract(web3, AddressReflectorContract, address_conversion_func): - return deploy(web3, AddressReflectorContract, address_conversion_func) +def address_reflector_contract(w3, AddressReflectorContract, address_conversion_func): + return deploy(w3, AddressReflectorContract, address_conversion_func) @pytest.fixture() -def math_contract(web3, MathContract, address_conversion_func): - return deploy(web3, MathContract, address_conversion_func) +def math_contract(w3, MathContract, address_conversion_func): + return deploy(w3, MathContract, address_conversion_func) @pytest.fixture() -def string_contract(web3, StringContract, address_conversion_func): - return deploy(web3, StringContract, address_conversion_func, args=["Caqalai"]) +def string_contract(w3, StringContract, address_conversion_func): + return deploy(w3, StringContract, address_conversion_func, args=["Caqalai"]) @pytest.fixture() -def arrays_contract(web3, ArraysContract, address_conversion_func): +def arrays_contract(w3, ArraysContract, address_conversion_func): # bytes_32 = [keccak('0'), keccak('1')] bytes32_array = [ b'\x04HR\xb2\xa6p\xad\xe5@~x\xfb(c\xc5\x1d\xe9\xfc\xb9eB\xa0q\x86\xfe:\xed\xa6\xbb\x8a\x11m', # noqa: E501 b'\xc8\x9e\xfd\xaaT\xc0\xf2\x0cz\xdfa(\x82\xdf\tP\xf5\xa9Qc~\x03\x07\xcd\xcbLg/)\x8b\x8b\xc6', # noqa: E501 ] byte_arr = [b'\xff', b'\xff', b'\xff', b'\xff'] - return deploy(web3, ArraysContract, address_conversion_func, args=[bytes32_array, byte_arr]) + return deploy(w3, ArraysContract, address_conversion_func, args=[bytes32_array, byte_arr]) @pytest.fixture() @@ -92,9 +92,9 @@ def strict_arrays_contract(w3_strict_abi, StrictArraysContract, address_conversi @pytest.fixture() -def address_contract(web3, WithConstructorAddressArgumentsContract, address_conversion_func): +def address_contract(w3, WithConstructorAddressArgumentsContract, address_conversion_func): return deploy( - web3, + w3, WithConstructorAddressArgumentsContract, address_conversion_func, args=["0xd3CdA913deB6f67967B99D67aCDFa1712C293601"] @@ -102,30 +102,30 @@ def address_contract(web3, WithConstructorAddressArgumentsContract, address_conv @pytest.fixture(params=[b'\x04\x06', '0x0406', '0406']) -def bytes_contract(web3, BytesContract, request, address_conversion_func): +def bytes_contract(w3, BytesContract, request, address_conversion_func): if is_text(request.param) and request.param[:2] != '0x': with pytest.warns( DeprecationWarning, match='in v6 it will be invalid to pass a hex string without the "0x" prefix' ): - return deploy(web3, BytesContract, address_conversion_func, args=[request.param]) + return deploy(w3, BytesContract, address_conversion_func, args=[request.param]) else: - return deploy(web3, BytesContract, address_conversion_func, args=[request.param]) + return deploy(w3, BytesContract, address_conversion_func, args=[request.param]) @pytest.fixture() -def fixed_reflection_contract(web3, FixedReflectionContract, address_conversion_func): - return deploy(web3, FixedReflectionContract, address_conversion_func) +def fixed_reflection_contract(w3, FixedReflectionContract, address_conversion_func): + return deploy(w3, FixedReflectionContract, address_conversion_func) @pytest.fixture() -def payable_tester_contract(web3, PayableTesterContract, address_conversion_func): - return deploy(web3, PayableTesterContract, address_conversion_func) +def payable_tester_contract(w3, PayableTesterContract, address_conversion_func): + return deploy(w3, PayableTesterContract, address_conversion_func) @pytest.fixture() -def revert_contract(web3, RevertContract, address_conversion_func): - return deploy(web3, RevertContract, address_conversion_func) +def revert_contract(w3, RevertContract, address_conversion_func): + return deploy(w3, RevertContract, address_conversion_func) @pytest.fixture() @@ -141,25 +141,25 @@ def call_transaction(): '0406040604060406040604060406040604060406040604060406040604060406', HexBytes('0406040604060406040604060406040604060406040604060406040604060406'), ]) -def bytes32_contract(web3, Bytes32Contract, request, address_conversion_func): +def bytes32_contract(w3, Bytes32Contract, request, address_conversion_func): if is_text(request.param) and request.param[:2] != '0x': with pytest.warns(DeprecationWarning): - return deploy(web3, Bytes32Contract, address_conversion_func, args=[request.param]) + return deploy(w3, Bytes32Contract, address_conversion_func, args=[request.param]) else: - return deploy(web3, Bytes32Contract, address_conversion_func, args=[request.param]) + return deploy(w3, Bytes32Contract, address_conversion_func, args=[request.param]) @pytest.fixture() -def undeployed_math_contract(web3, MathContract, address_conversion_func): +def undeployed_math_contract(MathContract, address_conversion_func): empty_address = address_conversion_func("0x000000000000000000000000000000000000dEaD") _undeployed_math_contract = MathContract(address=empty_address) return _undeployed_math_contract @pytest.fixture() -def mismatched_math_contract(web3, StringContract, MathContract, address_conversion_func): +def mismatched_math_contract(w3, StringContract, MathContract, address_conversion_func): deploy_txn = StringContract.constructor("Caqalai").transact() - deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + deploy_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None address = address_conversion_func(deploy_receipt['contractAddress']) _mismatched_math_contract = MathContract(address=address) @@ -167,31 +167,31 @@ def mismatched_math_contract(web3, StringContract, MathContract, address_convers @pytest.fixture() -def fallback_function_contract(web3, FallbackFunctionContract, address_conversion_func): - return deploy(web3, FallbackFunctionContract, address_conversion_func) +def fallback_function_contract(w3, FallbackFunctionContract, address_conversion_func): + return deploy(w3, FallbackFunctionContract, address_conversion_func) @pytest.fixture() -def receive_function_contract(web3, ReceiveFunctionContract, address_conversion_func): - return deploy(web3, ReceiveFunctionContract, address_conversion_func) +def receive_function_contract(w3, ReceiveFunctionContract, address_conversion_func): + return deploy(w3, ReceiveFunctionContract, address_conversion_func) @pytest.fixture() -def no_receive_function_contract(web3, NoReceiveFunctionContract, address_conversion_func): - return deploy(web3, NoReceiveFunctionContract, address_conversion_func) +def no_receive_function_contract(w3, NoReceiveFunctionContract, address_conversion_func): + return deploy(w3, NoReceiveFunctionContract, address_conversion_func) @pytest.fixture() -def tuple_contract(web3, TupleContract, address_conversion_func): - return deploy(web3, TupleContract, address_conversion_func) +def tuple_contract(w3, TupleContract, address_conversion_func): + return deploy(w3, TupleContract, address_conversion_func) @pytest.fixture() -def nested_tuple_contract(web3, NestedTupleContract, address_conversion_func): - return deploy(web3, NestedTupleContract, address_conversion_func) +def nested_tuple_contract(w3, NestedTupleContract, address_conversion_func): + return deploy(w3, NestedTupleContract, address_conversion_func) -def test_invalid_address_in_deploy_arg(web3, WithConstructorAddressArgumentsContract): +def test_invalid_address_in_deploy_arg(WithConstructorAddressArgumentsContract): with pytest.raises(InvalidAddress): WithConstructorAddressArgumentsContract.constructor( "0xd3cda913deb6f67967b99d67acdfa1712c293601", @@ -352,12 +352,12 @@ def test_call_read_address_variable(address_contract, call): assert result == "0xd3CdA913deB6f67967B99D67aCDFa1712C293601" -def test_init_with_ens_name_arg(web3, WithConstructorAddressArgumentsContract, call): +def test_init_with_ens_name_arg(w3, WithConstructorAddressArgumentsContract, call): with contract_ens_addresses( WithConstructorAddressArgumentsContract, [("arg-name.eth", "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413")], ): - address_contract = deploy(web3, WithConstructorAddressArgumentsContract, args=[ + address_contract = deploy(w3, WithConstructorAddressArgumentsContract, args=[ "arg-name.eth", ]) @@ -517,7 +517,7 @@ def test_call_fallback_function(fallback_function_contract): ({'data': '0x477a5c98'}, 'receive', 'fallback'), ({'value': 2}, 'receive', 'receive'), )) -def test_call_receive_fallback_function(web3, +def test_call_receive_fallback_function(w3, tx_params, expected, call, @@ -535,7 +535,7 @@ def test_call_receive_fallback_function(web3, assert initial_value == '' to = {'to': contract.address} merged = {**to, **tx_params} - web3.eth.send_transaction(merged) + w3.eth.send_transaction(merged) final_value = call(contract=contract, contract_function='getText') assert final_value == expected @@ -545,14 +545,14 @@ def test_call_nonexistent_receive_function(fallback_function_contract): fallback_function_contract.receive.call() -def test_throws_error_if_block_out_of_range(web3, math_contract): - web3.provider.make_request(method='evm_mine', params=[20]) +def test_throws_error_if_block_out_of_range(w3, math_contract): + w3.provider.make_request(method='evm_mine', params=[20]) with pytest.raises(BlockNumberOutofRange): math_contract.functions.counter().call(block_identifier=-50) -def test_accepts_latest_block(web3, math_contract): - web3.provider.make_request(method='evm_mine', params=[5]) +def test_accepts_latest_block(w3, math_contract): + w3.provider.make_request(method='evm_mine', params=[5]) math_contract.functions.increment().transact() late = math_contract.functions.counter().call(block_identifier='latest') @@ -562,10 +562,10 @@ def test_accepts_latest_block(web3, math_contract): assert pend == 1 -def test_accepts_block_hash_as_identifier(web3, math_contract): - blocks = web3.provider.make_request(method='evm_mine', params=[5]) +def test_accepts_block_hash_as_identifier(w3, math_contract): + blocks = w3.provider.make_request(method='evm_mine', params=[5]) math_contract.functions.increment().transact() - more_blocks = web3.provider.make_request(method='evm_mine', params=[5]) + more_blocks = w3.provider.make_request(method='evm_mine', params=[5]) old = math_contract.functions.counter().call(block_identifier=blocks['result'][2]) new = math_contract.functions.counter().call(block_identifier=more_blocks['result'][2]) @@ -574,11 +574,11 @@ def test_accepts_block_hash_as_identifier(web3, math_contract): assert new == 1 -def test_neg_block_indexes_from_the_end(web3, math_contract): - web3.provider.make_request(method='evm_mine', params=[5]) +def test_neg_block_indexes_from_the_end(w3, math_contract): + w3.provider.make_request(method='evm_mine', params=[5]) math_contract.functions.increment().transact() math_contract.functions.increment().transact() - web3.provider.make_request(method='evm_mine', params=[5]) + w3.provider.make_request(method='evm_mine', params=[5]) output1 = math_contract.functions.counter().call(block_identifier=-7) output2 = math_contract.functions.counter().call(block_identifier=-6) @@ -587,9 +587,9 @@ def test_neg_block_indexes_from_the_end(web3, math_contract): assert output2 == 2 -def test_returns_data_from_specified_block(web3, math_contract): - start_num = web3.eth.get_block('latest').number - web3.provider.make_request(method='evm_mine', params=[5]) +def test_returns_data_from_specified_block(w3, math_contract): + start_num = w3.eth.get_block('latest').number + w3.provider.make_request(method='evm_mine', params=[5]) math_contract.functions.increment().transact() math_contract.functions.increment().transact() @@ -635,38 +635,38 @@ def test_function_1_match_identifier_wrong_args_encoding(arrays_contract): arrays_contract.functions.setBytes32Value('dog').call() -def test_function_multiple_match_identifiers_no_correct_number_of_args(web3): +def test_function_multiple_match_identifiers_no_correct_number_of_args(w3): MULTIPLE_FUNCTIONS = json.loads('[{"constant":false,"inputs":[],"name":"a","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"","type":"bytes32"}],"name":"a","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"","type":"uint256"}],"name":"a","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"","type":"uint8"}],"name":"a","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"","type":"int8"}],"name":"a","outputs":[],"type":"function"}]') # noqa: E501 - Contract = web3.eth.contract(abi=MULTIPLE_FUNCTIONS) + Contract = w3.eth.contract(abi=MULTIPLE_FUNCTIONS) regex = message_regex + diagnosis_arg_regex with pytest.raises(ValidationError, match=regex): Contract.functions.a(100, 'dog').call() -def test_function_multiple_match_identifiers_no_correct_encoding_of_args(web3): +def test_function_multiple_match_identifiers_no_correct_encoding_of_args(w3): MULTIPLE_FUNCTIONS = json.loads('[{"constant":false,"inputs":[],"name":"a","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"","type":"bytes32"}],"name":"a","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"","type":"uint256"}],"name":"a","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"","type":"uint8"}],"name":"a","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"","type":"int8"}],"name":"a","outputs":[],"type":"function"}]') # noqa: E501 - Contract = web3.eth.contract(abi=MULTIPLE_FUNCTIONS) + Contract = w3.eth.contract(abi=MULTIPLE_FUNCTIONS) regex = message_regex + diagnosis_encoding_regex with pytest.raises(ValidationError, match=regex): Contract.functions.a('dog').call() -def test_function_multiple_possible_encodings(web3): +def test_function_multiple_possible_encodings(w3): MULTIPLE_FUNCTIONS = json.loads('[{"constant":false,"inputs":[],"name":"a","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"","type":"bytes32"}],"name":"a","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"","type":"uint256"}],"name":"a","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"","type":"uint8"}],"name":"a","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"","type":"int8"}],"name":"a","outputs":[],"type":"function"}]') # noqa: E501 - Contract = web3.eth.contract(abi=MULTIPLE_FUNCTIONS) + Contract = w3.eth.contract(abi=MULTIPLE_FUNCTIONS) regex = message_regex + diagnosis_ambiguous_encoding with pytest.raises(ValidationError, match=regex): Contract.functions.a(100).call() -def test_function_no_abi(web3): - contract = web3.eth.contract() +def test_function_no_abi(w3): + contract = w3.eth.contract() with pytest.raises(NoABIFound): contract.functions.thisFunctionDoesNotExist().call() -def test_call_abi_no_functions(web3): - contract = web3.eth.contract(abi=[]) +def test_call_abi_no_functions(w3): + contract = w3.eth.contract(abi=[]) with pytest.raises(NoABIFunctionsFound): contract.functions.thisFunctionDoesNotExist().call() @@ -704,7 +704,7 @@ def test_call_sending_ether_to_nonpayable_function(payable_tester_contract, call ('reflect_short_u', Decimal('25.5')), ), ) -def test_reflect_fixed_value(web3, fixed_reflection_contract, function, value): +def test_reflect_fixed_value(fixed_reflection_contract, function, value): contract_func = fixed_reflection_contract.functions[function] reflected = contract_func(value).call({'gas': 420000}) assert reflected == value @@ -741,7 +741,7 @@ def test_reflect_fixed_value(web3, fixed_reflection_contract, function, value): ('reflect', 0, "Ambiguous argument encoding"), ), ) -def test_invalid_fixed_value_reflections(web3, fixed_reflection_contract, function, value, error): +def test_invalid_fixed_value_reflections(fixed_reflection_contract, function, value, error): contract_func = fixed_reflection_contract.functions[function] with pytest.raises(ValidationError, match=error): contract_func(value).call({'gas': 420000}) diff --git a/tests/core/contracts/test_contract_caller_interface.py b/tests/core/contracts/test_contract_caller_interface.py index 45c4ac7c6a..9553766115 100644 --- a/tests/core/contracts/test_contract_caller_interface.py +++ b/tests/core/contracts/test_contract_caller_interface.py @@ -11,40 +11,40 @@ ) -def deploy(web3, Contract, apply_func=identity, args=None): +def deploy(w3, Contract, apply_func=identity, args=None): args = args or [] deploy_txn = Contract.constructor(*args).transact() - deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + deploy_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None address = apply_func(deploy_receipt['contractAddress']) contract = Contract(address=address) assert contract.address == address - assert len(web3.eth.get_code(contract.address)) > 0 + assert len(w3.eth.get_code(contract.address)) > 0 return contract @pytest.fixture() -def address(web3): - return web3.eth.accounts[1] +def address(w3): + return w3.eth.accounts[1] @pytest.fixture() -def math_contract(web3, MathContract, address_conversion_func): - return deploy(web3, MathContract, address_conversion_func) +def math_contract(w3, MathContract, address_conversion_func): + return deploy(w3, MathContract, address_conversion_func) @pytest.fixture() -def caller_tester_contract(web3, CallerTesterContract, address_conversion_func): - return deploy(web3, CallerTesterContract, address_conversion_func) +def caller_tester_contract(w3, CallerTesterContract, address_conversion_func): + return deploy(w3, CallerTesterContract, address_conversion_func) @pytest.fixture() -def transaction_dict(web3, address): +def transaction_dict(w3, address): return { 'from': address, 'gas': 210000, - 'maxFeePerGas': web3.toWei(1, 'gwei'), - 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), + 'maxFeePerGas': w3.toWei(1, 'gwei'), + 'maxPriorityFeePerGas': w3.toWei(1, 'gwei'), 'value': 12345, } @@ -59,26 +59,26 @@ def test_caller_with_parens(math_contract): assert result == 8 -def test_caller_with_no_abi(web3): - contract = web3.eth.contract() +def test_caller_with_no_abi(w3): + contract = w3.eth.contract() with pytest.raises(NoABIFound): contract.caller.thisFunctionDoesNotExist() -def test_caller_with_no_abi_and_parens(web3): - contract = web3.eth.contract() +def test_caller_with_no_abi_and_parens(w3): + contract = w3.eth.contract() with pytest.raises(NoABIFound): contract.caller().thisFunctionDoesNotExist() -def test_caller_with_empty_abi_and_parens(web3): - contract = web3.eth.contract(abi=[]) +def test_caller_with_empty_abi_and_parens(w3): + contract = w3.eth.contract(abi=[]) with pytest.raises(NoABIFunctionsFound): contract.caller().thisFunctionDoesNotExist() -def test_caller_with_empty_abi(web3): - contract = web3.eth.contract(abi=[]) +def test_caller_with_empty_abi(w3): + contract = w3.eth.contract(abi=[]) with pytest.raises(NoABIFunctionsFound): contract.caller.thisFunctionDoesNotExist() @@ -99,11 +99,11 @@ def test_caller_with_a_nonexistent_function(math_contract): contract.caller.thisFunctionDoesNotExist() -def test_caller_with_block_identifier(web3, math_contract): - start_num = web3.eth.get_block('latest').number +def test_caller_with_block_identifier(w3, math_contract): + start_num = w3.eth.get_block('latest').number assert math_contract.caller.counter() == 0 - web3.provider.make_request(method='evm_mine', params=[5]) + w3.provider.make_request(method='evm_mine', params=[5]) math_contract.functions.increment().transact() math_contract.functions.increment().transact() @@ -114,14 +114,14 @@ def test_caller_with_block_identifier(web3, math_contract): assert output2 == 2 -def test_caller_with_block_identifier_and_transaction_dict(web3, +def test_caller_with_block_identifier_and_transaction_dict(w3, caller_tester_contract, transaction_dict, address): - start_num = web3.eth.get_block('latest').number + start_num = w3.eth.get_block('latest').number assert caller_tester_contract.caller.counter() == 0 - web3.provider.make_request(method='evm_mine', params=[5]) + w3.provider.make_request(method='evm_mine', params=[5]) caller_tester_contract.functions.increment().transact() block_id = start_num + 6 @@ -140,7 +140,7 @@ def test_caller_with_block_identifier_and_transaction_dict(web3, assert counter == 1 -def test_caller_with_transaction_keyword(web3, +def test_caller_with_transaction_keyword(w3, caller_tester_contract, transaction_dict, address): @@ -153,7 +153,7 @@ def test_caller_with_transaction_keyword(web3, assert value == transaction_dict['value'] -def test_caller_with_dict_but_no_transaction_keyword(web3, +def test_caller_with_dict_but_no_transaction_keyword(w3, caller_tester_contract, transaction_dict, address): @@ -166,7 +166,7 @@ def test_caller_with_dict_but_no_transaction_keyword(web3, assert value == transaction_dict['value'] -def test_caller_with_args_and_no_transaction_keyword(web3, +def test_caller_with_args_and_no_transaction_keyword(w3, caller_tester_contract, transaction_dict, address): diff --git a/tests/core/contracts/test_contract_class_construction.py b/tests/core/contracts/test_contract_class_construction.py index 1f5557081d..1eea5d246a 100644 --- a/tests/core/contracts/test_contract_class_construction.py +++ b/tests/core/contracts/test_contract_class_construction.py @@ -13,17 +13,17 @@ ) -def test_class_construction_sets_class_vars(web3, +def test_class_construction_sets_class_vars(w3, MATH_ABI, MATH_CODE, MATH_RUNTIME): - MathContract = web3.eth.contract( + MathContract = w3.eth.contract( abi=MATH_ABI, bytecode=MATH_CODE, bytecode_runtime=MATH_RUNTIME, ) - assert MathContract.web3 == web3 + assert MathContract.w3 == w3 assert MathContract.bytecode == decode_hex(MATH_CODE) assert MathContract.bytecode_runtime == decode_hex(MATH_RUNTIME) @@ -33,21 +33,21 @@ def test_error_to_instantiate_base_class(): Contract() -def test_abi_as_json_string(web3, MATH_ABI, some_address): +def test_abi_as_json_string(w3, MATH_ABI, some_address): abi_str = json.dumps(MATH_ABI) - MathContract = web3.eth.contract(abi=abi_str) + MathContract = w3.eth.contract(abi=abi_str) assert MathContract.abi == MATH_ABI math = MathContract(some_address) assert math.abi == MATH_ABI -def test_error_to_call_non_existent_fallback(web3, +def test_error_to_call_non_existent_fallback(w3, MATH_ABI, MATH_CODE, MATH_RUNTIME): - math_contract = web3.eth.contract( + math_contract = w3.eth.contract( abi=MATH_ABI, bytecode=MATH_CODE, bytecode_runtime=MATH_RUNTIME, diff --git a/tests/core/contracts/test_contract_constructor.py b/tests/core/contracts/test_contract_constructor.py index b762853092..36ae246de8 100644 --- a/tests/core/contracts/test_contract_constructor.py +++ b/tests/core/contracts/test_contract_constructor.py @@ -15,33 +15,33 @@ def test_contract_constructor_abi_encoding_with_no_constructor_fn(MathContract, assert deploy_data == MATH_CODE -def test_contract_constructor_gas_estimate_no_constructor(web3, MathContract): +def test_contract_constructor_gas_estimate_no_constructor(w3, MathContract): gas_estimate = MathContract.constructor().estimateGas() deploy_txn = MathContract.constructor().transact() - txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + txn_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) gas_used = txn_receipt.get('gasUsed') assert abs(gas_estimate - gas_used) < 21000 -def test_contract_constructor_gas_estimate_with_block_id(web3, MathContract): +def test_contract_constructor_gas_estimate_with_block_id(w3, MathContract): block_identifier = None gas_estimate = MathContract.constructor().estimateGas(block_identifier=block_identifier) deploy_txn = MathContract.constructor().transact() - txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + txn_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) gas_used = txn_receipt.get('gasUsed') assert abs(gas_estimate - gas_used) < 21000 def test_contract_constructor_gas_estimate_with_constructor_without_arguments( - web3, + w3, SimpleConstructorContract): gas_estimate = SimpleConstructorContract.constructor().estimateGas() deploy_txn = SimpleConstructorContract.constructor().transact() - txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + txn_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) gas_used = txn_receipt.get('gasUsed') assert abs(gas_estimate - gas_used) < 21000 @@ -57,7 +57,7 @@ def test_contract_constructor_gas_estimate_with_constructor_without_arguments( ), ) def test_contract_constructor_gas_estimate_with_constructor_with_arguments( - web3, + w3, WithConstructorArgumentsContract, constructor_args, constructor_kwargs): @@ -66,14 +66,14 @@ def test_contract_constructor_gas_estimate_with_constructor_with_arguments( deploy_txn = WithConstructorArgumentsContract.constructor( *constructor_args, **constructor_kwargs).transact() - txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + txn_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) gas_used = txn_receipt.get('gasUsed') assert abs(gas_estimate - gas_used) < 21000 def test_contract_constructor_gas_estimate_with_constructor_with_address_argument( - web3, + w3, WithConstructorAddressArgumentsContract, address_conversion_func): gas_estimate = WithConstructorAddressArgumentsContract.constructor( @@ -81,43 +81,43 @@ def test_contract_constructor_gas_estimate_with_constructor_with_address_argumen deploy_txn = WithConstructorAddressArgumentsContract.constructor( address_conversion_func("0x16D9983245De15E7A9A73bC586E01FF6E08dE737")).transact() - txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + txn_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) gas_used = txn_receipt.get('gasUsed') assert abs(gas_estimate - gas_used) < 21000 def test_contract_constructor_transact_no_constructor( - web3, + w3, MathContract, MATH_RUNTIME, address_conversion_func): deploy_txn = MathContract.constructor().transact() - txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + txn_receipt = w3.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']) - blockchain_code = web3.eth.get_code(contract_address) + blockchain_code = w3.eth.get_code(contract_address) assert blockchain_code == decode_hex(MATH_RUNTIME) def test_contract_constructor_transact_with_constructor_without_arguments( - web3, + w3, SimpleConstructorContract, SIMPLE_CONSTRUCTOR_RUNTIME, address_conversion_func): deploy_txn = SimpleConstructorContract.constructor().transact() - txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + txn_receipt = w3.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']) - blockchain_code = web3.eth.get_code(contract_address) + blockchain_code = w3.eth.get_code(contract_address) assert blockchain_code == decode_hex(SIMPLE_CONSTRUCTOR_RUNTIME) @@ -131,7 +131,7 @@ def test_contract_constructor_transact_with_constructor_without_arguments( ), ) def test_contract_constructor_transact_with_constructor_with_arguments( - web3, + w3, WithConstructorArgumentsContract, WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME, constructor_args, @@ -142,13 +142,13 @@ def test_contract_constructor_transact_with_constructor_with_arguments( deploy_txn = WithConstructorArgumentsContract.constructor( *constructor_args, **constructor_kwargs).transact() - txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + txn_receipt = w3.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']) - blockchain_code = web3.eth.get_code(contract_address) + blockchain_code = w3.eth.get_code(contract_address) assert blockchain_code == decode_hex(WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME) assert expected_a == WithConstructorArgumentsContract( address=contract_address).functions.data_a().call() @@ -157,16 +157,16 @@ def test_contract_constructor_transact_with_constructor_with_arguments( def test_contract_constructor_transact_with_constructor_with_address_arguments( - web3, + w3, WithConstructorAddressArgumentsContract, WITH_CONSTRUCTOR_ADDRESS_RUNTIME, address_conversion_func): deploy_txn = WithConstructorAddressArgumentsContract.constructor(TEST_ADDRESS).transact() - txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + txn_receipt = w3.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']) - blockchain_code = web3.eth.get_code(contract_address) + blockchain_code = w3.eth.get_code(contract_address) assert blockchain_code == decode_hex(WITH_CONSTRUCTOR_ADDRESS_RUNTIME) assert TEST_ADDRESS == WithConstructorAddressArgumentsContract( address=contract_address).functions.testAddr().call() @@ -178,37 +178,37 @@ def test_contract_constructor_build_transaction_to_field_error(MathContract): def test_contract_constructor_build_transaction_no_constructor( - web3, + w3, MathContract, address_conversion_func): txn_hash = MathContract.constructor().transact( - {'from': address_conversion_func(web3.eth.accounts[0])} + {'from': address_conversion_func(w3.eth.accounts[0])} ) - txn = web3.eth.get_transaction(txn_hash) - nonce = web3.eth.get_transaction_count(web3.eth.coinbase) + txn = w3.eth.get_transaction(txn_hash) + nonce = w3.eth.get_transaction_count(w3.eth.coinbase) unsent_txn = MathContract.constructor().buildTransaction({'nonce': nonce}) assert txn['data'] == unsent_txn['data'] - new_txn_hash = web3.eth.send_transaction(unsent_txn) - new_txn = web3.eth.get_transaction(new_txn_hash) + new_txn_hash = w3.eth.send_transaction(unsent_txn) + new_txn = w3.eth.get_transaction(new_txn_hash) assert new_txn['data'] == unsent_txn['data'] assert new_txn['nonce'] == nonce def test_contract_constructor_build_transaction_with_constructor_without_argument( - web3, + w3, MathContract, address_conversion_func): txn_hash = MathContract.constructor().transact( - {'from': address_conversion_func(web3.eth.accounts[0])} + {'from': address_conversion_func(w3.eth.accounts[0])} ) - txn = web3.eth.get_transaction(txn_hash) - nonce = web3.eth.get_transaction_count(web3.eth.coinbase) + txn = w3.eth.get_transaction(txn_hash) + nonce = w3.eth.get_transaction_count(w3.eth.coinbase) unsent_txn = MathContract.constructor().buildTransaction({'nonce': nonce}) assert txn['data'] == unsent_txn['data'] - new_txn_hash = web3.eth.send_transaction(unsent_txn) - new_txn = web3.eth.get_transaction(new_txn_hash) + new_txn_hash = w3.eth.send_transaction(unsent_txn) + new_txn = w3.eth.get_transaction(new_txn_hash) assert new_txn['data'] == unsent_txn['data'] assert new_txn['nonce'] == nonce @@ -223,22 +223,22 @@ def test_contract_constructor_build_transaction_with_constructor_without_argumen ), ) def test_contract_constructor_build_transaction_with_constructor_with_argument( - web3, + w3, WithConstructorArgumentsContract, constructor_args, constructor_kwargs, address_conversion_func): txn_hash = WithConstructorArgumentsContract.constructor( *constructor_args, **constructor_kwargs).transact( - {'from': address_conversion_func(web3.eth.accounts[0])} + {'from': address_conversion_func(w3.eth.accounts[0])} ) - txn = web3.eth.get_transaction(txn_hash) - nonce = web3.eth.get_transaction_count(web3.eth.coinbase) + txn = w3.eth.get_transaction(txn_hash) + nonce = w3.eth.get_transaction_count(w3.eth.coinbase) unsent_txn = WithConstructorArgumentsContract.constructor( *constructor_args, **constructor_kwargs).buildTransaction({'nonce': nonce}) assert txn['data'] == unsent_txn['data'] - new_txn_hash = web3.eth.send_transaction(unsent_txn) - new_txn = web3.eth.get_transaction(new_txn_hash) + new_txn_hash = w3.eth.send_transaction(unsent_txn) + new_txn = w3.eth.get_transaction(new_txn_hash) assert new_txn['data'] == unsent_txn['data'] assert new_txn['nonce'] == nonce diff --git a/tests/core/contracts/test_contract_constructor_encoding.py b/tests/core/contracts/test_contract_constructor_encoding.py index 3711dfaf9a..7966c5f301 100644 --- a/tests/core/contracts/test_contract_constructor_encoding.py +++ b/tests/core/contracts/test_contract_constructor_encoding.py @@ -53,15 +53,15 @@ def test_error_if_invalid_arguments_supplied(WithConstructorArgumentsContract, a '0x61626364', ), ) -def test_contract_constructor_encoding_encoding(web3, WithConstructorArgumentsContract, bytes_arg): +def test_contract_constructor_encoding_encoding(w3, WithConstructorArgumentsContract, bytes_arg): deploy_data = WithConstructorArgumentsContract._encode_constructor_data([1234, bytes_arg]) encoded_args = '0x00000000000000000000000000000000000000000000000000000000000004d26162636400000000000000000000000000000000000000000000000000000000' # noqa: E501 - expected_ending = encode_hex(web3.codec.encode_abi(['uint256', 'bytes32'], [1234, b'abcd'])) + expected_ending = encode_hex(w3.codec.encode_abi(['uint256', 'bytes32'], [1234, b'abcd'])) assert expected_ending == encoded_args assert deploy_data.endswith(remove_0x_prefix(expected_ending)) -def test_contract_constructor_encoding_encoding_warning(web3, WithConstructorArgumentsContract): +def test_contract_constructor_encoding_encoding_warning(w3, WithConstructorArgumentsContract): with pytest.warns( DeprecationWarning, match='in v6 it will be invalid to pass a hex string without the \"0x\" prefix' @@ -70,7 +70,7 @@ def test_contract_constructor_encoding_encoding_warning(web3, WithConstructorArg encoded_args = '0x00000000000000000000000000000000000000000000000000000000000004d26162636400000000000000000000000000000000000000000000000000000000' # noqa: E501 expected_ending = encode_hex( - web3.codec.encode_abi(['uint256', 'bytes32'], [1234, b'abcd']) + w3.codec.encode_abi(['uint256', 'bytes32'], [1234, b'abcd']) ) assert expected_ending == encoded_args assert deploy_data.endswith(remove_0x_prefix(expected_ending)) diff --git a/tests/core/contracts/test_contract_deployment.py b/tests/core/contracts/test_contract_deployment.py index 20027ea701..f0b2e80d81 100644 --- a/tests/core/contracts/test_contract_deployment.py +++ b/tests/core/contracts/test_contract_deployment.py @@ -10,36 +10,36 @@ ) -def test_contract_deployment_no_constructor(web3, MathContract, +def test_contract_deployment_no_constructor(w3, MathContract, MATH_RUNTIME): deploy_txn = MathContract.constructor().transact() - txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + txn_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) assert txn_receipt is not None assert txn_receipt['contractAddress'] contract_address = txn_receipt['contractAddress'] - blockchain_code = web3.eth.get_code(contract_address) + blockchain_code = w3.eth.get_code(contract_address) assert blockchain_code == decode_hex(MATH_RUNTIME) -def test_contract_deployment_with_constructor_without_args(web3, +def test_contract_deployment_with_constructor_without_args(w3, SimpleConstructorContract, SIMPLE_CONSTRUCTOR_RUNTIME): deploy_txn = SimpleConstructorContract.constructor().transact() - txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + txn_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) assert txn_receipt is not None assert txn_receipt['contractAddress'] contract_address = txn_receipt['contractAddress'] - blockchain_code = web3.eth.get_code(contract_address) + blockchain_code = w3.eth.get_code(contract_address) assert blockchain_code == decode_hex(SIMPLE_CONSTRUCTOR_RUNTIME) -def test_contract_deployment_with_constructor_with_arguments(web3, +def test_contract_deployment_with_constructor_with_arguments(w3, WithConstructorArgumentsContract, WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME): with pytest.warns( @@ -48,13 +48,13 @@ def test_contract_deployment_with_constructor_with_arguments(web3, ): deploy_txn = WithConstructorArgumentsContract.constructor(1234, 'abcd').transact() - txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + txn_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) assert txn_receipt is not None assert txn_receipt['contractAddress'] contract_address = txn_receipt['contractAddress'] - blockchain_code = web3.eth.get_code(contract_address) + blockchain_code = w3.eth.get_code(contract_address) assert blockchain_code == decode_hex(WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME) @@ -90,18 +90,18 @@ def test_contract_deployment_with_constructor_with_arguments_strict_error(w3_str WithConstructorArgumentsContractStrict.constructor(1234, 'abcd').transact() -def test_contract_deployment_with_constructor_with_address_argument(web3, +def test_contract_deployment_with_constructor_with_address_argument(w3, WithConstructorAddressArgumentsContract, # noqa: E501 WITH_CONSTRUCTOR_ADDRESS_RUNTIME): # noqa: E501 deploy_txn = WithConstructorAddressArgumentsContract.constructor( "0x16D9983245De15E7A9A73bC586E01FF6E08dE737", ).transact() - txn_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + txn_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) assert txn_receipt is not None assert txn_receipt['contractAddress'] contract_address = txn_receipt['contractAddress'] - blockchain_code = web3.eth.get_code(contract_address) + blockchain_code = w3.eth.get_code(contract_address) assert blockchain_code == decode_hex(WITH_CONSTRUCTOR_ADDRESS_RUNTIME) diff --git a/tests/core/contracts/test_contract_estimateGas.py b/tests/core/contracts/test_contract_estimateGas.py index e3226f02fa..704e746028 100644 --- a/tests/core/contracts/test_contract_estimateGas.py +++ b/tests/core/contracts/test_contract_estimateGas.py @@ -6,28 +6,28 @@ @pytest.fixture(autouse=True) -def wait_for_first_block(web3, wait_for_block): - wait_for_block(web3) +def wait_for_first_block(w3, wait_for_block): + wait_for_block(w3) @pytest.fixture() -def math_contract(web3, +def math_contract(w3, MATH_ABI, MATH_CODE, MATH_RUNTIME, wait_for_transaction, address_conversion_func): - MathContract = web3.eth.contract( + MathContract = w3.eth.contract( abi=MATH_ABI, bytecode=MATH_CODE, bytecode_runtime=MATH_RUNTIME, ) - deploy_txn = MathContract.constructor().transact({'from': web3.eth.coinbase}) - deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + deploy_txn = MathContract.constructor().transact({'from': w3.eth.coinbase}) + deploy_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None contract_address = address_conversion_func(deploy_receipt['contractAddress']) - web3.isAddress(contract_address) + w3.isAddress(contract_address) _math_contract = MathContract(address=contract_address) assert _math_contract.address == contract_address @@ -35,23 +35,23 @@ def math_contract(web3, @pytest.fixture() -def fallback_function_contract(web3, +def fallback_function_contract(w3, FALLBACK_FUNCTION_ABI, FALLBACK_FUNCTION_CODE, FALLBACK_FUNCTION_RUNTIME, wait_for_transaction, address_conversion_func): - fallback_contract = web3.eth.contract( + fallback_contract = w3.eth.contract( abi=FALLBACK_FUNCTION_ABI, bytecode=FALLBACK_FUNCTION_CODE, bytecode_runtime=FALLBACK_FUNCTION_RUNTIME ) - deploy_txn = fallback_contract.constructor().transact({'from': web3.eth.coinbase}) - deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + deploy_txn = fallback_contract.constructor().transact({'from': w3.eth.coinbase}) + deploy_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None contract_address = address_conversion_func(deploy_receipt['contractAddress']) - web3.isAddress(contract_address) + w3.isAddress(contract_address) _fallback_function_contract = fallback_contract(address=contract_address) assert _fallback_function_contract.address == contract_address @@ -59,9 +59,9 @@ 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.wait_for_transaction_receipt(deploy_txn) +def payable_tester_contract(w3, PayableTesterContract, address_conversion_func): + deploy_txn = PayableTesterContract.constructor().transact({'from': w3.eth.coinbase}) + deploy_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None payable_tester_address = address_conversion_func(deploy_receipt['contractAddress']) @@ -71,7 +71,7 @@ def payable_tester_contract(web3, PayableTesterContract, address_conversion_func return _payable_tester -def test_contract_estimateGas(web3, math_contract, estimateGas, transact): +def test_contract_estimateGas(w3, math_contract, estimateGas, transact): gas_estimate = estimateGas(contract=math_contract, contract_function='increment') @@ -79,24 +79,24 @@ def test_contract_estimateGas(web3, math_contract, estimateGas, transact): contract=math_contract, contract_function='increment') - txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) + txn_receipt = w3.eth.wait_for_transaction_receipt(txn_hash) gas_used = txn_receipt.get('gasUsed') assert abs(gas_estimate - gas_used) < 21000 -def test_contract_fallback_estimateGas(web3, fallback_function_contract): +def test_contract_fallback_estimateGas(w3, fallback_function_contract): gas_estimate = fallback_function_contract.fallback.estimateGas() txn_hash = fallback_function_contract.fallback.transact() - txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) + txn_receipt = w3.eth.wait_for_transaction_receipt(txn_hash) gas_used = txn_receipt.get('gasUsed') assert abs(gas_estimate - gas_used) < 21000 -def test_contract_estimateGas_with_arguments(web3, math_contract, estimateGas, transact): +def test_contract_estimateGas_with_arguments(w3, math_contract, estimateGas, transact): gas_estimate = estimateGas(contract=math_contract, contract_function='add', func_args=[5, 6]) @@ -105,14 +105,14 @@ 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.wait_for_transaction_receipt(txn_hash) + txn_receipt = w3.eth.wait_for_transaction_receipt(txn_hash) gas_used = txn_receipt.get('gasUsed') assert abs(gas_estimate - gas_used) < 21000 def test_estimateGas_not_sending_ether_to_nonpayable_function( - web3, + w3, payable_tester_contract, estimateGas, transact): @@ -123,14 +123,14 @@ def test_estimateGas_not_sending_ether_to_nonpayable_function( contract=payable_tester_contract, contract_function='doNoValueCall') - txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) + txn_receipt = w3.eth.wait_for_transaction_receipt(txn_hash) gas_used = txn_receipt.get('gasUsed') assert abs(gas_estimate - gas_used) < 21000 def test_estimateGas_sending_ether_to_nonpayable_function( - web3, + w3, payable_tester_contract, estimateGas): with pytest.raises(ValidationError): @@ -139,22 +139,22 @@ def test_estimateGas_sending_ether_to_nonpayable_function( tx_params={'value': 1}) -def test_estimateGas_accepts_latest_block(web3, math_contract, transact): +def test_estimateGas_accepts_latest_block(w3, math_contract, transact): gas_estimate = math_contract.functions.counter().estimateGas(block_identifier='latest') txn_hash = transact( contract=math_contract, contract_function='increment') - txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) + txn_receipt = w3.eth.wait_for_transaction_receipt(txn_hash) gas_used = txn_receipt.get('gasUsed') assert abs(gas_estimate - gas_used) < 21000 -def test_estimateGas_block_identifier_unique_estimates(web3, math_contract, transact): +def test_estimateGas_block_identifier_unique_estimates(w3, math_contract, transact): txn_hash = transact(contract=math_contract, contract_function="increment") - web3.eth.wait_for_transaction_receipt(txn_hash) + w3.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_events_buildFilter.py b/tests/core/contracts/test_contract_events_buildFilter.py index 02fade01c3..f8e98c3beb 100644 --- a/tests/core/contracts/test_contract_events_buildFilter.py +++ b/tests/core/contracts/test_contract_events_buildFilter.py @@ -11,19 +11,19 @@ CONTRACT_ABI = json.loads('[{"constant":false,"inputs":[],"name":"return13","outputs":[{"name":"result","type":"int256"}],"type":"function"},{"constant":true,"inputs":[],"name":"counter","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"amt","type":"uint256"}],"name":"increment","outputs":[{"name":"result","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"a","type":"int256"},{"name":"b","type":"int256"}],"name":"add","outputs":[{"name":"result","type":"int256"}],"type":"function"},{"constant":false,"inputs":[],"name":"increment","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"a","type":"int256"}],"name":"multiply7","outputs":[{"name":"result","type":"int256"}],"type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"value","type":"uint256"}],"name":"Increased","type":"event"}]') # noqa: E501 -def test_build_filter_topic_signature(web3): - contract = web3.eth.contract(abi=CONTRACT_ABI) +def test_build_filter_topic_signature(w3): + contract = w3.eth.contract(abi=CONTRACT_ABI) filter_builder = contract.events.Increased.build_filter() filter_builder.args['value'].match_any(100, 200, 300) - _filter = filter_builder.deploy(web3) + _filter = filter_builder.deploy(w3) assert _filter.filter_params == { 'topics': ( HexBytes(keccak(text="Increased(uint256)")).hex(),)} assert _filter.data_filter_set == (('uint256', (100, 200, 300)),) -def test_build_filter_resetting_build_filter_properties(web3): - contract = web3.eth.contract(abi=CONTRACT_ABI) +def test_build_filter_resetting_build_filter_properties(w3): + contract = w3.eth.contract(abi=CONTRACT_ABI) filter_builder = contract.events.Increased.build_filter() # Address is setable from undeployed contract class filter_builder.address = b'\x10' * 40 @@ -38,26 +38,26 @@ def test_build_filter_resetting_build_filter_properties(web3): filter_builder.toBlock = 50 -def test_build_filter_argument_match_single_can_only_be_set_once(web3): - contract = web3.eth.contract(abi=CONTRACT_ABI) +def test_build_filter_argument_match_single_can_only_be_set_once(w3): + contract = w3.eth.contract(abi=CONTRACT_ABI) filter_builder = contract.events.Increased.build_filter() filter_builder.args['value'].match_single(100) with pytest.raises(ValueError): filter_builder.args['value'].match_single(200) -def test_build_filter_argument_match_any_can_only_be_set_once(web3): - contract = web3.eth.contract(abi=CONTRACT_ABI) +def test_build_filter_argument_match_any_can_only_be_set_once(w3): + contract = w3.eth.contract(abi=CONTRACT_ABI) filter_builder = contract.events.Increased.build_filter() filter_builder.args['value'].match_any(100, 200) with pytest.raises(ValueError): filter_builder.args['value'].match_any(200, 300) -def test_deployed_build_filter_can_have_no_values_set(web3): - contract = web3.eth.contract(abi=CONTRACT_ABI) +def test_deployed_build_filter_can_have_no_values_set(w3): + contract = w3.eth.contract(abi=CONTRACT_ABI) filter_builder = contract.events.Increased.build_filter() - filter_builder.deploy(web3) + filter_builder.deploy(w3) with pytest.raises(ValueError): filter_builder.address = b'\x00' * 40 with pytest.raises(ValueError): diff --git a/tests/core/contracts/test_contract_init.py b/tests/core/contracts/test_contract_init.py index cdf202205f..230ff7c384 100644 --- a/tests/core/contracts/test_contract_init.py +++ b/tests/core/contracts/test_contract_init.py @@ -12,9 +12,9 @@ @pytest.fixture() def math_addr(MathContract, address_conversion_func): - web3 = MathContract.web3 - deploy_txn = MathContract.constructor().transact({'from': web3.eth.coinbase}) - deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + w3 = MathContract.w3 + deploy_txn = MathContract.constructor().transact({'from': w3.eth.coinbase}) + deploy_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None return address_conversion_func(deploy_receipt['contractAddress']) @@ -28,27 +28,27 @@ def test_contract_with_unset_address(MathContract): def test_contract_with_name_address(MathContract, math_addr): with contract_ens_addresses(MathContract, [('thedao.eth', math_addr)]): mc = MathContract(address='thedao.eth') - caller = mc.web3.eth.coinbase + caller = mc.w3.eth.coinbase assert mc.address == 'thedao.eth' assert mc.functions.return13().call({'from': caller}) == 13 def test_contract_with_name_address_from_eth_contract( - web3, + w3, MATH_ABI, MATH_CODE, MATH_RUNTIME, math_addr, ): - with ens_addresses(web3, [('thedao.eth', math_addr)]): - mc = web3.eth.contract( + with ens_addresses(w3, [('thedao.eth', math_addr)]): + mc = w3.eth.contract( address='thedao.eth', abi=MATH_ABI, bytecode=MATH_CODE, bytecode_runtime=MATH_RUNTIME, ) - caller = mc.web3.eth.coinbase + caller = mc.w3.eth.coinbase assert mc.address == 'thedao.eth' assert mc.functions.return13().call({'from': caller}) == 13 @@ -58,7 +58,7 @@ def test_contract_with_name_address_changing(MathContract, math_addr): with contract_ens_addresses(MathContract, [('thedao.eth', math_addr)]): mc = MathContract(address='thedao.eth') - caller = mc.web3.eth.coinbase + caller = mc.w3.eth.coinbase assert mc.address == 'thedao.eth' # what happens when name returns no address at all diff --git a/tests/core/contracts/test_contract_method_abi_decoding.py b/tests/core/contracts/test_contract_method_abi_decoding.py index fafe12a9bb..a6c0f1b6be 100644 --- a/tests/core/contracts/test_contract_method_abi_decoding.py +++ b/tests/core/contracts/test_contract_method_abi_decoding.py @@ -81,8 +81,8 @@ ), ), ) -def test_contract_abi_decoding(web3, abi, data, method, expected): - contract = web3.eth.contract(abi=abi) +def test_contract_abi_decoding(w3, abi, data, method, expected): + contract = w3.eth.contract(abi=abi) func, params = contract.decode_function_input(data) assert func.fn_name == method assert params == expected @@ -108,8 +108,8 @@ def test_contract_abi_decoding(web3, abi, data, method, expected): ), ), ) -def test_contract_abi_encoding_kwargs(web3, abi, method, expected, data): - contract = web3.eth.contract(abi=abi) +def test_contract_abi_encoding_kwargs(w3, abi, method, expected, data): + contract = w3.eth.contract(abi=abi) func, params = contract.decode_function_input(data) assert func.fn_name == method assert params == expected diff --git a/tests/core/contracts/test_contract_method_abi_encoding.py b/tests/core/contracts/test_contract_method_abi_encoding.py index 19ba0f517f..efe4aa5b64 100644 --- a/tests/core/contracts/test_contract_method_abi_encoding.py +++ b/tests/core/contracts/test_contract_method_abi_encoding.py @@ -56,14 +56,14 @@ ), ), ) -def test_contract_abi_encoding(web3, abi, arguments, data, expected): - contract = web3.eth.contract(abi=abi) +def test_contract_abi_encoding(w3, abi, arguments, data, expected): + contract = w3.eth.contract(abi=abi) actual = contract.encodeABI('a', arguments, data=data) assert actual == expected -def test_contract_abi_encoding_warning(web3): - contract = web3.eth.contract(abi=ABI_C) +def test_contract_abi_encoding_warning(w3): + contract = w3.eth.contract(abi=ABI_C) with pytest.warns( DeprecationWarning, @@ -74,8 +74,8 @@ def test_contract_abi_encoding_warning(web3): assert actual == '0x9f3fab586100000000000000000000000000000000000000000000000000000000000000' # noqa: E501 -def test_contract_abi_encoding_kwargs(web3): - contract = web3.eth.contract(abi=ABI_D) +def test_contract_abi_encoding_kwargs(w3): + contract = w3.eth.contract(abi=ABI_D) kwargs = { 'b': [ '0x5595c210956e7721f9b692e702708556aa9aabb14ea163e96afa56ffbe9fa809', diff --git a/tests/core/contracts/test_contract_method_to_argument_matching.py b/tests/core/contracts/test_contract_method_to_argument_matching.py index 3560687df7..8f80dbf6c6 100644 --- a/tests/core/contracts/test_contract_method_to_argument_matching.py +++ b/tests/core/contracts/test_contract_method_to_argument_matching.py @@ -93,16 +93,16 @@ ''') -def test_finds_single_function_without_args(web3): - Contract = web3.eth.contract(abi=SINGLE_FN_NO_ARGS) +def test_finds_single_function_without_args(w3): + Contract = w3.eth.contract(abi=SINGLE_FN_NO_ARGS) abi = Contract._find_matching_fn_abi('a', []) assert abi['name'] == 'a' assert abi['inputs'] == [] -def test_finds_single_function_with_args(web3): - Contract = web3.eth.contract(abi=SINGLE_FN_ONE_ARG) +def test_finds_single_function_with_args(w3): + Contract = w3.eth.contract(abi=SINGLE_FN_ONE_ARG) abi = Contract._find_matching_fn_abi('a', [1234]) assert abi['name'] == 'a' @@ -110,22 +110,22 @@ def test_finds_single_function_with_args(web3): assert abi['inputs'][0]['type'] == 'uint256' -def test_finds_fallback_function(web3): - Contract = web3.eth.contract(abi=FALLBACK_FUNCTION) +def test_finds_fallback_function(w3): + Contract = w3.eth.contract(abi=FALLBACK_FUNCTION) abi = Contract._find_matching_fn_abi(FallbackFn, []) assert abi['type'] == 'fallback' -def test_finds_receive_function(web3): - Contract = web3.eth.contract(abi=RECEIVE_FUNCTION) +def test_finds_receive_function(w3): + Contract = w3.eth.contract(abi=RECEIVE_FUNCTION) abi = Contract._find_matching_fn_abi(ReceiveFn, []) assert abi['type'] == 'receive' -def test_error_when_no_function_name_match(web3): - Contract = web3.eth.contract(abi=SINGLE_FN_NO_ARGS) +def test_error_when_no_function_name_match(w3): + Contract = w3.eth.contract(abi=SINGLE_FN_NO_ARGS) with pytest.raises(ValidationError): Contract._find_matching_fn_abi('no_function_name', [1234]) @@ -144,8 +144,8 @@ def test_error_when_no_function_name_match(web3): ([[(-1, True), (2, False)]], ['(int256,bool)[]']), ) ) -def test_finds_function_with_matching_args(web3, arguments, expected_types): - Contract = web3.eth.contract(abi=MULTIPLE_FUNCTIONS) +def test_finds_function_with_matching_args(w3, arguments, expected_types): + Contract = w3.eth.contract(abi=MULTIPLE_FUNCTIONS) abi = Contract._find_matching_fn_abi('a', arguments) assert abi['name'] == 'a' @@ -153,8 +153,8 @@ def test_finds_function_with_matching_args(web3, arguments, expected_types): assert set(get_abi_input_types(abi)) == set(expected_types) -def test_finds_function_with_matching_args_deprecation_warning(web3): - Contract = web3.eth.contract(abi=MULTIPLE_FUNCTIONS) +def test_finds_function_with_matching_args_deprecation_warning(w3): + Contract = w3.eth.contract(abi=MULTIPLE_FUNCTIONS) with pytest.warns(DeprecationWarning): abi = Contract._find_matching_fn_abi('a', ['']) @@ -163,8 +163,8 @@ def test_finds_function_with_matching_args_deprecation_warning(web3): assert set(get_abi_input_types(abi)) == set(['bytes32']) -def test_error_when_duplicate_match(web3): - Contract = web3.eth.contract(abi=MULTIPLE_FUNCTIONS) +def test_error_when_duplicate_match(w3): + Contract = w3.eth.contract(abi=MULTIPLE_FUNCTIONS) with pytest.raises(ValidationError): Contract._find_matching_fn_abi('a', [100]) diff --git a/tests/core/contracts/test_contract_transact_interface.py b/tests/core/contracts/test_contract_transact_interface.py index 0e506be5f7..32a6c48414 100644 --- a/tests/core/contracts/test_contract_transact_interface.py +++ b/tests/core/contracts/test_contract_transact_interface.py @@ -15,61 +15,61 @@ ) -def deploy(web3, Contract, apply_func=identity, args=None): +def deploy(w3, Contract, apply_func=identity, args=None): args = args or [] deploy_txn = Contract.constructor(*args).transact() - deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn) + deploy_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn) assert deploy_receipt is not None address = apply_func(deploy_receipt['contractAddress']) contract = Contract(address=address) assert contract.address == address - assert len(web3.eth.get_code(contract.address)) > 0 + assert len(w3.eth.get_code(contract.address)) > 0 return contract @pytest.fixture() -def math_contract(web3, MathContract, address_conversion_func): - return deploy(web3, MathContract, address_conversion_func) +def math_contract(w3, MathContract, address_conversion_func): + return deploy(w3, MathContract, address_conversion_func) @pytest.fixture() -def string_contract(web3, StringContract, address_conversion_func): - return deploy(web3, StringContract, address_conversion_func, args=["Caqalai"]) +def string_contract(w3, StringContract, address_conversion_func): + return deploy(w3, StringContract, address_conversion_func, args=["Caqalai"]) @pytest.fixture() -def fallback_function_contract(web3, FallbackFunctionContract, address_conversion_func): - return deploy(web3, FallbackFunctionContract, address_conversion_func) +def fallback_function_contract(w3, FallbackFunctionContract, address_conversion_func): + return deploy(w3, FallbackFunctionContract, address_conversion_func) @pytest.fixture() -def arrays_contract(web3, ArraysContract, address_conversion_func): +def arrays_contract(w3, ArraysContract, address_conversion_func): # bytes_32 = [keccak('0'), keccak('1')] bytes32_array = [ b'\x04HR\xb2\xa6p\xad\xe5@~x\xfb(c\xc5\x1d\xe9\xfc\xb9eB\xa0q\x86\xfe:\xed\xa6\xbb\x8a\x11m', # noqa: E501 b'\xc8\x9e\xfd\xaaT\xc0\xf2\x0cz\xdfa(\x82\xdf\tP\xf5\xa9Qc~\x03\x07\xcd\xcbLg/)\x8b\x8b\xc6', # noqa: E501 ] byte_arr = [b'\xff', b'\xff', b'\xff', b'\xff'] - return deploy(web3, ArraysContract, address_conversion_func, args=[bytes32_array, byte_arr]) + return deploy(w3, ArraysContract, address_conversion_func, args=[bytes32_array, byte_arr]) @pytest.fixture() -def payable_tester_contract(web3, PayableTesterContract, address_conversion_func): - return deploy(web3, PayableTesterContract, address_conversion_func) +def payable_tester_contract(w3, PayableTesterContract, address_conversion_func): + return deploy(w3, PayableTesterContract, address_conversion_func) @pytest.fixture() -def receive_function_contract(web3, ReceiveFunctionContract, address_conversion_func): - return deploy(web3, ReceiveFunctionContract, address_conversion_func) +def receive_function_contract(w3, ReceiveFunctionContract, address_conversion_func): + return deploy(w3, ReceiveFunctionContract, address_conversion_func) -def test_transacting_with_contract_no_arguments(web3, math_contract, transact, call): +def test_transacting_with_contract_no_arguments(w3, math_contract, transact, call): initial_value = call(contract=math_contract, contract_function='counter') txn_hash = transact(contract=math_contract, contract_function='increment') - txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) + txn_receipt = w3.eth.wait_for_transaction_receipt(txn_hash) assert txn_receipt is not None final_value = call(contract=math_contract, @@ -79,7 +79,7 @@ def test_transacting_with_contract_no_arguments(web3, math_contract, transact, c def test_transact_not_sending_ether_to_nonpayable_function( - web3, + w3, payable_tester_contract, transact, call): @@ -89,7 +89,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.wait_for_transaction_receipt(txn_hash) + txn_receipt = w3.eth.wait_for_transaction_receipt(txn_hash) assert txn_receipt is not None final_value = call(contract=payable_tester_contract, @@ -99,7 +99,7 @@ def test_transact_not_sending_ether_to_nonpayable_function( def test_transact_sending_ether_to_nonpayable_function( - web3, + w3, payable_tester_contract, transact, call): @@ -111,7 +111,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.wait_for_transaction_receipt(txn_hash) + txn_receipt = w3.eth.wait_for_transaction_receipt(txn_hash) assert txn_receipt is not None final_value = call(contract=payable_tester_contract, @@ -127,7 +127,7 @@ def test_transact_sending_ether_to_nonpayable_function( (tuple(), {'amt': 5}), ), ) -def test_transacting_with_contract_with_arguments(web3, +def test_transacting_with_contract_with_arguments(w3, math_contract, transact, call, @@ -141,7 +141,7 @@ def test_transacting_with_contract_with_arguments(web3, func_args=transact_args, func_kwargs=transact_kwargs) - txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) + txn_receipt = w3.eth.wait_for_transaction_receipt(txn_hash) assert txn_receipt is not None final_value = call(contract=math_contract, @@ -150,41 +150,41 @@ def test_transacting_with_contract_with_arguments(web3, assert final_value - initial_value == 5 -def test_deploy_when_default_account_is_set(web3, +def test_deploy_when_default_account_is_set(w3, wait_for_transaction, STRING_CONTRACT): - web3.eth.default_account = web3.eth.accounts[1] - assert web3.eth.default_account is not empty + w3.eth.default_account = w3.eth.accounts[1] + assert w3.eth.default_account is not empty - StringContract = web3.eth.contract(**STRING_CONTRACT) + StringContract = w3.eth.contract(**STRING_CONTRACT) deploy_txn = StringContract.constructor("Caqalai").transact() - web3.eth.wait_for_transaction_receipt(deploy_txn) - txn_after = web3.eth.get_transaction(deploy_txn) - assert txn_after['from'] == web3.eth.default_account + w3.eth.wait_for_transaction_receipt(deploy_txn) + txn_after = w3.eth.get_transaction(deploy_txn) + assert txn_after['from'] == w3.eth.default_account -def test_transact_when_default_account_is_set(web3, +def test_transact_when_default_account_is_set(w3, wait_for_transaction, math_contract, transact): - web3.eth.default_account = web3.eth.accounts[1] - assert web3.eth.default_account is not empty + w3.eth.default_account = w3.eth.accounts[1] + assert w3.eth.default_account is not empty txn_hash = transact(contract=math_contract, contract_function='increment') - wait_for_transaction(web3, txn_hash) - txn_after = web3.eth.get_transaction(txn_hash) - assert txn_after['from'] == web3.eth.default_account + wait_for_transaction(w3, txn_hash) + txn_after = w3.eth.get_transaction(txn_hash) + assert txn_after['from'] == w3.eth.default_account -def test_transacting_with_contract_with_string_argument(web3, string_contract, transact, call): +def test_transacting_with_contract_with_string_argument(w3, string_contract, transact, call): # eth_abi will pass as raw bytes, no encoding # unless we encode ourselves txn_hash = transact(contract=string_contract, contract_function='setValue', func_args=["ÄLÄMÖLÖ".encode('utf8')]) - txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) + txn_receipt = w3.eth.wait_for_transaction_receipt(txn_hash) assert txn_receipt is not None final_value = call(contract=string_contract, @@ -193,7 +193,7 @@ def test_transacting_with_contract_with_string_argument(web3, string_contract, t assert final_value == "ÄLÄMÖLÖ" -def test_transacting_with_contract_with_bytes32_array_argument(web3, +def test_transacting_with_contract_with_bytes32_array_argument(w3, arrays_contract, transact, call): @@ -206,7 +206,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.wait_for_transaction_receipt(txn_hash) + txn_receipt = w3.eth.wait_for_transaction_receipt(txn_hash) assert txn_receipt is not None final_value = call(contract=arrays_contract, @@ -214,12 +214,12 @@ def test_transacting_with_contract_with_bytes32_array_argument(web3, assert final_value == new_bytes32_array -def test_transacting_with_contract_with_byte_array_argument(web3, arrays_contract, transact, call): +def test_transacting_with_contract_with_byte_array_argument(w3, arrays_contract, transact, call): new_byte_array = [b'\x03', b'\x03', b'\x03', b'\x03', b'\x03', b'\x03'] txn_hash = transact(contract=arrays_contract, contract_function='setByteValue', func_args=[new_byte_array]) - txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) + txn_receipt = w3.eth.wait_for_transaction_receipt(txn_hash) assert txn_receipt is not None final_value = call(contract=arrays_contract, @@ -227,20 +227,20 @@ def test_transacting_with_contract_with_byte_array_argument(web3, arrays_contrac assert final_value == new_byte_array -def test_transacting_with_contract_respects_explicit_gas(web3, +def test_transacting_with_contract_respects_explicit_gas(w3, STRING_CONTRACT, skip_if_testrpc, wait_for_block, call, transact): - skip_if_testrpc(web3) + skip_if_testrpc(w3) - wait_for_block(web3) + wait_for_block(w3) - StringContract = web3.eth.contract(**STRING_CONTRACT) + StringContract = w3.eth.contract(**STRING_CONTRACT) deploy_txn = StringContract.constructor("Caqalai").transact() - deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn, 30) + deploy_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn, 30) assert deploy_receipt is not None string_contract = StringContract(address=deploy_receipt['contractAddress']) @@ -250,31 +250,31 @@ 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.wait_for_transaction_receipt(txn_hash, 30) + txn_receipt = w3.eth.wait_for_transaction_receipt(txn_hash, 30) assert txn_receipt is not None final_value = call(contract=string_contract, contract_function='getValue') assert to_bytes(text=final_value) == to_bytes(text="ÄLÄMÖLÖ") - txn = web3.eth.get_transaction(txn_hash) + txn = w3.eth.get_transaction(txn_hash) assert txn['gas'] == 200000 -def test_auto_gas_computation_when_transacting(web3, +def test_auto_gas_computation_when_transacting(w3, STRING_CONTRACT, skip_if_testrpc, wait_for_block, call, transact): - skip_if_testrpc(web3) + skip_if_testrpc(w3) - wait_for_block(web3) + wait_for_block(w3) - StringContract = web3.eth.contract(**STRING_CONTRACT) + StringContract = w3.eth.contract(**STRING_CONTRACT) deploy_txn = StringContract.constructor("Caqalai").transact() - deploy_receipt = web3.eth.wait_for_transaction_receipt(deploy_txn, 30) + deploy_receipt = w3.eth.wait_for_transaction_receipt(deploy_txn, 30) assert deploy_receipt is not None string_contract = StringContract(address=deploy_receipt['contractAddress']) @@ -285,22 +285,22 @@ 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.wait_for_transaction_receipt(txn_hash, 30) + txn_receipt = w3.eth.wait_for_transaction_receipt(txn_hash, 30) assert txn_receipt is not None final_value = call(contract=string_contract, contract_function='getValue') assert to_bytes(text=final_value) == to_bytes(text="ÄLÄMÖLÖ") - txn = web3.eth.get_transaction(txn_hash) + txn = w3.eth.get_transaction(txn_hash) assert txn['gas'] == gas_estimate + 100000 -def test_fallback_transacting_with_contract(web3, fallback_function_contract, call): +def test_fallback_transacting_with_contract(w3, fallback_function_contract, call): initial_value = call(contract=fallback_function_contract, contract_function='getData') txn_hash = fallback_function_contract.fallback.transact() - txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) + txn_receipt = w3.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_contract_util_functions.py b/tests/core/contracts/test_contract_util_functions.py index 382a0e4d6f..af252824cb 100644 --- a/tests/core/contracts/test_contract_util_functions.py +++ b/tests/core/contracts/test_contract_util_functions.py @@ -8,6 +8,6 @@ # This test is necessary because transaction calls allow negative block indexes, although # get_block() does not allow negative block identifiers. Support for negative block identifier # will likely be removed in v5. -def test_parse_block_identifier_int(web3): - last_num = web3.eth.get_block('latest').number - assert 0 == parse_block_identifier_int(web3, -1 - last_num) +def test_parse_block_identifier_int(w3): + last_num = w3.eth.get_block('latest').number + assert 0 == parse_block_identifier_int(w3, -1 - last_num) diff --git a/tests/core/contracts/test_extracting_event_data.py b/tests/core/contracts/test_extracting_event_data.py index 3f80248f70..1d03a82848 100644 --- a/tests/core/contracts/test_extracting_event_data.py +++ b/tests/core/contracts/test_extracting_event_data.py @@ -24,18 +24,18 @@ @pytest.fixture() -def Emitter(web3, EMITTER): - return web3.eth.contract(**EMITTER) +def Emitter(w3, EMITTER): + return w3.eth.contract(**EMITTER) @pytest.fixture() -def emitter(web3, Emitter, wait_for_transaction, wait_for_block, address_conversion_func): - wait_for_block(web3) +def emitter(w3, Emitter, wait_for_transaction, wait_for_block, address_conversion_func): + wait_for_block(w3) deploy_txn_hash = Emitter.constructor().transact({'gas': 10000000}) - deploy_receipt = wait_for_transaction(web3, deploy_txn_hash) + deploy_receipt = wait_for_transaction(w3, deploy_txn_hash) contract_address = address_conversion_func(deploy_receipt['contractAddress']) - bytecode = web3.eth.get_code(contract_address) + bytecode = w3.eth.get_code(contract_address) assert bytecode == Emitter.bytecode_runtime _emitter = Emitter(address=contract_address) assert _emitter.address == contract_address @@ -43,26 +43,26 @@ def emitter(web3, Emitter, wait_for_transaction, wait_for_block, address_convers @pytest.fixture() -def EventContract(web3, EVENT_CONTRACT): - return web3.eth.contract(**EVENT_CONTRACT) +def EventContract(w3, EVENT_CONTRACT): + return w3.eth.contract(**EVENT_CONTRACT) @pytest.fixture() def event_contract( - web3, + w3, EventContract, wait_for_transaction, wait_for_block, address_conversion_func): - wait_for_block(web3) + wait_for_block(w3) deploy_txn_hash = EventContract.constructor().transact({ - 'from': web3.eth.coinbase, 'gas': 1000000 + 'from': w3.eth.coinbase, 'gas': 1000000 }) - deploy_receipt = wait_for_transaction(web3, deploy_txn_hash) + deploy_receipt = wait_for_transaction(w3, deploy_txn_hash) contract_address = address_conversion_func(deploy_receipt['contractAddress']) - bytecode = web3.eth.get_code(contract_address) + bytecode = w3.eth.get_code(contract_address) assert bytecode == EventContract.bytecode_runtime event_contract = EventContract(address=contract_address) assert event_contract.address == contract_address @@ -70,26 +70,26 @@ def event_contract( @pytest.fixture() -def IndexedEventContract(web3, INDEXED_EVENT_CONTRACT): - return web3.eth.contract(**INDEXED_EVENT_CONTRACT) +def IndexedEventContract(w3, INDEXED_EVENT_CONTRACT): + return w3.eth.contract(**INDEXED_EVENT_CONTRACT) @pytest.fixture() def indexed_event_contract( - web3, + w3, IndexedEventContract, wait_for_transaction, wait_for_block, address_conversion_func): - wait_for_block(web3) + wait_for_block(w3) deploy_txn_hash = IndexedEventContract.constructor().transact({ - 'from': web3.eth.coinbase, 'gas': 1000000 + 'from': w3.eth.coinbase, 'gas': 1000000 }) - deploy_receipt = wait_for_transaction(web3, deploy_txn_hash) + deploy_receipt = wait_for_transaction(w3, deploy_txn_hash) contract_address = address_conversion_func(deploy_receipt['contractAddress']) - bytecode = web3.eth.get_code(contract_address) + bytecode = w3.eth.get_code(contract_address) assert bytecode == IndexedEventContract.bytecode_runtime indexed_event_contract = IndexedEventContract(address=contract_address) assert indexed_event_contract.address == contract_address @@ -98,7 +98,7 @@ def indexed_event_contract( @pytest.fixture() def dup_txn_receipt( - web3, + w3, indexed_event_contract, wait_for_transaction, event_contract): @@ -106,11 +106,11 @@ def dup_txn_receipt( emitter_fn = indexed_event_contract.functions.logTwoEvents txn_hash = emitter_fn(12345).transact() - wait_for_transaction(web3, txn_hash) + wait_for_transaction(w3, txn_hash) event_contract_fn = event_contract.functions.logTwoEvents dup_txn_hash = event_contract_fn(12345).transact() - return wait_for_transaction(web3, dup_txn_hash) + return wait_for_transaction(w3, dup_txn_hash) @pytest.mark.parametrize( @@ -150,7 +150,7 @@ def dup_txn_receipt( ), ) ) -def test_event_data_extraction(web3, +def test_event_data_extraction(w3, emitter, wait_for_transaction, emitter_log_topics, @@ -162,7 +162,7 @@ def test_event_data_extraction(web3, emitter_fn = emitter.functions[contract_fn] event_id = getattr(emitter_event_ids, event_name) txn_hash = emitter_fn(event_id, *call_args).transact() - txn_receipt = wait_for_transaction(web3, txn_hash) + txn_receipt = wait_for_transaction(w3, txn_hash) assert len(txn_receipt['logs']) == 1 log_entry = txn_receipt['logs'][0] @@ -177,7 +177,7 @@ def test_event_data_extraction(web3, else: assert event_topic in log_entry['topics'] - event_data = get_event_data(web3.codec, event_abi, log_entry) + event_data = get_event_data(w3.codec, event_abi, log_entry) assert event_data['args'] == expected_args assert event_data['blockHash'] == txn_receipt['blockHash'] @@ -205,7 +205,7 @@ def test_event_data_extraction(web3, ), ) ) -def test_event_data_extraction_bytes(web3, +def test_event_data_extraction_bytes(w3, emitter, wait_for_transaction, emitter_log_topics, @@ -213,7 +213,7 @@ def test_event_data_extraction_bytes(web3, expected_args): emitter_fn = emitter.functions.logListArgs txn_hash = emitter_fn(*call_args).transact() - txn_receipt = wait_for_transaction(web3, txn_hash) + txn_receipt = wait_for_transaction(w3, txn_hash) assert len(txn_receipt['logs']) == 1 log_entry = txn_receipt['logs'][0] @@ -225,7 +225,7 @@ def test_event_data_extraction_bytes(web3, assert event_topic in log_entry['topics'] - event_data = get_event_data(web3.codec, event_abi, log_entry) + event_data = get_event_data(w3.codec, event_abi, log_entry) assert event_data['args'] == expected_args assert event_data['blockHash'] == txn_receipt['blockHash'] @@ -235,7 +235,7 @@ def test_event_data_extraction_bytes(web3, assert event_data['event'] == event_name -def test_event_data_extraction_bytes_with_warning(web3, +def test_event_data_extraction_bytes_with_warning(w3, emitter, wait_for_transaction, emitter_log_topics): @@ -244,7 +244,7 @@ def test_event_data_extraction_bytes_with_warning(web3, match='in v6 it will be invalid to pass a hex string without the "0x" prefix' ): txn_hash = emitter.functions.logListArgs(['13'], ['54']).transact() - txn_receipt = wait_for_transaction(web3, txn_hash) + txn_receipt = wait_for_transaction(w3, txn_hash) assert len(txn_receipt['logs']) == 1 log_entry = txn_receipt['logs'][0] @@ -256,7 +256,7 @@ def test_event_data_extraction_bytes_with_warning(web3, assert event_topic in log_entry['topics'] - event_data = get_event_data(web3.codec, event_abi, log_entry) + event_data = get_event_data(w3.codec, event_abi, log_entry) expected_args = { 'arg0': b']\x0b\xf6sp\xbe\xa2L\xa9is\xe4\xab\xb7\xfa+nVJpgt\xa7\x8f:\xa4\x9f\xdb\x93\xf0\x8f\xae', # noqa: E501 'arg1': [b'T\x00'] @@ -288,7 +288,7 @@ def test_event_data_extraction_bytes_strict_with_errors(strict_emitter, emitter_fn(*call_args).transact() -def test_dynamic_length_argument_extraction(web3, +def test_dynamic_length_argument_extraction(w3, emitter, wait_for_transaction, emitter_log_topics, @@ -296,7 +296,7 @@ def test_dynamic_length_argument_extraction(web3, string_0 = "this-is-the-first-string-which-exceeds-32-bytes-in-length" string_1 = "this-is-the-second-string-which-exceeds-32-bytes-in-length" txn_hash = emitter.functions.logDynamicArgs(string_0, string_1).transact() - txn_receipt = wait_for_transaction(web3, txn_hash) + txn_receipt = wait_for_transaction(w3, txn_hash) assert len(txn_receipt['logs']) == 1 log_entry = txn_receipt['logs'][0] @@ -306,10 +306,10 @@ def test_dynamic_length_argument_extraction(web3, event_topic = emitter_log_topics.LogDynamicArgs assert event_topic in log_entry['topics'] - string_0_topic = web3.keccak(text=string_0) + string_0_topic = w3.keccak(text=string_0) assert string_0_topic in log_entry['topics'] - event_data = get_event_data(web3.codec, event_abi, log_entry) + event_data = get_event_data(w3.codec, event_abi, log_entry) expected_args = { "arg0": string_0_topic, @@ -576,7 +576,7 @@ def test_argument_extraction_strict_bytes_types(w3_strict_abi, ) ) def test_event_rich_log( - web3, + w3, emitter, emitter_event_ids, wait_for_transaction, @@ -595,7 +595,7 @@ def test_event_rich_log( # Some tests do not rely on the event_id. Rather than changing this test too much, # bypass this here and just call the function with the provided args. txn_hash = emitter_fn(*call_args).transact() - txn_receipt = wait_for_transaction(web3, txn_hash) + txn_receipt = wait_for_transaction(w3, txn_hash) event_instance = emitter.events[event_name]() @@ -626,14 +626,14 @@ def test_event_rich_log( @pytest.mark.parametrize('process_receipt', (True, False)) def test_event_rich_log_with_byte_args( - web3, + w3, emitter, emitter_event_ids, wait_for_transaction, process_receipt): txn_hash = emitter.functions.logListArgs([b'13'], [b'54']).transact() - txn_receipt = wait_for_transaction(web3, txn_hash) + txn_receipt = wait_for_transaction(w3, txn_hash) event_instance = emitter.events.LogListArgs() @@ -662,7 +662,6 @@ def test_event_rich_log_with_byte_args( def test_receipt_processing_with_discard_flag( - web3, event_contract, indexed_event_contract, dup_txn_receipt, @@ -675,7 +674,6 @@ def test_receipt_processing_with_discard_flag( def test_receipt_processing_with_ignore_flag( - web3, event_contract, indexed_event_contract, dup_txn_receipt, @@ -704,7 +702,6 @@ def test_receipt_processing_with_ignore_flag( def test_receipt_processing_with_warn_flag( - web3, indexed_event_contract, dup_txn_receipt): @@ -716,7 +713,6 @@ def test_receipt_processing_with_warn_flag( def test_receipt_processing_with_strict_flag( - web3, indexed_event_contract, dup_txn_receipt): @@ -727,7 +723,6 @@ def test_receipt_processing_with_strict_flag( def test_receipt_processing_with_invalid_flag( - web3, indexed_event_contract, dup_txn_receipt): @@ -738,7 +733,6 @@ def test_receipt_processing_with_invalid_flag( def test_receipt_processing_with_no_flag( - web3, indexed_event_contract, dup_txn_receipt): @@ -750,7 +744,6 @@ def test_receipt_processing_with_no_flag( def test_single_log_processing_with_errors( - web3, indexed_event_contract, dup_txn_receipt): event_instance = indexed_event_contract.events.LogSingleWithIndex() @@ -759,12 +752,12 @@ def test_single_log_processing_with_errors( event_instance.processLog(dup_txn_receipt['logs'][0]) -def test_get_all_entries_with_nested_tuple_event(web3, emitter): +def test_get_all_entries_with_nested_tuple_event(w3, emitter): struct_args_filter = emitter.events.LogStructArgs.createFilter(fromBlock=0) tx_hash = emitter.functions.logStruct(1, (2, 3, (4, ))).transact({'gas': 100000}) - web3.eth.wait_for_transaction_receipt(tx_hash) - txn_receipt = web3.eth.get_transaction_receipt(tx_hash) + w3.eth.wait_for_transaction_receipt(tx_hash) + txn_receipt = w3.eth.get_transaction_receipt(tx_hash) entries = struct_args_filter.get_all_entries() diff --git a/tests/core/contracts/test_extracting_event_data_old.py b/tests/core/contracts/test_extracting_event_data_old.py index 1fae5c406d..14369dcc1a 100644 --- a/tests/core/contracts/test_extracting_event_data_old.py +++ b/tests/core/contracts/test_extracting_event_data_old.py @@ -10,18 +10,18 @@ @pytest.fixture() -def Emitter(web3, EMITTER): - return web3.eth.contract(**EMITTER) +def Emitter(w3, EMITTER): + return w3.eth.contract(**EMITTER) @pytest.fixture() -def emitter(web3, Emitter, wait_for_transaction, wait_for_block, address_conversion_func): - wait_for_block(web3) +def emitter(w3, Emitter, wait_for_transaction, wait_for_block, address_conversion_func): + wait_for_block(w3) deploy_txn_hash = Emitter.constructor().transact({'gas': 10000000}) - deploy_receipt = wait_for_transaction(web3, deploy_txn_hash) + deploy_receipt = wait_for_transaction(w3, deploy_txn_hash) contract_address = address_conversion_func(deploy_receipt['contractAddress']) - bytecode = web3.eth.get_code(contract_address) + bytecode = w3.eth.get_code(contract_address) assert bytecode == Emitter.bytecode_runtime _emitter = Emitter(address=contract_address) assert _emitter.address == contract_address @@ -65,7 +65,7 @@ def emitter(web3, Emitter, wait_for_transaction, wait_for_block, address_convers ), ) ) -def test_event_data_extraction(web3, +def test_event_data_extraction(w3, emitter, wait_for_transaction, emitter_log_topics, @@ -77,7 +77,7 @@ def test_event_data_extraction(web3, function = getattr(emitter.functions, contract_fn) event_id = getattr(emitter_event_ids, event_name) txn_hash = function(event_id, *call_args).transact() - txn_receipt = wait_for_transaction(web3, txn_hash) + txn_receipt = wait_for_transaction(w3, txn_hash) assert len(txn_receipt['logs']) == 1 log_entry = txn_receipt['logs'][0] @@ -92,7 +92,7 @@ def test_event_data_extraction(web3, else: assert event_topic in log_entry['topics'] - event_data = get_event_data(web3.codec, event_abi, log_entry) + event_data = get_event_data(w3.codec, event_abi, log_entry) assert event_data['args'] == expected_args assert event_data['blockHash'] == txn_receipt['blockHash'] @@ -102,7 +102,7 @@ def test_event_data_extraction(web3, assert event_data['event'] == event_name -def test_dynamic_length_argument_extraction(web3, +def test_dynamic_length_argument_extraction(w3, emitter, wait_for_transaction, emitter_log_topics, @@ -110,7 +110,7 @@ def test_dynamic_length_argument_extraction(web3, string_0 = "this-is-the-first-string-which-exceeds-32-bytes-in-length" string_1 = "this-is-the-second-string-which-exceeds-32-bytes-in-length" txn_hash = emitter.functions.logDynamicArgs(string_0, string_1).transact() - txn_receipt = wait_for_transaction(web3, txn_hash) + txn_receipt = wait_for_transaction(w3, txn_hash) assert len(txn_receipt['logs']) == 1 log_entry = txn_receipt['logs'][0] @@ -120,10 +120,10 @@ def test_dynamic_length_argument_extraction(web3, event_topic = emitter_log_topics.LogDynamicArgs assert event_topic in log_entry['topics'] - string_0_topic = web3.keccak(text=string_0) + string_0_topic = w3.keccak(text=string_0) assert string_0_topic in log_entry['topics'] - event_data = get_event_data(web3.codec, event_abi, log_entry) + event_data = get_event_data(w3.codec, event_abi, log_entry) expected_args = { "arg0": string_0_topic, diff --git a/tests/core/contracts/test_implicit_contract.py b/tests/core/contracts/test_implicit_contract.py index 6701c0f175..c1311fc191 100644 --- a/tests/core/contracts/test_implicit_contract.py +++ b/tests/core/contracts/test_implicit_contract.py @@ -10,20 +10,20 @@ @pytest.fixture() -def math_contract(web3, MATH_ABI, MATH_CODE, MATH_RUNTIME, address_conversion_func): +def math_contract(w3, MATH_ABI, MATH_CODE, MATH_RUNTIME, address_conversion_func): # Deploy math contract # NOTE Must use non-specialized contract factory or else deploy() doesn't work - MathContract = web3.eth.contract( + MathContract = w3.eth.contract( abi=MATH_ABI, bytecode=MATH_CODE, bytecode_runtime=MATH_RUNTIME, ) tx_hash = MathContract.constructor().transact() - tx_receipt = web3.eth.wait_for_transaction_receipt(tx_hash) + tx_receipt = w3.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? - MathContract = web3.eth.contract( + MathContract = w3.eth.contract( abi=MATH_ABI, bytecode=MATH_CODE, bytecode_runtime=MATH_RUNTIME, @@ -36,9 +36,9 @@ def math_contract(web3, MATH_ABI, MATH_CODE, MATH_RUNTIME, address_conversion_fu @pytest.fixture() -def get_transaction_count(web3): +def get_transaction_count(w3): def get_transaction_count(blocknum_or_label): - block = web3.eth.get_block(blocknum_or_label) + block = w3.eth.get_block(blocknum_or_label) # Return the blocknum if we requested this via labels # so we can directly query the block next time (using the same API call) # Either way, return the number of transactions in the given block @@ -62,7 +62,7 @@ def test_implicitcontract_call_default(math_contract, get_transaction_count): assert get_transaction_count("pending") == (blocknum, 0) -def test_implicitcontract_transact_default(web3, math_contract, get_transaction_count): +def test_implicitcontract_transact_default(math_contract, get_transaction_count): # Use to verify correct operation later on with pytest.warns(DeprecationWarning, match='deprecated in favor of classic contract syntax'): start_count = math_contract.counter() diff --git a/tests/core/eth-module/conftest.py b/tests/core/eth-module/conftest.py index 1da778510f..de445279c3 100644 --- a/tests/core/eth-module/conftest.py +++ b/tests/core/eth-module/conftest.py @@ -8,13 +8,13 @@ def account_password(): @pytest.fixture -def extra_accounts(web3, account_password): - num_accounts_to_create = 10 - len(web3.eth.accounts) +def extra_accounts(w3, account_password): + num_accounts_to_create = 10 - len(w3.eth.accounts) for i in range(num_accounts_to_create): - web3.personal.newAccount(account_password) + w3.personal.newAccount(account_password) - return web3.eth.accounts + return w3.eth.accounts CONTRACT_CODE = b"606060405261022e806100126000396000f360606040523615610074576000357c01000000000000000000000000000000000000000000000000000000009004806316216f391461007657806361bc221a146100995780637cf5dab0146100bc578063a5f3c23b146100e8578063d09de08a1461011d578063dcf537b11461014057610074565b005b610083600480505061016c565b6040518082815260200191505060405180910390f35b6100a6600480505061017f565b6040518082815260200191505060405180910390f35b6100d26004808035906020019091905050610188565b6040518082815260200191505060405180910390f35b61010760048080359060200190919080359060200190919050506101ea565b6040518082815260200191505060405180910390f35b61012a6004805050610201565b6040518082815260200191505060405180910390f35b6101566004808035906020019091905050610217565b6040518082815260200191505060405180910390f35b6000600d9050805080905061017c565b90565b60006000505481565b6000816000600082828250540192505081905550600060005054905080507f3496c3ede4ec3ab3686712aa1c238593ea6a42df83f98a5ec7df9834cfa577c5816040518082815260200191505060405180910390a18090506101e5565b919050565b6000818301905080508090506101fb565b92915050565b600061020d6001610188565b9050610214565b90565b60006007820290508050809050610229565b91905056" # noqa: E501 diff --git a/tests/core/eth-module/test_accounts.py b/tests/core/eth-module/test_accounts.py index 3c2056eb4a..34d24b086d 100644 --- a/tests/core/eth-module/test_accounts.py +++ b/tests/core/eth-module/test_accounts.py @@ -75,9 +75,9 @@ def web3js_password(): @pytest.fixture(params=['instance', 'class']) -def acct(request, web3): +def acct(request, w3): if request.param == 'instance': - return web3.eth.account + return w3.eth.account elif request.param == 'class': return Account raise Exception('Unreachable!') diff --git a/tests/core/eth-module/test_block_api.py b/tests/core/eth-module/test_block_api.py index 2ea7d0a8dc..c26b5a2e30 100644 --- a/tests/core/eth-module/test_block_api.py +++ b/tests/core/eth-module/test_block_api.py @@ -9,30 +9,30 @@ @pytest.fixture(autouse=True) -def wait_for_first_block(web3, wait_for_block): - wait_for_block(web3) +def wait_for_first_block(w3, wait_for_block): + wait_for_block(w3) -def test_uses_default_block(web3, extra_accounts, +def test_uses_default_block(w3, extra_accounts, wait_for_transaction): - assert(web3.eth.default_block == 'latest') - web3.eth.default_block = web3.eth.block_number - assert(web3.eth.default_block == web3.eth.block_number) + assert(w3.eth.default_block == 'latest') + w3.eth.default_block = w3.eth.block_number + assert(w3.eth.default_block == w3.eth.block_number) -def test_uses_defaultBlock_with_warning(web3, extra_accounts, +def test_uses_defaultBlock_with_warning(w3, extra_accounts, wait_for_transaction): with pytest.warns(DeprecationWarning): - assert web3.eth.defaultBlock == 'latest' + assert w3.eth.defaultBlock == 'latest' with pytest.warns(DeprecationWarning): - web3.eth.defaultBlock = web3.eth.block_number + w3.eth.defaultBlock = w3.eth.block_number with pytest.warns(DeprecationWarning): - assert(web3.eth.defaultBlock == web3.eth.block_number) + assert(w3.eth.defaultBlock == w3.eth.block_number) -def test_get_block_formatters_with_null_values(web3): +def test_get_block_formatters_with_null_values(w3): null_values_block = { 'baseFeePerGas': None, 'extraData': None, @@ -58,7 +58,7 @@ def test_get_block_formatters_with_null_values(web3): RPC.eth_getBlockByNumber: lambda *_: null_values_block, }) - web3.middleware_onion.inject(result_middleware, 'result_middleware', layer=0) + w3.middleware_onion.inject(result_middleware, 'result_middleware', layer=0) - received_block = web3.eth.get_block('pending') + received_block = w3.eth.get_block('pending') assert received_block == null_values_block diff --git a/tests/core/eth-module/test_default_account_api.py b/tests/core/eth-module/test_default_account_api.py index 6f544af8be..c8cf76bd52 100644 --- a/tests/core/eth-module/test_default_account_api.py +++ b/tests/core/eth-module/test_default_account_api.py @@ -2,75 +2,75 @@ @pytest.fixture(autouse=True) -def wait_for_first_block(web3, wait_for_block): - wait_for_block(web3) +def wait_for_first_block(w3, wait_for_block): + wait_for_block(w3) -def test_uses_default_account_when_set(web3, extra_accounts, +def test_uses_default_account_when_set(w3, extra_accounts, wait_for_transaction): - web3.eth.default_account = extra_accounts[2] - assert web3.eth.default_account == extra_accounts[2] + w3.eth.default_account = extra_accounts[2] + assert w3.eth.default_account == extra_accounts[2] - txn_hash = web3.eth.send_transaction({ + txn_hash = w3.eth.send_transaction({ "to": extra_accounts[1], "value": 1234, }) - wait_for_transaction(web3, txn_hash) + wait_for_transaction(w3, txn_hash) - txn = web3.eth.get_transaction(txn_hash) + txn = w3.eth.get_transaction(txn_hash) assert txn['from'] == extra_accounts[2] -def test_uses_defaultAccount_when_set_with_warning(web3, extra_accounts, +def test_uses_defaultAccount_when_set_with_warning(w3, extra_accounts, wait_for_transaction): with pytest.warns(DeprecationWarning): - web3.eth.defaultAccount = extra_accounts[2] + w3.eth.defaultAccount = extra_accounts[2] with pytest.warns(DeprecationWarning): - assert web3.eth.defaultAccount == extra_accounts[2] + assert w3.eth.defaultAccount == extra_accounts[2] - txn_hash = web3.eth.send_transaction({ + txn_hash = w3.eth.send_transaction({ "to": extra_accounts[1], "value": 1234, }) - wait_for_transaction(web3, txn_hash) + wait_for_transaction(w3, txn_hash) - txn = web3.eth.get_transaction(txn_hash) + txn = w3.eth.get_transaction(txn_hash) assert txn['from'] == extra_accounts[2] -def test_uses_given_from_address_when_provided(web3, extra_accounts, +def test_uses_given_from_address_when_provided(w3, extra_accounts, wait_for_transaction): - web3.eth.default_account = extra_accounts[2] - txn_hash = web3.eth.send_transaction({ + w3.eth.default_account = extra_accounts[2] + txn_hash = w3.eth.send_transaction({ "from": extra_accounts[5], "to": extra_accounts[1], "value": 1234, }) - wait_for_transaction(web3, txn_hash) + wait_for_transaction(w3, txn_hash) - txn = web3.eth.get_transaction(txn_hash) + txn = w3.eth.get_transaction(txn_hash) assert txn['from'] == extra_accounts[5] -def test_uses_given_from_address_when_provided_with_warning(web3, extra_accounts, +def test_uses_given_from_address_when_provided_with_warning(w3, extra_accounts, wait_for_transaction): with pytest.warns(DeprecationWarning): - web3.eth.defaultAccount = extra_accounts[2] + w3.eth.defaultAccount = extra_accounts[2] with pytest.warns(DeprecationWarning): - assert web3.eth.defaultAccount == extra_accounts[2] + assert w3.eth.defaultAccount == extra_accounts[2] - txn_hash = web3.eth.send_transaction({ + txn_hash = w3.eth.send_transaction({ "from": extra_accounts[5], "to": extra_accounts[1], "value": 1234, }) - wait_for_transaction(web3, txn_hash) + wait_for_transaction(w3, txn_hash) - txn = web3.eth.get_transaction(txn_hash) + txn = w3.eth.get_transaction(txn_hash) assert txn['from'] == extra_accounts[5] diff --git a/tests/core/eth-module/test_eth_contract.py b/tests/core/eth-module/test_eth_contract.py index 50a2ed9e46..fdb0a4f7e2 100644 --- a/tests/core/eth-module/test_eth_contract.py +++ b/tests/core/eth-module/test_eth_contract.py @@ -26,18 +26,18 @@ ((), {'address': NON_CHECKSUM_ADDRESS}, ValueError), ) ) -def test_contract_address_validation(web3, args, kwargs, expected): +def test_contract_address_validation(w3, args, kwargs, expected): if isinstance(expected, type) and issubclass(expected, Exception): with pytest.raises(expected): - web3.eth.contract(*args, **kwargs) + w3.eth.contract(*args, **kwargs) return # run without errors - web3.eth.contract(*args, **kwargs) + w3.eth.contract(*args, **kwargs) -def test_set_contract_factory(web3): +def test_set_contract_factory(w3): factoryClass = Mock() - web3.eth.set_contract_factory(factoryClass) - web3.eth.contract(contract_name='myname') - factoryClass.factory.assert_called_once_with(web3, contract_name='myname') + w3.eth.set_contract_factory(factoryClass) + w3.eth.contract(contract_name='myname') + factoryClass.factory.assert_called_once_with(w3, contract_name='myname') diff --git a/tests/core/eth-module/test_eth_mining.py b/tests/core/eth-module/test_eth_mining.py index cd4f831eb9..9daf8205ba 100644 --- a/tests/core/eth-module/test_eth_mining.py +++ b/tests/core/eth-module/test_eth_mining.py @@ -1,9 +1,9 @@ -def test_mining_property_tester(web3): - assert web3.eth.mining is False +def test_mining_property_tester(w3): + assert w3.eth.mining is False -def test_mining_property_ipc_and_rpc(web3, wait_for_miner_start, skip_if_testrpc): - skip_if_testrpc(web3) +def test_mining_property_ipc_and_rpc(w3, wait_for_miner_start, skip_if_testrpc): + skip_if_testrpc(w3) - wait_for_miner_start(web3) - assert web3.eth.mining is True + wait_for_miner_start(w3) + assert w3.eth.mining is True diff --git a/tests/core/eth-module/test_eth_properties.py b/tests/core/eth-module/test_eth_properties.py index 596a853539..9f89391ad6 100644 --- a/tests/core/eth-module/test_eth_properties.py +++ b/tests/core/eth-module/test_eth_properties.py @@ -1,19 +1,19 @@ import pytest -def test_eth_protocol_version(web3): - assert web3.eth.protocol_version == '63' +def test_eth_protocol_version(w3): + assert w3.eth.protocol_version == '63' -def test_eth_protocolVersion(web3): +def test_eth_protocolVersion(w3): with pytest.warns(DeprecationWarning): - assert web3.eth.protocolVersion == '63' + assert w3.eth.protocolVersion == '63' -def test_eth_chain_id(web3): - assert web3.eth.chain_id == 61 +def test_eth_chain_id(w3): + assert w3.eth.chain_id == 61 -def test_eth_chainId(web3): +def test_eth_chainId(w3): with pytest.warns(DeprecationWarning): - assert web3.eth.chainId == 61 + assert w3.eth.chainId == 61 diff --git a/tests/core/eth-module/test_gas_pricing.py b/tests/core/eth-module/test_gas_pricing.py index b93d668a2b..abecffd20c 100644 --- a/tests/core/eth-module/test_gas_pricing.py +++ b/tests/core/eth-module/test_gas_pricing.py @@ -4,48 +4,48 @@ ) -def test_get_set_gas_price(web3): - assert web3.eth.gas_price > 0 +def test_get_set_gas_price(w3): + assert w3.eth.gas_price > 0 -def test_get_set_gasPrice(web3): +def test_get_set_gasPrice(w3): with pytest.warns(DeprecationWarning): - assert web3.eth.gasPrice > 0 + assert w3.eth.gasPrice > 0 -def test_no_gas_price_strategy_returns_none(web3): - assert web3.eth.generate_gas_price() is None +def test_no_gas_price_strategy_returns_none(w3): + assert w3.eth.generate_gas_price() is None -def test_generateGasPrice_deprecated(web3): +def test_generateGasPrice_deprecated(w3): with pytest.warns(DeprecationWarning, match='generateGasPrice is deprecated in favor of generate_gas_price'): - gas_price = web3.eth.generateGasPrice() + gas_price = w3.eth.generateGasPrice() assert gas_price is None -def test_set_gas_price_strategy(web3): - def my_gas_price_strategy(web3, transaction_params): +def test_set_gas_price_strategy(w3): + def my_gas_price_strategy(w3, transaction_params): return 5 - web3.eth.set_gas_price_strategy(my_gas_price_strategy) - assert web3.eth.generate_gas_price() == 5 + w3.eth.set_gas_price_strategy(my_gas_price_strategy) + assert w3.eth.generate_gas_price() == 5 -def test_setGasPriceStrategy_deprecated(web3): +def test_setGasPriceStrategy_deprecated(w3): my_gas_price_strategy = Mock(return_value=5) with pytest.warns(DeprecationWarning, match="setGasPriceStrategy is deprecated in favor of " "set_gas_price_strategy"): - web3.eth.setGasPriceStrategy(my_gas_price_strategy) - assert web3.eth.generate_gas_price() == 5 + w3.eth.setGasPriceStrategy(my_gas_price_strategy) + assert w3.eth.generate_gas_price() == 5 -def test_gas_price_strategy_calls(web3): +def test_gas_price_strategy_calls(w3): transaction = { 'to': '0x0', 'value': 1000000000 } my_gas_price_strategy = Mock(return_value=5) - web3.eth.set_gas_price_strategy(my_gas_price_strategy) - assert web3.eth.generate_gas_price(transaction) == 5 - my_gas_price_strategy.assert_called_once_with(web3, transaction) + w3.eth.set_gas_price_strategy(my_gas_price_strategy) + assert w3.eth.generate_gas_price(transaction) == 5 + my_gas_price_strategy.assert_called_once_with(w3, transaction) diff --git a/tests/core/eth-module/test_iban.py b/tests/core/eth-module/test_iban.py index 7e4068cea6..71580bb5a3 100644 --- a/tests/core/eth-module/test_iban.py +++ b/tests/core/eth-module/test_iban.py @@ -14,8 +14,8 @@ ), ) ) -def test_createIndirect(value, expected, web3): - actual = web3.eth.iban.createIndirect(value).toString() +def test_createIndirect(value, expected, w3): + actual = w3.eth.iban.createIndirect(value).toString() assert actual == expected @@ -56,14 +56,14 @@ def test_createIndirect(value, expected, web3): ), ), ) -def test_fromAddress(value, expected, web3): +def test_fromAddress(value, expected, w3): if isinstance(expected, type) and issubclass(expected, Exception): with pytest.raises(expected): - web3.eth.iban.fromAddress(value).toString() + w3.eth.iban.fromAddress(value).toString() return - actual = web3.eth.iban.fromAddress(value).toString() + actual = w3.eth.iban.fromAddress(value).toString() assert actual == expected @@ -140,11 +140,11 @@ def test_fromAddress(value, expected, web3): ), ), ) -def test_isValid(value, expected, web3): - actual = web3.eth.iban.isValid(value) +def test_isValid(value, expected, w3): + actual = w3.eth.iban.isValid(value) assert actual is expected - iban = web3.eth.iban(value) + iban = w3.eth.iban(value) assert iban.isValid() is expected @@ -157,6 +157,6 @@ def test_isValid(value, expected, web3): ), ) ) -def test_toAddress(value, expected, web3): - actual = web3.eth.iban(value).address() +def test_toAddress(value, expected, w3): + actual = w3.eth.iban(value).address() assert actual == expected diff --git a/tests/core/eth-module/test_poa.py b/tests/core/eth-module/test_poa.py index 8be9346dfe..ecb60f84d0 100644 --- a/tests/core/eth-module/test_poa.py +++ b/tests/core/eth-module/test_poa.py @@ -11,40 +11,40 @@ # In the spec, a block with extra data longer than 32 bytes is invalid -def test_long_extra_data(web3): +def test_long_extra_data(w3): return_block_with_long_extra_data = construct_fixture_middleware({ 'eth_getBlockByNumber': {'extraData': '0x' + 'ff' * 33}, }) - web3.middleware_onion.inject(return_block_with_long_extra_data, layer=0) + w3.middleware_onion.inject(return_block_with_long_extra_data, layer=0) with pytest.raises(ExtraDataLengthError): - web3.eth.get_block('latest') + w3.eth.get_block('latest') -def test_full_extra_data(web3): +def test_full_extra_data(w3): return_block_with_long_extra_data = construct_fixture_middleware({ 'eth_getBlockByNumber': {'extraData': '0x' + 'ff' * 32}, }) - web3.middleware_onion.inject(return_block_with_long_extra_data, layer=0) - block = web3.eth.get_block('latest') + w3.middleware_onion.inject(return_block_with_long_extra_data, layer=0) + block = w3.eth.get_block('latest') assert block.extraData == b'\xff' * 32 -def test_geth_proof_of_authority(web3): +def test_geth_proof_of_authority(w3): return_block_with_long_extra_data = construct_fixture_middleware({ 'eth_getBlockByNumber': {'extraData': '0x' + 'ff' * 33}, }) - web3.middleware_onion.inject(geth_poa_middleware, layer=0) - web3.middleware_onion.inject(return_block_with_long_extra_data, layer=0) - block = web3.eth.get_block('latest') + w3.middleware_onion.inject(geth_poa_middleware, layer=0) + w3.middleware_onion.inject(return_block_with_long_extra_data, layer=0) + block = w3.eth.get_block('latest') assert 'extraData' not in block assert block.proofOfAuthorityData == b'\xff' * 33 -def test_returns_none_response(web3): +def test_returns_none_response(w3): return_none_response = construct_fixture_middleware({ 'eth_getBlockByNumber': None, }) - web3.middleware_onion.inject(geth_poa_middleware, layer=0) - web3.middleware_onion.inject(return_none_response, layer=0) + w3.middleware_onion.inject(geth_poa_middleware, layer=0) + w3.middleware_onion.inject(return_none_response, layer=0) with pytest.raises(BlockNotFound): - web3.eth.get_block(100000000000) + w3.eth.get_block(100000000000) diff --git a/tests/core/eth-module/test_transactions.py b/tests/core/eth-module/test_transactions.py index 5e8c5c7493..9dbfd087f1 100644 --- a/tests/core/eth-module/test_transactions.py +++ b/tests/core/eth-module/test_transactions.py @@ -58,12 +58,12 @@ 'storage_keys_dynamic_fee_txn', ], ) -def test_eth_tester_send_transaction_validation(web3, transaction): +def test_eth_tester_send_transaction_validation(w3, transaction): # Test that eth-tester transaction param validation does not throw for properly formatted # transactions. This is especially important because we have key mapping differences # (camelCase to snake_case) mitigated by providers/eth-tester/middleware. - txn_hash = web3.eth.send_transaction(transaction) - receipt = web3.eth.wait_for_transaction_receipt(txn_hash, timeout=RECEIPT_TIMEOUT) + txn_hash = w3.eth.send_transaction(transaction) + receipt = w3.eth.wait_for_transaction_receipt(txn_hash, timeout=RECEIPT_TIMEOUT) assert receipt.get('blockNumber') is not None @@ -71,27 +71,27 @@ def test_eth_tester_send_transaction_validation(web3, transaction): 'make_chain_id, expect_success', ( ( - lambda web3: web3.eth.chain_id, + lambda w3: w3.eth.chain_id, True, ), pytest.param( - lambda web3: 999999999999, + lambda w3: 999999999999, False, ), ), ) -def test_send_transaction_with_valid_chain_id(web3, make_chain_id, expect_success): +def test_send_transaction_with_valid_chain_id(w3, make_chain_id, expect_success): transaction = { - 'to': web3.eth.accounts[1], - 'chainId': make_chain_id(web3), + 'to': w3.eth.accounts[1], + 'chainId': make_chain_id(w3), } if expect_success: - txn_hash = web3.eth.send_transaction(transaction) - receipt = web3.eth.wait_for_transaction_receipt(txn_hash, timeout=RECEIPT_TIMEOUT) + txn_hash = w3.eth.send_transaction(transaction) + receipt = w3.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: - web3.eth.send_transaction(transaction) + w3.eth.send_transaction(transaction) assert 'chain ID' in str(exc_info.value) @@ -109,57 +109,57 @@ def test_send_transaction_with_valid_chain_id(web3, make_chain_id, expect_succes ), ) ) -def test_send_transaction_with_invalid_ens_names(web3, to, _from): - with ens_addresses(web3, [ - ('registered-name-1.eth', web3.eth.accounts[1]), +def test_send_transaction_with_invalid_ens_names(w3, to, _from): + with ens_addresses(w3, [ + ('registered-name-1.eth', w3.eth.accounts[1]), ]): transaction = { 'to': to, - 'chainId': web3.eth.chain_id, + 'chainId': w3.eth.chain_id, 'from': _from, } with pytest.raises(NameNotFound): - web3.eth.send_transaction(transaction) + w3.eth.send_transaction(transaction) -def test_send_transaction_with_ens_names(web3): - with ens_addresses(web3, [ - ('registered-name-1.eth', web3.eth.accounts[1]), - ('registered-name-2.eth', web3.eth.accounts[0]) +def test_send_transaction_with_ens_names(w3): + with ens_addresses(w3, [ + ('registered-name-1.eth', w3.eth.accounts[1]), + ('registered-name-2.eth', w3.eth.accounts[0]) ]): transaction = { 'to': 'registered-name-1.eth', - 'chainId': web3.eth.chain_id, + 'chainId': w3.eth.chain_id, 'from': 'registered-name-2.eth', } - txn_hash = web3.eth.send_transaction(transaction) - receipt = web3.eth.wait_for_transaction_receipt(txn_hash, timeout=RECEIPT_TIMEOUT) + txn_hash = w3.eth.send_transaction(transaction) + receipt = w3.eth.wait_for_transaction_receipt(txn_hash, timeout=RECEIPT_TIMEOUT) assert receipt.get('blockNumber') is not None -def test_wait_for_missing_receipt(web3): +def test_wait_for_missing_receipt(w3): with pytest.raises(TimeExhausted): - web3.eth.wait_for_transaction_receipt(b'\0' * 32, timeout=RECEIPT_TIMEOUT) + w3.eth.wait_for_transaction_receipt(b'\0' * 32, timeout=RECEIPT_TIMEOUT) -def test_passing_string_to_to_hex(web3): +def test_passing_string_to_to_hex(w3): with pytest.raises(TimeExhausted): transaction_hash = '0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060' - web3.eth.wait_for_transaction_receipt(transaction_hash, timeout=RECEIPT_TIMEOUT) + w3.eth.wait_for_transaction_receipt(transaction_hash, timeout=RECEIPT_TIMEOUT) -def test_unmined_transaction_wait_for_receipt(web3): - web3.middleware_onion.add(unmined_receipt_simulator_middleware) - txn_hash = web3.eth.send_transaction({ - 'from': web3.eth.coinbase, +def test_unmined_transaction_wait_for_receipt(w3): + w3.middleware_onion.add(unmined_receipt_simulator_middleware) + txn_hash = w3.eth.send_transaction({ + 'from': w3.eth.coinbase, 'to': '0xd3CdA913deB6f67967B99D67aCDFa1712C293601', 'value': 123457 }) with pytest.raises(TransactionNotFound): - web3.eth.get_transaction_receipt(txn_hash) + w3.eth.get_transaction_receipt(txn_hash) - txn_receipt = web3.eth.wait_for_transaction_receipt(txn_hash) + txn_receipt = w3.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/filtering/conftest.py b/tests/core/filtering/conftest.py index cce7d08c95..35e579df1e 100644 --- a/tests/core/filtering/conftest.py +++ b/tests/core/filtering/conftest.py @@ -25,7 +25,7 @@ scope='function', params=[True, False], ids=["local_filter_middleware", "node_based_filter"]) -def web3(request): +def w3(request): use_filter_middleware = request.param provider = EthereumTesterProvider() w3 = Web3(provider) @@ -35,8 +35,8 @@ def web3(request): @pytest.fixture(autouse=True) -def wait_for_mining_start(web3, wait_for_block): - wait_for_block(web3) +def wait_for_mining_start(w3, wait_for_block): + wait_for_block(w3) @pytest.fixture() @@ -66,18 +66,18 @@ def EMITTER(EMITTER_CODE, @pytest.fixture() -def Emitter(web3, EMITTER): - return web3.eth.contract(**EMITTER) +def Emitter(w3, EMITTER): + return w3.eth.contract(**EMITTER) @pytest.fixture() -def emitter(web3, Emitter, wait_for_transaction, wait_for_block, address_conversion_func): - wait_for_block(web3) +def emitter(w3, Emitter, wait_for_transaction, wait_for_block, address_conversion_func): + wait_for_block(w3) deploy_txn_hash = Emitter.constructor().transact({'gas': 10000000}) - deploy_receipt = wait_for_transaction(web3, deploy_txn_hash) + deploy_receipt = wait_for_transaction(w3, deploy_txn_hash) contract_address = address_conversion_func(deploy_receipt['contractAddress']) - bytecode = web3.eth.get_code(contract_address) + bytecode = w3.eth.get_code(contract_address) assert bytecode == Emitter.bytecode_runtime _emitter = Emitter(address=contract_address) assert _emitter.address == contract_address diff --git a/tests/core/filtering/test_basic_filter_tests.py b/tests/core/filtering/test_basic_filter_tests.py index c9309d909f..3a0d267502 100644 --- a/tests/core/filtering/test_basic_filter_tests.py +++ b/tests/core/filtering/test_basic_filter_tests.py @@ -1,40 +1,40 @@ def test_filtering_sequential_blocks_with_bounded_range( - web3, + w3, emitter, Emitter, wait_for_transaction): builder = emitter.events.LogNoArguments.build_filter() builder.fromBlock = "latest" - initial_block_number = web3.eth.block_number + initial_block_number = w3.eth.block_number builder.toBlock = initial_block_number + 100 - filter_ = builder.deploy(web3) + filter_ = builder.deploy(w3) for i in range(100): emitter.functions.logNoArgs(which=1).transact() - assert web3.eth.block_number == initial_block_number + 100 + assert w3.eth.block_number == initial_block_number + 100 assert len(filter_.get_new_entries()) == 100 def test_filtering_starting_block_range( - web3, + w3, emitter, Emitter, wait_for_transaction): for i in range(10): emitter.functions.logNoArgs(which=1).transact() builder = emitter.events.LogNoArguments.build_filter() - filter_ = builder.deploy(web3) - initial_block_number = web3.eth.block_number + filter_ = builder.deploy(w3) + initial_block_number = w3.eth.block_number for i in range(10): emitter.functions.logNoArgs(which=1).transact() - assert web3.eth.block_number == initial_block_number + 10 + assert w3.eth.block_number == initial_block_number + 10 assert len(filter_.get_new_entries()) == 10 -def test_requesting_results_with_no_new_blocks(web3, emitter): +def test_requesting_results_with_no_new_blocks(w3, emitter): builder = emitter.events.LogNoArguments.build_filter() - filter_ = builder.deploy(web3) + filter_ = builder.deploy(w3) assert len(filter_.get_new_entries()) == 0 diff --git a/tests/core/filtering/test_contract_createFilter_topic_merging.py b/tests/core/filtering/test_contract_createFilter_topic_merging.py index 61ed78c173..711b66c308 100644 --- a/tests/core/filtering/test_contract_createFilter_topic_merging.py +++ b/tests/core/filtering/test_contract_createFilter_topic_merging.py @@ -1,11 +1,7 @@ import pytest -def test_merged_topic_list_event( - web3, - emitter, - emitter_event_ids, - wait_for_transaction): +def test_merged_topic_list_event(emitter): manual_topics = [ '0xf16c999b533366ca5138d78e85da51611089cd05749f098d6c225d4cd42ee6ec', # event sig '0x0000000000000000000000000000000000000000000000000000000000000457', # 1111 diff --git a/tests/core/filtering/test_contract_data_filters.py b/tests/core/filtering/test_contract_data_filters.py index 6efb78c724..4c2f5eeafe 100644 --- a/tests/core/filtering/test_contract_data_filters.py +++ b/tests/core/filtering/test_contract_data_filters.py @@ -24,7 +24,7 @@ scope="module", params=[True, False], ids=["local_filter_middleware", "node_based_filter"]) -def web3(request): +def w3(request): use_filter_middleware = request.param provider = EthereumTesterProvider() w3 = Web3(provider) @@ -60,18 +60,18 @@ def EMITTER(EMITTER_CODE, @pytest.fixture(scope="module") -def Emitter(web3, EMITTER): - return web3.eth.contract(**EMITTER) +def Emitter(w3, EMITTER): + return w3.eth.contract(**EMITTER) @pytest.fixture(scope="module") -def emitter(web3, Emitter, wait_for_transaction, wait_for_block, address_conversion_func): - wait_for_block(web3) +def emitter(w3, Emitter, wait_for_transaction, wait_for_block, address_conversion_func): + wait_for_block(w3) deploy_txn_hash = Emitter.constructor().transact({'gas': 10000000}) - deploy_receipt = wait_for_transaction(web3, deploy_txn_hash) + deploy_receipt = wait_for_transaction(w3, deploy_txn_hash) contract_address = address_conversion_func(deploy_receipt['contractAddress']) - bytecode = web3.eth.get_code(contract_address) + bytecode = w3.eth.get_code(contract_address) assert bytecode == Emitter.bytecode_runtime _emitter = Emitter(address=contract_address) assert _emitter.address == contract_address @@ -131,7 +131,7 @@ def array_values(draw): @given(vals=dynamic_values()) @settings(max_examples=5, deadline=None) def test_data_filters_with_dynamic_arguments( - web3, + w3, wait_for_transaction, create_filter, emitter, @@ -140,7 +140,7 @@ def test_data_filters_with_dynamic_arguments( if api_style == 'build_filter': filter_builder = emitter.events.LogDynamicArgs.build_filter() filter_builder.args['arg1'].match_single(vals['matching']) - event_filter = filter_builder.deploy(web3) + event_filter = filter_builder.deploy(w3) else: event_filter = create_filter(emitter, [ 'LogDynamicArgs', { @@ -157,7 +157,7 @@ def test_data_filters_with_dynamic_arguments( ] for txn_hash in txn_hashes: - wait_for_transaction(web3, txn_hash) + wait_for_transaction(w3, txn_hash) log_entries = event_filter.get_new_entries() assert len(log_entries) == 1 @@ -168,7 +168,7 @@ def test_data_filters_with_dynamic_arguments( @given(vals=fixed_values()) @settings(max_examples=5, deadline=None) def test_data_filters_with_fixed_arguments( - web3, + w3, emitter, wait_for_transaction, create_filter, @@ -181,7 +181,7 @@ def test_data_filters_with_fixed_arguments( filter_builder.args['arg1'].match_single(vals['matching'][1]) filter_builder.args['arg2'].match_single(vals['matching'][2]) filter_builder.args['arg3'].match_single(vals['matching'][3]) - event_filter = filter_builder.deploy(web3) + event_filter = filter_builder.deploy(w3) else: event_filter = create_filter(emitter, [ 'LogQuadrupleArg', { @@ -210,7 +210,7 @@ def test_data_filters_with_fixed_arguments( })) for txn_hash in txn_hashes: - wait_for_transaction(web3, txn_hash) + wait_for_transaction(w3, txn_hash) log_entries = event_filter.get_new_entries() assert len(log_entries) == 1 @@ -222,7 +222,7 @@ def test_data_filters_with_fixed_arguments( @given(vals=array_values()) @settings(max_examples=5, deadline=None) def test_data_filters_with_list_arguments( - web3, + w3, emitter, wait_for_transaction, call_as_instance, @@ -235,7 +235,7 @@ def test_data_filters_with_list_arguments( if api_style == 'build_filter': filter_builder = emitter.events.LogListArgs.build_filter() filter_builder.args['arg1'].match_single(matching) - event_filter = filter_builder.deploy(web3) + event_filter = filter_builder.deploy(w3) txn_hashes = [] txn_hashes.append(emitter.functions.logListArgs( @@ -252,7 +252,7 @@ def test_data_filters_with_list_arguments( arg1=non_matching).transact({'maxFeePerGas': 10 ** 9, 'maxPriorityFeePerGas': 10 ** 9})) for txn_hash in txn_hashes: - wait_for_transaction(web3, txn_hash) + wait_for_transaction(w3, txn_hash) log_entries = event_filter.get_new_entries() assert len(log_entries) == 2 diff --git a/tests/core/filtering/test_contract_getLogs.py b/tests/core/filtering/test_contract_getLogs.py index 8badd8ca00..ac9b30ca18 100644 --- a/tests/core/filtering/test_contract_getLogs.py +++ b/tests/core/filtering/test_contract_getLogs.py @@ -10,7 +10,7 @@ def test_contract_get_available_events( def test_contract_getLogs_all( - web3, + w3, emitter, wait_for_transaction, emitter_event_ids, @@ -19,7 +19,7 @@ def test_contract_getLogs_all( event_id = emitter_event_ids.LogNoArguments txn_hash = contract.functions.logNoArgs(event_id).transact() - wait_for_transaction(web3, txn_hash) + wait_for_transaction(w3, txn_hash) log_entries = list(contract.events.LogNoArguments.getLogs()) assert len(log_entries) == 1 @@ -27,7 +27,7 @@ def test_contract_getLogs_all( def test_contract_getLogs_range( - web3, + w3, emitter, wait_for_transaction, emitter_event_ids, @@ -35,11 +35,11 @@ def test_contract_getLogs_range( contract = emitter event_id = emitter_event_ids.LogNoArguments - assert web3.eth.block_number == 2 + assert w3.eth.block_number == 2 txn_hash = contract.functions.logNoArgs(event_id).transact() # Mined as block 3 - wait_for_transaction(web3, txn_hash) - assert web3.eth.block_number == 3 + wait_for_transaction(w3, txn_hash) + assert w3.eth.block_number == 3 log_entries = list(contract.events.LogNoArguments.getLogs()) assert len(log_entries) == 1 @@ -52,7 +52,7 @@ def test_contract_getLogs_range( def test_contract_getLogs_argument_filter( - web3, + w3, emitter, wait_for_transaction, emitter_event_ids): @@ -77,7 +77,7 @@ def test_contract_getLogs_argument_filter( emitter.functions.logTriple(event_id, 1, 3, 1).transact() ) for txn_hash in txn_hashes: - wait_for_transaction(web3, txn_hash) + wait_for_transaction(w3, txn_hash) all_logs = contract.events.LogTripleWithIndex.getLogs(fromBlock=1) assert len(all_logs) == 4 diff --git a/tests/core/filtering/test_contract_on_event_filtering.py b/tests/core/filtering/test_contract_on_event_filtering.py index 9c2174d153..5828ffe49a 100644 --- a/tests/core/filtering/test_contract_on_event_filtering.py +++ b/tests/core/filtering/test_contract_on_event_filtering.py @@ -6,7 +6,7 @@ @pytest.mark.parametrize('call_as_instance', (True, False)) -def test_create_filter_address_parameter(web3, emitter, Emitter, call_as_instance): +def test_create_filter_address_parameter(emitter, Emitter, call_as_instance): if call_as_instance: event_filter = emitter.events.LogNoArguments.createFilter(fromBlock="latest") else: @@ -23,7 +23,7 @@ def test_create_filter_address_parameter(web3, emitter, Emitter, call_as_instanc @pytest.mark.parametrize('call_as_instance', (True, False)) @pytest.mark.parametrize('api_style', ('v4', 'build_filter')) def test_on_filter_using_get_entries_interface( - web3, + w3, emitter, Emitter, wait_for_transaction, @@ -38,12 +38,12 @@ def test_on_filter_using_get_entries_interface( contract = Emitter if api_style == 'build_filter': - event_filter = contract.events.LogNoArguments.build_filter().deploy(web3) + event_filter = contract.events.LogNoArguments.build_filter().deploy(w3) else: event_filter = create_filter(emitter, ['LogNoArguments', {}]) txn_hash = emitter.functions.logNoArgs(emitter_event_ids.LogNoArguments).transact() - wait_for_transaction(web3, txn_hash) + wait_for_transaction(w3, txn_hash) log_entries = event_filter.get_new_entries() assert len(log_entries) == 1 @@ -57,7 +57,7 @@ def test_on_filter_using_get_entries_interface( @pytest.mark.parametrize('call_as_instance', (True, False)) @pytest.mark.parametrize('api_style', ('v4', 'build_filter')) def test_on_sync_filter_with_event_name_and_single_argument( - web3, + w3, emitter, Emitter, wait_for_transaction, @@ -74,7 +74,7 @@ def test_on_sync_filter_with_event_name_and_single_argument( if api_style == 'build_filter': builder = contract.events.LogTripleWithIndex.build_filter() builder.args['arg1'].match_single(2) - event_filter = builder.deploy(web3) + event_filter = builder.deploy(w3) else: event_filter = create_filter(contract, ['LogTripleWithIndex', {'filter': { 'arg1': 2, @@ -92,7 +92,7 @@ def test_on_sync_filter_with_event_name_and_single_argument( emitter.functions.logTriple(event_id, 12345, 2, 54321).transact() ) for txn_hash in txn_hashes: - wait_for_transaction(web3, txn_hash) + wait_for_transaction(w3, txn_hash) seen_logs = event_filter.get_new_entries() assert len(seen_logs) == 2 @@ -102,7 +102,7 @@ def test_on_sync_filter_with_event_name_and_single_argument( @pytest.mark.parametrize('call_as_instance', (True, False)) @pytest.mark.parametrize('api_style', ('v4', 'build_filter')) def test_on_sync_filter_with_event_name_and_non_indexed_argument( - web3, + w3, emitter, Emitter, wait_for_transaction, @@ -120,7 +120,7 @@ def test_on_sync_filter_with_event_name_and_non_indexed_argument( builder = contract.events.LogTripleWithIndex.build_filter() builder.args['arg0'].match_single(1) builder.args['arg1'].match_single(2) - event_filter = builder.deploy(web3) + event_filter = builder.deploy(w3) else: event_filter = create_filter(contract, ['LogTripleWithIndex', {'filter': { 'arg0': 1, @@ -139,7 +139,7 @@ def test_on_sync_filter_with_event_name_and_non_indexed_argument( emitter.functions.logTriple(event_id, 12345, 2, 54321).transact() ) for txn_hash in txn_hashes: - wait_for_transaction(web3, txn_hash) + wait_for_transaction(w3, txn_hash) seen_logs = event_filter.get_new_entries() assert len(seen_logs) == 1 @@ -155,10 +155,10 @@ def test_on_sync_filter_with_event_name_and_non_indexed_argument( assert old_logs[0]['transactionHash'] == txn_hashes[1] -def test_filter_with_contract_address(web3, emitter, emitter_event_ids, wait_for_transaction): - event_filter = web3.eth.filter(filter_params={'address': emitter.address}) +def test_filter_with_contract_address(w3, emitter, emitter_event_ids, wait_for_transaction): + event_filter = w3.eth.filter(filter_params={'address': emitter.address}) txn_hash = emitter.functions.logNoArgs(emitter_event_ids.LogNoArguments).transact() - wait_for_transaction(web3, txn_hash) + wait_for_transaction(w3, txn_hash) seen_logs = event_filter.get_new_entries() assert len(seen_logs) == 1 assert seen_logs[0]['transactionHash'] == txn_hash @@ -166,7 +166,7 @@ def test_filter_with_contract_address(web3, emitter, emitter_event_ids, wait_for @pytest.mark.parametrize('call_as_instance', (True, False)) def test_on_sync_filter_with_topic_filter_options_on_old_apis( - web3, + w3, emitter, Emitter, wait_for_transaction, @@ -199,7 +199,7 @@ def test_on_sync_filter_with_topic_filter_options_on_old_apis( emitter.functions.logTriple(event_id, 1, 2, 1).transact() ) for txn_hash in txn_hashes: - wait_for_transaction(web3, txn_hash) + wait_for_transaction(w3, txn_hash) seen_logs = event_filter.get_new_entries() assert len(seen_logs) == 4 diff --git a/tests/core/filtering/test_contract_past_event_filtering.py b/tests/core/filtering/test_contract_past_event_filtering.py index 85009ef824..5686ab7e22 100644 --- a/tests/core/filtering/test_contract_past_event_filtering.py +++ b/tests/core/filtering/test_contract_past_event_filtering.py @@ -8,7 +8,7 @@ @pytest.mark.parametrize('call_as_instance', (True, False)) @pytest.mark.parametrize('api_style', ('v4', 'build_filter')) def test_on_filter_using_get_all_entries_interface( - web3, + w3, emitter, Emitter, wait_for_transaction, @@ -25,13 +25,13 @@ def test_on_filter_using_get_all_entries_interface( if api_style == 'build_filter': builder = contract.events.LogNoArguments.build_filter() builder.fromBlock = "latest" - event_filter = builder.deploy(web3) + event_filter = builder.deploy(w3) else: event_filter = create_filter( contract, ["LogNoArguments", {"fromBlock": "latest"}]) txn_hash = emitter.functions.logNoArgs(emitter_event_ids.LogNoArguments).transact() - wait_for_transaction(web3, txn_hash) + wait_for_transaction(w3, txn_hash) log_entries = event_filter.get_all_entries() @@ -48,7 +48,7 @@ def test_on_filter_using_get_all_entries_interface( @pytest.mark.parametrize('call_as_instance', (True, False)) @pytest.mark.parametrize('api_style', ('v4', 'build_filter')) def test_get_all_entries_returned_block_data( - web3, + w3, emitter, Emitter, wait_for_transaction, @@ -58,7 +58,7 @@ def test_get_all_entries_returned_block_data( create_filter, ): txn_hash = emitter.functions.logNoArgs(emitter_event_ids.LogNoArguments).transact() - txn_receipt = wait_for_transaction(web3, txn_hash) + txn_receipt = wait_for_transaction(w3, txn_hash) if call_as_instance: contract = emitter @@ -68,7 +68,7 @@ def test_get_all_entries_returned_block_data( if api_style == 'build_filter': builder = contract.events.LogNoArguments.build_filter() builder.fromBlock = txn_receipt["blockNumber"] - event_filter = builder.deploy(web3) + event_filter = builder.deploy(w3) else: event_filter = create_filter(contract, [ "LogNoArguments", {"fromBlock": txn_receipt["blockNumber"]}]) diff --git a/tests/core/filtering/test_contract_topic_filters.py b/tests/core/filtering/test_contract_topic_filters.py index 6e55ed74ac..f51f5b4670 100644 --- a/tests/core/filtering/test_contract_topic_filters.py +++ b/tests/core/filtering/test_contract_topic_filters.py @@ -24,7 +24,7 @@ scope='module', params=[True, False], ids=["local_filter_middleware", "node_based_filter"]) -def web3(request): +def w3(request): use_filter_middleware = request.param provider = EthereumTesterProvider() w3 = Web3(provider) @@ -34,8 +34,8 @@ def web3(request): @pytest.fixture(autouse=True) -def wait_for_mining_start(web3, wait_for_block): - wait_for_block(web3) +def wait_for_mining_start(w3, wait_for_block): + wait_for_block(w3) @pytest.fixture(scope="module") @@ -65,18 +65,18 @@ def EMITTER(EMITTER_CODE, @pytest.fixture(scope="module") -def Emitter(web3, EMITTER): - return web3.eth.contract(**EMITTER) +def Emitter(w3, EMITTER): + return w3.eth.contract(**EMITTER) @pytest.fixture(scope="module") -def emitter(web3, Emitter, wait_for_transaction, wait_for_block, address_conversion_func): - wait_for_block(web3) +def emitter(w3, Emitter, wait_for_transaction, wait_for_block, address_conversion_func): + wait_for_block(w3) deploy_txn_hash = Emitter.constructor().transact({'gas': 10000000}) - deploy_receipt = wait_for_transaction(web3, deploy_txn_hash) + deploy_receipt = wait_for_transaction(w3, deploy_txn_hash) contract_address = address_conversion_func(deploy_receipt['contractAddress']) - bytecode = web3.eth.get_code(contract_address) + bytecode = w3.eth.get_code(contract_address) assert bytecode == Emitter.bytecode_runtime _emitter = Emitter(address=contract_address) assert _emitter.address == contract_address @@ -138,7 +138,7 @@ def array_values(draw): @given(vals=dynamic_values()) @settings(max_examples=5, deadline=None) def test_topic_filters_with_dynamic_arguments( - web3, + w3, emitter, wait_for_transaction, create_filter, @@ -147,7 +147,7 @@ def test_topic_filters_with_dynamic_arguments( if api_style == 'build_filter': filter_builder = emitter.events.LogDynamicArgs.build_filter() filter_builder.args['arg0'].match_single(vals['matching']) - event_filter = filter_builder.deploy(web3) + event_filter = filter_builder.deploy(w3) else: event_filter = create_filter(emitter, [ 'LogDynamicArgs', { @@ -168,7 +168,7 @@ def test_topic_filters_with_dynamic_arguments( ] for txn_hash in txn_hashes: - wait_for_transaction(web3, txn_hash) + wait_for_transaction(w3, txn_hash) log_entries = event_filter.get_new_entries() assert len(log_entries) == 1 @@ -180,7 +180,7 @@ def test_topic_filters_with_dynamic_arguments( @given(vals=fixed_values()) @settings(max_examples=5, deadline=None) def test_topic_filters_with_fixed_arguments( - web3, + w3, emitter, Emitter, wait_for_transaction, @@ -194,7 +194,7 @@ def test_topic_filters_with_fixed_arguments( filter_builder.args['arg1'].match_single(vals['matching'][1]) filter_builder.args['arg2'].match_single(vals['matching'][2]) filter_builder.args['arg3'].match_single(vals['matching'][3]) - event_filter = filter_builder.deploy(web3) + event_filter = filter_builder.deploy(w3) else: event_filter = create_filter(emitter, [ 'LogQuadrupleWithIndex', { @@ -223,7 +223,7 @@ def test_topic_filters_with_fixed_arguments( })) for txn_hash in txn_hashes: - wait_for_transaction(web3, txn_hash) + wait_for_transaction(w3, txn_hash) log_entries = event_filter.get_new_entries() assert len(log_entries) == 1 @@ -235,7 +235,7 @@ def test_topic_filters_with_fixed_arguments( @given(vals=array_values()) @settings(max_examples=5, deadline=None) def test_topic_filters_with_list_arguments( - web3, + w3, emitter, wait_for_transaction, call_as_instance, @@ -247,7 +247,7 @@ def test_topic_filters_with_list_arguments( if api_style == 'build_filter': filter_builder = emitter.events.LogListArgs.build_filter() filter_builder.args['arg0'].match_single(matching) - event_filter = filter_builder.deploy(web3) + event_filter = filter_builder.deploy(w3) txn_hashes = [] txn_hashes.append(emitter.functions.logListArgs( arg0=matching, @@ -257,7 +257,7 @@ def test_topic_filters_with_list_arguments( arg1=non_matching).transact({'maxFeePerGas': 10 ** 9, 'maxPriorityFeePerGas': 10 ** 9})) for txn_hash in txn_hashes: - wait_for_transaction(web3, txn_hash) + wait_for_transaction(w3, txn_hash) log_entries = event_filter.get_new_entries() assert len(log_entries) == 1 diff --git a/tests/core/filtering/test_existing_filter_instance.py b/tests/core/filtering/test_existing_filter_instance.py index 217d6c51aa..fef675a5ce 100644 --- a/tests/core/filtering/test_existing_filter_instance.py +++ b/tests/core/filtering/test_existing_filter_instance.py @@ -9,27 +9,27 @@ @pytest.fixture() -def filter_id(web3): - if not isinstance(web3.provider, EthereumTesterProvider): - web3.provider = EthereumTesterProvider() +def filter_id(w3): + if not isinstance(w3.provider, EthereumTesterProvider): + w3.provider = EthereumTesterProvider() - block_filter = web3.eth.filter("latest") + block_filter = w3.eth.filter("latest") return block_filter.filter_id -def test_instantiate_existing_filter(web3, sleep_interval, wait_for_block, filter_id): +def test_instantiate_existing_filter(w3, sleep_interval, wait_for_block, filter_id): with pytest.raises(TypeError): - web3.eth.filter('latest', filter_id) + w3.eth.filter('latest', filter_id) with pytest.raises(TypeError): - web3.eth.filter('latest', filter_id=filter_id) + w3.eth.filter('latest', filter_id=filter_id) with pytest.raises(TypeError): - web3.eth.filter(filter_params='latest', filter_id=filter_id) + w3.eth.filter(filter_params='latest', filter_id=filter_id) - block_filter = web3.eth.filter(filter_id=filter_id) + block_filter = w3.eth.filter(filter_id=filter_id) - current_block = web3.eth.block_number + current_block = w3.eth.block_number - wait_for_block(web3, current_block + 3) + wait_for_block(w3, current_block + 3) found_block_hashes = [] with Timeout(5) as timeout: @@ -40,6 +40,6 @@ def test_instantiate_existing_filter(web3, sleep_interval, wait_for_block, filte assert len(found_block_hashes) == 3 expected_block_hashes = [ - web3.eth.get_block(n + 1).hash for n in range(current_block, current_block + 3) + w3.eth.get_block(n + 1).hash for n in range(current_block, current_block + 3) ] assert found_block_hashes == expected_block_hashes diff --git a/tests/core/filtering/test_filter_against_latest_blocks.py b/tests/core/filtering/test_filter_against_latest_blocks.py index 728424bafc..b12e76b580 100644 --- a/tests/core/filtering/test_filter_against_latest_blocks.py +++ b/tests/core/filtering/test_filter_against_latest_blocks.py @@ -6,15 +6,15 @@ ) -def test_sync_filter_against_latest_blocks(web3, sleep_interval, wait_for_block): - if not isinstance(web3.provider, EthereumTesterProvider): - web3.provider = EthereumTesterProvider() +def test_sync_filter_against_latest_blocks(w3, sleep_interval, wait_for_block): + if not isinstance(w3.provider, EthereumTesterProvider): + w3.provider = EthereumTesterProvider() - txn_filter = web3.eth.filter("latest") + txn_filter = w3.eth.filter("latest") - current_block = web3.eth.block_number + current_block = w3.eth.block_number - wait_for_block(web3, current_block + 3) + wait_for_block(w3, current_block + 3) found_block_hashes = [] with Timeout(5) as timeout: @@ -25,6 +25,6 @@ def test_sync_filter_against_latest_blocks(web3, sleep_interval, wait_for_block) assert len(found_block_hashes) == 3 expected_block_hashes = [ - web3.eth.get_block(n + 1).hash for n in range(current_block, current_block + 3) + w3.eth.get_block(n + 1).hash for n in range(current_block, current_block + 3) ] assert found_block_hashes == expected_block_hashes diff --git a/tests/core/filtering/test_filter_against_pending_transactions.py b/tests/core/filtering/test_filter_against_pending_transactions.py index e3162a9b8c..aebdb7fea7 100644 --- a/tests/core/filtering/test_filter_against_pending_transactions.py +++ b/tests/core/filtering/test_filter_against_pending_transactions.py @@ -10,30 +10,30 @@ ) -@pytest.mark.skip(reason="fixture 'web3_empty' not found") +@pytest.mark.skip(reason="fixture 'w3_empty' not found") @flaky(max_runs=3) -def test_sync_filter_against_pending_transactions(web3_empty, +def test_sync_filter_against_pending_transactions(w3_empty, wait_for_transaction, skip_if_testrpc ): - web3 = web3_empty - skip_if_testrpc(web3) + w3 = w3_empty + skip_if_testrpc(w3) - txn_filter = web3.eth.filter("pending") + txn_filter = w3.eth.filter("pending") - txn_1_hash = web3.eth.send_transaction({ - 'from': web3.eth.coinbase, + txn_1_hash = w3.eth.send_transaction({ + 'from': w3.eth.coinbase, 'to': '0xd3CdA913deB6f67967B99D67aCDFa1712C293601', 'value': 12345, }) - txn_2_hash = web3.eth.send_transaction({ - 'from': web3.eth.coinbase, + txn_2_hash = w3.eth.send_transaction({ + 'from': w3.eth.coinbase, 'to': '0xd3CdA913deB6f67967B99D67aCDFa1712C293601', 'value': 54321, }) - wait_for_transaction(web3, txn_1_hash) - wait_for_transaction(web3, txn_2_hash) + wait_for_transaction(w3, txn_1_hash) + wait_for_transaction(w3, txn_2_hash) with Timeout(5) as timeout: while not txn_filter.get_new_entries(): @@ -45,32 +45,32 @@ def test_sync_filter_against_pending_transactions(web3_empty, assert txn_2_hash in seen_txns -@pytest.mark.skip(reason="fixture 'web3_empty' not found") +@pytest.mark.skip(reason="fixture 'w3_empty' not found") @flaky(max_runs=3) -def test_async_filter_against_pending_transactions(web3_empty, +def test_async_filter_against_pending_transactions(w3_empty, wait_for_transaction, skip_if_testrpc ): - web3 = web3_empty - skip_if_testrpc(web3) + w3 = w3_empty + skip_if_testrpc(w3) seen_txns = [] - txn_filter = web3.eth.filter("pending") + txn_filter = w3.eth.filter("pending") txn_filter.watch(seen_txns.append) - txn_1_hash = web3.eth.send_transaction({ - 'from': web3.eth.coinbase, + txn_1_hash = w3.eth.send_transaction({ + 'from': w3.eth.coinbase, 'to': '0xd3CdA913deB6f67967B99D67aCDFa1712C293601', 'value': 12345, }) - txn_2_hash = web3.eth.send_transaction({ - 'from': web3.eth.coinbase, + txn_2_hash = w3.eth.send_transaction({ + 'from': w3.eth.coinbase, 'to': '0xd3CdA913deB6f67967B99D67aCDFa1712C293601', 'value': 54321, }) - wait_for_transaction(web3, txn_1_hash) - wait_for_transaction(web3, txn_2_hash) + wait_for_transaction(w3, txn_1_hash) + wait_for_transaction(w3, txn_2_hash) with Timeout(5) as timeout: while not seen_txns: diff --git a/tests/core/filtering/test_filter_against_transaction_logs.py b/tests/core/filtering/test_filter_against_transaction_logs.py index b0c13a03ca..664ec64b95 100644 --- a/tests/core/filtering/test_filter_against_transaction_logs.py +++ b/tests/core/filtering/test_filter_against_transaction_logs.py @@ -10,23 +10,23 @@ ) -@pytest.mark.skip(reason="fixture 'web3_empty' not found") +@pytest.mark.skip(reason="fixture 'w3_empty' not found") @flaky(max_runs=3) -def test_sync_filter_against_log_events(web3_empty, +def test_sync_filter_against_log_events(w3_empty, emitter, wait_for_transaction, emitter_log_topics, emitter_event_ids ): - web3 = web3_empty + w3 = w3_empty - txn_filter = web3.eth.filter({}) + txn_filter = w3.eth.filter({}) txn_hashes = [] txn_hashes.append(emitter.functions.logNoArgs(emitter_event_ids.LogNoArguments).transact()) for txn_hash in txn_hashes: - wait_for_transaction(web3, txn_hash) + wait_for_transaction(w3, txn_hash) with Timeout(5) as timeout: while not txn_filter.get_new_entries(): @@ -37,18 +37,18 @@ def test_sync_filter_against_log_events(web3_empty, assert set(txn_hashes) == set(log['transactionHash'] for log in seen_logs) -@pytest.mark.skip(reason="fixture 'web3_empty' not found") +@pytest.mark.skip(reason="fixture 'w3_empty' not found") @flaky(max_runs=3) -def test_async_filter_against_log_events(web3_empty, +def test_async_filter_against_log_events(w3_empty, emitter, wait_for_transaction, emitter_log_topics, emitter_event_ids ): - web3 = web3_empty + w3 = w3_empty seen_logs = [] - txn_filter = web3.eth.filter({}) + txn_filter = w3.eth.filter({}) txn_filter.watch(seen_logs.append) txn_hashes = [] @@ -56,7 +56,7 @@ def test_async_filter_against_log_events(web3_empty, txn_hashes.append(emitter.functions.logNoArgs(emitter_event_ids.LogNoArguments).transact()) for txn_hash in txn_hashes: - wait_for_transaction(web3, txn_hash) + wait_for_transaction(w3, txn_hash) with Timeout(5) as timeout: while not seen_logs: diff --git a/tests/core/filtering/test_filters_against_many_blocks.py b/tests/core/filtering/test_filters_against_many_blocks.py index ced0ff4117..397dda579a 100644 --- a/tests/core/filtering/test_filters_against_many_blocks.py +++ b/tests/core/filtering/test_filters_against_many_blocks.py @@ -7,11 +7,11 @@ @to_tuple -def deploy_contracts(web3, contract, wait_for_transaction): +def deploy_contracts(w3, contract, wait_for_transaction): for i in range(25): tx_hash = contract.constructor().transact() - wait_for_transaction(web3, tx_hash) - yield web3.eth.get_transaction_receipt(tx_hash)['contractAddress'] + wait_for_transaction(w3, tx_hash) + yield w3.eth.get_transaction_receipt(tx_hash)['contractAddress'] def pad_with_transactions(w3): @@ -34,7 +34,7 @@ def single_transaction(w3): @pytest.mark.parametrize('api_style', ('v4', 'build_filter')) def test_event_filter_new_events( - web3, + w3, emitter, Emitter, wait_for_transaction, @@ -50,43 +50,43 @@ def test_event_filter_new_events( if api_style == 'build_filter': builder = emitter.events.LogNoArguments.build_filter() builder.fromBlock = 'latest' - event_filter = builder.deploy(web3) + event_filter = builder.deploy(w3) else: event_filter = emitter.events.LogNoArguments().createFilter(fromBlock='latest') expected_match_counter = 0 - while web3.eth.block_number < 50: + while w3.eth.block_number < 50: is_match = bool(random.randint(0, 1)) if is_match: expected_match_counter += 1 - wait_for_transaction(web3, matching_transact()) - pad_with_transactions(web3) + wait_for_transaction(w3, matching_transact()) + pad_with_transactions(w3) continue non_matching_transact() - pad_with_transactions(web3) + pad_with_transactions(w3) assert len(event_filter.get_new_entries()) == expected_match_counter @pytest.mark.xfail(reason="Suspected eth-tester bug") -def test_block_filter(web3): - block_filter = web3.eth.filter("latest") +def test_block_filter(w3): + block_filter = w3.eth.filter("latest") - while web3.eth.block_number < 50: - pad_with_transactions(web3) + while w3.eth.block_number < 50: + pad_with_transactions(w3) - assert len(block_filter.get_new_entries()) == web3.eth.block_number + assert len(block_filter.get_new_entries()) == w3.eth.block_number -def test_transaction_filter_with_mining(web3): +def test_transaction_filter_with_mining(w3): - transaction_filter = web3.eth.filter("pending") + transaction_filter = w3.eth.filter("pending") transaction_counter = 0 while transaction_counter < 100: - single_transaction(web3) + single_transaction(w3) transaction_counter += 1 assert len(transaction_filter.get_new_entries()) == transaction_counter @@ -94,14 +94,14 @@ def test_transaction_filter_with_mining(web3): @pytest.mark.xfail(reason="Suspected eth-tester bug") def test_transaction_filter_without_mining( - web3): + w3): - web3.providers[0].ethereum_tester.auto_mine_transactions = False - transaction_filter = web3.eth.filter("pending") + w3.providers[0].ethereum_tester.auto_mine_transactions = False + transaction_filter = w3.eth.filter("pending") transaction_counter = 0 - transact_once = single_transaction(web3) + transact_once = single_transaction(w3) while transaction_counter < 100: next(transact_once) transaction_counter += 1 @@ -111,7 +111,7 @@ def test_transaction_filter_without_mining( @pytest.mark.parametrize('api_style', ('v4', 'build_filter')) def test_event_filter_new_events_many_deployed_contracts( - web3, + w3, emitter, Emitter, wait_for_transaction, @@ -122,13 +122,13 @@ def test_event_filter_new_events_many_deployed_contracts( matching_transact = emitter.functions.logNoArgs( which=1).transact - deployed_contract_addresses = deploy_contracts(web3, Emitter, wait_for_transaction) + deployed_contract_addresses = deploy_contracts(w3, Emitter, wait_for_transaction) def gen_non_matching_transact(): while True: contract_address = deployed_contract_addresses[ random.randint(0, len(deployed_contract_addresses) - 1)] - yield web3.eth.contract( + yield w3.eth.contract( address=contract_address, abi=Emitter.abi).functions.logNoArgs(which=1).transact non_matching_transact = gen_non_matching_transact() @@ -136,20 +136,20 @@ def gen_non_matching_transact(): if api_style == 'build_filter': builder = emitter.events.LogNoArguments.build_filter() builder.fromBlock = "latest" - event_filter = builder.deploy(web3) + event_filter = builder.deploy(w3) else: event_filter = emitter.events.LogNoArguments().createFilter(fromBlock='latest') expected_match_counter = 0 - while web3.eth.block_number < 50: + while w3.eth.block_number < 50: is_match = bool(random.randint(0, 1)) if is_match: expected_match_counter += 1 matching_transact() - pad_with_transactions(web3) + pad_with_transactions(w3) continue next(non_matching_transact)() - pad_with_transactions(web3) + pad_with_transactions(w3) assert len(event_filter.get_new_entries()) == expected_match_counter diff --git a/tests/core/filtering/test_utils_functions.py b/tests/core/filtering/test_utils_functions.py index 6d6b5a4383..54ea2c12d7 100644 --- a/tests/core/filtering/test_utils_functions.py +++ b/tests/core/filtering/test_utils_functions.py @@ -128,10 +128,10 @@ ), ) ) -def test_match_fn_with_various_data_types(web3, data, expected, match_data_and_abi): +def test_match_fn_with_various_data_types(w3, data, expected, match_data_and_abi): abi_types, match_data = zip(*match_data_and_abi) - encoded_data = web3.codec.encode_abi(abi_types, data) - assert match_fn(web3.codec, match_data_and_abi, encoded_data) == expected + encoded_data = w3.codec.encode_abi(abi_types, data) + assert match_fn(w3.codec, match_data_and_abi, encoded_data) == expected @pytest.mark.parametrize( @@ -224,13 +224,13 @@ def test_encode_abi_with_wrong_types_strict(w3_strict_abi, w3_strict_abi.codec.encode_abi(abi_type, data) -def test_wrong_type_match_data(web3): +def test_wrong_type_match_data(w3): data = ("hello", "goodbye") match_data_and_abi = ( ("string", (50505050,)), ("string", (50505050,)), ) abi_types, match_data = zip(*match_data_and_abi) - encoded_data = web3.codec.encode_abi(abi_types, data) + encoded_data = w3.codec.encode_abi(abi_types, data) with pytest.raises(ValueError): - match_fn(web3.codec, match_data_and_abi, encoded_data) + match_fn(w3.codec, match_data_and_abi, encoded_data) diff --git a/tests/core/gas-strategies/test_rpc_gas_pricing_strategies.py b/tests/core/gas-strategies/test_rpc_gas_pricing_strategies.py index 76e44ff705..7b54d72c79 100644 --- a/tests/core/gas-strategies/test_rpc_gas_pricing_strategies.py +++ b/tests/core/gas-strategies/test_rpc_gas_pricing_strategies.py @@ -3,12 +3,12 @@ ) -def test_default_rpc_gas_price_strategy(web3): - assert rpc_gas_price_strategy(web3, { +def test_default_rpc_gas_price_strategy(w3): + assert rpc_gas_price_strategy(w3, { 'to': '0x0', 'value': 1 }) == 10 ** 9 -def test_default_rpc_gas_price_strategy_callable_without_transaction(web3): - assert rpc_gas_price_strategy(web3) == 10 ** 9 +def test_default_rpc_gas_price_strategy_callable_without_transaction(w3): + assert rpc_gas_price_strategy(w3) == 10 ** 9 diff --git a/tests/core/manager/conftest.py b/tests/core/manager/conftest.py index 7653961d55..e79989a4a5 100644 --- a/tests/core/manager/conftest.py +++ b/tests/core/manager/conftest.py @@ -15,7 +15,7 @@ class Wrapper: def __repr__(self): return 'middleware-' + key - def __call__(self, make_request, web3): + def __call__(self, make_request, w3): def middleware_fn(method, params): params.append(key) method = "|".join((method, key)) diff --git a/tests/core/manager/test_middleware_can_be_stateful.py b/tests/core/manager/test_middleware_can_be_stateful.py index db652c03a6..4927b56230 100644 --- a/tests/core/manager/test_middleware_can_be_stateful.py +++ b/tests/core/manager/test_middleware_can_be_stateful.py @@ -6,7 +6,7 @@ ) -def stateful_middleware(make_request, web3): +def stateful_middleware(make_request, w3): state = [] def middleware(method, params): diff --git a/tests/core/manager/test_response_formatters.py b/tests/core/manager/test_response_formatters.py index df8e563b5f..65b3771104 100644 --- a/tests/core/manager/test_response_formatters.py +++ b/tests/core/manager/test_response_formatters.py @@ -107,17 +107,17 @@ def raise_contract_logic_error(response): ), ], ) -def test_formatted_response_raises_errors(web3, +def test_formatted_response_raises_errors(w3, response, params, error_formatters, null_result_formatters, error): with pytest.raises(error): - web3.manager.formatted_response(response, - params, - error_formatters, - null_result_formatters) + w3.manager.formatted_response(response, + params, + error_formatters, + null_result_formatters) @pytest.mark.parametrize( @@ -166,7 +166,7 @@ def test_formatted_response_raises_errors(web3, ], ) def test_formatted_response_raises_correct_error_message(response, - web3, + w3, params, error_formatters, null_result_formatters, @@ -174,7 +174,7 @@ def test_formatted_response_raises_correct_error_message(response, error_message): with pytest.raises(error, match=error_message): - web3.manager.formatted_response(response, params, error_formatters, null_result_formatters) + w3.manager.formatted_response(response, params, error_formatters, null_result_formatters) @pytest.mark.parametrize( @@ -199,14 +199,14 @@ def test_formatted_response_raises_correct_error_message(response, ], ) def test_formatted_response(response, - web3, + w3, params, error_formatters, null_result_formatters, expected): - formatted_resp = web3.manager.formatted_response(response, - params, - error_formatters, - null_result_formatters) + formatted_resp = w3.manager.formatted_response(response, + params, + error_formatters, + null_result_formatters) assert formatted_resp == expected diff --git a/tests/core/middleware/test_gas_price_strategy.py b/tests/core/middleware/test_gas_price_strategy.py index e3a2562cbe..4a4a2d3ab4 100644 --- a/tests/core/middleware/test_gas_price_strategy.py +++ b/tests/core/middleware/test_gas_price_strategy.py @@ -9,23 +9,23 @@ @pytest.fixture -def the_gas_price_strategy_middleware(web3): - make_request, web3 = Mock(), Mock() - initialized = gas_price_strategy_middleware(make_request, web3) - initialized.web3 = web3 +def the_gas_price_strategy_middleware(w3): + make_request, w3 = Mock(), Mock() + initialized = gas_price_strategy_middleware(make_request, w3) + initialized.w3 = w3 initialized.make_request = make_request return initialized def test_gas_price_generated(the_gas_price_strategy_middleware): - the_gas_price_strategy_middleware.web3.eth.generate_gas_price.return_value = 5 + the_gas_price_strategy_middleware.w3.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.generate_gas_price.assert_called_once_with({ + the_gas_price_strategy_middleware.w3.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.generate_gas_price.return_value = 5 + the_gas_price_strategy_middleware.w3.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.generate_gas_price.return_value = None + the_gas_price_strategy_middleware.w3.eth.generate_gas_price.return_value = None method = 'eth_sendTransaction' params = ({ 'to': '0x0', @@ -64,6 +64,6 @@ def test_gas_price_not_set_without_gas_price_strategy(the_gas_price_strategy_mid def test_not_generate_gas_price_when_not_send_transaction_rpc(the_gas_price_strategy_middleware): - the_gas_price_strategy_middleware.web3.getGasPriceStrategy = Mock() + the_gas_price_strategy_middleware.w3.getGasPriceStrategy = Mock() the_gas_price_strategy_middleware('eth_getBalance', []) - the_gas_price_strategy_middleware.web3.getGasPriceStrategy.assert_not_called() + the_gas_price_strategy_middleware.w3.getGasPriceStrategy.assert_not_called() diff --git a/tests/core/middleware/test_http_request_retry.py b/tests/core/middleware/test_http_request_retry.py index 7558a9df1c..c11324908b 100644 --- a/tests/core/middleware/test_http_request_retry.py +++ b/tests/core/middleware/test_http_request_retry.py @@ -24,11 +24,11 @@ @pytest.fixture def exception_retry_request_setup(): - web3 = Mock() + w3 = Mock() provider = HTTPProvider() errors = (ConnectionError, HTTPError, Timeout, TooManyRedirects) - setup = exception_retry_middleware(provider.make_request, web3, errors, 5) - setup.web3 = web3 + setup = exception_retry_middleware(provider.make_request, w3, errors, 5) + setup.w3 = w3 return setup @@ -68,11 +68,11 @@ def test_valid_method_retried(make_post_request_mock, exception_retry_request_se def test_is_strictly_default_http_middleware(): - web3 = HTTPProvider() - assert 'http_retry_request' in web3.middlewares + w3 = HTTPProvider() + assert 'http_retry_request' in w3.middlewares - web3 = IPCProvider() - assert 'http_retry_request' not in web3.middlewares + w3 = IPCProvider() + assert 'http_retry_request' not in w3.middlewares @patch('web3.providers.rpc.make_post_request', side_effect=ConnectionError) diff --git a/tests/core/mining-module/conftest.py b/tests/core/mining-module/conftest.py index 4e6ab94eb8..359e0741ea 100644 --- a/tests/core/mining-module/conftest.py +++ b/tests/core/mining-module/conftest.py @@ -2,12 +2,12 @@ @pytest.fixture(autouse=True) -def always_wait_for_mining_start(web3, +def always_wait_for_mining_start(w3, wait_for_miner_start, skip_if_testrpc): - skip_if_testrpc(web3) + skip_if_testrpc(w3) - wait_for_miner_start(web3) + wait_for_miner_start(w3) - assert web3.eth.mining - assert web3.eth.hashrate + assert w3.eth.mining + assert w3.eth.hashrate diff --git a/tests/core/mining-module/test_miner_hashrate.py b/tests/core/mining-module/test_miner_hashrate.py index d28acfcc72..0c6b16df66 100644 --- a/tests/core/mining-module/test_miner_hashrate.py +++ b/tests/core/mining-module/test_miner_hashrate.py @@ -4,8 +4,8 @@ @flaky(max_runs=3) -def test_miner_hashrate(web3_empty, wait_for_miner_start): - web3 = web3_empty +def test_miner_hashrate(w3_empty, wait_for_miner_start): + w3 = w3_empty - hashrate = web3.eth.hashrate + hashrate = w3.eth.hashrate assert hashrate > 0 diff --git a/tests/core/mining-module/test_miner_start.py b/tests/core/mining-module/test_miner_start.py index 80de7839c4..daa04e6835 100644 --- a/tests/core/mining-module/test_miner_start.py +++ b/tests/core/mining-module/test_miner_start.py @@ -10,25 +10,25 @@ @flaky(max_runs=3) -def test_miner_start(web3_empty, wait_for_miner_start): - web3 = web3_empty +def test_miner_start(w3_empty, wait_for_miner_start): + w3 = w3_empty # sanity - assert web3.eth.mining - assert web3.eth.hashrate + assert w3.eth.mining + assert w3.eth.hashrate - web3.geth.miner.stop() + w3.geth.miner.stop() with Timeout(60) as timeout: - while web3.eth.mining or web3.eth.hashrate: + while w3.eth.mining or w3.eth.hashrate: timeout.sleep(random.random()) - assert not web3.eth.mining - assert not web3.eth.hashrate + assert not w3.eth.mining + assert not w3.eth.hashrate - web3.miner.start(1) + w3.miner.start(1) - wait_for_miner_start(web3) + wait_for_miner_start(w3) - assert web3.eth.mining - assert web3.eth.hashrate + assert w3.eth.mining + assert w3.eth.hashrate diff --git a/tests/core/mining-module/test_miner_stop.py b/tests/core/mining-module/test_miner_stop.py index 60b6633b3f..1e2af7698c 100644 --- a/tests/core/mining-module/test_miner_stop.py +++ b/tests/core/mining-module/test_miner_stop.py @@ -10,18 +10,18 @@ @flaky(max_runs=3) -def test_miner_stop(web3_empty): - web3 = web3_empty +def test_miner_stop(w3_empty): + w3 = w3_empty - assert web3.eth.mining - assert web3.eth.hashrate + assert w3.eth.mining + assert w3.eth.hashrate - web3.geth.miner.stop() + w3.geth.miner.stop() with Timeout(60) as timeout: - while web3.eth.mining or web3.eth.hashrate: + while w3.eth.mining or w3.eth.hashrate: timeout.sleep(random.random()) timeout.check() - assert not web3.eth.mining - assert not web3.eth.hashrate + assert not w3.eth.mining + assert not w3.eth.hashrate diff --git a/tests/core/pm-module/test_ens_integration.py b/tests/core/pm-module/test_ens_integration.py index 163dcae8ff..c6bd38b519 100644 --- a/tests/core/pm-module/test_ens_integration.py +++ b/tests/core/pm-module/test_ens_integration.py @@ -116,19 +116,19 @@ def ens_setup(deployer): @pytest.fixture def ens(ens_setup, mocker): mocker.patch('web3.middleware.stalecheck._isfresh', return_value=True) - ens_setup.web3.eth.default_account = ens_setup.web3.eth.coinbase - ens_setup.web3.enable_unstable_package_management_api() + ens_setup.w3.eth.default_account = ens_setup.w3.eth.coinbase + ens_setup.w3.enable_unstable_package_management_api() return ens_setup def test_ens_must_be_set_before_ens_methods_can_be_used(ens): - w3 = ens.web3 + w3 = ens.w3 with pytest.raises(InvalidAddress): w3.pm.set_registry("tester.eth") def test_web3_ens(ens): - w3 = ens.web3 + w3 = ens.w3 ns = ENS.fromWeb3(w3, ens.ens.address) w3.ens = ns registry = SimpleRegistry.deploy_new_instance(w3) diff --git a/tests/core/providers/test_http_provider.py b/tests/core/providers/test_http_provider.py index f0e28c43aa..7ae1ec62f9 100644 --- a/tests/core/providers/test_http_provider.py +++ b/tests/core/providers/test_http_provider.py @@ -18,15 +18,15 @@ def test_no_args(): provider = HTTPProvider() - web3 = Web3(provider) - assert web3.manager.provider == provider + w3 = Web3(provider) + assert w3.manager.provider == provider def test_init_kwargs(): provider = HTTPProvider(endpoint_uri=URI, request_kwargs={'timeout': 60}) - web3 = Web3(provider) - assert web3.manager.provider == provider + w3 = Web3(provider) + assert w3.manager.provider == provider def test_user_provided_session(): @@ -36,8 +36,8 @@ def test_user_provided_session(): session.mount('https://', adapter) provider = HTTPProvider(endpoint_uri=URI, session=session) - web3 = Web3(provider) - assert web3.manager.provider == provider + w3 = Web3(provider) + assert w3.manager.provider == provider session = request._get_session(URI) adapter = session.get_adapter(URI) diff --git a/tests/core/providers/test_provider.py b/tests/core/providers/test_provider.py index d71744fb3a..7845d75f03 100644 --- a/tests/core/providers/test_provider.py +++ b/tests/core/providers/test_provider.py @@ -19,8 +19,8 @@ def test_isConnected_connected(): """ Web3.isConnected() returns True when connected to a node. """ - web3 = Web3(ConnectedProvider()) - assert web3.isConnected() is True + w3 = Web3(ConnectedProvider()) + assert w3.isConnected() is True def test_isConnected_disconnected(): @@ -28,8 +28,8 @@ def test_isConnected_disconnected(): Web3.isConnected() returns False when configured with a provider that's not connected to a node. """ - web3 = Web3(DisconnectedProvider()) - assert web3.isConnected() is False + w3 = Web3(DisconnectedProvider()) + assert w3.isConnected() is False def test_autoprovider_detection(): diff --git a/tests/core/testing-module/test_testing_mine.py b/tests/core/testing-module/test_testing_mine.py index b5e59451b4..40a52634fa 100644 --- a/tests/core/testing-module/test_testing_mine.py +++ b/tests/core/testing-module/test_testing_mine.py @@ -1,22 +1,22 @@ -def test_testing_mine_single_block(web3): - web3.testing.mine() +def test_testing_mine_single_block(w3): + w3.testing.mine() - before_mining_block = web3.eth.get_block("latest") + before_mining_block = w3.eth.get_block("latest") - web3.testing.mine() + w3.testing.mine() - after_mining_block = web3.eth.get_block("latest") + after_mining_block = w3.eth.get_block("latest") assert after_mining_block['number'] - before_mining_block['number'] == 1 -def test_testing_mine_multiple_blocks(web3): - web3.testing.mine() +def test_testing_mine_multiple_blocks(w3): + w3.testing.mine() - before_mining_block = web3.eth.get_block("latest") + before_mining_block = w3.eth.get_block("latest") - web3.testing.mine(5) + w3.testing.mine(5) - after_mining_block = web3.eth.get_block("latest") + after_mining_block = w3.eth.get_block("latest") assert after_mining_block['number'] - before_mining_block['number'] == 5 diff --git a/tests/core/testing-module/test_testing_snapshot_and_revert.py b/tests/core/testing-module/test_testing_snapshot_and_revert.py index 8f54dfbc13..5c3df21084 100644 --- a/tests/core/testing-module/test_testing_snapshot_and_revert.py +++ b/tests/core/testing-module/test_testing_snapshot_and_revert.py @@ -1,46 +1,46 @@ -def test_snapshot_revert_to_latest_snapshot(web3): - web3.testing.mine(5) +def test_snapshot_revert_to_latest_snapshot(w3): + w3.testing.mine(5) - block_before_snapshot = web3.eth.get_block("latest") + block_before_snapshot = w3.eth.get_block("latest") - web3.testing.snapshot() + w3.testing.snapshot() - block_after_snapshot = web3.eth.get_block("latest") + block_after_snapshot = w3.eth.get_block("latest") - web3.testing.mine(3) + w3.testing.mine(3) - block_after_mining = web3.eth.get_block("latest") + block_after_mining = w3.eth.get_block("latest") - web3.testing.revert() + w3.testing.revert() - block_after_revert = web3.eth.get_block("latest") + block_after_revert = w3.eth.get_block("latest") assert block_after_mining['number'] > block_before_snapshot['number'] assert block_before_snapshot['hash'] == block_after_snapshot['hash'] assert block_after_snapshot['hash'] == block_after_revert['hash'] -def test_snapshot_revert_to_specific(web3): - web3.testing.mine(5) +def test_snapshot_revert_to_specific(w3): + w3.testing.mine(5) - block_before_snapshot = web3.eth.get_block("latest") + block_before_snapshot = w3.eth.get_block("latest") - snapshot_idx = web3.testing.snapshot() + snapshot_idx = w3.testing.snapshot() - block_after_snapshot = web3.eth.get_block("latest") + block_after_snapshot = w3.eth.get_block("latest") - web3.testing.mine() - web3.testing.snapshot() - web3.testing.mine() - web3.testing.snapshot() - web3.testing.mine() - web3.testing.snapshot() + w3.testing.mine() + w3.testing.snapshot() + w3.testing.mine() + w3.testing.snapshot() + w3.testing.mine() + w3.testing.snapshot() - block_after_mining = web3.eth.get_block("latest") + block_after_mining = w3.eth.get_block("latest") - web3.testing.revert(snapshot_idx) + w3.testing.revert(snapshot_idx) - block_after_revert = web3.eth.get_block("latest") + block_after_revert = w3.eth.get_block("latest") assert block_after_mining['number'] > block_before_snapshot['number'] assert block_before_snapshot['hash'] == block_after_snapshot['hash'] diff --git a/tests/core/testing-module/test_testing_timeTravel.py b/tests/core/testing-module/test_testing_timeTravel.py index 2a135cee44..2f65f47b36 100644 --- a/tests/core/testing-module/test_testing_timeTravel.py +++ b/tests/core/testing-module/test_testing_timeTravel.py @@ -1,9 +1,9 @@ -def test_time_traveling(web3): - current_block_time = web3.eth.get_block("pending")['timestamp'] +def test_time_traveling(w3): + current_block_time = w3.eth.get_block("pending")['timestamp'] time_travel_to = current_block_time + 12345 - web3.testing.timeTravel(time_travel_to) + w3.testing.timeTravel(time_travel_to) - latest_block_time = web3.eth.get_block("pending")['timestamp'] + latest_block_time = w3.eth.get_block("pending")['timestamp'] assert latest_block_time >= time_travel_to diff --git a/tests/core/txpool-module/conftest.py b/tests/core/txpool-module/conftest.py index 0d64d61fa8..6b15c8989c 100644 --- a/tests/core/txpool-module/conftest.py +++ b/tests/core/txpool-module/conftest.py @@ -2,12 +2,12 @@ @pytest.fixture(autouse=True) -def skip_testrpc_and_wait_for_mining_start(web3, +def skip_testrpc_and_wait_for_mining_start(w3, wait_for_miner_start, skip_if_testrpc): - skip_if_testrpc(web3) + skip_if_testrpc(w3) - wait_for_miner_start(web3) + wait_for_miner_start(w3) - assert web3.eth.mining - assert web3.eth.hashrate + assert w3.eth.mining + assert w3.eth.hashrate diff --git a/tests/core/utilities/conftest.py b/tests/core/utilities/conftest.py index 49bc15d4fb..8274f13e5c 100644 --- a/tests/core/utilities/conftest.py +++ b/tests/core/utilities/conftest.py @@ -9,6 +9,6 @@ @pytest.fixture(scope="module") -def web3(): +def w3(): provider = EthereumTesterProvider() return Web3(provider) diff --git a/tests/core/utilities/test_abi_is_encodable.py b/tests/core/utilities/test_abi_is_encodable.py index 958c8e631a..5bf1178cf2 100644 --- a/tests/core/utilities/test_abi_is_encodable.py +++ b/tests/core/utilities/test_abi_is_encodable.py @@ -64,8 +64,8 @@ ((b'\x80', 0), '(string,int128)', False), ), ) -def test_is_encodable(web3, value, _type, expected): - actual = web3.is_encodable(_type, value) +def test_is_encodable(w3, value, _type, expected): + actual = w3.is_encodable(_type, value) assert actual is expected @@ -78,12 +78,12 @@ def test_is_encodable(web3, value, _type, expected): ('12', 'bytes', True), # no 0x prefix, can be decoded as hex ) ) -def test_is_encodable_warnings(web3, value, _type, expected): +def test_is_encodable_warnings(w3, value, _type, expected): with pytest.warns( DeprecationWarning, match='in v6 it will be invalid to pass a hex string without the "0x" prefix' ): - actual = web3.is_encodable(_type, value) + actual = w3.is_encodable(_type, value) assert actual is expected diff --git a/tests/core/utilities/test_attach_modules.py b/tests/core/utilities/test_attach_modules.py index 4d151cc73a..42a3cf820b 100644 --- a/tests/core/utilities/test_attach_modules.py +++ b/tests/core/utilities/test_attach_modules.py @@ -169,7 +169,7 @@ def test_attach_external_modules_that_do_not_inherit_from_module_class( assert is_integer(w3.eth.chain_id) -def test_attach_modules_for_module_with_more_than_one_init_argument(web3, module_many_init_args): +def test_attach_modules_for_module_with_more_than_one_init_argument(module_many_init_args): with pytest.raises( UnsupportedOperation, match=( diff --git a/tests/core/utilities/test_construct_event_data_set.py b/tests/core/utilities/test_construct_event_data_set.py index 6cbc7d73fd..5f5ad8a78c 100644 --- a/tests/core/utilities/test_construct_event_data_set.py +++ b/tests/core/utilities/test_construct_event_data_set.py @@ -77,8 +77,8 @@ def hex_and_pad(i): ), ) ) -def test_construct_event_data_set(web3, arguments, expected): - actual = construct_event_data_set(EVENT_1_ABI, web3.codec, arguments) +def test_construct_event_data_set(w3, arguments, expected): + actual = construct_event_data_set(EVENT_1_ABI, w3.codec, arguments) assert actual == expected diff --git a/tests/core/utilities/test_construct_event_filter_params.py b/tests/core/utilities/test_construct_event_filter_params.py index 882d04ef5b..5300b6ea60 100644 --- a/tests/core/utilities/test_construct_event_filter_params.py +++ b/tests/core/utilities/test_construct_event_filter_params.py @@ -46,8 +46,8 @@ }), ), ) -def test_construct_event_filter_params(web3, event_abi, fn_kwargs, expected): - _, actual = construct_event_filter_params(event_abi, web3.codec, **fn_kwargs) +def test_construct_event_filter_params(w3, event_abi, fn_kwargs, expected): + _, actual = construct_event_filter_params(event_abi, w3.codec, **fn_kwargs) assert actual == expected @@ -68,7 +68,7 @@ def hex_and_pad(i): ]), ), ) -def test_construct_event_filter_params_for_data_filters(event_abi, web3, fn_kwargs, +def test_construct_event_filter_params_for_data_filters(event_abi, w3, fn_kwargs, expected): - actual, _ = construct_event_filter_params(event_abi, web3.codec, **fn_kwargs) + actual, _ = construct_event_filter_params(event_abi, w3.codec, **fn_kwargs) assert actual == expected diff --git a/tests/core/utilities/test_construct_event_topics.py b/tests/core/utilities/test_construct_event_topics.py index 0931ba2cda..a76941a306 100644 --- a/tests/core/utilities/test_construct_event_topics.py +++ b/tests/core/utilities/test_construct_event_topics.py @@ -83,8 +83,8 @@ def hex_and_pad(i): ), ) ) -def test_construct_event_topics(web3, arguments, expected): - actual = construct_event_topic_set(EVENT_1_ABI, web3.codec, arguments) +def test_construct_event_topics(w3, arguments, expected): + actual = construct_event_topic_set(EVENT_1_ABI, w3.codec, arguments) assert actual == expected diff --git a/tests/core/utilities/test_event_filter_builder.py b/tests/core/utilities/test_event_filter_builder.py index 08ac40339e..93bb1dd7fd 100644 --- a/tests/core/utilities/test_event_filter_builder.py +++ b/tests/core/utilities/test_event_filter_builder.py @@ -43,21 +43,21 @@ def test_match_single_string_type_properties_data_arg(value): @given(st.text()) -def test_match_single_string_type_properties_topic_arg(web3, value): - topic_filter = TopicArgumentFilter(arg_type="string", abi_codec=web3.codec) +def test_match_single_string_type_properties_topic_arg(w3, value): + topic_filter = TopicArgumentFilter(arg_type="string", abi_codec=w3.codec) topic_filter.match_single(value) @given(st.lists(elements=st.text(), max_size=10, min_size=0)) -def test_match_any_string_type_properties(web3, values): - topic_filter = TopicArgumentFilter(arg_type="string", abi_codec=web3.codec) +def test_match_any_string_type_properties(w3, values): + topic_filter = TopicArgumentFilter(arg_type="string", abi_codec=w3.codec) topic_filter.match_any(*values) assert len(topic_filter.match_values) == len(values) @given(st.lists(elements=st.binary(), max_size=10, min_size=0)) -def test_match_any_bytes_type_properties(web3, values): - topic_filter = TopicArgumentFilter(arg_type="bytes", abi_codec=web3.codec) +def test_match_any_bytes_type_properties(w3, values): + topic_filter = TopicArgumentFilter(arg_type="bytes", abi_codec=w3.codec) topic_filter.match_any(*values) assert len(topic_filter.match_values) == len(values) diff --git a/tests/core/utilities/test_event_interface.py b/tests/core/utilities/test_event_interface.py index 4f72ccd5fb..7a87fdb1ea 100644 --- a/tests/core/utilities/test_event_interface.py +++ b/tests/core/utilities/test_event_interface.py @@ -16,19 +16,19 @@ } -def test_access_event_with_no_abi(web3): - contract = web3.eth.contract() +def test_access_event_with_no_abi(w3): + contract = w3.eth.contract() with pytest.raises(NoABIEventsFound): contract.events.thisEventDoesNotExist() -def test_access_event_abi_with_no_events(web3): - contract = web3.eth.contract(abi=[]) +def test_access_event_abi_with_no_events(w3): + contract = w3.eth.contract(abi=[]) with pytest.raises(NoABIEventsFound): contract.events.thisEventDoesNotExist() -def test_access_nonexistent_event(web3): - contract = web3.eth.contract(abi=[EVENT_1_ABI]) +def test_access_nonexistent_event(w3): + contract = w3.eth.contract(abi=[EVENT_1_ABI]) with pytest.raises(MismatchedABI): contract.events.thisEventDoesNotExist() diff --git a/tests/core/utilities/test_fee_utils.py b/tests/core/utilities/test_fee_utils.py index 106b247a24..79f14913ff 100644 --- a/tests/core/utilities/test_fee_utils.py +++ b/tests/core/utilities/test_fee_utils.py @@ -39,7 +39,7 @@ ) # Test fee_utils indirectly by mocking eth_feeHistory results and checking against expected output def test_fee_utils_indirectly( - web3, fee_history_rewards, expected_max_prio_calc + w3, fee_history_rewards, expected_max_prio_calc ) -> None: fail_max_prio_middleware = construct_error_generator_middleware( {RPCEndpoint("eth_maxPriorityFeePerGas"): lambda *_: ''} @@ -48,18 +48,18 @@ def test_fee_utils_indirectly( {RPCEndpoint('eth_feeHistory'): lambda *_: {'reward': fee_history_rewards}} ) - web3.middleware_onion.add(fail_max_prio_middleware, 'fail_max_prio') - web3.middleware_onion.inject(fee_history_result_middleware, 'fee_history_result', layer=0) + w3.middleware_onion.add(fail_max_prio_middleware, 'fail_max_prio') + w3.middleware_onion.inject(fee_history_result_middleware, 'fee_history_result', layer=0) with pytest.warns( UserWarning, match="There was an issue with the method eth_maxPriorityFeePerGas. Calculating using " "eth_feeHistory." ): - max_priority_fee = web3.eth.max_priority_fee + max_priority_fee = w3.eth.max_priority_fee assert is_integer(max_priority_fee) assert max_priority_fee == expected_max_prio_calc # clean up - web3.middleware_onion.remove('fail_max_prio') - web3.middleware_onion.remove('fee_history_result') + w3.middleware_onion.remove('fail_max_prio') + w3.middleware_onion.remove('fee_history_result') diff --git a/tests/core/utilities/test_prepare_transaction_replacement.py b/tests/core/utilities/test_prepare_transaction_replacement.py index ffef3e7af0..cb0a84fd2e 100644 --- a/tests/core/utilities/test_prepare_transaction_replacement.py +++ b/tests/core/utilities/test_prepare_transaction_replacement.py @@ -12,14 +12,14 @@ } -def test_prepare_transaction_replacement(web3): +def test_prepare_transaction_replacement(w3): current_transaction = SIMPLE_CURRENT_TRANSACTION new_transaction = { 'value': 1, 'nonce': 2, } replacement_transaction = prepare_replacement_transaction( - web3, current_transaction, new_transaction) + w3, current_transaction, new_transaction) assert replacement_transaction == { 'value': 1, @@ -28,13 +28,13 @@ def test_prepare_transaction_replacement(web3): } -def test_prepare_transaction_replacement_without_nonce_sets_correct_nonce(web3): +def test_prepare_transaction_replacement_without_nonce_sets_correct_nonce(w3): current_transaction = SIMPLE_CURRENT_TRANSACTION new_transaction = { 'value': 1, } replacement_transaction = prepare_replacement_transaction( - web3, current_transaction, new_transaction) + w3, current_transaction, new_transaction) assert replacement_transaction == { 'value': 1, 'nonce': 2, @@ -42,15 +42,15 @@ def test_prepare_transaction_replacement_without_nonce_sets_correct_nonce(web3): } -def test_prepare_transaction_replacement_already_mined_raises(web3): +def test_prepare_transaction_replacement_already_mined_raises(w3): with pytest.raises(ValueError): prepare_replacement_transaction( - web3, {'blockHash': '0xa1a1a1', 'hash': '0x0'}, {'value': 2}) + w3, {'blockHash': '0xa1a1a1', 'hash': '0x0'}, {'value': 2}) -def test_prepare_transaction_replacement_nonce_mismatch_raises(web3): +def test_prepare_transaction_replacement_nonce_mismatch_raises(w3): with pytest.raises(ValueError): - prepare_replacement_transaction(web3, { + prepare_replacement_transaction(w3, { 'blockHash': None, 'hash': '0x0', 'nonce': 1, @@ -59,7 +59,7 @@ def test_prepare_transaction_replacement_nonce_mismatch_raises(web3): }) -def test_prepare_transaction_replacement_not_higher_gas_price_raises(web3): +def test_prepare_transaction_replacement_not_higher_gas_price_raises(w3): current_transaction = SIMPLE_CURRENT_TRANSACTION new_transaction = { 'value': 1, @@ -67,31 +67,31 @@ def test_prepare_transaction_replacement_not_higher_gas_price_raises(web3): } with pytest.raises(ValueError): prepare_replacement_transaction( - web3, current_transaction, new_transaction) + w3, current_transaction, new_transaction) # Also raises when equal to the current transaction new_transaction['gasPrice'] = 10 with pytest.raises(ValueError): - prepare_replacement_transaction(web3, current_transaction, new_transaction) + prepare_replacement_transaction(w3, current_transaction, new_transaction) -def test_prepare_transaction_replacement_gas_price_defaulting(web3): +def test_prepare_transaction_replacement_gas_price_defaulting(w3): current_transaction = SIMPLE_CURRENT_TRANSACTION new_transaction = { 'value': 2, } replacement_transaction = prepare_replacement_transaction( - web3, current_transaction, new_transaction) + w3, current_transaction, new_transaction) assert replacement_transaction['gasPrice'] == 12 -def test_prepare_transaction_replacement_gas_price_defaulting_when_strategy_higer(web3): +def test_prepare_transaction_replacement_gas_price_defaulting_when_strategy_higer(w3): - def higher_gas_price_strategy(web3, txn): + def higher_gas_price_strategy(w3, txn): return 20 - web3.eth.set_gas_price_strategy(higher_gas_price_strategy) + w3.eth.set_gas_price_strategy(higher_gas_price_strategy) current_transaction = SIMPLE_CURRENT_TRANSACTION new_transaction = { @@ -99,17 +99,17 @@ def higher_gas_price_strategy(web3, txn): } replacement_transaction = prepare_replacement_transaction( - web3, current_transaction, new_transaction) + w3, current_transaction, new_transaction) assert replacement_transaction['gasPrice'] == 20 -def test_prepare_transaction_replacement_gas_price_defaulting_when_strategy_lower(web3): +def test_prepare_transaction_replacement_gas_price_defaulting_when_strategy_lower(w3): - def lower_gas_price_strategy(web3, txn): + def lower_gas_price_strategy(w3, txn): return 5 - web3.eth.set_gas_price_strategy(lower_gas_price_strategy) + w3.eth.set_gas_price_strategy(lower_gas_price_strategy) current_transaction = SIMPLE_CURRENT_TRANSACTION new_transaction = { @@ -117,6 +117,6 @@ def lower_gas_price_strategy(web3, txn): } replacement_transaction = prepare_replacement_transaction( - web3, current_transaction, new_transaction) + w3, current_transaction, new_transaction) assert replacement_transaction['gasPrice'] == 12 diff --git a/tests/core/utilities/test_valid_transaction_params.py b/tests/core/utilities/test_valid_transaction_params.py index 4424efa00b..0ae866bce1 100644 --- a/tests/core/utilities/test_valid_transaction_params.py +++ b/tests/core/utilities/test_valid_transaction_params.py @@ -136,16 +136,16 @@ def test_extract_valid_transaction_params_includes_invalid(): } -def test_fill_transaction_defaults_for_all_params(web3): - default_transaction = fill_transaction_defaults(web3, {}) +def test_fill_transaction_defaults_for_all_params(w3): + default_transaction = fill_transaction_defaults(w3, {}) assert default_transaction == { - 'chainId': web3.eth.chain_id, + 'chainId': w3.eth.chain_id, 'data': b'', - 'gas': web3.eth.estimate_gas({}), + 'gas': w3.eth.estimate_gas({}), 'maxFeePerGas': ( - web3.eth.max_priority_fee + (2 * web3.eth.get_block('latest')['baseFeePerGas']) + w3.eth.max_priority_fee + (2 * w3.eth.get_block('latest')['baseFeePerGas']) ), - 'maxPriorityFeePerGas': web3.eth.max_priority_fee, + 'maxPriorityFeePerGas': w3.eth.max_priority_fee, 'value': 0, } diff --git a/tests/core/web3-module/test_api.py b/tests/core/web3-module/test_api.py index d5ccdd84cb..97bbd32f1b 100644 --- a/tests/core/web3-module/test_api.py +++ b/tests/core/web3-module/test_api.py @@ -1,2 +1,2 @@ -def test_web3_api(web3): - assert web3.api.startswith("6") +def test_web3_api(w3): + assert w3.api.startswith("6") diff --git a/tests/core/web3-module/test_attach_modules.py b/tests/core/web3-module/test_attach_modules.py index 35f575cb06..42b453b3d4 100644 --- a/tests/core/web3-module/test_attach_modules.py +++ b/tests/core/web3-module/test_attach_modules.py @@ -8,8 +8,8 @@ ) -def test_attach_modules(web3, module1, module2, module3, module4): - web3.attach_modules({ +def test_attach_modules(w3, module1, module2, module3, module4): + w3.attach_modules({ 'module1': module1, 'module2': (module2, { 'submodule1': (module3, { @@ -19,30 +19,30 @@ def test_attach_modules(web3, module1, module2, module3, module4): }) # assert module1 attached - assert hasattr(web3, 'module1') - assert web3.module1.a == 'a' - assert web3.module1.b == 'b' + assert hasattr(w3, 'module1') + assert w3.module1.a == 'a' + assert w3.module1.b == 'b' # assert module2 + submodules attached - assert hasattr(web3, 'module2') - assert web3.module2.c == 'c' - assert web3.module2.d() == 'd' + assert hasattr(w3, 'module2') + assert w3.module2.c == 'c' + assert w3.module2.d() == 'd' - assert hasattr(web3.module2, 'submodule1') - assert web3.module2.submodule1.e == 'e' - assert hasattr(web3.module2.submodule1, 'submodule2') - assert web3.module2.submodule1.submodule2.f == 'f' + assert hasattr(w3.module2, 'submodule1') + assert w3.module2.submodule1.e == 'e' + assert hasattr(w3.module2.submodule1, 'submodule2') + assert w3.module2.submodule1.submodule2.f == 'f' # assert default modules intact - assert hasattr(web3, 'geth') - assert hasattr(web3, 'eth') - assert is_integer(web3.eth.chain_id) + assert hasattr(w3, 'geth') + assert hasattr(w3, 'eth') + assert is_integer(w3.eth.chain_id) def test_attach_modules_that_do_not_inherit_from_module_class( - web3, module1_unique, module2_unique, module3_unique, module4_unique, + w3, module1_unique, module2_unique, module3_unique, module4_unique, ): - web3.attach_modules( + w3.attach_modules( { 'module1': module1_unique, 'module2': (module2_unique, { @@ -54,28 +54,28 @@ def test_attach_modules_that_do_not_inherit_from_module_class( ) # assert module1 attached - assert hasattr(web3, 'module1') - assert web3.module1.a == 'a' - assert web3.module1.b() == 'b' - assert web3.module1.return_eth_chain_id == web3.eth.chain_id + assert hasattr(w3, 'module1') + assert w3.module1.a == 'a' + assert w3.module1.b() == 'b' + assert w3.module1.return_eth_chain_id == w3.eth.chain_id # assert module2 + submodules attached - assert hasattr(web3, 'module2') - assert web3.module2.c == 'c' - assert web3.module2.d() == 'd' + assert hasattr(w3, 'module2') + assert w3.module2.c == 'c' + assert w3.module2.d() == 'd' - assert hasattr(web3.module2, 'submodule1') - assert web3.module2.submodule1.e == 'e' - assert hasattr(web3.module2.submodule1, 'submodule2') - assert web3.module2.submodule1.submodule2.f == 'f' + assert hasattr(w3.module2, 'submodule1') + assert w3.module2.submodule1.e == 'e' + assert hasattr(w3.module2.submodule1, 'submodule2') + assert w3.module2.submodule1.submodule2.f == 'f' # assert default modules intact - assert hasattr(web3, 'geth') - assert hasattr(web3, 'eth') - assert is_integer(web3.eth.chain_id) + assert hasattr(w3, 'geth') + assert hasattr(w3, 'eth') + assert is_integer(w3.eth.chain_id) -def test_attach_modules_for_module_with_more_than_one_init_argument(web3, module_many_init_args): +def test_attach_modules_for_module_with_more_than_one_init_argument(w3, module_many_init_args): with pytest.raises( UnsupportedOperation, match=( @@ -83,4 +83,4 @@ def test_attach_modules_for_module_with_more_than_one_init_argument(web3, module "__init__\\(\\) method. More than one argument found for ModuleManyArgs: \\['a', 'b']" ) ): - web3.attach_modules({'module_should_fail': module_many_init_args}) + w3.attach_modules({'module_should_fail': module_many_init_args}) diff --git a/tests/core/web3-module/test_clientVersion.py b/tests/core/web3-module/test_clientVersion.py index 4f2783adcf..2d117b1af2 100644 --- a/tests/core/web3-module/test_clientVersion.py +++ b/tests/core/web3-module/test_clientVersion.py @@ -1,2 +1,2 @@ -def test_web3_clientVersion(web3): - assert web3.clientVersion.startswith("EthereumTester/") +def test_web3_clientVersion(w3): + assert w3.clientVersion.startswith("EthereumTester/") diff --git a/tests/core/web3-module/test_providers.py b/tests/core/web3-module/test_providers.py index 92069c71a9..c4612d77d8 100644 --- a/tests/core/web3-module/test_providers.py +++ b/tests/core/web3-module/test_providers.py @@ -7,12 +7,12 @@ ) -def test_set_provider(web3): +def test_set_provider(w3): provider = EthereumTesterProvider() - web3.provider = provider + w3.provider = provider - assert web3.provider == provider + assert w3.provider == provider def test_auto_provider_none(): diff --git a/tests/ens/conftest.py b/tests/ens/conftest.py index 88c58cd2f6..7a3d2044dd 100644 --- a/tests/ens/conftest.py +++ b/tests/ens/conftest.py @@ -220,7 +220,7 @@ def ens_setup(): @pytest.fixture def ens(ens_setup, mocker): mocker.patch('web3.middleware.stalecheck._isfresh', return_value=True) - ens_setup.web3.eth.default_account = ens_setup.web3.eth.coinbase + ens_setup.w3.eth.default_account = ens_setup.w3.eth.coinbase return ens_setup diff --git a/tests/ens/test_ens.py b/tests/ens/test_ens.py index d4febe2c1a..ae552f2785 100644 --- a/tests/ens/test_ens.py +++ b/tests/ens/test_ens.py @@ -4,9 +4,9 @@ ) -def test_fromWeb3_inherits_web3_middlewares(web3): +def test_fromWeb3_inherits_web3_middlewares(w3): test_middleware = pythonic_middleware - web3.middleware_onion.add(test_middleware, 'test_middleware') + w3.middleware_onion.add(test_middleware, 'test_middleware') - ns = ENS.fromWeb3(web3) - assert ns.web3.middleware_onion.get('test_middleware') == test_middleware + ns = ENS.fromWeb3(w3) + assert ns.w3.middleware_onion.get('test_middleware') == test_middleware diff --git a/tests/ens/test_setup_address.py b/tests/ens/test_setup_address.py index fb5df1d309..326161989b 100644 --- a/tests/ens/test_setup_address.py +++ b/tests/ens/test_setup_address.py @@ -112,7 +112,7 @@ def test_set_address_equivalence(ens, name, equivalent, TEST_ADDRESS): ], ) def test_set_address_noop(ens, set_address): - eth = ens.web3.eth + eth = ens.w3.eth owner = ens.owner('tester.eth') ens.setup_address('noop.tester.eth', set_address) starting_transactions = eth.get_transaction_count(owner) @@ -152,7 +152,7 @@ def getowner(name): def test_set_resolver_leave_default(ens, TEST_ADDRESS): owner = ens.owner('tester.eth') ens.setup_address('leave-default-resolver.tester.eth', TEST_ADDRESS) - eth = ens.web3.eth + eth = ens.w3.eth num_transactions = eth.get_transaction_count(owner) ens.setup_address( diff --git a/tests/ens/test_setup_name.py b/tests/ens/test_setup_name.py index a550ebfb64..26fb0a7e3b 100644 --- a/tests/ens/test_setup_name.py +++ b/tests/ens/test_setup_name.py @@ -55,7 +55,7 @@ def TEST_ADDRESS(address_conversion_func): ], ) def test_setup_name(ens, name, normalized_name, namehash_hex): - address = ens.web3.eth.accounts[3] + address = ens.w3.eth.accounts[3] assert not ens.name(address) owner = ens.owner('tester.eth') @@ -84,7 +84,7 @@ def test_cannot_set_name_on_mismatch_address(ens, TEST_ADDRESS): def test_setup_name_default_address(ens): name = 'reverse-defaults-to-forward.tester.eth' owner = ens.owner('tester.eth') - new_resolution = ens.web3.eth.accounts[-1] + new_resolution = ens.w3.eth.accounts[-1] ens.setup_address(name, new_resolution) assert not ens.name(new_resolution) assert ens.owner(name) == owner @@ -96,7 +96,7 @@ def test_setup_name_default_address(ens): def test_setup_name_default_to_owner(ens): name = 'reverse-defaults-to-owner.tester.eth' - new_owner = ens.web3.eth.accounts[-1] + new_owner = ens.w3.eth.accounts[-1] ens.setup_owner(name, new_owner) assert not ens.name(new_owner) assert ens.owner(name) == new_owner @@ -118,10 +118,10 @@ def test_setup_name_unauthorized(ens, TEST_ADDRESS): def test_setup_reverse_dict_unmodified(ens): # setup owner = ens.owner('tester.eth') - eth = ens.web3.eth + eth = ens.w3.eth start_count = eth.get_transaction_count(owner) - address = ens.web3.eth.accounts[3] + address = ens.w3.eth.accounts[3] transact = {} ens.setup_name('tester.eth', address, transact=transact) diff --git a/tests/integration/common.py b/tests/integration/common.py index e97aabae0c..218d9a4291 100644 --- a/tests/integration/common.py +++ b/tests/integration/common.py @@ -9,7 +9,7 @@ class MiscWebsocketTest: - def test_websocket_max_size_error(self, web3, endpoint_uri): + def test_websocket_max_size_error(self, w3, endpoint_uri): w3 = Web3(Web3.WebsocketProvider( endpoint_uri=endpoint_uri, websocket_kwargs={'max_size': 1}) ) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index dd254c6876..c9671aa285 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -16,22 +16,22 @@ @pytest.fixture(scope="module") -def math_contract_factory(web3): - contract_factory = web3.eth.contract(abi=MATH_ABI, bytecode=MATH_BYTECODE) +def math_contract_factory(w3): + contract_factory = w3.eth.contract(abi=MATH_ABI, bytecode=MATH_BYTECODE) return contract_factory @pytest.fixture(scope="module") -def emitter_contract_factory(web3): - contract_factory = web3.eth.contract( +def emitter_contract_factory(w3): + contract_factory = w3.eth.contract( abi=CONTRACT_EMITTER_ABI, bytecode=CONTRACT_EMITTER_CODE ) return contract_factory @pytest.fixture(scope="module") -def revert_contract_factory(web3): - contract_factory = web3.eth.contract( +def revert_contract_factory(w3): + contract_factory = w3.eth.contract( abi=_REVERT_CONTRACT_ABI, bytecode=REVERT_CONTRACT_BYTECODE ) return contract_factory diff --git a/tests/integration/generate_fixtures/common.py b/tests/integration/generate_fixtures/common.py index 49ac85b8a2..d7d20a8964 100644 --- a/tests/integration/generate_fixtures/common.py +++ b/tests/integration/generate_fixtures/common.py @@ -201,15 +201,15 @@ def get_process(run_command): return proc -def mine_block(web3): - origin_block_number = web3.eth.block_number +def mine_block(w3): + origin_block_number = w3.eth.block_number start_time = time.time() - web3.geth.miner.start(1) + w3.geth.miner.start(1) while time.time() < start_time + 120: - block_number = web3.eth.block_number + block_number = w3.eth.block_number if block_number > origin_block_number: - web3.geth.miner.stop() + w3.geth.miner.stop() return block_number else: time.sleep(0.1) @@ -217,16 +217,16 @@ def mine_block(web3): raise ValueError("No block mined during wait period") -def mine_transaction_hash(web3, txn_hash): +def mine_transaction_hash(w3, txn_hash): start_time = time.time() - web3.geth.miner.start(1) + w3.geth.miner.start(1) while time.time() < start_time + 120: try: - receipt = web3.eth.get_transaction_receipt(txn_hash) + receipt = w3.eth.get_transaction_receipt(txn_hash) except TransactionNotFound: continue if receipt is not None: - web3.geth.miner.stop() + w3.geth.miner.stop() return receipt else: time.sleep(0.1) @@ -234,11 +234,11 @@ def mine_transaction_hash(web3, txn_hash): raise ValueError("Math contract deploy transaction not mined during wait period") -def deploy_contract(web3, name, factory): - web3.geth.personal.unlock_account(web3.eth.coinbase, KEYFILE_PW) - deploy_txn_hash = factory.constructor().transact({'from': web3.eth.coinbase}) +def deploy_contract(w3, name, factory): + w3.geth.personal.unlock_account(w3.eth.coinbase, KEYFILE_PW) + deploy_txn_hash = factory.constructor().transact({'from': w3.eth.coinbase}) print('{0}_CONTRACT_DEPLOY_HASH: '.format(name.upper()), deploy_txn_hash) - deploy_receipt = mine_transaction_hash(web3, deploy_txn_hash) + deploy_receipt = mine_transaction_hash(w3, deploy_txn_hash) print('{0}_CONTRACT_DEPLOY_TRANSACTION_MINED'.format(name.upper())) contract_address = deploy_receipt['contractAddress'] assert is_checksum_address(contract_address) diff --git a/tests/integration/generate_fixtures/go_ethereum.py b/tests/integration/generate_fixtures/go_ethereum.py index 41ff0682e0..d6d55b7ee2 100644 --- a/tests/integration/generate_fixtures/go_ethereum.py +++ b/tests/integration/generate_fixtures/go_ethereum.py @@ -136,11 +136,11 @@ def generate_go_ethereum_fixture(destination_dir): geth_port=geth_port): common.wait_for_socket(geth_ipc_path) - web3 = Web3(Web3.IPCProvider(geth_ipc_path)) - chain_data = setup_chain_state(web3) + w3 = Web3(Web3.IPCProvider(geth_ipc_path)) + chain_data = setup_chain_state(w3) # close geth by exiting context # must be closed before copying data dir - verify_chain_state(web3, chain_data) + verify_chain_state(w3, chain_data) # verify that chain state is still valid after closing # and re-opening geth @@ -152,8 +152,8 @@ def generate_go_ethereum_fixture(destination_dir): geth_port=geth_port): common.wait_for_socket(geth_ipc_path) - web3 = Web3(Web3.IPCProvider(geth_ipc_path)) - verify_chain_state(web3, chain_data) + w3 = Web3(Web3.IPCProvider(geth_ipc_path)) + verify_chain_state(w3, chain_data) static_data = { 'raw_txn_account': common.RAW_TXN_ACCOUNT, @@ -166,29 +166,29 @@ def generate_go_ethereum_fixture(destination_dir): shutil.make_archive(destination_dir, 'zip', datadir) -def verify_chain_state(web3, chain_data): - receipt = web3.eth.wait_for_transaction_receipt(chain_data['mined_txn_hash']) - latest = web3.eth.get_block('latest') +def verify_chain_state(w3, chain_data): + receipt = w3.eth.wait_for_transaction_receipt(chain_data['mined_txn_hash']) + latest = w3.eth.get_block('latest') assert receipt.blockNumber <= latest.number -def mine_transaction_hash(web3, txn_hash): - web3.geth.miner.start(1) +def mine_transaction_hash(w3, txn_hash): + w3.geth.miner.start(1) try: - return web3.eth.wait_for_transaction_receipt(txn_hash, timeout=120) + return w3.eth.wait_for_transaction_receipt(txn_hash, timeout=120) finally: - web3.geth.miner.stop() + w3.geth.miner.stop() -def mine_block(web3): - origin_block_number = web3.eth.block_number +def mine_block(w3): + origin_block_number = w3.eth.block_number start_time = time.time() - web3.geth.miner.start(1) + w3.geth.miner.start(1) while time.time() < start_time + 120: - block_number = web3.eth.block_number + block_number = w3.eth.block_number if block_number > origin_block_number: - web3.geth.miner.stop() + w3.geth.miner.stop() return block_number else: time.sleep(0.1) @@ -196,77 +196,77 @@ def mine_block(web3): raise ValueError("No block mined during wait period") -def setup_chain_state(web3): - coinbase = web3.eth.coinbase +def setup_chain_state(w3): + coinbase = w3.eth.coinbase assert is_same_address(coinbase, common.COINBASE) # # Math Contract # - math_contract_factory = web3.eth.contract( + math_contract_factory = w3.eth.contract( abi=MATH_ABI, bytecode=MATH_BYTECODE, ) - math_deploy_receipt = common.deploy_contract(web3, 'math', math_contract_factory) + math_deploy_receipt = common.deploy_contract(w3, 'math', math_contract_factory) assert is_dict(math_deploy_receipt) # # Emitter Contract # - emitter_contract_factory = web3.eth.contract( + emitter_contract_factory = w3.eth.contract( abi=CONTRACT_EMITTER_ABI, bytecode=CONTRACT_EMITTER_CODE, ) - emitter_deploy_receipt = common.deploy_contract(web3, 'emitter', emitter_contract_factory) + emitter_deploy_receipt = common.deploy_contract(w3, 'emitter', emitter_contract_factory) emitter_contract = emitter_contract_factory(emitter_deploy_receipt['contractAddress']) txn_hash_with_log = emitter_contract.functions.logDouble( which=EMITTER_ENUM['LogDoubleWithIndex'], arg0=12345, arg1=54321, ).transact({ - 'from': web3.eth.coinbase, + 'from': w3.eth.coinbase, }) print('TXN_HASH_WITH_LOG:', txn_hash_with_log) - txn_receipt_with_log = mine_transaction_hash(web3, txn_hash_with_log) - block_with_log = web3.eth.get_block(txn_receipt_with_log['blockHash']) + txn_receipt_with_log = mine_transaction_hash(w3, txn_hash_with_log) + block_with_log = w3.eth.get_block(txn_receipt_with_log['blockHash']) print('BLOCK_HASH_WITH_LOG:', block_with_log['hash']) # # Revert Contract # - revert_contract_factory = web3.eth.contract( + revert_contract_factory = w3.eth.contract( abi=_REVERT_CONTRACT_ABI, bytecode=REVERT_CONTRACT_BYTECODE, ) - revert_deploy_receipt = common.deploy_contract(web3, 'revert', revert_contract_factory) + revert_deploy_receipt = common.deploy_contract(w3, 'revert', revert_contract_factory) revert_contract = revert_contract_factory(revert_deploy_receipt['contractAddress']) txn_hash_normal_function = revert_contract.functions.normalFunction().transact( - {'gas': 320000, 'from': web3.eth.coinbase} + {'gas': 320000, 'from': w3.eth.coinbase} ) print('TXN_HASH_REVERT_NORMAL:', txn_hash_normal_function) txn_hash_revert_with_msg = revert_contract.functions.revertWithMessage().transact( - {'gas': 320000, 'from': web3.eth.coinbase} + {'gas': 320000, 'from': w3.eth.coinbase} ) print('TXN_HASH_REVERT_WITH_MSG:', txn_hash_revert_with_msg) - txn_receipt_revert_with_msg = common.mine_transaction_hash(web3, txn_hash_revert_with_msg) - block_hash_revert_with_msg = web3.eth.get_block(txn_receipt_revert_with_msg['blockHash']) + txn_receipt_revert_with_msg = common.mine_transaction_hash(w3, txn_hash_revert_with_msg) + block_hash_revert_with_msg = w3.eth.get_block(txn_receipt_revert_with_msg['blockHash']) print('BLOCK_HASH_REVERT_WITH_MSG:', block_hash_revert_with_msg['hash']) txn_hash_revert_with_no_msg = revert_contract.functions.revertWithoutMessage().transact( - {'gas': 320000, 'from': web3.eth.coinbase} + {'gas': 320000, 'from': w3.eth.coinbase} ) print('TXN_HASH_REVERT_WITH_NO_MSG:', txn_hash_revert_with_no_msg) - txn_receipt_revert_with_no_msg = common.mine_transaction_hash(web3, txn_hash_revert_with_no_msg) - block_hash_revert_no_msg = web3.eth.get_block(txn_receipt_revert_with_no_msg['blockHash']) + txn_receipt_revert_with_no_msg = common.mine_transaction_hash(w3, txn_hash_revert_with_no_msg) + block_hash_revert_no_msg = w3.eth.get_block(txn_receipt_revert_with_no_msg['blockHash']) print('BLOCK_HASH_REVERT_NO_MSG:', block_hash_revert_no_msg['hash']) # # Empty Block # - empty_block_number = mine_block(web3) + empty_block_number = mine_block(w3) print('MINED_EMPTY_BLOCK') - empty_block = web3.eth.get_block(empty_block_number) + empty_block = w3.eth.get_block(empty_block_number) assert is_dict(empty_block) assert not empty_block['transactions'] print('EMPTY_BLOCK_HASH:', empty_block['hash']) @@ -274,18 +274,18 @@ def setup_chain_state(web3): # # Block with Transaction # - web3.geth.personal.unlock_account(coinbase, common.KEYFILE_PW) - web3.geth.miner.start(1) - mined_txn_hash = web3.eth.send_transaction({ + w3.geth.personal.unlock_account(coinbase, common.KEYFILE_PW) + w3.geth.miner.start(1) + mined_txn_hash = w3.eth.send_transaction({ 'from': coinbase, 'to': coinbase, 'value': 1, 'gas': 21000, - 'gas_price': web3.eth.gas_price, + 'gas_price': w3.eth.gas_price, }) - mined_txn_receipt = mine_transaction_hash(web3, mined_txn_hash) + mined_txn_receipt = mine_transaction_hash(w3, mined_txn_hash) print('MINED_TXN_HASH:', mined_txn_hash) - block_with_txn = web3.eth.get_block(mined_txn_receipt['blockHash']) + block_with_txn = w3.eth.get_block(mined_txn_receipt['blockHash']) print('BLOCK_WITH_TXN_HASH:', block_with_txn['hash']) geth_fixture = { diff --git a/tests/integration/go_ethereum/common.py b/tests/integration/go_ethereum/common.py index 86448bff46..914160dd04 100644 --- a/tests/integration/go_ethereum/common.py +++ b/tests/integration/go_ethereum/common.py @@ -21,34 +21,34 @@ def _check_web3_clientVersion(self, client_version): class GoEthereumEthModuleTest(EthModuleTest): @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) + def test_eth_sign_typed_data(self, w3, unlocked_account_dual_type): + super().test_eth_sign_typed_data(w3, unlocked_account_dual_type) @pytest.mark.xfail(reason='eth_signTypedData has not been released in geth') - def test_eth_signTypedData_deprecated(self, web3, unlocked_account_dual_type): - super().test_eth_signTypedData_deprecated(web3, unlocked_account_dual_type) + def test_eth_signTypedData_deprecated(self, w3, unlocked_account_dual_type): + super().test_eth_signTypedData_deprecated(w3, unlocked_account_dual_type) @pytest.mark.xfail(reason='eth_signTypedData has not been released in geth') - 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) + def test_invalid_eth_sign_typed_data(self, w3, unlocked_account_dual_type): + super().test_invalid_eth_sign_typed_data(w3, 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) + def test_eth_protocol_version(self, w3): + super().test_eth_protocol_version(w3) @pytest.mark.xfail(reason='eth_protocolVersion was removed in Geth 1.10.0') - def test_eth_protocolVersion(self, web3): - super().test_eth_protocolVersion(web3) + def test_eth_protocolVersion(self, w3): + super().test_eth_protocolVersion(w3) class GoEthereumVersionModuleTest(VersionModuleTest): @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) + def test_eth_protocol_version(self, w3): + super().test_eth_protocol_version(w3) @pytest.mark.xfail(reason='eth_protocolVersion was removed in Geth 1.10.0') - def test_eth_protocolVersion(self, web3): - super().test_eth_protocolVersion(web3) + def test_eth_protocolVersion(self, w3): + super().test_eth_protocolVersion(w3) class GoEthereumNetModuleTest(NetModuleTest): diff --git a/tests/integration/go_ethereum/conftest.py b/tests/integration/go_ethereum/conftest.py index 59934890c7..0862c47aa1 100644 --- a/tests/integration/go_ethereum/conftest.py +++ b/tests/integration/go_ethereum/conftest.py @@ -130,8 +130,8 @@ def geth_process(geth_binary, datadir, genesis_file, geth_command_arguments): @pytest.fixture(scope='module') -def coinbase(web3): - return web3.eth.coinbase +def coinbase(w3): + return w3.eth.coinbase @pytest.fixture(scope="module") @@ -140,7 +140,7 @@ def math_contract_deploy_txn_hash(geth_fixture_data): @pytest.fixture(scope="module") -def math_contract(web3, math_contract_factory, geth_fixture_data): +def math_contract(math_contract_factory, geth_fixture_data): return math_contract_factory(address=geth_fixture_data['math_address']) @@ -150,7 +150,7 @@ def math_contract_address(math_contract, address_conversion_func): @pytest.fixture(scope="module") -def emitter_contract(web3, emitter_contract_factory, geth_fixture_data): +def emitter_contract(emitter_contract_factory, geth_fixture_data): return emitter_contract_factory(address=geth_fixture_data['emitter_address']) @@ -160,10 +160,10 @@ def emitter_contract_address(emitter_contract, address_conversion_func): @pytest.fixture -def unlocked_account(web3, unlockable_account, unlockable_account_pw): - web3.geth.personal.unlock_account(unlockable_account, unlockable_account_pw) +def unlocked_account(w3, unlockable_account, unlockable_account_pw): + w3.geth.personal.unlock_account(unlockable_account, unlockable_account_pw) yield unlockable_account - web3.geth.personal.lock_account(unlockable_account) + w3.geth.personal.lock_account(unlockable_account) @pytest.fixture(scope='module') @@ -172,7 +172,7 @@ def unlockable_account_pw(geth_fixture_data): @pytest.fixture(scope="module") -def unlockable_account(web3, coinbase): +def unlockable_account(coinbase): yield coinbase @@ -182,10 +182,10 @@ def unlockable_account_dual_type(unlockable_account, address_conversion_func): @pytest.fixture -def unlocked_account_dual_type(web3, unlockable_account_dual_type, unlockable_account_pw): - web3.geth.personal.unlock_account(unlockable_account_dual_type, unlockable_account_pw) +def unlocked_account_dual_type(w3, unlockable_account_dual_type, unlockable_account_pw): + w3.geth.personal.unlock_account(unlockable_account_dual_type, unlockable_account_pw) yield unlockable_account_dual_type - web3.geth.personal.lock_account(unlockable_account_dual_type) + w3.geth.personal.lock_account(unlockable_account_dual_type) @pytest.fixture(scope="module") @@ -196,15 +196,15 @@ def funded_account_for_raw_txn(geth_fixture_data): @pytest.fixture(scope="module") -def empty_block(web3, geth_fixture_data): - block = web3.eth.get_block(geth_fixture_data['empty_block_hash']) +def empty_block(w3, geth_fixture_data): + block = w3.eth.get_block(geth_fixture_data['empty_block_hash']) assert is_dict(block) return block @pytest.fixture(scope="module") -def block_with_txn(web3, geth_fixture_data): - block = web3.eth.get_block(geth_fixture_data['block_with_txn_hash']) +def block_with_txn(w3, geth_fixture_data): + block = w3.eth.get_block(geth_fixture_data['block_with_txn_hash']) assert is_dict(block) return block @@ -215,8 +215,8 @@ def mined_txn_hash(geth_fixture_data): @pytest.fixture(scope="module") -def block_with_txn_with_log(web3, geth_fixture_data): - block = web3.eth.get_block(geth_fixture_data['block_hash_with_log']) +def block_with_txn_with_log(w3, geth_fixture_data): + block = w3.eth.get_block(geth_fixture_data['block_hash_with_log']) assert is_dict(block) return block @@ -237,5 +237,5 @@ def block_hash_revert_with_msg(geth_fixture_data): @pytest.fixture(scope="module") -def revert_contract(web3, revert_contract_factory, geth_fixture_data): +def revert_contract(revert_contract_factory, geth_fixture_data): return revert_contract_factory(address=geth_fixture_data['revert_address']) diff --git a/tests/integration/go_ethereum/test_goethereum_http.py b/tests/integration/go_ethereum/test_goethereum_http.py index a3ea078cac..53a624faad 100644 --- a/tests/integration/go_ethereum/test_goethereum_http.py +++ b/tests/integration/go_ethereum/test_goethereum_http.py @@ -90,16 +90,16 @@ def geth_command_arguments(rpc_port, @pytest.fixture(scope="module") -def web3(geth_process, endpoint_uri): +def w3(geth_process, endpoint_uri): wait_for_http(endpoint_uri) - _web3 = Web3(Web3.HTTPProvider(endpoint_uri)) - return _web3 + _w3 = Web3(Web3.HTTPProvider(endpoint_uri)) + return _w3 @pytest_asyncio.fixture(scope="module") async def async_w3(geth_process, endpoint_uri): await wait_for_aiohttp(endpoint_uri) - _web3 = Web3( + _w3 = Web3( AsyncHTTPProvider(endpoint_uri), middlewares=[ async_buffered_gas_estimate_middleware, @@ -115,7 +115,7 @@ async def async_w3(geth_process, endpoint_uri): ) } ) - return _web3 + return _w3 class TestGoEthereumTest(GoEthereumTest): @@ -124,37 +124,37 @@ class TestGoEthereumTest(GoEthereumTest): class TestGoEthereumAdminModuleTest(GoEthereumAdminModuleTest): @pytest.mark.xfail(reason="running geth with the --nodiscover flag doesn't allow peer addition") - def test_admin_peers(self, web3: "Web3") -> None: - super().test_admin_peers(web3) + def test_admin_peers(self, w3: "Web3") -> None: + super().test_admin_peers(w3) - def test_admin_start_stop_rpc(self, web3: "Web3") -> None: + def test_admin_start_stop_rpc(self, w3: "Web3") -> None: # This test causes all tests after it to fail on CI if it's allowed to run pytest.xfail(reason='Only one RPC endpoint is allowed to be active at any time') - super().test_admin_start_stop_rpc(web3) + super().test_admin_start_stop_rpc(w3) - def test_admin_start_stop_ws(self, web3: "Web3") -> None: + def test_admin_start_stop_ws(self, w3: "Web3") -> None: # This test causes all tests after it to fail on CI if it's allowed to run pytest.xfail(reason='Only one WS endpoint is allowed to be active at any time') - super().test_admin_start_stop_ws(web3) + super().test_admin_start_stop_ws(w3) class TestGoEthereumAsyncAdminModuleTest(GoEthereumAsyncAdminModuleTest): @pytest.mark.asyncio @pytest.mark.xfail(reason="running geth with the --nodiscover flag doesn't allow peer addition") - async def test_admin_peers(self, web3: "Web3") -> None: - await super().test_admin_peers(web3) + async def test_admin_peers(self, w3: "Web3") -> None: + await super().test_admin_peers(w3) @pytest.mark.asyncio - async def test_admin_start_stop_rpc(self, web3: "Web3") -> None: + async def test_admin_start_stop_rpc(self, w3: "Web3") -> None: # This test causes all tests after it to fail on CI if it's allowed to run pytest.xfail(reason='Only one RPC endpoint is allowed to be active at any time') - await super().test_admin_start_stop_rpc(web3) + await super().test_admin_start_stop_rpc(w3) @pytest.mark.asyncio - async def test_admin_start_stop_ws(self, web3: "Web3") -> None: + async def test_admin_start_stop_ws(self, w3: "Web3") -> None: # This test causes all tests after it to fail on CI if it's allowed to run pytest.xfail(reason='Only one WS endpoint is allowed to be active at any time') - await super().test_admin_start_stop_ws(web3) + await super().test_admin_start_stop_ws(w3) class TestGoEthereumEthModuleTest(GoEthereumEthModuleTest): diff --git a/tests/integration/go_ethereum/test_goethereum_ipc.py b/tests/integration/go_ethereum/test_goethereum_ipc.py index 367cda1929..6799e08f0d 100644 --- a/tests/integration/go_ethereum/test_goethereum_ipc.py +++ b/tests/integration/go_ethereum/test_goethereum_ipc.py @@ -52,10 +52,10 @@ def geth_ipc_path(datadir): @pytest.fixture(scope="module") -def web3(geth_process, geth_ipc_path): +def w3(geth_process, geth_ipc_path): wait_for_socket(geth_ipc_path) - _web3 = Web3(Web3.IPCProvider(geth_ipc_path, timeout=30)) - return _web3 + _w3 = Web3(Web3.IPCProvider(geth_ipc_path, timeout=30)) + return _w3 class TestGoEthereumTest(GoEthereumTest): @@ -64,12 +64,12 @@ class TestGoEthereumTest(GoEthereumTest): class TestGoEthereumAdminModuleTest(GoEthereumAdminModuleTest): @pytest.mark.xfail(reason="running geth with the --nodiscover flag doesn't allow peer addition") - def test_admin_peers(web3): - super().test_admin_peers(web3) + def test_admin_peers(w3): + super().test_admin_peers(w3) @pytest.mark.xfail(reason="websockets aren't enabled with our IPC flags") - def test_admin_start_stop_ws(web3): - super().test_admin_start_stop_ws(web3) + def test_admin_start_stop_ws(w3): + super().test_admin_start_stop_ws(w3) class TestGoEthereumEthModuleTest(GoEthereumEthModuleTest): diff --git a/tests/integration/go_ethereum/test_goethereum_ws.py b/tests/integration/go_ethereum/test_goethereum_ws.py index 9014f4fc1d..647681ede8 100644 --- a/tests/integration/go_ethereum/test_goethereum_ws.py +++ b/tests/integration/go_ethereum/test_goethereum_ws.py @@ -64,11 +64,11 @@ def geth_command_arguments(geth_binary, @pytest.fixture(scope="module") -def web3(geth_process, endpoint_uri): +def w3(geth_process, endpoint_uri): event_loop = asyncio.new_event_loop() event_loop.run_until_complete(wait_for_ws(endpoint_uri)) - _web3 = Web3(Web3.WebsocketProvider(endpoint_uri, websocket_timeout=30)) - return _web3 + _w3 = Web3(Web3.WebsocketProvider(endpoint_uri, websocket_timeout=30)) + return _w3 class TestGoEthereumTest(GoEthereumTest): @@ -77,17 +77,17 @@ class TestGoEthereumTest(GoEthereumTest): class TestGoEthereumAdminModuleTest(GoEthereumAdminModuleTest): @pytest.mark.xfail(reason="running geth with the --nodiscover flag doesn't allow peer addition") - def test_admin_peers(self, web3: "Web3") -> None: - super().test_admin_peers(web3) + def test_admin_peers(self, w3: "Web3") -> None: + super().test_admin_peers(w3) - def test_admin_start_stop_ws(self, web3: "Web3") -> None: + def test_admin_start_stop_ws(self, w3: "Web3") -> None: # This test inconsistently causes all tests after it to fail on CI if it's allowed to run pytest.xfail(reason='Only one WebSocket endpoint is allowed to be active at any time') - super().test_admin_start_stop_ws(web3) + super().test_admin_start_stop_ws(w3) - def test_admin_start_stop_rpc(self, web3: "Web3") -> None: + def test_admin_start_stop_rpc(self, w3: "Web3") -> None: pytest.xfail(reason="This test inconsistently causes all tests after it on CI to fail if it's allowed to run") # noqa: E501 - super().test_admin_start_stop_ws(web3) + super().test_admin_start_stop_ws(w3) class TestGoEthereumEthModuleTest(GoEthereumEthModuleTest): diff --git a/tests/integration/test_ethereum_tester.py b/tests/integration/test_ethereum_tester.py index 5d9297e723..c688fa1f14 100644 --- a/tests/integration/test_ethereum_tester.py +++ b/tests/integration/test_ethereum_tester.py @@ -45,23 +45,23 @@ def eth_tester_provider(eth_tester): @pytest.fixture(scope="module") -def web3(eth_tester_provider): - _web3 = Web3(eth_tester_provider) - return _web3 +def w3(eth_tester_provider): + _w3 = Web3(eth_tester_provider) + return _w3 # # Math Contract Setup # @pytest.fixture(scope="module") -def math_contract_deploy_txn_hash(web3, math_contract_factory): - deploy_txn_hash = math_contract_factory.constructor().transact({'from': web3.eth.coinbase}) +def math_contract_deploy_txn_hash(w3, math_contract_factory): + deploy_txn_hash = math_contract_factory.constructor().transact({'from': w3.eth.coinbase}) return deploy_txn_hash @pytest.fixture(scope="module") -def math_contract(web3, math_contract_factory, math_contract_deploy_txn_hash): - deploy_receipt = web3.eth.wait_for_transaction_receipt(math_contract_deploy_txn_hash) +def math_contract(w3, math_contract_factory, math_contract_deploy_txn_hash): + deploy_receipt = w3.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) @@ -78,14 +78,14 @@ def math_contract_address(math_contract, address_conversion_func): @pytest.fixture(scope="module") -def emitter_contract_deploy_txn_hash(web3, emitter_contract_factory): - deploy_txn_hash = emitter_contract_factory.constructor().transact({'from': web3.eth.coinbase}) +def emitter_contract_deploy_txn_hash(w3, emitter_contract_factory): + deploy_txn_hash = emitter_contract_factory.constructor().transact({'from': w3.eth.coinbase}) return deploy_txn_hash @pytest.fixture(scope="module") -def emitter_contract(web3, emitter_contract_factory, emitter_contract_deploy_txn_hash): - deploy_receipt = web3.eth.wait_for_transaction_receipt(emitter_contract_deploy_txn_hash) +def emitter_contract(w3, emitter_contract_factory, emitter_contract_deploy_txn_hash): + deploy_receipt = w3.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) @@ -98,24 +98,24 @@ def emitter_contract_address(emitter_contract, address_conversion_func): @pytest.fixture(scope="module") -def empty_block(web3): - web3.testing.mine() - block = web3.eth.get_block("latest") +def empty_block(w3): + w3.testing.mine() + block = w3.eth.get_block("latest") assert not block['transactions'] return block @pytest.fixture(scope="module") -def block_with_txn(web3): - txn_hash = web3.eth.send_transaction({ - 'from': web3.eth.coinbase, - 'to': web3.eth.coinbase, +def block_with_txn(w3): + txn_hash = w3.eth.send_transaction({ + 'from': w3.eth.coinbase, + 'to': w3.eth.coinbase, 'value': 1, 'gas': 21000, 'gas_price': 1000000000, # needs to be greater than base_fee post London }) - txn = web3.eth.get_transaction(txn_hash) - block = web3.eth.get_block(txn['blockNumber']) + txn = w3.eth.get_transaction(txn_hash) + block = w3.eth.get_block(txn['blockNumber']) return block @@ -125,14 +125,14 @@ def mined_txn_hash(block_with_txn): @pytest.fixture(scope="module") -def block_with_txn_with_log(web3, emitter_contract): +def block_with_txn_with_log(w3, emitter_contract): txn_hash = emitter_contract.functions.logDouble( which=EMITTER_ENUM['LogDoubleWithIndex'], arg0=12345, arg1=54321, ).transact({ - 'from': web3.eth.coinbase, + 'from': w3.eth.coinbase, }) - txn = web3.eth.get_transaction(txn_hash) - block = web3.eth.get_block(txn['blockNumber']) + txn = w3.eth.get_transaction(txn_hash) + block = w3.eth.get_block(txn['blockNumber']) return block @@ -145,14 +145,14 @@ def txn_hash_with_log(block_with_txn_with_log): # Revert Contract Setup # @pytest.fixture(scope="module") -def revert_contract_deploy_txn_hash(web3, revert_contract_factory): - deploy_txn_hash = revert_contract_factory.constructor().transact({'from': web3.eth.coinbase}) +def revert_contract_deploy_txn_hash(w3, revert_contract_factory): + deploy_txn_hash = revert_contract_factory.constructor().transact({'from': w3.eth.coinbase}) return deploy_txn_hash @pytest.fixture(scope="module") -def revert_contract(web3, revert_contract_factory, revert_contract_deploy_txn_hash): - deploy_receipt = web3.eth.wait_for_transaction_receipt(revert_contract_deploy_txn_hash) +def revert_contract(w3, revert_contract_factory, revert_contract_deploy_txn_hash): + deploy_receipt = w3.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) @@ -163,27 +163,27 @@ def revert_contract(web3, revert_contract_factory, revert_contract_deploy_txn_ha @pytest.fixture(scope='module') -def unlockable_account_pw(web3): +def unlockable_account_pw(): return 'web3-testing' @pytest.fixture(scope='module') -def unlockable_account(web3, unlockable_account_pw): - account = web3.geth.personal.import_raw_key(UNLOCKABLE_PRIVATE_KEY, unlockable_account_pw) - web3.eth.send_transaction({ - 'from': web3.eth.coinbase, +def unlockable_account(w3, unlockable_account_pw): + account = w3.geth.personal.import_raw_key(UNLOCKABLE_PRIVATE_KEY, unlockable_account_pw) + w3.eth.send_transaction({ + 'from': w3.eth.coinbase, 'to': account, - 'value': web3.toWei(10, 'ether'), + 'value': w3.toWei(10, 'ether'), 'gas': 21000, }) yield account @pytest.fixture -def unlocked_account(web3, unlockable_account, unlockable_account_pw): - web3.geth.personal.unlock_account(unlockable_account, unlockable_account_pw) +def unlocked_account(w3, unlockable_account, unlockable_account_pw): + w3.geth.personal.unlock_account(unlockable_account, unlockable_account_pw) yield unlockable_account - web3.geth.personal.lock_account(unlockable_account) + w3.geth.personal.lock_account(unlockable_account) @pytest.fixture() @@ -192,19 +192,19 @@ def unlockable_account_dual_type(unlockable_account, address_conversion_func): @pytest.fixture -def unlocked_account_dual_type(web3, unlockable_account_dual_type, unlockable_account_pw): - web3.geth.personal.unlock_account(unlockable_account_dual_type, unlockable_account_pw) +def unlocked_account_dual_type(w3, unlockable_account_dual_type, unlockable_account_pw): + w3.geth.personal.unlock_account(unlockable_account_dual_type, unlockable_account_pw) yield unlockable_account_dual_type - web3.geth.personal.lock_account(unlockable_account_dual_type) + w3.geth.personal.lock_account(unlockable_account_dual_type) @pytest.fixture(scope="module") -def funded_account_for_raw_txn(web3): +def funded_account_for_raw_txn(w3): account = '0x39EEed73fb1D3855E90Cbd42f348b3D7b340aAA6' - web3.eth.send_transaction({ - 'from': web3.eth.coinbase, + w3.eth.send_transaction({ + 'from': w3.eth.coinbase, 'to': account, - 'value': web3.toWei(10, 'ether'), + 'value': w3.toWei(10, 'ether'), 'gas': 21000, 'gas_price': 1, }) @@ -291,96 +291,96 @@ class TestEthereumTesterEthModule(EthModuleTest): ) def test_eth_getBlockByHash_pending( - self, web3: "Web3" + self, w3: "Web3" ) -> None: - block = web3.eth.get_block('pending') + block = w3.eth.get_block('pending') assert block['hash'] is not None @pytest.mark.xfail(reason='eth_feeHistory is not implemented on eth-tester') - def test_eth_fee_history(self, web3: "Web3"): - super().test_eth_fee_history(web3) + def test_eth_fee_history(self, w3: "Web3"): + super().test_eth_fee_history(w3) @pytest.mark.xfail(reason='eth_feeHistory is not implemented on eth-tester') - def test_eth_fee_history_with_integer(self, web3: "Web3"): - super().test_eth_fee_history_with_integer(web3) + def test_eth_fee_history_with_integer(self, w3: "Web3"): + super().test_eth_fee_history_with_integer(w3) @pytest.mark.xfail(reason='eth_feeHistory is not implemented on eth-tester') - def test_eth_fee_history_no_reward_percentiles(self, web3: "Web3"): - super().test_eth_fee_history_no_reward_percentiles(web3) + def test_eth_fee_history_no_reward_percentiles(self, w3: "Web3"): + super().test_eth_fee_history_no_reward_percentiles(w3) @disable_auto_mine - def test_eth_get_transaction_receipt_unmined(self, eth_tester, web3, unlocked_account): - super().test_eth_get_transaction_receipt_unmined(web3, unlocked_account) + def test_eth_get_transaction_receipt_unmined(self, eth_tester, w3, unlocked_account): + super().test_eth_get_transaction_receipt_unmined(w3, unlocked_account) @disable_auto_mine - def test_eth_replace_transaction_legacy(self, eth_tester, web3, unlocked_account): - super().test_eth_replace_transaction_legacy(web3, unlocked_account) + def test_eth_replace_transaction_legacy(self, eth_tester, w3, unlocked_account): + super().test_eth_replace_transaction_legacy(w3, unlocked_account) @disable_auto_mine - def test_eth_replace_transaction(self, eth_tester, web3, unlocked_account): - super().test_eth_replace_transaction(web3, unlocked_account) + def test_eth_replace_transaction(self, eth_tester, w3, unlocked_account): + super().test_eth_replace_transaction(w3, unlocked_account) @disable_auto_mine @pytest.mark.xfail(reason='py-evm does not raise on EIP-1559 transaction underpriced') # TODO: This might also be an issue in py-evm worth looking into. See reason above. - def test_eth_replace_transaction_underpriced(self, eth_tester, web3, unlocked_account): - super().test_eth_replace_transaction_underpriced(web3, unlocked_account) + def test_eth_replace_transaction_underpriced(self, eth_tester, w3, unlocked_account): + super().test_eth_replace_transaction_underpriced(w3, unlocked_account) @disable_auto_mine - def test_eth_replaceTransaction_deprecated(self, eth_tester, web3, unlocked_account): - super().test_eth_replaceTransaction_deprecated(web3, unlocked_account) + def test_eth_replaceTransaction_deprecated(self, eth_tester, w3, unlocked_account): + super().test_eth_replaceTransaction_deprecated(w3, unlocked_account) @disable_auto_mine - def test_eth_replace_transaction_incorrect_nonce(self, eth_tester, web3, unlocked_account): - super().test_eth_replace_transaction_incorrect_nonce(web3, unlocked_account) + def test_eth_replace_transaction_incorrect_nonce(self, eth_tester, w3, unlocked_account): + super().test_eth_replace_transaction_incorrect_nonce(w3, unlocked_account) @disable_auto_mine - def test_eth_replace_transaction_gas_price_too_low(self, eth_tester, web3, unlocked_account): - super().test_eth_replace_transaction_gas_price_too_low(web3, unlocked_account) + def test_eth_replace_transaction_gas_price_too_low(self, eth_tester, w3, unlocked_account): + super().test_eth_replace_transaction_gas_price_too_low(w3, unlocked_account) @disable_auto_mine def test_eth_replace_transaction_gas_price_defaulting_minimum(self, eth_tester, - web3, + w3, unlocked_account): - super().test_eth_replace_transaction_gas_price_defaulting_minimum(web3, unlocked_account) + super().test_eth_replace_transaction_gas_price_defaulting_minimum(w3, unlocked_account) @disable_auto_mine def test_eth_replace_transaction_gas_price_defaulting_strategy_higher(self, eth_tester, - web3, + w3, unlocked_account): super().test_eth_replace_transaction_gas_price_defaulting_strategy_higher( - web3, unlocked_account + w3, unlocked_account ) @disable_auto_mine def test_eth_replace_transaction_gas_price_defaulting_strategy_lower(self, eth_tester, - web3, + w3, unlocked_account): super().test_eth_replace_transaction_gas_price_defaulting_strategy_lower( - web3, unlocked_account + w3, unlocked_account ) @disable_auto_mine - def test_eth_modifyTransaction_deprecated(self, eth_tester, web3, unlocked_account): - super().test_eth_modifyTransaction_deprecated(web3, unlocked_account) + def test_eth_modifyTransaction_deprecated(self, eth_tester, w3, unlocked_account): + super().test_eth_modifyTransaction_deprecated(w3, unlocked_account) @disable_auto_mine - def test_eth_modify_transaction_legacy(self, eth_tester, web3, unlocked_account): - super().test_eth_modify_transaction_legacy(web3, unlocked_account) + def test_eth_modify_transaction_legacy(self, eth_tester, w3, unlocked_account): + super().test_eth_modify_transaction_legacy(w3, unlocked_account) @disable_auto_mine - def test_eth_modify_transaction(self, eth_tester, web3, unlocked_account): - super().test_eth_modify_transaction(web3, unlocked_account) + def test_eth_modify_transaction(self, eth_tester, w3, unlocked_account): + super().test_eth_modify_transaction(w3, unlocked_account) @disable_auto_mine - def test_eth_call_old_contract_state(self, eth_tester, web3, math_contract, unlocked_account): + def test_eth_call_old_contract_state(self, eth_tester, w3, math_contract, unlocked_account): # For now, ethereum tester cannot give call results in the pending block. # Once that feature is added, then delete the except/else blocks. try: - super().test_eth_call_old_contract_state(web3, math_contract, unlocked_account) + super().test_eth_call_old_contract_state(w3, math_contract, unlocked_account) except AssertionError as err: if str(err) == "pending call result was 0 instead of 1": pass @@ -390,47 +390,47 @@ def test_eth_call_old_contract_state(self, eth_tester, web3, math_contract, unlo raise AssertionError("eth-tester was unexpectedly able to give the pending call result") @pytest.mark.xfail(reason='json-rpc method is not implemented on eth-tester') - def test_eth_get_storage_at(self, web3, emitter_contract_address): - super().test_eth_get_storage_at(web3, emitter_contract_address) + def test_eth_get_storage_at(self, w3, emitter_contract_address): + super().test_eth_get_storage_at(w3, emitter_contract_address) @pytest.mark.xfail(reason='json-rpc method is not implemented on eth-tester') - def test_eth_getStorageAt_deprecated(self, web3, emitter_contract_address): - super().test_eth_getStorageAt_deprecated(web3, emitter_contract_address) + def test_eth_getStorageAt_deprecated(self, w3, emitter_contract_address): + super().test_eth_getStorageAt_deprecated(w3, emitter_contract_address) @pytest.mark.xfail(reason='json-rpc method is not implemented on eth-tester') - def test_eth_get_storage_at_ens_name(self, web3, emitter_contract_address): - super().test_eth_get_storage_at_ens_name(web3, emitter_contract_address) + def test_eth_get_storage_at_ens_name(self, w3, emitter_contract_address): + super().test_eth_get_storage_at_ens_name(w3, emitter_contract_address) def test_eth_estimate_gas_with_block(self, - web3, + w3, unlocked_account_dual_type): super().test_eth_estimate_gas_with_block( - web3, unlocked_account_dual_type + w3, unlocked_account_dual_type ) - def test_eth_chain_id(self, web3): - chain_id = web3.eth.chain_id + def test_eth_chain_id(self, w3): + chain_id = w3.eth.chain_id assert is_integer(chain_id) assert chain_id == 61 - def test_eth_chainId(self, web3): + def test_eth_chainId(self, w3): with pytest.warns(DeprecationWarning): - chain_id = web3.eth.chainId + chain_id = w3.eth.chainId assert is_integer(chain_id) assert chain_id == 61 @disable_auto_mine def test_eth_wait_for_transaction_receipt_unmined(self, eth_tester, - web3, + w3, unlocked_account_dual_type): - super().test_eth_wait_for_transaction_receipt_unmined(web3, unlocked_account_dual_type) + super().test_eth_wait_for_transaction_receipt_unmined(w3, unlocked_account_dual_type) @pytest.mark.xfail(raises=TypeError, reason="call override param not implemented on eth-tester") - def test_eth_call_with_override(self, web3, revert_contract): - super().test_eth_call_with_override(web3, revert_contract) + def test_eth_call_with_override(self, w3, revert_contract): + super().test_eth_call_with_override(w3, revert_contract) - def test_eth_call_revert_with_msg(self, web3, revert_contract, unlocked_account): + def test_eth_call_revert_with_msg(self, w3, revert_contract, unlocked_account): with pytest.raises(TransactionFailed, match='execution reverted: Function has been reverted'): txn_params = revert_contract._prepare_transaction( @@ -440,9 +440,9 @@ def test_eth_call_revert_with_msg(self, web3, revert_contract, unlocked_account) "to": revert_contract.address, }, ) - web3.eth.call(txn_params) + w3.eth.call(txn_params) - def test_eth_call_revert_without_msg(self, web3, revert_contract, unlocked_account): + def test_eth_call_revert_without_msg(self, w3, revert_contract, unlocked_account): with pytest.raises(TransactionFailed, match="execution reverted"): txn_params = revert_contract._prepare_transaction( fn_name="revertWithoutMessage", @@ -451,9 +451,9 @@ def test_eth_call_revert_without_msg(self, web3, revert_contract, unlocked_accou "to": revert_contract.address, }, ) - web3.eth.call(txn_params) + w3.eth.call(txn_params) - def test_eth_estimate_gas_revert_with_msg(self, web3, revert_contract, unlocked_account): + def test_eth_estimate_gas_revert_with_msg(self, w3, revert_contract, unlocked_account): with pytest.raises(TransactionFailed, match='execution reverted: Function has been reverted'): txn_params = revert_contract._prepare_transaction( @@ -463,9 +463,9 @@ def test_eth_estimate_gas_revert_with_msg(self, web3, revert_contract, unlocked_ "to": revert_contract.address, }, ) - web3.eth.estimate_gas(txn_params) + w3.eth.estimate_gas(txn_params) - def test_eth_estimate_gas_revert_without_msg(self, web3, revert_contract, unlocked_account): + def test_eth_estimate_gas_revert_without_msg(self, w3, revert_contract, unlocked_account): with pytest.raises(TransactionFailed, match="execution reverted"): txn_params = revert_contract._prepare_transaction( fn_name="revertWithoutMessage", @@ -474,60 +474,60 @@ def test_eth_estimate_gas_revert_without_msg(self, web3, revert_contract, unlock "to": revert_contract.address, }, ) - web3.eth.estimate_gas(txn_params) + w3.eth.estimate_gas(txn_params) @disable_auto_mine - def test_eth_send_transaction(self, eth_tester, web3, unlocked_account): - super().test_eth_send_transaction(web3, unlocked_account) + def test_eth_send_transaction(self, eth_tester, w3, unlocked_account): + super().test_eth_send_transaction(w3, unlocked_account) @disable_auto_mine - def test_eth_send_transaction_legacy(self, eth_tester, web3, unlocked_account): - super().test_eth_send_transaction_legacy(web3, unlocked_account) + def test_eth_send_transaction_legacy(self, eth_tester, w3, unlocked_account): + super().test_eth_send_transaction_legacy(w3, unlocked_account) @disable_auto_mine - def test_eth_send_raw_transaction(self, eth_tester, web3, unlocked_account): - super().test_eth_send_raw_transaction(web3, unlocked_account) + def test_eth_send_raw_transaction(self, eth_tester, w3, unlocked_account): + super().test_eth_send_raw_transaction(w3, unlocked_account) @disable_auto_mine @pytest.mark.parametrize("max_fee", (1000000000, None), ids=["with_max_fee", "without_max_fee"]) def test_gas_price_from_strategy_bypassed_for_dynamic_fee_txn( - self, eth_tester, web3, unlocked_account, max_fee, + self, eth_tester, w3, unlocked_account, max_fee, ): super().test_gas_price_from_strategy_bypassed_for_dynamic_fee_txn( - web3, unlocked_account, max_fee + w3, unlocked_account, max_fee ) @disable_auto_mine def test_gas_price_from_strategy_bypassed_for_dynamic_fee_txn_no_tip( - self, eth_tester, web3, unlocked_account + self, eth_tester, w3, unlocked_account ): super().test_gas_price_from_strategy_bypassed_for_dynamic_fee_txn_no_tip( - web3, unlocked_account, + w3, unlocked_account, ) @disable_auto_mine - def test_eth_sendTransaction_deprecated(self, eth_tester, web3, unlocked_account): - super().test_eth_sendTransaction_deprecated(web3, unlocked_account) + def test_eth_sendTransaction_deprecated(self, eth_tester, w3, unlocked_account): + super().test_eth_sendTransaction_deprecated(w3, unlocked_account) @pytest.mark.xfail(raises=ValueError, reason="eth-tester does not have miner_start support") - def test_eth_send_transaction_with_nonce(self, eth_tester, web3, unlocked_account): - super().test_eth_send_transaction_with_nonce(web3, unlocked_account) + def test_eth_send_transaction_with_nonce(self, eth_tester, w3, unlocked_account): + super().test_eth_send_transaction_with_nonce(w3, unlocked_account) @disable_auto_mine - def test_eth_send_transaction_default_fees(self, eth_tester, web3, unlocked_account): - super().test_eth_send_transaction_default_fees(web3, unlocked_account) + def test_eth_send_transaction_default_fees(self, eth_tester, w3, unlocked_account): + super().test_eth_send_transaction_default_fees(w3, unlocked_account) @disable_auto_mine - def test_eth_send_transaction_hex_fees(self, eth_tester, web3, unlocked_account): - super().test_eth_send_transaction_hex_fees(web3, unlocked_account) + def test_eth_send_transaction_hex_fees(self, eth_tester, w3, unlocked_account): + super().test_eth_send_transaction_hex_fees(w3, unlocked_account) @disable_auto_mine - def test_eth_send_transaction_no_gas(self, eth_tester, web3, unlocked_account): - super().test_eth_send_transaction_no_gas(web3, unlocked_account) + def test_eth_send_transaction_no_gas(self, eth_tester, w3, unlocked_account): + super().test_eth_send_transaction_no_gas(w3, unlocked_account) @disable_auto_mine - def test_eth_send_transaction_no_max_fee(self, eth_tester, web3, unlocked_account): - super().test_eth_send_transaction_no_max_fee(web3, unlocked_account) + def test_eth_send_transaction_no_max_fee(self, eth_tester, w3, unlocked_account): + super().test_eth_send_transaction_no_max_fee(w3, unlocked_account) class TestEthereumTesterVersionModule(VersionModuleTest): @@ -551,19 +551,19 @@ class TestEthereumTesterPersonalModule(GoEthereumPersonalModuleTest): # Test overridden here since eth-tester returns False rather than None for failed unlock def test_personal_unlock_account_failure(self, - web3, + w3, unlockable_account_dual_type): - result = web3.geth.personal.unlock_account(unlockable_account_dual_type, 'bad-password') + result = w3.geth.personal.unlock_account(unlockable_account_dual_type, 'bad-password') assert result is False def test_personal_unlockAccount_failure_deprecated(self, - web3, + w3, unlockable_account_dual_type): with pytest.warns(DeprecationWarning, match="unlockAccount is deprecated in favor of unlock_account"): - result = web3.geth.personal.unlockAccount(unlockable_account_dual_type, 'bad-password') + result = w3.geth.personal.unlockAccount(unlockable_account_dual_type, 'bad-password') assert result is False @pytest.mark.xfail(raises=ValueError, reason="list_wallets not implemented in eth-tester") - def test_personal_list_wallets(self, web3: "Web3") -> None: - super().test_personal_list_wallets(web3) + def test_personal_list_wallets(self, w3: "Web3") -> None: + super().test_personal_list_wallets(w3) diff --git a/web3/_utils/async_transactions.py b/web3/_utils/async_transactions.py index be5fa6c391..116fdf8898 100644 --- a/web3/_utils/async_transactions.py +++ b/web3/_utils/async_transactions.py @@ -24,13 +24,13 @@ async def get_block_gas_limit( async def get_buffered_gas_estimate( - web3: "Web3", transaction: TxParams, gas_buffer: int = 100000 + w3: "Web3", transaction: TxParams, gas_buffer: int = 100000 ) -> int: gas_estimate_transaction = cast(TxParams, dict(**transaction)) - gas_estimate = await web3.eth.estimate_gas(gas_estimate_transaction) # type: ignore + gas_estimate = await w3.eth.estimate_gas(gas_estimate_transaction) # type: ignore - gas_limit = await get_block_gas_limit(web3.eth) # type: ignore + gas_limit = await get_block_gas_limit(w3.eth) # type: ignore if gas_estimate > gas_limit: raise ValueError( diff --git a/web3/_utils/contracts.py b/web3/_utils/contracts.py index c7d6f45829..97a0b1d17c 100644 --- a/web3/_utils/contracts.py +++ b/web3/_utils/contracts.py @@ -164,11 +164,11 @@ def find_matching_fn_abi( def encode_abi( - web3: "Web3", abi: ABIFunction, arguments: Sequence[Any], data: Optional[HexStr] = None + w3: "Web3", abi: ABIFunction, arguments: Sequence[Any], data: Optional[HexStr] = None ) -> HexStr: argument_types = get_abi_input_types(abi) - if not check_if_arguments_can_be_encoded(abi, web3.codec, arguments, {}): + if not check_if_arguments_can_be_encoded(abi, w3.codec, arguments, {}): raise TypeError( "One or more arguments could not be encoded to the necessary " "ABI type. Expected types are: {0}".format( @@ -177,7 +177,7 @@ def encode_abi( ) normalizers = [ - abi_ens_resolver(web3), + abi_ens_resolver(w3), abi_address_to_hex, abi_bytes_to_bytes, abi_string_to_text, @@ -187,7 +187,7 @@ def encode_abi( argument_types, arguments, ) - encoded_arguments = web3.codec.encode_abi( + encoded_arguments = w3.codec.encode_abi( argument_types, normalized_arguments, ) @@ -200,7 +200,7 @@ def encode_abi( def prepare_transaction( address: ChecksumAddress, - web3: "Web3", + w3: "Web3", fn_identifier: Union[str, Type[FallbackFn], Type[ReceiveFn]], contract_abi: Optional[ABI] = None, fn_abi: Optional[ABIFunction] = None, @@ -215,7 +215,7 @@ def prepare_transaction( TODO: add new prepare_deploy_transaction API """ if fn_abi is None: - fn_abi = find_matching_fn_abi(contract_abi, web3.codec, fn_identifier, fn_args, fn_kwargs) + fn_abi = find_matching_fn_abi(contract_abi, w3.codec, fn_identifier, fn_args, fn_kwargs) validate_payable(transaction, fn_abi) @@ -231,7 +231,7 @@ def prepare_transaction( prepared_transaction.setdefault('to', address) prepared_transaction['data'] = encode_transaction_data( - web3, + w3, fn_identifier, contract_abi, fn_abi, @@ -242,7 +242,7 @@ def prepare_transaction( def encode_transaction_data( - web3: "Web3", + w3: "Web3", fn_identifier: Union[str, Type[FallbackFn], Type[ReceiveFn]], contract_abi: Optional[ABI] = None, fn_abi: Optional[ABIFunction] = None, @@ -256,12 +256,12 @@ def encode_transaction_data( elif is_text(fn_identifier): fn_abi, fn_selector, fn_arguments = get_function_info( # type ignored b/c fn_id here is always str b/c FallbackFn is handled above - fn_identifier, web3.codec, contract_abi, fn_abi, args, kwargs, # type: ignore + fn_identifier, w3.codec, contract_abi, fn_abi, args, kwargs, # type: ignore ) else: raise TypeError("Unsupported function identifier") - return add_0x_prefix(encode_abi(web3, fn_abi, fn_arguments, fn_selector)) + return add_0x_prefix(encode_abi(w3, fn_abi, fn_arguments, fn_selector)) def get_fallback_function_info( diff --git a/web3/_utils/ens.py b/web3/_utils/ens.py index 73040b239d..f924d306d7 100644 --- a/web3/_utils/ens.py +++ b/web3/_utils/ens.py @@ -76,5 +76,5 @@ def contract_ens_addresses( with contract_ens_addresses(mycontract, [('resolve-as-1s.eth', '0x111...111')]): # any contract call or transaction in here would only resolve the above ENS pair """ - with ens_addresses(contract.web3, name_addr_pairs): + with ens_addresses(contract.w3, name_addr_pairs): yield diff --git a/web3/_utils/module_testing/eth_module.py b/web3/_utils/module_testing/eth_module.py index 30a504a293..a2e4b66ea9 100644 --- a/web3/_utils/module_testing/eth_module.py +++ b/web3/_utils/module_testing/eth_module.py @@ -80,15 +80,15 @@ from web3.contract import Contract # noqa: F401 -def mine_pending_block(web3: "Web3") -> None: +def mine_pending_block(w3: "Web3") -> None: timeout = 10 - web3.geth.miner.start() # type: ignore + w3.geth.miner.start() # type: ignore start = time.time() while time.time() < start + timeout: - if len(web3.eth.get_block('pending')['transactions']) == 0: + if len(w3.eth.get_block('pending')['transactions']) == 0: break - web3.geth.miner.stop() # type: ignore + w3.geth.miner.stop() # type: ignore def _assert_contains_log( @@ -358,7 +358,7 @@ async def test_gas_price_strategy_middleware( } two_gwei_in_wei = async_w3.toWei(2, 'gwei') - def gas_price_strategy(web3: "Web3", txn: TxParams) -> Wei: + def gas_price_strategy(w3: "Web3", txn: TxParams) -> Wei: return two_gwei_in_wei async_w3.eth.set_gas_price_strategy(gas_price_strategy) @@ -389,7 +389,7 @@ async def test_gas_price_from_strategy_bypassed_for_dynamic_fee_txn( if max_fee is not None: txn_params = assoc(txn_params, "maxFeePerGas", max_fee) - def gas_price_strategy(web3: "Web3", txn: TxParams) -> Wei: + def gas_price_strategy(w3: "Web3", txn: TxParams) -> Wei: return async_w3.toWei(2, 'gwei') async_w3.eth.set_gas_price_strategy(gas_price_strategy) @@ -416,7 +416,7 @@ async def test_gas_price_from_strategy_bypassed_for_dynamic_fee_txn_no_tip( 'maxFeePerGas': Wei(1000000000), } - def gas_price_strategy(_web3: "Web3", _txn: TxParams) -> Wei: + def gas_price_strategy(_w3: "Web3", _txn: TxParams) -> Wei: return async_w3.toWei(2, 'gwei') async_w3.eth.set_gas_price_strategy(gas_price_strategy) @@ -1155,23 +1155,23 @@ def test_async_provider_default_block( class EthModuleTest: - def test_eth_protocol_version(self, web3: "Web3") -> None: + def test_eth_protocol_version(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning, match="This method has been deprecated in some clients"): - protocol_version = web3.eth.protocol_version + protocol_version = w3.eth.protocol_version assert is_string(protocol_version) assert protocol_version.isdigit() - def test_eth_protocolVersion(self, web3: "Web3") -> None: + def test_eth_protocolVersion(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): - protocol_version = web3.eth.protocolVersion + protocol_version = w3.eth.protocolVersion assert is_string(protocol_version) assert protocol_version.isdigit() - def test_eth_syncing(self, web3: "Web3") -> None: - syncing = web3.eth.syncing + def test_eth_syncing(self, w3: "Web3") -> None: + syncing = w3.eth.syncing assert is_boolean(syncing) or is_dict(syncing) @@ -1187,32 +1187,32 @@ def test_eth_syncing(self, web3: "Web3") -> None: assert is_integer(sync_dict['currentBlock']) assert is_integer(sync_dict['highestBlock']) - def test_eth_coinbase(self, web3: "Web3") -> None: - coinbase = web3.eth.coinbase + def test_eth_coinbase(self, w3: "Web3") -> None: + coinbase = w3.eth.coinbase assert is_checksum_address(coinbase) - def test_eth_mining(self, web3: "Web3") -> None: - mining = web3.eth.mining + def test_eth_mining(self, w3: "Web3") -> None: + mining = w3.eth.mining assert is_boolean(mining) - def test_eth_hashrate(self, web3: "Web3") -> None: - hashrate = web3.eth.hashrate + def test_eth_hashrate(self, w3: "Web3") -> None: + hashrate = w3.eth.hashrate assert is_integer(hashrate) assert hashrate >= 0 - def test_eth_chain_id(self, web3: "Web3") -> None: - chain_id = web3.eth.chain_id + def test_eth_chain_id(self, w3: "Web3") -> None: + chain_id = w3.eth.chain_id # chain id value from geth fixture genesis file assert chain_id == 131277322940537 - def test_eth_chainId(self, web3: "Web3") -> None: + def test_eth_chainId(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): - chain_id = web3.eth.chainId + chain_id = w3.eth.chainId # chain id value from geth fixture genesis file assert chain_id == 131277322940537 - def test_eth_fee_history(self, web3: "Web3") -> None: - fee_history = web3.eth.fee_history(1, 'latest', [50]) + def test_eth_fee_history(self, w3: "Web3") -> None: + fee_history = w3.eth.fee_history(1, 'latest', [50]) assert is_list_like(fee_history['baseFeePerGas']) assert is_list_like(fee_history['gasUsedRatio']) assert is_integer(fee_history['oldestBlock']) @@ -1221,9 +1221,9 @@ def test_eth_fee_history(self, web3: "Web3") -> None: assert is_list_like(fee_history['reward'][0]) def test_eth_fee_history_with_integer(self, - web3: "Web3", + w3: "Web3", empty_block: BlockData) -> None: - fee_history = web3.eth.fee_history(1, empty_block['number'], [50]) + fee_history = w3.eth.fee_history(1, empty_block['number'], [50]) assert is_list_like(fee_history['baseFeePerGas']) assert is_list_like(fee_history['gasUsedRatio']) assert is_integer(fee_history['oldestBlock']) @@ -1231,46 +1231,46 @@ def test_eth_fee_history_with_integer(self, assert is_list_like(fee_history['reward']) assert is_list_like(fee_history['reward'][0]) - def test_eth_fee_history_no_reward_percentiles(self, web3: "Web3") -> None: - fee_history = web3.eth.fee_history(1, 'latest') + def test_eth_fee_history_no_reward_percentiles(self, w3: "Web3") -> None: + fee_history = w3.eth.fee_history(1, 'latest') assert is_list_like(fee_history['baseFeePerGas']) assert is_list_like(fee_history['gasUsedRatio']) assert is_integer(fee_history['oldestBlock']) assert fee_history['oldestBlock'] >= 0 - def test_eth_gas_price(self, web3: "Web3") -> None: - gas_price = web3.eth.gas_price + def test_eth_gas_price(self, w3: "Web3") -> None: + gas_price = w3.eth.gas_price assert is_integer(gas_price) assert gas_price > 0 - def test_eth_gasPrice_deprecated(self, web3: "Web3") -> None: + def test_eth_gasPrice_deprecated(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): - gas_price = web3.eth.gasPrice + gas_price = w3.eth.gasPrice assert is_integer(gas_price) assert gas_price > 0 - def test_eth_max_priority_fee(self, web3: "Web3") -> None: - max_priority_fee = web3.eth.max_priority_fee + def test_eth_max_priority_fee(self, w3: "Web3") -> None: + max_priority_fee = w3.eth.max_priority_fee assert is_integer(max_priority_fee) - def test_eth_max_priority_fee_with_fee_history_calculation(self, web3: "Web3") -> None: + def test_eth_max_priority_fee_with_fee_history_calculation(self, w3: "Web3") -> None: fail_max_prio_middleware = construct_error_generator_middleware( {RPCEndpoint("eth_maxPriorityFeePerGas"): lambda *_: ''} ) - web3.middleware_onion.add(fail_max_prio_middleware, name='fail_max_prio_middleware') + w3.middleware_onion.add(fail_max_prio_middleware, name='fail_max_prio_middleware') with pytest.warns( UserWarning, match="There was an issue with the method eth_maxPriorityFeePerGas. Calculating using " "eth_feeHistory." ): - max_priority_fee = web3.eth.max_priority_fee + max_priority_fee = w3.eth.max_priority_fee assert is_integer(max_priority_fee) - web3.middleware_onion.remove('fail_max_prio_middleware') # clean up + w3.middleware_onion.remove('fail_max_prio_middleware') # clean up - def test_eth_accounts(self, web3: "Web3") -> None: - accounts = web3.eth.accounts + def test_eth_accounts(self, w3: "Web3") -> None: + accounts = w3.eth.accounts assert is_list_like(accounts) assert len(accounts) != 0 assert all(( @@ -1278,50 +1278,50 @@ def test_eth_accounts(self, web3: "Web3") -> None: for account in accounts )) - assert web3.eth.coinbase in accounts + assert w3.eth.coinbase in accounts - def test_eth_block_number(self, web3: "Web3") -> None: - block_number = web3.eth.block_number + def test_eth_block_number(self, w3: "Web3") -> None: + block_number = w3.eth.block_number assert is_integer(block_number) assert block_number >= 0 - def test_eth_get_block_number(self, web3: "Web3") -> None: - block_number = web3.eth.get_block_number() + def test_eth_get_block_number(self, w3: "Web3") -> None: + block_number = w3.eth.get_block_number() assert is_integer(block_number) assert block_number >= 0 - def test_eth_blockNumber(self, web3: "Web3") -> None: + def test_eth_blockNumber(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): - block_number = web3.eth.blockNumber + block_number = w3.eth.blockNumber assert is_integer(block_number) assert block_number >= 0 - def test_eth_get_balance(self, web3: "Web3") -> None: - coinbase = web3.eth.coinbase + def test_eth_get_balance(self, w3: "Web3") -> None: + coinbase = w3.eth.coinbase with pytest.raises(InvalidAddress): - web3.eth.get_balance(ChecksumAddress(HexAddress(HexStr(coinbase.lower())))) + w3.eth.get_balance(ChecksumAddress(HexAddress(HexStr(coinbase.lower())))) - balance = web3.eth.get_balance(coinbase) + balance = w3.eth.get_balance(coinbase) assert is_integer(balance) assert balance >= 0 - def test_eth_getBalance_deprecated(self, web3: "Web3") -> None: - coinbase = web3.eth.coinbase + def test_eth_getBalance_deprecated(self, w3: "Web3") -> None: + coinbase = w3.eth.coinbase with pytest.warns(DeprecationWarning, match='getBalance is deprecated in favor of get_balance'): - balance = web3.eth.getBalance(coinbase) + balance = w3.eth.getBalance(coinbase) assert is_integer(balance) assert balance >= 0 - def test_eth_get_balance_with_block_identifier(self, web3: "Web3") -> None: - miner_address = web3.eth.get_block(1)['miner'] - genesis_balance = web3.eth.get_balance(miner_address, 0) - later_balance = web3.eth.get_balance(miner_address, 1) + def test_eth_get_balance_with_block_identifier(self, w3: "Web3") -> None: + miner_address = w3.eth.get_block(1)['miner'] + genesis_balance = w3.eth.get_balance(miner_address, 0) + later_balance = w3.eth.get_balance(miner_address, 1) assert is_integer(genesis_balance) assert is_integer(later_balance) @@ -1332,201 +1332,201 @@ def test_eth_get_balance_with_block_identifier(self, web3: "Web3") -> None: ('not-an-address.eth', False) ]) def test_eth_get_balance_with_ens_name( - self, web3: "Web3", address: ChecksumAddress, expect_success: bool + self, w3: "Web3", address: ChecksumAddress, expect_success: bool ) -> None: - with ens_addresses(web3, {'test-address.eth': web3.eth.accounts[0]}): + with ens_addresses(w3, {'test-address.eth': w3.eth.accounts[0]}): if expect_success: - balance = web3.eth.get_balance(address) + balance = w3.eth.get_balance(address) assert is_integer(balance) assert balance >= 0 else: with pytest.raises(NameNotFound): - web3.eth.get_balance(address) + w3.eth.get_balance(address) def test_eth_get_storage_at( - self, web3: "Web3", emitter_contract_address: ChecksumAddress + self, w3: "Web3", emitter_contract_address: ChecksumAddress ) -> None: - storage = web3.eth.get_storage_at(emitter_contract_address, 0) + storage = w3.eth.get_storage_at(emitter_contract_address, 0) assert isinstance(storage, HexBytes) def test_eth_getStorageAt_deprecated( - self, web3: "Web3", emitter_contract_address: ChecksumAddress + self, w3: "Web3", emitter_contract_address: ChecksumAddress ) -> None: with pytest.warns(DeprecationWarning): - storage = web3.eth.getStorageAt(emitter_contract_address, 0) + storage = w3.eth.getStorageAt(emitter_contract_address, 0) assert isinstance(storage, HexBytes) def test_eth_get_storage_at_ens_name( - self, web3: "Web3", emitter_contract_address: ChecksumAddress + self, w3: "Web3", emitter_contract_address: ChecksumAddress ) -> None: - with ens_addresses(web3, {'emitter.eth': emitter_contract_address}): - storage = web3.eth.get_storage_at('emitter.eth', 0) + with ens_addresses(w3, {'emitter.eth': emitter_contract_address}): + storage = w3.eth.get_storage_at('emitter.eth', 0) assert isinstance(storage, HexBytes) - def test_eth_get_storage_at_invalid_address(self, web3: "Web3") -> None: - coinbase = web3.eth.coinbase + def test_eth_get_storage_at_invalid_address(self, w3: "Web3") -> None: + coinbase = w3.eth.coinbase with pytest.raises(InvalidAddress): - web3.eth.get_storage_at(ChecksumAddress(HexAddress(HexStr(coinbase.lower()))), 0) + w3.eth.get_storage_at(ChecksumAddress(HexAddress(HexStr(coinbase.lower()))), 0) def test_eth_get_transaction_count( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: - transaction_count = web3.eth.get_transaction_count(unlocked_account_dual_type) + transaction_count = w3.eth.get_transaction_count(unlocked_account_dual_type) assert is_integer(transaction_count) assert transaction_count >= 0 def test_eth_getTransactionCount_deprecated( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: with pytest.warns(DeprecationWarning): - transaction_count = web3.eth.getTransactionCount(unlocked_account_dual_type) + transaction_count = w3.eth.getTransactionCount(unlocked_account_dual_type) assert is_integer(transaction_count) assert transaction_count >= 0 def test_eth_get_transaction_count_ens_name( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: - with ens_addresses(web3, {'unlocked-acct-dual-type.eth': unlocked_account_dual_type}): - transaction_count = web3.eth.get_transaction_count('unlocked-acct-dual-type.eth') + with ens_addresses(w3, {'unlocked-acct-dual-type.eth': unlocked_account_dual_type}): + transaction_count = w3.eth.get_transaction_count('unlocked-acct-dual-type.eth') assert is_integer(transaction_count) assert transaction_count >= 0 - def test_eth_get_transaction_count_invalid_address(self, web3: "Web3") -> None: - coinbase = web3.eth.coinbase + def test_eth_get_transaction_count_invalid_address(self, w3: "Web3") -> None: + coinbase = w3.eth.coinbase with pytest.raises(InvalidAddress): - web3.eth.get_transaction_count(ChecksumAddress(HexAddress(HexStr(coinbase.lower())))) + w3.eth.get_transaction_count(ChecksumAddress(HexAddress(HexStr(coinbase.lower())))) def test_eth_getBlockTransactionCountByHash_empty_block( - self, web3: "Web3", empty_block: BlockData + self, w3: "Web3", empty_block: BlockData ) -> None: - transaction_count = web3.eth.get_block_transaction_count(empty_block['hash']) + transaction_count = w3.eth.get_block_transaction_count(empty_block['hash']) assert is_integer(transaction_count) assert transaction_count == 0 def test_eth_getBlockTransactionCountByNumber_empty_block( - self, web3: "Web3", empty_block: BlockData + self, w3: "Web3", empty_block: BlockData ) -> None: - transaction_count = web3.eth.get_block_transaction_count(empty_block['number']) + transaction_count = w3.eth.get_block_transaction_count(empty_block['number']) assert is_integer(transaction_count) assert transaction_count == 0 def test_eth_getBlockTransactionCountByHash_block_with_txn( - self, web3: "Web3", block_with_txn: BlockData + self, w3: "Web3", block_with_txn: BlockData ) -> None: - transaction_count = web3.eth.get_block_transaction_count(block_with_txn['hash']) + transaction_count = w3.eth.get_block_transaction_count(block_with_txn['hash']) assert is_integer(transaction_count) assert transaction_count >= 1 def test_eth_getBlockTransactionCountByNumber_block_with_txn( - self, web3: "Web3", block_with_txn: BlockData + self, w3: "Web3", block_with_txn: BlockData ) -> None: - transaction_count = web3.eth.get_block_transaction_count(block_with_txn['number']) + transaction_count = w3.eth.get_block_transaction_count(block_with_txn['number']) assert is_integer(transaction_count) assert transaction_count >= 1 def test_eth_getBlockTransactionCountByHash_block_with_txn_deprecated( - self, web3: "Web3", block_with_txn: BlockData + self, w3: "Web3", block_with_txn: BlockData ) -> None: with pytest.warns( DeprecationWarning, match="getBlockTransactionCount is deprecated in favor of get_block_transaction_count" ): - transaction_count = web3.eth.getBlockTransactionCount(block_with_txn['hash']) + transaction_count = w3.eth.getBlockTransactionCount(block_with_txn['hash']) assert is_integer(transaction_count) assert transaction_count >= 1 def test_eth_getBlockTransactionCountByNumber_block_with_txn_deprecated( - self, web3: "Web3", block_with_txn: BlockData + self, w3: "Web3", block_with_txn: BlockData ) -> None: with pytest.warns( DeprecationWarning, match="getBlockTransactionCount is deprecated in favor of get_block_transaction_count" ): - transaction_count = web3.eth.getBlockTransactionCount(block_with_txn['number']) + transaction_count = w3.eth.getBlockTransactionCount(block_with_txn['number']) assert is_integer(transaction_count) assert transaction_count >= 1 - def test_eth_getUncleCountByBlockHash(self, web3: "Web3", empty_block: BlockData) -> None: - uncle_count = web3.eth.get_uncle_count(empty_block['hash']) + def test_eth_getUncleCountByBlockHash(self, w3: "Web3", empty_block: BlockData) -> None: + uncle_count = w3.eth.get_uncle_count(empty_block['hash']) assert is_integer(uncle_count) assert uncle_count == 0 def test_eth_getUncleCountByBlockHash_deprecated(self, - web3: "Web3", + w3: "Web3", empty_block: BlockData) -> None: with pytest.warns(DeprecationWarning, match='getUncleCount is deprecated in favor of get_uncle_count'): - uncle_count = web3.eth.getUncleCount(empty_block['hash']) + uncle_count = w3.eth.getUncleCount(empty_block['hash']) assert is_integer(uncle_count) assert uncle_count == 0 - def test_eth_getUncleCountByBlockNumber(self, web3: "Web3", empty_block: BlockData) -> None: - uncle_count = web3.eth.get_uncle_count(empty_block['number']) + def test_eth_getUncleCountByBlockNumber(self, w3: "Web3", empty_block: BlockData) -> None: + uncle_count = w3.eth.get_uncle_count(empty_block['number']) assert is_integer(uncle_count) assert uncle_count == 0 def test_eth_getUncleCountByBlockNumber_deprecated(self, - web3: "Web3", + w3: "Web3", empty_block: BlockData) -> None: with pytest.warns(DeprecationWarning, match='getUncleCount is deprecated in favor of get_uncle_count'): - uncle_count = web3.eth.getUncleCount(empty_block['number']) + uncle_count = w3.eth.getUncleCount(empty_block['number']) assert is_integer(uncle_count) assert uncle_count == 0 - def test_eth_get_code(self, web3: "Web3", math_contract_address: ChecksumAddress) -> None: - code = web3.eth.get_code(math_contract_address) + def test_eth_get_code(self, w3: "Web3", math_contract_address: ChecksumAddress) -> None: + code = w3.eth.get_code(math_contract_address) assert isinstance(code, HexBytes) assert len(code) > 0 def test_eth_getCode_deprecated(self, - web3: "Web3", + w3: "Web3", math_contract_address: ChecksumAddress) -> None: with pytest.warns(DeprecationWarning, match='getCode is deprecated in favor of get_code'): - code = web3.eth.getCode(math_contract_address) + code = w3.eth.getCode(math_contract_address) assert isinstance(code, HexBytes) assert len(code) > 0 def test_eth_get_code_ens_address( - self, web3: "Web3", math_contract_address: ChecksumAddress + self, w3: "Web3", math_contract_address: ChecksumAddress ) -> None: with ens_addresses( - web3, {'mathcontract.eth': math_contract_address} + w3, {'mathcontract.eth': math_contract_address} ): - code = web3.eth.get_code('mathcontract.eth') + code = w3.eth.get_code('mathcontract.eth') assert isinstance(code, HexBytes) assert len(code) > 0 - def test_eth_get_code_invalid_address(self, web3: "Web3", math_contract: "Contract") -> None: + def test_eth_get_code_invalid_address(self, w3: "Web3", math_contract: "Contract") -> None: with pytest.raises(InvalidAddress): - web3.eth.get_code(ChecksumAddress(HexAddress(HexStr(math_contract.address.lower())))) + w3.eth.get_code(ChecksumAddress(HexAddress(HexStr(math_contract.address.lower())))) def test_eth_get_code_with_block_identifier( - self, web3: "Web3", emitter_contract: "Contract" + self, w3: "Web3", emitter_contract: "Contract" ) -> None: - code = web3.eth.get_code(emitter_contract.address, block_identifier=web3.eth.block_number) + code = w3.eth.get_code(emitter_contract.address, block_identifier=w3.eth.block_number) assert isinstance(code, HexBytes) assert len(code) > 0 - def test_eth_sign(self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress) -> None: - signature = web3.eth.sign( + def test_eth_sign(self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress) -> None: + signature = w3.eth.sign( unlocked_account_dual_type, text='Message tö sign. Longer than hash!' ) assert is_bytes(signature) assert len(signature) == 32 + 32 + 1 # test other formats - hexsign = web3.eth.sign( + hexsign = w3.eth.sign( unlocked_account_dual_type, hexstr=HexStr( '0x4d6573736167652074c3b6207369676e2e204c6f6e676572207468616e206861736821' @@ -1534,27 +1534,27 @@ def test_eth_sign(self, web3: "Web3", unlocked_account_dual_type: ChecksumAddres ) assert hexsign == signature - intsign = web3.eth.sign( + intsign = w3.eth.sign( unlocked_account_dual_type, 0x4d6573736167652074c3b6207369676e2e204c6f6e676572207468616e206861736821 ) assert intsign == signature - bytessign = web3.eth.sign( + bytessign = w3.eth.sign( unlocked_account_dual_type, b'Message t\xc3\xb6 sign. Longer than hash!' ) assert bytessign == signature - new_signature = web3.eth.sign( + new_signature = w3.eth.sign( unlocked_account_dual_type, text='different message is different' ) assert new_signature != signature def test_eth_sign_ens_names( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: - with ens_addresses(web3, {'unlocked-acct.eth': unlocked_account_dual_type}): - signature = web3.eth.sign( + with ens_addresses(w3, {'unlocked-acct.eth': unlocked_account_dual_type}): + signature = w3.eth.sign( 'unlocked-acct.eth', text='Message tö sign. Longer than hash!' ) assert is_bytes(signature) @@ -1562,7 +1562,7 @@ def test_eth_sign_ens_names( def test_eth_sign_typed_data( self, - web3: "Web3", + w3: "Web3", unlocked_account_dual_type: ChecksumAddress, skip_if_testrpc: Callable[["Web3"], None], ) -> None: @@ -1605,8 +1605,8 @@ def test_eth_sign_typed_data( } } ''' - skip_if_testrpc(web3) - signature = HexBytes(web3.eth.sign_typed_data( + skip_if_testrpc(w3) + signature = HexBytes(w3.eth.sign_typed_data( unlocked_account_dual_type, json.loads(validJSONMessage) )) @@ -1614,7 +1614,7 @@ def test_eth_sign_typed_data( def test_eth_signTypedData_deprecated( self, - web3: "Web3", + w3: "Web3", unlocked_account_dual_type: ChecksumAddress, skip_if_testrpc: Callable[["Web3"], None], ) -> None: @@ -1657,8 +1657,8 @@ def test_eth_signTypedData_deprecated( } } ''' - skip_if_testrpc(web3) - signature = HexBytes(web3.eth.signTypedData( + skip_if_testrpc(w3) + signature = HexBytes(w3.eth.signTypedData( unlocked_account_dual_type, json.loads(validJSONMessage) )) @@ -1666,11 +1666,11 @@ def test_eth_signTypedData_deprecated( def test_invalid_eth_sign_typed_data( self, - web3: "Web3", + w3: "Web3", unlocked_account_dual_type: ChecksumAddress, skip_if_testrpc: Callable[["Web3"], None] ) -> None: - skip_if_testrpc(web3) + skip_if_testrpc(w3) invalid_typed_message = ''' { "types": { @@ -1712,14 +1712,14 @@ def test_invalid_eth_sign_typed_data( ''' with pytest.raises(ValueError, match=r".*Expected 2 items for array type Person\[2\], got 1 items.*"): - web3.eth.sign_typed_data( + w3.eth.sign_typed_data( unlocked_account_dual_type, json.loads(invalid_typed_message) ) def test_eth_sign_transaction_legacy( self, - web3: "Web3", + w3: "Web3", unlocked_account: ChecksumAddress ) -> None: txn_params: TxParams = { @@ -1727,11 +1727,11 @@ def test_eth_sign_transaction_legacy( 'to': unlocked_account, 'value': Wei(1), 'gas': 21000, - 'gasPrice': web3.eth.gas_price, + 'gasPrice': w3.eth.gas_price, 'nonce': Nonce(0), } - result = web3.eth.sign_transaction(txn_params) - signatory_account = web3.eth.account.recover_transaction(result['raw']) + result = w3.eth.sign_transaction(txn_params) + signatory_account = w3.eth.account.recover_transaction(result['raw']) assert unlocked_account == signatory_account assert result['tx']['to'] == txn_params['to'] assert result['tx']['value'] == txn_params['value'] @@ -1741,7 +1741,7 @@ def test_eth_sign_transaction_legacy( def test_eth_sign_transaction( self, - web3: "Web3", + w3: "Web3", unlocked_account: ChecksumAddress ) -> None: txn_params: TxParams = { @@ -1749,12 +1749,12 @@ def test_eth_sign_transaction( 'to': unlocked_account, 'value': Wei(1), 'gas': 21000, - 'maxFeePerGas': web3.toWei(2, 'gwei'), - 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), + 'maxFeePerGas': w3.toWei(2, 'gwei'), + 'maxPriorityFeePerGas': w3.toWei(1, 'gwei'), 'nonce': Nonce(0), } - result = web3.eth.sign_transaction(txn_params) - signatory_account = web3.eth.account.recover_transaction(result['raw']) + result = w3.eth.sign_transaction(txn_params) + signatory_account = w3.eth.account.recover_transaction(result['raw']) assert unlocked_account == signatory_account assert result['tx']['to'] == txn_params['to'] assert result['tx']['value'] == txn_params['value'] @@ -1765,7 +1765,7 @@ def test_eth_sign_transaction( def test_eth_sign_transaction_hex_fees( self, - web3: "Web3", + w3: "Web3", unlocked_account: ChecksumAddress ) -> None: txn_params: TxParams = { @@ -1773,12 +1773,12 @@ def test_eth_sign_transaction_hex_fees( 'to': unlocked_account, 'value': Wei(1), 'gas': 21000, - 'maxFeePerGas': hex(web3.toWei(2, 'gwei')), - 'maxPriorityFeePerGas': hex(web3.toWei(1, 'gwei')), + 'maxFeePerGas': hex(w3.toWei(2, 'gwei')), + 'maxPriorityFeePerGas': hex(w3.toWei(1, 'gwei')), 'nonce': Nonce(0), } - result = web3.eth.sign_transaction(txn_params) - signatory_account = web3.eth.account.recover_transaction(result['raw']) + result = w3.eth.sign_transaction(txn_params) + signatory_account = w3.eth.account.recover_transaction(result['raw']) assert unlocked_account == signatory_account assert result['tx']['to'] == txn_params['to'] assert result['tx']['value'] == txn_params['value'] @@ -1790,20 +1790,20 @@ def test_eth_sign_transaction_hex_fees( assert result['tx']['nonce'] == txn_params['nonce'] def test_eth_signTransaction_deprecated(self, - web3: "Web3", + w3: "Web3", unlocked_account: ChecksumAddress) -> None: txn_params: TxParams = { 'from': unlocked_account, 'to': unlocked_account, 'value': Wei(1), 'gas': 21000, - 'gasPrice': web3.eth.gas_price, + 'gasPrice': w3.eth.gas_price, 'nonce': Nonce(0), } with pytest.warns(DeprecationWarning, match='signTransaction is deprecated in favor of sign_transaction'): - result = web3.eth.signTransaction(txn_params) - signatory_account = web3.eth.account.recover_transaction(result['raw']) + result = w3.eth.signTransaction(txn_params) + signatory_account = w3.eth.account.recover_transaction(result['raw']) assert unlocked_account == signatory_account assert result['tx']['to'] == txn_params['to'] assert result['tx']['value'] == txn_params['value'] @@ -1812,20 +1812,20 @@ def test_eth_signTransaction_deprecated(self, assert result['tx']['nonce'] == txn_params['nonce'] def test_eth_sign_transaction_ens_names( - self, web3: "Web3", unlocked_account: ChecksumAddress + self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: - with ens_addresses(web3, {'unlocked-account.eth': unlocked_account}): + with ens_addresses(w3, {'unlocked-account.eth': unlocked_account}): txn_params: TxParams = { 'from': 'unlocked-account.eth', 'to': 'unlocked-account.eth', 'value': Wei(1), 'gas': 21000, - 'maxFeePerGas': web3.toWei(2, 'gwei'), - 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), + 'maxFeePerGas': w3.toWei(2, 'gwei'), + 'maxPriorityFeePerGas': w3.toWei(1, 'gwei'), 'nonce': Nonce(0), } - result = web3.eth.sign_transaction(txn_params) - signatory_account = web3.eth.account.recover_transaction(result['raw']) + result = w3.eth.sign_transaction(txn_params) + signatory_account = w3.eth.account.recover_transaction(result['raw']) assert unlocked_account == signatory_account assert result['tx']['to'] == unlocked_account assert result['tx']['value'] == txn_params['value'] @@ -1835,7 +1835,7 @@ def test_eth_sign_transaction_ens_names( assert result['tx']['nonce'] == txn_params['nonce'] def test_eth_send_transaction_addr_checksum_required( - self, web3: "Web3", unlocked_account: ChecksumAddress + self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: non_checksum_addr = unlocked_account.lower() txn_params: TxParams = { @@ -1843,30 +1843,30 @@ def test_eth_send_transaction_addr_checksum_required( 'to': unlocked_account, 'value': Wei(1), 'gas': 21000, - 'maxFeePerGas': web3.toWei(2, 'gwei'), - 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), + 'maxFeePerGas': w3.toWei(2, 'gwei'), + 'maxPriorityFeePerGas': w3.toWei(1, 'gwei'), } with pytest.raises(InvalidAddress): invalid_params = cast(TxParams, dict(txn_params, **{'from': non_checksum_addr})) - web3.eth.send_transaction(invalid_params) + w3.eth.send_transaction(invalid_params) with pytest.raises(InvalidAddress): invalid_params = cast(TxParams, dict(txn_params, **{'to': non_checksum_addr})) - web3.eth.send_transaction(invalid_params) + w3.eth.send_transaction(invalid_params) def test_eth_send_transaction_legacy( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), 'gas': 21000, - 'gasPrice': web3.toWei(1, 'gwei'), # post-london needs to be more than the base fee + 'gasPrice': w3.toWei(1, 'gwei'), # post-london needs to be more than the base fee } - txn_hash = web3.eth.send_transaction(txn_params) - txn = web3.eth.get_transaction(txn_hash) + txn_hash = w3.eth.send_transaction(txn_params) + txn = w3.eth.get_transaction(txn_hash) assert is_same_address(txn['from'], cast(ChecksumAddress, txn_params['from'])) assert is_same_address(txn['to'], cast(ChecksumAddress, txn_params['to'])) @@ -1875,18 +1875,18 @@ def test_eth_send_transaction_legacy( assert txn['gasPrice'] == txn_params['gasPrice'] def test_eth_send_transaction( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), 'gas': 21000, - 'maxFeePerGas': web3.toWei(3, 'gwei'), - 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), + 'maxFeePerGas': w3.toWei(3, 'gwei'), + 'maxPriorityFeePerGas': w3.toWei(1, 'gwei'), } - txn_hash = web3.eth.send_transaction(txn_params) - txn = web3.eth.get_transaction(txn_hash) + txn_hash = w3.eth.send_transaction(txn_params) + txn = w3.eth.get_transaction(txn_hash) assert is_same_address(txn['from'], cast(ChecksumAddress, txn_params['from'])) assert is_same_address(txn['to'], cast(ChecksumAddress, txn_params['to'])) @@ -1897,20 +1897,20 @@ def test_eth_send_transaction( assert txn['gasPrice'] == txn_params['maxFeePerGas'] def test_eth_sendTransaction_deprecated( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), 'gas': 21000, - 'maxFeePerGas': web3.toWei(3, 'gwei'), - 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), + 'maxFeePerGas': w3.toWei(3, 'gwei'), + 'maxPriorityFeePerGas': w3.toWei(1, 'gwei'), } with pytest.warns(DeprecationWarning, match="sendTransaction is deprecated in favor of send_transaction"): - txn_hash = web3.eth.sendTransaction(txn_params) - txn = web3.eth.get_transaction(txn_hash) + txn_hash = w3.eth.sendTransaction(txn_params) + txn = w3.eth.get_transaction(txn_hash) assert is_same_address(txn['from'], cast(ChecksumAddress, txn_params['from'])) assert is_same_address(txn['to'], cast(ChecksumAddress, txn_params['to'])) @@ -1921,9 +1921,9 @@ def test_eth_sendTransaction_deprecated( assert txn['gasPrice'] == txn_params['maxFeePerGas'] def test_eth_send_transaction_with_nonce( - self, web3: "Web3", unlocked_account: ChecksumAddress + self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: - mine_pending_block(web3) # gives an accurate transaction count after mining + mine_pending_block(w3) # gives an accurate transaction count after mining txn_params: TxParams = { 'from': unlocked_account, @@ -1931,12 +1931,12 @@ def test_eth_send_transaction_with_nonce( 'value': Wei(1), 'gas': 21000, # unique maxFeePerGas to ensure transaction hash different from other tests - 'maxFeePerGas': web3.toWei(4.321, 'gwei'), - 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), - 'nonce': web3.eth.get_transaction_count(unlocked_account), + 'maxFeePerGas': w3.toWei(4.321, 'gwei'), + 'maxPriorityFeePerGas': w3.toWei(1, 'gwei'), + 'nonce': w3.eth.get_transaction_count(unlocked_account), } - txn_hash = web3.eth.send_transaction(txn_params) - txn = web3.eth.get_transaction(txn_hash) + txn_hash = w3.eth.send_transaction(txn_params) + txn = w3.eth.get_transaction(txn_hash) assert is_same_address(txn['from'], cast(ChecksumAddress, txn_params['from'])) assert is_same_address(txn['to'], cast(ChecksumAddress, txn_params['to'])) @@ -1948,7 +1948,7 @@ def test_eth_send_transaction_with_nonce( assert txn['gasPrice'] == txn_params['maxFeePerGas'] def test_eth_send_transaction_default_fees( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account_dual_type, @@ -1956,8 +1956,8 @@ def test_eth_send_transaction_default_fees( 'value': Wei(1), 'gas': 21000, } - txn_hash = web3.eth.send_transaction(txn_params) - txn = web3.eth.get_transaction(txn_hash) + txn_hash = w3.eth.send_transaction(txn_params) + txn = w3.eth.get_transaction(txn_hash) assert is_same_address(txn['from'], cast(ChecksumAddress, txn_params['from'])) assert is_same_address(txn['to'], cast(ChecksumAddress, txn_params['to'])) @@ -1968,7 +1968,7 @@ def test_eth_send_transaction_default_fees( assert txn['gasPrice'] == txn['maxFeePerGas'] def test_eth_send_transaction_hex_fees( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account_dual_type, @@ -1978,8 +1978,8 @@ def test_eth_send_transaction_hex_fees( 'maxFeePerGas': hex(250 * 10**9), 'maxPriorityFeePerGas': hex(2 * 10**9), } - txn_hash = web3.eth.send_transaction(txn_params) - txn = web3.eth.get_transaction(txn_hash) + txn_hash = w3.eth.send_transaction(txn_params) + txn = w3.eth.get_transaction(txn_hash) assert is_same_address(txn['from'], cast(ChecksumAddress, txn_params['from'])) assert is_same_address(txn['to'], cast(ChecksumAddress, txn_params['to'])) @@ -1989,7 +1989,7 @@ def test_eth_send_transaction_hex_fees( assert txn['maxPriorityFeePerGas'] == 2 * 10**9 def test_eth_send_transaction_no_gas( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account_dual_type, @@ -1998,8 +1998,8 @@ def test_eth_send_transaction_no_gas( 'maxFeePerGas': Wei(250 * 10**9), 'maxPriorityFeePerGas': Wei(2 * 10**9), } - txn_hash = web3.eth.send_transaction(txn_params) - txn = web3.eth.get_transaction(txn_hash) + txn_hash = w3.eth.send_transaction(txn_params) + txn = w3.eth.get_transaction(txn_hash) assert is_same_address(txn['from'], cast(ChecksumAddress, txn_params['from'])) assert is_same_address(txn['to'], cast(ChecksumAddress, txn_params['to'])) @@ -2007,7 +2007,7 @@ def test_eth_send_transaction_no_gas( assert txn['gas'] == 121000 # 21000 + buffer def test_eth_send_transaction_with_gas_price( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account_dual_type, @@ -2019,10 +2019,10 @@ def test_eth_send_transaction_with_gas_price( 'maxPriorityFeePerGas': Wei(2 * 10**9), } with pytest.raises(TransactionTypeMismatch): - web3.eth.send_transaction(txn_params) + w3.eth.send_transaction(txn_params) def test_eth_send_transaction_no_priority_fee( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account_dual_type, @@ -2032,12 +2032,12 @@ def test_eth_send_transaction_no_priority_fee( 'maxFeePerGas': Wei(250 * 10**9), } with pytest.raises(InvalidTransaction, match='maxPriorityFeePerGas must be defined'): - web3.eth.send_transaction(txn_params) + w3.eth.send_transaction(txn_params) def test_eth_send_transaction_no_max_fee( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: - maxPriorityFeePerGas = web3.toWei(2, 'gwei') + maxPriorityFeePerGas = w3.toWei(2, 'gwei') txn_params: TxParams = { 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, @@ -2045,19 +2045,19 @@ def test_eth_send_transaction_no_max_fee( 'gas': 21000, 'maxPriorityFeePerGas': maxPriorityFeePerGas, } - txn_hash = web3.eth.send_transaction(txn_params) - txn = web3.eth.get_transaction(txn_hash) + txn_hash = w3.eth.send_transaction(txn_params) + txn = w3.eth.get_transaction(txn_hash) assert is_same_address(txn['from'], cast(ChecksumAddress, txn_params['from'])) assert is_same_address(txn['to'], cast(ChecksumAddress, txn_params['to'])) assert txn['value'] == 1 assert txn['gas'] == 21000 - block = web3.eth.get_block('latest') + block = w3.eth.get_block('latest') assert txn['maxFeePerGas'] == maxPriorityFeePerGas + 2 * block['baseFeePerGas'] def test_eth_send_transaction_max_fee_less_than_tip( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account_dual_type, @@ -2070,21 +2070,21 @@ def test_eth_send_transaction_max_fee_less_than_tip( with pytest.raises( InvalidTransaction, match="maxFeePerGas must be >= maxPriorityFeePerGas" ): - web3.eth.send_transaction(txn_params) + w3.eth.send_transaction(txn_params) def test_validation_middleware_chain_id_mismatch( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: wrong_chain_id = 1234567890 - actual_chain_id = web3.eth.chain_id + actual_chain_id = w3.eth.chain_id txn_params: TxParams = { 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), 'gas': Wei(21000), - 'maxFeePerGas': web3.toWei(2, 'gwei'), - 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), + 'maxFeePerGas': w3.toWei(2, 'gwei'), + 'maxPriorityFeePerGas': w3.toWei(1, 'gwei'), 'chainId': wrong_chain_id, } @@ -2093,7 +2093,7 @@ def test_validation_middleware_chain_id_mismatch( match=f'The transaction declared chain ID {wrong_chain_id}, ' f'but the connected node is on {actual_chain_id}' ): - web3.eth.send_transaction(txn_params) + w3.eth.send_transaction(txn_params) @pytest.mark.parametrize( "max_fee", @@ -2101,9 +2101,9 @@ def test_validation_middleware_chain_id_mismatch( ids=["with_max_fee", "without_max_fee"] ) def test_gas_price_from_strategy_bypassed_for_dynamic_fee_txn( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress, max_fee: Wei + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress, max_fee: Wei ) -> None: - max_priority_fee = web3.toWei(1, 'gwei') + max_priority_fee = w3.toWei(1, 'gwei') txn_params: TxParams = { 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, @@ -2114,23 +2114,23 @@ def test_gas_price_from_strategy_bypassed_for_dynamic_fee_txn( if max_fee is not None: txn_params = assoc(txn_params, "maxFeePerGas", max_fee) - def gas_price_strategy(_web3: "Web3", _txn: TxParams) -> Wei: - return web3.toWei(2, 'gwei') - web3.eth.set_gas_price_strategy(gas_price_strategy) + def gas_price_strategy(_w3: "Web3", _txn: TxParams) -> Wei: + return w3.toWei(2, 'gwei') + w3.eth.set_gas_price_strategy(gas_price_strategy) - txn_hash = web3.eth.send_transaction(txn_params) - txn = web3.eth.get_transaction(txn_hash) + txn_hash = w3.eth.send_transaction(txn_params) + txn = w3.eth.get_transaction(txn_hash) - latest_block = web3.eth.get_block('latest') + latest_block = w3.eth.get_block('latest') assert txn['maxFeePerGas'] == max_fee if max_fee is not None \ else 2 * latest_block['baseFeePerGas'] + max_priority_fee assert txn['maxPriorityFeePerGas'] == max_priority_fee assert txn['gasPrice'] == txn['maxFeePerGas'] - web3.eth.set_gas_price_strategy(None) # reset strategy + w3.eth.set_gas_price_strategy(None) # reset strategy def test_gas_price_from_strategy_bypassed_for_dynamic_fee_txn_no_tip( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress, + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress, ) -> None: txn_params: TxParams = { 'from': unlocked_account_dual_type, @@ -2140,30 +2140,30 @@ def test_gas_price_from_strategy_bypassed_for_dynamic_fee_txn_no_tip( 'maxFeePerGas': Wei(1000000000), } - def gas_price_strategy(_web3: "Web3", _txn: TxParams) -> Wei: - return web3.toWei(2, 'gwei') - web3.eth.set_gas_price_strategy(gas_price_strategy) + def gas_price_strategy(_w3: "Web3", _txn: TxParams) -> Wei: + return w3.toWei(2, 'gwei') + w3.eth.set_gas_price_strategy(gas_price_strategy) with pytest.raises(InvalidTransaction, match="maxPriorityFeePerGas must be defined"): - web3.eth.send_transaction(txn_params) + w3.eth.send_transaction(txn_params) - web3.eth.set_gas_price_strategy(None) # reset strategy + w3.eth.set_gas_price_strategy(None) # reset strategy def test_eth_replace_transaction_legacy( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), 'gas': 21000, - 'gasPrice': web3.toWei(1, 'gwei'), # must be greater than base_fee post London + 'gasPrice': w3.toWei(1, 'gwei'), # must be greater than base_fee post London } - txn_hash = web3.eth.send_transaction(txn_params) + txn_hash = w3.eth.send_transaction(txn_params) - txn_params['gasPrice'] = web3.toWei(2, 'gwei') - replace_txn_hash = web3.eth.replace_transaction(txn_hash, txn_params) - replace_txn = web3.eth.get_transaction(replace_txn_hash) + txn_params['gasPrice'] = w3.toWei(2, 'gwei') + replace_txn_hash = w3.eth.replace_transaction(txn_hash, txn_params) + replace_txn = w3.eth.get_transaction(replace_txn_hash) assert is_same_address(replace_txn['from'], cast(ChecksumAddress, txn_params['from'])) assert is_same_address(replace_txn['to'], cast(ChecksumAddress, txn_params['to'])) @@ -2172,10 +2172,10 @@ def test_eth_replace_transaction_legacy( assert replace_txn['gasPrice'] == txn_params['gasPrice'] def test_eth_replace_transaction( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: - two_gwei_in_wei = web3.toWei(2, 'gwei') - three_gwei_in_wei = web3.toWei(3, 'gwei') + two_gwei_in_wei = w3.toWei(2, 'gwei') + three_gwei_in_wei = w3.toWei(3, 'gwei') txn_params: TxParams = { 'from': unlocked_account_dual_type, @@ -2183,15 +2183,15 @@ def test_eth_replace_transaction( 'value': Wei(1), 'gas': 21000, 'maxFeePerGas': two_gwei_in_wei, - 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), + 'maxPriorityFeePerGas': w3.toWei(1, 'gwei'), } - txn_hash = web3.eth.send_transaction(txn_params) + txn_hash = w3.eth.send_transaction(txn_params) txn_params['maxFeePerGas'] = three_gwei_in_wei txn_params['maxPriorityFeePerGas'] = two_gwei_in_wei - replace_txn_hash = web3.eth.replace_transaction(txn_hash, txn_params) - replace_txn = web3.eth.get_transaction(replace_txn_hash) + replace_txn_hash = w3.eth.replace_transaction(txn_hash, txn_params) + replace_txn = w3.eth.get_transaction(replace_txn_hash) assert is_same_address(replace_txn['from'], cast(ChecksumAddress, txn_params['from'])) assert is_same_address(replace_txn['to'], cast(ChecksumAddress, txn_params['to'])) @@ -2201,30 +2201,30 @@ def test_eth_replace_transaction( assert replace_txn['maxPriorityFeePerGas'] == two_gwei_in_wei def test_eth_replace_transaction_underpriced( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), 'gas': 21000, - 'maxFeePerGas': web3.toWei(3, 'gwei'), - 'maxPriorityFeePerGas': web3.toWei(2, 'gwei'), + 'maxFeePerGas': w3.toWei(3, 'gwei'), + 'maxPriorityFeePerGas': w3.toWei(2, 'gwei'), } - txn_hash = web3.eth.send_transaction(txn_params) + txn_hash = w3.eth.send_transaction(txn_params) - one_gwei_in_wei = web3.toWei(1, 'gwei') + one_gwei_in_wei = w3.toWei(1, 'gwei') txn_params['maxFeePerGas'] = one_gwei_in_wei txn_params['maxPriorityFeePerGas'] = one_gwei_in_wei with pytest.raises(ValueError, match="replacement transaction underpriced"): - web3.eth.replace_transaction(txn_hash, txn_params) + w3.eth.replace_transaction(txn_hash, txn_params) def test_eth_replaceTransaction_deprecated( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: - two_gwei_in_wei = web3.toWei(2, 'gwei') - three_gwei_in_wei = web3.toWei(3, 'gwei') + two_gwei_in_wei = w3.toWei(2, 'gwei') + three_gwei_in_wei = w3.toWei(3, 'gwei') txn_params: TxParams = { 'from': unlocked_account_dual_type, @@ -2232,9 +2232,9 @@ def test_eth_replaceTransaction_deprecated( 'value': Wei(1), 'gas': 21000, 'maxFeePerGas': two_gwei_in_wei, - 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), + 'maxPriorityFeePerGas': w3.toWei(1, 'gwei'), } - txn_hash = web3.eth.send_transaction(txn_params) + txn_hash = w3.eth.send_transaction(txn_params) txn_params['maxFeePerGas'] = three_gwei_in_wei txn_params['maxPriorityFeePerGas'] = two_gwei_in_wei @@ -2242,8 +2242,8 @@ def test_eth_replaceTransaction_deprecated( DeprecationWarning, match="replaceTransaction is deprecated in favor of replace_transaction" ): - replace_txn_hash = web3.eth.replaceTransaction(txn_hash, txn_params) - replace_txn = web3.eth.get_transaction(replace_txn_hash) + replace_txn_hash = w3.eth.replaceTransaction(txn_hash, txn_params) + replace_txn = w3.eth.get_transaction(replace_txn_hash) assert is_same_address(replace_txn['from'], cast(ChecksumAddress, txn_params['from'])) assert is_same_address(replace_txn['to'], cast(ChecksumAddress, txn_params['to'])) @@ -2253,85 +2253,85 @@ def test_eth_replaceTransaction_deprecated( assert replace_txn['maxPriorityFeePerGas'] == two_gwei_in_wei def test_eth_replace_transaction_non_existing_transaction( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), 'gas': 21000, - 'maxFeePerGas': web3.toWei(3, 'gwei'), - 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), + 'maxFeePerGas': w3.toWei(3, 'gwei'), + 'maxPriorityFeePerGas': w3.toWei(1, 'gwei'), } with pytest.raises(TransactionNotFound): - web3.eth.replace_transaction( + w3.eth.replace_transaction( HexStr('0x98e8cc09b311583c5079fa600f6c2a3bea8611af168c52e4b60b5b243a441997'), txn_params ) def test_eth_replace_transaction_already_mined( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), 'gas': 21000, - 'maxFeePerGas': web3.toWei(2, 'gwei'), - 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), + 'maxFeePerGas': w3.toWei(2, 'gwei'), + 'maxPriorityFeePerGas': w3.toWei(1, 'gwei'), } - txn_hash = web3.eth.send_transaction(txn_params) + txn_hash = w3.eth.send_transaction(txn_params) try: - web3.geth.miner.start() # type: ignore - web3.eth.wait_for_transaction_receipt(txn_hash, timeout=10) + w3.geth.miner.start() # type: ignore + w3.eth.wait_for_transaction_receipt(txn_hash, timeout=10) finally: - web3.geth.miner.stop() # type: ignore + w3.geth.miner.stop() # type: ignore - txn_params['maxFeePerGas'] = web3.toWei(3, 'gwei') - txn_params['maxPriorityFeePerGas'] = web3.toWei(2, 'gwei') + txn_params['maxFeePerGas'] = w3.toWei(3, 'gwei') + txn_params['maxPriorityFeePerGas'] = w3.toWei(2, 'gwei') with pytest.raises(ValueError, match="Supplied transaction with hash"): - web3.eth.replace_transaction(txn_hash, txn_params) + w3.eth.replace_transaction(txn_hash, txn_params) def test_eth_replace_transaction_incorrect_nonce( - self, web3: "Web3", unlocked_account: ChecksumAddress + self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account, 'to': unlocked_account, 'value': Wei(1), 'gas': 21000, - 'maxFeePerGas': web3.toWei(2, 'gwei'), - 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), + 'maxFeePerGas': w3.toWei(2, 'gwei'), + 'maxPriorityFeePerGas': w3.toWei(1, 'gwei'), } - txn_hash = web3.eth.send_transaction(txn_params) - txn = web3.eth.get_transaction(txn_hash) + txn_hash = w3.eth.send_transaction(txn_params) + txn = w3.eth.get_transaction(txn_hash) - txn_params['maxFeePerGas'] = web3.toWei(3, 'gwei') - txn_params['maxPriorityFeePerGas'] = web3.toWei(2, 'gwei') + txn_params['maxFeePerGas'] = w3.toWei(3, 'gwei') + txn_params['maxPriorityFeePerGas'] = w3.toWei(2, 'gwei') txn_params['nonce'] = Nonce(txn['nonce'] + 1) with pytest.raises(ValueError): - web3.eth.replace_transaction(txn_hash, txn_params) + w3.eth.replace_transaction(txn_hash, txn_params) def test_eth_replace_transaction_gas_price_too_low( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), 'gas': 21000, - 'gasPrice': web3.toWei(2, 'gwei'), + 'gasPrice': w3.toWei(2, 'gwei'), } - txn_hash = web3.eth.send_transaction(txn_params) + txn_hash = w3.eth.send_transaction(txn_params) - txn_params['gasPrice'] = web3.toWei(1, 'gwei') + txn_params['gasPrice'] = w3.toWei(1, 'gwei') with pytest.raises(ValueError): - web3.eth.replace_transaction(txn_hash, txn_params) + w3.eth.replace_transaction(txn_hash, txn_params) def test_eth_replace_transaction_gas_price_defaulting_minimum( - self, web3: "Web3", unlocked_account: ChecksumAddress + self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: - gas_price = web3.toWei(1, 'gwei') + gas_price = w3.toWei(1, 'gwei') txn_params: TxParams = { 'from': unlocked_account, @@ -2340,43 +2340,43 @@ def test_eth_replace_transaction_gas_price_defaulting_minimum( 'gas': 21000, 'gasPrice': gas_price, } - txn_hash = web3.eth.send_transaction(txn_params) + txn_hash = w3.eth.send_transaction(txn_params) txn_params.pop('gasPrice') - replace_txn_hash = web3.eth.replace_transaction(txn_hash, txn_params) - replace_txn = web3.eth.get_transaction(replace_txn_hash) + replace_txn_hash = w3.eth.replace_transaction(txn_hash, txn_params) + replace_txn = w3.eth.get_transaction(replace_txn_hash) assert replace_txn['gasPrice'] == math.ceil(gas_price * 1.125) # minimum gas price def test_eth_replace_transaction_gas_price_defaulting_strategy_higher( - self, web3: "Web3", unlocked_account: ChecksumAddress + self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account, 'to': unlocked_account, 'value': Wei(1), 'gas': 21000, - 'gasPrice': web3.toWei(1, 'gwei'), + 'gasPrice': w3.toWei(1, 'gwei'), } - txn_hash = web3.eth.send_transaction(txn_params) + txn_hash = w3.eth.send_transaction(txn_params) - two_gwei_in_wei = web3.toWei(2, 'gwei') + two_gwei_in_wei = w3.toWei(2, 'gwei') - def higher_gas_price_strategy(web3: "Web3", txn: TxParams) -> Wei: + def higher_gas_price_strategy(w3: "Web3", txn: TxParams) -> Wei: return two_gwei_in_wei - web3.eth.set_gas_price_strategy(higher_gas_price_strategy) + w3.eth.set_gas_price_strategy(higher_gas_price_strategy) txn_params.pop('gasPrice') - replace_txn_hash = web3.eth.replace_transaction(txn_hash, txn_params) - replace_txn = web3.eth.get_transaction(replace_txn_hash) + replace_txn_hash = w3.eth.replace_transaction(txn_hash, txn_params) + replace_txn = w3.eth.get_transaction(replace_txn_hash) assert replace_txn['gasPrice'] == two_gwei_in_wei # Strategy provides higher gas price - web3.eth.set_gas_price_strategy(None) # reset strategy + w3.eth.set_gas_price_strategy(None) # reset strategy def test_eth_replace_transaction_gas_price_defaulting_strategy_lower( - self, web3: "Web3", unlocked_account: ChecksumAddress + self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: - gas_price = web3.toWei(2, 'gwei') + gas_price = w3.toWei(2, 'gwei') txn_params: TxParams = { 'from': unlocked_account, @@ -2385,36 +2385,36 @@ def test_eth_replace_transaction_gas_price_defaulting_strategy_lower( 'gas': 21000, 'gasPrice': gas_price, } - txn_hash = web3.eth.send_transaction(txn_params) + txn_hash = w3.eth.send_transaction(txn_params) - def lower_gas_price_strategy(web3: "Web3", txn: TxParams) -> Wei: - return web3.toWei(1, 'gwei') + def lower_gas_price_strategy(w3: "Web3", txn: TxParams) -> Wei: + return w3.toWei(1, 'gwei') - web3.eth.set_gas_price_strategy(lower_gas_price_strategy) + w3.eth.set_gas_price_strategy(lower_gas_price_strategy) txn_params.pop('gasPrice') - replace_txn_hash = web3.eth.replace_transaction(txn_hash, txn_params) - replace_txn = web3.eth.get_transaction(replace_txn_hash) + replace_txn_hash = w3.eth.replace_transaction(txn_hash, txn_params) + replace_txn = w3.eth.get_transaction(replace_txn_hash) # Strategy provides lower gas price - minimum preferred assert replace_txn['gasPrice'] == math.ceil(gas_price * 1.125) - web3.eth.set_gas_price_strategy(None) # reset strategy + w3.eth.set_gas_price_strategy(None) # reset strategy def test_eth_modify_transaction_legacy( - self, web3: "Web3", unlocked_account: ChecksumAddress + self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account, 'to': unlocked_account, 'value': Wei(1), 'gas': 21000, - 'gasPrice': web3.toWei(1, 'gwei'), # must be greater than base_fee post London + 'gasPrice': w3.toWei(1, 'gwei'), # must be greater than base_fee post London } - txn_hash = web3.eth.send_transaction(txn_params) + txn_hash = w3.eth.send_transaction(txn_params) - modified_txn_hash = web3.eth.modify_transaction( + modified_txn_hash = w3.eth.modify_transaction( txn_hash, gasPrice=(cast(int, txn_params['gasPrice']) * 2), value=2 ) - modified_txn = web3.eth.get_transaction(modified_txn_hash) + modified_txn = w3.eth.get_transaction(modified_txn_hash) assert is_same_address(modified_txn['from'], cast(ChecksumAddress, txn_params['from'])) assert is_same_address(modified_txn['to'], cast(ChecksumAddress, txn_params['to'])) @@ -2423,25 +2423,25 @@ def test_eth_modify_transaction_legacy( assert modified_txn['gasPrice'] == cast(int, txn_params['gasPrice']) * 2 def test_eth_modify_transaction( - self, web3: "Web3", unlocked_account: ChecksumAddress + self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account, 'to': unlocked_account, 'value': Wei(1), 'gas': 21000, - 'maxPriorityFeePerGas': web3.toWei(1, 'gwei'), - 'maxFeePerGas': web3.toWei(2, 'gwei'), + 'maxPriorityFeePerGas': w3.toWei(1, 'gwei'), + 'maxFeePerGas': w3.toWei(2, 'gwei'), } - txn_hash = web3.eth.send_transaction(txn_params) + txn_hash = w3.eth.send_transaction(txn_params) - modified_txn_hash = web3.eth.modify_transaction( + modified_txn_hash = w3.eth.modify_transaction( txn_hash, value=2, maxPriorityFeePerGas=(cast(Wei, txn_params['maxPriorityFeePerGas']) * 2), maxFeePerGas=(cast(Wei, txn_params['maxFeePerGas']) * 2), ) - modified_txn = web3.eth.get_transaction(modified_txn_hash) + modified_txn = w3.eth.get_transaction(modified_txn_hash) assert is_same_address(modified_txn['from'], cast(ChecksumAddress, txn_params['from'])) assert is_same_address(modified_txn['to'], cast(ChecksumAddress, txn_params['to'])) @@ -2452,23 +2452,23 @@ def test_eth_modify_transaction( assert modified_txn['maxFeePerGas'] == cast(Wei, txn_params['maxFeePerGas']) * 2 def test_eth_modifyTransaction_deprecated( - self, web3: "Web3", unlocked_account: ChecksumAddress + self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: txn_params: TxParams = { 'from': unlocked_account, 'to': unlocked_account, 'value': Wei(1), 'gas': 21000, - 'gasPrice': web3.toWei(1, 'gwei'), + 'gasPrice': w3.toWei(1, 'gwei'), } - txn_hash = web3.eth.send_transaction(txn_params) + txn_hash = w3.eth.send_transaction(txn_params) with pytest.warns( DeprecationWarning, match="modifyTransaction is deprecated in favor of modify_transaction"): - modified_txn_hash = web3.eth.modifyTransaction( + modified_txn_hash = w3.eth.modifyTransaction( txn_hash, gasPrice=(cast(int, txn_params['gasPrice']) * 2), value=2 ) - modified_txn = web3.eth.get_transaction(modified_txn_hash) + modified_txn = w3.eth.get_transaction(modified_txn_hash) assert is_same_address(modified_txn['from'], cast(ChecksumAddress, txn_params['from'])) assert is_same_address(modified_txn['to'], cast(ChecksumAddress, txn_params['to'])) assert modified_txn['value'] == 2 @@ -2476,13 +2476,13 @@ def test_eth_modifyTransaction_deprecated( assert modified_txn['gasPrice'] == cast(int, txn_params['gasPrice']) * 2 def test_eth_send_raw_transaction( - self, web3: "Web3", unlocked_account: ChecksumAddress + self, w3: "Web3", unlocked_account: ChecksumAddress ) -> None: - signed_tx = web3.eth.account.sign_transaction( + signed_tx = w3.eth.account.sign_transaction( { 'to': '0x0000000000000000000000000000000000000000', 'value': 0, - 'nonce': web3.eth.get_transaction_count(unlocked_account), + 'nonce': w3.eth.get_transaction_count(unlocked_account), 'gas': 21000, 'maxFeePerGas': 1000000000, 'maxPriorityFeePerGas': 1000000000, @@ -2491,62 +2491,62 @@ def test_eth_send_raw_transaction( # unlocked_account private key: '0x392f63a79b1ff8774845f3fa69de4a13800a59e7083f5187f1558f0797ad0f01' ) - txn_hash = web3.eth.send_raw_transaction(signed_tx.rawTransaction) + txn_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction) assert txn_hash == signed_tx.hash def test_eth_call( - self, web3: "Web3", math_contract: "Contract" + self, w3: "Web3", math_contract: "Contract" ) -> None: - coinbase = web3.eth.coinbase + coinbase = w3.eth.coinbase txn_params = math_contract._prepare_transaction( fn_name='add', fn_args=(7, 11), transaction={'from': coinbase, 'to': math_contract.address}, ) - call_result = web3.eth.call(txn_params) + call_result = w3.eth.call(txn_params) assert is_string(call_result) - result = web3.codec.decode_single('uint256', call_result) + result = w3.codec.decode_single('uint256', call_result) assert result == 18 def test_eth_call_with_override( - self, web3: "Web3", revert_contract: "Contract" + self, w3: "Web3", revert_contract: "Contract" ) -> None: - coinbase = web3.eth.coinbase + coinbase = w3.eth.coinbase txn_params = revert_contract._prepare_transaction( fn_name='normalFunction', transaction={'from': coinbase, 'to': revert_contract.address}, ) - call_result = web3.eth.call(txn_params) - result = web3.codec.decode_single('bool', call_result) + call_result = w3.eth.call(txn_params) + result = w3.codec.decode_single('bool', call_result) assert result is True # override runtime bytecode: `normalFunction` returns `false` override_code = '0x6080604052348015600f57600080fd5b5060043610603c5760003560e01c8063185c38a4146041578063c06a97cb146049578063d67e4b84146051575b600080fd5b60476071565b005b604f60df565b005b605760e4565b604051808215151515815260200191505060405180910390f35b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f46756e6374696f6e20686173206265656e2072657665727465642e000000000081525060200191505060405180910390fd5b600080fd5b60008090509056fea2646970667358221220bb71e9e9a2e271cd0fbe833524a3ea67df95f25ea13aef5b0a761fa52b538f1064736f6c63430006010033' # noqa: E501 - call_result = web3.eth.call( + call_result = w3.eth.call( txn_params, 'latest', {revert_contract.address: {'code': override_code}} ) - result = web3.codec.decode_single('bool', call_result) + result = w3.codec.decode_single('bool', call_result) assert result is False def test_eth_call_with_0_result( - self, web3: "Web3", math_contract: "Contract" + self, w3: "Web3", math_contract: "Contract" ) -> None: - coinbase = web3.eth.coinbase + coinbase = w3.eth.coinbase txn_params = math_contract._prepare_transaction( fn_name='add', fn_args=(0, 0), transaction={'from': coinbase, 'to': math_contract.address}, ) - call_result = web3.eth.call(txn_params) + call_result = w3.eth.call(txn_params) assert is_string(call_result) - result = web3.codec.decode_single('uint256', call_result) + result = w3.codec.decode_single('uint256', call_result) assert result == 0 def test_eth_call_revert_with_msg( self, - web3: "Web3", + w3: "Web3", revert_contract: "Contract", unlocked_account: ChecksumAddress, ) -> None: @@ -2559,11 +2559,11 @@ def test_eth_call_revert_with_msg( "to": revert_contract.address, }, ) - web3.eth.call(txn_params) + w3.eth.call(txn_params) def test_eth_call_revert_without_msg( self, - web3: "Web3", + w3: "Web3", revert_contract: "Contract", unlocked_account: ChecksumAddress, ) -> None: @@ -2575,11 +2575,11 @@ def test_eth_call_revert_without_msg( "to": revert_contract.address, }, ) - web3.eth.call(txn_params) + w3.eth.call(txn_params) def test_eth_estimate_gas_revert_with_msg( self, - web3: "Web3", + w3: "Web3", revert_contract: "Contract", unlocked_account: ChecksumAddress, ) -> None: @@ -2592,11 +2592,11 @@ def test_eth_estimate_gas_revert_with_msg( "to": revert_contract.address, }, ) - web3.eth.estimate_gas(txn_params) + w3.eth.estimate_gas(txn_params) def test_eth_estimate_gas_revert_without_msg( self, - web3: "Web3", + w3: "Web3", revert_contract: "Contract", unlocked_account: ChecksumAddress, ) -> None: @@ -2608,12 +2608,12 @@ def test_eth_estimate_gas_revert_without_msg( "to": revert_contract.address, }, ) - web3.eth.estimate_gas(txn_params) + w3.eth.estimate_gas(txn_params) def test_eth_estimate_gas( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: - gas_estimate = web3.eth.estimate_gas({ + gas_estimate = w3.eth.estimate_gas({ 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), @@ -2622,11 +2622,11 @@ def test_eth_estimate_gas( assert gas_estimate > 0 def test_eth_estimateGas_deprecated( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: with pytest.warns(DeprecationWarning, match="estimateGas is deprecated in favor of estimate_gas"): - gas_estimate = web3.eth.estimateGas({ + gas_estimate = w3.eth.estimateGas({ 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), @@ -2635,9 +2635,9 @@ def test_eth_estimateGas_deprecated( assert gas_estimate > 0 def test_eth_estimate_gas_with_block( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: - gas_estimate = web3.eth.estimate_gas({ + gas_estimate = w3.eth.estimate_gas({ 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), @@ -2646,141 +2646,141 @@ def test_eth_estimate_gas_with_block( assert gas_estimate > 0 def test_eth_getBlock_deprecated( - self, web3: "Web3", empty_block: BlockData + self, w3: "Web3", empty_block: BlockData ) -> None: with pytest.warns(DeprecationWarning, match="getBlock is deprecated in favor of get_block"): - block = web3.eth.getBlock(empty_block['hash']) + block = w3.eth.getBlock(empty_block['hash']) assert block['hash'] == empty_block['hash'] def test_eth_getBlockByHash( - self, web3: "Web3", empty_block: BlockData + self, w3: "Web3", empty_block: BlockData ) -> None: - block = web3.eth.get_block(empty_block['hash']) + block = w3.eth.get_block(empty_block['hash']) assert block['hash'] == empty_block['hash'] def test_eth_getBlockByHash_not_found( - self, web3: "Web3", empty_block: BlockData + self, w3: "Web3", empty_block: BlockData ) -> None: with pytest.raises(BlockNotFound): - web3.eth.get_block(UNKNOWN_HASH) + w3.eth.get_block(UNKNOWN_HASH) def test_eth_getBlockByHash_pending( - self, web3: "Web3" + self, w3: "Web3" ) -> None: - block = web3.eth.get_block('pending') + block = w3.eth.get_block('pending') assert block['hash'] is None def test_eth_getBlockByNumber_with_integer( - self, web3: "Web3", empty_block: BlockData + self, w3: "Web3", empty_block: BlockData ) -> None: - block = web3.eth.get_block(empty_block['number']) + block = w3.eth.get_block(empty_block['number']) assert block['number'] == empty_block['number'] def test_eth_getBlockByNumber_with_integer_deprecated( - self, web3: "Web3", empty_block: BlockData + self, w3: "Web3", empty_block: BlockData ) -> None: with pytest.warns(DeprecationWarning, match="getBlock is deprecated in favor of get_block"): - block = web3.eth.getBlock(empty_block['number']) + block = w3.eth.getBlock(empty_block['number']) assert block['number'] == empty_block['number'] def test_eth_getBlockByNumber_latest( - self, web3: "Web3", empty_block: BlockData + self, w3: "Web3", empty_block: BlockData ) -> None: - current_block_number = web3.eth.block_number - block = web3.eth.get_block('latest') + current_block_number = w3.eth.block_number + block = w3.eth.get_block('latest') assert block['number'] == current_block_number def test_eth_getBlockByNumber_not_found( - self, web3: "Web3", empty_block: BlockData + self, w3: "Web3", empty_block: BlockData ) -> None: with pytest.raises(BlockNotFound): - web3.eth.get_block(BlockNumber(12345)) + w3.eth.get_block(BlockNumber(12345)) def test_eth_getBlockByNumber_pending( - self, web3: "Web3", empty_block: BlockData + self, w3: "Web3", empty_block: BlockData ) -> None: - current_block_number = web3.eth.block_number - block = web3.eth.get_block('pending') + current_block_number = w3.eth.block_number + block = w3.eth.get_block('pending') assert block['number'] == current_block_number + 1 def test_eth_getBlockByNumber_earliest( - self, web3: "Web3", empty_block: BlockData + self, w3: "Web3", empty_block: BlockData ) -> None: - genesis_block = web3.eth.get_block(BlockNumber(0)) - block = web3.eth.get_block('earliest') + genesis_block = w3.eth.get_block(BlockNumber(0)) + block = w3.eth.get_block('earliest') assert block['number'] == 0 assert block['hash'] == genesis_block['hash'] def test_eth_getBlockByNumber_full_transactions( - self, web3: "Web3", block_with_txn: BlockData + self, w3: "Web3", block_with_txn: BlockData ) -> None: - block = web3.eth.get_block(block_with_txn['number'], True) + block = w3.eth.get_block(block_with_txn['number'], True) transaction = block['transactions'][0] assert transaction['hash'] == block_with_txn['transactions'][0] # type: ignore def test_eth_getTransactionByHash( - self, web3: "Web3", mined_txn_hash: HexStr + self, w3: "Web3", mined_txn_hash: HexStr ) -> None: - transaction = web3.eth.get_transaction(mined_txn_hash) + transaction = w3.eth.get_transaction(mined_txn_hash) assert is_dict(transaction) assert transaction['hash'] == HexBytes(mined_txn_hash) def test_eth_getTransactionByHash_deprecated( - self, web3: "Web3", mined_txn_hash: HexStr + self, w3: "Web3", mined_txn_hash: HexStr ) -> None: with pytest.warns(DeprecationWarning, match='getTransaction is deprecated in favor of get_transaction'): - transaction = web3.eth.getTransaction(mined_txn_hash) + transaction = w3.eth.getTransaction(mined_txn_hash) assert is_dict(transaction) assert transaction['hash'] == HexBytes(mined_txn_hash) def test_eth_getTransactionByHash_contract_creation( - self, web3: "Web3", math_contract_deploy_txn_hash: HexStr + self, w3: "Web3", math_contract_deploy_txn_hash: HexStr ) -> None: - transaction = web3.eth.get_transaction(math_contract_deploy_txn_hash) + transaction = w3.eth.get_transaction(math_contract_deploy_txn_hash) assert is_dict(transaction) assert transaction['to'] is None, "to field is %r" % transaction['to'] def test_eth_getTransactionByBlockHashAndIndex( - self, web3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr + self, w3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr ) -> None: - transaction = web3.eth.get_transaction_by_block(block_with_txn['hash'], 0) + transaction = w3.eth.get_transaction_by_block(block_with_txn['hash'], 0) assert is_dict(transaction) assert transaction['hash'] == HexBytes(mined_txn_hash) def test_eth_getTransactionByBlockHashAndIndex_deprecated( - self, web3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr + self, w3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr ) -> None: with pytest.warns( DeprecationWarning, match='getTransactionByBlock is deprecated in favor of get_transaction_by_block' ): - transaction = web3.eth.getTransactionByBlock(block_with_txn['hash'], 0) + transaction = w3.eth.getTransactionByBlock(block_with_txn['hash'], 0) assert is_dict(transaction) assert transaction['hash'] == HexBytes(mined_txn_hash) def test_eth_getTransactionByBlockNumberAndIndex( - self, web3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr + self, w3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr ) -> None: - transaction = web3.eth.get_transaction_by_block(block_with_txn['number'], 0) + transaction = w3.eth.get_transaction_by_block(block_with_txn['number'], 0) assert is_dict(transaction) assert transaction['hash'] == HexBytes(mined_txn_hash) def test_eth_getTransactionByBlockNumberAndIndex_deprecated( - self, web3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr + self, w3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr ) -> None: with pytest.warns( DeprecationWarning, match='getTransactionByBlock is deprecated in favor of get_transaction_by_block' ): - transaction = web3.eth.getTransactionByBlock(block_with_txn['number'], 0) + transaction = w3.eth.getTransactionByBlock(block_with_txn['number'], 0) assert is_dict(transaction) assert transaction['hash'] == HexBytes(mined_txn_hash) def test_eth_get_transaction_receipt_mined( - self, web3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr + self, w3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr ) -> None: - receipt = web3.eth.get_transaction_receipt(mined_txn_hash) + receipt = w3.eth.get_transaction_receipt(mined_txn_hash) assert is_dict(receipt) assert receipt['blockNumber'] == block_with_txn['number'] assert receipt['blockHash'] == block_with_txn['hash'] @@ -2795,12 +2795,12 @@ def test_eth_get_transaction_receipt_mined( assert effective_gas_price > 0 def test_eth_getTransactionReceipt_mined_deprecated( - self, web3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr + self, w3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr ) -> None: with pytest.warns( DeprecationWarning, match="getTransactionReceipt is deprecated in favor of get_transaction_receipt"): - receipt = web3.eth.getTransactionReceipt(mined_txn_hash) + receipt = w3.eth.getTransactionReceipt(mined_txn_hash) assert is_dict(receipt) assert receipt['blockNumber'] == block_with_txn['number'] assert receipt['blockHash'] == block_with_txn['hash'] @@ -2811,27 +2811,27 @@ def test_eth_getTransactionReceipt_mined_deprecated( assert is_checksum_address(receipt['from']) def test_eth_get_transaction_receipt_unmined( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: - txn_hash = web3.eth.send_transaction({ + txn_hash = w3.eth.send_transaction({ 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), 'gas': 21000, - 'maxFeePerGas': web3.toWei(3, 'gwei'), - 'maxPriorityFeePerGas': web3.toWei(1, 'gwei') + 'maxFeePerGas': w3.toWei(3, 'gwei'), + 'maxPriorityFeePerGas': w3.toWei(1, 'gwei') }) with pytest.raises(TransactionNotFound): - web3.eth.get_transaction_receipt(txn_hash) + w3.eth.get_transaction_receipt(txn_hash) def test_eth_get_transaction_receipt_with_log_entry( self, - web3: "Web3", + w3: "Web3", block_with_txn_with_log: BlockData, emitter_contract: "Contract", txn_hash_with_log: HexStr, ) -> None: - receipt = web3.eth.get_transaction_receipt(txn_hash_with_log) + receipt = w3.eth.get_transaction_receipt(txn_hash_with_log) assert is_dict(receipt) assert receipt['blockNumber'] == block_with_txn_with_log['number'] assert receipt['blockHash'] == block_with_txn_with_log['hash'] @@ -2850,11 +2850,11 @@ def test_eth_get_transaction_receipt_with_log_entry( def test_eth_wait_for_transaction_receipt_mined( self, - web3: "Web3", + w3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr ) -> None: - receipt = web3.eth.wait_for_transaction_receipt(mined_txn_hash) + receipt = w3.eth.wait_for_transaction_receipt(mined_txn_hash) assert is_dict(receipt) assert receipt['blockNumber'] == block_with_txn['number'] assert receipt['blockHash'] == block_with_txn['hash'] @@ -2869,31 +2869,31 @@ def test_eth_wait_for_transaction_receipt_mined( assert effective_gas_price > 0 def test_eth_wait_for_transaction_receipt_unmined( - self, web3: "Web3", unlocked_account_dual_type: ChecksumAddress + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: - txn_hash = web3.eth.send_transaction({ + txn_hash = w3.eth.send_transaction({ 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), 'gas': 21000, - 'maxFeePerGas': web3.toWei(3, 'gwei'), - 'maxPriorityFeePerGas': web3.toWei(1, 'gwei') + 'maxFeePerGas': w3.toWei(3, 'gwei'), + 'maxPriorityFeePerGas': w3.toWei(1, 'gwei') }) timeout = 2 with pytest.raises(TimeExhausted) as exc_info: - web3.eth.wait_for_transaction_receipt(txn_hash, timeout=timeout) + w3.eth.wait_for_transaction_receipt(txn_hash, timeout=timeout) assert (_ in str(exc_info) for _ in [repr(txn_hash), timeout]) def test_eth_wait_for_transaction_receipt_with_log_entry( self, - web3: "Web3", + w3: "Web3", block_with_txn_with_log: BlockData, emitter_contract: "Contract", txn_hash_with_log: HexStr, ) -> None: - receipt = web3.eth.wait_for_transaction_receipt(txn_hash_with_log) + receipt = w3.eth.wait_for_transaction_receipt(txn_hash_with_log) assert is_dict(receipt) assert receipt['blockNumber'] == block_with_txn_with_log['number'] assert receipt['blockHash'] == block_with_txn_with_log['hash'] @@ -2910,78 +2910,78 @@ def test_eth_wait_for_transaction_receipt_with_log_entry( assert log_entry['transactionIndex'] == 0 assert log_entry['transactionHash'] == HexBytes(txn_hash_with_log) - def test_eth_getUncleByBlockHashAndIndex(self, web3: "Web3") -> None: + def test_eth_getUncleByBlockHashAndIndex(self, w3: "Web3") -> None: # TODO: how do we make uncles.... pass - def test_eth_getUncleByBlockNumberAndIndex(self, web3: "Web3") -> None: + def test_eth_getUncleByBlockNumberAndIndex(self, w3: "Web3") -> None: # TODO: how do we make uncles.... pass - def test_eth_newFilter(self, web3: "Web3") -> None: - filter = web3.eth.filter({}) + def test_eth_newFilter(self, w3: "Web3") -> None: + filter = w3.eth.filter({}) - changes = web3.eth.get_filter_changes(filter.filter_id) + changes = w3.eth.get_filter_changes(filter.filter_id) assert is_list_like(changes) assert not changes - logs = web3.eth.get_filter_logs(filter.filter_id) + logs = w3.eth.get_filter_logs(filter.filter_id) assert is_list_like(logs) assert not logs - result = web3.eth.uninstall_filter(filter.filter_id) + result = w3.eth.uninstall_filter(filter.filter_id) assert result is True - def test_eth_newFilter_deprecated(self, web3: "Web3") -> None: - filter = web3.eth.filter({}) + def test_eth_newFilter_deprecated(self, w3: "Web3") -> None: + filter = w3.eth.filter({}) - changes = web3.eth.get_filter_changes(filter.filter_id) + changes = w3.eth.get_filter_changes(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) + logs = w3.eth.getFilterLogs(filter.filter_id) assert is_list_like(logs) assert not logs - result = web3.eth.uninstall_filter(filter.filter_id) + result = w3.eth.uninstall_filter(filter.filter_id) assert result is True - def test_eth_newBlockFilter(self, web3: "Web3") -> None: - filter = web3.eth.filter('latest') + def test_eth_newBlockFilter(self, w3: "Web3") -> None: + filter = w3.eth.filter('latest') assert is_string(filter.filter_id) - changes = web3.eth.get_filter_changes(filter.filter_id) + changes = w3.eth.get_filter_changes(filter.filter_id) assert is_list_like(changes) assert not changes # TODO: figure out why this fails in go-ethereum - # logs = web3.eth.get_filter_logs(filter.filter_id) + # logs = w3.eth.get_filter_logs(filter.filter_id) # assert is_list_like(logs) # assert not logs - result = web3.eth.uninstall_filter(filter.filter_id) + result = w3.eth.uninstall_filter(filter.filter_id) assert result is True - def test_eth_newPendingTransactionFilter(self, web3: "Web3") -> None: - filter = web3.eth.filter('pending') + def test_eth_newPendingTransactionFilter(self, w3: "Web3") -> None: + filter = w3.eth.filter('pending') assert is_string(filter.filter_id) - changes = web3.eth.get_filter_changes(filter.filter_id) + changes = w3.eth.get_filter_changes(filter.filter_id) assert is_list_like(changes) assert not changes # TODO: figure out why this fails in go-ethereum - # logs = web3.eth.get_filter_logs(filter.filter_id) + # logs = w3.eth.get_filter_logs(filter.filter_id) # assert is_list_like(logs) # assert not logs - result = web3.eth.uninstall_filter(filter.filter_id) + result = w3.eth.uninstall_filter(filter.filter_id) assert result is True def test_eth_get_logs_without_logs( - self, web3: "Web3", block_with_txn_with_log: BlockData + self, w3: "Web3", block_with_txn_with_log: BlockData ) -> None: # Test with block range @@ -2989,7 +2989,7 @@ def test_eth_get_logs_without_logs( "fromBlock": BlockNumber(0), "toBlock": BlockNumber(block_with_txn_with_log['number'] - 1), } - result = web3.eth.get_logs(filter_params) + result = w3.eth.get_logs(filter_params) assert len(result) == 0 # the range is wrong @@ -2997,7 +2997,7 @@ def test_eth_get_logs_without_logs( "fromBlock": block_with_txn_with_log['number'], "toBlock": BlockNumber(block_with_txn_with_log['number'] - 1), } - result = web3.eth.get_logs(filter_params) + result = w3.eth.get_logs(filter_params) assert len(result) == 0 # Test with `address` @@ -3007,7 +3007,7 @@ def test_eth_get_logs_without_logs( "fromBlock": BlockNumber(0), "address": UNKNOWN_ADDRESS, } - result = web3.eth.get_logs(filter_params) + result = w3.eth.get_logs(filter_params) assert len(result) == 0 # Test with multiple `address` @@ -3017,12 +3017,12 @@ def test_eth_get_logs_without_logs( "fromBlock": BlockNumber(0), "address": [UNKNOWN_ADDRESS, UNKNOWN_ADDRESS], } - result = web3.eth.get_logs(filter_params) + result = w3.eth.get_logs(filter_params) assert len(result) == 0 def test_eth_get_logs_with_logs( self, - web3: "Web3", + w3: "Web3", block_with_txn_with_log: BlockData, emitter_contract_address: ChecksumAddress, txn_hash_with_log: HexStr, @@ -3035,7 +3035,7 @@ def test_eth_get_logs_with_logs( "fromBlock": block_with_txn_with_log['number'], "toBlock": block_with_txn_with_log['number'], } - result = web3.eth.get_logs(filter_params) + result = w3.eth.get_logs(filter_params) _assert_contains_log( result, block_with_txn_with_log, @@ -3047,7 +3047,7 @@ def test_eth_get_logs_with_logs( filter_params = { "fromBlock": BlockNumber(0), } - result = web3.eth.get_logs(filter_params) + result = w3.eth.get_logs(filter_params) _assert_contains_log( result, block_with_txn_with_log, @@ -3065,7 +3065,7 @@ def test_eth_get_logs_with_logs( def test_eth_get_logs_with_logs_topic_args( self, - web3: "Web3", + w3: "Web3", block_with_txn_with_log: BlockData, emitter_contract_address: ChecksumAddress, txn_hash_with_log: HexStr, @@ -3080,7 +3080,7 @@ def test_eth_get_logs_with_logs_topic_args( HexStr('0x000000000000000000000000000000000000000000000000000000000000d431')], } - result = web3.eth.get_logs(filter_params) + result = w3.eth.get_logs(filter_params) _assert_contains_log( result, block_with_txn_with_log, @@ -3095,7 +3095,7 @@ def test_eth_get_logs_with_logs_topic_args( HexStr('0x057bc32826fbe161da1c110afcdcae7c109a8b69149f727fc37a603c60ef94ca'), None], } - result = web3.eth.get_logs(filter_params) + result = w3.eth.get_logs(filter_params) _assert_contains_log( result, block_with_txn_with_log, @@ -3103,20 +3103,20 @@ def test_eth_get_logs_with_logs_topic_args( txn_hash_with_log ) - def test_eth_get_logs_with_logs_none_topic_args(self, web3: "Web3") -> None: + def test_eth_get_logs_with_logs_none_topic_args(self, w3: "Web3") -> None: # Test with None overflowing filter_params: FilterParams = { "fromBlock": BlockNumber(0), "topics": [None, None, None], } - result = web3.eth.get_logs(filter_params) + result = w3.eth.get_logs(filter_params) assert len(result) == 0 def test_eth_call_old_contract_state( - self, web3: "Web3", math_contract: "Contract", unlocked_account: ChecksumAddress + self, w3: "Web3", math_contract: "Contract", unlocked_account: ChecksumAddress ) -> None: - start_block = web3.eth.get_block('latest') + start_block = w3.eth.get_block('latest') block_num = start_block["number"] block_hash = start_block["hash"] @@ -3142,113 +3142,113 @@ 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_deprecated(self, web3: "Web3") -> None: - filter = web3.eth.filter({}) + def test_eth_uninstallFilter_deprecated(self, w3: "Web3") -> None: + filter = w3.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) + success = w3.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) + failure = w3.eth.uninstallFilter(filter.filter_id) assert failure is False - def test_eth_uninstall_filter(self, web3: "Web3") -> None: - filter = web3.eth.filter({}) + def test_eth_uninstall_filter(self, w3: "Web3") -> None: + filter = w3.eth.filter({}) assert is_string(filter.filter_id) - success = web3.eth.uninstall_filter(filter.filter_id) + success = w3.eth.uninstall_filter(filter.filter_id) assert success is True - failure = web3.eth.uninstall_filter(filter.filter_id) + failure = w3.eth.uninstall_filter(filter.filter_id) assert failure is False def test_eth_getTransactionFromBlock_deprecation( - self, web3: "Web3", block_with_txn: BlockData + self, w3: "Web3", block_with_txn: BlockData ) -> None: with pytest.raises(DeprecationWarning): - web3.eth.getTransactionFromBlock(block_with_txn['hash'], 0) + w3.eth.getTransactionFromBlock(block_with_txn['hash'], 0) - def test_eth_getCompilers_deprecation(self, web3: "Web3") -> None: + def test_eth_getCompilers_deprecation(self, w3: "Web3") -> None: with pytest.raises(DeprecationWarning): - web3.eth.getCompilers() + w3.eth.getCompilers() - def test_eth_submit_hashrate(self, web3: "Web3") -> None: + def test_eth_submit_hashrate(self, w3: "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) + result = w3.eth.submit_hashrate(5000, node_id) assert result is True - def test_eth_submitHashrate_deprecated(self, web3: "Web3") -> None: + def test_eth_submitHashrate_deprecated(self, w3: "Web3") -> None: # node_id from EIP 1474: https://github.com/ethereum/EIPs/pull/1474/files node_id = HexStr('59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c') with pytest.warns(DeprecationWarning, match='submitHashrate is deprecated in favor of submit_hashrate'): - result = web3.eth.submitHashrate(5000, node_id) + result = w3.eth.submitHashrate(5000, node_id) assert result is True - def test_eth_submit_work(self, web3: "Web3") -> None: + def test_eth_submit_work(self, w3: "Web3") -> None: nonce = 1 pow_hash = HexStr('0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef') mix_digest = HexStr('0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000') - result = web3.eth.submit_work(nonce, pow_hash, mix_digest) + result = w3.eth.submit_work(nonce, pow_hash, mix_digest) assert result is False - def test_eth_submitWork_deprecated(self, web3: "Web3") -> None: + def test_eth_submitWork_deprecated(self, w3: "Web3") -> None: nonce = 1 pow_hash = HexStr('0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef') mix_digest = HexStr('0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000') with pytest.warns(DeprecationWarning, match="submitWork is deprecated in favor of submit_work"): - result = web3.eth.submitWork(nonce, pow_hash, mix_digest) + result = w3.eth.submitWork(nonce, pow_hash, mix_digest) assert result is False def test_eth_get_raw_transaction( - self, web3: "Web3", mined_txn_hash: HexStr + self, w3: "Web3", mined_txn_hash: HexStr ) -> None: - raw_transaction = web3.eth.get_raw_transaction(mined_txn_hash) + raw_transaction = w3.eth.get_raw_transaction(mined_txn_hash) assert is_bytes(raw_transaction) - def test_eth_get_raw_transaction_raises_error(self, web3: "Web3") -> None: + def test_eth_get_raw_transaction_raises_error(self, w3: "Web3") -> None: with pytest.raises(TransactionNotFound, match=f"Transaction with hash: '{UNKNOWN_HASH}'"): - web3.eth.get_raw_transaction(UNKNOWN_HASH) + w3.eth.get_raw_transaction(UNKNOWN_HASH) def test_eth_get_raw_transaction_by_block( - self, web3: "Web3", + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress, block_with_txn: BlockData, ) -> None: # eth_getRawTransactionByBlockNumberAndIndex: block identifier # send a txn to make sure pending block has at least one txn - web3.eth.send_transaction( + w3.eth.send_transaction( { 'from': unlocked_account_dual_type, 'to': unlocked_account_dual_type, 'value': Wei(1), } ) - last_pending_txn_index = len(web3.eth.get_block('pending')['transactions']) - 1 - raw_transaction = web3.eth.get_raw_transaction_by_block('pending', last_pending_txn_index) + last_pending_txn_index = len(w3.eth.get_block('pending')['transactions']) - 1 + raw_transaction = w3.eth.get_raw_transaction_by_block('pending', last_pending_txn_index) assert is_bytes(raw_transaction) # eth_getRawTransactionByBlockNumberAndIndex: block number block_with_txn_number = block_with_txn['number'] assert is_integer(block_with_txn_number) - raw_transaction = web3.eth.get_raw_transaction_by_block(block_with_txn_number, 0) + raw_transaction = w3.eth.get_raw_transaction_by_block(block_with_txn_number, 0) assert is_bytes(raw_transaction) # eth_getRawTransactionByBlockHashAndIndex: block hash block_with_txn_hash = block_with_txn['hash'] assert is_bytes(block_with_txn_hash) - raw_transaction = web3.eth.get_raw_transaction_by_block(block_with_txn_hash, 0) + raw_transaction = w3.eth.get_raw_transaction_by_block(block_with_txn_hash, 0) assert is_bytes(raw_transaction) @pytest.mark.parametrize('unknown_block_num_or_hash', (1234567899999, UNKNOWN_HASH)) def test_eth_get_raw_transaction_by_block_raises_error( - self, web3: "Web3", unknown_block_num_or_hash: Union[int, HexBytes] + self, w3: "Web3", unknown_block_num_or_hash: Union[int, HexBytes] ) -> None: with pytest.raises( TransactionNotFound, match=( @@ -3256,10 +3256,10 @@ def test_eth_get_raw_transaction_by_block_raises_error( f"{to_hex_if_integer(unknown_block_num_or_hash)!r} not found." ) ): - web3.eth.get_raw_transaction_by_block(unknown_block_num_or_hash, 0) + w3.eth.get_raw_transaction_by_block(unknown_block_num_or_hash, 0) def test_eth_get_raw_transaction_by_block_raises_error_block_identifier( - self, web3: "Web3" + self, w3: "Web3" ) -> None: unknown_identifier = "unknown" with pytest.raises( @@ -3267,39 +3267,39 @@ def test_eth_get_raw_transaction_by_block_raises_error_block_identifier( f"Value did not match any of the recognized block identifiers: {unknown_identifier}" ) ): - web3.eth.get_raw_transaction_by_block(unknown_identifier, 0) # type: ignore + w3.eth.get_raw_transaction_by_block(unknown_identifier, 0) # type: ignore def test_default_account( self, - web3: "Web3", + w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: # check defaults to empty - default_account = web3.eth.default_account + default_account = w3.eth.default_account assert default_account is empty # check setter - web3.eth.default_account = unlocked_account_dual_type - default_account = web3.eth.default_account + w3.eth.default_account = unlocked_account_dual_type + default_account = w3.eth.default_account assert default_account == unlocked_account_dual_type # reset to default - web3.eth.default_account = empty + w3.eth.default_account = empty def test_default_block( self, - web3: "Web3", + w3: "Web3", ) -> None: # check defaults to 'latest' - default_block = web3.eth.default_block + default_block = w3.eth.default_block assert default_block == 'latest' # check setter - web3.eth.default_block = BlockNumber(12345) - default_block = web3.eth.default_block + w3.eth.default_block = BlockNumber(12345) + default_block = w3.eth.default_block assert default_block == BlockNumber(12345) # reset to default - web3.eth.default_block = 'latest' + w3.eth.default_block = 'latest' diff --git a/web3/_utils/module_testing/go_ethereum_admin_module.py b/web3/_utils/module_testing/go_ethereum_admin_module.py index 9a88f0bafe..38505deec7 100644 --- a/web3/_utils/module_testing/go_ethereum_admin_module.py +++ b/web3/_utils/module_testing/go_ethereum_admin_module.py @@ -16,17 +16,17 @@ class GoEthereumAdminModuleTest: - def test_add_peer(self, web3: "Web3") -> None: - result = web3.geth.admin.add_peer( + def test_add_peer(self, w3: "Web3") -> None: + result = w3.geth.admin.add_peer( EnodeURI('enode://f1a6b0bdbf014355587c3018454d070ac57801f05d3b39fe85da574f002a32e929f683d72aa5a8318382e4d3c7a05c9b91687b0d997a39619fb8a6e7ad88e512@1.1.1.1:30303'),) # noqa: E501 assert result is True - def test_admin_datadir(self, web3: "Web3", datadir: str) -> None: - result = web3.geth.admin.datadir() + def test_admin_datadir(self, w3: "Web3", datadir: str) -> None: + result = w3.geth.admin.datadir() assert result == datadir - def test_admin_node_info(self, web3: "Web3") -> None: - result = web3.geth.admin.node_info() + def test_admin_node_info(self, w3: "Web3") -> None: + result = w3.geth.admin.node_info() expected = AttributeDict({ 'id': '', 'name': '', @@ -39,55 +39,55 @@ def test_admin_node_info(self, web3: "Web3") -> None: # Test that result gives at least the keys that are listed in `expected` assert not set(expected.keys()).difference(result.keys()) - def test_admin_peers(self, web3: "Web3") -> None: - enode = web3.geth.admin.node_info()['enode'] - web3.geth.admin.add_peer(enode) - result = web3.geth.admin.peers() + def test_admin_peers(self, w3: "Web3") -> None: + enode = w3.geth.admin.node_info()['enode'] + w3.geth.admin.add_peer(enode) + result = w3.geth.admin.peers() assert len(result) == 1 - def test_admin_start_stop_rpc(self, web3: "Web3") -> None: - stop = web3.geth.admin.stop_rpc() + def test_admin_start_stop_rpc(self, w3: "Web3") -> None: + stop = w3.geth.admin.stop_rpc() assert stop is True - start = web3.geth.admin.start_rpc() + start = w3.geth.admin.start_rpc() assert start is True with pytest.warns(DeprecationWarning): - stop = web3.geth.admin.stopRPC() + stop = w3.geth.admin.stopRPC() assert stop is True with pytest.warns(DeprecationWarning): - start = web3.geth.admin.startRPC() + start = w3.geth.admin.startRPC() assert start is True - def test_admin_start_stop_ws(self, web3: "Web3") -> None: - stop = web3.geth.admin.stop_ws() + def test_admin_start_stop_ws(self, w3: "Web3") -> None: + stop = w3.geth.admin.stop_ws() assert stop is True - start = web3.geth.admin.start_ws() + start = w3.geth.admin.start_ws() assert start is True with pytest.warns(DeprecationWarning): - stop = web3.geth.admin.stopWS() + stop = w3.geth.admin.stopWS() assert stop is True with pytest.warns(DeprecationWarning): - start = web3.geth.admin.startWS() + start = w3.geth.admin.startWS() assert start is True # # Deprecated # - def test_admin_addPeer(self, web3: "Web3") -> None: + def test_admin_addPeer(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): - result = web3.geth.admin.addPeer( + result = w3.geth.admin.addPeer( EnodeURI('enode://f1a6b0bdbf014355587c3018454d070ac57801f05d3b39fe85da574f002a32e929f683d72aa5a8318382e4d3c7a05c9b91687b0d997a39619fb8a6e7ad88e512@1.1.1.1:30303'), # noqa: E501 ) assert result is True - def test_admin_nodeInfo(self, web3: "Web3") -> None: + def test_admin_nodeInfo(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): - result = web3.geth.admin.nodeInfo() + result = w3.geth.admin.nodeInfo() expected = AttributeDict({ 'id': '', 'name': '', @@ -119,24 +119,24 @@ async def test_async_nodes(self, async_w3: "Web3") -> None: assert isinstance(nodes, List) @pytest.mark.asyncio - async def test_admin_peers(self, web3: "Web3") -> None: - enode = await web3.geth.admin.node_info()['enode'] # type: ignore - web3.geth.admin.add_peer(enode) - result = await web3.geth.admin.peers() # type: ignore + async def test_admin_peers(self, w3: "Web3") -> None: + enode = await w3.geth.admin.node_info()['enode'] # type: ignore + w3.geth.admin.add_peer(enode) + result = await w3.geth.admin.peers() # type: ignore assert len(result) == 1 @pytest.mark.asyncio - async def test_admin_start_stop_rpc(self, web3: "Web3") -> None: - stop = await web3.geth.admin.stop_rpc() # type: ignore + async def test_admin_start_stop_rpc(self, w3: "Web3") -> None: + stop = await w3.geth.admin.stop_rpc() # type: ignore assert stop is True - start = await web3.geth.admin.start_rpc() # type: ignore + start = await w3.geth.admin.start_rpc() # type: ignore assert start is True @pytest.mark.asyncio - async def test_admin_start_stop_ws(self, web3: "Web3") -> None: - stop = await web3.geth.admin.stop_ws() # type: ignore + async def test_admin_start_stop_ws(self, w3: "Web3") -> None: + stop = await w3.geth.admin.stop_ws() # type: ignore assert stop is True - start = await web3.geth.admin.start_ws() # type: ignore + start = await w3.geth.admin.start_ws() # type: ignore assert start is True diff --git a/web3/_utils/module_testing/go_ethereum_personal_module.py b/web3/_utils/module_testing/go_ethereum_personal_module.py index 1e7fb35f06..34bff726b2 100644 --- a/web3/_utils/module_testing/go_ethereum_personal_module.py +++ b/web3/_utils/module_testing/go_ethereum_personal_module.py @@ -45,17 +45,17 @@ class GoEthereumPersonalModuleTest: - def test_personal_import_raw_key(self, web3: "Web3") -> None: - actual = web3.geth.personal.import_raw_key(PRIVATE_KEY_HEX, PASSWORD) + def test_personal_import_raw_key(self, w3: "Web3") -> None: + actual = w3.geth.personal.import_raw_key(PRIVATE_KEY_HEX, PASSWORD) assert actual == ADDRESS - def test_personal_importRawKey_deprecated(self, web3: "Web3") -> None: + def test_personal_importRawKey_deprecated(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): - actual = web3.geth.personal.importRawKey(SECOND_PRIVATE_KEY_HEX, PASSWORD) + actual = w3.geth.personal.importRawKey(SECOND_PRIVATE_KEY_HEX, PASSWORD) assert actual == SECOND_ADDRESS - def test_personal_list_accounts(self, web3: "Web3") -> None: - accounts = web3.geth.personal.list_accounts() + def test_personal_list_accounts(self, w3: "Web3") -> None: + accounts = w3.geth.personal.list_accounts() assert is_list_like(accounts) assert len(accounts) > 0 assert all(( @@ -64,9 +64,9 @@ def test_personal_list_accounts(self, web3: "Web3") -> None: in accounts )) - def test_personal_listAccounts_deprecated(self, web3: "Web3") -> None: + def test_personal_listAccounts_deprecated(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): - accounts = web3.geth.personal.listAccounts() + accounts = w3.geth.personal.listAccounts() assert is_list_like(accounts) assert len(accounts) > 0 assert all(( @@ -75,8 +75,8 @@ def test_personal_listAccounts_deprecated(self, web3: "Web3") -> None: in accounts )) - def test_personal_list_wallets(self, web3: "Web3") -> None: - wallets = web3.geth.personal.list_wallets() + def test_personal_list_wallets(self, w3: "Web3") -> None: + wallets = w3.geth.personal.list_wallets() assert is_list_like(wallets) assert len(wallets) > 0 assert is_checksum_address(wallets[0]['accounts'][0]['address']) @@ -85,25 +85,25 @@ def test_personal_list_wallets(self, web3: "Web3") -> None: assert is_string(wallets[0]['url']) def test_personal_lock_account( - self, web3: "Web3", unlockable_account_dual_type: ChecksumAddress + self, w3: "Web3", unlockable_account_dual_type: ChecksumAddress ) -> None: # TODO: how do we test this better? - web3.geth.personal.lock_account(unlockable_account_dual_type) + w3.geth.personal.lock_account(unlockable_account_dual_type) def test_personal_lockAccount_deprecated( - self, web3: "Web3", unlockable_account_dual_type: ChecksumAddress + self, w3: "Web3", unlockable_account_dual_type: ChecksumAddress ) -> None: with pytest.warns(DeprecationWarning): # TODO: how do we test this better? - web3.geth.personal.lockAccount(unlockable_account_dual_type) + w3.geth.personal.lockAccount(unlockable_account_dual_type) def test_personal_unlock_account_success( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: - result = web3.geth.personal.unlock_account( + result = w3.geth.personal.unlock_account( unlockable_account_dual_type, unlockable_account_pw ) @@ -111,56 +111,56 @@ def test_personal_unlock_account_success( def test_personal_unlockAccount_success_deprecated( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: with pytest.warns(DeprecationWarning): - result = web3.geth.personal.unlockAccount( + result = w3.geth.personal.unlockAccount( unlockable_account_dual_type, unlockable_account_pw ) assert result is True def test_personal_unlock_account_failure( - self, web3: "Web3", unlockable_account_dual_type: ChecksumAddress + self, w3: "Web3", unlockable_account_dual_type: ChecksumAddress ) -> None: with pytest.raises(ValueError): - web3.geth.personal.unlock_account(unlockable_account_dual_type, 'bad-password') + w3.geth.personal.unlock_account(unlockable_account_dual_type, 'bad-password') def test_personal_unlockAccount_failure_deprecated( - self, web3: "Web3", unlockable_account_dual_type: ChecksumAddress + self, w3: "Web3", unlockable_account_dual_type: ChecksumAddress ) -> None: with pytest.warns(DeprecationWarning): with pytest.raises(ValueError): - web3.geth.personal.unlockAccount(unlockable_account_dual_type, 'bad-password') + w3.geth.personal.unlockAccount(unlockable_account_dual_type, 'bad-password') - def test_personal_new_account(self, web3: "Web3") -> None: - new_account = web3.geth.personal.new_account(PASSWORD) + def test_personal_new_account(self, w3: "Web3") -> None: + new_account = w3.geth.personal.new_account(PASSWORD) assert is_checksum_address(new_account) - def test_personal_newAccount_deprecated(self, web3: "Web3") -> None: + def test_personal_newAccount_deprecated(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): - new_account = web3.geth.personal.newAccount(PASSWORD) + new_account = w3.geth.personal.newAccount(PASSWORD) assert is_checksum_address(new_account) def test_personal_send_transaction( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: - assert web3.eth.get_balance(unlockable_account_dual_type) > constants.WEI_PER_ETHER + assert w3.eth.get_balance(unlockable_account_dual_type) > constants.WEI_PER_ETHER txn_params: TxParams = { 'from': unlockable_account_dual_type, 'to': unlockable_account_dual_type, 'gas': 21000, 'value': Wei(1), - 'gasPrice': web3.toWei(1, 'gwei'), + 'gasPrice': w3.toWei(1, 'gwei'), } - txn_hash = web3.geth.personal.send_transaction(txn_params, unlockable_account_pw) + txn_hash = w3.geth.personal.send_transaction(txn_params, unlockable_account_pw) assert txn_hash - transaction = web3.eth.get_transaction(txn_hash) + transaction = w3.eth.get_transaction(txn_hash) assert is_same_address(transaction['from'], cast(ChecksumAddress, txn_params['from'])) assert is_same_address(transaction['to'], cast(ChecksumAddress, txn_params['to'])) @@ -170,23 +170,23 @@ def test_personal_send_transaction( def test_personal_sendTransaction_deprecated( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: - assert web3.eth.get_balance(unlockable_account_dual_type) > constants.WEI_PER_ETHER + assert w3.eth.get_balance(unlockable_account_dual_type) > constants.WEI_PER_ETHER txn_params: TxParams = { 'from': unlockable_account_dual_type, 'to': unlockable_account_dual_type, 'gas': 21000, 'value': Wei(1), - 'gasPrice': web3.toWei(1, 'gwei'), + 'gasPrice': w3.toWei(1, 'gwei'), } with pytest.warns(DeprecationWarning): - txn_hash = web3.geth.personal.sendTransaction(txn_params, unlockable_account_pw) + txn_hash = w3.geth.personal.sendTransaction(txn_params, unlockable_account_pw) assert txn_hash - transaction = web3.eth.get_transaction(txn_hash) + transaction = w3.eth.get_transaction(txn_hash) assert is_same_address(transaction['from'], cast(ChecksumAddress, txn_params['from'])) assert is_same_address(transaction['to'], cast(ChecksumAddress, txn_params['to'])) @@ -196,33 +196,33 @@ def test_personal_sendTransaction_deprecated( def test_personal_sign_and_ecrecover( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: message = 'test-web3-geth-personal-sign' - signature = web3.geth.personal.sign( + signature = w3.geth.personal.sign( message, unlockable_account_dual_type, unlockable_account_pw ) - signer = web3.geth.personal.ec_recover(message, signature) + signer = w3.geth.personal.ec_recover(message, signature) assert is_same_address(signer, unlockable_account_dual_type) def test_personal_sign_and_ecrecover_deprecated( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: with pytest.warns(DeprecationWarning): message = 'test-web3-geth-personal-sign' - signature = web3.geth.personal.sign( + signature = w3.geth.personal.sign( message, unlockable_account_dual_type, unlockable_account_pw ) - signer = web3.geth.personal.ecRecover(message, signature) + signer = w3.geth.personal.ecRecover(message, signature) assert is_same_address(signer, unlockable_account_dual_type) @pytest.mark.xfail( @@ -230,7 +230,7 @@ def test_personal_sign_and_ecrecover_deprecated( ) def test_personal_sign_typed_data( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: @@ -273,7 +273,7 @@ def test_personal_sign_typed_data( } } ''' - signature = HexBytes(web3.geth.personal.sign_typed_data( + signature = HexBytes(w3.geth.personal.sign_typed_data( json.loads(typed_message), unlockable_account_dual_type, unlockable_account_pw @@ -290,7 +290,7 @@ def test_personal_sign_typed_data( @pytest.mark.xfail(reason="personal_signTypedData JSON RPC call has not been released in geth") def test_personal_sign_typed_data_deprecated( self, - web3: "Web3", + w3: "Web3", unlockable_account_dual_type: ChecksumAddress, unlockable_account_pw: str, ) -> None: @@ -334,7 +334,7 @@ def test_personal_sign_typed_data_deprecated( } } ''' - signature = HexBytes(web3.geth.personal.sign_typed_data( + signature = HexBytes(w3.geth.personal.sign_typed_data( json.loads(typed_message), unlockable_account_dual_type, unlockable_account_pw diff --git a/web3/_utils/module_testing/go_ethereum_txpool_module.py b/web3/_utils/module_testing/go_ethereum_txpool_module.py index 98117b7882..23a8a87498 100644 --- a/web3/_utils/module_testing/go_ethereum_txpool_module.py +++ b/web3/_utils/module_testing/go_ethereum_txpool_module.py @@ -23,14 +23,14 @@ async def test_async_geth_txpool_status(self, async_w3: "Web3") -> None: class GoEthereumTxPoolModuleTest: - def test_geth_txpool_inspect(self, web3: "Web3") -> None: - test_data = web3.geth.txpool.inspect() # type: ignore + def test_geth_txpool_inspect(self, w3: "Web3") -> None: + test_data = w3.geth.txpool.inspect() # type: ignore assert "pending" in test_data - def test_geth_txpool_content(self, web3: "Web3") -> None: - test_data = web3.geth.txpool.content() # type: ignore + def test_geth_txpool_content(self, w3: "Web3") -> None: + test_data = w3.geth.txpool.content() # type: ignore assert "pending" in test_data - def test_geth_txpool_status(self, web3: "Web3") -> None: - test_data = web3.geth.txpool.status() # type: ignore + def test_geth_txpool_status(self, w3: "Web3") -> None: + test_data = w3.geth.txpool.status() # type: ignore assert "pending" in test_data diff --git a/web3/_utils/module_testing/net_module.py b/web3/_utils/module_testing/net_module.py index 57deed74cc..dd894a735a 100644 --- a/web3/_utils/module_testing/net_module.py +++ b/web3/_utils/module_testing/net_module.py @@ -14,31 +14,31 @@ class NetModuleTest: - def test_net_version(self, web3: "Web3") -> None: - version = web3.net.version + def test_net_version(self, w3: "Web3") -> None: + version = w3.net.version assert is_string(version) assert version.isdigit() - def test_net_listening(self, web3: "Web3") -> None: - listening = web3.net.listening + def test_net_listening(self, w3: "Web3") -> None: + listening = w3.net.listening assert is_boolean(listening) - def test_net_peer_count(self, web3: "Web3") -> None: - peer_count = web3.net.peer_count + def test_net_peer_count(self, w3: "Web3") -> None: + peer_count = w3.net.peer_count assert is_integer(peer_count) - def test_net_peerCount(self, web3: "Web3") -> None: + def test_net_peerCount(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): - peer_count = web3.net.peerCount + peer_count = w3.net.peerCount assert is_integer(peer_count) - def test_net_chainId_deprecation(self, web3: "Web3") -> None: + def test_net_chainId_deprecation(self, w3: "Web3") -> None: with pytest.raises(DeprecationWarning): - web3.net.chainId + w3.net.chainId class AsyncNetModuleTest: diff --git a/web3/_utils/module_testing/version_module.py b/web3/_utils/module_testing/version_module.py index 69b7c907ed..825e5afda7 100644 --- a/web3/_utils/module_testing/version_module.py +++ b/web3/_utils/module_testing/version_module.py @@ -12,16 +12,16 @@ class VersionModuleTest: - def test_eth_protocol_version(self, web3: "Web3") -> None: + def test_eth_protocol_version(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): - protocol_version = web3.eth.protocol_version + protocol_version = w3.eth.protocol_version assert is_string(protocol_version) assert protocol_version.isdigit() - def test_eth_protocolVersion(self, web3: "Web3") -> None: + def test_eth_protocolVersion(self, w3: "Web3") -> None: with pytest.warns(DeprecationWarning): - protocol_version = web3.eth.protocolVersion + protocol_version = w3.eth.protocolVersion assert is_string(protocol_version) assert protocol_version.isdigit() diff --git a/web3/_utils/module_testing/web3_module.py b/web3/_utils/module_testing/web3_module.py index 17e25e1ff7..73abb9cbfb 100644 --- a/web3/_utils/module_testing/web3_module.py +++ b/web3/_utils/module_testing/web3_module.py @@ -25,8 +25,8 @@ class Web3ModuleTest: - def test_web3_clientVersion(self, web3: Web3) -> None: - client_version = web3.clientVersion + def test_web3_clientVersion(self, w3: Web3) -> None: + client_version = w3.clientVersion self._check_web3_clientVersion(client_version) def _check_web3_clientVersion(self, client_version: str) -> NoReturn: @@ -176,14 +176,14 @@ def _check_web3_clientVersion(self, client_version: str) -> NoReturn: ), ) def test_solidityKeccak( - self, web3: "Web3", types: Sequence[TypeStr], values: Sequence[Any], expected: HexBytes + self, w3: "Web3", types: Sequence[TypeStr], values: Sequence[Any], expected: HexBytes ) -> None: if isinstance(expected, type) and issubclass(expected, Exception): with pytest.raises(expected): # type: ignore - web3.solidityKeccak(types, values) + w3.solidityKeccak(types, values) return - actual = web3.solidityKeccak(types, values) + actual = w3.solidityKeccak(types, values) assert actual == expected @pytest.mark.parametrize( @@ -202,9 +202,9 @@ def test_solidityKeccak( ), ) def test_solidityKeccak_ens( - self, web3: "Web3", types: Sequence[TypeStr], values: Sequence[str], expected: HexBytes + self, w3: "Web3", types: Sequence[TypeStr], values: Sequence[str], expected: HexBytes ) -> None: - with ens_addresses(web3, { + with ens_addresses(w3, { 'one.eth': ChecksumAddress( HexAddress(HexStr("0x49EdDD3769c0712032808D86597B84ac5c2F5614")) ), @@ -217,7 +217,7 @@ def test_solidityKeccak_ens( Web3.solidityKeccak(types, values) # when called as instance method, ens lookups can succeed - actual = web3.solidityKeccak(types, values) + actual = w3.solidityKeccak(types, values) assert actual == expected @pytest.mark.parametrize( @@ -229,10 +229,10 @@ def test_solidityKeccak_ens( ) ) def test_solidityKeccak_same_number_of_types_and_values( - self, web3: "Web3", types: Sequence[TypeStr], values: Sequence[Any] + self, w3: "Web3", types: Sequence[TypeStr], values: Sequence[Any] ) -> None: with pytest.raises(ValueError): - web3.solidityKeccak(types, values) + w3.solidityKeccak(types, values) - def test_is_connected(self, web3: "Web3") -> None: - assert web3.isConnected() + def test_is_connected(self, w3: "Web3") -> None: + assert w3.isConnected() diff --git a/web3/_utils/transactions.py b/web3/_utils/transactions.py index 13d43ffea7..8d9ca470df 100644 --- a/web3/_utils/transactions.py +++ b/web3/_utils/transactions.py @@ -56,14 +56,14 @@ TRANSACTION_DEFAULTS = { 'value': 0, 'data': b'', - 'gas': lambda web3, tx: web3.eth.estimate_gas(tx), - 'gasPrice': lambda web3, tx: web3.eth.generate_gas_price(tx) or web3.eth.gas_price, + 'gas': lambda w3, tx: w3.eth.estimate_gas(tx), + 'gasPrice': lambda w3, tx: w3.eth.generate_gas_price(tx) or w3.eth.gas_price, 'maxFeePerGas': ( - lambda web3, tx: - web3.eth.max_priority_fee + (2 * web3.eth.get_block('latest')['baseFeePerGas']) + lambda w3, tx: + w3.eth.max_priority_fee + (2 * w3.eth.get_block('latest')['baseFeePerGas']) ), - 'maxPriorityFeePerGas': lambda web3, tx: web3.eth.max_priority_fee, - 'chainId': lambda web3, tx: web3.eth.chain_id, + 'maxPriorityFeePerGas': lambda w3, tx: w3.eth.max_priority_fee, + 'chainId': lambda w3, tx: w3.eth.chain_id, } if TYPE_CHECKING: @@ -71,12 +71,12 @@ @curry -def fill_nonce(web3: "Web3", transaction: TxParams) -> TxParams: +def fill_nonce(w3: "Web3", transaction: TxParams) -> TxParams: if 'from' in transaction and 'nonce' not in transaction: return assoc( transaction, 'nonce', - web3.eth.get_transaction_count( + w3.eth.get_transaction_count( cast(ChecksumAddress, transaction['from']), block_identifier='pending')) else: @@ -84,11 +84,11 @@ def fill_nonce(web3: "Web3", transaction: TxParams) -> TxParams: @curry -def fill_transaction_defaults(web3: "Web3", transaction: TxParams) -> TxParams: +def fill_transaction_defaults(w3: "Web3", transaction: TxParams) -> TxParams: """ - if web3 is None, fill as much as possible while offline + if w3 is None, fill as much as possible while offline """ - strategy_based_gas_price = web3.eth.generate_gas_price(transaction) + strategy_based_gas_price = w3.eth.generate_gas_price(transaction) is_dynamic_fee_transaction = ( not strategy_based_gas_price and ( @@ -108,9 +108,9 @@ def fill_transaction_defaults(web3: "Web3", transaction: TxParams) -> TxParams: continue if callable(default_getter): - if web3 is None: + if w3 is None: raise ValueError("You must specify a '%s' value in the transaction" % key) - default_val = default_getter(web3, transaction) + default_val = default_getter(w3, transaction) else: default_val = default_getter @@ -118,21 +118,21 @@ def fill_transaction_defaults(web3: "Web3", transaction: TxParams) -> TxParams: return merge(defaults, transaction) -def get_block_gas_limit(web3: "Web3", block_identifier: Optional[BlockIdentifier] = None) -> int: +def get_block_gas_limit(w3: "Web3", block_identifier: Optional[BlockIdentifier] = None) -> int: if block_identifier is None: - block_identifier = web3.eth.block_number - block = web3.eth.get_block(block_identifier) + block_identifier = w3.eth.block_number + block = w3.eth.get_block(block_identifier) return block['gasLimit'] def get_buffered_gas_estimate( - web3: "Web3", transaction: TxParams, gas_buffer: int = 100000 + w3: "Web3", transaction: TxParams, gas_buffer: int = 100000 ) -> int: gas_estimate_transaction = cast(TxParams, dict(**transaction)) - gas_estimate = web3.eth.estimate_gas(gas_estimate_transaction) + gas_estimate = w3.eth.estimate_gas(gas_estimate_transaction) - gas_limit = get_block_gas_limit(web3) + gas_limit = get_block_gas_limit(w3) if gas_estimate > gas_limit: raise ValueError( @@ -144,8 +144,8 @@ def get_buffered_gas_estimate( return min(gas_limit, gas_estimate + gas_buffer) -def get_required_transaction(web3: "Web3", transaction_hash: _Hash32) -> TxData: - current_transaction = web3.eth.get_transaction(transaction_hash) +def get_required_transaction(w3: "Web3", transaction_hash: _Hash32) -> TxData: + current_transaction = w3.eth.get_transaction(transaction_hash) if not current_transaction: raise ValueError(f'Supplied transaction with hash {transaction_hash!r} does not exist') return current_transaction @@ -193,7 +193,7 @@ def assert_valid_transaction_params(transaction_params: TxParams) -> None: def prepare_replacement_transaction( - web3: "Web3", + w3: "Web3", original_transaction: TxData, replacement_transaction: TxParams, gas_multiplier: float = 1.125 @@ -220,7 +220,7 @@ def prepare_replacement_transaction( raise ValueError('Supplied gas price must exceed existing transaction gas price') else: - generated_gas_price = web3.eth.generate_gas_price(replacement_transaction) + generated_gas_price = w3.eth.generate_gas_price(replacement_transaction) minimum_gas_price = int(math.ceil(original_transaction['gasPrice'] * gas_multiplier)) if generated_gas_price and generated_gas_price > minimum_gas_price: replacement_transaction = assoc( @@ -233,9 +233,9 @@ def prepare_replacement_transaction( def replace_transaction( - web3: "Web3", current_transaction: TxData, new_transaction: TxParams + w3: "Web3", current_transaction: TxData, new_transaction: TxParams ) -> HexBytes: new_transaction = prepare_replacement_transaction( - web3, current_transaction, new_transaction + w3, current_transaction, new_transaction ) - return web3.eth.send_transaction(new_transaction) + return w3.eth.send_transaction(new_transaction) diff --git a/web3/contract.py b/web3/contract.py index d8b7227bbd..38e98b4152 100644 --- a/web3/contract.py +++ b/web3/contract.py @@ -155,9 +155,9 @@ class ContractFunctions: """Class containing contract function objects """ - def __init__(self, abi: ABI, web3: 'Web3', address: Optional[ChecksumAddress] = None) -> None: + def __init__(self, abi: ABI, w3: 'Web3', address: Optional[ChecksumAddress] = None) -> None: self.abi = abi - self.web3 = web3 + self.w3 = w3 self.address = address if self.abi: @@ -168,7 +168,7 @@ def __init__(self, abi: ABI, web3: 'Web3', address: Optional[ChecksumAddress] = func['name'], ContractFunction.factory( func['name'], - web3=self.web3, + w3=self.w3, contract_abi=self.abi, address=self.address, function_identifier=func['name'])) @@ -229,7 +229,7 @@ class ContractEvents: """ - def __init__(self, abi: ABI, web3: 'Web3', address: Optional[ChecksumAddress] = None) -> None: + def __init__(self, abi: ABI, w3: 'Web3', address: Optional[ChecksumAddress] = None) -> None: if abi: self.abi = abi self._events = filter_by_type('event', self.abi) @@ -239,7 +239,7 @@ def __init__(self, abi: ABI, web3: 'Web3', address: Optional[ChecksumAddress] = event['name'], ContractEvent.factory( event['name'], - web3=web3, + w3=w3, contract_abi=self.abi, address=address, event_name=event['name'])) @@ -294,7 +294,7 @@ class Contract: """ # set during class construction - web3: 'Web3' = None + w3: 'Web3' = None # instance level properties address: ChecksumAddress = None @@ -328,32 +328,32 @@ def __init__(self, address: Optional[ChecksumAddress] = None) -> None: :param address: Contract address as 0x hex string """ - if self.web3 is None: + if self.w3 is None: raise AttributeError( 'The `Contract` class has not been initialized. Please use the ' '`web3.contract` interface to create your contract class.' ) if address: - self.address = normalize_address(self.web3.ens, address) + self.address = normalize_address(self.w3.ens, address) if not self.address: raise TypeError("The address argument is required to instantiate a contract.") - self.functions = ContractFunctions(self.abi, self.web3, self.address) - self.caller = ContractCaller(self.abi, self.web3, self.address) - self.events = ContractEvents(self.abi, self.web3, self.address) - self.fallback = Contract.get_fallback_function(self.abi, self.web3, self.address) - self.receive = Contract.get_receive_function(self.abi, self.web3, self.address) + self.functions = ContractFunctions(self.abi, self.w3, self.address) + self.caller = ContractCaller(self.abi, self.w3, self.address) + self.events = ContractEvents(self.abi, self.w3, self.address) + self.fallback = Contract.get_fallback_function(self.abi, self.w3, self.address) + self.receive = Contract.get_receive_function(self.abi, self.w3, self.address) @classmethod - def factory(cls, web3: 'Web3', class_name: Optional[str] = None, **kwargs: Any) -> 'Contract': + def factory(cls, w3: 'Web3', class_name: Optional[str] = None, **kwargs: Any) -> 'Contract': - kwargs['web3'] = web3 + kwargs['w3'] = w3 normalizers = { 'abi': normalize_abi, - 'address': partial(normalize_address, kwargs['web3'].ens), + 'address': partial(normalize_address, kwargs['w3'].ens), 'bytecode': normalize_bytecode, 'bytecode_runtime': normalize_bytecode, } @@ -364,11 +364,11 @@ def factory(cls, web3: 'Web3', class_name: Optional[str] = None, **kwargs: Any) kwargs, normalizers=normalizers, )) - contract.functions = ContractFunctions(contract.abi, contract.web3) - contract.caller = ContractCaller(contract.abi, contract.web3, contract.address) - contract.events = ContractEvents(contract.abi, contract.web3) - contract.fallback = Contract.get_fallback_function(contract.abi, contract.web3) - contract.receive = Contract.get_receive_function(contract.abi, contract.web3) + contract.functions = ContractFunctions(contract.abi, contract.w3) + contract.caller = ContractCaller(contract.abi, contract.w3, contract.address) + contract.events = ContractEvents(contract.abi, contract.w3) + contract.fallback = Contract.get_fallback_function(contract.abi, contract.w3) + contract.receive = Contract.get_receive_function(contract.abi, contract.w3) return contract @@ -388,7 +388,7 @@ def constructor(cls, *args: Any, **kwargs: Any) -> 'ContractConstructor': "with it" ) - return ContractConstructor(cls.web3, + return ContractConstructor(cls.w3, cls.abi, cls.bytecode, *args, @@ -406,18 +406,18 @@ def encodeABI(cls, fn_name: str, args: Optional[Any] = None, :param data: defaults to function selector """ fn_abi, fn_selector, fn_arguments = get_function_info( - fn_name, cls.web3.codec, contract_abi=cls.abi, args=args, kwargs=kwargs, + fn_name, cls.w3.codec, contract_abi=cls.abi, args=args, kwargs=kwargs, ) if data is None: data = fn_selector - return encode_abi(cls.web3, fn_abi, fn_arguments, data) + return encode_abi(cls.w3, fn_abi, fn_arguments, data) @combomethod def all_functions(self) -> List['ContractFunction']: return find_functions_by_identifier( - self.abi, self.web3, self.address, lambda _: True + self.abi, self.w3, self.address, lambda _: True ) @combomethod @@ -431,7 +431,7 @@ def get_function_by_signature(self, signature: str) -> 'ContractFunction': def callable_check(fn_abi: ABIFunction) -> bool: return abi_to_signature(fn_abi) == signature - fns = find_functions_by_identifier(self.abi, self.web3, self.address, callable_check) + fns = find_functions_by_identifier(self.abi, self.w3, self.address, callable_check) return get_function_by_identifier(fns, 'signature') @combomethod @@ -440,7 +440,7 @@ def callable_check(fn_abi: ABIFunction) -> bool: return fn_abi['name'] == fn_name return find_functions_by_identifier( - self.abi, self.web3, self.address, callable_check + self.abi, self.w3, self.address, callable_check ) @combomethod @@ -455,7 +455,7 @@ def callable_check(fn_abi: ABIFunction) -> bool: # https://github.com/python/mypy/issues/4976 return encode_hex(function_abi_to_4byte_selector(fn_abi)) == to_4byte_hex(selector) # type: ignore # noqa: E501 - fns = find_functions_by_identifier(self.abi, self.web3, self.address, callable_check) + fns = find_functions_by_identifier(self.abi, self.w3, self.address, callable_check) return get_function_by_identifier(fns, 'selector') @combomethod @@ -468,7 +468,7 @@ def decode_function_input(self, data: HexStr) -> Tuple['ContractFunction', Dict[ names = get_abi_input_names(func.abi) types = get_abi_input_types(func.abi) - decoded = self.web3.codec.decode_abi(types, cast(HexBytes, params)) + decoded = self.w3.codec.decode_abi(types, cast(HexBytes, params)) normalized = map_abi_data(BASE_RETURN_NORMALIZERS, types, decoded) return func, dict(zip(names, normalized)) @@ -476,10 +476,10 @@ def decode_function_input(self, data: HexStr) -> Tuple['ContractFunction', Dict[ @combomethod def find_functions_by_args(self, *args: Any) -> List['ContractFunction']: def callable_check(fn_abi: ABIFunction) -> bool: - return check_if_arguments_can_be_encoded(fn_abi, self.web3.codec, args=args, kwargs={}) + return check_if_arguments_can_be_encoded(fn_abi, self.w3.codec, args=args, kwargs={}) return find_functions_by_identifier( - self.abi, self.web3, self.address, callable_check + self.abi, self.w3, self.address, callable_check ) @combomethod @@ -501,7 +501,7 @@ def _prepare_transaction(cls, return prepare_transaction( cls.address, - cls.web3, + cls.w3, fn_identifier=fn_name, contract_abi=cls.abi, transaction=transaction, @@ -515,7 +515,7 @@ def _find_matching_fn_abi( kwargs: Optional[Any] = None ) -> ABIFunction: return find_matching_fn_abi(cls.abi, - cls.web3.codec, + cls.w3.codec, fn_identifier=fn_identifier, args=args, kwargs=kwargs) @@ -531,12 +531,12 @@ def _find_matching_event_abi( @staticmethod def get_fallback_function( - abi: ABI, web3: 'Web3', address: Optional[ChecksumAddress] = None + abi: ABI, w3: 'Web3', address: Optional[ChecksumAddress] = None ) -> 'ContractFunction': if abi and fallback_func_abi_exists(abi): return ContractFunction.factory( 'fallback', - web3=web3, + w3=w3, contract_abi=abi, address=address, function_identifier=FallbackFn)() @@ -545,12 +545,12 @@ def get_fallback_function( @staticmethod def get_receive_function( - abi: ABI, web3: 'Web3', address: Optional[ChecksumAddress] = None + abi: ABI, w3: 'Web3', address: Optional[ChecksumAddress] = None ) -> 'ContractFunction': if abi and receive_func_abi_exists(abi): return ContractFunction.factory( 'receive', - web3=web3, + w3=w3, contract_abi=abi, address=address, function_identifier=ReceiveFn)() @@ -571,7 +571,7 @@ def _encode_constructor_data(cls, args: Optional[Any] = None, arguments = merge_args_and_kwargs(constructor_abi, args, kwargs) deploy_data = add_0x_prefix( - encode_abi(cls.web3, constructor_abi, arguments, data=cls.bytecode) + encode_abi(cls.w3, constructor_abi, arguments, data=cls.bytecode) ) else: if args is not None or kwargs is not None: @@ -596,9 +596,9 @@ class ContractConstructor: Class for contract constructor API. """ def __init__( - self, web3: 'Web3', abi: ABI, bytecode: HexStr, *args: Any, **kwargs: Any + self, w3: 'Web3', abi: ABI, bytecode: HexStr, *args: Any, **kwargs: Any ) -> None: - self.web3 = web3 + self.w3 = w3 self.abi = abi self.bytecode = bytecode self.data_in_transaction = self._encode_data_in_transaction(*args, **kwargs) @@ -615,7 +615,7 @@ def _encode_data_in_transaction(self, *args: Any, **kwargs: Any) -> HexStr: arguments = merge_args_and_kwargs(constructor_abi, args, kwargs) data = add_0x_prefix( - encode_abi(self.web3, constructor_abi, arguments, data=self.bytecode) + encode_abi(self.w3, constructor_abi, arguments, data=self.bytecode) ) else: data = to_hex(self.bytecode) @@ -634,13 +634,13 @@ def estimateGas( self.check_forbidden_keys_in_transaction(estimate_gas_transaction, ["data", "to"]) - if self.web3.eth.default_account is not empty: + if self.w3.eth.default_account is not empty: # type ignored b/c check prevents an empty default_account - estimate_gas_transaction.setdefault('from', self.web3.eth.default_account) # type: ignore # noqa: E501 + estimate_gas_transaction.setdefault('from', self.w3.eth.default_account) # type: ignore # noqa: E501 estimate_gas_transaction['data'] = self.data_in_transaction - return self.web3.eth.estimate_gas( + return self.w3.eth.estimate_gas( estimate_gas_transaction, block_identifier=block_identifier ) @@ -653,14 +653,14 @@ def transact(self, transaction: Optional[TxParams] = None) -> HexBytes: self.check_forbidden_keys_in_transaction(transact_transaction, ["data", "to"]) - if self.web3.eth.default_account is not empty: + if self.w3.eth.default_account is not empty: # type ignored b/c check prevents an empty default_account - transact_transaction.setdefault('from', self.web3.eth.default_account) # type: ignore + transact_transaction.setdefault('from', self.w3.eth.default_account) # type: ignore transact_transaction['data'] = self.data_in_transaction # TODO: handle asynchronous contract creation - return self.web3.eth.send_transaction(transact_transaction) + return self.w3.eth.send_transaction(transact_transaction) @combomethod def buildTransaction(self, transaction: Optional[TxParams] = None) -> TxParams: @@ -675,13 +675,13 @@ def buildTransaction(self, transaction: Optional[TxParams] = None) -> TxParams: self.check_forbidden_keys_in_transaction(built_transaction, ["data", "to"]) - if self.web3.eth.default_account is not empty: + if self.w3.eth.default_account is not empty: # type ignored b/c check prevents an empty default_account - built_transaction.setdefault('from', self.web3.eth.default_account) # type: ignore + built_transaction.setdefault('from', self.w3.eth.default_account) # type: ignore built_transaction['data'] = self.data_in_transaction built_transaction['to'] = Address(b'') - return fill_transaction_defaults(self.web3, built_transaction) + return fill_transaction_defaults(self.w3, built_transaction) @staticmethod def check_forbidden_keys_in_transaction( @@ -787,7 +787,7 @@ def _none_addr(datatype: str, data: ChecksumAddress) -> Tuple[str, Optional[Chec class ImplicitMethod(ConciseMethod): def __call_by_default(self, args: Any) -> bool: function_abi = find_matching_fn_abi(self._function.contract_abi, - self._function.web3.codec, + self._function.w3.codec, fn_identifier=self._function.function_identifier, args=args) @@ -852,7 +852,7 @@ class ContractFunction: """ address: ChecksumAddress = None function_identifier: FunctionIdentifier = None - web3: 'Web3' = None + w3: 'Web3' = None contract_abi: ABI = None abi: ABIFunction = None transaction: TxParams = None @@ -882,7 +882,7 @@ def _set_function_info(self) -> None: if not self.abi: self.abi = find_matching_fn_abi( self.contract_abi, - self.web3.codec, + self.w3.codec, self.function_identifier, self.args, self.kwargs @@ -936,9 +936,9 @@ def call( if self.address: call_transaction.setdefault('to', self.address) - if self.web3.eth.default_account is not empty: + if self.w3.eth.default_account is not empty: # type ignored b/c check prevents an empty default_account - call_transaction.setdefault('from', self.web3.eth.default_account) # type: ignore + call_transaction.setdefault('from', self.w3.eth.default_account) # type: ignore if 'to' not in call_transaction: if isinstance(self, type): @@ -952,10 +952,10 @@ def call( "Please ensure that this contract instance has an address." ) - block_id = parse_block_identifier(self.web3, block_identifier) + block_id = parse_block_identifier(self.w3, block_identifier) return call_contract_function( - self.web3, + self.w3, self.address, self._return_data_normalizers, self.function_identifier, @@ -979,9 +979,9 @@ def transact(self, transaction: Optional[TxParams] = None) -> HexBytes: if self.address is not None: transact_transaction.setdefault('to', self.address) - if self.web3.eth.default_account is not empty: + if self.w3.eth.default_account is not empty: # type ignored b/c check prevents an empty default_account - transact_transaction.setdefault('from', self.web3.eth.default_account) # type: ignore + transact_transaction.setdefault('from', self.w3.eth.default_account) # type: ignore if 'to' not in transact_transaction: if isinstance(self, type): @@ -996,7 +996,7 @@ def transact(self, transaction: Optional[TxParams] = None) -> HexBytes: return transact_with_contract_function( self.address, - self.web3, + self.w3, self.function_identifier, transact_transaction, self.contract_abi, @@ -1021,9 +1021,9 @@ def estimateGas( if self.address: estimate_gas_transaction.setdefault('to', self.address) - if self.web3.eth.default_account is not empty: + if self.w3.eth.default_account is not empty: # type ignored b/c check prevents an empty default_account - estimate_gas_transaction.setdefault('from', self.web3.eth.default_account) # type: ignore # noqa: E501 + estimate_gas_transaction.setdefault('from', self.w3.eth.default_account) # type: ignore # noqa: E501 if 'to' not in estimate_gas_transaction: if isinstance(self, type): @@ -1038,7 +1038,7 @@ def estimateGas( return estimate_gas_for_function( self.address, - self.web3, + self.w3, self.function_identifier, estimate_gas_transaction, self.contract_abi, @@ -1078,7 +1078,7 @@ def buildTransaction(self, transaction: Optional[TxParams] = None) -> TxParams: return build_transaction_for_function( self.address, - self.web3, + self.w3, self.function_identifier, built_transaction, self.contract_abi, @@ -1089,7 +1089,7 @@ def buildTransaction(self, transaction: Optional[TxParams] = None) -> TxParams: @combomethod def _encode_transaction_data(cls) -> HexStr: - return add_0x_prefix(encode_abi(cls.web3, cls.abi, cls.arguments, cls.selector)) + return add_0x_prefix(encode_abi(cls.w3, cls.abi, cls.arguments, cls.selector)) _return_data_normalizers: Optional[Tuple[Callable[..., Any], ...]] = tuple() @@ -1114,7 +1114,7 @@ class ContractEvent: """ address: ChecksumAddress = None event_name: str = None - web3: 'Web3' = None + w3: 'Web3' = None contract_abi: ABI = None abi: ABIEvent = None @@ -1151,7 +1151,7 @@ def _parse_logs( for log in txn_receipt['logs']: try: - rich_log = get_event_data(self.web3.codec, self.abi, log) + rich_log = get_event_data(self.w3.codec, self.abi, log) except (MismatchedABI, LogTopicError, InvalidEventABI, TypeError) as e: if errors == DISCARD: continue @@ -1173,7 +1173,7 @@ def _parse_logs( @combomethod def processLog(self, log: HexStr) -> EventData: - return get_event_data(self.web3.codec, self.abi, log) + return get_event_data(self.w3.codec, self.abi, log) @combomethod def createFilter( @@ -1201,7 +1201,7 @@ def createFilter( _, event_filter_params = construct_event_filter_params( self._get_event_abi(), - self.web3.codec, + self.w3.codec, contract_address=self.address, argument_filters=_filters, fromBlock=fromBlock, @@ -1210,7 +1210,7 @@ def createFilter( topics=topics, ) - filter_builder = EventFilterBuilder(event_abi, self.web3.codec) + filter_builder = EventFilterBuilder(event_abi, self.w3.codec) filter_builder.address = cast(ChecksumAddress, event_filter_params.get('address')) filter_builder.fromBlock = event_filter_params.get('fromBlock') filter_builder.toBlock = event_filter_params.get('toBlock') @@ -1228,8 +1228,8 @@ def createFilter( for arg, value in match_single_vals.items(): filter_builder.args[arg].match_single(value) - log_filter = filter_builder.deploy(self.web3) - log_filter.log_entry_formatter = get_event_data(self.web3.codec, self._get_event_abi()) + log_filter = filter_builder.deploy(self.w3) + log_filter.log_entry_formatter = get_event_data(self.w3.codec, self._get_event_abi()) log_filter.builder = filter_builder return log_filter @@ -1238,8 +1238,8 @@ def createFilter( def build_filter(self) -> EventFilterBuilder: builder = EventFilterBuilder( self._get_event_abi(), - self.web3.codec, - formatter=get_event_data(self.web3.codec, self._get_event_abi())) + self.w3.codec, + formatter=get_event_data(self.w3.codec, self._get_event_abi())) builder.address = self.address return builder @@ -1326,7 +1326,7 @@ def getLogs(self, # Namely, convert event names to their keccak signatures data_filter_set, event_filter_params = construct_event_filter_params( abi, - self.web3.codec, + self.w3.codec, contract_address=self.address, argument_filters=_filters, fromBlock=fromBlock, @@ -1338,10 +1338,10 @@ def getLogs(self, event_filter_params['blockHash'] = blockHash # Call JSON-RPC API - logs = self.web3.eth.get_logs(event_filter_params) + logs = self.w3.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) + return tuple(get_event_data(self.w3.codec, abi, entry) for entry in logs) @classmethod def factory(cls, class_name: str, **kwargs: Any) -> PropertyCheckingFactory: @@ -1372,11 +1372,11 @@ class ContractCaller: """ def __init__(self, abi: ABI, - web3: 'Web3', + w3: 'Web3', address: ChecksumAddress, transaction: Optional[TxParams] = None, block_identifier: BlockIdentifier = 'latest') -> None: - self.web3 = web3 + self.w3 = w3 self.address = address self.abi = abi self._functions = None @@ -1389,12 +1389,12 @@ def __init__(self, for func in self._functions: fn: ContractFunction = ContractFunction.factory( func['name'], - web3=self.web3, + w3=self.w3, contract_abi=self.abi, address=self.address, function_identifier=func['name']) - block_id = parse_block_identifier(self.web3, block_identifier) + block_id = parse_block_identifier(self.w3, block_identifier) caller_method = partial(self.call_function, fn, transaction=transaction, @@ -1435,7 +1435,7 @@ def __call__( if transaction is None: transaction = {} return type(self)(self.abi, - self.web3, + self.w3, self.address, transaction=transaction, block_identifier=block_identifier) @@ -1472,7 +1472,7 @@ def check_for_forbidden_api_filter_arguments( def call_contract_function( - web3: 'Web3', + w3: 'Web3', address: ChecksumAddress, normalizers: Tuple[Callable[..., Any], ...], function_identifier: FunctionIdentifier, @@ -1489,7 +1489,7 @@ def call_contract_function( """ call_transaction = prepare_transaction( address, - web3, + w3, fn_identifier=function_identifier, contract_abi=contract_abi, fn_abi=fn_abi, @@ -1498,25 +1498,25 @@ def call_contract_function( fn_kwargs=kwargs, ) - return_data = web3.eth.call( + return_data = w3.eth.call( call_transaction, block_identifier=block_id, state_override=state_override, ) if fn_abi is None: - fn_abi = find_matching_fn_abi(contract_abi, web3.codec, function_identifier, args, kwargs) + fn_abi = find_matching_fn_abi(contract_abi, w3.codec, function_identifier, args, kwargs) output_types = get_abi_output_types(fn_abi) try: - output_data = web3.codec.decode_abi(output_types, return_data) + output_data = w3.codec.decode_abi(output_types, return_data) except DecodingError as e: # Provide a more helpful error message than the one provided by # eth-abi-utils is_missing_code_error = ( return_data in ACCEPTABLE_EMPTY_STRINGS - and web3.eth.get_code(address) in ACCEPTABLE_EMPTY_STRINGS) + and w3.eth.get_code(address) in ACCEPTABLE_EMPTY_STRINGS) if is_missing_code_error: msg = ( "Could not transact with/call contract function, is contract " @@ -1541,22 +1541,22 @@ def call_contract_function( return normalized_data -def parse_block_identifier(web3: 'Web3', block_identifier: BlockIdentifier) -> BlockIdentifier: +def parse_block_identifier(w3: 'Web3', block_identifier: BlockIdentifier) -> BlockIdentifier: if isinstance(block_identifier, int): - return parse_block_identifier_int(web3, block_identifier) + return parse_block_identifier_int(w3, block_identifier) elif block_identifier in ['latest', 'earliest', 'pending']: return block_identifier elif isinstance(block_identifier, bytes) or is_hex_encoded_block_hash(block_identifier): - return web3.eth.get_block(block_identifier)['number'] + return w3.eth.get_block(block_identifier)['number'] else: raise BlockNumberOutofRange -def parse_block_identifier_int(web3: 'Web3', block_identifier_int: int) -> BlockNumber: +def parse_block_identifier_int(w3: 'Web3', block_identifier_int: int) -> BlockNumber: if block_identifier_int >= 0: block_num = block_identifier_int else: - last_block = web3.eth.get_block('latest')['number'] + last_block = w3.eth.get_block('latest')['number'] block_num = last_block + block_identifier_int + 1 if block_num < 0: raise BlockNumberOutofRange @@ -1565,7 +1565,7 @@ def parse_block_identifier_int(web3: 'Web3', block_identifier_int: int) -> Block def transact_with_contract_function( address: ChecksumAddress, - web3: 'Web3', + w3: 'Web3', function_name: Optional[FunctionIdentifier] = None, transaction: Optional[TxParams] = None, contract_abi: Optional[ABI] = None, @@ -1578,7 +1578,7 @@ def transact_with_contract_function( """ transact_transaction = prepare_transaction( address, - web3, + w3, fn_identifier=function_name, contract_abi=contract_abi, transaction=transaction, @@ -1587,13 +1587,13 @@ def transact_with_contract_function( fn_kwargs=kwargs, ) - txn_hash = web3.eth.send_transaction(transact_transaction) + txn_hash = w3.eth.send_transaction(transact_transaction) return txn_hash def estimate_gas_for_function( address: ChecksumAddress, - web3: 'Web3', + w3: 'Web3', fn_identifier: Optional[FunctionIdentifier] = None, transaction: Optional[TxParams] = None, contract_abi: Optional[ABI] = None, @@ -1608,7 +1608,7 @@ def estimate_gas_for_function( """ estimate_transaction = prepare_transaction( address, - web3, + w3, fn_identifier=fn_identifier, contract_abi=contract_abi, fn_abi=fn_abi, @@ -1617,12 +1617,12 @@ def estimate_gas_for_function( fn_kwargs=kwargs, ) - return web3.eth.estimate_gas(estimate_transaction, block_identifier) + return w3.eth.estimate_gas(estimate_transaction, block_identifier) def build_transaction_for_function( address: ChecksumAddress, - web3: 'Web3', + w3: 'Web3', function_name: Optional[FunctionIdentifier] = None, transaction: Optional[TxParams] = None, contract_abi: Optional[ABI] = None, @@ -1636,7 +1636,7 @@ def build_transaction_for_function( """ prepared_transaction = prepare_transaction( address, - web3, + w3, fn_identifier=function_name, contract_abi=contract_abi, fn_abi=fn_abi, @@ -1645,19 +1645,19 @@ def build_transaction_for_function( fn_kwargs=kwargs, ) - prepared_transaction = fill_transaction_defaults(web3, prepared_transaction) + prepared_transaction = fill_transaction_defaults(w3, prepared_transaction) return prepared_transaction def find_functions_by_identifier( - contract_abi: ABI, web3: 'Web3', address: ChecksumAddress, callable_check: Callable[..., Any] + contract_abi: ABI, w3: 'Web3', address: ChecksumAddress, callable_check: Callable[..., Any] ) -> List[ContractFunction]: fns_abi = filter_by_type('function', contract_abi) return [ ContractFunction.factory( fn_abi['name'], - web3=web3, + w3=w3, contract_abi=contract_abi, address=address, function_identifier=fn_abi['name'], diff --git a/web3/eth.py b/web3/eth.py index 95473c0bc2..079f6bd1f5 100644 --- a/web3/eth.py +++ b/web3/eth.py @@ -210,7 +210,7 @@ def send_transaction_munger(self, transaction: TxParams) -> Tuple[TxParams]: def _generate_gas_price(self, transaction_params: Optional[TxParams] = None) -> Optional[Wei]: if self.gasPriceStrategy: - return self.gasPriceStrategy(self.web3, transaction_params) + return self.gasPriceStrategy(self.w3, transaction_params) return None def set_gas_price_strategy(self, gas_price_strategy: GasPriceStrategy) -> None: @@ -804,8 +804,8 @@ def replaceTransaction(self, transaction_hash: _Hash32, new_transaction: TxParam return self.replace_transaction(transaction_hash, new_transaction) def replace_transaction(self, transaction_hash: _Hash32, new_transaction: TxParams) -> HexBytes: - current_transaction = get_required_transaction(self.web3, transaction_hash) - return replace_transaction(self.web3, current_transaction, new_transaction) + current_transaction = get_required_transaction(self.w3, transaction_hash) + return replace_transaction(self.w3, current_transaction, new_transaction) # todo: Update Any to stricter kwarg checking with TxParams # https://github.com/python/mypy/issues/4441 @@ -819,10 +819,10 @@ def modify_transaction( self, transaction_hash: _Hash32, **transaction_params: Any ) -> HexBytes: assert_valid_transaction_params(cast(TxParams, transaction_params)) - current_transaction = get_required_transaction(self.web3, transaction_hash) + current_transaction = get_required_transaction(self.w3, transaction_hash) current_transaction_params = extract_valid_transaction_params(current_transaction) new_transaction = merge(current_transaction_params, transaction_params) - return replace_transaction(self.web3, current_transaction, new_transaction) + return replace_transaction(self.w3, current_transaction, new_transaction) def send_transaction(self, transaction: TxParams) -> HexBytes: return self._send_transaction(transaction) @@ -952,7 +952,7 @@ def contract( # noqa: F811 ) -> Union[Type[Contract], Contract]: ContractFactoryClass = kwargs.pop('ContractFactoryClass', self.defaultContractFactory) - ContractFactory = ContractFactoryClass.factory(self.web3, **kwargs) + ContractFactory = ContractFactoryClass.factory(self.w3, **kwargs) if address: return ContractFactory(address) diff --git a/web3/gas_strategies/rpc.py b/web3/gas_strategies/rpc.py index 272c90ebe8..aea969daae 100644 --- a/web3/gas_strategies/rpc.py +++ b/web3/gas_strategies/rpc.py @@ -12,9 +12,9 @@ ) -def rpc_gas_price_strategy(web3: Web3, +def rpc_gas_price_strategy(w3: Web3, transaction_params: Optional[TxParams] = None) -> Wei: """ A simple gas price strategy deriving it's value from the eth_gasPrice JSON-RPC call. """ - return web3.manager.request_blocking(RPC.eth_gasPrice, []) + return w3.manager.request_blocking(RPC.eth_gasPrice, []) diff --git a/web3/gas_strategies/time_based.py b/web3/gas_strategies/time_based.py index 34af8e6cde..042f58a88d 100644 --- a/web3/gas_strategies/time_based.py +++ b/web3/gas_strategies/time_based.py @@ -201,14 +201,14 @@ def construct_time_based_gas_price_strategy( and 100 means 100%. """ - def time_based_gas_price_strategy(web3: Web3, transaction_params: TxParams) -> Wei: + def time_based_gas_price_strategy(w3: Web3, transaction_params: TxParams) -> Wei: if weighted: - avg_block_time = _get_weighted_avg_block_time(web3, sample_size=sample_size) + avg_block_time = _get_weighted_avg_block_time(w3, sample_size=sample_size) else: - avg_block_time = _get_avg_block_time(web3, sample_size=sample_size) + avg_block_time = _get_avg_block_time(w3, sample_size=sample_size) wait_blocks = int(math.ceil(max_wait_seconds / avg_block_time)) - raw_miner_data = _get_raw_miner_data(web3, sample_size=sample_size) + raw_miner_data = _get_raw_miner_data(w3, sample_size=sample_size) miner_data = _aggregate_miner_data(raw_miner_data) probabilities = _compute_probabilities( diff --git a/web3/manager.py b/web3/manager.py index 1cd4e1c241..1594c4dd6f 100644 --- a/web3/manager.py +++ b/web3/manager.py @@ -90,15 +90,15 @@ class RequestManager: def __init__( self, - web3: 'Web3', + w3: 'Web3', provider: Optional[BaseProvider] = None, middlewares: Optional[Sequence[Tuple[Middleware, str]]] = None ) -> None: - self.web3 = web3 + self.w3 = w3 self.pending_requests: Dict[UUID, ThreadWithReturn[RPCResponse]] = {} if middlewares is None: - middlewares = self.default_middlewares(web3) + middlewares = self.default_middlewares(w3) self.middleware_onion: MiddlewareOnion = NamedElementOnion(middlewares) @@ -107,7 +107,7 @@ def __init__( else: self.provider = provider - web3: 'Web3' = None + w3: 'Web3' = None _provider = None @property @@ -120,7 +120,7 @@ def provider(self, provider: BaseProvider) -> None: @staticmethod def default_middlewares( - web3: 'Web3' + w3: 'Web3' ) -> List[Tuple[Middleware, str]]: """ List the default middlewares for the request manager. @@ -129,7 +129,7 @@ def default_middlewares( return [ (request_parameter_normalizer, 'request_param_normalizer'), # Delete (gas_price_strategy_middleware, 'gas_price_strategy'), - (name_to_address_middleware(web3), 'name_to_address'), # Add Async + (name_to_address_middleware(w3), 'name_to_address'), # Add Async (attrdict_middleware, 'attrdict'), # Delete (pythonic_middleware, 'pythonic'), # Delete (validation_middleware, 'validation'), @@ -144,7 +144,7 @@ def _make_request( self, method: Union[RPCEndpoint, Callable[..., RPCEndpoint]], params: Any ) -> RPCResponse: request_func = self.provider.request_func( - self.web3, + self.w3, self.middleware_onion) self.logger.debug("Making request. Method: %s", method) return request_func(method, params) @@ -154,7 +154,7 @@ async def _coro_make_request( ) -> RPCResponse: # type ignored b/c request_func is an awaitable in async model request_func = await self.provider.request_func( # type: ignore - self.web3, + self.w3, self.middleware_onion) self.logger.debug("Making request. Method: %s", method) return await request_func(method, params) diff --git a/web3/method.py b/web3/method.py index 78f68a68e3..4f08807e40 100644 --- a/web3/method.py +++ b/web3/method.py @@ -123,7 +123,7 @@ def __init__( error_formatters: Optional[Callable[..., TReturn]] = None, null_result_formatters: Optional[Callable[..., TReturn]] = None, method_choice_depends_on_args: Optional[Callable[..., RPCEndpoint]] = None, - web3: Optional["Web3"] = None): + w3: Optional["Web3"] = None): self.json_rpc_method = json_rpc_method self.mungers = mungers or [default_munger] diff --git a/web3/middleware/__init__.py b/web3/middleware/__init__.py index ea2f00c6ed..7ca174697c 100644 --- a/web3/middleware/__init__.py +++ b/web3/middleware/__init__.py @@ -80,7 +80,7 @@ def combine_middlewares( middlewares: Sequence[Middleware], - web3: 'Web3', + w3: 'Web3', provider_request_fn: Callable[[RPCEndpoint, Any], Any] ) -> Callable[..., RPCResponse]: """ @@ -88,7 +88,7 @@ def combine_middlewares( function wrapped with all of the middlewares. """ return functools.reduce( - lambda request_fn, middleware: middleware(request_fn, web3), + lambda request_fn, middleware: middleware(request_fn, w3), reversed(middlewares), provider_request_fn, ) @@ -96,7 +96,7 @@ def combine_middlewares( async def async_combine_middlewares( middlewares: Sequence[Middleware], - web3: 'Web3', + w3: 'Web3', provider_request_fn: Callable[[RPCEndpoint, Any], Any] ) -> Callable[..., RPCResponse]: """ @@ -105,7 +105,7 @@ async def async_combine_middlewares( """ accumulator_fn = provider_request_fn for middleware in reversed(middlewares): - accumulator_fn = await construct_middleware(middleware, accumulator_fn, web3) + accumulator_fn = await construct_middleware(middleware, accumulator_fn, w3) return accumulator_fn diff --git a/web3/middleware/attrdict.py b/web3/middleware/attrdict.py index 14f33e1bf1..16643ae4ac 100644 --- a/web3/middleware/attrdict.py +++ b/web3/middleware/attrdict.py @@ -24,7 +24,7 @@ def attrdict_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> Callable[[RPCEndpoint, Any], RPCResponse]: """ Converts any result which is a dictionary into an a diff --git a/web3/middleware/buffered_gas_estimate.py b/web3/middleware/buffered_gas_estimate.py index 194c4178e1..faa8baa0a7 100644 --- a/web3/middleware/buffered_gas_estimate.py +++ b/web3/middleware/buffered_gas_estimate.py @@ -25,7 +25,7 @@ def buffered_gas_estimate_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> Callable[[RPCEndpoint, Any], RPCResponse]: def middleware(method: RPCEndpoint, params: Any) -> RPCResponse: if method == 'eth_sendTransaction': @@ -34,7 +34,7 @@ def middleware(method: RPCEndpoint, params: Any) -> RPCResponse: transaction = assoc( transaction, 'gas', - hex(get_buffered_gas_estimate(web3, transaction)), + hex(get_buffered_gas_estimate(w3, transaction)), ) return make_request(method, [transaction]) return make_request(method, params) @@ -42,13 +42,13 @@ def middleware(method: RPCEndpoint, params: Any) -> RPCResponse: async def async_buffered_gas_estimate_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> AsyncMiddleware: async def middleware(method: RPCEndpoint, params: Any) -> RPCResponse: if method == 'eth_sendTransaction': transaction = params[0] if 'gas' not in transaction: - gas_estimate = await async_get_buffered_gas_estimate(web3, transaction) + gas_estimate = await async_get_buffered_gas_estimate(w3, transaction) transaction = assoc( transaction, 'gas', diff --git a/web3/middleware/cache.py b/web3/middleware/cache.py index e81761b0a3..c0635daf97 100644 --- a/web3/middleware/cache.py +++ b/web3/middleware/cache.py @@ -112,7 +112,7 @@ def construct_simple_cache_middleware( cached. """ def simple_cache_middleware( - make_request: Callable[[RPCEndpoint, Any], RPCResponse], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], RPCResponse], w3: "Web3" ) -> Callable[[RPCEndpoint, Any], RPCResponse]: cache = cache_class() lock = threading.Lock() @@ -216,7 +216,7 @@ def construct_time_based_cache_middleware( cached. """ def time_based_cache_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> Callable[[RPCEndpoint, Any], RPCResponse]: cache = cache_class() lock = threading.Lock() @@ -356,7 +356,7 @@ def construct_latest_block_based_cache_middleware( block time. """ def latest_block_based_cache_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> Callable[[RPCEndpoint, Any], RPCResponse]: cache = cache_class() block_info: BlockInfoCache = {} @@ -379,12 +379,12 @@ def _update_block_info_cache() -> None: # measured by blocks is greater than or equal to the number of # blocks sampled then we need to recompute the average block # time. - latest_block = web3.eth.get_block('latest') + latest_block = w3.eth.get_block('latest') ancestor_block_number = BlockNumber(max( 0, latest_block['number'] - average_block_time_sample_size, )) - ancestor_block = web3.eth.get_block(ancestor_block_number) + ancestor_block = w3.eth.get_block(ancestor_block_number) sample_size = latest_block['number'] - ancestor_block_number block_info[AVG_BLOCK_SAMPLE_SIZE_KEY] = sample_size @@ -402,10 +402,10 @@ def _update_block_info_cache() -> None: # latest block is too old so update cache if time_since_latest_block > avg_block_time: - block_info['latest_block'] = web3.eth.get_block('latest') + block_info['latest_block'] = w3.eth.get_block('latest') else: # latest block has not been fetched so we fetch it. - block_info['latest_block'] = web3.eth.get_block('latest') + block_info['latest_block'] = w3.eth.get_block('latest') lock = threading.Lock() diff --git a/web3/middleware/exception_handling.py b/web3/middleware/exception_handling.py index a74cc19694..c2781456a9 100644 --- a/web3/middleware/exception_handling.py +++ b/web3/middleware/exception_handling.py @@ -30,7 +30,7 @@ def construct_exception_handler_middleware( method_handlers = {} def exception_handler_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> Callable[[RPCEndpoint, Any], RPCResponse]: def middleware(method: RPCEndpoint, params: Any) -> RPCResponse: if method in method_handlers: diff --git a/web3/middleware/exception_retry_request.py b/web3/middleware/exception_retry_request.py index 3289189d5a..48514ef44c 100644 --- a/web3/middleware/exception_retry_request.py +++ b/web3/middleware/exception_retry_request.py @@ -90,7 +90,7 @@ def check_if_retry_on_failure(method: RPCEndpoint) -> bool: def exception_retry_middleware( make_request: Callable[[RPCEndpoint, Any], RPCResponse], - web3: "Web3", + w3: "Web3", errors: Collection[Type[BaseException]], retries: int = 5, ) -> Callable[[RPCEndpoint, Any], RPCResponse]: @@ -116,10 +116,10 @@ def middleware(method: RPCEndpoint, params: Any) -> RPCResponse: def http_retry_request_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> Callable[[RPCEndpoint, Any], Any]: return exception_retry_middleware( make_request, - web3, + w3, (ConnectionError, HTTPError, Timeout, TooManyRedirects) ) diff --git a/web3/middleware/gas_price_strategy.py b/web3/middleware/gas_price_strategy.py index 9d3fcacc6d..c336956d64 100644 --- a/web3/middleware/gas_price_strategy.py +++ b/web3/middleware/gas_price_strategy.py @@ -70,7 +70,7 @@ def validate_transaction_params( def gas_price_strategy_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> Callable[[RPCEndpoint, Any], RPCResponse]: """ - Uses a gas price strategy if one is set. This is only supported for legacy transactions. @@ -81,8 +81,8 @@ def gas_price_strategy_middleware( def middleware(method: RPCEndpoint, params: Any) -> RPCResponse: if method == 'eth_sendTransaction': transaction = params[0] - generated_gas_price = web3.eth.generate_gas_price(transaction) - latest_block = web3.eth.get_block('latest') + generated_gas_price = w3.eth.generate_gas_price(transaction) + latest_block = w3.eth.get_block('latest') transaction = validate_transaction_params( transaction, latest_block, generated_gas_price ) @@ -93,7 +93,7 @@ def middleware(method: RPCEndpoint, params: Any) -> RPCResponse: async def async_gas_price_strategy_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> AsyncMiddleware: """ - Uses a gas price strategy if one is set. This is only supported for legacy transactions. @@ -104,8 +104,8 @@ async def async_gas_price_strategy_middleware( async def middleware(method: RPCEndpoint, params: Any) -> RPCResponse: if method == 'eth_sendTransaction': transaction = params[0] - generated_gas_price = await web3.eth.generate_gas_price(transaction) # type: ignore - latest_block = await web3.eth.get_block('latest') # type: ignore + generated_gas_price = await w3.eth.generate_gas_price(transaction) # type: ignore + latest_block = await w3.eth.get_block('latest') # type: ignore transaction = validate_transaction_params( transaction, latest_block, generated_gas_price ) diff --git a/web3/middleware/geth_poa.py b/web3/middleware/geth_poa.py index 6048cc70f0..5f2f74a135 100644 --- a/web3/middleware/geth_poa.py +++ b/web3/middleware/geth_poa.py @@ -55,7 +55,7 @@ async def async_geth_poa_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> AsyncMiddleware: middleware = await async_construct_formatting_middleware( result_formatters={ @@ -63,4 +63,4 @@ async def async_geth_poa_middleware( RPC.eth_getBlockByNumber: apply_formatter_if(is_not_null, geth_poa_cleanup), }, ) - return await middleware(make_request, web3) + return await middleware(make_request, w3) diff --git a/web3/middleware/simulate_unmined_transaction.py b/web3/middleware/simulate_unmined_transaction.py index e36300c9ff..9e74b20c06 100644 --- a/web3/middleware/simulate_unmined_transaction.py +++ b/web3/middleware/simulate_unmined_transaction.py @@ -22,7 +22,7 @@ def unmined_receipt_simulator_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: Web3 + make_request: Callable[[RPCEndpoint, Any], Any], w3: Web3 ) -> Callable[[RPCEndpoint, Any], RPCResponse]: receipt_counters: DefaultDict[Hash32, TxReceipt] = collections.defaultdict( # type: ignore # noqa: F821, E501 itertools.count diff --git a/web3/middleware/stalecheck.py b/web3/middleware/stalecheck.py index 7b244653f9..73e8158770 100644 --- a/web3/middleware/stalecheck.py +++ b/web3/middleware/stalecheck.py @@ -50,7 +50,7 @@ def make_stalecheck_middleware( raise ValueError("You must set a positive allowable_delay in seconds for this middleware") def stalecheck_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> Callable[[RPCEndpoint, Any], RPCResponse]: cache: Dict[str, BlockData] = {'latest': None} @@ -59,7 +59,7 @@ def middleware(method: RPCEndpoint, params: Any) -> RPCResponse: if _isfresh(cache['latest'], allowable_delay): pass else: - latest = web3.eth.get_block('latest') + latest = w3.eth.get_block('latest') if _isfresh(latest, allowable_delay): cache['latest'] = latest else: diff --git a/web3/middleware/validation.py b/web3/middleware/validation.py index 44d79825de..5fafce175b 100644 --- a/web3/middleware/validation.py +++ b/web3/middleware/validation.py @@ -164,9 +164,9 @@ async def async_build_method_validators(async_w3: "Web3", method: RPCEndpoint) - async def async_validation_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> AsyncMiddleware: middleware = await async_construct_web3_formatting_middleware( async_build_method_validators ) - return await middleware(make_request, web3) + return await middleware(make_request, w3) diff --git a/web3/module.py b/web3/module.py index c0dc6edb24..49fdfb9209 100644 --- a/web3/module.py +++ b/web3/module.py @@ -84,10 +84,10 @@ async def caller(*args: Any, **kwargs: Any) -> RPCResponse: class Module: is_async = False - def __init__(self, web3: "Web3") -> None: + def __init__(self, w3: "Web3") -> None: if self.is_async: - self.retrieve_caller_fn = retrieve_async_method_call_fn(web3, self) + self.retrieve_caller_fn = retrieve_async_method_call_fn(w3, self) else: - self.retrieve_caller_fn = retrieve_blocking_method_call_fn(web3, self) - self.web3 = web3 - self.codec: ABICodec = web3.codec + self.retrieve_caller_fn = retrieve_blocking_method_call_fn(w3, self) + self.w3 = w3 + self.codec: ABICodec = w3.codec diff --git a/web3/parity.py b/web3/parity.py index 2c32c3b96f..84bcaa5c44 100644 --- a/web3/parity.py +++ b/web3/parity.py @@ -186,8 +186,8 @@ def trace_call_munger( block_identifier: Optional[BlockIdentifier] = None ) -> Tuple[TxParams, ParityTraceMode, BlockIdentifier]: # TODO: move to middleware - if 'from' not in transaction and is_checksum_address(self.web3.eth.default_account): - transaction = assoc(transaction, 'from', self.web3.eth.default_account) + if 'from' not in transaction and is_checksum_address(self.w3.eth.default_account): + transaction = assoc(transaction, 'from', self.w3.eth.default_account) # TODO: move to middleware if block_identifier is None: diff --git a/web3/pm.py b/web3/pm.py index 2646dc4b9b..be32db5eb1 100644 --- a/web3/pm.py +++ b/web3/pm.py @@ -327,7 +327,7 @@ def get_package_from_manifest(self, manifest: Manifest) -> Package: * Parameters: * ``manifest``: A dict representing a valid manifest """ - return Package(manifest, self.web3) + return Package(manifest, self.w3) def get_package_from_uri(self, manifest_uri: URI) -> Package: """ @@ -339,7 +339,7 @@ def get_package_from_uri(self, manifest_uri: URI) -> Package: * Parameters: * ``uri``: Must be a valid content-addressed URI """ - return Package.from_uri(manifest_uri, self.web3) + return Package.from_uri(manifest_uri, self.w3) def get_local_package(self, package_name: str, ethpm_dir: Path = None) -> Package: """ @@ -381,17 +381,17 @@ def set_registry(self, address: Union[Address, ChecksumAddress, ENS]) -> None: """ if is_canonical_address(address): addr_string = to_text(address) - self.registry = SimpleRegistry(to_checksum_address(addr_string), self.web3) + self.registry = SimpleRegistry(to_checksum_address(addr_string), self.w3) elif is_checksum_address(address): - self.registry = SimpleRegistry(cast(ChecksumAddress, address), self.web3) + self.registry = SimpleRegistry(cast(ChecksumAddress, address), self.w3) elif is_ens_name(address): self._validate_set_ens() - addr_lookup = self.web3.ens.address(str(address)) + addr_lookup = self.w3.ens.address(str(address)) if not addr_lookup: raise NameNotFound( f"No address found after ENS lookup for name: {address!r}." ) - self.registry = SimpleRegistry(addr_lookup, self.web3) + self.registry = SimpleRegistry(addr_lookup, self.w3) else: raise PMError( "Expected a canonical/checksummed address or ENS name for the address, " @@ -409,7 +409,7 @@ def deploy_and_set_registry(self) -> ChecksumAddress: w3.ens.setup_address(ens_name, w3.pm.registry.address) """ - self.registry = SimpleRegistry.deploy_new_instance(self.web3) + self.registry = SimpleRegistry.deploy_new_instance(self.w3) return to_checksum_address(self.registry.address) def release_package( @@ -554,11 +554,11 @@ def _validate_set_registry(self) -> None: ) def _validate_set_ens(self) -> None: - if not self.web3: + if not self.w3: raise InvalidAddress( "Could not look up ENS address because no web3 " "connection available" ) - elif not self.web3.ens: + elif not self.w3.ens: raise InvalidAddress( "Could not look up ENS address because web3.ens is " "set to None" ) diff --git a/web3/providers/async_base.py b/web3/providers/async_base.py index 1d446389b7..6f2fa551ab 100644 --- a/web3/providers/async_base.py +++ b/web3/providers/async_base.py @@ -53,7 +53,7 @@ def middlewares( self._middlewares = tuple(values) # type: ignore async def request_func( - self, web3: "Web3", outer_middlewares: MiddlewareOnion + self, w3: "Web3", outer_middlewares: MiddlewareOnion ) -> Callable[[RPCEndpoint], Any]: all_middlewares: Tuple[Middleware] = tuple(outer_middlewares) + tuple(self.middlewares) # type: ignore # noqa: E501 @@ -61,16 +61,16 @@ async def request_func( if cache_key is None or cache_key != all_middlewares: self._request_func_cache = ( all_middlewares, - await self._generate_request_func(web3, all_middlewares) + await self._generate_request_func(w3, all_middlewares) ) return self._request_func_cache[-1] async def _generate_request_func( - self, web3: "Web3", middlewares: Sequence[Middleware] + self, w3: "Web3", middlewares: Sequence[Middleware] ) -> Callable[..., RPCResponse]: return await async_combine_middlewares( middlewares=middlewares, - web3=web3, + w3=w3, provider_request_fn=self.make_request, ) diff --git a/web3/providers/base.py b/web3/providers/base.py index 4f426934d5..51f4ba123c 100644 --- a/web3/providers/base.py +++ b/web3/providers/base.py @@ -47,7 +47,7 @@ def middlewares( self._middlewares = tuple(values) # type: ignore def request_func( - self, web3: "Web3", outer_middlewares: MiddlewareOnion + self, w3: "Web3", outer_middlewares: MiddlewareOnion ) -> Callable[..., RPCResponse]: """ @param outer_middlewares is an iterable of middlewares, ordered by first to execute @@ -60,16 +60,16 @@ def request_func( if cache_key is None or cache_key != all_middlewares: self._request_func_cache = ( all_middlewares, - self._generate_request_func(web3, all_middlewares) + self._generate_request_func(w3, all_middlewares) ) return self._request_func_cache[-1] def _generate_request_func( - self, web3: "Web3", middlewares: Sequence[Middleware] + self, w3: "Web3", middlewares: Sequence[Middleware] ) -> Callable[..., RPCResponse]: return combine_middlewares( middlewares=middlewares, - web3=web3, + w3=w3, provider_request_fn=self.make_request, ) diff --git a/web3/providers/eth_tester/middleware.py b/web3/providers/eth_tester/middleware.py index fb865d8aab..18fbd42965 100644 --- a/web3/providers/eth_tester/middleware.py +++ b/web3/providers/eth_tester/middleware.py @@ -287,13 +287,13 @@ def is_hexstr(value: Any) -> bool: ) -def guess_from(web3: "Web3", _: TxParams) -> ChecksumAddress: - coinbase = web3.eth.coinbase +def guess_from(w3: "Web3", _: TxParams) -> ChecksumAddress: + coinbase = w3.eth.coinbase if coinbase is not None: return coinbase try: - return web3.eth.accounts[0] + return w3.eth.accounts[0] except KeyError: # no accounts available to pre-fill, carry on pass @@ -303,20 +303,20 @@ def guess_from(web3: "Web3", _: TxParams) -> ChecksumAddress: @curry def fill_default( - field: str, guess_func: Callable[..., Any], web3: "Web3", transaction: TxParams + field: str, guess_func: Callable[..., Any], w3: "Web3", transaction: TxParams ) -> TxParams: # type ignored b/c TxParams keys must be string literal types if field in transaction and transaction[field] is not None: # type: ignore return transaction else: - guess_val = guess_func(web3, transaction) + guess_val = guess_func(w3, transaction) return assoc(transaction, field, guess_val) def default_transaction_fields_middleware( - make_request: Callable[[RPCEndpoint, Any], Any], web3: "Web3" + make_request: Callable[[RPCEndpoint, Any], Any], w3: "Web3" ) -> Callable[[RPCEndpoint, Any], RPCResponse]: - fill_default_from = fill_default('from', guess_from, web3) + fill_default_from = fill_default('from', guess_from, w3) def middleware(method: RPCEndpoint, params: Any) -> RPCResponse: if method in ( diff --git a/web3/testing.py b/web3/testing.py index 4537df8c80..f421c83a22 100644 --- a/web3/testing.py +++ b/web3/testing.py @@ -12,21 +12,21 @@ class Testing(Module): def timeTravel(self, timestamp: int) -> None: - return self.web3.manager.request_blocking(RPC.testing_timeTravel, [timestamp]) + return self.w3.manager.request_blocking(RPC.testing_timeTravel, [timestamp]) def mine(self, num_blocks: int = 1) -> None: - return self.web3.manager.request_blocking(RPC.evm_mine, [num_blocks]) + return self.w3.manager.request_blocking(RPC.evm_mine, [num_blocks]) def snapshot(self) -> int: - self.last_snapshot_idx = self.web3.manager.request_blocking(RPC.evm_snapshot, []) + self.last_snapshot_idx = self.w3.manager.request_blocking(RPC.evm_snapshot, []) return self.last_snapshot_idx def reset(self) -> None: - return self.web3.manager.request_blocking(RPC.evm_reset, []) + return self.w3.manager.request_blocking(RPC.evm_reset, []) def revert(self, snapshot_idx: Optional[int] = None) -> None: if snapshot_idx is None: revert_target = self.last_snapshot_idx else: revert_target = snapshot_idx - return self.web3.manager.request_blocking(RPC.evm_revert, [revert_target]) + return self.w3.manager.request_blocking(RPC.evm_revert, [revert_target]) diff --git a/web3/tools/benchmark/main.py b/web3/tools/benchmark/main.py index 7146974e0e..efef6d8189 100644 --- a/web3/tools/benchmark/main.py +++ b/web3/tools/benchmark/main.py @@ -63,21 +63,21 @@ def build_web3_http(endpoint_uri: str) -> Web3: wait_for_http(endpoint_uri) - _web3 = Web3( + _w3 = Web3( HTTPProvider(endpoint_uri), middlewares=[gas_price_strategy_middleware, buffered_gas_estimate_middleware] ) - return _web3 + return _w3 async def build_async_w3_http(endpoint_uri: str) -> Web3: await wait_for_aiohttp(endpoint_uri) - _web3 = Web3( + _w3 = Web3( AsyncHTTPProvider(endpoint_uri), # type: ignore middlewares=[async_gas_price_strategy_middleware, async_buffered_gas_estimate_middleware], modules={"eth": AsyncEth}, ) - return _web3 + return _w3 def sync_benchmark(func: Callable[..., Any], n: int) -> Union[float, str]: From 81427e69388a4a900ca1260fbb82bef91129367c Mon Sep 17 00:00:00 2001 From: Dario Date: Wed, 2 Mar 2022 23:49:06 +0100 Subject: [PATCH 17/57] Add chain_id setter (#2207) --- newsfragments/2207.feature.rst | 1 + tests/core/eth-module/test_eth_properties.py | 13 ++++++++++++- web3/eth.py | 10 +++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 newsfragments/2207.feature.rst diff --git a/newsfragments/2207.feature.rst b/newsfragments/2207.feature.rst new file mode 100644 index 0000000000..78a6f8bbd5 --- /dev/null +++ b/newsfragments/2207.feature.rst @@ -0,0 +1 @@ +Add setter for the Eth.chain_id property diff --git a/tests/core/eth-module/test_eth_properties.py b/tests/core/eth-module/test_eth_properties.py index 9f89391ad6..596222b62a 100644 --- a/tests/core/eth-module/test_eth_properties.py +++ b/tests/core/eth-module/test_eth_properties.py @@ -2,7 +2,8 @@ def test_eth_protocol_version(w3): - assert w3.eth.protocol_version == '63' + with pytest.warns(DeprecationWarning): + assert w3.eth.protocol_version == '63' def test_eth_protocolVersion(w3): @@ -17,3 +18,13 @@ def test_eth_chain_id(w3): def test_eth_chainId(w3): with pytest.warns(DeprecationWarning): assert w3.eth.chainId == 61 + + +def test_set_chain_id(w3): + assert w3.eth.chain_id == 61 + + w3.eth.chain_id = 72 + assert w3.eth.chain_id == 72 + + w3.eth.chain_id = None + assert w3.eth.chain_id == 61 diff --git a/web3/eth.py b/web3/eth.py index 079f6bd1f5..ef1c134911 100644 --- a/web3/eth.py +++ b/web3/eth.py @@ -114,6 +114,7 @@ class BaseEth(Module): _default_account: Union[ChecksumAddress, Empty] = empty _default_block: BlockIdentifier = "latest" + _default_chain_id: Optional[int] = None gasPriceStrategy = None _gas_price: Method[Callable[[], Wei]] = Method( @@ -629,7 +630,14 @@ def blockNumber(self) -> BlockNumber: @property def chain_id(self) -> int: - return self._chain_id() + if self._default_chain_id is None: + return self._chain_id() + else: + return self._default_chain_id + + @chain_id.setter + def chain_id(self, value: int) -> None: + self._default_chain_id = value @property def chainId(self) -> int: From 5cf1fb7b84b590baa9b98a79d04e67b1554349a5 Mon Sep 17 00:00:00 2001 From: Mikko Ohtamaa Date: Thu, 10 Mar 2022 00:21:07 +0100 Subject: [PATCH 18/57] An example how to manage local private key using env (#2380) * An example how to manage local private key using env How to manage private keys using environment variable, how to generate them, and some security warnings. * Fix extra period Inserted by the editor? * add content tweaks and newsfragment Co-authored-by: Marc Garreau --- docs/web3.eth.account.rst | 55 +++++++++++++++++++++++++++++++++++++- newsfragments/2380.doc.rst | 1 + 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 newsfragments/2380.doc.rst diff --git a/docs/web3.eth.account.rst b/docs/web3.eth.account.rst index 60a25839f2..a331c3b733 100644 --- a/docs/web3.eth.account.rst +++ b/docs/web3.eth.account.rst @@ -39,7 +39,7 @@ Hosted Private Key not your Ether" in the wise words of Andreas Antonopoulos. Some Common Uses for Local Private Keys -------------------------------------------- +--------------------------------------- A very common reason to work with local private keys is to interact with a hosted node. @@ -55,6 +55,59 @@ Using private keys usually involves ``w3.eth.account`` in one way or another. Re or see a full list of things you can do in the docs for :class:`eth_account.Account `. +Read a private key from an environment variable +----------------------------------------------- + +In this example we pass the private key to our Python application in an +`environment variable `_. +This private key is then added to the transaction signing keychain +with ``Signing`` middleware. + +If unfamiliar, note that you can `export your private keys from Metamask and other wallets `_. + +.. warning :: + + - **Never** share your private keys. + - **Never** put your private keys in source code. + - **Never** commit private keys to a Git repository. + +Example ``account_test_script.py`` + +.. code-block:: python + + import os + from eth_account import Account + from eth_account.signers.local import LocalAccount + from web3.auto import w3 + from web3.middleware import construct_sign_and_send_raw_middleware + + private_key = os.environ.get("PRIVATE_KEY") + assert private_key is not None, "You must set PRIVATE_KEY environment variable" + assert private_key.startswith("0x"), "Private key must start with 0x hex prefix" + + account: LocalAccount = Account.from_key(private_key) + w3.middleware_onion.add(construct_sign_and_send_raw_middleware(account)) + + print(f"Your hot wallet address is {account.address}") + +Example how to run this in UNIX shell: + +.. code-block:: shell + + # Generate a new 256-bit random integer using openssl UNIX command that acts as a private key. + # You can also do: + # python -c "from web3 import Web3; w3 = Web3(); acc = w3.eth.account.create(); print(f'private key={w3.toHex(acc.key)}, account={acc.address}')" + # Store this in a safe place, like in your password manager. + export PRIVATE_KEY=0x`openssl rand -hex 32` + + # Run our script + python account_test_script.py + +This will print:: + + Your hot wallet address is 0x27C8F899bb69E1501BBB96d09d7477a2a7518918 + + .. _extract_geth_pk: Extract private key from geth keyfile diff --git a/newsfragments/2380.doc.rst b/newsfragments/2380.doc.rst new file mode 100644 index 0000000000..6baf4bb2d6 --- /dev/null +++ b/newsfragments/2380.doc.rst @@ -0,0 +1 @@ +Document reading private keys from environment variables From b9d99fc40114938d39b26e726ddc09a8b4307998 Mon Sep 17 00:00:00 2001 From: Harmouch101 Date: Wed, 2 Mar 2022 20:19:05 +0200 Subject: [PATCH 19/57] :broom: clean python2 syntax. Signed-off-by: Harmouch101 --- docs/conf.py | 16 ++++++++-------- docs/examples.rst | 15 +++++---------- ens/main.py | 15 +++++++-------- ens/utils.py | 2 +- tests/core/contracts/conftest.py | 2 +- .../test_contract_ambiguous_functions.py | 2 +- .../contracts/test_contract_call_interface.py | 2 +- tests/core/pm-module/test_ens_integration.py | 2 +- tests/core/providers/test_auto_provider.py | 8 ++++---- tests/core/utilities/test_formatters.py | 2 +- tests/ens/conftest.py | 2 +- web3/_utils/blocks.py | 2 +- web3/_utils/decorators.py | 2 +- web3/_utils/empty.py | 3 --- web3/_utils/encoding.py | 6 +++--- web3/_utils/ens.py | 2 +- web3/_utils/method_formatters.py | 6 ++---- web3/_utils/module_testing/eth_module.py | 4 ++-- web3/_utils/normalizers.py | 17 ++++++++--------- web3/_utils/rpc_abi.py | 2 +- web3/_utils/transactions.py | 2 +- web3/_utils/validation.py | 2 +- web3/auto/infura/endpoints.py | 8 ++++---- web3/contract.py | 12 ++++++------ web3/datastructures.py | 10 +++------- web3/exceptions.py | 8 +++++--- web3/main.py | 11 +++++------ web3/manager.py | 4 ++-- web3/middleware/validation.py | 17 ++++++----------- web3/providers/async_rpc.py | 8 +++----- web3/providers/auto.py | 6 ++---- web3/providers/ipc.py | 8 +++++--- web3/providers/rpc.py | 8 +++----- web3/providers/websocket.py | 4 ++-- web3/tools/pytest_ethereum/linker.py | 7 +++---- 35 files changed, 101 insertions(+), 126 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index fd50c0c203..a4f5ec9031 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -52,8 +52,8 @@ master_doc = 'index' # General information about the project. -project = u'Web3.py' -copyright = u'2018, Piper Merriam, Jason Carver' +project = 'Web3.py' +copyright = '2018, Piper Merriam, Jason Carver' __version__ = setup_version # The version info for the project you're documenting, acts as replacement for @@ -222,8 +222,8 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - ('index', 'Populus.tex', u'Populus Documentation', - u'Piper Merriam', 'manual'), + ('index', 'Populus.tex', 'Populus Documentation', + 'Piper Merriam', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -252,8 +252,8 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'web3', u'Web3.py Documentation', - [u'Piper Merriam'], 1) + ('index', 'web3', 'Web3.py Documentation', + ['Piper Merriam'], 1) ] # If true, show URL addresses after external links. @@ -266,8 +266,8 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'Web3.py', u'Web3.py Documentation', - u'Piper Merriam', 'Web3.py', 'Backend agnostic Ethereum client interactions.', + ('index', 'Web3.py', 'Web3.py Documentation', + 'Piper Merriam', 'Web3.py', 'Backend agnostic Ethereum client interactions.', 'Miscellaneous'), ] diff --git a/docs/examples.rst b/docs/examples.rst index e54ed70d43..83d41a6ee7 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -992,7 +992,7 @@ The script can be run with: ``python ./eventscanner.py `` # from our in-memory cache block_when = get_block_when(block_number) - logger.debug("Processing event %s, block:%d count:%d", evt["event"], evt["blockNumber"]) + logger.debug(f"Processing event {evt["event"]}, block: {evt["blockNumber"]} count: {evt["blockNumber"]}") processed = self.state.process_event(block_when, evt) all_processed.append(processed) @@ -1064,8 +1064,8 @@ The script can be run with: ``python ./eventscanner.py `` # Print some diagnostics to logs to try to fiddle with real world JSON-RPC API performance estimated_end_block = current_block + chunk_size logger.debug( - "Scanning token transfers for blocks: %d - %d, chunk size %d, last chunk scan took %f, last logs found %d", - current_block, estimated_end_block, chunk_size, last_scan_duration, last_logs_found) + f"Scanning token transfers for blocks: {current_block} - {estimated_end_block}, chunk size {chunk_size}, last chunk scan took {last_scan_duration}, last logs found {last_logs_found}" + ) start = time.time() actual_end_block, end_block_timestamp, new_entries = self.scan_chunk(current_block, estimated_end_block) @@ -1116,12 +1116,7 @@ The script can be run with: ``python ./eventscanner.py `` if i < retries - 1: # Give some more verbose info than the default middleware logger.warning( - "Retrying events for block range %d - %d (%d) failed with %s, retrying in %s seconds", - start_block, - end_block, - end_block-start_block, - e, - delay) + f"Retrying events for block range {start_block} - {end_block} ({end_block-start_block}) failed with {e} , retrying in {delay} seconds") # Decrease the `eth_getBlocks` range end_block = start_block + ((end_block - start_block) // 2) # Let the JSON-RPC to recover e.g. from restart @@ -1175,7 +1170,7 @@ The script can be run with: ``python ./eventscanner.py `` toBlock=to_block ) - logger.debug("Querying eth_getLogs with the following parameters: %s", event_filter_params) + logger.debug(f"Querying eth_getLogs with the following parameters: {event_filter_params}") # Call JSON-RPC API on your Ethereum node. # get_logs() returns raw AttributedDict entries diff --git a/ens/main.py b/ens/main.py index 928a3106a4..d38fc3cedb 100644 --- a/ens/main.py +++ b/ens/main.py @@ -227,10 +227,10 @@ def setup_name( address = resolved elif resolved and address != resolved and resolved != EMPTY_ADDR_HEX: raise AddressMismatch( - "Could not set address %r to point to name, because the name resolves to %r. " - "To change the name for an existing address, call setup_address() first." % ( - address, resolved - ) + f"Could not set address {address!r} to point to name, " + f"because the name resolves to {resolved!r}. " + "To change the name for an existing address, call " + "setup_address() first." ) if is_none_or_zero_address(address): address = self.owner(name) @@ -335,9 +335,8 @@ def _assert_control(self, account: ChecksumAddress, name: str, parent_owned: Optional[str] = None) -> None: if not address_in(account, self.w3.eth.accounts): raise UnauthorizedError( - "in order to modify %r, you must control account %r, which owns %r" % ( - name, account, parent_owned or name - ) + f"in order to modify {name!r}, you must control account" + f" {account!r}, which owns {parent_owned or name!r}" ) def _first_owner(self, name: str) -> Tuple[Optional[ChecksumAddress], Sequence[str], str]: @@ -374,7 +373,7 @@ def _claim_ownership( label_to_hash(label), owner ).transact(transact) - owned = "%s.%s" % (label, owned) + owned = f"{label}.{owned}" def _set_resolver( self, diff --git a/ens/utils.py b/ens/utils.py index 43c223b5e2..33fda9ee29 100644 --- a/ens/utils.py +++ b/ens/utils.py @@ -140,7 +140,7 @@ def sha3_text(val: Union[str, bytes]) -> HexBytes: def label_to_hash(label: str) -> HexBytes: label = normalize_name(label) if '.' in label: - raise ValueError("Cannot generate hash for label %r with a '.'" % label) + raise ValueError(f"Cannot generate hash for label {label!r} with a '.'") return Web3().keccak(text=label) diff --git a/tests/core/contracts/conftest.py b/tests/core/contracts/conftest.py index 2941572be8..91d01d5875 100644 --- a/tests/core/contracts/conftest.py +++ b/tests/core/contracts/conftest.py @@ -1010,7 +1010,7 @@ def invoke_contract(api_call_desig='call', tx_params={}): allowable_call_desig = ['call', 'transact', 'estimateGas', 'buildTransaction'] if api_call_desig not in allowable_call_desig: - raise ValueError("allowable_invoke_method must be one of: %s" % allowable_call_desig) + raise ValueError(f"allowable_invoke_method must be one of: {allowable_call_desig}") function = contract.functions[contract_function] result = getattr(function(*func_args, **func_kwargs), api_call_desig)(tx_params) diff --git a/tests/core/contracts/test_contract_ambiguous_functions.py b/tests/core/contracts/test_contract_ambiguous_functions.py index 69e15e4ff6..8f6c0b5ae2 100644 --- a/tests/core/contracts/test_contract_ambiguous_functions.py +++ b/tests/core/contracts/test_contract_ambiguous_functions.py @@ -153,7 +153,7 @@ def test_find_or_get_functions_by_type(w3, method, args, repr_func, expected): ( 'get_function_by_selector', (b'\x00' * (4 + 1), ), - r'expected value of size 4 bytes. Got: %s bytes' % (4 + 1), + f'expected value of size 4 bytes. Got: {(4 + 1)} bytes', ValueError ), ( diff --git a/tests/core/contracts/test_contract_call_interface.py b/tests/core/contracts/test_contract_call_interface.py index 6b1c1809b8..4e67c7d1cd 100644 --- a/tests/core/contracts/test_contract_call_interface.py +++ b/tests/core/contracts/test_contract_call_interface.py @@ -726,7 +726,7 @@ def test_reflect_fixed_value(fixed_reflection_contract, function, value): ('reflect_short_u', Decimal('0.01'), "no matching argument types"), ( 'reflect_short_u', - Decimal('1e-%d' % (DEFAULT_DECIMALS + 1)), + Decimal(f'1e-{DEFAULT_DECIMALS + 1}'), "no matching argument types", ), ('reflect_short_u', Decimal('25.4' + '9' * DEFAULT_DECIMALS), "no matching argument types"), diff --git a/tests/core/pm-module/test_ens_integration.py b/tests/core/pm-module/test_ens_integration.py index c6bd38b519..76dc64a1d6 100644 --- a/tests/core/pm-module/test_ens_integration.py +++ b/tests/core/pm-module/test_ens_integration.py @@ -20,7 +20,7 @@ def bytes32(val): if isinstance(val, int): result = to_bytes(val) else: - raise TypeError('val %r could not be converted to bytes') + raise TypeError(f'{val!r} could not be converted to bytes') return result.rjust(32, b'\0') diff --git a/tests/core/providers/test_auto_provider.py b/tests/core/providers/test_auto_provider.py index c0e30295f6..1647d5d502 100644 --- a/tests/core/providers/test_auto_provider.py +++ b/tests/core/providers/test_auto_provider.py @@ -108,7 +108,7 @@ def test_web3_auto_infura(monkeypatch, caplog, environ_name): w3 = infura.w3 assert isinstance(w3.provider, HTTPProvider) - expected_url = 'https://%s/v3/%s' % (infura.INFURA_MAINNET_DOMAIN, API_KEY) + expected_url = f'https://{infura.INFURA_MAINNET_DOMAIN}/v3/{API_KEY}' assert getattr(w3.provider, 'endpoint_uri') == expected_url @@ -117,7 +117,7 @@ def test_web3_auto_infura_websocket_default(monkeypatch, caplog, environ_name): monkeypatch.setenv('WEB3_INFURA_SCHEME', 'wss') API_KEY = 'aoeuhtns' monkeypatch.setenv(environ_name, API_KEY) - expected_url = 'wss://%s/ws/v3/%s' % (infura.INFURA_MAINNET_DOMAIN, API_KEY) + expected_url = f'wss://{infura.INFURA_MAINNET_DOMAIN}/ws/v3/{API_KEY}' importlib.reload(infura) assert len(caplog.record_tuples) == 0 @@ -145,7 +145,7 @@ def test_web3_auto_infura_websocket_with_secret(monkeypatch, caplog, environ_nam w3 = infura.w3 assert isinstance(w3.provider, WebsocketProvider) - expected_url = 'wss://:secret@%s/ws/v3/test' % (infura.INFURA_MAINNET_DOMAIN) + expected_url = f'wss://:secret@{infura.INFURA_MAINNET_DOMAIN}/ws/v3/test' assert getattr(w3.provider, 'endpoint_uri') == expected_url @@ -159,7 +159,7 @@ def test_web3_auto_infura_with_secret(monkeypatch, caplog, environ_name): w3 = infura.w3 assert isinstance(w3.provider, HTTPProvider) - expected_url = 'https://%s/v3/test' % (infura.INFURA_MAINNET_DOMAIN) + expected_url = f'https://{infura.INFURA_MAINNET_DOMAIN}/v3/test' expected_auth_value = ('', 'secret') assert getattr(w3.provider, 'endpoint_uri') == expected_url assert w3.provider.get_request_kwargs()['auth'] == expected_auth_value diff --git a/tests/core/utilities/test_formatters.py b/tests/core/utilities/test_formatters.py index 649578f7ce..45a56772f8 100644 --- a/tests/core/utilities/test_formatters.py +++ b/tests/core/utilities/test_formatters.py @@ -18,7 +18,7 @@ def square_int(x): return x -@pytest.mark.parametrize('non_collection', [1, 'abc', u'def', True, None]) +@pytest.mark.parametrize('non_collection', [1, 'abc', 'def', True, None]) def test_map_collection_on_non_collection(non_collection): assert map_collection(lambda x: x + 2, non_collection) == non_collection diff --git a/tests/ens/conftest.py b/tests/ens/conftest.py index 7a3d2044dd..a11c5ff7dd 100644 --- a/tests/ens/conftest.py +++ b/tests/ens/conftest.py @@ -34,7 +34,7 @@ def bytes32(val): if isinstance(val, int): result = Web3.toBytes(val) else: - raise TypeError('val %r could not be converted to bytes') + raise TypeError(f'{val!r} could not be converted to bytes') if len(result) < 32: return result.rjust(32, b'\0') else: diff --git a/web3/_utils/blocks.py b/web3/_utils/blocks.py index ac875f3c03..63ff37328c 100644 --- a/web3/_utils/blocks.py +++ b/web3/_utils/blocks.py @@ -31,7 +31,7 @@ def is_predefined_block_number(value: Any) -> bool: elif is_integer(value): return False else: - raise TypeError("unrecognized block reference: %r" % value) + raise TypeError(f"unrecognized block reference: {value!r}") return value_text in {"latest", "pending", "earliest"} diff --git a/web3/_utils/decorators.py b/web3/_utils/decorators.py index 63e14d9506..d93ff99277 100644 --- a/web3/_utils/decorators.py +++ b/web3/_utils/decorators.py @@ -24,7 +24,7 @@ def wrapped(*args: Any) -> Any: thread_id = threading.get_ident() thread_local_args = (thread_id,) + arg_instances if thread_local_args in to_wrap.__already_called: # type: ignore - raise ValueError('Recursively called %s with %r' % (to_wrap, args)) + raise ValueError(f'Recursively called {to_wrap} with {args!r}') to_wrap.__already_called[thread_local_args] = True # type: ignore try: wrapped_val = to_wrap(*args) diff --git a/web3/_utils/empty.py b/web3/_utils/empty.py index e6d299b3d6..1fb94fda60 100644 --- a/web3/_utils/empty.py +++ b/web3/_utils/empty.py @@ -7,8 +7,5 @@ class Empty: def __bool__(self) -> Literal[False]: return False - def __nonzero__(self) -> Literal[False]: - return False - empty = Empty() diff --git a/web3/_utils/encoding.py b/web3/_utils/encoding.py index 085cbf1378..5b9a4a4a56 100644 --- a/web3/_utils/encoding.py +++ b/web3/_utils/encoding.py @@ -191,14 +191,14 @@ def _json_mapping_errors(self, mapping: Dict[Any, Any]) -> Iterable[str]: try: self._friendly_json_encode(val) except TypeError as exc: - yield "%r: because (%s)" % (key, exc) + yield f"{key!r}: because ({exc})" def _json_list_errors(self, iterable: Iterable[Any]) -> Iterable[str]: for index, element in enumerate(iterable): try: self._friendly_json_encode(element) except TypeError as exc: - yield "%d: because (%s)" % (index, exc) + yield f"{index}: because ({exc})" def _friendly_json_encode(self, obj: Dict[Any, Any], cls: Optional[Type[json.JSONEncoder]] = None) -> str: @@ -238,7 +238,7 @@ def to_4byte_hex(hex_or_str_or_bytes: Union[HexStr, str, bytes, int]) -> HexStr: byte_str = hexstr_if_str(to_bytes, hex_or_str_or_bytes) if len(byte_str) > 4: raise ValueError( - 'expected value of size 4 bytes. Got: %d bytes' % len(byte_str) + f'expected value of size 4 bytes. Got: {len(byte_str)} bytes' ) hex_str = encode_hex(byte_str) return pad_hex(hex_str, size_of_4bytes) diff --git a/web3/_utils/ens.py b/web3/_utils/ens.py index f924d306d7..c5ba63deb5 100644 --- a/web3/_utils/ens.py +++ b/web3/_utils/ens.py @@ -46,7 +46,7 @@ def validate_name_has_address(ens: ENS, name: str) -> ChecksumAddress: if addr: return addr else: - raise NameNotFound("Could not find address for name %r" % name) + raise NameNotFound(f"Could not find address for name {name!r}") class StaticENS: diff --git a/web3/_utils/method_formatters.py b/web3/_utils/method_formatters.py index 5105b5f0e0..7a1ff17a7b 100644 --- a/web3/_utils/method_formatters.py +++ b/web3/_utils/method_formatters.py @@ -123,7 +123,7 @@ def to_hexbytes( if isinstance(val, (str, int, bytes)): result = HexBytes(val) else: - raise TypeError("Cannot convert %r to HexBytes" % val) + raise TypeError(f"Cannot convert {val!r} to HexBytes") extra_bytes = len(result) - num_bytes if extra_bytes == 0 or (variable_length and extra_bytes < 0): @@ -132,9 +132,7 @@ def to_hexbytes( return HexBytes(result[extra_bytes:]) else: raise ValueError( - "The value %r is %d bytes, but should be %d" % ( - result, len(result), num_bytes - ) + f"The value {result!r} is {len(result)} bytes, but should be {num_bytes}" ) diff --git a/web3/_utils/module_testing/eth_module.py b/web3/_utils/module_testing/eth_module.py index a2e4b66ea9..f2fa5bee92 100644 --- a/web3/_utils/module_testing/eth_module.py +++ b/web3/_utils/module_testing/eth_module.py @@ -2739,7 +2739,7 @@ def test_eth_getTransactionByHash_contract_creation( ) -> None: transaction = w3.eth.get_transaction(math_contract_deploy_txn_hash) assert is_dict(transaction) - assert transaction['to'] is None, "to field is %r" % transaction['to'] + assert transaction['to'] is None, f"to field is {transaction['to']!r}" def test_eth_getTransactionByBlockHashAndIndex( self, w3: "Web3", block_with_txn: BlockData, mined_txn_hash: HexStr @@ -3140,7 +3140,7 @@ def test_eth_call_old_contract_state( assert default_call_result == 0 if pending_call_result != 1: - raise AssertionError("pending call result was %d instead of 1" % pending_call_result) + raise AssertionError(f"pending call result was {pending_call_result} instead of 1") def test_eth_uninstallFilter_deprecated(self, w3: "Web3") -> None: filter = w3.eth.filter({}) diff --git a/web3/_utils/normalizers.py b/web3/_utils/normalizers.py index fe0b07dd7d..61f5f07414 100644 --- a/web3/_utils/normalizers.py +++ b/web3/_utils/normalizers.py @@ -146,9 +146,8 @@ def abi_bytes_to_hex( num_bytes = abi_type.sub if len(bytes_data) > num_bytes: raise ValueError( - "This value was expected to be at most %d bytes, but instead was %d: %r" % ( - (num_bytes, len(bytes_data), data) - ) + f"This value was expected to be at most {num_bytes} bytes, " + f"but instead was {len(bytes_data)}: {data!r}" ) padded = bytes_data.ljust(num_bytes, b'\0') @@ -204,18 +203,18 @@ def abi_ens_resolver(w3: "Web3", type_str: TypeStr, val: Any) -> Tuple[TypeStr, if type_str == 'address' and is_ens_name(val): if w3 is None: raise InvalidAddress( - "Could not look up name %r because no web3" - " connection available" % (val) + f"Could not look up name {val!r} because no web3" + " connection available" ) elif w3.ens is None: raise InvalidAddress( - "Could not look up name %r because ENS is" - " set to None" % (val) + f"Could not look up name {val!r} because ENS is" + " set to None" ) elif int(w3.net.version) != 1 and not isinstance(w3.ens, StaticENS): raise InvalidAddress( - "Could not look up name %r because web3 is" - " not connected to mainnet" % (val) + f"Could not look up name {val!r} because web3 is" + " not connected to mainnet" ) else: return type_str, validate_name_has_address(w3.ens, val) diff --git a/web3/_utils/rpc_abi.py b/web3/_utils/rpc_abi.py index 87b29e41bb..641497ef42 100644 --- a/web3/_utils/rpc_abi.py +++ b/web3/_utils/rpc_abi.py @@ -241,4 +241,4 @@ def abi_request_formatters( single_dict_formatter = apply_abi_formatters_to_dict(normalizers, abi_types) yield method, apply_formatter_at_index(single_dict_formatter, 0) else: - raise TypeError("ABI definitions must be a list or dictionary, got %r" % abi_types) + raise TypeError(f"ABI definitions must be a list or dictionary, got {abi_types!r}") diff --git a/web3/_utils/transactions.py b/web3/_utils/transactions.py index 8d9ca470df..638cb89d50 100644 --- a/web3/_utils/transactions.py +++ b/web3/_utils/transactions.py @@ -109,7 +109,7 @@ def fill_transaction_defaults(w3: "Web3", transaction: TxParams) -> TxParams: if callable(default_getter): if w3 is None: - raise ValueError("You must specify a '%s' value in the transaction" % key) + raise ValueError(f"You must specify a '{key}' value in the transaction") default_val = default_getter(w3, transaction) else: default_val = default_getter diff --git a/web3/_utils/validation.py b/web3/_utils/validation.py index 65fcb9f1c0..d59e788d61 100644 --- a/web3/_utils/validation.py +++ b/web3/_utils/validation.py @@ -205,5 +205,5 @@ def assert_one_val(*args: Any, **kwargs: Any) -> None: if not has_one_val(*args, **kwargs): raise TypeError( "Exactly one of the passed values can be specified. " - "Instead, values were: %r, %r" % (args, kwargs) + f"Instead, values were: {args!r}, {kwargs!r}" ) diff --git a/web3/auto/infura/endpoints.py b/web3/auto/infura/endpoints.py index c8de5c78d2..8531e3c023 100644 --- a/web3/auto/infura/endpoints.py +++ b/web3/auto/infura/endpoints.py @@ -56,10 +56,10 @@ def build_infura_url(domain: str) -> URI: secret = load_secret() if scheme == WEBSOCKET_SCHEME and secret != '': - return URI("%s://:%s@%s/ws/v3/%s" % (scheme, secret, domain, key)) + return URI(f"{scheme}://:{secret}@{domain}/ws/v3/{key}") elif scheme == WEBSOCKET_SCHEME and secret == '': - return URI("%s://%s/ws/v3/%s" % (scheme, domain, key)) + return URI(f"{scheme}://{domain}/ws/v3/{key}") elif scheme == HTTP_SCHEME: - return URI("%s://%s/v3/%s" % (scheme, domain, key)) + return URI(f"{scheme}://{domain}/v3/{key}") else: - raise ValidationError("Cannot connect to Infura with scheme %r" % scheme) + raise ValidationError(f"Cannot connect to Infura with scheme {scheme!r}") diff --git a/web3/contract.py b/web3/contract.py index 38e98b4152..c20d0e2156 100644 --- a/web3/contract.py +++ b/web3/contract.py @@ -425,7 +425,7 @@ def get_function_by_signature(self, signature: str) -> 'ContractFunction': if ' ' in signature: raise ValueError( 'Function signature should not contain any spaces. ' - 'Found spaces in input: %s' % signature + f'Found spaces in input: {signature}' ) def callable_check(fn_abi: ABIFunction) -> bool: @@ -715,9 +715,9 @@ def __prepared_function(self, *args: Any, **kwargs: Any) -> 'ContractFunction': modifier, modifier_dict = kwargs.popitem() if modifier not in self.ALLOWED_MODIFIERS: raise TypeError( - "The only allowed keyword arguments are: %s" % self.ALLOWED_MODIFIERS) + f"The only allowed keyword arguments are: {self.ALLOWED_MODIFIERS}") else: - raise TypeError("Use up to one keyword argument, one of: %s" % self.ALLOWED_MODIFIERS) + raise TypeError(f"Use up to one keyword argument, one of: {self.ALLOWED_MODIFIERS}") return getattr(self._function(*args), modifier)(modifier_dict) @@ -1099,11 +1099,11 @@ def factory(cls, class_name: str, **kwargs: Any) -> 'ContractFunction': def __repr__(self) -> str: if self.abi: - _repr = '' - return '' % self.fn_name + return f'' class ContractEvent: diff --git a/web3/datastructures.py b/web3/datastructures.py index 79f6cd59ec..27b2e73bc2 100644 --- a/web3/datastructures.py +++ b/web3/datastructures.py @@ -57,7 +57,7 @@ def __len__(self) -> int: return len(self.__dict__) def __repr__(self) -> str: - return self.__class__.__name__ + "(%r)" % self.__dict__ + return self.__class__.__name__ + f"({self.__dict__!r})" def _repr_pretty_(self, builder: Any, cycle: bool) -> None: """ @@ -158,12 +158,8 @@ def inject(self, element: TValue, name: Optional[TKey] = None, raise TypeError("The layer for insertion must be an int.") elif layer != 0 and layer != len(self._queue): raise NotImplementedError( - "You can only insert to the beginning or end of a %s, currently. " - "You tried to insert to %d, but only 0 and %d are permitted. " % ( - type(self), - layer, - len(self._queue), - ) + f"You can only insert to the beginning or end of a {type(self)}, currently. " + f"You tried to insert to {layer}, but only 0 and {len(self._queue)} are permitted. " ) self.add(element, name=name) diff --git a/web3/exceptions.py b/web3/exceptions.py index 3390275151..b7d88d1b59 100644 --- a/web3/exceptions.py +++ b/web3/exceptions.py @@ -52,9 +52,11 @@ class StaleBlockchain(Exception): def __init__(self, block: BlockData, allowable_delay: int) -> None: last_block_date = datetime.datetime.fromtimestamp(block["timestamp"]).strftime('%c') message = ( - "The latest block, #%d, is %d seconds old, but is only allowed to be %d s old. " - "The date of the most recent block is %s. Continue syncing and try again..." % - (block["number"], time.time() - block["timestamp"], allowable_delay, last_block_date) + f"The latest block, #{block['number']}, is " + f"{time.time() - block['timestamp']} seconds old, but is only " + f"allowed to be {allowable_delay} s old. " + f"The date of the most recent block is {last_block_date}. Continue " + "syncing and try again..." ) super().__init__(message, block, allowable_delay) diff --git a/web3/main.py b/web3/main.py index acbac1b9a3..5395895683 100644 --- a/web3/main.py +++ b/web3/main.py @@ -292,12 +292,11 @@ def keccak(primitive: Optional[Primitives] = None, text: Optional[str] = None, return eth_utils_keccak(input_bytes) raise TypeError( - "You called keccak with first arg %r and keywords %r. You must call it with one of " - "these approaches: keccak(text='txt'), keccak(hexstr='0x747874'), " - "keccak(b'\\x74\\x78\\x74'), or keccak(0x747874)." % ( - primitive, - {'text': text, 'hexstr': hexstr} - ) + f"You called keccak with first arg {primitive!r} and keywords " + f"{{'text': {text!r}, 'hexstr': {hexstr!r}}}. You must call it " + "with one of these approaches: keccak(text='txt'), keccak " + "(hexstr='0x747874'), keccak(b'\\x74\\x78\\x74'), or kecca " + "(0x747874)." ) @combomethod diff --git a/web3/manager.py b/web3/manager.py index 1594c4dd6f..db5c6085b4 100644 --- a/web3/manager.py +++ b/web3/manager.py @@ -146,7 +146,7 @@ def _make_request( request_func = self.provider.request_func( self.w3, self.middleware_onion) - self.logger.debug("Making request. Method: %s", method) + self.logger.debug(f"Making request. Method: {method}") return request_func(method, params) async def _coro_make_request( @@ -156,7 +156,7 @@ async def _coro_make_request( request_func = await self.provider.request_func( # type: ignore self.w3, self.middleware_onion) - self.logger.debug("Making request. Method: %s", method) + self.logger.debug(f"Making request. Method: {method}") return await request_func(method, params) @staticmethod diff --git a/web3/middleware/validation.py b/web3/middleware/validation.py index 5fafce175b..23872858ef 100644 --- a/web3/middleware/validation.py +++ b/web3/middleware/validation.py @@ -59,11 +59,8 @@ def _validate_chain_id(web3_chain_id: int, chain_id: int) -> int: return chain_id else: raise ValidationError( - "The transaction declared chain ID %r, " - "but the connected node is on %r" % ( - chain_id, - web3_chain_id, - ) + f"The transaction declared chain ID {chain_id!r}, " + f"but the connected node is on {web3_chain_id!r}" ) @@ -73,13 +70,11 @@ def _check_extradata_length(val: Any) -> Any: result = HexBytes(val) if len(result) > MAX_EXTRADATA_LENGTH: raise ExtraDataLengthError( - "The field extraData is %d bytes, but should be %d. " - "It is quite likely that you are connected to a POA chain. " - "Refer to " + f"The field extraData is {len(result)} bytes, but should be " + f"{MAX_EXTRADATA_LENGTH}. It is quite likely that you are " + "connected to a POA chain. Refer to " "http://web3py.readthedocs.io/en/stable/middleware.html#geth-style-proof-of-authority " - "for more details. The full extraData is: %r" % ( - len(result), MAX_EXTRADATA_LENGTH, result - ) + f"for more details. The full extraData is: {result!r}" ) return val diff --git a/web3/providers/async_rpc.py b/web3/providers/async_rpc.py index d3229c71de..dc80bfdedf 100644 --- a/web3/providers/async_rpc.py +++ b/web3/providers/async_rpc.py @@ -74,8 +74,7 @@ def get_request_headers(self) -> Dict[str, str]: } async def make_request(self, method: RPCEndpoint, params: Any) -> RPCResponse: - self.logger.debug("Making request HTTP. URI: %s, Method: %s", - self.endpoint_uri, method) + self.logger.debug(f"Making request HTTP. URI: {self.endpoint_uri}, Method: {method}") request_data = self.encode_rpc_request(method, params) raw_response = await async_make_post_request( self.endpoint_uri, @@ -83,7 +82,6 @@ async def make_request(self, method: RPCEndpoint, params: Any) -> RPCResponse: **self.get_request_kwargs() ) response = self.decode_rpc_response(raw_response) - self.logger.debug("Getting response HTTP. URI: %s, " - "Method: %s, Response: %s", - self.endpoint_uri, method, response) + self.logger.debug(f"Getting response HTTP. URI: {self.endpoint_uri}, " + f"Method: {method}, Response: {response}") return response diff --git a/web3/providers/auto.py b/web3/providers/auto.py index 9d351b3aec..9bc49b893b 100644 --- a/web3/providers/auto.py +++ b/web3/providers/auto.py @@ -55,10 +55,8 @@ def load_provider_from_uri( return WebsocketProvider(uri_string) else: raise NotImplementedError( - 'Web3 does not know how to connect to scheme %r in %r' % ( - uri.scheme, - uri_string, - ) + f'Web3 does not know how to connect to scheme {uri.scheme!r} ' + f'in {uri_string!r}' ) diff --git a/web3/providers/ipc.py b/web3/providers/ipc.py index 45faf63b61..a166aabd80 100644 --- a/web3/providers/ipc.py +++ b/web3/providers/ipc.py @@ -52,7 +52,10 @@ def __init__(self, ipc_path: str) -> None: def __enter__(self) -> socket.socket: if not self.ipc_path: - raise FileNotFoundError("cannot connect to IPC socket at path: %r" % self.ipc_path) + raise FileNotFoundError( + "cannot connect to IPC socket at path: " + f"{self.ipc_path!r}" + ) if not self.sock: self.sock = self._open() @@ -231,8 +234,7 @@ def __str__(self) -> str: return f"<{self.__class__.__name__} {self.ipc_path}>" def make_request(self, method: RPCEndpoint, params: Any) -> RPCResponse: - self.logger.debug("Making request IPC. Path: %s, Method: %s", - self.ipc_path, method) + self.logger.debug(f"Making request IPC. Path: {self.ipc_path}, Method: {method}") request = self.encode_rpc_request(method, params) with self._lock, self._socket as sock: diff --git a/web3/providers/rpc.py b/web3/providers/rpc.py index 0be744f71d..74c83eac7e 100644 --- a/web3/providers/rpc.py +++ b/web3/providers/rpc.py @@ -82,8 +82,7 @@ def get_request_headers(self) -> Dict[str, str]: } def make_request(self, method: RPCEndpoint, params: Any) -> RPCResponse: - self.logger.debug("Making request HTTP. URI: %s, Method: %s", - self.endpoint_uri, method) + self.logger.debug(f"Making request HTTP. URI: {self.endpoint_uri}, Method: {method}") request_data = self.encode_rpc_request(method, params) raw_response = make_post_request( self.endpoint_uri, @@ -91,7 +90,6 @@ def make_request(self, method: RPCEndpoint, params: Any) -> RPCResponse: **self.get_request_kwargs() ) response = self.decode_rpc_response(raw_response) - self.logger.debug("Getting response HTTP. URI: %s, " - "Method: %s, Response: %s", - self.endpoint_uri, method, response) + self.logger.debug(f"Getting response HTTP. URI: {self.endpoint_uri}, " + f"Method: {method}, Response: {response}") return response diff --git a/web3/providers/websocket.py b/web3/providers/websocket.py index e999d56d3f..ef486ff49c 100644 --- a/web3/providers/websocket.py +++ b/web3/providers/websocket.py @@ -133,8 +133,8 @@ async def coro_make_request(self, request_data: bytes) -> RPCResponse: ) def make_request(self, method: RPCEndpoint, params: Any) -> RPCResponse: - self.logger.debug("Making request WebSocket. URI: %s, " - "Method: %s", self.endpoint_uri, method) + self.logger.debug(f"Making request WebSocket. URI: {self.endpoint_uri}, " + f"Method: {method}") request_data = self.encode_rpc_request(method, params) future = asyncio.run_coroutine_threadsafe( self.coro_make_request(request_data), diff --git a/web3/tools/pytest_ethereum/linker.py b/web3/tools/pytest_ethereum/linker.py index c0804d0136..d7385ea857 100644 --- a/web3/tools/pytest_ethereum/linker.py +++ b/web3/tools/pytest_ethereum/linker.py @@ -82,7 +82,7 @@ def _deploy( manifest = insert_deployment( package, contract_name, deployment_data, latest_block_uri ) - logger.info("%s deployed." % contract_name) + logger.info(f"{contract_name} deployed.") return Package(manifest, package.w3) @@ -107,8 +107,7 @@ def link(contract: ContractName, linked_type: str, package: Package) -> Package: to_hex(linked_factory.bytecode), ) logger.info( - "%s linked to %s at address %s." - % (contract, linked_type, to_checksum_address(deployment_address)) + f"{contract} linked to {linked_type} at address {to_checksum_address(deployment_address)}." ) return Package(manifest, package.w3) @@ -120,5 +119,5 @@ def run_python(callback_fn: Callable[..., None], package: Package) -> Package: the contracts in the package. """ callback_fn(package) - logger.info("%s python function ran." % callback_fn.__name__) + logger.info(f"{callback_fn.__name__} python function ran.") return package From fb294c3be7c18a8f8bba620d224bdfd4549cca82 Mon Sep 17 00:00:00 2001 From: Harmouch101 Date: Wed, 2 Mar 2022 20:55:30 +0200 Subject: [PATCH 20/57] :memo: add newsfragment! Signed-off-by: Harmouch101 --- newsfragments/2372.misc.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 newsfragments/2372.misc.rst diff --git a/newsfragments/2372.misc.rst b/newsfragments/2372.misc.rst new file mode 100644 index 0000000000..85a5d056e1 --- /dev/null +++ b/newsfragments/2372.misc.rst @@ -0,0 +1 @@ +remove python 2 syntax. \ No newline at end of file From c5b413dafea7876dd049b4d66c807c47a152ddd0 Mon Sep 17 00:00:00 2001 From: Harmouch101 Date: Tue, 8 Mar 2022 18:43:51 +0200 Subject: [PATCH 21/57] :zap: update! Signed-off-by: Harmouch101 --- docs/v4_migration.rst | 4 +- docs/web3.eth.rst | 4 +- ethpm/contract.py | 12 ++--- ethpm/tools/builder.py | 2 +- ethpm/validation/manifest.py | 12 ++--- .../contracts/test_contract_call_interface.py | 6 +-- ...st_contract_method_to_argument_matching.py | 6 +-- .../test_filter_against_transaction_logs.py | 12 ++--- .../middleware/test_fixture_middleware.py | 5 +- .../test_simple_cache_middleware.py | 2 +- .../test_time_based_cache_middleware.py | 2 +- .../middleware/test_transaction_signing.py | 5 +- tests/core/providers/test_ipc_provider.py | 2 +- .../core/providers/test_websocket_provider.py | 4 +- .../test_abi_filtering_by_argument_name.py | 14 ++--- tests/ethpm/_utils/test_contract_utils.py | 10 ++-- tests/ethpm/validation/test_manifest.py | 8 +-- tests/integration/generate_fixtures/common.py | 14 +++-- .../generate_fixtures/go_ethereum.py | 7 +-- tests/integration/go_ethereum/conftest.py | 7 +-- .../go_ethereum/test_goethereum_http.py | 2 +- .../go_ethereum/test_goethereum_ws.py | 2 +- web3/_utils/abi.py | 52 ++++++++----------- web3/_utils/async_transactions.py | 4 +- web3/_utils/blocks.py | 3 +- web3/_utils/caching.py | 8 +-- web3/_utils/contracts.py | 25 ++++----- web3/_utils/datatypes.py | 6 +-- web3/_utils/encoding.py | 20 ++++--- web3/_utils/events.py | 10 ++-- web3/_utils/filters.py | 2 +- web3/_utils/http.py | 5 +- web3/_utils/math.py | 5 +- .../go_ethereum_admin_module.py | 2 +- web3/_utils/rpc_abi.py | 2 +- web3/_utils/threads.py | 2 +- web3/_utils/transactions.py | 6 +-- web3/_utils/validation.py | 17 +++--- web3/contract.py | 23 ++++---- web3/main.py | 2 +- web3/manager.py | 2 +- web3/middleware/filter.py | 8 +-- web3/middleware/signing.py | 2 +- web3/middleware/stalecheck.py | 4 +- web3/providers/async_rpc.py | 2 +- web3/providers/auto.py | 7 ++- web3/providers/eth_tester/defaults.py | 8 ++- web3/providers/ipc.py | 8 +-- web3/providers/rpc.py | 2 +- web3/providers/websocket.py | 8 +-- web3/tools/benchmark/node.py | 2 +- 51 files changed, 180 insertions(+), 209 deletions(-) diff --git a/docs/v4_migration.rst b/docs/v4_migration.rst index 14ca20f2e1..f7c2a4ceed 100644 --- a/docs/v4_migration.rst +++ b/docs/v4_migration.rst @@ -68,7 +68,7 @@ printing out new block hashes as they appear: .. code-block:: python >>> def new_block_callback(block_hash): - ... print "New Block: {0}".format(block_hash) + ... print(f"New Block: {block_hash}") ... >>> new_block_filter = web3.eth.filter('latest') >>> new_block_filter.watch(new_block_callback) @@ -79,7 +79,7 @@ In v4, that same logic: >>> new_block_filter = web3.eth.filter('latest') >>> for block_hash in new_block_filter.get_new_entries(): - ... print("New Block: {}".format(block_hash)) + ... print(f"New Block: {block_hash}") The caller is responsible for polling the results from ``get_new_entries()``. See :ref:`asynchronous_filters` for examples of filter-event handling with web3 v4. diff --git a/docs/web3.eth.rst b/docs/web3.eth.rst index eaa1653782..9fbe9c13ab 100644 --- a/docs/web3.eth.rst +++ b/docs/web3.eth.rst @@ -364,7 +364,7 @@ The following methods are available on the ``web3.eth`` namespace. assert rlp_account == HexaryTrie.get_from_proof( root, trie_key, format_proof_nodes(proof.accountProof) - ), "Failed to verify account proof {}".format(proof.address) + ), f"Failed to verify account proof {proof.address}" for storage_proof in proof.storageProof: trie_key = keccak(pad_bytes(b'\x00', 32, storage_proof.key)) @@ -376,7 +376,7 @@ The following methods are available on the ``web3.eth`` namespace. assert rlp_value == HexaryTrie.get_from_proof( root, trie_key, format_proof_nodes(storage_proof.proof) - ), "Failed to verify storage proof {}".format(storage_proof.key) + ), f"Failed to verify storage proof {storage_proof.key}" return True diff --git a/ethpm/contract.py b/ethpm/contract.py index d9b226d392..e56d6670c9 100644 --- a/ethpm/contract.py +++ b/ethpm/contract.py @@ -56,7 +56,7 @@ def __init__(self, address: bytes, **kwargs: Any) -> None: ) validate_address(address) # type ignored to allow for undefined **kwargs on `Contract` base class __init__ - super(LinkableContract, self).__init__(address=address, **kwargs) # type: ignore + super().__init__(address=address, **kwargs) # type: ignore @classmethod def factory( @@ -69,7 +69,7 @@ def factory( if not is_prelinked_bytecode(to_bytes(hexstr=bytecode), dep_link_refs): needs_bytecode_linking = True kwargs = assoc(kwargs, "needs_bytecode_linking", needs_bytecode_linking) - return super(LinkableContract, cls).factory(w3, class_name, **kwargs) + return super().factory(w3, class_name, **kwargs) @classmethod def constructor(cls, *args: Any, **kwargs: Any) -> ContractConstructor: @@ -77,7 +77,7 @@ def constructor(cls, *args: Any, **kwargs: Any) -> ContractConstructor: raise BytecodeLinkingError( "Contract cannot be deployed until its bytecode is linked." ) - return super(LinkableContract, cls).constructor(*args, **kwargs) + return super().constructor(*args, **kwargs) @classmethod def link_bytecode(cls, attr_dict: Dict[str, str]) -> Type["LinkableContract"]: @@ -111,7 +111,7 @@ def validate_attr_dict(self, attr_dict: Dict[str, str]) -> None: """ Validates that ContractType keys in attr_dict reference existing manifest ContractTypes. """ - attr_dict_names = list(attr_dict.keys()) + attr_dict_names = attr_dict.keys() if not self.unlinked_references and not self.linked_references: raise BytecodeLinkingError( @@ -122,8 +122,8 @@ def validate_attr_dict(self, attr_dict: Dict[str, str]) -> None: linked_refs = self.linked_references or ({},) all_link_refs = unlinked_refs + linked_refs - all_link_names = [ref["name"] for ref in all_link_refs if ref] - if set(attr_dict_names) != set(all_link_names): + all_link_names = {ref["name"] for ref in all_link_refs if ref} + if attr_dict_names != all_link_names: raise BytecodeLinkingError( "All link references must be defined when calling " "`link_bytecode` on a contract factory." diff --git a/ethpm/tools/builder.py b/ethpm/tools/builder.py index 895b790c09..6f38968402 100644 --- a/ethpm/tools/builder.py +++ b/ethpm/tools/builder.py @@ -498,7 +498,7 @@ def normalize_compiler_output(compiler_output: Dict[str, Any]) -> Dict[str, Any] ] paths, names = zip(*paths_and_names) if len(names) != len(set(names)): - duplicates = set([name for name in names if names.count(name) > 1]) + duplicates = {name for name in names if names.count(name) > 1} raise ManifestBuildingError( f"Duplicate contract types: {duplicates} were found in the compiler output." ) diff --git a/ethpm/validation/manifest.py b/ethpm/validation/manifest.py index 6aba1b1034..eb94f86523 100644 --- a/ethpm/validation/manifest.py +++ b/ethpm/validation/manifest.py @@ -66,11 +66,11 @@ def _load_schema_data() -> Dict[str, Any]: def extract_contract_types_from_deployments(deployment_data: List[Any]) -> Set[str]: - contract_types = set( + contract_types = { deployment["contractType"] for chain_deployments in deployment_data for deployment in chain_deployments.values() - ) + } return contract_types @@ -108,11 +108,11 @@ def validate_manifest_deployments(manifest: Dict[str, Any]) -> None: """ Validate that a manifest's deployments contracts reference existing contractTypes. """ - if set(("contractTypes", "deployments")).issubset(manifest): - all_contract_types = list(manifest["contractTypes"].keys()) - all_deployments = list(manifest["deployments"].values()) + if {"contractTypes", "deployments"}.issubset(manifest): + all_contract_types = manifest["contractTypes"].keys() + all_deployments = manifest["deployments"].values() all_deployment_names = extract_contract_types_from_deployments(all_deployments) - missing_contract_types = set(all_deployment_names).difference( + missing_contract_types = all_deployment_names.difference( all_contract_types ) if missing_contract_types: diff --git a/tests/core/contracts/test_contract_call_interface.py b/tests/core/contracts/test_contract_call_interface.py index 4e67c7d1cd..34a754191c 100644 --- a/tests/core/contracts/test_contract_call_interface.py +++ b/tests/core/contracts/test_contract_call_interface.py @@ -602,9 +602,9 @@ def test_returns_data_from_specified_block(w3, math_contract): message_regex = ( r"\nCould not identify the intended function with name `.*`, " - r"positional argument\(s\) of type `.*` and " - r"keyword argument\(s\) of type `.*`." - r"\nFound .* function\(s\) with the name `.*`: .*" + r"positional arguments? of type `.*` and " + r"keyword arguments? of type `.*`." + r"\nFound .* functions? with the name `.*`: .*" ) diagnosis_arg_regex = ( r"\nFunction invocation failed due to improper number of arguments." diff --git a/tests/core/contracts/test_contract_method_to_argument_matching.py b/tests/core/contracts/test_contract_method_to_argument_matching.py index 8f80dbf6c6..d4c051b2a0 100644 --- a/tests/core/contracts/test_contract_method_to_argument_matching.py +++ b/tests/core/contracts/test_contract_method_to_argument_matching.py @@ -150,7 +150,7 @@ def test_finds_function_with_matching_args(w3, arguments, expected_types): abi = Contract._find_matching_fn_abi('a', arguments) assert abi['name'] == 'a' assert len(abi['inputs']) == len(expected_types) - assert set(get_abi_input_types(abi)) == set(expected_types) + assert get_abi_input_types(abi) == expected_types def test_finds_function_with_matching_args_deprecation_warning(w3): @@ -160,7 +160,7 @@ def test_finds_function_with_matching_args_deprecation_warning(w3): abi = Contract._find_matching_fn_abi('a', ['']) assert abi['name'] == 'a' assert len(abi['inputs']) == len(['bytes32']) - assert set(get_abi_input_types(abi)) == set(['bytes32']) + assert get_abi_input_types(abi) == ['bytes32'] def test_error_when_duplicate_match(w3): @@ -193,4 +193,4 @@ def test_strict_finds_function_with_matching_args(w3_strict_abi, arguments, expe abi = Contract._find_matching_fn_abi('a', arguments) assert abi['name'] == 'a' assert len(abi['inputs']) == len(expected_types) - assert set(get_abi_input_types(abi)) == set(expected_types) + assert get_abi_input_types(abi) == expected_types diff --git a/tests/core/filtering/test_filter_against_transaction_logs.py b/tests/core/filtering/test_filter_against_transaction_logs.py index 664ec64b95..d1e63a4e43 100644 --- a/tests/core/filtering/test_filter_against_transaction_logs.py +++ b/tests/core/filtering/test_filter_against_transaction_logs.py @@ -22,8 +22,8 @@ def test_sync_filter_against_log_events(w3_empty, txn_filter = w3.eth.filter({}) - txn_hashes = [] - txn_hashes.append(emitter.functions.logNoArgs(emitter_event_ids.LogNoArguments).transact()) + txn_hashes = set() + txn_hashes.add(emitter.functions.logNoArgs(emitter_event_ids.LogNoArguments).transact()) for txn_hash in txn_hashes: wait_for_transaction(w3, txn_hash) @@ -34,7 +34,7 @@ def test_sync_filter_against_log_events(w3_empty, seen_logs = txn_filter.get_new_entries() - assert set(txn_hashes) == set(log['transactionHash'] for log in seen_logs) + assert txn_hashes == {log['transactionHash'] for log in seen_logs} @pytest.mark.skip(reason="fixture 'w3_empty' not found") @@ -51,9 +51,9 @@ def test_async_filter_against_log_events(w3_empty, txn_filter = w3.eth.filter({}) txn_filter.watch(seen_logs.append) - txn_hashes = [] + txn_hashes = set() - txn_hashes.append(emitter.functions.logNoArgs(emitter_event_ids.LogNoArguments).transact()) + txn_hashes.add(emitter.functions.logNoArgs(emitter_event_ids.LogNoArguments).transact()) for txn_hash in txn_hashes: wait_for_transaction(w3, txn_hash) @@ -64,4 +64,4 @@ def test_async_filter_against_log_events(w3_empty, txn_filter.stop_watching(30) - assert set(txn_hashes) == set(log['transactionHash'] for log in seen_logs) + assert txn_hashes == {log['transactionHash'] for log in seen_logs} diff --git a/tests/core/middleware/test_fixture_middleware.py b/tests/core/middleware/test_fixture_middleware.py index 19ed3816c4..1cb9eb9b7b 100644 --- a/tests/core/middleware/test_fixture_middleware.py +++ b/tests/core/middleware/test_fixture_middleware.py @@ -13,10 +13,7 @@ class DummyProvider(BaseProvider): def make_request(self, method, params): - raise NotImplementedError("Cannot make request for {0}:{1}".format( - method, - params, - )) + raise NotImplementedError(f"Cannot make request for {method}:{params}") @pytest.fixture diff --git a/tests/core/middleware/test_simple_cache_middleware.py b/tests/core/middleware/test_simple_cache_middleware.py index 2f09a10ff9..3cbe96e761 100644 --- a/tests/core/middleware/test_simple_cache_middleware.py +++ b/tests/core/middleware/test_simple_cache_middleware.py @@ -87,7 +87,7 @@ def result_cb(method, params): def test_simple_cache_middleware_does_not_cache_error_responses(w3_base): w3 = w3_base w3.middleware_onion.add(construct_error_generator_middleware({ - 'fake_endpoint': lambda *_: 'msg-{0}'.format(str(uuid.uuid4())), + 'fake_endpoint': lambda *_: f'msg-{uuid.uuid4()}', })) w3.middleware_onion.add(construct_simple_cache_middleware( diff --git a/tests/core/middleware/test_time_based_cache_middleware.py b/tests/core/middleware/test_time_based_cache_middleware.py index 968160171f..d2ee1a9502 100644 --- a/tests/core/middleware/test_time_based_cache_middleware.py +++ b/tests/core/middleware/test_time_based_cache_middleware.py @@ -130,7 +130,7 @@ def test_time_based_cache_middleware_does_not_cache_error_response( counter = itertools.count() def mk_error(method, params): - return "error-number-{0}".format(next(counter)) + return f"error-number-{next(counter)}" w3.middleware_onion.add(construct_error_generator_middleware({ 'fake_endpoint': mk_error, diff --git a/tests/core/middleware/test_transaction_signing.py b/tests/core/middleware/test_transaction_signing.py index bb9d2a7dbb..8d1ccefec8 100644 --- a/tests/core/middleware/test_transaction_signing.py +++ b/tests/core/middleware/test_transaction_signing.py @@ -83,10 +83,7 @@ class DummyProvider(BaseProvider): def make_request(self, method, params): - raise NotImplementedError("Cannot make request for {0}:{1}".format( - method, - params, - )) + raise NotImplementedError(f"Cannot make request for {method}:{params}") @pytest.fixture() diff --git a/tests/core/providers/test_ipc_provider.py b/tests/core/providers/test_ipc_provider.py index 2b1042b007..5f856eed7a 100644 --- a/tests/core/providers/test_ipc_provider.py +++ b/tests/core/providers/test_ipc_provider.py @@ -23,7 +23,7 @@ @pytest.fixture def jsonrpc_ipc_pipe_path(): with tempfile.TemporaryDirectory() as temp_dir: - ipc_path = os.path.join(temp_dir, '{0}.ipc'.format(uuid.uuid4())) + ipc_path = os.path.join(temp_dir, f'{uuid.uuid4()}.ipc') try: yield ipc_path finally: diff --git a/tests/core/providers/test_websocket_provider.py b/tests/core/providers/test_websocket_provider.py index 0cf475d31e..25037b1fa0 100644 --- a/tests/core/providers/test_websocket_provider.py +++ b/tests/core/providers/test_websocket_provider.py @@ -55,7 +55,7 @@ async def empty_server(websocket, path): def w3(open_port, start_websocket_server): # need new event loop as the one used by server is already running event_loop = asyncio.new_event_loop() - endpoint_uri = 'ws://127.0.0.1:{}'.format(open_port) + endpoint_uri = f'ws://127.0.0.1:{open_port}' event_loop.run_until_complete(wait_for_ws(endpoint_uri)) provider = WebsocketProvider(endpoint_uri, websocket_timeout=0.01) return Web3(provider) @@ -68,6 +68,6 @@ def test_websocket_provider_timeout(w3): def test_restricted_websocket_kwargs(): invalid_kwargs = {'uri': 'ws://127.0.0.1:8546'} - re_exc_message = r'.*found: {0}*'.format(set(invalid_kwargs.keys())) + re_exc_message = f'.*found: {set(invalid_kwargs)!r}*' with pytest.raises(ValidationError, match=re_exc_message): WebsocketProvider(websocket_kwargs=invalid_kwargs) diff --git a/tests/core/utilities/test_abi_filtering_by_argument_name.py b/tests/core/utilities/test_abi_filtering_by_argument_name.py index 2baac9e355..a9687fb50f 100644 --- a/tests/core/utilities/test_abi_filtering_by_argument_name.py +++ b/tests/core/utilities/test_abi_filtering_by_argument_name.py @@ -48,14 +48,14 @@ @pytest.mark.parametrize( 'argument_names,expected', ( - ([], ['func_1', 'func_2', 'func_3', 'func_4']), - (['a'], ['func_2', 'func_3', 'func_4']), - (['a', 'c'], ['func_4']), - (['c'], ['func_4']), - (['b'], ['func_3', 'func_4']), + ([], {'func_1', 'func_2', 'func_3', 'func_4'}), + (['a'], {'func_2', 'func_3', 'func_4'}), + (['a', 'c'], {'func_4'}), + (['c'], {'func_4'}), + (['b'], {'func_3', 'func_4'}), ) ) def test_filter_by_arguments_1(argument_names, expected): actual_matches = filter_by_argument_name(argument_names, ABI) - function_names = [match['name'] for match in actual_matches] - assert set(function_names) == set(expected) + function_names = {match['name'] for match in actual_matches} + assert function_names == expected diff --git a/tests/ethpm/_utils/test_contract_utils.py b/tests/ethpm/_utils/test_contract_utils.py index 1ffd417901..a6bd9f00e2 100644 --- a/tests/ethpm/_utils/test_contract_utils.py +++ b/tests/ethpm/_utils/test_contract_utils.py @@ -58,11 +58,11 @@ def test_validate_contract_name_invalidates(name): @pytest.mark.parametrize( "contract_data,expected_kwargs", ( - ({"abi": ""}, ["abi"]), - ({"deploymentBytecode": {"bytecode": ""}}, ["bytecode"]), + ({"abi": ""}, {"abi"}), + ({"deploymentBytecode": {"bytecode": ""}}, {"bytecode"}), ( {"abi": "", "runtimeBytecode": {"bytecode": ""}}, - ["abi", "bytecode_runtime"], + {"abi", "bytecode_runtime"}, ), ( { @@ -74,13 +74,13 @@ def test_validate_contract_name_invalidates(name): ], }, }, - ["abi", "bytecode", "unlinked_references"], + {"abi", "bytecode", "unlinked_references"}, ), ), ) def test_generate_contract_factory_kwargs(contract_data, expected_kwargs): contract_factory = generate_contract_factory_kwargs(contract_data) - assert set(contract_factory.keys()) == set(expected_kwargs) + assert contract_factory.keys() == expected_kwargs def test_validate_w3_instance_validates(w3): diff --git a/tests/ethpm/validation/test_manifest.py b/tests/ethpm/validation/test_manifest.py index c68089f7cc..348e2ff388 100644 --- a/tests/ethpm/validation/test_manifest.py +++ b/tests/ethpm/validation/test_manifest.py @@ -78,17 +78,17 @@ def test_validate_deployments_without_deployment(manifest_with_no_deployments): @pytest.mark.parametrize( "data,expected", ( - ({}, set()), - ([{"some": {"contractType": "one"}}], set(["one"])), + ([], {}), + ([{"some": {"contractType": "one"}}], {"one"}), ( [{"some": {"contractType": "one"}, "other": {"contractType": "two"}}], - set(["one", "two"]), + {"one", "two"}, ), ), ) def test_extract_contract_types_from_deployments(data, expected): actual = extract_contract_types_from_deployments(data) - assert actual == expected + assert actual == set(expected) def test_validate_manifest_version_validates_version_three_string(): diff --git a/tests/integration/generate_fixtures/common.py b/tests/integration/generate_fixtures/common.py index d7d20a8964..a6bc487e6b 100644 --- a/tests/integration/generate_fixtures/common.py +++ b/tests/integration/generate_fixtures/common.py @@ -183,11 +183,8 @@ def get_geth_process(geth_binary, output, errors = proc.communicate() print( "Geth Process Exited:\n" - "stdout:{0}\n\n" - "stderr:{1}\n\n".format( - to_text(output), - to_text(errors), - ) + f"stdout:{to_text(output)}\n\n" + f"stderr:{to_text(errors)}\n\n" ) @@ -235,12 +232,13 @@ def mine_transaction_hash(w3, txn_hash): def deploy_contract(w3, name, factory): + name = name.upper() w3.geth.personal.unlock_account(w3.eth.coinbase, KEYFILE_PW) deploy_txn_hash = factory.constructor().transact({'from': w3.eth.coinbase}) - print('{0}_CONTRACT_DEPLOY_HASH: '.format(name.upper()), deploy_txn_hash) + print(f'{name}_CONTRACT_DEPLOY_HASH: {deploy_txn_hash}') deploy_receipt = mine_transaction_hash(w3, deploy_txn_hash) - print('{0}_CONTRACT_DEPLOY_TRANSACTION_MINED'.format(name.upper())) + print(f'{name}_CONTRACT_DEPLOY_TRANSACTION_MINED') contract_address = deploy_receipt['contractAddress'] assert is_checksum_address(contract_address) - print('{0}_CONTRACT_ADDRESS:'.format(name.upper()), contract_address) + print(f'{name}_CONTRACT_ADDRESS: {contract_address}') return deploy_receipt diff --git a/tests/integration/generate_fixtures/go_ethereum.py b/tests/integration/generate_fixtures/go_ethereum.py index d6d55b7ee2..eadbfb00bc 100644 --- a/tests/integration/generate_fixtures/go_ethereum.py +++ b/tests/integration/generate_fixtures/go_ethereum.py @@ -91,11 +91,8 @@ def get_geth_process(geth_binary, print( "Geth Process Exited:\n" - "stdout:{0}\n\n" - "stderr:{1}\n\n".format( - to_text(output), - to_text(errors), - ) + f"stdout:{to_text(output)}\n\n" + f"stderr:{to_text(errors)}\n\n" ) diff --git a/tests/integration/go_ethereum/conftest.py b/tests/integration/go_ethereum/conftest.py index 0862c47aa1..622e11f106 100644 --- a/tests/integration/go_ethereum/conftest.py +++ b/tests/integration/go_ethereum/conftest.py @@ -121,11 +121,8 @@ def geth_process(geth_binary, datadir, genesis_file, geth_command_arguments): output, errors = proc.communicate() print( "Geth Process Exited:\n" - "stdout:{0}\n\n" - "stderr:{1}\n\n".format( - to_text(output), - to_text(errors), - ) + f"stdout:{to_text(output)}\n\n" + f"stderr:{to_text(errors)}\n\n" ) diff --git a/tests/integration/go_ethereum/test_goethereum_http.py b/tests/integration/go_ethereum/test_goethereum_http.py index 53a624faad..ec209d02e1 100644 --- a/tests/integration/go_ethereum/test_goethereum_http.py +++ b/tests/integration/go_ethereum/test_goethereum_http.py @@ -58,7 +58,7 @@ def rpc_port(): @pytest.fixture(scope="module") def endpoint_uri(rpc_port): - return 'http://localhost:{0}'.format(rpc_port) + return f'http://localhost:{rpc_port}' def _geth_command_arguments(rpc_port, diff --git a/tests/integration/go_ethereum/test_goethereum_ws.py b/tests/integration/go_ethereum/test_goethereum_ws.py index 647681ede8..22367aa570 100644 --- a/tests/integration/go_ethereum/test_goethereum_ws.py +++ b/tests/integration/go_ethereum/test_goethereum_ws.py @@ -27,7 +27,7 @@ def ws_port(): @pytest.fixture(scope="module") def endpoint_uri(ws_port): - return 'ws://localhost:{0}'.format(ws_port) + return f'ws://localhost:{ws_port}' def _geth_command_arguments(ws_port, diff --git a/web3/_utils/abi.py b/web3/_utils/abi.py index 698f4151cd..aef5c6c137 100644 --- a/web3/_utils/abi.py +++ b/web3/_utils/abi.py @@ -290,9 +290,8 @@ def validate(self) -> None: if self.value_bit_size % 8 != 0: raise ValueError( - "Invalid value bit size: {0}. Must be a multiple of 8".format( - self.value_bit_size, - ) + f"Invalid value bit size: {self.value_bit_size}. " + "Must be a multiple of 8" ) if self.value_bit_size > self.data_byte_size * 8: @@ -328,13 +327,13 @@ def validate_value(self, value: Any) -> bytes: # type: ignore self.invalidate_value( value, exc=ValueOutOfBounds, - msg="exceeds total byte size for bytes{} encoding".format(byte_size), + msg=f"exceeds total byte size for bytes{byte_size} encoding", ) elif len(value) < byte_size: self.invalidate_value( value, exc=ValueOutOfBounds, - msg="less than total byte size for bytes{} encoding".format(byte_size), + msg=f"less than total byte size for bytes{byte_size} encoding", ) return value @@ -438,10 +437,8 @@ def merge_args_and_kwargs( # Ensure the function is being applied to the correct number of args if len(args) + len(kwargs) != len(function_abi.get('inputs', [])): raise TypeError( - "Incorrect argument count. Expected '{0}'. Got '{1}'".format( - len(function_abi['inputs']), - len(args) + len(kwargs), - ) + f"Incorrect argument count. Expected '{len(function_abi['inputs'])}" + f". Got '{len(args) + len(kwargs)}'" ) # If no keyword args were given, we don't need to align them @@ -456,10 +453,9 @@ def merge_args_and_kwargs( duplicate_args = kwarg_names.intersection(args_as_kwargs.keys()) if duplicate_args: raise TypeError( - "{fn_name}() got multiple values for argument(s) '{dups}'".format( - fn_name=function_abi['name'], - dups=', '.join(duplicate_args), - ) + f"{function_abi.get('name')}() got multiple values for " + f"argument{'s' if len(duplicate_args) > 1 else ''} " + f"'{', '.join(duplicate_args)}'" ) # Check for unknown args @@ -467,16 +463,14 @@ def merge_args_and_kwargs( if unknown_args: if function_abi.get('name'): raise TypeError( - "{fn_name}() got unexpected keyword argument(s) '{dups}'".format( - fn_name=function_abi.get('name'), - dups=', '.join(unknown_args), - ) + f"{function_abi.get('name')}() got unexpected keyword argument" + f"{'s' if len(unknown_args) > 1 else ''} " + f"{', '.join(unknown_args)}'" ) raise TypeError( - "Type: '{_type}' got unexpected keyword argument(s) '{dups}'".format( - _type=function_abi.get('type'), - dups=', '.join(unknown_args), - ) + f"Type: '{function_abi.get('type')}' got unexpected keyword " + f"argument{'s' if len(unknown_args) > 1 else ''} " + f"{', '.join(unknown_args)}'" ) # Sort args according to their position in the ABI and unzip them from their @@ -545,10 +539,8 @@ def _align_abi_input(arg_abi: ABIFunctionParams, arg: Any) -> Tuple[Any, ...]: if not is_list_like(aligned_arg): raise TypeError( - 'Expected non-string sequence for "{}" component type: got {}'.format( - arg_abi['type'], - aligned_arg, - ), + f'Expected non-string sequence for "{arg_abi.get("type")}" ' + f'component type: got {aligned_arg}' ) # convert NamedTuple to regular tuple @@ -604,9 +596,9 @@ def get_constructor_abi(contract_abi: ABI) -> ABIFunction: INT_SIZES = range(8, 257, 8) BYTES_SIZES = range(1, 33) -UINT_TYPES = ['uint{0}'.format(i) for i in INT_SIZES] -INT_TYPES = ['int{0}'.format(i) for i in INT_SIZES] -BYTES_TYPES = ['bytes{0}'.format(i) for i in BYTES_SIZES] + ['bytes32.byte'] +UINT_TYPES = [f'uint{i}' for i in INT_SIZES] +INT_TYPES = [f'int{i}' for i in INT_SIZES] +BYTES_TYPES = [f'bytes{i}' for i in BYTES_SIZES] + ['bytes32.byte'] STATIC_TYPES = list(itertools.chain( ['address', 'bool'], @@ -694,7 +686,7 @@ def size_of_type(abi_type: TypeStr) -> int: def sub_type_of_array_type(abi_type: TypeStr) -> str: if not is_array_type(abi_type): raise ValueError( - "Cannot parse subtype of nonarray abi-type: {0}".format(abi_type) + f"Cannot parse subtype of nonarray abi-type: {abi_type}" ) return re.sub(END_BRACKETS_OF_ARRAY_TYPE_REGEX, '', abi_type, 1) @@ -703,7 +695,7 @@ def sub_type_of_array_type(abi_type: TypeStr) -> str: def length_of_array_type(abi_type: TypeStr) -> int: if not is_array_type(abi_type): raise ValueError( - "Cannot parse length of nonarray abi-type: {0}".format(abi_type) + f"Cannot parse length of nonarray abi-type: {abi_type}" ) inner_brackets = re.search(END_BRACKETS_OF_ARRAY_TYPE_REGEX, abi_type).group(0).strip("[]") diff --git a/web3/_utils/async_transactions.py b/web3/_utils/async_transactions.py index 116fdf8898..7e6153e047 100644 --- a/web3/_utils/async_transactions.py +++ b/web3/_utils/async_transactions.py @@ -35,8 +35,8 @@ async def get_buffered_gas_estimate( if gas_estimate > gas_limit: raise ValueError( "Contract does not appear to be deployable within the " - "current network gas limits. Estimated: {0}. Current gas " - "limit: {1}".format(gas_estimate, gas_limit) + f"current network gas limits. Estimated: {gas_estimate}. " + f"Current gas limit: {gas_limit}" ) return min(gas_limit, gas_estimate + gas_buffer) diff --git a/web3/_utils/blocks.py b/web3/_utils/blocks.py index 63ff37328c..d05e33c38e 100644 --- a/web3/_utils/blocks.py +++ b/web3/_utils/blocks.py @@ -70,5 +70,6 @@ def select_method_for_block_identifier( return if_number else: raise ValueError( - "Value did not match any of the recognized block identifiers: {0}".format(value) + "Value did not match any of the recognized block identifiers: " + f"{value}" ) diff --git a/web3/_utils/caching.py b/web3/_utils/caching.py index 09cdf25335..ce11235312 100644 --- a/web3/_utils/caching.py +++ b/web3/_utils/caching.py @@ -39,7 +39,7 @@ def generate_cache_key(value: Any) -> str: in value ))) else: - raise TypeError("Cannot generate cache key for value {0} of type {1}".format( - value, - type(value), - )) + raise TypeError( + f"Cannot generate cache key for value {value} of type " + f"{type(value)}" + ) diff --git a/web3/_utils/contracts.py b/web3/_utils/contracts.py index 97a0b1d17c..fbddcf7768 100644 --- a/web3/_utils/contracts.py +++ b/web3/_utils/contracts.py @@ -146,18 +146,15 @@ def find_matching_fn_abi( ) message = ( - "\nCould not identify the intended function with name `{name}`, " - "positional argument(s) of type `{arg_types}` and " - "keyword argument(s) of type `{kwarg_types}`." - "\nFound {num_candidates} function(s) with the name `{name}`: {candidates}" - "{diagnosis}" - ).format( - name=fn_identifier, - arg_types=tuple(map(type, args)), - kwarg_types=valmap(type, kwargs), - num_candidates=len(matching_identifiers), - candidates=matching_function_signatures, - diagnosis=diagnosis, + f"\nCould not identify the intended function with name `" + f"{fn_identifier}`, positional argument" + f"{'s' if len(args) > 1 else ''} of type " + f"`{tuple(map(type, args))}` and keyword argument" + f"{'s' if len(kwargs) > 1 else ''} of type " + f"`{valmap(type, kwargs)}`.\nFound {len(matching_identifiers)} " + f"function{'s' if len(matching_identifiers) > 1 else ''} with " + f"the name `{fn_identifier}`" + f": {matching_function_signatures}{diagnosis}" ) raise ValidationError(message) @@ -171,9 +168,7 @@ def encode_abi( if not check_if_arguments_can_be_encoded(abi, w3.codec, arguments, {}): raise TypeError( "One or more arguments could not be encoded to the necessary " - "ABI type. Expected types are: {0}".format( - ', '.join(argument_types), - ) + f"ABI type. Expected types are: {', '.join(argument_types)}" ) normalizers = [ diff --git a/web3/_utils/datatypes.py b/web3/_utils/datatypes.py index 957de2a22e..110449fd75 100644 --- a/web3/_utils/datatypes.py +++ b/web3/_utils/datatypes.py @@ -18,9 +18,9 @@ def verify_attr(class_name: str, key: str, namespace: Collection[str]) -> None: if key not in namespace: raise AttributeError( - "Property {0} not found on {1} class. " - "`{1}.factory` only accepts keyword arguments which are " - "present on the {1} class".format(key, class_name) + f"Property {key} not found on {class_name} class. " + f"`{class_name}.factory` only accepts keyword arguments which are " + f"present on the {class_name} class" ) diff --git a/web3/_utils/encoding.py b/web3/_utils/encoding.py index 5b9a4a4a56..7482db29fa 100644 --- a/web3/_utils/encoding.py +++ b/web3/_utils/encoding.py @@ -88,7 +88,7 @@ def hex_encode_abi_type(abi_type: TypeStr, value: Any, return to_hex(text=value) else: raise ValueError( - "Unsupported ABI type: {0}".format(abi_type) + f"Unsupported ABI type: {abi_type}" ) @@ -169,9 +169,8 @@ def hexstr_if_str( (primitive, hexstr) = (None, hexstr_or_primitive) if remove_0x_prefix(HexStr(hexstr)) and not is_hex(hexstr): raise ValueError( - "when sending a str, it must be a hex string. Got: {0!r}".format( - hexstr_or_primitive, - ) + "when sending a str, it must be a hex string. Got: " + f"{hexstr_or_primitive!r}" ) else: (primitive, hexstr) = (hexstr_or_primitive, None) @@ -208,10 +207,15 @@ def _friendly_json_encode(self, obj: Dict[Any, Any], except TypeError as full_exception: if hasattr(obj, 'items'): item_errors = '; '.join(self._json_mapping_errors(obj)) - raise TypeError("dict had unencodable value at keys: {{{}}}".format(item_errors)) + raise TypeError( + "dict had unencodable value at keys: " + f"{{{item_errors}}}" + ) elif is_list_like(obj): element_errors = '; '.join(self._json_list_errors(obj)) - raise TypeError("list had unencodable value at index: [{}]".format(element_errors)) + raise TypeError( + f"list had unencodable value at index: [{element_errors}]" + ) else: raise full_exception @@ -220,7 +224,7 @@ def json_decode(self, json_str: str) -> Dict[Any, Any]: decoded = json.loads(json_str) return decoded except json.decoder.JSONDecodeError as exc: - err_msg = 'Could not decode {} because of {}.'.format(repr(json_str), exc) + err_msg = f'Could not decode {json_str!r} because of {exc}.' # Calling code may rely on catching JSONDecodeError to recognize bad json # so we have to re-raise the same type. raise json.decoder.JSONDecodeError(err_msg, exc.doc, exc.pos) @@ -230,7 +234,7 @@ def json_encode(self, obj: Dict[Any, Any], try: return self._friendly_json_encode(obj, cls=cls) except TypeError as exc: - raise TypeError("Could not encode to JSON: {}".format(exc)) + raise TypeError(f"Could not encode to JSON: {exc}") def to_4byte_hex(hex_or_str_or_bytes: Union[HexStr, str, bytes, int]) -> HexStr: diff --git a/web3/_utils/events.py b/web3/_utils/events.py index 9cfe6fb685..78bc60e94b 100644 --- a/web3/_utils/events.py +++ b/web3/_utils/events.py @@ -219,10 +219,10 @@ def get_event_data(abi_codec: ABICodec, event_abi: ABIEvent, log_entry: LogRecei log_topic_names = get_abi_input_names(ABIEvent({'inputs': log_topics_abi})) if len(log_topics) != len(log_topic_types): - raise LogTopicError("Expected {0} log topics. Got {1}".format( - len(log_topic_types), - len(log_topics), - )) + raise LogTopicError( + f"Expected {len(log_topic_types)} log topics. Got " + f"{len(log_topics)}" + ) log_data = hexstr_if_str(to_bytes, log_entry['data']) log_data_abi = exclude_indexed_event_inputs(event_abi) @@ -400,7 +400,7 @@ def filter_params(self) -> FilterParams: def deploy(self, w3: "Web3") -> "LogFilter": if not isinstance(w3, web3.Web3): - raise ValueError("Invalid web3 argument: got: {0}".format(repr(w3))) + raise ValueError(f"Invalid web3 argument: got: {w3!r}") for arg in AttributeDict.values(self.args): arg._immutable = True diff --git a/web3/_utils/filters.py b/web3/_utils/filters.py index b6a77c385f..79d3ae734f 100644 --- a/web3/_utils/filters.py +++ b/web3/_utils/filters.py @@ -97,7 +97,7 @@ def construct_event_filter_params( filter_params['address'] = [address, contract_address] else: raise ValueError( - "Unsupported type for `address` parameter: {0}".format(type(address)) + f"Unsupported type for `address` parameter: {type(address)}" ) elif address: filter_params['address'] = address diff --git a/web3/_utils/http.py b/web3/_utils/http.py index 80c7e31296..e244183877 100644 --- a/web3/_utils/http.py +++ b/web3/_utils/http.py @@ -1,8 +1,5 @@ def construct_user_agent(class_name: str) -> str: from web3 import __version__ as web3_version - user_agent = 'Web3.py/{version}/{class_name}'.format( - version=web3_version, - class_name=class_name, - ) + user_agent = f'Web3.py/{web3_version}/{class_name}' return user_agent diff --git a/web3/_utils/math.py b/web3/_utils/math.py index cb983f235b..96052bb00d 100644 --- a/web3/_utils/math.py +++ b/web3/_utils/math.py @@ -14,9 +14,10 @@ def percentile(values: Optional[Sequence[int]] = None, """ if values in [None, tuple(), []] or len(values) < 1: raise InsufficientData( - "Expected a sequence of at least 1 integers, got {0!r}".format(values)) + f"Expected a sequence of at least 1 integers, got {values!r}" + ) if percentile is None: - raise ValueError("Expected a percentile choice, got {0}".format(percentile)) + raise ValueError(f"Expected a percentile choice, got {percentile}") sorted_values = sorted(values) diff --git a/web3/_utils/module_testing/go_ethereum_admin_module.py b/web3/_utils/module_testing/go_ethereum_admin_module.py index 38505deec7..0fa20285ff 100644 --- a/web3/_utils/module_testing/go_ethereum_admin_module.py +++ b/web3/_utils/module_testing/go_ethereum_admin_module.py @@ -98,7 +98,7 @@ def test_admin_nodeInfo(self, w3: "Web3") -> None: 'protocols': AttributeDict({}) }) # Test that result gives at least the keys that are listed in `expected` - assert not set(expected.keys()).difference(result.keys()) + assert not set(expected).difference(result) class GoEthereumAsyncAdminModuleTest: diff --git a/web3/_utils/rpc_abi.py b/web3/_utils/rpc_abi.py index 641497ef42..4ebf435919 100644 --- a/web3/_utils/rpc_abi.py +++ b/web3/_utils/rpc_abi.py @@ -219,7 +219,7 @@ def apply_abi_formatters_to_dict( abi_dict: Dict[str, Any], data: Dict[Any, Any] ) -> Dict[Any, Any]: - fields = list(set(abi_dict.keys()) & set(data.keys())) + fields = list(abi_dict.keys() & data.keys()) formatted_values = map_abi_data( normalizers, [abi_dict[field] for field in fields], diff --git a/web3/_utils/threads.py b/web3/_utils/threads.py index ba45d8775e..435807dbbe 100644 --- a/web3/_utils/threads.py +++ b/web3/_utils/threads.py @@ -49,7 +49,7 @@ def __exit__( def __str__(self) -> str: if self.seconds is None: return '' - return "{0} seconds".format(self.seconds) + return f"{self.seconds} seconds" @property def expire_at(self) -> int: diff --git a/web3/_utils/transactions.py b/web3/_utils/transactions.py index 638cb89d50..40acdf0780 100644 --- a/web3/_utils/transactions.py +++ b/web3/_utils/transactions.py @@ -137,8 +137,8 @@ def get_buffered_gas_estimate( if gas_estimate > gas_limit: raise ValueError( "Contract does not appear to be deployable within the " - "current network gas limits. Estimated: {0}. Current gas " - "limit: {1}".format(gas_estimate, gas_limit) + f"current network gas limits. Estimated: {gas_estimate}. " + f"Current gas limit: {gas_limit}" ) return min(gas_limit, gas_estimate + gas_buffer) @@ -189,7 +189,7 @@ def extract_valid_transaction_params(transaction_params: TxData) -> TxParams: def assert_valid_transaction_params(transaction_params: TxParams) -> None: for param in transaction_params: if param not in VALID_TRANSACTION_PARAMS: - raise ValueError('{} is not a valid transaction parameter'.format(param)) + raise ValueError(f'{param} is not a valid transaction parameter') def prepare_replacement_transaction( diff --git a/web3/_utils/validation.py b/web3/_utils/validation.py index d59e788d61..d6080e340c 100644 --- a/web3/_utils/validation.py +++ b/web3/_utils/validation.py @@ -87,7 +87,7 @@ def validate_abi(abi: ABI) -> None: if duplicates: raise ValueError( 'Abi contains functions with colliding selectors. ' - 'Functions {0}'.format(_prepare_selector_collision_msg(duplicates)) + f'Functions {_prepare_selector_collision_msg(duplicates)}' ) @@ -96,7 +96,7 @@ def validate_abi_type(abi_type: TypeStr) -> None: Helper function for validating an abi_type """ if not is_recognized_type(abi_type): - raise ValueError("Unrecognized abi_type: {abi_type}".format(abi_type=abi_type)) + raise ValueError(f"Unrecognized abi_type: {abi_type}") def validate_abi_value(abi_type: TypeStr, value: Any) -> None: @@ -110,15 +110,13 @@ def validate_abi_value(abi_type: TypeStr, value: Any) -> None: if specified_length is not None: if specified_length < 1: raise TypeError( - "Invalid abi-type: {abi_type}. Length of fixed sized arrays" - "must be greater than 0." - .format(abi_type=abi_type) + f"Invalid abi-type: {abi_type}. Length of fixed sized " + "arrays must be greater than 0." ) if specified_length != len(value): raise TypeError( "The following array length does not the length specified" - "by the abi-type, {abi_type}: {value}" - .format(abi_type=abi_type, value=value) + f"by the abi-type, {abi_type}: {value}" ) # validate sub_types @@ -150,8 +148,7 @@ def validate_abi_value(abi_type: TypeStr, value: Any) -> None: return raise TypeError( - "The following abi value is not a '{abi_type}': {value}" - .format(abi_type=abi_type, value=value) + f"The following abi value is not a '{abi_type}': {value}" ) @@ -174,7 +171,7 @@ def validate_address(value: Any) -> None: return if not isinstance(value, str): - raise TypeError('Address {} must be provided as a string'.format(value)) + raise TypeError(f'Address {value} must be provided as a string') if not is_hex_address(value): raise InvalidAddress("Address must be 20 bytes, as a hex string with a 0x prefix", value) if not is_checksum_address(value): diff --git a/web3/contract.py b/web3/contract.py index c20d0e2156..0f152ce02a 100644 --- a/web3/contract.py +++ b/web3/contract.py @@ -192,7 +192,7 @@ def __getattr__(self, function_name: str) -> "ContractFunction": ) elif function_name not in self.__dict__['_functions']: raise ABIFunctionNotFound( - "The function '{}' was not found in this contract's abi. ".format(function_name), + f"The function '{function_name}' was not found in this contract's abi. ", "Are you sure you provided the correct contract abi?" ) else: @@ -252,7 +252,7 @@ def __getattr__(self, event_name: str) -> Type['ContractEvent']: ) elif event_name not in self.__dict__['_events']: raise ABIEventFunctionNotFound( - "The event '{}' was not found in this contract's abi. ".format(event_name), + f"The event '{event_name}' was not found in this contract's abi. ", "Are you sure you provided the correct contract abi?" ) else: @@ -585,7 +585,7 @@ def _encode_constructor_data(cls, args: Optional[Any] = None, def mk_collision_prop(fn_name: str) -> Callable[[], None]: def collision_fn() -> NoReturn: - msg = "Namespace collision for function name {0} with ConciseContract API.".format(fn_name) + msg = f"Namespace collision for function name {fn_name} with ConciseContract API." raise AttributeError(msg) collision_fn.__name__ = fn_name return collision_fn @@ -687,10 +687,11 @@ def buildTransaction(self, transaction: Optional[TxParams] = None) -> TxParams: def check_forbidden_keys_in_transaction( transaction: TxParams, forbidden_keys: Optional[Collection[str]] = None ) -> None: - keys_found = set(transaction.keys()) & set(forbidden_keys) + keys_found = transaction.keys() & forbidden_keys if keys_found: raise ValueError( - "Cannot set '{}' field(s) in transaction".format(', '.join(keys_found)) + f"Cannot set '{', '.join(keys_found)}'" + f"field{'s' if len(keys_found) > 1 else ''} in transaction" ) @@ -1412,12 +1413,12 @@ def __getattr__(self, function_name: str) -> Any: "The ABI for this contract contains no function definitions. ", "Are you sure you provided the correct contract ABI?" ) - elif function_name not in set(fn['name'] for fn in self._functions): + elif function_name not in {fn['name'] for fn in self._functions}: functions_available = ', '.join([fn['name'] for fn in self._functions]) raise ABIFunctionNotFound( - "The function '{}' was not found in this contract's ABI. ".format(function_name), + f"The function '{function_name}' was not found in this contract's ABI. ", "Here is a list of all of the function names found: ", - "{}. ".format(functions_available), + f"{functions_available}. ", "Did you mean to call one of those functions?" ) else: @@ -1673,11 +1674,11 @@ def get_function_by_identifier( ) -> ContractFunction: if len(fns) > 1: raise ValueError( - 'Found multiple functions with matching {0}. ' - 'Found: {1!r}'.format(identifier, fns) + f'Found multiple functions with matching {identifier}. ' + f'Found: {fns!r}' ) elif len(fns) == 0: raise ValueError( - 'Could not find any function with matching {0}'.format(identifier) + f'Could not find any function with matching {identifier}' ) return fns[0] diff --git a/web3/main.py b/web3/main.py index 5395895683..666ef18e03 100644 --- a/web3/main.py +++ b/web3/main.py @@ -314,7 +314,7 @@ def solidityKeccak(cls, abi_types: List[TypeStr], values: List[Any]) -> bytes: if len(abi_types) != len(values): raise ValueError( "Length mismatch between provided abi types and values. Got " - "{0} types and {1} values.".format(len(abi_types), len(values)) + f"{len(abi_types)} types and {len(values)} values." ) if isinstance(cls, type): diff --git a/web3/manager.py b/web3/manager.py index db5c6085b4..6cc2b68e44 100644 --- a/web3/manager.py +++ b/web3/manager.py @@ -230,7 +230,7 @@ def receive_blocking(self, request_id: UUID, timeout: Optional[float] = None) -> try: request = self.pending_requests.pop(request_id) except KeyError: - raise KeyError("Request for id:{0} not found".format(request_id)) + raise KeyError(f"Request for id:{request_id} not found") else: response = request.get(timeout=timeout) diff --git a/web3/middleware/filter.py b/web3/middleware/filter.py index 5b2f82a417..dee73d7be3 100644 --- a/web3/middleware/filter.py +++ b/web3/middleware/filter.py @@ -293,15 +293,15 @@ def get_logs(self) -> List[LogReceipt]: "fromBlock": "from_block" } -NEW_FILTER_METHODS = set([ +NEW_FILTER_METHODS = { "eth_newBlockFilter", "eth_newFilter", -]) +} -FILTER_CHANGES_METHODS = set([ +FILTER_CHANGES_METHODS = { "eth_getFilterChanges", "eth_getFilterLogs", -]) +} class RequestBlocks: diff --git a/web3/middleware/signing.py b/web3/middleware/signing.py index 4ed76a9830..b0f121f243 100644 --- a/web3/middleware/signing.py +++ b/web3/middleware/signing.py @@ -93,7 +93,7 @@ def to_account(val: Any) -> LocalAccount: "key must be one of the types: " "eth_keys.datatype.PrivateKey, eth_account.signers.local.LocalAccount, " "or raw private key as a hex string or byte string. " - "Was of type {0}".format(type(val))) + f"Was of type {type(val)}") @to_account.register(LocalAccount) diff --git a/web3/middleware/stalecheck.py b/web3/middleware/stalecheck.py index 73e8158770..e8d98188ad 100644 --- a/web3/middleware/stalecheck.py +++ b/web3/middleware/stalecheck.py @@ -20,9 +20,9 @@ if TYPE_CHECKING: from web3 import Web3 # noqa: F401 -SKIP_STALECHECK_FOR_METHODS = set([ +SKIP_STALECHECK_FOR_METHODS = { 'eth_getBlockByNumber', -]) +} def _isfresh(block: BlockData, allowable_delay: int) -> bool: diff --git a/web3/providers/async_rpc.py b/web3/providers/async_rpc.py index dc80bfdedf..04f27f3b3e 100644 --- a/web3/providers/async_rpc.py +++ b/web3/providers/async_rpc.py @@ -58,7 +58,7 @@ async def cache_async_session(self, session: ClientSession) -> None: await _cache_async_session(self.endpoint_uri, session) def __str__(self) -> str: - return "RPC connection {0}".format(self.endpoint_uri) + return f"RPC connection {self.endpoint_uri}" @to_dict def get_request_kwargs(self) -> Iterable[Tuple[str, Any]]: diff --git a/web3/providers/auto.py b/web3/providers/auto.py index 9bc49b893b..47f3f4e933 100644 --- a/web3/providers/auto.py +++ b/web3/providers/auto.py @@ -103,10 +103,9 @@ def _proxy_request(self, method: RPCEndpoint, params: Any, if provider is None: raise CannotHandleRequest( "Could not discover provider while making request: " - "method:{0}\n" - "params:{1}\n".format( - method, - params)) + f"method:{method}\n" + f"params:{params}\n" + ) return provider.make_request(method, params) diff --git a/web3/providers/eth_tester/defaults.py b/web3/providers/eth_tester/defaults.py index a33d337ef6..5c190217f8 100644 --- a/web3/providers/eth_tester/defaults.py +++ b/web3/providers/eth_tester/defaults.py @@ -102,11 +102,9 @@ def inner(*args: Any, **kwargs: Any) -> TValue: def client_version(eth_tester: "EthereumTester", params: Any) -> str: # TODO: account for the backend that is in use. from eth_tester import __version__ - return "EthereumTester/{version}/{platform}/python{v.major}.{v.minor}.{v.micro}".format( - version=__version__, - v=sys.version_info, - platform=sys.platform, - ) + v = sys.version_info + return f"EthereumTester/{__version__}/{sys.platform}/python{v.major}" \ + f".{v.minor}.{v.micro}" @curry diff --git a/web3/providers/ipc.py b/web3/providers/ipc.py index a166aabd80..1e7250451b 100644 --- a/web3/providers/ipc.py +++ b/web3/providers/ipc.py @@ -153,8 +153,8 @@ def get_default_ipc_path() -> str: # type: ignore else: raise ValueError( - "Unsupported platform '{0}'. Only darwin/linux/win32/freebsd are " - "supported. You must specify the ipc_path".format(sys.platform) + f"Unsupported platform '{sys.platform}'. Only darwin/linux/win32/" + "freebsd are supported. You must specify the ipc_path" ) @@ -202,8 +202,8 @@ def get_dev_ipc_path() -> str: # type: ignore else: raise ValueError( - "Unsupported platform '{0}'. Only darwin/linux/win32/freebsd are " - "supported. You must specify the ipc_path".format(sys.platform) + f"Unsupported platform '{sys.platform}'. Only darwin/linux/win32/" + "freebsd are supported. You must specify the ipc_path" ) diff --git a/web3/providers/rpc.py b/web3/providers/rpc.py index 74c83eac7e..13e3156aa5 100644 --- a/web3/providers/rpc.py +++ b/web3/providers/rpc.py @@ -66,7 +66,7 @@ def __init__( super().__init__() def __str__(self) -> str: - return "RPC connection {0}".format(self.endpoint_uri) + return f"RPC connection {self.endpoint_uri}" @to_dict def get_request_kwargs(self) -> Iterable[Tuple[str, Any]]: diff --git a/web3/providers/websocket.py b/web3/providers/websocket.py index ef486ff49c..0713fa830c 100644 --- a/web3/providers/websocket.py +++ b/web3/providers/websocket.py @@ -103,13 +103,13 @@ def __init__( if websocket_kwargs is None: websocket_kwargs = {} else: - found_restricted_keys = set(websocket_kwargs.keys()).intersection( + found_restricted_keys = set(websocket_kwargs).intersection( RESTRICTED_WEBSOCKET_KWARGS ) if found_restricted_keys: raise ValidationError( - '{0} are not allowed in websocket_kwargs, ' - 'found: {1}'.format(RESTRICTED_WEBSOCKET_KWARGS, found_restricted_keys) + f'{RESTRICTED_WEBSOCKET_KWARGS} are not allowed ' + f'in websocket_kwargs, found: {found_restricted_keys}' ) self.conn = PersistentWebSocket( self.endpoint_uri, websocket_kwargs @@ -117,7 +117,7 @@ def __init__( super().__init__() def __str__(self) -> str: - return "WS connection {0}".format(self.endpoint_uri) + return f"WS connection {self.endpoint_uri}" async def coro_make_request(self, request_data: bytes) -> RPCResponse: async with self.conn as conn: diff --git a/web3/tools/benchmark/node.py b/web3/tools/benchmark/node.py index 86fa3416b7..2cc23d0fe6 100644 --- a/web3/tools/benchmark/node.py +++ b/web3/tools/benchmark/node.py @@ -59,7 +59,7 @@ def _rpc_port(self) -> str: return str(port) def _endpoint_uri(self) -> str: - return "http://localhost:{0}".format(self.rpc_port) + return f"http://localhost:{self.rpc_port}" def _geth_binary(self) -> str: if "GETH_BINARY" in os.environ: From 1adadd48072f0033aaf91b0483264050ff64e96e Mon Sep 17 00:00:00 2001 From: Harmouch101 Date: Thu, 10 Mar 2022 10:03:48 +0200 Subject: [PATCH 22/57] :zap: resolve issues! Signed-off-by: Harmouch101 --- tests/ethpm/validation/test_manifest.py | 4 ++-- web3/_utils/abi.py | 18 +++++++----------- web3/_utils/blocks.py | 3 +-- web3/_utils/caching.py | 3 +-- web3/_utils/contracts.py | 17 +++++++---------- web3/_utils/encoding.py | 6 ++---- web3/_utils/events.py | 3 +-- web3/contract.py | 4 ++-- web3/main.py | 9 ++++----- web3/providers/auto.py | 6 ++---- web3/providers/eth_tester/defaults.py | 3 +-- web3/providers/ipc.py | 3 +-- 12 files changed, 31 insertions(+), 48 deletions(-) diff --git a/tests/ethpm/validation/test_manifest.py b/tests/ethpm/validation/test_manifest.py index 348e2ff388..6633830f09 100644 --- a/tests/ethpm/validation/test_manifest.py +++ b/tests/ethpm/validation/test_manifest.py @@ -78,7 +78,7 @@ def test_validate_deployments_without_deployment(manifest_with_no_deployments): @pytest.mark.parametrize( "data,expected", ( - ([], {}), + ([], set()), ([{"some": {"contractType": "one"}}], {"one"}), ( [{"some": {"contractType": "one"}, "other": {"contractType": "two"}}], @@ -88,7 +88,7 @@ def test_validate_deployments_without_deployment(manifest_with_no_deployments): ) def test_extract_contract_types_from_deployments(data, expected): actual = extract_contract_types_from_deployments(data) - assert actual == set(expected) + assert actual == expected def test_validate_manifest_version_validates_version_three_string(): diff --git a/web3/_utils/abi.py b/web3/_utils/abi.py index aef5c6c137..55935de423 100644 --- a/web3/_utils/abi.py +++ b/web3/_utils/abi.py @@ -290,8 +290,7 @@ def validate(self) -> None: if self.value_bit_size % 8 != 0: raise ValueError( - f"Invalid value bit size: {self.value_bit_size}. " - "Must be a multiple of 8" + f"Invalid value bit size: {self.value_bit_size}. Must be a multiple of 8" ) if self.value_bit_size > self.data_byte_size * 8: @@ -452,25 +451,22 @@ def merge_args_and_kwargs( # Check for duplicate args duplicate_args = kwarg_names.intersection(args_as_kwargs.keys()) if duplicate_args: + s = 's' if len(duplicate_args) > 1 else '' raise TypeError( - f"{function_abi.get('name')}() got multiple values for " - f"argument{'s' if len(duplicate_args) > 1 else ''} " - f"'{', '.join(duplicate_args)}'" + f"{function_abi.get('name')}() got multiple values for argument{s} '{', '.join(duplicate_args)}'" ) # Check for unknown args unknown_args = kwarg_names.difference(sorted_arg_names) if unknown_args: + s = 's' if len(unknown_args) > 1 else '' + unknown_args = ', '.join(unknown_args) if function_abi.get('name'): raise TypeError( - f"{function_abi.get('name')}() got unexpected keyword argument" - f"{'s' if len(unknown_args) > 1 else ''} " - f"{', '.join(unknown_args)}'" + f"{function_abi.get('name')}() got unexpected keyword argument{s} '{unknown_args}'" ) raise TypeError( - f"Type: '{function_abi.get('type')}' got unexpected keyword " - f"argument{'s' if len(unknown_args) > 1 else ''} " - f"{', '.join(unknown_args)}'" + f"Type: '{function_abi.get('type')}' got unexpected keyword argument{s} '{unknown_args}'" ) # Sort args according to their position in the ABI and unzip them from their diff --git a/web3/_utils/blocks.py b/web3/_utils/blocks.py index d05e33c38e..dd6c237c76 100644 --- a/web3/_utils/blocks.py +++ b/web3/_utils/blocks.py @@ -70,6 +70,5 @@ def select_method_for_block_identifier( return if_number else: raise ValueError( - "Value did not match any of the recognized block identifiers: " - f"{value}" + f"Value did not match any of the recognized block identifiers: {value}" ) diff --git a/web3/_utils/caching.py b/web3/_utils/caching.py index ce11235312..ee78b48c16 100644 --- a/web3/_utils/caching.py +++ b/web3/_utils/caching.py @@ -40,6 +40,5 @@ def generate_cache_key(value: Any) -> str: ))) else: raise TypeError( - f"Cannot generate cache key for value {value} of type " - f"{type(value)}" + f"Cannot generate cache key for value {value} of type {type(value)}" ) diff --git a/web3/_utils/contracts.py b/web3/_utils/contracts.py index fbddcf7768..2623e5a11f 100644 --- a/web3/_utils/contracts.py +++ b/web3/_utils/contracts.py @@ -144,17 +144,14 @@ def find_matching_fn_abi( "\nAmbiguous argument encoding. " "Provided arguments can be encoded to multiple functions matching this call." ) - + s_a = 's' if len(args) > 1 else '' + s_k = 's' if len(kwargs) > 1 else '' + s_m = 's' if len(matching_identifiers) > 1 else '' message = ( - f"\nCould not identify the intended function with name `" - f"{fn_identifier}`, positional argument" - f"{'s' if len(args) > 1 else ''} of type " - f"`{tuple(map(type, args))}` and keyword argument" - f"{'s' if len(kwargs) > 1 else ''} of type " - f"`{valmap(type, kwargs)}`.\nFound {len(matching_identifiers)} " - f"function{'s' if len(matching_identifiers) > 1 else ''} with " - f"the name `{fn_identifier}`" - f": {matching_function_signatures}{diagnosis}" + f"\nCould not identify the intended function with name `{fn_identifier}`, positional argument" + f"{s_a} of type `{tuple(map(type, args))}` and keyword argument{s_k} of type " + f"`{valmap(type, kwargs)}`.\nFound {len(matching_identifiers)} function{s_m} with " + f"the name `{fn_identifier}` {matching_function_signatures}{diagnosis}" ) raise ValidationError(message) diff --git a/web3/_utils/encoding.py b/web3/_utils/encoding.py index 7482db29fa..b8adfd88d1 100644 --- a/web3/_utils/encoding.py +++ b/web3/_utils/encoding.py @@ -169,8 +169,7 @@ def hexstr_if_str( (primitive, hexstr) = (None, hexstr_or_primitive) if remove_0x_prefix(HexStr(hexstr)) and not is_hex(hexstr): raise ValueError( - "when sending a str, it must be a hex string. Got: " - f"{hexstr_or_primitive!r}" + f"when sending a str, it must be a hex string. Got: {hexstr_or_primitive!r}" ) else: (primitive, hexstr) = (hexstr_or_primitive, None) @@ -208,8 +207,7 @@ def _friendly_json_encode(self, obj: Dict[Any, Any], if hasattr(obj, 'items'): item_errors = '; '.join(self._json_mapping_errors(obj)) raise TypeError( - "dict had unencodable value at keys: " - f"{{{item_errors}}}" + f"dict had unencodable value at keys: {{{item_errors}}}" ) elif is_list_like(obj): element_errors = '; '.join(self._json_list_errors(obj)) diff --git a/web3/_utils/events.py b/web3/_utils/events.py index 78bc60e94b..dbb1bcbf27 100644 --- a/web3/_utils/events.py +++ b/web3/_utils/events.py @@ -220,8 +220,7 @@ def get_event_data(abi_codec: ABICodec, event_abi: ABIEvent, log_entry: LogRecei if len(log_topics) != len(log_topic_types): raise LogTopicError( - f"Expected {len(log_topic_types)} log topics. Got " - f"{len(log_topics)}" + f"Expected {len(log_topic_types)} log topics. Got {len(log_topics)}" ) log_data = hexstr_if_str(to_bytes, log_entry['data']) diff --git a/web3/contract.py b/web3/contract.py index 0f152ce02a..b88f76c2a2 100644 --- a/web3/contract.py +++ b/web3/contract.py @@ -689,9 +689,9 @@ def check_forbidden_keys_in_transaction( ) -> None: keys_found = transaction.keys() & forbidden_keys if keys_found: + s = 's' if len(keys_found) > 1 else '' raise ValueError( - f"Cannot set '{', '.join(keys_found)}'" - f"field{'s' if len(keys_found) > 1 else ''} in transaction" + f"Cannot set '{', '.join(keys_found)}' field{s} in transaction" ) diff --git a/web3/main.py b/web3/main.py index 666ef18e03..c8cb108922 100644 --- a/web3/main.py +++ b/web3/main.py @@ -292,11 +292,10 @@ def keccak(primitive: Optional[Primitives] = None, text: Optional[str] = None, return eth_utils_keccak(input_bytes) raise TypeError( - f"You called keccak with first arg {primitive!r} and keywords " - f"{{'text': {text!r}, 'hexstr': {hexstr!r}}}. You must call it " - "with one of these approaches: keccak(text='txt'), keccak " - "(hexstr='0x747874'), keccak(b'\\x74\\x78\\x74'), or kecca " - "(0x747874)." + f"You called keccak with first arg {primitive!r} and keywords {{'text': {text!r}, " + f"'hexstr': {hexstr!r}}}. You must call it with one of these approaches: " + "keccak(text='txt'), keccak(hexstr='0x747874'), keccak(b'\\x74\\x78\\x74'), " + "or keccak(0x747874)." ) @combomethod diff --git a/web3/providers/auto.py b/web3/providers/auto.py index 47f3f4e933..362640b588 100644 --- a/web3/providers/auto.py +++ b/web3/providers/auto.py @@ -55,8 +55,7 @@ def load_provider_from_uri( return WebsocketProvider(uri_string) else: raise NotImplementedError( - f'Web3 does not know how to connect to scheme {uri.scheme!r} ' - f'in {uri_string!r}' + f'Web3 does not know how to connect to scheme {uri.scheme!r} in {uri_string!r}' ) @@ -103,8 +102,7 @@ def _proxy_request(self, method: RPCEndpoint, params: Any, if provider is None: raise CannotHandleRequest( "Could not discover provider while making request: " - f"method:{method}\n" - f"params:{params}\n" + f"method:{method}\nparams:{params}\n" ) return provider.make_request(method, params) diff --git a/web3/providers/eth_tester/defaults.py b/web3/providers/eth_tester/defaults.py index 5c190217f8..544da5e863 100644 --- a/web3/providers/eth_tester/defaults.py +++ b/web3/providers/eth_tester/defaults.py @@ -103,8 +103,7 @@ def client_version(eth_tester: "EthereumTester", params: Any) -> str: # TODO: account for the backend that is in use. from eth_tester import __version__ v = sys.version_info - return f"EthereumTester/{__version__}/{sys.platform}/python{v.major}" \ - f".{v.minor}.{v.micro}" + return f"EthereumTester/{__version__}/{sys.platform}/python{v.major}.{v.minor}.{v.micro}" @curry diff --git a/web3/providers/ipc.py b/web3/providers/ipc.py index 1e7250451b..9bb3903b32 100644 --- a/web3/providers/ipc.py +++ b/web3/providers/ipc.py @@ -53,8 +53,7 @@ def __init__(self, ipc_path: str) -> None: def __enter__(self) -> socket.socket: if not self.ipc_path: raise FileNotFoundError( - "cannot connect to IPC socket at path: " - f"{self.ipc_path!r}" + f"cannot connect to IPC socket at path: {self.ipc_path!r}" ) if not self.sock: From 4f560c3eec04b562a401e6784d40e1687ec7d89e Mon Sep 17 00:00:00 2001 From: Harmouch101 Date: Thu, 10 Mar 2022 10:09:39 +0200 Subject: [PATCH 23/57] :memo: update newsfragment! Signed-off-by: Harmouch101 --- newsfragments/2372.misc.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/newsfragments/2372.misc.rst b/newsfragments/2372.misc.rst index 85a5d056e1..bd2a98be31 100644 --- a/newsfragments/2372.misc.rst +++ b/newsfragments/2372.misc.rst @@ -1 +1,6 @@ -remove python 2 syntax. \ No newline at end of file +improve the code base by: +- using `f-strings`. +- removing redundant `set()` calls. +- making error messages more readable in the code. +- removing python2 `u` prefix. +- other cleanups. \ No newline at end of file From 2904d15232219f5b8eba48a30f46660fe2c89cf7 Mon Sep 17 00:00:00 2001 From: Harmouch101 Date: Thu, 10 Mar 2022 10:18:54 +0200 Subject: [PATCH 24/57] :bug: fix lint issues Signed-off-by: Harmouch101 --- web3/_utils/abi.py | 9 +++++---- web3/_utils/contracts.py | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/web3/_utils/abi.py b/web3/_utils/abi.py index 55935de423..6f69ef0309 100644 --- a/web3/_utils/abi.py +++ b/web3/_utils/abi.py @@ -452,21 +452,22 @@ def merge_args_and_kwargs( duplicate_args = kwarg_names.intersection(args_as_kwargs.keys()) if duplicate_args: s = 's' if len(duplicate_args) > 1 else '' + duplicate_arg = ', '.join(duplicate_args) raise TypeError( - f"{function_abi.get('name')}() got multiple values for argument{s} '{', '.join(duplicate_args)}'" + f"{function_abi.get('name')}() got multiple values for argument{s} '{duplicate_arg}'" ) # Check for unknown args unknown_args = kwarg_names.difference(sorted_arg_names) if unknown_args: s = 's' if len(unknown_args) > 1 else '' - unknown_args = ', '.join(unknown_args) + unknown_arg = ', '.join(unknown_args) if function_abi.get('name'): raise TypeError( - f"{function_abi.get('name')}() got unexpected keyword argument{s} '{unknown_args}'" + f"{function_abi.get('name')}() got unexpected keyword argument{s} '{unknown_arg}'" ) raise TypeError( - f"Type: '{function_abi.get('type')}' got unexpected keyword argument{s} '{unknown_args}'" + f"Type: '{function_abi.get('type')}' got unexpected keyword argument{s} '{unknown_arg}'" ) # Sort args according to their position in the ABI and unzip them from their diff --git a/web3/_utils/contracts.py b/web3/_utils/contracts.py index 2623e5a11f..81ce4b191a 100644 --- a/web3/_utils/contracts.py +++ b/web3/_utils/contracts.py @@ -148,8 +148,8 @@ def find_matching_fn_abi( s_k = 's' if len(kwargs) > 1 else '' s_m = 's' if len(matching_identifiers) > 1 else '' message = ( - f"\nCould not identify the intended function with name `{fn_identifier}`, positional argument" - f"{s_a} of type `{tuple(map(type, args))}` and keyword argument{s_k} of type " + f"\nCould not identify the intended function with name `{fn_identifier}`, positional " + f"argument {s_a} of type `{tuple(map(type, args))}` and keyword argument{s_k} of type " f"`{valmap(type, kwargs)}`.\nFound {len(matching_identifiers)} function{s_m} with " f"the name `{fn_identifier}` {matching_function_signatures}{diagnosis}" ) From e9a279f20cc6abae571d562ee99861a1563793c3 Mon Sep 17 00:00:00 2001 From: Harmouch101 Date: Thu, 10 Mar 2022 10:35:04 +0200 Subject: [PATCH 25/57] :zap: fix message error! Signed-off-by: Harmouch101 --- web3/_utils/contracts.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web3/_utils/contracts.py b/web3/_utils/contracts.py index 81ce4b191a..a4ed743ff6 100644 --- a/web3/_utils/contracts.py +++ b/web3/_utils/contracts.py @@ -149,9 +149,9 @@ def find_matching_fn_abi( s_m = 's' if len(matching_identifiers) > 1 else '' message = ( f"\nCould not identify the intended function with name `{fn_identifier}`, positional " - f"argument {s_a} of type `{tuple(map(type, args))}` and keyword argument{s_k} of type " + f"argument{s_a} of type `{tuple(map(type, args))}` and keyword argument{s_k} of type " f"`{valmap(type, kwargs)}`.\nFound {len(matching_identifiers)} function{s_m} with " - f"the name `{fn_identifier}` {matching_function_signatures}{diagnosis}" + f"the name `{fn_identifier}`: {matching_function_signatures}{diagnosis}" ) raise ValidationError(message) From dca17957af20799dfd4cf372b5ce7d7dd838113c Mon Sep 17 00:00:00 2001 From: Harmouch101 Date: Thu, 10 Mar 2022 18:33:31 +0200 Subject: [PATCH 26/57] :rewind: revert changes! Signed-off-by: Harmouch101 --- .../core/contracts/test_contract_call_interface.py | 6 +++--- web3/_utils/abi.py | 13 ++++++------- web3/_utils/contracts.py | 7 ++----- web3/contract.py | 3 +-- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/tests/core/contracts/test_contract_call_interface.py b/tests/core/contracts/test_contract_call_interface.py index 34a754191c..4e67c7d1cd 100644 --- a/tests/core/contracts/test_contract_call_interface.py +++ b/tests/core/contracts/test_contract_call_interface.py @@ -602,9 +602,9 @@ def test_returns_data_from_specified_block(w3, math_contract): message_regex = ( r"\nCould not identify the intended function with name `.*`, " - r"positional arguments? of type `.*` and " - r"keyword arguments? of type `.*`." - r"\nFound .* functions? with the name `.*`: .*" + r"positional argument\(s\) of type `.*` and " + r"keyword argument\(s\) of type `.*`." + r"\nFound .* function\(s\) with the name `.*`: .*" ) diagnosis_arg_regex = ( r"\nFunction invocation failed due to improper number of arguments." diff --git a/web3/_utils/abi.py b/web3/_utils/abi.py index 6f69ef0309..791f7bdfd5 100644 --- a/web3/_utils/abi.py +++ b/web3/_utils/abi.py @@ -451,23 +451,22 @@ def merge_args_and_kwargs( # Check for duplicate args duplicate_args = kwarg_names.intersection(args_as_kwargs.keys()) if duplicate_args: - s = 's' if len(duplicate_args) > 1 else '' - duplicate_arg = ', '.join(duplicate_args) raise TypeError( - f"{function_abi.get('name')}() got multiple values for argument{s} '{duplicate_arg}'" + f"{function_abi.get('name')}() got multiple values for argument(s) " + f"'{', '.join(duplicate_args)}'" ) # Check for unknown args unknown_args = kwarg_names.difference(sorted_arg_names) if unknown_args: - s = 's' if len(unknown_args) > 1 else '' - unknown_arg = ', '.join(unknown_args) if function_abi.get('name'): raise TypeError( - f"{function_abi.get('name')}() got unexpected keyword argument{s} '{unknown_arg}'" + f"{function_abi.get('name')}() got unexpected keyword argument(s)" + f" '{', '.join(unknown_args)}'" ) raise TypeError( - f"Type: '{function_abi.get('type')}' got unexpected keyword argument{s} '{unknown_arg}'" + f"Type: '{function_abi.get('type')}' got unexpected keyword argument(s)" + f" '{', '.join(unknown_args)}'" ) # Sort args according to their position in the ABI and unzip them from their diff --git a/web3/_utils/contracts.py b/web3/_utils/contracts.py index a4ed743ff6..dcf66f6304 100644 --- a/web3/_utils/contracts.py +++ b/web3/_utils/contracts.py @@ -144,13 +144,10 @@ def find_matching_fn_abi( "\nAmbiguous argument encoding. " "Provided arguments can be encoded to multiple functions matching this call." ) - s_a = 's' if len(args) > 1 else '' - s_k = 's' if len(kwargs) > 1 else '' - s_m = 's' if len(matching_identifiers) > 1 else '' message = ( f"\nCould not identify the intended function with name `{fn_identifier}`, positional " - f"argument{s_a} of type `{tuple(map(type, args))}` and keyword argument{s_k} of type " - f"`{valmap(type, kwargs)}`.\nFound {len(matching_identifiers)} function{s_m} with " + f"argument(s) of type `{tuple(map(type, args))}` and keyword argument(s) of type " + f"`{valmap(type, kwargs)}`.\nFound {len(matching_identifiers)} function(s) with " f"the name `{fn_identifier}`: {matching_function_signatures}{diagnosis}" ) diff --git a/web3/contract.py b/web3/contract.py index b88f76c2a2..5679e5be86 100644 --- a/web3/contract.py +++ b/web3/contract.py @@ -689,9 +689,8 @@ def check_forbidden_keys_in_transaction( ) -> None: keys_found = transaction.keys() & forbidden_keys if keys_found: - s = 's' if len(keys_found) > 1 else '' raise ValueError( - f"Cannot set '{', '.join(keys_found)}' field{s} in transaction" + f"Cannot set '{', '.join(keys_found)}' field(s) in transaction" ) From c72280af844bd998717fd7638f87692d7b6e0fa8 Mon Sep 17 00:00:00 2001 From: Felipe Selmo Date: Thu, 24 Feb 2022 15:03:20 -0700 Subject: [PATCH 27/57] Minor cleanups in method class. --- web3/method.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/web3/method.py b/web3/method.py index 4f08807e40..dfc88800e9 100644 --- a/web3/method.py +++ b/web3/method.py @@ -61,14 +61,14 @@ def inner(args: Any) -> TReturn: return inner -def default_munger(module: "Module", *args: Any, **kwargs: Any) -> Tuple[()]: +def default_munger(_module: "Module", *args: Any, **kwargs: Any) -> Tuple[()]: if not args and not kwargs: return () else: raise TypeError("Parameters passed to method without parameter mungers defined.") -def default_root_munger(module: "Module", *args: Any) -> List[Any]: +def default_root_munger(_module: "Module", *args: Any) -> List[Any]: return [*args] @@ -115,15 +115,14 @@ def get_balance_root_munger(module, account, block_identifier=None): and the response formatters are applied to the output. """ def __init__( - self, - json_rpc_method: Optional[RPCEndpoint] = None, - mungers: Optional[Sequence[Munger]] = None, - request_formatters: Optional[Callable[..., TReturn]] = None, - result_formatters: Optional[Callable[..., TReturn]] = None, - error_formatters: Optional[Callable[..., TReturn]] = None, - null_result_formatters: Optional[Callable[..., TReturn]] = None, - method_choice_depends_on_args: Optional[Callable[..., RPCEndpoint]] = None, - w3: Optional["Web3"] = None): + self, + json_rpc_method: Optional[RPCEndpoint] = None, + mungers: Optional[Sequence[Munger]] = None, + request_formatters: Optional[Callable[..., TReturn]] = None, + result_formatters: Optional[Callable[..., TReturn]] = None, + null_result_formatters: Optional[Callable[..., TReturn]] = None, + method_choice_depends_on_args: Optional[Callable[..., RPCEndpoint]] = None, + ): self.json_rpc_method = json_rpc_method self.mungers = mungers or [default_munger] @@ -133,8 +132,9 @@ def __init__( self.null_result_formatters = null_result_formatters or get_null_result_formatters self.method_choice_depends_on_args = method_choice_depends_on_args - def __get__(self, obj: Optional["Module"] = None, - obj_type: Optional[Type["Module"]] = None) -> TFunc: + def __get__( + self, obj: Optional["Module"] = None, obj_type: Optional[Type["Module"]] = None + ) -> TFunc: if obj is None: raise TypeError( "Direct calls to methods are not supported. " @@ -204,7 +204,7 @@ def process_params( return request, response_formatters -class DeprecatedMethod(): +class DeprecatedMethod: def __init__(self, method: Method[Callable[..., Any]], old_name: str, new_name: str) -> None: self.method = method self.old_name = old_name From 0e3aefdbdccbef7aac854ab2920cf95692779714 Mon Sep 17 00:00:00 2001 From: Felipe Selmo Date: Thu, 24 Feb 2022 15:05:42 -0700 Subject: [PATCH 28/57] Remove old reference to TestRPCProvider --- web3/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/web3/__init__.py b/web3/__init__.py index 5c8edfacef..8d86766529 100644 --- a/web3/__init__.py +++ b/web3/__init__.py @@ -45,7 +45,6 @@ "HTTPProvider", "IPCProvider", "WebsocketProvider", - "TestRPCProvider", "EthereumTesterProvider", "Account", "AsyncHTTPProvider", From 7762ed9fe15c6bac76c1b8974394b4c4ead2ce13 Mon Sep 17 00:00:00 2001 From: Felipe Selmo Date: Thu, 24 Feb 2022 19:04:29 -0700 Subject: [PATCH 29/57] Add option to attach methods to classes extending from `Module` class * Refactor logic for attaching a `Method` class as a property rather than a method. Instead of implicitly setting `mungers=None`, explicitly set the `is_property` flag on `Method` to `True`. This also facilitates attaching new methods and properties to modules. * Fix up some tests in test_method.py that were falsely passing to actually test correctly. Add tests for new `is_property` flag for the `Method` class. * Create `test_module.py` and add tests for `attach_methods()` --- newsfragments/2383.breaking-change.rst | 1 + tests/core/method-class/test_method.py | 44 ++++++++++----- tests/core/module-class/test_module.py | 75 ++++++++++++++++++++++++++ web3/_utils/admin.py | 10 ++-- web3/_utils/miner.py | 6 +-- web3/_utils/personal.py | 4 +- web3/_utils/txpool.py | 6 +-- web3/eth.py | 22 ++++---- web3/method.py | 35 +++++++----- web3/module.py | 12 +++++ web3/parity.py | 6 +-- 11 files changed, 170 insertions(+), 51 deletions(-) create mode 100644 newsfragments/2383.breaking-change.rst create mode 100644 tests/core/module-class/test_module.py diff --git a/newsfragments/2383.breaking-change.rst b/newsfragments/2383.breaking-change.rst new file mode 100644 index 0000000000..a53354bbc7 --- /dev/null +++ b/newsfragments/2383.breaking-change.rst @@ -0,0 +1 @@ +Add ``attach_methods()`` to ``Module`` class to facilitate attaching methods to modules. \ No newline at end of file diff --git a/tests/core/method-class/test_method.py b/tests/core/method-class/test_method.py index 28b7f953aa..44e132f4b6 100644 --- a/tests/core/method-class/test_method.py +++ b/tests/core/method-class/test_method.py @@ -32,7 +32,7 @@ def test_method_accepts_callable_for_selector(): def test_method_selector_fn_accepts_str(): method = Method( - mungers=None, + is_property=True, json_rpc_method='eth_method', ) assert method.method_selector_fn() == 'eth_method' @@ -77,7 +77,7 @@ def test_input_munger_parameter_passthrough_matching_arity(): mungers=[lambda m, z, y: ['success']], json_rpc_method='eth_method', ) - method.input_munger(object(), ['first', 'second'], {}) == 'success' + assert method.input_munger(object(), ['first', 'second'], {}) == ['success'] def test_input_munger_parameter_passthrough_mismatch_arity(): @@ -94,16 +94,15 @@ def test_input_munger_falsy_config_result_in_default_munger(): mungers=[], json_rpc_method='eth_method', ) - method.input_munger(object(), [], {}) == [] + assert method.input_munger(object(), [], {}) == [] -def test_default_input_munger_with_input_parameters_exception(): +def test_default_input_munger_with_input_parameters(): method = Method( mungers=[], json_rpc_method='eth_method', ) - with pytest.raises(TypeError): - method.input_munger(object(), [1], {}) + assert method.input_munger(object(), [1], {}) == [1] @pytest.mark.parametrize( @@ -125,7 +124,7 @@ def test_default_input_munger_with_input_parameters_exception(): }, ['unexpected_argument'], {}, - TypeError, + IndexError, 2 ), ( @@ -184,6 +183,15 @@ def test_default_input_munger_with_input_parameters_exception(): ('eth_getBalance', ('0x0000000000000000000000000000000000000000', '0x3')), 2, ), + ( + { + 'json_rpc_method': 'eth_getBalance', + }, + ('0x0000000000000000000000000000000000000000', 3), + {}, + ('eth_getBalance', ('0x0000000000000000000000000000000000000000', '0x3')), + 2, + ), ( { 'mungers': [ @@ -206,7 +214,17 @@ def test_default_input_munger_with_input_parameters_exception(): {}, ('eth_chainId', ()), 2, - ) + ), + ( + { + 'is_property': True, + 'json_rpc_method': 'eth_chainId', + }, + [], + {}, + ('eth_chainId', ()), + 2, + ), ), ids=[ 'raises-error-no-rpc-method', @@ -215,9 +233,11 @@ def test_default_input_munger_with_input_parameters_exception(): 'test-rpc-method-as-callable', 'test-arg-munger', 'test-munger-wrong-length-arg', - 'test-request-formatters', + 'test-request-formatters-default-root-munger-explicit', + 'test-request-formatters-default-root-munger-implicit', 'test-mungers-and-request-formatters', 'test-response-formatters', + 'test-set-as-property-default-munger-implicit', ] ) def test_process_params( @@ -230,7 +250,7 @@ def test_process_params( if isclass(expected_request_result) and issubclass(expected_request_result, Exception): with pytest.raises(expected_request_result): method = Method(**method_config) - request_params, output_formatter = method.process_params(object(), *args, **kwargs) + method.process_params(object(), *args, **kwargs) else: method = Method(**method_config) request_params, output_formatter = method.process_params(object(), *args, **kwargs) @@ -248,8 +268,8 @@ class Success(Exception): pass -def return_exception_raising_formatter(method): - def formatter(params): +def return_exception_raising_formatter(_method): + def formatter(_params): raise Success() return compose(formatter) diff --git a/tests/core/module-class/test_module.py b/tests/core/module-class/test_module.py new file mode 100644 index 0000000000..3654a7df8d --- /dev/null +++ b/tests/core/module-class/test_module.py @@ -0,0 +1,75 @@ +import pytest + +from web3 import ( + EthereumTesterProvider, + Web3, +) +from web3.method import ( + Method, +) + + +@pytest.fixture +def web3_with_external_modules(module1, module2, module3): + return Web3( + EthereumTesterProvider(), + external_modules={ + 'module1': module1, + 'module2': (module2, { + 'submodule1': module3, + }), + } + ) + + +def test_attach_methods_to_module(web3_with_external_modules): + w3 = web3_with_external_modules + + w3.module1.attach_methods({ + # set `property1` on `module1` with `eth_chainId` RPC endpoint + 'property1': Method('eth_chainId', is_property=True), + # set `method1` on `module1` with `eth_getBalance` RPC endpoint + 'method1': Method('eth_getBalance'), + }) + + assert w3.eth.chain_id == 61 + assert w3.module1.property1 == 61 + + coinbase = w3.eth.coinbase + assert w3.eth.get_balance(coinbase, 'latest') == 1000000000000000000000000 + assert w3.module1.method1(coinbase, 'latest') == 1000000000000000000000000 + + w3.module2.submodule1.attach_methods({ + # set `method2` on `module2.submodule1` with `eth_blockNumber` RPC endpoint + 'method2': Method('eth_blockNumber', is_property=True) + }) + + assert w3.eth.block_number == 0 + assert w3.module2.submodule1.method2 == 0 + + w3.eth.attach_methods({'get_block2': Method('eth_getBlockByNumber')}) + + assert w3.eth.get_block('latest')['number'] == 0 + assert w3.eth.get_block('pending')['number'] == 1 + + assert w3.eth.get_block2('latest')['number'] == 0 + assert w3.eth.get_block2('pending')['number'] == 1 + + +def test_attach_methods_with_mungers(web3_with_external_modules): + w3 = web3_with_external_modules + + w3.module1.attach_methods({ + 'method1': Method('eth_getBlockByNumber', mungers=[ + lambda _method, block_id, f, _z: (block_id, f), + lambda _m, block_id, _f: (block_id - 1,), + ]), + }) + + assert w3.eth.get_block(0)['baseFeePerGas'] == 1000000000 + assert w3.eth.get_block(1)['baseFeePerGas'] == 875000000 + + # `method1` should take a higher block number than `eth_getBlockByNumber` due to mungers and no + # other params should matter + assert w3.module1.method1(1, False, '_is_never_used_')['baseFeePerGas'] == 1000000000 + assert w3.module1.method1(2, '_will_be_overridden_', None)['baseFeePerGas'] == 875000000 diff --git a/web3/_utils/admin.py b/web3/_utils/admin.py index 2505451d96..86e946d550 100644 --- a/web3/_utils/admin.py +++ b/web3/_utils/admin.py @@ -40,19 +40,19 @@ def admin_start_params_munger( datadir: Method[Callable[[], str]] = Method( RPC.admin_datadir, - mungers=None, + is_property=True, ) node_info: Method[Callable[[], NodeInfo]] = Method( RPC.admin_nodeInfo, - mungers=None, + is_property=True, ) peers: Method[Callable[[], List[Peer]]] = Method( RPC.admin_peers, - mungers=None, + is_property=True, ) @@ -77,13 +77,13 @@ def __call__( stop_rpc: Method[Callable[[], bool]] = Method( RPC.admin_stopRPC, - mungers=None, + is_property=True, ) stop_ws: Method[Callable[[], bool]] = Method( RPC.admin_stopWS, - mungers=None, + is_property=True, ) # diff --git a/web3/_utils/miner.py b/web3/_utils/miner.py index 873f296d95..f39c99953e 100644 --- a/web3/_utils/miner.py +++ b/web3/_utils/miner.py @@ -51,19 +51,19 @@ stop: Method[Callable[[], bool]] = Method( RPC.miner_stop, - mungers=None, + is_property=True, ) start_auto_dag: Method[Callable[[], bool]] = Method( RPC.miner_startAutoDag, - mungers=None, + is_property=True, ) stop_auto_dag: Method[Callable[[], bool]] = Method( RPC.miner_stopAutoDag, - mungers=None, + is_property=True, ) diff --git a/web3/_utils/personal.py b/web3/_utils/personal.py index 2bb2eda77d..d9690cc44a 100644 --- a/web3/_utils/personal.py +++ b/web3/_utils/personal.py @@ -44,13 +44,13 @@ list_accounts: Method[Callable[[], List[ChecksumAddress]]] = Method( RPC.personal_listAccounts, - mungers=None, + is_property=True, ) list_wallets: Method[Callable[[], List[GethWallet]]] = Method( RPC.personal_listWallets, - mungers=None, + is_property=True, ) diff --git a/web3/_utils/txpool.py b/web3/_utils/txpool.py index 052f8b35ca..7af244b52b 100644 --- a/web3/_utils/txpool.py +++ b/web3/_utils/txpool.py @@ -16,17 +16,17 @@ content: Method[Callable[[], TxPoolContent]] = Method( RPC.txpool_content, - mungers=None, + is_property=True, ) inspect: Method[Callable[[], TxPoolInspect]] = Method( RPC.txpool_inspect, - mungers=None, + is_property=True, ) status: Method[Callable[[], TxPoolStatus]] = Method( RPC.txpool_status, - mungers=None, + is_property=True, ) diff --git a/web3/eth.py b/web3/eth.py index ef1c134911..5c84b14a6c 100644 --- a/web3/eth.py +++ b/web3/eth.py @@ -119,7 +119,7 @@ class BaseEth(Module): _gas_price: Method[Callable[[], Wei]] = Method( RPC.eth_gasPrice, - mungers=None, + is_property=True, ) @property @@ -244,7 +244,7 @@ def estimate_gas_munger( _max_priority_fee: Method[Callable[..., Wei]] = Method( RPC.eth_maxPriorityFeePerGas, - mungers=None, + is_property=True, ) def get_block_munger( @@ -267,12 +267,12 @@ def get_block_munger( get_block_number: Method[Callable[[], BlockNumber]] = Method( RPC.eth_blockNumber, - mungers=None, + is_property=True, ) get_coinbase: Method[Callable[[], ChecksumAddress]] = Method( RPC.eth_coinbase, - mungers=None, + is_property=True, ) def block_id_munger( @@ -315,27 +315,27 @@ def call_munger( _get_accounts: Method[Callable[[], Tuple[ChecksumAddress]]] = Method( RPC.eth_accounts, - mungers=None, + is_property=True, ) _get_hashrate: Method[Callable[[], int]] = Method( RPC.eth_hashrate, - mungers=None, + is_property=True, ) _chain_id: Method[Callable[[], int]] = Method( RPC.eth_chainId, - mungers=None, + is_property=True, ) _is_mining: Method[Callable[[], bool]] = Method( RPC.eth_mining, - mungers=None, + is_property=True, ) _is_syncing: Method[Callable[[], Union[SyncStatus, bool]]] = Method( RPC.eth_syncing, - mungers=None, + is_property=True, ) _get_transaction_receipt: Method[Callable[[_Hash32], TxReceipt]] = Method( @@ -565,7 +565,7 @@ def icapNamereg(self) -> NoReturn: _protocol_version: Method[Callable[[], str]] = Method( RPC.eth_protocolVersion, - mungers=None, + is_property=True, ) @property @@ -983,7 +983,7 @@ def getCompilers(self) -> NoReturn: get_work: Method[Callable[[], List[HexBytes]]] = Method( RPC.eth_getWork, - mungers=None, + is_property=True, ) @deprecated_for("generate_gas_price") diff --git a/web3/method.py b/web3/method.py index dfc88800e9..ce94e75915 100644 --- a/web3/method.py +++ b/web3/method.py @@ -61,6 +61,14 @@ def inner(args: Any) -> TReturn: return inner +def _set_mungers(mungers: Optional[Sequence[Munger]], is_property: bool) -> Sequence[Any]: + return ( + mungers if mungers + else [default_munger] if is_property + else [default_root_munger] + ) + + def default_munger(_module: "Module", *args: Any, **kwargs: Any) -> Tuple[()]: if not args and not kwargs: return () @@ -81,7 +89,7 @@ class Method(Generic[TFunc]): Calls to the Method go through these steps: 1. input munging - includes normalization, parameter checking, early parameter - formatting. Any processing on the input parameters that need to happen before + formatting. Any processing on the input parameters that need to happen before json_rpc method string selection occurs. A note about mungers: The first (root) munger should reflect the desired @@ -122,15 +130,16 @@ def __init__( result_formatters: Optional[Callable[..., TReturn]] = None, null_result_formatters: Optional[Callable[..., TReturn]] = None, method_choice_depends_on_args: Optional[Callable[..., RPCEndpoint]] = None, + is_property: bool = False, ): - self.json_rpc_method = json_rpc_method - self.mungers = mungers or [default_munger] + self.mungers = _set_mungers(mungers, is_property) self.request_formatters = request_formatters or get_request_formatters self.result_formatters = result_formatters or get_result_formatters self.error_formatters = get_error_formatters self.null_result_formatters = null_result_formatters or get_null_result_formatters self.method_choice_depends_on_args = method_choice_depends_on_args + self.is_property = is_property def __get__( self, obj: Optional["Module"] = None, obj_type: Optional[Type["Module"]] = None @@ -167,8 +176,8 @@ def input_munger( root_munger = next(mungers_iter) munged_inputs = pipe( root_munger(module, *args, **kwargs), - *map(lambda m: _munger_star_apply(functools.partial(m, module)), mungers_iter)) - + *map(lambda m: _munger_star_apply(functools.partial(m, module)), mungers_iter) + ) return munged_inputs def process_params( @@ -194,13 +203,15 @@ def process_params( params = [] method = self.method_selector_fn() - response_formatters = (self.result_formatters(method, module), - self.error_formatters(method), - self.null_result_formatters(method),) - - request = (method, - _apply_request_formatters(params, self.request_formatters(method))) - + response_formatters = ( + self.result_formatters(method, module), + self.error_formatters(method), + self.null_result_formatters(method), + ) + request = ( + method, + _apply_request_formatters(params, self.request_formatters(method)) + ) return request, response_formatters diff --git a/web3/module.py b/web3/module.py index 49fdfb9209..de3343e5a8 100644 --- a/web3/module.py +++ b/web3/module.py @@ -3,6 +3,7 @@ Any, Callable, Coroutine, + Dict, TypeVar, Union, ) @@ -91,3 +92,14 @@ def __init__(self, w3: "Web3") -> None: self.retrieve_caller_fn = retrieve_blocking_method_call_fn(w3, self) self.w3 = w3 self.codec: ABICodec = w3.codec + + def attach_methods( + self, + methods: Dict[str, Method[Callable[..., Any]]], + ) -> None: + for method_name, method_class in methods.items(): + klass = ( + method_class.__get__(obj=self)() if method_class.is_property else + method_class.__get__(obj=self) + ) + setattr(self, method_name, klass) diff --git a/web3/parity.py b/web3/parity.py index 84bcaa5c44..4b47a40b21 100644 --- a/web3/parity.py +++ b/web3/parity.py @@ -94,7 +94,7 @@ class Parity(Module): enode: Method[Callable[[], str]] = Method( RPC.parity_enode, - mungers=None, + is_property=True, ) """ property default_block """ @@ -141,7 +141,7 @@ def list_storage_keys_munger( net_peers: Method[Callable[[], ParityNetPeers]] = Method( RPC.parity_netPeers, - mungers=None + is_property=True ) add_reserved_peer: Method[Callable[[EnodeURI], bool]] = Method( @@ -217,7 +217,7 @@ def trace_transactions_munger( mode: Method[Callable[[], ParityMode]] = Method( RPC.parity_mode, - mungers=None + is_property=True ) # Deprecated Methods From 061fb6693e4a2c16a91c88c9b11df65227225902 Mon Sep 17 00:00:00 2001 From: Felipe Selmo Date: Thu, 10 Mar 2022 09:18:39 -0300 Subject: [PATCH 30/57] More tests for method class and cleanup from PR #2383 comments --- tests/core/method-class/test_method.py | 99 ++++++++++++++++++++------ tests/core/module-class/test_module.py | 19 ++--- web3/method.py | 16 +++-- 3 files changed, 99 insertions(+), 35 deletions(-) diff --git a/tests/core/method-class/test_method.py b/tests/core/method-class/test_method.py index 44e132f4b6..9e0bb64e0d 100644 --- a/tests/core/method-class/test_method.py +++ b/tests/core/method-class/test_method.py @@ -3,6 +3,9 @@ ) import pytest +from eth_utils import ( + ValidationError, +) from eth_utils.toolz import ( compose, ) @@ -69,7 +72,7 @@ def test_get_formatters_non_falsy_config_retrieval(): first_formatter = (method.request_formatters(method_name).first,) all_other_formatters = method.request_formatters(method_name).funcs assert len(first_formatter + all_other_formatters) == 2 - # assert method.request_formatters('eth_nonmatching') == 'nonmatch' + assert (method.request_formatters('eth_getBalance').first,) == first_formatter def test_input_munger_parameter_passthrough_matching_arity(): @@ -89,9 +92,17 @@ def test_input_munger_parameter_passthrough_mismatch_arity(): method.input_munger(object(), ['first', 'second', 'third'], {}) -def test_input_munger_falsy_config_result_in_default_munger(): +def test_default_input_munger_with_no_input_parameters(): method = Method( - mungers=[], + json_rpc_method='eth_method', + ) + assert method.input_munger(object(), [], {}) == [] + + +@pytest.mark.parametrize('empty', ([], (), None), ids=['empty-list', 'empty-tuple', 'None']) +def test_empty_input_munger_with_no_input_parameters(empty): + method = Method( + mungers=empty, json_rpc_method='eth_method', ) assert method.input_munger(object(), [], {}) == [] @@ -99,14 +110,69 @@ def test_input_munger_falsy_config_result_in_default_munger(): def test_default_input_munger_with_input_parameters(): method = Method( - mungers=[], json_rpc_method='eth_method', ) assert method.input_munger(object(), [1], {}) == [1] +@pytest.mark.parametrize('empty', ([], (), None), ids=['empty-list', 'empty-tuple', 'None']) +def test_empty_input_mungers_with_input_parameters(empty): + method = Method( + mungers=empty, + json_rpc_method='eth_method', + ) + assert method.input_munger(object(), [1], {}) == [1] + + +def test_default_munger_for_property_with_no_input_parameters(): + method = Method( + is_property=True, + json_rpc_method='eth_method', + ) + assert method.input_munger(object(), [], {}) == () + + +@pytest.mark.parametrize('empty', ([], (), None), ids=['empty-list', 'empty-tuple', 'None']) +def test_empty_mungers_for_property_with_no_input_parameters(empty): + method = Method( + is_property=True, + mungers=empty, + json_rpc_method='eth_method', + ) + assert method.input_munger(object(), [], {}) == () + + +def test_default_munger_for_property_with_input_parameters_raises_ValidationError(): + method = Method( + is_property=True, + json_rpc_method='eth_method', + ) + with pytest.raises(ValidationError, match='Parameters cannot be passed to a property'): + method.input_munger(object(), [1], {}) + + +@pytest.mark.parametrize('empty', ([], (), None), ids=['empty-list', 'empty-tuple', 'None']) +def test_empty_mungers_for_property_with_input_parameters_raises_ValidationError(empty): + method = Method( + is_property=True, + mungers=empty, + json_rpc_method='eth_method', + ) + with pytest.raises(ValidationError, match='Parameters cannot be passed to a property'): + method.input_munger(object(), [1], {}) + + +def test_property_with_mungers_raises_ValidationError(): + with pytest.raises(ValidationError, match='Mungers cannot be used with a property'): + Method( + is_property=True, + mungers=[lambda m, z, y: 'success'], + json_rpc_method='eth_method', + ) + + @pytest.mark.parametrize( - "method_config,args,kwargs,expected_request_result,expected_result_formatters_len", + "method_config,args,kwargs,expected_request_result", ( ( { @@ -115,17 +181,15 @@ def test_default_input_munger_with_input_parameters(): [], {}, ValueError, - 2 ), ( { 'mungers': [], 'json_rpc_method': 'eth_getBalance', }, - ['unexpected_argument'], + ['only_the_first_argument_but_expects_two'], {}, IndexError, - 2 ), ( { @@ -135,7 +199,6 @@ def test_default_input_munger_with_input_parameters(): ['0x0000000000000000000000000000000000000000', 3], {}, ('eth_getBalance', (('0x' + '00' * 20), "0x3")), - 2 ), ( { @@ -145,7 +208,6 @@ def test_default_input_munger_with_input_parameters(): ['0x0000000000000000000000000000000000000000', 3], {}, ('eth_getBalance', (('0x' + '00' * 20), "0x3")), - 2 ), ( { @@ -158,7 +220,6 @@ def test_default_input_munger_with_input_parameters(): [1, 2, 3, ('0x' + '00' * 20)], {}, ('eth_getBalance', (('0x' + '00' * 20), "1")), - 2, ), ( { @@ -171,7 +232,6 @@ def test_default_input_munger_with_input_parameters(): [1, 2, 3, 4], {}, TypeError, - 2, ), ( { @@ -181,7 +241,6 @@ def test_default_input_munger_with_input_parameters(): ('0x0000000000000000000000000000000000000000', 3), {}, ('eth_getBalance', ('0x0000000000000000000000000000000000000000', '0x3')), - 2, ), ( { @@ -190,7 +249,6 @@ def test_default_input_munger_with_input_parameters(): ('0x0000000000000000000000000000000000000000', 3), {}, ('eth_getBalance', ('0x0000000000000000000000000000000000000000', '0x3')), - 2, ), ( { @@ -203,7 +261,6 @@ def test_default_input_munger_with_input_parameters(): [('0x' + '00' * 20), 1, 2, 3], {}, ('eth_getBalance', (('0x' + '00' * 20), '1')), - 2, ), ( { @@ -213,7 +270,6 @@ def test_default_input_munger_with_input_parameters(): [], {}, ('eth_chainId', ()), - 2, ), ( { @@ -223,16 +279,15 @@ def test_default_input_munger_with_input_parameters(): [], {}, ('eth_chainId', ()), - 2, ), ), ids=[ 'raises-error-no-rpc-method', - 'test-unexpected-arg', + 'test-missing-argument', 'test-rpc-method-as-string', 'test-rpc-method-as-callable', 'test-arg-munger', - 'test-munger-wrong-length-arg', + 'test-munger-too-many-args', 'test-request-formatters-default-root-munger-explicit', 'test-request-formatters-default-root-munger-implicit', 'test-mungers-and-request-formatters', @@ -245,7 +300,7 @@ def test_process_params( args, kwargs, expected_request_result, - expected_result_formatters_len): +): if isclass(expected_request_result) and issubclass(expected_request_result, Exception): with pytest.raises(expected_request_result): @@ -257,7 +312,9 @@ def test_process_params( assert request_params == expected_request_result first_formatter = (output_formatter[0].first,) all_other_formatters = output_formatter[0].funcs - assert len(first_formatter + all_other_formatters) == expected_result_formatters_len + + # the expected result formatters length is 2 + assert len(first_formatter + all_other_formatters) == 2 def keywords(module, keyword_one, keyword_two): diff --git a/tests/core/module-class/test_module.py b/tests/core/module-class/test_module.py index 3654a7df8d..ec67fa8d46 100644 --- a/tests/core/module-class/test_module.py +++ b/tests/core/module-class/test_module.py @@ -59,17 +59,20 @@ def test_attach_methods_to_module(web3_with_external_modules): def test_attach_methods_with_mungers(web3_with_external_modules): w3 = web3_with_external_modules + # `method1` uses `eth_getBlockByNumber` but makes use of unique mungers w3.module1.attach_methods({ 'method1': Method('eth_getBlockByNumber', mungers=[ - lambda _method, block_id, f, _z: (block_id, f), - lambda _m, block_id, _f: (block_id - 1,), + lambda _method, block_id, full_transactions: (block_id, full_transactions), + # take the user-provided `block_id` and subtract 1 + lambda _method, block_id, full_transactions: (block_id - 1, full_transactions), ]), }) - assert w3.eth.get_block(0)['baseFeePerGas'] == 1000000000 - assert w3.eth.get_block(1)['baseFeePerGas'] == 875000000 + assert w3.eth.get_block(0, False)['baseFeePerGas'] == 1000000000 + assert w3.eth.get_block(1, False)['baseFeePerGas'] == 875000000 - # `method1` should take a higher block number than `eth_getBlockByNumber` due to mungers and no - # other params should matter - assert w3.module1.method1(1, False, '_is_never_used_')['baseFeePerGas'] == 1000000000 - assert w3.module1.method1(2, '_will_be_overridden_', None)['baseFeePerGas'] == 875000000 + # Testing the mungers work: + # `method1` also calls 'eth_getBlockByNumber' but subtracts 1 from the user-provided `block_id` + # due to the second munger. So, `0` from above is a `1` here and `1` is `2`. + assert w3.module1.method1(1, False)['baseFeePerGas'] == 1000000000 + assert w3.module1.method1(2, False)['baseFeePerGas'] == 875000000 diff --git a/web3/method.py b/web3/method.py index ce94e75915..9e0e6b822f 100644 --- a/web3/method.py +++ b/web3/method.py @@ -15,6 +15,9 @@ ) import warnings +from eth_utils import ( + ValidationError, +) from eth_utils.curried import ( to_tuple, ) @@ -62,6 +65,9 @@ def inner(args: Any) -> TReturn: def _set_mungers(mungers: Optional[Sequence[Munger]], is_property: bool) -> Sequence[Any]: + if is_property and mungers: + raise ValidationError("Mungers cannot be used with a property.") + return ( mungers if mungers else [default_munger] if is_property @@ -70,10 +76,9 @@ def _set_mungers(mungers: Optional[Sequence[Munger]], is_property: bool) -> Sequ def default_munger(_module: "Module", *args: Any, **kwargs: Any) -> Tuple[()]: - if not args and not kwargs: - return () - else: - raise TypeError("Parameters passed to method without parameter mungers defined.") + if args or kwargs: + raise ValidationError("Parameters cannot be passed to a property.") + return () def default_root_munger(_module: "Module", *args: Any) -> List[Any]: @@ -136,7 +141,6 @@ def __init__( self.mungers = _set_mungers(mungers, is_property) self.request_formatters = request_formatters or get_request_formatters self.result_formatters = result_formatters or get_result_formatters - self.error_formatters = get_error_formatters self.null_result_formatters = null_result_formatters or get_null_result_formatters self.method_choice_depends_on_args = method_choice_depends_on_args self.is_property = is_property @@ -205,7 +209,7 @@ def process_params( method = self.method_selector_fn() response_formatters = ( self.result_formatters(method, module), - self.error_formatters(method), + get_error_formatters(method), self.null_result_formatters(method), ) request = ( From 9ba6fec2b13a62302318035edeb8b97797d1ec1f Mon Sep 17 00:00:00 2001 From: Mahmoud Harmouch Date: Fri, 11 Mar 2022 23:32:41 +0200 Subject: [PATCH 31/57] bump docker base image & rm parity env var! (#2369) * :zap: bump docker base image and parity version! Signed-off-by: Harmouch101 * :memo: add newsfragment! Signed-off-by: Harmouch101 * :zap: rm parity tests from docker. Signed-off-by: Harmouch101 * :memo: update newsfragment. Signed-off-by: Harmouch101 --- Dockerfile | 3 +-- docker-compose.yml | 2 -- newsfragments/2369.misc.rst | 1 + 3 files changed, 2 insertions(+), 4 deletions(-) create mode 100644 newsfragments/2369.misc.rst diff --git a/Dockerfile b/Dockerfile index 912a2961e2..8fe1aabb26 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,6 @@ -FROM python:3.6 +FROM python:3.9 # Set up code directory -RUN mkdir -p /usr/src/app WORKDIR /usr/src/app # Install Linux dependencies diff --git a/docker-compose.yml b/docker-compose.yml index c130de201a..2ffdfaede2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,8 +3,6 @@ services: sandbox: build: context: . - environment: - PARITY_VERSION: v2.3.5 volumes: - .:/code command: tail -f /dev/null diff --git a/newsfragments/2369.misc.rst b/newsfragments/2369.misc.rst new file mode 100644 index 0000000000..cede2588df --- /dev/null +++ b/newsfragments/2369.misc.rst @@ -0,0 +1 @@ +bump docker base image to ``3.9`` and remove parity tests from docker. \ No newline at end of file From ca662c879e95e9e184d9dfdb78855492e1d7db23 Mon Sep 17 00:00:00 2001 From: kclowes Date: Mon, 14 Mar 2022 10:55:43 -0600 Subject: [PATCH 32/57] Add async chain_id setter (#2376) * Add async chain_id setter * Add newsfragment for async chain_id --- newsfragments/2376.bugfix.rst | 1 + tests/core/eth-module/test_eth_properties.py | 29 ++++++++++++++++++++ web3/eth.py | 9 +++++- 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 newsfragments/2376.bugfix.rst diff --git a/newsfragments/2376.bugfix.rst b/newsfragments/2376.bugfix.rst new file mode 100644 index 0000000000..8518a5427e --- /dev/null +++ b/newsfragments/2376.bugfix.rst @@ -0,0 +1 @@ +Add async default_chain_id and chain_id setter diff --git a/tests/core/eth-module/test_eth_properties.py b/tests/core/eth-module/test_eth_properties.py index 596222b62a..c24070eb60 100644 --- a/tests/core/eth-module/test_eth_properties.py +++ b/tests/core/eth-module/test_eth_properties.py @@ -1,5 +1,23 @@ import pytest +from web3 import Web3 +from web3.eth import ( + AsyncEth, +) +from web3.providers.eth_tester.main import ( + AsyncEthereumTesterProvider, +) + + +@pytest.fixture +def async_w3(): + return Web3( + AsyncEthereumTesterProvider(), + middlewares=[], + modules={ + 'eth': (AsyncEth,), + }) + def test_eth_protocol_version(w3): with pytest.warns(DeprecationWarning): @@ -28,3 +46,14 @@ def test_set_chain_id(w3): w3.eth.chain_id = None assert w3.eth.chain_id == 61 + + +@pytest.mark.asyncio +async def test_async_set_chain_id(async_w3): + assert await async_w3.eth.chain_id == 61 + + async_w3.eth.chain_id = 72 + assert await async_w3.eth.chain_id == 72 + + async_w3.eth.chain_id = None + assert await async_w3.eth.chain_id == 61 diff --git a/web3/eth.py b/web3/eth.py index 5c84b14a6c..54c88a41d1 100644 --- a/web3/eth.py +++ b/web3/eth.py @@ -358,7 +358,14 @@ async def block_number(self) -> BlockNumber: @property async def chain_id(self) -> int: - return await self._chain_id() # type: ignore + if self._default_chain_id is None: + return await self._chain_id() # type: ignore + else: + return self._default_chain_id + + @chain_id.setter + def chain_id(self, value: int) -> None: + self._default_chain_id = value @property async def coinbase(self) -> ChecksumAddress: From 533e292a355e1a1230f2e3d7e767911ba3e568fd Mon Sep 17 00:00:00 2001 From: Tadashi Date: Tue, 22 Mar 2022 17:16:13 +0100 Subject: [PATCH 33/57] Update filters.rst (#2322) * Update filters.rst Since 2020 Infura added [support to eth_getFilterChanges over HTTPS](https://blog.infura.io/filters-support-over-https/) (though limited). * Add newsfragment Co-authored-by: kclowes --- docs/filters.rst | 7 ++++--- newsfragments/2322.doc.rst | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 newsfragments/2322.doc.rst diff --git a/docs/filters.rst b/docs/filters.rst index deab2d7f8c..cef28b8b95 100644 --- a/docs/filters.rst +++ b/docs/filters.rst @@ -44,8 +44,9 @@ The :meth:`web3.eth.Eth.filter` method can be used to setup filters for: .. note :: Creating event filters requires that your Ethereum node has an API support enabled for filters. - It does not work with Infura nodes. To get event logs on Infura or other - stateless nodes please see :class:`web3.contract.ContractEvents`. + Note that Infura support for filters does not offer access to `pending` filters. + To get event logs on other stateless nodes please see :class:`web3.contract.ContractEvents`. + Filter Class @@ -179,7 +180,7 @@ Getting events without setting up a filter ------------------------------------------ You can query an Ethereum node for direct fetch of events, without creating a filter first. -This works on all node types, including Infura. +This works on all node types. For examples see :meth:`web3.contract.ContractEvents.getLogs`. diff --git a/newsfragments/2322.doc.rst b/newsfragments/2322.doc.rst new file mode 100644 index 0000000000..888fa618c9 --- /dev/null +++ b/newsfragments/2322.doc.rst @@ -0,0 +1 @@ +Clarify info about Infura filters over HTTP From 7635de9f3de3c96a8e906f52409502194202a312 Mon Sep 17 00:00:00 2001 From: Kyle Benac Date: Fri, 1 Apr 2022 10:50:07 -0700 Subject: [PATCH 34/57] Add Infura example to middleware docs (#2410) * Add Infura example to middleware docs * Add newsfragment --- docs/middleware.rst | 13 +++++++++++++ newsfragments/2410.doc.rst | 1 + 2 files changed, 14 insertions(+) create mode 100644 newsfragments/2410.doc.rst diff --git a/docs/middleware.rst b/docs/middleware.rst index 6448c2e745..5cb04e9c32 100644 --- a/docs/middleware.rst +++ b/docs/middleware.rst @@ -458,6 +458,19 @@ this middleware to have any effect. >>> w3.middleware_onion.add(construct_sign_and_send_raw_middleware(acct)) >>> w3.eth.default_account = acct.address +:ref:`Hosted nodes` (like Infura or Alchemy) only support signed transactions. This often results in ``send_raw_transaction`` being used repeatedly. Instead, we can automate this process with ``construct_sign_and_send_raw_middleware(private_key_or_account)``. + +.. code-block:: python + + >>> from web3 import Web3 + >>> w3 = Web3(Web3.HTTPProvider('HTTP_ENDPOINT')) + >>> from web3.middleware import construct_sign_and_send_raw_middleware + >>> from eth_account import Account + >>> import os + >>> acct = w3.eth.account.from_key(os.environ.get('PRIVATE_KEY')) + >>> w3.middleware_onion.add(construct_sign_and_send_raw_middleware(acct)) + >>> w3.eth.default_account = acct.address + Now you can send a transaction from acct.address without having to build and sign each raw transaction. When making use of this signing middleware, when sending dynamic fee transactions (recommended over legacy transactions), diff --git a/newsfragments/2410.doc.rst b/newsfragments/2410.doc.rst new file mode 100644 index 0000000000..28f8a043e1 --- /dev/null +++ b/newsfragments/2410.doc.rst @@ -0,0 +1 @@ +Add example for the ``construct_sign_and_send_raw_middleware`` when connected to a hosted node From cde7a0600e2a6308b02bda244657f816bab2eda0 Mon Sep 17 00:00:00 2001 From: kclowes Date: Mon, 4 Apr 2022 15:09:22 -0600 Subject: [PATCH 35/57] Implement ENS set_text and get_text (#2395) * add lookup text record value * Add 'get_text' method * Add set_text method * Add docs for get_text/set_text Co-authored-by: smk762 Co-authored-by: smk762 <35845239+smk762@users.noreply.github.com> --- docs/ens_overview.rst | 34 +++++++++++++++ ens/abis.py | 79 ++++++++++++++++++++++++++++++++++ ens/main.py | 53 +++++++++++++++++++++++ newsfragments/2286.feature.rst | 1 + setup.py | 2 +- tests/ens/test_get_text.py | 66 ++++++++++++++++++++++++++++ 6 files changed, 234 insertions(+), 1 deletion(-) create mode 100644 newsfragments/2286.feature.rst create mode 100644 tests/ens/test_get_text.py diff --git a/docs/ens_overview.rst b/docs/ens_overview.rst index 471f456a96..f01a4e38c0 100644 --- a/docs/ens_overview.rst +++ b/docs/ens_overview.rst @@ -162,3 +162,37 @@ Wait for the transaction to be mined, then: :: assert ns.name('0x5B2063246F2191f18F2675ceDB8b28102e957458') == 'jasoncarver.eth' + +Set Text Metadata for an ENS Record +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +As the owner of an ENS record, you can add text metadata. +A list of supported fields can be found in the +`ENS documentation `_. +You'll need to setup the address first, and then the text can be set: + +:: + + ns.setup_address('jasoncarver.eth', 0x5B2063246F2191f18F2675ceDB8b28102e957458) + ns.set_text('jasoncarver.eth', 'url', 'https://example.com') + +A transaction dictionary can be passed as the last argument if desired: + +:: + + transaction_dict = {'from': '0x123...'} + ns.set_text('jasoncarver.eth', 'url', 'https://example.com', transaction_dict) + +If the transaction dictionary is not passed, sensible defaults will be used, and if +a transaction dictionary is passed but does not have a ``from`` value, +the default will be the ``owner``. + +Read Text Metadata for an ENS Record +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Anyone can read the data from an ENS Record: + +:: + + url = ns.get_text('jasoncarver.eth', 'url') + assert url == 'https://example.com' diff --git a/ens/abis.py b/ens/abis.py index d29b4d896f..5ce9474df2 100644 --- a/ens/abis.py +++ b/ens/abis.py @@ -975,6 +975,29 @@ } ], "payable": False, + "stateMutability": "view", + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "node", + "type": "bytes32" + }, + { + "name": "key", + "type": "string" + }, + { + "name": "value", + "type": "string" + } + ], + "name": "setText", + "outputs": [], + "payable": False, + "stateMutability": "nonpayable", "type": "function" }, { @@ -1001,6 +1024,7 @@ } ], "payable": False, + "stateMutability": "view", "type": "function" }, { @@ -1022,6 +1046,7 @@ "name": "setPubkey", "outputs": [], "payable": False, + "stateMutability": "nonpayable", "type": "function" }, { @@ -1040,6 +1065,7 @@ } ], "payable": False, + "stateMutability": "view", "type": "function" }, { @@ -1058,6 +1084,30 @@ } ], "payable": False, + "stateMutability": "view", + "type": "function" + }, + { + "constant": True, + "inputs": [ + { + "name": "node", + "type": "bytes32" + }, + { + "name": "key", + "type": "string" + } + ], + "name": "text", + "outputs": [ + { + "name": "ret", + "type": "string" + } + ], + "payable": False, + "stateMutability": "view", "type": "function" }, { @@ -1079,6 +1129,7 @@ "name": "setABI", "outputs": [], "payable": False, + "stateMutability": "nonpayable", "type": "function" }, { @@ -1097,6 +1148,7 @@ } ], "payable": False, + "stateMutability": "view", "type": "function" }, { @@ -1114,6 +1166,7 @@ "name": "setName", "outputs": [], "payable": False, + "stateMutability": "nonpayable", "type": "function" }, { @@ -1131,6 +1184,7 @@ "name": "setContent", "outputs": [], "payable": False, + "stateMutability": "nonpayable", "type": "function" }, { @@ -1153,6 +1207,7 @@ } ], "payable": False, + "stateMutability": "view", "type": "function" }, { @@ -1170,6 +1225,7 @@ "name": "setAddr", "outputs": [], "payable": False, + "stateMutability": "nonpayable", "type": "function" }, { @@ -1180,6 +1236,7 @@ } ], "payable": False, + "stateMutability": "nonpayable", "type": "constructor" }, { @@ -1271,6 +1328,28 @@ ], "name": "PubkeyChanged", "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "name": "node", + "type": "bytes32" + }, + { + "indexed": True, + "name": "indexedKey", + "type": "string" + }, + { + "indexed": False, + "name": "key", + "type": "string" + } + ], + "name": "TextChanged", + "type": "event" } ] diff --git a/ens/main.py b/ens/main.py index d38fc3cedb..5cc4e98fb6 100644 --- a/ens/main.py +++ b/ens/main.py @@ -23,6 +23,9 @@ is_checksum_address, to_checksum_address, ) +from eth_utils.toolz import ( + merge, +) from hexbytes import ( HexBytes, ) @@ -282,6 +285,56 @@ def owner(self, name: str) -> ChecksumAddress: node = raw_name_to_hash(name) return self.ens.caller.owner(node) + def get_text(self, name: str, key: str) -> str: + """ + Get the value of a text record by key from an ENS name. + + :param str name: ENS name to look up + :param str key: ENS name's text record key + :return: ENS name's text record value + :rtype: str + :raises UnownedName: if no one owns `name` + """ + node = raw_name_to_hash(name) + normal_name = normalize_name(name) + + r = self.resolver(normal_name) + if r: + return r.caller.text(node, key) + else: + raise UnownedName("claim domain using setup_address() first") + + def set_text( + self, + name: str, + key: str, + value: str, + transact: "TxParams" = {} + ) -> HexBytes: + """ + Set the value of a text record of an ENS name. + + :param str name: ENS name + :param str key: Name of the attribute to set + :param str value: Value to set the attribute to + :param dict transact: the transaction configuration, like in + :meth:`~web3.eth.Eth.send_transaction` + :return: Transaction hash + :rtype: HexBytes + :raises UnownedName: if no one owns `name` + """ + owner = self.owner(name) + node = raw_name_to_hash(name) + normal_name = normalize_name(name) + + transaction_dict = merge({'from': owner}, transact) + + r = self.resolver(normal_name) + if r: + return r.functions.setText(node, key, value).transact(transaction_dict) + else: + raise UnownedName("claim domain using setup_address() first") + def setup_owner( self, name: str, diff --git a/newsfragments/2286.feature.rst b/newsfragments/2286.feature.rst new file mode 100644 index 0000000000..e65010cec7 --- /dev/null +++ b/newsfragments/2286.feature.rst @@ -0,0 +1 @@ +Add 'get_text' method to look up ENS text record values diff --git a/setup.py b/setup.py index 84ff7a5190..315808f8ee 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ "mypy==0.910", "types-setuptools>=57.4.4,<58", "types-requests>=2.26.1,<3", - "types-protobuf>=3.18.2,<4", + "types-protobuf==3.19.13", ], 'docs': [ "mock", diff --git a/tests/ens/test_get_text.py b/tests/ens/test_get_text.py new file mode 100644 index 0000000000..82da916a67 --- /dev/null +++ b/tests/ens/test_get_text.py @@ -0,0 +1,66 @@ +import pytest + +from eth_tester.exceptions import ( + TransactionFailed, +) + +from ens.exceptions import ( + UnownedName, +) +from web3 import Web3 + + +@pytest.mark.parametrize('key,expected', ( + ('avatar', 'tester.jpeg'), + ('email', 'user@example.com'), + ('url', 'http://example.com'), + ('description', 'a test'), + ('notice', 'this contract is a test contract'), +),) +def test_set_text_unowned_name(ens, key, expected): + with pytest.raises(UnownedName): + ens.set_text('tester.eth', key, expected) + + +@pytest.mark.parametrize('key,expected', ( + ('avatar', 'tester.jpeg'), + ('email', 'user@example.com'), + ('url', 'http://example.com'), + ('description', 'a test'), + ('notice', 'this contract is a test contract'), +),) +def test_get_text(ens, key, expected): + address = ens.w3.eth.accounts[2] + ens.setup_address('tester.eth', address) + owner = ens.owner('tester.eth') + assert address == owner + ens.set_text('tester.eth', key, expected) + assert ens.get_text('tester.eth', key) == expected + + # teardown + ens.setup_address('tester.eth', None) + + +def test_set_text_fails_with_bad_address(ens): + address = ens.w3.eth.accounts[2] + ens.setup_address('tester.eth', address) + zero_address = '0x' + '00' * 20 + with pytest.raises(TransactionFailed): + ens.set_text('tester.eth', 'url', 'http://example.com', transact={'from': zero_address}) + + +def test_set_text_pass_in_transaction_dict(ens): + address = ens.w3.eth.accounts[2] + ens.setup_address('tester.eth', address) + ens.set_text('tester.eth', 'url', 'http://example.com', transact={'from': address}) + ens.set_text( + 'tester.eth', + 'avatar', + 'example.jpeg', + transact={'gasPrice': Web3.toWei(100, 'gwei')} + ) + assert ens.get_text('tester.eth', 'url') == 'http://example.com' + assert ens.get_text('tester.eth', 'avatar') == 'example.jpeg' + + # teardown + ens.setup_address('tester.eth', None) From 827e2e37d707fa048473d91e5df1fafccb155632 Mon Sep 17 00:00:00 2001 From: Felipe Selmo Date: Fri, 8 Apr 2022 14:58:06 -0600 Subject: [PATCH 36/57] Validate forward resolution for reverse resolution by default - As outlined in the warning in the ENS docs, for the reverse resolution of a name for an address to be accurate, the forward resolution address must also match. Source at the time of this commit is here: https://docs.ens.domains/dapp-developer-guide/resolving-names#reverse-resolution. --- ens/main.py | 6 +++++- newsfragments/2420.feature.rst | 1 + tests/ens/test_setup_name.py | 11 +++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 newsfragments/2420.feature.rst diff --git a/ens/main.py b/ens/main.py index 5cc4e98fb6..465f640af6 100644 --- a/ens/main.py +++ b/ens/main.py @@ -152,7 +152,11 @@ def name(self, address: ChecksumAddress) -> Optional[str]: :type address: hex-string """ reversed_domain = address_to_reverse_domain(address) - return self.resolve(reversed_domain, get='name') + name = self.resolve(reversed_domain, get='name') + + # To be absolutely certain of the name, via reverse resolution, the address must match in + # the forward resolution + return name if to_checksum_address(address) == self.address(name) else None def setup_address( self, diff --git a/newsfragments/2420.feature.rst b/newsfragments/2420.feature.rst new file mode 100644 index 0000000000..f81eb8df89 --- /dev/null +++ b/newsfragments/2420.feature.rst @@ -0,0 +1 @@ +For ``ENS.name()``, validate that the forward resolution returns the same address as provided by the user as per the ENS documentation recommendation for Reverse Resolution. diff --git a/tests/ens/test_setup_name.py b/tests/ens/test_setup_name.py index 26fb0a7e3b..e81b73d9ae 100644 --- a/tests/ens/test_setup_name.py +++ b/tests/ens/test_setup_name.py @@ -69,6 +69,17 @@ def test_setup_name(ens, name, normalized_name, namehash_hex): # check that the correct owner is set: assert ens.owner(name) == owner + # setup name to point to new address + new_address = ens.w3.eth.accounts[4] + ens.setup_address(name, None) + ens.setup_name(name, new_address) + + # validate that ens.name() only returns a name if the forward resolution also returns the + # address + assert ens.name(new_address) == normalized_name # reverse resolution + assert ens.address(name) == new_address # forward resolution + assert not ens.name(address) + ens.setup_name(None, address) ens.setup_address(name, None) assert not ens.name(address) From 2cd75fd6891c6ac29d93c3c5a0200fe9b24c8b80 Mon Sep 17 00:00:00 2001 From: kclowes Date: Mon, 11 Apr 2022 15:37:52 -0600 Subject: [PATCH 37/57] Add flaky decorator to geth estimate_gas (#2418) * Add flaky decorator to geth gas estimation tests * Add newsfragment --- newsfragments/2418.misc.rst | 1 + tests/integration/go_ethereum/common.py | 33 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 newsfragments/2418.misc.rst diff --git a/newsfragments/2418.misc.rst b/newsfragments/2418.misc.rst new file mode 100644 index 0000000000..86392cb2a0 --- /dev/null +++ b/newsfragments/2418.misc.rst @@ -0,0 +1 @@ +Add flaky decorator to Geth gas estimation tests. diff --git a/tests/integration/go_ethereum/common.py b/tests/integration/go_ethereum/common.py index 914160dd04..67802a397e 100644 --- a/tests/integration/go_ethereum/common.py +++ b/tests/integration/go_ethereum/common.py @@ -1,4 +1,14 @@ import pytest +from typing import ( + TYPE_CHECKING, +) + +from eth_typing import ( + ChecksumAddress, +) +from flaky import ( + flaky, +) from web3._utils.module_testing import ( # noqa: F401 AsyncEthModuleTest, @@ -13,6 +23,11 @@ Web3ModuleTest, ) +if TYPE_CHECKING: + from web3 import ( # noqa: F401 + Web3, + ) + class GoEthereumTest(Web3ModuleTest): def _check_web3_clientVersion(self, client_version): @@ -40,6 +55,24 @@ def test_eth_protocol_version(self, w3): def test_eth_protocolVersion(self, w3): super().test_eth_protocolVersion(w3) + @flaky(max_runs=3) + def test_eth_estimate_gas( + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress + ) -> None: + super().test_eth_estimate_gas(w3, unlocked_account_dual_type) + + @flaky(max_runs=3) + def test_eth_estimateGas_deprecated( + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress + ) -> None: + super().test_eth_estimateGas_deprecated(w3, unlocked_account_dual_type) + + @flaky(max_runs=3) + def test_eth_estimate_gas_with_block( + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress + ) -> None: + super().test_eth_estimate_gas_with_block(w3, unlocked_account_dual_type) + class GoEthereumVersionModuleTest(VersionModuleTest): @pytest.mark.xfail(reason='eth_protocolVersion was removed in Geth 1.10.0') From eb8edd63c6895173b6877dd51fc2ad25f53b1e69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Schoentgen?= Date: Thu, 21 Apr 2022 16:53:51 +0200 Subject: [PATCH 38/57] Fix usage of obsolete IOError exception (#2434) * Fix usage of obsolete IOError exception `IOError` is an alias of `OSError` on Python 3. * Add newsfragment Co-authored-by: kclowes --- newsfragments/2434.breaking-change.rst | 1 + web3/_utils/windows.py | 4 ++-- web3/providers/async_base.py | 2 +- web3/providers/auto.py | 2 +- web3/providers/base.py | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 newsfragments/2434.breaking-change.rst diff --git a/newsfragments/2434.breaking-change.rst b/newsfragments/2434.breaking-change.rst new file mode 100644 index 0000000000..e1f03956b0 --- /dev/null +++ b/newsfragments/2434.breaking-change.rst @@ -0,0 +1 @@ +Move IOError -> OSError diff --git a/web3/_utils/windows.py b/web3/_utils/windows.py index b0a6a345e1..d46a71bdb2 100644 --- a/web3/_utils/windows.py +++ b/web3/_utils/windows.py @@ -17,12 +17,12 @@ def __init__(self, ipc_path: str) -> None: ipc_path, win32file.GENERIC_READ | win32file.GENERIC_WRITE, 0, None, win32file.OPEN_EXISTING, 0, None) except pywintypes.error as err: - raise IOError(err) + raise OSError(err) def recv(self, max_length: int) -> str: (err, data) = win32file.ReadFile(self.handle, max_length) if err: - raise IOError(err) + raise OSError(err) return data def sendall(self, data: str) -> Tuple[int, int]: diff --git a/web3/providers/async_base.py b/web3/providers/async_base.py index 6f2fa551ab..9f8b713259 100644 --- a/web3/providers/async_base.py +++ b/web3/providers/async_base.py @@ -102,7 +102,7 @@ def decode_rpc_response(self, raw_response: bytes) -> RPCResponse: async def isConnected(self) -> bool: try: response = await self.make_request(RPCEndpoint('web3_clientVersion'), []) - except IOError: + except OSError: return False assert response['jsonrpc'] == '2.0' diff --git a/web3/providers/auto.py b/web3/providers/auto.py index 362640b588..d1e223bece 100644 --- a/web3/providers/auto.py +++ b/web3/providers/auto.py @@ -89,7 +89,7 @@ def __init__( def make_request(self, method: RPCEndpoint, params: Any) -> RPCResponse: try: return self._proxy_request(method, params) - except IOError: + except OSError: return self._proxy_request(method, params, use_cache=False) def isConnected(self) -> bool: diff --git a/web3/providers/base.py b/web3/providers/base.py index 51f4ba123c..d43c22151e 100644 --- a/web3/providers/base.py +++ b/web3/providers/base.py @@ -101,7 +101,7 @@ def encode_rpc_request(self, method: RPCEndpoint, params: Any) -> bytes: def isConnected(self) -> bool: try: response = self.make_request(RPCEndpoint('web3_clientVersion'), []) - except IOError: + except OSError: return False assert response['jsonrpc'] == '2.0' From 15f7afbce7bf10bfd61bba9701fe0394033e5fca Mon Sep 17 00:00:00 2001 From: DB Date: Fri, 22 Apr 2022 05:51:07 -0400 Subject: [PATCH 39/57] deprecated estimateGas and buildTransaction in v5 contract --- web3/contract.py | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/web3/contract.py b/web3/contract.py index d8b7227bbd..38e51a5e4d 100644 --- a/web3/contract.py +++ b/web3/contract.py @@ -623,7 +623,7 @@ def _encode_data_in_transaction(self, *args: Any, **kwargs: Any) -> HexStr: return data @combomethod - def estimateGas( + def estimate_gas( self, transaction: Optional[TxParams] = None, block_identifier: Optional[BlockIdentifier] = None ) -> int: @@ -644,6 +644,14 @@ def estimateGas( estimate_gas_transaction, block_identifier=block_identifier ) + @combomethod + @deprecated_for("estimate_gas") + def estimateGas( + self, transaction: Optional[TxParams] = None, + block_identifier: Optional[BlockIdentifier] = None + ) -> int: + return self.estimate_gas(transaction, block_identifier) + @combomethod def transact(self, transaction: Optional[TxParams] = None) -> HexBytes: if transaction is None: @@ -663,7 +671,7 @@ def transact(self, transaction: Optional[TxParams] = None) -> HexBytes: return self.web3.eth.send_transaction(transact_transaction) @combomethod - def buildTransaction(self, transaction: Optional[TxParams] = None) -> TxParams: + def build_transaction(self, transaction: Optional[TxParams] = None) -> TxParams: """ Build the transaction dictionary without sending """ @@ -683,6 +691,11 @@ def buildTransaction(self, transaction: Optional[TxParams] = None) -> TxParams: built_transaction['to'] = Address(b'') return fill_transaction_defaults(self.web3, built_transaction) + @combomethod + @deprecated_for("build_transaction") + def buildTransaction(self, transaction: Optional[TxParams] = None) -> TxParams: + return self.build_transaction(transaction) + @staticmethod def check_forbidden_keys_in_transaction( transaction: TxParams, forbidden_keys: Optional[Collection[str]] = None @@ -1005,7 +1018,7 @@ def transact(self, transaction: Optional[TxParams] = None) -> HexBytes: **self.kwargs ) - def estimateGas( + def estimate_gas( self, transaction: Optional[TxParams] = None, block_identifier: Optional[BlockIdentifier] = None ) -> int: @@ -1015,9 +1028,9 @@ def estimateGas( estimate_gas_transaction = cast(TxParams, dict(**transaction)) if 'data' in estimate_gas_transaction: - raise ValueError("Cannot set 'data' field in estimateGas transaction") + raise ValueError("Cannot set 'data' field in estimate_gas transaction") if 'to' in estimate_gas_transaction: - raise ValueError("Cannot set to in estimateGas transaction") + raise ValueError("Cannot set to in estimate_gas transaction") if self.address: estimate_gas_transaction.setdefault('to', self.address) @@ -1028,7 +1041,7 @@ def estimateGas( if 'to' not in estimate_gas_transaction: if isinstance(self, type): raise ValueError( - "When using `Contract.estimateGas` from a contract factory " + "When using `Contract.estimate_gas` from a contract factory " "you must provide a `to` address with the transaction" ) else: @@ -1048,7 +1061,14 @@ def estimateGas( **self.kwargs ) - def buildTransaction(self, transaction: Optional[TxParams] = None) -> TxParams: + @deprecated_for("estimate_gas") + def estimateGas( + self, transaction: Optional[TxParams] = None, + block_identifier: Optional[BlockIdentifier] = None + ) -> int: + return self.estimate_gas(transaction, block_identifier) + + def build_transaction(self, transaction: Optional[TxParams] = None) -> TxParams: """ Build the transaction dictionary without sending """ @@ -1062,7 +1082,7 @@ def buildTransaction(self, transaction: Optional[TxParams] = None) -> TxParams: if not self.address and 'to' not in built_transaction: raise ValueError( - "When using `ContractFunction.buildTransaction` from a contract factory " + "When using `ContractFunction.build_transaction` from a contract factory " "you must provide a `to` address with the transaction" ) if self.address and 'to' in built_transaction: @@ -1087,6 +1107,10 @@ def buildTransaction(self, transaction: Optional[TxParams] = None) -> TxParams: **self.kwargs ) + @deprecated_for("build_transaction") + def buildTransaction(self, transaction: Optional[TxParams] = None) -> TxParams: + return self.build_transaction(transaction) + @combomethod def _encode_transaction_data(cls) -> HexStr: return add_0x_prefix(encode_abi(cls.web3, cls.abi, cls.arguments, cls.selector)) @@ -1603,7 +1627,7 @@ def estimate_gas_for_function( **kwargs: Any) -> int: """Estimates gas cost a function call would take. - Don't call this directly, instead use :meth:`Contract.estimateGas` + Don't call this directly, instead use :meth:`Contract.estimate_gas` on your contract instance. """ estimate_transaction = prepare_transaction( @@ -1631,7 +1655,7 @@ def build_transaction_for_function( **kwargs: Any) -> TxParams: """Builds a dictionary with the fields required to make the given transaction - Don't call this directly, instead use :meth:`Contract.buildTransaction` + Don't call this directly, instead use :meth:`Contract.build_transaction` on your contract instance. """ prepared_transaction = prepare_transaction( From 53836c0cef9ee4d7183459a64a65ad6bd38a12d5 Mon Sep 17 00:00:00 2001 From: DB Date: Fri, 22 Apr 2022 05:54:02 -0400 Subject: [PATCH 40/57] newsfragment --- newsfragments/1416.misc.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 newsfragments/1416.misc.rst diff --git a/newsfragments/1416.misc.rst b/newsfragments/1416.misc.rst new file mode 100644 index 0000000000..ac379cf2df --- /dev/null +++ b/newsfragments/1416.misc.rst @@ -0,0 +1 @@ +Deprectated buildTransaction and estimateGas in contract.py v5 \ No newline at end of file From 895fdc0cbb169d7c1a8c3bf616d0eb26492039f4 Mon Sep 17 00:00:00 2001 From: DB Date: Fri, 22 Apr 2022 22:12:13 -0400 Subject: [PATCH 41/57] update docs for eth --- docs/web3.eth.rst | 221 ---------------------------------------------- 1 file changed, 221 deletions(-) diff --git a/docs/web3.eth.rst b/docs/web3.eth.rst index eaa1653782..b1b419c267 100644 --- a/docs/web3.eth.rst +++ b/docs/web3.eth.rst @@ -51,25 +51,11 @@ The following properties are available on the ``web3.eth`` namespace. The ethereum address that will be used as the default ``from`` address for all transactions. Defaults to empty. - -.. py:attribute:: Eth.defaultAccount - - .. warning:: Deprecated: This property is deprecated in favor of - :attr:`~web3.eth.Eth.default_account` - - .. py:attribute:: Eth.default_block The default block number that will be used for any RPC methods that accept a block identifier. Defaults to ``'latest'``. - -.. py:attribute:: Eth.defaultBlock - - .. warning:: Deprecated: This property is deprecated in favor of - :attr:`~web3.eth.Eth.default_block` - - .. py:attribute:: Eth.syncing * Delegates to ``eth_syncing`` RPC Method @@ -148,13 +134,6 @@ The following properties are available on the ``web3.eth`` namespace. >>> web3.eth.gas_price 20000000000 - -.. py:attribute:: Eth.gasPrice - - .. warning:: Deprecated: This property is deprecated in favor of - :attr:`~web3.eth.Eth.gas_price` - - .. py:attribute:: Eth.accounts * Delegates to ``eth_accounts`` RPC Method @@ -180,31 +159,6 @@ The following properties are available on the ``web3.eth`` namespace. >>> web3.eth.block_number 2206939 - -.. py:attribute:: Eth.blockNumber - - .. warning:: Deprecated: This property is deprecated in favor of - :attr:`~web3.eth.Eth.block_number` - - -.. py:attribute:: Eth.protocol_version - - * Delegates to ``eth_protocolVersion`` RPC Method - - Returns the id of the current Ethereum protocol version. - - .. code-block:: python - - >>> web3.eth.protocol_version - '63' - - -.. py:attribute:: Eth.protocolVersion - - .. warning:: Deprecated: This property is deprecated in favor of - :attr:`~web3.eth.Eth.protocol_version` - - .. py:attribute:: Eth.chain_id * Delegates to ``eth_chainId`` RPC Method @@ -217,13 +171,6 @@ The following properties are available on the ``web3.eth`` namespace. 61 -.. py:attribute:: Eth.chainId - - .. warning:: Deprecated: This property is deprecated in favor of - :attr:`~web3.eth.chain_id` - - - Methods ------- @@ -244,13 +191,6 @@ The following methods are available on the ``web3.eth`` namespace. >>> web3.eth.get_balance('0xd3CdA913deB6f67967B99D67aCDFa1712C293601') 77320681768999138915 - -.. py:method:: Eth.getBalance(account, block_identifier=eth.default_block) - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.eth.get_balance()` - - .. py:method:: Eth.get_block_number() * Delegates to ``eth_blockNumber`` RPC Method @@ -277,13 +217,6 @@ The following methods are available on the ``web3.eth`` namespace. >>> web3.eth.get_storage_at('0x6C8f2A135f6ed072DE4503Bd7C4999a1a17F824B', 0) '0x00000000000000000000000000000000000000000000000000120a0b063499d4' - -.. py:method:: Eth.getStorageAt(account, position, block_identifier=eth.default_block) - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.eth.Eth.get_storage_at` - - .. py:method:: Eth.get_proof(account, positions, block_identifier=eth.default_block) * Delegates to ``eth_getProof`` RPC Method @@ -384,12 +317,6 @@ The following methods are available on the ``web3.eth`` namespace. proof = w3.eth.get_proof('0x6C8f2A135f6ed072DE4503Bd7C4999a1a17F824B', [0, 1], 3391) assert verify_eth_get_proof(proof, block.stateRoot) - -.. py:method:: Eth.getProof(account, positions, block_identifier=eth.default_block) - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.eth.Eth.get_proof` - .. py:method:: Eth.get_code(account, block_identifier=eth.default_block) * Delegates to ``eth_getCode`` RPC Method @@ -408,12 +335,6 @@ The following methods are available on the ``web3.eth`` namespace. >>> web3.eth.get_code('0xd3CdA913deB6f67967B99D67aCDFa1712C293601') '0x' - -.. py:method:: Eth.getCode(account, block_identifier=eth.default_block) - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.eth.Eth.get_code` - .. py:method:: Eth.get_block(block_identifier=eth.default_block, full_transactions=False) * Delegates to ``eth_getBlockByNumber`` or ``eth_getBlockByHash`` RPC Methods @@ -452,11 +373,6 @@ The following methods are available on the ``web3.eth`` namespace. 'uncles': [], }) -.. py:method:: Eth.getBlock(block_identifier=eth.default_block, full_transactions=False) - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.eth.Eth.get_block` - .. py:method:: Eth.get_block_transaction_count(block_identifier) * Delegates to ``eth_getBlockTransactionCountByNumber`` or @@ -475,20 +391,6 @@ The following methods are available on the ``web3.eth`` namespace. >>> web3.eth.get_block_transaction_count('0x4e3a3754410177e6937ef1f84bba68ea139e8d1a2258c5f85db9f1cd715a1bdd') # block 46147 1 - -.. py:method:: Eth.getBlockTransactionCount(block_identifier) - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.eth.Eth.get_block_transaction_count` - - - -.. py:method:: Eth.getUncle(block_identifier) - - .. note:: Method to get an Uncle from its hash is not available through - RPC, a possible substitute is the method ``Eth.get_uncle_by_block`` - - .. py:method:: Eth.get_uncle_by_block(block_identifier, uncle_index) * Delegates to ``eth_getUncleByBlockHashAndIndex`` or @@ -534,11 +436,6 @@ The following methods are available on the ``web3.eth`` namespace. ... }) -.. py:method:: Eth.getUncleByBlock(block_identifier, uncle_index) - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.eth.Eth.get_uncle_by_block()` - .. py:method:: Eth.get_uncle_count(block_identifier) * Delegates to ``eth_getUncleCountByBlockHash`` or @@ -559,11 +456,6 @@ The following methods are available on the ``web3.eth`` namespace. >>> web3.eth.get_uncle_count('0x685b2226cbf6e1f890211010aa192bf16f0a0cba9534264a033b023d7367b845') 1 -.. py:method:: Eth.getUncleCount(block_identifier) - - .. warning:: Deprecated: This method is deprecated in favor of - :attr:`~web3.eth.Eth.get_uncle_count()` - .. py:method:: Eth.get_transaction(transaction_hash) * Delegates to ``eth_getTransactionByHash`` RPC Method @@ -590,12 +482,6 @@ The following methods are available on the ``web3.eth`` namespace. }) -.. py:method:: Eth.getTransaction(transaction_hash) - - .. warning:: Deprecated: This method is deprecated in favor of - :attr:`~web3.eth.Eth.get_transaction` - - .. py:method:: Eth.get_raw_transaction(transaction_hash) * Delegates to ``eth_getRawTransactionByHash`` RPC Method @@ -663,11 +549,6 @@ The following methods are available on the ``web3.eth`` namespace. 'value': 31337, }) -.. py:method:: Eth.getTransactionByBlock(block_identifier, transaction_index) - - .. warning:: Deprecated: This method is deprecated in favor of - :attr:`~web3.eth.Eth.get_transaction_by_block` - .. py:method:: Eth.get_raw_transaction_by_block(block_identifier, transaction_index) * Delegates to ``eth_getRawTransactionByBlockNumberAndIndex`` or @@ -720,12 +601,6 @@ The following methods are available on the ``web3.eth`` namespace. 'transactionIndex': 0, }) - -.. 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 @@ -757,11 +632,6 @@ The following methods are available on the ``web3.eth`` namespace. 'transactionIndex': 0, }) -.. py:method:: Eth.getTransactionReceipt(transaction_hash) - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.eth.Eth.get_transaction_receipt()` - .. py:method:: Eth.get_transaction_count(account, block_identifier=web3.eth.default_block) * Delegates to ``eth_getTransactionCount`` RPC Method @@ -776,13 +646,6 @@ The following methods are available on the ``web3.eth`` namespace. >>> web3.eth.get_transaction_count('0xd3CdA913deB6f67967B99D67aCDFa1712C293601') 340 - -.. py:method:: Eth.getTransactionCount(account, block_identifier=web3.eth.default_block) - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.eth.Eth.get_transaction_count()` - - .. py:method:: Eth.send_transaction(transaction) * Delegates to ``eth_sendTransaction`` RPC Method @@ -854,11 +717,6 @@ The following methods are available on the ``web3.eth`` namespace. }) HexBytes('0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331') -.. py:method:: Eth.sendTransaction(transaction) - - .. warning:: Deprecated: This method is deprecated in favor of - :attr:`~web3.eth.Eth.send_transaction()` - .. py:method:: Eth.sign_transaction(transaction) * Delegates to ``eth_signTransaction`` RPC Method. @@ -880,12 +738,6 @@ The following methods are available on the ``web3.eth`` namespace. ) b"\xf8d\x80\x85\x040\xe24\x00\x82R\x08\x94\xdcTM\x1a\xa8\x8f\xf8\xbb\xd2\xf2\xae\xc7T\xb1\xf1\xe9\x9e\x18\x12\xfd\x01\x80\x1b\xa0\x11\r\x8f\xee\x1d\xe5=\xf0\x87\x0en\xb5\x99\xed;\xf6\x8f\xb3\xf1\xe6,\x82\xdf\xe5\x97lF|\x97%;\x15\xa04P\xb7=*\xef \t\xf0&\xbc\xbf\tz%z\xe7\xa3~\xb5\xd3\xb7=\xc0v\n\xef\xad+\x98\xe3'" # noqa: E501 - -.. py:method:: Eth.signTransaction(transaction) - - .. warning:: Deprecated: This method is deprecated in favor of - :attr:`~web3.eth.Eth.sign_transaction()` - .. py:method:: Eth.send_raw_transaction(raw_transaction) * Delegates to ``eth_sendRawTransaction`` RPC Method @@ -910,11 +762,6 @@ The following methods are available on the ``web3.eth`` namespace. >>> w3.eth.send_raw_transaction(signed_txn.rawTransaction) HexBytes('0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331') -.. py:method:: Eth.sendRawTransaction(raw_transaction) - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.eth.Eth.send_raw_transaction()` - .. py:method:: Eth.replace_transaction(transaction_hash, new_transaction) * Delegates to ``eth_sendTransaction`` RPC Method @@ -970,11 +817,6 @@ The following methods are available on the ``web3.eth`` namespace. }) HexBytes('0x4177e670ec6431606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1528989') -.. py:method:: Eth.replaceTransaction(transaction_hash, new_transaction) - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.eth.Eth.replace_transaction()` - .. py:method:: Eth.modify_transaction(transaction_hash, **transaction_params) * Delegates to ``eth_sendTransaction`` RPC Method @@ -1001,11 +843,6 @@ The following methods are available on the ``web3.eth`` namespace. >>> web3.eth.modify_transaction('0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331', value=2000) HexBytes('0xec6434e6701771606e55d6b4ca35a1a6b75ee3d73315145a921026d15299d05') -.. py:method:: Eth.modifyTransaction(transaction_hash, **transaction_params) - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.eth.Eth.modify_transaction()` - .. py:method:: Eth.sign(account, data=None, hexstr=None, text=None) * Delegates to ``eth_sign`` RPC Method @@ -1047,11 +884,6 @@ 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, state_override=None) * Delegates to ``eth_call`` RPC Method @@ -1133,11 +965,6 @@ The following methods are available on the ``web3.eth`` namespace. >>> web3.eth.estimate_gas({'to': '0xd3CdA913deB6f67967B99D67aCDFa1712C293601', 'from':web3.eth.coinbase, 'value': 12345}) 21000 -.. py:method:: Eth.estimateGas(transaction, block_identifier=None) - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.eth.Eth.estimate_gas()` - .. py:method:: Eth.generate_gas_price(transaction_params=None) Uses the selected gas price strategy to calculate a gas price. This method @@ -1155,21 +982,11 @@ The following methods are available on the ``web3.eth`` namespace. 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.set_gas_price_strategy(gas_price_strategy) Set the selected gas price strategy. It must be a method of the signature ``(web3, transaction_params)`` and return a gas price denominated in wei. -.. py:method:: Eth.setGasPriceStrategy(gas_price_strategy) - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.eth.Eth.set_gas_price_strategy()` - Filters ------- @@ -1258,12 +1075,6 @@ with the filtering API. ] -.. py:method:: Eth.getFilterChanges(self, filter_id) - - .. warning:: Deprecated: This property is deprecated in favor of - :meth:`~web3.eth.Eth.get_filter_changes()` - - .. py:method:: Eth.get_filter_logs(self, filter_id) * Delegates to ``eth_getFilterLogs`` RPC Method. @@ -1290,13 +1101,6 @@ with the filtering API. ... ] - -.. 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. @@ -1312,11 +1116,6 @@ with the filtering API. >>> web3.eth.uninstall_filter(filt.filter_id) False # already uninstalled. -.. py:method:: Eth.uninstallFilter(self, filter_id) - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.eth.Eth.uninstall_filter` - .. py:method:: Eth.get_logs(filter_params) @@ -1324,11 +1123,6 @@ with the filtering API. 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) - - .. 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 @@ -1339,11 +1133,6 @@ with the filtering API. >>> web3.eth.submit_hashrate(5000, node_id) True -.. py:method:: Eth.submitHashrate(hashrate, nodeid) - - .. 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. @@ -1357,11 +1146,6 @@ with the filtering API. ) 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 --------- @@ -1433,8 +1217,3 @@ Contracts Future calls to ``Eth.contract()`` will then default to ``contractFactoryClass``. An example of an alternative Contract Factory is ``ConciseContract``. - -.. py:method:: Eth.setContractFactory(contractFactoryClass) - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.eth.Eth.set_contract_factory()` From 56e8986e20b7c1ece455c838ed5410f607971019 Mon Sep 17 00:00:00 2001 From: DB Date: Fri, 22 Apr 2022 22:14:31 -0400 Subject: [PATCH 42/57] updated geth docs --- docs/web3.geth.rst | 75 ---------------------------------------------- 1 file changed, 75 deletions(-) diff --git a/docs/web3.geth.rst b/docs/web3.geth.rst index f448e35c7a..3922cef3cd 100644 --- a/docs/web3.geth.rst +++ b/docs/web3.geth.rst @@ -54,12 +54,6 @@ The ``web3.geth.admin`` object exposes methods to interact with the RPC APIs und } -.. py:method:: nodeInfo() - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.geth.admin.node_info()` - - .. py:method:: peers() * Delegates to ``admin_peers`` RPC Method @@ -117,11 +111,6 @@ The ``web3.geth.admin`` object exposes methods to interact with the RPC APIs und >>> web3.geth.admin.add_peer('enode://e54eebad24dce1f6d246bea455ffa756d97801582420b9ed681a2ea84bf376d0bd87ae8dd6dc06cdb862a2ca89ecabe1be1050be35b4e70d62bc1a092cb7e2d3@52.71.255.237:30303') True - -.. py:method:: addPeer(node_url) - - .. warning:: Deprecated: This method is deprecated in favor of :meth:`~web3.geth.admin.add_peer()` - .. py:method:: start_rpc(host='localhost', port=8545, cors="", apis="eth,net,web3") * Delegates to ``admin_startRPC`` RPC Method @@ -136,13 +125,6 @@ The ``web3.geth.admin`` object exposes methods to interact with the RPC APIs und >>> web3.geth.admin.start_rpc() True - -.. py:method:: startRPC(host='localhost', port=8545, cors="", apis="eth,net,web3") - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.geth.admin.start_rpc()` - - .. py:method:: start_ws(host='localhost', port=8546, cors="", apis="eth,net,web3") * Delegates to ``admin_startWS`` RPC Method @@ -157,13 +139,6 @@ The ``web3.geth.admin`` object exposes methods to interact with the RPC APIs und >>> web3.geth.admin.start_ws() True - -.. py:method:: startWS(host='localhost', port=8546, cors="", apis="eth,net,web3") - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.geth.admin.start_ws()` - - .. py:method:: stop_rpc() * Delegates to ``admin_stopRPC`` RPC Method @@ -176,12 +151,6 @@ The ``web3.geth.admin`` object exposes methods to interact with the RPC APIs und True -.. py:method:: stopRPC() - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.geth.admin.stop_rpc()` - - .. py:method:: stop_ws() * Delegates to ``admin_stopWS`` RPC Method @@ -193,13 +162,6 @@ The ``web3.geth.admin`` object exposes methods to interact with the RPC APIs und >>> web3.geth.admin.stop_ws() True - -.. py:method:: stopWS() - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.geth.admin.stop_ws()` - - .. py:module:: web3.geth.personal GethPersonal API @@ -219,12 +181,6 @@ The following methods are available on the ``web3.geth.personal`` namespace. ['0xd3CdA913deB6f67967B99D67aCDFa1712C293601'] -.. py:method:: listAccounts() - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.geth.personal.list_accounts()` - - .. py:method:: list_wallets() * Delegates to ``personal_listWallets`` RPC Method @@ -257,12 +213,6 @@ The following methods are available on the ``web3.geth.personal`` namespace. '0xd3CdA913deB6f67967B99D67aCDFa1712C293601' -.. py:method:: importRawKey() - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.geth.personal.import_raw_key()` - - .. py:method:: new_account(self, passphrase) * Delegates to ``personal_newAccount`` RPC Method @@ -276,12 +226,6 @@ The following methods are available on the ``web3.geth.personal`` namespace. '0xd3CdA913deB6f67967B99D67aCDFa1712C293601' -.. py:method:: newAccount() - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.geth.personal.new_account()` - - .. py:method:: lock_account(self, account) * Delegates to ``personal_lockAccount`` RPC Method @@ -293,12 +237,6 @@ The following methods are available on the ``web3.geth.personal`` namespace. >>> web3.geth.personal.lock_account('0xd3CdA913deB6f67967B99D67aCDFa1712C293601') -.. py:method:: lockAccount() - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.geth.personal.lock_account()` - - .. py:method:: unlock_account(self, account, passphrase, duration=None) * Delegates to ``personal_unlockAccount`` RPC Method @@ -317,25 +255,12 @@ The following methods are available on the ``web3.geth.personal`` namespace. True -.. py:method:: unlockAccount() - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.geth.personal.unlock_account()` - - .. py:method:: send_transaction(self, transaction, passphrase) * Delegates to ``personal_sendTransaction`` RPC Method Sends the transaction. - -.. py:method:: sendTransaction() - - .. warning:: Deprecated: This method is deprecated in favor of - :meth:`~web3.geth.personal.send_transaction()` - - .. py:module:: web3.geth.txpool GethTxPool API From b1c9969ab7e3f0640b3be26b6b97a69100b1dde7 Mon Sep 17 00:00:00 2001 From: Eric Huang <104116818+EricHuang0525@users.noreply.github.com> Date: Thu, 28 Apr 2022 01:59:25 +0800 Subject: [PATCH 43/57] Resolve Typo in documentation. (#2444) * Resolve Typo in documentation. * Add newsfragment for doc fix Co-authored-by: kclowes --- docs/filters.rst | 2 +- newsfragments/2444.doc.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 newsfragments/2444.doc.rst diff --git a/docs/filters.rst b/docs/filters.rst index cef28b8b95..57fef0028d 100644 --- a/docs/filters.rst +++ b/docs/filters.rst @@ -112,7 +112,7 @@ will return a new :class:`BlockFilter` object. ``TransactionFilter`` is a subclass of :class:`Filter`. You can setup a filter for new blocks using ``web3.eth.filter('pending')`` which -will return a new :class:`BlockFilter` object. +will return a new :class:`TransactionFilter` object. .. code-block:: python diff --git a/newsfragments/2444.doc.rst b/newsfragments/2444.doc.rst new file mode 100644 index 0000000000..629dc65b47 --- /dev/null +++ b/newsfragments/2444.doc.rst @@ -0,0 +1 @@ +Doc fix: Pending transaction filter returns a ``TransactionFilter`` not a ``BlockFilter`` From 3e8f07c14f10f97071de2f93180e0be07a575ffa Mon Sep 17 00:00:00 2001 From: kclowes Date: Wed, 27 Apr 2022 13:31:13 -0600 Subject: [PATCH 44/57] Add sync chain_id to simple cache (#2426) * Cache eth.chain_id in simple_cache_middleware (#2425) * Add caching for sync chain_id * Remove async chainId setter Will add async chainId to the cache once the simple_cache_middleware is available on async * Add docs * Add newsfragment for simple_cache_middleware, take out old, confusing newsfragment --- docs/web3.eth.rst | 12 ++++++ newsfragments/2207.feature.rst | 1 - newsfragments/2376.bugfix.rst | 1 - newsfragments/2425.feature.rst | 1 + tests/core/eth-module/test_eth_properties.py | 39 -------------------- web3/eth.py | 19 +--------- web3/middleware/cache.py | 1 + 7 files changed, 16 insertions(+), 58 deletions(-) delete mode 100644 newsfragments/2207.feature.rst delete mode 100644 newsfragments/2376.bugfix.rst create mode 100644 newsfragments/2425.feature.rst diff --git a/docs/web3.eth.rst b/docs/web3.eth.rst index 9fbe9c13ab..52ddc83417 100644 --- a/docs/web3.eth.rst +++ b/docs/web3.eth.rst @@ -216,6 +216,18 @@ The following properties are available on the ``web3.eth`` namespace. >>> web3.eth.chain_id 61 + .. note:: + + This property gets called frequently in validation middleware, + but `chain_id` is added to the ``simple_cache_middleware`` by default. + Add the :meth:`simple_cache_middleware` + to the ``middleware_onion`` to increase performance: + + .. code-block:: python + + >>> from web3.middleware import simple_cache_middleware + >>> w3.middleware_onion.add(simple_cache_middleare) + .. py:attribute:: Eth.chainId diff --git a/newsfragments/2207.feature.rst b/newsfragments/2207.feature.rst deleted file mode 100644 index 78a6f8bbd5..0000000000 --- a/newsfragments/2207.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Add setter for the Eth.chain_id property diff --git a/newsfragments/2376.bugfix.rst b/newsfragments/2376.bugfix.rst deleted file mode 100644 index 8518a5427e..0000000000 --- a/newsfragments/2376.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Add async default_chain_id and chain_id setter diff --git a/newsfragments/2425.feature.rst b/newsfragments/2425.feature.rst new file mode 100644 index 0000000000..fc01c0dcdc --- /dev/null +++ b/newsfragments/2425.feature.rst @@ -0,0 +1 @@ +Add sync chain_id to ``simple_middleware_cache`` diff --git a/tests/core/eth-module/test_eth_properties.py b/tests/core/eth-module/test_eth_properties.py index c24070eb60..5b829abaa1 100644 --- a/tests/core/eth-module/test_eth_properties.py +++ b/tests/core/eth-module/test_eth_properties.py @@ -1,23 +1,5 @@ import pytest -from web3 import Web3 -from web3.eth import ( - AsyncEth, -) -from web3.providers.eth_tester.main import ( - AsyncEthereumTesterProvider, -) - - -@pytest.fixture -def async_w3(): - return Web3( - AsyncEthereumTesterProvider(), - middlewares=[], - modules={ - 'eth': (AsyncEth,), - }) - def test_eth_protocol_version(w3): with pytest.warns(DeprecationWarning): @@ -36,24 +18,3 @@ def test_eth_chain_id(w3): def test_eth_chainId(w3): with pytest.warns(DeprecationWarning): assert w3.eth.chainId == 61 - - -def test_set_chain_id(w3): - assert w3.eth.chain_id == 61 - - w3.eth.chain_id = 72 - assert w3.eth.chain_id == 72 - - w3.eth.chain_id = None - assert w3.eth.chain_id == 61 - - -@pytest.mark.asyncio -async def test_async_set_chain_id(async_w3): - assert await async_w3.eth.chain_id == 61 - - async_w3.eth.chain_id = 72 - assert await async_w3.eth.chain_id == 72 - - async_w3.eth.chain_id = None - assert await async_w3.eth.chain_id == 61 diff --git a/web3/eth.py b/web3/eth.py index 54c88a41d1..55bbceb6e4 100644 --- a/web3/eth.py +++ b/web3/eth.py @@ -114,7 +114,6 @@ class BaseEth(Module): _default_account: Union[ChecksumAddress, Empty] = empty _default_block: BlockIdentifier = "latest" - _default_chain_id: Optional[int] = None gasPriceStrategy = None _gas_price: Method[Callable[[], Wei]] = Method( @@ -358,14 +357,7 @@ async def block_number(self) -> BlockNumber: @property async def chain_id(self) -> int: - if self._default_chain_id is None: - return await self._chain_id() # type: ignore - else: - return self._default_chain_id - - @chain_id.setter - def chain_id(self, value: int) -> None: - self._default_chain_id = value + return await self._chain_id() # type: ignore @property async def coinbase(self) -> ChecksumAddress: @@ -637,14 +629,7 @@ def blockNumber(self) -> BlockNumber: @property def chain_id(self) -> int: - if self._default_chain_id is None: - return self._chain_id() - else: - return self._default_chain_id - - @chain_id.setter - def chain_id(self, value: int) -> None: - self._default_chain_id = value + return self._chain_id() @property def chainId(self) -> int: diff --git a/web3/middleware/cache.py b/web3/middleware/cache.py index c0635daf97..91331327bc 100644 --- a/web3/middleware/cache.py +++ b/web3/middleware/cache.py @@ -82,6 +82,7 @@ # 'eth_getWork', # 'eth_submitWork', # 'eth_submitHashrate', + 'eth_chainId', }) From a87885bc74375c6767625fbb9d12c4060f0ee7a9 Mon Sep 17 00:00:00 2001 From: kclowes Date: Wed, 27 Apr 2022 15:13:46 -0600 Subject: [PATCH 45/57] Compile release notes --- docs/releases.rst | 53 ++++++++++++++++++++++++++ newsfragments/1183.breaking-change.rst | 1 - newsfragments/2286.feature.rst | 1 - newsfragments/2322.doc.rst | 1 - newsfragments/2342.breaking-change.rst | 6 --- newsfragments/2369.misc.rst | 1 - newsfragments/2372.misc.rst | 6 --- newsfragments/2380.doc.rst | 1 - newsfragments/2383.breaking-change.rst | 1 - newsfragments/2410.doc.rst | 1 - newsfragments/2418.misc.rst | 1 - newsfragments/2420.feature.rst | 1 - newsfragments/2425.feature.rst | 1 - newsfragments/2434.breaking-change.rst | 1 - newsfragments/2444.doc.rst | 1 - 15 files changed, 53 insertions(+), 24 deletions(-) delete mode 100644 newsfragments/1183.breaking-change.rst delete mode 100644 newsfragments/2286.feature.rst delete mode 100644 newsfragments/2322.doc.rst delete mode 100644 newsfragments/2342.breaking-change.rst delete mode 100644 newsfragments/2369.misc.rst delete mode 100644 newsfragments/2372.misc.rst delete mode 100644 newsfragments/2380.doc.rst delete mode 100644 newsfragments/2383.breaking-change.rst delete mode 100644 newsfragments/2410.doc.rst delete mode 100644 newsfragments/2418.misc.rst delete mode 100644 newsfragments/2420.feature.rst delete mode 100644 newsfragments/2425.feature.rst delete mode 100644 newsfragments/2434.breaking-change.rst delete mode 100644 newsfragments/2444.doc.rst diff --git a/docs/releases.rst b/docs/releases.rst index 56329d346d..3661e2d3f7 100644 --- a/docs/releases.rst +++ b/docs/releases.rst @@ -3,6 +3,59 @@ Release Notes .. towncrier release notes start +v6.0.0-beta.2 (2022-04-27) +-------------------------- + +Breaking Changes +~~~~~~~~~~~~~~~~ + +- Audit ``.rst`` and ``.py`` files and convert all Web3 instance variable names + to ``w3`` to avoid confusion with the ``web3`` module. (`#1183 + `__) +- Update dependency requirements: - eth-utils - eth-abi - eth-tester - + eth-account - eth-typing (`#2342 + `__) +- Add ``attach_methods()`` to ``Module`` class to facilitate attaching methods + to modules. (`#2383 `__) +- Move IOError -> OSError (`#2434 + `__) + + +Documentation Updates +~~~~~~~~~~~~~~~~~~~~~ + +- Clarify info about Infura filters over HTTP (`#2322 + `__) +- Document reading private keys from environment variables (`#2380 + `__) +- Add example for the ``construct_sign_and_send_raw_middleware`` when connected + to a hosted node (`#2410 + `__) +- Doc fix: Pending transaction filter returns a ``TransactionFilter`` not a + ``BlockFilter`` (`#2444 `__) + + +Features +~~~~~~~~ + +- Add 'get_text' method to look up ENS text record values (`#2286 + `__) +- For ``ENS.name()``, validate that the forward resolution returns the same + address as provided by the user as per the ENS documentation recommendation + for Reverse Resolution. (`#2420 + `__) +- Add sync chain_id to ``simple_middleware_cache`` (`#2425 + `__) + + +Misc +~~~~ + +- `#2369 `__, `#2372 + `__, `#2418 + `__ + + v6.0.0-beta.1 (2022-02-28) -------------------------- diff --git a/newsfragments/1183.breaking-change.rst b/newsfragments/1183.breaking-change.rst deleted file mode 100644 index 2486e9fd65..0000000000 --- a/newsfragments/1183.breaking-change.rst +++ /dev/null @@ -1 +0,0 @@ -Audit ``.rst`` and ``.py`` files and convert all Web3 instance variable names to ``w3`` to avoid confusion with the ``web3`` module. \ No newline at end of file diff --git a/newsfragments/2286.feature.rst b/newsfragments/2286.feature.rst deleted file mode 100644 index e65010cec7..0000000000 --- a/newsfragments/2286.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Add 'get_text' method to look up ENS text record values diff --git a/newsfragments/2322.doc.rst b/newsfragments/2322.doc.rst deleted file mode 100644 index 888fa618c9..0000000000 --- a/newsfragments/2322.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Clarify info about Infura filters over HTTP diff --git a/newsfragments/2342.breaking-change.rst b/newsfragments/2342.breaking-change.rst deleted file mode 100644 index e33b6b533e..0000000000 --- a/newsfragments/2342.breaking-change.rst +++ /dev/null @@ -1,6 +0,0 @@ -Update dependency requirements: -- eth-utils -- eth-abi -- eth-tester -- eth-account -- eth-typing diff --git a/newsfragments/2369.misc.rst b/newsfragments/2369.misc.rst deleted file mode 100644 index cede2588df..0000000000 --- a/newsfragments/2369.misc.rst +++ /dev/null @@ -1 +0,0 @@ -bump docker base image to ``3.9`` and remove parity tests from docker. \ No newline at end of file diff --git a/newsfragments/2372.misc.rst b/newsfragments/2372.misc.rst deleted file mode 100644 index bd2a98be31..0000000000 --- a/newsfragments/2372.misc.rst +++ /dev/null @@ -1,6 +0,0 @@ -improve the code base by: -- using `f-strings`. -- removing redundant `set()` calls. -- making error messages more readable in the code. -- removing python2 `u` prefix. -- other cleanups. \ No newline at end of file diff --git a/newsfragments/2380.doc.rst b/newsfragments/2380.doc.rst deleted file mode 100644 index 6baf4bb2d6..0000000000 --- a/newsfragments/2380.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Document reading private keys from environment variables diff --git a/newsfragments/2383.breaking-change.rst b/newsfragments/2383.breaking-change.rst deleted file mode 100644 index a53354bbc7..0000000000 --- a/newsfragments/2383.breaking-change.rst +++ /dev/null @@ -1 +0,0 @@ -Add ``attach_methods()`` to ``Module`` class to facilitate attaching methods to modules. \ No newline at end of file diff --git a/newsfragments/2410.doc.rst b/newsfragments/2410.doc.rst deleted file mode 100644 index 28f8a043e1..0000000000 --- a/newsfragments/2410.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Add example for the ``construct_sign_and_send_raw_middleware`` when connected to a hosted node diff --git a/newsfragments/2418.misc.rst b/newsfragments/2418.misc.rst deleted file mode 100644 index 86392cb2a0..0000000000 --- a/newsfragments/2418.misc.rst +++ /dev/null @@ -1 +0,0 @@ -Add flaky decorator to Geth gas estimation tests. diff --git a/newsfragments/2420.feature.rst b/newsfragments/2420.feature.rst deleted file mode 100644 index f81eb8df89..0000000000 --- a/newsfragments/2420.feature.rst +++ /dev/null @@ -1 +0,0 @@ -For ``ENS.name()``, validate that the forward resolution returns the same address as provided by the user as per the ENS documentation recommendation for Reverse Resolution. diff --git a/newsfragments/2425.feature.rst b/newsfragments/2425.feature.rst deleted file mode 100644 index fc01c0dcdc..0000000000 --- a/newsfragments/2425.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Add sync chain_id to ``simple_middleware_cache`` diff --git a/newsfragments/2434.breaking-change.rst b/newsfragments/2434.breaking-change.rst deleted file mode 100644 index e1f03956b0..0000000000 --- a/newsfragments/2434.breaking-change.rst +++ /dev/null @@ -1 +0,0 @@ -Move IOError -> OSError diff --git a/newsfragments/2444.doc.rst b/newsfragments/2444.doc.rst deleted file mode 100644 index 629dc65b47..0000000000 --- a/newsfragments/2444.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Doc fix: Pending transaction filter returns a ``TransactionFilter`` not a ``BlockFilter`` From 357030d2bd7194ce4a45faf5f10a4326e93bbbc5 Mon Sep 17 00:00:00 2001 From: kclowes Date: Wed, 27 Apr 2022 15:17:29 -0600 Subject: [PATCH 46/57] =?UTF-8?q?Bump=20version:=206.0.0-beta.1=20?= =?UTF-8?q?=E2=86=92=206.0.0-beta.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index f001726537..a4b0a31bd4 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 6.0.0-beta.1 +current_version = 6.0.0-beta.2 commit = True tag = True parse = (?P\d+)\.(?P\d+)\.(?P\d+)(-(?P[^.]*)\.(?P\d+))? diff --git a/setup.py b/setup.py index 315808f8ee..35b4e0f2d3 100644 --- a/setup.py +++ b/setup.py @@ -65,7 +65,7 @@ setup( name='web3', # *IMPORTANT*: Don't manually change the version here. Use the 'bumpversion' utility. - version='6.0.0-beta.1', + version='6.0.0-beta.2', description="""Web3.py""", long_description_content_type='text/markdown', long_description=long_description, From 49a3d2e875d009d8c825ee76d59e0a481caa78fa Mon Sep 17 00:00:00 2001 From: Juliya Smith Date: Fri, 29 Apr 2022 10:41:07 -0500 Subject: [PATCH 47/57] docs: fix `simple_cache_middleware` example (#2449) * docs: fix example * Add newsfragment for typo Co-authored-by: kclowes --- docs/web3.eth.rst | 2 +- newsfragments/2449.doc.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 newsfragments/2449.doc.rst diff --git a/docs/web3.eth.rst b/docs/web3.eth.rst index 52ddc83417..9b271f182e 100644 --- a/docs/web3.eth.rst +++ b/docs/web3.eth.rst @@ -226,7 +226,7 @@ The following properties are available on the ``web3.eth`` namespace. .. code-block:: python >>> from web3.middleware import simple_cache_middleware - >>> w3.middleware_onion.add(simple_cache_middleare) + >>> w3.middleware_onion.add(simple_cache_middleware) .. py:attribute:: Eth.chainId diff --git a/newsfragments/2449.doc.rst b/newsfragments/2449.doc.rst new file mode 100644 index 0000000000..9d3afa5c83 --- /dev/null +++ b/newsfragments/2449.doc.rst @@ -0,0 +1 @@ +Fix typo in simple_cache_middleware example From 5b6dea222989391e348e5fabe84f6a2ee69f5028 Mon Sep 17 00:00:00 2001 From: Juliya Smith Date: Mon, 2 May 2022 13:53:15 -0500 Subject: [PATCH 48/57] fix: add chainId to txn params (#2450) * fix: add chainId to txn params * fix: error message on chain id hex to int * Add newsfragment Co-authored-by: kclowes --- newsfragments/2450.misc.rst | 1 + web3/_utils/rpc_abi.py | 1 + web3/middleware/validation.py | 5 +++-- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 newsfragments/2450.misc.rst diff --git a/newsfragments/2450.misc.rst b/newsfragments/2450.misc.rst new file mode 100644 index 0000000000..eaca4dda9e --- /dev/null +++ b/newsfragments/2450.misc.rst @@ -0,0 +1 @@ +Add ``chainId`` to tx params to ``TRANSACTION_PARAMS_ABI`` diff --git a/web3/_utils/rpc_abi.py b/web3/_utils/rpc_abi.py index 4ebf435919..bb55e89c9a 100644 --- a/web3/_utils/rpc_abi.py +++ b/web3/_utils/rpc_abi.py @@ -163,6 +163,7 @@ class RPC: 'nonce': 'uint', 'to': 'address', 'value': 'uint', + 'chainId': 'uint', } FILTER_PARAMS_ABIS = { diff --git a/web3/middleware/validation.py b/web3/middleware/validation.py index 23872858ef..852d921bdc 100644 --- a/web3/middleware/validation.py +++ b/web3/middleware/validation.py @@ -55,11 +55,12 @@ @curry def _validate_chain_id(web3_chain_id: int, chain_id: int) -> int: - if to_integer_if_hex(chain_id) == web3_chain_id: + chain_id_int = to_integer_if_hex(chain_id) + if chain_id_int == web3_chain_id: return chain_id else: raise ValidationError( - f"The transaction declared chain ID {chain_id!r}, " + f"The transaction declared chain ID {chain_id_int!r}, " f"but the connected node is on {web3_chain_id!r}" ) From 78bb85d93bf83dbd65ba69d2a8baf7cf2e6e2775 Mon Sep 17 00:00:00 2001 From: Felipe Selmo Date: Mon, 2 May 2022 11:45:01 -0600 Subject: [PATCH 49/57] Update integration test fixture to use geth v1.10.17 - Upgrade the go version used in the geth steps for circleci --- .circleci/config.yml | 34 ++++++++++----------- docs/contributing.rst | 4 +-- newsfragments/2054.misc.rst | 1 + setup.py | 4 +-- tests/integration/geth-1.10.13-fixture.zip | Bin 39419 -> 0 bytes tests/integration/geth-1.10.17-fixture.zip | Bin 0 -> 42372 bytes tests/integration/go_ethereum/conftest.py | 2 +- web3/tools/benchmark/node.py | 2 +- 8 files changed, 24 insertions(+), 23 deletions(-) create mode 100644 newsfragments/2054.misc.rst delete mode 100644 tests/integration/geth-1.10.13-fixture.zip create mode 100644 tests/integration/geth-1.10.17-fixture.zip diff --git a/.circleci/config.yml b/.circleci/config.yml index 08c9b05884..91e8ab890a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -76,8 +76,8 @@ geth_steps: &geth_steps echo $GETH_VERSION export GETH_BINARY="$HOME/.py-geth/geth-$GETH_VERSION/bin/geth" if [ ! -e "$GETH_BINARY" ]; then - curl -O https://storage.googleapis.com/golang/go1.14.2.linux-amd64.tar.gz - tar xvf go1.14.2.linux-amd64.tar.gz + curl -O https://storage.googleapis.com/golang/go1.18.1.linux-amd64.tar.gz + tar xvf go1.18.1.linux-amd64.tar.gz sudo chown -R root:root ./go sudo mv go /usr/local sudo ln -s /usr/local/go/bin/go /usr/local/bin/go @@ -119,8 +119,8 @@ geth_custom_steps: &geth_custom_steps echo $GETH_VERSION export GETH_BINARY="./custom_geth" echo 'export GETH_BINARY="./custom_geth"' >> $BASH_ENV - curl -O https://storage.googleapis.com/golang/go1.14.2.linux-amd64.tar.gz - tar xvf go1.14.2.linux-amd64.tar.gz + curl -O https://storage.googleapis.com/golang/go1.18.1.linux-amd64.tar.gz + tar xvf go1.18.1.linux-amd64.tar.gz sudo chown -R root:root ./go sudo mv go /usr/local sudo ln -s /usr/local/go/bin/go /usr/local/bin/go @@ -253,7 +253,7 @@ jobs: - image: circleci/python:3.7 environment: TOXENV: py37-integration-goethereum-ipc - GETH_VERSION: v1.10.13 + GETH_VERSION: v1.10.17 py37-integration-goethereum-http: <<: *geth_steps @@ -261,7 +261,7 @@ jobs: - image: circleci/python:3.7 environment: TOXENV: py37-integration-goethereum-http - GETH_VERSION: v1.10.13 + GETH_VERSION: v1.10.17 py37-integration-goethereum-ws: <<: *geth_steps @@ -269,7 +269,7 @@ jobs: - image: circleci/python:3.7 environment: TOXENV: py37-integration-goethereum-ws - GETH_VERSION: v1.10.13 + GETH_VERSION: v1.10.17 py37-integration-ethtester-pyevm: <<: *common @@ -323,7 +323,7 @@ jobs: - image: circleci/python:3.8 environment: TOXENV: py38-integration-goethereum-ipc - GETH_VERSION: v1.10.13 + GETH_VERSION: v1.10.17 py38-integration-goethereum-http: <<: *geth_steps @@ -331,7 +331,7 @@ jobs: - image: circleci/python:3.8 environment: TOXENV: py38-integration-goethereum-http - GETH_VERSION: v1.10.13 + GETH_VERSION: v1.10.17 py38-integration-goethereum-ws: <<: *geth_steps @@ -339,7 +339,7 @@ jobs: - image: circleci/python:3.8 environment: TOXENV: py38-integration-goethereum-ws - GETH_VERSION: v1.10.13 + GETH_VERSION: v1.10.17 py38-integration-ethtester-pyevm: <<: *common @@ -388,7 +388,7 @@ jobs: - image: circleci/python:3.9 environment: TOXENV: py39-integration-goethereum-ipc - GETH_VERSION: v1.10.13 + GETH_VERSION: v1.10.17 py39-integration-goethereum-http: <<: *geth_steps @@ -396,7 +396,7 @@ jobs: - image: circleci/python:3.9 environment: TOXENV: py39-integration-goethereum-http - GETH_VERSION: v1.10.13 + GETH_VERSION: v1.10.17 py39-integration-goethereum-ws: <<: *geth_steps @@ -404,7 +404,7 @@ jobs: - image: circleci/python:3.9 environment: TOXENV: py39-integration-goethereum-ws - GETH_VERSION: v1.10.13 + GETH_VERSION: v1.10.17 py39-integration-ethtester-pyevm: <<: *common @@ -453,7 +453,7 @@ jobs: - image: circleci/python:3.10 environment: TOXENV: py310-integration-goethereum-ipc - GETH_VERSION: v1.10.11 + GETH_VERSION: v1.10.17 py310-integration-goethereum-http: <<: *geth_steps @@ -461,7 +461,7 @@ jobs: - image: circleci/python:3.10 environment: TOXENV: py310-integration-goethereum-http - GETH_VERSION: v1.10.11 + GETH_VERSION: v1.10.17 py310-integration-goethereum-ws: <<: *geth_steps @@ -469,7 +469,7 @@ jobs: - image: circleci/python:3.10 environment: TOXENV: py310-integration-goethereum-ws - GETH_VERSION: v1.10.11 + GETH_VERSION: v1.10.17 py310-integration-ethtester-pyevm: <<: *common @@ -492,7 +492,7 @@ jobs: - image: circleci/python:3.10 environment: TOXENV: benchmark - GETH_VERSION: v1.10.13 + GETH_VERSION: v1.10.17 workflows: version: 2.1 diff --git a/docs/contributing.rst b/docs/contributing.rst index f730748d5f..3e85fb80ef 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -308,13 +308,13 @@ Geth Fixtures .. code:: sh - $ python -m geth.install v1.10.13 + $ python -m geth.install v1.10.17 2. Specify the Geth binary and run the fixture creation script (from within the web3.py directory): .. code:: sh - $ GETH_BINARY=~/.py-geth/geth-v1.10.13/bin/geth python ./tests/integration/generate_fixtures/go_ethereum.py ./tests/integration/geth-1.10.13-fixture + $ GETH_BINARY=~/.py-geth/geth-v1.10.17/bin/geth python ./tests/integration/generate_fixtures/go_ethereum.py ./tests/integration/geth-1.10.17-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. diff --git a/newsfragments/2054.misc.rst b/newsfragments/2054.misc.rst new file mode 100644 index 0000000000..946cd50210 --- /dev/null +++ b/newsfragments/2054.misc.rst @@ -0,0 +1 @@ +Update integration test fixture to use geth ``v1.10.17`` diff --git a/setup.py b/setup.py index 35b4e0f2d3..07b54a33c1 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ extras_require = { 'tester': [ "eth-tester[py-evm]==v0.6.0-beta.5", - "py-geth>=3.7.0,<4", + "py-geth>=3.8.0,<4", ], 'linter': [ "flake8==3.8.3", @@ -23,7 +23,7 @@ "click>=5.1", "configparser==3.5.0", "contextlib2>=0.5.4", - "py-geth>=3.6.0,<4", + "py-geth>=3.8.0,<4", "py-solc>=0.4.0", "pytest>=6.2.5,<7", "sphinx>=4.2.0,<5", diff --git a/tests/integration/geth-1.10.13-fixture.zip b/tests/integration/geth-1.10.13-fixture.zip deleted file mode 100644 index 019622a3a410d313c891e24a62e0dbdf9925f1a8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 39419 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 literal 0 HcmV?d00001 diff --git a/tests/integration/go_ethereum/conftest.py b/tests/integration/go_ethereum/conftest.py index 622e11f106..c4ce4bf79a 100644 --- a/tests/integration/go_ethereum/conftest.py +++ b/tests/integration/go_ethereum/conftest.py @@ -19,7 +19,7 @@ KEYFILE_PW = 'web3py-test' -GETH_FIXTURE_ZIP = 'geth-1.10.13-fixture.zip' +GETH_FIXTURE_ZIP = 'geth-1.10.17-fixture.zip' @pytest.fixture(scope='module') diff --git a/web3/tools/benchmark/node.py b/web3/tools/benchmark/node.py index 2cc23d0fe6..52eda6a173 100644 --- a/web3/tools/benchmark/node.py +++ b/web3/tools/benchmark/node.py @@ -24,7 +24,7 @@ kill_proc_gracefully, ) -GETH_FIXTURE_ZIP = "geth-1.10.13-fixture.zip" +GETH_FIXTURE_ZIP = "geth-1.10.17-fixture.zip" class GethBenchmarkFixture: From 595e55ec29a895dd32e4cbd3dfaab1726d4ae766 Mon Sep 17 00:00:00 2001 From: Felipe Selmo Date: Mon, 2 May 2022 12:24:54 -0600 Subject: [PATCH 50/57] Add pytest xfail with strict=False to flaky eth estimate_gas tests. - Added test_eth_get_transaction_receipt_unmined and test_eth_wait_for_transaction_receipt_unmined to the list of flaky tests with timeout issues. --- newsfragments/2054.misc.rst | 2 +- tests/integration/go_ethereum/common.py | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/newsfragments/2054.misc.rst b/newsfragments/2054.misc.rst index 946cd50210..03c910331a 100644 --- a/newsfragments/2054.misc.rst +++ b/newsfragments/2054.misc.rst @@ -1 +1 @@ -Update integration test fixture to use geth ``v1.10.17`` +Update integration test fixture to use geth ``v1.10.17``. Add pytest ``xfail`` with ``strict=False`` to flaky eth estimate_gas tests. diff --git a/tests/integration/go_ethereum/common.py b/tests/integration/go_ethereum/common.py index 67802a397e..8f343d61b2 100644 --- a/tests/integration/go_ethereum/common.py +++ b/tests/integration/go_ethereum/common.py @@ -6,9 +6,6 @@ from eth_typing import ( ChecksumAddress, ) -from flaky import ( - flaky, -) from web3._utils.module_testing import ( # noqa: F401 AsyncEthModuleTest, @@ -55,24 +52,36 @@ def test_eth_protocol_version(self, w3): def test_eth_protocolVersion(self, w3): super().test_eth_protocolVersion(w3) - @flaky(max_runs=3) + @pytest.mark.xfail(reason='Inconsistently creating timeout issues.', strict=False) def test_eth_estimate_gas( self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: super().test_eth_estimate_gas(w3, unlocked_account_dual_type) - @flaky(max_runs=3) + @pytest.mark.xfail(reason='Inconsistently creating timeout issues.', strict=False) def test_eth_estimateGas_deprecated( self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: super().test_eth_estimateGas_deprecated(w3, unlocked_account_dual_type) - @flaky(max_runs=3) + @pytest.mark.xfail(reason='Inconsistently creating timeout issues.', strict=False) def test_eth_estimate_gas_with_block( self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress ) -> None: super().test_eth_estimate_gas_with_block(w3, unlocked_account_dual_type) + @pytest.mark.xfail(reason='Inconsistently creating timeout issues.', strict=False) + def test_eth_get_transaction_receipt_unmined( + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress + ) -> None: + super().test_eth_get_transaction_receipt_unmined(w3, unlocked_account_dual_type) + + @pytest.mark.xfail(reason='Inconsistently creating timeout issues.', strict=False) + def test_eth_wait_for_transaction_receipt_unmined( + self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress + ) -> None: + super().test_eth_wait_for_transaction_receipt_unmined(w3, unlocked_account_dual_type) + class GoEthereumVersionModuleTest(VersionModuleTest): @pytest.mark.xfail(reason='eth_protocolVersion was removed in Geth 1.10.0') From 5f7f68ff5b8f4fcf1b63776d643bce22accd2a7b Mon Sep 17 00:00:00 2001 From: Felipe Selmo Date: Mon, 2 May 2022 14:02:20 -0600 Subject: [PATCH 51/57] More flaky tests with timeouts added to loose xfail list --- tests/integration/go_ethereum/common.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/integration/go_ethereum/common.py b/tests/integration/go_ethereum/common.py index 8f343d61b2..fa98cb1b70 100644 --- a/tests/integration/go_ethereum/common.py +++ b/tests/integration/go_ethereum/common.py @@ -19,6 +19,9 @@ VersionModuleTest, Web3ModuleTest, ) +from web3.types import ( + BlockData, +) if TYPE_CHECKING: from web3 import ( # noqa: F401 @@ -82,6 +85,16 @@ def test_eth_wait_for_transaction_receipt_unmined( ) -> None: super().test_eth_wait_for_transaction_receipt_unmined(w3, unlocked_account_dual_type) + @pytest.mark.xfail(reason='Inconsistently creating timeout issues.', strict=False) + def test_eth_get_raw_transaction_by_block( + self, w3: "Web3", + unlocked_account_dual_type: ChecksumAddress, + block_with_txn: BlockData, + ) -> None: + super().test_eth_get_raw_transaction_by_block( + w3, unlocked_account_dual_type, block_with_txn + ) + class GoEthereumVersionModuleTest(VersionModuleTest): @pytest.mark.xfail(reason='eth_protocolVersion was removed in Geth 1.10.0') From bc20bdc4b74d51022842420d8caa744555321bb9 Mon Sep 17 00:00:00 2001 From: Felipe Selmo Date: Fri, 25 Mar 2022 17:34:14 -0600 Subject: [PATCH 52/57] Add ENSIP-10 support: - Adds support for extended resolvers for wildcard resolution as defined by ENSIP-10. - Adds the method ``parent()`` to the ENS class whose function is to extract the proper parent from an ENS name. - Adds the ``ens_encode_name()`` method that uses DNS name-encoding standards with a few tweaks, such as skipping the fully-encoded length validation for the domain (limit of 255 for DNS) and encoding the empty names as defined by ENSIP-10 as a single zero byte ``b'\x00'``. Unrelated: - Minor cleanup for some existing ens tests --- ens/abis.py | 3009 ++++++++++++++++--------------- ens/constants.py | 6 + ens/contract_data.py | 43 +- ens/exceptions.py | 14 + ens/main.py | 174 +- ens/utils.py | 64 +- newsfragments/2411.feature.rst | 1 + tests/ens/conftest.py | 45 +- tests/ens/test_get_text.py | 59 +- tests/ens/test_setup_address.py | 19 +- tests/ens/test_setup_name.py | 8 +- 11 files changed, 1901 insertions(+), 1541 deletions(-) create mode 100644 newsfragments/2411.feature.rst diff --git a/ens/abis.py b/ens/abis.py index 5ce9474df2..9706a2d78c 100644 --- a/ens/abis.py +++ b/ens/abis.py @@ -1,1473 +1,1586 @@ # flake8: noqa ENS = [ - { - "constant": True, - "inputs": [ - { - "name": "node", - "type": "bytes32" - } - ], - "name": "resolver", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "payable": False, - "type": "function" - }, - { - "constant": True, - "inputs": [ - { - "name": "node", - "type": "bytes32" - } - ], - "name": "owner", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "payable": False, - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "node", - "type": "bytes32" - }, - { - "name": "label", - "type": "bytes32" - }, - { - "name": "owner", - "type": "address" - } - ], - "name": "setSubnodeOwner", - "outputs": [], - "payable": False, - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "node", - "type": "bytes32" - }, - { - "name": "ttl", - "type": "uint64" - } - ], - "name": "setTTL", - "outputs": [], - "payable": False, - "type": "function" - }, - { - "constant": True, - "inputs": [ - { - "name": "node", - "type": "bytes32" - } - ], - "name": "ttl", - "outputs": [ - { - "name": "", - "type": "uint64" - } - ], - "payable": False, - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "node", - "type": "bytes32" - }, - { + { + "constant": True, + "inputs": [ + { + "name": "node", + "type": "bytes32" + } + ], "name": "resolver", - "type": "address" - } - ], - "name": "setResolver", - "outputs": [], - "payable": False, - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "node", - "type": "bytes32" - }, - { - "name": "owner", - "type": "address" - } - ], - "name": "setOwner", - "outputs": [], - "payable": False, - "type": "function" - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": True, - "name": "node", - "type": "bytes32" - }, - { - "indexed": False, - "name": "owner", - "type": "address" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": True, - "name": "node", - "type": "bytes32" - }, - { - "indexed": True, - "name": "label", - "type": "bytes32" - }, - { - "indexed": False, + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": False, + "type": "function" + }, + { + "constant": True, + "inputs": [ + { + "name": "node", + "type": "bytes32" + } + ], "name": "owner", - "type": "address" - } - ], - "name": "NewOwner", - "type": "event" - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": True, - "name": "node", - "type": "bytes32" - }, - { - "indexed": False, - "name": "resolver", - "type": "address" - } - ], - "name": "NewResolver", - "type": "event" - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": True, - "name": "node", - "type": "bytes32" - }, - { - "indexed": False, + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": False, + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "node", + "type": "bytes32" + }, + { + "name": "label", + "type": "bytes32" + }, + { + "name": "owner", + "type": "address" + } + ], + "name": "setSubnodeOwner", + "outputs": [], + "payable": False, + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "node", + "type": "bytes32" + }, + { + "name": "ttl", + "type": "uint64" + } + ], + "name": "setTTL", + "outputs": [], + "payable": False, + "type": "function" + }, + { + "constant": True, + "inputs": [ + { + "name": "node", + "type": "bytes32" + } + ], "name": "ttl", - "type": "uint64" - } - ], - "name": "NewTTL", - "type": "event" - } + "outputs": [ + { + "name": "", + "type": "uint64" + } + ], + "payable": False, + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "node", + "type": "bytes32" + }, + { + "name": "resolver", + "type": "address" + } + ], + "name": "setResolver", + "outputs": [], + "payable": False, + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "node", + "type": "bytes32" + }, + { + "name": "owner", + "type": "address" + } + ], + "name": "setOwner", + "outputs": [], + "payable": False, + "type": "function" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "name": "node", + "type": "bytes32" + }, + { + "indexed": False, + "name": "owner", + "type": "address" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "name": "node", + "type": "bytes32" + }, + { + "indexed": True, + "name": "label", + "type": "bytes32" + }, + { + "indexed": False, + "name": "owner", + "type": "address" + } + ], + "name": "NewOwner", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "name": "node", + "type": "bytes32" + }, + { + "indexed": False, + "name": "resolver", + "type": "address" + } + ], + "name": "NewResolver", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "name": "node", + "type": "bytes32" + }, + { + "indexed": False, + "name": "ttl", + "type": "uint64" + } + ], + "name": "NewTTL", + "type": "event" + } ] AUCTION_REGISTRAR = [ - { - "constant": False, - "inputs": [ - { - "name": "_hash", - "type": "bytes32" - } - ], - "name": "releaseDeed", - "outputs": [], - "payable": False, - "type": "function" - }, - { - "constant": True, - "inputs": [ - { - "name": "_hash", - "type": "bytes32" - } - ], - "name": "getAllowedTime", - "outputs": [ - { - "name": "timestamp", - "type": "uint256" - } - ], - "payable": False, - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "unhashedName", - "type": "string" - } - ], - "name": "invalidateName", - "outputs": [], - "payable": False, - "type": "function" - }, - { - "constant": True, - "inputs": [ - { - "name": "hash", - "type": "bytes32" - }, - { - "name": "owner", - "type": "address" - }, - { - "name": "value", - "type": "uint256" - }, - { - "name": "salt", - "type": "bytes32" - } - ], - "name": "shaBid", - "outputs": [ - { - "name": "sealedBid", - "type": "bytes32" - } - ], - "payable": False, - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "bidder", - "type": "address" - }, - { - "name": "seal", - "type": "bytes32" - } - ], - "name": "cancelBid", - "outputs": [], - "payable": False, - "type": "function" - }, - { - "constant": True, - "inputs": [ - { - "name": "_hash", - "type": "bytes32" - } - ], - "name": "entries", - "outputs": [ - { - "name": "", - "type": "uint8" - }, - { - "name": "", - "type": "address" - }, - { - "name": "", - "type": "uint256" - }, - { - "name": "", - "type": "uint256" - }, - { - "name": "", - "type": "uint256" - } - ], - "payable": False, - "type": "function" - }, - { - "constant": True, - "inputs": [], - "name": "ens", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "payable": False, - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "_hash", - "type": "bytes32" - }, - { - "name": "_value", - "type": "uint256" - }, - { - "name": "_salt", - "type": "bytes32" - } - ], - "name": "unsealBid", - "outputs": [], - "payable": False, - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "_hash", - "type": "bytes32" - } - ], - "name": "transferRegistrars", - "outputs": [], - "payable": False, - "type": "function" - }, - { - "constant": True, - "inputs": [ - { - "name": "", - "type": "address" - }, - { - "name": "", - "type": "bytes32" - } - ], - "name": "sealedBids", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "payable": False, - "type": "function" - }, - { - "constant": True, - "inputs": [ - { - "name": "_hash", - "type": "bytes32" - } - ], - "name": "state", - "outputs": [ - { - "name": "", - "type": "uint8" - } - ], - "payable": False, - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "_hash", - "type": "bytes32" - }, - { - "name": "newOwner", - "type": "address" - } - ], - "name": "transfer", - "outputs": [], - "payable": False, - "type": "function" - }, - { - "constant": True, - "inputs": [ - { - "name": "_hash", - "type": "bytes32" - }, - { - "name": "_timestamp", - "type": "uint256" - } - ], - "name": "isAllowed", - "outputs": [ - { - "name": "allowed", - "type": "bool" - } - ], - "payable": False, - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "_hash", - "type": "bytes32" - } - ], - "name": "finalizeAuction", - "outputs": [], - "payable": False, - "type": "function" - }, - { - "constant": True, - "inputs": [], - "name": "registryStarted", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": False, - "type": "function" - }, - { - "constant": True, - "inputs": [], - "name": "launchLength", - "outputs": [ - { - "name": "", - "type": "uint32" - } - ], - "payable": False, - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "sealedBid", - "type": "bytes32" - } - ], - "name": "newBid", - "outputs": [], - "payable": True, - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "labels", - "type": "bytes32[]" - } - ], - "name": "eraseNode", - "outputs": [], - "payable": False, - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "_hashes", - "type": "bytes32[]" - } - ], - "name": "startAuctions", - "outputs": [], - "payable": False, - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "hash", - "type": "bytes32" - }, - { - "name": "deed", - "type": "address" - }, - { - "name": "registrationDate", - "type": "uint256" - } - ], - "name": "acceptRegistrarTransfer", - "outputs": [], - "payable": False, - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "_hash", - "type": "bytes32" - } - ], - "name": "startAuction", - "outputs": [], - "payable": False, - "type": "function" - }, - { - "constant": True, - "inputs": [], - "name": "rootNode", - "outputs": [ - { - "name": "", - "type": "bytes32" - } - ], - "payable": False, - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "hashes", - "type": "bytes32[]" - }, - { - "name": "sealedBid", - "type": "bytes32" - } - ], - "name": "startAuctionsAndBid", - "outputs": [], - "payable": True, - "type": "function" - }, - { - "inputs": [ - { - "name": "_ens", - "type": "address" - }, - { - "name": "_rootNode", - "type": "bytes32" - }, - { - "name": "_startDate", - "type": "uint256" - } - ], - "payable": False, - "type": "constructor" - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": True, - "name": "hash", - "type": "bytes32" - }, - { - "indexed": False, - "name": "registrationDate", - "type": "uint256" - } - ], - "name": "AuctionStarted", - "type": "event" - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": True, - "name": "hash", - "type": "bytes32" - }, - { - "indexed": True, - "name": "bidder", - "type": "address" - }, - { - "indexed": False, - "name": "deposit", - "type": "uint256" - } - ], - "name": "NewBid", - "type": "event" - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": True, - "name": "hash", - "type": "bytes32" - }, - { - "indexed": True, - "name": "owner", - "type": "address" - }, - { - "indexed": False, - "name": "value", - "type": "uint256" - }, - { - "indexed": False, - "name": "status", - "type": "uint8" - } - ], - "name": "BidRevealed", - "type": "event" - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": True, - "name": "hash", - "type": "bytes32" - }, - { - "indexed": True, - "name": "owner", - "type": "address" - }, - { - "indexed": False, - "name": "value", - "type": "uint256" - }, - { - "indexed": False, - "name": "registrationDate", - "type": "uint256" - } - ], - "name": "HashRegistered", - "type": "event" - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": True, - "name": "hash", - "type": "bytes32" - }, - { - "indexed": False, - "name": "value", - "type": "uint256" - } - ], - "name": "HashReleased", - "type": "event" - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": True, - "name": "hash", - "type": "bytes32" - }, - { - "indexed": True, - "name": "name", - "type": "string" - }, - { - "indexed": False, - "name": "value", - "type": "uint256" - }, - { - "indexed": False, - "name": "registrationDate", - "type": "uint256" - } - ], - "name": "HashInvalidated", - "type": "event" - } + { + "constant": False, + "inputs": [ + { + "name": "_hash", + "type": "bytes32" + } + ], + "name": "releaseDeed", + "outputs": [], + "payable": False, + "type": "function" + }, + { + "constant": True, + "inputs": [ + { + "name": "_hash", + "type": "bytes32" + } + ], + "name": "getAllowedTime", + "outputs": [ + { + "name": "timestamp", + "type": "uint256" + } + ], + "payable": False, + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "unhashedName", + "type": "string" + } + ], + "name": "invalidateName", + "outputs": [], + "payable": False, + "type": "function" + }, + { + "constant": True, + "inputs": [ + { + "name": "hash", + "type": "bytes32" + }, + { + "name": "owner", + "type": "address" + }, + { + "name": "value", + "type": "uint256" + }, + { + "name": "salt", + "type": "bytes32" + } + ], + "name": "shaBid", + "outputs": [ + { + "name": "sealedBid", + "type": "bytes32" + } + ], + "payable": False, + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "bidder", + "type": "address" + }, + { + "name": "seal", + "type": "bytes32" + } + ], + "name": "cancelBid", + "outputs": [], + "payable": False, + "type": "function" + }, + { + "constant": True, + "inputs": [ + { + "name": "_hash", + "type": "bytes32" + } + ], + "name": "entries", + "outputs": [ + { + "name": "", + "type": "uint8" + }, + { + "name": "", + "type": "address" + }, + { + "name": "", + "type": "uint256" + }, + { + "name": "", + "type": "uint256" + }, + { + "name": "", + "type": "uint256" + } + ], + "payable": False, + "type": "function" + }, + { + "constant": True, + "inputs": [], + "name": "ens", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": False, + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "_hash", + "type": "bytes32" + }, + { + "name": "_value", + "type": "uint256" + }, + { + "name": "_salt", + "type": "bytes32" + } + ], + "name": "unsealBid", + "outputs": [], + "payable": False, + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "_hash", + "type": "bytes32" + } + ], + "name": "transferRegistrars", + "outputs": [], + "payable": False, + "type": "function" + }, + { + "constant": True, + "inputs": [ + { + "name": "", + "type": "address" + }, + { + "name": "", + "type": "bytes32" + } + ], + "name": "sealedBids", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": False, + "type": "function" + }, + { + "constant": True, + "inputs": [ + { + "name": "_hash", + "type": "bytes32" + } + ], + "name": "state", + "outputs": [ + { + "name": "", + "type": "uint8" + } + ], + "payable": False, + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "_hash", + "type": "bytes32" + }, + { + "name": "newOwner", + "type": "address" + } + ], + "name": "transfer", + "outputs": [], + "payable": False, + "type": "function" + }, + { + "constant": True, + "inputs": [ + { + "name": "_hash", + "type": "bytes32" + }, + { + "name": "_timestamp", + "type": "uint256" + } + ], + "name": "isAllowed", + "outputs": [ + { + "name": "allowed", + "type": "bool" + } + ], + "payable": False, + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "_hash", + "type": "bytes32" + } + ], + "name": "finalizeAuction", + "outputs": [], + "payable": False, + "type": "function" + }, + { + "constant": True, + "inputs": [], + "name": "registryStarted", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": False, + "type": "function" + }, + { + "constant": True, + "inputs": [], + "name": "launchLength", + "outputs": [ + { + "name": "", + "type": "uint32" + } + ], + "payable": False, + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "sealedBid", + "type": "bytes32" + } + ], + "name": "newBid", + "outputs": [], + "payable": True, + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "labels", + "type": "bytes32[]" + } + ], + "name": "eraseNode", + "outputs": [], + "payable": False, + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "_hashes", + "type": "bytes32[]" + } + ], + "name": "startAuctions", + "outputs": [], + "payable": False, + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "hash", + "type": "bytes32" + }, + { + "name": "deed", + "type": "address" + }, + { + "name": "registrationDate", + "type": "uint256" + } + ], + "name": "acceptRegistrarTransfer", + "outputs": [], + "payable": False, + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "_hash", + "type": "bytes32" + } + ], + "name": "startAuction", + "outputs": [], + "payable": False, + "type": "function" + }, + { + "constant": True, + "inputs": [], + "name": "rootNode", + "outputs": [ + { + "name": "", + "type": "bytes32" + } + ], + "payable": False, + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "hashes", + "type": "bytes32[]" + }, + { + "name": "sealedBid", + "type": "bytes32" + } + ], + "name": "startAuctionsAndBid", + "outputs": [], + "payable": True, + "type": "function" + }, + { + "inputs": [ + { + "name": "_ens", + "type": "address" + }, + { + "name": "_rootNode", + "type": "bytes32" + }, + { + "name": "_startDate", + "type": "uint256" + } + ], + "payable": False, + "type": "constructor" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "name": "hash", + "type": "bytes32" + }, + { + "indexed": False, + "name": "registrationDate", + "type": "uint256" + } + ], + "name": "AuctionStarted", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "name": "hash", + "type": "bytes32" + }, + { + "indexed": True, + "name": "bidder", + "type": "address" + }, + { + "indexed": False, + "name": "deposit", + "type": "uint256" + } + ], + "name": "NewBid", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "name": "hash", + "type": "bytes32" + }, + { + "indexed": True, + "name": "owner", + "type": "address" + }, + { + "indexed": False, + "name": "value", + "type": "uint256" + }, + { + "indexed": False, + "name": "status", + "type": "uint8" + } + ], + "name": "BidRevealed", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "name": "hash", + "type": "bytes32" + }, + { + "indexed": True, + "name": "owner", + "type": "address" + }, + { + "indexed": False, + "name": "value", + "type": "uint256" + }, + { + "indexed": False, + "name": "registrationDate", + "type": "uint256" + } + ], + "name": "HashRegistered", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "name": "hash", + "type": "bytes32" + }, + { + "indexed": False, + "name": "value", + "type": "uint256" + } + ], + "name": "HashReleased", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "name": "hash", + "type": "bytes32" + }, + { + "indexed": True, + "name": "name", + "type": "string" + }, + { + "indexed": False, + "name": "value", + "type": "uint256" + }, + { + "indexed": False, + "name": "registrationDate", + "type": "uint256" + } + ], + "name": "HashInvalidated", + "type": "event" + } ] DEED = [ - { - "constant": True, - "inputs": [], - "name": "creationDate", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": False, - "type": "function" - }, - { - "constant": False, - "inputs": [], - "name": "destroyDeed", - "outputs": [], - "payable": False, - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "newOwner", - "type": "address" - } - ], - "name": "setOwner", - "outputs": [], - "payable": False, - "type": "function" - }, - { - "constant": True, - "inputs": [], - "name": "registrar", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "payable": False, - "type": "function" - }, - { - "constant": True, - "inputs": [], - "name": "owner", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "payable": False, - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "refundRatio", - "type": "uint256" - } - ], - "name": "closeDeed", - "outputs": [], - "payable": False, - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "newRegistrar", - "type": "address" - } - ], - "name": "setRegistrar", - "outputs": [], - "payable": False, - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "newValue", - "type": "uint256" - } - ], - "name": "setBalance", - "outputs": [], - "payable": True, - "type": "function" - }, - { - "inputs": [], - "type": "constructor" - }, - { - "payable": True, - "type": "fallback" - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": False, - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnerChanged", - "type": "event" - }, - { - "anonymous": False, - "inputs": [], - "name": "DeedClosed", - "type": "event" - } + { + "constant": True, + "inputs": [], + "name": "creationDate", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": False, + "type": "function" + }, + { + "constant": False, + "inputs": [], + "name": "destroyDeed", + "outputs": [], + "payable": False, + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "newOwner", + "type": "address" + } + ], + "name": "setOwner", + "outputs": [], + "payable": False, + "type": "function" + }, + { + "constant": True, + "inputs": [], + "name": "registrar", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": False, + "type": "function" + }, + { + "constant": True, + "inputs": [], + "name": "owner", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": False, + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "refundRatio", + "type": "uint256" + } + ], + "name": "closeDeed", + "outputs": [], + "payable": False, + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "newRegistrar", + "type": "address" + } + ], + "name": "setRegistrar", + "outputs": [], + "payable": False, + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "newValue", + "type": "uint256" + } + ], + "name": "setBalance", + "outputs": [], + "payable": True, + "type": "function" + }, + { + "inputs": [], + "type": "constructor" + }, + { + "payable": True, + "type": "fallback" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnerChanged", + "type": "event" + }, + { + "anonymous": False, + "inputs": [], + "name": "DeedClosed", + "type": "event" + } ] FIFS_REGISTRAR = [ - { - "constant": True, - "inputs": [], - "name": "ens", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "payable": False, - "type": "function" - }, - { - "constant": True, - "inputs": [ - { - "name": "", - "type": "bytes32" - } - ], - "name": "expiryTimes", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": False, - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "subnode", - "type": "bytes32" - }, - { - "name": "owner", - "type": "address" - } - ], - "name": "register", - "outputs": [], - "payable": False, - "type": "function" - }, - { - "constant": True, - "inputs": [], - "name": "rootNode", - "outputs": [ - { - "name": "", - "type": "bytes32" - } - ], - "payable": False, - "type": "function" - }, - { - "inputs": [ - { - "name": "ensAddr", - "type": "address" - }, - { - "name": "node", - "type": "bytes32" - } - ], - "type": "constructor" - } + { + "constant": True, + "inputs": [], + "name": "ens", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": False, + "type": "function" + }, + { + "constant": True, + "inputs": [ + { + "name": "", + "type": "bytes32" + } + ], + "name": "expiryTimes", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": False, + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "subnode", + "type": "bytes32" + }, + { + "name": "owner", + "type": "address" + } + ], + "name": "register", + "outputs": [], + "payable": False, + "type": "function" + }, + { + "constant": True, + "inputs": [], + "name": "rootNode", + "outputs": [ + { + "name": "", + "type": "bytes32" + } + ], + "payable": False, + "type": "function" + }, + { + "inputs": [ + { + "name": "ensAddr", + "type": "address" + }, + { + "name": "node", + "type": "bytes32" + } + ], + "type": "constructor" + } ] RESOLVER = [ - { - "constant": True, - "inputs": [ - { - "name": "interfaceID", - "type": "bytes4" - } - ], - "name": "supportsInterface", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": False, - "stateMutability": "view", - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "node", - "type": "bytes32" - }, - { - "name": "key", - "type": "string" - }, - { - "name": "value", - "type": "string" - } - ], - "name": "setText", - "outputs": [], - "payable": False, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": True, - "inputs": [ - { - "name": "node", - "type": "bytes32" - }, - { - "name": "contentTypes", - "type": "uint256" - } - ], - "name": "ABI", - "outputs": [ - { - "name": "contentType", - "type": "uint256" - }, - { - "name": "data", - "type": "bytes" - } - ], - "payable": False, - "stateMutability": "view", - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "node", - "type": "bytes32" - }, - { - "name": "x", - "type": "bytes32" - }, - { - "name": "y", - "type": "bytes32" - } - ], - "name": "setPubkey", - "outputs": [], - "payable": False, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": True, - "inputs": [ - { - "name": "node", - "type": "bytes32" - } - ], - "name": "content", - "outputs": [ - { - "name": "ret", - "type": "bytes32" - } - ], - "payable": False, - "stateMutability": "view", - "type": "function" - }, - { - "constant": True, - "inputs": [ - { - "name": "node", - "type": "bytes32" - } - ], - "name": "addr", - "outputs": [ - { - "name": "ret", - "type": "address" - } - ], - "payable": False, - "stateMutability": "view", - "type": "function" - }, - { - "constant": True, - "inputs": [ - { - "name": "node", - "type": "bytes32" - }, - { - "name": "key", - "type": "string" - } - ], - "name": "text", - "outputs": [ - { - "name": "ret", - "type": "string" - } - ], - "payable": False, - "stateMutability": "view", - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "node", - "type": "bytes32" - }, - { - "name": "contentType", - "type": "uint256" - }, - { - "name": "data", - "type": "bytes" - } - ], - "name": "setABI", - "outputs": [], - "payable": False, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": True, - "inputs": [ - { - "name": "node", - "type": "bytes32" - } - ], - "name": "name", - "outputs": [ - { - "name": "ret", - "type": "string" - } - ], - "payable": False, - "stateMutability": "view", - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "node", - "type": "bytes32" - }, - { - "name": "name", - "type": "string" - } - ], - "name": "setName", - "outputs": [], - "payable": False, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "node", - "type": "bytes32" - }, - { - "name": "hash", - "type": "bytes32" - } - ], - "name": "setContent", - "outputs": [], - "payable": False, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": True, - "inputs": [ - { - "name": "node", - "type": "bytes32" - } - ], - "name": "pubkey", - "outputs": [ - { - "name": "x", - "type": "bytes32" - }, - { - "name": "y", - "type": "bytes32" - } - ], - "payable": False, - "stateMutability": "view", - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "node", - "type": "bytes32" - }, - { + { + "constant": True, + "inputs": [ + { + "name": "interfaceID", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": False, + "stateMutability": "view", + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "node", + "type": "bytes32" + }, + { + "name": "key", + "type": "string" + }, + { + "name": "value", + "type": "string" + } + ], + "name": "setText", + "outputs": [], + "payable": False, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": True, + "inputs": [ + { + "name": "node", + "type": "bytes32" + }, + { + "name": "contentTypes", + "type": "uint256" + } + ], + "name": "ABI", + "outputs": [ + { + "name": "contentType", + "type": "uint256" + }, + { + "name": "data", + "type": "bytes" + } + ], + "payable": False, + "stateMutability": "view", + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "node", + "type": "bytes32" + }, + { + "name": "x", + "type": "bytes32" + }, + { + "name": "y", + "type": "bytes32" + } + ], + "name": "setPubkey", + "outputs": [], + "payable": False, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": True, + "inputs": [ + { + "name": "node", + "type": "bytes32" + } + ], + "name": "content", + "outputs": [ + { + "name": "ret", + "type": "bytes32" + } + ], + "payable": False, + "stateMutability": "view", + "type": "function" + }, + { + "constant": True, + "inputs": [ + { + "name": "node", + "type": "bytes32" + } + ], "name": "addr", - "type": "address" - } - ], - "name": "setAddr", - "outputs": [], - "payable": False, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "name": "ensAddr", - "type": "address" - } - ], - "payable": False, - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": True, - "name": "node", - "type": "bytes32" - }, - { - "indexed": False, - "name": "a", - "type": "address" - } - ], - "name": "AddrChanged", - "type": "event" - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": True, - "name": "node", - "type": "bytes32" - }, - { - "indexed": False, - "name": "hash", - "type": "bytes32" - } - ], - "name": "ContentChanged", - "type": "event" - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": True, - "name": "node", - "type": "bytes32" - }, - { - "indexed": False, + "outputs": [ + { + "name": "ret", + "type": "address" + } + ], + "payable": False, + "stateMutability": "view", + "type": "function" + }, + { + "constant": True, + "inputs": [ + { + "name": "node", + "type": "bytes32" + }, + { + "name": "key", + "type": "string" + } + ], + "name": "text", + "outputs": [ + { + "name": "ret", + "type": "string" + } + ], + "payable": False, + "stateMutability": "view", + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "node", + "type": "bytes32" + }, + { + "name": "contentType", + "type": "uint256" + }, + { + "name": "data", + "type": "bytes" + } + ], + "name": "setABI", + "outputs": [], + "payable": False, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": True, + "inputs": [ + { + "name": "node", + "type": "bytes32" + } + ], "name": "name", - "type": "string" - } - ], - "name": "NameChanged", - "type": "event" - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": True, - "name": "node", - "type": "bytes32" - }, - { - "indexed": True, - "name": "contentType", - "type": "uint256" - } - ], - "name": "ABIChanged", - "type": "event" - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": True, - "name": "node", - "type": "bytes32" - }, - { - "indexed": False, - "name": "x", - "type": "bytes32" - }, - { - "indexed": False, - "name": "y", - "type": "bytes32" - } - ], - "name": "PubkeyChanged", - "type": "event" - }, - { - "anonymous": False, - "inputs": [ - { - "indexed": True, - "name": "node", - "type": "bytes32" - }, - { - "indexed": True, - "name": "indexedKey", - "type": "string" - }, - { - "indexed": False, - "name": "key", - "type": "string" - } - ], - "name": "TextChanged", - "type": "event" - } + "outputs": [ + { + "name": "ret", + "type": "string" + } + ], + "payable": False, + "stateMutability": "view", + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "node", + "type": "bytes32" + }, + { + "name": "name", + "type": "string" + } + ], + "name": "setName", + "outputs": [], + "payable": False, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "node", + "type": "bytes32" + }, + { + "name": "hash", + "type": "bytes32" + } + ], + "name": "setContent", + "outputs": [], + "payable": False, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": True, + "inputs": [ + { + "name": "node", + "type": "bytes32" + } + ], + "name": "pubkey", + "outputs": [ + { + "name": "x", + "type": "bytes32" + }, + { + "name": "y", + "type": "bytes32" + } + ], + "payable": False, + "stateMutability": "view", + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "node", + "type": "bytes32" + }, + { + "name": "addr", + "type": "address" + } + ], + "name": "setAddr", + "outputs": [], + "payable": False, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "name": "ensAddr", + "type": "address" + } + ], + "payable": False, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "name": "node", + "type": "bytes32" + }, + { + "indexed": False, + "name": "a", + "type": "address" + } + ], + "name": "AddrChanged", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "name": "node", + "type": "bytes32" + }, + { + "indexed": False, + "name": "hash", + "type": "bytes32" + } + ], + "name": "ContentChanged", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "name": "node", + "type": "bytes32" + }, + { + "indexed": False, + "name": "name", + "type": "string" + } + ], + "name": "NameChanged", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "name": "node", + "type": "bytes32" + }, + { + "indexed": True, + "name": "contentType", + "type": "uint256" + } + ], + "name": "ABIChanged", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "name": "node", + "type": "bytes32" + }, + { + "indexed": False, + "name": "x", + "type": "bytes32" + }, + { + "indexed": False, + "name": "y", + "type": "bytes32" + } + ], + "name": "PubkeyChanged", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "name": "node", + "type": "bytes32" + }, + { + "indexed": True, + "name": "indexedKey", + "type": "string" + }, + { + "indexed": False, + "name": "key", + "type": "string" + } + ], + "name": "TextChanged", + "type": "event" + } +] + +EXTENDED_RESOLVER = [ + { + "constant": False, + "inputs": [ + { + "internalType": "bytes", + "name": "name", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "resolve", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "internalType": "bytes", + "name": "response", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "extraData", + "type": "bytes" + } + ], + "name": "resolveWithProof", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", "type": "function" + } +] + RESOLVER + +REVERSE_RESOLVER = [ + { + 'constant': True, + 'inputs': [], + 'name': 'ens', + 'outputs': [ + { + 'name': '', + 'type': 'address'} + ], + 'payable': False, + 'stateMutability': 'view', + 'type': 'function' + }, + { + 'constant': True, + 'inputs': [ + { + 'name': '', + 'type': 'bytes32'} + ], + 'name': 'name', + 'outputs': [ + { + 'name': '', + 'type': 'string' + } + ], + 'payable': False, + 'stateMutability': 'view', + 'type': 'function' + }, + { + 'constant': False, + 'inputs': [ + { + 'name': 'node', + 'type': 'bytes32' + }, + { + 'name': '_name', 'type': 'string' + } + ], + 'name': 'setName', + 'outputs': [], + 'payable': False, + 'stateMutability': 'nonpayable', + 'type': 'function'}, + { + 'inputs': [ + { + 'name': 'ensAddr', + 'type': 'address' + } + ], + 'payable': False, + 'stateMutability': 'nonpayable', + 'type': 'constructor' + } ] REVERSE_REGISTRAR = [ - { - "constant": False, - "inputs": [ - { - "name": "owner", - "type": "address" - }, - { - "name": "resolver", - "type": "address" - } - ], - "name": "claimWithResolver", - "outputs": [ - { - "name": "node", - "type": "bytes32" - } - ], - "payable": False, - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "owner", - "type": "address" - } - ], - "name": "claim", - "outputs": [ - { - "name": "node", - "type": "bytes32" - } - ], - "payable": False, - "type": "function" - }, - { - "constant": True, - "inputs": [], - "name": "ens", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "payable": False, - "type": "function" - }, - { - "constant": True, - "inputs": [], - "name": "defaultResolver", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "payable": False, - "type": "function" - }, - { - "constant": True, - "inputs": [ - { - "name": "addr", - "type": "address" - } - ], - "name": "node", - "outputs": [ - { - "name": "ret", - "type": "bytes32" - } - ], - "payable": False, - "type": "function" - }, - { - "constant": False, - "inputs": [ - { - "name": "name", - "type": "string" - } - ], - "name": "setName", - "outputs": [ - { + { + "constant": False, + "inputs": [ + { + "name": "owner", + "type": "address" + }, + { + "name": "resolver", + "type": "address" + } + ], + "name": "claimWithResolver", + "outputs": [ + { + "name": "node", + "type": "bytes32" + } + ], + "payable": False, + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "owner", + "type": "address" + } + ], + "name": "claim", + "outputs": [ + { + "name": "node", + "type": "bytes32" + } + ], + "payable": False, + "type": "function" + }, + { + "constant": True, + "inputs": [], + "name": "ens", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": False, + "type": "function" + }, + { + "constant": True, + "inputs": [], + "name": "defaultResolver", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": False, + "type": "function" + }, + { + "constant": True, + "inputs": [ + { + "name": "addr", + "type": "address" + } + ], "name": "node", - "type": "bytes32" - } - ], - "payable": False, - "type": "function" - }, - { - "inputs": [ - { - "name": "ensAddr", - "type": "address" - }, - { - "name": "resolverAddr", - "type": "address" - } - ], - "payable": False, - "type": "constructor" - } + "outputs": [ + { + "name": "ret", + "type": "bytes32" + } + ], + "payable": False, + "type": "function" + }, + { + "constant": False, + "inputs": [ + { + "name": "name", + "type": "string" + } + ], + "name": "setName", + "outputs": [ + { + "name": "node", + "type": "bytes32" + } + ], + "payable": False, + "type": "function" + }, + { + "inputs": [ + { + "name": "ensAddr", + "type": "address" + }, + { + "name": "resolverAddr", + "type": "address" + } + ], + "payable": False, + "type": "constructor" + } ] diff --git a/ens/constants.py b/ens/constants.py index 78455f4e30..eb8ce5b461 100644 --- a/ens/constants.py +++ b/ens/constants.py @@ -18,3 +18,9 @@ REVERSE_REGISTRAR_DOMAIN = 'addr.reverse' ENS_MAINNET_ADDR = ChecksumAddress(HexAddress(HexStr('0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e'))) + + +# --- interface ids --- # + +GET_TEXT_INTERFACE_ID = HexStr("0x59d1d43c") +EXTENDED_RESOLVER_INTERFACE_ID = HexStr('0x9061b923') # ENSIP-10 diff --git a/ens/contract_data.py b/ens/contract_data.py index 76e5a409da..6ec924d031 100644 --- a/ens/contract_data.py +++ b/ens/contract_data.py @@ -1,19 +1,42 @@ # flake8: noqa import json -registrar_abi = json.loads('[{"constant":false,"inputs":[{"name":"_hash","type":"bytes32"}],"name":"releaseDeed","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_hash","type":"bytes32"}],"name":"getAllowedTime","outputs":[{"name":"timestamp","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"unhashedName","type":"string"}],"name":"invalidateName","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"hash","type":"bytes32"},{"name":"owner","type":"address"},{"name":"value","type":"uint256"},{"name":"salt","type":"bytes32"}],"name":"shaBid","outputs":[{"name":"sealedBid","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"bidder","type":"address"},{"name":"seal","type":"bytes32"}],"name":"cancelBid","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_hash","type":"bytes32"}],"name":"entries","outputs":[{"name":"","type":"uint8"},{"name":"","type":"address"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"ens","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_hash","type":"bytes32"},{"name":"_value","type":"uint256"},{"name":"_salt","type":"bytes32"}],"name":"unsealBid","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_hash","type":"bytes32"}],"name":"transferRegistrars","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"bytes32"}],"name":"sealedBids","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_hash","type":"bytes32"}],"name":"state","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_hash","type":"bytes32"},{"name":"newOwner","type":"address"}],"name":"transfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_hash","type":"bytes32"},{"name":"_timestamp","type":"uint256"}],"name":"isAllowed","outputs":[{"name":"allowed","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_hash","type":"bytes32"}],"name":"finalizeAuction","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"registryStarted","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"launchLength","outputs":[{"name":"","type":"uint32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"sealedBid","type":"bytes32"}],"name":"newBid","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"labels","type":"bytes32[]"}],"name":"eraseNode","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_hashes","type":"bytes32[]"}],"name":"startAuctions","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"hash","type":"bytes32"},{"name":"deed","type":"address"},{"name":"registrationDate","type":"uint256"}],"name":"acceptRegistrarTransfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_hash","type":"bytes32"}],"name":"startAuction","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"rootNode","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"hashes","type":"bytes32[]"},{"name":"sealedBid","type":"bytes32"}],"name":"startAuctionsAndBid","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"inputs":[{"name":"_ens","type":"address"},{"name":"_rootNode","type":"bytes32"},{"name":"_startDate","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"hash","type":"bytes32"},{"indexed":false,"name":"registrationDate","type":"uint256"}],"name":"AuctionStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"hash","type":"bytes32"},{"indexed":true,"name":"bidder","type":"address"},{"indexed":false,"name":"deposit","type":"uint256"}],"name":"NewBid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"hash","type":"bytes32"},{"indexed":true,"name":"owner","type":"address"},{"indexed":false,"name":"value","type":"uint256"},{"indexed":false,"name":"status","type":"uint8"}],"name":"BidRevealed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"hash","type":"bytes32"},{"indexed":true,"name":"owner","type":"address"},{"indexed":false,"name":"value","type":"uint256"},{"indexed":false,"name":"registrationDate","type":"uint256"}],"name":"HashRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"hash","type":"bytes32"},{"indexed":false,"name":"value","type":"uint256"}],"name":"HashReleased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"hash","type":"bytes32"},{"indexed":true,"name":"name","type":"string"},{"indexed":false,"name":"value","type":"uint256"},{"indexed":false,"name":"registrationDate","type":"uint256"}],"name":"HashInvalidated","type":"event"}]') -registrar_bytecode = "6060604052341561000f57600080fd5b60405160608061275783398101604052808051919060200180519190602001805160008054600160a060020a031916600160a060020a0387161781556001859055909250821190506100615742610063565b805b6004555050506126df806100786000396000f300606060405236156101175763ffffffff60e060020a6000350416630230a07c811461011c57806313c89a8f1461013457806315f733311461015c57806322ec1244146101ad5780632525f5c1146101d5578063267b6922146101f75780633f15457f1461025f57806347872b421461028e5780635ddae283146102aa5780635e431709146102c057806361d585da146102e257806379ce9fac1461031c578063935033371461033e578063983b94fb1461036b5780639c67f06f14610381578063ae1a0b0c14610394578063ce92dced146103c0578063de10f04b146103cb578063e27fe50f1461041a578063ea9e107a14610469578063ede8acdb1461048e578063faff50a8146104a4578063febefd61146104b7575b600080fd5b341561012757600080fd5b6101326004356104fd565b005b341561013f57600080fd5b61014a60043561072a565b60405190815260200160405180910390f35b341561016757600080fd5b61013260046024813581810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965061074e95505050505050565b34156101b857600080fd5b61014a600435600160a060020a0360243516604435606435610a7a565b34156101e057600080fd5b610132600160a060020a0360043516602435610ac5565b341561020257600080fd5b61020d600435610c8c565b6040518086600581111561021d57fe5b60ff16815260200185600160a060020a0316600160a060020a031681526020018481526020018381526020018281526020019550505050505060405180910390f35b341561026a57600080fd5b610272610cd8565b604051600160a060020a03909116815260200160405180910390f35b341561029957600080fd5b610132600435602435604435610ce7565b34156102b557600080fd5b610132600435611254565b34156102cb57600080fd5b610272600160a060020a03600435166024356114b4565b34156102ed57600080fd5b6102f86004356114da565b6040518082600581111561030857fe5b60ff16815260200191505060405180910390f35b341561032757600080fd5b610132600435600160a060020a0360243516611550565b341561034957600080fd5b61035760043560243561169b565b604051901515815260200160405180910390f35b341561037657600080fd5b6101326004356116b1565b341561038c57600080fd5b61014a611919565b341561039f57600080fd5b6103a761191f565b60405163ffffffff909116815260200160405180910390f35b610132600435611926565b34156103d657600080fd5b6101326004602481358181019083013580602081810201604051908101604052809392919081815260200183836020028082843750949650611a1a95505050505050565b341561042557600080fd5b6101326004602481358181019083013580602081810201604051908101604052809392919081815260200183836020028082843750949650611a7595505050505050565b341561047457600080fd5b610132600435600160a060020a0360243516604435611aab565b341561049957600080fd5b610132600435611ab0565b34156104af57600080fd5b61014a611bfc565b61013260046024813581810190830135806020818102016040519081016040528093929190818152602001838360200280828437509496505093359350611c0292505050565b60008082600261050c826114da565b600581111561051757fe5b1415806105a3575060008181526002602052604080822054600160a060020a031691638da5cb5b9151602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561057257600080fd5b6102c65a03f1151561058357600080fd5b50505060405180519050600160a060020a031633600160a060020a031614155b156105ad57600080fd5b600084815260026020526040902080546001820154919450600160a060020a031692506301e13380014210801561065f575060008054600154600160a060020a03308116939216916302571be391906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561063957600080fd5b6102c65a03f1151561064a57600080fd5b50505060405180519050600160a060020a0316145b1561066957600080fd5b60006002840181905560038401558254600160a060020a031916835561068e84611c14565b81600160a060020a031663bbe427716103e860405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b15156106d657600080fd5b6102c65a03f115156106e757600080fd5b505050600283015484907f292b79b9246fa2c8e77d3fe195b251f9cb839d7d038e667c069ee7708c631e169060405190815260200160405180910390a250505050565b6004547001000000000000000000000000000000006249d400818404020401919050565b600080826040518082805190602001908083835b602083106107815780518252601f199092019160209182019101610762565b6001836020036101000a03801982511681845116179092525050509190910192506040915050519081900390206002806107ba836114da565b60058111156107c557fe5b146107cf57600080fd5b60066107da86611e12565b11156107e557600080fd5b846040518082805190602001908083835b602083106108155780518252601f1990920191602091820191016107f6565b6001836020036101000a03801982511681845116179092525050509190910192506040915050519081900390206000818152600260205260409020909450925061085e84611c14565b8254600160a060020a0316156109b5576108838360020154662386f26fc10000611ec3565b60028085018290558454600160a060020a03169163b0c80972919004600060405160e060020a63ffffffff8516028152600481019290925215156024820152604401600060405180830381600087803b15156108de57600080fd5b6102c65a03f115156108ef57600080fd5b50508354600160a060020a031690506313af40353360405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b151561094257600080fd5b6102c65a03f1151561095357600080fd5b50508354600160a060020a0316905063bbe427716103e860405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b15156109a057600080fd5b6102c65a03f115156109b157600080fd5b5050505b846040518082805190602001908083835b602083106109e55780518252601f1990920191602091820191016109c6565b6001836020036101000a0380198251168184511617909252505050919091019250604091505051809103902084600019167f1f9c649fe47e58bb60f4e52f0d90e4c47a526c9f90c5113df842c025970b66ad8560020154866001015460405191825260208201526040908101905180910390a3505060006002820181905560038201558054600160a060020a03191690555050565b600084848484604051938452600160a060020a03929092166c010000000000000000000000000260208401526034830152605482015260740160405180910390209050949350505050565b600160a060020a03808316600090815260036020908152604080832085845290915290205416801580610b61575062069780600160a060020a0382166305b344106000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515610b3d57600080fd5b6102c65a03f11515610b4e57600080fd5b5050506040518051905001621275000142105b15610b6b57600080fd5b80600160a060020a03166313af40353360405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b1515610bb957600080fd5b6102c65a03f11515610bca57600080fd5b50505080600160a060020a031663bbe42771600560405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b1515610c1457600080fd5b6102c65a03f11515610c2557600080fd5b505050600160a060020a03831660008181526003602090815260408083208684529091528082208054600160a060020a03191690558491600080516020612694833981519152916005905191825260ff1660208201526040908101905180910390a3505050565b60008181526002602052604081208190819081908190610cab876114da565b815460018301546002840154600390940154929a600160a060020a03909216995097509195509350915050565b600054600160a060020a031681565b600080600080600080610cfc89338a8a610a7a565b600160a060020a033381166000908152600360209081526040808320858452909152902054919750169450841515610d3357600080fd5b600160a060020a0333811660009081526003602090815260408083208a845282528083208054600160a060020a03191690558c835260029091528082209650610dd6928b9290891691633fa4f245919051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515610db657600080fd5b6102c65a03f11515610dc757600080fd5b50505060405180519050611edb565b925084600160a060020a031663b0c8097284600160405160e060020a63ffffffff8516028152600481019290925215156024820152604401600060405180830381600087803b1515610e2757600080fd5b6102c65a03f11515610e3857600080fd5b505050610e44896114da565b91506002826005811115610e5457fe5b1415610ef25784600160a060020a031663bbe42771600560405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b1515610ea157600080fd5b6102c65a03f11515610eb257600080fd5b5050600160a060020a03331690508960008051602061269483398151915285600160405191825260ff1660208201526040908101905180910390a3611249565b6004826005811115610f0057fe5b14610f0a57600080fd5b662386f26fc10000831080610f88575060018401546202a2ff1901600160a060020a0386166305b344106000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515610f6b57600080fd5b6102c65a03f11515610f7c57600080fd5b50505060405180519050115b156110265784600160a060020a031663bbe427716103e360405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b1515610fd557600080fd5b6102c65a03f11515610fe657600080fd5b5050600160a060020a03331690508960008051602061269483398151915285600060405191825260ff1660208201526040908101905180910390a3611249565b8360030154831115611108578354600160a060020a0316156110a257508254600160a060020a03168063bbe427716103e360405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b151561108d57600080fd5b6102c65a03f1151561109e57600080fd5b5050505b600384018054600280870191909155908490558454600160a060020a031916600160a060020a038781169190911786553316908a9060008051602061269483398151915290869060405191825260ff1660208201526040908101905180910390a3611249565b83600201548311156111b45760028401839055600160a060020a03851663bbe427716103e360405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b151561116357600080fd5b6102c65a03f1151561117457600080fd5b5050600160a060020a03331690508960008051602061269483398151915285600360405191825260ff1660208201526040908101905180910390a3611249565b84600160a060020a031663bbe427716103e360405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b15156111fc57600080fd5b6102c65a03f1151561120d57600080fd5b5050600160a060020a03331690508960008051602061269483398151915285600460405191825260ff1660208201526040908101905180910390a35b505050505050505050565b600080826002611263826114da565b600581111561126e57fe5b1415806112fa575060008181526002602052604080822054600160a060020a031691638da5cb5b9151602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156112c957600080fd5b6102c65a03f115156112da57600080fd5b50505060405180519050600160a060020a031633600160a060020a031614155b1561130457600080fd5b60008054600154600160a060020a03909116916302571be391906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561135b57600080fd5b6102c65a03f1151561136c57600080fd5b50505060405180519050925030600160a060020a031683600160a060020a0316141561139757600080fd5b600084815260026020526040908190208054909350600160a060020a03169063faab9d399085905160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b15156113fa57600080fd5b6102c65a03f1151561140b57600080fd5b505082546001840154600160a060020a03808716935063ea9e107a92889291169060405160e060020a63ffffffff86160281526004810193909352600160a060020a0390911660248301526044820152606401600060405180830381600087803b151561147757600080fd5b6102c65a03f1151561148857600080fd5b50508254600160a060020a03191683555050600060018201819055600282018190556003909101555050565b6003602090815260009283526040808420909152908252902054600160a060020a031681565b60008181526002602052604081206114f2834261169b565b1515611501576005915061154a565b80600101544210156115315760018101546202a2ff1901421015611528576001915061154a565b6004915061154a565b60038101541515611545576000915061154a565b600291505b50919050565b600082600261155e826114da565b600581111561156957fe5b1415806115f5575060008181526002602052604080822054600160a060020a031691638da5cb5b9151602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156115c457600080fd5b6102c65a03f115156115d557600080fd5b50505060405180519050600160a060020a031633600160a060020a031614155b156115ff57600080fd5b600160a060020a038316151561161457600080fd5b600084815260026020526040908190208054909350600160a060020a0316906313af40359085905160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b151561167757600080fd5b6102c65a03f1151561168857600080fd5b5050506116958484611eec565b50505050565b60006116a68361072a565b821190505b92915050565b60008160026116bf826114da565b60058111156116ca57fe5b141580611756575060008181526002602052604080822054600160a060020a031691638da5cb5b9151602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561172557600080fd5b6102c65a03f1151561173657600080fd5b50505060405180519050600160a060020a031633600160a060020a031614155b1561176057600080fd5b60008381526002602081905260409091209081015490925061178990662386f26fc10000611ec3565b600283018190558254600160a060020a03169063b0c8097290600160405160e060020a63ffffffff8516028152600481019290925215156024820152604401600060405180830381600087803b15156117e157600080fd5b6102c65a03f115156117f257600080fd5b5050825461186291508490600160a060020a0316638da5cb5b6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561184257600080fd5b6102c65a03f1151561185357600080fd5b50505060405180519050611eec565b8154600160a060020a0316638da5cb5b6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156118a957600080fd5b6102c65a03f115156118ba57600080fd5b50505060405180519050600160a060020a031683600019167f0f0c27adfd84b60b6f456b0e87cdccb1e5fb9603991588d87fa99f5b6b61e6708460020154856001015460405191825260208201526040908101905180910390a3505050565b60045481565b6249d40081565b600160a060020a0333811660009081526003602090815260408083208584529091528120549091168190111561195b57600080fd5b662386f26fc1000034101561196f57600080fd5b3433611979612187565b600160a060020a0390911681526020016040518091039082f080151561199e57600080fd5b33600160a060020a039081166000818152600360209081526040808320898452909152908190208054600160a060020a0319169385169390931790925591935090915083907fb556ff269c1b6714f432c36431e2041d28436a73b6c3f19c021827bbdc6bfc299034905190815260200160405180910390a35050565b80511515611a2757600080fd5b6002611a4b82600184510381518110611a3c57fe5b906020019060200201516114da565b6005811115611a5657fe5b1415611a6157600080fd5b611a72600182510382600154611fd6565b50565b60005b8151811015611aa757611a9f828281518110611a9057fe5b90602001906020020151611ab0565b600101611a78565b5050565b505050565b600080600454421080611aca5750600454630784ce000142115b80611b51575060008054600154600160a060020a03308116939216916302571be391906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515611b2a57600080fd5b6102c65a03f11515611b3b57600080fd5b50505060405180519050600160a060020a031614155b15611b5b57600080fd5b611b64836114da565b91506001826005811115611b7457fe5b1415611b7f57611aab565b6000826005811115611b8d57fe5b14611b9757600080fd5b50600082815260026020819052604080832042620697800160018201819055928101849055600381019390935584917f87e97e825a1d1fa0c54e1d36c7506c1dea8b1efd451fe68b000cf96f7cf40003915190815260200160405180910390a2505050565b60015481565b611c0b82611a75565b611aa781611926565b60008054600154600160a060020a033081169216906302571be390846040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515611c6d57600080fd5b6102c65a03f11515611c7e57600080fd5b50505060405180519050600160a060020a03161415611aa757600054600154600160a060020a03909116906306ab592390843060405160e060020a63ffffffff861602815260048101939093526024830191909152600160a060020a03166044820152606401600060405180830381600087803b1515611cfd57600080fd5b6102c65a03f11515611d0e57600080fd5b5050506001548260405191825260208201526040908101905190819003902060008054919250600160a060020a0390911690631896f70a90839060405160e060020a63ffffffff85160281526004810192909252600160a060020a03166024820152604401600060405180830381600087803b1515611d8c57600080fd5b6102c65a03f11515611d9d57600080fd5b505060008054600160a060020a03169150635b0fc9c390839060405160e060020a63ffffffff85160281526004810192909252600160a060020a03166024820152604401600060405180830381600087803b1515611dfa57600080fd5b6102c65a03f11515611e0b57600080fd5b5050505050565b600060018201818080838651019250600091505b82841015611eba5760ff845116905060808160ff161015611e4c57600184019350611eaf565b60e08160ff161015611e6357600284019350611eaf565b60f08160ff161015611e7a57600384019350611eaf565b60f88160ff161015611e9157600484019350611eaf565b60fc8160ff161015611ea857600584019350611eaf565b6006840193505b600190910190611e26565b50949350505050565b600081831115611ed45750816116ab565b50806116ab565b600081831015611ed45750816116ab565b60008054600154600160a060020a03308116939216916302571be391906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515611f4657600080fd5b6102c65a03f11515611f5757600080fd5b50505060405180519050600160a060020a03161415611aa757600054600154600160a060020a03909116906306ab592390848460405160e060020a63ffffffff861602815260048101939093526024830191909152600160a060020a03166044820152606401600060405180830381600087803b1515611dfa57600080fd5b600054600160a060020a03166306ab592382848681518110611ff457fe5b906020019060200201513060405160e060020a63ffffffff861602815260048101939093526024830191909152600160a060020a03166044820152606401600060405180830381600087803b151561204b57600080fd5b6102c65a03f1151561205c57600080fd5b5050508082848151811061206c57fe5b906020019060200201516040519182526020820152604090810190518091039020905060008311156120a6576120a6600184038383611fd6565b60008054600160a060020a031690631896f70a90839060405160e060020a63ffffffff85160281526004810192909252600160a060020a03166024820152604401600060405180830381600087803b151561210057600080fd5b6102c65a03f1151561211157600080fd5b505060008054600160a060020a03169150635b0fc9c390839060405160e060020a63ffffffff85160281526004810192909252600160a060020a03166024820152604401600060405180830381600087803b151561216e57600080fd5b6102c65a03f1151561217f57600080fd5b505050505050565b6040516104fc8061219883390190560060606040526040516020806104fc8339810160405280805160028054600160a060020a03928316600160a060020a03199182161790915560008054339093169290911691909117905550504260019081556005805460ff191690911790553460045561048c806100706000396000f300606060405236156100a15763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166305b3441081146100a65780630b5ab3d5146100cb57806313af4035146100e05780632b20e397146100ff5780633fa4f2451461012e578063674f220f146101415780638da5cb5b14610154578063b0c8097214610167578063bbe4277114610182578063faab9d3914610198575b600080fd5b34156100b157600080fd5b6100b96101b7565b60405190815260200160405180910390f35b34156100d657600080fd5b6100de6101bd565b005b34156100eb57600080fd5b6100de600160a060020a0360043516610207565b341561010a57600080fd5b6101126102b0565b604051600160a060020a03909116815260200160405180910390f35b341561013957600080fd5b6100b96102bf565b341561014c57600080fd5b6101126102c5565b341561015f57600080fd5b6101126102d4565b341561017257600080fd5b6100de60043560243515156102e3565b341561018d57600080fd5b6100de60043561036c565b34156101a357600080fd5b6100de600160a060020a0360043516610416565b60015481565b60055460ff16156101cd57600080fd5b600254600160a060020a039081169030163180156108fc0290604051600060405180830381858888f19350505050156102055761deadff5b565b60005433600160a060020a0390811691161461022257600080fd5b600160a060020a038116151561023757600080fd5b6002805460038054600160a060020a0380841673ffffffffffffffffffffffffffffffffffffffff19928316179092559091169083161790557fa2ea9883a321a3e97b8266c2b078bfeec6d50c711ed71f874a90d500ae2eaf3681604051600160a060020a03909116815260200160405180910390a150565b600054600160a060020a031681565b60045481565b600354600160a060020a031681565b600254600160a060020a031681565b60005433600160a060020a039081169116146102fe57600080fd5b60055460ff16151561030f57600080fd5b81600454101561031e57600080fd5b6004829055600254600160a060020a039081169030163183900380156108fc0290604051600060405180830381858888f1935050505015801561035e5750805b1561036857600080fd5b5050565b60005433600160a060020a0390811691161461038757600080fd5b60055460ff16151561039857600080fd5b6005805460ff1916905561dead6103e8600160a060020a03301631838203020480156108fc0290604051600060405180830381858888f1935050505015156103df57600080fd5b7fbb2ce2f51803bba16bc85282b47deeea9a5c6223eabea1077be696b3f265cf1360405160405180910390a16104136101bd565b50565b60005433600160a060020a0390811691161461043157600080fd5b6000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555600a165627a7a7230582023849fab751378a237489f526a289ede7796b7f6b7dac5a973b8c3ca25f368a800297b6c4b278d165a6b33958f8ea5dfb00c8c9d4d0acf1985bef5d10786898bc3e7a165627a7a72305820e6807b87ab11a69864cefed52eef7f9c4635fd0e26312e944bbbcbff5cd26d920029" -registrar_bytecode_runtime = "606060405236156101175763ffffffff60e060020a6000350416630230a07c811461011c57806313c89a8f1461013457806315f733311461015c57806322ec1244146101ad5780632525f5c1146101d5578063267b6922146101f75780633f15457f1461025f57806347872b421461028e5780635ddae283146102aa5780635e431709146102c057806361d585da146102e257806379ce9fac1461031c578063935033371461033e578063983b94fb1461036b5780639c67f06f14610381578063ae1a0b0c14610394578063ce92dced146103c0578063de10f04b146103cb578063e27fe50f1461041a578063ea9e107a14610469578063ede8acdb1461048e578063faff50a8146104a4578063febefd61146104b7575b600080fd5b341561012757600080fd5b6101326004356104fd565b005b341561013f57600080fd5b61014a60043561072a565b60405190815260200160405180910390f35b341561016757600080fd5b61013260046024813581810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965061074e95505050505050565b34156101b857600080fd5b61014a600435600160a060020a0360243516604435606435610a7a565b34156101e057600080fd5b610132600160a060020a0360043516602435610ac5565b341561020257600080fd5b61020d600435610c8c565b6040518086600581111561021d57fe5b60ff16815260200185600160a060020a0316600160a060020a031681526020018481526020018381526020018281526020019550505050505060405180910390f35b341561026a57600080fd5b610272610cd8565b604051600160a060020a03909116815260200160405180910390f35b341561029957600080fd5b610132600435602435604435610ce7565b34156102b557600080fd5b610132600435611254565b34156102cb57600080fd5b610272600160a060020a03600435166024356114b4565b34156102ed57600080fd5b6102f86004356114da565b6040518082600581111561030857fe5b60ff16815260200191505060405180910390f35b341561032757600080fd5b610132600435600160a060020a0360243516611550565b341561034957600080fd5b61035760043560243561169b565b604051901515815260200160405180910390f35b341561037657600080fd5b6101326004356116b1565b341561038c57600080fd5b61014a611919565b341561039f57600080fd5b6103a761191f565b60405163ffffffff909116815260200160405180910390f35b610132600435611926565b34156103d657600080fd5b6101326004602481358181019083013580602081810201604051908101604052809392919081815260200183836020028082843750949650611a1a95505050505050565b341561042557600080fd5b6101326004602481358181019083013580602081810201604051908101604052809392919081815260200183836020028082843750949650611a7595505050505050565b341561047457600080fd5b610132600435600160a060020a0360243516604435611aab565b341561049957600080fd5b610132600435611ab0565b34156104af57600080fd5b61014a611bfc565b61013260046024813581810190830135806020818102016040519081016040528093929190818152602001838360200280828437509496505093359350611c0292505050565b60008082600261050c826114da565b600581111561051757fe5b1415806105a3575060008181526002602052604080822054600160a060020a031691638da5cb5b9151602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561057257600080fd5b6102c65a03f1151561058357600080fd5b50505060405180519050600160a060020a031633600160a060020a031614155b156105ad57600080fd5b600084815260026020526040902080546001820154919450600160a060020a031692506301e13380014210801561065f575060008054600154600160a060020a03308116939216916302571be391906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561063957600080fd5b6102c65a03f1151561064a57600080fd5b50505060405180519050600160a060020a0316145b1561066957600080fd5b60006002840181905560038401558254600160a060020a031916835561068e84611c14565b81600160a060020a031663bbe427716103e860405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b15156106d657600080fd5b6102c65a03f115156106e757600080fd5b505050600283015484907f292b79b9246fa2c8e77d3fe195b251f9cb839d7d038e667c069ee7708c631e169060405190815260200160405180910390a250505050565b6004547001000000000000000000000000000000006249d400818404020401919050565b600080826040518082805190602001908083835b602083106107815780518252601f199092019160209182019101610762565b6001836020036101000a03801982511681845116179092525050509190910192506040915050519081900390206002806107ba836114da565b60058111156107c557fe5b146107cf57600080fd5b60066107da86611e12565b11156107e557600080fd5b846040518082805190602001908083835b602083106108155780518252601f1990920191602091820191016107f6565b6001836020036101000a03801982511681845116179092525050509190910192506040915050519081900390206000818152600260205260409020909450925061085e84611c14565b8254600160a060020a0316156109b5576108838360020154662386f26fc10000611ec3565b60028085018290558454600160a060020a03169163b0c80972919004600060405160e060020a63ffffffff8516028152600481019290925215156024820152604401600060405180830381600087803b15156108de57600080fd5b6102c65a03f115156108ef57600080fd5b50508354600160a060020a031690506313af40353360405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b151561094257600080fd5b6102c65a03f1151561095357600080fd5b50508354600160a060020a0316905063bbe427716103e860405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b15156109a057600080fd5b6102c65a03f115156109b157600080fd5b5050505b846040518082805190602001908083835b602083106109e55780518252601f1990920191602091820191016109c6565b6001836020036101000a0380198251168184511617909252505050919091019250604091505051809103902084600019167f1f9c649fe47e58bb60f4e52f0d90e4c47a526c9f90c5113df842c025970b66ad8560020154866001015460405191825260208201526040908101905180910390a3505060006002820181905560038201558054600160a060020a03191690555050565b600084848484604051938452600160a060020a03929092166c010000000000000000000000000260208401526034830152605482015260740160405180910390209050949350505050565b600160a060020a03808316600090815260036020908152604080832085845290915290205416801580610b61575062069780600160a060020a0382166305b344106000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515610b3d57600080fd5b6102c65a03f11515610b4e57600080fd5b5050506040518051905001621275000142105b15610b6b57600080fd5b80600160a060020a03166313af40353360405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b1515610bb957600080fd5b6102c65a03f11515610bca57600080fd5b50505080600160a060020a031663bbe42771600560405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b1515610c1457600080fd5b6102c65a03f11515610c2557600080fd5b505050600160a060020a03831660008181526003602090815260408083208684529091528082208054600160a060020a03191690558491600080516020612694833981519152916005905191825260ff1660208201526040908101905180910390a3505050565b60008181526002602052604081208190819081908190610cab876114da565b815460018301546002840154600390940154929a600160a060020a03909216995097509195509350915050565b600054600160a060020a031681565b600080600080600080610cfc89338a8a610a7a565b600160a060020a033381166000908152600360209081526040808320858452909152902054919750169450841515610d3357600080fd5b600160a060020a0333811660009081526003602090815260408083208a845282528083208054600160a060020a03191690558c835260029091528082209650610dd6928b9290891691633fa4f245919051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515610db657600080fd5b6102c65a03f11515610dc757600080fd5b50505060405180519050611edb565b925084600160a060020a031663b0c8097284600160405160e060020a63ffffffff8516028152600481019290925215156024820152604401600060405180830381600087803b1515610e2757600080fd5b6102c65a03f11515610e3857600080fd5b505050610e44896114da565b91506002826005811115610e5457fe5b1415610ef25784600160a060020a031663bbe42771600560405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b1515610ea157600080fd5b6102c65a03f11515610eb257600080fd5b5050600160a060020a03331690508960008051602061269483398151915285600160405191825260ff1660208201526040908101905180910390a3611249565b6004826005811115610f0057fe5b14610f0a57600080fd5b662386f26fc10000831080610f88575060018401546202a2ff1901600160a060020a0386166305b344106000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515610f6b57600080fd5b6102c65a03f11515610f7c57600080fd5b50505060405180519050115b156110265784600160a060020a031663bbe427716103e360405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b1515610fd557600080fd5b6102c65a03f11515610fe657600080fd5b5050600160a060020a03331690508960008051602061269483398151915285600060405191825260ff1660208201526040908101905180910390a3611249565b8360030154831115611108578354600160a060020a0316156110a257508254600160a060020a03168063bbe427716103e360405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b151561108d57600080fd5b6102c65a03f1151561109e57600080fd5b5050505b600384018054600280870191909155908490558454600160a060020a031916600160a060020a038781169190911786553316908a9060008051602061269483398151915290869060405191825260ff1660208201526040908101905180910390a3611249565b83600201548311156111b45760028401839055600160a060020a03851663bbe427716103e360405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b151561116357600080fd5b6102c65a03f1151561117457600080fd5b5050600160a060020a03331690508960008051602061269483398151915285600360405191825260ff1660208201526040908101905180910390a3611249565b84600160a060020a031663bbe427716103e360405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b15156111fc57600080fd5b6102c65a03f1151561120d57600080fd5b5050600160a060020a03331690508960008051602061269483398151915285600460405191825260ff1660208201526040908101905180910390a35b505050505050505050565b600080826002611263826114da565b600581111561126e57fe5b1415806112fa575060008181526002602052604080822054600160a060020a031691638da5cb5b9151602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156112c957600080fd5b6102c65a03f115156112da57600080fd5b50505060405180519050600160a060020a031633600160a060020a031614155b1561130457600080fd5b60008054600154600160a060020a03909116916302571be391906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561135b57600080fd5b6102c65a03f1151561136c57600080fd5b50505060405180519050925030600160a060020a031683600160a060020a0316141561139757600080fd5b600084815260026020526040908190208054909350600160a060020a03169063faab9d399085905160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b15156113fa57600080fd5b6102c65a03f1151561140b57600080fd5b505082546001840154600160a060020a03808716935063ea9e107a92889291169060405160e060020a63ffffffff86160281526004810193909352600160a060020a0390911660248301526044820152606401600060405180830381600087803b151561147757600080fd5b6102c65a03f1151561148857600080fd5b50508254600160a060020a03191683555050600060018201819055600282018190556003909101555050565b6003602090815260009283526040808420909152908252902054600160a060020a031681565b60008181526002602052604081206114f2834261169b565b1515611501576005915061154a565b80600101544210156115315760018101546202a2ff1901421015611528576001915061154a565b6004915061154a565b60038101541515611545576000915061154a565b600291505b50919050565b600082600261155e826114da565b600581111561156957fe5b1415806115f5575060008181526002602052604080822054600160a060020a031691638da5cb5b9151602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156115c457600080fd5b6102c65a03f115156115d557600080fd5b50505060405180519050600160a060020a031633600160a060020a031614155b156115ff57600080fd5b600160a060020a038316151561161457600080fd5b600084815260026020526040908190208054909350600160a060020a0316906313af40359085905160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b151561167757600080fd5b6102c65a03f1151561168857600080fd5b5050506116958484611eec565b50505050565b60006116a68361072a565b821190505b92915050565b60008160026116bf826114da565b60058111156116ca57fe5b141580611756575060008181526002602052604080822054600160a060020a031691638da5cb5b9151602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561172557600080fd5b6102c65a03f1151561173657600080fd5b50505060405180519050600160a060020a031633600160a060020a031614155b1561176057600080fd5b60008381526002602081905260409091209081015490925061178990662386f26fc10000611ec3565b600283018190558254600160a060020a03169063b0c8097290600160405160e060020a63ffffffff8516028152600481019290925215156024820152604401600060405180830381600087803b15156117e157600080fd5b6102c65a03f115156117f257600080fd5b5050825461186291508490600160a060020a0316638da5cb5b6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561184257600080fd5b6102c65a03f1151561185357600080fd5b50505060405180519050611eec565b8154600160a060020a0316638da5cb5b6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b15156118a957600080fd5b6102c65a03f115156118ba57600080fd5b50505060405180519050600160a060020a031683600019167f0f0c27adfd84b60b6f456b0e87cdccb1e5fb9603991588d87fa99f5b6b61e6708460020154856001015460405191825260208201526040908101905180910390a3505050565b60045481565b6249d40081565b600160a060020a0333811660009081526003602090815260408083208584529091528120549091168190111561195b57600080fd5b662386f26fc1000034101561196f57600080fd5b3433611979612187565b600160a060020a0390911681526020016040518091039082f080151561199e57600080fd5b33600160a060020a039081166000818152600360209081526040808320898452909152908190208054600160a060020a0319169385169390931790925591935090915083907fb556ff269c1b6714f432c36431e2041d28436a73b6c3f19c021827bbdc6bfc299034905190815260200160405180910390a35050565b80511515611a2757600080fd5b6002611a4b82600184510381518110611a3c57fe5b906020019060200201516114da565b6005811115611a5657fe5b1415611a6157600080fd5b611a72600182510382600154611fd6565b50565b60005b8151811015611aa757611a9f828281518110611a9057fe5b90602001906020020151611ab0565b600101611a78565b5050565b505050565b600080600454421080611aca5750600454630784ce000142115b80611b51575060008054600154600160a060020a03308116939216916302571be391906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515611b2a57600080fd5b6102c65a03f11515611b3b57600080fd5b50505060405180519050600160a060020a031614155b15611b5b57600080fd5b611b64836114da565b91506001826005811115611b7457fe5b1415611b7f57611aab565b6000826005811115611b8d57fe5b14611b9757600080fd5b50600082815260026020819052604080832042620697800160018201819055928101849055600381019390935584917f87e97e825a1d1fa0c54e1d36c7506c1dea8b1efd451fe68b000cf96f7cf40003915190815260200160405180910390a2505050565b60015481565b611c0b82611a75565b611aa781611926565b60008054600154600160a060020a033081169216906302571be390846040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515611c6d57600080fd5b6102c65a03f11515611c7e57600080fd5b50505060405180519050600160a060020a03161415611aa757600054600154600160a060020a03909116906306ab592390843060405160e060020a63ffffffff861602815260048101939093526024830191909152600160a060020a03166044820152606401600060405180830381600087803b1515611cfd57600080fd5b6102c65a03f11515611d0e57600080fd5b5050506001548260405191825260208201526040908101905190819003902060008054919250600160a060020a0390911690631896f70a90839060405160e060020a63ffffffff85160281526004810192909252600160a060020a03166024820152604401600060405180830381600087803b1515611d8c57600080fd5b6102c65a03f11515611d9d57600080fd5b505060008054600160a060020a03169150635b0fc9c390839060405160e060020a63ffffffff85160281526004810192909252600160a060020a03166024820152604401600060405180830381600087803b1515611dfa57600080fd5b6102c65a03f11515611e0b57600080fd5b5050505050565b600060018201818080838651019250600091505b82841015611eba5760ff845116905060808160ff161015611e4c57600184019350611eaf565b60e08160ff161015611e6357600284019350611eaf565b60f08160ff161015611e7a57600384019350611eaf565b60f88160ff161015611e9157600484019350611eaf565b60fc8160ff161015611ea857600584019350611eaf565b6006840193505b600190910190611e26565b50949350505050565b600081831115611ed45750816116ab565b50806116ab565b600081831015611ed45750816116ab565b60008054600154600160a060020a03308116939216916302571be391906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515611f4657600080fd5b6102c65a03f11515611f5757600080fd5b50505060405180519050600160a060020a03161415611aa757600054600154600160a060020a03909116906306ab592390848460405160e060020a63ffffffff861602815260048101939093526024830191909152600160a060020a03166044820152606401600060405180830381600087803b1515611dfa57600080fd5b600054600160a060020a03166306ab592382848681518110611ff457fe5b906020019060200201513060405160e060020a63ffffffff861602815260048101939093526024830191909152600160a060020a03166044820152606401600060405180830381600087803b151561204b57600080fd5b6102c65a03f1151561205c57600080fd5b5050508082848151811061206c57fe5b906020019060200201516040519182526020820152604090810190518091039020905060008311156120a6576120a6600184038383611fd6565b60008054600160a060020a031690631896f70a90839060405160e060020a63ffffffff85160281526004810192909252600160a060020a03166024820152604401600060405180830381600087803b151561210057600080fd5b6102c65a03f1151561211157600080fd5b505060008054600160a060020a03169150635b0fc9c390839060405160e060020a63ffffffff85160281526004810192909252600160a060020a03166024820152604401600060405180830381600087803b151561216e57600080fd5b6102c65a03f1151561217f57600080fd5b505050505050565b6040516104fc8061219883390190560060606040526040516020806104fc8339810160405280805160028054600160a060020a03928316600160a060020a03199182161790915560008054339093169290911691909117905550504260019081556005805460ff191690911790553460045561048c806100706000396000f300606060405236156100a15763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166305b3441081146100a65780630b5ab3d5146100cb57806313af4035146100e05780632b20e397146100ff5780633fa4f2451461012e578063674f220f146101415780638da5cb5b14610154578063b0c8097214610167578063bbe4277114610182578063faab9d3914610198575b600080fd5b34156100b157600080fd5b6100b96101b7565b60405190815260200160405180910390f35b34156100d657600080fd5b6100de6101bd565b005b34156100eb57600080fd5b6100de600160a060020a0360043516610207565b341561010a57600080fd5b6101126102b0565b604051600160a060020a03909116815260200160405180910390f35b341561013957600080fd5b6100b96102bf565b341561014c57600080fd5b6101126102c5565b341561015f57600080fd5b6101126102d4565b341561017257600080fd5b6100de60043560243515156102e3565b341561018d57600080fd5b6100de60043561036c565b34156101a357600080fd5b6100de600160a060020a0360043516610416565b60015481565b60055460ff16156101cd57600080fd5b600254600160a060020a039081169030163180156108fc0290604051600060405180830381858888f19350505050156102055761deadff5b565b60005433600160a060020a0390811691161461022257600080fd5b600160a060020a038116151561023757600080fd5b6002805460038054600160a060020a0380841673ffffffffffffffffffffffffffffffffffffffff19928316179092559091169083161790557fa2ea9883a321a3e97b8266c2b078bfeec6d50c711ed71f874a90d500ae2eaf3681604051600160a060020a03909116815260200160405180910390a150565b600054600160a060020a031681565b60045481565b600354600160a060020a031681565b600254600160a060020a031681565b60005433600160a060020a039081169116146102fe57600080fd5b60055460ff16151561030f57600080fd5b81600454101561031e57600080fd5b6004829055600254600160a060020a039081169030163183900380156108fc0290604051600060405180830381858888f1935050505015801561035e5750805b1561036857600080fd5b5050565b60005433600160a060020a0390811691161461038757600080fd5b60055460ff16151561039857600080fd5b6005805460ff1916905561dead6103e8600160a060020a03301631838203020480156108fc0290604051600060405180830381858888f1935050505015156103df57600080fd5b7fbb2ce2f51803bba16bc85282b47deeea9a5c6223eabea1077be696b3f265cf1360405160405180910390a16104136101bd565b50565b60005433600160a060020a0390811691161461043157600080fd5b6000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555600a165627a7a7230582023849fab751378a237489f526a289ede7796b7f6b7dac5a973b8c3ca25f368a800297b6c4b278d165a6b33958f8ea5dfb00c8c9d4d0acf1985bef5d10786898bc3e7a165627a7a72305820e6807b87ab11a69864cefed52eef7f9c4635fd0e26312e944bbbcbff5cd26d920029" - -resolver_abi = json.loads('[{"constant":true,"inputs":[{"name":"interfaceID","type":"bytes4"}],"name":"supportsInterface","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"key","type":"string"},{"name":"value","type":"string"}],"name":"setText","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"node","type":"bytes32"},{"name":"contentTypes","type":"uint256"}],"name":"ABI","outputs":[{"name":"contentType","type":"uint256"},{"name":"data","type":"bytes"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"x","type":"bytes32"},{"name":"y","type":"bytes32"}],"name":"setPubkey","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"name":"content","outputs":[{"name":"ret","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"name":"addr","outputs":[{"name":"ret","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"node","type":"bytes32"},{"name":"key","type":"string"}],"name":"text","outputs":[{"name":"ret","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"contentType","type":"uint256"},{"name":"data","type":"bytes"}],"name":"setABI","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"name":"name","outputs":[{"name":"ret","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"name","type":"string"}],"name":"setName","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"hash","type":"bytes32"}],"name":"setContent","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"name":"pubkey","outputs":[{"name":"x","type":"bytes32"},{"name":"y","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"addr","type":"address"}],"name":"setAddr","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"ensAddr","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"a","type":"address"}],"name":"AddrChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"hash","type":"bytes32"}],"name":"ContentChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"name","type":"string"}],"name":"NameChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":true,"name":"contentType","type":"uint256"}],"name":"ABIChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"x","type":"bytes32"},{"indexed":false,"name":"y","type":"bytes32"}],"name":"PubkeyChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":true,"name":"indexedKey","type":"string"},{"indexed":false,"name":"key","type":"string"}],"name":"TextChanged","type":"event"}]') -resolver_bytecode = "6060604052341561000f57600080fd5b6040516020806111b08339810160405280805160008054600160a060020a03909216600160a060020a0319909216919091179055505061115c806100546000396000f300606060405236156100a95763ffffffff60e060020a60003504166301ffc9a781146100ae57806310f13a8c146100e25780632203ab561461017c57806329cd62ea146102135780632dff69411461022f5780633b3b57de1461025757806359d1d43c14610289578063623195b014610356578063691f3431146103b257806377372213146103c8578063c3d014d61461041e578063c869023314610437578063d5fa2b0014610465575b600080fd5b34156100b957600080fd5b6100ce600160e060020a031960043516610487565b604051901515815260200160405180910390f35b34156100ed57600080fd5b61017a600480359060446024803590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284378201915050505050509190803590602001908201803590602001908080601f0160208091040260200160405190810160405281815292919060208401838380828437509496506105f495505050505050565b005b341561018757600080fd5b610195600435602435610805565b60405182815260406020820181815290820183818151815260200191508051906020019080838360005b838110156101d75780820151838201526020016101bf565b50505050905090810190601f1680156102045780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b341561021e57600080fd5b61017a60043560243560443561092f565b341561023a57600080fd5b610245600435610a2e565b60405190815260200160405180910390f35b341561026257600080fd5b61026d600435610a44565b604051600160a060020a03909116815260200160405180910390f35b341561029457600080fd5b6102df600480359060446024803590810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650610a5f95505050505050565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561031b578082015183820152602001610303565b50505050905090810190601f1680156103485780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561036157600080fd5b61017a600480359060248035919060649060443590810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650610b7e95505050505050565b34156103bd57600080fd5b6102df600435610c7a565b34156103d357600080fd5b61017a600480359060446024803590810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650610d4095505050505050565b341561042957600080fd5b61017a600435602435610e8a565b341561044257600080fd5b61044d600435610f63565b60405191825260208201526040908101905180910390f35b341561047057600080fd5b61017a600435600160a060020a0360243516610f80565b6000600160e060020a031982167f3b3b57de0000000000000000000000000000000000000000000000000000000014806104ea5750600160e060020a031982167fd8389dc500000000000000000000000000000000000000000000000000000000145b8061051e5750600160e060020a031982167f691f343100000000000000000000000000000000000000000000000000000000145b806105525750600160e060020a031982167f2203ab5600000000000000000000000000000000000000000000000000000000145b806105865750600160e060020a031982167fc869023300000000000000000000000000000000000000000000000000000000145b806105ba5750600160e060020a031982167f59d1d43c00000000000000000000000000000000000000000000000000000000145b806105ee5750600160e060020a031982167f01ffc9a700000000000000000000000000000000000000000000000000000000145b92915050565b600080548491600160a060020a033381169216906302571be39084906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561064d57600080fd5b6102c65a03f1151561065e57600080fd5b50505060405180519050600160a060020a031614151561067d57600080fd5b6000848152600160205260409081902083916005909101908590518082805190602001908083835b602083106106c45780518252601f1990920191602091820191016106a5565b6001836020036101000a0380198251168184511680821785525050505050509050019150509081526020016040518091039020908051610708929160200190611083565b50826040518082805190602001908083835b602083106107395780518252601f19909201916020918201910161071a565b6001836020036101000a0380198251168184511617909252505050919091019250604091505051908190039020847fd8c9334b1a9c2f9da342a0a2b32629c1a229b6445dad78947f674b44444a75508560405160208082528190810183818151815260200191508051906020019080838360005b838110156107c55780820151838201526020016107ad565b50505050905090810190601f1680156107f25780820380516001836020036101000a031916815260200191505b509250505060405180910390a350505050565b600061080f611101565b60008481526001602081905260409091209092505b838311610922578284161580159061085d5750600083815260068201602052604081205460026000196101006001841615020190911604115b15610917578060060160008481526020019081526020016000208054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561090b5780601f106108e05761010080835404028352916020019161090b565b820191906000526020600020905b8154815290600101906020018083116108ee57829003601f168201915b50505050509150610927565b600290920291610824565b600092505b509250929050565b600080548491600160a060020a033381169216906302571be39084906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561098857600080fd5b6102c65a03f1151561099957600080fd5b50505060405180519050600160a060020a03161415156109b857600080fd5b6040805190810160409081528482526020808301859052600087815260019091522060030181518155602082015160019091015550837f1d6f5e03d3f63eb58751986629a5439baee5079ff04f345becb66e23eb154e46848460405191825260208201526040908101905180910390a250505050565b6000908152600160208190526040909120015490565b600090815260016020526040902054600160a060020a031690565b610a67611101565b60008381526001602052604090819020600501908390518082805190602001908083835b60208310610aaa5780518252601f199092019160209182019101610a8b565b6001836020036101000a03801982511681845116808217855250505050505090500191505090815260200160405180910390208054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b715780601f10610b4657610100808354040283529160200191610b71565b820191906000526020600020905b815481529060010190602001808311610b5457829003601f168201915b5050505050905092915050565b600080548491600160a060020a033381169216906302571be39084906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515610bd757600080fd5b6102c65a03f11515610be857600080fd5b50505060405180519050600160a060020a0316141515610c0757600080fd5b6000198301831615610c1857600080fd5b60008481526001602090815260408083208684526006019091529020828051610c45929160200190611083565b5082847faa121bbeef5f32f5961a2a28966e769023910fc9479059ee3495d4c1a696efe360405160405180910390a350505050565b610c82611101565b6001600083600019166000191681526020019081526020016000206002018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610d345780601f10610d0957610100808354040283529160200191610d34565b820191906000526020600020905b815481529060010190602001808311610d1757829003601f168201915b50505050509050919050565b600080548391600160a060020a033381169216906302571be39084906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515610d9957600080fd5b6102c65a03f11515610daa57600080fd5b50505060405180519050600160a060020a0316141515610dc957600080fd5b6000838152600160205260409020600201828051610deb929160200190611083565b50827fb7d29e911041e8d9b843369e890bcb72c9388692ba48b65ac54e7214c4c348f78360405160208082528190810183818151815260200191508051906020019080838360005b83811015610e4b578082015183820152602001610e33565b50505050905090810190601f168015610e785780820380516001836020036101000a031916815260200191505b509250505060405180910390a2505050565b600080548391600160a060020a033381169216906302571be39084906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515610ee357600080fd5b6102c65a03f11515610ef457600080fd5b50505060405180519050600160a060020a0316141515610f1357600080fd5b6000838152600160208190526040918290200183905583907f0424b6fe0d9c3bdbece0e7879dc241bb0c22e900be8b6c168b4ee08bd9bf83bc9084905190815260200160405180910390a2505050565b600090815260016020526040902060038101546004909101549091565b600080548391600160a060020a033381169216906302571be39084906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515610fd957600080fd5b6102c65a03f11515610fea57600080fd5b50505060405180519050600160a060020a031614151561100957600080fd5b60008381526001602052604090819020805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03851617905583907f52d7d861f09ab3d26239d492e8968629f95e9e318cf0b73bfddc441522a15fd290849051600160a060020a03909116815260200160405180910390a2505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106110c457805160ff19168380011785556110f1565b828001600101855582156110f1579182015b828111156110f15782518255916020019190600101906110d6565b506110fd929150611113565b5090565b60206040519081016040526000815290565b61112d91905b808211156110fd5760008155600101611119565b905600a165627a7a723058206016a807d9d5f6060e9c0d1c808e52d4ca30a4cab0140adcc6587bfc13bedf100029" -resolver_bytecode_runtime = "606060405236156100a95763ffffffff60e060020a60003504166301ffc9a781146100ae57806310f13a8c146100e25780632203ab561461017c57806329cd62ea146102135780632dff69411461022f5780633b3b57de1461025757806359d1d43c14610289578063623195b014610356578063691f3431146103b257806377372213146103c8578063c3d014d61461041e578063c869023314610437578063d5fa2b0014610465575b600080fd5b34156100b957600080fd5b6100ce600160e060020a031960043516610487565b604051901515815260200160405180910390f35b34156100ed57600080fd5b61017a600480359060446024803590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284378201915050505050509190803590602001908201803590602001908080601f0160208091040260200160405190810160405281815292919060208401838380828437509496506105f495505050505050565b005b341561018757600080fd5b610195600435602435610805565b60405182815260406020820181815290820183818151815260200191508051906020019080838360005b838110156101d75780820151838201526020016101bf565b50505050905090810190601f1680156102045780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b341561021e57600080fd5b61017a60043560243560443561092f565b341561023a57600080fd5b610245600435610a2e565b60405190815260200160405180910390f35b341561026257600080fd5b61026d600435610a44565b604051600160a060020a03909116815260200160405180910390f35b341561029457600080fd5b6102df600480359060446024803590810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650610a5f95505050505050565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561031b578082015183820152602001610303565b50505050905090810190601f1680156103485780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561036157600080fd5b61017a600480359060248035919060649060443590810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650610b7e95505050505050565b34156103bd57600080fd5b6102df600435610c7a565b34156103d357600080fd5b61017a600480359060446024803590810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650610d4095505050505050565b341561042957600080fd5b61017a600435602435610e8a565b341561044257600080fd5b61044d600435610f63565b60405191825260208201526040908101905180910390f35b341561047057600080fd5b61017a600435600160a060020a0360243516610f80565b6000600160e060020a031982167f3b3b57de0000000000000000000000000000000000000000000000000000000014806104ea5750600160e060020a031982167fd8389dc500000000000000000000000000000000000000000000000000000000145b8061051e5750600160e060020a031982167f691f343100000000000000000000000000000000000000000000000000000000145b806105525750600160e060020a031982167f2203ab5600000000000000000000000000000000000000000000000000000000145b806105865750600160e060020a031982167fc869023300000000000000000000000000000000000000000000000000000000145b806105ba5750600160e060020a031982167f59d1d43c00000000000000000000000000000000000000000000000000000000145b806105ee5750600160e060020a031982167f01ffc9a700000000000000000000000000000000000000000000000000000000145b92915050565b600080548491600160a060020a033381169216906302571be39084906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561064d57600080fd5b6102c65a03f1151561065e57600080fd5b50505060405180519050600160a060020a031614151561067d57600080fd5b6000848152600160205260409081902083916005909101908590518082805190602001908083835b602083106106c45780518252601f1990920191602091820191016106a5565b6001836020036101000a0380198251168184511680821785525050505050509050019150509081526020016040518091039020908051610708929160200190611083565b50826040518082805190602001908083835b602083106107395780518252601f19909201916020918201910161071a565b6001836020036101000a0380198251168184511617909252505050919091019250604091505051908190039020847fd8c9334b1a9c2f9da342a0a2b32629c1a229b6445dad78947f674b44444a75508560405160208082528190810183818151815260200191508051906020019080838360005b838110156107c55780820151838201526020016107ad565b50505050905090810190601f1680156107f25780820380516001836020036101000a031916815260200191505b509250505060405180910390a350505050565b600061080f611101565b60008481526001602081905260409091209092505b838311610922578284161580159061085d5750600083815260068201602052604081205460026000196101006001841615020190911604115b15610917578060060160008481526020019081526020016000208054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561090b5780601f106108e05761010080835404028352916020019161090b565b820191906000526020600020905b8154815290600101906020018083116108ee57829003601f168201915b50505050509150610927565b600290920291610824565b600092505b509250929050565b600080548491600160a060020a033381169216906302571be39084906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561098857600080fd5b6102c65a03f1151561099957600080fd5b50505060405180519050600160a060020a03161415156109b857600080fd5b6040805190810160409081528482526020808301859052600087815260019091522060030181518155602082015160019091015550837f1d6f5e03d3f63eb58751986629a5439baee5079ff04f345becb66e23eb154e46848460405191825260208201526040908101905180910390a250505050565b6000908152600160208190526040909120015490565b600090815260016020526040902054600160a060020a031690565b610a67611101565b60008381526001602052604090819020600501908390518082805190602001908083835b60208310610aaa5780518252601f199092019160209182019101610a8b565b6001836020036101000a03801982511681845116808217855250505050505090500191505090815260200160405180910390208054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b715780601f10610b4657610100808354040283529160200191610b71565b820191906000526020600020905b815481529060010190602001808311610b5457829003601f168201915b5050505050905092915050565b600080548491600160a060020a033381169216906302571be39084906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515610bd757600080fd5b6102c65a03f11515610be857600080fd5b50505060405180519050600160a060020a0316141515610c0757600080fd5b6000198301831615610c1857600080fd5b60008481526001602090815260408083208684526006019091529020828051610c45929160200190611083565b5082847faa121bbeef5f32f5961a2a28966e769023910fc9479059ee3495d4c1a696efe360405160405180910390a350505050565b610c82611101565b6001600083600019166000191681526020019081526020016000206002018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610d345780601f10610d0957610100808354040283529160200191610d34565b820191906000526020600020905b815481529060010190602001808311610d1757829003601f168201915b50505050509050919050565b600080548391600160a060020a033381169216906302571be39084906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515610d9957600080fd5b6102c65a03f11515610daa57600080fd5b50505060405180519050600160a060020a0316141515610dc957600080fd5b6000838152600160205260409020600201828051610deb929160200190611083565b50827fb7d29e911041e8d9b843369e890bcb72c9388692ba48b65ac54e7214c4c348f78360405160208082528190810183818151815260200191508051906020019080838360005b83811015610e4b578082015183820152602001610e33565b50505050905090810190601f168015610e785780820380516001836020036101000a031916815260200191505b509250505060405180910390a2505050565b600080548391600160a060020a033381169216906302571be39084906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515610ee357600080fd5b6102c65a03f11515610ef457600080fd5b50505060405180519050600160a060020a0316141515610f1357600080fd5b6000838152600160208190526040918290200183905583907f0424b6fe0d9c3bdbece0e7879dc241bb0c22e900be8b6c168b4ee08bd9bf83bc9084905190815260200160405180910390a2505050565b600090815260016020526040902060038101546004909101549091565b600080548391600160a060020a033381169216906302571be39084906040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515610fd957600080fd5b6102c65a03f11515610fea57600080fd5b50505060405180519050600160a060020a031614151561100957600080fd5b60008381526001602052604090819020805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03851617905583907f52d7d861f09ab3d26239d492e8968629f95e9e318cf0b73bfddc441522a15fd290849051600160a060020a03909116815260200160405180910390a2505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106110c457805160ff19168380011785556110f1565b828001600101855582156110f1579182015b828111156110f15782518255916020019190600101906110d6565b506110fd929150611113565b5090565b60206040519081016040526000815290565b61112d91905b808211156110fd5760008155600101611119565b905600a165627a7a723058206016a807d9d5f6060e9c0d1c808e52d4ca30a4cab0140adcc6587bfc13bedf100029" +# ENS Default Registrar +registrar_abi = json.loads('[{"inputs":[{"internalType":"contract ENS","name":"_ens","type":"address"},{"internalType":"bytes32","name":"_baseNode","type":"bytes32"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"controller","type":"address"}],"name":"ControllerAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"controller","type":"address"}],"name":"ControllerRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"expires","type":"uint256"}],"name":"NameMigrated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"expires","type":"uint256"}],"name":"NameRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"expires","type":"uint256"}],"name":"NameRenewed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"constant":true,"inputs":[],"name":"GRACE_PERIOD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"controller","type":"address"}],"name":"addController","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"available","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"baseNode","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"controllers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"ens","outputs":[{"internalType":"contract ENS","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"nameExpires","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address","name":"owner","type":"address"}],"name":"reclaim","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"register","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"registerOnly","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"controller","type":"address"}],"name":"removeController","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"renew","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"resolver","type":"address"}],"name":"setResolver","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes4","name":"interfaceID","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]') +registrar_bytecode = '60806040523480156200001157600080fd5b5060405160408062002e71833981018060405260408110156200003357600080fd5b8101908080519060200190929190805190602001909291905050506200008b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002620001d6640100000000026401000000009004565b33600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3620001866380ac58cd7c010000000000000000000000000000000000000000000000000000000002620001d6640100000000026401000000009004565b81600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600381905550505062000294565b63ffffffff7c010000000000000000000000000000000000000000000000000000000002817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916141515156200022857600080fd5b6001600080837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b612bcd80620002a46000396000f3fe60806040526004361061015f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806301ffc9a714610164578063081812fc146101d6578063095ea7b3146102515780630e297b45146102ac57806323b872dd1461032557806328ed4f6c146103a05780633f15457f146103fb57806342842e0e146104525780634e543b26146104cd5780636352211e1461051e57806370a0823114610599578063715018a6146105fe5780638da5cb5b146106155780638f32d59b1461066c57806396e494e81461069b578063a22cb465146106ee578063a7fc7a071461074b578063b88d4fde1461079c578063c1a287e2146108ae578063c475abff146108d9578063d6e4fa8614610932578063da8c229e14610981578063ddf7fcb0146109ea578063e985e9c514610a15578063f2fde38b14610a9e578063f6a74ed714610aef578063fca247ac14610b40575b600080fd5b34801561017057600080fd5b506101bc6004803603602081101561018757600080fd5b8101908080357bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19169060200190929190505050610bb9565b604051808215151515815260200191505060405180910390f35b3480156101e257600080fd5b5061020f600480360360208110156101f957600080fd5b8101908080359060200190929190505050610f82565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561025d57600080fd5b506102aa6004803603604081101561027457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610fd3565b005b3480156102b857600080fd5b5061030f600480360360608110156102cf57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611118565b6040518082815260200191505060405180910390f35b34801561033157600080fd5b5061039e6004803603606081101561034857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611130565b005b3480156103ac57600080fd5b506103f9600480360360408110156103c357600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611155565b005b34801561040757600080fd5b50610410611381565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561045e57600080fd5b506104cb6004803603606081101561047557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506113a7565b005b3480156104d957600080fd5b5061051c600480360360208110156104f057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506113c8565b005b34801561052a57600080fd5b506105576004803603602081101561054157600080fd5b81019080803590602001909291905050506114bd565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156105a557600080fd5b506105e8600480360360208110156105bc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506114f0565b6040518082815260200191505060405180910390f35b34801561060a57600080fd5b50610613611574565b005b34801561062157600080fd5b5061062a611648565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561067857600080fd5b50610681611672565b604051808215151515815260200191505060405180910390f35b3480156106a757600080fd5b506106d4600480360360208110156106be57600080fd5b81019080803590602001909291905050506116ca565b604051808215151515815260200191505060405180910390f35b3480156106fa57600080fd5b506107496004803603604081101561071157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035151590602001909291905050506116ee565b005b34801561075757600080fd5b5061079a6004803603602081101561076e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061182a565b005b3480156107a857600080fd5b506108ac600480360360808110156107bf57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019064010000000081111561082657600080fd5b82018360208201111561083857600080fd5b8035906020019184600183028401116401000000008311171561085a57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506118db565b005b3480156108ba57600080fd5b506108c3611903565b6040518082815260200191505060405180910390f35b3480156108e557600080fd5b5061091c600480360360408110156108fc57600080fd5b81019080803590602001909291908035906020019092919050505061190a565b6040518082815260200191505060405180910390f35b34801561093e57600080fd5b5061096b6004803603602081101561095557600080fd5b8101908080359060200190929190505050611b45565b6040518082815260200191505060405180910390f35b34801561098d57600080fd5b506109d0600480360360208110156109a457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611b62565b604051808215151515815260200191505060405180910390f35b3480156109f657600080fd5b506109ff611b82565b6040518082815260200191505060405180910390f35b348015610a2157600080fd5b50610a8460048036036040811015610a3857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611b88565b604051808215151515815260200191505060405180910390f35b348015610aaa57600080fd5b50610aed60048036036020811015610ac157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611c1c565b005b348015610afb57600080fd5b50610b3e60048036036020811015610b1257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611c3b565b005b348015610b4c57600080fd5b50610ba360048036036060811015610b6357600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611cec565b6040518082815260200191505060405180910390f35b600060405180807f737570706f727473496e74657266616365286279746573342900000000000000815250601901905060405180910390207bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610efe575060405180807f736166655472616e7366657246726f6d28616464726573732c6164647265737381526020017f2c75696e743235362c6279746573290000000000000000000000000000000000815250602f019050604051809103902060405180807f736166655472616e7366657246726f6d28616464726573732c6164647265737381526020017f2c75696e743235362900000000000000000000000000000000000000000000008152506029019050604051809103902060405180807f7472616e7366657246726f6d28616464726573732c616464726573732c75696e81526020017f74323536290000000000000000000000000000000000000000000000000000008152506025019050604051809103902060405180807f6973417070726f766564466f72416c6c28616464726573732c6164647265737381526020017f29000000000000000000000000000000000000000000000000000000000000008152506021019050604051809103902060405180807f736574417070726f76616c466f72416c6c28616464726573732c626f6f6c2900815250601f019050604051809103902060405180807f676574417070726f7665642875696e74323536290000000000000000000000008152506014019050604051809103902060405180807f617070726f766528616464726573732c75696e743235362900000000000000008152506018019050604051809103902060405180807f6f776e65724f662875696e7432353629000000000000000000000000000000008152506010019050604051809103902060405180807f62616c616e63654f6628616464726573732900000000000000000000000000008152506012019050604051809103902018181818181818187bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610f7b575060405180807f7265636c61696d2875696e743235362c61646472657373290000000000000000815250601801905060405180910390207bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b9050919050565b6000610f8d82611d04565b1515610f9857600080fd5b6006600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610fde826114bd565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561101b57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061105b575061105a8133611b88565b5b151561106657600080fd5b826006600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4505050565b60006111278484846000611d76565b90509392505050565b61113a33826120b2565b151561114557600080fd5b611150838383612147565b505050565b3073ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166302571be36003546040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018082815260200191505060206040518083038186803b1580156111fd57600080fd5b505afa158015611211573d6000803e3d6000fd5b505050506040513d602081101561122757600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff1614151561125a57600080fd5b61126433836120b2565b151561126f57600080fd5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166306ab592360035484600102846040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808481526020018381526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019350505050602060405180830381600087803b15801561134157600080fd5b505af1158015611355573d6000803e3d6000fd5b505050506040513d602081101561136b57600080fd5b8101908080519060200190929190505050505050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6113c383838360206040519081016040528060008152506118db565b505050565b6113d0611672565b15156113db57600080fd5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16631896f70a600354836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808381526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200192505050600060405180830381600087803b1580156114a257600080fd5b505af11580156114b6573d6000803e3d6000fd5b5050505050565b60004260096000848152602001908152602001600020541115156114e057600080fd5b6114e9826123ac565b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415151561152d57600080fd5b600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61157c611672565b151561158757600080fd5b600073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614905090565b6000426276a700600960008581526020019081526020016000205401109050919050565b3373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415151561172957600080fd5b80600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051808215151515815260200191505060405180910390a35050565b611832611672565b151561183d57600080fd5b6001600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167f0a8bb31534c0ed46f380cb867bd5c803a189ced9a764e30b3a4991a9901d747460405160405180910390a250565b6118e6848484611130565b6118f28484848461242a565b15156118fd57600080fd5b50505050565b6276a70081565b60003073ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166302571be36003546040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018082815260200191505060206040518083038186803b1580156119b457600080fd5b505afa1580156119c8573d6000803e3d6000fd5b505050506040513d60208110156119de57600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff16141515611a1157600080fd5b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515611a6957600080fd5b426276a70060096000868152602001908152602001600020540110151515611a9057600080fd5b6276a70082016276a7008360096000878152602001908152602001600020540101111515611abd57600080fd5b816009600085815260200190815260200160002060008282540192505081905550827f9b87a00e30f1ac65d898f070f8a3488fe60517182d0a2098e1b4b93a54aa9bd660096000868152602001908152602001600020546040518082815260200191505060405180910390a26009600084815260200190815260200160002054905092915050565b600060096000838152602001908152602001600020549050919050565b60046020528060005260406000206000915054906101000a900460ff1681565b60035481565b6000600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611c24611672565b1515611c2f57600080fd5b611c388161264d565b50565b611c43611672565b1515611c4e57600080fd5b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167f33d83959be2573f5453b12eb9d43b3499bc57d96bd2f067ba44803c859e8111360405160405180910390a250565b6000611cfb8484846001611d76565b90509392505050565b6000806005600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415915050919050565b60003073ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166302571be36003546040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018082815260200191505060206040518083038186803b158015611e2057600080fd5b505afa158015611e34573d6000803e3d6000fd5b505050506040513d6020811015611e4a57600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff16141515611e7d57600080fd5b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515611ed557600080fd5b611ede856116ca565b1515611ee957600080fd5b6276a70042016276a70084420101111515611f0357600080fd5b8242016009600087815260200190815260200160002081905550611f2685611d04565b15611f3557611f3485612749565b5b611f3f848661275e565b811561205457600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166306ab592360035487600102876040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808481526020018381526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019350505050602060405180830381600087803b15801561201757600080fd5b505af115801561202b573d6000803e3d6000fd5b505050506040513d602081101561204157600080fd5b8101908080519060200190929190505050505b8373ffffffffffffffffffffffffffffffffffffffff16857fb3d987963d01b2f68493b4bdb130988f157ea43070d4ad840fee0466ed9370d98542016040518082815260200191505060405180910390a38242019050949350505050565b6000806120be836114bd565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061212d57508373ffffffffffffffffffffffffffffffffffffffff1661211584610f82565b73ffffffffffffffffffffffffffffffffffffffff16145b8061213e575061213d8185611b88565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16612167826114bd565b73ffffffffffffffffffffffffffffffffffffffff1614151561218957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141515156121c557600080fd5b6121ce816128f7565b6122216001600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546129b790919063ffffffff16565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506122b76001600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546129d990919063ffffffff16565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816005600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000806005600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561242157600080fd5b80915050919050565b600061244b8473ffffffffffffffffffffffffffffffffffffffff166129fa565b151561245a5760019050612645565b60008473ffffffffffffffffffffffffffffffffffffffff1663150b7a02338887876040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015612551578082015181840152602081019050612536565b50505050905090810190601f16801561257e5780820380516001836020036101000a031916815260200191505b5095505050505050602060405180830381600087803b1580156125a057600080fd5b505af11580156125b4573d6000803e3d6000fd5b505050506040513d60208110156125ca57600080fd5b8101908080519060200190929190505050905063150b7a027c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150505b949350505050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561268957600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61275b612755826114bd565b82612a0d565b50565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415151561279a57600080fd5b6127a381611d04565b1515156127af57600080fd5b816005600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506128546001600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546129d990919063ffffffff16565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600073ffffffffffffffffffffffffffffffffffffffff166006600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415156129b45760006006600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b50565b60008282111515156129c857600080fd5b600082840390508091505092915050565b60008082840190508381101515156129f057600080fd5b8091505092915050565b600080823b905060008111915050919050565b8173ffffffffffffffffffffffffffffffffffffffff16612a2d826114bd565b73ffffffffffffffffffffffffffffffffffffffff16141515612a4f57600080fd5b612a58816128f7565b612aab6001600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546129b790919063ffffffff16565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060006005600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505056fea165627a7a72305820af9388697026a32fc11fae5e11a7544e431f49880e9dccb1eb61220f2ec18abc0029' +registrar_bytecode_runtime = '60806040526004361061015f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806301ffc9a714610164578063081812fc146101d6578063095ea7b3146102515780630e297b45146102ac57806323b872dd1461032557806328ed4f6c146103a05780633f15457f146103fb57806342842e0e146104525780634e543b26146104cd5780636352211e1461051e57806370a0823114610599578063715018a6146105fe5780638da5cb5b146106155780638f32d59b1461066c57806396e494e81461069b578063a22cb465146106ee578063a7fc7a071461074b578063b88d4fde1461079c578063c1a287e2146108ae578063c475abff146108d9578063d6e4fa8614610932578063da8c229e14610981578063ddf7fcb0146109ea578063e985e9c514610a15578063f2fde38b14610a9e578063f6a74ed714610aef578063fca247ac14610b40575b600080fd5b34801561017057600080fd5b506101bc6004803603602081101561018757600080fd5b8101908080357bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19169060200190929190505050610bb9565b604051808215151515815260200191505060405180910390f35b3480156101e257600080fd5b5061020f600480360360208110156101f957600080fd5b8101908080359060200190929190505050610f82565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561025d57600080fd5b506102aa6004803603604081101561027457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610fd3565b005b3480156102b857600080fd5b5061030f600480360360608110156102cf57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611118565b6040518082815260200191505060405180910390f35b34801561033157600080fd5b5061039e6004803603606081101561034857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611130565b005b3480156103ac57600080fd5b506103f9600480360360408110156103c357600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611155565b005b34801561040757600080fd5b50610410611381565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561045e57600080fd5b506104cb6004803603606081101561047557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506113a7565b005b3480156104d957600080fd5b5061051c600480360360208110156104f057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506113c8565b005b34801561052a57600080fd5b506105576004803603602081101561054157600080fd5b81019080803590602001909291905050506114bd565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156105a557600080fd5b506105e8600480360360208110156105bc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506114f0565b6040518082815260200191505060405180910390f35b34801561060a57600080fd5b50610613611574565b005b34801561062157600080fd5b5061062a611648565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561067857600080fd5b50610681611672565b604051808215151515815260200191505060405180910390f35b3480156106a757600080fd5b506106d4600480360360208110156106be57600080fd5b81019080803590602001909291905050506116ca565b604051808215151515815260200191505060405180910390f35b3480156106fa57600080fd5b506107496004803603604081101561071157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035151590602001909291905050506116ee565b005b34801561075757600080fd5b5061079a6004803603602081101561076e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061182a565b005b3480156107a857600080fd5b506108ac600480360360808110156107bf57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019064010000000081111561082657600080fd5b82018360208201111561083857600080fd5b8035906020019184600183028401116401000000008311171561085a57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506118db565b005b3480156108ba57600080fd5b506108c3611903565b6040518082815260200191505060405180910390f35b3480156108e557600080fd5b5061091c600480360360408110156108fc57600080fd5b81019080803590602001909291908035906020019092919050505061190a565b6040518082815260200191505060405180910390f35b34801561093e57600080fd5b5061096b6004803603602081101561095557600080fd5b8101908080359060200190929190505050611b45565b6040518082815260200191505060405180910390f35b34801561098d57600080fd5b506109d0600480360360208110156109a457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611b62565b604051808215151515815260200191505060405180910390f35b3480156109f657600080fd5b506109ff611b82565b6040518082815260200191505060405180910390f35b348015610a2157600080fd5b50610a8460048036036040811015610a3857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611b88565b604051808215151515815260200191505060405180910390f35b348015610aaa57600080fd5b50610aed60048036036020811015610ac157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611c1c565b005b348015610afb57600080fd5b50610b3e60048036036020811015610b1257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611c3b565b005b348015610b4c57600080fd5b50610ba360048036036060811015610b6357600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611cec565b6040518082815260200191505060405180910390f35b600060405180807f737570706f727473496e74657266616365286279746573342900000000000000815250601901905060405180910390207bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610efe575060405180807f736166655472616e7366657246726f6d28616464726573732c6164647265737381526020017f2c75696e743235362c6279746573290000000000000000000000000000000000815250602f019050604051809103902060405180807f736166655472616e7366657246726f6d28616464726573732c6164647265737381526020017f2c75696e743235362900000000000000000000000000000000000000000000008152506029019050604051809103902060405180807f7472616e7366657246726f6d28616464726573732c616464726573732c75696e81526020017f74323536290000000000000000000000000000000000000000000000000000008152506025019050604051809103902060405180807f6973417070726f766564466f72416c6c28616464726573732c6164647265737381526020017f29000000000000000000000000000000000000000000000000000000000000008152506021019050604051809103902060405180807f736574417070726f76616c466f72416c6c28616464726573732c626f6f6c2900815250601f019050604051809103902060405180807f676574417070726f7665642875696e74323536290000000000000000000000008152506014019050604051809103902060405180807f617070726f766528616464726573732c75696e743235362900000000000000008152506018019050604051809103902060405180807f6f776e65724f662875696e7432353629000000000000000000000000000000008152506010019050604051809103902060405180807f62616c616e63654f6628616464726573732900000000000000000000000000008152506012019050604051809103902018181818181818187bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610f7b575060405180807f7265636c61696d2875696e743235362c61646472657373290000000000000000815250601801905060405180910390207bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b9050919050565b6000610f8d82611d04565b1515610f9857600080fd5b6006600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610fde826114bd565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561101b57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061105b575061105a8133611b88565b5b151561106657600080fd5b826006600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4505050565b60006111278484846000611d76565b90509392505050565b61113a33826120b2565b151561114557600080fd5b611150838383612147565b505050565b3073ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166302571be36003546040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018082815260200191505060206040518083038186803b1580156111fd57600080fd5b505afa158015611211573d6000803e3d6000fd5b505050506040513d602081101561122757600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff1614151561125a57600080fd5b61126433836120b2565b151561126f57600080fd5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166306ab592360035484600102846040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808481526020018381526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019350505050602060405180830381600087803b15801561134157600080fd5b505af1158015611355573d6000803e3d6000fd5b505050506040513d602081101561136b57600080fd5b8101908080519060200190929190505050505050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6113c383838360206040519081016040528060008152506118db565b505050565b6113d0611672565b15156113db57600080fd5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16631896f70a600354836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808381526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200192505050600060405180830381600087803b1580156114a257600080fd5b505af11580156114b6573d6000803e3d6000fd5b5050505050565b60004260096000848152602001908152602001600020541115156114e057600080fd5b6114e9826123ac565b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415151561152d57600080fd5b600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61157c611672565b151561158757600080fd5b600073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614905090565b6000426276a700600960008581526020019081526020016000205401109050919050565b3373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415151561172957600080fd5b80600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051808215151515815260200191505060405180910390a35050565b611832611672565b151561183d57600080fd5b6001600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167f0a8bb31534c0ed46f380cb867bd5c803a189ced9a764e30b3a4991a9901d747460405160405180910390a250565b6118e6848484611130565b6118f28484848461242a565b15156118fd57600080fd5b50505050565b6276a70081565b60003073ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166302571be36003546040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018082815260200191505060206040518083038186803b1580156119b457600080fd5b505afa1580156119c8573d6000803e3d6000fd5b505050506040513d60208110156119de57600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff16141515611a1157600080fd5b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515611a6957600080fd5b426276a70060096000868152602001908152602001600020540110151515611a9057600080fd5b6276a70082016276a7008360096000878152602001908152602001600020540101111515611abd57600080fd5b816009600085815260200190815260200160002060008282540192505081905550827f9b87a00e30f1ac65d898f070f8a3488fe60517182d0a2098e1b4b93a54aa9bd660096000868152602001908152602001600020546040518082815260200191505060405180910390a26009600084815260200190815260200160002054905092915050565b600060096000838152602001908152602001600020549050919050565b60046020528060005260406000206000915054906101000a900460ff1681565b60035481565b6000600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611c24611672565b1515611c2f57600080fd5b611c388161264d565b50565b611c43611672565b1515611c4e57600080fd5b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167f33d83959be2573f5453b12eb9d43b3499bc57d96bd2f067ba44803c859e8111360405160405180910390a250565b6000611cfb8484846001611d76565b90509392505050565b6000806005600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415915050919050565b60003073ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166302571be36003546040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018082815260200191505060206040518083038186803b158015611e2057600080fd5b505afa158015611e34573d6000803e3d6000fd5b505050506040513d6020811015611e4a57600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff16141515611e7d57600080fd5b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515611ed557600080fd5b611ede856116ca565b1515611ee957600080fd5b6276a70042016276a70084420101111515611f0357600080fd5b8242016009600087815260200190815260200160002081905550611f2685611d04565b15611f3557611f3485612749565b5b611f3f848661275e565b811561205457600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166306ab592360035487600102876040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808481526020018381526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019350505050602060405180830381600087803b15801561201757600080fd5b505af115801561202b573d6000803e3d6000fd5b505050506040513d602081101561204157600080fd5b8101908080519060200190929190505050505b8373ffffffffffffffffffffffffffffffffffffffff16857fb3d987963d01b2f68493b4bdb130988f157ea43070d4ad840fee0466ed9370d98542016040518082815260200191505060405180910390a38242019050949350505050565b6000806120be836114bd565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061212d57508373ffffffffffffffffffffffffffffffffffffffff1661211584610f82565b73ffffffffffffffffffffffffffffffffffffffff16145b8061213e575061213d8185611b88565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16612167826114bd565b73ffffffffffffffffffffffffffffffffffffffff1614151561218957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141515156121c557600080fd5b6121ce816128f7565b6122216001600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546129b790919063ffffffff16565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506122b76001600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546129d990919063ffffffff16565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816005600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000806005600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561242157600080fd5b80915050919050565b600061244b8473ffffffffffffffffffffffffffffffffffffffff166129fa565b151561245a5760019050612645565b60008473ffffffffffffffffffffffffffffffffffffffff1663150b7a02338887876040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015612551578082015181840152602081019050612536565b50505050905090810190601f16801561257e5780820380516001836020036101000a031916815260200191505b5095505050505050602060405180830381600087803b1580156125a057600080fd5b505af11580156125b4573d6000803e3d6000fd5b505050506040513d60208110156125ca57600080fd5b8101908080519060200190929190505050905063150b7a027c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150505b949350505050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561268957600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61275b612755826114bd565b82612a0d565b50565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415151561279a57600080fd5b6127a381611d04565b1515156127af57600080fd5b816005600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506128546001600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546129d990919063ffffffff16565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600073ffffffffffffffffffffffffffffffffffffffff166006600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415156129b45760006006600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b50565b60008282111515156129c857600080fd5b600082840390508091505092915050565b60008082840190508381101515156129f057600080fd5b8091505092915050565b600080823b905060008111915050919050565b8173ffffffffffffffffffffffffffffffffffffffff16612a2d826114bd565b73ffffffffffffffffffffffffffffffffffffffff16141515612a4f57600080fd5b612a58816128f7565b612aab6001600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546129b790919063ffffffff16565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060006005600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505056fea165627a7a72305820af9388697026a32fc11fae5e11a7544e431f49880e9dccb1eb61220f2ec18abc0029' +# ENS Public Resolver 2 +resolver_abi = json.loads('[{"inputs":[{"internalType":"contract ENS","name":"_ens","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"contentType","type":"uint256"}],"name":"ABIChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"address","name":"a","type":"address"}],"name":"AddrChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"coinType","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"newAddress","type":"bytes"}],"name":"AddressChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"bool","name":"isAuthorised","type":"bool"}],"name":"AuthorisationChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"hash","type":"bytes"}],"name":"ContenthashChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"name","type":"bytes"},{"indexed":false,"internalType":"uint16","name":"resource","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"record","type":"bytes"}],"name":"DNSRecordChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"name","type":"bytes"},{"indexed":false,"internalType":"uint16","name":"resource","type":"uint16"}],"name":"DNSRecordDeleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"DNSZoneCleared","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":true,"internalType":"bytes4","name":"interfaceID","type":"bytes4"},{"indexed":false,"internalType":"address","name":"implementer","type":"address"}],"name":"InterfaceChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"string","name":"name","type":"string"}],"name":"NameChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"x","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"y","type":"bytes32"}],"name":"PubkeyChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":true,"internalType":"string","name":"indexedKey","type":"string"},{"indexed":false,"internalType":"string","name":"key","type":"string"}],"name":"TextChanged","type":"event"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"uint256","name":"contentTypes","type":"uint256"}],"name":"ABI","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"addr","outputs":[{"internalType":"address payable","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"uint256","name":"coinType","type":"uint256"}],"name":"addr","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"authorisations","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"clearDNSZone","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"contenthash","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes32","name":"name","type":"bytes32"},{"internalType":"uint16","name":"resource","type":"uint16"}],"name":"dnsRecord","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes32","name":"name","type":"bytes32"}],"name":"hasDNSRecords","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes4","name":"interfaceID","type":"bytes4"}],"name":"interfaceImplementer","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"pubkey","outputs":[{"internalType":"bytes32","name":"x","type":"bytes32"},{"internalType":"bytes32","name":"y","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"uint256","name":"contentType","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"setABI","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"uint256","name":"coinType","type":"uint256"},{"internalType":"bytes","name":"a","type":"bytes"}],"name":"setAddr","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"address","name":"a","type":"address"}],"name":"setAddr","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"address","name":"target","type":"address"},{"internalType":"bool","name":"isAuthorised","type":"bool"}],"name":"setAuthorisation","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes","name":"hash","type":"bytes"}],"name":"setContenthash","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"setDNSRecords","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes4","name":"interfaceID","type":"bytes4"},{"internalType":"address","name":"implementer","type":"address"}],"name":"setInterface","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"string","name":"name","type":"string"}],"name":"setName","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes32","name":"x","type":"bytes32"},{"internalType":"bytes32","name":"y","type":"bytes32"}],"name":"setPubkey","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"string","name":"key","type":"string"},{"internalType":"string","name":"value","type":"string"}],"name":"setText","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes4","name":"interfaceID","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"string","name":"key","type":"string"}],"name":"text","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"}]') +resolver_bytecode = '60806040523480156200001157600080fd5b506040516020806200399f833981018060405262000033919081019062000091565b80600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505062000105565b6000620000898251620000f1565b905092915050565b600060208284031215620000a457600080fd5b6000620000b4848285016200007b565b91505092915050565b6000620000ca82620000d1565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620000fe82620000bd565b9050919050565b61388a80620001156000396000f3fe608060405260043610610133576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806301ffc9a7146101385780630af179d71461017557806310f13a8c1461019e578063124a319c146101c75780632203ab561461020457806329cd62ea14610242578063304e6ade1461026b5780633b3b57de146102945780633e9ce794146102d15780634cbf6ba4146102fa57806359d1d43c14610337578063623195b014610374578063691f34311461039d57806377372213146103da5780638b95dd7114610403578063a8fa56821461042c578063ad5780af14610469578063bc1c58d114610492578063c8690233146104cf578063d5fa2b001461050d578063e59d895d14610536578063f1cb7e061461055f578063f86bc8791461059c575b600080fd5b34801561014457600080fd5b5061015f600480360361015a9190810190613148565b6105d9565b60405161016c91906132df565b60405180910390f35b34801561018157600080fd5b5061019c60048036036101979190810190612f00565b610656565b005b3480156101aa57600080fd5b506101c560048036036101c09190810190612fb0565b6108d5565b005b3480156101d357600080fd5b506101ee60048036036101e99190810190612e75565b610979565b6040516101fb91906132a9565b60405180910390f35b34801561021057600080fd5b5061022b60048036036102269190810190613039565b610ede565b60405161023992919061361e565b60405180910390f35b34801561024e57600080fd5b5061026960048036036102649190810190612dd7565b611033565b005b34801561027757600080fd5b50610292600480360361028d9190810190612f00565b6110c8565b005b3480156102a057600080fd5b506102bb60048036036102b69190810190612c98565b611141565b6040516102c891906132c4565b60405180910390f35b3480156102dd57600080fd5b506102f860048036036102f39190810190612d4c565b611178565b005b34801561030657600080fd5b50610321600480360361031c9190810190612d9b565b61125f565b60405161032e91906132df565b60405180910390f35b34801561034357600080fd5b5061035e60048036036103599190810190612f58565b6112c7565b60405161036b91906135fc565b60405180910390f35b34801561038057600080fd5b5061039b60048036036103969190810190613075565b6113a3565b005b3480156103a957600080fd5b506103c460048036036103bf9190810190612c98565b61143f565b6040516103d191906135fc565b60405180910390f35b3480156103e657600080fd5b5061040160048036036103fc9190810190612f58565b6114f4565b005b34801561040f57600080fd5b5061042a600480360361042591908101906130e1565b61156d565b005b34801561043857600080fd5b50610453600480360361044e9190810190612e26565b611647565b60405161046091906135da565b60405180910390f35b34801561047557600080fd5b50610490600480360361048b9190810190612c98565b61174c565b005b34801561049e57600080fd5b506104b960048036036104b49190810190612c98565b6117bf565b6040516104c691906135da565b60405180910390f35b3480156104db57600080fd5b506104f660048036036104f19190810190612c98565b611874565b604051610504929190613383565b60405180910390f35b34801561051957600080fd5b50610534600480360361052f9190810190612cc1565b6118ae565b005b34801561054257600080fd5b5061055d60048036036105589190810190612eb1565b6118dc565b005b34801561056b57600080fd5b5061058660048036036105819190810190613039565b6119d3565b60405161059391906135da565b60405180910390f35b3480156105a857600080fd5b506105c360048036036105be9190810190612cfd565b611a9a565b6040516105d091906132df565b60405180910390f35b60006359d1d43c7c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061064f575061064e82611ad6565b5b9050919050565b8261066081611b53565b151561066b57600080fd5b6000809050600080905060608060006106826128bc565b6106da60008a8a8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050611cf890919063ffffffff16565b90505b6106e681611d22565b15156108625760008661ffff161415610791578060400151955061070981611d38565b9350836040516020018082805190602001908083835b602083101515610744578051825260208201915060208101905060208303925061071f565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120915061078a81611d6f565b9250610854565b606061079c82611d38565b9050816040015161ffff168761ffff161415806107c957506107c78186611d9f90919063ffffffff16565b155b156108525761082b8b86898d8d8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508a8b88602001510360008b5114611dc6565b81604001519650816020015195508094508480519060200120925061084f82611d6f565b93505b505b61085d816120fa565b6106dd565b506000835111156108ca576108c98984878b8b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505088898e8e9050036000895114611dc6565b5b505050505050505050565b846108df81611b53565b15156108ea57600080fd5b828260096000898152602001908152602001600020878760405180838380828437808301925050509250505090815260200160405180910390209190610931929190612908565b507fd8c9334b1a9c2f9da342a0a2b32629c1a229b6445dad78947f674b44444a7550868686888860405161096995949392919061350f565b60405180910390a1505050505050565b600080600660008581526020019081526020016000206000847bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515610a405780915050610ed8565b6000610a4b85611141565b9050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610a8d57600092505050610ed8565b600060608273ffffffffffffffffffffffffffffffffffffffff166301ffc9a77c010000000000000000000000000000000000000000000000000000000002604051602401610adc91906135bf565b6040516020818303038152906040527f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040518082805190602001908083835b602083101515610b8e5780518252602082019150602081019050602083039250610b69565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114610bee576040519150601f19603f3d011682016040523d82523d6000602084013e610bf3565b606091505b5091509150811580610c06575060208151105b80610cae575060007f01000000000000000000000000000000000000000000000000000000000000000281601f815181101515610c3f57fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b15610cc0576000945050505050610ed8565b8273ffffffffffffffffffffffffffffffffffffffff1686604051602401610ce891906135bf565b6040516020818303038152906040527f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040518082805190602001908083835b602083101515610d9a5780518252602082019150602081019050602083039250610d75565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114610dfa576040519150601f19603f3d011682016040523d82523d6000602084013e610dff565b606091505b508092508193505050811580610e16575060208151105b80610ebe575060007f01000000000000000000000000000000000000000000000000000000000000000281601f815181101515610e4f57fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b15610ed0576000945050505050610ed8565b829450505050505b92915050565b60006060600080600086815260200190815260200160002090506000600190505b848111151561100f57600085821614158015610f4157506000826000838152602001908152602001600020805460018160011615610100020316600290049050115b156110005780826000838152602001908152602001600020808054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610fee5780601f10610fc357610100808354040283529160200191610fee565b820191906000526020600020905b815481529060010190602001808311610fd157829003601f168201915b5050505050905093509350505061102c565b6001819060020a029050610eff565b506000602060405190810160405280600081525081915092509250505b9250929050565b8261103d81611b53565b151561104857600080fd5b6040805190810160405280848152602001838152506008600086815260200190815260200160002060008201518160000155602082015181600101559050507f1d6f5e03d3f63eb58751986629a5439baee5079ff04f345becb66e23eb154e468484846040516110ba939291906133ac565b60405180910390a150505050565b826110d281611b53565b15156110dd57600080fd5b82826002600087815260200190815260200160002091906110ff929190612988565b507fe379c1624ed7e714cc0937528a32359d69d5281337765313dba4e081b72d75788484846040516111339392919061341a565b60405180910390a150505050565b6000606061115083603c6119d3565b9050600081511415611166576000915050611173565b61116f81612210565b9150505b919050565b80600b600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507fe1c5610a6e0cbe10764ecd182adcef1ec338dc4e199c99c32ce98f38e12791df83338484604051611252949392919061333e565b60405180910390a1505050565b60008060056000858152602001908152602001600020600060036000878152602001908152602001600020548152602001908152602001600020600084815260200190815260200160002060009054906101000a900461ffff1661ffff161415905092915050565b606060096000858152602001908152602001600020838360405180838380828437808301925050509250505090815260200160405180910390208054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156113955780601f1061136a57610100808354040283529160200191611395565b820191906000526020600020905b81548152906001019060200180831161137857829003601f168201915b505050505090509392505050565b836113ad81611b53565b15156113b857600080fd5b60008460018603161415156113cc57600080fd5b8282600080888152602001908152602001600020600087815260200190815260200160002091906113fe929190612988565b507faa121bbeef5f32f5961a2a28966e769023910fc9479059ee3495d4c1a696efe38585604051611430929190613558565b60405180910390a15050505050565b6060600760008381526020019081526020016000208054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156114e85780601f106114bd576101008083540402835291602001916114e8565b820191906000526020600020905b8154815290600101906020018083116114cb57829003601f168201915b50505050509050919050565b826114fe81611b53565b151561150957600080fd5b828260076000878152602001908152602001600020919061152b929190612908565b507fb7d29e911041e8d9b843369e890bcb72c9388692ba48b65ac54e7214c4c348f784848460405161155f939291906134dd565b60405180910390a150505050565b8261157781611b53565b151561158257600080fd5b7f65412581168e88a1e60c6459d7f44ae83ad0832e670826c05a4e2476b57af7528484846040516115b593929190613581565b60405180910390a1603c831415611608577f52d7d861f09ab3d26239d492e8968629f95e9e318cf0b73bfddc441522a15fd2846115f184612210565b6040516115ff929190613315565b60405180910390a15b816001600086815260200190815260200160002060008581526020019081526020016000209080519060200190611640929190612a08565b5050505050565b606060046000858152602001908152602001600020600060036000878152602001908152602001600020548152602001908152602001600020600084815260200190815260200160002060008361ffff1661ffff1681526020019081526020016000208054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561173e5780601f106117135761010080835404028352916020019161173e565b820191906000526020600020905b81548152906001019060200180831161172157829003601f168201915b505050505090509392505050565b8061175681611b53565b151561176157600080fd5b60036000838152602001908152602001600020600081548092919060010191905055507fb757169b8492ca2f1c6619d9d76ce22803035c3b1d5f6930dffe7b127c1a1983826040516117b391906132fa565b60405180910390a15050565b6060600260008381526020019081526020016000208054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156118685780601f1061183d57610100808354040283529160200191611868565b820191906000526020600020905b81548152906001019060200180831161184b57829003601f168201915b50505050509050919050565b6000806008600084815260200190815260200160002060000154600860008581526020019081526020016000206001015491509150915091565b816118b881611b53565b15156118c357600080fd5b6118d783603c6118d285612235565b61156d565b505050565b826118e681611b53565b15156118f157600080fd5b81600660008681526020019081526020016000206000857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f7c69f06bea0bdef565b709e93a147836b0063ba2dd89f02d0b7e8d931e6a6daa8484846040516119c5939291906133e3565b60405180910390a150505050565b60606001600084815260200190815260200160002060008381526020019081526020016000208054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611a8d5780601f10611a6257610100808354040283529160200191611a8d565b820191906000526020600020905b815481529060010190602001808311611a7057829003601f168201915b5050505050905092915050565b600b602052826000526040600020602052816000526040600020602052806000526040600020600092509250509054906101000a900460ff1681565b600063c86902337c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611b4c5750611b4b82612280565b5b9050919050565b600080600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166302571be3846040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401611bcd91906132fa565b60206040518083038186803b158015611be557600080fd5b505afa158015611bf9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611c1d9190810190612c6f565b90503373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161480611cf05750600b600084815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b915050919050565b611d006128bc565b828160000181905250818160c0018181525050611d1c816120fa565b92915050565b6000816000015151826020015110159050919050565b6060611d688260200151611d54846000015185602001516122fd565b846000015161235a9092919063ffffffff16565b9050919050565b6060611d988260a001518360a001518460c0015103846000015161235a9092919063ffffffff16565b9050919050565b600081518351148015611dbe5750611dbd83600084600087516123cf565b5b905092915050565b6000600360008981526020019081526020016000205490506000878051906020012090506060611e0186868961235a9092919063ffffffff16565b90508315611f79576000600460008c81526020019081526020016000206000858152602001908152602001600020600084815260200190815260200160002060008a61ffff1661ffff168152602001908152602001600020805460018160011615610100020316600290049050141515611edf57600560008b815260200190815260200160002060008481526020019081526020016000206000838152602001908152602001600020600081819054906101000a900461ffff16809291906001900391906101000a81548161ffff021916908361ffff160217905550505b600460008b81526020019081526020016000206000848152602001908152602001600020600083815260200190815260200160002060008961ffff1661ffff1681526020019081526020016000206000611f399190612a88565b7f03528ed0c2a3ebc993b12ce3c16bb382f9c7d88ef7d8a1bf290eaf35955a12078a8a8a604051611f6c9392919061344c565b60405180910390a16120ee565b6000600460008c81526020019081526020016000206000858152602001908152602001600020600084815260200190815260200160002060008a61ffff1661ffff168152602001908152602001600020805460018160011615610100020316600290049050141561204d57600560008b815260200190815260200160002060008481526020019081526020016000206000838152602001908152602001600020600081819054906101000a900461ffff168092919060010191906101000a81548161ffff021916908361ffff160217905550505b80600460008c81526020019081526020016000206000858152602001908152602001600020600084815260200190815260200160002060008a61ffff1661ffff16815260200190815260200160002090805190602001906120af929190612a08565b507f52a608b3303a48862d07a73d82fa221318c0027fbbcfb1b2329bface3f19ff2b8a8a8a846040516120e5949392919061348a565b60405180910390a15b50505050505050505050565b8060c00151816020018181525050806000015151816020015110151561211f5761220d565b6000612133826000015183602001516122fd565b82602001510190506121528183600001516123f390919063ffffffff16565b826040019061ffff16908161ffff16815250506002810190506121828183600001516123f390919063ffffffff16565b826060019061ffff16908161ffff16815250506002810190506121b281836000015161241b90919063ffffffff16565b826080019063ffffffff16908163ffffffff168152505060048101905060006121e88284600001516123f390919063ffffffff16565b61ffff169050600282019150818360a00181815250508082018360c001818152505050505b50565b60006014825114151561222257600080fd5b600c6101000a6020830151049050919050565b606060146040519080825280601f01601f19166020018201604052801561226b5781602001600182028038833980820191505090505b509050600c6101000a82026020820152919050565b600063691f34317c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806122f657506122f582612445565b5b9050919050565b6000808290505b60011561234e5783518110151561231757fe5b600061232c82866124fa90919063ffffffff16565b60ff16905060018101820191506000811415612348575061234e565b50612304565b82810391505092915050565b606083518284011115151561236e57600080fd5b6060826040519080825280601f01601f1916602001820160405280156123a35781602001600182028038833980820191505090505b50905060008060208301915085602088010190506123c2828287612580565b8293505050509392505050565b60006123dc8484846125cb565b6123e78787856125cb565b14905095945050505050565b60008251600283011115151561240857600080fd5b61ffff8260028501015116905092915050565b60008251600483011115151561243057600080fd5b63ffffffff8260048501015116905092915050565b600060405180807f696e74657266616365496d706c656d656e74657228627974657333322c62797481526020017f6573342900000000000000000000000000000000000000000000000000000000815250602401905060405180910390207bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806124f357506124f2826125f0565b5b9050919050565b6000828281518110151561250a57fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027f01000000000000000000000000000000000000000000000000000000000000009004905092915050565b5b6020811015156125a65781518352602083019250602082019150602081039050612581565b60006001826020036101000a0390508019835116818551168181178652505050505050565b60008351828401111515156125df57600080fd5b818360208601012090509392505050565b600063a8fa56827c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061266657506126658261266d565b5b9050919050565b600063bc1c58d17c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806126e357506126e2826126ea565b5b9050919050565b6000633b3b57de7c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806127bb575063f1cb7e067c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806127cb57506127ca826127d2565b5b9050919050565b6000632203ab567c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061284857506128478261284f565b5b9050919050565b60006301ffc9a77c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60e0604051908101604052806060815260200160008152602001600061ffff168152602001600061ffff168152602001600063ffffffff16815260200160008152602001600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061294957803560ff1916838001178555612977565b82800160010185558215612977579182015b8281111561297657823582559160200191906001019061295b565b5b5090506129849190612ad0565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106129c957803560ff19168380011785556129f7565b828001600101855582156129f7579182015b828111156129f65782358255916020019190600101906129db565b5b509050612a049190612ad0565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10612a4957805160ff1916838001178555612a77565b82800160010185558215612a77579182015b82811115612a76578251825591602001919060010190612a5b565b5b509050612a849190612ad0565b5090565b50805460018160011615610100020316600290046000825580601f10612aae5750612acd565b601f016020900490600052602060002090810190612acc9190612ad0565b5b50565b612af291905b80821115612aee576000816000905550600101612ad6565b5090565b90565b6000612b01823561375b565b905092915050565b6000612b15825161375b565b905092915050565b6000612b29823561376d565b905092915050565b6000612b3d8235613779565b905092915050565b6000612b518235613783565b905092915050565b60008083601f8401121515612b6d57600080fd5b8235905067ffffffffffffffff811115612b8657600080fd5b602083019150836001820283011115612b9e57600080fd5b9250929050565b600082601f8301121515612bb857600080fd5b8135612bcb612bc68261367b565b61364e565b91508082526020830160208301858383011115612be757600080fd5b612bf28382846137fd565b50505092915050565b60008083601f8401121515612c0f57600080fd5b8235905067ffffffffffffffff811115612c2857600080fd5b602083019150836001820283011115612c4057600080fd5b9250929050565b6000612c5382356137af565b905092915050565b6000612c6782356137bd565b905092915050565b600060208284031215612c8157600080fd5b6000612c8f84828501612b09565b91505092915050565b600060208284031215612caa57600080fd5b6000612cb884828501612b31565b91505092915050565b60008060408385031215612cd457600080fd5b6000612ce285828601612b31565b9250506020612cf385828601612af5565b9150509250929050565b600080600060608486031215612d1257600080fd5b6000612d2086828701612b31565b9350506020612d3186828701612af5565b9250506040612d4286828701612af5565b9150509250925092565b600080600060608486031215612d6157600080fd5b6000612d6f86828701612b31565b9350506020612d8086828701612af5565b9250506040612d9186828701612b1d565b9150509250925092565b60008060408385031215612dae57600080fd5b6000612dbc85828601612b31565b9250506020612dcd85828601612b31565b9150509250929050565b600080600060608486031215612dec57600080fd5b6000612dfa86828701612b31565b9350506020612e0b86828701612b31565b9250506040612e1c86828701612b31565b9150509250925092565b600080600060608486031215612e3b57600080fd5b6000612e4986828701612b31565b9350506020612e5a86828701612b31565b9250506040612e6b86828701612c47565b9150509250925092565b60008060408385031215612e8857600080fd5b6000612e9685828601612b31565b9250506020612ea785828601612b45565b9150509250929050565b600080600060608486031215612ec657600080fd5b6000612ed486828701612b31565b9350506020612ee586828701612b45565b9250506040612ef686828701612af5565b9150509250925092565b600080600060408486031215612f1557600080fd5b6000612f2386828701612b31565b935050602084013567ffffffffffffffff811115612f4057600080fd5b612f4c86828701612b59565b92509250509250925092565b600080600060408486031215612f6d57600080fd5b6000612f7b86828701612b31565b935050602084013567ffffffffffffffff811115612f9857600080fd5b612fa486828701612bfb565b92509250509250925092565b600080600080600060608688031215612fc857600080fd5b6000612fd688828901612b31565b955050602086013567ffffffffffffffff811115612ff357600080fd5b612fff88828901612bfb565b9450945050604086013567ffffffffffffffff81111561301e57600080fd5b61302a88828901612bfb565b92509250509295509295909350565b6000806040838503121561304c57600080fd5b600061305a85828601612b31565b925050602061306b85828601612c5b565b9150509250929050565b6000806000806060858703121561308b57600080fd5b600061309987828801612b31565b94505060206130aa87828801612c5b565b935050604085013567ffffffffffffffff8111156130c757600080fd5b6130d387828801612b59565b925092505092959194509250565b6000806000606084860312156130f657600080fd5b600061310486828701612b31565b935050602061311586828701612c5b565b925050604084013567ffffffffffffffff81111561313257600080fd5b61313e86828701612ba5565b9150509250925092565b60006020828403121561315a57600080fd5b600061316884828501612b45565b91505092915050565b61317a816137c7565b82525050565b613189816136cf565b82525050565b613198816136bd565b82525050565b6131a7816136e1565b82525050565b6131b6816136ed565b82525050565b6131c5816136f7565b82525050565b60008284526020840193506131e18385846137fd565b6131ea8361383f565b840190509392505050565b6000613200826136a7565b80845261321481602086016020860161380c565b61321d8161383f565b602085010191505092915050565b60008284526020840193506132418385846137fd565b61324a8361383f565b840190509392505050565b6000613260826136b2565b80845261327481602086016020860161380c565b61327d8161383f565b602085010191505092915050565b61329481613723565b82525050565b6132a381613751565b82525050565b60006020820190506132be600083018461318f565b92915050565b60006020820190506132d96000830184613180565b92915050565b60006020820190506132f4600083018461319e565b92915050565b600060208201905061330f60008301846131ad565b92915050565b600060408201905061332a60008301856131ad565b6133376020830184613171565b9392505050565b600060808201905061335360008301876131ad565b6133606020830186613171565b61336d604083018561318f565b61337a606083018461319e565b95945050505050565b600060408201905061339860008301856131ad565b6133a560208301846131ad565b9392505050565b60006060820190506133c160008301866131ad565b6133ce60208301856131ad565b6133db60408301846131ad565b949350505050565b60006060820190506133f860008301866131ad565b61340560208301856131bc565b613412604083018461318f565b949350505050565b600060408201905061342f60008301866131ad565b81810360208301526134428184866131cb565b9050949350505050565b600060608201905061346160008301866131ad565b818103602083015261347381856131f5565b9050613482604083018461328b565b949350505050565b600060808201905061349f60008301876131ad565b81810360208301526134b181866131f5565b90506134c0604083018561328b565b81810360608301526134d281846131f5565b905095945050505050565b60006040820190506134f260008301866131ad565b818103602083015261350581848661322b565b9050949350505050565b600060608201905061352460008301886131ad565b818103602083015261353781868861322b565b9050818103604083015261354c81848661322b565b90509695505050505050565b600060408201905061356d60008301856131ad565b61357a602083018461329a565b9392505050565b600060608201905061359660008301866131ad565b6135a3602083018561329a565b81810360408301526135b581846131f5565b9050949350505050565b60006020820190506135d460008301846131bc565b92915050565b600060208201905081810360008301526135f481846131f5565b905092915050565b600060208201905081810360008301526136168184613255565b905092915050565b6000604082019050613633600083018561329a565b818103602083015261364581846131f5565b90509392505050565b6000604051905081810181811067ffffffffffffffff8211171561367157600080fd5b8060405250919050565b600067ffffffffffffffff82111561369257600080fd5b601f19601f8301169050602081019050919050565b600081519050919050565b600081519050919050565b60006136c882613731565b9050919050565b60006136da82613731565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600061ffff82169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600061376682613731565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600061ffff82169050919050565b6000819050919050565b60006137d2826137d9565b9050919050565b60006137e4826137eb565b9050919050565b60006137f682613731565b9050919050565b82818337600083830152505050565b60005b8381101561382a57808201518184015260208101905061380f565b83811115613839576000848401525b50505050565b6000601f19601f830116905091905056fea265627a7a72305820668668127482cd23a9f375761bf0b8d29fdbff7c261f4d2755ca9c73637d86bf6c6578706572696d656e74616cf50037' +resolver_bytecode_runtime = '608060405260043610610133576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806301ffc9a7146101385780630af179d71461017557806310f13a8c1461019e578063124a319c146101c75780632203ab561461020457806329cd62ea14610242578063304e6ade1461026b5780633b3b57de146102945780633e9ce794146102d15780634cbf6ba4146102fa57806359d1d43c14610337578063623195b014610374578063691f34311461039d57806377372213146103da5780638b95dd7114610403578063a8fa56821461042c578063ad5780af14610469578063bc1c58d114610492578063c8690233146104cf578063d5fa2b001461050d578063e59d895d14610536578063f1cb7e061461055f578063f86bc8791461059c575b600080fd5b34801561014457600080fd5b5061015f600480360361015a9190810190613148565b6105d9565b60405161016c91906132df565b60405180910390f35b34801561018157600080fd5b5061019c60048036036101979190810190612f00565b610656565b005b3480156101aa57600080fd5b506101c560048036036101c09190810190612fb0565b6108d5565b005b3480156101d357600080fd5b506101ee60048036036101e99190810190612e75565b610979565b6040516101fb91906132a9565b60405180910390f35b34801561021057600080fd5b5061022b60048036036102269190810190613039565b610ede565b60405161023992919061361e565b60405180910390f35b34801561024e57600080fd5b5061026960048036036102649190810190612dd7565b611033565b005b34801561027757600080fd5b50610292600480360361028d9190810190612f00565b6110c8565b005b3480156102a057600080fd5b506102bb60048036036102b69190810190612c98565b611141565b6040516102c891906132c4565b60405180910390f35b3480156102dd57600080fd5b506102f860048036036102f39190810190612d4c565b611178565b005b34801561030657600080fd5b50610321600480360361031c9190810190612d9b565b61125f565b60405161032e91906132df565b60405180910390f35b34801561034357600080fd5b5061035e60048036036103599190810190612f58565b6112c7565b60405161036b91906135fc565b60405180910390f35b34801561038057600080fd5b5061039b60048036036103969190810190613075565b6113a3565b005b3480156103a957600080fd5b506103c460048036036103bf9190810190612c98565b61143f565b6040516103d191906135fc565b60405180910390f35b3480156103e657600080fd5b5061040160048036036103fc9190810190612f58565b6114f4565b005b34801561040f57600080fd5b5061042a600480360361042591908101906130e1565b61156d565b005b34801561043857600080fd5b50610453600480360361044e9190810190612e26565b611647565b60405161046091906135da565b60405180910390f35b34801561047557600080fd5b50610490600480360361048b9190810190612c98565b61174c565b005b34801561049e57600080fd5b506104b960048036036104b49190810190612c98565b6117bf565b6040516104c691906135da565b60405180910390f35b3480156104db57600080fd5b506104f660048036036104f19190810190612c98565b611874565b604051610504929190613383565b60405180910390f35b34801561051957600080fd5b50610534600480360361052f9190810190612cc1565b6118ae565b005b34801561054257600080fd5b5061055d60048036036105589190810190612eb1565b6118dc565b005b34801561056b57600080fd5b5061058660048036036105819190810190613039565b6119d3565b60405161059391906135da565b60405180910390f35b3480156105a857600080fd5b506105c360048036036105be9190810190612cfd565b611a9a565b6040516105d091906132df565b60405180910390f35b60006359d1d43c7c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061064f575061064e82611ad6565b5b9050919050565b8261066081611b53565b151561066b57600080fd5b6000809050600080905060608060006106826128bc565b6106da60008a8a8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050611cf890919063ffffffff16565b90505b6106e681611d22565b15156108625760008661ffff161415610791578060400151955061070981611d38565b9350836040516020018082805190602001908083835b602083101515610744578051825260208201915060208101905060208303925061071f565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120915061078a81611d6f565b9250610854565b606061079c82611d38565b9050816040015161ffff168761ffff161415806107c957506107c78186611d9f90919063ffffffff16565b155b156108525761082b8b86898d8d8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508a8b88602001510360008b5114611dc6565b81604001519650816020015195508094508480519060200120925061084f82611d6f565b93505b505b61085d816120fa565b6106dd565b506000835111156108ca576108c98984878b8b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505088898e8e9050036000895114611dc6565b5b505050505050505050565b846108df81611b53565b15156108ea57600080fd5b828260096000898152602001908152602001600020878760405180838380828437808301925050509250505090815260200160405180910390209190610931929190612908565b507fd8c9334b1a9c2f9da342a0a2b32629c1a229b6445dad78947f674b44444a7550868686888860405161096995949392919061350f565b60405180910390a1505050505050565b600080600660008581526020019081526020016000206000847bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515610a405780915050610ed8565b6000610a4b85611141565b9050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610a8d57600092505050610ed8565b600060608273ffffffffffffffffffffffffffffffffffffffff166301ffc9a77c010000000000000000000000000000000000000000000000000000000002604051602401610adc91906135bf565b6040516020818303038152906040527f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040518082805190602001908083835b602083101515610b8e5780518252602082019150602081019050602083039250610b69565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114610bee576040519150601f19603f3d011682016040523d82523d6000602084013e610bf3565b606091505b5091509150811580610c06575060208151105b80610cae575060007f01000000000000000000000000000000000000000000000000000000000000000281601f815181101515610c3f57fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b15610cc0576000945050505050610ed8565b8273ffffffffffffffffffffffffffffffffffffffff1686604051602401610ce891906135bf565b6040516020818303038152906040527f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040518082805190602001908083835b602083101515610d9a5780518252602082019150602081019050602083039250610d75565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114610dfa576040519150601f19603f3d011682016040523d82523d6000602084013e610dff565b606091505b508092508193505050811580610e16575060208151105b80610ebe575060007f01000000000000000000000000000000000000000000000000000000000000000281601f815181101515610e4f57fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b15610ed0576000945050505050610ed8565b829450505050505b92915050565b60006060600080600086815260200190815260200160002090506000600190505b848111151561100f57600085821614158015610f4157506000826000838152602001908152602001600020805460018160011615610100020316600290049050115b156110005780826000838152602001908152602001600020808054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610fee5780601f10610fc357610100808354040283529160200191610fee565b820191906000526020600020905b815481529060010190602001808311610fd157829003601f168201915b5050505050905093509350505061102c565b6001819060020a029050610eff565b506000602060405190810160405280600081525081915092509250505b9250929050565b8261103d81611b53565b151561104857600080fd5b6040805190810160405280848152602001838152506008600086815260200190815260200160002060008201518160000155602082015181600101559050507f1d6f5e03d3f63eb58751986629a5439baee5079ff04f345becb66e23eb154e468484846040516110ba939291906133ac565b60405180910390a150505050565b826110d281611b53565b15156110dd57600080fd5b82826002600087815260200190815260200160002091906110ff929190612988565b507fe379c1624ed7e714cc0937528a32359d69d5281337765313dba4e081b72d75788484846040516111339392919061341a565b60405180910390a150505050565b6000606061115083603c6119d3565b9050600081511415611166576000915050611173565b61116f81612210565b9150505b919050565b80600b600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507fe1c5610a6e0cbe10764ecd182adcef1ec338dc4e199c99c32ce98f38e12791df83338484604051611252949392919061333e565b60405180910390a1505050565b60008060056000858152602001908152602001600020600060036000878152602001908152602001600020548152602001908152602001600020600084815260200190815260200160002060009054906101000a900461ffff1661ffff161415905092915050565b606060096000858152602001908152602001600020838360405180838380828437808301925050509250505090815260200160405180910390208054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156113955780601f1061136a57610100808354040283529160200191611395565b820191906000526020600020905b81548152906001019060200180831161137857829003601f168201915b505050505090509392505050565b836113ad81611b53565b15156113b857600080fd5b60008460018603161415156113cc57600080fd5b8282600080888152602001908152602001600020600087815260200190815260200160002091906113fe929190612988565b507faa121bbeef5f32f5961a2a28966e769023910fc9479059ee3495d4c1a696efe38585604051611430929190613558565b60405180910390a15050505050565b6060600760008381526020019081526020016000208054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156114e85780601f106114bd576101008083540402835291602001916114e8565b820191906000526020600020905b8154815290600101906020018083116114cb57829003601f168201915b50505050509050919050565b826114fe81611b53565b151561150957600080fd5b828260076000878152602001908152602001600020919061152b929190612908565b507fb7d29e911041e8d9b843369e890bcb72c9388692ba48b65ac54e7214c4c348f784848460405161155f939291906134dd565b60405180910390a150505050565b8261157781611b53565b151561158257600080fd5b7f65412581168e88a1e60c6459d7f44ae83ad0832e670826c05a4e2476b57af7528484846040516115b593929190613581565b60405180910390a1603c831415611608577f52d7d861f09ab3d26239d492e8968629f95e9e318cf0b73bfddc441522a15fd2846115f184612210565b6040516115ff929190613315565b60405180910390a15b816001600086815260200190815260200160002060008581526020019081526020016000209080519060200190611640929190612a08565b5050505050565b606060046000858152602001908152602001600020600060036000878152602001908152602001600020548152602001908152602001600020600084815260200190815260200160002060008361ffff1661ffff1681526020019081526020016000208054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561173e5780601f106117135761010080835404028352916020019161173e565b820191906000526020600020905b81548152906001019060200180831161172157829003601f168201915b505050505090509392505050565b8061175681611b53565b151561176157600080fd5b60036000838152602001908152602001600020600081548092919060010191905055507fb757169b8492ca2f1c6619d9d76ce22803035c3b1d5f6930dffe7b127c1a1983826040516117b391906132fa565b60405180910390a15050565b6060600260008381526020019081526020016000208054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156118685780601f1061183d57610100808354040283529160200191611868565b820191906000526020600020905b81548152906001019060200180831161184b57829003601f168201915b50505050509050919050565b6000806008600084815260200190815260200160002060000154600860008581526020019081526020016000206001015491509150915091565b816118b881611b53565b15156118c357600080fd5b6118d783603c6118d285612235565b61156d565b505050565b826118e681611b53565b15156118f157600080fd5b81600660008681526020019081526020016000206000857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f7c69f06bea0bdef565b709e93a147836b0063ba2dd89f02d0b7e8d931e6a6daa8484846040516119c5939291906133e3565b60405180910390a150505050565b60606001600084815260200190815260200160002060008381526020019081526020016000208054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611a8d5780601f10611a6257610100808354040283529160200191611a8d565b820191906000526020600020905b815481529060010190602001808311611a7057829003601f168201915b5050505050905092915050565b600b602052826000526040600020602052816000526040600020602052806000526040600020600092509250509054906101000a900460ff1681565b600063c86902337c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611b4c5750611b4b82612280565b5b9050919050565b600080600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166302571be3846040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401611bcd91906132fa565b60206040518083038186803b158015611be557600080fd5b505afa158015611bf9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611c1d9190810190612c6f565b90503373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161480611cf05750600b600084815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b915050919050565b611d006128bc565b828160000181905250818160c0018181525050611d1c816120fa565b92915050565b6000816000015151826020015110159050919050565b6060611d688260200151611d54846000015185602001516122fd565b846000015161235a9092919063ffffffff16565b9050919050565b6060611d988260a001518360a001518460c0015103846000015161235a9092919063ffffffff16565b9050919050565b600081518351148015611dbe5750611dbd83600084600087516123cf565b5b905092915050565b6000600360008981526020019081526020016000205490506000878051906020012090506060611e0186868961235a9092919063ffffffff16565b90508315611f79576000600460008c81526020019081526020016000206000858152602001908152602001600020600084815260200190815260200160002060008a61ffff1661ffff168152602001908152602001600020805460018160011615610100020316600290049050141515611edf57600560008b815260200190815260200160002060008481526020019081526020016000206000838152602001908152602001600020600081819054906101000a900461ffff16809291906001900391906101000a81548161ffff021916908361ffff160217905550505b600460008b81526020019081526020016000206000848152602001908152602001600020600083815260200190815260200160002060008961ffff1661ffff1681526020019081526020016000206000611f399190612a88565b7f03528ed0c2a3ebc993b12ce3c16bb382f9c7d88ef7d8a1bf290eaf35955a12078a8a8a604051611f6c9392919061344c565b60405180910390a16120ee565b6000600460008c81526020019081526020016000206000858152602001908152602001600020600084815260200190815260200160002060008a61ffff1661ffff168152602001908152602001600020805460018160011615610100020316600290049050141561204d57600560008b815260200190815260200160002060008481526020019081526020016000206000838152602001908152602001600020600081819054906101000a900461ffff168092919060010191906101000a81548161ffff021916908361ffff160217905550505b80600460008c81526020019081526020016000206000858152602001908152602001600020600084815260200190815260200160002060008a61ffff1661ffff16815260200190815260200160002090805190602001906120af929190612a08565b507f52a608b3303a48862d07a73d82fa221318c0027fbbcfb1b2329bface3f19ff2b8a8a8a846040516120e5949392919061348a565b60405180910390a15b50505050505050505050565b8060c00151816020018181525050806000015151816020015110151561211f5761220d565b6000612133826000015183602001516122fd565b82602001510190506121528183600001516123f390919063ffffffff16565b826040019061ffff16908161ffff16815250506002810190506121828183600001516123f390919063ffffffff16565b826060019061ffff16908161ffff16815250506002810190506121b281836000015161241b90919063ffffffff16565b826080019063ffffffff16908163ffffffff168152505060048101905060006121e88284600001516123f390919063ffffffff16565b61ffff169050600282019150818360a00181815250508082018360c001818152505050505b50565b60006014825114151561222257600080fd5b600c6101000a6020830151049050919050565b606060146040519080825280601f01601f19166020018201604052801561226b5781602001600182028038833980820191505090505b509050600c6101000a82026020820152919050565b600063691f34317c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806122f657506122f582612445565b5b9050919050565b6000808290505b60011561234e5783518110151561231757fe5b600061232c82866124fa90919063ffffffff16565b60ff16905060018101820191506000811415612348575061234e565b50612304565b82810391505092915050565b606083518284011115151561236e57600080fd5b6060826040519080825280601f01601f1916602001820160405280156123a35781602001600182028038833980820191505090505b50905060008060208301915085602088010190506123c2828287612580565b8293505050509392505050565b60006123dc8484846125cb565b6123e78787856125cb565b14905095945050505050565b60008251600283011115151561240857600080fd5b61ffff8260028501015116905092915050565b60008251600483011115151561243057600080fd5b63ffffffff8260048501015116905092915050565b600060405180807f696e74657266616365496d706c656d656e74657228627974657333322c62797481526020017f6573342900000000000000000000000000000000000000000000000000000000815250602401905060405180910390207bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806124f357506124f2826125f0565b5b9050919050565b6000828281518110151561250a57fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027f01000000000000000000000000000000000000000000000000000000000000009004905092915050565b5b6020811015156125a65781518352602083019250602082019150602081039050612581565b60006001826020036101000a0390508019835116818551168181178652505050505050565b60008351828401111515156125df57600080fd5b818360208601012090509392505050565b600063a8fa56827c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061266657506126658261266d565b5b9050919050565b600063bc1c58d17c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806126e357506126e2826126ea565b5b9050919050565b6000633b3b57de7c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806127bb575063f1cb7e067c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806127cb57506127ca826127d2565b5b9050919050565b6000632203ab567c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061284857506128478261284f565b5b9050919050565b60006301ffc9a77c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60e0604051908101604052806060815260200160008152602001600061ffff168152602001600061ffff168152602001600063ffffffff16815260200160008152602001600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061294957803560ff1916838001178555612977565b82800160010185558215612977579182015b8281111561297657823582559160200191906001019061295b565b5b5090506129849190612ad0565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106129c957803560ff19168380011785556129f7565b828001600101855582156129f7579182015b828111156129f65782358255916020019190600101906129db565b5b509050612a049190612ad0565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10612a4957805160ff1916838001178555612a77565b82800160010185558215612a77579182015b82811115612a76578251825591602001919060010190612a5b565b5b509050612a849190612ad0565b5090565b50805460018160011615610100020316600290046000825580601f10612aae5750612acd565b601f016020900490600052602060002090810190612acc9190612ad0565b5b50565b612af291905b80821115612aee576000816000905550600101612ad6565b5090565b90565b6000612b01823561375b565b905092915050565b6000612b15825161375b565b905092915050565b6000612b29823561376d565b905092915050565b6000612b3d8235613779565b905092915050565b6000612b518235613783565b905092915050565b60008083601f8401121515612b6d57600080fd5b8235905067ffffffffffffffff811115612b8657600080fd5b602083019150836001820283011115612b9e57600080fd5b9250929050565b600082601f8301121515612bb857600080fd5b8135612bcb612bc68261367b565b61364e565b91508082526020830160208301858383011115612be757600080fd5b612bf28382846137fd565b50505092915050565b60008083601f8401121515612c0f57600080fd5b8235905067ffffffffffffffff811115612c2857600080fd5b602083019150836001820283011115612c4057600080fd5b9250929050565b6000612c5382356137af565b905092915050565b6000612c6782356137bd565b905092915050565b600060208284031215612c8157600080fd5b6000612c8f84828501612b09565b91505092915050565b600060208284031215612caa57600080fd5b6000612cb884828501612b31565b91505092915050565b60008060408385031215612cd457600080fd5b6000612ce285828601612b31565b9250506020612cf385828601612af5565b9150509250929050565b600080600060608486031215612d1257600080fd5b6000612d2086828701612b31565b9350506020612d3186828701612af5565b9250506040612d4286828701612af5565b9150509250925092565b600080600060608486031215612d6157600080fd5b6000612d6f86828701612b31565b9350506020612d8086828701612af5565b9250506040612d9186828701612b1d565b9150509250925092565b60008060408385031215612dae57600080fd5b6000612dbc85828601612b31565b9250506020612dcd85828601612b31565b9150509250929050565b600080600060608486031215612dec57600080fd5b6000612dfa86828701612b31565b9350506020612e0b86828701612b31565b9250506040612e1c86828701612b31565b9150509250925092565b600080600060608486031215612e3b57600080fd5b6000612e4986828701612b31565b9350506020612e5a86828701612b31565b9250506040612e6b86828701612c47565b9150509250925092565b60008060408385031215612e8857600080fd5b6000612e9685828601612b31565b9250506020612ea785828601612b45565b9150509250929050565b600080600060608486031215612ec657600080fd5b6000612ed486828701612b31565b9350506020612ee586828701612b45565b9250506040612ef686828701612af5565b9150509250925092565b600080600060408486031215612f1557600080fd5b6000612f2386828701612b31565b935050602084013567ffffffffffffffff811115612f4057600080fd5b612f4c86828701612b59565b92509250509250925092565b600080600060408486031215612f6d57600080fd5b6000612f7b86828701612b31565b935050602084013567ffffffffffffffff811115612f9857600080fd5b612fa486828701612bfb565b92509250509250925092565b600080600080600060608688031215612fc857600080fd5b6000612fd688828901612b31565b955050602086013567ffffffffffffffff811115612ff357600080fd5b612fff88828901612bfb565b9450945050604086013567ffffffffffffffff81111561301e57600080fd5b61302a88828901612bfb565b92509250509295509295909350565b6000806040838503121561304c57600080fd5b600061305a85828601612b31565b925050602061306b85828601612c5b565b9150509250929050565b6000806000806060858703121561308b57600080fd5b600061309987828801612b31565b94505060206130aa87828801612c5b565b935050604085013567ffffffffffffffff8111156130c757600080fd5b6130d387828801612b59565b925092505092959194509250565b6000806000606084860312156130f657600080fd5b600061310486828701612b31565b935050602061311586828701612c5b565b925050604084013567ffffffffffffffff81111561313257600080fd5b61313e86828701612ba5565b9150509250925092565b60006020828403121561315a57600080fd5b600061316884828501612b45565b91505092915050565b61317a816137c7565b82525050565b613189816136cf565b82525050565b613198816136bd565b82525050565b6131a7816136e1565b82525050565b6131b6816136ed565b82525050565b6131c5816136f7565b82525050565b60008284526020840193506131e18385846137fd565b6131ea8361383f565b840190509392505050565b6000613200826136a7565b80845261321481602086016020860161380c565b61321d8161383f565b602085010191505092915050565b60008284526020840193506132418385846137fd565b61324a8361383f565b840190509392505050565b6000613260826136b2565b80845261327481602086016020860161380c565b61327d8161383f565b602085010191505092915050565b61329481613723565b82525050565b6132a381613751565b82525050565b60006020820190506132be600083018461318f565b92915050565b60006020820190506132d96000830184613180565b92915050565b60006020820190506132f4600083018461319e565b92915050565b600060208201905061330f60008301846131ad565b92915050565b600060408201905061332a60008301856131ad565b6133376020830184613171565b9392505050565b600060808201905061335360008301876131ad565b6133606020830186613171565b61336d604083018561318f565b61337a606083018461319e565b95945050505050565b600060408201905061339860008301856131ad565b6133a560208301846131ad565b9392505050565b60006060820190506133c160008301866131ad565b6133ce60208301856131ad565b6133db60408301846131ad565b949350505050565b60006060820190506133f860008301866131ad565b61340560208301856131bc565b613412604083018461318f565b949350505050565b600060408201905061342f60008301866131ad565b81810360208301526134428184866131cb565b9050949350505050565b600060608201905061346160008301866131ad565b818103602083015261347381856131f5565b9050613482604083018461328b565b949350505050565b600060808201905061349f60008301876131ad565b81810360208301526134b181866131f5565b90506134c0604083018561328b565b81810360608301526134d281846131f5565b905095945050505050565b60006040820190506134f260008301866131ad565b818103602083015261350581848661322b565b9050949350505050565b600060608201905061352460008301886131ad565b818103602083015261353781868861322b565b9050818103604083015261354c81848661322b565b90509695505050505050565b600060408201905061356d60008301856131ad565b61357a602083018461329a565b9392505050565b600060608201905061359660008301866131ad565b6135a3602083018561329a565b81810360408301526135b581846131f5565b9050949350505050565b60006020820190506135d460008301846131bc565b92915050565b600060208201905081810360008301526135f481846131f5565b905092915050565b600060208201905081810360008301526136168184613255565b905092915050565b6000604082019050613633600083018561329a565b818103602083015261364581846131f5565b90509392505050565b6000604051905081810181811067ffffffffffffffff8211171561367157600080fd5b8060405250919050565b600067ffffffffffffffff82111561369257600080fd5b601f19601f8301169050602081019050919050565b600081519050919050565b600081519050919050565b60006136c882613731565b9050919050565b60006136da82613731565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600061ffff82169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600061376682613731565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600061ffff82169050919050565b6000819050919050565b60006137d2826137d9565b9050919050565b60006137e4826137eb565b9050919050565b60006137f682613731565b9050919050565b82818337600083830152505050565b60005b8381101561382a57808201518184015260208101905061380f565b83811115613839576000848401525b50505050565b6000601f19601f830116905091905056fea265627a7a72305820668668127482cd23a9f375761bf0b8d29fdbff7c261f4d2755ca9c73637d86bf6c6578706572696d656e74616cf50037' reverse_registrar_abi = json.loads('[{"constant":false,"inputs":[{"name":"owner","type":"address"},{"name":"resolver","type":"address"}],"name":"claimWithResolver","outputs":[{"name":"node","type":"bytes32"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"owner","type":"address"}],"name":"claim","outputs":[{"name":"node","type":"bytes32"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"ens","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"defaultResolver","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"addr","type":"address"}],"name":"node","outputs":[{"name":"ret","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"name","type":"string"}],"name":"setName","outputs":[{"name":"node","type":"bytes32"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"ensAddr","type":"address"},{"name":"resolverAddr","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]') reverse_registrar_bytecode = "6060604052341561000f57600080fd5b604051604080610d96833981016040528080519060200190919080519060200190919050506000826000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166302571be37f91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e26001026000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808260001916600019168152602001915050602060405180830381600087803b151561017a57600080fd5b6102c65a03f1151561018b57600080fd5b50505060405180519050905060008173ffffffffffffffffffffffffffffffffffffffff16141515610277578073ffffffffffffffffffffffffffffffffffffffff16631e83409a336000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b151561025a57600080fd5b6102c65a03f1151561026b57600080fd5b50505060405180519050505b505050610b0d806102896000396000f300606060405260043610610078576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630f5a54661461007d5780631e83409a146100f15780633f15457f14610146578063828eab0e1461019b578063bffbe61c146101f0578063c47f002714610245575b600080fd5b341561008857600080fd5b6100d3600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506102be565b60405180826000191660001916815260200191505060405180910390f35b34156100fc57600080fd5b610128600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061086e565b60405180826000191660001916815260200191505060405180910390f35b341561015157600080fd5b610159610882565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156101a657600080fd5b6101ae6108a7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156101fb57600080fd5b610227600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506108cd565b60405180826000191660001916815260200191505060405180910390f35b341561025057600080fd5b6102a0600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190505061092f565b60405180826000191660001916815260200191505060405180910390f35b60008060006102cc33610a80565b91507f91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e260010282604051808360001916600019168152602001826000191660001916815260200192505050604051809103902092506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166302571be3846000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808260001916600019168152602001915050602060405180830381600087803b15156103c157600080fd5b6102c65a03f115156103d257600080fd5b50505060405180519050905060008473ffffffffffffffffffffffffffffffffffffffff16141580156104eb57506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630178b8bf846000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808260001916600019168152602001915050602060405180830381600087803b15156104a057600080fd5b6102c65a03f115156104b157600080fd5b5050506040518051905073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b1561071b573073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151561063b576000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166306ab59237f91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e260010284306040518463ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180846000191660001916815260200183600019166000191681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019350505050600060405180830381600087803b151561062357600080fd5b6102c65a03f1151561063457600080fd5b5050503090505b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16631896f70a84866040518363ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018083600019166000191681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200192505050600060405180830381600087803b151561070657600080fd5b6102c65a03f1151561071757600080fd5b5050505b8473ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515610863576000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166306ab59237f91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e260010284886040518463ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180846000191660001916815260200183600019166000191681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019350505050600060405180830381600087803b151561084e57600080fd5b6102c65a03f1151561085f57600080fd5b5050505b829250505092915050565b600061087b8260006102be565b9050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60007f91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e26001026108fc83610a80565b60405180836000191660001916815260200182600019166000191681526020019250505060405180910390209050919050565b600061095d30600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166102be565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16637737221382846040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180836000191660001916815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610a185780820151818401526020810190506109fd565b50505050905090810190601f168015610a455780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b1515610a6457600080fd5b6102c65a03f11515610a7557600080fd5b505050809050919050565b60007f303132333435363738396162636465660000000000000000000000000000000060285b60018103905081600f85161a815360108404935060018103905081600f85161a815360108404935080610aa6576028600020925050509190505600a165627a7a72305820a8513240f040cd9ded89ca4d0c5bda58536850e642e1d933ad64158ef4c820660029" reverse_registrar_bytecode_runtime = "606060405260043610610078576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630f5a54661461007d5780631e83409a146100f15780633f15457f14610146578063828eab0e1461019b578063bffbe61c146101f0578063c47f002714610245575b600080fd5b341561008857600080fd5b6100d3600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506102be565b60405180826000191660001916815260200191505060405180910390f35b34156100fc57600080fd5b610128600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061086e565b60405180826000191660001916815260200191505060405180910390f35b341561015157600080fd5b610159610882565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156101a657600080fd5b6101ae6108a7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156101fb57600080fd5b610227600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506108cd565b60405180826000191660001916815260200191505060405180910390f35b341561025057600080fd5b6102a0600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190505061092f565b60405180826000191660001916815260200191505060405180910390f35b60008060006102cc33610a80565b91507f91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e260010282604051808360001916600019168152602001826000191660001916815260200192505050604051809103902092506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166302571be3846000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808260001916600019168152602001915050602060405180830381600087803b15156103c157600080fd5b6102c65a03f115156103d257600080fd5b50505060405180519050905060008473ffffffffffffffffffffffffffffffffffffffff16141580156104eb57506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630178b8bf846000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808260001916600019168152602001915050602060405180830381600087803b15156104a057600080fd5b6102c65a03f115156104b157600080fd5b5050506040518051905073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b1561071b573073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151561063b576000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166306ab59237f91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e260010284306040518463ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180846000191660001916815260200183600019166000191681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019350505050600060405180830381600087803b151561062357600080fd5b6102c65a03f1151561063457600080fd5b5050503090505b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16631896f70a84866040518363ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018083600019166000191681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200192505050600060405180830381600087803b151561070657600080fd5b6102c65a03f1151561071757600080fd5b5050505b8473ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515610863576000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166306ab59237f91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e260010284886040518463ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180846000191660001916815260200183600019166000191681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019350505050600060405180830381600087803b151561084e57600080fd5b6102c65a03f1151561085f57600080fd5b5050505b829250505092915050565b600061087b8260006102be565b9050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60007f91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e26001026108fc83610a80565b60405180836000191660001916815260200182600019166000191681526020019250505060405180910390209050919050565b600061095d30600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166102be565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16637737221382846040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180836000191660001916815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610a185780820151818401526020810190506109fd565b50505050905090810190601f168015610a455780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b1515610a6457600080fd5b6102c65a03f11515610a7557600080fd5b505050809050919050565b60007f303132333435363738396162636465660000000000000000000000000000000060285b60018103905081600f85161a815360108404935060018103905081600f85161a815360108404935080610aa6576028600020925050509190505600a165627a7a72305820a8513240f040cd9ded89ca4d0c5bda58536850e642e1d933ad64158ef4c820660029" -reverse_resolver_abi = json.loads('[{"constant":true,"inputs":[],"name":"ens","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"_name","type":"string"}],"name":"setName","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"ensAddr","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]') -reverse_resolver_bytecode = "6060604052341561000f57600080fd5b6040516020806106c9833981016040528080519060200190919050506000816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166302571be37f91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e26001026000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808260001916600019168152602001915050602060405180830381600087803b151561013057600080fd5b6102c65a03f1151561014157600080fd5b50505060405180519050905060008173ffffffffffffffffffffffffffffffffffffffff1614151561022d578073ffffffffffffffffffffffffffffffffffffffff16631e83409a336000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b151561021057600080fd5b6102c65a03f1151561022157600080fd5b50505060405180519050505b505061048b8061023e6000396000f300606060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633f15457f1461005c578063691f3431146100b15780637737221314610151575b600080fd5b341561006757600080fd5b61006f6101bb565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156100bc57600080fd5b6100d66004808035600019169060200190919050506101e0565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101165780820151818401526020810190506100fb565b50505050905090810190601f1680156101435780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561015c57600080fd5b6101b960048080356000191690602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610290565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60016020528060005260406000206000915090508054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102885780601f1061025d57610100808354040283529160200191610288565b820191906000526020600020905b81548152906001019060200180831161026b57829003601f168201915b505050505081565b816000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166302571be3826000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808260001916600019168152602001915050602060405180830381600087803b151561033157600080fd5b6102c65a03f1151561034257600080fd5b5050506040518051905073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561038557600080fd5b8160016000856000191660001916815260200190815260200160002090805190602001906103b49291906103ba565b50505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106103fb57805160ff1916838001178555610429565b82800160010185558215610429579182015b8281111561042857825182559160200191906001019061040d565b5b509050610436919061043a565b5090565b61045c91905b80821115610458576000816000905550600101610440565b5090565b905600a165627a7a72305820f4c4cb4d191f31a62c4de12f7aecf9b258ba17f3a6ee294191171f7d30c04ab00029" -reverse_resolver_bytecode_runtime = "606060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633f15457f1461005c578063691f3431146100b15780637737221314610151575b600080fd5b341561006757600080fd5b61006f6101bb565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156100bc57600080fd5b6100d66004808035600019169060200190919050506101e0565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101165780820151818401526020810190506100fb565b50505050905090810190601f1680156101435780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561015c57600080fd5b6101b960048080356000191690602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610290565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60016020528060005260406000206000915090508054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102885780601f1061025d57610100808354040283529160200191610288565b820191906000526020600020905b81548152906001019060200180831161026b57829003601f168201915b505050505081565b816000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166302571be3826000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808260001916600019168152602001915050602060405180830381600087803b151561033157600080fd5b6102c65a03f1151561034257600080fd5b5050506040518051905073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561038557600080fd5b8160016000856000191660001916815260200190815260200160002090805190602001906103b49291906103ba565b50505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106103fb57805160ff1916838001178555610429565b82800160010185558215610429579182015b8281111561042857825182559160200191906001019061040d565b5b509050610436919061043a565b5090565b61045c91905b80821115610458576000816000905550600101610440565b5090565b905600a165627a7a72305820f4c4cb4d191f31a62c4de12f7aecf9b258ba17f3a6ee294191171f7d30c04ab00029" +# ENS Default Reverse Resolver +reverse_resolver_abi = json.loads('[{"inputs":[{"internalType":"contract ENS","name":"ensAddr","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"constant":true,"inputs":[],"name":"ens","outputs":[{"internalType":"contract ENS","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"string","name":"_name","type":"string"}],"name":"setName","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]') +reverse_resolver_bytecode = '608060405234801561001057600080fd5b5060405160208061079f8339810180604052602081101561003057600080fd5b8101908080519060200190929190505050806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166302571be37f91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e26001026040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018082815260200191505060206040518083038186803b15801561013457600080fd5b505afa158015610148573d6000803e3d6000fd5b505050506040513d602081101561015e57600080fd5b81019080805190602001909291905050509050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151561027f578073ffffffffffffffffffffffffffffffffffffffff16631e83409a336040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15801561024257600080fd5b505af1158015610256573d6000803e3d6000fd5b505050506040513d602081101561026c57600080fd5b8101908080519060200190929190505050505b505061050f806102906000396000f3fe608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633f15457f1461005c578063691f3431146100b35780637737221314610167575b600080fd5b34801561006857600080fd5b50610071610239565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156100bf57600080fd5b506100ec600480360360208110156100d657600080fd5b810190808035906020019092919050505061025e565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012c578082015181840152602081019050610111565b50505050905090810190601f1680156101595780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017357600080fd5b506102376004803603604081101561018a57600080fd5b8101908080359060200190929190803590602001906401000000008111156101b157600080fd5b8201836020820111156101c357600080fd5b803590602001918460018302840111640100000000831117156101e557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061030e565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60016020528060005260406000206000915090508054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103065780601f106102db57610100808354040283529160200191610306565b820191906000526020600020905b8154815290600101906020018083116102e957829003601f168201915b505050505081565b816000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166302571be3826040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018082815260200191505060206040518083038186803b15801561039d57600080fd5b505afa1580156103b1573d6000803e3d6000fd5b505050506040513d60208110156103c757600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561041157600080fd5b8160016000858152602001908152602001600020908051906020019061043892919061043e565b50505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061047f57805160ff19168380011785556104ad565b828001600101855582156104ad579182015b828111156104ac578251825591602001919060010190610491565b5b5090506104ba91906104be565b5090565b6104e091905b808211156104dc5760008160009055506001016104c4565b5090565b9056fea165627a7a72305820f326fd97e1fac0bcd89f007846301e41c2ad494c12d70b2b50dd61e62ffc906a0029' +reverse_resolver_bytecode_runtime = '608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633f15457f1461005c578063691f3431146100b35780637737221314610167575b600080fd5b34801561006857600080fd5b50610071610239565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156100bf57600080fd5b506100ec600480360360208110156100d657600080fd5b810190808035906020019092919050505061025e565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012c578082015181840152602081019050610111565b50505050905090810190601f1680156101595780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017357600080fd5b506102376004803603604081101561018a57600080fd5b8101908080359060200190929190803590602001906401000000008111156101b157600080fd5b8201836020820111156101c357600080fd5b803590602001918460018302840111640100000000831117156101e557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061030e565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60016020528060005260406000206000915090508054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103065780601f106102db57610100808354040283529160200191610306565b820191906000526020600020905b8154815290600101906020018083116102e957829003601f168201915b505050505081565b816000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166302571be3826040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018082815260200191505060206040518083038186803b15801561039d57600080fd5b505afa1580156103b1573d6000803e3d6000fd5b505050506040513d60208110156103c757600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561041157600080fd5b8160016000858152602001908152602001600020908051906020019061043892919061043e565b50505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061047f57805160ff19168380011785556104ad565b828001600101855582156104ad579182015b828111156104ac578251825591602001919060010190610491565b5b5090506104ba91906104be565b5090565b6104e091905b808211156104dc5760008160009055506001016104c4565b5090565b9056fea165627a7a72305820f326fd97e1fac0bcd89f007846301e41c2ad494c12d70b2b50dd61e62ffc906a0029' + + +# --- simple resolver --- # +''' +pragma solidity ^0.8.11; + +contract SimpleResolver { + // deployed on ropsten at address = 0xD4D522c96111679bF86220deFE75e0aA1df890b4 + + function supportsInterface(bytes4 interfaceID) public returns (bool) { + return interfaceID == 0x3b3b57de; + } + + function addr(bytes32 nodeID) public returns (address) { + return address(this); + } +} +''' +simple_resolver_abi = json.loads('[{"inputs":[{"internalType":"bytes32","name":"nodeID","type":"bytes32"}],"name":"addr","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceID","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]') +simple_resolver_bytecode = '608060405234801561001057600080fd5b5061028c806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806301ffc9a71461003b5780633b3b57de1461006b575b600080fd5b61005560048036038101906100509190610134565b61009b565b604051610062919061017c565b60405180910390f35b610085600480360381019061008091906101cd565b6100cd565b604051610092919061023b565b60405180910390f35b6000633b3b57de60e01b827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6000309050919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610111816100dc565b811461011c57600080fd5b50565b60008135905061012e81610108565b92915050565b60006020828403121561014a576101496100d7565b5b60006101588482850161011f565b91505092915050565b60008115159050919050565b61017681610161565b82525050565b6000602082019050610191600083018461016d565b92915050565b6000819050919050565b6101aa81610197565b81146101b557600080fd5b50565b6000813590506101c7816101a1565b92915050565b6000602082840312156101e3576101e26100d7565b5b60006101f1848285016101b8565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610225826101fa565b9050919050565b6102358161021a565b82525050565b6000602082019050610250600083018461022c565b9291505056fea264697066735822122090fd4775d8c721c381bd14218694b81067bc90d79ff9e6d4dcad53f0c1a461e164736f6c634300080d0033' +simple_resolver_bytecode_runtime = '608060405234801561001057600080fd5b50600436106100365760003560e01c806301ffc9a71461003b5780633b3b57de1461006b575b600080fd5b61005560048036038101906100509190610134565b61009b565b604051610062919061017c565b60405180910390f35b610085600480360381019061008091906101cd565b6100cd565b604051610092919061023b565b60405180910390f35b6000633b3b57de60e01b827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6000309050919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610111816100dc565b811461011c57600080fd5b50565b60008135905061012e81610108565b92915050565b60006020828403121561014a576101496100d7565b5b60006101588482850161011f565b91505092915050565b60008115159050919050565b61017681610161565b82525050565b6000602082019050610191600083018461016d565b92915050565b6000819050919050565b6101aa81610197565b81146101b557600080fd5b50565b6000813590506101c7816101a1565b92915050565b6000602082840312156101e3576101e26100d7565b5b60006101f1848285016101b8565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610225826101fa565b9050919050565b6102358161021a565b82525050565b6000602082019050610250600083018461022c565b9291505056fea264697066735822122090fd4775d8c721c381bd14218694b81067bc90d79ff9e6d4dcad53f0c1a461e164736f6c634300080d0033' diff --git a/ens/exceptions.py b/ens/exceptions.py index 4048c5d2f2..3e254cffde 100644 --- a/ens/exceptions.py +++ b/ens/exceptions.py @@ -40,6 +40,20 @@ class UnownedName(Exception): pass +class ResolverNotFound(Exception): + """ + Raised if no resolver was found for the name you are trying to resolve. + """ + pass + + +class UnsupportedFunction(Exception): + """ + Raised if a resolver does not support a particular method. + """ + pass + + class BidTooLow(ValueError): """ Raised if you bid less than the minimum amount diff --git a/ens/main.py b/ens/main.py index 465f640af6..6f4d702516 100644 --- a/ens/main.py +++ b/ens/main.py @@ -6,6 +6,7 @@ ) from typing import ( TYPE_CHECKING, + Any, Optional, Sequence, Tuple, @@ -17,8 +18,10 @@ Address, ChecksumAddress, HexAddress, + HexStr, ) from eth_utils import ( + is_address, is_binary_address, is_checksum_address, to_checksum_address, @@ -34,18 +37,25 @@ from ens.constants import ( EMPTY_ADDR_HEX, ENS_MAINNET_ADDR, + EXTENDED_RESOLVER_INTERFACE_ID, + GET_TEXT_INTERFACE_ID, REVERSE_REGISTRAR_DOMAIN, ) from ens.exceptions import ( AddressMismatch, + ResolverNotFound, UnauthorizedError, UnownedName, + UnsupportedFunction, ) from ens.utils import ( address_in, address_to_reverse_domain, default, + ens_encode_name, + get_abi_output_types, init_web3, + is_empty_name, is_none_or_zero_address, is_valid_name, label_to_hash, @@ -119,7 +129,8 @@ def __init__( ens_addr = addr if addr else ENS_MAINNET_ADDR self.ens = self.w3.eth.contract(abi=abis.ENS, address=ens_addr) - self._resolverContract = self.w3.eth.contract(abi=abis.RESOLVER) + self._resolver_contract = self.w3.eth.contract(abi=abis.RESOLVER) + self._reverse_resolver_contract = self.w3.eth.contract(abi=abis.REVERSE_RESOLVER) @classmethod def fromWeb3(cls, w3: 'Web3', addr: ChecksumAddress = None) -> 'ENS': @@ -152,18 +163,40 @@ def name(self, address: ChecksumAddress) -> Optional[str]: :type address: hex-string """ reversed_domain = address_to_reverse_domain(address) - name = self.resolve(reversed_domain, get='name') + name = self.resolve(reversed_domain, fn_name='name') # To be absolutely certain of the name, via reverse resolution, the address must match in # the forward resolution return name if to_checksum_address(address) == self.address(name) else None + @staticmethod + def parent(name: str) -> str: + """ + Part of ENSIP-10. Returns the parent of a given ENS name, or the empty string if the ENS + name does not have a parent. + + e.g. + - parent('1.foo.bar.eth') = 'foo.bar.eth' + - parent('foo.bar.eth') = 'bar.eth' + - parent('foo.eth') = 'eth' + - parent('eth') is defined as the empty string '' + + :param name: an ENS name + :return: the parent for the provided ENS name + :rtype: str + """ + if not name: + return '' + + labels = name.split('.') + return '' if len(labels) == 1 else '.'.join(labels[1:]) + def setup_address( self, name: str, address: Union[Address, ChecksumAddress, HexAddress] = cast(ChecksumAddress, default), transact: Optional["TxParams"] = None - ) -> HexBytes: + ) -> Optional[HexBytes]: """ Set up the name to point to the supplied address. The sender of the transaction must own the name, or @@ -252,24 +285,38 @@ def setup_name( self.setup_address(name, address, transact=transact) return self._setup_reverse(name, address, transact=transact) - def resolve(self, name: str, get: str = 'addr') -> Optional[Union[ChecksumAddress, str]]: + def resolver(self, normal_name: str) -> Optional['Contract']: + return self._get_resolver(normal_name)[0] + + def resolve(self, name: str, fn_name: str = 'addr') -> Optional[Union[ChecksumAddress, str]]: normal_name = normalize_name(name) - resolver = self.resolver(normal_name) - if resolver: - lookup_function = getattr(resolver.functions, get) - namehash = normal_name_to_hash(normal_name) - address = lookup_function(namehash).call() - if is_none_or_zero_address(address): - return None - return address - else: - return None - def resolver(self, normal_name: str) -> Optional['Contract']: - resolver_addr = self.ens.caller.resolver(normal_name_to_hash(normal_name)) - if is_none_or_zero_address(resolver_addr): + resolver, current_name = self._get_resolver(normal_name, fn_name) + if not resolver: return None - return self._resolverContract(address=resolver_addr) + + node = self.namehash(normal_name) + + if _resolver_supports_interface(resolver, EXTENDED_RESOLVER_INTERFACE_ID): + # update the resolver abi to the extended resolver abi + extended_resolver = self.w3.eth.contract(abi=abis.EXTENDED_RESOLVER)(resolver.address) + contract_func_with_args = (fn_name, [node]) + + calldata = extended_resolver.encodeABI(*contract_func_with_args) + contract_call_result = extended_resolver.caller.resolve( + ens_encode_name(normal_name), calldata + ) + result = self._decode_ensip10_resolve_data( + contract_call_result, extended_resolver, fn_name + ) + return to_checksum_address(result) if is_address(result) else result + elif normal_name == current_name: + lookup_function = getattr(resolver.functions, fn_name) + result = lookup_function(node).call() + if is_none_or_zero_address(result): + return None + return to_checksum_address(result) if is_address(result) else result + return None def reverser(self, target_address: ChecksumAddress) -> Optional['Contract']: reversed_domain = address_to_reverse_domain(target_address) @@ -295,25 +342,34 @@ def get_text(self, name: str, key: str) -> str: :param str name: ENS name to look up :param str key: ENS name's text record key - :return: ENS name's text record value + :return: ENS name's text record value :rtype: str - :raises UnownedName: if no one owns `name` + :raises UnsupportedFunction: If the resolver does not support the "0x59d1d43c" interface id + :raises ResolverNotFound: If no resolver is found for the provided name """ node = raw_name_to_hash(name) normal_name = normalize_name(name) r = self.resolver(normal_name) if r: - return r.caller.text(node, key) + if _resolver_supports_interface(r, GET_TEXT_INTERFACE_ID): + return r.caller.text(node, key) + else: + raise UnsupportedFunction( + f"Resolver for name {name} does not support `text` function." + ) else: - raise UnownedName("claim domain using setup_address() first") + raise ResolverNotFound( + f"No resolver found for name `{name}`. It is likely the name contains an " + "unsupported top level domain (tld)." + ) def set_text( self, name: str, key: str, value: str, - transact: "TxParams" = {} + transact: "TxParams" = None ) -> HexBytes: """ Set the value of a text record of an ENS name. @@ -321,12 +377,16 @@ def set_text( :param str name: ENS name :param str key: Name of the attribute to set :param str value: Value to set the attribute to - :param dict transact: the transaction configuration, like in + :param dict transact: The transaction configuration, like in :meth:`~web3.eth.Eth.send_transaction` :return: Transaction hash :rtype: HexBytes - :raises UnownedName: if no one owns `name` + :raises UnsupportedFunction: If the resolver does not support the "0x59d1d43c" interface id + :raises ResolverNotFound: If no resolver is found for the provided name """ + if not transact: + transact = {} + owner = self.owner(name) node = raw_name_to_hash(name) normal_name = normalize_name(name) @@ -335,16 +395,24 @@ def set_text( r = self.resolver(normal_name) if r: - return r.functions.setText(node, key, value).transact(transaction_dict) + if _resolver_supports_interface(r, GET_TEXT_INTERFACE_ID): + return r.functions.setText(node, key, value).transact(transaction_dict) + else: + raise UnsupportedFunction( + f"Resolver for name `{name}` does not support `text` function" + ) else: - raise UnownedName("claim domain using setup_address() first") + raise ResolverNotFound( + f"No resolver found for name `{name}`. It is likely the name contains an " + "unsupported top level domain (tld)." + ) def setup_owner( self, name: str, new_owner: ChecksumAddress = cast(ChecksumAddress, default), transact: Optional["TxParams"] = None - ) -> ChecksumAddress: + ) -> Optional[ChecksumAddress]: """ Set the owner of the supplied name to `new_owner`. @@ -449,21 +517,61 @@ def _set_resolver( namehash, resolver_addr ).transact(transact) - return self._resolverContract(address=resolver_addr) + return self._resolver_contract(address=resolver_addr) + + def _get_resolver( + self, + normal_name: str, + func: str = 'addr' + ) -> Tuple[Optional['Contract'], str]: + current_name = normal_name + + # look for a resolver, starting at the full name and taking the parent each time that no + # resolver is found + while True: + if is_empty_name(current_name): + # if no resolver found across all iterations, current_name will eventually be the + # empty string '' which returns here + return None, current_name + + resolver_addr = self.ens.caller.resolver(normal_name_to_hash(current_name)) + if not is_none_or_zero_address(resolver_addr): + # if resolver found, return it + return self._type_aware_resolver(resolver_addr, func), current_name + + # set current_name to parent and try again + current_name = self.parent(current_name) + + def _decode_ensip10_resolve_data( + self, contract_call_result: bytes, extended_resolver: 'Contract', fn_name: str, + ) -> Any: + func = extended_resolver.get_function_by_name(fn_name) + output_types = get_abi_output_types(func.abi) + decoded = self.w3.codec.decode_abi(output_types, contract_call_result) + return decoded[0] if len(decoded) == 1 else decoded def _setup_reverse( self, name: str, address: ChecksumAddress, transact: Optional["TxParams"] = None ) -> HexBytes: + name = normalize_name(name) if name else '' if not transact: transact = {} transact = deepcopy(transact) - if name: - name = normalize_name(name) - else: - name = '' transact['from'] = address return self._reverse_registrar().functions.setName(name).transact(transact) + def _type_aware_resolver(self, address: ChecksumAddress, func: str) -> 'Contract': + return ( + self._reverse_resolver_contract(address=address) if func == 'name' else + self._resolver_contract(address=address) + ) + def _reverse_registrar(self) -> 'Contract': addr = self.ens.caller.owner(normal_name_to_hash(REVERSE_REGISTRAR_DOMAIN)) return self.w3.eth.contract(address=addr, abi=abis.REVERSE_REGISTRAR) + + +def _resolver_supports_interface(resolver: 'Contract', interface_id: HexStr) -> bool: + if not any('supportsInterface' in repr(func) for func in resolver.all_functions()): + return False + return resolver.caller.supportsInterface(interface_id) diff --git a/ens/utils.py b/ens/utils.py index 33fda9ee29..cc3d9b734c 100644 --- a/ens/utils.py +++ b/ens/utils.py @@ -1,8 +1,13 @@ -import datetime +from datetime import ( + datetime, + timezone, +) from typing import ( TYPE_CHECKING, Any, Collection, + Dict, + List, Optional, Sequence, Tuple, @@ -18,10 +23,15 @@ HexStr, ) from eth_utils import ( + ValidationError, is_same_address, remove_0x_prefix, + to_bytes, to_normalized_address, ) +from eth_utils.abi import ( + collapse_if_tuple, +) from hexbytes import ( HexBytes, ) @@ -48,6 +58,7 @@ BaseProvider, ) from web3.types import ( # noqa: F401 + ABIFunction, Middleware, ) @@ -102,11 +113,41 @@ def normalize_name(name: str) -> str: name = name.decode('utf-8') try: - return idna.uts46_remap(name, std3_rules=True) + return idna.uts46_remap(name, std3_rules=True, transitional=False) except idna.IDNAError as exc: raise InvalidName(f"{name} is an invalid name, because {exc}") from exc +def ens_encode_name(name: str) -> bytes: + """ + Encode a name according to DNS standards specified in section 3.1 of RFC1035 with the + following validations: + + - There is no limit on the total length of the encoded name and the limit on labels is the + ENS standard of 255. + + - Return a single 0-octet, b'\x00', if empty name. + """ + if is_empty_name(name): + return b'\x00' + + normalized_name = normalize_name(name) + + labels = normalized_name.split('.') + labels_as_bytes = [to_bytes(text=label) for label in labels] + + # raises if len(label) > 255: + for index, label in enumerate(labels): + if len(label) > 255: + raise ValidationError(f"Label at position {index} too long after encoding.") + + # concat label size in bytes to each label: + dns_prepped_labels = [to_bytes(len(label)) + label for label in labels_as_bytes] + + # return the joined prepped labels in order and append the zero byte at the end: + return b''.join(dns_prepped_labels) + b'\x00' + + def is_valid_name(name: str) -> bool: """ Validate whether the fully qualified name is valid, as defined in ENS `EIP-137 @@ -124,11 +165,8 @@ def is_valid_name(name: str) -> bool: return False -def to_utc_datetime(timestamp: float) -> Optional[datetime.datetime]: - if timestamp: - return datetime.datetime.fromtimestamp(timestamp, datetime.timezone.utc) - else: - return None +def to_utc_datetime(timestamp: float) -> Optional[datetime]: + return datetime.fromtimestamp(timestamp, timezone.utc) if timestamp else None def sha3_text(val: Union[str, bytes]) -> HexBytes: @@ -204,6 +242,10 @@ def is_none_or_zero_address(addr: Union[Address, ChecksumAddress, HexAddress]) - return not addr or addr == EMPTY_ADDR_HEX +def is_empty_name(name: str) -> bool: + return name in {None, '.', ''} + + def is_valid_ens_name(ens_name: str) -> bool: split_domain = ens_name.split('.') if len(split_domain) == 1: @@ -212,3 +254,11 @@ def is_valid_ens_name(ens_name: str) -> bool: if not is_valid_name(name): return False return True + + +# borrowed from similar method at `web._utils.abi` due to circular dependency +def get_abi_output_types(abi: 'ABIFunction') -> List[str]: + return ( + [] if abi['type'] == 'fallback' + else [collapse_if_tuple(cast(Dict[str, Any], arg)) for arg in abi['outputs']] + ) diff --git a/newsfragments/2411.feature.rst b/newsfragments/2411.feature.rst new file mode 100644 index 0000000000..136b93dc27 --- /dev/null +++ b/newsfragments/2411.feature.rst @@ -0,0 +1 @@ +ENSIP-10 / wildcard resolution support for ENS module diff --git a/tests/ens/conftest.py b/tests/ens/conftest.py index a11c5ff7dd..3610be08f9 100644 --- a/tests/ens/conftest.py +++ b/tests/ens/conftest.py @@ -20,6 +20,9 @@ reverse_resolver_abi, reverse_resolver_bytecode, reverse_resolver_bytecode_runtime, + simple_resolver_abi, + simple_resolver_bytecode, + simple_resolver_bytecode_runtime, ) from web3 import Web3 from web3.contract import ( @@ -77,6 +80,15 @@ def PublicResolverFactory(w3): ) +def SimpleResolver(w3): + return w3.eth.contract( + bytecode=simple_resolver_bytecode, + bytecode_runtime=simple_resolver_bytecode_runtime, + abi=simple_resolver_abi, + ContractFactoryClass=Contract, + ) + + def ENSFactory(w3): return w3.eth.contract( bytecode="6060604052341561000f57600080fd5b60008080526020527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb58054600160a060020a033316600160a060020a0319909116179055610501806100626000396000f300606060405236156100805763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630178b8bf811461008557806302571be3146100b757806306ab5923146100cd57806314ab9038146100f457806316a25cbd146101175780631896f70a1461014a5780635b0fc9c31461016c575b600080fd5b341561009057600080fd5b61009b60043561018e565b604051600160a060020a03909116815260200160405180910390f35b34156100c257600080fd5b61009b6004356101ac565b34156100d857600080fd5b6100f2600435602435600160a060020a03604435166101c7565b005b34156100ff57600080fd5b6100f260043567ffffffffffffffff60243516610289565b341561012257600080fd5b61012d600435610355565b60405167ffffffffffffffff909116815260200160405180910390f35b341561015557600080fd5b6100f2600435600160a060020a036024351661038c565b341561017757600080fd5b6100f2600435600160a060020a0360243516610432565b600090815260208190526040902060010154600160a060020a031690565b600090815260208190526040902054600160a060020a031690565b600083815260208190526040812054849033600160a060020a039081169116146101f057600080fd5b8484604051918252602082015260409081019051908190039020915083857fce0457fe73731f824cc272376169235128c118b49d344817417c6d108d155e8285604051600160a060020a03909116815260200160405180910390a3506000908152602081905260409020805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555050565b600082815260208190526040902054829033600160a060020a039081169116146102b257600080fd5b827f1d4f9bbfc9cab89d66e1a1562f2233ccbf1308cb4f63de2ead5787adddb8fa688360405167ffffffffffffffff909116815260200160405180910390a250600091825260208290526040909120600101805467ffffffffffffffff90921674010000000000000000000000000000000000000000027fffffffff0000000000000000ffffffffffffffffffffffffffffffffffffffff909216919091179055565b60009081526020819052604090206001015474010000000000000000000000000000000000000000900467ffffffffffffffff1690565b600082815260208190526040902054829033600160a060020a039081169116146103b557600080fd5b827f335721b01866dc23fbee8b6b2c7b1e14d6f05c28cd35a2c934239f94095602a083604051600160a060020a03909116815260200160405180910390a250600091825260208290526040909120600101805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03909216919091179055565b600082815260208190526040902054829033600160a060020a0390811691161461045b57600080fd5b827fd4735d920b0f87494915f556dd9b54c8f309026070caea5c737245152564d26683604051600160a060020a03909116815260200160405180910390a250600091825260208290526040909120805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039092169190911790555600a165627a7a7230582050975b6c54a16d216b563f4c4960d6ebc5881eb1ec73c2ef1f87920a251159530029", # noqa: E501 @@ -86,7 +98,7 @@ def ENSFactory(w3): ) -def ETHRegistrarFactory(w3): +def ENSRegistryFactory(w3): return w3.eth.contract( bytecode=registrar_bytecode, bytecode_runtime=registrar_bytecode_runtime, @@ -140,12 +152,12 @@ def ens_setup(): public_resolver.address ).transact({'from': ens_key}) - # create .eth auction registrar + # create .eth registrar eth_registrar = deploy( w3, - ETHRegistrarFactory, + ENSRegistryFactory, ens_key, - args=[ens_contract.address, eth_namehash, 1], + args=[ens_contract.address, eth_namehash], ) # set '.eth' to resolve to the registrar @@ -194,12 +206,35 @@ def ens_setup(): ).transact({'from': ens_key}) # set owner of tester.eth to an account controlled by tests + second_account = w3.eth.accounts[2] + ens_contract.functions.setSubnodeOwner( eth_namehash, w3.keccak(text='tester'), - w3.eth.accounts[2] # note that this does not have to be the default, only in the list + second_account # note that this does not have to be the default, only in the list + ).transact({'from': ens_key}) + + # --- setup simple resolver example --- # + + # create simple resolver + simple_resolver = deploy(w3, SimpleResolver, ens_key, args=[ens_contract.address]) + + # set owner of simple-resolver.eth to an account controlled by tests + ens_contract.functions.setSubnodeOwner( + eth_namehash, + w3.keccak(text='simple-resolver'), + second_account ).transact({'from': ens_key}) + simple_resolver_namehash = bytes32(0x65db4c1c4f4ab9e6917fa7896ce546b1fe03e9341e98187e3917afb60aa9835a) # noqa: E501 + + ens_contract.functions.setResolver( + simple_resolver_namehash, + simple_resolver.address + ).transact({'from': second_account}) + + # --- finish setup --- # + # make the registrar the owner of the 'eth' name ens_contract.functions.setSubnodeOwner( b'\0' * 32, diff --git a/tests/ens/test_get_text.py b/tests/ens/test_get_text.py index 82da916a67..9e441d45a6 100644 --- a/tests/ens/test_get_text.py +++ b/tests/ens/test_get_text.py @@ -5,7 +5,8 @@ ) from ens.exceptions import ( - UnownedName, + ResolverNotFound, + UnsupportedFunction, ) from web3 import Web3 @@ -17,28 +18,9 @@ ('description', 'a test'), ('notice', 'this contract is a test contract'), ),) -def test_set_text_unowned_name(ens, key, expected): - with pytest.raises(UnownedName): - ens.set_text('tester.eth', key, expected) - - -@pytest.mark.parametrize('key,expected', ( - ('avatar', 'tester.jpeg'), - ('email', 'user@example.com'), - ('url', 'http://example.com'), - ('description', 'a test'), - ('notice', 'this contract is a test contract'), -),) -def test_get_text(ens, key, expected): - address = ens.w3.eth.accounts[2] - ens.setup_address('tester.eth', address) - owner = ens.owner('tester.eth') - assert address == owner - ens.set_text('tester.eth', key, expected) - assert ens.get_text('tester.eth', key) == expected - - # teardown - ens.setup_address('tester.eth', None) +def test_set_text_resolver_not_found(ens, key, expected): + with pytest.raises(ResolverNotFound): + ens.set_text('tld', key, expected) def test_set_text_fails_with_bad_address(ens): @@ -57,10 +39,39 @@ def test_set_text_pass_in_transaction_dict(ens): 'tester.eth', 'avatar', 'example.jpeg', - transact={'gasPrice': Web3.toWei(100, 'gwei')} + transact={ + 'maxFeePerGas': Web3.toWei(100, 'gwei'), + 'maxPriorityFeePerGas': Web3.toWei(100, 'gwei'), + } ) assert ens.get_text('tester.eth', 'url') == 'http://example.com' assert ens.get_text('tester.eth', 'avatar') == 'example.jpeg' # teardown ens.setup_address('tester.eth', None) + + +@pytest.mark.parametrize('key,expected', ( + ('avatar', 'tester.jpeg'), + ('email', 'user@example.com'), + ('url', 'http://example.com'), + ('description', 'a test'), + ('notice', 'this contract is a test contract'), +),) +def test_get_text(ens, key, expected): + address = ens.w3.eth.accounts[2] + ens.setup_address('tester.eth', address) + owner = ens.owner('tester.eth') + assert address == owner + ens.set_text('tester.eth', key, expected) + assert ens.get_text('tester.eth', key) == expected + + +def test_get_text_resolver_not_found(ens): + with pytest.raises(ResolverNotFound): + ens.get_text('tld', 'any_key') + + +def test_get_text_for_resolver_with_unsupported_function(ens): + with pytest.raises(UnsupportedFunction): + ens.get_text('simple-resolver.eth', 'any_key') diff --git a/tests/ens/test_setup_address.py b/tests/ens/test_setup_address.py index 326161989b..4d1ab182fd 100644 --- a/tests/ens/test_setup_address.py +++ b/tests/ens/test_setup_address.py @@ -3,6 +3,9 @@ patch, ) +from eth_typing import ( + HexStr, +) from eth_utils import ( is_same_address, to_bytes, @@ -23,53 +26,45 @@ @pytest.mark.parametrize( - 'name, full_name, namehash_hex', + 'name, namehash_hex', [ ( - 'tester.eth', 'tester.eth', '0x2a7ac1c833d35677c2ff34a908951de142cc1653de6080ad4e38f4c9cc00aafe', ), ( - 'TESTER.eth', 'TESTER.eth', '0x2a7ac1c833d35677c2ff34a908951de142cc1653de6080ad4e38f4c9cc00aafe', ), # handles alternative dot separators ( - 'tester.eth', 'tester.eth', '0x2a7ac1c833d35677c2ff34a908951de142cc1653de6080ad4e38f4c9cc00aafe', ), ( - 'tester。eth', 'tester。eth', '0x2a7ac1c833d35677c2ff34a908951de142cc1653de6080ad4e38f4c9cc00aafe', ), ( - 'tester。eth', 'tester。eth', '0x2a7ac1c833d35677c2ff34a908951de142cc1653de6080ad4e38f4c9cc00aafe', ), # confirm that set-owner works ( - 'lots.of.subdomains.tester.eth', 'lots.of.subdomains.tester.eth', '0x0d62a759aa1f1c9680de8603a12a5eb175cd1bfa79426229868eba99f4dce692', ), ], ) -def test_set_address(ens, name, full_name, namehash_hex, TEST_ADDRESS): +def test_set_address(ens, name, namehash_hex, TEST_ADDRESS): assert ens.address(name) is None owner = ens.owner('tester.eth') ens.setup_address(name, TEST_ADDRESS) assert is_same_address(ens.address(name), TEST_ADDRESS) - namehash = Web3.toBytes(hexstr=namehash_hex) - normal_name = ens.nameprep(full_name) - assert is_same_address(ens.address(name), TEST_ADDRESS) - + namehash = Web3.toBytes(hexstr=HexStr(namehash_hex)) + normal_name = ens.nameprep(name) # check that the correct namehash is set: assert is_same_address(ens.resolver(normal_name).caller.addr(namehash), TEST_ADDRESS) diff --git a/tests/ens/test_setup_name.py b/tests/ens/test_setup_name.py index e81b73d9ae..f47f48c736 100644 --- a/tests/ens/test_setup_name.py +++ b/tests/ens/test_setup_name.py @@ -1,5 +1,9 @@ import pytest +from eth_typing import ( + HexStr, +) + from ens.main import ( AddressMismatch, UnauthorizedError, @@ -13,7 +17,7 @@ """ -@pytest.fixture() +@pytest.fixture def TEST_ADDRESS(address_conversion_func): return address_conversion_func("0x000000000000000000000000000000000000dEaD") @@ -63,7 +67,7 @@ def test_setup_name(ens, name, normalized_name, namehash_hex): assert ens.name(address) == normalized_name # check that the correct namehash is set: - node = Web3.toBytes(hexstr=namehash_hex) + node = Web3.toBytes(hexstr=HexStr(namehash_hex)) assert ens.resolver(normalized_name).caller.addr(node) == address # check that the correct owner is set: From b54e08f989f9905357010aef308382ad19ba0b4b Mon Sep 17 00:00:00 2001 From: Felipe Selmo Date: Mon, 28 Mar 2022 16:45:31 -0600 Subject: [PATCH 53/57] Add tests related to ENSIP-10 implementation: - Test wildcard resolver functionality using a basic resolver with support for the `resolve()` method and validate the parent ens domain and its subdomains within the resolve method of the contract. - Test the new ``ens_encode_name()`` from the ``ens.utils`` module. - Test the new ``ENS.parent()`` method to extract a parent from an ENS name. --- ens/contract_data.py | 29 ++-- ens/utils.py | 2 +- tests/ens/conftest.py | 39 +++++- tests/ens/test_contracts/ExtendedResolver.sol | 127 ++++++++++++++++++ tests/ens/test_contracts/SimpleResolver.sol | 13 ++ tests/ens/test_get_text.py | 2 +- tests/ens/test_resolve.py | 28 ++++ tests/ens/test_utils.py | 88 ++++++++++++ 8 files changed, 306 insertions(+), 22 deletions(-) create mode 100644 tests/ens/test_contracts/ExtendedResolver.sol create mode 100644 tests/ens/test_contracts/SimpleResolver.sol create mode 100644 tests/ens/test_resolve.py diff --git a/ens/contract_data.py b/ens/contract_data.py index 6ec924d031..236329b9bb 100644 --- a/ens/contract_data.py +++ b/ens/contract_data.py @@ -18,25 +18,16 @@ # ENS Default Reverse Resolver reverse_resolver_abi = json.loads('[{"inputs":[{"internalType":"contract ENS","name":"ensAddr","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"constant":true,"inputs":[],"name":"ens","outputs":[{"internalType":"contract ENS","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"string","name":"_name","type":"string"}],"name":"setName","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]') reverse_resolver_bytecode = '608060405234801561001057600080fd5b5060405160208061079f8339810180604052602081101561003057600080fd5b8101908080519060200190929190505050806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166302571be37f91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e26001026040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018082815260200191505060206040518083038186803b15801561013457600080fd5b505afa158015610148573d6000803e3d6000fd5b505050506040513d602081101561015e57600080fd5b81019080805190602001909291905050509050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151561027f578073ffffffffffffffffffffffffffffffffffffffff16631e83409a336040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15801561024257600080fd5b505af1158015610256573d6000803e3d6000fd5b505050506040513d602081101561026c57600080fd5b8101908080519060200190929190505050505b505061050f806102906000396000f3fe608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633f15457f1461005c578063691f3431146100b35780637737221314610167575b600080fd5b34801561006857600080fd5b50610071610239565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156100bf57600080fd5b506100ec600480360360208110156100d657600080fd5b810190808035906020019092919050505061025e565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012c578082015181840152602081019050610111565b50505050905090810190601f1680156101595780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017357600080fd5b506102376004803603604081101561018a57600080fd5b8101908080359060200190929190803590602001906401000000008111156101b157600080fd5b8201836020820111156101c357600080fd5b803590602001918460018302840111640100000000831117156101e557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061030e565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60016020528060005260406000206000915090508054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103065780601f106102db57610100808354040283529160200191610306565b820191906000526020600020905b8154815290600101906020018083116102e957829003601f168201915b505050505081565b816000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166302571be3826040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018082815260200191505060206040518083038186803b15801561039d57600080fd5b505afa1580156103b1573d6000803e3d6000fd5b505050506040513d60208110156103c757600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561041157600080fd5b8160016000858152602001908152602001600020908051906020019061043892919061043e565b50505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061047f57805160ff19168380011785556104ad565b828001600101855582156104ad579182015b828111156104ac578251825591602001919060010190610491565b5b5090506104ba91906104be565b5090565b6104e091905b808211156104dc5760008160009055506001016104c4565b5090565b9056fea165627a7a72305820f326fd97e1fac0bcd89f007846301e41c2ad494c12d70b2b50dd61e62ffc906a0029' -reverse_resolver_bytecode_runtime = '608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633f15457f1461005c578063691f3431146100b35780637737221314610167575b600080fd5b34801561006857600080fd5b50610071610239565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156100bf57600080fd5b506100ec600480360360208110156100d657600080fd5b810190808035906020019092919050505061025e565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012c578082015181840152602081019050610111565b50505050905090810190601f1680156101595780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017357600080fd5b506102376004803603604081101561018a57600080fd5b8101908080359060200190929190803590602001906401000000008111156101b157600080fd5b8201836020820111156101c357600080fd5b803590602001918460018302840111640100000000831117156101e557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061030e565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60016020528060005260406000206000915090508054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103065780601f106102db57610100808354040283529160200191610306565b820191906000526020600020905b8154815290600101906020018083116102e957829003601f168201915b505050505081565b816000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166302571be3826040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018082815260200191505060206040518083038186803b15801561039d57600080fd5b505afa1580156103b1573d6000803e3d6000fd5b505050506040513d60208110156103c757600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561041157600080fd5b8160016000858152602001908152602001600020908051906020019061043892919061043e565b50505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061047f57805160ff19168380011785556104ad565b828001600101855582156104ad579182015b828111156104ac578251825591602001919060010190610491565b5b5090506104ba91906104be565b5090565b6104e091905b808211156104dc5760008160009055506001016104c4565b5090565b9056fea165627a7a72305820f326fd97e1fac0bcd89f007846301e41c2ad494c12d70b2b50dd61e62ffc906a0029' +reverse_resolver_bytecode_runtime = '608060405234801561001057600080fd5b506004361061004c5760003560e01c806301ffc9a7146100515780633e9ce794146100815780639061b9231461009d578063f86bc879146100cd575b600080fd5b61006b6004803603810190610066919061051e565b6100fd565b6040516100789190610566565b60405180910390f35b61009b60048036038101906100969190610641565b61015e565b005b6100b760048036038101906100b291906106f9565b610245565b6040516100c49190610813565b60405180910390f35b6100e760048036038101906100e29190610835565b61042f565b6040516100f49190610566565b60405180910390f35b6000639061b92360e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061015757506101568261046b565b5b9050919050565b806001600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507fe1c5610a6e0cbe10764ecd182adcef1ec338dc4e199c99c32ce98f38e12791df8333848460405161023894939291906108a6565b60405180910390a1505050565b60606040518060400160405280601781526020017f11657874656e6465642d7265736f6c766572036574680000000000000000000081525080519060200120858560405161029492919061092a565b60405180910390201480156102ad575060248383905010155b15610328577ff0a378cc2afe91730d0105e67d6bb037cc5b8b6bfec5b5962d9b637ff6497e5560001b83836004906024926102ea9392919061094d565b906102f591906109a0565b146102ff57600080fd5b61beef60405160200161031291906109ff565b6040516020818303038152906040529050610427565b60008585600081811061033e5761033d610a1a565b5b9050013560f81c60f81b60f81c60ff1690506040518060400160405280601781526020017f11657874656e6465642d7265736f6c766572036574680000000000000000000081525080519060200120868683600161039c9190610a82565b9080926103ab9392919061094d565b6040516103b9929190610ad8565b604051809103902014610401576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103f890610b28565b60405180910390fd5b61dead60405160200161041491906109ff565b6040516020818303038152906040529150505b949350505050565b6001602052826000526040600020602052816000526040600020602052806000526040600020600092509250509054906101000a900460ff1681565b60006301ffc9a760e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6104fb816104c6565b811461050657600080fd5b50565b600081359050610518816104f2565b92915050565b600060208284031215610534576105336104bc565b5b600061054284828501610509565b91505092915050565b60008115159050919050565b6105608161054b565b82525050565b600060208201905061057b6000830184610557565b92915050565b6000819050919050565b61059481610581565b811461059f57600080fd5b50565b6000813590506105b18161058b565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006105e2826105b7565b9050919050565b6105f2816105d7565b81146105fd57600080fd5b50565b60008135905061060f816105e9565b92915050565b61061e8161054b565b811461062957600080fd5b50565b60008135905061063b81610615565b92915050565b60008060006060848603121561065a576106596104bc565b5b6000610668868287016105a2565b935050602061067986828701610600565b925050604061068a8682870161062c565b9150509250925092565b600080fd5b600080fd5b600080fd5b60008083601f8401126106b9576106b8610694565b5b8235905067ffffffffffffffff8111156106d6576106d5610699565b5b6020830191508360018202830111156106f2576106f161069e565b5b9250929050565b60008060008060408587031215610713576107126104bc565b5b600085013567ffffffffffffffff811115610731576107306104c1565b5b61073d878288016106a3565b9450945050602085013567ffffffffffffffff8111156107605761075f6104c1565b5b61076c878288016106a3565b925092505092959194509250565b600081519050919050565b600082825260208201905092915050565b60005b838110156107b4578082015181840152602081019050610799565b838111156107c3576000848401525b50505050565b6000601f19601f8301169050919050565b60006107e58261077a565b6107ef8185610785565b93506107ff818560208601610796565b610808816107c9565b840191505092915050565b6000602082019050818103600083015261082d81846107da565b905092915050565b60008060006060848603121561084e5761084d6104bc565b5b600061085c868287016105a2565b935050602061086d86828701610600565b925050604061087e86828701610600565b9150509250925092565b61089181610581565b82525050565b6108a0816105d7565b82525050565b60006080820190506108bb6000830187610888565b6108c86020830186610897565b6108d56040830185610897565b6108e26060830184610557565b95945050505050565b600081905092915050565b82818337600083830152505050565b600061091183856108eb565b935061091e8385846108f6565b82840190509392505050565b6000610937828486610905565b91508190509392505050565b600080fd5b600080fd5b6000808585111561096157610960610943565b5b8386111561097257610971610948565b5b6001850283019150848603905094509492505050565b600082905092915050565b600082821b905092915050565b60006109ac8383610988565b826109b78135610581565b925060208210156109f7576109f27fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83602003600802610993565b831692505b505092915050565b6000602082019050610a146000830184610897565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610a8d82610a49565b9150610a9883610a49565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610acd57610acc610a53565b5b828201905092915050565b6000610ae5828486610905565b91508190509392505050565b600082825260208201905092915050565b50565b6000610b12600083610af1565b9150610b1d82610b02565b600082019050919050565b60006020820190508181036000830152610b4181610b05565b905091905056fea264697066735822122053f3072486d953b17f72555d93bae38d3607f573e572c03ca3b10c082471640064736f6c634300080d0033' +# ENSIP-10 - Extended Resolver for Wildcard Resolution +# compiled from `tests/test_contracts/ExtendedResolver.sol` +extended_resolver_abi = '[{"inputs": [{"internalType": "contract ENS","name": "_ens","type": "address"}],"stateMutability": "nonpayable","type": "constructor"},{"anonymous": false,"inputs": [{"indexed": false,"internalType": "bytes32","name": "node","type": "bytes32"},{"indexed": false,"internalType": "address","name": "owner","type": "address"},{"indexed": false,"internalType": "address","name": "target","type": "address"},{"indexed": false,"internalType": "bool","name": "isAuthorised","type": "bool"}],"name": "AuthorisationChanged","type": "event"},{"inputs": [{"internalType": "bytes32", "name": "", "type": "bytes32"},{"internalType": "address", "name": "", "type": "address"},{"internalType": "address", "name": "", "type": "address"}],"name": "authorisations","outputs": [{"internalType": "bool", "name": "", "type": "bool"}],"stateMutability": "view","type": "function"},{"inputs": [{"internalType": "bytes", "name": "dnsName", "type": "bytes"},{"internalType": "bytes", "name": "data", "type": "bytes"}],"name": "resolve","outputs": [{"internalType": "bytes", "name": "", "type": "bytes"}],"stateMutability": "view","type": "function"},{"inputs": [{"internalType": "bytes32", "name": "node", "type": "bytes32"},{"internalType": "address", "name": "target", "type": "address"},{"internalType": "bool", "name": "isAuthorised", "type": "bool"}],"name": "setAuthorisation","outputs": [],"stateMutability": "nonpayable","type": "function"},{"inputs": [{"internalType": "bytes4","name": "interfaceID","type": "bytes4"}],"name": "supportsInterface","outputs": [{"internalType": "bool", "name": "", "type": "bool"}],"stateMutability": "pure","type": "function"}]' +extended_resolver_bytecode = '608060405234801561001057600080fd5b50604051610dbb380380610dbb833981810160405281019061003291906100ed565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505061011a565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100a88261007d565b9050919050565b60006100ba8261009d565b9050919050565b6100ca816100af565b81146100d557600080fd5b50565b6000815190506100e7816100c1565b92915050565b60006020828403121561010357610102610078565b5b6000610111848285016100d8565b91505092915050565b610c92806101296000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c806301ffc9a7146100515780633e9ce794146100815780639061b9231461009d578063f86bc879146100cd575b600080fd5b61006b60048036038101906100669190610554565b6100fd565b604051610078919061059c565b60405180910390f35b61009b60048036038101906100969190610677565b61015e565b005b6100b760048036038101906100b2919061072f565b610245565b6040516100c49190610849565b60405180910390f35b6100e760048036038101906100e2919061086b565b610465565b6040516100f4919061059c565b60405180910390f35b6000639061b92360e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806101575750610156826104a1565b5b9050919050565b806001600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507fe1c5610a6e0cbe10764ecd182adcef1ec338dc4e199c99c32ce98f38e12791df8333848460405161023894939291906108dc565b60405180910390a1505050565b60606040518060400160405280601781526020017f11657874656e6465642d7265736f6c7665720365746800000000000000000000815250805190602001208585604051610294929190610960565b60405180910390201480156102ad575060248383905010155b1561035e577ff0a378cc2afe91730d0105e67d6bb037cc5b8b6bfec5b5962d9b637ff6497e5560001b83836004906024926102ea93929190610983565b906102f591906109d6565b14610335576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161032c90610ab8565b60405180910390fd5b61beef6040516020016103489190610ad8565b604051602081830303815290604052905061045d565b60008585600081811061037457610373610af3565b5b9050013560f81c60f81b60f81c60ff1690506040518060400160405280601781526020017f11657874656e6465642d7265736f6c76657203657468000000000000000000008152508051906020012086868360016103d29190610b5b565b9080926103e193929190610983565b6040516103ef929190610bb1565b604051809103902014610437576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042e90610c3c565b60405180910390fd5b61dead60405160200161044a9190610ad8565b6040516020818303038152906040529150505b949350505050565b6001602052826000526040600020602052816000526040600020602052806000526040600020600092509250509054906101000a900460ff1681565b60006301ffc9a760e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610531816104fc565b811461053c57600080fd5b50565b60008135905061054e81610528565b92915050565b60006020828403121561056a576105696104f2565b5b60006105788482850161053f565b91505092915050565b60008115159050919050565b61059681610581565b82525050565b60006020820190506105b1600083018461058d565b92915050565b6000819050919050565b6105ca816105b7565b81146105d557600080fd5b50565b6000813590506105e7816105c1565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610618826105ed565b9050919050565b6106288161060d565b811461063357600080fd5b50565b6000813590506106458161061f565b92915050565b61065481610581565b811461065f57600080fd5b50565b6000813590506106718161064b565b92915050565b6000806000606084860312156106905761068f6104f2565b5b600061069e868287016105d8565b93505060206106af86828701610636565b92505060406106c086828701610662565b9150509250925092565b600080fd5b600080fd5b600080fd5b60008083601f8401126106ef576106ee6106ca565b5b8235905067ffffffffffffffff81111561070c5761070b6106cf565b5b602083019150836001820283011115610728576107276106d4565b5b9250929050565b60008060008060408587031215610749576107486104f2565b5b600085013567ffffffffffffffff811115610767576107666104f7565b5b610773878288016106d9565b9450945050602085013567ffffffffffffffff811115610796576107956104f7565b5b6107a2878288016106d9565b925092505092959194509250565b600081519050919050565b600082825260208201905092915050565b60005b838110156107ea5780820151818401526020810190506107cf565b838111156107f9576000848401525b50505050565b6000601f19601f8301169050919050565b600061081b826107b0565b61082581856107bb565b93506108358185602086016107cc565b61083e816107ff565b840191505092915050565b600060208201905081810360008301526108638184610810565b905092915050565b600080600060608486031215610884576108836104f2565b5b6000610892868287016105d8565b93505060206108a386828701610636565b92505060406108b486828701610636565b9150509250925092565b6108c7816105b7565b82525050565b6108d68161060d565b82525050565b60006080820190506108f160008301876108be565b6108fe60208301866108cd565b61090b60408301856108cd565b610918606083018461058d565b95945050505050565b600081905092915050565b82818337600083830152505050565b60006109478385610921565b935061095483858461092c565b82840190509392505050565b600061096d82848661093b565b91508190509392505050565b600080fd5b600080fd5b6000808585111561099757610996610979565b5b838611156109a8576109a761097e565b5b6001850283019150848603905094509492505050565b600082905092915050565b600082821b905092915050565b60006109e283836109be565b826109ed81356105b7565b92506020821015610a2d57610a287fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff836020036008026109c9565b831692505b505092915050565b600082825260208201905092915050565b7f706172656e7420646f6d61696e206e6f742076616c696461746564206170707260008201527f6f7072696174656c790000000000000000000000000000000000000000000000602082015250565b6000610aa2602983610a35565b9150610aad82610a46565b604082019050919050565b60006020820190508181036000830152610ad181610a95565b9050919050565b6000602082019050610aed60008301846108cd565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610b6682610b22565b9150610b7183610b22565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610ba657610ba5610b2c565b5b828201905092915050565b6000610bbe82848661093b565b91508190509392505050565b7f737562646f6d61696e206e6f742076616c69646174656420617070726f70726960008201527f6174656c79000000000000000000000000000000000000000000000000000000602082015250565b6000610c26602583610a35565b9150610c3182610bca565b604082019050919050565b60006020820190508181036000830152610c5581610c19565b905091905056fea26469706673582212209fff87be19ed85e754d5e2791de6ed052e7e653185e1d47fa94515f851becd2f64736f6c634300080d0033' +extended_resolver_bytecode_runtime = '608060405234801561001057600080fd5b506004361061004c5760003560e01c806301ffc9a7146100515780633e9ce794146100815780639061b9231461009d578063f86bc879146100cd575b600080fd5b61006b60048036038101906100669190610554565b6100fd565b604051610078919061059c565b60405180910390f35b61009b60048036038101906100969190610677565b61015e565b005b6100b760048036038101906100b2919061072f565b610245565b6040516100c49190610849565b60405180910390f35b6100e760048036038101906100e2919061086b565b610465565b6040516100f4919061059c565b60405180910390f35b6000639061b92360e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806101575750610156826104a1565b5b9050919050565b806001600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507fe1c5610a6e0cbe10764ecd182adcef1ec338dc4e199c99c32ce98f38e12791df8333848460405161023894939291906108dc565b60405180910390a1505050565b60606040518060400160405280601781526020017f11657874656e6465642d7265736f6c7665720365746800000000000000000000815250805190602001208585604051610294929190610960565b60405180910390201480156102ad575060248383905010155b1561035e577ff0a378cc2afe91730d0105e67d6bb037cc5b8b6bfec5b5962d9b637ff6497e5560001b83836004906024926102ea93929190610983565b906102f591906109d6565b14610335576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161032c90610ab8565b60405180910390fd5b61beef6040516020016103489190610ad8565b604051602081830303815290604052905061045d565b60008585600081811061037457610373610af3565b5b9050013560f81c60f81b60f81c60ff1690506040518060400160405280601781526020017f11657874656e6465642d7265736f6c76657203657468000000000000000000008152508051906020012086868360016103d29190610b5b565b9080926103e193929190610983565b6040516103ef929190610bb1565b604051809103902014610437576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042e90610c3c565b60405180910390fd5b61dead60405160200161044a9190610ad8565b6040516020818303038152906040529150505b949350505050565b6001602052826000526040600020602052816000526040600020602052806000526040600020600092509250509054906101000a900460ff1681565b60006301ffc9a760e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610531816104fc565b811461053c57600080fd5b50565b60008135905061054e81610528565b92915050565b60006020828403121561056a576105696104f2565b5b60006105788482850161053f565b91505092915050565b60008115159050919050565b61059681610581565b82525050565b60006020820190506105b1600083018461058d565b92915050565b6000819050919050565b6105ca816105b7565b81146105d557600080fd5b50565b6000813590506105e7816105c1565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610618826105ed565b9050919050565b6106288161060d565b811461063357600080fd5b50565b6000813590506106458161061f565b92915050565b61065481610581565b811461065f57600080fd5b50565b6000813590506106718161064b565b92915050565b6000806000606084860312156106905761068f6104f2565b5b600061069e868287016105d8565b93505060206106af86828701610636565b92505060406106c086828701610662565b9150509250925092565b600080fd5b600080fd5b600080fd5b60008083601f8401126106ef576106ee6106ca565b5b8235905067ffffffffffffffff81111561070c5761070b6106cf565b5b602083019150836001820283011115610728576107276106d4565b5b9250929050565b60008060008060408587031215610749576107486104f2565b5b600085013567ffffffffffffffff811115610767576107666104f7565b5b610773878288016106d9565b9450945050602085013567ffffffffffffffff811115610796576107956104f7565b5b6107a2878288016106d9565b925092505092959194509250565b600081519050919050565b600082825260208201905092915050565b60005b838110156107ea5780820151818401526020810190506107cf565b838111156107f9576000848401525b50505050565b6000601f19601f8301169050919050565b600061081b826107b0565b61082581856107bb565b93506108358185602086016107cc565b61083e816107ff565b840191505092915050565b600060208201905081810360008301526108638184610810565b905092915050565b600080600060608486031215610884576108836104f2565b5b6000610892868287016105d8565b93505060206108a386828701610636565b92505060406108b486828701610636565b9150509250925092565b6108c7816105b7565b82525050565b6108d68161060d565b82525050565b60006080820190506108f160008301876108be565b6108fe60208301866108cd565b61090b60408301856108cd565b610918606083018461058d565b95945050505050565b600081905092915050565b82818337600083830152505050565b60006109478385610921565b935061095483858461092c565b82840190509392505050565b600061096d82848661093b565b91508190509392505050565b600080fd5b600080fd5b6000808585111561099757610996610979565b5b838611156109a8576109a761097e565b5b6001850283019150848603905094509492505050565b600082905092915050565b600082821b905092915050565b60006109e283836109be565b826109ed81356105b7565b92506020821015610a2d57610a287fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff836020036008026109c9565b831692505b505092915050565b600082825260208201905092915050565b7f706172656e7420646f6d61696e206e6f742076616c696461746564206170707260008201527f6f7072696174656c790000000000000000000000000000000000000000000000602082015250565b6000610aa2602983610a35565b9150610aad82610a46565b604082019050919050565b60006020820190508181036000830152610ad181610a95565b9050919050565b6000602082019050610aed60008301846108cd565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610b6682610b22565b9150610b7183610b22565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610ba657610ba5610b2c565b5b828201905092915050565b6000610bbe82848661093b565b91508190509392505050565b7f737562646f6d61696e206e6f742076616c69646174656420617070726f70726960008201527f6174656c79000000000000000000000000000000000000000000000000000000602082015250565b6000610c26602583610a35565b9150610c3182610bca565b604082019050919050565b60006020820190508181036000830152610c5581610c19565b905091905056fea26469706673582212209fff87be19ed85e754d5e2791de6ed052e7e653185e1d47fa94515f851becd2f64736f6c634300080d0033' -# --- simple resolver --- # -''' -pragma solidity ^0.8.11; - -contract SimpleResolver { - // deployed on ropsten at address = 0xD4D522c96111679bF86220deFE75e0aA1df890b4 - - function supportsInterface(bytes4 interfaceID) public returns (bool) { - return interfaceID == 0x3b3b57de; - } - - function addr(bytes32 nodeID) public returns (address) { - return address(this); - } -} -''' +# Simple resolver with no support for interfaces like getText(), etc +# compiled from `tests/test_contracts/SimpleResolver.sol` simple_resolver_abi = json.loads('[{"inputs":[{"internalType":"bytes32","name":"nodeID","type":"bytes32"}],"name":"addr","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceID","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]') -simple_resolver_bytecode = '608060405234801561001057600080fd5b5061028c806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806301ffc9a71461003b5780633b3b57de1461006b575b600080fd5b61005560048036038101906100509190610134565b61009b565b604051610062919061017c565b60405180910390f35b610085600480360381019061008091906101cd565b6100cd565b604051610092919061023b565b60405180910390f35b6000633b3b57de60e01b827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6000309050919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610111816100dc565b811461011c57600080fd5b50565b60008135905061012e81610108565b92915050565b60006020828403121561014a576101496100d7565b5b60006101588482850161011f565b91505092915050565b60008115159050919050565b61017681610161565b82525050565b6000602082019050610191600083018461016d565b92915050565b6000819050919050565b6101aa81610197565b81146101b557600080fd5b50565b6000813590506101c7816101a1565b92915050565b6000602082840312156101e3576101e26100d7565b5b60006101f1848285016101b8565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610225826101fa565b9050919050565b6102358161021a565b82525050565b6000602082019050610250600083018461022c565b9291505056fea264697066735822122090fd4775d8c721c381bd14218694b81067bc90d79ff9e6d4dcad53f0c1a461e164736f6c634300080d0033' -simple_resolver_bytecode_runtime = '608060405234801561001057600080fd5b50600436106100365760003560e01c806301ffc9a71461003b5780633b3b57de1461006b575b600080fd5b61005560048036038101906100509190610134565b61009b565b604051610062919061017c565b60405180910390f35b610085600480360381019061008091906101cd565b6100cd565b604051610092919061023b565b60405180910390f35b6000633b3b57de60e01b827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6000309050919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610111816100dc565b811461011c57600080fd5b50565b60008135905061012e81610108565b92915050565b60006020828403121561014a576101496100d7565b5b60006101588482850161011f565b91505092915050565b60008115159050919050565b61017681610161565b82525050565b6000602082019050610191600083018461016d565b92915050565b6000819050919050565b6101aa81610197565b81146101b557600080fd5b50565b6000813590506101c7816101a1565b92915050565b6000602082840312156101e3576101e26100d7565b5b60006101f1848285016101b8565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610225826101fa565b9050919050565b6102358161021a565b82525050565b6000602082019050610250600083018461022c565b9291505056fea264697066735822122090fd4775d8c721c381bd14218694b81067bc90d79ff9e6d4dcad53f0c1a461e164736f6c634300080d0033' +simple_resolver_bytecode = '608060405234801561001057600080fd5b5061028c806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806301ffc9a71461003b5780633b3b57de1461006b575b600080fd5b61005560048036038101906100509190610134565b61009b565b604051610062919061017c565b60405180910390f35b610085600480360381019061008091906101cd565b6100cd565b604051610092919061023b565b60405180910390f35b6000633b3b57de60e01b827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6000309050919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610111816100dc565b811461011c57600080fd5b50565b60008135905061012e81610108565b92915050565b60006020828403121561014a576101496100d7565b5b60006101588482850161011f565b91505092915050565b60008115159050919050565b61017681610161565b82525050565b6000602082019050610191600083018461016d565b92915050565b6000819050919050565b6101aa81610197565b81146101b557600080fd5b50565b6000813590506101c7816101a1565b92915050565b6000602082840312156101e3576101e26100d7565b5b60006101f1848285016101b8565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610225826101fa565b9050919050565b6102358161021a565b82525050565b6000602082019050610250600083018461022c565b9291505056fea2646970667358221220e9d34e70193fa6e99d9be00bd7b1e4b63dc6fd9c84934a35350d8b2c4215974964736f6c634300080d0033' +simple_resolver_bytecode_runtime = '608060405234801561001057600080fd5b50600436106100365760003560e01c806301ffc9a71461003b5780633b3b57de1461006b575b600080fd5b61005560048036038101906100509190610134565b61009b565b604051610062919061017c565b60405180910390f35b610085600480360381019061008091906101cd565b6100cd565b604051610092919061023b565b60405180910390f35b6000633b3b57de60e01b827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6000309050919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b610111816100dc565b811461011c57600080fd5b50565b60008135905061012e81610108565b92915050565b60006020828403121561014a576101496100d7565b5b60006101588482850161011f565b91505092915050565b60008115159050919050565b61017681610161565b82525050565b6000602082019050610191600083018461016d565b92915050565b6000819050919050565b6101aa81610197565b81146101b557600080fd5b50565b6000813590506101c7816101a1565b92915050565b6000602082840312156101e3576101e26100d7565b5b60006101f1848285016101b8565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610225826101fa565b9050919050565b6102358161021a565b82525050565b6000602082019050610250600083018461022c565b9291505056fea2646970667358221220e9d34e70193fa6e99d9be00bd7b1e4b63dc6fd9c84934a35350d8b2c4215974964736f6c634300080d0033' diff --git a/ens/utils.py b/ens/utils.py index cc3d9b734c..e56ef75d7c 100644 --- a/ens/utils.py +++ b/ens/utils.py @@ -256,7 +256,7 @@ def is_valid_ens_name(ens_name: str) -> bool: return True -# borrowed from similar method at `web._utils.abi` due to circular dependency +# borrowed from similar method at `web3._utils.abi` due to circular dependency def get_abi_output_types(abi: 'ABIFunction') -> List[str]: return ( [] if abi['type'] == 'fallback' diff --git a/tests/ens/conftest.py b/tests/ens/conftest.py index 3610be08f9..c93c1021fc 100644 --- a/tests/ens/conftest.py +++ b/tests/ens/conftest.py @@ -8,6 +8,9 @@ from ens import ENS from ens.contract_data import ( + extended_resolver_abi, + extended_resolver_bytecode, + extended_resolver_bytecode_runtime, registrar_abi, registrar_bytecode, registrar_bytecode_runtime, @@ -89,6 +92,15 @@ def SimpleResolver(w3): ) +def ExtendedResolver(w3): + return w3.eth.contract( + bytecode=extended_resolver_bytecode, + bytecode_runtime=extended_resolver_bytecode_runtime, + abi=extended_resolver_abi, + ContractFactoryClass=Contract, + ) + + def ENSFactory(w3): return w3.eth.contract( bytecode="6060604052341561000f57600080fd5b60008080526020527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb58054600160a060020a033316600160a060020a0319909116179055610501806100626000396000f300606060405236156100805763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630178b8bf811461008557806302571be3146100b757806306ab5923146100cd57806314ab9038146100f457806316a25cbd146101175780631896f70a1461014a5780635b0fc9c31461016c575b600080fd5b341561009057600080fd5b61009b60043561018e565b604051600160a060020a03909116815260200160405180910390f35b34156100c257600080fd5b61009b6004356101ac565b34156100d857600080fd5b6100f2600435602435600160a060020a03604435166101c7565b005b34156100ff57600080fd5b6100f260043567ffffffffffffffff60243516610289565b341561012257600080fd5b61012d600435610355565b60405167ffffffffffffffff909116815260200160405180910390f35b341561015557600080fd5b6100f2600435600160a060020a036024351661038c565b341561017757600080fd5b6100f2600435600160a060020a0360243516610432565b600090815260208190526040902060010154600160a060020a031690565b600090815260208190526040902054600160a060020a031690565b600083815260208190526040812054849033600160a060020a039081169116146101f057600080fd5b8484604051918252602082015260409081019051908190039020915083857fce0457fe73731f824cc272376169235128c118b49d344817417c6d108d155e8285604051600160a060020a03909116815260200160405180910390a3506000908152602081905260409020805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555050565b600082815260208190526040902054829033600160a060020a039081169116146102b257600080fd5b827f1d4f9bbfc9cab89d66e1a1562f2233ccbf1308cb4f63de2ead5787adddb8fa688360405167ffffffffffffffff909116815260200160405180910390a250600091825260208290526040909120600101805467ffffffffffffffff90921674010000000000000000000000000000000000000000027fffffffff0000000000000000ffffffffffffffffffffffffffffffffffffffff909216919091179055565b60009081526020819052604090206001015474010000000000000000000000000000000000000000900467ffffffffffffffff1690565b600082815260208190526040902054829033600160a060020a039081169116146103b557600080fd5b827f335721b01866dc23fbee8b6b2c7b1e14d6f05c28cd35a2c934239f94095602a083604051600160a060020a03909116815260200160405180910390a250600091825260208290526040909120600101805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03909216919091179055565b600082815260208190526040902054829033600160a060020a0390811691161461045b57600080fd5b827fd4735d920b0f87494915f556dd9b54c8f309026070caea5c737245152564d26683604051600160a060020a03909116815260200160405180910390a250600091825260208290526040909120805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039092169190911790555600a165627a7a7230582050975b6c54a16d216b563f4c4960d6ebc5881eb1ec73c2ef1f87920a251159530029", # noqa: E501 @@ -226,13 +238,38 @@ def ens_setup(): second_account ).transact({'from': ens_key}) - simple_resolver_namehash = bytes32(0x65db4c1c4f4ab9e6917fa7896ce546b1fe03e9341e98187e3917afb60aa9835a) # noqa: E501 + # ns.namehash('simple-resolver.eth') + simple_resolver_namehash = bytes32( + 0x65db4c1c4f4ab9e6917fa7896ce546b1fe03e9341e98187e3917afb60aa9835a + ) ens_contract.functions.setResolver( simple_resolver_namehash, simple_resolver.address ).transact({'from': second_account}) + # --- setup extended resolver example --- # + + # create extended resolver + extended_resolver = deploy(w3, ExtendedResolver, ens_key, args=[ens_contract.address]) + + # set owner of extended-resolver.eth to an account controlled by tests + ens_contract.functions.setSubnodeOwner( + eth_namehash, + w3.keccak(text='extended-resolver'), + second_account + ).transact({'from': ens_key}) + + # ns.namehash('extended-resolver.eth') + extended_resolver_namehash = bytes32( + 0xf0a378cc2afe91730d0105e67d6bb037cc5b8b6bfec5b5962d9b637ff6497e55 + ) + + ens_contract.functions.setResolver( + extended_resolver_namehash, + extended_resolver.address + ).transact({'from': second_account}) + # --- finish setup --- # # make the registrar the owner of the 'eth' name diff --git a/tests/ens/test_contracts/ExtendedResolver.sol b/tests/ens/test_contracts/ExtendedResolver.sol new file mode 100644 index 0000000000..5e8b7eedca --- /dev/null +++ b/tests/ens/test_contracts/ExtendedResolver.sol @@ -0,0 +1,127 @@ +/** + * The SimpleExtendedResolver is really only meant to test the validation of the parent ens domain + * `extended-resolver.eth` and, separately, the subdomains of this parent domain. We then "resolve" + * to arbitrary addresses 0x000000000000000000000000000000000000dEaD for subdomain validations and + * 0x000000000000000000000000000000000000bEEF for the parent domain validation so that we can be + * sure each case was validated via the appropriate logic via the `resolve()` function of the contract. + */ + + +pragma solidity >=0.4.24; + +interface ENS { + + // Logged when the owner of a node assigns a new owner to a subnode. + event NewOwner(bytes32 node, bytes32 label, address owner); + + // Logged when the owner of a node transfers ownership to a new account. + event Transfer(bytes32 node, address owner); + + // Logged when the resolver for a node changes. + event NewResolver(bytes32 node, address resolver); + + // Logged when the TTL of a node changes + event NewTTL(bytes32 node, uint64 ttl); + + + function setSubnodeOwner(bytes32 node, bytes32 label, address owner) external; + function setResolver(bytes32 node, address resolver) external; + function setOwner(bytes32 node, address owner) external; + function setTTL(bytes32 node, uint64 ttl) external; + function owner(bytes32 node) external view returns (address); + function resolver(bytes32 node) external view returns (address); + function ttl(bytes32 node) external view returns (uint64); +} + +pragma solidity >= 0.7.0; + +abstract contract ResolverBase { + bytes4 private constant INTERFACE_META_ID = 0x01ffc9a7; + + function supportsInterface(bytes4 interfaceID) virtual public pure returns(bool) { + return interfaceID == INTERFACE_META_ID; + } + + function isAuthorised(bytes32 node) internal virtual view returns(bool); + + modifier authorised(bytes32 node) { + require(isAuthorised(node)); + _; + } + + function bytesToAddress(bytes memory b) internal pure returns(address payable a) { + require(b.length == 20); + assembly { + a := div(mload(add(b, 32)), exp(256, 12)) + } + } + + function addressToBytes(address a) internal pure returns(bytes memory b) { + b = new bytes(20); + assembly { + mstore(add(b, 32), mul(a, exp(256, 12))) + } + } +} + +contract ExtendedResolver is ResolverBase { + ENS ens; + + bytes4 constant private EXTENDED_RESOLVER_INTERFACE_ID = 0x9061b923; + string constant extendedResolverParentDomain = "\x11extended-resolver\x03eth\x00"; + bytes32 constant extendedResolverNamehash = 0xf0a378cc2afe91730d0105e67d6bb037cc5b8b6bfec5b5962d9b637ff6497e55; + + /** + * A mapping of authorisations. An address that is authorised for a name + * may make any changes to the name that the owner could, but may not update + * the set of authorisations. + * (node, owner, caller) => isAuthorised + */ + mapping(bytes32=>mapping(address=>mapping(address=>bool))) public authorisations; + + event AuthorisationChanged(bytes32 node, address owner, address target, bool isAuthorised); + + constructor(ENS _ens) public { + ens = _ens; + } + + /** + * @dev Sets or clears an authorisation. + * Authorisations are specific to the caller. Any account can set an authorisation + * for any name, but the authorisation that is checked will be that of the + * current owner of a name. Thus, transferring a name effectively clears any + * existing authorisations, and new authorisations can be set in advance of + * an ownership transfer if desired. + * + * @param node The name to change the authorisation on. + * @param target The address that is to be authorised or deauthorised. + * @param isAuthorised True if the address should be authorised, or false if it should be deauthorised. + */ + function setAuthorisation(bytes32 node, address target, bool isAuthorised) external { + authorisations[node][msg.sender][target] = isAuthorised; + emit AuthorisationChanged(node, msg.sender, target, isAuthorised); + } + + function isAuthorised(bytes32 node) override internal view returns(bool) { + address owner = ens.owner(node); + return owner == msg.sender || authorisations[node][owner][msg.sender]; + } + + function supportsInterface(bytes4 interfaceID) override public pure returns(bool) { + return interfaceID == EXTENDED_RESOLVER_INTERFACE_ID || super.supportsInterface(interfaceID); + } + + // Simple resolve method solely used to test ENSIP-10 / Wildcard Resolution functionality + function resolve(bytes calldata dnsName, bytes calldata data) external view returns (bytes memory) { + // validate 'extended-resolver.eth' parent domain + if (keccak256(dnsName) == keccak256(bytes(extendedResolverParentDomain)) && data.length >= 36) { + require(bytes32(data[4:36]) == extendedResolverNamehash, "parent domain not validated appropriately"); + return abi.encode(address(0x000000000000000000000000000000000000bEEF)); + } else { + uint length = uint8(dnsName[0]); + // validate subdomains of 'extended-resolver.eth' parent domain + require(keccak256(dnsName[1 + length:]) == keccak256(bytes(extendedResolverParentDomain)), "subdomain not validated appropriately"); + return abi.encode(address(0x000000000000000000000000000000000000dEaD)); + } + } +} diff --git a/tests/ens/test_contracts/SimpleResolver.sol b/tests/ens/test_contracts/SimpleResolver.sol new file mode 100644 index 0000000000..30fce21479 --- /dev/null +++ b/tests/ens/test_contracts/SimpleResolver.sol @@ -0,0 +1,13 @@ +pragma solidity ^0.8.13; + +contract SimpleResolver { + // deployed on ropsten at address = 0xD4D522c96111679bF86220deFE75e0aA1df890b4 + + function supportsInterface(bytes4 interfaceID) public returns (bool) { + return interfaceID == 0x3b3b57de; + } + + function addr(bytes32 nodeID) public returns (address) { + return address(this); + } +} diff --git a/tests/ens/test_get_text.py b/tests/ens/test_get_text.py index 9e441d45a6..54865cfc5a 100644 --- a/tests/ens/test_get_text.py +++ b/tests/ens/test_get_text.py @@ -73,5 +73,5 @@ def test_get_text_resolver_not_found(ens): def test_get_text_for_resolver_with_unsupported_function(ens): - with pytest.raises(UnsupportedFunction): + with pytest.raises(UnsupportedFunction, match="does not support `text` function"): ens.get_text('simple-resolver.eth', 'any_key') diff --git a/tests/ens/test_resolve.py b/tests/ens/test_resolve.py new file mode 100644 index 0000000000..00459506c1 --- /dev/null +++ b/tests/ens/test_resolve.py @@ -0,0 +1,28 @@ +import pytest + + +def test_resolve(ens): + acct = ens.w3.eth.accounts[2] + ens.setup_address('tester.eth', acct) + + assert ens.resolve('tester.eth') == acct + + # clean up + ens.setup_address('tester.eth', None) + + +@pytest.mark.parametrize('subdomain', ('sub1', 'sub2', 'rändöm', '🌈rainbow', 'faß')) +def test_wildcard_resolution_with_extended_resolver_for_subdomains(ens, subdomain): + # validate subdomains of `extended-resolver.eth` by asserting it returns the specified + # hard-coded address from `tests/test_contracts/ExtendedResolver.sol` which requires + # certain conditions to be met that are specific to subdomains only + resolved_child_address = ens.resolve(f'{subdomain}.extended-resolver.eth') + assert resolved_child_address == '0x000000000000000000000000000000000000dEaD' + + +def test_wildcard_resolution_with_extended_resolver_for_parent_ens_domain(ens): + # validate `extended-resolver.eth` by asserting it returns the specified hard-coded address from + # `tests/test_contracts/ExtendedResolver.sol` which requires a specific condition to be + # met for the parent domain `extended-resolver.eth` + resolved_parent_address = ens.resolve('extended-resolver.eth') + assert resolved_parent_address == '0x000000000000000000000000000000000000bEEF' diff --git a/tests/ens/test_utils.py b/tests/ens/test_utils.py index 052670a533..f384cdb709 100644 --- a/tests/ens/test_utils.py +++ b/tests/ens/test_utils.py @@ -1,5 +1,12 @@ +import pytest + +from eth_utils import ( + ValidationError, + to_bytes, +) from ens.utils import ( + ens_encode_name, init_web3, ) @@ -8,3 +15,84 @@ def test_init_adds_middlewares(): w3 = init_web3() middlewares = map(str, w3.manager.middleware_onion) assert 'stalecheck_middleware' in next(middlewares) + + +@pytest.mark.parametrize( + 'name,expected', + ( + # test some allowed cases + ('tester.eth', b'\x06tester\x03eth\x00'), + ( + 'a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p', + b'\x01a\x01b\x01c\x01d\x01e\x01f\x01g\x01h\x01i\x01j\x01k\x01l\x01m\x01n\x01o\x01p\x00' + ), + ('1.2.3.4.5.6.7.8.9.10', b'\x011\x012\x013\x014\x015\x016\x017\x018\x019\x0210\x00'), + ('abc.123.def-456.eth', b'\x03abc\x03123\x07def-456\x03eth\x00'), + ('abc.123.def-456.eth', b'\x03abc\x03123\x07def-456\x03eth\x00'), + ('nhéééééé.eth', b'\x0enh\xc3\xa9\xc3\xa9\xc3\xa9\xc3\xa9\xc3\xa9\xc3\xa9\x03eth\x00'), + ('🌈rainbow.eth', b'\x0b\xf0\x9f\x8c\x88rainbow\x03eth\x00'), + ('🐔🐔.tk', b'\x08\xf0\x9f\x90\x94\xf0\x9f\x90\x94\x02tk\x00'), + + # test that label length may be less than 255 + (f"{'a' * 255}.b", b'\xff' + (b'a' * 255) + b'\x01b\x00'), + (f"a.{'b' * 255}", b'\x01a' + b'\xff' + (b'b' * 255) + b'\x00'), + (f"abc-123.{'b' * 255}", b'\x07abc-123' + b'\xff' + b'b' * 255 + b'\x00'), + ) +) +def test_ens_encode_name(name, expected): + assert ens_encode_name(name) == expected + + +@pytest.mark.parametrize( + 'name,expected', + ( + ( + f"{'a' * 63}.{'b' * 63}.{'c' * 63}.{'d' * 63}.{'e' * 63}.{'f' * 63}.{'g' * 63}", + b''.join([b'?' + to_bytes(text=label) * 63 for label in 'abcdefg']) + b'\x00' + ), + ( + f"{'a-1' * 21}.{'b-2' * 21}.{'c-3' * 21}.{'d-4' * 21}.{'e-5' * 21}.{'f-6' * 21}", + b''.join([ + b'?' + to_bytes(text=label) * 21 for label in [ + 'a-1', 'b-2', 'c-3', 'd-4', 'e-5', 'f-6', + ] + ]) + b'\x00' + ), + ) +) +def test_ens_encode_name_validating_total_encoded_name_size(name, expected): + # This test is important because dns validation technically limits the total encoded domain name + # size to 255. ENSIP-10 expects the name to be DNS encoded with one of the validation exceptions + # being that the total encoded size can be any length. + ens_encoded = ens_encode_name(name) + assert len(ens_encoded) > 255 + assert ens_encoded == expected + + +@pytest.mark.parametrize('empty_name', ('', '.')) +def test_ens_encode_name_returns_single_zero_byte_for_empty_name(empty_name): + assert ens_encode_name(empty_name) == b'\00' + + +@pytest.mark.parametrize( + 'name,invalid_label_index', + ( + ('a' * 256, 0), + (f"{'a' * 256}.b", 0), + (f"a.{'a-b1' * 64}x", 1), + (f"{'a' * 256}.{'1' * 255}.{'b' * 255}", 0), + (f"{'a' * 255}.{'1' * 256}.{'b' * 255}", 1), + (f"{'a' * 255}.{'1' * 255}.{'b' * 256}", 2), + ) +) +def test_ens_encode_name_raises_ValidationError_on_label_lengths_over_63(name, invalid_label_index): + with pytest.raises(ValidationError, match=f'Label at position {invalid_label_index} too long'): + ens_encode_name(name) + + +def test_ens_encode_name_normalizes_name_before_encoding(): + assert ens_encode_name('Öbb.at') == ens_encode_name('öbb.at') + assert ens_encode_name('nhÉéÉéÉé.eth') == ens_encode_name('nhéééééé.eth') + assert ens_encode_name('TESTER.eth') == ens_encode_name('tester.eth') + assert ens_encode_name('test\u200btest.com') == ens_encode_name('testtest.com') + assert ens_encode_name("O\u0308bb.at") == ens_encode_name("öbb.at") From ec7be3cc5ca54b9d290343d3701b3174ad0ce6b1 Mon Sep 17 00:00:00 2001 From: Felipe Selmo Date: Thu, 28 Apr 2022 18:23:27 -0600 Subject: [PATCH 54/57] Improvements from comments in PR #2411 --- ens/main.py | 6 ++++-- tests/ens/test_get_text.py | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ens/main.py b/ens/main.py index 6f4d702516..d5c5759f7e 100644 --- a/ens/main.py +++ b/ens/main.py @@ -522,7 +522,7 @@ def _set_resolver( def _get_resolver( self, normal_name: str, - func: str = 'addr' + fn_name: str = 'addr' ) -> Tuple[Optional['Contract'], str]: current_name = normal_name @@ -537,7 +537,7 @@ def _get_resolver( resolver_addr = self.ens.caller.resolver(normal_name_to_hash(current_name)) if not is_none_or_zero_address(resolver_addr): # if resolver found, return it - return self._type_aware_resolver(resolver_addr, func), current_name + return self._type_aware_resolver(resolver_addr, fn_name), current_name # set current_name to parent and try again current_name = self.parent(current_name) @@ -548,6 +548,8 @@ def _decode_ensip10_resolve_data( func = extended_resolver.get_function_by_name(fn_name) output_types = get_abi_output_types(func.abi) decoded = self.w3.codec.decode_abi(output_types, contract_call_result) + + # if decoding a single value, return that value - else, return the tuple return decoded[0] if len(decoded) == 1 else decoded def _setup_reverse( diff --git a/tests/ens/test_get_text.py b/tests/ens/test_get_text.py index 54865cfc5a..db2624efe9 100644 --- a/tests/ens/test_get_text.py +++ b/tests/ens/test_get_text.py @@ -66,6 +66,9 @@ def test_get_text(ens, key, expected): ens.set_text('tester.eth', key, expected) assert ens.get_text('tester.eth', key) == expected + # teardown + ens.setup_address('tester.eth', None) + def test_get_text_resolver_not_found(ens): with pytest.raises(ResolverNotFound): From ede0f0371e6b47d464a6b224d0156e7d456d1a09 Mon Sep 17 00:00:00 2001 From: Felipe Selmo Date: Fri, 29 Apr 2022 14:18:32 -0600 Subject: [PATCH 55/57] Refactoring for ``resolve()`` and ``resolver()`` ENS methods - Make ``ENS.resolve()`` an internal method to provide a better user experience / less confusion. ``ENS.address()`` and ``ENS.name()`` should better abstract forward and backward resolution without the need to expose the ``resolve()`` method as part of the API. - Normalize the name being passed into ``ENS.resolver()`` since this is an exposed method for user input. This is done on other methods for the class but was not yet done for ``ENS.resolver()``. --- ens/main.py | 70 ++++++++++--------- ...resolve.py => test_wildcard_resolution.py} | 14 +--- 2 files changed, 40 insertions(+), 44 deletions(-) rename tests/ens/{test_resolve.py => test_wildcard_resolution.py} (74%) diff --git a/ens/main.py b/ens/main.py index d5c5759f7e..6db478e57f 100644 --- a/ens/main.py +++ b/ens/main.py @@ -152,7 +152,7 @@ def address(self, name: str) -> Optional[ChecksumAddress]: :param str name: an ENS name to look up :raises InvalidName: if `name` has invalid syntax """ - return cast(ChecksumAddress, self.resolve(name, 'addr')) + return cast(ChecksumAddress, self._resolve(name, 'addr')) def name(self, address: ChecksumAddress) -> Optional[str]: """ @@ -163,7 +163,7 @@ def name(self, address: ChecksumAddress) -> Optional[str]: :type address: hex-string """ reversed_domain = address_to_reverse_domain(address) - name = self.resolve(reversed_domain, fn_name='name') + name = self._resolve(reversed_domain, fn_name='name') # To be absolutely certain of the name, via reverse resolution, the address must match in # the forward resolution @@ -285,38 +285,14 @@ def setup_name( self.setup_address(name, address, transact=transact) return self._setup_reverse(name, address, transact=transact) - def resolver(self, normal_name: str) -> Optional['Contract']: - return self._get_resolver(normal_name)[0] + def resolver(self, name: str) -> Optional['Contract']: + """ + Get the resolver for an ENS name. - def resolve(self, name: str, fn_name: str = 'addr') -> Optional[Union[ChecksumAddress, str]]: + :param str name: The ENS name + """ normal_name = normalize_name(name) - - resolver, current_name = self._get_resolver(normal_name, fn_name) - if not resolver: - return None - - node = self.namehash(normal_name) - - if _resolver_supports_interface(resolver, EXTENDED_RESOLVER_INTERFACE_ID): - # update the resolver abi to the extended resolver abi - extended_resolver = self.w3.eth.contract(abi=abis.EXTENDED_RESOLVER)(resolver.address) - contract_func_with_args = (fn_name, [node]) - - calldata = extended_resolver.encodeABI(*contract_func_with_args) - contract_call_result = extended_resolver.caller.resolve( - ens_encode_name(normal_name), calldata - ) - result = self._decode_ensip10_resolve_data( - contract_call_result, extended_resolver, fn_name - ) - return to_checksum_address(result) if is_address(result) else result - elif normal_name == current_name: - lookup_function = getattr(resolver.functions, fn_name) - result = lookup_function(node).call() - if is_none_or_zero_address(result): - return None - return to_checksum_address(result) if is_address(result) else result - return None + return self._get_resolver(normal_name)[0] def reverser(self, target_address: ChecksumAddress) -> Optional['Contract']: reversed_domain = address_to_reverse_domain(target_address) @@ -456,6 +432,36 @@ def setup_owner( self._claim_ownership(new_owner, unowned, owned, super_owner, transact=transact) return new_owner + def _resolve(self, name: str, fn_name: str = 'addr') -> Optional[Union[ChecksumAddress, str]]: + normal_name = normalize_name(name) + + resolver, current_name = self._get_resolver(normal_name, fn_name) + if not resolver: + return None + + node = self.namehash(normal_name) + + if _resolver_supports_interface(resolver, EXTENDED_RESOLVER_INTERFACE_ID): + # update the resolver abi to the extended resolver abi + extended_resolver = self.w3.eth.contract(abi=abis.EXTENDED_RESOLVER)(resolver.address) + contract_func_with_args = (fn_name, [node]) + + calldata = extended_resolver.encodeABI(*contract_func_with_args) + contract_call_result = extended_resolver.caller.resolve( + ens_encode_name(normal_name), calldata + ) + result = self._decode_ensip10_resolve_data( + contract_call_result, extended_resolver, fn_name + ) + return to_checksum_address(result) if is_address(result) else result + elif normal_name == current_name: + lookup_function = getattr(resolver.functions, fn_name) + result = lookup_function(node).call() + if is_none_or_zero_address(result): + return None + return to_checksum_address(result) if is_address(result) else result + return None + def _assert_control(self, account: ChecksumAddress, name: str, parent_owned: Optional[str] = None) -> None: if not address_in(account, self.w3.eth.accounts): diff --git a/tests/ens/test_resolve.py b/tests/ens/test_wildcard_resolution.py similarity index 74% rename from tests/ens/test_resolve.py rename to tests/ens/test_wildcard_resolution.py index 00459506c1..bf1a658ffe 100644 --- a/tests/ens/test_resolve.py +++ b/tests/ens/test_wildcard_resolution.py @@ -1,22 +1,12 @@ import pytest -def test_resolve(ens): - acct = ens.w3.eth.accounts[2] - ens.setup_address('tester.eth', acct) - - assert ens.resolve('tester.eth') == acct - - # clean up - ens.setup_address('tester.eth', None) - - @pytest.mark.parametrize('subdomain', ('sub1', 'sub2', 'rändöm', '🌈rainbow', 'faß')) def test_wildcard_resolution_with_extended_resolver_for_subdomains(ens, subdomain): # validate subdomains of `extended-resolver.eth` by asserting it returns the specified # hard-coded address from `tests/test_contracts/ExtendedResolver.sol` which requires # certain conditions to be met that are specific to subdomains only - resolved_child_address = ens.resolve(f'{subdomain}.extended-resolver.eth') + resolved_child_address = ens.address(f'{subdomain}.extended-resolver.eth') assert resolved_child_address == '0x000000000000000000000000000000000000dEaD' @@ -24,5 +14,5 @@ def test_wildcard_resolution_with_extended_resolver_for_parent_ens_domain(ens): # validate `extended-resolver.eth` by asserting it returns the specified hard-coded address from # `tests/test_contracts/ExtendedResolver.sol` which requires a specific condition to be # met for the parent domain `extended-resolver.eth` - resolved_parent_address = ens.resolve('extended-resolver.eth') + resolved_parent_address = ens.address('extended-resolver.eth') assert resolved_parent_address == '0x000000000000000000000000000000000000bEEF' From fe36d83b7c4d184b44dc033189f635c5bd5a46b2 Mon Sep 17 00:00:00 2001 From: Felipe Selmo Date: Fri, 29 Apr 2022 14:21:03 -0600 Subject: [PATCH 56/57] Updates to ENS documentation --- docs/ens_overview.rst | 172 ++++++++++++++++++++++++++---------------- 1 file changed, 106 insertions(+), 66 deletions(-) diff --git a/docs/ens_overview.rst b/docs/ens_overview.rst index f01a4e38c0..94c33a0198 100644 --- a/docs/ens_overview.rst +++ b/docs/ens_overview.rst @@ -1,7 +1,7 @@ .. _ens_overview: Ethereum Name Service -================================ +===================== The Ethereum Name Service is analogous to the Domain Name Service. It enables users and developers to use human-friendly names in place of error-prone @@ -19,12 +19,11 @@ Create an :class:`~ens.main.ENS` object (named ``ns`` below) in one of three way 2. Specify an instance or list of :ref:`providers` 3. From an existing :class:`web3.Web3` object -:: +.. code-block:: python # automatic detection from ens.auto import ns - # or, with a provider from web3 import IPCProvider from ens import ENS @@ -32,125 +31,111 @@ Create an :class:`~ens.main.ENS` object (named ``ns`` below) in one of three way provider = IPCProvider(...) ns = ENS(provider) - # or, with a w3 instance # Note: This inherits the w3 middlewares from the w3 instance and adds a stalecheck middleware to the middleware onion from ens import ENS - w3 = Web3(...) ns = ENS.fromWeb3(w3) +.... Usage ----- -Name info +Name Info ~~~~~~~~~ .. _ens_get_address: -Look up the address for an ENS name -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Get the Address for an ENS Name +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: python from ens.auto import ns - - - # look up the hex representation of the address for a name - eth_address = ns.address('jasoncarver.eth') - assert eth_address == '0x5B2063246F2191f18F2675ceDB8b28102e957458' - The ``ENS`` module has no opinion as to which TLD you can use, but will not infer a TLD if it is not provided with the name. +Get the ENS Name for an Address +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Get name from address -^^^^^^^^^^^^^^^^^^^^^ - -:: +.. code-block:: python domain = ns.name('0x5B2063246F2191f18F2675ceDB8b28102e957458') - # name() also accepts the bytes version of the address - assert ns.name(b'[ c$o!\x91\xf1\x8f&u\xce\xdb\x8b(\x10.\x95tX') == domain - # confirm that the name resolves back to the address that you looked up: - assert ns.address(domain) == '0x5B2063246F2191f18F2675ceDB8b28102e957458' -Get owner of name -^^^^^^^^^^^^^^^^^ +.. note:: For accuracy, and as a recommendation from the ENS documentation on + `reverse resolution `_, + the ``ENS`` module now verifies that the forward resolution matches the address with every call to get the + ``name()`` for an address. This is the only sure way to know whether the reverse resolution is correct. Anyone can + claim any name, only forward resolution implies that the owner of the name gave their stamp of approval. -:: +Get the Owner of a Name +^^^^^^^^^^^^^^^^^^^^^^^ + +.. code-block:: python eth_address = ns.owner('exchange.eth') -Set up your name -~~~~~~~~~~~~~~~~ +.... -Point your name to your address -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Set Up Your Name and Address +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Do you want to set up your name so that :meth:`~ens.main.ENS.address` will show the -address it points to? +Link a Name to an Address +^^^^^^^^^^^^^^^^^^^^^^^^^ -:: +You can set up your name so that :meth:`~ens.main.ENS.address` will show the address it points to. In order to do so, +you must already be the owner of the domain (or its parent). - ns.setup_address('jasoncarver.eth', '0x5B2063246F2191f18F2675ceDB8b28102e957458') +.. code-block:: python -You must already be the owner of the domain (or its parent). + ns.setup_address('jasoncarver.eth', '0x5B2063246F2191f18F2675ceDB8b28102e957458') -In the common case where you want to point the name to the owning -address, you can skip the address +In the common case where you want to point the name to the owning address, you can skip the address. -:: +.. code-block:: python ns.setup_address('jasoncarver.eth') -You can claim arbitrarily deep subdomains. *Gas costs scale up with the -number of subdomains!* +You can claim arbitrarily deep subdomains. -:: +.. code-block:: python ns.setup_address('supreme.executive.power.derives.from.a.mandate.from.the.masses.jasoncarver.eth') -Wait for the transaction to be mined, then: - -:: + # wait for the transaction to be mined, then: + assert ( + ns.address('supreme.executive.power.derives.from.a.mandate.from.the.masses.jasoncarver.eth') + == '0x5B2063246F2191f18F2675ceDB8b28102e957458' + ) - assert ns.address('supreme.executive.power.derives.from.a.mandate.from.the.masses.jasoncarver.eth') == \ - '0x5B2063246F2191f18F2675ceDB8b28102e957458' +.. warning:: Gas costs scale up with the number of subdomains! -Allow people to find your name using your address -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Link an Address to a Name +^^^^^^^^^^^^^^^^^^^^^^^^^ -Do you want to set up your address so that :meth:`~ens.main.ENS.name` will show the -name that points to it? +You can set up your address so that :meth:`~ens.main.ENS.name` will show the name that points to it. -This is like Caller ID. It enables you and others to take an account and -determine what name points to it. Sometimes this is referred to as -"reverse" resolution. +This is like Caller ID. It enables you and others to take an account and determine what name points to it. Sometimes +this is referred to as "reverse" resolution. The ENS Reverse Resolver is used for this functionality. -:: +.. code-block:: python ns.setup_name('jasoncarver.eth', '0x5B2063246F2191f18F2675ceDB8b28102e957458') -.. note:: Do not rely on reverse resolution for security. - - Anyone can claim any "caller ID". Only forward resolution implies that - the owner of the name gave their stamp of approval. - If you don't supply the address, :meth:`~ens.main.ENS.setup_name` will assume you want the address returned by :meth:`~ens.main.ENS.address`. -:: +.. code-block:: python ns.setup_name('jasoncarver.eth') @@ -159,26 +144,31 @@ call :meth:`~ens.main.ENS.setup_address` for you. Wait for the transaction to be mined, then: -:: +.. code-block:: python assert ns.name('0x5B2063246F2191f18F2675ceDB8b28102e957458') == 'jasoncarver.eth' +.... + +Text Records +~~~~~~~~~~~~ + Set Text Metadata for an ENS Record -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ As the owner of an ENS record, you can add text metadata. A list of supported fields can be found in the `ENS documentation `_. You'll need to setup the address first, and then the text can be set: -:: +.. code-block:: python ns.setup_address('jasoncarver.eth', 0x5B2063246F2191f18F2675ceDB8b28102e957458) ns.set_text('jasoncarver.eth', 'url', 'https://example.com') A transaction dictionary can be passed as the last argument if desired: -:: +.. code-block:: python transaction_dict = {'from': '0x123...'} ns.set_text('jasoncarver.eth', 'url', 'https://example.com', transaction_dict) @@ -188,11 +178,61 @@ a transaction dictionary is passed but does not have a ``from`` value, the default will be the ``owner``. Read Text Metadata for an ENS Record -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Anyone can read the data from an ENS Record: -:: +.. code-block:: python url = ns.get_text('jasoncarver.eth', 'url') assert url == 'https://example.com' + +.... + +Working With Resolvers +~~~~~~~~~~~~~~~~~~~~~~ + +Get the Resolver for an ENS Record +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +You can get the resolver for an ENS name via the :meth:`~ens.main.ENS.resolver` method. + +.. code-block:: python + + >>> resolver = ns.resolver('jasoncarver.eth') + >>> resolver.address + '0x5FfC014343cd971B7eb70732021E26C35B744cc4' + +.... + +Wildcard Resolution Support +--------------------------- + +The ``ENS`` module supports Wildcard Resolution for resolvers that implement the ``ExtendedResolver`` interface +as described in `ENSIP-10 `_. +Resolvers that implement the extended resolver interface should return ``True`` when calling the +``supportsInterface()`` function with the extended resolver interface id ``0x9061b923`` and should resolve subdomains +to a unique address. + +A working example of a resolver that supports wildcard resolution is the resolver for the ``hatch.eth`` record on the +Ropsten testnet. + +.. code-block:: python + + # connect to the Ropsten testnet + >>> w3 = Web3(WebsocketProvider("wss://{ropsten_provider}")) + >>> ns = ENS.fromWeb3(w3) + + # get the resolver for `hatch.eth` + >>> resolver = ns.resolver('hatch.eth') + >>> resolver.address + '0x8fc4C380c5d539aE631daF3Ca9182b40FB21D1ae' + + # verify extended resolver interface support + >>> resolver.caller.supportsInterface('0x9061b923') + True + + >>> ns.address('random-subdomain.hatch.eth') + '0x49D4c4ff230688e4A357bc057e7E35e64d271939' + >>> ns.address('another-random-subdomain.hatch.eth') + '0xb35359B6450B0CbC9BE15A4eE6bcb8c5b0d9fC4A' From ee360407a70674e293d0a4f775ab6f5dbdae602e Mon Sep 17 00:00:00 2001 From: DB Date: Wed, 4 May 2022 05:35:44 -0400 Subject: [PATCH 57/57] fixing docs that I updated accidently --- docs/web3.eth.rst | 237 ++++++++++++++++++++++++++++++++++++++++++++- docs/web3.geth.rst | 77 ++++++++++++++- 2 files changed, 311 insertions(+), 3 deletions(-) diff --git a/docs/web3.eth.rst b/docs/web3.eth.rst index b1b419c267..35dec1c5bf 100644 --- a/docs/web3.eth.rst +++ b/docs/web3.eth.rst @@ -51,11 +51,25 @@ The following properties are available on the ``web3.eth`` namespace. The ethereum address that will be used as the default ``from`` address for all transactions. Defaults to empty. + +.. py:attribute:: Eth.defaultAccount + + .. warning:: Deprecated: This property is deprecated in favor of + :attr:`~web3.eth.Eth.default_account` + + .. py:attribute:: Eth.default_block The default block number that will be used for any RPC methods that accept a block identifier. Defaults to ``'latest'``. + +.. py:attribute:: Eth.defaultBlock + + .. warning:: Deprecated: This property is deprecated in favor of + :attr:`~web3.eth.Eth.default_block` + + .. py:attribute:: Eth.syncing * Delegates to ``eth_syncing`` RPC Method @@ -134,6 +148,13 @@ The following properties are available on the ``web3.eth`` namespace. >>> web3.eth.gas_price 20000000000 + +.. py:attribute:: Eth.gasPrice + + .. warning:: Deprecated: This property is deprecated in favor of + :attr:`~web3.eth.Eth.gas_price` + + .. py:attribute:: Eth.accounts * Delegates to ``eth_accounts`` RPC Method @@ -159,6 +180,31 @@ The following properties are available on the ``web3.eth`` namespace. >>> web3.eth.block_number 2206939 + +.. py:attribute:: Eth.blockNumber + + .. warning:: Deprecated: This property is deprecated in favor of + :attr:`~web3.eth.Eth.block_number` + + +.. py:attribute:: Eth.protocol_version + + * Delegates to ``eth_protocolVersion`` RPC Method + + Returns the id of the current Ethereum protocol version. + + .. code-block:: python + + >>> web3.eth.protocol_version + '63' + + +.. py:attribute:: Eth.protocolVersion + + .. warning:: Deprecated: This property is deprecated in favor of + :attr:`~web3.eth.Eth.protocol_version` + + .. py:attribute:: Eth.chain_id * Delegates to ``eth_chainId`` RPC Method @@ -170,6 +216,25 @@ The following properties are available on the ``web3.eth`` namespace. >>> web3.eth.chain_id 61 + .. note:: + + This property gets called frequently in validation middleware, + but `chain_id` is added to the ``simple_cache_middleware`` by default. + Add the :meth:`simple_cache_middleware` + to the ``middleware_onion`` to increase performance: + + .. code-block:: python + + >>> from web3.middleware import simple_cache_middleware + >>> w3.middleware_onion.add(simple_cache_middleware) + + +.. py:attribute:: Eth.chainId + + .. warning:: Deprecated: This property is deprecated in favor of + :attr:`~web3.eth.chain_id` + + Methods ------- @@ -191,6 +256,13 @@ The following methods are available on the ``web3.eth`` namespace. >>> web3.eth.get_balance('0xd3CdA913deB6f67967B99D67aCDFa1712C293601') 77320681768999138915 + +.. py:method:: Eth.getBalance(account, block_identifier=eth.default_block) + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.eth.get_balance()` + + .. py:method:: Eth.get_block_number() * Delegates to ``eth_blockNumber`` RPC Method @@ -217,6 +289,13 @@ The following methods are available on the ``web3.eth`` namespace. >>> web3.eth.get_storage_at('0x6C8f2A135f6ed072DE4503Bd7C4999a1a17F824B', 0) '0x00000000000000000000000000000000000000000000000000120a0b063499d4' + +.. py:method:: Eth.getStorageAt(account, position, block_identifier=eth.default_block) + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.eth.Eth.get_storage_at` + + .. py:method:: Eth.get_proof(account, positions, block_identifier=eth.default_block) * Delegates to ``eth_getProof`` RPC Method @@ -297,7 +376,7 @@ The following methods are available on the ``web3.eth`` namespace. assert rlp_account == HexaryTrie.get_from_proof( root, trie_key, format_proof_nodes(proof.accountProof) - ), "Failed to verify account proof {}".format(proof.address) + ), f"Failed to verify account proof {proof.address}" for storage_proof in proof.storageProof: trie_key = keccak(pad_bytes(b'\x00', 32, storage_proof.key)) @@ -309,7 +388,7 @@ The following methods are available on the ``web3.eth`` namespace. assert rlp_value == HexaryTrie.get_from_proof( root, trie_key, format_proof_nodes(storage_proof.proof) - ), "Failed to verify storage proof {}".format(storage_proof.key) + ), f"Failed to verify storage proof {storage_proof.key}" return True @@ -317,6 +396,12 @@ The following methods are available on the ``web3.eth`` namespace. proof = w3.eth.get_proof('0x6C8f2A135f6ed072DE4503Bd7C4999a1a17F824B', [0, 1], 3391) assert verify_eth_get_proof(proof, block.stateRoot) + +.. py:method:: Eth.getProof(account, positions, block_identifier=eth.default_block) + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.eth.Eth.get_proof` + .. py:method:: Eth.get_code(account, block_identifier=eth.default_block) * Delegates to ``eth_getCode`` RPC Method @@ -335,6 +420,12 @@ The following methods are available on the ``web3.eth`` namespace. >>> web3.eth.get_code('0xd3CdA913deB6f67967B99D67aCDFa1712C293601') '0x' + +.. py:method:: Eth.getCode(account, block_identifier=eth.default_block) + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.eth.Eth.get_code` + .. py:method:: Eth.get_block(block_identifier=eth.default_block, full_transactions=False) * Delegates to ``eth_getBlockByNumber`` or ``eth_getBlockByHash`` RPC Methods @@ -373,6 +464,11 @@ The following methods are available on the ``web3.eth`` namespace. 'uncles': [], }) +.. py:method:: Eth.getBlock(block_identifier=eth.default_block, full_transactions=False) + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.eth.Eth.get_block` + .. py:method:: Eth.get_block_transaction_count(block_identifier) * Delegates to ``eth_getBlockTransactionCountByNumber`` or @@ -391,6 +487,20 @@ The following methods are available on the ``web3.eth`` namespace. >>> web3.eth.get_block_transaction_count('0x4e3a3754410177e6937ef1f84bba68ea139e8d1a2258c5f85db9f1cd715a1bdd') # block 46147 1 + +.. py:method:: Eth.getBlockTransactionCount(block_identifier) + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.eth.Eth.get_block_transaction_count` + + + +.. py:method:: Eth.getUncle(block_identifier) + + .. note:: Method to get an Uncle from its hash is not available through + RPC, a possible substitute is the method ``Eth.get_uncle_by_block`` + + .. py:method:: Eth.get_uncle_by_block(block_identifier, uncle_index) * Delegates to ``eth_getUncleByBlockHashAndIndex`` or @@ -436,6 +546,11 @@ The following methods are available on the ``web3.eth`` namespace. ... }) +.. py:method:: Eth.getUncleByBlock(block_identifier, uncle_index) + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.eth.Eth.get_uncle_by_block()` + .. py:method:: Eth.get_uncle_count(block_identifier) * Delegates to ``eth_getUncleCountByBlockHash`` or @@ -456,6 +571,11 @@ The following methods are available on the ``web3.eth`` namespace. >>> web3.eth.get_uncle_count('0x685b2226cbf6e1f890211010aa192bf16f0a0cba9534264a033b023d7367b845') 1 +.. py:method:: Eth.getUncleCount(block_identifier) + + .. warning:: Deprecated: This method is deprecated in favor of + :attr:`~web3.eth.Eth.get_uncle_count()` + .. py:method:: Eth.get_transaction(transaction_hash) * Delegates to ``eth_getTransactionByHash`` RPC Method @@ -482,6 +602,12 @@ The following methods are available on the ``web3.eth`` namespace. }) +.. py:method:: Eth.getTransaction(transaction_hash) + + .. warning:: Deprecated: This method is deprecated in favor of + :attr:`~web3.eth.Eth.get_transaction` + + .. py:method:: Eth.get_raw_transaction(transaction_hash) * Delegates to ``eth_getRawTransactionByHash`` RPC Method @@ -549,6 +675,11 @@ The following methods are available on the ``web3.eth`` namespace. 'value': 31337, }) +.. py:method:: Eth.getTransactionByBlock(block_identifier, transaction_index) + + .. warning:: Deprecated: This method is deprecated in favor of + :attr:`~web3.eth.Eth.get_transaction_by_block` + .. py:method:: Eth.get_raw_transaction_by_block(block_identifier, transaction_index) * Delegates to ``eth_getRawTransactionByBlockNumberAndIndex`` or @@ -601,6 +732,12 @@ The following methods are available on the ``web3.eth`` namespace. 'transactionIndex': 0, }) + +.. 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 @@ -632,6 +769,11 @@ The following methods are available on the ``web3.eth`` namespace. 'transactionIndex': 0, }) +.. py:method:: Eth.getTransactionReceipt(transaction_hash) + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.eth.Eth.get_transaction_receipt()` + .. py:method:: Eth.get_transaction_count(account, block_identifier=web3.eth.default_block) * Delegates to ``eth_getTransactionCount`` RPC Method @@ -646,6 +788,13 @@ The following methods are available on the ``web3.eth`` namespace. >>> web3.eth.get_transaction_count('0xd3CdA913deB6f67967B99D67aCDFa1712C293601') 340 + +.. py:method:: Eth.getTransactionCount(account, block_identifier=web3.eth.default_block) + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.eth.Eth.get_transaction_count()` + + .. py:method:: Eth.send_transaction(transaction) * Delegates to ``eth_sendTransaction`` RPC Method @@ -717,6 +866,11 @@ The following methods are available on the ``web3.eth`` namespace. }) HexBytes('0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331') +.. py:method:: Eth.sendTransaction(transaction) + + .. warning:: Deprecated: This method is deprecated in favor of + :attr:`~web3.eth.Eth.send_transaction()` + .. py:method:: Eth.sign_transaction(transaction) * Delegates to ``eth_signTransaction`` RPC Method. @@ -738,6 +892,12 @@ The following methods are available on the ``web3.eth`` namespace. ) b"\xf8d\x80\x85\x040\xe24\x00\x82R\x08\x94\xdcTM\x1a\xa8\x8f\xf8\xbb\xd2\xf2\xae\xc7T\xb1\xf1\xe9\x9e\x18\x12\xfd\x01\x80\x1b\xa0\x11\r\x8f\xee\x1d\xe5=\xf0\x87\x0en\xb5\x99\xed;\xf6\x8f\xb3\xf1\xe6,\x82\xdf\xe5\x97lF|\x97%;\x15\xa04P\xb7=*\xef \t\xf0&\xbc\xbf\tz%z\xe7\xa3~\xb5\xd3\xb7=\xc0v\n\xef\xad+\x98\xe3'" # noqa: E501 + +.. py:method:: Eth.signTransaction(transaction) + + .. warning:: Deprecated: This method is deprecated in favor of + :attr:`~web3.eth.Eth.sign_transaction()` + .. py:method:: Eth.send_raw_transaction(raw_transaction) * Delegates to ``eth_sendRawTransaction`` RPC Method @@ -762,6 +922,11 @@ The following methods are available on the ``web3.eth`` namespace. >>> w3.eth.send_raw_transaction(signed_txn.rawTransaction) HexBytes('0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331') +.. py:method:: Eth.sendRawTransaction(raw_transaction) + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.eth.Eth.send_raw_transaction()` + .. py:method:: Eth.replace_transaction(transaction_hash, new_transaction) * Delegates to ``eth_sendTransaction`` RPC Method @@ -817,6 +982,11 @@ The following methods are available on the ``web3.eth`` namespace. }) HexBytes('0x4177e670ec6431606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1528989') +.. py:method:: Eth.replaceTransaction(transaction_hash, new_transaction) + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.eth.Eth.replace_transaction()` + .. py:method:: Eth.modify_transaction(transaction_hash, **transaction_params) * Delegates to ``eth_sendTransaction`` RPC Method @@ -843,6 +1013,11 @@ The following methods are available on the ``web3.eth`` namespace. >>> web3.eth.modify_transaction('0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331', value=2000) HexBytes('0xec6434e6701771606e55d6b4ca35a1a6b75ee3d73315145a921026d15299d05') +.. py:method:: Eth.modifyTransaction(transaction_hash, **transaction_params) + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.eth.Eth.modify_transaction()` + .. py:method:: Eth.sign(account, data=None, hexstr=None, text=None) * Delegates to ``eth_sign`` RPC Method @@ -884,6 +1059,11 @@ 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, state_override=None) * Delegates to ``eth_call`` RPC Method @@ -965,6 +1145,11 @@ The following methods are available on the ``web3.eth`` namespace. >>> web3.eth.estimate_gas({'to': '0xd3CdA913deB6f67967B99D67aCDFa1712C293601', 'from':web3.eth.coinbase, 'value': 12345}) 21000 +.. py:method:: Eth.estimateGas(transaction, block_identifier=None) + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.eth.Eth.estimate_gas()` + .. py:method:: Eth.generate_gas_price(transaction_params=None) Uses the selected gas price strategy to calculate a gas price. This method @@ -982,11 +1167,21 @@ The following methods are available on the ``web3.eth`` namespace. 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.set_gas_price_strategy(gas_price_strategy) Set the selected gas price strategy. It must be a method of the signature ``(web3, transaction_params)`` and return a gas price denominated in wei. +.. py:method:: Eth.setGasPriceStrategy(gas_price_strategy) + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.eth.Eth.set_gas_price_strategy()` + Filters ------- @@ -1075,6 +1270,12 @@ with the filtering API. ] +.. py:method:: Eth.getFilterChanges(self, filter_id) + + .. warning:: Deprecated: This property is deprecated in favor of + :meth:`~web3.eth.Eth.get_filter_changes()` + + .. py:method:: Eth.get_filter_logs(self, filter_id) * Delegates to ``eth_getFilterLogs`` RPC Method. @@ -1101,6 +1302,13 @@ with the filtering API. ... ] + +.. 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. @@ -1116,6 +1324,11 @@ with the filtering API. >>> web3.eth.uninstall_filter(filt.filter_id) False # already uninstalled. +.. py:method:: Eth.uninstallFilter(self, filter_id) + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.eth.Eth.uninstall_filter` + .. py:method:: Eth.get_logs(filter_params) @@ -1123,6 +1336,11 @@ with the filtering API. 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) + + .. 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 @@ -1133,6 +1351,11 @@ with the filtering API. >>> web3.eth.submit_hashrate(5000, node_id) True +.. py:method:: Eth.submitHashrate(hashrate, nodeid) + + .. 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. @@ -1146,6 +1369,11 @@ with the filtering API. ) 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 --------- @@ -1217,3 +1445,8 @@ Contracts Future calls to ``Eth.contract()`` will then default to ``contractFactoryClass``. An example of an alternative Contract Factory is ``ConciseContract``. + +.. py:method:: Eth.setContractFactory(contractFactoryClass) + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.eth.Eth.set_contract_factory()` \ No newline at end of file diff --git a/docs/web3.geth.rst b/docs/web3.geth.rst index 3922cef3cd..c07d0fb176 100644 --- a/docs/web3.geth.rst +++ b/docs/web3.geth.rst @@ -54,6 +54,12 @@ The ``web3.geth.admin`` object exposes methods to interact with the RPC APIs und } +.. py:method:: nodeInfo() + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.geth.admin.node_info()` + + .. py:method:: peers() * Delegates to ``admin_peers`` RPC Method @@ -111,6 +117,11 @@ The ``web3.geth.admin`` object exposes methods to interact with the RPC APIs und >>> web3.geth.admin.add_peer('enode://e54eebad24dce1f6d246bea455ffa756d97801582420b9ed681a2ea84bf376d0bd87ae8dd6dc06cdb862a2ca89ecabe1be1050be35b4e70d62bc1a092cb7e2d3@52.71.255.237:30303') True + +.. py:method:: addPeer(node_url) + + .. warning:: Deprecated: This method is deprecated in favor of :meth:`~web3.geth.admin.add_peer()` + .. py:method:: start_rpc(host='localhost', port=8545, cors="", apis="eth,net,web3") * Delegates to ``admin_startRPC`` RPC Method @@ -125,6 +136,13 @@ The ``web3.geth.admin`` object exposes methods to interact with the RPC APIs und >>> web3.geth.admin.start_rpc() True + +.. py:method:: startRPC(host='localhost', port=8545, cors="", apis="eth,net,web3") + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.geth.admin.start_rpc()` + + .. py:method:: start_ws(host='localhost', port=8546, cors="", apis="eth,net,web3") * Delegates to ``admin_startWS`` RPC Method @@ -139,6 +157,13 @@ The ``web3.geth.admin`` object exposes methods to interact with the RPC APIs und >>> web3.geth.admin.start_ws() True + +.. py:method:: startWS(host='localhost', port=8546, cors="", apis="eth,net,web3") + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.geth.admin.start_ws()` + + .. py:method:: stop_rpc() * Delegates to ``admin_stopRPC`` RPC Method @@ -151,6 +176,12 @@ The ``web3.geth.admin`` object exposes methods to interact with the RPC APIs und True +.. py:method:: stopRPC() + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.geth.admin.stop_rpc()` + + .. py:method:: stop_ws() * Delegates to ``admin_stopWS`` RPC Method @@ -162,6 +193,13 @@ The ``web3.geth.admin`` object exposes methods to interact with the RPC APIs und >>> web3.geth.admin.stop_ws() True + +.. py:method:: stopWS() + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.geth.admin.stop_ws()` + + .. py:module:: web3.geth.personal GethPersonal API @@ -181,6 +219,12 @@ The following methods are available on the ``web3.geth.personal`` namespace. ['0xd3CdA913deB6f67967B99D67aCDFa1712C293601'] +.. py:method:: listAccounts() + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.geth.personal.list_accounts()` + + .. py:method:: list_wallets() * Delegates to ``personal_listWallets`` RPC Method @@ -213,6 +257,12 @@ The following methods are available on the ``web3.geth.personal`` namespace. '0xd3CdA913deB6f67967B99D67aCDFa1712C293601' +.. py:method:: importRawKey() + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.geth.personal.import_raw_key()` + + .. py:method:: new_account(self, passphrase) * Delegates to ``personal_newAccount`` RPC Method @@ -226,6 +276,12 @@ The following methods are available on the ``web3.geth.personal`` namespace. '0xd3CdA913deB6f67967B99D67aCDFa1712C293601' +.. py:method:: newAccount() + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.geth.personal.new_account()` + + .. py:method:: lock_account(self, account) * Delegates to ``personal_lockAccount`` RPC Method @@ -237,6 +293,12 @@ The following methods are available on the ``web3.geth.personal`` namespace. >>> web3.geth.personal.lock_account('0xd3CdA913deB6f67967B99D67aCDFa1712C293601') +.. py:method:: lockAccount() + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.geth.personal.lock_account()` + + .. py:method:: unlock_account(self, account, passphrase, duration=None) * Delegates to ``personal_unlockAccount`` RPC Method @@ -255,12 +317,25 @@ The following methods are available on the ``web3.geth.personal`` namespace. True +.. py:method:: unlockAccount() + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.geth.personal.unlock_account()` + + .. py:method:: send_transaction(self, transaction, passphrase) * Delegates to ``personal_sendTransaction`` RPC Method Sends the transaction. + +.. py:method:: sendTransaction() + + .. warning:: Deprecated: This method is deprecated in favor of + :meth:`~web3.geth.personal.send_transaction()` + + .. py:module:: web3.geth.txpool GethTxPool API @@ -461,4 +536,4 @@ The following methods are available on the ``web3.geth.txpool`` namespace. }], } } - } + } \ No newline at end of file