@metamask/assets-controller 2.0.2 → 2.1.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 (108) hide show
  1. package/CHANGELOG.md +28 -1
  2. package/dist/AssetsController-method-action-types.cjs.map +1 -1
  3. package/dist/AssetsController-method-action-types.d.cts +5 -0
  4. package/dist/AssetsController-method-action-types.d.cts.map +1 -1
  5. package/dist/AssetsController-method-action-types.d.mts +5 -0
  6. package/dist/AssetsController-method-action-types.d.mts.map +1 -1
  7. package/dist/AssetsController-method-action-types.mjs.map +1 -1
  8. package/dist/AssetsController.cjs +259 -88
  9. package/dist/AssetsController.cjs.map +1 -1
  10. package/dist/AssetsController.d.cts +44 -17
  11. package/dist/AssetsController.d.cts.map +1 -1
  12. package/dist/AssetsController.d.mts +44 -17
  13. package/dist/AssetsController.d.mts.map +1 -1
  14. package/dist/AssetsController.mjs +259 -88
  15. package/dist/AssetsController.mjs.map +1 -1
  16. package/dist/data-sources/AbstractDataSource.cjs.map +1 -1
  17. package/dist/data-sources/AbstractDataSource.d.cts +3 -3
  18. package/dist/data-sources/AbstractDataSource.d.cts.map +1 -1
  19. package/dist/data-sources/AbstractDataSource.d.mts +3 -3
  20. package/dist/data-sources/AbstractDataSource.d.mts.map +1 -1
  21. package/dist/data-sources/AbstractDataSource.mjs.map +1 -1
  22. package/dist/data-sources/AccountsApiDataSource.cjs +1 -0
  23. package/dist/data-sources/AccountsApiDataSource.cjs.map +1 -1
  24. package/dist/data-sources/AccountsApiDataSource.d.cts.map +1 -1
  25. package/dist/data-sources/AccountsApiDataSource.d.mts.map +1 -1
  26. package/dist/data-sources/AccountsApiDataSource.mjs +1 -0
  27. package/dist/data-sources/AccountsApiDataSource.mjs.map +1 -1
  28. package/dist/data-sources/BackendWebsocketDataSource.cjs +18 -6
  29. package/dist/data-sources/BackendWebsocketDataSource.cjs.map +1 -1
  30. package/dist/data-sources/BackendWebsocketDataSource.d.cts +2 -2
  31. package/dist/data-sources/BackendWebsocketDataSource.d.cts.map +1 -1
  32. package/dist/data-sources/BackendWebsocketDataSource.d.mts +2 -2
  33. package/dist/data-sources/BackendWebsocketDataSource.d.mts.map +1 -1
  34. package/dist/data-sources/BackendWebsocketDataSource.mjs +15 -6
  35. package/dist/data-sources/BackendWebsocketDataSource.mjs.map +1 -1
  36. package/dist/data-sources/PriceDataSource.cjs +20 -14
  37. package/dist/data-sources/PriceDataSource.cjs.map +1 -1
  38. package/dist/data-sources/PriceDataSource.d.cts +2 -2
  39. package/dist/data-sources/PriceDataSource.d.cts.map +1 -1
  40. package/dist/data-sources/PriceDataSource.d.mts +2 -2
  41. package/dist/data-sources/PriceDataSource.d.mts.map +1 -1
  42. package/dist/data-sources/PriceDataSource.mjs +20 -14
  43. package/dist/data-sources/PriceDataSource.mjs.map +1 -1
  44. package/dist/data-sources/RpcDataSource.cjs +23 -4
  45. package/dist/data-sources/RpcDataSource.cjs.map +1 -1
  46. package/dist/data-sources/RpcDataSource.d.cts.map +1 -1
  47. package/dist/data-sources/RpcDataSource.d.mts.map +1 -1
  48. package/dist/data-sources/RpcDataSource.mjs +23 -4
  49. package/dist/data-sources/RpcDataSource.mjs.map +1 -1
  50. package/dist/data-sources/SnapDataSource.cjs +3 -2
  51. package/dist/data-sources/SnapDataSource.cjs.map +1 -1
  52. package/dist/data-sources/SnapDataSource.d.cts.map +1 -1
  53. package/dist/data-sources/SnapDataSource.d.mts.map +1 -1
  54. package/dist/data-sources/SnapDataSource.mjs +3 -2
  55. package/dist/data-sources/SnapDataSource.mjs.map +1 -1
  56. package/dist/data-sources/StakedBalanceDataSource.cjs +41 -3
  57. package/dist/data-sources/StakedBalanceDataSource.cjs.map +1 -1
  58. package/dist/data-sources/StakedBalanceDataSource.d.cts.map +1 -1
  59. package/dist/data-sources/StakedBalanceDataSource.d.mts.map +1 -1
  60. package/dist/data-sources/StakedBalanceDataSource.mjs +41 -3
  61. package/dist/data-sources/StakedBalanceDataSource.mjs.map +1 -1
  62. package/dist/data-sources/TokenDataSource.cjs +1 -0
  63. package/dist/data-sources/TokenDataSource.cjs.map +1 -1
  64. package/dist/data-sources/TokenDataSource.d.cts.map +1 -1
  65. package/dist/data-sources/TokenDataSource.d.mts.map +1 -1
  66. package/dist/data-sources/TokenDataSource.mjs +1 -0
  67. package/dist/data-sources/TokenDataSource.mjs.map +1 -1
  68. package/dist/data-sources/evm-rpc-services/services/TokenDetector.cjs.map +1 -1
  69. package/dist/data-sources/evm-rpc-services/services/TokenDetector.d.cts.map +1 -1
  70. package/dist/data-sources/evm-rpc-services/services/TokenDetector.d.mts.map +1 -1
  71. package/dist/data-sources/evm-rpc-services/services/TokenDetector.mjs.map +1 -1
  72. package/dist/index.cjs.map +1 -1
  73. package/dist/index.d.cts +2 -1
  74. package/dist/index.d.cts.map +1 -1
  75. package/dist/index.d.mts +2 -1
  76. package/dist/index.d.mts.map +1 -1
  77. package/dist/index.mjs.map +1 -1
  78. package/dist/middlewares/DetectionMiddleware.cjs +44 -27
  79. package/dist/middlewares/DetectionMiddleware.cjs.map +1 -1
  80. package/dist/middlewares/DetectionMiddleware.d.cts +15 -9
  81. package/dist/middlewares/DetectionMiddleware.d.cts.map +1 -1
  82. package/dist/middlewares/DetectionMiddleware.d.mts +15 -9
  83. package/dist/middlewares/DetectionMiddleware.d.mts.map +1 -1
  84. package/dist/middlewares/DetectionMiddleware.mjs +44 -27
  85. package/dist/middlewares/DetectionMiddleware.mjs.map +1 -1
  86. package/dist/middlewares/ParallelMiddleware.cjs +216 -0
  87. package/dist/middlewares/ParallelMiddleware.cjs.map +1 -0
  88. package/dist/middlewares/ParallelMiddleware.d.cts +45 -0
  89. package/dist/middlewares/ParallelMiddleware.d.cts.map +1 -0
  90. package/dist/middlewares/ParallelMiddleware.d.mts +45 -0
  91. package/dist/middlewares/ParallelMiddleware.d.mts.map +1 -0
  92. package/dist/middlewares/ParallelMiddleware.mjs +214 -0
  93. package/dist/middlewares/ParallelMiddleware.mjs.map +1 -0
  94. package/dist/middlewares/index.cjs +5 -1
  95. package/dist/middlewares/index.cjs.map +1 -1
  96. package/dist/middlewares/index.d.cts +2 -0
  97. package/dist/middlewares/index.d.cts.map +1 -1
  98. package/dist/middlewares/index.d.mts +2 -0
  99. package/dist/middlewares/index.d.mts.map +1 -1
  100. package/dist/middlewares/index.mjs +1 -0
  101. package/dist/middlewares/index.mjs.map +1 -1
  102. package/dist/types.cjs.map +1 -1
  103. package/dist/types.d.cts +16 -0
  104. package/dist/types.d.cts.map +1 -1
  105. package/dist/types.d.mts +16 -0
  106. package/dist/types.d.mts.map +1 -1
  107. package/dist/types.mjs.map +1 -1
  108. package/package.json +6 -5
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AACzB,2DAG4B;AAF1B,oHAAA,gBAAgB,OAAA;AAChB,mIAAA,+BAA+B,OAAA;AAkFjC,sCAAsC;AACtC,yDAAoD;AAA3C,kHAAA,kBAAkB,OAAA;AAI3B,6BAA6B;AAC7B,yDAAuD;AAA9C,qHAAA,qBAAqB,OAAA;AAS9B,kCAAkC;AAClC,yDAGwB;AAFtB,0HAAA,0BAA0B,OAAA;AAC1B,gIAAA,gCAAgC,OAAA;AAUlC,qBAAqB;AACrB,yDAAoE;AAA3D,6GAAA,aAAa,OAAA;AAAE,mHAAA,mBAAmB,OAAA;AAW3C,gFAAgF;AAChF,yDASwB;AARtB,8GAAA,cAAc,OAAA;AACd,oHAAA,oBAAoB,OAAA;AACpB,qHAAA,qBAAqB,OAAA;AACrB,YAAY;AACZ,kHAAA,kBAAkB,OAAA;AAClB,oBAAoB;AACpB,iHAAA,iBAAiB,OAAA;AACjB,uHAAA,uBAAuB,OAAA;AAUzB,0BAA0B;AAC1B,yDAAkE;AAAzD,+GAAA,eAAe,OAAA;AAAE,+GAAA,eAAe,OAAA;AASzC,cAAc;AACd,uDAAoD;AAA3C,kHAAA,mBAAmB,OAAA;AAE5B,YAAY;AACZ,qCAA2C;AAAlC,yGAAA,gBAAgB,OAAA;AAEzB,YAAY;AACZ,mDAI6B;AAH3B,yHAAA,8BAA8B,OAAA;AAC9B,+GAAA,oBAAoB,OAAA;AACpB,sHAAA,2BAA2B,OAAA","sourcesContent":["// Main controller export\nexport {\n AssetsController,\n getDefaultAssetsControllerState,\n} from './AssetsController';\n\n// State and messenger types\nexport type {\n AssetsControllerState,\n AssetsControllerMessenger,\n AssetsControllerOptions,\n AssetsControllerFirstInitFetchMetaMetricsPayload,\n AssetsControllerGetStateAction,\n AssetsControllerActions,\n AssetsControllerStateChangeEvent,\n AssetsControllerBalanceChangedEvent,\n AssetsControllerPriceChangedEvent,\n AssetsControllerAssetsDetectedEvent,\n AssetsControllerEvents,\n} from './AssetsController';\nexport type {\n AssetsControllerGetAssetsAction,\n AssetsControllerGetAssetsBalanceAction,\n AssetsControllerGetAssetMetadataAction,\n AssetsControllerGetAssetsPriceAction,\n AssetsControllerAddCustomAssetAction,\n AssetsControllerRemoveCustomAssetAction,\n AssetsControllerGetCustomAssetsAction,\n AssetsControllerHideAssetAction,\n AssetsControllerUnhideAssetAction,\n AssetsControllerMethodActions,\n} from './AssetsController-method-action-types';\n\n// Core types\nexport type {\n // CAIP types\n Caip19AssetId,\n AccountId,\n ChainId,\n // Asset types\n AssetType,\n TokenStandard,\n // Contract data types\n TokenFees,\n HoneypotStatus,\n StorageSlots,\n LocalizedDescription,\n // Metadata types\n BaseAssetMetadata,\n FungibleAssetMetadata,\n ERC721AssetMetadata,\n ERC1155AssetMetadata,\n AssetMetadata,\n // Price types\n BaseAssetPrice,\n FungibleAssetPrice,\n NFTAssetPrice,\n AssetPrice,\n // Balance types\n FungibleAssetBalance,\n ERC721AssetBalance,\n ERC1155AssetBalance,\n AssetBalance,\n // Data source types\n AccountWithSupportedChains,\n DataType,\n DataRequest,\n DataResponse,\n // Middleware types\n Context,\n NextFunction,\n Middleware,\n FetchContext,\n FetchNextFunction,\n FetchMiddleware,\n SubscriptionResponse,\n // Combined asset type\n Asset,\n // Event types\n BalanceChangeEvent,\n PriceChangeEvent,\n MetadataChangeEvent,\n AssetsDetectedEvent,\n} from './types';\n\n// Data sources - base class and types\nexport { AbstractDataSource } from './data-sources';\n\nexport type { DataSourceState, SubscriptionRequest } from './data-sources';\n\n// Data sources - AccountsApi\nexport { AccountsApiDataSource } from './data-sources';\n\nexport type {\n AccountsApiDataSourceConfig,\n AccountsApiDataSourceOptions,\n AccountsApiDataSourceState,\n AccountsApiDataSourceAllowedActions,\n} from './data-sources';\n\n// Data sources - BackendWebsocket\nexport {\n BackendWebsocketDataSource,\n createBackendWebsocketDataSource,\n} from './data-sources';\n\nexport type {\n BackendWebsocketDataSourceOptions,\n BackendWebsocketDataSourceState,\n BackendWebsocketDataSourceAllowedActions,\n BackendWebsocketDataSourceAllowedEvents,\n} from './data-sources';\n\n// Data sources - RPC\nexport { RpcDataSource, createRpcDataSource } from './data-sources';\n\nexport type {\n RpcDataSourceConfig,\n RpcDataSourceOptions,\n RpcDataSourceState,\n RpcDataSourceAllowedActions,\n RpcDataSourceAllowedEvents,\n ChainStatus,\n} from './data-sources';\n\n// Data sources - Unified Snap Data Source (dynamically discovers keyring snaps)\nexport {\n SnapDataSource,\n createSnapDataSource,\n SNAP_DATA_SOURCE_NAME,\n // Constants\n KEYRING_PERMISSION,\n // Utility functions\n getChainIdsCaveat,\n extractChainFromAssetId,\n} from './data-sources';\n\nexport type {\n SnapDataSourceState,\n SnapDataSourceOptions,\n SnapDataSourceAllowedActions,\n SnapDataSourceAllowedEvents,\n} from './data-sources';\n\n// Enrichment data sources\nexport { TokenDataSource, PriceDataSource } from './data-sources';\n\nexport type {\n TokenDataSourceOptions,\n TokenDataSourceAllowedActions,\n PriceDataSourceConfig,\n PriceDataSourceOptions,\n} from './data-sources';\n\n// Middlewares\nexport { DetectionMiddleware } from './middlewares';\n\n// Utilities\nexport { normalizeAssetId } from './utils';\n\n// Selectors\nexport {\n getAggregatedBalanceForAccount,\n getGroupIdForAccount,\n getInternalAccountsForGroup,\n} from './selectors/balance';\n\nexport type {\n AccountsById,\n AggregatedBalanceEntry,\n AggregatedBalanceForAccount,\n EnabledNetworkMap,\n} from './selectors/balance';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AACzB,2DAG4B;AAF1B,oHAAA,gBAAgB,OAAA;AAChB,mIAAA,+BAA+B,OAAA;AAoFjC,sCAAsC;AACtC,yDAAoD;AAA3C,kHAAA,kBAAkB,OAAA;AAI3B,6BAA6B;AAC7B,yDAAuD;AAA9C,qHAAA,qBAAqB,OAAA;AAS9B,kCAAkC;AAClC,yDAGwB;AAFtB,0HAAA,0BAA0B,OAAA;AAC1B,gIAAA,gCAAgC,OAAA;AAUlC,qBAAqB;AACrB,yDAAoE;AAA3D,6GAAA,aAAa,OAAA;AAAE,mHAAA,mBAAmB,OAAA;AAW3C,gFAAgF;AAChF,yDASwB;AARtB,8GAAA,cAAc,OAAA;AACd,oHAAA,oBAAoB,OAAA;AACpB,qHAAA,qBAAqB,OAAA;AACrB,YAAY;AACZ,kHAAA,kBAAkB,OAAA;AAClB,oBAAoB;AACpB,iHAAA,iBAAiB,OAAA;AACjB,uHAAA,uBAAuB,OAAA;AAUzB,0BAA0B;AAC1B,yDAAkE;AAAzD,+GAAA,eAAe,OAAA;AAAE,+GAAA,eAAe,OAAA;AASzC,cAAc;AACd,uDAAoD;AAA3C,kHAAA,mBAAmB,OAAA;AAE5B,YAAY;AACZ,qCAA2C;AAAlC,yGAAA,gBAAgB,OAAA;AAEzB,YAAY;AACZ,mDAI6B;AAH3B,yHAAA,8BAA8B,OAAA;AAC9B,+GAAA,oBAAoB,OAAA;AACpB,sHAAA,2BAA2B,OAAA","sourcesContent":["// Main controller export\nexport {\n AssetsController,\n getDefaultAssetsControllerState,\n} from './AssetsController';\nexport type { PendingTokenMetadata } from './AssetsController';\n\n// State and messenger types\nexport type {\n AssetsControllerState,\n AssetsControllerMessenger,\n AssetsControllerOptions,\n AssetsControllerFirstInitFetchMetaMetricsPayload,\n AssetsControllerGetStateAction,\n AssetsControllerActions,\n AssetsControllerStateChangeEvent,\n AssetsControllerBalanceChangedEvent,\n AssetsControllerPriceChangedEvent,\n AssetsControllerAssetsDetectedEvent,\n AssetsControllerEvents,\n} from './AssetsController';\nexport type {\n AssetsControllerGetAssetsAction,\n AssetsControllerGetAssetsBalanceAction,\n AssetsControllerGetAssetMetadataAction,\n AssetsControllerGetAssetsPriceAction,\n AssetsControllerAddCustomAssetAction,\n AssetsControllerRemoveCustomAssetAction,\n AssetsControllerGetCustomAssetsAction,\n AssetsControllerHideAssetAction,\n AssetsControllerUnhideAssetAction,\n AssetsControllerMethodActions,\n} from './AssetsController-method-action-types';\n\n// Core types\nexport type {\n // CAIP types\n Caip19AssetId,\n AccountId,\n ChainId,\n // Asset types\n AssetType,\n TokenStandard,\n // Contract data types\n TokenFees,\n HoneypotStatus,\n StorageSlots,\n LocalizedDescription,\n // Metadata types\n BaseAssetMetadata,\n FungibleAssetMetadata,\n ERC721AssetMetadata,\n ERC1155AssetMetadata,\n AssetMetadata,\n // Price types\n BaseAssetPrice,\n FungibleAssetPrice,\n NFTAssetPrice,\n AssetPrice,\n // Balance types\n FungibleAssetBalance,\n ERC721AssetBalance,\n ERC1155AssetBalance,\n AssetBalance,\n // Data source types\n AccountWithSupportedChains,\n DataType,\n DataRequest,\n DataResponse,\n AssetsUpdateMode,\n // Middleware types\n Context,\n NextFunction,\n Middleware,\n FetchContext,\n FetchNextFunction,\n FetchMiddleware,\n SubscriptionResponse,\n // Combined asset type\n Asset,\n // Event types\n BalanceChangeEvent,\n PriceChangeEvent,\n MetadataChangeEvent,\n AssetsDetectedEvent,\n} from './types';\n\n// Data sources - base class and types\nexport { AbstractDataSource } from './data-sources';\n\nexport type { DataSourceState, SubscriptionRequest } from './data-sources';\n\n// Data sources - AccountsApi\nexport { AccountsApiDataSource } from './data-sources';\n\nexport type {\n AccountsApiDataSourceConfig,\n AccountsApiDataSourceOptions,\n AccountsApiDataSourceState,\n AccountsApiDataSourceAllowedActions,\n} from './data-sources';\n\n// Data sources - BackendWebsocket\nexport {\n BackendWebsocketDataSource,\n createBackendWebsocketDataSource,\n} from './data-sources';\n\nexport type {\n BackendWebsocketDataSourceOptions,\n BackendWebsocketDataSourceState,\n BackendWebsocketDataSourceAllowedActions,\n BackendWebsocketDataSourceAllowedEvents,\n} from './data-sources';\n\n// Data sources - RPC\nexport { RpcDataSource, createRpcDataSource } from './data-sources';\n\nexport type {\n RpcDataSourceConfig,\n RpcDataSourceOptions,\n RpcDataSourceState,\n RpcDataSourceAllowedActions,\n RpcDataSourceAllowedEvents,\n ChainStatus,\n} from './data-sources';\n\n// Data sources - Unified Snap Data Source (dynamically discovers keyring snaps)\nexport {\n SnapDataSource,\n createSnapDataSource,\n SNAP_DATA_SOURCE_NAME,\n // Constants\n KEYRING_PERMISSION,\n // Utility functions\n getChainIdsCaveat,\n extractChainFromAssetId,\n} from './data-sources';\n\nexport type {\n SnapDataSourceState,\n SnapDataSourceOptions,\n SnapDataSourceAllowedActions,\n SnapDataSourceAllowedEvents,\n} from './data-sources';\n\n// Enrichment data sources\nexport { TokenDataSource, PriceDataSource } from './data-sources';\n\nexport type {\n TokenDataSourceOptions,\n TokenDataSourceAllowedActions,\n PriceDataSourceConfig,\n PriceDataSourceOptions,\n} from './data-sources';\n\n// Middlewares\nexport { DetectionMiddleware } from './middlewares';\n\n// Utilities\nexport { normalizeAssetId } from './utils';\n\n// Selectors\nexport {\n getAggregatedBalanceForAccount,\n getGroupIdForAccount,\n getInternalAccountsForGroup,\n} from './selectors/balance';\n\nexport type {\n AccountsById,\n AggregatedBalanceEntry,\n AggregatedBalanceForAccount,\n EnabledNetworkMap,\n} from './selectors/balance';\n"]}
package/dist/index.d.cts CHANGED
@@ -1,7 +1,8 @@
1
1
  export { AssetsController, getDefaultAssetsControllerState, } from "./AssetsController.cjs";
2
+ export type { PendingTokenMetadata } from "./AssetsController.cjs";
2
3
  export type { AssetsControllerState, AssetsControllerMessenger, AssetsControllerOptions, AssetsControllerFirstInitFetchMetaMetricsPayload, AssetsControllerGetStateAction, AssetsControllerActions, AssetsControllerStateChangeEvent, AssetsControllerBalanceChangedEvent, AssetsControllerPriceChangedEvent, AssetsControllerAssetsDetectedEvent, AssetsControllerEvents, } from "./AssetsController.cjs";
3
4
  export type { AssetsControllerGetAssetsAction, AssetsControllerGetAssetsBalanceAction, AssetsControllerGetAssetMetadataAction, AssetsControllerGetAssetsPriceAction, AssetsControllerAddCustomAssetAction, AssetsControllerRemoveCustomAssetAction, AssetsControllerGetCustomAssetsAction, AssetsControllerHideAssetAction, AssetsControllerUnhideAssetAction, AssetsControllerMethodActions, } from "./AssetsController-method-action-types.cjs";
4
- export type { Caip19AssetId, AccountId, ChainId, AssetType, TokenStandard, TokenFees, HoneypotStatus, StorageSlots, LocalizedDescription, BaseAssetMetadata, FungibleAssetMetadata, ERC721AssetMetadata, ERC1155AssetMetadata, AssetMetadata, BaseAssetPrice, FungibleAssetPrice, NFTAssetPrice, AssetPrice, FungibleAssetBalance, ERC721AssetBalance, ERC1155AssetBalance, AssetBalance, AccountWithSupportedChains, DataType, DataRequest, DataResponse, Context, NextFunction, Middleware, FetchContext, FetchNextFunction, FetchMiddleware, SubscriptionResponse, Asset, BalanceChangeEvent, PriceChangeEvent, MetadataChangeEvent, AssetsDetectedEvent, } from "./types.cjs";
5
+ export type { Caip19AssetId, AccountId, ChainId, AssetType, TokenStandard, TokenFees, HoneypotStatus, StorageSlots, LocalizedDescription, BaseAssetMetadata, FungibleAssetMetadata, ERC721AssetMetadata, ERC1155AssetMetadata, AssetMetadata, BaseAssetPrice, FungibleAssetPrice, NFTAssetPrice, AssetPrice, FungibleAssetBalance, ERC721AssetBalance, ERC1155AssetBalance, AssetBalance, AccountWithSupportedChains, DataType, DataRequest, DataResponse, AssetsUpdateMode, Context, NextFunction, Middleware, FetchContext, FetchNextFunction, FetchMiddleware, SubscriptionResponse, Asset, BalanceChangeEvent, PriceChangeEvent, MetadataChangeEvent, AssetsDetectedEvent, } from "./types.cjs";
5
6
  export { AbstractDataSource } from "./data-sources/index.cjs";
6
7
  export type { DataSourceState, SubscriptionRequest } from "./data-sources/index.cjs";
7
8
  export { AccountsApiDataSource } from "./data-sources/index.cjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,+BAA+B,GAChC,+BAA2B;AAG5B,YAAY,EACV,qBAAqB,EACrB,yBAAyB,EACzB,uBAAuB,EACvB,gDAAgD,EAChD,8BAA8B,EAC9B,uBAAuB,EACvB,gCAAgC,EAChC,mCAAmC,EACnC,iCAAiC,EACjC,mCAAmC,EACnC,sBAAsB,GACvB,+BAA2B;AAC5B,YAAY,EACV,+BAA+B,EAC/B,sCAAsC,EACtC,sCAAsC,EACtC,oCAAoC,EACpC,oCAAoC,EACpC,uCAAuC,EACvC,qCAAqC,EACrC,+BAA+B,EAC/B,iCAAiC,EACjC,6BAA6B,GAC9B,mDAA+C;AAGhD,YAAY,EAEV,aAAa,EACb,SAAS,EACT,OAAO,EAEP,SAAS,EACT,aAAa,EAEb,SAAS,EACT,cAAc,EACd,YAAY,EACZ,oBAAoB,EAEpB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EAEb,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,UAAU,EAEV,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EAEZ,0BAA0B,EAC1B,QAAQ,EACR,WAAW,EACX,YAAY,EAEZ,OAAO,EACP,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EAEpB,KAAK,EAEL,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,GACpB,oBAAg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AiC,EACjC,+BAA+B,EAC/B,wCAAwC,EACxC,uCAAuC,GACxC,iCAAuB;AAGxB,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,iCAAuB;AAEpE,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,2BAA2B,EAC3B,0BAA0B,EAC1B,WAAW,GACZ,iCAAuB;AAGxB,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,qBAAqB,EAErB,kBAAkB,EAElB,iBAAiB,EACjB,uBAAuB,GACxB,iCAAuB;AAExB,YAAY,EACV,mBAAmB,EACnB,qBAAqB,EACrB,4BAA4B,EAC5B,2BAA2B,GAC5B,iCAAuB;AAGxB,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,iCAAuB;AAElE,YAAY,EACV,sBAAsB,EACtB,6BAA6B,EAC7B,qBAAqB,EACrB,sBAAsB,GACvB,iCAAuB;AAGxB,OAAO,EAAE,mBAAmB,EAAE,gCAAsB;AAGpD,OAAO,EAAE,gBAAgB,EAAE,oBAAgB;AAG3C,OAAO,EACL,8BAA8B,EAC9B,oBAAoB,EACpB,2BAA2B,GAC5B,gCAA4B;AAE7B,YAAY,EACV,YAAY,EACZ,sBAAsB,EACtB,2BAA2B,EAC3B,iBAAiB,GAClB,gCAA4B"}
package/dist/index.d.mts CHANGED
@@ -1,7 +1,8 @@
1
1
  export { AssetsController, getDefaultAssetsControllerState, } from "./AssetsController.mjs";
2
+ export type { PendingTokenMetadata } from "./AssetsController.mjs";
2
3
  export type { AssetsControllerState, AssetsControllerMessenger, AssetsControllerOptions, AssetsControllerFirstInitFetchMetaMetricsPayload, AssetsControllerGetStateAction, AssetsControllerActions, AssetsControllerStateChangeEvent, AssetsControllerBalanceChangedEvent, AssetsControllerPriceChangedEvent, AssetsControllerAssetsDetectedEvent, AssetsControllerEvents, } from "./AssetsController.mjs";
3
4
  export type { AssetsControllerGetAssetsAction, AssetsControllerGetAssetsBalanceAction, AssetsControllerGetAssetMetadataAction, AssetsControllerGetAssetsPriceAction, AssetsControllerAddCustomAssetAction, AssetsControllerRemoveCustomAssetAction, AssetsControllerGetCustomAssetsAction, AssetsControllerHideAssetAction, AssetsControllerUnhideAssetAction, AssetsControllerMethodActions, } from "./AssetsController-method-action-types.mjs";
4
- export type { Caip19AssetId, AccountId, ChainId, AssetType, TokenStandard, TokenFees, HoneypotStatus, StorageSlots, LocalizedDescription, BaseAssetMetadata, FungibleAssetMetadata, ERC721AssetMetadata, ERC1155AssetMetadata, AssetMetadata, BaseAssetPrice, FungibleAssetPrice, NFTAssetPrice, AssetPrice, FungibleAssetBalance, ERC721AssetBalance, ERC1155AssetBalance, AssetBalance, AccountWithSupportedChains, DataType, DataRequest, DataResponse, Context, NextFunction, Middleware, FetchContext, FetchNextFunction, FetchMiddleware, SubscriptionResponse, Asset, BalanceChangeEvent, PriceChangeEvent, MetadataChangeEvent, AssetsDetectedEvent, } from "./types.mjs";
5
+ export type { Caip19AssetId, AccountId, ChainId, AssetType, TokenStandard, TokenFees, HoneypotStatus, StorageSlots, LocalizedDescription, BaseAssetMetadata, FungibleAssetMetadata, ERC721AssetMetadata, ERC1155AssetMetadata, AssetMetadata, BaseAssetPrice, FungibleAssetPrice, NFTAssetPrice, AssetPrice, FungibleAssetBalance, ERC721AssetBalance, ERC1155AssetBalance, AssetBalance, AccountWithSupportedChains, DataType, DataRequest, DataResponse, AssetsUpdateMode, Context, NextFunction, Middleware, FetchContext, FetchNextFunction, FetchMiddleware, SubscriptionResponse, Asset, BalanceChangeEvent, PriceChangeEvent, MetadataChangeEvent, AssetsDetectedEvent, } from "./types.mjs";
5
6
  export { AbstractDataSource } from "./data-sources/index.mjs";
6
7
  export type { DataSourceState, SubscriptionRequest } from "./data-sources/index.mjs";
7
8
  export { AccountsApiDataSource } from "./data-sources/index.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,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9B,oBAAoB,EACpB,2BAA2B,EAC5B,gCAA4B","sourcesContent":["// Main controller export\nexport {\n AssetsController,\n getDefaultAssetsControllerState,\n} from './AssetsController';\n\n// State and messenger types\nexport type {\n AssetsControllerState,\n AssetsControllerMessenger,\n AssetsControllerOptions,\n AssetsControllerFirstInitFetchMetaMetricsPayload,\n AssetsControllerGetStateAction,\n AssetsControllerActions,\n AssetsControllerStateChangeEvent,\n AssetsControllerBalanceChangedEvent,\n AssetsControllerPriceChangedEvent,\n AssetsControllerAssetsDetectedEvent,\n AssetsControllerEvents,\n} from './AssetsController';\nexport type {\n AssetsControllerGetAssetsAction,\n AssetsControllerGetAssetsBalanceAction,\n AssetsControllerGetAssetMetadataAction,\n AssetsControllerGetAssetsPriceAction,\n AssetsControllerAddCustomAssetAction,\n AssetsControllerRemoveCustomAssetAction,\n AssetsControllerGetCustomAssetsAction,\n AssetsControllerHideAssetAction,\n AssetsControllerUnhideAssetAction,\n AssetsControllerMethodActions,\n} from './AssetsController-method-action-types';\n\n// Core types\nexport type {\n // CAIP types\n Caip19AssetId,\n AccountId,\n ChainId,\n // Asset types\n AssetType,\n TokenStandard,\n // Contract data types\n TokenFees,\n HoneypotStatus,\n StorageSlots,\n LocalizedDescription,\n // Metadata types\n BaseAssetMetadata,\n FungibleAssetMetadata,\n ERC721AssetMetadata,\n ERC1155AssetMetadata,\n AssetMetadata,\n // Price types\n BaseAssetPrice,\n FungibleAssetPrice,\n NFTAssetPrice,\n AssetPrice,\n // Balance types\n FungibleAssetBalance,\n ERC721AssetBalance,\n ERC1155AssetBalance,\n AssetBalance,\n // Data source types\n AccountWithSupportedChains,\n DataType,\n DataRequest,\n DataResponse,\n // Middleware types\n Context,\n NextFunction,\n Middleware,\n FetchContext,\n FetchNextFunction,\n FetchMiddleware,\n SubscriptionResponse,\n // Combined asset type\n Asset,\n // Event types\n BalanceChangeEvent,\n PriceChangeEvent,\n MetadataChangeEvent,\n AssetsDetectedEvent,\n} from './types';\n\n// Data sources - base class and types\nexport { AbstractDataSource } from './data-sources';\n\nexport type { DataSourceState, SubscriptionRequest } from './data-sources';\n\n// Data sources - AccountsApi\nexport { AccountsApiDataSource } from './data-sources';\n\nexport type {\n AccountsApiDataSourceConfig,\n AccountsApiDataSourceOptions,\n AccountsApiDataSourceState,\n AccountsApiDataSourceAllowedActions,\n} from './data-sources';\n\n// Data sources - BackendWebsocket\nexport {\n BackendWebsocketDataSource,\n createBackendWebsocketDataSource,\n} from './data-sources';\n\nexport type {\n BackendWebsocketDataSourceOptions,\n BackendWebsocketDataSourceState,\n BackendWebsocketDataSourceAllowedActions,\n BackendWebsocketDataSourceAllowedEvents,\n} from './data-sources';\n\n// Data sources - RPC\nexport { RpcDataSource, createRpcDataSource } from './data-sources';\n\nexport type {\n RpcDataSourceConfig,\n RpcDataSourceOptions,\n RpcDataSourceState,\n RpcDataSourceAllowedActions,\n RpcDataSourceAllowedEvents,\n ChainStatus,\n} from './data-sources';\n\n// Data sources - Unified Snap Data Source (dynamically discovers keyring snaps)\nexport {\n SnapDataSource,\n createSnapDataSource,\n SNAP_DATA_SOURCE_NAME,\n // Constants\n KEYRING_PERMISSION,\n // Utility functions\n getChainIdsCaveat,\n extractChainFromAssetId,\n} from './data-sources';\n\nexport type {\n SnapDataSourceState,\n SnapDataSourceOptions,\n SnapDataSourceAllowedActions,\n SnapDataSourceAllowedEvents,\n} from './data-sources';\n\n// Enrichment data sources\nexport { TokenDataSource, PriceDataSource } from './data-sources';\n\nexport type {\n TokenDataSourceOptions,\n TokenDataSourceAllowedActions,\n PriceDataSourceConfig,\n PriceDataSourceOptions,\n} from './data-sources';\n\n// Middlewares\nexport { DetectionMiddleware } from './middlewares';\n\n// Utilities\nexport { normalizeAssetId } from './utils';\n\n// Selectors\nexport {\n getAggregatedBalanceForAccount,\n getGroupIdForAccount,\n getInternalAccountsForGroup,\n} from './selectors/balance';\n\nexport type {\n AccountsById,\n AggregatedBalanceEntry,\n AggregatedBalanceForAccount,\n EnabledNetworkMap,\n} from './selectors/balance';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,OAAO,EACL,gBAAgB,EAChB,+BAA+B,EAChC,+BAA2B;AAmF5B,sCAAsC;AACtC,OAAO,EAAE,kBAAkB,EAAE,iCAAuB;AAIpD,6BAA6B;AAC7B,OAAO,EAAE,qBAAqB,EAAE,iCAAuB;AASvD,kCAAkC;AAClC,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,EACjC,iCAAuB;AASxB,qBAAqB;AACrB,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,iCAAuB;AAWpE,gFAAgF;AAChF,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,qBAAqB;AACrB,YAAY;AACZ,kBAAkB;AAClB,oBAAoB;AACpB,iBAAiB,EACjB,uBAAuB,EACxB,iCAAuB;AASxB,0BAA0B;AAC1B,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,iCAAuB;AASlE,cAAc;AACd,OAAO,EAAE,mBAAmB,EAAE,gCAAsB;AAEpD,YAAY;AACZ,OAAO,EAAE,gBAAgB,EAAE,oBAAgB;AAE3C,YAAY;AACZ,OAAO,EACL,8BAA8B,EAC9B,oBAAoB,EACpB,2BAA2B,EAC5B,gCAA4B","sourcesContent":["// Main controller export\nexport {\n AssetsController,\n getDefaultAssetsControllerState,\n} from './AssetsController';\nexport type { PendingTokenMetadata } from './AssetsController';\n\n// State and messenger types\nexport type {\n AssetsControllerState,\n AssetsControllerMessenger,\n AssetsControllerOptions,\n AssetsControllerFirstInitFetchMetaMetricsPayload,\n AssetsControllerGetStateAction,\n AssetsControllerActions,\n AssetsControllerStateChangeEvent,\n AssetsControllerBalanceChangedEvent,\n AssetsControllerPriceChangedEvent,\n AssetsControllerAssetsDetectedEvent,\n AssetsControllerEvents,\n} from './AssetsController';\nexport type {\n AssetsControllerGetAssetsAction,\n AssetsControllerGetAssetsBalanceAction,\n AssetsControllerGetAssetMetadataAction,\n AssetsControllerGetAssetsPriceAction,\n AssetsControllerAddCustomAssetAction,\n AssetsControllerRemoveCustomAssetAction,\n AssetsControllerGetCustomAssetsAction,\n AssetsControllerHideAssetAction,\n AssetsControllerUnhideAssetAction,\n AssetsControllerMethodActions,\n} from './AssetsController-method-action-types';\n\n// Core types\nexport type {\n // CAIP types\n Caip19AssetId,\n AccountId,\n ChainId,\n // Asset types\n AssetType,\n TokenStandard,\n // Contract data types\n TokenFees,\n HoneypotStatus,\n StorageSlots,\n LocalizedDescription,\n // Metadata types\n BaseAssetMetadata,\n FungibleAssetMetadata,\n ERC721AssetMetadata,\n ERC1155AssetMetadata,\n AssetMetadata,\n // Price types\n BaseAssetPrice,\n FungibleAssetPrice,\n NFTAssetPrice,\n AssetPrice,\n // Balance types\n FungibleAssetBalance,\n ERC721AssetBalance,\n ERC1155AssetBalance,\n AssetBalance,\n // Data source types\n AccountWithSupportedChains,\n DataType,\n DataRequest,\n DataResponse,\n AssetsUpdateMode,\n // Middleware types\n Context,\n NextFunction,\n Middleware,\n FetchContext,\n FetchNextFunction,\n FetchMiddleware,\n SubscriptionResponse,\n // Combined asset type\n Asset,\n // Event types\n BalanceChangeEvent,\n PriceChangeEvent,\n MetadataChangeEvent,\n AssetsDetectedEvent,\n} from './types';\n\n// Data sources - base class and types\nexport { AbstractDataSource } from './data-sources';\n\nexport type { DataSourceState, SubscriptionRequest } from './data-sources';\n\n// Data sources - AccountsApi\nexport { AccountsApiDataSource } from './data-sources';\n\nexport type {\n AccountsApiDataSourceConfig,\n AccountsApiDataSourceOptions,\n AccountsApiDataSourceState,\n AccountsApiDataSourceAllowedActions,\n} from './data-sources';\n\n// Data sources - BackendWebsocket\nexport {\n BackendWebsocketDataSource,\n createBackendWebsocketDataSource,\n} from './data-sources';\n\nexport type {\n BackendWebsocketDataSourceOptions,\n BackendWebsocketDataSourceState,\n BackendWebsocketDataSourceAllowedActions,\n BackendWebsocketDataSourceAllowedEvents,\n} from './data-sources';\n\n// Data sources - RPC\nexport { RpcDataSource, createRpcDataSource } from './data-sources';\n\nexport type {\n RpcDataSourceConfig,\n RpcDataSourceOptions,\n RpcDataSourceState,\n RpcDataSourceAllowedActions,\n RpcDataSourceAllowedEvents,\n ChainStatus,\n} from './data-sources';\n\n// Data sources - Unified Snap Data Source (dynamically discovers keyring snaps)\nexport {\n SnapDataSource,\n createSnapDataSource,\n SNAP_DATA_SOURCE_NAME,\n // Constants\n KEYRING_PERMISSION,\n // Utility functions\n getChainIdsCaveat,\n extractChainFromAssetId,\n} from './data-sources';\n\nexport type {\n SnapDataSourceState,\n SnapDataSourceOptions,\n SnapDataSourceAllowedActions,\n SnapDataSourceAllowedEvents,\n} from './data-sources';\n\n// Enrichment data sources\nexport { TokenDataSource, PriceDataSource } from './data-sources';\n\nexport type {\n TokenDataSourceOptions,\n TokenDataSourceAllowedActions,\n PriceDataSourceConfig,\n PriceDataSourceOptions,\n} from './data-sources';\n\n// Middlewares\nexport { DetectionMiddleware } from './middlewares';\n\n// Utilities\nexport { normalizeAssetId } from './utils';\n\n// Selectors\nexport {\n getAggregatedBalanceForAccount,\n getGroupIdForAccount,\n getInternalAccountsForGroup,\n} from './selectors/balance';\n\nexport type {\n AccountsById,\n AggregatedBalanceEntry,\n AggregatedBalanceForAccount,\n EnabledNetworkMap,\n} from './selectors/balance';\n"]}
@@ -13,12 +13,19 @@ const CONTROLLER_NAME = 'DetectionMiddleware';
13
13
  // DETECTION MIDDLEWARE
14
14
  // ============================================================================
15
15
  /**
16
- * DetectionMiddleware identifies assets that do not have metadata.
16
+ * DetectionMiddleware builds the set of assets that downstream sources use for
17
+ * metadata and price fetching.
17
18
  *
18
19
  * This middleware:
19
- * - Checks assets in the response for metadata in state (via ctx.getAssetsState)
20
- * - Assets in response but without metadata are considered "detected"
21
- * - Fills response.detectedAssets with asset IDs per account that lack metadata
20
+ * - Includes every asset that appears in response.assetsBalance (so prices and
21
+ * metadata are fetched for existing assets as well as new ones)
22
+ * - Includes each account's custom assets from state (so custom tokens get
23
+ * metadata and prices even when they have no balance yet)
24
+ * - Fills response.detectedAssets with these asset IDs per account
25
+ *
26
+ * TokenDataSource and PriceDataSource both key off detectedAssets. TokenDataSource
27
+ * then filters to only fetch metadata for assets that lack it; PriceDataSource
28
+ * fetches prices for all detected assets.
22
29
  *
23
30
  * Usage:
24
31
  * ```typescript
@@ -34,45 +41,55 @@ class DetectionMiddleware {
34
41
  return this.name;
35
42
  }
36
43
  /**
37
- * Get the middleware for detecting assets without metadata.
44
+ * Get the middleware that builds detectedAssets for metadata and price fetching.
38
45
  *
39
46
  * This middleware:
40
- * 1. Extracts the response from context
41
- * 2. Detects assets from the response that don't have metadata
42
- * 3. Fills response.detectedAssets with detected asset IDs per account
43
- * 4. Calls next() to continue the middleware chain
47
+ * 1. Includes all assets from response.assetsBalance (so prices are fetched for existing assets too)
48
+ * 2. Merges each account's custom assets from state
49
+ * 3. Fills response.detectedAssets with these asset IDs per account
44
50
  *
45
51
  * @returns The middleware function for the assets pipeline.
46
52
  */
47
53
  get assetsMiddleware() {
48
54
  return (0, types_1.forDataTypes)(['balance'], async (ctx, next) => {
49
- // Extract response from context
50
- const { response } = ctx;
51
- // If no balances in response, nothing to detect - pass through
52
- if (!response.assetsBalance) {
53
- return next(ctx);
54
- }
55
- // Get metadata from state
56
- const { assetsInfo: stateMetadata } = ctx.getAssetsState();
55
+ const { request, response } = ctx;
56
+ // Get state for custom assets
57
+ const state = ctx.getAssetsState();
58
+ const { customAssets: stateCustomAssets } = state;
57
59
  const detectedAssets = {};
58
- // Detect assets from the response that don't have metadata
59
- for (const [accountId, accountBalances] of Object.entries(response.assetsBalance)) {
60
- const detected = [];
61
- for (const assetId of Object.keys(accountBalances)) {
62
- // Asset is detected if it does not have metadata in state
63
- if (!stateMetadata[assetId]) {
60
+ // 1. From balance response: include every asset with balance (so prices + metadata path include existing assets)
61
+ if (response.assetsBalance) {
62
+ for (const [accountId, accountBalances] of Object.entries(response.assetsBalance)) {
63
+ const detected = [];
64
+ for (const assetId of Object.keys(accountBalances)) {
64
65
  detected.push(assetId);
65
66
  }
67
+ // Merge this account's custom assets from state
68
+ const customForAccount = stateCustomAssets?.[accountId] ?? [];
69
+ for (const assetId of customForAccount) {
70
+ if (!detected.includes(assetId)) {
71
+ detected.push(assetId);
72
+ }
73
+ }
74
+ if (detected.length > 0) {
75
+ detectedAssets[accountId] = detected;
76
+ }
77
+ }
78
+ }
79
+ // 2. Accounts in request that weren't in balance response: include their custom assets
80
+ for (const { account } of request.accountsWithSupportedChains) {
81
+ const accountId = account.id;
82
+ if (detectedAssets[accountId]) {
83
+ continue;
66
84
  }
67
- if (detected.length > 0) {
68
- detectedAssets[accountId] = detected;
85
+ const customForAccount = stateCustomAssets?.[accountId] ?? [];
86
+ if (customForAccount.length > 0) {
87
+ detectedAssets[accountId] = customForAccount;
69
88
  }
70
89
  }
71
- // Fill detectedAssets in the response
72
90
  if (Object.keys(detectedAssets).length > 0) {
73
91
  response.detectedAssets = detectedAssets;
74
92
  }
75
- // Call next() to continue the middleware chain
76
93
  return next(ctx);
77
94
  });
78
95
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DetectionMiddleware.cjs","sourceRoot":"","sources":["../../src/middlewares/DetectionMiddleware.ts"],"names":[],"mappings":";;;AAAA,0CAA8D;AAC9D,wCAAwC;AAGxC,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,MAAM,eAAe,GAAG,qBAAqB,CAAC;AAE9C,uBAAuB;AACvB,IAAA,2BAAkB,EAAC,sBAAa,EAAE,eAAe,CAAC,CAAC;AAEnD,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E;;;;;;;;;;;;;GAaG;AACH,MAAa,mBAAmB;IAAhC;QACW,SAAI,GAAG,eAAe,CAAC;IA6DlC,CAAC;IA3DC,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED;;;;;;;;;;OAUG;IACH,IAAI,gBAAgB;QAClB,OA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uleLogger } from '../logger';\nimport { forDataTypes } from '../types';\nimport type { AccountId, Caip19AssetId, Middleware } from '../types';\n\n// ============================================================================\n// CONSTANTS\n// ============================================================================\n\nconst CONTROLLER_NAME = 'DetectionMiddleware';\n\n// Logger for debugging\ncreateModuleLogger(projectLogger, CONTROLLER_NAME);\n\n// ============================================================================\n// DETECTION MIDDLEWARE\n// ============================================================================\n\n/**\n * DetectionMiddleware identifies assets that do not have metadata.\n *\n * This middleware:\n * - Checks assets in the response for metadata in state (via ctx.getAssetsState)\n * - Assets in response but without metadata are considered \"detected\"\n * - Fills response.detectedAssets with asset IDs per account that lack metadata\n *\n * Usage:\n * ```typescript\n * const detectionMiddleware = new DetectionMiddleware();\n * const middleware = detectionMiddleware.assetsMiddleware;\n * ```\n */\nexport class DetectionMiddleware {\n readonly name = CONTROLLER_NAME;\n\n getName(): string {\n return this.name;\n }\n\n /**\n * Get the middleware for detecting assets without metadata.\n *\n * This middleware:\n * 1. Extracts the response from context\n * 2. Detects assets from the response that don't have metadata\n * 3. Fills response.detectedAssets with detected asset IDs per account\n * 4. Calls next() to continue the middleware chain\n *\n * @returns The middleware function for the assets pipeline.\n */\n get assetsMiddleware(): Middleware {\n return forDataTypes(['balance'], async (ctx, next) => {\n // Extract response from context\n const { response } = ctx;\n\n // If no balances in response, nothing to detect - pass through\n if (!response.assetsBalance) {\n return next(ctx);\n }\n\n // Get metadata from state\n const { assetsInfo: stateMetadata } = ctx.getAssetsState();\n\n const detectedAssets: Record<AccountId, Caip19AssetId[]> = {};\n\n // Detect assets from the response that don't have metadata\n for (const [accountId, accountBalances] of Object.entries(\n response.assetsBalance,\n )) {\n const detected: Caip19AssetId[] = [];\n\n for (const assetId of Object.keys(\n accountBalances as Record<string, unknown>,\n )) {\n // Asset is detected if it does not have metadata in state\n if (!stateMetadata[assetId as Caip19AssetId]) {\n detected.push(assetId as Caip19AssetId);\n }\n }\n\n if (detected.length > 0) {\n detectedAssets[accountId] = detected;\n }\n }\n\n // Fill detectedAssets in the response\n if (Object.keys(detectedAssets).length > 0) {\n response.detectedAssets = detectedAssets;\n }\n\n // Call next() to continue the middleware chain\n return next(ctx);\n });\n }\n}\n"]}
1
+ {"version":3,"file":"DetectionMiddleware.cjs","sourceRoot":"","sources":["../../src/middlewares/DetectionMiddleware.ts"],"names":[],"mappings":";;;AAAA,0CAA8D;AAC9D,wCAAwC;AAGxC,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,MAAM,eAAe,GAAG,qBAAqB,CAAC;AAE9C,uBAAuB;AACvB,IAAA,2BAAkB,EAAC,sBAAa,EAAE,eAAe,CAAC,CAAC;AAEnD,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,mBAAmB;IAAhC;QACW,SAAI,GAAG,eAAe,CAAC;IAwElC,CAAC;IAtEC,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED;;;;;;;;;OASG;IACH,IAAI,gBAAgB;QAClB,OAAO,IAAA,oBAAY,EAAC,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;YACnD,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC;YAElC,8BAA8B;YAC9B,MAAM,KAAK,GAAG,GAAG,CAAC,cAAc,EAAE,CAAC;YACnC,MAAM,EAAE,YAAY,EAAE,iBAAiB,EAAE,GAAG,KAAK,CAAC;YAElD,MAAM,cAAc,GAAuC,EAAE,CAAC;YAE9D,iHAAiH;YACjH,IAAI,QAAQ,CAAC,aAAa,EAAE,CAAC;gBAC3B,KAAK,MAAM,CAAC,SAAS,EAAE,eAAe,CAAC,IAAI,MAAM,CAAC,OAAO,CACvD,QAAQ,CAAC,aAAa,CACvB,EAAE,CAAC;oBACF,MAAM,QAAQ,GAAoB,EAAE,CAAC;oBAErC,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,IAA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logger';\nimport { forDataTypes } from '../types';\nimport type { AccountId, Caip19AssetId, Middleware } from '../types';\n\n// ============================================================================\n// CONSTANTS\n// ============================================================================\n\nconst CONTROLLER_NAME = 'DetectionMiddleware';\n\n// Logger for debugging\ncreateModuleLogger(projectLogger, CONTROLLER_NAME);\n\n// ============================================================================\n// DETECTION MIDDLEWARE\n// ============================================================================\n\n/**\n * DetectionMiddleware builds the set of assets that downstream sources use for\n * metadata and price fetching.\n *\n * This middleware:\n * - Includes every asset that appears in response.assetsBalance (so prices and\n * metadata are fetched for existing assets as well as new ones)\n * - Includes each account's custom assets from state (so custom tokens get\n * metadata and prices even when they have no balance yet)\n * - Fills response.detectedAssets with these asset IDs per account\n *\n * TokenDataSource and PriceDataSource both key off detectedAssets. TokenDataSource\n * then filters to only fetch metadata for assets that lack it; PriceDataSource\n * fetches prices for all detected assets.\n *\n * Usage:\n * ```typescript\n * const detectionMiddleware = new DetectionMiddleware();\n * const middleware = detectionMiddleware.assetsMiddleware;\n * ```\n */\nexport class DetectionMiddleware {\n readonly name = CONTROLLER_NAME;\n\n getName(): string {\n return this.name;\n }\n\n /**\n * Get the middleware that builds detectedAssets for metadata and price fetching.\n *\n * This middleware:\n * 1. Includes all assets from response.assetsBalance (so prices are fetched for existing assets too)\n * 2. Merges each account's custom assets from state\n * 3. Fills response.detectedAssets with these asset IDs per account\n *\n * @returns The middleware function for the assets pipeline.\n */\n get assetsMiddleware(): Middleware {\n return forDataTypes(['balance'], async (ctx, next) => {\n const { request, response } = ctx;\n\n // Get state for custom assets\n const state = ctx.getAssetsState();\n const { customAssets: stateCustomAssets } = state;\n\n const detectedAssets: Record<AccountId, Caip19AssetId[]> = {};\n\n // 1. From balance response: include every asset with balance (so prices + metadata path include existing assets)\n if (response.assetsBalance) {\n for (const [accountId, accountBalances] of Object.entries(\n response.assetsBalance,\n )) {\n const detected: Caip19AssetId[] = [];\n\n for (const assetId of Object.keys(\n accountBalances as Record<string, unknown>,\n )) {\n detected.push(assetId as Caip19AssetId);\n }\n\n // Merge this account's custom assets from state\n const customForAccount = stateCustomAssets?.[accountId] ?? [];\n for (const assetId of customForAccount) {\n if (!detected.includes(assetId)) {\n detected.push(assetId);\n }\n }\n\n if (detected.length > 0) {\n detectedAssets[accountId] = detected;\n }\n }\n }\n\n // 2. Accounts in request that weren't in balance response: include their custom assets\n for (const { account } of request.accountsWithSupportedChains) {\n const accountId = account.id;\n if (detectedAssets[accountId]) {\n continue;\n }\n const customForAccount = stateCustomAssets?.[accountId] ?? [];\n if (customForAccount.length > 0) {\n detectedAssets[accountId] = customForAccount;\n }\n }\n\n if (Object.keys(detectedAssets).length > 0) {\n response.detectedAssets = detectedAssets;\n }\n\n return next(ctx);\n });\n }\n}\n"]}
@@ -1,11 +1,18 @@
1
1
  import type { Middleware } from "../types.cjs";
2
2
  /**
3
- * DetectionMiddleware identifies assets that do not have metadata.
3
+ * DetectionMiddleware builds the set of assets that downstream sources use for
4
+ * metadata and price fetching.
4
5
  *
5
6
  * This middleware:
6
- * - Checks assets in the response for metadata in state (via ctx.getAssetsState)
7
- * - Assets in response but without metadata are considered "detected"
8
- * - Fills response.detectedAssets with asset IDs per account that lack metadata
7
+ * - Includes every asset that appears in response.assetsBalance (so prices and
8
+ * metadata are fetched for existing assets as well as new ones)
9
+ * - Includes each account's custom assets from state (so custom tokens get
10
+ * metadata and prices even when they have no balance yet)
11
+ * - Fills response.detectedAssets with these asset IDs per account
12
+ *
13
+ * TokenDataSource and PriceDataSource both key off detectedAssets. TokenDataSource
14
+ * then filters to only fetch metadata for assets that lack it; PriceDataSource
15
+ * fetches prices for all detected assets.
9
16
  *
10
17
  * Usage:
11
18
  * ```typescript
@@ -17,13 +24,12 @@ export declare class DetectionMiddleware {
17
24
  readonly name = "DetectionMiddleware";
18
25
  getName(): string;
19
26
  /**
20
- * Get the middleware for detecting assets without metadata.
27
+ * Get the middleware that builds detectedAssets for metadata and price fetching.
21
28
  *
22
29
  * This middleware:
23
- * 1. Extracts the response from context
24
- * 2. Detects assets from the response that don't have metadata
25
- * 3. Fills response.detectedAssets with detected asset IDs per account
26
- * 4. Calls next() to continue the middleware chain
30
+ * 1. Includes all assets from response.assetsBalance (so prices are fetched for existing assets too)
31
+ * 2. Merges each account's custom assets from state
32
+ * 3. Fills response.detectedAssets with these asset IDs per account
27
33
  *
28
34
  * @returns The middleware function for the assets pipeline.
29
35
  */
@@ -1 +1 @@
1
- {"version":3,"file":"DetectionMiddleware.d.cts","sourceRoot":"","sources":["../../src/middlewares/DetectionMiddleware.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA4B,UAAU,EAAE,qBAAiB;AAerE;;;;;;;;;;;;;GAaG;AACH,qBAAa,mBAAmB;IAC9B,QAAQ,CAAC,IAAI,yBAAmB;IAEhC,OAAO,IAAI,MAAM;IAIjB;;;;;;;;;;OAUG;IACH,IAAI,gBAAgB,IAAI,UAAU,CA2CjC;CACF"}
1
+ {"version":3,"file":"DetectionMiddleware.d.cts","sourceRoot":"","sources":["../../src/middlewares/DetectionMiddleware.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA4B,UAAU,EAAE,qBAAiB;AAerE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,mBAAmB;IAC9B,QAAQ,CAAC,IAAI,yBAAmB;IAEhC,OAAO,IAAI,MAAM;IAIjB;;;;;;;;;OASG;IACH,IAAI,gBAAgB,IAAI,UAAU,CAuDjC;CACF"}
@@ -1,11 +1,18 @@
1
1
  import type { Middleware } from "../types.mjs";
2
2
  /**
3
- * DetectionMiddleware identifies assets that do not have metadata.
3
+ * DetectionMiddleware builds the set of assets that downstream sources use for
4
+ * metadata and price fetching.
4
5
  *
5
6
  * This middleware:
6
- * - Checks assets in the response for metadata in state (via ctx.getAssetsState)
7
- * - Assets in response but without metadata are considered "detected"
8
- * - Fills response.detectedAssets with asset IDs per account that lack metadata
7
+ * - Includes every asset that appears in response.assetsBalance (so prices and
8
+ * metadata are fetched for existing assets as well as new ones)
9
+ * - Includes each account's custom assets from state (so custom tokens get
10
+ * metadata and prices even when they have no balance yet)
11
+ * - Fills response.detectedAssets with these asset IDs per account
12
+ *
13
+ * TokenDataSource and PriceDataSource both key off detectedAssets. TokenDataSource
14
+ * then filters to only fetch metadata for assets that lack it; PriceDataSource
15
+ * fetches prices for all detected assets.
9
16
  *
10
17
  * Usage:
11
18
  * ```typescript
@@ -17,13 +24,12 @@ export declare class DetectionMiddleware {
17
24
  readonly name = "DetectionMiddleware";
18
25
  getName(): string;
19
26
  /**
20
- * Get the middleware for detecting assets without metadata.
27
+ * Get the middleware that builds detectedAssets for metadata and price fetching.
21
28
  *
22
29
  * This middleware:
23
- * 1. Extracts the response from context
24
- * 2. Detects assets from the response that don't have metadata
25
- * 3. Fills response.detectedAssets with detected asset IDs per account
26
- * 4. Calls next() to continue the middleware chain
30
+ * 1. Includes all assets from response.assetsBalance (so prices are fetched for existing assets too)
31
+ * 2. Merges each account's custom assets from state
32
+ * 3. Fills response.detectedAssets with these asset IDs per account
27
33
  *
28
34
  * @returns The middleware function for the assets pipeline.
29
35
  */
@@ -1 +1 @@
1
- {"version":3,"file":"DetectionMiddleware.d.mts","sourceRoot":"","sources":["../../src/middlewares/DetectionMiddleware.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA4B,UAAU,EAAE,qBAAiB;AAerE;;;;;;;;;;;;;GAaG;AACH,qBAAa,mBAAmB;IAC9B,QAAQ,CAAC,IAAI,yBAAmB;IAEhC,OAAO,IAAI,MAAM;IAIjB;;;;;;;;;;OAUG;IACH,IAAI,gBAAgB,IAAI,UAAU,CA2CjC;CACF"}
1
+ {"version":3,"file":"DetectionMiddleware.d.mts","sourceRoot":"","sources":["../../src/middlewares/DetectionMiddleware.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA4B,UAAU,EAAE,qBAAiB;AAerE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,mBAAmB;IAC9B,QAAQ,CAAC,IAAI,yBAAmB;IAEhC,OAAO,IAAI,MAAM;IAIjB;;;;;;;;;OASG;IACH,IAAI,gBAAgB,IAAI,UAAU,CAuDjC;CACF"}
@@ -10,12 +10,19 @@ createModuleLogger(projectLogger, CONTROLLER_NAME);
10
10
  // DETECTION MIDDLEWARE
11
11
  // ============================================================================
12
12
  /**
13
- * DetectionMiddleware identifies assets that do not have metadata.
13
+ * DetectionMiddleware builds the set of assets that downstream sources use for
14
+ * metadata and price fetching.
14
15
  *
15
16
  * This middleware:
16
- * - Checks assets in the response for metadata in state (via ctx.getAssetsState)
17
- * - Assets in response but without metadata are considered "detected"
18
- * - Fills response.detectedAssets with asset IDs per account that lack metadata
17
+ * - Includes every asset that appears in response.assetsBalance (so prices and
18
+ * metadata are fetched for existing assets as well as new ones)
19
+ * - Includes each account's custom assets from state (so custom tokens get
20
+ * metadata and prices even when they have no balance yet)
21
+ * - Fills response.detectedAssets with these asset IDs per account
22
+ *
23
+ * TokenDataSource and PriceDataSource both key off detectedAssets. TokenDataSource
24
+ * then filters to only fetch metadata for assets that lack it; PriceDataSource
25
+ * fetches prices for all detected assets.
19
26
  *
20
27
  * Usage:
21
28
  * ```typescript
@@ -31,45 +38,55 @@ export class DetectionMiddleware {
31
38
  return this.name;
32
39
  }
33
40
  /**
34
- * Get the middleware for detecting assets without metadata.
41
+ * Get the middleware that builds detectedAssets for metadata and price fetching.
35
42
  *
36
43
  * This middleware:
37
- * 1. Extracts the response from context
38
- * 2. Detects assets from the response that don't have metadata
39
- * 3. Fills response.detectedAssets with detected asset IDs per account
40
- * 4. Calls next() to continue the middleware chain
44
+ * 1. Includes all assets from response.assetsBalance (so prices are fetched for existing assets too)
45
+ * 2. Merges each account's custom assets from state
46
+ * 3. Fills response.detectedAssets with these asset IDs per account
41
47
  *
42
48
  * @returns The middleware function for the assets pipeline.
43
49
  */
44
50
  get assetsMiddleware() {
45
51
  return forDataTypes(['balance'], async (ctx, next) => {
46
- // Extract response from context
47
- const { response } = ctx;
48
- // If no balances in response, nothing to detect - pass through
49
- if (!response.assetsBalance) {
50
- return next(ctx);
51
- }
52
- // Get metadata from state
53
- const { assetsInfo: stateMetadata } = ctx.getAssetsState();
52
+ const { request, response } = ctx;
53
+ // Get state for custom assets
54
+ const state = ctx.getAssetsState();
55
+ const { customAssets: stateCustomAssets } = state;
54
56
  const detectedAssets = {};
55
- // Detect assets from the response that don't have metadata
56
- for (const [accountId, accountBalances] of Object.entries(response.assetsBalance)) {
57
- const detected = [];
58
- for (const assetId of Object.keys(accountBalances)) {
59
- // Asset is detected if it does not have metadata in state
60
- if (!stateMetadata[assetId]) {
57
+ // 1. From balance response: include every asset with balance (so prices + metadata path include existing assets)
58
+ if (response.assetsBalance) {
59
+ for (const [accountId, accountBalances] of Object.entries(response.assetsBalance)) {
60
+ const detected = [];
61
+ for (const assetId of Object.keys(accountBalances)) {
61
62
  detected.push(assetId);
62
63
  }
64
+ // Merge this account's custom assets from state
65
+ const customForAccount = stateCustomAssets?.[accountId] ?? [];
66
+ for (const assetId of customForAccount) {
67
+ if (!detected.includes(assetId)) {
68
+ detected.push(assetId);
69
+ }
70
+ }
71
+ if (detected.length > 0) {
72
+ detectedAssets[accountId] = detected;
73
+ }
74
+ }
75
+ }
76
+ // 2. Accounts in request that weren't in balance response: include their custom assets
77
+ for (const { account } of request.accountsWithSupportedChains) {
78
+ const accountId = account.id;
79
+ if (detectedAssets[accountId]) {
80
+ continue;
63
81
  }
64
- if (detected.length > 0) {
65
- detectedAssets[accountId] = detected;
82
+ const customForAccount = stateCustomAssets?.[accountId] ?? [];
83
+ if (customForAccount.length > 0) {
84
+ detectedAssets[accountId] = customForAccount;
66
85
  }
67
86
  }
68
- // Fill detectedAssets in the response
69
87
  if (Object.keys(detectedAssets).length > 0) {
70
88
  response.detectedAssets = detectedAssets;
71
89
  }
72
- // Call next() to continue the middleware chain
73
90
  return next(ctx);
74
91
  });
75
92
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DetectionMiddleware.mjs","sourceRoot":"","sources":["../../src/middlew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,OAAwB,CAAC,EAAE,CAAC;wBAC7C,QAAQ,CAAC,IAAI,CAAC,OAAwB,CAAC,CAAC;oBAC1C,CAAC;gBACH,CAAC;gBAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACxB,cAAc,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC;gBACvC,CAAC;YACH,CAAC;YAED,sCAAsC;YACtC,IAAI,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC3C,QAAQ,CAAC,cAAc,GAAG,cAAc,CAAC;YAC3C,CAAC;YAED,+CAA+C;YAC/C,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { projectLogger, createModuleLogger } from '../logger';\nimport { forDataTypes } from '../types';\nimport type { AccountId, Caip19AssetId, Middleware } from '../types';\n\n// ============================================================================\n// CONSTANTS\n// ============================================================================\n\nconst CONTROLLER_NAME = 'DetectionMiddleware';\n\n// Logger for debugging\ncreateModuleLogger(projectLogger, CONTROLLER_NAME);\n\n// ============================================================================\n// DETECTION MIDDLEWARE\n// ============================================================================\n\n/**\n * DetectionMiddleware identifies assets that do not have metadata.\n *\n * This middleware:\n * - Checks assets in the response for metadata in state (via ctx.getAssetsState)\n * - Assets in response but without metadata are considered \"detected\"\n * - Fills response.detectedAssets with asset IDs per account that lack metadata\n *\n * Usage:\n * ```typescript\n * const detectionMiddleware = new DetectionMiddleware();\n * const middleware = detectionMiddleware.assetsMiddleware;\n * ```\n */\nexport class DetectionMiddleware {\n readonly name = CONTROLLER_NAME;\n\n getName(): string {\n return this.name;\n }\n\n /**\n * Get the middleware for detecting assets without metadata.\n *\n * This middleware:\n * 1. Extracts the response from context\n * 2. Detects assets from the response that don't have metadata\n * 3. Fills response.detectedAssets with detected asset IDs per account\n * 4. Calls next() to continue the middleware chain\n *\n * @returns The middleware function for the assets pipeline.\n */\n get assetsMiddleware(): Middleware {\n return forDataTypes(['balance'], async (ctx, next) => {\n // Extract response from context\n const { response } = ctx;\n\n // If no balances in response, nothing to detect - pass through\n if (!response.assetsBalance) {\n return next(ctx);\n }\n\n // Get metadata from state\n const { assetsInfo: stateMetadata } = ctx.getAssetsState();\n\n const detectedAssets: Record<AccountId, Caip19AssetId[]> = {};\n\n // Detect assets from the response that don't have metadata\n for (const [accountId, accountBalances] of Object.entries(\n response.assetsBalance,\n )) {\n const detected: Caip19AssetId[] = [];\n\n for (const assetId of Object.keys(\n accountBalances as Record<string, unknown>,\n )) {\n // Asset is detected if it does not have metadata in state\n if (!stateMetadata[assetId as Caip19AssetId]) {\n detected.push(assetId as Caip19AssetId);\n }\n }\n\n if (detected.length > 0) {\n detectedAssets[accountId] = detected;\n }\n }\n\n // Fill detectedAssets in the response\n if (Object.keys(detectedAssets).length > 0) {\n response.detectedAssets = detectedAssets;\n }\n\n // Call next() to continue the middleware chain\n return next(ctx);\n });\n }\n}\n"]}
1
+ {"version":3,"file":"DetectionMiddleware.mjs","sourceRoot":"","sources":["../../src/middlewares/DetectionMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,sBAAkB;AAC9D,OAAO,EAAE,YAAY,EAAE,qBAAiB;AAGxC,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,MAAM,eAAe,GAAG,qBAAqB,CAAC;AAE9C,uBAAuB;AACvB,kBAAkB,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;AAEnD,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,mBAAmB;IAAhC;QACW,SAAI,GAAG,eAAe,CAAC;IAwElC,CAAC;IAtEC,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED;;;;;;;;;OASG;IACH,IAAI,gBAAgB;QAClB,OAAO,YAAY,CAA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C;gBAC7B,IAAI,cAAc,CAAC,SAAS,CAAC,EAAE,CAAC;oBAC9B,SAAS;gBACX,CAAC;gBACD,MAAM,gBAAgB,GAAG,iBAAiB,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;gBAC9D,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAChC,cAAc,CAAC,SAAS,CAAC,GAAG,gBAAgB,CAAC;gBAC/C,CAAC;YACH,CAAC;YAED,IAAI,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC3C,QAAQ,CAAC,cAAc,GAAG,cAAc,CAAC;YAC3C,CAAC;YAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { projectLogger, createModuleLogger } from '../logger';\nimport { forDataTypes } from '../types';\nimport type { AccountId, Caip19AssetId, Middleware } from '../types';\n\n// ============================================================================\n// CONSTANTS\n// ============================================================================\n\nconst CONTROLLER_NAME = 'DetectionMiddleware';\n\n// Logger for debugging\ncreateModuleLogger(projectLogger, CONTROLLER_NAME);\n\n// ============================================================================\n// DETECTION MIDDLEWARE\n// ============================================================================\n\n/**\n * DetectionMiddleware builds the set of assets that downstream sources use for\n * metadata and price fetching.\n *\n * This middleware:\n * - Includes every asset that appears in response.assetsBalance (so prices and\n * metadata are fetched for existing assets as well as new ones)\n * - Includes each account's custom assets from state (so custom tokens get\n * metadata and prices even when they have no balance yet)\n * - Fills response.detectedAssets with these asset IDs per account\n *\n * TokenDataSource and PriceDataSource both key off detectedAssets. TokenDataSource\n * then filters to only fetch metadata for assets that lack it; PriceDataSource\n * fetches prices for all detected assets.\n *\n * Usage:\n * ```typescript\n * const detectionMiddleware = new DetectionMiddleware();\n * const middleware = detectionMiddleware.assetsMiddleware;\n * ```\n */\nexport class DetectionMiddleware {\n readonly name = CONTROLLER_NAME;\n\n getName(): string {\n return this.name;\n }\n\n /**\n * Get the middleware that builds detectedAssets for metadata and price fetching.\n *\n * This middleware:\n * 1. Includes all assets from response.assetsBalance (so prices are fetched for existing assets too)\n * 2. Merges each account's custom assets from state\n * 3. Fills response.detectedAssets with these asset IDs per account\n *\n * @returns The middleware function for the assets pipeline.\n */\n get assetsMiddleware(): Middleware {\n return forDataTypes(['balance'], async (ctx, next) => {\n const { request, response } = ctx;\n\n // Get state for custom assets\n const state = ctx.getAssetsState();\n const { customAssets: stateCustomAssets } = state;\n\n const detectedAssets: Record<AccountId, Caip19AssetId[]> = {};\n\n // 1. From balance response: include every asset with balance (so prices + metadata path include existing assets)\n if (response.assetsBalance) {\n for (const [accountId, accountBalances] of Object.entries(\n response.assetsBalance,\n )) {\n const detected: Caip19AssetId[] = [];\n\n for (const assetId of Object.keys(\n accountBalances as Record<string, unknown>,\n )) {\n detected.push(assetId as Caip19AssetId);\n }\n\n // Merge this account's custom assets from state\n const customForAccount = stateCustomAssets?.[accountId] ?? [];\n for (const assetId of customForAccount) {\n if (!detected.includes(assetId)) {\n detected.push(assetId);\n }\n }\n\n if (detected.length > 0) {\n detectedAssets[accountId] = detected;\n }\n }\n }\n\n // 2. Accounts in request that weren't in balance response: include their custom assets\n for (const { account } of request.accountsWithSupportedChains) {\n const accountId = account.id;\n if (detectedAssets[accountId]) {\n continue;\n }\n const customForAccount = stateCustomAssets?.[accountId] ?? [];\n if (customForAccount.length > 0) {\n detectedAssets[accountId] = customForAccount;\n }\n }\n\n if (Object.keys(detectedAssets).length > 0) {\n response.detectedAssets = detectedAssets;\n }\n\n return next(ctx);\n });\n }\n}\n"]}