@metamask-previews/preferences-controller 13.0.2-preview-367cb1da → 13.0.2-preview-cf09c0a
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/dist/PreferencesController.cjs +333 -0
- package/dist/PreferencesController.cjs.map +1 -0
- package/dist/{types/PreferencesController.d.ts → PreferencesController.d.cts} +4 -4
- package/dist/PreferencesController.d.cts.map +1 -0
- package/dist/PreferencesController.d.mts +271 -0
- package/dist/PreferencesController.d.mts.map +1 -0
- package/dist/PreferencesController.mjs +326 -10
- package/dist/PreferencesController.mjs.map +1 -1
- package/dist/constants.cjs +26 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/{types/constants.d.ts → constants.d.cts} +1 -1
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.mts +23 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/constants.mjs +21 -5
- package/dist/constants.mjs.map +1 -1
- package/dist/index.cjs +21 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -7
- package/dist/PreferencesController.js +0 -12
- package/dist/PreferencesController.js.map +0 -1
- package/dist/chunk-FT2APC4J.mjs +0 -44
- package/dist/chunk-FT2APC4J.mjs.map +0 -1
- package/dist/chunk-KFN3X2JE.mjs +0 -347
- package/dist/chunk-KFN3X2JE.mjs.map +0 -1
- package/dist/chunk-POA2PUW4.js +0 -44
- package/dist/chunk-POA2PUW4.js.map +0 -1
- package/dist/chunk-Z2JUHJIP.js +0 -347
- package/dist/chunk-Z2JUHJIP.js.map +0 -1
- package/dist/constants.js +0 -7
- package/dist/constants.js.map +0 -1
- package/dist/index.js +0 -13
- package/dist/index.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/types/PreferencesController.d.ts.map +0 -1
- package/dist/types/constants.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -3
- package/dist/types/index.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
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,6BAA6B,EACnC,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;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,YAAY,EAAE;QAAE,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAC7C;;OAEG;IACH,UAAU,EAAE;QAAE,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAAA;KAAE,CAAC;IAC5C;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAC9B;;OAEG;IACH,6BAA6B,EAAE,OAAO,CAAC;IACvC;;OAEG;IACH,cAAc,EAAE;QAAE,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAAA;KAAE,CAAC;IAChD;;OAEG;IACH,cAAc,EAAE,OA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|
|
10
|
-
getDefaultPreferencesState
|
|
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);
|
|
11
5
|
};
|
|
6
|
+
var _PreferencesController_instances, _PreferencesController_syncIdentities;
|
|
7
|
+
import { BaseController } from "@metamask/base-controller";
|
|
8
|
+
import { toChecksumHexAddress } from "@metamask/controller-utils";
|
|
9
|
+
import { ETHERSCAN_SUPPORTED_CHAIN_IDS } from "./constants.mjs";
|
|
10
|
+
const metadata = {
|
|
11
|
+
featureFlags: { persist: true, anonymous: true },
|
|
12
|
+
identities: { persist: true, anonymous: false },
|
|
13
|
+
ipfsGateway: { persist: true, anonymous: false },
|
|
14
|
+
isIpfsGatewayEnabled: { persist: true, anonymous: true },
|
|
15
|
+
isMultiAccountBalancesEnabled: { persist: true, anonymous: true },
|
|
16
|
+
lostIdentities: { persist: true, anonymous: false },
|
|
17
|
+
openSeaEnabled: { persist: true, anonymous: true },
|
|
18
|
+
securityAlertsEnabled: { persist: true, anonymous: true },
|
|
19
|
+
selectedAddress: { persist: true, anonymous: false },
|
|
20
|
+
showTestNetworks: { persist: true, anonymous: true },
|
|
21
|
+
showIncomingTransactions: { persist: true, anonymous: true },
|
|
22
|
+
useNftDetection: { persist: true, anonymous: true },
|
|
23
|
+
useTokenDetection: { persist: true, anonymous: true },
|
|
24
|
+
smartTransactionsOptInStatus: { persist: true, anonymous: false },
|
|
25
|
+
useTransactionSimulations: { persist: true, anonymous: true },
|
|
26
|
+
};
|
|
27
|
+
const name = 'PreferencesController';
|
|
28
|
+
/**
|
|
29
|
+
* Get the default PreferencesController state.
|
|
30
|
+
*
|
|
31
|
+
* @returns The default PreferencesController state.
|
|
32
|
+
*/
|
|
33
|
+
export function getDefaultPreferencesState() {
|
|
34
|
+
return {
|
|
35
|
+
featureFlags: {},
|
|
36
|
+
identities: {},
|
|
37
|
+
ipfsGateway: 'https://ipfs.io/ipfs/',
|
|
38
|
+
isIpfsGatewayEnabled: true,
|
|
39
|
+
isMultiAccountBalancesEnabled: true,
|
|
40
|
+
lostIdentities: {},
|
|
41
|
+
openSeaEnabled: false,
|
|
42
|
+
securityAlertsEnabled: false,
|
|
43
|
+
selectedAddress: '',
|
|
44
|
+
showIncomingTransactions: {
|
|
45
|
+
[ETHERSCAN_SUPPORTED_CHAIN_IDS.MAINNET]: true,
|
|
46
|
+
[ETHERSCAN_SUPPORTED_CHAIN_IDS.GOERLI]: true,
|
|
47
|
+
[ETHERSCAN_SUPPORTED_CHAIN_IDS.BSC]: true,
|
|
48
|
+
[ETHERSCAN_SUPPORTED_CHAIN_IDS.BSC_TESTNET]: true,
|
|
49
|
+
[ETHERSCAN_SUPPORTED_CHAIN_IDS.OPTIMISM]: true,
|
|
50
|
+
[ETHERSCAN_SUPPORTED_CHAIN_IDS.OPTIMISM_SEPOLIA]: true,
|
|
51
|
+
[ETHERSCAN_SUPPORTED_CHAIN_IDS.POLYGON]: true,
|
|
52
|
+
[ETHERSCAN_SUPPORTED_CHAIN_IDS.POLYGON_TESTNET]: true,
|
|
53
|
+
[ETHERSCAN_SUPPORTED_CHAIN_IDS.AVALANCHE]: true,
|
|
54
|
+
[ETHERSCAN_SUPPORTED_CHAIN_IDS.AVALANCHE_TESTNET]: true,
|
|
55
|
+
[ETHERSCAN_SUPPORTED_CHAIN_IDS.FANTOM]: true,
|
|
56
|
+
[ETHERSCAN_SUPPORTED_CHAIN_IDS.FANTOM_TESTNET]: true,
|
|
57
|
+
[ETHERSCAN_SUPPORTED_CHAIN_IDS.SEPOLIA]: true,
|
|
58
|
+
[ETHERSCAN_SUPPORTED_CHAIN_IDS.LINEA_GOERLI]: true,
|
|
59
|
+
[ETHERSCAN_SUPPORTED_CHAIN_IDS.LINEA_SEPOLIA]: true,
|
|
60
|
+
[ETHERSCAN_SUPPORTED_CHAIN_IDS.LINEA_MAINNET]: true,
|
|
61
|
+
[ETHERSCAN_SUPPORTED_CHAIN_IDS.MOONBEAM]: true,
|
|
62
|
+
[ETHERSCAN_SUPPORTED_CHAIN_IDS.MOONBEAM_TESTNET]: true,
|
|
63
|
+
[ETHERSCAN_SUPPORTED_CHAIN_IDS.MOONRIVER]: true,
|
|
64
|
+
[ETHERSCAN_SUPPORTED_CHAIN_IDS.GNOSIS]: true,
|
|
65
|
+
},
|
|
66
|
+
showTestNetworks: false,
|
|
67
|
+
useNftDetection: false,
|
|
68
|
+
useTokenDetection: true,
|
|
69
|
+
smartTransactionsOptInStatus: false,
|
|
70
|
+
useTransactionSimulations: true,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Controller that stores shared settings and exposes convenience methods
|
|
75
|
+
*/
|
|
76
|
+
export class PreferencesController extends BaseController {
|
|
77
|
+
/**
|
|
78
|
+
* Creates a PreferencesController instance.
|
|
79
|
+
*
|
|
80
|
+
* @param args - Arguments
|
|
81
|
+
* @param args.messenger - The preferences controller messenger.
|
|
82
|
+
* @param args.state - Preferences controller state.
|
|
83
|
+
*/
|
|
84
|
+
constructor({ messenger, state, }) {
|
|
85
|
+
super({
|
|
86
|
+
name,
|
|
87
|
+
metadata,
|
|
88
|
+
messenger,
|
|
89
|
+
state: {
|
|
90
|
+
...getDefaultPreferencesState(),
|
|
91
|
+
...state,
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
_PreferencesController_instances.add(this);
|
|
95
|
+
messenger.subscribe('KeyringController:stateChange', (keyringState) => {
|
|
96
|
+
const accounts = new Set();
|
|
97
|
+
for (const keyring of keyringState.keyrings) {
|
|
98
|
+
for (const account of keyring.accounts) {
|
|
99
|
+
accounts.add(account);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (accounts.size > 0) {
|
|
103
|
+
__classPrivateFieldGet(this, _PreferencesController_instances, "m", _PreferencesController_syncIdentities).call(this, Array.from(accounts));
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Adds identities to state.
|
|
109
|
+
*
|
|
110
|
+
* @param addresses - List of addresses to use to generate new identities.
|
|
111
|
+
*/
|
|
112
|
+
addIdentities(addresses) {
|
|
113
|
+
const checksummedAddresses = addresses.map((address) => toChecksumHexAddress(address));
|
|
114
|
+
this.update((state) => {
|
|
115
|
+
const { identities } = state;
|
|
116
|
+
for (const address of checksummedAddresses) {
|
|
117
|
+
if (identities[address]) {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
const identityCount = Object.keys(identities).length;
|
|
121
|
+
identities[address] = {
|
|
122
|
+
name: `Account ${identityCount + 1}`,
|
|
123
|
+
address,
|
|
124
|
+
importTime: Date.now(),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Removes an identity from state.
|
|
131
|
+
*
|
|
132
|
+
* @param address - Address of the identity to remove.
|
|
133
|
+
*/
|
|
134
|
+
removeIdentity(address) {
|
|
135
|
+
address = toChecksumHexAddress(address);
|
|
136
|
+
const { identities } = this.state;
|
|
137
|
+
if (!identities[address]) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
this.update((state) => {
|
|
141
|
+
delete state.identities[address];
|
|
142
|
+
if (address === state.selectedAddress) {
|
|
143
|
+
state.selectedAddress = Object.keys(state.identities)[0];
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Associates a new label with an identity.
|
|
149
|
+
*
|
|
150
|
+
* @param address - Address of the identity to associate.
|
|
151
|
+
* @param label - New label to assign.
|
|
152
|
+
*/
|
|
153
|
+
setAccountLabel(address, label) {
|
|
154
|
+
address = toChecksumHexAddress(address);
|
|
155
|
+
this.update((state) => {
|
|
156
|
+
const identity = state.identities[address] || {};
|
|
157
|
+
identity.name = label;
|
|
158
|
+
state.identities[address] = identity;
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Enable or disable a specific feature flag.
|
|
163
|
+
*
|
|
164
|
+
* @param feature - Feature to toggle.
|
|
165
|
+
* @param activated - Value to assign.
|
|
166
|
+
*/
|
|
167
|
+
setFeatureFlag(feature, activated) {
|
|
168
|
+
this.update((state) => {
|
|
169
|
+
state.featureFlags[feature] = activated;
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Sets selected address.
|
|
174
|
+
*
|
|
175
|
+
* @param selectedAddress - Ethereum address.
|
|
176
|
+
*/
|
|
177
|
+
setSelectedAddress(selectedAddress) {
|
|
178
|
+
this.update((state) => {
|
|
179
|
+
state.selectedAddress = toChecksumHexAddress(selectedAddress);
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Sets new IPFS gateway.
|
|
184
|
+
*
|
|
185
|
+
* @param ipfsGateway - IPFS gateway string.
|
|
186
|
+
*/
|
|
187
|
+
setIpfsGateway(ipfsGateway) {
|
|
188
|
+
this.update((state) => {
|
|
189
|
+
state.ipfsGateway = ipfsGateway;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Toggle the token detection setting.
|
|
194
|
+
*
|
|
195
|
+
* @param useTokenDetection - Boolean indicating user preference on token detection.
|
|
196
|
+
*/
|
|
197
|
+
setUseTokenDetection(useTokenDetection) {
|
|
198
|
+
this.update((state) => {
|
|
199
|
+
state.useTokenDetection = useTokenDetection;
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Toggle the NFT detection setting.
|
|
204
|
+
*
|
|
205
|
+
* @param useNftDetection - Boolean indicating user preference on NFT detection.
|
|
206
|
+
*/
|
|
207
|
+
setUseNftDetection(useNftDetection) {
|
|
208
|
+
if (useNftDetection && !this.state.openSeaEnabled) {
|
|
209
|
+
throw new Error('useNftDetection cannot be enabled if openSeaEnabled is false');
|
|
210
|
+
}
|
|
211
|
+
this.update((state) => {
|
|
212
|
+
state.useNftDetection = useNftDetection;
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Toggle the opensea enabled setting.
|
|
217
|
+
*
|
|
218
|
+
* @param openSeaEnabled - Boolean indicating user preference on using OpenSea's API.
|
|
219
|
+
*/
|
|
220
|
+
setOpenSeaEnabled(openSeaEnabled) {
|
|
221
|
+
this.update((state) => {
|
|
222
|
+
state.openSeaEnabled = openSeaEnabled;
|
|
223
|
+
if (!openSeaEnabled) {
|
|
224
|
+
state.useNftDetection = false;
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Toggle the security alert enabled setting.
|
|
230
|
+
*
|
|
231
|
+
* @param securityAlertsEnabled - Boolean indicating user preference on using security alerts.
|
|
232
|
+
*/
|
|
233
|
+
setSecurityAlertsEnabled(securityAlertsEnabled) {
|
|
234
|
+
this.update((state) => {
|
|
235
|
+
state.securityAlertsEnabled = securityAlertsEnabled;
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* A setter for the user preferences to enable/disable fetch of multiple accounts balance.
|
|
240
|
+
*
|
|
241
|
+
* @param isMultiAccountBalancesEnabled - true to enable multiple accounts balance fetch, false to fetch only selectedAddress.
|
|
242
|
+
*/
|
|
243
|
+
setIsMultiAccountBalancesEnabled(isMultiAccountBalancesEnabled) {
|
|
244
|
+
this.update((state) => {
|
|
245
|
+
state.isMultiAccountBalancesEnabled = isMultiAccountBalancesEnabled;
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* A setter for the user have the test networks visible/hidden.
|
|
250
|
+
*
|
|
251
|
+
* @param showTestNetworks - true to show test networks, false to hidden.
|
|
252
|
+
*/
|
|
253
|
+
setShowTestNetworks(showTestNetworks) {
|
|
254
|
+
this.update((state) => {
|
|
255
|
+
state.showTestNetworks = showTestNetworks;
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* A setter for the user allow to be fetched IPFS content
|
|
260
|
+
*
|
|
261
|
+
* @param isIpfsGatewayEnabled - true to enable ipfs source
|
|
262
|
+
*/
|
|
263
|
+
setIsIpfsGatewayEnabled(isIpfsGatewayEnabled) {
|
|
264
|
+
this.update((state) => {
|
|
265
|
+
state.isIpfsGatewayEnabled = isIpfsGatewayEnabled;
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* A setter for the user allow to be fetched IPFS content
|
|
270
|
+
*
|
|
271
|
+
* @param chainId - On hexadecimal format to enable the incoming transaction network
|
|
272
|
+
* @param isIncomingTransactionNetworkEnable - true to enable incoming transactions
|
|
273
|
+
*/
|
|
274
|
+
setEnableNetworkIncomingTransactions(chainId, isIncomingTransactionNetworkEnable) {
|
|
275
|
+
if (Object.values(ETHERSCAN_SUPPORTED_CHAIN_IDS).includes(chainId)) {
|
|
276
|
+
this.update((state) => {
|
|
277
|
+
state.showIncomingTransactions = {
|
|
278
|
+
...this.state.showIncomingTransactions,
|
|
279
|
+
[chainId]: isIncomingTransactionNetworkEnable,
|
|
280
|
+
};
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* A setter for the user to opt into smart transactions
|
|
286
|
+
*
|
|
287
|
+
* @param smartTransactionsOptInStatus - true to opt into smart transactions
|
|
288
|
+
*/
|
|
289
|
+
setSmartTransactionsOptInStatus(smartTransactionsOptInStatus) {
|
|
290
|
+
this.update((state) => {
|
|
291
|
+
state.smartTransactionsOptInStatus = smartTransactionsOptInStatus;
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* A setter for the user preferences to enable/disable transaction simulations.
|
|
296
|
+
*
|
|
297
|
+
* @param useTransactionSimulations - true to enable transaction simulations, false to disable it.
|
|
298
|
+
*/
|
|
299
|
+
setUseTransactionSimulations(useTransactionSimulations) {
|
|
300
|
+
this.update((state) => {
|
|
301
|
+
state.useTransactionSimulations = useTransactionSimulations;
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
_PreferencesController_instances = new WeakSet(), _PreferencesController_syncIdentities = function _PreferencesController_syncIdentities(addresses) {
|
|
306
|
+
addresses = addresses.map((address) => toChecksumHexAddress(address));
|
|
307
|
+
this.update((state) => {
|
|
308
|
+
const { identities } = state;
|
|
309
|
+
const newlyLost = {};
|
|
310
|
+
for (const [address, identity] of Object.entries(identities)) {
|
|
311
|
+
if (!addresses.includes(address)) {
|
|
312
|
+
newlyLost[address] = identity;
|
|
313
|
+
delete identities[address];
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
for (const [address, identity] of Object.entries(newlyLost)) {
|
|
317
|
+
state.lostIdentities[address] = identity;
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
this.addIdentities(addresses);
|
|
321
|
+
if (!addresses.includes(this.state.selectedAddress)) {
|
|
322
|
+
this.update((state) => {
|
|
323
|
+
state.selectedAddress = addresses[0];
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
export default PreferencesController;
|
|
12
328
|
//# sourceMappingURL=PreferencesController.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
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;AAsG5D,MAAM,QAAQ,GAAG;IACf,YAAY,EAAE,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,CAAC,CAAC;KACJ;AACH,CAAC;AAwJH,eAAe,qBAAqB,CAAC","sourcesContent":["import {\n BaseController,\n type ControllerStateChangeEvent,\n type ControllerGetStateAction,\n type RestrictedControllerMessenger,\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\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\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};\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 = RestrictedControllerMessenger<\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() {\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 smartTransactionsOptInStatus: false,\n useTransactionSimulations: true,\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 * 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\nexport default PreferencesController;\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ETHERSCAN_SUPPORTED_CHAIN_IDS = void 0;
|
|
4
|
+
exports.ETHERSCAN_SUPPORTED_CHAIN_IDS = {
|
|
5
|
+
MAINNET: '0x1',
|
|
6
|
+
GOERLI: '0x5',
|
|
7
|
+
BSC: '0x38',
|
|
8
|
+
BSC_TESTNET: '0x61',
|
|
9
|
+
OPTIMISM: '0xa',
|
|
10
|
+
OPTIMISM_SEPOLIA: '0xaa37dc',
|
|
11
|
+
POLYGON: '0x89',
|
|
12
|
+
POLYGON_TESTNET: '0x13881',
|
|
13
|
+
AVALANCHE: '0xa86a',
|
|
14
|
+
AVALANCHE_TESTNET: '0xa869',
|
|
15
|
+
FANTOM: '0xfa',
|
|
16
|
+
FANTOM_TESTNET: '0xfa2',
|
|
17
|
+
SEPOLIA: '0xaa36a7',
|
|
18
|
+
LINEA_GOERLI: '0xe704',
|
|
19
|
+
LINEA_SEPOLIA: '0xe705',
|
|
20
|
+
LINEA_MAINNET: '0xe708',
|
|
21
|
+
MOONBEAM: '0x504',
|
|
22
|
+
MOONBEAM_TESTNET: '0x507',
|
|
23
|
+
MOONRIVER: '0x505',
|
|
24
|
+
GNOSIS: '0x64',
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=constants.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,6BAA6B,GAAG;IAC3C,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,KAAK;IACb,GAAG,EAAE,MAAM;IACX,WAAW,EAAE,MAAM;IACnB,QAAQ,EAAE,KAAK;IACf,gBAAgB,EAAE,UAAU;IAC5B,OAAO,EAAE,MAAM;IACf,eAAe,EAAE,SAAS;IAC1B,SAAS,EAAE,QAAQ;IACnB,iBAAiB,EAAE,QAAQ;IAC3B,MAAM,EAAE,MAAM;IACd,cAAc,EAAE,OAAO;IACvB,OAAO,EAAE,UAAU;IACnB,YAAY,EAAE,QAAQ;IACtB,aAAa,EAAE,QAAQ;IACvB,aAAa,EAAE,QAAQ;IACvB,QAAQ,EAAE,OAAO;IACjB,gBAAgB,EAAE,OAAO;IACzB,SAAS,EAAE,OAAO;IAClB,MAAM,EAAE,MAAM;CACN,CAAC","sourcesContent":["export const ETHERSCAN_SUPPORTED_CHAIN_IDS = {\n MAINNET: '0x1',\n GOERLI: '0x5',\n BSC: '0x38',\n BSC_TESTNET: '0x61',\n OPTIMISM: '0xa',\n OPTIMISM_SEPOLIA: '0xaa37dc',\n POLYGON: '0x89',\n POLYGON_TESTNET: '0x13881',\n AVALANCHE: '0xa86a',\n AVALANCHE_TESTNET: '0xa869',\n FANTOM: '0xfa',\n FANTOM_TESTNET: '0xfa2',\n SEPOLIA: '0xaa36a7',\n LINEA_GOERLI: '0xe704',\n LINEA_SEPOLIA: '0xe705',\n LINEA_MAINNET: '0xe708',\n MOONBEAM: '0x504',\n MOONBEAM_TESTNET: '0x507',\n MOONRIVER: '0x505',\n GNOSIS: '0x64',\n} as const;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;CAqBhC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const ETHERSCAN_SUPPORTED_CHAIN_IDS: {
|
|
2
|
+
readonly MAINNET: "0x1";
|
|
3
|
+
readonly GOERLI: "0x5";
|
|
4
|
+
readonly BSC: "0x38";
|
|
5
|
+
readonly BSC_TESTNET: "0x61";
|
|
6
|
+
readonly OPTIMISM: "0xa";
|
|
7
|
+
readonly OPTIMISM_SEPOLIA: "0xaa37dc";
|
|
8
|
+
readonly POLYGON: "0x89";
|
|
9
|
+
readonly POLYGON_TESTNET: "0x13881";
|
|
10
|
+
readonly AVALANCHE: "0xa86a";
|
|
11
|
+
readonly AVALANCHE_TESTNET: "0xa869";
|
|
12
|
+
readonly FANTOM: "0xfa";
|
|
13
|
+
readonly FANTOM_TESTNET: "0xfa2";
|
|
14
|
+
readonly SEPOLIA: "0xaa36a7";
|
|
15
|
+
readonly LINEA_GOERLI: "0xe704";
|
|
16
|
+
readonly LINEA_SEPOLIA: "0xe705";
|
|
17
|
+
readonly LINEA_MAINNET: "0xe708";
|
|
18
|
+
readonly MOONBEAM: "0x504";
|
|
19
|
+
readonly MOONBEAM_TESTNET: "0x507";
|
|
20
|
+
readonly MOONRIVER: "0x505";
|
|
21
|
+
readonly GNOSIS: "0x64";
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=constants.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;CAqBhC,CAAC"}
|
package/dist/constants.mjs
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export const ETHERSCAN_SUPPORTED_CHAIN_IDS = {
|
|
2
|
+
MAINNET: '0x1',
|
|
3
|
+
GOERLI: '0x5',
|
|
4
|
+
BSC: '0x38',
|
|
5
|
+
BSC_TESTNET: '0x61',
|
|
6
|
+
OPTIMISM: '0xa',
|
|
7
|
+
OPTIMISM_SEPOLIA: '0xaa37dc',
|
|
8
|
+
POLYGON: '0x89',
|
|
9
|
+
POLYGON_TESTNET: '0x13881',
|
|
10
|
+
AVALANCHE: '0xa86a',
|
|
11
|
+
AVALANCHE_TESTNET: '0xa869',
|
|
12
|
+
FANTOM: '0xfa',
|
|
13
|
+
FANTOM_TESTNET: '0xfa2',
|
|
14
|
+
SEPOLIA: '0xaa36a7',
|
|
15
|
+
LINEA_GOERLI: '0xe704',
|
|
16
|
+
LINEA_SEPOLIA: '0xe705',
|
|
17
|
+
LINEA_MAINNET: '0xe708',
|
|
18
|
+
MOONBEAM: '0x504',
|
|
19
|
+
MOONBEAM_TESTNET: '0x507',
|
|
20
|
+
MOONRIVER: '0x505',
|
|
21
|
+
GNOSIS: '0x64',
|
|
6
22
|
};
|
|
7
23
|
//# sourceMappingURL=constants.mjs.map
|
package/dist/constants.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC3C,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,KAAK;IACb,GAAG,EAAE,MAAM;IACX,WAAW,EAAE,MAAM;IACnB,QAAQ,EAAE,KAAK;IACf,gBAAgB,EAAE,UAAU;IAC5B,OAAO,EAAE,MAAM;IACf,eAAe,EAAE,SAAS;IAC1B,SAAS,EAAE,QAAQ;IACnB,iBAAiB,EAAE,QAAQ;IAC3B,MAAM,EAAE,MAAM;IACd,cAAc,EAAE,OAAO;IACvB,OAAO,EAAE,UAAU;IACnB,YAAY,EAAE,QAAQ;IACtB,aAAa,EAAE,QAAQ;IACvB,aAAa,EAAE,QAAQ;IACvB,QAAQ,EAAE,OAAO;IACjB,gBAAgB,EAAE,OAAO;IACzB,SAAS,EAAE,OAAO;IAClB,MAAM,EAAE,MAAM;CACN,CAAC","sourcesContent":["export const ETHERSCAN_SUPPORTED_CHAIN_IDS = {\n MAINNET: '0x1',\n GOERLI: '0x5',\n BSC: '0x38',\n BSC_TESTNET: '0x61',\n OPTIMISM: '0xa',\n OPTIMISM_SEPOLIA: '0xaa37dc',\n POLYGON: '0x89',\n POLYGON_TESTNET: '0x13881',\n AVALANCHE: '0xa86a',\n AVALANCHE_TESTNET: '0xa869',\n FANTOM: '0xfa',\n FANTOM_TESTNET: '0xfa2',\n SEPOLIA: '0xaa36a7',\n LINEA_GOERLI: '0xe704',\n LINEA_SEPOLIA: '0xe705',\n LINEA_MAINNET: '0xe708',\n MOONBEAM: '0x504',\n MOONBEAM_TESTNET: '0x507',\n MOONRIVER: '0x505',\n GNOSIS: '0x64',\n} as const;\n"]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.ETHERSCAN_SUPPORTED_CHAIN_IDS = void 0;
|
|
18
|
+
__exportStar(require("./PreferencesController.cjs"), exports);
|
|
19
|
+
var constants_1 = require("./constants.cjs");
|
|
20
|
+
Object.defineProperty(exports, "ETHERSCAN_SUPPORTED_CHAIN_IDS", { enumerable: true, get: function () { return constants_1.ETHERSCAN_SUPPORTED_CHAIN_IDS; } });
|
|
21
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8DAAwC;AACxC,6CAA4D;AAAnD,0HAAA,6BAA6B,OAAA","sourcesContent":["export * from './PreferencesController';\nexport { ETHERSCAN_SUPPORTED_CHAIN_IDS } from './constants';\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4CAAwC;AACxC,OAAO,EAAE,6BAA6B,EAAE,wBAAoB"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4CAAwC;AACxC,OAAO,EAAE,6BAA6B,EAAE,wBAAoB"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
getDefaultPreferencesState
|
|
4
|
-
} from "./chunk-KFN3X2JE.mjs";
|
|
5
|
-
import {
|
|
6
|
-
ETHERSCAN_SUPPORTED_CHAIN_IDS
|
|
7
|
-
} from "./chunk-FT2APC4J.mjs";
|
|
8
|
-
export {
|
|
9
|
-
ETHERSCAN_SUPPORTED_CHAIN_IDS,
|
|
10
|
-
PreferencesController,
|
|
11
|
-
getDefaultPreferencesState
|
|
12
|
-
};
|
|
1
|
+
export * from "./PreferencesController.mjs";
|
|
2
|
+
export { ETHERSCAN_SUPPORTED_CHAIN_IDS } from "./constants.mjs";
|
|
13
3
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4CAAwC;AACxC,OAAO,EAAE,6BAA6B,EAAE,wBAAoB","sourcesContent":["export * from './PreferencesController';\nexport { ETHERSCAN_SUPPORTED_CHAIN_IDS } from './constants';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/preferences-controller",
|
|
3
|
-
"version": "13.0.2-preview-
|
|
3
|
+
"version": "13.0.2-preview-cf09c0a",
|
|
4
4
|
"description": "Manages user-configurable settings for MetaMask",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -18,19 +18,24 @@
|
|
|
18
18
|
"sideEffects": false,
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
|
-
"import":
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
"import": {
|
|
22
|
+
"types": "./dist/index.d.mts",
|
|
23
|
+
"default": "./dist/index.mjs"
|
|
24
|
+
},
|
|
25
|
+
"require": {
|
|
26
|
+
"types": "./dist/index.d.cts",
|
|
27
|
+
"default": "./dist/index.cjs"
|
|
28
|
+
}
|
|
24
29
|
},
|
|
25
30
|
"./package.json": "./package.json"
|
|
26
31
|
},
|
|
27
|
-
"main": "./dist/index.
|
|
28
|
-
"types": "./dist/
|
|
32
|
+
"main": "./dist/index.cjs",
|
|
33
|
+
"types": "./dist/index.d.cts",
|
|
29
34
|
"files": [
|
|
30
35
|
"dist/"
|
|
31
36
|
],
|
|
32
37
|
"scripts": {
|
|
33
|
-
"build": "
|
|
38
|
+
"build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
|
|
34
39
|
"build:docs": "typedoc",
|
|
35
40
|
"changelog:update": "../../scripts/update-changelog.sh @metamask/preferences-controller",
|
|
36
41
|
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/preferences-controller",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _chunkZ2JUHJIPjs = require('./chunk-Z2JUHJIP.js');
|
|
6
|
-
require('./chunk-POA2PUW4.js');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
exports.PreferencesController = _chunkZ2JUHJIPjs.PreferencesController; exports.default = _chunkZ2JUHJIPjs.PreferencesController_default; exports.getDefaultPreferencesState = _chunkZ2JUHJIPjs.getDefaultPreferencesState;
|
|
12
|
-
//# sourceMappingURL=PreferencesController.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|