cchecksum 0.0.5__tar.gz → 0.0.6__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.

Files changed (42) hide show
  1. {cchecksum-0.0.5/cchecksum.egg-info → cchecksum-0.0.6}/PKG-INFO +1 -1
  2. {cchecksum-0.0.5 → cchecksum-0.0.6}/cchecksum/checksum.py +34 -7
  3. {cchecksum-0.0.5 → cchecksum-0.0.6/cchecksum.egg-info}/PKG-INFO +1 -1
  4. {cchecksum-0.0.5 → cchecksum-0.0.6}/.github/workflows/black.yaml +0 -0
  5. {cchecksum-0.0.5 → cchecksum-0.0.6}/.github/workflows/deploy-docs.yaml +0 -0
  6. {cchecksum-0.0.5 → cchecksum-0.0.6}/.github/workflows/pytest.yaml +0 -0
  7. {cchecksum-0.0.5 → cchecksum-0.0.6}/.github/workflows/release.yaml +0 -0
  8. {cchecksum-0.0.5 → cchecksum-0.0.6}/.gitignore +0 -0
  9. {cchecksum-0.0.5 → cchecksum-0.0.6}/LICENSE +0 -0
  10. {cchecksum-0.0.5 → cchecksum-0.0.6}/Makefile +0 -0
  11. {cchecksum-0.0.5 → cchecksum-0.0.6}/README.md +0 -0
  12. {cchecksum-0.0.5 → cchecksum-0.0.6}/cchecksum/__init__.py +0 -0
  13. {cchecksum-0.0.5 → cchecksum-0.0.6}/cchecksum/_cchecksum.pyi +0 -0
  14. {cchecksum-0.0.5 → cchecksum-0.0.6}/cchecksum/_checksum.c +0 -0
  15. {cchecksum-0.0.5 → cchecksum-0.0.6}/cchecksum/_checksum.pyx +0 -0
  16. {cchecksum-0.0.5 → cchecksum-0.0.6}/cchecksum/py.typed +0 -0
  17. {cchecksum-0.0.5 → cchecksum-0.0.6}/cchecksum.egg-info/SOURCES.txt +0 -0
  18. {cchecksum-0.0.5 → cchecksum-0.0.6}/cchecksum.egg-info/dependency_links.txt +0 -0
  19. {cchecksum-0.0.5 → cchecksum-0.0.6}/cchecksum.egg-info/not-zip-safe +0 -0
  20. {cchecksum-0.0.5 → cchecksum-0.0.6}/cchecksum.egg-info/requires.txt +0 -0
  21. {cchecksum-0.0.5 → cchecksum-0.0.6}/cchecksum.egg-info/top_level.txt +0 -0
  22. {cchecksum-0.0.5 → cchecksum-0.0.6}/docs/Makefile +0 -0
  23. {cchecksum-0.0.5 → cchecksum-0.0.6}/docs/_build/html/_static/alabaster.css +0 -0
  24. {cchecksum-0.0.5 → cchecksum-0.0.6}/docs/_build/html/_static/basic.css +0 -0
  25. {cchecksum-0.0.5 → cchecksum-0.0.6}/docs/_build/html/_static/custom.css +0 -0
  26. {cchecksum-0.0.5 → cchecksum-0.0.6}/docs/_build/html/_static/doctools.js +0 -0
  27. {cchecksum-0.0.5 → cchecksum-0.0.6}/docs/_build/html/_static/documentation_options.js +0 -0
  28. {cchecksum-0.0.5 → cchecksum-0.0.6}/docs/_build/html/_static/file.png +0 -0
  29. {cchecksum-0.0.5 → cchecksum-0.0.6}/docs/_build/html/_static/language_data.js +0 -0
  30. {cchecksum-0.0.5 → cchecksum-0.0.6}/docs/_build/html/_static/minus.png +0 -0
  31. {cchecksum-0.0.5 → cchecksum-0.0.6}/docs/_build/html/_static/plus.png +0 -0
  32. {cchecksum-0.0.5 → cchecksum-0.0.6}/docs/_build/html/_static/pygments.css +0 -0
  33. {cchecksum-0.0.5 → cchecksum-0.0.6}/docs/_build/html/_static/searchtools.js +0 -0
  34. {cchecksum-0.0.5 → cchecksum-0.0.6}/docs/_build/html/_static/sphinx_highlight.js +0 -0
  35. {cchecksum-0.0.5 → cchecksum-0.0.6}/docs/conf.py +0 -0
  36. {cchecksum-0.0.5 → cchecksum-0.0.6}/docs/index.rst +0 -0
  37. {cchecksum-0.0.5 → cchecksum-0.0.6}/docs/make.bat +0 -0
  38. {cchecksum-0.0.5 → cchecksum-0.0.6}/pyproject.toml +0 -0
  39. {cchecksum-0.0.5 → cchecksum-0.0.6}/requirements.txt +0 -0
  40. {cchecksum-0.0.5 → cchecksum-0.0.6}/setup.cfg +0 -0
  41. {cchecksum-0.0.5 → cchecksum-0.0.6}/setup.py +0 -0
  42. {cchecksum-0.0.5 → cchecksum-0.0.6}/test_checksum.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: cchecksum
3
- Version: 0.0.5
3
+ Version: 0.0.6
4
4
  Summary: A ~2x 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
@@ -1,9 +1,9 @@
1
- import binascii
2
- from typing import Union
1
+ from binascii import hexlify
2
+ from typing import Optional, Union
3
3
 
4
4
  from eth_hash.auto import keccak
5
- from eth_typing import AnyAddress, ChecksumAddress, HexAddress
6
- from eth_utils import hexstr_if_str, to_hex
5
+ from eth_typing import AnyAddress, ChecksumAddress, HexAddress, HexStr, Primitives
6
+ from eth_utils import add_0x_prefix, encode_hex, hexstr_if_str
7
7
  from eth_utils.address import _HEX_ADDRESS_REGEXP
8
8
 
9
9
  from cchecksum._checksum import cchecksum
@@ -41,7 +41,7 @@ def to_checksum_address(value: Union[AnyAddress, str, bytes]) -> ChecksumAddress
41
41
  """
42
42
  norm_address_no_0x = to_normalized_address(value)[2:]
43
43
  address_hash = bytes(keccak(norm_address_no_0x.encode("utf-8")))
44
- address_hash_hex_no_0x = binascii.hexlify(address_hash).decode("ascii")
44
+ address_hash_hex_no_0x = hexlify(address_hash).decode("ascii")
45
45
  return cchecksum(norm_address_no_0x, address_hash_hex_no_0x)
46
46
 
47
47
 
@@ -51,12 +51,12 @@ def to_normalized_address(value: Union[AnyAddress, str, bytes]) -> HexAddress:
51
51
 
52
52
  This function ensures that the address is in a consistent lowercase hexadecimal
53
53
  format, which is useful for further processing or validation. It uses
54
- :func:`eth_utils.hexstr_if_str` and :func:`eth_utils.to_hex` to convert the input
54
+ :func:`eth_utils.hexstr_if_str` and :func:`to_hex` to convert the input
55
55
  to a hexadecimal string.
56
56
 
57
57
  Args:
58
58
  value: The address to be normalized. It can be in any format supported by
59
- :func:`eth_utils.to_hex`.
59
+ :func:`to_hex`.
60
60
 
61
61
  Raises:
62
62
  ValueError: If the input address is not in a recognized format.
@@ -110,3 +110,30 @@ def is_address(value: str) -> bool:
110
110
  - :func:`eth_utils.is_address` for the standard implementation.
111
111
  """
112
112
  return _HEX_ADDRESS_REGEXP.fullmatch(value) is not None
113
+
114
+
115
+ BytesLike = Union[Primitives, bytearray, memoryview]
116
+
117
+
118
+ def to_hex(
119
+ address_bytes: Optional[BytesLike] = None,
120
+ *,
121
+ hexstr: Optional[HexStr] = None,
122
+ ) -> HexStr:
123
+ """
124
+ Auto converts any supported value into its hex representation.
125
+ Trims leading zeros, as defined in:
126
+ https://github.com/ethereum/wiki/wiki/JSON-RPC#hex-value-encoding
127
+ """
128
+ if hexstr is not None:
129
+ return add_0x_prefix(hexstr.lower())
130
+
131
+ if isinstance(address_bytes, (bytes, bytearray)):
132
+ return encode_hex(address_bytes)
133
+
134
+ if isinstance(address_bytes, memoryview):
135
+ return encode_hex(bytes(address_bytes))
136
+
137
+ raise TypeError(
138
+ f"Unsupported type: '{repr(type(address_bytes))}'. Must be one of: bytes or bytearray."
139
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: cchecksum
3
- Version: 0.0.5
3
+ Version: 0.0.6
4
4
  Summary: A ~2x 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
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