web3 6.17.2__py3-none-any.whl → 6.19.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.
- web3/_utils/decorators.py +22 -7
- web3/_utils/miner.py +8 -12
- web3/_utils/module_testing/go_ethereum_personal_module.py +67 -44
- web3/_utils/module_testing/module_testing_utils.py +13 -0
- web3/contract/base_contract.py +2 -2
- web3/exceptions.py +19 -1
- web3/geth.py +48 -10
- web3/main.py +5 -8
- web3/manager.py +19 -8
- web3/method.py +11 -3
- web3/providers/persistent.py +162 -3
- web3/providers/websocket/request_processor.py +40 -5
- web3/providers/websocket/websocket_v2.py +18 -114
- web3/tools/pytest_ethereum/deployer.py +1 -1
- {web3-6.17.2.dist-info → web3-6.19.0.dist-info}/METADATA +2 -2
- {web3-6.17.2.dist-info → web3-6.19.0.dist-info}/RECORD +20 -20
- {web3-6.17.2.dist-info → web3-6.19.0.dist-info}/LICENSE +0 -0
- {web3-6.17.2.dist-info → web3-6.19.0.dist-info}/WHEEL +0 -0
- {web3-6.17.2.dist-info → web3-6.19.0.dist-info}/entry_points.txt +0 -0
- {web3-6.17.2.dist-info → web3-6.19.0.dist-info}/top_level.txt +0 -0
web3/_utils/decorators.py
CHANGED
|
@@ -35,22 +35,37 @@ def reject_recursive_repeats(to_wrap: Callable[..., Any]) -> Callable[..., Any]:
|
|
|
35
35
|
return wrapped
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
def
|
|
38
|
+
def deprecate_method(
|
|
39
|
+
replacement_method: str = None, deprecation_msg: str = None
|
|
40
|
+
) -> Callable[..., Any]:
|
|
39
41
|
"""
|
|
40
|
-
Decorate a deprecated function
|
|
42
|
+
Decorate a deprecated function with info on its replacement method OR a clarifying
|
|
43
|
+
reason for the deprecation.
|
|
41
44
|
|
|
42
|
-
@
|
|
43
|
-
def
|
|
45
|
+
@deprecate_method("to_bytes()")
|
|
46
|
+
def to_ascii(arg):
|
|
47
|
+
...
|
|
48
|
+
|
|
49
|
+
@deprecate_method(deprecation_msg=(
|
|
50
|
+
"This method is no longer supported and will be removed in the next release."
|
|
51
|
+
))
|
|
52
|
+
def some_method(arg):
|
|
44
53
|
...
|
|
45
54
|
"""
|
|
55
|
+
if replacement_method is None and deprecation_msg is None:
|
|
56
|
+
raise ValueError(
|
|
57
|
+
"Must provide either `replacement_method` or `deprecation_msg`"
|
|
58
|
+
)
|
|
46
59
|
|
|
47
60
|
def decorator(to_wrap: TFunc) -> TFunc:
|
|
48
61
|
@functools.wraps(to_wrap)
|
|
49
62
|
def wrapper(*args: Any, **kwargs: Any) -> Callable[..., Any]:
|
|
50
|
-
|
|
51
|
-
f"{to_wrap.__name__} is deprecated in favor of {
|
|
52
|
-
|
|
63
|
+
msg = (
|
|
64
|
+
f"{to_wrap.__name__} is deprecated in favor of {replacement_method}"
|
|
65
|
+
if replacement_method is not None
|
|
66
|
+
else deprecation_msg
|
|
53
67
|
)
|
|
68
|
+
warnings.warn(msg, category=DeprecationWarning)
|
|
54
69
|
return to_wrap(*args, **kwargs)
|
|
55
70
|
|
|
56
71
|
return cast(TFunc, wrapper)
|
web3/_utils/miner.py
CHANGED
|
@@ -28,18 +28,14 @@ _make_dag: Method[Callable[[BlockNumber], bool]] = Method(
|
|
|
28
28
|
mungers=[default_root_munger],
|
|
29
29
|
)
|
|
30
30
|
|
|
31
|
-
make_dag = DeprecatedMethod(
|
|
32
|
-
_make_dag, "make_dag", msg="All mining methods have been deprecated"
|
|
33
|
-
)
|
|
31
|
+
make_dag = DeprecatedMethod(_make_dag, msg="All mining methods have been deprecated")
|
|
34
32
|
|
|
35
33
|
_set_extra: Method[Callable[[str], bool]] = Method(
|
|
36
34
|
RPC.miner_setExtra,
|
|
37
35
|
mungers=[default_root_munger],
|
|
38
36
|
)
|
|
39
37
|
|
|
40
|
-
set_extra = DeprecatedMethod(
|
|
41
|
-
_set_extra, "set_extra", msg="All mining methods have been deprecated"
|
|
42
|
-
)
|
|
38
|
+
set_extra = DeprecatedMethod(_set_extra, msg="All mining methods have been deprecated")
|
|
43
39
|
|
|
44
40
|
_set_etherbase: Method[Callable[[ChecksumAddress], bool]] = Method(
|
|
45
41
|
RPC.miner_setEtherbase,
|
|
@@ -47,7 +43,7 @@ _set_etherbase: Method[Callable[[ChecksumAddress], bool]] = Method(
|
|
|
47
43
|
)
|
|
48
44
|
|
|
49
45
|
set_etherbase = DeprecatedMethod(
|
|
50
|
-
_set_etherbase,
|
|
46
|
+
_set_etherbase, msg="All mining methods have been deprecated"
|
|
51
47
|
)
|
|
52
48
|
|
|
53
49
|
_set_gas_price: Method[Callable[[Wei], bool]] = Method(
|
|
@@ -56,7 +52,7 @@ _set_gas_price: Method[Callable[[Wei], bool]] = Method(
|
|
|
56
52
|
)
|
|
57
53
|
|
|
58
54
|
set_gas_price = DeprecatedMethod(
|
|
59
|
-
_set_gas_price,
|
|
55
|
+
_set_gas_price, msg="All mining methods have been deprecated"
|
|
60
56
|
)
|
|
61
57
|
|
|
62
58
|
_start: Method[Callable[[int], bool]] = Method(
|
|
@@ -64,14 +60,14 @@ _start: Method[Callable[[int], bool]] = Method(
|
|
|
64
60
|
mungers=[default_root_munger],
|
|
65
61
|
)
|
|
66
62
|
|
|
67
|
-
start = DeprecatedMethod(_start,
|
|
63
|
+
start = DeprecatedMethod(_start, msg="All mining methods have been deprecated")
|
|
68
64
|
|
|
69
65
|
_stop: Method[Callable[[], bool]] = Method(
|
|
70
66
|
RPC.miner_stop,
|
|
71
67
|
is_property=True,
|
|
72
68
|
)
|
|
73
69
|
|
|
74
|
-
stop = DeprecatedMethod(_stop,
|
|
70
|
+
stop = DeprecatedMethod(_stop, msg="All mining methods have been deprecated")
|
|
75
71
|
|
|
76
72
|
_start_auto_dag: Method[Callable[[], bool]] = Method(
|
|
77
73
|
RPC.miner_startAutoDag,
|
|
@@ -79,7 +75,7 @@ _start_auto_dag: Method[Callable[[], bool]] = Method(
|
|
|
79
75
|
)
|
|
80
76
|
|
|
81
77
|
start_auto_dag = DeprecatedMethod(
|
|
82
|
-
_start_auto_dag,
|
|
78
|
+
_start_auto_dag, msg="All mining methods have been deprecated"
|
|
83
79
|
)
|
|
84
80
|
|
|
85
81
|
_stop_auto_dag: Method[Callable[[], bool]] = Method(
|
|
@@ -88,5 +84,5 @@ _stop_auto_dag: Method[Callable[[], bool]] = Method(
|
|
|
88
84
|
)
|
|
89
85
|
|
|
90
86
|
stop_auto_dag = DeprecatedMethod(
|
|
91
|
-
_stop_auto_dag,
|
|
87
|
+
_stop_auto_dag, msg="All mining methods have been deprecated"
|
|
92
88
|
)
|
|
@@ -55,17 +55,20 @@ ACCOUNT_FOR_UNLOCK = "0x12efDc31B1a8FA1A1e756DFD8A1601055C971E13"
|
|
|
55
55
|
|
|
56
56
|
class GoEthereumPersonalModuleTest:
|
|
57
57
|
def test_personal_import_raw_key(self, w3: "Web3") -> None:
|
|
58
|
-
|
|
58
|
+
with pytest.warns(DeprecationWarning):
|
|
59
|
+
actual = w3.geth.personal.import_raw_key(PRIVATE_KEY_HEX, PASSWORD)
|
|
59
60
|
assert actual == ADDRESS
|
|
60
61
|
|
|
61
62
|
def test_personal_list_accounts(self, w3: "Web3") -> None:
|
|
62
|
-
|
|
63
|
+
with pytest.warns(DeprecationWarning):
|
|
64
|
+
accounts = w3.geth.personal.list_accounts()
|
|
63
65
|
assert is_list_like(accounts)
|
|
64
66
|
assert len(accounts) > 0
|
|
65
67
|
assert all((is_checksum_address(item) for item in accounts))
|
|
66
68
|
|
|
67
69
|
def test_personal_list_wallets(self, w3: "Web3") -> None:
|
|
68
|
-
|
|
70
|
+
with pytest.warns(DeprecationWarning):
|
|
71
|
+
wallets = w3.geth.personal.list_wallets()
|
|
69
72
|
assert is_list_like(wallets)
|
|
70
73
|
assert len(wallets) > 0
|
|
71
74
|
assert is_checksum_address(wallets[0]["accounts"][0]["address"])
|
|
@@ -76,8 +79,8 @@ class GoEthereumPersonalModuleTest:
|
|
|
76
79
|
def test_personal_lock_account(
|
|
77
80
|
self, w3: "Web3", unlockable_account_dual_type: ChecksumAddress
|
|
78
81
|
) -> None:
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
with pytest.warns(DeprecationWarning):
|
|
83
|
+
w3.geth.personal.lock_account(unlockable_account_dual_type)
|
|
81
84
|
|
|
82
85
|
def test_personal_unlock_account_success(
|
|
83
86
|
self,
|
|
@@ -85,9 +88,10 @@ class GoEthereumPersonalModuleTest:
|
|
|
85
88
|
unlockable_account_dual_type: ChecksumAddress,
|
|
86
89
|
unlockable_account_pw: str,
|
|
87
90
|
) -> None:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
+
with pytest.warns(DeprecationWarning):
|
|
92
|
+
result = w3.geth.personal.unlock_account(
|
|
93
|
+
unlockable_account_dual_type, unlockable_account_pw
|
|
94
|
+
)
|
|
91
95
|
assert result is True
|
|
92
96
|
|
|
93
97
|
def test_personal_unlock_account_failure(
|
|
@@ -99,7 +103,8 @@ class GoEthereumPersonalModuleTest:
|
|
|
99
103
|
)
|
|
100
104
|
|
|
101
105
|
def test_personal_new_account(self, w3: "Web3") -> None:
|
|
102
|
-
|
|
106
|
+
with pytest.warns(DeprecationWarning):
|
|
107
|
+
new_account = w3.geth.personal.new_account(PASSWORD)
|
|
103
108
|
assert is_checksum_address(new_account)
|
|
104
109
|
|
|
105
110
|
def test_personal_send_transaction(
|
|
@@ -118,7 +123,10 @@ class GoEthereumPersonalModuleTest:
|
|
|
118
123
|
"value": Wei(1),
|
|
119
124
|
"gasPrice": w3.to_wei(1, "gwei"),
|
|
120
125
|
}
|
|
121
|
-
|
|
126
|
+
with pytest.warns(DeprecationWarning):
|
|
127
|
+
txn_hash = w3.geth.personal.send_transaction(
|
|
128
|
+
txn_params, unlockable_account_pw
|
|
129
|
+
)
|
|
122
130
|
assert txn_hash
|
|
123
131
|
transaction = w3.eth.get_transaction(txn_hash)
|
|
124
132
|
|
|
@@ -139,10 +147,13 @@ class GoEthereumPersonalModuleTest:
|
|
|
139
147
|
unlockable_account_pw: str,
|
|
140
148
|
) -> None:
|
|
141
149
|
message = "test-web3-geth-personal-sign"
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
150
|
+
with pytest.warns(DeprecationWarning):
|
|
151
|
+
signature = w3.geth.personal.sign(
|
|
152
|
+
message, unlockable_account_dual_type, unlockable_account_pw
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
with pytest.warns(DeprecationWarning):
|
|
156
|
+
signer = w3.geth.personal.ec_recover(message, signature)
|
|
146
157
|
assert is_same_address(signer, unlockable_account_dual_type)
|
|
147
158
|
|
|
148
159
|
@pytest.mark.xfail(
|
|
@@ -193,13 +204,14 @@ class GoEthereumPersonalModuleTest:
|
|
|
193
204
|
}
|
|
194
205
|
}
|
|
195
206
|
"""
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
207
|
+
with pytest.warns(DeprecationWarning):
|
|
208
|
+
signature = HexBytes(
|
|
209
|
+
w3.geth.personal.sign_typed_data(
|
|
210
|
+
json.loads(typed_message),
|
|
211
|
+
unlockable_account_dual_type,
|
|
212
|
+
unlockable_account_pw,
|
|
213
|
+
)
|
|
201
214
|
)
|
|
202
|
-
)
|
|
203
215
|
|
|
204
216
|
expected_signature = HexBytes(
|
|
205
217
|
"0xc8b56aaeefd10ab4005c2455daf28d9082af661ac347cd"
|
|
@@ -219,33 +231,38 @@ class GoEthereumAsyncPersonalModuleTest:
|
|
|
219
231
|
unlockable_account_pw: str,
|
|
220
232
|
) -> None:
|
|
221
233
|
message = "This is a test"
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
234
|
+
with pytest.warns(DeprecationWarning):
|
|
235
|
+
signature = await async_w3.geth.personal.sign(
|
|
236
|
+
message, async_unlockable_account_dual_type, unlockable_account_pw
|
|
237
|
+
)
|
|
225
238
|
address = await async_w3.geth.personal.ec_recover(message, signature)
|
|
226
239
|
assert is_same_address(async_unlockable_account_dual_type, address)
|
|
227
240
|
|
|
228
241
|
@pytest.mark.asyncio
|
|
229
242
|
async def test_async_import_key(self, async_w3: "AsyncWeb3") -> None:
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
243
|
+
with pytest.warns(DeprecationWarning):
|
|
244
|
+
address = await async_w3.geth.personal.import_raw_key(
|
|
245
|
+
THIRD_PRIVATE_KEY_HEX, "Testing"
|
|
246
|
+
)
|
|
233
247
|
assert address is not None
|
|
234
248
|
|
|
235
249
|
@pytest.mark.asyncio
|
|
236
250
|
async def test_async_list_accounts(self, async_w3: "AsyncWeb3") -> None:
|
|
237
|
-
|
|
251
|
+
with pytest.warns(DeprecationWarning):
|
|
252
|
+
accounts = await async_w3.geth.personal.list_accounts()
|
|
238
253
|
assert len(accounts) > 0
|
|
239
254
|
|
|
240
255
|
@pytest.mark.asyncio
|
|
241
256
|
async def test_async_list_wallets(self, async_w3: "AsyncWeb3") -> None:
|
|
242
|
-
|
|
257
|
+
with pytest.warns(DeprecationWarning):
|
|
258
|
+
wallets = await async_w3.geth.personal.list_wallets()
|
|
243
259
|
assert isinstance(wallets[0], AttributeDict)
|
|
244
260
|
|
|
245
261
|
@pytest.mark.asyncio
|
|
246
262
|
async def test_async_new_account(self, async_w3: "AsyncWeb3") -> None:
|
|
247
263
|
passphrase = "Create New Account"
|
|
248
|
-
|
|
264
|
+
with pytest.warns(DeprecationWarning):
|
|
265
|
+
account = await async_w3.geth.personal.new_account(passphrase)
|
|
249
266
|
assert is_checksum_address(account)
|
|
250
267
|
|
|
251
268
|
@pytest.mark.asyncio
|
|
@@ -255,13 +272,16 @@ class GoEthereumAsyncPersonalModuleTest:
|
|
|
255
272
|
async_unlockable_account_dual_type: ChecksumAddress,
|
|
256
273
|
unlockable_account_pw: str,
|
|
257
274
|
) -> None:
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
275
|
+
with pytest.warns(DeprecationWarning):
|
|
276
|
+
unlocked = await async_w3.geth.personal.unlock_account(
|
|
277
|
+
async_unlockable_account_dual_type, unlockable_account_pw
|
|
278
|
+
)
|
|
261
279
|
assert unlocked is True
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
280
|
+
|
|
281
|
+
with pytest.warns(DeprecationWarning):
|
|
282
|
+
locked = await async_w3.geth.personal.lock_account(
|
|
283
|
+
async_unlockable_account_dual_type
|
|
284
|
+
)
|
|
265
285
|
assert locked is True
|
|
266
286
|
|
|
267
287
|
@pytest.mark.asyncio
|
|
@@ -275,9 +295,10 @@ class GoEthereumAsyncPersonalModuleTest:
|
|
|
275
295
|
tx_params["to"] = async_unlockable_account_dual_type
|
|
276
296
|
tx_params["from"] = async_unlockable_account_dual_type
|
|
277
297
|
tx_params["value"] = Wei(123)
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
298
|
+
with pytest.warns(DeprecationWarning):
|
|
299
|
+
response = await async_w3.geth.personal.send_transaction(
|
|
300
|
+
tx_params, unlockable_account_pw
|
|
301
|
+
)
|
|
281
302
|
assert response is not None
|
|
282
303
|
|
|
283
304
|
@pytest.mark.xfail(
|
|
@@ -291,10 +312,12 @@ class GoEthereumAsyncPersonalModuleTest:
|
|
|
291
312
|
unlockable_account_pw: str,
|
|
292
313
|
) -> None:
|
|
293
314
|
message = {"message": "This is a test"}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
315
|
+
with pytest.warns(DeprecationWarning):
|
|
316
|
+
signature = await async_w3.geth.personal.sign_typed_data(
|
|
317
|
+
message, async_unlockable_account_dual_type, unlockable_account_pw
|
|
318
|
+
)
|
|
319
|
+
with pytest.warns(DeprecationWarning):
|
|
320
|
+
address = await async_w3.geth.personal.ec_recover(
|
|
321
|
+
json.dumps(message), signature
|
|
322
|
+
)
|
|
300
323
|
assert is_same_address(async_unlockable_account_dual_type, address)
|
|
@@ -193,6 +193,12 @@ class WebsocketMessageStreamMock:
|
|
|
193
193
|
self.messages = deque(messages) if messages else deque()
|
|
194
194
|
self.raise_exception = raise_exception
|
|
195
195
|
|
|
196
|
+
def __await__(self) -> Generator[Any, Any, "Self"]:
|
|
197
|
+
async def __async_init__() -> "Self":
|
|
198
|
+
return self
|
|
199
|
+
|
|
200
|
+
return __async_init__().__await__()
|
|
201
|
+
|
|
196
202
|
def __aiter__(self) -> "Self":
|
|
197
203
|
return self
|
|
198
204
|
|
|
@@ -205,6 +211,13 @@ class WebsocketMessageStreamMock:
|
|
|
205
211
|
|
|
206
212
|
return self.messages.popleft()
|
|
207
213
|
|
|
214
|
+
@staticmethod
|
|
215
|
+
async def pong() -> Literal[False]:
|
|
216
|
+
return False
|
|
217
|
+
|
|
218
|
+
async def connect(self) -> None:
|
|
219
|
+
pass
|
|
220
|
+
|
|
208
221
|
async def send(self, data: bytes) -> None:
|
|
209
222
|
pass
|
|
210
223
|
|
web3/contract/base_contract.py
CHANGED
|
@@ -57,7 +57,7 @@ from web3._utils.datatypes import (
|
|
|
57
57
|
PropertyCheckingFactory,
|
|
58
58
|
)
|
|
59
59
|
from web3._utils.decorators import (
|
|
60
|
-
|
|
60
|
+
deprecate_method,
|
|
61
61
|
)
|
|
62
62
|
from web3._utils.empty import (
|
|
63
63
|
empty,
|
|
@@ -727,7 +727,7 @@ class BaseContract:
|
|
|
727
727
|
# Public API
|
|
728
728
|
#
|
|
729
729
|
@combomethod
|
|
730
|
-
@
|
|
730
|
+
@deprecate_method("encode_abi()")
|
|
731
731
|
def encodeABI(
|
|
732
732
|
cls,
|
|
733
733
|
fn_name: str,
|
web3/exceptions.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import datetime
|
|
2
2
|
import time
|
|
3
3
|
from typing import (
|
|
4
|
+
TYPE_CHECKING,
|
|
4
5
|
Any,
|
|
5
6
|
Dict,
|
|
6
7
|
Optional,
|
|
@@ -15,6 +16,9 @@ from web3.types import (
|
|
|
15
16
|
BlockData,
|
|
16
17
|
)
|
|
17
18
|
|
|
19
|
+
if TYPE_CHECKING:
|
|
20
|
+
import asyncio
|
|
21
|
+
|
|
18
22
|
|
|
19
23
|
class Web3Exception(Exception):
|
|
20
24
|
"""
|
|
@@ -341,7 +345,21 @@ class BadResponseFormat(Web3Exception):
|
|
|
341
345
|
Raised when a JSON-RPC response comes back in an unexpected format
|
|
342
346
|
"""
|
|
343
347
|
|
|
344
|
-
|
|
348
|
+
|
|
349
|
+
class TaskNotRunning(Web3Exception):
|
|
350
|
+
"""
|
|
351
|
+
Used to signal between asyncio contexts that a task that is being awaited
|
|
352
|
+
is not currently running.
|
|
353
|
+
"""
|
|
354
|
+
|
|
355
|
+
def __init__(
|
|
356
|
+
self, task: "asyncio.Task[Any]", message: Optional[str] = None
|
|
357
|
+
) -> None:
|
|
358
|
+
self.task = task
|
|
359
|
+
if message is None:
|
|
360
|
+
message = f"Task {task} is not running."
|
|
361
|
+
self.message = message
|
|
362
|
+
super().__init__(message)
|
|
345
363
|
|
|
346
364
|
|
|
347
365
|
class MethodUnavailable(Web3Exception):
|
web3/geth.py
CHANGED
|
@@ -21,6 +21,9 @@ from hexbytes.main import (
|
|
|
21
21
|
from web3._utils.compat import (
|
|
22
22
|
Protocol,
|
|
23
23
|
)
|
|
24
|
+
from web3._utils.decorators import (
|
|
25
|
+
deprecate_method,
|
|
26
|
+
)
|
|
24
27
|
from web3._utils.miner import (
|
|
25
28
|
make_dag,
|
|
26
29
|
set_etherbase,
|
|
@@ -35,6 +38,7 @@ from web3._utils.rpc_abi import (
|
|
|
35
38
|
RPC,
|
|
36
39
|
)
|
|
37
40
|
from web3.method import (
|
|
41
|
+
DeprecatedMethod,
|
|
38
42
|
Method,
|
|
39
43
|
default_root_munger,
|
|
40
44
|
)
|
|
@@ -63,6 +67,12 @@ class UnlockAccountWrapper(Protocol):
|
|
|
63
67
|
pass
|
|
64
68
|
|
|
65
69
|
|
|
70
|
+
GETH_PERSONAL_DEPRECATION_MSG = (
|
|
71
|
+
"Geth now uses `clef` for account and key management. This method will be removed "
|
|
72
|
+
"in web3.py `v7`."
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
|
|
66
76
|
class GethPersonal(Module):
|
|
67
77
|
"""
|
|
68
78
|
https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-personal
|
|
@@ -70,57 +80,75 @@ class GethPersonal(Module):
|
|
|
70
80
|
|
|
71
81
|
is_async = False
|
|
72
82
|
|
|
73
|
-
|
|
83
|
+
_ec_recover: Method[Callable[[str, HexStr], ChecksumAddress]] = Method(
|
|
74
84
|
RPC.personal_ecRecover,
|
|
75
85
|
mungers=[default_root_munger],
|
|
76
86
|
)
|
|
87
|
+
ec_recover = DeprecatedMethod(_ec_recover, msg=GETH_PERSONAL_DEPRECATION_MSG)
|
|
77
88
|
|
|
78
|
-
|
|
89
|
+
_import_raw_key: Method[Callable[[str, str], ChecksumAddress]] = Method(
|
|
79
90
|
RPC.personal_importRawKey,
|
|
80
91
|
mungers=[default_root_munger],
|
|
81
92
|
)
|
|
93
|
+
import_raw_key = DeprecatedMethod(
|
|
94
|
+
_import_raw_key, msg=GETH_PERSONAL_DEPRECATION_MSG
|
|
95
|
+
)
|
|
82
96
|
|
|
83
|
-
|
|
97
|
+
_list_accounts: Method[Callable[[], List[ChecksumAddress]]] = Method(
|
|
84
98
|
RPC.personal_listAccounts,
|
|
85
99
|
is_property=True,
|
|
86
100
|
)
|
|
101
|
+
list_accounts = DeprecatedMethod(_list_accounts, msg=GETH_PERSONAL_DEPRECATION_MSG)
|
|
87
102
|
|
|
88
|
-
|
|
103
|
+
_list_wallets: Method[Callable[[], List[GethWallet]]] = Method(
|
|
89
104
|
RPC.personal_listWallets,
|
|
90
105
|
is_property=True,
|
|
91
106
|
)
|
|
107
|
+
list_wallets = DeprecatedMethod(_list_wallets, msg=GETH_PERSONAL_DEPRECATION_MSG)
|
|
92
108
|
|
|
93
|
-
|
|
109
|
+
_send_transaction: Method[Callable[[TxParams, str], HexBytes]] = Method(
|
|
94
110
|
RPC.personal_sendTransaction,
|
|
95
111
|
mungers=[default_root_munger],
|
|
96
112
|
)
|
|
113
|
+
send_transaction = DeprecatedMethod(
|
|
114
|
+
_send_transaction, msg=GETH_PERSONAL_DEPRECATION_MSG
|
|
115
|
+
)
|
|
97
116
|
|
|
98
|
-
|
|
117
|
+
_sign: Method[Callable[[str, ChecksumAddress, Optional[str]], HexStr]] = Method(
|
|
99
118
|
RPC.personal_sign,
|
|
100
119
|
mungers=[default_root_munger],
|
|
101
120
|
)
|
|
121
|
+
sign = DeprecatedMethod(_sign, msg=GETH_PERSONAL_DEPRECATION_MSG)
|
|
102
122
|
|
|
103
|
-
|
|
123
|
+
_sign_typed_data: Method[
|
|
104
124
|
Callable[[Dict[str, Any], ChecksumAddress, str], HexStr]
|
|
105
125
|
] = Method(
|
|
106
126
|
RPC.personal_signTypedData,
|
|
107
127
|
mungers=[default_root_munger],
|
|
108
128
|
)
|
|
129
|
+
sign_typed_data = DeprecatedMethod(
|
|
130
|
+
_sign_typed_data, msg=GETH_PERSONAL_DEPRECATION_MSG
|
|
131
|
+
)
|
|
109
132
|
|
|
110
|
-
|
|
133
|
+
_new_account: Method[Callable[[str], ChecksumAddress]] = Method(
|
|
111
134
|
RPC.personal_newAccount,
|
|
112
135
|
mungers=[default_root_munger],
|
|
113
136
|
)
|
|
137
|
+
new_account = DeprecatedMethod(_new_account, msg=GETH_PERSONAL_DEPRECATION_MSG)
|
|
114
138
|
|
|
115
|
-
|
|
139
|
+
_lock_account: Method[Callable[[ChecksumAddress], bool]] = Method(
|
|
116
140
|
RPC.personal_lockAccount,
|
|
117
141
|
mungers=[default_root_munger],
|
|
118
142
|
)
|
|
143
|
+
lock_account = DeprecatedMethod(_lock_account, msg=GETH_PERSONAL_DEPRECATION_MSG)
|
|
119
144
|
|
|
120
|
-
|
|
145
|
+
_unlock_account: Method[UnlockAccountWrapper] = Method(
|
|
121
146
|
RPC.personal_unlockAccount,
|
|
122
147
|
mungers=[default_root_munger],
|
|
123
148
|
)
|
|
149
|
+
unlock_account = DeprecatedMethod(
|
|
150
|
+
_unlock_account, msg=GETH_PERSONAL_DEPRECATION_MSG
|
|
151
|
+
)
|
|
124
152
|
|
|
125
153
|
|
|
126
154
|
class GethTxPool(Module):
|
|
@@ -373,6 +401,7 @@ class AsyncGethPersonal(Module):
|
|
|
373
401
|
mungers=[default_root_munger],
|
|
374
402
|
)
|
|
375
403
|
|
|
404
|
+
@deprecate_method(deprecation_msg=GETH_PERSONAL_DEPRECATION_MSG)
|
|
376
405
|
async def ec_recover(self, message: str, signature: HexStr) -> ChecksumAddress:
|
|
377
406
|
return await self._ec_recover(message, signature)
|
|
378
407
|
|
|
@@ -383,6 +412,7 @@ class AsyncGethPersonal(Module):
|
|
|
383
412
|
mungers=[default_root_munger],
|
|
384
413
|
)
|
|
385
414
|
|
|
415
|
+
@deprecate_method(deprecation_msg=GETH_PERSONAL_DEPRECATION_MSG)
|
|
386
416
|
async def import_raw_key(
|
|
387
417
|
self, private_key: str, passphrase: str
|
|
388
418
|
) -> ChecksumAddress:
|
|
@@ -400,9 +430,11 @@ class AsyncGethPersonal(Module):
|
|
|
400
430
|
is_property=True,
|
|
401
431
|
)
|
|
402
432
|
|
|
433
|
+
@deprecate_method(deprecation_msg=GETH_PERSONAL_DEPRECATION_MSG)
|
|
403
434
|
async def list_accounts(self) -> List[ChecksumAddress]:
|
|
404
435
|
return await self._list_accounts()
|
|
405
436
|
|
|
437
|
+
@deprecate_method(deprecation_msg=GETH_PERSONAL_DEPRECATION_MSG)
|
|
406
438
|
async def list_wallets(self) -> List[GethWallet]:
|
|
407
439
|
return await self._list_wallets()
|
|
408
440
|
|
|
@@ -413,6 +445,7 @@ class AsyncGethPersonal(Module):
|
|
|
413
445
|
mungers=[default_root_munger],
|
|
414
446
|
)
|
|
415
447
|
|
|
448
|
+
@deprecate_method(deprecation_msg=GETH_PERSONAL_DEPRECATION_MSG)
|
|
416
449
|
async def send_transaction(
|
|
417
450
|
self, transaction: TxParams, passphrase: str
|
|
418
451
|
) -> HexBytes:
|
|
@@ -434,11 +467,13 @@ class AsyncGethPersonal(Module):
|
|
|
434
467
|
mungers=[default_root_munger],
|
|
435
468
|
)
|
|
436
469
|
|
|
470
|
+
@deprecate_method(deprecation_msg=GETH_PERSONAL_DEPRECATION_MSG)
|
|
437
471
|
async def sign(
|
|
438
472
|
self, message: str, account: ChecksumAddress, passphrase: str
|
|
439
473
|
) -> HexStr:
|
|
440
474
|
return await self._sign(message, account, passphrase)
|
|
441
475
|
|
|
476
|
+
@deprecate_method(deprecation_msg=GETH_PERSONAL_DEPRECATION_MSG)
|
|
442
477
|
async def sign_typed_data(
|
|
443
478
|
self, message: Dict[str, Any], account: ChecksumAddress, passphrase: str
|
|
444
479
|
) -> HexStr:
|
|
@@ -463,12 +498,15 @@ class AsyncGethPersonal(Module):
|
|
|
463
498
|
mungers=[default_root_munger],
|
|
464
499
|
)
|
|
465
500
|
|
|
501
|
+
@deprecate_method(deprecation_msg=GETH_PERSONAL_DEPRECATION_MSG)
|
|
466
502
|
async def new_account(self, passphrase: str) -> ChecksumAddress:
|
|
467
503
|
return await self._new_account(passphrase)
|
|
468
504
|
|
|
505
|
+
@deprecate_method(deprecation_msg=GETH_PERSONAL_DEPRECATION_MSG)
|
|
469
506
|
async def lock_account(self, account: ChecksumAddress) -> bool:
|
|
470
507
|
return await self._lock_account(account)
|
|
471
508
|
|
|
509
|
+
@deprecate_method(deprecation_msg=GETH_PERSONAL_DEPRECATION_MSG)
|
|
472
510
|
async def unlock_account(
|
|
473
511
|
self, account: ChecksumAddress, passphrase: str, duration: Optional[int] = None
|
|
474
512
|
) -> bool:
|
web3/main.py
CHANGED
|
@@ -573,12 +573,9 @@ class _PersistentConnectionWeb3(AsyncWeb3):
|
|
|
573
573
|
|
|
574
574
|
# async for w3 in w3.persistent_websocket(provider)
|
|
575
575
|
async def __aiter__(self) -> AsyncIterator[Self]:
|
|
576
|
-
|
|
577
|
-
await self.provider.connect()
|
|
578
|
-
|
|
576
|
+
provider = self.provider
|
|
579
577
|
while True:
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
continue
|
|
578
|
+
await provider.connect()
|
|
579
|
+
yield self
|
|
580
|
+
provider.logger.error("Connection interrupted, attempting to reconnect...")
|
|
581
|
+
await provider.disconnect()
|
web3/manager.py
CHANGED
|
@@ -35,6 +35,7 @@ from web3.exceptions import (
|
|
|
35
35
|
BadResponseFormat,
|
|
36
36
|
MethodUnavailable,
|
|
37
37
|
ProviderConnectionError,
|
|
38
|
+
TaskNotRunning,
|
|
38
39
|
)
|
|
39
40
|
from web3.middleware import (
|
|
40
41
|
abi_middleware,
|
|
@@ -377,14 +378,24 @@ class RequestManager:
|
|
|
377
378
|
raise ProviderConnectionError("No listener found for websocket connection.")
|
|
378
379
|
|
|
379
380
|
while True:
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
381
|
+
try:
|
|
382
|
+
response = await self._request_processor.pop_raw_response(
|
|
383
|
+
subscription=True
|
|
384
|
+
)
|
|
385
|
+
if (
|
|
386
|
+
response is not None
|
|
387
|
+
and response.get("params", {}).get("subscription")
|
|
388
|
+
in self._request_processor.active_subscriptions
|
|
389
|
+
):
|
|
390
|
+
# if response is an active subscription response, process it
|
|
391
|
+
yield await self._process_ws_response(response)
|
|
392
|
+
except TaskNotRunning:
|
|
393
|
+
self._provider._handle_listener_task_exceptions()
|
|
394
|
+
self.logger.error(
|
|
395
|
+
"Message listener background task has stopped unexpectedly. "
|
|
396
|
+
"Stopping message stream."
|
|
397
|
+
)
|
|
398
|
+
raise StopAsyncIteration
|
|
388
399
|
|
|
389
400
|
async def _process_ws_response(self, response: RPCResponse) -> RPCResponse:
|
|
390
401
|
provider = cast(PersistentConnectionProvider, self._provider)
|