chore: fix issue 27079 incorrect 0 balance#27083
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. |
Builds ready [c1018c2]
Page Load Metrics (1837 ± 125 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
ui/ducks/send/send.js
Outdated
| if (details.standard === TokenStandard.ERC20) { | ||
| asset.balance = | ||
| details.balance && details.decimals | ||
| details.balance && details.decimals >= 0 |
There was a problem hiding this comment.
| details.balance && details.decimals >= 0 | |
| details.balance && typeof details.decimals === 'number' |
I guess we're actually interested in checking if it's properly defined as a number at all? This avoid typecasting as part of comparison.
There was a problem hiding this comment.
Should it actually handle and forward 0 balance as well, to clearly distinguish between the cases balance is known to be 0 and balance undefined or couldn't be determined?
| details.balance && details.decimals >= 0 | |
| typeof details.balance === 'string' && typeof details.decimals === 'number' |
Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
d4b6997 to
91a937b
Compare
|
Builds ready [91a937b]
Page Load Metrics (1765 ± 97 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #27083 +/- ##
========================================
Coverage 70.03% 70.03%
========================================
Files 1433 1433
Lines 49879 49879
Branches 13971 13971
========================================
Hits 34928 34928
Misses 14951 14951 ☔ View full report in Codecov by Sentry. |
|
Missing release label release-12.5.0 on PR. Adding release label release-12.5.0 on PR and removing other release labels(release-12.6.0), as PR was added to branch 12.5.0 when release was cut. |



Description
If a token has decimals as 0 it's truthly evaluated to false. This PR checks that the decimals >= 0 to prevent the balance from being evaluated as undefined and ultimately showing an improper balance.
Related issues
Fixes:
#27079
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist