You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- fix: cp-7.64.0 MUSD-266 staked ethereum balance mismatch (#25468)
<!--
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**
Fixed bug where Staked Ethereum balances weren't updating when switching
accounts.
<!--
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?
-->
## **Changelog**
<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`
If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`
(This helps the Release Engineer do their job more quickly and
accurately)
-->
CHANGELOG entry: fixed bug where Staked Ethereum balances weren't
updating when switching accounts.
## **Related issues**
Fixes: [MUSD-266: Staked Ethereum Balance
Mismatch](https://consensyssoftware.atlassian.net/browse/MUSD-266)
## **Manual testing steps**
```gherkin
Feature: Correct staked asset balances per account
Scenario: user switches accounts and sees staked Ethereum balance update
Given user has multiple EVM accounts with different Ethereum and Staked Ethereum balances
When user switches the selected account
Then the displayed Ethereum balance matches the selected account
And the displayed Staked Ethereum balance matches the selected account
Scenario: user views a staked token and sees the staked balance (not the native counterpart)
Given user has a staked token balance
When user opens the token details view for the staked token
Then the displayed balance corresponds to the staked asset
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
1. Staked Ethereum doesn't update when switching accounts
2. Staked Ethereum AssetOverview was displaying the user's **native**
ETH balance
### **After**
<!-- [screenshots/recordings] -->
1. Staked Ethereum now updates when switching accounts
2. Staked Ethereum on balance in TokenListItem now matches balance on
AssetOverview screen
https://github.com/user-attachments/assets/8ba8ed5b-b499-4739-8b8b-895d1a09a47c
## **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**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] 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.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes core `selectAsset` lookup behavior for EVM chains and alters
displayed fiat formatting/rounding for staked balances, which could
impact multiple balance/asset UI surfaces when switching accounts.
>
> **Overview**
> Fixes a bug where **Staked Ethereum** could display the wrong
account’s balance after switching accounts by scoping `selectAsset`
results (native and staked) to `selectSelectedInternalAccountId` on EVM
chains.
>
> Updates `useBalance` to source staked native asset fiat values from
`selectAsset` (matching the token list’s Intl formatting) with a
`weiToFiat` fallback, and adjusts/extends tests accordingly (including
new coverage for account-scoped lookups and updated expected fiat
strings).
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
32c383d. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
[aeee852](aeee852)
Co-authored-by: Matthew Grainger <46547583+Matt561@users.noreply.github.com>
Co-authored-by: João Loureiro <175489935+joaoloureirop@users.noreply.github.com>
0 commit comments