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

When dealing with very large numbers (>= 1e+21), result in the send() method fails to convert scientific notation to a number, creating downstream BigNumber conversion errors #16

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

nicholaspai
Copy link

Description

First of all, thank you for building this package in the first place, it is really awesome! 💯

I ran into this error when using the MetaMask provider and calling web3.eth.getBalanceOf(address) on an account with a lot of ETH. I seed all of my GanacheCLI accounts with 10,000 ETH so I ran into this error easily. I encountered BigNumber conversion errors, complaining that I was trying to convert a scientific-notation number, for example "9.988e+22", into a BN. I added a fix to detect if result is a number in scientific notation and to subsequently convert it.

Specific edits:

  • Created a file to convert between exponential/scientific notation and numbers
  • Checked whether result in send() is in scientific notation, which is possible I believe because nodeJS sometimes automatically converts numbers >= 1e21 into scientific notation. See more here
  • To replicate the error, call web3.eth.getBalanceOf(address) on an address with a lot of ETH.

Other Changes

Checklist

Scripts

Added Scripts:

Updated Scripts:

Dependencies

Added Dependencies:

Updated Dependencies:

Related Issues

@CLAassistant
Copy link

CLAassistant commented Mar 5, 2020

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants