From e9b5cb6c41108179bea6e2816fdc4cbe9ea7fa61 Mon Sep 17 00:00:00 2001 From: Ben Hauser Date: Fri, 2 Feb 2024 05:06:22 +0400 Subject: [PATCH] fix: handle breaking changes from updated deps --- brownie/convert/normalize.py | 2 ++ brownie/network/account.py | 8 ++------ brownie/network/middlewares/ganache7.py | 2 +- brownie/network/middlewares/hardhat.py | 2 +- brownie/network/rpc/__init__.py | 2 +- brownie/network/rpc/ganache.py | 4 ++-- brownie/network/web3.py | 6 +++--- 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/brownie/convert/normalize.py b/brownie/convert/normalize.py index ea18dd873..b0200b6f1 100644 --- a/brownie/convert/normalize.py +++ b/brownie/convert/normalize.py @@ -108,6 +108,8 @@ def _check_array(values: Union[List, Tuple], length: Optional[int]) -> None: def _get_abi_types(abi_params: List) -> Sequence[ABIType]: + if not abi_params: + return [] type_str = f"({','.join(get_type_strings(abi_params))})" tuple_type = parse(type_str) return tuple_type.components diff --git a/brownie/network/account.py b/brownie/network/account.py index 8e017bab8..ab3f9a551 100644 --- a/brownie/network/account.py +++ b/brownie/network/account.py @@ -13,10 +13,10 @@ import eth_account import eth_keys import rlp -from eip712.messages import EIP712Message, _hash_eip191_message +from eip712.messages import EIP712Message from eth_account._utils.signing import sign_message_hash from eth_account.datastructures import SignedMessage -from eth_account.messages import defunct_hash_message +from eth_account.messages import _hash_eip191_message, defunct_hash_message from eth_utils import keccak from eth_utils.applicators import apply_formatters_to_dict from hexbytes import HexBytes @@ -404,7 +404,6 @@ def get_deployment_address(self, nonce: Optional[int] = None) -> EthAddress: class _PrivateKeyAccount(PublicKeyAccount): - """Base class for Account and LocalAccount""" def __init__(self, addr: str) -> None: @@ -865,7 +864,6 @@ def _await_confirmation( class Account(_PrivateKeyAccount): - """Class for interacting with an Ethereum account. Attributes: @@ -881,7 +879,6 @@ def _transact(self, tx: Dict, allow_revert: bool) -> Any: class LocalAccount(_PrivateKeyAccount): - """Class for interacting with an Ethereum account. Attributes: @@ -984,7 +981,6 @@ def _transact(self, tx: Dict, allow_revert: bool) -> None: class ClefAccount(_PrivateKeyAccount): - """ Class for interacting with an Ethereum account where signing is handled in Clef. """ diff --git a/brownie/network/middlewares/ganache7.py b/brownie/network/middlewares/ganache7.py index 33150a687..499699e22 100644 --- a/brownie/network/middlewares/ganache7.py +++ b/brownie/network/middlewares/ganache7.py @@ -8,7 +8,7 @@ class Ganache7MiddleWare(BrownieMiddlewareABC): @classmethod def get_layer(cls, w3: Web3, network_type: str) -> Optional[int]: - if w3.clientVersion.lower().startswith("ganache/v7"): + if w3.client_version.lower().startswith("ganache/v7"): return -100 else: return None diff --git a/brownie/network/middlewares/hardhat.py b/brownie/network/middlewares/hardhat.py index cc0440035..14f8efa84 100644 --- a/brownie/network/middlewares/hardhat.py +++ b/brownie/network/middlewares/hardhat.py @@ -9,7 +9,7 @@ class HardhatMiddleWare(BrownieMiddlewareABC): @classmethod def get_layer(cls, w3: Web3, network_type: str) -> Optional[int]: - if w3.clientVersion.lower().startswith("hardhat"): + if w3.client_version.lower().startswith("hardhat"): return -100 else: return None diff --git a/brownie/network/rpc/__init__.py b/brownie/network/rpc/__init__.py index b4c2305d9..495f56755 100644 --- a/brownie/network/rpc/__init__.py +++ b/brownie/network/rpc/__init__.py @@ -117,7 +117,7 @@ def attach(self, laddr: Union[str, Tuple]) -> None: self.process = psutil.Process(pid) for key, module in ATTACH_BACKENDS.items(): - if web3.clientVersion.lower().startswith(key): + if web3.client_version.lower().startswith(key): self.backend = module break diff --git a/brownie/network/rpc/ganache.py b/brownie/network/rpc/ganache.py index 75b1cb410..ec1eb11ee 100644 --- a/brownie/network/rpc/ganache.py +++ b/brownie/network/rpc/ganache.py @@ -137,7 +137,7 @@ def sleep(seconds: int) -> int: def mine(timestamp: Optional[int] = None) -> None: params = [timestamp] if timestamp else [] _request("evm_mine", params) - if timestamp and web3.clientVersion.lower().startswith("ganache/v7"): + if timestamp and web3.client_version.lower().startswith("ganache/v7"): # ganache v7 does not modify the internal time when mining new blocks # so we also set the time to maintain consistency with v6 behavior _request("evm_setTime", [(timestamp + 1) * 1000]) @@ -152,7 +152,7 @@ def revert(snapshot_id: int) -> None: def unlock_account(address: str) -> None: - if web3.clientVersion.lower().startswith("ganache/v7"): + if web3.client_version.lower().startswith("ganache/v7"): web3.provider.make_request("evm_addAccount", [address, ""]) # type: ignore web3.provider.make_request( # type: ignore "personal_unlockAccount", diff --git a/brownie/network/web3.py b/brownie/network/web3.py index cfad08c43..6e16ec85e 100644 --- a/brownie/network/web3.py +++ b/brownie/network/web3.py @@ -10,8 +10,8 @@ from web3 import HTTPProvider, IPCProvider from web3 import Web3 as _Web3 from web3 import WebsocketProvider -from web3.contract import ContractEvent # noqa -from web3.contract import ContractEvents as _ContractEvents # noqa +from web3.contract.contract import ContractEvent # noqa +from web3.contract.contract import ContractEvents as _ContractEvents # noqa from web3.gas_strategies.rpc import rpc_gas_price_strategy from brownie._config import CONFIG, _get_data_folder @@ -112,7 +112,7 @@ def disconnect(self) -> None: def isConnected(self) -> bool: if not self.provider: return False - return super().isConnected() + return super().is_connected() @property def supports_traces(self) -> bool: