normalize assetIds for native assets#8789
Merged
Merged
Conversation
Prithpal-Sooriya
approved these changes
May 13, 2026
7 tasks
pull Bot
pushed a commit
to Reality2byte/metamask-extension
that referenced
this pull request
May 14, 2026
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** patch assets controller 7.0.0 core PRs: - MetaMask/core#8789 - MetaMask/core#8781 - MetaMask/core#8786 <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: patch assets controller 7.0.0 ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Touches token/native balance normalization and default asset metadata keying; mistakes could lead to incorrect balances or duplicate/missing asset entries in state. > > **Overview** > Applies a Yarn patch override for `@metamask/assets-controller@7.0.0` and updates the lockfile to use the patched package. > > The patch tightens `RpcDataSource` balance conversion by validating `decimals` and raw balances (defaulting invalid values to `"0"`), and only reuses existing asset metadata when it has valid `decimals` (with a helper to pick the first valid decimals source). > > It also standardizes default/native asset identifiers: `mUSD` defaults now use an EIP-55 checksummed address and `DEFAULT_ASSET_METADATA` keys are stored/queried as checksummed CAIP-19 IDs (no `.toLowerCase()`), and `buildNativeAssetsFromConstant` now runs IDs through `normalizeAssetId`. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 58b729d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
Normalizes native asset addresses.
References
Checklist
Note
Medium Risk
Changes the canonical native asset IDs produced by
buildNativeAssetsFromConstant, which can affect cache/state keys and lookups if any consumers relied on the previous un-normalized IDs. Logic is small and test-covered, with normalization limited to EVMerc20CAIP-19 IDs.Overview
Native-asset seeding now normalizes each CAIP-19 native asset ID returned by
buildNativeAssetsFromConstantusingnormalizeAssetId, aligning the seed map with IDs produced by other data sources (e.g., EIP-55 checksummed ERC-20 addresses).Tests were updated to assert the normalized IDs, and the package changelog documents the fix.
Reviewed by Cursor Bugbot for commit 00b8711. Bugbot is set up for automated code reviews on this repo. Configure here.