Skip to content

fix native asset detection#8483

Open
bergarces wants to merge 13 commits intomainfrom
native-asset-detection
Open

fix native asset detection#8483
bergarces wants to merge 13 commits intomainfrom
native-asset-detection

Conversation

@bergarces
Copy link
Copy Markdown
Contributor

@bergarces bergarces commented Apr 16, 2026

Explanation

The code for the new controller currently considers that only assets in the slip44 namespace are native. This limits support for prices on many chains supported by price-api. With this changes, we create a centralised way of determining if an asset is native, as well as support chains for which price-api does not yet support the slip44 entry or for which there is none.

Not doing this would cause a regression when the new controller is updated.

With AssetsController enabled without this changes, we are missing support for chains that already had support before. Mostly due to using a wrong default instead of a specific assetId.
image

image image

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
Changes how assets are classified as native across multiple data sources and legacy formatting paths, which can affect balances/prices and downstream consumers if misidentified. Logic is straightforward but touches core asset pipelines for EVM chains with non-standard native representations.

Overview
Introduces a shared isNativeAsset helper and replaces scattered slip44/string checks across AssetsController, RpcDataSource, BackendWebsocketDataSource, TokenDataSource, and BalanceFetcher, so native assets are recognized even when represented as erc20: (including known IDs from SPOT_PRICES_SUPPORT_INFO and zero-address ERC-20).

Updates bridge and transaction-pay legacy format conversions to use getNativeTokenAddress(chainId) (instead of always the zero address) when emitting native token entries, and adjusts RPC native asset ID fallback to ${chainId}/erc20:${ZERO_ADDRESS}. Also exports SPOT_PRICES_SUPPORT_INFO from @metamask/assets-controllers and updates tests to expect chain-specific native addresses (e.g., Polygon 0x…1010).

Reviewed by Cursor Bugbot for commit cf3f16d. Bugbot is set up for automated code reviews on this repo. Configure here.

@bergarces bergarces requested a review from a team as a code owner April 16, 2026 10:22
Comment thread packages/assets-controller/src/data-sources/RpcDataSource.ts
Comment thread packages/assets-controller/src/data-sources/RpcDataSource.ts
Comment thread packages/assets-controller/src/utils/formatExchangeRatesForBridge.ts Outdated
@bergarces
Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-previews

@github-actions
Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/account-tree-controller@7.1.0-preview-a7ae91da8
@metamask-previews/accounts-controller@37.2.0-preview-a7ae91da8
@metamask-previews/address-book-controller@7.1.1-preview-a7ae91da8
@metamask-previews/ai-controllers@0.6.3-preview-a7ae91da8
@metamask-previews/analytics-controller@1.0.1-preview-a7ae91da8
@metamask-previews/analytics-data-regulation-controller@0.0.0-preview-a7ae91da8
@metamask-previews/announcement-controller@8.1.0-preview-a7ae91da8
@metamask-previews/app-metadata-controller@2.0.1-preview-a7ae91da8
@metamask-previews/approval-controller@9.0.1-preview-a7ae91da8
@metamask-previews/assets-controller@6.0.0-preview-a7ae91da8
@metamask-previews/assets-controllers@104.0.0-preview-a7ae91da8
@metamask-previews/base-controller@9.1.0-preview-a7ae91da8
@metamask-previews/base-data-service@0.1.1-preview-a7ae91da8
@metamask-previews/bridge-controller@70.1.1-preview-a7ae91da8
@metamask-previews/bridge-status-controller@70.0.5-preview-a7ae91da8
@metamask-previews/build-utils@3.0.4-preview-a7ae91da8
@metamask-previews/chain-agnostic-permission@1.5.0-preview-a7ae91da8
@metamask-previews/claims-controller@0.5.0-preview-a7ae91da8
@metamask-previews/client-controller@1.0.1-preview-a7ae91da8
@metamask-previews/compliance-controller@2.0.0-preview-a7ae91da8
@metamask-previews/composable-controller@12.0.1-preview-a7ae91da8
@metamask-previews/config-registry-controller@0.2.0-preview-a7ae91da8
@metamask-previews/connectivity-controller@0.2.0-preview-a7ae91da8
@metamask-previews/controller-utils@11.20.0-preview-a7ae91da8
@metamask-previews/core-backend@6.2.1-preview-a7ae91da8
@metamask-previews/delegation-controller@3.0.0-preview-a7ae91da8
@metamask-previews/earn-controller@12.0.0-preview-a7ae91da8
@metamask-previews/eip-5792-middleware@3.0.3-preview-a7ae91da8
@metamask-previews/eip-7702-internal-rpc-middleware@0.1.0-preview-a7ae91da8
@metamask-previews/eip1193-permission-middleware@1.0.3-preview-a7ae91da8
@metamask-previews/ens-controller@19.1.1-preview-a7ae91da8
@metamask-previews/eth-block-tracker@15.0.1-preview-a7ae91da8
@metamask-previews/eth-json-rpc-middleware@23.1.1-preview-a7ae91da8
@metamask-previews/eth-json-rpc-provider@6.0.1-preview-a7ae91da8
@metamask-previews/foundryup@1.0.1-preview-a7ae91da8
@metamask-previews/gas-fee-controller@26.1.1-preview-a7ae91da8
@metamask-previews/gator-permissions-controller@4.0.0-preview-a7ae91da8
@metamask-previews/geolocation-controller@0.1.2-preview-a7ae91da8
@metamask-previews/json-rpc-engine@10.2.4-preview-a7ae91da8
@metamask-previews/json-rpc-middleware-stream@8.0.8-preview-a7ae91da8
@metamask-previews/keyring-controller@25.2.0-preview-a7ae91da8
@metamask-previews/logging-controller@8.0.1-preview-a7ae91da8
@metamask-previews/message-manager@14.1.1-preview-a7ae91da8
@metamask-previews/messenger@1.1.1-preview-a7ae91da8
@metamask-previews/messenger-cli@0.1.0-preview-a7ae91da8
@metamask-previews/money-account-balance-service@0.2.0-preview-a7ae91da8
@metamask-previews/money-account-controller@0.1.0-preview-a7ae91da8
@metamask-previews/multichain-account-service@8.0.1-preview-a7ae91da8
@metamask-previews/multichain-api-middleware@2.0.0-preview-a7ae91da8
@metamask-previews/multichain-network-controller@3.0.6-preview-a7ae91da8
@metamask-previews/multichain-transactions-controller@7.0.4-preview-a7ae91da8
@metamask-previews/name-controller@9.1.1-preview-a7ae91da8
@metamask-previews/network-controller@30.0.1-preview-a7ae91da8
@metamask-previews/network-enablement-controller@5.0.2-preview-a7ae91da8
@metamask-previews/notification-services-controller@23.1.0-preview-a7ae91da8
@metamask-previews/permission-controller@12.3.0-preview-a7ae91da8
@metamask-previews/permission-log-controller@5.1.0-preview-a7ae91da8
@metamask-previews/perps-controller@3.1.1-preview-a7ae91da8
@metamask-previews/phishing-controller@17.1.1-preview-a7ae91da8
@metamask-previews/polling-controller@16.0.4-preview-a7ae91da8
@metamask-previews/preferences-controller@23.1.0-preview-a7ae91da8
@metamask-previews/profile-metrics-controller@3.1.3-preview-a7ae91da8
@metamask-previews/profile-sync-controller@28.0.2-preview-a7ae91da8
@metamask-previews/ramps-controller@13.2.0-preview-a7ae91da8
@metamask-previews/rate-limit-controller@7.0.1-preview-a7ae91da8
@metamask-previews/react-data-query@0.2.0-preview-a7ae91da8
@metamask-previews/remote-feature-flag-controller@4.2.0-preview-a7ae91da8
@metamask-previews/sample-controllers@4.0.4-preview-a7ae91da8
@metamask-previews/seedless-onboarding-controller@9.1.0-preview-a7ae91da8
@metamask-previews/selected-network-controller@26.1.0-preview-a7ae91da8
@metamask-previews/shield-controller@5.1.1-preview-a7ae91da8
@metamask-previews/signature-controller@39.2.0-preview-a7ae91da8
@metamask-previews/social-controllers@1.0.0-preview-a7ae91da8
@metamask-previews/storage-service@1.0.1-preview-a7ae91da8
@metamask-previews/subscription-controller@6.1.2-preview-a7ae91da8
@metamask-previews/transaction-controller@64.3.0-preview-a7ae91da8
@metamask-previews/transaction-pay-controller@19.2.0-preview-a7ae91da8
@metamask-previews/user-operation-controller@41.2.0-preview-a7ae91da8

@bergarces bergarces force-pushed the native-asset-detection branch from a7ae91d to f57ddeb Compare April 17, 2026 09:35
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 1 potential issue.

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.

Reviewed by Cursor Bugbot for commit 994d5ea. Configure here.

Comment thread packages/assets-controller/src/utils/formatStateForTransactionPay.ts Outdated
@bergarces bergarces requested a review from a team as a code owner April 17, 2026 10:48
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