@metamask-previews/account-tree-controller 0.6.0-preview-e0bc4b4b → 0.6.0-preview-9b5151c

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 (114) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/AccountTreeController.cjs +86 -25
  3. package/dist/AccountTreeController.cjs.map +1 -1
  4. package/dist/AccountTreeController.d.cts +5 -3
  5. package/dist/AccountTreeController.d.cts.map +1 -1
  6. package/dist/AccountTreeController.d.mts +5 -3
  7. package/dist/AccountTreeController.d.mts.map +1 -1
  8. package/dist/AccountTreeController.mjs +87 -26
  9. package/dist/AccountTreeController.mjs.map +1 -1
  10. package/dist/AccountTreeGroup.cjs +51 -35
  11. package/dist/AccountTreeGroup.cjs.map +1 -1
  12. package/dist/AccountTreeGroup.d.cts +15 -22
  13. package/dist/AccountTreeGroup.d.cts.map +1 -1
  14. package/dist/AccountTreeGroup.d.mts +15 -22
  15. package/dist/AccountTreeGroup.d.mts.map +1 -1
  16. package/dist/AccountTreeGroup.mjs +49 -33
  17. package/dist/AccountTreeGroup.mjs.map +1 -1
  18. package/dist/AccountTreeWallet.cjs +61 -27
  19. package/dist/AccountTreeWallet.cjs.map +1 -1
  20. package/dist/AccountTreeWallet.d.cts +24 -17
  21. package/dist/AccountTreeWallet.d.cts.map +1 -1
  22. package/dist/AccountTreeWallet.d.mts +24 -17
  23. package/dist/AccountTreeWallet.d.mts.map +1 -1
  24. package/dist/AccountTreeWallet.mjs +60 -26
  25. package/dist/AccountTreeWallet.mjs.map +1 -1
  26. package/dist/rules/entropy.cjs +83 -0
  27. package/dist/rules/entropy.cjs.map +1 -0
  28. package/dist/rules/entropy.d.cts +15 -0
  29. package/dist/rules/entropy.d.cts.map +1 -0
  30. package/dist/rules/entropy.d.mts +15 -0
  31. package/dist/rules/entropy.d.mts.map +1 -0
  32. package/dist/rules/entropy.mjs +79 -0
  33. package/dist/rules/entropy.mjs.map +1 -0
  34. package/dist/rules/index.cjs +4 -4
  35. package/dist/rules/index.cjs.map +1 -1
  36. package/dist/rules/index.d.cts +4 -4
  37. package/dist/rules/index.d.cts.map +1 -1
  38. package/dist/rules/index.d.mts +4 -4
  39. package/dist/rules/index.d.mts.map +1 -1
  40. package/dist/rules/index.mjs +4 -4
  41. package/dist/rules/index.mjs.map +1 -1
  42. package/dist/rules/keyring.cjs +80 -0
  43. package/dist/rules/keyring.cjs.map +1 -0
  44. package/dist/rules/keyring.d.cts +20 -0
  45. package/dist/rules/keyring.d.cts.map +1 -0
  46. package/dist/rules/keyring.d.mts +20 -0
  47. package/dist/rules/keyring.d.mts.map +1 -0
  48. package/dist/rules/keyring.mjs +75 -0
  49. package/dist/rules/keyring.mjs.map +1 -0
  50. package/dist/rules/rule.cjs +10 -0
  51. package/dist/rules/rule.cjs.map +1 -0
  52. package/dist/rules/rule.d.cts +42 -0
  53. package/dist/rules/rule.d.cts.map +1 -0
  54. package/dist/rules/rule.d.mts +42 -0
  55. package/dist/rules/rule.d.mts.map +1 -0
  56. package/dist/rules/rule.mjs +6 -0
  57. package/dist/rules/rule.mjs.map +1 -0
  58. package/dist/rules/snap.cjs +53 -0
  59. package/dist/rules/snap.cjs.map +1 -0
  60. package/dist/rules/snap.d.cts +23 -0
  61. package/dist/rules/snap.d.cts.map +1 -0
  62. package/dist/rules/snap.d.mts +23 -0
  63. package/dist/rules/snap.d.mts.map +1 -0
  64. package/dist/rules/snap.mjs +49 -0
  65. package/dist/rules/snap.mjs.map +1 -0
  66. package/dist/types.cjs +3 -0
  67. package/dist/types.cjs.map +1 -0
  68. package/dist/types.d.cts +15 -0
  69. package/dist/types.d.cts.map +1 -0
  70. package/dist/types.d.mts +15 -0
  71. package/dist/types.d.mts.map +1 -0
  72. package/dist/types.mjs +2 -0
  73. package/dist/types.mjs.map +1 -0
  74. package/package.json +3 -3
  75. package/dist/rules/EntropySourceWalletRule.cjs +0 -100
  76. package/dist/rules/EntropySourceWalletRule.cjs.map +0 -1
  77. package/dist/rules/EntropySourceWalletRule.d.cts +0 -19
  78. package/dist/rules/EntropySourceWalletRule.d.cts.map +0 -1
  79. package/dist/rules/EntropySourceWalletRule.d.mts +0 -19
  80. package/dist/rules/EntropySourceWalletRule.d.mts.map +0 -1
  81. package/dist/rules/EntropySourceWalletRule.mjs +0 -95
  82. package/dist/rules/EntropySourceWalletRule.mjs.map +0 -1
  83. package/dist/rules/KeyringWalletRule.cjs +0 -99
  84. package/dist/rules/KeyringWalletRule.cjs.map +0 -1
  85. package/dist/rules/KeyringWalletRule.d.cts +0 -18
  86. package/dist/rules/KeyringWalletRule.d.cts.map +0 -1
  87. package/dist/rules/KeyringWalletRule.d.mts +0 -18
  88. package/dist/rules/KeyringWalletRule.d.mts.map +0 -1
  89. package/dist/rules/KeyringWalletRule.mjs +0 -94
  90. package/dist/rules/KeyringWalletRule.mjs.map +0 -1
  91. package/dist/rules/SnapWalletRule.cjs +0 -70
  92. package/dist/rules/SnapWalletRule.cjs.map +0 -1
  93. package/dist/rules/SnapWalletRule.d.cts +0 -10
  94. package/dist/rules/SnapWalletRule.d.cts.map +0 -1
  95. package/dist/rules/SnapWalletRule.d.mts +0 -10
  96. package/dist/rules/SnapWalletRule.d.mts.map +0 -1
  97. package/dist/rules/SnapWalletRule.mjs +0 -66
  98. package/dist/rules/SnapWalletRule.mjs.map +0 -1
  99. package/dist/rules/WalletRule.cjs +0 -13
  100. package/dist/rules/WalletRule.cjs.map +0 -1
  101. package/dist/rules/WalletRule.d.cts +0 -37
  102. package/dist/rules/WalletRule.d.cts.map +0 -1
  103. package/dist/rules/WalletRule.d.mts +0 -37
  104. package/dist/rules/WalletRule.d.mts.map +0 -1
  105. package/dist/rules/WalletRule.mjs +0 -9
  106. package/dist/rules/WalletRule.mjs.map +0 -1
  107. package/dist/rules/utils.cjs +0 -15
  108. package/dist/rules/utils.cjs.map +0 -1
  109. package/dist/rules/utils.d.cts +0 -11
  110. package/dist/rules/utils.d.cts.map +0 -1
  111. package/dist/rules/utils.d.mts +0 -11
  112. package/dist/rules/utils.d.mts.map +0 -1
  113. package/dist/rules/utils.mjs +0 -11
  114. package/dist/rules/utils.mjs.map +0 -1
@@ -10,49 +10,65 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _MutableAccountTreeGroup_accounts;
13
+ var _AccountTreeGroup_instances, _AccountTreeGroup_messenger, _AccountTreeGroup_group, _AccountTreeGroup_wallet, _AccountTreeGroup_getAccount;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.MutableAccountTreeGroup = exports.DEFAULT_ACCOUNT_GROUP_NAME = void 0;
16
- const account_api_1 = require("@metamask/account-api");
15
+ exports.AccountTreeGroup = exports.DEFAULT_ACCOUNT_GROUP_NAME = void 0;
17
16
  exports.DEFAULT_ACCOUNT_GROUP_NAME = 'Default';
18
- // This class is meant to be used internally by every rules. It exposes mutable operations
19
- // which should not leak outside of this package.
20
- class MutableAccountTreeGroup {
21
- constructor(messenger, wallet, id) {
22
- _MutableAccountTreeGroup_accounts.set(this, void 0);
23
- this.id = (0, account_api_1.toAccountGroupId)(wallet.id, id);
24
- this.wallet = wallet;
25
- this.messenger = messenger;
26
- __classPrivateFieldSet(this, _MutableAccountTreeGroup_accounts, new Set(), "f");
17
+ /**
18
+ * Account group coming from the {@link AccountTreeController}.
19
+ */
20
+ class AccountTreeGroup {
21
+ constructor({ messenger, wallet, group, }) {
22
+ _AccountTreeGroup_instances.add(this);
23
+ _AccountTreeGroup_messenger.set(this, void 0);
24
+ _AccountTreeGroup_group.set(this, void 0);
25
+ _AccountTreeGroup_wallet.set(this, void 0);
26
+ __classPrivateFieldSet(this, _AccountTreeGroup_messenger, messenger, "f");
27
+ __classPrivateFieldSet(this, _AccountTreeGroup_group, group, "f");
28
+ __classPrivateFieldSet(this, _AccountTreeGroup_wallet, wallet, "f");
27
29
  }
28
- getAccountIds() {
29
- return Array.from(__classPrivateFieldGet(this, _MutableAccountTreeGroup_accounts, "f")); // FIXME: Should we force the copy here?
30
+ get id() {
31
+ return __classPrivateFieldGet(this, _AccountTreeGroup_group, "f").id;
30
32
  }
31
- getAccounts() {
32
- const accounts = [];
33
- for (const id of __classPrivateFieldGet(this, _MutableAccountTreeGroup_accounts, "f")) {
34
- const account = this.getAccount(id);
35
- // FIXME: I'm really not sure we should skip those but... We could be
36
- // "de-sync" with the AccountsController and might have some dangling
37
- // account IDs.
38
- if (!account) {
39
- console.warn(`! Unable to get account: "${id}"`);
40
- continue;
41
- }
42
- accounts.push(account);
43
- }
44
- return accounts;
33
+ get wallet() {
34
+ return __classPrivateFieldGet(this, _AccountTreeGroup_wallet, "f");
35
+ }
36
+ get name() {
37
+ return __classPrivateFieldGet(this, _AccountTreeGroup_group, "f").metadata.name;
38
+ }
39
+ getAccountIds() {
40
+ return __classPrivateFieldGet(this, _AccountTreeGroup_group, "f").accounts;
45
41
  }
46
42
  getAccount(id) {
47
- return this.messenger.call('AccountsController:getAccount', id);
43
+ return __classPrivateFieldGet(this, _AccountTreeGroup_messenger, "f").call('AccountsController:getAccount', id);
48
44
  }
49
- addAccount(account) {
50
- __classPrivateFieldGet(this, _MutableAccountTreeGroup_accounts, "f").add(account.id);
45
+ getAccounts() {
46
+ return __classPrivateFieldGet(this, _AccountTreeGroup_group, "f").accounts.map((id) => __classPrivateFieldGet(this, _AccountTreeGroup_instances, "m", _AccountTreeGroup_getAccount).call(this, id));
51
47
  }
52
- getDefaultName() {
53
- return exports.DEFAULT_ACCOUNT_GROUP_NAME;
48
+ getAnyAccount() {
49
+ const accountIds = this.getAccountIds();
50
+ if (accountIds.length === 0) {
51
+ throw new Error('Group contains no account');
52
+ }
53
+ return __classPrivateFieldGet(this, _AccountTreeGroup_instances, "m", _AccountTreeGroup_getAccount).call(this, accountIds[0]);
54
+ }
55
+ getOnlyAccount() {
56
+ const accountIds = this.getAccountIds();
57
+ if (accountIds.length === 0) {
58
+ throw new Error('Group contains no account');
59
+ }
60
+ if (accountIds.length > 1) {
61
+ throw new Error('Group contains more than 1 account');
62
+ }
63
+ return __classPrivateFieldGet(this, _AccountTreeGroup_instances, "m", _AccountTreeGroup_getAccount).call(this, accountIds[0]);
54
64
  }
55
65
  }
56
- exports.MutableAccountTreeGroup = MutableAccountTreeGroup;
57
- _MutableAccountTreeGroup_accounts = new WeakMap();
66
+ exports.AccountTreeGroup = AccountTreeGroup;
67
+ _AccountTreeGroup_messenger = new WeakMap(), _AccountTreeGroup_group = new WeakMap(), _AccountTreeGroup_wallet = new WeakMap(), _AccountTreeGroup_instances = new WeakSet(), _AccountTreeGroup_getAccount = function _AccountTreeGroup_getAccount(id) {
68
+ const account = this.getAccount(id);
69
+ if (!account) {
70
+ throw new Error(`Unable to get account with ID: "${id}"`);
71
+ }
72
+ return account;
73
+ };
58
74
  //# sourceMappingURL=AccountTreeGroup.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"AccountTreeGroup.cjs","sourceRoot":"","sources":["../src/AccountTreeGroup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAK+B;AAKlB,QAAA,0BAA0B,GAAW,SAAS,CAAC;AAiB5D,0FAA0F;AAC1F,iDAAiD;AACjD,MAAa,uBAAuB;IASlC,YACE,SAAyC,EACzC,MAAsC,EACtC,EAAU;QALH,oDAA0B;QAOjC,IAAI,CAAC,EAAE,GAAG,IAAA,8BAAgB,EAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAE3B,uBAAA,IAAI,qCAAa,IAAI,GAAG,EAAE,MAAA,CAAC;IAC7B,CAAC;IAED,aAAa;QACX,OAAO,KAAK,CAAC,IAAI,CAAC,uBAAA,IAAI,yCAAU,CAAC,CAAC,CAAC,wCAAwC;IAC7E,CAAC;IAED,WAAW;QACT,MAAM,QAAQ,GAAG,EAAE,CAAC;QAEpB,KAAK,MAAM,EAAE,IAAI,uBAAA,IAAI,yCAAU,EAAE;YAC/B,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YAEpC,qEAAqE;YACrE,qEAAqE;YACrE,eAAe;YACf,IAAI,CAAC,OAAO,EAAE;gBACZ,OAAO,CAAC,IAAI,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;gBACjD,SAAS;aACV;YACD,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACxB;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,UAAU,CAAC,EAAa;QACtB,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,+BAA+B,EAAE,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,UAAU,CAAC,OAAwB;QACjC,uBAAA,IAAI,yCAAU,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC;IAED,cAAc;QACZ,OAAO,kCAA0B,CAAC;IACpC,CAAC;CACF;AAtDD,0DAsDC","sourcesContent":["import {\n toAccountGroupId,\n type AccountGroup,\n type AccountGroupId,\n type AccountWallet,\n} from '@metamask/account-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { AccountId } from '@metamask/keyring-utils';\nimport type { AccountTreeControllerMessenger } from 'src';\n\nexport const DEFAULT_ACCOUNT_GROUP_NAME: string = 'Default';\n\n/**\n * Account group coming from the {@link AccountTreeController}.\n */\nexport type AccountTreeGroup = {\n /**\n * Account IDs for that account group.\n */\n getAccountIds(): AccountId[];\n\n /**\n * Gets the default name for that account group.\n */\n getDefaultName(): string;\n} & AccountGroup<InternalAccount>;\n\n// This class is meant to be used internally by every rules. It exposes mutable operations\n// which should not leak outside of this package.\nexport class MutableAccountTreeGroup implements AccountTreeGroup {\n readonly id: AccountGroupId;\n\n readonly wallet: AccountWallet<InternalAccount>;\n\n readonly messenger: AccountTreeControllerMessenger;\n\n readonly #accounts: Set<AccountId>;\n\n constructor(\n messenger: AccountTreeControllerMessenger,\n wallet: AccountWallet<InternalAccount>,\n id: string,\n ) {\n this.id = toAccountGroupId(wallet.id, id);\n this.wallet = wallet;\n this.messenger = messenger;\n\n this.#accounts = new Set();\n }\n\n getAccountIds(): AccountId[] {\n return Array.from(this.#accounts); // FIXME: Should we force the copy here?\n }\n\n getAccounts(): InternalAccount[] {\n const accounts = [];\n\n for (const id of this.#accounts) {\n const account = this.getAccount(id);\n\n // FIXME: I'm really not sure we should skip those but... We could be\n // \"de-sync\" with the AccountsController and might have some dangling\n // account IDs.\n if (!account) {\n console.warn(`! Unable to get account: \"${id}\"`);\n continue;\n }\n accounts.push(account);\n }\n return accounts;\n }\n\n getAccount(id: AccountId): InternalAccount | undefined {\n return this.messenger.call('AccountsController:getAccount', id);\n }\n\n addAccount(account: InternalAccount) {\n this.#accounts.add(account.id);\n }\n\n getDefaultName(): string {\n return DEFAULT_ACCOUNT_GROUP_NAME;\n }\n}\n"]}
1
+ {"version":3,"file":"AccountTreeGroup.cjs","sourceRoot":"","sources":["../src/AccountTreeGroup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAQa,QAAA,0BAA0B,GAAW,SAAS,CAAC;AAE5D;;GAEG;AACH,MAAa,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,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,aAAa;QACX,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAExC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;SAC9C;QAED,OAAO,uBAAA,IAAI,iEAAY,MAAhB,IAAI,EAAa,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;IAED,cAAc;QACZ,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAExC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;SAC9C;QACD,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;SACvD;QAED,OAAO,uBAAA,IAAI,iEAAY,MAAhB,IAAI,EAAa,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;CACF;AA5ED,4CA4EC;kPAnCa,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 AccountGroup, type AccountGroupId } from '@metamask/account-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type {\n AccountGroupObject,\n AccountTreeControllerMessenger,\n AccountTreeWallet,\n} from 'src';\n\nexport const DEFAULT_ACCOUNT_GROUP_NAME: string = 'Default';\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 name(): string {\n return this.#group.metadata.name;\n }\n\n getAccountIds(): 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 getAnyAccount(): InternalAccount {\n const accountIds = this.getAccountIds();\n\n if (accountIds.length === 0) {\n throw new Error('Group contains no account');\n }\n\n return this.#getAccount(accountIds[0]);\n }\n\n getOnlyAccount(): InternalAccount {\n const accountIds = this.getAccountIds();\n\n if (accountIds.length === 0) {\n throw new Error('Group contains no account');\n }\n if (accountIds.length > 1) {\n throw new Error('Group contains more than 1 account');\n }\n\n return this.#getAccount(accountIds[0]);\n }\n}\n"]}
@@ -1,31 +1,24 @@
1
- import { type AccountGroup, type AccountGroupId, type AccountWallet } from "@metamask/account-api";
1
+ import { type AccountGroup, type AccountGroupId } from "@metamask/account-api";
2
2
  import type { InternalAccount } from "@metamask/keyring-internal-api";
3
- import type { AccountId } from "@metamask/keyring-utils";
4
- import type { AccountTreeControllerMessenger } from "src";
3
+ import type { AccountGroupObject, AccountTreeControllerMessenger, AccountTreeWallet } from "src";
5
4
  export declare const DEFAULT_ACCOUNT_GROUP_NAME: string;
6
5
  /**
7
6
  * Account group coming from the {@link AccountTreeController}.
8
7
  */
9
- export type AccountTreeGroup = {
10
- /**
11
- * Account IDs for that account group.
12
- */
13
- getAccountIds(): AccountId[];
14
- /**
15
- * Gets the default name for that account group.
16
- */
17
- getDefaultName(): string;
18
- } & AccountGroup<InternalAccount>;
19
- export declare class MutableAccountTreeGroup implements AccountTreeGroup {
8
+ export declare class AccountTreeGroup implements AccountGroup<InternalAccount> {
20
9
  #private;
21
- readonly id: AccountGroupId;
22
- readonly wallet: AccountWallet<InternalAccount>;
23
- readonly messenger: AccountTreeControllerMessenger;
24
- constructor(messenger: AccountTreeControllerMessenger, wallet: AccountWallet<InternalAccount>, id: string);
25
- getAccountIds(): AccountId[];
10
+ constructor({ messenger, wallet, group, }: {
11
+ messenger: AccountTreeControllerMessenger;
12
+ wallet: AccountTreeWallet;
13
+ group: AccountGroupObject;
14
+ });
15
+ get id(): AccountGroupId;
16
+ get wallet(): AccountTreeWallet;
17
+ get name(): string;
18
+ getAccountIds(): InternalAccount['id'][];
19
+ getAccount(id: string): InternalAccount | undefined;
26
20
  getAccounts(): InternalAccount[];
27
- getAccount(id: AccountId): InternalAccount | undefined;
28
- addAccount(account: InternalAccount): void;
29
- getDefaultName(): string;
21
+ getAnyAccount(): InternalAccount;
22
+ getOnlyAccount(): InternalAccount;
30
23
  }
31
24
  //# sourceMappingURL=AccountTreeGroup.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AccountTreeGroup.d.cts","sourceRoot":"","sources":["../src/AccountTreeGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,8BAA8B;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,gCAAgC;AACzD,OAAO,KAAK,EAAE,8BAA8B,EAAE,YAAY;AAE1D,eAAO,MAAM,0BAA0B,EAAE,MAAkB,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,aAAa,IAAI,SAAS,EAAE,CAAC;IAE7B;;OAEG;IACH,cAAc,IAAI,MAAM,CAAC;CAC1B,GAAG,YAAY,CAAC,eAAe,CAAC,CAAC;AAIlC,qBAAa,uBAAwB,YAAW,gBAAgB;;IAC9D,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAC;IAE5B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IAEhD,QAAQ,CAAC,SAAS,EAAE,8BAA8B,CAAC;gBAKjD,SAAS,EAAE,8BAA8B,EACzC,MAAM,EAAE,aAAa,CAAC,eAAe,CAAC,EACtC,EAAE,EAAE,MAAM;IASZ,aAAa,IAAI,SAAS,EAAE;IAI5B,WAAW,IAAI,eAAe,EAAE;IAkBhC,UAAU,CAAC,EAAE,EAAE,SAAS,GAAG,eAAe,GAAG,SAAS;IAItD,UAAU,CAAC,OAAO,EAAE,eAAe;IAInC,cAAc,IAAI,MAAM;CAGzB"}
1
+ {"version":3,"file":"AccountTreeGroup.d.cts","sourceRoot":"","sources":["../src/AccountTreeGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,8BAA8B;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,KAAK,EACV,kBAAkB,EAClB,8BAA8B,EAC9B,iBAAiB,EAClB,YAAY;AAEb,eAAO,MAAM,0BAA0B,EAAE,MAAkB,CAAC;AAE5D;;GAEG;AACH,qBAAa,gBAAiB,YAAW,YAAY,CAAC,eAAe,CAAC;;gBAOxD,EACV,SAAS,EACT,MAAM,EACN,KAAK,GACN,EAAE;QACD,SAAS,EAAE,8BAA8B,CAAC;QAC1C,MAAM,EAAE,iBAAiB,CAAC;QAC1B,KAAK,EAAE,kBAAkB,CAAC;KAC3B;IAMD,IAAI,EAAE,IAAI,cAAc,CAEvB;IAED,IAAI,MAAM,IAAI,iBAAiB,CAE9B;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,aAAa,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE;IAIxC,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAanD,WAAW,IAAI,eAAe,EAAE;IAIhC,aAAa,IAAI,eAAe;IAUhC,cAAc,IAAI,eAAe;CAYlC"}
@@ -1,31 +1,24 @@
1
- import { type AccountGroup, type AccountGroupId, type AccountWallet } from "@metamask/account-api";
1
+ import { type AccountGroup, type AccountGroupId } from "@metamask/account-api";
2
2
  import type { InternalAccount } from "@metamask/keyring-internal-api";
3
- import type { AccountId } from "@metamask/keyring-utils";
4
- import type { AccountTreeControllerMessenger } from "src";
3
+ import type { AccountGroupObject, AccountTreeControllerMessenger, AccountTreeWallet } from "src";
5
4
  export declare const DEFAULT_ACCOUNT_GROUP_NAME: string;
6
5
  /**
7
6
  * Account group coming from the {@link AccountTreeController}.
8
7
  */
9
- export type AccountTreeGroup = {
10
- /**
11
- * Account IDs for that account group.
12
- */
13
- getAccountIds(): AccountId[];
14
- /**
15
- * Gets the default name for that account group.
16
- */
17
- getDefaultName(): string;
18
- } & AccountGroup<InternalAccount>;
19
- export declare class MutableAccountTreeGroup implements AccountTreeGroup {
8
+ export declare class AccountTreeGroup implements AccountGroup<InternalAccount> {
20
9
  #private;
21
- readonly id: AccountGroupId;
22
- readonly wallet: AccountWallet<InternalAccount>;
23
- readonly messenger: AccountTreeControllerMessenger;
24
- constructor(messenger: AccountTreeControllerMessenger, wallet: AccountWallet<InternalAccount>, id: string);
25
- getAccountIds(): AccountId[];
10
+ constructor({ messenger, wallet, group, }: {
11
+ messenger: AccountTreeControllerMessenger;
12
+ wallet: AccountTreeWallet;
13
+ group: AccountGroupObject;
14
+ });
15
+ get id(): AccountGroupId;
16
+ get wallet(): AccountTreeWallet;
17
+ get name(): string;
18
+ getAccountIds(): InternalAccount['id'][];
19
+ getAccount(id: string): InternalAccount | undefined;
26
20
  getAccounts(): InternalAccount[];
27
- getAccount(id: AccountId): InternalAccount | undefined;
28
- addAccount(account: InternalAccount): void;
29
- getDefaultName(): string;
21
+ getAnyAccount(): InternalAccount;
22
+ getOnlyAccount(): InternalAccount;
30
23
  }
31
24
  //# sourceMappingURL=AccountTreeGroup.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AccountTreeGroup.d.mts","sourceRoot":"","sources":["../src/AccountTreeGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,8BAA8B;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,gCAAgC;AACzD,OAAO,KAAK,EAAE,8BAA8B,EAAE,YAAY;AAE1D,eAAO,MAAM,0BAA0B,EAAE,MAAkB,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,aAAa,IAAI,SAAS,EAAE,CAAC;IAE7B;;OAEG;IACH,cAAc,IAAI,MAAM,CAAC;CAC1B,GAAG,YAAY,CAAC,eAAe,CAAC,CAAC;AAIlC,qBAAa,uBAAwB,YAAW,gBAAgB;;IAC9D,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAC;IAE5B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IAEhD,QAAQ,CAAC,SAAS,EAAE,8BAA8B,CAAC;gBAKjD,SAAS,EAAE,8BAA8B,EACzC,MAAM,EAAE,aAAa,CAAC,eAAe,CAAC,EACtC,EAAE,EAAE,MAAM;IASZ,aAAa,IAAI,SAAS,EAAE;IAI5B,WAAW,IAAI,eAAe,EAAE;IAkBhC,UAAU,CAAC,EAAE,EAAE,SAAS,GAAG,eAAe,GAAG,SAAS;IAItD,UAAU,CAAC,OAAO,EAAE,eAAe;IAInC,cAAc,IAAI,MAAM;CAGzB"}
1
+ {"version":3,"file":"AccountTreeGroup.d.mts","sourceRoot":"","sources":["../src/AccountTreeGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,8BAA8B;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,KAAK,EACV,kBAAkB,EAClB,8BAA8B,EAC9B,iBAAiB,EAClB,YAAY;AAEb,eAAO,MAAM,0BAA0B,EAAE,MAAkB,CAAC;AAE5D;;GAEG;AACH,qBAAa,gBAAiB,YAAW,YAAY,CAAC,eAAe,CAAC;;gBAOxD,EACV,SAAS,EACT,MAAM,EACN,KAAK,GACN,EAAE;QACD,SAAS,EAAE,8BAA8B,CAAC;QAC1C,MAAM,EAAE,iBAAiB,CAAC;QAC1B,KAAK,EAAE,kBAAkB,CAAC;KAC3B;IAMD,IAAI,EAAE,IAAI,cAAc,CAEvB;IAED,IAAI,MAAM,IAAI,iBAAiB,CAE9B;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,aAAa,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE;IAIxC,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAanD,WAAW,IAAI,eAAe,EAAE;IAIhC,aAAa,IAAI,eAAe;IAUhC,cAAc,IAAI,eAAe;CAYlC"}
@@ -9,46 +9,62 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _MutableAccountTreeGroup_accounts;
13
- import { toAccountGroupId } from "@metamask/account-api";
12
+ var _AccountTreeGroup_instances, _AccountTreeGroup_messenger, _AccountTreeGroup_group, _AccountTreeGroup_wallet, _AccountTreeGroup_getAccount;
14
13
  export const DEFAULT_ACCOUNT_GROUP_NAME = 'Default';
15
- // This class is meant to be used internally by every rules. It exposes mutable operations
16
- // which should not leak outside of this package.
17
- export class MutableAccountTreeGroup {
18
- constructor(messenger, wallet, id) {
19
- _MutableAccountTreeGroup_accounts.set(this, void 0);
20
- this.id = toAccountGroupId(wallet.id, id);
21
- this.wallet = wallet;
22
- this.messenger = messenger;
23
- __classPrivateFieldSet(this, _MutableAccountTreeGroup_accounts, new Set(), "f");
14
+ /**
15
+ * Account group coming from the {@link AccountTreeController}.
16
+ */
17
+ export class AccountTreeGroup {
18
+ constructor({ messenger, wallet, group, }) {
19
+ _AccountTreeGroup_instances.add(this);
20
+ _AccountTreeGroup_messenger.set(this, void 0);
21
+ _AccountTreeGroup_group.set(this, void 0);
22
+ _AccountTreeGroup_wallet.set(this, void 0);
23
+ __classPrivateFieldSet(this, _AccountTreeGroup_messenger, messenger, "f");
24
+ __classPrivateFieldSet(this, _AccountTreeGroup_group, group, "f");
25
+ __classPrivateFieldSet(this, _AccountTreeGroup_wallet, wallet, "f");
24
26
  }
25
- getAccountIds() {
26
- return Array.from(__classPrivateFieldGet(this, _MutableAccountTreeGroup_accounts, "f")); // FIXME: Should we force the copy here?
27
+ get id() {
28
+ return __classPrivateFieldGet(this, _AccountTreeGroup_group, "f").id;
27
29
  }
28
- getAccounts() {
29
- const accounts = [];
30
- for (const id of __classPrivateFieldGet(this, _MutableAccountTreeGroup_accounts, "f")) {
31
- const account = this.getAccount(id);
32
- // FIXME: I'm really not sure we should skip those but... We could be
33
- // "de-sync" with the AccountsController and might have some dangling
34
- // account IDs.
35
- if (!account) {
36
- console.warn(`! Unable to get account: "${id}"`);
37
- continue;
38
- }
39
- accounts.push(account);
40
- }
41
- return accounts;
30
+ get wallet() {
31
+ return __classPrivateFieldGet(this, _AccountTreeGroup_wallet, "f");
32
+ }
33
+ get name() {
34
+ return __classPrivateFieldGet(this, _AccountTreeGroup_group, "f").metadata.name;
35
+ }
36
+ getAccountIds() {
37
+ return __classPrivateFieldGet(this, _AccountTreeGroup_group, "f").accounts;
42
38
  }
43
39
  getAccount(id) {
44
- return this.messenger.call('AccountsController:getAccount', id);
40
+ return __classPrivateFieldGet(this, _AccountTreeGroup_messenger, "f").call('AccountsController:getAccount', id);
45
41
  }
46
- addAccount(account) {
47
- __classPrivateFieldGet(this, _MutableAccountTreeGroup_accounts, "f").add(account.id);
42
+ getAccounts() {
43
+ return __classPrivateFieldGet(this, _AccountTreeGroup_group, "f").accounts.map((id) => __classPrivateFieldGet(this, _AccountTreeGroup_instances, "m", _AccountTreeGroup_getAccount).call(this, id));
48
44
  }
49
- getDefaultName() {
50
- return DEFAULT_ACCOUNT_GROUP_NAME;
45
+ getAnyAccount() {
46
+ const accountIds = this.getAccountIds();
47
+ if (accountIds.length === 0) {
48
+ throw new Error('Group contains no account');
49
+ }
50
+ return __classPrivateFieldGet(this, _AccountTreeGroup_instances, "m", _AccountTreeGroup_getAccount).call(this, accountIds[0]);
51
+ }
52
+ getOnlyAccount() {
53
+ const accountIds = this.getAccountIds();
54
+ if (accountIds.length === 0) {
55
+ throw new Error('Group contains no account');
56
+ }
57
+ if (accountIds.length > 1) {
58
+ throw new Error('Group contains more than 1 account');
59
+ }
60
+ return __classPrivateFieldGet(this, _AccountTreeGroup_instances, "m", _AccountTreeGroup_getAccount).call(this, accountIds[0]);
51
61
  }
52
62
  }
53
- _MutableAccountTreeGroup_accounts = new WeakMap();
63
+ _AccountTreeGroup_messenger = new WeakMap(), _AccountTreeGroup_group = new WeakMap(), _AccountTreeGroup_wallet = new WeakMap(), _AccountTreeGroup_instances = new WeakSet(), _AccountTreeGroup_getAccount = function _AccountTreeGroup_getAccount(id) {
64
+ const account = this.getAccount(id);
65
+ if (!account) {
66
+ throw new Error(`Unable to get account with ID: "${id}"`);
67
+ }
68
+ return account;
69
+ };
54
70
  //# sourceMappingURL=AccountTreeGroup.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"AccountTreeGroup.mjs","sourceRoot":"","sources":["../src/AccountTreeGroup.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EACL,gBAAgB,EAIjB,8BAA8B;AAK/B,MAAM,CAAC,MAAM,0BAA0B,GAAW,SAAS,CAAC;AAiB5D,0FAA0F;AAC1F,iDAAiD;AACjD,MAAM,OAAO,uBAAuB;IASlC,YACE,SAAyC,EACzC,MAAsC,EACtC,EAAU;QALH,oDAA0B;QAOjC,IAAI,CAAC,EAAE,GAAG,gBAAgB,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAE3B,uBAAA,IAAI,qCAAa,IAAI,GAAG,EAAE,MAAA,CAAC;IAC7B,CAAC;IAED,aAAa;QACX,OAAO,KAAK,CAAC,IAAI,CAAC,uBAAA,IAAI,yCAAU,CAAC,CAAC,CAAC,wCAAwC;IAC7E,CAAC;IAED,WAAW;QACT,MAAM,QAAQ,GAAG,EAAE,CAAC;QAEpB,KAAK,MAAM,EAAE,IAAI,uBAAA,IAAI,yCAAU,EAAE;YAC/B,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YAEpC,qEAAqE;YACrE,qEAAqE;YACrE,eAAe;YACf,IAAI,CAAC,OAAO,EAAE;gBACZ,OAAO,CAAC,IAAI,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;gBACjD,SAAS;aACV;YACD,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACxB;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,UAAU,CAAC,EAAa;QACtB,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,+BAA+B,EAAE,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,UAAU,CAAC,OAAwB;QACjC,uBAAA,IAAI,yCAAU,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC;IAED,cAAc;QACZ,OAAO,0BAA0B,CAAC;IACpC,CAAC;CACF","sourcesContent":["import {\n toAccountGroupId,\n type AccountGroup,\n type AccountGroupId,\n type AccountWallet,\n} from '@metamask/account-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { AccountId } from '@metamask/keyring-utils';\nimport type { AccountTreeControllerMessenger } from 'src';\n\nexport const DEFAULT_ACCOUNT_GROUP_NAME: string = 'Default';\n\n/**\n * Account group coming from the {@link AccountTreeController}.\n */\nexport type AccountTreeGroup = {\n /**\n * Account IDs for that account group.\n */\n getAccountIds(): AccountId[];\n\n /**\n * Gets the default name for that account group.\n */\n getDefaultName(): string;\n} & AccountGroup<InternalAccount>;\n\n// This class is meant to be used internally by every rules. It exposes mutable operations\n// which should not leak outside of this package.\nexport class MutableAccountTreeGroup implements AccountTreeGroup {\n readonly id: AccountGroupId;\n\n readonly wallet: AccountWallet<InternalAccount>;\n\n readonly messenger: AccountTreeControllerMessenger;\n\n readonly #accounts: Set<AccountId>;\n\n constructor(\n messenger: AccountTreeControllerMessenger,\n wallet: AccountWallet<InternalAccount>,\n id: string,\n ) {\n this.id = toAccountGroupId(wallet.id, id);\n this.wallet = wallet;\n this.messenger = messenger;\n\n this.#accounts = new Set();\n }\n\n getAccountIds(): AccountId[] {\n return Array.from(this.#accounts); // FIXME: Should we force the copy here?\n }\n\n getAccounts(): InternalAccount[] {\n const accounts = [];\n\n for (const id of this.#accounts) {\n const account = this.getAccount(id);\n\n // FIXME: I'm really not sure we should skip those but... We could be\n // \"de-sync\" with the AccountsController and might have some dangling\n // account IDs.\n if (!account) {\n console.warn(`! Unable to get account: \"${id}\"`);\n continue;\n }\n accounts.push(account);\n }\n return accounts;\n }\n\n getAccount(id: AccountId): InternalAccount | undefined {\n return this.messenger.call('AccountsController:getAccount', id);\n }\n\n addAccount(account: InternalAccount) {\n this.#accounts.add(account.id);\n }\n\n getDefaultName(): string {\n return DEFAULT_ACCOUNT_GROUP_NAME;\n }\n}\n"]}
1
+ {"version":3,"file":"AccountTreeGroup.mjs","sourceRoot":"","sources":["../src/AccountTreeGroup.ts"],"names":[],"mappings":";;;;;;;;;;;;AAQA,MAAM,CAAC,MAAM,0BAA0B,GAAW,SAAS,CAAC;AAE5D;;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,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,aAAa;QACX,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAExC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;SAC9C;QAED,OAAO,uBAAA,IAAI,iEAAY,MAAhB,IAAI,EAAa,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;IAED,cAAc;QACZ,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAExC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;SAC9C;QACD,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;SACvD;QAED,OAAO,uBAAA,IAAI,iEAAY,MAAhB,IAAI,EAAa,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;CACF;kPAnCa,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 AccountGroup, type AccountGroupId } from '@metamask/account-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type {\n AccountGroupObject,\n AccountTreeControllerMessenger,\n AccountTreeWallet,\n} from 'src';\n\nexport const DEFAULT_ACCOUNT_GROUP_NAME: string = 'Default';\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 name(): string {\n return this.#group.metadata.name;\n }\n\n getAccountIds(): 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 getAnyAccount(): InternalAccount {\n const accountIds = this.getAccountIds();\n\n if (accountIds.length === 0) {\n throw new Error('Group contains no account');\n }\n\n return this.#getAccount(accountIds[0]);\n }\n\n getOnlyAccount(): InternalAccount {\n const accountIds = this.getAccountIds();\n\n if (accountIds.length === 0) {\n throw new Error('Group contains no account');\n }\n if (accountIds.length > 1) {\n throw new Error('Group contains more than 1 account');\n }\n\n return this.#getAccount(accountIds[0]);\n }\n}\n"]}
@@ -10,41 +10,75 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _MutableAccountTreeWallet_groups;
13
+ var _AccountTreeWallet_messenger, _AccountTreeWallet_wallet, _AccountTreeWallet_groups;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.MutableAccountTreeWallet = void 0;
16
- const account_api_1 = require("@metamask/account-api");
15
+ exports.AccountTreeWallet = void 0;
17
16
  const AccountTreeGroup_1 = require("./AccountTreeGroup.cjs");
18
- // This class is meant to be used internally by every rules. It exposes mutable operations
19
- // which should not leak outside of this package.
20
- class MutableAccountTreeWallet {
21
- constructor(messenger, category, id) {
22
- _MutableAccountTreeWallet_groups.set(this, void 0);
23
- this.id = (0, account_api_1.toAccountWalletId)(category, id);
24
- this.category = category;
25
- this.messenger = messenger;
26
- __classPrivateFieldSet(this, _MutableAccountTreeWallet_groups, new Map(), "f");
17
+ /**
18
+ * Account wallet coming from the {@link AccountTreeController}.
19
+ */
20
+ class AccountTreeWallet {
21
+ constructor({ messenger, wallet, }) {
22
+ _AccountTreeWallet_messenger.set(this, void 0);
23
+ _AccountTreeWallet_wallet.set(this, void 0);
24
+ _AccountTreeWallet_groups.set(this, void 0);
25
+ __classPrivateFieldSet(this, _AccountTreeWallet_messenger, messenger, "f");
26
+ __classPrivateFieldSet(this, _AccountTreeWallet_wallet, wallet, "f");
27
+ __classPrivateFieldSet(this, _AccountTreeWallet_groups, new Map(), "f");
28
+ for (const [groupId, group] of Object.entries(__classPrivateFieldGet(this, _AccountTreeWallet_wallet, "f").groups)) {
29
+ __classPrivateFieldGet(this, _AccountTreeWallet_groups, "f").set(groupId, new AccountTreeGroup_1.AccountTreeGroup({
30
+ messenger: __classPrivateFieldGet(this, _AccountTreeWallet_messenger, "f"),
31
+ wallet: this,
32
+ group,
33
+ }));
34
+ }
35
+ }
36
+ get id() {
37
+ return __classPrivateFieldGet(this, _AccountTreeWallet_wallet, "f").id;
38
+ }
39
+ get category() {
40
+ return __classPrivateFieldGet(this, _AccountTreeWallet_wallet, "f").category;
41
+ }
42
+ get name() {
43
+ return __classPrivateFieldGet(this, _AccountTreeWallet_wallet, "f").metadata.name;
27
44
  }
45
+ /**
46
+ * Gets account tree group for a given ID.
47
+ *
48
+ * @param groupId - Group ID.
49
+ * @returns Account tree group.
50
+ */
28
51
  getAccountGroup(groupId) {
29
- return __classPrivateFieldGet(this, _MutableAccountTreeWallet_groups, "f").get(groupId);
52
+ return __classPrivateFieldGet(this, _AccountTreeWallet_groups, "f").get(groupId);
30
53
  }
54
+ /**
55
+ * Gets all account tree groups.
56
+ *
57
+ * @returns Account tree groups.
58
+ */
31
59
  getAccountGroups() {
32
- return Array.from(__classPrivateFieldGet(this, _MutableAccountTreeWallet_groups, "f").values()); // TODO: Should we avoid the copy here?
60
+ return Array.from(__classPrivateFieldGet(this, _AccountTreeWallet_groups, "f").values());
33
61
  }
34
- // NOTE: This method SHOULD BE overriden if a rule need to group things differently.
35
- addAccount(account) {
36
- const id = account_api_1.DEFAULT_ACCOUNT_GROUP_UNIQUE_ID;
37
- // Use a single-group by default.
38
- let group = __classPrivateFieldGet(this, _MutableAccountTreeWallet_groups, "f").get((0, account_api_1.toAccountGroupId)(this.id, id));
39
- if (!group) {
40
- // We create the account group and attach it to this wallet.
41
- group = new AccountTreeGroup_1.MutableAccountTreeGroup(this.messenger, this, id);
42
- __classPrivateFieldGet(this, _MutableAccountTreeWallet_groups, "f").set(group.id, group);
62
+ /**
63
+ * Gets any underlying account.
64
+ *
65
+ * This can be useful if the accounts from this wallet have been grouped some
66
+ * common criteria, so you expect some commonly defined information on any of
67
+ * those accounts.
68
+ *
69
+ * @throws If the wallet has no account group (which should not be possible).
70
+ * @returns Any account that share the same information based on the grouping
71
+ * rule that has been used.
72
+ */
73
+ getAnyAccount() {
74
+ if (__classPrivateFieldGet(this, _AccountTreeWallet_groups, "f").size === 0) {
75
+ throw new Error('Wallet contains no account group');
43
76
  }
44
- group.addAccount(account);
45
- return group;
77
+ // It cannot be `undefined`, we checked the size before.
78
+ const group = __classPrivateFieldGet(this, _AccountTreeWallet_groups, "f").values().next().value;
79
+ return group.getAnyAccount();
46
80
  }
47
81
  }
48
- exports.MutableAccountTreeWallet = MutableAccountTreeWallet;
49
- _MutableAccountTreeWallet_groups = new WeakMap();
82
+ exports.AccountTreeWallet = AccountTreeWallet;
83
+ _AccountTreeWallet_messenger = new WeakMap(), _AccountTreeWallet_wallet = new WeakMap(), _AccountTreeWallet_groups = new WeakMap();
50
84
  //# sourceMappingURL=AccountTreeWallet.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"AccountTreeWallet.cjs","sourceRoot":"","sources":["../src/AccountTreeWallet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAQ+B;AAK/B,6DAA6D;AA0B7D,0FAA0F;AAC1F,iDAAiD;AACjD,MAAsB,wBAAwB;IAS5C,YACE,SAAyC,EACzC,QAA+B,EAC/B,EAAU;QALH,mDAAsD;QAO7D,IAAI,CAAC,EAAE,GAAG,IAAA,+BAAiB,EAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAE3B,uBAAA,IAAI,oCAAW,IAAI,GAAG,EAAE,MAAA,CAAC;IAC3B,CAAC;IAED,eAAe,CAAC,OAAuB;QACrC,OAAO,uBAAA,IAAI,wCAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,gBAAgB;QACd,OAAO,KAAK,CAAC,IAAI,CAAC,uBAAA,IAAI,wCAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,uCAAuC;IACnF,CAAC;IAED,oFAAoF;IACpF,UAAU,CAAC,OAAwB;QACjC,MAAM,EAAE,GAAG,6CAA+B,CAAC;QAE3C,iCAAiC;QACjC,IAAI,KAAK,GAAG,uBAAA,IAAI,wCAAQ,CAAC,GAAG,CAAC,IAAA,8BAAgB,EAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;QAC5D,IAAI,CAAC,KAAK,EAAE;YACV,4DAA4D;YAC5D,KAAK,GAAG,IAAI,0CAAuB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;YAC9D,uBAAA,IAAI,wCAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;SACnC;QAED,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAE1B,OAAO,KAAK,CAAC;IACf,CAAC;CAGF;AA/CD,4DA+CC","sourcesContent":["import {\n toAccountGroupId,\n toAccountWalletId,\n DEFAULT_ACCOUNT_GROUP_UNIQUE_ID,\n type AccountGroupId,\n type AccountWallet,\n type AccountWalletCategory,\n type AccountWalletId,\n} from '@metamask/account-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { type AccountTreeControllerMessenger } from './AccountTreeController';\nimport type { AccountTreeGroup } from './AccountTreeGroup';\nimport { MutableAccountTreeGroup } from './AccountTreeGroup';\n\n/**\n * Account wallet coming from the {@link AccountTreeController}.\n */\nexport type AccountTreeWallet = {\n /**\n * Gets account tree group for a given ID.\n *\n * @returns Account tree group.\n */\n getAccountGroup(groupId: AccountGroupId): AccountTreeGroup | undefined;\n\n /**\n * Gets all account tree groups.\n *\n * @returns Account tree groups.\n */\n getAccountGroups(): AccountTreeGroup[];\n\n /**\n * Gets the default name for that account wallet.\n */\n getDefaultName(): string;\n} & AccountWallet<InternalAccount>;\n\n// This class is meant to be used internally by every rules. It exposes mutable operations\n// which should not leak outside of this package.\nexport abstract class MutableAccountTreeWallet implements AccountTreeWallet {\n readonly id: AccountWalletId;\n\n readonly category: AccountWalletCategory;\n\n readonly messenger: AccountTreeControllerMessenger;\n\n readonly #groups: Map<AccountGroupId, MutableAccountTreeGroup>;\n\n constructor(\n messenger: AccountTreeControllerMessenger,\n category: AccountWalletCategory,\n id: string,\n ) {\n this.id = toAccountWalletId(category, id);\n this.category = category;\n this.messenger = messenger;\n\n this.#groups = new Map();\n }\n\n getAccountGroup(groupId: AccountGroupId): AccountTreeGroup | undefined {\n return this.#groups.get(groupId);\n }\n\n getAccountGroups(): AccountTreeGroup[] {\n return Array.from(this.#groups.values()); // TODO: Should we avoid the copy here?\n }\n\n // NOTE: This method SHOULD BE overriden if a rule need to group things differently.\n addAccount(account: InternalAccount): MutableAccountTreeGroup {\n const id = DEFAULT_ACCOUNT_GROUP_UNIQUE_ID;\n\n // Use a single-group by default.\n let group = this.#groups.get(toAccountGroupId(this.id, id));\n if (!group) {\n // We create the account group and attach it to this wallet.\n group = new MutableAccountTreeGroup(this.messenger, this, id);\n this.#groups.set(group.id, group);\n }\n\n group.addAccount(account);\n\n return group;\n }\n\n abstract getDefaultName(): string;\n}\n"]}
1
+ {"version":3,"file":"AccountTreeWallet.cjs","sourceRoot":"","sources":["../src/AccountTreeWallet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AASA,6DAAsD;AAEtD;;GAEG;AACH,MAAa,iBAAiB;IAO5B,YAAY,EACV,SAAS,EACT,MAAM,GAIP;QAZQ,+CAA2C;QAE3C,4CAA6B;QAE7B,4CAA+C;QAStD,uBAAA,IAAI,gCAAc,SAAS,MAAA,CAAC;QAC5B,uBAAA,IAAI,6BAAW,MAAM,MAAA,CAAC;QACtB,uBAAA,IAAI,6BAAW,IAAI,GAAG,EAAE,MAAA,CAAC;QAEzB,KAAK,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,uBAAA,IAAI,iCAAQ,CAAC,MAAM,CAAC,EAAE;YAClE,uBAAA,IAAI,iCAAQ,CAAC,GAAG,CACd,OAAyB,EACzB,IAAI,mCAAgB,CAAC;gBACnB,SAAS,EAAE,uBAAA,IAAI,oCAAW;gBAC1B,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,QAAQ;QACV,OAAO,uBAAA,IAAI,iCAAQ,CAAC,QAAQ,CAAC;IAC/B,CAAC;IAED,IAAI,IAAI;QACN,OAAO,uBAAA,IAAI,iCAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;IACpC,CAAC;IAED;;;;;OAKG;IACH,eAAe,CAAC,OAAuB;QACrC,OAAO,uBAAA,IAAI,iCAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,gBAAgB;QACd,OAAO,KAAK,CAAC,IAAI,CAAC,uBAAA,IAAI,iCAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;;;;;OAUG;IACH,aAAa;QACX,IAAI,uBAAA,IAAI,iCAAQ,CAAC,IAAI,KAAK,CAAC,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;SACrD;QAED,wDAAwD;QACxD,MAAM,KAAK,GAAG,uBAAA,IAAI,iCAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAyB,CAAC;QACrE,OAAO,KAAK,CAAC,aAAa,EAAE,CAAC;IAC/B,CAAC;CACF;AAjFD,8CAiFC","sourcesContent":["import type {\n AccountWalletCategory,\n AccountWalletId,\n} from '@metamask/account-api';\nimport { type AccountGroupId, type AccountWallet } from '@metamask/account-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport type { AccountWalletObject } from './AccountTreeController';\nimport { type AccountTreeControllerMessenger } from './AccountTreeController';\nimport { AccountTreeGroup } from './AccountTreeGroup';\n\n/**\n * Account wallet coming from the {@link AccountTreeController}.\n */\nexport class AccountTreeWallet implements AccountWallet<InternalAccount> {\n readonly #messenger: AccountTreeControllerMessenger;\n\n readonly #wallet: AccountWalletObject;\n\n readonly #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 category(): AccountWalletCategory {\n return this.#wallet.category;\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.\n */\n getAccountGroup(groupId: AccountGroupId): AccountTreeGroup | undefined {\n return this.#groups.get(groupId);\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 /**\n * Gets any underlying account.\n *\n * This can be useful if the accounts from this wallet have been grouped some\n * common criteria, so you expect some commonly defined information on any of\n * those accounts.\n *\n * @throws If the wallet has no account group (which should not be possible).\n * @returns Any account that share the same information based on the grouping\n * rule that has been used.\n */\n getAnyAccount(): InternalAccount {\n if (this.#groups.size === 0) {\n throw new Error('Wallet contains no account group');\n }\n\n // It cannot be `undefined`, we checked the size before.\n const group = this.#groups.values().next().value as AccountTreeGroup;\n return group.getAnyAccount();\n }\n}\n"]}
@@ -1,15 +1,25 @@
1
- import { type AccountGroupId, type AccountWallet, type AccountWalletCategory, type AccountWalletId } from "@metamask/account-api";
1
+ import type { AccountWalletCategory, AccountWalletId } from "@metamask/account-api";
2
+ import { type AccountGroupId, type AccountWallet } from "@metamask/account-api";
2
3
  import type { InternalAccount } from "@metamask/keyring-internal-api";
4
+ import type { AccountWalletObject } from "./AccountTreeController.cjs";
3
5
  import { type AccountTreeControllerMessenger } from "./AccountTreeController.cjs";
4
- import type { AccountTreeGroup } from "./AccountTreeGroup.cjs";
5
- import { MutableAccountTreeGroup } from "./AccountTreeGroup.cjs";
6
+ import { AccountTreeGroup } from "./AccountTreeGroup.cjs";
6
7
  /**
7
8
  * Account wallet coming from the {@link AccountTreeController}.
8
9
  */
9
- export type AccountTreeWallet = {
10
+ export declare class AccountTreeWallet implements AccountWallet<InternalAccount> {
11
+ #private;
12
+ constructor({ messenger, wallet, }: {
13
+ messenger: AccountTreeControllerMessenger;
14
+ wallet: AccountWalletObject;
15
+ });
16
+ get id(): AccountWalletId;
17
+ get category(): AccountWalletCategory;
18
+ get name(): string;
10
19
  /**
11
20
  * Gets account tree group for a given ID.
12
21
  *
22
+ * @param groupId - Group ID.
13
23
  * @returns Account tree group.
14
24
  */
15
25
  getAccountGroup(groupId: AccountGroupId): AccountTreeGroup | undefined;
@@ -20,19 +30,16 @@ export type AccountTreeWallet = {
20
30
  */
21
31
  getAccountGroups(): AccountTreeGroup[];
22
32
  /**
23
- * Gets the default name for that account wallet.
33
+ * Gets any underlying account.
34
+ *
35
+ * This can be useful if the accounts from this wallet have been grouped some
36
+ * common criteria, so you expect some commonly defined information on any of
37
+ * those accounts.
38
+ *
39
+ * @throws If the wallet has no account group (which should not be possible).
40
+ * @returns Any account that share the same information based on the grouping
41
+ * rule that has been used.
24
42
  */
25
- getDefaultName(): string;
26
- } & AccountWallet<InternalAccount>;
27
- export declare abstract class MutableAccountTreeWallet implements AccountTreeWallet {
28
- #private;
29
- readonly id: AccountWalletId;
30
- readonly category: AccountWalletCategory;
31
- readonly messenger: AccountTreeControllerMessenger;
32
- constructor(messenger: AccountTreeControllerMessenger, category: AccountWalletCategory, id: string);
33
- getAccountGroup(groupId: AccountGroupId): AccountTreeGroup | undefined;
34
- getAccountGroups(): AccountTreeGroup[];
35
- addAccount(account: InternalAccount): MutableAccountTreeGroup;
36
- abstract getDefaultName(): string;
43
+ getAnyAccount(): InternalAccount;
37
44
  }
38
45
  //# sourceMappingURL=AccountTreeWallet.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AccountTreeWallet.d.cts","sourceRoot":"","sources":["../src/AccountTreeWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACrB,8BAA8B;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,EAAE,KAAK,8BAA8B,EAAE,oCAAgC;AAC9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,+BAA2B;AAC3D,OAAO,EAAE,uBAAuB,EAAE,+BAA2B;AAE7D;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;;OAIG;IACH,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,gBAAgB,GAAG,SAAS,CAAC;IAEvE;;;;OAIG;IACH,gBAAgB,IAAI,gBAAgB,EAAE,CAAC;IAEvC;;OAEG;IACH,cAAc,IAAI,MAAM,CAAC;CAC1B,GAAG,aAAa,CAAC,eAAe,CAAC,CAAC;AAInC,8BAAsB,wBAAyB,YAAW,iBAAiB;;IACzE,QAAQ,CAAC,EAAE,EAAE,eAAe,CAAC;IAE7B,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAAC;IAEzC,QAAQ,CAAC,SAAS,EAAE,8BAA8B,CAAC;gBAKjD,SAAS,EAAE,8BAA8B,EACzC,QAAQ,EAAE,qBAAqB,EAC/B,EAAE,EAAE,MAAM;IASZ,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,gBAAgB,GAAG,SAAS;IAItE,gBAAgB,IAAI,gBAAgB,EAAE;IAKtC,UAAU,CAAC,OAAO,EAAE,eAAe,GAAG,uBAAuB;IAgB7D,QAAQ,CAAC,cAAc,IAAI,MAAM;CAClC"}
1
+ {"version":3,"file":"AccountTreeWallet.d.cts","sourceRoot":"","sources":["../src/AccountTreeWallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EAChB,8BAA8B;AAC/B,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,8BAA8B;AAChF,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,oCAAgC;AACnE,OAAO,EAAE,KAAK,8BAA8B,EAAE,oCAAgC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,+BAA2B;AAEtD;;GAEG;AACH,qBAAa,iBAAkB,YAAW,aAAa,CAAC,eAAe,CAAC;;gBAO1D,EACV,SAAS,EACT,MAAM,GACP,EAAE;QACD,SAAS,EAAE,8BAA8B,CAAC;QAC1C,MAAM,EAAE,mBAAmB,CAAC;KAC7B;IAiBD,IAAI,EAAE,IAAI,eAAe,CAExB;IAED,IAAI,QAAQ,IAAI,qBAAqB,CAEpC;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;;OAKG;IACH,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,gBAAgB,GAAG,SAAS;IAItE;;;;OAIG;IACH,gBAAgB,IAAI,gBAAgB,EAAE;IAItC;;;;;;;;;;OAUG;IACH,aAAa,IAAI,eAAe;CASjC"}