Following code causes error.
FixedNumber.fromValue(BigNumber.from('0'), 0).toFormat('fixed128x0');
FixedNumber.fromValue(BigNumber.from('0'), 0, 'fixed128x0');
the error is
Error: invalid BigNumber string (argument="value", value="0.0", code=INVALID_ARGUMENT, version=bignumber/5.1.0)
following is OK
FixedNumber.fromString('0', 'fixed128x0')
=> FixedNumber {
format: FixedFormat {
signed: true,
width: 128,
decimals: 0,
name: 'fixed128x0',
_multiplier: '1'
},
_hex: '0x00',
_value: '0.0',
_isFixedNumber: true
}
but there is some doubt that _value is "0.0". this may be the cause of the error.
the error can be reproduced on @ethersproject/bignumber:5.1.0.
and I use node v14.16.1.
This has been fixed in 5.2.0.
Try it out and let me know if there are still any issues. Thanks! :)
# node
Welcome to Node.js v14.16.1.
Type ".help" for more information.
> const { BigNumber, FixedNumber } = require('@ethersproject/bignumber')
undefined
> FixedNumber.fromValue(BigNumber.from('0'), 0).toFormat('fixed128x0');
FixedNumber {
format: FixedFormat {
signed: true,
width: 128,
decimals: 0,
name: 'fixed128x0',
_multiplier: '1'
},
_hex: '0x00',
_value: '0',
_isFixedNumber: true
}
馃憤
@ricmoo thank you!
Most helpful comment
This has been fixed in 5.2.0.
Try it out and let me know if there are still any issues. Thanks! :)