@metamask/multichain-account-service 7.0.0 → 8.0.0

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 (210) hide show
  1. package/CHANGELOG.md +63 -1
  2. package/dist/MultichainAccountGroup.cjs +4 -69
  3. package/dist/MultichainAccountGroup.cjs.map +1 -1
  4. package/dist/MultichainAccountGroup.d.cts +0 -6
  5. package/dist/MultichainAccountGroup.d.cts.map +1 -1
  6. package/dist/MultichainAccountGroup.d.mts +0 -6
  7. package/dist/MultichainAccountGroup.d.mts.map +1 -1
  8. package/dist/MultichainAccountGroup.mjs +5 -70
  9. package/dist/MultichainAccountGroup.mjs.map +1 -1
  10. package/dist/MultichainAccountService-method-action-types.cjs +7 -0
  11. package/dist/MultichainAccountService-method-action-types.cjs.map +1 -0
  12. package/dist/MultichainAccountService-method-action-types.d.cts +177 -0
  13. package/dist/MultichainAccountService-method-action-types.d.cts.map +1 -0
  14. package/dist/MultichainAccountService-method-action-types.d.mts +177 -0
  15. package/dist/MultichainAccountService-method-action-types.d.mts.map +1 -0
  16. package/dist/MultichainAccountService-method-action-types.mjs +6 -0
  17. package/dist/MultichainAccountService-method-action-types.mjs.map +1 -0
  18. package/dist/MultichainAccountService.cjs +59 -28
  19. package/dist/MultichainAccountService.cjs.map +1 -1
  20. package/dist/MultichainAccountService.d.cts +24 -2
  21. package/dist/MultichainAccountService.d.cts.map +1 -1
  22. package/dist/MultichainAccountService.d.mts +24 -2
  23. package/dist/MultichainAccountService.d.mts.map +1 -1
  24. package/dist/MultichainAccountService.mjs +60 -29
  25. package/dist/MultichainAccountService.mjs.map +1 -1
  26. package/dist/MultichainAccountWallet.cjs +302 -164
  27. package/dist/MultichainAccountWallet.cjs.map +1 -1
  28. package/dist/MultichainAccountWallet.d.cts +27 -7
  29. package/dist/MultichainAccountWallet.d.cts.map +1 -1
  30. package/dist/MultichainAccountWallet.d.mts +27 -7
  31. package/dist/MultichainAccountWallet.d.mts.map +1 -1
  32. package/dist/MultichainAccountWallet.mjs +303 -165
  33. package/dist/MultichainAccountWallet.mjs.map +1 -1
  34. package/dist/analytics/perf.cjs +65 -0
  35. package/dist/analytics/perf.cjs.map +1 -0
  36. package/dist/analytics/perf.d.cts +34 -0
  37. package/dist/analytics/perf.d.cts.map +1 -0
  38. package/dist/analytics/perf.d.mts +34 -0
  39. package/dist/analytics/perf.d.mts.map +1 -0
  40. package/dist/analytics/perf.mjs +59 -0
  41. package/dist/analytics/perf.mjs.map +1 -0
  42. package/dist/analytics/timer.cjs +14 -0
  43. package/dist/analytics/timer.cjs.map +1 -0
  44. package/dist/analytics/timer.d.cts +8 -0
  45. package/dist/analytics/timer.d.cts.map +1 -0
  46. package/dist/analytics/timer.d.mts +8 -0
  47. package/dist/analytics/timer.d.mts.map +1 -0
  48. package/dist/analytics/timer.mjs +10 -0
  49. package/dist/analytics/timer.mjs.map +1 -0
  50. package/dist/analytics/traces.cjs +49 -1
  51. package/dist/analytics/traces.cjs.map +1 -1
  52. package/dist/analytics/traces.d.cts +28 -0
  53. package/dist/analytics/traces.d.cts.map +1 -1
  54. package/dist/analytics/traces.d.mts +28 -0
  55. package/dist/analytics/traces.d.mts.map +1 -1
  56. package/dist/analytics/traces.mjs +46 -0
  57. package/dist/analytics/traces.mjs.map +1 -1
  58. package/dist/errors.cjs +32 -0
  59. package/dist/errors.cjs.map +1 -0
  60. package/dist/errors.d.cts +16 -0
  61. package/dist/errors.d.cts.map +1 -0
  62. package/dist/errors.d.mts +16 -0
  63. package/dist/errors.d.mts.map +1 -0
  64. package/dist/errors.mjs +28 -0
  65. package/dist/errors.mjs.map +1 -0
  66. package/dist/index.cjs.map +1 -1
  67. package/dist/index.d.cts +2 -1
  68. package/dist/index.d.cts.map +1 -1
  69. package/dist/index.d.mts +2 -1
  70. package/dist/index.d.mts.map +1 -1
  71. package/dist/index.mjs.map +1 -1
  72. package/dist/logger.cjs +14 -1
  73. package/dist/logger.cjs.map +1 -1
  74. package/dist/logger.d.cts +8 -0
  75. package/dist/logger.d.cts.map +1 -1
  76. package/dist/logger.d.mts +8 -0
  77. package/dist/logger.d.mts.map +1 -1
  78. package/dist/logger.mjs +12 -0
  79. package/dist/logger.mjs.map +1 -1
  80. package/dist/providers/AccountProviderWrapper.cjs +5 -6
  81. package/dist/providers/AccountProviderWrapper.cjs.map +1 -1
  82. package/dist/providers/AccountProviderWrapper.d.cts +5 -4
  83. package/dist/providers/AccountProviderWrapper.d.cts.map +1 -1
  84. package/dist/providers/AccountProviderWrapper.d.mts +5 -4
  85. package/dist/providers/AccountProviderWrapper.d.mts.map +1 -1
  86. package/dist/providers/AccountProviderWrapper.mjs +5 -6
  87. package/dist/providers/AccountProviderWrapper.mjs.map +1 -1
  88. package/dist/providers/BaseBip44AccountProvider.cjs +0 -10
  89. package/dist/providers/BaseBip44AccountProvider.cjs.map +1 -1
  90. package/dist/providers/BaseBip44AccountProvider.d.cts +1 -17
  91. package/dist/providers/BaseBip44AccountProvider.d.cts.map +1 -1
  92. package/dist/providers/BaseBip44AccountProvider.d.mts +1 -17
  93. package/dist/providers/BaseBip44AccountProvider.d.mts.map +1 -1
  94. package/dist/providers/BaseBip44AccountProvider.mjs +0 -10
  95. package/dist/providers/BaseBip44AccountProvider.mjs.map +1 -1
  96. package/dist/providers/BtcAccountProvider.cjs +15 -33
  97. package/dist/providers/BtcAccountProvider.cjs.map +1 -1
  98. package/dist/providers/BtcAccountProvider.d.cts +6 -4
  99. package/dist/providers/BtcAccountProvider.d.cts.map +1 -1
  100. package/dist/providers/BtcAccountProvider.d.mts +6 -4
  101. package/dist/providers/BtcAccountProvider.d.mts.map +1 -1
  102. package/dist/providers/BtcAccountProvider.mjs +16 -34
  103. package/dist/providers/BtcAccountProvider.mjs.map +1 -1
  104. package/dist/providers/EvmAccountProvider.cjs +44 -3
  105. package/dist/providers/EvmAccountProvider.cjs.map +1 -1
  106. package/dist/providers/EvmAccountProvider.d.cts.map +1 -1
  107. package/dist/providers/EvmAccountProvider.d.mts.map +1 -1
  108. package/dist/providers/EvmAccountProvider.mjs +44 -3
  109. package/dist/providers/EvmAccountProvider.mjs.map +1 -1
  110. package/dist/providers/SnapAccountProvider.cjs +111 -21
  111. package/dist/providers/SnapAccountProvider.cjs.map +1 -1
  112. package/dist/providers/SnapAccountProvider.d.cts +33 -2
  113. package/dist/providers/SnapAccountProvider.d.cts.map +1 -1
  114. package/dist/providers/SnapAccountProvider.d.mts +33 -2
  115. package/dist/providers/SnapAccountProvider.d.mts.map +1 -1
  116. package/dist/providers/SnapAccountProvider.mjs +113 -23
  117. package/dist/providers/SnapAccountProvider.mjs.map +1 -1
  118. package/dist/providers/SolAccountProvider.cjs +31 -39
  119. package/dist/providers/SolAccountProvider.cjs.map +1 -1
  120. package/dist/providers/SolAccountProvider.d.cts +10 -3
  121. package/dist/providers/SolAccountProvider.d.cts.map +1 -1
  122. package/dist/providers/SolAccountProvider.d.mts +10 -3
  123. package/dist/providers/SolAccountProvider.d.mts.map +1 -1
  124. package/dist/providers/SolAccountProvider.mjs +32 -40
  125. package/dist/providers/SolAccountProvider.mjs.map +1 -1
  126. package/dist/providers/TrxAccountProvider.cjs +15 -37
  127. package/dist/providers/TrxAccountProvider.cjs.map +1 -1
  128. package/dist/providers/TrxAccountProvider.d.cts +6 -4
  129. package/dist/providers/TrxAccountProvider.d.cts.map +1 -1
  130. package/dist/providers/TrxAccountProvider.d.mts +6 -4
  131. package/dist/providers/TrxAccountProvider.d.mts.map +1 -1
  132. package/dist/providers/TrxAccountProvider.mjs +16 -38
  133. package/dist/providers/TrxAccountProvider.mjs.map +1 -1
  134. package/dist/providers/index.cjs +2 -1
  135. package/dist/providers/index.cjs.map +1 -1
  136. package/dist/providers/index.d.cts +1 -1
  137. package/dist/providers/index.d.cts.map +1 -1
  138. package/dist/providers/index.d.mts +1 -1
  139. package/dist/providers/index.d.mts.map +1 -1
  140. package/dist/providers/index.mjs +1 -1
  141. package/dist/providers/index.mjs.map +1 -1
  142. package/dist/providers/utils.cjs +15 -5
  143. package/dist/providers/utils.cjs.map +1 -1
  144. package/dist/providers/utils.d.cts +9 -2
  145. package/dist/providers/utils.d.cts.map +1 -1
  146. package/dist/providers/utils.d.mts +9 -2
  147. package/dist/providers/utils.d.mts.map +1 -1
  148. package/dist/providers/utils.mjs +13 -4
  149. package/dist/providers/utils.mjs.map +1 -1
  150. package/dist/snaps/SnapPlatformWatcher.cjs +72 -8
  151. package/dist/snaps/SnapPlatformWatcher.cjs.map +1 -1
  152. package/dist/snaps/SnapPlatformWatcher.d.cts +15 -1
  153. package/dist/snaps/SnapPlatformWatcher.d.cts.map +1 -1
  154. package/dist/snaps/SnapPlatformWatcher.d.mts +15 -1
  155. package/dist/snaps/SnapPlatformWatcher.d.mts.map +1 -1
  156. package/dist/snaps/SnapPlatformWatcher.mjs +72 -8
  157. package/dist/snaps/SnapPlatformWatcher.mjs.map +1 -1
  158. package/dist/tests/accounts.cjs +7 -1
  159. package/dist/tests/accounts.cjs.map +1 -1
  160. package/dist/tests/accounts.d.cts +9 -0
  161. package/dist/tests/accounts.d.cts.map +1 -1
  162. package/dist/tests/accounts.d.mts +9 -0
  163. package/dist/tests/accounts.d.mts.map +1 -1
  164. package/dist/tests/accounts.mjs +6 -0
  165. package/dist/tests/accounts.mjs.map +1 -1
  166. package/dist/tests/index.cjs.map +1 -1
  167. package/dist/tests/index.d.cts +1 -0
  168. package/dist/tests/index.d.cts.map +1 -1
  169. package/dist/tests/index.d.mts +1 -0
  170. package/dist/tests/index.d.mts.map +1 -1
  171. package/dist/tests/index.mjs.map +1 -1
  172. package/dist/tests/providers.cjs +14 -16
  173. package/dist/tests/providers.cjs.map +1 -1
  174. package/dist/tests/providers.d.cts +11 -0
  175. package/dist/tests/providers.d.cts.map +1 -1
  176. package/dist/tests/providers.d.mts +11 -0
  177. package/dist/tests/providers.d.mts.map +1 -1
  178. package/dist/tests/providers.mjs +14 -17
  179. package/dist/tests/providers.mjs.map +1 -1
  180. package/dist/tests/types.cjs +3 -0
  181. package/dist/tests/types.cjs.map +1 -0
  182. package/dist/tests/types.d.cts +7 -0
  183. package/dist/tests/types.d.cts.map +1 -0
  184. package/dist/tests/types.d.mts +7 -0
  185. package/dist/tests/types.d.mts.map +1 -0
  186. package/dist/tests/types.mjs +2 -0
  187. package/dist/tests/types.mjs.map +1 -0
  188. package/dist/types.cjs.map +1 -1
  189. package/dist/types.d.cts +13 -54
  190. package/dist/types.d.cts.map +1 -1
  191. package/dist/types.d.mts +13 -54
  192. package/dist/types.d.mts.map +1 -1
  193. package/dist/types.mjs.map +1 -1
  194. package/dist/utils.cjs +49 -5
  195. package/dist/utils.cjs.map +1 -1
  196. package/dist/utils.d.cts +32 -5
  197. package/dist/utils.d.cts.map +1 -1
  198. package/dist/utils.d.mts +32 -5
  199. package/dist/utils.d.mts.map +1 -1
  200. package/dist/utils.mjs +45 -4
  201. package/dist/utils.mjs.map +1 -1
  202. package/package.json +9 -7
  203. package/dist/constants/traces.cjs +0 -9
  204. package/dist/constants/traces.cjs.map +0 -1
  205. package/dist/constants/traces.d.cts +0 -5
  206. package/dist/constants/traces.d.cts.map +0 -1
  207. package/dist/constants/traces.d.mts +0 -5
  208. package/dist/constants/traces.d.mts.map +0 -1
  209. package/dist/constants/traces.mjs +0 -6
  210. package/dist/constants/traces.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"providers.cjs","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":";;;AACA,uDAM+B;AAQ/B,sDAIsB;AAqBtB,SAAgB,uBAAuB,CACrC,WAA6B,EAAE;IAE/B,OAAO;QACL,YAAY,EAAE,QAAQ;QACtB,QAAQ,EAAE,IAAI,GAAG,EAAE;QACnB,YAAY,EAAE;YACZ,MAAM,EAAE;gBACN,sBAAQ,CAAC,MAAM;gBACf,sBAAQ,CAAC,OAAO;gBAChB,sBAAQ,CAAC,OAAO;gBAChB,sBAAQ,CAAC,MAAM;gBACf,sBAAQ,CAAC,GAAG;aACb;YACD,KAAK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C,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 {\n AccountCreationType,\n BtcScope,\n EthScope,\n SolScope,\n TrxScope,\n} from '@metamask/keyring-api';\nimport type {\n CreateAccountOptions,\n EntropySourceId,\n KeyringAccount,\n KeyringCapabilities,\n} 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 capabilities: KeyringCapabilities;\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 capabilities: {\n scopes: [\n SolScope.Devnet,\n SolScope.Testnet,\n BtcScope.Testnet,\n TrxScope.Shasta,\n EthScope.Eoa,\n ],\n bip44: { deriveIndex: true },\n },\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 = (): KeyringAccount[] =>\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 type: AccountCreationType.Bip44DeriveIndex,\n entropySource,\n groupIndex,\n });\n\n const baseAlign = (\n BaseBip44AccountProvider.prototype as unknown as {\n alignAccounts: (\n this: {\n createAccounts: (\n options: CreateAccountOptions,\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
+ {"version":3,"file":"providers.cjs","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":";;;AACA,uDAA+E;AAM/E,sDAA0E;AAsB1E,SAAgB,uBAAuB,CACrC,WAA6B,EAAE;IAE/B,OAAO;QACL,YAAY,EAAE,QAAQ;QACtB,QAAQ,EAAE,IAAI,GAAG,EAAE;QACnB,YAAY,EAAE;YACZ,MAAM,EAAE;gBACN,sBAAQ,CAAC,MAAM;gBACf,sBAAQ,CAAC,OAAO;gBAChB,sBAAQ,CAAC,OAAO;gBAChB,sBAAQ,CAAC,MAAM;gBACf,sBAAQ,CAAC,GAAG;aACb;YACD,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE;SAC7B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AAK,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;AAED;;;;;;;;GAQG;AACH,SAAgB,sBAAsB,CAAC,EACrC,IAAI,GAAG,CAAC,EACR,EAAE,GACc;IAChB,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,IAAI,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;AACnE,CAAC;AALD,wDAKC","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport { BtcScope, EthScope, SolScope, TrxScope } from '@metamask/keyring-api';\nimport type {\n KeyringAccount,\n KeyringCapabilities,\n} from '@metamask/keyring-api';\n\nimport { AccountProviderWrapper, EvmAccountProvider } from '../providers';\nimport { GroupIndexRange } from '../utils';\n\nexport type MockAccountProvider = {\n mockAccounts: KeyringAccount[];\n accounts: Set<KeyringAccount['id']>;\n capabilities: KeyringCapabilities;\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 capabilities: {\n scopes: [\n SolScope.Devnet,\n SolScope.Testnet,\n BtcScope.Testnet,\n TrxScope.Shasta,\n EthScope.Eoa,\n ],\n bip44: { deriveIndex: true },\n },\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 = (): KeyringAccount[] =>\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.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\n/**\n * Helper to convert a group index range to an array of group indices, inclusive of the\n * start and end indices.\n *\n * @param range - The range.\n * @param range.from - The starting index of the range (inclusive).\n * @param range.to - The ending index of the range (inclusive).\n * @returns An array of group indices from `from` to `to`, inclusive.\n */\nexport function toGroupIndexRangeArray({\n from = 0,\n to,\n}: GroupIndexRange): number[] {\n return Array.from({ length: to - from + 1 }, (_, i) => from + i);\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  /// <reference types="jest" />
2
2
  import type { KeyringAccount, KeyringCapabilities } from "@metamask/keyring-api";
3
+ import { GroupIndexRange } from "../utils.cjs";
3
4
  export type MockAccountProvider = {
4
5
  mockAccounts: KeyringAccount[];
5
6
  accounts: Set<KeyringAccount['id']>;
@@ -34,4 +35,14 @@ export declare function setupBip44AccountProvider({ name, accounts, mocks, index
34
35
  * @param created - The accounts to be returned and persisted in the mock state.
35
36
  */
36
37
  export declare function mockCreateAccountsOnce(provider: MockAccountProvider, created: KeyringAccount[]): void;
38
+ /**
39
+ * Helper to convert a group index range to an array of group indices, inclusive of the
40
+ * start and end indices.
41
+ *
42
+ * @param range - The range.
43
+ * @param range.from - The starting index of the range (inclusive).
44
+ * @param range.to - The ending index of the range (inclusive).
45
+ * @returns An array of group indices from `from` to `to`, inclusive.
46
+ */
47
+ export declare function toGroupIndexRangeArray({ from, to, }: GroupIndexRange): number[];
37
48
  //# sourceMappingURL=providers.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"providers.d.cts","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":";AAQA,OAAO,KAAK,EAGV,cAAc,EACd,mBAAmB,EACpB,8BAA8B;AAQ/B,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,QAAQ,EAAE,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;IACpC,YAAY,EAAE,mBAAmB,CAAC;IAClC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC;IACvB,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC;IACzB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC;IAChB,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,EAAE,IAAI,CAAC,IAAI,CAAC;IAC/B,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC;IACtB,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC;CACvB,CAAC;AAEF,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,CAAC,IAAI,CAAC;IAC/B,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,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,CA4BrB;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,CA0CtB;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,EAAE,cAAc,EAAE,GACxB,IAAI,CAgBN;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,IAAQ,EACR,EAAE,GACH,EAAE,eAAe,GAAG,MAAM,EAAE,CAE5B"}
@@ -1,5 +1,6 @@
1
1
  /// <reference types="jest" />
2
2
  import type { KeyringAccount, KeyringCapabilities } from "@metamask/keyring-api";
3
+ import { GroupIndexRange } from "../utils.mjs";
3
4
  export type MockAccountProvider = {
4
5
  mockAccounts: KeyringAccount[];
5
6
  accounts: Set<KeyringAccount['id']>;
@@ -34,4 +35,14 @@ export declare function setupBip44AccountProvider({ name, accounts, mocks, index
34
35
  * @param created - The accounts to be returned and persisted in the mock state.
35
36
  */
36
37
  export declare function mockCreateAccountsOnce(provider: MockAccountProvider, created: KeyringAccount[]): void;
38
+ /**
39
+ * Helper to convert a group index range to an array of group indices, inclusive of the
40
+ * start and end indices.
41
+ *
42
+ * @param range - The range.
43
+ * @param range.from - The starting index of the range (inclusive).
44
+ * @param range.to - The ending index of the range (inclusive).
45
+ * @returns An array of group indices from `from` to `to`, inclusive.
46
+ */
47
+ export declare function toGroupIndexRangeArray({ from, to, }: GroupIndexRange): number[];
37
48
  //# sourceMappingURL=providers.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"providers.d.mts","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":";AAQA,OAAO,KAAK,EAGV,cAAc,EACd,mBAAmB,EACpB,8BAA8B;AAQ/B,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,QAAQ,EAAE,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;IACpC,YAAY,EAAE,mBAAmB,CAAC;IAClC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC;IACvB,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC;IACzB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC;IAChB,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,EAAE,IAAI,CAAC,IAAI,CAAC;IAC/B,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,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,CA4BrB;AAED,wBAAgB,yBAAyB,CAAC,EACxC,IAAwB,EACxB,QAAQ,EACR,KAA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IACtB,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC;CACvB,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,QAAQ,GAAE,cAAc,EAAO,GAC9B,mBAAmB,CA4BrB;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,CA0CtB;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,EAAE,cAAc,EAAE,GACxB,IAAI,CAgBN;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,IAAQ,EACR,EAAE,GACH,EAAE,eAAe,GAAG,MAAM,EAAE,CAE5B"}
@@ -1,5 +1,5 @@
1
- import { AccountCreationType, BtcScope, EthScope, SolScope, TrxScope } from "@metamask/keyring-api";
2
- import { AccountProviderWrapper, EvmAccountProvider, BaseBip44AccountProvider } from "../providers/index.mjs";
1
+ import { BtcScope, EthScope, SolScope, TrxScope } from "@metamask/keyring-api";
2
+ import { AccountProviderWrapper, EvmAccountProvider } from "../providers/index.mjs";
3
3
  export function makeMockAccountProvider(accounts = []) {
4
4
  return {
5
5
  mockAccounts: accounts,
@@ -46,21 +46,6 @@ export function setupBip44AccountProvider({ name = 'Mocked Provider', accounts,
46
46
  // Assuming this never fails.
47
47
  getAccounts().find((account) => account.id === id));
48
48
  mocks.createAccounts.mockResolvedValue([]);
49
- mocks.alignAccounts.mockImplementation(async ({ entropySource, groupIndex, }) => {
50
- if (mocks.isDisabled()) {
51
- const wrapperAlign = AccountProviderWrapper.prototype.alignAccounts;
52
- const ids = await wrapperAlign.call({ isEnabled: false, isDisabled: () => true }, { entropySource, groupIndex });
53
- return ids;
54
- }
55
- const createdAccounts = await mocks.createAccounts({
56
- type: AccountCreationType.Bip44DeriveIndex,
57
- entropySource,
58
- groupIndex,
59
- });
60
- const baseAlign = BaseBip44AccountProvider.prototype.alignAccounts;
61
- const ids = await baseAlign.call({ createAccounts: async () => createdAccounts }, { entropySource, groupIndex });
62
- return ids;
63
- });
64
49
  mocks.init.mockImplementation((accountIds) => {
65
50
  accountIds.forEach((id) => mocks.accounts.add(id));
66
51
  });
@@ -97,4 +82,16 @@ export function mockCreateAccountsOnce(provider, created) {
97
82
  return created;
98
83
  });
99
84
  }
85
+ /**
86
+ * Helper to convert a group index range to an array of group indices, inclusive of the
87
+ * start and end indices.
88
+ *
89
+ * @param range - The range.
90
+ * @param range.from - The starting index of the range (inclusive).
91
+ * @param range.to - The ending index of the range (inclusive).
92
+ * @returns An array of group indices from `from` to `to`, inclusive.
93
+ */
94
+ export function toGroupIndexRangeArray({ from = 0, to, }) {
95
+ return Array.from({ length: to - from + 1 }, (_, i) => from + i);
96
+ }
100
97
  //# sourceMappingURL=providers.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"providers.mjs","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACT,8BAA8B;AAQ/B,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACzB,+BAAqB;AAqBtB,MAAM,UAAU,uBAAuB,CACrC,WAA6B,EAAE;IAE/B,OAAO;QACL,YAAY,EAAE,QAAQ;QACtB,QAAQ,EAAE,IAAI,GAAG,EAAE;QACnB,YAAY,EAAE;YACZ,MAAM,EAAE;gBACN,QAAQ,CAAC,MAAM;gBACf,QAAQ,CAAC,OAAO;gBAChB,QAAQ,CAAC,OAAO;gBAChB,QAA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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 {\n AccountCreationType,\n BtcScope,\n EthScope,\n SolScope,\n TrxScope,\n} from '@metamask/keyring-api';\nimport type {\n CreateAccountOptions,\n EntropySourceId,\n KeyringAccount,\n KeyringCapabilities,\n} 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 capabilities: KeyringCapabilities;\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 capabilities: {\n scopes: [\n SolScope.Devnet,\n SolScope.Testnet,\n BtcScope.Testnet,\n TrxScope.Shasta,\n EthScope.Eoa,\n ],\n bip44: { deriveIndex: true },\n },\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 = (): KeyringAccount[] =>\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 type: AccountCreationType.Bip44DeriveIndex,\n entropySource,\n groupIndex,\n });\n\n const baseAlign = (\n BaseBip44AccountProvider.prototype as unknown as {\n alignAccounts: (\n this: {\n createAccounts: (\n options: CreateAccountOptions,\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
+ {"version":3,"file":"providers.mjs","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,8BAA8B;AAM/E,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,+BAAqB;AAsB1E,MAAM,UAAU,uBAAuB,CACrC,WAA6B,EAAE;IAE/B,OAAO;QACL,YAAY,EAAE,QAAQ;QACtB,QAAQ,EAAE,IAAI,GAAG,EAAE;QACnB,YAAY,EAAE;YACZ,MAAM,EAAE;gBACN,QAAQ,CAAC,MAAM;gBACf,QAAQ,CAAC,OAAO;gBAChB,QAAQ,C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C7B,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;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CAAC,EACrC,IAAI,GAAG,CAAC,EACR,EAAE,GACc;IAChB,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,IAAI,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport { BtcScope, EthScope, SolScope, TrxScope } from '@metamask/keyring-api';\nimport type {\n KeyringAccount,\n KeyringCapabilities,\n} from '@metamask/keyring-api';\n\nimport { AccountProviderWrapper, EvmAccountProvider } from '../providers';\nimport { GroupIndexRange } from '../utils';\n\nexport type MockAccountProvider = {\n mockAccounts: KeyringAccount[];\n accounts: Set<KeyringAccount['id']>;\n capabilities: KeyringCapabilities;\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 capabilities: {\n scopes: [\n SolScope.Devnet,\n SolScope.Testnet,\n BtcScope.Testnet,\n TrxScope.Shasta,\n EthScope.Eoa,\n ],\n bip44: { deriveIndex: true },\n },\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 = (): KeyringAccount[] =>\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.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\n/**\n * Helper to convert a group index range to an array of group indices, inclusive of the\n * start and end indices.\n *\n * @param range - The range.\n * @param range.from - The starting index of the range (inclusive).\n * @param range.to - The ending index of the range (inclusive).\n * @returns An array of group indices from `from` to `to`, inclusive.\n */\nexport function toGroupIndexRangeArray({\n from = 0,\n to,\n}: GroupIndexRange): number[] {\n return Array.from({ length: to - from + 1 }, (_, i) => from + i);\n}\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/tests/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * A utility type that makes all properties of a type optional, recursively.\n */\nexport type DeepPartial<Type> = Type extends string\n ? Type\n : {\n [Property in keyof Type]?: Type[Property] extends (infer Value)[]\n ? DeepPartial<Value>[]\n : Type[Property] extends readonly (infer Value)[]\n ? readonly DeepPartial<Value>[]\n : Type[Property] extends object\n ? DeepPartial<Type[Property]>\n : Type[Property];\n };\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A utility type that makes all properties of a type optional, recursively.
3
+ */
4
+ export type DeepPartial<Type> = Type extends string ? Type : {
5
+ [Property in keyof Type]?: Type[Property] extends (infer Value)[] ? DeepPartial<Value>[] : Type[Property] extends readonly (infer Value)[] ? readonly DeepPartial<Value>[] : Type[Property] extends object ? DeepPartial<Type[Property]> : Type[Property];
6
+ };
7
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/tests/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,IAAI,IAAI,IAAI,SAAS,MAAM,GAC/C,IAAI,GACJ;KACG,QAAQ,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,GAC7D,WAAW,CAAC,KAAK,CAAC,EAAE,GACpB,IAAI,CAAC,QAAQ,CAAC,SAAS,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,GAC7C,SAAS,WAAW,CAAC,KAAK,CAAC,EAAE,GAC7B,IAAI,CAAC,QAAQ,CAAC,SAAS,MAAM,GAC3B,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAC3B,IAAI,CAAC,QAAQ,CAAC;CACvB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A utility type that makes all properties of a type optional, recursively.
3
+ */
4
+ export type DeepPartial<Type> = Type extends string ? Type : {
5
+ [Property in keyof Type]?: Type[Property] extends (infer Value)[] ? DeepPartial<Value>[] : Type[Property] extends readonly (infer Value)[] ? readonly DeepPartial<Value>[] : Type[Property] extends object ? DeepPartial<Type[Property]> : Type[Property];
6
+ };
7
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../src/tests/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,IAAI,IAAI,IAAI,SAAS,MAAM,GAC/C,IAAI,GACJ;KACG,QAAQ,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,GAC7D,WAAW,CAAC,KAAK,CAAC,EAAE,GACpB,IAAI,CAAC,QAAQ,CAAC,SAAS,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,GAC7C,SAAS,WAAW,CAAC,KAAK,CAAC,EAAE,GAC7B,IAAI,CAAC,QAAQ,CAAC,SAAS,MAAM,GAC3B,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAC3B,IAAI,CAAC,QAAQ,CAAC;CACvB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/tests/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * A utility type that makes all properties of a type optional, recursively.\n */\nexport type DeepPartial<Type> = Type extends string\n ? Type\n : {\n [Property in keyof Type]?: Type[Property] extends (infer Value)[]\n ? DeepPartial<Value>[]\n : Type[Property] extends readonly (infer Value)[]\n ? readonly DeepPartial<Value>[]\n : Type[Property] extends object\n ? DeepPartial<Type[Property]>\n : Type[Property];\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 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"]}
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 { serviceName } from './MultichainAccountService';\nimport type { MultichainAccountServiceMethodActions } from './MultichainAccountService-method-action-types';\n\n/**\n * All actions that {@link MultichainAccountService} registers so that other\n * modules can call them.\n */\nexport type MultichainAccountServiceActions =\n MultichainAccountServiceMethodActions;\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\n/**\n * Config for the Snap platform watcher (SnapPlatformWatcher).\n */\nexport type SnapPlatformWatcherConfig = {\n /**\n * How long to wait for the Snap keyring to appear before rejecting (ms).\n */\n timeoutMs?: number;\n};\n\nexport type MultichainAccountServiceConfig = {\n trace?: TraceCallback;\n snapPlatformWatcher?: SnapPlatformWatcherConfig;\n};\n"]}
package/dist/types.d.cts CHANGED
@@ -6,64 +6,13 @@ import type { KeyringControllerAddNewKeyringAction, KeyringControllerCreateNewVa
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";
9
- import type { MultichainAccountService, serviceName } from "./MultichainAccountService.cjs";
10
- export type MultichainAccountServiceGetMultichainAccountGroupAction = {
11
- type: `${typeof serviceName}:getMultichainAccountGroup`;
12
- handler: MultichainAccountService['getMultichainAccountGroup'];
13
- };
14
- export type MultichainAccountServiceGetMultichainAccountGroupsAction = {
15
- type: `${typeof serviceName}:getMultichainAccountGroups`;
16
- handler: MultichainAccountService['getMultichainAccountGroups'];
17
- };
18
- export type MultichainAccountServiceGetMultichainAccountWalletAction = {
19
- type: `${typeof serviceName}:getMultichainAccountWallet`;
20
- handler: MultichainAccountService['getMultichainAccountWallet'];
21
- };
22
- export type MultichainAccountServiceGetMultichainAccountWalletsAction = {
23
- type: `${typeof serviceName}:getMultichainAccountWallets`;
24
- handler: MultichainAccountService['getMultichainAccountWallets'];
25
- };
26
- export type MultichainAccountServiceCreateNextMultichainAccountGroupAction = {
27
- type: `${typeof serviceName}:createNextMultichainAccountGroup`;
28
- handler: MultichainAccountService['createNextMultichainAccountGroup'];
29
- };
30
- export type MultichainAccountServiceCreateMultichainAccountGroupAction = {
31
- type: `${typeof serviceName}:createMultichainAccountGroup`;
32
- handler: MultichainAccountService['createMultichainAccountGroup'];
33
- };
34
- export type MultichainAccountServiceSetBasicFunctionalityAction = {
35
- type: `${typeof serviceName}:setBasicFunctionality`;
36
- handler: MultichainAccountService['setBasicFunctionality'];
37
- };
38
- export type MultichainAccountServiceAlignWalletAction = {
39
- type: `${typeof serviceName}:alignWallet`;
40
- handler: MultichainAccountService['alignWallet'];
41
- };
42
- export type MultichainAccountServiceAlignWalletsAction = {
43
- type: `${typeof serviceName}:alignWallets`;
44
- handler: MultichainAccountService['alignWallets'];
45
- };
46
- export type MultichainAccountServiceCreateMultichainAccountWalletAction = {
47
- type: `${typeof serviceName}:createMultichainAccountWallet`;
48
- handler: MultichainAccountService['createMultichainAccountWallet'];
49
- };
50
- export type MultichainAccountServiceResyncAccountsAction = {
51
- type: `${typeof serviceName}:resyncAccounts`;
52
- handler: MultichainAccountService['resyncAccounts'];
53
- };
54
- export type MultichainAccountServiceRemoveMultichainAccountWalletAction = {
55
- type: `${typeof serviceName}:removeMultichainAccountWallet`;
56
- handler: MultichainAccountService['removeMultichainAccountWallet'];
57
- };
58
- export type MultichainAccountServiceEnsureCanUseSnapPlatformAction = {
59
- type: `${typeof serviceName}:ensureCanUseSnapPlatform`;
60
- handler: MultichainAccountService['ensureCanUseSnapPlatform'];
61
- };
9
+ import type { serviceName } from "./MultichainAccountService.cjs";
10
+ import type { MultichainAccountServiceMethodActions } from "./MultichainAccountService-method-action-types.cjs";
62
11
  /**
63
12
  * All actions that {@link MultichainAccountService} registers so that other
64
13
  * modules can call them.
65
14
  */
66
- export type MultichainAccountServiceActions = MultichainAccountServiceGetMultichainAccountGroupAction | MultichainAccountServiceGetMultichainAccountGroupsAction | MultichainAccountServiceGetMultichainAccountWalletAction | MultichainAccountServiceGetMultichainAccountWalletsAction | MultichainAccountServiceCreateNextMultichainAccountGroupAction | MultichainAccountServiceCreateMultichainAccountGroupAction | MultichainAccountServiceSetBasicFunctionalityAction | MultichainAccountServiceAlignWalletAction | MultichainAccountServiceAlignWalletsAction | MultichainAccountServiceCreateMultichainAccountWalletAction | MultichainAccountServiceResyncAccountsAction | MultichainAccountServiceRemoveMultichainAccountWalletAction | MultichainAccountServiceEnsureCanUseSnapPlatformAction;
15
+ export type MultichainAccountServiceActions = MultichainAccountServiceMethodActions;
67
16
  export type MultichainAccountServiceMultichainAccountGroupCreatedEvent = {
68
17
  type: `${typeof serviceName}:multichainAccountGroupCreated`;
69
18
  payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];
@@ -96,8 +45,18 @@ type AllowedEvents = SnapControllerStateChangeEvent | KeyringControllerStateChan
96
45
  * {@link MultichainAccountService} needs to access.
97
46
  */
98
47
  export type MultichainAccountServiceMessenger = Messenger<'MultichainAccountService', MultichainAccountServiceActions | AllowedActions, MultichainAccountServiceEvents | AllowedEvents>;
48
+ /**
49
+ * Config for the Snap platform watcher (SnapPlatformWatcher).
50
+ */
51
+ export type SnapPlatformWatcherConfig = {
52
+ /**
53
+ * How long to wait for the Snap keyring to appear before rejecting (ms).
54
+ */
55
+ timeoutMs?: number;
56
+ };
99
57
  export type MultichainAccountServiceConfig = {
100
58
  trace?: TraceCallback;
59
+ snapPlatformWatcher?: SnapPlatformWatcherConfig;
101
60
  };
102
61
  export {};
103
62
  //# sourceMappingURL=types.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EACtB,yBAAyB,EACzB,6BAA6B,EAC9B,8BAA8B;AAC/B,OAAO,KAAK,EACV,mCAAmC,EACnC,qCAAqC,EACrC,kCAAkC,EAClC,2CAA2C,EAC3C,mCAAmC,EACnC,8CAA8C,EAC/C,sCAAsC;AACvC,OAAO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;IACvE,IAAI,EAAE,GAAG,OAAO,WAAW,gCAAgC,CAAC;IAC5D,OAAO,EAAE,CAAC,sBAAsB,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;CACjE,CAAC;AAEF,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,GAAG,OAAO,WAAW,qBAAqB,CAAC;IACjD,OAAO,EAAE,CAAC,yBAAyB,EAAE,6BAA6B,CAAC,CAAC;CACrE,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,8BAA8B,GACtC,0DAA0D,GAC1D,0DAA0D,GAC1D,+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;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,mBAAmB,CAAC,EAAE,yBAAyB,CAAC;CACjD,CAAC"}
package/dist/types.d.mts CHANGED
@@ -6,64 +6,13 @@ import type { KeyringControllerAddNewKeyringAction, KeyringControllerCreateNewVa
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";
9
- import type { MultichainAccountService, serviceName } from "./MultichainAccountService.mjs";
10
- export type MultichainAccountServiceGetMultichainAccountGroupAction = {
11
- type: `${typeof serviceName}:getMultichainAccountGroup`;
12
- handler: MultichainAccountService['getMultichainAccountGroup'];
13
- };
14
- export type MultichainAccountServiceGetMultichainAccountGroupsAction = {
15
- type: `${typeof serviceName}:getMultichainAccountGroups`;
16
- handler: MultichainAccountService['getMultichainAccountGroups'];
17
- };
18
- export type MultichainAccountServiceGetMultichainAccountWalletAction = {
19
- type: `${typeof serviceName}:getMultichainAccountWallet`;
20
- handler: MultichainAccountService['getMultichainAccountWallet'];
21
- };
22
- export type MultichainAccountServiceGetMultichainAccountWalletsAction = {
23
- type: `${typeof serviceName}:getMultichainAccountWallets`;
24
- handler: MultichainAccountService['getMultichainAccountWallets'];
25
- };
26
- export type MultichainAccountServiceCreateNextMultichainAccountGroupAction = {
27
- type: `${typeof serviceName}:createNextMultichainAccountGroup`;
28
- handler: MultichainAccountService['createNextMultichainAccountGroup'];
29
- };
30
- export type MultichainAccountServiceCreateMultichainAccountGroupAction = {
31
- type: `${typeof serviceName}:createMultichainAccountGroup`;
32
- handler: MultichainAccountService['createMultichainAccountGroup'];
33
- };
34
- export type MultichainAccountServiceSetBasicFunctionalityAction = {
35
- type: `${typeof serviceName}:setBasicFunctionality`;
36
- handler: MultichainAccountService['setBasicFunctionality'];
37
- };
38
- export type MultichainAccountServiceAlignWalletAction = {
39
- type: `${typeof serviceName}:alignWallet`;
40
- handler: MultichainAccountService['alignWallet'];
41
- };
42
- export type MultichainAccountServiceAlignWalletsAction = {
43
- type: `${typeof serviceName}:alignWallets`;
44
- handler: MultichainAccountService['alignWallets'];
45
- };
46
- export type MultichainAccountServiceCreateMultichainAccountWalletAction = {
47
- type: `${typeof serviceName}:createMultichainAccountWallet`;
48
- handler: MultichainAccountService['createMultichainAccountWallet'];
49
- };
50
- export type MultichainAccountServiceResyncAccountsAction = {
51
- type: `${typeof serviceName}:resyncAccounts`;
52
- handler: MultichainAccountService['resyncAccounts'];
53
- };
54
- export type MultichainAccountServiceRemoveMultichainAccountWalletAction = {
55
- type: `${typeof serviceName}:removeMultichainAccountWallet`;
56
- handler: MultichainAccountService['removeMultichainAccountWallet'];
57
- };
58
- export type MultichainAccountServiceEnsureCanUseSnapPlatformAction = {
59
- type: `${typeof serviceName}:ensureCanUseSnapPlatform`;
60
- handler: MultichainAccountService['ensureCanUseSnapPlatform'];
61
- };
9
+ import type { serviceName } from "./MultichainAccountService.mjs";
10
+ import type { MultichainAccountServiceMethodActions } from "./MultichainAccountService-method-action-types.mjs";
62
11
  /**
63
12
  * All actions that {@link MultichainAccountService} registers so that other
64
13
  * modules can call them.
65
14
  */
66
- export type MultichainAccountServiceActions = MultichainAccountServiceGetMultichainAccountGroupAction | MultichainAccountServiceGetMultichainAccountGroupsAction | MultichainAccountServiceGetMultichainAccountWalletAction | MultichainAccountServiceGetMultichainAccountWalletsAction | MultichainAccountServiceCreateNextMultichainAccountGroupAction | MultichainAccountServiceCreateMultichainAccountGroupAction | MultichainAccountServiceSetBasicFunctionalityAction | MultichainAccountServiceAlignWalletAction | MultichainAccountServiceAlignWalletsAction | MultichainAccountServiceCreateMultichainAccountWalletAction | MultichainAccountServiceResyncAccountsAction | MultichainAccountServiceRemoveMultichainAccountWalletAction | MultichainAccountServiceEnsureCanUseSnapPlatformAction;
15
+ export type MultichainAccountServiceActions = MultichainAccountServiceMethodActions;
67
16
  export type MultichainAccountServiceMultichainAccountGroupCreatedEvent = {
68
17
  type: `${typeof serviceName}:multichainAccountGroupCreated`;
69
18
  payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];
@@ -96,8 +45,18 @@ type AllowedEvents = SnapControllerStateChangeEvent | KeyringControllerStateChan
96
45
  * {@link MultichainAccountService} needs to access.
97
46
  */
98
47
  export type MultichainAccountServiceMessenger = Messenger<'MultichainAccountService', MultichainAccountServiceActions | AllowedActions, MultichainAccountServiceEvents | AllowedEvents>;
48
+ /**
49
+ * Config for the Snap platform watcher (SnapPlatformWatcher).
50
+ */
51
+ export type SnapPlatformWatcherConfig = {
52
+ /**
53
+ * How long to wait for the Snap keyring to appear before rejecting (ms).
54
+ */
55
+ timeoutMs?: number;
56
+ };
99
57
  export type MultichainAccountServiceConfig = {
100
58
  trace?: TraceCallback;
59
+ snapPlatformWatcher?: SnapPlatformWatcherConfig;
101
60
  };
102
61
  export {};
103
62
  //# sourceMappingURL=types.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EACtB,yBAAyB,EACzB,6BAA6B,EAC9B,8BAA8B;AAC/B,OAAO,KAAK,EACV,mCAAmC,EACnC,qCAAqC,EACrC,kCAAkC,EAClC,2CAA2C,EAC3C,mCAAmC,EACnC,8CAA8C,EAC/C,sCAAsC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAC5D,OAAO,KAAK,EACV,oCAAoC,EACpC,gDAAgD,EAChD,+CAA+C,EAC/C,wCAAwC,EACxC,+BAA+B,EAC/B,oCAAoC,EACpC,iCAAiC,EACjC,kCAAkC,EACnC,qCAAqC;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EACV,mDAAmD,EACnD,2CAA2C,EAC5C,qCAAqC;AACtC,OAAO,KAAK,EACV,iBAAiB,IAAI,qCAAqC,EAC1D,4BAA4B,EAC5B,eAAe,IAAI,8BAA8B,EAClD,oCAAoC;AAErC,OAAO,KAAK,EACV,wBAAwB,EACxB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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;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,mBAAmB,CAAC,EAAE,yBAAyB,CAAC;CACjD,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 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"]}
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 { serviceName } from './MultichainAccountService';\nimport type { MultichainAccountServiceMethodActions } from './MultichainAccountService-method-action-types';\n\n/**\n * All actions that {@link MultichainAccountService} registers so that other\n * modules can call them.\n */\nexport type MultichainAccountServiceActions =\n MultichainAccountServiceMethodActions;\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\n/**\n * Config for the Snap platform watcher (SnapPlatformWatcher).\n */\nexport type SnapPlatformWatcherConfig = {\n /**\n * How long to wait for the Snap keyring to appear before rejecting (ms).\n */\n timeoutMs?: number;\n};\n\nexport type MultichainAccountServiceConfig = {\n trace?: TraceCallback;\n snapPlatformWatcher?: SnapPlatformWatcherConfig;\n};\n"]}
package/dist/utils.cjs CHANGED
@@ -1,22 +1,66 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSentryError = void 0;
3
+ exports.toErrorMessage = exports.createSentryError = exports.assertGroupIndexIsValid = exports.assertGroupIndexRangeIsValid = void 0;
4
+ /**
5
+ * Asserts that a range is valid.
6
+ *
7
+ * @param range - The range to assert.
8
+ * @param range.from - The starting index of the range (inclusive).
9
+ * @param range.to - The ending index of the range (inclusive).
10
+ */
11
+ function assertGroupIndexRangeIsValid({ from = 0, to, }) {
12
+ if (from < 0) {
13
+ throw new Error(`Bad range, from (${from}) must be >= 0`);
14
+ }
15
+ if (to < 0) {
16
+ throw new Error(`Bad range, to (${to}) must be >= 0`);
17
+ }
18
+ if (to < from) {
19
+ throw new Error(`Bad range, to (${to}) must be >= from (${from})`);
20
+ }
21
+ }
22
+ exports.assertGroupIndexRangeIsValid = assertGroupIndexRangeIsValid;
23
+ /**
24
+ * Asserts that a group index is valid given the next available group index.
25
+ *
26
+ * @param groupIndex - The group index to assert.
27
+ * @param nextGroupIndex - The next available group index.
28
+ */
29
+ function assertGroupIndexIsValid(groupIndex, nextGroupIndex) {
30
+ if (groupIndex > nextGroupIndex) {
31
+ throw new Error(`Bad group index, groupIndex (${groupIndex}) cannot be higher than the next available one (<= ${nextGroupIndex})`);
32
+ }
33
+ }
34
+ exports.assertGroupIndexIsValid = assertGroupIndexIsValid;
4
35
  /**
5
36
  * Creates a Sentry error from an error message, an inner error and a context.
6
37
  *
7
38
  * NOTE: Sentry defaults to a depth of 3 when extracting non-native attributes.
8
39
  * As such, the context depth shouldn't be too deep.
9
40
  *
10
- * @param msg - The error message to create a Sentry error from.
41
+ * @param message - The error message to create a Sentry error from.
11
42
  * @param innerError - The inner error to create a Sentry error from.
12
43
  * @param context - The context to add to the Sentry error.
13
44
  * @returns A Sentry error.
14
45
  */
15
- const createSentryError = (msg, innerError, context) => {
16
- const error = new Error(msg);
46
+ const createSentryError = (message, innerError, context) => {
47
+ const error = new Error(message);
17
48
  error.cause = innerError;
18
- error.context = context;
49
+ if (context) {
50
+ error.context = context;
51
+ }
19
52
  return error;
20
53
  };
21
54
  exports.createSentryError = createSentryError;
55
+ /**
56
+ * Converts an unknown error value to a string message.
57
+ *
58
+ * @param error - The error to convert.
59
+ * @returns The error message if the error is an `Error` instance, otherwise
60
+ * the string representation of the value.
61
+ */
62
+ function toErrorMessage(error) {
63
+ return error instanceof Error ? error.message : String(error);
64
+ }
65
+ exports.toErrorMessage = toErrorMessage;
22
66
  //# sourceMappingURL=utils.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACI,MAAM,iBAAiB,GAAG,CAC/B,GAAW,EACX,UAAiB,EACjB,OAAgC,EAChC,EAAE;IACF,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,CAG1B,CAAC;IACF,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC;IACzB,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAZW,QAAA,iBAAiB,qBAY5B","sourcesContent":["/**\n * Creates a Sentry error from an error message, an inner error and a context.\n *\n * NOTE: Sentry defaults to a depth of 3 when extracting non-native attributes.\n * As such, the context depth shouldn't be too deep.\n *\n * @param msg - The error message to create a Sentry error from.\n * @param innerError - The inner error to create a Sentry error from.\n * @param context - The context to add to the Sentry error.\n * @returns A Sentry error.\n */\nexport const createSentryError = (\n msg: string,\n innerError: Error,\n context: Record<string, unknown>,\n) => {\n const error = new Error(msg) as Error & {\n cause: Error;\n context: typeof context;\n };\n error.cause = innerError;\n error.context = context;\n return error;\n};\n"]}
1
+ {"version":3,"file":"utils.cjs","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAQA;;;;;;GAMG;AACH,SAAgB,4BAA4B,CAAC,EAC3C,IAAI,GAAG,CAAC,EACR,EAAE,GACc;IAChB,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAI,gBAAgB,CAAC,CAAC;IAC5D,CAAC;IAED,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,kBAAkB,EAAE,sBAAsB,IAAI,GAAG,CAAC,CAAC;IACrE,CAAC;AACH,CAAC;AAfD,oEAeC;AAED;;;;;GAKG;AACH,SAAgB,uBAAuB,CACrC,UAAkB,EAClB,cAAsB;IAEtB,IAAI,UAAU,GAAG,cAAc,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CACb,gCAAgC,UAAU,sDAAsD,cAAc,GAAG,CAClH,CAAC;IACJ,CAAC;AACH,CAAC;AATD,0DASC;AAED;;;;;;;;;;GAUG;AACI,MAAM,iBAAiB,GAAG,CAC/B,OAAe,EACf,UAAiB,EACjB,OAAiC,EAC1B,EAAE;IACT,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAG9B,CAAC;IACF,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC;IACzB,IAAI,OAAO,EAAE,CAAC;QACZ,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;IAC1B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAdW,QAAA,iBAAiB,qBAc5B;AAEF;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,KAAc;IAC3C,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AAFD,wCAEC","sourcesContent":["/**\n * Range-based multichain account creations type.\n */\nexport type GroupIndexRange = {\n from?: number;\n to: number;\n};\n\n/**\n * Asserts that a range is valid.\n *\n * @param range - The range to assert.\n * @param range.from - The starting index of the range (inclusive).\n * @param range.to - The ending index of the range (inclusive).\n */\nexport function assertGroupIndexRangeIsValid({\n from = 0,\n to,\n}: GroupIndexRange): void {\n if (from < 0) {\n throw new Error(`Bad range, from (${from}) must be >= 0`);\n }\n\n if (to < 0) {\n throw new Error(`Bad range, to (${to}) must be >= 0`);\n }\n\n if (to < from) {\n throw new Error(`Bad range, to (${to}) must be >= from (${from})`);\n }\n}\n\n/**\n * Asserts that a group index is valid given the next available group index.\n *\n * @param groupIndex - The group index to assert.\n * @param nextGroupIndex - The next available group index.\n */\nexport function assertGroupIndexIsValid(\n groupIndex: number,\n nextGroupIndex: number,\n): void {\n if (groupIndex > nextGroupIndex) {\n throw new Error(\n `Bad group index, groupIndex (${groupIndex}) cannot be higher than the next available one (<= ${nextGroupIndex})`,\n );\n }\n}\n\n/**\n * Creates a Sentry error from an error message, an inner error and a context.\n *\n * NOTE: Sentry defaults to a depth of 3 when extracting non-native attributes.\n * As such, the context depth shouldn't be too deep.\n *\n * @param message - The error message to create a Sentry error from.\n * @param innerError - The inner error to create a Sentry error from.\n * @param context - The context to add to the Sentry error.\n * @returns A Sentry error.\n */\nexport const createSentryError = (\n message: string,\n innerError: Error,\n context?: Record<string, unknown>,\n): Error => {\n const error = new Error(message) as Error & {\n cause: Error;\n context: typeof context;\n };\n error.cause = innerError;\n if (context) {\n error.context = context;\n }\n return error;\n};\n\n/**\n * Converts an unknown error value to a string message.\n *\n * @param error - The error to convert.\n * @returns The error message if the error is an `Error` instance, otherwise\n * the string representation of the value.\n */\nexport function toErrorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"]}