@metamask-previews/preferences-controller 18.0.0-preview-e7141654 → 18.0.0-preview-ae04854
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 +4 -0
- package/dist/PreferencesController.cjs +13 -0
- package/dist/PreferencesController.cjs.map +1 -1
- package/dist/PreferencesController.d.cts +10 -0
- package/dist/PreferencesController.d.cts.map +1 -1
- package/dist/PreferencesController.d.mts +10 -0
- package/dist/PreferencesController.d.mts.map +1 -1
- package/dist/PreferencesController.mjs +13 -0
- package/dist/PreferencesController.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Add `dismissSmartAccountSuggestionEnabled` preference ([#5866](https://github.com/MetaMask/core/pull/5866))
|
|
13
|
+
|
|
10
14
|
### Changed
|
|
11
15
|
|
|
12
16
|
- Bump `@metamask/controller-utils` to `^11.9.0` ([#5812](https://github.com/MetaMask/core/pull/5812))
|
|
@@ -30,6 +30,7 @@ const metadata = {
|
|
|
30
30
|
useSafeChainsListValidation: { persist: true, anonymous: true },
|
|
31
31
|
tokenSortConfig: { persist: true, anonymous: true },
|
|
32
32
|
privacyMode: { persist: true, anonymous: true },
|
|
33
|
+
dismissSmartAccountSuggestionEnabled: { persist: true, anonymous: true },
|
|
33
34
|
};
|
|
34
35
|
const name = 'PreferencesController';
|
|
35
36
|
/**
|
|
@@ -83,6 +84,7 @@ function getDefaultPreferencesState() {
|
|
|
83
84
|
sortCallback: 'stringNumeric',
|
|
84
85
|
},
|
|
85
86
|
privacyMode: false,
|
|
87
|
+
dismissSmartAccountSuggestionEnabled: false,
|
|
86
88
|
};
|
|
87
89
|
}
|
|
88
90
|
exports.getDefaultPreferencesState = getDefaultPreferencesState;
|
|
@@ -360,6 +362,17 @@ class PreferencesController extends base_controller_1.BaseController {
|
|
|
360
362
|
state.privacyMode = privacyMode;
|
|
361
363
|
});
|
|
362
364
|
}
|
|
365
|
+
/**
|
|
366
|
+
* A setter for the user preferences dismiss smart account upgrade prompt.
|
|
367
|
+
*
|
|
368
|
+
* @param dismissSmartAccountSuggestionEnabled - true to dismiss smart account upgrade prompt, false to enable it.
|
|
369
|
+
*/
|
|
370
|
+
setDismissSmartAccountSuggestionEnabled(dismissSmartAccountSuggestionEnabled) {
|
|
371
|
+
this.update((state) => {
|
|
372
|
+
state.dismissSmartAccountSuggestionEnabled =
|
|
373
|
+
dismissSmartAccountSuggestionEnabled;
|
|
374
|
+
});
|
|
375
|
+
}
|
|
363
376
|
}
|
|
364
377
|
exports.PreferencesController = PreferencesController;
|
|
365
378
|
_PreferencesController_instances = new WeakSet(), _PreferencesController_syncIdentities = function _PreferencesController_syncIdentities(addresses) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreferencesController.cjs","sourceRoot":"","sources":["../src/PreferencesController.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+DAKmC;AACnC,iEAAkE;AAMlE,+CAA4D;AA4H5D,MAAM,QAAQ,GAAG;IACf,YAAY,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE;IAChD,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE;IAC/C,WAAW,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE;IAChD,oBAAoB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE;IACxD,6BAA6B,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE;IACjE,cAAc,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE;IACnD,cAAc,E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,CAC9B,CAAC;IAEF,IAAI,CAAC,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;YAC5D,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;gBAChC,SAAS,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC;gBAC9B,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC;aAC5B;SACF;QAED,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;YAC3D,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC;SAC1C;IACH,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAE9B,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE;QACnD,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,eAAe,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;KACJ;AACH,CAAC;AAuMH,kBAAe,qBAAqB,CAAC","sourcesContent":["import {\n BaseController,\n type ControllerStateChangeEvent,\n type ControllerGetStateAction,\n type RestrictedMessenger,\n} from '@metamask/base-controller';\nimport { toChecksumHexAddress } from '@metamask/controller-utils';\nimport type {\n KeyringControllerState,\n KeyringControllerStateChangeEvent,\n} from '@metamask/keyring-controller';\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 openSeaEnabled: 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 useMultiRpcMigration: 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\nconst metadata = {\n featureFlags: { persist: true, anonymous: true },\n identities: { persist: true, anonymous: false },\n ipfsGateway: { persist: true, anonymous: false },\n isIpfsGatewayEnabled: { persist: true, anonymous: true },\n isMultiAccountBalancesEnabled: { persist: true, anonymous: true },\n lostIdentities: { persist: true, anonymous: false },\n openSeaEnabled: { persist: true, anonymous: true },\n securityAlertsEnabled: { persist: true, anonymous: true },\n selectedAddress: { persist: true, anonymous: false },\n showTestNetworks: { persist: true, anonymous: true },\n showIncomingTransactions: { persist: true, anonymous: true },\n useNftDetection: { persist: true, anonymous: true },\n useTokenDetection: { persist: true, anonymous: true },\n smartTransactionsOptInStatus: { persist: true, anonymous: false },\n useTransactionSimulations: { persist: true, anonymous: true },\n useMultiRpcMigration: { persist: true, anonymous: true },\n useSafeChainsListValidation: { persist: true, anonymous: true },\n tokenSortConfig: { persist: true, anonymous: true },\n privacyMode: { persist: true, anonymous: true },\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 AllowedEvents = KeyringControllerStateChangeEvent;\n\nexport type PreferencesControllerMessenger = RestrictedMessenger<\n typeof name,\n PreferencesControllerActions,\n PreferencesControllerEvents | AllowedEvents,\n never,\n AllowedEvents['type']\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 openSeaEnabled: 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 },\n showTestNetworks: false,\n useNftDetection: false,\n useTokenDetection: true,\n useMultiRpcMigration: true,\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 };\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[]) {\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) {\n address = toChecksumHexAddress(address);\n const { identities } = this.state;\n if (!identities[address]) {\n return;\n }\n this.update((state) => {\n delete state.identities[address];\n if (address === 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) {\n address = toChecksumHexAddress(address);\n this.update((state) => {\n const identity = state.identities[address] || {};\n identity.name = label;\n state.identities[address] = 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) {\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[]) {\n addresses = 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 (!addresses.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(addresses);\n\n if (!addresses.includes(this.state.selectedAddress)) {\n this.update((state) => {\n state.selectedAddress = addresses[0];\n });\n }\n }\n\n /**\n * Sets selected address.\n *\n * @param selectedAddress - Ethereum address.\n */\n setSelectedAddress(selectedAddress: string) {\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) {\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) {\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) {\n if (useNftDetection && !this.state.openSeaEnabled) {\n throw new Error(\n 'useNftDetection cannot be enabled if openSeaEnabled is false',\n );\n }\n this.update((state) => {\n state.useNftDetection = useNftDetection;\n });\n }\n\n /**\n * Toggle the opensea enabled setting.\n *\n * @param openSeaEnabled - Boolean indicating user preference on using OpenSea's API.\n */\n setOpenSeaEnabled(openSeaEnabled: boolean) {\n this.update((state) => {\n state.openSeaEnabled = openSeaEnabled;\n if (!openSeaEnabled) {\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) {\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(isMultiAccountBalancesEnabled: boolean) {\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) {\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) {\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 ) {\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 useMultiRpcMigration - Boolean indicating if the multi rpc modal will be displayed or not.\n */\n setUseMultiRpcMigration(useMultiRpcMigration: boolean) {\n this.update((state) => {\n state.useMultiRpcMigration = useMultiRpcMigration;\n if (!useMultiRpcMigration) {\n state.useMultiRpcMigration = 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) {\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) {\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) {\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) {\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) {\n this.update((state) => {\n state.privacyMode = privacyMode;\n });\n }\n}\n\nexport default PreferencesController;\n"]}
|
|
1
|
+
{"version":3,"file":"PreferencesController.cjs","sourceRoot":"","sources":["../src/PreferencesController.ts"],"names":[],"mappings":";;;;;;;;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QAED,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;YAC3D,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC;SAC1C;IACH,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAE9B,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE;QACnD,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,eAAe,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;KACJ;AACH,CAAC;AAqNH,kBAAe,qBAAqB,CAAC","sourcesContent":["import {\n BaseController,\n type ControllerStateChangeEvent,\n type ControllerGetStateAction,\n type RestrictedMessenger,\n} from '@metamask/base-controller';\nimport { toChecksumHexAddress } from '@metamask/controller-utils';\nimport type {\n KeyringControllerState,\n KeyringControllerStateChangeEvent,\n} from '@metamask/keyring-controller';\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 openSeaEnabled: 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 useMultiRpcMigration: 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\nconst metadata = {\n featureFlags: { persist: true, anonymous: true },\n identities: { persist: true, anonymous: false },\n ipfsGateway: { persist: true, anonymous: false },\n isIpfsGatewayEnabled: { persist: true, anonymous: true },\n isMultiAccountBalancesEnabled: { persist: true, anonymous: true },\n lostIdentities: { persist: true, anonymous: false },\n openSeaEnabled: { persist: true, anonymous: true },\n securityAlertsEnabled: { persist: true, anonymous: true },\n selectedAddress: { persist: true, anonymous: false },\n showTestNetworks: { persist: true, anonymous: true },\n showIncomingTransactions: { persist: true, anonymous: true },\n useNftDetection: { persist: true, anonymous: true },\n useTokenDetection: { persist: true, anonymous: true },\n smartTransactionsOptInStatus: { persist: true, anonymous: false },\n useTransactionSimulations: { persist: true, anonymous: true },\n useMultiRpcMigration: { persist: true, anonymous: true },\n useSafeChainsListValidation: { persist: true, anonymous: true },\n tokenSortConfig: { persist: true, anonymous: true },\n privacyMode: { persist: true, anonymous: true },\n dismissSmartAccountSuggestionEnabled: { persist: true, anonymous: true },\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 AllowedEvents = KeyringControllerStateChangeEvent;\n\nexport type PreferencesControllerMessenger = RestrictedMessenger<\n typeof name,\n PreferencesControllerActions,\n PreferencesControllerEvents | AllowedEvents,\n never,\n AllowedEvents['type']\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 openSeaEnabled: 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 },\n showTestNetworks: false,\n useNftDetection: false,\n useTokenDetection: true,\n useMultiRpcMigration: true,\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 };\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[]) {\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) {\n address = toChecksumHexAddress(address);\n const { identities } = this.state;\n if (!identities[address]) {\n return;\n }\n this.update((state) => {\n delete state.identities[address];\n if (address === 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) {\n address = toChecksumHexAddress(address);\n this.update((state) => {\n const identity = state.identities[address] || {};\n identity.name = label;\n state.identities[address] = 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) {\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[]) {\n addresses = 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 (!addresses.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(addresses);\n\n if (!addresses.includes(this.state.selectedAddress)) {\n this.update((state) => {\n state.selectedAddress = addresses[0];\n });\n }\n }\n\n /**\n * Sets selected address.\n *\n * @param selectedAddress - Ethereum address.\n */\n setSelectedAddress(selectedAddress: string) {\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) {\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) {\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) {\n if (useNftDetection && !this.state.openSeaEnabled) {\n throw new Error(\n 'useNftDetection cannot be enabled if openSeaEnabled is false',\n );\n }\n this.update((state) => {\n state.useNftDetection = useNftDetection;\n });\n }\n\n /**\n * Toggle the opensea enabled setting.\n *\n * @param openSeaEnabled - Boolean indicating user preference on using OpenSea's API.\n */\n setOpenSeaEnabled(openSeaEnabled: boolean) {\n this.update((state) => {\n state.openSeaEnabled = openSeaEnabled;\n if (!openSeaEnabled) {\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) {\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(isMultiAccountBalancesEnabled: boolean) {\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) {\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) {\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 ) {\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 useMultiRpcMigration - Boolean indicating if the multi rpc modal will be displayed or not.\n */\n setUseMultiRpcMigration(useMultiRpcMigration: boolean) {\n this.update((state) => {\n state.useMultiRpcMigration = useMultiRpcMigration;\n if (!useMultiRpcMigration) {\n state.useMultiRpcMigration = 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) {\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) {\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) {\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) {\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) {\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 ) {\n this.update((state) => {\n state.dismissSmartAccountSuggestionEnabled =\n dismissSmartAccountSuggestionEnabled;\n });\n }\n}\n\nexport default PreferencesController;\n"]}
|
|
@@ -121,6 +121,10 @@ export type PreferencesState = {
|
|
|
121
121
|
* Controls whether balance and assets are hidden or not
|
|
122
122
|
*/
|
|
123
123
|
privacyMode: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Allow user to stop being prompted for smart account upgrade
|
|
126
|
+
*/
|
|
127
|
+
dismissSmartAccountSuggestionEnabled: boolean;
|
|
124
128
|
};
|
|
125
129
|
declare const name = "PreferencesController";
|
|
126
130
|
export type PreferencesControllerGetStateAction = ControllerGetStateAction<typeof name, PreferencesState>;
|
|
@@ -274,6 +278,12 @@ export declare class PreferencesController extends BaseController<typeof name, P
|
|
|
274
278
|
* @param privacyMode - true to enable privacy mode, false to disable it.
|
|
275
279
|
*/
|
|
276
280
|
setPrivacyMode(privacyMode: boolean): void;
|
|
281
|
+
/**
|
|
282
|
+
* A setter for the user preferences dismiss smart account upgrade prompt.
|
|
283
|
+
*
|
|
284
|
+
* @param dismissSmartAccountSuggestionEnabled - true to dismiss smart account upgrade prompt, false to enable it.
|
|
285
|
+
*/
|
|
286
|
+
setDismissSmartAccountSuggestionEnabled(dismissSmartAccountSuggestionEnabled: boolean): void;
|
|
277
287
|
}
|
|
278
288
|
export default PreferencesController;
|
|
279
289
|
//# sourceMappingURL=PreferencesController.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreferencesController.d.cts","sourceRoot":"","sources":["../src/PreferencesController.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACzB,kCAAkC;AAEnC,OAAO,KAAK,EAEV,iCAAiC,EAClC,qCAAqC;AAEtC,OAAO,EAAE,6BAA6B,EAAE,wBAAoB;AAE5D;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAClC,MAAM,OAAO,6BAA6B,CAAC;AAE7C;;;GAGG;AACH,MAAM,MAAM,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AE,OAAO;IAMrE;;;;OAIG;IACH,4BAA4B,CAAC,yBAAyB,EAAE,OAAO;IAM/D;;;;OAIG;IACH,kBAAkB,CAAC,eAAe,EAAE,eAAe;IAMnD;;;;OAIG;IACH,8BAA8B,CAAC,2BAA2B,EAAE,OAAO;IAMnE;;;;OAIG;IACH,cAAc,CAAC,WAAW,EAAE,OAAO;IAMnC;;;;OAIG;IACH,uCAAuC,CACrC,oCAAoC,EAAE,OAAO;CAOhD;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -121,6 +121,10 @@ export type PreferencesState = {
|
|
|
121
121
|
* Controls whether balance and assets are hidden or not
|
|
122
122
|
*/
|
|
123
123
|
privacyMode: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Allow user to stop being prompted for smart account upgrade
|
|
126
|
+
*/
|
|
127
|
+
dismissSmartAccountSuggestionEnabled: boolean;
|
|
124
128
|
};
|
|
125
129
|
declare const name = "PreferencesController";
|
|
126
130
|
export type PreferencesControllerGetStateAction = ControllerGetStateAction<typeof name, PreferencesState>;
|
|
@@ -274,6 +278,12 @@ export declare class PreferencesController extends BaseController<typeof name, P
|
|
|
274
278
|
* @param privacyMode - true to enable privacy mode, false to disable it.
|
|
275
279
|
*/
|
|
276
280
|
setPrivacyMode(privacyMode: boolean): void;
|
|
281
|
+
/**
|
|
282
|
+
* A setter for the user preferences dismiss smart account upgrade prompt.
|
|
283
|
+
*
|
|
284
|
+
* @param dismissSmartAccountSuggestionEnabled - true to dismiss smart account upgrade prompt, false to enable it.
|
|
285
|
+
*/
|
|
286
|
+
setDismissSmartAccountSuggestionEnabled(dismissSmartAccountSuggestionEnabled: boolean): void;
|
|
277
287
|
}
|
|
278
288
|
export default PreferencesController;
|
|
279
289
|
//# sourceMappingURL=PreferencesController.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreferencesController.d.mts","sourceRoot":"","sources":["../src/PreferencesController.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cA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Ae,EAAE,MAAM,CAAC;IACxB;;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;IACnC;;OAEG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAC9B;;OAEG;IACH,2BAA2B,EAAE,OAAO,CAAC;IACrC;;OAEG;IACH,eAAe,EAAE,eAAe,CAAC;IACjC;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"PreferencesController.d.mts","sourceRoot":"","sources":["../src/PreferencesController.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACzB,kCAAkC;AAEnC,OAAO,KAAK,EAEV,iCAAiC,EAClC,qCAAqC;AAEtC,OAAO,EAAE,6BAA6B,EAAE,wBAAoB;AAE5D;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;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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W3C;;;;OAIG;IACH,iBAAiB,CAAC,cAAc,EAAE,OAAO;IASzC;;;;OAIG;IACH,wBAAwB,CAAC,qBAAqB,EAAE,OAAO;IAMvD;;;;OAIG;IACH,gCAAgC,CAAC,6BAA6B,EAAE,OAAO;IAMvE;;;;OAIG;IACH,mBAAmB,CAAC,gBAAgB,EAAE,OAAO;IAM7C;;;;OAIG;IACH,uBAAuB,CAAC,oBAAoB,EAAE,OAAO;IAMrD;;;;;OAKG;IACH,oCAAoC,CAClC,OAAO,EAAE,4BAA4B,EACrC,kCAAkC,EAAE,OAAO;IAY7C;;;;OAIG;IACH,uBAAuB,CAAC,oBAAoB,EAAE,OAAO;IASrD;;;;OAIG;IACH,+BAA+B,CAAC,4BAA4B,EAAE,OAAO;IAMrE;;;;OAIG;IACH,4BAA4B,CAAC,yBAAyB,EAAE,OAAO;IAM/D;;;;OAIG;IACH,kBAAkB,CAAC,eAAe,EAAE,eAAe;IAMnD;;;;OAIG;IACH,8BAA8B,CAAC,2BAA2B,EAAE,OAAO;IAMnE;;;;OAIG;IACH,cAAc,CAAC,WAAW,EAAE,OAAO;IAMnC;;;;OAIG;IACH,uCAAuC,CACrC,oCAAoC,EAAE,OAAO;CAOhD;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -27,6 +27,7 @@ const metadata = {
|
|
|
27
27
|
useSafeChainsListValidation: { persist: true, anonymous: true },
|
|
28
28
|
tokenSortConfig: { persist: true, anonymous: true },
|
|
29
29
|
privacyMode: { persist: true, anonymous: true },
|
|
30
|
+
dismissSmartAccountSuggestionEnabled: { persist: true, anonymous: true },
|
|
30
31
|
};
|
|
31
32
|
const name = 'PreferencesController';
|
|
32
33
|
/**
|
|
@@ -80,6 +81,7 @@ export function getDefaultPreferencesState() {
|
|
|
80
81
|
sortCallback: 'stringNumeric',
|
|
81
82
|
},
|
|
82
83
|
privacyMode: false,
|
|
84
|
+
dismissSmartAccountSuggestionEnabled: false,
|
|
83
85
|
};
|
|
84
86
|
}
|
|
85
87
|
/**
|
|
@@ -356,6 +358,17 @@ export class PreferencesController extends BaseController {
|
|
|
356
358
|
state.privacyMode = privacyMode;
|
|
357
359
|
});
|
|
358
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* A setter for the user preferences dismiss smart account upgrade prompt.
|
|
363
|
+
*
|
|
364
|
+
* @param dismissSmartAccountSuggestionEnabled - true to dismiss smart account upgrade prompt, false to enable it.
|
|
365
|
+
*/
|
|
366
|
+
setDismissSmartAccountSuggestionEnabled(dismissSmartAccountSuggestionEnabled) {
|
|
367
|
+
this.update((state) => {
|
|
368
|
+
state.dismissSmartAccountSuggestionEnabled =
|
|
369
|
+
dismissSmartAccountSuggestionEnabled;
|
|
370
|
+
});
|
|
371
|
+
}
|
|
359
372
|
}
|
|
360
373
|
_PreferencesController_instances = new WeakSet(), _PreferencesController_syncIdentities = function _PreferencesController_syncIdentities(addresses) {
|
|
361
374
|
addresses = addresses.map((address) => toChecksumHexAddress(address));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreferencesController.mjs","sourceRoot":"","sources":["../src/PreferencesController.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,cAAc,EAIf,kCAAkC;AACnC,OAAO,EAAE,oBAAoB,EAAE,mCAAmC;AAMlE,OAAO,EAAE,6BAA6B,EAAE,wBAAoB;AA4H5D,MAAM,QAAQ,GAAG;IACf,YAAY,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE;IAChD,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE;IAC/C,WAAW,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE;IAChD,oBAAoB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE;IACxD,6BAA6B,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE;IACjE,cA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oBAAoB,CAAC,OAAO,CAAC,CAC9B,CAAC;IAEF,IAAI,CAAC,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;YAC5D,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;gBAChC,SAAS,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC;gBAC9B,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC;aAC5B;SACF;QAED,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;YAC3D,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC;SAC1C;IACH,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAE9B,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE;QACnD,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,eAAe,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;KACJ;AACH,CAAC;AAuMH,eAAe,qBAAqB,CAAC","sourcesContent":["import {\n BaseController,\n type ControllerStateChangeEvent,\n type ControllerGetStateAction,\n type RestrictedMessenger,\n} from '@metamask/base-controller';\nimport { toChecksumHexAddress } from '@metamask/controller-utils';\nimport type {\n KeyringControllerState,\n KeyringControllerStateChangeEvent,\n} from '@metamask/keyring-controller';\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 openSeaEnabled: 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 useMultiRpcMigration: 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\nconst metadata = {\n featureFlags: { persist: true, anonymous: true },\n identities: { persist: true, anonymous: false },\n ipfsGateway: { persist: true, anonymous: false },\n isIpfsGatewayEnabled: { persist: true, anonymous: true },\n isMultiAccountBalancesEnabled: { persist: true, anonymous: true },\n lostIdentities: { persist: true, anonymous: false },\n openSeaEnabled: { persist: true, anonymous: true },\n securityAlertsEnabled: { persist: true, anonymous: true },\n selectedAddress: { persist: true, anonymous: false },\n showTestNetworks: { persist: true, anonymous: true },\n showIncomingTransactions: { persist: true, anonymous: true },\n useNftDetection: { persist: true, anonymous: true },\n useTokenDetection: { persist: true, anonymous: true },\n smartTransactionsOptInStatus: { persist: true, anonymous: false },\n useTransactionSimulations: { persist: true, anonymous: true },\n useMultiRpcMigration: { persist: true, anonymous: true },\n useSafeChainsListValidation: { persist: true, anonymous: true },\n tokenSortConfig: { persist: true, anonymous: true },\n privacyMode: { persist: true, anonymous: true },\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 AllowedEvents = KeyringControllerStateChangeEvent;\n\nexport type PreferencesControllerMessenger = RestrictedMessenger<\n typeof name,\n PreferencesControllerActions,\n PreferencesControllerEvents | AllowedEvents,\n never,\n AllowedEvents['type']\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 openSeaEnabled: 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 },\n showTestNetworks: false,\n useNftDetection: false,\n useTokenDetection: true,\n useMultiRpcMigration: true,\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 };\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[]) {\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) {\n address = toChecksumHexAddress(address);\n const { identities } = this.state;\n if (!identities[address]) {\n return;\n }\n this.update((state) => {\n delete state.identities[address];\n if (address === 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) {\n address = toChecksumHexAddress(address);\n this.update((state) => {\n const identity = state.identities[address] || {};\n identity.name = label;\n state.identities[address] = 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) {\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[]) {\n addresses = 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 (!addresses.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(addresses);\n\n if (!addresses.includes(this.state.selectedAddress)) {\n this.update((state) => {\n state.selectedAddress = addresses[0];\n });\n }\n }\n\n /**\n * Sets selected address.\n *\n * @param selectedAddress - Ethereum address.\n */\n setSelectedAddress(selectedAddress: string) {\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) {\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) {\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) {\n if (useNftDetection && !this.state.openSeaEnabled) {\n throw new Error(\n 'useNftDetection cannot be enabled if openSeaEnabled is false',\n );\n }\n this.update((state) => {\n state.useNftDetection = useNftDetection;\n });\n }\n\n /**\n * Toggle the opensea enabled setting.\n *\n * @param openSeaEnabled - Boolean indicating user preference on using OpenSea's API.\n */\n setOpenSeaEnabled(openSeaEnabled: boolean) {\n this.update((state) => {\n state.openSeaEnabled = openSeaEnabled;\n if (!openSeaEnabled) {\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) {\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(isMultiAccountBalancesEnabled: boolean) {\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) {\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) {\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 ) {\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 useMultiRpcMigration - Boolean indicating if the multi rpc modal will be displayed or not.\n */\n setUseMultiRpcMigration(useMultiRpcMigration: boolean) {\n this.update((state) => {\n state.useMultiRpcMigration = useMultiRpcMigration;\n if (!useMultiRpcMigration) {\n state.useMultiRpcMigration = 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) {\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) {\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) {\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) {\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) {\n this.update((state) => {\n state.privacyMode = privacyMode;\n });\n }\n}\n\nexport default PreferencesController;\n"]}
|
|
1
|
+
{"version":3,"file":"PreferencesController.mjs","sourceRoot":"","sources":["../src/PreferencesController.ts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O,UAAU,CAAC,OAAO,CAAC,CAAC;aAC5B;SACF;QAED,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;YAC3D,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC;SAC1C;IACH,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAE9B,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE;QACnD,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,eAAe,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;KACJ;AACH,CAAC;AAqNH,eAAe,qBAAqB,CAAC","sourcesContent":["import {\n BaseController,\n type ControllerStateChangeEvent,\n type ControllerGetStateAction,\n type RestrictedMessenger,\n} from '@metamask/base-controller';\nimport { toChecksumHexAddress } from '@metamask/controller-utils';\nimport type {\n KeyringControllerState,\n KeyringControllerStateChangeEvent,\n} from '@metamask/keyring-controller';\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 openSeaEnabled: 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 useMultiRpcMigration: 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\nconst metadata = {\n featureFlags: { persist: true, anonymous: true },\n identities: { persist: true, anonymous: false },\n ipfsGateway: { persist: true, anonymous: false },\n isIpfsGatewayEnabled: { persist: true, anonymous: true },\n isMultiAccountBalancesEnabled: { persist: true, anonymous: true },\n lostIdentities: { persist: true, anonymous: false },\n openSeaEnabled: { persist: true, anonymous: true },\n securityAlertsEnabled: { persist: true, anonymous: true },\n selectedAddress: { persist: true, anonymous: false },\n showTestNetworks: { persist: true, anonymous: true },\n showIncomingTransactions: { persist: true, anonymous: true },\n useNftDetection: { persist: true, anonymous: true },\n useTokenDetection: { persist: true, anonymous: true },\n smartTransactionsOptInStatus: { persist: true, anonymous: false },\n useTransactionSimulations: { persist: true, anonymous: true },\n useMultiRpcMigration: { persist: true, anonymous: true },\n useSafeChainsListValidation: { persist: true, anonymous: true },\n tokenSortConfig: { persist: true, anonymous: true },\n privacyMode: { persist: true, anonymous: true },\n dismissSmartAccountSuggestionEnabled: { persist: true, anonymous: true },\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 AllowedEvents = KeyringControllerStateChangeEvent;\n\nexport type PreferencesControllerMessenger = RestrictedMessenger<\n typeof name,\n PreferencesControllerActions,\n PreferencesControllerEvents | AllowedEvents,\n never,\n AllowedEvents['type']\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 openSeaEnabled: 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 },\n showTestNetworks: false,\n useNftDetection: false,\n useTokenDetection: true,\n useMultiRpcMigration: true,\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 };\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[]) {\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) {\n address = toChecksumHexAddress(address);\n const { identities } = this.state;\n if (!identities[address]) {\n return;\n }\n this.update((state) => {\n delete state.identities[address];\n if (address === 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) {\n address = toChecksumHexAddress(address);\n this.update((state) => {\n const identity = state.identities[address] || {};\n identity.name = label;\n state.identities[address] = 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) {\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[]) {\n addresses = 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 (!addresses.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(addresses);\n\n if (!addresses.includes(this.state.selectedAddress)) {\n this.update((state) => {\n state.selectedAddress = addresses[0];\n });\n }\n }\n\n /**\n * Sets selected address.\n *\n * @param selectedAddress - Ethereum address.\n */\n setSelectedAddress(selectedAddress: string) {\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) {\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) {\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) {\n if (useNftDetection && !this.state.openSeaEnabled) {\n throw new Error(\n 'useNftDetection cannot be enabled if openSeaEnabled is false',\n );\n }\n this.update((state) => {\n state.useNftDetection = useNftDetection;\n });\n }\n\n /**\n * Toggle the opensea enabled setting.\n *\n * @param openSeaEnabled - Boolean indicating user preference on using OpenSea's API.\n */\n setOpenSeaEnabled(openSeaEnabled: boolean) {\n this.update((state) => {\n state.openSeaEnabled = openSeaEnabled;\n if (!openSeaEnabled) {\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) {\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(isMultiAccountBalancesEnabled: boolean) {\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) {\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) {\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 ) {\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 useMultiRpcMigration - Boolean indicating if the multi rpc modal will be displayed or not.\n */\n setUseMultiRpcMigration(useMultiRpcMigration: boolean) {\n this.update((state) => {\n state.useMultiRpcMigration = useMultiRpcMigration;\n if (!useMultiRpcMigration) {\n state.useMultiRpcMigration = 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) {\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) {\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) {\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) {\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) {\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 ) {\n this.update((state) => {\n state.dismissSmartAccountSuggestionEnabled =\n dismissSmartAccountSuggestionEnabled;\n });\n }\n}\n\nexport default PreferencesController;\n"]}
|