web3 7.3.1__py3-none-any.whl → 7.5.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/caching/caching_utils.py +125 -24
- web3/_utils/caching/request_caching_validation.py +204 -47
- 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 +5 -5
- 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/method_formatters.py +108 -1
- web3/_utils/module_testing/__init__.py +4 -0
- web3/_utils/module_testing/eth_module.py +3 -3
- web3/_utils/module_testing/go_ethereum_debug_module.py +128 -0
- web3/_utils/module_testing/module_testing_utils.py +3 -3
- web3/_utils/module_testing/utils.py +11 -3
- web3/_utils/rpc_abi.py +3 -0
- web3/contract/async_contract.py +45 -2
- web3/contract/base_contract.py +248 -63
- web3/contract/contract.py +41 -0
- web3/contract/utils.py +48 -0
- web3/geth.py +59 -0
- web3/main.py +4 -0
- web3/manager.py +10 -0
- web3/providers/async_base.py +7 -4
- web3/providers/base.py +7 -4
- web3/providers/ipc.py +4 -0
- web3/types.py +87 -2
- web3/utils/async_exception_handling.py +2 -5
- web3/utils/exception_handling.py +2 -7
- {web3-7.3.1.dist-info → web3-7.5.0.dist-info}/METADATA +2 -1
- {web3-7.3.1.dist-info → web3-7.5.0.dist-info}/RECORD +48 -47
- {web3-7.3.1.dist-info → web3-7.5.0.dist-info}/WHEEL +1 -1
- {web3-7.3.1.dist-info → web3-7.5.0.dist-info}/LICENSE +0 -0
- {web3-7.3.1.dist-info → web3-7.5.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.28.
|
|
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 = "0x6080604052348015600e575f5ffd5b50610a688061001c5f395ff3fe608060405234801561000f575f5ffd5b5060043610610029575f3560e01c80638e1ae3c71461002d575b5f5ffd5b6100476004803603810190610042919061064d565b61005d565b6040516100549190610a12565b60405180910390f35b61006561006d565b819050919050565b60405180606001604052805f815260200160608152602001606081525090565b5f604051905090565b5f5ffd5b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6100e8826100a2565b810181811067ffffffffffffffff82111715610107576101066100b2565b5b80604052505050565b5f61011961008d565b905061012582826100df565b919050565b5f5ffd5b5f819050919050565b6101408161012e565b811461014a575f5ffd5b50565b5f8135905061015b81610137565b92915050565b5f5ffd5b5f67ffffffffffffffff82111561017f5761017e6100b2565b5b602082029050602081019050919050565b5f5ffd5b5f6101a66101a184610165565b610110565b905080838252602082019050602084028301858111156101c9576101c8610190565b5b835b818110156101f257806101de888261014d565b8452602084019350506020810190506101cb565b5050509392505050565b5f82601f8301126102105761020f610161565b5b8135610220848260208601610194565b91505092915050565b5f67ffffffffffffffff821115610243576102426100b2565b5b602082029050602081019050919050565b5f819050919050565b61026681610254565b8114610270575f5ffd5b50565b5f813590506102818161025d565b92915050565b5f67ffffffffffffffff8211156102a1576102a06100b2565b5b602082029050919050565b5f8115159050919050565b6102c0816102ac565b81146102ca575f5ffd5b50565b5f813590506102db816102b7565b92915050565b5f6102f36102ee84610287565b610110565b9050806020840283018581111561030d5761030c610190565b5b835b81811015610336578061032288826102cd565b84526020840193505060208101905061030f565b5050509392505050565b5f82601f83011261035457610353610161565b5b60026103618482856102e1565b91505092915050565b5f67ffffffffffffffff821115610384576103836100b2565b5b602082029050602081019050919050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6103be82610395565b9050919050565b6103ce816103b4565b81146103d8575f5ffd5b50565b5f813590506103e9816103c5565b92915050565b5f6104016103fc8461036a565b610110565b9050808382526020820190506020840283018581111561042457610423610190565b5b835b8181101561044d578061043988826103db565b845260208401935050602081019050610426565b5050509392505050565b5f82601f83011261046b5761046a610161565b5b813561047b8482602086016103ef565b91505092915050565b5f608082840312156104995761049861009e565b5b6104a36060610110565b90505f6104b284828501610273565b5f8301525060206104c584828501610340565b602083015250606082013567ffffffffffffffff8111156104e9576104e861012a565b5b6104f584828501610457565b60408301525092915050565b5f61051361050e84610229565b610110565b9050808382526020820190506020840283018581111561053657610535610190565b5b835b8181101561057d57803567ffffffffffffffff81111561055b5761055a610161565b5b8086016105688982610484565b85526020850194505050602081019050610538565b5050509392505050565b5f82601f83011261059b5761059a610161565b5b81356105ab848260208601610501565b91505092915050565b5f606082840312156105c9576105c861009e565b5b6105d36060610110565b90505f6105e28482850161014d565b5f83015250602082013567ffffffffffffffff8111156106055761060461012a565b5b610611848285016101fc565b602083015250604082013567ffffffffffffffff8111156106355761063461012a565b5b61064184828501610587565b60408301525092915050565b5f6020828403121561066257610661610096565b5b5f82013567ffffffffffffffff81111561067f5761067e61009a565b5b61068b848285016105b4565b91505092915050565b61069d8161012e565b82525050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f6106d78383610694565b60208301905092915050565b5f602082019050919050565b5f6106f9826106a3565b61070381856106ad565b935061070e836106bd565b805f5b8381101561073e57815161072588826106cc565b9750610730836106e3565b925050600181019050610711565b5085935050505092915050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b61077d81610254565b82525050565b5f60029050919050565b5f81905092915050565b5f819050919050565b6107a9816102ac565b82525050565b5f6107ba83836107a0565b60208301905092915050565b5f602082019050919050565b6107db81610783565b6107e5818461078d565b92506107f082610797565b805f5b8381101561082057815161080787826107af565b9650610812836107c6565b9250506001810190506107f3565b505050505050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b61085a816103b4565b82525050565b5f61086b8383610851565b60208301905092915050565b5f602082019050919050565b5f61088d82610828565b6108978185610832565b93506108a283610842565b805f5b838110156108d25781516108b98882610860565b97506108c483610877565b9250506001810190506108a5565b5085935050505092915050565b5f608083015f8301516108f45f860182610774565b50602083015161090760208601826107d2565b506040830151848203606086015261091f8282610883565b9150508091505092915050565b5f61093783836108df565b905092915050565b5f602082019050919050565b5f6109558261074b565b61095f8185610755565b93508360208202850161097185610765565b805f5b858110156109ac578484038952815161098d858261092c565b94506109988361093f565b925060208a01995050600181019050610974565b50829750879550505050505092915050565b5f606083015f8301516109d35f860182610694565b50602083015184820360208601526109eb82826106ef565b91505060408301518482036040860152610a05828261094b565b9150508091505092915050565b5f6020820190508181035f830152610a2a81846109be565b90509291505056fea2646970667358221220688d7c1933bc8458c33b311fef8cd1eabb9fad171f74729d08c558a805acaafb64736f6c634300081c0033" # noqa: E501
|
|
8
|
+
TUPLE_CONTRACT_RUNTIME = "0x608060405234801561000f575f5ffd5b5060043610610029575f3560e01c80638e1ae3c71461002d575b5f5ffd5b6100476004803603810190610042919061064d565b61005d565b6040516100549190610a12565b60405180910390f35b61006561006d565b819050919050565b60405180606001604052805f815260200160608152602001606081525090565b5f604051905090565b5f5ffd5b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6100e8826100a2565b810181811067ffffffffffffffff82111715610107576101066100b2565b5b80604052505050565b5f61011961008d565b905061012582826100df565b919050565b5f5ffd5b5f819050919050565b6101408161012e565b811461014a575f5ffd5b50565b5f8135905061015b81610137565b92915050565b5f5ffd5b5f67ffffffffffffffff82111561017f5761017e6100b2565b5b602082029050602081019050919050565b5f5ffd5b5f6101a66101a184610165565b610110565b905080838252602082019050602084028301858111156101c9576101c8610190565b5b835b818110156101f257806101de888261014d565b8452602084019350506020810190506101cb565b5050509392505050565b5f82601f8301126102105761020f610161565b5b8135610220848260208601610194565b91505092915050565b5f67ffffffffffffffff821115610243576102426100b2565b5b602082029050602081019050919050565b5f819050919050565b61026681610254565b8114610270575f5ffd5b50565b5f813590506102818161025d565b92915050565b5f67ffffffffffffffff8211156102a1576102a06100b2565b5b602082029050919050565b5f8115159050919050565b6102c0816102ac565b81146102ca575f5ffd5b50565b5f813590506102db816102b7565b92915050565b5f6102f36102ee84610287565b610110565b9050806020840283018581111561030d5761030c610190565b5b835b81811015610336578061032288826102cd565b84526020840193505060208101905061030f565b5050509392505050565b5f82601f83011261035457610353610161565b5b60026103618482856102e1565b91505092915050565b5f67ffffffffffffffff821115610384576103836100b2565b5b602082029050602081019050919050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6103be82610395565b9050919050565b6103ce816103b4565b81146103d8575f5ffd5b50565b5f813590506103e9816103c5565b92915050565b5f6104016103fc8461036a565b610110565b9050808382526020820190506020840283018581111561042457610423610190565b5b835b8181101561044d578061043988826103db565b845260208401935050602081019050610426565b5050509392505050565b5f82601f83011261046b5761046a610161565b5b813561047b8482602086016103ef565b91505092915050565b5f608082840312156104995761049861009e565b5b6104a36060610110565b90505f6104b284828501610273565b5f8301525060206104c584828501610340565b602083015250606082013567ffffffffffffffff8111156104e9576104e861012a565b5b6104f584828501610457565b60408301525092915050565b5f61051361050e84610229565b610110565b9050808382526020820190506020840283018581111561053657610535610190565b5b835b8181101561057d57803567ffffffffffffffff81111561055b5761055a610161565b5b8086016105688982610484565b85526020850194505050602081019050610538565b5050509392505050565b5f82601f83011261059b5761059a610161565b5b81356105ab848260208601610501565b91505092915050565b5f606082840312156105c9576105c861009e565b5b6105d36060610110565b90505f6105e28482850161014d565b5f83015250602082013567ffffffffffffffff8111156106055761060461012a565b5b610611848285016101fc565b602083015250604082013567ffffffffffffffff8111156106355761063461012a565b5b61064184828501610587565b60408301525092915050565b5f6020828403121561066257610661610096565b5b5f82013567ffffffffffffffff81111561067f5761067e61009a565b5b61068b848285016105b4565b91505092915050565b61069d8161012e565b82525050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f6106d78383610694565b60208301905092915050565b5f602082019050919050565b5f6106f9826106a3565b61070381856106ad565b935061070e836106bd565b805f5b8381101561073e57815161072588826106cc565b9750610730836106e3565b925050600181019050610711565b5085935050505092915050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b61077d81610254565b82525050565b5f60029050919050565b5f81905092915050565b5f819050919050565b6107a9816102ac565b82525050565b5f6107ba83836107a0565b60208301905092915050565b5f602082019050919050565b6107db81610783565b6107e5818461078d565b92506107f082610797565b805f5b8381101561082057815161080787826107af565b9650610812836107c6565b9250506001810190506107f3565b505050505050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b61085a816103b4565b82525050565b5f61086b8383610851565b60208301905092915050565b5f602082019050919050565b5f61088d82610828565b6108978185610832565b93506108a283610842565b805f5b838110156108d25781516108b98882610860565b97506108c483610877565b9250506001810190506108a5565b5085935050505092915050565b5f608083015f8301516108f45f860182610774565b50602083015161090760208601826107d2565b506040830151848203606086015261091f8282610883565b9150508091505092915050565b5f61093783836108df565b905092915050565b5f602082019050919050565b5f6109558261074b565b61095f8185610755565b93508360208202850161097185610765565b805f5b858110156109ac578484038952815161098d858261092c565b94506109988361093f565b925060208a01995050600181019050610974565b50829750879550505050505092915050565b5f606083015f8301516109d35f860182610694565b50602083015184820360208601526109eb82826106ef565b91505060408301518482036040860152610a05828261094b565b9150508091505092915050565b5f6020820190508181035f830152610a2a81846109be565b90509291505056fea2646970667358221220688d7c1933bc8458c33b311fef8cd1eabb9fad171f74729d08c558a805acaafb64736f6c634300081c0033" # 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 = "0x6080604052348015600e575f5ffd5b5061067b8061001c5f395ff3fe608060405234801561000f575f5ffd5b5060043610610029575f3560e01c80632655aef11461002d575b5f5ffd5b610047600480360381019061004291906103f1565b61005d565b6040516100549190610625565b60405180910390f35b61006561006d565b819050919050565b6040518060200160405280606081525090565b5f604051905090565b5f5ffd5b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6100db82610095565b810181811067ffffffffffffffff821117156100fa576100f96100a5565b5b80604052505050565b5f61010c610080565b905061011882826100d2565b919050565b5f5ffd5b5f5ffd5b5f67ffffffffffffffff82111561013f5761013e6100a5565b5b602082029050602081019050919050565b5f5ffd5b5f67ffffffffffffffff82111561016e5761016d6100a5565b5b602082029050602081019050919050565b5f819050919050565b6101918161017f565b811461019b575f5ffd5b50565b5f813590506101ac81610188565b92915050565b5f604082840312156101c7576101c6610091565b5b6101d16040610103565b90505f6101e08482850161019e565b5f8301525060206101f38482850161019e565b60208301525092915050565b5f61021161020c84610154565b610103565b9050808382526020820190506040840283018581111561023457610233610150565b5b835b8181101561025d578061024988826101b2565b845260208401935050604081019050610236565b5050509392505050565b5f82601f83011261027b5761027a610121565b5b813561028b8482602086016101ff565b91505092915050565b5f602082840312156102a9576102a8610091565b5b6102b36020610103565b90505f82013567ffffffffffffffff8111156102d2576102d161011d565b5b6102de84828501610267565b5f8301525092915050565b5f6102fb6102f684610125565b610103565b9050808382526020820190506020840283018581111561031e5761031d610150565b5b835b8181101561036557803567ffffffffffffffff81111561034357610342610121565b5b8086016103508982610294565b85526020850194505050602081019050610320565b5050509392505050565b5f82601f83011261038357610382610121565b5b81356103938482602086016102e9565b91505092915050565b5f602082840312156103b1576103b0610091565b5b6103bb6020610103565b90505f82013567ffffffffffffffff8111156103da576103d961011d565b5b6103e68482850161036f565b5f8301525092915050565b5f6020828403121561040657610405610089565b5b5f82013567ffffffffffffffff8111156104235761042261008d565b5b61042f8482850161039c565b91505092915050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b6104938161017f565b82525050565b604082015f8201516104ad5f85018261048a565b5060208201516104c0602085018261048a565b50505050565b5f6104d18383610499565b60408301905092915050565b5f602082019050919050565b5f6104f382610461565b6104fd818561046b565b93506105088361047b565b805f5b8381101561053857815161051f88826104c6565b975061052a836104dd565b92505060018101905061050b565b5085935050505092915050565b5f602083015f8301518482035f86015261055f82826104e9565b9150508091505092915050565b5f6105778383610545565b905092915050565b5f602082019050919050565b5f61059582610438565b61059f8185610442565b9350836020820285016105b185610452565b805f5b858110156105ec57848403895281516105cd858261056c565b94506105d88361057f565b925060208a019950506001810190506105b4565b50829750879550505050505092915050565b5f602083015f8301518482035f860152610618828261058b565b9150508091505092915050565b5f6020820190508181035f83015261063d81846105fe565b90509291505056fea2646970667358221220f5c624356ac8a8f7232e74f6d7ddfb2174750d834bbdb0855da9ba0d26ff61df64736f6c634300081c0033" # noqa: E501
|
|
75
|
+
NESTED_TUPLE_CONTRACT_RUNTIME = "0x608060405234801561000f575f5ffd5b5060043610610029575f3560e01c80632655aef11461002d575b5f5ffd5b610047600480360381019061004291906103f1565b61005d565b6040516100549190610625565b60405180910390f35b61006561006d565b819050919050565b6040518060200160405280606081525090565b5f604051905090565b5f5ffd5b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6100db82610095565b810181811067ffffffffffffffff821117156100fa576100f96100a5565b5b80604052505050565b5f61010c610080565b905061011882826100d2565b919050565b5f5ffd5b5f5ffd5b5f67ffffffffffffffff82111561013f5761013e6100a5565b5b602082029050602081019050919050565b5f5ffd5b5f67ffffffffffffffff82111561016e5761016d6100a5565b5b602082029050602081019050919050565b5f819050919050565b6101918161017f565b811461019b575f5ffd5b50565b5f813590506101ac81610188565b92915050565b5f604082840312156101c7576101c6610091565b5b6101d16040610103565b90505f6101e08482850161019e565b5f8301525060206101f38482850161019e565b60208301525092915050565b5f61021161020c84610154565b610103565b9050808382526020820190506040840283018581111561023457610233610150565b5b835b8181101561025d578061024988826101b2565b845260208401935050604081019050610236565b5050509392505050565b5f82601f83011261027b5761027a610121565b5b813561028b8482602086016101ff565b91505092915050565b5f602082840312156102a9576102a8610091565b5b6102b36020610103565b90505f82013567ffffffffffffffff8111156102d2576102d161011d565b5b6102de84828501610267565b5f8301525092915050565b5f6102fb6102f684610125565b610103565b9050808382526020820190506020840283018581111561031e5761031d610150565b5b835b8181101561036557803567ffffffffffffffff81111561034357610342610121565b5b8086016103508982610294565b85526020850194505050602081019050610320565b5050509392505050565b5f82601f83011261038357610382610121565b5b81356103938482602086016102e9565b91505092915050565b5f602082840312156103b1576103b0610091565b5b6103bb6020610103565b90505f82013567ffffffffffffffff8111156103da576103d961011d565b5b6103e68482850161036f565b5f8301525092915050565b5f6020828403121561040657610405610089565b5b5f82013567ffffffffffffffff8111156104235761042261008d565b5b61042f8482850161039c565b91505092915050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b6104938161017f565b82525050565b604082015f8201516104ad5f85018261048a565b5060208201516104c0602085018261048a565b50505050565b5f6104d18383610499565b60408301905092915050565b5f602082019050919050565b5f6104f382610461565b6104fd818561046b565b93506105088361047b565b805f5b8381101561053857815161051f88826104c6565b975061052a836104dd565b92505060018101905061050b565b5085935050505092915050565b5f602083015f8301518482035f86015261055f82826104e9565b9150508091505092915050565b5f6105778383610545565b905092915050565b5f602082019050919050565b5f61059582610438565b61059f8185610442565b9350836020820285016105b185610452565b805f5b858110156105ec57848403895281516105cd858261056c565b94506105d88361057f565b925060208a019950506001810190506105b4565b50829750879550505050505092915050565b5f602083015f8301518482035f860152610618828261058b565b9150508091505092915050565b5f6020820190508181035f83015261063d81846105fe565b90509291505056fea2646970667358221220f5c624356ac8a8f7232e74f6d7ddfb2174750d834bbdb0855da9ba0d26ff61df64736f6c634300081c0033" # noqa: E501
|
|
76
76
|
NESTED_TUPLE_CONTRACT_ABI = [
|
|
77
77
|
{
|
|
78
78
|
"inputs": [
|
web3/_utils/method_formatters.py
CHANGED
|
@@ -9,6 +9,7 @@ from typing import (
|
|
|
9
9
|
Iterable,
|
|
10
10
|
NoReturn,
|
|
11
11
|
Tuple,
|
|
12
|
+
TypeVar,
|
|
12
13
|
Union,
|
|
13
14
|
cast,
|
|
14
15
|
)
|
|
@@ -111,6 +112,8 @@ if TYPE_CHECKING:
|
|
|
111
112
|
from web3.eth import Eth # noqa: F401
|
|
112
113
|
from web3.module import Module # noqa: F401
|
|
113
114
|
|
|
115
|
+
TValue = TypeVar("TValue")
|
|
116
|
+
|
|
114
117
|
|
|
115
118
|
def bytes_to_ascii(value: bytes) -> str:
|
|
116
119
|
return codecs.decode(value, "ascii")
|
|
@@ -607,6 +610,102 @@ PYTHONIC_REQUEST_FORMATTERS: Dict[RPCEndpoint, Callable[..., Any]] = {
|
|
|
607
610
|
}
|
|
608
611
|
|
|
609
612
|
# --- Result Formatters --- #
|
|
613
|
+
# -- debug -- #
|
|
614
|
+
DEBUG_CALLTRACE_LOG_ENTRY_FORMATTERS = apply_formatter_if(
|
|
615
|
+
is_not_null,
|
|
616
|
+
type_aware_apply_formatters_to_dict(
|
|
617
|
+
{
|
|
618
|
+
"address": to_checksum_address,
|
|
619
|
+
"topics": apply_list_to_array_formatter(to_hexbytes(32)),
|
|
620
|
+
"data": HexBytes,
|
|
621
|
+
"position": to_integer_if_hex,
|
|
622
|
+
}
|
|
623
|
+
),
|
|
624
|
+
)
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
debug_calltrace_log_list_result_formatter: Callable[
|
|
628
|
+
[Formatters], Any
|
|
629
|
+
] = apply_formatter_to_array(DEBUG_CALLTRACE_LOG_ENTRY_FORMATTERS)
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
PRETRACE_INNER_FORMATTERS = {
|
|
633
|
+
"balance": to_integer_if_hex,
|
|
634
|
+
"nonce": to_integer_if_hex,
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
def has_pretrace_keys(val: Any) -> bool:
|
|
639
|
+
if isinstance(val, dict) or isinstance(val, AttributeDict):
|
|
640
|
+
return (
|
|
641
|
+
val.get("balance")
|
|
642
|
+
or val.get("nonce")
|
|
643
|
+
or val.get("code")
|
|
644
|
+
or val.get("storage")
|
|
645
|
+
)
|
|
646
|
+
return False
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
@curry
|
|
650
|
+
def pretrace_formatter(
|
|
651
|
+
resp: Union[AttributeDict[str, Any], Dict[str, Any]],
|
|
652
|
+
) -> Union[ReadableAttributeDict[str, Any], Dict[str, Any]]:
|
|
653
|
+
return type_aware_apply_formatters_to_dict_keys_and_values(
|
|
654
|
+
apply_formatter_if(is_address, to_checksum_address),
|
|
655
|
+
apply_formatter_if(
|
|
656
|
+
has_pretrace_keys,
|
|
657
|
+
type_aware_apply_formatters_to_dict(PRETRACE_INNER_FORMATTERS),
|
|
658
|
+
),
|
|
659
|
+
resp,
|
|
660
|
+
)
|
|
661
|
+
|
|
662
|
+
|
|
663
|
+
DEBUG_PRESTATE_DIFFMODE_FORMATTERS = {
|
|
664
|
+
"pre": pretrace_formatter,
|
|
665
|
+
"post": pretrace_formatter,
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
DEBUG_CALLTRACE_FORMATTERS = {
|
|
670
|
+
"from": to_checksum_address,
|
|
671
|
+
"to": to_checksum_address,
|
|
672
|
+
"value": to_integer_if_hex,
|
|
673
|
+
"gas": to_integer_if_hex,
|
|
674
|
+
"gasUsed": to_integer_if_hex,
|
|
675
|
+
"input": HexBytes,
|
|
676
|
+
"output": HexBytes,
|
|
677
|
+
"calls": lambda calls: debug_calltrace_list_result_formatter(calls),
|
|
678
|
+
"logs": debug_calltrace_log_list_result_formatter,
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
OPCODE_TRACE_FORMATTERS = {
|
|
683
|
+
"pc": to_integer_if_hex,
|
|
684
|
+
"gas": to_integer_if_hex,
|
|
685
|
+
"gasCost": to_integer_if_hex,
|
|
686
|
+
"refund": to_integer_if_hex,
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
DEBUG_TRACE_FORMATTERS = {
|
|
691
|
+
**DEBUG_CALLTRACE_FORMATTERS,
|
|
692
|
+
**OPCODE_TRACE_FORMATTERS,
|
|
693
|
+
**DEBUG_PRESTATE_DIFFMODE_FORMATTERS,
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
trace_result_formatters = type_aware_apply_formatters_to_dict(DEBUG_TRACE_FORMATTERS)
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
debug_calltrace_result_formatter = type_aware_apply_formatters_to_dict(
|
|
701
|
+
DEBUG_CALLTRACE_FORMATTERS
|
|
702
|
+
)
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
debug_calltrace_list_result_formatter: Callable[
|
|
706
|
+
[Formatters], Any
|
|
707
|
+
] = apply_formatter_to_array(debug_calltrace_result_formatter)
|
|
708
|
+
|
|
610
709
|
|
|
611
710
|
# -- tracing -- #
|
|
612
711
|
|
|
@@ -646,7 +745,7 @@ TRACE_RESULT_FORMATTERS = apply_formatter_if(
|
|
|
646
745
|
)
|
|
647
746
|
|
|
648
747
|
# result formatters for the trace field
|
|
649
|
-
TRACE_FORMATTERS = apply_formatter_if(
|
|
748
|
+
TRACE_FORMATTERS: Callable[[TValue], Union[Any, TValue]] = apply_formatter_if(
|
|
650
749
|
is_not_null,
|
|
651
750
|
type_aware_apply_formatters_to_dict(
|
|
652
751
|
{
|
|
@@ -795,6 +894,14 @@ PYTHONIC_RESULT_FORMATTERS: Dict[RPCEndpoint, Callable[..., Any]] = {
|
|
|
795
894
|
RPC.evm_snapshot: hex_to_integer,
|
|
796
895
|
# Net
|
|
797
896
|
RPC.net_peerCount: to_integer_if_hex,
|
|
897
|
+
# Debug
|
|
898
|
+
RPC.debug_traceTransaction: apply_formatter_if(
|
|
899
|
+
is_not_null,
|
|
900
|
+
compose(
|
|
901
|
+
pretrace_formatter,
|
|
902
|
+
trace_result_formatters,
|
|
903
|
+
),
|
|
904
|
+
),
|
|
798
905
|
# tracing
|
|
799
906
|
RPC.trace_block: trace_list_result_formatter,
|
|
800
907
|
RPC.trace_call: common_tracing_result_formatter,
|
|
@@ -5,6 +5,10 @@ from .eth_module import (
|
|
|
5
5
|
from .go_ethereum_admin_module import (
|
|
6
6
|
GoEthereumAdminModuleTest,
|
|
7
7
|
)
|
|
8
|
+
from .go_ethereum_debug_module import (
|
|
9
|
+
GoEthereumAsyncDebugModuleTest,
|
|
10
|
+
GoEthereumDebugModuleTest,
|
|
11
|
+
)
|
|
8
12
|
from .go_ethereum_txpool_module import (
|
|
9
13
|
GoEthereumAsyncTxPoolModuleTest,
|
|
10
14
|
GoEthereumTxPoolModuleTest,
|
|
@@ -113,7 +113,7 @@ UNKNOWN_HASH = HexStr(
|
|
|
113
113
|
# "test offchain lookup" as an abi-encoded string
|
|
114
114
|
OFFCHAIN_LOOKUP_TEST_DATA = "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001474657374206f6666636861696e206c6f6f6b7570000000000000000000000000" # noqa: E501
|
|
115
115
|
OFFCHAIN_LOOKUP_4BYTE_DATA = "0x556f1830"
|
|
116
|
-
OFFCHAIN_LOOKUP_RETURN_DATA = "
|
|
116
|
+
OFFCHAIN_LOOKUP_RETURN_DATA = "00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a0da96d05a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002c68747470733a2f2f776562332e70792f676174657761792f7b73656e6465727d2f7b646174617d2e6a736f6e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001768747470733a2f2f776562332e70792f6761746577617900000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001474657374206f6666636861696e206c6f6f6b757000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001474657374206f6666636861696e206c6f6f6b7570000000000000000000000000" # noqa: E501
|
|
117
117
|
# "web3py" as an abi-encoded string
|
|
118
118
|
WEB3PY_AS_HEXBYTES = "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000067765623370790000000000000000000000000000000000000000000000000000" # noqa: E501
|
|
119
119
|
|
|
@@ -1628,7 +1628,7 @@ class AsyncEthModuleTest:
|
|
|
1628
1628
|
async_mock_offchain_lookup_request_response(
|
|
1629
1629
|
monkeypatch,
|
|
1630
1630
|
http_method="POST",
|
|
1631
|
-
mocked_request_url=
|
|
1631
|
+
mocked_request_url="https://web3.py/gateway",
|
|
1632
1632
|
mocked_status_code=200,
|
|
1633
1633
|
mocked_json_data=WEB3PY_AS_HEXBYTES,
|
|
1634
1634
|
sender=normalized_contract_address,
|
|
@@ -4091,7 +4091,7 @@ class EthModuleTest:
|
|
|
4091
4091
|
mock_offchain_lookup_request_response(
|
|
4092
4092
|
monkeypatch,
|
|
4093
4093
|
http_method="POST",
|
|
4094
|
-
mocked_request_url=
|
|
4094
|
+
mocked_request_url="https://web3.py/gateway",
|
|
4095
4095
|
mocked_status_code=200,
|
|
4096
4096
|
mocked_json_data=WEB3PY_AS_HEXBYTES,
|
|
4097
4097
|
sender=normalized_contract_address,
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from typing import (
|
|
3
|
+
cast,
|
|
4
|
+
)
|
|
5
|
+
|
|
6
|
+
from eth_typing import (
|
|
7
|
+
HexStr,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
from web3 import (
|
|
11
|
+
AsyncWeb3,
|
|
12
|
+
Web3,
|
|
13
|
+
)
|
|
14
|
+
from web3.types import (
|
|
15
|
+
BlockData,
|
|
16
|
+
CallTrace,
|
|
17
|
+
ChecksumAddress,
|
|
18
|
+
DiffModeTrace,
|
|
19
|
+
OpcodeTrace,
|
|
20
|
+
PrestateTrace,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class GoEthereumAsyncDebugModuleTest:
|
|
25
|
+
@pytest.mark.asyncio
|
|
26
|
+
async def test_async_geth_debug_trace_transaction_opcode_logger(
|
|
27
|
+
self, async_w3: "AsyncWeb3", txn_hash_with_log: HexStr
|
|
28
|
+
) -> None:
|
|
29
|
+
result = await async_w3.geth.debug.trace_transaction(txn_hash_with_log)
|
|
30
|
+
assert "structLogs" in dict(result).keys()
|
|
31
|
+
assert "gas" in dict(result).keys()
|
|
32
|
+
assert "failed" in dict(result).keys()
|
|
33
|
+
|
|
34
|
+
@pytest.mark.asyncio
|
|
35
|
+
async def test_async_geth_debug_trace_transaction_call_tracer(
|
|
36
|
+
self, async_w3: "AsyncWeb3", txn_hash_with_log: HexStr
|
|
37
|
+
) -> None:
|
|
38
|
+
result = cast(
|
|
39
|
+
CallTrace,
|
|
40
|
+
await async_w3.geth.debug.trace_transaction(
|
|
41
|
+
txn_hash_with_log, {"tracer": "callTracer"}
|
|
42
|
+
),
|
|
43
|
+
)
|
|
44
|
+
assert result.get("type") == "CALL"
|
|
45
|
+
|
|
46
|
+
@pytest.mark.asyncio
|
|
47
|
+
async def test_async_geth_debug_trace_transaction_prestate_tracer_diffMode(
|
|
48
|
+
self, async_w3: "AsyncWeb3", txn_hash_with_log: HexStr
|
|
49
|
+
) -> None:
|
|
50
|
+
result = cast(
|
|
51
|
+
DiffModeTrace,
|
|
52
|
+
await async_w3.geth.debug.trace_transaction(
|
|
53
|
+
txn_hash_with_log,
|
|
54
|
+
{"tracer": "prestateTracer", "tracerConfig": {"diffMode": True}},
|
|
55
|
+
),
|
|
56
|
+
)
|
|
57
|
+
assert "post" in dict(result).keys()
|
|
58
|
+
assert "pre" in dict(result).keys()
|
|
59
|
+
|
|
60
|
+
@pytest.mark.asyncio
|
|
61
|
+
async def test_async_geth_debug_trace_transaction_prestate_tracer(
|
|
62
|
+
self,
|
|
63
|
+
async_w3: "AsyncWeb3",
|
|
64
|
+
txn_hash_with_log: HexStr,
|
|
65
|
+
async_block_with_txn_with_log: BlockData,
|
|
66
|
+
) -> None:
|
|
67
|
+
result = cast(
|
|
68
|
+
PrestateTrace,
|
|
69
|
+
await async_w3.geth.debug.trace_transaction(
|
|
70
|
+
txn_hash_with_log,
|
|
71
|
+
{"tracer": "prestateTracer"},
|
|
72
|
+
),
|
|
73
|
+
)
|
|
74
|
+
tx = await async_w3.eth.get_transaction(txn_hash_with_log)
|
|
75
|
+
from_addr: ChecksumAddress = tx["from"]
|
|
76
|
+
assert isinstance(result[from_addr].get("balance"), int)
|
|
77
|
+
assert "post" not in dict(result).keys()
|
|
78
|
+
assert "pre" not in dict(result).keys()
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class GoEthereumDebugModuleTest:
|
|
82
|
+
def test_geth_debug_trace_transaction_opcode_logger(
|
|
83
|
+
self, w3: "Web3", txn_hash_with_log: HexStr
|
|
84
|
+
) -> None:
|
|
85
|
+
result = cast(OpcodeTrace, w3.geth.debug.trace_transaction(txn_hash_with_log))
|
|
86
|
+
assert "structLogs" in dict(result).keys()
|
|
87
|
+
assert "gas" in dict(result).keys()
|
|
88
|
+
assert "failed" in dict(result).keys()
|
|
89
|
+
|
|
90
|
+
def test_geth_debug_trace_transaction_call_tracer(
|
|
91
|
+
self, w3: "Web3", txn_hash_with_log: HexStr
|
|
92
|
+
) -> None:
|
|
93
|
+
result = cast(
|
|
94
|
+
CallTrace,
|
|
95
|
+
w3.geth.debug.trace_transaction(
|
|
96
|
+
txn_hash_with_log, {"tracer": "callTracer"}
|
|
97
|
+
),
|
|
98
|
+
)
|
|
99
|
+
assert result.get("type") == "CALL"
|
|
100
|
+
|
|
101
|
+
def test_geth_debug_trace_transaction_prestate_tracer_diffmode(
|
|
102
|
+
self, w3: "Web3", txn_hash_with_log: HexStr
|
|
103
|
+
) -> None:
|
|
104
|
+
result = cast(
|
|
105
|
+
DiffModeTrace,
|
|
106
|
+
w3.geth.debug.trace_transaction(
|
|
107
|
+
txn_hash_with_log,
|
|
108
|
+
{"tracer": "prestateTracer", "tracerConfig": {"diffMode": True}},
|
|
109
|
+
),
|
|
110
|
+
)
|
|
111
|
+
assert "post" in dict(result).keys()
|
|
112
|
+
assert "pre" in dict(result).keys()
|
|
113
|
+
|
|
114
|
+
def test_geth_debug_trace_transaction_prestate_tracer(
|
|
115
|
+
self, w3: "Web3", txn_hash_with_log: HexStr
|
|
116
|
+
) -> None:
|
|
117
|
+
result = cast(
|
|
118
|
+
PrestateTrace,
|
|
119
|
+
w3.geth.debug.trace_transaction(
|
|
120
|
+
txn_hash_with_log,
|
|
121
|
+
{"tracer": "prestateTracer"},
|
|
122
|
+
),
|
|
123
|
+
)
|
|
124
|
+
tx = w3.eth.get_transaction(txn_hash_with_log)
|
|
125
|
+
from_addr: ChecksumAddress = tx["from"]
|
|
126
|
+
assert isinstance(result[from_addr].get("balance"), int)
|
|
127
|
+
assert "post" not in dict(result).keys()
|
|
128
|
+
assert "pre" not in dict(result).keys()
|
|
@@ -147,7 +147,7 @@ def mock_offchain_lookup_request_response(
|
|
|
147
147
|
if url_from_args == mocked_request_url:
|
|
148
148
|
assert kwargs["timeout"] == DEFAULT_HTTP_TIMEOUT
|
|
149
149
|
if http_method.upper() == "POST":
|
|
150
|
-
assert kwargs["
|
|
150
|
+
assert kwargs["json"] == {"data": calldata, "sender": sender}
|
|
151
151
|
return MockedResponse()
|
|
152
152
|
|
|
153
153
|
# else, make a normal request (no mocking)
|
|
@@ -196,8 +196,8 @@ def async_mock_offchain_lookup_request_response(
|
|
|
196
196
|
# mock response only to specified url while validating appropriate fields
|
|
197
197
|
if url_from_args == mocked_request_url:
|
|
198
198
|
assert kwargs["timeout"] == ClientTimeout(DEFAULT_HTTP_TIMEOUT)
|
|
199
|
-
if http_method.upper() == "
|
|
200
|
-
assert kwargs["
|
|
199
|
+
if http_method.upper() == "POST":
|
|
200
|
+
assert kwargs["json"] == {"data": calldata, "sender": sender}
|
|
201
201
|
return AsyncMockedResponse()
|
|
202
202
|
|
|
203
203
|
# else, make a normal request (no mocking)
|
|
@@ -35,6 +35,14 @@ class RequestMocker:
|
|
|
35
35
|
Context manager to mock requests made by a web3 instance. This is meant to be used
|
|
36
36
|
via a ``request_mocker`` fixture defined within the appropriate context.
|
|
37
37
|
|
|
38
|
+
************************************************************************************
|
|
39
|
+
Important: When mocking results, it's important to keep in mind the types that
|
|
40
|
+
clients return. For example, what we commonly translate to integers are returned
|
|
41
|
+
as hex strings in the RPC response and should be mocked as such for more
|
|
42
|
+
accurate testing.
|
|
43
|
+
************************************************************************************
|
|
44
|
+
|
|
45
|
+
|
|
38
46
|
Example:
|
|
39
47
|
-------
|
|
40
48
|
|
|
@@ -105,10 +113,9 @@ class RequestMocker:
|
|
|
105
113
|
|
|
106
114
|
return self
|
|
107
115
|
|
|
108
|
-
# define __exit__ with typing information
|
|
109
116
|
def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None:
|
|
110
117
|
# mypy error: Cannot assign to a method
|
|
111
|
-
self.w3.provider.make_request = self._make_request # type: ignore[
|
|
118
|
+
self.w3.provider.make_request = self._make_request # type: ignore[assignment]
|
|
112
119
|
# reset request func cache to re-build request_func with original make_request
|
|
113
120
|
self.w3.provider._request_func_cache = (None, None)
|
|
114
121
|
|
|
@@ -167,6 +174,7 @@ class RequestMocker:
|
|
|
167
174
|
return mocked_response
|
|
168
175
|
|
|
169
176
|
# -- async -- #
|
|
177
|
+
|
|
170
178
|
async def __aenter__(self) -> "Self":
|
|
171
179
|
# mypy error: Cannot assign to a method
|
|
172
180
|
self.w3.provider.make_request = self._async_mock_request_handler # type: ignore[method-assign] # noqa: E501
|
|
@@ -176,7 +184,7 @@ class RequestMocker:
|
|
|
176
184
|
|
|
177
185
|
async def __aexit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None:
|
|
178
186
|
# mypy error: Cannot assign to a method
|
|
179
|
-
self.w3.provider.make_request = self._make_request # type: ignore[
|
|
187
|
+
self.w3.provider.make_request = self._make_request # type: ignore[assignment]
|
|
180
188
|
# reset request func cache to re-build request_func with original make_request
|
|
181
189
|
self.w3.provider._request_func_cache = (None, None)
|
|
182
190
|
|
web3/_utils/rpc_abi.py
CHANGED
web3/contract/async_contract.py
CHANGED
|
@@ -15,6 +15,7 @@ from typing import (
|
|
|
15
15
|
|
|
16
16
|
from eth_typing import (
|
|
17
17
|
ABI,
|
|
18
|
+
ABIEvent,
|
|
18
19
|
ChecksumAddress,
|
|
19
20
|
)
|
|
20
21
|
from eth_utils import (
|
|
@@ -79,7 +80,9 @@ from web3.contract.utils import (
|
|
|
79
80
|
async_call_contract_function,
|
|
80
81
|
async_estimate_gas_for_function,
|
|
81
82
|
async_transact_with_contract_function,
|
|
83
|
+
find_events_by_identifier,
|
|
82
84
|
find_functions_by_identifier,
|
|
85
|
+
get_event_by_identifier,
|
|
83
86
|
get_function_by_identifier,
|
|
84
87
|
)
|
|
85
88
|
from web3.exceptions import (
|
|
@@ -97,6 +100,9 @@ from web3.types import (
|
|
|
97
100
|
StateOverride,
|
|
98
101
|
TxParams,
|
|
99
102
|
)
|
|
103
|
+
from web3.utils.abi import (
|
|
104
|
+
get_abi_element,
|
|
105
|
+
)
|
|
100
106
|
|
|
101
107
|
if TYPE_CHECKING:
|
|
102
108
|
from ens import AsyncENS # noqa: F401
|
|
@@ -107,6 +113,17 @@ class AsyncContractEvent(BaseContractEvent):
|
|
|
107
113
|
# mypy types
|
|
108
114
|
w3: "AsyncWeb3"
|
|
109
115
|
|
|
116
|
+
def __call__(self) -> "AsyncContractEvent":
|
|
117
|
+
clone = copy.copy(self)
|
|
118
|
+
|
|
119
|
+
if not self.abi:
|
|
120
|
+
self.abi = cast(
|
|
121
|
+
ABIEvent,
|
|
122
|
+
get_abi_element(self.contract_abi, self.event_name),
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
return clone
|
|
126
|
+
|
|
110
127
|
@combomethod
|
|
111
128
|
async def get_logs(
|
|
112
129
|
self,
|
|
@@ -135,7 +152,7 @@ class AsyncContractEvent(BaseContractEvent):
|
|
|
135
152
|
from = max(mycontract.web3.eth.block_number - 10, 1)
|
|
136
153
|
to = mycontract.web3.eth.block_number
|
|
137
154
|
|
|
138
|
-
events = mycontract.events.Transfer.
|
|
155
|
+
events = mycontract.events.Transfer.get_logs(from_block=from, to_block=to)
|
|
139
156
|
|
|
140
157
|
for e in events:
|
|
141
158
|
print(e["args"]["from"],
|
|
@@ -197,7 +214,9 @@ class AsyncContractEvent(BaseContractEvent):
|
|
|
197
214
|
all_event_logs,
|
|
198
215
|
argument_filters,
|
|
199
216
|
)
|
|
200
|
-
|
|
217
|
+
sorted_logs = sorted(filtered_logs, key=lambda e: e["logIndex"])
|
|
218
|
+
sorted_logs = sorted(sorted_logs, key=lambda e: e["blockNumber"])
|
|
219
|
+
return cast(Awaitable[Iterable[EventData]], sorted_logs)
|
|
201
220
|
|
|
202
221
|
@combomethod
|
|
203
222
|
async def create_filter(
|
|
@@ -239,6 +258,12 @@ class AsyncContractEvent(BaseContractEvent):
|
|
|
239
258
|
builder.address = self.address
|
|
240
259
|
return builder
|
|
241
260
|
|
|
261
|
+
@classmethod
|
|
262
|
+
def factory(cls, class_name: str, **kwargs: Any) -> Self:
|
|
263
|
+
return PropertyCheckingFactory(class_name, (cls,), kwargs)(
|
|
264
|
+
abi=kwargs.get("abi")
|
|
265
|
+
)
|
|
266
|
+
|
|
242
267
|
|
|
243
268
|
class AsyncContractEvents(BaseContractEvents):
|
|
244
269
|
def __init__(
|
|
@@ -556,6 +581,24 @@ class AsyncContract(BaseContract):
|
|
|
556
581
|
) -> "AsyncContractFunction":
|
|
557
582
|
return get_function_by_identifier(fns, identifier)
|
|
558
583
|
|
|
584
|
+
@combomethod
|
|
585
|
+
def find_events_by_identifier(
|
|
586
|
+
cls,
|
|
587
|
+
contract_abi: ABI,
|
|
588
|
+
w3: "AsyncWeb3",
|
|
589
|
+
address: ChecksumAddress,
|
|
590
|
+
callable_check: Callable[..., Any],
|
|
591
|
+
) -> List["AsyncContractEvent"]:
|
|
592
|
+
return find_events_by_identifier(
|
|
593
|
+
contract_abi, w3, address, callable_check, AsyncContractEvent
|
|
594
|
+
)
|
|
595
|
+
|
|
596
|
+
@combomethod
|
|
597
|
+
def get_event_by_identifier(
|
|
598
|
+
cls, events: Sequence["AsyncContractEvent"], identifier: str
|
|
599
|
+
) -> "AsyncContractEvent":
|
|
600
|
+
return get_event_by_identifier(events, identifier)
|
|
601
|
+
|
|
559
602
|
|
|
560
603
|
class AsyncContractCaller(BaseContractCaller):
|
|
561
604
|
# mypy types
|