feat: assets controllers config registry native asset - #9789
Open
maxime-oe wants to merge 8 commits into
Open
Conversation
…ry before SPOT_PRICES_SUPPORT_INFO getAssetId (and CodefiTokenPricesServiceV2.fetchTokenPrices internally) now checks ConfigRegistryController's assets.native.assetId first, falling back to the hardcoded SPOT_PRICES_SUPPORT_INFO map and then to NetworkEnablementController's nativeAssetIdentifiers. New chains get correct native-asset pricing without a SPOT_PRICES_SUPPORT_INFO release. getAssetId keeps its original two-arg signature so internal fetchTokenPrices and external callers get the same answer: the registry data lives in a module-level cache (mirroring the existing getSupportedNetworks/ getSupportedCurrencies pattern in this file), fed and kept current by TokenRatesController via ConfigRegistryController's state and stateChanged event. BREAKING: TokenRatesControllerMessenger now requires the ConfigRegistryController:getState action and ConfigRegistryController:stateChanged event to be delegated. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…rs-config-registry-native-asset-id # Conflicts: # packages/assets-controllers/CHANGELOG.md
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- Regenerate README.md via yarn readme-content:update (was failing the readme-content:check lint job). - Add the missing @metamask/config-registry-controller entry to yarn.lock for assets-controllers, which was never regenerated after the dependency was added to package.json. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…stead of bulk getState Use ConfigRegistryController's direct getNetworkConfigByCaip2ChainId action instead of getState, called per chain right before TokenRatesController prices that chain's assets: - Avoids reaching into ConfigRegistryController's raw state shape (configs.networks) from outside the controller, going through its published per-chain lookup instead. - The cache only ever holds chains that have actually been resolved, never a bulk snapshot of the entire (possibly large) network map. - Always fresh on use, so the ConfigRegistryController:stateChanged subscription is no longer needed. setNetworkConfigs (bulk) is replaced by setNetworkConfig (single chain, upserts or clears one entry) in codefi-v2.ts. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…oject reference Fixes lint:tsconfigs:all — tsconfig.json/tsconfig.build.json references must mirror package.json dependencies, and the config-registry-controller dependency added earlier was missing its reference. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…rs-config-registry-native-asset-id # Conflicts: # packages/assets-controllers/CHANGELOG.md
maxime-oe
marked this pull request as ready for review
August 5, 2026 10:08
maxime-oe
temporarily deployed
to
default-branch
August 5, 2026 10:08 — with
GitHub Actions
Inactive
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
References
Checklist
Note
Medium Risk
Breaking messenger delegation is required for all clients, and native token price lookups can change when the config registry overrides hardcoded asset IDs.
Overview
Breaking:
TokenRatesControllernow depends on@metamask/config-registry-controllerand its messenger must delegateConfigRegistryController:getNetworkConfigByCaip2ChainId.Before each
updateExchangeRatesrun,TokenRatesControllerseeds a per-chain module cache (via newsetNetworkConfig/resetNetworkConfigsCacheincodefi-v2) by calling that action for only the chains being priced.getAssetIdandCodefiTokenPricesServiceV2then resolve native token CAIP-19 IDs with priority: config registryassets.native.assetId→ hardcodedSPOT_PRICES_SUPPORT_INFO→NetworkEnablementControllernative identifiers. New chains can get correct native spot-price IDs without shipping a new hardcoded map.Tests and package/tsconfig wiring cover the new dependency and resolution order.
Reviewed by Cursor Bugbot for commit 286a1db. Bugbot is set up for automated code reviews on this repo. Configure here.