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

Fix an onboarding crash happening with specific web3 provider setups #442

Merged
merged 2 commits into from Nov 1, 2018

Conversation

bpierre
Copy link
Contributor

@bpierre bpierre commented Oct 31, 2018

Fixes #440

When calling getBalance(), it was possible to sometimes get another value than an big integer as a string.

Having null as a result, and passing it to the BN.js constructor, could lead to an infinite loop.

To prevent this issue to happen again:

  • In the app, balance is now always represented by a BN.js instance. To represent an unknown balance, new BN(-1) is now used rather than null.

  • The result of getbalance() is now filtered to ensure that we are passing an integer to BN.js. Otherwise, we pass "-1".

When calling getBalance(), it was possible to sometimes get another
value than an big integer as a string.

Having `null` as a result, and passing it to the BN.js constructor,
could lead to an infinit loop [1].

To prevent this issue to happen again:

- In the app, `balance` is now always represented by a BN.js instance.
To represent an unknown balance, `new BN(-1)` is now used rather than `null`.

- The result of getbalance() is now filtered to ensure that we are
passing an integer to BN.js. Otherwise, we pass "-1".

[1] indutny/bn.js#186
@bpierre bpierre requested a review from izqui October 31, 2018 19:16
Copy link
Contributor

@sohkai sohkai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅✅✅✅✅✅

@bpierre bpierre merged commit f896c00 into master Nov 1, 2018
@bpierre bpierre deleted the filter-getbalance-value branch November 1, 2018 12:43
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.

None yet

2 participants