Skip to content

Commit

Permalink
Type fixes
Browse files Browse the repository at this point in the history
* Specify type for abi event
* Fix lint
  • Loading branch information
reedsa committed May 1, 2024
1 parent 1b27b51 commit 66fb46d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ens/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
TYPE_CHECKING,
Any,
Collection,
Dict,
List,
Optional,
Sequence,
Expand Down Expand Up @@ -60,6 +59,7 @@
from eth_typing import ( # noqa: F401
ABIFunction,
)

from web3 import ( # noqa: F401
AsyncWeb3,
Web3 as _Web3,
Expand Down
2 changes: 1 addition & 1 deletion web3/_utils/abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def _align_abi_input(arg_abi: ABIFunctionParam, arg: Any) -> Tuple[Any, ...]:
new_abi = copy.copy(arg_abi)
new_abi["type"] = tuple_prefix + "[]" * (num_dims - 1)

sub_abis = itertools.repeat(new_abi) # type: ignore
sub_abis = itertools.repeat(new_abi)

if isinstance(arg, abc.Mapping):
# Arg is mapping. Align values according to abi order.
Expand Down
8 changes: 6 additions & 2 deletions web3/_utils/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ def get_event_data(
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}))
log_topic_names = get_abi_input_names(
ABIEvent({"type": "event", "inputs": log_topics_abi})
)

if len(log_topics_bytes) != len(log_topic_types):
raise LogTopicError(
Expand All @@ -258,7 +260,9 @@ def get_event_data(
log_data_abi = exclude_indexed_event_inputs(event_abi)
log_data_normalized_inputs = normalize_event_input_types(log_data_abi)
log_data_types = get_event_abi_types_for_decoding(log_data_normalized_inputs)
log_data_names = get_abi_input_names(ABIEvent({"inputs": log_data_abi}))
log_data_names = get_abi_input_names(
ABIEvent({"type": "event", "inputs": log_data_abi})
)

# sanity check that there are not name intersections between the topic
# names and the data argument names.
Expand Down
2 changes: 1 addition & 1 deletion web3/utils/abi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from eth_utils import (
from eth_utils.abi import ( # NOQA
event_abi_to_log_topic,
event_signature_to_log_topic,
function_abi_to_4byte_selector,
Expand Down

0 comments on commit 66fb46d

Please sign in to comment.