Giter VIP home page Giter VIP logo

web3x's People

Contributors

aguxez avatar ayrat555 avatar chrisplim avatar dependabot[bot] avatar dsummers91 avatar hengestone avatar hswick avatar mjia-catalx avatar mosic avatar pik694 avatar rupurt avatar timjp87 avatar willjleong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

web3x's Issues

Contract calls that return multiple arrays raise an error when decoding result

Web3x.Contract.call/3 raises with certain output signatures, particularly when the output type is (uint256[],string[]).

When calling ABI.decode/3 with the function selector struct, and when calling ABI.decode/2 with the signature string syntax it decodes correctly:

ABI.decode(fs, output_data, :output)
[[1], ["bar"]]

ABI.decode("foo(uint256[],string[])", output_data)
[[1], ["bar"]]

When using the Web3x.Contract module, the following is eventually called within Web3.Abi.decode_output/3:

ABI.decode("foo((uint256[],string[]))", output_data)

which raises with the following stack trace:

** (MatchError) no match of right hand side value: <<99, 115, 120, 99, 121, 100, 106, 121, 52, 51, 108, 109, 102, 119, 101, 117, 105, 50, 50, 121, 121, 105, 102, 50, 107, 117, 0, 0, 0, 0, 0>>
    (ex_abi 0.5.11) lib/abi/type_decoder.ex:371: ABI.TypeDecoder.decode_uint/2
    (ex_abi 0.5.11) lib/abi/type_decoder.ex:271: anonymous fn/3 in ABI.TypeDecoder.decode_type/2
    (elixir 1.13.0) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ex_abi 0.5.11) lib/abi/type_decoder.ex:266: ABI.TypeDecoder.decode_type/2
    (ex_abi 0.5.11) lib/abi/type_decoder.ex:311: ABI.TypeDecoder.decode_type/3
    (ex_abi 0.5.11) lib/abi/type_decoder.ex:333: anonymous fn/3 in ABI.TypeDecoder.decode_type/3
    (elixir 1.13.0) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ex_abi 0.5.11) lib/abi/type_decoder.ex:331: ABI.TypeDecoder.decode_type/3
    (ex_abi 0.5.11) lib/abi/type_decoder.ex:188: anonymous fn/3 in ABI.TypeDecoder.do_decode_raw/2
    (elixir 1.13.0) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ex_abi 0.5.11) lib/abi/type_decoder.ex:185: ABI.TypeDecoder.do_decode_raw/2
    (ex_abi 0.5.11) lib/abi/type_decoder.ex:179: ABI.TypeDecoder.decode_raw/2

The following lines I believe are the problem, as it wraps the output signature in a another set of parentheses.

output_types = Enum.map(abi[name]["outputs"], fn x -> x["type"] end)
types_signature = format_output_type_signatures(output_types)
output_signature = "#{name}(#{types_signature})"

output_signature ends up being "foo((uint256[],string[]))" instead of "foo(uint256[],string[])". At least in this case when the types are uint256[] and string[], this raises an error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.