faster-eth-utils 5.3.10__cp38-cp38-musllinux_1_2_x86_64.whl → 5.3.11__cp38-cp38-musllinux_1_2_x86_64.whl

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 faster-eth-utils might be problematic. Click here for more details.

faster_eth_utils/abi.py CHANGED
@@ -7,6 +7,7 @@ import re
7
7
  from typing import (
8
8
  Any,
9
9
  Dict,
10
+ Final,
10
11
  Iterable,
11
12
  List,
12
13
  Literal,
@@ -40,6 +41,9 @@ from .crypto import (
40
41
  )
41
42
 
42
43
 
44
+ ABIType = Literal["function", "constructor", "fallback", "receive", "event", "error"]
45
+
46
+
43
47
  def _align_abi_input(
44
48
  arg_abi: ABIComponent, normalized_arg: Any
45
49
  ) -> Union[Any, Tuple[Any, ...]]:
@@ -278,6 +282,16 @@ def filter_abi_by_name(abi_name: str, contract_abi: ABI) -> Sequence[ABIElement]
278
282
  ]
279
283
 
280
284
 
285
+ __ABI_TYPE_LITERALS: Final = {
286
+ Literal["function"]: "function",
287
+ Literal["constructor"]: "constructor",
288
+ Literal["fallback"]: "fallback",
289
+ Literal["receive"]: "receive",
290
+ Literal["event"]: "event",
291
+ Literal["error"]: "error",
292
+ }
293
+
294
+
281
295
  @overload
282
296
  def filter_abi_by_type(
283
297
  abi_type: Literal["function"],
@@ -327,9 +341,7 @@ def filter_abi_by_type(
327
341
 
328
342
 
329
343
  def filter_abi_by_type(
330
- abi_type: Literal[
331
- "function", "constructor", "fallback", "receive", "event", "error"
332
- ],
344
+ abi_type: ABIType,
333
345
  contract_abi: ABI,
334
346
  ) -> Union[
335
347
  List[ABIFunction], List[ABIConstructor], List[ABIFallback], List[ABIReceive], List[ABIEvent], List[ABIError]
@@ -361,20 +373,12 @@ ABIEvent, ABIError]]`
361
373
  [{'type': 'function', 'name': 'myFunction', 'inputs': [], 'outputs': []}, \
362
374
  {'type': 'function', 'name': 'myFunction2', 'inputs': [], 'outputs': []}]
363
375
  """
364
- if abi_type == Literal["function"] or abi_type == "function":
365
- return [abi for abi in contract_abi if abi["type"] == "function"]
366
- elif abi_type == Literal["constructor"] or abi_type == "constructor":
367
- return [abi for abi in contract_abi if abi["type"] == "constructor"]
368
- elif abi_type == Literal["fallback"] or abi_type == "fallback":
369
- return [abi for abi in contract_abi if abi["type"] == "fallback"]
370
- elif abi_type == Literal["receive"] or abi_type == "receive":
371
- return [abi for abi in contract_abi if abi["type"] == "receive"]
372
- elif abi_type == Literal["event"] or abi_type == "event":
373
- return [abi for abi in contract_abi if abi["type"] == "event"]
374
- elif abi_type == Literal["error"] or abi_type == "error":
375
- return [abi for abi in contract_abi if abi["type"] == "error"]
376
- else:
376
+ if abi_type in ("function", "constructor", "fallback", "receive", "event", "error"):
377
+ return [abi for abi in contract_abi if abi["type"] == abi_type] # type: ignore [return-value]
378
+ abi_type_string: Optional[ABIType] = __ABI_TYPE_LITERALS.get(abi_type) # type: ignore [call-overload]
379
+ if abi_type_string is None:
377
380
  raise ValueError(f"Unsupported ABI type: {abi_type}")
381
+ return [abi for abi in contract_abi if abi["type"] == abi_type_string] # type: ignore [return-value]
378
382
 
379
383
 
380
384
  def get_all_function_abis(contract_abi: ABI) -> Sequence[ABIFunction]:
@@ -50,9 +50,9 @@ def apply_formatter_at_index(
50
50
  f"Need: {at_index + 1}"
51
51
  ) from None
52
52
 
53
- yield from value[:at_index]
53
+ yield from cast(Sequence[TOther], value[:at_index])
54
54
  yield formatter(cast(TArg, item))
55
- yield from value[at_index + 1 :]
55
+ yield from cast(Sequence[TOther], value[at_index + 1 :])
56
56
 
57
57
 
58
58
  def combine_argument_formatters(*formatters: Callable[..., Any]) -> Formatters:
@@ -80,18 +80,20 @@ def combine_argument_formatters(*formatters: Callable[..., Any]) -> Formatters:
80
80
  def apply_formatters_to_sequence(
81
81
  formatters: List[Callable[[Any], TReturn]], sequence: Sequence[Any]
82
82
  ) -> Generator[TReturn, None, None]:
83
- if len(formatters) == len(sequence):
83
+ num_formatters = len(formatters)
84
+ num_items = len(sequence)
85
+ if num_formatters == num_items:
84
86
  for formatter, item in zip(formatters, sequence):
85
87
  yield formatter(item)
86
- elif len(formatters) > len(sequence):
88
+ elif num_formatters > num_items:
87
89
  raise IndexError(
88
- f"Too many formatters for sequence: {len(formatters)} formatters for "
89
- f"{repr(sequence)}"
90
+ f"Too many formatters for sequence: {num_formatters} formatters for "
91
+ f"{sequence!r}"
90
92
  )
91
93
  else:
92
94
  raise IndexError(
93
- f"Too few formatters for sequence: {len(formatters)} formatters for "
94
- f"{repr(sequence)}"
95
+ f"Too few formatters for sequence: {num_formatters} formatters for "
96
+ f"{sequence!r}"
95
97
  )
96
98
 
97
99
 
@@ -105,8 +107,8 @@ def apply_formatter_if(
105
107
  condition: Callable[[TArg], bool], formatter: Callable[[TArg], TReturn], value: TArg
106
108
  ) -> Union[TArg, TReturn]: ...
107
109
 
108
- def apply_formatter_if(
109
- condition: Union[Callable[[TArg], TypeGuard[TOther]], Callable[[Any], TypeGuard[TOther]], Callable[[TArg], bool]],
110
+ def apply_formatter_if( # type: ignore [misc]
111
+ condition: Union[Callable[[TArg], TypeGuard[TOther]], Callable[[TArg], bool]],
110
112
  formatter: Union[Callable[[TOther], TReturn], Callable[[TArg], TReturn]],
111
113
  value: TArg,
112
114
  ) -> Union[TArg, TReturn]:
@@ -116,12 +118,11 @@ def apply_formatter_if(
116
118
  return value
117
119
 
118
120
 
119
- @to_dict
120
121
  def apply_formatters_to_dict(
121
122
  formatters: Dict[Any, Any],
122
123
  value: Union[Dict[Any, Any], CamelModel],
123
124
  unaliased: bool = False,
124
- ) -> Generator[Tuple[Any, Any], None, None]:
125
+ ) -> Dict[Any, Any]:
125
126
  """
126
127
  Apply formatters to a dictionary of values. If the value is a pydantic model,
127
128
  it will be serialized to a dictionary first, taking into account the
@@ -136,22 +137,24 @@ def apply_formatters_to_dict(
136
137
  if isinstance(value, CamelModel):
137
138
  value = value.model_dump(by_alias=not unaliased)
138
139
 
139
- for key, item in value.items():
140
- if key in formatters:
141
- try:
142
- yield key, formatters[key](item)
143
- except ValueError as exc:
144
- new_error_message = (
145
- f"Could not format invalid value {repr(item)} as field {repr(key)}"
146
- )
147
- raise ValueError(new_error_message) from exc
148
- except TypeError as exc:
149
- new_error_message = (
150
- f"Could not format invalid type {repr(item)} as field {repr(key)}"
151
- )
152
- raise TypeError(new_error_message) from exc
153
- else:
154
- yield key, item
140
+ def get_value(key: Any, item: Any) -> Any:
141
+ if key not in formatters:
142
+ return item
143
+ try:
144
+ return formatters[key](item)
145
+ except ValueError as exc:
146
+ raise ValueError(
147
+ f"Could not format invalid value {repr(item)} as field {repr(key)}"
148
+ ) from exc
149
+ except TypeError as exc:
150
+ raise TypeError(
151
+ f"Could not format invalid type {repr(item)} as field {repr(key)}"
152
+ ) from exc
153
+
154
+ return {
155
+ key: get_value(key, item) if key in formatters else key
156
+ for key, item in value.items()
157
+ }
155
158
 
156
159
 
157
160
  @return_arg_type(1)
@@ -175,10 +178,9 @@ def apply_one_of_formatters(
175
178
  )
176
179
 
177
180
 
178
- @to_dict
179
181
  def apply_key_map(
180
182
  key_mappings: Dict[Any, Any], value: Dict[Any, Any]
181
- ) -> Generator[Tuple[Any, Any], None, None]:
183
+ ) -> Dict[Any, Any]:
182
184
  key_conflicts = (
183
185
  set(value.keys())
184
186
  .difference(key_mappings.keys())
@@ -189,8 +191,7 @@ def apply_key_map(
189
191
  f"Could not apply key map due to conflicting key(s): {key_conflicts}"
190
192
  )
191
193
 
192
- for key, item in value.items():
193
- if key in key_mappings:
194
- yield key_mappings[key], item
195
- else:
196
- yield key, item
194
+ def get_key(key: Any) -> Any:
195
+ return key_mappings[key] if key in key_mappings else key
196
+
197
+ return {get_key(key): item for key, item in value.items()}
@@ -1,4 +1,11 @@
1
- class ValidationError(Exception):
1
+ """
2
+ faster-eth-utils exceptions always inherit from eth-utils exceptions, so porting to faster-eth-utils
3
+ does not require any change to your existing exception handlers. They will continue to work.
4
+ """
5
+
6
+ import eth_utils.exceptions
7
+
8
+ class ValidationError(eth_utils.exceptions.ValidationError):
2
9
  """
3
10
  Raised when something does not pass a validation check.
4
11
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: faster-eth-utils
3
- Version: 5.3.10
3
+ Version: 5.3.11
4
4
  Summary: A fork of eth-utils: Common utility functions for python code that interacts with Ethereum, implemented in C
5
5
  Home-page: https://github.com/BobTheBuidler/eth-utils
6
6
  Author: The Ethereum Foundation
@@ -24,6 +24,7 @@ License-File: LICENSE
24
24
  Requires-Dist: cchecksum>=0.0.3
25
25
  Requires-Dist: eth-hash>=0.3.1
26
26
  Requires-Dist: eth-typing>=5.0.0
27
+ Requires-Dist: eth-utils<6,>=5.2.0
27
28
  Requires-Dist: pydantic<3,>=2.0.0
28
29
  Requires-Dist: cytoolz>=0.10.1; implementation_name == "cpython"
29
30
  Requires-Dist: toolz>0.8.2; implementation_name == "pypy"
@@ -40,7 +41,7 @@ Requires-Dist: wheel; extra == "dev"
40
41
  Requires-Dist: sphinx>=6.0.0; extra == "dev"
41
42
  Requires-Dist: sphinx-autobuild>=2021.3.14; extra == "dev"
42
43
  Requires-Dist: sphinx-rtd-theme>=1.0.0; extra == "dev"
43
- Requires-Dist: towncrier<25,>=24; extra == "dev"
44
+ Requires-Dist: towncrier<26,>=24; extra == "dev"
44
45
  Requires-Dist: hypothesis>=4.43.0; extra == "dev"
45
46
  Requires-Dist: pytest>=7.0.0; extra == "dev"
46
47
  Requires-Dist: pytest-codspeed>=2.0.0; extra == "dev"
@@ -49,7 +50,7 @@ Provides-Extra: docs
49
50
  Requires-Dist: sphinx>=6.0.0; extra == "docs"
50
51
  Requires-Dist: sphinx-autobuild>=2021.3.14; extra == "docs"
51
52
  Requires-Dist: sphinx-rtd-theme>=1.0.0; extra == "docs"
52
- Requires-Dist: towncrier<25,>=24; extra == "docs"
53
+ Requires-Dist: towncrier<26,>=24; extra == "docs"
53
54
  Provides-Extra: test
54
55
  Requires-Dist: hypothesis>=4.43.0; extra == "test"
55
56
  Requires-Dist: mypy==1.14.1; extra == "test"
@@ -65,10 +66,14 @@ Requires-Dist: pytest-xdist>=2.4.0; extra == "test"
65
66
 
66
67
  ##### This fork will be kept up-to-date with [eth-utils](https://github.com/ethereum/eth-utils). I will pull updates as they are released and push new [faster-eth-utils](https://github.com/BobTheBuidler/faster-eth-utils) releases to [PyPI](https://pypi.org/project/faster-eth-utils/).
67
68
 
68
- ##### You can find the compiled C code on faster-eth-utils [master](https://github.com/BobTheBuidler/eth-utils/tree/master) branch.
69
+ ##### Starting in [v5.3.11](https://github.com/BobTheBuidler/faster-eth-utils/releases/tag/v5.3.11), all `faster-eth-utils` Exception classes inherit from the matching Exception class in `eth-utils`, so porting to `faster-eth-utils` does not require any change to your existing exception handlers. All existing exception handling in your codebase will continue to work as it did when originaly implemented.
69
70
 
70
71
  ##### We benchmark `faster-eth-utils` against the original `eth-utils` for your convenience. [See results](https://github.com/BobTheBuidler/faster-eth-utils/tree/master/benchmarks/results).
71
72
 
73
+ ##### You can find the compiled C code on faster-eth-utils [master](https://github.com/BobTheBuidler/eth-utils/tree/master) branch.
74
+
75
+ ###### You may also be interested in: [faster-web3.py](https://github.com/BobTheBuidler/faster-web3.py/), [faster-eth-abi](https://github.com/BobTheBuidler/faster-eth-abi/), and [faster-hexbytes](https://github.com/BobTheBuidler/faster-hexbytes/)
76
+
72
77
  ##### The original eth-utils readme is below:
73
78
 
74
79
  # Ethereum Utilities
@@ -1,12 +1,12 @@
1
- 99c07adba6ff961eaf3e__mypyc.cpython-38-x86_64-linux-gnu.so,sha256=bmUb4VXfobh2ud915mO89Q01aJ4jXtObPnQtdKD3ZSA,1393344
1
+ 99c07adba6ff961eaf3e__mypyc.cpython-38-x86_64-linux-gnu.so,sha256=lMkFXhh7vPD6DWS4W945h0OYaTDRgW4CH0Fcyszy7HU,1375144
2
2
  faster_eth_utils/__init__.py,sha256=hW-A_fjyQ76crTKwuxxSbvNzvPfW27dSlzhtOkseymg,2762
3
3
  faster_eth_utils/__main__.py,sha256=mH37e49q7_A0-q1ymqkq1QyYABbQHVmXeuSKIBSahO8,86
4
4
  faster_eth_utils/abi.cpython-38-x86_64-linux-gnu.so,sha256=E4KZxRse-11Jwzsip35CD5dYBuQ2QBXN3qrOQiTSolk,17416
5
- faster_eth_utils/abi.py,sha256=2Lk78YiWLIG_srH2nTYny8tYrxM7JS-zWNpBe8ACMEs,26544
5
+ faster_eth_utils/abi.py,sha256=3pAqpKXMOcOLCD4uUUVfxBcM9H1K311dpd1Zj0Qi21g,26404
6
6
  faster_eth_utils/address.cpython-38-x86_64-linux-gnu.so,sha256=iqAxHwMXFnib36FVEf1gcKeOs4HG1IcHMiZZ8DNaZSA,17432
7
7
  faster_eth_utils/address.py,sha256=IIHlYuIz-F6-mAnRWdsD4uH5l56yVRFMokFQINao9lE,3680
8
8
  faster_eth_utils/applicators.cpython-38-x86_64-linux-gnu.so,sha256=Vj0RmWtWkCRgrxwfkGoPCrRVXkKMZPLpi-K653d_fX4,17448
9
- faster_eth_utils/applicators.py,sha256=dcmcvx2PvK7I6xilt02mlr8OmEOTOeajh3uAbZoOONg,5842
9
+ faster_eth_utils/applicators.py,sha256=LEffyul-ZdsAhNB7H7E6e-J4fXw7bUt0NxrkjZWMHkA,5833
10
10
  faster_eth_utils/conversions.cpython-38-x86_64-linux-gnu.so,sha256=F3aHZFbWNzdcRlrhW89qR6301xIr0TxuYANcfqytuQc,17448
11
11
  faster_eth_utils/conversions.py,sha256=t2TEe0WsffqOFDbyQcERTSbHJYpDBWHKd8XPArhLoEE,5665
12
12
  faster_eth_utils/crypto.cpython-38-x86_64-linux-gnu.so,sha256=aH1uwiLRs1vIr4GlbUVDqU7e4P8ftxc6aELnwXvregY,17424
@@ -20,7 +20,7 @@ faster_eth_utils/decorators.py,sha256=BdAz-imQIf0TlBm7Di7T05o3IC6ei-xJc7FgIOqqAy
20
20
  faster_eth_utils/encoding.cpython-38-x86_64-linux-gnu.so,sha256=iDjtteDybS1bDIZeY5WOJilGgoOxHGkp_dk3X3vgfYs,17440
21
21
  faster_eth_utils/encoding.py,sha256=1qfDeuinLZ01XjYgknpm_p9LuWwaYvicYkYI8mS1iMc,199
22
22
  faster_eth_utils/exceptions.cpython-38-x86_64-linux-gnu.so,sha256=lzx1SMU2_oa7VsR9O5oos2MM0nalTi_bwJtUA2ZQBm0,17440
23
- faster_eth_utils/exceptions.py,sha256=3ndM6zl4QoSc6GupV9T1Klz9TByM8w2zr4ez8UJvzew,110
23
+ faster_eth_utils/exceptions.py,sha256=7Cjxewj4g95RxNvjNqaB2w3HGk6068V82ppCHS_S-Y0,369
24
24
  faster_eth_utils/functional.cpython-38-x86_64-linux-gnu.so,sha256=LSf71b8DVzpqG19wjLxYwpiRA_Jg3biVYYuTsf7VUao,17440
25
25
  faster_eth_utils/functional.py,sha256=nJTxE4_HDci0chos5mQdy05pJ8o7n0wx_o7_WCro2gI,2449
26
26
  faster_eth_utils/hexadecimal.cpython-38-x86_64-linux-gnu.so,sha256=gEEls8vy7pDvzDvbbW5dNXk70XuH3urjMRJjCWAU2ss,17448
@@ -46,8 +46,8 @@ faster_eth_utils/__json/eth_networks.json,sha256=0S8HoWD6RTR6Hc0uQdQl2VHtopytIYl
46
46
  faster_eth_utils/curried/__init__.py,sha256=x_nPjvTwmXeEl5jV86RRUvudu6ks1kMUxZfbjNuGx8Y,7407
47
47
  faster_eth_utils/typing/__init__.py,sha256=84PxIxCvEHtBb-Ik6qnGvXH4alaWbamr_zDbtlbJh3A,325
48
48
  faster_eth_utils/typing/misc.py,sha256=4N5raYXFAeRGpmch6qgHrtYNCDxCJM5XtAAsJ1FSzzU,190
49
- faster_eth_utils-5.3.10.dist-info/LICENSE,sha256=STqznQ6A8OeJylPrTA7dlsMtH0isQQybRlnDZOKGVrM,1095
50
- faster_eth_utils-5.3.10.dist-info/METADATA,sha256=c1GOzh-ndbPQ5AjXVxQzdTU23_0rseQx5y7vsn6Zbw4,6775
51
- faster_eth_utils-5.3.10.dist-info/WHEEL,sha256=AtKzrIIwO6LyEQPNa-CKogjoLSeXFnST8-hqmpwwZQA,110
52
- faster_eth_utils-5.3.10.dist-info/top_level.txt,sha256=8eOy3WlvVLCcmwPnl2UMylYQNmrXz76p9L_TH-NYSSM,55
53
- faster_eth_utils-5.3.10.dist-info/RECORD,,
49
+ faster_eth_utils-5.3.11.dist-info/LICENSE,sha256=STqznQ6A8OeJylPrTA7dlsMtH0isQQybRlnDZOKGVrM,1095
50
+ faster_eth_utils-5.3.11.dist-info/METADATA,sha256=SP0G6owcAkOXrTZ1fiil-xt0P4wBG9uh42rObUwzZ10,7466
51
+ faster_eth_utils-5.3.11.dist-info/WHEEL,sha256=AtKzrIIwO6LyEQPNa-CKogjoLSeXFnST8-hqmpwwZQA,110
52
+ faster_eth_utils-5.3.11.dist-info/top_level.txt,sha256=8eOy3WlvVLCcmwPnl2UMylYQNmrXz76p9L_TH-NYSSM,55
53
+ faster_eth_utils-5.3.11.dist-info/RECORD,,