Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement cchecksum for ~2x faster checksumming #17

Merged
merged 9 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions eth_pydantic_types/address.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Annotated, Any, ClassVar, Optional, cast
antazoey marked this conversation as resolved.
Show resolved Hide resolved

from cchecksum import to_checksum_address
from eth_typing import ChecksumAddress
from eth_utils import is_checksum_address, to_checksum_address
from pydantic_core.core_schema import ValidationInfo, str_schema

from eth_pydantic_types.hash import HashStr20
Expand Down Expand Up @@ -34,11 +34,7 @@ def __eth_pydantic_validate__(cls, value: Any, info: Optional[ValidationInfo] =

@classmethod
def to_checksum_address(cls, value: str) -> ChecksumAddress:
return (
cast(ChecksumAddress, value)
if is_checksum_address(value)
else to_checksum_address(value)
)
return to_checksum_address(value)


"""
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
url="https://github.com/ApeWorX/eth-pydantic-types",
include_package_data=True,
install_requires=[
"cchecksum>=0.0.3,<1"
antazoey marked this conversation as resolved.
Show resolved Hide resolved
"hexbytes>=0.3.1,<2",
"eth-utils>=2.3.1,<6",
"eth-typing>=3.5.2,<6",
Expand Down
Loading