Giter Club home page Giter Club logo

abi's People

Contributors

atoulme avatar dingpl716 avatar hayesgm avatar paulperegud avatar tsutsu avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

abi's Issues

Encoding Dynamic Arrays missing location

It seems the encoding for dynamic arrays is missing the placeholder for the location. Currently the output is this:

ABI.encode("dynamicUint(uint[])", [[1,2,3,4,5]]) |> Hexate.encode


=> "5d4e0342000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000005"

Whereas I believe it should be something like this:

"5d4e03420000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000005"

Notice the 0000000000000000000000000000000000000000000000000000000000000020 preceding the length prefix. This is denoting that the dynamic array starts after 32 bytes. Since there is only one argument.

Decoding function arguments from data for dynamic types

I was trying to get the function arguments for a function with bytes32[] as the argument type.

ABI.decode goes into an infinite loop.

Is this not supported yet?

The command I tried:

ABI.decode("myTempFunction(bytes32[],bytes32[])", "4251d89700000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000176a5ced4b86db8f44cb702405947e3d0b672980608810bb4d922702bbe1809440000000000000000000000000000000000000000000000000000000000000001e1ba3868e0fb3c2af6ad53db380ac069165eb51ae5b6f5ea3f574c2f79b81a08" |> Base.decode16!(case: :lower))

Invalid encoding of dynamic types

Hi,
thanks for exthereum/abi. When using it I've noticed that calls to functions with arguments of dynamic types are not properly encoded.

ABI.encode("foo(bytes)", [<<1>>]) |> Base.encode16(case: :lower)
outputs
"30c8d1da00000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000"
The correct output is:
"30c8d1da000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000"
The missing part is:
0000000000000000000000000000000000000000000000000000000000000020
which is a head part of encoded bytes and should be put right behind encoded function signature.
https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI#use-of-dynamic-types

Invalid encode of string

Invalid encoding result.
ABI.encode("getVerificationContract(string)", ["test"]) |> Base.encode16(case: :lower)
Expected:

0x8575e5a5000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000047465737400000000000000000000000000000000000000000000000000000000

Returned

8575e5a500000000000000000000000000000000000000000000000000000000000000047465737400000000000000000000000000000000000000000000000000000000

Address type as string, not :uint 160

Hi there! Thanks for library!
We've faced issue that :address type is converted to uint 160 and it throws message:
Data overflow encoding uint, data 0x56e19818ba7e4c0335a4cbf82ee6530c89a30735 cannot fit in 160 bits
It happens here: lib/quorum/abi/type_encoder.ex:239: Quorum.ABI.TypeEncoder.encode_uint/2
Actually we are using quorum, so it may be connected somehow with this bug..
So, we need not to convert address to uint

Now it's solved with converting address to int, but result data generates incorrectly

{address_hex, _} = Integer.parse(address, 16)
address_hex

Got on_load_function_failed when trying to start release.

Hi.
Cannot start release with compiled :libsecp256k1 library.
Release failed on docker container with Alpine and local Mac.
I don't see libsecp256k1_nif.so in priv dir. Could it raise an error?

{supervisor,kernel,['Argument__1']}
<0.1384.0>
[]
{exit,{on_load_function_failed,libsecp256k1},[{init,run_on_load_handlers,0,[]},{kernel,init,1,[{file,"kernel.erl"},{line,217}]},{supervisor,init,1,[{file,"supervisor.erl"},{line,294}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,365}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,333}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]}
    initial_call:     pid:     registered_name:     error_info:     ancestors:     message_queue_len:     messages:     links:     dictionary:     trap_exit:     status:     heap_size:     stack_size:     reductions: 2018-06-04 14:21:43 supervisor_report   
[kernel_sup,<0.1360.0>]
0
[]
[<0.1361.0>]
[]
true
running
610
27
235
{local,kernel_sup}
start_error
{on_load_function_failed,libsecp256k1}
[{pid,undefined},{id,kernel_safe_sup},{mfargs,{supervisor,start_link,[{local,kernel_safe_sup},kernel,safe]}},{restart_type,permanent},{shutdown,infinity},{child_type,supervisor}]
{application_master,init,['Argument__1','Argument__2','Argument__3','Argument__4']}
    supervisor:     errorContext:     reason:     offender: 2018-06-04 14:21:44 crash_report        
<0.1359.0>
[]
{exit,{{shutdown,{failed_to_start_child,kernel_safe_sup,{on_load_function_failed,libsecp256k1}}},{kernel,start,[normal,[]]}},[{application_master,init,4,[{file,"application_master.erl"},{line,134}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]}
[<0.1358.0>]
1
[{'EXIT',<0.1360.0>,normal}]
[<0.1358.0>,<0.1357.0>]
[]
true
running
376
27
213
    initial_call:     pid:     registered_name:     error_info:     ancestors:     message_queue_len:     messages:     links:     dictionary:     trap_exit:     status:     heap_size:     stack_size:     reductions: 2018-06-04 14:21:44 std_info            
kernel
{{shutdown,{failed_to_start_child,kernel_safe_sup,{on_load_function_failed,libsecp256k1}}},{kernel,start,[normal,[]]}}
permanent
{"Kernel pid terminated",application_controller,"{application_start_failure,kernel,{{shutdown,{failed_to_start_child,kernel_safe_sup,{on_load_function_failed,libsecp256k1}}},{kernel,start,[normal,[]]}}}"}
    application:     exited:     type: Kernel pid terminated (application_controller) ({application_start_failure,kernel,{{shutdown,{failed_to_start_child,kernel_safe_sup,{on_load_function_failed,libsecp256k1}}},{kernel,start,[normal,[]]}}
Crash dump is being written to: erl_crash.dump...done```

Unable to decode int

Receiving this error when I try to output an int from a contract method:

** (RuntimeError) Unsupported decoding type: {:int, 256}
    lib/abi/type_decoder.ex:241: ABI.TypeDecoder.decode_type/2
    lib/abi/type_decoder.ex:219: anonymous fn/2 in ABI.TypeDecoder.decode_type/2

Here is a contract method that I'm failing on:

    function getInt() public pure returns (int) {                                                                                                                      
        return (40 - 100);                                                                                                                                             
    }

Cannot compile on Mac OSX

===> Compiling libsecp256k1
HEAD is now at d333521 Merge #494: Support OpenSSL versions >= 1.1 for ENABLE_OPENSSL_TESTS
Can't exec "/opt/local/bin/aclocal": No such file or directory at /opt/local/share/autoconf/Autom4te/FileUtils.pm line 326.
autoreconf: failed to run /opt/local/bin/aclocal: No such file or directory
===> Hook for compile failed!

ProductName: Mac OS X
ProductVersion: 10.13.6
BuildVersion: 17G65

automake: stable 1.16.1 (bottled)

Is there a way to build the ABI deps on Mac OSX?

Fail to encode long string

Hello, dear developer!
Library fails when try to encode (and the same with decoding) long string

Here is sample:

function_selector = %FunctionSelector{
  function: "setAccountFieldMainData",
  returns: nil,
  types: [:string, :string]
}
params = [{String.duplicate("1234567890", 10), "string"}]

ABI.encode(function_selector, params)

Suppose it's enough info to reproduce
Thank you for your time

license

no license on which software is made available

encode bytes32 error

Below is the function signature in solidity:

get(bytes32)

I tried the following:

ABI.TypeEncoder.encode_raw([{"63cb2f697029ee491b58939796e9013087104b816ce0f51e731e9b03cc50c3b9"}], [{:tuple, [bytes: 32]}])

to which I get the following error:

** (RuntimeError) size mismatch for bytes32: "63cb2f697029ee491b58939796e9013087104b816ce0f51e731e9b03cc50c3b9"
    lib/abi/type_encoder.ex:178: ABI.TypeEncoder.encode_type/2

This is because here: https://github.com/exthereum/abi/blob/master/lib/abi/type_encoder.ex#L173 , the size required will be less than or equal to 32, since the function signature has bytes32.

Am I providing the wrong input? Am I required to encode the hex string into another format that will be accepted in TypeEncoder.encode_raw? I couldn't find a relevant example in the docs.

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.