@metamask-previews/preferences-controller 22.1.0-preview-968b2b4f4 → 22.1.0-preview-bc00f2c
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 +6 -0
- package/dist/PreferencesController.cjs +0 -145
- package/dist/PreferencesController.cjs.map +1 -1
- package/dist/PreferencesController.d.cts +1 -77
- package/dist/PreferencesController.d.cts.map +1 -1
- package/dist/PreferencesController.d.mts +1 -77
- package/dist/PreferencesController.d.mts.map +1 -1
- package/dist/PreferencesController.mjs +0 -145
- package/dist/PreferencesController.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,12 @@ 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
|
+
|
|
14
20
|
## [22.1.0]
|
|
15
21
|
|
|
16
22
|
### Added
|
|
@@ -1,14 +1,7 @@
|
|
|
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;
|
|
8
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
3
|
exports.PreferencesController = exports.getDefaultPreferencesState = void 0;
|
|
10
4
|
const base_controller_1 = require("@metamask/base-controller");
|
|
11
|
-
const controller_utils_1 = require("@metamask/controller-utils");
|
|
12
5
|
const constants_1 = require("./constants.cjs");
|
|
13
6
|
const metadata = {
|
|
14
7
|
featureFlags: {
|
|
@@ -17,12 +10,6 @@ const metadata = {
|
|
|
17
10
|
includeInDebugSnapshot: true,
|
|
18
11
|
usedInUi: true,
|
|
19
12
|
},
|
|
20
|
-
identities: {
|
|
21
|
-
includeInStateLogs: true,
|
|
22
|
-
persist: true,
|
|
23
|
-
includeInDebugSnapshot: false,
|
|
24
|
-
usedInUi: true,
|
|
25
|
-
},
|
|
26
13
|
ipfsGateway: {
|
|
27
14
|
includeInStateLogs: true,
|
|
28
15
|
persist: true,
|
|
@@ -41,12 +28,6 @@ const metadata = {
|
|
|
41
28
|
includeInDebugSnapshot: true,
|
|
42
29
|
usedInUi: true,
|
|
43
30
|
},
|
|
44
|
-
lostIdentities: {
|
|
45
|
-
includeInStateLogs: true,
|
|
46
|
-
persist: true,
|
|
47
|
-
includeInDebugSnapshot: false,
|
|
48
|
-
usedInUi: false,
|
|
49
|
-
},
|
|
50
31
|
displayNftMedia: {
|
|
51
32
|
includeInStateLogs: true,
|
|
52
33
|
persist: true,
|
|
@@ -59,12 +40,6 @@ const metadata = {
|
|
|
59
40
|
includeInDebugSnapshot: true,
|
|
60
41
|
usedInUi: true,
|
|
61
42
|
},
|
|
62
|
-
selectedAddress: {
|
|
63
|
-
includeInStateLogs: true,
|
|
64
|
-
persist: true,
|
|
65
|
-
includeInDebugSnapshot: false,
|
|
66
|
-
usedInUi: true,
|
|
67
|
-
},
|
|
68
43
|
showTestNetworks: {
|
|
69
44
|
includeInStateLogs: true,
|
|
70
45
|
persist: true,
|
|
@@ -137,12 +112,6 @@ const metadata = {
|
|
|
137
112
|
includeInDebugSnapshot: true,
|
|
138
113
|
usedInUi: true,
|
|
139
114
|
},
|
|
140
|
-
smartAccountOptInForAccounts: {
|
|
141
|
-
includeInStateLogs: true,
|
|
142
|
-
persist: true,
|
|
143
|
-
includeInDebugSnapshot: true,
|
|
144
|
-
usedInUi: true,
|
|
145
|
-
},
|
|
146
115
|
tokenNetworkFilter: {
|
|
147
116
|
includeInStateLogs: true,
|
|
148
117
|
persist: true,
|
|
@@ -159,14 +128,11 @@ const name = 'PreferencesController';
|
|
|
159
128
|
function getDefaultPreferencesState() {
|
|
160
129
|
return {
|
|
161
130
|
featureFlags: {},
|
|
162
|
-
identities: {},
|
|
163
131
|
ipfsGateway: 'https://ipfs.io/ipfs/',
|
|
164
132
|
isIpfsGatewayEnabled: true,
|
|
165
133
|
isMultiAccountBalancesEnabled: true,
|
|
166
|
-
lostIdentities: {},
|
|
167
134
|
displayNftMedia: false,
|
|
168
135
|
securityAlertsEnabled: false,
|
|
169
|
-
selectedAddress: '',
|
|
170
136
|
showIncomingTransactions: {
|
|
171
137
|
[constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS.MAINNET]: true,
|
|
172
138
|
[constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS.GOERLI]: true,
|
|
@@ -207,7 +173,6 @@ function getDefaultPreferencesState() {
|
|
|
207
173
|
privacyMode: false,
|
|
208
174
|
dismissSmartAccountSuggestionEnabled: false,
|
|
209
175
|
smartAccountOptIn: true,
|
|
210
|
-
smartAccountOptInForAccounts: [],
|
|
211
176
|
tokenNetworkFilter: {},
|
|
212
177
|
};
|
|
213
178
|
}
|
|
@@ -233,72 +198,6 @@ class PreferencesController extends base_controller_1.BaseController {
|
|
|
233
198
|
...state,
|
|
234
199
|
},
|
|
235
200
|
});
|
|
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
|
-
});
|
|
302
201
|
}
|
|
303
202
|
/**
|
|
304
203
|
* Enable or disable a specific feature flag.
|
|
@@ -311,16 +210,6 @@ class PreferencesController extends base_controller_1.BaseController {
|
|
|
311
210
|
state.featureFlags[feature] = activated;
|
|
312
211
|
});
|
|
313
212
|
}
|
|
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
|
-
}
|
|
324
213
|
/**
|
|
325
214
|
* Sets new IPFS gateway.
|
|
326
215
|
*
|
|
@@ -507,18 +396,6 @@ class PreferencesController extends base_controller_1.BaseController {
|
|
|
507
396
|
state.smartAccountOptIn = smartAccountOptIn;
|
|
508
397
|
});
|
|
509
398
|
}
|
|
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
|
-
}
|
|
522
399
|
/**
|
|
523
400
|
* Set the token network filter configuration setting.
|
|
524
401
|
*
|
|
@@ -531,27 +408,5 @@ class PreferencesController extends base_controller_1.BaseController {
|
|
|
531
408
|
}
|
|
532
409
|
}
|
|
533
410
|
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
|
-
};
|
|
556
411
|
exports.default = PreferencesController;
|
|
557
412
|
//# sourceMappingURL=PreferencesController.cjs.map
|
|
@@ -1 +1 @@
|
|
|
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,OAA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AC5D,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
|
+
{"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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oC;gBACxC,oCAAoC,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,oBAAoB,CAAC,iBAA0B;QAC7C,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC9C,CAAC,CAAC,CAAC;IACL,CAAC;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;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,26 +1,7 @@
|
|
|
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";
|
|
4
3
|
import type { Messenger } from "@metamask/messenger";
|
|
5
|
-
import type { Hex } from "@metamask/utils";
|
|
6
4
|
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
|
-
};
|
|
24
5
|
/**
|
|
25
6
|
* A type union of the name for each chain that is supported by Etherscan or
|
|
26
7
|
* an Etherscan-compatible service.
|
|
@@ -46,12 +27,6 @@ export type PreferencesState = {
|
|
|
46
27
|
featureFlags: {
|
|
47
28
|
[feature: string]: boolean;
|
|
48
29
|
};
|
|
49
|
-
/**
|
|
50
|
-
* Map of addresses to Identity objects
|
|
51
|
-
*/
|
|
52
|
-
identities: {
|
|
53
|
-
[address: string]: Identity;
|
|
54
|
-
};
|
|
55
30
|
/**
|
|
56
31
|
* The configured IPFS gateway
|
|
57
32
|
*/
|
|
@@ -64,12 +39,6 @@ export type PreferencesState = {
|
|
|
64
39
|
* Controls whether multi-account balances are enabled or not
|
|
65
40
|
*/
|
|
66
41
|
isMultiAccountBalancesEnabled: boolean;
|
|
67
|
-
/**
|
|
68
|
-
* Map of lost addresses to Identity objects
|
|
69
|
-
*/
|
|
70
|
-
lostIdentities: {
|
|
71
|
-
[address: string]: Identity;
|
|
72
|
-
};
|
|
73
42
|
/**
|
|
74
43
|
* Controls whether the OpenSea API is used
|
|
75
44
|
*/
|
|
@@ -78,10 +47,6 @@ export type PreferencesState = {
|
|
|
78
47
|
* Controls whether "security alerts" are enabled
|
|
79
48
|
*/
|
|
80
49
|
securityAlertsEnabled: boolean;
|
|
81
|
-
/**
|
|
82
|
-
* The current selected address
|
|
83
|
-
*/
|
|
84
|
-
selectedAddress: string;
|
|
85
50
|
/**
|
|
86
51
|
* Controls whether incoming transactions are enabled, per-chain (for Etherscan-supported chains)
|
|
87
52
|
*/
|
|
@@ -132,12 +97,6 @@ export type PreferencesState = {
|
|
|
132
97
|
* User to opt in for smart account upgrade for all user accounts.
|
|
133
98
|
*/
|
|
134
99
|
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[];
|
|
141
100
|
/**
|
|
142
101
|
* Controls token filtering controls
|
|
143
102
|
*/
|
|
@@ -148,8 +107,7 @@ export type PreferencesControllerGetStateAction = ControllerGetStateAction<typeo
|
|
|
148
107
|
export type PreferencesControllerStateChangeEvent = ControllerStateChangeEvent<typeof name, PreferencesState>;
|
|
149
108
|
export type PreferencesControllerActions = PreferencesControllerGetStateAction;
|
|
150
109
|
export type PreferencesControllerEvents = PreferencesControllerStateChangeEvent;
|
|
151
|
-
type
|
|
152
|
-
export type PreferencesControllerMessenger = Messenger<typeof name, PreferencesControllerActions, PreferencesControllerEvents | AllowedEvents>;
|
|
110
|
+
export type PreferencesControllerMessenger = Messenger<typeof name, PreferencesControllerActions, PreferencesControllerEvents>;
|
|
153
111
|
/**
|
|
154
112
|
* Get the default PreferencesController state.
|
|
155
113
|
*
|
|
@@ -160,7 +118,6 @@ export declare function getDefaultPreferencesState(): PreferencesState;
|
|
|
160
118
|
* Controller that stores shared settings and exposes convenience methods
|
|
161
119
|
*/
|
|
162
120
|
export declare class PreferencesController extends BaseController<typeof name, PreferencesState, PreferencesControllerMessenger> {
|
|
163
|
-
#private;
|
|
164
121
|
/**
|
|
165
122
|
* Creates a PreferencesController instance.
|
|
166
123
|
*
|
|
@@ -172,25 +129,6 @@ export declare class PreferencesController extends BaseController<typeof name, P
|
|
|
172
129
|
messenger: PreferencesControllerMessenger;
|
|
173
130
|
state?: Partial<PreferencesState>;
|
|
174
131
|
});
|
|
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;
|
|
194
132
|
/**
|
|
195
133
|
* Enable or disable a specific feature flag.
|
|
196
134
|
*
|
|
@@ -198,12 +136,6 @@ export declare class PreferencesController extends BaseController<typeof name, P
|
|
|
198
136
|
* @param activated - Value to assign.
|
|
199
137
|
*/
|
|
200
138
|
setFeatureFlag(feature: string, activated: boolean): void;
|
|
201
|
-
/**
|
|
202
|
-
* Sets selected address.
|
|
203
|
-
*
|
|
204
|
-
* @param selectedAddress - Ethereum address.
|
|
205
|
-
*/
|
|
206
|
-
setSelectedAddress(selectedAddress: string): void;
|
|
207
139
|
/**
|
|
208
140
|
* Sets new IPFS gateway.
|
|
209
141
|
*
|
|
@@ -307,14 +239,6 @@ export declare class PreferencesController extends BaseController<typeof name, P
|
|
|
307
239
|
* @param smartAccountOptIn - true if user opts in for smart account update, false otherwise.
|
|
308
240
|
*/
|
|
309
241
|
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;
|
|
318
242
|
/**
|
|
319
243
|
* Set the token network filter configuration setting.
|
|
320
244
|
*
|
|
@@ -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;
|
|
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,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAC7C;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAC9B;;OAEG;IACH,6BAA6B,EAAE,OAAO,CAAC;IACvC;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,qBAAqB,EAAE,OAAO,CAAC;IAC/B;;OAEG;IACH,wBAAwB,EAAE;SACvB,OAAO,IAAI,4BAA4B,GAAG,OAAO;KACnD,CAAC;IACF;;OAEG;IACH,gBAAgB,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,iBAAiB,EAAE,OAAO,CAAC;IAC3B;;OAEG;IACH,4BAA4B,EAAE,OAAO,CAAC;IACtC;;OAEG;IACH,yBAAyB,EAAE,OAAO,CAAC;I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|
@@ -1,26 +1,7 @@
|
|
|
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";
|
|
4
3
|
import type { Messenger } from "@metamask/messenger";
|
|
5
|
-
import type { Hex } from "@metamask/utils";
|
|
6
4
|
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
|
-
};
|
|
24
5
|
/**
|
|
25
6
|
* A type union of the name for each chain that is supported by Etherscan or
|
|
26
7
|
* an Etherscan-compatible service.
|
|
@@ -46,12 +27,6 @@ export type PreferencesState = {
|
|
|
46
27
|
featureFlags: {
|
|
47
28
|
[feature: string]: boolean;
|
|
48
29
|
};
|
|
49
|
-
/**
|
|
50
|
-
* Map of addresses to Identity objects
|
|
51
|
-
*/
|
|
52
|
-
identities: {
|
|
53
|
-
[address: string]: Identity;
|
|
54
|
-
};
|
|
55
30
|
/**
|
|
56
31
|
* The configured IPFS gateway
|
|
57
32
|
*/
|
|
@@ -64,12 +39,6 @@ export type PreferencesState = {
|
|
|
64
39
|
* Controls whether multi-account balances are enabled or not
|
|
65
40
|
*/
|
|
66
41
|
isMultiAccountBalancesEnabled: boolean;
|
|
67
|
-
/**
|
|
68
|
-
* Map of lost addresses to Identity objects
|
|
69
|
-
*/
|
|
70
|
-
lostIdentities: {
|
|
71
|
-
[address: string]: Identity;
|
|
72
|
-
};
|
|
73
42
|
/**
|
|
74
43
|
* Controls whether the OpenSea API is used
|
|
75
44
|
*/
|
|
@@ -78,10 +47,6 @@ export type PreferencesState = {
|
|
|
78
47
|
* Controls whether "security alerts" are enabled
|
|
79
48
|
*/
|
|
80
49
|
securityAlertsEnabled: boolean;
|
|
81
|
-
/**
|
|
82
|
-
* The current selected address
|
|
83
|
-
*/
|
|
84
|
-
selectedAddress: string;
|
|
85
50
|
/**
|
|
86
51
|
* Controls whether incoming transactions are enabled, per-chain (for Etherscan-supported chains)
|
|
87
52
|
*/
|
|
@@ -132,12 +97,6 @@ export type PreferencesState = {
|
|
|
132
97
|
* User to opt in for smart account upgrade for all user accounts.
|
|
133
98
|
*/
|
|
134
99
|
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[];
|
|
141
100
|
/**
|
|
142
101
|
* Controls token filtering controls
|
|
143
102
|
*/
|
|
@@ -148,8 +107,7 @@ export type PreferencesControllerGetStateAction = ControllerGetStateAction<typeo
|
|
|
148
107
|
export type PreferencesControllerStateChangeEvent = ControllerStateChangeEvent<typeof name, PreferencesState>;
|
|
149
108
|
export type PreferencesControllerActions = PreferencesControllerGetStateAction;
|
|
150
109
|
export type PreferencesControllerEvents = PreferencesControllerStateChangeEvent;
|
|
151
|
-
type
|
|
152
|
-
export type PreferencesControllerMessenger = Messenger<typeof name, PreferencesControllerActions, PreferencesControllerEvents | AllowedEvents>;
|
|
110
|
+
export type PreferencesControllerMessenger = Messenger<typeof name, PreferencesControllerActions, PreferencesControllerEvents>;
|
|
153
111
|
/**
|
|
154
112
|
* Get the default PreferencesController state.
|
|
155
113
|
*
|
|
@@ -160,7 +118,6 @@ export declare function getDefaultPreferencesState(): PreferencesState;
|
|
|
160
118
|
* Controller that stores shared settings and exposes convenience methods
|
|
161
119
|
*/
|
|
162
120
|
export declare class PreferencesController extends BaseController<typeof name, PreferencesState, PreferencesControllerMessenger> {
|
|
163
|
-
#private;
|
|
164
121
|
/**
|
|
165
122
|
* Creates a PreferencesController instance.
|
|
166
123
|
*
|
|
@@ -172,25 +129,6 @@ export declare class PreferencesController extends BaseController<typeof name, P
|
|
|
172
129
|
messenger: PreferencesControllerMessenger;
|
|
173
130
|
state?: Partial<PreferencesState>;
|
|
174
131
|
});
|
|
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;
|
|
194
132
|
/**
|
|
195
133
|
* Enable or disable a specific feature flag.
|
|
196
134
|
*
|
|
@@ -198,12 +136,6 @@ export declare class PreferencesController extends BaseController<typeof name, P
|
|
|
198
136
|
* @param activated - Value to assign.
|
|
199
137
|
*/
|
|
200
138
|
setFeatureFlag(feature: string, activated: boolean): void;
|
|
201
|
-
/**
|
|
202
|
-
* Sets selected address.
|
|
203
|
-
*
|
|
204
|
-
* @param selectedAddress - Ethereum address.
|
|
205
|
-
*/
|
|
206
|
-
setSelectedAddress(selectedAddress: string): void;
|
|
207
139
|
/**
|
|
208
140
|
* Sets new IPFS gateway.
|
|
209
141
|
*
|
|
@@ -307,14 +239,6 @@ export declare class PreferencesController extends BaseController<typeof name, P
|
|
|
307
239
|
* @param smartAccountOptIn - true if user opts in for smart account update, false otherwise.
|
|
308
240
|
*/
|
|
309
241
|
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;
|
|
318
242
|
/**
|
|
319
243
|
* Set the token network filter configuration setting.
|
|
320
244
|
*
|
|
@@ -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;
|
|
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,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,YAA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IG;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;;;;OAIG;IACH,qBAAqB,CAAC,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAKzE;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -1,11 +1,4 @@
|
|
|
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;
|
|
7
1
|
import { BaseController } from "@metamask/base-controller";
|
|
8
|
-
import { toChecksumHexAddress } from "@metamask/controller-utils";
|
|
9
2
|
import { ETHERSCAN_SUPPORTED_CHAIN_IDS } from "./constants.mjs";
|
|
10
3
|
const metadata = {
|
|
11
4
|
featureFlags: {
|
|
@@ -14,12 +7,6 @@ const metadata = {
|
|
|
14
7
|
includeInDebugSnapshot: true,
|
|
15
8
|
usedInUi: true,
|
|
16
9
|
},
|
|
17
|
-
identities: {
|
|
18
|
-
includeInStateLogs: true,
|
|
19
|
-
persist: true,
|
|
20
|
-
includeInDebugSnapshot: false,
|
|
21
|
-
usedInUi: true,
|
|
22
|
-
},
|
|
23
10
|
ipfsGateway: {
|
|
24
11
|
includeInStateLogs: true,
|
|
25
12
|
persist: true,
|
|
@@ -38,12 +25,6 @@ const metadata = {
|
|
|
38
25
|
includeInDebugSnapshot: true,
|
|
39
26
|
usedInUi: true,
|
|
40
27
|
},
|
|
41
|
-
lostIdentities: {
|
|
42
|
-
includeInStateLogs: true,
|
|
43
|
-
persist: true,
|
|
44
|
-
includeInDebugSnapshot: false,
|
|
45
|
-
usedInUi: false,
|
|
46
|
-
},
|
|
47
28
|
displayNftMedia: {
|
|
48
29
|
includeInStateLogs: true,
|
|
49
30
|
persist: true,
|
|
@@ -56,12 +37,6 @@ const metadata = {
|
|
|
56
37
|
includeInDebugSnapshot: true,
|
|
57
38
|
usedInUi: true,
|
|
58
39
|
},
|
|
59
|
-
selectedAddress: {
|
|
60
|
-
includeInStateLogs: true,
|
|
61
|
-
persist: true,
|
|
62
|
-
includeInDebugSnapshot: false,
|
|
63
|
-
usedInUi: true,
|
|
64
|
-
},
|
|
65
40
|
showTestNetworks: {
|
|
66
41
|
includeInStateLogs: true,
|
|
67
42
|
persist: true,
|
|
@@ -134,12 +109,6 @@ const metadata = {
|
|
|
134
109
|
includeInDebugSnapshot: true,
|
|
135
110
|
usedInUi: true,
|
|
136
111
|
},
|
|
137
|
-
smartAccountOptInForAccounts: {
|
|
138
|
-
includeInStateLogs: true,
|
|
139
|
-
persist: true,
|
|
140
|
-
includeInDebugSnapshot: true,
|
|
141
|
-
usedInUi: true,
|
|
142
|
-
},
|
|
143
112
|
tokenNetworkFilter: {
|
|
144
113
|
includeInStateLogs: true,
|
|
145
114
|
persist: true,
|
|
@@ -156,14 +125,11 @@ const name = 'PreferencesController';
|
|
|
156
125
|
export function getDefaultPreferencesState() {
|
|
157
126
|
return {
|
|
158
127
|
featureFlags: {},
|
|
159
|
-
identities: {},
|
|
160
128
|
ipfsGateway: 'https://ipfs.io/ipfs/',
|
|
161
129
|
isIpfsGatewayEnabled: true,
|
|
162
130
|
isMultiAccountBalancesEnabled: true,
|
|
163
|
-
lostIdentities: {},
|
|
164
131
|
displayNftMedia: false,
|
|
165
132
|
securityAlertsEnabled: false,
|
|
166
|
-
selectedAddress: '',
|
|
167
133
|
showIncomingTransactions: {
|
|
168
134
|
[ETHERSCAN_SUPPORTED_CHAIN_IDS.MAINNET]: true,
|
|
169
135
|
[ETHERSCAN_SUPPORTED_CHAIN_IDS.GOERLI]: true,
|
|
@@ -204,7 +170,6 @@ export function getDefaultPreferencesState() {
|
|
|
204
170
|
privacyMode: false,
|
|
205
171
|
dismissSmartAccountSuggestionEnabled: false,
|
|
206
172
|
smartAccountOptIn: true,
|
|
207
|
-
smartAccountOptInForAccounts: [],
|
|
208
173
|
tokenNetworkFilter: {},
|
|
209
174
|
};
|
|
210
175
|
}
|
|
@@ -229,72 +194,6 @@ export class PreferencesController extends BaseController {
|
|
|
229
194
|
...state,
|
|
230
195
|
},
|
|
231
196
|
});
|
|
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
|
-
});
|
|
298
197
|
}
|
|
299
198
|
/**
|
|
300
199
|
* Enable or disable a specific feature flag.
|
|
@@ -307,16 +206,6 @@ export class PreferencesController extends BaseController {
|
|
|
307
206
|
state.featureFlags[feature] = activated;
|
|
308
207
|
});
|
|
309
208
|
}
|
|
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
|
-
}
|
|
320
209
|
/**
|
|
321
210
|
* Sets new IPFS gateway.
|
|
322
211
|
*
|
|
@@ -503,18 +392,6 @@ export class PreferencesController extends BaseController {
|
|
|
503
392
|
state.smartAccountOptIn = smartAccountOptIn;
|
|
504
393
|
});
|
|
505
394
|
}
|
|
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
|
-
}
|
|
518
395
|
/**
|
|
519
396
|
* Set the token network filter configuration setting.
|
|
520
397
|
*
|
|
@@ -526,27 +403,5 @@ export class PreferencesController extends BaseController {
|
|
|
526
403
|
});
|
|
527
404
|
}
|
|
528
405
|
}
|
|
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
|
-
};
|
|
551
406
|
export default PreferencesController;
|
|
552
407
|
//# 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;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,IA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AC,MAAM,CAAC,CAAC,KAAK,EAAE,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"]}
|
|
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,IAAI;KACf;IACD,wBAAwB,EAAE;QACxB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KACf;IACD,eAAe,EAAE;QACf,kBAAkB,EAAE,IAAI;QACxB,OA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;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"]}
|