-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
chore(runway): cherry-pick fix: cp-7.60.0 staked eth balances show first account staked balance across accounts #23277
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(runway): cherry-pick fix: cp-7.60.0 staked eth balances show first account staked balance across accounts #23277
Conversation
…rst account staked balance across accounts (#23257) <!-- 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** 1. What is the reason for the change? There is a bug where we are not able to see the correct staked ethereum balance when there are multiple accounts with staked ethereum. There is also a bug where we are not able to see the APR and Earn History for a user with 0 staked ethereum balance. 2. What is the improvement/solution? - Ensure that the native asset is not set isStaked true, as the Staked Ethereum asset is the one which should be set isStaked true. - Add accountId to filtering of token data in assets list selector to ensure we have correct balances across multiple accounts for staked ethereum. - Allow zero value staked ethereum in the allTokens selector, but limit to supported staking chains to lessen amount of tokens returned. <!-- 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: null ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/MUSD-114 Fixes: https://consensyssoftware.atlassian.net/browse/MUSD-112 Fixes: #23259 Fixes: #23260 ## **Manual testing steps** ```gherkin Feature: fix staked eth balances across multiple accounts and apr / earn history for zero balance staked eth Scenario: user has multiple accounts with ETH Given user stakes ETH on all accounts When user views the token list Then the Staked Ethereum balance should be correct in each account Then the Staked Ethereum asset detail page should show the correct amount for the account Then the Ethereum asset detail page should show the correct Staked Ethereum amount Scenario: user has multiple accounts with ETH, 1 with 0 Staked ETH Given user has 0 Staked Eth on an account When user views the token list Then the Staked Ethereum balance should not show in token list Then the Ethereum asset detail page should show no Staked Ethereum at all Then the Ethereum asset detail page should show APR and Earn History even when 0 Staked ETH ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** https://github.com/user-attachments/assets/b08a1c20-6e57-45cf-b238-53d3b5008b6a <!-- [screenshots/recordings] --> ### **After** https://github.com/user-attachments/assets/488c8b0e-57a8-4228-8e6f-0b43c00ee952 <img width="200" alt="Simulator Screenshot - iPhone 17 Pro - 2025-11-25 at 10 15 28" src="https://github.com/user-attachments/assets/0ee7d224-8b4e-413a-8f52-9e7db6eb5182" /> <img width="200" alt="Simulator Screenshot - iPhone 17 Pro - 2025-11-25 at 10 15 31" src="https://github.com/user-attachments/assets/8c41b2b2-64fa-4a07-bd7a-80f98f7c6194" /> <!-- [screenshots/recordings] --> ## **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] > Ensure native assets are never marked staked, include a distinct Staked Ethereum entry, and adjust zero-balance filtering to retain native/staked tokens on the current network; update tests accordingly. > > - **Selectors**: > - Set `isStaked: false` for native balances in `selectedAccountNativeTokenCachedBalanceByChainId*`. > - Update `selectNativeTokensAcrossChains` to always add a separate "Staked Ethereum" token alongside the native asset using cached staked balance data. > - Modify zero-balance behavior in `selectEvmTokensWithZeroBalanceFilter` to keep native and staked tokens on the current network when hiding zero balances. > - Cleanup: remove unused `toHex` import. > - **Tests**: > - Adjust expectations for `isStaked` on native balances and zero-balance filtering results. > - Assert presence of "Staked Ethereum" in filtered lists and updated token counts. > - Maintain memoization and network filtering coverage. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit ce72756. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
|
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. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsFallback: AI analysis did not complete successfully. Running all tests. |
| nativeTokenInfoByChainId.stakedBalance !== toHex(0) && | ||
| nativeTokenInfoByChainId.stakedBalance !== '0' | ||
| ) { | ||
| if (nativeTokenInfoByChainId && !nativeTokenInfoByChainId.isStaked) { |
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.
Bug: Staked tokens created for all chains, not just staking-supported
The condition !nativeTokenInfoByChainId.isStaked is always true because isStaked is now always set to false on line 82. This causes "Staked Ethereum" tokens to be created for ALL chains with account data (including non-ETH chains like Polygon), not just staking-supported chains. For example, Polygon would get a token with name: 'Staked Ethereum' but symbol: 'POL', which is nonsensical. The PR description mentions "limit to supported staking chains" but this limitation wasn't implemented - the condition effectively became just if (nativeTokenInfoByChainId).
Additional Locations (1)
|
|
No release label on PR. Adding release label release-7.60.0 on PR, as PR was cherry-picked in branch 7.60.0. |



Description
What is the reason for the change?
There is a bug where we are not able to see the correct staked ethereum
balance when there are multiple accounts with staked ethereum. There is
also a bug where we are not able to see the APR and Earn History for a
user with 0 staked ethereum balance.
What is the improvement/solution?
Ethereum asset is the one which should be set isStaked true.
ensure we have correct balances across multiple accounts for staked
ethereum.
to supported staking chains to lessen amount of tokens returned.
Changelog
CHANGELOG entry: null
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/MUSD-114
Fixes: https://consensyssoftware.atlassian.net/browse/MUSD-112
Fixes: #23259
Fixes: #23260
Manual testing steps
Screenshots/Recordings
Before
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2025-11-25.at.02.08.03.mp4
After
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2025-11-25.at.10.15.10.mp4
Pre-merge author checklist
Docs and MetaMask Mobile
Coding
Standards.
if applicable
guidelines).
Not required for external contributors.
Pre-merge reviewer checklist
app, test code being changed).
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
Note
Stops marking native assets as staked and introduces a separate Staked Ethereum token, updating zero-balance filtering and tests accordingly.
selectedAccountNativeTokenCachedBalanceByChainId: always setsisStaked: falsefor native balances.selectNativeTokensAcrossChainsForAddress: adds distinct staked token (name: 'Staked Ethereum') alongside native, usingstakedBalance/fiat; shows when applicable (supports current-network zero-balance visibility).toHeximport.isStaked: false.Staked Ethereumand updated count.Written by Cursor Bugbot for commit 850b8fa. This will update automatically on new commits. Configure here.
e76aaf4