web3 7.0.0b4__py3-none-any.whl → 7.0.0b6__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.
- web3/_utils/batching.py +217 -0
- web3/_utils/caching.py +26 -2
- web3/_utils/compat/__init__.py +1 -0
- web3/_utils/contracts.py +5 -5
- web3/_utils/events.py +20 -20
- web3/_utils/filters.py +6 -6
- web3/_utils/method_formatters.py +0 -23
- web3/_utils/module_testing/__init__.py +0 -3
- web3/_utils/module_testing/eth_module.py +442 -373
- web3/_utils/module_testing/module_testing_utils.py +13 -0
- web3/_utils/module_testing/web3_module.py +438 -17
- web3/_utils/rpc_abi.py +0 -18
- web3/contract/async_contract.py +11 -11
- web3/contract/base_contract.py +19 -18
- web3/contract/contract.py +13 -13
- web3/contract/utils.py +112 -4
- web3/eth/async_eth.py +10 -8
- web3/eth/eth.py +7 -6
- web3/exceptions.py +75 -21
- web3/gas_strategies/time_based.py +2 -2
- web3/geth.py +0 -188
- web3/main.py +21 -13
- web3/manager.py +237 -74
- web3/method.py +29 -9
- web3/middleware/base.py +43 -0
- web3/middleware/filter.py +18 -6
- web3/middleware/signing.py +2 -2
- web3/module.py +47 -7
- web3/providers/async_base.py +55 -23
- web3/providers/base.py +59 -26
- web3/providers/eth_tester/defaults.py +0 -48
- web3/providers/eth_tester/main.py +36 -11
- web3/providers/eth_tester/middleware.py +3 -8
- web3/providers/ipc.py +23 -8
- web3/providers/legacy_websocket.py +26 -1
- web3/providers/persistent/async_ipc.py +60 -76
- web3/providers/persistent/persistent.py +134 -10
- web3/providers/persistent/request_processor.py +98 -14
- web3/providers/persistent/websocket.py +43 -66
- web3/providers/rpc/async_rpc.py +20 -2
- web3/providers/rpc/rpc.py +22 -2
- web3/providers/rpc/utils.py +1 -10
- web3/tools/benchmark/node.py +2 -8
- web3/types.py +8 -2
- {web3-7.0.0b4.dist-info → web3-7.0.0b6.dist-info}/LICENSE +1 -1
- {web3-7.0.0b4.dist-info → web3-7.0.0b6.dist-info}/METADATA +32 -21
- {web3-7.0.0b4.dist-info → web3-7.0.0b6.dist-info}/RECORD +49 -49
- web3/_utils/module_testing/go_ethereum_personal_module.py +0 -300
- {web3-7.0.0b4.dist-info → web3-7.0.0b6.dist-info}/WHEEL +0 -0
- {web3-7.0.0b4.dist-info → web3-7.0.0b6.dist-info}/top_level.txt +0 -0
web3/geth.py
CHANGED
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
from typing import (
|
|
2
|
-
Any,
|
|
3
2
|
Awaitable,
|
|
4
3
|
Callable,
|
|
5
|
-
Dict,
|
|
6
4
|
List,
|
|
7
5
|
Optional,
|
|
8
6
|
Protocol,
|
|
9
7
|
Tuple,
|
|
10
8
|
)
|
|
11
9
|
|
|
12
|
-
from eth_typing.encoding import (
|
|
13
|
-
HexStr,
|
|
14
|
-
)
|
|
15
10
|
from eth_typing.evm import (
|
|
16
11
|
ChecksumAddress,
|
|
17
12
|
)
|
|
18
|
-
from hexbytes.main import (
|
|
19
|
-
HexBytes,
|
|
20
|
-
)
|
|
21
13
|
|
|
22
14
|
from web3._utils.rpc_abi import (
|
|
23
15
|
RPC,
|
|
@@ -31,10 +23,8 @@ from web3.module import (
|
|
|
31
23
|
)
|
|
32
24
|
from web3.types import (
|
|
33
25
|
EnodeURI,
|
|
34
|
-
GethWallet,
|
|
35
26
|
NodeInfo,
|
|
36
27
|
Peer,
|
|
37
|
-
TxParams,
|
|
38
28
|
TxPoolContent,
|
|
39
29
|
TxPoolInspect,
|
|
40
30
|
TxPoolStatus,
|
|
@@ -51,66 +41,6 @@ class UnlockAccountWrapper(Protocol):
|
|
|
51
41
|
pass
|
|
52
42
|
|
|
53
43
|
|
|
54
|
-
class GethPersonal(Module):
|
|
55
|
-
"""
|
|
56
|
-
https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-personal
|
|
57
|
-
"""
|
|
58
|
-
|
|
59
|
-
is_async = False
|
|
60
|
-
|
|
61
|
-
ec_recover: Method[Callable[[str, HexStr], ChecksumAddress]] = Method(
|
|
62
|
-
RPC.personal_ecRecover,
|
|
63
|
-
mungers=[default_root_munger],
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
import_raw_key: Method[Callable[[str, str], ChecksumAddress]] = Method(
|
|
67
|
-
RPC.personal_importRawKey,
|
|
68
|
-
mungers=[default_root_munger],
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
list_accounts: Method[Callable[[], List[ChecksumAddress]]] = Method(
|
|
72
|
-
RPC.personal_listAccounts,
|
|
73
|
-
is_property=True,
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
list_wallets: Method[Callable[[], List[GethWallet]]] = Method(
|
|
77
|
-
RPC.personal_listWallets,
|
|
78
|
-
is_property=True,
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
send_transaction: Method[Callable[[TxParams, str], HexBytes]] = Method(
|
|
82
|
-
RPC.personal_sendTransaction,
|
|
83
|
-
mungers=[default_root_munger],
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
sign: Method[Callable[[str, ChecksumAddress, Optional[str]], HexStr]] = Method(
|
|
87
|
-
RPC.personal_sign,
|
|
88
|
-
mungers=[default_root_munger],
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
sign_typed_data: Method[
|
|
92
|
-
Callable[[Dict[str, Any], ChecksumAddress, str], HexStr]
|
|
93
|
-
] = Method(
|
|
94
|
-
RPC.personal_signTypedData,
|
|
95
|
-
mungers=[default_root_munger],
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
new_account: Method[Callable[[str], ChecksumAddress]] = Method(
|
|
99
|
-
RPC.personal_newAccount,
|
|
100
|
-
mungers=[default_root_munger],
|
|
101
|
-
)
|
|
102
|
-
|
|
103
|
-
lock_account: Method[Callable[[ChecksumAddress], bool]] = Method(
|
|
104
|
-
RPC.personal_lockAccount,
|
|
105
|
-
mungers=[default_root_munger],
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
unlock_account: Method[UnlockAccountWrapper] = Method(
|
|
109
|
-
RPC.personal_unlockAccount,
|
|
110
|
-
mungers=[default_root_munger],
|
|
111
|
-
)
|
|
112
|
-
|
|
113
|
-
|
|
114
44
|
class GethTxPool(Module):
|
|
115
45
|
"""
|
|
116
46
|
https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool
|
|
@@ -204,7 +134,6 @@ class GethAdmin(Module):
|
|
|
204
134
|
|
|
205
135
|
|
|
206
136
|
class Geth(Module):
|
|
207
|
-
personal: GethPersonal
|
|
208
137
|
admin: GethAdmin
|
|
209
138
|
txpool: GethTxPool
|
|
210
139
|
|
|
@@ -332,125 +261,8 @@ class AsyncGethAdmin(Module):
|
|
|
332
261
|
return await self._stop_ws()
|
|
333
262
|
|
|
334
263
|
|
|
335
|
-
class AsyncGethPersonal(Module):
|
|
336
|
-
"""
|
|
337
|
-
https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-personal
|
|
338
|
-
"""
|
|
339
|
-
|
|
340
|
-
is_async = True
|
|
341
|
-
|
|
342
|
-
# ec_recover
|
|
343
|
-
|
|
344
|
-
_ec_recover: Method[Callable[[str, HexStr], Awaitable[ChecksumAddress]]] = Method(
|
|
345
|
-
RPC.personal_ecRecover,
|
|
346
|
-
mungers=[default_root_munger],
|
|
347
|
-
)
|
|
348
|
-
|
|
349
|
-
async def ec_recover(self, message: str, signature: HexStr) -> ChecksumAddress:
|
|
350
|
-
return await self._ec_recover(message, signature)
|
|
351
|
-
|
|
352
|
-
# import_raw_key
|
|
353
|
-
|
|
354
|
-
_import_raw_key: Method[Callable[[str, str], Awaitable[ChecksumAddress]]] = Method(
|
|
355
|
-
RPC.personal_importRawKey,
|
|
356
|
-
mungers=[default_root_munger],
|
|
357
|
-
)
|
|
358
|
-
|
|
359
|
-
async def import_raw_key(
|
|
360
|
-
self, private_key: str, passphrase: str
|
|
361
|
-
) -> ChecksumAddress:
|
|
362
|
-
return await self._import_raw_key(private_key, passphrase)
|
|
363
|
-
|
|
364
|
-
# list_accounts and list_wallets
|
|
365
|
-
|
|
366
|
-
_list_accounts: Method[Callable[[], Awaitable[List[ChecksumAddress]]]] = Method(
|
|
367
|
-
RPC.personal_listAccounts,
|
|
368
|
-
is_property=True,
|
|
369
|
-
)
|
|
370
|
-
|
|
371
|
-
_list_wallets: Method[Callable[[], Awaitable[List[GethWallet]]]] = Method(
|
|
372
|
-
RPC.personal_listWallets,
|
|
373
|
-
is_property=True,
|
|
374
|
-
)
|
|
375
|
-
|
|
376
|
-
async def list_accounts(self) -> List[ChecksumAddress]:
|
|
377
|
-
return await self._list_accounts()
|
|
378
|
-
|
|
379
|
-
async def list_wallets(self) -> List[GethWallet]:
|
|
380
|
-
return await self._list_wallets()
|
|
381
|
-
|
|
382
|
-
# send_transaction
|
|
383
|
-
|
|
384
|
-
_send_transaction: Method[Callable[[TxParams, str], Awaitable[HexBytes]]] = Method(
|
|
385
|
-
RPC.personal_sendTransaction,
|
|
386
|
-
mungers=[default_root_munger],
|
|
387
|
-
)
|
|
388
|
-
|
|
389
|
-
async def send_transaction(
|
|
390
|
-
self, transaction: TxParams, passphrase: str
|
|
391
|
-
) -> HexBytes:
|
|
392
|
-
return await self._send_transaction(transaction, passphrase)
|
|
393
|
-
|
|
394
|
-
# sign and sign_typed_data
|
|
395
|
-
|
|
396
|
-
_sign: Method[
|
|
397
|
-
Callable[[str, ChecksumAddress, Optional[str]], Awaitable[HexStr]]
|
|
398
|
-
] = Method(
|
|
399
|
-
RPC.personal_sign,
|
|
400
|
-
mungers=[default_root_munger],
|
|
401
|
-
)
|
|
402
|
-
|
|
403
|
-
_sign_typed_data: Method[
|
|
404
|
-
Callable[[Dict[str, Any], ChecksumAddress, str], Awaitable[HexStr]]
|
|
405
|
-
] = Method(
|
|
406
|
-
RPC.personal_signTypedData,
|
|
407
|
-
mungers=[default_root_munger],
|
|
408
|
-
)
|
|
409
|
-
|
|
410
|
-
async def sign(
|
|
411
|
-
self, message: str, account: ChecksumAddress, passphrase: str
|
|
412
|
-
) -> HexStr:
|
|
413
|
-
return await self._sign(message, account, passphrase)
|
|
414
|
-
|
|
415
|
-
async def sign_typed_data(
|
|
416
|
-
self, message: Dict[str, Any], account: ChecksumAddress, passphrase: str
|
|
417
|
-
) -> HexStr:
|
|
418
|
-
return await self._sign_typed_data(message, account, passphrase)
|
|
419
|
-
|
|
420
|
-
# new_account, lock_account, and unlock_account
|
|
421
|
-
|
|
422
|
-
_new_account: Method[Callable[[str], Awaitable[ChecksumAddress]]] = Method(
|
|
423
|
-
RPC.personal_newAccount,
|
|
424
|
-
mungers=[default_root_munger],
|
|
425
|
-
)
|
|
426
|
-
|
|
427
|
-
_lock_account: Method[Callable[[ChecksumAddress], Awaitable[bool]]] = Method(
|
|
428
|
-
RPC.personal_lockAccount,
|
|
429
|
-
mungers=[default_root_munger],
|
|
430
|
-
)
|
|
431
|
-
|
|
432
|
-
_unlock_account: Method[
|
|
433
|
-
Callable[[ChecksumAddress, str, Optional[int]], Awaitable[bool]]
|
|
434
|
-
] = Method(
|
|
435
|
-
RPC.personal_unlockAccount,
|
|
436
|
-
mungers=[default_root_munger],
|
|
437
|
-
)
|
|
438
|
-
|
|
439
|
-
async def new_account(self, passphrase: str) -> ChecksumAddress:
|
|
440
|
-
return await self._new_account(passphrase)
|
|
441
|
-
|
|
442
|
-
async def lock_account(self, account: ChecksumAddress) -> bool:
|
|
443
|
-
return await self._lock_account(account)
|
|
444
|
-
|
|
445
|
-
async def unlock_account(
|
|
446
|
-
self, account: ChecksumAddress, passphrase: str, duration: Optional[int] = None
|
|
447
|
-
) -> bool:
|
|
448
|
-
return await self._unlock_account(account, passphrase, duration)
|
|
449
|
-
|
|
450
|
-
|
|
451
264
|
class AsyncGeth(Module):
|
|
452
265
|
is_async = True
|
|
453
266
|
|
|
454
|
-
personal: AsyncGethPersonal
|
|
455
267
|
admin: AsyncGethAdmin
|
|
456
268
|
txpool: AsyncGethTxPool
|
web3/main.py
CHANGED
|
@@ -34,6 +34,7 @@ from typing import (
|
|
|
34
34
|
TYPE_CHECKING,
|
|
35
35
|
Any,
|
|
36
36
|
AsyncIterator,
|
|
37
|
+
Callable,
|
|
37
38
|
Dict,
|
|
38
39
|
Generator,
|
|
39
40
|
List,
|
|
@@ -91,17 +92,18 @@ from web3.exceptions import (
|
|
|
91
92
|
from web3.geth import (
|
|
92
93
|
AsyncGeth,
|
|
93
94
|
AsyncGethAdmin,
|
|
94
|
-
AsyncGethPersonal,
|
|
95
95
|
AsyncGethTxPool,
|
|
96
96
|
Geth,
|
|
97
97
|
GethAdmin,
|
|
98
|
-
GethPersonal,
|
|
99
98
|
GethTxPool,
|
|
100
99
|
)
|
|
101
100
|
from web3.manager import (
|
|
102
101
|
RequestManager as DefaultRequestManager,
|
|
103
102
|
)
|
|
104
103
|
from web3.middleware.base import MiddlewareOnion
|
|
104
|
+
from web3.method import (
|
|
105
|
+
Method,
|
|
106
|
+
)
|
|
105
107
|
from web3.module import (
|
|
106
108
|
Module,
|
|
107
109
|
)
|
|
@@ -145,7 +147,9 @@ from web3.types import (
|
|
|
145
147
|
)
|
|
146
148
|
|
|
147
149
|
if TYPE_CHECKING:
|
|
150
|
+
from web3._utils.batching import RequestBatcher # noqa: F401
|
|
148
151
|
from web3._utils.empty import Empty # noqa: F401
|
|
152
|
+
from web3.providers.persistent import PersistentConnectionProvider # noqa: F401
|
|
149
153
|
|
|
150
154
|
|
|
151
155
|
def get_async_default_modules() -> Dict[str, Union[Type[Module], Sequence[Any]]]:
|
|
@@ -156,7 +160,6 @@ def get_async_default_modules() -> Dict[str, Union[Type[Module], Sequence[Any]]]
|
|
|
156
160
|
AsyncGeth,
|
|
157
161
|
{
|
|
158
162
|
"admin": AsyncGethAdmin,
|
|
159
|
-
"personal": AsyncGethPersonal,
|
|
160
163
|
"txpool": AsyncGethTxPool,
|
|
161
164
|
},
|
|
162
165
|
),
|
|
@@ -171,7 +174,6 @@ def get_default_modules() -> Dict[str, Union[Type[Module], Sequence[Any]]]:
|
|
|
171
174
|
Geth,
|
|
172
175
|
{
|
|
173
176
|
"admin": GethAdmin,
|
|
174
|
-
"personal": GethPersonal,
|
|
175
177
|
"txpool": GethTxPool,
|
|
176
178
|
},
|
|
177
179
|
),
|
|
@@ -340,6 +342,13 @@ class BaseWeb3:
|
|
|
340
342
|
def is_encodable(self, _type: TypeStr, value: Any) -> bool:
|
|
341
343
|
return self.codec.is_encodable(_type, value)
|
|
342
344
|
|
|
345
|
+
# -- APIs for high-level requests -- #
|
|
346
|
+
|
|
347
|
+
def batch_requests(
|
|
348
|
+
self,
|
|
349
|
+
) -> "RequestBatcher[Method[Callable[..., Any]]]":
|
|
350
|
+
return self.manager._batch_requests()
|
|
351
|
+
|
|
343
352
|
|
|
344
353
|
class Web3(BaseWeb3):
|
|
345
354
|
# mypy types
|
|
@@ -472,7 +481,7 @@ class AsyncWeb3(BaseWeb3):
|
|
|
472
481
|
new_ens.w3 = self # set self object reference for ``AsyncENS.w3``
|
|
473
482
|
self._ens = new_ens
|
|
474
483
|
|
|
475
|
-
|
|
484
|
+
# -- persistent connection methods -- #
|
|
476
485
|
|
|
477
486
|
@property
|
|
478
487
|
@persistent_connection_provider_method()
|
|
@@ -515,12 +524,11 @@ class AsyncWeb3(BaseWeb3):
|
|
|
515
524
|
"when instantiating via ``async for``."
|
|
516
525
|
)
|
|
517
526
|
async def __aiter__(self) -> AsyncIterator[Self]:
|
|
518
|
-
|
|
519
|
-
await self.provider.connect()
|
|
520
|
-
|
|
527
|
+
provider = self.provider
|
|
521
528
|
while True:
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
529
|
+
await provider.connect()
|
|
530
|
+
yield self
|
|
531
|
+
cast("PersistentConnectionProvider", provider).logger.error(
|
|
532
|
+
"Connection interrupted, attempting to reconnect..."
|
|
533
|
+
)
|
|
534
|
+
await provider.disconnect()
|