@metamask/snaps-controllers 18.0.4 → 19.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 (288) hide show
  1. package/CHANGELOG.md +96 -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 +7 -24
  13. package/dist/cronjob/CronjobController.d.cts.map +1 -1
  14. package/dist/cronjob/CronjobController.d.mts +7 -24
  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 +8 -8
  29. package/dist/insights/SnapInsightsController.d.cts.map +1 -1
  30. package/dist/insights/SnapInsightsController.d.mts +8 -8
  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 +9 -39
  53. package/dist/interface/SnapInterfaceController.d.cts.map +1 -1
  54. package/dist/interface/SnapInterfaceController.d.mts +9 -39
  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} +13 -28
  77. package/dist/multichain/MultichainRoutingService.d.cts.map +1 -0
  78. package/dist/multichain/{MultichainRouter.d.cts → MultichainRoutingService.d.mts} +13 -28
  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 +32 -189
  187. package/dist/snaps/SnapController.d.cts.map +1 -1
  188. package/dist/snaps/SnapController.d.mts +32 -189
  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 +8 -7
  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 +0,0 @@
1
- {"version":3,"file":"MultichainRouter.cjs","sourceRoot":"","sources":["../../src/multichain/MultichainRouter.ts"],"names":[],"mappings":";;;AAEA,qDAAiD;AACjD,mEAGqC;AAGrC,uDAAoD;AAMpD,2CAMyB;AACzB,mCAAgC;AAEhC,8CAA4C;AAwE5C,MAAM,IAAI,GAAG,kBAAkB,CAAC;AAEhC,MAAa,gBAAgB;IAC3B,IAAI,GAAgB,IAAI,CAAC;IAEzB,KAAK,GAAG,IAAI,CAAC;IAEJ,UAAU,CAA4B;IAEtC,gBAAgB,CAA0B;IAEnD,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E,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;AA5UD,4CA4UC","sourcesContent":["import type { Messenger } from '@metamask/messenger';\nimport type { GetPermissions } 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 { getRunnableSnaps } from '../snaps';\nimport type { GetAllSnaps, HandleSnapRequest } from '../snaps';\n\nexport type MultichainRouterHandleRequestAction = {\n type: `${typeof name}:handleRequest`;\n handler: MultichainRouter['handleRequest'];\n};\n\nexport type MultichainRouterGetSupportedMethodsAction = {\n type: `${typeof name}:getSupportedMethods`;\n handler: MultichainRouter['getSupportedMethods'];\n};\n\nexport type MultichainRouterGetSupportedAccountsAction = {\n type: `${typeof name}:getSupportedAccounts`;\n handler: MultichainRouter['getSupportedAccounts'];\n};\n\nexport type MultichainRouterIsSupportedScopeAction = {\n type: `${typeof name}:isSupportedScope`;\n handler: MultichainRouter['isSupportedScope'];\n};\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 MultichainRouterActions =\n | MultichainRouterHandleRequestAction\n | MultichainRouterGetSupportedMethodsAction\n | MultichainRouterGetSupportedAccountsAction\n | MultichainRouterIsSupportedScopeAction;\n\nexport type MultichainRouterAllowedActions =\n | GetAllSnaps\n | HandleSnapRequest\n | GetPermissions\n | AccountsControllerListMultichainAccountsAction;\n\nexport type MultichainRouterEvents = never;\n\nexport type MultichainRouterMessenger = Messenger<\n typeof name,\n MultichainRouterActions | MultichainRouterAllowedActions\n>;\n\nexport type MultichainRouterArgs = {\n messenger: MultichainRouterMessenger;\n withSnapKeyring: WithSnapKeyringFunction;\n};\n\ntype ProtocolSnap = {\n snapId: SnapId;\n methods: string[];\n};\n\nconst name = 'MultichainRouter';\n\nexport class MultichainRouter {\n name: typeof name = name;\n\n state = null;\n\n readonly #messenger: MultichainRouterMessenger;\n\n readonly #withSnapKeyring: WithSnapKeyringFunction;\n\n constructor({ messenger, withSnapKeyring }: MultichainRouterArgs) {\n this.#messenger = messenger;\n this.#withSnapKeyring = withSnapKeyring;\n\n this.#messenger.registerActionHandler(\n `${name}:handleRequest`,\n async (...args) => this.handleRequest(...args),\n );\n\n this.#messenger.registerActionHandler(\n `${name}:getSupportedMethods`,\n (...args) => this.getSupportedMethods(...args),\n );\n\n this.#messenger.registerActionHandler(\n `${name}:getSupportedAccounts`,\n (...args) => this.getSupportedAccounts(...args),\n );\n\n this.#messenger.registerActionHandler(\n `${name}:isSupportedScope`,\n (...args) => this.isSupportedScope(...args),\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 allSnaps = this.#messenger.call('SnapController:getAll');\n const filteredSnaps = getRunnableSnaps(allSnaps);\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 MultichainRouter 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 +0,0 @@
1
- {"version":3,"file":"MultichainRouter.d.cts","sourceRoot":"","sources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C;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 { GetPermissions } 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 { getRunnableSnaps } from '../snaps';\nimport type { GetAllSnaps, HandleSnapRequest } from '../snaps';\n\nexport type MultichainRouterHandleRequestAction = {\n type: `${typeof name}:handleRequest`;\n handler: MultichainRouter['handleRequest'];\n};\n\nexport type MultichainRouterGetSupportedMethodsAction = {\n type: `${typeof name}:getSupportedMethods`;\n handler: MultichainRouter['getSupportedMethods'];\n};\n\nexport type MultichainRouterGetSupportedAccountsAction = {\n type: `${typeof name}:getSupportedAccounts`;\n handler: MultichainRouter['getSupportedAccounts'];\n};\n\nexport type MultichainRouterIsSupportedScopeAction = {\n type: `${typeof name}:isSupportedScope`;\n handler: MultichainRouter['isSupportedScope'];\n};\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 MultichainRouterActions =\n | MultichainRouterHandleRequestAction\n | MultichainRouterGetSupportedMethodsAction\n | MultichainRouterGetSupportedAccountsAction\n | MultichainRouterIsSupportedScopeAction;\n\nexport type MultichainRouterAllowedActions =\n | GetAllSnaps\n | HandleSnapRequest\n | GetPermissions\n | AccountsControllerListMultichainAccountsAction;\n\nexport type MultichainRouterEvents = never;\n\nexport type MultichainRouterMessenger = Messenger<\n typeof name,\n MultichainRouterActions | MultichainRouterAllowedActions\n>;\n\nexport type MultichainRouterArgs = {\n messenger: MultichainRouterMessenger;\n withSnapKeyring: WithSnapKeyringFunction;\n};\n\ntype ProtocolSnap = {\n snapId: SnapId;\n methods: string[];\n};\n\nconst name = 'MultichainRouter';\n\nexport class MultichainRouter {\n name: typeof name = name;\n\n state = null;\n\n readonly #messenger: MultichainRouterMessenger;\n\n readonly #withSnapKeyring: WithSnapKeyringFunction;\n\n constructor({ messenger, withSnapKeyring }: MultichainRouterArgs) {\n this.#messenger = messenger;\n this.#withSnapKeyring = withSnapKeyring;\n\n this.#messenger.registerActionHandler(\n `${name}:handleRequest`,\n async (...args) => this.handleRequest(...args),\n );\n\n this.#messenger.registerActionHandler(\n `${name}:getSupportedMethods`,\n (...args) => this.getSupportedMethods(...args),\n );\n\n this.#messenger.registerActionHandler(\n `${name}:getSupportedAccounts`,\n (...args) => this.getSupportedAccounts(...args),\n );\n\n this.#messenger.registerActionHandler(\n `${name}:isSupportedScope`,\n (...args) => this.isSupportedScope(...args),\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 allSnaps = this.#messenger.call('SnapController:getAll');\n const filteredSnaps = getRunnableSnaps(allSnaps);\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 MultichainRouter 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,314 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.setupMultiplex = exports.AbstractExecutionService = void 0;
7
- const json_rpc_engine_1 = require("@metamask/json-rpc-engine");
8
- const v2_1 = require("@metamask/json-rpc-engine/v2");
9
- const json_rpc_middleware_stream_1 = require("@metamask/json-rpc-middleware-stream");
10
- const object_multiplex_1 = __importDefault(require("@metamask/object-multiplex"));
11
- const snaps_utils_1 = require("@metamask/snaps-utils");
12
- const utils_1 = require("@metamask/utils");
13
- const nanoid_1 = require("nanoid");
14
- const readable_stream_1 = require("readable-stream");
15
- const logging_1 = require("../logging.cjs");
16
- const Timer_1 = require("../snaps/Timer.cjs");
17
- const utils_2 = require("../utils.cjs");
18
- const controllerName = 'ExecutionService';
19
- class AbstractExecutionService {
20
- name = controllerName;
21
- state = null;
22
- #jobs;
23
- #status;
24
- #setupSnapProvider;
25
- #messenger;
26
- #initTimeout;
27
- #pingTimeout;
28
- #terminationTimeout;
29
- #usePing;
30
- constructor({ setupSnapProvider, messenger, initTimeout = (0, utils_1.inMilliseconds)(60, utils_1.Duration.Second), pingTimeout = (0, utils_1.inMilliseconds)(10, utils_1.Duration.Second), terminationTimeout = (0, utils_1.inMilliseconds)(1, utils_1.Duration.Second), usePing = true, }) {
31
- this.#jobs = new Map();
32
- this.#status = new Map();
33
- this.#setupSnapProvider = setupSnapProvider;
34
- this.#messenger = messenger;
35
- this.#initTimeout = initTimeout;
36
- this.#pingTimeout = pingTimeout;
37
- this.#terminationTimeout = terminationTimeout;
38
- this.#usePing = usePing;
39
- this.#registerMessageHandlers();
40
- }
41
- /**
42
- * Constructor helper for registering the controller's messaging system
43
- * actions.
44
- */
45
- #registerMessageHandlers() {
46
- this.#messenger.registerActionHandler(`${controllerName}:handleRpcRequest`, async (snapId, options) => this.handleRpcRequest(snapId, options));
47
- this.#messenger.registerActionHandler(`${controllerName}:executeSnap`, async (data) => this.executeSnap(data));
48
- this.#messenger.registerActionHandler(`${controllerName}:terminateSnap`, async (snapId) => this.terminateSnap(snapId));
49
- this.#messenger.registerActionHandler(`${controllerName}:terminateAllSnaps`, async () => this.terminateAllSnaps());
50
- }
51
- /**
52
- * Terminates the Snap with the specified ID and deletes all its associated
53
- * data. Any subsequent messages targeting the Snap will fail with an error.
54
- * Throws an error if termination fails unexpectedly.
55
- *
56
- * @param snapId - The id of the Snap to be terminated.
57
- */
58
- async terminateSnap(snapId) {
59
- const job = this.#jobs.get(snapId);
60
- if (!job) {
61
- return;
62
- }
63
- try {
64
- // Ping worker and tell it to run teardown, continue with termination if it takes too long
65
- const result = await (0, utils_2.withTimeout)(this.#command(snapId, {
66
- jsonrpc: '2.0',
67
- method: 'terminate',
68
- id: (0, nanoid_1.nanoid)(),
69
- }), this.#terminationTimeout);
70
- if (result === utils_2.hasTimedOut || result !== 'OK') {
71
- (0, snaps_utils_1.logWarning)(`Snap "${snapId}" failed to terminate gracefully.`);
72
- }
73
- }
74
- catch {
75
- // Ignore
76
- }
77
- Object.values(job.streams).forEach((stream) => {
78
- try {
79
- if (!stream.destroyed) {
80
- stream.destroy();
81
- }
82
- }
83
- catch (error) {
84
- (0, snaps_utils_1.logError)('Error while destroying stream', error);
85
- }
86
- });
87
- await this.terminateJob(job);
88
- this.#jobs.delete(snapId);
89
- this.#status.delete(snapId);
90
- (0, logging_1.log)(`Snap "${snapId}" terminated.`);
91
- }
92
- /**
93
- * Initiates a job for a Snap.
94
- *
95
- * @param snapId - The ID of the Snap to initiate a job for.
96
- * @param timer - The timer to use for timeouts.
97
- * @returns Information regarding the created job.
98
- * @throws If the execution service returns an error or execution times out.
99
- */
100
- async #initJob(snapId, timer) {
101
- const { streams, worker } = await this.#initStreams(snapId, timer);
102
- const jsonRpcConnection = (0, json_rpc_middleware_stream_1.createStreamMiddleware)();
103
- (0, readable_stream_1.pipeline)(jsonRpcConnection.stream, streams.command, jsonRpcConnection.stream, (error) => {
104
- if (error && !error.message?.match('Premature close')) {
105
- (0, snaps_utils_1.logError)(`Command stream failure.`, error);
106
- }
107
- });
108
- const rpcEngine = v2_1.JsonRpcEngineV2.create({
109
- middleware: [(0, json_rpc_engine_1.asV2Middleware)(jsonRpcConnection.middleware)],
110
- });
111
- const envMetadata = {
112
- id: snapId,
113
- streams,
114
- rpcEngine,
115
- worker,
116
- };
117
- this.#jobs.set(snapId, envMetadata);
118
- return envMetadata;
119
- }
120
- /**
121
- * Sets up the streams for an initiated job.
122
- *
123
- * @param snapId - The Snap ID.
124
- * @param timer - The timer to use for timeouts.
125
- * @returns The streams to communicate with the worker and the worker itself.
126
- * @throws If the execution service returns an error or execution times out.
127
- */
128
- async #initStreams(snapId, timer) {
129
- const result = await (0, utils_2.withTimeout)(this.initEnvStream(snapId), timer);
130
- if (result === utils_2.hasTimedOut) {
131
- // For certain environments, such as the iframe we may have already created the worker and wish to terminate it.
132
- await this.terminateJob({ id: snapId });
133
- const status = this.#status.get(snapId);
134
- if (status === 'created') {
135
- // Currently this error can only be thrown by OffscreenExecutionService.
136
- throw new Error(`The executor for "${snapId}" couldn't start initialization. The offscreen document may not exist.`);
137
- }
138
- throw new Error(`The executor for "${snapId}" failed to initialize. The iframe/webview/worker failed to load.`);
139
- }
140
- const { worker, stream: envStream } = result;
141
- const mux = setupMultiplex(envStream, `Snap: "${snapId}"`);
142
- const commandStream = mux.createStream(snaps_utils_1.SNAP_STREAM_NAMES.COMMAND);
143
- // Handle out-of-band errors, i.e. errors thrown from the Snap outside of the req/res cycle.
144
- // Also keep track of outbound request/responses
145
- const notificationHandler = (message) => {
146
- if ((0, utils_1.hasProperty)(message, 'id')) {
147
- return;
148
- }
149
- if (message.method === 'OutboundRequest') {
150
- this.#messenger.publish('ExecutionService:outboundRequest', snapId);
151
- }
152
- else if (message.method === 'OutboundResponse') {
153
- this.#messenger.publish('ExecutionService:outboundResponse', snapId);
154
- }
155
- else if (message.method === 'UnhandledError') {
156
- this.#messenger.publish('ExecutionService:unhandledError', snapId, message.params.error);
157
- commandStream.removeListener('data', notificationHandler);
158
- }
159
- else {
160
- (0, snaps_utils_1.logError)(new Error(`Received unexpected command stream notification "${message.method}".`));
161
- }
162
- };
163
- commandStream.on('data', notificationHandler);
164
- const rpcStream = mux
165
- .createStream(snaps_utils_1.SNAP_STREAM_NAMES.JSON_RPC)
166
- .setMaxListeners(20);
167
- rpcStream.on('data', (chunk) => {
168
- if (chunk?.data && (0, utils_1.hasProperty)(chunk?.data, 'id')) {
169
- this.#messenger.publish('ExecutionService:outboundRequest', snapId);
170
- }
171
- });
172
- // An error handler is not attached to the RPC stream until `setupSnapProvider` is called.
173
- // We must set it up here to prevent errors from bubbling up if the stream is destroyed before then.
174
- rpcStream.on('error', (error) => {
175
- if (error && !error.message?.match('Premature close')) {
176
- (0, snaps_utils_1.logError)(`Snap: "${snapId}" - RPC stream failure:`, error);
177
- }
178
- });
179
- const originalWrite = rpcStream.write.bind(rpcStream);
180
- // @ts-expect-error Hack to inspect the messages being written to the stream.
181
- rpcStream.write = (chunk, encoding, callback) => {
182
- // Ignore chain switching notifications as it doesn't matter for the SnapProvider.
183
- if (chunk?.data?.method === 'metamask_chainChanged') {
184
- return true;
185
- }
186
- if (chunk?.data && (0, utils_1.hasProperty)(chunk?.data, 'id')) {
187
- this.#messenger.publish('ExecutionService:outboundResponse', snapId);
188
- }
189
- return originalWrite(chunk, encoding, callback);
190
- };
191
- return {
192
- streams: {
193
- command: commandStream,
194
- rpc: rpcStream,
195
- connection: envStream,
196
- mux,
197
- },
198
- worker,
199
- };
200
- }
201
- /**
202
- * Set the execution status of the Snap.
203
- *
204
- * @param snapId - The Snap ID.
205
- * @param status - The current execution status.
206
- */
207
- setSnapStatus(snapId, status) {
208
- this.#status.set(snapId, status);
209
- }
210
- async terminateAllSnaps() {
211
- await Promise.all([...this.#jobs.keys()].map(async (snapId) => this.terminateSnap(snapId)));
212
- }
213
- /**
214
- * Initializes and executes a Snap, setting up the communication channels to the Snap etc.
215
- *
216
- * @param snapData - Data needed for Snap execution.
217
- * @param snapData.snapId - The ID of the Snap to execute.
218
- * @param snapData.sourceCode - The source code of the Snap to execute.
219
- * @param snapData.endowments - The endowments available to the executing Snap.
220
- * @returns A string `OK` if execution succeeded.
221
- * @throws If the execution service returns an error or execution times out.
222
- */
223
- async executeSnap({ snapId, sourceCode, endowments, }) {
224
- if (this.#jobs.has(snapId)) {
225
- throw new Error(`"${snapId}" is already running.`);
226
- }
227
- this.setSnapStatus(snapId, 'created');
228
- const timer = new Timer_1.Timer(this.#initTimeout);
229
- // This may resolve even if the environment has failed to start up fully
230
- const job = await this.#initJob(snapId, timer);
231
- // Certain environments use ping as part of their initialization and thus can skip it here
232
- if (this.#usePing) {
233
- // Ping the worker to ensure that it started up
234
- const pingResult = await (0, utils_2.withTimeout)(this.#command(job.id, {
235
- jsonrpc: '2.0',
236
- method: 'ping',
237
- id: (0, nanoid_1.nanoid)(),
238
- }), this.#pingTimeout);
239
- if (pingResult === utils_2.hasTimedOut) {
240
- throw new Error(`The executor for "${snapId}" was unreachable. The executor did not respond in time.`);
241
- }
242
- }
243
- const rpcStream = job.streams.rpc;
244
- this.#setupSnapProvider(snapId, rpcStream);
245
- // Use the remaining time as the timer, but ensure that the
246
- // Snap gets at least half the init timeout.
247
- const remainingTime = Math.max(timer.remaining, this.#initTimeout / 2);
248
- this.setSnapStatus(snapId, 'initialized');
249
- const request = {
250
- jsonrpc: '2.0',
251
- method: 'executeSnap',
252
- params: { snapId, sourceCode, endowments },
253
- id: (0, nanoid_1.nanoid)(),
254
- };
255
- (0, utils_1.assertIsJsonRpcRequest)(request);
256
- this.setSnapStatus(snapId, 'executing');
257
- const result = await (0, utils_2.withTimeout)(this.#command(job.id, request), remainingTime);
258
- if (result === utils_2.hasTimedOut) {
259
- throw new Error(`${snapId} failed to start.`);
260
- }
261
- if (result === 'OK') {
262
- this.setSnapStatus(snapId, 'running');
263
- }
264
- return result;
265
- }
266
- async #command(snapId, message) {
267
- const job = this.#jobs.get(snapId);
268
- if (!job) {
269
- throw new Error(`"${snapId}" is not currently running.`);
270
- }
271
- (0, logging_1.log)('Parent: Sending Command', message);
272
- return await job.rpcEngine.handle(message);
273
- }
274
- /**
275
- * Handle RPC request.
276
- *
277
- * @param snapId - The ID of the recipient Snap.
278
- * @param options - Bag of options to pass to the RPC handler.
279
- * @returns Promise that can handle the request.
280
- */
281
- async handleRpcRequest(snapId, options) {
282
- const { handler, request, origin } = options;
283
- return await this.#command(snapId, {
284
- id: (0, nanoid_1.nanoid)(),
285
- jsonrpc: '2.0',
286
- method: 'snapRpc',
287
- params: {
288
- snapId,
289
- origin,
290
- handler,
291
- request: request,
292
- },
293
- });
294
- }
295
- }
296
- exports.AbstractExecutionService = AbstractExecutionService;
297
- /**
298
- * Sets up stream multiplexing for the given stream.
299
- *
300
- * @param connectionStream - The stream to mux.
301
- * @param streamName - The name of the stream, for identification in errors.
302
- * @returns The multiplexed stream.
303
- */
304
- function setupMultiplex(connectionStream, streamName) {
305
- const mux = new object_multiplex_1.default();
306
- (0, readable_stream_1.pipeline)(connectionStream, mux, connectionStream, (error) => {
307
- if (error && !error.message?.match('Premature close')) {
308
- (0, snaps_utils_1.logError)(`"${streamName}" stream failure.`, error);
309
- }
310
- });
311
- return mux;
312
- }
313
- exports.setupMultiplex = setupMultiplex;
314
- //# sourceMappingURL=AbstractExecutionService.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AbstractExecutionService.cjs","sourceRoot":"","sources":["../../src/services/AbstractExecutionService.ts"],"names":[],"mappings":";;;;;;AAAA,+DAA2D;AAC3D,qDAAgF;AAChF,qFAA8E;AAC9E,kFAAyD;AAGzD,uDAAgF;AAMhF,2CAKyB;AACzB,mCAAgC;AAChC,qDAA2C;AAS3C,4CAAiC;AACjC,8CAAuC;AACvC,wCAAoD;AAEpD,MAAM,cAAc,GAAG,kBAAkB,CAAC;AA6C1C,MAAsB,wBAAwB;IAG5C,IAAI,GAA0B,cAAc,CAAC;IAE7C,KAAK,GAAG,IAAI,CAAC;IAEJ,KAAK,CAA+B;IAEpC,OAAO,CAA+B;IAEtC,kBAAkB,CAAoB;IAEtC,UAAU,CAA4B;IAEtC,YAAY,CAAS;IAErB,YAAY,CAAS;IAErB,mBAAmB,CAAS;IAE5B,QAAQ,CAAU;IAE3B,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;IAClC,IAAA,0BAAQ,EAAC,gBAAgB,EAAE,GAAG,EAAE,gBAAgB,EAAE,CAAC,KAAK,EAAE,EAAE;QAC1D,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC;YACtD,IAAA,sBAAQ,EAAC,IAAI,UAAU,mBAAmB,EAAE,KAAK,CAAC,CAAC;QACrD,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACb,CAAC;AAXD,wCAWC","sourcesContent":["import { asV2Middleware } from '@metamask/json-rpc-engine';\nimport { JsonRpcEngineV2 as JsonRpcEngine } from '@metamask/json-rpc-engine/v2';\nimport { createStreamMiddleware } from '@metamask/json-rpc-middleware-stream';\nimport ObjectMultiplex from '@metamask/object-multiplex';\nimport type { BasePostMessageStream } from '@metamask/post-message-stream';\nimport type { SnapRpcHookArgs } from '@metamask/snaps-utils';\nimport { SNAP_STREAM_NAMES, logError, logWarning } from '@metamask/snaps-utils';\nimport type {\n Json,\n JsonRpcNotification,\n JsonRpcRequest,\n} from '@metamask/utils';\nimport {\n Duration,\n assertIsJsonRpcRequest,\n hasProperty,\n inMilliseconds,\n} from '@metamask/utils';\nimport { nanoid } from 'nanoid';\nimport { pipeline } from 'readable-stream';\nimport type { Duplex } from 'readable-stream';\n\nimport type {\n ExecutionService,\n ExecutionServiceMessenger,\n SnapErrorJson,\n SnapExecutionData,\n} from './ExecutionService';\nimport { log } from '../logging';\nimport { Timer } from '../snaps/Timer';\nimport { hasTimedOut, withTimeout } from '../utils';\n\nconst controllerName = 'ExecutionService';\n\nexport type SetupSnapProvider = (snapId: string, stream: Duplex) => void;\n\nexport type ExecutionServiceArgs = {\n setupSnapProvider: SetupSnapProvider;\n messenger: ExecutionServiceMessenger;\n initTimeout?: number;\n pingTimeout?: number;\n terminationTimeout?: number;\n usePing?: boolean;\n};\n\nexport type JobStreams = {\n command: Duplex;\n rpc: Duplex;\n connection: BasePostMessageStream;\n mux: ObjectMultiplex;\n};\n\nexport type Job<WorkerType> = {\n id: string;\n streams: JobStreams;\n rpcEngine: JsonRpcEngine<JsonRpcRequest>;\n worker: WorkerType;\n};\n\nexport type TerminateJobArgs<WorkerType> = Partial<Job<WorkerType>> &\n Pick<Job<WorkerType>, 'id'>;\n\n/** \n Statuses used for diagnostic purposes\n - created: The initial state, no initialization has started \n - initializing: Snap execution environment is initializing\n - initialized: Snap execution environment has initialized\n - executing: Snap source code is being executed\n - running: Snap executed and ready for RPC requests\n */\ntype ExecutionStatus =\n | 'created'\n | 'initializing'\n | 'initialized'\n | 'executing'\n | 'running';\n\nexport abstract class AbstractExecutionService<WorkerType>\n implements ExecutionService\n{\n name: typeof controllerName = controllerName;\n\n state = null;\n\n readonly #jobs: Map<string, Job<WorkerType>>;\n\n readonly #status: Map<string, ExecutionStatus>;\n\n readonly #setupSnapProvider: SetupSnapProvider;\n\n readonly #messenger: ExecutionServiceMessenger;\n\n readonly #initTimeout: number;\n\n readonly #pingTimeout: number;\n\n readonly #terminationTimeout: number;\n\n readonly #usePing: boolean;\n\n constructor({\n setupSnapProvider,\n messenger,\n initTimeout = inMilliseconds(60, Duration.Second),\n pingTimeout = inMilliseconds(10, Duration.Second),\n terminationTimeout = inMilliseconds(1, Duration.Second),\n usePing = true,\n }: ExecutionServiceArgs) {\n this.#jobs = new Map();\n this.#status = new Map();\n this.#setupSnapProvider = setupSnapProvider;\n this.#messenger = messenger;\n this.#initTimeout = initTimeout;\n this.#pingTimeout = pingTimeout;\n this.#terminationTimeout = terminationTimeout;\n this.#usePing = usePing;\n\n this.#registerMessageHandlers();\n }\n\n /**\n * Constructor helper for registering the controller's messaging system\n * actions.\n */\n #registerMessageHandlers(): void {\n this.#messenger.registerActionHandler(\n `${controllerName}:handleRpcRequest`,\n async (snapId: string, options: SnapRpcHookArgs) =>\n this.handleRpcRequest(snapId, options),\n );\n\n this.#messenger.registerActionHandler(\n `${controllerName}:executeSnap`,\n async (data: SnapExecutionData) => this.executeSnap(data),\n );\n\n this.#messenger.registerActionHandler(\n `${controllerName}:terminateSnap`,\n async (snapId: string) => this.terminateSnap(snapId),\n );\n\n this.#messenger.registerActionHandler(\n `${controllerName}:terminateAllSnaps`,\n async () => this.terminateAllSnaps(),\n );\n }\n\n /**\n * Performs additional necessary work during job termination. **MUST** be\n * implemented by concrete implementations. See\n * {@link AbstractExecutionService.terminate} for details.\n *\n * @param job - The object corresponding to the job to be terminated.\n */\n protected abstract terminateJob(\n job: TerminateJobArgs<WorkerType>,\n ): Promise<void>;\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 */\n public async terminateSnap(snapId: string): Promise<void> {\n const job = this.#jobs.get(snapId);\n if (!job) {\n return;\n }\n\n try {\n // Ping worker and tell it to run teardown, continue with termination if it takes too long\n const result = await withTimeout(\n this.#command(snapId, {\n jsonrpc: '2.0',\n method: 'terminate',\n id: nanoid(),\n }),\n this.#terminationTimeout,\n );\n\n if (result === hasTimedOut || result !== 'OK') {\n logWarning(`Snap \"${snapId}\" failed to terminate gracefully.`);\n }\n } catch {\n // Ignore\n }\n\n Object.values(job.streams).forEach((stream) => {\n try {\n if (!stream.destroyed) {\n stream.destroy();\n }\n } catch (error) {\n logError('Error while destroying stream', error);\n }\n });\n\n await this.terminateJob(job);\n\n this.#jobs.delete(snapId);\n this.#status.delete(snapId);\n log(`Snap \"${snapId}\" terminated.`);\n }\n\n /**\n * Initiates a job for a Snap.\n *\n * @param snapId - The ID of the Snap to initiate a job for.\n * @param timer - The timer to use for timeouts.\n * @returns Information regarding the created job.\n * @throws If the execution service returns an error or execution times out.\n */\n async #initJob(snapId: string, timer: Timer): Promise<Job<WorkerType>> {\n const { streams, worker } = await this.#initStreams(snapId, timer);\n\n const jsonRpcConnection = createStreamMiddleware();\n\n pipeline(\n jsonRpcConnection.stream,\n streams.command,\n jsonRpcConnection.stream,\n (error) => {\n if (error && !error.message?.match('Premature close')) {\n logError(`Command stream failure.`, error);\n }\n },\n );\n\n const rpcEngine = JsonRpcEngine.create({\n middleware: [asV2Middleware(jsonRpcConnection.middleware)],\n });\n\n const envMetadata = {\n id: snapId,\n streams,\n rpcEngine,\n worker,\n };\n this.#jobs.set(snapId, envMetadata);\n\n return envMetadata;\n }\n\n /**\n * Sets up the streams for an initiated job.\n *\n * @param snapId - The Snap ID.\n * @param timer - The timer to use for timeouts.\n * @returns The streams to communicate with the worker and the worker itself.\n * @throws If the execution service returns an error or execution times out.\n */\n async #initStreams(\n snapId: string,\n timer: Timer,\n ): Promise<{ streams: JobStreams; worker: WorkerType }> {\n const result = await withTimeout(this.initEnvStream(snapId), timer);\n\n if (result === hasTimedOut) {\n // For certain environments, such as the iframe we may have already created the worker and wish to terminate it.\n await this.terminateJob({ id: snapId });\n\n const status = this.#status.get(snapId);\n if (status === 'created') {\n // Currently this error can only be thrown by OffscreenExecutionService.\n throw new Error(\n `The executor for \"${snapId}\" couldn't start initialization. The offscreen document may not exist.`,\n );\n }\n throw new Error(\n `The executor for \"${snapId}\" failed to initialize. The iframe/webview/worker failed to load.`,\n );\n }\n\n const { worker, stream: envStream } = result;\n const mux = setupMultiplex(envStream, `Snap: \"${snapId}\"`);\n const commandStream = mux.createStream(SNAP_STREAM_NAMES.COMMAND);\n\n // Handle out-of-band errors, i.e. errors thrown from the Snap outside of the req/res cycle.\n // Also keep track of outbound request/responses\n const notificationHandler = (\n message:\n | JsonRpcRequest\n | JsonRpcNotification<Json[] | Record<string, Json>>,\n ) => {\n if (hasProperty(message, 'id')) {\n return;\n }\n\n if (message.method === 'OutboundRequest') {\n this.#messenger.publish('ExecutionService:outboundRequest', snapId);\n } else if (message.method === 'OutboundResponse') {\n this.#messenger.publish('ExecutionService:outboundResponse', snapId);\n } else if (message.method === 'UnhandledError') {\n this.#messenger.publish(\n 'ExecutionService:unhandledError',\n snapId,\n (message.params as { error: SnapErrorJson }).error,\n );\n commandStream.removeListener('data', notificationHandler);\n } else {\n logError(\n new Error(\n `Received unexpected command stream notification \"${message.method}\".`,\n ),\n );\n }\n };\n\n commandStream.on('data', notificationHandler);\n\n const rpcStream = mux\n .createStream(SNAP_STREAM_NAMES.JSON_RPC)\n .setMaxListeners(20);\n\n rpcStream.on('data', (chunk) => {\n if (chunk?.data && hasProperty(chunk?.data, 'id')) {\n this.#messenger.publish('ExecutionService:outboundRequest', snapId);\n }\n });\n\n // An error handler is not attached to the RPC stream until `setupSnapProvider` is called.\n // We must set it up here to prevent errors from bubbling up if the stream is destroyed before then.\n rpcStream.on('error', (error) => {\n if (error && !error.message?.match('Premature close')) {\n logError(`Snap: \"${snapId}\" - RPC stream failure:`, error);\n }\n });\n\n const originalWrite = rpcStream.write.bind(rpcStream);\n\n // @ts-expect-error Hack to inspect the messages being written to the stream.\n rpcStream.write = (chunk, encoding, callback) => {\n // Ignore chain switching notifications as it doesn't matter for the SnapProvider.\n if (chunk?.data?.method === 'metamask_chainChanged') {\n return true;\n }\n\n if (chunk?.data && hasProperty(chunk?.data, 'id')) {\n this.#messenger.publish('ExecutionService:outboundResponse', snapId);\n }\n\n return originalWrite(chunk, encoding, callback);\n };\n\n return {\n streams: {\n command: commandStream,\n rpc: rpcStream,\n connection: envStream,\n mux,\n },\n worker,\n };\n }\n\n /**\n * Abstract function implemented by implementing class that spins up a new worker for a job.\n *\n * Depending on the execution environment, this may run forever if the Snap fails to start up properly, therefore any call to this function should be wrapped in a timeout.\n */\n protected abstract initEnvStream(snapId: string): Promise<{\n worker: WorkerType;\n stream: BasePostMessageStream;\n }>;\n\n /**\n * Set the execution status of the Snap.\n *\n * @param snapId - The Snap ID.\n * @param status - The current execution status.\n */\n protected setSnapStatus(snapId: string, status: ExecutionStatus) {\n this.#status.set(snapId, status);\n }\n\n async terminateAllSnaps() {\n await Promise.all(\n [...this.#jobs.keys()].map(async (snapId) => this.terminateSnap(snapId)),\n );\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 */\n async executeSnap({\n snapId,\n sourceCode,\n endowments,\n }: SnapExecutionData): Promise<string> {\n if (this.#jobs.has(snapId)) {\n throw new Error(`\"${snapId}\" is already running.`);\n }\n\n this.setSnapStatus(snapId, 'created');\n\n const timer = new Timer(this.#initTimeout);\n\n // This may resolve even if the environment has failed to start up fully\n const job = await this.#initJob(snapId, timer);\n\n // Certain environments use ping as part of their initialization and thus can skip it here\n if (this.#usePing) {\n // Ping the worker to ensure that it started up\n const pingResult = await withTimeout(\n this.#command(job.id, {\n jsonrpc: '2.0',\n method: 'ping',\n id: nanoid(),\n }),\n this.#pingTimeout,\n );\n\n if (pingResult === hasTimedOut) {\n throw new Error(\n `The executor for \"${snapId}\" was unreachable. The executor did not respond in time.`,\n );\n }\n }\n\n const rpcStream = job.streams.rpc;\n\n this.#setupSnapProvider(snapId, rpcStream);\n\n // Use the remaining time as the timer, but ensure that the\n // Snap gets at least half the init timeout.\n const remainingTime = Math.max(timer.remaining, this.#initTimeout / 2);\n\n this.setSnapStatus(snapId, 'initialized');\n\n const request = {\n jsonrpc: '2.0',\n method: 'executeSnap',\n params: { snapId, sourceCode, endowments },\n id: nanoid(),\n };\n\n assertIsJsonRpcRequest(request);\n\n this.setSnapStatus(snapId, 'executing');\n\n const result = await withTimeout(\n this.#command(job.id, request),\n remainingTime,\n );\n\n if (result === hasTimedOut) {\n throw new Error(`${snapId} failed to start.`);\n }\n\n if (result === 'OK') {\n this.setSnapStatus(snapId, 'running');\n }\n\n return result as string;\n }\n\n async #command(\n snapId: string,\n message: JsonRpcRequest,\n ): Promise<Json | undefined> {\n const job = this.#jobs.get(snapId);\n if (!job) {\n throw new Error(`\"${snapId}\" is not currently running.`);\n }\n\n log('Parent: Sending Command', message);\n return await job.rpcEngine.handle(message);\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 */\n public async handleRpcRequest(\n snapId: string,\n options: SnapRpcHookArgs,\n ): Promise<unknown> {\n const { handler, request, origin } = options;\n\n return await this.#command(snapId, {\n id: nanoid(),\n jsonrpc: '2.0',\n method: 'snapRpc',\n params: {\n snapId,\n origin,\n handler,\n request: request as JsonRpcRequest,\n },\n });\n }\n}\n\n/**\n * Sets up stream multiplexing for the given stream.\n *\n * @param connectionStream - The stream to mux.\n * @param streamName - The name of the stream, for identification in errors.\n * @returns The multiplexed stream.\n */\nexport function setupMultiplex(\n connectionStream: Duplex,\n streamName: string,\n): ObjectMultiplex {\n const mux = new ObjectMultiplex();\n pipeline(connectionStream, mux, connectionStream, (error) => {\n if (error && !error.message?.match('Premature close')) {\n logError(`\"${streamName}\" stream failure.`, error);\n }\n });\n return mux;\n}\n"]}
@@ -1,107 +0,0 @@
1
- import { JsonRpcEngineV2 as JsonRpcEngine } from "@metamask/json-rpc-engine/v2";
2
- import ObjectMultiplex from "@metamask/object-multiplex";
3
- import type { BasePostMessageStream } from "@metamask/post-message-stream";
4
- import type { SnapRpcHookArgs } from "@metamask/snaps-utils";
5
- import type { JsonRpcRequest } from "@metamask/utils";
6
- import type { Duplex } from "readable-stream";
7
- import type { ExecutionService, ExecutionServiceMessenger, SnapExecutionData } from "./ExecutionService.cjs";
8
- declare const controllerName = "ExecutionService";
9
- export type SetupSnapProvider = (snapId: string, stream: Duplex) => void;
10
- export type ExecutionServiceArgs = {
11
- setupSnapProvider: SetupSnapProvider;
12
- messenger: ExecutionServiceMessenger;
13
- initTimeout?: number;
14
- pingTimeout?: number;
15
- terminationTimeout?: number;
16
- usePing?: boolean;
17
- };
18
- export type JobStreams = {
19
- command: Duplex;
20
- rpc: Duplex;
21
- connection: BasePostMessageStream;
22
- mux: ObjectMultiplex;
23
- };
24
- export type Job<WorkerType> = {
25
- id: string;
26
- streams: JobStreams;
27
- rpcEngine: JsonRpcEngine<JsonRpcRequest>;
28
- worker: WorkerType;
29
- };
30
- export type TerminateJobArgs<WorkerType> = Partial<Job<WorkerType>> & Pick<Job<WorkerType>, 'id'>;
31
- /**
32
- Statuses used for diagnostic purposes
33
- - created: The initial state, no initialization has started
34
- - initializing: Snap execution environment is initializing
35
- - initialized: Snap execution environment has initialized
36
- - executing: Snap source code is being executed
37
- - running: Snap executed and ready for RPC requests
38
- */
39
- type ExecutionStatus = 'created' | 'initializing' | 'initialized' | 'executing' | 'running';
40
- export declare abstract class AbstractExecutionService<WorkerType> implements ExecutionService {
41
- #private;
42
- name: typeof controllerName;
43
- state: null;
44
- constructor({ setupSnapProvider, messenger, initTimeout, pingTimeout, terminationTimeout, usePing, }: ExecutionServiceArgs);
45
- /**
46
- * Performs additional necessary work during job termination. **MUST** be
47
- * implemented by concrete implementations. See
48
- * {@link AbstractExecutionService.terminate} for details.
49
- *
50
- * @param job - The object corresponding to the job to be terminated.
51
- */
52
- protected abstract terminateJob(job: TerminateJobArgs<WorkerType>): Promise<void>;
53
- /**
54
- * Terminates the Snap with the specified ID and deletes all its associated
55
- * data. Any subsequent messages targeting the Snap will fail with an error.
56
- * Throws an error if termination fails unexpectedly.
57
- *
58
- * @param snapId - The id of the Snap to be terminated.
59
- */
60
- terminateSnap(snapId: string): Promise<void>;
61
- /**
62
- * Abstract function implemented by implementing class that spins up a new worker for a job.
63
- *
64
- * Depending on the execution environment, this may run forever if the Snap fails to start up properly, therefore any call to this function should be wrapped in a timeout.
65
- */
66
- protected abstract initEnvStream(snapId: string): Promise<{
67
- worker: WorkerType;
68
- stream: BasePostMessageStream;
69
- }>;
70
- /**
71
- * Set the execution status of the Snap.
72
- *
73
- * @param snapId - The Snap ID.
74
- * @param status - The current execution status.
75
- */
76
- protected setSnapStatus(snapId: string, status: ExecutionStatus): void;
77
- terminateAllSnaps(): Promise<void>;
78
- /**
79
- * Initializes and executes a Snap, setting up the communication channels to the Snap etc.
80
- *
81
- * @param snapData - Data needed for Snap execution.
82
- * @param snapData.snapId - The ID of the Snap to execute.
83
- * @param snapData.sourceCode - The source code of the Snap to execute.
84
- * @param snapData.endowments - The endowments available to the executing Snap.
85
- * @returns A string `OK` if execution succeeded.
86
- * @throws If the execution service returns an error or execution times out.
87
- */
88
- executeSnap({ snapId, sourceCode, endowments, }: SnapExecutionData): Promise<string>;
89
- /**
90
- * Handle RPC request.
91
- *
92
- * @param snapId - The ID of the recipient Snap.
93
- * @param options - Bag of options to pass to the RPC handler.
94
- * @returns Promise that can handle the request.
95
- */
96
- handleRpcRequest(snapId: string, options: SnapRpcHookArgs): Promise<unknown>;
97
- }
98
- /**
99
- * Sets up stream multiplexing for the given stream.
100
- *
101
- * @param connectionStream - The stream to mux.
102
- * @param streamName - The name of the stream, for identification in errors.
103
- * @returns The multiplexed stream.
104
- */
105
- export declare function setupMultiplex(connectionStream: Duplex, streamName: string): ObjectMultiplex;
106
- export {};
107
- //# sourceMappingURL=AbstractExecutionService.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AbstractExecutionService.d.cts","sourceRoot":"","sources":["../../src/services/AbstractExecutionService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,IAAI,aAAa,EAAE,qCAAqC;AAEhF,OAAO,eAAe,mCAAmC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,sCAAsC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAE7D,OAAO,KAAK,EAGV,cAAc,EACf,wBAAwB;AASzB,OAAO,KAAK,EAAE,MAAM,EAAE,wBAAwB;AAE9C,OAAO,KAAK,EACV,gBAAgB,EAChB,yBAAyB,EAEzB,iBAAiB,EAClB,+BAA2B;AAK5B,QAAA,MAAM,cAAc,qBAAqB,CAAC;AAE1C,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,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