@metamask/assets-controller 0.2.0 → 1.0.0

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 (126) hide show
  1. package/CHANGELOG.md +17 -1
  2. package/dist/AssetsController-method-action-types.cjs +7 -0
  3. package/dist/AssetsController-method-action-types.cjs.map +1 -0
  4. package/dist/AssetsController-method-action-types.d.cts +78 -0
  5. package/dist/AssetsController-method-action-types.d.cts.map +1 -0
  6. package/dist/AssetsController-method-action-types.d.mts +78 -0
  7. package/dist/AssetsController-method-action-types.d.mts.map +1 -0
  8. package/dist/AssetsController-method-action-types.mjs +6 -0
  9. package/dist/AssetsController-method-action-types.mjs.map +1 -0
  10. package/dist/AssetsController.cjs +201 -237
  11. package/dist/AssetsController.cjs.map +1 -1
  12. package/dist/AssetsController.d.cts +29 -92
  13. package/dist/AssetsController.d.cts.map +1 -1
  14. package/dist/AssetsController.d.mts +29 -92
  15. package/dist/AssetsController.d.mts.map +1 -1
  16. package/dist/AssetsController.mjs +201 -237
  17. package/dist/AssetsController.mjs.map +1 -1
  18. package/dist/data-sources/AbstractDataSource.cjs +8 -0
  19. package/dist/data-sources/AbstractDataSource.cjs.map +1 -1
  20. package/dist/data-sources/AbstractDataSource.d.cts +16 -1
  21. package/dist/data-sources/AbstractDataSource.d.cts.map +1 -1
  22. package/dist/data-sources/AbstractDataSource.d.mts +16 -1
  23. package/dist/data-sources/AbstractDataSource.d.mts.map +1 -1
  24. package/dist/data-sources/AbstractDataSource.mjs +8 -0
  25. package/dist/data-sources/AbstractDataSource.mjs.map +1 -1
  26. package/dist/data-sources/AccountsApiDataSource.cjs +25 -99
  27. package/dist/data-sources/AccountsApiDataSource.cjs.map +1 -1
  28. package/dist/data-sources/AccountsApiDataSource.d.cts +5 -67
  29. package/dist/data-sources/AccountsApiDataSource.d.cts.map +1 -1
  30. package/dist/data-sources/AccountsApiDataSource.d.mts +5 -67
  31. package/dist/data-sources/AccountsApiDataSource.d.mts.map +1 -1
  32. package/dist/data-sources/AccountsApiDataSource.mjs +24 -97
  33. package/dist/data-sources/AccountsApiDataSource.mjs.map +1 -1
  34. package/dist/data-sources/BackendWebsocketDataSource.cjs +138 -45
  35. package/dist/data-sources/BackendWebsocketDataSource.cjs.map +1 -1
  36. package/dist/data-sources/BackendWebsocketDataSource.d.cts +19 -66
  37. package/dist/data-sources/BackendWebsocketDataSource.d.cts.map +1 -1
  38. package/dist/data-sources/BackendWebsocketDataSource.d.mts +19 -66
  39. package/dist/data-sources/BackendWebsocketDataSource.d.mts.map +1 -1
  40. package/dist/data-sources/BackendWebsocketDataSource.mjs +138 -45
  41. package/dist/data-sources/BackendWebsocketDataSource.mjs.map +1 -1
  42. package/dist/data-sources/PriceDataSource.cjs +22 -44
  43. package/dist/data-sources/PriceDataSource.cjs.map +1 -1
  44. package/dist/data-sources/PriceDataSource.d.cts +6 -89
  45. package/dist/data-sources/PriceDataSource.d.cts.map +1 -1
  46. package/dist/data-sources/PriceDataSource.d.mts +6 -89
  47. package/dist/data-sources/PriceDataSource.d.mts.map +1 -1
  48. package/dist/data-sources/PriceDataSource.mjs +22 -44
  49. package/dist/data-sources/PriceDataSource.mjs.map +1 -1
  50. package/dist/data-sources/RpcDataSource.cjs +64 -102
  51. package/dist/data-sources/RpcDataSource.cjs.map +1 -1
  52. package/dist/data-sources/RpcDataSource.d.cts +16 -55
  53. package/dist/data-sources/RpcDataSource.d.cts.map +1 -1
  54. package/dist/data-sources/RpcDataSource.d.mts +16 -55
  55. package/dist/data-sources/RpcDataSource.d.mts.map +1 -1
  56. package/dist/data-sources/RpcDataSource.mjs +64 -102
  57. package/dist/data-sources/RpcDataSource.mjs.map +1 -1
  58. package/dist/data-sources/SnapDataSource.cjs +32 -30
  59. package/dist/data-sources/SnapDataSource.cjs.map +1 -1
  60. package/dist/data-sources/SnapDataSource.d.cts +7 -44
  61. package/dist/data-sources/SnapDataSource.d.cts.map +1 -1
  62. package/dist/data-sources/SnapDataSource.d.mts +7 -44
  63. package/dist/data-sources/SnapDataSource.d.mts.map +1 -1
  64. package/dist/data-sources/SnapDataSource.mjs +32 -30
  65. package/dist/data-sources/SnapDataSource.mjs.map +1 -1
  66. package/dist/data-sources/TokenDataSource.cjs +3 -16
  67. package/dist/data-sources/TokenDataSource.cjs.map +1 -1
  68. package/dist/data-sources/TokenDataSource.d.cts +2 -25
  69. package/dist/data-sources/TokenDataSource.d.cts.map +1 -1
  70. package/dist/data-sources/TokenDataSource.d.mts +2 -25
  71. package/dist/data-sources/TokenDataSource.d.mts.map +1 -1
  72. package/dist/data-sources/TokenDataSource.mjs +3 -16
  73. package/dist/data-sources/TokenDataSource.mjs.map +1 -1
  74. package/dist/data-sources/index.cjs +1 -6
  75. package/dist/data-sources/index.cjs.map +1 -1
  76. package/dist/data-sources/index.d.cts +6 -7
  77. package/dist/data-sources/index.d.cts.map +1 -1
  78. package/dist/data-sources/index.d.mts +6 -7
  79. package/dist/data-sources/index.d.mts.map +1 -1
  80. package/dist/data-sources/index.mjs +1 -3
  81. package/dist/data-sources/index.mjs.map +1 -1
  82. package/dist/index.cjs +6 -6
  83. package/dist/index.cjs.map +1 -1
  84. package/dist/index.d.cts +11 -11
  85. package/dist/index.d.cts.map +1 -1
  86. package/dist/index.d.mts +11 -11
  87. package/dist/index.d.mts.map +1 -1
  88. package/dist/index.mjs +3 -3
  89. package/dist/index.mjs.map +1 -1
  90. package/dist/middlewares/DetectionMiddleware.cjs +4 -27
  91. package/dist/middlewares/DetectionMiddleware.cjs.map +1 -1
  92. package/dist/middlewares/DetectionMiddleware.d.cts +3 -26
  93. package/dist/middlewares/DetectionMiddleware.d.cts.map +1 -1
  94. package/dist/middlewares/DetectionMiddleware.d.mts +3 -26
  95. package/dist/middlewares/DetectionMiddleware.d.mts.map +1 -1
  96. package/dist/middlewares/DetectionMiddleware.mjs +4 -27
  97. package/dist/middlewares/DetectionMiddleware.mjs.map +1 -1
  98. package/dist/middlewares/index.cjs.map +1 -1
  99. package/dist/middlewares/index.d.cts +1 -1
  100. package/dist/middlewares/index.d.cts.map +1 -1
  101. package/dist/middlewares/index.d.mts +1 -1
  102. package/dist/middlewares/index.d.mts.map +1 -1
  103. package/dist/middlewares/index.mjs.map +1 -1
  104. package/dist/selectors/balance.cjs +306 -0
  105. package/dist/selectors/balance.cjs.map +1 -0
  106. package/dist/selectors/balance.d.cts +22 -0
  107. package/dist/selectors/balance.d.cts.map +1 -0
  108. package/dist/selectors/balance.d.mts +22 -0
  109. package/dist/selectors/balance.d.mts.map +1 -0
  110. package/dist/selectors/balance.mjs +297 -0
  111. package/dist/selectors/balance.mjs.map +1 -0
  112. package/dist/types.cjs.map +1 -1
  113. package/dist/types.d.cts +53 -18
  114. package/dist/types.d.cts.map +1 -1
  115. package/dist/types.d.mts +53 -18
  116. package/dist/types.d.mts.map +1 -1
  117. package/dist/types.mjs.map +1 -1
  118. package/package.json +2 -2
  119. package/dist/data-sources/initDataSources.cjs +0 -215
  120. package/dist/data-sources/initDataSources.cjs.map +0 -1
  121. package/dist/data-sources/initDataSources.d.cts +0 -140
  122. package/dist/data-sources/initDataSources.d.cts.map +0 -1
  123. package/dist/data-sources/initDataSources.d.mts +0 -140
  124. package/dist/data-sources/initDataSources.d.mts.map +0 -1
  125. package/dist/data-sources/initDataSources.mjs +0 -210
  126. package/dist/data-sources/initDataSources.mjs.map +0 -1
package/dist/types.d.mts CHANGED
@@ -253,13 +253,22 @@ export type AssetBalance = FungibleAssetBalance | ERC721AssetBalance | ERC1155As
253
253
  * Data type dimension - what kind of data
254
254
  */
255
255
  export type DataType = 'balance' | 'metadata' | 'price';
256
+ /**
257
+ * Account with its supported chains (enabled chains ∩ account scope).
258
+ * Pre-computed by the controller so data sources do not need to implement
259
+ * account-scope logic; they iterate over supportedChains for each account.
260
+ */
261
+ export type AccountWithSupportedChains = {
262
+ account: InternalAccount;
263
+ supportedChains: ChainId[];
264
+ };
256
265
  /**
257
266
  * Request for data from data sources
258
267
  */
259
268
  export type DataRequest = {
260
- /** Accounts to fetch data for */
261
- accounts: InternalAccount[];
262
- /** CAIP-2 chain IDs */
269
+ /** Accounts with their supported chains (enabled ∩ account scope). Data sources use this instead of computing accountSupportsChain. */
270
+ accountsWithSupportedChains: AccountWithSupportedChains[];
271
+ /** CAIP-2 chain IDs (union of chains in this request) */
263
272
  chainIds: ChainId[];
264
273
  /** Filter by asset types */
265
274
  assetTypes?: AssetType[];
@@ -287,6 +296,46 @@ export type DataResponse = {
287
296
  /** Detected assets (assets that do not have metadata) */
288
297
  detectedAssets?: Record<AccountId, Caip19AssetId[]>;
289
298
  };
299
+ /**
300
+ * Callbacks for data sources to report to AssetsController.
301
+ * Passed to data sources so they report by direct call instead of messenger.
302
+ */
303
+ export type AssetsControllerReport = {
304
+ onActiveChainsUpdate: (dataSourceId: string, activeChains: ChainId[]) => void;
305
+ onAssetsUpdate: (response: DataResponse, sourceId: string) => Promise<void>;
306
+ };
307
+ /** Request passed from controller to data source when subscribing */
308
+ export type DataSourceSubscriptionRequest = {
309
+ request: DataRequest;
310
+ subscriptionId: string;
311
+ isUpdate: boolean;
312
+ };
313
+ /**
314
+ * Interface for balance data sources that the controller calls directly.
315
+ * No messenger is required for controller <-> data source communication.
316
+ */
317
+ export type BalanceDataSource = {
318
+ getAssetsMiddleware: () => Middleware;
319
+ subscribe: (request: DataSourceSubscriptionRequest) => Promise<void>;
320
+ unsubscribe: (subscriptionId: string) => Promise<void>;
321
+ getName: () => string;
322
+ };
323
+ /**
324
+ * Interface for the price data source (subscribe/unsubscribe + middleware).
325
+ * Controller calls these methods directly.
326
+ */
327
+ export type PriceDataSourceInterface = {
328
+ getAssetsMiddleware: () => Middleware;
329
+ subscribe: (request: DataSourceSubscriptionRequest) => Promise<void>;
330
+ unsubscribe: (subscriptionId: string) => Promise<void>;
331
+ };
332
+ /**
333
+ * Middleware-only source (e.g. detection, token enrichment).
334
+ * Controller calls getAssetsMiddleware() directly.
335
+ */
336
+ export type MiddlewareDataSource = {
337
+ getAssetsMiddleware: () => Middleware;
338
+ };
290
339
  /**
291
340
  * Internal state structure for AssetsController following normalized design.
292
341
  *
@@ -364,21 +413,7 @@ export type FetchContext = Context;
364
413
  export type FetchNextFunction = NextFunction;
365
414
  export type FetchMiddleware = Middleware;
366
415
  /**
367
- * Data source ID.
368
- *
369
- * Data sources follow a standard messenger pattern:
370
- * - `${id}:getActiveChains` - action to get active chains
371
- * - `${id}:activeChainsUpdated` - event when chains change
372
- *
373
- * Registration order determines subscription order.
374
- */
375
- export type DataSourceDefinition = string;
376
- /**
377
- * Registered data source
378
- */
379
- export type RegisteredDataSource = DataSourceDefinition;
380
- /**
381
- * Subscription response
416
+ * Subscription response returned when subscribing to asset updates.
382
417
  */
383
418
  export type SubscriptionResponse = {
384
419
  /** Chains actively subscribed */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,IAAI,EAAE,wBAAwB;AAExE;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG,aAAa,CAAC;AAE1C;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,WAAW,CAAC;AAMlC;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,KAAK,GAAG,aAAa,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,SAAS,GACT,KAAK,GACL,MAAM,CAAC;AAMX;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,+CAA+C;IAC/C,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,8DAA8D;IAC9D,IAAI,EAAE,aA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AAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,aAAa,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CACjC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC3B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAyZA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,YAAY,CAC1B,SAAqB,EACrB,UAAsB;IAEtB,OAAO,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QACzB,MAAM,cAAc,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC;QAC7C,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QAEtE,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;QAED,OAAO,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { CaipAssetType, CaipChainId, Json } from '@metamask/utils';\n\n/**\n * CAIP-19 compliant asset identifier\n * Format: \"{chainId}/{assetNamespace}:{assetReference}[/tokenId]\"\n *\n * Examples:\n * - Native: \"eip155:1/slip44:60\" (ETH)\n * - ERC20: \"eip155:1/erc20:0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\" (USDC)\n * - ERC721: \"eip155:1/erc721:0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D/1234\" (BAYC #1234)\n * - SPL: \"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/spl:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\"\n */\nexport type Caip19AssetId = CaipAssetType;\n\n/**\n * InternalAccount UUID from AccountsController\n * Not the blockchain address!\n */\nexport type AccountId = string;\n\n/**\n * CAIP-2 chain identifier\n */\nexport type ChainId = CaipChainId;\n\n// ============================================================================\n// ASSET TYPES - Defined by metadata structure\n// ============================================================================\n\n/**\n * Asset types define the metadata structure, not blockchain implementation.\n * - \"fungible\" includes: native, erc20, spl - all share balance, symbol, decimals\n * - \"nft\" includes: erc721, erc1155 - include tokenId, image, attributes\n */\nexport type AssetType = 'fungible' | 'nft' | 'collectible';\n\n/**\n * Token standards - blockchain implementation details\n */\nexport type TokenStandard =\n | 'native'\n | 'erc20'\n | 'erc721'\n | 'erc1155'\n | 'spl'\n | string;\n\n// ============================================================================\n// METADATA TYPES (vary by asset type)\n// ============================================================================\n\n/**\n * UI preferences for an asset (stored in assetPreferences state, not in metadata).\n */\nexport type AssetPreferences = {\n /** Whether the asset is hidden from display */\n hidden?: boolean;\n};\n\n/**\n * Base metadata attributes shared by ALL asset types.\n */\nexport type BaseAssetMetadata = {\n /** Token standard - how it's implemented on the blockchain */\n type: TokenStandard;\n /** Display symbol (e.g., \"ETH\", \"USDC\") */\n symbol: string;\n /** Full name (e.g., \"Ethereum\", \"USD Coin\") */\n name: string;\n /** Token decimals (18 for ETH, 6 for USDC, etc.) */\n decimals: number;\n /** Logo URL or data URI */\n image?: string;\n};\n\n// ============================================================================\n// TOKEN CONTRACT DATA TYPES\n// ============================================================================\n\n/** Fee information for token transfers */\nexport type TokenFees = {\n avgFee: number;\n maxFee: number;\n minFee: number;\n};\n\n/** Honeypot detection status */\nexport type HoneypotStatus = {\n honeypotIs: boolean;\n goPlus?: boolean;\n};\n\n/** Storage slot information for the contract */\nexport type StorageSlots = {\n balance: number;\n approval: number;\n};\n\n/** Localized description */\nexport type LocalizedDescription = {\n en: string;\n};\n\n// ============================================================================\n// ASSET METADATA TYPES\n// ============================================================================\n\n/**\n * Metadata for fungible tokens.\n * Structure mirrors V3AssetResponse from the Tokens API.\n *\n * Differences from V3AssetResponse:\n * - `type` is derived from assetId namespace (not in API response)\n * - `image` maps from API's `iconUrl`\n * - `assetId` is not stored (used as the key)\n */\nexport type FungibleAssetMetadata = {\n /** Token type derived from assetId namespace */\n type: 'native' | 'erc20' | 'spl';\n /** CoinGecko ID for price lookups */\n coingeckoId?: string;\n /** Number of token list occurrences */\n occurrences?: number;\n /** DEX/aggregator integrations */\n aggregators?: string[];\n /** Asset labels/tags (e.g., \"stable_coin\") */\n labels?: string[];\n /** Whether the token supports ERC-20 permit */\n erc20Permit?: boolean;\n /** Fee information for token transfers */\n fees?: TokenFees;\n /** Honeypot detection status */\n honeypotStatus?: HoneypotStatus;\n /** Storage slot information for the contract */\n storage?: StorageSlots;\n /** Whether the contract is verified */\n isContractVerified?: boolean;\n /** Localized description */\n description?: LocalizedDescription;\n} & BaseAssetMetadata;\n\n/**\n * Metadata for ERC721 NFTs\n * Asset Type: \"nft\"\n */\nexport type ERC721AssetMetadata = {\n type: 'erc721';\n decimals: 0;\n /** Collection name */\n collectionName?: string;\n /** Collection size */\n collectionSize?: number;\n /** NFT traits/attributes - must be Json-serializable */\n traits?: Record<string, Json>;\n /** Rarity score */\n rarity?: number;\n /** Verification status */\n verified?: boolean;\n} & BaseAssetMetadata;\n\n/**\n * Metadata for ERC1155 multi-tokens\n */\nexport type ERC1155AssetMetadata = {\n type: 'erc1155';\n /** Token URI */\n tokenUri?: string;\n /** Token category */\n category?: string;\n /** Spam detection flag */\n isSpam?: boolean;\n} & BaseAssetMetadata;\n\n/**\n * Union type representing all possible asset metadata types.\n * All types must be JSON-serializable.\n */\nexport type AssetMetadata =\n | FungibleAssetMetadata\n | ERC721AssetMetadata\n | ERC1155AssetMetadata\n | (BaseAssetMetadata & { [key: string]: Json });\n\n// ============================================================================\n// PRICE TYPES (vary by asset type)\n// ============================================================================\n\n/**\n * Base price attributes.\n */\nexport type BaseAssetPrice = {\n /** Current price in USD */\n price: number;\n /** Timestamp of last price update */\n lastUpdated: number;\n};\n\n/**\n * Price data for fungible tokens (native, ERC20, SPL)\n * Matches V3SpotPricesResponse from the Price API.\n */\nexport type FungibleAssetPrice = {\n /** CoinGecko ID */\n id?: string;\n /** Current price in USD */\n price: number;\n /** Market capitalization */\n marketCap?: number;\n /** All-time high price */\n allTimeHigh?: number;\n /** All-time low price */\n allTimeLow?: number;\n /** 24h trading volume */\n totalVolume?: number;\n /** 24h high price */\n high1d?: number;\n /** 24h low price */\n low1d?: number;\n /** Circulating supply */\n circulatingSupply?: number;\n /** Fully diluted market cap */\n dilutedMarketCap?: number;\n /** 24h market cap change percentage */\n marketCapPercentChange1d?: number;\n /** 24h price change in USD */\n priceChange1d?: number;\n /** 1h price change percentage */\n pricePercentChange1h?: number;\n /** 24h price change percentage */\n pricePercentChange1d?: number;\n /** 7d price change percentage */\n pricePercentChange7d?: number;\n /** 14d price change percentage */\n pricePercentChange14d?: number;\n /** 30d price change percentage */\n pricePercentChange30d?: number;\n /** 200d price change percentage */\n pricePercentChange200d?: number;\n /** 1y price change percentage */\n pricePercentChange1y?: number;\n /** Timestamp of last price update (added by client) */\n lastUpdated: number;\n};\n\n/**\n * Price data for NFT collections\n */\nexport type NFTAssetPrice = {\n /** Floor price */\n floorPrice?: number;\n /** Last sale price */\n lastSalePrice?: number;\n /** Collection trading volume */\n collectionVolume?: number;\n /** Average price */\n averagePrice?: number;\n /** Number of sales in 24h */\n sales24h?: number;\n} & BaseAssetPrice;\n\n/**\n * Union type representing all possible asset price types.\n * All types must be JSON-serializable.\n */\nexport type AssetPrice =\n | FungibleAssetPrice\n | NFTAssetPrice\n | (BaseAssetPrice & { [key: string]: Json });\n\n// ============================================================================\n// BALANCE TYPES (vary by asset type)\n// ============================================================================\n\n/**\n * Balance data for fungible tokens (native, ERC20, SPL).\n */\nexport type FungibleAssetBalance = {\n /** Raw balance amount as string (e.g., \"1000000000\" for 1000 USDC) */\n amount: string;\n};\n\n/**\n * Balance data for ERC721 NFTs.\n * Each tokenId has its own CAIP-19 asset ID, so always \"1\".\n */\nexport type ERC721AssetBalance = {\n /** Always \"1\" for ERC721 (non-fungible) */\n amount: '1';\n};\n\n/**\n * Balance data for ERC1155 multi-tokens.\n */\nexport type ERC1155AssetBalance = {\n /** Quantity owned of this specific tokenId */\n amount: string;\n};\n\n/**\n * Union type representing all possible asset balance types.\n * All types must be JSON-serializable.\n */\nexport type AssetBalance =\n | FungibleAssetBalance\n | ERC721AssetBalance\n | ERC1155AssetBalance\n | { amount: string; [key: string]: Json };\n\n// ============================================================================\n// DATA SOURCE TYPES\n// ============================================================================\n\n/**\n * Data type dimension - what kind of data\n */\nexport type DataType = 'balance' | 'metadata' | 'price';\n\n/**\n * Request for data from data sources\n */\nexport type DataRequest = {\n /** Accounts to fetch data for */\n accounts: InternalAccount[];\n /** CAIP-2 chain IDs */\n chainIds: ChainId[];\n /** Filter by asset types */\n assetTypes?: AssetType[];\n /** Which data to fetch */\n dataTypes: DataType[];\n /** Specific CAIP-19 asset IDs */\n customAssets?: Caip19AssetId[];\n /** Force fresh fetch, bypass cache */\n forceUpdate?: boolean;\n /** Hint for polling interval (ms) - used by data sources that implement polling */\n updateInterval?: number;\n};\n\n/**\n * Response from data sources\n */\nexport type DataResponse = {\n /** Metadata for assets (shared across accounts) */\n assetsMetadata?: Record<Caip19AssetId, AssetMetadata>;\n /** Price data for assets (shared across accounts) */\n assetsPrice?: Record<Caip19AssetId, AssetPrice>;\n /** Balance data per account */\n assetsBalance?: Record<AccountId, Record<Caip19AssetId, AssetBalance>>;\n /** Errors encountered, keyed by chain ID */\n errors?: Record<ChainId, string>;\n /** Detected assets (assets that do not have metadata) */\n detectedAssets?: Record<AccountId, Caip19AssetId[]>;\n};\n\n// ============================================================================\n// UNIFIED MIDDLEWARE TYPES\n// ============================================================================\n\n/**\n * Internal state structure for AssetsController following normalized design.\n *\n * Keys use CAIP identifiers:\n * - assetsMetadata keys: CAIP-19 asset IDs (e.g., \"eip155:1/erc20:0x...\")\n * - assetsBalance outer keys: Account IDs (InternalAccount.id UUIDs)\n * - assetsBalance inner keys: CAIP-19 asset IDs\n * - assetsPrice keys: CAIP-19 asset IDs\n * - customAssets outer keys: Account IDs (InternalAccount.id UUIDs)\n * - customAssets inner values: CAIP-19 asset IDs array\n * - assetPreferences keys: CAIP-19 asset IDs\n */\nexport type AssetsControllerStateInternal = {\n /** Shared metadata for all assets (stored once per asset) */\n assetsMetadata: Record<Caip19AssetId, AssetMetadata>;\n /** Per-account balance data */\n assetsBalance: Record<AccountId, Record<Caip19AssetId, AssetBalance>>;\n /** Price data for assets */\n assetsPrice: Record<Caip19AssetId, AssetPrice>;\n /** Custom assets added by users per account */\n customAssets: Record<AccountId, Caip19AssetId[]>;\n /** UI preferences per asset (e.g. hidden) - separate from metadata */\n assetPreferences: Record<Caip19AssetId, AssetPreferences>;\n};\n\n/**\n * Base context for all middleware operations.\n * Contains the common interface shared by fetch and subscribe.\n */\nexport type Context = {\n /** The data request */\n request: DataRequest;\n /** The response data (mutated by middlewares) */\n response: DataResponse;\n /** Get current assets state */\n getAssetsState: () => AssetsControllerStateInternal;\n};\n\n/**\n * Next function for middleware chain\n */\nexport type NextFunction = (context: Context) => Promise<Context>;\n\n/**\n * Middleware function - works for both fetch and subscribe operations.\n */\nexport type Middleware = (\n context: Context,\n next: NextFunction,\n) => Promise<Context>;\n\n/**\n * Wraps a middleware to only execute if specific dataTypes are requested.\n *\n * @param dataTypes - DataTypes that must be in the request for middleware to run\n * @param middleware - The middleware to conditionally execute\n * @returns A middleware that skips execution if none of the dataTypes are requested\n *\n * @example\n * ```typescript\n * // Only runs for metadata requests\n * const metadataMiddleware = forDataTypes(['metadata'], async (ctx, next) => {\n * const result = await next(ctx);\n * // Enrich metadata...\n * return result;\n * });\n *\n * // Runs for balance or price requests\n * const balanceOrPriceMiddleware = forDataTypes(['balance', 'price'], async (ctx, next) => {\n * const result = await next(ctx);\n * // Process balances or prices...\n * return result;\n * });\n * ```\n */\nexport function forDataTypes(\n dataTypes: DataType[],\n middleware: Middleware,\n): Middleware {\n return async (ctx, next) => {\n const requestedTypes = ctx.request.dataTypes;\n const shouldRun = dataTypes.some((dt) => requestedTypes.includes(dt));\n\n if (!shouldRun) {\n return next(ctx);\n }\n\n return middleware(ctx, next);\n };\n}\n\n/**\n * Context for fetch operations.\n * Extends base Context - no additional fields needed for fetch.\n */\nexport type FetchContext = Context;\n\n// Legacy aliases for backwards compatibility\nexport type FetchNextFunction = NextFunction;\nexport type FetchMiddleware = Middleware;\n\n/**\n * Data source ID.\n *\n * Data sources follow a standard messenger pattern:\n * - `${id}:getActiveChains` - action to get active chains\n * - `${id}:activeChainsUpdated` - event when chains change\n *\n * Registration order determines subscription order.\n */\nexport type DataSourceDefinition = string;\n\n/**\n * Registered data source\n */\nexport type RegisteredDataSource = DataSourceDefinition;\n\n/**\n * Subscription response\n */\nexport type SubscriptionResponse = {\n /** Chains actively subscribed */\n chains: ChainId[];\n /** Account ID being watched */\n accountId: AccountId;\n /** Asset types being watched */\n assetTypes: AssetType[];\n /** Data types being kept fresh */\n dataTypes: DataType[];\n /** Cleanup function */\n unsubscribe: () => void;\n};\n\n// ============================================================================\n// COMBINED ASSET TYPE (for UI)\n// ============================================================================\n\n/**\n * Combined asset type matching state structure: balance, metadata, price\n */\nexport type Asset = {\n /** CAIP-19 asset ID */\n id: Caip19AssetId;\n /** CAIP-2 chain ID (extracted from id) */\n chainId: ChainId;\n /** Balance data */\n balance: AssetBalance;\n /** Metadata (symbol, name, decimals, etc.) */\n metadata: AssetMetadata;\n /** Price data */\n price: AssetPrice;\n /** Computed fiat value (balance × price) */\n fiatValue: number;\n};\n\n// ============================================================================\n// EVENT TYPES\n// ============================================================================\n\n/**\n * Event emitted when balances change\n */\nexport type BalanceChangeEvent = {\n accountId: AccountId;\n assetId: Caip19AssetId;\n previousAmount: string;\n newAmount: string;\n timestamp: number;\n};\n\n/**\n * Event emitted when prices change\n */\nexport type PriceChangeEvent = {\n assetIds: Caip19AssetId[];\n timestamp: number;\n};\n\n/**\n * Event emitted when metadata changes\n */\nexport type MetadataChangeEvent = {\n assetId: Caip19AssetId;\n changes: Partial<AssetMetadata>;\n};\n\n/**\n * Event emitted when assets without metadata are detected\n */\nexport type AssetsDetectedEvent = {\n accountId: AccountId;\n assetIds: Caip19AssetId[];\n};\n"]}
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAodA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,YAAY,CAC1B,SAAqB,EACrB,UAAsB;IAEtB,OAAO,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QACzB,MAAM,cAAc,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC;QAC7C,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QAEtE,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;QAED,OAAO,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { CaipAssetType, CaipChainId, Json } from '@metamask/utils';\n\n/**\n * CAIP-19 compliant asset identifier\n * Format: \"{chainId}/{assetNamespace}:{assetReference}[/tokenId]\"\n *\n * Examples:\n * - Native: \"eip155:1/slip44:60\" (ETH)\n * - ERC20: \"eip155:1/erc20:0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\" (USDC)\n * - ERC721: \"eip155:1/erc721:0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D/1234\" (BAYC #1234)\n * - SPL: \"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/spl:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\"\n */\nexport type Caip19AssetId = CaipAssetType;\n\n/**\n * InternalAccount UUID from AccountsController\n * Not the blockchain address!\n */\nexport type AccountId = string;\n\n/**\n * CAIP-2 chain identifier\n */\nexport type ChainId = CaipChainId;\n\n// ============================================================================\n// ASSET TYPES - Defined by metadata structure\n// ============================================================================\n\n/**\n * Asset types define the metadata structure, not blockchain implementation.\n * - \"fungible\" includes: native, erc20, spl - all share balance, symbol, decimals\n * - \"nft\" includes: erc721, erc1155 - include tokenId, image, attributes\n */\nexport type AssetType = 'fungible' | 'nft' | 'collectible';\n\n/**\n * Token standards - blockchain implementation details\n */\nexport type TokenStandard =\n | 'native'\n | 'erc20'\n | 'erc721'\n | 'erc1155'\n | 'spl'\n | string;\n\n// ============================================================================\n// METADATA TYPES (vary by asset type)\n// ============================================================================\n\n/**\n * UI preferences for an asset (stored in assetPreferences state, not in metadata).\n */\nexport type AssetPreferences = {\n /** Whether the asset is hidden from display */\n hidden?: boolean;\n};\n\n/**\n * Base metadata attributes shared by ALL asset types.\n */\nexport type BaseAssetMetadata = {\n /** Token standard - how it's implemented on the blockchain */\n type: TokenStandard;\n /** Display symbol (e.g., \"ETH\", \"USDC\") */\n symbol: string;\n /** Full name (e.g., \"Ethereum\", \"USD Coin\") */\n name: string;\n /** Token decimals (18 for ETH, 6 for USDC, etc.) */\n decimals: number;\n /** Logo URL or data URI */\n image?: string;\n};\n\n// ============================================================================\n// TOKEN CONTRACT DATA TYPES\n// ============================================================================\n\n/** Fee information for token transfers */\nexport type TokenFees = {\n avgFee: number;\n maxFee: number;\n minFee: number;\n};\n\n/** Honeypot detection status */\nexport type HoneypotStatus = {\n honeypotIs: boolean;\n goPlus?: boolean;\n};\n\n/** Storage slot information for the contract */\nexport type StorageSlots = {\n balance: number;\n approval: number;\n};\n\n/** Localized description */\nexport type LocalizedDescription = {\n en: string;\n};\n\n// ============================================================================\n// ASSET METADATA TYPES\n// ============================================================================\n\n/**\n * Metadata for fungible tokens.\n * Structure mirrors V3AssetResponse from the Tokens API.\n *\n * Differences from V3AssetResponse:\n * - `type` is derived from assetId namespace (not in API response)\n * - `image` maps from API's `iconUrl`\n * - `assetId` is not stored (used as the key)\n */\nexport type FungibleAssetMetadata = {\n /** Token type derived from assetId namespace */\n type: 'native' | 'erc20' | 'spl';\n /** CoinGecko ID for price lookups */\n coingeckoId?: string;\n /** Number of token list occurrences */\n occurrences?: number;\n /** DEX/aggregator integrations */\n aggregators?: string[];\n /** Asset labels/tags (e.g., \"stable_coin\") */\n labels?: string[];\n /** Whether the token supports ERC-20 permit */\n erc20Permit?: boolean;\n /** Fee information for token transfers */\n fees?: TokenFees;\n /** Honeypot detection status */\n honeypotStatus?: HoneypotStatus;\n /** Storage slot information for the contract */\n storage?: StorageSlots;\n /** Whether the contract is verified */\n isContractVerified?: boolean;\n /** Localized description */\n description?: LocalizedDescription;\n} & BaseAssetMetadata;\n\n/**\n * Metadata for ERC721 NFTs\n * Asset Type: \"nft\"\n */\nexport type ERC721AssetMetadata = {\n type: 'erc721';\n decimals: 0;\n /** Collection name */\n collectionName?: string;\n /** Collection size */\n collectionSize?: number;\n /** NFT traits/attributes - must be Json-serializable */\n traits?: Record<string, Json>;\n /** Rarity score */\n rarity?: number;\n /** Verification status */\n verified?: boolean;\n} & BaseAssetMetadata;\n\n/**\n * Metadata for ERC1155 multi-tokens\n */\nexport type ERC1155AssetMetadata = {\n type: 'erc1155';\n /** Token URI */\n tokenUri?: string;\n /** Token category */\n category?: string;\n /** Spam detection flag */\n isSpam?: boolean;\n} & BaseAssetMetadata;\n\n/**\n * Union type representing all possible asset metadata types.\n * All types must be JSON-serializable.\n */\nexport type AssetMetadata =\n | FungibleAssetMetadata\n | ERC721AssetMetadata\n | ERC1155AssetMetadata\n | (BaseAssetMetadata & { [key: string]: Json });\n\n// ============================================================================\n// PRICE TYPES (vary by asset type)\n// ============================================================================\n\n/**\n * Base price attributes.\n */\nexport type BaseAssetPrice = {\n /** Current price in USD */\n price: number;\n /** Timestamp of last price update */\n lastUpdated: number;\n};\n\n/**\n * Price data for fungible tokens (native, ERC20, SPL)\n * Matches V3SpotPricesResponse from the Price API.\n */\nexport type FungibleAssetPrice = {\n /** CoinGecko ID */\n id?: string;\n /** Current price in USD */\n price: number;\n /** Market capitalization */\n marketCap?: number;\n /** All-time high price */\n allTimeHigh?: number;\n /** All-time low price */\n allTimeLow?: number;\n /** 24h trading volume */\n totalVolume?: number;\n /** 24h high price */\n high1d?: number;\n /** 24h low price */\n low1d?: number;\n /** Circulating supply */\n circulatingSupply?: number;\n /** Fully diluted market cap */\n dilutedMarketCap?: number;\n /** 24h market cap change percentage */\n marketCapPercentChange1d?: number;\n /** 24h price change in USD */\n priceChange1d?: number;\n /** 1h price change percentage */\n pricePercentChange1h?: number;\n /** 24h price change percentage */\n pricePercentChange1d?: number;\n /** 7d price change percentage */\n pricePercentChange7d?: number;\n /** 14d price change percentage */\n pricePercentChange14d?: number;\n /** 30d price change percentage */\n pricePercentChange30d?: number;\n /** 200d price change percentage */\n pricePercentChange200d?: number;\n /** 1y price change percentage */\n pricePercentChange1y?: number;\n /** Timestamp of last price update (added by client) */\n lastUpdated: number;\n};\n\n/**\n * Price data for NFT collections\n */\nexport type NFTAssetPrice = {\n /** Floor price */\n floorPrice?: number;\n /** Last sale price */\n lastSalePrice?: number;\n /** Collection trading volume */\n collectionVolume?: number;\n /** Average price */\n averagePrice?: number;\n /** Number of sales in 24h */\n sales24h?: number;\n} & BaseAssetPrice;\n\n/**\n * Union type representing all possible asset price types.\n * All types must be JSON-serializable.\n */\nexport type AssetPrice =\n | FungibleAssetPrice\n | NFTAssetPrice\n | (BaseAssetPrice & { [key: string]: Json });\n\n// ============================================================================\n// BALANCE TYPES (vary by asset type)\n// ============================================================================\n\n/**\n * Balance data for fungible tokens (native, ERC20, SPL).\n */\nexport type FungibleAssetBalance = {\n /** Raw balance amount as string (e.g., \"1000000000\" for 1000 USDC) */\n amount: string;\n};\n\n/**\n * Balance data for ERC721 NFTs.\n * Each tokenId has its own CAIP-19 asset ID, so always \"1\".\n */\nexport type ERC721AssetBalance = {\n /** Always \"1\" for ERC721 (non-fungible) */\n amount: '1';\n};\n\n/**\n * Balance data for ERC1155 multi-tokens.\n */\nexport type ERC1155AssetBalance = {\n /** Quantity owned of this specific tokenId */\n amount: string;\n};\n\n/**\n * Union type representing all possible asset balance types.\n * All types must be JSON-serializable.\n */\nexport type AssetBalance =\n | FungibleAssetBalance\n | ERC721AssetBalance\n | ERC1155AssetBalance\n | { amount: string; [key: string]: Json };\n\n// ============================================================================\n// DATA SOURCE TYPES\n// ============================================================================\n\n/**\n * Data type dimension - what kind of data\n */\nexport type DataType = 'balance' | 'metadata' | 'price';\n\n/**\n * Account with its supported chains (enabled chains ∩ account scope).\n * Pre-computed by the controller so data sources do not need to implement\n * account-scope logic; they iterate over supportedChains for each account.\n */\nexport type AccountWithSupportedChains = {\n account: InternalAccount;\n supportedChains: ChainId[];\n};\n\n/**\n * Request for data from data sources\n */\nexport type DataRequest = {\n /** Accounts with their supported chains (enabled ∩ account scope). Data sources use this instead of computing accountSupportsChain. */\n accountsWithSupportedChains: AccountWithSupportedChains[];\n /** CAIP-2 chain IDs (union of chains in this request) */\n chainIds: ChainId[];\n /** Filter by asset types */\n assetTypes?: AssetType[];\n /** Which data to fetch */\n dataTypes: DataType[];\n /** Specific CAIP-19 asset IDs */\n customAssets?: Caip19AssetId[];\n /** Force fresh fetch, bypass cache */\n forceUpdate?: boolean;\n /** Hint for polling interval (ms) - used by data sources that implement polling */\n updateInterval?: number;\n};\n\n/**\n * Response from data sources\n */\nexport type DataResponse = {\n /** Metadata for assets (shared across accounts) */\n assetsMetadata?: Record<Caip19AssetId, AssetMetadata>;\n /** Price data for assets (shared across accounts) */\n assetsPrice?: Record<Caip19AssetId, AssetPrice>;\n /** Balance data per account */\n assetsBalance?: Record<AccountId, Record<Caip19AssetId, AssetBalance>>;\n /** Errors encountered, keyed by chain ID */\n errors?: Record<ChainId, string>;\n /** Detected assets (assets that do not have metadata) */\n detectedAssets?: Record<AccountId, Caip19AssetId[]>;\n};\n\n// ============================================================================\n// DATA SOURCE <-> CONTROLLER (DIRECT CALLS, NO MESSENGER PER SOURCE)\n// ============================================================================\n\n/**\n * Callbacks for data sources to report to AssetsController.\n * Passed to data sources so they report by direct call instead of messenger.\n */\nexport type AssetsControllerReport = {\n onActiveChainsUpdate: (dataSourceId: string, activeChains: ChainId[]) => void;\n onAssetsUpdate: (response: DataResponse, sourceId: string) => Promise<void>;\n};\n\n/** Request passed from controller to data source when subscribing */\nexport type DataSourceSubscriptionRequest = {\n request: DataRequest;\n subscriptionId: string;\n isUpdate: boolean;\n};\n\n/**\n * Interface for balance data sources that the controller calls directly.\n * No messenger is required for controller <-> data source communication.\n */\nexport type BalanceDataSource = {\n getAssetsMiddleware: () => Middleware;\n subscribe: (request: DataSourceSubscriptionRequest) => Promise<void>;\n unsubscribe: (subscriptionId: string) => Promise<void>;\n getName: () => string;\n};\n\n/**\n * Interface for the price data source (subscribe/unsubscribe + middleware).\n * Controller calls these methods directly.\n */\nexport type PriceDataSourceInterface = {\n getAssetsMiddleware: () => Middleware;\n subscribe: (request: DataSourceSubscriptionRequest) => Promise<void>;\n unsubscribe: (subscriptionId: string) => Promise<void>;\n};\n\n/**\n * Middleware-only source (e.g. detection, token enrichment).\n * Controller calls getAssetsMiddleware() directly.\n */\nexport type MiddlewareDataSource = {\n getAssetsMiddleware: () => Middleware;\n};\n\n// ============================================================================\n// UNIFIED MIDDLEWARE TYPES\n// ============================================================================\n\n/**\n * Internal state structure for AssetsController following normalized design.\n *\n * Keys use CAIP identifiers:\n * - assetsMetadata keys: CAIP-19 asset IDs (e.g., \"eip155:1/erc20:0x...\")\n * - assetsBalance outer keys: Account IDs (InternalAccount.id UUIDs)\n * - assetsBalance inner keys: CAIP-19 asset IDs\n * - assetsPrice keys: CAIP-19 asset IDs\n * - customAssets outer keys: Account IDs (InternalAccount.id UUIDs)\n * - customAssets inner values: CAIP-19 asset IDs array\n * - assetPreferences keys: CAIP-19 asset IDs\n */\nexport type AssetsControllerStateInternal = {\n /** Shared metadata for all assets (stored once per asset) */\n assetsMetadata: Record<Caip19AssetId, AssetMetadata>;\n /** Per-account balance data */\n assetsBalance: Record<AccountId, Record<Caip19AssetId, AssetBalance>>;\n /** Price data for assets */\n assetsPrice: Record<Caip19AssetId, AssetPrice>;\n /** Custom assets added by users per account */\n customAssets: Record<AccountId, Caip19AssetId[]>;\n /** UI preferences per asset (e.g. hidden) - separate from metadata */\n assetPreferences: Record<Caip19AssetId, AssetPreferences>;\n};\n\n/**\n * Base context for all middleware operations.\n * Contains the common interface shared by fetch and subscribe.\n */\nexport type Context = {\n /** The data request */\n request: DataRequest;\n /** The response data (mutated by middlewares) */\n response: DataResponse;\n /** Get current assets state */\n getAssetsState: () => AssetsControllerStateInternal;\n};\n\n/**\n * Next function for middleware chain\n */\nexport type NextFunction = (context: Context) => Promise<Context>;\n\n/**\n * Middleware function - works for both fetch and subscribe operations.\n */\nexport type Middleware = (\n context: Context,\n next: NextFunction,\n) => Promise<Context>;\n\n/**\n * Wraps a middleware to only execute if specific dataTypes are requested.\n *\n * @param dataTypes - DataTypes that must be in the request for middleware to run\n * @param middleware - The middleware to conditionally execute\n * @returns A middleware that skips execution if none of the dataTypes are requested\n *\n * @example\n * ```typescript\n * // Only runs for metadata requests\n * const metadataMiddleware = forDataTypes(['metadata'], async (ctx, next) => {\n * const result = await next(ctx);\n * // Enrich metadata...\n * return result;\n * });\n *\n * // Runs for balance or price requests\n * const balanceOrPriceMiddleware = forDataTypes(['balance', 'price'], async (ctx, next) => {\n * const result = await next(ctx);\n * // Process balances or prices...\n * return result;\n * });\n * ```\n */\nexport function forDataTypes(\n dataTypes: DataType[],\n middleware: Middleware,\n): Middleware {\n return async (ctx, next) => {\n const requestedTypes = ctx.request.dataTypes;\n const shouldRun = dataTypes.some((dt) => requestedTypes.includes(dt));\n\n if (!shouldRun) {\n return next(ctx);\n }\n\n return middleware(ctx, next);\n };\n}\n\n/**\n * Context for fetch operations.\n * Extends base Context - no additional fields needed for fetch.\n */\nexport type FetchContext = Context;\n\n// Legacy aliases for backwards compatibility\nexport type FetchNextFunction = NextFunction;\nexport type FetchMiddleware = Middleware;\n\n/**\n * Subscription response returned when subscribing to asset updates.\n */\nexport type SubscriptionResponse = {\n /** Chains actively subscribed */\n chains: ChainId[];\n /** Account ID being watched */\n accountId: AccountId;\n /** Asset types being watched */\n assetTypes: AssetType[];\n /** Data types being kept fresh */\n dataTypes: DataType[];\n /** Cleanup function */\n unsubscribe: () => void;\n};\n\n// ============================================================================\n// COMBINED ASSET TYPE (for UI)\n// ============================================================================\n\n/**\n * Combined asset type matching state structure: balance, metadata, price\n */\nexport type Asset = {\n /** CAIP-19 asset ID */\n id: Caip19AssetId;\n /** CAIP-2 chain ID (extracted from id) */\n chainId: ChainId;\n /** Balance data */\n balance: AssetBalance;\n /** Metadata (symbol, name, decimals, etc.) */\n metadata: AssetMetadata;\n /** Price data */\n price: AssetPrice;\n /** Computed fiat value (balance × price) */\n fiatValue: number;\n};\n\n// ============================================================================\n// EVENT TYPES\n// ============================================================================\n\n/**\n * Event emitted when balances change\n */\nexport type BalanceChangeEvent = {\n accountId: AccountId;\n assetId: Caip19AssetId;\n previousAmount: string;\n newAmount: string;\n timestamp: number;\n};\n\n/**\n * Event emitted when prices change\n */\nexport type PriceChangeEvent = {\n assetIds: Caip19AssetId[];\n timestamp: number;\n};\n\n/**\n * Event emitted when metadata changes\n */\nexport type MetadataChangeEvent = {\n assetId: Caip19AssetId;\n changes: Partial<AssetMetadata>;\n};\n\n/**\n * Event emitted when assets without metadata are detected\n */\nexport type AssetsDetectedEvent = {\n accountId: AccountId;\n assetIds: Caip19AssetId[];\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/assets-controller",
3
- "version": "0.2.0",
3
+ "version": "1.0.0",
4
4
  "description": "Tracks assets balances/prices and handles token detection across all digital assets",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -51,7 +51,7 @@
51
51
  "@ethereumjs/util": "^9.1.0",
52
52
  "@ethersproject/abi": "^5.7.0",
53
53
  "@ethersproject/providers": "^5.7.0",
54
- "@metamask/account-tree-controller": "^4.0.0",
54
+ "@metamask/account-tree-controller": "^4.1.0",
55
55
  "@metamask/base-controller": "^9.0.0",
56
56
  "@metamask/controller-utils": "^11.18.0",
57
57
  "@metamask/core-backend": "^5.1.0",
@@ -1,215 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initDataSources = exports.initMessengers = void 0;
4
- const messenger_1 = require("@metamask/messenger");
5
- const AccountsApiDataSource_1 = require("./AccountsApiDataSource.cjs");
6
- const BackendWebsocketDataSource_1 = require("./BackendWebsocketDataSource.cjs");
7
- const PriceDataSource_1 = require("./PriceDataSource.cjs");
8
- const RpcDataSource_1 = require("./RpcDataSource.cjs");
9
- const SnapDataSource_1 = require("./SnapDataSource.cjs");
10
- const TokenDataSource_1 = require("./TokenDataSource.cjs");
11
- const middlewares_1 = require("../middlewares/index.cjs");
12
- // ============================================================================
13
- // MESSENGER INITIALIZATION
14
- // ============================================================================
15
- /**
16
- * Initialize all messengers for data sources.
17
- *
18
- * This function creates child messengers for each data source from the root
19
- * controller messenger, with proper action/event delegation.
20
- *
21
- * @example
22
- * ```typescript
23
- * import { initMessengers } from '@metamask/assets-controllers';
24
- *
25
- * const messengers = initMessengers({ messenger });
26
- * ```
27
- *
28
- * @param options - Configuration options
29
- * @returns Object containing all messengers, or null if disabled
30
- */
31
- function initMessengers(options) {
32
- const { messenger, isEnabled = () => true } = options;
33
- if (!isEnabled()) {
34
- return null;
35
- }
36
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
- const rootMessenger = messenger;
38
- // RPC Data Source messenger
39
- const rpcMessenger = new messenger_1.Messenger({
40
- namespace: 'RpcDataSource',
41
- parent: rootMessenger,
42
- });
43
- rootMessenger.delegate({
44
- actions: [
45
- 'NetworkController:getState',
46
- 'NetworkController:getNetworkClientById',
47
- 'AssetsController:activeChainsUpdate',
48
- 'AssetsController:assetsUpdate',
49
- 'AssetsController:getState',
50
- 'TokenListController:getState',
51
- 'NetworkEnablementController:getState',
52
- ],
53
- events: ['NetworkController:stateChange'],
54
- messenger: rpcMessenger,
55
- });
56
- // Backend Websocket Data Source messenger
57
- const backendWebsocketMessenger = new messenger_1.Messenger({
58
- namespace: 'BackendWebsocketDataSource',
59
- parent: rootMessenger,
60
- });
61
- rootMessenger.delegate({
62
- actions: [
63
- 'BackendWebSocketService:subscribe',
64
- 'BackendWebSocketService:unsubscribe',
65
- 'BackendWebSocketService:getState',
66
- 'BackendWebSocketService:getConnectionInfo',
67
- 'BackendWebSocketService:findSubscriptionsByChannelPrefix',
68
- 'AssetsController:activeChainsUpdate',
69
- 'AssetsController:assetsUpdate',
70
- ],
71
- events: [
72
- 'BackendWebSocketService:stateChange',
73
- 'BackendWebSocketService:connectionStateChanged',
74
- 'AccountsApiDataSource:activeChainsUpdated',
75
- ],
76
- messenger: backendWebsocketMessenger,
77
- });
78
- // Accounts API Data Source messenger
79
- // Note: AccountsApiDataSource uses ApiPlatformClient directly, so no BackendApiClient actions needed
80
- const accountsApiMessenger = new messenger_1.Messenger({
81
- namespace: 'AccountsApiDataSource',
82
- parent: rootMessenger,
83
- });
84
- rootMessenger.delegate({
85
- actions: [
86
- 'AssetsController:activeChainsUpdate',
87
- 'AssetsController:assetsUpdate',
88
- ],
89
- messenger: accountsApiMessenger,
90
- });
91
- // Snap Data Source messenger
92
- const snapMessenger = new messenger_1.Messenger({
93
- namespace: 'SnapDataSource',
94
- parent: rootMessenger,
95
- });
96
- rootMessenger.delegate({
97
- actions: [
98
- 'AssetsController:activeChainsUpdate',
99
- 'AssetsController:assetsUpdate',
100
- // SnapController actions for direct snap communication
101
- 'SnapController:getRunnableSnaps',
102
- 'SnapController:handleRequest',
103
- // PermissionController action for dynamic snap discovery
104
- 'PermissionController:getPermissions',
105
- ],
106
- events: [
107
- // Snap keyring balance updates - snaps emit this when balances change
108
- 'AccountsController:accountBalancesUpdated',
109
- // Permission changes for runtime snap discovery
110
- 'PermissionController:stateChange',
111
- ],
112
- messenger: snapMessenger,
113
- });
114
- // Token Data Source messenger
115
- // Note: TokenDataSource uses ApiPlatformClient directly, so no BackendApiClient actions needed
116
- const tokenMessenger = new messenger_1.Messenger({
117
- namespace: 'TokenDataSource',
118
- parent: rootMessenger,
119
- });
120
- // Price Data Source messenger
121
- // Note: PriceDataSource uses ApiPlatformClient directly, so no BackendApiClient actions needed
122
- const priceMessenger = new messenger_1.Messenger({
123
- namespace: 'PriceDataSource',
124
- parent: rootMessenger,
125
- });
126
- rootMessenger.delegate({
127
- actions: ['AssetsController:getState', 'AssetsController:assetsUpdate'],
128
- messenger: priceMessenger,
129
- });
130
- // Detection Middleware messenger
131
- const detectionMessenger = new messenger_1.Messenger({
132
- namespace: 'DetectionMiddleware',
133
- parent: rootMessenger,
134
- });
135
- return {
136
- rpcMessenger: rpcMessenger,
137
- backendWebsocketMessenger: backendWebsocketMessenger,
138
- accountsApiMessenger: accountsApiMessenger,
139
- snapMessenger: snapMessenger,
140
- tokenMessenger: tokenMessenger,
141
- priceMessenger: priceMessenger,
142
- detectionMessenger: detectionMessenger,
143
- };
144
- }
145
- exports.initMessengers = initMessengers;
146
- // ============================================================================
147
- // DATA SOURCE INITIALIZATION
148
- // ============================================================================
149
- /**
150
- * Initialize all data sources and middlewares.
151
- *
152
- * This function creates and initializes all data sources, registering their
153
- * action handlers with the messenger.
154
- *
155
- * @example
156
- * ```typescript
157
- * import { initMessengers, initDataSources } from '@metamask/assets-controllers';
158
- *
159
- * // Initialize messengers first
160
- * const messengers = initMessengers({ controllerMessenger });
161
- *
162
- * // Then initialize data sources
163
- * const dataSources = initDataSources({
164
- * messengers,
165
- * queryApiClient,
166
- * });
167
- * ```
168
- *
169
- * @param options - Configuration options
170
- * @returns Object containing all data source instances, or null if disabled
171
- */
172
- function initDataSources(options) {
173
- const { messengers, queryApiClient, rpcDataSourceConfig, isEnabled = () => true, } = options;
174
- if (!isEnabled()) {
175
- return null;
176
- }
177
- // Initialize primary data sources (provide balance data)
178
- const rpcDataSource = new RpcDataSource_1.RpcDataSource({
179
- messenger: messengers.rpcMessenger,
180
- ...rpcDataSourceConfig,
181
- });
182
- const backendWebsocketDataSource = new BackendWebsocketDataSource_1.BackendWebsocketDataSource({
183
- messenger: messengers.backendWebsocketMessenger,
184
- });
185
- const accountsApiDataSource = new AccountsApiDataSource_1.AccountsApiDataSource({
186
- messenger: messengers.accountsApiMessenger,
187
- queryApiClient,
188
- });
189
- const snapDataSource = new SnapDataSource_1.SnapDataSource({
190
- messenger: messengers.snapMessenger,
191
- });
192
- // Initialize middleware data sources (enrich responses)
193
- const tokenDataSource = new TokenDataSource_1.TokenDataSource({
194
- messenger: messengers.tokenMessenger,
195
- queryApiClient,
196
- });
197
- const priceDataSource = new PriceDataSource_1.PriceDataSource({
198
- messenger: messengers.priceMessenger,
199
- queryApiClient,
200
- });
201
- const detectionMiddleware = new middlewares_1.DetectionMiddleware({
202
- messenger: messengers.detectionMessenger,
203
- });
204
- return {
205
- rpcDataSource,
206
- backendWebsocketDataSource,
207
- accountsApiDataSource,
208
- snapDataSource,
209
- tokenDataSource,
210
- priceDataSource,
211
- detectionMiddleware,
212
- };
213
- }
214
- exports.initDataSources = initDataSources;
215
- //# sourceMappingURL=initDataSources.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"initDataSources.cjs","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C,cAAc;KACf,CAAC,CAAC;IAEH,MAAM,mBAAmB,GAAG,IAAI,iCAAmB,CAAC;QAClD,SAAS,EAAE,UAAU,CAAC,kBAAkB;KACzC,CAAC,CAAC;IAEH,OAAO;QACL,aAAa;QACb,0BAA0B;QAC1B,qBAAqB;QACrB,cAAc;QACd,eAAe;QACf,eAAe;QACf,mBAAmB;KACpB,CAAC;AACJ,CAAC;AAzDD,0CAyDC","sourcesContent":["import type { ApiPlatformClient } from '@metamask/core-backend';\nimport { Messenger } from '@metamask/messenger';\nimport type { ActionConstraint, EventConstraint } from '@metamask/messenger';\n\nimport { AccountsApiDataSource } from './AccountsApiDataSource';\nimport type {\n AccountsApiDataSourceActions,\n AccountsApiDataSourceAllowedActions,\n AccountsApiDataSourceEvents,\n AccountsApiDataSourceMessenger,\n} from './AccountsApiDataSource';\nimport { BackendWebsocketDataSource } from './BackendWebsocketDataSource';\nimport type {\n BackendWebsocketDataSourceActions,\n BackendWebsocketDataSourceAllowedActions,\n BackendWebsocketDataSourceAllowedEvents,\n BackendWebsocketDataSourceEvents,\n BackendWebsocketDataSourceMessenger,\n} from './BackendWebsocketDataSource';\nimport { PriceDataSource } from './PriceDataSource';\nimport type {\n PriceDataSourceActions,\n PriceDataSourceAllowedActions,\n PriceDataSourceEvents,\n PriceDataSourceMessenger,\n} from './PriceDataSource';\nimport { RpcDataSource } from './RpcDataSource';\nimport type {\n RpcDataSourceActions,\n RpcDataSourceAllowedActions,\n RpcDataSourceAllowedEvents,\n RpcDataSourceEvents,\n RpcDataSourceMessenger,\n} from './RpcDataSource';\nimport { SnapDataSource } from './SnapDataSource';\nimport type {\n SnapDataSourceActions,\n SnapDataSourceEvents,\n SnapDataSourceMessenger,\n} from './SnapDataSource';\nimport { TokenDataSource } from './TokenDataSource';\nimport type {\n TokenDataSourceActions,\n TokenDataSourceMessenger,\n} from './TokenDataSource';\nimport type {\n DetectionMiddlewareActions,\n DetectionMiddlewareMessenger,\n} from '../middlewares';\nimport { DetectionMiddleware } from '../middlewares';\n\n// ============================================================================\n// ACTION & EVENT TYPES\n// ============================================================================\n\n/**\n * All actions from data sources.\n */\nexport type DataSourceActions =\n | RpcDataSourceActions\n | BackendWebsocketDataSourceActions\n | AccountsApiDataSourceActions\n | SnapDataSourceActions\n | TokenDataSourceActions\n | PriceDataSourceActions\n | DetectionMiddlewareActions;\n\n/**\n * All events from data sources.\n */\nexport type DataSourceEvents =\n | RpcDataSourceEvents\n | BackendWebsocketDataSourceEvents\n | AccountsApiDataSourceEvents\n | SnapDataSourceEvents\n | PriceDataSourceEvents;\n\n/**\n * All external actions that data sources need.\n * Note: TokenDataSource, AccountsApiDataSource, and PriceDataSource now use ApiPlatformClient\n * directly, so they don't need BackendApiClient actions delegated.\n */\nexport type DataSourceAllowedActions =\n | RpcDataSourceAllowedActions\n | BackendWebsocketDataSourceAllowedActions\n | AccountsApiDataSourceAllowedActions\n | PriceDataSourceAllowedActions;\n\n/**\n * All external events that data sources need.\n */\nexport type DataSourceAllowedEvents =\n | RpcDataSourceAllowedEvents\n | BackendWebsocketDataSourceAllowedEvents;\n\n/**\n * Root messenger type for all data sources.\n */\nexport type RootMessenger<\n AllowedActions extends ActionConstraint,\n AllowedEvents extends EventConstraint,\n> = Messenger<string, AllowedActions, AllowedEvents>;\n\n// ============================================================================\n// MESSENGER TYPES\n// ============================================================================\n\n/**\n * All messengers for data sources.\n */\nexport type DataSourceMessengers = {\n rpcMessenger: RpcDataSourceMessenger;\n backendWebsocketMessenger: BackendWebsocketDataSourceMessenger;\n accountsApiMessenger: AccountsApiDataSourceMessenger;\n snapMessenger: SnapDataSourceMessenger;\n tokenMessenger: TokenDataSourceMessenger;\n priceMessenger: PriceDataSourceMessenger;\n detectionMessenger: DetectionMiddlewareMessenger;\n};\n\n/**\n * Options for initializing messengers.\n */\nexport type InitMessengersOptions<\n AllowedActions extends ActionConstraint,\n AllowedEvents extends EventConstraint,\n> = {\n /** The root controller messenger */\n messenger: RootMessenger<AllowedActions, AllowedEvents>;\n /** Function to determine if initialization should proceed. Defaults to true. */\n isEnabled?: () => boolean;\n};\n\n// ============================================================================\n// CONTROLLER TYPES\n// ============================================================================\n\n/**\n * All data source instances.\n */\nexport type DataSources = {\n rpcDataSource: RpcDataSource;\n backendWebsocketDataSource: BackendWebsocketDataSource;\n accountsApiDataSource: AccountsApiDataSource;\n snapDataSource: SnapDataSource;\n tokenDataSource: TokenDataSource;\n priceDataSource: PriceDataSource;\n detectionMiddleware: DetectionMiddleware;\n};\n\n/**\n * Configuration options for RpcDataSource.\n */\nexport type RpcDataSourceConfig = {\n /** Balance polling interval in ms (default: 30s) */\n balanceInterval?: number;\n /** Token detection polling interval in ms (default: 180s / 3 min) */\n detectionInterval?: number;\n /** Whether token detection is enabled (default: false) */\n tokenDetectionEnabled?: boolean;\n /** Request timeout in ms (default: 10s) */\n timeout?: number;\n};\n\n/**\n * Options for initializing data sources.\n */\nexport type InitDataSourcesOptions = {\n /** Messengers for each data source */\n messengers: DataSourceMessengers;\n\n /** ApiPlatformClient for cached API calls */\n queryApiClient: ApiPlatformClient;\n\n /** Optional configuration for RpcDataSource */\n rpcDataSourceConfig?: RpcDataSourceConfig;\n\n /** Function to determine if initialization should proceed. Defaults to true. */\n isEnabled?: () => boolean;\n};\n\n// ============================================================================\n// MESSENGER INITIALIZATION\n// ============================================================================\n\n/**\n * Initialize all messengers for data sources.\n *\n * This function creates child messengers for each data source from the root\n * controller messenger, with proper action/event delegation.\n *\n * @example\n * ```typescript\n * import { initMessengers } from '@metamask/assets-controllers';\n *\n * const messengers = initMessengers({ messenger });\n * ```\n *\n * @param options - Configuration options\n * @returns Object containing all messengers, or null if disabled\n */\nexport function initMessengers<\n AllowedActions extends ActionConstraint,\n AllowedEvents extends EventConstraint,\n>(\n options: InitMessengersOptions<AllowedActions, AllowedEvents>,\n): DataSourceMessengers | null {\n const { messenger, isEnabled = (): boolean => true } = options;\n\n if (!isEnabled()) {\n return null;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const rootMessenger = messenger as any;\n\n // RPC Data Source messenger\n const rpcMessenger = new Messenger({\n namespace: 'RpcDataSource',\n parent: rootMessenger,\n });\n rootMessenger.delegate({\n actions: [\n 'NetworkController:getState',\n 'NetworkController:getNetworkClientById',\n 'AssetsController:activeChainsUpdate',\n 'AssetsController:assetsUpdate',\n 'AssetsController:getState',\n 'TokenListController:getState',\n 'NetworkEnablementController:getState',\n ],\n events: ['NetworkController:stateChange'],\n messenger: rpcMessenger,\n });\n\n // Backend Websocket Data Source messenger\n const backendWebsocketMessenger = new Messenger({\n namespace: 'BackendWebsocketDataSource',\n parent: rootMessenger,\n });\n rootMessenger.delegate({\n actions: [\n 'BackendWebSocketService:subscribe',\n 'BackendWebSocketService:unsubscribe',\n 'BackendWebSocketService:getState',\n 'BackendWebSocketService:getConnectionInfo',\n 'BackendWebSocketService:findSubscriptionsByChannelPrefix',\n 'AssetsController:activeChainsUpdate',\n 'AssetsController:assetsUpdate',\n ],\n events: [\n 'BackendWebSocketService:stateChange',\n 'BackendWebSocketService:connectionStateChanged',\n 'AccountsApiDataSource:activeChainsUpdated',\n ],\n messenger: backendWebsocketMessenger,\n });\n\n // Accounts API Data Source messenger\n // Note: AccountsApiDataSource uses ApiPlatformClient directly, so no BackendApiClient actions needed\n const accountsApiMessenger = new Messenger({\n namespace: 'AccountsApiDataSource',\n parent: rootMessenger,\n });\n rootMessenger.delegate({\n actions: [\n 'AssetsController:activeChainsUpdate',\n 'AssetsController:assetsUpdate',\n ],\n messenger: accountsApiMessenger,\n });\n\n // Snap Data Source messenger\n const snapMessenger = new Messenger({\n namespace: 'SnapDataSource',\n parent: rootMessenger,\n });\n rootMessenger.delegate({\n actions: [\n 'AssetsController:activeChainsUpdate',\n 'AssetsController:assetsUpdate',\n // SnapController actions for direct snap communication\n 'SnapController:getRunnableSnaps',\n 'SnapController:handleRequest',\n // PermissionController action for dynamic snap discovery\n 'PermissionController:getPermissions',\n ],\n events: [\n // Snap keyring balance updates - snaps emit this when balances change\n 'AccountsController:accountBalancesUpdated',\n // Permission changes for runtime snap discovery\n 'PermissionController:stateChange',\n ],\n messenger: snapMessenger,\n });\n\n // Token Data Source messenger\n // Note: TokenDataSource uses ApiPlatformClient directly, so no BackendApiClient actions needed\n const tokenMessenger = new Messenger({\n namespace: 'TokenDataSource',\n parent: rootMessenger,\n });\n\n // Price Data Source messenger\n // Note: PriceDataSource uses ApiPlatformClient directly, so no BackendApiClient actions needed\n const priceMessenger = new Messenger({\n namespace: 'PriceDataSource',\n parent: rootMessenger,\n });\n rootMessenger.delegate({\n actions: ['AssetsController:getState', 'AssetsController:assetsUpdate'],\n messenger: priceMessenger,\n });\n\n // Detection Middleware messenger\n const detectionMessenger = new Messenger({\n namespace: 'DetectionMiddleware',\n parent: rootMessenger,\n });\n\n return {\n rpcMessenger: rpcMessenger as RpcDataSourceMessenger,\n backendWebsocketMessenger:\n backendWebsocketMessenger as BackendWebsocketDataSourceMessenger,\n accountsApiMessenger:\n accountsApiMessenger as AccountsApiDataSourceMessenger,\n snapMessenger: snapMessenger as SnapDataSourceMessenger,\n tokenMessenger: tokenMessenger as TokenDataSourceMessenger,\n priceMessenger: priceMessenger as PriceDataSourceMessenger,\n detectionMessenger: detectionMessenger as DetectionMiddlewareMessenger,\n };\n}\n\n// ============================================================================\n// DATA SOURCE INITIALIZATION\n// ============================================================================\n\n/**\n * Initialize all data sources and middlewares.\n *\n * This function creates and initializes all data sources, registering their\n * action handlers with the messenger.\n *\n * @example\n * ```typescript\n * import { initMessengers, initDataSources } from '@metamask/assets-controllers';\n *\n * // Initialize messengers first\n * const messengers = initMessengers({ controllerMessenger });\n *\n * // Then initialize data sources\n * const dataSources = initDataSources({\n * messengers,\n * queryApiClient,\n * });\n * ```\n *\n * @param options - Configuration options\n * @returns Object containing all data source instances, or null if disabled\n */\nexport function initDataSources(\n options: InitDataSourcesOptions,\n): DataSources | null {\n const {\n messengers,\n queryApiClient,\n rpcDataSourceConfig,\n isEnabled = (): boolean => true,\n } = options;\n\n if (!isEnabled()) {\n return null;\n }\n\n // Initialize primary data sources (provide balance data)\n const rpcDataSource = new RpcDataSource({\n messenger: messengers.rpcMessenger,\n ...rpcDataSourceConfig,\n });\n\n const backendWebsocketDataSource = new BackendWebsocketDataSource({\n messenger: messengers.backendWebsocketMessenger,\n });\n\n const accountsApiDataSource = new AccountsApiDataSource({\n messenger: messengers.accountsApiMessenger,\n queryApiClient,\n });\n\n const snapDataSource = new SnapDataSource({\n messenger: messengers.snapMessenger,\n });\n\n // Initialize middleware data sources (enrich responses)\n const tokenDataSource = new TokenDataSource({\n messenger: messengers.tokenMessenger,\n queryApiClient,\n });\n\n const priceDataSource = new PriceDataSource({\n messenger: messengers.priceMessenger,\n queryApiClient,\n });\n\n const detectionMiddleware = new DetectionMiddleware({\n messenger: messengers.detectionMessenger,\n });\n\n return {\n rpcDataSource,\n backendWebsocketDataSource,\n accountsApiDataSource,\n snapDataSource,\n tokenDataSource,\n priceDataSource,\n detectionMiddleware,\n };\n}\n"]}
@@ -1,140 +0,0 @@
1
- import type { ApiPlatformClient } from "@metamask/core-backend";
2
- import { Messenger } from "@metamask/messenger";
3
- import type { ActionConstraint, EventConstraint } from "@metamask/messenger";
4
- import { AccountsApiDataSource } from "./AccountsApiDataSource.cjs";
5
- import type { AccountsApiDataSourceActions, AccountsApiDataSourceAllowedActions, AccountsApiDataSourceEvents, AccountsApiDataSourceMessenger } from "./AccountsApiDataSource.cjs";
6
- import { BackendWebsocketDataSource } from "./BackendWebsocketDataSource.cjs";
7
- import type { BackendWebsocketDataSourceActions, BackendWebsocketDataSourceAllowedActions, BackendWebsocketDataSourceAllowedEvents, BackendWebsocketDataSourceEvents, BackendWebsocketDataSourceMessenger } from "./BackendWebsocketDataSource.cjs";
8
- import { PriceDataSource } from "./PriceDataSource.cjs";
9
- import type { PriceDataSourceActions, PriceDataSourceAllowedActions, PriceDataSourceEvents, PriceDataSourceMessenger } from "./PriceDataSource.cjs";
10
- import { RpcDataSource } from "./RpcDataSource.cjs";
11
- import type { RpcDataSourceActions, RpcDataSourceAllowedActions, RpcDataSourceAllowedEvents, RpcDataSourceEvents, RpcDataSourceMessenger } from "./RpcDataSource.cjs";
12
- import { SnapDataSource } from "./SnapDataSource.cjs";
13
- import type { SnapDataSourceActions, SnapDataSourceEvents, SnapDataSourceMessenger } from "./SnapDataSource.cjs";
14
- import { TokenDataSource } from "./TokenDataSource.cjs";
15
- import type { TokenDataSourceActions, TokenDataSourceMessenger } from "./TokenDataSource.cjs";
16
- import type { DetectionMiddlewareActions, DetectionMiddlewareMessenger } from "../middlewares/index.cjs";
17
- import { DetectionMiddleware } from "../middlewares/index.cjs";
18
- /**
19
- * All actions from data sources.
20
- */
21
- export type DataSourceActions = RpcDataSourceActions | BackendWebsocketDataSourceActions | AccountsApiDataSourceActions | SnapDataSourceActions | TokenDataSourceActions | PriceDataSourceActions | DetectionMiddlewareActions;
22
- /**
23
- * All events from data sources.
24
- */
25
- export type DataSourceEvents = RpcDataSourceEvents | BackendWebsocketDataSourceEvents | AccountsApiDataSourceEvents | SnapDataSourceEvents | PriceDataSourceEvents;
26
- /**
27
- * All external actions that data sources need.
28
- * Note: TokenDataSource, AccountsApiDataSource, and PriceDataSource now use ApiPlatformClient
29
- * directly, so they don't need BackendApiClient actions delegated.
30
- */
31
- export type DataSourceAllowedActions = RpcDataSourceAllowedActions | BackendWebsocketDataSourceAllowedActions | AccountsApiDataSourceAllowedActions | PriceDataSourceAllowedActions;
32
- /**
33
- * All external events that data sources need.
34
- */
35
- export type DataSourceAllowedEvents = RpcDataSourceAllowedEvents | BackendWebsocketDataSourceAllowedEvents;
36
- /**
37
- * Root messenger type for all data sources.
38
- */
39
- export type RootMessenger<AllowedActions extends ActionConstraint, AllowedEvents extends EventConstraint> = Messenger<string, AllowedActions, AllowedEvents>;
40
- /**
41
- * All messengers for data sources.
42
- */
43
- export type DataSourceMessengers = {
44
- rpcMessenger: RpcDataSourceMessenger;
45
- backendWebsocketMessenger: BackendWebsocketDataSourceMessenger;
46
- accountsApiMessenger: AccountsApiDataSourceMessenger;
47
- snapMessenger: SnapDataSourceMessenger;
48
- tokenMessenger: TokenDataSourceMessenger;
49
- priceMessenger: PriceDataSourceMessenger;
50
- detectionMessenger: DetectionMiddlewareMessenger;
51
- };
52
- /**
53
- * Options for initializing messengers.
54
- */
55
- export type InitMessengersOptions<AllowedActions extends ActionConstraint, AllowedEvents extends EventConstraint> = {
56
- /** The root controller messenger */
57
- messenger: RootMessenger<AllowedActions, AllowedEvents>;
58
- /** Function to determine if initialization should proceed. Defaults to true. */
59
- isEnabled?: () => boolean;
60
- };
61
- /**
62
- * All data source instances.
63
- */
64
- export type DataSources = {
65
- rpcDataSource: RpcDataSource;
66
- backendWebsocketDataSource: BackendWebsocketDataSource;
67
- accountsApiDataSource: AccountsApiDataSource;
68
- snapDataSource: SnapDataSource;
69
- tokenDataSource: TokenDataSource;
70
- priceDataSource: PriceDataSource;
71
- detectionMiddleware: DetectionMiddleware;
72
- };
73
- /**
74
- * Configuration options for RpcDataSource.
75
- */
76
- export type RpcDataSourceConfig = {
77
- /** Balance polling interval in ms (default: 30s) */
78
- balanceInterval?: number;
79
- /** Token detection polling interval in ms (default: 180s / 3 min) */
80
- detectionInterval?: number;
81
- /** Whether token detection is enabled (default: false) */
82
- tokenDetectionEnabled?: boolean;
83
- /** Request timeout in ms (default: 10s) */
84
- timeout?: number;
85
- };
86
- /**
87
- * Options for initializing data sources.
88
- */
89
- export type InitDataSourcesOptions = {
90
- /** Messengers for each data source */
91
- messengers: DataSourceMessengers;
92
- /** ApiPlatformClient for cached API calls */
93
- queryApiClient: ApiPlatformClient;
94
- /** Optional configuration for RpcDataSource */
95
- rpcDataSourceConfig?: RpcDataSourceConfig;
96
- /** Function to determine if initialization should proceed. Defaults to true. */
97
- isEnabled?: () => boolean;
98
- };
99
- /**
100
- * Initialize all messengers for data sources.
101
- *
102
- * This function creates child messengers for each data source from the root
103
- * controller messenger, with proper action/event delegation.
104
- *
105
- * @example
106
- * ```typescript
107
- * import { initMessengers } from '@metamask/assets-controllers';
108
- *
109
- * const messengers = initMessengers({ messenger });
110
- * ```
111
- *
112
- * @param options - Configuration options
113
- * @returns Object containing all messengers, or null if disabled
114
- */
115
- export declare function initMessengers<AllowedActions extends ActionConstraint, AllowedEvents extends EventConstraint>(options: InitMessengersOptions<AllowedActions, AllowedEvents>): DataSourceMessengers | null;
116
- /**
117
- * Initialize all data sources and middlewares.
118
- *
119
- * This function creates and initializes all data sources, registering their
120
- * action handlers with the messenger.
121
- *
122
- * @example
123
- * ```typescript
124
- * import { initMessengers, initDataSources } from '@metamask/assets-controllers';
125
- *
126
- * // Initialize messengers first
127
- * const messengers = initMessengers({ controllerMessenger });
128
- *
129
- * // Then initialize data sources
130
- * const dataSources = initDataSources({
131
- * messengers,
132
- * queryApiClient,
133
- * });
134
- * ```
135
- *
136
- * @param options - Configuration options
137
- * @returns Object containing all data source instances, or null if disabled
138
- */
139
- export declare function initDataSources(options: InitDataSourcesOptions): DataSources | null;
140
- //# sourceMappingURL=initDataSources.d.cts.map