66import itertools
77
88from eth_abi import (
9- encode_single ,
109 grammar ,
1110)
1211from eth_typing import (
@@ -268,12 +267,13 @@ class EventFilterBuilder:
268267 _address = None
269268 _immutable = False
270269
271- def __init__ (self , event_abi , formatter = None ):
270+ def __init__ (self , event_abi , abi_codec , formatter = None ):
272271 self .event_abi = event_abi
272+ self .abi_codec = abi_codec
273273 self .formatter = formatter
274274 self .event_topic = initialize_event_topics (self .event_abi )
275275 self .args = AttributeDict (
276- _build_argument_filters_from_event_abi (event_abi ))
276+ _build_argument_filters_from_event_abi (event_abi , abi_codec ))
277277 self ._ordered_arg_names = tuple (arg ['name' ] for arg in event_abi ['inputs' ])
278278
279279 @property
@@ -376,11 +376,11 @@ def initialize_event_topics(event_abi):
376376
377377
378378@to_dict
379- def _build_argument_filters_from_event_abi (event_abi ):
379+ def _build_argument_filters_from_event_abi (event_abi , abi_codec ):
380380 for item in event_abi ['inputs' ]:
381381 key = item ['name' ]
382382 if item ['indexed' ] is True :
383- value = TopicArgumentFilter (arg_type = item ['type' ])
383+ value = TopicArgumentFilter (abi_codec , arg_type = item ['type' ])
384384 else :
385385 value = DataArgumentFilter (arg_type = item ['type' ])
386386 yield key , value
@@ -431,6 +431,10 @@ def match_values(self):
431431
432432
433433class TopicArgumentFilter (BaseArgumentFilter ):
434+ def __init__ (self , arg_type , abi_codec ):
435+ self .abi_codec = abi_codec
436+ self .arg_type = arg_type
437+
434438 @to_tuple
435439 def _get_match_values (self ):
436440 yield from (self ._encode (value ) for value in self ._match_values )
@@ -446,7 +450,7 @@ def _encode(self, value):
446450 if is_dynamic_sized_type (self .arg_type ):
447451 return to_hex (keccak (encode_single_packed (self .arg_type , value )))
448452 else :
449- return to_hex (encode_single (self .arg_type , value ))
453+ return to_hex (self . abi_codec . encode_single (self .arg_type , value ))
450454
451455
452456class EventLogErrorFlags (Enum ):
0 commit comments