@metamask-previews/account-tree-controller 1.5.0-preview-3fb593f6 → 1.5.0-preview-53e28985

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 CHANGED
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Changed
11
+
12
+ - Bump `@metamask/base-controller` from `^8.4.1` to `^8.4.2` ([#6917](https://github.com/MetaMask/core/pull/6917))
13
+
10
14
  ## [1.5.0]
11
15
 
12
16
  ### Changed
@@ -10,10 +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_initialized, _AccountTreeController_getEntropyRule, _AccountTreeController_getSnapRule, _AccountTreeController_getKeyringRule, _AccountTreeController_applyAccountWalletMetadata, _AccountTreeController_getRuleForWallet, _AccountTreeController_getComputedAccountGroupName, _AccountTreeController_getDefaultAccountGroupName, _AccountTreeController_applyAccountGroupMetadata, _AccountTreeController_handleAccountAdded, _AccountTreeController_handleAccountRemoved, _AccountTreeController_pruneEmptyGroupAndWallet, _AccountTreeController_sortAccountsOfGroup, _AccountTreeController_insertAccount, _AccountTreeController_insertOrUpdateMultichainAccountWalletAndGroup, _AccountTreeController_getMultichainAccountWallets, _AccountTreeController_listAccounts, _AccountTreeController_assertAccountGroupExists, _AccountTreeController_assertAccountWalletExists, _AccountTreeController_assertAccountGroupNameIsUnique, _AccountTreeController_getDefaultSelectedAccountGroup, _AccountTreeController_handleSelectedAccountChange, _AccountTreeController_handleMultichainAccountGroupCreatedOrUpdated, _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 account_api_2 = require("@metamask/account-api");
17
18
  const base_controller_1 = require("@metamask/base-controller");
18
19
  const keyring_api_1 = require("@metamask/keyring-api");
19
20
  const utils_1 = require("@metamask/utils");
@@ -143,6 +144,12 @@ class AccountTreeController extends base_controller_1.BaseController {
143
144
  this.messagingSystem.subscribe('UserStorageController:stateChange', (userStorageControllerState) => {
144
145
  __classPrivateFieldGet(this, _AccountTreeController_backupAndSyncService, "f").handleUserStorageStateChange(userStorageControllerState);
145
146
  });
147
+ this.messagingSystem.subscribe('MultichainAccountService:multichainAccountGroupCreated', (group) => {
148
+ __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_handleMultichainAccountGroupCreatedOrUpdated).call(this, group);
149
+ });
150
+ this.messagingSystem.subscribe('MultichainAccountService:multichainAccountGroupUpdated', (group) => {
151
+ __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_handleMultichainAccountGroupCreatedOrUpdated).call(this, group);
152
+ });
146
153
  this.messagingSystem.subscribe('MultichainAccountService:walletStatusChange', (walletId, status) => {
147
154
  __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_handleMultichainAccountWalletStatusChange).call(this, walletId, status);
148
155
  });
@@ -162,6 +169,7 @@ class AccountTreeController extends base_controller_1.BaseController {
162
169
  return;
163
170
  }
164
171
  (0, logger_1.projectLogger)('Initializing...');
172
+ // For now, we always re-compute all wallets, we do not re-use the existing state.
165
173
  const wallets = {};
166
174
  // Clear mappings for fresh rebuild.
167
175
  __classPrivateFieldGet(this, _AccountTreeController_accountIdToContext, "f").clear();
@@ -169,6 +177,12 @@ class AccountTreeController extends base_controller_1.BaseController {
169
177
  // Keep the current selected group to check if it's still part of the tree
170
178
  // after rebuilding it.
171
179
  const previousSelectedAccountGroup = this.state.accountTree.selectedAccountGroup;
180
+ // Insert all multichain account wallet/groups.
181
+ for (const wallet of __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_getMultichainAccountWallets).call(this)) {
182
+ for (const group of wallet.getMultichainAccountGroups()) {
183
+ __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_insertOrUpdateMultichainAccountWalletAndGroup).call(this, wallets, wallet, group);
184
+ }
185
+ }
172
186
  // There's no guarantee that accounts would be sorted by their import time
173
187
  // with `listMultichainAccounts`. We have to sort them here before constructing
174
188
  // the tree.
@@ -181,9 +195,9 @@ class AccountTreeController extends base_controller_1.BaseController {
181
195
  // won't be enough and we would have to use group properties instead (like group
182
196
  // index or maybe introduce a `importTime` at group level).
183
197
  const accounts = __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_listAccounts).call(this).sort((a, b) => a.metadata.importTime - b.metadata.importTime);
184
- // For now, we always re-compute all wallets, we do not re-use the existing state.
198
+ // Insert all other kind of accounts (private keys, HW, other Snap accounts, etc.).
185
199
  for (const account of accounts) {
186
- __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_insert).call(this, wallets, account);
200
+ __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_insertAccount).call(this, wallets, account);
187
201
  }
188
202
  // Once we have the account tree, we can apply persisted metadata (names + UI states).
189
203
  let previousSelectedAccountGroupStillExists = false;
@@ -721,10 +735,15 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
721
735
  if (!__classPrivateFieldGet(this, _AccountTreeController_initialized, "f")) {
722
736
  return;
723
737
  }
738
+ if ((0, account_api_1.isBip44Account)(account)) {
739
+ // We're skipping BIP-44 accounts since we rely on the `MultichainAccountService` to do
740
+ // the grouping of wallets/groups directly.
741
+ return;
742
+ }
724
743
  // Check if this account is already known by the tree to avoid double-insertion.
725
744
  if (!__classPrivateFieldGet(this, _AccountTreeController_accountIdToContext, "f").has(account.id)) {
726
745
  this.update((state) => {
727
- __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_insert).call(this, state.accountTree.wallets, account);
746
+ __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_insertAccount).call(this, state.accountTree.wallets, account);
728
747
  const context = __classPrivateFieldGet(this, _AccountTreeController_accountIdToContext, "f").get(account.id);
729
748
  if (context) {
730
749
  const { walletId, groupId } = context;
@@ -747,33 +766,39 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
747
766
  const context = __classPrivateFieldGet(this, _AccountTreeController_accountIdToContext, "f").get(accountId);
748
767
  if (context) {
749
768
  const { walletId, groupId } = context;
750
- const previousSelectedAccountGroup = this.state.accountTree.selectedAccountGroup;
751
- let selectedAccountGroupChanged = false;
752
- this.update((state) => {
753
- const accounts = state.accountTree.wallets[walletId]?.groups[groupId]?.accounts;
754
- if (accounts) {
755
- const index = accounts.indexOf(accountId);
756
- if (index !== -1) {
769
+ // If it's in the context, then `group` should be defined.
770
+ const group = this.state.accountTree.wallets[walletId]?.groups[groupId];
771
+ // We're only considering non-BIP-44 accounts for single account events.
772
+ if (group.type !== account_api_2.AccountGroupType.MultichainAccount) {
773
+ const index = group.accounts.indexOf(accountId);
774
+ if (index !== -1) {
775
+ let selectedAccountGroupChanged = false;
776
+ const previousSelectedAccountGroup = this.state.accountTree.selectedAccountGroup;
777
+ this.update((state) => {
778
+ const accounts = state.accountTree.wallets[walletId]?.groups[groupId].accounts;
779
+ // Effectively remove account from the group and state.
757
780
  accounts.splice(index, 1);
758
- // Check if we need to update selectedAccountGroup after removal
759
- if (state.accountTree.selectedAccountGroup === groupId &&
760
- accounts.length === 0) {
761
- // The currently selected group is now empty, find a new group to select
762
- const newSelectedAccountGroup = __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_getDefaultAccountGroupId).call(this, state.accountTree.wallets);
763
- state.accountTree.selectedAccountGroup = newSelectedAccountGroup;
764
- selectedAccountGroupChanged =
765
- newSelectedAccountGroup !== previousSelectedAccountGroup;
781
+ // If there's no more account, we have to prune the group and maybe select
782
+ // a new account group too.
783
+ if (accounts.length === 0) {
784
+ // Check if we need to update selectedAccountGroup after removal
785
+ if (state.accountTree.selectedAccountGroup === groupId) {
786
+ // The currently selected group is now empty, find a new group to select
787
+ const newSelectedAccountGroup = __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_getDefaultAccountGroupId).call(this, state.accountTree.wallets);
788
+ state.accountTree.selectedAccountGroup =
789
+ newSelectedAccountGroup;
790
+ selectedAccountGroupChanged =
791
+ newSelectedAccountGroup !== previousSelectedAccountGroup;
792
+ }
793
+ __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_pruneEmptyGroupAndWallet).call(this, state, walletId, groupId);
766
794
  }
767
- }
768
- if (accounts.length === 0) {
769
- __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_pruneEmptyGroupAndWallet).call(this, state, walletId, groupId);
795
+ });
796
+ this.messagingSystem.publish(`${exports.controllerName}:accountTreeChange`, this.state.accountTree);
797
+ // Emit selectedAccountGroupChange event if the selected group changed
798
+ if (selectedAccountGroupChanged) {
799
+ this.messagingSystem.publish(`${exports.controllerName}:selectedAccountGroupChange`, this.state.accountTree.selectedAccountGroup, previousSelectedAccountGroup);
770
800
  }
771
801
  }
772
- });
773
- this.messagingSystem.publish(`${exports.controllerName}:accountTreeChange`, this.state.accountTree);
774
- // Emit selectedAccountGroupChange event if the selected group changed
775
- if (selectedAccountGroupChanged) {
776
- this.messagingSystem.publish(`${exports.controllerName}:selectedAccountGroupChange`, this.state.accountTree.selectedAccountGroup, previousSelectedAccountGroup);
777
802
  }
778
803
  // Clear reverse-mapping for that account.
779
804
  __classPrivateFieldGet(this, _AccountTreeController_accountIdToContext, "f").delete(accountId);
@@ -790,9 +815,25 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
790
815
  delete state.accountWalletsMetadata[walletId];
791
816
  }
792
817
  return state;
793
- }, _AccountTreeController_insert = function _AccountTreeController_insert(wallets, account) {
794
- const result = __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_getEntropyRule).call(this).match(account) ??
795
- __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_getSnapRule).call(this).match(account) ??
818
+ }, _AccountTreeController_sortAccountsOfGroup = function _AccountTreeController_sortAccountsOfGroup(group) {
819
+ group.accounts.sort(
820
+ /* istanbul ignore next: Comparator branch execution (a===id vs b===id)
821
+ * and return attribution vary across engines; final ordering is covered
822
+ * by behavior tests. Ignoring the entire comparator avoids flaky line
823
+ * coverage without reducing scenario coverage.
824
+ */
825
+ (a, b) => {
826
+ const aSortOrder = __classPrivateFieldGet(this, _AccountTreeController_accountIdToContext, "f").get(a)?.sortOrder;
827
+ const bSortOrder = __classPrivateFieldGet(this, _AccountTreeController_accountIdToContext, "f").get(b)?.sortOrder;
828
+ return (aSortOrder ?? group_1.MAX_SORT_ORDER) - (bSortOrder ?? group_1.MAX_SORT_ORDER);
829
+ });
830
+ }, _AccountTreeController_insertAccount = function _AccountTreeController_insertAccount(wallets, account) {
831
+ if ((0, account_api_1.isBip44Account)(account)) {
832
+ // We're skipping BIP-44 accounts since we rely on the `MultichainAccountService` to do
833
+ // the grouping of wallets/groups directly.
834
+ return;
835
+ }
836
+ const result = __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_getSnapRule).call(this).match(account) ??
796
837
  __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_getKeyringRule).call(this).match(account); // This one cannot fail.
797
838
  // Update controller's state.
798
839
  const walletId = result.wallet.id;
@@ -811,10 +852,6 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
811
852
  // the union tag `result.wallet.type`.
812
853
  };
813
854
  wallet = wallets[walletId];
814
- // Trigger atomic sync for new wallet (only for entropy wallets)
815
- if (wallet.type === account_api_1.AccountWalletType.Entropy) {
816
- __classPrivateFieldGet(this, _AccountTreeController_backupAndSyncService, "f").enqueueSingleWalletSync(walletId);
817
- }
818
855
  }
819
856
  const groupId = result.group.id;
820
857
  let group = wallet.groups[groupId];
@@ -837,28 +874,9 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
837
874
  group = wallet.groups[groupId];
838
875
  // Map group ID to its containing wallet ID for efficient direct access
839
876
  __classPrivateFieldGet(this, _AccountTreeController_groupIdToWalletId, "f").set(groupId, walletId);
840
- // Trigger atomic sync for new group (only for entropy wallets)
841
- if (wallet.type === account_api_1.AccountWalletType.Entropy) {
842
- __classPrivateFieldGet(this, _AccountTreeController_backupAndSyncService, "f").enqueueSingleGroupSync(groupId);
843
- }
844
877
  }
845
878
  else {
846
879
  group.accounts.push(id);
847
- // We need to do this at every insertion because race conditions can happen
848
- // during the account creation process where one provider completes before the other.
849
- // The discovery process in the service can also lead to some accounts being created "out of order".
850
- const { accounts } = group;
851
- accounts.sort(
852
- /* istanbul ignore next: Comparator branch execution (a===id vs b===id)
853
- * and return attribution vary across engines; final ordering is covered
854
- * by behavior tests. Ignoring the entire comparator avoids flaky line
855
- * coverage without reducing scenario coverage.
856
- */
857
- (a, b) => {
858
- const aSortOrder = a === id ? sortOrder : __classPrivateFieldGet(this, _AccountTreeController_accountIdToContext, "f").get(a)?.sortOrder;
859
- const bSortOrder = b === id ? sortOrder : __classPrivateFieldGet(this, _AccountTreeController_accountIdToContext, "f").get(b)?.sortOrder;
860
- return ((aSortOrder ?? group_1.MAX_SORT_ORDER) - (bSortOrder ?? group_1.MAX_SORT_ORDER));
861
- });
862
880
  }
863
881
  (0, logger_1.projectLogger)(`[${groupId}] Add new account: { id: "${account.id}", type: "${account.type}", address: "${account.address}"`);
864
882
  // Update the reverse mapping for this account.
@@ -867,6 +885,88 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
867
885
  groupId: group.id,
868
886
  sortOrder,
869
887
  });
888
+ // We need to do this at every insertion because race conditions can happen
889
+ // during the account creation process where one provider completes before the other.
890
+ // The discovery process in the service can also lead to some accounts being created "out of order".
891
+ __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_sortAccountsOfGroup).call(this, group);
892
+ }, _AccountTreeController_insertOrUpdateMultichainAccountWalletAndGroup = function _AccountTreeController_insertOrUpdateMultichainAccountWalletAndGroup(wallets, multichainAccountWallet, multichainAccountGroup) {
893
+ const walletId = multichainAccountWallet.id;
894
+ const groupId = multichainAccountGroup.id;
895
+ let wallet = null;
896
+ let group = null;
897
+ // Check type, mainly to infer proper wallet object type.
898
+ const walletObject = wallets[walletId];
899
+ if (walletObject && walletObject.type === account_api_1.AccountWalletType.Entropy) {
900
+ wallet = walletObject;
901
+ group = wallet.groups[groupId];
902
+ }
903
+ // We always re-use the account list from the group (if accounts get
904
+ // added/removed/re-ordered within the group).
905
+ const accounts = multichainAccountGroup.getAccounts();
906
+ const accountIds = accounts
907
+ // For now, we need this type-cast because `getAccounts` do not have the same
908
+ // type-constraint (uses string[] instead of [string; ...string])
909
+ .map((account) => account.id);
910
+ // Create the group object first, to inject it in the wallet in case this wallet is
911
+ // not part of the tree yet.
912
+ if (!group) {
913
+ group = {
914
+ id: multichainAccountGroup.id,
915
+ type: multichainAccountGroup.type,
916
+ accounts: accountIds,
917
+ metadata: {
918
+ entropy: {
919
+ groupIndex: multichainAccountGroup.groupIndex,
920
+ },
921
+ name: '',
922
+ pinned: false,
923
+ hidden: false,
924
+ },
925
+ };
926
+ }
927
+ else {
928
+ group.accounts = accountIds;
929
+ }
930
+ if (!wallet) {
931
+ wallet = {
932
+ id: multichainAccountWallet.id,
933
+ type: multichainAccountWallet.type,
934
+ status: multichainAccountWallet.status,
935
+ groups: {
936
+ [group.id]: group,
937
+ },
938
+ metadata: {
939
+ entropy: {
940
+ id: multichainAccountWallet.entropySource,
941
+ },
942
+ name: '', // Will get updated later.
943
+ },
944
+ };
945
+ wallets[walletId] = wallet;
946
+ // Trigger atomic sync for new wallet.
947
+ __classPrivateFieldGet(this, _AccountTreeController_backupAndSyncService, "f").enqueueSingleWalletSync(walletId);
948
+ }
949
+ else {
950
+ wallet.groups[group.id] = group;
951
+ // Trigger atomic sync for new group.
952
+ __classPrivateFieldGet(this, _AccountTreeController_backupAndSyncService, "f").enqueueSingleGroupSync(groupId);
953
+ }
954
+ // Map group ID to its containing wallet ID for efficient direct access
955
+ __classPrivateFieldGet(this, _AccountTreeController_groupIdToWalletId, "f").set(groupId, walletId);
956
+ // Update the reverse mapping for all accounts account.
957
+ for (const account of accounts) {
958
+ __classPrivateFieldGet(this, _AccountTreeController_accountIdToContext, "f").set(account.id, {
959
+ walletId: wallet.id,
960
+ groupId: group.id,
961
+ sortOrder: group_1.ACCOUNT_TYPE_TO_SORT_ORDER[account.type] ?? group_1.MAX_SORT_ORDER,
962
+ });
963
+ }
964
+ // We need to do this at every insertion because race conditions can happen
965
+ // during the account creation process where one provider completes before the other.
966
+ // The discovery process in the service can also lead to some accounts being created "out of order".
967
+ __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_sortAccountsOfGroup).call(this, group);
968
+ }, _AccountTreeController_getMultichainAccountWallets = function _AccountTreeController_getMultichainAccountWallets() {
969
+ return this.messagingSystem.call('MultichainAccountService:getMultichainAccountWallets');
870
970
  }, _AccountTreeController_listAccounts = function _AccountTreeController_listAccounts() {
871
971
  return this.messagingSystem.call('AccountsController:listMultichainAccounts');
872
972
  }, _AccountTreeController_assertAccountGroupExists = function _AccountTreeController_assertAccountGroupExists(groupId) {
@@ -911,6 +1011,19 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
911
1011
  state.accountTree.selectedAccountGroup = groupId;
912
1012
  });
913
1013
  this.messagingSystem.publish(`${exports.controllerName}:selectedAccountGroupChange`, groupId, previousSelectedAccountGroup);
1014
+ }, _AccountTreeController_handleMultichainAccountGroupCreatedOrUpdated = function _AccountTreeController_handleMultichainAccountGroupCreatedOrUpdated(multichainAccountGroup) {
1015
+ this.update((state) => {
1016
+ __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_insertOrUpdateMultichainAccountWalletAndGroup).call(this, state.accountTree.wallets, multichainAccountGroup.wallet, multichainAccountGroup);
1017
+ const wallet = state.accountTree.wallets[multichainAccountGroup.wallet.id];
1018
+ if (wallet) {
1019
+ __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_applyAccountWalletMetadata).call(this, state, wallet.id);
1020
+ const group = wallet.groups[multichainAccountGroup.id];
1021
+ if (group) {
1022
+ __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_applyAccountGroupMetadata).call(this, state, wallet.id, group.id);
1023
+ }
1024
+ }
1025
+ });
1026
+ this.messagingSystem.publish(`${exports.controllerName}:accountTreeChange`, this.state.accountTree);
914
1027
  }, _AccountTreeController_handleMultichainAccountWalletStatusChange = function _AccountTreeController_handleMultichainAccountWalletStatusChange(walletId, walletStatus) {
915
1028
  this.update((state) => {
916
1029
  const wallet = state.accountTree.wallets[walletId];