Skip to content

fix: handle evm unsupported chains gracefully in token import flow for custom network cp-13.20.0#40325

Merged
HowardBraham merged 5 commits intomainfrom
fix/usetokenwithfiltering
Feb 23, 2026
Merged

fix: handle evm unsupported chains gracefully in token import flow for custom network cp-13.20.0#40325
HowardBraham merged 5 commits intomainfrom
fix/usetokenwithfiltering

Conversation

@khanti42
Copy link
Contributor

@khanti42 khanti42 commented Feb 23, 2026

Description

Fixes error when importing tokens on EVM networks with decimal string chainIds (e.g., Injective testnet) using similar strategy to: #39806.

Open in GitHub Codespaces

Changelog

CHANGELOG entry: Fixed error when importing tokens on EVM networks when chainId is provided as decimal string.

Related issues

Related to PR: #39806

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

Screen.Recording.2026-02-23.at.13.23.52.mov

After

Screen.Recording.2026-02-23.at.13.21.50.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

Low Risk
Small defensive change in token list/image resolution; main risk is minor regressions in native-asset icon fallback/selection on edge networks.

Overview
Improves resilience when building native-token entries in useTokensWithFiltering for multichain balances.

The hook now uses getNativeAssetForChainIdSafe and guards getAssetImageUrl with a try/catch, so unsupported/custom EVM chain IDs (including decimal-string chainIds) don’t throw during native token image resolution and instead fall back to available icons/undefined.

Written by Cursor Bugbot for commit 779be7d. This will update automatically on new commits. Configure here.

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

@metamaskbot metamaskbot added the team-networks PRs from the Networks team label Feb 23, 2026
@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Feb 23, 2026

✨ Files requiring CODEOWNER review ✨

🔄 @MetaMask/swaps-engineers (1 files, +16 -11)
  • 📁 ui/
    • 📁 hooks/
      • 📁 bridge/
        • 📄 useTokensWithFiltering.ts +16 -11

@khanti42 khanti42 marked this pull request as ready for review February 23, 2026 12:34
@khanti42 khanti42 requested a review from a team as a code owner February 23, 2026 12:34
@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Feb 23, 2026

Builds ready [53912ab]
⚡ Performance Benchmarks (1405 ± 106 ms)
👆 Interaction Benchmarks
ActionMetricMean (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account28731295344
total28731295344
Confirm Txconfirm_tx6051760616061
total6051760616061
Bridge User Actionsbridge_load_page23843278286
bridge_load_asset_picker18436223224
bridge_search_token7001702702
total11001811051122
🔌 Startup Benchmarks
BuildMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
Chrome Browserify Startup Standard HomeuiStartup14051184169110614631598
load119199714299512331366
domContentLoaded118499314219512271361
domInteractive2917129222486
firstPaint1566746988202356
backgroundConnect21019140422212234
firstReactRender19115062028
initialActions104112
loadScripts99180212359510381170
setupStore1464661621
numNetworkReqs312291202286
Chrome Browserify Startup Power User HomeuiStartup3255140010846221638999399
load12041045168211712281454
domContentLoaded11891035164811312121429
domInteractive3320180203555
firstPaint206771333168248340
backgroundConnect10912588037158110094615
firstReactRender24174652632
initialActions105112
loadScripts983837143111010061242
setupStore1564681536
numNetworkReqs80311472493121
Chrome Webpack Startup Standard HomeuiStartup8676841189949341011
load74661395189802909
domContentLoaded73960994288797903
domInteractive2816115212481
firstPaint1156327952138219
backgroundConnect26186272941
firstReactRender1812131131931
initialActions105112
loadScripts73760793587795901
setupStore1262751322
numNetworkReqs312299212591
Chrome Webpack Startup Power User HomeuiStartup1246871260625813061636
load74363712661187341013
domContentLoaded7316311259118718988
domInteractive40182053537135
firstPaint1456452286165323
backgroundConnect1961301219142175343
firstReactRender22164042330
initialActions103111
loadScripts7286291243116716978
setupStore1355181527
numNetworkReqs1193923643149174
Firefox Browserify Startup Standard HomeuiStartup16261386256121016372086
load13731148231718714061705
domContentLoaded13731144231718714061705
domInteractive85329209995172
firstPaint------
backgroundConnect5828132176498
firstReactRender13113631416
initialActions103112
loadScripts13471125229518413811625
setupStore218219341590
numNetworkReqs3120103202590
Firefox Browserify Startup Power User HomeuiStartup29022038572753830243846
load16491303463046816742052
domContentLoaded16491303462946816742052
domInteractive182541702191205392
firstPaint------
backgroundConnect4221221381306630991
firstReactRender19157091925
initialActions103122
loadScripts16101282460246016462015
setupStore19316717199292589
numNetworkReqs87382143898173
Firefox Webpack Startup Standard HomeuiStartup16561408316625416852029
load14011182290123714361573
domContentLoaded14011182290123714361573
domInteractive110281533205128208
firstPaint------
backgroundConnect59252223562113
firstReactRender15122631524
initialActions102122
loadScripts13781169287723414161548
setupStore207164281366
numNetworkReqs312095182784
Firefox Webpack Startup Power User HomeuiStartup28181997384534630183437
load16031329216220016802082
domContentLoaded16031327216120016802082
domInteractive17653821157193555
firstPaint------
backgroundConnect48312114013227381025
firstReactRender22167372431
initialActions213122
loadScripts15631308214319816242044
setupStore12915703137171464
numNetworkReqs86312273596153
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2191219221
srpButtonToSrpForm984103103
confirmSrpToPwForm2302323
pwFormToMetricsScreen1611618
metricsToWalletReadyScreen1832122
doneButtonToHomeScreen9461629851221
openAccountMenuToAccountListLoaded76491676487675
total88879189649020
Onboarding New WalletcreateWalletToSocialScreen2190220220
srpButtonToPwForm1041104105
createPwToRecoveryScreen8089
skipBackupToMetricsScreen3723839
agreeButtonToOnboardingSuccess1601616
doneButtonToAssetList102939613571358
total141539717411753
Asset DetailsassetClickToPriceChart4094654
total4094654
Solana Asset DetailsassetClickToPriceChart4744655
total4744655
Import Srp HomeloginToHomeScreen197318120472240
openAccountMenuAfterLogin4154448
homeAfterImportWithNewWallet270329628853188
total471735549225131
Send TransactionsopenSendPageFromHome1701717
selectTokenToSendFormLoaded2793539
reviewTransactionToConfirmationPage8547862863
total9012904904
SwapopenSwapPageFromHome11812125137
fetchAndDisplaySwapQuotes46317847254728
total47498248374862
🌐 Dapp Page Load Benchmarks

Current Commit: 53912ab | Date: 2/23/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.03s (±38ms) 🟡 | historical mean value: 1.04s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 720ms (±35ms) 🟢 | historical mean value: 727ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 77ms (±14ms) 🟢 | historical mean value: 80ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 38ms 1.01s 1.32s 1.07s 1.32s
domContentLoaded 720ms 35ms 699ms 989ms 745ms 989ms
firstPaint 77ms 14ms 56ms 196ms 88ms 196ms
firstContentfulPaint 77ms 14ms 56ms 196ms 88ms 196ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: -65.56 KiB (-1.49%)
  • ui: 150.87 KiB (1.84%)
  • common: 226 KiB (2.06%)

@khanti42 khanti42 requested a review from a team as a code owner February 23, 2026 13:03
@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Feb 23, 2026

Builds ready [bb94384]
⚡ Performance Benchmarks (1467 ± 126 ms)
👆 Interaction Benchmarks
ActionMetricMean (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account29326303330
total29326303330
Confirm Txconfirm_tx60631460736078
total60631460736078
Bridge User Actionsbridge_load_page26545291326
bridge_load_asset_picker18527197230
bridge_search_token72218728755
total11462711401190
🔌 Startup Benchmarks
BuildMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
Chrome Browserify Startup Standard HomeuiStartup14671237196512615161705
load12381028160810712761439
domContentLoaded12301020160010712701430
domInteractive3017118222688
firstPaint182701353150229382
backgroundConnect21519926913218242
firstReactRender19135052127
initialActions105113
loadScripts1032819138210710751233
setupStore1477781723
numNetworkReqs312299202584
Chrome Browserify Startup Power User HomeuiStartup16051263274218116651802
load1071961185614710651435
domContentLoaded1052952183613910491361
domInteractive3116129213085
firstPaint207631854216228374
backgroundConnect28224062548286364
firstReactRender22154262436
initialActions103112
loadScripts85876216141378491175
setupStore1473461529
numNetworkReqs57351622555116
Chrome Webpack Startup Standard HomeuiStartup89070612031049621060
load757622102792824906
domContentLoaded751619102091819896
domInteractive2916102202479
firstPaint1106522448144206
backgroundConnect29196793250
firstReactRender1912136132031
initialActions106112
loadScripts748617101890816887
setupStore1262741320
numNetworkReqs312297212592
Chrome Webpack Startup Power User HomeuiStartup1232905194315313181490
load71763113221217021006
domContentLoaded7096261316121692997
domInteractive37172093334119
firstPaint1306649889123352
backgroundConnect17713235652187297
firstReactRender22173332428
initialActions102111
loadScripts7066241303118690988
setupStore1344981335
numNetworkReqs1023625853135241
Firefox Browserify Startup Standard HomeuiStartup16351411226715616381983
load13751191180311314031616
domContentLoaded13741191180311414001615
domInteractive77333224491137
firstPaint------
backgroundConnect60302493062107
firstReactRender13112421415
initialActions102012
loadScripts13461168178310213781563
setupStore2161733114115
numNetworkReqs322099212791
Firefox Browserify Startup Power User HomeuiStartup26952052385739428493518
load15531219242424615892119
domContentLoaded15521214242324615872118
domInteractive11834505102109372
firstPaint------
backgroundConnect2971091281261296871
firstReactRender201467111961
initialActions103122
loadScripts15091196236123615102052
setupStore1278793178148537
numNetworkReqs58261463772137
Firefox Webpack Startup Standard HomeuiStartup17331468335625217531976
load14651207296722814881643
domContentLoaded14641207296722814871643
domInteractive993036655131201
firstPaint------
backgroundConnect62242483473113
firstReactRender17125961825
initialActions102012
loadScripts14401190294022614651612
setupStore187117181850
numNetworkReqs311993182778
Firefox Webpack Startup Power User HomeuiStartup27561881780667628343723
load16341253652157617322298
domContentLoaded16341253652157617322298
domInteractive1053155696103320
firstPaint------
backgroundConnect3341041304286391911
firstReactRender21156562329
initialActions207122
loadScripts15841237649156316562216
setupStore1668793227201703
numNetworkReqs56261433380124
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2214223227
srpButtonToSrpForm9319395
confirmSrpToPwForm2202222
pwFormToMetricsScreen1601616
metricsToWalletReadyScreen1711818
doneButtonToHomeScreen99728112691369
openAccountMenuToAccountListLoaded702820572287238
total856345789518969
Onboarding New WalletcreateWalletToSocialScreen2180218218
srpButtonToPwForm1040104104
createPwToRecoveryScreen8088
skipBackupToMetricsScreen3503535
agreeButtonToOnboardingSuccess1501616
doneButtonToAssetList590114614768
total9701149971146
Asset DetailsassetClickToPriceChart4024042
total4024042
Solana Asset DetailsassetClickToPriceChart4714848
total4714848
Import Srp HomeloginToHomeScreen19217819032051
openAccountMenuAfterLogin4124244
homeAfterImportWithNewWallet24449724822589
total448320845704831
Send TransactionsopenSendPageFromHome1711819
selectTokenToSendFormLoaded2022022
reviewTransactionToConfirmationPage8536850863
total89610901909
SwapopenSwapPageFromHome14823154187
fetchAndDisplaySwapQuotes45831445904603
total47312747574758
🌐 Dapp Page Load Benchmarks

Current Commit: bb94384 | Date: 2/23/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.06s (±41ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 736ms (±39ms) 🟢 | historical mean value: 727ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 79ms (±14ms) 🟢 | historical mean value: 80ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.06s 41ms 1.03s 1.39s 1.08s 1.39s
domContentLoaded 736ms 39ms 717ms 1.05s 763ms 1.05s
firstPaint 79ms 14ms 64ms 208ms 84ms 208ms
firstContentfulPaint 79ms 14ms 64ms 208ms 84ms 208ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: -65.56 KiB (-1.49%)
  • ui: 139.35 KiB (1.7%)
  • common: 225.96 KiB (2.06%)

@khanti42 khanti42 changed the title fix: handle evm unsupported chains gracefully in token import flow for custom network cp-13.18.0 fix: handle evm unsupported chains gracefully in token import flow for custom network cp-13.20.0 Feb 23, 2026
Copy link

@cursor cursor bot left a comment

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.

@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Feb 23, 2026

Builds ready [779be7d]
⚡ Performance Benchmarks (1356 ± 105 ms)
👆 Interaction Benchmarks
ActionMetricMean (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account2624262268
total2624262268
Confirm Txconfirm_tx6034860376047
total6034860376047
Bridge User Actionsbridge_load_page20818224236
bridge_load_asset_picker19018205208
bridge_search_token7002700702
total1099611051106
🔌 Startup Benchmarks
BuildMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
Chrome Browserify Startup Standard HomeuiStartup13561125191010513981535
load115493416689712031324
domContentLoaded114693115949311971309
domInteractive2716111212285
firstPaint2136012582542151078
backgroundConnect20118026313206224
firstReactRender18123941824
initialActions103112
loadScripts96175514039110081116
setupStore1273961321
numNetworkReqs312296212291
Chrome Browserify Startup Power User HomeuiStartup2914140310501174432266213
load12121039184513212531486
domContentLoaded11961021179012712411456
domInteractive3719323373486
firstPaint1978347386263305
backgroundConnect889255483694110583142
firstReactRender24164952533
initialActions104111
loadScripts993828157312610271257
setupStore1353151522
numNetworkReqs78421412496124
Chrome Webpack Startup Standard HomeuiStartup846687108192931999
load72860996687804869
domContentLoaded72260595986797863
domInteractive2716100192376
firstPaint1176030158163223
backgroundConnect26196982843
firstReactRender17113751928
initialActions104112
loadScripts71960395685795861
setupStore1163751218
numNetworkReqs312297212591
Chrome Webpack Startup Power User HomeuiStartup1259849267927813601675
load7296491131102726984
domContentLoaded7186401120103712977
domInteractive39201462937127
firstPaint1476837971198278
backgroundConnect1891001005113168341
firstReactRender22163732329
initialActions102111
loadScripts7156381104101710968
setupStore1344871425
numNetworkReqs1354325938152200
Firefox Browserify Startup Standard HomeuiStartup16801435262120117042031
load14151212224916214521707
domContentLoaded14141212224816214521706
domInteractive843421443112147
firstPaint------
backgroundConnect6032205246287
firstReactRender14112621417
initialActions103112
loadScripts13851185221615514241615
setupStore208159271548
numNetworkReqs311996202786
Firefox Browserify Startup Power User HomeuiStartup28262176884469229863494
load15911272687456415602017
domContentLoaded15911272687456415602017
domInteractive14736721132132479
firstPaint------
backgroundConnect3511211358265442922
firstReactRender201469121955
initialActions203122
loadScripts15531251683455815321894
setupStore148161170196129587
numNetworkReqs77242043797163
Firefox Webpack Startup Standard HomeuiStartup18611464337236618712534
load15581239300830715742081
domContentLoaded15581238300830715732080
domInteractive1013026444133158
firstPaint------
backgroundConnect75284064784135
firstReactRender17133441825
initialActions102122
loadScripts15261223297130315391998
setupStore2982854226103
numNetworkReqs311996182880
Firefox Webpack Startup Power User HomeuiStartup27121868383037629293317
load15781323297225516611967
domContentLoaded15781323297225516601966
domInteractive176541673208183416
firstPaint------
backgroundConnect396541488288540935
firstReactRender20155862228
initialActions213123
loadScripts15331265295224016021944
setupStore13116769177122553
numNetworkReqs80282053994175
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2200220220
srpButtonToSrpForm9529798
confirmSrpToPwForm2202222
pwFormToMetricsScreen1601616
metricsToWalletReadyScreen1611617
doneButtonToHomeScreen113726313821441
openAccountMenuToAccountListLoaded737429074967878
total88829589829013
Onboarding New WalletcreateWalletToSocialScreen2191220221
srpButtonToPwForm1092110112
createPwToRecoveryScreen9099
skipBackupToMetricsScreen3613738
agreeButtonToOnboardingSuccess1601616
doneButtonToAssetList11285011601167
total15165015511555
Asset DetailsassetClickToPriceChart3723740
total3723740
Solana Asset DetailsassetClickToPriceChart5035155
total5035155
Import Srp HomeloginToHomeScreen20052420122036
openAccountMenuAfterLogin3523538
homeAfterImportWithNewWallet23002723262327
total437610243734543
Send TransactionsopenSendPageFromHome31123847
selectTokenToSendFormLoaded2122224
reviewTransactionToConfirmationPage8493852852
total9043908908
SwapopenSwapPageFromHome12024143150
fetchAndDisplaySwapQuotes4572145744574
total46842646854723
🌐 Dapp Page Load Benchmarks

Current Commit: 779be7d | Date: 2/23/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±38ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 735ms (±37ms) 🟢 | historical mean value: 727ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 79ms (±9ms) 🟢 | historical mean value: 80ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 38ms 1.03s 1.34s 1.08s 1.34s
domContentLoaded 735ms 37ms 712ms 1.01s 759ms 1.01s
firstPaint 79ms 9ms 60ms 152ms 88ms 152ms
firstContentfulPaint 79ms 9ms 60ms 152ms 88ms 152ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: -65.56 KiB (-1.49%)
  • ui: 139.01 KiB (1.7%)
  • common: 225.96 KiB (2.06%)

@HowardBraham HowardBraham added this pull request to the merge queue Feb 23, 2026
Merged via the queue into main with commit 9fcbdfe Feb 23, 2026
177 checks passed
@HowardBraham HowardBraham deleted the fix/usetokenwithfiltering branch February 23, 2026 21:45
@github-actions github-actions bot locked and limited conversation to collaborators Feb 23, 2026
@metamaskbot metamaskbot added the release-13.21.0 Issue or pull request that will be included in release 13.21.0 label Feb 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-13.21.0 Issue or pull request that will be included in release 13.21.0 size-S team-networks PRs from the Networks team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants