feat: assets-controllers extract and export getAssetId#9386
Conversation
|
@metamaskbot publish-preview |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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 99313eb. Configure here.
| */ | ||
| const chainIdToNativeTokenAddress: Record<Hex, Hex> = { | ||
| '0x89': '0x0000000000000000000000000000000000001010', // Polygon | ||
| '0x1e': '0x542fda317318ebf1d3deaf76e0b632741a7e677d', // Rootstock Mainnet - Native symbol: RBTC |
There was a problem hiding this comment.
Rootstock native address mapping removed
Medium Severity
The Rootstock (0x1e) entry was removed from chainIdToNativeTokenAddress, so getNativeTokenAddress now returns the zero address instead of RBTC’s contract address. Native detection in getAssetId and market-data keys in TokenRatesController no longer match wallets that still use the RBTC address, which can misclassify native RBTC as ERC-20 or drop prices.
Reviewed by Cursor Bugbot for commit 99313eb. Configure here.
There was a problem hiding this comment.
0x542fda317318ebf1d3deaf76e0b632741a7e677d has never been the native.
99313eb to
734dfcf
Compare
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
| }: { | ||
| chainId: Hex; | ||
| tokenAddress: string; | ||
| nativeAssetIdentifiers: NativeAssetIdentifiersMap; |
There was a problem hiding this comment.
1 tiny nit, I think we can make this an optional obj (so consumers don't need to pass this in.
| nativeAssetIdentifiers: NativeAssetIdentifiersMap; | |
| nativeAssetIdentifiers?: NativeAssetIdentifiersMap; |


Explanation
Extract
getAssetIdfrom thefetchTokenPricesso it can be reused later not only for v3 Spot Prices but also V3 historical prices (example client PR soon).References
Checklist
Note
Low Risk
Mostly a refactor plus a new public export; the Rootstock native-address map removal is a small behavior tweak for how native tokens are detected by address.
Overview
Extracts CAIP-19 asset ID resolution from
CodefiTokenPricesServiceV2.fetchTokenPricesinto a sharedgetAssetIdhelper and re-exports it fromtoken-prices-serviceand the packageindex, so spot and upcoming historical Price API callers can use the same logic.getAssetIdpicksSPOT_PRICES_SUPPORT_INFOfor native tokens when present, otherwisenativeAssetIdentifiers, and buildseip155:…/erc20:…for ERC-20s.fetchTokenPricesnow calls this helper instead of inlined mapping.Also removes Rootstock (
0x1e) fromchainIdToNativeTokenAddress, so Rootstock native is treated like the zero address for native-vs-ERC-20 checks (Rootstock pricing still uses the slip44 entry inSPOT_PRICES_SUPPORT_INFO).Reviewed by Cursor Bugbot for commit 734dfcf. Bugbot is set up for automated code reviews on this repo. Configure here.