@metamask/snaps-controllers 18.0.4 → 19.0.1

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 (288) hide show
  1. package/CHANGELOG.md +108 -1
  2. package/dist/cronjob/CronjobController-method-action-types.cjs +7 -0
  3. package/dist/cronjob/CronjobController-method-action-types.cjs.map +1 -0
  4. package/dist/cronjob/CronjobController-method-action-types.d.cts +51 -0
  5. package/dist/cronjob/CronjobController-method-action-types.d.cts.map +1 -0
  6. package/dist/cronjob/CronjobController-method-action-types.d.mts +51 -0
  7. package/dist/cronjob/CronjobController-method-action-types.d.mts.map +1 -0
  8. package/dist/cronjob/CronjobController-method-action-types.mjs +6 -0
  9. package/dist/cronjob/CronjobController-method-action-types.mjs.map +1 -0
  10. package/dist/cronjob/CronjobController.cjs +7 -4
  11. package/dist/cronjob/CronjobController.cjs.map +1 -1
  12. package/dist/cronjob/CronjobController.d.cts +8 -25
  13. package/dist/cronjob/CronjobController.d.cts.map +1 -1
  14. package/dist/cronjob/CronjobController.d.mts +8 -25
  15. package/dist/cronjob/CronjobController.d.mts.map +1 -1
  16. package/dist/cronjob/CronjobController.mjs +7 -4
  17. package/dist/cronjob/CronjobController.mjs.map +1 -1
  18. package/dist/cronjob/index.cjs +3 -15
  19. package/dist/cronjob/index.cjs.map +1 -1
  20. package/dist/cronjob/index.d.cts +3 -1
  21. package/dist/cronjob/index.d.cts.map +1 -1
  22. package/dist/cronjob/index.d.mts +3 -1
  23. package/dist/cronjob/index.d.mts.map +1 -1
  24. package/dist/cronjob/index.mjs +1 -1
  25. package/dist/cronjob/index.mjs.map +1 -1
  26. package/dist/insights/SnapInsightsController.cjs +1 -3
  27. package/dist/insights/SnapInsightsController.cjs.map +1 -1
  28. package/dist/insights/SnapInsightsController.d.cts +9 -9
  29. package/dist/insights/SnapInsightsController.d.cts.map +1 -1
  30. package/dist/insights/SnapInsightsController.d.mts +9 -9
  31. package/dist/insights/SnapInsightsController.d.mts.map +1 -1
  32. package/dist/insights/SnapInsightsController.mjs +1 -3
  33. package/dist/insights/SnapInsightsController.mjs.map +1 -1
  34. package/dist/insights/index.cjs +3 -15
  35. package/dist/insights/index.cjs.map +1 -1
  36. package/dist/insights/index.d.cts +2 -1
  37. package/dist/insights/index.d.cts.map +1 -1
  38. package/dist/insights/index.d.mts +2 -1
  39. package/dist/insights/index.d.mts.map +1 -1
  40. package/dist/insights/index.mjs +1 -1
  41. package/dist/insights/index.mjs.map +1 -1
  42. package/dist/interface/SnapInterfaceController-method-action-types.cjs +7 -0
  43. package/dist/interface/SnapInterfaceController-method-action-types.cjs.map +1 -0
  44. package/dist/interface/SnapInterfaceController-method-action-types.d.cts +99 -0
  45. package/dist/interface/SnapInterfaceController-method-action-types.d.cts.map +1 -0
  46. package/dist/interface/SnapInterfaceController-method-action-types.d.mts +99 -0
  47. package/dist/interface/SnapInterfaceController-method-action-types.d.mts.map +1 -0
  48. package/dist/interface/SnapInterfaceController-method-action-types.mjs +6 -0
  49. package/dist/interface/SnapInterfaceController-method-action-types.mjs.map +1 -0
  50. package/dist/interface/SnapInterfaceController.cjs +12 -16
  51. package/dist/interface/SnapInterfaceController.cjs.map +1 -1
  52. package/dist/interface/SnapInterfaceController.d.cts +10 -40
  53. package/dist/interface/SnapInterfaceController.d.cts.map +1 -1
  54. package/dist/interface/SnapInterfaceController.d.mts +10 -40
  55. package/dist/interface/SnapInterfaceController.d.mts.map +1 -1
  56. package/dist/interface/SnapInterfaceController.mjs +12 -16
  57. package/dist/interface/SnapInterfaceController.mjs.map +1 -1
  58. package/dist/interface/index.cjs +3 -15
  59. package/dist/interface/index.cjs.map +1 -1
  60. package/dist/interface/index.d.cts +3 -1
  61. package/dist/interface/index.d.cts.map +1 -1
  62. package/dist/interface/index.d.mts +3 -1
  63. package/dist/interface/index.d.mts.map +1 -1
  64. package/dist/interface/index.mjs +1 -1
  65. package/dist/interface/index.mjs.map +1 -1
  66. package/dist/multichain/MultichainRoutingService-method-action-types.cjs +7 -0
  67. package/dist/multichain/MultichainRoutingService-method-action-types.cjs.map +1 -0
  68. package/dist/multichain/MultichainRoutingService-method-action-types.d.cts +61 -0
  69. package/dist/multichain/MultichainRoutingService-method-action-types.d.cts.map +1 -0
  70. package/dist/multichain/MultichainRoutingService-method-action-types.d.mts +61 -0
  71. package/dist/multichain/MultichainRoutingService-method-action-types.d.mts.map +1 -0
  72. package/dist/multichain/MultichainRoutingService-method-action-types.mjs +6 -0
  73. package/dist/multichain/MultichainRoutingService-method-action-types.mjs.map +1 -0
  74. package/dist/multichain/{MultichainRouter.cjs → MultichainRoutingService.cjs} +14 -13
  75. package/dist/multichain/MultichainRoutingService.cjs.map +1 -0
  76. package/dist/multichain/{MultichainRouter.d.mts → MultichainRoutingService.d.cts} +14 -29
  77. package/dist/multichain/MultichainRoutingService.d.cts.map +1 -0
  78. package/dist/multichain/{MultichainRouter.d.cts → MultichainRoutingService.d.mts} +14 -29
  79. package/dist/multichain/MultichainRoutingService.d.mts.map +1 -0
  80. package/dist/multichain/{MultichainRouter.mjs → MultichainRoutingService.mjs} +12 -11
  81. package/dist/multichain/MultichainRoutingService.mjs.map +1 -0
  82. package/dist/multichain/index.cjs +3 -15
  83. package/dist/multichain/index.cjs.map +1 -1
  84. package/dist/multichain/index.d.cts +3 -1
  85. package/dist/multichain/index.d.cts.map +1 -1
  86. package/dist/multichain/index.d.mts +3 -1
  87. package/dist/multichain/index.d.mts.map +1 -1
  88. package/dist/multichain/index.mjs +1 -1
  89. package/dist/multichain/index.mjs.map +1 -1
  90. package/dist/services/ExecutionService-method-action-types.cjs +7 -0
  91. package/dist/services/ExecutionService-method-action-types.cjs.map +1 -0
  92. package/dist/services/ExecutionService-method-action-types.d.cts +50 -0
  93. package/dist/services/ExecutionService-method-action-types.d.cts.map +1 -0
  94. package/dist/services/ExecutionService-method-action-types.d.mts +50 -0
  95. package/dist/services/ExecutionService-method-action-types.d.mts.map +1 -0
  96. package/dist/services/ExecutionService-method-action-types.mjs +6 -0
  97. package/dist/services/ExecutionService-method-action-types.mjs.map +1 -0
  98. package/dist/services/ExecutionService.cjs +287 -0
  99. package/dist/services/ExecutionService.cjs.map +1 -1
  100. package/dist/services/ExecutionService.d.cts +100 -46
  101. package/dist/services/ExecutionService.d.cts.map +1 -1
  102. package/dist/services/ExecutionService.d.mts +100 -46
  103. package/dist/services/ExecutionService.d.mts.map +1 -1
  104. package/dist/services/ExecutionService.mjs +285 -1
  105. package/dist/services/ExecutionService.mjs.map +1 -1
  106. package/dist/services/browser.cjs +5 -2
  107. package/dist/services/browser.cjs.map +1 -1
  108. package/dist/services/browser.d.cts +4 -2
  109. package/dist/services/browser.d.cts.map +1 -1
  110. package/dist/services/browser.d.mts +4 -2
  111. package/dist/services/browser.d.mts.map +1 -1
  112. package/dist/services/browser.mjs +2 -2
  113. package/dist/services/browser.mjs.map +1 -1
  114. package/dist/services/iframe/IframeExecutionService.cjs +2 -2
  115. package/dist/services/iframe/IframeExecutionService.cjs.map +1 -1
  116. package/dist/services/iframe/IframeExecutionService.d.cts +3 -3
  117. package/dist/services/iframe/IframeExecutionService.d.cts.map +1 -1
  118. package/dist/services/iframe/IframeExecutionService.d.mts +3 -3
  119. package/dist/services/iframe/IframeExecutionService.d.mts.map +1 -1
  120. package/dist/services/iframe/IframeExecutionService.mjs +2 -2
  121. package/dist/services/iframe/IframeExecutionService.mjs.map +1 -1
  122. package/dist/services/index.cjs +5 -1
  123. package/dist/services/index.cjs.map +1 -1
  124. package/dist/services/index.d.cts +4 -2
  125. package/dist/services/index.d.cts.map +1 -1
  126. package/dist/services/index.d.mts +4 -2
  127. package/dist/services/index.d.mts.map +1 -1
  128. package/dist/services/index.mjs +2 -1
  129. package/dist/services/index.mjs.map +1 -1
  130. package/dist/services/multiplex.cjs +27 -0
  131. package/dist/services/multiplex.cjs.map +1 -0
  132. package/dist/services/multiplex.d.cts +11 -0
  133. package/dist/services/multiplex.d.cts.map +1 -0
  134. package/dist/services/multiplex.d.mts +11 -0
  135. package/dist/services/multiplex.d.mts.map +1 -0
  136. package/dist/services/multiplex.mjs +27 -0
  137. package/dist/services/multiplex.mjs.map +1 -0
  138. package/dist/services/node-js/NodeProcessExecutionService.cjs +2 -2
  139. package/dist/services/node-js/NodeProcessExecutionService.cjs.map +1 -1
  140. package/dist/services/node-js/NodeProcessExecutionService.d.cts +3 -3
  141. package/dist/services/node-js/NodeProcessExecutionService.d.cts.map +1 -1
  142. package/dist/services/node-js/NodeProcessExecutionService.d.mts +3 -3
  143. package/dist/services/node-js/NodeProcessExecutionService.d.mts.map +1 -1
  144. package/dist/services/node-js/NodeProcessExecutionService.mjs +2 -2
  145. package/dist/services/node-js/NodeProcessExecutionService.mjs.map +1 -1
  146. package/dist/services/node-js/NodeThreadExecutionService.cjs +2 -5
  147. package/dist/services/node-js/NodeThreadExecutionService.cjs.map +1 -1
  148. package/dist/services/node-js/NodeThreadExecutionService.d.cts +3 -3
  149. package/dist/services/node-js/NodeThreadExecutionService.d.cts.map +1 -1
  150. package/dist/services/node-js/NodeThreadExecutionService.d.mts +3 -3
  151. package/dist/services/node-js/NodeThreadExecutionService.d.mts.map +1 -1
  152. package/dist/services/node-js/NodeThreadExecutionService.mjs +2 -5
  153. package/dist/services/node-js/NodeThreadExecutionService.mjs.map +1 -1
  154. package/dist/services/offscreen/OffscreenExecutionService.cjs.map +1 -1
  155. package/dist/services/offscreen/OffscreenExecutionService.d.cts +1 -1
  156. package/dist/services/offscreen/OffscreenExecutionService.d.cts.map +1 -1
  157. package/dist/services/offscreen/OffscreenExecutionService.d.mts +1 -1
  158. package/dist/services/offscreen/OffscreenExecutionService.d.mts.map +1 -1
  159. package/dist/services/offscreen/OffscreenExecutionService.mjs.map +1 -1
  160. package/dist/services/proxy/ProxyExecutionService.cjs +2 -5
  161. package/dist/services/proxy/ProxyExecutionService.cjs.map +1 -1
  162. package/dist/services/proxy/ProxyExecutionService.d.cts +3 -3
  163. package/dist/services/proxy/ProxyExecutionService.d.cts.map +1 -1
  164. package/dist/services/proxy/ProxyExecutionService.d.mts +3 -3
  165. package/dist/services/proxy/ProxyExecutionService.d.mts.map +1 -1
  166. package/dist/services/proxy/ProxyExecutionService.mjs +2 -5
  167. package/dist/services/proxy/ProxyExecutionService.mjs.map +1 -1
  168. package/dist/services/webview/WebViewExecutionService.cjs +2 -2
  169. package/dist/services/webview/WebViewExecutionService.cjs.map +1 -1
  170. package/dist/services/webview/WebViewExecutionService.d.cts +3 -3
  171. package/dist/services/webview/WebViewExecutionService.d.cts.map +1 -1
  172. package/dist/services/webview/WebViewExecutionService.d.mts +3 -3
  173. package/dist/services/webview/WebViewExecutionService.d.mts.map +1 -1
  174. package/dist/services/webview/WebViewExecutionService.mjs +2 -2
  175. package/dist/services/webview/WebViewExecutionService.mjs.map +1 -1
  176. package/dist/snaps/SnapController-method-action-types.cjs +7 -0
  177. package/dist/snaps/SnapController-method-action-types.cjs.map +1 -0
  178. package/dist/snaps/SnapController-method-action-types.d.cts +284 -0
  179. package/dist/snaps/SnapController-method-action-types.d.cts.map +1 -0
  180. package/dist/snaps/SnapController-method-action-types.d.mts +284 -0
  181. package/dist/snaps/SnapController-method-action-types.d.mts.map +1 -0
  182. package/dist/snaps/SnapController-method-action-types.mjs +6 -0
  183. package/dist/snaps/SnapController-method-action-types.mjs.map +1 -0
  184. package/dist/snaps/SnapController.cjs +118 -113
  185. package/dist/snaps/SnapController.cjs.map +1 -1
  186. package/dist/snaps/SnapController.d.cts +33 -190
  187. package/dist/snaps/SnapController.d.cts.map +1 -1
  188. package/dist/snaps/SnapController.d.mts +33 -190
  189. package/dist/snaps/SnapController.d.mts.map +1 -1
  190. package/dist/snaps/SnapController.mjs +119 -114
  191. package/dist/snaps/SnapController.mjs.map +1 -1
  192. package/dist/snaps/index.cjs +3 -1
  193. package/dist/snaps/index.cjs.map +1 -1
  194. package/dist/snaps/index.d.cts +3 -1
  195. package/dist/snaps/index.d.cts.map +1 -1
  196. package/dist/snaps/index.d.mts +3 -1
  197. package/dist/snaps/index.d.mts.map +1 -1
  198. package/dist/snaps/index.mjs +1 -1
  199. package/dist/snaps/index.mjs.map +1 -1
  200. package/dist/snaps/registry/SnapRegistryController-method-action-types.cjs +7 -0
  201. package/dist/snaps/registry/SnapRegistryController-method-action-types.cjs.map +1 -0
  202. package/dist/snaps/registry/SnapRegistryController-method-action-types.d.cts +46 -0
  203. package/dist/snaps/registry/SnapRegistryController-method-action-types.d.cts.map +1 -0
  204. package/dist/snaps/registry/SnapRegistryController-method-action-types.d.mts +46 -0
  205. package/dist/snaps/registry/SnapRegistryController-method-action-types.d.mts.map +1 -0
  206. package/dist/snaps/registry/SnapRegistryController-method-action-types.mjs +6 -0
  207. package/dist/snaps/registry/SnapRegistryController-method-action-types.mjs.map +1 -0
  208. package/dist/snaps/registry/{json.cjs → SnapRegistryController.cjs} +27 -24
  209. package/dist/snaps/registry/SnapRegistryController.cjs.map +1 -0
  210. package/dist/snaps/registry/SnapRegistryController.d.cts +67 -0
  211. package/dist/snaps/registry/SnapRegistryController.d.cts.map +1 -0
  212. package/dist/snaps/registry/SnapRegistryController.d.mts +67 -0
  213. package/dist/snaps/registry/SnapRegistryController.d.mts.map +1 -0
  214. package/dist/snaps/registry/{json.mjs → SnapRegistryController.mjs} +25 -22
  215. package/dist/snaps/registry/SnapRegistryController.mjs.map +1 -0
  216. package/dist/snaps/registry/index.cjs +5 -16
  217. package/dist/snaps/registry/index.cjs.map +1 -1
  218. package/dist/snaps/registry/index.d.cts +5 -2
  219. package/dist/snaps/registry/index.d.cts.map +1 -1
  220. package/dist/snaps/registry/index.d.mts +5 -2
  221. package/dist/snaps/registry/index.d.mts.map +1 -1
  222. package/dist/snaps/registry/index.mjs +2 -2
  223. package/dist/snaps/registry/index.mjs.map +1 -1
  224. package/dist/snaps/registry/types.cjs +11 -0
  225. package/dist/snaps/registry/types.cjs.map +1 -0
  226. package/dist/snaps/registry/types.d.cts +20 -0
  227. package/dist/snaps/registry/types.d.cts.map +1 -0
  228. package/dist/snaps/registry/types.d.mts +20 -0
  229. package/dist/snaps/registry/types.d.mts.map +1 -0
  230. package/dist/snaps/registry/types.mjs +8 -0
  231. package/dist/snaps/registry/types.mjs.map +1 -0
  232. package/dist/types/controllers.cjs.map +1 -1
  233. package/dist/types/controllers.d.cts +1 -1
  234. package/dist/types/controllers.d.cts.map +1 -1
  235. package/dist/types/controllers.d.mts +1 -1
  236. package/dist/types/controllers.d.mts.map +1 -1
  237. package/dist/types/controllers.mjs.map +1 -1
  238. package/dist/websocket/WebSocketService-method-action-types.cjs +7 -0
  239. package/dist/websocket/WebSocketService-method-action-types.cjs.map +1 -0
  240. package/dist/websocket/WebSocketService-method-action-types.d.cts +54 -0
  241. package/dist/websocket/WebSocketService-method-action-types.d.cts.map +1 -0
  242. package/dist/websocket/WebSocketService-method-action-types.d.mts +54 -0
  243. package/dist/websocket/WebSocketService-method-action-types.d.mts.map +1 -0
  244. package/dist/websocket/WebSocketService-method-action-types.mjs +6 -0
  245. package/dist/websocket/WebSocketService-method-action-types.mjs.map +1 -0
  246. package/dist/websocket/WebSocketService.cjs +14 -11
  247. package/dist/websocket/WebSocketService.cjs.map +1 -1
  248. package/dist/websocket/WebSocketService.d.cts +43 -22
  249. package/dist/websocket/WebSocketService.d.cts.map +1 -1
  250. package/dist/websocket/WebSocketService.d.mts +43 -22
  251. package/dist/websocket/WebSocketService.d.mts.map +1 -1
  252. package/dist/websocket/WebSocketService.mjs +14 -11
  253. package/dist/websocket/WebSocketService.mjs.map +1 -1
  254. package/dist/websocket/index.cjs +3 -15
  255. package/dist/websocket/index.cjs.map +1 -1
  256. package/dist/websocket/index.d.cts +3 -1
  257. package/dist/websocket/index.d.cts.map +1 -1
  258. package/dist/websocket/index.d.mts +3 -1
  259. package/dist/websocket/index.d.mts.map +1 -1
  260. package/dist/websocket/index.mjs +1 -1
  261. package/dist/websocket/index.mjs.map +1 -1
  262. package/package.json +12 -11
  263. package/dist/multichain/MultichainRouter.cjs.map +0 -1
  264. package/dist/multichain/MultichainRouter.d.cts.map +0 -1
  265. package/dist/multichain/MultichainRouter.d.mts.map +0 -1
  266. package/dist/multichain/MultichainRouter.mjs.map +0 -1
  267. package/dist/services/AbstractExecutionService.cjs +0 -314
  268. package/dist/services/AbstractExecutionService.cjs.map +0 -1
  269. package/dist/services/AbstractExecutionService.d.cts +0 -107
  270. package/dist/services/AbstractExecutionService.d.cts.map +0 -1
  271. package/dist/services/AbstractExecutionService.d.mts +0 -107
  272. package/dist/services/AbstractExecutionService.d.mts.map +0 -1
  273. package/dist/services/AbstractExecutionService.mjs +0 -313
  274. package/dist/services/AbstractExecutionService.mjs.map +0 -1
  275. package/dist/snaps/registry/json.cjs.map +0 -1
  276. package/dist/snaps/registry/json.d.cts +0 -58
  277. package/dist/snaps/registry/json.d.cts.map +0 -1
  278. package/dist/snaps/registry/json.d.mts +0 -58
  279. package/dist/snaps/registry/json.d.mts.map +0 -1
  280. package/dist/snaps/registry/json.mjs.map +0 -1
  281. package/dist/snaps/registry/registry.cjs +0 -11
  282. package/dist/snaps/registry/registry.cjs.map +0 -1
  283. package/dist/snaps/registry/registry.d.cts +0 -41
  284. package/dist/snaps/registry/registry.d.cts.map +0 -1
  285. package/dist/snaps/registry/registry.d.mts +0 -41
  286. package/dist/snaps/registry/registry.d.mts.map +0 -1
  287. package/dist/snaps/registry/registry.mjs +0 -8
  288. package/dist/snaps/registry/registry.mjs.map +0 -1
@@ -1,25 +1,10 @@
1
1
  import type { Messenger } from "@metamask/messenger";
2
- import type { GetPermissions } from "@metamask/permission-controller";
2
+ import type { PermissionControllerGetPermissionsAction } from "@metamask/permission-controller";
3
3
  import type { Json, JsonRpcRequest } from "@metamask/snaps-sdk";
4
4
  import type { InternalAccount } from "@metamask/snaps-utils";
5
5
  import type { CaipAccountId, CaipChainId } from "@metamask/utils";
6
- import type { GetAllSnaps, HandleSnapRequest } from "../snaps/index.mjs";
7
- export type MultichainRouterHandleRequestAction = {
8
- type: `${typeof name}:handleRequest`;
9
- handler: MultichainRouter['handleRequest'];
10
- };
11
- export type MultichainRouterGetSupportedMethodsAction = {
12
- type: `${typeof name}:getSupportedMethods`;
13
- handler: MultichainRouter['getSupportedMethods'];
14
- };
15
- export type MultichainRouterGetSupportedAccountsAction = {
16
- type: `${typeof name}:getSupportedAccounts`;
17
- handler: MultichainRouter['getSupportedAccounts'];
18
- };
19
- export type MultichainRouterIsSupportedScopeAction = {
20
- type: `${typeof name}:isSupportedScope`;
21
- handler: MultichainRouter['isSupportedScope'];
22
- };
6
+ import type { MultichainRoutingServiceMethodActions } from "./MultichainRoutingService-method-action-types.cjs";
7
+ import type { SnapControllerGetRunnableSnapsAction, SnapControllerHandleRequestAction } from "../snaps/index.cjs";
23
8
  type SnapKeyring = {
24
9
  submitRequest: (request: {
25
10
  origin: string;
@@ -36,25 +21,25 @@ export type AccountsControllerListMultichainAccountsAction = {
36
21
  type: `AccountsController:listMultichainAccounts`;
37
22
  handler: (chainId?: CaipChainId) => InternalAccount[];
38
23
  };
39
- export type MultichainRouterActions = MultichainRouterHandleRequestAction | MultichainRouterGetSupportedMethodsAction | MultichainRouterGetSupportedAccountsAction | MultichainRouterIsSupportedScopeAction;
40
- export type MultichainRouterAllowedActions = GetAllSnaps | HandleSnapRequest | GetPermissions | AccountsControllerListMultichainAccountsAction;
41
- export type MultichainRouterEvents = never;
42
- export type MultichainRouterMessenger = Messenger<typeof name, MultichainRouterActions | MultichainRouterAllowedActions>;
43
- export type MultichainRouterArgs = {
44
- messenger: MultichainRouterMessenger;
24
+ export type MultichainRoutingServiceActions = MultichainRoutingServiceMethodActions;
25
+ type AllowedActions = SnapControllerGetRunnableSnapsAction | SnapControllerHandleRequestAction | PermissionControllerGetPermissionsAction | AccountsControllerListMultichainAccountsAction;
26
+ export type MultichainRoutingServiceEvents = never;
27
+ export type MultichainRoutingServiceMessenger = Messenger<typeof name, MultichainRoutingServiceActions | AllowedActions>;
28
+ export type MultichainRoutingServiceArgs = {
29
+ messenger: MultichainRoutingServiceMessenger;
45
30
  withSnapKeyring: WithSnapKeyringFunction;
46
31
  };
47
- declare const name = "MultichainRouter";
48
- export declare class MultichainRouter {
32
+ declare const name = "MultichainRoutingService";
33
+ export declare class MultichainRoutingService {
49
34
  #private;
50
35
  name: typeof name;
51
36
  state: null;
52
- constructor({ messenger, withSnapKeyring }: MultichainRouterArgs);
37
+ constructor({ messenger, withSnapKeyring }: MultichainRoutingServiceArgs);
53
38
  /**
54
39
  * Handle an incoming JSON-RPC request tied to a specific scope by routing
55
40
  * to either a protocol Snap or an account Snap.
56
41
  *
57
- * Note: Addresses are considered case-sensitive by the MultichainRouter as
42
+ * Note: Addresses are considered case-sensitive by the MultichainRoutingService as
58
43
  * not all non-EVM chains are case-insensitive.
59
44
  *
60
45
  * @param options - An options bag.
@@ -96,4 +81,4 @@ export declare class MultichainRouter {
96
81
  isSupportedScope(scope: CaipChainId): boolean;
97
82
  }
98
83
  export {};
99
- //# sourceMappingURL=MultichainRouter.d.mts.map
84
+ //# sourceMappingURL=MultichainRoutingService.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultichainRoutingService.d.cts","sourceRoot":"","sources":["../../src/multichain/MultichainRoutingService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,wCAAwC,EAAE,wCAAwC;AAMhG,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAU,4BAA4B;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAE7D,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EAEZ,wBAAwB;AAUzB,OAAO,KAAK,EAAE,qCAAqC,EAAE,2DAAuD;AAC5G,OAAO,KAAK,EACV,oCAAoC,EACpC,iCAAiC,EAClC,2BAAiB;AAElB,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,CAAC,OAAO,EAAE;QACvB,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,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AC;QACpC,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,WAAW,CAAC;QACnB,OAAO,EAAE,cAAc,CAAC;KACzB,GAAG,OAAO,CAAC,IAAI,CAAC;IA0EjB;;;;;;OAMG;IACH,mBAAmB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,EAAE;IAYjD;;;;;OAKG;IACH,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,EAAE;IAMlD;;;;;OAKG;IACH,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO;CAO9C"}
@@ -1,25 +1,10 @@
1
1
  import type { Messenger } from "@metamask/messenger";
2
- import type { GetPermissions } from "@metamask/permission-controller";
2
+ import type { PermissionControllerGetPermissionsAction } from "@metamask/permission-controller";
3
3
  import type { Json, JsonRpcRequest } from "@metamask/snaps-sdk";
4
4
  import type { InternalAccount } from "@metamask/snaps-utils";
5
5
  import type { CaipAccountId, CaipChainId } from "@metamask/utils";
6
- import type { GetAllSnaps, HandleSnapRequest } from "../snaps/index.cjs";
7
- export type MultichainRouterHandleRequestAction = {
8
- type: `${typeof name}:handleRequest`;
9
- handler: MultichainRouter['handleRequest'];
10
- };
11
- export type MultichainRouterGetSupportedMethodsAction = {
12
- type: `${typeof name}:getSupportedMethods`;
13
- handler: MultichainRouter['getSupportedMethods'];
14
- };
15
- export type MultichainRouterGetSupportedAccountsAction = {
16
- type: `${typeof name}:getSupportedAccounts`;
17
- handler: MultichainRouter['getSupportedAccounts'];
18
- };
19
- export type MultichainRouterIsSupportedScopeAction = {
20
- type: `${typeof name}:isSupportedScope`;
21
- handler: MultichainRouter['isSupportedScope'];
22
- };
6
+ import type { MultichainRoutingServiceMethodActions } from "./MultichainRoutingService-method-action-types.mjs";
7
+ import type { SnapControllerGetRunnableSnapsAction, SnapControllerHandleRequestAction } from "../snaps/index.mjs";
23
8
  type SnapKeyring = {
24
9
  submitRequest: (request: {
25
10
  origin: string;
@@ -36,25 +21,25 @@ export type AccountsControllerListMultichainAccountsAction = {
36
21
  type: `AccountsController:listMultichainAccounts`;
37
22
  handler: (chainId?: CaipChainId) => InternalAccount[];
38
23
  };
39
- export type MultichainRouterActions = MultichainRouterHandleRequestAction | MultichainRouterGetSupportedMethodsAction | MultichainRouterGetSupportedAccountsAction | MultichainRouterIsSupportedScopeAction;
40
- export type MultichainRouterAllowedActions = GetAllSnaps | HandleSnapRequest | GetPermissions | AccountsControllerListMultichainAccountsAction;
41
- export type MultichainRouterEvents = never;
42
- export type MultichainRouterMessenger = Messenger<typeof name, MultichainRouterActions | MultichainRouterAllowedActions>;
43
- export type MultichainRouterArgs = {
44
- messenger: MultichainRouterMessenger;
24
+ export type MultichainRoutingServiceActions = MultichainRoutingServiceMethodActions;
25
+ type AllowedActions = SnapControllerGetRunnableSnapsAction | SnapControllerHandleRequestAction | PermissionControllerGetPermissionsAction | AccountsControllerListMultichainAccountsAction;
26
+ export type MultichainRoutingServiceEvents = never;
27
+ export type MultichainRoutingServiceMessenger = Messenger<typeof name, MultichainRoutingServiceActions | AllowedActions>;
28
+ export type MultichainRoutingServiceArgs = {
29
+ messenger: MultichainRoutingServiceMessenger;
45
30
  withSnapKeyring: WithSnapKeyringFunction;
46
31
  };
47
- declare const name = "MultichainRouter";
48
- export declare class MultichainRouter {
32
+ declare const name = "MultichainRoutingService";
33
+ export declare class MultichainRoutingService {
49
34
  #private;
50
35
  name: typeof name;
51
36
  state: null;
52
- constructor({ messenger, withSnapKeyring }: MultichainRouterArgs);
37
+ constructor({ messenger, withSnapKeyring }: MultichainRoutingServiceArgs);
53
38
  /**
54
39
  * Handle an incoming JSON-RPC request tied to a specific scope by routing
55
40
  * to either a protocol Snap or an account Snap.
56
41
  *
57
- * Note: Addresses are considered case-sensitive by the MultichainRouter as
42
+ * Note: Addresses are considered case-sensitive by the MultichainRoutingService as
58
43
  * not all non-EVM chains are case-insensitive.
59
44
  *
60
45
  * @param options - An options bag.
@@ -96,4 +81,4 @@ export declare class MultichainRouter {
96
81
  isSupportedScope(scope: CaipChainId): boolean;
97
82
  }
98
83
  export {};
99
- //# sourceMappingURL=MultichainRouter.d.cts.map
84
+ //# sourceMappingURL=MultichainRoutingService.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultichainRoutingService.d.mts","sourceRoot":"","sources":["../../src/multichain/MultichainRoutingService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,wCAAwC,EAAE,wCAAwC;AAMhG,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAU,4BAA4B;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAE7D,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EAEZ,wBAAwB;AAUzB,OAAO,KAAK,EAAE,qCAAqC,EAAE,2DAAuD;AAC5G,OAAO,KAAK,EACV,oCAAoC,EACpC,iCAAiC,EAClC,2BAAiB;AAElB,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,CAAC,OAAO,EAAE;QACvB,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACvC,KAAK,EAAE,WAAW,CAAC;KACpB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrB,CAAC;AAGF,MAAM,MAAM,uBAAuB,GAAG,CAAC,UAAU,EAC/C,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,WAAW,CAAA;CAAE,KAAK,OAAO,CAAC,UAAU,CAAC,KACtE,OAAO,CAAC,UAAU,CAAC,CAAC;AAEzB,MAAM,MAAM,8CAA8C,GAAG;IAC3D,IAAI,EAAE,2CAA2C,CAAC;IAClD,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,WAAW,KAAK,eAAe,EAAE,CAAC;CACvD,CAAC;AAEF,MAAM,MAAM,+BAA+B,GACzC,qCAAqC,CAAC;AAExC,KAAK,cAAc,GACf,oCAAoC,GACpC,iCAAiC,GACjC,wCAAwC,GACxC,8CAA8C,CAAC;AAEnD,MAAM,MAAM,8BAA8B,GAAG,KAAK,CAAC;AAEnD,MAAM,MAAM,iCAAiC,GAAG,SAAS,CACvD,OAAO,IAAI,EACX,+BAA+B,GAAG,cAAc,CACjD,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,SAAS,EAAE,iCAAiC,CAAC;IAC7C,eAAe,EAAE,uBAAuB,CAAC;CAC1C,CAAC;AAOF,QAAA,MAAM,IAAI,6BAA6B,CAAC;AASxC,qBAAa,wBAAwB;;IACnC,IAAI,EAAE,OAAO,IAAI,CAAQ;IAEzB,KAAK,OAAQ;gBAMD,EAAE,SAAS,EAAE,eAAe,EAAE,EAAE,4BAA4B;IAqKxE;;;;;;;;;;;;;;;OAeG;IACG,aAAa,CAAC,EAClB,kBAAkB,EAClB,MAAM,EACN,KAAK,EACL,OAAO,EAAE,UAAU,GACpB,EAAE;QACD,kBAAkB,EAAE,aAAa,EAAE,CAAC;QACpC,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,WAAW,CAAC;QACnB,OAAO,EAAE,cAAc,CAAC;KACzB,GAAG,OAAO,CAAC,IAAI,CAAC;IA0EjB;;;;;;OAMG;IACH,mBAAmB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,EAAE;IAYjD;;;;;OAKG;IACH,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,EAAE;IAMlD;;;;;OAKG;IACH,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO;CAO9C"}
@@ -3,9 +3,14 @@ import { getProtocolCaveatScopes, SnapEndowments } from "@metamask/snaps-rpc-met
3
3
  import { HandlerType } from "@metamask/snaps-utils";
4
4
  import { assert, hasProperty, isObject, KnownCaipNamespace, parseCaipAccountId } from "@metamask/utils";
5
5
  import { nanoid } from "nanoid";
6
- import { getRunnableSnaps } from "../snaps/index.mjs";
7
- const name = 'MultichainRouter';
8
- export class MultichainRouter {
6
+ const name = 'MultichainRoutingService';
7
+ const MESSENGER_EXPOSED_METHODS = [
8
+ 'handleRequest',
9
+ 'getSupportedMethods',
10
+ 'getSupportedAccounts',
11
+ 'isSupportedScope',
12
+ ];
13
+ export class MultichainRoutingService {
9
14
  name = name;
10
15
  state = null;
11
16
  #messenger;
@@ -13,10 +18,7 @@ export class MultichainRouter {
13
18
  constructor({ messenger, withSnapKeyring }) {
14
19
  this.#messenger = messenger;
15
20
  this.#withSnapKeyring = withSnapKeyring;
16
- this.#messenger.registerActionHandler(`${name}:handleRequest`, async (...args) => this.handleRequest(...args));
17
- this.#messenger.registerActionHandler(`${name}:getSupportedMethods`, (...args) => this.getSupportedMethods(...args));
18
- this.#messenger.registerActionHandler(`${name}:getSupportedAccounts`, (...args) => this.getSupportedAccounts(...args));
19
- this.#messenger.registerActionHandler(`${name}:isSupportedScope`, (...args) => this.isSupportedScope(...args));
21
+ this.#messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
20
22
  }
21
23
  /**
22
24
  * Attempts to resolve the account address to use for a given request by inspecting the request itself.
@@ -110,8 +112,7 @@ export class MultichainRouter {
110
112
  * @returns A list of all the protocol Snaps available and their RPC methods.
111
113
  */
112
114
  #getProtocolSnaps(scope) {
113
- const allSnaps = this.#messenger.call('SnapController:getAll');
114
- const filteredSnaps = getRunnableSnaps(allSnaps);
115
+ const filteredSnaps = this.#messenger.call('SnapController:getRunnableSnaps');
115
116
  return filteredSnaps.reduce((accumulator, snap) => {
116
117
  const permissions = this.#messenger.call('PermissionController:getPermissions', snap.id);
117
118
  if (permissions && hasProperty(permissions, SnapEndowments.Protocol)) {
@@ -131,7 +132,7 @@ export class MultichainRouter {
131
132
  * Handle an incoming JSON-RPC request tied to a specific scope by routing
132
133
  * to either a protocol Snap or an account Snap.
133
134
  *
134
- * Note: Addresses are considered case-sensitive by the MultichainRouter as
135
+ * Note: Addresses are considered case-sensitive by the MultichainRoutingService as
135
136
  * not all non-EVM chains are case-insensitive.
136
137
  *
137
138
  * @param options - An options bag.
@@ -233,4 +234,4 @@ export class MultichainRouter {
233
234
  return hasAccountSnap || this.#getProtocolSnaps(scope).length > 0;
234
235
  }
235
236
  }
236
- //# sourceMappingURL=MultichainRouter.mjs.map
237
+ //# sourceMappingURL=MultichainRoutingService.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultichainRoutingService.mjs","sourceRoot":"","sources":["../../src/multichain/MultichainRoutingService.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,6BAA6B;AACjD,OAAO,EACL,uBAAuB,EACvB,cAAc,EACf,oCAAoC;AAGrC,OAAO,EAAE,WAAW,EAAE,8BAA8B;AAMpD,OAAO,EACL,MAAM,EACN,WAAW,EACX,QAAQ,EACR,kBAAkB,EAClB,kBAAkB,EACnB,wBAAwB;AACzB,OAAO,EAAE,MAAM,EAAE,eAAe;AAsDhC,MAAM,IAAI,GAAG,0BAA0B,CAAC;AAExC,MAAM,yBAAyB,GAAG;IAChC,eAAe;IACf,qBAAqB;IACrB,sBAAsB;IACtB,kBAAkB;CACV,CAAC;AAEX,MAAM,OAAO,wBAAwB;IACnC,IAAI,GAAgB,IAAI,CAAC;IAEzB,KAAK,GAAG,IAAI,CAAC;IAEJ,UAAU,CAAoC;IAE9C,gBAAgB,CAA0B;IAEnD,YAAY,EAAE,SAAS,EAAE,eAAe,EAAgC;QACtE,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;QAExC,IAAI,CAAC,UAAU,CAAC,4BAA4B,CAC1C,IAAI,EACJ,yBAAyB,CAC1B,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,sBAAsB,CAC1B,MAAc,EACd,KAAkB,EAClB,OAA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6BAA6B,CAAC,KAAK,CAAC,CAAC,OAAO,CACtE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAC7B,CAAC;QAEF,MAAM,eAAe,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,OAAO,CAC3D,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CACvB,CAAC;QAEF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,cAAc,EAAE,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;IACtE,CAAC;IAED;;;;;OAKG;IACH,oBAAoB,CAAC,KAAkB;QACrC,OAAO,IAAI,CAAC,6BAA6B,CAAC,KAAK,CAAC,CAAC,GAAG,CAClD,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,KAAK,IAAI,OAAO,CAAC,OAAO,EAAE,CAC3C,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,gBAAgB,CAAC,KAAkB;QACjC,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU;aACnC,IAAI,CAAC,2CAA2C,EAAE,KAAK,CAAC;aACxD,IAAI,CAAC,CAAC,OAAwB,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACtE,+GAA+G;QAC/G,OAAO,cAAc,IAAI,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IACpE,CAAC;CACF","sourcesContent":["import type { Messenger } from '@metamask/messenger';\nimport type { PermissionControllerGetPermissionsAction } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport {\n getProtocolCaveatScopes,\n SnapEndowments,\n} from '@metamask/snaps-rpc-methods';\nimport type { Json, JsonRpcRequest, SnapId } from '@metamask/snaps-sdk';\nimport type { InternalAccount } from '@metamask/snaps-utils';\nimport { HandlerType } from '@metamask/snaps-utils';\nimport type {\n CaipAccountId,\n CaipChainId,\n JsonRpcParams,\n} from '@metamask/utils';\nimport {\n assert,\n hasProperty,\n isObject,\n KnownCaipNamespace,\n parseCaipAccountId,\n} from '@metamask/utils';\nimport { nanoid } from 'nanoid';\n\nimport type { MultichainRoutingServiceMethodActions } from './MultichainRoutingService-method-action-types';\nimport type {\n SnapControllerGetRunnableSnapsAction,\n SnapControllerHandleRequestAction,\n} from '../snaps';\n\ntype SnapKeyring = {\n submitRequest: (request: {\n origin: string;\n account: string;\n method: string;\n params?: Json[] | Record<string, Json>;\n scope: CaipChainId;\n }) => Promise<Json>;\n};\n\n// Expecting a bound function that calls KeyringController.withKeyring selecting the Snap keyring\nexport type WithSnapKeyringFunction = <ReturnType>(\n operation: ({ keyring }: { keyring: SnapKeyring }) => Promise<ReturnType>,\n) => Promise<ReturnType>;\n\nexport type AccountsControllerListMultichainAccountsAction = {\n type: `AccountsController:listMultichainAccounts`;\n handler: (chainId?: CaipChainId) => InternalAccount[];\n};\n\nexport type MultichainRoutingServiceActions =\n MultichainRoutingServiceMethodActions;\n\ntype AllowedActions =\n | SnapControllerGetRunnableSnapsAction\n | SnapControllerHandleRequestAction\n | PermissionControllerGetPermissionsAction\n | AccountsControllerListMultichainAccountsAction;\n\nexport type MultichainRoutingServiceEvents = never;\n\nexport type MultichainRoutingServiceMessenger = Messenger<\n typeof name,\n MultichainRoutingServiceActions | AllowedActions\n>;\n\nexport type MultichainRoutingServiceArgs = {\n messenger: MultichainRoutingServiceMessenger;\n withSnapKeyring: WithSnapKeyringFunction;\n};\n\ntype ProtocolSnap = {\n snapId: SnapId;\n methods: string[];\n};\n\nconst name = 'MultichainRoutingService';\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'handleRequest',\n 'getSupportedMethods',\n 'getSupportedAccounts',\n 'isSupportedScope',\n] as const;\n\nexport class MultichainRoutingService {\n name: typeof name = name;\n\n state = null;\n\n readonly #messenger: MultichainRoutingServiceMessenger;\n\n readonly #withSnapKeyring: WithSnapKeyringFunction;\n\n constructor({ messenger, withSnapKeyring }: MultichainRoutingServiceArgs) {\n this.#messenger = messenger;\n this.#withSnapKeyring = withSnapKeyring;\n\n this.#messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Attempts to resolve the account address to use for a given request by inspecting the request itself.\n *\n * The request is sent to an account Snap that will attempt this resolution.\n *\n * We manually construct the request instead of using the SnapKeyring, as the keyring may not be available.\n *\n * @param snapId - The ID of the Snap to send the request to.\n * @param scope - The CAIP-2 scope for the request.\n * @param request - The JSON-RPC request.\n * @returns The resolved address if found, otherwise null.\n * @throws If the invocation of the SnapKeyring fails.\n */\n async #resolveRequestAddress(\n snapId: SnapId,\n scope: CaipChainId,\n request: JsonRpcRequest,\n ) {\n try {\n const result = await this.#messenger.call(\n 'SnapController:handleRequest',\n {\n snapId,\n origin: 'metamask',\n request: {\n method: 'keyring_resolveAccountAddress',\n params: {\n request,\n scope,\n },\n },\n handler: HandlerType.OnKeyringRequest,\n },\n );\n\n assert(result === null || isObject(result));\n\n const address = result?.address as CaipAccountId;\n return address ? parseCaipAccountId(address).address : null;\n } catch {\n throw rpcErrors.internal();\n }\n }\n\n /**\n * Get the account ID of the account that should service the RPC request via an account Snap.\n *\n * This function checks whether any accounts exist that can service a given request by\n * using a combination of the resolveAccountAddress functionality and the connected accounts.\n *\n * If an account is expected to service this request but none is found, the function will throw.\n *\n * @param connectedAddresses - The CAIP-10 addresses connected to the\n * requesting origin for the requested scope.\n * @param scope - The CAIP-2 scope for the request.\n * @param request - The JSON-RPC request.\n * @returns An account ID if found, otherwise null.\n * @throws If no account is found, but the accounts exist that could service the request.\n */\n async #getSnapAccountId(\n connectedAddresses: CaipAccountId[],\n scope: CaipChainId,\n request: JsonRpcRequest,\n ) {\n const accounts = this.#messenger\n .call('AccountsController:listMultichainAccounts', scope)\n .filter(\n (\n account: InternalAccount,\n ): account is InternalAccount & {\n metadata: Required<InternalAccount['metadata']>;\n } =>\n Boolean(account.metadata.snap?.enabled) &&\n account.methods.includes(request.method),\n );\n\n // If no accounts can service the request, return null.\n if (accounts.length === 0) {\n return null;\n }\n\n const parsedConnectedAddresses = connectedAddresses.map(\n (connectedAddress) => parseCaipAccountId(connectedAddress).address,\n );\n\n const connectedAccounts = accounts.filter((account) =>\n parsedConnectedAddresses.includes(account.address),\n );\n\n if (connectedAccounts.length === 0) {\n throw rpcErrors.invalidParams({\n message: 'No available account found for request.',\n });\n }\n\n const resolutionSnapId = connectedAccounts[0].metadata.snap.id;\n\n // Attempt to resolve the address that should be used for signing.\n const address = await this.#resolveRequestAddress(\n resolutionSnapId,\n scope,\n request,\n );\n\n // If we have a resolved address, try to find the selected account based on that\n // otherwise, default to one of the connected accounts.\n // TODO: Eventually let the user choose if we have more than one option for the account.\n const selectedAccount = address\n ? connectedAccounts.find((account) => account.address === address)\n : connectedAccounts[0];\n\n if (!selectedAccount) {\n throw rpcErrors.invalidParams({\n message: 'No available account found for request.',\n });\n }\n\n return selectedAccount.id;\n }\n\n /**\n * Get all protocol Snaps that can service a given CAIP-2 scope.\n *\n * Protocol Snaps are deemed fit to service a scope if they are runnable\n * and have the proper permissions set for the scope.\n *\n * @param scope - A CAIP-2 scope.\n * @returns A list of all the protocol Snaps available and their RPC methods.\n */\n #getProtocolSnaps(scope: CaipChainId) {\n const filteredSnaps = this.#messenger.call(\n 'SnapController:getRunnableSnaps',\n );\n\n return filteredSnaps.reduce<ProtocolSnap[]>((accumulator, snap) => {\n const permissions = this.#messenger.call(\n 'PermissionController:getPermissions',\n snap.id,\n );\n\n if (permissions && hasProperty(permissions, SnapEndowments.Protocol)) {\n const permission = permissions[SnapEndowments.Protocol];\n const scopes = getProtocolCaveatScopes(permission);\n if (scopes && hasProperty(scopes, scope)) {\n accumulator.push({\n snapId: snap.id,\n methods: scopes[scope].methods,\n });\n }\n }\n\n return accumulator;\n }, []);\n }\n\n /**\n * Handle an incoming JSON-RPC request tied to a specific scope by routing\n * to either a protocol Snap or an account Snap.\n *\n * Note: Addresses are considered case-sensitive by the MultichainRoutingService as\n * not all non-EVM chains are case-insensitive.\n *\n * @param options - An options bag.\n * @param options.connectedAddresses - Addresses currently connected to the\n * origin for the requested scope.\n * @param options.origin - The origin of the RPC request.\n * @param options.request - The JSON-RPC request.\n * @param options.scope - The CAIP-2 scope for the request.\n * @returns The response from the chosen Snap.\n * @throws If no handler was found.\n */\n async handleRequest({\n connectedAddresses,\n origin,\n scope,\n request: rawRequest,\n }: {\n connectedAddresses: CaipAccountId[];\n origin: string;\n scope: CaipChainId;\n request: JsonRpcRequest;\n }): Promise<Json> {\n // Explicitly block EVM scopes, just in case.\n assert(\n !scope.startsWith(KnownCaipNamespace.Eip155) &&\n !scope.startsWith('wallet:eip155'),\n );\n\n // Re-create the request to simplify and remove additional properties that may be present in MM middleware.\n const request = {\n jsonrpc: '2.0' as const,\n id: rawRequest.id ?? nanoid(),\n method: rawRequest.method,\n ...(rawRequest.params ? { params: rawRequest.params } : {}),\n };\n\n const { method, params } = request;\n\n // If the RPC request can be serviced by an account Snap, route it there.\n const accountId = await this.#getSnapAccountId(\n connectedAddresses,\n scope,\n request,\n );\n\n if (accountId) {\n return this.#withSnapKeyring(async ({ keyring }) =>\n keyring.submitRequest({\n origin,\n account: accountId,\n scope,\n method,\n params: params as JsonRpcParams,\n }),\n );\n }\n\n // If the RPC request cannot be serviced by an account Snap,\n // but has a protocol Snap available, route it there.\n const protocolSnaps = this.#getProtocolSnaps(scope);\n const protocolSnap = protocolSnaps.find((snap) =>\n snap.methods.includes(method),\n );\n\n if (protocolSnap) {\n return this.#messenger.call('SnapController:handleRequest', {\n snapId: protocolSnap.snapId,\n origin,\n request: {\n method: '',\n params: {\n request,\n scope,\n },\n },\n handler: HandlerType.OnProtocolRequest,\n }) as Promise<Json>;\n }\n\n // If no compatible account or protocol Snaps were found, throw.\n throw rpcErrors.methodNotFound();\n }\n\n /**\n * Get a list of metadata for supported accounts for a given scope from the client.\n *\n * @param scope - The CAIP-2 scope.\n * @returns A list of metadata for the supported accounts.\n */\n #getSupportedAccountsMetadata(scope: CaipChainId): InternalAccount[] {\n return this.#messenger\n .call('AccountsController:listMultichainAccounts', scope)\n .filter((account: InternalAccount) => account.metadata.snap?.enabled);\n }\n\n /**\n * Get a list of supported methods for a given scope.\n * This combines both protocol and account Snaps supported methods.\n *\n * @param scope - The CAIP-2 scope.\n * @returns A list of supported methods.\n */\n getSupportedMethods(scope: CaipChainId): string[] {\n const accountMethods = this.#getSupportedAccountsMetadata(scope).flatMap(\n (account) => account.methods,\n );\n\n const protocolMethods = this.#getProtocolSnaps(scope).flatMap(\n (snap) => snap.methods,\n );\n\n return Array.from(new Set([...accountMethods, ...protocolMethods]));\n }\n\n /**\n * Get a list of supported accounts for a given scope.\n *\n * @param scope - The CAIP-2 scope.\n * @returns A list of CAIP-10 addresses.\n */\n getSupportedAccounts(scope: CaipChainId): string[] {\n return this.#getSupportedAccountsMetadata(scope).map(\n (account) => `${scope}:${account.address}`,\n );\n }\n\n /**\n * Determine whether a given CAIP-2 scope is supported by the router.\n *\n * @param scope - The CAIP-2 scope.\n * @returns True if the router can service the scope, otherwise false.\n */\n isSupportedScope(scope: CaipChainId): boolean {\n const hasAccountSnap = this.#messenger\n .call('AccountsController:listMultichainAccounts', scope)\n .some((account: InternalAccount) => account.metadata.snap?.enabled);\n // We currently assume here that if one Snap exists that service the scope, we can service the scope generally.\n return hasAccountSnap || this.#getProtocolSnaps(scope).length > 0;\n }\n}\n"]}
@@ -1,18 +1,6 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
2
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./MultichainRouter.cjs"), exports);
3
+ exports.MultichainRoutingService = void 0;
4
+ var MultichainRoutingService_1 = require("./MultichainRoutingService.cjs");
5
+ Object.defineProperty(exports, "MultichainRoutingService", { enumerable: true, get: function () { return MultichainRoutingService_1.MultichainRoutingService; } });
18
6
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/multichain/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAmC","sourcesContent":["export * from './MultichainRouter';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/multichain/index.ts"],"names":[],"mappings":";;;AAKA,2EAAsE;AAA7D,oIAAA,wBAAwB,OAAA","sourcesContent":["export type {\n MultichainRoutingServiceActions,\n MultichainRoutingServiceEvents,\n MultichainRoutingServiceMessenger,\n} from './MultichainRoutingService';\nexport { MultichainRoutingService } from './MultichainRoutingService';\nexport type {\n MultichainRoutingServiceGetSupportedAccountsAction,\n MultichainRoutingServiceGetSupportedMethodsAction,\n MultichainRoutingServiceHandleRequestAction,\n MultichainRoutingServiceIsSupportedScopeAction,\n} from './MultichainRoutingService-method-action-types';\n"]}
@@ -1,2 +1,4 @@
1
- export * from "./MultichainRouter.cjs";
1
+ export type { MultichainRoutingServiceActions, MultichainRoutingServiceEvents, MultichainRoutingServiceMessenger, } from "./MultichainRoutingService.cjs";
2
+ export { MultichainRoutingService } from "./MultichainRoutingService.cjs";
3
+ export type { MultichainRoutingServiceGetSupportedAccountsAction, MultichainRoutingServiceGetSupportedMethodsAction, MultichainRoutingServiceHandleRequestAction, MultichainRoutingServiceIsSupportedScopeAction, } from "./MultichainRoutingService-method-action-types.cjs";
2
4
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/multichain/index.ts"],"names":[],"mappings":"AAAA,uCAAmC"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/multichain/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,GAClC,uCAAmC;AACpC,OAAO,EAAE,wBAAwB,EAAE,uCAAmC;AACtE,YAAY,EACV,kDAAkD,EAClD,iDAAiD,EACjD,2CAA2C,EAC3C,8CAA8C,GAC/C,2DAAuD"}
@@ -1,2 +1,4 @@
1
- export * from "./MultichainRouter.mjs";
1
+ export type { MultichainRoutingServiceActions, MultichainRoutingServiceEvents, MultichainRoutingServiceMessenger, } from "./MultichainRoutingService.mjs";
2
+ export { MultichainRoutingService } from "./MultichainRoutingService.mjs";
3
+ export type { MultichainRoutingServiceGetSupportedAccountsAction, MultichainRoutingServiceGetSupportedMethodsAction, MultichainRoutingServiceHandleRequestAction, MultichainRoutingServiceIsSupportedScopeAction, } from "./MultichainRoutingService-method-action-types.mjs";
2
4
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/multichain/index.ts"],"names":[],"mappings":"AAAA,uCAAmC"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/multichain/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,GAClC,uCAAmC;AACpC,OAAO,EAAE,wBAAwB,EAAE,uCAAmC;AACtE,YAAY,EACV,kDAAkD,EAClD,iDAAiD,EACjD,2CAA2C,EAC3C,8CAA8C,GAC/C,2DAAuD"}
@@ -1,2 +1,2 @@
1
- export * from "./MultichainRouter.mjs";
1
+ export { MultichainRoutingService } from "./MultichainRoutingService.mjs";
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/multichain/index.ts"],"names":[],"mappings":"AAAA,uCAAmC","sourcesContent":["export * from './MultichainRouter';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/multichain/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,uCAAmC","sourcesContent":["export type {\n MultichainRoutingServiceActions,\n MultichainRoutingServiceEvents,\n MultichainRoutingServiceMessenger,\n} from './MultichainRoutingService';\nexport { MultichainRoutingService } from './MultichainRoutingService';\nexport type {\n MultichainRoutingServiceGetSupportedAccountsAction,\n MultichainRoutingServiceGetSupportedMethodsAction,\n MultichainRoutingServiceHandleRequestAction,\n MultichainRoutingServiceIsSupportedScopeAction,\n} from './MultichainRoutingService-method-action-types';\n"]}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * This file is auto generated.
4
+ * Do not edit manually.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=ExecutionService-method-action-types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExecutionService-method-action-types.cjs","sourceRoot":"","sources":["../../src/services/ExecutionService-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ExecutionService } from './ExecutionService';\n\n/**\n * Terminates the Snap with the specified ID and deletes all its associated\n * data. Any subsequent messages targeting the Snap will fail with an error.\n * Throws an error if termination fails unexpectedly.\n *\n * @param snapId - The id of the Snap to be terminated.\n */\nexport type ExecutionServiceTerminateSnapAction = {\n type: `ExecutionService:terminateSnap`;\n handler: ExecutionService['terminateSnap'];\n};\n\nexport type ExecutionServiceTerminateAllSnapsAction = {\n type: `ExecutionService:terminateAllSnaps`;\n handler: ExecutionService['terminateAllSnaps'];\n};\n\n/**\n * Initializes and executes a Snap, setting up the communication channels to the Snap etc.\n *\n * @param snapData - Data needed for Snap execution.\n * @param snapData.snapId - The ID of the Snap to execute.\n * @param snapData.sourceCode - The source code of the Snap to execute.\n * @param snapData.endowments - The endowments available to the executing Snap.\n * @returns A string `OK` if execution succeeded.\n * @throws If the execution service returns an error or execution times out.\n */\nexport type ExecutionServiceExecuteSnapAction = {\n type: `ExecutionService:executeSnap`;\n handler: ExecutionService['executeSnap'];\n};\n\n/**\n * Handle RPC request.\n *\n * @param snapId - The ID of the recipient Snap.\n * @param options - Bag of options to pass to the RPC handler.\n * @returns Promise that can handle the request.\n */\nexport type ExecutionServiceHandleRpcRequestAction = {\n type: `ExecutionService:handleRpcRequest`;\n handler: ExecutionService['handleRpcRequest'];\n};\n\n/**\n * Union of all ExecutionService action types.\n */\nexport type ExecutionServiceMethodActions =\n | ExecutionServiceTerminateSnapAction\n | ExecutionServiceTerminateAllSnapsAction\n | ExecutionServiceExecuteSnapAction\n | ExecutionServiceHandleRpcRequestAction;\n"]}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * This file is auto generated.
3
+ * Do not edit manually.
4
+ */
5
+ import type { ExecutionService } from "./ExecutionService.cjs";
6
+ /**
7
+ * Terminates the Snap with the specified ID and deletes all its associated
8
+ * data. Any subsequent messages targeting the Snap will fail with an error.
9
+ * Throws an error if termination fails unexpectedly.
10
+ *
11
+ * @param snapId - The id of the Snap to be terminated.
12
+ */
13
+ export type ExecutionServiceTerminateSnapAction = {
14
+ type: `ExecutionService:terminateSnap`;
15
+ handler: ExecutionService['terminateSnap'];
16
+ };
17
+ export type ExecutionServiceTerminateAllSnapsAction = {
18
+ type: `ExecutionService:terminateAllSnaps`;
19
+ handler: ExecutionService['terminateAllSnaps'];
20
+ };
21
+ /**
22
+ * Initializes and executes a Snap, setting up the communication channels to the Snap etc.
23
+ *
24
+ * @param snapData - Data needed for Snap execution.
25
+ * @param snapData.snapId - The ID of the Snap to execute.
26
+ * @param snapData.sourceCode - The source code of the Snap to execute.
27
+ * @param snapData.endowments - The endowments available to the executing Snap.
28
+ * @returns A string `OK` if execution succeeded.
29
+ * @throws If the execution service returns an error or execution times out.
30
+ */
31
+ export type ExecutionServiceExecuteSnapAction = {
32
+ type: `ExecutionService:executeSnap`;
33
+ handler: ExecutionService['executeSnap'];
34
+ };
35
+ /**
36
+ * Handle RPC request.
37
+ *
38
+ * @param snapId - The ID of the recipient Snap.
39
+ * @param options - Bag of options to pass to the RPC handler.
40
+ * @returns Promise that can handle the request.
41
+ */
42
+ export type ExecutionServiceHandleRpcRequestAction = {
43
+ type: `ExecutionService:handleRpcRequest`;
44
+ handler: ExecutionService['handleRpcRequest'];
45
+ };
46
+ /**
47
+ * Union of all ExecutionService action types.
48
+ */
49
+ export type ExecutionServiceMethodActions = ExecutionServiceTerminateSnapAction | ExecutionServiceTerminateAllSnapsAction | ExecutionServiceExecuteSnapAction | ExecutionServiceHandleRpcRequestAction;
50
+ //# sourceMappingURL=ExecutionService-method-action-types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExecutionService-method-action-types.d.cts","sourceRoot":"","sources":["../../src/services/ExecutionService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,+BAA2B;AAE3D;;;;;;GAMG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,gBAAgB,CAAC,eAAe,CAAC,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;CAChD,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;CAC1C,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,sCAAsC,GAAG;IACnD,IAAI,EAAE,mCAAmC,CAAC;IAC1C,OAAO,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,mCAAmC,GACnC,uCAAuC,GACvC,iCAAiC,GACjC,sCAAsC,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * This file is auto generated.
3
+ * Do not edit manually.
4
+ */
5
+ import type { ExecutionService } from "./ExecutionService.mjs";
6
+ /**
7
+ * Terminates the Snap with the specified ID and deletes all its associated
8
+ * data. Any subsequent messages targeting the Snap will fail with an error.
9
+ * Throws an error if termination fails unexpectedly.
10
+ *
11
+ * @param snapId - The id of the Snap to be terminated.
12
+ */
13
+ export type ExecutionServiceTerminateSnapAction = {
14
+ type: `ExecutionService:terminateSnap`;
15
+ handler: ExecutionService['terminateSnap'];
16
+ };
17
+ export type ExecutionServiceTerminateAllSnapsAction = {
18
+ type: `ExecutionService:terminateAllSnaps`;
19
+ handler: ExecutionService['terminateAllSnaps'];
20
+ };
21
+ /**
22
+ * Initializes and executes a Snap, setting up the communication channels to the Snap etc.
23
+ *
24
+ * @param snapData - Data needed for Snap execution.
25
+ * @param snapData.snapId - The ID of the Snap to execute.
26
+ * @param snapData.sourceCode - The source code of the Snap to execute.
27
+ * @param snapData.endowments - The endowments available to the executing Snap.
28
+ * @returns A string `OK` if execution succeeded.
29
+ * @throws If the execution service returns an error or execution times out.
30
+ */
31
+ export type ExecutionServiceExecuteSnapAction = {
32
+ type: `ExecutionService:executeSnap`;
33
+ handler: ExecutionService['executeSnap'];
34
+ };
35
+ /**
36
+ * Handle RPC request.
37
+ *
38
+ * @param snapId - The ID of the recipient Snap.
39
+ * @param options - Bag of options to pass to the RPC handler.
40
+ * @returns Promise that can handle the request.
41
+ */
42
+ export type ExecutionServiceHandleRpcRequestAction = {
43
+ type: `ExecutionService:handleRpcRequest`;
44
+ handler: ExecutionService['handleRpcRequest'];
45
+ };
46
+ /**
47
+ * Union of all ExecutionService action types.
48
+ */
49
+ export type ExecutionServiceMethodActions = ExecutionServiceTerminateSnapAction | ExecutionServiceTerminateAllSnapsAction | ExecutionServiceExecuteSnapAction | ExecutionServiceHandleRpcRequestAction;
50
+ //# sourceMappingURL=ExecutionService-method-action-types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExecutionService-method-action-types.d.mts","sourceRoot":"","sources":["../../src/services/ExecutionService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,+BAA2B;AAE3D;;;;;;GAMG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,gBAAgB,CAAC,eAAe,CAAC,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;CAChD,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;CAC1C,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,sCAAsC,GAAG;IACnD,IAAI,EAAE,mCAAmC,CAAC;IAC1C,OAAO,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,mCAAmC,GACnC,uCAAuC,GACvC,iCAAiC,GACjC,sCAAsC,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This file is auto generated.
3
+ * Do not edit manually.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=ExecutionService-method-action-types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExecutionService-method-action-types.mjs","sourceRoot":"","sources":["../../src/services/ExecutionService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ExecutionService } from './ExecutionService';\n\n/**\n * Terminates the Snap with the specified ID and deletes all its associated\n * data. Any subsequent messages targeting the Snap will fail with an error.\n * Throws an error if termination fails unexpectedly.\n *\n * @param snapId - The id of the Snap to be terminated.\n */\nexport type ExecutionServiceTerminateSnapAction = {\n type: `ExecutionService:terminateSnap`;\n handler: ExecutionService['terminateSnap'];\n};\n\nexport type ExecutionServiceTerminateAllSnapsAction = {\n type: `ExecutionService:terminateAllSnaps`;\n handler: ExecutionService['terminateAllSnaps'];\n};\n\n/**\n * Initializes and executes a Snap, setting up the communication channels to the Snap etc.\n *\n * @param snapData - Data needed for Snap execution.\n * @param snapData.snapId - The ID of the Snap to execute.\n * @param snapData.sourceCode - The source code of the Snap to execute.\n * @param snapData.endowments - The endowments available to the executing Snap.\n * @returns A string `OK` if execution succeeded.\n * @throws If the execution service returns an error or execution times out.\n */\nexport type ExecutionServiceExecuteSnapAction = {\n type: `ExecutionService:executeSnap`;\n handler: ExecutionService['executeSnap'];\n};\n\n/**\n * Handle RPC request.\n *\n * @param snapId - The ID of the recipient Snap.\n * @param options - Bag of options to pass to the RPC handler.\n * @returns Promise that can handle the request.\n */\nexport type ExecutionServiceHandleRpcRequestAction = {\n type: `ExecutionService:handleRpcRequest`;\n handler: ExecutionService['handleRpcRequest'];\n};\n\n/**\n * Union of all ExecutionService action types.\n */\nexport type ExecutionServiceMethodActions =\n | ExecutionServiceTerminateSnapAction\n | ExecutionServiceTerminateAllSnapsAction\n | ExecutionServiceExecuteSnapAction\n | ExecutionServiceHandleRpcRequestAction;\n"]}