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

Calling structs incorrectly decodes non-32-byte data #421

Closed
ckeenan opened this issue Apr 4, 2016 · 3 comments
Closed

Calling structs incorrectly decodes non-32-byte data #421

ckeenan opened this issue Apr 4, 2016 · 3 comments
Assignees
Labels
0.x.x Bug Addressing a bug

Comments

@ckeenan
Copy link

ckeenan commented Apr 4, 2016

A struct with bytesX where X < 32 will overflow the subsequent fields of the struct when called via web3. Placing the bytesX type last will work, however (if it is the only one of its kind in the struct). Using web3@0.15.3

For example

struct SomeStruct {
    bytes2 testB;
    bytes32 testA;
}

testStruct = SomeStruct({
    testA: 0x0c98fceab753c7528a29469e19c7901cab3e987b379bf0627c4027ef0a6993c4,
    testB: 0x1210
});

testStruct will return [ '0x1210', '0x0000000000000000000000000000000000000000000000000000000000000c98' ] when accessed

reversing the field order results in correct values

struct SomeStruct {
    bytes32 testA;
    bytes2 testB;
}
@frozeman
Copy link
Contributor

frozeman commented Apr 4, 2016

@chriseth

@frozeman frozeman added the Bug Addressing a bug label Apr 4, 2016
@ckeenan
Copy link
Author

ckeenan commented Apr 7, 2016

I see this with LOGs too. For example event Test(bytes2 testA, bytes32 testB); results in args values of:

{ testA: '0x1234',
  testB: '0x0000000000000000000000000000000000000000000000000000000000003ac2' }

while event Test(bytes32 testB, bytes2 testA); will show correct arg values

@nivida
Copy link
Contributor

nivida commented Mar 25, 2019

Version 0.20.x got his last maintenance release with v0.20.7. Please update your code to the latest 1.0 version of Web3.js. Further details about the current project state are explained in the release announcement of version 1.0.0-beta.38.

@nivida nivida closed this as completed Mar 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.x.x Bug Addressing a bug
Projects
None yet
Development

No branches or pull requests

3 participants