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..e5bb08c32 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: @@ -606,7 +605,7 @@ def estimate_gas( "data": HexBytes(data or ""), } if gas_price is not None: - tx["gasPrice"] = web3.toHex(gas_price) + tx["gasPrice"] = web3.to_hex(gas_price) try: return web3.eth.estimate_gas(tx) except ValueError as exc: @@ -753,7 +752,7 @@ def _make_transaction( "from": self.address, "value": Wei(amount), "nonce": nonce if nonce is not None else self._pending_nonce(), - "gas": web3.toHex(gas_limit), + "gas": web3.to_hex(gas_limit), "data": HexBytes(data), } if to: @@ -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. """ @@ -1000,10 +996,10 @@ def _transact(self, tx: Dict, allow_revert: bool) -> None: self._check_for_revert(tx) formatters = { - "nonce": web3.toHex, - "value": web3.toHex, - "chainId": web3.toHex, - "data": web3.toHex, + "nonce": web3.to_hex, + "value": web3.to_hex, + "chainId": web3.to_hex, + "data": web3.to_hex, "from": to_address, } if "to" in tx: @@ -1029,7 +1025,7 @@ def _apply_fee_to_tx( if gas_price is not None: if max_fee or priority_fee: raise ValueError("gas_price and (max_fee, priority_fee) are mutually exclusive") - tx["gasPrice"] = web3.toHex(gas_price) + tx["gasPrice"] = web3.to_hex(gas_price) return tx if priority_fee is None: @@ -1046,7 +1042,7 @@ def _apply_fee_to_tx( if priority_fee > max_fee: raise InvalidTransaction("priority_fee must not exceed max_fee") - tx["maxFeePerGas"] = web3.toHex(max_fee) - tx["maxPriorityFeePerGas"] = web3.toHex(priority_fee) - tx["type"] = web3.toHex(2) + tx["maxFeePerGas"] = web3.to_hex(max_fee) + tx["maxPriorityFeePerGas"] = web3.to_hex(priority_fee) + tx["type"] = web3.to_hex(2) return tx diff --git a/brownie/network/contract.py b/brownie/network/contract.py index a35260aed..102ff9f24 100644 --- a/brownie/network/contract.py +++ b/brownie/network/contract.py @@ -1361,7 +1361,7 @@ def _retrieve_contract_events( if from_block is None and isinstance(to_block, int): from_block = to_block - 10 - event_filter: filters.LogFilter = event_type.createFilter( + event_filter: filters.LogFilter = event_type.create_filter( fromBlock=from_block, toBlock=to_block ) return event_filter.get_all_entries() diff --git a/brownie/network/event.py b/brownie/network/event.py index 1327bce78..437a0658a 100644 --- a/brownie/network/event.py +++ b/brownie/network/event.py @@ -207,7 +207,7 @@ def __init__( self._callbacks_list: List[dict] = [] self.delay: float = delay # Members - self._event_filter: filters.LogFilter = event.createFilter( + self._event_filter: filters.LogFilter = event.create_filter( fromBlock=(web3.eth.block_number - 1) ) self._cooldown_time_over: bool = False 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..543ae7719 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: @@ -193,7 +193,7 @@ def _resolve_address(domain: str) -> str: domain = domain.lower() if domain not in _ens_cache or time.time() - _ens_cache[domain][1] > 86400: try: - ns = ENS.fromWeb3(web3._mainnet) + ns = ENS.from_web3(web3._mainnet) except MainnetUndefined as e: raise MainnetUndefined(f"Cannot resolve ENS address - {e}") from None address = ns.address(domain)