4
0
Fork 0

Reformat function ExW3.reformat_abi/1

pull/11/head
Piotr Żelazko 6 years ago
parent 84c41b5d37
commit 4a8487ae1d
No known key found for this signature in database
GPG Key ID: 27E11A19853A7913
  1. 25
      lib/exw3.ex

@ -188,16 +188,11 @@ defmodule ExW3 do
@spec reformat_abi([]) :: %{} @spec reformat_abi([]) :: %{}
@doc "Reformats abi from list to map with event and function names as keys" @doc "Reformats abi from list to map with event and function names as keys"
def reformat_abi(abi) do def reformat_abi(abi) do
Map.new(Enum.map(
abi, abi
fn x -> |> Enum.map(&map_abi/1)
case {x["name"], x["type"]} do |> Map.new
{nil, "constructor"} -> {"constructor", x}
{nil, "fallback"} -> {"fallback", x}
{name, _} -> {x["name"], x}
end
end
))
end end
@spec load_abi(binary()) :: [] @spec load_abi(binary()) :: []
@ -304,6 +299,16 @@ defmodule ExW3 do
end end
end end
# ABI mapper
defp map_abi(x) do
case {x["name"], x["type"]} do
{nil, "constructor"} -> {"constructor", x}
{nil, "fallback"} -> {"fallback", x}
{name, _} -> {name, x}
end
end
defmodule Poller do defmodule Poller do
use GenServer use GenServer

Loading…
Cancel
Save