-
Notifications
You must be signed in to change notification settings - Fork 5k
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
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
@@ -2679,7 +2679,7 @@ export function updateSendAsset( | |||
|
|||
if (details.standard === TokenStandard.ERC20) { | |||
asset.balance = | |||
details.balance && details.decimals | |||
details.balance && details.decimals >= 0 |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
d4b6997
to
91a937b
Compare
Quality Gate passedIssues Measures |
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