web3 7.11.0__py3-none-any.whl → 7.12.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 +2 -2
- ens/ens.py +2 -2
- ens/utils.py +14 -3
- web3/_utils/abi.py +24 -20
- web3/_utils/batching.py +22 -68
- web3/_utils/caching/request_caching_validation.py +8 -4
- web3/_utils/contract_sources/contract_data/ambiguous_function_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/arrays_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/bytes_contracts.py +5 -5
- web3/_utils/contract_sources/contract_data/constructor_contracts.py +7 -7
- web3/_utils/contract_sources/contract_data/contract_caller_tester.py +3 -3
- web3/_utils/contract_sources/contract_data/emitter_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/event_contracts.py +7 -7
- web3/_utils/contract_sources/contract_data/extended_resolver.py +3 -3
- web3/_utils/contract_sources/contract_data/fallback_function_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/function_name_tester_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/math_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/offchain_lookup.py +3 -3
- web3/_utils/contract_sources/contract_data/offchain_resolver.py +3 -3
- web3/_utils/contract_sources/contract_data/panic_errors_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/payable_tester.py +3 -3
- web3/_utils/contract_sources/contract_data/receive_function_contracts.py +5 -5
- web3/_utils/contract_sources/contract_data/reflector_contracts.py +3 -3
- web3/_utils/contract_sources/contract_data/revert_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/simple_resolver.py +3 -3
- web3/_utils/contract_sources/contract_data/storage_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/string_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/tuple_contracts.py +5 -5
- web3/_utils/decorators.py +14 -11
- web3/_utils/error_formatters_utils.py +17 -0
- web3/_utils/filters.py +39 -28
- web3/_utils/http_session_manager.py +18 -15
- web3/_utils/method_formatters.py +19 -24
- web3/_utils/module_testing/eth_module.py +107 -47
- web3/_utils/module_testing/web3_module.py +78 -4
- web3/_utils/validation.py +1 -1
- web3/contract/utils.py +20 -35
- web3/eth/async_eth.py +4 -0
- web3/eth/eth.py +15 -2
- web3/manager.py +105 -23
- web3/method.py +17 -9
- web3/providers/async_base.py +15 -1
- web3/providers/base.py +18 -5
- web3/providers/ipc.py +2 -4
- web3/providers/legacy_websocket.py +4 -5
- web3/providers/persistent/async_ipc.py +3 -1
- web3/providers/persistent/persistent.py +110 -40
- web3/providers/persistent/request_processor.py +34 -51
- web3/providers/persistent/subscription_manager.py +13 -7
- web3/providers/rpc/async_rpc.py +7 -7
- web3/providers/rpc/rpc.py +6 -6
- web3/utils/abi.py +1 -1
- web3/utils/subscriptions.py +7 -4
- {web3-7.11.0.dist-info → web3-7.12.0.dist-info}/METADATA +1 -1
- {web3-7.11.0.dist-info → web3-7.12.0.dist-info}/RECORD +58 -58
- {web3-7.11.0.dist-info → web3-7.12.0.dist-info}/WHEEL +1 -1
- {web3-7.11.0.dist-info → web3-7.12.0.dist-info}/licenses/LICENSE +0 -0
- {web3-7.11.0.dist-info → web3-7.12.0.dist-info}/top_level.txt +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Generated by `compile_contracts.py` script.
|
|
3
|
-
Compiled with Solidity v0.8.
|
|
3
|
+
Compiled with Solidity v0.8.30.
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
6
|
# source: web3/_utils/contract_sources/TupleContracts.sol:TupleContract
|
|
7
|
-
TUPLE_CONTRACT_BYTECODE = "
|
|
8
|
-
TUPLE_CONTRACT_RUNTIME = "
|
|
7
|
+
TUPLE_CONTRACT_BYTECODE = "0x6080604052348015600e575f5ffd5b50610a688061001c5f395ff3fe608060405234801561000f575f5ffd5b5060043610610029575f3560e01c80638e1ae3c71461002d575b5f5ffd5b6100476004803603810190610042919061064d565b61005d565b6040516100549190610a12565b60405180910390f35b61006561006d565b819050919050565b60405180606001604052805f815260200160608152602001606081525090565b5f604051905090565b5f5ffd5b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6100e8826100a2565b810181811067ffffffffffffffff82111715610107576101066100b2565b5b80604052505050565b5f61011961008d565b905061012582826100df565b919050565b5f5ffd5b5f819050919050565b6101408161012e565b811461014a575f5ffd5b50565b5f8135905061015b81610137565b92915050565b5f5ffd5b5f67ffffffffffffffff82111561017f5761017e6100b2565b5b602082029050602081019050919050565b5f5ffd5b5f6101a66101a184610165565b610110565b905080838252602082019050602084028301858111156101c9576101c8610190565b5b835b818110156101f257806101de888261014d565b8452602084019350506020810190506101cb565b5050509392505050565b5f82601f8301126102105761020f610161565b5b8135610220848260208601610194565b91505092915050565b5f67ffffffffffffffff821115610243576102426100b2565b5b602082029050602081019050919050565b5f819050919050565b61026681610254565b8114610270575f5ffd5b50565b5f813590506102818161025d565b92915050565b5f67ffffffffffffffff8211156102a1576102a06100b2565b5b602082029050919050565b5f8115159050919050565b6102c0816102ac565b81146102ca575f5ffd5b50565b5f813590506102db816102b7565b92915050565b5f6102f36102ee84610287565b610110565b9050806020840283018581111561030d5761030c610190565b5b835b81811015610336578061032288826102cd565b84526020840193505060208101905061030f565b5050509392505050565b5f82601f83011261035457610353610161565b5b60026103618482856102e1565b91505092915050565b5f67ffffffffffffffff821115610384576103836100b2565b5b602082029050602081019050919050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6103be82610395565b9050919050565b6103ce816103b4565b81146103d8575f5ffd5b50565b5f813590506103e9816103c5565b92915050565b5f6104016103fc8461036a565b610110565b9050808382526020820190506020840283018581111561042457610423610190565b5b835b8181101561044d578061043988826103db565b845260208401935050602081019050610426565b5050509392505050565b5f82601f83011261046b5761046a610161565b5b813561047b8482602086016103ef565b91505092915050565b5f608082840312156104995761049861009e565b5b6104a36060610110565b90505f6104b284828501610273565b5f8301525060206104c584828501610340565b602083015250606082013567ffffffffffffffff8111156104e9576104e861012a565b5b6104f584828501610457565b60408301525092915050565b5f61051361050e84610229565b610110565b9050808382526020820190506020840283018581111561053657610535610190565b5b835b8181101561057d57803567ffffffffffffffff81111561055b5761055a610161565b5b8086016105688982610484565b85526020850194505050602081019050610538565b5050509392505050565b5f82601f83011261059b5761059a610161565b5b81356105ab848260208601610501565b91505092915050565b5f606082840312156105c9576105c861009e565b5b6105d36060610110565b90505f6105e28482850161014d565b5f83015250602082013567ffffffffffffffff8111156106055761060461012a565b5b610611848285016101fc565b602083015250604082013567ffffffffffffffff8111156106355761063461012a565b5b61064184828501610587565b60408301525092915050565b5f6020828403121561066257610661610096565b5b5f82013567ffffffffffffffff81111561067f5761067e61009a565b5b61068b848285016105b4565b91505092915050565b61069d8161012e565b82525050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f6106d78383610694565b60208301905092915050565b5f602082019050919050565b5f6106f9826106a3565b61070381856106ad565b935061070e836106bd565b805f5b8381101561073e57815161072588826106cc565b9750610730836106e3565b925050600181019050610711565b5085935050505092915050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b61077d81610254565b82525050565b5f60029050919050565b5f81905092915050565b5f819050919050565b6107a9816102ac565b82525050565b5f6107ba83836107a0565b60208301905092915050565b5f602082019050919050565b6107db81610783565b6107e5818461078d565b92506107f082610797565b805f5b8381101561082057815161080787826107af565b9650610812836107c6565b9250506001810190506107f3565b505050505050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b61085a816103b4565b82525050565b5f61086b8383610851565b60208301905092915050565b5f602082019050919050565b5f61088d82610828565b6108978185610832565b93506108a283610842565b805f5b838110156108d25781516108b98882610860565b97506108c483610877565b9250506001810190506108a5565b5085935050505092915050565b5f608083015f8301516108f45f860182610774565b50602083015161090760208601826107d2565b506040830151848203606086015261091f8282610883565b9150508091505092915050565b5f61093783836108df565b905092915050565b5f602082019050919050565b5f6109558261074b565b61095f8185610755565b93508360208202850161097185610765565b805f5b858110156109ac578484038952815161098d858261092c565b94506109988361093f565b925060208a01995050600181019050610974565b50829750879550505050505092915050565b5f606083015f8301516109d35f860182610694565b50602083015184820360208601526109eb82826106ef565b91505060408301518482036040860152610a05828261094b565b9150508091505092915050565b5f6020820190508181035f830152610a2a81846109be565b90509291505056fea26469706673582212207c5620c2257d173ed894791417ffad7e98aad1aab11d2ec22b5148e5d77de0c464736f6c634300081e0033" # noqa: E501
|
|
8
|
+
TUPLE_CONTRACT_RUNTIME = "0x608060405234801561000f575f5ffd5b5060043610610029575f3560e01c80638e1ae3c71461002d575b5f5ffd5b6100476004803603810190610042919061064d565b61005d565b6040516100549190610a12565b60405180910390f35b61006561006d565b819050919050565b60405180606001604052805f815260200160608152602001606081525090565b5f604051905090565b5f5ffd5b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6100e8826100a2565b810181811067ffffffffffffffff82111715610107576101066100b2565b5b80604052505050565b5f61011961008d565b905061012582826100df565b919050565b5f5ffd5b5f819050919050565b6101408161012e565b811461014a575f5ffd5b50565b5f8135905061015b81610137565b92915050565b5f5ffd5b5f67ffffffffffffffff82111561017f5761017e6100b2565b5b602082029050602081019050919050565b5f5ffd5b5f6101a66101a184610165565b610110565b905080838252602082019050602084028301858111156101c9576101c8610190565b5b835b818110156101f257806101de888261014d565b8452602084019350506020810190506101cb565b5050509392505050565b5f82601f8301126102105761020f610161565b5b8135610220848260208601610194565b91505092915050565b5f67ffffffffffffffff821115610243576102426100b2565b5b602082029050602081019050919050565b5f819050919050565b61026681610254565b8114610270575f5ffd5b50565b5f813590506102818161025d565b92915050565b5f67ffffffffffffffff8211156102a1576102a06100b2565b5b602082029050919050565b5f8115159050919050565b6102c0816102ac565b81146102ca575f5ffd5b50565b5f813590506102db816102b7565b92915050565b5f6102f36102ee84610287565b610110565b9050806020840283018581111561030d5761030c610190565b5b835b81811015610336578061032288826102cd565b84526020840193505060208101905061030f565b5050509392505050565b5f82601f83011261035457610353610161565b5b60026103618482856102e1565b91505092915050565b5f67ffffffffffffffff821115610384576103836100b2565b5b602082029050602081019050919050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6103be82610395565b9050919050565b6103ce816103b4565b81146103d8575f5ffd5b50565b5f813590506103e9816103c5565b92915050565b5f6104016103fc8461036a565b610110565b9050808382526020820190506020840283018581111561042457610423610190565b5b835b8181101561044d578061043988826103db565b845260208401935050602081019050610426565b5050509392505050565b5f82601f83011261046b5761046a610161565b5b813561047b8482602086016103ef565b91505092915050565b5f608082840312156104995761049861009e565b5b6104a36060610110565b90505f6104b284828501610273565b5f8301525060206104c584828501610340565b602083015250606082013567ffffffffffffffff8111156104e9576104e861012a565b5b6104f584828501610457565b60408301525092915050565b5f61051361050e84610229565b610110565b9050808382526020820190506020840283018581111561053657610535610190565b5b835b8181101561057d57803567ffffffffffffffff81111561055b5761055a610161565b5b8086016105688982610484565b85526020850194505050602081019050610538565b5050509392505050565b5f82601f83011261059b5761059a610161565b5b81356105ab848260208601610501565b91505092915050565b5f606082840312156105c9576105c861009e565b5b6105d36060610110565b90505f6105e28482850161014d565b5f83015250602082013567ffffffffffffffff8111156106055761060461012a565b5b610611848285016101fc565b602083015250604082013567ffffffffffffffff8111156106355761063461012a565b5b61064184828501610587565b60408301525092915050565b5f6020828403121561066257610661610096565b5b5f82013567ffffffffffffffff81111561067f5761067e61009a565b5b61068b848285016105b4565b91505092915050565b61069d8161012e565b82525050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f6106d78383610694565b60208301905092915050565b5f602082019050919050565b5f6106f9826106a3565b61070381856106ad565b935061070e836106bd565b805f5b8381101561073e57815161072588826106cc565b9750610730836106e3565b925050600181019050610711565b5085935050505092915050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b61077d81610254565b82525050565b5f60029050919050565b5f81905092915050565b5f819050919050565b6107a9816102ac565b82525050565b5f6107ba83836107a0565b60208301905092915050565b5f602082019050919050565b6107db81610783565b6107e5818461078d565b92506107f082610797565b805f5b8381101561082057815161080787826107af565b9650610812836107c6565b9250506001810190506107f3565b505050505050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b61085a816103b4565b82525050565b5f61086b8383610851565b60208301905092915050565b5f602082019050919050565b5f61088d82610828565b6108978185610832565b93506108a283610842565b805f5b838110156108d25781516108b98882610860565b97506108c483610877565b9250506001810190506108a5565b5085935050505092915050565b5f608083015f8301516108f45f860182610774565b50602083015161090760208601826107d2565b506040830151848203606086015261091f8282610883565b9150508091505092915050565b5f61093783836108df565b905092915050565b5f602082019050919050565b5f6109558261074b565b61095f8185610755565b93508360208202850161097185610765565b805f5b858110156109ac578484038952815161098d858261092c565b94506109988361093f565b925060208a01995050600181019050610974565b50829750879550505050505092915050565b5f606083015f8301516109d35f860182610694565b50602083015184820360208601526109eb82826106ef565b91505060408301518482036040860152610a05828261094b565b9150508091505092915050565b5f6020820190508181035f830152610a2a81846109be565b90509291505056fea26469706673582212207c5620c2257d173ed894791417ffad7e98aad1aab11d2ec22b5148e5d77de0c464736f6c634300081e0033" # noqa: E501
|
|
9
9
|
TUPLE_CONTRACT_ABI = [
|
|
10
10
|
{
|
|
11
11
|
"inputs": [
|
|
@@ -71,8 +71,8 @@ TUPLE_CONTRACT_DATA = {
|
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
# source: web3/_utils/contract_sources/TupleContracts.sol:NestedTupleContract
|
|
74
|
-
NESTED_TUPLE_CONTRACT_BYTECODE = "
|
|
75
|
-
NESTED_TUPLE_CONTRACT_RUNTIME = "
|
|
74
|
+
NESTED_TUPLE_CONTRACT_BYTECODE = "0x6080604052348015600e575f5ffd5b5061067b8061001c5f395ff3fe608060405234801561000f575f5ffd5b5060043610610029575f3560e01c80632655aef11461002d575b5f5ffd5b610047600480360381019061004291906103f1565b61005d565b6040516100549190610625565b60405180910390f35b61006561006d565b819050919050565b6040518060200160405280606081525090565b5f604051905090565b5f5ffd5b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6100db82610095565b810181811067ffffffffffffffff821117156100fa576100f96100a5565b5b80604052505050565b5f61010c610080565b905061011882826100d2565b919050565b5f5ffd5b5f5ffd5b5f67ffffffffffffffff82111561013f5761013e6100a5565b5b602082029050602081019050919050565b5f5ffd5b5f67ffffffffffffffff82111561016e5761016d6100a5565b5b602082029050602081019050919050565b5f819050919050565b6101918161017f565b811461019b575f5ffd5b50565b5f813590506101ac81610188565b92915050565b5f604082840312156101c7576101c6610091565b5b6101d16040610103565b90505f6101e08482850161019e565b5f8301525060206101f38482850161019e565b60208301525092915050565b5f61021161020c84610154565b610103565b9050808382526020820190506040840283018581111561023457610233610150565b5b835b8181101561025d578061024988826101b2565b845260208401935050604081019050610236565b5050509392505050565b5f82601f83011261027b5761027a610121565b5b813561028b8482602086016101ff565b91505092915050565b5f602082840312156102a9576102a8610091565b5b6102b36020610103565b90505f82013567ffffffffffffffff8111156102d2576102d161011d565b5b6102de84828501610267565b5f8301525092915050565b5f6102fb6102f684610125565b610103565b9050808382526020820190506020840283018581111561031e5761031d610150565b5b835b8181101561036557803567ffffffffffffffff81111561034357610342610121565b5b8086016103508982610294565b85526020850194505050602081019050610320565b5050509392505050565b5f82601f83011261038357610382610121565b5b81356103938482602086016102e9565b91505092915050565b5f602082840312156103b1576103b0610091565b5b6103bb6020610103565b90505f82013567ffffffffffffffff8111156103da576103d961011d565b5b6103e68482850161036f565b5f8301525092915050565b5f6020828403121561040657610405610089565b5b5f82013567ffffffffffffffff8111156104235761042261008d565b5b61042f8482850161039c565b91505092915050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b6104938161017f565b82525050565b604082015f8201516104ad5f85018261048a565b5060208201516104c0602085018261048a565b50505050565b5f6104d18383610499565b60408301905092915050565b5f602082019050919050565b5f6104f382610461565b6104fd818561046b565b93506105088361047b565b805f5b8381101561053857815161051f88826104c6565b975061052a836104dd565b92505060018101905061050b565b5085935050505092915050565b5f602083015f8301518482035f86015261055f82826104e9565b9150508091505092915050565b5f6105778383610545565b905092915050565b5f602082019050919050565b5f61059582610438565b61059f8185610442565b9350836020820285016105b185610452565b805f5b858110156105ec57848403895281516105cd858261056c565b94506105d88361057f565b925060208a019950506001810190506105b4565b50829750879550505050505092915050565b5f602083015f8301518482035f860152610618828261058b565b9150508091505092915050565b5f6020820190508181035f83015261063d81846105fe565b90509291505056fea2646970667358221220e9a46dd271224211ac317ab5deb76259a8309e527c859b3d977cfc261a3780db64736f6c634300081e0033" # noqa: E501
|
|
75
|
+
NESTED_TUPLE_CONTRACT_RUNTIME = "0x608060405234801561000f575f5ffd5b5060043610610029575f3560e01c80632655aef11461002d575b5f5ffd5b610047600480360381019061004291906103f1565b61005d565b6040516100549190610625565b60405180910390f35b61006561006d565b819050919050565b6040518060200160405280606081525090565b5f604051905090565b5f5ffd5b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6100db82610095565b810181811067ffffffffffffffff821117156100fa576100f96100a5565b5b80604052505050565b5f61010c610080565b905061011882826100d2565b919050565b5f5ffd5b5f5ffd5b5f67ffffffffffffffff82111561013f5761013e6100a5565b5b602082029050602081019050919050565b5f5ffd5b5f67ffffffffffffffff82111561016e5761016d6100a5565b5b602082029050602081019050919050565b5f819050919050565b6101918161017f565b811461019b575f5ffd5b50565b5f813590506101ac81610188565b92915050565b5f604082840312156101c7576101c6610091565b5b6101d16040610103565b90505f6101e08482850161019e565b5f8301525060206101f38482850161019e565b60208301525092915050565b5f61021161020c84610154565b610103565b9050808382526020820190506040840283018581111561023457610233610150565b5b835b8181101561025d578061024988826101b2565b845260208401935050604081019050610236565b5050509392505050565b5f82601f83011261027b5761027a610121565b5b813561028b8482602086016101ff565b91505092915050565b5f602082840312156102a9576102a8610091565b5b6102b36020610103565b90505f82013567ffffffffffffffff8111156102d2576102d161011d565b5b6102de84828501610267565b5f8301525092915050565b5f6102fb6102f684610125565b610103565b9050808382526020820190506020840283018581111561031e5761031d610150565b5b835b8181101561036557803567ffffffffffffffff81111561034357610342610121565b5b8086016103508982610294565b85526020850194505050602081019050610320565b5050509392505050565b5f82601f83011261038357610382610121565b5b81356103938482602086016102e9565b91505092915050565b5f602082840312156103b1576103b0610091565b5b6103bb6020610103565b90505f82013567ffffffffffffffff8111156103da576103d961011d565b5b6103e68482850161036f565b5f8301525092915050565b5f6020828403121561040657610405610089565b5b5f82013567ffffffffffffffff8111156104235761042261008d565b5b61042f8482850161039c565b91505092915050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b6104938161017f565b82525050565b604082015f8201516104ad5f85018261048a565b5060208201516104c0602085018261048a565b50505050565b5f6104d18383610499565b60408301905092915050565b5f602082019050919050565b5f6104f382610461565b6104fd818561046b565b93506105088361047b565b805f5b8381101561053857815161051f88826104c6565b975061052a836104dd565b92505060018101905061050b565b5085935050505092915050565b5f602083015f8301518482035f86015261055f82826104e9565b9150508091505092915050565b5f6105778383610545565b905092915050565b5f602082019050919050565b5f61059582610438565b61059f8185610442565b9350836020820285016105b185610452565b805f5b858110156105ec57848403895281516105cd858261056c565b94506105d88361057f565b925060208a019950506001810190506105b4565b50829750879550505050505092915050565b5f602083015f8301518482035f860152610618828261058b565b9150508091505092915050565b5f6020820190508181035f83015261063d81846105fe565b90509291505056fea2646970667358221220e9a46dd271224211ac317ab5deb76259a8309e527c859b3d977cfc261a3780db64736f6c634300081e0033" # noqa: E501
|
|
76
76
|
NESTED_TUPLE_CONTRACT_ABI = [
|
|
77
77
|
{
|
|
78
78
|
"inputs": [
|
web3/_utils/decorators.py
CHANGED
|
@@ -3,6 +3,8 @@ import threading
|
|
|
3
3
|
from typing import (
|
|
4
4
|
Any,
|
|
5
5
|
Callable,
|
|
6
|
+
Set,
|
|
7
|
+
Tuple,
|
|
6
8
|
TypeVar,
|
|
7
9
|
cast,
|
|
8
10
|
)
|
|
@@ -20,21 +22,22 @@ def reject_recursive_repeats(to_wrap: Callable[..., Any]) -> Callable[..., Any]:
|
|
|
20
22
|
Prevent simple cycles by returning None when called recursively with same instance
|
|
21
23
|
"""
|
|
22
24
|
# types ignored b/c dynamically set attribute
|
|
23
|
-
|
|
25
|
+
already_called: Set[Tuple[int, ...]] = set()
|
|
26
|
+
to_wrap.__already_called = already_called # type: ignore
|
|
27
|
+
|
|
28
|
+
add_call = already_called.add
|
|
29
|
+
remove_call = already_called.remove
|
|
24
30
|
|
|
25
31
|
@functools.wraps(to_wrap)
|
|
26
32
|
def wrapped(*args: Any) -> Any:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
thread_local_args = (thread_id,) + arg_instances
|
|
30
|
-
if thread_local_args in to_wrap.__already_called: # type: ignore
|
|
33
|
+
thread_local_args = (threading.get_ident(), *map(id, args))
|
|
34
|
+
if thread_local_args in already_called:
|
|
31
35
|
raise Web3ValueError(f"Recursively called {to_wrap} with {args!r}")
|
|
32
|
-
|
|
36
|
+
add_call(thread_local_args)
|
|
33
37
|
try:
|
|
34
|
-
|
|
38
|
+
return to_wrap(*args)
|
|
35
39
|
finally:
|
|
36
|
-
|
|
37
|
-
return wrapped_val
|
|
40
|
+
remove_call(thread_local_args)
|
|
38
41
|
|
|
39
42
|
return wrapped
|
|
40
43
|
|
|
@@ -43,7 +46,7 @@ def deprecated_for(replace_message: str) -> Callable[..., Any]:
|
|
|
43
46
|
"""
|
|
44
47
|
Decorate a deprecated function, with info about what to use instead, like:
|
|
45
48
|
|
|
46
|
-
@deprecated_for("to_bytes()")
|
|
49
|
+
@deprecated_for("use to_bytes() instead")
|
|
47
50
|
def toAscii(arg):
|
|
48
51
|
...
|
|
49
52
|
"""
|
|
@@ -52,7 +55,7 @@ def deprecated_for(replace_message: str) -> Callable[..., Any]:
|
|
|
52
55
|
@functools.wraps(to_wrap)
|
|
53
56
|
def wrapper(*args: Any, **kwargs: Any) -> Callable[..., Any]:
|
|
54
57
|
warnings.warn(
|
|
55
|
-
f"{to_wrap.__name__} is deprecated
|
|
58
|
+
f"{to_wrap.__name__} is deprecated: {replace_message}",
|
|
56
59
|
category=DeprecationWarning,
|
|
57
60
|
stacklevel=2,
|
|
58
61
|
)
|
|
@@ -8,6 +8,7 @@ from eth_utils import (
|
|
|
8
8
|
)
|
|
9
9
|
|
|
10
10
|
from web3.exceptions import (
|
|
11
|
+
BlockNotFound,
|
|
11
12
|
ContractCustomError,
|
|
12
13
|
ContractLogicError,
|
|
13
14
|
ContractPanicError,
|
|
@@ -185,3 +186,19 @@ def raise_transaction_indexing_error_if_indexing(response: RPCResponse) -> RPCRe
|
|
|
185
186
|
raise TransactionIndexingInProgress(message)
|
|
186
187
|
|
|
187
188
|
return response
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def raise_block_not_found_on_error(response: RPCResponse) -> RPCResponse:
|
|
192
|
+
"""
|
|
193
|
+
Raise ``BlockNotFound`` on specific error message(s).
|
|
194
|
+
"""
|
|
195
|
+
error = response.get("error")
|
|
196
|
+
if not isinstance(error, str) and error is not None:
|
|
197
|
+
message = error.get("message")
|
|
198
|
+
if message is not None:
|
|
199
|
+
if "not found" in message.lower() and any(
|
|
200
|
+
key in message.lower() for key in ("block", "header")
|
|
201
|
+
):
|
|
202
|
+
raise BlockNotFound(message)
|
|
203
|
+
|
|
204
|
+
return response
|
web3/_utils/filters.py
CHANGED
|
@@ -8,6 +8,7 @@ from typing import (
|
|
|
8
8
|
List,
|
|
9
9
|
Optional,
|
|
10
10
|
Sequence,
|
|
11
|
+
Set,
|
|
11
12
|
Tuple,
|
|
12
13
|
Union,
|
|
13
14
|
)
|
|
@@ -26,7 +27,6 @@ from eth_typing import (
|
|
|
26
27
|
)
|
|
27
28
|
from eth_utils import (
|
|
28
29
|
is_hex,
|
|
29
|
-
is_list_like,
|
|
30
30
|
is_string,
|
|
31
31
|
is_text,
|
|
32
32
|
)
|
|
@@ -67,15 +67,48 @@ if TYPE_CHECKING:
|
|
|
67
67
|
from web3.eth import Eth # noqa: F401
|
|
68
68
|
|
|
69
69
|
|
|
70
|
+
def _sanitize_addresses(
|
|
71
|
+
*address: Union[ChecksumAddress, List[ChecksumAddress]],
|
|
72
|
+
) -> Union[ChecksumAddress, List[ChecksumAddress]]:
|
|
73
|
+
"""
|
|
74
|
+
Validates an address or list of addresses and returns a single
|
|
75
|
+
ChecksumAddress or a list of ChecksumAddresses.
|
|
76
|
+
Raises Web3ValueError if the address is not valid.
|
|
77
|
+
|
|
78
|
+
:param address: A single address or a list of addresses.
|
|
79
|
+
:return: A list of ChecksumAddress.
|
|
80
|
+
"""
|
|
81
|
+
address_set: Set[ChecksumAddress] = set()
|
|
82
|
+
for arg in address:
|
|
83
|
+
if not arg:
|
|
84
|
+
continue
|
|
85
|
+
elif isinstance(arg, str) or isinstance(arg, bytes):
|
|
86
|
+
address_set.add(arg)
|
|
87
|
+
elif isinstance(arg, list):
|
|
88
|
+
address_set.update(arg)
|
|
89
|
+
else:
|
|
90
|
+
raise Web3ValueError(
|
|
91
|
+
f"Unsupported type for `address` parameter: {type(address)}"
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
if not address_set:
|
|
95
|
+
return []
|
|
96
|
+
else:
|
|
97
|
+
for addr in address_set:
|
|
98
|
+
validate_address(addr)
|
|
99
|
+
|
|
100
|
+
return list(address_set) if len(address_set) > 1 else address_set.pop()
|
|
101
|
+
|
|
102
|
+
|
|
70
103
|
def construct_event_filter_params(
|
|
71
104
|
event_abi: ABIEvent,
|
|
72
105
|
abi_codec: ABICodec,
|
|
73
|
-
contract_address: Optional[ChecksumAddress] = None,
|
|
106
|
+
contract_address: Optional[Union[ChecksumAddress, List[ChecksumAddress]]] = None,
|
|
74
107
|
argument_filters: Optional[Dict[str, Any]] = None,
|
|
75
108
|
topics: Optional[Sequence[HexStr]] = None,
|
|
76
109
|
from_block: Optional[BlockIdentifier] = None,
|
|
77
110
|
to_block: Optional[BlockIdentifier] = None,
|
|
78
|
-
address: Optional[ChecksumAddress] = None,
|
|
111
|
+
address: Optional[Union[ChecksumAddress, List[ChecksumAddress]]] = None,
|
|
79
112
|
) -> Tuple[List[List[Optional[HexStr]]], FilterParams]:
|
|
80
113
|
filter_params: FilterParams = {}
|
|
81
114
|
topic_set: Sequence[HexStr] = construct_event_topic_set(
|
|
@@ -92,31 +125,9 @@ def construct_event_filter_params(
|
|
|
92
125
|
|
|
93
126
|
filter_params["topics"] = topic_set
|
|
94
127
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
elif is_string(address):
|
|
99
|
-
filter_params["address"] = (
|
|
100
|
-
[address, contract_address]
|
|
101
|
-
if address != contract_address
|
|
102
|
-
else [address]
|
|
103
|
-
)
|
|
104
|
-
else:
|
|
105
|
-
raise Web3ValueError(
|
|
106
|
-
f"Unsupported type for `address` parameter: {type(address)}"
|
|
107
|
-
)
|
|
108
|
-
elif address:
|
|
109
|
-
filter_params["address"] = address
|
|
110
|
-
elif contract_address:
|
|
111
|
-
filter_params["address"] = contract_address
|
|
112
|
-
|
|
113
|
-
if "address" not in filter_params:
|
|
114
|
-
pass
|
|
115
|
-
elif is_list_like(filter_params["address"]):
|
|
116
|
-
for addr in filter_params["address"]:
|
|
117
|
-
validate_address(addr)
|
|
118
|
-
else:
|
|
119
|
-
validate_address(filter_params["address"])
|
|
128
|
+
sanitized_addresses = _sanitize_addresses(address, contract_address)
|
|
129
|
+
if sanitized_addresses:
|
|
130
|
+
filter_params["address"] = sanitized_addresses
|
|
120
131
|
|
|
121
132
|
if from_block is not None:
|
|
122
133
|
filter_params["fromBlock"] = from_block
|
|
@@ -81,14 +81,14 @@ class HTTPSessionManager:
|
|
|
81
81
|
|
|
82
82
|
with self._lock:
|
|
83
83
|
cached_session, evicted_items = self.session_cache.cache(cache_key, session)
|
|
84
|
-
self.logger.debug(
|
|
84
|
+
self.logger.debug("Session cached: %s, %s", endpoint_uri, cached_session)
|
|
85
85
|
|
|
86
86
|
if evicted_items is not None:
|
|
87
87
|
evicted_sessions = evicted_items.values()
|
|
88
88
|
for evicted_session in evicted_sessions:
|
|
89
89
|
self.logger.debug(
|
|
90
|
-
"Session cache full. Session evicted from cache: "
|
|
91
|
-
|
|
90
|
+
"Session cache full. Session evicted from cache: %s",
|
|
91
|
+
evicted_session,
|
|
92
92
|
)
|
|
93
93
|
threading.Timer(
|
|
94
94
|
# If `request_timeout` is `None`, don't wait forever for the closing
|
|
@@ -167,7 +167,7 @@ class HTTPSessionManager:
|
|
|
167
167
|
def _close_evicted_sessions(self, evicted_sessions: List[requests.Session]) -> None:
|
|
168
168
|
for evicted_session in evicted_sessions:
|
|
169
169
|
evicted_session.close()
|
|
170
|
-
self.logger.debug(
|
|
170
|
+
self.logger.debug("Closed evicted session: %s", evicted_session)
|
|
171
171
|
|
|
172
172
|
# -- async -- #
|
|
173
173
|
|
|
@@ -178,7 +178,7 @@ class HTTPSessionManager:
|
|
|
178
178
|
request_timeout: Optional[ClientTimeout] = None,
|
|
179
179
|
) -> ClientSession:
|
|
180
180
|
# cache key should have a unique thread identifier
|
|
181
|
-
cache_key = generate_cache_key(f"{
|
|
181
|
+
cache_key = generate_cache_key(f"{id(asyncio.get_event_loop())}:{endpoint_uri}")
|
|
182
182
|
|
|
183
183
|
evicted_items = None
|
|
184
184
|
async with async_lock(self.session_pool, self._lock):
|
|
@@ -195,7 +195,7 @@ class HTTPSessionManager:
|
|
|
195
195
|
cache_key, session
|
|
196
196
|
)
|
|
197
197
|
self.logger.debug(
|
|
198
|
-
|
|
198
|
+
"Async session cached: %s, %s", endpoint_uri, cached_session
|
|
199
199
|
)
|
|
200
200
|
|
|
201
201
|
else:
|
|
@@ -215,8 +215,10 @@ class HTTPSessionManager:
|
|
|
215
215
|
)
|
|
216
216
|
if warning:
|
|
217
217
|
self.logger.debug(
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
"%s: %s, %s. Creating and caching a new async session for uri.",
|
|
219
|
+
warning,
|
|
220
|
+
endpoint_uri,
|
|
221
|
+
cached_session,
|
|
220
222
|
)
|
|
221
223
|
|
|
222
224
|
self.session_cache._data.pop(cache_key)
|
|
@@ -224,7 +226,8 @@ class HTTPSessionManager:
|
|
|
224
226
|
# if loop was closed but not the session, close the session
|
|
225
227
|
await cached_session.close()
|
|
226
228
|
self.logger.debug(
|
|
227
|
-
|
|
229
|
+
"Async session closed and evicted from cache: %s",
|
|
230
|
+
cached_session,
|
|
228
231
|
)
|
|
229
232
|
|
|
230
233
|
# replace stale session with a new session at the cache key
|
|
@@ -238,7 +241,7 @@ class HTTPSessionManager:
|
|
|
238
241
|
cache_key, _session
|
|
239
242
|
)
|
|
240
243
|
self.logger.debug(
|
|
241
|
-
|
|
244
|
+
"Async session cached: %s, %s", endpoint_uri, cached_session
|
|
242
245
|
)
|
|
243
246
|
|
|
244
247
|
if evicted_items is not None:
|
|
@@ -248,8 +251,8 @@ class HTTPSessionManager:
|
|
|
248
251
|
evicted_sessions = list(evicted_items.values())
|
|
249
252
|
for evicted_session in evicted_sessions:
|
|
250
253
|
self.logger.debug(
|
|
251
|
-
"Async session cache full. Session evicted from cache: "
|
|
252
|
-
|
|
254
|
+
"Async session cache full. Session evicted from cache: %s",
|
|
255
|
+
evicted_session,
|
|
253
256
|
)
|
|
254
257
|
# Kick off an asyncio `Task` to close the evicted sessions. In the case
|
|
255
258
|
# that the cache filled very quickly and some sessions have been evicted
|
|
@@ -323,10 +326,10 @@ class HTTPSessionManager:
|
|
|
323
326
|
|
|
324
327
|
for evicted_session in evicted_sessions:
|
|
325
328
|
await evicted_session.close()
|
|
326
|
-
self.logger.debug(
|
|
329
|
+
self.logger.debug("Closed evicted async session: %s", evicted_session)
|
|
327
330
|
|
|
328
331
|
if any(not evicted_session.closed for evicted_session in evicted_sessions):
|
|
329
332
|
self.logger.warning(
|
|
330
|
-
"Some evicted async sessions were not properly closed: "
|
|
331
|
-
|
|
333
|
+
"Some evicted async sessions were not properly closed: %s",
|
|
334
|
+
evicted_sessions,
|
|
332
335
|
)
|
web3/_utils/method_formatters.py
CHANGED
|
@@ -55,6 +55,7 @@ from web3._utils.abi import (
|
|
|
55
55
|
is_length,
|
|
56
56
|
)
|
|
57
57
|
from web3._utils.error_formatters_utils import (
|
|
58
|
+
raise_block_not_found_on_error,
|
|
58
59
|
raise_contract_logic_error_on_revert,
|
|
59
60
|
raise_transaction_indexing_error_if_indexing,
|
|
60
61
|
)
|
|
@@ -104,6 +105,7 @@ from web3.types import (
|
|
|
104
105
|
BlockIdentifier,
|
|
105
106
|
Formatters,
|
|
106
107
|
RPCEndpoint,
|
|
108
|
+
RPCResponse,
|
|
107
109
|
SimulateV1Payload,
|
|
108
110
|
StateOverrideParams,
|
|
109
111
|
TReturn,
|
|
@@ -649,19 +651,15 @@ simulate_v1_request_formatter: Callable[
|
|
|
649
651
|
)
|
|
650
652
|
|
|
651
653
|
block_result_formatters_copy = BLOCK_RESULT_FORMATTERS.copy()
|
|
652
|
-
block_result_formatters_copy
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
}
|
|
662
|
-
)
|
|
663
|
-
)
|
|
664
|
-
}
|
|
654
|
+
block_result_formatters_copy["calls"] = apply_list_to_array_formatter(
|
|
655
|
+
type_aware_apply_formatters_to_dict(
|
|
656
|
+
{
|
|
657
|
+
"returnData": HexBytes,
|
|
658
|
+
"logs": apply_list_to_array_formatter(log_entry_formatter),
|
|
659
|
+
"gasUsed": to_integer_if_hex,
|
|
660
|
+
"status": to_integer_if_hex,
|
|
661
|
+
}
|
|
662
|
+
)
|
|
665
663
|
)
|
|
666
664
|
simulate_v1_result_formatter = apply_formatter_if(
|
|
667
665
|
is_not_null,
|
|
@@ -1092,6 +1090,7 @@ ERROR_FORMATTERS: Dict[RPCEndpoint, Callable[..., Any]] = {
|
|
|
1092
1090
|
RPC.eth_estimateGas: raise_contract_logic_error_on_revert,
|
|
1093
1091
|
RPC.eth_call: raise_contract_logic_error_on_revert,
|
|
1094
1092
|
RPC.eth_getTransactionReceipt: raise_transaction_indexing_error_if_indexing,
|
|
1093
|
+
RPC.eth_getBlockReceipts: raise_block_not_found_on_error,
|
|
1095
1094
|
}
|
|
1096
1095
|
|
|
1097
1096
|
|
|
@@ -1105,9 +1104,7 @@ def combine_formatters(
|
|
|
1105
1104
|
yield formatter_map[method_name]
|
|
1106
1105
|
|
|
1107
1106
|
|
|
1108
|
-
def get_request_formatters(
|
|
1109
|
-
method_name: Union[RPCEndpoint, Callable[..., RPCEndpoint]],
|
|
1110
|
-
) -> Dict[str, Callable[..., Any]]:
|
|
1107
|
+
def get_request_formatters(method_name: RPCEndpoint) -> Callable[[RPCResponse], Any]:
|
|
1111
1108
|
request_formatter_maps = (
|
|
1112
1109
|
ABI_REQUEST_FORMATTERS,
|
|
1113
1110
|
# METHOD_NORMALIZERS needs to be after ABI_REQUEST_FORMATTERS
|
|
@@ -1239,7 +1236,7 @@ FILTER_RESULT_FORMATTERS: Dict[RPCEndpoint, Callable[..., Any]] = {
|
|
|
1239
1236
|
|
|
1240
1237
|
@to_tuple
|
|
1241
1238
|
def apply_module_to_formatters(
|
|
1242
|
-
formatters:
|
|
1239
|
+
formatters: Iterable[Callable[..., TReturn]],
|
|
1243
1240
|
module: "Module",
|
|
1244
1241
|
method_name: Union[RPCEndpoint, Callable[..., RPCEndpoint]],
|
|
1245
1242
|
) -> Iterable[Callable[..., TReturn]]:
|
|
@@ -1248,9 +1245,9 @@ def apply_module_to_formatters(
|
|
|
1248
1245
|
|
|
1249
1246
|
|
|
1250
1247
|
def get_result_formatters(
|
|
1251
|
-
method_name:
|
|
1248
|
+
method_name: RPCEndpoint,
|
|
1252
1249
|
module: "Module",
|
|
1253
|
-
) ->
|
|
1250
|
+
) -> Callable[[RPCResponse], Any]:
|
|
1254
1251
|
formatters = combine_formatters((PYTHONIC_RESULT_FORMATTERS,), method_name)
|
|
1255
1252
|
formatters_requiring_module = combine_formatters(
|
|
1256
1253
|
(FILTER_RESULT_FORMATTERS,), method_name
|
|
@@ -1261,9 +1258,7 @@ def get_result_formatters(
|
|
|
1261
1258
|
return compose(*partial_formatters, *formatters)
|
|
1262
1259
|
|
|
1263
1260
|
|
|
1264
|
-
def get_error_formatters(
|
|
1265
|
-
method_name: Union[RPCEndpoint, Callable[..., RPCEndpoint]],
|
|
1266
|
-
) -> Callable[..., Any]:
|
|
1261
|
+
def get_error_formatters(method_name: RPCEndpoint) -> Callable[[RPCResponse], Any]:
|
|
1267
1262
|
# Note error formatters work on the full response dict
|
|
1268
1263
|
error_formatter_maps = (ERROR_FORMATTERS,)
|
|
1269
1264
|
formatters = combine_formatters(error_formatter_maps, method_name)
|
|
@@ -1272,8 +1267,8 @@ def get_error_formatters(
|
|
|
1272
1267
|
|
|
1273
1268
|
|
|
1274
1269
|
def get_null_result_formatters(
|
|
1275
|
-
method_name:
|
|
1276
|
-
) -> Callable[
|
|
1270
|
+
method_name: RPCEndpoint,
|
|
1271
|
+
) -> Callable[[RPCResponse], Any]:
|
|
1277
1272
|
formatters = combine_formatters((NULL_RESULT_FORMATTERS,), method_name)
|
|
1278
1273
|
|
|
1279
1274
|
return compose(*formatters)
|