Skip to content

Commit 420dfa3

Browse files
refactor: use new types from eth_pydantic_types (#2322)
Co-authored-by: antazoey <antyzoa@gmail.com>
1 parent 7953d1b commit 420dfa3

File tree

8 files changed

+16
-17
lines changed

8 files changed

+16
-17
lines changed

setup.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@
121121
"web3[tester]>=6.20.1,<8",
122122
# ** Dependencies maintained by ApeWorX **
123123
"eip712>=0.2.10,<0.3",
124-
"ethpm-types>=0.6.25,<0.7",
125-
"eth_pydantic_types>=0.1.3,<0.2",
124+
"ethpm-types>=0.6.26,<0.7",
125+
"eth_pydantic_types>=0.2.0,<0.3",
126126
"evmchains>=0.1.0,<0.2",
127-
"evm-trace>=0.2.3,<0.3",
127+
"evm-trace>=0.2.5,<0.3",
128128
],
129129
entry_points={
130130
"console_scripts": ["ape=ape._cli:cli"],

src/ape/types/address.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import TYPE_CHECKING, Annotated, Any, Optional, Union
22

33
from eth_pydantic_types import Address as _Address
4-
from eth_pydantic_types import HashBytes20, HashStr20
4+
from eth_pydantic_types import HexBytes20, HexStr20
55
from eth_typing import ChecksumAddress
66

77
from ape.utils.basemodel import ManagerAccessMixin
@@ -10,7 +10,7 @@
1010
from pydantic_core.core_schema import ValidationInfo
1111

1212

13-
RawAddress = Union[str, int, HashStr20, HashBytes20]
13+
RawAddress = Union[str, int, HexStr20, HexBytes20]
1414
"""
1515
A raw data-type representation of an address.
1616
"""

src/ape/utils/abi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from eth_abi.exceptions import DecodingError, InsufficientDataBytes
1212
from eth_abi.registry import BaseEquals, registry
1313
from eth_pydantic_types import HexBytes, HexStr
14-
from eth_pydantic_types.validators import validate_bytes_size
14+
from eth_pydantic_types.utils import validate_bytes_size
1515
from eth_utils import decode_hex
1616
from ethpm_types.abi import ABIType, ConstructorABI, EventABI, EventABIType, MethodABI
1717

tests/functional/geth/test_provider.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import Optional, cast
55

66
import pytest
7-
from eth_pydantic_types import HashBytes32
7+
from eth_pydantic_types import HexBytes32
88
from eth_typing import HexStr
99
from eth_utils import keccak, to_hex
1010
from hexbytes import HexBytes
@@ -556,7 +556,7 @@ def test_send_transaction_when_no_error_and_receipt_fails(
556556
geth_provider._web3 = mock_web3
557557
# Getting a receipt "works", but you get a failed one.
558558
# NOTE: Value is meaningless.
559-
tx_hash = HashBytes32.__eth_pydantic_validate__(123**36)
559+
tx_hash = HexBytes32.__eth_pydantic_validate__(123**36)
560560
receipt_data = {
561561
"failed": True,
562562
"blockNumber": 0,

tests/functional/geth/test_trace.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
LOCAL_TRACE = r"""
1515
Call trace for '0x([A-Fa-f0-9]{64})'
1616
tx\.origin=0x[a-fA-F0-9]{40}
17-
ContractA\.methodWithoutArguments\(\) -> 0x[A-Fa-f0-9]{2,}..[A-Fa-f0-9]{4} \[\d+ gas\]
17+
ContractA\.methodWithoutArguments\(\) -> 0x[A-Fa-f0-9]{4}..[A-Fa-f0-9]{4} \[\d+ gas\]
1818
├── SYMBOL\.supercluster\(x=234444\) -> \[
1919
│ \[23523523235235, 11111111111, 234444\],
2020
│ \[

tests/functional/test_contract_event.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
from typing import TYPE_CHECKING, Optional
44

55
import pytest
6-
from eth_pydantic_types import HexBytes
7-
from eth_pydantic_types.hash import HashBytes20
6+
from eth_pydantic_types import HexBytes, HexBytes20
87
from eth_utils import to_hex
98
from ethpm_types import ContractType
109

@@ -474,7 +473,7 @@ def test_model_dump(solidity_contract_container, owner):
474473
def test_model_dump_hexbytes(mode):
475474
# NOTE: There was an issue when using HexBytes for Any.
476475
event_arguments = {"key": 123, "validators": [HexBytes(123)]}
477-
txn_hash = HashBytes20.__eth_pydantic_validate__(347374237412374174)
476+
txn_hash = HexBytes20.__eth_pydantic_validate__(347374237412374174)
478477
event = ContractLog(
479478
block_number=123,
480479
block_hash="block-hash",
@@ -497,7 +496,7 @@ def test_model_dump_json():
497496
event_arguments=event_arguments,
498497
event_name="MyEvent",
499498
log_index=0,
500-
transaction_hash=HashBytes20.__eth_pydantic_validate__(347374237412374174),
499+
transaction_hash=HexBytes20.__eth_pydantic_validate__(347374237412374174),
501500
)
502501
actual = event.model_dump_json()
503502
assert actual == (

tests/functional/test_ecosystem.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import Any, ClassVar, cast
44

55
import pytest
6-
from eth_pydantic_types import HashBytes32, HexBytes
6+
from eth_pydantic_types import HexBytes, HexBytes32
77
from eth_typing import HexAddress, HexStr
88
from ethpm_types import ContractType, ErrorABI
99
from ethpm_types.abi import ABIType, EventABI, MethodABI
@@ -744,7 +744,7 @@ def test_encode_blueprint_contract(ethereum, vyper_contract_type):
744744

745745
def test_decode_returndata(ethereum):
746746
abi = make_method_abi("doThing", outputs=[{"name": "", "type": "bool"}])
747-
data = HashBytes32.__eth_pydantic_validate__(0)
747+
data = HexBytes32.__eth_pydantic_validate__(0)
748748
actual = ethereum.decode_returndata(abi, data)
749749
assert actual == (False,)
750750

tests/functional/test_provider.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from unittest import mock
44

55
import pytest
6-
from eth_pydantic_types import HashBytes32
6+
from eth_pydantic_types import HexBytes32
77
from eth_tester.exceptions import TransactionFailed # type: ignore
88
from eth_typing import HexStr
99
from eth_utils import ValidationError, to_hex
@@ -434,7 +434,7 @@ def test_send_transaction_when_no_error_and_receipt_fails(
434434

435435
try:
436436
# NOTE: Value is meaningless.
437-
tx_hash = HashBytes32.__eth_pydantic_validate__(123**36)
437+
tx_hash = HexBytes32.__eth_pydantic_validate__(123**36)
438438

439439
# Sending tx "works" meaning no vm error.
440440
mock_eth_tester.ethereum_tester.send_raw_transaction.return_value = tx_hash

0 commit comments

Comments
 (0)