web3 7.0.0b8__py3-none-any.whl → 7.0.0b9__py3-none-any.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.
- ens/async_ens.py +16 -7
- ens/base_ens.py +3 -1
- ens/exceptions.py +2 -7
- ens/utils.py +0 -17
- web3/_utils/abi.py +100 -257
- web3/_utils/compat/__init__.py +1 -0
- web3/_utils/contracts.py +116 -205
- web3/_utils/encoding.py +4 -5
- web3/_utils/events.py +28 -33
- web3/_utils/fee_utils.py +2 -2
- web3/_utils/filters.py +2 -5
- web3/_utils/http_session_manager.py +30 -7
- web3/_utils/method_formatters.py +3 -3
- web3/_utils/module_testing/eth_module.py +59 -37
- web3/_utils/module_testing/module_testing_utils.py +43 -1
- web3/_utils/module_testing/persistent_connection_provider.py +2 -0
- web3/_utils/module_testing/web3_module.py +8 -8
- web3/_utils/normalizers.py +10 -8
- web3/_utils/validation.py +5 -7
- web3/contract/async_contract.py +18 -17
- web3/contract/base_contract.py +116 -80
- web3/contract/contract.py +16 -17
- web3/contract/utils.py +86 -55
- web3/eth/async_eth.py +1 -2
- web3/eth/eth.py +1 -2
- web3/exceptions.py +22 -9
- web3/gas_strategies/time_based.py +4 -0
- web3/manager.py +34 -12
- web3/middleware/filter.py +3 -3
- web3/middleware/signing.py +6 -1
- web3/types.py +5 -45
- web3/utils/__init__.py +48 -4
- web3/utils/abi.py +575 -10
- {web3-7.0.0b8.dist-info → web3-7.0.0b9.dist-info}/METADATA +7 -5
- {web3-7.0.0b8.dist-info → web3-7.0.0b9.dist-info}/RECORD +39 -44
- {web3-7.0.0b8.dist-info → web3-7.0.0b9.dist-info}/WHEEL +1 -1
- web3/tools/benchmark/__init__.py +0 -0
- web3/tools/benchmark/main.py +0 -190
- web3/tools/benchmark/node.py +0 -120
- web3/tools/benchmark/reporting.py +0 -39
- web3/tools/benchmark/utils.py +0 -69
- /web3/_utils/{function_identifiers.py → abi_element_identifiers.py} +0 -0
- {web3-7.0.0b8.dist-info → web3-7.0.0b9.dist-info}/LICENSE +0 -0
- {web3-7.0.0b8.dist-info → web3-7.0.0b9.dist-info}/top_level.txt +0 -0
web3/_utils/normalizers.py
CHANGED
|
@@ -19,6 +19,7 @@ from eth_abi.grammar import (
|
|
|
19
19
|
parse,
|
|
20
20
|
)
|
|
21
21
|
from eth_typing import (
|
|
22
|
+
ABI,
|
|
22
23
|
ChecksumAddress,
|
|
23
24
|
HexStr,
|
|
24
25
|
TypeStr,
|
|
@@ -62,9 +63,6 @@ from web3.exceptions import (
|
|
|
62
63
|
NameNotFound,
|
|
63
64
|
Web3ValueError,
|
|
64
65
|
)
|
|
65
|
-
from web3.types import (
|
|
66
|
-
ABI,
|
|
67
|
-
)
|
|
68
66
|
|
|
69
67
|
if TYPE_CHECKING:
|
|
70
68
|
from web3 import ( # noqa: F401
|
|
@@ -256,7 +254,9 @@ def normalize_abi(abi: Union[ABI, str]) -> ABI:
|
|
|
256
254
|
return cast(ABI, abi)
|
|
257
255
|
|
|
258
256
|
|
|
259
|
-
def normalize_address(
|
|
257
|
+
def normalize_address(
|
|
258
|
+
ens: ENS, address: Optional[ChecksumAddress]
|
|
259
|
+
) -> Union[ChecksumAddress, None]:
|
|
260
260
|
if address:
|
|
261
261
|
if is_ens_name(address):
|
|
262
262
|
validate_name_has_address(ens, address)
|
|
@@ -265,15 +265,17 @@ def normalize_address(ens: ENS, address: ChecksumAddress) -> ChecksumAddress:
|
|
|
265
265
|
return address
|
|
266
266
|
|
|
267
267
|
|
|
268
|
-
def normalize_address_no_ens(
|
|
268
|
+
def normalize_address_no_ens(
|
|
269
|
+
address: Optional[ChecksumAddress],
|
|
270
|
+
) -> Union[ChecksumAddress, None]:
|
|
269
271
|
if address:
|
|
270
272
|
validate_address(address)
|
|
271
273
|
return address
|
|
272
274
|
|
|
273
275
|
|
|
274
|
-
def normalize_bytecode(bytecode: bytes) -> HexBytes:
|
|
275
|
-
if bytecode:
|
|
276
|
-
|
|
276
|
+
def normalize_bytecode(bytecode: Optional[bytes]) -> Union[HexBytes, None]:
|
|
277
|
+
if bytecode is not None:
|
|
278
|
+
return HexBytes(bytecode)
|
|
277
279
|
return bytecode
|
|
278
280
|
|
|
279
281
|
|
web3/_utils/validation.py
CHANGED
|
@@ -5,10 +5,14 @@ from typing import (
|
|
|
5
5
|
)
|
|
6
6
|
|
|
7
7
|
from eth_typing import (
|
|
8
|
+
ABI,
|
|
9
|
+
ABIFunction,
|
|
8
10
|
HexStr,
|
|
9
11
|
TypeStr,
|
|
10
12
|
)
|
|
11
13
|
from eth_utils import (
|
|
14
|
+
abi_to_signature,
|
|
15
|
+
filter_abi_by_type,
|
|
12
16
|
function_abi_to_4byte_selector,
|
|
13
17
|
is_0x_prefixed,
|
|
14
18
|
is_binary_address,
|
|
@@ -38,8 +42,6 @@ from ens.utils import (
|
|
|
38
42
|
is_valid_ens_name,
|
|
39
43
|
)
|
|
40
44
|
from web3._utils.abi import (
|
|
41
|
-
abi_to_signature,
|
|
42
|
-
filter_by_type,
|
|
43
45
|
is_address_type,
|
|
44
46
|
is_array_type,
|
|
45
47
|
is_bool_type,
|
|
@@ -56,10 +58,6 @@ from web3.exceptions import (
|
|
|
56
58
|
Web3TypeError,
|
|
57
59
|
Web3ValueError,
|
|
58
60
|
)
|
|
59
|
-
from web3.types import (
|
|
60
|
-
ABI,
|
|
61
|
-
ABIFunction,
|
|
62
|
-
)
|
|
63
61
|
|
|
64
62
|
|
|
65
63
|
def _prepare_selector_collision_msg(duplicates: Dict[HexStr, ABIFunction]) -> str:
|
|
@@ -81,7 +79,7 @@ def validate_abi(abi: ABI) -> None:
|
|
|
81
79
|
if not all(is_dict(e) for e in abi):
|
|
82
80
|
raise Web3ValueError("'abi' is not a list of dictionaries")
|
|
83
81
|
|
|
84
|
-
functions =
|
|
82
|
+
functions = filter_abi_by_type("function", abi)
|
|
85
83
|
selectors = groupby(compose(encode_hex, function_abi_to_4byte_selector), functions)
|
|
86
84
|
duplicates = valfilter(lambda funcs: len(funcs) > 1, selectors)
|
|
87
85
|
if duplicates:
|
web3/contract/async_contract.py
CHANGED
|
@@ -14,11 +14,16 @@ from typing import (
|
|
|
14
14
|
)
|
|
15
15
|
|
|
16
16
|
from eth_typing import (
|
|
17
|
+
ABI,
|
|
17
18
|
ChecksumAddress,
|
|
18
19
|
)
|
|
19
20
|
from eth_utils import (
|
|
20
21
|
combomethod,
|
|
21
22
|
)
|
|
23
|
+
from eth_utils.abi import (
|
|
24
|
+
get_abi_input_names,
|
|
25
|
+
get_all_function_abis,
|
|
26
|
+
)
|
|
22
27
|
from eth_utils.toolz import (
|
|
23
28
|
partial,
|
|
24
29
|
)
|
|
@@ -28,9 +33,12 @@ from hexbytes import (
|
|
|
28
33
|
|
|
29
34
|
from web3._utils.abi import (
|
|
30
35
|
fallback_func_abi_exists,
|
|
31
|
-
filter_by_type,
|
|
32
36
|
receive_func_abi_exists,
|
|
33
37
|
)
|
|
38
|
+
from web3._utils.abi_element_identifiers import (
|
|
39
|
+
FallbackFn,
|
|
40
|
+
ReceiveFn,
|
|
41
|
+
)
|
|
34
42
|
from web3._utils.async_transactions import (
|
|
35
43
|
async_fill_transaction_defaults,
|
|
36
44
|
)
|
|
@@ -50,10 +58,6 @@ from web3._utils.events import (
|
|
|
50
58
|
from web3._utils.filters import (
|
|
51
59
|
AsyncLogFilter,
|
|
52
60
|
)
|
|
53
|
-
from web3._utils.function_identifiers import (
|
|
54
|
-
FallbackFn,
|
|
55
|
-
ReceiveFn,
|
|
56
|
-
)
|
|
57
61
|
from web3._utils.normalizers import (
|
|
58
62
|
normalize_abi,
|
|
59
63
|
normalize_address_no_ens,
|
|
@@ -88,15 +92,11 @@ from web3.exceptions import (
|
|
|
88
92
|
Web3ValueError,
|
|
89
93
|
)
|
|
90
94
|
from web3.types import (
|
|
91
|
-
ABI,
|
|
92
95
|
BlockIdentifier,
|
|
93
96
|
EventData,
|
|
94
97
|
StateOverride,
|
|
95
98
|
TxParams,
|
|
96
99
|
)
|
|
97
|
-
from web3.utils import (
|
|
98
|
-
get_abi_input_names,
|
|
99
|
-
)
|
|
100
100
|
|
|
101
101
|
if TYPE_CHECKING:
|
|
102
102
|
from ens import AsyncENS # noqa: F401
|
|
@@ -311,7 +311,7 @@ class AsyncContractFunction(BaseContractFunction):
|
|
|
311
311
|
self.w3,
|
|
312
312
|
self.address,
|
|
313
313
|
self._return_data_normalizers,
|
|
314
|
-
self.
|
|
314
|
+
self.abi_element_identifier,
|
|
315
315
|
call_transaction,
|
|
316
316
|
block_id,
|
|
317
317
|
self.contract_abi,
|
|
@@ -328,7 +328,7 @@ class AsyncContractFunction(BaseContractFunction):
|
|
|
328
328
|
return await async_transact_with_contract_function(
|
|
329
329
|
self.address,
|
|
330
330
|
self.w3,
|
|
331
|
-
self.
|
|
331
|
+
self.abi_element_identifier,
|
|
332
332
|
setup_transaction,
|
|
333
333
|
self.contract_abi,
|
|
334
334
|
self.abi,
|
|
@@ -346,7 +346,7 @@ class AsyncContractFunction(BaseContractFunction):
|
|
|
346
346
|
return await async_estimate_gas_for_function(
|
|
347
347
|
self.address,
|
|
348
348
|
self.w3,
|
|
349
|
-
self.
|
|
349
|
+
self.abi_element_identifier,
|
|
350
350
|
setup_transaction,
|
|
351
351
|
self.contract_abi,
|
|
352
352
|
self.abi,
|
|
@@ -363,7 +363,7 @@ class AsyncContractFunction(BaseContractFunction):
|
|
|
363
363
|
return await async_build_transaction_for_function(
|
|
364
364
|
self.address,
|
|
365
365
|
self.w3,
|
|
366
|
-
self.
|
|
366
|
+
self.abi_element_identifier,
|
|
367
367
|
built_transaction,
|
|
368
368
|
self.contract_abi,
|
|
369
369
|
self.abi,
|
|
@@ -383,7 +383,7 @@ class AsyncContractFunction(BaseContractFunction):
|
|
|
383
383
|
w3=async_w3,
|
|
384
384
|
contract_abi=abi,
|
|
385
385
|
address=address,
|
|
386
|
-
|
|
386
|
+
abi_element_identifier=FallbackFn,
|
|
387
387
|
)()
|
|
388
388
|
return cast(AsyncContractFunction, NonExistentFallbackFunction())
|
|
389
389
|
|
|
@@ -399,7 +399,7 @@ class AsyncContractFunction(BaseContractFunction):
|
|
|
399
399
|
w3=async_w3,
|
|
400
400
|
contract_abi=abi,
|
|
401
401
|
address=address,
|
|
402
|
-
|
|
402
|
+
abi_element_identifier=ReceiveFn,
|
|
403
403
|
)()
|
|
404
404
|
return cast(AsyncContractFunction, NonExistentReceiveFunction())
|
|
405
405
|
|
|
@@ -577,14 +577,15 @@ class AsyncContractCaller(BaseContractCaller):
|
|
|
577
577
|
if transaction is None:
|
|
578
578
|
transaction = {}
|
|
579
579
|
|
|
580
|
-
self._functions =
|
|
580
|
+
self._functions = get_all_function_abis(self.abi)
|
|
581
|
+
|
|
581
582
|
for func in self._functions:
|
|
582
583
|
fn = AsyncContractFunction.factory(
|
|
583
584
|
func["name"],
|
|
584
585
|
w3=w3,
|
|
585
586
|
contract_abi=self.abi,
|
|
586
587
|
address=self.address,
|
|
587
|
-
|
|
588
|
+
abi_element_identifier=func["name"],
|
|
588
589
|
decode_tuples=decode_tuples,
|
|
589
590
|
)
|
|
590
591
|
|