@metamask-previews/multichain-account-service 0.2.1-preview-ec3106a5 → 0.2.1-preview-9fd73632

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 (52) hide show
  1. package/CHANGELOG.md +1 -10
  2. package/dist/MultichainAccountService.cjs +33 -97
  3. package/dist/MultichainAccountService.cjs.map +1 -1
  4. package/dist/MultichainAccountService.d.cts +4 -26
  5. package/dist/MultichainAccountService.d.cts.map +1 -1
  6. package/dist/MultichainAccountService.d.mts +4 -26
  7. package/dist/MultichainAccountService.d.mts.map +1 -1
  8. package/dist/MultichainAccountService.mjs +34 -98
  9. package/dist/MultichainAccountService.mjs.map +1 -1
  10. package/dist/providers/BaseAccountProvider.cjs +19 -4
  11. package/dist/providers/BaseAccountProvider.cjs.map +1 -1
  12. package/dist/providers/BaseAccountProvider.d.cts +19 -5
  13. package/dist/providers/BaseAccountProvider.d.cts.map +1 -1
  14. package/dist/providers/BaseAccountProvider.d.mts +19 -5
  15. package/dist/providers/BaseAccountProvider.d.mts.map +1 -1
  16. package/dist/providers/BaseAccountProvider.mjs +17 -3
  17. package/dist/providers/BaseAccountProvider.mjs.map +1 -1
  18. package/dist/providers/EvmAccountProvider.cjs.map +1 -1
  19. package/dist/providers/EvmAccountProvider.d.cts +1 -2
  20. package/dist/providers/EvmAccountProvider.d.cts.map +1 -1
  21. package/dist/providers/EvmAccountProvider.d.mts +1 -2
  22. package/dist/providers/EvmAccountProvider.d.mts.map +1 -1
  23. package/dist/providers/EvmAccountProvider.mjs.map +1 -1
  24. package/dist/providers/SolAccountProvider.cjs.map +1 -1
  25. package/dist/providers/SolAccountProvider.d.cts +1 -2
  26. package/dist/providers/SolAccountProvider.d.cts.map +1 -1
  27. package/dist/providers/SolAccountProvider.d.mts +1 -2
  28. package/dist/providers/SolAccountProvider.d.mts.map +1 -1
  29. package/dist/providers/SolAccountProvider.mjs.map +1 -1
  30. package/dist/tests/accounts.cjs +3 -7
  31. package/dist/tests/accounts.cjs.map +1 -1
  32. package/dist/tests/accounts.d.cts +0 -1
  33. package/dist/tests/accounts.d.cts.map +1 -1
  34. package/dist/tests/accounts.d.mts +0 -1
  35. package/dist/tests/accounts.d.mts.map +1 -1
  36. package/dist/tests/accounts.mjs +1 -5
  37. package/dist/tests/accounts.mjs.map +1 -1
  38. package/dist/tests/messenger.cjs +1 -5
  39. package/dist/tests/messenger.cjs.map +1 -1
  40. package/dist/tests/messenger.d.cts +2 -2
  41. package/dist/tests/messenger.d.cts.map +1 -1
  42. package/dist/tests/messenger.d.mts +2 -2
  43. package/dist/tests/messenger.d.mts.map +1 -1
  44. package/dist/tests/messenger.mjs +1 -5
  45. package/dist/tests/messenger.mjs.map +1 -1
  46. package/dist/types.cjs.map +1 -1
  47. package/dist/types.d.cts +2 -2
  48. package/dist/types.d.cts.map +1 -1
  49. package/dist/types.d.mts +2 -2
  50. package/dist/types.d.mts.map +1 -1
  51. package/dist/types.mjs.map +1 -1
  52. package/package.json +2 -3
@@ -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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,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,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mB,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;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAgB;IAEhB,IACE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO;QACxB,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,KAAK,+BAA+B,CAAC,QAAQ,EACzE;QACA,OAAO,CAAC,IAAI,CACV,gGAAgG,CACjG,CAAC;QACF,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,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,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;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 +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"]}
@@ -13,9 +13,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
13
  var _MockAccountBuilder_account;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.MockAccountBuilder = exports.MOCK_HARDWARE_ACCOUNT_1 = exports.MOCK_SNAP_ACCOUNT_2 = exports.MOCK_SNAP_ACCOUNT_1 = exports.MOCK_HD_ACCOUNT_2 = exports.MOCK_HD_ACCOUNT_1 = exports.MOCK_HD_KEYRING_2 = exports.MOCK_HD_KEYRING_1 = exports.MOCK_ENTROPY_SOURCE_2 = exports.MOCK_ENTROPY_SOURCE_1 = exports.MOCK_SNAP_2 = exports.MOCK_SNAP_1 = void 0;
16
- const account_api_1 = require("@metamask/account-api");
17
16
  const keyring_api_1 = require("@metamask/keyring-api");
18
17
  const keyring_controller_1 = require("@metamask/keyring-controller");
18
+ const BaseAccountProvider_1 = require("../providers/BaseAccountProvider.cjs");
19
19
  const ETH_EOA_METHODS = [
20
20
  keyring_api_1.EthMethod.PersonalSign,
21
21
  keyring_api_1.EthMethod.Sign,
@@ -158,18 +158,14 @@ class MockAccountBuilder {
158
158
  static from(account) {
159
159
  return new MockAccountBuilder(account);
160
160
  }
161
- withId(id) {
162
- __classPrivateFieldGet(this, _MockAccountBuilder_account, "f").id = id;
163
- return this;
164
- }
165
161
  withEntropySource(entropySource) {
166
- if ((0, account_api_1.isBip44Account)(__classPrivateFieldGet(this, _MockAccountBuilder_account, "f"))) {
162
+ if ((0, BaseAccountProvider_1.isBip44Account)(__classPrivateFieldGet(this, _MockAccountBuilder_account, "f"))) {
167
163
  __classPrivateFieldGet(this, _MockAccountBuilder_account, "f").options.entropy.id = entropySource;
168
164
  }
169
165
  return this;
170
166
  }
171
167
  withGroupIndex(groupIndex) {
172
- if ((0, account_api_1.isBip44Account)(__classPrivateFieldGet(this, _MockAccountBuilder_account, "f"))) {
168
+ if ((0, BaseAccountProvider_1.isBip44Account)(__classPrivateFieldGet(this, _MockAccountBuilder_account, "f"))) {
173
169
  __classPrivateFieldGet(this, _MockAccountBuilder_account, "f").options.entropy.groupIndex = groupIndex;
174
170
  }
175
171
  return this;
@@ -1 +1 @@
1
- {"version":3,"file":"accounts.cjs","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAAuD;AAEvD,uDAQ+B;AAC/B,qEAA4D;AAG5D,MAAM,eAAe,GAAG;IACt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KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,MAAA,CAAC;IACtD,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,OAAwB;QAClC,OAAO,IAAI,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,CAAC,EAAyB;QAC9B,uBAAA,IAAI,mCAAS,CAAC,EAAE,GAAG,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,iBAAiB,CAAC,aAA8B;QAC9C,IAAI,IAAA,4BAAc,EAAC,uBAAA,IAAI,mCAAS,CAAC,EAAE;YACjC,uBAAA,IAAI,mCAAS,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,aAAa,CAAC;SAClD;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,cAAc,CAAC,UAAkB;QAC/B,IAAI,IAAA,4BAAc,EAAC,uBAAA,IAAI,mCAAS,CAAC,EAAE;YACjC,uBAAA,IAAI,mCAAS,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC;SACvD;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG;QACD,OAAO,uBAAA,IAAI,mCAAS,CAAC;IACvB,CAAC;CACF;AAlCD,gDAkCC","sourcesContent":["import { isBip44Account } from '@metamask/account-api';\nimport type { EntropySourceId } from '@metamask/keyring-api';\nimport {\n EthAccountType,\n EthMethod,\n EthScope,\n KeyringAccountEntropyTypeOption,\n SolAccountType,\n SolMethod,\n SolScope,\n} from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nconst ETH_EOA_METHODS = [\n EthMethod.PersonalSign,\n EthMethod.Sign,\n EthMethod.SignTransaction,\n EthMethod.SignTypedDataV1,\n EthMethod.SignTypedDataV3,\n EthMethod.SignTypedDataV4,\n] as const;\n\nconst SOL_METHODS = Object.values(SolMethod);\n\nexport const MOCK_SNAP_1 = {\n id: 'local:mock-snap-id-1',\n name: 'Mock Snap 1',\n enabled: true,\n manifest: {\n proposedName: 'Mock Snap 1',\n },\n};\n\nexport const MOCK_SNAP_2 = {\n id: 'local:mock-snap-id-2',\n name: 'Mock Snap 2',\n enabled: true,\n manifest: {\n proposedName: 'Mock Snap 2',\n },\n};\n\nexport const MOCK_ENTROPY_SOURCE_1 = 'mock-keyring-id-1';\nexport const MOCK_ENTROPY_SOURCE_2 = 'mock-keyring-id-2';\n\nexport const MOCK_HD_KEYRING_1 = {\n type: KeyringTypes.hd,\n metadata: { id: MOCK_ENTROPY_SOURCE_1, name: 'HD Keyring 1' },\n accounts: ['0x123'],\n};\n\nexport const MOCK_HD_KEYRING_2 = {\n type: KeyringTypes.hd,\n metadata: { id: MOCK_ENTROPY_SOURCE_2, name: 'HD Keyring 2' },\n accounts: ['0x456'],\n};\n\nexport const MOCK_HD_ACCOUNT_1: InternalAccount = {\n id: 'mock-id-1',\n address: '0x123',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_HD_KEYRING_1.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Account 1',\n keyring: { type: KeyringTypes.hd },\n importTime: 0,\n lastSelected: 0,\n nameLastUpdatedAt: 0,\n },\n};\n\nexport const MOCK_HD_ACCOUNT_2: InternalAccount = {\n id: 'mock-id-2',\n address: '0x456',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_HD_KEYRING_2.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Account 2',\n keyring: { type: KeyringTypes.hd },\n importTime: 0,\n lastSelected: 0,\n nameLastUpdatedAt: 0,\n },\n};\n\nexport const MOCK_SNAP_ACCOUNT_1: InternalAccount = {\n id: 'mock-snap-id-1',\n address: 'aabbccdd',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_HD_KEYRING_2.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: SOL_METHODS,\n type: SolAccountType.DataAccount,\n scopes: [SolScope.Mainnet],\n metadata: {\n name: 'Snap Account 1',\n keyring: { type: KeyringTypes.snap },\n snap: MOCK_SNAP_1,\n importTime: 0,\n lastSelected: 0,\n },\n};\n\nexport const MOCK_SNAP_ACCOUNT_2: InternalAccount = {\n id: 'mock-snap-id-2',\n address: '0x789',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Snap Acc 2',\n keyring: { type: KeyringTypes.snap },\n snap: MOCK_SNAP_2,\n importTime: 0,\n lastSelected: 0,\n },\n};\n\nexport const MOCK_HARDWARE_ACCOUNT_1: InternalAccount = {\n id: 'mock-hardware-id-1',\n address: '0xABC',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Hardware Acc 1',\n keyring: { type: KeyringTypes.ledger },\n importTime: 0,\n lastSelected: 0,\n },\n};\n\nexport class MockAccountBuilder {\n readonly #account: InternalAccount;\n\n constructor(account: InternalAccount) {\n // Make a deep-copy to avoid mutating the same ref.\n this.#account = JSON.parse(JSON.stringify(account));\n }\n\n static from(account: InternalAccount): MockAccountBuilder {\n return new MockAccountBuilder(account);\n }\n\n withId(id: InternalAccount['id']) {\n this.#account.id = id;\n return this;\n }\n\n withEntropySource(entropySource: EntropySourceId) {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.id = entropySource;\n }\n return this;\n }\n\n withGroupIndex(groupIndex: number) {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.groupIndex = groupIndex;\n }\n return this;\n }\n\n get() {\n return this.#account;\n }\n}\n"]}
1
+ {"version":3,"file":"accounts.cjs","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,uDAQ+B;AAC/B,qEAA4D;AAG5D,8EAAkE;AAElE,MAAM,eAAe,GAAG;IACtB,uBAAS,CAAC,YAAY;IACtB,uBAAS,CAAC,IAAI;IACd,uBAAS,CAAC,eAAe;IACzB,uBAAS,CAAC,eAAe;IACzB,uBAAS,CAAC,eAAe;IACzB,uBAAS,CAAC,eAAe;CACjB,CAAC;AAEX,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,uBAAS,CAAC,CAAC;AAEhC,QAAA,WAAW,GAAG;IACzB,EAAE,EAAE,sBAAsB;IAC1B,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE;QACR,YAAY,EAAE,aAAa;KAC5B;CACF,CAAC;AAEW,QAAA,WAAW,GAAG;IACzB,EAAE,EAAE,sBAAsB;IAC1B,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE;QACR,YAAY,EAAE,aAAa;KAC5B;CACF,CAAC;AAEW,QAAA,qBAAqB,GAAG,mBAAmB,CAAC;AAC5C,QAAA,qBAAqB,GAAG,mBAAmB,CAAC;AAE5C,QAAA,iBAAiB,GAAG;IAC/B,IAAI,EAAE,iCAAY,CAAC,EAAE;IACrB,QAAQ,EAAE,EAAE,EAAE,EAAE,6BAAqB,EAAE,IAAI,EAAE,cAAc,EAAE;IAC7D,QAAQ,EAAE,CAAC,OAAO,CAAC;CACpB,CAAC;AAEW,QAAA,iBAAiB,GAAG;IAC/B,IAAI,EAAE,iCAAY,CAAC,EAAE;IACrB,QAAQ,EAAE,EAAE,EAAE,EAAE,6BAAqB,EAAE,IAAI,EAAE,cAAc,EAAE;IAC7D,QAAQ,EAAE,CAAC,OAAO,CAAC;CACpB,CAAC;AAEW,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E,IAAI,EAAE,iCAAY,CAAC,MAAM,EAAE;QACtC,UAAU,EAAE,CAAC;QACb,YAAY,EAAE,CAAC;KAChB;CACF,CAAC;AAEF,MAAa,kBAAkB;IAG7B,YAAY,OAAwB;QAF3B,8CAA0B;QAGjC,mDAAmD;QACnD,uBAAA,IAAI,+BAAY,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,MAAA,CAAC;IACtD,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,OAAwB;QAClC,OAAO,IAAI,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,iBAAiB,CAAC,aAA8B;QAC9C,IAAI,IAAA,oCAAc,EAAC,uBAAA,IAAI,mCAAS,CAAC,EAAE;YACjC,uBAAA,IAAI,mCAAS,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,aAAa,CAAC;SAClD;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,cAAc,CAAC,UAAkB;QAC/B,IAAI,IAAA,oCAAc,EAAC,uBAAA,IAAI,mCAAS,CAAC,EAAE;YACjC,uBAAA,IAAI,mCAAS,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC;SACvD;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG;QACD,OAAO,uBAAA,IAAI,mCAAS,CAAC;IACvB,CAAC;CACF;AA7BD,gDA6BC","sourcesContent":["import type { EntropySourceId } from '@metamask/keyring-api';\nimport {\n EthAccountType,\n EthMethod,\n EthScope,\n KeyringAccountEntropyTypeOption,\n SolAccountType,\n SolMethod,\n SolScope,\n} from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { isBip44Account } from '../providers/BaseAccountProvider';\n\nconst ETH_EOA_METHODS = [\n EthMethod.PersonalSign,\n EthMethod.Sign,\n EthMethod.SignTransaction,\n EthMethod.SignTypedDataV1,\n EthMethod.SignTypedDataV3,\n EthMethod.SignTypedDataV4,\n] as const;\n\nconst SOL_METHODS = Object.values(SolMethod);\n\nexport const MOCK_SNAP_1 = {\n id: 'local:mock-snap-id-1',\n name: 'Mock Snap 1',\n enabled: true,\n manifest: {\n proposedName: 'Mock Snap 1',\n },\n};\n\nexport const MOCK_SNAP_2 = {\n id: 'local:mock-snap-id-2',\n name: 'Mock Snap 2',\n enabled: true,\n manifest: {\n proposedName: 'Mock Snap 2',\n },\n};\n\nexport const MOCK_ENTROPY_SOURCE_1 = 'mock-keyring-id-1';\nexport const MOCK_ENTROPY_SOURCE_2 = 'mock-keyring-id-2';\n\nexport const MOCK_HD_KEYRING_1 = {\n type: KeyringTypes.hd,\n metadata: { id: MOCK_ENTROPY_SOURCE_1, name: 'HD Keyring 1' },\n accounts: ['0x123'],\n};\n\nexport const MOCK_HD_KEYRING_2 = {\n type: KeyringTypes.hd,\n metadata: { id: MOCK_ENTROPY_SOURCE_2, name: 'HD Keyring 2' },\n accounts: ['0x456'],\n};\n\nexport const MOCK_HD_ACCOUNT_1: InternalAccount = {\n id: 'mock-id-1',\n address: '0x123',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_HD_KEYRING_1.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Account 1',\n keyring: { type: KeyringTypes.hd },\n importTime: 0,\n lastSelected: 0,\n nameLastUpdatedAt: 0,\n },\n};\n\nexport const MOCK_HD_ACCOUNT_2: InternalAccount = {\n id: 'mock-id-2',\n address: '0x456',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_HD_KEYRING_2.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Account 2',\n keyring: { type: KeyringTypes.hd },\n importTime: 0,\n lastSelected: 0,\n nameLastUpdatedAt: 0,\n },\n};\n\nexport const MOCK_SNAP_ACCOUNT_1: InternalAccount = {\n id: 'mock-snap-id-1',\n address: 'aabbccdd',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_HD_KEYRING_2.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: SOL_METHODS,\n type: SolAccountType.DataAccount,\n scopes: [SolScope.Mainnet],\n metadata: {\n name: 'Snap Account 1',\n keyring: { type: KeyringTypes.snap },\n snap: MOCK_SNAP_1,\n importTime: 0,\n lastSelected: 0,\n },\n};\n\nexport const MOCK_SNAP_ACCOUNT_2: InternalAccount = {\n id: 'mock-snap-id-2',\n address: '0x789',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Snap Acc 2',\n keyring: { type: KeyringTypes.snap },\n snap: MOCK_SNAP_2,\n importTime: 0,\n lastSelected: 0,\n },\n};\n\nexport const MOCK_HARDWARE_ACCOUNT_1: InternalAccount = {\n id: 'mock-hardware-id-1',\n address: '0xABC',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Hardware Acc 1',\n keyring: { type: KeyringTypes.ledger },\n importTime: 0,\n lastSelected: 0,\n },\n};\n\nexport class MockAccountBuilder {\n readonly #account: InternalAccount;\n\n constructor(account: InternalAccount) {\n // Make a deep-copy to avoid mutating the same ref.\n this.#account = JSON.parse(JSON.stringify(account));\n }\n\n static from(account: InternalAccount): MockAccountBuilder {\n return new MockAccountBuilder(account);\n }\n\n withEntropySource(entropySource: EntropySourceId) {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.id = entropySource;\n }\n return this;\n }\n\n withGroupIndex(groupIndex: number) {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.groupIndex = groupIndex;\n }\n return this;\n }\n\n get() {\n return this.#account;\n }\n}\n"]}
@@ -44,7 +44,6 @@ export declare class MockAccountBuilder {
44
44
  #private;
45
45
  constructor(account: InternalAccount);
46
46
  static from(account: InternalAccount): MockAccountBuilder;
47
- withId(id: InternalAccount['id']): this;
48
47
  withEntropySource(entropySource: EntropySourceId): this;
49
48
  withGroupIndex(groupIndex: number): this;
50
49
  get(): {
@@ -1 +1 @@
1
- {"version":3,"file":"accounts.d.cts","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAU7D,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAatE,eAAO,MAAM,WAAW;;;;;;;CAOvB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;CAOvB,CAAC;AAEF,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AACzD,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AAEzD,eAAO,MAAM,iBAAiB;;;;;;;CAI7B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;CAI7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,eAqB/B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,eAqB/B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,eAsBjC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,eAcjC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,eAarC,CAAC;AAEF,qBAAa,kBAAkB;;gBAGjB,OAAO,EAAE,eAAe;IAKpC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,kBAAkB;IAIzD,MAAM,CAAC,EAAE,EAAE,eAAe,CAAC,IAAI,CAAC;IAKhC,iBAAiB,CAAC,aAAa,EAAE,eAAe;IAOhD,cAAc,CAAC,UAAU,EAAE,MAAM;IAOjC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGJ"}
1
+ {"version":3,"file":"accounts.d.cts","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAU7D,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAetE,eAAO,MAAM,WAAW;;;;;;;CAOvB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;CAOvB,CAAC;AAEF,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AACzD,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AAEzD,eAAO,MAAM,iBAAiB;;;;;;;CAI7B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;CAI7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,eAqB/B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,eAqB/B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,eAsBjC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,eAcjC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,eAarC,CAAC;AAEF,qBAAa,kBAAkB;;gBAGjB,OAAO,EAAE,eAAe;IAKpC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,kBAAkB;IAIzD,iBAAiB,CAAC,aAAa,EAAE,eAAe;IAOhD,cAAc,CAAC,UAAU,EAAE,MAAM;IAOjC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGJ"}
@@ -44,7 +44,6 @@ export declare class MockAccountBuilder {
44
44
  #private;
45
45
  constructor(account: InternalAccount);
46
46
  static from(account: InternalAccount): MockAccountBuilder;
47
- withId(id: InternalAccount['id']): this;
48
47
  withEntropySource(entropySource: EntropySourceId): this;
49
48
  withGroupIndex(groupIndex: number): this;
50
49
  get(): {
@@ -1 +1 @@
1
- {"version":3,"file":"accounts.d.mts","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAU7D,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAatE,eAAO,MAAM,WAAW;;;;;;;CAOvB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;CAOvB,CAAC;AAEF,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AACzD,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AAEzD,eAAO,MAAM,iBAAiB;;;;;;;CAI7B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;CAI7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,eAqB/B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,eAqB/B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,eAsBjC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,eAcjC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,eAarC,CAAC;AAEF,qBAAa,kBAAkB;;gBAGjB,OAAO,EAAE,eAAe;IAKpC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,kBAAkB;IAIzD,MAAM,CAAC,EAAE,EAAE,eAAe,CAAC,IAAI,CAAC;IAKhC,iBAAiB,CAAC,aAAa,EAAE,eAAe;IAOhD,cAAc,CAAC,UAAU,EAAE,MAAM;IAOjC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGJ"}
1
+ {"version":3,"file":"accounts.d.mts","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAU7D,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAetE,eAAO,MAAM,WAAW;;;;;;;CAOvB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;CAOvB,CAAC;AAEF,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AACzD,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AAEzD,eAAO,MAAM,iBAAiB;;;;;;;CAI7B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;CAI7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,eAqB/B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,eAqB/B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,eAsBjC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,eAcjC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,eAarC,CAAC;AAEF,qBAAa,kBAAkB;;gBAGjB,OAAO,EAAE,eAAe;IAKpC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,kBAAkB;IAIzD,iBAAiB,CAAC,aAAa,EAAE,eAAe;IAOhD,cAAc,CAAC,UAAU,EAAE,MAAM;IAOjC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGJ"}
@@ -10,9 +10,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
12
  var _MockAccountBuilder_account;
13
- import { isBip44Account } from "@metamask/account-api";
14
13
  import { EthAccountType, EthMethod, EthScope, KeyringAccountEntropyTypeOption, SolAccountType, SolMethod, SolScope } from "@metamask/keyring-api";
15
14
  import { KeyringTypes } from "@metamask/keyring-controller";
15
+ import { isBip44Account } from "../providers/BaseAccountProvider.mjs";
16
16
  const ETH_EOA_METHODS = [
17
17
  EthMethod.PersonalSign,
18
18
  EthMethod.Sign,
@@ -155,10 +155,6 @@ export class MockAccountBuilder {
155
155
  static from(account) {
156
156
  return new MockAccountBuilder(account);
157
157
  }
158
- withId(id) {
159
- __classPrivateFieldGet(this, _MockAccountBuilder_account, "f").id = id;
160
- return this;
161
- }
162
158
  withEntropySource(entropySource) {
163
159
  if (isBip44Account(__classPrivateFieldGet(this, _MockAccountBuilder_account, "f"))) {
164
160
  __classPrivateFieldGet(this, _MockAccountBuilder_account, "f").options.entropy.id = entropySource;
@@ -1 +1 @@
1
- {"version":3,"file":"accounts.mjs","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,8BAA8B;AAEvD,OAAO,EACL,cAAc,EACd,SAAS,EACT,QAAQ,EACR,+BAA+B,EAC/B,cAAc,EACd,SAAS,EACT,QAAQ,EACT,8BAA8B;AAC/B,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAG5D,MAAM,eAAe,GAAG;IACtB,SAAS,CAAC,YAAY;IACtB,SAAS,CAAC,IAAI;IACd,SAAS,CAAC,eAAe;IACzB,SAAS,CAAC,eAAe;IACzB,SAAS,CAAC,eAAe;IACzB,SAAS,CAAC,eAAe;CACjB,CAAC;AAEX,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AAE7C,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,EAAE,EAAE,sBAAsB;IAC1B,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE;QACR,YAAY,EAAE,aAAa;KAC5B;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,EAAE,EAAE,sBAAsB;IAC1B,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE;QACR,YAAY,EAAE,aAAa;KAC5B;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AACzD,MAAM,CAAC,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AAEzD,MA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AC,EAAE;YACjC,uBAAA,IAAI,mCAAS,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC;SACvD;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG;QACD,OAAO,uBAAA,IAAI,mCAAS,CAAC;IACvB,CAAC;CACF","sourcesContent":["import { isBip44Account } from '@metamask/account-api';\nimport type { EntropySourceId } from '@metamask/keyring-api';\nimport {\n EthAccountType,\n EthMethod,\n EthScope,\n KeyringAccountEntropyTypeOption,\n SolAccountType,\n SolMethod,\n SolScope,\n} from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nconst ETH_EOA_METHODS = [\n EthMethod.PersonalSign,\n EthMethod.Sign,\n EthMethod.SignTransaction,\n EthMethod.SignTypedDataV1,\n EthMethod.SignTypedDataV3,\n EthMethod.SignTypedDataV4,\n] as const;\n\nconst SOL_METHODS = Object.values(SolMethod);\n\nexport const MOCK_SNAP_1 = {\n id: 'local:mock-snap-id-1',\n name: 'Mock Snap 1',\n enabled: true,\n manifest: {\n proposedName: 'Mock Snap 1',\n },\n};\n\nexport const MOCK_SNAP_2 = {\n id: 'local:mock-snap-id-2',\n name: 'Mock Snap 2',\n enabled: true,\n manifest: {\n proposedName: 'Mock Snap 2',\n },\n};\n\nexport const MOCK_ENTROPY_SOURCE_1 = 'mock-keyring-id-1';\nexport const MOCK_ENTROPY_SOURCE_2 = 'mock-keyring-id-2';\n\nexport const MOCK_HD_KEYRING_1 = {\n type: KeyringTypes.hd,\n metadata: { id: MOCK_ENTROPY_SOURCE_1, name: 'HD Keyring 1' },\n accounts: ['0x123'],\n};\n\nexport const MOCK_HD_KEYRING_2 = {\n type: KeyringTypes.hd,\n metadata: { id: MOCK_ENTROPY_SOURCE_2, name: 'HD Keyring 2' },\n accounts: ['0x456'],\n};\n\nexport const MOCK_HD_ACCOUNT_1: InternalAccount = {\n id: 'mock-id-1',\n address: '0x123',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_HD_KEYRING_1.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Account 1',\n keyring: { type: KeyringTypes.hd },\n importTime: 0,\n lastSelected: 0,\n nameLastUpdatedAt: 0,\n },\n};\n\nexport const MOCK_HD_ACCOUNT_2: InternalAccount = {\n id: 'mock-id-2',\n address: '0x456',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_HD_KEYRING_2.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Account 2',\n keyring: { type: KeyringTypes.hd },\n importTime: 0,\n lastSelected: 0,\n nameLastUpdatedAt: 0,\n },\n};\n\nexport const MOCK_SNAP_ACCOUNT_1: InternalAccount = {\n id: 'mock-snap-id-1',\n address: 'aabbccdd',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_HD_KEYRING_2.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: SOL_METHODS,\n type: SolAccountType.DataAccount,\n scopes: [SolScope.Mainnet],\n metadata: {\n name: 'Snap Account 1',\n keyring: { type: KeyringTypes.snap },\n snap: MOCK_SNAP_1,\n importTime: 0,\n lastSelected: 0,\n },\n};\n\nexport const MOCK_SNAP_ACCOUNT_2: InternalAccount = {\n id: 'mock-snap-id-2',\n address: '0x789',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Snap Acc 2',\n keyring: { type: KeyringTypes.snap },\n snap: MOCK_SNAP_2,\n importTime: 0,\n lastSelected: 0,\n },\n};\n\nexport const MOCK_HARDWARE_ACCOUNT_1: InternalAccount = {\n id: 'mock-hardware-id-1',\n address: '0xABC',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Hardware Acc 1',\n keyring: { type: KeyringTypes.ledger },\n importTime: 0,\n lastSelected: 0,\n },\n};\n\nexport class MockAccountBuilder {\n readonly #account: InternalAccount;\n\n constructor(account: InternalAccount) {\n // Make a deep-copy to avoid mutating the same ref.\n this.#account = JSON.parse(JSON.stringify(account));\n }\n\n static from(account: InternalAccount): MockAccountBuilder {\n return new MockAccountBuilder(account);\n }\n\n withId(id: InternalAccount['id']) {\n this.#account.id = id;\n return this;\n }\n\n withEntropySource(entropySource: EntropySourceId) {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.id = entropySource;\n }\n return this;\n }\n\n withGroupIndex(groupIndex: number) {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.groupIndex = groupIndex;\n }\n return this;\n }\n\n get() {\n return this.#account;\n }\n}\n"]}
1
+ {"version":3,"file":"accounts.mjs","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EACL,cAAc,EACd,SAAS,EACT,QAAQ,EACR,+BAA+B,EAC/B,cAAc,EACd,SAAS,EACT,QAAQ,EACT,8BAA8B;AAC/B,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAG5D,OAAO,EAAE,cAAc,EAAE,6CAAyC;AAElE,MAAM,eAAe,GAAG;IACtB,SAAS,CAAC,YAAY;IACtB,SAAS,CAAC,IAAI;IACd,SAAS,CAAC,eAAe;IACzB,SAAS,CAAC,eAAe;IACzB,SAAS,CAAC,eAAe;IACzB,SAAS,CAAC,eAAe;CACjB,CAAC;AAEX,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AAE7C,MAAM,CAAC,MAAM,WAAW,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AC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,iBAAiB,CAAC,aAA8B;QAC9C,IAAI,cAAc,CAAC,uBAAA,IAAI,mCAAS,CAAC,EAAE;YACjC,uBAAA,IAAI,mCAAS,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,aAAa,CAAC;SAClD;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,cAAc,CAAC,UAAkB;QAC/B,IAAI,cAAc,CAAC,uBAAA,IAAI,mCAAS,CAAC,EAAE;YACjC,uBAAA,IAAI,mCAAS,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC;SACvD;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG;QACD,OAAO,uBAAA,IAAI,mCAAS,CAAC;IACvB,CAAC;CACF","sourcesContent":["import type { EntropySourceId } from '@metamask/keyring-api';\nimport {\n EthAccountType,\n EthMethod,\n EthScope,\n KeyringAccountEntropyTypeOption,\n SolAccountType,\n SolMethod,\n SolScope,\n} from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { isBip44Account } from '../providers/BaseAccountProvider';\n\nconst ETH_EOA_METHODS = [\n EthMethod.PersonalSign,\n EthMethod.Sign,\n EthMethod.SignTransaction,\n EthMethod.SignTypedDataV1,\n EthMethod.SignTypedDataV3,\n EthMethod.SignTypedDataV4,\n] as const;\n\nconst SOL_METHODS = Object.values(SolMethod);\n\nexport const MOCK_SNAP_1 = {\n id: 'local:mock-snap-id-1',\n name: 'Mock Snap 1',\n enabled: true,\n manifest: {\n proposedName: 'Mock Snap 1',\n },\n};\n\nexport const MOCK_SNAP_2 = {\n id: 'local:mock-snap-id-2',\n name: 'Mock Snap 2',\n enabled: true,\n manifest: {\n proposedName: 'Mock Snap 2',\n },\n};\n\nexport const MOCK_ENTROPY_SOURCE_1 = 'mock-keyring-id-1';\nexport const MOCK_ENTROPY_SOURCE_2 = 'mock-keyring-id-2';\n\nexport const MOCK_HD_KEYRING_1 = {\n type: KeyringTypes.hd,\n metadata: { id: MOCK_ENTROPY_SOURCE_1, name: 'HD Keyring 1' },\n accounts: ['0x123'],\n};\n\nexport const MOCK_HD_KEYRING_2 = {\n type: KeyringTypes.hd,\n metadata: { id: MOCK_ENTROPY_SOURCE_2, name: 'HD Keyring 2' },\n accounts: ['0x456'],\n};\n\nexport const MOCK_HD_ACCOUNT_1: InternalAccount = {\n id: 'mock-id-1',\n address: '0x123',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_HD_KEYRING_1.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Account 1',\n keyring: { type: KeyringTypes.hd },\n importTime: 0,\n lastSelected: 0,\n nameLastUpdatedAt: 0,\n },\n};\n\nexport const MOCK_HD_ACCOUNT_2: InternalAccount = {\n id: 'mock-id-2',\n address: '0x456',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_HD_KEYRING_2.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Account 2',\n keyring: { type: KeyringTypes.hd },\n importTime: 0,\n lastSelected: 0,\n nameLastUpdatedAt: 0,\n },\n};\n\nexport const MOCK_SNAP_ACCOUNT_1: InternalAccount = {\n id: 'mock-snap-id-1',\n address: 'aabbccdd',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_HD_KEYRING_2.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: SOL_METHODS,\n type: SolAccountType.DataAccount,\n scopes: [SolScope.Mainnet],\n metadata: {\n name: 'Snap Account 1',\n keyring: { type: KeyringTypes.snap },\n snap: MOCK_SNAP_1,\n importTime: 0,\n lastSelected: 0,\n },\n};\n\nexport const MOCK_SNAP_ACCOUNT_2: InternalAccount = {\n id: 'mock-snap-id-2',\n address: '0x789',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Snap Acc 2',\n keyring: { type: KeyringTypes.snap },\n snap: MOCK_SNAP_2,\n importTime: 0,\n lastSelected: 0,\n },\n};\n\nexport const MOCK_HARDWARE_ACCOUNT_1: InternalAccount = {\n id: 'mock-hardware-id-1',\n address: '0xABC',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Hardware Acc 1',\n keyring: { type: KeyringTypes.ledger },\n importTime: 0,\n lastSelected: 0,\n },\n};\n\nexport class MockAccountBuilder {\n readonly #account: InternalAccount;\n\n constructor(account: InternalAccount) {\n // Make a deep-copy to avoid mutating the same ref.\n this.#account = JSON.parse(JSON.stringify(account));\n }\n\n static from(account: InternalAccount): MockAccountBuilder {\n return new MockAccountBuilder(account);\n }\n\n withEntropySource(entropySource: EntropySourceId) {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.id = entropySource;\n }\n return this;\n }\n\n withGroupIndex(groupIndex: number) {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.groupIndex = groupIndex;\n }\n return this;\n }\n\n get() {\n return this.#account;\n }\n}\n"]}
@@ -20,11 +20,7 @@ exports.getRootMessenger = getRootMessenger;
20
20
  function getMultichainAccountServiceMessenger(messenger) {
21
21
  return messenger.getRestricted({
22
22
  name: 'MultichainAccountService',
23
- allowedEvents: [
24
- 'KeyringController:stateChange',
25
- 'AccountsController:accountAdded',
26
- 'AccountsController:accountRemoved',
27
- ],
23
+ allowedEvents: ['KeyringController:stateChange'],
28
24
  allowedActions: [
29
25
  'AccountsController:getAccount',
30
26
  'AccountsController:getAccountByAddress',
@@ -1 +1 @@
1
- {"version":3,"file":"messenger.cjs","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":";;;AAAA,+DAAsD;AAUtD;;;;GAIG;AACH,SAAgB,gBAAgB;IAC9B,OAAO,IAAI,2BAAS,EAGjB,CAAC;AACN,CAAC;AALD,4CAKC;AAED;;;;;GAKG;AACH,SAAgB,oCAAoC,CAClD,SAA8C;IAE9C,OAAO,SAAS,CAAC,aAAa,CAAC;QAC7B,IAAI,EAAE,0BAA0B;QAChC,aAAa,EAAE;YACb,+BAA+B;YAC/B,iCAAiC;YACjC,mCAAmC;SACpC;QACD,cAAc,EAAE;YACd,+BAA+B;YAC/B,wCAAwC;YACxC,2CAA2C;YAC3C,8BAA8B;YAC9B,+BAA+B;YAC/B,4BAA4B;SAC7B;KACF,CAAC,CAAC;AACL,CAAC;AAnBD,oFAmBC","sourcesContent":["import { Messenger } from '@metamask/base-controller';\n\nimport type {\n AllowedActions,\n AllowedEvents,\n MultichainAccountServiceActions,\n MultichainAccountServiceEvents,\n MultichainAccountServiceMessenger,\n} from '../types';\n\n/**\n * Creates a new root messenger instance for testing.\n *\n * @returns A new Messenger instance.\n */\nexport function getRootMessenger() {\n return new Messenger<\n MultichainAccountServiceActions | AllowedActions,\n MultichainAccountServiceEvents | AllowedEvents\n >();\n}\n\n/**\n * Retrieves a restricted messenger for the MultichainAccountService.\n *\n * @param messenger - The root messenger instance. Defaults to a new Messenger created by getRootMessenger().\n * @returns The restricted messenger for the MultichainAccountService.\n */\nexport function getMultichainAccountServiceMessenger(\n messenger: ReturnType<typeof getRootMessenger>,\n): MultichainAccountServiceMessenger {\n return messenger.getRestricted({\n name: 'MultichainAccountService',\n allowedEvents: [\n 'KeyringController:stateChange',\n 'AccountsController:accountAdded',\n 'AccountsController:accountRemoved',\n ],\n allowedActions: [\n 'AccountsController:getAccount',\n 'AccountsController:getAccountByAddress',\n 'AccountsController:listMultichainAccounts',\n 'SnapController:handleRequest',\n 'KeyringController:withKeyring',\n 'KeyringController:getState',\n ],\n });\n}\n"]}
1
+ {"version":3,"file":"messenger.cjs","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":";;;AAAA,+DAAsD;AAUtD;;;;GAIG;AACH,SAAgB,gBAAgB;IAC9B,OAAO,IAAI,2BAAS,EAGjB,CAAC;AACN,CAAC;AALD,4CAKC;AAED;;;;;GAKG;AACH,SAAgB,oCAAoC,CAClD,SAA8C;IAE9C,OAAO,SAAS,CAAC,aAAa,CAAC;QAC7B,IAAI,EAAE,0BAA0B;QAChC,aAAa,EAAE,CAAC,+BAA+B,CAAC;QAChD,cAAc,EAAE;YACd,+BAA+B;YAC/B,wCAAwC;YACxC,2CAA2C;YAC3C,8BAA8B;YAC9B,+BAA+B;YAC/B,4BAA4B;SAC7B;KACF,CAAC,CAAC;AACL,CAAC;AAfD,oFAeC","sourcesContent":["import { Messenger } from '@metamask/base-controller';\n\nimport type {\n AllowedActions,\n AllowedEvents,\n MultichainAccountServiceActions,\n MultichainAccountServiceEvents,\n MultichainAccountServiceMessenger,\n} from '../types';\n\n/**\n * Creates a new root messenger instance for testing.\n *\n * @returns A new Messenger instance.\n */\nexport function getRootMessenger() {\n return new Messenger<\n MultichainAccountServiceActions | AllowedActions,\n MultichainAccountServiceEvents | AllowedEvents\n >();\n}\n\n/**\n * Retrieves a restricted messenger for the MultichainAccountService.\n *\n * @param messenger - The root messenger instance. Defaults to a new Messenger created by getRootMessenger().\n * @returns The restricted messenger for the MultichainAccountService.\n */\nexport function getMultichainAccountServiceMessenger(\n messenger: ReturnType<typeof getRootMessenger>,\n): MultichainAccountServiceMessenger {\n return messenger.getRestricted({\n name: 'MultichainAccountService',\n allowedEvents: ['KeyringController:stateChange'],\n allowedActions: [\n 'AccountsController:getAccount',\n 'AccountsController:getAccountByAddress',\n 'AccountsController:listMultichainAccounts',\n 'SnapController:handleRequest',\n 'KeyringController:withKeyring',\n 'KeyringController:getState',\n ],\n });\n}\n"]}
@@ -1,11 +1,11 @@
1
1
  import { Messenger } from "@metamask/base-controller";
2
- import type { AllowedActions, AllowedEvents, MultichainAccountServiceMessenger } from "../types.cjs";
2
+ import type { AllowedActions, MultichainAccountServiceMessenger } from "../types.cjs";
3
3
  /**
4
4
  * Creates a new root messenger instance for testing.
5
5
  *
6
6
  * @returns A new Messenger instance.
7
7
  */
8
- export declare function getRootMessenger(): Messenger<AllowedActions, AllowedEvents>;
8
+ export declare function getRootMessenger(): Messenger<AllowedActions, import("@metamask/keyring-controller").KeyringControllerStateChangeEvent>;
9
9
  /**
10
10
  * Retrieves a restricted messenger for the MultichainAccountService.
11
11
  *
@@ -1 +1 @@
1
- {"version":3,"file":"messenger.d.cts","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kCAAkC;AAEtD,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EAGb,iCAAiC,EAClC,qBAAiB;AAElB;;;;GAIG;AACH,wBAAgB,gBAAgB,6CAK/B;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,SAAS,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GAC7C,iCAAiC,CAiBnC"}
1
+ {"version":3,"file":"messenger.d.cts","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kCAAkC;AAEtD,OAAO,KAAK,EACV,cAAc,EAId,iCAAiC,EAClC,qBAAiB;AAElB;;;;GAIG;AACH,wBAAgB,gBAAgB,wGAK/B;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,SAAS,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GAC7C,iCAAiC,CAanC"}
@@ -1,11 +1,11 @@
1
1
  import { Messenger } from "@metamask/base-controller";
2
- import type { AllowedActions, AllowedEvents, MultichainAccountServiceMessenger } from "../types.mjs";
2
+ import type { AllowedActions, MultichainAccountServiceMessenger } from "../types.mjs";
3
3
  /**
4
4
  * Creates a new root messenger instance for testing.
5
5
  *
6
6
  * @returns A new Messenger instance.
7
7
  */
8
- export declare function getRootMessenger(): Messenger<AllowedActions, AllowedEvents>;
8
+ export declare function getRootMessenger(): Messenger<AllowedActions, import("@metamask/keyring-controller").KeyringControllerStateChangeEvent>;
9
9
  /**
10
10
  * Retrieves a restricted messenger for the MultichainAccountService.
11
11
  *
@@ -1 +1 @@
1
- {"version":3,"file":"messenger.d.mts","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kCAAkC;AAEtD,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EAGb,iCAAiC,EAClC,qBAAiB;AAElB;;;;GAIG;AACH,wBAAgB,gBAAgB,6CAK/B;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,SAAS,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GAC7C,iCAAiC,CAiBnC"}
1
+ {"version":3,"file":"messenger.d.mts","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kCAAkC;AAEtD,OAAO,KAAK,EACV,cAAc,EAId,iCAAiC,EAClC,qBAAiB;AAElB;;;;GAIG;AACH,wBAAgB,gBAAgB,wGAK/B;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,SAAS,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GAC7C,iCAAiC,CAanC"}
@@ -16,11 +16,7 @@ export function getRootMessenger() {
16
16
  export function getMultichainAccountServiceMessenger(messenger) {
17
17
  return messenger.getRestricted({
18
18
  name: 'MultichainAccountService',
19
- allowedEvents: [
20
- 'KeyringController:stateChange',
21
- 'AccountsController:accountAdded',
22
- 'AccountsController:accountRemoved',
23
- ],
19
+ allowedEvents: ['KeyringController:stateChange'],
24
20
  allowedActions: [
25
21
  'AccountsController:getAccount',
26
22
  'AccountsController:getAccountByAddress',
@@ -1 +1 @@
1
- {"version":3,"file":"messenger.mjs","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kCAAkC;AAUtD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,IAAI,SAAS,EAGjB,CAAC;AACN,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oCAAoC,CAClD,SAA8C;IAE9C,OAAO,SAAS,CAAC,aAAa,CAAC;QAC7B,IAAI,EAAE,0BAA0B;QAChC,aAAa,EAAE;YACb,+BAA+B;YAC/B,iCAAiC;YACjC,mCAAmC;SACpC;QACD,cAAc,EAAE;YACd,+BAA+B;YAC/B,wCAAwC;YACxC,2CAA2C;YAC3C,8BAA8B;YAC9B,+BAA+B;YAC/B,4BAA4B;SAC7B;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { Messenger } from '@metamask/base-controller';\n\nimport type {\n AllowedActions,\n AllowedEvents,\n MultichainAccountServiceActions,\n MultichainAccountServiceEvents,\n MultichainAccountServiceMessenger,\n} from '../types';\n\n/**\n * Creates a new root messenger instance for testing.\n *\n * @returns A new Messenger instance.\n */\nexport function getRootMessenger() {\n return new Messenger<\n MultichainAccountServiceActions | AllowedActions,\n MultichainAccountServiceEvents | AllowedEvents\n >();\n}\n\n/**\n * Retrieves a restricted messenger for the MultichainAccountService.\n *\n * @param messenger - The root messenger instance. Defaults to a new Messenger created by getRootMessenger().\n * @returns The restricted messenger for the MultichainAccountService.\n */\nexport function getMultichainAccountServiceMessenger(\n messenger: ReturnType<typeof getRootMessenger>,\n): MultichainAccountServiceMessenger {\n return messenger.getRestricted({\n name: 'MultichainAccountService',\n allowedEvents: [\n 'KeyringController:stateChange',\n 'AccountsController:accountAdded',\n 'AccountsController:accountRemoved',\n ],\n allowedActions: [\n 'AccountsController:getAccount',\n 'AccountsController:getAccountByAddress',\n 'AccountsController:listMultichainAccounts',\n 'SnapController:handleRequest',\n 'KeyringController:withKeyring',\n 'KeyringController:getState',\n ],\n });\n}\n"]}
1
+ {"version":3,"file":"messenger.mjs","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kCAAkC;AAUtD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,IAAI,SAAS,EAGjB,CAAC;AACN,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oCAAoC,CAClD,SAA8C;IAE9C,OAAO,SAAS,CAAC,aAAa,CAAC;QAC7B,IAAI,EAAE,0BAA0B;QAChC,aAAa,EAAE,CAAC,+BAA+B,CAAC;QAChD,cAAc,EAAE;YACd,+BAA+B;YAC/B,wCAAwC;YACxC,2CAA2C;YAC3C,8BAA8B;YAC9B,+BAA+B;YAC/B,4BAA4B;SAC7B;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { Messenger } from '@metamask/base-controller';\n\nimport type {\n AllowedActions,\n AllowedEvents,\n MultichainAccountServiceActions,\n MultichainAccountServiceEvents,\n MultichainAccountServiceMessenger,\n} from '../types';\n\n/**\n * Creates a new root messenger instance for testing.\n *\n * @returns A new Messenger instance.\n */\nexport function getRootMessenger() {\n return new Messenger<\n MultichainAccountServiceActions | AllowedActions,\n MultichainAccountServiceEvents | AllowedEvents\n >();\n}\n\n/**\n * Retrieves a restricted messenger for the MultichainAccountService.\n *\n * @param messenger - The root messenger instance. Defaults to a new Messenger created by getRootMessenger().\n * @returns The restricted messenger for the MultichainAccountService.\n */\nexport function getMultichainAccountServiceMessenger(\n messenger: ReturnType<typeof getRootMessenger>,\n): MultichainAccountServiceMessenger {\n return messenger.getRestricted({\n name: 'MultichainAccountService',\n allowedEvents: ['KeyringController:stateChange'],\n allowedActions: [\n 'AccountsController:getAccount',\n 'AccountsController:getAccountByAddress',\n 'AccountsController:listMultichainAccounts',\n 'SnapController:handleRequest',\n 'KeyringController:withKeyring',\n 'KeyringController:getState',\n ],\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n AccountsControllerAccountAddedEvent,\n AccountsControllerAccountRemovedEvent,\n AccountsControllerGetAccountAction,\n AccountsControllerGetAccountByAddressAction,\n AccountsControllerListMultichainAccountsAction,\n} from '@metamask/accounts-controller';\nimport type { RestrictedMessenger } from '@metamask/base-controller';\nimport type {\n KeyringControllerGetStateAction,\n KeyringControllerStateChangeEvent,\n KeyringControllerWithKeyringAction,\n} from '@metamask/keyring-controller';\nimport type { HandleSnapRequest as SnapControllerHandleSnapRequestAction } from '@metamask/snaps-controllers';\n\n/**\n * All actions that {@link MultichainAccountService} registers so that other\n * modules can call them.\n */\nexport type MultichainAccountServiceActions = never;\n/**\n * All events that {@link MultichainAccountService} publishes so that other modules\n * can subscribe to them.\n */\nexport type MultichainAccountServiceEvents = never;\n\n/**\n * All actions registered by other modules that {@link MultichainAccountService}\n * calls.\n */\nexport type AllowedActions =\n | AccountsControllerListMultichainAccountsAction\n | AccountsControllerGetAccountAction\n | AccountsControllerGetAccountByAddressAction\n | SnapControllerHandleSnapRequestAction\n | KeyringControllerWithKeyringAction\n | KeyringControllerGetStateAction;\n\n/**\n * All events published by other modules that {@link MultichainAccountService}\n * subscribes to.\n */\nexport type AllowedEvents =\n | KeyringControllerStateChangeEvent\n | AccountsControllerAccountAddedEvent\n | AccountsControllerAccountRemovedEvent;\n\n/**\n * The messenger restricted to actions and events that\n * {@link MultichainAccountService} needs to access.\n */\nexport type MultichainAccountServiceMessenger = RestrictedMessenger<\n 'MultichainAccountService',\n MultichainAccountServiceActions | AllowedActions,\n MultichainAccountServiceEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n"]}
1
+ {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n AccountsControllerGetAccountAction,\n AccountsControllerGetAccountByAddressAction,\n AccountsControllerListMultichainAccountsAction,\n} from '@metamask/accounts-controller';\nimport type { RestrictedMessenger } from '@metamask/base-controller';\nimport type {\n KeyringControllerGetStateAction,\n KeyringControllerStateChangeEvent,\n KeyringControllerWithKeyringAction,\n} from '@metamask/keyring-controller';\nimport type { HandleSnapRequest as SnapControllerHandleSnapRequestAction } from '@metamask/snaps-controllers';\n\n/**\n * All actions that {@link MultichainAccountService} registers so that other\n * modules can call them.\n */\nexport type MultichainAccountServiceActions = never;\n/**\n * All events that {@link MultichainAccountService} publishes so that other modules\n * can subscribe to them.\n */\nexport type MultichainAccountServiceEvents = never;\n\n/**\n * All actions registered by other modules that {@link MultichainAccountService}\n * calls.\n */\nexport type AllowedActions =\n | AccountsControllerListMultichainAccountsAction\n | AccountsControllerGetAccountAction\n | AccountsControllerGetAccountByAddressAction\n | SnapControllerHandleSnapRequestAction\n | KeyringControllerWithKeyringAction\n | KeyringControllerGetStateAction;\n\n/**\n * All events published by other modules that {@link MultichainAccountService}\n * subscribes to.\n */\nexport type AllowedEvents = KeyringControllerStateChangeEvent;\n\n/**\n * The messenger restricted to actions and events that\n * {@link MultichainAccountService} needs to access.\n */\nexport type MultichainAccountServiceMessenger = RestrictedMessenger<\n 'MultichainAccountService',\n MultichainAccountServiceActions | AllowedActions,\n MultichainAccountServiceEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n"]}