@metamask-previews/multichain-account-service 5.0.0-preview-cb897e9 → 5.0.0-preview-6a568504

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 (96) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/MultichainAccountGroup.cjs +84 -45
  3. package/dist/MultichainAccountGroup.cjs.map +1 -1
  4. package/dist/MultichainAccountGroup.d.cts +17 -4
  5. package/dist/MultichainAccountGroup.d.cts.map +1 -1
  6. package/dist/MultichainAccountGroup.d.mts +17 -4
  7. package/dist/MultichainAccountGroup.d.mts.map +1 -1
  8. package/dist/MultichainAccountGroup.mjs +84 -45
  9. package/dist/MultichainAccountGroup.mjs.map +1 -1
  10. package/dist/MultichainAccountService.cjs +144 -113
  11. package/dist/MultichainAccountService.cjs.map +1 -1
  12. package/dist/MultichainAccountService.d.cts +48 -20
  13. package/dist/MultichainAccountService.d.cts.map +1 -1
  14. package/dist/MultichainAccountService.d.mts +48 -20
  15. package/dist/MultichainAccountService.d.mts.map +1 -1
  16. package/dist/MultichainAccountService.mjs +145 -114
  17. package/dist/MultichainAccountService.mjs.map +1 -1
  18. package/dist/MultichainAccountWallet.cjs +108 -123
  19. package/dist/MultichainAccountWallet.cjs.map +1 -1
  20. package/dist/MultichainAccountWallet.d.cts +5 -4
  21. package/dist/MultichainAccountWallet.d.cts.map +1 -1
  22. package/dist/MultichainAccountWallet.d.mts +5 -4
  23. package/dist/MultichainAccountWallet.d.mts.map +1 -1
  24. package/dist/MultichainAccountWallet.mjs +108 -123
  25. package/dist/MultichainAccountWallet.mjs.map +1 -1
  26. package/dist/providers/AccountProviderWrapper.cjs +18 -0
  27. package/dist/providers/AccountProviderWrapper.cjs.map +1 -1
  28. package/dist/providers/AccountProviderWrapper.d.cts +12 -0
  29. package/dist/providers/AccountProviderWrapper.d.cts.map +1 -1
  30. package/dist/providers/AccountProviderWrapper.d.mts +12 -0
  31. package/dist/providers/AccountProviderWrapper.d.mts.map +1 -1
  32. package/dist/providers/AccountProviderWrapper.mjs +18 -0
  33. package/dist/providers/AccountProviderWrapper.mjs.map +1 -1
  34. package/dist/providers/BaseBip44AccountProvider.cjs +45 -20
  35. package/dist/providers/BaseBip44AccountProvider.cjs.map +1 -1
  36. package/dist/providers/BaseBip44AccountProvider.d.cts +58 -6
  37. package/dist/providers/BaseBip44AccountProvider.d.cts.map +1 -1
  38. package/dist/providers/BaseBip44AccountProvider.d.mts +58 -6
  39. package/dist/providers/BaseBip44AccountProvider.d.mts.map +1 -1
  40. package/dist/providers/BaseBip44AccountProvider.mjs +45 -20
  41. package/dist/providers/BaseBip44AccountProvider.mjs.map +1 -1
  42. package/dist/providers/BtcAccountProvider.cjs +1 -0
  43. package/dist/providers/BtcAccountProvider.cjs.map +1 -1
  44. package/dist/providers/BtcAccountProvider.d.cts.map +1 -1
  45. package/dist/providers/BtcAccountProvider.d.mts.map +1 -1
  46. package/dist/providers/BtcAccountProvider.mjs +1 -0
  47. package/dist/providers/BtcAccountProvider.mjs.map +1 -1
  48. package/dist/providers/EvmAccountProvider.cjs +39 -5
  49. package/dist/providers/EvmAccountProvider.cjs.map +1 -1
  50. package/dist/providers/EvmAccountProvider.d.cts +8 -0
  51. package/dist/providers/EvmAccountProvider.d.cts.map +1 -1
  52. package/dist/providers/EvmAccountProvider.d.mts +8 -0
  53. package/dist/providers/EvmAccountProvider.d.mts.map +1 -1
  54. package/dist/providers/EvmAccountProvider.mjs +39 -5
  55. package/dist/providers/EvmAccountProvider.mjs.map +1 -1
  56. package/dist/providers/SolAccountProvider.cjs +4 -0
  57. package/dist/providers/SolAccountProvider.cjs.map +1 -1
  58. package/dist/providers/SolAccountProvider.d.cts.map +1 -1
  59. package/dist/providers/SolAccountProvider.d.mts.map +1 -1
  60. package/dist/providers/SolAccountProvider.mjs +4 -0
  61. package/dist/providers/SolAccountProvider.mjs.map +1 -1
  62. package/dist/providers/TrxAccountProvider.cjs +1 -0
  63. package/dist/providers/TrxAccountProvider.cjs.map +1 -1
  64. package/dist/providers/TrxAccountProvider.d.cts.map +1 -1
  65. package/dist/providers/TrxAccountProvider.d.mts.map +1 -1
  66. package/dist/providers/TrxAccountProvider.mjs +1 -0
  67. package/dist/providers/TrxAccountProvider.mjs.map +1 -1
  68. package/dist/tests/messenger.cjs +4 -0
  69. package/dist/tests/messenger.cjs.map +1 -1
  70. package/dist/tests/messenger.d.cts.map +1 -1
  71. package/dist/tests/messenger.d.mts.map +1 -1
  72. package/dist/tests/messenger.mjs +4 -0
  73. package/dist/tests/messenger.mjs.map +1 -1
  74. package/dist/tests/providers.cjs +62 -7
  75. package/dist/tests/providers.cjs.map +1 -1
  76. package/dist/tests/providers.d.cts +17 -3
  77. package/dist/tests/providers.d.cts.map +1 -1
  78. package/dist/tests/providers.d.mts +17 -3
  79. package/dist/tests/providers.d.mts.map +1 -1
  80. package/dist/tests/providers.mjs +60 -6
  81. package/dist/tests/providers.mjs.map +1 -1
  82. package/dist/types.cjs.map +1 -1
  83. package/dist/types.d.cts +8 -4
  84. package/dist/types.d.cts.map +1 -1
  85. package/dist/types.d.mts +8 -4
  86. package/dist/types.d.mts.map +1 -1
  87. package/dist/types.mjs.map +1 -1
  88. package/dist/utils.cjs +1 -11
  89. package/dist/utils.cjs.map +1 -1
  90. package/dist/utils.d.cts +0 -1
  91. package/dist/utils.d.cts.map +1 -1
  92. package/dist/utils.d.mts +0 -1
  93. package/dist/utils.d.mts.map +1 -1
  94. package/dist/utils.mjs +0 -9
  95. package/dist/utils.mjs.map +1 -1
  96. package/package.json +1 -1
@@ -38,6 +38,10 @@ export function getMultichainAccountServiceMessenger(rootMessenger, extra) {
38
38
  'KeyringController:addNewKeyring',
39
39
  'NetworkController:findNetworkClientIdByChainId',
40
40
  'NetworkController:getNetworkClientById',
41
+ 'KeyringController:createNewVaultAndKeychain',
42
+ 'KeyringController:createNewVaultAndRestore',
43
+ 'AccountsController:getAccounts',
44
+ 'KeyringController:removeAccount',
41
45
  ...(extra?.actions ?? []),
42
46
  ],
43
47
  events: [
@@ -1 +1 @@
1
- {"version":3,"file":"messenger.mjs","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,4BAA4B;AAqBpE;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,IAAI,SAAS,CAAC;QACnB,SAAS,EAAE,kBAAkB;QAC7B,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE;KAC5B,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,oCAAoC,CAClD,aAA4B,EAC5B,KAGC;IAED,MAAM,SAAS,GAAG,IAAI,SAAS,CAK7B;QACA,SAAS,EAAE,0BAA0B;QACrC,MAAM,EAAE,aAAa;KACtB,CAAC,CAAC;IACH,aAAa,CAAC,QAAQ,CAAC;QACrB,SAAS;QACT,OAAO,EAAE;YACP,+BAA+B;YAC/B,wCAAwC;YACxC,2CAA2C;YAC3C,yBAAyB;YACzB,8BAA8B;YAC9B,+BAA+B;YAC/B,4BAA4B;YAC5B,qCAAqC;YACrC,iCAAiC;YACjC,gDAAgD;YAChD,wCAAwC;YACxC,GAAG,CAAC,KAAK,EAAE,OAAO,IAAI,EAAE,CAAC;SAC1B;QACD,MAAM,EAAE;YACN,+BAA+B;YAC/B,4BAA4B;YAC5B,iCAAiC;YACjC,mCAAmC;YACnC,GAAG,CAAC,KAAK,EAAE,MAAM,IAAI,EAAE,CAAC;SACzB;KACF,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { Messenger, MOCK_ANY_NAMESPACE } from '@metamask/messenger';\nimport type {\n MessengerActions,\n MessengerEvents,\n MockAnyNamespace,\n} from '@metamask/messenger';\n\nimport type { MultichainAccountServiceMessenger } from '../types';\n\nexport type AllMultichainAccountServiceActions =\n MessengerActions<MultichainAccountServiceMessenger>;\n\nexport type AllMultichainAccountServiceEvents =\n MessengerEvents<MultichainAccountServiceMessenger>;\n\nexport type RootMessenger = Messenger<\n MockAnyNamespace,\n AllMultichainAccountServiceActions,\n AllMultichainAccountServiceEvents\n>;\n\n/**\n * Creates and returns a root messenger for testing\n *\n * @returns A messenger instance\n */\nexport function getRootMessenger(): RootMessenger {\n return new Messenger({\n namespace: MOCK_ANY_NAMESPACE,\n captureException: jest.fn(),\n });\n}\n\n/**\n * Retrieves a restricted messenger for the MultichainAccountService.\n *\n * @param rootMessenger - The root messenger instance. Defaults to a new Messenger created by getRootMessenger().\n * @param extra - Extra messenger options.\n * @param extra.actions - Extra actions to delegate.\n * @param extra.events - Extra events to delegate.\n * @returns The restricted messenger for the MultichainAccountService.\n */\nexport function getMultichainAccountServiceMessenger(\n rootMessenger: RootMessenger,\n extra?: {\n actions?: AllMultichainAccountServiceActions['type'][];\n events?: AllMultichainAccountServiceEvents['type'][];\n },\n): MultichainAccountServiceMessenger {\n const messenger = new Messenger<\n 'MultichainAccountService',\n AllMultichainAccountServiceActions,\n AllMultichainAccountServiceEvents,\n RootMessenger\n >({\n namespace: 'MultichainAccountService',\n parent: rootMessenger,\n });\n rootMessenger.delegate({\n messenger,\n actions: [\n 'AccountsController:getAccount',\n 'AccountsController:getAccountByAddress',\n 'AccountsController:listMultichainAccounts',\n 'SnapController:getState',\n 'SnapController:handleRequest',\n 'KeyringController:withKeyring',\n 'KeyringController:getState',\n 'KeyringController:getKeyringsByType',\n 'KeyringController:addNewKeyring',\n 'NetworkController:findNetworkClientIdByChainId',\n 'NetworkController:getNetworkClientById',\n ...(extra?.actions ?? []),\n ],\n events: [\n 'KeyringController:stateChange',\n 'SnapController:stateChange',\n 'AccountsController:accountAdded',\n 'AccountsController:accountRemoved',\n ...(extra?.events ?? []),\n ],\n });\n return messenger;\n}\n"]}
1
+ {"version":3,"file":"messenger.mjs","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,4BAA4B;AAqBpE;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,IAAI,SAAS,CAAC;QACnB,SAAS,EAAE,kBAAkB;QAC7B,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE;KAC5B,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,oCAAoC,CAClD,aAA4B,EAC5B,KAGC;IAED,MAAM,SAAS,GAAG,IAAI,SAAS,CAK7B;QACA,SAAS,EAAE,0BAA0B;QACrC,MAAM,EAAE,aAAa;KACtB,CAAC,CAAC;IACH,aAAa,CAAC,QAAQ,CAAC;QACrB,SAAS;QACT,OAAO,EAAE;YACP,+BAA+B;YAC/B,wCAAwC;YACxC,2CAA2C;YAC3C,yBAAyB;YACzB,8BAA8B;YAC9B,+BAA+B;YAC/B,4BAA4B;YAC5B,qCAAqC;YACrC,iCAAiC;YACjC,gDAAgD;YAChD,wCAAwC;YACxC,6CAA6C;YAC7C,4CAA4C;YAC5C,gCAAgC;YAChC,iCAAiC;YACjC,GAAG,CAAC,KAAK,EAAE,OAAO,IAAI,EAAE,CAAC;SAC1B;QACD,MAAM,EAAE;YACN,+BAA+B;YAC/B,4BAA4B;YAC5B,iCAAiC;YACjC,mCAAmC;YACnC,GAAG,CAAC,KAAK,EAAE,MAAM,IAAI,EAAE,CAAC;SACzB;KACF,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { Messenger, MOCK_ANY_NAMESPACE } from '@metamask/messenger';\nimport type {\n MessengerActions,\n MessengerEvents,\n MockAnyNamespace,\n} from '@metamask/messenger';\n\nimport type { MultichainAccountServiceMessenger } from '../types';\n\nexport type AllMultichainAccountServiceActions =\n MessengerActions<MultichainAccountServiceMessenger>;\n\nexport type AllMultichainAccountServiceEvents =\n MessengerEvents<MultichainAccountServiceMessenger>;\n\nexport type RootMessenger = Messenger<\n MockAnyNamespace,\n AllMultichainAccountServiceActions,\n AllMultichainAccountServiceEvents\n>;\n\n/**\n * Creates and returns a root messenger for testing\n *\n * @returns A messenger instance\n */\nexport function getRootMessenger(): RootMessenger {\n return new Messenger({\n namespace: MOCK_ANY_NAMESPACE,\n captureException: jest.fn(),\n });\n}\n\n/**\n * Retrieves a restricted messenger for the MultichainAccountService.\n *\n * @param rootMessenger - The root messenger instance. Defaults to a new Messenger created by getRootMessenger().\n * @param extra - Extra messenger options.\n * @param extra.actions - Extra actions to delegate.\n * @param extra.events - Extra events to delegate.\n * @returns The restricted messenger for the MultichainAccountService.\n */\nexport function getMultichainAccountServiceMessenger(\n rootMessenger: RootMessenger,\n extra?: {\n actions?: AllMultichainAccountServiceActions['type'][];\n events?: AllMultichainAccountServiceEvents['type'][];\n },\n): MultichainAccountServiceMessenger {\n const messenger = new Messenger<\n 'MultichainAccountService',\n AllMultichainAccountServiceActions,\n AllMultichainAccountServiceEvents,\n RootMessenger\n >({\n namespace: 'MultichainAccountService',\n parent: rootMessenger,\n });\n rootMessenger.delegate({\n messenger,\n actions: [\n 'AccountsController:getAccount',\n 'AccountsController:getAccountByAddress',\n 'AccountsController:listMultichainAccounts',\n 'SnapController:getState',\n 'SnapController:handleRequest',\n 'KeyringController:withKeyring',\n 'KeyringController:getState',\n 'KeyringController:getKeyringsByType',\n 'KeyringController:addNewKeyring',\n 'NetworkController:findNetworkClientIdByChainId',\n 'NetworkController:getNetworkClientById',\n 'KeyringController:createNewVaultAndKeychain',\n 'KeyringController:createNewVaultAndRestore',\n 'AccountsController:getAccounts',\n 'KeyringController:removeAccount',\n ...(extra?.actions ?? []),\n ],\n events: [\n 'KeyringController:stateChange',\n 'SnapController:stateChange',\n 'AccountsController:accountAdded',\n 'AccountsController:accountRemoved',\n ...(extra?.events ?? []),\n ],\n });\n return messenger;\n}\n"]}
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setupNamedAccountProvider = exports.makeMockAccountProvider = void 0;
4
- const account_api_1 = require("@metamask/account-api");
3
+ exports.mockCreateAccountsOnce = exports.setupBip44AccountProvider = exports.makeMockAccountProvider = void 0;
5
4
  const providers_1 = require("../providers/index.cjs");
6
5
  function makeMockAccountProvider(accounts = []) {
7
6
  return {
8
- accounts,
7
+ mockAccounts: accounts,
8
+ accounts: new Set(),
9
9
  constructor: jest.fn(),
10
+ alignAccounts: jest.fn(),
11
+ init: jest.fn(),
10
12
  resyncAccounts: jest.fn(),
11
13
  getAccount: jest.fn(),
12
14
  getAccounts: jest.fn(),
@@ -14,26 +16,79 @@ function makeMockAccountProvider(accounts = []) {
14
16
  discoverAccounts: jest.fn(),
15
17
  isAccountCompatible: jest.fn(),
16
18
  getName: jest.fn(),
19
+ isDisabled: jest.fn(),
20
+ setEnabled: jest.fn(),
21
+ isEnabled: true,
17
22
  };
18
23
  }
19
24
  exports.makeMockAccountProvider = makeMockAccountProvider;
20
- function setupNamedAccountProvider({ name = 'Mocked Provider', accounts, mocks = makeMockAccountProvider(), filter = () => true, index, }) {
25
+ function setupBip44AccountProvider({ name = 'Mocked Provider', accounts, mocks = makeMockAccountProvider(), index, }) {
21
26
  // You can mock this and all other mocks will re-use that list
22
27
  // of accounts.
23
- mocks.accounts = accounts;
24
- const getAccounts = () => mocks.accounts.filter((account) => (0, account_api_1.isBip44Account)(account) && filter(account));
28
+ mocks.mockAccounts = accounts;
29
+ mocks.accounts = new Set(accounts.map((account) => account.id));
30
+ // Toggle enabled state only
31
+ mocks.setEnabled.mockImplementation((enabled) => {
32
+ mocks.isEnabled = enabled;
33
+ });
34
+ mocks.isDisabled.mockImplementation(() => !mocks.isEnabled);
35
+ const getAccounts = () => mocks.mockAccounts.filter((account) => [...mocks.accounts].includes(account.id));
25
36
  mocks.getName.mockImplementation(() => name);
26
37
  mocks.getAccounts.mockImplementation(getAccounts);
27
38
  mocks.getAccount.mockImplementation((id) =>
28
39
  // Assuming this never fails.
29
40
  getAccounts().find((account) => account.id === id));
30
41
  mocks.createAccounts.mockResolvedValue([]);
42
+ mocks.alignAccounts.mockImplementation(async ({ entropySource, groupIndex, }) => {
43
+ if (mocks.isDisabled()) {
44
+ const wrapperAlign = providers_1.AccountProviderWrapper.prototype.alignAccounts;
45
+ const ids = await wrapperAlign.call({ isEnabled: false, isDisabled: () => true }, { entropySource, groupIndex });
46
+ return ids;
47
+ }
48
+ const createdAccounts = await mocks.createAccounts({
49
+ entropySource,
50
+ groupIndex,
51
+ });
52
+ const baseAlign = providers_1.BaseBip44AccountProvider.prototype.alignAccounts;
53
+ const ids = await baseAlign.call({ createAccounts: async () => createdAccounts }, { entropySource, groupIndex });
54
+ return ids;
55
+ });
56
+ mocks.init.mockImplementation((accountIds) => {
57
+ accountIds.forEach((id) => mocks.accounts.add(id));
58
+ });
31
59
  if (index === 0) {
32
60
  // Make the first provider to always be an `EvmAccountProvider`, since we
33
61
  // check for this pre-condition in some methods.
34
62
  Object.setPrototypeOf(mocks, providers_1.EvmAccountProvider.prototype);
35
63
  }
64
+ if (index !== 0) {
65
+ Object.setPrototypeOf(mocks, providers_1.AccountProviderWrapper.prototype);
66
+ }
36
67
  return mocks;
37
68
  }
38
- exports.setupNamedAccountProvider = setupNamedAccountProvider;
69
+ exports.setupBip44AccountProvider = setupBip44AccountProvider;
70
+ /**
71
+ * Helper to mock a single createAccounts call while updating the provider's
72
+ * internal state so subsequent getAccount/getAccounts can resolve the accounts.
73
+ *
74
+ * @param provider - The mock provider whose createAccounts call to mock.
75
+ * @param created - The accounts to be returned and persisted in the mock state.
76
+ */
77
+ function mockCreateAccountsOnce(provider, created) {
78
+ provider.createAccounts.mockImplementationOnce(async () => {
79
+ // Add newly created accounts to the provider's internal store
80
+ for (const acc of created) {
81
+ if (!provider.mockAccounts.some((a) => a.id === acc.id)) {
82
+ provider.mockAccounts.push(acc);
83
+ }
84
+ }
85
+ // Merge IDs into the visible list used by getAccounts/getAccount
86
+ const ids = created.map((a) => a.id);
87
+ for (const id of ids) {
88
+ provider.accounts.add(id);
89
+ }
90
+ return created;
91
+ });
92
+ }
93
+ exports.mockCreateAccountsOnce = mockCreateAccountsOnce;
39
94
  //# sourceMappingURL=providers.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"providers.cjs","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":";;;AACA,uDAAuD;AAGvD,sDAAkD;AAclD,SAAgB,uBAAuB,CACrC,WAA6B,EAAE;IAE/B,OAAO;QACL,QAAQ;QACR,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;QACtB,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;QACzB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;QACrB,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;QACtB,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;QACzB,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC3B,mBAAmB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC9B,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;KACnB,CAAC;AACJ,CAAC;AAdD,0DAcC;AAED,SAAgB,yBAAyB,CAAC,EACxC,IAAI,GAAG,iBAAiB,EACxB,QAAQ,EACR,KAAK,GAAG,uBAAuB,EAAE,EACjC,MAAM,GAAG,GAAG,EAAE,CAAC,IAAI,EACnB,KAAK,GAON;IACC,8DAA8D;IAC9D,eAAe;IACf,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAE1B,MAAM,WAAW,GAAG,GAAG,EAAE,CACvB,KAAK,CAAC,QAAQ,CAAC,MAAM,CACnB,CAAC,OAAO,EAAE,EAAE,CAAC,IAAA,4BAAc,EAAC,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CACxD,CAAC;IAEJ,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAE7C,KAAK,CAAC,WAAW,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAClD,KAAK,CAAC,UAAU,CAAC,kBAAkB,CACjC,CAAC,EAAsC,EAAE,EAAE;IACzC,6BAA6B;IAC7B,WAAW,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,CACrD,CAAC;IACF,KAAK,CAAC,cAAc,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;IAE3C,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;QAChB,yEAAyE;QACzE,gDAAgD;QAChD,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,8BAAkB,CAAC,SAAS,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAvCD,8DAuCC","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport { isBip44Account } from '@metamask/account-api';\nimport type { KeyringAccount } from '@metamask/keyring-api';\n\nimport { EvmAccountProvider } from '../providers';\n\nexport type MockAccountProvider = {\n accounts: KeyringAccount[];\n constructor: jest.Mock;\n resyncAccounts: jest.Mock;\n getAccount: jest.Mock;\n getAccounts: jest.Mock;\n createAccounts: jest.Mock;\n discoverAccounts: jest.Mock;\n isAccountCompatible?: jest.Mock;\n getName: jest.Mock;\n};\n\nexport function makeMockAccountProvider(\n accounts: KeyringAccount[] = [],\n): MockAccountProvider {\n return {\n accounts,\n constructor: jest.fn(),\n resyncAccounts: jest.fn(),\n getAccount: jest.fn(),\n getAccounts: jest.fn(),\n createAccounts: jest.fn(),\n discoverAccounts: jest.fn(),\n isAccountCompatible: jest.fn(),\n getName: jest.fn(),\n };\n}\n\nexport function setupNamedAccountProvider({\n name = 'Mocked Provider',\n accounts,\n mocks = makeMockAccountProvider(),\n filter = () => true,\n index,\n}: {\n name?: string;\n mocks?: MockAccountProvider;\n accounts: KeyringAccount[];\n filter?: (account: KeyringAccount) => boolean;\n index?: number;\n}): MockAccountProvider {\n // You can mock this and all other mocks will re-use that list\n // of accounts.\n mocks.accounts = accounts;\n\n const getAccounts = () =>\n mocks.accounts.filter(\n (account) => isBip44Account(account) && filter(account),\n );\n\n mocks.getName.mockImplementation(() => name);\n\n mocks.getAccounts.mockImplementation(getAccounts);\n mocks.getAccount.mockImplementation(\n (id: Bip44Account<KeyringAccount>['id']) =>\n // Assuming this never fails.\n getAccounts().find((account) => account.id === id),\n );\n mocks.createAccounts.mockResolvedValue([]);\n\n if (index === 0) {\n // Make the first provider to always be an `EvmAccountProvider`, since we\n // check for this pre-condition in some methods.\n Object.setPrototypeOf(mocks, EvmAccountProvider.prototype);\n }\n\n return mocks;\n}\n"]}
1
+ {"version":3,"file":"providers.cjs","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":";;;AAGA,sDAIsB;AAoBtB,SAAgB,uBAAuB,CACrC,WAA6B,EAAE;IAE/B,OAAO;QACL,YAAY,EAAE,QAAQ;QACtB,QAAQ,EAAE,IAAI,GAAG,EAAE;QACnB,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;QACtB,aAAa,EAAE,IAAI,CAAC,EAAE,EAAE;QACxB,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;QACf,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;QACzB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;QACrB,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;QACtB,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;QACzB,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC3B,mBAAmB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC9B,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;QAClB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;QACrB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;QACrB,SAAS,EAAE,IAAI;KAChB,CAAC;AACJ,CAAC;AApBD,0DAoBC;AAED,SAAgB,yBAAyB,CAAC,EACxC,IAAI,GAAG,iBAAiB,EACxB,QAAQ,EACR,KAAK,GAAG,uBAAuB,EAAE,EACjC,K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B,OAAyB;IAEzB,QAAQ,CAAC,cAAc,CAAC,sBAAsB,CAAC,KAAK,IAAI,EAAE;QACxD,8DAA8D;QAC9D,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC1B,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;gBACxD,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;QACD,iEAAiE;QACjE,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACrC,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;YACrB,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5B,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC;AAnBD,wDAmBC","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\n\nimport {\n AccountProviderWrapper,\n EvmAccountProvider,\n BaseBip44AccountProvider,\n} from '../providers';\n\nexport type MockAccountProvider = {\n mockAccounts: KeyringAccount[];\n accounts: Set<KeyringAccount['id']>;\n constructor: jest.Mock;\n alignAccounts: jest.Mock;\n init: jest.Mock;\n resyncAccounts: jest.Mock;\n getAccount: jest.Mock;\n getAccounts: jest.Mock;\n createAccounts: jest.Mock;\n discoverAccounts: jest.Mock;\n isAccountCompatible: jest.Mock;\n getName: jest.Mock;\n isEnabled: boolean;\n isDisabled: jest.Mock;\n setEnabled: jest.Mock;\n};\n\nexport function makeMockAccountProvider(\n accounts: KeyringAccount[] = [],\n): MockAccountProvider {\n return {\n mockAccounts: accounts,\n accounts: new Set(),\n constructor: jest.fn(),\n alignAccounts: jest.fn(),\n init: jest.fn(),\n resyncAccounts: jest.fn(),\n getAccount: jest.fn(),\n getAccounts: jest.fn(),\n createAccounts: jest.fn(),\n discoverAccounts: jest.fn(),\n isAccountCompatible: jest.fn(),\n getName: jest.fn(),\n isDisabled: jest.fn(),\n setEnabled: jest.fn(),\n isEnabled: true,\n };\n}\n\nexport function setupBip44AccountProvider({\n name = 'Mocked Provider',\n accounts,\n mocks = makeMockAccountProvider(),\n index,\n}: {\n name?: string;\n mocks?: MockAccountProvider;\n accounts: KeyringAccount[];\n filter?: (account: KeyringAccount) => boolean;\n index?: number;\n}): MockAccountProvider {\n // You can mock this and all other mocks will re-use that list\n // of accounts.\n mocks.mockAccounts = accounts;\n mocks.accounts = new Set(accounts.map((account) => account.id));\n // Toggle enabled state only\n mocks.setEnabled.mockImplementation((enabled: boolean) => {\n mocks.isEnabled = enabled;\n });\n mocks.isDisabled.mockImplementation(() => !mocks.isEnabled);\n\n const getAccounts = () =>\n mocks.mockAccounts.filter((account) =>\n [...mocks.accounts].includes(account.id),\n );\n\n mocks.getName.mockImplementation(() => name);\n\n mocks.getAccounts.mockImplementation(getAccounts);\n mocks.getAccount.mockImplementation(\n (id: Bip44Account<KeyringAccount>['id']) =>\n // Assuming this never fails.\n getAccounts().find((account) => account.id === id),\n );\n mocks.createAccounts.mockResolvedValue([]);\n mocks.alignAccounts.mockImplementation(\n async ({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }) => {\n if (mocks.isDisabled()) {\n const wrapperAlign = (\n AccountProviderWrapper.prototype as unknown as {\n alignAccounts: (\n this: { isEnabled: boolean },\n opts: { entropySource: EntropySourceId; groupIndex: number },\n ) => Promise<string[]>;\n }\n ).alignAccounts;\n const ids = await wrapperAlign.call(\n { isEnabled: false, isDisabled: () => true },\n { entropySource, groupIndex },\n );\n return ids;\n }\n const createdAccounts = await mocks.createAccounts({\n entropySource,\n groupIndex,\n });\n\n const baseAlign = (\n BaseBip44AccountProvider.prototype as unknown as {\n alignAccounts: (\n this: {\n createAccounts: (o: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }) => Promise<unknown[]>;\n },\n opts: { entropySource: EntropySourceId; groupIndex: number },\n ) => Promise<string[]>;\n }\n ).alignAccounts;\n const ids = await baseAlign.call(\n { createAccounts: async () => createdAccounts },\n { entropySource, groupIndex },\n );\n\n return ids;\n },\n );\n mocks.init.mockImplementation(\n (accountIds: Bip44Account<KeyringAccount>['id'][]) => {\n accountIds.forEach((id) => mocks.accounts.add(id));\n },\n );\n\n if (index === 0) {\n // Make the first provider to always be an `EvmAccountProvider`, since we\n // check for this pre-condition in some methods.\n Object.setPrototypeOf(mocks, EvmAccountProvider.prototype);\n }\n\n if (index !== 0) {\n Object.setPrototypeOf(mocks, AccountProviderWrapper.prototype);\n }\n\n return mocks;\n}\n\n/**\n * Helper to mock a single createAccounts call while updating the provider's\n * internal state so subsequent getAccount/getAccounts can resolve the accounts.\n *\n * @param provider - The mock provider whose createAccounts call to mock.\n * @param created - The accounts to be returned and persisted in the mock state.\n */\nexport function mockCreateAccountsOnce(\n provider: MockAccountProvider,\n created: KeyringAccount[],\n): void {\n provider.createAccounts.mockImplementationOnce(async () => {\n // Add newly created accounts to the provider's internal store\n for (const acc of created) {\n if (!provider.mockAccounts.some((a) => a.id === acc.id)) {\n provider.mockAccounts.push(acc);\n }\n }\n // Merge IDs into the visible list used by getAccounts/getAccount\n const ids = created.map((a) => a.id);\n for (const id of ids) {\n provider.accounts.add(id);\n }\n\n return created;\n });\n}\n"]}
@@ -1,22 +1,36 @@
1
1
  /// <reference types="jest" />
2
2
  import type { KeyringAccount } from "@metamask/keyring-api";
3
3
  export type MockAccountProvider = {
4
- accounts: KeyringAccount[];
4
+ mockAccounts: KeyringAccount[];
5
+ accounts: Set<KeyringAccount['id']>;
5
6
  constructor: jest.Mock;
7
+ alignAccounts: jest.Mock;
8
+ init: jest.Mock;
6
9
  resyncAccounts: jest.Mock;
7
10
  getAccount: jest.Mock;
8
11
  getAccounts: jest.Mock;
9
12
  createAccounts: jest.Mock;
10
13
  discoverAccounts: jest.Mock;
11
- isAccountCompatible?: jest.Mock;
14
+ isAccountCompatible: jest.Mock;
12
15
  getName: jest.Mock;
16
+ isEnabled: boolean;
17
+ isDisabled: jest.Mock;
18
+ setEnabled: jest.Mock;
13
19
  };
14
20
  export declare function makeMockAccountProvider(accounts?: KeyringAccount[]): MockAccountProvider;
15
- export declare function setupNamedAccountProvider({ name, accounts, mocks, filter, index, }: {
21
+ export declare function setupBip44AccountProvider({ name, accounts, mocks, index, }: {
16
22
  name?: string;
17
23
  mocks?: MockAccountProvider;
18
24
  accounts: KeyringAccount[];
19
25
  filter?: (account: KeyringAccount) => boolean;
20
26
  index?: number;
21
27
  }): MockAccountProvider;
28
+ /**
29
+ * Helper to mock a single createAccounts call while updating the provider's
30
+ * internal state so subsequent getAccount/getAccounts can resolve the accounts.
31
+ *
32
+ * @param provider - The mock provider whose createAccounts call to mock.
33
+ * @param created - The accounts to be returned and persisted in the mock state.
34
+ */
35
+ export declare function mockCreateAccountsOnce(provider: MockAccountProvider, created: KeyringAccount[]): void;
22
36
  //# sourceMappingURL=providers.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"providers.d.cts","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAI5D,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC;IACvB,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC;IAC1B,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC;IACtB,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC;IACvB,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC;IAC1B,gBAAgB,EAAE,IAAI,CAAC,IAAI,CAAC;IAC5B,mBAAmB,CAA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nB,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC;IACtB,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC;CACvB,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,QAAQ,GAAE,cAAc,EAAO,GAC9B,mBAAmB,CAkBrB;AAED,wBAAgB,yBAAyB,CAAC,EACxC,IAAwB,EACxB,QAAQ,EACR,KAAiC,EACjC,KAAK,GACN,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,mBAAmB,CA2FtB;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,EAAE,cAAc,EAAE,GACxB,IAAI,CAgBN"}
@@ -1,22 +1,36 @@
1
1
  /// <reference types="jest" />
2
2
  import type { KeyringAccount } from "@metamask/keyring-api";
3
3
  export type MockAccountProvider = {
4
- accounts: KeyringAccount[];
4
+ mockAccounts: KeyringAccount[];
5
+ accounts: Set<KeyringAccount['id']>;
5
6
  constructor: jest.Mock;
7
+ alignAccounts: jest.Mock;
8
+ init: jest.Mock;
6
9
  resyncAccounts: jest.Mock;
7
10
  getAccount: jest.Mock;
8
11
  getAccounts: jest.Mock;
9
12
  createAccounts: jest.Mock;
10
13
  discoverAccounts: jest.Mock;
11
- isAccountCompatible?: jest.Mock;
14
+ isAccountCompatible: jest.Mock;
12
15
  getName: jest.Mock;
16
+ isEnabled: boolean;
17
+ isDisabled: jest.Mock;
18
+ setEnabled: jest.Mock;
13
19
  };
14
20
  export declare function makeMockAccountProvider(accounts?: KeyringAccount[]): MockAccountProvider;
15
- export declare function setupNamedAccountProvider({ name, accounts, mocks, filter, index, }: {
21
+ export declare function setupBip44AccountProvider({ name, accounts, mocks, index, }: {
16
22
  name?: string;
17
23
  mocks?: MockAccountProvider;
18
24
  accounts: KeyringAccount[];
19
25
  filter?: (account: KeyringAccount) => boolean;
20
26
  index?: number;
21
27
  }): MockAccountProvider;
28
+ /**
29
+ * Helper to mock a single createAccounts call while updating the provider's
30
+ * internal state so subsequent getAccount/getAccounts can resolve the accounts.
31
+ *
32
+ * @param provider - The mock provider whose createAccounts call to mock.
33
+ * @param created - The accounts to be returned and persisted in the mock state.
34
+ */
35
+ export declare function mockCreateAccountsOnce(provider: MockAccountProvider, created: KeyringAccount[]): void;
22
36
  //# sourceMappingURL=providers.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"providers.d.mts","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAI5D,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC;IACvB,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC;IAC1B,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC;IACtB,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC;IACvB,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC;IAC1B,gBAAgB,EAAE,IAAI,CAAC,IAAI,CAAC;IAC5B,mBAAmB,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC;IAChC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC;CACpB,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,QAAQ,GAAE,cAAc,EAAO,GAC9B,mBAAmB,CAYrB;AAED,wBAAgB,yBAAyB,CAAC,EACxC,IAAwB,EACxB,QAAQ,EACR,KAAiC,EACjC,MAAmB,EACnB,KAAK,GACN,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,QAA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AAE,cAAc,EAAE,CAAC;IAC3B,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,mBAAmB,CA2FtB;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,EAAE,cAAc,EAAE,GACxB,IAAI,CAgBN"}
@@ -1,9 +1,11 @@
1
- import { isBip44Account } from "@metamask/account-api";
2
- import { EvmAccountProvider } from "../providers/index.mjs";
1
+ import { AccountProviderWrapper, EvmAccountProvider, BaseBip44AccountProvider } from "../providers/index.mjs";
3
2
  export function makeMockAccountProvider(accounts = []) {
4
3
  return {
5
- accounts,
4
+ mockAccounts: accounts,
5
+ accounts: new Set(),
6
6
  constructor: jest.fn(),
7
+ alignAccounts: jest.fn(),
8
+ init: jest.fn(),
7
9
  resyncAccounts: jest.fn(),
8
10
  getAccount: jest.fn(),
9
11
  getAccounts: jest.fn(),
@@ -11,24 +13,76 @@ export function makeMockAccountProvider(accounts = []) {
11
13
  discoverAccounts: jest.fn(),
12
14
  isAccountCompatible: jest.fn(),
13
15
  getName: jest.fn(),
16
+ isDisabled: jest.fn(),
17
+ setEnabled: jest.fn(),
18
+ isEnabled: true,
14
19
  };
15
20
  }
16
- export function setupNamedAccountProvider({ name = 'Mocked Provider', accounts, mocks = makeMockAccountProvider(), filter = () => true, index, }) {
21
+ export function setupBip44AccountProvider({ name = 'Mocked Provider', accounts, mocks = makeMockAccountProvider(), index, }) {
17
22
  // You can mock this and all other mocks will re-use that list
18
23
  // of accounts.
19
- mocks.accounts = accounts;
20
- const getAccounts = () => mocks.accounts.filter((account) => isBip44Account(account) && filter(account));
24
+ mocks.mockAccounts = accounts;
25
+ mocks.accounts = new Set(accounts.map((account) => account.id));
26
+ // Toggle enabled state only
27
+ mocks.setEnabled.mockImplementation((enabled) => {
28
+ mocks.isEnabled = enabled;
29
+ });
30
+ mocks.isDisabled.mockImplementation(() => !mocks.isEnabled);
31
+ const getAccounts = () => mocks.mockAccounts.filter((account) => [...mocks.accounts].includes(account.id));
21
32
  mocks.getName.mockImplementation(() => name);
22
33
  mocks.getAccounts.mockImplementation(getAccounts);
23
34
  mocks.getAccount.mockImplementation((id) =>
24
35
  // Assuming this never fails.
25
36
  getAccounts().find((account) => account.id === id));
26
37
  mocks.createAccounts.mockResolvedValue([]);
38
+ mocks.alignAccounts.mockImplementation(async ({ entropySource, groupIndex, }) => {
39
+ if (mocks.isDisabled()) {
40
+ const wrapperAlign = AccountProviderWrapper.prototype.alignAccounts;
41
+ const ids = await wrapperAlign.call({ isEnabled: false, isDisabled: () => true }, { entropySource, groupIndex });
42
+ return ids;
43
+ }
44
+ const createdAccounts = await mocks.createAccounts({
45
+ entropySource,
46
+ groupIndex,
47
+ });
48
+ const baseAlign = BaseBip44AccountProvider.prototype.alignAccounts;
49
+ const ids = await baseAlign.call({ createAccounts: async () => createdAccounts }, { entropySource, groupIndex });
50
+ return ids;
51
+ });
52
+ mocks.init.mockImplementation((accountIds) => {
53
+ accountIds.forEach((id) => mocks.accounts.add(id));
54
+ });
27
55
  if (index === 0) {
28
56
  // Make the first provider to always be an `EvmAccountProvider`, since we
29
57
  // check for this pre-condition in some methods.
30
58
  Object.setPrototypeOf(mocks, EvmAccountProvider.prototype);
31
59
  }
60
+ if (index !== 0) {
61
+ Object.setPrototypeOf(mocks, AccountProviderWrapper.prototype);
62
+ }
32
63
  return mocks;
33
64
  }
65
+ /**
66
+ * Helper to mock a single createAccounts call while updating the provider's
67
+ * internal state so subsequent getAccount/getAccounts can resolve the accounts.
68
+ *
69
+ * @param provider - The mock provider whose createAccounts call to mock.
70
+ * @param created - The accounts to be returned and persisted in the mock state.
71
+ */
72
+ export function mockCreateAccountsOnce(provider, created) {
73
+ provider.createAccounts.mockImplementationOnce(async () => {
74
+ // Add newly created accounts to the provider's internal store
75
+ for (const acc of created) {
76
+ if (!provider.mockAccounts.some((a) => a.id === acc.id)) {
77
+ provider.mockAccounts.push(acc);
78
+ }
79
+ }
80
+ // Merge IDs into the visible list used by getAccounts/getAccount
81
+ const ids = created.map((a) => a.id);
82
+ for (const id of ids) {
83
+ provider.accounts.add(id);
84
+ }
85
+ return created;
86
+ });
87
+ }
34
88
  //# sourceMappingURL=providers.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"providers.mjs","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,8BAA8B;AAGvD,OAAO,EAAE,kBAAkB,EAAE,+BAAqB;AAclD,MAAM,UAAU,uBAAuB,CACrC,WAA6B,EAAE;IAE/B,OAAO;QACL,QAAQ;QACR,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;QACtB,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;QACzB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;QACrB,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;QACtB,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;QACzB,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC3B,mBAAmB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC9B,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;KACnB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,EACxC,IAAI,GAAG,iBAAiB,EACxB,QAAQ,EACR,KAAK,GAAG,uBAAuB,EAAE,EACjC,MAAM,GAAG,GAAG,EAAE,CAAC,IAAI,EACnB,KAAK,GAON;IACC,8DAA8D;IAC9D,eAAe;IACf,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAE1B,MAAM,WAAW,GAAG,GAAG,EAAE,CACvB,KAAK,CAAC,QAAQ,CAAC,MAAM,CACnB,CAAC,OAAO,EAAE,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CACxD,CAAC;IAEJ,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAE7C,KAAK,CAAC,WAAW,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAClD,KAAK,CAAC,UAAU,CAAC,kBAAkB,CACjC,CAAC,EAAsC,EAAE,EAAE;IACzC,6BAA6B;IAC7B,WAAW,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,CACrD,CAAC;IACF,KAAK,CAAC,cAAc,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;IAE3C,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;QAChB,yEAAyE;QACzE,gDAAgD;QAChD,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport { isBip44Account } from '@metamask/account-api';\nimport type { KeyringAccount } from '@metamask/keyring-api';\n\nimport { EvmAccountProvider } from '../providers';\n\nexport type MockAccountProvider = {\n accounts: KeyringAccount[];\n constructor: jest.Mock;\n resyncAccounts: jest.Mock;\n getAccount: jest.Mock;\n getAccounts: jest.Mock;\n createAccounts: jest.Mock;\n discoverAccounts: jest.Mock;\n isAccountCompatible?: jest.Mock;\n getName: jest.Mock;\n};\n\nexport function makeMockAccountProvider(\n accounts: KeyringAccount[] = [],\n): MockAccountProvider {\n return {\n accounts,\n constructor: jest.fn(),\n resyncAccounts: jest.fn(),\n getAccount: jest.fn(),\n getAccounts: jest.fn(),\n createAccounts: jest.fn(),\n discoverAccounts: jest.fn(),\n isAccountCompatible: jest.fn(),\n getName: jest.fn(),\n };\n}\n\nexport function setupNamedAccountProvider({\n name = 'Mocked Provider',\n accounts,\n mocks = makeMockAccountProvider(),\n filter = () => true,\n index,\n}: {\n name?: string;\n mocks?: MockAccountProvider;\n accounts: KeyringAccount[];\n filter?: (account: KeyringAccount) => boolean;\n index?: number;\n}): MockAccountProvider {\n // You can mock this and all other mocks will re-use that list\n // of accounts.\n mocks.accounts = accounts;\n\n const getAccounts = () =>\n mocks.accounts.filter(\n (account) => isBip44Account(account) && filter(account),\n );\n\n mocks.getName.mockImplementation(() => name);\n\n mocks.getAccounts.mockImplementation(getAccounts);\n mocks.getAccount.mockImplementation(\n (id: Bip44Account<KeyringAccount>['id']) =>\n // Assuming this never fails.\n getAccounts().find((account) => account.id === id),\n );\n mocks.createAccounts.mockResolvedValue([]);\n\n if (index === 0) {\n // Make the first provider to always be an `EvmAccountProvider`, since we\n // check for this pre-condition in some methods.\n Object.setPrototypeOf(mocks, EvmAccountProvider.prototype);\n }\n\n return mocks;\n}\n"]}
1
+ {"version":3,"file":"providers.mjs","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACzB,+BAAqB;AAoBtB,MAAM,UAAU,uBAAuB,CACrC,WAA6B,EAAE;IAE/B,OAAO;QACL,YAAY,EAAE,QAAQ;QACtB,QAAQ,EAAE,IAAI,GAAG,EAAE;QACnB,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;QACtB,aAAa,EAAE,IAAI,CAAC,EAAE,EAAE;QACxB,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;QACf,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;QACzB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;QACrB,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;QACtB,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;QACzB,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC3B,mBAAmB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC9B,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;QAClB,UAAU,EAAE,IAAI,CAAC,EAAE,EAA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AAE,CAAC;QAChB,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAC;IACjE,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,QAA6B,EAC7B,OAAyB;IAEzB,QAAQ,CAAC,cAAc,CAAC,sBAAsB,CAAC,KAAK,IAAI,EAAE;QACxD,8DAA8D;QAC9D,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC1B,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;gBACxD,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;QACD,iEAAiE;QACjE,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACrC,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;YACrB,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5B,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\n\nimport {\n AccountProviderWrapper,\n EvmAccountProvider,\n BaseBip44AccountProvider,\n} from '../providers';\n\nexport type MockAccountProvider = {\n mockAccounts: KeyringAccount[];\n accounts: Set<KeyringAccount['id']>;\n constructor: jest.Mock;\n alignAccounts: jest.Mock;\n init: jest.Mock;\n resyncAccounts: jest.Mock;\n getAccount: jest.Mock;\n getAccounts: jest.Mock;\n createAccounts: jest.Mock;\n discoverAccounts: jest.Mock;\n isAccountCompatible: jest.Mock;\n getName: jest.Mock;\n isEnabled: boolean;\n isDisabled: jest.Mock;\n setEnabled: jest.Mock;\n};\n\nexport function makeMockAccountProvider(\n accounts: KeyringAccount[] = [],\n): MockAccountProvider {\n return {\n mockAccounts: accounts,\n accounts: new Set(),\n constructor: jest.fn(),\n alignAccounts: jest.fn(),\n init: jest.fn(),\n resyncAccounts: jest.fn(),\n getAccount: jest.fn(),\n getAccounts: jest.fn(),\n createAccounts: jest.fn(),\n discoverAccounts: jest.fn(),\n isAccountCompatible: jest.fn(),\n getName: jest.fn(),\n isDisabled: jest.fn(),\n setEnabled: jest.fn(),\n isEnabled: true,\n };\n}\n\nexport function setupBip44AccountProvider({\n name = 'Mocked Provider',\n accounts,\n mocks = makeMockAccountProvider(),\n index,\n}: {\n name?: string;\n mocks?: MockAccountProvider;\n accounts: KeyringAccount[];\n filter?: (account: KeyringAccount) => boolean;\n index?: number;\n}): MockAccountProvider {\n // You can mock this and all other mocks will re-use that list\n // of accounts.\n mocks.mockAccounts = accounts;\n mocks.accounts = new Set(accounts.map((account) => account.id));\n // Toggle enabled state only\n mocks.setEnabled.mockImplementation((enabled: boolean) => {\n mocks.isEnabled = enabled;\n });\n mocks.isDisabled.mockImplementation(() => !mocks.isEnabled);\n\n const getAccounts = () =>\n mocks.mockAccounts.filter((account) =>\n [...mocks.accounts].includes(account.id),\n );\n\n mocks.getName.mockImplementation(() => name);\n\n mocks.getAccounts.mockImplementation(getAccounts);\n mocks.getAccount.mockImplementation(\n (id: Bip44Account<KeyringAccount>['id']) =>\n // Assuming this never fails.\n getAccounts().find((account) => account.id === id),\n );\n mocks.createAccounts.mockResolvedValue([]);\n mocks.alignAccounts.mockImplementation(\n async ({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }) => {\n if (mocks.isDisabled()) {\n const wrapperAlign = (\n AccountProviderWrapper.prototype as unknown as {\n alignAccounts: (\n this: { isEnabled: boolean },\n opts: { entropySource: EntropySourceId; groupIndex: number },\n ) => Promise<string[]>;\n }\n ).alignAccounts;\n const ids = await wrapperAlign.call(\n { isEnabled: false, isDisabled: () => true },\n { entropySource, groupIndex },\n );\n return ids;\n }\n const createdAccounts = await mocks.createAccounts({\n entropySource,\n groupIndex,\n });\n\n const baseAlign = (\n BaseBip44AccountProvider.prototype as unknown as {\n alignAccounts: (\n this: {\n createAccounts: (o: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }) => Promise<unknown[]>;\n },\n opts: { entropySource: EntropySourceId; groupIndex: number },\n ) => Promise<string[]>;\n }\n ).alignAccounts;\n const ids = await baseAlign.call(\n { createAccounts: async () => createdAccounts },\n { entropySource, groupIndex },\n );\n\n return ids;\n },\n );\n mocks.init.mockImplementation(\n (accountIds: Bip44Account<KeyringAccount>['id'][]) => {\n accountIds.forEach((id) => mocks.accounts.add(id));\n },\n );\n\n if (index === 0) {\n // Make the first provider to always be an `EvmAccountProvider`, since we\n // check for this pre-condition in some methods.\n Object.setPrototypeOf(mocks, EvmAccountProvider.prototype);\n }\n\n if (index !== 0) {\n Object.setPrototypeOf(mocks, AccountProviderWrapper.prototype);\n }\n\n return mocks;\n}\n\n/**\n * Helper to mock a single createAccounts call while updating the provider's\n * internal state so subsequent getAccount/getAccounts can resolve the accounts.\n *\n * @param provider - The mock provider whose createAccounts call to mock.\n * @param created - The accounts to be returned and persisted in the mock state.\n */\nexport function mockCreateAccountsOnce(\n provider: MockAccountProvider,\n created: KeyringAccount[],\n): void {\n provider.createAccounts.mockImplementationOnce(async () => {\n // Add newly created accounts to the provider's internal store\n for (const acc of created) {\n if (!provider.mockAccounts.some((a) => a.id === acc.id)) {\n provider.mockAccounts.push(acc);\n }\n }\n // Merge IDs into the visible list used by getAccounts/getAccount\n const ids = created.map((a) => a.id);\n for (const id of ids) {\n provider.accounts.add(id);\n }\n\n return created;\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n Bip44Account,\n MultichainAccountGroup,\n MultichainAccountWalletId,\n MultichainAccountWalletStatus,\n} from '@metamask/account-api';\nimport type {\n AccountsControllerAccountAddedEvent,\n AccountsControllerAccountRemovedEvent,\n AccountsControllerGetAccountAction,\n AccountsControllerGetAccountByAddressAction,\n AccountsControllerListMultichainAccountsAction,\n} from '@metamask/accounts-controller';\nimport type { TraceCallback } from '@metamask/controller-utils';\nimport type { KeyringAccount } from '@metamask/keyring-api';\nimport type {\n KeyringControllerAddNewKeyringAction,\n KeyringControllerGetKeyringsByTypeAction,\n KeyringControllerGetStateAction,\n KeyringControllerStateChangeEvent,\n KeyringControllerWithKeyringAction,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n NetworkControllerFindNetworkClientIdByChainIdAction,\n NetworkControllerGetNetworkClientByIdAction,\n} from '@metamask/network-controller';\nimport type {\n HandleSnapRequest as SnapControllerHandleSnapRequestAction,\n SnapControllerGetStateAction,\n SnapStateChange as SnapControllerStateChangeEvent,\n} from '@metamask/snaps-controllers';\n\nimport type {\n MultichainAccountService,\n serviceName,\n} from './MultichainAccountService';\n\nexport type MultichainAccountServiceGetMultichainAccountGroupAction = {\n type: `${typeof serviceName}:getMultichainAccountGroup`;\n handler: MultichainAccountService['getMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountGroupsAction = {\n type: `${typeof serviceName}:getMultichainAccountGroups`;\n handler: MultichainAccountService['getMultichainAccountGroups'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountWalletAction = {\n type: `${typeof serviceName}:getMultichainAccountWallet`;\n handler: MultichainAccountService['getMultichainAccountWallet'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountWalletsAction = {\n type: `${typeof serviceName}:getMultichainAccountWallets`;\n handler: MultichainAccountService['getMultichainAccountWallets'];\n};\n\nexport type MultichainAccountServiceCreateNextMultichainAccountGroupAction = {\n type: `${typeof serviceName}:createNextMultichainAccountGroup`;\n handler: MultichainAccountService['createNextMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceCreateMultichainAccountGroupAction = {\n type: `${typeof serviceName}:createMultichainAccountGroup`;\n handler: MultichainAccountService['createMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceSetBasicFunctionalityAction = {\n type: `${typeof serviceName}:setBasicFunctionality`;\n handler: MultichainAccountService['setBasicFunctionality'];\n};\n\nexport type MultichainAccountServiceAlignWalletAction = {\n type: `${typeof serviceName}:alignWallet`;\n handler: MultichainAccountService['alignWallet'];\n};\n\nexport type MultichainAccountServiceAlignWalletsAction = {\n type: `${typeof serviceName}:alignWallets`;\n handler: MultichainAccountService['alignWallets'];\n};\n\nexport type MultichainAccountServiceCreateMultichainAccountWalletAction = {\n type: `${typeof serviceName}:createMultichainAccountWallet`;\n handler: MultichainAccountService['createMultichainAccountWallet'];\n};\n\nexport type MultichainAccountServiceResyncAccountsAction = {\n type: `${typeof serviceName}:resyncAccounts`;\n handler: MultichainAccountService['resyncAccounts'];\n};\n\nexport type MultichainAccountServiceEnsureCanUseSnapPlatformAction = {\n type: `${typeof serviceName}:ensureCanUseSnapPlatform`;\n handler: MultichainAccountService['ensureCanUseSnapPlatform'];\n};\n\n/**\n * All actions that {@link MultichainAccountService} registers so that other\n * modules can call them.\n */\nexport type MultichainAccountServiceActions =\n | MultichainAccountServiceGetMultichainAccountGroupAction\n | MultichainAccountServiceGetMultichainAccountGroupsAction\n | MultichainAccountServiceGetMultichainAccountWalletAction\n | MultichainAccountServiceGetMultichainAccountWalletsAction\n | MultichainAccountServiceCreateNextMultichainAccountGroupAction\n | MultichainAccountServiceCreateMultichainAccountGroupAction\n | MultichainAccountServiceSetBasicFunctionalityAction\n | MultichainAccountServiceAlignWalletAction\n | MultichainAccountServiceAlignWalletsAction\n | MultichainAccountServiceCreateMultichainAccountWalletAction\n | MultichainAccountServiceResyncAccountsAction\n | MultichainAccountServiceEnsureCanUseSnapPlatformAction;\n\nexport type MultichainAccountServiceMultichainAccountGroupCreatedEvent = {\n type: `${typeof serviceName}:multichainAccountGroupCreated`;\n payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];\n};\n\nexport type MultichainAccountServiceMultichainAccountGroupUpdatedEvent = {\n type: `${typeof serviceName}:multichainAccountGroupUpdated`;\n payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];\n};\n\nexport type MultichainAccountServiceWalletStatusChangeEvent = {\n type: `${typeof serviceName}:walletStatusChange`;\n payload: [MultichainAccountWalletId, MultichainAccountWalletStatus];\n};\n\n/**\n * All events that {@link MultichainAccountService} publishes so that other modules\n * can subscribe to them.\n */\nexport type MultichainAccountServiceEvents =\n | MultichainAccountServiceMultichainAccountGroupCreatedEvent\n | MultichainAccountServiceMultichainAccountGroupUpdatedEvent\n | MultichainAccountServiceWalletStatusChangeEvent;\n\n/**\n * All actions registered by other modules that {@link MultichainAccountService}\n * calls.\n */\ntype AllowedActions =\n | AccountsControllerListMultichainAccountsAction\n | AccountsControllerGetAccountAction\n | AccountsControllerGetAccountByAddressAction\n | SnapControllerGetStateAction\n | SnapControllerHandleSnapRequestAction\n | KeyringControllerWithKeyringAction\n | KeyringControllerGetStateAction\n | KeyringControllerGetKeyringsByTypeAction\n | KeyringControllerAddNewKeyringAction\n | NetworkControllerGetNetworkClientByIdAction\n | NetworkControllerFindNetworkClientIdByChainIdAction;\n\n/**\n * All events published by other modules that {@link MultichainAccountService}\n * subscribes to.\n */\ntype AllowedEvents =\n | SnapControllerStateChangeEvent\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 = Messenger<\n 'MultichainAccountService',\n MultichainAccountServiceActions | AllowedActions,\n MultichainAccountServiceEvents | AllowedEvents\n>;\n\nexport type MultichainAccountServiceConfig = {\n trace?: TraceCallback;\n};\n"]}
1
+ {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n Bip44Account,\n MultichainAccountGroup,\n MultichainAccountWalletId,\n MultichainAccountWalletStatus,\n} from '@metamask/account-api';\nimport type {\n AccountsControllerAccountAddedEvent,\n AccountsControllerAccountRemovedEvent,\n AccountsControllerGetAccountAction,\n AccountsControllerGetAccountByAddressAction,\n AccountsControllerGetAccountsAction,\n AccountsControllerListMultichainAccountsAction,\n} from '@metamask/accounts-controller';\nimport type { TraceCallback } from '@metamask/controller-utils';\nimport type { KeyringAccount } from '@metamask/keyring-api';\nimport type {\n KeyringControllerAddNewKeyringAction,\n KeyringControllerCreateNewVaultAndKeychainAction,\n KeyringControllerCreateNewVaultAndRestoreAction,\n KeyringControllerGetKeyringsByTypeAction,\n KeyringControllerGetStateAction,\n KeyringControllerRemoveAccountAction,\n KeyringControllerStateChangeEvent,\n KeyringControllerWithKeyringAction,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n NetworkControllerFindNetworkClientIdByChainIdAction,\n NetworkControllerGetNetworkClientByIdAction,\n} from '@metamask/network-controller';\nimport type {\n HandleSnapRequest as SnapControllerHandleSnapRequestAction,\n SnapControllerGetStateAction,\n SnapStateChange as SnapControllerStateChangeEvent,\n} from '@metamask/snaps-controllers';\n\nimport type {\n MultichainAccountService,\n serviceName,\n} from './MultichainAccountService';\n\nexport type MultichainAccountServiceGetMultichainAccountGroupAction = {\n type: `${typeof serviceName}:getMultichainAccountGroup`;\n handler: MultichainAccountService['getMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountGroupsAction = {\n type: `${typeof serviceName}:getMultichainAccountGroups`;\n handler: MultichainAccountService['getMultichainAccountGroups'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountWalletAction = {\n type: `${typeof serviceName}:getMultichainAccountWallet`;\n handler: MultichainAccountService['getMultichainAccountWallet'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountWalletsAction = {\n type: `${typeof serviceName}:getMultichainAccountWallets`;\n handler: MultichainAccountService['getMultichainAccountWallets'];\n};\n\nexport type MultichainAccountServiceCreateNextMultichainAccountGroupAction = {\n type: `${typeof serviceName}:createNextMultichainAccountGroup`;\n handler: MultichainAccountService['createNextMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceCreateMultichainAccountGroupAction = {\n type: `${typeof serviceName}:createMultichainAccountGroup`;\n handler: MultichainAccountService['createMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceSetBasicFunctionalityAction = {\n type: `${typeof serviceName}:setBasicFunctionality`;\n handler: MultichainAccountService['setBasicFunctionality'];\n};\n\nexport type MultichainAccountServiceAlignWalletAction = {\n type: `${typeof serviceName}:alignWallet`;\n handler: MultichainAccountService['alignWallet'];\n};\n\nexport type MultichainAccountServiceAlignWalletsAction = {\n type: `${typeof serviceName}:alignWallets`;\n handler: MultichainAccountService['alignWallets'];\n};\n\nexport type MultichainAccountServiceCreateMultichainAccountWalletAction = {\n type: `${typeof serviceName}:createMultichainAccountWallet`;\n handler: MultichainAccountService['createMultichainAccountWallet'];\n};\n\nexport type MultichainAccountServiceResyncAccountsAction = {\n type: `${typeof serviceName}:resyncAccounts`;\n handler: MultichainAccountService['resyncAccounts'];\n};\n\nexport type MultichainAccountServiceRemoveMultichainAccountWalletAction = {\n type: `${typeof serviceName}:removeMultichainAccountWallet`;\n handler: MultichainAccountService['removeMultichainAccountWallet'];\n};\n\nexport type MultichainAccountServiceEnsureCanUseSnapPlatformAction = {\n type: `${typeof serviceName}:ensureCanUseSnapPlatform`;\n handler: MultichainAccountService['ensureCanUseSnapPlatform'];\n};\n\n/**\n * All actions that {@link MultichainAccountService} registers so that other\n * modules can call them.\n */\nexport type MultichainAccountServiceActions =\n | MultichainAccountServiceGetMultichainAccountGroupAction\n | MultichainAccountServiceGetMultichainAccountGroupsAction\n | MultichainAccountServiceGetMultichainAccountWalletAction\n | MultichainAccountServiceGetMultichainAccountWalletsAction\n | MultichainAccountServiceCreateNextMultichainAccountGroupAction\n | MultichainAccountServiceCreateMultichainAccountGroupAction\n | MultichainAccountServiceSetBasicFunctionalityAction\n | MultichainAccountServiceAlignWalletAction\n | MultichainAccountServiceAlignWalletsAction\n | MultichainAccountServiceCreateMultichainAccountWalletAction\n | MultichainAccountServiceResyncAccountsAction\n | MultichainAccountServiceRemoveMultichainAccountWalletAction\n | MultichainAccountServiceEnsureCanUseSnapPlatformAction;\n\nexport type MultichainAccountServiceMultichainAccountGroupCreatedEvent = {\n type: `${typeof serviceName}:multichainAccountGroupCreated`;\n payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];\n};\n\nexport type MultichainAccountServiceMultichainAccountGroupUpdatedEvent = {\n type: `${typeof serviceName}:multichainAccountGroupUpdated`;\n payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];\n};\n\nexport type MultichainAccountServiceWalletStatusChangeEvent = {\n type: `${typeof serviceName}:walletStatusChange`;\n payload: [MultichainAccountWalletId, MultichainAccountWalletStatus];\n};\n\n/**\n * All events that {@link MultichainAccountService} publishes so that other modules\n * can subscribe to them.\n */\nexport type MultichainAccountServiceEvents =\n | MultichainAccountServiceMultichainAccountGroupCreatedEvent\n | MultichainAccountServiceMultichainAccountGroupUpdatedEvent\n | MultichainAccountServiceWalletStatusChangeEvent;\n\n/**\n * All actions registered by other modules that {@link MultichainAccountService}\n * calls.\n */\ntype AllowedActions =\n | AccountsControllerListMultichainAccountsAction\n | AccountsControllerGetAccountsAction\n | AccountsControllerGetAccountAction\n | AccountsControllerGetAccountByAddressAction\n | SnapControllerGetStateAction\n | SnapControllerHandleSnapRequestAction\n | KeyringControllerWithKeyringAction\n | KeyringControllerGetStateAction\n | KeyringControllerGetKeyringsByTypeAction\n | KeyringControllerAddNewKeyringAction\n | NetworkControllerGetNetworkClientByIdAction\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | KeyringControllerCreateNewVaultAndKeychainAction\n | KeyringControllerCreateNewVaultAndRestoreAction\n | KeyringControllerRemoveAccountAction;\n\n/**\n * All events published by other modules that {@link MultichainAccountService}\n * subscribes to.\n */\ntype AllowedEvents =\n | SnapControllerStateChangeEvent\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 = Messenger<\n 'MultichainAccountService',\n MultichainAccountServiceActions | AllowedActions,\n MultichainAccountServiceEvents | AllowedEvents\n>;\n\nexport type MultichainAccountServiceConfig = {\n trace?: TraceCallback;\n};\n"]}
package/dist/types.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  import type { Bip44Account, MultichainAccountGroup, MultichainAccountWalletId, MultichainAccountWalletStatus } from "@metamask/account-api";
2
- import type { AccountsControllerAccountAddedEvent, AccountsControllerAccountRemovedEvent, AccountsControllerGetAccountAction, AccountsControllerGetAccountByAddressAction, AccountsControllerListMultichainAccountsAction } from "@metamask/accounts-controller";
2
+ import type { AccountsControllerAccountAddedEvent, AccountsControllerAccountRemovedEvent, AccountsControllerGetAccountAction, AccountsControllerGetAccountByAddressAction, AccountsControllerGetAccountsAction, AccountsControllerListMultichainAccountsAction } from "@metamask/accounts-controller";
3
3
  import type { TraceCallback } from "@metamask/controller-utils";
4
4
  import type { KeyringAccount } from "@metamask/keyring-api";
5
- import type { KeyringControllerAddNewKeyringAction, KeyringControllerGetKeyringsByTypeAction, KeyringControllerGetStateAction, KeyringControllerStateChangeEvent, KeyringControllerWithKeyringAction } from "@metamask/keyring-controller";
5
+ import type { KeyringControllerAddNewKeyringAction, KeyringControllerCreateNewVaultAndKeychainAction, KeyringControllerCreateNewVaultAndRestoreAction, KeyringControllerGetKeyringsByTypeAction, KeyringControllerGetStateAction, KeyringControllerRemoveAccountAction, KeyringControllerStateChangeEvent, KeyringControllerWithKeyringAction } from "@metamask/keyring-controller";
6
6
  import type { Messenger } from "@metamask/messenger";
7
7
  import type { NetworkControllerFindNetworkClientIdByChainIdAction, NetworkControllerGetNetworkClientByIdAction } from "@metamask/network-controller";
8
8
  import type { HandleSnapRequest as SnapControllerHandleSnapRequestAction, SnapControllerGetStateAction, SnapStateChange as SnapControllerStateChangeEvent } from "@metamask/snaps-controllers";
@@ -51,6 +51,10 @@ export type MultichainAccountServiceResyncAccountsAction = {
51
51
  type: `${typeof serviceName}:resyncAccounts`;
52
52
  handler: MultichainAccountService['resyncAccounts'];
53
53
  };
54
+ export type MultichainAccountServiceRemoveMultichainAccountWalletAction = {
55
+ type: `${typeof serviceName}:removeMultichainAccountWallet`;
56
+ handler: MultichainAccountService['removeMultichainAccountWallet'];
57
+ };
54
58
  export type MultichainAccountServiceEnsureCanUseSnapPlatformAction = {
55
59
  type: `${typeof serviceName}:ensureCanUseSnapPlatform`;
56
60
  handler: MultichainAccountService['ensureCanUseSnapPlatform'];
@@ -59,7 +63,7 @@ export type MultichainAccountServiceEnsureCanUseSnapPlatformAction = {
59
63
  * All actions that {@link MultichainAccountService} registers so that other
60
64
  * modules can call them.
61
65
  */
62
- export type MultichainAccountServiceActions = MultichainAccountServiceGetMultichainAccountGroupAction | MultichainAccountServiceGetMultichainAccountGroupsAction | MultichainAccountServiceGetMultichainAccountWalletAction | MultichainAccountServiceGetMultichainAccountWalletsAction | MultichainAccountServiceCreateNextMultichainAccountGroupAction | MultichainAccountServiceCreateMultichainAccountGroupAction | MultichainAccountServiceSetBasicFunctionalityAction | MultichainAccountServiceAlignWalletAction | MultichainAccountServiceAlignWalletsAction | MultichainAccountServiceCreateMultichainAccountWalletAction | MultichainAccountServiceResyncAccountsAction | MultichainAccountServiceEnsureCanUseSnapPlatformAction;
66
+ export type MultichainAccountServiceActions = MultichainAccountServiceGetMultichainAccountGroupAction | MultichainAccountServiceGetMultichainAccountGroupsAction | MultichainAccountServiceGetMultichainAccountWalletAction | MultichainAccountServiceGetMultichainAccountWalletsAction | MultichainAccountServiceCreateNextMultichainAccountGroupAction | MultichainAccountServiceCreateMultichainAccountGroupAction | MultichainAccountServiceSetBasicFunctionalityAction | MultichainAccountServiceAlignWalletAction | MultichainAccountServiceAlignWalletsAction | MultichainAccountServiceCreateMultichainAccountWalletAction | MultichainAccountServiceResyncAccountsAction | MultichainAccountServiceRemoveMultichainAccountWalletAction | MultichainAccountServiceEnsureCanUseSnapPlatformAction;
63
67
  export type MultichainAccountServiceMultichainAccountGroupCreatedEvent = {
64
68
  type: `${typeof serviceName}:multichainAccountGroupCreated`;
65
69
  payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];
@@ -81,7 +85,7 @@ export type MultichainAccountServiceEvents = MultichainAccountServiceMultichainA
81
85
  * All actions registered by other modules that {@link MultichainAccountService}
82
86
  * calls.
83
87
  */
84
- type AllowedActions = AccountsControllerListMultichainAccountsAction | AccountsControllerGetAccountAction | AccountsControllerGetAccountByAddressAction | SnapControllerGetStateAction | SnapControllerHandleSnapRequestAction | KeyringControllerWithKeyringAction | KeyringControllerGetStateAction | KeyringControllerGetKeyringsByTypeAction | KeyringControllerAddNewKeyringAction | NetworkControllerGetNetworkClientByIdAction | NetworkControllerFindNetworkClientIdByChainIdAction;
88
+ type AllowedActions = AccountsControllerListMultichainAccountsAction | AccountsControllerGetAccountsAction | AccountsControllerGetAccountAction | AccountsControllerGetAccountByAddressAction | SnapControllerGetStateAction | SnapControllerHandleSnapRequestAction | KeyringControllerWithKeyringAction | KeyringControllerGetStateAction | KeyringControllerGetKeyringsByTypeAction | KeyringControllerAddNewKeyringAction | NetworkControllerGetNetworkClientByIdAction | NetworkControllerFindNetworkClientIdByChainIdAction | KeyringControllerCreateNewVaultAndKeychainAction | KeyringControllerCreateNewVaultAndRestoreAction | KeyringControllerRemoveAccountAction;
85
89
  /**
86
90
  * All events published by other modules that {@link MultichainAccountService}
87
91
  * subscribes to.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,Y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A2C,GAC3C,4BAA4B,GAC5B,qCAAqC,GACrC,kCAAkC,GAClC,+BAA+B,GAC/B,wCAAwC,GACxC,oCAAoC,GACpC,2CAA2C,GAC3C,mDAAmD,GACnD,gDAAgD,GAChD,+CAA+C,GAC/C,oCAAoC,CAAC;AAEzC;;;GAGG;AACH,KAAK,aAAa,GACd,8BAA8B,GAC9B,iCAAiC,GACjC,mCAAmC,GACnC,qCAAqC,CAAC;AAE1C;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG,SAAS,CACvD,0BAA0B,EAC1B,+BAA+B,GAAG,cAAc,EAChD,8BAA8B,GAAG,aAAa,CAC/C,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,CAAC"}
package/dist/types.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  import type { Bip44Account, MultichainAccountGroup, MultichainAccountWalletId, MultichainAccountWalletStatus } from "@metamask/account-api";
2
- import type { AccountsControllerAccountAddedEvent, AccountsControllerAccountRemovedEvent, AccountsControllerGetAccountAction, AccountsControllerGetAccountByAddressAction, AccountsControllerListMultichainAccountsAction } from "@metamask/accounts-controller";
2
+ import type { AccountsControllerAccountAddedEvent, AccountsControllerAccountRemovedEvent, AccountsControllerGetAccountAction, AccountsControllerGetAccountByAddressAction, AccountsControllerGetAccountsAction, AccountsControllerListMultichainAccountsAction } from "@metamask/accounts-controller";
3
3
  import type { TraceCallback } from "@metamask/controller-utils";
4
4
  import type { KeyringAccount } from "@metamask/keyring-api";
5
- import type { KeyringControllerAddNewKeyringAction, KeyringControllerGetKeyringsByTypeAction, KeyringControllerGetStateAction, KeyringControllerStateChangeEvent, KeyringControllerWithKeyringAction } from "@metamask/keyring-controller";
5
+ import type { KeyringControllerAddNewKeyringAction, KeyringControllerCreateNewVaultAndKeychainAction, KeyringControllerCreateNewVaultAndRestoreAction, KeyringControllerGetKeyringsByTypeAction, KeyringControllerGetStateAction, KeyringControllerRemoveAccountAction, KeyringControllerStateChangeEvent, KeyringControllerWithKeyringAction } from "@metamask/keyring-controller";
6
6
  import type { Messenger } from "@metamask/messenger";
7
7
  import type { NetworkControllerFindNetworkClientIdByChainIdAction, NetworkControllerGetNetworkClientByIdAction } from "@metamask/network-controller";
8
8
  import type { HandleSnapRequest as SnapControllerHandleSnapRequestAction, SnapControllerGetStateAction, SnapStateChange as SnapControllerStateChangeEvent } from "@metamask/snaps-controllers";
@@ -51,6 +51,10 @@ export type MultichainAccountServiceResyncAccountsAction = {
51
51
  type: `${typeof serviceName}:resyncAccounts`;
52
52
  handler: MultichainAccountService['resyncAccounts'];
53
53
  };
54
+ export type MultichainAccountServiceRemoveMultichainAccountWalletAction = {
55
+ type: `${typeof serviceName}:removeMultichainAccountWallet`;
56
+ handler: MultichainAccountService['removeMultichainAccountWallet'];
57
+ };
54
58
  export type MultichainAccountServiceEnsureCanUseSnapPlatformAction = {
55
59
  type: `${typeof serviceName}:ensureCanUseSnapPlatform`;
56
60
  handler: MultichainAccountService['ensureCanUseSnapPlatform'];
@@ -59,7 +63,7 @@ export type MultichainAccountServiceEnsureCanUseSnapPlatformAction = {
59
63
  * All actions that {@link MultichainAccountService} registers so that other
60
64
  * modules can call them.
61
65
  */
62
- export type MultichainAccountServiceActions = MultichainAccountServiceGetMultichainAccountGroupAction | MultichainAccountServiceGetMultichainAccountGroupsAction | MultichainAccountServiceGetMultichainAccountWalletAction | MultichainAccountServiceGetMultichainAccountWalletsAction | MultichainAccountServiceCreateNextMultichainAccountGroupAction | MultichainAccountServiceCreateMultichainAccountGroupAction | MultichainAccountServiceSetBasicFunctionalityAction | MultichainAccountServiceAlignWalletAction | MultichainAccountServiceAlignWalletsAction | MultichainAccountServiceCreateMultichainAccountWalletAction | MultichainAccountServiceResyncAccountsAction | MultichainAccountServiceEnsureCanUseSnapPlatformAction;
66
+ export type MultichainAccountServiceActions = MultichainAccountServiceGetMultichainAccountGroupAction | MultichainAccountServiceGetMultichainAccountGroupsAction | MultichainAccountServiceGetMultichainAccountWalletAction | MultichainAccountServiceGetMultichainAccountWalletsAction | MultichainAccountServiceCreateNextMultichainAccountGroupAction | MultichainAccountServiceCreateMultichainAccountGroupAction | MultichainAccountServiceSetBasicFunctionalityAction | MultichainAccountServiceAlignWalletAction | MultichainAccountServiceAlignWalletsAction | MultichainAccountServiceCreateMultichainAccountWalletAction | MultichainAccountServiceResyncAccountsAction | MultichainAccountServiceRemoveMultichainAccountWalletAction | MultichainAccountServiceEnsureCanUseSnapPlatformAction;
63
67
  export type MultichainAccountServiceMultichainAccountGroupCreatedEvent = {
64
68
  type: `${typeof serviceName}:multichainAccountGroupCreated`;
65
69
  payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];
@@ -81,7 +85,7 @@ export type MultichainAccountServiceEvents = MultichainAccountServiceMultichainA
81
85
  * All actions registered by other modules that {@link MultichainAccountService}
82
86
  * calls.
83
87
  */
84
- type AllowedActions = AccountsControllerListMultichainAccountsAction | AccountsControllerGetAccountAction | AccountsControllerGetAccountByAddressAction | SnapControllerGetStateAction | SnapControllerHandleSnapRequestAction | KeyringControllerWithKeyringAction | KeyringControllerGetStateAction | KeyringControllerGetKeyringsByTypeAction | KeyringControllerAddNewKeyringAction | NetworkControllerGetNetworkClientByIdAction | NetworkControllerFindNetworkClientIdByChainIdAction;
88
+ type AllowedActions = AccountsControllerListMultichainAccountsAction | AccountsControllerGetAccountsAction | AccountsControllerGetAccountAction | AccountsControllerGetAccountByAddressAction | SnapControllerGetStateAction | SnapControllerHandleSnapRequestAction | KeyringControllerWithKeyringAction | KeyringControllerGetStateAction | KeyringControllerGetKeyringsByTypeAction | KeyringControllerAddNewKeyringAction | NetworkControllerGetNetworkClientByIdAction | NetworkControllerFindNetworkClientIdByChainIdAction | KeyringControllerCreateNewVaultAndKeychainAction | KeyringControllerCreateNewVaultAndRestoreAction | KeyringControllerRemoveAccountAction;
85
89
  /**
86
90
  * All events published by other modules that {@link MultichainAccountService}
87
91
  * subscribes to.
@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,+CAA+C,CAAC;AAEpD;;;GAGG;AACH,KAAK,cAAc,GACf,8CAA8C,GAC9C,mCAAmC,GACnC,kCAAkC,GAClC,2CAA2C,GAC3C,4BAA4B,GAC5B,qCAAqC,GACrC,kCAAkC,GAClC,+BAA+B,GAC/B,wCAAwC,GACxC,oCAAoC,GACpC,2CAA2C,GAC3C,mDAAmD,GACnD,gDAAgD,GAChD,+CAA+C,GAC/C,oCAAoC,CAAC;AAEzC;;;GAGG;AACH,KAAK,aAAa,GACd,8BAA8B,GAC9B,iCAAiC,GACjC,mCAAmC,GACnC,qCAAqC,CAAC;AAE1C;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG,SAAS,CACvD,0BAA0B,EAC1B,+BAA+B,GAAG,cAAc,EAChD,8BAA8B,GAAG,aAAa,CAC/C,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n Bip44Account,\n MultichainAccountGroup,\n MultichainAccountWalletId,\n MultichainAccountWalletStatus,\n} from '@metamask/account-api';\nimport type {\n AccountsControllerAccountAddedEvent,\n AccountsControllerAccountRemovedEvent,\n AccountsControllerGetAccountAction,\n AccountsControllerGetAccountByAddressAction,\n AccountsControllerListMultichainAccountsAction,\n} from '@metamask/accounts-controller';\nimport type { TraceCallback } from '@metamask/controller-utils';\nimport type { KeyringAccount } from '@metamask/keyring-api';\nimport type {\n KeyringControllerAddNewKeyringAction,\n KeyringControllerGetKeyringsByTypeAction,\n KeyringControllerGetStateAction,\n KeyringControllerStateChangeEvent,\n KeyringControllerWithKeyringAction,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n NetworkControllerFindNetworkClientIdByChainIdAction,\n NetworkControllerGetNetworkClientByIdAction,\n} from '@metamask/network-controller';\nimport type {\n HandleSnapRequest as SnapControllerHandleSnapRequestAction,\n SnapControllerGetStateAction,\n SnapStateChange as SnapControllerStateChangeEvent,\n} from '@metamask/snaps-controllers';\n\nimport type {\n MultichainAccountService,\n serviceName,\n} from './MultichainAccountService';\n\nexport type MultichainAccountServiceGetMultichainAccountGroupAction = {\n type: `${typeof serviceName}:getMultichainAccountGroup`;\n handler: MultichainAccountService['getMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountGroupsAction = {\n type: `${typeof serviceName}:getMultichainAccountGroups`;\n handler: MultichainAccountService['getMultichainAccountGroups'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountWalletAction = {\n type: `${typeof serviceName}:getMultichainAccountWallet`;\n handler: MultichainAccountService['getMultichainAccountWallet'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountWalletsAction = {\n type: `${typeof serviceName}:getMultichainAccountWallets`;\n handler: MultichainAccountService['getMultichainAccountWallets'];\n};\n\nexport type MultichainAccountServiceCreateNextMultichainAccountGroupAction = {\n type: `${typeof serviceName}:createNextMultichainAccountGroup`;\n handler: MultichainAccountService['createNextMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceCreateMultichainAccountGroupAction = {\n type: `${typeof serviceName}:createMultichainAccountGroup`;\n handler: MultichainAccountService['createMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceSetBasicFunctionalityAction = {\n type: `${typeof serviceName}:setBasicFunctionality`;\n handler: MultichainAccountService['setBasicFunctionality'];\n};\n\nexport type MultichainAccountServiceAlignWalletAction = {\n type: `${typeof serviceName}:alignWallet`;\n handler: MultichainAccountService['alignWallet'];\n};\n\nexport type MultichainAccountServiceAlignWalletsAction = {\n type: `${typeof serviceName}:alignWallets`;\n handler: MultichainAccountService['alignWallets'];\n};\n\nexport type MultichainAccountServiceCreateMultichainAccountWalletAction = {\n type: `${typeof serviceName}:createMultichainAccountWallet`;\n handler: MultichainAccountService['createMultichainAccountWallet'];\n};\n\nexport type MultichainAccountServiceResyncAccountsAction = {\n type: `${typeof serviceName}:resyncAccounts`;\n handler: MultichainAccountService['resyncAccounts'];\n};\n\nexport type MultichainAccountServiceEnsureCanUseSnapPlatformAction = {\n type: `${typeof serviceName}:ensureCanUseSnapPlatform`;\n handler: MultichainAccountService['ensureCanUseSnapPlatform'];\n};\n\n/**\n * All actions that {@link MultichainAccountService} registers so that other\n * modules can call them.\n */\nexport type MultichainAccountServiceActions =\n | MultichainAccountServiceGetMultichainAccountGroupAction\n | MultichainAccountServiceGetMultichainAccountGroupsAction\n | MultichainAccountServiceGetMultichainAccountWalletAction\n | MultichainAccountServiceGetMultichainAccountWalletsAction\n | MultichainAccountServiceCreateNextMultichainAccountGroupAction\n | MultichainAccountServiceCreateMultichainAccountGroupAction\n | MultichainAccountServiceSetBasicFunctionalityAction\n | MultichainAccountServiceAlignWalletAction\n | MultichainAccountServiceAlignWalletsAction\n | MultichainAccountServiceCreateMultichainAccountWalletAction\n | MultichainAccountServiceResyncAccountsAction\n | MultichainAccountServiceEnsureCanUseSnapPlatformAction;\n\nexport type MultichainAccountServiceMultichainAccountGroupCreatedEvent = {\n type: `${typeof serviceName}:multichainAccountGroupCreated`;\n payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];\n};\n\nexport type MultichainAccountServiceMultichainAccountGroupUpdatedEvent = {\n type: `${typeof serviceName}:multichainAccountGroupUpdated`;\n payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];\n};\n\nexport type MultichainAccountServiceWalletStatusChangeEvent = {\n type: `${typeof serviceName}:walletStatusChange`;\n payload: [MultichainAccountWalletId, MultichainAccountWalletStatus];\n};\n\n/**\n * All events that {@link MultichainAccountService} publishes so that other modules\n * can subscribe to them.\n */\nexport type MultichainAccountServiceEvents =\n | MultichainAccountServiceMultichainAccountGroupCreatedEvent\n | MultichainAccountServiceMultichainAccountGroupUpdatedEvent\n | MultichainAccountServiceWalletStatusChangeEvent;\n\n/**\n * All actions registered by other modules that {@link MultichainAccountService}\n * calls.\n */\ntype AllowedActions =\n | AccountsControllerListMultichainAccountsAction\n | AccountsControllerGetAccountAction\n | AccountsControllerGetAccountByAddressAction\n | SnapControllerGetStateAction\n | SnapControllerHandleSnapRequestAction\n | KeyringControllerWithKeyringAction\n | KeyringControllerGetStateAction\n | KeyringControllerGetKeyringsByTypeAction\n | KeyringControllerAddNewKeyringAction\n | NetworkControllerGetNetworkClientByIdAction\n | NetworkControllerFindNetworkClientIdByChainIdAction;\n\n/**\n * All events published by other modules that {@link MultichainAccountService}\n * subscribes to.\n */\ntype AllowedEvents =\n | SnapControllerStateChangeEvent\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 = Messenger<\n 'MultichainAccountService',\n MultichainAccountServiceActions | AllowedActions,\n MultichainAccountServiceEvents | AllowedEvents\n>;\n\nexport type MultichainAccountServiceConfig = {\n trace?: TraceCallback;\n};\n"]}
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n Bip44Account,\n MultichainAccountGroup,\n MultichainAccountWalletId,\n MultichainAccountWalletStatus,\n} from '@metamask/account-api';\nimport type {\n AccountsControllerAccountAddedEvent,\n AccountsControllerAccountRemovedEvent,\n AccountsControllerGetAccountAction,\n AccountsControllerGetAccountByAddressAction,\n AccountsControllerGetAccountsAction,\n AccountsControllerListMultichainAccountsAction,\n} from '@metamask/accounts-controller';\nimport type { TraceCallback } from '@metamask/controller-utils';\nimport type { KeyringAccount } from '@metamask/keyring-api';\nimport type {\n KeyringControllerAddNewKeyringAction,\n KeyringControllerCreateNewVaultAndKeychainAction,\n KeyringControllerCreateNewVaultAndRestoreAction,\n KeyringControllerGetKeyringsByTypeAction,\n KeyringControllerGetStateAction,\n KeyringControllerRemoveAccountAction,\n KeyringControllerStateChangeEvent,\n KeyringControllerWithKeyringAction,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n NetworkControllerFindNetworkClientIdByChainIdAction,\n NetworkControllerGetNetworkClientByIdAction,\n} from '@metamask/network-controller';\nimport type {\n HandleSnapRequest as SnapControllerHandleSnapRequestAction,\n SnapControllerGetStateAction,\n SnapStateChange as SnapControllerStateChangeEvent,\n} from '@metamask/snaps-controllers';\n\nimport type {\n MultichainAccountService,\n serviceName,\n} from './MultichainAccountService';\n\nexport type MultichainAccountServiceGetMultichainAccountGroupAction = {\n type: `${typeof serviceName}:getMultichainAccountGroup`;\n handler: MultichainAccountService['getMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountGroupsAction = {\n type: `${typeof serviceName}:getMultichainAccountGroups`;\n handler: MultichainAccountService['getMultichainAccountGroups'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountWalletAction = {\n type: `${typeof serviceName}:getMultichainAccountWallet`;\n handler: MultichainAccountService['getMultichainAccountWallet'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountWalletsAction = {\n type: `${typeof serviceName}:getMultichainAccountWallets`;\n handler: MultichainAccountService['getMultichainAccountWallets'];\n};\n\nexport type MultichainAccountServiceCreateNextMultichainAccountGroupAction = {\n type: `${typeof serviceName}:createNextMultichainAccountGroup`;\n handler: MultichainAccountService['createNextMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceCreateMultichainAccountGroupAction = {\n type: `${typeof serviceName}:createMultichainAccountGroup`;\n handler: MultichainAccountService['createMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceSetBasicFunctionalityAction = {\n type: `${typeof serviceName}:setBasicFunctionality`;\n handler: MultichainAccountService['setBasicFunctionality'];\n};\n\nexport type MultichainAccountServiceAlignWalletAction = {\n type: `${typeof serviceName}:alignWallet`;\n handler: MultichainAccountService['alignWallet'];\n};\n\nexport type MultichainAccountServiceAlignWalletsAction = {\n type: `${typeof serviceName}:alignWallets`;\n handler: MultichainAccountService['alignWallets'];\n};\n\nexport type MultichainAccountServiceCreateMultichainAccountWalletAction = {\n type: `${typeof serviceName}:createMultichainAccountWallet`;\n handler: MultichainAccountService['createMultichainAccountWallet'];\n};\n\nexport type MultichainAccountServiceResyncAccountsAction = {\n type: `${typeof serviceName}:resyncAccounts`;\n handler: MultichainAccountService['resyncAccounts'];\n};\n\nexport type MultichainAccountServiceRemoveMultichainAccountWalletAction = {\n type: `${typeof serviceName}:removeMultichainAccountWallet`;\n handler: MultichainAccountService['removeMultichainAccountWallet'];\n};\n\nexport type MultichainAccountServiceEnsureCanUseSnapPlatformAction = {\n type: `${typeof serviceName}:ensureCanUseSnapPlatform`;\n handler: MultichainAccountService['ensureCanUseSnapPlatform'];\n};\n\n/**\n * All actions that {@link MultichainAccountService} registers so that other\n * modules can call them.\n */\nexport type MultichainAccountServiceActions =\n | MultichainAccountServiceGetMultichainAccountGroupAction\n | MultichainAccountServiceGetMultichainAccountGroupsAction\n | MultichainAccountServiceGetMultichainAccountWalletAction\n | MultichainAccountServiceGetMultichainAccountWalletsAction\n | MultichainAccountServiceCreateNextMultichainAccountGroupAction\n | MultichainAccountServiceCreateMultichainAccountGroupAction\n | MultichainAccountServiceSetBasicFunctionalityAction\n | MultichainAccountServiceAlignWalletAction\n | MultichainAccountServiceAlignWalletsAction\n | MultichainAccountServiceCreateMultichainAccountWalletAction\n | MultichainAccountServiceResyncAccountsAction\n | MultichainAccountServiceRemoveMultichainAccountWalletAction\n | MultichainAccountServiceEnsureCanUseSnapPlatformAction;\n\nexport type MultichainAccountServiceMultichainAccountGroupCreatedEvent = {\n type: `${typeof serviceName}:multichainAccountGroupCreated`;\n payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];\n};\n\nexport type MultichainAccountServiceMultichainAccountGroupUpdatedEvent = {\n type: `${typeof serviceName}:multichainAccountGroupUpdated`;\n payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];\n};\n\nexport type MultichainAccountServiceWalletStatusChangeEvent = {\n type: `${typeof serviceName}:walletStatusChange`;\n payload: [MultichainAccountWalletId, MultichainAccountWalletStatus];\n};\n\n/**\n * All events that {@link MultichainAccountService} publishes so that other modules\n * can subscribe to them.\n */\nexport type MultichainAccountServiceEvents =\n | MultichainAccountServiceMultichainAccountGroupCreatedEvent\n | MultichainAccountServiceMultichainAccountGroupUpdatedEvent\n | MultichainAccountServiceWalletStatusChangeEvent;\n\n/**\n * All actions registered by other modules that {@link MultichainAccountService}\n * calls.\n */\ntype AllowedActions =\n | AccountsControllerListMultichainAccountsAction\n | AccountsControllerGetAccountsAction\n | AccountsControllerGetAccountAction\n | AccountsControllerGetAccountByAddressAction\n | SnapControllerGetStateAction\n | SnapControllerHandleSnapRequestAction\n | KeyringControllerWithKeyringAction\n | KeyringControllerGetStateAction\n | KeyringControllerGetKeyringsByTypeAction\n | KeyringControllerAddNewKeyringAction\n | NetworkControllerGetNetworkClientByIdAction\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | KeyringControllerCreateNewVaultAndKeychainAction\n | KeyringControllerCreateNewVaultAndRestoreAction\n | KeyringControllerRemoveAccountAction;\n\n/**\n * All events published by other modules that {@link MultichainAccountService}\n * subscribes to.\n */\ntype AllowedEvents =\n | SnapControllerStateChangeEvent\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 = Messenger<\n 'MultichainAccountService',\n MultichainAccountServiceActions | AllowedActions,\n MultichainAccountServiceEvents | AllowedEvents\n>;\n\nexport type MultichainAccountServiceConfig = {\n trace?: TraceCallback;\n};\n"]}