faster-eth-abi 5.2.8__cp38-cp38-win_amd64.whl → 5.2.10__cp38-cp38-win_amd64.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-abi might be problematic. Click here for more details.
- 76f9a3652d4d2667c55c__mypyc.cp38-win_amd64.pyd +0 -0
- faster_eth_abi/_codec.cp38-win_amd64.pyd +0 -0
- faster_eth_abi/_decoding.cp38-win_amd64.pyd +0 -0
- faster_eth_abi/_decoding.py +58 -20
- faster_eth_abi/_encoding.cp38-win_amd64.pyd +0 -0
- faster_eth_abi/_encoding.py +12 -5
- faster_eth_abi/abi.cp38-win_amd64.pyd +0 -0
- faster_eth_abi/constants.cp38-win_amd64.pyd +0 -0
- faster_eth_abi/decoding.py +39 -55
- faster_eth_abi/encoding.py +0 -2
- faster_eth_abi/from_type_str.cp38-win_amd64.pyd +0 -0
- faster_eth_abi/packed.cp38-win_amd64.pyd +0 -0
- faster_eth_abi/tools/__init__.cp38-win_amd64.pyd +0 -0
- faster_eth_abi/tools/_strategies.cp38-win_amd64.pyd +0 -0
- faster_eth_abi/utils/__init__.cp38-win_amd64.pyd +0 -0
- faster_eth_abi/utils/numeric.cp38-win_amd64.pyd +0 -0
- faster_eth_abi/utils/numeric.py +51 -20
- faster_eth_abi/utils/padding.cp38-win_amd64.pyd +0 -0
- faster_eth_abi/utils/string.cp38-win_amd64.pyd +0 -0
- faster_eth_abi/utils/validation.cp38-win_amd64.pyd +0 -0
- {faster_eth_abi-5.2.8.dist-info → faster_eth_abi-5.2.10.dist-info}/METADATA +1 -1
- faster_eth_abi-5.2.10.dist-info/RECORD +44 -0
- faster_eth_abi-5.2.8.dist-info/RECORD +0 -44
- {faster_eth_abi-5.2.8.dist-info → faster_eth_abi-5.2.10.dist-info}/LICENSE +0 -0
- {faster_eth_abi-5.2.8.dist-info → faster_eth_abi-5.2.10.dist-info}/WHEEL +0 -0
- {faster_eth_abi-5.2.8.dist-info → faster_eth_abi-5.2.10.dist-info}/top_level.txt +0 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
faster_eth_abi/_decoding.py
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
from typing import (
|
|
2
2
|
TYPE_CHECKING,
|
|
3
3
|
Any,
|
|
4
|
-
Optional,
|
|
5
4
|
Tuple,
|
|
6
5
|
)
|
|
7
6
|
|
|
7
|
+
from faster_eth_utils import (
|
|
8
|
+
big_endian_to_int,
|
|
9
|
+
)
|
|
10
|
+
|
|
8
11
|
from faster_eth_abi.exceptions import (
|
|
9
12
|
InsufficientDataBytes,
|
|
13
|
+
NonEmptyPaddingBytes,
|
|
10
14
|
)
|
|
11
15
|
from faster_eth_abi.io import (
|
|
12
16
|
BytesIO,
|
|
@@ -20,31 +24,25 @@ if TYPE_CHECKING:
|
|
|
20
24
|
HeadTailDecoder,
|
|
21
25
|
SizedArrayDecoder,
|
|
22
26
|
TupleDecoder,
|
|
23
|
-
UnsignedIntegerDecoder,
|
|
24
27
|
)
|
|
25
28
|
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
# this helper breaks a circular dependency on the non-compiled decoding module
|
|
32
|
-
from . import (
|
|
33
|
-
decoding,
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
global _UINT256_DECODER
|
|
37
|
-
_UINT256_DECODER = decoding.decode_uint_256
|
|
30
|
+
# Helpers
|
|
31
|
+
def decode_uint_256(stream: ContextFramesBytesIO) -> int:
|
|
32
|
+
"""
|
|
33
|
+
This function is a faster version of decode_uint_256 in decoding.py.
|
|
38
34
|
|
|
39
|
-
|
|
35
|
+
It recreates the logic from the UnsignedIntegerDecoder, but we can
|
|
36
|
+
skip a lot because we know the value of many vars.
|
|
37
|
+
"""
|
|
38
|
+
# read data from stream
|
|
39
|
+
if len(data := stream.read(32)) == 32:
|
|
40
|
+
return big_endian_to_int(data) # type: ignore [no-any-return]
|
|
41
|
+
raise InsufficientDataBytes(f"Tried to read 32 bytes, only got {len(data)} bytes.")
|
|
40
42
|
|
|
41
43
|
|
|
42
|
-
def
|
|
43
|
-
decoder
|
|
44
|
-
if decoder is None:
|
|
45
|
-
decoder = __set_uint256_decoder()
|
|
46
|
-
decoded: int = decoder(stream)
|
|
47
|
-
return decoded
|
|
44
|
+
def get_value_byte_size(decoder: "FixedByteSizeDecoder") -> int:
|
|
45
|
+
return decoder.value_bit_size // 8
|
|
48
46
|
|
|
49
47
|
|
|
50
48
|
# HeadTailDecoder
|
|
@@ -115,3 +113,43 @@ def read_fixed_byte_size_data_from_stream(
|
|
|
115
113
|
raise InsufficientDataBytes(
|
|
116
114
|
f"Tried to read {data_byte_size} bytes, only got {len(data)} bytes."
|
|
117
115
|
)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def split_data_and_padding_fixed_byte_size(
|
|
119
|
+
self: "FixedByteSizeDecoder",
|
|
120
|
+
raw_data: bytes,
|
|
121
|
+
) -> Tuple[bytes, bytes]:
|
|
122
|
+
value_byte_size = get_value_byte_size(self)
|
|
123
|
+
padding_size = self.data_byte_size - value_byte_size
|
|
124
|
+
|
|
125
|
+
if self.is_big_endian:
|
|
126
|
+
if padding_size == 0:
|
|
127
|
+
return raw_data, b""
|
|
128
|
+
padding_bytes = raw_data[:padding_size]
|
|
129
|
+
data = raw_data[padding_size:]
|
|
130
|
+
else:
|
|
131
|
+
data = raw_data[:value_byte_size]
|
|
132
|
+
padding_bytes = raw_data[value_byte_size:]
|
|
133
|
+
|
|
134
|
+
return data, padding_bytes
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def validate_padding_bytes_fixed_byte_size(
|
|
138
|
+
self: "FixedByteSizeDecoder",
|
|
139
|
+
value: Any,
|
|
140
|
+
padding_bytes: bytes,
|
|
141
|
+
) -> None:
|
|
142
|
+
value_byte_size = get_value_byte_size(self)
|
|
143
|
+
padding_size = self.data_byte_size - value_byte_size
|
|
144
|
+
|
|
145
|
+
if padding_bytes != b"\x00" * padding_size:
|
|
146
|
+
raise NonEmptyPaddingBytes(f"Padding bytes were not empty: {padding_bytes!r}")
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
# BooleanDecoder
|
|
150
|
+
def decoder_fn_boolean(data: bytes) -> bool:
|
|
151
|
+
if data == b"\x00":
|
|
152
|
+
return False
|
|
153
|
+
elif data == b"\x01":
|
|
154
|
+
return True
|
|
155
|
+
raise NonEmptyPaddingBytes(f"Boolean must be either 0x0 or 0x1. Got: {data!r}")
|
|
Binary file
|
faster_eth_abi/_encoding.py
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
from itertools import (
|
|
2
|
-
accumulate,
|
|
3
|
-
)
|
|
4
1
|
from typing import (
|
|
5
2
|
TYPE_CHECKING,
|
|
6
3
|
Any,
|
|
@@ -35,7 +32,12 @@ def encode_tuple(
|
|
|
35
32
|
tail_chunks.append(b"")
|
|
36
33
|
|
|
37
34
|
head_length = sum(32 if item is None else len(item) for item in raw_head_chunks)
|
|
38
|
-
tail_offsets =
|
|
35
|
+
tail_offsets = [0]
|
|
36
|
+
total_offset = 0
|
|
37
|
+
for item in tail_chunks[:-1]:
|
|
38
|
+
total_offset += len(item)
|
|
39
|
+
tail_offsets.append(total_offset)
|
|
40
|
+
|
|
39
41
|
head_chunks = tuple(
|
|
40
42
|
encode_uint_256(head_length + offset) if chunk is None else chunk
|
|
41
43
|
for chunk, offset in zip(raw_head_chunks, tail_offsets)
|
|
@@ -77,7 +79,12 @@ def encode_elements(item_encoder: "BaseEncoder", value: Sequence[Any]) -> bytes:
|
|
|
77
79
|
return b"".join(tail_chunks)
|
|
78
80
|
|
|
79
81
|
head_length = 32 * len(value)
|
|
80
|
-
tail_offsets =
|
|
82
|
+
tail_offsets = [0]
|
|
83
|
+
total_offset = 0
|
|
84
|
+
for item in tail_chunks[:-1]:
|
|
85
|
+
total_offset += len(item)
|
|
86
|
+
tail_offsets.append(total_offset)
|
|
87
|
+
|
|
81
88
|
head_chunks = tuple(
|
|
82
89
|
encode_uint_256(head_length + offset) for offset in tail_offsets
|
|
83
90
|
)
|
|
Binary file
|
|
Binary file
|
faster_eth_abi/decoding.py
CHANGED
|
@@ -19,7 +19,11 @@ from faster_eth_abi._decoding import (
|
|
|
19
19
|
decode_head_tail,
|
|
20
20
|
decode_sized_array,
|
|
21
21
|
decode_tuple,
|
|
22
|
+
decoder_fn_boolean,
|
|
23
|
+
get_value_byte_size,
|
|
22
24
|
read_fixed_byte_size_data_from_stream,
|
|
25
|
+
split_data_and_padding_fixed_byte_size,
|
|
26
|
+
validate_padding_bytes_fixed_byte_size,
|
|
23
27
|
)
|
|
24
28
|
from faster_eth_abi.base import (
|
|
25
29
|
BaseCoder,
|
|
@@ -98,14 +102,14 @@ class TupleDecoder(BaseDecoder):
|
|
|
98
102
|
def __init__(self, decoders: Tuple[BaseDecoder, ...], **kwargs: Any) -> None:
|
|
99
103
|
super().__init__(**kwargs)
|
|
100
104
|
|
|
101
|
-
self.decoders = tuple(
|
|
105
|
+
self.decoders = decoders = tuple(
|
|
102
106
|
HeadTailDecoder(tail_decoder=d) if getattr(d, "is_dynamic", False) else d
|
|
103
107
|
for d in decoders
|
|
104
108
|
)
|
|
105
109
|
|
|
106
|
-
self.is_dynamic = any(getattr(d, "is_dynamic", False) for d in
|
|
110
|
+
self.is_dynamic = any(getattr(d, "is_dynamic", False) for d in decoders)
|
|
107
111
|
self.len_of_head = sum(
|
|
108
|
-
getattr(decoder, "array_size", 1) for decoder in
|
|
112
|
+
getattr(decoder, "array_size", 1) for decoder in decoders
|
|
109
113
|
)
|
|
110
114
|
|
|
111
115
|
def validate(self) -> None:
|
|
@@ -173,9 +177,10 @@ class SingleDecoder(BaseDecoder):
|
|
|
173
177
|
def decode(self, stream):
|
|
174
178
|
raw_data = self.read_data_from_stream(stream)
|
|
175
179
|
data, padding_bytes = self.split_data_and_padding(raw_data)
|
|
176
|
-
|
|
180
|
+
decoder_fn = self.decoder_fn
|
|
181
|
+
if decoder_fn is None:
|
|
177
182
|
raise AssertionError("`decoder_fn` is None")
|
|
178
|
-
value =
|
|
183
|
+
value = decoder_fn(data)
|
|
179
184
|
self.validate_padding_bytes(value, padding_bytes)
|
|
180
185
|
|
|
181
186
|
return value
|
|
@@ -190,16 +195,15 @@ class SingleDecoder(BaseDecoder):
|
|
|
190
195
|
|
|
191
196
|
|
|
192
197
|
class BaseArrayDecoder(BaseDecoder):
|
|
193
|
-
item_decoder = None
|
|
198
|
+
item_decoder: BaseDecoder = None
|
|
194
199
|
|
|
195
200
|
def __init__(self, **kwargs: Any) -> None:
|
|
196
201
|
super().__init__(**kwargs)
|
|
197
202
|
|
|
198
203
|
# Use a head-tail decoder to decode dynamic elements
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
)
|
|
204
|
+
item_decoder = self.item_decoder
|
|
205
|
+
if item_decoder.is_dynamic:
|
|
206
|
+
self.item_decoder = HeadTailDecoder(tail_decoder=item_decoder)
|
|
203
207
|
|
|
204
208
|
def validate(self) -> None:
|
|
205
209
|
super().validate()
|
|
@@ -280,51 +284,37 @@ class FixedByteSizeDecoder(SingleDecoder):
|
|
|
280
284
|
def validate(self) -> None:
|
|
281
285
|
super().validate()
|
|
282
286
|
|
|
283
|
-
|
|
287
|
+
value_bit_size = self.value_bit_size
|
|
288
|
+
if value_bit_size is None:
|
|
284
289
|
raise ValueError("`value_bit_size` may not be None")
|
|
285
|
-
|
|
290
|
+
data_byte_size = self.data_byte_size
|
|
291
|
+
if data_byte_size is None:
|
|
286
292
|
raise ValueError("`data_byte_size` may not be None")
|
|
287
293
|
if self.decoder_fn is None:
|
|
288
294
|
raise ValueError("`decoder_fn` may not be None")
|
|
289
295
|
if self.is_big_endian is None:
|
|
290
296
|
raise ValueError("`is_big_endian` may not be None")
|
|
291
297
|
|
|
292
|
-
if
|
|
298
|
+
if value_bit_size % 8 != 0:
|
|
293
299
|
raise ValueError(
|
|
294
|
-
"Invalid value bit size: {
|
|
300
|
+
f"Invalid value bit size: {value_bit_size}. Must be a multiple of 8"
|
|
295
301
|
)
|
|
296
302
|
|
|
297
|
-
if
|
|
303
|
+
if value_bit_size > data_byte_size * 8:
|
|
298
304
|
raise ValueError("Value byte size exceeds data size")
|
|
299
305
|
|
|
300
306
|
def read_data_from_stream(self, stream: ContextFramesBytesIO) -> bytes:
|
|
301
307
|
return read_fixed_byte_size_data_from_stream(self, stream)
|
|
302
308
|
|
|
303
309
|
def split_data_and_padding(self, raw_data: bytes) -> Tuple[bytes, bytes]:
|
|
304
|
-
|
|
305
|
-
padding_size = self.data_byte_size - value_byte_size
|
|
306
|
-
|
|
307
|
-
if self.is_big_endian:
|
|
308
|
-
padding_bytes = raw_data[:padding_size]
|
|
309
|
-
data = raw_data[padding_size:]
|
|
310
|
-
else:
|
|
311
|
-
data = raw_data[:value_byte_size]
|
|
312
|
-
padding_bytes = raw_data[value_byte_size:]
|
|
313
|
-
|
|
314
|
-
return data, padding_bytes
|
|
310
|
+
return split_data_and_padding_fixed_byte_size(self, raw_data)
|
|
315
311
|
|
|
316
312
|
def validate_padding_bytes(self, value: Any, padding_bytes: bytes) -> None:
|
|
317
|
-
|
|
318
|
-
padding_size = self.data_byte_size - value_byte_size
|
|
319
|
-
|
|
320
|
-
if padding_bytes != b"\x00" * padding_size:
|
|
321
|
-
raise NonEmptyPaddingBytes(
|
|
322
|
-
f"Padding bytes were not empty: {padding_bytes!r}"
|
|
323
|
-
)
|
|
313
|
+
validate_padding_bytes_fixed_byte_size(self, value, padding_bytes)
|
|
324
314
|
|
|
325
|
-
def _get_value_byte_size(self):
|
|
326
|
-
|
|
327
|
-
return
|
|
315
|
+
def _get_value_byte_size(self) -> int:
|
|
316
|
+
# This is unused, but it is kept in to preserve the eth-abi api
|
|
317
|
+
return get_value_byte_size(self)
|
|
328
318
|
|
|
329
319
|
|
|
330
320
|
class Fixed32ByteSizeDecoder(FixedByteSizeDecoder):
|
|
@@ -335,16 +325,7 @@ class BooleanDecoder(Fixed32ByteSizeDecoder):
|
|
|
335
325
|
value_bit_size = 8
|
|
336
326
|
is_big_endian = True
|
|
337
327
|
|
|
338
|
-
|
|
339
|
-
def decoder_fn(data):
|
|
340
|
-
if data == b"\x00":
|
|
341
|
-
return False
|
|
342
|
-
elif data == b"\x01":
|
|
343
|
-
return True
|
|
344
|
-
else:
|
|
345
|
-
raise NonEmptyPaddingBytes(
|
|
346
|
-
f"Boolean must be either 0x0 or 0x1. Got: {data!r}"
|
|
347
|
-
)
|
|
328
|
+
decoder_fn = staticmethod(decoder_fn_boolean)
|
|
348
329
|
|
|
349
330
|
@parse_type_str("bool")
|
|
350
331
|
def from_type_str(cls, abi_type, registry):
|
|
@@ -384,13 +365,14 @@ class SignedIntegerDecoder(Fixed32ByteSizeDecoder):
|
|
|
384
365
|
|
|
385
366
|
def decoder_fn(self, data):
|
|
386
367
|
value = big_endian_to_int(data)
|
|
387
|
-
|
|
388
|
-
|
|
368
|
+
value_bit_size = self.value_bit_size
|
|
369
|
+
if value >= 2 ** (value_bit_size - 1):
|
|
370
|
+
return value - 2**value_bit_size
|
|
389
371
|
else:
|
|
390
372
|
return value
|
|
391
373
|
|
|
392
374
|
def validate_padding_bytes(self, value: Any, padding_bytes: bytes) -> None:
|
|
393
|
-
value_byte_size = self
|
|
375
|
+
value_byte_size = get_value_byte_size(self)
|
|
394
376
|
padding_size = self.data_byte_size - value_byte_size
|
|
395
377
|
|
|
396
378
|
if value >= 0:
|
|
@@ -424,16 +406,17 @@ class BytesDecoder(Fixed32ByteSizeDecoder):
|
|
|
424
406
|
|
|
425
407
|
|
|
426
408
|
class BaseFixedDecoder(Fixed32ByteSizeDecoder):
|
|
427
|
-
frac_places = None
|
|
409
|
+
frac_places: int = None
|
|
428
410
|
is_big_endian = True
|
|
429
411
|
|
|
430
412
|
def validate(self) -> None:
|
|
431
413
|
super().validate()
|
|
432
414
|
|
|
433
|
-
|
|
415
|
+
frac_places = self.frac_places
|
|
416
|
+
if frac_places is None:
|
|
434
417
|
raise ValueError("must specify `frac_places`")
|
|
435
418
|
|
|
436
|
-
if
|
|
419
|
+
if frac_places <= 0 or frac_places > 80:
|
|
437
420
|
raise ValueError("`frac_places` must be in range (0, 80]")
|
|
438
421
|
|
|
439
422
|
|
|
@@ -456,8 +439,9 @@ class UnsignedFixedDecoder(BaseFixedDecoder):
|
|
|
456
439
|
class SignedFixedDecoder(BaseFixedDecoder):
|
|
457
440
|
def decoder_fn(self, data):
|
|
458
441
|
value = big_endian_to_int(data)
|
|
459
|
-
|
|
460
|
-
|
|
442
|
+
value_bit_size = self.value_bit_size
|
|
443
|
+
if value >= 2 ** (value_bit_size - 1):
|
|
444
|
+
signed_value = value - 2**value_bit_size
|
|
461
445
|
else:
|
|
462
446
|
signed_value = value
|
|
463
447
|
|
|
@@ -467,7 +451,7 @@ class SignedFixedDecoder(BaseFixedDecoder):
|
|
|
467
451
|
return decimal_value
|
|
468
452
|
|
|
469
453
|
def validate_padding_bytes(self, value: Any, padding_bytes: bytes) -> None:
|
|
470
|
-
value_byte_size = self
|
|
454
|
+
value_byte_size = get_value_byte_size(self)
|
|
471
455
|
padding_size = self.data_byte_size - value_byte_size
|
|
472
456
|
|
|
473
457
|
if value >= 0:
|
faster_eth_abi/encoding.py
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
faster_eth_abi/utils/numeric.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import decimal
|
|
2
2
|
from typing import (
|
|
3
3
|
Callable,
|
|
4
|
+
Dict,
|
|
4
5
|
Final,
|
|
5
6
|
Tuple,
|
|
6
7
|
)
|
|
@@ -8,6 +9,7 @@ from typing import (
|
|
|
8
9
|
ABI_DECIMAL_PREC: Final = 999
|
|
9
10
|
|
|
10
11
|
abi_decimal_context: Final = decimal.Context(prec=ABI_DECIMAL_PREC)
|
|
12
|
+
decimal_localcontext: Final = decimal.localcontext
|
|
11
13
|
|
|
12
14
|
ZERO: Final = decimal.Decimal(0)
|
|
13
15
|
TEN: Final = decimal.Decimal(10)
|
|
@@ -16,47 +18,76 @@ Decimal: Final = decimal.Decimal
|
|
|
16
18
|
|
|
17
19
|
|
|
18
20
|
def ceil32(x: int) -> int:
|
|
19
|
-
|
|
21
|
+
remainder = x % 32
|
|
22
|
+
return x if remainder == 0 else x + 32 - remainder
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
_unsigned_integer_bounds_cache: Final[Dict[int, Tuple[int, int]]] = {}
|
|
20
26
|
|
|
21
27
|
|
|
22
28
|
def compute_unsigned_integer_bounds(num_bits: int) -> Tuple[int, int]:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
2**num_bits - 1
|
|
26
|
-
|
|
29
|
+
bounds = _unsigned_integer_bounds_cache.get(num_bits)
|
|
30
|
+
if bounds is None:
|
|
31
|
+
bounds = 0, 2**num_bits - 1
|
|
32
|
+
_unsigned_integer_bounds_cache[num_bits] = bounds
|
|
33
|
+
return bounds
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
_signed_integer_bounds_cache: Final[Dict[int, Tuple[int, int]]] = {}
|
|
27
37
|
|
|
28
38
|
|
|
29
39
|
def compute_signed_integer_bounds(num_bits: int) -> Tuple[int, int]:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
2 ** (num_bits - 1)
|
|
33
|
-
|
|
40
|
+
bounds = _signed_integer_bounds_cache.get(num_bits)
|
|
41
|
+
if bounds is None:
|
|
42
|
+
overflow_at = 2 ** (num_bits - 1)
|
|
43
|
+
min_value = -overflow_at
|
|
44
|
+
max_value = overflow_at - 1
|
|
45
|
+
bounds = min_value, max_value
|
|
46
|
+
_signed_integer_bounds_cache[num_bits] = bounds
|
|
47
|
+
return bounds
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
_unsigned_fixed_bounds_cache: Final[Dict[Tuple[int, int], decimal.Decimal]] = {}
|
|
34
51
|
|
|
35
52
|
|
|
36
53
|
def compute_unsigned_fixed_bounds(
|
|
37
54
|
num_bits: int,
|
|
38
55
|
frac_places: int,
|
|
39
56
|
) -> Tuple[decimal.Decimal, decimal.Decimal]:
|
|
40
|
-
|
|
57
|
+
upper = _unsigned_fixed_bounds_cache.get((num_bits, frac_places))
|
|
58
|
+
if upper is None:
|
|
59
|
+
int_upper = 2**num_bits - 1
|
|
60
|
+
|
|
61
|
+
with decimal_localcontext(abi_decimal_context):
|
|
62
|
+
upper = Decimal(int_upper) * TEN**-frac_places
|
|
41
63
|
|
|
42
|
-
|
|
43
|
-
upper = Decimal(int_upper) * TEN**-frac_places
|
|
64
|
+
_unsigned_fixed_bounds_cache[(num_bits, frac_places)] = upper
|
|
44
65
|
|
|
45
66
|
return ZERO, upper
|
|
46
67
|
|
|
47
68
|
|
|
69
|
+
_signed_fixed_bounds_cache: Final[
|
|
70
|
+
Dict[Tuple[int, int], Tuple[decimal.Decimal, decimal.Decimal]]
|
|
71
|
+
] = {}
|
|
72
|
+
|
|
73
|
+
|
|
48
74
|
def compute_signed_fixed_bounds(
|
|
49
75
|
num_bits: int,
|
|
50
76
|
frac_places: int,
|
|
51
77
|
) -> Tuple[decimal.Decimal, decimal.Decimal]:
|
|
52
|
-
|
|
78
|
+
bounds = _signed_fixed_bounds_cache.get((num_bits, frac_places))
|
|
79
|
+
if bounds is None:
|
|
80
|
+
int_lower, int_upper = compute_signed_integer_bounds(num_bits)
|
|
81
|
+
|
|
82
|
+
with decimal_localcontext(abi_decimal_context):
|
|
83
|
+
exp = TEN**-frac_places
|
|
84
|
+
lower = Decimal(int_lower) * exp
|
|
85
|
+
upper = Decimal(int_upper) * exp
|
|
53
86
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
lower = Decimal(int_lower) * exp
|
|
57
|
-
upper = Decimal(int_upper) * exp
|
|
87
|
+
bounds = lower, upper
|
|
88
|
+
_signed_fixed_bounds_cache[(num_bits, frac_places)] = bounds
|
|
58
89
|
|
|
59
|
-
return
|
|
90
|
+
return bounds
|
|
60
91
|
|
|
61
92
|
|
|
62
93
|
def scale_places(places: int) -> Callable[[decimal.Decimal], decimal.Decimal]:
|
|
@@ -70,11 +101,11 @@ def scale_places(places: int) -> Callable[[decimal.Decimal], decimal.Decimal]:
|
|
|
70
101
|
f"of type {type(places)}.",
|
|
71
102
|
)
|
|
72
103
|
|
|
73
|
-
with
|
|
104
|
+
with decimal_localcontext(abi_decimal_context):
|
|
74
105
|
scaling_factor = TEN**-places
|
|
75
106
|
|
|
76
107
|
def f(x: decimal.Decimal) -> decimal.Decimal:
|
|
77
|
-
with
|
|
108
|
+
with decimal_localcontext(abi_decimal_context):
|
|
78
109
|
return x * scaling_factor
|
|
79
110
|
|
|
80
111
|
places_repr = f"Eneg{places}" if places > 0 else f"Epos{-places}"
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: faster_eth_abi
|
|
3
|
-
Version: 5.2.
|
|
3
|
+
Version: 5.2.10
|
|
4
4
|
Summary: A faster fork of eth_abi: Python utilities for working with Ethereum ABI definitions, especially encoding and decoding. Implemented in C.
|
|
5
5
|
Home-page: https://github.com/BobTheBuidler/faster-eth-abi
|
|
6
6
|
Author: The Ethereum Foundation
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
76f9a3652d4d2667c55c__mypyc.cp38-win_amd64.pyd,sha256=F-83ULREMZzMbkdy73gZMKT6CLlF-O-_MG4nmmlgzYI,160256
|
|
2
|
+
faster_eth_abi/__init__.py,sha256=JpTfPTiusUGMmX8sEsGAxvILxFbvhh3MEyfiKOd5o9g,217
|
|
3
|
+
faster_eth_abi/_codec.cp38-win_amd64.pyd,sha256=0207uQxGldSBH52D_nHGPgeSRyDfIWIOlDLZ7u8IJW8,10752
|
|
4
|
+
faster_eth_abi/_codec.py,sha256=fLRvqvrD8F38U4m1wZztvx-7JJbZaPikwXS5u9BzY14,2509
|
|
5
|
+
faster_eth_abi/_decoding.cp38-win_amd64.pyd,sha256=C5-Gm0uFYUd4D-wv-dJerCwMGrdub2yEIY6EXgr87IM,10752
|
|
6
|
+
faster_eth_abi/_decoding.py,sha256=06ddzblp834cZ_6SA5Q3J3_XnQTa0gmWeM4gYRxrcSk,4555
|
|
7
|
+
faster_eth_abi/_encoding.cp38-win_amd64.pyd,sha256=jVyAuIX19V2pNfolgDJRgiis_q0GbYqwjQjNJBii0YU,10752
|
|
8
|
+
faster_eth_abi/_encoding.py,sha256=rsZihtFUqYu80ANOsxP9QwpFJDH73VBVJSzOrllBm2k,3340
|
|
9
|
+
faster_eth_abi/abi.cp38-win_amd64.pyd,sha256=bNz_k7adB_DQYFwv4tNTmWvIpjfZ_yI-pfBRD_-haIM,10752
|
|
10
|
+
faster_eth_abi/abi.py,sha256=-t9OVBSCxy6SuWpCu3cxHrCqkx8_svPIRb0MSFXEl5Q,383
|
|
11
|
+
faster_eth_abi/base.py,sha256=y4IXpQJWGfUISl3xjCO420Grxido3tE2ebPV2rK-DvM,1229
|
|
12
|
+
faster_eth_abi/codec.py,sha256=e1uO8BJrXRn0Ih70eUa5qipD2wcg2aZSR4fyVuGpFoY,4580
|
|
13
|
+
faster_eth_abi/constants.cp38-win_amd64.pyd,sha256=seJVkx5LHzakFNZK82GbRZsspytWO3Da95mFfJTiIsE,10752
|
|
14
|
+
faster_eth_abi/constants.py,sha256=q3FGynS-Eb78cnrL6mBoAvTDz16PF3tW2OylTMd6ajs,114
|
|
15
|
+
faster_eth_abi/decoding.py,sha256=7zOcSLdiQhAJWnCOSAdFg2AtSMoj8ZdN2IYE_aZKHQU,17028
|
|
16
|
+
faster_eth_abi/encoding.py,sha256=P1svhYylcZa55cQ9LPj6jV8iJVLSL_c5SIZT1Umol58,19679
|
|
17
|
+
faster_eth_abi/exceptions.py,sha256=KzNYRc9t0CvlkveozWvLeo1WC_GarcBkwzV67aY_5yI,3067
|
|
18
|
+
faster_eth_abi/from_type_str.cp38-win_amd64.pyd,sha256=XDtAloq5gnr-5fOdGNLEzZAqt1Wm2AQ8ciDL4XmjWXU,10752
|
|
19
|
+
faster_eth_abi/from_type_str.py,sha256=WLRP3OIyrJORgloX-7V0x2KdrZj0kLay-J9I8f-H36s,4446
|
|
20
|
+
faster_eth_abi/grammar.py,sha256=lhEmp3ZwMTzm1-jJiMUVD4zrBgU4MEZCRiND4WxfOes,13839
|
|
21
|
+
faster_eth_abi/io.py,sha256=E_QX7aYAjGYnkNAZmJMmSmx1lqvl_FDNmMFruTi9UX4,3831
|
|
22
|
+
faster_eth_abi/packed.cp38-win_amd64.pyd,sha256=C6ABre-v9RxpRPh2wepdlz1tmuksWYZxoqIQTO0j3ac,10752
|
|
23
|
+
faster_eth_abi/packed.py,sha256=RZ2chvsx9_AL9OxY1ixHTsaUJHaR_tmrNdViOIp-xSg,316
|
|
24
|
+
faster_eth_abi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
|
+
faster_eth_abi/registry.py,sha256=gU5-k_1eYUjs7-NAKoH9nncCJ36tZZHM5ZXvwmXt0cw,21192
|
|
26
|
+
faster_eth_abi/tools/__init__.cp38-win_amd64.pyd,sha256=o_0PCh29DpITT8jQphshcFdjpQpQWQSYZEDuDxsY4ew,10752
|
|
27
|
+
faster_eth_abi/tools/__init__.py,sha256=jxyQnb34ldRjCTYi3Ajb5h5QlFQ6ODfKQNhOCVwR7Ao,54
|
|
28
|
+
faster_eth_abi/tools/_strategies.cp38-win_amd64.pyd,sha256=j_jjvGUL3nzVNwtlAMODirwzWGKB2R0_BKYmTgptZ4U,10752
|
|
29
|
+
faster_eth_abi/tools/_strategies.py,sha256=HCFdQFLa84SMf7Deui2-szTH34hxTfc0Rog_kmpTg_w,6197
|
|
30
|
+
faster_eth_abi/utils/__init__.cp38-win_amd64.pyd,sha256=MrzjHLAQm4I-O_ww0y9FElIzjmjyVxQecp_pIrpWxwQ,10752
|
|
31
|
+
faster_eth_abi/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
|
+
faster_eth_abi/utils/numeric.cp38-win_amd64.pyd,sha256=B0tV5JFiCpe_2H1XnpshRMbb0VwuwJVhyofcjG2BGMg,10752
|
|
33
|
+
faster_eth_abi/utils/numeric.py,sha256=saAVL12dfDrMXZeao3u2jar-U2y57YKVUqF6VOzoLxs,3395
|
|
34
|
+
faster_eth_abi/utils/padding.cp38-win_amd64.pyd,sha256=hQCeWLR1zTD0DcKzBZ54IlE9e9aSWFV-NJIdw49Clk8,10752
|
|
35
|
+
faster_eth_abi/utils/padding.py,sha256=k6dkOiQ3k0OhQUZ6blCiL1VOQVYGyynucafbySjcFfY,515
|
|
36
|
+
faster_eth_abi/utils/string.cp38-win_amd64.pyd,sha256=K3GxztcnlV6nWs4LNXSvdjnGcholNwDJ9zCGfLw_5BM,10752
|
|
37
|
+
faster_eth_abi/utils/string.py,sha256=wYcvWof4kuitrGGSe_NOduQaxE4HHYmpraCPXKcZxMs,455
|
|
38
|
+
faster_eth_abi/utils/validation.cp38-win_amd64.pyd,sha256=c22lQhrSKhChb629IpYeVTO7ozf9_A1wgMqWPVKYEEg,10752
|
|
39
|
+
faster_eth_abi/utils/validation.py,sha256=9veO7wyQsmcFgeaGrsKdSifjV1gaXfTDDKAt1EbKHYY,539
|
|
40
|
+
faster_eth_abi-5.2.10.dist-info/LICENSE,sha256=Q1lDDWXR057JL2Y7HTAwclCF32_LCloN4sGUkXO1YeI,1127
|
|
41
|
+
faster_eth_abi-5.2.10.dist-info/METADATA,sha256=eT1bIpv_A9zYB8TtAzlTfm9Qozp9l7F9sM5nXn8MOzA,5208
|
|
42
|
+
faster_eth_abi-5.2.10.dist-info/WHEEL,sha256=2M046GvC9RLU1f1TWyM-2sB7cRKLhAC7ucAFK8l8f24,99
|
|
43
|
+
faster_eth_abi-5.2.10.dist-info/top_level.txt,sha256=CO2FQwf61aFzjYze7Wywa5KQdJ6bbLkzDoGEjDF2g9o,43
|
|
44
|
+
faster_eth_abi-5.2.10.dist-info/RECORD,,
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
76f9a3652d4d2667c55c__mypyc.cp38-win_amd64.pyd,sha256=q4OWcbGDcAvt6tEq6H4JmF2sD2wZGQQDmb8Z08zyoBo,150528
|
|
2
|
-
faster_eth_abi/__init__.py,sha256=JpTfPTiusUGMmX8sEsGAxvILxFbvhh3MEyfiKOd5o9g,217
|
|
3
|
-
faster_eth_abi/_codec.cp38-win_amd64.pyd,sha256=ov2tFCp3g4DpZMjiTNVKE4KG6D_kLHVoQCqDKd-m3fs,10752
|
|
4
|
-
faster_eth_abi/_codec.py,sha256=fLRvqvrD8F38U4m1wZztvx-7JJbZaPikwXS5u9BzY14,2509
|
|
5
|
-
faster_eth_abi/_decoding.cp38-win_amd64.pyd,sha256=e1D0PXNjPWPArQCTTGz8S4L-JNnbxtFRTMerZn7Hvd0,10752
|
|
6
|
-
faster_eth_abi/_decoding.py,sha256=uhteNEJzs873MqIOxc68XuFnKOhsUH0CJcQFLbL0Q18,3264
|
|
7
|
-
faster_eth_abi/_encoding.cp38-win_amd64.pyd,sha256=eB1NvWF884YxLwfAaFpO-peOjdwXavNR8D7sSU6N_Q0,10752
|
|
8
|
-
faster_eth_abi/_encoding.py,sha256=157A_MltVLCEwBmD7SB8UaKXkAOtIKC5MVupk6dk_yA,3217
|
|
9
|
-
faster_eth_abi/abi.cp38-win_amd64.pyd,sha256=g_ZjR_KtG0AdhsXupKMyB3cI1a7IcmHoM1yum_yvAvc,10752
|
|
10
|
-
faster_eth_abi/abi.py,sha256=-t9OVBSCxy6SuWpCu3cxHrCqkx8_svPIRb0MSFXEl5Q,383
|
|
11
|
-
faster_eth_abi/base.py,sha256=y4IXpQJWGfUISl3xjCO420Grxido3tE2ebPV2rK-DvM,1229
|
|
12
|
-
faster_eth_abi/codec.py,sha256=e1uO8BJrXRn0Ih70eUa5qipD2wcg2aZSR4fyVuGpFoY,4580
|
|
13
|
-
faster_eth_abi/constants.cp38-win_amd64.pyd,sha256=hDd5QdYIRSHnIsFYvOTs6HS5sNpCkbPcqF0wvUZs1ZA,10752
|
|
14
|
-
faster_eth_abi/constants.py,sha256=q3FGynS-Eb78cnrL6mBoAvTDz16PF3tW2OylTMd6ajs,114
|
|
15
|
-
faster_eth_abi/decoding.py,sha256=-2P8kAaHM1HFYS5b8QKstStO6PkWlugEaDUoujX1Uf0,17447
|
|
16
|
-
faster_eth_abi/encoding.py,sha256=bKw8wCqpfv8U83I2xsmiI37wn2lQUIhn4bn1xS_l1Zc,19704
|
|
17
|
-
faster_eth_abi/exceptions.py,sha256=KzNYRc9t0CvlkveozWvLeo1WC_GarcBkwzV67aY_5yI,3067
|
|
18
|
-
faster_eth_abi/from_type_str.cp38-win_amd64.pyd,sha256=arpdYW6yEWJV-thinlDbcau9zVXLE1vQbHE1N-_t9Sc,10752
|
|
19
|
-
faster_eth_abi/from_type_str.py,sha256=WLRP3OIyrJORgloX-7V0x2KdrZj0kLay-J9I8f-H36s,4446
|
|
20
|
-
faster_eth_abi/grammar.py,sha256=lhEmp3ZwMTzm1-jJiMUVD4zrBgU4MEZCRiND4WxfOes,13839
|
|
21
|
-
faster_eth_abi/io.py,sha256=E_QX7aYAjGYnkNAZmJMmSmx1lqvl_FDNmMFruTi9UX4,3831
|
|
22
|
-
faster_eth_abi/packed.cp38-win_amd64.pyd,sha256=S4BxBMQ5iKxx-EuX9NLs01BtDJ_ZTMr7t5XTshs9CYA,10752
|
|
23
|
-
faster_eth_abi/packed.py,sha256=RZ2chvsx9_AL9OxY1ixHTsaUJHaR_tmrNdViOIp-xSg,316
|
|
24
|
-
faster_eth_abi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
|
-
faster_eth_abi/registry.py,sha256=gU5-k_1eYUjs7-NAKoH9nncCJ36tZZHM5ZXvwmXt0cw,21192
|
|
26
|
-
faster_eth_abi/tools/__init__.cp38-win_amd64.pyd,sha256=y9qVkZkQBq4cHlak6AxTd8vgyZjqgzO5Gi0hdHYfMgU,10752
|
|
27
|
-
faster_eth_abi/tools/__init__.py,sha256=jxyQnb34ldRjCTYi3Ajb5h5QlFQ6ODfKQNhOCVwR7Ao,54
|
|
28
|
-
faster_eth_abi/tools/_strategies.cp38-win_amd64.pyd,sha256=hqimZqHOpkEx4y9wwzxUb1aiTq3ba6JKf77ciDr1uOg,10752
|
|
29
|
-
faster_eth_abi/tools/_strategies.py,sha256=HCFdQFLa84SMf7Deui2-szTH34hxTfc0Rog_kmpTg_w,6197
|
|
30
|
-
faster_eth_abi/utils/__init__.cp38-win_amd64.pyd,sha256=mNvFnTB_cDtCph7BYWTyqYBdZWYigaX5A0tsigibdQA,10752
|
|
31
|
-
faster_eth_abi/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
|
-
faster_eth_abi/utils/numeric.cp38-win_amd64.pyd,sha256=7tKEMfWQe04RNnhtGrVt1hPgHdNIc99PmHbTSd69ERI,10752
|
|
33
|
-
faster_eth_abi/utils/numeric.py,sha256=hNGble1NA99_5hrAOnH0ZakCuHc6PFMC1p0olmpo_vM,2232
|
|
34
|
-
faster_eth_abi/utils/padding.cp38-win_amd64.pyd,sha256=hGtYY27LEgjZRn8ILVr96XPiL_zr7ccMt10YcBJhF6A,10752
|
|
35
|
-
faster_eth_abi/utils/padding.py,sha256=k6dkOiQ3k0OhQUZ6blCiL1VOQVYGyynucafbySjcFfY,515
|
|
36
|
-
faster_eth_abi/utils/string.cp38-win_amd64.pyd,sha256=CsEnZWyDRCU_8DR6WGoVvETY5ufvEdNkvBmcLatJky8,10752
|
|
37
|
-
faster_eth_abi/utils/string.py,sha256=wYcvWof4kuitrGGSe_NOduQaxE4HHYmpraCPXKcZxMs,455
|
|
38
|
-
faster_eth_abi/utils/validation.cp38-win_amd64.pyd,sha256=uK55JUrpdE2odEoakg24S_gi_XGubIbg3BltGoiEss4,10752
|
|
39
|
-
faster_eth_abi/utils/validation.py,sha256=9veO7wyQsmcFgeaGrsKdSifjV1gaXfTDDKAt1EbKHYY,539
|
|
40
|
-
faster_eth_abi-5.2.8.dist-info/LICENSE,sha256=Q1lDDWXR057JL2Y7HTAwclCF32_LCloN4sGUkXO1YeI,1127
|
|
41
|
-
faster_eth_abi-5.2.8.dist-info/METADATA,sha256=yOnTAF2c2n9t-pBL2rjLtx82TLs9NscD8mV7UV2ZEnw,5207
|
|
42
|
-
faster_eth_abi-5.2.8.dist-info/WHEEL,sha256=2M046GvC9RLU1f1TWyM-2sB7cRKLhAC7ucAFK8l8f24,99
|
|
43
|
-
faster_eth_abi-5.2.8.dist-info/top_level.txt,sha256=CO2FQwf61aFzjYze7Wywa5KQdJ6bbLkzDoGEjDF2g9o,43
|
|
44
|
-
faster_eth_abi-5.2.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|