web3 7.12.1__py3-none-any.whl → 7.14.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 +9 -5
- ens/base_ens.py +1 -1
- ens/utils.py +2 -1
- web3/_utils/abi.py +5 -5
- web3/_utils/async_transactions.py +12 -9
- web3/_utils/batching.py +1 -1
- web3/_utils/caching/caching_utils.py +2 -2
- web3/_utils/contracts.py +5 -5
- web3/_utils/ens.py +1 -1
- web3/_utils/events.py +1 -1
- web3/_utils/module_testing/eth_module.py +133 -125
- web3/_utils/module_testing/go_ethereum_admin_module.py +7 -6
- web3/_utils/module_testing/go_ethereum_debug_module.py +5 -4
- web3/_utils/module_testing/go_ethereum_txpool_module.py +6 -3
- web3/_utils/module_testing/module_testing_utils.py +1 -1
- web3/_utils/module_testing/net_module.py +4 -3
- web3/_utils/module_testing/persistent_connection_provider.py +132 -20
- web3/_utils/module_testing/utils.py +7 -6
- web3/_utils/module_testing/web3_module.py +15 -11
- web3/_utils/normalizers.py +3 -3
- web3/_utils/transactions.py +2 -1
- web3/contract/async_contract.py +13 -13
- web3/contract/base_contract.py +11 -12
- web3/contract/utils.py +7 -7
- web3/eth/async_eth.py +3 -14
- web3/exceptions.py +8 -1
- web3/gas_strategies/time_based.py +1 -1
- web3/main.py +24 -11
- web3/manager.py +11 -13
- web3/middleware/__init__.py +1 -1
- web3/middleware/base.py +5 -5
- web3/middleware/buffered_gas_estimate.py +1 -1
- web3/middleware/filter.py +10 -9
- web3/middleware/formatting.py +11 -5
- web3/middleware/gas_price_strategy.py +1 -1
- web3/middleware/names.py +4 -4
- web3/middleware/signing.py +3 -3
- web3/middleware/stalecheck.py +2 -2
- web3/middleware/validation.py +2 -2
- web3/module.py +3 -3
- web3/providers/async_base.py +2 -2
- web3/providers/base.py +2 -2
- web3/providers/eth_tester/defaults.py +2 -2
- web3/providers/eth_tester/main.py +1 -1
- web3/providers/eth_tester/middleware.py +2 -2
- web3/providers/persistent/persistent.py +8 -7
- web3/providers/persistent/persistent_connection.py +1 -1
- web3/providers/persistent/subscription_manager.py +67 -14
- web3/providers/persistent/utils.py +1 -1
- web3/types.py +16 -3
- web3/utils/subscriptions.py +26 -4
- {web3-7.12.1.dist-info → web3-7.14.0.dist-info}/METADATA +1 -1
- {web3-7.12.1.dist-info → web3-7.14.0.dist-info}/RECORD +56 -57
- ens/specs/.DS_Store +0 -0
- {web3-7.12.1.dist-info → web3-7.14.0.dist-info}/WHEEL +0 -0
- {web3-7.12.1.dist-info → web3-7.14.0.dist-info}/licenses/LICENSE +0 -0
- {web3-7.12.1.dist-info → web3-7.14.0.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import pytest
|
|
2
2
|
from typing import (
|
|
3
3
|
TYPE_CHECKING,
|
|
4
|
+
Any,
|
|
4
5
|
List,
|
|
5
6
|
)
|
|
6
7
|
|
|
@@ -70,29 +71,29 @@ class GoEthereumAdminModuleTest:
|
|
|
70
71
|
|
|
71
72
|
class GoEthereumAsyncAdminModuleTest:
|
|
72
73
|
@pytest.mark.asyncio
|
|
73
|
-
async def test_async_datadir(self, async_w3: "AsyncWeb3") -> None:
|
|
74
|
+
async def test_async_datadir(self, async_w3: "AsyncWeb3[Any]") -> None:
|
|
74
75
|
datadir = await async_w3.geth.admin.datadir()
|
|
75
76
|
assert isinstance(datadir, str)
|
|
76
77
|
|
|
77
78
|
@pytest.mark.asyncio
|
|
78
|
-
async def test_async_node_info(self, async_w3: "AsyncWeb3") -> None:
|
|
79
|
+
async def test_async_node_info(self, async_w3: "AsyncWeb3[Any]") -> None:
|
|
79
80
|
node_info = await async_w3.geth.admin.node_info()
|
|
80
81
|
assert "Geth" in node_info["name"]
|
|
81
82
|
|
|
82
83
|
@pytest.mark.asyncio
|
|
83
|
-
async def test_async_nodes(self, async_w3: "AsyncWeb3") -> None:
|
|
84
|
+
async def test_async_nodes(self, async_w3: "AsyncWeb3[Any]") -> None:
|
|
84
85
|
nodes = await async_w3.geth.admin.peers()
|
|
85
86
|
assert isinstance(nodes, List)
|
|
86
87
|
|
|
87
88
|
@pytest.mark.asyncio
|
|
88
|
-
async def test_admin_peers(self, async_w3: "AsyncWeb3") -> None:
|
|
89
|
+
async def test_admin_peers(self, async_w3: "AsyncWeb3[Any]") -> None:
|
|
89
90
|
node_info = await async_w3.geth.admin.node_info()
|
|
90
91
|
await async_w3.geth.admin.add_peer(node_info["enode"])
|
|
91
92
|
result = await async_w3.geth.admin.peers()
|
|
92
93
|
assert len(result) == 1
|
|
93
94
|
|
|
94
95
|
@pytest.mark.asyncio
|
|
95
|
-
async def test_admin_start_stop_http(self, async_w3: "AsyncWeb3") -> None:
|
|
96
|
+
async def test_admin_start_stop_http(self, async_w3: "AsyncWeb3[Any]") -> None:
|
|
96
97
|
stop = await async_w3.geth.admin.stop_http()
|
|
97
98
|
assert stop is True
|
|
98
99
|
|
|
@@ -100,7 +101,7 @@ class GoEthereumAsyncAdminModuleTest:
|
|
|
100
101
|
assert start is True
|
|
101
102
|
|
|
102
103
|
@pytest.mark.asyncio
|
|
103
|
-
async def test_admin_start_stop_ws(self, async_w3: "AsyncWeb3") -> None:
|
|
104
|
+
async def test_admin_start_stop_ws(self, async_w3: "AsyncWeb3[Any]") -> None:
|
|
104
105
|
stop = await async_w3.geth.admin.stop_ws()
|
|
105
106
|
assert stop is True
|
|
106
107
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import pytest
|
|
2
2
|
from typing import (
|
|
3
|
+
Any,
|
|
3
4
|
cast,
|
|
4
5
|
)
|
|
5
6
|
|
|
@@ -24,7 +25,7 @@ from web3.types import (
|
|
|
24
25
|
class GoEthereumAsyncDebugModuleTest:
|
|
25
26
|
@pytest.mark.asyncio
|
|
26
27
|
async def test_async_geth_debug_trace_transaction_opcode_logger(
|
|
27
|
-
self, async_w3: "AsyncWeb3", txn_hash_with_log: HexStr
|
|
28
|
+
self, async_w3: "AsyncWeb3[Any]", txn_hash_with_log: HexStr
|
|
28
29
|
) -> None:
|
|
29
30
|
result = await async_w3.geth.debug.trace_transaction(txn_hash_with_log)
|
|
30
31
|
assert "structLogs" in dict(result).keys()
|
|
@@ -33,7 +34,7 @@ class GoEthereumAsyncDebugModuleTest:
|
|
|
33
34
|
|
|
34
35
|
@pytest.mark.asyncio
|
|
35
36
|
async def test_async_geth_debug_trace_transaction_call_tracer(
|
|
36
|
-
self, async_w3: "AsyncWeb3", txn_hash_with_log: HexStr
|
|
37
|
+
self, async_w3: "AsyncWeb3[Any]", txn_hash_with_log: HexStr
|
|
37
38
|
) -> None:
|
|
38
39
|
result = cast(
|
|
39
40
|
CallTrace,
|
|
@@ -45,7 +46,7 @@ class GoEthereumAsyncDebugModuleTest:
|
|
|
45
46
|
|
|
46
47
|
@pytest.mark.asyncio
|
|
47
48
|
async def test_async_geth_debug_trace_transaction_prestate_tracer_diffMode(
|
|
48
|
-
self, async_w3: "AsyncWeb3", txn_hash_with_log: HexStr
|
|
49
|
+
self, async_w3: "AsyncWeb3[Any]", txn_hash_with_log: HexStr
|
|
49
50
|
) -> None:
|
|
50
51
|
result = cast(
|
|
51
52
|
DiffModeTrace,
|
|
@@ -60,7 +61,7 @@ class GoEthereumAsyncDebugModuleTest:
|
|
|
60
61
|
@pytest.mark.asyncio
|
|
61
62
|
async def test_async_geth_debug_trace_transaction_prestate_tracer(
|
|
62
63
|
self,
|
|
63
|
-
async_w3: "AsyncWeb3",
|
|
64
|
+
async_w3: "AsyncWeb3[Any]",
|
|
64
65
|
txn_hash_with_log: HexStr,
|
|
65
66
|
async_block_with_txn_with_log: BlockData,
|
|
66
67
|
) -> None:
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import pytest
|
|
2
|
+
from typing import (
|
|
3
|
+
Any,
|
|
4
|
+
)
|
|
2
5
|
|
|
3
6
|
from web3 import (
|
|
4
7
|
AsyncWeb3,
|
|
@@ -8,17 +11,17 @@ from web3 import (
|
|
|
8
11
|
|
|
9
12
|
class GoEthereumAsyncTxPoolModuleTest:
|
|
10
13
|
@pytest.mark.asyncio
|
|
11
|
-
async def test_async_geth_txpool_inspect(self, async_w3: "AsyncWeb3") -> None:
|
|
14
|
+
async def test_async_geth_txpool_inspect(self, async_w3: "AsyncWeb3[Any]") -> None:
|
|
12
15
|
test_data = await async_w3.geth.txpool.inspect()
|
|
13
16
|
assert "pending" in test_data
|
|
14
17
|
|
|
15
18
|
@pytest.mark.asyncio
|
|
16
|
-
async def test_async_geth_txpool_content(self, async_w3: "AsyncWeb3") -> None:
|
|
19
|
+
async def test_async_geth_txpool_content(self, async_w3: "AsyncWeb3[Any]") -> None:
|
|
17
20
|
test_data = await async_w3.geth.txpool.content()
|
|
18
21
|
assert "pending" in test_data
|
|
19
22
|
|
|
20
23
|
@pytest.mark.asyncio
|
|
21
|
-
async def test_async_geth_txpool_status(self, async_w3: "AsyncWeb3") -> None:
|
|
24
|
+
async def test_async_geth_txpool_status(self, async_w3: "AsyncWeb3[Any]") -> None:
|
|
22
25
|
test_data = await async_w3.geth.txpool.status()
|
|
23
26
|
assert "pending" in test_data
|
|
24
27
|
|
|
@@ -132,7 +132,7 @@ def async_mock_offchain_lookup_request_response(
|
|
|
132
132
|
|
|
133
133
|
@staticmethod
|
|
134
134
|
def raise_for_status() -> None:
|
|
135
|
-
raise Exception("called raise_for_status()") # noqa:
|
|
135
|
+
raise Exception("called raise_for_status()") # noqa: E704
|
|
136
136
|
|
|
137
137
|
async def _mock_specific_request(
|
|
138
138
|
*args: Any, **kwargs: Any
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import pytest
|
|
2
2
|
from typing import (
|
|
3
3
|
TYPE_CHECKING,
|
|
4
|
+
Any,
|
|
4
5
|
)
|
|
5
6
|
|
|
6
7
|
from eth_utils import (
|
|
@@ -36,20 +37,20 @@ class NetModuleTest:
|
|
|
36
37
|
|
|
37
38
|
class AsyncNetModuleTest:
|
|
38
39
|
@pytest.mark.asyncio
|
|
39
|
-
async def test_net_version(self, async_w3: "AsyncWeb3") -> None:
|
|
40
|
+
async def test_net_version(self, async_w3: "AsyncWeb3[Any]") -> None:
|
|
40
41
|
version = await async_w3.net.version
|
|
41
42
|
|
|
42
43
|
assert is_string(version)
|
|
43
44
|
assert version.isdigit()
|
|
44
45
|
|
|
45
46
|
@pytest.mark.asyncio
|
|
46
|
-
async def test_net_listening(self, async_w3: "AsyncWeb3") -> None:
|
|
47
|
+
async def test_net_listening(self, async_w3: "AsyncWeb3[Any]") -> None:
|
|
47
48
|
listening = await async_w3.net.listening
|
|
48
49
|
|
|
49
50
|
assert is_boolean(listening)
|
|
50
51
|
|
|
51
52
|
@pytest.mark.asyncio
|
|
52
|
-
async def test_net_peer_count(self, async_w3: "AsyncWeb3") -> None:
|
|
53
|
+
async def test_net_peer_count(self, async_w3: "AsyncWeb3[Any]") -> None:
|
|
53
54
|
peer_count = await async_w3.net.peer_count
|
|
54
55
|
|
|
55
56
|
assert is_integer(peer_count)
|
|
@@ -9,6 +9,7 @@ from typing import (
|
|
|
9
9
|
Dict,
|
|
10
10
|
Generator,
|
|
11
11
|
List,
|
|
12
|
+
Sequence,
|
|
12
13
|
Tuple,
|
|
13
14
|
Union,
|
|
14
15
|
cast,
|
|
@@ -44,6 +45,7 @@ from web3.types import (
|
|
|
44
45
|
LogReceipt,
|
|
45
46
|
Nonce,
|
|
46
47
|
RPCEndpoint,
|
|
48
|
+
TopicFilter,
|
|
47
49
|
TxData,
|
|
48
50
|
Wei,
|
|
49
51
|
)
|
|
@@ -171,7 +173,7 @@ async def idle_handler(
|
|
|
171
173
|
|
|
172
174
|
|
|
173
175
|
async def emit_contract_event(
|
|
174
|
-
async_w3: AsyncWeb3,
|
|
176
|
+
async_w3: "AsyncWeb3[Any]",
|
|
175
177
|
acct: ChecksumAddress,
|
|
176
178
|
contract_function: "AsyncContractFunction",
|
|
177
179
|
args: Any = (),
|
|
@@ -184,7 +186,7 @@ async def emit_contract_event(
|
|
|
184
186
|
|
|
185
187
|
|
|
186
188
|
async def log_indexed_and_non_indexed_args_task(
|
|
187
|
-
async_w3: AsyncWeb3,
|
|
189
|
+
async_w3: "AsyncWeb3[Any]",
|
|
188
190
|
async_emitter_contract: "AsyncContract",
|
|
189
191
|
acct: ChecksumAddress,
|
|
190
192
|
delay: float = 0.1,
|
|
@@ -224,14 +226,14 @@ async def clean_up_task(task: "asyncio.Task[Any]") -> None:
|
|
|
224
226
|
|
|
225
227
|
class PersistentConnectionProviderTest:
|
|
226
228
|
@pytest.fixture(autouse=True)
|
|
227
|
-
def clear_caches(self, async_w3: AsyncWeb3) -> Generator[None, None, None]:
|
|
229
|
+
def clear_caches(self, async_w3: "AsyncWeb3[Any]") -> Generator[None, None, None]:
|
|
228
230
|
yield
|
|
229
231
|
async_w3.provider._request_processor.clear_caches()
|
|
230
232
|
async_w3.subscription_manager.total_handler_calls = 0
|
|
231
233
|
|
|
232
234
|
@staticmethod
|
|
233
235
|
async def seed_transactions_to_geth(
|
|
234
|
-
async_w3: AsyncWeb3,
|
|
236
|
+
async_w3: "AsyncWeb3[Any]",
|
|
235
237
|
acct: ChecksumAddress,
|
|
236
238
|
num_txs: int = 1,
|
|
237
239
|
delay: float = 0.1,
|
|
@@ -303,7 +305,7 @@ class PersistentConnectionProviderTest:
|
|
|
303
305
|
)
|
|
304
306
|
async def test_async_eth_subscribe_syncing_mocked(
|
|
305
307
|
self,
|
|
306
|
-
async_w3: AsyncWeb3,
|
|
308
|
+
async_w3: "AsyncWeb3[Any]",
|
|
307
309
|
subscription_params: Tuple[Any, ...],
|
|
308
310
|
ws_subscription_response: Dict[str, Any],
|
|
309
311
|
expected_formatted_result: Any,
|
|
@@ -334,7 +336,9 @@ class PersistentConnectionProviderTest:
|
|
|
334
336
|
)
|
|
335
337
|
|
|
336
338
|
@pytest.mark.asyncio
|
|
337
|
-
async def test_async_eth_subscribe_new_heads(
|
|
339
|
+
async def test_async_eth_subscribe_new_heads(
|
|
340
|
+
self, async_w3: "AsyncWeb3[Any]"
|
|
341
|
+
) -> None:
|
|
338
342
|
sub_id = await async_w3.eth.subscribe("newHeads")
|
|
339
343
|
assert is_hexstr(sub_id)
|
|
340
344
|
|
|
@@ -353,7 +357,7 @@ class PersistentConnectionProviderTest:
|
|
|
353
357
|
@pytest.mark.asyncio
|
|
354
358
|
async def test_async_eth_subscribe_creates_and_handles_new_heads_subscription_type(
|
|
355
359
|
self,
|
|
356
|
-
async_w3: AsyncWeb3,
|
|
360
|
+
async_w3: "AsyncWeb3[Any]",
|
|
357
361
|
) -> None:
|
|
358
362
|
sub_manager = async_w3.subscription_manager
|
|
359
363
|
new_heads_handler_test = SubscriptionHandlerTest()
|
|
@@ -380,7 +384,7 @@ class PersistentConnectionProviderTest:
|
|
|
380
384
|
@pytest.mark.asyncio
|
|
381
385
|
async def test_async_eth_subscribe_process_pending_tx_true(
|
|
382
386
|
self,
|
|
383
|
-
async_w3: AsyncWeb3,
|
|
387
|
+
async_w3: "AsyncWeb3[Any]",
|
|
384
388
|
) -> None:
|
|
385
389
|
sub_id = await async_w3.eth.subscribe("newPendingTransactions", True)
|
|
386
390
|
assert is_hexstr(sub_id)
|
|
@@ -423,7 +427,7 @@ class PersistentConnectionProviderTest:
|
|
|
423
427
|
@pytest.mark.asyncio
|
|
424
428
|
async def test_async_eth_subscribe_and_process_pending_tx_false(
|
|
425
429
|
self,
|
|
426
|
-
async_w3: AsyncWeb3,
|
|
430
|
+
async_w3: "AsyncWeb3[Any]",
|
|
427
431
|
) -> None:
|
|
428
432
|
sub_id = await async_w3.eth.subscribe("newPendingTransactions")
|
|
429
433
|
assert is_hexstr(sub_id)
|
|
@@ -460,7 +464,7 @@ class PersistentConnectionProviderTest:
|
|
|
460
464
|
@pytest.mark.asyncio
|
|
461
465
|
async def test_async_eth_subscribe_creates_and_handles_pending_tx_subscription_type(
|
|
462
466
|
self,
|
|
463
|
-
async_w3: AsyncWeb3,
|
|
467
|
+
async_w3: "AsyncWeb3[Any]",
|
|
464
468
|
) -> None:
|
|
465
469
|
sub_manager = async_w3.subscription_manager
|
|
466
470
|
pending_tx_handler_test = SubscriptionHandlerTest()
|
|
@@ -497,7 +501,7 @@ class PersistentConnectionProviderTest:
|
|
|
497
501
|
|
|
498
502
|
@pytest.mark.asyncio
|
|
499
503
|
async def test_async_eth_subscribe_and_process_logs(
|
|
500
|
-
self, async_w3: AsyncWeb3, async_emitter_contract: "AsyncContract"
|
|
504
|
+
self, async_w3: "AsyncWeb3[Any]", async_emitter_contract: "AsyncContract"
|
|
501
505
|
) -> None:
|
|
502
506
|
event = async_emitter_contract.events.LogIndexedAndNotIndexed
|
|
503
507
|
event_topic = async_w3.keccak(text=event.abi_element_identifier).to_0x_hex()
|
|
@@ -536,7 +540,7 @@ class PersistentConnectionProviderTest:
|
|
|
536
540
|
@pytest.mark.asyncio
|
|
537
541
|
async def test_async_eth_subscribe_creates_and_handles_logs_subscription_type(
|
|
538
542
|
self,
|
|
539
|
-
async_w3: AsyncWeb3,
|
|
543
|
+
async_w3: "AsyncWeb3[Any]",
|
|
540
544
|
async_emitter_contract: "AsyncContract",
|
|
541
545
|
) -> None:
|
|
542
546
|
sub_manager = async_w3.subscription_manager
|
|
@@ -580,10 +584,116 @@ class PersistentConnectionProviderTest:
|
|
|
580
584
|
sub_manager.total_handler_calls = 0
|
|
581
585
|
await clean_up_task(emit_event_task)
|
|
582
586
|
|
|
587
|
+
@pytest.mark.asyncio
|
|
588
|
+
@pytest.mark.parametrize(
|
|
589
|
+
"topics",
|
|
590
|
+
[
|
|
591
|
+
pytest.param(
|
|
592
|
+
[
|
|
593
|
+
HexStr(
|
|
594
|
+
"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" # noqa: E501
|
|
595
|
+
)
|
|
596
|
+
],
|
|
597
|
+
id="Single specific topic at position 0",
|
|
598
|
+
),
|
|
599
|
+
pytest.param(
|
|
600
|
+
[
|
|
601
|
+
None,
|
|
602
|
+
HexStr(
|
|
603
|
+
"0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" # noqa: E501
|
|
604
|
+
),
|
|
605
|
+
],
|
|
606
|
+
id="Wildcard at position 0, specific topic at position 1",
|
|
607
|
+
),
|
|
608
|
+
pytest.param(
|
|
609
|
+
[
|
|
610
|
+
[
|
|
611
|
+
HexStr(
|
|
612
|
+
"0x1111111111111111111111111111111111111111111111111111111111111111" # noqa: E501
|
|
613
|
+
),
|
|
614
|
+
HexStr(
|
|
615
|
+
"0x2222222222222222222222222222222222222222222222222222222222222222" # noqa: E501
|
|
616
|
+
),
|
|
617
|
+
]
|
|
618
|
+
],
|
|
619
|
+
id="OR pattern: topic A or B at position 0",
|
|
620
|
+
),
|
|
621
|
+
pytest.param(
|
|
622
|
+
[
|
|
623
|
+
[
|
|
624
|
+
HexStr(
|
|
625
|
+
"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" # noqa: E501
|
|
626
|
+
),
|
|
627
|
+
HexStr(
|
|
628
|
+
"0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" # noqa: E501
|
|
629
|
+
),
|
|
630
|
+
],
|
|
631
|
+
HexStr(
|
|
632
|
+
"0xcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" # noqa: E501
|
|
633
|
+
),
|
|
634
|
+
],
|
|
635
|
+
id="Complex: (A or B) at position 0 AND C at position 1",
|
|
636
|
+
),
|
|
637
|
+
pytest.param(
|
|
638
|
+
[
|
|
639
|
+
HexBytes(
|
|
640
|
+
"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" # noqa: E501
|
|
641
|
+
)
|
|
642
|
+
],
|
|
643
|
+
id="Single specific topic at position 0 with HexBytes",
|
|
644
|
+
),
|
|
645
|
+
pytest.param(
|
|
646
|
+
[
|
|
647
|
+
[
|
|
648
|
+
HexBytes(
|
|
649
|
+
"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" # noqa: E501
|
|
650
|
+
),
|
|
651
|
+
HexStr(
|
|
652
|
+
"0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" # noqa: E501
|
|
653
|
+
),
|
|
654
|
+
b"\xcc" * 32,
|
|
655
|
+
]
|
|
656
|
+
],
|
|
657
|
+
id="OR pattern with mixed HexBytes, HexStr, and bytes at position 0",
|
|
658
|
+
),
|
|
659
|
+
],
|
|
660
|
+
)
|
|
661
|
+
async def test_async_logs_subscription_with_and_or_topic_patterns(
|
|
662
|
+
self,
|
|
663
|
+
async_w3: "AsyncWeb3[Any]",
|
|
664
|
+
async_emitter_contract: "AsyncContract",
|
|
665
|
+
topics: Sequence[TopicFilter],
|
|
666
|
+
) -> None:
|
|
667
|
+
"""Test that LogsSubscription properly handles AND/OR topic patterns."""
|
|
668
|
+
sub_manager = async_w3.subscription_manager
|
|
669
|
+
|
|
670
|
+
subscription = LogsSubscription(
|
|
671
|
+
address=async_emitter_contract.address,
|
|
672
|
+
topics=topics,
|
|
673
|
+
handler=idle_handler,
|
|
674
|
+
)
|
|
675
|
+
|
|
676
|
+
await sub_manager.subscribe(subscription)
|
|
677
|
+
assert len(sub_manager.subscriptions) == 1
|
|
678
|
+
assert isinstance(sub_manager.subscriptions[0], LogsSubscription)
|
|
679
|
+
assert sub_manager.subscriptions[0].topics == topics
|
|
680
|
+
|
|
681
|
+
assert subscription.subscription_params == (
|
|
682
|
+
"logs",
|
|
683
|
+
{
|
|
684
|
+
"address": async_emitter_contract.address,
|
|
685
|
+
"topics": topics,
|
|
686
|
+
},
|
|
687
|
+
)
|
|
688
|
+
|
|
689
|
+
# clean up
|
|
690
|
+
await sub_manager.unsubscribe(subscription)
|
|
691
|
+
assert len(sub_manager.subscriptions) == 0
|
|
692
|
+
|
|
583
693
|
@pytest.mark.asyncio
|
|
584
694
|
async def test_async_extradata_poa_middleware_on_eth_subscription(
|
|
585
695
|
self,
|
|
586
|
-
async_w3: AsyncWeb3,
|
|
696
|
+
async_w3: "AsyncWeb3[Any]",
|
|
587
697
|
) -> None:
|
|
588
698
|
async_w3.middleware_onion.inject(
|
|
589
699
|
ExtraDataToPOAMiddleware, "poa_middleware", layer=0
|
|
@@ -626,7 +736,7 @@ class PersistentConnectionProviderTest:
|
|
|
626
736
|
@pytest.mark.asyncio
|
|
627
737
|
async def test_asyncio_gather_for_multiple_requests_matches_the_responses(
|
|
628
738
|
self,
|
|
629
|
-
async_w3: AsyncWeb3,
|
|
739
|
+
async_w3: "AsyncWeb3[Any]",
|
|
630
740
|
) -> None:
|
|
631
741
|
(
|
|
632
742
|
latest,
|
|
@@ -662,7 +772,7 @@ class PersistentConnectionProviderTest:
|
|
|
662
772
|
assert chain_id == chain_id2 == chain_id3 == 131277322940537
|
|
663
773
|
|
|
664
774
|
@pytest.mark.asyncio
|
|
665
|
-
async def test_async_public_socket_api(self, async_w3: AsyncWeb3) -> None:
|
|
775
|
+
async def test_async_public_socket_api(self, async_w3: "AsyncWeb3[Any]") -> None:
|
|
666
776
|
# clear all caches and queues
|
|
667
777
|
async_w3.provider._request_processor.clear_caches()
|
|
668
778
|
|
|
@@ -691,7 +801,7 @@ class PersistentConnectionProviderTest:
|
|
|
691
801
|
|
|
692
802
|
@pytest.mark.asyncio
|
|
693
803
|
async def test_async_subscription_manager_subscribes_to_many_subscriptions(
|
|
694
|
-
self, async_w3: AsyncWeb3, async_emitter_contract: "AsyncContract"
|
|
804
|
+
self, async_w3: "AsyncWeb3[Any]", async_emitter_contract: "AsyncContract"
|
|
695
805
|
) -> None:
|
|
696
806
|
sub_manager = async_w3.subscription_manager
|
|
697
807
|
|
|
@@ -754,7 +864,9 @@ class PersistentConnectionProviderTest:
|
|
|
754
864
|
await clean_up_task(emit_event_task)
|
|
755
865
|
|
|
756
866
|
@pytest.mark.asyncio
|
|
757
|
-
async def test_subscription_handler_context(
|
|
867
|
+
async def test_subscription_handler_context(
|
|
868
|
+
self, async_w3: "AsyncWeb3[Any]"
|
|
869
|
+
) -> None:
|
|
758
870
|
base_url = "http://localhost:1337"
|
|
759
871
|
async_beacon = AsyncBeacon(base_url)
|
|
760
872
|
handler_test = SubscriptionHandlerTest()
|
|
@@ -802,7 +914,7 @@ class PersistentConnectionProviderTest:
|
|
|
802
914
|
|
|
803
915
|
@pytest.mark.asyncio
|
|
804
916
|
async def test_subscriptions_with_handler_and_without(
|
|
805
|
-
self, async_w3: AsyncWeb3
|
|
917
|
+
self, async_w3: "AsyncWeb3[Any]"
|
|
806
918
|
) -> None:
|
|
807
919
|
handler_test = SubscriptionHandlerTest()
|
|
808
920
|
stream_passed = False
|
|
@@ -851,7 +963,7 @@ class PersistentConnectionProviderTest:
|
|
|
851
963
|
@pytest.mark.asyncio
|
|
852
964
|
async def test_handle_subscriptions_breaks_on_unsubscribe(
|
|
853
965
|
self,
|
|
854
|
-
async_w3: AsyncWeb3,
|
|
966
|
+
async_w3: "AsyncWeb3[Any]",
|
|
855
967
|
) -> None:
|
|
856
968
|
async def unsubscribe_subs(
|
|
857
969
|
subs: List[Union[NewHeadsSubscription, LogsSubscription]],
|
|
@@ -879,7 +991,7 @@ class PersistentConnectionProviderTest:
|
|
|
879
991
|
|
|
880
992
|
@pytest.mark.asyncio
|
|
881
993
|
async def test_run_forever_starts_with_0_subs_and_runs_until_task_cancelled(
|
|
882
|
-
self, async_w3: AsyncWeb3
|
|
994
|
+
self, async_w3: "AsyncWeb3[Any]"
|
|
883
995
|
) -> None:
|
|
884
996
|
sub_manager = async_w3.subscription_manager
|
|
885
997
|
assert_no_subscriptions_left(sub_manager._subscription_container)
|
|
@@ -97,7 +97,7 @@ class RequestMocker:
|
|
|
97
97
|
|
|
98
98
|
def __init__(
|
|
99
99
|
self,
|
|
100
|
-
w3: Union["AsyncWeb3", "Web3"],
|
|
100
|
+
w3: Union["AsyncWeb3[Any]", "Web3"],
|
|
101
101
|
mock_results: Dict[Union["RPCEndpoint", str], Any] = None,
|
|
102
102
|
mock_errors: Dict[Union["RPCEndpoint", str], Any] = None,
|
|
103
103
|
mock_responses: Dict[Union["RPCEndpoint", str], Any] = None,
|
|
@@ -131,8 +131,9 @@ class RequestMocker:
|
|
|
131
131
|
return self
|
|
132
132
|
|
|
133
133
|
def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None:
|
|
134
|
-
#
|
|
135
|
-
|
|
134
|
+
self.w3.provider.make_request = ( # type: ignore[method-assign]
|
|
135
|
+
self._make_request
|
|
136
|
+
)
|
|
136
137
|
# reset request func cache to re-build request_func with original make_request
|
|
137
138
|
self.w3.provider._request_func_cache = (None, None)
|
|
138
139
|
|
|
@@ -204,7 +205,7 @@ class RequestMocker:
|
|
|
204
205
|
async def __aexit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None:
|
|
205
206
|
if not isinstance(self.w3.provider, PersistentConnectionProvider):
|
|
206
207
|
# mypy error: Cannot assign to a method
|
|
207
|
-
self.w3.provider.make_request = self._make_request # type: ignore[
|
|
208
|
+
self.w3.provider.make_request = self._make_request # type: ignore[method-assign] # noqa: E501
|
|
208
209
|
# reset request func cache to re-build request_func w/ original make_request
|
|
209
210
|
self.w3.provider._request_func_cache = (None, None)
|
|
210
211
|
else:
|
|
@@ -261,7 +262,7 @@ class RequestMocker:
|
|
|
261
262
|
async def _async_mock_request_handler(
|
|
262
263
|
self, method: "RPCEndpoint", params: Any
|
|
263
264
|
) -> "RPCResponse":
|
|
264
|
-
self.w3 = cast("AsyncWeb3", self.w3)
|
|
265
|
+
self.w3 = cast("AsyncWeb3[Any]", self.w3)
|
|
265
266
|
self._make_request = cast("AsyncMakeRequestFn", self._make_request)
|
|
266
267
|
if all(
|
|
267
268
|
method not in mock_dict
|
|
@@ -299,7 +300,7 @@ class RequestMocker:
|
|
|
299
300
|
async def _async_mock_recv_handler(
|
|
300
301
|
self, rpc_request: "RPCRequest"
|
|
301
302
|
) -> "RPCResponse":
|
|
302
|
-
self.w3 = cast("AsyncWeb3", self.w3)
|
|
303
|
+
self.w3 = cast("AsyncWeb3[Any]", self.w3)
|
|
303
304
|
method = rpc_request["method"]
|
|
304
305
|
request_id = rpc_request["id"]
|
|
305
306
|
if all(
|
|
@@ -565,13 +565,13 @@ class AsyncWeb3ModuleTest(Web3ModuleTest):
|
|
|
565
565
|
# an asynchronous test should have the exact same name.
|
|
566
566
|
|
|
567
567
|
@pytest.mark.asyncio
|
|
568
|
-
async def test_web3_client_version(self, async_w3: AsyncWeb3) -> None:
|
|
568
|
+
async def test_web3_client_version(self, async_w3: AsyncWeb3[Any]) -> None:
|
|
569
569
|
client_version = await async_w3.client_version
|
|
570
570
|
self._check_web3_client_version(client_version)
|
|
571
571
|
|
|
572
572
|
@pytest.mark.asyncio
|
|
573
|
-
async def test_batch_requests(
|
|
574
|
-
self, async_w3: AsyncWeb3, async_math_contract: "AsyncContract"
|
|
573
|
+
async def test_batch_requests(
|
|
574
|
+
self, async_w3: AsyncWeb3[Any], async_math_contract: "AsyncContract"
|
|
575
575
|
) -> None:
|
|
576
576
|
async with async_w3.batch_requests() as batch:
|
|
577
577
|
batch.add(async_w3.eth.get_block(6))
|
|
@@ -638,8 +638,10 @@ class AsyncWeb3ModuleTest(Web3ModuleTest):
|
|
|
638
638
|
assert last_three_responses[2]["number"] == 5
|
|
639
639
|
|
|
640
640
|
@pytest.mark.asyncio
|
|
641
|
-
async def test_batch_requests_initialized_as_object(
|
|
642
|
-
self,
|
|
641
|
+
async def test_batch_requests_initialized_as_object(
|
|
642
|
+
self,
|
|
643
|
+
async_w3: AsyncWeb3[Any],
|
|
644
|
+
async_math_contract: "AsyncContract",
|
|
643
645
|
) -> None:
|
|
644
646
|
batch = async_w3.batch_requests()
|
|
645
647
|
batch.add(async_w3.eth.get_block(1))
|
|
@@ -686,7 +688,7 @@ class AsyncWeb3ModuleTest(Web3ModuleTest):
|
|
|
686
688
|
assert cast(BlockData, b4)["number"] == 4
|
|
687
689
|
|
|
688
690
|
@pytest.mark.asyncio
|
|
689
|
-
async def test_batch_requests_clear(self, async_w3: AsyncWeb3) -> None:
|
|
691
|
+
async def test_batch_requests_clear(self, async_w3: AsyncWeb3[Any]) -> None:
|
|
690
692
|
async with async_w3.batch_requests() as batch:
|
|
691
693
|
batch.add(async_w3.eth.get_block(1))
|
|
692
694
|
batch.add(async_w3.eth.get_block(2))
|
|
@@ -715,7 +717,7 @@ class AsyncWeb3ModuleTest(Web3ModuleTest):
|
|
|
715
717
|
assert cast(BlockData, r3)["number"] == 6
|
|
716
718
|
|
|
717
719
|
@pytest.mark.asyncio
|
|
718
|
-
async def test_batch_requests_cancel(self, async_w3: AsyncWeb3) -> None:
|
|
720
|
+
async def test_batch_requests_cancel(self, async_w3: AsyncWeb3[Any]) -> None:
|
|
719
721
|
# as context manager
|
|
720
722
|
async with async_w3.batch_requests() as batch:
|
|
721
723
|
batch.add(async_w3.eth.get_block(1))
|
|
@@ -755,8 +757,10 @@ class AsyncWeb3ModuleTest(Web3ModuleTest):
|
|
|
755
757
|
assert isinstance(block_num, int)
|
|
756
758
|
|
|
757
759
|
@pytest.mark.asyncio
|
|
758
|
-
async def test_batch_requests_raises_for_common_unsupported_methods(
|
|
759
|
-
self,
|
|
760
|
+
async def test_batch_requests_raises_for_common_unsupported_methods(
|
|
761
|
+
self,
|
|
762
|
+
async_w3: AsyncWeb3[Any],
|
|
763
|
+
async_math_contract: "AsyncContract",
|
|
760
764
|
) -> None:
|
|
761
765
|
async with async_w3.batch_requests() as batch:
|
|
762
766
|
with pytest.raises(MethodNotSupported, match="eth_sendTransaction"):
|
|
@@ -779,8 +783,8 @@ class AsyncWeb3ModuleTest(Web3ModuleTest):
|
|
|
779
783
|
await batch.async_execute()
|
|
780
784
|
|
|
781
785
|
@pytest.mark.asyncio
|
|
782
|
-
async def test_batch_requests_concurrently_with_regular_requests(
|
|
783
|
-
self, async_w3: AsyncWeb3
|
|
786
|
+
async def test_batch_requests_concurrently_with_regular_requests(
|
|
787
|
+
self, async_w3: AsyncWeb3[Any]
|
|
784
788
|
) -> None:
|
|
785
789
|
responses = []
|
|
786
790
|
batch_response = []
|
web3/_utils/normalizers.py
CHANGED
|
@@ -72,7 +72,7 @@ if TYPE_CHECKING:
|
|
|
72
72
|
|
|
73
73
|
|
|
74
74
|
def implicitly_identity(
|
|
75
|
-
to_wrap: Callable[[TypeStr, Any], Any]
|
|
75
|
+
to_wrap: Callable[[TypeStr, Any], Any],
|
|
76
76
|
) -> Callable[[TypeStr, Any], Tuple[TypeStr, Any]]:
|
|
77
77
|
@functools.wraps(to_wrap)
|
|
78
78
|
def wrapper(type_str: TypeStr, data: Any) -> Tuple[TypeStr, Any]:
|
|
@@ -112,7 +112,7 @@ def decode_abi_strings(type_str: TypeStr, data: Any) -> Tuple[TypeStr, str]:
|
|
|
112
112
|
|
|
113
113
|
|
|
114
114
|
def parse_basic_type_str(
|
|
115
|
-
old_normalizer: Callable[[BasicType, TypeStr, Any], Tuple[TypeStr, Any]]
|
|
115
|
+
old_normalizer: Callable[[BasicType, TypeStr, Any], Tuple[TypeStr, Any]],
|
|
116
116
|
) -> Callable[[TypeStr, Any], Tuple[TypeStr, Any]]:
|
|
117
117
|
"""
|
|
118
118
|
Modifies a normalizer to automatically parse the incoming type string. If
|
|
@@ -283,7 +283,7 @@ def normalize_bytecode(bytecode: Optional[bytes]) -> Union[HexBytes, None]:
|
|
|
283
283
|
|
|
284
284
|
|
|
285
285
|
async def async_abi_ens_resolver(
|
|
286
|
-
async_w3: "AsyncWeb3",
|
|
286
|
+
async_w3: "AsyncWeb3[Any]",
|
|
287
287
|
type_str: TypeStr,
|
|
288
288
|
val: Any,
|
|
289
289
|
) -> Tuple[TypeStr, Any]:
|
web3/_utils/transactions.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import math
|
|
2
2
|
from typing import (
|
|
3
3
|
TYPE_CHECKING,
|
|
4
|
+
Any,
|
|
4
5
|
Dict,
|
|
5
6
|
List,
|
|
6
7
|
Literal,
|
|
@@ -230,7 +231,7 @@ def assert_valid_transaction_params(transaction_params: TxParams) -> None:
|
|
|
230
231
|
|
|
231
232
|
|
|
232
233
|
def prepare_replacement_transaction(
|
|
233
|
-
w3: Union["Web3", "AsyncWeb3"],
|
|
234
|
+
w3: Union["Web3", "AsyncWeb3[Any]"],
|
|
234
235
|
original_transaction: TxData,
|
|
235
236
|
replacement_transaction: TxParams,
|
|
236
237
|
gas_multiplier: float = 1.125,
|