Open
Conversation
fixes MetaMask/metamask-mobile#26707 https://consensyssoftware.atlassian.net/browse/ASSETS-2814 Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
|
Cursor Agent can help with this pull request. Just |
Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
What is the current state of things and why does it need to change?
The
AccountsApiBalanceFetcherwas incorrectly zeroing out ERC-20 token balances for accounts that were not part of the current balance fetch request. This could lead to incorrect balance displays, particularly when fetching balances for a single selected account while other accounts had existing (but not requested) balances.What is the solution your changes offer and how does it work?
This PR introduces a new condition,
isAccountIncludedInRequest, to theshouldZeroOutBalancelogic. This ensures that ERC-20 balances are only zeroed out if the account being processed is explicitly part of the current balance fetch request (either theselectedAccountor one of theallAccountsifqueryAllAccountsis true).Are there any changes whose purpose might not obvious to those unfamiliar with the domain?
The addition of
isAccountIncludedInRequestand its integration into theshouldZeroOutBalancecondition is crucial to prevent unintended zeroing of balances for accounts not in the scope of the current query.References
Checklist