@metamask-previews/keyring-sdk 1.1.0-8ff7ba2

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 (51) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +47 -0
  3. package/dist/eth/eth-keyring-wrapper.cjs +164 -0
  4. package/dist/eth/eth-keyring-wrapper.cjs.map +1 -0
  5. package/dist/eth/eth-keyring-wrapper.d.cts +53 -0
  6. package/dist/eth/eth-keyring-wrapper.d.cts.map +1 -0
  7. package/dist/eth/eth-keyring-wrapper.d.mts +53 -0
  8. package/dist/eth/eth-keyring-wrapper.d.mts.map +1 -0
  9. package/dist/eth/eth-keyring-wrapper.mjs +160 -0
  10. package/dist/eth/eth-keyring-wrapper.mjs.map +1 -0
  11. package/dist/eth/index.cjs +18 -0
  12. package/dist/eth/index.cjs.map +1 -0
  13. package/dist/eth/index.d.cts +2 -0
  14. package/dist/eth/index.d.cts.map +1 -0
  15. package/dist/eth/index.d.mts +2 -0
  16. package/dist/eth/index.d.mts.map +1 -0
  17. package/dist/eth/index.mjs +2 -0
  18. package/dist/eth/index.mjs.map +1 -0
  19. package/dist/index.cjs +21 -0
  20. package/dist/index.cjs.map +1 -0
  21. package/dist/index.d.cts +5 -0
  22. package/dist/index.d.cts.map +1 -0
  23. package/dist/index.d.mts +5 -0
  24. package/dist/index.d.mts.map +1 -0
  25. package/dist/index.mjs +5 -0
  26. package/dist/index.mjs.map +1 -0
  27. package/dist/keyring-account-registry.cjs +135 -0
  28. package/dist/keyring-account-registry.cjs.map +1 -0
  29. package/dist/keyring-account-registry.d.cts +88 -0
  30. package/dist/keyring-account-registry.d.cts.map +1 -0
  31. package/dist/keyring-account-registry.d.mts +88 -0
  32. package/dist/keyring-account-registry.d.mts.map +1 -0
  33. package/dist/keyring-account-registry.mjs +131 -0
  34. package/dist/keyring-account-registry.mjs.map +1 -0
  35. package/dist/keyring-wrapper.cjs +134 -0
  36. package/dist/keyring-wrapper.cjs.map +1 -0
  37. package/dist/keyring-wrapper.d.cts +149 -0
  38. package/dist/keyring-wrapper.d.cts.map +1 -0
  39. package/dist/keyring-wrapper.d.mts +149 -0
  40. package/dist/keyring-wrapper.d.mts.map +1 -0
  41. package/dist/keyring-wrapper.mjs +130 -0
  42. package/dist/keyring-wrapper.mjs.map +1 -0
  43. package/dist/mnemonic.cjs +20 -0
  44. package/dist/mnemonic.cjs.map +1 -0
  45. package/dist/mnemonic.d.cts +8 -0
  46. package/dist/mnemonic.d.cts.map +1 -0
  47. package/dist/mnemonic.d.mts +8 -0
  48. package/dist/mnemonic.d.mts.map +1 -0
  49. package/dist/mnemonic.mjs +17 -0
  50. package/dist/mnemonic.mjs.map +1 -0
  51. package/package.json +95 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAkC;AAClC,iEAA2C;AAC3C,iDAA2B;AAC3B,kDAAsB","sourcesContent":["export * from './keyring-wrapper';\nexport * from './keyring-account-registry';\nexport * from './mnemonic';\nexport * from './eth';\n"]}
@@ -0,0 +1,5 @@
1
+ export * from "./keyring-wrapper.cjs";
2
+ export * from "./keyring-account-registry.cjs";
3
+ export * from "./mnemonic.cjs";
4
+ export * from "./eth/index.cjs";
5
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sCAAkC;AAClC,+CAA2C;AAC3C,+BAA2B;AAC3B,gCAAsB"}
@@ -0,0 +1,5 @@
1
+ export * from "./keyring-wrapper.mjs";
2
+ export * from "./keyring-account-registry.mjs";
3
+ export * from "./mnemonic.mjs";
4
+ export * from "./eth/index.mjs";
5
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sCAAkC;AAClC,+CAA2C;AAC3C,+BAA2B;AAC3B,gCAAsB"}
package/dist/index.mjs ADDED
@@ -0,0 +1,5 @@
1
+ export * from "./keyring-wrapper.mjs";
2
+ export * from "./keyring-account-registry.mjs";
3
+ export * from "./mnemonic.mjs";
4
+ export * from "./eth/index.mjs";
5
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sCAAkC;AAClC,+CAA2C;AAC3C,+BAA2B;AAC3B,gCAAsB","sourcesContent":["export * from './keyring-wrapper';\nexport * from './keyring-account-registry';\nexport * from './mnemonic';\nexport * from './eth';\n"]}
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ 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");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var _KeyringAccountRegistry_accountById, _KeyringAccountRegistry_idByAddress;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.KeyringAccountRegistry = void 0;
10
+ const uuid_1 = require("uuid");
11
+ /**
12
+ * In-memory registry for KeyringAccount objects.
13
+ *
14
+ * Provides O(1) lookups by account ID or address, and stores the full
15
+ * KeyringAccount objects for efficient retrieval.
16
+ */
17
+ class KeyringAccountRegistry {
18
+ constructor() {
19
+ _KeyringAccountRegistry_accountById.set(this, new Map());
20
+ _KeyringAccountRegistry_idByAddress.set(this, new Map());
21
+ }
22
+ /**
23
+ * Get an account by its account ID.
24
+ *
25
+ * @param accountId - The account ID to look up.
26
+ * @returns The KeyringAccount, or undefined if not found.
27
+ */
28
+ get(accountId) {
29
+ return __classPrivateFieldGet(this, _KeyringAccountRegistry_accountById, "f").get(accountId);
30
+ }
31
+ /**
32
+ * Get an account's address by its account ID.
33
+ *
34
+ * @param accountId - The account ID to look up.
35
+ * @returns The address, or undefined if not found.
36
+ */
37
+ getAddress(accountId) {
38
+ return __classPrivateFieldGet(this, _KeyringAccountRegistry_accountById, "f").get(accountId)?.address;
39
+ }
40
+ /**
41
+ * Get an account ID by the underlying address.
42
+ *
43
+ * @param address - The address to look up.
44
+ * @returns The account ID, or undefined if not found.
45
+ */
46
+ getAccountId(address) {
47
+ return __classPrivateFieldGet(this, _KeyringAccountRegistry_idByAddress, "f").get(address);
48
+ }
49
+ /**
50
+ * Register a new address and generate an account ID for it.
51
+ * If the address is already registered, returns the existing account ID.
52
+ *
53
+ * @param address - The address to register.
54
+ * @returns The account ID for this address.
55
+ */
56
+ register(address) {
57
+ const existing = __classPrivateFieldGet(this, _KeyringAccountRegistry_idByAddress, "f").get(address);
58
+ if (existing) {
59
+ return existing;
60
+ }
61
+ const id = (0, uuid_1.v4)();
62
+ __classPrivateFieldGet(this, _KeyringAccountRegistry_idByAddress, "f").set(address, id);
63
+ return id;
64
+ }
65
+ /**
66
+ * Add an account to the registry.
67
+ * Also registers the address → account ID mapping.
68
+ *
69
+ * ⚠️ If an address was previously registered via `register()` with a
70
+ * different account ID, calling `set()` with an account that has a new ID for
71
+ * the same address will overwrite the address → ID mapping. The old ID
72
+ * becomes "dangling" (i.e., `get(oldId)` will return undefined).
73
+ *
74
+ * @param account - The KeyringAccount to cache.
75
+ */
76
+ set(account) {
77
+ __classPrivateFieldGet(this, _KeyringAccountRegistry_accountById, "f").set(account.id, account);
78
+ __classPrivateFieldGet(this, _KeyringAccountRegistry_idByAddress, "f").set(account.address, account.id);
79
+ }
80
+ /**
81
+ * Remove an account from the registry.
82
+ *
83
+ * @param accountId - The account ID to remove.
84
+ */
85
+ delete(accountId) {
86
+ const account = __classPrivateFieldGet(this, _KeyringAccountRegistry_accountById, "f").get(accountId);
87
+ if (account) {
88
+ __classPrivateFieldGet(this, _KeyringAccountRegistry_idByAddress, "f").delete(account.address);
89
+ __classPrivateFieldGet(this, _KeyringAccountRegistry_accountById, "f").delete(accountId);
90
+ }
91
+ }
92
+ /**
93
+ * Clear all accounts from the registry.
94
+ */
95
+ clear() {
96
+ __classPrivateFieldGet(this, _KeyringAccountRegistry_accountById, "f").clear();
97
+ __classPrivateFieldGet(this, _KeyringAccountRegistry_idByAddress, "f").clear();
98
+ }
99
+ /**
100
+ * Get all cached accounts as an array.
101
+ *
102
+ * @returns Array of all KeyringAccountType objects in the registry.
103
+ */
104
+ values() {
105
+ return Array.from(__classPrivateFieldGet(this, _KeyringAccountRegistry_accountById, "f").values());
106
+ }
107
+ /**
108
+ * Get all account IDs in the registry.
109
+ *
110
+ * @returns Array of all account IDs.
111
+ */
112
+ keys() {
113
+ return Array.from(__classPrivateFieldGet(this, _KeyringAccountRegistry_accountById, "f").keys());
114
+ }
115
+ /**
116
+ * Check if an account exists in the registry.
117
+ *
118
+ * @param accountId - The account ID to check.
119
+ * @returns True if the account exists.
120
+ */
121
+ has(accountId) {
122
+ return __classPrivateFieldGet(this, _KeyringAccountRegistry_accountById, "f").has(accountId);
123
+ }
124
+ /**
125
+ * Get the number of accounts in the registry.
126
+ *
127
+ * @returns The number of accounts.
128
+ */
129
+ get size() {
130
+ return __classPrivateFieldGet(this, _KeyringAccountRegistry_accountById, "f").size;
131
+ }
132
+ }
133
+ exports.KeyringAccountRegistry = KeyringAccountRegistry;
134
+ _KeyringAccountRegistry_accountById = new WeakMap(), _KeyringAccountRegistry_idByAddress = new WeakMap();
135
+ //# sourceMappingURL=keyring-account-registry.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyring-account-registry.cjs","sourceRoot":"","sources":["../src/keyring-account-registry.ts"],"names":[],"mappings":";;;;;;;;;AAEA,+BAAoC;AAEpC;;;;;GAKG;AACH,MAAa,sBAAsB;IAAnC;QAGW,8CAAe,IAAI,GAAG,EAAiC,EAAC;QAExD,8CAAe,IAAI,GAAG,EAAqB,EAAC;IA0HvD,CAAC;IAxHC;;;;;OAKG;IACH,GAAG,CAAC,SAAoB;QACtB,OAAO,uBAAA,IAAI,2CAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACH,UAAU,CAAC,SAAoB;QAC7B,OAAO,uBAAA,IAAI,2CAAa,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IACnD,CAAC;IAED;;;;;OAKG;IACH,YAAY,CAAC,OAAe;QAC1B,OAAO,uBAAA,IAAI,2CAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IAED;;;;;;OAMG;IACH,QAAQ,CAAC,OAAe;QACtB,MAAM,QAAQ,GAAG,uBAAA,IAAI,2CAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAChD,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,MAAM,EAAE,GAAG,IAAA,SAAM,GAAE,CAAC;QACpB,uBAAA,IAAI,2CAAa,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACnC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED;;;;;;;;;;OAUG;IACH,GAAG,CAAC,OAA2B;QAC7B,uBAAA,IAAI,2CAAa,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAC3C,uBAAA,IAAI,2CAAa,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;IACrD,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,SAAoB;QACzB,MAAM,OAAO,GAAG,uBAAA,IAAI,2CAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACjD,IAAI,OAAO,EAAE,CAAC;YACZ,uBAAA,IAAI,2CAAa,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC1C,uBAAA,IAAI,2CAAa,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK;QACH,uBAAA,IAAI,2CAAa,CAAC,KAAK,EAAE,CAAC;QAC1B,uBAAA,IAAI,2CAAa,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,MAAM;QACJ,OAAO,KAAK,CAAC,IAAI,CAAC,uBAAA,IAAI,2CAAa,CAAC,MAAM,EAAE,CAAC,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACH,IAAI;QACF,OAAO,KAAK,CAAC,IAAI,CAAC,uBAAA,IAAI,2CAAa,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,SAAoB;QACtB,OAAO,uBAAA,IAAI,2CAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IAED;;;;OAIG;IACH,IAAI,IAAI;QACN,OAAO,uBAAA,IAAI,2CAAa,CAAC,IAAI,CAAC;IAChC,CAAC;CACF;AA/HD,wDA+HC","sourcesContent":["import type { KeyringAccount } from '@metamask/keyring-api';\nimport type { AccountId } from '@metamask/keyring-utils';\nimport { v4 as uuidv4 } from 'uuid';\n\n/**\n * In-memory registry for KeyringAccount objects.\n *\n * Provides O(1) lookups by account ID or address, and stores the full\n * KeyringAccount objects for efficient retrieval.\n */\nexport class KeyringAccountRegistry<\n KeyringAccountType extends KeyringAccount = KeyringAccount,\n> {\n readonly #accountById = new Map<AccountId, KeyringAccountType>();\n\n readonly #idByAddress = new Map<string, AccountId>();\n\n /**\n * Get an account by its account ID.\n *\n * @param accountId - The account ID to look up.\n * @returns The KeyringAccount, or undefined if not found.\n */\n get(accountId: AccountId): KeyringAccountType | undefined {\n return this.#accountById.get(accountId);\n }\n\n /**\n * Get an account's address by its account ID.\n *\n * @param accountId - The account ID to look up.\n * @returns The address, or undefined if not found.\n */\n getAddress(accountId: AccountId): string | undefined {\n return this.#accountById.get(accountId)?.address;\n }\n\n /**\n * Get an account ID by the underlying address.\n *\n * @param address - The address to look up.\n * @returns The account ID, or undefined if not found.\n */\n getAccountId(address: string): AccountId | undefined {\n return this.#idByAddress.get(address);\n }\n\n /**\n * Register a new address and generate an account ID for it.\n * If the address is already registered, returns the existing account ID.\n *\n * @param address - The address to register.\n * @returns The account ID for this address.\n */\n register(address: string): AccountId {\n const existing = this.#idByAddress.get(address);\n if (existing) {\n return existing;\n }\n const id = uuidv4();\n this.#idByAddress.set(address, id);\n return id;\n }\n\n /**\n * Add an account to the registry.\n * Also registers the address → account ID mapping.\n *\n * ⚠️ If an address was previously registered via `register()` with a\n * different account ID, calling `set()` with an account that has a new ID for\n * the same address will overwrite the address → ID mapping. The old ID\n * becomes \"dangling\" (i.e., `get(oldId)` will return undefined).\n *\n * @param account - The KeyringAccount to cache.\n */\n set(account: KeyringAccountType): void {\n this.#accountById.set(account.id, account);\n this.#idByAddress.set(account.address, account.id);\n }\n\n /**\n * Remove an account from the registry.\n *\n * @param accountId - The account ID to remove.\n */\n delete(accountId: AccountId): void {\n const account = this.#accountById.get(accountId);\n if (account) {\n this.#idByAddress.delete(account.address);\n this.#accountById.delete(accountId);\n }\n }\n\n /**\n * Clear all accounts from the registry.\n */\n clear(): void {\n this.#accountById.clear();\n this.#idByAddress.clear();\n }\n\n /**\n * Get all cached accounts as an array.\n *\n * @returns Array of all KeyringAccountType objects in the registry.\n */\n values(): KeyringAccountType[] {\n return Array.from(this.#accountById.values());\n }\n\n /**\n * Get all account IDs in the registry.\n *\n * @returns Array of all account IDs.\n */\n keys(): AccountId[] {\n return Array.from(this.#accountById.keys());\n }\n\n /**\n * Check if an account exists in the registry.\n *\n * @param accountId - The account ID to check.\n * @returns True if the account exists.\n */\n has(accountId: AccountId): boolean {\n return this.#accountById.has(accountId);\n }\n\n /**\n * Get the number of accounts in the registry.\n *\n * @returns The number of accounts.\n */\n get size(): number {\n return this.#accountById.size;\n }\n}\n"]}
@@ -0,0 +1,88 @@
1
+ import type { KeyringAccount } from "@metamask/keyring-api";
2
+ import type { AccountId } from "@metamask/keyring-utils";
3
+ /**
4
+ * In-memory registry for KeyringAccount objects.
5
+ *
6
+ * Provides O(1) lookups by account ID or address, and stores the full
7
+ * KeyringAccount objects for efficient retrieval.
8
+ */
9
+ export declare class KeyringAccountRegistry<KeyringAccountType extends KeyringAccount = KeyringAccount> {
10
+ #private;
11
+ /**
12
+ * Get an account by its account ID.
13
+ *
14
+ * @param accountId - The account ID to look up.
15
+ * @returns The KeyringAccount, or undefined if not found.
16
+ */
17
+ get(accountId: AccountId): KeyringAccountType | undefined;
18
+ /**
19
+ * Get an account's address by its account ID.
20
+ *
21
+ * @param accountId - The account ID to look up.
22
+ * @returns The address, or undefined if not found.
23
+ */
24
+ getAddress(accountId: AccountId): string | undefined;
25
+ /**
26
+ * Get an account ID by the underlying address.
27
+ *
28
+ * @param address - The address to look up.
29
+ * @returns The account ID, or undefined if not found.
30
+ */
31
+ getAccountId(address: string): AccountId | undefined;
32
+ /**
33
+ * Register a new address and generate an account ID for it.
34
+ * If the address is already registered, returns the existing account ID.
35
+ *
36
+ * @param address - The address to register.
37
+ * @returns The account ID for this address.
38
+ */
39
+ register(address: string): AccountId;
40
+ /**
41
+ * Add an account to the registry.
42
+ * Also registers the address → account ID mapping.
43
+ *
44
+ * ⚠️ If an address was previously registered via `register()` with a
45
+ * different account ID, calling `set()` with an account that has a new ID for
46
+ * the same address will overwrite the address → ID mapping. The old ID
47
+ * becomes "dangling" (i.e., `get(oldId)` will return undefined).
48
+ *
49
+ * @param account - The KeyringAccount to cache.
50
+ */
51
+ set(account: KeyringAccountType): void;
52
+ /**
53
+ * Remove an account from the registry.
54
+ *
55
+ * @param accountId - The account ID to remove.
56
+ */
57
+ delete(accountId: AccountId): void;
58
+ /**
59
+ * Clear all accounts from the registry.
60
+ */
61
+ clear(): void;
62
+ /**
63
+ * Get all cached accounts as an array.
64
+ *
65
+ * @returns Array of all KeyringAccountType objects in the registry.
66
+ */
67
+ values(): KeyringAccountType[];
68
+ /**
69
+ * Get all account IDs in the registry.
70
+ *
71
+ * @returns Array of all account IDs.
72
+ */
73
+ keys(): AccountId[];
74
+ /**
75
+ * Check if an account exists in the registry.
76
+ *
77
+ * @param accountId - The account ID to check.
78
+ * @returns True if the account exists.
79
+ */
80
+ has(accountId: AccountId): boolean;
81
+ /**
82
+ * Get the number of accounts in the registry.
83
+ *
84
+ * @returns The number of accounts.
85
+ */
86
+ get size(): number;
87
+ }
88
+ //# sourceMappingURL=keyring-account-registry.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyring-account-registry.d.cts","sourceRoot":"","sources":["../src/keyring-account-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,gCAAgC;AAGzD;;;;;GAKG;AACH,qBAAa,sBAAsB,CACjC,kBAAkB,SAAS,cAAc,GAAG,cAAc;;IAM1D;;;;;OAKG;IACH,GAAG,CAAC,SAAS,EAAE,SAAS,GAAG,kBAAkB,GAAG,SAAS;IAIzD;;;;;OAKG;IACH,UAAU,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS;IAIpD;;;;;OAKG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAIpD;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS;IAUpC;;;;;;;;;;OAUG;IACH,GAAG,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAKtC;;;;OAIG;IACH,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAQlC;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb;;;;OAIG;IACH,MAAM,IAAI,kBAAkB,EAAE;IAI9B;;;;OAIG;IACH,IAAI,IAAI,SAAS,EAAE;IAInB;;;;;OAKG;IACH,GAAG,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO;IAIlC;;;;OAIG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
@@ -0,0 +1,88 @@
1
+ import type { KeyringAccount } from "@metamask/keyring-api";
2
+ import type { AccountId } from "@metamask/keyring-utils";
3
+ /**
4
+ * In-memory registry for KeyringAccount objects.
5
+ *
6
+ * Provides O(1) lookups by account ID or address, and stores the full
7
+ * KeyringAccount objects for efficient retrieval.
8
+ */
9
+ export declare class KeyringAccountRegistry<KeyringAccountType extends KeyringAccount = KeyringAccount> {
10
+ #private;
11
+ /**
12
+ * Get an account by its account ID.
13
+ *
14
+ * @param accountId - The account ID to look up.
15
+ * @returns The KeyringAccount, or undefined if not found.
16
+ */
17
+ get(accountId: AccountId): KeyringAccountType | undefined;
18
+ /**
19
+ * Get an account's address by its account ID.
20
+ *
21
+ * @param accountId - The account ID to look up.
22
+ * @returns The address, or undefined if not found.
23
+ */
24
+ getAddress(accountId: AccountId): string | undefined;
25
+ /**
26
+ * Get an account ID by the underlying address.
27
+ *
28
+ * @param address - The address to look up.
29
+ * @returns The account ID, or undefined if not found.
30
+ */
31
+ getAccountId(address: string): AccountId | undefined;
32
+ /**
33
+ * Register a new address and generate an account ID for it.
34
+ * If the address is already registered, returns the existing account ID.
35
+ *
36
+ * @param address - The address to register.
37
+ * @returns The account ID for this address.
38
+ */
39
+ register(address: string): AccountId;
40
+ /**
41
+ * Add an account to the registry.
42
+ * Also registers the address → account ID mapping.
43
+ *
44
+ * ⚠️ If an address was previously registered via `register()` with a
45
+ * different account ID, calling `set()` with an account that has a new ID for
46
+ * the same address will overwrite the address → ID mapping. The old ID
47
+ * becomes "dangling" (i.e., `get(oldId)` will return undefined).
48
+ *
49
+ * @param account - The KeyringAccount to cache.
50
+ */
51
+ set(account: KeyringAccountType): void;
52
+ /**
53
+ * Remove an account from the registry.
54
+ *
55
+ * @param accountId - The account ID to remove.
56
+ */
57
+ delete(accountId: AccountId): void;
58
+ /**
59
+ * Clear all accounts from the registry.
60
+ */
61
+ clear(): void;
62
+ /**
63
+ * Get all cached accounts as an array.
64
+ *
65
+ * @returns Array of all KeyringAccountType objects in the registry.
66
+ */
67
+ values(): KeyringAccountType[];
68
+ /**
69
+ * Get all account IDs in the registry.
70
+ *
71
+ * @returns Array of all account IDs.
72
+ */
73
+ keys(): AccountId[];
74
+ /**
75
+ * Check if an account exists in the registry.
76
+ *
77
+ * @param accountId - The account ID to check.
78
+ * @returns True if the account exists.
79
+ */
80
+ has(accountId: AccountId): boolean;
81
+ /**
82
+ * Get the number of accounts in the registry.
83
+ *
84
+ * @returns The number of accounts.
85
+ */
86
+ get size(): number;
87
+ }
88
+ //# sourceMappingURL=keyring-account-registry.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyring-account-registry.d.mts","sourceRoot":"","sources":["../src/keyring-account-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,gCAAgC;AAGzD;;;;;GAKG;AACH,qBAAa,sBAAsB,CACjC,kBAAkB,SAAS,cAAc,GAAG,cAAc;;IAM1D;;;;;OAKG;IACH,GAAG,CAAC,SAAS,EAAE,SAAS,GAAG,kBAAkB,GAAG,SAAS;IAIzD;;;;;OAKG;IACH,UAAU,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS;IAIpD;;;;;OAKG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAIpD;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS;IAUpC;;;;;;;;;;OAUG;IACH,GAAG,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAKtC;;;;OAIG;IACH,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAQlC;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb;;;;OAIG;IACH,MAAM,IAAI,kBAAkB,EAAE;IAI9B;;;;OAIG;IACH,IAAI,IAAI,SAAS,EAAE;IAInB;;;;;OAKG;IACH,GAAG,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO;IAIlC;;;;OAIG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
@@ -0,0 +1,131 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ 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");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var _KeyringAccountRegistry_accountById, _KeyringAccountRegistry_idByAddress;
7
+ import { v4 as uuidv4 } from "uuid";
8
+ /**
9
+ * In-memory registry for KeyringAccount objects.
10
+ *
11
+ * Provides O(1) lookups by account ID or address, and stores the full
12
+ * KeyringAccount objects for efficient retrieval.
13
+ */
14
+ export class KeyringAccountRegistry {
15
+ constructor() {
16
+ _KeyringAccountRegistry_accountById.set(this, new Map());
17
+ _KeyringAccountRegistry_idByAddress.set(this, new Map());
18
+ }
19
+ /**
20
+ * Get an account by its account ID.
21
+ *
22
+ * @param accountId - The account ID to look up.
23
+ * @returns The KeyringAccount, or undefined if not found.
24
+ */
25
+ get(accountId) {
26
+ return __classPrivateFieldGet(this, _KeyringAccountRegistry_accountById, "f").get(accountId);
27
+ }
28
+ /**
29
+ * Get an account's address by its account ID.
30
+ *
31
+ * @param accountId - The account ID to look up.
32
+ * @returns The address, or undefined if not found.
33
+ */
34
+ getAddress(accountId) {
35
+ return __classPrivateFieldGet(this, _KeyringAccountRegistry_accountById, "f").get(accountId)?.address;
36
+ }
37
+ /**
38
+ * Get an account ID by the underlying address.
39
+ *
40
+ * @param address - The address to look up.
41
+ * @returns The account ID, or undefined if not found.
42
+ */
43
+ getAccountId(address) {
44
+ return __classPrivateFieldGet(this, _KeyringAccountRegistry_idByAddress, "f").get(address);
45
+ }
46
+ /**
47
+ * Register a new address and generate an account ID for it.
48
+ * If the address is already registered, returns the existing account ID.
49
+ *
50
+ * @param address - The address to register.
51
+ * @returns The account ID for this address.
52
+ */
53
+ register(address) {
54
+ const existing = __classPrivateFieldGet(this, _KeyringAccountRegistry_idByAddress, "f").get(address);
55
+ if (existing) {
56
+ return existing;
57
+ }
58
+ const id = uuidv4();
59
+ __classPrivateFieldGet(this, _KeyringAccountRegistry_idByAddress, "f").set(address, id);
60
+ return id;
61
+ }
62
+ /**
63
+ * Add an account to the registry.
64
+ * Also registers the address → account ID mapping.
65
+ *
66
+ * ⚠️ If an address was previously registered via `register()` with a
67
+ * different account ID, calling `set()` with an account that has a new ID for
68
+ * the same address will overwrite the address → ID mapping. The old ID
69
+ * becomes "dangling" (i.e., `get(oldId)` will return undefined).
70
+ *
71
+ * @param account - The KeyringAccount to cache.
72
+ */
73
+ set(account) {
74
+ __classPrivateFieldGet(this, _KeyringAccountRegistry_accountById, "f").set(account.id, account);
75
+ __classPrivateFieldGet(this, _KeyringAccountRegistry_idByAddress, "f").set(account.address, account.id);
76
+ }
77
+ /**
78
+ * Remove an account from the registry.
79
+ *
80
+ * @param accountId - The account ID to remove.
81
+ */
82
+ delete(accountId) {
83
+ const account = __classPrivateFieldGet(this, _KeyringAccountRegistry_accountById, "f").get(accountId);
84
+ if (account) {
85
+ __classPrivateFieldGet(this, _KeyringAccountRegistry_idByAddress, "f").delete(account.address);
86
+ __classPrivateFieldGet(this, _KeyringAccountRegistry_accountById, "f").delete(accountId);
87
+ }
88
+ }
89
+ /**
90
+ * Clear all accounts from the registry.
91
+ */
92
+ clear() {
93
+ __classPrivateFieldGet(this, _KeyringAccountRegistry_accountById, "f").clear();
94
+ __classPrivateFieldGet(this, _KeyringAccountRegistry_idByAddress, "f").clear();
95
+ }
96
+ /**
97
+ * Get all cached accounts as an array.
98
+ *
99
+ * @returns Array of all KeyringAccountType objects in the registry.
100
+ */
101
+ values() {
102
+ return Array.from(__classPrivateFieldGet(this, _KeyringAccountRegistry_accountById, "f").values());
103
+ }
104
+ /**
105
+ * Get all account IDs in the registry.
106
+ *
107
+ * @returns Array of all account IDs.
108
+ */
109
+ keys() {
110
+ return Array.from(__classPrivateFieldGet(this, _KeyringAccountRegistry_accountById, "f").keys());
111
+ }
112
+ /**
113
+ * Check if an account exists in the registry.
114
+ *
115
+ * @param accountId - The account ID to check.
116
+ * @returns True if the account exists.
117
+ */
118
+ has(accountId) {
119
+ return __classPrivateFieldGet(this, _KeyringAccountRegistry_accountById, "f").has(accountId);
120
+ }
121
+ /**
122
+ * Get the number of accounts in the registry.
123
+ *
124
+ * @returns The number of accounts.
125
+ */
126
+ get size() {
127
+ return __classPrivateFieldGet(this, _KeyringAccountRegistry_accountById, "f").size;
128
+ }
129
+ }
130
+ _KeyringAccountRegistry_accountById = new WeakMap(), _KeyringAccountRegistry_idByAddress = new WeakMap();
131
+ //# sourceMappingURL=keyring-account-registry.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyring-account-registry.mjs","sourceRoot":"","sources":["../src/keyring-account-registry.ts"],"names":[],"mappings":";;;;;;AAEA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,aAAa;AAEpC;;;;;GAKG;AACH,MAAM,OAAO,sBAAsB;IAAnC;QAGW,8CAAe,IAAI,GAAG,EAAiC,EAAC;QAExD,8CAAe,IAAI,GAAG,EAAqB,EAAC;IA0HvD,CAAC;IAxHC;;;;;OAKG;IACH,GAAG,CAAC,SAAoB;QACtB,OAAO,uBAAA,IAAI,2CAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACH,UAAU,CAAC,SAAoB;QAC7B,OAAO,uBAAA,IAAI,2CAAa,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IACnD,CAAC;IAED;;;;;OAKG;IACH,YAAY,CAAC,OAAe;QAC1B,OAAO,uBAAA,IAAI,2CAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IAED;;;;;;OAMG;IACH,QAAQ,CAAC,OAAe;QACtB,MAAM,QAAQ,GAAG,uBAAA,IAAI,2CAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAChD,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;QACpB,uBAAA,IAAI,2CAAa,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACnC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED;;;;;;;;;;OAUG;IACH,GAAG,CAAC,OAA2B;QAC7B,uBAAA,IAAI,2CAAa,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAC3C,uBAAA,IAAI,2CAAa,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;IACrD,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,SAAoB;QACzB,MAAM,OAAO,GAAG,uBAAA,IAAI,2CAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACjD,IAAI,OAAO,EAAE,CAAC;YACZ,uBAAA,IAAI,2CAAa,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC1C,uBAAA,IAAI,2CAAa,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK;QACH,uBAAA,IAAI,2CAAa,CAAC,KAAK,EAAE,CAAC;QAC1B,uBAAA,IAAI,2CAAa,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,MAAM;QACJ,OAAO,KAAK,CAAC,IAAI,CAAC,uBAAA,IAAI,2CAAa,CAAC,MAAM,EAAE,CAAC,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACH,IAAI;QACF,OAAO,KAAK,CAAC,IAAI,CAAC,uBAAA,IAAI,2CAAa,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,SAAoB;QACtB,OAAO,uBAAA,IAAI,2CAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IAED;;;;OAIG;IACH,IAAI,IAAI;QACN,OAAO,uBAAA,IAAI,2CAAa,CAAC,IAAI,CAAC;IAChC,CAAC;CACF","sourcesContent":["import type { KeyringAccount } from '@metamask/keyring-api';\nimport type { AccountId } from '@metamask/keyring-utils';\nimport { v4 as uuidv4 } from 'uuid';\n\n/**\n * In-memory registry for KeyringAccount objects.\n *\n * Provides O(1) lookups by account ID or address, and stores the full\n * KeyringAccount objects for efficient retrieval.\n */\nexport class KeyringAccountRegistry<\n KeyringAccountType extends KeyringAccount = KeyringAccount,\n> {\n readonly #accountById = new Map<AccountId, KeyringAccountType>();\n\n readonly #idByAddress = new Map<string, AccountId>();\n\n /**\n * Get an account by its account ID.\n *\n * @param accountId - The account ID to look up.\n * @returns The KeyringAccount, or undefined if not found.\n */\n get(accountId: AccountId): KeyringAccountType | undefined {\n return this.#accountById.get(accountId);\n }\n\n /**\n * Get an account's address by its account ID.\n *\n * @param accountId - The account ID to look up.\n * @returns The address, or undefined if not found.\n */\n getAddress(accountId: AccountId): string | undefined {\n return this.#accountById.get(accountId)?.address;\n }\n\n /**\n * Get an account ID by the underlying address.\n *\n * @param address - The address to look up.\n * @returns The account ID, or undefined if not found.\n */\n getAccountId(address: string): AccountId | undefined {\n return this.#idByAddress.get(address);\n }\n\n /**\n * Register a new address and generate an account ID for it.\n * If the address is already registered, returns the existing account ID.\n *\n * @param address - The address to register.\n * @returns The account ID for this address.\n */\n register(address: string): AccountId {\n const existing = this.#idByAddress.get(address);\n if (existing) {\n return existing;\n }\n const id = uuidv4();\n this.#idByAddress.set(address, id);\n return id;\n }\n\n /**\n * Add an account to the registry.\n * Also registers the address → account ID mapping.\n *\n * ⚠️ If an address was previously registered via `register()` with a\n * different account ID, calling `set()` with an account that has a new ID for\n * the same address will overwrite the address → ID mapping. The old ID\n * becomes \"dangling\" (i.e., `get(oldId)` will return undefined).\n *\n * @param account - The KeyringAccount to cache.\n */\n set(account: KeyringAccountType): void {\n this.#accountById.set(account.id, account);\n this.#idByAddress.set(account.address, account.id);\n }\n\n /**\n * Remove an account from the registry.\n *\n * @param accountId - The account ID to remove.\n */\n delete(accountId: AccountId): void {\n const account = this.#accountById.get(accountId);\n if (account) {\n this.#idByAddress.delete(account.address);\n this.#accountById.delete(accountId);\n }\n }\n\n /**\n * Clear all accounts from the registry.\n */\n clear(): void {\n this.#accountById.clear();\n this.#idByAddress.clear();\n }\n\n /**\n * Get all cached accounts as an array.\n *\n * @returns Array of all KeyringAccountType objects in the registry.\n */\n values(): KeyringAccountType[] {\n return Array.from(this.#accountById.values());\n }\n\n /**\n * Get all account IDs in the registry.\n *\n * @returns Array of all account IDs.\n */\n keys(): AccountId[] {\n return Array.from(this.#accountById.keys());\n }\n\n /**\n * Check if an account exists in the registry.\n *\n * @param accountId - The account ID to check.\n * @returns True if the account exists.\n */\n has(accountId: AccountId): boolean {\n return this.#accountById.has(accountId);\n }\n\n /**\n * Get the number of accounts in the registry.\n *\n * @returns The number of accounts.\n */\n get size(): number {\n return this.#accountById.size;\n }\n}\n"]}
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
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
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _KeyringWrapper_capabilities, _KeyringWrapper_lock;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.KeyringWrapper = void 0;
16
+ const async_mutex_1 = require("async-mutex");
17
+ const keyring_account_registry_1 = require("./keyring-account-registry.cjs");
18
+ /**
19
+ * Generic adapter that turns an existing {@link Keyring} implementation into a
20
+ * {@link KeyringV2} instance.
21
+ *
22
+ * Consumers are expected to provide concrete mappings between high-level V2
23
+ * operations and the underlying keyring methods (for example BIP-44 account
24
+ * creation, private-key import, and request handling). This class focuses on
25
+ * the common mechanics required by all adapters: state serialization,
26
+ * account-ID/address mapping and basic account management.
27
+ */
28
+ class KeyringWrapper {
29
+ constructor(options) {
30
+ _KeyringWrapper_capabilities.set(this, void 0);
31
+ /**
32
+ * Mutex to ensure exclusive access to the inner keyring during
33
+ * operations that mutate its state.
34
+ */
35
+ _KeyringWrapper_lock.set(this, new async_mutex_1.Mutex());
36
+ /**
37
+ * Registry for KeyringAccount objects.
38
+ * Provides O(1) lookups by AccountId or address.
39
+ *
40
+ * Subclasses should use this registry when creating accounts and
41
+ * clear/update it when deleting accounts or deserializing state.
42
+ */
43
+ this.registry = new keyring_account_registry_1.KeyringAccountRegistry();
44
+ this.inner = options.inner;
45
+ this.type = `${options.type}`;
46
+ __classPrivateFieldSet(this, _KeyringWrapper_capabilities, options.capabilities, "f");
47
+ }
48
+ /**
49
+ * Get the capabilities of this keyring.
50
+ *
51
+ * Subclasses can override this getter to return capabilities dynamically
52
+ * based on runtime state.
53
+ *
54
+ * @returns The keyring's capabilities.
55
+ */
56
+ get capabilities() {
57
+ return __classPrivateFieldGet(this, _KeyringWrapper_capabilities, "f");
58
+ }
59
+ /**
60
+ * Execute an operation with exclusive access to the inner keyring.
61
+ *
62
+ * This method ensures thread-safety for operations that read or mutate
63
+ * the inner keyring state. All operations that modify the keyring
64
+ * (createAccounts, deleteAccount, deserialize) should use this method
65
+ * to prevent race conditions.
66
+ *
67
+ * Within the callback, use `this.inner` to access the inner keyring.
68
+ *
69
+ * @param callback - A function that performs the operation.
70
+ * @returns The result of the callback.
71
+ */
72
+ async withLock(callback) {
73
+ return __classPrivateFieldGet(this, _KeyringWrapper_lock, "f").runExclusive(callback);
74
+ }
75
+ /**
76
+ * Serialize the underlying keyring state to a JSON-serializable object.
77
+ *
78
+ * This simply delegates to the legacy keyring's {@link Keyring.serialize}
79
+ * implementation.
80
+ *
81
+ * @returns The serialized keyring state.
82
+ */
83
+ async serialize() {
84
+ return this.inner.serialize();
85
+ }
86
+ /**
87
+ * Hydrate the underlying keyring from a previously serialized state.
88
+ *
89
+ * This clears the registry, delegates to the legacy keyring's
90
+ * {@link Keyring.deserialize} implementation, and rebuilds the registry
91
+ * by calling {@link getAccounts}.
92
+ *
93
+ * @param state - The serialized keyring state.
94
+ */
95
+ async deserialize(state) {
96
+ await this.withLock(async () => {
97
+ // Clear the registry when deserializing
98
+ this.registry.clear();
99
+ // Deserialize the legacy keyring
100
+ await this.inner.deserialize(state);
101
+ // Rebuild the registry by calling getAccounts().
102
+ // Subclass implementations of getAccounts() should populate the registry
103
+ // as a side effect (see the abstract method's documentation).
104
+ await this.getAccounts();
105
+ });
106
+ }
107
+ /**
108
+ * Look up a single account by its {@link AccountId}.
109
+ *
110
+ * This method first checks the registry for O(1) lookup.
111
+ * If not found, it falls back to calling {@link getAccounts} which
112
+ * should populate the registry as a side effect.
113
+ *
114
+ * @param accountId - The AccountId to look up.
115
+ * @returns The matching KeyringAccount.
116
+ */
117
+ async getAccount(accountId) {
118
+ let cached = this.registry.get(accountId);
119
+ if (cached) {
120
+ return cached;
121
+ }
122
+ // Prime the registry by calling getAccounts
123
+ await this.getAccounts();
124
+ // Try registry again after priming
125
+ cached = this.registry.get(accountId);
126
+ if (!cached) {
127
+ throw new Error(`Account not found for id: ${accountId}`);
128
+ }
129
+ return cached;
130
+ }
131
+ }
132
+ exports.KeyringWrapper = KeyringWrapper;
133
+ _KeyringWrapper_capabilities = new WeakMap(), _KeyringWrapper_lock = new WeakMap();
134
+ //# sourceMappingURL=keyring-wrapper.cjs.map