99
99
NoABIEventsFound ,
100
100
NoABIFound ,
101
101
NoABIFunctionsFound ,
102
- ValidationError ,
102
+ Web3ValidationError ,
103
103
)
104
104
from web3 .logs import (
105
105
DISCARD ,
@@ -218,7 +218,7 @@ def callable_check(fn_abi: ABIFunction) -> bool:
218
218
fns = self .find_functions_by_identifier (
219
219
self .abi , self .w3 , self .address , callable_check
220
220
)
221
- return get_function_by_identifier (fns , "signature" )
221
+ return self . get_function_by_identifier (fns , "signature" )
222
222
223
223
@combomethod
224
224
def find_functions_by_name (self , fn_name : str ) -> "BaseContractFunction" :
@@ -232,7 +232,7 @@ def callable_check(fn_abi: ABIFunction) -> bool:
232
232
@combomethod
233
233
def get_function_by_name (self , fn_name : str ) -> "BaseContractFunction" :
234
234
fns = self .find_functions_by_name (fn_name )
235
- return get_function_by_identifier (fns , "name" )
235
+ return self . get_function_by_identifier (fns , "name" )
236
236
237
237
@combomethod
238
238
def get_function_by_selector (
@@ -246,7 +246,7 @@ def callable_check(fn_abi: ABIFunction) -> bool:
246
246
fns = self .find_functions_by_identifier (
247
247
self .abi , self .w3 , self .address , callable_check
248
248
)
249
- return get_function_by_identifier (fns , "selector" )
249
+ return self . get_function_by_identifier (fns , "selector" )
250
250
251
251
@combomethod
252
252
def decode_function_input (
@@ -279,7 +279,7 @@ def callable_check(fn_abi: ABIFunction) -> bool:
279
279
@combomethod
280
280
def get_function_by_args (self , * args : Any ) -> "BaseContractFunction" :
281
281
fns = self .find_functions_by_args (* args )
282
- return get_function_by_identifier (fns , "args" )
282
+ return self . get_function_by_identifier (fns , "args" )
283
283
284
284
#
285
285
# Private Helpers
@@ -364,6 +364,14 @@ def find_functions_by_identifier(
364
364
"This method should be implemented in the inherited class"
365
365
)
366
366
367
+ @combomethod
368
+ def get_function_by_identifier (
369
+ cls , fns : Sequence ["BaseContractFunction" ], identifier : str
370
+ ) -> "BaseContractFunction" :
371
+ raise NotImplementedError (
372
+ "This method should be implemented in the inherited class"
373
+ )
374
+
367
375
@staticmethod
368
376
def get_fallback_function (
369
377
abi : ABI ,
@@ -947,7 +955,7 @@ def _get_event_filter_params(
947
955
blkhash_set = blockHash is not None
948
956
blknum_set = fromBlock is not None or toBlock is not None
949
957
if blkhash_set and blknum_set :
950
- raise ValidationError (
958
+ raise Web3ValidationError (
951
959
"blockHash cannot be set at the same time as fromBlock or toBlock"
952
960
)
953
961
@@ -972,6 +980,26 @@ def _get_event_filter_params(
972
980
def factory (cls , class_name : str , ** kwargs : Any ) -> PropertyCheckingFactory :
973
981
return PropertyCheckingFactory (class_name , (cls ,), kwargs )
974
982
983
+ @staticmethod
984
+ def check_for_forbidden_api_filter_arguments (
985
+ event_abi : ABIEvent , _filters : Dict [str , Any ]
986
+ ) -> None :
987
+ name_indexed_inputs = {_input ["name" ]: _input for _input in event_abi ["inputs" ]}
988
+
989
+ for filter_name , filter_value in _filters .items ():
990
+ _input = name_indexed_inputs [filter_name ]
991
+ if is_array_type (_input ["type" ]):
992
+ raise TypeError (
993
+ "createFilter no longer supports array type filter arguments. "
994
+ "see the build_filter method for filtering array type filters."
995
+ )
996
+ if is_list_like (filter_value ) and is_dynamic_sized_type (_input ["type" ]):
997
+ raise TypeError (
998
+ "createFilter no longer supports setting filter argument options "
999
+ "for dynamic sized types. See the build_filter method for setting "
1000
+ "filters with the match_any method."
1001
+ )
1002
+
975
1003
@combomethod
976
1004
def _set_up_filter_builder (
977
1005
self ,
@@ -994,7 +1022,7 @@ def _set_up_filter_builder(
994
1022
995
1023
event_abi = self ._get_event_abi ()
996
1024
997
- check_for_forbidden_api_filter_arguments (event_abi , _filters )
1025
+ self . check_for_forbidden_api_filter_arguments (event_abi , _filters )
998
1026
999
1027
_ , event_filter_params = construct_event_filter_params (
1000
1028
self ._get_event_abi (),
@@ -1137,35 +1165,3 @@ def call_function(
1137
1165
block_identifier = block_identifier ,
1138
1166
ccip_read_enabled = ccip_read_enabled ,
1139
1167
)
1140
-
1141
-
1142
- def check_for_forbidden_api_filter_arguments (
1143
- event_abi : ABIEvent , _filters : Dict [str , Any ]
1144
- ) -> None :
1145
- name_indexed_inputs = {_input ["name" ]: _input for _input in event_abi ["inputs" ]}
1146
-
1147
- for filter_name , filter_value in _filters .items ():
1148
- _input = name_indexed_inputs [filter_name ]
1149
- if is_array_type (_input ["type" ]):
1150
- raise TypeError (
1151
- "createFilter no longer supports array type filter arguments. "
1152
- "see the build_filter method for filtering array type filters."
1153
- )
1154
- if is_list_like (filter_value ) and is_dynamic_sized_type (_input ["type" ]):
1155
- raise TypeError (
1156
- "createFilter no longer supports setting filter argument options for "
1157
- "dynamic sized types. See the build_filter method for setting "
1158
- "filters with the match_any method."
1159
- )
1160
-
1161
-
1162
- def get_function_by_identifier (
1163
- fns : Sequence [BaseContractFunction ], identifier : str
1164
- ) -> BaseContractFunction :
1165
- if len (fns ) > 1 :
1166
- raise ValueError (
1167
- f"Found multiple functions with matching { identifier } . " f"Found: { fns !r} "
1168
- )
1169
- elif len (fns ) == 0 :
1170
- raise ValueError (f"Could not find any function with matching { identifier } " )
1171
- return fns [0 ]
0 commit comments