Refactor docstrings and comments

This commit is contained in:
Fedor Ivanov 2024-03-12 12:19:43 +00:00
parent 27299ad667
commit 13a0060b39
No known key found for this signature in database
2 changed files with 24 additions and 3 deletions

View File

@ -182,8 +182,28 @@ defmodule ABI.FunctionSelector do
"outputs" => named_outputs
} <-
item
# Workaround for missing "outputs" field.
# This is a fix for https://github.com/poanetwork/ex_abi/issues/162
# Workaround for ABIs that are missing the "outputs" field.
#
# For instance, consider this valid ABI:
#
# ```jsonc
# // ...
# {
# "type": "function",
# "stateMutability": "view",
# "name": "assumeLastTokenIdMatches",
# "inputs": [
# {
# "type": "uint256",
# "name": "lastTokenId",
# "internalType": "uint256"
# }
# ]
# },
# // ...
# ```
# If the "outputs" field is missing, we should assume it's an empty
# list to continue parsing the ABI.
|> Map.put_new("outputs", []),
true <- simple_types?(named_inputs, item),
true <- simple_types?(named_outputs, item) do

View File

@ -113,7 +113,8 @@ defmodule ABI.FunctionSelectorTest do
end
@doc """
Regression test for issue #162 (https://github.com/poanetwork/ex_abi/issues/162).
Regression test to verify the correct parsing of ABIs that lack the
"outputs" field.
"""
test "with the missing outputs field" do
abi = [