Skip to content

Commit cab4658

Browse files
authored
chore: bump eth pydantic types (#125)
1 parent 0f30210 commit cab4658

File tree

7 files changed

+28
-15
lines changed

7 files changed

+28
-15
lines changed

ape_foundry/provider.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from ape.utils import cached_property
2727
from ape_ethereum.provider import Web3Provider
2828
from ape_test import ApeTestConfig
29-
from eth_pydantic_types import HashBytes32, HexBytes
29+
from eth_pydantic_types import HexBytes, HexBytes32
3030
from eth_typing import HexStr
3131
from eth_utils import add_0x_prefix, is_0x_prefixed, is_hex, to_hex
3232
from pydantic import field_validator, model_validator
@@ -41,6 +41,7 @@
4141
from web3.middleware import ExtraDataToPOAMiddleware # type: ignore
4242
except ImportError:
4343
from web3.middleware import geth_poa_middleware as ExtraDataToPOAMiddleware # type: ignore
44+
4445
from web3.middleware.validation import MAX_EXTRADATA_LENGTH
4546
from yarl import URL
4647

@@ -141,6 +142,7 @@ class FoundryProvider(SubprocessProvider, Web3Provider, TestProviderAPI):
141142
attempted_ports: list[int] = []
142143
cached_chain_id: Optional[int] = None
143144
_did_warn_wrong_node = False
145+
_disconnected: Optional[bool] = None
144146

145147
@property
146148
def unlocked_accounts(self) -> list["AddressType"]:
@@ -258,7 +260,7 @@ def ws_uri(self) -> str:
258260

259261
@property
260262
def is_connected(self) -> bool:
261-
if self._host in ("auto", None):
263+
if self._disconnected is True or self._host in ("auto", None):
262264
# Hasn't tried yet.
263265
return False
264266

@@ -299,7 +301,7 @@ def connect(self):
299301
Start the foundry process and verify it's up and accepting connections.
300302
**NOTE**: Must set port before calling 'super().connect()'.
301303
"""
302-
304+
self._disconnected = False
303305
if "APE_FOUNDRY_HOST" in os.environ:
304306
self._host = os.environ["APE_FOUNDRY_HOST"]
305307

@@ -452,6 +454,7 @@ def disconnect(self):
452454
self._web3 = None
453455
self._host = None
454456
super().disconnect()
457+
self._disconnected = True
455458

456459
def build_command(self) -> list[str]:
457460
cmd = [
@@ -665,8 +668,8 @@ def set_storage(self, address: "AddressType", slot: int, value: HexBytes):
665668
"anvil_setStorageAt",
666669
[
667670
address,
668-
to_hex(HashBytes32.__eth_pydantic_validate__(slot)),
669-
to_hex(HashBytes32.__eth_pydantic_validate__(value)),
671+
to_hex(HexBytes32.__eth_pydantic_validate__(slot)),
672+
to_hex(HexBytes32.__eth_pydantic_validate__(value)),
670673
],
671674
)
672675

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ force_grid_wrap = 0
4141
include_trailing_comma = true
4242
multi_line_output = 3
4343
use_parentheses = true
44+
skip = ["version.py"]
4445

4546
[tool.mdformat]
4647
number = true

setup.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"pytest-mock", # For creating mocks
1111
"pytest-benchmark", # For performance tests
1212
"hypothesis>=6.2.0,<7.0", # Strategy-based fuzzer
13-
"ape-alchemy", # For running fork tests
13+
"ape-alchemy>=0.8.9", # For running fork tests
1414
"ape-polygon", # For running polygon fork tests
1515
"ape-optimism", # For Optimism integration tests
1616
],
@@ -74,13 +74,13 @@
7474
url="https://github.com/ApeWorX/ape-foundry",
7575
include_package_data=True,
7676
install_requires=[
77-
"eth-ape>=0.8.21,<0.9",
78-
"ethpm-types>=0.6.19,<0.7",
79-
"eth_pydantic_types>=0.1.3,<0.2",
77+
"eth-ape>=0.8.34,<0.9",
78+
"eth_pydantic_types>=0.2.0,<0.3",
8079
"evm-trace>=0.2.3,<0.3",
80+
"ethpm-types>=0.6.19,<0.7",
81+
"hexbytes>=0.3.1,<2",
8182
"web3>=6.20.1,<8",
8283
"yarl>=1.9.2,<2",
83-
"hexbytes>=0.3.1,<2",
8484
],
8585
python_requires=">=3.9,<4",
8686
extras_require=extras_require,

tests/conftest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@ def contract_a(owner, connected_provider, get_contract_type):
246246
ContractContainer(get_contract_type("contract_b")), contract_c.address
247247
)
248248
contract_a = owner.deploy(
249-
ContractContainer(get_contract_type("contract_a")), contract_b.address, contract_c.address
249+
ContractContainer(get_contract_type("contract_a")),
250+
contract_b.address,
251+
contract_c.address,
250252
)
251253
return contract_a
252254

tests/test_fork_provider.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,11 @@ def test_contract_revert_no_message(owner, mainnet_fork_contract_instance, mainn
142142

143143
@pytest.mark.fork
144144
def test_transaction_contract_as_sender(
145-
mainnet_fork_contract_instance, owner, contract_container, mainnet_fork_provider, convert
145+
mainnet_fork_contract_instance,
146+
owner,
147+
contract_container,
148+
mainnet_fork_provider,
149+
convert,
146150
):
147151
# Set balance so test wouldn't normally fail from lack of funds
148152
contract = owner.deploy(contract_container)

tests/test_provider.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from ape.exceptions import ContractLogicError, TransactionError, VirtualMachineError
99
from ape_ethereum.trace import Trace
1010
from ape_ethereum.transactions import TransactionStatusEnum, TransactionType
11-
from eth_pydantic_types import HashBytes32
11+
from eth_pydantic_types import HexBytes32
1212
from eth_utils import to_hex, to_int
1313
from evm_trace import CallType
1414
from hexbytes import HexBytes
@@ -429,7 +429,7 @@ def test_send_transaction_when_no_error_and_receipt_fails(
429429

430430
try:
431431
# NOTE: Value is meaningless.
432-
tx_hash = HashBytes32.__eth_pydantic_validate__(123**36)
432+
tx_hash = HexBytes32.__eth_pydantic_validate__(123**36)
433433

434434
# Sending tx "works" meaning no vm error.
435435
mock_web3.eth.send_raw_transaction.return_value = tx_hash

tests/test_trace.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
MAINNET_TXN_HASH = "0xb7d7f1d5ce7743e821d3026647df486f517946ef1342a1ae93c96e4a8016eab7"
2222
EXPECTED_MAP = {
2323
MAINNET_TXN_HASH: (MAINNET_TRACE_FIRST_10_LINES, MAINNET_TRACE_LAST_10_LINES),
24-
MAINNET_FAIL_TXN_HASH: (MAINNET_FAIL_TRACE_FIRST_10_LINES, MAINNET_FAIL_TRACE_LAST_10_LINES),
24+
MAINNET_FAIL_TXN_HASH: (
25+
MAINNET_FAIL_TRACE_FIRST_10_LINES,
26+
MAINNET_FAIL_TRACE_LAST_10_LINES,
27+
),
2528
}
2629
BASE_CONTRACTS_PATH = Path(__file__).parent / "data" / "contracts" / "ethereum"
2730

0 commit comments

Comments
 (0)