trufflesuite/drizzle-legacy

uncaught at getAccounts Error: Please pass numbers as strings or BigNumber objects to avoid precision errors.

Closed this issue · 8 comments

When going from a logged out state in metamask to a logged in state there is this console error that I get. Not sure exactly what it is related to though.

uncaught at getAccounts Error: Please pass numbers as strings or BigNumber objects to avoid precision errors.
at Object.fromWei (http://localhost:3000/static/js/bundle.js:64029:16)
    at t.value (http://localhost:3000/static/js/bundle.js:103485:180)
    at http://localhost:3000/static/js/bundle.js:27623:22
    at measureLifeCyclePerf (http://localhost:3000/static/js/bundle.js:26903:13)
    at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (http://localhost:3000/static/js/bundle.js:27622:26)
    at ReactCompositeComponentWrapper._renderValidatedComponent (http://localhost:3000/static/js/bundle.js:27649:33)
    at ReactCompositeComponentWrapper.performInitialMount (http://localhost:3000/static/js/bundle.js:27189:31)
    at ReactCompositeComponentWrapper.mountComponent (http://localhost:3000/static/js/bundle.js:27085:22)
    at Object.mountComponent (http://localhost:3000/static/js/bundle.js:19420:36)
    at ReactCompositeComponentWrapper.performInitialMount (http://localhost:3000/static/js/bundle.js:27198:35)

Did you fix this?

Think this needs a bit more clarification. The error is happening because somewhere the code is passing a value into the web3.utils.fromWei function as a number type instead of a String or BigNumber. Are you using the fromWei function in your own client-side code at all?

Will attempt to reproduce on our end.

I can reproduce on drizzle-box. This happens under the following scenario:

Metamask 5.3.0
drizzle-box v1.0.0

  1. Login to Metamask using account 1.
  2. Switch to account 2.
  3. Observe the error Uncaught Error: Please pass numbers as strings or BigNumber objects to avoid precision errors

For drizzle-box, I've narrowed down the issue to https://github.com/trufflesuite/drizzle-react-components/blob/master/src/AccountData.js#L36.

The issue with the code is that balance becomes undefined at some point during the account switch. I think a simple check for that should fix it if you have implemented your own version of AccountData. I'll open an issue + PR over on the drizzle-react-components repo.

I don't believe this is an issue with Drizzle itself, so I'll be closing this.

@terencechow Can you provide us with a sample of your code?

Or confirm that checking for undefined balance will fix your issue? If not, please let us know and we can look into this some more. Thanks.

@honestbonsai can you bump and publish drizzle-react-components and then update the box so we can close this issue?

@adrianmcli Will do.

Closing this out due to inactivity and @honestbonsai fixes in DRC and drizzle-box. Please reopen if necessary.