-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Support toFixed
method on BigNumbers
#2675
Comments
The BN.js library is only for integers that's why it doesn't support toFixed (). Can you explain why toString() can be unsafe? |
We get the BigNumber object from ethers.js. Could you please open an issue in the ethers.js repository? |
@princesinha19 I see in the docs of bignumber.js that calling But the more recent version of ethers depends on bn.js which does not have this problem. So looks like this might be a false alarm..? |
Yes right @bohendo. But, it's a problem of ethers.js because we are using ethers.js for BigNumber Object so, I think this should be solved by ethers.js. |
Yes @bohendo it looks like ethers calls it |
Description
web3.eth.abi.decodeLog
now returns ethers.jsBigNumber
instances (which itself is inconsistent seeing as how Web3 removed BigNumber in favor of BN.js). TheseBigNumber
instances do not support the methodtoFixed()
.toString()
can be unsafe, so we would like to only usetoFixed()
. Alternatively, support for getting the decoded data as strings instead of BigNumbers is an acceptable workaround.Expected behavior
Calling
bigNumberInstance.toFixed()
should work.Actual behavior
Calling
bigNumberInstance.toFixed()
returns an error.Steps to reproduce the behavior
See Gist.
Error Logs
Gists
https://gist.github.com/rhlsthrm/9c198a5c4537a01fa521c97f0e785801
Versions
The text was updated successfully, but these errors were encountered: