diff --git a/python-packages/contract_wrappers/setup.py b/python-packages/contract_wrappers/setup.py index 838d932db8..0bb2c4e527 100755 --- a/python-packages/contract_wrappers/setup.py +++ b/python-packages/contract_wrappers/setup.py @@ -246,11 +246,9 @@ def run(self): "0x-contract-artifacts", "0x-json-schemas", "0x-order-utils", - "0x-web3", + "web3", "attrs", "eth_utils", - "hypothesis>=3.31.2", # HACK! this is web3's dependency! - # above works around https://github.com/ethereum/web3.py/issues/1179 "mypy_extensions", ], extras_require={ diff --git a/python-packages/contract_wrappers/src/zero_ex/contract_wrappers/__init__.py b/python-packages/contract_wrappers/src/zero_ex/contract_wrappers/__init__.py index 208187869a..b164578050 100644 --- a/python-packages/contract_wrappers/src/zero_ex/contract_wrappers/__init__.py +++ b/python-packages/contract_wrappers/src/zero_ex/contract_wrappers/__init__.py @@ -32,8 +32,8 @@ >>> from web3 import Web3 >>> accounts = Web3(ganache).eth.accounts ->>> maker_address = accounts[0].lower() ->>> taker_address = accounts[1].lower() +>>> maker_address = accounts[0] +>>> taker_address = accounts[1] In the examples below, we'll use the optional `tx_params`:code: parameter to the contract calls, in order to specify which account each transaction is to diff --git a/python-packages/contract_wrappers/stubs/web3/__init__.pyi b/python-packages/contract_wrappers/stubs/web3/__init__.pyi index 82e638b479..ab531c1e73 100644 --- a/python-packages/contract_wrappers/stubs/web3/__init__.pyi +++ b/python-packages/contract_wrappers/stubs/web3/__init__.pyi @@ -3,7 +3,7 @@ from typing import Any, Callable, Dict, List, Optional, Union from hexbytes import HexBytes from eth_account.local import LocalAccount from web3 import datastructures -from web3.utils import datatypes +from web3.contract import Contract from web3.providers.base import BaseProvider @@ -47,7 +47,7 @@ class Web3: def getTransactionReceipt(tx_hash: Union[HexBytes, bytes]) -> Any: ... @staticmethod - def contract(address: str, abi: Dict) -> datatypes.Contract: ... + def contract(address: str, abi: Dict) -> Contract: ... ... @staticmethod diff --git a/python-packages/contract_wrappers/stubs/web3/contract.pyi b/python-packages/contract_wrappers/stubs/web3/contract.pyi index 3078722ba2..6f575e5b39 100644 --- a/python-packages/contract_wrappers/stubs/web3/contract.pyi +++ b/python-packages/contract_wrappers/stubs/web3/contract.pyi @@ -1,3 +1,15 @@ +from typing import Any + + +class Contract: + def call(self): ... + + functions: Any + + events: Any + ... + + class ContractFunction: def __call__(self, *args, **kwargs): ... diff --git a/python-packages/contract_wrappers/stubs/web3/utils/datatypes.pyi b/python-packages/contract_wrappers/stubs/web3/utils/datatypes.pyi deleted file mode 100644 index f4d350d897..0000000000 --- a/python-packages/contract_wrappers/stubs/web3/utils/datatypes.pyi +++ /dev/null @@ -1,10 +0,0 @@ -from typing import Any - - -class Contract: - def call(self): ... - - functions: Any - - events: Any - ... diff --git a/python-packages/contract_wrappers/test/test_exchange_wrapper.py b/python-packages/contract_wrappers/test/test_exchange_wrapper.py index 4f2b70a079..b8a6a01788 100644 --- a/python-packages/contract_wrappers/test/test_exchange_wrapper.py +++ b/python-packages/contract_wrappers/test/test_exchange_wrapper.py @@ -30,7 +30,7 @@ def create_test_order( ): """Create a test order.""" order = Order( - makerAddress=maker_address.lower(), + makerAddress=maker_address, takerAddress="0x0000000000000000000000000000000000000000", feeRecipientAddress="0x0000000000000000000000000000000000000000", senderAddress="0x0000000000000000000000000000000000000000", diff --git a/python-packages/middlewares/setup.py b/python-packages/middlewares/setup.py index 572f29c02f..1477b5e6fd 100755 --- a/python-packages/middlewares/setup.py +++ b/python-packages/middlewares/setup.py @@ -155,15 +155,13 @@ def run(self): "eth-account", "eth-keys", "hexbytes", - "hypothesis>=3.31.2", # HACK! this is web3's dependency! - # above works around https://github.com/ethereum/web3.py/issues/1179 "mypy_extensions", ], extras_require={ "dev": [ "0x-contract-addresses", "0x-order-utils", - "0x-web3", + "web3", "bandit", "black", "coverage", diff --git a/python-packages/middlewares/src/zero_ex/middlewares/local_message_signer.py b/python-packages/middlewares/src/zero_ex/middlewares/local_message_signer.py index 618446e5cd..2ebb94b73a 100644 --- a/python-packages/middlewares/src/zero_ex/middlewares/local_message_signer.py +++ b/python-packages/middlewares/src/zero_ex/middlewares/local_message_signer.py @@ -9,7 +9,7 @@ from functools import singledispatch from typing import Dict, List, Set, Tuple, Union from eth_account import Account, messages -from eth_account.local import LocalAccount +from eth_account.signers.local import LocalAccount from eth_keys.datatypes import PrivateKey from hexbytes import HexBytes @@ -71,7 +71,7 @@ def construct_local_message_signer( >>> from web3 import Web3, HTTPProvider >>> Web3( ... HTTPProvider("https://mainnet.infura.io/v3/API_KEY") - ... ).middleware_stack.add( + ... ).middleware_onion.add( ... construct_local_message_signer(private_key) ... ) diff --git a/python-packages/contract_wrappers/stubs/web3/utils/__init__.pyi b/python-packages/middlewares/stubs/eth_account/signers/__init__.pyi similarity index 100% rename from python-packages/contract_wrappers/stubs/web3/utils/__init__.pyi rename to python-packages/middlewares/stubs/eth_account/signers/__init__.pyi diff --git a/python-packages/middlewares/stubs/eth_account/local.pyi b/python-packages/middlewares/stubs/eth_account/signers/local.pyi similarity index 100% rename from python-packages/middlewares/stubs/eth_account/local.pyi rename to python-packages/middlewares/stubs/eth_account/signers/local.pyi diff --git a/python-packages/middlewares/test/test_local_message_signer.py b/python-packages/middlewares/test/test_local_message_signer.py index c189652012..ef1b36f595 100644 --- a/python-packages/middlewares/test/test_local_message_signer.py +++ b/python-packages/middlewares/test/test_local_message_signer.py @@ -27,7 +27,7 @@ def test_local_message_signer__sign_order(): ) ganache = HTTPProvider("http://127.0.0.1:8545") web3_instance = Web3(ganache) - web3_instance.middleware_stack.add( + web3_instance.middleware_onion.add( construct_local_message_signer(private_key) ) order = { diff --git a/python-packages/order_utils/setup.py b/python-packages/order_utils/setup.py index 8496a88efd..0dfabdf673 100755 --- a/python-packages/order_utils/setup.py +++ b/python-packages/order_utils/setup.py @@ -172,11 +172,9 @@ def run(self): "0x-contract-addresses", "0x-contract-artifacts", "0x-json-schemas", - "0x-web3", - "eth-abi<2.0.0", + "web3", + "eth-abi", "eth_utils", - "hypothesis>=3.31.2", # HACK! this is web3's dependency! - # above works around https://github.com/ethereum/web3.py/issues/1179 "mypy_extensions", ], extras_require={ diff --git a/python-packages/order_utils/src/zero_ex/order_utils/__init__.py b/python-packages/order_utils/src/zero_ex/order_utils/__init__.py index ef2f6ce232..62306ce057 100644 --- a/python-packages/order_utils/src/zero_ex/order_utils/__init__.py +++ b/python-packages/order_utils/src/zero_ex/order_utils/__init__.py @@ -27,7 +27,7 @@ from web3 import Web3 import web3.exceptions from web3.providers.base import BaseProvider -from web3.utils import datatypes +from web3.contract import Contract from zero_ex.contract_addresses import NETWORK_TO_ADDRESSES, NetworkId import zero_ex.contract_artifacts @@ -186,7 +186,7 @@ def is_valid_signature( NetworkId(int(web3_instance.net.version)) ].exchange # false positive from pylint: disable=no-member - contract: datatypes.Contract = web3_instance.eth.contract( + contract: Contract = web3_instance.eth.contract( address=to_checksum_address(contract_address), abi=zero_ex.contract_artifacts.abi_by_name("Exchange"), ) @@ -285,7 +285,7 @@ def sign_hash( >>> provider = Web3.HTTPProvider("http://127.0.0.1:8545") >>> sign_hash( ... provider, - ... Web3(provider).personal.listAccounts[0], + ... Web3(provider).geth.personal.listAccounts()[0], ... '0x34decbedc118904df65f379a175bb39ca18209d6ce41d5ed549d54e6e0a95004', ... ) '0x1b117902c86dfb95fe0d1badd983ee166ad259b27acb220174cbb4460d872871137feabdfe76e05924b484789f79af4ee7fa29ec006cedce1bbf369320d034e10b03' @@ -355,7 +355,7 @@ def sign_hash_to_bytes( >>> provider = Web3.HTTPProvider("http://127.0.0.1:8545") >>> sign_hash_to_bytes( ... provider, - ... Web3(provider).personal.listAccounts[0], + ... Web3(provider).geth.personal.listAccounts()[0], ... '0x34decbedc118904df65f379a175bb39ca18209d6ce41d5ed549d54e6e0a95004', ... ).decode(encoding='utf_8') '1b117902c86dfb95fe0d1badd983ee166ad259b27acb220174cbb4460d872871137feabdfe76e05924b484789f79af4ee7fa29ec006cedce1bbf369320d034e10b03' diff --git a/python-packages/order_utils/stubs/web3/__init__.pyi b/python-packages/order_utils/stubs/web3/__init__.pyi index b2af954753..a1dd77adb4 100644 --- a/python-packages/order_utils/stubs/web3/__init__.pyi +++ b/python-packages/order_utils/stubs/web3/__init__.pyi @@ -1,6 +1,6 @@ -from typing import Dict, Optional, Union +from typing import Dict, List, Optional, Union -from web3.utils import datatypes +from web3.contract import Contract from web3.providers.base import BaseProvider @@ -23,6 +23,15 @@ class Web3: class eth: @staticmethod - def contract(address: str, abi: Dict) -> datatypes.Contract: ... + def contract(address: str, abi: Dict) -> Contract: ... ... + + class geth: + class personal: + @staticmethod + def listAccounts() -> List[str]: + ... + ... + ... + ... diff --git a/python-packages/order_utils/stubs/web3/utils/datatypes.pyi b/python-packages/order_utils/stubs/web3/contract.pyi similarity index 100% rename from python-packages/order_utils/stubs/web3/utils/datatypes.pyi rename to python-packages/order_utils/stubs/web3/contract.pyi diff --git a/python-packages/order_utils/stubs/web3/utils/__init__.pyi b/python-packages/order_utils/stubs/web3/utils/__init__.pyi deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/python-packages/order_utils/test/test_signature_utils.py b/python-packages/order_utils/test/test_signature_utils.py index 8c5ec18443..a542f8eba3 100644 --- a/python-packages/order_utils/test/test_signature_utils.py +++ b/python-packages/order_utils/test/test_signature_utils.py @@ -133,7 +133,9 @@ def test_sign_hash_to_bytes__golden_path(): provider = Web3.HTTPProvider("http://127.0.0.1:8545") signature = sign_hash_to_bytes( provider, - Web3(provider).personal.listAccounts[0], # pylint: disable=no-member + Web3( # pylint: disable=no-member + provider + ).geth.personal.listAccounts()[0], "0x34decbedc118904df65f379a175bb39ca18209d6ce41d5ed549d54e6e0a95004", ) assert ( diff --git a/python-packages/sra_client/setup.py b/python-packages/sra_client/setup.py index c32ae60dfa..9940039ed9 100755 --- a/python-packages/sra_client/setup.py +++ b/python-packages/sra_client/setup.py @@ -195,7 +195,7 @@ def run(self): "0x-contract-artifacts", "0x-contract-addresses", "0x-order-utils", - "0x-web3", + "web3", "bandit", "black", "coverage", diff --git a/python-packages/sra_client/src/zero_ex/sra_client/__init__.py b/python-packages/sra_client/src/zero_ex/sra_client/__init__.py index 9b8b8c7a13..76e8077acd 100644 --- a/python-packages/sra_client/src/zero_ex/sra_client/__init__.py +++ b/python-packages/sra_client/src/zero_ex/sra_client/__init__.py @@ -76,7 +76,7 @@ For our Maker role, we'll just use the first address available in the node: ->>> maker_address = Web3(eth_node).eth.accounts[0].lower() +>>> maker_address = Web3(eth_node).eth.accounts[0] The 0x Ganache snapshot loaded into our eth_node has a pre-loaded ZRX balance for this account, so the example orders below have the maker trading away ZRX. @@ -284,7 +284,7 @@ Filling ^^^^^^^ ->>> taker_address = Web3(eth_node).eth.accounts[1].lower() +>>> taker_address = Web3(eth_node).eth.accounts[1] Our taker will take a ZRX/WETH order, but it doesn't have any WETH yet. By depositing some ether into the WETH contract, it will be given some WETH to