From 06a8f941a196430b00636571337f86e98d20a4e2 Mon Sep 17 00:00:00 2001 From: Stuart Reed Date: Mon, 25 Mar 2024 12:35:18 -0600 Subject: [PATCH 1/2] Fix typing, remove @curry --- web3/_utils/events.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/web3/_utils/events.py b/web3/_utils/events.py index da2a91a81a..e756db3d09 100644 --- a/web3/_utils/events.py +++ b/web3/_utils/events.py @@ -29,6 +29,7 @@ from eth_typing import ( ChecksumAddress, HexStr, + Primitives, TypeStr, ) from eth_utils import ( @@ -99,9 +100,8 @@ ) -@curry def _log_entry_data_to_bytes( - log_entry_data: Union[HexStr, str, bytes, bytearray], + log_entry_data: Union[Primitives, HexStr, str], ) -> bytes: return hexstr_if_str(to_bytes, log_entry_data) @@ -242,15 +242,15 @@ def get_event_data( else: log_topics = log_entry["topics"][1:] - log_topics = [_log_entry_data_to_bytes(topic) for topic in log_topics] + log_topics_bytes = [_log_entry_data_to_bytes(topic) for topic in log_topics] log_topics_abi = get_indexed_event_inputs(event_abi) log_topic_normalized_inputs = normalize_event_input_types(log_topics_abi) log_topic_types = get_event_abi_types_for_decoding(log_topic_normalized_inputs) log_topic_names = get_abi_input_names(ABIEvent({"inputs": log_topics_abi})) - if len(log_topics) != len(log_topic_types): + if len(log_topics_bytes) != len(log_topic_types): raise LogTopicError( - f"Expected {len(log_topic_types)} log topics. Got {len(log_topics)}" + f"Expected {len(log_topic_types)} log topics. Got {len(log_topics_bytes)}" ) log_data = _log_entry_data_to_bytes(log_entry["data"]) @@ -279,7 +279,7 @@ def get_event_data( decoded_topic_data = [ abi_codec.decode([topic_type], topic_data)[0] - for topic_type, topic_data in zip(log_topic_types, log_topics) + for topic_type, topic_data in zip(log_topic_types, log_topics_bytes) ] normalized_topic_data = map_abi_data( BASE_RETURN_NORMALIZERS, log_topic_types, decoded_topic_data From b0c434f430b0208441f7c30ae33999380f7b7ba0 Mon Sep 17 00:00:00 2001 From: Stuart Reed Date: Mon, 25 Mar 2024 13:38:15 -0600 Subject: [PATCH 2/2] Newsfragment for #3301 --- newsfragments/3301.internal.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 newsfragments/3301.internal.rst diff --git a/newsfragments/3301.internal.rst b/newsfragments/3301.internal.rst new file mode 100644 index 0000000000..0bf067d41b --- /dev/null +++ b/newsfragments/3301.internal.rst @@ -0,0 +1 @@ +Fix internal typing for functions used by ``process_log``. \ No newline at end of file