exw3 icon indicating copy to clipboard operation
exw3 copied to clipboard

ABI function calls with output type "string" Decode (MatchError)

Open willjleong opened this issue 3 years ago • 2 comments

I'm trying to call an abi's :symbol method in an erc721 smartcontract but get an error whenever I call a method that returns and abi function output with "string" type. Methods that return address or uint256 work fine... Is this an issue with exw3 or ex_abi? I noticed that this repo doesn't test for smart-contracts calls that have return outputs of "string"

GenServer ContractManager terminating
** (MatchError) no match of right hand side value: <<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.5) lib/abi/type_decoder.ex:238: ABI.TypeDecoder.decode_bytes/4
    (ex_abi 0.5.5) lib/abi/type_decoder.ex:333: anonymous fn/3 in ABI.TypeDecoder.decode_type/3
    (elixir 1.11.4) lib/enum.ex:2193: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ex_abi 0.5.5) lib/abi/type_decoder.ex:331: ABI.TypeDecoder.decode_type/3
    (ex_abi 0.5.5) lib/abi/type_decoder.ex:188: 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.5) lib/abi/type_decoder.ex:185: ABI.TypeDecoder.do_decode_raw/2
    (ex_abi 0.5.5) lib/abi/type_decoder.ex:179: ABI.TypeDecoder.decode_raw/2
    (exw3 0.6.0) lib/exw3/abi.ex:52: ExW3.Abi.decode_output/3
    (exw3 0.6.0) lib/exw3/contract.ex:214: ExW3.Contract.eth_call_helper/4
    (exw3 0.6.0) lib/exw3/contract.ex:480: ExW3.Contract.handle_call/3
    (stdlib 3.14.2.1) gen_server.erl:715: :gen_server.try_handle_call/4
    (stdlib 3.14.2.1) gen_server.erl:744: :gen_server.handle_msg/6
    (stdlib 3.14.2.1) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message (from #PID<0.639.0>): {:call, {:"0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D", :symbol, []}}

This issues is occurring on this line when the output decoded type is "string" https://github.com/hswick/exw3/blob/master/lib/exw3/abi.ex#L49

willjleong avatar Sep 25 '21 20:09 willjleong

I'm seeing similar errors. I'm under the impression it's a problem with ex_abi?

gregors avatar Dec 09 '21 19:12 gregors

@willjleong I'm curious if my PR fixes your issue - https://github.com/hswick/exw3/pull/107

gregors avatar Dec 14 '21 15:12 gregors