exw3
exw3 copied to clipboard
Problem with ABI.TypeDecoder
Hi!
I have a problem with ExW3.Contract.call method and ABI.TypeDecoder.decode_type.
Solidity function:
function get_DFA(uint dfaID) public returns (DFA memory) { DFA storage dfa = dfa_pool[dfaID]; return dfa; }
Elixir function:
def sc_call(sc_abi_path, sc_address, sc_name, sc_method, sc_method_args \\ []) do
ExW3.Contract.start_link()
sc_abi = ExW3.Abi.load_abi(sc_abi_path)
ExW3.Contract.register(String.to_atom(sc_name), abi: sc_abi)
ExW3.Contract.at(String.to_atom(sc_name), sc_address)
ExW3.Contract.call(String.to_atom(sc_name), String.to_atom(sc_method), sc_method_args)
end
When I call this method from ElixirApp, I get a error
ElixirApp.Utils.Ethereum.sc_call("data/DFAPool.abi", "0x39Df1178CCBeC6d48A81969b6f67f13F3B4CC6E3", "DFAPool", "get_DFA", [1])
00:35:02.056 [error] GenServer ContractManager terminating ** (FunctionClauseError) no function clause matching in ABI.TypeDecoder.decode_type/2 (ex_abi 0.5.3) lib/abi/type_decoder.ex:244: ABI.TypeDecoder.decode_type(:tuple, <<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...>>) (ex_abi 0.5.3) lib/abi/type_decoder.ex:270: anonymous fn/3 in ABI.TypeDecoder.decode_type/2 (elixir 1.11.4) lib/enum.ex:2193: Enum."-reduce/3-lists^foldl/2-0-"/3 (ex_abi 0.5.3) lib/abi/type_decoder.ex:265: ABI.TypeDecoder.decode_type/2 (ex_abi 0.5.3) lib/abi/type_decoder.ex:189: anonymous fn/3 in ABI.TypeDecoder.do_decode_raw/2 (elixir 1.11.4) lib/enum.ex:2193: Enum."-reduce/3-lists^foldl/2-0-"/3 (ex_abi 0.5.3) lib/abi/type_decoder.ex:184: ABI.TypeDecoder.do_decode_raw/2 (ex_abi 0.5.3) lib/abi/type_decoder.ex:178: ABI.TypeDecoder.decode_raw/2 Last message (from #PID<0.255.0>): {:call, {:DFAPool, :get_DFA, [1]}}
I don't understand what's happened.
This looks similar to a bug I fixed in ex_abi
https://github.com/poanetwork/ex_abi/pull/61. Can you upgrade to ex_abi
v0.5.5 and lmk if it fixes your problem?
How are you encoding the Base 16?