web3 7.5.0__py3-none-any.whl → 7.6.1__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/abi.py CHANGED
@@ -63,6 +63,7 @@ from eth_utils import (
63
63
  decode_hex,
64
64
  filter_abi_by_type,
65
65
  get_abi_input_names,
66
+ get_abi_input_types,
66
67
  is_bytes,
67
68
  is_list_like,
68
69
  is_string,
@@ -76,6 +77,10 @@ from eth_utils.toolz import (
76
77
  pipe,
77
78
  )
78
79
 
80
+ from web3._utils.abi_element_identifiers import (
81
+ FallbackFn,
82
+ ReceiveFn,
83
+ )
79
84
  from web3._utils.decorators import (
80
85
  reject_recursive_repeats,
81
86
  )
@@ -92,6 +97,7 @@ from web3.exceptions import (
92
97
  Web3ValueError,
93
98
  )
94
99
  from web3.types import (
100
+ ABIElementIdentifier,
95
101
  TReturn,
96
102
  )
97
103
 
@@ -117,9 +123,13 @@ def exclude_indexed_event_inputs(event_abi: ABIEvent) -> Sequence[ABIComponentIn
117
123
  return [arg for arg in event_abi["inputs"] if arg["indexed"] is False]
118
124
 
119
125
 
126
+ def filter_by_types(types: Collection[str], contract_abi: ABI) -> Sequence[ABIElement]:
127
+ return [abi_element for abi_element in contract_abi if abi_element["type"] in types]
128
+
129
+
120
130
  def filter_by_argument_name(
121
131
  argument_names: Collection[str], contract_abi: ABI
122
- ) -> List[ABIElement]:
132
+ ) -> Sequence[ABIElement]:
123
133
  """
124
134
  Return a list of each ``ABIElement`` which contain arguments matching provided
125
135
  names.
@@ -139,6 +149,54 @@ def filter_by_argument_name(
139
149
  return abis_with_matching_args
140
150
 
141
151
 
152
+ def filter_by_argument_type(
153
+ argument_types: Collection[str], contract_abi: ABI
154
+ ) -> List[ABIElement]:
155
+ """
156
+ Return a list of each ``ABIElement`` which contain arguments matching provided
157
+ types.
158
+ """
159
+ abis_with_matching_args = []
160
+ for abi_element in contract_abi:
161
+ try:
162
+ abi_arg_types = get_abi_input_types(abi_element)
163
+
164
+ if set(argument_types).intersection(abi_arg_types) == set(argument_types):
165
+ abis_with_matching_args.append(abi_element)
166
+ except ValueError:
167
+ # fallback or receive functions do not have arguments
168
+ # proceed to next ABIElement
169
+ continue
170
+
171
+ return abis_with_matching_args
172
+
173
+
174
+ def get_name_from_abi_element_identifier(
175
+ abi_element_identifier: ABIElementIdentifier,
176
+ ) -> str:
177
+ if abi_element_identifier in ["fallback", FallbackFn]:
178
+ return "fallback"
179
+ elif abi_element_identifier in ["receive", ReceiveFn]:
180
+ return "receive"
181
+ elif is_text(abi_element_identifier):
182
+ return str(abi_element_identifier).split("(")[0]
183
+ else:
184
+ raise Web3TypeError("Unsupported function identifier")
185
+
186
+
187
+ def get_abi_element_signature(
188
+ abi_element_identifier: ABIElementIdentifier,
189
+ abi_element_argument_types: Optional[Sequence[str]] = None,
190
+ ) -> str:
191
+ element_name = get_name_from_abi_element_identifier(abi_element_identifier)
192
+ argument_types = ",".join(abi_element_argument_types or [])
193
+
194
+ if element_name in ["fallback", "receive"]:
195
+ return element_name
196
+
197
+ return f"{element_name}({argument_types})"
198
+
199
+
142
200
  class AddressEncoder(encoding.AddressEncoder):
143
201
  @classmethod
144
202
  def validate_value(cls, value: Any) -> None:
@@ -0,0 +1,42 @@
1
+ """
2
+ Generated by `compile_contracts.py` script.
3
+ Compiled with Solidity v0.8.28.
4
+ """
5
+
6
+ # source: web3/_utils/contract_sources/AmbiguousFunctionContract.sol:AmbiguousFunctionContract # noqa: E501
7
+ AMBIGUOUS_FUNCTION_CONTRACT_BYTECODE = "0x6080604052348015600e575f5ffd5b5061044a8061001c5f395ff3fe608060405234801561000f575f5ffd5b506004361061003f575f3560e01c80631626ba7e1461004357806320c13b0b14610073578063d482bb47146100a3575b5f5ffd5b61005d60048036038101906100589190610293565b6100c1565b60405161006a9190610305565b60405180910390f35b61008d6004803603810190610088919061031e565b6100cb565b60405161009a9190610305565b60405180910390f35b6100ab6100d6565b6040516100b891906103f4565b60405180910390f35b5f5f905092915050565b5f6001905092915050565b60606040518060400160405280600581526020017f76616c6964000000000000000000000000000000000000000000000000000000815250905090565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b61013681610124565b8114610140575f5ffd5b50565b5f813590506101518161012d565b92915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6101a58261015f565b810181811067ffffffffffffffff821117156101c4576101c361016f565b5b80604052505050565b5f6101d6610113565b90506101e2828261019c565b919050565b5f67ffffffffffffffff8211156102015761020061016f565b5b61020a8261015f565b9050602081019050919050565b828183375f83830152505050565b5f610237610232846101e7565b6101cd565b9050828152602081018484840111156102535761025261015b565b5b61025e848285610217565b509392505050565b5f82601f83011261027a57610279610157565b5b813561028a848260208601610225565b91505092915050565b5f5f604083850312156102a9576102a861011c565b5b5f6102b685828601610143565b925050602083013567ffffffffffffffff8111156102d7576102d6610120565b5b6102e385828601610266565b9150509250929050565b5f819050919050565b6102ff816102ed565b82525050565b5f6020820190506103185f8301846102f6565b92915050565b5f5f604083850312156103345761033361011c565b5b5f83013567ffffffffffffffff81111561035157610350610120565b5b61035d85828601610266565b925050602083013567ffffffffffffffff81111561037e5761037d610120565b5b61038a85828601610266565b9150509250929050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f6103c682610394565b6103d0818561039e565b93506103e08185602086016103ae565b6103e98161015f565b840191505092915050565b5f6020820190508181035f83015261040c81846103bc565b90509291505056fea2646970667358221220baaf91e0e0589f566caa06e4f8fa283b865412d3e3c1dc1eca705cc8ad7f393764736f6c634300081c0033" # noqa: E501
8
+ AMBIGUOUS_FUNCTION_CONTRACT_RUNTIME = "0x608060405234801561000f575f5ffd5b506004361061003f575f3560e01c80631626ba7e1461004357806320c13b0b14610073578063d482bb47146100a3575b5f5ffd5b61005d60048036038101906100589190610293565b6100c1565b60405161006a9190610305565b60405180910390f35b61008d6004803603810190610088919061031e565b6100cb565b60405161009a9190610305565b60405180910390f35b6100ab6100d6565b6040516100b891906103f4565b60405180910390f35b5f5f905092915050565b5f6001905092915050565b60606040518060400160405280600581526020017f76616c6964000000000000000000000000000000000000000000000000000000815250905090565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b61013681610124565b8114610140575f5ffd5b50565b5f813590506101518161012d565b92915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6101a58261015f565b810181811067ffffffffffffffff821117156101c4576101c361016f565b5b80604052505050565b5f6101d6610113565b90506101e2828261019c565b919050565b5f67ffffffffffffffff8211156102015761020061016f565b5b61020a8261015f565b9050602081019050919050565b828183375f83830152505050565b5f610237610232846101e7565b6101cd565b9050828152602081018484840111156102535761025261015b565b5b61025e848285610217565b509392505050565b5f82601f83011261027a57610279610157565b5b813561028a848260208601610225565b91505092915050565b5f5f604083850312156102a9576102a861011c565b5b5f6102b685828601610143565b925050602083013567ffffffffffffffff8111156102d7576102d6610120565b5b6102e385828601610266565b9150509250929050565b5f819050919050565b6102ff816102ed565b82525050565b5f6020820190506103185f8301846102f6565b92915050565b5f5f604083850312156103345761033361011c565b5b5f83013567ffffffffffffffff81111561035157610350610120565b5b61035d85828601610266565b925050602083013567ffffffffffffffff81111561037e5761037d610120565b5b61038a85828601610266565b9150509250929050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f6103c682610394565b6103d0818561039e565b93506103e08185602086016103ae565b6103e98161015f565b840191505092915050565b5f6020820190508181035f83015261040c81846103bc565b90509291505056fea2646970667358221220baaf91e0e0589f566caa06e4f8fa283b865412d3e3c1dc1eca705cc8ad7f393764736f6c634300081c0033" # noqa: E501
9
+ AMBIGUOUS_FUNCTION_CONTRACT_ABI = [
10
+ {
11
+ "inputs": [
12
+ {"internalType": "bytes32", "name": "message", "type": "bytes32"},
13
+ {"internalType": "bytes", "name": "signature", "type": "bytes"},
14
+ ],
15
+ "name": "isValidSignature",
16
+ "outputs": [{"internalType": "uint256", "name": "result", "type": "uint256"}],
17
+ "stateMutability": "view",
18
+ "type": "function",
19
+ },
20
+ {
21
+ "inputs": [
22
+ {"internalType": "bytes", "name": "message", "type": "bytes"},
23
+ {"internalType": "bytes", "name": "signature", "type": "bytes"},
24
+ ],
25
+ "name": "isValidSignature",
26
+ "outputs": [{"internalType": "uint256", "name": "result", "type": "uint256"}],
27
+ "stateMutability": "view",
28
+ "type": "function",
29
+ },
30
+ {
31
+ "inputs": [],
32
+ "name": "isValidSignature",
33
+ "outputs": [{"internalType": "string", "name": "result", "type": "string"}],
34
+ "stateMutability": "view",
35
+ "type": "function",
36
+ },
37
+ ]
38
+ AMBIGUOUS_FUNCTION_CONTRACT_DATA = {
39
+ "bytecode": AMBIGUOUS_FUNCTION_CONTRACT_BYTECODE,
40
+ "bytecode_runtime": AMBIGUOUS_FUNCTION_CONTRACT_RUNTIME,
41
+ "abi": AMBIGUOUS_FUNCTION_CONTRACT_ABI,
42
+ }
@@ -4,8 +4,8 @@ Compiled with Solidity v0.8.28.
4
4
  """
5
5
 
6
6
  # source: web3/_utils/contract_sources/EventContracts.sol:EventContract
7
- EVENT_CONTRACT_BYTECODE = "0x6080604052348015600e575f5ffd5b5061017a8061001c5f395ff3fe608060405234801561000f575f5ffd5b5060043610610029575f3560e01c80635818fad71461002d575b5f5ffd5b610047600480360381019061004291906100f1565b610049565b005b7ff70fe689e290d8ce2b2a388ac28db36fbb0e16a6d89c6804c461f65a1b40bb1581604051610078919061012b565b60405180910390a17f56d2ef3c5228bf5d88573621e325a4672ab50e033749a601e4f4a5e1dce905d4816040516100af919061012b565b60405180910390a150565b5f5ffd5b5f819050919050565b6100d0816100be565b81146100da575f5ffd5b50565b5f813590506100eb816100c7565b92915050565b5f60208284031215610106576101056100ba565b5b5f610113848285016100dd565b91505092915050565b610125816100be565b82525050565b5f60208201905061013e5f83018461011c565b9291505056fea2646970667358221220ffb25fdd3a92ed8f87f68da4885d8c0f5e6fd2edeafb3d1cab0da0f2683b846b64736f6c634300081c0033" # noqa: E501
8
- EVENT_CONTRACT_RUNTIME = "0x608060405234801561000f575f5ffd5b5060043610610029575f3560e01c80635818fad71461002d575b5f5ffd5b610047600480360381019061004291906100f1565b610049565b005b7ff70fe689e290d8ce2b2a388ac28db36fbb0e16a6d89c6804c461f65a1b40bb1581604051610078919061012b565b60405180910390a17f56d2ef3c5228bf5d88573621e325a4672ab50e033749a601e4f4a5e1dce905d4816040516100af919061012b565b60405180910390a150565b5f5ffd5b5f819050919050565b6100d0816100be565b81146100da575f5ffd5b50565b5f813590506100eb816100c7565b92915050565b5f60208284031215610106576101056100ba565b5b5f610113848285016100dd565b91505092915050565b610125816100be565b82525050565b5f60208201905061013e5f83018461011c565b9291505056fea2646970667358221220ffb25fdd3a92ed8f87f68da4885d8c0f5e6fd2edeafb3d1cab0da0f2683b846b64736f6c634300081c0033" # noqa: E501
7
+ EVENT_CONTRACT_BYTECODE = "0x6080604052348015600e575f5ffd5b5061017a8061001c5f395ff3fe608060405234801561000f575f5ffd5b5060043610610029575f3560e01c80635818fad71461002d575b5f5ffd5b610047600480360381019061004291906100f1565b610049565b005b7ff70fe689e290d8ce2b2a388ac28db36fbb0e16a6d89c6804c461f65a1b40bb1581604051610078919061012b565b60405180910390a17f56d2ef3c5228bf5d88573621e325a4672ab50e033749a601e4f4a5e1dce905d4816040516100af919061012b565b60405180910390a150565b5f5ffd5b5f819050919050565b6100d0816100be565b81146100da575f5ffd5b50565b5f813590506100eb816100c7565b92915050565b5f60208284031215610106576101056100ba565b5b5f610113848285016100dd565b91505092915050565b610125816100be565b82525050565b5f60208201905061013e5f83018461011c565b9291505056fea26469706673582212200e015f231e61081fe45f12e0f685c07278b70c9a1af144d2c6a7a0c7b6e61bab64736f6c634300081c0033" # noqa: E501
8
+ EVENT_CONTRACT_RUNTIME = "0x608060405234801561000f575f5ffd5b5060043610610029575f3560e01c80635818fad71461002d575b5f5ffd5b610047600480360381019061004291906100f1565b610049565b005b7ff70fe689e290d8ce2b2a388ac28db36fbb0e16a6d89c6804c461f65a1b40bb1581604051610078919061012b565b60405180910390a17f56d2ef3c5228bf5d88573621e325a4672ab50e033749a601e4f4a5e1dce905d4816040516100af919061012b565b60405180910390a150565b5f5ffd5b5f819050919050565b6100d0816100be565b81146100da575f5ffd5b50565b5f813590506100eb816100c7565b92915050565b5f60208284031215610106576101056100ba565b5b5f610113848285016100dd565b91505092915050565b610125816100be565b82525050565b5f60208201905061013e5f83018461011c565b9291505056fea26469706673582212200e015f231e61081fe45f12e0f685c07278b70c9a1af144d2c6a7a0c7b6e61bab64736f6c634300081c0033" # noqa: E501
9
9
  EVENT_CONTRACT_ABI = [
10
10
  {
11
11
  "anonymous": False,
@@ -49,8 +49,8 @@ EVENT_CONTRACT_DATA = {
49
49
 
50
50
 
51
51
  # source: web3/_utils/contract_sources/EventContracts.sol:IndexedEventContract
52
- INDEXED_EVENT_CONTRACT_BYTECODE = "0x6080604052348015600e575f5ffd5b506101708061001c5f395ff3fe608060405234801561000f575f5ffd5b5060043610610029575f3560e01c80635818fad71461002d575b5f5ffd5b610047600480360381019061004291906100e7565b610049565b005b807ff70fe689e290d8ce2b2a388ac28db36fbb0e16a6d89c6804c461f65a1b40bb1560405160405180910390a27f56d2ef3c5228bf5d88573621e325a4672ab50e033749a601e4f4a5e1dce905d4816040516100a59190610121565b60405180910390a150565b5f5ffd5b5f819050919050565b6100c6816100b4565b81146100d0575f5ffd5b50565b5f813590506100e1816100bd565b92915050565b5f602082840312156100fc576100fb6100b0565b5b5f610109848285016100d3565b91505092915050565b61011b816100b4565b82525050565b5f6020820190506101345f830184610112565b9291505056fea2646970667358221220c54729ba3e926e84d8497888e2dc66bd33efa5e4ebcd95e323dc53eb183500cc64736f6c634300081c0033" # noqa: E501
53
- INDEXED_EVENT_CONTRACT_RUNTIME = "0x608060405234801561000f575f5ffd5b5060043610610029575f3560e01c80635818fad71461002d575b5f5ffd5b610047600480360381019061004291906100e7565b610049565b005b807ff70fe689e290d8ce2b2a388ac28db36fbb0e16a6d89c6804c461f65a1b40bb1560405160405180910390a27f56d2ef3c5228bf5d88573621e325a4672ab50e033749a601e4f4a5e1dce905d4816040516100a59190610121565b60405180910390a150565b5f5ffd5b5f819050919050565b6100c6816100b4565b81146100d0575f5ffd5b50565b5f813590506100e1816100bd565b92915050565b5f602082840312156100fc576100fb6100b0565b5b5f610109848285016100d3565b91505092915050565b61011b816100b4565b82525050565b5f6020820190506101345f830184610112565b9291505056fea2646970667358221220c54729ba3e926e84d8497888e2dc66bd33efa5e4ebcd95e323dc53eb183500cc64736f6c634300081c0033" # noqa: E501
52
+ INDEXED_EVENT_CONTRACT_BYTECODE = "0x6080604052348015600e575f5ffd5b506101708061001c5f395ff3fe608060405234801561000f575f5ffd5b5060043610610029575f3560e01c80635818fad71461002d575b5f5ffd5b610047600480360381019061004291906100e7565b610049565b005b807ff70fe689e290d8ce2b2a388ac28db36fbb0e16a6d89c6804c461f65a1b40bb1560405160405180910390a27f56d2ef3c5228bf5d88573621e325a4672ab50e033749a601e4f4a5e1dce905d4816040516100a59190610121565b60405180910390a150565b5f5ffd5b5f819050919050565b6100c6816100b4565b81146100d0575f5ffd5b50565b5f813590506100e1816100bd565b92915050565b5f602082840312156100fc576100fb6100b0565b5b5f610109848285016100d3565b91505092915050565b61011b816100b4565b82525050565b5f6020820190506101345f830184610112565b9291505056fea264697066735822122038d1b44cbd4d6a31971aab3eaac7933f03b5db859486e34c7a6fd33fb9b2091e64736f6c634300081c0033" # noqa: E501
53
+ INDEXED_EVENT_CONTRACT_RUNTIME = "0x608060405234801561000f575f5ffd5b5060043610610029575f3560e01c80635818fad71461002d575b5f5ffd5b610047600480360381019061004291906100e7565b610049565b005b807ff70fe689e290d8ce2b2a388ac28db36fbb0e16a6d89c6804c461f65a1b40bb1560405160405180910390a27f56d2ef3c5228bf5d88573621e325a4672ab50e033749a601e4f4a5e1dce905d4816040516100a59190610121565b60405180910390a150565b5f5ffd5b5f819050919050565b6100c6816100b4565b81146100d0575f5ffd5b50565b5f813590506100e1816100bd565b92915050565b5f602082840312156100fc576100fb6100b0565b5b5f610109848285016100d3565b91505092915050565b61011b816100b4565b82525050565b5f6020820190506101345f830184610112565b9291505056fea264697066735822122038d1b44cbd4d6a31971aab3eaac7933f03b5db859486e34c7a6fd33fb9b2091e64736f6c634300081c0033" # noqa: E501
54
54
  INDEXED_EVENT_CONTRACT_ABI = [
55
55
  {
56
56
  "anonymous": False,
@@ -91,3 +91,48 @@ INDEXED_EVENT_CONTRACT_DATA = {
91
91
  "bytecode_runtime": INDEXED_EVENT_CONTRACT_RUNTIME,
92
92
  "abi": INDEXED_EVENT_CONTRACT_ABI,
93
93
  }
94
+
95
+
96
+ # source: web3/_utils/contract_sources/EventContracts.sol:AmbiguousEventNameContract
97
+ AMBIGUOUS_EVENT_NAME_CONTRACT_BYTECODE = "0x6080604052348015600e575f5ffd5b506102728061001c5f395ff3fe608060405234801561000f575f5ffd5b5060043610610029575f3560e01c80635818fad71461002d575b5f5ffd5b61004760048036038101906100429190610119565b610049565b005b7f56d2ef3c5228bf5d88573621e325a4672ab50e033749a601e4f4a5e1dce905d4816040516100789190610153565b60405180910390a17fe466ad4edc182e32048f6e723b179ae20d1030f298fcfa1e9ad4a759b5a63112816040516020016100b29190610153565b6040516020818303038152906040526100ca906101ae565b6040516100d79190610223565b60405180910390a150565b5f5ffd5b5f819050919050565b6100f8816100e6565b8114610102575f5ffd5b50565b5f81359050610113816100ef565b92915050565b5f6020828403121561012e5761012d6100e2565b5b5f61013b84828501610105565b91505092915050565b61014d816100e6565b82525050565b5f6020820190506101665f830184610144565b92915050565b5f81519050919050565b5f819050602082019050919050565b5f819050919050565b5f6101998251610185565b80915050919050565b5f82821b905092915050565b5f6101b88261016c565b826101c284610176565b90506101cd8161018e565b9250602082101561020d576102087fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff836020036008026101a2565b831692505b5050919050565b61021d81610185565b82525050565b5f6020820190506102365f830184610214565b9291505056fea2646970667358221220b00fa945245be24cc68c14582f357e7d83cfa8fcd440eabf93e87592563e3df064736f6c634300081c0033" # noqa: E501
98
+ AMBIGUOUS_EVENT_NAME_CONTRACT_RUNTIME = "0x608060405234801561000f575f5ffd5b5060043610610029575f3560e01c80635818fad71461002d575b5f5ffd5b61004760048036038101906100429190610119565b610049565b005b7f56d2ef3c5228bf5d88573621e325a4672ab50e033749a601e4f4a5e1dce905d4816040516100789190610153565b60405180910390a17fe466ad4edc182e32048f6e723b179ae20d1030f298fcfa1e9ad4a759b5a63112816040516020016100b29190610153565b6040516020818303038152906040526100ca906101ae565b6040516100d79190610223565b60405180910390a150565b5f5ffd5b5f819050919050565b6100f8816100e6565b8114610102575f5ffd5b50565b5f81359050610113816100ef565b92915050565b5f6020828403121561012e5761012d6100e2565b5b5f61013b84828501610105565b91505092915050565b61014d816100e6565b82525050565b5f6020820190506101665f830184610144565b92915050565b5f81519050919050565b5f819050602082019050919050565b5f819050919050565b5f6101998251610185565b80915050919050565b5f82821b905092915050565b5f6101b88261016c565b826101c284610176565b90506101cd8161018e565b9250602082101561020d576102087fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff836020036008026101a2565b831692505b5050919050565b61021d81610185565b82525050565b5f6020820190506102365f830184610214565b9291505056fea2646970667358221220b00fa945245be24cc68c14582f357e7d83cfa8fcd440eabf93e87592563e3df064736f6c634300081c0033" # noqa: E501
99
+ AMBIGUOUS_EVENT_NAME_CONTRACT_ABI = [
100
+ {
101
+ "anonymous": False,
102
+ "inputs": [
103
+ {
104
+ "indexed": False,
105
+ "internalType": "uint256",
106
+ "name": "arg0",
107
+ "type": "uint256",
108
+ }
109
+ ],
110
+ "name": "LogSingleArg",
111
+ "type": "event",
112
+ },
113
+ {
114
+ "anonymous": False,
115
+ "inputs": [
116
+ {
117
+ "indexed": False,
118
+ "internalType": "bytes32",
119
+ "name": "arg0",
120
+ "type": "bytes32",
121
+ }
122
+ ],
123
+ "name": "LogSingleArg",
124
+ "type": "event",
125
+ },
126
+ {
127
+ "inputs": [{"internalType": "uint256", "name": "_arg0", "type": "uint256"}],
128
+ "name": "logTwoEvents",
129
+ "outputs": [],
130
+ "stateMutability": "nonpayable",
131
+ "type": "function",
132
+ },
133
+ ]
134
+ AMBIGUOUS_EVENT_NAME_CONTRACT_DATA = {
135
+ "bytecode": AMBIGUOUS_EVENT_NAME_CONTRACT_BYTECODE,
136
+ "bytecode_runtime": AMBIGUOUS_EVENT_NAME_CONTRACT_RUNTIME,
137
+ "abi": AMBIGUOUS_EVENT_NAME_CONTRACT_ABI,
138
+ }
web3/_utils/contracts.py CHANGED
@@ -1,3 +1,4 @@
1
+ import copy
1
2
  import functools
2
3
  from typing import (
3
4
  TYPE_CHECKING,
@@ -47,13 +48,11 @@ from hexbytes import (
47
48
 
48
49
  from web3._utils.abi import (
49
50
  filter_by_argument_name,
51
+ get_abi_element_signature,
52
+ get_name_from_abi_element_identifier,
50
53
  map_abi_data,
51
54
  named_tree,
52
55
  )
53
- from web3._utils.abi_element_identifiers import (
54
- FallbackFn,
55
- ReceiveFn,
56
- )
57
56
  from web3._utils.blocks import (
58
57
  is_hex_encoded_block_hash,
59
58
  )
@@ -79,6 +78,8 @@ from web3.types import (
79
78
  ABIElementIdentifier,
80
79
  BlockIdentifier,
81
80
  BlockNumber,
81
+ TContractEvent,
82
+ TContractFn,
82
83
  TxParams,
83
84
  )
84
85
  from web3.utils.abi import (
@@ -182,6 +183,18 @@ def prepare_transaction(
182
183
  """
183
184
  fn_args = fn_args or []
184
185
  fn_kwargs = fn_kwargs or {}
186
+
187
+ if not fn_args and not fn_kwargs and "(" not in str(abi_element_identifier):
188
+ abi_element_identifier = get_abi_element_signature(abi_element_identifier)
189
+
190
+ if abi_element_identifier in [
191
+ "fallback()",
192
+ "receive()",
193
+ ]:
194
+ abi_element_identifier = get_name_from_abi_element_identifier(
195
+ abi_element_identifier
196
+ )
197
+
185
198
  if abi_callable is None:
186
199
  abi_callable = cast(
187
200
  ABICallable,
@@ -227,11 +240,12 @@ def encode_transaction_data(
227
240
  kwargs: Optional[Any] = None,
228
241
  ) -> HexStr:
229
242
  info_abi: ABIElement
230
- if abi_element_identifier is FallbackFn:
243
+ abi_element_name = get_name_from_abi_element_identifier(abi_element_identifier)
244
+ if abi_element_name == "fallback":
231
245
  info_abi, info_selector, info_arguments = get_fallback_function_info(
232
246
  contract_abi, cast(ABIFallback, abi_callable)
233
247
  )
234
- elif abi_element_identifier is ReceiveFn:
248
+ elif abi_element_name == "receive":
235
249
  info_abi, info_selector, info_arguments = get_receive_function_info(
236
250
  contract_abi, cast(ABIReceive, abi_callable)
237
251
  )
@@ -321,7 +335,7 @@ def validate_payable(transaction: TxParams, abi_callable: ABICallable) -> None:
321
335
 
322
336
 
323
337
  def parse_block_identifier(
324
- w3: "Web3", block_identifier: BlockIdentifier
338
+ w3: "Web3", block_identifier: Optional[BlockIdentifier]
325
339
  ) -> BlockIdentifier:
326
340
  if block_identifier is None:
327
341
  return w3.eth.default_block
@@ -378,4 +392,31 @@ async def async_parse_block_identifier_int(
378
392
  if block_num < 0:
379
393
  raise BlockNumberOutOfRange
380
394
  return BlockNumber(block_num)
381
- return BlockNumber(block_num)
395
+
396
+
397
+ def copy_contract_function(
398
+ contract_function: TContractFn, *args: Any, **kwargs: Any
399
+ ) -> TContractFn:
400
+ """
401
+ Copy a contract function instance.
402
+ """
403
+ clone = copy.copy(contract_function)
404
+ clone.args = args or tuple()
405
+ clone.kwargs = kwargs or dict()
406
+
407
+ clone._set_function_info()
408
+ return clone
409
+
410
+
411
+ def copy_contract_event(
412
+ contract_event: TContractEvent, *args: Any, **kwargs: Any
413
+ ) -> TContractEvent:
414
+ """
415
+ Copy a contract function instance.
416
+ """
417
+ clone = copy.copy(contract_event)
418
+ clone.args = args or tuple()
419
+ clone.kwargs = kwargs or dict()
420
+
421
+ clone._set_event_info()
422
+ return clone
@@ -836,6 +836,7 @@ def subscription_formatter(value: Any) -> Union[HexBytes, HexStr, Dict[str, Any]
836
836
  PYTHONIC_RESULT_FORMATTERS: Dict[RPCEndpoint, Callable[..., Any]] = {
837
837
  # Eth
838
838
  RPC.eth_accounts: apply_list_to_array_formatter(to_checksum_address),
839
+ RPC.eth_blobBaseFee: to_integer_if_hex,
839
840
  RPC.eth_blockNumber: to_integer_if_hex,
840
841
  RPC.eth_chainId: to_integer_if_hex,
841
842
  RPC.eth_call: HexBytes,
@@ -1841,6 +1841,12 @@ class AsyncEthModuleTest:
1841
1841
  assert len(accounts) != 0
1842
1842
  assert all(is_checksum_address(account) for account in accounts)
1843
1843
 
1844
+ @pytest.mark.asyncio
1845
+ async def test_async_eth_blob_base_fee(self, async_w3: "AsyncWeb3") -> None:
1846
+ blob_base_fee = await async_w3.eth.blob_base_fee
1847
+ assert is_integer(blob_base_fee)
1848
+ assert blob_base_fee >= 0
1849
+
1844
1850
  @pytest.mark.asyncio
1845
1851
  async def test_async_eth_get_logs_without_logs(
1846
1852
  self, async_w3: "AsyncWeb3", async_block_with_txn_with_log: BlockData
@@ -2613,6 +2619,11 @@ class EthModuleTest:
2613
2619
  assert len(accounts) != 0
2614
2620
  assert all(is_checksum_address(account) for account in accounts)
2615
2621
 
2622
+ def test_eth_blob_base_fee(self, w3: "Web3") -> None:
2623
+ blob_base_fee = w3.eth.blob_base_fee
2624
+ assert is_integer(blob_base_fee)
2625
+ assert blob_base_fee >= 0
2626
+
2616
2627
  def test_eth_block_number(self, w3: "Web3") -> None:
2617
2628
  block_number = w3.eth.block_number
2618
2629
  assert is_integer(block_number)
web3/_utils/rpc_abi.py CHANGED
@@ -48,6 +48,7 @@ class RPC:
48
48
 
49
49
  # eth
50
50
  eth_accounts = RPCEndpoint("eth_accounts")
51
+ eth_blobBaseFee = RPCEndpoint("eth_blobBaseFee")
51
52
  eth_blockNumber = RPCEndpoint("eth_blockNumber")
52
53
  eth_call = RPCEndpoint("eth_call")
53
54
  eth_createAccessList = RPCEndpoint("eth_createAccessList")
web3/_utils/validation.py CHANGED
@@ -79,6 +79,9 @@ def validate_abi(abi: ABI) -> None:
79
79
  if not all(is_dict(e) for e in abi):
80
80
  raise Web3ValueError("'abi' is not a list of dictionaries")
81
81
 
82
+ if not all("type" in e for e in abi):
83
+ raise Web3ValueError("'abi' must contain a list of elements each with a type")
84
+
82
85
  functions = filter_abi_by_type("function", abi)
83
86
  selectors = groupby(compose(encode_hex, function_abi_to_4byte_selector), functions)
84
87
  duplicates = valfilter(lambda funcs: len(funcs) > 1, selectors)