Skip to content

fix: toast message after wallet import#41664

Open
hmalik88 wants to merge 7 commits intomainfrom
hm/fix-toast-message
Open

fix: toast message after wallet import#41664
hmalik88 wants to merge 7 commits intomainfrom
hm/fix-toast-message

Conversation

@hmalik88
Copy link
Copy Markdown
Contributor

@hmalik88 hmalik88 commented Apr 10, 2026

Description

When importing an SRP, the toast message briefly shows "Wallet 1 imported" before updating to the correct number (e.g. "Wallet 2 imported"). This happens because background state updates are debounced (200ms, max 1s), so hdKeyrings.length is stale when the toast first renders.

  • Changed showNewSrpAddedToast from a boolean to number | false, storing the wallet number directly
  • The import component now computes hdKeyrings.length + 1 before the import and passes it to the toast state
  • The toast reads the number from state instead of deriving it from the (lagging) keyrings selector
  • Removed a duplicate setShowNewSrpAddedToast dispatch from importMnemonicToVault

Changelog

CHANGELOG entry: Fixed a bug that was causing the wallet imported toast to momentarily show the wrong wallet added.

Related issues

Fixes #40944

Manual testing steps

  1. Build from this branch
  2. Import an SRP, the toast should immediately show the correct wallet number (e.g. "Wallet 2 imported")

Screenshots/Recordings

Before

See issue: #40944

After

Screen.Recording.2026-04-10.at.3.55.22.PM.mov

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.

Note

Medium Risk
Changes the Redux appState.showNewSrpAddedToast type from boolean to number | false and updates dispatch/selector usage; any remaining call sites assuming a boolean could break or hide the toast incorrectly.

Overview
Fixes the “New SRP Added” toast briefly showing the wrong wallet number after importing an SRP by storing the wallet number in Redux instead of a boolean.

selectNewSrpAdded/setShowNewSrpAddedToast now use number | false, the import flow dispatches the computed next wallet number (hdKeyrings.length + 1), and ToastMaster renders the message directly from that stored number. A redundant setShowNewSrpAddedToast(true) dispatch inside importMnemonicToVault was removed, and related unit tests were updated.

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

@github-actions
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.

@sonarqubecloud
Copy link
Copy Markdown

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Apr 10, 2026

Builds ready [0d9bad2]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)

Baseline (latest main): 71bd826 | Date: 10/14/58243 | Pipeline: 24262177286 | Baseline logs

Interaction Benchmarks · Samples: 5
Benchmarkchrome-browserify
loadNewAccount🟡 [Show logs]
confirmTx🟡 [Show logs]
bridgeUserActions🟡 [Show logs]

📈 Results compared to the previous 5 runs on main

  • bridgeUserActions/bridge_load_asset_picker: -21%

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

  • 🟡 loadNewAccount/FCP: p75 2.5s
  • 🟡 confirmTx/FCP: p75 2.5s
  • 🟡 bridgeUserActions/FCP: p75 2.5s
Startup Benchmarks · Samples: 100
Benchmarkchrome-browserifychrome-webpackfirefox-browserifyfirefox-webpack
startupStandardHome🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]
startupPowerUserHome🟡 [Show logs]🟡 [Show logs]🟡 [Show logs]🟡 [Show logs]

📈 Results compared to the previous 5 runs on main

  • startupStandardHome/uiStartup: -13%
  • startupStandardHome/load: -15%
  • startupStandardHome/domContentLoaded: -17%
  • startupStandardHome/initialActions: -33%
  • startupStandardHome/loadScripts: -21%
  • startupStandardHome/numNetworkReqs: -18%
  • startupPowerUserHome/uiStartup: -11%
  • startupPowerUserHome/backgroundConnect: +109%
  • startupPowerUserHome/setupStore: +15%
  • startupPowerUserHome/numNetworkReqs: -16%
  • startupStandardHome/uiStartup: -14%
  • startupStandardHome/load: -16%
  • startupStandardHome/domContentLoaded: -16%
  • startupStandardHome/firstPaint: -11%
  • startupStandardHome/backgroundConnect: -33%
  • startupStandardHome/firstReactRender: -23%
  • startupStandardHome/loadScripts: -15%
  • startupStandardHome/setupStore: -13%
  • startupStandardHome/numNetworkReqs: -29%
  • startupPowerUserHome/domInteractive: -17%
  • startupPowerUserHome/numNetworkReqs: +31%
  • startupStandardHome/domInteractive: -29%
  • startupStandardHome/initialActions: +33%
  • startupStandardHome/setupStore: +13%
  • startupStandardHome/numNetworkReqs: -18%
  • startupPowerUserHome/uiStartup: -11%
  • startupPowerUserHome/backgroundConnect: -32%
  • startupPowerUserHome/setupStore: -13%
  • startupStandardHome/initialActions: +14%
  • startupStandardHome/setupStore: -50%
  • startupPowerUserHome/backgroundConnect: -30%

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

  • 🔴 startupPowerUserHome/INP: p75 728ms
  • 🔴 startupPowerUserHome/INP: p75 712ms
  • 🟡 startupPowerUserHome/LCP: p75 3.5s
  • 🟡 startupPowerUserHome/LCP: p75 3.7s
User Journey Benchmarks · Samples: 5 · mock API
Benchmarkchrome-browserify
onboardingImportWallet🟢 [Show logs]
onboardingNewWallet🟢 [Show logs]
assetDetails🟡 [Show logs]
solanaAssetDetails🟡 [Show logs]
importSrpHome🟡 [Show logs]
sendTransactions🟡 [Show logs]
swap🟡 [Show logs]

📈 Results compared to the previous 5 runs on main

  • onboardingImportWallet/srpButtonToSrpForm: -85%
  • onboardingImportWallet/metricsToWalletReadyScreen: -32%
  • onboardingImportWallet/doneButtonToHomeScreen: -76%
  • onboardingImportWallet/openAccountMenuToAccountListLoaded: +18%
  • onboardingImportWallet/total: -44%
  • onboardingNewWallet/srpButtonToPwForm: -79%
  • onboardingNewWallet/skipBackupToMetricsScreen: -69%
  • onboardingNewWallet/agreeButtonToOnboardingSuccess: -27%
  • onboardingNewWallet/doneButtonToAssetList: -23%
  • onboardingNewWallet/total: -25%
  • solanaAssetDetails/assetClickToPriceChart: -68%
  • solanaAssetDetails/total: -68%
  • importSrpHome/openAccountMenuAfterLogin: -80%
  • importSrpHome/homeAfterImportWithNewWallet: -68%
  • importSrpHome/total: -61%
  • sendTransactions/openSendPageFromHome: -26%
  • sendTransactions/selectTokenToSendFormLoaded: -29%
  • sendTransactions/reviewTransactionToConfirmationPage: +34%
  • sendTransactions/total: +30%
  • swap/openSwapPageFromHome: -97%
  • swap/fetchAndDisplaySwapQuotes: +32%
  • swap/total: +11%

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

  • 🟡 assetDetails/INP: p75 224ms
  • 🟡 assetDetails/FCP: p75 2.5s
  • 🟡 solanaAssetDetails/FCP: p75 2.6s
  • 🟡 importSrpHome/INP: p75 208ms
  • 🟡 importSrpHome/FCP: p75 2.4s
  • 🟡 sendTransactions/INP: p75 232ms
  • 🟡 sendTransactions/FCP: p75 2.4s
  • 🟡 swap/FCP: p75 2.5s
Dapp Page Load Benchmarks · Samples: 100
Benchmarkchrome-browserify
dappPageLoad🟢 [Show logs]
Bundle size diffs [🚀 Bundle size reduced!]
  • background: 58 Bytes (0%)
  • ui: 1.69 KiB (0.02%)
  • common: -1.8 KiB (-0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Accounts - Importing an SRP displays incorrect toast message until the keyring updates

2 participants