Open hayeah opened 6 years ago
@hayeah Could you please provide more details or examples? What is expected behavior?
Solidity numbers are decoded to BigNumber, see these test cases:
For most applications Number.MAX_SAFE_INTEGER is enough. It'd be good to be able to configure the decoding to return JavaScript numbers instead.
@hayeah Thank you for the response. For decoding, what is the expected behavior? Will it be automatically decoded to js number, or users need to specify that?
I think it'd be best if user has a way to create multiple instances of the library. Maybe an interface like
const abi = new ABIEncoding({ useBigNumber: false, use0xPrefix: false })
abi.decodeMethod(...)
abi.decodeMethod(...)
// etc...
Right now all numbers are decoded to BigNumber instances, which are fussy to use in the application code.
IEEE 754 and can only safely represent numbers between -(2^53 - 1) and 2^53 - 1 .
Would like a way to configure ethjs-abi use decode Solidity integers to plain JS numbers, and throw an error if not safe.
BigNumber.toNumber() throws if the conversion is unsafe, and we can rely on this behaviour.