web3 7.0.0b1__py3-none-any.whl → 7.0.0b3__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 +6 -8
- ens/ens.py +6 -6
- ens/utils.py +18 -16
- web3/_utils/abi.py +9 -15
- web3/_utils/events.py +15 -6
- web3/_utils/math.py +12 -14
- web3/_utils/method_formatters.py +7 -0
- web3/_utils/module_testing/eth_module.py +67 -6
- web3/_utils/module_testing/module_testing_utils.py +2 -2
- web3/_utils/request.py +1 -1
- web3/_utils/rpc_abi.py +1 -0
- web3/_utils/transactions.py +4 -0
- web3/contract/base_contract.py +1 -1
- web3/datastructures.py +7 -7
- web3/eth/async_eth.py +20 -2
- web3/eth/eth.py +13 -1
- web3/exceptions.py +11 -0
- web3/main.py +4 -30
- web3/manager.py +12 -13
- web3/middleware/__init__.py +9 -8
- web3/module.py +1 -1
- web3/providers/async_base.py +6 -6
- web3/providers/base.py +8 -8
- web3/providers/eth_tester/main.py +16 -20
- web3/providers/ipc.py +1 -1
- web3/providers/legacy_websocket.py +1 -1
- web3/providers/persistent/persistent.py +2 -2
- web3/providers/persistent/request_processor.py +3 -5
- web3/tools/benchmark/main.py +2 -2
- web3/types.py +4 -0
- web3/utils/caching.py +2 -4
- {web3-7.0.0b1.dist-info → web3-7.0.0b3.dist-info}/METADATA +3 -9
- web3-7.0.0b3.dist-info/RECORD +168 -0
- {web3-7.0.0b1.dist-info → web3-7.0.0b3.dist-info}/WHEEL +1 -1
- {web3-7.0.0b1.dist-info → web3-7.0.0b3.dist-info}/top_level.txt +0 -1
- ethpm/__init__.py +0 -20
- ethpm/_utils/__init__.py +0 -0
- ethpm/_utils/backend.py +0 -93
- ethpm/_utils/cache.py +0 -44
- ethpm/_utils/chains.py +0 -119
- ethpm/_utils/contract.py +0 -35
- ethpm/_utils/deployments.py +0 -145
- ethpm/_utils/ipfs.py +0 -116
- ethpm/_utils/protobuf/__init__.py +0 -0
- ethpm/_utils/protobuf/ipfs_file_pb2.py +0 -33
- ethpm/_utils/registry.py +0 -29
- ethpm/assets/__init__.py +0 -0
- ethpm/assets/ens/v3.json +0 -1
- ethpm/assets/escrow/with_bytecode_v3.json +0 -1
- ethpm/assets/ipfs_file.proto +0 -32
- ethpm/assets/owned/output_v3.json +0 -1
- ethpm/assets/owned/with_contract_type_v3.json +0 -1
- ethpm/assets/registry/contracts/Authority.sol +0 -156
- ethpm/assets/registry/contracts/IndexedOrderedSetLib.sol +0 -106
- ethpm/assets/registry/contracts/PackageDB.sol +0 -225
- ethpm/assets/registry/contracts/PackageRegistry.sol +0 -361
- ethpm/assets/registry/contracts/PackageRegistryInterface.sol +0 -97
- ethpm/assets/registry/contracts/ReleaseDB.sol +0 -309
- ethpm/assets/registry/contracts/ReleaseValidator.sol +0 -152
- ethpm/assets/registry/solc_input.json +0 -1
- ethpm/assets/registry/solc_output.json +0 -1
- ethpm/assets/registry/v3.json +0 -1
- ethpm/assets/safe-math-lib/v3-strict-no-deployments.json +0 -1
- ethpm/assets/simple-registry/contracts/Ownable.sol +0 -63
- ethpm/assets/simple-registry/contracts/PackageRegistry.sol +0 -373
- ethpm/assets/simple-registry/contracts/PackageRegistryInterface.sol +0 -96
- ethpm/assets/simple-registry/solc_input.json +0 -33
- ethpm/assets/simple-registry/solc_output.json +0 -1
- ethpm/assets/simple-registry/v3.json +0 -1
- ethpm/assets/standard-token/output_v3.json +0 -1
- ethpm/assets/standard-token/with_bytecode_v3.json +0 -1
- ethpm/assets/vyper_registry/0.1.0.json +0 -1
- ethpm/assets/vyper_registry/registry.vy +0 -216
- ethpm/assets/vyper_registry/registry_with_delete.vy +0 -244
- ethpm/backends/__init__.py +0 -0
- ethpm/backends/base.py +0 -43
- ethpm/backends/http.py +0 -108
- ethpm/backends/ipfs.py +0 -219
- ethpm/backends/registry.py +0 -154
- ethpm/constants.py +0 -17
- ethpm/contract.py +0 -187
- ethpm/dependencies.py +0 -58
- ethpm/deployments.py +0 -80
- ethpm/ethpm-spec/examples/escrow/1.0.0-pretty.json +0 -146
- ethpm/ethpm-spec/examples/escrow/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/escrow/contracts/Escrow.sol +0 -32
- ethpm/ethpm-spec/examples/escrow/contracts/SafeSendLib.sol +0 -20
- ethpm/ethpm-spec/examples/escrow/v3-pretty.json +0 -171
- ethpm/ethpm-spec/examples/escrow/v3.json +0 -1
- ethpm/ethpm-spec/examples/owned/1.0.0-pretty.json +0 -21
- ethpm/ethpm-spec/examples/owned/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/owned/contracts/Owned.sol +0 -12
- ethpm/ethpm-spec/examples/owned/v3-pretty.json +0 -27
- ethpm/ethpm-spec/examples/owned/v3.json +0 -1
- ethpm/ethpm-spec/examples/piper-coin/1.0.0-pretty.json +0 -31
- ethpm/ethpm-spec/examples/piper-coin/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/piper-coin/v3-pretty.json +0 -21
- ethpm/ethpm-spec/examples/piper-coin/v3.json +0 -1
- ethpm/ethpm-spec/examples/safe-math-lib/1.0.0-pretty.json +0 -85
- ethpm/ethpm-spec/examples/safe-math-lib/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/safe-math-lib/contracts/SafeMathLib.sol +0 -24
- ethpm/ethpm-spec/examples/safe-math-lib/v3-pretty.json +0 -117
- ethpm/ethpm-spec/examples/safe-math-lib/v3.json +0 -1
- ethpm/ethpm-spec/examples/standard-token/1.0.0-pretty.json +0 -55
- ethpm/ethpm-spec/examples/standard-token/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/standard-token/contracts/AbstractToken.sol +0 -20
- ethpm/ethpm-spec/examples/standard-token/contracts/StandardToken.sol +0 -84
- ethpm/ethpm-spec/examples/standard-token/v3-pretty.json +0 -460
- ethpm/ethpm-spec/examples/standard-token/v3.json +0 -1
- ethpm/ethpm-spec/examples/transferable/1.0.0-pretty.json +0 -21
- ethpm/ethpm-spec/examples/transferable/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/transferable/contracts/Transferable.sol +0 -14
- ethpm/ethpm-spec/examples/transferable/v3-pretty.json +0 -27
- ethpm/ethpm-spec/examples/transferable/v3.json +0 -1
- ethpm/ethpm-spec/examples/wallet/1.0.0-pretty.json +0 -120
- ethpm/ethpm-spec/examples/wallet/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/wallet/contracts/Wallet.sol +0 -41
- ethpm/ethpm-spec/examples/wallet/v3-pretty.json +0 -181
- ethpm/ethpm-spec/examples/wallet/v3.json +0 -1
- ethpm/ethpm-spec/examples/wallet-with-send/1.0.0-pretty.json +0 -135
- ethpm/ethpm-spec/examples/wallet-with-send/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/wallet-with-send/contracts/WalletWithSend.sol +0 -18
- ethpm/ethpm-spec/examples/wallet-with-send/v3-pretty.json +0 -207
- ethpm/ethpm-spec/examples/wallet-with-send/v3.json +0 -1
- ethpm/ethpm-spec/spec/package.spec.json +0 -379
- ethpm/ethpm-spec/spec/v3.spec.json +0 -483
- ethpm/exceptions.py +0 -68
- ethpm/package.py +0 -438
- ethpm/tools/__init__.py +0 -4
- ethpm/tools/builder.py +0 -930
- ethpm/tools/checker.py +0 -312
- ethpm/tools/get_manifest.py +0 -19
- ethpm/uri.py +0 -141
- ethpm/validation/__init__.py +0 -0
- ethpm/validation/manifest.py +0 -146
- ethpm/validation/misc.py +0 -39
- ethpm/validation/package.py +0 -80
- ethpm/validation/uri.py +0 -163
- web3/pm.py +0 -602
- web3/tools/__init__.py +0 -4
- web3/tools/pytest_ethereum/__init__.py +0 -0
- web3/tools/pytest_ethereum/_utils.py +0 -145
- web3/tools/pytest_ethereum/deployer.py +0 -48
- web3/tools/pytest_ethereum/exceptions.py +0 -22
- web3/tools/pytest_ethereum/linker.py +0 -128
- web3/tools/pytest_ethereum/plugins.py +0 -33
- web3-7.0.0b1.dist-info/RECORD +0 -280
- web3-7.0.0b1.dist-info/entry_points.txt +0 -2
- {web3-7.0.0b1.dist-info → web3-7.0.0b3.dist-info}/LICENSE +0 -0
web3/eth/async_eth.py
CHANGED
|
@@ -4,6 +4,7 @@ from typing import (
|
|
|
4
4
|
Any,
|
|
5
5
|
Awaitable,
|
|
6
6
|
Callable,
|
|
7
|
+
Dict,
|
|
7
8
|
List,
|
|
8
9
|
Optional,
|
|
9
10
|
Tuple,
|
|
@@ -75,6 +76,7 @@ from web3.types import (
|
|
|
75
76
|
BlockData,
|
|
76
77
|
BlockIdentifier,
|
|
77
78
|
BlockParams,
|
|
79
|
+
BlockReceipts,
|
|
78
80
|
CreateAccessListResponse,
|
|
79
81
|
FeeHistory,
|
|
80
82
|
FilterParams,
|
|
@@ -440,6 +442,20 @@ class AsyncEth(BaseEth):
|
|
|
440
442
|
) -> BlockData:
|
|
441
443
|
return await self._get_block(block_identifier, full_transactions)
|
|
442
444
|
|
|
445
|
+
# eth_getBlockReceipts
|
|
446
|
+
|
|
447
|
+
_get_block_receipts: Method[
|
|
448
|
+
Callable[[BlockIdentifier], Awaitable[BlockReceipts]]
|
|
449
|
+
] = Method(
|
|
450
|
+
RPC.eth_getBlockReceipts,
|
|
451
|
+
mungers=[default_root_munger],
|
|
452
|
+
)
|
|
453
|
+
|
|
454
|
+
async def get_block_receipts(
|
|
455
|
+
self, block_identifier: BlockIdentifier
|
|
456
|
+
) -> BlockReceipts:
|
|
457
|
+
return await self._get_block_receipts(block_identifier)
|
|
458
|
+
|
|
443
459
|
# eth_getBalance
|
|
444
460
|
|
|
445
461
|
_get_balance: Method[
|
|
@@ -622,14 +638,16 @@ class AsyncEth(BaseEth):
|
|
|
622
638
|
# eth_signTypedData
|
|
623
639
|
|
|
624
640
|
_sign_typed_data: Method[
|
|
625
|
-
Callable[
|
|
641
|
+
Callable[
|
|
642
|
+
[Union[Address, ChecksumAddress, ENS], Dict[str, Any]], Awaitable[HexStr]
|
|
643
|
+
]
|
|
626
644
|
] = Method(
|
|
627
645
|
RPC.eth_signTypedData,
|
|
628
646
|
mungers=[default_root_munger],
|
|
629
647
|
)
|
|
630
648
|
|
|
631
649
|
async def sign_typed_data(
|
|
632
|
-
self, account: Union[Address, ChecksumAddress, ENS], data: str
|
|
650
|
+
self, account: Union[Address, ChecksumAddress, ENS], data: Dict[str, Any]
|
|
633
651
|
) -> HexStr:
|
|
634
652
|
return await self._sign_typed_data(account, data)
|
|
635
653
|
|
web3/eth/eth.py
CHANGED
|
@@ -2,6 +2,7 @@ from typing import (
|
|
|
2
2
|
TYPE_CHECKING,
|
|
3
3
|
Any,
|
|
4
4
|
Callable,
|
|
5
|
+
Dict,
|
|
5
6
|
List,
|
|
6
7
|
Optional,
|
|
7
8
|
Sequence,
|
|
@@ -72,6 +73,7 @@ from web3.types import (
|
|
|
72
73
|
BlockData,
|
|
73
74
|
BlockIdentifier,
|
|
74
75
|
BlockParams,
|
|
76
|
+
BlockReceipts,
|
|
75
77
|
CreateAccessListResponse,
|
|
76
78
|
FeeHistory,
|
|
77
79
|
FilterParams,
|
|
@@ -411,6 +413,16 @@ class Eth(BaseEth):
|
|
|
411
413
|
) -> BlockData:
|
|
412
414
|
return self._get_block(block_identifier, full_transactions)
|
|
413
415
|
|
|
416
|
+
# eth_getBlockReceipts
|
|
417
|
+
|
|
418
|
+
_get_block_receipts: Method[Callable[[BlockIdentifier], BlockReceipts]] = Method(
|
|
419
|
+
RPC.eth_getBlockReceipts,
|
|
420
|
+
mungers=[default_root_munger],
|
|
421
|
+
)
|
|
422
|
+
|
|
423
|
+
def get_block_receipts(self, block_identifier: BlockIdentifier) -> BlockReceipts:
|
|
424
|
+
return self._get_block_receipts(block_identifier)
|
|
425
|
+
|
|
414
426
|
# eth_getBalance
|
|
415
427
|
|
|
416
428
|
_get_balance: Method[
|
|
@@ -611,7 +623,7 @@ class Eth(BaseEth):
|
|
|
611
623
|
# eth_signTypedData
|
|
612
624
|
|
|
613
625
|
sign_typed_data: Method[
|
|
614
|
-
Callable[[Union[Address, ChecksumAddress, ENS], str], HexStr]
|
|
626
|
+
Callable[[Union[Address, ChecksumAddress, ENS], Dict[str, Any]], HexStr]
|
|
615
627
|
] = Method(
|
|
616
628
|
RPC.eth_signTypedData,
|
|
617
629
|
mungers=[default_root_munger],
|
web3/exceptions.py
CHANGED
|
@@ -30,6 +30,16 @@ class Web3Exception(Exception):
|
|
|
30
30
|
# deal with other exceptions
|
|
31
31
|
"""
|
|
32
32
|
|
|
33
|
+
def __init__(
|
|
34
|
+
self,
|
|
35
|
+
*args: Any,
|
|
36
|
+
user_message: Optional[str] = None,
|
|
37
|
+
):
|
|
38
|
+
super().__init__(*args)
|
|
39
|
+
|
|
40
|
+
# Assign properties of Web3Exception
|
|
41
|
+
self.user_message = user_message
|
|
42
|
+
|
|
33
43
|
|
|
34
44
|
class BadFunctionCallOutput(Web3Exception):
|
|
35
45
|
"""
|
|
@@ -274,6 +284,7 @@ class ContractLogicError(Web3Exception):
|
|
|
274
284
|
message: Optional[str] = None,
|
|
275
285
|
data: Optional[Union[str, Dict[str, str]]] = None,
|
|
276
286
|
):
|
|
287
|
+
super().__init__(message, data)
|
|
277
288
|
self.message = message
|
|
278
289
|
self.data = data
|
|
279
290
|
|
web3/main.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import decimal
|
|
2
|
-
import warnings
|
|
3
2
|
from types import (
|
|
4
3
|
TracebackType,
|
|
5
4
|
)
|
|
@@ -142,7 +141,6 @@ from web3.types import (
|
|
|
142
141
|
)
|
|
143
142
|
|
|
144
143
|
if TYPE_CHECKING:
|
|
145
|
-
from web3.pm import PM # noqa: F401
|
|
146
144
|
from web3._utils.empty import Empty # noqa: F401
|
|
147
145
|
|
|
148
146
|
|
|
@@ -338,30 +336,6 @@ class BaseWeb3:
|
|
|
338
336
|
def is_encodable(self, _type: TypeStr, value: Any) -> bool:
|
|
339
337
|
return self.codec.is_encodable(_type, value)
|
|
340
338
|
|
|
341
|
-
@property
|
|
342
|
-
def pm(self) -> "PM":
|
|
343
|
-
if hasattr(self, "_pm"):
|
|
344
|
-
# ignored b/c property is dynamically set
|
|
345
|
-
# via enable_unstable_package_management_api
|
|
346
|
-
return self._pm
|
|
347
|
-
else:
|
|
348
|
-
raise AttributeError(
|
|
349
|
-
"The Package Management feature is disabled by default until "
|
|
350
|
-
"its API stabilizes. To use these features, please enable them by "
|
|
351
|
-
"running `w3.enable_unstable_package_management_api()` and try again."
|
|
352
|
-
)
|
|
353
|
-
|
|
354
|
-
def enable_unstable_package_management_api(self) -> None:
|
|
355
|
-
if not hasattr(self, "_pm"):
|
|
356
|
-
warnings.warn(
|
|
357
|
-
"The ``ethPM`` module is no longer being maintained and will be "
|
|
358
|
-
"deprecated with ``web3.py`` version 7",
|
|
359
|
-
UserWarning,
|
|
360
|
-
)
|
|
361
|
-
from web3.pm import PM # noqa: F811
|
|
362
|
-
|
|
363
|
-
self.attach_modules({"_pm": PM})
|
|
364
|
-
|
|
365
339
|
|
|
366
340
|
class Web3(BaseWeb3):
|
|
367
341
|
# mypy types
|
|
@@ -378,14 +352,14 @@ class Web3(BaseWeb3):
|
|
|
378
352
|
def __init__(
|
|
379
353
|
self,
|
|
380
354
|
provider: Optional[BaseProvider] = None,
|
|
381
|
-
|
|
355
|
+
middleware: Optional[Sequence[Any]] = None,
|
|
382
356
|
modules: Optional[Dict[str, Union[Type[Module], Sequence[Any]]]] = None,
|
|
383
357
|
external_modules: Optional[
|
|
384
358
|
Dict[str, Union[Type[Module], Sequence[Any]]]
|
|
385
359
|
] = None,
|
|
386
360
|
ens: Union[ENS, "Empty"] = empty,
|
|
387
361
|
) -> None:
|
|
388
|
-
self.manager = self.RequestManager(self, provider,
|
|
362
|
+
self.manager = self.RequestManager(self, provider, middleware)
|
|
389
363
|
self.codec = ABICodec(build_strict_registry())
|
|
390
364
|
|
|
391
365
|
if modules is None:
|
|
@@ -446,14 +420,14 @@ class AsyncWeb3(BaseWeb3):
|
|
|
446
420
|
def __init__(
|
|
447
421
|
self,
|
|
448
422
|
provider: Optional[AsyncBaseProvider] = None,
|
|
449
|
-
|
|
423
|
+
middleware: Optional[Sequence[Any]] = None,
|
|
450
424
|
modules: Optional[Dict[str, Union[Type[Module], Sequence[Any]]]] = None,
|
|
451
425
|
external_modules: Optional[
|
|
452
426
|
Dict[str, Union[Type[Module], Sequence[Any]]]
|
|
453
427
|
] = None,
|
|
454
428
|
ens: Union[AsyncENS, "Empty"] = empty,
|
|
455
429
|
) -> None:
|
|
456
|
-
self.manager = self.RequestManager(self, provider,
|
|
430
|
+
self.manager = self.RequestManager(self, provider, middleware)
|
|
457
431
|
self.codec = ABICodec(build_strict_registry())
|
|
458
432
|
|
|
459
433
|
self._modules = get_async_default_modules() if modules is None else modules
|
web3/manager.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import asyncio
|
|
2
1
|
import logging
|
|
3
2
|
from typing import (
|
|
4
3
|
TYPE_CHECKING,
|
|
@@ -125,7 +124,7 @@ class RequestManager:
|
|
|
125
124
|
self,
|
|
126
125
|
w3: Union["AsyncWeb3", "Web3"],
|
|
127
126
|
provider: Optional[Union["BaseProvider", "AsyncBaseProvider"]] = None,
|
|
128
|
-
|
|
127
|
+
middleware: Optional[Sequence[Tuple[Middleware, str]]] = None,
|
|
129
128
|
) -> None:
|
|
130
129
|
self.w3 = w3
|
|
131
130
|
|
|
@@ -134,10 +133,10 @@ class RequestManager:
|
|
|
134
133
|
else:
|
|
135
134
|
self.provider = provider
|
|
136
135
|
|
|
137
|
-
if
|
|
138
|
-
|
|
136
|
+
if middleware is None:
|
|
137
|
+
middleware = self.get_default_middleware()
|
|
139
138
|
|
|
140
|
-
self.middleware_onion = NamedElementOnion(
|
|
139
|
+
self.middleware_onion = NamedElementOnion(middleware)
|
|
141
140
|
|
|
142
141
|
if isinstance(provider, PersistentConnectionProvider):
|
|
143
142
|
# set up the request processor to be able to properly process ordered
|
|
@@ -157,9 +156,9 @@ class RequestManager:
|
|
|
157
156
|
self._provider = provider
|
|
158
157
|
|
|
159
158
|
@staticmethod
|
|
160
|
-
def
|
|
159
|
+
def get_default_middleware() -> List[Tuple[Middleware, str]]:
|
|
161
160
|
"""
|
|
162
|
-
List the default
|
|
161
|
+
List the default middleware for the request manager.
|
|
163
162
|
Documentation should remain in sync with these defaults.
|
|
164
163
|
"""
|
|
165
164
|
return [
|
|
@@ -246,7 +245,11 @@ class RequestManager:
|
|
|
246
245
|
if not isinstance(code, int):
|
|
247
246
|
_raise_bad_response_format(response, "error['code'] must be an integer")
|
|
248
247
|
elif code == METHOD_NOT_FOUND:
|
|
249
|
-
raise MethodUnavailable(
|
|
248
|
+
raise MethodUnavailable(
|
|
249
|
+
error,
|
|
250
|
+
user_message="Check your node provider's API docs to see what "
|
|
251
|
+
"methods are supported",
|
|
252
|
+
)
|
|
250
253
|
|
|
251
254
|
# Errors must include a message
|
|
252
255
|
if not isinstance(error.get("message"), str):
|
|
@@ -345,11 +348,7 @@ class RequestManager:
|
|
|
345
348
|
)
|
|
346
349
|
|
|
347
350
|
while True:
|
|
348
|
-
|
|
349
|
-
# back to the event loop while waiting for the response in the queue.
|
|
350
|
-
await asyncio.sleep(0)
|
|
351
|
-
|
|
352
|
-
response = self._request_processor.pop_raw_response(subscription=True)
|
|
351
|
+
response = await self._request_processor.pop_raw_response(subscription=True)
|
|
353
352
|
if (
|
|
354
353
|
response is not None
|
|
355
354
|
and response.get("params", {}).get("subscription")
|
web3/middleware/__init__.py
CHANGED
|
@@ -11,6 +11,7 @@ from .attrdict import (
|
|
|
11
11
|
)
|
|
12
12
|
from .base import (
|
|
13
13
|
Middleware,
|
|
14
|
+
Web3Middleware,
|
|
14
15
|
)
|
|
15
16
|
from .buffered_gas_estimate import (
|
|
16
17
|
BufferedGasEstimateMiddleware,
|
|
@@ -58,8 +59,8 @@ if TYPE_CHECKING:
|
|
|
58
59
|
)
|
|
59
60
|
|
|
60
61
|
|
|
61
|
-
def
|
|
62
|
-
|
|
62
|
+
def combine_middleware(
|
|
63
|
+
middleware: Sequence[Middleware],
|
|
63
64
|
w3: "Web3",
|
|
64
65
|
provider_request_fn: MakeRequestFn,
|
|
65
66
|
) -> Callable[..., "RPCResponse"]:
|
|
@@ -69,14 +70,14 @@ def combine_middlewares(
|
|
|
69
70
|
the response through the response processors.
|
|
70
71
|
"""
|
|
71
72
|
accumulator_fn = provider_request_fn
|
|
72
|
-
for
|
|
73
|
+
for mw in reversed(middleware):
|
|
73
74
|
# initialize the middleware and wrap the accumulator function down the stack
|
|
74
|
-
accumulator_fn =
|
|
75
|
+
accumulator_fn = mw(w3).wrap_make_request(accumulator_fn)
|
|
75
76
|
return accumulator_fn
|
|
76
77
|
|
|
77
78
|
|
|
78
|
-
async def
|
|
79
|
-
|
|
79
|
+
async def async_combine_middleware(
|
|
80
|
+
middleware: Sequence[Middleware],
|
|
80
81
|
async_w3: "AsyncWeb3",
|
|
81
82
|
provider_request_fn: AsyncMakeRequestFn,
|
|
82
83
|
) -> Callable[..., Coroutine[Any, Any, "RPCResponse"]]:
|
|
@@ -86,8 +87,8 @@ async def async_combine_middlewares(
|
|
|
86
87
|
the response through the response processors.
|
|
87
88
|
"""
|
|
88
89
|
accumulator_fn = provider_request_fn
|
|
89
|
-
for
|
|
90
|
+
for mw in reversed(middleware):
|
|
90
91
|
# initialize the middleware and wrap the accumulator function down the stack
|
|
91
|
-
initialized =
|
|
92
|
+
initialized = mw(async_w3)
|
|
92
93
|
accumulator_fn = await initialized.async_wrap_make_request(accumulator_fn)
|
|
93
94
|
return accumulator_fn
|
web3/module.py
CHANGED
|
@@ -129,7 +129,7 @@ def retrieve_async_method_call_fn(
|
|
|
129
129
|
|
|
130
130
|
# Module should no longer have access to the full web3 api.
|
|
131
131
|
# Only the calling functions need access to the request methods.
|
|
132
|
-
# Any "re-entrant" shenanigans can go in the
|
|
132
|
+
# Any "re-entrant" shenanigans can go in the middleware, which do
|
|
133
133
|
# have web3 access.
|
|
134
134
|
class Module:
|
|
135
135
|
is_async = False
|
web3/providers/async_base.py
CHANGED
|
@@ -28,7 +28,7 @@ from web3.exceptions import (
|
|
|
28
28
|
ProviderConnectionError,
|
|
29
29
|
)
|
|
30
30
|
from web3.middleware import (
|
|
31
|
-
|
|
31
|
+
async_combine_middleware,
|
|
32
32
|
)
|
|
33
33
|
from web3.middleware.base import (
|
|
34
34
|
Middleware,
|
|
@@ -95,14 +95,14 @@ class AsyncBaseProvider:
|
|
|
95
95
|
async def request_func(
|
|
96
96
|
self, async_w3: "AsyncWeb3", middleware_onion: MiddlewareOnion
|
|
97
97
|
) -> Callable[..., Coroutine[Any, Any, RPCResponse]]:
|
|
98
|
-
|
|
98
|
+
middleware: Tuple[Middleware, ...] = middleware_onion.as_tuple_of_middleware()
|
|
99
99
|
|
|
100
100
|
cache_key = self._request_func_cache[0]
|
|
101
|
-
if cache_key !=
|
|
101
|
+
if cache_key != middleware:
|
|
102
102
|
self._request_func_cache = (
|
|
103
|
-
|
|
104
|
-
await
|
|
105
|
-
|
|
103
|
+
middleware,
|
|
104
|
+
await async_combine_middleware(
|
|
105
|
+
middleware=middleware,
|
|
106
106
|
async_w3=async_w3,
|
|
107
107
|
provider_request_fn=self.make_request,
|
|
108
108
|
),
|
web3/providers/base.py
CHANGED
|
@@ -25,7 +25,7 @@ from web3.exceptions import (
|
|
|
25
25
|
ProviderConnectionError,
|
|
26
26
|
)
|
|
27
27
|
from web3.middleware import (
|
|
28
|
-
|
|
28
|
+
combine_middleware,
|
|
29
29
|
)
|
|
30
30
|
from web3.middleware.base import (
|
|
31
31
|
Middleware,
|
|
@@ -61,7 +61,7 @@ CACHEABLE_REQUESTS = cast(
|
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
class BaseProvider:
|
|
64
|
-
# a tuple of (
|
|
64
|
+
# a tuple of (middleware, request_func)
|
|
65
65
|
_request_func_cache: Tuple[Tuple[Middleware, ...], Callable[..., RPCResponse]] = (
|
|
66
66
|
None,
|
|
67
67
|
None,
|
|
@@ -86,19 +86,19 @@ class BaseProvider:
|
|
|
86
86
|
) -> Callable[..., RPCResponse]:
|
|
87
87
|
"""
|
|
88
88
|
@param w3 is the web3 instance
|
|
89
|
-
@param middleware_onion is an iterable of
|
|
89
|
+
@param middleware_onion is an iterable of middleware,
|
|
90
90
|
ordered by first to execute
|
|
91
91
|
@returns a function that calls all the middleware and
|
|
92
92
|
eventually self.make_request()
|
|
93
93
|
"""
|
|
94
|
-
|
|
94
|
+
middleware: Tuple[Middleware, ...] = middleware_onion.as_tuple_of_middleware()
|
|
95
95
|
|
|
96
96
|
cache_key = self._request_func_cache[0]
|
|
97
|
-
if cache_key !=
|
|
97
|
+
if cache_key != middleware:
|
|
98
98
|
self._request_func_cache = (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
middleware,
|
|
100
|
+
combine_middleware(
|
|
101
|
+
middleware=middleware,
|
|
102
102
|
w3=w3,
|
|
103
103
|
provider_request_fn=self.make_request,
|
|
104
104
|
),
|
|
@@ -12,7 +12,7 @@ from eth_abi import (
|
|
|
12
12
|
abi,
|
|
13
13
|
)
|
|
14
14
|
from eth_abi.exceptions import (
|
|
15
|
-
|
|
15
|
+
DecodingError,
|
|
16
16
|
)
|
|
17
17
|
from eth_utils import (
|
|
18
18
|
is_bytes,
|
|
@@ -34,8 +34,8 @@ from web3.types import (
|
|
|
34
34
|
)
|
|
35
35
|
|
|
36
36
|
from ...middleware import (
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
async_combine_middleware,
|
|
38
|
+
combine_middleware,
|
|
39
39
|
)
|
|
40
40
|
from .middleware import (
|
|
41
41
|
default_transaction_fields_middleware,
|
|
@@ -58,7 +58,7 @@ if TYPE_CHECKING:
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
class AsyncEthereumTesterProvider(AsyncBaseProvider):
|
|
61
|
-
|
|
61
|
+
_middleware = (
|
|
62
62
|
default_transaction_fields_middleware,
|
|
63
63
|
ethereum_tester_middleware,
|
|
64
64
|
)
|
|
@@ -83,16 +83,14 @@ class AsyncEthereumTesterProvider(AsyncBaseProvider):
|
|
|
83
83
|
) -> Callable[..., Coroutine[Any, Any, RPCResponse]]:
|
|
84
84
|
# override the request_func to add the ethereum_tester_middleware
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
self._middlewares
|
|
88
|
-
)
|
|
86
|
+
middleware = middleware_onion.as_tuple_of_middleware() + tuple(self._middleware)
|
|
89
87
|
|
|
90
88
|
cache_key = self._request_func_cache[0]
|
|
91
|
-
if cache_key !=
|
|
89
|
+
if cache_key != middleware:
|
|
92
90
|
self._request_func_cache = (
|
|
93
|
-
|
|
94
|
-
await
|
|
95
|
-
|
|
91
|
+
middleware,
|
|
92
|
+
await async_combine_middleware(
|
|
93
|
+
middleware=middleware,
|
|
96
94
|
async_w3=async_w3,
|
|
97
95
|
provider_request_fn=self.make_request,
|
|
98
96
|
),
|
|
@@ -107,7 +105,7 @@ class AsyncEthereumTesterProvider(AsyncBaseProvider):
|
|
|
107
105
|
|
|
108
106
|
|
|
109
107
|
class EthereumTesterProvider(BaseProvider):
|
|
110
|
-
|
|
108
|
+
_middleware = (
|
|
111
109
|
default_transaction_fields_middleware,
|
|
112
110
|
ethereum_tester_middleware,
|
|
113
111
|
)
|
|
@@ -159,16 +157,14 @@ class EthereumTesterProvider(BaseProvider):
|
|
|
159
157
|
) -> Callable[..., RPCResponse]:
|
|
160
158
|
# override the request_func to add the ethereum_tester_middleware
|
|
161
159
|
|
|
162
|
-
|
|
163
|
-
self._middlewares
|
|
164
|
-
)
|
|
160
|
+
middleware = middleware_onion.as_tuple_of_middleware() + tuple(self._middleware)
|
|
165
161
|
|
|
166
162
|
cache_key = self._request_func_cache[0]
|
|
167
|
-
if cache_key !=
|
|
163
|
+
if cache_key != middleware:
|
|
168
164
|
self._request_func_cache = (
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
165
|
+
middleware,
|
|
166
|
+
combine_middleware(
|
|
167
|
+
middleware=middleware,
|
|
172
168
|
w3=w3,
|
|
173
169
|
provider_request_fn=self.make_request,
|
|
174
170
|
),
|
|
@@ -229,7 +225,7 @@ def _make_request(
|
|
|
229
225
|
if is_bytes(raw_error_msg)
|
|
230
226
|
else raw_error_msg
|
|
231
227
|
)
|
|
232
|
-
except
|
|
228
|
+
except DecodingError:
|
|
233
229
|
reason = first_arg
|
|
234
230
|
raise TransactionFailed(f"execution reverted: {reason}")
|
|
235
231
|
else:
|
web3/providers/ipc.py
CHANGED
|
@@ -24,7 +24,7 @@ from web3.types import (
|
|
|
24
24
|
RPCResponse,
|
|
25
25
|
)
|
|
26
26
|
|
|
27
|
-
DEFAULT_PERSISTENT_CONNECTION_TIMEOUT =
|
|
27
|
+
DEFAULT_PERSISTENT_CONNECTION_TIMEOUT = 30.0
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
class PersistentConnectionProvider(AsyncJSONBaseProvider, ABC):
|
|
@@ -78,7 +78,7 @@ class PersistentConnectionProvider(AsyncJSONBaseProvider, ABC):
|
|
|
78
78
|
self.logger.debug(
|
|
79
79
|
f"Popping response for id {request_id} from cache."
|
|
80
80
|
)
|
|
81
|
-
popped_response = self._request_processor.pop_raw_response(
|
|
81
|
+
popped_response = await self._request_processor.pop_raw_response(
|
|
82
82
|
cache_key=request_cache_key,
|
|
83
83
|
)
|
|
84
84
|
return popped_response
|
|
@@ -235,19 +235,17 @@ class RequestProcessor:
|
|
|
235
235
|
)
|
|
236
236
|
self._request_response_cache.cache(cache_key, raw_response)
|
|
237
237
|
|
|
238
|
-
def pop_raw_response(
|
|
238
|
+
async def pop_raw_response(
|
|
239
239
|
self, cache_key: str = None, subscription: bool = False
|
|
240
240
|
) -> Any:
|
|
241
241
|
if subscription:
|
|
242
242
|
qsize = self._subscription_response_queue.qsize()
|
|
243
|
-
|
|
244
|
-
return None
|
|
243
|
+
raw_response = await self._subscription_response_queue.get()
|
|
245
244
|
|
|
246
245
|
if not self._provider._listen_event.is_set():
|
|
247
246
|
self._provider._listen_event.set()
|
|
248
247
|
|
|
249
|
-
|
|
250
|
-
if qsize == 1:
|
|
248
|
+
if qsize == 0:
|
|
251
249
|
if not self._subscription_queue_synced_with_ws_stream:
|
|
252
250
|
self._subscription_queue_synced_with_ws_stream = True
|
|
253
251
|
self._provider.logger.info(
|
web3/tools/benchmark/main.py
CHANGED
|
@@ -59,7 +59,7 @@ def build_web3_http(endpoint_uri: str) -> Web3:
|
|
|
59
59
|
wait_for_http(endpoint_uri)
|
|
60
60
|
_w3 = Web3(
|
|
61
61
|
HTTPProvider(endpoint_uri),
|
|
62
|
-
|
|
62
|
+
middleware=[GasPriceStrategyMiddleware, BufferedGasEstimateMiddleware],
|
|
63
63
|
)
|
|
64
64
|
return _w3
|
|
65
65
|
|
|
@@ -68,7 +68,7 @@ async def build_async_w3_http(endpoint_uri: str) -> AsyncWeb3:
|
|
|
68
68
|
await wait_for_aiohttp(endpoint_uri)
|
|
69
69
|
_w3 = AsyncWeb3(
|
|
70
70
|
AsyncHTTPProvider(endpoint_uri),
|
|
71
|
-
|
|
71
|
+
middleware=[GasPriceStrategyMiddleware, BufferedGasEstimateMiddleware],
|
|
72
72
|
)
|
|
73
73
|
return _w3
|
|
74
74
|
|
web3/types.py
CHANGED
|
@@ -135,6 +135,7 @@ TxData = TypedDict(
|
|
|
135
135
|
"TxData",
|
|
136
136
|
{
|
|
137
137
|
"accessList": AccessList,
|
|
138
|
+
"blobVersionedHashes": Sequence[HexBytes],
|
|
138
139
|
"blockHash": HexBytes,
|
|
139
140
|
"blockNumber": BlockNumber,
|
|
140
141
|
"chainId": int,
|
|
@@ -142,6 +143,7 @@ TxData = TypedDict(
|
|
|
142
143
|
"from": ChecksumAddress,
|
|
143
144
|
"gas": int,
|
|
144
145
|
"gasPrice": Wei,
|
|
146
|
+
"maxFeePerBlobGas": Wei,
|
|
145
147
|
"maxFeePerGas": Wei,
|
|
146
148
|
"maxPriorityFeePerGas": Wei,
|
|
147
149
|
"hash": HexBytes,
|
|
@@ -381,6 +383,8 @@ TxReceipt = TypedDict(
|
|
|
381
383
|
},
|
|
382
384
|
)
|
|
383
385
|
|
|
386
|
+
BlockReceipts = List[TxReceipt]
|
|
387
|
+
|
|
384
388
|
|
|
385
389
|
class SignedTx(TypedDict, total=False):
|
|
386
390
|
raw: bytes
|
web3/utils/caching.py
CHANGED
|
@@ -16,22 +16,20 @@ class SimpleCache:
|
|
|
16
16
|
self._data: OrderedDict[str, Any] = OrderedDict()
|
|
17
17
|
|
|
18
18
|
def cache(self, key: str, value: Any) -> Tuple[Any, Dict[str, Any]]:
|
|
19
|
-
evicted_items =
|
|
19
|
+
evicted_items = {}
|
|
20
20
|
# If the key is already in the OrderedDict just update it
|
|
21
21
|
# and don't evict any values. Ideally, we could still check to see
|
|
22
22
|
# if there are too many items in the OrderedDict but that may rearrange
|
|
23
23
|
# the order it should be unlikely that the size could grow over the limit
|
|
24
24
|
if key not in self._data:
|
|
25
25
|
while len(self._data) >= self._size:
|
|
26
|
-
if evicted_items is None:
|
|
27
|
-
evicted_items = {}
|
|
28
26
|
k, v = self._data.popitem(last=False)
|
|
29
27
|
evicted_items[k] = v
|
|
30
28
|
self._data[key] = value
|
|
31
29
|
|
|
32
30
|
# Return the cached value along with the evicted items at the same time. No
|
|
33
31
|
# need to reach back into the cache to grab the value.
|
|
34
|
-
return value, evicted_items
|
|
32
|
+
return value, evicted_items or None
|
|
35
33
|
|
|
36
34
|
def get_cache_entry(self, key: str) -> Optional[Any]:
|
|
37
35
|
return self._data[key] if key in self._data else None
|