Skip to content

fix: resolve slip44 key mismatch for native tokens in assets-unify-state selectors#40964

Merged
salimtb merged 2 commits intomainfrom
fix/assets-unify-avax-slip44-key-mismatch
Mar 17, 2026
Merged

fix: resolve slip44 key mismatch for native tokens in assets-unify-state selectors#40964
salimtb merged 2 commits intomainfrom
fix/assets-unify-avax-slip44-key-mismatch

Conversation

@salimtb
Copy link
Copy Markdown
Contributor

@salimtb salimtb commented Mar 17, 2026

Description

When assets-unify-state is enabled, assetsInfo stores native EVM tokens using slip44:60 (EVM generic coin type) while assetsPrice may use a chain-specific slip44 (e.g. slip44:9005 for AVAX on Avalanche C-Chain).

This mismatch caused two selectors to silently skip affected native tokens:

  • getCurrencyRateControllerCurrencyRates: no conversion rate for AVAX, making token.secondary undefined on the token list
  • getTokenRatesControllerMarketData: no market data for AVAX, making pricePercentChange1d undefined and hiding the % change badge

Both selectors now fall back to a chain-prefix scan when the direct assetId lookup misses, bridging the key mismatch without changing stored state.

Open in GitHub Codespaces

Changelog

CHANGELOG entry: resolve slip44 key mismatch for native tokens in assets-unify-state selectors

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

after.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
Touches rate/market-data selectors used for token pricing and currency conversion; the new chain-prefix fallback could select an unintended slip44 entry if multiple native-price keys exist for a chain.

Overview
Fixes assets-unify-state selectors to handle native EVM tokens when assetsInfo uses slip44:60 but assetsPrice uses a chain-specific slip44 (e.g. AVAX). getCurrencyRateControllerCurrencyRates now falls back to any native slip44:* price entry for the same chain when a direct lookup misses.

Similarly, getTokenRatesControllerMarketData adds a guarded fallback (only for native slip44 assets) to find matching native metadata in assetsInfo, preventing misattribution of ERC-20 prices.

Expands assets-migration.test.ts with many new edge-case tests across the migrated selectors (deduping customAssets, skipping missing metadata/non-EVM assets, multi-account/multi-chain behavior, decimal parsing), including explicit coverage for the slip44 mismatch scenarios.

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

…unify-state selectors

When assets-unify-state is enabled, assetsInfo stores native EVM tokens
using slip44:60 (EVM generic coin type) while assetsPrice may use a
chain-specific slip44 (e.g. slip44:9005 for AVAX on Avalanche C-Chain).

This mismatch caused two selectors to silently skip affected native tokens:
- getCurrencyRateControllerCurrencyRates: no conversion rate for AVAX,
  making token.secondary undefined on the token list
- getTokenRatesControllerMarketData: no market data for AVAX, making
  pricePercentChange1d undefined and hiding the % change badge

Both selectors now fall back to a chain-prefix scan when the direct assetId
lookup misses, bridging the key mismatch without changing stored state.
@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.

@salimtb salimtb marked this pull request as ready for review March 17, 2026 14:49
@salimtb salimtb changed the title fix(assets): resolve slip44 key mismatch for native tokens in assets-unify-state selectors fix: resolve slip44 key mismatch for native tokens in assets-unify-state selectors Mar 17, 2026
@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Mar 17, 2026

Builds ready [6997581]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account29727133623309336
total29727133623309336
Confirm Txconfirm_tx602760216032560326032
total602760216032560326032
Bridge User Actionsbridge_load_page26519732647308326
bridge_load_asset_picker33023347594409475
bridge_search_token74372475513754755
total1291122213765612961376
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup14491198176610914951656
load119598714329312251377
domContentLoaded118898413939012181356
domInteractive2918115212589
firstPaint157711195125207242
backgroundConnect21219430315214239
firstReactRender21128992129
initialActions106123
loadScripts99278711968910231158
setupStore1474361627
numNetworkReqs393186163780
Power User HomeuiStartup56321998177392837656010135
load13291128182414913731672
domContentLoaded13081107176614013401653
domInteractive42212754333151
firstPaint225901260142280365
backgroundConnect230731614597266434515873
firstReactRender2817364342735
initialActions108114
loadScripts1081895149013111021411
setupStore1668191727
numNetworkReqs1437335745151249
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2202192221220222
srpButtonToSrpForm9591103497103
confirmSrpToPwForm22212312223
pwFormToMetricsScreen16151601616
metricsToWalletReadyScreen17161701717
doneButtonToHomeScreen71959385494794854
openAccountMenuToAccountListLoaded2838271629419929182941
total3930381940769039634076
Onboarding New WalletcreateWalletToSocialScreen2202152263222226
srpButtonToPwForm1131091226110122
createPwToRecoveryScreen889099
skipBackupToMetricsScreen40394114141
agreeButtonToOnboardingSuccess17161701717
doneButtonToAssetList52348957635533576
total93388198949975989
Asset DetailsassetClickToPriceChart664699207899
total664699207899
Solana Asset DetailsassetClickToPriceChart756095158695
total756095158695
Import Srp HomeloginToHomeScreen2388229824736223942473
openAccountMenuAfterLogin84729488494
homeAfterImportWithNewWallet14865872845104126712845
total399830655346105852375346
Send TransactionsopenSendPageFromHome32293523235
selectTokenToSendFormLoaded30263543335
reviewTransactionToConfirmationPage1227115912734212441273
total1295122413534713141353
SwapopenSwapPageFromHome1281251323132132
fetchAndDisplaySwapQuotes268826842691326902691
total2813278628341828242834
🌐 Dapp Page Load Benchmarks

Current Commit: 6997581 | Date: 3/17/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.07s (±41ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 750ms (±37ms) 🟢 | historical mean value: 734ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 83ms (±14ms) 🟢 | historical mean value: 87ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.07s 41ms 1.03s 1.38s 1.09s 1.38s
domContentLoaded 750ms 37ms 723ms 1.04s 768ms 1.04s
firstPaint 83ms 14ms 64ms 212ms 92ms 212ms
firstContentfulPaint 83ms 14ms 64ms 212ms 92ms 212ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 422 Bytes (0.01%)
  • ui: 5.59 KiB (0.07%)
  • common: 1.12 KiB (0.01%)

Copy link
Copy Markdown

@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 2 potential issues.

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.

@sonarqubecloud
Copy link
Copy Markdown

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Mar 17, 2026

Builds ready [ef0e39e]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account2772752792279279
total2772752792279279
Confirm Txconfirm_tx601560076029860146029
total601560076029860146029
Bridge User Actionsbridge_load_page22719528037265280
bridge_load_asset_picker26625428513278285
bridge_search_token79675586845830868
total1289121314188613661418
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup14861228177910615481660
load1225101114539512761384
domContentLoaded1219100614239312701377
domInteractive3017130222685
firstPaint181731307180213364
backgroundConnect21719827613220243
firstReactRender21134972137
initialActions106124
loadScripts101780712139010631162
setupStore1375771724
numNetworkReqs393186164079
Power User HomeuiStartup57672183184113086679114026
load13421132179713414081627
domContentLoaded13241128175112513771578
domInteractive3821194333297
firstPaint227871450158302383
backgroundConnect224835014817268327928514
firstReactRender25164252739
initialActions109113
loadScripts1094921144411811471327
setupStore1665081829
numNetworkReqs1366127245147241
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2192172211220221
srpButtonToSrpForm95949619696
confirmSrpToPwForm23222412324
pwFormToMetricsScreen16151601616
metricsToWalletReadyScreen16161701617
doneButtonToHomeScreen61459666630599666
openAccountMenuToAccountListLoaded2913289829221029212922
total3896386339463038883946
Onboarding New WalletcreateWalletToSocialScreen2202192200220220
srpButtonToPwForm1121101152114115
createPwToRecoveryScreen999099
skipBackupToMetricsScreen40404104041
agreeButtonToOnboardingSuccess17161811718
doneButtonToAssetList51648454623537546
total91988294823933948
Asset DetailsassetClickToPriceChart56546135661
total56546135661
Solana Asset DetailsassetClickToPriceChart14311418126159181
total14311418126159181
Import Srp HomeloginToHomeScreen2396237124141824142414
openAccountMenuAfterLogin53466365463
homeAfterImportWithNewWallet1648533255390923502553
total40952974495091448644950
Send TransactionsopenSendPageFromHome24202732627
selectTokenToSendFormLoaded32293423434
reviewTransactionToConfirmationPage1022685140031013901400
total1078745144930614421449
SwapopenSwapPageFromHome1089012212113122
fetchAndDisplaySwapQuotes268826852692326892692
total2803277928341828082834
🌐 Dapp Page Load Benchmarks

Current Commit: ef0e39e | Date: 3/17/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.01s (±115ms) 🟡 | historical mean value: 1.04s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 710ms (±139ms) 🟢 | historical mean value: 734ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 91ms (±120ms) 🟢 | historical mean value: 87ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.01s 115ms 964ms 2.12s 1.04s 2.12s
domContentLoaded 710ms 139ms 675ms 2.07s 735ms 2.07s
firstPaint 91ms 120ms 68ms 1.29s 88ms 1.29s
firstContentfulPaint 91ms 120ms 68ms 1.29s 88ms 1.29s
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 422 Bytes (0.01%)
  • ui: 5.59 KiB (0.07%)
  • common: 1.15 KiB (0.01%)

continue;
}

// assetsInfo may use slip44:60 (EVM standard) for native tokens while assetsPrice
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.

Is there something we can do in the future to stop assetsInfo having the wrong assetId?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we can hardcode a list but this is not the best approach

@salimtb salimtb added this pull request to the merge queue Mar 17, 2026
Merged via the queue into main with commit 4d25400 Mar 17, 2026
181 of 183 checks passed
@salimtb salimtb deleted the fix/assets-unify-avax-slip44-key-mismatch branch March 17, 2026 17:56
@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-XL team-assets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants