Skip to content

Commit

Permalink
Update _main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Dec 16, 2024
1 parent add3055 commit b7eaf72
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions evmspec/data/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
DecodeHook = Callable[[Type[_T], Any], _T]
"""A type alias for a function that decodes an object into a specific type."""

__str_new__ = str.__new__
__hb_new__ = HexBytes.__new__

class Address(str):
"""
Expand Down Expand Up @@ -58,7 +60,7 @@ def __new__(cls, address: str):
See Also:
- `cchecksum.to_checksum_address`: Function used for checksum conversion.
"""
return str.__new__(cls, to_checksum_address(address))
return __str_new__(cls, to_checksum_address(address))

@classmethod
def _decode_hook(cls, typ: Type["Address"], obj: str):
Expand Down Expand Up @@ -342,7 +344,7 @@ def __new__(cls, v):
except KeyError as e:
raise ValueError(f"{v} is too long") from e.__cause__

return HexBytes.__new__(cls, missing_bytes + input_bytes)
return __hb_new__(cls, missing_bytes + input_bytes)

def __repr__(self) -> str:
return f"{type(self).__name__}({self.hex()})"
Expand Down

0 comments on commit b7eaf72

Please sign in to comment.