-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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: decimals and fiat conversion crashes in simulation #24422
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. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #24422 +/- ##
========================================
Coverage 67.36% 67.36%
========================================
Files 1285 1285
Lines 50088 50096 +8
Branches 12996 12997 +1
========================================
+ Hits 33738 33745 +7
- Misses 16350 16351 +1 ☔ View full report in Codecov by Sentry. |
Builds ready [9972070]
Page Load Metrics (805 ± 609 ms)
Bundle size diffs
|
Missing release label release-11.16.0 on PR. Adding release label release-11.16.0 on PR and removing other release labels(release-11.18.0), as PR was cherry-picked in branch 11.16.0. |
Description
This PR fixes 2 bugs in
useBalanceChanges
Fix 1: decimals parsing in
fetchErc20Decimals
sometimes returnsNaN
fetchErc20Decimals
usesparseInt
to parse the return from getTokenStandardAndDetails.parseInt
will returnNaN
if it cannot parse the string:This PR patches
fetchErc20Decimals
to try a couple methods of parsing and fall back to the default if none of them work.Fix 2: fiat rates for ETH or tokens may contain more than 15 decimals
The constructor and many methods on
BigNumber
will throw an error if you attempt to call them with a javascript number that has more than 15 decimal places. An explanation can be found here, along with a workaround: Converting these numbers to a string may loose some precision, but is a safe.New tests added and fixed
Related issues
Fixes: #24336
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist