Skip to content

fix: (import-tokens) validate duplicate token checks by selected network#40969

Merged
Prithpal-Sooriya merged 1 commit intomainfrom
cursor/multi-chain-token-import-validation-72be
Mar 17, 2026
Merged

fix: (import-tokens) validate duplicate token checks by selected network#40969
Prithpal-Sooriya merged 1 commit intomainfrom
cursor/multi-chain-token-import-validation-72be

Conversation

@Prithpal-Sooriya
Copy link
Copy Markdown
Contributor

@Prithpal-Sooriya Prithpal-Sooriya commented Mar 17, 2026

Description

Fixes a false "Token has already been added" validation in the multichain import token modal.

The duplicate-token check was reading tokens from the home network selector (chainId) instead of the network currently selected inside the import modal (selectedNetwork). This caused cross-network false positives when users imported the same token address on another chain.

This change keeps scope minimal:

  • Use selectedNetwork for duplicate address validation
  • Add a regression test that reproduces the mismatch scenario and asserts that tokenAlreadyAdded is not shown

Changelog

CHANGELOG entry: fix: (import-tokens) validate duplicate token checks by selected network

Related issues

Fixes: #38954 https://consensyssoftware.atlassian.net/browse/ASSETS-2177

Manual testing steps

  1. Open Import tokens modal.
  2. Ensure a token is already imported on network A.
  3. In the import modal, switch to network B and input the same token address.
  4. Verify "Token has already been added" is not shown for network B.

Screenshots/Recordings

Before

After

https://www.loom.com/share/dce5af505797496da9532d936b6e4715

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

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Mar 17, 2026

✨ Files requiring CODEOWNER review ✨

👨‍🔧 @MetaMask/core-extension-ux (2 files, +35 -1)
  • 📁 ui/
    • 📁 components/
      • 📁 multichain/
        • 📁 import-tokens-modal/
          • 📄 import-tokens-modal.js +1 -1
          • 📄 import-tokens-modal.test.js +34 -0

@Prithpal-Sooriya Prithpal-Sooriya changed the title fix(import-tokens): validate duplicate token checks by selected network fix: (import-tokens) validate duplicate token checks by selected network Mar 17, 2026
@Prithpal-Sooriya Prithpal-Sooriya marked this pull request as ready for review March 17, 2026 15:29
@Prithpal-Sooriya Prithpal-Sooriya requested a review from a team as a code owner March 17, 2026 15:29
@sonarqubecloud
Copy link
Copy Markdown

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Mar 17, 2026

Builds ready [9b582e1]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account2832732958283295
total2832732958283295
Confirm Txconfirm_tx6011600060271260246027
total6011600060271260246027
Bridge User Actionsbridge_load_page2092082090209209
bridge_load_asset_picker21514025647251256
bridge_search_token76474677813778778
total1224120512341412341234
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup14971246193710515411675
load12441036162510412871437
domContentLoaded12371030159710212811427
domInteractive3118116222687
firstPaint1537339275212289
backgroundConnect22220226512227245
firstReactRender20134542027
initialActions107124
loadScripts103184113919910721223
setupStore1373751722
numNetworkReqs393181154077
Power User HomeuiStartup63442143159072804678413448
load13341172192413213581621
domContentLoaded13141165190912713381583
domInteractive39222213135100
firstPaint22186624101292378
backgroundConnect2529323140772877338710601
firstReactRender25163942733
initialActions108124
loadScripts1084941165511811091316
setupStore1675281932
numNetworkReqs1918737357213319
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2202172222221222
srpButtonToSrpForm96939829898
confirmSrpToPwForm22222302223
pwFormToMetricsScreen15151601616
metricsToWalletReadyScreen16161601616
doneButtonToHomeScreen63758767933645679
openAccountMenuToAccountListLoaded290929082911129082911
total3915386639543239283954
Onboarding New WalletcreateWalletToSocialScreen2202192211220221
srpButtonToPwForm1151141161115116
createPwToRecoveryScreen999099
skipBackupToMetricsScreen41404314243
agreeButtonToOnboardingSuccess18171801818
doneButtonToAssetList55848968878608688
total96189210947910121094
Asset DetailsassetClickToPriceChart694985137685
total694985137685
Solana Asset DetailsassetClickToPriceChart43345385053
total43345385053
Import Srp HomeloginToHomeScreen2296226023352823222335
openAccountMenuAfterLogin76698777987
homeAfterImportWithNewWallet1611535242187723302421
total39752873473486846834734
Send TransactionsopenSendPageFromHome23143062830
selectTokenToSendFormLoaded32184393843
reviewTransactionToConfirmationPage86769610081139041008
total1043809140320611201403
SwapopenSwapPageFromHome92909319393
fetchAndDisplaySwapQuotes268526822688226862688
total277527722779327792779
🌐 Dapp Page Load Benchmarks

Current Commit: 9b582e1 | Date: 3/17/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±42ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 740ms (±63ms) 🟢 | historical mean value: 734ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 83ms (±43ms) 🟢 | historical mean value: 87ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 42ms 1.03s 1.37s 1.06s 1.37s
domContentLoaded 740ms 63ms 718ms 1.32s 751ms 1.32s
firstPaint 83ms 43ms 64ms 512ms 92ms 512ms
firstContentfulPaint 83ms 43ms 64ms 512ms 92ms 512ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs
  • background: 58 Bytes (0%)
  • ui: 5 Bytes (0%)
  • common: 20 Bytes (0%)

@Prithpal-Sooriya Prithpal-Sooriya added this pull request to the merge queue Mar 17, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 17, 2026
@Prithpal-Sooriya Prithpal-Sooriya added this pull request to the merge queue Mar 17, 2026
Merged via the queue into main with commit fa75613 Mar 17, 2026
204 of 205 checks passed
@Prithpal-Sooriya Prithpal-Sooriya deleted the cursor/multi-chain-token-import-validation-72be branch March 17, 2026 18:29
@github-actions github-actions bot locked and limited conversation to collaborators Mar 17, 2026
@metamaskbot metamaskbot added the release-13.24.0 Issue or pull request that will be included in release 13.24.0 label Mar 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-13.24.0 Issue or pull request that will be included in release 13.24.0 size-S team-assets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Can't import multi-chain tokens (Printr)

4 participants