truffle
truffle copied to clipboard
Integers in structs are not converted to BigNumbers
- [X] I've asked for help in the Truffle Gitter before filing this issue.
Issue
When structs (tuples) are returned from the contract, their integer fields are not reformatted into a configured BigNubmer type, and remain as strings. This adds a lot of inconsistency to our project when trying to converge integer types.
Steps to Reproduce
Create a contract with the following code:
struct Struct {
uint256 a;
uint256 b;
}
function getStruct() external view returns (Struct memory);
function getA() external view returns (uint256);
and observe the difference in the Truffle console:
truffle(development)> c.getA()
BN {
negative: 0,
words: [ 150000, <1 empty item> ],
length: 1,
red: null
}
truffle(development)> c.getStruct()
[
'150000',
'100000',
'110000',
'10500',
a: '150000',
b: '100000',
]
Expected Behavior
Integer types should be reformatted to the correct BigNumber type.
Actual Results
Some integers are not reformatted and remain as strings.
Thanks for reporting this; unfortunately I'm not sure there's any good way to fix this at the moment. We are planning a rewrite of all of our decoding functionality and once that's done this should be fixed, but unfortunately I'm not sure there's any real way to fix this short of completing that.
Just a note: this rewrite is currently in progress!
Any news?
@haltman-at do you know anything about the progress on this?
Unfortunately the contract rewrite has gotten delayed by other things, and I still can't see any good way to fix this without it. Hopefully we'll have time to get to it soon? (Btw @gnidan you may want to know about this...)