@metamask-previews/multichain-account-service 0.2.1-preview-848266f → 0.2.1-preview-7509efdb

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 (58) hide show
  1. package/CHANGELOG.md +1 -11
  2. package/dist/MultichainAccountService.cjs +36 -113
  3. package/dist/MultichainAccountService.cjs.map +1 -1
  4. package/dist/MultichainAccountService.d.cts +5 -36
  5. package/dist/MultichainAccountService.d.cts.map +1 -1
  6. package/dist/MultichainAccountService.d.mts +5 -36
  7. package/dist/MultichainAccountService.d.mts.map +1 -1
  8. package/dist/MultichainAccountService.mjs +35 -112
  9. package/dist/MultichainAccountService.mjs.map +1 -1
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +1 -1
  12. package/dist/index.d.cts.map +1 -1
  13. package/dist/index.d.mts +1 -1
  14. package/dist/index.d.mts.map +1 -1
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/providers/BaseAccountProvider.cjs +19 -4
  17. package/dist/providers/BaseAccountProvider.cjs.map +1 -1
  18. package/dist/providers/BaseAccountProvider.d.cts +19 -5
  19. package/dist/providers/BaseAccountProvider.d.cts.map +1 -1
  20. package/dist/providers/BaseAccountProvider.d.mts +19 -5
  21. package/dist/providers/BaseAccountProvider.d.mts.map +1 -1
  22. package/dist/providers/BaseAccountProvider.mjs +17 -3
  23. package/dist/providers/BaseAccountProvider.mjs.map +1 -1
  24. package/dist/providers/EvmAccountProvider.cjs.map +1 -1
  25. package/dist/providers/EvmAccountProvider.d.cts +1 -2
  26. package/dist/providers/EvmAccountProvider.d.cts.map +1 -1
  27. package/dist/providers/EvmAccountProvider.d.mts +1 -2
  28. package/dist/providers/EvmAccountProvider.d.mts.map +1 -1
  29. package/dist/providers/EvmAccountProvider.mjs.map +1 -1
  30. package/dist/providers/SolAccountProvider.cjs.map +1 -1
  31. package/dist/providers/SolAccountProvider.d.cts +1 -2
  32. package/dist/providers/SolAccountProvider.d.cts.map +1 -1
  33. package/dist/providers/SolAccountProvider.d.mts +1 -2
  34. package/dist/providers/SolAccountProvider.d.mts.map +1 -1
  35. package/dist/providers/SolAccountProvider.mjs.map +1 -1
  36. package/dist/tests/accounts.cjs +3 -7
  37. package/dist/tests/accounts.cjs.map +1 -1
  38. package/dist/tests/accounts.d.cts +0 -1
  39. package/dist/tests/accounts.d.cts.map +1 -1
  40. package/dist/tests/accounts.d.mts +0 -1
  41. package/dist/tests/accounts.d.mts.map +1 -1
  42. package/dist/tests/accounts.mjs +1 -5
  43. package/dist/tests/accounts.mjs.map +1 -1
  44. package/dist/tests/messenger.cjs +1 -5
  45. package/dist/tests/messenger.cjs.map +1 -1
  46. package/dist/tests/messenger.d.cts +2 -2
  47. package/dist/tests/messenger.d.cts.map +1 -1
  48. package/dist/tests/messenger.d.mts +2 -2
  49. package/dist/tests/messenger.d.mts.map +1 -1
  50. package/dist/tests/messenger.mjs +1 -5
  51. package/dist/tests/messenger.mjs.map +1 -1
  52. package/dist/types.cjs.map +1 -1
  53. package/dist/types.d.cts +3 -20
  54. package/dist/types.d.cts.map +1 -1
  55. package/dist/types.d.mts +3 -20
  56. package/dist/types.d.mts.map +1 -1
  57. package/dist/types.mjs.map +1 -1
  58. package/package.json +2 -3
@@ -9,12 +9,21 @@ 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 _MultichainAccountService_instances, _MultichainAccountService_messenger, _MultichainAccountService_providers, _MultichainAccountService_wallets, _MultichainAccountService_accountIdToContext, _MultichainAccountService_handleOnAccountAdded, _MultichainAccountService_handleOnAccountRemoved, _MultichainAccountService_getWallet;
13
- import { isBip44Account, MultichainAccountWallet, toMultichainAccountWalletId } from "@metamask/account-api";
12
+ var _MultichainAccountService_instances, _MultichainAccountService_messenger, _MultichainAccountService_providers, _MultichainAccountService_wallets, _MultichainAccountService_setMultichainAccountWallets, _MultichainAccountService_getWallet;
13
+ import { MultichainAccountWallet, toMultichainAccountWalletId } from "@metamask/account-api";
14
14
  import { KeyringTypes } from "@metamask/keyring-controller";
15
15
  import { EvmAccountProvider } from "./providers/EvmAccountProvider.mjs";
16
16
  import { SolAccountProvider } from "./providers/SolAccountProvider.mjs";
17
- export const serviceName = 'MultichainAccountService';
17
+ const serviceName = 'MultichainAccountService';
18
+ /**
19
+ * Select keyrings from keyring controller state.
20
+ *
21
+ * @param state - The keyring controller state.
22
+ * @returns The keyrings.
23
+ */
24
+ function selectKeyringControllerKeyrings(state) {
25
+ return state.keyrings;
26
+ }
18
27
  /**
19
28
  * Service to expose multichain accounts capabilities.
20
29
  */
@@ -31,84 +40,29 @@ export class MultichainAccountService {
31
40
  _MultichainAccountService_messenger.set(this, void 0);
32
41
  _MultichainAccountService_providers.set(this, void 0);
33
42
  _MultichainAccountService_wallets.set(this, void 0);
34
- _MultichainAccountService_accountIdToContext.set(this, void 0);
35
43
  /**
36
44
  * The name of the service.
37
45
  */
38
46
  this.name = serviceName;
39
47
  __classPrivateFieldSet(this, _MultichainAccountService_messenger, messenger, "f");
40
48
  __classPrivateFieldSet(this, _MultichainAccountService_wallets, new Map(), "f");
41
- __classPrivateFieldSet(this, _MultichainAccountService_accountIdToContext, new Map(), "f");
42
49
  // TODO: Rely on keyring capabilities once the keyring API is used by all keyrings.
43
50
  __classPrivateFieldSet(this, _MultichainAccountService_providers, [
44
51
  new EvmAccountProvider(__classPrivateFieldGet(this, _MultichainAccountService_messenger, "f")),
45
52
  new SolAccountProvider(__classPrivateFieldGet(this, _MultichainAccountService_messenger, "f")),
46
53
  ], "f");
47
- __classPrivateFieldGet(this, _MultichainAccountService_messenger, "f").registerActionHandler('MultichainAccountService:getMultichainAccount', (...args) => this.getMultichainAccount(...args));
48
- __classPrivateFieldGet(this, _MultichainAccountService_messenger, "f").registerActionHandler('MultichainAccountService:getMultichainAccounts', (...args) => this.getMultichainAccounts(...args));
49
- __classPrivateFieldGet(this, _MultichainAccountService_messenger, "f").registerActionHandler('MultichainAccountService:getMultichainAccountWallet', (...args) => this.getMultichainAccountWallet(...args));
50
- __classPrivateFieldGet(this, _MultichainAccountService_messenger, "f").registerActionHandler('MultichainAccountService:getMultichainAccountWallets', (...args) => this.getMultichainAccountWallets(...args));
51
54
  }
52
55
  /**
53
56
  * Initialize the service and constructs the internal reprensentation of
54
57
  * multichain accounts and wallets.
55
58
  */
56
59
  init() {
57
- // Create initial wallets.
58
- const { keyrings } = __classPrivateFieldGet(this, _MultichainAccountService_messenger, "f").call('KeyringController:getState');
59
- for (const keyring of keyrings) {
60
- if (keyring.type === KeyringTypes.hd) {
61
- // Only HD keyrings have an entropy source/SRP.
62
- const entropySource = keyring.metadata.id;
63
- // This will automatically "associate" all multichain accounts for that wallet
64
- // (based on the accounts owned by each account providers).
65
- const wallet = new MultichainAccountWallet({
66
- entropySource,
67
- providers: __classPrivateFieldGet(this, _MultichainAccountService_providers, "f"),
68
- });
69
- __classPrivateFieldGet(this, _MultichainAccountService_wallets, "f").set(wallet.id, wallet);
70
- // Reverse mapping between account ID and their multichain wallet/account:
71
- for (const multichainAccount of wallet.getMultichainAccounts()) {
72
- for (const account of multichainAccount.getAccounts()) {
73
- __classPrivateFieldGet(this, _MultichainAccountService_accountIdToContext, "f").set(account.id, {
74
- wallet,
75
- multichainAccount,
76
- });
77
- }
78
- }
79
- }
80
- }
81
- __classPrivateFieldGet(this, _MultichainAccountService_messenger, "f").subscribe('AccountsController:accountAdded', (account) => __classPrivateFieldGet(this, _MultichainAccountService_instances, "m", _MultichainAccountService_handleOnAccountAdded).call(this, account));
82
- __classPrivateFieldGet(this, _MultichainAccountService_messenger, "f").subscribe('AccountsController:accountRemoved', (id) => __classPrivateFieldGet(this, _MultichainAccountService_instances, "m", _MultichainAccountService_handleOnAccountRemoved).call(this, id));
83
- }
84
- /**
85
- * Gets a reference to the wallet and multichain account for a given account ID.
86
- *
87
- * @param id - Account ID.
88
- * @returns An object with references to the wallet and multichain account associated for
89
- * that account ID, or undefined if this account ID is not part of any.
90
- */
91
- getMultichainAccountAndWallet(id) {
92
- return __classPrivateFieldGet(this, _MultichainAccountService_accountIdToContext, "f").get(id);
93
- }
94
- /**
95
- * Gets a reference to the multichain account wallet matching this entropy source.
96
- *
97
- * @param options - Options.
98
- * @param options.entropySource - The entropy source of the multichain account.
99
- * @throws If none multichain account match this entropy.
100
- * @returns A reference to the multichain account wallet.
101
- */
102
- getMultichainAccountWallet({ entropySource, }) {
103
- return __classPrivateFieldGet(this, _MultichainAccountService_instances, "m", _MultichainAccountService_getWallet).call(this, entropySource);
104
- }
105
- /**
106
- * Gets an array of all multichain account wallets.
107
- *
108
- * @returns An array of all multichain account wallets.
109
- */
110
- getMultichainAccountWallets() {
111
- return Array.from(__classPrivateFieldGet(this, _MultichainAccountService_wallets, "f").values());
60
+ // Gather all entropy sources first.
61
+ const state = __classPrivateFieldGet(this, _MultichainAccountService_messenger, "f").call('KeyringController:getState');
62
+ __classPrivateFieldGet(this, _MultichainAccountService_instances, "m", _MultichainAccountService_setMultichainAccountWallets).call(this, state.keyrings);
63
+ __classPrivateFieldGet(this, _MultichainAccountService_messenger, "f").subscribe('KeyringController:stateChange', (keyrings) => {
64
+ __classPrivateFieldGet(this, _MultichainAccountService_instances, "m", _MultichainAccountService_setMultichainAccountWallets).call(this, keyrings);
65
+ }, selectKeyringControllerKeyrings);
112
66
  }
113
67
  /**
114
68
  * Gets a reference to the multichain account matching this entropy source and group index.
@@ -138,56 +92,25 @@ export class MultichainAccountService {
138
92
  return __classPrivateFieldGet(this, _MultichainAccountService_instances, "m", _MultichainAccountService_getWallet).call(this, entropySource).getMultichainAccounts();
139
93
  }
140
94
  }
141
- _MultichainAccountService_messenger = new WeakMap(), _MultichainAccountService_providers = new WeakMap(), _MultichainAccountService_wallets = new WeakMap(), _MultichainAccountService_accountIdToContext = new WeakMap(), _MultichainAccountService_instances = new WeakSet(), _MultichainAccountService_handleOnAccountAdded = function _MultichainAccountService_handleOnAccountAdded(account) {
142
- // We completely omit non-BIP-44 accounts!
143
- if (!isBip44Account(account)) {
144
- return;
145
- }
146
- let sync = true;
147
- let wallet = __classPrivateFieldGet(this, _MultichainAccountService_wallets, "f").get(toMultichainAccountWalletId(account.options.entropy.id));
148
- if (!wallet) {
149
- // That's a new wallet.
150
- wallet = new MultichainAccountWallet({
151
- entropySource: account.options.entropy.id,
152
- providers: __classPrivateFieldGet(this, _MultichainAccountService_providers, "f"),
153
- });
154
- __classPrivateFieldGet(this, _MultichainAccountService_wallets, "f").set(wallet.id, wallet);
155
- // If that's a new wallet wallet. There's nothing to "force-sync".
156
- sync = false;
157
- }
158
- let multichainAccount = wallet.getMultichainAccount(account.options.entropy.groupIndex);
159
- if (!multichainAccount) {
160
- // This new account is a new multichain account, let the wallet know
161
- // it has to re-sync with its providers.
162
- if (sync) {
163
- wallet.sync();
164
- }
165
- multichainAccount = wallet.getMultichainAccount(account.options.entropy.groupIndex);
166
- // If that's a new multichain account. There's nothing to "force-sync".
167
- sync = false;
168
- }
169
- // We have to check against `undefined` in case `getMultichainAccount` is
170
- // not able to find this multichain account (which should not be possible...)
171
- if (multichainAccount) {
172
- if (sync) {
173
- multichainAccount.sync();
95
+ _MultichainAccountService_messenger = new WeakMap(), _MultichainAccountService_providers = new WeakMap(), _MultichainAccountService_wallets = new WeakMap(), _MultichainAccountService_instances = new WeakSet(), _MultichainAccountService_setMultichainAccountWallets = function _MultichainAccountService_setMultichainAccountWallets(keyrings) {
96
+ for (const keyring of keyrings) {
97
+ if (keyring.type === KeyringTypes.hd) {
98
+ // Only HD keyrings have an entropy source/SRP.
99
+ const entropySource = keyring.metadata.id;
100
+ // Do not re-create wallets if they exists. Even if a keyrings got new accounts, this
101
+ // will be handled by the `*AccountProvider`s which are always in-sync with their
102
+ // keyrings and controllers (like the `AccountsController`).
103
+ if (!__classPrivateFieldGet(this, _MultichainAccountService_wallets, "f").has(toMultichainAccountWalletId(entropySource))) {
104
+ // This will automatically "associate" all multichain accounts for that wallet
105
+ // (based on the accounts owned by each account providers).
106
+ const wallet = new MultichainAccountWallet({
107
+ entropySource,
108
+ providers: __classPrivateFieldGet(this, _MultichainAccountService_providers, "f"),
109
+ });
110
+ __classPrivateFieldGet(this, _MultichainAccountService_wallets, "f").set(wallet.id, wallet);
111
+ }
174
112
  }
175
- // Same here, this account should have been already grouped in that
176
- // multichain account.
177
- __classPrivateFieldGet(this, _MultichainAccountService_accountIdToContext, "f").set(account.id, {
178
- wallet,
179
- multichainAccount,
180
- });
181
- }
182
- }, _MultichainAccountService_handleOnAccountRemoved = function _MultichainAccountService_handleOnAccountRemoved(id) {
183
- // Force sync of the appropriate wallet if an account got removed.
184
- const found = __classPrivateFieldGet(this, _MultichainAccountService_accountIdToContext, "f").get(id);
185
- if (found) {
186
- const { wallet } = found;
187
- wallet.sync();
188
113
  }
189
- // Safe to call delete even if the `id` was not referencing a BIP-44 account.
190
- __classPrivateFieldGet(this, _MultichainAccountService_accountIdToContext, "f").delete(id);
191
114
  }, _MultichainAccountService_getWallet = function _MultichainAccountService_getWallet(entropySource) {
192
115
  const wallet = __classPrivateFieldGet(this, _MultichainAccountService_wallets, "f").get(toMultichainAccountWalletId(entropySource));
193
116
  if (!wallet) {
@@ -1 +1 @@
1
- {"version":3,"file":"MultichainAccountService.mjs","sourceRoot":"","sources":["../src/MultichainAccountService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,2BAA2B,EAE5B,8BAA8B;AAE/B,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAG5D,OAAO,EAAE,kBAAkB,EAAE,2CAAuC;AACpE,OAAO,EAAE,kBAAkB,EAAE,2CAAuC;AAGpE,MAAM,CAAC,MAAM,WAAW,GAAG,0BAA0B,CAAC;AAetD;;GAEG;AACH,MAAM,OAAO,wBAAwB;IAoBnC;;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C3E;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type {\n MultichainAccountWalletId,\n AccountProvider,\n Bip44Account,\n} from '@metamask/account-api';\nimport {\n isBip44Account,\n MultichainAccountWallet,\n toMultichainAccountWalletId,\n type MultichainAccount,\n} from '@metamask/account-api';\nimport type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { EvmAccountProvider } from './providers/EvmAccountProvider';\nimport { SolAccountProvider } from './providers/SolAccountProvider';\nimport type { MultichainAccountServiceMessenger } from './types';\n\nexport const serviceName = 'MultichainAccountService';\n\n/**\n * The options that {@link MultichainAccountService} takes.\n */\ntype MultichainAccountServiceOptions = {\n messenger: MultichainAccountServiceMessenger;\n};\n\n/** Reverse mapping object used to map account IDs and their wallet/multichain account. */\ntype AccountContext<Account extends Bip44Account<KeyringAccount>> = {\n wallet: MultichainAccountWallet<Account>;\n multichainAccount: MultichainAccount<Account>;\n};\n\n/**\n * Service to expose multichain accounts capabilities.\n */\nexport class MultichainAccountService {\n readonly #messenger: MultichainAccountServiceMessenger;\n\n readonly #providers: AccountProvider<Bip44Account<InternalAccount>>[];\n\n readonly #wallets: Map<\n MultichainAccountWalletId,\n MultichainAccountWallet<Bip44Account<InternalAccount>>\n >;\n\n readonly #accountIdToContext: Map<\n Bip44Account<InternalAccount>['id'],\n AccountContext<Bip44Account<InternalAccount>>\n >;\n\n /**\n * The name of the service.\n */\n name: typeof serviceName = serviceName;\n\n /**\n * Constructs a new MultichainAccountService.\n *\n * @param options - The options.\n * @param options.messenger - The messenger suited to this\n * MultichainAccountService.\n */\n constructor({ messenger }: MultichainAccountServiceOptions) {\n this.#messenger = messenger;\n this.#wallets = new Map();\n this.#accountIdToContext = new Map();\n // TODO: Rely on keyring capabilities once the keyring API is used by all keyrings.\n this.#providers = [\n new EvmAccountProvider(this.#messenger),\n new SolAccountProvider(this.#messenger),\n ];\n\n this.#messenger.registerActionHandler(\n 'MultichainAccountService:getMultichainAccount',\n (...args) => this.getMultichainAccount(...args),\n );\n this.#messenger.registerActionHandler(\n 'MultichainAccountService:getMultichainAccounts',\n (...args) => this.getMultichainAccounts(...args),\n );\n this.#messenger.registerActionHandler(\n 'MultichainAccountService:getMultichainAccountWallet',\n (...args) => this.getMultichainAccountWallet(...args),\n );\n this.#messenger.registerActionHandler(\n 'MultichainAccountService:getMultichainAccountWallets',\n (...args) => this.getMultichainAccountWallets(...args),\n );\n }\n\n /**\n * Initialize the service and constructs the internal reprensentation of\n * multichain accounts and wallets.\n */\n init(): void {\n // Create initial wallets.\n const { keyrings } = this.#messenger.call('KeyringController:getState');\n for (const keyring of keyrings) {\n if (keyring.type === (KeyringTypes.hd as string)) {\n // Only HD keyrings have an entropy source/SRP.\n const entropySource = keyring.metadata.id;\n\n // This will automatically \"associate\" all multichain accounts for that wallet\n // (based on the accounts owned by each account providers).\n const wallet = new MultichainAccountWallet({\n entropySource,\n providers: this.#providers,\n });\n this.#wallets.set(wallet.id, wallet);\n\n // Reverse mapping between account ID and their multichain wallet/account:\n for (const multichainAccount of wallet.getMultichainAccounts()) {\n for (const account of multichainAccount.getAccounts()) {\n this.#accountIdToContext.set(account.id, {\n wallet,\n multichainAccount,\n });\n }\n }\n }\n }\n\n this.#messenger.subscribe('AccountsController:accountAdded', (account) =>\n this.#handleOnAccountAdded(account),\n );\n this.#messenger.subscribe('AccountsController:accountRemoved', (id) =>\n this.#handleOnAccountRemoved(id),\n );\n }\n\n #handleOnAccountAdded(account: InternalAccount): void {\n // We completely omit non-BIP-44 accounts!\n if (!isBip44Account(account)) {\n return;\n }\n\n let sync = true;\n\n let wallet = this.#wallets.get(\n toMultichainAccountWalletId(account.options.entropy.id),\n );\n if (!wallet) {\n // That's a new wallet.\n wallet = new MultichainAccountWallet({\n entropySource: account.options.entropy.id,\n providers: this.#providers,\n });\n this.#wallets.set(wallet.id, wallet);\n\n // If that's a new wallet wallet. There's nothing to \"force-sync\".\n sync = false;\n }\n\n let multichainAccount = wallet.getMultichainAccount(\n account.options.entropy.groupIndex,\n );\n if (!multichainAccount) {\n // This new account is a new multichain account, let the wallet know\n // it has to re-sync with its providers.\n if (sync) {\n wallet.sync();\n }\n\n multichainAccount = wallet.getMultichainAccount(\n account.options.entropy.groupIndex,\n );\n\n // If that's a new multichain account. There's nothing to \"force-sync\".\n sync = false;\n }\n\n // We have to check against `undefined` in case `getMultichainAccount` is\n // not able to find this multichain account (which should not be possible...)\n if (multichainAccount) {\n if (sync) {\n multichainAccount.sync();\n }\n\n // Same here, this account should have been already grouped in that\n // multichain account.\n this.#accountIdToContext.set(account.id, {\n wallet,\n multichainAccount,\n });\n }\n }\n\n #handleOnAccountRemoved(id: InternalAccount['id']): void {\n // Force sync of the appropriate wallet if an account got removed.\n const found = this.#accountIdToContext.get(id);\n if (found) {\n const { wallet } = found;\n\n wallet.sync();\n }\n\n // Safe to call delete even if the `id` was not referencing a BIP-44 account.\n this.#accountIdToContext.delete(id);\n }\n\n #getWallet(\n entropySource: EntropySourceId,\n ): MultichainAccountWallet<Bip44Account<InternalAccount>> {\n const wallet = this.#wallets.get(\n toMultichainAccountWalletId(entropySource),\n );\n\n if (!wallet) {\n throw new Error('Unknown wallet, no wallet matching this entropy source');\n }\n\n return wallet;\n }\n\n /**\n * Gets a reference to the wallet and multichain account for a given account ID.\n *\n * @param id - Account ID.\n * @returns An object with references to the wallet and multichain account associated for\n * that account ID, or undefined if this account ID is not part of any.\n */\n getMultichainAccountAndWallet(\n id: InternalAccount['id'],\n ): AccountContext<Bip44Account<InternalAccount>> | undefined {\n return this.#accountIdToContext.get(id);\n }\n\n /**\n * Gets a reference to the multichain account wallet matching this entropy source.\n *\n * @param options - Options.\n * @param options.entropySource - The entropy source of the multichain account.\n * @throws If none multichain account match this entropy.\n * @returns A reference to the multichain account wallet.\n */\n getMultichainAccountWallet({\n entropySource,\n }: {\n entropySource: EntropySourceId;\n }): MultichainAccountWallet<Bip44Account<InternalAccount>> {\n return this.#getWallet(entropySource);\n }\n\n /**\n * Gets an array of all multichain account wallets.\n *\n * @returns An array of all multichain account wallets.\n */\n getMultichainAccountWallets(): MultichainAccountWallet<\n Bip44Account<InternalAccount>\n >[] {\n return Array.from(this.#wallets.values());\n }\n\n /**\n * Gets a reference to the multichain account matching this entropy source and group index.\n *\n * @param options - Options.\n * @param options.entropySource - The entropy source of the multichain account.\n * @param options.groupIndex - The group index of the multichain account.\n * @throws If none multichain account match this entropy source and group index.\n * @returns A reference to the multichain account.\n */\n getMultichainAccount({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): MultichainAccount<Bip44Account<InternalAccount>> {\n const multichainAccount =\n this.#getWallet(entropySource).getMultichainAccount(groupIndex);\n\n if (!multichainAccount) {\n throw new Error(`No multichain account for index: ${groupIndex}`);\n }\n\n return multichainAccount;\n }\n\n /**\n * Gets all multichain accounts for a given entropy source.\n *\n * @param options - Options.\n * @param options.entropySource - The entropy source to query.\n * @throws If no multichain accounts match this entropy source.\n * @returns A list of all multichain accounts.\n */\n getMultichainAccounts({\n entropySource,\n }: {\n entropySource: EntropySourceId;\n }): MultichainAccount<Bip44Account<InternalAccount>>[] {\n return this.#getWallet(entropySource).getMultichainAccounts();\n }\n}\n"]}
1
+ {"version":3,"file":"MultichainAccountService.mjs","sourceRoot":"","sources":["../src/MultichainAccountService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,OAAO,EACL,uBAAuB,EACvB,2BAA2B,EAE5B,8BAA8B;AAM/B,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAG5D,OAAO,EAAE,kBAAkB,EAAE,2CAAuC;AACpE,OAAO,EAAE,kBAAkB,EAAE,2CAAuC;AAGpE,MAAM,WAAW,GAAG,0BAA0B,CAAC;AAS/C;;;;;GAKG;AACH,SAAS,+BAA+B,CAAC,KAA6B;IACpE,OAAO,KAAK,CAAC,QAAQ,CAAC;AACxB,CAAC;AA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Gd;QACC,OAAO,uBAAA,IAAI,gFAAW,MAAf,IAAI,EAAY,aAAa,CAAC,CAAC,qBAAqB,EAAE,CAAC;IAChE,CAAC;CACF;yUA9E8B,QAAyB;IACpD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;QAC9B,IAAI,OAAO,CAAC,IAAI,KAAM,YAAY,CAAC,EAAa,EAAE;YAChD,+CAA+C;YAC/C,MAAM,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YAE1C,qFAAqF;YACrF,iFAAiF;YACjF,4DAA4D;YAC5D,IAAI,CAAC,uBAAA,IAAI,yCAAS,CAAC,GAAG,CAAC,2BAA2B,CAAC,aAAa,CAAC,CAAC,EAAE;gBAClE,8EAA8E;gBAC9E,2DAA2D;gBAC3D,MAAM,MAAM,GAAG,IAAI,uBAAuB,CAAC;oBACzC,aAAa;oBACb,SAAS,EAAE,uBAAA,IAAI,2CAAW;iBAC3B,CAAC,CAAC;gBAEH,uBAAA,IAAI,yCAAS,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;aACtC;SACF;KACF;AACH,CAAC,qFAGC,aAA8B;IAE9B,MAAM,MAAM,GAAG,uBAAA,IAAI,yCAAS,CAAC,GAAG,CAC9B,2BAA2B,CAAC,aAAa,CAAC,CAC3C,CAAC;IAEF,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;KAC3E;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type {\n MultichainAccountWalletId,\n AccountProvider,\n} from '@metamask/account-api';\nimport {\n MultichainAccountWallet,\n toMultichainAccountWalletId,\n type MultichainAccount,\n} from '@metamask/account-api';\nimport type { EntropySourceId } from '@metamask/keyring-api';\nimport type {\n KeyringControllerState,\n KeyringObject,\n} from '@metamask/keyring-controller';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { EvmAccountProvider } from './providers/EvmAccountProvider';\nimport { SolAccountProvider } from './providers/SolAccountProvider';\nimport type { MultichainAccountServiceMessenger } from './types';\n\nconst serviceName = 'MultichainAccountService';\n\n/**\n * The options that {@link MultichainAccountService} takes.\n */\ntype MultichainAccountServiceOptions = {\n messenger: MultichainAccountServiceMessenger;\n};\n\n/**\n * Select keyrings from keyring controller state.\n *\n * @param state - The keyring controller state.\n * @returns The keyrings.\n */\nfunction selectKeyringControllerKeyrings(state: KeyringControllerState) {\n return state.keyrings;\n}\n\n/**\n * Service to expose multichain accounts capabilities.\n */\nexport class MultichainAccountService {\n readonly #messenger: MultichainAccountServiceMessenger;\n\n readonly #providers: AccountProvider<InternalAccount>[];\n\n readonly #wallets: Map<\n MultichainAccountWalletId,\n MultichainAccountWallet<InternalAccount>\n >;\n\n /**\n * The name of the service.\n */\n name: typeof serviceName = serviceName;\n\n /**\n * Constructs a new MultichainAccountService.\n *\n * @param options - The options.\n * @param options.messenger - The messenger suited to this\n * MultichainAccountService.\n */\n constructor({ messenger }: MultichainAccountServiceOptions) {\n this.#messenger = messenger;\n this.#wallets = new Map();\n // TODO: Rely on keyring capabilities once the keyring API is used by all keyrings.\n this.#providers = [\n new EvmAccountProvider(this.#messenger),\n new SolAccountProvider(this.#messenger),\n ];\n }\n\n /**\n * Initialize the service and constructs the internal reprensentation of\n * multichain accounts and wallets.\n */\n init(): void {\n // Gather all entropy sources first.\n const state = this.#messenger.call('KeyringController:getState');\n this.#setMultichainAccountWallets(state.keyrings);\n\n this.#messenger.subscribe(\n 'KeyringController:stateChange',\n (keyrings) => {\n this.#setMultichainAccountWallets(keyrings);\n },\n selectKeyringControllerKeyrings,\n );\n }\n\n #setMultichainAccountWallets(keyrings: KeyringObject[]) {\n for (const keyring of keyrings) {\n if (keyring.type === (KeyringTypes.hd as string)) {\n // Only HD keyrings have an entropy source/SRP.\n const entropySource = keyring.metadata.id;\n\n // Do not re-create wallets if they exists. Even if a keyrings got new accounts, this\n // will be handled by the `*AccountProvider`s which are always in-sync with their\n // keyrings and controllers (like the `AccountsController`).\n if (!this.#wallets.has(toMultichainAccountWalletId(entropySource))) {\n // This will automatically \"associate\" all multichain accounts for that wallet\n // (based on the accounts owned by each account providers).\n const wallet = new MultichainAccountWallet({\n entropySource,\n providers: this.#providers,\n });\n\n this.#wallets.set(wallet.id, wallet);\n }\n }\n }\n }\n\n #getWallet(\n entropySource: EntropySourceId,\n ): MultichainAccountWallet<InternalAccount> {\n const wallet = this.#wallets.get(\n toMultichainAccountWalletId(entropySource),\n );\n\n if (!wallet) {\n throw new Error('Unknown wallet, no wallet matching this entropy source');\n }\n\n return wallet;\n }\n\n /**\n * Gets a reference to the multichain account matching this entropy source and group index.\n *\n * @param options - Options.\n * @param options.entropySource - The entropy source of the multichain account.\n * @param options.groupIndex - The group index of the multichain account.\n * @throws If none multichain account match this entropy source and group index.\n * @returns A reference to the multichain account.\n */\n getMultichainAccount({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): MultichainAccount<InternalAccount> {\n const multichainAccount =\n this.#getWallet(entropySource).getMultichainAccount(groupIndex);\n\n if (!multichainAccount) {\n throw new Error(`No multichain account for index: ${groupIndex}`);\n }\n\n return multichainAccount;\n }\n\n /**\n * Gets all multichain accounts for a given entropy source.\n *\n * @param options - Options.\n * @param options.entropySource - The entropy source to query.\n * @throws If no multichain accounts match this entropy source.\n * @returns A list of all multichain accounts.\n */\n getMultichainAccounts({\n entropySource,\n }: {\n entropySource: EntropySourceId;\n }): MultichainAccount<InternalAccount>[] {\n return this.#getWallet(entropySource).getMultichainAccounts();\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AASA,2EAAsE;AAA7D,oIAAA,wBAAwB,OAAA","sourcesContent":["export type {\n MultichainAccountServiceActions,\n MultichainAccountServiceEvents,\n MultichainAccountServiceMessenger,\n MultichainAccountServiceGetMultichainAccountAction,\n MultichainAccountServiceGetMultichainAccountWalletAction,\n MultichainAccountServiceGetMultichainAccountWalletsAction,\n MultichainAccountServiceGetMultichainAccountsAction,\n} from './types';\nexport { MultichainAccountService } from './MultichainAccountService';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAKA,2EAAsE;AAA7D,oIAAA,wBAAwB,OAAA","sourcesContent":["export type {\n MultichainAccountServiceActions,\n MultichainAccountServiceEvents,\n MultichainAccountServiceMessenger,\n} from './types';\nexport { MultichainAccountService } from './MultichainAccountService';\n"]}
package/dist/index.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- export type { MultichainAccountServiceActions, MultichainAccountServiceEvents, MultichainAccountServiceMessenger, MultichainAccountServiceGetMultichainAccountAction, MultichainAccountServiceGetMultichainAccountWalletAction, MultichainAccountServiceGetMultichainAccountWalletsAction, MultichainAccountServiceGetMultichainAccountsAction, } from "./types.cjs";
1
+ export type { MultichainAccountServiceActions, MultichainAccountServiceEvents, MultichainAccountServiceMessenger, } from "./types.cjs";
2
2
  export { MultichainAccountService } from "./MultichainAccountService.cjs";
3
3
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,EACjC,kDAAkD,EAClD,wDAAwD,EACxD,yDAAyD,EACzD,mDAAmD,GACpD,oBAAgB;AACjB,OAAO,EAAE,wBAAwB,EAAE,uCAAmC"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,GAClC,oBAAgB;AACjB,OAAO,EAAE,wBAAwB,EAAE,uCAAmC"}
package/dist/index.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- export type { MultichainAccountServiceActions, MultichainAccountServiceEvents, MultichainAccountServiceMessenger, MultichainAccountServiceGetMultichainAccountAction, MultichainAccountServiceGetMultichainAccountWalletAction, MultichainAccountServiceGetMultichainAccountWalletsAction, MultichainAccountServiceGetMultichainAccountsAction, } from "./types.mjs";
1
+ export type { MultichainAccountServiceActions, MultichainAccountServiceEvents, MultichainAccountServiceMessenger, } from "./types.mjs";
2
2
  export { MultichainAccountService } from "./MultichainAccountService.mjs";
3
3
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,EACjC,kDAAkD,EAClD,wDAAwD,EACxD,yDAAyD,EACzD,mDAAmD,GACpD,oBAAgB;AACjB,OAAO,EAAE,wBAAwB,EAAE,uCAAmC"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,GAClC,oBAAgB;AACjB,OAAO,EAAE,wBAAwB,EAAE,uCAAmC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,wBAAwB,EAAE,uCAAmC","sourcesContent":["export type {\n MultichainAccountServiceActions,\n MultichainAccountServiceEvents,\n MultichainAccountServiceMessenger,\n MultichainAccountServiceGetMultichainAccountAction,\n MultichainAccountServiceGetMultichainAccountWalletAction,\n MultichainAccountServiceGetMultichainAccountWalletsAction,\n MultichainAccountServiceGetMultichainAccountsAction,\n} from './types';\nexport { MultichainAccountService } from './MultichainAccountService';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,uCAAmC","sourcesContent":["export type {\n MultichainAccountServiceActions,\n MultichainAccountServiceEvents,\n MultichainAccountServiceMessenger,\n} from './types';\nexport { MultichainAccountService } from './MultichainAccountService';\n"]}
@@ -6,8 +6,23 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
6
6
  };
7
7
  var _BaseAccountProvider_instances, _BaseAccountProvider_getAccounts;
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.BaseAccountProvider = void 0;
10
- const account_api_1 = require("@metamask/account-api");
9
+ exports.BaseAccountProvider = exports.isBip44Account = void 0;
10
+ const keyring_api_1 = require("@metamask/keyring-api");
11
+ /**
12
+ * Checks if an account is BIP-44 compatible.
13
+ *
14
+ * @param account - The account to be tested.
15
+ * @returns True if the account is BIP-44 compatible.
16
+ */
17
+ function isBip44Account(account) {
18
+ if (!account.options.entropy ||
19
+ account.options.entropy.type !== keyring_api_1.KeyringAccountEntropyTypeOption.Mnemonic) {
20
+ console.warn("! Found an HD account with invalid entropy options: account won't be associated to its wallet.");
21
+ return false;
22
+ }
23
+ return true;
24
+ }
25
+ exports.isBip44Account = isBip44Account;
11
26
  class BaseAccountProvider {
12
27
  constructor(messenger) {
13
28
  _BaseAccountProvider_instances.add(this);
@@ -33,8 +48,8 @@ _BaseAccountProvider_instances = new WeakSet(), _BaseAccountProvider_getAccounts
33
48
  // accounts, including EVM and non-EVM. We might wanna change this action
34
49
  // name once we fully support multichain accounts.
35
50
  'AccountsController:listMultichainAccounts')) {
36
- if ((0, account_api_1.isBip44Account)(account) &&
37
- this.isAccountCompatible(account) &&
51
+ if (this.isAccountCompatible(account) &&
52
+ isBip44Account(account) &&
38
53
  filter(account)) {
39
54
  accounts.push(account);
40
55
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BaseAccountProvider.cjs","sourceRoot":"","sources":["../../src/providers/BaseAccountProvider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uDAI+B;AAK/B,MAAsB,mBAAmB;IAKvC,YAAY,SAA4C;;QACtD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAyBD,WAAW;QACT,OAAO,uBAAA,IAAI,wEAAa,MAAjB,IAAI,CAAe,CAAC;IAC7B,CAAC;IAED,UAAU,CAAC,EAAyB;QAClC,wDAAwD;QACxD,MAAM,CAAC,KAAK,CAAC,GAAG,uBAAA,IAAI,wEAAa,MAAjB,IAAI,EAAc,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAElE,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAC;SAClD;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CAGF;AAhDD,kDAgDC;6HAtCG,SAAgD,GAAG,EAAE,CAAC,IAAI;IAE1D,MAAM,QAAQ,GAAoC,EAAE,CAAC;IAErD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI;IACvC,2EAA2E;IAC3E,yEAAyE;IACzE,kDAAkD;IAClD,2CAA2C,CAC5C,EAAE;QACD,IACE,IAAA,4BAAc,EAAC,OAAO,CAAC;YACvB,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC;YACjC,MAAM,CAAC,OAAO,CAAC,EACf;YACA,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACxB;KACF;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {\n isBip44Account,\n type AccountProvider,\n type Bip44Account,\n} from '@metamask/account-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport type { MultichainAccountServiceMessenger } from '../types';\n\nexport abstract class BaseAccountProvider\n implements AccountProvider<Bip44Account<InternalAccount>>\n{\n protected readonly messenger: MultichainAccountServiceMessenger;\n\n constructor(messenger: MultichainAccountServiceMessenger) {\n this.messenger = messenger;\n }\n\n #getAccounts(\n filter: (account: InternalAccount) => boolean = () => true,\n ): Bip44Account<InternalAccount>[] {\n const accounts: Bip44Account<InternalAccount>[] = [];\n\n for (const account of this.messenger.call(\n // NOTE: Even though the name is misleading, this only fetches all internal\n // accounts, including EVM and non-EVM. We might wanna change this action\n // name once we fully support multichain accounts.\n 'AccountsController:listMultichainAccounts',\n )) {\n if (\n isBip44Account(account) &&\n this.isAccountCompatible(account) &&\n filter(account)\n ) {\n accounts.push(account);\n }\n }\n\n return accounts;\n }\n\n getAccounts(): Bip44Account<InternalAccount>[] {\n return this.#getAccounts();\n }\n\n getAccount(id: InternalAccount['id']): Bip44Account<InternalAccount> {\n // TODO: Maybe just use a proper find for faster lookup?\n const [found] = this.#getAccounts((account) => account.id === id);\n\n if (!found) {\n throw new Error(`Unable to find account: ${id}`);\n }\n\n return found;\n }\n\n abstract isAccountCompatible(account: Bip44Account<InternalAccount>): boolean;\n}\n"]}
1
+ {"version":3,"file":"BaseAccountProvider.cjs","sourceRoot":"","sources":["../../src/providers/BaseAccountProvider.ts"],"names":[],"mappings":";;;;;;;;;AAMA,uDAAwE;AAWxE;;;;;GAKG;AACH,SAAgB,cAAc,CAC5B,OAAgB;IAEhB,IACE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO;QACxB,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,KAAK,6CAA+B,CAAC,QAAQ,EACzE;QACA,OAAO,CAAC,IAAI,CACV,gGAAgG,CACjG,CAAC;QACF,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAdD,wCAcC;AAED,MAAsB,mBAAmB;IAKvC,YAAY,SAA4C;;QACtD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAyBD,WAAW;QACT,OAAO,uBAAA,IAAI,wEAAa,MAAjB,IAAI,CAAe,CAAC;IAC7B,CAAC;IAED,UAAU,CAAC,EAAa;QACtB,wDAAwD;QACxD,MAAM,CAAC,KAAK,CAAC,GAAG,uBAAA,IAAI,wEAAa,MAAjB,IAAI,EAAc,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAElE,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAC;SAClD;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CAGF;AAhDD,kDAgDC;6HAtCG,SAAgD,GAAG,EAAE,CAAC,IAAI;IAE1D,MAAM,QAAQ,GAAoC,EAAE,CAAC;IAErD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI;IACvC,2EAA2E;IAC3E,yEAAyE;IACzE,kDAAkD;IAClD,2CAA2C,CAC5C,EAAE;QACD,IACE,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC;YACjC,cAAc,CAAC,OAAO,CAAC;YACvB,MAAM,CAAC,OAAO,CAAC,EACf;YACA,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACxB;KACF;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import type { AccountProvider } from '@metamask/account-api';\nimport type { AccountId } from '@metamask/accounts-controller';\nimport type {\n KeyringAccount,\n KeyringAccountEntropyMnemonicOptions,\n} from '@metamask/keyring-api';\nimport { KeyringAccountEntropyTypeOption } from '@metamask/keyring-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport type { MultichainAccountServiceMessenger } from '../types';\n\nexport type Bip44Account<Account extends KeyringAccount> = Account & {\n options: {\n entropy: KeyringAccountEntropyMnemonicOptions;\n };\n};\n\n/**\n * Checks if an account is BIP-44 compatible.\n *\n * @param account - The account to be tested.\n * @returns True if the account is BIP-44 compatible.\n */\nexport function isBip44Account<Account extends KeyringAccount>(\n account: Account,\n): account is Bip44Account<Account> {\n if (\n !account.options.entropy ||\n account.options.entropy.type !== KeyringAccountEntropyTypeOption.Mnemonic\n ) {\n console.warn(\n \"! Found an HD account with invalid entropy options: account won't be associated to its wallet.\",\n );\n return false;\n }\n\n return true;\n}\n\nexport abstract class BaseAccountProvider\n implements AccountProvider<InternalAccount>\n{\n protected readonly messenger: MultichainAccountServiceMessenger;\n\n constructor(messenger: MultichainAccountServiceMessenger) {\n this.messenger = messenger;\n }\n\n #getAccounts(\n filter: (account: InternalAccount) => boolean = () => true,\n ): Bip44Account<InternalAccount>[] {\n const accounts: Bip44Account<InternalAccount>[] = [];\n\n for (const account of this.messenger.call(\n // NOTE: Even though the name is misleading, this only fetches all internal\n // accounts, including EVM and non-EVM. We might wanna change this action\n // name once we fully support multichain accounts.\n 'AccountsController:listMultichainAccounts',\n )) {\n if (\n this.isAccountCompatible(account) &&\n isBip44Account(account) &&\n filter(account)\n ) {\n accounts.push(account);\n }\n }\n\n return accounts;\n }\n\n getAccounts(): InternalAccount[] {\n return this.#getAccounts();\n }\n\n getAccount(id: AccountId): InternalAccount {\n // TODO: Maybe just use a proper find for faster lookup?\n const [found] = this.#getAccounts((account) => account.id === id);\n\n if (!found) {\n throw new Error(`Unable to find account: ${id}`);\n }\n\n return found;\n }\n\n abstract isAccountCompatible(account: InternalAccount): boolean;\n}\n"]}
@@ -1,12 +1,26 @@
1
- import { type AccountProvider, type Bip44Account } from "@metamask/account-api";
1
+ import type { AccountProvider } from "@metamask/account-api";
2
+ import type { AccountId } from "@metamask/accounts-controller";
3
+ import type { KeyringAccount, KeyringAccountEntropyMnemonicOptions } from "@metamask/keyring-api";
2
4
  import type { InternalAccount } from "@metamask/keyring-internal-api";
3
5
  import type { MultichainAccountServiceMessenger } from "../types.cjs";
4
- export declare abstract class BaseAccountProvider implements AccountProvider<Bip44Account<InternalAccount>> {
6
+ export type Bip44Account<Account extends KeyringAccount> = Account & {
7
+ options: {
8
+ entropy: KeyringAccountEntropyMnemonicOptions;
9
+ };
10
+ };
11
+ /**
12
+ * Checks if an account is BIP-44 compatible.
13
+ *
14
+ * @param account - The account to be tested.
15
+ * @returns True if the account is BIP-44 compatible.
16
+ */
17
+ export declare function isBip44Account<Account extends KeyringAccount>(account: Account): account is Bip44Account<Account>;
18
+ export declare abstract class BaseAccountProvider implements AccountProvider<InternalAccount> {
5
19
  #private;
6
20
  protected readonly messenger: MultichainAccountServiceMessenger;
7
21
  constructor(messenger: MultichainAccountServiceMessenger);
8
- getAccounts(): Bip44Account<InternalAccount>[];
9
- getAccount(id: InternalAccount['id']): Bip44Account<InternalAccount>;
10
- abstract isAccountCompatible(account: Bip44Account<InternalAccount>): boolean;
22
+ getAccounts(): InternalAccount[];
23
+ getAccount(id: AccountId): InternalAccount;
24
+ abstract isAccountCompatible(account: InternalAccount): boolean;
11
25
  }
12
26
  //# sourceMappingURL=BaseAccountProvider.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseAccountProvider.d.cts","sourceRoot":"","sources":["../../src/providers/BaseAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,8BAA8B;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAiB;AAElE,8BAAsB,mBACpB,YAAW,eAAe,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;;IAEzD,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,iCAAiC,CAAC;gBAEpD,SAAS,EAAE,iCAAiC;IA2BxD,WAAW,IAAI,YAAY,CAAC,eAAe,CAAC,EAAE;IAI9C,UAAU,CAAC,EAAE,EAAE,eAAe,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,eAAe,CAAC;IAWpE,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,eAAe,CAAC,GAAG,OAAO;CAC9E"}
1
+ {"version":3,"file":"BaseAccountProvider.d.cts","sourceRoot":"","sources":["../../src/providers/BaseAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,sCAAsC;AAC/D,OAAO,KAAK,EACV,cAAc,EACd,oCAAoC,EACrC,8BAA8B;AAE/B,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAiB;AAElE,MAAM,MAAM,YAAY,CAAC,OAAO,SAAS,cAAc,IAAI,OAAO,GAAG;IACnE,OAAO,EAAE;QACP,OAAO,EAAE,oCAAoC,CAAC;KAC/C,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,SAAS,cAAc,EAC3D,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAYlC;AAED,8BAAsB,mBACpB,YAAW,eAAe,CAAC,eAAe,CAAC;;IAE3C,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,iCAAiC,CAAC;gBAEpD,SAAS,EAAE,iCAAiC;IA2BxD,WAAW,IAAI,eAAe,EAAE;IAIhC,UAAU,CAAC,EAAE,EAAE,SAAS,GAAG,eAAe;IAW1C,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO;CAChE"}
@@ -1,12 +1,26 @@
1
- import { type AccountProvider, type Bip44Account } from "@metamask/account-api";
1
+ import type { AccountProvider } from "@metamask/account-api";
2
+ import type { AccountId } from "@metamask/accounts-controller";
3
+ import type { KeyringAccount, KeyringAccountEntropyMnemonicOptions } from "@metamask/keyring-api";
2
4
  import type { InternalAccount } from "@metamask/keyring-internal-api";
3
5
  import type { MultichainAccountServiceMessenger } from "../types.mjs";
4
- export declare abstract class BaseAccountProvider implements AccountProvider<Bip44Account<InternalAccount>> {
6
+ export type Bip44Account<Account extends KeyringAccount> = Account & {
7
+ options: {
8
+ entropy: KeyringAccountEntropyMnemonicOptions;
9
+ };
10
+ };
11
+ /**
12
+ * Checks if an account is BIP-44 compatible.
13
+ *
14
+ * @param account - The account to be tested.
15
+ * @returns True if the account is BIP-44 compatible.
16
+ */
17
+ export declare function isBip44Account<Account extends KeyringAccount>(account: Account): account is Bip44Account<Account>;
18
+ export declare abstract class BaseAccountProvider implements AccountProvider<InternalAccount> {
5
19
  #private;
6
20
  protected readonly messenger: MultichainAccountServiceMessenger;
7
21
  constructor(messenger: MultichainAccountServiceMessenger);
8
- getAccounts(): Bip44Account<InternalAccount>[];
9
- getAccount(id: InternalAccount['id']): Bip44Account<InternalAccount>;
10
- abstract isAccountCompatible(account: Bip44Account<InternalAccount>): boolean;
22
+ getAccounts(): InternalAccount[];
23
+ getAccount(id: AccountId): InternalAccount;
24
+ abstract isAccountCompatible(account: InternalAccount): boolean;
11
25
  }
12
26
  //# sourceMappingURL=BaseAccountProvider.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseAccountProvider.d.mts","sourceRoot":"","sources":["../../src/providers/BaseAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,8BAA8B;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAiB;AAElE,8BAAsB,mBACpB,YAAW,eAAe,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;;IAEzD,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,iCAAiC,CAAC;gBAEpD,SAAS,EAAE,iCAAiC;IA2BxD,WAAW,IAAI,YAAY,CAAC,eAAe,CAAC,EAAE;IAI9C,UAAU,CAAC,EAAE,EAAE,eAAe,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,eAAe,CAAC;IAWpE,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,eAAe,CAAC,GAAG,OAAO;CAC9E"}
1
+ {"version":3,"file":"BaseAccountProvider.d.mts","sourceRoot":"","sources":["../../src/providers/BaseAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,sCAAsC;AAC/D,OAAO,KAAK,EACV,cAAc,EACd,oCAAoC,EACrC,8BAA8B;AAE/B,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAiB;AAElE,MAAM,MAAM,YAAY,CAAC,OAAO,SAAS,cAAc,IAAI,OAAO,GAAG;IACnE,OAAO,EAAE;QACP,OAAO,EAAE,oCAAoC,CAAC;KAC/C,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,SAAS,cAAc,EAC3D,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAYlC;AAED,8BAAsB,mBACpB,YAAW,eAAe,CAAC,eAAe,CAAC;;IAE3C,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,iCAAiC,CAAC;gBAEpD,SAAS,EAAE,iCAAiC;IA2BxD,WAAW,IAAI,eAAe,EAAE;IAIhC,UAAU,CAAC,EAAE,EAAE,SAAS,GAAG,eAAe;IAW1C,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO;CAChE"}
@@ -4,7 +4,21 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
4
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
6
  var _BaseAccountProvider_instances, _BaseAccountProvider_getAccounts;
7
- import { isBip44Account } from "@metamask/account-api";
7
+ import { KeyringAccountEntropyTypeOption } from "@metamask/keyring-api";
8
+ /**
9
+ * Checks if an account is BIP-44 compatible.
10
+ *
11
+ * @param account - The account to be tested.
12
+ * @returns True if the account is BIP-44 compatible.
13
+ */
14
+ export function isBip44Account(account) {
15
+ if (!account.options.entropy ||
16
+ account.options.entropy.type !== KeyringAccountEntropyTypeOption.Mnemonic) {
17
+ console.warn("! Found an HD account with invalid entropy options: account won't be associated to its wallet.");
18
+ return false;
19
+ }
20
+ return true;
21
+ }
8
22
  export class BaseAccountProvider {
9
23
  constructor(messenger) {
10
24
  _BaseAccountProvider_instances.add(this);
@@ -29,8 +43,8 @@ _BaseAccountProvider_instances = new WeakSet(), _BaseAccountProvider_getAccounts
29
43
  // accounts, including EVM and non-EVM. We might wanna change this action
30
44
  // name once we fully support multichain accounts.
31
45
  'AccountsController:listMultichainAccounts')) {
32
- if (isBip44Account(account) &&
33
- this.isAccountCompatible(account) &&
46
+ if (this.isAccountCompatible(account) &&
47
+ isBip44Account(account) &&
34
48
  filter(account)) {
35
49
  accounts.push(account);
36
50
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BaseAccountProvider.mjs","sourceRoot":"","sources":["../../src/providers/BaseAccountProvider.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,cAAc,EAGf,8BAA8B;AAK/B,MAAM,OAAgB,mBAAmB;IAKvC,YAAY,SAA4C;;QACtD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAyBD,WAAW;QACT,OAAO,uBAAA,IAAI,wEAAa,MAAjB,IAAI,CAAe,CAAC;IAC7B,CAAC;IAED,UAAU,CAAC,EAAyB;QAClC,wDAAwD;QACxD,MAAM,CAAC,KAAK,CAAC,GAAG,uBAAA,IAAI,wEAAa,MAAjB,IAAI,EAAc,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAElE,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAC;SAClD;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CAGF;6HAtCG,SAAgD,GAAG,EAAE,CAAC,IAAI;IAE1D,MAAM,QAAQ,GAAoC,EAAE,CAAC;IAErD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI;IACvC,2EAA2E;IAC3E,yEAAyE;IACzE,kDAAkD;IAClD,2CAA2C,CAC5C,EAAE;QACD,IACE,cAAc,CAAC,OAAO,CAAC;YACvB,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC;YACjC,MAAM,CAAC,OAAO,CAAC,EACf;YACA,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACxB;KACF;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {\n isBip44Account,\n type AccountProvider,\n type Bip44Account,\n} from '@metamask/account-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport type { MultichainAccountServiceMessenger } from '../types';\n\nexport abstract class BaseAccountProvider\n implements AccountProvider<Bip44Account<InternalAccount>>\n{\n protected readonly messenger: MultichainAccountServiceMessenger;\n\n constructor(messenger: MultichainAccountServiceMessenger) {\n this.messenger = messenger;\n }\n\n #getAccounts(\n filter: (account: InternalAccount) => boolean = () => true,\n ): Bip44Account<InternalAccount>[] {\n const accounts: Bip44Account<InternalAccount>[] = [];\n\n for (const account of this.messenger.call(\n // NOTE: Even though the name is misleading, this only fetches all internal\n // accounts, including EVM and non-EVM. We might wanna change this action\n // name once we fully support multichain accounts.\n 'AccountsController:listMultichainAccounts',\n )) {\n if (\n isBip44Account(account) &&\n this.isAccountCompatible(account) &&\n filter(account)\n ) {\n accounts.push(account);\n }\n }\n\n return accounts;\n }\n\n getAccounts(): Bip44Account<InternalAccount>[] {\n return this.#getAccounts();\n }\n\n getAccount(id: InternalAccount['id']): Bip44Account<InternalAccount> {\n // TODO: Maybe just use a proper find for faster lookup?\n const [found] = this.#getAccounts((account) => account.id === id);\n\n if (!found) {\n throw new Error(`Unable to find account: ${id}`);\n }\n\n return found;\n }\n\n abstract isAccountCompatible(account: Bip44Account<InternalAccount>): boolean;\n}\n"]}
1
+ {"version":3,"file":"BaseAccountProvider.mjs","sourceRoot":"","sources":["../../src/providers/BaseAccountProvider.ts"],"names":[],"mappings":";;;;;;AAMA,OAAO,EAAE,+BAA+B,EAAE,8BAA8B;AAWxE;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ountProvider } from '@metamask/account-api';\nimport type { AccountId } from '@metamask/accounts-controller';\nimport type {\n KeyringAccount,\n KeyringAccountEntropyMnemonicOptions,\n} from '@metamask/keyring-api';\nimport { KeyringAccountEntropyTypeOption } from '@metamask/keyring-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport type { MultichainAccountServiceMessenger } from '../types';\n\nexport type Bip44Account<Account extends KeyringAccount> = Account & {\n options: {\n entropy: KeyringAccountEntropyMnemonicOptions;\n };\n};\n\n/**\n * Checks if an account is BIP-44 compatible.\n *\n * @param account - The account to be tested.\n * @returns True if the account is BIP-44 compatible.\n */\nexport function isBip44Account<Account extends KeyringAccount>(\n account: Account,\n): account is Bip44Account<Account> {\n if (\n !account.options.entropy ||\n account.options.entropy.type !== KeyringAccountEntropyTypeOption.Mnemonic\n ) {\n console.warn(\n \"! Found an HD account with invalid entropy options: account won't be associated to its wallet.\",\n );\n return false;\n }\n\n return true;\n}\n\nexport abstract class BaseAccountProvider\n implements AccountProvider<InternalAccount>\n{\n protected readonly messenger: MultichainAccountServiceMessenger;\n\n constructor(messenger: MultichainAccountServiceMessenger) {\n this.messenger = messenger;\n }\n\n #getAccounts(\n filter: (account: InternalAccount) => boolean = () => true,\n ): Bip44Account<InternalAccount>[] {\n const accounts: Bip44Account<InternalAccount>[] = [];\n\n for (const account of this.messenger.call(\n // NOTE: Even though the name is misleading, this only fetches all internal\n // accounts, including EVM and non-EVM. We might wanna change this action\n // name once we fully support multichain accounts.\n 'AccountsController:listMultichainAccounts',\n )) {\n if (\n this.isAccountCompatible(account) &&\n isBip44Account(account) &&\n filter(account)\n ) {\n accounts.push(account);\n }\n }\n\n return accounts;\n }\n\n getAccounts(): InternalAccount[] {\n return this.#getAccounts();\n }\n\n getAccount(id: AccountId): InternalAccount {\n // TODO: Maybe just use a proper find for faster lookup?\n const [found] = this.#getAccounts((account) => account.id === id);\n\n if (!found) {\n throw new Error(`Unable to find account: ${id}`);\n }\n\n return found;\n }\n\n abstract isAccountCompatible(account: InternalAccount): boolean;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"EvmAccountProvider.cjs","sourceRoot":"","sources":["../../src/providers/EvmAccountProvider.ts"],"names":[],"mappings":";;;AACA,uDAAuD;AACvD,qEAA4D;AAG5D,mEAA4D;AAE5D,MAAa,kBAAmB,SAAQ,yCAAmB;IACzD,mBAAmB,CAAC,OAAsC;QACxD,OAAO,CACL,OAAO,CAAC,IAAI,KAAK,4BAAc,CAAC,GAAG;YACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAM,iCAAY,CAAC,EAAa,CAC9D,CAAC;IACJ,CAAC;CACF;AAPD,gDAOC","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport { EthAccountType } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { BaseAccountProvider } from './BaseAccountProvider';\n\nexport class EvmAccountProvider extends BaseAccountProvider {\n isAccountCompatible(account: Bip44Account<InternalAccount>): boolean {\n return (\n account.type === EthAccountType.Eoa &&\n account.metadata.keyring.type === (KeyringTypes.hd as string)\n );\n }\n}\n"]}
1
+ {"version":3,"file":"EvmAccountProvider.cjs","sourceRoot":"","sources":["../../src/providers/EvmAccountProvider.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AACvD,qEAA4D;AAG5D,mEAA4D;AAE5D,MAAa,kBAAmB,SAAQ,yCAAmB;IACzD,mBAAmB,CAAC,OAAwB;QAC1C,OAAO,CACL,OAAO,CAAC,IAAI,KAAK,4BAAc,CAAC,GAAG;YACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAM,iCAAY,CAAC,EAAa,CAC9D,CAAC;IACJ,CAAC;CACF;AAPD,gDAOC","sourcesContent":["import { EthAccountType } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { BaseAccountProvider } from './BaseAccountProvider';\n\nexport class EvmAccountProvider extends BaseAccountProvider {\n isAccountCompatible(account: InternalAccount): boolean {\n return (\n account.type === EthAccountType.Eoa &&\n account.metadata.keyring.type === (KeyringTypes.hd as string)\n );\n }\n}\n"]}
@@ -1,7 +1,6 @@
1
- import type { Bip44Account } from "@metamask/account-api";
2
1
  import type { InternalAccount } from "@metamask/keyring-internal-api";
3
2
  import { BaseAccountProvider } from "./BaseAccountProvider.cjs";
4
3
  export declare class EvmAccountProvider extends BaseAccountProvider {
5
- isAccountCompatible(account: Bip44Account<InternalAccount>): boolean;
4
+ isAccountCompatible(account: InternalAccount): boolean;
6
5
  }
7
6
  //# sourceMappingURL=EvmAccountProvider.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EvmAccountProvider.d.cts","sourceRoot":"","sources":["../../src/providers/EvmAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,8BAA8B;AAG1D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,EAAE,mBAAmB,EAAE,kCAA8B;AAE5D,qBAAa,kBAAmB,SAAQ,mBAAmB;IACzD,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,eAAe,CAAC,GAAG,OAAO;CAMrE"}
1
+ {"version":3,"file":"EvmAccountProvider.d.cts","sourceRoot":"","sources":["../../src/providers/EvmAccountProvider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,EAAE,mBAAmB,EAAE,kCAA8B;AAE5D,qBAAa,kBAAmB,SAAQ,mBAAmB;IACzD,mBAAmB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO;CAMvD"}
@@ -1,7 +1,6 @@
1
- import type { Bip44Account } from "@metamask/account-api";
2
1
  import type { InternalAccount } from "@metamask/keyring-internal-api";
3
2
  import { BaseAccountProvider } from "./BaseAccountProvider.mjs";
4
3
  export declare class EvmAccountProvider extends BaseAccountProvider {
5
- isAccountCompatible(account: Bip44Account<InternalAccount>): boolean;
4
+ isAccountCompatible(account: InternalAccount): boolean;
6
5
  }
7
6
  //# sourceMappingURL=EvmAccountProvider.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EvmAccountProvider.d.mts","sourceRoot":"","sources":["../../src/providers/EvmAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,8BAA8B;AAG1D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,EAAE,mBAAmB,EAAE,kCAA8B;AAE5D,qBAAa,kBAAmB,SAAQ,mBAAmB;IACzD,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,eAAe,CAAC,GAAG,OAAO;CAMrE"}
1
+ {"version":3,"file":"EvmAccountProvider.d.mts","sourceRoot":"","sources":["../../src/providers/EvmAccountProvider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,EAAE,mBAAmB,EAAE,kCAA8B;AAE5D,qBAAa,kBAAmB,SAAQ,mBAAmB;IACzD,mBAAmB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO;CAMvD"}
@@ -1 +1 @@
1
- {"version":3,"file":"EvmAccountProvider.mjs","sourceRoot":"","sources":["../../src/providers/EvmAccountProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,8BAA8B;AACvD,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAG5D,OAAO,EAAE,mBAAmB,EAAE,kCAA8B;AAE5D,MAAM,OAAO,kBAAmB,SAAQ,mBAAmB;IACzD,mBAAmB,CAAC,OAAsC;QACxD,OAAO,CACL,OAAO,CAAC,IAAI,KAAK,cAAc,CAAC,GAAG;YACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAM,YAAY,CAAC,EAAa,CAC9D,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport { EthAccountType } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { BaseAccountProvider } from './BaseAccountProvider';\n\nexport class EvmAccountProvider extends BaseAccountProvider {\n isAccountCompatible(account: Bip44Account<InternalAccount>): boolean {\n return (\n account.type === EthAccountType.Eoa &&\n account.metadata.keyring.type === (KeyringTypes.hd as string)\n );\n }\n}\n"]}
1
+ {"version":3,"file":"EvmAccountProvider.mjs","sourceRoot":"","sources":["../../src/providers/EvmAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,8BAA8B;AACvD,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAG5D,OAAO,EAAE,mBAAmB,EAAE,kCAA8B;AAE5D,MAAM,OAAO,kBAAmB,SAAQ,mBAAmB;IACzD,mBAAmB,CAAC,OAAwB;QAC1C,OAAO,CACL,OAAO,CAAC,IAAI,KAAK,cAAc,CAAC,GAAG;YACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAM,YAAY,CAAC,EAAa,CAC9D,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { EthAccountType } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { BaseAccountProvider } from './BaseAccountProvider';\n\nexport class EvmAccountProvider extends BaseAccountProvider {\n isAccountCompatible(account: InternalAccount): boolean {\n return (\n account.type === EthAccountType.Eoa &&\n account.metadata.keyring.type === (KeyringTypes.hd as string)\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SolAccountProvider.cjs","sourceRoot":"","sources":["../../src/providers/SolAccountProvider.ts"],"names":[],"mappings":";;;AACA,uDAAuD;AACvD,qEAA4D;AAI5D,mEAA4D;AAE5D,MAAa,kBAAmB,SAAQ,yCAAmB;IAGzD,mBAAmB,CAAC,OAAsC;QACxD,OAAO,CACL,OAAO,CAAC,IAAI,KAAK,4BAAc,CAAC,WAAW;YAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAM,iCAAY,CAAC,IAAe,CAChE,CAAC;IACJ,CAAC;;AARH,gDASC;AARQ,iCAAc,GAAG,kCAA4C,CAAC","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport { SolAccountType } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { SnapId } from '@metamask/snaps-sdk';\n\nimport { BaseAccountProvider } from './BaseAccountProvider';\n\nexport class SolAccountProvider extends BaseAccountProvider {\n static SOLANA_SNAP_ID = 'npm:@metamask/solana-wallet-snap' as SnapId;\n\n isAccountCompatible(account: Bip44Account<InternalAccount>): boolean {\n return (\n account.type === SolAccountType.DataAccount &&\n account.metadata.keyring.type === (KeyringTypes.snap as string)\n );\n }\n}\n"]}
1
+ {"version":3,"file":"SolAccountProvider.cjs","sourceRoot":"","sources":["../../src/providers/SolAccountProvider.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AACvD,qEAA4D;AAI5D,mEAA4D;AAE5D,MAAa,kBAAmB,SAAQ,yCAAmB;IAGzD,mBAAmB,CAAC,OAAwB;QAC1C,OAAO,CACL,OAAO,CAAC,IAAI,KAAK,4BAAc,CAAC,WAAW;YAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAM,iCAAY,CAAC,IAAe,CAChE,CAAC;IACJ,CAAC;;AARH,gDASC;AARQ,iCAAc,GAAG,kCAA4C,CAAC","sourcesContent":["import { SolAccountType } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { SnapId } from '@metamask/snaps-sdk';\n\nimport { BaseAccountProvider } from './BaseAccountProvider';\n\nexport class SolAccountProvider extends BaseAccountProvider {\n static SOLANA_SNAP_ID = 'npm:@metamask/solana-wallet-snap' as SnapId;\n\n isAccountCompatible(account: InternalAccount): boolean {\n return (\n account.type === SolAccountType.DataAccount &&\n account.metadata.keyring.type === (KeyringTypes.snap as string)\n );\n }\n}\n"]}
@@ -1,9 +1,8 @@
1
- import type { Bip44Account } from "@metamask/account-api";
2
1
  import type { InternalAccount } from "@metamask/keyring-internal-api";
3
2
  import type { SnapId } from "@metamask/snaps-sdk";
4
3
  import { BaseAccountProvider } from "./BaseAccountProvider.cjs";
5
4
  export declare class SolAccountProvider extends BaseAccountProvider {
6
5
  static SOLANA_SNAP_ID: SnapId;
7
- isAccountCompatible(account: Bip44Account<InternalAccount>): boolean;
6
+ isAccountCompatible(account: InternalAccount): boolean;
8
7
  }
9
8
  //# sourceMappingURL=SolAccountProvider.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SolAccountProvider.d.cts","sourceRoot":"","sources":["../../src/providers/SolAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,8BAA8B;AAG1D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAElD,OAAO,EAAE,mBAAmB,EAAE,kCAA8B;AAE5D,qBAAa,kBAAmB,SAAQ,mBAAmB;IACzD,MAAM,CAAC,cAAc,SAAgD;IAErE,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,eAAe,CAAC,GAAG,OAAO;CAMrE"}
1
+ {"version":3,"file":"SolAccountProvider.d.cts","sourceRoot":"","sources":["../../src/providers/SolAccountProvider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAElD,OAAO,EAAE,mBAAmB,EAAE,kCAA8B;AAE5D,qBAAa,kBAAmB,SAAQ,mBAAmB;IACzD,MAAM,CAAC,cAAc,SAAgD;IAErE,mBAAmB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO;CAMvD"}
@@ -1,9 +1,8 @@
1
- import type { Bip44Account } from "@metamask/account-api";
2
1
  import type { InternalAccount } from "@metamask/keyring-internal-api";
3
2
  import type { SnapId } from "@metamask/snaps-sdk";
4
3
  import { BaseAccountProvider } from "./BaseAccountProvider.mjs";
5
4
  export declare class SolAccountProvider extends BaseAccountProvider {
6
5
  static SOLANA_SNAP_ID: SnapId;
7
- isAccountCompatible(account: Bip44Account<InternalAccount>): boolean;
6
+ isAccountCompatible(account: InternalAccount): boolean;
8
7
  }
9
8
  //# sourceMappingURL=SolAccountProvider.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SolAccountProvider.d.mts","sourceRoot":"","sources":["../../src/providers/SolAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,8BAA8B;AAG1D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAElD,OAAO,EAAE,mBAAmB,EAAE,kCAA8B;AAE5D,qBAAa,kBAAmB,SAAQ,mBAAmB;IACzD,MAAM,CAAC,cAAc,SAAgD;IAErE,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,eAAe,CAAC,GAAG,OAAO;CAMrE"}
1
+ {"version":3,"file":"SolAccountProvider.d.mts","sourceRoot":"","sources":["../../src/providers/SolAccountProvider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAElD,OAAO,EAAE,mBAAmB,EAAE,kCAA8B;AAE5D,qBAAa,kBAAmB,SAAQ,mBAAmB;IACzD,MAAM,CAAC,cAAc,SAAgD;IAErE,mBAAmB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO;CAMvD"}
@@ -1 +1 @@
1
- {"version":3,"file":"SolAccountProvider.mjs","sourceRoot":"","sources":["../../src/providers/SolAccountProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,8BAA8B;AACvD,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAI5D,OAAO,EAAE,mBAAmB,EAAE,kCAA8B;AAE5D,MAAM,OAAO,kBAAmB,SAAQ,mBAAmB;IAGzD,mBAAmB,CAAC,OAAsC;QACxD,OAAO,CACL,OAAO,CAAC,IAAI,KAAK,cAAc,CAAC,WAAW;YAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAM,YAAY,CAAC,IAAe,CAChE,CAAC;IACJ,CAAC;;AAPM,iCAAc,GAAG,kCAA4C,CAAC","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport { SolAccountType } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { SnapId } from '@metamask/snaps-sdk';\n\nimport { BaseAccountProvider } from './BaseAccountProvider';\n\nexport class SolAccountProvider extends BaseAccountProvider {\n static SOLANA_SNAP_ID = 'npm:@metamask/solana-wallet-snap' as SnapId;\n\n isAccountCompatible(account: Bip44Account<InternalAccount>): boolean {\n return (\n account.type === SolAccountType.DataAccount &&\n account.metadata.keyring.type === (KeyringTypes.snap as string)\n );\n }\n}\n"]}
1
+ {"version":3,"file":"SolAccountProvider.mjs","sourceRoot":"","sources":["../../src/providers/SolAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,8BAA8B;AACvD,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAI5D,OAAO,EAAE,mBAAmB,EAAE,kCAA8B;AAE5D,MAAM,OAAO,kBAAmB,SAAQ,mBAAmB;IAGzD,mBAAmB,CAAC,OAAwB;QAC1C,OAAO,CACL,OAAO,CAAC,IAAI,KAAK,cAAc,CAAC,WAAW;YAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAM,YAAY,CAAC,IAAe,CAChE,CAAC;IACJ,CAAC;;AAPM,iCAAc,GAAG,kCAA4C,CAAC","sourcesContent":["import { SolAccountType } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { SnapId } from '@metamask/snaps-sdk';\n\nimport { BaseAccountProvider } from './BaseAccountProvider';\n\nexport class SolAccountProvider extends BaseAccountProvider {\n static SOLANA_SNAP_ID = 'npm:@metamask/solana-wallet-snap' as SnapId;\n\n isAccountCompatible(account: InternalAccount): boolean {\n return (\n account.type === SolAccountType.DataAccount &&\n account.metadata.keyring.type === (KeyringTypes.snap as string)\n );\n }\n}\n"]}