@metamask-previews/account-tree-controller 0.7.0-preview-0fca3de → 0.7.0-preview-af4e47c0

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/AccountTreeController.cjs +183 -36
  3. package/dist/AccountTreeController.cjs.map +1 -1
  4. package/dist/AccountTreeController.d.cts +32 -0
  5. package/dist/AccountTreeController.d.cts.map +1 -1
  6. package/dist/AccountTreeController.d.mts +32 -0
  7. package/dist/AccountTreeController.d.mts.map +1 -1
  8. package/dist/AccountTreeController.mjs +183 -36
  9. package/dist/AccountTreeController.mjs.map +1 -1
  10. package/dist/group.cjs.map +1 -1
  11. package/dist/group.d.cts +19 -8
  12. package/dist/group.d.cts.map +1 -1
  13. package/dist/group.d.mts +19 -8
  14. package/dist/group.d.mts.map +1 -1
  15. package/dist/group.mjs.map +1 -1
  16. package/dist/rules/entropy.cjs +2 -0
  17. package/dist/rules/entropy.cjs.map +1 -1
  18. package/dist/rules/entropy.d.cts.map +1 -1
  19. package/dist/rules/entropy.d.mts.map +1 -1
  20. package/dist/rules/entropy.mjs +2 -0
  21. package/dist/rules/entropy.mjs.map +1 -1
  22. package/dist/rules/keyring.cjs +4 -1
  23. package/dist/rules/keyring.cjs.map +1 -1
  24. package/dist/rules/keyring.d.cts.map +1 -1
  25. package/dist/rules/keyring.d.mts.map +1 -1
  26. package/dist/rules/keyring.mjs +4 -1
  27. package/dist/rules/keyring.mjs.map +1 -1
  28. package/dist/rules/snap.cjs +4 -1
  29. package/dist/rules/snap.cjs.map +1 -1
  30. package/dist/rules/snap.d.cts.map +1 -1
  31. package/dist/rules/snap.d.mts.map +1 -1
  32. package/dist/rules/snap.mjs +4 -1
  33. package/dist/rules/snap.mjs.map +1 -1
  34. package/dist/type-utils.cjs +3 -0
  35. package/dist/type-utils.cjs.map +1 -0
  36. package/dist/type-utils.d.cts +24 -0
  37. package/dist/type-utils.d.cts.map +1 -0
  38. package/dist/type-utils.d.mts +24 -0
  39. package/dist/type-utils.d.mts.map +1 -0
  40. package/dist/type-utils.mjs +2 -0
  41. package/dist/type-utils.mjs.map +1 -0
  42. package/dist/types.cjs.map +1 -1
  43. package/dist/types.d.cts +14 -1
  44. package/dist/types.d.cts.map +1 -1
  45. package/dist/types.d.mts +14 -1
  46. package/dist/types.d.mts.map +1 -1
  47. package/dist/types.mjs.map +1 -1
  48. package/dist/wallet.cjs.map +1 -1
  49. package/dist/wallet.d.cts +16 -9
  50. package/dist/wallet.d.cts.map +1 -1
  51. package/dist/wallet.d.mts +16 -9
  52. package/dist/wallet.d.mts.map +1 -1
  53. package/dist/wallet.mjs.map +1 -1
  54. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"group.mjs","sourceRoot":"","sources":["../src/group.ts"],"names":[],"mappings":";;;;;;;;;;;;AAWA,MAAM,CAAC,MAAM,0BAA0B,GAAW,SAAS,CAAC;AAkE5D;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAO3B,YAAY,EACV,SAAS,EACT,MAAM,EACN,KAAK,GAKN;;QAdQ,8CAA2C;QAE3C,0CAA2B;QAE3B,2CAA2B;QAWlC,uBAAA,IAAI,+BAAc,SAAS,MAAA,CAAC;QAC5B,uBAAA,IAAI,2BAAU,KAAK,MAAA,CAAC;QACpB,uBAAA,IAAI,4BAAW,MAAM,MAAA,CAAC;IACxB,CAAC;IAED,IAAI,EAAE;QACJ,OAAO,uBAAA,IAAI,+BAAO,CAAC,EAAE,CAAC;IACxB,CAAC;IAED,IAAI,MAAM;QACR,OAAO,uBAAA,IAAI,gCAAQ,CAAC;IACtB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,uBAAA,IAAI,+BAAO,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,IAAI,IAAI;QACN,OAAO,uBAAA,IAAI,+BAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;IACnC,CAAC;IAED,aAAa;QACX,OAAO,uBAAA,IAAI,+BAAO,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED,UAAU,CAAC,EAAU;QACnB,OAAO,uBAAA,IAAI,mCAAW,CAAC,IAAI,CAAC,+BAA+B,EAAE,EAAE,CAAC,CAAC;IACnE,CAAC;IAWD,WAAW;QACT,OAAO,uBAAA,IAAI,+BAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,uBAAA,IAAI,iEAAY,MAAhB,IAAI,EAAa,EAAE,CAAC,CAAC,CAAC;IAChE,CAAC;IAED,cAAc;QACZ,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAExC,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;SACvD;QAED,4CAA4C;QAC5C,OAAO,uBAAA,IAAI,iEAAY,MAAhB,IAAI,EAAa,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;CACF;kPAvBa,EAAU;IACpB,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAEpC,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,mCAAmC,EAAE,GAAG,CAAC,CAAC;KAC3D;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type {\n AccountGroupType,\n MultichainAccountGroupId,\n} from '@metamask/account-api';\nimport type { AccountGroup, AccountGroupId } from '@metamask/account-api';\nimport type { AccountId } from '@metamask/accounts-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport type { AccountTreeControllerMessenger } from './types';\nimport type { AccountTreeWallet } from './wallet';\n\nexport const DEFAULT_ACCOUNT_GROUP_NAME: string = 'Default';\n\n/**\n * Type constraint for a {@link AccountGroupObject}. If one of its union-members\n * does not match this contraint, {@link AccountGroupObject} will resolve\n * to `never`.\n */\ntype IsAccountGroupObject<\n Type extends {\n type: AccountGroupType;\n id: AccountGroupId;\n accounts: AccountId[];\n metadata: {\n name: string;\n };\n },\n> = Type;\n\n/**\n * Multichain-account group object.\n */\nexport type AccountGroupMultichainAccountObject = {\n type: AccountGroupType.MultichainAccount;\n id: MultichainAccountGroupId;\n // Blockchain Accounts (at least 1 account per multichain-accounts):\n accounts: [AccountId, ...AccountId[]];\n metadata: {\n name: string;\n entropy: {\n groupIndex: number;\n };\n };\n};\n\n/**\n * Multichain-account group object.\n */\nexport type AccountGroupSingleAccountObject = {\n type: AccountGroupType.SingleAccount;\n id: AccountGroupId;\n // Blockchain Accounts (1 account per group):\n accounts: [AccountId];\n metadata: {\n name: string;\n };\n};\n\n/**\n * Account group object.\n */\nexport type AccountGroupObject = IsAccountGroupObject<\n AccountGroupMultichainAccountObject | AccountGroupSingleAccountObject\n>;\n\nexport type AccountGroupObjectOf<GroupType extends AccountGroupType> = Extract<\n | {\n type: AccountGroupType.MultichainAccount;\n object: AccountGroupMultichainAccountObject;\n }\n | {\n type: AccountGroupType.SingleAccount;\n object: AccountGroupSingleAccountObject;\n },\n { type: GroupType }\n>['object'];\n\n/**\n * Account group coming from the {@link AccountTreeController}.\n */\nexport class AccountTreeGroup implements AccountGroup<InternalAccount> {\n readonly #messenger: AccountTreeControllerMessenger;\n\n readonly #group: AccountGroupObject;\n\n readonly #wallet: AccountTreeWallet;\n\n constructor({\n messenger,\n wallet,\n group,\n }: {\n messenger: AccountTreeControllerMessenger;\n wallet: AccountTreeWallet;\n group: AccountGroupObject;\n }) {\n this.#messenger = messenger;\n this.#group = group;\n this.#wallet = wallet;\n }\n\n get id(): AccountGroupId {\n return this.#group.id;\n }\n\n get wallet(): AccountTreeWallet {\n return this.#wallet;\n }\n\n get type(): AccountGroupType {\n return this.#group.type;\n }\n\n get name(): string {\n return this.#group.metadata.name;\n }\n\n getAccountIds(): [InternalAccount['id'], ...InternalAccount['id'][]] {\n return this.#group.accounts;\n }\n\n getAccount(id: string): InternalAccount | undefined {\n return this.#messenger.call('AccountsController:getAccount', id);\n }\n\n #getAccount(id: string): InternalAccount {\n const account = this.getAccount(id);\n\n if (!account) {\n throw new Error(`Unable to get account with ID: \"${id}\"`);\n }\n return account;\n }\n\n getAccounts(): InternalAccount[] {\n return this.#group.accounts.map((id) => this.#getAccount(id));\n }\n\n getOnlyAccount(): InternalAccount {\n const accountIds = this.getAccountIds();\n\n if (accountIds.length > 1) {\n throw new Error('Group contains more than 1 account');\n }\n\n // A group always have at least one account.\n return this.#getAccount(accountIds[0]);\n }\n}\n"]}
1
+ {"version":3,"file":"group.mjs","sourceRoot":"","sources":["../src/group.ts"],"names":[],"mappings":";;;;;;;;;;;;AAiCA,MAAM,CAAC,MAAM,0BAA0B,GAAW,SAAS,CAAC;AA6D5D;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAO3B,YAAY,EACV,SAAS,EACT,MAAM,EACN,KAAK,GAKN;;QAdQ,8CAA2C;QAE3C,0CAA2B;QAE3B,2CAA2B;QAWlC,uBAAA,IAAI,+BAAc,SAAS,MAAA,CAAC;QAC5B,uBAAA,IAAI,2BAAU,KAAK,MAAA,CAAC;QACpB,uBAAA,IAAI,4BAAW,MAAM,MAAA,CAAC;IACxB,CAAC;IAED,IAAI,EAAE;QACJ,OAAO,uBAAA,IAAI,+BAAO,CAAC,EAAE,CAAC;IACxB,CAAC;IAED,IAAI,MAAM;QACR,OAAO,uBAAA,IAAI,gCAAQ,CAAC;IACtB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,uBAAA,IAAI,+BAAO,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,IAAI,IAAI;QACN,OAAO,uBAAA,IAAI,+BAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;IACnC,CAAC;IAED,aAAa;QACX,OAAO,uBAAA,IAAI,+BAAO,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED,UAAU,CAAC,EAAU;QACnB,OAAO,uBAAA,IAAI,mCAAW,CAAC,IAAI,CAAC,+BAA+B,EAAE,EAAE,CAAC,CAAC;IACnE,CAAC;IAWD,WAAW;QACT,OAAO,uBAAA,IAAI,+BAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,uBAAA,IAAI,iEAAY,MAAhB,IAAI,EAAa,EAAE,CAAC,CAAC,CAAC;IAChE,CAAC;IAED,cAAc;QACZ,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAExC,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;SACvD;QAED,4CAA4C;QAC5C,OAAO,uBAAA,IAAI,iEAAY,MAAhB,IAAI,EAAa,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;CACF;kPAvBa,EAAU;IACpB,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAEpC,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,mCAAmC,EAAE,GAAG,CAAC,CAAC;KAC3D;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type {\n AccountGroupType,\n MultichainAccountGroupId,\n} from '@metamask/account-api';\nimport type { AccountGroup, AccountGroupId } from '@metamask/account-api';\nimport type { AccountId } from '@metamask/accounts-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport type {\n UpdatableField,\n ExtractRequiredFieldValues,\n} from './type-utils.js';\nimport type { AccountTreeControllerMessenger } from './types';\nimport type { AccountTreeWallet } from './wallet';\n\n/**\n * Persisted metadata for account groups (stored in controller state for persistence/sync).\n */\nexport type AccountGroupPersistedMetadata = {\n /** Custom name set by user, overrides default naming logic */\n name?: UpdatableField<string>;\n /** Whether this group is pinned in the UI */\n pinned?: UpdatableField<boolean>;\n /** Whether this group is hidden in the UI */\n hidden?: UpdatableField<boolean>;\n};\n\n/**\n * Tree metadata for account groups (required plain values extracted from persisted metadata).\n */\nexport type AccountGroupTreeMetadata =\n ExtractRequiredFieldValues<AccountGroupPersistedMetadata>;\n\nexport const DEFAULT_ACCOUNT_GROUP_NAME: string = 'Default';\n\n/**\n * Type constraint for a {@link AccountGroupObject}. If one of its union-members\n * does not match this contraint, {@link AccountGroupObject} will resolve\n * to `never`.\n */\ntype IsAccountGroupObject<\n Type extends {\n type: AccountGroupType;\n id: AccountGroupId;\n accounts: AccountId[];\n metadata: AccountGroupTreeMetadata;\n },\n> = Type;\n\n/**\n * Multichain-account group object.\n */\nexport type AccountGroupMultichainAccountObject = {\n type: AccountGroupType.MultichainAccount;\n id: MultichainAccountGroupId;\n // Blockchain Accounts (at least 1 account per multichain-accounts):\n accounts: [AccountId, ...AccountId[]];\n metadata: AccountGroupTreeMetadata & {\n entropy: {\n groupIndex: number;\n };\n };\n};\n\n/**\n * Multichain-account group object.\n */\nexport type AccountGroupSingleAccountObject = {\n type: AccountGroupType.SingleAccount;\n id: AccountGroupId;\n // Blockchain Accounts (1 account per group):\n accounts: [AccountId];\n metadata: AccountGroupTreeMetadata;\n};\n\n/**\n * Account group object.\n */\nexport type AccountGroupObject = IsAccountGroupObject<\n AccountGroupMultichainAccountObject | AccountGroupSingleAccountObject\n>;\n\nexport type AccountGroupObjectOf<GroupType extends AccountGroupType> = Extract<\n | {\n type: AccountGroupType.MultichainAccount;\n object: AccountGroupMultichainAccountObject;\n }\n | {\n type: AccountGroupType.SingleAccount;\n object: AccountGroupSingleAccountObject;\n },\n { type: GroupType }\n>['object'];\n\n/**\n * Account group coming from the {@link AccountTreeController}.\n */\nexport class AccountTreeGroup implements AccountGroup<InternalAccount> {\n readonly #messenger: AccountTreeControllerMessenger;\n\n readonly #group: AccountGroupObject;\n\n readonly #wallet: AccountTreeWallet;\n\n constructor({\n messenger,\n wallet,\n group,\n }: {\n messenger: AccountTreeControllerMessenger;\n wallet: AccountTreeWallet;\n group: AccountGroupObject;\n }) {\n this.#messenger = messenger;\n this.#group = group;\n this.#wallet = wallet;\n }\n\n get id(): AccountGroupId {\n return this.#group.id;\n }\n\n get wallet(): AccountTreeWallet {\n return this.#wallet;\n }\n\n get type(): AccountGroupType {\n return this.#group.type;\n }\n\n get name(): string {\n return this.#group.metadata.name;\n }\n\n getAccountIds(): [InternalAccount['id'], ...InternalAccount['id'][]] {\n return this.#group.accounts;\n }\n\n getAccount(id: string): InternalAccount | undefined {\n return this.#messenger.call('AccountsController:getAccount', id);\n }\n\n #getAccount(id: string): InternalAccount {\n const account = this.getAccount(id);\n\n if (!account) {\n throw new Error(`Unable to get account with ID: \"${id}\"`);\n }\n return account;\n }\n\n getAccounts(): InternalAccount[] {\n return this.#group.accounts.map((id) => this.#getAccount(id));\n }\n\n getOnlyAccount(): InternalAccount {\n const accountIds = this.getAccountIds();\n\n if (accountIds.length > 1) {\n throw new Error('Group contains more than 1 account');\n }\n\n // A group always have at least one account.\n return this.#getAccount(accountIds[0]);\n }\n}\n"]}
@@ -48,6 +48,8 @@ class EntropyRule extends rule_1.BaseRule {
48
48
  entropy: {
49
49
  groupIndex: account.options.entropy.groupIndex,
50
50
  },
51
+ pinned: false,
52
+ hidden: false,
51
53
  },
52
54
  },
53
55
  };
@@ -1 +1 @@
1
- {"version":3,"file":"entropy.cjs","sourceRoot":"","sources":["../../src/rules/entropy.ts"],"names":[],"mappings":";;;AAAA,uDAM+B;AAC/B,uDAAyD;AACzD,qEAA4D;AAI5D,sCAA+D;AAG/D,MAAa,WACX,SAAQ,eAAQ;IADlB;;QAIW,eAAU,GAAG,+BAAiB,CAAC,OAAO,CAAC;QAEvC,cAAS,GAAG,8BAAgB,CAAC,iBAAiB,CAAC;IAoF1D,CAAC;IAlFC,qBAAqB,CAAC,aAAqB;QACzC,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QAEvE,OAAO,QAAQ;aACZ,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,O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U,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,oCAAoC;IAC5F,CAAC;IAED,0BAA0B,CACxB,KAA+D;QAE/D,IAAI,SAAS,GAAG,EAAE,CAAC;QACnB,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,QAAQ,EAAE;YAC/B,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,+BAA+B,EAAE,EAAE,CAAC,CAAC;YAEzE,IAAI,OAAO,EAAE;gBACX,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAElC,2CAA2C;gBAC3C,IAAI,IAAA,8BAAgB,EAAC,OAAO,CAAC,IAAI,CAAC,EAAE;oBAClC,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;iBAC9B;aACF;SACF;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AA1FD,kCA0FC","sourcesContent":["import {\n AccountGroupType,\n AccountWalletType,\n isBip44Account,\n toMultichainAccountGroupId,\n toMultichainAccountWalletId,\n} from '@metamask/account-api';\nimport { isEvmAccountType } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport type { AccountGroupObjectOf } from '../group';\nimport { BaseRule, type Rule, type RuleResult } from '../rule';\nimport type { AccountWalletObjectOf } from '../wallet';\n\nexport class EntropyRule\n extends BaseRule\n implements Rule<AccountWalletType.Entropy, AccountGroupType.MultichainAccount>\n{\n readonly walletType = AccountWalletType.Entropy;\n\n readonly groupType = AccountGroupType.MultichainAccount;\n\n getEntropySourceIndex(entropySource: string) {\n const { keyrings } = this.messenger.call('KeyringController:getState');\n\n return keyrings\n .filter((keyring) => keyring.type === (KeyringTypes.hd as string))\n .findIndex((keyring) => keyring.metadata.id === entropySource);\n }\n\n match(\n account: InternalAccount,\n ):\n | RuleResult<AccountWalletType.Entropy, AccountGroupType.MultichainAccount>\n | undefined {\n if (!isBip44Account(account)) {\n return undefined;\n }\n\n const entropySource = account.options.entropy.id;\n const entropySourceIndex = this.getEntropySourceIndex(entropySource);\n if (entropySourceIndex === -1) {\n console.warn(\n `! Found an unknown entropy ID: \"${entropySource}\", account \"${account.id}\" won't be grouped by entropy.`,\n );\n return undefined;\n }\n\n const walletId = toMultichainAccountWalletId(entropySource);\n const groupId = toMultichainAccountGroupId(\n walletId,\n account.options.entropy.groupIndex,\n );\n\n return {\n wallet: {\n type: this.walletType,\n id: walletId,\n metadata: {\n entropy: {\n id: entropySource,\n // QUESTION: Should we re-compute the index everytime instead?\n index: entropySourceIndex,\n },\n },\n },\n\n group: {\n type: this.groupType,\n id: groupId,\n metadata: {\n entropy: {\n groupIndex: account.options.entropy.groupIndex,\n },\n },\n },\n };\n }\n\n getDefaultAccountWalletName(\n wallet: AccountWalletObjectOf<AccountWalletType.Entropy>,\n ): string {\n return `Wallet ${wallet.metadata.entropy.index + 1}`; // Use human indexing (starts at 1).\n }\n\n getDefaultAccountGroupName(\n group: AccountGroupObjectOf<AccountGroupType.MultichainAccount>,\n ): string {\n let candidate = '';\n for (const id of group.accounts) {\n const account = this.messenger.call('AccountsController:getAccount', id);\n\n if (account) {\n candidate = account.metadata.name;\n\n // EVM account name has a highest priority.\n if (isEvmAccountType(account.type)) {\n return account.metadata.name;\n }\n }\n }\n\n return candidate;\n }\n}\n"]}
1
+ {"version":3,"file":"entropy.cjs","sourceRoot":"","sources":["../../src/rules/entropy.ts"],"names":[],"mappings":";;;AAAA,uDAM+B;AAC/B,uDAAyD;AACzD,qEAA4D;AAI5D,sCAA+D;AAG/D,MAAa,WACX,SAAQ,eAAQ;IADlB;;QAIW,eAAU,GAAG,+BAAiB,CAAC,OAAO,CAAC;QAEvC,cAAS,GAAG,8BAAgB,CAAC,iBAAiB,CAAC;IAsF1D,CAAC;IApFC,qBAAqB,CAAC,aAAqB;QACzC,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,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CAAC,OAAO,CAAC,OAAO,CAAC,UAAU;qBAC/C;oBACD,MAAM,EAAE,KAAK;oBACb,MAAM,EAAE,KAAK;iBACd;aACF;SACF,CAAC;IACJ,CAAC;IAED,2BAA2B,CACzB,MAAwD;QAExD,OAAO,UAAU,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,oCAAoC;IAC5F,CAAC;IAED,0BAA0B,CACxB,KAA+D;QAE/D,IAAI,SAAS,GAAG,EAAE,CAAC;QACnB,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,QAAQ,EAAE;YAC/B,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,+BAA+B,EAAE,EAAE,CAAC,CAAC;YAEzE,IAAI,OAAO,EAAE;gBACX,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAElC,2CAA2C;gBAC3C,IAAI,IAAA,8BAAgB,EAAC,OAAO,CAAC,IAAI,CAAC,EAAE;oBAClC,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;iBAC9B;aACF;SACF;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AA5FD,kCA4FC","sourcesContent":["import {\n AccountGroupType,\n AccountWalletType,\n isBip44Account,\n toMultichainAccountGroupId,\n toMultichainAccountWalletId,\n} from '@metamask/account-api';\nimport { isEvmAccountType } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport type { AccountGroupObjectOf } from '../group';\nimport { BaseRule, type Rule, type RuleResult } from '../rule';\nimport type { AccountWalletObjectOf } from '../wallet';\n\nexport class EntropyRule\n extends BaseRule\n implements Rule<AccountWalletType.Entropy, AccountGroupType.MultichainAccount>\n{\n readonly walletType = AccountWalletType.Entropy;\n\n readonly groupType = AccountGroupType.MultichainAccount;\n\n getEntropySourceIndex(entropySource: string) {\n const { keyrings } = this.messenger.call('KeyringController:getState');\n\n return keyrings\n .filter((keyring) => keyring.type === (KeyringTypes.hd as string))\n .findIndex((keyring) => keyring.metadata.id === entropySource);\n }\n\n match(\n account: InternalAccount,\n ):\n | RuleResult<AccountWalletType.Entropy, AccountGroupType.MultichainAccount>\n | undefined {\n if (!isBip44Account(account)) {\n return undefined;\n }\n\n const entropySource = account.options.entropy.id;\n const entropySourceIndex = this.getEntropySourceIndex(entropySource);\n if (entropySourceIndex === -1) {\n console.warn(\n `! Found an unknown entropy ID: \"${entropySource}\", account \"${account.id}\" won't be grouped by entropy.`,\n );\n return undefined;\n }\n\n const walletId = toMultichainAccountWalletId(entropySource);\n const groupId = toMultichainAccountGroupId(\n walletId,\n account.options.entropy.groupIndex,\n );\n\n return {\n wallet: {\n type: this.walletType,\n id: walletId,\n metadata: {\n entropy: {\n id: entropySource,\n // QUESTION: Should we re-compute the index everytime instead?\n index: entropySourceIndex,\n },\n },\n },\n\n group: {\n type: this.groupType,\n id: groupId,\n metadata: {\n entropy: {\n groupIndex: account.options.entropy.groupIndex,\n },\n pinned: false,\n hidden: false,\n },\n },\n };\n }\n\n getDefaultAccountWalletName(\n wallet: AccountWalletObjectOf<AccountWalletType.Entropy>,\n ): string {\n return `Wallet ${wallet.metadata.entropy.index + 1}`; // Use human indexing (starts at 1).\n }\n\n getDefaultAccountGroupName(\n group: AccountGroupObjectOf<AccountGroupType.MultichainAccount>,\n ): string {\n let candidate = '';\n for (const id of group.accounts) {\n const account = this.messenger.call('AccountsController:getAccount', id);\n\n if (account) {\n candidate = account.metadata.name;\n\n // EVM account name has a highest priority.\n if (isEvmAccountType(account.type)) {\n return account.metadata.name;\n }\n }\n }\n\n return candidate;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"entropy.d.cts","sourceRoot":"","sources":["../../src/rules/entropy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EAIlB,8BAA8B;AAG/B,OAAO,KAAK,EAA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CAiBV"}
1
+ {"version":3,"file":"entropy.d.mts","sourceRoot":"","sources":["../../src/rules/entropy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EAIlB,8BAA8B;AAG/B,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAiB;AACrD,OAAO,EAAE,QAAQ,EAAE,KAAK,IAAI,EAAE,KAAK,UAAU,EAAE,oBAAgB;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAkB;AAEvD,qBAAa,WACX,SAAQ,QACR,YAAW,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,CAAC,iBAAiB,CAAC;IAE9E,QAAQ,CAAC,UAAU,6BAA6B;IAEhD,QAAQ,CAAC,SAAS,sCAAsC;IAExD,qBAAqB,CAAC,aAAa,EAAE,MAAM;IAQ3C,KAAK,CACH,OAAO,EAAE,eAAe,GAEtB,UAAU,CAAC,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,GACzE,SAAS;IA+Cb,2BAA2B,CACzB,MAAM,EAAE,qBAAqB,CAAC,iBAAiB,CAAC,OAAO,CAAC,GACvD,MAAM;IAIT,0BAA0B,CACxB,KAAK,EAAE,oBAAoB,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,GAC9D,MAAM;CAiBV"}
@@ -45,6 +45,8 @@ export class EntropyRule extends BaseRule {
45
45
  entropy: {
46
46
  groupIndex: account.options.entropy.groupIndex,
47
47
  },
48
+ pinned: false,
49
+ hidden: false,
48
50
  },
49
51
  },
50
52
  };
@@ -1 +1 @@
1
- {"version":3,"file":"entropy.mjs","sourceRoot":"","sources":["../../src/rules/entropy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,0BAA0B,EAC1B,2BAA2B,EAC5B,8BAA8B;AAC/B,OAAO,EAAE,gBAA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AAC,UAAU;gBACrB,EAAE,EAAE,QAAQ;gBACZ,QAAQ,EAAE;oBACR,OAAO,EAAE;wBACP,EAAE,EAAE,aAAa;wBACjB,8DAA8D;wBAC9D,KAAK,EAAE,kBAAkB;qBAC1B;iBACF;aACF;YAED,KAAK,EAAE;gBACL,IAAI,EAAE,IAAI,CAAC,SAAS;gBACpB,EAAE,EAAE,OAAO;gBACX,QAAQ,EAAE;oBACR,OAAO,EAAE;wBACP,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU;qBAC/C;iBACF;aACF;SACF,CAAC;IACJ,CAAC;IAED,2BAA2B,CACzB,MAAwD;QAExD,OAAO,UAAU,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,oCAAoC;IAC5F,CAAC;IAED,0BAA0B,CACxB,KAA+D;QAE/D,IAAI,SAAS,GAAG,EAAE,CAAC;QACnB,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,QAAQ,EAAE;YAC/B,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,+BAA+B,EAAE,EAAE,CAAC,CAAC;YAEzE,IAAI,OAAO,EAAE;gBACX,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAElC,2CAA2C;gBAC3C,IAAI,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;oBAClC,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;iBAC9B;aACF;SACF;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["import {\n AccountGroupType,\n AccountWalletType,\n isBip44Account,\n toMultichainAccountGroupId,\n toMultichainAccountWalletId,\n} from '@metamask/account-api';\nimport { isEvmAccountType } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport type { AccountGroupObjectOf } from '../group';\nimport { BaseRule, type Rule, type RuleResult } from '../rule';\nimport type { AccountWalletObjectOf } from '../wallet';\n\nexport class EntropyRule\n extends BaseRule\n implements Rule<AccountWalletType.Entropy, AccountGroupType.MultichainAccount>\n{\n readonly walletType = AccountWalletType.Entropy;\n\n readonly groupType = AccountGroupType.MultichainAccount;\n\n getEntropySourceIndex(entropySource: string) {\n const { keyrings } = this.messenger.call('KeyringController:getState');\n\n return keyrings\n .filter((keyring) => keyring.type === (KeyringTypes.hd as string))\n .findIndex((keyring) => keyring.metadata.id === entropySource);\n }\n\n match(\n account: InternalAccount,\n ):\n | RuleResult<AccountWalletType.Entropy, AccountGroupType.MultichainAccount>\n | undefined {\n if (!isBip44Account(account)) {\n return undefined;\n }\n\n const entropySource = account.options.entropy.id;\n const entropySourceIndex = this.getEntropySourceIndex(entropySource);\n if (entropySourceIndex === -1) {\n console.warn(\n `! Found an unknown entropy ID: \"${entropySource}\", account \"${account.id}\" won't be grouped by entropy.`,\n );\n return undefined;\n }\n\n const walletId = toMultichainAccountWalletId(entropySource);\n const groupId = toMultichainAccountGroupId(\n walletId,\n account.options.entropy.groupIndex,\n );\n\n return {\n wallet: {\n type: this.walletType,\n id: walletId,\n metadata: {\n entropy: {\n id: entropySource,\n // QUESTION: Should we re-compute the index everytime instead?\n index: entropySourceIndex,\n },\n },\n },\n\n group: {\n type: this.groupType,\n id: groupId,\n metadata: {\n entropy: {\n groupIndex: account.options.entropy.groupIndex,\n },\n },\n },\n };\n }\n\n getDefaultAccountWalletName(\n wallet: AccountWalletObjectOf<AccountWalletType.Entropy>,\n ): string {\n return `Wallet ${wallet.metadata.entropy.index + 1}`; // Use human indexing (starts at 1).\n }\n\n getDefaultAccountGroupName(\n group: AccountGroupObjectOf<AccountGroupType.MultichainAccount>,\n ): string {\n let candidate = '';\n for (const id of group.accounts) {\n const account = this.messenger.call('AccountsController:getAccount', id);\n\n if (account) {\n candidate = account.metadata.name;\n\n // EVM account name has a highest priority.\n if (isEvmAccountType(account.type)) {\n return account.metadata.name;\n }\n }\n }\n\n return candidate;\n }\n}\n"]}
1
+ {"version":3,"file":"entropy.mjs","sourceRoot":"","sources":["../../src/rules/entropy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,0BAA0B,EAC1B,2BAA2B,EAC5B,8BAA8B;AAC/B,OAAO,EAAE,gBAAgB,EAAE,8BAA8B;AACzD,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAI5D,OAAO,EAAE,QAAQ,EAA8B,oBAAgB;AAG/D,MAAM,OAAO,WACX,SAAQ,QAAQ;IADlB;;QAIW,eAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC;QAEvC,cAAS,GAAG,gBAAgB,CAAC,iBAAiB,CAAC;IAsF1D,CAAC;IApFC,qBAAqB,CAAC,aAAqB;QACzC,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QAEvE,OAAO,QAAQ;aACZ,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAM,YAAY,CAAC,EAAa,CAAC;aACjE,SAAS,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,KAAK,aAAa,CAAC,CAAC;IACnE,CAAC;IAED,KAAK,CACH,OAAwB;QAIxB,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE;YAC5B,OAAO,SAAS,CAAC;SAClB;QAED,MAAM,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACjD,MAAM,kBAAkB,GAAG,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC;QACrE,IAAI,kBAAkB,KAAK,CAAC,CAAC,EAAE;YAC7B,OAAO,CAAC,IAAI,CACV,mCAAmC,aAAa,eAAe,OAAO,CAAC,EAAE,gCAAgC,CAC1G,CAAC;YACF,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C9B;aACF;SACF;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["import {\n AccountGroupType,\n AccountWalletType,\n isBip44Account,\n toMultichainAccountGroupId,\n toMultichainAccountWalletId,\n} from '@metamask/account-api';\nimport { isEvmAccountType } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport type { AccountGroupObjectOf } from '../group';\nimport { BaseRule, type Rule, type RuleResult } from '../rule';\nimport type { AccountWalletObjectOf } from '../wallet';\n\nexport class EntropyRule\n extends BaseRule\n implements Rule<AccountWalletType.Entropy, AccountGroupType.MultichainAccount>\n{\n readonly walletType = AccountWalletType.Entropy;\n\n readonly groupType = AccountGroupType.MultichainAccount;\n\n getEntropySourceIndex(entropySource: string) {\n const { keyrings } = this.messenger.call('KeyringController:getState');\n\n return keyrings\n .filter((keyring) => keyring.type === (KeyringTypes.hd as string))\n .findIndex((keyring) => keyring.metadata.id === entropySource);\n }\n\n match(\n account: InternalAccount,\n ):\n | RuleResult<AccountWalletType.Entropy, AccountGroupType.MultichainAccount>\n | undefined {\n if (!isBip44Account(account)) {\n return undefined;\n }\n\n const entropySource = account.options.entropy.id;\n const entropySourceIndex = this.getEntropySourceIndex(entropySource);\n if (entropySourceIndex === -1) {\n console.warn(\n `! Found an unknown entropy ID: \"${entropySource}\", account \"${account.id}\" won't be grouped by entropy.`,\n );\n return undefined;\n }\n\n const walletId = toMultichainAccountWalletId(entropySource);\n const groupId = toMultichainAccountGroupId(\n walletId,\n account.options.entropy.groupIndex,\n );\n\n return {\n wallet: {\n type: this.walletType,\n id: walletId,\n metadata: {\n entropy: {\n id: entropySource,\n // QUESTION: Should we re-compute the index everytime instead?\n index: entropySourceIndex,\n },\n },\n },\n\n group: {\n type: this.groupType,\n id: groupId,\n metadata: {\n entropy: {\n groupIndex: account.options.entropy.groupIndex,\n },\n pinned: false,\n hidden: false,\n },\n },\n };\n }\n\n getDefaultAccountWalletName(\n wallet: AccountWalletObjectOf<AccountWalletType.Entropy>,\n ): string {\n return `Wallet ${wallet.metadata.entropy.index + 1}`; // Use human indexing (starts at 1).\n }\n\n getDefaultAccountGroupName(\n group: AccountGroupObjectOf<AccountGroupType.MultichainAccount>,\n ): string {\n let candidate = '';\n for (const id of group.accounts) {\n const account = this.messenger.call('AccountsController:getAccount', id);\n\n if (account) {\n candidate = account.metadata.name;\n\n // EVM account name has a highest priority.\n if (isEvmAccountType(account.type)) {\n return account.metadata.name;\n }\n }\n }\n\n return candidate;\n }\n}\n"]}
@@ -71,7 +71,10 @@ class KeyringRule extends rule_1.BaseRule {
71
71
  group: {
72
72
  type: this.groupType,
73
73
  id: groupId,
74
- metadata: {},
74
+ metadata: {
75
+ pinned: false,
76
+ hidden: false,
77
+ },
75
78
  },
76
79
  };
77
80
  }
@@ -1 +1 @@
1
- {"version":3,"file":"keyring.cjs","sourceRoot":"","sources":["../../src/rules/keyring.ts"],"names":[],"mappings":";;;AAAA,uDAAyD;AACzD,uDAA0D;AAC1D,uDAA4E;AAC5E,qEAA4D;AAI5D,sCAA+D;AAE/D;;;;;GAKG;AACH,SAAgB,mCAAmC,CAAC,IAAkB;IACpE,QAAQ,IAAI,EAAE;QACZ,KAAK,iCAAY,CAAC,MAAM,CAAC,CAAC;YACxB,OAAO,mBAAmB,CAAC;SAC5B;QACD,KAAK,iCAAY,CAAC,MAAM,CAAC,CAAC;YACxB,OAAO,QAAQ,CAAC;SACjB;QACD,KAAK,iCAAY,CAAC,MAAM,CAAC,CAAC;YACxB,OAAO,QAAQ,CAAC;SACjB;QACD,KAAK,iCAAY,CAAC,MAAM,CAAC,CAAC;YACxB,OAAO,QAAQ,CAAC;SACjB;QACD,KAAK,iCAAY,CAAC,OAAO,CAAC,CAAC;YACzB,OAAO,SAAS,CAAC;SAClB;QACD,KAAK,iCAAY,CAAC,EAAE,CAAC,CAAC;YACpB,OAAO,IAAI,CAAC;SACb;QACD,wEAAwE;QACxE,0CAA0C;QAC1C,KAAK,iCAAY,CAAC,EAAE,CAAC,CAAC;YACpB,OAAO,WAAW,CAAC;SACpB;QACD,KAAK,iCAAY,CAAC,IAAI,CAAC,CAAC;YACtB,OAAO,aAAa,CAAC;SACtB;QACD,2EAA2E;QAC3E,OAAO,CAAC,CAAC;YACP,OAAO,SAAS,CAAC;SAClB;KACF;AACH,CAAC;AAjCD,kFAiCC;AAED,MAAa,WACX,SAAQ,eAAQ;IADlB;;QAIW,eAAU,GAAG,+BAAiB,CAAC,OAAO,CAAC;QAEvC,cAAS,GAAG,8BAAgB,CAAC,aAAa,CAAC;IAoCtD,CAAC;IAlCC,KAAK,CACH,OAAwB;QAGxB,oDAAoD;QACpD,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAoB,CAAC;QAElE,MAAM,QAAQ,GAAG,IAAA,+BAAiB,EAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QACjE,MAAM,OAAO,GAAG,IAAA,8BAAgB,EAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAE5D,OAAO;YACL,MAAM,EAAE;gBACN,IAAI,EAAE,IAAI,CAAC,UAAU;gBACrB,EAAE,EAAE,QAAQ;gBACZ,QAAQ,EAAE;oBACR,OAAO,EAAE;wBACP,IAAI,EAAE,WAAW;qBAClB;iBACF;aACF;YAED,KAAK,EAAE;gBACL,IAAI,EAAE,IAAI,CAAC,SAAS;gBACpB,EAAE,EAAE,OAAO;gBACX,QAAQ,EAAE,EAAE;aACb;SACF,CAAC;IACJ,CAAC;IAED,2BAA2B,CACzB,MAAwD;QAExD,OAAO,mCAAmC,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3E,CAAC;CACF;AA1CD,kCA0CC","sourcesContent":["import { AccountGroupType } from '@metamask/account-api';\nimport { AccountWalletType } from '@metamask/account-api';\nimport { toAccountGroupId, toAccountWalletId } from '@metamask/account-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { AccountWalletObjectOf } from 'src/wallet';\n\nimport { BaseRule, type Rule, type RuleResult } from '../rule';\n\n/**\n * Get wallet name from a keyring type.\n *\n * @param type - Keyring's type.\n * @returns Wallet name.\n */\nexport function getAccountWalletNameFromKeyringType(type: KeyringTypes) {\n switch (type) {\n case KeyringTypes.simple: {\n return 'Imported accounts';\n }\n case KeyringTypes.trezor: {\n return 'Trezor';\n }\n case KeyringTypes.oneKey: {\n return 'OneKey';\n }\n case KeyringTypes.ledger: {\n return 'Ledger';\n }\n case KeyringTypes.lattice: {\n return 'Lattice';\n }\n case KeyringTypes.qr: {\n return 'QR';\n }\n // Those keyrings should never really be used in such context since they\n // should be used by other grouping rules.\n case KeyringTypes.hd: {\n return 'HD Wallet';\n }\n case KeyringTypes.snap: {\n return 'Snap Wallet';\n }\n // ------------------------------------------------------------------------\n default: {\n return 'Unknown';\n }\n }\n}\n\nexport class KeyringRule\n extends BaseRule\n implements Rule<AccountWalletType.Keyring, AccountGroupType.SingleAccount>\n{\n readonly walletType = AccountWalletType.Keyring;\n\n readonly groupType = AccountGroupType.SingleAccount;\n\n match(\n account: InternalAccount,\n // No `| undefined` return type for this rule, as it cannot fail.\n ): RuleResult<AccountWalletType.Keyring, AccountGroupType.SingleAccount> {\n // We assume that `type` is really a `KeyringTypes`.\n const keyringType = account.metadata.keyring.type as KeyringTypes;\n\n const walletId = toAccountWalletId(this.walletType, keyringType);\n const groupId = toAccountGroupId(walletId, account.address);\n\n return {\n wallet: {\n type: this.walletType,\n id: walletId,\n metadata: {\n keyring: {\n type: keyringType,\n },\n },\n },\n\n group: {\n type: this.groupType,\n id: groupId,\n metadata: {},\n },\n };\n }\n\n getDefaultAccountWalletName(\n wallet: AccountWalletObjectOf<AccountWalletType.Keyring>,\n ): string {\n return getAccountWalletNameFromKeyringType(wallet.metadata.keyring.type);\n }\n}\n"]}
1
+ {"version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AC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QACjE,MAAM,OAAO,GAAG,IAAA,8BAAgB,EAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAE5D,OAAO;YACL,MAAM,EAAE;gBACN,IAAI,EAAE,IAAI,CAAC,UAAU;gBACrB,EAAE,EAAE,QAAQ;gBACZ,QAAQ,EAAE;oBACR,OAAO,EAAE;wBACP,IAAI,EAAE,WAAW;qBAClB;iBACF;aACF;YAED,KAAK,EAAE;gBACL,IAAI,EAAE,IAAI,CAAC,SAAS;gBACpB,EAAE,EAAE,OAAO;gBACX,QAAQ,EAAE;oBACR,MAAM,EAAE,KAAK;oBACb,MAAM,EAAE,KAAK;iBACd;aACF;SACF,CAAC;IACJ,CAAC;IAED,2BAA2B,CACzB,MAAwD;QAExD,OAAO,mCAAmC,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3E,CAAC;CACF;AA7CD,kCA6CC","sourcesContent":["import { AccountGroupType } from '@metamask/account-api';\nimport { AccountWalletType } from '@metamask/account-api';\nimport { toAccountGroupId, toAccountWalletId } from '@metamask/account-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { AccountWalletObjectOf } from 'src/wallet';\n\nimport { BaseRule, type Rule, type RuleResult } from '../rule';\n\n/**\n * Get wallet name from a keyring type.\n *\n * @param type - Keyring's type.\n * @returns Wallet name.\n */\nexport function getAccountWalletNameFromKeyringType(type: KeyringTypes) {\n switch (type) {\n case KeyringTypes.simple: {\n return 'Imported accounts';\n }\n case KeyringTypes.trezor: {\n return 'Trezor';\n }\n case KeyringTypes.oneKey: {\n return 'OneKey';\n }\n case KeyringTypes.ledger: {\n return 'Ledger';\n }\n case KeyringTypes.lattice: {\n return 'Lattice';\n }\n case KeyringTypes.qr: {\n return 'QR';\n }\n // Those keyrings should never really be used in such context since they\n // should be used by other grouping rules.\n case KeyringTypes.hd: {\n return 'HD Wallet';\n }\n case KeyringTypes.snap: {\n return 'Snap Wallet';\n }\n // ------------------------------------------------------------------------\n default: {\n return 'Unknown';\n }\n }\n}\n\nexport class KeyringRule\n extends BaseRule\n implements Rule<AccountWalletType.Keyring, AccountGroupType.SingleAccount>\n{\n readonly walletType = AccountWalletType.Keyring;\n\n readonly groupType = AccountGroupType.SingleAccount;\n\n match(\n account: InternalAccount,\n // No `| undefined` return type for this rule, as it cannot fail.\n ): RuleResult<AccountWalletType.Keyring, AccountGroupType.SingleAccount> {\n // We assume that `type` is really a `KeyringTypes`.\n const keyringType = account.metadata.keyring.type as KeyringTypes;\n\n const walletId = toAccountWalletId(this.walletType, keyringType);\n const groupId = toAccountGroupId(walletId, account.address);\n\n return {\n wallet: {\n type: this.walletType,\n id: walletId,\n metadata: {\n keyring: {\n type: keyringType,\n },\n },\n },\n\n group: {\n type: this.groupType,\n id: groupId,\n metadata: {\n pinned: false,\n hidden: false,\n },\n },\n };\n }\n\n getDefaultAccountWalletName(\n wallet: AccountWalletObjectOf<AccountWalletType.Keyring>,\n ): string {\n return getAccountWalletNameFromKeyringType(wallet.metadata.keyring.type);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"keyring.d.cts","sourceRoot":"","sources":["../../src/rules/keyring.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,8BAA8B;AACzD,OAAO,EAAE,iBAAiB,EAAE,8BAA8B;AAE1D,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,mBAAmB;AAExD,OAAO,EAAE,QAAQ,EAAE,KAAK,IAAI,EAAE,KAAK,UAAU,EAAE,oBAAgB;AAE/D;;;;;GAKG;AACH,wBAAgB,mCAAmC,CAAC,IAAI,EAAE,YAAY,qHAiCrE;AAED,qBAAa,WACX,SAAQ,QACR,YAAW,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,CAAC,aAAa,CAAC;IAE1E,QAAQ,CAAC,UAAU,6BAA6B;IAEhD,QAAQ,CAAC,SAAS,kCAAkC;IAEpD,KAAK,CACH,OAAO,EAAE,eAAe,GAEvB,UAAU,CAAC,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,CAAC,aAAa,CAAC;IA0BxE,2BAA2B,CACzB,MAAM,EAAE,qBAAqB,CAAC,iBAAiB,CAAC,OAAO,CAAC,GACvD,MAAM;CAGV"}
1
+ {"version":3,"file":"keyring.d.cts","sourceRoot":"","sources":["../../src/rules/keyring.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,8BAA8B;AACzD,OAAO,EAAE,iBAAiB,EAAE,8BAA8B;AAE1D,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,mBAAmB;AAExD,OAAO,EAAE,QAAQ,EAAE,KAAK,IAAI,EAAE,KAAK,UAAU,EAAE,oBAAgB;AAE/D;;;;;GAKG;AACH,wBAAgB,mCAAmC,CAAC,IAAI,EAAE,YAAY,qHAiCrE;AAED,qBAAa,WACX,SAAQ,QACR,YAAW,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,CAAC,aAAa,CAAC;IAE1E,QAAQ,CAAC,UAAU,6BAA6B;IAEhD,QAAQ,CAAC,SAAS,kCAAkC;IAEpD,KAAK,CACH,OAAO,EAAE,eAAe,GAEvB,UAAU,CAAC,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,CAAC,aAAa,CAAC;IA6BxE,2BAA2B,CACzB,MAAM,EAAE,qBAAqB,CAAC,iBAAiB,CAAC,OAAO,CAAC,GACvD,MAAM;CAGV"}
@@ -1 +1 @@
1
- {"version":3,"file":"keyring.d.mts","sourceRoot":"","sources":["../../src/rules/keyring.ts"],"names":[],"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AiB,CAAC,OAAO,EAAE,gBAAgB,CAAC,aAAa,CAAC;IAE1E,QAAQ,CAAC,UAAU,6BAA6B;IAEhD,QAAQ,CAAC,SAAS,kCAAkC;IAEpD,KAAK,CACH,OAAO,EAAE,eAAe,GAEvB,UAAU,CAAC,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,CAAC,aAAa,CAAC;IA6BxE,2BAA2B,CACzB,MAAM,EAAE,qBAAqB,CAAC,iBAAiB,CAAC,OAAO,CAAC,GACvD,MAAM;CAGV"}
@@ -67,7 +67,10 @@ export class KeyringRule extends BaseRule {
67
67
  group: {
68
68
  type: this.groupType,
69
69
  id: groupId,
70
- metadata: {},
70
+ metadata: {
71
+ pinned: false,
72
+ hidden: false,
73
+ },
71
74
  },
72
75
  };
73
76
  }
@@ -1 +1 @@
1
- {"version":3,"file":"keyring.mjs","sourceRoot":"","sources":["../../src/rules/keyring.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,8BAA8B;AACzD,OAAO,EAAE,iBAAiB,EAAE,8BAA8B;AAC1D,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,8BAA8B;AAC5E,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAI5D,OAAO,EAAE,QAAQ,EAA8B,oBAAgB;AAE/D;;;;;GAKG;AACH,MAAM,UAAU,mCAAmC,CAAC,IAAkB;IACpE,QAAQ,IAAI,EAAE;QACZ,KAAK,YAAY,CAAC,MAAM,CAAC,CAAC;YACxB,OAAO,mBAAmB,CAAC;SAC5B;QACD,KAAK,YAAY,CAAC,MAAM,CAAC,CAAC;YACxB,OAAO,QAAQ,CAAC;SACjB;QACD,KAAK,YAAY,CAAC,MAAM,CAAC,CAAC;YACxB,OAAO,QAAQ,CAAC;SACjB;QACD,KAAK,YAAY,CAAC,MAAM,CAAC,CAAC;YACxB,OAAO,QAAQ,CAAC;SACjB;QACD,KAAK,YAAY,CAAC,OAAO,CAAC,CAAC;YACzB,OAAO,SAAS,CAA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AccountWalletType } from '@metamask/account-api';\nimport { toAccountGroupId, toAccountWalletId } from '@metamask/account-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { AccountWalletObjectOf } from 'src/wallet';\n\nimport { BaseRule, type Rule, type RuleResult } from '../rule';\n\n/**\n * Get wallet name from a keyring type.\n *\n * @param type - Keyring's type.\n * @returns Wallet name.\n */\nexport function getAccountWalletNameFromKeyringType(type: KeyringTypes) {\n switch (type) {\n case KeyringTypes.simple: {\n return 'Imported accounts';\n }\n case KeyringTypes.trezor: {\n return 'Trezor';\n }\n case KeyringTypes.oneKey: {\n return 'OneKey';\n }\n case KeyringTypes.ledger: {\n return 'Ledger';\n }\n case KeyringTypes.lattice: {\n return 'Lattice';\n }\n case KeyringTypes.qr: {\n return 'QR';\n }\n // Those keyrings should never really be used in such context since they\n // should be used by other grouping rules.\n case KeyringTypes.hd: {\n return 'HD Wallet';\n }\n case KeyringTypes.snap: {\n return 'Snap Wallet';\n }\n // ------------------------------------------------------------------------\n default: {\n return 'Unknown';\n }\n }\n}\n\nexport class KeyringRule\n extends BaseRule\n implements Rule<AccountWalletType.Keyring, AccountGroupType.SingleAccount>\n{\n readonly walletType = AccountWalletType.Keyring;\n\n readonly groupType = AccountGroupType.SingleAccount;\n\n match(\n account: InternalAccount,\n // No `| undefined` return type for this rule, as it cannot fail.\n ): RuleResult<AccountWalletType.Keyring, AccountGroupType.SingleAccount> {\n // We assume that `type` is really a `KeyringTypes`.\n const keyringType = account.metadata.keyring.type as KeyringTypes;\n\n const walletId = toAccountWalletId(this.walletType, keyringType);\n const groupId = toAccountGroupId(walletId, account.address);\n\n return {\n wallet: {\n type: this.walletType,\n id: walletId,\n metadata: {\n keyring: {\n type: keyringType,\n },\n },\n },\n\n group: {\n type: this.groupType,\n id: groupId,\n metadata: {},\n },\n };\n }\n\n getDefaultAccountWalletName(\n wallet: AccountWalletObjectOf<AccountWalletType.Keyring>,\n ): string {\n return getAccountWalletNameFromKeyringType(wallet.metadata.keyring.type);\n }\n}\n"]}
1
+ {"version":3,"file":"keyring.mjs","sourceRoot":"","sources":["../../src/rules/keyring.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,8BAA8B;AACzD,OAAO,EAAE,iBAAiB,EAAE,8BAA8B;AAC1D,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,8BAA8B;AAC5E,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAI5D,OAAO,EAAE,QAAQ,EAA8B,oBAAgB;AAE/D;;;;;GAKG;AACH,MAAM,UAAU,mCAAmC,CAAC,IAAkB;IACpE,QAAQ,IAAI,EAAE;QACZ,KAAK,YAAY,CAAC,MAAM,CAAC,CAAC;YACxB,OAAO,mBAAmB,CAAC;SAC5B;QACD,KAAK,YAAY,CAAC,MAAM,CAAC,CAAC;YACxB,OAAO,QAAQ,CAAC;SACjB;QACD,KAAK,YAAY,CAAC,MAAM,CAAC,CAAC;YACxB,OAAO,QAAQ,CAAC;SACjB;QACD,KAAK,YAAY,CAAC,MAAM,CAAC,CAAC;YACxB,OAAO,QAAQ,CAAC;SACjB;QACD,KAAK,YAAY,CAAC,OAAO,CAAC,CAAC;YACzB,OAAO,SAAS,CAAC;SAClB;QACD,KAAK,YAAY,CAAC,EAAE,CAAC,CAAC;YACpB,OAAO,IAAI,CAAC;SACb;QACD,wEAAwE;QACxE,0CAA0C;QAC1C,KAAK,YAAY,CAAC,EAAE,CAAC,CAAC;YACpB,OAAO,WAAW,CAAC;SACpB;QACD,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;YACtB,OAAO,aAAa,CAAC;SACtB;QACD,2EAA2E;QAC3E,OAAO,CAAC,CAAC;YACP,OAAO,SAAS,CAAC;SAClB;KACF;AACH,CAAC;AAED,MAAM,OAAO,WACX,SAAQ,QAAQ;IADlB;;QAIW,eAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC;QAEvC,cAAS,GAAG,gBAAgB,CAAC,aAAa,CAAC;IAuCtD,CAAC;IArCC,KAAK,CACH,OAAwB;QAGxB,oDAAoD;QACpD,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAoB,CAAC;QAElE,MAAM,QAAQ,GAAG,iBAAiB,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QACjE,MAAM,OAAO,GAAG,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAE5D,OAAO;YACL,MAAM,EAAE;gBACN,IAAI,EAAE,IAAI,CAAC,UAAU;gBACrB,EAAE,EAAE,QAAQ;gBACZ,QAAQ,EAAE;oBACR,OAAO,EAAE;wBACP,IAAI,EAAE,WAAW;qBAClB;iBACF;aACF;YAED,KAAK,EAAE;gBACL,IAAI,EAAE,IAAI,CAAC,SAAS;gBACpB,EAAE,EAAE,OAAO;gBACX,QAAQ,EAAE;oBACR,MAAM,EAAE,KAAK;oBACb,MAAM,EAAE,KAAK;iBACd;aACF;SACF,CAAC;IACJ,CAAC;IAED,2BAA2B,CACzB,MAAwD;QAExD,OAAO,mCAAmC,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3E,CAAC;CACF","sourcesContent":["import { AccountGroupType } from '@metamask/account-api';\nimport { AccountWalletType } from '@metamask/account-api';\nimport { toAccountGroupId, toAccountWalletId } from '@metamask/account-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { AccountWalletObjectOf } from 'src/wallet';\n\nimport { BaseRule, type Rule, type RuleResult } from '../rule';\n\n/**\n * Get wallet name from a keyring type.\n *\n * @param type - Keyring's type.\n * @returns Wallet name.\n */\nexport function getAccountWalletNameFromKeyringType(type: KeyringTypes) {\n switch (type) {\n case KeyringTypes.simple: {\n return 'Imported accounts';\n }\n case KeyringTypes.trezor: {\n return 'Trezor';\n }\n case KeyringTypes.oneKey: {\n return 'OneKey';\n }\n case KeyringTypes.ledger: {\n return 'Ledger';\n }\n case KeyringTypes.lattice: {\n return 'Lattice';\n }\n case KeyringTypes.qr: {\n return 'QR';\n }\n // Those keyrings should never really be used in such context since they\n // should be used by other grouping rules.\n case KeyringTypes.hd: {\n return 'HD Wallet';\n }\n case KeyringTypes.snap: {\n return 'Snap Wallet';\n }\n // ------------------------------------------------------------------------\n default: {\n return 'Unknown';\n }\n }\n}\n\nexport class KeyringRule\n extends BaseRule\n implements Rule<AccountWalletType.Keyring, AccountGroupType.SingleAccount>\n{\n readonly walletType = AccountWalletType.Keyring;\n\n readonly groupType = AccountGroupType.SingleAccount;\n\n match(\n account: InternalAccount,\n // No `| undefined` return type for this rule, as it cannot fail.\n ): RuleResult<AccountWalletType.Keyring, AccountGroupType.SingleAccount> {\n // We assume that `type` is really a `KeyringTypes`.\n const keyringType = account.metadata.keyring.type as KeyringTypes;\n\n const walletId = toAccountWalletId(this.walletType, keyringType);\n const groupId = toAccountGroupId(walletId, account.address);\n\n return {\n wallet: {\n type: this.walletType,\n id: walletId,\n metadata: {\n keyring: {\n type: keyringType,\n },\n },\n },\n\n group: {\n type: this.groupType,\n id: groupId,\n metadata: {\n pinned: false,\n hidden: false,\n },\n },\n };\n }\n\n getDefaultAccountWalletName(\n wallet: AccountWalletObjectOf<AccountWalletType.Keyring>,\n ): string {\n return getAccountWalletNameFromKeyringType(wallet.metadata.keyring.type);\n }\n}\n"]}
@@ -43,7 +43,10 @@ class SnapRule extends rule_1.BaseRule {
43
43
  group: {
44
44
  type: this.groupType,
45
45
  id: groupId,
46
- metadata: {},
46
+ metadata: {
47
+ pinned: false,
48
+ hidden: false,
49
+ },
47
50
  },
48
51
  };
49
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"snap.cjs","sourceRoot":"","sources":["../../src/rules/snap.ts"],"names":[],"mappings":";;;AAAA,uDAA4E;AAC5E,uDAA4E;AAC5E,qEAA4D;AAG5D,uDAAwD;AAExD,sC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,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;QAC/D,MAAM,QAAQ,GAAG,IAAI;YACnB,CAAC,CAAC,oGAAoG;gBACpG,eAAe;gBACf,IAAI,CAAC,QAAQ,CAAC,YAAY;YAC5B,CAAC,CAAC,IAAA,6BAAe,EAAC,MAAM,CAAC,CAAC;QAE5B,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAtDD,4BAsDC","sourcesContent":["import { AccountGroupType, AccountWalletType } from '@metamask/account-api';\nimport { toAccountWalletId, toAccountGroupId } from '@metamask/account-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { stripSnapPrefix } from '@metamask/snaps-utils';\n\nimport { BaseRule, type Rule, type RuleResult } from '../rule';\nimport type { AccountWalletObjectOf } from '../wallet';\n\n/**\n * Snap account type.\n */\ntype SnapAccount<Account extends InternalAccount> = Account & {\n metadata: Account['metadata'] & {\n snap: {\n id: SnapId;\n };\n };\n};\n\n/**\n * Check if an account is a Snap account.\n *\n * @param account - The account to check.\n * @returns True if the account is a Snap account, false otherwise.\n */\nfunction isSnapAccount(\n account: InternalAccount,\n): account is SnapAccount<InternalAccount> {\n return (\n account.metadata.keyring.type === (KeyringTypes.snap as string) &&\n account.metadata.snap !== undefined &&\n account.metadata.snap.enabled\n );\n}\n\nexport class SnapRule\n extends BaseRule\n implements Rule<AccountWalletType.Snap, AccountGroupType.SingleAccount>\n{\n readonly walletType = AccountWalletType.Snap;\n\n readonly groupType = AccountGroupType.SingleAccount;\n\n match(\n account: InternalAccount,\n ):\n | RuleResult<AccountWalletType.Snap, AccountGroupType.SingleAccount>\n | undefined {\n if (!isSnapAccount(account)) {\n return undefined;\n }\n\n const { id: snapId } = account.metadata.snap;\n\n const walletId = toAccountWalletId(this.walletType, snapId);\n const groupId = toAccountGroupId(walletId, account.address);\n\n return {\n wallet: {\n type: this.walletType,\n id: walletId,\n metadata: {\n snap: {\n id: snapId,\n },\n },\n },\n\n group: {\n type: this.groupType,\n id: groupId,\n metadata: {},\n },\n };\n }\n\n getDefaultAccountWalletName(\n wallet: AccountWalletObjectOf<AccountWalletType.Snap>,\n ): string {\n const snapId = wallet.metadata.snap.id;\n const snap = this.messenger.call('SnapController:get', snapId);\n const snapName = snap\n ? // TODO: Handle localization here, but that's a \"client thing\", so we don't have a `core` controller\n // to refer to.\n snap.manifest.proposedName\n : stripSnapPrefix(snapId);\n\n return snapName;\n }\n}\n"]}
1
+ {"version":3,"file":"snap.cjs","sourceRoot":"","sources":["../../src/rules/snap.ts"],"names":[],"mappings":";;;AAAA,uDAA4E;AAC5E,uDAA4E;AAC5E,qEAA4D;AAG5D,uDAAwD;AAExD,sCAA+D;AAc/D;;;;;GAKG;AACH,SAAS,aAAa,CACpB,OAAwB;IAExB,OAAO,CACL,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAM,iCAAY,CAAC,IAAe;QAC/D,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS;QACnC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAC9B,CAAC;AACJ,CAAC;AAED,MAAa,QACX,SAAQ,eAAQ;IADlB;;QAIW,eAAU,GAAG,+BAAiB,CAAC,IAAI,CAAC;QAEpC,cAAS,GAAG,8BAAgB,CAAC,aAAa,CAAC;IAmDtD,CAAC;IAjDC,KAAK,CACH,OAAwB;QAIxB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE;YAC3B,OAAO,SAAS,CAAC;SAClB;QAED,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;QAE7C,MAAM,QAAQ,GAAG,IAAA,+BAAiB,EAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC5D,MAAM,OAAO,GAAG,IAAA,8BAAgB,EAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAE5D,OAAO;YACL,MAAM,EAAE;gBACN,IAAI,EAAE,IAAI,CAAC,UAAU;gBACrB,EAAE,EAAE,QAAQ;gBACZ,QAAQ,EAAE;oBACR,IAAI,EAAE;wBACJ,EAAE,EAAE,MAAM;qBACX;iBACF;aACF;YAED,KAAK,EAAE;gBACL,IAAI,EAAE,IAAI,CAAC,SAAS;gBACpB,EAAE,EAAE,OAAO;gBACX,QAAQ,EAAE;oBACR,MAAM,EAAE,KAAK;oBACb,MAAM,EAAE,KAAK;iBACd;aACF;SACF,CAAC;IACJ,CAAC;IAED,2BAA2B,CACzB,MAAqD;QAErD,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;QAC/D,MAAM,QAAQ,GAAG,IAAI;YACnB,CAAC,CAAC,oGAAoG;gBACpG,eAAe;gBACf,IAAI,CAAC,QAAQ,CAAC,YAAY;YAC5B,CAAC,CAAC,IAAA,6BAAe,EAAC,MAAM,CAAC,CAAC;QAE5B,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAzDD,4BAyDC","sourcesContent":["import { AccountGroupType, AccountWalletType } from '@metamask/account-api';\nimport { toAccountWalletId, toAccountGroupId } from '@metamask/account-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { stripSnapPrefix } from '@metamask/snaps-utils';\n\nimport { BaseRule, type Rule, type RuleResult } from '../rule';\nimport type { AccountWalletObjectOf } from '../wallet';\n\n/**\n * Snap account type.\n */\ntype SnapAccount<Account extends InternalAccount> = Account & {\n metadata: Account['metadata'] & {\n snap: {\n id: SnapId;\n };\n };\n};\n\n/**\n * Check if an account is a Snap account.\n *\n * @param account - The account to check.\n * @returns True if the account is a Snap account, false otherwise.\n */\nfunction isSnapAccount(\n account: InternalAccount,\n): account is SnapAccount<InternalAccount> {\n return (\n account.metadata.keyring.type === (KeyringTypes.snap as string) &&\n account.metadata.snap !== undefined &&\n account.metadata.snap.enabled\n );\n}\n\nexport class SnapRule\n extends BaseRule\n implements Rule<AccountWalletType.Snap, AccountGroupType.SingleAccount>\n{\n readonly walletType = AccountWalletType.Snap;\n\n readonly groupType = AccountGroupType.SingleAccount;\n\n match(\n account: InternalAccount,\n ):\n | RuleResult<AccountWalletType.Snap, AccountGroupType.SingleAccount>\n | undefined {\n if (!isSnapAccount(account)) {\n return undefined;\n }\n\n const { id: snapId } = account.metadata.snap;\n\n const walletId = toAccountWalletId(this.walletType, snapId);\n const groupId = toAccountGroupId(walletId, account.address);\n\n return {\n wallet: {\n type: this.walletType,\n id: walletId,\n metadata: {\n snap: {\n id: snapId,\n },\n },\n },\n\n group: {\n type: this.groupType,\n id: groupId,\n metadata: {\n pinned: false,\n hidden: false,\n },\n },\n };\n }\n\n getDefaultAccountWalletName(\n wallet: AccountWalletObjectOf<AccountWalletType.Snap>,\n ): string {\n const snapId = wallet.metadata.snap.id;\n const snap = this.messenger.call('SnapController:get', snapId);\n const snapName = snap\n ? // TODO: Handle localization here, but that's a \"client thing\", so we don't have a `core` controller\n // to refer to.\n snap.manifest.proposedName\n : stripSnapPrefix(snapId);\n\n return snapName;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"snap.d.cts","sourceRoot":"","sources":["../../src/rules/snap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,8BAA8B;AAG5E,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAItE,OAAO,EAAE,QAAQ,EAAE,KAAK,IAAI,EAAE,KAAK,UAAU,EAAE,oBAAgB;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAkB;AA6BvD,qBAAa,QACX,SAAQ,QACR,YAAW,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,gBAAgB,CAAC,aAAa,CAAC;IAEvE,QAAQ,CAAC,UAAU,0BAA0B;IAE7C,QAAQ,CAAC,SAAS,kCAAkC;IAEpD,KAAK,CACH,OAAO,EAAE,eAAe,GAEtB,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,gBAAgB,CAAC,aAAa,CAAC,GAClE,SAAS;IA6Bb,2BAA2B,CACzB,MAAM,EAAE,qBAAqB,CAAC,iBAAiB,CAAC,IAAI,CAAC,GACpD,MAAM;CAWV"}
1
+ {"version":3,"file":"snap.d.cts","sourceRoot":"","sources":["../../src/rules/snap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,8BAA8B;AAG5E,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAItE,OAAO,EAAE,QAAQ,EAAE,KAAK,IAAI,EAAE,KAAK,UAAU,EAAE,oBAAgB;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAkB;AA6BvD,qBAAa,QACX,SAAQ,QACR,YAAW,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,gBAAgB,CAAC,aAAa,CAAC;IAEvE,QAAQ,CAAC,UAAU,0BAA0B;IAE7C,QAAQ,CAAC,SAAS,kCAAkC;IAEpD,KAAK,CACH,OAAO,EAAE,eAAe,GAEtB,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,gBAAgB,CAAC,aAAa,CAAC,GAClE,SAAS;IAgCb,2BAA2B,CACzB,MAAM,EAAE,qBAAqB,CAAC,iBAAiB,CAAC,IAAI,CAAC,GACpD,MAAM;CAWV"}
@@ -1 +1 @@
1
- {"version":3,"file":"snap.d.mts","sourceRoot":"","sources":["../../src/rules/snap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,8BAA8B;AAG5E,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAItE,OAAO,EAAE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41
41
  type: this.groupType,
42
42
  id: groupId,
43
- metadata: {},
43
+ metadata: {
44
+ pinned: false,
45
+ hidden: false,
46
+ },
44
47
  },
45
48
  };
46
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"snap.mjs","sourceRoot":"","sources":["../../src/rules/snap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,8BAA8B;AAC5E,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,8BAA8B;AAC5E,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAG5D,OAAO,EAAE,eAAe,EAAE,8BAA8B;AAExD,OAAO,EAAE,QAAQ,EAA8B,oBAAgB;AAc/D;;;;;GAKG;AACH,SAAS,aAAa,CACpB,OAAwB;IAExB,OAAO,CACL,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAM,YAAY,CAAC,IAAe;QAC/D,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS;QACnC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAC9B,CAAC;AACJ,CAAC;AAED,MAAM,OAAO,QACX,SAAQ,QAAQ;IADlB;;QAIW,eAAU,GAAG,iBAAiB,CAAC,IAAI,CAAC;QAEpC,cAAS,GAAG,gBAAgB,CAAC,aAAa,CAAC;IAgDtD,CAAC;IA9CC,KAAK,CACH,OAAwB;QAIxB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE;YAC3B,OAAO,SAAS,CAAC;SAClB;QAED,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;QAE7C,MAAM,QAAQ,GAAG,iBAAiB,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC5D,MAAM,OAAO,GAAG,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAE5D,OAAO;YACL,MAAM,EAAE;gBACN,IAAI,EAAE,IAAI,CAAC,UAAU;gBACrB,EAAE,EAAE,QAAQ;gBACZ,QAAQ,EAAE;oBACR,IAAI,EAAE;wBACJ,EAAE,EAAE,MAAM;qBACX;iBACF;aACF;YAED,KAAK,EAAE;gBACL,IAAI,EAAE,IAAI,CAAC,SAAS;gBACpB,EAAE,EAAE,OAAO;gBACX,QAAQ,EAAE,EAAE;aACb;SACF,CAAC;IACJ,CAAC;IAED,2BAA2B,CACzB,MAAqD;QAErD,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;QAC/D,MAAM,QAAQ,GAAG,IAAI;YACnB,CAAC,CAAC,oGAAoG;gBACpG,eAAe;gBACf,IAAI,CAAC,QAAQ,CAAC,YAAY;YAC5B,CAAC,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QAE5B,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF","sourcesContent":["import { AccountGroupType, AccountWalletType } from '@metamask/account-api';\nimport { toAccountWalletId, toAccountGroupId } from '@metamask/account-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { stripSnapPrefix } from '@metamask/snaps-utils';\n\nimport { BaseRule, type Rule, type RuleResult } from '../rule';\nimport type { AccountWalletObjectOf } from '../wallet';\n\n/**\n * Snap account type.\n */\ntype SnapAccount<Account extends InternalAccount> = Account & {\n metadata: Account['metadata'] & {\n snap: {\n id: SnapId;\n };\n };\n};\n\n/**\n * Check if an account is a Snap account.\n *\n * @param account - The account to check.\n * @returns True if the account is a Snap account, false otherwise.\n */\nfunction isSnapAccount(\n account: InternalAccount,\n): account is SnapAccount<InternalAccount> {\n return (\n account.metadata.keyring.type === (KeyringTypes.snap as string) &&\n account.metadata.snap !== undefined &&\n account.metadata.snap.enabled\n );\n}\n\nexport class SnapRule\n extends BaseRule\n implements Rule<AccountWalletType.Snap, AccountGroupType.SingleAccount>\n{\n readonly walletType = AccountWalletType.Snap;\n\n readonly groupType = AccountGroupType.SingleAccount;\n\n match(\n account: InternalAccount,\n ):\n | RuleResult<AccountWalletType.Snap, AccountGroupType.SingleAccount>\n | undefined {\n if (!isSnapAccount(account)) {\n return undefined;\n }\n\n const { id: snapId } = account.metadata.snap;\n\n const walletId = toAccountWalletId(this.walletType, snapId);\n const groupId = toAccountGroupId(walletId, account.address);\n\n return {\n wallet: {\n type: this.walletType,\n id: walletId,\n metadata: {\n snap: {\n id: snapId,\n },\n },\n },\n\n group: {\n type: this.groupType,\n id: groupId,\n metadata: {},\n },\n };\n }\n\n getDefaultAccountWalletName(\n wallet: AccountWalletObjectOf<AccountWalletType.Snap>,\n ): string {\n const snapId = wallet.metadata.snap.id;\n const snap = this.messenger.call('SnapController:get', snapId);\n const snapName = snap\n ? // TODO: Handle localization here, but that's a \"client thing\", so we don't have a `core` controller\n // to refer to.\n snap.manifest.proposedName\n : stripSnapPrefix(snapId);\n\n return snapName;\n }\n}\n"]}
1
+ {"version":3,"file":"snap.mjs","sourceRoot":"","sources":["../../src/rules/snap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,8BAA8B;AAC5E,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,8BAA8B;AAC5E,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAG5D,OAAO,EAAE,eAAe,EAAE,8BAA8B;AAExD,OAAO,EAAE,QAAQ,EAA8B,oBAAgB;AAc/D;;;;;GAKG;AACH,SAAS,aAAa,CACpB,OAAwB;IAExB,OAAO,CACL,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAM,YAAY,CAAC,IAAe;QAC/D,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS;QACnC,OAAO,CAAC,QA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eAAe,CAAC,MAAM,CAAC,CAAC;QAE5B,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF","sourcesContent":["import { AccountGroupType, AccountWalletType } from '@metamask/account-api';\nimport { toAccountWalletId, toAccountGroupId } from '@metamask/account-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { stripSnapPrefix } from '@metamask/snaps-utils';\n\nimport { BaseRule, type Rule, type RuleResult } from '../rule';\nimport type { AccountWalletObjectOf } from '../wallet';\n\n/**\n * Snap account type.\n */\ntype SnapAccount<Account extends InternalAccount> = Account & {\n metadata: Account['metadata'] & {\n snap: {\n id: SnapId;\n };\n };\n};\n\n/**\n * Check if an account is a Snap account.\n *\n * @param account - The account to check.\n * @returns True if the account is a Snap account, false otherwise.\n */\nfunction isSnapAccount(\n account: InternalAccount,\n): account is SnapAccount<InternalAccount> {\n return (\n account.metadata.keyring.type === (KeyringTypes.snap as string) &&\n account.metadata.snap !== undefined &&\n account.metadata.snap.enabled\n );\n}\n\nexport class SnapRule\n extends BaseRule\n implements Rule<AccountWalletType.Snap, AccountGroupType.SingleAccount>\n{\n readonly walletType = AccountWalletType.Snap;\n\n readonly groupType = AccountGroupType.SingleAccount;\n\n match(\n account: InternalAccount,\n ):\n | RuleResult<AccountWalletType.Snap, AccountGroupType.SingleAccount>\n | undefined {\n if (!isSnapAccount(account)) {\n return undefined;\n }\n\n const { id: snapId } = account.metadata.snap;\n\n const walletId = toAccountWalletId(this.walletType, snapId);\n const groupId = toAccountGroupId(walletId, account.address);\n\n return {\n wallet: {\n type: this.walletType,\n id: walletId,\n metadata: {\n snap: {\n id: snapId,\n },\n },\n },\n\n group: {\n type: this.groupType,\n id: groupId,\n metadata: {\n pinned: false,\n hidden: false,\n },\n },\n };\n }\n\n getDefaultAccountWalletName(\n wallet: AccountWalletObjectOf<AccountWalletType.Snap>,\n ): string {\n const snapId = wallet.metadata.snap.id;\n const snap = this.messenger.call('SnapController:get', snapId);\n const snapName = snap\n ? // TODO: Handle localization here, but that's a \"client thing\", so we don't have a `core` controller\n // to refer to.\n snap.manifest.proposedName\n : stripSnapPrefix(snapId);\n\n return snapName;\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=type-utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-utils.cjs","sourceRoot":"","sources":["../src/type-utils.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Updatable field with timestamp tracking for persistence and synchronization.\n */\nexport type UpdatableField<T> = {\n value: T;\n lastUpdatedAt: number;\n};\n\n/**\n * Type utility to extract value from UpdatableField or return field as-is.\n */\nexport type ExtractFieldValue<Field> =\n Field extends UpdatableField<unknown> ? Field['value'] : Field;\n\n/**\n * Type utility to extract plain values from an object with UpdatableField properties.\n */\nexport type ExtractFieldValues<ObjectValue extends Record<string, unknown>> = {\n [Key in keyof ObjectValue]: ExtractFieldValue<ObjectValue[Key]>;\n};\n\n/**\n * Type utility to extract plain values and make all properties required (for tree objects).\n */\nexport type ExtractRequiredFieldValues<\n ObjectValue extends Record<string, unknown>,\n> = {\n [Key in keyof ObjectValue]-?: ExtractFieldValue<ObjectValue[Key]>;\n};\n"]}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Updatable field with timestamp tracking for persistence and synchronization.
3
+ */
4
+ export type UpdatableField<T> = {
5
+ value: T;
6
+ lastUpdatedAt: number;
7
+ };
8
+ /**
9
+ * Type utility to extract value from UpdatableField or return field as-is.
10
+ */
11
+ export type ExtractFieldValue<Field> = Field extends UpdatableField<unknown> ? Field['value'] : Field;
12
+ /**
13
+ * Type utility to extract plain values from an object with UpdatableField properties.
14
+ */
15
+ export type ExtractFieldValues<ObjectValue extends Record<string, unknown>> = {
16
+ [Key in keyof ObjectValue]: ExtractFieldValue<ObjectValue[Key]>;
17
+ };
18
+ /**
19
+ * Type utility to extract plain values and make all properties required (for tree objects).
20
+ */
21
+ export type ExtractRequiredFieldValues<ObjectValue extends Record<string, unknown>> = {
22
+ [Key in keyof ObjectValue]-?: ExtractFieldValue<ObjectValue[Key]>;
23
+ };
24
+ //# sourceMappingURL=type-utils.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-utils.d.cts","sourceRoot":"","sources":["../src/type-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAC9B,KAAK,EAAE,CAAC,CAAC;IACT,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,KAAK,IACjC,KAAK,SAAS,cAAc,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;AAEjE;;GAEG;AACH,MAAM,MAAM,kBAAkB,CAAC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;KAC3E,GAAG,IAAI,MAAM,WAAW,GAAG,iBAAiB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;CAChE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0BAA0B,CACpC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IACzC;KACD,GAAG,IAAI,MAAM,WAAW,CAAC,CAAC,GAAG,iBAAiB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;CAClE,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Updatable field with timestamp tracking for persistence and synchronization.
3
+ */
4
+ export type UpdatableField<T> = {
5
+ value: T;
6
+ lastUpdatedAt: number;
7
+ };
8
+ /**
9
+ * Type utility to extract value from UpdatableField or return field as-is.
10
+ */
11
+ export type ExtractFieldValue<Field> = Field extends UpdatableField<unknown> ? Field['value'] : Field;
12
+ /**
13
+ * Type utility to extract plain values from an object with UpdatableField properties.
14
+ */
15
+ export type ExtractFieldValues<ObjectValue extends Record<string, unknown>> = {
16
+ [Key in keyof ObjectValue]: ExtractFieldValue<ObjectValue[Key]>;
17
+ };
18
+ /**
19
+ * Type utility to extract plain values and make all properties required (for tree objects).
20
+ */
21
+ export type ExtractRequiredFieldValues<ObjectValue extends Record<string, unknown>> = {
22
+ [Key in keyof ObjectValue]-?: ExtractFieldValue<ObjectValue[Key]>;
23
+ };
24
+ //# sourceMappingURL=type-utils.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-utils.d.mts","sourceRoot":"","sources":["../src/type-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAC9B,KAAK,EAAE,CAAC,CAAC;IACT,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,KAAK,IACjC,KAAK,SAAS,cAAc,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;AAEjE;;GAEG;AACH,MAAM,MAAM,kBAAkB,CAAC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;KAC3E,GAAG,IAAI,MAAM,WAAW,GAAG,iBAAiB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;CAChE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0BAA0B,CACpC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IACzC;KACD,GAAG,IAAI,MAAM,WAAW,CAAC,CAAC,GAAG,iBAAiB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;CAClE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type-utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-utils.mjs","sourceRoot":"","sources":["../src/type-utils.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Updatable field with timestamp tracking for persistence and synchronization.\n */\nexport type UpdatableField<T> = {\n value: T;\n lastUpdatedAt: number;\n};\n\n/**\n * Type utility to extract value from UpdatableField or return field as-is.\n */\nexport type ExtractFieldValue<Field> =\n Field extends UpdatableField<unknown> ? Field['value'] : Field;\n\n/**\n * Type utility to extract plain values from an object with UpdatableField properties.\n */\nexport type ExtractFieldValues<ObjectValue extends Record<string, unknown>> = {\n [Key in keyof ObjectValue]: ExtractFieldValue<ObjectValue[Key]>;\n};\n\n/**\n * Type utility to extract plain values and make all properties required (for tree objects).\n */\nexport type ExtractRequiredFieldValues<\n ObjectValue extends Record<string, unknown>,\n> = {\n [Key in keyof ObjectValue]-?: ExtractFieldValue<ObjectValue[Key]>;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { AccountGroupId, AccountWalletId } from '@metamask/account-api';\nimport type {\n AccountsControllerAccountAddedEvent,\n AccountsControllerAccountRemovedEvent,\n AccountsControllerGetAccountAction,\n AccountsControllerGetSelectedAccountAction,\n AccountsControllerListMultichainAccountsAction,\n AccountsControllerSelectedAccountChangeEvent,\n AccountsControllerSetSelectedAccountAction,\n} from '@metamask/accounts-controller';\nimport {\n type ControllerGetStateAction,\n type ControllerStateChangeEvent,\n type RestrictedMessenger,\n} from '@metamask/base-controller';\nimport type { KeyringControllerGetStateAction } from '@metamask/keyring-controller';\nimport type { GetSnap as SnapControllerGetSnap } from '@metamask/snaps-controllers';\n\nimport type {\n AccountTreeController,\n controllerName,\n} from './AccountTreeController';\nimport type { AccountWalletObject } from './wallet';\n\nexport type AccountTreeControllerState = {\n accountTree: {\n wallets: {\n // Wallets:\n [walletId: AccountWalletId]: AccountWalletObject;\n };\n selectedAccountGroup: AccountGroupId | '';\n };\n};\n\nexport type AccountTreeControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n AccountTreeControllerState\n>;\n\nexport type AccountTreeControllerSetSelectedAccountGroupAction = {\n type: `${typeof controllerName}:setSelectedAccountGroup`;\n handler: AccountTreeController['setSelectedAccountGroup'];\n};\n\nexport type AccountTreeControllerGetSelectedAccountGroupAction = {\n type: `${typeof controllerName}:getSelectedAccountGroup`;\n handler: AccountTreeController['getSelectedAccountGroup'];\n};\n\nexport type AllowedActions =\n | AccountsControllerGetAccountAction\n | AccountsControllerGetSelectedAccountAction\n | AccountsControllerListMultichainAccountsAction\n | AccountsControllerSetSelectedAccountAction\n | KeyringControllerGetStateAction\n | SnapControllerGetSnap;\n\nexport type AccountTreeControllerActions =\n | AccountTreeControllerGetStateAction\n | AccountTreeControllerSetSelectedAccountGroupAction\n | AccountTreeControllerGetSelectedAccountGroupAction;\n\nexport type AccountTreeControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n AccountTreeControllerState\n>;\n\nexport type AllowedEvents =\n | AccountsControllerAccountAddedEvent\n | AccountsControllerAccountRemovedEvent\n | AccountsControllerSelectedAccountChangeEvent;\n\nexport type AccountTreeControllerEvents = AccountTreeControllerStateChangeEvent;\n\nexport type AccountTreeControllerMessenger = RestrictedMessenger<\n typeof controllerName,\n AccountTreeControllerActions | AllowedActions,\n AccountTreeControllerEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n"]}
1
+ {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { AccountGroupId, AccountWalletId } from '@metamask/account-api';\nimport type {\n AccountsControllerAccountAddedEvent,\n AccountsControllerAccountRemovedEvent,\n AccountsControllerGetAccountAction,\n AccountsControllerGetSelectedAccountAction,\n AccountsControllerListMultichainAccountsAction,\n AccountsControllerSelectedAccountChangeEvent,\n AccountsControllerSetSelectedAccountAction,\n} from '@metamask/accounts-controller';\nimport {\n type ControllerGetStateAction,\n type ControllerStateChangeEvent,\n type RestrictedMessenger,\n} from '@metamask/base-controller';\nimport type { KeyringControllerGetStateAction } from '@metamask/keyring-controller';\nimport type { GetSnap as SnapControllerGetSnap } from '@metamask/snaps-controllers';\n\nimport type {\n AccountTreeController,\n controllerName,\n} from './AccountTreeController';\nimport type {\n AccountGroupObject,\n AccountGroupPersistedMetadata,\n} from './group';\nimport type {\n AccountWalletObject,\n AccountWalletPersistedMetadata,\n} from './wallet';\n\n// Backward compatibility aliases using indexed access types\n/**\n * @deprecated Use AccountGroupTreeMetadata for tree objects or AccountGroupPersistedMetadata for controller state\n */\nexport type AccountGroupMetadata = AccountGroupObject['metadata'];\n\n/**\n * @deprecated Use AccountWalletTreeMetadata for tree objects or AccountWalletPersistedMetadata for controller state\n */\nexport type AccountWalletMetadata = AccountWalletObject['metadata'];\n\nexport type AccountTreeControllerState = {\n accountTree: {\n wallets: {\n // Wallets:\n [walletId: AccountWalletId]: AccountWalletObject;\n };\n selectedAccountGroup: AccountGroupId | '';\n };\n /** Persistent metadata for account groups (names, pinning, hiding, sync timestamps) */\n accountGroupsMetadata: Record<AccountGroupId, AccountGroupPersistedMetadata>;\n /** Persistent metadata for account wallets (names, sync timestamps) */\n accountWalletsMetadata: Record<\n AccountWalletId,\n AccountWalletPersistedMetadata\n >;\n};\n\nexport type AccountTreeControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n AccountTreeControllerState\n>;\n\nexport type AccountTreeControllerSetSelectedAccountGroupAction = {\n type: `${typeof controllerName}:setSelectedAccountGroup`;\n handler: AccountTreeController['setSelectedAccountGroup'];\n};\n\nexport type AccountTreeControllerGetSelectedAccountGroupAction = {\n type: `${typeof controllerName}:getSelectedAccountGroup`;\n handler: AccountTreeController['getSelectedAccountGroup'];\n};\n\nexport type AllowedActions =\n | AccountsControllerGetAccountAction\n | AccountsControllerGetSelectedAccountAction\n | AccountsControllerListMultichainAccountsAction\n | AccountsControllerSetSelectedAccountAction\n | KeyringControllerGetStateAction\n | SnapControllerGetSnap;\n\nexport type AccountTreeControllerActions =\n | AccountTreeControllerGetStateAction\n | AccountTreeControllerSetSelectedAccountGroupAction\n | AccountTreeControllerGetSelectedAccountGroupAction;\n\nexport type AccountTreeControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n AccountTreeControllerState\n>;\n\nexport type AllowedEvents =\n | AccountsControllerAccountAddedEvent\n | AccountsControllerAccountRemovedEvent\n | AccountsControllerSelectedAccountChangeEvent;\n\nexport type AccountTreeControllerEvents = AccountTreeControllerStateChangeEvent;\n\nexport type AccountTreeControllerMessenger = RestrictedMessenger<\n typeof controllerName,\n AccountTreeControllerActions | AllowedActions,\n AccountTreeControllerEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n"]}
package/dist/types.d.cts CHANGED
@@ -4,7 +4,16 @@ import { type ControllerGetStateAction, type ControllerStateChangeEvent, type Re
4
4
  import type { KeyringControllerGetStateAction } from "@metamask/keyring-controller";
5
5
  import type { GetSnap as SnapControllerGetSnap } from "@metamask/snaps-controllers";
6
6
  import type { AccountTreeController, controllerName } from "./AccountTreeController.cjs";
7
- import type { AccountWalletObject } from "./wallet.cjs";
7
+ import type { AccountGroupObject, AccountGroupPersistedMetadata } from "./group.cjs";
8
+ import type { AccountWalletObject, AccountWalletPersistedMetadata } from "./wallet.cjs";
9
+ /**
10
+ * @deprecated Use AccountGroupTreeMetadata for tree objects or AccountGroupPersistedMetadata for controller state
11
+ */
12
+ export type AccountGroupMetadata = AccountGroupObject['metadata'];
13
+ /**
14
+ * @deprecated Use AccountWalletTreeMetadata for tree objects or AccountWalletPersistedMetadata for controller state
15
+ */
16
+ export type AccountWalletMetadata = AccountWalletObject['metadata'];
8
17
  export type AccountTreeControllerState = {
9
18
  accountTree: {
10
19
  wallets: {
@@ -12,6 +21,10 @@ export type AccountTreeControllerState = {
12
21
  };
13
22
  selectedAccountGroup: AccountGroupId | '';
14
23
  };
24
+ /** Persistent metadata for account groups (names, pinning, hiding, sync timestamps) */
25
+ accountGroupsMetadata: Record<AccountGroupId, AccountGroupPersistedMetadata>;
26
+ /** Persistent metadata for account wallets (names, sync timestamps) */
27
+ accountWalletsMetadata: Record<AccountWalletId, AccountWalletPersistedMetadata>;
15
28
  };
16
29
  export type AccountTreeControllerGetStateAction = ControllerGetStateAction<typeof controllerName, AccountTreeControllerState>;
17
30
  export type AccountTreeControllerSetSelectedAccountGroupAction = {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,8BAA8B;AAC7E,OAAO,KAAK,EACV,mCAAmC,EACnC,qCAAqC,EACrC,kCAAkC,EAClC,0CAA0C,EAC1C,8CAA8C,EAC9C,4CAA4C,EAC5C,0CAA0C,EAC3C,sCAAsC;AACvC,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACzB,kCAAkC;AACnC,OAAO,KAAK,EAAE,+BAA+B,EAAE,qCAAqC;AACpF,OAAO,KAAK,EAAE,OAAO,IAAI,qBAAqB,EAAE,oCAAoC;AAEpF,OAAO,KAAK,EACV,qBAAqB,EACrB,cAAc,EACf,oCAAgC;AACjC,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAiB;AAEpD,MAAM,MAAM,0BAA0B,GAAG;IACvC,WAAW,EAAE;QACX,OAAO,EAAE;YAEP,CAAC,QAAQ,EAAE,eAAe,GAAG,mBAAmB,CAAC;SAClD,CAAC;QACF,oBAAoB,EAAE,cAAc,GAAG,EAAE,CAAC;KAC3C,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG,wBAAwB,CACxE,OAAO,cAAc,EACrB,0BAA0B,CAC3B,CAAC;AAEF,MAAM,MAAM,kDAAkD,GAAG;IAC/D,IAAI,EAAE,GAAG,OAAO,cAAc,0BAA0B,CAAC;IACzD,OAAO,EAAE,qBAAqB,CAAC,yBAAyB,CAAC,CAAC;CAC3D,CAAC;AAEF,MAAM,MAAM,kDAAkD,GAAG;IAC/D,IAAI,EAAE,GAAG,OAAO,cAAc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5E,OAAO,cAAc,EACrB,0BAA0B,CAC3B,CAAC;AAEF,MAAM,MAAM,aAAa,GACrB,mCAAmC,GACnC,qCAAqC,GACrC,4CAA4C,CAAC;AAEjD,MAAM,MAAM,2BAA2B,GAAG,qCAAqC,CAAC;AAEhF,MAAM,MAAM,8BAA8B,GAAG,mBAAmB,CAC9D,OAAO,cAAc,EACrB,4BAA4B,GAAG,cAAc,EAC7C,2BAA2B,GAAG,aAAa,EAC3C,cAAc,CAAC,MAAM,CAAC,EACtB,aAAa,CAAC,MAAM,CAAC,CACtB,CAAC"}
package/dist/types.d.mts CHANGED
@@ -4,7 +4,16 @@ import { type ControllerGetStateAction, type ControllerStateChangeEvent, type Re
4
4
  import type { KeyringControllerGetStateAction } from "@metamask/keyring-controller";
5
5
  import type { GetSnap as SnapControllerGetSnap } from "@metamask/snaps-controllers";
6
6
  import type { AccountTreeController, controllerName } from "./AccountTreeController.mjs";
7
- import type { AccountWalletObject } from "./wallet.mjs";
7
+ import type { AccountGroupObject, AccountGroupPersistedMetadata } from "./group.mjs";
8
+ import type { AccountWalletObject, AccountWalletPersistedMetadata } from "./wallet.mjs";
9
+ /**
10
+ * @deprecated Use AccountGroupTreeMetadata for tree objects or AccountGroupPersistedMetadata for controller state
11
+ */
12
+ export type AccountGroupMetadata = AccountGroupObject['metadata'];
13
+ /**
14
+ * @deprecated Use AccountWalletTreeMetadata for tree objects or AccountWalletPersistedMetadata for controller state
15
+ */
16
+ export type AccountWalletMetadata = AccountWalletObject['metadata'];
8
17
  export type AccountTreeControllerState = {
9
18
  accountTree: {
10
19
  wallets: {
@@ -12,6 +21,10 @@ export type AccountTreeControllerState = {
12
21
  };
13
22
  selectedAccountGroup: AccountGroupId | '';
14
23
  };
24
+ /** Persistent metadata for account groups (names, pinning, hiding, sync timestamps) */
25
+ accountGroupsMetadata: Record<AccountGroupId, AccountGroupPersistedMetadata>;
26
+ /** Persistent metadata for account wallets (names, sync timestamps) */
27
+ accountWalletsMetadata: Record<AccountWalletId, AccountWalletPersistedMetadata>;
15
28
  };
16
29
  export type AccountTreeControllerGetStateAction = ControllerGetStateAction<typeof controllerName, AccountTreeControllerState>;
17
30
  export type AccountTreeControllerSetSelectedAccountGroupAction = {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,8BAA8B;AAC7E,OAAO,KAAK,EACV,mCAAmC,EACnC,qCAAqC,EACrC,kCAAkC,EAClC,0CAA0C,EAC1C,8CAA8C,EAC9C,4CAA4C,EAC5C,0CAA0C,EAC3C,sCAAsC;AACvC,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACzB,kCAAkC;AACnC,OAAO,KAAK,EAAE,+BAA+B,EAAE,qCAAqC;AACpF,OAAO,KAAK,EAAE,OAAO,IAAI,qBAAqB,EAAE,oCAAoC;AAEpF,OAAO,KAAK,EACV,qBAAqB,EACrB,cAAc,EACf,oCAAgC;AACjC,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAiB;AAEpD,MAAM,MAAM,0BAA0B,GAAG;IACvC,WAAW,EAAE;QACX,OAAO,EAAE;YAEP,CAAC,QAAQ,EAAE,eAAe,GAAG,mBAAmB,CAAC;SAClD,CAAC;QACF,oBAAoB,EAAE,cAAc,GAAG,EAAE,CAAC;KAC3C,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG,wBAAwB,CACxE,OAAO,cAAc,EACrB,0BAA0B,CAC3B,CAAC;AAEF,MAAM,MAAM,kDAAkD,GAAG;IAC/D,IAAI,EAAE,GAAG,OAAO,cAAc,0BAA0B,CAAC;IACzD,OAAO,EAAE,qBAAqB,CAAC,yBAAyB,CAAC,CAAC;CAC3D,CAAC;AAEF,MAAM,MAAM,kDAAkD,GAAG;IAC/D,IAAI,EAAE,GAAG,OAAO,cAAc,0BAA0B,CAAC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,EACrB,0BAA0B,CAC3B,CAAC;AAEF,MAAM,MAAM,aAAa,GACrB,mCAAmC,GACnC,qCAAqC,GACrC,4CAA4C,CAAC;AAEjD,MAAM,MAAM,2BAA2B,GAAG,qCAAqC,CAAC;AAEhF,MAAM,MAAM,8BAA8B,GAAG,mBAAmB,CAC9D,OAAO,cAAc,EACrB,4BAA4B,GAAG,cAAc,EAC7C,2BAA2B,GAAG,aAAa,EAC3C,cAAc,CAAC,MAAM,CAAC,EACtB,aAAa,CAAC,MAAM,CAAC,CACtB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { AccountGroupId, AccountWalletId } from '@metamask/account-api';\nimport type {\n AccountsControllerAccountAddedEvent,\n AccountsControllerAccountRemovedEvent,\n AccountsControllerGetAccountAction,\n AccountsControllerGetSelectedAccountAction,\n AccountsControllerListMultichainAccountsAction,\n AccountsControllerSelectedAccountChangeEvent,\n AccountsControllerSetSelectedAccountAction,\n} from '@metamask/accounts-controller';\nimport {\n type ControllerGetStateAction,\n type ControllerStateChangeEvent,\n type RestrictedMessenger,\n} from '@metamask/base-controller';\nimport type { KeyringControllerGetStateAction } from '@metamask/keyring-controller';\nimport type { GetSnap as SnapControllerGetSnap } from '@metamask/snaps-controllers';\n\nimport type {\n AccountTreeController,\n controllerName,\n} from './AccountTreeController';\nimport type { AccountWalletObject } from './wallet';\n\nexport type AccountTreeControllerState = {\n accountTree: {\n wallets: {\n // Wallets:\n [walletId: AccountWalletId]: AccountWalletObject;\n };\n selectedAccountGroup: AccountGroupId | '';\n };\n};\n\nexport type AccountTreeControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n AccountTreeControllerState\n>;\n\nexport type AccountTreeControllerSetSelectedAccountGroupAction = {\n type: `${typeof controllerName}:setSelectedAccountGroup`;\n handler: AccountTreeController['setSelectedAccountGroup'];\n};\n\nexport type AccountTreeControllerGetSelectedAccountGroupAction = {\n type: `${typeof controllerName}:getSelectedAccountGroup`;\n handler: AccountTreeController['getSelectedAccountGroup'];\n};\n\nexport type AllowedActions =\n | AccountsControllerGetAccountAction\n | AccountsControllerGetSelectedAccountAction\n | AccountsControllerListMultichainAccountsAction\n | AccountsControllerSetSelectedAccountAction\n | KeyringControllerGetStateAction\n | SnapControllerGetSnap;\n\nexport type AccountTreeControllerActions =\n | AccountTreeControllerGetStateAction\n | AccountTreeControllerSetSelectedAccountGroupAction\n | AccountTreeControllerGetSelectedAccountGroupAction;\n\nexport type AccountTreeControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n AccountTreeControllerState\n>;\n\nexport type AllowedEvents =\n | AccountsControllerAccountAddedEvent\n | AccountsControllerAccountRemovedEvent\n | AccountsControllerSelectedAccountChangeEvent;\n\nexport type AccountTreeControllerEvents = AccountTreeControllerStateChangeEvent;\n\nexport type AccountTreeControllerMessenger = RestrictedMessenger<\n typeof controllerName,\n AccountTreeControllerActions | AllowedActions,\n AccountTreeControllerEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n"]}
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { AccountGroupId, AccountWalletId } from '@metamask/account-api';\nimport type {\n AccountsControllerAccountAddedEvent,\n AccountsControllerAccountRemovedEvent,\n AccountsControllerGetAccountAction,\n AccountsControllerGetSelectedAccountAction,\n AccountsControllerListMultichainAccountsAction,\n AccountsControllerSelectedAccountChangeEvent,\n AccountsControllerSetSelectedAccountAction,\n} from '@metamask/accounts-controller';\nimport {\n type ControllerGetStateAction,\n type ControllerStateChangeEvent,\n type RestrictedMessenger,\n} from '@metamask/base-controller';\nimport type { KeyringControllerGetStateAction } from '@metamask/keyring-controller';\nimport type { GetSnap as SnapControllerGetSnap } from '@metamask/snaps-controllers';\n\nimport type {\n AccountTreeController,\n controllerName,\n} from './AccountTreeController';\nimport type {\n AccountGroupObject,\n AccountGroupPersistedMetadata,\n} from './group';\nimport type {\n AccountWalletObject,\n AccountWalletPersistedMetadata,\n} from './wallet';\n\n// Backward compatibility aliases using indexed access types\n/**\n * @deprecated Use AccountGroupTreeMetadata for tree objects or AccountGroupPersistedMetadata for controller state\n */\nexport type AccountGroupMetadata = AccountGroupObject['metadata'];\n\n/**\n * @deprecated Use AccountWalletTreeMetadata for tree objects or AccountWalletPersistedMetadata for controller state\n */\nexport type AccountWalletMetadata = AccountWalletObject['metadata'];\n\nexport type AccountTreeControllerState = {\n accountTree: {\n wallets: {\n // Wallets:\n [walletId: AccountWalletId]: AccountWalletObject;\n };\n selectedAccountGroup: AccountGroupId | '';\n };\n /** Persistent metadata for account groups (names, pinning, hiding, sync timestamps) */\n accountGroupsMetadata: Record<AccountGroupId, AccountGroupPersistedMetadata>;\n /** Persistent metadata for account wallets (names, sync timestamps) */\n accountWalletsMetadata: Record<\n AccountWalletId,\n AccountWalletPersistedMetadata\n >;\n};\n\nexport type AccountTreeControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n AccountTreeControllerState\n>;\n\nexport type AccountTreeControllerSetSelectedAccountGroupAction = {\n type: `${typeof controllerName}:setSelectedAccountGroup`;\n handler: AccountTreeController['setSelectedAccountGroup'];\n};\n\nexport type AccountTreeControllerGetSelectedAccountGroupAction = {\n type: `${typeof controllerName}:getSelectedAccountGroup`;\n handler: AccountTreeController['getSelectedAccountGroup'];\n};\n\nexport type AllowedActions =\n | AccountsControllerGetAccountAction\n | AccountsControllerGetSelectedAccountAction\n | AccountsControllerListMultichainAccountsAction\n | AccountsControllerSetSelectedAccountAction\n | KeyringControllerGetStateAction\n | SnapControllerGetSnap;\n\nexport type AccountTreeControllerActions =\n | AccountTreeControllerGetStateAction\n | AccountTreeControllerSetSelectedAccountGroupAction\n | AccountTreeControllerGetSelectedAccountGroupAction;\n\nexport type AccountTreeControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n AccountTreeControllerState\n>;\n\nexport type AllowedEvents =\n | AccountsControllerAccountAddedEvent\n | AccountsControllerAccountRemovedEvent\n | AccountsControllerSelectedAccountChangeEvent;\n\nexport type AccountTreeControllerEvents = AccountTreeControllerStateChangeEvent;\n\nexport type AccountTreeControllerMessenger = RestrictedMessenger<\n typeof controllerName,\n AccountTreeControllerActions | AllowedActions,\n AccountTreeControllerEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"wallet.cjs","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAgBA,uCAA2C;AA8F3C;;GAEG;AACH,MAAa,iBAAiB;IAO5B,YAAY,EACV,SAAS,EACT,MAAM,GAIP;QAZQ,4CAA6B;QAapC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,uBAAA,IAAI,6BAAW,MAAM,MAAA,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QAExB,KAAK,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,uBAAA,IAAI,iCAAQ,CAAC,MAAM,CAAC,EAAE;YAClE,IAAI,CAAC,MAAM,CAAC,GAAG,CACb,OAAyB,EACzB,IAAI,wBAAgB,CAAC;gBACnB,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,MAAM,EAAE,IAAI;gBACZ,KAAK;aACN,CAAC,CACH,CAAC;SACH;IACH,CAAC;IAED,IAAI,EAAE;QACJ,OAAO,uBAAA,IAAI,iCAAQ,CAAC,EAAE,CAAC;IACzB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,uBAAA,IAAI,iCAAQ,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED,IAAI,IAAI;QACN,OAAO,uBAAA,IAAI,iCAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;IACpC,CAAC;IAED;;;;;OAKG;IACH,eAAe,CAAC,OAAuB;QACrC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IAED;;;;;;OAMG;IACH,sBAAsB,CAAC,OAAuB;QAC5C,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAC5C,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;SAChD;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;OAIG;IACH,gBAAgB;QACd,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1C,CAAC;CACF;AA5ED,8CA4EC","sourcesContent":["import type {\n AccountWalletType,\n AccountWalletId,\n MultichainAccountWalletId,\n} from '@metamask/account-api';\nimport { type AccountGroupId, type AccountWallet } from '@metamask/account-api';\nimport type { EntropySourceId } from '@metamask/keyring-api';\nimport type { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { SnapId } from '@metamask/snaps-sdk';\n\nimport type {\n AccountGroupMultichainAccountObject,\n AccountGroupObject,\n AccountGroupSingleAccountObject,\n} from './group';\nimport { AccountTreeGroup } from './group';\nimport { type AccountTreeControllerMessenger } from './types';\n\n/**\n * Type constraint for a {@link AccountGroupObject}. If one of its union-members\n * does not match this contraint, {@link AccountGroupObject} will resolve\n * to `never`.\n */\ntype IsAccountWalletObject<\n Type extends {\n type: AccountWalletType;\n id: AccountWalletId;\n groups: {\n [groupId: AccountGroupId]: AccountGroupObject;\n };\n metadata: {\n name: string;\n };\n },\n> = Type;\n\n/**\n * Account wallet object for the \"entropy\" wallet category.\n */\nexport type AccountWalletEntropyObject = {\n type: AccountWalletType.Entropy;\n id: MultichainAccountWalletId;\n groups: {\n // NOTE: Using `MultichainAccountGroupId` instead of `AccountGroupId` would introduce\n // some type problems when using a group ID as an `AccountGroupId` directly. This\n // would require some up-cast to a `MultichainAccountGroupId` which could be considered\n // unsafe... So we keep it as a `AccountGroupId` for now.\n [groupId: AccountGroupId]: AccountGroupMultichainAccountObject;\n };\n metadata: {\n name: string;\n entropy: {\n id: EntropySourceId;\n index: number;\n };\n };\n};\n\n/**\n * Account wallet object for the \"snap\" wallet category.\n */\nexport type AccountWalletSnapObject = {\n type: AccountWalletType.Snap;\n id: AccountWalletId;\n groups: {\n [groupId: AccountGroupId]: AccountGroupSingleAccountObject;\n };\n metadata: {\n name: string;\n snap: {\n id: SnapId;\n };\n };\n};\n\n/**\n * Account wallet object for the \"keyring\" wallet category.\n */\nexport type AccountWalletKeyringObject = {\n type: AccountWalletType.Keyring;\n id: AccountWalletId;\n groups: {\n [groupId: AccountGroupId]: AccountGroupSingleAccountObject;\n };\n metadata: {\n name: string;\n keyring: {\n type: KeyringTypes;\n };\n };\n};\n\n/**\n * Account wallet metadata for the \"keyring\" wallet category.\n */\nexport type AccountWalletObject = IsAccountWalletObject<\n | AccountWalletEntropyObject\n | AccountWalletSnapObject\n | AccountWalletKeyringObject\n>;\n\nexport type AccountWalletObjectOf<WalletType extends AccountWalletType> =\n Extract<\n | { type: AccountWalletType.Entropy; object: AccountWalletEntropyObject }\n | { type: AccountWalletType.Keyring; object: AccountWalletKeyringObject }\n | { type: AccountWalletType.Snap; object: AccountWalletSnapObject },\n { type: WalletType }\n >['object'];\n\n/**\n * Account wallet coming from the {@link AccountTreeController}.\n */\nexport class AccountTreeWallet implements AccountWallet<InternalAccount> {\n readonly #wallet: AccountWalletObject;\n\n protected messenger: AccountTreeControllerMessenger;\n\n protected groups: Map<AccountGroupId, AccountTreeGroup>;\n\n constructor({\n messenger,\n wallet,\n }: {\n messenger: AccountTreeControllerMessenger;\n wallet: AccountWalletObject;\n }) {\n this.messenger = messenger;\n this.#wallet = wallet;\n this.groups = new Map();\n\n for (const [groupId, group] of Object.entries(this.#wallet.groups)) {\n this.groups.set(\n groupId as AccountGroupId,\n new AccountTreeGroup({\n messenger: this.messenger,\n wallet: this,\n group,\n }),\n );\n }\n }\n\n get id(): AccountWalletId {\n return this.#wallet.id;\n }\n\n get type(): AccountWalletType {\n return this.#wallet.type;\n }\n\n get name(): string {\n return this.#wallet.metadata.name;\n }\n\n /**\n * Gets account tree group for a given ID.\n *\n * @param groupId - Group ID.\n * @returns Account tree group, or undefined if not found.\n */\n getAccountGroup(groupId: AccountGroupId): AccountTreeGroup | undefined {\n return this.groups.get(groupId);\n }\n\n /**\n * Gets account tree group for a given ID.\n *\n * @param groupId - Group ID.\n * @throws If the account group is not found.\n * @returns Account tree group.\n */\n getAccountGroupOrThrow(groupId: AccountGroupId): AccountTreeGroup {\n const group = this.getAccountGroup(groupId);\n if (!group) {\n throw new Error('Unable to get account group');\n }\n\n return group;\n }\n\n /**\n * Gets all account tree groups.\n *\n * @returns Account tree groups.\n */\n getAccountGroups(): AccountTreeGroup[] {\n return Array.from(this.groups.values());\n }\n}\n"]}
1
+ {"version":3,"file":"wallet.cjs","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAgBA,uCAA2C;AA2G3C;;GAEG;AACH,MAAa,iBAAiB;IAO5B,YAAY,EACV,SAAS,EACT,MAAM,GAIP;QAZQ,4CAA6B;QAapC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,uBAAA,IAAI,6BAAW,MAAM,MAAA,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QAExB,KAAK,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,uBAAA,IAAI,iCAAQ,CAAC,MAAM,CAAC,EAAE;YAClE,IAAI,CAAC,MAAM,CAAC,GAAG,CACb,OAAyB,EACzB,IAAI,wBAAgB,CAAC;gBACnB,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,MAAM,EAAE,IAAI;gBACZ,KAAK;aACN,CAAC,CACH,CAAC;SACH;IACH,CAAC;IAED,IAAI,EAAE;QACJ,OAAO,uBAAA,IAAI,iCAAQ,CAAC,EAAE,CAAC;IACzB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,uBAAA,IAAI,iCAAQ,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED,IAAI,IAAI;QACN,OAAO,uBAAA,IAAI,iCAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;IACpC,CAAC;IAED;;;;;OAKG;IACH,eAAe,CAAC,OAAuB;QACrC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IAED;;;;;;OAMG;IACH,sBAAsB,CAAC,OAAuB;QAC5C,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAC5C,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;SAChD;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;OAIG;IACH,gBAAgB;QACd,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1C,CAAC;CACF;AA5ED,8CA4EC","sourcesContent":["import type {\n AccountWalletType,\n AccountWalletId,\n MultichainAccountWalletId,\n} from '@metamask/account-api';\nimport { type AccountGroupId, type AccountWallet } from '@metamask/account-api';\nimport type { EntropySourceId } from '@metamask/keyring-api';\nimport type { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { SnapId } from '@metamask/snaps-sdk';\n\nimport type {\n AccountGroupMultichainAccountObject,\n AccountGroupObject,\n AccountGroupSingleAccountObject,\n} from './group';\nimport { AccountTreeGroup } from './group';\nimport type {\n UpdatableField,\n ExtractRequiredFieldValues,\n} from './type-utils.js';\nimport { type AccountTreeControllerMessenger } from './types';\n\n/**\n * Persisted metadata for account wallets (stored in controller state for persistence/sync).\n */\nexport type AccountWalletPersistedMetadata = {\n /** Custom name set by user, overrides default naming logic */\n name?: UpdatableField<string>;\n};\n\n/**\n * Tree metadata for account wallets (required plain values extracted from persisted metadata).\n */\nexport type AccountWalletTreeMetadata =\n ExtractRequiredFieldValues<AccountWalletPersistedMetadata>;\n\n/**\n * Type constraint for a {@link AccountGroupObject}. If one of its union-members\n * does not match this contraint, {@link AccountGroupObject} will resolve\n * to `never`.\n */\ntype IsAccountWalletObject<\n Type extends {\n type: AccountWalletType;\n id: AccountWalletId;\n groups: {\n [groupId: AccountGroupId]: AccountGroupObject;\n };\n metadata: AccountWalletTreeMetadata;\n },\n> = Type;\n\n/**\n * Account wallet object for the \"entropy\" wallet category.\n */\nexport type AccountWalletEntropyObject = {\n type: AccountWalletType.Entropy;\n id: MultichainAccountWalletId;\n groups: {\n // NOTE: Using `MultichainAccountGroupId` instead of `AccountGroupId` would introduce\n // some type problems when using a group ID as an `AccountGroupId` directly. This\n // would require some up-cast to a `MultichainAccountGroupId` which could be considered\n // unsafe... So we keep it as a `AccountGroupId` for now.\n [groupId: AccountGroupId]: AccountGroupMultichainAccountObject;\n };\n metadata: AccountWalletTreeMetadata & {\n entropy: {\n id: EntropySourceId;\n index: number;\n };\n };\n};\n\n/**\n * Account wallet object for the \"snap\" wallet category.\n */\nexport type AccountWalletSnapObject = {\n type: AccountWalletType.Snap;\n id: AccountWalletId;\n groups: {\n [groupId: AccountGroupId]: AccountGroupSingleAccountObject;\n };\n metadata: AccountWalletTreeMetadata & {\n snap: {\n id: SnapId;\n };\n };\n};\n\n/**\n * Account wallet object for the \"keyring\" wallet category.\n */\nexport type AccountWalletKeyringObject = {\n type: AccountWalletType.Keyring;\n id: AccountWalletId;\n groups: {\n [groupId: AccountGroupId]: AccountGroupSingleAccountObject;\n };\n metadata: AccountWalletTreeMetadata & {\n keyring: {\n type: KeyringTypes;\n };\n };\n};\n\n/**\n * Account wallet metadata for the \"keyring\" wallet category.\n */\nexport type AccountWalletObject = IsAccountWalletObject<\n | AccountWalletEntropyObject\n | AccountWalletSnapObject\n | AccountWalletKeyringObject\n>;\n\nexport type AccountWalletObjectOf<WalletType extends AccountWalletType> =\n Extract<\n | { type: AccountWalletType.Entropy; object: AccountWalletEntropyObject }\n | { type: AccountWalletType.Keyring; object: AccountWalletKeyringObject }\n | { type: AccountWalletType.Snap; object: AccountWalletSnapObject },\n { type: WalletType }\n >['object'];\n\n/**\n * Account wallet coming from the {@link AccountTreeController}.\n */\nexport class AccountTreeWallet implements AccountWallet<InternalAccount> {\n readonly #wallet: AccountWalletObject;\n\n protected messenger: AccountTreeControllerMessenger;\n\n protected groups: Map<AccountGroupId, AccountTreeGroup>;\n\n constructor({\n messenger,\n wallet,\n }: {\n messenger: AccountTreeControllerMessenger;\n wallet: AccountWalletObject;\n }) {\n this.messenger = messenger;\n this.#wallet = wallet;\n this.groups = new Map();\n\n for (const [groupId, group] of Object.entries(this.#wallet.groups)) {\n this.groups.set(\n groupId as AccountGroupId,\n new AccountTreeGroup({\n messenger: this.messenger,\n wallet: this,\n group,\n }),\n );\n }\n }\n\n get id(): AccountWalletId {\n return this.#wallet.id;\n }\n\n get type(): AccountWalletType {\n return this.#wallet.type;\n }\n\n get name(): string {\n return this.#wallet.metadata.name;\n }\n\n /**\n * Gets account tree group for a given ID.\n *\n * @param groupId - Group ID.\n * @returns Account tree group, or undefined if not found.\n */\n getAccountGroup(groupId: AccountGroupId): AccountTreeGroup | undefined {\n return this.groups.get(groupId);\n }\n\n /**\n * Gets account tree group for a given ID.\n *\n * @param groupId - Group ID.\n * @throws If the account group is not found.\n * @returns Account tree group.\n */\n getAccountGroupOrThrow(groupId: AccountGroupId): AccountTreeGroup {\n const group = this.getAccountGroup(groupId);\n if (!group) {\n throw new Error('Unable to get account group');\n }\n\n return group;\n }\n\n /**\n * Gets all account tree groups.\n *\n * @returns Account tree groups.\n */\n getAccountGroups(): AccountTreeGroup[] {\n return Array.from(this.groups.values());\n }\n}\n"]}