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

FixedNumber with zero decimal causes error #1463

Closed
aya-eiya opened this issue Apr 14, 2021 · 2 comments
Closed

FixedNumber with zero decimal causes error #1463

aya-eiya opened this issue Apr 14, 2021 · 2 comments
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published. minor-bump Planned for the next minor version bump.

Comments

@aya-eiya
Copy link

aya-eiya commented Apr 14, 2021

Problems

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.

Version

the error can be reproduced on @ethersproject/bignumber:5.1.0.
and I use node v14.16.1.

@aya-eiya aya-eiya added the investigate Under investigation and may be a bug. label Apr 14, 2021
@ricmoo ricmoo added enhancement New feature or improvement. on-deck This Enhancement or Bug is currently being worked on. minor-bump Planned for the next minor version bump. and removed investigate Under investigation and may be a bug. labels Apr 16, 2021
@ricmoo ricmoo added bug Verified to be an issue. and removed enhancement New feature or improvement. labels Apr 24, 2021
@ricmoo
Copy link
Member

ricmoo commented May 20, 2021

This has been fixed in 5.2.0.

Try it out and let me know if there are still any issues. Thanks! :)

@ricmoo ricmoo added fixed/complete This Bug is fixed or Enhancement is complete and published. and removed on-deck This Enhancement or Bug is currently being worked on. labels May 20, 2021
@aya-eiya
Copy link
Author

# 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published. minor-bump Planned for the next minor version bump.
Projects
None yet
Development

No branches or pull requests

2 participants