@metamask-previews/preferences-controller 22.1.0-preview-bc00f2c → 22.1.0-preview-93519965c

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.
package/CHANGELOG.md CHANGED
@@ -11,12 +11,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
11
11
 
12
12
  - Bump `@metamask/controller-utils` from `^11.18.0` to `^11.19.0` ([#7995](https://github.com/MetaMask/core/pull/7995))
13
13
 
14
- ### Removed
15
-
16
- - Remove legacy methods and state ([#8115](https://github.com/MetaMask/core/pull/8115))
17
- - `identities`, `lostIdentities` and `selectedAddress` along with any associated methods were removed.
18
- - `setSmartAccountOptInForAccounts` was also removed as it is deprecated and not used in the clients.
19
-
20
14
  ## [22.1.0]
21
15
 
22
16
  ### Added
@@ -1,7 +1,14 @@
1
1
  "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ 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");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var _PreferencesController_instances, _PreferencesController_syncIdentities;
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
3
9
  exports.PreferencesController = exports.getDefaultPreferencesState = void 0;
4
10
  const base_controller_1 = require("@metamask/base-controller");
11
+ const controller_utils_1 = require("@metamask/controller-utils");
5
12
  const constants_1 = require("./constants.cjs");
6
13
  const metadata = {
7
14
  featureFlags: {
@@ -10,6 +17,12 @@ const metadata = {
10
17
  includeInDebugSnapshot: true,
11
18
  usedInUi: true,
12
19
  },
20
+ identities: {
21
+ includeInStateLogs: true,
22
+ persist: true,
23
+ includeInDebugSnapshot: false,
24
+ usedInUi: true,
25
+ },
13
26
  ipfsGateway: {
14
27
  includeInStateLogs: true,
15
28
  persist: true,
@@ -28,6 +41,12 @@ const metadata = {
28
41
  includeInDebugSnapshot: true,
29
42
  usedInUi: true,
30
43
  },
44
+ lostIdentities: {
45
+ includeInStateLogs: true,
46
+ persist: true,
47
+ includeInDebugSnapshot: false,
48
+ usedInUi: false,
49
+ },
31
50
  displayNftMedia: {
32
51
  includeInStateLogs: true,
33
52
  persist: true,
@@ -40,6 +59,12 @@ const metadata = {
40
59
  includeInDebugSnapshot: true,
41
60
  usedInUi: true,
42
61
  },
62
+ selectedAddress: {
63
+ includeInStateLogs: true,
64
+ persist: true,
65
+ includeInDebugSnapshot: false,
66
+ usedInUi: true,
67
+ },
43
68
  showTestNetworks: {
44
69
  includeInStateLogs: true,
45
70
  persist: true,
@@ -112,6 +137,12 @@ const metadata = {
112
137
  includeInDebugSnapshot: true,
113
138
  usedInUi: true,
114
139
  },
140
+ smartAccountOptInForAccounts: {
141
+ includeInStateLogs: true,
142
+ persist: true,
143
+ includeInDebugSnapshot: true,
144
+ usedInUi: true,
145
+ },
115
146
  tokenNetworkFilter: {
116
147
  includeInStateLogs: true,
117
148
  persist: true,
@@ -128,11 +159,14 @@ const name = 'PreferencesController';
128
159
  function getDefaultPreferencesState() {
129
160
  return {
130
161
  featureFlags: {},
162
+ identities: {},
131
163
  ipfsGateway: 'https://ipfs.io/ipfs/',
132
164
  isIpfsGatewayEnabled: true,
133
165
  isMultiAccountBalancesEnabled: true,
166
+ lostIdentities: {},
134
167
  displayNftMedia: false,
135
168
  securityAlertsEnabled: false,
169
+ selectedAddress: '',
136
170
  showIncomingTransactions: {
137
171
  [constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS.MAINNET]: true,
138
172
  [constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS.GOERLI]: true,
@@ -173,6 +207,7 @@ function getDefaultPreferencesState() {
173
207
  privacyMode: false,
174
208
  dismissSmartAccountSuggestionEnabled: false,
175
209
  smartAccountOptIn: true,
210
+ smartAccountOptInForAccounts: [],
176
211
  tokenNetworkFilter: {},
177
212
  };
178
213
  }
@@ -198,6 +233,72 @@ class PreferencesController extends base_controller_1.BaseController {
198
233
  ...state,
199
234
  },
200
235
  });
236
+ _PreferencesController_instances.add(this);
237
+ messenger.subscribe('KeyringController:stateChange', (keyringState) => {
238
+ const accounts = new Set();
239
+ for (const keyring of keyringState.keyrings) {
240
+ for (const account of keyring.accounts) {
241
+ accounts.add(account);
242
+ }
243
+ }
244
+ if (accounts.size > 0) {
245
+ __classPrivateFieldGet(this, _PreferencesController_instances, "m", _PreferencesController_syncIdentities).call(this, Array.from(accounts));
246
+ }
247
+ });
248
+ }
249
+ /**
250
+ * Adds identities to state.
251
+ *
252
+ * @param addresses - List of addresses to use to generate new identities.
253
+ */
254
+ addIdentities(addresses) {
255
+ const checksummedAddresses = addresses.map((address) => (0, controller_utils_1.toChecksumHexAddress)(address));
256
+ this.update((state) => {
257
+ const { identities } = state;
258
+ for (const address of checksummedAddresses) {
259
+ if (identities[address]) {
260
+ continue;
261
+ }
262
+ const identityCount = Object.keys(identities).length;
263
+ identities[address] = {
264
+ name: `Account ${identityCount + 1}`,
265
+ address,
266
+ importTime: Date.now(),
267
+ };
268
+ }
269
+ });
270
+ }
271
+ /**
272
+ * Removes an identity from state.
273
+ *
274
+ * @param address - Address of the identity to remove.
275
+ */
276
+ removeIdentity(address) {
277
+ const checksumAddress = (0, controller_utils_1.toChecksumHexAddress)(address);
278
+ const { identities } = this.state;
279
+ if (!identities[checksumAddress]) {
280
+ return;
281
+ }
282
+ this.update((state) => {
283
+ delete state.identities[checksumAddress];
284
+ if (checksumAddress === state.selectedAddress) {
285
+ state.selectedAddress = Object.keys(state.identities)[0];
286
+ }
287
+ });
288
+ }
289
+ /**
290
+ * Associates a new label with an identity.
291
+ *
292
+ * @param address - Address of the identity to associate.
293
+ * @param label - New label to assign.
294
+ */
295
+ setAccountLabel(address, label) {
296
+ const checksumAddress = (0, controller_utils_1.toChecksumHexAddress)(address);
297
+ this.update((state) => {
298
+ const identity = state.identities[checksumAddress] || {};
299
+ identity.name = label;
300
+ state.identities[checksumAddress] = identity;
301
+ });
201
302
  }
202
303
  /**
203
304
  * Enable or disable a specific feature flag.
@@ -210,6 +311,16 @@ class PreferencesController extends base_controller_1.BaseController {
210
311
  state.featureFlags[feature] = activated;
211
312
  });
212
313
  }
314
+ /**
315
+ * Sets selected address.
316
+ *
317
+ * @param selectedAddress - Ethereum address.
318
+ */
319
+ setSelectedAddress(selectedAddress) {
320
+ this.update((state) => {
321
+ state.selectedAddress = (0, controller_utils_1.toChecksumHexAddress)(selectedAddress);
322
+ });
323
+ }
213
324
  /**
214
325
  * Sets new IPFS gateway.
215
326
  *
@@ -396,6 +507,18 @@ class PreferencesController extends base_controller_1.BaseController {
396
507
  state.smartAccountOptIn = smartAccountOptIn;
397
508
  });
398
509
  }
510
+ /**
511
+ * Add account to list of accounts for which user has optedin
512
+ * smart account upgrade.
513
+ *
514
+ * @param accounts - accounts for which user wants to optin for smart account upgrade
515
+ * @deprecated This method is deprecated and will be removed in the future.
516
+ */
517
+ setSmartAccountOptInForAccounts(accounts = []) {
518
+ this.update((state) => {
519
+ state.smartAccountOptInForAccounts = accounts;
520
+ });
521
+ }
399
522
  /**
400
523
  * Set the token network filter configuration setting.
401
524
  *
@@ -408,5 +531,27 @@ class PreferencesController extends base_controller_1.BaseController {
408
531
  }
409
532
  }
410
533
  exports.PreferencesController = PreferencesController;
534
+ _PreferencesController_instances = new WeakSet(), _PreferencesController_syncIdentities = function _PreferencesController_syncIdentities(addresses) {
535
+ const checksumAddresses = addresses.map((address) => (0, controller_utils_1.toChecksumHexAddress)(address));
536
+ this.update((state) => {
537
+ const { identities } = state;
538
+ const newlyLost = {};
539
+ for (const [address, identity] of Object.entries(identities)) {
540
+ if (!checksumAddresses.includes(address)) {
541
+ newlyLost[address] = identity;
542
+ delete identities[address];
543
+ }
544
+ }
545
+ for (const [address, identity] of Object.entries(newlyLost)) {
546
+ state.lostIdentities[address] = identity;
547
+ }
548
+ });
549
+ this.addIdentities(checksumAddresses);
550
+ if (!checksumAddresses.includes(this.state.selectedAddress)) {
551
+ this.update((state) => {
552
+ state.selectedAddress = checksumAddresses[0];
553
+ });
554
+ }
555
+ };
411
556
  exports.default = PreferencesController;
412
557
  //# sourceMappingURL=PreferencesController.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"PreferencesController.cjs","sourceRoot":"","sources":["../src/PreferencesController.ts"],"names":[],"mappings":";;;AAAA,+DAA2D;AAO3D,+CAA4D;AA0G5D,MAAM,QAAQ,GAAG;IACf,YAAY,EAAE;QACZ,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KACf;IACD,WAAW,EAAE;QACX,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,IAAI;KACf;IACD,oBAAoB,EAAE;QACpB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KACf;IACD,6BAA6B,EAAE;QAC7B,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KACf;IACD,eAAe,EAAE;QACf,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KACf;IACD,qBAAqB,EAAE;QACrB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KACf;IACD,gBAAgB,EAAE;QAChB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KACf;IACD,wBAAwB,E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IACH,qBAAqB,CAAC,kBAA2C;QAC/D,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAChD,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAxQD,sDAwQC;AAED,kBAAe,qBAAqB,CAAC","sourcesContent":["import { BaseController } from '@metamask/base-controller';\nimport type {\n ControllerStateChangeEvent,\n ControllerGetStateAction,\n} from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\n\nimport { ETHERSCAN_SUPPORTED_CHAIN_IDS } from './constants';\n\n/**\n * A type union of the name for each chain that is supported by Etherscan or\n * an Etherscan-compatible service.\n */\nexport type EtherscanSupportedChains =\n keyof typeof ETHERSCAN_SUPPORTED_CHAIN_IDS;\n\n/**\n * A type union of the chain ID for each chain that is supported by Etherscan\n * or an Etherscan-compatible service.\n */\nexport type EtherscanSupportedHexChainId =\n (typeof ETHERSCAN_SUPPORTED_CHAIN_IDS)[EtherscanSupportedChains];\n\ntype TokenSortConfig = {\n key: string;\n order: 'asc' | 'dsc';\n sortCallback: string;\n};\n\n/**\n * Preferences controller state\n */\nexport type PreferencesState = {\n /**\n * Map of specific features to enable or disable\n */\n featureFlags: { [feature: string]: boolean };\n /**\n * The configured IPFS gateway\n */\n ipfsGateway: string;\n /**\n * Controls whether IPFS is enabled or not\n */\n isIpfsGatewayEnabled: boolean;\n /**\n * Controls whether multi-account balances are enabled or not\n */\n isMultiAccountBalancesEnabled: boolean;\n /**\n * Controls whether the OpenSea API is used\n */\n displayNftMedia: boolean;\n /**\n * Controls whether \"security alerts\" are enabled\n */\n securityAlertsEnabled: boolean;\n /**\n * Controls whether incoming transactions are enabled, per-chain (for Etherscan-supported chains)\n */\n showIncomingTransactions: {\n [chainId in EtherscanSupportedHexChainId]: boolean;\n };\n /**\n * Controls whether test networks are shown in the wallet\n */\n showTestNetworks: boolean;\n /**\n * Controls whether NFT detection is enabled\n */\n useNftDetection: boolean;\n /**\n * Controls whether token detection is enabled\n */\n useTokenDetection: boolean;\n /**\n * Controls whether smart transactions are opted into\n */\n smartTransactionsOptInStatus: boolean;\n /**\n * Controls whether transaction simulations are enabled\n */\n useTransactionSimulations: boolean;\n /**\n * Controls whether Multi rpc modal is displayed or not\n */\n showMultiRpcModal: boolean;\n /**\n * Controls whether to use the safe chains list validation\n */\n useSafeChainsListValidation: boolean;\n /**\n * Controls which order tokens are sorted in\n */\n tokenSortConfig: TokenSortConfig;\n /**\n * Controls whether balance and assets are hidden or not\n */\n privacyMode: boolean;\n /**\n * Allow user to stop being prompted for smart account upgrade\n */\n dismissSmartAccountSuggestionEnabled: boolean;\n /**\n * User to opt in for smart account upgrade for all user accounts.\n */\n smartAccountOptIn: boolean;\n /**\n * Controls token filtering controls\n */\n tokenNetworkFilter: Record<string, boolean>;\n};\n\nconst metadata = {\n featureFlags: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n ipfsGateway: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n isIpfsGatewayEnabled: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n isMultiAccountBalancesEnabled: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n displayNftMedia: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n securityAlertsEnabled: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n showTestNetworks: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n showIncomingTransactions: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n useNftDetection: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n useTokenDetection: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n smartTransactionsOptInStatus: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n useTransactionSimulations: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n showMultiRpcModal: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n useSafeChainsListValidation: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n tokenSortConfig: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n privacyMode: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n dismissSmartAccountSuggestionEnabled: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n smartAccountOptIn: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n tokenNetworkFilter: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n};\n\nconst name = 'PreferencesController';\n\nexport type PreferencesControllerGetStateAction = ControllerGetStateAction<\n typeof name,\n PreferencesState\n>;\n\nexport type PreferencesControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof name,\n PreferencesState\n>;\n\nexport type PreferencesControllerActions = PreferencesControllerGetStateAction;\n\nexport type PreferencesControllerEvents = PreferencesControllerStateChangeEvent;\n\nexport type PreferencesControllerMessenger = Messenger<\n typeof name,\n PreferencesControllerActions,\n PreferencesControllerEvents\n>;\n\n/**\n * Get the default PreferencesController state.\n *\n * @returns The default PreferencesController state.\n */\nexport function getDefaultPreferencesState(): PreferencesState {\n return {\n featureFlags: {},\n ipfsGateway: 'https://ipfs.io/ipfs/',\n isIpfsGatewayEnabled: true,\n isMultiAccountBalancesEnabled: true,\n displayNftMedia: false,\n securityAlertsEnabled: false,\n showIncomingTransactions: {\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.MAINNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.GOERLI]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.BSC]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.BSC_TESTNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.OPTIMISM]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.OPTIMISM_SEPOLIA]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.POLYGON]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.POLYGON_TESTNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.AVALANCHE]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.AVALANCHE_TESTNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.FANTOM]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.FANTOM_TESTNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.SEPOLIA]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.LINEA_GOERLI]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.LINEA_SEPOLIA]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.LINEA_MAINNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.MOONBEAM]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.MOONBEAM_TESTNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.MOONRIVER]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.GNOSIS]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.SEI]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.MONAD]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.HYPEREVM]: true,\n },\n showTestNetworks: false,\n useNftDetection: false,\n useTokenDetection: true,\n showMultiRpcModal: false,\n smartTransactionsOptInStatus: true,\n useTransactionSimulations: true,\n useSafeChainsListValidation: true,\n tokenSortConfig: {\n key: 'tokenFiatAmount',\n order: 'dsc',\n sortCallback: 'stringNumeric',\n },\n privacyMode: false,\n dismissSmartAccountSuggestionEnabled: false,\n smartAccountOptIn: true,\n tokenNetworkFilter: {},\n };\n}\n\n/**\n * Controller that stores shared settings and exposes convenience methods\n */\nexport class PreferencesController extends BaseController<\n typeof name,\n PreferencesState,\n PreferencesControllerMessenger\n> {\n /**\n * Creates a PreferencesController instance.\n *\n * @param args - Arguments\n * @param args.messenger - The preferences controller messenger.\n * @param args.state - Preferences controller state.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: PreferencesControllerMessenger;\n state?: Partial<PreferencesState>;\n }) {\n super({\n name,\n metadata,\n messenger,\n state: {\n ...getDefaultPreferencesState(),\n ...state,\n },\n });\n }\n\n /**\n * Enable or disable a specific feature flag.\n *\n * @param feature - Feature to toggle.\n * @param activated - Value to assign.\n */\n setFeatureFlag(feature: string, activated: boolean): void {\n this.update((state) => {\n state.featureFlags[feature] = activated;\n });\n }\n\n /**\n * Sets new IPFS gateway.\n *\n * @param ipfsGateway - IPFS gateway string.\n */\n setIpfsGateway(ipfsGateway: string): void {\n this.update((state) => {\n state.ipfsGateway = ipfsGateway;\n });\n }\n\n /**\n * Toggle the token detection setting.\n *\n * @param useTokenDetection - Boolean indicating user preference on token detection.\n */\n setUseTokenDetection(useTokenDetection: boolean): void {\n this.update((state) => {\n state.useTokenDetection = useTokenDetection;\n });\n }\n\n /**\n * Toggle the NFT detection setting.\n *\n * @param useNftDetection - Boolean indicating user preference on NFT detection.\n */\n setUseNftDetection(useNftDetection: boolean): void {\n if (useNftDetection && !this.state.displayNftMedia) {\n throw new Error(\n 'useNftDetection cannot be enabled if displayNftMedia is false',\n );\n }\n this.update((state) => {\n state.useNftDetection = useNftDetection;\n });\n }\n\n /**\n * Toggle the display nft media enabled setting.\n *\n * @param displayNftMedia - Boolean indicating user preference on using OpenSea's API.\n */\n setDisplayNftMedia(displayNftMedia: boolean): void {\n this.update((state) => {\n state.displayNftMedia = displayNftMedia;\n if (!displayNftMedia) {\n state.useNftDetection = false;\n }\n });\n }\n\n /**\n * Toggle the security alert enabled setting.\n *\n * @param securityAlertsEnabled - Boolean indicating user preference on using security alerts.\n */\n setSecurityAlertsEnabled(securityAlertsEnabled: boolean): void {\n this.update((state) => {\n state.securityAlertsEnabled = securityAlertsEnabled;\n });\n }\n\n /**\n * A setter for the user preferences to enable/disable fetch of multiple accounts balance.\n *\n * @param isMultiAccountBalancesEnabled - true to enable multiple accounts balance fetch, false to fetch only selectedAddress.\n */\n setIsMultiAccountBalancesEnabled(\n isMultiAccountBalancesEnabled: boolean,\n ): void {\n this.update((state) => {\n state.isMultiAccountBalancesEnabled = isMultiAccountBalancesEnabled;\n });\n }\n\n /**\n * A setter for the user have the test networks visible/hidden.\n *\n * @param showTestNetworks - true to show test networks, false to hidden.\n */\n setShowTestNetworks(showTestNetworks: boolean): void {\n this.update((state) => {\n state.showTestNetworks = showTestNetworks;\n });\n }\n\n /**\n * A setter for the user allow to be fetched IPFS content\n *\n * @param isIpfsGatewayEnabled - true to enable ipfs source\n */\n setIsIpfsGatewayEnabled(isIpfsGatewayEnabled: boolean): void {\n this.update((state) => {\n state.isIpfsGatewayEnabled = isIpfsGatewayEnabled;\n });\n }\n\n /**\n * A setter for the user allow to be fetched IPFS content\n *\n * @param chainId - On hexadecimal format to enable the incoming transaction network\n * @param isIncomingTransactionNetworkEnable - true to enable incoming transactions\n */\n setEnableNetworkIncomingTransactions(\n chainId: EtherscanSupportedHexChainId,\n isIncomingTransactionNetworkEnable: boolean,\n ): void {\n if (Object.values(ETHERSCAN_SUPPORTED_CHAIN_IDS).includes(chainId)) {\n this.update((state) => {\n state.showIncomingTransactions = {\n ...this.state.showIncomingTransactions,\n [chainId]: isIncomingTransactionNetworkEnable,\n };\n });\n }\n }\n\n /**\n * Toggle multi rpc migration modal.\n *\n * @param showMultiRpcModal - Boolean indicating if the multi rpc modal will be displayed or not.\n */\n setShowMultiRpcModal(showMultiRpcModal: boolean): void {\n this.update((state) => {\n state.showMultiRpcModal = showMultiRpcModal;\n if (!showMultiRpcModal) {\n state.showMultiRpcModal = false;\n }\n });\n }\n\n /**\n * A setter for the user to opt into smart transactions\n *\n * @param smartTransactionsOptInStatus - true to opt into smart transactions\n */\n setSmartTransactionsOptInStatus(smartTransactionsOptInStatus: boolean): void {\n this.update((state) => {\n state.smartTransactionsOptInStatus = smartTransactionsOptInStatus;\n });\n }\n\n /**\n * A setter for the user preferences to enable/disable transaction simulations.\n *\n * @param useTransactionSimulations - true to enable transaction simulations, false to disable it.\n */\n setUseTransactionSimulations(useTransactionSimulations: boolean): void {\n this.update((state) => {\n state.useTransactionSimulations = useTransactionSimulations;\n });\n }\n\n /**\n * A setter to update the user's preferred token sorting order.\n *\n * @param tokenSortConfig - a configuration representing the sort order of tokens.\n */\n setTokenSortConfig(tokenSortConfig: TokenSortConfig): void {\n this.update((state) => {\n state.tokenSortConfig = tokenSortConfig;\n });\n }\n\n /**\n * A setter for the user preferences to enable/disable safe chains list validation.\n *\n * @param useSafeChainsListValidation - true to enable safe chains list validation, false to disable it.\n */\n setUseSafeChainsListValidation(useSafeChainsListValidation: boolean): void {\n this.update((state) => {\n state.useSafeChainsListValidation = useSafeChainsListValidation;\n });\n }\n\n /**\n * A setter for the user preferences to enable/disable privacy mode.\n *\n * @param privacyMode - true to enable privacy mode, false to disable it.\n */\n setPrivacyMode(privacyMode: boolean): void {\n this.update((state) => {\n state.privacyMode = privacyMode;\n });\n }\n\n /**\n * A setter for the user preferences dismiss smart account upgrade prompt.\n *\n * @param dismissSmartAccountSuggestionEnabled - true to dismiss smart account upgrade prompt, false to enable it.\n */\n setDismissSmartAccountSuggestionEnabled(\n dismissSmartAccountSuggestionEnabled: boolean,\n ): void {\n this.update((state) => {\n state.dismissSmartAccountSuggestionEnabled =\n dismissSmartAccountSuggestionEnabled;\n });\n }\n\n /**\n * A setter for the user preferences smart account OptIn.\n *\n * @param smartAccountOptIn - true if user opts in for smart account update, false otherwise.\n */\n setSmartAccountOptIn(smartAccountOptIn: boolean): void {\n this.update((state) => {\n state.smartAccountOptIn = smartAccountOptIn;\n });\n }\n\n /**\n * Set the token network filter configuration setting.\n *\n * @param tokenNetworkFilter - Object describing token network filter configuration.\n */\n setTokenNetworkFilter(tokenNetworkFilter: Record<string, boolean>): void {\n this.update((state) => {\n state.tokenNetworkFilter = tokenNetworkFilter;\n });\n }\n}\n\nexport default PreferencesController;\n"]}
1
+ {"version":3,"file":"PreferencesController.cjs","sourceRoot":"","sources":["../src/PreferencesController.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+DAA2D;AAK3D,iEAAkE;AAQlE,+CAA4D;AA8I5D,MAAM,QAAQ,GAAG;IACf,YAAY,EAAE;QACZ,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KACf;IACD,UAAU,EAAE;QACV,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,IAAI;KACf;IACD,WAAW,EAAE;QACX,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,IAAI;KACf;IACD,oBAAoB,EAAE;QACpB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KACf;IACD,6BAA6B,EAAE;QAC7B,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KACf;IACD,cAAc,EAAE;QACd,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,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AE,UAAU,EAAE,GAAG,KAAK,CAAC;QAC7B,MAAM,SAAS,GAAoC,EAAE,CAAC;QAEtD,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7D,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBACzC,SAAS,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC;gBAC9B,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;QAED,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5D,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC;QAC3C,CAAC;IACH,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAEtC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE,CAAC;QAC5D,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,eAAe,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AA0PH,kBAAe,qBAAqB,CAAC","sourcesContent":["import { BaseController } from '@metamask/base-controller';\nimport type {\n ControllerStateChangeEvent,\n ControllerGetStateAction,\n} from '@metamask/base-controller';\nimport { toChecksumHexAddress } from '@metamask/controller-utils';\nimport type {\n KeyringControllerState,\n KeyringControllerStateChangeEvent,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type { Hex } from '@metamask/utils';\n\nimport { ETHERSCAN_SUPPORTED_CHAIN_IDS } from './constants';\n\n/**\n * A representation of a MetaMask identity\n */\nexport type Identity = {\n /**\n * The address of the identity\n */\n address: string;\n /**\n * The timestamp for when this identity was first added\n */\n importTime?: number;\n /**\n * The name of the identity\n */\n name: string;\n};\n\n/**\n * A type union of the name for each chain that is supported by Etherscan or\n * an Etherscan-compatible service.\n */\nexport type EtherscanSupportedChains =\n keyof typeof ETHERSCAN_SUPPORTED_CHAIN_IDS;\n\n/**\n * A type union of the chain ID for each chain that is supported by Etherscan\n * or an Etherscan-compatible service.\n */\nexport type EtherscanSupportedHexChainId =\n (typeof ETHERSCAN_SUPPORTED_CHAIN_IDS)[EtherscanSupportedChains];\n\ntype TokenSortConfig = {\n key: string;\n order: 'asc' | 'dsc';\n sortCallback: string;\n};\n\n/**\n * Preferences controller state\n */\nexport type PreferencesState = {\n /**\n * Map of specific features to enable or disable\n */\n featureFlags: { [feature: string]: boolean };\n /**\n * Map of addresses to Identity objects\n */\n identities: { [address: string]: Identity };\n /**\n * The configured IPFS gateway\n */\n ipfsGateway: string;\n /**\n * Controls whether IPFS is enabled or not\n */\n isIpfsGatewayEnabled: boolean;\n /**\n * Controls whether multi-account balances are enabled or not\n */\n isMultiAccountBalancesEnabled: boolean;\n /**\n * Map of lost addresses to Identity objects\n */\n lostIdentities: { [address: string]: Identity };\n /**\n * Controls whether the OpenSea API is used\n */\n displayNftMedia: boolean;\n /**\n * Controls whether \"security alerts\" are enabled\n */\n securityAlertsEnabled: boolean;\n /**\n * The current selected address\n */\n selectedAddress: string;\n /**\n * Controls whether incoming transactions are enabled, per-chain (for Etherscan-supported chains)\n */\n showIncomingTransactions: {\n [chainId in EtherscanSupportedHexChainId]: boolean;\n };\n /**\n * Controls whether test networks are shown in the wallet\n */\n showTestNetworks: boolean;\n /**\n * Controls whether NFT detection is enabled\n */\n useNftDetection: boolean;\n /**\n * Controls whether token detection is enabled\n */\n useTokenDetection: boolean;\n /**\n * Controls whether smart transactions are opted into\n */\n smartTransactionsOptInStatus: boolean;\n /**\n * Controls whether transaction simulations are enabled\n */\n useTransactionSimulations: boolean;\n /**\n * Controls whether Multi rpc modal is displayed or not\n */\n showMultiRpcModal: boolean;\n /**\n * Controls whether to use the safe chains list validation\n */\n useSafeChainsListValidation: boolean;\n /**\n * Controls which order tokens are sorted in\n */\n tokenSortConfig: TokenSortConfig;\n /**\n * Controls whether balance and assets are hidden or not\n */\n privacyMode: boolean;\n /**\n * Allow user to stop being prompted for smart account upgrade\n */\n dismissSmartAccountSuggestionEnabled: boolean;\n /**\n * User to opt in for smart account upgrade for all user accounts.\n */\n smartAccountOptIn: boolean;\n /**\n * User to opt in for smart account upgrade for specific accounts.\n *\n * @deprecated This preference is deprecated and will be removed in the future.\n */\n smartAccountOptInForAccounts: Hex[];\n /**\n * Controls token filtering controls\n */\n tokenNetworkFilter: Record<string, boolean>;\n};\n\nconst metadata = {\n featureFlags: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n identities: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n ipfsGateway: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n isIpfsGatewayEnabled: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n isMultiAccountBalancesEnabled: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n lostIdentities: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: false,\n },\n displayNftMedia: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n securityAlertsEnabled: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n selectedAddress: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n showTestNetworks: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n showIncomingTransactions: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n useNftDetection: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n useTokenDetection: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n smartTransactionsOptInStatus: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n useTransactionSimulations: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n showMultiRpcModal: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n useSafeChainsListValidation: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n tokenSortConfig: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n privacyMode: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n dismissSmartAccountSuggestionEnabled: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n smartAccountOptIn: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n smartAccountOptInForAccounts: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n tokenNetworkFilter: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n};\n\nconst name = 'PreferencesController';\n\nexport type PreferencesControllerGetStateAction = ControllerGetStateAction<\n typeof name,\n PreferencesState\n>;\n\nexport type PreferencesControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof name,\n PreferencesState\n>;\n\nexport type PreferencesControllerActions = PreferencesControllerGetStateAction;\n\nexport type PreferencesControllerEvents = PreferencesControllerStateChangeEvent;\n\ntype AllowedEvents = KeyringControllerStateChangeEvent;\n\nexport type PreferencesControllerMessenger = Messenger<\n typeof name,\n PreferencesControllerActions,\n PreferencesControllerEvents | AllowedEvents\n>;\n\n/**\n * Get the default PreferencesController state.\n *\n * @returns The default PreferencesController state.\n */\nexport function getDefaultPreferencesState(): PreferencesState {\n return {\n featureFlags: {},\n identities: {},\n ipfsGateway: 'https://ipfs.io/ipfs/',\n isIpfsGatewayEnabled: true,\n isMultiAccountBalancesEnabled: true,\n lostIdentities: {},\n displayNftMedia: false,\n securityAlertsEnabled: false,\n selectedAddress: '',\n showIncomingTransactions: {\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.MAINNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.GOERLI]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.BSC]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.BSC_TESTNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.OPTIMISM]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.OPTIMISM_SEPOLIA]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.POLYGON]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.POLYGON_TESTNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.AVALANCHE]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.AVALANCHE_TESTNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.FANTOM]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.FANTOM_TESTNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.SEPOLIA]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.LINEA_GOERLI]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.LINEA_SEPOLIA]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.LINEA_MAINNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.MOONBEAM]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.MOONBEAM_TESTNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.MOONRIVER]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.GNOSIS]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.SEI]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.MONAD]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.HYPEREVM]: true,\n },\n showTestNetworks: false,\n useNftDetection: false,\n useTokenDetection: true,\n showMultiRpcModal: false,\n smartTransactionsOptInStatus: true,\n useTransactionSimulations: true,\n useSafeChainsListValidation: true,\n tokenSortConfig: {\n key: 'tokenFiatAmount',\n order: 'dsc',\n sortCallback: 'stringNumeric',\n },\n privacyMode: false,\n dismissSmartAccountSuggestionEnabled: false,\n smartAccountOptIn: true,\n smartAccountOptInForAccounts: [],\n tokenNetworkFilter: {},\n };\n}\n\n/**\n * Controller that stores shared settings and exposes convenience methods\n */\nexport class PreferencesController extends BaseController<\n typeof name,\n PreferencesState,\n PreferencesControllerMessenger\n> {\n /**\n * Creates a PreferencesController instance.\n *\n * @param args - Arguments\n * @param args.messenger - The preferences controller messenger.\n * @param args.state - Preferences controller state.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: PreferencesControllerMessenger;\n state?: Partial<PreferencesState>;\n }) {\n super({\n name,\n metadata,\n messenger,\n state: {\n ...getDefaultPreferencesState(),\n ...state,\n },\n });\n\n messenger.subscribe(\n 'KeyringController:stateChange',\n (keyringState: KeyringControllerState) => {\n const accounts = new Set<string>();\n for (const keyring of keyringState.keyrings) {\n for (const account of keyring.accounts) {\n accounts.add(account);\n }\n }\n if (accounts.size > 0) {\n this.#syncIdentities(Array.from(accounts));\n }\n },\n );\n }\n\n /**\n * Adds identities to state.\n *\n * @param addresses - List of addresses to use to generate new identities.\n */\n addIdentities(addresses: string[]): void {\n const checksummedAddresses = addresses.map((address) =>\n toChecksumHexAddress(address),\n );\n this.update((state) => {\n const { identities } = state;\n for (const address of checksummedAddresses) {\n if (identities[address]) {\n continue;\n }\n const identityCount = Object.keys(identities).length;\n\n identities[address] = {\n name: `Account ${identityCount + 1}`,\n address,\n importTime: Date.now(),\n };\n }\n });\n }\n\n /**\n * Removes an identity from state.\n *\n * @param address - Address of the identity to remove.\n */\n removeIdentity(address: string): void {\n const checksumAddress = toChecksumHexAddress(address);\n const { identities } = this.state;\n if (!identities[checksumAddress]) {\n return;\n }\n this.update((state) => {\n delete state.identities[checksumAddress];\n if (checksumAddress === state.selectedAddress) {\n state.selectedAddress = Object.keys(state.identities)[0];\n }\n });\n }\n\n /**\n * Associates a new label with an identity.\n *\n * @param address - Address of the identity to associate.\n * @param label - New label to assign.\n */\n setAccountLabel(address: string, label: string): void {\n const checksumAddress = toChecksumHexAddress(address);\n this.update((state) => {\n const identity = state.identities[checksumAddress] || {};\n identity.name = label;\n state.identities[checksumAddress] = identity;\n });\n }\n\n /**\n * Enable or disable a specific feature flag.\n *\n * @param feature - Feature to toggle.\n * @param activated - Value to assign.\n */\n setFeatureFlag(feature: string, activated: boolean): void {\n this.update((state) => {\n state.featureFlags[feature] = activated;\n });\n }\n\n /**\n * Synchronizes the current identity list with new identities.\n *\n * @param addresses - List of addresses corresponding to identities to sync.\n */\n #syncIdentities(addresses: string[]): void {\n const checksumAddresses = addresses.map((address: string) =>\n toChecksumHexAddress(address),\n );\n\n this.update((state) => {\n const { identities } = state;\n const newlyLost: { [address: string]: Identity } = {};\n\n for (const [address, identity] of Object.entries(identities)) {\n if (!checksumAddresses.includes(address)) {\n newlyLost[address] = identity;\n delete identities[address];\n }\n }\n\n for (const [address, identity] of Object.entries(newlyLost)) {\n state.lostIdentities[address] = identity;\n }\n });\n this.addIdentities(checksumAddresses);\n\n if (!checksumAddresses.includes(this.state.selectedAddress)) {\n this.update((state) => {\n state.selectedAddress = checksumAddresses[0];\n });\n }\n }\n\n /**\n * Sets selected address.\n *\n * @param selectedAddress - Ethereum address.\n */\n setSelectedAddress(selectedAddress: string): void {\n this.update((state) => {\n state.selectedAddress = toChecksumHexAddress(selectedAddress);\n });\n }\n\n /**\n * Sets new IPFS gateway.\n *\n * @param ipfsGateway - IPFS gateway string.\n */\n setIpfsGateway(ipfsGateway: string): void {\n this.update((state) => {\n state.ipfsGateway = ipfsGateway;\n });\n }\n\n /**\n * Toggle the token detection setting.\n *\n * @param useTokenDetection - Boolean indicating user preference on token detection.\n */\n setUseTokenDetection(useTokenDetection: boolean): void {\n this.update((state) => {\n state.useTokenDetection = useTokenDetection;\n });\n }\n\n /**\n * Toggle the NFT detection setting.\n *\n * @param useNftDetection - Boolean indicating user preference on NFT detection.\n */\n setUseNftDetection(useNftDetection: boolean): void {\n if (useNftDetection && !this.state.displayNftMedia) {\n throw new Error(\n 'useNftDetection cannot be enabled if displayNftMedia is false',\n );\n }\n this.update((state) => {\n state.useNftDetection = useNftDetection;\n });\n }\n\n /**\n * Toggle the display nft media enabled setting.\n *\n * @param displayNftMedia - Boolean indicating user preference on using OpenSea's API.\n */\n setDisplayNftMedia(displayNftMedia: boolean): void {\n this.update((state) => {\n state.displayNftMedia = displayNftMedia;\n if (!displayNftMedia) {\n state.useNftDetection = false;\n }\n });\n }\n\n /**\n * Toggle the security alert enabled setting.\n *\n * @param securityAlertsEnabled - Boolean indicating user preference on using security alerts.\n */\n setSecurityAlertsEnabled(securityAlertsEnabled: boolean): void {\n this.update((state) => {\n state.securityAlertsEnabled = securityAlertsEnabled;\n });\n }\n\n /**\n * A setter for the user preferences to enable/disable fetch of multiple accounts balance.\n *\n * @param isMultiAccountBalancesEnabled - true to enable multiple accounts balance fetch, false to fetch only selectedAddress.\n */\n setIsMultiAccountBalancesEnabled(\n isMultiAccountBalancesEnabled: boolean,\n ): void {\n this.update((state) => {\n state.isMultiAccountBalancesEnabled = isMultiAccountBalancesEnabled;\n });\n }\n\n /**\n * A setter for the user have the test networks visible/hidden.\n *\n * @param showTestNetworks - true to show test networks, false to hidden.\n */\n setShowTestNetworks(showTestNetworks: boolean): void {\n this.update((state) => {\n state.showTestNetworks = showTestNetworks;\n });\n }\n\n /**\n * A setter for the user allow to be fetched IPFS content\n *\n * @param isIpfsGatewayEnabled - true to enable ipfs source\n */\n setIsIpfsGatewayEnabled(isIpfsGatewayEnabled: boolean): void {\n this.update((state) => {\n state.isIpfsGatewayEnabled = isIpfsGatewayEnabled;\n });\n }\n\n /**\n * A setter for the user allow to be fetched IPFS content\n *\n * @param chainId - On hexadecimal format to enable the incoming transaction network\n * @param isIncomingTransactionNetworkEnable - true to enable incoming transactions\n */\n setEnableNetworkIncomingTransactions(\n chainId: EtherscanSupportedHexChainId,\n isIncomingTransactionNetworkEnable: boolean,\n ): void {\n if (Object.values(ETHERSCAN_SUPPORTED_CHAIN_IDS).includes(chainId)) {\n this.update((state) => {\n state.showIncomingTransactions = {\n ...this.state.showIncomingTransactions,\n [chainId]: isIncomingTransactionNetworkEnable,\n };\n });\n }\n }\n\n /**\n * Toggle multi rpc migration modal.\n *\n * @param showMultiRpcModal - Boolean indicating if the multi rpc modal will be displayed or not.\n */\n setShowMultiRpcModal(showMultiRpcModal: boolean): void {\n this.update((state) => {\n state.showMultiRpcModal = showMultiRpcModal;\n if (!showMultiRpcModal) {\n state.showMultiRpcModal = false;\n }\n });\n }\n\n /**\n * A setter for the user to opt into smart transactions\n *\n * @param smartTransactionsOptInStatus - true to opt into smart transactions\n */\n setSmartTransactionsOptInStatus(smartTransactionsOptInStatus: boolean): void {\n this.update((state) => {\n state.smartTransactionsOptInStatus = smartTransactionsOptInStatus;\n });\n }\n\n /**\n * A setter for the user preferences to enable/disable transaction simulations.\n *\n * @param useTransactionSimulations - true to enable transaction simulations, false to disable it.\n */\n setUseTransactionSimulations(useTransactionSimulations: boolean): void {\n this.update((state) => {\n state.useTransactionSimulations = useTransactionSimulations;\n });\n }\n\n /**\n * A setter to update the user's preferred token sorting order.\n *\n * @param tokenSortConfig - a configuration representing the sort order of tokens.\n */\n setTokenSortConfig(tokenSortConfig: TokenSortConfig): void {\n this.update((state) => {\n state.tokenSortConfig = tokenSortConfig;\n });\n }\n\n /**\n * A setter for the user preferences to enable/disable safe chains list validation.\n *\n * @param useSafeChainsListValidation - true to enable safe chains list validation, false to disable it.\n */\n setUseSafeChainsListValidation(useSafeChainsListValidation: boolean): void {\n this.update((state) => {\n state.useSafeChainsListValidation = useSafeChainsListValidation;\n });\n }\n\n /**\n * A setter for the user preferences to enable/disable privacy mode.\n *\n * @param privacyMode - true to enable privacy mode, false to disable it.\n */\n setPrivacyMode(privacyMode: boolean): void {\n this.update((state) => {\n state.privacyMode = privacyMode;\n });\n }\n\n /**\n * A setter for the user preferences dismiss smart account upgrade prompt.\n *\n * @param dismissSmartAccountSuggestionEnabled - true to dismiss smart account upgrade prompt, false to enable it.\n */\n setDismissSmartAccountSuggestionEnabled(\n dismissSmartAccountSuggestionEnabled: boolean,\n ): void {\n this.update((state) => {\n state.dismissSmartAccountSuggestionEnabled =\n dismissSmartAccountSuggestionEnabled;\n });\n }\n\n /**\n * A setter for the user preferences smart account OptIn.\n *\n * @param smartAccountOptIn - true if user opts in for smart account update, false otherwise.\n */\n setSmartAccountOptIn(smartAccountOptIn: boolean): void {\n this.update((state) => {\n state.smartAccountOptIn = smartAccountOptIn;\n });\n }\n\n /**\n * Add account to list of accounts for which user has optedin\n * smart account upgrade.\n *\n * @param accounts - accounts for which user wants to optin for smart account upgrade\n * @deprecated This method is deprecated and will be removed in the future.\n */\n setSmartAccountOptInForAccounts(accounts: Hex[] = []): void {\n this.update((state) => {\n state.smartAccountOptInForAccounts = accounts;\n });\n }\n\n /**\n * Set the token network filter configuration setting.\n *\n * @param tokenNetworkFilter - Object describing token network filter configuration.\n */\n setTokenNetworkFilter(tokenNetworkFilter: Record<string, boolean>): void {\n this.update((state) => {\n state.tokenNetworkFilter = tokenNetworkFilter;\n });\n }\n}\n\nexport default PreferencesController;\n"]}
@@ -1,7 +1,26 @@
1
1
  import { BaseController } from "@metamask/base-controller";
2
2
  import type { ControllerStateChangeEvent, ControllerGetStateAction } from "@metamask/base-controller";
3
+ import type { KeyringControllerStateChangeEvent } from "@metamask/keyring-controller";
3
4
  import type { Messenger } from "@metamask/messenger";
5
+ import type { Hex } from "@metamask/utils";
4
6
  import { ETHERSCAN_SUPPORTED_CHAIN_IDS } from "./constants.cjs";
7
+ /**
8
+ * A representation of a MetaMask identity
9
+ */
10
+ export type Identity = {
11
+ /**
12
+ * The address of the identity
13
+ */
14
+ address: string;
15
+ /**
16
+ * The timestamp for when this identity was first added
17
+ */
18
+ importTime?: number;
19
+ /**
20
+ * The name of the identity
21
+ */
22
+ name: string;
23
+ };
5
24
  /**
6
25
  * A type union of the name for each chain that is supported by Etherscan or
7
26
  * an Etherscan-compatible service.
@@ -27,6 +46,12 @@ export type PreferencesState = {
27
46
  featureFlags: {
28
47
  [feature: string]: boolean;
29
48
  };
49
+ /**
50
+ * Map of addresses to Identity objects
51
+ */
52
+ identities: {
53
+ [address: string]: Identity;
54
+ };
30
55
  /**
31
56
  * The configured IPFS gateway
32
57
  */
@@ -39,6 +64,12 @@ export type PreferencesState = {
39
64
  * Controls whether multi-account balances are enabled or not
40
65
  */
41
66
  isMultiAccountBalancesEnabled: boolean;
67
+ /**
68
+ * Map of lost addresses to Identity objects
69
+ */
70
+ lostIdentities: {
71
+ [address: string]: Identity;
72
+ };
42
73
  /**
43
74
  * Controls whether the OpenSea API is used
44
75
  */
@@ -47,6 +78,10 @@ export type PreferencesState = {
47
78
  * Controls whether "security alerts" are enabled
48
79
  */
49
80
  securityAlertsEnabled: boolean;
81
+ /**
82
+ * The current selected address
83
+ */
84
+ selectedAddress: string;
50
85
  /**
51
86
  * Controls whether incoming transactions are enabled, per-chain (for Etherscan-supported chains)
52
87
  */
@@ -97,6 +132,12 @@ export type PreferencesState = {
97
132
  * User to opt in for smart account upgrade for all user accounts.
98
133
  */
99
134
  smartAccountOptIn: boolean;
135
+ /**
136
+ * User to opt in for smart account upgrade for specific accounts.
137
+ *
138
+ * @deprecated This preference is deprecated and will be removed in the future.
139
+ */
140
+ smartAccountOptInForAccounts: Hex[];
100
141
  /**
101
142
  * Controls token filtering controls
102
143
  */
@@ -107,7 +148,8 @@ export type PreferencesControllerGetStateAction = ControllerGetStateAction<typeo
107
148
  export type PreferencesControllerStateChangeEvent = ControllerStateChangeEvent<typeof name, PreferencesState>;
108
149
  export type PreferencesControllerActions = PreferencesControllerGetStateAction;
109
150
  export type PreferencesControllerEvents = PreferencesControllerStateChangeEvent;
110
- export type PreferencesControllerMessenger = Messenger<typeof name, PreferencesControllerActions, PreferencesControllerEvents>;
151
+ type AllowedEvents = KeyringControllerStateChangeEvent;
152
+ export type PreferencesControllerMessenger = Messenger<typeof name, PreferencesControllerActions, PreferencesControllerEvents | AllowedEvents>;
111
153
  /**
112
154
  * Get the default PreferencesController state.
113
155
  *
@@ -118,6 +160,7 @@ export declare function getDefaultPreferencesState(): PreferencesState;
118
160
  * Controller that stores shared settings and exposes convenience methods
119
161
  */
120
162
  export declare class PreferencesController extends BaseController<typeof name, PreferencesState, PreferencesControllerMessenger> {
163
+ #private;
121
164
  /**
122
165
  * Creates a PreferencesController instance.
123
166
  *
@@ -129,6 +172,25 @@ export declare class PreferencesController extends BaseController<typeof name, P
129
172
  messenger: PreferencesControllerMessenger;
130
173
  state?: Partial<PreferencesState>;
131
174
  });
175
+ /**
176
+ * Adds identities to state.
177
+ *
178
+ * @param addresses - List of addresses to use to generate new identities.
179
+ */
180
+ addIdentities(addresses: string[]): void;
181
+ /**
182
+ * Removes an identity from state.
183
+ *
184
+ * @param address - Address of the identity to remove.
185
+ */
186
+ removeIdentity(address: string): void;
187
+ /**
188
+ * Associates a new label with an identity.
189
+ *
190
+ * @param address - Address of the identity to associate.
191
+ * @param label - New label to assign.
192
+ */
193
+ setAccountLabel(address: string, label: string): void;
132
194
  /**
133
195
  * Enable or disable a specific feature flag.
134
196
  *
@@ -136,6 +198,12 @@ export declare class PreferencesController extends BaseController<typeof name, P
136
198
  * @param activated - Value to assign.
137
199
  */
138
200
  setFeatureFlag(feature: string, activated: boolean): void;
201
+ /**
202
+ * Sets selected address.
203
+ *
204
+ * @param selectedAddress - Ethereum address.
205
+ */
206
+ setSelectedAddress(selectedAddress: string): void;
139
207
  /**
140
208
  * Sets new IPFS gateway.
141
209
  *
@@ -239,6 +307,14 @@ export declare class PreferencesController extends BaseController<typeof name, P
239
307
  * @param smartAccountOptIn - true if user opts in for smart account update, false otherwise.
240
308
  */
241
309
  setSmartAccountOptIn(smartAccountOptIn: boolean): void;
310
+ /**
311
+ * Add account to list of accounts for which user has optedin
312
+ * smart account upgrade.
313
+ *
314
+ * @param accounts - accounts for which user wants to optin for smart account upgrade
315
+ * @deprecated This method is deprecated and will be removed in the future.
316
+ */
317
+ setSmartAccountOptInForAccounts(accounts?: Hex[]): void;
242
318
  /**
243
319
  * Set the token network filter configuration setting.
244
320
  *
@@ -1 +1 @@
1
- {"version":3,"file":"PreferencesController.d.cts","sourceRoot":"","sources":["../src/PreferencesController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EACV,0BAA0B,EAC1B,wBAAwB,EACzB,kCAAkC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD,OAAO,EAAE,6BAA6B,EAAE,wBAAoB;AAE5D;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAClC,MAAM,OAAO,6BAA6B,CAAC;AAE7C;;;GAGG;AACH,MAAM,MAAM,4BAA4B,GACtC,CAAC,OAAO,6BAA6B,CAAC,CAAC,wBAAwB,CAAC,CAAC;AAEnE,KAAK,eAAe,GAAG;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,YAAY,EAAE;QAAE,CAAC,OAAO,EAAE,MA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oCAAoC,EAAE,OAAO,GAC5C,IAAI;IAOP;;;;OAIG;IACH,oBAAoB,CAAC,iBAAiB,EAAE,OAAO,GAAG,IAAI;IAMtD;;;;;;OAMG;IACH,+BAA+B,CAAC,QAAQ,GAAE,GAAG,EAAO,GAAG,IAAI;IAM3D;;;;OAIG;IACH,qBAAqB,CAAC,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAKzE;AAED,eAAe,qBAAqB,CAAC"}
@@ -1,7 +1,26 @@
1
1
  import { BaseController } from "@metamask/base-controller";
2
2
  import type { ControllerStateChangeEvent, ControllerGetStateAction } from "@metamask/base-controller";
3
+ import type { KeyringControllerStateChangeEvent } from "@metamask/keyring-controller";
3
4
  import type { Messenger } from "@metamask/messenger";
5
+ import type { Hex } from "@metamask/utils";
4
6
  import { ETHERSCAN_SUPPORTED_CHAIN_IDS } from "./constants.mjs";
7
+ /**
8
+ * A representation of a MetaMask identity
9
+ */
10
+ export type Identity = {
11
+ /**
12
+ * The address of the identity
13
+ */
14
+ address: string;
15
+ /**
16
+ * The timestamp for when this identity was first added
17
+ */
18
+ importTime?: number;
19
+ /**
20
+ * The name of the identity
21
+ */
22
+ name: string;
23
+ };
5
24
  /**
6
25
  * A type union of the name for each chain that is supported by Etherscan or
7
26
  * an Etherscan-compatible service.
@@ -27,6 +46,12 @@ export type PreferencesState = {
27
46
  featureFlags: {
28
47
  [feature: string]: boolean;
29
48
  };
49
+ /**
50
+ * Map of addresses to Identity objects
51
+ */
52
+ identities: {
53
+ [address: string]: Identity;
54
+ };
30
55
  /**
31
56
  * The configured IPFS gateway
32
57
  */
@@ -39,6 +64,12 @@ export type PreferencesState = {
39
64
  * Controls whether multi-account balances are enabled or not
40
65
  */
41
66
  isMultiAccountBalancesEnabled: boolean;
67
+ /**
68
+ * Map of lost addresses to Identity objects
69
+ */
70
+ lostIdentities: {
71
+ [address: string]: Identity;
72
+ };
42
73
  /**
43
74
  * Controls whether the OpenSea API is used
44
75
  */
@@ -47,6 +78,10 @@ export type PreferencesState = {
47
78
  * Controls whether "security alerts" are enabled
48
79
  */
49
80
  securityAlertsEnabled: boolean;
81
+ /**
82
+ * The current selected address
83
+ */
84
+ selectedAddress: string;
50
85
  /**
51
86
  * Controls whether incoming transactions are enabled, per-chain (for Etherscan-supported chains)
52
87
  */
@@ -97,6 +132,12 @@ export type PreferencesState = {
97
132
  * User to opt in for smart account upgrade for all user accounts.
98
133
  */
99
134
  smartAccountOptIn: boolean;
135
+ /**
136
+ * User to opt in for smart account upgrade for specific accounts.
137
+ *
138
+ * @deprecated This preference is deprecated and will be removed in the future.
139
+ */
140
+ smartAccountOptInForAccounts: Hex[];
100
141
  /**
101
142
  * Controls token filtering controls
102
143
  */
@@ -107,7 +148,8 @@ export type PreferencesControllerGetStateAction = ControllerGetStateAction<typeo
107
148
  export type PreferencesControllerStateChangeEvent = ControllerStateChangeEvent<typeof name, PreferencesState>;
108
149
  export type PreferencesControllerActions = PreferencesControllerGetStateAction;
109
150
  export type PreferencesControllerEvents = PreferencesControllerStateChangeEvent;
110
- export type PreferencesControllerMessenger = Messenger<typeof name, PreferencesControllerActions, PreferencesControllerEvents>;
151
+ type AllowedEvents = KeyringControllerStateChangeEvent;
152
+ export type PreferencesControllerMessenger = Messenger<typeof name, PreferencesControllerActions, PreferencesControllerEvents | AllowedEvents>;
111
153
  /**
112
154
  * Get the default PreferencesController state.
113
155
  *
@@ -118,6 +160,7 @@ export declare function getDefaultPreferencesState(): PreferencesState;
118
160
  * Controller that stores shared settings and exposes convenience methods
119
161
  */
120
162
  export declare class PreferencesController extends BaseController<typeof name, PreferencesState, PreferencesControllerMessenger> {
163
+ #private;
121
164
  /**
122
165
  * Creates a PreferencesController instance.
123
166
  *
@@ -129,6 +172,25 @@ export declare class PreferencesController extends BaseController<typeof name, P
129
172
  messenger: PreferencesControllerMessenger;
130
173
  state?: Partial<PreferencesState>;
131
174
  });
175
+ /**
176
+ * Adds identities to state.
177
+ *
178
+ * @param addresses - List of addresses to use to generate new identities.
179
+ */
180
+ addIdentities(addresses: string[]): void;
181
+ /**
182
+ * Removes an identity from state.
183
+ *
184
+ * @param address - Address of the identity to remove.
185
+ */
186
+ removeIdentity(address: string): void;
187
+ /**
188
+ * Associates a new label with an identity.
189
+ *
190
+ * @param address - Address of the identity to associate.
191
+ * @param label - New label to assign.
192
+ */
193
+ setAccountLabel(address: string, label: string): void;
132
194
  /**
133
195
  * Enable or disable a specific feature flag.
134
196
  *
@@ -136,6 +198,12 @@ export declare class PreferencesController extends BaseController<typeof name, P
136
198
  * @param activated - Value to assign.
137
199
  */
138
200
  setFeatureFlag(feature: string, activated: boolean): void;
201
+ /**
202
+ * Sets selected address.
203
+ *
204
+ * @param selectedAddress - Ethereum address.
205
+ */
206
+ setSelectedAddress(selectedAddress: string): void;
139
207
  /**
140
208
  * Sets new IPFS gateway.
141
209
  *
@@ -239,6 +307,14 @@ export declare class PreferencesController extends BaseController<typeof name, P
239
307
  * @param smartAccountOptIn - true if user opts in for smart account update, false otherwise.
240
308
  */
241
309
  setSmartAccountOptIn(smartAccountOptIn: boolean): void;
310
+ /**
311
+ * Add account to list of accounts for which user has optedin
312
+ * smart account upgrade.
313
+ *
314
+ * @param accounts - accounts for which user wants to optin for smart account upgrade
315
+ * @deprecated This method is deprecated and will be removed in the future.
316
+ */
317
+ setSmartAccountOptInForAccounts(accounts?: Hex[]): void;
242
318
  /**
243
319
  * Set the token network filter configuration setting.
244
320
  *
@@ -1 +1 @@
1
- {"version":3,"file":"PreferencesController.d.mts","sourceRoot":"","sources":["../src/PreferencesController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EACV,0BAA0B,EAC1B,wBAAwB,EACzB,kCAAkC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD,OAAO,EAAE,6BAA6B,EAAE,wBAAoB;AAE5D;;;GAGG;AACH,MAAM,MAAM,wBAAwB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AAI;IAStD;;;;OAIG;IACH,+BAA+B,CAAC,4BAA4B,EAAE,OAAO,GAAG,IAAI;IAM5E;;;;OAIG;IACH,4BAA4B,CAAC,yBAAyB,EAAE,OAAO,GAAG,IAAI;IAMtE;;;;OAIG;IACH,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,IAAI;IAM1D;;;;OAIG;IACH,8BAA8B,CAAC,2BAA2B,EAAE,OAAO,GAAG,IAAI;IAM1E;;;;OAIG;IACH,cAAc,CAAC,WAAW,EAAE,OAAO,GAAG,IAAI;IAM1C;;;;OAIG;IACH,uCAAuC,CACrC,oCAAoC,EAAE,OAAO,GAC5C,IAAI;IAOP;;;;OAIG;IACH,oBAAoB,CAAC,iBAAiB,EAAE,OAAO,GAAG,IAAI;IAMtD;;;;;;OAMG;IACH,+BAA+B,CAAC,QAAQ,GAAE,GAAG,EAAO,GAAG,IAAI;IAM3D;;;;OAIG;IACH,qBAAqB,CAAC,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAKzE;AAED,eAAe,qBAAqB,CAAC"}
@@ -1,4 +1,11 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ 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");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var _PreferencesController_instances, _PreferencesController_syncIdentities;
1
7
  import { BaseController } from "@metamask/base-controller";
8
+ import { toChecksumHexAddress } from "@metamask/controller-utils";
2
9
  import { ETHERSCAN_SUPPORTED_CHAIN_IDS } from "./constants.mjs";
3
10
  const metadata = {
4
11
  featureFlags: {
@@ -7,6 +14,12 @@ const metadata = {
7
14
  includeInDebugSnapshot: true,
8
15
  usedInUi: true,
9
16
  },
17
+ identities: {
18
+ includeInStateLogs: true,
19
+ persist: true,
20
+ includeInDebugSnapshot: false,
21
+ usedInUi: true,
22
+ },
10
23
  ipfsGateway: {
11
24
  includeInStateLogs: true,
12
25
  persist: true,
@@ -25,6 +38,12 @@ const metadata = {
25
38
  includeInDebugSnapshot: true,
26
39
  usedInUi: true,
27
40
  },
41
+ lostIdentities: {
42
+ includeInStateLogs: true,
43
+ persist: true,
44
+ includeInDebugSnapshot: false,
45
+ usedInUi: false,
46
+ },
28
47
  displayNftMedia: {
29
48
  includeInStateLogs: true,
30
49
  persist: true,
@@ -37,6 +56,12 @@ const metadata = {
37
56
  includeInDebugSnapshot: true,
38
57
  usedInUi: true,
39
58
  },
59
+ selectedAddress: {
60
+ includeInStateLogs: true,
61
+ persist: true,
62
+ includeInDebugSnapshot: false,
63
+ usedInUi: true,
64
+ },
40
65
  showTestNetworks: {
41
66
  includeInStateLogs: true,
42
67
  persist: true,
@@ -109,6 +134,12 @@ const metadata = {
109
134
  includeInDebugSnapshot: true,
110
135
  usedInUi: true,
111
136
  },
137
+ smartAccountOptInForAccounts: {
138
+ includeInStateLogs: true,
139
+ persist: true,
140
+ includeInDebugSnapshot: true,
141
+ usedInUi: true,
142
+ },
112
143
  tokenNetworkFilter: {
113
144
  includeInStateLogs: true,
114
145
  persist: true,
@@ -125,11 +156,14 @@ const name = 'PreferencesController';
125
156
  export function getDefaultPreferencesState() {
126
157
  return {
127
158
  featureFlags: {},
159
+ identities: {},
128
160
  ipfsGateway: 'https://ipfs.io/ipfs/',
129
161
  isIpfsGatewayEnabled: true,
130
162
  isMultiAccountBalancesEnabled: true,
163
+ lostIdentities: {},
131
164
  displayNftMedia: false,
132
165
  securityAlertsEnabled: false,
166
+ selectedAddress: '',
133
167
  showIncomingTransactions: {
134
168
  [ETHERSCAN_SUPPORTED_CHAIN_IDS.MAINNET]: true,
135
169
  [ETHERSCAN_SUPPORTED_CHAIN_IDS.GOERLI]: true,
@@ -170,6 +204,7 @@ export function getDefaultPreferencesState() {
170
204
  privacyMode: false,
171
205
  dismissSmartAccountSuggestionEnabled: false,
172
206
  smartAccountOptIn: true,
207
+ smartAccountOptInForAccounts: [],
173
208
  tokenNetworkFilter: {},
174
209
  };
175
210
  }
@@ -194,6 +229,72 @@ export class PreferencesController extends BaseController {
194
229
  ...state,
195
230
  },
196
231
  });
232
+ _PreferencesController_instances.add(this);
233
+ messenger.subscribe('KeyringController:stateChange', (keyringState) => {
234
+ const accounts = new Set();
235
+ for (const keyring of keyringState.keyrings) {
236
+ for (const account of keyring.accounts) {
237
+ accounts.add(account);
238
+ }
239
+ }
240
+ if (accounts.size > 0) {
241
+ __classPrivateFieldGet(this, _PreferencesController_instances, "m", _PreferencesController_syncIdentities).call(this, Array.from(accounts));
242
+ }
243
+ });
244
+ }
245
+ /**
246
+ * Adds identities to state.
247
+ *
248
+ * @param addresses - List of addresses to use to generate new identities.
249
+ */
250
+ addIdentities(addresses) {
251
+ const checksummedAddresses = addresses.map((address) => toChecksumHexAddress(address));
252
+ this.update((state) => {
253
+ const { identities } = state;
254
+ for (const address of checksummedAddresses) {
255
+ if (identities[address]) {
256
+ continue;
257
+ }
258
+ const identityCount = Object.keys(identities).length;
259
+ identities[address] = {
260
+ name: `Account ${identityCount + 1}`,
261
+ address,
262
+ importTime: Date.now(),
263
+ };
264
+ }
265
+ });
266
+ }
267
+ /**
268
+ * Removes an identity from state.
269
+ *
270
+ * @param address - Address of the identity to remove.
271
+ */
272
+ removeIdentity(address) {
273
+ const checksumAddress = toChecksumHexAddress(address);
274
+ const { identities } = this.state;
275
+ if (!identities[checksumAddress]) {
276
+ return;
277
+ }
278
+ this.update((state) => {
279
+ delete state.identities[checksumAddress];
280
+ if (checksumAddress === state.selectedAddress) {
281
+ state.selectedAddress = Object.keys(state.identities)[0];
282
+ }
283
+ });
284
+ }
285
+ /**
286
+ * Associates a new label with an identity.
287
+ *
288
+ * @param address - Address of the identity to associate.
289
+ * @param label - New label to assign.
290
+ */
291
+ setAccountLabel(address, label) {
292
+ const checksumAddress = toChecksumHexAddress(address);
293
+ this.update((state) => {
294
+ const identity = state.identities[checksumAddress] || {};
295
+ identity.name = label;
296
+ state.identities[checksumAddress] = identity;
297
+ });
197
298
  }
198
299
  /**
199
300
  * Enable or disable a specific feature flag.
@@ -206,6 +307,16 @@ export class PreferencesController extends BaseController {
206
307
  state.featureFlags[feature] = activated;
207
308
  });
208
309
  }
310
+ /**
311
+ * Sets selected address.
312
+ *
313
+ * @param selectedAddress - Ethereum address.
314
+ */
315
+ setSelectedAddress(selectedAddress) {
316
+ this.update((state) => {
317
+ state.selectedAddress = toChecksumHexAddress(selectedAddress);
318
+ });
319
+ }
209
320
  /**
210
321
  * Sets new IPFS gateway.
211
322
  *
@@ -392,6 +503,18 @@ export class PreferencesController extends BaseController {
392
503
  state.smartAccountOptIn = smartAccountOptIn;
393
504
  });
394
505
  }
506
+ /**
507
+ * Add account to list of accounts for which user has optedin
508
+ * smart account upgrade.
509
+ *
510
+ * @param accounts - accounts for which user wants to optin for smart account upgrade
511
+ * @deprecated This method is deprecated and will be removed in the future.
512
+ */
513
+ setSmartAccountOptInForAccounts(accounts = []) {
514
+ this.update((state) => {
515
+ state.smartAccountOptInForAccounts = accounts;
516
+ });
517
+ }
395
518
  /**
396
519
  * Set the token network filter configuration setting.
397
520
  *
@@ -403,5 +526,27 @@ export class PreferencesController extends BaseController {
403
526
  });
404
527
  }
405
528
  }
529
+ _PreferencesController_instances = new WeakSet(), _PreferencesController_syncIdentities = function _PreferencesController_syncIdentities(addresses) {
530
+ const checksumAddresses = addresses.map((address) => toChecksumHexAddress(address));
531
+ this.update((state) => {
532
+ const { identities } = state;
533
+ const newlyLost = {};
534
+ for (const [address, identity] of Object.entries(identities)) {
535
+ if (!checksumAddresses.includes(address)) {
536
+ newlyLost[address] = identity;
537
+ delete identities[address];
538
+ }
539
+ }
540
+ for (const [address, identity] of Object.entries(newlyLost)) {
541
+ state.lostIdentities[address] = identity;
542
+ }
543
+ });
544
+ this.addIdentities(checksumAddresses);
545
+ if (!checksumAddresses.includes(this.state.selectedAddress)) {
546
+ this.update((state) => {
547
+ state.selectedAddress = checksumAddresses[0];
548
+ });
549
+ }
550
+ };
406
551
  export default PreferencesController;
407
552
  //# sourceMappingURL=PreferencesController.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"PreferencesController.mjs","sourceRoot":"","sources":["../src/PreferencesController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAO3D,OAAO,EAAE,6BAA6B,EAAE,wBAAoB;AA0G5D,MAAM,QAAQ,GAAG;IACf,YAAY,EAAE;QACZ,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KACf;IACD,WAAW,EAAE;QACX,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,IAAI;KACf;IACD,oBAAoB,EAAE;QACpB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KACf;IACD,6BAA6B,EAAE;QAC7B,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KACf;IACD,eAAe,EAAE;QACf,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KACf;IACD,qBAAqB,EAAE;QACrB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KACf;IACD,gBAAgB,EAAE;QAChB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IA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C;IAED;;;;OAIG;IACH,qBAAqB,CAAC,kBAA2C;QAC/D,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAChD,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,eAAe,qBAAqB,CAAC","sourcesContent":["import { BaseController } from '@metamask/base-controller';\nimport type {\n ControllerStateChangeEvent,\n ControllerGetStateAction,\n} from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\n\nimport { ETHERSCAN_SUPPORTED_CHAIN_IDS } from './constants';\n\n/**\n * A type union of the name for each chain that is supported by Etherscan or\n * an Etherscan-compatible service.\n */\nexport type EtherscanSupportedChains =\n keyof typeof ETHERSCAN_SUPPORTED_CHAIN_IDS;\n\n/**\n * A type union of the chain ID for each chain that is supported by Etherscan\n * or an Etherscan-compatible service.\n */\nexport type EtherscanSupportedHexChainId =\n (typeof ETHERSCAN_SUPPORTED_CHAIN_IDS)[EtherscanSupportedChains];\n\ntype TokenSortConfig = {\n key: string;\n order: 'asc' | 'dsc';\n sortCallback: string;\n};\n\n/**\n * Preferences controller state\n */\nexport type PreferencesState = {\n /**\n * Map of specific features to enable or disable\n */\n featureFlags: { [feature: string]: boolean };\n /**\n * The configured IPFS gateway\n */\n ipfsGateway: string;\n /**\n * Controls whether IPFS is enabled or not\n */\n isIpfsGatewayEnabled: boolean;\n /**\n * Controls whether multi-account balances are enabled or not\n */\n isMultiAccountBalancesEnabled: boolean;\n /**\n * Controls whether the OpenSea API is used\n */\n displayNftMedia: boolean;\n /**\n * Controls whether \"security alerts\" are enabled\n */\n securityAlertsEnabled: boolean;\n /**\n * Controls whether incoming transactions are enabled, per-chain (for Etherscan-supported chains)\n */\n showIncomingTransactions: {\n [chainId in EtherscanSupportedHexChainId]: boolean;\n };\n /**\n * Controls whether test networks are shown in the wallet\n */\n showTestNetworks: boolean;\n /**\n * Controls whether NFT detection is enabled\n */\n useNftDetection: boolean;\n /**\n * Controls whether token detection is enabled\n */\n useTokenDetection: boolean;\n /**\n * Controls whether smart transactions are opted into\n */\n smartTransactionsOptInStatus: boolean;\n /**\n * Controls whether transaction simulations are enabled\n */\n useTransactionSimulations: boolean;\n /**\n * Controls whether Multi rpc modal is displayed or not\n */\n showMultiRpcModal: boolean;\n /**\n * Controls whether to use the safe chains list validation\n */\n useSafeChainsListValidation: boolean;\n /**\n * Controls which order tokens are sorted in\n */\n tokenSortConfig: TokenSortConfig;\n /**\n * Controls whether balance and assets are hidden or not\n */\n privacyMode: boolean;\n /**\n * Allow user to stop being prompted for smart account upgrade\n */\n dismissSmartAccountSuggestionEnabled: boolean;\n /**\n * User to opt in for smart account upgrade for all user accounts.\n */\n smartAccountOptIn: boolean;\n /**\n * Controls token filtering controls\n */\n tokenNetworkFilter: Record<string, boolean>;\n};\n\nconst metadata = {\n featureFlags: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n ipfsGateway: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n isIpfsGatewayEnabled: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n isMultiAccountBalancesEnabled: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n displayNftMedia: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n securityAlertsEnabled: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n showTestNetworks: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n showIncomingTransactions: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n useNftDetection: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n useTokenDetection: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n smartTransactionsOptInStatus: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n useTransactionSimulations: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n showMultiRpcModal: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n useSafeChainsListValidation: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n tokenSortConfig: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n privacyMode: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n dismissSmartAccountSuggestionEnabled: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n smartAccountOptIn: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n tokenNetworkFilter: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n};\n\nconst name = 'PreferencesController';\n\nexport type PreferencesControllerGetStateAction = ControllerGetStateAction<\n typeof name,\n PreferencesState\n>;\n\nexport type PreferencesControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof name,\n PreferencesState\n>;\n\nexport type PreferencesControllerActions = PreferencesControllerGetStateAction;\n\nexport type PreferencesControllerEvents = PreferencesControllerStateChangeEvent;\n\nexport type PreferencesControllerMessenger = Messenger<\n typeof name,\n PreferencesControllerActions,\n PreferencesControllerEvents\n>;\n\n/**\n * Get the default PreferencesController state.\n *\n * @returns The default PreferencesController state.\n */\nexport function getDefaultPreferencesState(): PreferencesState {\n return {\n featureFlags: {},\n ipfsGateway: 'https://ipfs.io/ipfs/',\n isIpfsGatewayEnabled: true,\n isMultiAccountBalancesEnabled: true,\n displayNftMedia: false,\n securityAlertsEnabled: false,\n showIncomingTransactions: {\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.MAINNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.GOERLI]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.BSC]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.BSC_TESTNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.OPTIMISM]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.OPTIMISM_SEPOLIA]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.POLYGON]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.POLYGON_TESTNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.AVALANCHE]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.AVALANCHE_TESTNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.FANTOM]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.FANTOM_TESTNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.SEPOLIA]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.LINEA_GOERLI]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.LINEA_SEPOLIA]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.LINEA_MAINNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.MOONBEAM]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.MOONBEAM_TESTNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.MOONRIVER]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.GNOSIS]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.SEI]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.MONAD]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.HYPEREVM]: true,\n },\n showTestNetworks: false,\n useNftDetection: false,\n useTokenDetection: true,\n showMultiRpcModal: false,\n smartTransactionsOptInStatus: true,\n useTransactionSimulations: true,\n useSafeChainsListValidation: true,\n tokenSortConfig: {\n key: 'tokenFiatAmount',\n order: 'dsc',\n sortCallback: 'stringNumeric',\n },\n privacyMode: false,\n dismissSmartAccountSuggestionEnabled: false,\n smartAccountOptIn: true,\n tokenNetworkFilter: {},\n };\n}\n\n/**\n * Controller that stores shared settings and exposes convenience methods\n */\nexport class PreferencesController extends BaseController<\n typeof name,\n PreferencesState,\n PreferencesControllerMessenger\n> {\n /**\n * Creates a PreferencesController instance.\n *\n * @param args - Arguments\n * @param args.messenger - The preferences controller messenger.\n * @param args.state - Preferences controller state.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: PreferencesControllerMessenger;\n state?: Partial<PreferencesState>;\n }) {\n super({\n name,\n metadata,\n messenger,\n state: {\n ...getDefaultPreferencesState(),\n ...state,\n },\n });\n }\n\n /**\n * Enable or disable a specific feature flag.\n *\n * @param feature - Feature to toggle.\n * @param activated - Value to assign.\n */\n setFeatureFlag(feature: string, activated: boolean): void {\n this.update((state) => {\n state.featureFlags[feature] = activated;\n });\n }\n\n /**\n * Sets new IPFS gateway.\n *\n * @param ipfsGateway - IPFS gateway string.\n */\n setIpfsGateway(ipfsGateway: string): void {\n this.update((state) => {\n state.ipfsGateway = ipfsGateway;\n });\n }\n\n /**\n * Toggle the token detection setting.\n *\n * @param useTokenDetection - Boolean indicating user preference on token detection.\n */\n setUseTokenDetection(useTokenDetection: boolean): void {\n this.update((state) => {\n state.useTokenDetection = useTokenDetection;\n });\n }\n\n /**\n * Toggle the NFT detection setting.\n *\n * @param useNftDetection - Boolean indicating user preference on NFT detection.\n */\n setUseNftDetection(useNftDetection: boolean): void {\n if (useNftDetection && !this.state.displayNftMedia) {\n throw new Error(\n 'useNftDetection cannot be enabled if displayNftMedia is false',\n );\n }\n this.update((state) => {\n state.useNftDetection = useNftDetection;\n });\n }\n\n /**\n * Toggle the display nft media enabled setting.\n *\n * @param displayNftMedia - Boolean indicating user preference on using OpenSea's API.\n */\n setDisplayNftMedia(displayNftMedia: boolean): void {\n this.update((state) => {\n state.displayNftMedia = displayNftMedia;\n if (!displayNftMedia) {\n state.useNftDetection = false;\n }\n });\n }\n\n /**\n * Toggle the security alert enabled setting.\n *\n * @param securityAlertsEnabled - Boolean indicating user preference on using security alerts.\n */\n setSecurityAlertsEnabled(securityAlertsEnabled: boolean): void {\n this.update((state) => {\n state.securityAlertsEnabled = securityAlertsEnabled;\n });\n }\n\n /**\n * A setter for the user preferences to enable/disable fetch of multiple accounts balance.\n *\n * @param isMultiAccountBalancesEnabled - true to enable multiple accounts balance fetch, false to fetch only selectedAddress.\n */\n setIsMultiAccountBalancesEnabled(\n isMultiAccountBalancesEnabled: boolean,\n ): void {\n this.update((state) => {\n state.isMultiAccountBalancesEnabled = isMultiAccountBalancesEnabled;\n });\n }\n\n /**\n * A setter for the user have the test networks visible/hidden.\n *\n * @param showTestNetworks - true to show test networks, false to hidden.\n */\n setShowTestNetworks(showTestNetworks: boolean): void {\n this.update((state) => {\n state.showTestNetworks = showTestNetworks;\n });\n }\n\n /**\n * A setter for the user allow to be fetched IPFS content\n *\n * @param isIpfsGatewayEnabled - true to enable ipfs source\n */\n setIsIpfsGatewayEnabled(isIpfsGatewayEnabled: boolean): void {\n this.update((state) => {\n state.isIpfsGatewayEnabled = isIpfsGatewayEnabled;\n });\n }\n\n /**\n * A setter for the user allow to be fetched IPFS content\n *\n * @param chainId - On hexadecimal format to enable the incoming transaction network\n * @param isIncomingTransactionNetworkEnable - true to enable incoming transactions\n */\n setEnableNetworkIncomingTransactions(\n chainId: EtherscanSupportedHexChainId,\n isIncomingTransactionNetworkEnable: boolean,\n ): void {\n if (Object.values(ETHERSCAN_SUPPORTED_CHAIN_IDS).includes(chainId)) {\n this.update((state) => {\n state.showIncomingTransactions = {\n ...this.state.showIncomingTransactions,\n [chainId]: isIncomingTransactionNetworkEnable,\n };\n });\n }\n }\n\n /**\n * Toggle multi rpc migration modal.\n *\n * @param showMultiRpcModal - Boolean indicating if the multi rpc modal will be displayed or not.\n */\n setShowMultiRpcModal(showMultiRpcModal: boolean): void {\n this.update((state) => {\n state.showMultiRpcModal = showMultiRpcModal;\n if (!showMultiRpcModal) {\n state.showMultiRpcModal = false;\n }\n });\n }\n\n /**\n * A setter for the user to opt into smart transactions\n *\n * @param smartTransactionsOptInStatus - true to opt into smart transactions\n */\n setSmartTransactionsOptInStatus(smartTransactionsOptInStatus: boolean): void {\n this.update((state) => {\n state.smartTransactionsOptInStatus = smartTransactionsOptInStatus;\n });\n }\n\n /**\n * A setter for the user preferences to enable/disable transaction simulations.\n *\n * @param useTransactionSimulations - true to enable transaction simulations, false to disable it.\n */\n setUseTransactionSimulations(useTransactionSimulations: boolean): void {\n this.update((state) => {\n state.useTransactionSimulations = useTransactionSimulations;\n });\n }\n\n /**\n * A setter to update the user's preferred token sorting order.\n *\n * @param tokenSortConfig - a configuration representing the sort order of tokens.\n */\n setTokenSortConfig(tokenSortConfig: TokenSortConfig): void {\n this.update((state) => {\n state.tokenSortConfig = tokenSortConfig;\n });\n }\n\n /**\n * A setter for the user preferences to enable/disable safe chains list validation.\n *\n * @param useSafeChainsListValidation - true to enable safe chains list validation, false to disable it.\n */\n setUseSafeChainsListValidation(useSafeChainsListValidation: boolean): void {\n this.update((state) => {\n state.useSafeChainsListValidation = useSafeChainsListValidation;\n });\n }\n\n /**\n * A setter for the user preferences to enable/disable privacy mode.\n *\n * @param privacyMode - true to enable privacy mode, false to disable it.\n */\n setPrivacyMode(privacyMode: boolean): void {\n this.update((state) => {\n state.privacyMode = privacyMode;\n });\n }\n\n /**\n * A setter for the user preferences dismiss smart account upgrade prompt.\n *\n * @param dismissSmartAccountSuggestionEnabled - true to dismiss smart account upgrade prompt, false to enable it.\n */\n setDismissSmartAccountSuggestionEnabled(\n dismissSmartAccountSuggestionEnabled: boolean,\n ): void {\n this.update((state) => {\n state.dismissSmartAccountSuggestionEnabled =\n dismissSmartAccountSuggestionEnabled;\n });\n }\n\n /**\n * A setter for the user preferences smart account OptIn.\n *\n * @param smartAccountOptIn - true if user opts in for smart account update, false otherwise.\n */\n setSmartAccountOptIn(smartAccountOptIn: boolean): void {\n this.update((state) => {\n state.smartAccountOptIn = smartAccountOptIn;\n });\n }\n\n /**\n * Set the token network filter configuration setting.\n *\n * @param tokenNetworkFilter - Object describing token network filter configuration.\n */\n setTokenNetworkFilter(tokenNetworkFilter: Record<string, boolean>): void {\n this.update((state) => {\n state.tokenNetworkFilter = tokenNetworkFilter;\n });\n }\n}\n\nexport default PreferencesController;\n"]}
1
+ {"version":3,"file":"PreferencesController.mjs","sourceRoot":"","sources":["../src/PreferencesController.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAK3D,OAAO,EAAE,oBAAoB,EAAE,mCAAmC;AAQlE,OAAO,EAAE,6BAA6B,EAAE,wBAAoB;AA8I5D,MAAM,QAAQ,GAAG;IACf,YAAY,EAAE;QACZ,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KACf;IACD,UAAU,EAAE;QACV,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,IAAI;KACf;IACD,WAAW,EAAE;QACX,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,IAAI;KACf;IACD,oBAAoB,EAAE;QACpB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KACf;IACD,6BAA6B,EAAE;QAC7B,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KAC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,EAAE;QACpB,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;QAC7B,MAAM,SAAS,GAAoC,EAAE,CAAC;QAEtD,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7D,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBACzC,SAAS,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC;gBAC9B,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;QAED,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5D,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC;QAC3C,CAAC;IACH,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAEtC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE,CAAC;QAC5D,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,eAAe,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AA0PH,eAAe,qBAAqB,CAAC","sourcesContent":["import { BaseController } from '@metamask/base-controller';\nimport type {\n ControllerStateChangeEvent,\n ControllerGetStateAction,\n} from '@metamask/base-controller';\nimport { toChecksumHexAddress } from '@metamask/controller-utils';\nimport type {\n KeyringControllerState,\n KeyringControllerStateChangeEvent,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type { Hex } from '@metamask/utils';\n\nimport { ETHERSCAN_SUPPORTED_CHAIN_IDS } from './constants';\n\n/**\n * A representation of a MetaMask identity\n */\nexport type Identity = {\n /**\n * The address of the identity\n */\n address: string;\n /**\n * The timestamp for when this identity was first added\n */\n importTime?: number;\n /**\n * The name of the identity\n */\n name: string;\n};\n\n/**\n * A type union of the name for each chain that is supported by Etherscan or\n * an Etherscan-compatible service.\n */\nexport type EtherscanSupportedChains =\n keyof typeof ETHERSCAN_SUPPORTED_CHAIN_IDS;\n\n/**\n * A type union of the chain ID for each chain that is supported by Etherscan\n * or an Etherscan-compatible service.\n */\nexport type EtherscanSupportedHexChainId =\n (typeof ETHERSCAN_SUPPORTED_CHAIN_IDS)[EtherscanSupportedChains];\n\ntype TokenSortConfig = {\n key: string;\n order: 'asc' | 'dsc';\n sortCallback: string;\n};\n\n/**\n * Preferences controller state\n */\nexport type PreferencesState = {\n /**\n * Map of specific features to enable or disable\n */\n featureFlags: { [feature: string]: boolean };\n /**\n * Map of addresses to Identity objects\n */\n identities: { [address: string]: Identity };\n /**\n * The configured IPFS gateway\n */\n ipfsGateway: string;\n /**\n * Controls whether IPFS is enabled or not\n */\n isIpfsGatewayEnabled: boolean;\n /**\n * Controls whether multi-account balances are enabled or not\n */\n isMultiAccountBalancesEnabled: boolean;\n /**\n * Map of lost addresses to Identity objects\n */\n lostIdentities: { [address: string]: Identity };\n /**\n * Controls whether the OpenSea API is used\n */\n displayNftMedia: boolean;\n /**\n * Controls whether \"security alerts\" are enabled\n */\n securityAlertsEnabled: boolean;\n /**\n * The current selected address\n */\n selectedAddress: string;\n /**\n * Controls whether incoming transactions are enabled, per-chain (for Etherscan-supported chains)\n */\n showIncomingTransactions: {\n [chainId in EtherscanSupportedHexChainId]: boolean;\n };\n /**\n * Controls whether test networks are shown in the wallet\n */\n showTestNetworks: boolean;\n /**\n * Controls whether NFT detection is enabled\n */\n useNftDetection: boolean;\n /**\n * Controls whether token detection is enabled\n */\n useTokenDetection: boolean;\n /**\n * Controls whether smart transactions are opted into\n */\n smartTransactionsOptInStatus: boolean;\n /**\n * Controls whether transaction simulations are enabled\n */\n useTransactionSimulations: boolean;\n /**\n * Controls whether Multi rpc modal is displayed or not\n */\n showMultiRpcModal: boolean;\n /**\n * Controls whether to use the safe chains list validation\n */\n useSafeChainsListValidation: boolean;\n /**\n * Controls which order tokens are sorted in\n */\n tokenSortConfig: TokenSortConfig;\n /**\n * Controls whether balance and assets are hidden or not\n */\n privacyMode: boolean;\n /**\n * Allow user to stop being prompted for smart account upgrade\n */\n dismissSmartAccountSuggestionEnabled: boolean;\n /**\n * User to opt in for smart account upgrade for all user accounts.\n */\n smartAccountOptIn: boolean;\n /**\n * User to opt in for smart account upgrade for specific accounts.\n *\n * @deprecated This preference is deprecated and will be removed in the future.\n */\n smartAccountOptInForAccounts: Hex[];\n /**\n * Controls token filtering controls\n */\n tokenNetworkFilter: Record<string, boolean>;\n};\n\nconst metadata = {\n featureFlags: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n identities: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n ipfsGateway: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n isIpfsGatewayEnabled: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n isMultiAccountBalancesEnabled: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n lostIdentities: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: false,\n },\n displayNftMedia: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n securityAlertsEnabled: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n selectedAddress: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n showTestNetworks: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n showIncomingTransactions: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n useNftDetection: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n useTokenDetection: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n smartTransactionsOptInStatus: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n useTransactionSimulations: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n showMultiRpcModal: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n useSafeChainsListValidation: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n tokenSortConfig: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n privacyMode: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n dismissSmartAccountSuggestionEnabled: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n smartAccountOptIn: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n smartAccountOptInForAccounts: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n tokenNetworkFilter: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n};\n\nconst name = 'PreferencesController';\n\nexport type PreferencesControllerGetStateAction = ControllerGetStateAction<\n typeof name,\n PreferencesState\n>;\n\nexport type PreferencesControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof name,\n PreferencesState\n>;\n\nexport type PreferencesControllerActions = PreferencesControllerGetStateAction;\n\nexport type PreferencesControllerEvents = PreferencesControllerStateChangeEvent;\n\ntype AllowedEvents = KeyringControllerStateChangeEvent;\n\nexport type PreferencesControllerMessenger = Messenger<\n typeof name,\n PreferencesControllerActions,\n PreferencesControllerEvents | AllowedEvents\n>;\n\n/**\n * Get the default PreferencesController state.\n *\n * @returns The default PreferencesController state.\n */\nexport function getDefaultPreferencesState(): PreferencesState {\n return {\n featureFlags: {},\n identities: {},\n ipfsGateway: 'https://ipfs.io/ipfs/',\n isIpfsGatewayEnabled: true,\n isMultiAccountBalancesEnabled: true,\n lostIdentities: {},\n displayNftMedia: false,\n securityAlertsEnabled: false,\n selectedAddress: '',\n showIncomingTransactions: {\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.MAINNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.GOERLI]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.BSC]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.BSC_TESTNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.OPTIMISM]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.OPTIMISM_SEPOLIA]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.POLYGON]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.POLYGON_TESTNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.AVALANCHE]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.AVALANCHE_TESTNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.FANTOM]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.FANTOM_TESTNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.SEPOLIA]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.LINEA_GOERLI]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.LINEA_SEPOLIA]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.LINEA_MAINNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.MOONBEAM]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.MOONBEAM_TESTNET]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.MOONRIVER]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.GNOSIS]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.SEI]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.MONAD]: true,\n [ETHERSCAN_SUPPORTED_CHAIN_IDS.HYPEREVM]: true,\n },\n showTestNetworks: false,\n useNftDetection: false,\n useTokenDetection: true,\n showMultiRpcModal: false,\n smartTransactionsOptInStatus: true,\n useTransactionSimulations: true,\n useSafeChainsListValidation: true,\n tokenSortConfig: {\n key: 'tokenFiatAmount',\n order: 'dsc',\n sortCallback: 'stringNumeric',\n },\n privacyMode: false,\n dismissSmartAccountSuggestionEnabled: false,\n smartAccountOptIn: true,\n smartAccountOptInForAccounts: [],\n tokenNetworkFilter: {},\n };\n}\n\n/**\n * Controller that stores shared settings and exposes convenience methods\n */\nexport class PreferencesController extends BaseController<\n typeof name,\n PreferencesState,\n PreferencesControllerMessenger\n> {\n /**\n * Creates a PreferencesController instance.\n *\n * @param args - Arguments\n * @param args.messenger - The preferences controller messenger.\n * @param args.state - Preferences controller state.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: PreferencesControllerMessenger;\n state?: Partial<PreferencesState>;\n }) {\n super({\n name,\n metadata,\n messenger,\n state: {\n ...getDefaultPreferencesState(),\n ...state,\n },\n });\n\n messenger.subscribe(\n 'KeyringController:stateChange',\n (keyringState: KeyringControllerState) => {\n const accounts = new Set<string>();\n for (const keyring of keyringState.keyrings) {\n for (const account of keyring.accounts) {\n accounts.add(account);\n }\n }\n if (accounts.size > 0) {\n this.#syncIdentities(Array.from(accounts));\n }\n },\n );\n }\n\n /**\n * Adds identities to state.\n *\n * @param addresses - List of addresses to use to generate new identities.\n */\n addIdentities(addresses: string[]): void {\n const checksummedAddresses = addresses.map((address) =>\n toChecksumHexAddress(address),\n );\n this.update((state) => {\n const { identities } = state;\n for (const address of checksummedAddresses) {\n if (identities[address]) {\n continue;\n }\n const identityCount = Object.keys(identities).length;\n\n identities[address] = {\n name: `Account ${identityCount + 1}`,\n address,\n importTime: Date.now(),\n };\n }\n });\n }\n\n /**\n * Removes an identity from state.\n *\n * @param address - Address of the identity to remove.\n */\n removeIdentity(address: string): void {\n const checksumAddress = toChecksumHexAddress(address);\n const { identities } = this.state;\n if (!identities[checksumAddress]) {\n return;\n }\n this.update((state) => {\n delete state.identities[checksumAddress];\n if (checksumAddress === state.selectedAddress) {\n state.selectedAddress = Object.keys(state.identities)[0];\n }\n });\n }\n\n /**\n * Associates a new label with an identity.\n *\n * @param address - Address of the identity to associate.\n * @param label - New label to assign.\n */\n setAccountLabel(address: string, label: string): void {\n const checksumAddress = toChecksumHexAddress(address);\n this.update((state) => {\n const identity = state.identities[checksumAddress] || {};\n identity.name = label;\n state.identities[checksumAddress] = identity;\n });\n }\n\n /**\n * Enable or disable a specific feature flag.\n *\n * @param feature - Feature to toggle.\n * @param activated - Value to assign.\n */\n setFeatureFlag(feature: string, activated: boolean): void {\n this.update((state) => {\n state.featureFlags[feature] = activated;\n });\n }\n\n /**\n * Synchronizes the current identity list with new identities.\n *\n * @param addresses - List of addresses corresponding to identities to sync.\n */\n #syncIdentities(addresses: string[]): void {\n const checksumAddresses = addresses.map((address: string) =>\n toChecksumHexAddress(address),\n );\n\n this.update((state) => {\n const { identities } = state;\n const newlyLost: { [address: string]: Identity } = {};\n\n for (const [address, identity] of Object.entries(identities)) {\n if (!checksumAddresses.includes(address)) {\n newlyLost[address] = identity;\n delete identities[address];\n }\n }\n\n for (const [address, identity] of Object.entries(newlyLost)) {\n state.lostIdentities[address] = identity;\n }\n });\n this.addIdentities(checksumAddresses);\n\n if (!checksumAddresses.includes(this.state.selectedAddress)) {\n this.update((state) => {\n state.selectedAddress = checksumAddresses[0];\n });\n }\n }\n\n /**\n * Sets selected address.\n *\n * @param selectedAddress - Ethereum address.\n */\n setSelectedAddress(selectedAddress: string): void {\n this.update((state) => {\n state.selectedAddress = toChecksumHexAddress(selectedAddress);\n });\n }\n\n /**\n * Sets new IPFS gateway.\n *\n * @param ipfsGateway - IPFS gateway string.\n */\n setIpfsGateway(ipfsGateway: string): void {\n this.update((state) => {\n state.ipfsGateway = ipfsGateway;\n });\n }\n\n /**\n * Toggle the token detection setting.\n *\n * @param useTokenDetection - Boolean indicating user preference on token detection.\n */\n setUseTokenDetection(useTokenDetection: boolean): void {\n this.update((state) => {\n state.useTokenDetection = useTokenDetection;\n });\n }\n\n /**\n * Toggle the NFT detection setting.\n *\n * @param useNftDetection - Boolean indicating user preference on NFT detection.\n */\n setUseNftDetection(useNftDetection: boolean): void {\n if (useNftDetection && !this.state.displayNftMedia) {\n throw new Error(\n 'useNftDetection cannot be enabled if displayNftMedia is false',\n );\n }\n this.update((state) => {\n state.useNftDetection = useNftDetection;\n });\n }\n\n /**\n * Toggle the display nft media enabled setting.\n *\n * @param displayNftMedia - Boolean indicating user preference on using OpenSea's API.\n */\n setDisplayNftMedia(displayNftMedia: boolean): void {\n this.update((state) => {\n state.displayNftMedia = displayNftMedia;\n if (!displayNftMedia) {\n state.useNftDetection = false;\n }\n });\n }\n\n /**\n * Toggle the security alert enabled setting.\n *\n * @param securityAlertsEnabled - Boolean indicating user preference on using security alerts.\n */\n setSecurityAlertsEnabled(securityAlertsEnabled: boolean): void {\n this.update((state) => {\n state.securityAlertsEnabled = securityAlertsEnabled;\n });\n }\n\n /**\n * A setter for the user preferences to enable/disable fetch of multiple accounts balance.\n *\n * @param isMultiAccountBalancesEnabled - true to enable multiple accounts balance fetch, false to fetch only selectedAddress.\n */\n setIsMultiAccountBalancesEnabled(\n isMultiAccountBalancesEnabled: boolean,\n ): void {\n this.update((state) => {\n state.isMultiAccountBalancesEnabled = isMultiAccountBalancesEnabled;\n });\n }\n\n /**\n * A setter for the user have the test networks visible/hidden.\n *\n * @param showTestNetworks - true to show test networks, false to hidden.\n */\n setShowTestNetworks(showTestNetworks: boolean): void {\n this.update((state) => {\n state.showTestNetworks = showTestNetworks;\n });\n }\n\n /**\n * A setter for the user allow to be fetched IPFS content\n *\n * @param isIpfsGatewayEnabled - true to enable ipfs source\n */\n setIsIpfsGatewayEnabled(isIpfsGatewayEnabled: boolean): void {\n this.update((state) => {\n state.isIpfsGatewayEnabled = isIpfsGatewayEnabled;\n });\n }\n\n /**\n * A setter for the user allow to be fetched IPFS content\n *\n * @param chainId - On hexadecimal format to enable the incoming transaction network\n * @param isIncomingTransactionNetworkEnable - true to enable incoming transactions\n */\n setEnableNetworkIncomingTransactions(\n chainId: EtherscanSupportedHexChainId,\n isIncomingTransactionNetworkEnable: boolean,\n ): void {\n if (Object.values(ETHERSCAN_SUPPORTED_CHAIN_IDS).includes(chainId)) {\n this.update((state) => {\n state.showIncomingTransactions = {\n ...this.state.showIncomingTransactions,\n [chainId]: isIncomingTransactionNetworkEnable,\n };\n });\n }\n }\n\n /**\n * Toggle multi rpc migration modal.\n *\n * @param showMultiRpcModal - Boolean indicating if the multi rpc modal will be displayed or not.\n */\n setShowMultiRpcModal(showMultiRpcModal: boolean): void {\n this.update((state) => {\n state.showMultiRpcModal = showMultiRpcModal;\n if (!showMultiRpcModal) {\n state.showMultiRpcModal = false;\n }\n });\n }\n\n /**\n * A setter for the user to opt into smart transactions\n *\n * @param smartTransactionsOptInStatus - true to opt into smart transactions\n */\n setSmartTransactionsOptInStatus(smartTransactionsOptInStatus: boolean): void {\n this.update((state) => {\n state.smartTransactionsOptInStatus = smartTransactionsOptInStatus;\n });\n }\n\n /**\n * A setter for the user preferences to enable/disable transaction simulations.\n *\n * @param useTransactionSimulations - true to enable transaction simulations, false to disable it.\n */\n setUseTransactionSimulations(useTransactionSimulations: boolean): void {\n this.update((state) => {\n state.useTransactionSimulations = useTransactionSimulations;\n });\n }\n\n /**\n * A setter to update the user's preferred token sorting order.\n *\n * @param tokenSortConfig - a configuration representing the sort order of tokens.\n */\n setTokenSortConfig(tokenSortConfig: TokenSortConfig): void {\n this.update((state) => {\n state.tokenSortConfig = tokenSortConfig;\n });\n }\n\n /**\n * A setter for the user preferences to enable/disable safe chains list validation.\n *\n * @param useSafeChainsListValidation - true to enable safe chains list validation, false to disable it.\n */\n setUseSafeChainsListValidation(useSafeChainsListValidation: boolean): void {\n this.update((state) => {\n state.useSafeChainsListValidation = useSafeChainsListValidation;\n });\n }\n\n /**\n * A setter for the user preferences to enable/disable privacy mode.\n *\n * @param privacyMode - true to enable privacy mode, false to disable it.\n */\n setPrivacyMode(privacyMode: boolean): void {\n this.update((state) => {\n state.privacyMode = privacyMode;\n });\n }\n\n /**\n * A setter for the user preferences dismiss smart account upgrade prompt.\n *\n * @param dismissSmartAccountSuggestionEnabled - true to dismiss smart account upgrade prompt, false to enable it.\n */\n setDismissSmartAccountSuggestionEnabled(\n dismissSmartAccountSuggestionEnabled: boolean,\n ): void {\n this.update((state) => {\n state.dismissSmartAccountSuggestionEnabled =\n dismissSmartAccountSuggestionEnabled;\n });\n }\n\n /**\n * A setter for the user preferences smart account OptIn.\n *\n * @param smartAccountOptIn - true if user opts in for smart account update, false otherwise.\n */\n setSmartAccountOptIn(smartAccountOptIn: boolean): void {\n this.update((state) => {\n state.smartAccountOptIn = smartAccountOptIn;\n });\n }\n\n /**\n * Add account to list of accounts for which user has optedin\n * smart account upgrade.\n *\n * @param accounts - accounts for which user wants to optin for smart account upgrade\n * @deprecated This method is deprecated and will be removed in the future.\n */\n setSmartAccountOptInForAccounts(accounts: Hex[] = []): void {\n this.update((state) => {\n state.smartAccountOptInForAccounts = accounts;\n });\n }\n\n /**\n * Set the token network filter configuration setting.\n *\n * @param tokenNetworkFilter - Object describing token network filter configuration.\n */\n setTokenNetworkFilter(tokenNetworkFilter: Record<string, boolean>): void {\n this.update((state) => {\n state.tokenNetworkFilter = tokenNetworkFilter;\n });\n }\n}\n\nexport default PreferencesController;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/preferences-controller",
3
- "version": "22.1.0-preview-bc00f2c",
3
+ "version": "22.1.0-preview-93519965c",
4
4
  "description": "Manages user-configurable settings for MetaMask",
5
5
  "keywords": [
6
6
  "MetaMask",