-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
fix: toBignumber conversion error with high balance #12010
Conversation
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
|
Do you have a link (or would you be able to describe in PR description) the issue this fixes? Considering if this is related at all to solving it: Also, is there any possible way to add a regression test for this bugfix? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check whether the useMemo
is actually needed. This kind of hook allocates system memory to watch the dependancies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, once the tests are passing. Thanks
@siibars Thanks for updating, much clearer! 👍 Looks like it is indeed related.
First steps in sorting out this larger mess: |
@siibars I am trying to track down exactly where the
|
We get this as wei string from the server side API. |
using new BN(assets) instead of hexToBn(assets) fixes the issue. |
hi @legobeat I think this hextobn util here make sense but Indeed the BN import should probably be aligned and this file should also be written in ts for more type safety at build time. @amitabh94 I am curious about d. and e. working as expected with account with a high share amount / conversion rate with a lot of decimals, do we have tests for such cases ? cheers |
|
|
|
We will have to check whether if we have specific test cases for decimals but what I know is that we use bignumber.js in Staking api which is used to deal with big numbers with decimal places. |
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** There is a bignumber conversion attempt which is failing, this change fixes this. <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Related issues** Fixes: STAKE-848 ## **Manual testing steps** 1. connect with an account with a high ETH balance 2. enable the native staking feature flag 3. click stake to get to the StakeinputView ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] -->  View: Root Error: [number-to-bn] while converting number "3.487400189415765903484e+21" to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported. ### **After** This issue doesn't happen. <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [x] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [x] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --------- Co-authored-by: legobeat <[email protected]>
Description
There is a bignumber conversion attempt which is failing, this change fixes this.
Related issues
Fixes: STAKE-848
Manual testing steps
Screenshots/Recordings
Before
View: Root
Error: [number-to-bn] while converting number "3.487400189415765903484e+21" to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported.
After
This issue doesn't happen.
Pre-merge author checklist
Pre-merge reviewer checklist