@metamask-previews/assets-controllers 95.3.0-preview-ab102d86 → 96.0.0-preview-863782e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +30 -1
  2. package/dist/NftController.cjs +1 -22
  3. package/dist/NftController.cjs.map +1 -1
  4. package/dist/NftController.d.cts +0 -10
  5. package/dist/NftController.d.cts.map +1 -1
  6. package/dist/NftController.d.mts +0 -10
  7. package/dist/NftController.d.mts.map +1 -1
  8. package/dist/NftController.mjs +1 -22
  9. package/dist/NftController.mjs.map +1 -1
  10. package/dist/TokenRatesController.cjs +8 -1
  11. package/dist/TokenRatesController.cjs.map +1 -1
  12. package/dist/TokenRatesController.d.cts +2 -1
  13. package/dist/TokenRatesController.d.cts.map +1 -1
  14. package/dist/TokenRatesController.d.mts +2 -1
  15. package/dist/TokenRatesController.d.mts.map +1 -1
  16. package/dist/TokenRatesController.mjs +8 -1
  17. package/dist/TokenRatesController.mjs.map +1 -1
  18. package/dist/selectors/token-selectors.cjs +1 -1
  19. package/dist/selectors/token-selectors.cjs.map +1 -1
  20. package/dist/selectors/token-selectors.mjs +1 -1
  21. package/dist/selectors/token-selectors.mjs.map +1 -1
  22. package/dist/token-prices-service/abstract-token-prices-service.cjs.map +1 -1
  23. package/dist/token-prices-service/abstract-token-prices-service.d.cts +12 -1
  24. package/dist/token-prices-service/abstract-token-prices-service.d.cts.map +1 -1
  25. package/dist/token-prices-service/abstract-token-prices-service.d.mts +12 -1
  26. package/dist/token-prices-service/abstract-token-prices-service.d.mts.map +1 -1
  27. package/dist/token-prices-service/abstract-token-prices-service.mjs.map +1 -1
  28. package/dist/token-prices-service/codefi-v2.cjs +228 -18
  29. package/dist/token-prices-service/codefi-v2.cjs.map +1 -1
  30. package/dist/token-prices-service/codefi-v2.d.cts +76 -2
  31. package/dist/token-prices-service/codefi-v2.d.cts.map +1 -1
  32. package/dist/token-prices-service/codefi-v2.d.mts +76 -2
  33. package/dist/token-prices-service/codefi-v2.d.mts.map +1 -1
  34. package/dist/token-prices-service/codefi-v2.mjs +222 -18
  35. package/dist/token-prices-service/codefi-v2.mjs.map +1 -1
  36. package/dist/token-prices-service/index.cjs +4 -1
  37. package/dist/token-prices-service/index.cjs.map +1 -1
  38. package/dist/token-prices-service/index.d.cts +2 -2
  39. package/dist/token-prices-service/index.d.cts.map +1 -1
  40. package/dist/token-prices-service/index.d.mts +2 -2
  41. package/dist/token-prices-service/index.d.mts.map +1 -1
  42. package/dist/token-prices-service/index.mjs +1 -1
  43. package/dist/token-prices-service/index.mjs.map +1 -1
  44. package/package.json +3 -2
@@ -1 +1 @@
1
- {"version":3,"file":"token-selectors.mjs","sourceRoot":"","sources":["../../src/selectors/token-selectors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,mCAAmC;AACjE,OAAO,EAAE,QAAQ,EAAE,8BAA8B;AAGjD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,wBAAwB;AAElE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB;AAG1D,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC7B,gCAA4B;AAK7B,OAAO,EAAE,qBAAqB,EAAE,8CAA0C;AAK1E,qBAAqB;AACrB,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,MAAM,EAAE,QAAQ;IAChB,SAAS,EAAE,WAAW;IACtB,UAAU,EAAE,YAAY;IACxB,aAAa,EAAE,eAAe;IAC9B,WAAW,EAAE,aAAa;IAC1B,cAAc,EAAE,gBAAgB;CACxB,CAAC;AAKX,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAChD,aAAa,CACmB,CAAC;AAEnC,MAAM,CAAC,MAAM,yBAAyB,GACpC,IAAI,GAAG,CAAC,qBAAqB,CAAC,CAAC;AA4EjC,MAAM,uBAAuB,GAAG,cAAc,CAAC,SAAS,EAAkB,CAAC;AAE3E,MAA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;;;;;GAOG;AACH,SAAS,gCAAgC,CACvC,OAAyC,EACzC,yBAAkF,EAClF,OAAkD;IAElD,MAAM,eAAe,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAE3D,IAAI,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC;QAC3B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC;QAC9D,cAAc,EAAE,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC;KAC7C,CAAC;AACJ,CAAC","sourcesContent":["import type { AccountGroupId } from '@metamask/account-api';\nimport type { AccountTreeControllerState } from '@metamask/account-tree-controller';\nimport type { AccountsControllerState } from '@metamask/accounts-controller';\nimport { convertHexToDecimal } from '@metamask/controller-utils';\nimport { TrxScope } from '@metamask/keyring-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { NetworkState } from '@metamask/network-controller';\nimport { hexToBigInt, parseCaipAssetType } from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\nimport { createSelector, weakMapMemoize } from 'reselect';\nimport { TokenRwaData } from 'src/token-service';\n\nimport {\n parseBalanceWithDecimals,\n stringifyBalanceWithDecimals,\n} from './stringify-balance';\nimport type { CurrencyRateState } from '../CurrencyRateController';\nimport type { MultichainAssetsControllerState } from '../MultichainAssetsController';\nimport type { MultichainAssetsRatesControllerState } from '../MultichainAssetsRatesController';\nimport type { MultichainBalancesControllerState } from '../MultichainBalancesController';\nimport { getNativeTokenAddress } from '../token-prices-service/codefi-v2';\nimport type { TokenBalancesControllerState } from '../TokenBalancesController';\nimport type { Token, TokenRatesControllerState } from '../TokenRatesController';\nimport type { TokensControllerState } from '../TokensController';\n\n// Asset Tron Filters\nexport const TRON_RESOURCE = {\n ENERGY: 'energy',\n BANDWIDTH: 'bandwidth',\n MAX_ENERGY: 'max-energy',\n MAX_BANDWIDTH: 'max-bandwidth',\n STRX_ENERGY: 'strx-energy',\n STRX_BANDWIDTH: 'strx-bandwidth',\n} as const;\n\nexport type TronResourceSymbol =\n (typeof TRON_RESOURCE)[keyof typeof TRON_RESOURCE];\n\nexport const TRON_RESOURCE_SYMBOLS = Object.values(\n TRON_RESOURCE,\n) as readonly TronResourceSymbol[];\n\nexport const TRON_RESOURCE_SYMBOLS_SET: ReadonlySet<TronResourceSymbol> =\n new Set(TRON_RESOURCE_SYMBOLS);\n\nexport type AssetsByAccountGroup = {\n [accountGroupId: AccountGroupId]: AccountGroupAssets;\n};\n\nexport type AccountGroupAssets = {\n [network: string]: Asset[];\n};\n\ntype EvmAccountType = Extract<InternalAccount['type'], `eip155:${string}`>;\ntype MultichainAccountType = Exclude<\n InternalAccount['type'],\n `eip155:${string}`\n>;\n\nexport type Asset = (\n | {\n accountType: EvmAccountType;\n assetId: Hex; // This is also the address for EVM tokens\n address: Hex;\n chainId: Hex;\n }\n | {\n accountType: MultichainAccountType;\n assetId: `${string}:${string}/${string}:${string}`;\n chainId: `${string}:${string}`;\n }\n) & {\n accountId: string;\n image: string;\n name: string;\n symbol: string;\n decimals: number;\n isNative: boolean;\n rawBalance: Hex;\n balance: string;\n fiat:\n | {\n balance: number;\n currency: string;\n conversionRate: number;\n }\n | undefined;\n rwaData?: TokenRwaData;\n};\n\nexport type AssetListState = {\n accountTree: AccountTreeControllerState['accountTree'];\n internalAccounts: AccountsControllerState['internalAccounts'];\n allTokens: TokensControllerState['allTokens'];\n allIgnoredTokens: TokensControllerState['allIgnoredTokens'];\n tokenBalances: TokenBalancesControllerState['tokenBalances'];\n marketData: TokenRatesControllerState['marketData'];\n currencyRates: CurrencyRateState['currencyRates'];\n accountsAssets: MultichainAssetsControllerState['accountsAssets'];\n allIgnoredAssets: MultichainAssetsControllerState['allIgnoredAssets'];\n assetsMetadata: MultichainAssetsControllerState['assetsMetadata'];\n balances: MultichainBalancesControllerState['balances'];\n conversionRates: MultichainAssetsRatesControllerState['conversionRates'];\n currentCurrency: CurrencyRateState['currentCurrency'];\n networkConfigurationsByChainId: NetworkState['networkConfigurationsByChainId'];\n // This is the state from AccountTrackerController. The state is different on mobile and extension\n // accountsByChainId with a balance is the only field that both clients have in common\n // This field could be removed once TokenBalancesController returns native balances\n accountsByChainId: Record<\n Hex,\n Record<\n Hex,\n {\n balance: Hex | null;\n }\n >\n >;\n};\n\nconst createAssetListSelector = createSelector.withTypes<AssetListState>();\n\nconst selectAccountsToGroupIdMap = createAssetListSelector(\n [(state) => state.accountTree, (state) => state.internalAccounts],\n (accountTree, internalAccounts) => {\n const accountsMap: Record<\n string,\n {\n accountGroupId: AccountGroupId;\n type: InternalAccount['type'];\n accountId: string;\n }\n > = {};\n for (const { groups } of Object.values(accountTree.wallets)) {\n for (const { id: accountGroupId, accounts } of Object.values(groups)) {\n for (const accountId of accounts) {\n const internalAccount = internalAccounts.accounts[accountId];\n\n accountsMap[\n // TODO: We would not need internalAccounts if evmTokens state had the accountId\n internalAccount.type.startsWith('eip155')\n ? internalAccount.address\n : accountId\n ] = { accountGroupId, type: internalAccount.type, accountId };\n }\n }\n }\n\n return accountsMap;\n },\n);\n\n// TODO: This selector will not be needed once the native balances are part of the evm tokens state\nconst selectAllEvmAccountNativeBalances = createAssetListSelector(\n [\n selectAccountsToGroupIdMap,\n (state) => state.accountsByChainId,\n (state) => state.marketData,\n (state) => state.currencyRates,\n (state) => state.currentCurrency,\n (state) => state.networkConfigurationsByChainId,\n ],\n (\n accountsMap,\n accountsByChainId,\n marketData,\n currencyRates,\n currentCurrency,\n networkConfigurationsByChainId,\n ) => {\n const groupAssets: AssetsByAccountGroup = {};\n\n for (const [chainId, chainAccounts] of Object.entries(\n accountsByChainId,\n ) as [Hex, Record<Hex, { balance: Hex | null }>][]) {\n for (const [accountAddress, accountBalance] of Object.entries(\n chainAccounts,\n )) {\n const account = accountsMap[accountAddress.toLowerCase()];\n if (!account) {\n continue;\n }\n\n const { accountGroupId, type, accountId } = account;\n\n groupAssets[accountGroupId] ??= {};\n groupAssets[accountGroupId][chainId] ??= [];\n const groupChainAssets = groupAssets[accountGroupId][chainId];\n\n // If a native balance is missing, we still want to show it as 0\n const rawBalance = accountBalance.balance || '0x0';\n\n const nativeCurrency =\n networkConfigurationsByChainId[chainId]?.nativeCurrency || 'NATIVE';\n\n const nativeToken = {\n address: getNativeTokenAddress(chainId),\n decimals: 18,\n name: nativeCurrency === 'ETH' ? 'Ethereum' : nativeCurrency,\n symbol: nativeCurrency,\n // This field need to be filled at client level for now\n image: '',\n };\n\n const fiatData = getFiatBalanceForEvmToken(\n rawBalance,\n nativeToken.decimals,\n marketData,\n currencyRates,\n chainId,\n nativeToken.address,\n nativeCurrency, // Pass native currency symbol for fallback when market data is missing\n );\n\n groupChainAssets.push({\n accountType: type as EvmAccountType,\n assetId: nativeToken.address,\n isNative: true,\n address: nativeToken.address,\n image: nativeToken.image,\n name: nativeToken.name,\n symbol: nativeToken.symbol,\n accountId,\n decimals: nativeToken.decimals,\n rawBalance,\n balance: stringifyBalanceWithDecimals(\n hexToBigInt(rawBalance),\n nativeToken.decimals,\n ),\n fiat: fiatData\n ? {\n balance: fiatData.balance,\n currency: currentCurrency,\n conversionRate: fiatData.conversionRate,\n }\n : undefined,\n chainId,\n });\n }\n }\n\n return groupAssets;\n },\n);\n\nconst selectAllEvmAssets = createAssetListSelector(\n [\n selectAccountsToGroupIdMap,\n (state) => state.allTokens,\n (state) => state.allIgnoredTokens,\n (state) => state.tokenBalances,\n (state) => state.marketData,\n (state) => state.currencyRates,\n (state) => state.currentCurrency,\n ],\n (\n accountsMap,\n evmTokens,\n ignoredEvmTokens,\n tokenBalances,\n marketData,\n currencyRates,\n currentCurrency,\n ) => {\n const groupAssets: AssetsByAccountGroup = {};\n\n for (const [chainId, chainTokens] of Object.entries(evmTokens) as [\n Hex,\n { [key: string]: Token[] },\n ][]) {\n for (const [accountAddress, addressTokens] of Object.entries(\n chainTokens,\n ) as [Hex, Token[]][]) {\n for (const token of addressTokens) {\n const tokenAddress = token.address as Hex;\n const account = accountsMap[accountAddress];\n if (!account) {\n continue;\n }\n\n const { accountGroupId, type, accountId } = account;\n\n if (\n ignoredEvmTokens[chainId]?.[accountAddress]?.includes(tokenAddress)\n ) {\n continue;\n }\n\n const rawBalance =\n tokenBalances[accountAddress]?.[chainId]?.[tokenAddress];\n\n if (!rawBalance) {\n continue;\n }\n\n groupAssets[accountGroupId] ??= {};\n groupAssets[accountGroupId][chainId] ??= [];\n const groupChainAssets = groupAssets[accountGroupId][chainId];\n\n const fiatData = getFiatBalanceForEvmToken(\n rawBalance,\n token.decimals,\n marketData,\n currencyRates,\n chainId,\n tokenAddress,\n );\n\n groupChainAssets.push({\n accountType: type as EvmAccountType,\n assetId: tokenAddress,\n isNative: false,\n address: tokenAddress,\n image: token.image ?? '',\n name: token.name ?? token.symbol,\n symbol: token.symbol,\n accountId,\n decimals: token.decimals,\n rawBalance,\n balance: stringifyBalanceWithDecimals(\n hexToBigInt(rawBalance),\n token.decimals,\n ),\n fiat: fiatData\n ? {\n balance: fiatData.balance,\n currency: currentCurrency,\n conversionRate: fiatData.conversionRate,\n }\n : undefined,\n chainId,\n ...(token.rwaData && { rwaData: token.rwaData }),\n });\n }\n }\n }\n\n return groupAssets;\n },\n);\n\nconst selectAllMultichainAssets = createAssetListSelector(\n [\n selectAccountsToGroupIdMap,\n (state) => state.accountsAssets,\n (state) => state.allIgnoredAssets,\n (state) => state.assetsMetadata,\n (state) => state.balances,\n (state) => state.conversionRates,\n (state) => state.currentCurrency,\n ],\n (\n accountsMap,\n multichainTokens,\n ignoredMultichainAssets,\n multichainAssetsMetadata,\n multichainBalances,\n multichainConversionRates,\n currentCurrency,\n ) => {\n const groupAssets: AssetsByAccountGroup = {};\n\n for (const [accountId, accountAssets] of Object.entries(multichainTokens)) {\n for (const assetId of accountAssets) {\n let caipAsset: ReturnType<typeof parseCaipAssetType>;\n try {\n caipAsset = parseCaipAssetType(assetId);\n } catch {\n // TODO: We should log this error when we have the ability to inject a logger from the client\n continue;\n }\n\n const { chainId } = caipAsset;\n const asset = `${caipAsset.assetNamespace}:${caipAsset.assetReference}`;\n\n const account = accountsMap[accountId];\n const assetMetadata = multichainAssetsMetadata[assetId];\n if (!account || !assetMetadata) {\n continue;\n }\n\n const { accountGroupId, type } = account;\n\n if (ignoredMultichainAssets?.[accountId]?.includes(assetId)) {\n continue;\n }\n\n groupAssets[accountGroupId] ??= {};\n groupAssets[accountGroupId][chainId] ??= [];\n const groupChainAssets = groupAssets[accountGroupId][chainId];\n\n const balance:\n | {\n amount: string;\n unit: string;\n }\n | undefined = multichainBalances[accountId]?.[assetId];\n\n const decimals = assetMetadata.units.find(\n (unit) =>\n unit.name === assetMetadata.name &&\n unit.symbol === assetMetadata.symbol,\n )?.decimals;\n\n if (!balance || decimals === undefined) {\n continue;\n }\n\n const rawBalance = parseBalanceWithDecimals(balance.amount, decimals);\n\n if (!rawBalance) {\n continue;\n }\n\n const fiatData = getFiatBalanceForMultichainAsset(\n balance,\n multichainConversionRates,\n assetId,\n );\n\n // TODO: We shouldn't have to rely on fallbacks for name and symbol, they should not be optional\n groupChainAssets.push({\n accountType: type as MultichainAccountType,\n assetId,\n isNative: caipAsset.assetNamespace === 'slip44',\n image: assetMetadata.iconUrl,\n name: assetMetadata.name ?? assetMetadata.symbol ?? asset,\n symbol: assetMetadata.symbol ?? asset,\n accountId,\n decimals,\n rawBalance,\n balance: balance.amount,\n fiat: fiatData\n ? {\n balance: fiatData.balance,\n currency: currentCurrency,\n conversionRate: fiatData.conversionRate,\n }\n : undefined,\n chainId,\n });\n }\n }\n\n return groupAssets;\n },\n);\n\nexport const selectAllAssets = createAssetListSelector(\n [\n selectAllEvmAssets,\n selectAllMultichainAssets,\n selectAllEvmAccountNativeBalances,\n ],\n (evmAssets, multichainAssets, evmAccountNativeBalances) => {\n const groupAssets: AssetsByAccountGroup = {};\n\n mergeAssets(groupAssets, evmAssets);\n\n mergeAssets(groupAssets, multichainAssets);\n\n mergeAssets(groupAssets, evmAccountNativeBalances);\n\n return groupAssets;\n },\n);\n\nexport type SelectAccountGroupAssetOpts = {\n filterTronStakedTokens: boolean;\n};\n\nconst defaultSelectAccountGroupAssetOpts: SelectAccountGroupAssetOpts = {\n filterTronStakedTokens: true,\n};\n\nconst filterTronStakedTokens = (assetsByAccountGroup: AccountGroupAssets) => {\n const newAssetsByAccountGroup = { ...assetsByAccountGroup };\n\n Object.values(TrxScope).forEach((tronChainId) => {\n if (!newAssetsByAccountGroup[tronChainId]) {\n return;\n }\n\n newAssetsByAccountGroup[tronChainId] = newAssetsByAccountGroup[\n tronChainId\n ].filter((asset: Asset) => {\n if (\n asset.chainId.startsWith('tron:') &&\n TRON_RESOURCE_SYMBOLS_SET.has(\n asset.symbol?.toLowerCase() as TronResourceSymbol,\n )\n ) {\n return false;\n }\n return true;\n });\n });\n\n return newAssetsByAccountGroup;\n};\n\nexport const selectAssetsBySelectedAccountGroup = createAssetListSelector(\n [\n selectAllAssets,\n (state) => state.accountTree,\n (\n _state,\n opts: SelectAccountGroupAssetOpts = defaultSelectAccountGroupAssetOpts,\n ) => opts,\n ],\n (groupAssets, accountTree, opts) => {\n const { selectedAccountGroup } = accountTree;\n if (!selectedAccountGroup) {\n return {};\n }\n\n let result = groupAssets[selectedAccountGroup] || {};\n\n if (opts.filterTronStakedTokens) {\n result = filterTronStakedTokens(result);\n }\n\n return result;\n },\n {\n memoize: weakMapMemoize,\n argsMemoize: weakMapMemoize,\n },\n);\n\n// TODO: Once native assets are part of the evm tokens state, this function can be simplified as chains will always be unique\n/**\n * Merges the new assets into the existing assets\n *\n * @param existingAssets - The existing assets\n * @param newAssets - The new assets\n */\nfunction mergeAssets(\n existingAssets: AssetsByAccountGroup,\n newAssets: AssetsByAccountGroup,\n) {\n for (const [accountGroupId, accountAssets] of Object.entries(newAssets) as [\n AccountGroupId,\n AccountGroupAssets,\n ][]) {\n const existingAccountGroupAssets = existingAssets[accountGroupId];\n\n if (!existingAccountGroupAssets) {\n existingAssets[accountGroupId] = {};\n for (const [network, chainAssets] of Object.entries(accountAssets)) {\n existingAssets[accountGroupId][network] = [...chainAssets];\n }\n } else {\n for (const [network, chainAssets] of Object.entries(accountAssets)) {\n existingAccountGroupAssets[network] ??= [];\n existingAccountGroupAssets[network].push(...chainAssets);\n }\n }\n }\n}\n\n/**\n * @param rawBalance - The balance of the token\n * @param decimals - The decimals of the token\n * @param marketData - The market data for the token\n * @param currencyRates - The currency rates for the token\n * @param chainId - The chain id of the token\n * @param tokenAddress - The address of the token\n * @param nativeCurrencySymbol - The native currency symbol (e.g., 'ETH', 'BNB') - used for fallback when market data is missing for native tokens\n * @returns The price and currency of the token in the current currency. Returns undefined if the asset is not found in the market data or currency rates.\n */\nfunction getFiatBalanceForEvmToken(\n rawBalance: Hex,\n decimals: number,\n marketData: TokenRatesControllerState['marketData'],\n currencyRates: CurrencyRateState['currencyRates'],\n chainId: Hex,\n tokenAddress: Hex,\n nativeCurrencySymbol?: string,\n) {\n const tokenMarketData = marketData[chainId]?.[tokenAddress];\n\n // For native tokens: if no market data exists, use price=1 and look up currency rate directly\n // This is because native tokens are priced in themselves (1 ETH = 1 ETH)\n if (!tokenMarketData && nativeCurrencySymbol) {\n const currencyRate = currencyRates[nativeCurrencySymbol];\n\n if (!currencyRate?.conversionRate) {\n return undefined;\n }\n\n const fiatBalance =\n (convertHexToDecimal(rawBalance) / 10 ** decimals) *\n currencyRate.conversionRate;\n\n return {\n balance: fiatBalance,\n conversionRate: currencyRate.conversionRate,\n };\n }\n\n if (!tokenMarketData) {\n return undefined;\n }\n\n const currencyRate = currencyRates[tokenMarketData.currency];\n\n if (!currencyRate?.conversionRate) {\n return undefined;\n }\n\n const fiatBalance =\n (convertHexToDecimal(rawBalance) / 10 ** decimals) *\n tokenMarketData.price *\n currencyRate.conversionRate;\n\n return {\n balance: fiatBalance,\n conversionRate: currencyRate.conversionRate,\n };\n}\n\n/**\n * @param balance - The balance of the asset, in the format { amount: string; unit: string }\n * @param balance.amount - The amount of the balance\n * @param balance.unit - The unit of the balance\n * @param multichainConversionRates - The conversion rates for the multichain asset\n * @param assetId - The asset id of the asset\n * @returns The price and currency of the token in the current currency. Returns undefined if the asset is not found in the conversion rates.\n */\nfunction getFiatBalanceForMultichainAsset(\n balance: { amount: string; unit: string },\n multichainConversionRates: MultichainAssetsRatesControllerState['conversionRates'],\n assetId: `${string}:${string}/${string}:${string}`,\n) {\n const assetMarketData = multichainConversionRates[assetId];\n\n if (!assetMarketData?.rate) {\n return undefined;\n }\n\n return {\n balance: Number(balance.amount) * Number(assetMarketData.rate),\n conversionRate: Number(assetMarketData.rate),\n };\n}\n"]}
1
+ {"version":3,"file":"token-selectors.mjs","sourceRoot":"","sources":["../../src/selectors/token-selectors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,mCAAmC;AACjE,OAAO,EAAE,QAAQ,EAAE,8BAA8B;AAGjD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,wBAAwB;AAElE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB;AAG1D,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC7B,gCAA4B;AAK7B,OAAO,EAAE,qBAAqB,EAAE,8CAA0C;AAK1E,qBAAqB;AACrB,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,MAAM,EAAE,QAAQ;IAChB,SAAS,EAAE,WAAW;IACtB,UAAU,EAAE,YAAY;IACxB,aAAa,EAAE,eAAe;IAC9B,WAAW,EAAE,aAAa;IAC1B,cAAc,EAAE,gBAAgB;CACxB,CAAC;AAKX,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAChD,aAAa,CACmB,CAAC;AAEnC,MAAM,CAAC,MAAM,yBAAyB,GACpC,IAAI,GAAG,CAAC,qBAAqB,CAAC,CAAC;AA4EjC,MAAM,uBAAuB,GAAG,cAAc,CAAC,SAAS,EAAkB,CAAC;AAE3E,MAAM,0BAA0B,GAAG,uBAAu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gCAAgC,CACvC,OAAyC,EACzC,yBAAkF,EAClF,OAAkD;IAElD,MAAM,eAAe,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAE3D,IAAI,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC;QAC3B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC;QAC9D,cAAc,EAAE,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC;KAC7C,CAAC;AACJ,CAAC","sourcesContent":["import type { AccountGroupId } from '@metamask/account-api';\nimport type { AccountTreeControllerState } from '@metamask/account-tree-controller';\nimport type { AccountsControllerState } from '@metamask/accounts-controller';\nimport { convertHexToDecimal } from '@metamask/controller-utils';\nimport { TrxScope } from '@metamask/keyring-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { NetworkState } from '@metamask/network-controller';\nimport { hexToBigInt, parseCaipAssetType } from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\nimport { createSelector, weakMapMemoize } from 'reselect';\nimport { TokenRwaData } from 'src/token-service';\n\nimport {\n parseBalanceWithDecimals,\n stringifyBalanceWithDecimals,\n} from './stringify-balance';\nimport type { CurrencyRateState } from '../CurrencyRateController';\nimport type { MultichainAssetsControllerState } from '../MultichainAssetsController';\nimport type { MultichainAssetsRatesControllerState } from '../MultichainAssetsRatesController';\nimport type { MultichainBalancesControllerState } from '../MultichainBalancesController';\nimport { getNativeTokenAddress } from '../token-prices-service/codefi-v2';\nimport type { TokenBalancesControllerState } from '../TokenBalancesController';\nimport type { Token, TokenRatesControllerState } from '../TokenRatesController';\nimport type { TokensControllerState } from '../TokensController';\n\n// Asset Tron Filters\nexport const TRON_RESOURCE = {\n ENERGY: 'energy',\n BANDWIDTH: 'bandwidth',\n MAX_ENERGY: 'max-energy',\n MAX_BANDWIDTH: 'max-bandwidth',\n STRX_ENERGY: 'strx-energy',\n STRX_BANDWIDTH: 'strx-bandwidth',\n} as const;\n\nexport type TronResourceSymbol =\n (typeof TRON_RESOURCE)[keyof typeof TRON_RESOURCE];\n\nexport const TRON_RESOURCE_SYMBOLS = Object.values(\n TRON_RESOURCE,\n) as readonly TronResourceSymbol[];\n\nexport const TRON_RESOURCE_SYMBOLS_SET: ReadonlySet<TronResourceSymbol> =\n new Set(TRON_RESOURCE_SYMBOLS);\n\nexport type AssetsByAccountGroup = {\n [accountGroupId: AccountGroupId]: AccountGroupAssets;\n};\n\nexport type AccountGroupAssets = {\n [network: string]: Asset[];\n};\n\ntype EvmAccountType = Extract<InternalAccount['type'], `eip155:${string}`>;\ntype MultichainAccountType = Exclude<\n InternalAccount['type'],\n `eip155:${string}`\n>;\n\nexport type Asset = (\n | {\n accountType: EvmAccountType;\n assetId: Hex; // This is also the address for EVM tokens\n address: Hex;\n chainId: Hex;\n }\n | {\n accountType: MultichainAccountType;\n assetId: `${string}:${string}/${string}:${string}`;\n chainId: `${string}:${string}`;\n }\n) & {\n accountId: string;\n image: string;\n name: string;\n symbol: string;\n decimals: number;\n isNative: boolean;\n rawBalance: Hex;\n balance: string;\n fiat:\n | {\n balance: number;\n currency: string;\n conversionRate: number;\n }\n | undefined;\n rwaData?: TokenRwaData;\n};\n\nexport type AssetListState = {\n accountTree: AccountTreeControllerState['accountTree'];\n internalAccounts: AccountsControllerState['internalAccounts'];\n allTokens: TokensControllerState['allTokens'];\n allIgnoredTokens: TokensControllerState['allIgnoredTokens'];\n tokenBalances: TokenBalancesControllerState['tokenBalances'];\n marketData: TokenRatesControllerState['marketData'];\n currencyRates: CurrencyRateState['currencyRates'];\n accountsAssets: MultichainAssetsControllerState['accountsAssets'];\n allIgnoredAssets: MultichainAssetsControllerState['allIgnoredAssets'];\n assetsMetadata: MultichainAssetsControllerState['assetsMetadata'];\n balances: MultichainBalancesControllerState['balances'];\n conversionRates: MultichainAssetsRatesControllerState['conversionRates'];\n currentCurrency: CurrencyRateState['currentCurrency'];\n networkConfigurationsByChainId: NetworkState['networkConfigurationsByChainId'];\n // This is the state from AccountTrackerController. The state is different on mobile and extension\n // accountsByChainId with a balance is the only field that both clients have in common\n // This field could be removed once TokenBalancesController returns native balances\n accountsByChainId: Record<\n Hex,\n Record<\n Hex,\n {\n balance: Hex | null;\n }\n >\n >;\n};\n\nconst createAssetListSelector = createSelector.withTypes<AssetListState>();\n\nconst selectAccountsToGroupIdMap = createAssetListSelector(\n [(state) => state.accountTree, (state) => state.internalAccounts],\n (accountTree, internalAccounts) => {\n const accountsMap: Record<\n string,\n {\n accountGroupId: AccountGroupId;\n type: InternalAccount['type'];\n accountId: string;\n }\n > = {};\n for (const { groups } of Object.values(accountTree.wallets)) {\n for (const { id: accountGroupId, accounts } of Object.values(groups)) {\n for (const accountId of accounts) {\n const internalAccount = internalAccounts.accounts[accountId];\n\n accountsMap[\n // TODO: We would not need internalAccounts if evmTokens state had the accountId\n internalAccount.type.startsWith('eip155')\n ? internalAccount.address\n : accountId\n ] = { accountGroupId, type: internalAccount.type, accountId };\n }\n }\n }\n\n return accountsMap;\n },\n);\n\n// TODO: This selector will not be needed once the native balances are part of the evm tokens state\nconst selectAllEvmAccountNativeBalances = createAssetListSelector(\n [\n selectAccountsToGroupIdMap,\n (state) => state.accountsByChainId,\n (state) => state.marketData,\n (state) => state.currencyRates,\n (state) => state.currentCurrency,\n (state) => state.networkConfigurationsByChainId,\n ],\n (\n accountsMap,\n accountsByChainId,\n marketData,\n currencyRates,\n currentCurrency,\n networkConfigurationsByChainId,\n ) => {\n const groupAssets: AssetsByAccountGroup = {};\n\n for (const [chainId, chainAccounts] of Object.entries(\n accountsByChainId,\n ) as [Hex, Record<Hex, { balance: Hex | null }>][]) {\n for (const [accountAddress, accountBalance] of Object.entries(\n chainAccounts,\n )) {\n const account = accountsMap[accountAddress.toLowerCase()];\n if (!account) {\n continue;\n }\n\n const { accountGroupId, type, accountId } = account;\n\n groupAssets[accountGroupId] ??= {};\n groupAssets[accountGroupId][chainId] ??= [];\n const groupChainAssets = groupAssets[accountGroupId][chainId];\n\n // If a native balance is missing, we still want to show it as 0\n const rawBalance = accountBalance.balance || '0x0';\n\n const nativeCurrency =\n networkConfigurationsByChainId[chainId]?.nativeCurrency || 'NATIVE';\n\n const nativeToken = {\n address: getNativeTokenAddress(chainId),\n decimals: 18,\n name: nativeCurrency === 'ETH' ? 'Ethereum' : nativeCurrency,\n symbol: nativeCurrency,\n // This field need to be filled at client level for now\n image: '',\n };\n\n const fiatData = getFiatBalanceForEvmToken(\n rawBalance,\n nativeToken.decimals,\n marketData,\n currencyRates,\n chainId,\n nativeToken.address,\n nativeCurrency, // Pass native currency symbol for fallback when market data is missing\n );\n\n groupChainAssets.push({\n accountType: type as EvmAccountType,\n assetId: nativeToken.address,\n isNative: true,\n address: nativeToken.address,\n image: nativeToken.image,\n name: nativeToken.name,\n symbol: nativeToken.symbol,\n accountId,\n decimals: nativeToken.decimals,\n rawBalance,\n balance: stringifyBalanceWithDecimals(\n hexToBigInt(rawBalance),\n nativeToken.decimals,\n ),\n fiat: fiatData\n ? {\n balance: fiatData.balance,\n currency: currentCurrency,\n conversionRate: fiatData.conversionRate,\n }\n : undefined,\n chainId,\n });\n }\n }\n\n return groupAssets;\n },\n);\n\nconst selectAllEvmAssets = createAssetListSelector(\n [\n selectAccountsToGroupIdMap,\n (state) => state.allTokens,\n (state) => state.allIgnoredTokens,\n (state) => state.tokenBalances,\n (state) => state.marketData,\n (state) => state.currencyRates,\n (state) => state.currentCurrency,\n ],\n (\n accountsMap,\n evmTokens,\n ignoredEvmTokens,\n tokenBalances,\n marketData,\n currencyRates,\n currentCurrency,\n ) => {\n const groupAssets: AssetsByAccountGroup = {};\n\n for (const [chainId, chainTokens] of Object.entries(evmTokens) as [\n Hex,\n { [key: string]: Token[] },\n ][]) {\n for (const [accountAddress, addressTokens] of Object.entries(\n chainTokens,\n ) as [Hex, Token[]][]) {\n for (const token of addressTokens) {\n const tokenAddress = token.address as Hex;\n const account = accountsMap[accountAddress];\n if (!account) {\n continue;\n }\n\n const { accountGroupId, type, accountId } = account;\n\n if (\n ignoredEvmTokens[chainId]?.[accountAddress]?.includes(tokenAddress)\n ) {\n continue;\n }\n\n const rawBalance =\n tokenBalances[accountAddress]?.[chainId]?.[tokenAddress];\n\n if (!rawBalance) {\n continue;\n }\n\n groupAssets[accountGroupId] ??= {};\n groupAssets[accountGroupId][chainId] ??= [];\n const groupChainAssets = groupAssets[accountGroupId][chainId];\n\n const fiatData = getFiatBalanceForEvmToken(\n rawBalance,\n token.decimals,\n marketData,\n currencyRates,\n chainId,\n tokenAddress,\n );\n\n groupChainAssets.push({\n accountType: type as EvmAccountType,\n assetId: tokenAddress,\n isNative: false,\n address: tokenAddress,\n image: token.image ?? '',\n name: token.name ?? token.symbol,\n symbol: token.symbol,\n accountId,\n decimals: token.decimals,\n rawBalance,\n balance: stringifyBalanceWithDecimals(\n hexToBigInt(rawBalance),\n token.decimals,\n ),\n fiat: fiatData\n ? {\n balance: fiatData.balance,\n currency: currentCurrency,\n conversionRate: fiatData.conversionRate,\n }\n : undefined,\n chainId,\n ...(token.rwaData && { rwaData: token.rwaData }),\n });\n }\n }\n }\n\n return groupAssets;\n },\n);\n\nconst selectAllMultichainAssets = createAssetListSelector(\n [\n selectAccountsToGroupIdMap,\n (state) => state.accountsAssets,\n (state) => state.allIgnoredAssets,\n (state) => state.assetsMetadata,\n (state) => state.balances,\n (state) => state.conversionRates,\n (state) => state.currentCurrency,\n ],\n (\n accountsMap,\n multichainTokens,\n ignoredMultichainAssets,\n multichainAssetsMetadata,\n multichainBalances,\n multichainConversionRates,\n currentCurrency,\n ) => {\n const groupAssets: AssetsByAccountGroup = {};\n\n for (const [accountId, accountAssets] of Object.entries(multichainTokens)) {\n for (const assetId of accountAssets) {\n let caipAsset: ReturnType<typeof parseCaipAssetType>;\n try {\n caipAsset = parseCaipAssetType(assetId);\n } catch {\n // TODO: We should log this error when we have the ability to inject a logger from the client\n continue;\n }\n\n const { chainId } = caipAsset;\n const asset = `${caipAsset.assetNamespace}:${caipAsset.assetReference}`;\n\n const account = accountsMap[accountId];\n const assetMetadata = multichainAssetsMetadata[assetId];\n if (!account || !assetMetadata) {\n continue;\n }\n\n const { accountGroupId, type } = account;\n\n if (ignoredMultichainAssets?.[accountId]?.includes(assetId)) {\n continue;\n }\n\n groupAssets[accountGroupId] ??= {};\n groupAssets[accountGroupId][chainId] ??= [];\n const groupChainAssets = groupAssets[accountGroupId][chainId];\n\n const balance:\n | {\n amount: string;\n unit: string;\n }\n | undefined = multichainBalances[accountId]?.[assetId];\n\n const decimals = assetMetadata.units?.find(\n (unit) =>\n unit.name === assetMetadata.name &&\n unit.symbol === assetMetadata.symbol,\n )?.decimals;\n\n if (!balance || decimals === undefined) {\n continue;\n }\n\n const rawBalance = parseBalanceWithDecimals(balance.amount, decimals);\n\n if (!rawBalance) {\n continue;\n }\n\n const fiatData = getFiatBalanceForMultichainAsset(\n balance,\n multichainConversionRates,\n assetId,\n );\n\n // TODO: We shouldn't have to rely on fallbacks for name and symbol, they should not be optional\n groupChainAssets.push({\n accountType: type as MultichainAccountType,\n assetId,\n isNative: caipAsset.assetNamespace === 'slip44',\n image: assetMetadata.iconUrl,\n name: assetMetadata.name ?? assetMetadata.symbol ?? asset,\n symbol: assetMetadata.symbol ?? asset,\n accountId,\n decimals,\n rawBalance,\n balance: balance.amount,\n fiat: fiatData\n ? {\n balance: fiatData.balance,\n currency: currentCurrency,\n conversionRate: fiatData.conversionRate,\n }\n : undefined,\n chainId,\n });\n }\n }\n\n return groupAssets;\n },\n);\n\nexport const selectAllAssets = createAssetListSelector(\n [\n selectAllEvmAssets,\n selectAllMultichainAssets,\n selectAllEvmAccountNativeBalances,\n ],\n (evmAssets, multichainAssets, evmAccountNativeBalances) => {\n const groupAssets: AssetsByAccountGroup = {};\n\n mergeAssets(groupAssets, evmAssets);\n\n mergeAssets(groupAssets, multichainAssets);\n\n mergeAssets(groupAssets, evmAccountNativeBalances);\n\n return groupAssets;\n },\n);\n\nexport type SelectAccountGroupAssetOpts = {\n filterTronStakedTokens: boolean;\n};\n\nconst defaultSelectAccountGroupAssetOpts: SelectAccountGroupAssetOpts = {\n filterTronStakedTokens: true,\n};\n\nconst filterTronStakedTokens = (assetsByAccountGroup: AccountGroupAssets) => {\n const newAssetsByAccountGroup = { ...assetsByAccountGroup };\n\n Object.values(TrxScope).forEach((tronChainId) => {\n if (!newAssetsByAccountGroup[tronChainId]) {\n return;\n }\n\n newAssetsByAccountGroup[tronChainId] = newAssetsByAccountGroup[\n tronChainId\n ].filter((asset: Asset) => {\n if (\n asset.chainId.startsWith('tron:') &&\n TRON_RESOURCE_SYMBOLS_SET.has(\n asset.symbol?.toLowerCase() as TronResourceSymbol,\n )\n ) {\n return false;\n }\n return true;\n });\n });\n\n return newAssetsByAccountGroup;\n};\n\nexport const selectAssetsBySelectedAccountGroup = createAssetListSelector(\n [\n selectAllAssets,\n (state) => state.accountTree,\n (\n _state,\n opts: SelectAccountGroupAssetOpts = defaultSelectAccountGroupAssetOpts,\n ) => opts,\n ],\n (groupAssets, accountTree, opts) => {\n const { selectedAccountGroup } = accountTree;\n if (!selectedAccountGroup) {\n return {};\n }\n\n let result = groupAssets[selectedAccountGroup] || {};\n\n if (opts.filterTronStakedTokens) {\n result = filterTronStakedTokens(result);\n }\n\n return result;\n },\n {\n memoize: weakMapMemoize,\n argsMemoize: weakMapMemoize,\n },\n);\n\n// TODO: Once native assets are part of the evm tokens state, this function can be simplified as chains will always be unique\n/**\n * Merges the new assets into the existing assets\n *\n * @param existingAssets - The existing assets\n * @param newAssets - The new assets\n */\nfunction mergeAssets(\n existingAssets: AssetsByAccountGroup,\n newAssets: AssetsByAccountGroup,\n) {\n for (const [accountGroupId, accountAssets] of Object.entries(newAssets) as [\n AccountGroupId,\n AccountGroupAssets,\n ][]) {\n const existingAccountGroupAssets = existingAssets[accountGroupId];\n\n if (!existingAccountGroupAssets) {\n existingAssets[accountGroupId] = {};\n for (const [network, chainAssets] of Object.entries(accountAssets)) {\n existingAssets[accountGroupId][network] = [...chainAssets];\n }\n } else {\n for (const [network, chainAssets] of Object.entries(accountAssets)) {\n existingAccountGroupAssets[network] ??= [];\n existingAccountGroupAssets[network].push(...chainAssets);\n }\n }\n }\n}\n\n/**\n * @param rawBalance - The balance of the token\n * @param decimals - The decimals of the token\n * @param marketData - The market data for the token\n * @param currencyRates - The currency rates for the token\n * @param chainId - The chain id of the token\n * @param tokenAddress - The address of the token\n * @param nativeCurrencySymbol - The native currency symbol (e.g., 'ETH', 'BNB') - used for fallback when market data is missing for native tokens\n * @returns The price and currency of the token in the current currency. Returns undefined if the asset is not found in the market data or currency rates.\n */\nfunction getFiatBalanceForEvmToken(\n rawBalance: Hex,\n decimals: number,\n marketData: TokenRatesControllerState['marketData'],\n currencyRates: CurrencyRateState['currencyRates'],\n chainId: Hex,\n tokenAddress: Hex,\n nativeCurrencySymbol?: string,\n) {\n const tokenMarketData = marketData[chainId]?.[tokenAddress];\n\n // For native tokens: if no market data exists, use price=1 and look up currency rate directly\n // This is because native tokens are priced in themselves (1 ETH = 1 ETH)\n if (!tokenMarketData && nativeCurrencySymbol) {\n const currencyRate = currencyRates[nativeCurrencySymbol];\n\n if (!currencyRate?.conversionRate) {\n return undefined;\n }\n\n const fiatBalance =\n (convertHexToDecimal(rawBalance) / 10 ** decimals) *\n currencyRate.conversionRate;\n\n return {\n balance: fiatBalance,\n conversionRate: currencyRate.conversionRate,\n };\n }\n\n if (!tokenMarketData) {\n return undefined;\n }\n\n const currencyRate = currencyRates[tokenMarketData.currency];\n\n if (!currencyRate?.conversionRate) {\n return undefined;\n }\n\n const fiatBalance =\n (convertHexToDecimal(rawBalance) / 10 ** decimals) *\n tokenMarketData.price *\n currencyRate.conversionRate;\n\n return {\n balance: fiatBalance,\n conversionRate: currencyRate.conversionRate,\n };\n}\n\n/**\n * @param balance - The balance of the asset, in the format { amount: string; unit: string }\n * @param balance.amount - The amount of the balance\n * @param balance.unit - The unit of the balance\n * @param multichainConversionRates - The conversion rates for the multichain asset\n * @param assetId - The asset id of the asset\n * @returns The price and currency of the token in the current currency. Returns undefined if the asset is not found in the conversion rates.\n */\nfunction getFiatBalanceForMultichainAsset(\n balance: { amount: string; unit: string },\n multichainConversionRates: MultichainAssetsRatesControllerState['conversionRates'],\n assetId: `${string}:${string}/${string}:${string}`,\n) {\n const assetMarketData = multichainConversionRates[assetId];\n\n if (!assetMarketData?.rate) {\n return undefined;\n }\n\n return {\n balance: Number(balance.amount) * Number(assetMarketData.rate),\n conversionRate: Number(assetMarketData.rate),\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"abstract-token-prices-service.cjs","sourceRoot":"","sources":["../../src/token-prices-service/abstract-token-prices-service.ts"],"names":[],"mappings":"","sourcesContent":["import type { ServicePolicy } from '@metamask/controller-utils';\nimport type { CaipAssetType, Hex } from '@metamask/utils';\n\nimport type { MarketDataDetails } from '../TokenRatesController';\n\n/**\n * Represents an exchange rate.\n */\nexport type ExchangeRate = {\n name: string;\n ticker: string;\n value: number;\n currencyType: string;\n usd?: number;\n};\n\n/**\n * A map of currency to its exchange rate.\n */\nexport type ExchangeRatesByCurrency<Currency extends string> = {\n [C in Currency]: ExchangeRate;\n};\n\nexport type EvmAssetAddressWithChain<ChainId extends Hex = Hex> = {\n tokenAddress: Hex;\n chainId: ChainId;\n};\n\nexport type EvmAssetWithId<ChainId extends Hex = Hex> =\n EvmAssetAddressWithChain<ChainId> & {\n assetId: CaipAssetType;\n };\n\nexport type EvmAssetWithMarketData<\n ChainId extends Hex = Hex,\n Currency extends string = string,\n> = EvmAssetAddressWithChain<ChainId> &\n MarketDataDetails & { currency: Currency };\n\n/**\n * An ideal token prices service. All implementations must confirm to this\n * interface.\n *\n * @template ChainId - A type union of valid arguments for the `chainId`\n * argument to `fetchTokenPrices`.\n * @template Currency - A type union of valid arguments for the `currency`\n * argument to `fetchTokenPrices`.\n */\nexport type AbstractTokenPricesService<\n ChainId extends Hex = Hex,\n Currency extends string = string,\n> = Partial<Pick<ServicePolicy, 'onBreak' | 'onDegraded'>> & {\n /**\n * Retrieves prices in the given currency for the tokens identified by the\n * given addresses which are expected to live on the given chain.\n *\n * @param args - The arguments to this function.\n * @param args.assets - The assets to get prices for.\n * @param args.currency - The desired currency of the token prices.\n * @returns The prices for the requested tokens.\n */\n fetchTokenPrices({\n assets,\n currency,\n }: {\n assets: EvmAssetAddressWithChain<ChainId>[];\n currency: Currency;\n }): Promise<EvmAssetWithMarketData<ChainId, Currency>[]>;\n\n /**\n * Retrieves exchange rates in the given currency.\n *\n * @param args - The arguments to this function.\n * @param args.baseCurrency - The desired currency of the token prices.\n * @param args.includeUsdRate - Whether to include the USD rate in the response.\n * @param args.cryptocurrencies - The cryptocurrencies to get exchange rates for.\n * @returns The exchange rates in the requested base currency.\n */\n fetchExchangeRates({\n baseCurrency,\n includeUsdRate,\n cryptocurrencies,\n }: {\n baseCurrency: Currency;\n includeUsdRate: boolean;\n cryptocurrencies: string[];\n }): Promise<ExchangeRatesByCurrency<Currency>>;\n\n /**\n * Type guard for whether the API can return token prices for the given chain\n * ID.\n *\n * @param chainId - The chain ID to check.\n * @returns True if the API supports the chain ID, false otherwise.\n */\n validateChainIdSupported(chainId: unknown): chainId is ChainId;\n\n /**\n * Type guard for whether the API can return token prices in the given\n * currency.\n *\n * @param currency - The currency to check.\n * @returns True if the API supports the currency, false otherwise.\n */\n validateCurrencySupported(currency: unknown): currency is Currency;\n};\n"]}
1
+ {"version":3,"file":"abstract-token-prices-service.cjs","sourceRoot":"","sources":["../../src/token-prices-service/abstract-token-prices-service.ts"],"names":[],"mappings":"","sourcesContent":["import type { ServicePolicy } from '@metamask/controller-utils';\nimport type { CaipAssetType, CaipChainId, Hex } from '@metamask/utils';\n\nimport type { MarketDataDetails } from '../TokenRatesController';\n\n/**\n * A map of CAIP-2 chain IDs to their native asset identifiers (CAIP-19 format).\n */\nexport type NativeAssetIdentifiersMap = Record<CaipChainId, CaipAssetType>;\n\n/**\n * Represents an exchange rate.\n */\nexport type ExchangeRate = {\n name: string;\n ticker: string;\n value: number;\n currencyType: string;\n usd?: number;\n};\n\n/**\n * A map of currency to its exchange rate.\n */\nexport type ExchangeRatesByCurrency<Currency extends string> = {\n [C in Currency]: ExchangeRate;\n};\n\nexport type EvmAssetAddressWithChain<ChainId extends Hex = Hex> = {\n tokenAddress: Hex;\n chainId: ChainId;\n};\n\nexport type EvmAssetWithId<ChainId extends Hex = Hex> =\n EvmAssetAddressWithChain<ChainId> & {\n assetId: CaipAssetType;\n };\n\nexport type EvmAssetWithMarketData<\n ChainId extends Hex = Hex,\n Currency extends string = string,\n> = EvmAssetAddressWithChain<ChainId> &\n MarketDataDetails & { currency: Currency };\n\n/**\n * An ideal token prices service. All implementations must confirm to this\n * interface.\n *\n * @template ChainId - A type union of valid arguments for the `chainId`\n * argument to `fetchTokenPrices`.\n * @template Currency - A type union of valid arguments for the `currency`\n * argument to `fetchTokenPrices`.\n */\nexport type AbstractTokenPricesService<\n ChainId extends Hex = Hex,\n Currency extends string = string,\n> = Partial<Pick<ServicePolicy, 'onBreak' | 'onDegraded'>> & {\n /**\n * Retrieves prices in the given currency for the tokens identified by the\n * given addresses which are expected to live on the given chain.\n *\n * @param args - The arguments to this function.\n * @param args.assets - The assets to get prices for.\n * @param args.currency - The desired currency of the token prices.\n * @returns The prices for the requested tokens.\n */\n fetchTokenPrices({\n assets,\n currency,\n }: {\n assets: EvmAssetAddressWithChain<ChainId>[];\n currency: Currency;\n }): Promise<EvmAssetWithMarketData<ChainId, Currency>[]>;\n\n /**\n * Retrieves exchange rates in the given currency.\n *\n * @param args - The arguments to this function.\n * @param args.baseCurrency - The desired currency of the token prices.\n * @param args.includeUsdRate - Whether to include the USD rate in the response.\n * @param args.cryptocurrencies - The cryptocurrencies to get exchange rates for.\n * @returns The exchange rates in the requested base currency.\n */\n fetchExchangeRates({\n baseCurrency,\n includeUsdRate,\n cryptocurrencies,\n }: {\n baseCurrency: Currency;\n includeUsdRate: boolean;\n cryptocurrencies: string[];\n }): Promise<ExchangeRatesByCurrency<Currency>>;\n\n /**\n * Type guard for whether the API can return token prices for the given chain\n * ID.\n *\n * @param chainId - The chain ID to check.\n * @returns True if the API supports the chain ID, false otherwise.\n */\n validateChainIdSupported(chainId: unknown): chainId is ChainId;\n\n /**\n * Type guard for whether the API can return token prices in the given\n * currency.\n *\n * @param currency - The currency to check.\n * @returns True if the API supports the currency, false otherwise.\n */\n validateCurrencySupported(currency: unknown): currency is Currency;\n\n /**\n * Sets the native asset identifiers map for resolving native token CAIP-19 IDs.\n * This should be called with data from NetworkEnablementController.state.nativeAssetIdentifiers.\n *\n * @param nativeAssetIdentifiers - Map of CAIP-2 chain IDs to native asset identifiers.\n */\n setNativeAssetIdentifiers?(\n nativeAssetIdentifiers: NativeAssetIdentifiersMap,\n ): void;\n};\n"]}
@@ -1,6 +1,10 @@
1
1
  import type { ServicePolicy } from "@metamask/controller-utils";
2
- import type { CaipAssetType, Hex } from "@metamask/utils";
2
+ import type { CaipAssetType, CaipChainId, Hex } from "@metamask/utils";
3
3
  import type { MarketDataDetails } from "../TokenRatesController.cjs";
4
+ /**
5
+ * A map of CAIP-2 chain IDs to their native asset identifiers (CAIP-19 format).
6
+ */
7
+ export type NativeAssetIdentifiersMap = Record<CaipChainId, CaipAssetType>;
4
8
  /**
5
9
  * Represents an exchange rate.
6
10
  */
@@ -80,5 +84,12 @@ export type AbstractTokenPricesService<ChainId extends Hex = Hex, Currency exten
80
84
  * @returns True if the API supports the currency, false otherwise.
81
85
  */
82
86
  validateCurrencySupported(currency: unknown): currency is Currency;
87
+ /**
88
+ * Sets the native asset identifiers map for resolving native token CAIP-19 IDs.
89
+ * This should be called with data from NetworkEnablementController.state.nativeAssetIdentifiers.
90
+ *
91
+ * @param nativeAssetIdentifiers - Map of CAIP-2 chain IDs to native asset identifiers.
92
+ */
93
+ setNativeAssetIdentifiers?(nativeAssetIdentifiers: NativeAssetIdentifiersMap): void;
83
94
  };
84
95
  //# sourceMappingURL=abstract-token-prices-service.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"abstract-token-prices-service.d.cts","sourceRoot":"","sources":["../../src/token-prices-service/abstract-token-prices-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,wBAAwB;AAE1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,oCAAgC;AAEjE;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,uBAAuB,CAAC,QAAQ,SAAS,MAAM,IAAI;KAC5D,CAAC,IAAI,QAAQ,GAAG,YAAY;CAC9B,CAAC;AAEF,MAAM,MAAM,wBAAwB,CAAC,OAAO,SAAS,GAAG,GAAG,GAAG,IAAI;IAChE,YAAY,EAAE,GAAG,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,cAAc,CAAC,OAAO,SAAS,GAAG,GAAG,GAAG,IAClD,wBAAwB,CAAC,OAAO,CAAC,GAAG;IAClC,OAAO,EAAE,aAAa,CAAC;CACxB,CAAC;AAEJ,MAAM,MAAM,sBAAsB,CAChC,OAAO,SAAS,GAAG,GAAG,GAAG,EACzB,QAAQ,SAAS,MAAM,GAAG,MAAM,IAC9B,wBAAwB,CAAC,OAAO,CAAC,GACnC,iBAAiB,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC;AAE7C;;;;;;;;GAQG;AACH,MAAM,MAAM,0BAA0B,CACpC,OAAO,SAAS,GAAG,GAAG,GAAG,EACzB,QAAQ,SAAS,MAAM,GAAG,MAAM,IAC9B,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,YAAY,CAAC,CAAC,GAAG;IAC3D;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EACf,MAAM,EACN,QAAQ,GACT,EAAE;QACD,MAAM,EAAE,wBAAwB,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5C,QAAQ,EAAE,QAAQ,CAAC;KACpB,GAAG,OAAO,CAAC,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEzD;;;;;;;;OAQG;IACH,kBAAkB,CAAC,EACjB,YAAY,EACZ,cAAc,EACd,gBAAgB,GACjB,EAAE;QACD,YAAY,EAAE,QAAQ,CAAC;QACvB,cAAc,EAAE,OAAO,CAAC;QACxB,gBAAgB,EAAE,MAAM,EAAE,CAAC;KAC5B,GAAG,OAAO,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE/C;;;;;;OAMG;IACH,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,OAAO,CAAC;IAE/D;;;;;;OAMG;IACH,yBAAyB,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,QAAQ,CAAC;CACpE,CAAC"}
1
+ {"version":3,"file":"abstract-token-prices-service.d.cts","sourceRoot":"","sources":["../../src/token-prices-service/abstract-token-prices-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,EAAE,wBAAwB;AAEvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,oCAAgC;AAEjE;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,MAAM,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAA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,YAAY,EAAE,QAAQ,CAAC;QACvB,cAAc,EAAE,OAAO,CAAC;QACxB,gBAAgB,EAAE,MAAM,EAAE,CAAC;KAC5B,GAAG,OAAO,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE/C;;;;;;OAMG;IACH,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,OAAO,CAAC;IAE/D;;;;;;OAMG;IACH,yBAAyB,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,QAAQ,CAAC;IAEnE;;;;;OAKG;IACH,yBAAyB,CAAC,CACxB,sBAAsB,EAAE,yBAAyB,GAChD,IAAI,CAAC;CACT,CAAC"}
@@ -1,6 +1,10 @@
1
1
  import type { ServicePolicy } from "@metamask/controller-utils";
2
- import type { CaipAssetType, Hex } from "@metamask/utils";
2
+ import type { CaipAssetType, CaipChainId, Hex } from "@metamask/utils";
3
3
  import type { MarketDataDetails } from "../TokenRatesController.mjs";
4
+ /**
5
+ * A map of CAIP-2 chain IDs to their native asset identifiers (CAIP-19 format).
6
+ */
7
+ export type NativeAssetIdentifiersMap = Record<CaipChainId, CaipAssetType>;
4
8
  /**
5
9
  * Represents an exchange rate.
6
10
  */
@@ -80,5 +84,12 @@ export type AbstractTokenPricesService<ChainId extends Hex = Hex, Currency exten
80
84
  * @returns True if the API supports the currency, false otherwise.
81
85
  */
82
86
  validateCurrencySupported(currency: unknown): currency is Currency;
87
+ /**
88
+ * Sets the native asset identifiers map for resolving native token CAIP-19 IDs.
89
+ * This should be called with data from NetworkEnablementController.state.nativeAssetIdentifiers.
90
+ *
91
+ * @param nativeAssetIdentifiers - Map of CAIP-2 chain IDs to native asset identifiers.
92
+ */
93
+ setNativeAssetIdentifiers?(nativeAssetIdentifiers: NativeAssetIdentifiersMap): void;
83
94
  };
84
95
  //# sourceMappingURL=abstract-token-prices-service.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"abstract-token-prices-service.d.mts","sourceRoot":"","s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,gBAAgB,CAAC,EACf,MAAM,EACN,QAAQ,GACT,EAAE;QACD,MAAM,EAAE,wBAAwB,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5C,QAAQ,EAAE,QAAQ,CAAC;KACpB,GAAG,OAAO,CAAC,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEzD;;;;;;;;OAQG;IACH,kBAAkB,CAAC,EACjB,YAAY,EACZ,cAAc,EACd,gBAAgB,GACjB,EAAE;QACD,YAAY,EAAE,QAAQ,CAAC;QACvB,cAAc,EAAE,OAAO,CAAC;QACxB,gBAAgB,EAAE,MAAM,EAAE,CAAC;KAC5B,GAAG,OAAO,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE/C;;;;;;OAMG;IACH,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,OAAO,CAAC;IAE/D;;;;;;OAMG;IACH,yBAAyB,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,QAAQ,CAAC;CACpE,CAAC"}
1
+ {"version":3,"file":"abstract-token-prices-service.d.mts","sourceRoot":"","sources":["../../src/token-prices-service/abstract-token-prices-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,EAAE,wBAAwB;AAEvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,oCAAgC;AAEjE;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,MAAM,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;A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AG,OAAO,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE/C;;;;;;OAMG;IACH,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,OAAO,CAAC;IAE/D;;;;;;OAMG;IACH,yBAAyB,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,QAAQ,CAAC;IAEnE;;;;;OAKG;IACH,yBAAyB,CAAC,CACxB,sBAAsB,EAAE,yBAAyB,GAChD,IAAI,CAAC;CACT,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"abstract-token-prices-service.mjs","sourceRoot":"","sources":["../../src/token-prices-service/abstract-token-prices-service.ts"],"names":[],"mappings":"","sourcesContent":["import type { ServicePolicy } from '@metamask/controller-utils';\nimport type { CaipAssetType, Hex } from '@metamask/utils';\n\nimport type { MarketDataDetails } from '../TokenRatesController';\n\n/**\n * Represents an exchange rate.\n */\nexport type ExchangeRate = {\n name: string;\n ticker: string;\n value: number;\n currencyType: string;\n usd?: number;\n};\n\n/**\n * A map of currency to its exchange rate.\n */\nexport type ExchangeRatesByCurrency<Currency extends string> = {\n [C in Currency]: ExchangeRate;\n};\n\nexport type EvmAssetAddressWithChain<ChainId extends Hex = Hex> = {\n tokenAddress: Hex;\n chainId: ChainId;\n};\n\nexport type EvmAssetWithId<ChainId extends Hex = Hex> =\n EvmAssetAddressWithChain<ChainId> & {\n assetId: CaipAssetType;\n };\n\nexport type EvmAssetWithMarketData<\n ChainId extends Hex = Hex,\n Currency extends string = string,\n> = EvmAssetAddressWithChain<ChainId> &\n MarketDataDetails & { currency: Currency };\n\n/**\n * An ideal token prices service. All implementations must confirm to this\n * interface.\n *\n * @template ChainId - A type union of valid arguments for the `chainId`\n * argument to `fetchTokenPrices`.\n * @template Currency - A type union of valid arguments for the `currency`\n * argument to `fetchTokenPrices`.\n */\nexport type AbstractTokenPricesService<\n ChainId extends Hex = Hex,\n Currency extends string = string,\n> = Partial<Pick<ServicePolicy, 'onBreak' | 'onDegraded'>> & {\n /**\n * Retrieves prices in the given currency for the tokens identified by the\n * given addresses which are expected to live on the given chain.\n *\n * @param args - The arguments to this function.\n * @param args.assets - The assets to get prices for.\n * @param args.currency - The desired currency of the token prices.\n * @returns The prices for the requested tokens.\n */\n fetchTokenPrices({\n assets,\n currency,\n }: {\n assets: EvmAssetAddressWithChain<ChainId>[];\n currency: Currency;\n }): Promise<EvmAssetWithMarketData<ChainId, Currency>[]>;\n\n /**\n * Retrieves exchange rates in the given currency.\n *\n * @param args - The arguments to this function.\n * @param args.baseCurrency - The desired currency of the token prices.\n * @param args.includeUsdRate - Whether to include the USD rate in the response.\n * @param args.cryptocurrencies - The cryptocurrencies to get exchange rates for.\n * @returns The exchange rates in the requested base currency.\n */\n fetchExchangeRates({\n baseCurrency,\n includeUsdRate,\n cryptocurrencies,\n }: {\n baseCurrency: Currency;\n includeUsdRate: boolean;\n cryptocurrencies: string[];\n }): Promise<ExchangeRatesByCurrency<Currency>>;\n\n /**\n * Type guard for whether the API can return token prices for the given chain\n * ID.\n *\n * @param chainId - The chain ID to check.\n * @returns True if the API supports the chain ID, false otherwise.\n */\n validateChainIdSupported(chainId: unknown): chainId is ChainId;\n\n /**\n * Type guard for whether the API can return token prices in the given\n * currency.\n *\n * @param currency - The currency to check.\n * @returns True if the API supports the currency, false otherwise.\n */\n validateCurrencySupported(currency: unknown): currency is Currency;\n};\n"]}
1
+ {"version":3,"file":"abstract-token-prices-service.mjs","sourceRoot":"","sources":["../../src/token-prices-service/abstract-token-prices-service.ts"],"names":[],"mappings":"","sourcesContent":["import type { ServicePolicy } from '@metamask/controller-utils';\nimport type { CaipAssetType, CaipChainId, Hex } from '@metamask/utils';\n\nimport type { MarketDataDetails } from '../TokenRatesController';\n\n/**\n * A map of CAIP-2 chain IDs to their native asset identifiers (CAIP-19 format).\n */\nexport type NativeAssetIdentifiersMap = Record<CaipChainId, CaipAssetType>;\n\n/**\n * Represents an exchange rate.\n */\nexport type ExchangeRate = {\n name: string;\n ticker: string;\n value: number;\n currencyType: string;\n usd?: number;\n};\n\n/**\n * A map of currency to its exchange rate.\n */\nexport type ExchangeRatesByCurrency<Currency extends string> = {\n [C in Currency]: ExchangeRate;\n};\n\nexport type EvmAssetAddressWithChain<ChainId extends Hex = Hex> = {\n tokenAddress: Hex;\n chainId: ChainId;\n};\n\nexport type EvmAssetWithId<ChainId extends Hex = Hex> =\n EvmAssetAddressWithChain<ChainId> & {\n assetId: CaipAssetType;\n };\n\nexport type EvmAssetWithMarketData<\n ChainId extends Hex = Hex,\n Currency extends string = string,\n> = EvmAssetAddressWithChain<ChainId> &\n MarketDataDetails & { currency: Currency };\n\n/**\n * An ideal token prices service. All implementations must confirm to this\n * interface.\n *\n * @template ChainId - A type union of valid arguments for the `chainId`\n * argument to `fetchTokenPrices`.\n * @template Currency - A type union of valid arguments for the `currency`\n * argument to `fetchTokenPrices`.\n */\nexport type AbstractTokenPricesService<\n ChainId extends Hex = Hex,\n Currency extends string = string,\n> = Partial<Pick<ServicePolicy, 'onBreak' | 'onDegraded'>> & {\n /**\n * Retrieves prices in the given currency for the tokens identified by the\n * given addresses which are expected to live on the given chain.\n *\n * @param args - The arguments to this function.\n * @param args.assets - The assets to get prices for.\n * @param args.currency - The desired currency of the token prices.\n * @returns The prices for the requested tokens.\n */\n fetchTokenPrices({\n assets,\n currency,\n }: {\n assets: EvmAssetAddressWithChain<ChainId>[];\n currency: Currency;\n }): Promise<EvmAssetWithMarketData<ChainId, Currency>[]>;\n\n /**\n * Retrieves exchange rates in the given currency.\n *\n * @param args - The arguments to this function.\n * @param args.baseCurrency - The desired currency of the token prices.\n * @param args.includeUsdRate - Whether to include the USD rate in the response.\n * @param args.cryptocurrencies - The cryptocurrencies to get exchange rates for.\n * @returns The exchange rates in the requested base currency.\n */\n fetchExchangeRates({\n baseCurrency,\n includeUsdRate,\n cryptocurrencies,\n }: {\n baseCurrency: Currency;\n includeUsdRate: boolean;\n cryptocurrencies: string[];\n }): Promise<ExchangeRatesByCurrency<Currency>>;\n\n /**\n * Type guard for whether the API can return token prices for the given chain\n * ID.\n *\n * @param chainId - The chain ID to check.\n * @returns True if the API supports the chain ID, false otherwise.\n */\n validateChainIdSupported(chainId: unknown): chainId is ChainId;\n\n /**\n * Type guard for whether the API can return token prices in the given\n * currency.\n *\n * @param currency - The currency to check.\n * @returns True if the API supports the currency, false otherwise.\n */\n validateCurrencySupported(currency: unknown): currency is Currency;\n\n /**\n * Sets the native asset identifiers map for resolving native token CAIP-19 IDs.\n * This should be called with data from NetworkEnablementController.state.nativeAssetIdentifiers.\n *\n * @param nativeAssetIdentifiers - Map of CAIP-2 chain IDs to native asset identifiers.\n */\n setNativeAssetIdentifiers?(\n nativeAssetIdentifiers: NativeAssetIdentifiersMap,\n ): void;\n};\n"]}
@@ -10,16 +10,17 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _CodefiTokenPricesServiceV2_policy;
13
+ var _CodefiTokenPricesServiceV2_policy, _CodefiTokenPricesServiceV2_nativeAssetIdentifiers;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.CodefiTokenPricesServiceV2 = exports.SUPPORTED_CHAIN_IDS = exports.SPOT_PRICES_SUPPORT_INFO = exports.getNativeTokenAddress = exports.ZERO_ADDRESS = exports.SUPPORTED_CURRENCIES = void 0;
15
+ exports.CodefiTokenPricesServiceV2 = exports.resetSupportedCurrenciesCache = exports.getSupportedCurrencies = exports.fetchSupportedCurrencies = exports.resetSupportedNetworksCache = exports.getSupportedNetworks = exports.fetchSupportedNetworks = exports.SUPPORTED_CHAIN_IDS = exports.SPOT_PRICES_SUPPORT_INFO = exports.getNativeTokenAddress = exports.ZERO_ADDRESS = exports.SUPPORTED_CURRENCIES = exports.SUPPORTED_CURRENCIES_FALLBACK = void 0;
16
16
  const controller_utils_1 = require("@metamask/controller-utils");
17
17
  const utils_1 = require("@metamask/utils");
18
18
  /**
19
19
  * The list of currencies that can be supplied as the `vsCurrency` parameter to
20
20
  * the `/spot-prices` endpoint, in lowercase form.
21
+ * This is the fallback list used when the API is unavailable.
21
22
  */
22
- exports.SUPPORTED_CURRENCIES = [
23
+ exports.SUPPORTED_CURRENCIES_FALLBACK = [
23
24
  // Bitcoin
24
25
  'btc',
25
26
  // Ether
@@ -195,6 +196,11 @@ exports.SUPPORTED_CURRENCIES = [
195
196
  // Apechain
196
197
  'ape',
197
198
  ];
199
+ /**
200
+ * @deprecated Use `getSupportedCurrencies()` or `fetchSupportedCurrencies()` instead.
201
+ * This is an alias for backward compatibility.
202
+ */
203
+ exports.SUPPORTED_CURRENCIES = exports.SUPPORTED_CURRENCIES_FALLBACK;
198
204
  /**
199
205
  * Represents the zero address, commonly used as a placeholder in blockchain transactions.
200
206
  * In the context of fetching market data, the zero address is utilized to retrieve information
@@ -298,13 +304,156 @@ exports.SPOT_PRICES_SUPPORT_INFO = {
298
304
  * @see Used by {@link CodefiTokenPricesServiceV2} to validate that a given chain ID is supported by V2 of the Codefi Price API.
299
305
  */
300
306
  exports.SUPPORTED_CHAIN_IDS = Object.keys(exports.SPOT_PRICES_SUPPORT_INFO);
301
- /**
302
- * The list of chain IDs that are supported by V3 of the Codefi Price API.
303
- * Only includes chain IDs from SPOT_PRICES_SUPPORT_INFO that have a non-null CAIP-19 value.
304
- */
305
- const SUPPORTED_CHAIN_IDS_V3 = Object.keys(exports.SPOT_PRICES_SUPPORT_INFO).filter((chainId) => exports.SPOT_PRICES_SUPPORT_INFO[chainId] !== null);
306
307
  const BASE_URL_V1 = 'https://price.api.cx.metamask.io/v1';
308
+ const BASE_URL_V2 = 'https://price.api.cx.metamask.io/v2';
307
309
  const BASE_URL_V3 = 'https://price.api.cx.metamask.io/v3';
310
+ /**
311
+ * In-memory store for the last successfully fetched supported networks.
312
+ */
313
+ let lastFetchedSupportedNetworks = null;
314
+ /**
315
+ * Converts a CAIP-2 chain ID (e.g., 'eip155:1') to a hex chain ID (e.g., '0x1').
316
+ *
317
+ * @param caipChainId - The CAIP-2 chain ID string.
318
+ * @returns The hex chain ID or null if not an EIP-155 chain.
319
+ */
320
+ function caipChainIdToHex(caipChainId) {
321
+ const match = caipChainId.match(/^eip155:(\d+)$/u);
322
+ if (!match) {
323
+ return null;
324
+ }
325
+ return (0, utils_1.numberToHex)(parseInt(match[1], 10));
326
+ }
327
+ /**
328
+ * Fetches the list of supported networks from the API.
329
+ * Falls back to the hardcoded list if the fetch fails.
330
+ *
331
+ * @returns The supported networks response.
332
+ */
333
+ async function fetchSupportedNetworks() {
334
+ try {
335
+ const url = `${BASE_URL_V2}/supportedNetworks`;
336
+ const response = await (0, controller_utils_1.handleFetch)(url, {
337
+ headers: { 'Cache-Control': 'no-cache' },
338
+ });
339
+ if (response &&
340
+ typeof response === 'object' &&
341
+ 'fullSupport' in response &&
342
+ 'partialSupport' in response) {
343
+ lastFetchedSupportedNetworks = response;
344
+ return lastFetchedSupportedNetworks;
345
+ }
346
+ // Invalid response format, fall back to hardcoded list
347
+ return getSupportedNetworksFallback();
348
+ }
349
+ catch {
350
+ // On any error, fall back to the hardcoded list
351
+ return getSupportedNetworksFallback();
352
+ }
353
+ }
354
+ exports.fetchSupportedNetworks = fetchSupportedNetworks;
355
+ /**
356
+ * Synchronously gets the list of supported networks.
357
+ * Returns the last fetched value if available, otherwise returns the fallback list.
358
+ *
359
+ * @returns The supported networks response.
360
+ */
361
+ function getSupportedNetworks() {
362
+ if (lastFetchedSupportedNetworks !== null) {
363
+ return lastFetchedSupportedNetworks;
364
+ }
365
+ return getSupportedNetworksFallback();
366
+ }
367
+ exports.getSupportedNetworks = getSupportedNetworks;
368
+ /**
369
+ * Generates a fallback supported networks response from the hardcoded SPOT_PRICES_SUPPORT_INFO.
370
+ *
371
+ * @returns A SupportedNetworksResponse derived from hardcoded data.
372
+ */
373
+ function getSupportedNetworksFallback() {
374
+ const caipChainIds = Object.keys(exports.SPOT_PRICES_SUPPORT_INFO).map((hexChainId) => (0, utils_1.toCaipChainId)(utils_1.KnownCaipNamespace.Eip155, (0, utils_1.hexToNumber)(hexChainId).toString()));
375
+ return {
376
+ fullSupport: caipChainIds.slice(0, 11), // First 11 chains as "full support"
377
+ partialSupport: {
378
+ spotPricesV2: caipChainIds,
379
+ spotPricesV3: caipChainIds,
380
+ },
381
+ };
382
+ }
383
+ /**
384
+ * Resets the supported networks cache.
385
+ * This is primarily intended for testing purposes.
386
+ */
387
+ function resetSupportedNetworksCache() {
388
+ lastFetchedSupportedNetworks = null;
389
+ }
390
+ exports.resetSupportedNetworksCache = resetSupportedNetworksCache;
391
+ /**
392
+ * Gets the list of supported chain IDs for spot prices v3 as hex values.
393
+ *
394
+ * @returns Array of hex chain IDs supported by spot prices v3.
395
+ */
396
+ function getSupportedChainIdsV3AsHex() {
397
+ const supportedNetworks = getSupportedNetworks();
398
+ const allV3Chains = [
399
+ ...supportedNetworks.fullSupport,
400
+ ...supportedNetworks.partialSupport.spotPricesV3,
401
+ ];
402
+ return allV3Chains
403
+ .map(caipChainIdToHex)
404
+ .filter((hexChainId) => hexChainId !== null);
405
+ }
406
+ /**
407
+ * In-memory store for the last successfully fetched supported currencies.
408
+ */
409
+ let lastFetchedCurrencies = null;
410
+ /**
411
+ * Fetches the list of supported currencies from the API.
412
+ * Falls back to the hardcoded list if the fetch fails.
413
+ *
414
+ * @returns The list of supported currencies in lowercase.
415
+ */
416
+ async function fetchSupportedCurrencies() {
417
+ try {
418
+ const url = `${BASE_URL_V1}/supportedVsCurrencies`;
419
+ const response = await (0, controller_utils_1.handleFetch)(url, {
420
+ headers: { 'Cache-Control': 'no-cache' },
421
+ });
422
+ if (Array.isArray(response)) {
423
+ const currencies = response.map((currency) => currency.toLowerCase());
424
+ lastFetchedCurrencies = currencies;
425
+ return currencies;
426
+ }
427
+ // Invalid response format, fall back to hardcoded list
428
+ return [...exports.SUPPORTED_CURRENCIES_FALLBACK];
429
+ }
430
+ catch {
431
+ // On any error, fall back to the hardcoded list
432
+ return [...exports.SUPPORTED_CURRENCIES_FALLBACK];
433
+ }
434
+ }
435
+ exports.fetchSupportedCurrencies = fetchSupportedCurrencies;
436
+ /**
437
+ * Synchronously gets the list of supported currencies.
438
+ * Returns the last fetched value if available, otherwise returns the fallback list.
439
+ *
440
+ * @returns The list of supported currencies in lowercase.
441
+ */
442
+ function getSupportedCurrencies() {
443
+ if (lastFetchedCurrencies !== null) {
444
+ return lastFetchedCurrencies;
445
+ }
446
+ return exports.SUPPORTED_CURRENCIES_FALLBACK;
447
+ }
448
+ exports.getSupportedCurrencies = getSupportedCurrencies;
449
+ /**
450
+ * Resets the supported currencies cache.
451
+ * This is primarily intended for testing purposes.
452
+ */
453
+ function resetSupportedCurrenciesCache() {
454
+ lastFetchedCurrencies = null;
455
+ }
456
+ exports.resetSupportedCurrenciesCache = resetSupportedCurrenciesCache;
308
457
  /**
309
458
  * This version of the token prices service uses V2 of the Codefi Price API to
310
459
  * fetch token prices.
@@ -312,6 +461,11 @@ const BASE_URL_V3 = 'https://price.api.cx.metamask.io/v3';
312
461
  class CodefiTokenPricesServiceV2 {
313
462
  constructor({ degradedThreshold = controller_utils_1.DEFAULT_DEGRADED_THRESHOLD, retries = controller_utils_1.DEFAULT_MAX_RETRIES, maximumConsecutiveFailures = controller_utils_1.DEFAULT_MAX_CONSECUTIVE_FAILURES, onBreak, onDegraded, circuitBreakDuration = controller_utils_1.DEFAULT_CIRCUIT_BREAK_DURATION, } = {}) {
314
463
  _CodefiTokenPricesServiceV2_policy.set(this, void 0);
464
+ /**
465
+ * Map of CAIP-2 chain IDs to their native asset identifiers.
466
+ * Updated via setNativeAssetIdentifiers().
467
+ */
468
+ _CodefiTokenPricesServiceV2_nativeAssetIdentifiers.set(this, {});
315
469
  __classPrivateFieldSet(this, _CodefiTokenPricesServiceV2_policy, (0, controller_utils_1.createServicePolicy)({
316
470
  maxRetries: retries,
317
471
  maxConsecutiveFailures: maximumConsecutiveFailures,
@@ -345,6 +499,24 @@ class CodefiTokenPricesServiceV2 {
345
499
  onDegraded(...args) {
346
500
  return __classPrivateFieldGet(this, _CodefiTokenPricesServiceV2_policy, "f").onDegraded(...args);
347
501
  }
502
+ /**
503
+ * Sets the native asset identifiers map for resolving native token CAIP-19 IDs.
504
+ * This should be called with data from NetworkEnablementController.state.nativeAssetIdentifiers.
505
+ *
506
+ * @param nativeAssetIdentifiers - Map of CAIP-2 chain IDs to native asset identifiers.
507
+ */
508
+ setNativeAssetIdentifiers(nativeAssetIdentifiers) {
509
+ __classPrivateFieldSet(this, _CodefiTokenPricesServiceV2_nativeAssetIdentifiers, nativeAssetIdentifiers, "f");
510
+ }
511
+ /**
512
+ * Updates the supported networks cache by fetching from the API.
513
+ * This should be called periodically to keep the supported networks list fresh.
514
+ *
515
+ * @returns The updated supported networks response.
516
+ */
517
+ async updateSupportedNetworks() {
518
+ return fetchSupportedNetworks();
519
+ }
348
520
  /**
349
521
  * Retrieves prices in the given currency for the tokens identified by the
350
522
  * given addresses which are expected to live on the given chain.
@@ -355,21 +527,41 @@ class CodefiTokenPricesServiceV2 {
355
527
  * @returns The prices for the requested tokens.
356
528
  */
357
529
  async fetchTokenPrices({ assets, currency, }) {
530
+ // Refresh supported networks in background (non-blocking)
531
+ // This ensures the list stays fresh during normal polling
532
+ // Note: fetchSupportedNetworks handles errors internally and always resolves
533
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
534
+ fetchSupportedNetworks();
535
+ // Get dynamically fetched supported chain IDs for V3
536
+ const supportedChainIdsV3 = getSupportedChainIdsV3AsHex();
358
537
  const assetsWithIds = assets
359
538
  // Filter out assets that are not supported by V3 of the Price API.
360
- .filter((asset) => SUPPORTED_CHAIN_IDS_V3.includes(asset.chainId))
539
+ .filter((asset) => supportedChainIdsV3.includes(asset.chainId))
361
540
  .map((asset) => {
362
541
  const caipChainId = (0, utils_1.toCaipChainId)(utils_1.KnownCaipNamespace.Eip155, (0, utils_1.hexToNumber)(asset.chainId).toString());
363
542
  const nativeAddress = (0, exports.getNativeTokenAddress)(asset.chainId);
543
+ const isNativeToken = nativeAddress.toLowerCase() === asset.tokenAddress.toLowerCase();
544
+ let assetId;
545
+ if (isNativeToken) {
546
+ // For native tokens, use nativeAssetIdentifiers from NetworkEnablementController,
547
+ // falling back to hardcoded SPOT_PRICES_SUPPORT_INFO
548
+ assetId =
549
+ __classPrivateFieldGet(this, _CodefiTokenPricesServiceV2_nativeAssetIdentifiers, "f")[caipChainId] ??
550
+ exports.SPOT_PRICES_SUPPORT_INFO[asset.chainId];
551
+ }
552
+ else {
553
+ // For ERC20 tokens, construct the CAIP-19 ID dynamically
554
+ assetId = `${caipChainId}/erc20:${asset.tokenAddress.toLowerCase()}`;
555
+ }
556
+ if (!assetId) {
557
+ return undefined;
558
+ }
364
559
  return {
365
560
  ...asset,
366
- assetId: (nativeAddress.toLowerCase() ===
367
- asset.tokenAddress.toLowerCase()
368
- ? exports.SPOT_PRICES_SUPPORT_INFO[asset.chainId]
369
- : `${caipChainId}/erc20:${asset.tokenAddress.toLowerCase()}`),
561
+ assetId: assetId,
370
562
  };
371
563
  })
372
- .filter((asset) => asset.assetId);
564
+ .filter((asset) => asset !== undefined);
373
565
  if (assetsWithIds.length === 0) {
374
566
  return [];
375
567
  }
@@ -402,6 +594,11 @@ class CodefiTokenPricesServiceV2 {
402
594
  * @returns The exchange rates for the requested base currency.
403
595
  */
404
596
  async fetchExchangeRates({ baseCurrency, includeUsdRate, cryptocurrencies, }) {
597
+ // Refresh supported currencies in background (non-blocking)
598
+ // This ensures the list stays fresh during normal polling
599
+ // Note: fetchSupportedCurrencies handles errors internally and always resolves
600
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
601
+ fetchSupportedCurrencies();
405
602
  const url = new URL(`${BASE_URL_V1}/exchange-rates`);
406
603
  url.searchParams.append('baseCurrency', baseCurrency);
407
604
  const urlUsd = new URL(`${BASE_URL_V1}/exchange-rates`);
@@ -474,8 +671,13 @@ class CodefiTokenPricesServiceV2 {
474
671
  * @returns True if the API supports the chain ID, false otherwise.
475
672
  */
476
673
  validateChainIdSupported(chainId) {
477
- const supportedChainIds = exports.SUPPORTED_CHAIN_IDS;
478
- return typeof chainId === 'string' && supportedChainIds.includes(chainId);
674
+ // Use dynamically fetched supported networks
675
+ const supportedChainIds = getSupportedChainIdsV3AsHex();
676
+ // Also include the hardcoded fallback list for backwards compatibility
677
+ const allSupportedChainIds = [
678
+ ...new Set([...supportedChainIds, ...exports.SUPPORTED_CHAIN_IDS]),
679
+ ];
680
+ return (typeof chainId === 'string' && allSupportedChainIds.includes(chainId));
479
681
  }
480
682
  /**
481
683
  * Type guard for whether the API can return token prices in the given
@@ -486,11 +688,19 @@ class CodefiTokenPricesServiceV2 {
486
688
  * @returns True if the API supports the currency, false otherwise.
487
689
  */
488
690
  validateCurrencySupported(currency) {
489
- const supportedCurrencies = exports.SUPPORTED_CURRENCIES;
691
+ const supportedCurrencies = getSupportedCurrencies();
490
692
  return (typeof currency === 'string' &&
491
693
  supportedCurrencies.includes(currency.toLowerCase()));
492
694
  }
695
+ /**
696
+ * Fetches the list of supported currencies from the API.
697
+ *
698
+ * @returns The list of supported currencies.
699
+ */
700
+ async updateSupportedCurrencies() {
701
+ return fetchSupportedCurrencies();
702
+ }
493
703
  }
494
704
  exports.CodefiTokenPricesServiceV2 = CodefiTokenPricesServiceV2;
495
- _CodefiTokenPricesServiceV2_policy = new WeakMap();
705
+ _CodefiTokenPricesServiceV2_policy = new WeakMap(), _CodefiTokenPricesServiceV2_nativeAssetIdentifiers = new WeakMap();
496
706
  //# sourceMappingURL=codefi-v2.cjs.map