@metamask-previews/multichain-account-service 0.6.0-preview-c977d80 → 0.6.0-preview-cfa64945
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/MultichainAccountGroup.cjs +35 -23
- package/dist/MultichainAccountGroup.cjs.map +1 -1
- package/dist/MultichainAccountGroup.d.cts +3 -1
- package/dist/MultichainAccountGroup.d.cts.map +1 -1
- package/dist/MultichainAccountGroup.d.mts +3 -1
- package/dist/MultichainAccountGroup.d.mts.map +1 -1
- package/dist/MultichainAccountGroup.mjs +35 -23
- package/dist/MultichainAccountGroup.mjs.map +1 -1
- package/dist/MultichainAccountService.cjs +2 -0
- package/dist/MultichainAccountService.cjs.map +1 -1
- package/dist/MultichainAccountService.d.cts.map +1 -1
- package/dist/MultichainAccountService.d.mts.map +1 -1
- package/dist/MultichainAccountService.mjs +2 -0
- package/dist/MultichainAccountService.mjs.map +1 -1
- package/dist/MultichainAccountWallet.cjs +122 -107
- package/dist/MultichainAccountWallet.cjs.map +1 -1
- package/dist/MultichainAccountWallet.d.cts +3 -1
- package/dist/MultichainAccountWallet.d.cts.map +1 -1
- package/dist/MultichainAccountWallet.d.mts +3 -1
- package/dist/MultichainAccountWallet.d.mts.map +1 -1
- package/dist/MultichainAccountWallet.mjs +122 -107
- package/dist/MultichainAccountWallet.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/tests/messenger.d.cts +2 -2
- package/dist/tests/messenger.d.cts.map +1 -1
- package/dist/tests/messenger.d.mts +2 -2
- package/dist/tests/messenger.d.mts.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +11 -1
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +11 -1
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _MultichainAccountWallet_id, _MultichainAccountWallet_providers, _MultichainAccountWallet_entropySource, _MultichainAccountWallet_accountGroups, _MultichainAccountWallet_isAlignmentInProgress;
|
|
12
|
+
var _MultichainAccountWallet_instances, _MultichainAccountWallet_id, _MultichainAccountWallet_providers, _MultichainAccountWallet_entropySource, _MultichainAccountWallet_accountGroups, _MultichainAccountWallet_messenger, _MultichainAccountWallet_initialized, _MultichainAccountWallet_isAlignmentInProgress, _MultichainAccountWallet_sync, _MultichainAccountWallet_createMultichainAccountGroup;
|
|
13
13
|
import { getGroupIndexFromMultichainAccountGroupId, isMultichainAccountGroupId, toMultichainAccountWalletId } from "@metamask/account-api";
|
|
14
14
|
import { toDefaultAccountGroupId } from "@metamask/account-api";
|
|
15
15
|
import { AccountWalletType } from "@metamask/account-api";
|
|
@@ -19,18 +19,24 @@ import { MultichainAccountGroup } from "./MultichainAccountGroup.mjs";
|
|
|
19
19
|
* group index).
|
|
20
20
|
*/
|
|
21
21
|
export class MultichainAccountWallet {
|
|
22
|
-
constructor({ providers, entropySource, }) {
|
|
22
|
+
constructor({ providers, entropySource, messenger, }) {
|
|
23
|
+
_MultichainAccountWallet_instances.add(this);
|
|
23
24
|
_MultichainAccountWallet_id.set(this, void 0);
|
|
24
25
|
_MultichainAccountWallet_providers.set(this, void 0);
|
|
25
26
|
_MultichainAccountWallet_entropySource.set(this, void 0);
|
|
26
27
|
_MultichainAccountWallet_accountGroups.set(this, void 0);
|
|
28
|
+
_MultichainAccountWallet_messenger.set(this, void 0);
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly
|
|
30
|
+
_MultichainAccountWallet_initialized.set(this, false);
|
|
27
31
|
_MultichainAccountWallet_isAlignmentInProgress.set(this, false);
|
|
28
32
|
__classPrivateFieldSet(this, _MultichainAccountWallet_id, toMultichainAccountWalletId(entropySource), "f");
|
|
29
33
|
__classPrivateFieldSet(this, _MultichainAccountWallet_providers, providers, "f");
|
|
30
34
|
__classPrivateFieldSet(this, _MultichainAccountWallet_entropySource, entropySource, "f");
|
|
35
|
+
__classPrivateFieldSet(this, _MultichainAccountWallet_messenger, messenger, "f");
|
|
31
36
|
__classPrivateFieldSet(this, _MultichainAccountWallet_accountGroups, new Map(), "f");
|
|
32
|
-
// Initial synchronization.
|
|
33
|
-
this.
|
|
37
|
+
// Initial synchronization (don't emit events during initialization).
|
|
38
|
+
__classPrivateFieldGet(this, _MultichainAccountWallet_instances, "m", _MultichainAccountWallet_sync).call(this);
|
|
39
|
+
__classPrivateFieldSet(this, _MultichainAccountWallet_initialized, true, "f");
|
|
34
40
|
}
|
|
35
41
|
/**
|
|
36
42
|
* Force wallet synchronization.
|
|
@@ -39,42 +45,7 @@ export class MultichainAccountWallet {
|
|
|
39
45
|
* doesn't know about.
|
|
40
46
|
*/
|
|
41
47
|
sync() {
|
|
42
|
-
|
|
43
|
-
for (const account of provider.getAccounts()) {
|
|
44
|
-
const { entropy } = account.options;
|
|
45
|
-
// Filter for this wallet only.
|
|
46
|
-
if (entropy.id !== this.entropySource) {
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
// This multichain account might exists already.
|
|
50
|
-
let multichainAccount = __classPrivateFieldGet(this, _MultichainAccountWallet_accountGroups, "f").get(entropy.groupIndex);
|
|
51
|
-
if (!multichainAccount) {
|
|
52
|
-
multichainAccount = new MultichainAccountGroup({
|
|
53
|
-
groupIndex: entropy.groupIndex,
|
|
54
|
-
wallet: this,
|
|
55
|
-
providers: __classPrivateFieldGet(this, _MultichainAccountWallet_providers, "f"),
|
|
56
|
-
});
|
|
57
|
-
// This existing multichain account group might differ from the
|
|
58
|
-
// `createMultichainAccountGroup` behavior. When creating a new
|
|
59
|
-
// group, we expect the providers to all succeed. But here, we're
|
|
60
|
-
// just fetching the account lists from them, so this group might
|
|
61
|
-
// not be "aligned" yet (e.g having a missing Solana account).
|
|
62
|
-
//
|
|
63
|
-
// Since "aligning" is an async operation, it would have to be run
|
|
64
|
-
// after the first-sync.
|
|
65
|
-
// TODO: Implement align mechanism to create "missing" accounts.
|
|
66
|
-
__classPrivateFieldGet(this, _MultichainAccountWallet_accountGroups, "f").set(entropy.groupIndex, multichainAccount);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
// Now force-sync all remaining multichain accounts.
|
|
71
|
-
for (const [groupIndex, multichainAccount,] of __classPrivateFieldGet(this, _MultichainAccountWallet_accountGroups, "f").entries()) {
|
|
72
|
-
multichainAccount.sync();
|
|
73
|
-
// Clean up old multichain accounts.
|
|
74
|
-
if (!multichainAccount.hasAccounts()) {
|
|
75
|
-
__classPrivateFieldGet(this, _MultichainAccountWallet_accountGroups, "f").delete(groupIndex);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
48
|
+
__classPrivateFieldGet(this, _MultichainAccountWallet_instances, "m", _MultichainAccountWallet_sync).call(this);
|
|
78
49
|
}
|
|
79
50
|
/**
|
|
80
51
|
* Gets the multichain account wallet ID.
|
|
@@ -163,71 +134,7 @@ export class MultichainAccountWallet {
|
|
|
163
134
|
* @returns The multichain account group for this group index.
|
|
164
135
|
*/
|
|
165
136
|
async createMultichainAccountGroup(groupIndex) {
|
|
166
|
-
|
|
167
|
-
if (groupIndex > nextGroupIndex) {
|
|
168
|
-
throw new Error(`You cannot use a group index that is higher than the next available one: expected <=${nextGroupIndex}, got ${groupIndex}`);
|
|
169
|
-
}
|
|
170
|
-
let group = this.getMultichainAccountGroup(groupIndex);
|
|
171
|
-
if (group) {
|
|
172
|
-
// If the group already exists, we just `sync` it and returns the same
|
|
173
|
-
// reference.
|
|
174
|
-
group.sync();
|
|
175
|
-
return group;
|
|
176
|
-
}
|
|
177
|
-
const results = await Promise.allSettled(__classPrivateFieldGet(this, _MultichainAccountWallet_providers, "f").map((provider) => provider.createAccounts({
|
|
178
|
-
entropySource: __classPrivateFieldGet(this, _MultichainAccountWallet_entropySource, "f"),
|
|
179
|
-
groupIndex,
|
|
180
|
-
})));
|
|
181
|
-
// --------------------------------------------------------------------------------
|
|
182
|
-
// READ THIS CAREFULLY:
|
|
183
|
-
//
|
|
184
|
-
// Since we're not "fully supporting multichain" for now, we still rely on single
|
|
185
|
-
// :accountCreated events to sync multichain account groups and wallets. Which means
|
|
186
|
-
// that even if of the provider fails, some accounts will still be created on some
|
|
187
|
-
// other providers and will become "available" on the `AccountsController`, like:
|
|
188
|
-
//
|
|
189
|
-
// 1. Creating a multichain account group for index 1
|
|
190
|
-
// 2. EvmAccountProvider.createAccounts returns the EVM account for index 1
|
|
191
|
-
// * AccountsController WILL fire :accountCreated for this account
|
|
192
|
-
// * This account WILL BE "available" on the AccountsController state
|
|
193
|
-
// 3. SolAccountProvider.createAccounts fails to create a Solana account for index 1
|
|
194
|
-
// * AccountsController WON't fire :accountCreated for this account
|
|
195
|
-
// * This account WON'T be "available" on the Account
|
|
196
|
-
// 4. MultichainAccountService will receive a :accountCreated for the EVM account from
|
|
197
|
-
// step 2 and will create a new multichain account group for index 1, but it won't
|
|
198
|
-
// receive any event for the Solana account of this group. Thus, this group won't be
|
|
199
|
-
// "aligned" (missing "blockchain account" on this group).
|
|
200
|
-
//
|
|
201
|
-
// --------------------------------------------------------------------------------
|
|
202
|
-
// If any of the provider failed to create their accounts, then we consider the
|
|
203
|
-
// multichain account group to have failed too.
|
|
204
|
-
if (results.some((result) => result.status === 'rejected')) {
|
|
205
|
-
// NOTE: Some accounts might still have been created on other account providers. We
|
|
206
|
-
// don't rollback them.
|
|
207
|
-
const error = `Unable to create multichain account group for index: ${groupIndex}`;
|
|
208
|
-
let warn = `${error}:`;
|
|
209
|
-
for (const result of results) {
|
|
210
|
-
if (result.status === 'rejected') {
|
|
211
|
-
warn += `\n- ${result.reason}`;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
console.warn(warn);
|
|
215
|
-
throw new Error(error);
|
|
216
|
-
}
|
|
217
|
-
// Because of the :accountAdded automatic sync, we might already have created the
|
|
218
|
-
// group, so we first try to get it.
|
|
219
|
-
group = this.getMultichainAccountGroup(groupIndex);
|
|
220
|
-
if (!group) {
|
|
221
|
-
// If for some reason it's still not created, we're creating it explicitly now:
|
|
222
|
-
group = new MultichainAccountGroup({
|
|
223
|
-
wallet: this,
|
|
224
|
-
providers: __classPrivateFieldGet(this, _MultichainAccountWallet_providers, "f"),
|
|
225
|
-
groupIndex,
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
// Register the account to our internal map.
|
|
229
|
-
__classPrivateFieldGet(this, _MultichainAccountWallet_accountGroups, "f").set(groupIndex, group); // `group` cannot be undefined here.
|
|
230
|
-
return group;
|
|
137
|
+
return __classPrivateFieldGet(this, _MultichainAccountWallet_instances, "m", _MultichainAccountWallet_createMultichainAccountGroup).call(this, groupIndex);
|
|
231
138
|
}
|
|
232
139
|
/**
|
|
233
140
|
* Creates the next multichain account group.
|
|
@@ -236,7 +143,7 @@ export class MultichainAccountWallet {
|
|
|
236
143
|
* @returns The multichain account group for the next group index available.
|
|
237
144
|
*/
|
|
238
145
|
async createNextMultichainAccountGroup() {
|
|
239
|
-
return this.
|
|
146
|
+
return __classPrivateFieldGet(this, _MultichainAccountWallet_instances, "m", _MultichainAccountWallet_createMultichainAccountGroup).call(this, this.getNextGroupIndex());
|
|
240
147
|
}
|
|
241
148
|
/**
|
|
242
149
|
* Gets whether alignment is currently in progress for this wallet.
|
|
@@ -283,5 +190,113 @@ export class MultichainAccountWallet {
|
|
|
283
190
|
}
|
|
284
191
|
}
|
|
285
192
|
}
|
|
286
|
-
_MultichainAccountWallet_id = new WeakMap(), _MultichainAccountWallet_providers = new WeakMap(), _MultichainAccountWallet_entropySource = new WeakMap(), _MultichainAccountWallet_accountGroups = new WeakMap(), _MultichainAccountWallet_isAlignmentInProgress = new WeakMap()
|
|
193
|
+
_MultichainAccountWallet_id = new WeakMap(), _MultichainAccountWallet_providers = new WeakMap(), _MultichainAccountWallet_entropySource = new WeakMap(), _MultichainAccountWallet_accountGroups = new WeakMap(), _MultichainAccountWallet_messenger = new WeakMap(), _MultichainAccountWallet_initialized = new WeakMap(), _MultichainAccountWallet_isAlignmentInProgress = new WeakMap(), _MultichainAccountWallet_instances = new WeakSet(), _MultichainAccountWallet_sync = function _MultichainAccountWallet_sync() {
|
|
194
|
+
for (const provider of __classPrivateFieldGet(this, _MultichainAccountWallet_providers, "f")) {
|
|
195
|
+
for (const account of provider.getAccounts()) {
|
|
196
|
+
const { entropy } = account.options;
|
|
197
|
+
// Filter for this wallet only.
|
|
198
|
+
if (entropy.id !== this.entropySource) {
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
// This multichain account might exists already.
|
|
202
|
+
let multichainAccount = __classPrivateFieldGet(this, _MultichainAccountWallet_accountGroups, "f").get(entropy.groupIndex);
|
|
203
|
+
if (!multichainAccount) {
|
|
204
|
+
multichainAccount = new MultichainAccountGroup({
|
|
205
|
+
groupIndex: entropy.groupIndex,
|
|
206
|
+
wallet: this,
|
|
207
|
+
providers: __classPrivateFieldGet(this, _MultichainAccountWallet_providers, "f"),
|
|
208
|
+
messenger: __classPrivateFieldGet(this, _MultichainAccountWallet_messenger, "f"),
|
|
209
|
+
});
|
|
210
|
+
// This existing multichain account group might differ from the
|
|
211
|
+
// `createMultichainAccountGroup` behavior. When creating a new
|
|
212
|
+
// group, we expect the providers to all succeed. But here, we're
|
|
213
|
+
// just fetching the account lists from them, so this group might
|
|
214
|
+
// not be "aligned" yet (e.g having a missing Solana account).
|
|
215
|
+
//
|
|
216
|
+
// Since "aligning" is an async operation, it would have to be run
|
|
217
|
+
// after the first-sync.
|
|
218
|
+
// TODO: Implement align mechanism to create "missing" accounts.
|
|
219
|
+
__classPrivateFieldGet(this, _MultichainAccountWallet_accountGroups, "f").set(entropy.groupIndex, multichainAccount);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
// Now force-sync all remaining multichain accounts.
|
|
224
|
+
for (const [groupIndex, multichainAccount,] of __classPrivateFieldGet(this, _MultichainAccountWallet_accountGroups, "f").entries()) {
|
|
225
|
+
multichainAccount.sync();
|
|
226
|
+
// Clean up old multichain accounts.
|
|
227
|
+
if (!multichainAccount.hasAccounts()) {
|
|
228
|
+
__classPrivateFieldGet(this, _MultichainAccountWallet_accountGroups, "f").delete(groupIndex);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}, _MultichainAccountWallet_createMultichainAccountGroup = async function _MultichainAccountWallet_createMultichainAccountGroup(groupIndex) {
|
|
232
|
+
const nextGroupIndex = this.getNextGroupIndex();
|
|
233
|
+
if (groupIndex > nextGroupIndex) {
|
|
234
|
+
throw new Error(`You cannot use a group index that is higher than the next available one: expected <=${nextGroupIndex}, got ${groupIndex}`);
|
|
235
|
+
}
|
|
236
|
+
let group = this.getMultichainAccountGroup(groupIndex);
|
|
237
|
+
if (group) {
|
|
238
|
+
// If the group already exists, we just `sync` it and returns the same
|
|
239
|
+
// reference.
|
|
240
|
+
group.sync();
|
|
241
|
+
return group;
|
|
242
|
+
}
|
|
243
|
+
const results = await Promise.allSettled(__classPrivateFieldGet(this, _MultichainAccountWallet_providers, "f").map((provider) => provider.createAccounts({
|
|
244
|
+
entropySource: __classPrivateFieldGet(this, _MultichainAccountWallet_entropySource, "f"),
|
|
245
|
+
groupIndex,
|
|
246
|
+
})));
|
|
247
|
+
// --------------------------------------------------------------------------------
|
|
248
|
+
// READ THIS CAREFULLY:
|
|
249
|
+
//
|
|
250
|
+
// Since we're not "fully supporting multichain" for now, we still rely on single
|
|
251
|
+
// :accountCreated events to sync multichain account groups and wallets. Which means
|
|
252
|
+
// that even if of the provider fails, some accounts will still be created on some
|
|
253
|
+
// other providers and will become "available" on the `AccountsController`, like:
|
|
254
|
+
//
|
|
255
|
+
// 1. Creating a multichain account group for index 1
|
|
256
|
+
// 2. EvmAccountProvider.createAccounts returns the EVM account for index 1
|
|
257
|
+
// * AccountsController WILL fire :accountCreated for this account
|
|
258
|
+
// * This account WILL BE "available" on the AccountsController state
|
|
259
|
+
// 3. SolAccountProvider.createAccounts fails to create a Solana account for index 1
|
|
260
|
+
// * AccountsController WON't fire :accountCreated for this account
|
|
261
|
+
// * This account WON'T be "available" on the Account
|
|
262
|
+
// 4. MultichainAccountService will receive a :accountCreated for the EVM account from
|
|
263
|
+
// step 2 and will create a new multichain account group for index 1, but it won't
|
|
264
|
+
// receive any event for the Solana account of this group. Thus, this group won't be
|
|
265
|
+
// "aligned" (missing "blockchain account" on this group).
|
|
266
|
+
//
|
|
267
|
+
// --------------------------------------------------------------------------------
|
|
268
|
+
// If any of the provider failed to create their accounts, then we consider the
|
|
269
|
+
// multichain account group to have failed too.
|
|
270
|
+
if (results.some((result) => result.status === 'rejected')) {
|
|
271
|
+
// NOTE: Some accounts might still have been created on other account providers. We
|
|
272
|
+
// don't rollback them.
|
|
273
|
+
const error = `Unable to create multichain account group for index: ${groupIndex}`;
|
|
274
|
+
let warn = `${error}:`;
|
|
275
|
+
for (const result of results) {
|
|
276
|
+
if (result.status === 'rejected') {
|
|
277
|
+
warn += `\n- ${result.reason}`;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
console.warn(warn);
|
|
281
|
+
throw new Error(error);
|
|
282
|
+
}
|
|
283
|
+
// Because of the :accountAdded automatic sync, we might already have created the
|
|
284
|
+
// group, so we first try to get it.
|
|
285
|
+
group = this.getMultichainAccountGroup(groupIndex);
|
|
286
|
+
if (!group) {
|
|
287
|
+
// If for some reason it's still not created, we're creating it explicitly now:
|
|
288
|
+
group = new MultichainAccountGroup({
|
|
289
|
+
wallet: this,
|
|
290
|
+
providers: __classPrivateFieldGet(this, _MultichainAccountWallet_providers, "f"),
|
|
291
|
+
groupIndex,
|
|
292
|
+
messenger: __classPrivateFieldGet(this, _MultichainAccountWallet_messenger, "f"),
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
// Register the account to our internal map.
|
|
296
|
+
__classPrivateFieldGet(this, _MultichainAccountWallet_accountGroups, "f").set(groupIndex, group); // `group` cannot be undefined here.
|
|
297
|
+
if (__classPrivateFieldGet(this, _MultichainAccountWallet_initialized, "f")) {
|
|
298
|
+
__classPrivateFieldGet(this, _MultichainAccountWallet_messenger, "f").publish('MultichainAccountService:multichainAccountGroupCreated', group);
|
|
299
|
+
}
|
|
300
|
+
return group;
|
|
301
|
+
};
|
|
287
302
|
//# sourceMappingURL=MultichainAccountWallet.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultichainAccountWallet.mjs","sourceRoot":"","sources":["../src/MultichainAccountWallet.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EACL,yCAAyC,EACzC,0BAA0B,EAC1B,2BAA2B,EAC5B,8BAA8B;AAC/B,OAAO,EAAE,uBAAuB,EAAE,8BAA8B;AAChE,OAAO,EAAE,iBAAiB,EAAE,8BAA8B;AAa1D,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAElE;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IAclC,YAAY,EACV,SAAS,EACT,aAAa,GAId;QAhBQ,8CAA+B;QAE/B,qDAAuC;QAEvC,yDAAgC;QAEhC,yDAA6D;QAEtE,yDAAkC,KAAK,EAAC;QAStC,uBAAA,IAAI,+BAAO,2BAA2B,CAAC,aAAa,CAAC,MAAA,CAAC;QACtD,uBAAA,IAAI,sCAAc,SAAS,MAAA,CAAC;QAC5B,uBAAA,IAAI,0CAAkB,aAAa,MAAA,CAAC;QACpC,uBAAA,IAAI,0CAAkB,IAAI,GAAG,EAAE,MAAA,CAAC;QAEhC,2BAA2B;QAC3B,IA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,KAAK,MAAA,CAAC;SACrC;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,UAAU,CAAC,UAAkB;QACjC,IAAI,uBAAA,IAAI,sDAAuB,EAAE;YAC/B,OAAO,CAAC,gCAAgC;SACzC;QAED,uBAAA,IAAI,kDAA0B,IAAI,MAAA,CAAC;QACnC,IAAI;YACF,MAAM,KAAK,GAAG,IAAI,CAAC,yBAAyB,CAAC,UAAU,CAAC,CAAC;YACzD,IAAI,KAAK,EAAE;gBACT,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;aACrB;SACF;gBAAS;YACR,uBAAA,IAAI,kDAA0B,KAAK,MAAA,CAAC;SACrC;IACH,CAAC;CACF","sourcesContent":["import {\n getGroupIndexFromMultichainAccountGroupId,\n isMultichainAccountGroupId,\n toMultichainAccountWalletId,\n} from '@metamask/account-api';\nimport { toDefaultAccountGroupId } from '@metamask/account-api';\nimport { AccountWalletType } from '@metamask/account-api';\nimport type {\n Bip44Account,\n MultichainAccountWalletId,\n MultichainAccountWallet as MultichainAccountWalletDefinition,\n} from '@metamask/account-api';\nimport type { AccountGroupId } from '@metamask/account-api';\nimport type { AccountProvider } from '@metamask/account-api';\nimport {\n type EntropySourceId,\n type KeyringAccount,\n} from '@metamask/keyring-api';\n\nimport { MultichainAccountGroup } from './MultichainAccountGroup';\n\n/**\n * A multichain account wallet that holds multiple multichain accounts (one multichain account per\n * group index).\n */\nexport class MultichainAccountWallet<\n Account extends Bip44Account<KeyringAccount>,\n> implements MultichainAccountWalletDefinition<Account>\n{\n readonly #id: MultichainAccountWalletId;\n\n readonly #providers: AccountProvider<Account>[];\n\n readonly #entropySource: EntropySourceId;\n\n readonly #accountGroups: Map<number, MultichainAccountGroup<Account>>;\n\n #isAlignmentInProgress: boolean = false;\n\n constructor({\n providers,\n entropySource,\n }: {\n providers: AccountProvider<Account>[];\n entropySource: EntropySourceId;\n }) {\n this.#id = toMultichainAccountWalletId(entropySource);\n this.#providers = providers;\n this.#entropySource = entropySource;\n this.#accountGroups = new Map();\n\n // Initial synchronization.\n this.sync();\n }\n\n /**\n * Force wallet synchronization.\n *\n * This can be used if account providers got new accounts that the wallet\n * doesn't know about.\n */\n sync(): void {\n for (const provider of this.#providers) {\n for (const account of provider.getAccounts()) {\n const { entropy } = account.options;\n\n // Filter for this wallet only.\n if (entropy.id !== this.entropySource) {\n continue;\n }\n\n // This multichain account might exists already.\n let multichainAccount = this.#accountGroups.get(entropy.groupIndex);\n if (!multichainAccount) {\n multichainAccount = new MultichainAccountGroup<Account>({\n groupIndex: entropy.groupIndex,\n wallet: this,\n providers: this.#providers,\n });\n\n // This existing multichain account group might differ from the\n // `createMultichainAccountGroup` behavior. When creating a new\n // group, we expect the providers to all succeed. But here, we're\n // just fetching the account lists from them, so this group might\n // not be \"aligned\" yet (e.g having a missing Solana account).\n //\n // Since \"aligning\" is an async operation, it would have to be run\n // after the first-sync.\n // TODO: Implement align mechanism to create \"missing\" accounts.\n\n this.#accountGroups.set(entropy.groupIndex, multichainAccount);\n }\n }\n }\n\n // Now force-sync all remaining multichain accounts.\n for (const [\n groupIndex,\n multichainAccount,\n ] of this.#accountGroups.entries()) {\n multichainAccount.sync();\n\n // Clean up old multichain accounts.\n if (!multichainAccount.hasAccounts()) {\n this.#accountGroups.delete(groupIndex);\n }\n }\n }\n\n /**\n * Gets the multichain account wallet ID.\n *\n * @returns The multichain account wallet ID.\n */\n get id(): MultichainAccountWalletId {\n return this.#id;\n }\n\n /**\n * Gets the multichain account wallet type, which is always {@link AccountWalletType.Entropy}.\n *\n * @returns The multichain account wallet type.\n */\n get type(): AccountWalletType.Entropy {\n return AccountWalletType.Entropy;\n }\n\n /**\n * Gets the multichain account wallet entropy source.\n *\n * @returns The multichain account wallet entropy source.\n */\n get entropySource(): EntropySourceId {\n return this.#entropySource;\n }\n\n /**\n * Gets multichain account for a given ID.\n * The default group ID will default to the multichain account with index 0.\n *\n * @param id - Account group ID.\n * @returns Account group.\n */\n getAccountGroup(\n id: AccountGroupId,\n ): MultichainAccountGroup<Account> | undefined {\n // We consider the \"default case\" to be mapped to index 0.\n if (id === toDefaultAccountGroupId(this.id)) {\n return this.#accountGroups.get(0);\n }\n\n // If it is not a valid ID, we cannot extract the group index\n // from it, so we fail fast.\n if (!isMultichainAccountGroupId(id)) {\n return undefined;\n }\n\n const groupIndex = getGroupIndexFromMultichainAccountGroupId(id);\n return this.#accountGroups.get(groupIndex);\n }\n\n /**\n * Gets all multichain accounts. Similar to {@link MultichainAccountWallet.getMultichainAccountGroups}.\n *\n * @returns The multichain accounts.\n */\n getAccountGroups(): MultichainAccountGroup<Account>[] {\n return this.getMultichainAccountGroups();\n }\n\n /**\n * Gets multichain account group for a given index.\n *\n * @param groupIndex - Multichain account index.\n * @returns The multichain account associated with the given index.\n */\n getMultichainAccountGroup(\n groupIndex: number,\n ): MultichainAccountGroup<Account> | undefined {\n return this.#accountGroups.get(groupIndex);\n }\n\n /**\n * Gets all multichain account groups.\n *\n * @returns The multichain accounts.\n */\n getMultichainAccountGroups(): MultichainAccountGroup<Account>[] {\n return Array.from(this.#accountGroups.values()); // TODO: Prevent copy here.\n }\n\n /**\n * Gets next group index for this wallet.\n *\n * @returns The next group index of this wallet.\n */\n getNextGroupIndex(): number {\n // We do not check for gaps.\n return (\n Math.max(\n -1, // So it will default to 0 if no groups.\n ...this.#accountGroups.keys(),\n ) + 1\n );\n }\n\n /**\n * Creates a multichain account group for a given group index.\n *\n * @param groupIndex - The group index to use.\n * @throws If any of the account providers fails to create their accounts.\n * @returns The multichain account group for this group index.\n */\n async createMultichainAccountGroup(\n groupIndex: number,\n ): Promise<MultichainAccountGroup<Account>> {\n const nextGroupIndex = this.getNextGroupIndex();\n if (groupIndex > nextGroupIndex) {\n throw new Error(\n `You cannot use a group index that is higher than the next available one: expected <=${nextGroupIndex}, got ${groupIndex}`,\n );\n }\n\n let group = this.getMultichainAccountGroup(groupIndex);\n if (group) {\n // If the group already exists, we just `sync` it and returns the same\n // reference.\n group.sync();\n\n return group;\n }\n\n const results = await Promise.allSettled(\n this.#providers.map((provider) =>\n provider.createAccounts({\n entropySource: this.#entropySource,\n groupIndex,\n }),\n ),\n );\n\n // --------------------------------------------------------------------------------\n // READ THIS CAREFULLY:\n //\n // Since we're not \"fully supporting multichain\" for now, we still rely on single\n // :accountCreated events to sync multichain account groups and wallets. Which means\n // that even if of the provider fails, some accounts will still be created on some\n // other providers and will become \"available\" on the `AccountsController`, like:\n //\n // 1. Creating a multichain account group for index 1\n // 2. EvmAccountProvider.createAccounts returns the EVM account for index 1\n // * AccountsController WILL fire :accountCreated for this account\n // * This account WILL BE \"available\" on the AccountsController state\n // 3. SolAccountProvider.createAccounts fails to create a Solana account for index 1\n // * AccountsController WON't fire :accountCreated for this account\n // * This account WON'T be \"available\" on the Account\n // 4. MultichainAccountService will receive a :accountCreated for the EVM account from\n // step 2 and will create a new multichain account group for index 1, but it won't\n // receive any event for the Solana account of this group. Thus, this group won't be\n // \"aligned\" (missing \"blockchain account\" on this group).\n //\n // --------------------------------------------------------------------------------\n\n // If any of the provider failed to create their accounts, then we consider the\n // multichain account group to have failed too.\n if (results.some((result) => result.status === 'rejected')) {\n // NOTE: Some accounts might still have been created on other account providers. We\n // don't rollback them.\n const error = `Unable to create multichain account group for index: ${groupIndex}`;\n\n let warn = `${error}:`;\n for (const result of results) {\n if (result.status === 'rejected') {\n warn += `\\n- ${result.reason}`;\n }\n }\n console.warn(warn);\n\n throw new Error(error);\n }\n\n // Because of the :accountAdded automatic sync, we might already have created the\n // group, so we first try to get it.\n group = this.getMultichainAccountGroup(groupIndex);\n if (!group) {\n // If for some reason it's still not created, we're creating it explicitly now:\n group = new MultichainAccountGroup({\n wallet: this,\n providers: this.#providers,\n groupIndex,\n });\n }\n\n // Register the account to our internal map.\n this.#accountGroups.set(groupIndex, group); // `group` cannot be undefined here.\n\n return group;\n }\n\n /**\n * Creates the next multichain account group.\n *\n * @throws If any of the account providers fails to create their accounts.\n * @returns The multichain account group for the next group index available.\n */\n async createNextMultichainAccountGroup(): Promise<\n MultichainAccountGroup<Account>\n > {\n return this.createMultichainAccountGroup(this.getNextGroupIndex());\n }\n\n /**\n * Gets whether alignment is currently in progress for this wallet.\n *\n * @returns True if alignment is in progress, false otherwise.\n */\n getIsAlignmentInProgress(): boolean {\n return this.#isAlignmentInProgress;\n }\n\n /**\n * Align all multichain account groups.\n */\n async alignGroups(): Promise<void> {\n if (this.#isAlignmentInProgress) {\n return; // Prevent concurrent alignments\n }\n\n this.#isAlignmentInProgress = true;\n try {\n const groups = this.getMultichainAccountGroups();\n await Promise.all(groups.map((g) => g.align()));\n } finally {\n this.#isAlignmentInProgress = false;\n }\n }\n\n /**\n * Align a specific multichain account group.\n *\n * @param groupIndex - The group index to align.\n */\n async alignGroup(groupIndex: number): Promise<void> {\n if (this.#isAlignmentInProgress) {\n return; // Prevent concurrent alignments\n }\n\n this.#isAlignmentInProgress = true;\n try {\n const group = this.getMultichainAccountGroup(groupIndex);\n if (group) {\n await group.align();\n }\n } finally {\n this.#isAlignmentInProgress = false;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MultichainAccountWallet.mjs","sourceRoot":"","sources":["../src/MultichainAccountWallet.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EACL,yCAAyC,EACzC,0BAA0B,EAC1B,2BAA2B,EAC5B,8BAA8B;AAC/B,OAAO,EAAE,uBAAuB,EAAE,8BAA8B;AAChE,OAAO,EAAE,iBAAiB,EAAE,8BAA8B;AAa1D,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAGlE;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IAmBlC,YAAY,EACV,SAAS,EACT,aAAa,EACb,SAAS,GAKV;;QAvBQ,8CAA+B;QAE/B,qDAAuC;QAEvC,yDAAgC;QAEhC,yDAA6D;QAE7D,qDAA8C;QAEvD,8DAA8D;QAC9D,+CAAe,KAAK,EAAC;QAErB,yDAAkC,KAAK,EAAC;QAWtC,uBAAA,IAAI,+BAA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,0DAA0D;IAC1D,EAAE;IACF,mFAAmF;IAEnF,+EAA+E;IAC/E,+CAA+C;IAC/C,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,UAAU,CAAC,EAAE;QAC1D,mFAAmF;QACnF,uBAAuB;QACvB,MAAM,KAAK,GAAG,wDAAwD,UAAU,EAAE,CAAC;QAEnF,IAAI,IAAI,GAAG,GAAG,KAAK,GAAG,CAAC;QACvB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;YAC5B,IAAI,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;gBAChC,IAAI,IAAI,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC;aAChC;SACF;QACD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEnB,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;KACxB;IAED,iFAAiF;IACjF,oCAAoC;IACpC,KAAK,GAAG,IAAI,CAAC,yBAAyB,CAAC,UAAU,CAAC,CAAC;IACnD,IAAI,CAAC,KAAK,EAAE;QACV,+EAA+E;QAC/E,KAAK,GAAG,IAAI,sBAAsB,CAAC;YACjC,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE,uBAAA,IAAI,0CAAW;YAC1B,UAAU;YACV,SAAS,EAAE,uBAAA,IAAI,0CAAW;SAC3B,CAAC,CAAC;KACJ;IAED,4CAA4C;IAC5C,uBAAA,IAAI,8CAAe,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC,oCAAoC;IAEhF,IAAI,uBAAA,IAAI,4CAAa,EAAE;QACrB,uBAAA,IAAI,0CAAW,CAAC,OAAO,CACrB,wDAAwD,EACxD,KAAK,CACN,CAAC;KACH;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import {\n getGroupIndexFromMultichainAccountGroupId,\n isMultichainAccountGroupId,\n toMultichainAccountWalletId,\n} from '@metamask/account-api';\nimport { toDefaultAccountGroupId } from '@metamask/account-api';\nimport { AccountWalletType } from '@metamask/account-api';\nimport type {\n Bip44Account,\n MultichainAccountWalletId,\n MultichainAccountWallet as MultichainAccountWalletDefinition,\n} from '@metamask/account-api';\nimport type { AccountGroupId } from '@metamask/account-api';\nimport type { AccountProvider } from '@metamask/account-api';\nimport {\n type EntropySourceId,\n type KeyringAccount,\n} from '@metamask/keyring-api';\n\nimport { MultichainAccountGroup } from './MultichainAccountGroup';\nimport type { MultichainAccountServiceMessenger } from './types';\n\n/**\n * A multichain account wallet that holds multiple multichain accounts (one multichain account per\n * group index).\n */\nexport class MultichainAccountWallet<\n Account extends Bip44Account<KeyringAccount>,\n> implements MultichainAccountWalletDefinition<Account>\n{\n readonly #id: MultichainAccountWalletId;\n\n readonly #providers: AccountProvider<Account>[];\n\n readonly #entropySource: EntropySourceId;\n\n readonly #accountGroups: Map<number, MultichainAccountGroup<Account>>;\n\n readonly #messenger: MultichainAccountServiceMessenger;\n\n // eslint-disable-next-line @typescript-eslint/prefer-readonly\n #initialized = false;\n\n #isAlignmentInProgress: boolean = false;\n\n constructor({\n providers,\n entropySource,\n messenger,\n }: {\n providers: AccountProvider<Account>[];\n entropySource: EntropySourceId;\n messenger: MultichainAccountServiceMessenger;\n }) {\n this.#id = toMultichainAccountWalletId(entropySource);\n this.#providers = providers;\n this.#entropySource = entropySource;\n this.#messenger = messenger;\n this.#accountGroups = new Map();\n\n // Initial synchronization (don't emit events during initialization).\n this.#sync();\n this.#initialized = true;\n }\n\n /**\n * Force wallet synchronization.\n *\n * This can be used if account providers got new accounts that the wallet\n * doesn't know about.\n */\n sync(): void {\n this.#sync();\n }\n\n #sync(): void {\n for (const provider of this.#providers) {\n for (const account of provider.getAccounts()) {\n const { entropy } = account.options;\n\n // Filter for this wallet only.\n if (entropy.id !== this.entropySource) {\n continue;\n }\n\n // This multichain account might exists already.\n let multichainAccount = this.#accountGroups.get(entropy.groupIndex);\n if (!multichainAccount) {\n multichainAccount = new MultichainAccountGroup<Account>({\n groupIndex: entropy.groupIndex,\n wallet: this,\n providers: this.#providers,\n messenger: this.#messenger,\n });\n\n // This existing multichain account group might differ from the\n // `createMultichainAccountGroup` behavior. When creating a new\n // group, we expect the providers to all succeed. But here, we're\n // just fetching the account lists from them, so this group might\n // not be \"aligned\" yet (e.g having a missing Solana account).\n //\n // Since \"aligning\" is an async operation, it would have to be run\n // after the first-sync.\n // TODO: Implement align mechanism to create \"missing\" accounts.\n\n this.#accountGroups.set(entropy.groupIndex, multichainAccount);\n }\n }\n }\n\n // Now force-sync all remaining multichain accounts.\n for (const [\n groupIndex,\n multichainAccount,\n ] of this.#accountGroups.entries()) {\n multichainAccount.sync();\n\n // Clean up old multichain accounts.\n if (!multichainAccount.hasAccounts()) {\n this.#accountGroups.delete(groupIndex);\n }\n }\n }\n\n /**\n * Gets the multichain account wallet ID.\n *\n * @returns The multichain account wallet ID.\n */\n get id(): MultichainAccountWalletId {\n return this.#id;\n }\n\n /**\n * Gets the multichain account wallet type, which is always {@link AccountWalletType.Entropy}.\n *\n * @returns The multichain account wallet type.\n */\n get type(): AccountWalletType.Entropy {\n return AccountWalletType.Entropy;\n }\n\n /**\n * Gets the multichain account wallet entropy source.\n *\n * @returns The multichain account wallet entropy source.\n */\n get entropySource(): EntropySourceId {\n return this.#entropySource;\n }\n\n /**\n * Gets multichain account for a given ID.\n * The default group ID will default to the multichain account with index 0.\n *\n * @param id - Account group ID.\n * @returns Account group.\n */\n getAccountGroup(\n id: AccountGroupId,\n ): MultichainAccountGroup<Account> | undefined {\n // We consider the \"default case\" to be mapped to index 0.\n if (id === toDefaultAccountGroupId(this.id)) {\n return this.#accountGroups.get(0);\n }\n\n // If it is not a valid ID, we cannot extract the group index\n // from it, so we fail fast.\n if (!isMultichainAccountGroupId(id)) {\n return undefined;\n }\n\n const groupIndex = getGroupIndexFromMultichainAccountGroupId(id);\n return this.#accountGroups.get(groupIndex);\n }\n\n /**\n * Gets all multichain accounts. Similar to {@link MultichainAccountWallet.getMultichainAccountGroups}.\n *\n * @returns The multichain accounts.\n */\n getAccountGroups(): MultichainAccountGroup<Account>[] {\n return this.getMultichainAccountGroups();\n }\n\n /**\n * Gets multichain account group for a given index.\n *\n * @param groupIndex - Multichain account index.\n * @returns The multichain account associated with the given index.\n */\n getMultichainAccountGroup(\n groupIndex: number,\n ): MultichainAccountGroup<Account> | undefined {\n return this.#accountGroups.get(groupIndex);\n }\n\n /**\n * Gets all multichain account groups.\n *\n * @returns The multichain accounts.\n */\n getMultichainAccountGroups(): MultichainAccountGroup<Account>[] {\n return Array.from(this.#accountGroups.values()); // TODO: Prevent copy here.\n }\n\n /**\n * Gets next group index for this wallet.\n *\n * @returns The next group index of this wallet.\n */\n getNextGroupIndex(): number {\n // We do not check for gaps.\n return (\n Math.max(\n -1, // So it will default to 0 if no groups.\n ...this.#accountGroups.keys(),\n ) + 1\n );\n }\n\n /**\n * Creates a multichain account group for a given group index.\n *\n * @param groupIndex - The group index to use.\n * @throws If any of the account providers fails to create their accounts.\n * @returns The multichain account group for this group index.\n */\n async createMultichainAccountGroup(\n groupIndex: number,\n ): Promise<MultichainAccountGroup<Account>> {\n return this.#createMultichainAccountGroup(groupIndex);\n }\n\n async #createMultichainAccountGroup(\n groupIndex: number,\n ): Promise<MultichainAccountGroup<Account>> {\n const nextGroupIndex = this.getNextGroupIndex();\n if (groupIndex > nextGroupIndex) {\n throw new Error(\n `You cannot use a group index that is higher than the next available one: expected <=${nextGroupIndex}, got ${groupIndex}`,\n );\n }\n\n let group = this.getMultichainAccountGroup(groupIndex);\n if (group) {\n // If the group already exists, we just `sync` it and returns the same\n // reference.\n group.sync();\n\n return group;\n }\n\n const results = await Promise.allSettled(\n this.#providers.map((provider) =>\n provider.createAccounts({\n entropySource: this.#entropySource,\n groupIndex,\n }),\n ),\n );\n\n // --------------------------------------------------------------------------------\n // READ THIS CAREFULLY:\n //\n // Since we're not \"fully supporting multichain\" for now, we still rely on single\n // :accountCreated events to sync multichain account groups and wallets. Which means\n // that even if of the provider fails, some accounts will still be created on some\n // other providers and will become \"available\" on the `AccountsController`, like:\n //\n // 1. Creating a multichain account group for index 1\n // 2. EvmAccountProvider.createAccounts returns the EVM account for index 1\n // * AccountsController WILL fire :accountCreated for this account\n // * This account WILL BE \"available\" on the AccountsController state\n // 3. SolAccountProvider.createAccounts fails to create a Solana account for index 1\n // * AccountsController WON't fire :accountCreated for this account\n // * This account WON'T be \"available\" on the Account\n // 4. MultichainAccountService will receive a :accountCreated for the EVM account from\n // step 2 and will create a new multichain account group for index 1, but it won't\n // receive any event for the Solana account of this group. Thus, this group won't be\n // \"aligned\" (missing \"blockchain account\" on this group).\n //\n // --------------------------------------------------------------------------------\n\n // If any of the provider failed to create their accounts, then we consider the\n // multichain account group to have failed too.\n if (results.some((result) => result.status === 'rejected')) {\n // NOTE: Some accounts might still have been created on other account providers. We\n // don't rollback them.\n const error = `Unable to create multichain account group for index: ${groupIndex}`;\n\n let warn = `${error}:`;\n for (const result of results) {\n if (result.status === 'rejected') {\n warn += `\\n- ${result.reason}`;\n }\n }\n console.warn(warn);\n\n throw new Error(error);\n }\n\n // Because of the :accountAdded automatic sync, we might already have created the\n // group, so we first try to get it.\n group = this.getMultichainAccountGroup(groupIndex);\n if (!group) {\n // If for some reason it's still not created, we're creating it explicitly now:\n group = new MultichainAccountGroup({\n wallet: this,\n providers: this.#providers,\n groupIndex,\n messenger: this.#messenger,\n });\n }\n\n // Register the account to our internal map.\n this.#accountGroups.set(groupIndex, group); // `group` cannot be undefined here.\n\n if (this.#initialized) {\n this.#messenger.publish(\n 'MultichainAccountService:multichainAccountGroupCreated',\n group,\n );\n }\n\n return group;\n }\n\n /**\n * Creates the next multichain account group.\n *\n * @throws If any of the account providers fails to create their accounts.\n * @returns The multichain account group for the next group index available.\n */\n async createNextMultichainAccountGroup(): Promise<\n MultichainAccountGroup<Account>\n > {\n return this.#createMultichainAccountGroup(this.getNextGroupIndex());\n }\n\n /**\n * Gets whether alignment is currently in progress for this wallet.\n *\n * @returns True if alignment is in progress, false otherwise.\n */\n getIsAlignmentInProgress(): boolean {\n return this.#isAlignmentInProgress;\n }\n\n /**\n * Align all multichain account groups.\n */\n async alignGroups(): Promise<void> {\n if (this.#isAlignmentInProgress) {\n return; // Prevent concurrent alignments\n }\n\n this.#isAlignmentInProgress = true;\n try {\n const groups = this.getMultichainAccountGroups();\n await Promise.all(groups.map((g) => g.align()));\n } finally {\n this.#isAlignmentInProgress = false;\n }\n }\n\n /**\n * Align a specific multichain account group.\n *\n * @param groupIndex - The group index to align.\n */\n async alignGroup(groupIndex: number): Promise<void> {\n if (this.#isAlignmentInProgress) {\n return; // Prevent concurrent alignments\n }\n\n this.#isAlignmentInProgress = true;\n try {\n const group = this.getMultichainAccountGroup(groupIndex);\n if (group) {\n await group.align();\n }\n } finally {\n this.#isAlignmentInProgress = false;\n }\n }\n}\n"]}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAeA,mDAIqB;AAHnB,mHAAA,sBAAsB,OAAA;AACtB,qHAAA,wBAAwB,OAAA;AACxB,gHAAA,mBAAmB,OAAA;AAErB,yEAAoE;AAA3D,kIAAA,uBAAuB,OAAA;AAChC,uEAAkE;AAAzD,gIAAA,sBAAsB,OAAA;AAC/B,2EAAsE;AAA7D,oIAAA,wBAAwB,OAAA","sourcesContent":["export type {\n MultichainAccountServiceActions,\n MultichainAccountServiceEvents,\n MultichainAccountServiceMessenger,\n MultichainAccountServiceGetMultichainAccountGroupAction,\n MultichainAccountServiceGetMultichainAccountWalletAction,\n MultichainAccountServiceGetMultichainAccountWalletsAction,\n MultichainAccountServiceGetMultichainAccountGroupsAction,\n MultichainAccountServiceCreateMultichainAccountGroupAction,\n MultichainAccountServiceCreateNextMultichainAccountGroupAction,\n MultichainAccountServiceGetIsAlignmentInProgressAction,\n MultichainAccountServiceSetBasicFunctionalityAction,\n MultichainAccountServiceMultichainAccountGroupCreatedEvent,\n MultichainAccountServiceMultichainAccountGroupUpdatedEvent,\n} from './types';\nexport {\n AccountProviderWrapper,\n BaseBip44AccountProvider,\n SnapAccountProvider,\n} from './providers';\nexport { MultichainAccountWallet } from './MultichainAccountWallet';\nexport { MultichainAccountGroup } from './MultichainAccountGroup';\nexport { MultichainAccountService } from './MultichainAccountService';\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { MultichainAccountServiceActions, MultichainAccountServiceEvents, MultichainAccountServiceMessenger, MultichainAccountServiceGetMultichainAccountGroupAction, MultichainAccountServiceGetMultichainAccountWalletAction, MultichainAccountServiceGetMultichainAccountWalletsAction, MultichainAccountServiceGetMultichainAccountGroupsAction, MultichainAccountServiceCreateMultichainAccountGroupAction, MultichainAccountServiceCreateNextMultichainAccountGroupAction, MultichainAccountServiceGetIsAlignmentInProgressAction, MultichainAccountServiceSetBasicFunctionalityAction, } from "./types.cjs";
|
|
1
|
+
export type { MultichainAccountServiceActions, MultichainAccountServiceEvents, MultichainAccountServiceMessenger, MultichainAccountServiceGetMultichainAccountGroupAction, MultichainAccountServiceGetMultichainAccountWalletAction, MultichainAccountServiceGetMultichainAccountWalletsAction, MultichainAccountServiceGetMultichainAccountGroupsAction, MultichainAccountServiceCreateMultichainAccountGroupAction, MultichainAccountServiceCreateNextMultichainAccountGroupAction, MultichainAccountServiceGetIsAlignmentInProgressAction, MultichainAccountServiceSetBasicFunctionalityAction, MultichainAccountServiceMultichainAccountGroupCreatedEvent, MultichainAccountServiceMultichainAccountGroupUpdatedEvent, } from "./types.cjs";
|
|
2
2
|
export { AccountProviderWrapper, BaseBip44AccountProvider, SnapAccountProvider, } from "./providers/index.cjs";
|
|
3
3
|
export { MultichainAccountWallet } from "./MultichainAccountWallet.cjs";
|
|
4
4
|
export { MultichainAccountGroup } from "./MultichainAccountGroup.cjs";
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,EACjC,uDAAuD,EACvD,wDAAwD,EACxD,yDAAyD,EACzD,wDAAwD,EACxD,0DAA0D,EAC1D,8DAA8D,EAC9D,sDAAsD,EACtD,mDAAmD,
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,EACjC,uDAAuD,EACvD,wDAAwD,EACxD,yDAAyD,EACzD,wDAAwD,EACxD,0DAA0D,EAC1D,8DAA8D,EAC9D,sDAAsD,EACtD,mDAAmD,EACnD,0DAA0D,EAC1D,0DAA0D,GAC3D,oBAAgB;AACjB,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,GACpB,8BAAoB;AACrB,OAAO,EAAE,uBAAuB,EAAE,sCAAkC;AACpE,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAClE,OAAO,EAAE,wBAAwB,EAAE,uCAAmC"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { MultichainAccountServiceActions, MultichainAccountServiceEvents, MultichainAccountServiceMessenger, MultichainAccountServiceGetMultichainAccountGroupAction, MultichainAccountServiceGetMultichainAccountWalletAction, MultichainAccountServiceGetMultichainAccountWalletsAction, MultichainAccountServiceGetMultichainAccountGroupsAction, MultichainAccountServiceCreateMultichainAccountGroupAction, MultichainAccountServiceCreateNextMultichainAccountGroupAction, MultichainAccountServiceGetIsAlignmentInProgressAction, MultichainAccountServiceSetBasicFunctionalityAction, } from "./types.mjs";
|
|
1
|
+
export type { MultichainAccountServiceActions, MultichainAccountServiceEvents, MultichainAccountServiceMessenger, MultichainAccountServiceGetMultichainAccountGroupAction, MultichainAccountServiceGetMultichainAccountWalletAction, MultichainAccountServiceGetMultichainAccountWalletsAction, MultichainAccountServiceGetMultichainAccountGroupsAction, MultichainAccountServiceCreateMultichainAccountGroupAction, MultichainAccountServiceCreateNextMultichainAccountGroupAction, MultichainAccountServiceGetIsAlignmentInProgressAction, MultichainAccountServiceSetBasicFunctionalityAction, MultichainAccountServiceMultichainAccountGroupCreatedEvent, MultichainAccountServiceMultichainAccountGroupUpdatedEvent, } from "./types.mjs";
|
|
2
2
|
export { AccountProviderWrapper, BaseBip44AccountProvider, SnapAccountProvider, } from "./providers/index.mjs";
|
|
3
3
|
export { MultichainAccountWallet } from "./MultichainAccountWallet.mjs";
|
|
4
4
|
export { MultichainAccountGroup } from "./MultichainAccountGroup.mjs";
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,EACjC,uDAAuD,EACvD,wDAAwD,EACxD,yDAAyD,EACzD,wDAAwD,EACxD,0DAA0D,EAC1D,8DAA8D,EAC9D,sDAAsD,EACtD,mDAAmD,
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,EACjC,uDAAuD,EACvD,wDAAwD,EACxD,yDAAyD,EACzD,wDAAwD,EACxD,0DAA0D,EAC1D,8DAA8D,EAC9D,sDAAsD,EACtD,mDAAmD,EACnD,0DAA0D,EAC1D,0DAA0D,GAC3D,oBAAgB;AACjB,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,GACpB,8BAAoB;AACrB,OAAO,EAAE,uBAAuB,EAAE,sCAAkC;AACpE,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAClE,OAAO,EAAE,wBAAwB,EAAE,uCAAmC"}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,EACpB,8BAAoB;AACrB,OAAO,EAAE,uBAAuB,EAAE,sCAAkC;AACpE,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAClE,OAAO,EAAE,wBAAwB,EAAE,uCAAmC","sourcesContent":["export type {\n MultichainAccountServiceActions,\n MultichainAccountServiceEvents,\n MultichainAccountServiceMessenger,\n MultichainAccountServiceGetMultichainAccountGroupAction,\n MultichainAccountServiceGetMultichainAccountWalletAction,\n MultichainAccountServiceGetMultichainAccountWalletsAction,\n MultichainAccountServiceGetMultichainAccountGroupsAction,\n MultichainAccountServiceCreateMultichainAccountGroupAction,\n MultichainAccountServiceCreateNextMultichainAccountGroupAction,\n MultichainAccountServiceGetIsAlignmentInProgressAction,\n MultichainAccountServiceSetBasicFunctionalityAction,\n MultichainAccountServiceMultichainAccountGroupCreatedEvent,\n MultichainAccountServiceMultichainAccountGroupUpdatedEvent,\n} from './types';\nexport {\n AccountProviderWrapper,\n BaseBip44AccountProvider,\n SnapAccountProvider,\n} from './providers';\nexport { MultichainAccountWallet } from './MultichainAccountWallet';\nexport { MultichainAccountGroup } from './MultichainAccountGroup';\nexport { MultichainAccountService } from './MultichainAccountService';\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Messenger } from "@metamask/base-controller";
|
|
2
|
-
import type { AllowedActions, AllowedEvents, MultichainAccountServiceActions, MultichainAccountServiceMessenger } from "../types.cjs";
|
|
2
|
+
import type { AllowedActions, AllowedEvents, MultichainAccountServiceActions, MultichainAccountServiceEvents, MultichainAccountServiceMessenger } from "../types.cjs";
|
|
3
3
|
/**
|
|
4
4
|
* Creates a new root messenger instance for testing.
|
|
5
5
|
*
|
|
6
6
|
* @returns A new Messenger instance.
|
|
7
7
|
*/
|
|
8
|
-
export declare function getRootMessenger(): Messenger<MultichainAccountServiceActions | AllowedActions, AllowedEvents>;
|
|
8
|
+
export declare function getRootMessenger(): Messenger<MultichainAccountServiceActions | AllowedActions, MultichainAccountServiceEvents | AllowedEvents>;
|
|
9
9
|
/**
|
|
10
10
|
* Retrieves a restricted messenger for the MultichainAccountService.
|
|
11
11
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messenger.d.cts","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kCAAkC;AAEtD,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,+BAA+B,
|
|
1
|
+
{"version":3,"file":"messenger.d.cts","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kCAAkC;AAEtD,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,EAClC,qBAAiB;AAElB;;;;GAIG;AACH,wBAAgB,gBAAgB,gHAK/B;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,SAAS,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GAC7C,iCAAiC,CAiBnC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Messenger } from "@metamask/base-controller";
|
|
2
|
-
import type { AllowedActions, AllowedEvents, MultichainAccountServiceActions, MultichainAccountServiceMessenger } from "../types.mjs";
|
|
2
|
+
import type { AllowedActions, AllowedEvents, MultichainAccountServiceActions, MultichainAccountServiceEvents, MultichainAccountServiceMessenger } from "../types.mjs";
|
|
3
3
|
/**
|
|
4
4
|
* Creates a new root messenger instance for testing.
|
|
5
5
|
*
|
|
6
6
|
* @returns A new Messenger instance.
|
|
7
7
|
*/
|
|
8
|
-
export declare function getRootMessenger(): Messenger<MultichainAccountServiceActions | AllowedActions, AllowedEvents>;
|
|
8
|
+
export declare function getRootMessenger(): Messenger<MultichainAccountServiceActions | AllowedActions, MultichainAccountServiceEvents | AllowedEvents>;
|
|
9
9
|
/**
|
|
10
10
|
* Retrieves a restricted messenger for the MultichainAccountService.
|
|
11
11
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messenger.d.mts","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kCAAkC;AAEtD,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,+BAA+B,
|
|
1
|
+
{"version":3,"file":"messenger.d.mts","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kCAAkC;AAEtD,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,EAClC,qBAAiB;AAElB;;;;GAIG;AACH,wBAAgB,gBAAgB,gHAK/B;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,SAAS,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GAC7C,iCAAiC,CAiBnC"}
|
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n AccountsControllerAccountAddedEvent,\n AccountsControllerAccountRemovedEvent,\n AccountsControllerGetAccountAction,\n AccountsControllerGetAccountByAddressAction,\n AccountsControllerListMultichainAccountsAction,\n} from '@metamask/accounts-controller';\nimport type { RestrictedMessenger } from '@metamask/base-controller';\nimport type {\n KeyringControllerGetStateAction,\n KeyringControllerStateChangeEvent,\n KeyringControllerWithKeyringAction,\n} from '@metamask/keyring-controller';\nimport type { HandleSnapRequest as SnapControllerHandleSnapRequestAction } from '@metamask/snaps-controllers';\n\nimport type {\n MultichainAccountService,\n serviceName,\n} from './MultichainAccountService';\n\nexport type MultichainAccountServiceGetMultichainAccountGroupAction = {\n type: `${typeof serviceName}:getMultichainAccountGroup`;\n handler: MultichainAccountService['getMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountGroupsAction = {\n type: `${typeof serviceName}:getMultichainAccountGroups`;\n handler: MultichainAccountService['getMultichainAccountGroups'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountWalletAction = {\n type: `${typeof serviceName}:getMultichainAccountWallet`;\n handler: MultichainAccountService['getMultichainAccountWallet'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountWalletsAction = {\n type: `${typeof serviceName}:getMultichainAccountWallets`;\n handler: MultichainAccountService['getMultichainAccountWallets'];\n};\n\nexport type MultichainAccountServiceCreateNextMultichainAccountGroupAction = {\n type: `${typeof serviceName}:createNextMultichainAccountGroup`;\n handler: MultichainAccountService['createNextMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceCreateMultichainAccountGroupAction = {\n type: `${typeof serviceName}:createMultichainAccountGroup`;\n handler: MultichainAccountService['createMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceSetBasicFunctionalityAction = {\n type: `${typeof serviceName}:setBasicFunctionality`;\n handler: MultichainAccountService['setBasicFunctionality'];\n};\n\nexport type MultichainAccountServiceAlignWalletAction = {\n type: `${typeof serviceName}:alignWallet`;\n handler: MultichainAccountService['alignWallet'];\n};\n\nexport type MultichainAccountServiceAlignWalletsAction = {\n type: `${typeof serviceName}:alignWallets`;\n handler: MultichainAccountService['alignWallets'];\n};\n\nexport type MultichainAccountServiceGetIsAlignmentInProgressAction = {\n type: `${typeof serviceName}:getIsAlignmentInProgress`;\n handler: MultichainAccountService['getIsAlignmentInProgress'];\n};\n\n/**\n * All actions that {@link MultichainAccountService} registers so that other\n * modules can call them.\n */\nexport type MultichainAccountServiceActions =\n | MultichainAccountServiceGetMultichainAccountGroupAction\n | MultichainAccountServiceGetMultichainAccountGroupsAction\n | MultichainAccountServiceGetMultichainAccountWalletAction\n | MultichainAccountServiceGetMultichainAccountWalletsAction\n | MultichainAccountServiceCreateNextMultichainAccountGroupAction\n | MultichainAccountServiceCreateMultichainAccountGroupAction\n | MultichainAccountServiceSetBasicFunctionalityAction\n | MultichainAccountServiceAlignWalletAction\n | MultichainAccountServiceAlignWalletsAction\n | MultichainAccountServiceGetIsAlignmentInProgressAction;\n\n/**\n * All events that {@link MultichainAccountService} publishes so that other modules\n * can subscribe to them.\n */\nexport type MultichainAccountServiceEvents
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n Bip44Account,\n MultichainAccountGroup,\n} from '@metamask/account-api';\nimport type {\n AccountsControllerAccountAddedEvent,\n AccountsControllerAccountRemovedEvent,\n AccountsControllerGetAccountAction,\n AccountsControllerGetAccountByAddressAction,\n AccountsControllerListMultichainAccountsAction,\n} from '@metamask/accounts-controller';\nimport type { RestrictedMessenger } from '@metamask/base-controller';\nimport type { KeyringAccount } from '@metamask/keyring-api';\nimport type {\n KeyringControllerGetStateAction,\n KeyringControllerStateChangeEvent,\n KeyringControllerWithKeyringAction,\n} from '@metamask/keyring-controller';\nimport type { HandleSnapRequest as SnapControllerHandleSnapRequestAction } from '@metamask/snaps-controllers';\n\nimport type {\n MultichainAccountService,\n serviceName,\n} from './MultichainAccountService';\n\nexport type MultichainAccountServiceGetMultichainAccountGroupAction = {\n type: `${typeof serviceName}:getMultichainAccountGroup`;\n handler: MultichainAccountService['getMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountGroupsAction = {\n type: `${typeof serviceName}:getMultichainAccountGroups`;\n handler: MultichainAccountService['getMultichainAccountGroups'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountWalletAction = {\n type: `${typeof serviceName}:getMultichainAccountWallet`;\n handler: MultichainAccountService['getMultichainAccountWallet'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountWalletsAction = {\n type: `${typeof serviceName}:getMultichainAccountWallets`;\n handler: MultichainAccountService['getMultichainAccountWallets'];\n};\n\nexport type MultichainAccountServiceCreateNextMultichainAccountGroupAction = {\n type: `${typeof serviceName}:createNextMultichainAccountGroup`;\n handler: MultichainAccountService['createNextMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceCreateMultichainAccountGroupAction = {\n type: `${typeof serviceName}:createMultichainAccountGroup`;\n handler: MultichainAccountService['createMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceSetBasicFunctionalityAction = {\n type: `${typeof serviceName}:setBasicFunctionality`;\n handler: MultichainAccountService['setBasicFunctionality'];\n};\n\nexport type MultichainAccountServiceAlignWalletAction = {\n type: `${typeof serviceName}:alignWallet`;\n handler: MultichainAccountService['alignWallet'];\n};\n\nexport type MultichainAccountServiceAlignWalletsAction = {\n type: `${typeof serviceName}:alignWallets`;\n handler: MultichainAccountService['alignWallets'];\n};\n\nexport type MultichainAccountServiceGetIsAlignmentInProgressAction = {\n type: `${typeof serviceName}:getIsAlignmentInProgress`;\n handler: MultichainAccountService['getIsAlignmentInProgress'];\n};\n\n/**\n * All actions that {@link MultichainAccountService} registers so that other\n * modules can call them.\n */\nexport type MultichainAccountServiceActions =\n | MultichainAccountServiceGetMultichainAccountGroupAction\n | MultichainAccountServiceGetMultichainAccountGroupsAction\n | MultichainAccountServiceGetMultichainAccountWalletAction\n | MultichainAccountServiceGetMultichainAccountWalletsAction\n | MultichainAccountServiceCreateNextMultichainAccountGroupAction\n | MultichainAccountServiceCreateMultichainAccountGroupAction\n | MultichainAccountServiceSetBasicFunctionalityAction\n | MultichainAccountServiceAlignWalletAction\n | MultichainAccountServiceAlignWalletsAction\n | MultichainAccountServiceGetIsAlignmentInProgressAction;\n\nexport type MultichainAccountServiceMultichainAccountGroupCreatedEvent = {\n type: `${typeof serviceName}:multichainAccountGroupCreated`;\n payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];\n};\n\nexport type MultichainAccountServiceMultichainAccountGroupUpdatedEvent = {\n type: `${typeof serviceName}:multichainAccountGroupUpdated`;\n payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];\n};\n\n/**\n * All events that {@link MultichainAccountService} publishes so that other modules\n * can subscribe to them.\n */\nexport type MultichainAccountServiceEvents =\n | MultichainAccountServiceMultichainAccountGroupCreatedEvent\n | MultichainAccountServiceMultichainAccountGroupUpdatedEvent;\n\n/**\n * All actions registered by other modules that {@link MultichainAccountService}\n * calls.\n */\nexport type AllowedActions =\n | AccountsControllerListMultichainAccountsAction\n | AccountsControllerGetAccountAction\n | AccountsControllerGetAccountByAddressAction\n | SnapControllerHandleSnapRequestAction\n | KeyringControllerWithKeyringAction\n | KeyringControllerGetStateAction;\n\n/**\n * All events published by other modules that {@link MultichainAccountService}\n * subscribes to.\n */\nexport type AllowedEvents =\n | KeyringControllerStateChangeEvent\n | AccountsControllerAccountAddedEvent\n | AccountsControllerAccountRemovedEvent;\n\n/**\n * The messenger restricted to actions and events that\n * {@link MultichainAccountService} needs to access.\n */\nexport type MultichainAccountServiceMessenger = RestrictedMessenger<\n 'MultichainAccountService',\n MultichainAccountServiceActions | AllowedActions,\n MultichainAccountServiceEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n"]}
|
package/dist/types.d.cts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { Bip44Account, MultichainAccountGroup } from "@metamask/account-api";
|
|
1
2
|
import type { AccountsControllerAccountAddedEvent, AccountsControllerAccountRemovedEvent, AccountsControllerGetAccountAction, AccountsControllerGetAccountByAddressAction, AccountsControllerListMultichainAccountsAction } from "@metamask/accounts-controller";
|
|
2
3
|
import type { RestrictedMessenger } from "@metamask/base-controller";
|
|
4
|
+
import type { KeyringAccount } from "@metamask/keyring-api";
|
|
3
5
|
import type { KeyringControllerGetStateAction, KeyringControllerStateChangeEvent, KeyringControllerWithKeyringAction } from "@metamask/keyring-controller";
|
|
4
6
|
import type { HandleSnapRequest as SnapControllerHandleSnapRequestAction } from "@metamask/snaps-controllers";
|
|
5
7
|
import type { MultichainAccountService, serviceName } from "./MultichainAccountService.cjs";
|
|
@@ -48,11 +50,19 @@ export type MultichainAccountServiceGetIsAlignmentInProgressAction = {
|
|
|
48
50
|
* modules can call them.
|
|
49
51
|
*/
|
|
50
52
|
export type MultichainAccountServiceActions = MultichainAccountServiceGetMultichainAccountGroupAction | MultichainAccountServiceGetMultichainAccountGroupsAction | MultichainAccountServiceGetMultichainAccountWalletAction | MultichainAccountServiceGetMultichainAccountWalletsAction | MultichainAccountServiceCreateNextMultichainAccountGroupAction | MultichainAccountServiceCreateMultichainAccountGroupAction | MultichainAccountServiceSetBasicFunctionalityAction | MultichainAccountServiceAlignWalletAction | MultichainAccountServiceAlignWalletsAction | MultichainAccountServiceGetIsAlignmentInProgressAction;
|
|
53
|
+
export type MultichainAccountServiceMultichainAccountGroupCreatedEvent = {
|
|
54
|
+
type: `${typeof serviceName}:multichainAccountGroupCreated`;
|
|
55
|
+
payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];
|
|
56
|
+
};
|
|
57
|
+
export type MultichainAccountServiceMultichainAccountGroupUpdatedEvent = {
|
|
58
|
+
type: `${typeof serviceName}:multichainAccountGroupUpdated`;
|
|
59
|
+
payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];
|
|
60
|
+
};
|
|
51
61
|
/**
|
|
52
62
|
* All events that {@link MultichainAccountService} publishes so that other modules
|
|
53
63
|
* can subscribe to them.
|
|
54
64
|
*/
|
|
55
|
-
export type MultichainAccountServiceEvents =
|
|
65
|
+
export type MultichainAccountServiceEvents = MultichainAccountServiceMultichainAccountGroupCreatedEvent | MultichainAccountServiceMultichainAccountGroupUpdatedEvent;
|
|
56
66
|
/**
|
|
57
67
|
* All actions registered by other modules that {@link MultichainAccountService}
|
|
58
68
|
* calls.
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mCAAmC,EACnC,qCAAqC,EACrC,kCAAkC,EAClC,2CAA2C,EAC3C,8CAA8C,EAC/C,sCAAsC;AACvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,kCAAkC;AACrE,OAAO,KAAK,EACV,+BAA+B,EAC/B,iCAAiC,EACjC,kCAAkC,EACnC,qCAAqC;AACtC,OAAO,KAAK,EAAE,iBAAiB,IAAI,qCAAqC,EAAE,oCAAoC;AAE9G,OAAO,KAAK,EACV,wBAAwB,EACxB,WAAW,EACZ,uCAAmC;AAEpC,MAAM,MAAM,uDAAuD,GAAG;IACpE,IAAI,EAAE,GAAG,OAAO,WAAW,4BAA4B,CAAC;IACxD,OAAO,EAAE,wBAAwB,CAAC,2BAA2B,CAAC,CAAC;CAChE,CAAC;AAEF,MAAM,MAAM,wDAAwD,GAAG;IACrE,IAAI,EAAE,GAAG,OAAO,WAAW,6BAA6B,CAAC;IACzD,OAAO,EAAE,wBAAwB,CAAC,4BAA4B,CAAC,CAAC;CACjE,CAAC;AAEF,MAAM,MAAM,wDAAwD,GAAG;IACrE,IAAI,EAAE,GAAG,OAAO,WAAW,6BAA6B,CAAC;IACzD,OAAO,EAAE,wBAAwB,CAAC,4BAA4B,CAAC,CAAC;CACjE,CAAC;AAEF,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,GAAG,OAAO,WAAW,8BAA8B,CAAC;IAC1D,OAAO,EAAE,wBAAwB,CAAC,6BAA6B,CAAC,CAAC;CAClE,CAAC;AAEF,MAAM,MAAM,8DAA8D,GAAG;IAC3E,IAAI,EAAE,GAAG,OAAO,WAAW,mCAAmC,CAAC;IAC/D,OAAO,EAAE,wBAAwB,CAAC,kC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AAkC,GAClC,2CAA2C,GAC3C,qCAAqC,GACrC,kCAAkC,GAClC,+BAA+B,CAAC;AAEpC;;;GAGG;AACH,MAAM,MAAM,aAAa,GACrB,iCAAiC,GACjC,mCAAmC,GACnC,qCAAqC,CAAC;AAE1C;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG,mBAAmB,CACjE,0BAA0B,EAC1B,+BAA+B,GAAG,cAAc,EAChD,8BAA8B,GAAG,aAAa,EAC9C,cAAc,CAAC,MAAM,CAAC,EACtB,aAAa,CAAC,MAAM,CAAC,CACtB,CAAC"}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { Bip44Account, MultichainAccountGroup } from "@metamask/account-api";
|
|
1
2
|
import type { AccountsControllerAccountAddedEvent, AccountsControllerAccountRemovedEvent, AccountsControllerGetAccountAction, AccountsControllerGetAccountByAddressAction, AccountsControllerListMultichainAccountsAction } from "@metamask/accounts-controller";
|
|
2
3
|
import type { RestrictedMessenger } from "@metamask/base-controller";
|
|
4
|
+
import type { KeyringAccount } from "@metamask/keyring-api";
|
|
3
5
|
import type { KeyringControllerGetStateAction, KeyringControllerStateChangeEvent, KeyringControllerWithKeyringAction } from "@metamask/keyring-controller";
|
|
4
6
|
import type { HandleSnapRequest as SnapControllerHandleSnapRequestAction } from "@metamask/snaps-controllers";
|
|
5
7
|
import type { MultichainAccountService, serviceName } from "./MultichainAccountService.mjs";
|
|
@@ -48,11 +50,19 @@ export type MultichainAccountServiceGetIsAlignmentInProgressAction = {
|
|
|
48
50
|
* modules can call them.
|
|
49
51
|
*/
|
|
50
52
|
export type MultichainAccountServiceActions = MultichainAccountServiceGetMultichainAccountGroupAction | MultichainAccountServiceGetMultichainAccountGroupsAction | MultichainAccountServiceGetMultichainAccountWalletAction | MultichainAccountServiceGetMultichainAccountWalletsAction | MultichainAccountServiceCreateNextMultichainAccountGroupAction | MultichainAccountServiceCreateMultichainAccountGroupAction | MultichainAccountServiceSetBasicFunctionalityAction | MultichainAccountServiceAlignWalletAction | MultichainAccountServiceAlignWalletsAction | MultichainAccountServiceGetIsAlignmentInProgressAction;
|
|
53
|
+
export type MultichainAccountServiceMultichainAccountGroupCreatedEvent = {
|
|
54
|
+
type: `${typeof serviceName}:multichainAccountGroupCreated`;
|
|
55
|
+
payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];
|
|
56
|
+
};
|
|
57
|
+
export type MultichainAccountServiceMultichainAccountGroupUpdatedEvent = {
|
|
58
|
+
type: `${typeof serviceName}:multichainAccountGroupUpdated`;
|
|
59
|
+
payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];
|
|
60
|
+
};
|
|
51
61
|
/**
|
|
52
62
|
* All events that {@link MultichainAccountService} publishes so that other modules
|
|
53
63
|
* can subscribe to them.
|
|
54
64
|
*/
|
|
55
|
-
export type MultichainAccountServiceEvents =
|
|
65
|
+
export type MultichainAccountServiceEvents = MultichainAccountServiceMultichainAccountGroupCreatedEvent | MultichainAccountServiceMultichainAccountGroupUpdatedEvent;
|
|
56
66
|
/**
|
|
57
67
|
* All actions registered by other modules that {@link MultichainAccountService}
|
|
58
68
|
* calls.
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mCAAmC,EACnC,qCAAqC,EACrC,kCAAkC,EAClC,2CAA2C,EAC3C,8CAA8C,EAC/C,sCAAsC;AACvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,kCAAkC;AACrE,OAAO,KAAK,EACV,+BAA+B,EAC/B,iCAAiC,EACjC,kCAAkC,EACnC,qCAAqC;AACtC,OAAO,KAAK,EAAE,iBAAiB,IAAI,qCAAqC,EAAE,oCAAoC;AAE9G,OAAO,KAAK,EACV,wBAAwB,EACxB,WAAW,EACZ,uCAAmC;AAEpC,MAAM,MAAM,uDAAuD,GAAG;IACpE,IAAI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H,MAAM,MAAM,+BAA+B,GACvC,uDAAuD,GACvD,wDAAwD,GACxD,wDAAwD,GACxD,yDAAyD,GACzD,8DAA8D,GAC9D,0DAA0D,GAC1D,mDAAmD,GACnD,yCAAyC,GACzC,0CAA0C,GAC1C,sDAAsD,CAAC;AAE3D,MAAM,MAAM,0DAA0D,GAAG;IACvE,IAAI,EAAE,GAAG,OAAO,WAAW,gCAAgC,CAAC;IAC5D,OAAO,EAAE,CAAC,sBAAsB,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;CACjE,CAAC;AAEF,MAAM,MAAM,0DAA0D,GAAG;IACvE,IAAI,EAAE,GAAG,OAAO,WAAW,gCAAgC,CAAC;IAC5D,OAAO,EAAE,CAAC,sBAAsB,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;CACjE,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,8BAA8B,GACtC,0DAA0D,GAC1D,0DAA0D,CAAC;AAE/D;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB,8CAA8C,GAC9C,kCAAkC,GAClC,2CAA2C,GAC3C,qCAAqC,GACrC,kCAAkC,GAClC,+BAA+B,CAAC;AAEpC;;;GAGG;AACH,MAAM,MAAM,aAAa,GACrB,iCAAiC,GACjC,mCAAmC,GACnC,qCAAqC,CAAC;AAE1C;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG,mBAAmB,CACjE,0BAA0B,EAC1B,+BAA+B,GAAG,cAAc,EAChD,8BAA8B,GAAG,aAAa,EAC9C,cAAc,CAAC,MAAM,CAAC,EACtB,aAAa,CAAC,MAAM,CAAC,CACtB,CAAC"}
|
package/dist/types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n AccountsControllerAccountAddedEvent,\n AccountsControllerAccountRemovedEvent,\n AccountsControllerGetAccountAction,\n AccountsControllerGetAccountByAddressAction,\n AccountsControllerListMultichainAccountsAction,\n} from '@metamask/accounts-controller';\nimport type { RestrictedMessenger } from '@metamask/base-controller';\nimport type {\n KeyringControllerGetStateAction,\n KeyringControllerStateChangeEvent,\n KeyringControllerWithKeyringAction,\n} from '@metamask/keyring-controller';\nimport type { HandleSnapRequest as SnapControllerHandleSnapRequestAction } from '@metamask/snaps-controllers';\n\nimport type {\n MultichainAccountService,\n serviceName,\n} from './MultichainAccountService';\n\nexport type MultichainAccountServiceGetMultichainAccountGroupAction = {\n type: `${typeof serviceName}:getMultichainAccountGroup`;\n handler: MultichainAccountService['getMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountGroupsAction = {\n type: `${typeof serviceName}:getMultichainAccountGroups`;\n handler: MultichainAccountService['getMultichainAccountGroups'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountWalletAction = {\n type: `${typeof serviceName}:getMultichainAccountWallet`;\n handler: MultichainAccountService['getMultichainAccountWallet'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountWalletsAction = {\n type: `${typeof serviceName}:getMultichainAccountWallets`;\n handler: MultichainAccountService['getMultichainAccountWallets'];\n};\n\nexport type MultichainAccountServiceCreateNextMultichainAccountGroupAction = {\n type: `${typeof serviceName}:createNextMultichainAccountGroup`;\n handler: MultichainAccountService['createNextMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceCreateMultichainAccountGroupAction = {\n type: `${typeof serviceName}:createMultichainAccountGroup`;\n handler: MultichainAccountService['createMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceSetBasicFunctionalityAction = {\n type: `${typeof serviceName}:setBasicFunctionality`;\n handler: MultichainAccountService['setBasicFunctionality'];\n};\n\nexport type MultichainAccountServiceAlignWalletAction = {\n type: `${typeof serviceName}:alignWallet`;\n handler: MultichainAccountService['alignWallet'];\n};\n\nexport type MultichainAccountServiceAlignWalletsAction = {\n type: `${typeof serviceName}:alignWallets`;\n handler: MultichainAccountService['alignWallets'];\n};\n\nexport type MultichainAccountServiceGetIsAlignmentInProgressAction = {\n type: `${typeof serviceName}:getIsAlignmentInProgress`;\n handler: MultichainAccountService['getIsAlignmentInProgress'];\n};\n\n/**\n * All actions that {@link MultichainAccountService} registers so that other\n * modules can call them.\n */\nexport type MultichainAccountServiceActions =\n | MultichainAccountServiceGetMultichainAccountGroupAction\n | MultichainAccountServiceGetMultichainAccountGroupsAction\n | MultichainAccountServiceGetMultichainAccountWalletAction\n | MultichainAccountServiceGetMultichainAccountWalletsAction\n | MultichainAccountServiceCreateNextMultichainAccountGroupAction\n | MultichainAccountServiceCreateMultichainAccountGroupAction\n | MultichainAccountServiceSetBasicFunctionalityAction\n | MultichainAccountServiceAlignWalletAction\n | MultichainAccountServiceAlignWalletsAction\n | MultichainAccountServiceGetIsAlignmentInProgressAction;\n\n/**\n * All events that {@link MultichainAccountService} publishes so that other modules\n * can subscribe to them.\n */\nexport type MultichainAccountServiceEvents
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n Bip44Account,\n MultichainAccountGroup,\n} from '@metamask/account-api';\nimport type {\n AccountsControllerAccountAddedEvent,\n AccountsControllerAccountRemovedEvent,\n AccountsControllerGetAccountAction,\n AccountsControllerGetAccountByAddressAction,\n AccountsControllerListMultichainAccountsAction,\n} from '@metamask/accounts-controller';\nimport type { RestrictedMessenger } from '@metamask/base-controller';\nimport type { KeyringAccount } from '@metamask/keyring-api';\nimport type {\n KeyringControllerGetStateAction,\n KeyringControllerStateChangeEvent,\n KeyringControllerWithKeyringAction,\n} from '@metamask/keyring-controller';\nimport type { HandleSnapRequest as SnapControllerHandleSnapRequestAction } from '@metamask/snaps-controllers';\n\nimport type {\n MultichainAccountService,\n serviceName,\n} from './MultichainAccountService';\n\nexport type MultichainAccountServiceGetMultichainAccountGroupAction = {\n type: `${typeof serviceName}:getMultichainAccountGroup`;\n handler: MultichainAccountService['getMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountGroupsAction = {\n type: `${typeof serviceName}:getMultichainAccountGroups`;\n handler: MultichainAccountService['getMultichainAccountGroups'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountWalletAction = {\n type: `${typeof serviceName}:getMultichainAccountWallet`;\n handler: MultichainAccountService['getMultichainAccountWallet'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountWalletsAction = {\n type: `${typeof serviceName}:getMultichainAccountWallets`;\n handler: MultichainAccountService['getMultichainAccountWallets'];\n};\n\nexport type MultichainAccountServiceCreateNextMultichainAccountGroupAction = {\n type: `${typeof serviceName}:createNextMultichainAccountGroup`;\n handler: MultichainAccountService['createNextMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceCreateMultichainAccountGroupAction = {\n type: `${typeof serviceName}:createMultichainAccountGroup`;\n handler: MultichainAccountService['createMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceSetBasicFunctionalityAction = {\n type: `${typeof serviceName}:setBasicFunctionality`;\n handler: MultichainAccountService['setBasicFunctionality'];\n};\n\nexport type MultichainAccountServiceAlignWalletAction = {\n type: `${typeof serviceName}:alignWallet`;\n handler: MultichainAccountService['alignWallet'];\n};\n\nexport type MultichainAccountServiceAlignWalletsAction = {\n type: `${typeof serviceName}:alignWallets`;\n handler: MultichainAccountService['alignWallets'];\n};\n\nexport type MultichainAccountServiceGetIsAlignmentInProgressAction = {\n type: `${typeof serviceName}:getIsAlignmentInProgress`;\n handler: MultichainAccountService['getIsAlignmentInProgress'];\n};\n\n/**\n * All actions that {@link MultichainAccountService} registers so that other\n * modules can call them.\n */\nexport type MultichainAccountServiceActions =\n | MultichainAccountServiceGetMultichainAccountGroupAction\n | MultichainAccountServiceGetMultichainAccountGroupsAction\n | MultichainAccountServiceGetMultichainAccountWalletAction\n | MultichainAccountServiceGetMultichainAccountWalletsAction\n | MultichainAccountServiceCreateNextMultichainAccountGroupAction\n | MultichainAccountServiceCreateMultichainAccountGroupAction\n | MultichainAccountServiceSetBasicFunctionalityAction\n | MultichainAccountServiceAlignWalletAction\n | MultichainAccountServiceAlignWalletsAction\n | MultichainAccountServiceGetIsAlignmentInProgressAction;\n\nexport type MultichainAccountServiceMultichainAccountGroupCreatedEvent = {\n type: `${typeof serviceName}:multichainAccountGroupCreated`;\n payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];\n};\n\nexport type MultichainAccountServiceMultichainAccountGroupUpdatedEvent = {\n type: `${typeof serviceName}:multichainAccountGroupUpdated`;\n payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];\n};\n\n/**\n * All events that {@link MultichainAccountService} publishes so that other modules\n * can subscribe to them.\n */\nexport type MultichainAccountServiceEvents =\n | MultichainAccountServiceMultichainAccountGroupCreatedEvent\n | MultichainAccountServiceMultichainAccountGroupUpdatedEvent;\n\n/**\n * All actions registered by other modules that {@link MultichainAccountService}\n * calls.\n */\nexport type AllowedActions =\n | AccountsControllerListMultichainAccountsAction\n | AccountsControllerGetAccountAction\n | AccountsControllerGetAccountByAddressAction\n | SnapControllerHandleSnapRequestAction\n | KeyringControllerWithKeyringAction\n | KeyringControllerGetStateAction;\n\n/**\n * All events published by other modules that {@link MultichainAccountService}\n * subscribes to.\n */\nexport type AllowedEvents =\n | KeyringControllerStateChangeEvent\n | AccountsControllerAccountAddedEvent\n | AccountsControllerAccountRemovedEvent;\n\n/**\n * The messenger restricted to actions and events that\n * {@link MultichainAccountService} needs to access.\n */\nexport type MultichainAccountServiceMessenger = RestrictedMessenger<\n 'MultichainAccountService',\n MultichainAccountServiceActions | AllowedActions,\n MultichainAccountServiceEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n"]}
|