Skip to content

fix: MUSD-771 updated selectAccountTokensAcrossChainsUnified to select tokens across chains for evm-scope specifically cp-7.76.0#29675

Merged
Matt561 merged 5 commits into
mainfrom
fix/musd-771-app-crash-when-user-clicks-pooled-staking-unstake-button
May 5, 2026
Merged

fix: MUSD-771 updated selectAccountTokensAcrossChainsUnified to select tokens across chains for evm-scope specifically cp-7.76.0#29675
Matt561 merged 5 commits into
mainfrom
fix/musd-771-app-crash-when-user-clicks-pooled-staking-unstake-button

Conversation

@Matt561

@Matt561 Matt561 commented May 4, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes an app crash that occurs when the user clicks the "unstake" button (ETH pooled-staking) when non-evm network is selected.

Changelog

CHANGELOG entry: fixed app crash occurring when user clicked pooled-staking unstake button when non-evm network is selected.

Related issues

Fixes: MUSD-771: App Crash when user clicks pooled-staking "unstake" button

Manual testing steps

Feature: Fix app crash when clicking "unstake" button (pooled-staking)

  Scenario: App crash fixed
    Given user has Staked ETH to unstake

    When user clicks "Tokens" section header on home screen
    And user selects non-EVM network (e.g. Tron) in network selector
    And user returns to home screen
    And user clicks Ethereum asset row
    And user clicks "unstake" button on Ethereum asset details screen
    
    Then user is redirected to unstake screen with keypad
    And the app does not crash

Screenshots/Recordings

Before

musd-771-unstake-button-crash-demo-before.mov

After

musd-771-unstake-button-crash-demo-after.mov

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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.

Note

Medium Risk
Medium risk because it changes how the unified multichain token selector chooses the EVM address, which can affect token lists and Earn flows across networks; however the change is localized and covered by updated unit tests/mocks.

Overview
Fixes a crash/empty-balance issue when a non-EVM network is active by making selectAccountTokensAcrossChainsUnified always derive EVM tokens from the EVM-scoped account in the selected account group, rather than whatever account is currently selected.

Adds selectAccountTokensAcrossChainsForEvmScope (using selectSelectedInternalAccountByScope(EVM_SCOPE) + selectAccountTokensAcrossChainsForAddress) and updates multichain/Earn-related tests to mock selectSelectedInternalAccountByScope and the new EVM-token selector signature.

Reviewed by Cursor Bugbot for commit d5602d9. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

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.

@Matt561 Matt561 changed the title fix: MUSD-771 updated selectAccountTokensAcrossChainsUnified to select tokens across chains for evm-scope specifically fix: MUSD-771 updated selectAccountTokensAcrossChainsUnified to select tokens across chains for evm-scope specifically cp-7.76.0 May 4, 2026
@github-actions github-actions Bot added the size-S label May 4, 2026
@Matt561 Matt561 requested review from a team and ulissesferreira and removed request for a team May 4, 2026 17:10
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.66%. Comparing base (a614776) to head (b259afb).
⚠️ Report is 82 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #29675      +/-   ##
==========================================
- Coverage   81.84%   74.66%   -7.19%     
==========================================
  Files        5244     5255      +11     
  Lines      138676   138982     +306     
  Branches    31462    31517      +55     
==========================================
- Hits       113503   103765    -9738     
- Misses      17450    27853   +10403     
+ Partials     7723     7364     -359     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeStake, SmokeWalletPlatform, SmokePerps, SmokeMoney, SmokeNetworkExpansion, SmokeNetworkAbstractions, SmokeConfirmations, SmokeSwap
  • Selected Performance tags: @PerformanceAssetLoading
  • Risk Level: medium
  • AI Confidence: 82%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are primarily in test files (3 of 4 files are .test.ts) plus one production selector change in multichain.ts. The production change replaces selectAccountTokensAcrossChains with a new selectAccountTokensAcrossChainsForEvmScope selector that explicitly resolves the EVM-scoped account address using selectSelectedInternalAccountByScope. This is a bug fix for scenarios where a non-EVM network (e.g., TRON) is active and the old selector would incorrectly use a non-EVM address.

Impact analysis:

  1. selectAccountTokensAcrossChainsUnified (changed selector) is used by:

    • earnController/earn/index.ts → affects SmokeStake (staking/lending flows)
    • Token list components → affects SmokeWalletPlatform
  2. selectSelectedInternalAccountByScope (newly introduced dependency) is used by:

    • Perps components → affects SmokePerps
    • Ramp/buy hooks → affects SmokeMoney
    • Earn selectors → affects SmokeStake
  3. selectAccountTokensAcrossChainsForAddress (underlying function) is used by:

    • Bridge hooks → affects SmokeSwap
    • Confirmation hooks (useTokenAsset) → affects SmokeConfirmations
    • Network abstractions (multi-chain token filtering) → affects SmokeNetworkAbstractions
  4. Non-EVM network handling fix → affects SmokeNetworkExpansion (Solana/TRON flows)

Dependent tags per descriptions:

  • SmokeStake → also select SmokeConfirmations ✓
  • SmokeSwap → also select SmokeConfirmations ✓
  • SmokePerps → also select SmokeWalletPlatform ✓ and SmokeConfirmations ✓
  • SmokeMoney → also select SmokeWalletPlatform ✓
  • SmokeNetworkAbstractions → also select SmokeNetworkExpansion ✓
  • SmokeNetworkExpansion → also select SmokeConfirmations ✓ (for Solana flows)

Performance Test Selection:
The change modifies a core selector selectAccountTokensAcrossChainsUnified that is used for token/asset loading across chains. The new implementation adds an extra selector call (selectSelectedInternalAccountByScope) in the chain, which could marginally affect asset loading performance. @PerformanceAssetLoading covers token list rendering and balance fetching which directly uses this selector path.

View GitHub Actions results

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d5602d9. Configure here.

Comment thread app/selectors/multichain/multichain.ts
@sonarqubecloud

sonarqubecloud Bot commented May 5, 2026

Copy link
Copy Markdown

@Matt561 Matt561 enabled auto-merge May 5, 2026 20:06
@Matt561 Matt561 added this pull request to the merge queue May 5, 2026
Merged via the queue into main with commit 0a39d7f May 5, 2026
107 of 108 checks passed
@Matt561 Matt561 deleted the fix/musd-771-app-crash-when-user-clicks-pooled-staking-unstake-button branch May 5, 2026 20:26
@github-actions github-actions Bot locked and limited conversation to collaborators May 5, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.77.0 Issue or pull request that will be included in release 7.77.0 label May 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.77.0 Issue or pull request that will be included in release 7.77.0 size-S team-earn

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants