Skip to content

Commit

Permalink
fix: handle breaking changes from updated deps
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdefinitelyahuman committed Feb 2, 2024
1 parent d3873b4 commit 55dbe85
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 24 deletions.
2 changes: 2 additions & 0 deletions brownie/convert/normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 12 additions & 16 deletions brownie/network/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -865,7 +864,6 @@ def _await_confirmation(


class Account(_PrivateKeyAccount):

"""Class for interacting with an Ethereum account.
Attributes:
Expand All @@ -881,7 +879,6 @@ def _transact(self, tx: Dict, allow_revert: bool) -> Any:


class LocalAccount(_PrivateKeyAccount):

"""Class for interacting with an Ethereum account.
Attributes:
Expand Down Expand Up @@ -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.
"""
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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
2 changes: 1 addition & 1 deletion brownie/network/middlewares/ganache7.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion brownie/network/middlewares/hardhat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion brownie/network/rpc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions brownie/network/rpc/ganache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions brownie/network/web3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 55dbe85

Please sign in to comment.