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

Decoder incorrectly adds named item to array result #220

Closed
MicahZoltu opened this issue Jun 30, 2018 · 2 comments
Closed

Decoder incorrectly adds named item to array result #220

MicahZoltu opened this issue Jun 30, 2018 · 2 comments
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published.

Comments

@MicahZoltu
Copy link

When decoding an array of tuples, the name of the array is used as the name of the first array item in the resulting datastructure.

import { Wallet, providers, Contract, utils } from 'ethers'
const abi = [{"components":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"items","type":"tuple[]"}]
const encoded = '0x' +
'0000000000000000000000000000000000000000000000000000000000000020' +
'0000000000000000000000000000000000000000000000000000000000000002' +
'0000000000000000000000000000000000000000000000000000000000000003' +
'0000000000000000000000000000000000000000000000000000000000000004' +
'0000000000000000000000000000000000000000000000000000000000000005' +
'0000000000000000000000000000000000000000000000000000000000000006'
const result = new utils.AbiCoder().decode(abi, encoded)
console.log(result.items.items === undefined) // true

It is expected that the structure of the result would be result.items[0] and result.items[1].

Note: One can simply ignore the result.items.items but it is confusing when looking at the data in a debugger or printing it. And as always, it is a bug so could cause other problems down the road if not fixed.

@ricmoo ricmoo added bug Verified to be an issue. on-deck This Enhancement or Bug is currently being worked on. v4.0 labels Jul 1, 2018
@ricmoo
Copy link
Member

ricmoo commented Jul 1, 2018

This does seem to be a bug, and looks related to a bug I thought I'd fixed a month ago.

I will look into this and make sure it is fixed before the v4 release later this week.

Update: This was fixed in the v3 branch, but missed the v4 branch. It has been added. :)

@ricmoo ricmoo removed the on-deck This Enhancement or Bug is currently being worked on. label Jul 1, 2018
@ricmoo
Copy link
Member

ricmoo commented Jul 1, 2018

This has been fixed in the latest version.

Thanks! :)

@ricmoo ricmoo closed this as completed Jul 1, 2018
@ricmoo ricmoo added the fixed/complete This Bug is fixed or Enhancement is complete and published. label Jan 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published.
Projects
None yet
Development

No branches or pull requests

2 participants