Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🩹 use arg.get in get_abi_input_names and get_abi_output_names #299

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions eth_utils/abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ def get_aligned_abi_inputs(
)


def get_abi_input_names(abi_element: ABIElement) -> List[str]:
def get_abi_input_names(abi_element: ABIElement) -> List[str | None]:
"""
Return names for each input from the function or event ABI.

Expand Down Expand Up @@ -643,7 +643,7 @@ def get_abi_input_names(abi_element: ABIElement) -> List[str]:
"""
_raise_if_fallback_or_receive_abi(abi_element)
return [
arg["name"]
arg.get("name", None)
for arg in cast(Sequence[ABIComponent], abi_element.get("inputs", []))
]

Expand Down Expand Up @@ -684,7 +684,7 @@ def get_abi_input_types(abi_element: ABIElement) -> List[str]:
]


def get_abi_output_names(abi_element: ABIElement) -> List[str]:
def get_abi_output_names(abi_element: ABIElement) -> List[str | None]:
"""
Return names for each output from the ABI element.

Expand Down Expand Up @@ -724,7 +724,7 @@ def get_abi_output_names(abi_element: ABIElement) -> List[str]:
"""
_raise_if_not_function_abi(abi_element)
return [
arg["name"]
arg.get("name", None)
for arg in cast(Sequence[ABIComponent], abi_element.get("outputs", []))
]

Expand Down
1 change: 1 addition & 0 deletions newsfragments/299.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
replace ``arg["name"]`` with ``arg.get("name")`` to correctly handle optional names