Skip to content

fix(confirmations): prevent send account startsWith crash#43925

Closed
Prithpal-Sooriya wants to merge 1 commit into
mainfrom
cursor/fix-send-account-startswith-3c91
Closed

fix(confirmations): prevent send account startsWith crash#43925
Prithpal-Sooriya wants to merge 1 commit into
mainfrom
cursor/fix-send-account-startswith-3c91

Conversation

@Prithpal-Sooriya

Copy link
Copy Markdown
Contributor

Description

Context:

  • ASSETS-3029 reports a crash in Extension Wallet 13.22.0 while entering send flows (Send -> select token or token -> Send).
  • The error is TypeError: Cannot read properties of undefined (reading 'startsWith') and points to ui/pages/confirmations/utils/account.ts.

Problem:

  • isEVMAccountForSend/isSolanaAccountForSend/isBitcoinAccountForSend/isTronAccountForSend assumed account.type and account.scopes always contained strings.
  • When malformed account objects are present (e.g., missing type, or non-string scope entries), these checks could call .startsWith on undefined and crash the UI.

Solution:

  • Added a shared, defensive compatibility helper that verifies values are strings before calling .startsWith.
  • Updated all send-account compatibility helpers (EVM/Solana/Bitcoin/Tron) to use this guarded logic.
  • Added regression tests for malformed account shapes (missing type, undefined scope entries) and added dedicated Tron coverage.

Changelog

CHANGELOG entry: Fixed a crash that could occur in send flow when malformed account entries were missing account type metadata.

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/ASSETS-3029

Manual testing steps

  1. Open the extension and unlock a wallet with multiple token/account options.
  2. Go through both reported flows:
    • Click Send and then select a token.
    • Select a token first and then click Send.
  3. Confirm the send UI does not crash and recipients render normally.
  4. Confirm this remains true even when account data includes non-EVM accounts in the wallet list.

Pre-merge author checklist

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.
Open in Web Open in Cursor 

Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
@mm-token-exchange-service

Copy link
Copy Markdown

✨ Files requiring CODEOWNER review ✨

@MetaMask/confirmations (2 files, +134 -53)
  • 📁 ui/
    • 📁 pages/
      • 📁 confirmations/
        • 📁 utils/
          • 📄 account.test.ts +99 -0
          • 📄 account.ts +35 -53

@sonarqubecloud

Copy link
Copy Markdown

@mm-token-exchange-service

Copy link
Copy Markdown
Builds ready [0559dfc]
Deprecated Browserify fallback builds
⚡ Performance Benchmarks (Total: 🟢 12 pass · 🟡 12 warn · 🔴 0 fail)

Baseline (latest main): 1e3d238 | Date: 6/25/2026 | Pipeline: 28227949240 | Baseline logs

Interaction Benchmarks · Samples: 5
Benchmarkchrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🟡 [CI log]🟢 [CI log]
confirmTx
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
bridgeUserActions
[Sentry log · main/release]
🟡 [CI log]🟡 [CI log]

📈 Results compared to the previous 5 runs on main

  • loadNewAccount/inp: +27%
  • loadNewAccount/cls: -75%
  • bridgeUserActions/bridge_load_page: +129%
  • bridgeUserActions/bridge_load_asset_picker: +18%
  • bridgeUserActions/longTaskCount: +67%
  • bridgeUserActions/longTaskTotalDuration: +54%
  • bridgeUserActions/longTaskMaxDuration: +11%
  • bridgeUserActions/tbt: +51%
  • bridgeUserActions/total: +12%
  • loadNewAccount/inp: -21%
  • loadNewAccount/fcp: -46%
  • loadNewAccount/lcp: +1020%
  • confirmTx/confirm_tx: +10%
  • confirmTx/longTaskCount: -100%
  • confirmTx/longTaskTotalDuration: -100%
  • confirmTx/longTaskMaxDuration: -100%
  • confirmTx/tbt: -100%
  • confirmTx/total: +10%
  • confirmTx/inp: -14%
  • confirmTx/lcp: +1186%
  • bridgeUserActions/bridge_load_page: +207%
  • bridgeUserActions/bridge_load_asset_picker: +64%
  • bridgeUserActions/longTaskCount: -100%
  • bridgeUserActions/longTaskTotalDuration: -100%
  • bridgeUserActions/longTaskMaxDuration: -100%
  • bridgeUserActions/tbt: -100%
  • bridgeUserActions/total: +20%
  • bridgeUserActions/lcp: +1195%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 loadNewAccount/FCP: p75 1.8s
  • 🟡 bridgeUserActions/FCP: p75 1.8s
  • 🟡 confirmTx/FCP: p75 1.8s
  • 🟡 bridgeUserActions/FCP: p75 1.8s
Startup Benchmarks · Samples: 100
Benchmarkchrome-webpackfirefox-webpack
startupStandardHome
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
🟡 loadScripts
startupPowerUserHome
[Sentry log · main/release]
🟡 [CI log]

📈 Results compared to the previous 5 runs on main

  • startupStandardHome/backgroundConnect: +11%
  • startupStandardHome/setupStore: -29%
  • startupPowerUserHome/backgroundConnect: +22%
  • startupPowerUserHome/setupStore: +20%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 startupPowerUserHome/INP: p75 208ms
  • 🟡 startupPowerUserHome/LCP: p75 3.4s
User Journey Benchmarks · Samples: 5 · mock API
Benchmarkchrome-webpackfirefox-webpack
onboardingImportWallet
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
🟡 total
assetDetails
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
solanaAssetDetails
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
importSrpHome
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
sendTransactions
[Sentry log · main/release]
🟡 [CI log]🟡 [CI log]
swap
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • onboardingImportWallet/srpButtonToSrpForm: -23%
  • onboardingImportWallet/confirmSrpToPwForm: -24%
  • onboardingImportWallet/pwFormToMetricsScreen: -23%
  • onboardingImportWallet/metricsToWalletReadyScreen: -45%
  • onboardingImportWallet/doneButtonToHomeScreen: -77%
  • onboardingImportWallet/openAccountMenuToAccountListLoaded: -100%
  • onboardingImportWallet/longTaskCount: -75%
  • onboardingImportWallet/longTaskTotalDuration: -92%
  • onboardingImportWallet/longTaskMaxDuration: -89%
  • onboardingImportWallet/tbt: -99%
  • onboardingImportWallet/total: -83%
  • onboardingNewWallet/skipBackupToMetricsScreen: +16%
  • onboardingNewWallet/doneButtonToAssetList: -33%
  • onboardingNewWallet/longTaskCount: -62%
  • onboardingNewWallet/longTaskTotalDuration: -64%
  • onboardingNewWallet/longTaskMaxDuration: -39%
  • onboardingNewWallet/tbt: -72%
  • onboardingNewWallet/total: -29%
  • solanaAssetDetails/assetClickToPriceChart: -75%
  • solanaAssetDetails/total: -75%
  • solanaAssetDetails/inp: -19%
  • solanaAssetDetails/fcp: -21%
  • solanaAssetDetails/lcp: -12%
  • solanaAssetDetails/cls: +12%
  • importSrpHome/openAccountMenuAfterLogin: +17%
  • importSrpHome/homeAfterImportWithNewWallet: -39%
  • importSrpHome/longTaskCount: -33%
  • importSrpHome/longTaskTotalDuration: -31%
  • importSrpHome/tbt: -35%
  • importSrpHome/total: -33%
  • importSrpHome/inp: -28%
  • importSrpHome/cls: -53%
  • sendTransactions/openSendPageFromHome: +60%
  • sendTransactions/longTaskCount: -50%
  • sendTransactions/longTaskTotalDuration: -61%
  • sendTransactions/longTaskMaxDuration: -37%
  • sendTransactions/tbt: -100%
  • sendTransactions/fcp: +26%
  • sendTransactions/lcp: +29%
  • sendTransactions/cls: -92%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 sendTransactions/FCP: p75 2.2s
  • 🔴 assetDetails/INP: p75 736ms
  • 🟡 assetDetails/FCP: p75 1.9s
  • 🟡 solanaAssetDetails/FCP: p75 1.9s
  • 🟡 importSrpHome/FCP: p75 1.8s
  • 🟡 sendTransactions/FCP: p75 1.8s
Dapp Page Load Benchmarks · Samples: 100
Benchmarkchrome-webpack
dappPageLoad
[Sentry log · main/release]
🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • dappPageLoad/pageLoadTime: -14%
Bundle size diffs
  • background: 73 Bytes (0%)
  • ui: -93 Bytes (0%)
  • common: 0 Bytes (0%)
  • other: 0 Bytes (0%)
  • contentScripts: 0 Bytes (0%)
  • zip: 82 Bytes (0%)

@github-actions github-actions Bot locked and limited conversation to collaborators Jun 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants