@metamask-previews/assets-controller 0.0.0-preview-6dfa4aeba → 0.1.0-preview-ce3ee897a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +16 -3
  2. package/dist/AssetsController.cjs +84 -15
  3. package/dist/AssetsController.cjs.map +1 -1
  4. package/dist/AssetsController.d.cts +39 -12
  5. package/dist/AssetsController.d.cts.map +1 -1
  6. package/dist/AssetsController.d.mts +39 -12
  7. package/dist/AssetsController.d.mts.map +1 -1
  8. package/dist/AssetsController.mjs +84 -15
  9. package/dist/AssetsController.mjs.map +1 -1
  10. package/dist/data-sources/RpcDataSource.cjs.map +1 -1
  11. package/dist/data-sources/RpcDataSource.d.cts +0 -7
  12. package/dist/data-sources/RpcDataSource.d.cts.map +1 -1
  13. package/dist/data-sources/RpcDataSource.d.mts +0 -7
  14. package/dist/data-sources/RpcDataSource.d.mts.map +1 -1
  15. package/dist/data-sources/RpcDataSource.mjs.map +1 -1
  16. package/dist/data-sources/evm-rpc-services/clients/MulticallClient.cjs +192 -95
  17. package/dist/data-sources/evm-rpc-services/clients/MulticallClient.cjs.map +1 -1
  18. package/dist/data-sources/evm-rpc-services/clients/MulticallClient.d.cts +22 -1
  19. package/dist/data-sources/evm-rpc-services/clients/MulticallClient.d.cts.map +1 -1
  20. package/dist/data-sources/evm-rpc-services/clients/MulticallClient.d.mts +22 -1
  21. package/dist/data-sources/evm-rpc-services/clients/MulticallClient.d.mts.map +1 -1
  22. package/dist/data-sources/evm-rpc-services/clients/MulticallClient.mjs +192 -95
  23. package/dist/data-sources/evm-rpc-services/clients/MulticallClient.mjs.map +1 -1
  24. package/dist/data-sources/initDataSources.cjs +10 -4
  25. package/dist/data-sources/initDataSources.cjs.map +1 -1
  26. package/dist/data-sources/initDataSources.d.cts +8 -4
  27. package/dist/data-sources/initDataSources.d.cts.map +1 -1
  28. package/dist/data-sources/initDataSources.d.mts +8 -4
  29. package/dist/data-sources/initDataSources.d.mts.map +1 -1
  30. package/dist/data-sources/initDataSources.mjs +10 -4
  31. package/dist/data-sources/initDataSources.mjs.map +1 -1
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.cts +1 -1
  34. package/dist/index.d.cts.map +1 -1
  35. package/dist/index.d.mts +1 -1
  36. package/dist/index.d.mts.map +1 -1
  37. package/dist/index.mjs.map +1 -1
  38. package/dist/types.cjs.map +1 -1
  39. package/dist/types.d.cts +10 -0
  40. package/dist/types.d.cts.map +1 -1
  41. package/dist/types.d.mts +10 -0
  42. package/dist/types.d.mts.map +1 -1
  43. package/dist/types.mjs.map +1 -1
  44. package/package.json +2 -3
@@ -5,48 +5,50 @@ import type { KeyringControllerLockEvent, KeyringControllerUnlockEvent } from "@
5
5
  import type { InternalAccount } from "@metamask/keyring-internal-api";
6
6
  import type { Messenger } from "@metamask/messenger";
7
7
  import type { NetworkEnablementControllerGetStateAction, NetworkEnablementControllerEvents } from "@metamask/network-enablement-controller";
8
- import type { Json } from "@metamask/utils";
9
8
  import type { AccountsApiDataSourceGetAssetsMiddlewareAction } from "./data-sources/AccountsApiDataSource.mjs";
10
9
  import type { PriceDataSourceGetAssetsMiddlewareAction, PriceDataSourceFetchAction, PriceDataSourceSubscribeAction, PriceDataSourceUnsubscribeAction } from "./data-sources/PriceDataSource.mjs";
11
10
  import type { RpcDataSourceGetAssetsMiddlewareAction } from "./data-sources/RpcDataSource.mjs";
12
11
  import type { SnapDataSourceGetAssetsMiddlewareAction } from "./data-sources/SnapDataSource.mjs";
13
12
  import type { TokenDataSourceGetAssetsMiddlewareAction } from "./data-sources/TokenDataSource.mjs";
14
13
  import type { DetectionMiddlewareGetAssetsMiddlewareAction } from "./middlewares/DetectionMiddleware.mjs";
15
- import type { AccountId, ChainId, Caip19AssetId, AssetMetadata, AssetPrice, AssetBalance, AssetType, DataType, DataResponse, DataSourceDefinition, Asset } from "./types.mjs";
14
+ import type { AccountId, AssetPreferences, ChainId, Caip19AssetId, AssetMetadata, AssetPrice, AssetBalance, AssetType, DataType, DataResponse, DataSourceDefinition, Asset } from "./types.mjs";
16
15
  declare const CONTROLLER_NAME: "AssetsController";
17
16
  /**
18
17
  * State structure for AssetsController.
19
18
  *
20
- * All values are JSON-serializable. The type is widened to satisfy
21
- * StateConstraint from BaseController, but the actual runtime values
22
- * conform to AssetMetadata, AssetPrice, and AssetBalance interfaces.
19
+ * All values are JSON-serializable. UI preferences (e.g. hidden) are in
20
+ * assetPreferences, not in metadata.
23
21
  *
24
22
  * @see AssetsControllerStateInternal for the semantic type structure
25
23
  */
26
24
  export type AssetsControllerState = {
27
25
  /** Shared metadata for all assets (stored once per asset) */
28
26
  assetsMetadata: {
29
- [assetId: string]: Json;
27
+ [assetId: string]: AssetMetadata;
30
28
  };
31
29
  /** Per-account balance data */
32
30
  assetsBalance: {
33
31
  [accountId: string]: {
34
- [assetId: string]: Json;
32
+ [assetId: string]: AssetBalance;
35
33
  };
36
34
  };
37
35
  /** Price data for assets */
38
36
  assetsPrice: {
39
- [assetId: string]: Json;
37
+ [assetId: string]: AssetPrice;
40
38
  };
41
39
  /** Custom assets added by users per account (CAIP-19 asset IDs) */
42
40
  customAssets: {
43
- [accountId: string]: string[];
41
+ [accountId: string]: Caip19AssetId[];
42
+ };
43
+ /** UI preferences per asset (e.g. hidden) */
44
+ assetPreferences: {
45
+ [assetId: string]: AssetPreferences;
44
46
  };
45
47
  };
46
48
  /**
47
49
  * Returns the default state for AssetsController.
48
50
  *
49
- * @returns The default AssetsController state with empty metadata, balance, price, and customAssets maps.
51
+ * @returns The default AssetsController state with empty maps.
50
52
  */
51
53
  export declare function getDefaultAssetsControllerState(): AssetsControllerState;
52
54
  export type AssetsControllerGetStateAction = ControllerGetStateAction<typeof CONTROLLER_NAME, AssetsControllerState>;
@@ -86,7 +88,15 @@ export type AssetsControllerGetCustomAssetsAction = {
86
88
  type: `${typeof CONTROLLER_NAME}:getCustomAssets`;
87
89
  handler: AssetsController['getCustomAssets'];
88
90
  };
89
- export type AssetsControllerActions = AssetsControllerGetStateAction | AssetsControllerGetAssetsAction | AssetsControllerGetAssetsBalanceAction | AssetsControllerGetAssetMetadataAction | AssetsControllerGetAssetsPriceAction | AssetsControllerActiveChainsUpdateAction | AssetsControllerAssetsUpdateAction | AssetsControllerAddCustomAssetAction | AssetsControllerRemoveCustomAssetAction | AssetsControllerGetCustomAssetsAction;
91
+ export type AssetsControllerHideAssetAction = {
92
+ type: `${typeof CONTROLLER_NAME}:hideAsset`;
93
+ handler: AssetsController['hideAsset'];
94
+ };
95
+ export type AssetsControllerUnhideAssetAction = {
96
+ type: `${typeof CONTROLLER_NAME}:unhideAsset`;
97
+ handler: AssetsController['unhideAsset'];
98
+ };
99
+ export type AssetsControllerActions = AssetsControllerGetStateAction | AssetsControllerGetAssetsAction | AssetsControllerGetAssetsBalanceAction | AssetsControllerGetAssetMetadataAction | AssetsControllerGetAssetsPriceAction | AssetsControllerActiveChainsUpdateAction | AssetsControllerAssetsUpdateAction | AssetsControllerAddCustomAssetAction | AssetsControllerRemoveCustomAssetAction | AssetsControllerGetCustomAssetsAction | AssetsControllerHideAssetAction | AssetsControllerUnhideAssetAction;
90
100
  export type AssetsControllerStateChangeEvent = ControllerStateChangeEvent<typeof CONTROLLER_NAME, AssetsControllerState>;
91
101
  export type AssetsControllerBalanceChangedEvent = {
92
102
  type: `${typeof CONTROLLER_NAME}:balanceChanged`;
@@ -135,6 +145,8 @@ export type AssetsControllerOptions = {
135
145
  state?: Partial<AssetsControllerState>;
136
146
  /** Default polling interval hint passed to data sources (ms) */
137
147
  defaultUpdateInterval?: number;
148
+ /** Function to determine if the controller is enabled. Defaults to true. */
149
+ isEnabled?: () => boolean;
138
150
  };
139
151
  /**
140
152
  * AssetsController provides a unified interface for managing asset balances
@@ -168,7 +180,7 @@ export type AssetsControllerOptions = {
168
180
  */
169
181
  export declare class AssetsController extends BaseController<typeof CONTROLLER_NAME, AssetsControllerState, AssetsControllerMessenger> {
170
182
  #private;
171
- constructor({ messenger, state, defaultUpdateInterval, }: AssetsControllerOptions);
183
+ constructor({ messenger, state, defaultUpdateInterval, isEnabled, }: AssetsControllerOptions);
172
184
  /**
173
185
  * Register data sources with the controller.
174
186
  * Order of the array determines subscription order.
@@ -209,6 +221,7 @@ export declare class AssetsController extends BaseController<typeof CONTROLLER_N
209
221
  /**
210
222
  * Add a custom asset for an account.
211
223
  * Custom assets are included in subscription and fetch operations.
224
+ * Adding a custom asset also unhides it if it was previously hidden.
212
225
  *
213
226
  * @param accountId - The account ID to add the custom asset for.
214
227
  * @param assetId - The CAIP-19 asset ID to add.
@@ -228,6 +241,20 @@ export declare class AssetsController extends BaseController<typeof CONTROLLER_N
228
241
  * @returns Array of CAIP-19 asset IDs for the account's custom assets.
229
242
  */
230
243
  getCustomAssets(accountId: AccountId): Caip19AssetId[];
244
+ /**
245
+ * Hide an asset globally.
246
+ * Hidden assets are excluded from the asset list returned by getAssets.
247
+ * The hidden state is stored in assetPreferences.
248
+ *
249
+ * @param assetId - The CAIP-19 asset ID to hide.
250
+ */
251
+ hideAsset(assetId: Caip19AssetId): void;
252
+ /**
253
+ * Unhide an asset globally.
254
+ *
255
+ * @param assetId - The CAIP-19 asset ID to unhide.
256
+ */
257
+ unhideAsset(assetId: Caip19AssetId): void;
231
258
  /**
232
259
  * Subscribe to price updates for all assets held by the given accounts.
233
260
  * Polls PriceDataSource which fetches prices from balance state.
@@ -1 +1 @@
1
- {"version":3,"file":"AssetsController.d.mts","sourceRoot":"","sources":["../src/AssetsController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,8DAA8D,EAC9D,oDAAoD,EACrD,0CAA0C;AAC3C,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,KAAK,EACV,0BAA0B,EAC1B,4BAA4B,EAC7B,qCAAqC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE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AQG;IACH,oBAAoB,CAClB,QAAQ,EAAE,eAAe,EAAE,EAC3B,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,GAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAA;KAAO,GACxC,IAAI;IAmCP;;OAEG;IACH,sBAAsB,IAAI,IAAI;IAypB9B;;;;;;OAMG;IACG,kBAAkB,CACtB,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;IA8ChB,OAAO,IAAI,IAAI;CA6BhB"}
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _AssetsController_instances, _AssetsController_defaultUpdateInterval, _AssetsController_controllerMutex, _AssetsController_activeSubscriptions, _AssetsController_enabledChains, _AssetsController_selectedAccounts_get, _AssetsController_dataSources, _AssetsController_initializeState, _AssetsController_extractEnabledChains, _AssetsController_normalizeChainReference, _AssetsController_subscribeToEvents, _AssetsController_registerActionHandlers, _AssetsController_executeMiddlewares, _AssetsController_assignChainsToDataSources, _AssetsController_updateState, _AssetsController_getAssetsFromState, _AssetsController_tokenStandardToAssetType, _AssetsController_start, _AssetsController_stop, _AssetsController_subscribeToDataSources, _AssetsController_subscribeAssetsBalance, _AssetsController_buildChainToAccountsMap, _AssetsController_getAccountsForChains, _AssetsController_subscribeToDataSource, _AssetsController_unsubscribeDataSource, _AssetsController_getEnabledChainsForAccount, _AssetsController_handleAccountGroupChanged, _AssetsController_handleEnabledNetworksChanged, _AssetsController_handleSubscriptionUpdate;
12
+ var _AssetsController_instances, _AssetsController_isEnabled, _AssetsController_defaultUpdateInterval, _AssetsController_controllerMutex, _AssetsController_activeSubscriptions, _AssetsController_enabledChains, _AssetsController_selectedAccounts_get, _AssetsController_dataSources, _AssetsController_initializeState, _AssetsController_extractEnabledChains, _AssetsController_normalizeChainReference, _AssetsController_subscribeToEvents, _AssetsController_registerActionHandlers, _AssetsController_executeMiddlewares, _AssetsController_assignChainsToDataSources, _AssetsController_updateState, _AssetsController_getAssetsFromState, _AssetsController_tokenStandardToAssetType, _AssetsController_start, _AssetsController_stop, _AssetsController_subscribeToDataSources, _AssetsController_subscribeAssetsBalance, _AssetsController_buildChainToAccountsMap, _AssetsController_getAccountsForChains, _AssetsController_subscribeToDataSource, _AssetsController_unsubscribeDataSource, _AssetsController_getEnabledChainsForAccount, _AssetsController_handleAccountGroupChanged, _AssetsController_handleEnabledNetworksChanged, _AssetsController_handleSubscriptionUpdate;
13
13
  import { BaseController } from "@metamask/base-controller";
14
14
  import { parseCaipAssetType } from "@metamask/utils";
15
15
  import { Mutex } from "async-mutex";
@@ -28,7 +28,7 @@ const log = createModuleLogger(projectLogger, CONTROLLER_NAME);
28
28
  /**
29
29
  * Returns the default state for AssetsController.
30
30
  *
31
- * @returns The default AssetsController state with empty metadata, balance, price, and customAssets maps.
31
+ * @returns The default AssetsController state with empty maps.
32
32
  */
33
33
  export function getDefaultAssetsControllerState() {
34
34
  return {
@@ -36,6 +36,7 @@ export function getDefaultAssetsControllerState() {
36
36
  assetsBalance: {},
37
37
  assetsPrice: {},
38
38
  customAssets: {},
39
+ assetPreferences: {},
39
40
  };
40
41
  }
41
42
  // ============================================================================
@@ -66,6 +67,12 @@ const stateMetadata = {
66
67
  includeInDebugSnapshot: false,
67
68
  usedInUi: true,
68
69
  },
70
+ assetPreferences: {
71
+ persist: true,
72
+ includeInStateLogs: false,
73
+ includeInDebugSnapshot: false,
74
+ usedInUi: true,
75
+ },
69
76
  };
70
77
  // ============================================================================
71
78
  // HELPER FUNCTIONS
@@ -155,7 +162,7 @@ function normalizeResponse(response) {
155
162
  * - The controller does NOT manage polling - it simply receives pushed updates
156
163
  */
157
164
  export class AssetsController extends BaseController {
158
- constructor({ messenger, state = {}, defaultUpdateInterval = DEFAULT_POLLING_INTERVAL_MS, }) {
165
+ constructor({ messenger, state = {}, defaultUpdateInterval = DEFAULT_POLLING_INTERVAL_MS, isEnabled = () => true, }) {
159
166
  super({
160
167
  name: CONTROLLER_NAME,
161
168
  messenger,
@@ -166,6 +173,8 @@ export class AssetsController extends BaseController {
166
173
  },
167
174
  });
168
175
  _AssetsController_instances.add(this);
176
+ /** Whether the controller is enabled */
177
+ _AssetsController_isEnabled.set(this, void 0);
169
178
  /** Default update interval hint passed to data sources */
170
179
  _AssetsController_defaultUpdateInterval.set(this, void 0);
171
180
  _AssetsController_controllerMutex.set(this, new Mutex());
@@ -184,7 +193,12 @@ export class AssetsController extends BaseController {
184
193
  * Key: sourceId, Value: Set of currently available chainIds
185
194
  */
186
195
  _AssetsController_dataSources.set(this, new Map());
196
+ __classPrivateFieldSet(this, _AssetsController_isEnabled, isEnabled(), "f");
187
197
  __classPrivateFieldSet(this, _AssetsController_defaultUpdateInterval, defaultUpdateInterval, "f");
198
+ if (!__classPrivateFieldGet(this, _AssetsController_isEnabled, "f")) {
199
+ log('AssetsController is disabled, skipping initialization');
200
+ return;
201
+ }
188
202
  log('Initializing AssetsController', {
189
203
  defaultUpdateInterval,
190
204
  });
@@ -341,6 +355,7 @@ export class AssetsController extends BaseController {
341
355
  /**
342
356
  * Add a custom asset for an account.
343
357
  * Custom assets are included in subscription and fetch operations.
358
+ * Adding a custom asset also unhides it if it was previously hidden.
344
359
  *
345
360
  * @param accountId - The account ID to add the custom asset for.
346
361
  * @param assetId - The CAIP-19 asset ID to add.
@@ -357,6 +372,14 @@ export class AssetsController extends BaseController {
357
372
  if (!customAssets[accountId].includes(normalizedAssetId)) {
358
373
  customAssets[accountId].push(normalizedAssetId);
359
374
  }
375
+ // Unhide the asset if it was hidden (via assetPreferences)
376
+ const prefs = state.assetPreferences[normalizedAssetId];
377
+ if (prefs?.hidden) {
378
+ delete prefs.hidden;
379
+ if (Object.keys(prefs).length === 0) {
380
+ delete state.assetPreferences[normalizedAssetId];
381
+ }
382
+ }
360
383
  });
361
384
  // Fetch data for the newly added custom asset
362
385
  const account = __classPrivateFieldGet(this, _AssetsController_instances, "a", _AssetsController_selectedAccounts_get).find((a) => a.id === accountId);
@@ -378,12 +401,11 @@ export class AssetsController extends BaseController {
378
401
  const normalizedAssetId = normalizeAssetId(assetId);
379
402
  log('Removing custom asset', { accountId, assetId: normalizedAssetId });
380
403
  this.update((state) => {
381
- const customAssets = state.customAssets;
382
- if (customAssets[accountId]) {
383
- customAssets[accountId] = customAssets[accountId].filter((id) => id !== normalizedAssetId);
404
+ if (state.customAssets[accountId]) {
405
+ state.customAssets[accountId] = state.customAssets[accountId].filter((id) => id !== normalizedAssetId);
384
406
  // Clean up empty arrays
385
- if (customAssets[accountId].length === 0) {
386
- delete customAssets[accountId];
407
+ if (state.customAssets[accountId].length === 0) {
408
+ delete state.customAssets[accountId];
387
409
  }
388
410
  }
389
411
  });
@@ -395,7 +417,45 @@ export class AssetsController extends BaseController {
395
417
  * @returns Array of CAIP-19 asset IDs for the account's custom assets.
396
418
  */
397
419
  getCustomAssets(accountId) {
398
- return (this.state.customAssets[accountId] ?? []);
420
+ return this.state.customAssets[accountId] ?? [];
421
+ }
422
+ // ============================================================================
423
+ // HIDDEN ASSETS MANAGEMENT
424
+ // ============================================================================
425
+ /**
426
+ * Hide an asset globally.
427
+ * Hidden assets are excluded from the asset list returned by getAssets.
428
+ * The hidden state is stored in assetPreferences.
429
+ *
430
+ * @param assetId - The CAIP-19 asset ID to hide.
431
+ */
432
+ hideAsset(assetId) {
433
+ const normalizedAssetId = normalizeAssetId(assetId);
434
+ log('Hiding asset', { assetId: normalizedAssetId });
435
+ this.update((state) => {
436
+ if (!state.assetPreferences[normalizedAssetId]) {
437
+ state.assetPreferences[normalizedAssetId] = {};
438
+ }
439
+ state.assetPreferences[normalizedAssetId].hidden = true;
440
+ });
441
+ }
442
+ /**
443
+ * Unhide an asset globally.
444
+ *
445
+ * @param assetId - The CAIP-19 asset ID to unhide.
446
+ */
447
+ unhideAsset(assetId) {
448
+ const normalizedAssetId = normalizeAssetId(assetId);
449
+ log('Unhiding asset', { assetId: normalizedAssetId });
450
+ this.update((state) => {
451
+ const prefs = state.assetPreferences[normalizedAssetId];
452
+ if (prefs) {
453
+ delete prefs.hidden;
454
+ if (Object.keys(prefs).length === 0) {
455
+ delete state.assetPreferences[normalizedAssetId];
456
+ }
457
+ }
458
+ });
399
459
  }
400
460
  /**
401
461
  * Subscribe to price updates for all assets held by the given accounts.
@@ -488,9 +548,11 @@ export class AssetsController extends BaseController {
488
548
  this.messenger.unregisterActionHandler('AssetsController:addCustomAsset');
489
549
  this.messenger.unregisterActionHandler('AssetsController:removeCustomAsset');
490
550
  this.messenger.unregisterActionHandler('AssetsController:getCustomAssets');
551
+ this.messenger.unregisterActionHandler('AssetsController:hideAsset');
552
+ this.messenger.unregisterActionHandler('AssetsController:unhideAsset');
491
553
  }
492
554
  }
493
- _AssetsController_defaultUpdateInterval = new WeakMap(), _AssetsController_controllerMutex = new WeakMap(), _AssetsController_activeSubscriptions = new WeakMap(), _AssetsController_enabledChains = new WeakMap(), _AssetsController_dataSources = new WeakMap(), _AssetsController_instances = new WeakSet(), _AssetsController_selectedAccounts_get = function _AssetsController_selectedAccounts_get() {
555
+ _AssetsController_isEnabled = new WeakMap(), _AssetsController_defaultUpdateInterval = new WeakMap(), _AssetsController_controllerMutex = new WeakMap(), _AssetsController_activeSubscriptions = new WeakMap(), _AssetsController_enabledChains = new WeakMap(), _AssetsController_dataSources = new WeakMap(), _AssetsController_instances = new WeakSet(), _AssetsController_selectedAccounts_get = function _AssetsController_selectedAccounts_get() {
494
556
  return this.messenger.call('AccountTreeController:getAccountsFromSelectedAccountGroup');
495
557
  }, _AssetsController_initializeState = function _AssetsController_initializeState() {
496
558
  const { enabledNetworkMap } = this.messenger.call('NetworkEnablementController:getState');
@@ -549,6 +611,8 @@ _AssetsController_defaultUpdateInterval = new WeakMap(), _AssetsController_contr
549
611
  this.messenger.registerActionHandler('AssetsController:addCustomAsset', this.addCustomAsset.bind(this));
550
612
  this.messenger.registerActionHandler('AssetsController:removeCustomAsset', this.removeCustomAsset.bind(this));
551
613
  this.messenger.registerActionHandler('AssetsController:getCustomAssets', this.getCustomAssets.bind(this));
614
+ this.messenger.registerActionHandler('AssetsController:hideAsset', this.hideAsset.bind(this));
615
+ this.messenger.registerActionHandler('AssetsController:unhideAsset', this.unhideAsset.bind(this));
552
616
  }, _AssetsController_executeMiddlewares =
553
617
  // ============================================================================
554
618
  // MIDDLEWARE EXECUTION
@@ -620,7 +684,7 @@ async function _AssetsController_updateState(response) {
620
684
  const changedBalances = [];
621
685
  const changedMetadata = [];
622
686
  this.update((state) => {
623
- // Use type assertions to avoid deep type instantiation issues with Draft<Json>
687
+ // Use type assertions to avoid deep type instantiation issues with Immer Draft types
624
688
  const metadata = state.assetsMetadata;
625
689
  const balances = state.assetsBalance;
626
690
  const prices = state.assetsPrice;
@@ -731,16 +795,21 @@ async function _AssetsController_updateState(response) {
731
795
  const accountBalances = this.state.assetsBalance[account.id] ?? {};
732
796
  for (const [assetId, balance] of Object.entries(accountBalances)) {
733
797
  const typedAssetId = assetId;
734
- const assetChainId = extractChainId(typedAssetId);
735
- if (!chainIdSet.has(assetChainId)) {
736
- continue;
737
- }
738
798
  const metadataRaw = this.state.assetsMetadata[typedAssetId];
739
799
  // Skip assets without metadata
740
800
  if (!metadataRaw) {
741
801
  continue;
742
802
  }
743
803
  const metadata = metadataRaw;
804
+ // Skip hidden assets (assetPreferences)
805
+ const prefs = this.state.assetPreferences[typedAssetId];
806
+ if (prefs?.hidden) {
807
+ continue;
808
+ }
809
+ const assetChainId = extractChainId(typedAssetId);
810
+ if (!chainIdSet.has(assetChainId)) {
811
+ continue;
812
+ }
744
813
  // Filter by asset type
745
814
  const tokenAssetType = __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_tokenStandardToAssetType).call(this, metadata.type);
746
815
  if (!assetTypeSet.has(tokenAssetType)) {