Skip to content

Commit

Permalink
feat: optimize HexBytes32 (#31)
Browse files Browse the repository at this point in the history
* feat: optimize HexBytes32

* chore: `black .`

* Update _main.py

* chore: `black .`

* Update _main.py

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
BobTheBuidler and github-actions[bot] authored Dec 16, 2024
1 parent a9f230e commit 5e5ab9e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions evmspec/data/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __new__(cls, address: str):
See Also:
- `cchecksum.to_checksum_address`: Function used for checksum conversion.
"""
return super().__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 +342,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 Expand Up @@ -456,3 +456,7 @@ async def get_logs(self) -> Tuple["Log", ...]:


class BlockHash(HexBytes32): ...


__str_new__ = str.__new__
__hb_new__ = HexBytes.__new__

0 comments on commit 5e5ab9e

Please sign in to comment.