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

Loading…
Cancel
Save