Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

abi.solidityPack does not work with array #70

Open
gonglinyuan opened this issue Dec 14, 2018 · 1 comment
Open

abi.solidityPack does not work with array #70

gonglinyuan opened this issue Dec 14, 2018 · 1 comment

Comments

@gonglinyuan
Copy link

> abi.solidityPack(['int32[]', 'bytes8', 'address'], [[0, 0], '0x123456', '0x14723a09acff6d2a60dcdf7aa4aff308fddc160c'])
TypeError: Cannot read property '1' of null
    at parseTypeN (C:\Users\gonglinyuan\node_modules\ethereumjs-abi\lib\index.js:42:42)
    at Function.ABI.solidityPack (C:\Users\gonglinyuan\node_modules\ethereumjs-abi\lib\index.js:467:14)
> abi.solidityPack(['bytes8', 'address'], ['0x123456', '0x14723a09acff6d2a60dcdf7aa4aff308fddc160c'])
<Buffer 12 34 56 00 00 00 00 00 14 72 3a 09 ac ff 6d 2a 60 dc df 7a a4 af f3 08 fd dc 16 0c>

As you can see, solidityPack works perfectly well when there are no array in the parameters. But with 'int32[]', it fails.

@Alonzo-Coeus
Copy link

Alonzo-Coeus commented Jun 27, 2019

seems to be due to the function parseTypeN which they use for packing ints and uints. It thinks the list/array is actually a number as the check for type is type.startsWith('uint') which would obviously cause problems.
TLDR; The type checking code thinks that the array of parameters is actually a scalar value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants