web3 7.0.0b8__py3-none-any.whl → 7.1.0__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/beacon/api_endpoints.py +3 -0
- web3/beacon/async_beacon.py +18 -2
- web3/beacon/beacon.py +18 -2
- web3/contract/async_contract.py +26 -25
- web3/contract/base_contract.py +116 -80
- web3/contract/contract.py +26 -25
- web3/contract/utils.py +86 -55
- web3/datastructures.py +21 -11
- 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/base.py +8 -0
- web3/middleware/filter.py +3 -3
- web3/middleware/signing.py +6 -1
- web3/scripts/install_pre_releases.py +33 -0
- web3/scripts/parse_pygeth_version.py +16 -0
- 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.1.0.dist-info}/METADATA +10 -10
- {web3-7.0.0b8.dist-info → web3-7.1.0.dist-info}/RECORD +46 -44
- {web3-7.0.0b8.dist-info → web3-7.1.0.dist-info}/WHEEL +1 -1
- /web3/_utils/{function_identifiers.py → abi_element_identifiers.py} +0 -0
- {web3-7.0.0b8.dist-info → web3-7.1.0.dist-info}/LICENSE +0 -0
- {web3-7.0.0b8.dist-info → web3-7.1.0.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/beacon/api_endpoints.py
CHANGED
|
@@ -26,6 +26,9 @@ GET_BLINDED_BLOCKS = "/eth/v1/beacon/blinded_blocks/{0}"
|
|
|
26
26
|
# rewards
|
|
27
27
|
GET_REWARDS = "/eth/v1/beacon/rewards/blocks/{0}"
|
|
28
28
|
|
|
29
|
+
# blobs
|
|
30
|
+
GET_BLOB_SIDECARS = "/eth/v1/beacon/blob_sidecars/{0}"
|
|
31
|
+
|
|
29
32
|
# light client
|
|
30
33
|
GET_LIGHT_CLIENT_BOOTSTRAP_STRUCTURE = "/eth/v1/beacon/light_client/bootstrap/{0}"
|
|
31
34
|
GET_LIGHT_CLIENT_UPDATES = "/eth/v1/beacon/light_client/updates"
|
web3/beacon/async_beacon.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
from typing import (
|
|
2
2
|
Any,
|
|
3
3
|
Dict,
|
|
4
|
+
List,
|
|
5
|
+
Optional,
|
|
4
6
|
)
|
|
5
7
|
|
|
6
8
|
from eth_typing import (
|
|
@@ -17,6 +19,7 @@ from web3.beacon.api_endpoints import (
|
|
|
17
19
|
GET_BEACON_HEADS,
|
|
18
20
|
GET_BEACON_STATE,
|
|
19
21
|
GET_BLINDED_BLOCKS,
|
|
22
|
+
GET_BLOB_SIDECARS,
|
|
20
23
|
GET_BLOCK,
|
|
21
24
|
GET_BLOCK_ATTESTATIONS,
|
|
22
25
|
GET_BLOCK_HEADER,
|
|
@@ -64,10 +67,12 @@ class AsyncBeacon:
|
|
|
64
67
|
self.request_timeout = request_timeout
|
|
65
68
|
self._request_session_manager = HTTPSessionManager()
|
|
66
69
|
|
|
67
|
-
async def _async_make_get_request(
|
|
70
|
+
async def _async_make_get_request(
|
|
71
|
+
self, endpoint_uri: str, params: Optional[Dict[str, str]] = None
|
|
72
|
+
) -> Dict[str, Any]:
|
|
68
73
|
uri = URI(self.base_url + endpoint_uri)
|
|
69
74
|
return await self._request_session_manager.async_json_make_get_request(
|
|
70
|
-
uri, timeout=self.request_timeout
|
|
75
|
+
uri, params=params, timeout=self.request_timeout
|
|
71
76
|
)
|
|
72
77
|
|
|
73
78
|
# [ BEACON endpoints ]
|
|
@@ -220,3 +225,14 @@ class AsyncBeacon:
|
|
|
220
225
|
|
|
221
226
|
async def get_syncing(self) -> Dict[str, Any]:
|
|
222
227
|
return await self._async_make_get_request(GET_SYNCING)
|
|
228
|
+
|
|
229
|
+
# [ BLOB endpoints ]
|
|
230
|
+
|
|
231
|
+
async def get_blob_sidecars(
|
|
232
|
+
self, block_id: str, indices: Optional[List[int]] = None
|
|
233
|
+
) -> Dict[str, Any]:
|
|
234
|
+
indices_param = {"indices": ",".join(map(str, indices))} if indices else None
|
|
235
|
+
return await self._async_make_get_request(
|
|
236
|
+
GET_BLOB_SIDECARS.format(block_id),
|
|
237
|
+
params=indices_param,
|
|
238
|
+
)
|
web3/beacon/beacon.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
from typing import (
|
|
2
2
|
Any,
|
|
3
3
|
Dict,
|
|
4
|
+
List,
|
|
5
|
+
Optional,
|
|
4
6
|
)
|
|
5
7
|
|
|
6
8
|
from eth_typing import (
|
|
@@ -17,6 +19,7 @@ from web3.beacon.api_endpoints import (
|
|
|
17
19
|
GET_BEACON_HEADS,
|
|
18
20
|
GET_BEACON_STATE,
|
|
19
21
|
GET_BLINDED_BLOCKS,
|
|
22
|
+
GET_BLOB_SIDECARS,
|
|
20
23
|
GET_BLOCK,
|
|
21
24
|
GET_BLOCK_ATTESTATIONS,
|
|
22
25
|
GET_BLOCK_HEADER,
|
|
@@ -62,10 +65,12 @@ class Beacon:
|
|
|
62
65
|
self.request_timeout = request_timeout
|
|
63
66
|
self._request_session_manager = HTTPSessionManager()
|
|
64
67
|
|
|
65
|
-
def _make_get_request(
|
|
68
|
+
def _make_get_request(
|
|
69
|
+
self, endpoint_url: str, params: Optional[Dict[str, str]] = None
|
|
70
|
+
) -> Dict[str, Any]:
|
|
66
71
|
uri = URI(self.base_url + endpoint_url)
|
|
67
72
|
return self._request_session_manager.json_make_get_request(
|
|
68
|
-
uri, timeout=self.request_timeout
|
|
73
|
+
uri, params=params, timeout=self.request_timeout
|
|
69
74
|
)
|
|
70
75
|
|
|
71
76
|
# [ BEACON endpoints ]
|
|
@@ -206,3 +211,14 @@ class Beacon:
|
|
|
206
211
|
|
|
207
212
|
def get_syncing(self) -> Dict[str, Any]:
|
|
208
213
|
return self._make_get_request(GET_SYNCING)
|
|
214
|
+
|
|
215
|
+
# [ BLOB endpoints ]
|
|
216
|
+
|
|
217
|
+
def get_blob_sidecars(
|
|
218
|
+
self, block_id: str, indices: Optional[List[int]] = None
|
|
219
|
+
) -> Dict[str, Any]:
|
|
220
|
+
indices_param = {"indices": ",".join(map(str, indices))} if indices else None
|
|
221
|
+
return self._make_get_request(
|
|
222
|
+
GET_BLOB_SIDECARS.format(block_id),
|
|
223
|
+
params=indices_param,
|
|
224
|
+
)
|
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,
|
|
@@ -319,8 +319,8 @@ class AsyncContractFunction(BaseContractFunction):
|
|
|
319
319
|
state_override,
|
|
320
320
|
ccip_read_enabled,
|
|
321
321
|
self.decode_tuples,
|
|
322
|
-
*self.args,
|
|
323
|
-
**self.kwargs,
|
|
322
|
+
*self.args or (),
|
|
323
|
+
**self.kwargs or {},
|
|
324
324
|
)
|
|
325
325
|
|
|
326
326
|
async def transact(self, transaction: Optional[TxParams] = None) -> HexBytes:
|
|
@@ -328,12 +328,12 @@ 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,
|
|
335
|
-
*self.args,
|
|
336
|
-
**self.kwargs,
|
|
335
|
+
*self.args or (),
|
|
336
|
+
**self.kwargs or {},
|
|
337
337
|
)
|
|
338
338
|
|
|
339
339
|
async def estimate_gas(
|
|
@@ -346,14 +346,14 @@ 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,
|
|
353
353
|
block_identifier,
|
|
354
354
|
state_override,
|
|
355
|
-
*self.args,
|
|
356
|
-
**self.kwargs,
|
|
355
|
+
*self.args or (),
|
|
356
|
+
**self.kwargs or {},
|
|
357
357
|
)
|
|
358
358
|
|
|
359
359
|
async def build_transaction(
|
|
@@ -363,12 +363,12 @@ 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,
|
|
370
|
-
*self.args,
|
|
371
|
-
**self.kwargs,
|
|
370
|
+
*self.args or (),
|
|
371
|
+
**self.kwargs or {},
|
|
372
372
|
)
|
|
373
373
|
|
|
374
374
|
@staticmethod
|
|
@@ -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
|
|