abi v0.1.0 ABI.FunctionSelector

Module to help parse the ABI function signatures, e.g. my_function(uint64, string[]).

Link to this section Summary

Functions

Decodes a function selector to struct. This is a simple version and we may opt to do format parsing later

Encodes a function call signature

Link to this section Types

Link to this type t()
t() :: %ABI.FunctionSelector{function: String.t(), returns: type(), types: [type()]}
Link to this type type()
type() :: {:uint, integer()} | :bool

Link to this section Functions

Link to this function decode(signature)

Decodes a function selector to struct. This is a simple version and we may opt to do format parsing later.

Examples

iex> ABI.FunctionSelector.decode("bark(uint256,bool)")
%ABI.FunctionSelector{
  function: "bark",
  types: [
    {:uint, 256},
    :bool
  ]
}

iex> ABI.FunctionSelector.decode("growl(uint,address,string[])")
%ABI.FunctionSelector{
  function: "growl",
  types: [
    {:uint, 256},
    :address,
    {:array, :string}
  ]
}
Link to this function decode_type(els)
Link to this function encode(function_selector)

Encodes a function call signature.

Examples

iex> ABI.FunctionSelector.encode(%ABI.FunctionSelector{
...>   function: "bark",
...>   types: [
...>     {:uint, 256},
...>     :bool,
...>     {:array, :string}
...>   ]
...> })
"bark(uint256,bool,string[])"