Skip to content

Event Decoder stores numbers oddly. #261

@MicahZoltu

Description

@MicahZoltu

When decoding an event like Foo(uint256 a), I end up with an object like:

{ /*...*/, values: { a: { _hex: '0x5' } } }

I would have expected a BigNumber here, or barring that a hex encoded string. _ prefixed property names are usually internal, so I am hesitant to write code that relies or reading that. Also, non-number values are stored without the inner-most object, so just { b: '0xabcd1234' }, which makes number values odd.

After a significant amount of digging I found the issue is in the way it "freezes" the values key. It does JSON.stringify then JSON.parse on it, which results in stripping the prototype from all of the methods and leaving only the _hex internal variable of the original BigNumber object.

Metadata

Metadata

Assignees

Labels

bugVerified to be an issue.fixed/completeThis Bug is fixed or Enhancement is complete and published.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions