diff --git a/evmspec/data/_main.py b/evmspec/data/_main.py index 3cf2771..9dc2099 100644 --- a/evmspec/data/_main.py +++ b/evmspec/data/_main.py @@ -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): """ @@ -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): @@ -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()})"