poanetwork / ex_abi

The Ethereum ABI Interface
GNU General Public License v3.0
61 stars 43 forks source link

`ABI.parse_specification` ignores function objects without `outputs` field #162

Closed fedor-ivn closed 8 months ago

fedor-ivn commented 8 months ago

Recently we came across such a contract, where one of the methods (assumeLastTokenIdMatches) does not have an array of outputs in its ABI:

// ...
    {
        "type": "function",
        "stateMutability": "view",
        "name": "assumeLastTokenIdMatches",
        "inputs": [
            {
                "type": "uint256",
                "name": "lastTokenId",
                "internalType": "uint256"
            }
        ]
    },
// ...

If I try to parse this ABI using ABI.parse_specification, the function assumeLastTokenIdMatches is skipped:

iex(1)> File.read!("contract-abi.json") |> Jason.decode! |> ABI.parse_specification |> Enum.filter(fn %ABI.FunctionSelector{function: name} -> name == "assumeLastTokenIdMatches" end)
[]

contract-abi.json

Possibly, the problem is somewhere here:

https://github.com/poanetwork/ex_abi/blob/5d63e8a7fefc1428b86bb699de53bc4b9bb41744/lib/abi/function_selector.ex#L179-L183