Skip to content

feat: assets controllers config registry native asset - #9789

Open
maxime-oe wants to merge 8 commits into
mainfrom
feat/assets-controllers-config-registry-native-asset-id
Open

feat: assets controllers config registry native asset#9789
maxime-oe wants to merge 8 commits into
mainfrom
feat/assets-controllers-config-registry-native-asset-id

Conversation

@maxime-oe

@maxime-oe maxime-oe commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Explanation

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

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: TokenRatesController now depends on @metamask/config-registry-controller and its messenger must delegate ConfigRegistryController:getNetworkConfigByCaip2ChainId.

Before each updateExchangeRates run, TokenRatesController seeds a per-chain module cache (via new setNetworkConfig / resetNetworkConfigsCache in codefi-v2) by calling that action for only the chains being priced. getAssetId and CodefiTokenPricesServiceV2 then resolve native token CAIP-19 IDs with priority: config registry assets.native.assetId → hardcoded SPOT_PRICES_SUPPORT_INFONetworkEnablementController native 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.

maxime-oe and others added 3 commits August 5, 2026 11:01
…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>
@maxime-oe maxime-oe changed the title Feat/assets controllers config registry native asset Feat; assets controllers config registry native asset Aug 5, 2026
@maxime-oe maxime-oe changed the title Feat; assets controllers config registry native asset feat: assets controllers config registry native asset Aug 5, 2026
maxime-oe and others added 5 commits August 5, 2026 11:20
- 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
maxime-oe marked this pull request as ready for review August 5, 2026 10:08
@maxime-oe
maxime-oe requested review from a team as code owners August 5, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant