@metamask-previews/account-tree-controller 1.5.0-preview-35a5c8a7 → 1.5.0-preview-a649a76b
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 -2
- package/dist/AccountTreeController.cjs +72 -40
- package/dist/AccountTreeController.cjs.map +1 -1
- package/dist/AccountTreeController.d.cts +1 -1
- package/dist/AccountTreeController.d.cts.map +1 -1
- package/dist/AccountTreeController.d.mts +1 -1
- package/dist/AccountTreeController.d.mts.map +1 -1
- package/dist/AccountTreeController.mjs +71 -39
- package/dist/AccountTreeController.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +7 -4
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +7 -4
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,12 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Add optional account hidden/pinned state callbacks ([#6910](https://github.com/MetaMask/core/pull/6910))
|
|
13
|
+
- Those callbacks can be used migrate existing account state into the tree metadata.
|
|
14
|
+
- Bump `@metamask/base-controller` from `^8.4.1` to `^8.4.2` ([#6917](https://github.com/MetaMask/core/pull/6917))
|
|
15
|
+
|
|
10
16
|
## [1.5.0]
|
|
11
17
|
|
|
12
18
|
### Changed
|
|
13
19
|
|
|
14
|
-
- **BREAKING:** Use new `Messenger` from `@metamask/messenger` ([#6380](https://github.com/MetaMask/core/pull/6380))
|
|
15
|
-
- Previously, `AccountTreeController` accepted a `RestrictedMessenger` instance from `@metamask/base-controller`.
|
|
16
20
|
- Use non-EVM account names for group names ([#6831](https://github.com/MetaMask/core/pull/6831))
|
|
17
21
|
- EVM accounts still take precedence over non-EVM accounts.
|
|
18
22
|
- Before accounts get re-aligned, it is possible that a group contains only non-EVM accounts, in which case, the first non-EVM account name will be used for that account group.
|
|
@@ -10,11 +10,11 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
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");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _AccountTreeController_instances, _AccountTreeController_accountIdToContext, _AccountTreeController_groupIdToWalletId, _AccountTreeController_backupAndSyncService, _AccountTreeController_rules, _AccountTreeController_trace, _AccountTreeController_backupAndSyncConfig, _AccountTreeController_initialized, _AccountTreeController_getEntropyRule, _AccountTreeController_getSnapRule, _AccountTreeController_getKeyringRule, _AccountTreeController_applyAccountWalletMetadata, _AccountTreeController_getRuleForWallet, _AccountTreeController_getComputedAccountGroupName, _AccountTreeController_getDefaultAccountGroupName, _AccountTreeController_applyAccountGroupMetadata, _AccountTreeController_handleAccountAdded, _AccountTreeController_handleAccountRemoved, _AccountTreeController_pruneEmptyGroupAndWallet, _AccountTreeController_insert, _AccountTreeController_listAccounts, _AccountTreeController_assertAccountGroupExists, _AccountTreeController_assertAccountWalletExists, _AccountTreeController_assertAccountGroupNameIsUnique, _AccountTreeController_getDefaultSelectedAccountGroup, _AccountTreeController_handleSelectedAccountChange, _AccountTreeController_handleMultichainAccountWalletStatusChange, _AccountTreeController_getAccountGroup, _AccountTreeController_getDefaultAccountFromAccountGroupId, _AccountTreeController_getDefaultAccountGroupId, _AccountTreeController_registerMessageHandlers, _AccountTreeController_createBackupAndSyncContext;
|
|
13
|
+
var _AccountTreeController_instances, _AccountTreeController_accountIdToContext, _AccountTreeController_groupIdToWalletId, _AccountTreeController_backupAndSyncService, _AccountTreeController_rules, _AccountTreeController_trace, _AccountTreeController_backupAndSyncConfig, _AccountTreeController_accountOrderCallbacks, _AccountTreeController_initialized, _AccountTreeController_getEntropyRule, _AccountTreeController_getSnapRule, _AccountTreeController_getKeyringRule, _AccountTreeController_applyAccountWalletMetadata, _AccountTreeController_getRuleForWallet, _AccountTreeController_getComputedAccountGroupName, _AccountTreeController_getDefaultAccountGroupName, _AccountTreeController_applyAccountGroupMetadata, _AccountTreeController_handleAccountAdded, _AccountTreeController_handleAccountRemoved, _AccountTreeController_pruneEmptyGroupAndWallet, _AccountTreeController_insert, _AccountTreeController_listAccounts, _AccountTreeController_assertAccountGroupExists, _AccountTreeController_assertAccountWalletExists, _AccountTreeController_assertAccountGroupNameIsUnique, _AccountTreeController_getDefaultSelectedAccountGroup, _AccountTreeController_handleSelectedAccountChange, _AccountTreeController_handleMultichainAccountWalletStatusChange, _AccountTreeController_getAccountGroup, _AccountTreeController_getDefaultAccountFromAccountGroupId, _AccountTreeController_getDefaultAccountGroupId, _AccountTreeController_registerMessageHandlers, _AccountTreeController_createBackupAndSyncContext;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.AccountTreeController = exports.getDefaultAccountTreeControllerState = exports.controllerName = void 0;
|
|
16
16
|
const account_api_1 = require("@metamask/account-api");
|
|
17
|
-
const
|
|
17
|
+
const base_controller_1 = require("@metamask/base-controller");
|
|
18
18
|
const keyring_api_1 = require("@metamask/keyring-api");
|
|
19
19
|
const utils_1 = require("@metamask/utils");
|
|
20
20
|
const analytics_1 = require("./backup-and-sync/analytics/index.cjs");
|
|
@@ -29,31 +29,31 @@ const accountTreeControllerMetadata = {
|
|
|
29
29
|
accountTree: {
|
|
30
30
|
includeInStateLogs: true,
|
|
31
31
|
persist: false,
|
|
32
|
-
|
|
32
|
+
anonymous: false,
|
|
33
33
|
usedInUi: true,
|
|
34
34
|
},
|
|
35
35
|
isAccountTreeSyncingInProgress: {
|
|
36
36
|
includeInStateLogs: false,
|
|
37
37
|
persist: false,
|
|
38
|
-
|
|
38
|
+
anonymous: false,
|
|
39
39
|
usedInUi: true,
|
|
40
40
|
},
|
|
41
41
|
hasAccountTreeSyncingSyncedAtLeastOnce: {
|
|
42
42
|
includeInStateLogs: true,
|
|
43
43
|
persist: true,
|
|
44
|
-
|
|
44
|
+
anonymous: false,
|
|
45
45
|
usedInUi: true,
|
|
46
46
|
},
|
|
47
47
|
accountGroupsMetadata: {
|
|
48
48
|
includeInStateLogs: true,
|
|
49
49
|
persist: true,
|
|
50
|
-
|
|
50
|
+
anonymous: false,
|
|
51
51
|
usedInUi: true,
|
|
52
52
|
},
|
|
53
53
|
accountWalletsMetadata: {
|
|
54
54
|
includeInStateLogs: true,
|
|
55
55
|
persist: true,
|
|
56
|
-
|
|
56
|
+
anonymous: false,
|
|
57
57
|
usedInUi: true,
|
|
58
58
|
},
|
|
59
59
|
};
|
|
@@ -75,7 +75,7 @@ function getDefaultAccountTreeControllerState() {
|
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
exports.getDefaultAccountTreeControllerState = getDefaultAccountTreeControllerState;
|
|
78
|
-
class AccountTreeController extends
|
|
78
|
+
class AccountTreeController extends base_controller_1.BaseController {
|
|
79
79
|
/**
|
|
80
80
|
* Constructor for AccountTreeController.
|
|
81
81
|
*
|
|
@@ -104,6 +104,10 @@ class AccountTreeController extends next_1.BaseController {
|
|
|
104
104
|
_AccountTreeController_rules.set(this, void 0);
|
|
105
105
|
_AccountTreeController_trace.set(this, void 0);
|
|
106
106
|
_AccountTreeController_backupAndSyncConfig.set(this, void 0);
|
|
107
|
+
/**
|
|
108
|
+
* Callbacks to migrate hidden and pinned account information from the account order controller
|
|
109
|
+
*/
|
|
110
|
+
_AccountTreeController_accountOrderCallbacks.set(this, void 0);
|
|
107
111
|
_AccountTreeController_initialized.set(this, void 0);
|
|
108
112
|
// This will be set to true upon the first `init` call.
|
|
109
113
|
__classPrivateFieldSet(this, _AccountTreeController_initialized, false, "f");
|
|
@@ -114,11 +118,11 @@ class AccountTreeController extends next_1.BaseController {
|
|
|
114
118
|
// Rules to apply to construct the wallets tree.
|
|
115
119
|
__classPrivateFieldSet(this, _AccountTreeController_rules, [
|
|
116
120
|
// 1. We group by entropy-source
|
|
117
|
-
new entropy_1.EntropyRule(this.
|
|
121
|
+
new entropy_1.EntropyRule(this.messagingSystem),
|
|
118
122
|
// 2. We group by Snap ID
|
|
119
|
-
new snap_1.SnapRule(this.
|
|
123
|
+
new snap_1.SnapRule(this.messagingSystem),
|
|
120
124
|
// 3. We group by wallet type (this rule cannot fail and will group all non-matching accounts)
|
|
121
|
-
new keyring_1.KeyringRule(this.
|
|
125
|
+
new keyring_1.KeyringRule(this.messagingSystem),
|
|
122
126
|
], "f");
|
|
123
127
|
// Initialize trace function
|
|
124
128
|
__classPrivateFieldSet(this, _AccountTreeController_trace, config?.trace ?? analytics_1.traceFallback, "f");
|
|
@@ -129,21 +133,23 @@ class AccountTreeController extends next_1.BaseController {
|
|
|
129
133
|
config.backupAndSync.onBackupAndSyncEvent((0, analytics_1.formatAnalyticsEvent)(event)));
|
|
130
134
|
},
|
|
131
135
|
}, "f");
|
|
136
|
+
// Used when migrating initial hidden/pinned state for groups (if available).
|
|
137
|
+
__classPrivateFieldSet(this, _AccountTreeController_accountOrderCallbacks, config?.accountOrderCallbacks, "f");
|
|
132
138
|
// Initialize the backup and sync service
|
|
133
139
|
__classPrivateFieldSet(this, _AccountTreeController_backupAndSyncService, new service_1.BackupAndSyncService(__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_createBackupAndSyncContext).call(this)), "f");
|
|
134
|
-
this.
|
|
140
|
+
this.messagingSystem.subscribe('AccountsController:accountAdded', (account) => {
|
|
135
141
|
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_handleAccountAdded).call(this, account);
|
|
136
142
|
});
|
|
137
|
-
this.
|
|
143
|
+
this.messagingSystem.subscribe('AccountsController:accountRemoved', (accountId) => {
|
|
138
144
|
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_handleAccountRemoved).call(this, accountId);
|
|
139
145
|
});
|
|
140
|
-
this.
|
|
146
|
+
this.messagingSystem.subscribe('AccountsController:selectedAccountChange', (account) => {
|
|
141
147
|
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_handleSelectedAccountChange).call(this, account);
|
|
142
148
|
});
|
|
143
|
-
this.
|
|
149
|
+
this.messagingSystem.subscribe('UserStorageController:stateChange', (userStorageControllerState) => {
|
|
144
150
|
__classPrivateFieldGet(this, _AccountTreeController_backupAndSyncService, "f").handleUserStorageStateChange(userStorageControllerState);
|
|
145
151
|
});
|
|
146
|
-
this.
|
|
152
|
+
this.messagingSystem.subscribe('MultichainAccountService:walletStatusChange', (walletId, status) => {
|
|
147
153
|
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_handleMultichainAccountWalletStatusChange).call(this, walletId, status);
|
|
148
154
|
});
|
|
149
155
|
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_registerMessageHandlers).call(this);
|
|
@@ -232,7 +238,7 @@ class AccountTreeController extends next_1.BaseController {
|
|
|
232
238
|
if (previousSelectedAccountGroup !==
|
|
233
239
|
this.state.accountTree.selectedAccountGroup) {
|
|
234
240
|
(0, logger_1.projectLogger)(`Selected (initial) group is: [${this.state.accountTree.selectedAccountGroup}]`);
|
|
235
|
-
this.
|
|
241
|
+
this.messagingSystem.publish(`${exports.controllerName}:selectedAccountGroupChange`, this.state.accountTree.selectedAccountGroup, previousSelectedAccountGroup);
|
|
236
242
|
}
|
|
237
243
|
(0, logger_1.projectLogger)('Initialized!');
|
|
238
244
|
__classPrivateFieldSet(this, _AccountTreeController_initialized, true, "f");
|
|
@@ -293,7 +299,7 @@ class AccountTreeController extends next_1.BaseController {
|
|
|
293
299
|
}
|
|
294
300
|
const accounts = [];
|
|
295
301
|
for (const id of group.accounts) {
|
|
296
|
-
const account = this.
|
|
302
|
+
const account = this.messagingSystem.call('AccountsController:getAccount', id);
|
|
297
303
|
// For now, we're filtering undefined account, but I believe
|
|
298
304
|
// throwing would be more appropriate here.
|
|
299
305
|
if (account) {
|
|
@@ -345,10 +351,10 @@ class AccountTreeController extends next_1.BaseController {
|
|
|
345
351
|
state.accountTree.selectedAccountGroup = groupId;
|
|
346
352
|
});
|
|
347
353
|
(0, logger_1.projectLogger)(`Selected group is now: [${this.state.accountTree.selectedAccountGroup}]`);
|
|
348
|
-
this.
|
|
354
|
+
this.messagingSystem.publish(`${exports.controllerName}:selectedAccountGroupChange`, groupId, previousSelectedAccountGroup);
|
|
349
355
|
// Update AccountsController - this will trigger selectedAccountChange event,
|
|
350
356
|
// but our handler is idempotent so it won't cause infinite loop
|
|
351
|
-
this.
|
|
357
|
+
this.messagingSystem.call('AccountsController:setSelectedAccount', accountToSelect);
|
|
352
358
|
}
|
|
353
359
|
/**
|
|
354
360
|
* Resolves name conflicts by adding a suffix to make the name unique.
|
|
@@ -555,7 +561,7 @@ class AccountTreeController extends next_1.BaseController {
|
|
|
555
561
|
}
|
|
556
562
|
}
|
|
557
563
|
exports.AccountTreeController = AccountTreeController;
|
|
558
|
-
_AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeController_groupIdToWalletId = new WeakMap(), _AccountTreeController_backupAndSyncService = new WeakMap(), _AccountTreeController_rules = new WeakMap(), _AccountTreeController_trace = new WeakMap(), _AccountTreeController_backupAndSyncConfig = new WeakMap(), _AccountTreeController_initialized = new WeakMap(), _AccountTreeController_instances = new WeakSet(), _AccountTreeController_getEntropyRule = function _AccountTreeController_getEntropyRule() {
|
|
564
|
+
_AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeController_groupIdToWalletId = new WeakMap(), _AccountTreeController_backupAndSyncService = new WeakMap(), _AccountTreeController_rules = new WeakMap(), _AccountTreeController_trace = new WeakMap(), _AccountTreeController_backupAndSyncConfig = new WeakMap(), _AccountTreeController_accountOrderCallbacks = new WeakMap(), _AccountTreeController_initialized = new WeakMap(), _AccountTreeController_instances = new WeakSet(), _AccountTreeController_getEntropyRule = function _AccountTreeController_getEntropyRule() {
|
|
559
565
|
return __classPrivateFieldGet(this, _AccountTreeController_rules, "f")[0];
|
|
560
566
|
}, _AccountTreeController_getSnapRule = function _AccountTreeController_getSnapRule() {
|
|
561
567
|
return __classPrivateFieldGet(this, _AccountTreeController_rules, "f")[1];
|
|
@@ -596,7 +602,7 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
596
602
|
}, _AccountTreeController_getComputedAccountGroupName = function _AccountTreeController_getComputedAccountGroupName(wallet, group) {
|
|
597
603
|
let proposedName = ''; // Empty means there's no computed name for this group.
|
|
598
604
|
for (const id of group.accounts) {
|
|
599
|
-
const account = this.
|
|
605
|
+
const account = this.messagingSystem.call('AccountsController:getAccount', id);
|
|
600
606
|
if (!account || !account.metadata.name.length) {
|
|
601
607
|
continue;
|
|
602
608
|
}
|
|
@@ -674,10 +680,10 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
674
680
|
} while (proposedNameExists);
|
|
675
681
|
return proposedName;
|
|
676
682
|
}, _AccountTreeController_applyAccountGroupMetadata = function _AccountTreeController_applyAccountGroupMetadata(state, walletId, groupId, { allowComputedName, nextNaturalNameIndex, } = {}) {
|
|
677
|
-
var _a;
|
|
683
|
+
var _a, _b, _c;
|
|
678
684
|
const wallet = state.accountTree.wallets[walletId];
|
|
679
685
|
const group = wallet.groups[groupId];
|
|
680
|
-
const persistedGroupMetadata = state.accountGroupsMetadata[
|
|
686
|
+
const persistedGroupMetadata = state.accountGroupsMetadata[groupId];
|
|
681
687
|
// Apply persisted name if available (including empty strings)
|
|
682
688
|
if (persistedGroupMetadata?.name !== undefined) {
|
|
683
689
|
state.accountTree.wallets[walletId].groups[groupId].metadata.name =
|
|
@@ -711,9 +717,35 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
711
717
|
if (persistedGroupMetadata?.pinned?.value !== undefined) {
|
|
712
718
|
group.metadata.pinned = persistedGroupMetadata.pinned.value;
|
|
713
719
|
}
|
|
720
|
+
else {
|
|
721
|
+
let isPinned = false;
|
|
722
|
+
if (__classPrivateFieldGet(this, _AccountTreeController_accountOrderCallbacks, "f")?.isPinnedAccount) {
|
|
723
|
+
isPinned = group.accounts.some((account) => __classPrivateFieldGet(this, _AccountTreeController_accountOrderCallbacks, "f")?.isPinnedAccount?.(account));
|
|
724
|
+
}
|
|
725
|
+
(_b = state.accountGroupsMetadata)[groupId] ?? (_b[groupId] = {});
|
|
726
|
+
state.accountGroupsMetadata[groupId].pinned = {
|
|
727
|
+
value: isPinned,
|
|
728
|
+
lastUpdatedAt: 0,
|
|
729
|
+
};
|
|
730
|
+
// If any accounts was previously pinned, then we consider the group to be pinned as well.
|
|
731
|
+
group.metadata.pinned = isPinned;
|
|
732
|
+
}
|
|
714
733
|
if (persistedGroupMetadata?.hidden?.value !== undefined) {
|
|
715
734
|
group.metadata.hidden = persistedGroupMetadata.hidden.value;
|
|
716
735
|
}
|
|
736
|
+
else {
|
|
737
|
+
let isHidden = false;
|
|
738
|
+
if (__classPrivateFieldGet(this, _AccountTreeController_accountOrderCallbacks, "f")?.isHiddenAccount) {
|
|
739
|
+
isHidden = group.accounts.some((account) => __classPrivateFieldGet(this, _AccountTreeController_accountOrderCallbacks, "f")?.isHiddenAccount?.(account));
|
|
740
|
+
}
|
|
741
|
+
(_c = state.accountGroupsMetadata)[groupId] ?? (_c[groupId] = {});
|
|
742
|
+
state.accountGroupsMetadata[groupId].hidden = {
|
|
743
|
+
value: isHidden,
|
|
744
|
+
lastUpdatedAt: 0,
|
|
745
|
+
};
|
|
746
|
+
// If any accounts was previously hidden, then we consider the group to be hidden as well.
|
|
747
|
+
group.metadata.hidden = isHidden;
|
|
748
|
+
}
|
|
717
749
|
}, _AccountTreeController_handleAccountAdded = function _AccountTreeController_handleAccountAdded(account) {
|
|
718
750
|
// We wait for the first `init` to be called to actually build up the tree and
|
|
719
751
|
// mutate it. We expect the caller to first update the `AccountsController` state
|
|
@@ -735,7 +767,7 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
735
767
|
}
|
|
736
768
|
}
|
|
737
769
|
});
|
|
738
|
-
this.
|
|
770
|
+
this.messagingSystem.publish(`${exports.controllerName}:accountTreeChange`, this.state.accountTree);
|
|
739
771
|
}
|
|
740
772
|
}, _AccountTreeController_handleAccountRemoved = function _AccountTreeController_handleAccountRemoved(accountId) {
|
|
741
773
|
// We wait for the first `init` to be called to actually build up the tree and
|
|
@@ -770,10 +802,10 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
770
802
|
}
|
|
771
803
|
}
|
|
772
804
|
});
|
|
773
|
-
this.
|
|
805
|
+
this.messagingSystem.publish(`${exports.controllerName}:accountTreeChange`, this.state.accountTree);
|
|
774
806
|
// Emit selectedAccountGroupChange event if the selected group changed
|
|
775
807
|
if (selectedAccountGroupChanged) {
|
|
776
|
-
this.
|
|
808
|
+
this.messagingSystem.publish(`${exports.controllerName}:selectedAccountGroupChange`, this.state.accountTree.selectedAccountGroup, previousSelectedAccountGroup);
|
|
777
809
|
}
|
|
778
810
|
// Clear reverse-mapping for that account.
|
|
779
811
|
__classPrivateFieldGet(this, _AccountTreeController_accountIdToContext, "f").delete(accountId);
|
|
@@ -868,7 +900,7 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
868
900
|
sortOrder,
|
|
869
901
|
});
|
|
870
902
|
}, _AccountTreeController_listAccounts = function _AccountTreeController_listAccounts() {
|
|
871
|
-
return this.
|
|
903
|
+
return this.messagingSystem.call('AccountsController:listMultichainAccounts');
|
|
872
904
|
}, _AccountTreeController_assertAccountGroupExists = function _AccountTreeController_assertAccountGroupExists(groupId) {
|
|
873
905
|
const exists = __classPrivateFieldGet(this, _AccountTreeController_groupIdToWalletId, "f").has(groupId);
|
|
874
906
|
if (!exists) {
|
|
@@ -884,7 +916,7 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
884
916
|
throw new Error('Account group name already exists');
|
|
885
917
|
}
|
|
886
918
|
}, _AccountTreeController_getDefaultSelectedAccountGroup = function _AccountTreeController_getDefaultSelectedAccountGroup(wallets) {
|
|
887
|
-
const selectedAccount = this.
|
|
919
|
+
const selectedAccount = this.messagingSystem.call('AccountsController:getSelectedMultichainAccount');
|
|
888
920
|
if (selectedAccount && selectedAccount.id) {
|
|
889
921
|
const accountMapping = __classPrivateFieldGet(this, _AccountTreeController_accountIdToContext, "f").get(selectedAccount.id);
|
|
890
922
|
if (accountMapping) {
|
|
@@ -910,7 +942,7 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
910
942
|
this.update((state) => {
|
|
911
943
|
state.accountTree.selectedAccountGroup = groupId;
|
|
912
944
|
});
|
|
913
|
-
this.
|
|
945
|
+
this.messagingSystem.publish(`${exports.controllerName}:selectedAccountGroupChange`, groupId, previousSelectedAccountGroup);
|
|
914
946
|
}, _AccountTreeController_handleMultichainAccountWalletStatusChange = function _AccountTreeController_handleMultichainAccountWalletStatusChange(walletId, walletStatus) {
|
|
915
947
|
this.update((state) => {
|
|
916
948
|
const wallet = state.accountTree.wallets[walletId];
|
|
@@ -926,7 +958,7 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
926
958
|
if (group) {
|
|
927
959
|
let candidate;
|
|
928
960
|
for (const id of group.accounts) {
|
|
929
|
-
const account = this.
|
|
961
|
+
const account = this.messagingSystem.call('AccountsController:getAccount', id);
|
|
930
962
|
if (!candidate) {
|
|
931
963
|
candidate = id;
|
|
932
964
|
}
|
|
@@ -950,7 +982,7 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
950
982
|
candidate = group.id;
|
|
951
983
|
}
|
|
952
984
|
for (const id of group.accounts) {
|
|
953
|
-
const account = this.
|
|
985
|
+
const account = this.messagingSystem.call('AccountsController:getAccount', id);
|
|
954
986
|
if (account && (0, keyring_api_1.isEvmAccountType)(account.type)) {
|
|
955
987
|
// EVM accounts have a higher priority, so if we find any, we just
|
|
956
988
|
// use that group!
|
|
@@ -961,18 +993,18 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
961
993
|
}
|
|
962
994
|
return candidate;
|
|
963
995
|
}, _AccountTreeController_registerMessageHandlers = function _AccountTreeController_registerMessageHandlers() {
|
|
964
|
-
this.
|
|
965
|
-
this.
|
|
966
|
-
this.
|
|
967
|
-
this.
|
|
968
|
-
this.
|
|
969
|
-
this.
|
|
970
|
-
this.
|
|
996
|
+
this.messagingSystem.registerActionHandler(`${exports.controllerName}:getSelectedAccountGroup`, this.getSelectedAccountGroup.bind(this));
|
|
997
|
+
this.messagingSystem.registerActionHandler(`${exports.controllerName}:setSelectedAccountGroup`, this.setSelectedAccountGroup.bind(this));
|
|
998
|
+
this.messagingSystem.registerActionHandler(`${exports.controllerName}:getAccountsFromSelectedAccountGroup`, this.getAccountsFromSelectedAccountGroup.bind(this));
|
|
999
|
+
this.messagingSystem.registerActionHandler(`${exports.controllerName}:setAccountWalletName`, this.setAccountWalletName.bind(this));
|
|
1000
|
+
this.messagingSystem.registerActionHandler(`${exports.controllerName}:setAccountGroupName`, this.setAccountGroupName.bind(this));
|
|
1001
|
+
this.messagingSystem.registerActionHandler(`${exports.controllerName}:setAccountGroupPinned`, this.setAccountGroupPinned.bind(this));
|
|
1002
|
+
this.messagingSystem.registerActionHandler(`${exports.controllerName}:setAccountGroupHidden`, this.setAccountGroupHidden.bind(this));
|
|
971
1003
|
}, _AccountTreeController_createBackupAndSyncContext = function _AccountTreeController_createBackupAndSyncContext() {
|
|
972
1004
|
return {
|
|
973
1005
|
...__classPrivateFieldGet(this, _AccountTreeController_backupAndSyncConfig, "f"),
|
|
974
1006
|
controller: this,
|
|
975
|
-
messenger: this.
|
|
1007
|
+
messenger: this.messagingSystem,
|
|
976
1008
|
controllerStateUpdateFn: this.update.bind(this),
|
|
977
1009
|
traceFn: __classPrivateFieldGet(this, _AccountTreeController_trace, "f").bind(this),
|
|
978
1010
|
groupIdToWalletId: __classPrivateFieldGet(this, _AccountTreeController_groupIdToWalletId, "f"),
|