@metamask-previews/account-tree-controller 1.3.0-preview-e5ce1e86 → 1.4.0-preview-bc80f5a1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"AccountTreeController.d.cts","sourceRoot":"","sources":["../src/AccountTreeController.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,eAAe,EAGhB,8BAA8B;AAI/B,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAG3D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAUtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,oBAAgB;AACvE,OAAO,EACL,0BAA0B,EAI3B,oBAAgB;AAMjB,OAAO,KAAK,EACV,2BAA2B,EAE3B,8BAA8B,EAC9B,0BAA0B,EAC3B,oBAAgB;AACjB,OAAO,EAAE,KAAK,mBAAmB,EAA8B,qBAAiB;AAEhF,eAAO,MAAM,cAAc,0BAA0B,CAAC;AAoCtD;;;;GAIG;AACH,wBAAgB,oCAAoC,IAAI,0BAA0B,CAWjF;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,QAAQ,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAEpC;;OAEG;IACH,OAAO,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAElC;;OAEG;IACH,SAAS,EAAE,CAAC,OAAO,0BAA0B,CAAC,CAAC,mBAAmB,CAAC,CAAC;CACrE,CAAC;AAEF,qBAAa,qBAAsB,SAAQ,cAAc,CACvD,OAAO,cAAc,EACrB,0BAA0B,EAC1B,8BAA8B,CAC/B;;IAkBC;;;;;;;OAOG;gBAES,EACV,SAAS,EACT,KAAK,EACL,MAAM,GACP,EAAE;QACD,SAAS,EAAE,8BAA8B,CAAC;QAC1C,KAAK,CAAC,EAAE,OAAO,CAAC,0BAA0B,CAAC,CA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AAC,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA+B7C;;;;;OAKG;IACH,qBAAqB,CACnB,OAAO,EAAE,cAAc,GACtB,kBAAkB,GAAG,SAAS;IAiTjC;;;;OAIG;IACH,uBAAuB,IAAI,cAAc,GAAG,EAAE;IAI9C;;;;OAIG;IACH,uBAAuB,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IA2MtD;;;;;;;;OAQG;IACH,mBAAmB,CACjB,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,MAAM,GACX,MAAM;IAeT;;;;;;;;OAQG;IACH,mBAAmB,CACjB,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,MAAM,EACZ,kBAAkB,GAAE,OAAe,GAClC,IAAI;IAgDP;;;;;;OAMG;IACH,oBAAoB,CAAC,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAyBnE;;;;;;OAMG;IACH,qBAAqB,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;IAmCrE;;;;;;OAMG;IACH,qBAAqB,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;IAmCrE;;;OAGG;IACH,UAAU,IAAI,IAAI;IAsDlB;;;;;;;;;;OAUG;IACG,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI1C;;;;;;;;;;;OAWG;IACG,8BAA8B,IAAI,OAAO,CAAC,IAAI,CAAC;CAoBtD"}
@@ -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 _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_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;
12
+ 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
13
  import { AccountWalletType, select } from "@metamask/account-api";
14
14
  import { BaseController } from "@metamask/base-controller";
15
15
  import { isEvmAccountType } from "@metamask/keyring-api";
@@ -191,16 +191,22 @@ export class AccountTreeController extends BaseController {
191
191
  // Used for default group default names (so we use human-indexing here).
192
192
  let nextNaturalNameIndex = 1;
193
193
  for (const group of Object.values(wallet.groups)) {
194
- __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_applyAccountGroupMetadata).call(this, state, wallet.id, group.id,
195
- // FIXME: We should not need this kind of logic if we were not inserting accounts
196
- // 1 by 1. Instead, we should be inserting wallets and groups directly. This would
197
- // allow us to naturally insert a group in the tree AND update its metadata right
198
- // away...
199
- // But here, we have to wait for the entire group to be ready before updating
200
- // its metadata (mainly because we're dealing with single accounts rather than entire
201
- // groups).
202
- // That is why we need this kind of extra parameter.
203
- nextNaturalNameIndex);
194
+ __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_applyAccountGroupMetadata).call(this, state, wallet.id, group.id, {
195
+ // We allow computed name when initializing the tree.
196
+ // This will automatically handle account name migration for the very first init of the
197
+ // tree. Once groups are created, their name will be persisted, thus, taking precedence
198
+ // over the computed names (even if we re-init).
199
+ allowComputedName: true,
200
+ // FIXME: We should not need this kind of logic if we were not inserting accounts
201
+ // 1 by 1. Instead, we should be inserting wallets and groups directly. This would
202
+ // allow us to naturally insert a group in the tree AND update its metadata right
203
+ // away...
204
+ // But here, we have to wait for the entire group to be ready before updating
205
+ // its metadata (mainly because we're dealing with single accounts rather than entire
206
+ // groups).
207
+ // That is why we need this kind of extra parameter.
208
+ nextNaturalNameIndex,
209
+ });
204
210
  if (group.id === previousSelectedAccountGroup) {
205
211
  previousSelectedAccountGroupStillExists = true;
206
212
  }
@@ -582,7 +588,82 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
582
588
  default:
583
589
  return __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_getKeyringRule).call(this);
584
590
  }
585
- }, _AccountTreeController_applyAccountGroupMetadata = function _AccountTreeController_applyAccountGroupMetadata(state, walletId, groupId, nextNaturalNameIndex) {
591
+ }, _AccountTreeController_getComputedAccountGroupName = function _AccountTreeController_getComputedAccountGroupName(wallet, group) {
592
+ let proposedName = ''; // Empty means there's no computed name for this group.
593
+ for (const id of group.accounts) {
594
+ const account = this.messagingSystem.call('AccountsController:getAccount', id);
595
+ if (!account) {
596
+ continue;
597
+ }
598
+ // We only consider EVM account types for computed names.
599
+ if (isEvmAccountType(account.type) && account.metadata.name.length) {
600
+ proposedName = account.metadata.name;
601
+ break;
602
+ }
603
+ }
604
+ // If this name already exists for whatever reason, we rename it to resolve this conflict.
605
+ if (proposedName.length &&
606
+ !isAccountGroupNameUniqueFromWallet(wallet, group.id, proposedName)) {
607
+ proposedName = this.resolveNameConflict(wallet, group.id, proposedName);
608
+ }
609
+ return proposedName;
610
+ }, _AccountTreeController_getDefaultAccountGroupName = function _AccountTreeController_getDefaultAccountGroupName(state, wallet, group, nextNaturalNameIndex) {
611
+ // Get the appropriate rule for this wallet type
612
+ const rule = __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_getRuleForWallet).call(this, wallet);
613
+ // Get the prefix for groups of this wallet
614
+ const namePrefix = rule.getDefaultAccountGroupPrefix(wallet);
615
+ // Parse the highest account index being used (similar to accounts-controller)
616
+ let highestNameIndex = 0;
617
+ for (const { id: otherGroupId } of Object.values(wallet.groups)) {
618
+ // Skip the current group being processed
619
+ if (otherGroupId === group.id) {
620
+ continue;
621
+ }
622
+ // We always get the name from the persisted map, since `init` will clear the
623
+ // `state.accountTree.wallets`, thus, given empty `group.metadata.name`.
624
+ // NOTE: If the other group has not been named yet, we just use an empty name.
625
+ const otherGroupName = state.accountGroupsMetadata[otherGroupId]?.name?.value ?? '';
626
+ // Parse the existing group name to extract the numeric index
627
+ const nameMatch = otherGroupName.match(/account\s+(\d+)$/iu);
628
+ if (nameMatch) {
629
+ const nameIndex = parseInt(nameMatch[1], 10);
630
+ if (nameIndex > highestNameIndex) {
631
+ highestNameIndex = nameIndex;
632
+ }
633
+ }
634
+ }
635
+ // We just use the highest known index no matter the wallet type.
636
+ //
637
+ // For entropy-based wallets (bip44), if a multichain account group with group index 1
638
+ // is inserted before another one with group index 0, then the naming will be:
639
+ // - "Account 1" (group index 1)
640
+ // - "Account 2" (group index 0)
641
+ // This naming makes more sense for the end-user.
642
+ //
643
+ // For other type of wallets, since those wallets can create arbitrary gaps, we still
644
+ // rely on the highest know index to avoid back-filling account with "old names".
645
+ let proposedNameIndex = Math.max(
646
+ // Use + 1 to use the next available index.
647
+ highestNameIndex + 1,
648
+ // In case all accounts have been renamed differently than the usual "Account <index>"
649
+ // pattern, we want to use the next "natural" index, which is just the number of groups
650
+ // in that wallet (e.g. ["Account A", "Another Account"], next natural index would be
651
+ // "Account 3" in this case).
652
+ nextNaturalNameIndex ?? Object.keys(wallet.groups).length);
653
+ // Find a unique name by checking for conflicts and incrementing if needed
654
+ let proposedNameExists;
655
+ let proposedName = '';
656
+ do {
657
+ proposedName = `${namePrefix} ${proposedNameIndex}`;
658
+ // Check if this name already exists in the wallet (excluding current group)
659
+ proposedNameExists = !isAccountGroupNameUniqueFromWallet(wallet, group.id, proposedName);
660
+ /* istanbul ignore next */
661
+ if (proposedNameExists) {
662
+ proposedNameIndex += 1; // Try next number
663
+ }
664
+ } while (proposedNameExists);
665
+ return proposedName;
666
+ }, _AccountTreeController_applyAccountGroupMetadata = function _AccountTreeController_applyAccountGroupMetadata(state, walletId, groupId, { allowComputedName, nextNaturalNameIndex, } = {}) {
586
667
  var _a;
587
668
  const wallet = state.accountTree.wallets[walletId];
588
669
  const group = wallet.groups[groupId];
@@ -593,62 +674,16 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
593
674
  persistedGroupMetadata.name.value;
594
675
  }
595
676
  else if (!group.metadata.name) {
596
- // Get the appropriate rule for this wallet type
597
- const rule = __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_getRuleForWallet).call(this, wallet);
598
- // Get the prefix for groups of this wallet
599
- const namePrefix = rule.getDefaultAccountGroupPrefix(wallet);
600
- // Skip computed names for now - use default naming with per-wallet logic
601
- // TODO: Implement computed names in a future iteration
602
- // Parse the highest account index being used (similar to accounts-controller)
603
- let highestNameIndex = 0;
604
- for (const { id: otherGroupId } of Object.values(wallet.groups)) {
605
- // Skip the current group being processed
606
- if (otherGroupId === groupId) {
607
- continue;
608
- }
609
- // We always get the name from the persisted map, since `init` will clear the
610
- // `state.accountTree.wallets`, thus, given empty `group.metadata.name`.
611
- // NOTE: If the other group has not been named yet, we just use an empty name.
612
- const otherGroupName = state.accountGroupsMetadata[otherGroupId]?.name?.value ?? '';
613
- // Parse the existing group name to extract the numeric index
614
- const nameMatch = otherGroupName.match(/account\s+(\d+)$/iu);
615
- if (nameMatch) {
616
- const nameIndex = parseInt(nameMatch[1], 10);
617
- if (nameIndex > highestNameIndex) {
618
- highestNameIndex = nameIndex;
619
- }
620
- }
621
- }
622
- // We just use the highest known index no matter the wallet type.
623
- //
624
- // For entropy-based wallets (bip44), if a multichain account group with group index 1
625
- // is inserted before another one with group index 0, then the naming will be:
626
- // - "Account 1" (group index 1)
627
- // - "Account 2" (group index 0)
628
- // This naming makes more sense for the end-user.
629
- //
630
- // For other type of wallets, since those wallets can create arbitrary gaps, we still
631
- // rely on the highest know index to avoid back-filling account with "old names".
632
- let proposedNameIndex = Math.max(
633
- // Use + 1 to use the next available index.
634
- highestNameIndex + 1,
635
- // In case all accounts have been renamed differently than the usual "Account <index>"
636
- // pattern, we want to use the next "natural" index, which is just the number of groups
637
- // in that wallet (e.g. ["Account A", "Another Account"], next natural index would be
638
- // "Account 3" in this case).
639
- nextNaturalNameIndex ?? Object.keys(wallet.groups).length);
640
- // Find a unique name by checking for conflicts and incrementing if needed
641
- let proposedNameExists;
642
677
  let proposedName = '';
643
- do {
644
- proposedName = `${namePrefix} ${proposedNameIndex}`;
645
- // Check if this name already exists in the wallet (excluding current group)
646
- proposedNameExists = !isAccountGroupNameUniqueFromWallet(wallet, group.id, proposedName);
647
- /* istanbul ignore next */
648
- if (proposedNameExists) {
649
- proposedNameIndex += 1; // Try next number
650
- }
651
- } while (proposedNameExists);
678
+ // Computed names are usually only used for existing/old accounts. So this option
679
+ // should be used only when we first initialize the tree.
680
+ if (allowComputedName) {
681
+ proposedName = __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_getComputedAccountGroupName).call(this, wallet, group);
682
+ }
683
+ // If we still don't have a valid name candidate, we fallback to a default name.
684
+ if (!proposedName.length) {
685
+ proposedName = __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_getDefaultAccountGroupName).call(this, state, wallet, group, nextNaturalNameIndex);
686
+ }
652
687
  state.accountTree.wallets[walletId].groups[groupId].metadata.name =
653
688
  proposedName;
654
689
  log(`[${group.id}] Set default name to: "${group.metadata.name}"`);