cchecksum 0.0.13__tar.gz → 0.0.15__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cchecksum might be problematic. Click here for more details.
- {cchecksum-0.0.13/cchecksum.egg-info → cchecksum-0.0.15}/PKG-INFO +2 -2
- {cchecksum-0.0.13 → cchecksum-0.0.15}/README.md +1 -1
- {cchecksum-0.0.13 → cchecksum-0.0.15}/cchecksum/checksum.py +27 -47
- {cchecksum-0.0.13 → cchecksum-0.0.15/cchecksum.egg-info}/PKG-INFO +2 -2
- {cchecksum-0.0.13 → cchecksum-0.0.15}/setup.py +1 -1
- {cchecksum-0.0.13 → cchecksum-0.0.15}/.github/workflows/black.yaml +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/.github/workflows/deploy-docs.yaml +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/.github/workflows/pytest.yaml +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/.github/workflows/release.yaml +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/.gitignore +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/LICENSE +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/Makefile +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/cchecksum/__init__.py +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/cchecksum/_checksum.c +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/cchecksum/_checksum.pyi +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/cchecksum/_checksum.pyx +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/cchecksum/checksum.pyi +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/cchecksum/py.typed +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/cchecksum.egg-info/SOURCES.txt +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/cchecksum.egg-info/dependency_links.txt +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/cchecksum.egg-info/not-zip-safe +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/cchecksum.egg-info/requires.txt +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/cchecksum.egg-info/top_level.txt +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/docs/Makefile +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/docs/_build/html/_static/alabaster.css +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/docs/_build/html/_static/basic.css +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/docs/_build/html/_static/custom.css +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/docs/_build/html/_static/doctools.js +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/docs/_build/html/_static/documentation_options.js +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/docs/_build/html/_static/file.png +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/docs/_build/html/_static/language_data.js +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/docs/_build/html/_static/minus.png +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/docs/_build/html/_static/plus.png +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/docs/_build/html/_static/pygments.css +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/docs/_build/html/_static/searchtools.js +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/docs/_build/html/_static/sphinx_highlight.js +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/docs/conf.py +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/docs/index.rst +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/docs/make.bat +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/pyproject.toml +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/requirements.txt +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/setup.cfg +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.15}/test_checksum.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cchecksum
|
|
3
|
-
Version: 0.0.
|
|
4
|
-
Summary: A ~
|
|
3
|
+
Version: 0.0.15
|
|
4
|
+
Summary: A ~5x faster drop-in replacement for eth_utils.to_checksum_address. Raises the exact same Exceptions. Implemented in C.
|
|
5
5
|
Home-page: https://github.com/BobTheBuidler/cchecksum
|
|
6
6
|
Author: BobTheBuidler
|
|
7
7
|
Author-email: bobthebuidlerdefi@gmail.com
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## CChecksum
|
|
2
2
|
|
|
3
|
-
CChecksum is a ~
|
|
3
|
+
CChecksum is a ~5x faster drop-in replacement for eth_utils.to_checksum_address, with the most cpu-intensive part implemented in c.
|
|
4
4
|
|
|
5
5
|
It keeps the exact same API as the existing implementation, exceptions and all.
|
|
6
6
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
from binascii import hexlify
|
|
2
|
-
from typing import Optional, Union
|
|
2
|
+
from typing import AnyStr, Optional, Union
|
|
3
3
|
|
|
4
4
|
from eth_hash.auto import keccak
|
|
5
5
|
from eth_typing import AnyAddress, ChecksumAddress, HexAddress, HexStr
|
|
6
|
-
from eth_utils import encode_hex, is_hexstr, remove_0x_prefix
|
|
7
6
|
from eth_utils.address import _HEX_ADDRESS_REGEXP
|
|
7
|
+
from eth_utils.hexadecimal import _HEX_REGEXP
|
|
8
8
|
from eth_utils.toolz import compose
|
|
9
9
|
|
|
10
10
|
from cchecksum._checksum import cchecksum
|
|
@@ -16,6 +16,7 @@ keccak(b"")
|
|
|
16
16
|
hash_address = compose(hexlify, bytes, keccak.hasher, str.encode)
|
|
17
17
|
|
|
18
18
|
hex_address_fullmatch = _HEX_ADDRESS_REGEXP.fullmatch
|
|
19
|
+
hex_fullmatch = _HEX_REGEXP.fullmatch
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
# this was ripped out of eth_utils and optimized a little bit
|
|
@@ -48,13 +49,13 @@ def to_checksum_address(value: Union[AnyAddress, str, bytes]) -> ChecksumAddress
|
|
|
48
49
|
- :func:`eth_utils.to_checksum_address` for the standard implementation.
|
|
49
50
|
- :func:`to_normalized_address` for converting to a normalized address before checksumming.
|
|
50
51
|
"""
|
|
51
|
-
norm_address_no_0x =
|
|
52
|
+
norm_address_no_0x = to_normalized_address_no_0x(value)
|
|
52
53
|
return cchecksum(norm_address_no_0x, hash_address(norm_address_no_0x))
|
|
53
54
|
|
|
54
55
|
|
|
55
|
-
def
|
|
56
|
+
def to_normalized_address_no_0x(value: Union[AnyAddress, str, bytes]) -> HexAddress:
|
|
56
57
|
"""
|
|
57
|
-
Converts an address to its normalized hexadecimal representation.
|
|
58
|
+
Converts an address to its normalized hexadecimal representation without the '0x' prefix.
|
|
58
59
|
|
|
59
60
|
This function ensures that the address is in a consistent lowercase hexadecimal
|
|
60
61
|
format, which is useful for further processing or validation. It uses
|
|
@@ -80,55 +81,34 @@ def to_normalized_address(value: Union[AnyAddress, str, bytes]) -> HexAddress:
|
|
|
80
81
|
- :func:`eth_utils.to_normalized_address` for the standard implementation.
|
|
81
82
|
- :func:`is_address` for checking if a string is a valid address.
|
|
82
83
|
"""
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
except AttributeError as e:
|
|
86
|
-
raise TypeError(
|
|
87
|
-
f"Value must be any string, instead got type {type(value)}"
|
|
88
|
-
) from e.__cause__
|
|
89
|
-
|
|
90
|
-
# if `hex_address` is not a valid address
|
|
91
|
-
if hex_address_fullmatch(hex_address) is None:
|
|
92
|
-
raise ValueError(
|
|
93
|
-
f"Unknown format {repr(value)}, attempted to normalize to {repr(hex_address)}"
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
return hex_address # type: ignore [return-value]
|
|
97
|
-
|
|
84
|
+
if isinstance(value, str):
|
|
85
|
+
hex_address_no_0x = value[2:] if value.startswith(("0x", "0X")) else value
|
|
98
86
|
|
|
99
|
-
|
|
87
|
+
# if `value` has content and is not a hexstring
|
|
88
|
+
if hex_address_no_0x and hex_fullmatch(value) is None:
|
|
89
|
+
raise ValueError("when sending a str, it must be a hex string. " f"Got: {repr(value)}")
|
|
100
90
|
|
|
91
|
+
elif isinstance(value, (bytes, bytearray)):
|
|
92
|
+
hex_address_no_0x = hexlify(value).decode("ascii")
|
|
101
93
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
Convert to a type, assuming that strings can be only hexstr (not unicode text).
|
|
94
|
+
elif isinstance(value, memoryview):
|
|
95
|
+
hex_address_no_0x = hexlify(bytes(value)).decode("ascii")
|
|
105
96
|
|
|
106
|
-
:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if remove_0x_prefix(hexstr_or_primitive) and not is_hexstr(hexstr_or_primitive):
|
|
110
|
-
raise ValueError(
|
|
111
|
-
"when sending a str, it must be a hex string. " f"Got: {repr(hexstr_or_primitive)}"
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
return (
|
|
115
|
-
hexstr_or_primitive
|
|
116
|
-
if hexstr_or_primitive.startswith(("0x", "0X"))
|
|
117
|
-
else f"0x{hexstr_or_primitive}"
|
|
97
|
+
else:
|
|
98
|
+
raise TypeError(
|
|
99
|
+
f"Unsupported type: '{repr(type(value))}'. Must be one of: bytes or bytearray."
|
|
118
100
|
)
|
|
119
101
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
102
|
+
# if `hex_address_no_0x` is not a valid address
|
|
103
|
+
if hex_address_fullmatch(f"0x{hex_address_no_0x}") is None:
|
|
104
|
+
hex_address = f"0x{hex_address_no_0x}".lower()
|
|
105
|
+
raise ValueError(
|
|
106
|
+
f"Unknown format {repr(value)}, attempted to normalize to {repr(hex_address)}"
|
|
107
|
+
)
|
|
125
108
|
|
|
126
|
-
|
|
127
|
-
f"Unsupported type: '{repr(type(address_bytes))}'. Must be one of: bytes or bytearray."
|
|
128
|
-
)
|
|
109
|
+
return hex_address_no_0x.lower() # type: ignore [return-value]
|
|
129
110
|
|
|
130
111
|
|
|
131
|
-
del
|
|
132
|
-
del Optional, Union
|
|
112
|
+
del AnyStr, Optional, Union
|
|
133
113
|
del AnyAddress, ChecksumAddress, HexAddress, HexStr
|
|
134
|
-
del _HEX_ADDRESS_REGEXP, compose, keccak
|
|
114
|
+
del _HEX_ADDRESS_REGEXP, _HEX_REGEXP, compose, keccak
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cchecksum
|
|
3
|
-
Version: 0.0.
|
|
4
|
-
Summary: A ~
|
|
3
|
+
Version: 0.0.15
|
|
4
|
+
Summary: A ~5x faster drop-in replacement for eth_utils.to_checksum_address. Raises the exact same Exceptions. Implemented in C.
|
|
5
5
|
Home-page: https://github.com/BobTheBuidler/cchecksum
|
|
6
6
|
Author: BobTheBuidler
|
|
7
7
|
Author-email: bobthebuidlerdefi@gmail.com
|
|
@@ -13,7 +13,7 @@ setup(
|
|
|
13
13
|
"local_scheme": "no-local-version",
|
|
14
14
|
"version_scheme": "python-simplified-semver",
|
|
15
15
|
},
|
|
16
|
-
description="A ~
|
|
16
|
+
description="A ~5x faster drop-in replacement for eth_utils.to_checksum_address. Raises the exact same Exceptions. Implemented in C.",
|
|
17
17
|
author="BobTheBuidler",
|
|
18
18
|
author_email="bobthebuidlerdefi@gmail.com",
|
|
19
19
|
url="https://github.com/BobTheBuidler/cchecksum",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|