@metamask/snaps-jest 5.0.0 → 6.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 (519) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/dist/chunk-2KLZ7GOW.js +15 -0
  3. package/dist/chunk-2KLZ7GOW.js.map +1 -0
  4. package/dist/chunk-2M7WQ26F.js +28 -0
  5. package/dist/chunk-2M7WQ26F.js.map +1 -0
  6. package/dist/chunk-34GS3AHA.js +33 -0
  7. package/dist/chunk-34GS3AHA.js.map +1 -0
  8. package/dist/chunk-3CC2NI7R.js +80 -0
  9. package/dist/chunk-3CC2NI7R.js.map +1 -0
  10. package/dist/chunk-3IUQA6YL.mjs +1 -0
  11. package/dist/chunk-3IUQA6YL.mjs.map +1 -0
  12. package/dist/chunk-3KCEPGJA.js +39 -0
  13. package/dist/chunk-3KCEPGJA.js.map +1 -0
  14. package/dist/chunk-3KQYPQZY.js +20 -0
  15. package/dist/chunk-3KQYPQZY.js.map +1 -0
  16. package/dist/chunk-3O5OISLU.js +16 -0
  17. package/dist/chunk-3O5OISLU.js.map +1 -0
  18. package/dist/chunk-3ZW2EE3B.js +1 -0
  19. package/dist/chunk-3ZW2EE3B.js.map +1 -0
  20. package/dist/chunk-4FCRZDOX.js +134 -0
  21. package/dist/chunk-4FCRZDOX.js.map +1 -0
  22. package/dist/chunk-4HY4SM3A.js +1 -0
  23. package/dist/chunk-4HY4SM3A.js.map +1 -0
  24. package/dist/chunk-4JUUFDTC.js +104 -0
  25. package/dist/chunk-4JUUFDTC.js.map +1 -0
  26. package/dist/chunk-4VCE3DRR.mjs +34 -0
  27. package/dist/chunk-4VCE3DRR.mjs.map +1 -0
  28. package/dist/chunk-4WCFXE73.js +48 -0
  29. package/dist/chunk-4WCFXE73.js.map +1 -0
  30. package/dist/chunk-5IUHGC5S.js +153 -0
  31. package/dist/chunk-5IUHGC5S.js.map +1 -0
  32. package/dist/chunk-5O6VBW42.js +42 -0
  33. package/dist/chunk-5O6VBW42.js.map +1 -0
  34. package/dist/chunk-6IMEYERE.js +137 -0
  35. package/dist/chunk-6IMEYERE.js.map +1 -0
  36. package/dist/chunk-6KNT4UMX.mjs +35 -0
  37. package/dist/chunk-6KNT4UMX.mjs.map +1 -0
  38. package/dist/chunk-6RDNSELT.mjs +39 -0
  39. package/dist/chunk-6RDNSELT.mjs.map +1 -0
  40. package/dist/chunk-72YN2D26.mjs +60 -0
  41. package/dist/chunk-72YN2D26.mjs.map +1 -0
  42. package/dist/chunk-7JLVQJK7.js +14 -0
  43. package/dist/chunk-7JLVQJK7.js.map +1 -0
  44. package/dist/chunk-AH7YNG6N.js +22 -0
  45. package/dist/chunk-AH7YNG6N.js.map +1 -0
  46. package/dist/chunk-AIZADBRK.mjs +36 -0
  47. package/dist/chunk-AIZADBRK.mjs.map +1 -0
  48. package/dist/chunk-AKFRQ5EJ.mjs +42 -0
  49. package/dist/chunk-AKFRQ5EJ.mjs.map +1 -0
  50. package/dist/chunk-AUB7XPDH.mjs +28 -0
  51. package/dist/chunk-AUB7XPDH.mjs.map +1 -0
  52. package/dist/chunk-BJMTD7H2.mjs +20 -0
  53. package/dist/chunk-BJMTD7H2.mjs.map +1 -0
  54. package/dist/chunk-BN5VBVT3.mjs +233 -0
  55. package/dist/chunk-BN5VBVT3.mjs.map +1 -0
  56. package/dist/chunk-CKOGTHM4.mjs +22 -0
  57. package/dist/chunk-CKOGTHM4.mjs.map +1 -0
  58. package/dist/chunk-CZQKOZLR.js +11 -0
  59. package/dist/chunk-CZQKOZLR.js.map +1 -0
  60. package/dist/chunk-D36QBJ35.js +24 -0
  61. package/dist/{cjs/internals/simulation/methods/hooks/show-dialog.js.map → chunk-D36QBJ35.js.map} +1 -1
  62. package/dist/chunk-DEFFA5IJ.mjs +24 -0
  63. package/dist/chunk-DEFFA5IJ.mjs.map +1 -0
  64. package/dist/chunk-EFB6AQPB.js +36 -0
  65. package/dist/chunk-EFB6AQPB.js.map +1 -0
  66. package/dist/chunk-EOCDSPT7.mjs +97 -0
  67. package/dist/chunk-EOCDSPT7.mjs.map +1 -0
  68. package/dist/chunk-FPFX5AKR.mjs +36 -0
  69. package/dist/chunk-FPFX5AKR.mjs.map +1 -0
  70. package/dist/chunk-HBT34TJ2.mjs +1 -0
  71. package/dist/chunk-HBT34TJ2.mjs.map +1 -0
  72. package/dist/chunk-HBVDXIVN.mjs +80 -0
  73. package/dist/chunk-HBVDXIVN.mjs.map +1 -0
  74. package/dist/chunk-HMF2CKYT.mjs +39 -0
  75. package/dist/chunk-HMF2CKYT.mjs.map +1 -0
  76. package/dist/chunk-HP56MLQ3.js +1 -0
  77. package/dist/chunk-HP56MLQ3.js.map +1 -0
  78. package/dist/chunk-I5LVU57H.mjs +69 -0
  79. package/dist/chunk-I5LVU57H.mjs.map +1 -0
  80. package/dist/chunk-I7FLOZU7.mjs +1 -0
  81. package/dist/chunk-I7FLOZU7.mjs.map +1 -0
  82. package/dist/chunk-J2ID3DS7.mjs +33 -0
  83. package/dist/chunk-J2ID3DS7.mjs.map +1 -0
  84. package/dist/chunk-JA7RJLI7.js +34 -0
  85. package/dist/chunk-JA7RJLI7.js.map +1 -0
  86. package/dist/chunk-JB2H2XEL.mjs +1 -0
  87. package/dist/chunk-JB2H2XEL.mjs.map +1 -0
  88. package/dist/chunk-JDN3VGMO.js +21 -0
  89. package/dist/chunk-JDN3VGMO.js.map +1 -0
  90. package/dist/chunk-JGQJFYU4.js +57 -0
  91. package/dist/chunk-JGQJFYU4.js.map +1 -0
  92. package/dist/chunk-JJCX335U.mjs +91 -0
  93. package/dist/chunk-JJCX335U.mjs.map +1 -0
  94. package/dist/chunk-JMDSN227.mjs +25 -0
  95. package/dist/chunk-JMDSN227.mjs.map +1 -0
  96. package/dist/chunk-JXOKRTEH.mjs +11 -0
  97. package/dist/chunk-JXOKRTEH.mjs.map +1 -0
  98. package/dist/chunk-JZJWUVD7.mjs +1 -0
  99. package/dist/chunk-JZJWUVD7.mjs.map +1 -0
  100. package/dist/chunk-K2KTKFLP.js +76 -0
  101. package/dist/chunk-K2KTKFLP.js.map +1 -0
  102. package/dist/chunk-KGIWSGTT.js +91 -0
  103. package/dist/chunk-KGIWSGTT.js.map +1 -0
  104. package/dist/chunk-KPXLJ6RH.js +60 -0
  105. package/dist/chunk-KPXLJ6RH.js.map +1 -0
  106. package/dist/chunk-LD5PSHHT.mjs +57 -0
  107. package/dist/chunk-LD5PSHHT.mjs.map +1 -0
  108. package/dist/chunk-LNNKGOHQ.mjs +16 -0
  109. package/dist/chunk-LNNKGOHQ.mjs.map +1 -0
  110. package/dist/chunk-MNDF32ZV.js +8 -0
  111. package/dist/chunk-MNDF32ZV.js.map +1 -0
  112. package/dist/chunk-MSQ7Q2VJ.mjs +13 -0
  113. package/dist/chunk-MSQ7Q2VJ.mjs.map +1 -0
  114. package/dist/chunk-O3VJYBFN.mjs +15 -0
  115. package/dist/chunk-O3VJYBFN.mjs.map +1 -0
  116. package/dist/chunk-O4MJRHZD.js +69 -0
  117. package/dist/chunk-O4MJRHZD.js.map +1 -0
  118. package/dist/chunk-OC64PNDU.mjs +21 -0
  119. package/dist/chunk-OC64PNDU.mjs.map +1 -0
  120. package/dist/chunk-ON6M4WG5.js +36 -0
  121. package/dist/chunk-ON6M4WG5.js.map +1 -0
  122. package/dist/chunk-P7JA42ZC.mjs +153 -0
  123. package/dist/chunk-P7JA42ZC.mjs.map +1 -0
  124. package/dist/chunk-PHUTP7NB.js +25 -0
  125. package/dist/chunk-PHUTP7NB.js.map +1 -0
  126. package/dist/chunk-QFPRGU5L.mjs +104 -0
  127. package/dist/chunk-QFPRGU5L.mjs.map +1 -0
  128. package/dist/chunk-QMHWGASM.js +1 -0
  129. package/dist/chunk-QMHWGASM.js.map +1 -0
  130. package/dist/chunk-QNDLJ2W7.js +1 -0
  131. package/dist/chunk-QNDLJ2W7.js.map +1 -0
  132. package/dist/chunk-QUUILTDY.mjs +137 -0
  133. package/dist/chunk-QUUILTDY.mjs.map +1 -0
  134. package/dist/chunk-R7ORBTUD.js +1 -0
  135. package/dist/chunk-R7ORBTUD.js.map +1 -0
  136. package/dist/chunk-RQBZLDXL.js +233 -0
  137. package/dist/chunk-RQBZLDXL.js.map +1 -0
  138. package/dist/chunk-S3DHQTXB.js +1 -0
  139. package/dist/chunk-S3DHQTXB.js.map +1 -0
  140. package/dist/chunk-SWSSV3LK.js +35 -0
  141. package/dist/chunk-SWSSV3LK.js.map +1 -0
  142. package/dist/chunk-T4TRX3ZR.js +22 -0
  143. package/dist/chunk-T4TRX3ZR.js.map +1 -0
  144. package/dist/chunk-UXHKMILA.mjs +1 -0
  145. package/dist/chunk-UXHKMILA.mjs.map +1 -0
  146. package/dist/chunk-VCXM6FKU.mjs +1 -0
  147. package/dist/chunk-VCXM6FKU.mjs.map +1 -0
  148. package/dist/chunk-VHTVUQWR.mjs +14 -0
  149. package/dist/chunk-VHTVUQWR.mjs.map +1 -0
  150. package/dist/chunk-VNQIROKZ.js +97 -0
  151. package/dist/chunk-VNQIROKZ.js.map +1 -0
  152. package/dist/chunk-VXQOXWRO.mjs +48 -0
  153. package/dist/chunk-VXQOXWRO.mjs.map +1 -0
  154. package/dist/chunk-VYKYQSUI.mjs +22 -0
  155. package/dist/chunk-VYKYQSUI.mjs.map +1 -0
  156. package/dist/chunk-WEI35OIM.mjs +8 -0
  157. package/dist/chunk-WEI35OIM.mjs.map +1 -0
  158. package/dist/chunk-WL2GRM5E.mjs +76 -0
  159. package/dist/chunk-WL2GRM5E.mjs.map +1 -0
  160. package/dist/chunk-XDZPH5WD.js +39 -0
  161. package/dist/chunk-XDZPH5WD.js.map +1 -0
  162. package/dist/chunk-Y5NWZU43.js +13 -0
  163. package/dist/chunk-Y5NWZU43.js.map +1 -0
  164. package/dist/chunk-YZFWCFMG.js +1 -0
  165. package/dist/chunk-YZFWCFMG.js.map +1 -0
  166. package/dist/chunk-ZCE26WZM.mjs +1 -0
  167. package/dist/chunk-ZCE26WZM.mjs.map +1 -0
  168. package/dist/chunk-ZZPKZRJQ.mjs +134 -0
  169. package/dist/chunk-ZZPKZRJQ.mjs.map +1 -0
  170. package/dist/environment.js +47 -0
  171. package/dist/environment.js.map +1 -0
  172. package/dist/environment.mjs +47 -0
  173. package/dist/environment.mjs.map +1 -0
  174. package/dist/helpers.js +44 -0
  175. package/dist/helpers.js.map +1 -0
  176. package/dist/helpers.mjs +44 -0
  177. package/dist/helpers.mjs.map +1 -0
  178. package/dist/index.js +54 -0
  179. package/dist/index.js.map +1 -0
  180. package/dist/index.mjs +54 -0
  181. package/dist/index.mjs.map +1 -0
  182. package/dist/internals/environment.js +8 -0
  183. package/dist/internals/environment.js.map +1 -0
  184. package/dist/internals/environment.mjs +8 -0
  185. package/dist/internals/environment.mjs.map +1 -0
  186. package/dist/internals/index.js +123 -0
  187. package/dist/internals/index.js.map +1 -0
  188. package/dist/internals/index.mjs +123 -0
  189. package/dist/internals/index.mjs.map +1 -0
  190. package/dist/internals/logger.js +8 -0
  191. package/dist/internals/logger.js.map +1 -0
  192. package/dist/internals/logger.mjs +8 -0
  193. package/dist/internals/logger.mjs.map +1 -0
  194. package/dist/internals/request.js +40 -0
  195. package/dist/internals/request.js.map +1 -0
  196. package/dist/internals/request.mjs +40 -0
  197. package/dist/internals/request.mjs.map +1 -0
  198. package/dist/internals/server.js +9 -0
  199. package/dist/internals/server.js.map +1 -0
  200. package/dist/internals/server.mjs +9 -0
  201. package/dist/internals/server.mjs.map +1 -0
  202. package/dist/internals/simulation/constants.js +12 -0
  203. package/dist/internals/simulation/constants.js.map +1 -0
  204. package/dist/internals/simulation/constants.mjs +12 -0
  205. package/dist/internals/simulation/constants.mjs.map +1 -0
  206. package/dist/internals/simulation/controllers.js +26 -0
  207. package/dist/internals/simulation/controllers.js.map +1 -0
  208. package/dist/internals/simulation/controllers.mjs +26 -0
  209. package/dist/internals/simulation/controllers.mjs.map +1 -0
  210. package/dist/internals/simulation/files.js +8 -0
  211. package/dist/internals/simulation/files.js.map +1 -0
  212. package/dist/internals/simulation/files.mjs +8 -0
  213. package/dist/internals/simulation/files.mjs.map +1 -0
  214. package/dist/internals/simulation/index.js +90 -0
  215. package/dist/internals/simulation/index.js.map +1 -0
  216. package/dist/internals/simulation/index.mjs +90 -0
  217. package/dist/internals/simulation/index.mjs.map +1 -0
  218. package/dist/internals/simulation/interface.js +16 -0
  219. package/dist/internals/simulation/interface.js.map +1 -0
  220. package/dist/internals/simulation/interface.mjs +16 -0
  221. package/dist/internals/simulation/interface.mjs.map +1 -0
  222. package/dist/internals/simulation/methods/constants.js +12 -0
  223. package/dist/internals/simulation/methods/constants.js.map +1 -0
  224. package/dist/internals/simulation/methods/constants.mjs +12 -0
  225. package/dist/internals/simulation/methods/constants.mjs.map +1 -0
  226. package/dist/internals/simulation/methods/hooks/encryption.js +10 -0
  227. package/dist/internals/simulation/methods/hooks/encryption.js.map +1 -0
  228. package/dist/internals/simulation/methods/hooks/encryption.mjs +10 -0
  229. package/dist/internals/simulation/methods/hooks/encryption.mjs.map +1 -0
  230. package/dist/internals/simulation/methods/hooks/get-locale.js +8 -0
  231. package/dist/internals/simulation/methods/hooks/get-locale.js.map +1 -0
  232. package/dist/internals/simulation/methods/hooks/get-locale.mjs +8 -0
  233. package/dist/internals/simulation/methods/hooks/get-locale.mjs.map +1 -0
  234. package/dist/internals/simulation/methods/hooks/index.js +45 -0
  235. package/dist/internals/simulation/methods/hooks/index.js.map +1 -0
  236. package/dist/internals/simulation/methods/hooks/index.mjs +45 -0
  237. package/dist/internals/simulation/methods/hooks/index.mjs.map +1 -0
  238. package/dist/internals/simulation/methods/hooks/interface.js +10 -0
  239. package/dist/internals/simulation/methods/hooks/interface.js.map +1 -0
  240. package/dist/internals/simulation/methods/hooks/interface.mjs +10 -0
  241. package/dist/internals/simulation/methods/hooks/interface.mjs.map +1 -0
  242. package/dist/internals/simulation/methods/hooks/notifications.js +16 -0
  243. package/dist/internals/simulation/methods/hooks/notifications.js.map +1 -0
  244. package/dist/internals/simulation/methods/hooks/notifications.mjs +16 -0
  245. package/dist/internals/simulation/methods/hooks/notifications.mjs.map +1 -0
  246. package/dist/internals/simulation/methods/hooks/show-dialog.js +14 -0
  247. package/dist/internals/simulation/methods/hooks/show-dialog.js.map +1 -0
  248. package/dist/internals/simulation/methods/hooks/show-dialog.mjs +14 -0
  249. package/dist/internals/simulation/methods/hooks/show-dialog.mjs.map +1 -0
  250. package/dist/internals/simulation/methods/hooks/state.js +18 -0
  251. package/dist/internals/simulation/methods/hooks/state.js.map +1 -0
  252. package/dist/internals/simulation/methods/hooks/state.mjs +18 -0
  253. package/dist/internals/simulation/methods/hooks/state.mjs.map +1 -0
  254. package/dist/internals/simulation/methods/index.js +29 -0
  255. package/dist/internals/simulation/methods/index.js.map +1 -0
  256. package/dist/internals/simulation/methods/index.mjs +29 -0
  257. package/dist/internals/simulation/methods/index.mjs.map +1 -0
  258. package/dist/internals/simulation/methods/specifications.js +28 -0
  259. package/dist/internals/simulation/methods/specifications.js.map +1 -0
  260. package/dist/internals/simulation/methods/specifications.mjs +28 -0
  261. package/dist/internals/simulation/methods/specifications.mjs.map +1 -0
  262. package/dist/internals/simulation/middleware/engine.js +15 -0
  263. package/dist/internals/simulation/middleware/engine.js.map +1 -0
  264. package/dist/internals/simulation/middleware/engine.mjs +15 -0
  265. package/dist/internals/simulation/middleware/engine.mjs.map +1 -0
  266. package/dist/internals/simulation/middleware/index.js +16 -0
  267. package/dist/internals/simulation/middleware/index.js.map +1 -0
  268. package/dist/internals/simulation/middleware/index.mjs +16 -0
  269. package/dist/internals/simulation/middleware/index.mjs.map +1 -0
  270. package/dist/internals/simulation/middleware/internal-methods/accounts.js +8 -0
  271. package/dist/internals/simulation/middleware/internal-methods/accounts.js.map +1 -0
  272. package/dist/internals/simulation/middleware/internal-methods/accounts.mjs +8 -0
  273. package/dist/internals/simulation/middleware/internal-methods/accounts.mjs.map +1 -0
  274. package/dist/internals/simulation/middleware/internal-methods/index.js +11 -0
  275. package/dist/internals/simulation/middleware/internal-methods/index.js.map +1 -0
  276. package/dist/internals/simulation/middleware/internal-methods/index.mjs +11 -0
  277. package/dist/internals/simulation/middleware/internal-methods/index.mjs.map +1 -0
  278. package/dist/internals/simulation/middleware/internal-methods/middleware.js +10 -0
  279. package/dist/internals/simulation/middleware/internal-methods/middleware.js.map +1 -0
  280. package/dist/internals/simulation/middleware/internal-methods/middleware.mjs +10 -0
  281. package/dist/internals/simulation/middleware/internal-methods/middleware.mjs.map +1 -0
  282. package/dist/internals/simulation/middleware/internal-methods/provider-state.js +8 -0
  283. package/dist/internals/simulation/middleware/internal-methods/provider-state.js.map +1 -0
  284. package/dist/internals/simulation/middleware/internal-methods/provider-state.mjs +8 -0
  285. package/dist/internals/simulation/middleware/internal-methods/provider-state.mjs.map +1 -0
  286. package/dist/internals/simulation/middleware/mock.js +9 -0
  287. package/dist/internals/simulation/middleware/mock.js.map +1 -0
  288. package/dist/internals/simulation/middleware/mock.mjs +9 -0
  289. package/dist/internals/simulation/middleware/mock.mjs.map +1 -0
  290. package/dist/internals/simulation/options.js +9 -0
  291. package/dist/internals/simulation/options.js.map +1 -0
  292. package/dist/internals/simulation/options.mjs +9 -0
  293. package/dist/internals/simulation/options.mjs.map +1 -0
  294. package/dist/internals/simulation/simulation.js +39 -0
  295. package/dist/internals/simulation/simulation.js.map +1 -0
  296. package/dist/internals/simulation/simulation.mjs +39 -0
  297. package/dist/internals/simulation/simulation.mjs.map +1 -0
  298. package/dist/internals/simulation/store/index.js +44 -0
  299. package/dist/internals/simulation/store/index.js.map +1 -0
  300. package/dist/internals/simulation/store/index.mjs +44 -0
  301. package/dist/internals/simulation/store/index.mjs.map +1 -0
  302. package/dist/internals/simulation/store/mocks.js +16 -0
  303. package/dist/internals/simulation/store/mocks.js.map +1 -0
  304. package/dist/internals/simulation/store/mocks.mjs +16 -0
  305. package/dist/internals/simulation/store/mocks.mjs.map +1 -0
  306. package/dist/internals/simulation/store/notifications.js +16 -0
  307. package/dist/internals/simulation/store/notifications.js.map +1 -0
  308. package/dist/internals/simulation/store/notifications.mjs +16 -0
  309. package/dist/internals/simulation/store/notifications.mjs.map +1 -0
  310. package/dist/internals/simulation/store/state.js +14 -0
  311. package/dist/internals/simulation/store/state.js.map +1 -0
  312. package/dist/internals/simulation/store/state.mjs +14 -0
  313. package/dist/internals/simulation/store/state.mjs.map +1 -0
  314. package/dist/internals/simulation/store/store.js +12 -0
  315. package/dist/internals/simulation/store/store.js.map +1 -0
  316. package/dist/internals/simulation/store/store.mjs +12 -0
  317. package/dist/internals/simulation/store/store.mjs.map +1 -0
  318. package/dist/internals/simulation/store/ui.js +16 -0
  319. package/dist/internals/simulation/store/ui.js.map +1 -0
  320. package/dist/internals/simulation/store/ui.mjs +16 -0
  321. package/dist/internals/simulation/store/ui.mjs.map +1 -0
  322. package/dist/internals/structs.js +18 -0
  323. package/dist/internals/structs.js.map +1 -0
  324. package/dist/internals/structs.mjs +18 -0
  325. package/dist/internals/structs.mjs.map +1 -0
  326. package/dist/matchers.js +50 -0
  327. package/dist/matchers.js.map +1 -0
  328. package/dist/matchers.mjs +50 -0
  329. package/dist/matchers.mjs.map +1 -0
  330. package/dist/options.js +8 -0
  331. package/dist/options.js.map +1 -0
  332. package/dist/options.mjs +8 -0
  333. package/dist/options.mjs.map +1 -0
  334. package/dist/setup.js +39 -0
  335. package/dist/setup.js.map +1 -0
  336. package/dist/setup.mjs +39 -0
  337. package/dist/setup.mjs.map +1 -0
  338. package/dist/tsconfig.build.tsbuildinfo +1 -0
  339. package/dist/types/vendor/readable-stream.d.js +1 -0
  340. package/dist/types/vendor/readable-stream.d.js.map +1 -0
  341. package/dist/types/vendor/readable-stream.d.mjs +1 -0
  342. package/dist/types/vendor/readable-stream.d.mjs.map +1 -0
  343. package/dist/types.js +2 -0
  344. package/dist/types.js.map +1 -0
  345. package/dist/types.mjs +2 -0
  346. package/dist/types.mjs.map +1 -0
  347. package/jest-preset.js +1 -1
  348. package/package.json +24 -20
  349. package/dist/cjs/environment.js +0 -144
  350. package/dist/cjs/environment.js.map +0 -1
  351. package/dist/cjs/helpers.js +0 -142
  352. package/dist/cjs/helpers.js.map +0 -1
  353. package/dist/cjs/index.js +0 -42
  354. package/dist/cjs/index.js.map +0 -1
  355. package/dist/cjs/internals/environment.js +0 -19
  356. package/dist/cjs/internals/environment.js.map +0 -1
  357. package/dist/cjs/internals/index.js +0 -25
  358. package/dist/cjs/internals/index.js.map +0 -1
  359. package/dist/cjs/internals/logger.js +0 -14
  360. package/dist/cjs/internals/logger.js.map +0 -1
  361. package/dist/cjs/internals/request.js +0 -69
  362. package/dist/cjs/internals/request.js.map +0 -1
  363. package/dist/cjs/internals/server.js +0 -71
  364. package/dist/cjs/internals/server.js.map +0 -1
  365. package/dist/cjs/internals/simulation/constants.js +0 -29
  366. package/dist/cjs/internals/simulation/constants.js.map +0 -1
  367. package/dist/cjs/internals/simulation/controllers.js +0 -95
  368. package/dist/cjs/internals/simulation/controllers.js.map +0 -1
  369. package/dist/cjs/internals/simulation/files.js +0 -22
  370. package/dist/cjs/internals/simulation/files.js.map +0 -1
  371. package/dist/cjs/internals/simulation/index.js +0 -24
  372. package/dist/cjs/internals/simulation/index.js.map +0 -1
  373. package/dist/cjs/internals/simulation/interface.js +0 -98
  374. package/dist/cjs/internals/simulation/interface.js.map +0 -1
  375. package/dist/cjs/internals/simulation/methods/constants.js +0 -84
  376. package/dist/cjs/internals/simulation/methods/constants.js.map +0 -1
  377. package/dist/cjs/internals/simulation/methods/hooks/encryption.js +0 -33
  378. package/dist/cjs/internals/simulation/methods/hooks/encryption.js.map +0 -1
  379. package/dist/cjs/internals/simulation/methods/hooks/get-locale.js +0 -17
  380. package/dist/cjs/internals/simulation/methods/hooks/get-locale.js.map +0 -1
  381. package/dist/cjs/internals/simulation/methods/hooks/index.js +0 -25
  382. package/dist/cjs/internals/simulation/methods/hooks/index.js.map +0 -1
  383. package/dist/cjs/internals/simulation/methods/hooks/interface.js +0 -26
  384. package/dist/cjs/internals/simulation/methods/hooks/interface.js.map +0 -1
  385. package/dist/cjs/internals/simulation/methods/hooks/notifications.js +0 -66
  386. package/dist/cjs/internals/simulation/methods/hooks/notifications.js.map +0 -1
  387. package/dist/cjs/internals/simulation/methods/hooks/show-dialog.js +0 -43
  388. package/dist/cjs/internals/simulation/methods/hooks/state.js +0 -80
  389. package/dist/cjs/internals/simulation/methods/hooks/state.js.map +0 -1
  390. package/dist/cjs/internals/simulation/methods/index.js +0 -20
  391. package/dist/cjs/internals/simulation/methods/index.js.map +0 -1
  392. package/dist/cjs/internals/simulation/methods/specifications.js +0 -81
  393. package/dist/cjs/internals/simulation/methods/specifications.js.map +0 -1
  394. package/dist/cjs/internals/simulation/middleware/engine.js +0 -31
  395. package/dist/cjs/internals/simulation/middleware/engine.js.map +0 -1
  396. package/dist/cjs/internals/simulation/middleware/index.js +0 -20
  397. package/dist/cjs/internals/simulation/middleware/index.js.map +0 -1
  398. package/dist/cjs/internals/simulation/middleware/internal-methods/accounts.js +0 -30
  399. package/dist/cjs/internals/simulation/middleware/internal-methods/accounts.js.map +0 -1
  400. package/dist/cjs/internals/simulation/middleware/internal-methods/index.js +0 -20
  401. package/dist/cjs/internals/simulation/middleware/internal-methods/index.js.map +0 -1
  402. package/dist/cjs/internals/simulation/middleware/internal-methods/middleware.js +0 -37
  403. package/dist/cjs/internals/simulation/middleware/internal-methods/middleware.js.map +0 -1
  404. package/dist/cjs/internals/simulation/middleware/internal-methods/provider-state.js +0 -23
  405. package/dist/cjs/internals/simulation/middleware/internal-methods/provider-state.js.map +0 -1
  406. package/dist/cjs/internals/simulation/middleware/mock.js +0 -23
  407. package/dist/cjs/internals/simulation/middleware/mock.js.map +0 -1
  408. package/dist/cjs/internals/simulation/options.js +0 -24
  409. package/dist/cjs/internals/simulation/options.js.map +0 -1
  410. package/dist/cjs/internals/simulation/simulation.js +0 -124
  411. package/dist/cjs/internals/simulation/simulation.js.map +0 -1
  412. package/dist/cjs/internals/simulation/store/index.js +0 -23
  413. package/dist/cjs/internals/simulation/store/index.js.map +0 -1
  414. package/dist/cjs/internals/simulation/store/mocks.js +0 -52
  415. package/dist/cjs/internals/simulation/store/mocks.js.map +0 -1
  416. package/dist/cjs/internals/simulation/store/notifications.js +0 -52
  417. package/dist/cjs/internals/simulation/store/notifications.js.map +0 -1
  418. package/dist/cjs/internals/simulation/store/state.js +0 -64
  419. package/dist/cjs/internals/simulation/store/state.js.map +0 -1
  420. package/dist/cjs/internals/simulation/store/store.js +0 -57
  421. package/dist/cjs/internals/simulation/store/store.js.map +0 -1
  422. package/dist/cjs/internals/simulation/store/ui.js +0 -48
  423. package/dist/cjs/internals/simulation/store/ui.js.map +0 -1
  424. package/dist/cjs/internals/structs.js +0 -165
  425. package/dist/cjs/internals/structs.js.map +0 -1
  426. package/dist/cjs/matchers.js +0 -120
  427. package/dist/cjs/matchers.js.map +0 -1
  428. package/dist/cjs/options.js +0 -23
  429. package/dist/cjs/options.js.map +0 -1
  430. package/dist/cjs/setup.js +0 -10
  431. package/dist/cjs/setup.js.map +0 -1
  432. package/dist/cjs/types.js +0 -6
  433. package/dist/cjs/types.js.map +0 -1
  434. package/dist/esm/environment.js +0 -121
  435. package/dist/esm/environment.js.map +0 -1
  436. package/dist/esm/helpers.js +0 -163
  437. package/dist/esm/helpers.js.map +0 -1
  438. package/dist/esm/index.js +0 -6
  439. package/dist/esm/index.js.map +0 -1
  440. package/dist/esm/internals/environment.js +0 -14
  441. package/dist/esm/internals/environment.js.map +0 -1
  442. package/dist/esm/internals/index.js +0 -8
  443. package/dist/esm/internals/index.js.map +0 -1
  444. package/dist/esm/internals/logger.js +0 -4
  445. package/dist/esm/internals/logger.js.map +0 -1
  446. package/dist/esm/internals/request.js +0 -77
  447. package/dist/esm/internals/request.js.map +0 -1
  448. package/dist/esm/internals/server.js +0 -64
  449. package/dist/esm/internals/server.js.map +0 -1
  450. package/dist/esm/internals/simulation/constants.js +0 -12
  451. package/dist/esm/internals/simulation/constants.js.map +0 -1
  452. package/dist/esm/internals/simulation/controllers.js +0 -90
  453. package/dist/esm/internals/simulation/controllers.js.map +0 -1
  454. package/dist/esm/internals/simulation/files.js +0 -19
  455. package/dist/esm/internals/simulation/files.js.map +0 -1
  456. package/dist/esm/internals/simulation/index.js +0 -7
  457. package/dist/esm/internals/simulation/index.js.map +0 -1
  458. package/dist/esm/internals/simulation/interface.js +0 -95
  459. package/dist/esm/internals/simulation/interface.js.map +0 -1
  460. package/dist/esm/internals/simulation/methods/constants.js +0 -69
  461. package/dist/esm/internals/simulation/methods/constants.js.map +0 -1
  462. package/dist/esm/internals/simulation/methods/hooks/encryption.js +0 -39
  463. package/dist/esm/internals/simulation/methods/hooks/encryption.js.map +0 -1
  464. package/dist/esm/internals/simulation/methods/hooks/get-locale.js +0 -13
  465. package/dist/esm/internals/simulation/methods/hooks/get-locale.js.map +0 -1
  466. package/dist/esm/internals/simulation/methods/hooks/index.js +0 -8
  467. package/dist/esm/internals/simulation/methods/hooks/index.js.map +0 -1
  468. package/dist/esm/internals/simulation/methods/hooks/interface.js +0 -18
  469. package/dist/esm/internals/simulation/methods/hooks/interface.js.map +0 -1
  470. package/dist/esm/internals/simulation/methods/hooks/notifications.js +0 -58
  471. package/dist/esm/internals/simulation/methods/hooks/notifications.js.map +0 -1
  472. package/dist/esm/internals/simulation/methods/hooks/show-dialog.js +0 -38
  473. package/dist/esm/internals/simulation/methods/hooks/show-dialog.js.map +0 -1
  474. package/dist/esm/internals/simulation/methods/hooks/state.js +0 -74
  475. package/dist/esm/internals/simulation/methods/hooks/state.js.map +0 -1
  476. package/dist/esm/internals/simulation/methods/index.js +0 -3
  477. package/dist/esm/internals/simulation/methods/index.js.map +0 -1
  478. package/dist/esm/internals/simulation/methods/specifications.js +0 -84
  479. package/dist/esm/internals/simulation/methods/specifications.js.map +0 -1
  480. package/dist/esm/internals/simulation/middleware/engine.js +0 -33
  481. package/dist/esm/internals/simulation/middleware/engine.js.map +0 -1
  482. package/dist/esm/internals/simulation/middleware/index.js +0 -3
  483. package/dist/esm/internals/simulation/middleware/index.js.map +0 -1
  484. package/dist/esm/internals/simulation/middleware/internal-methods/accounts.js +0 -31
  485. package/dist/esm/internals/simulation/middleware/internal-methods/accounts.js.map +0 -1
  486. package/dist/esm/internals/simulation/middleware/internal-methods/index.js +0 -3
  487. package/dist/esm/internals/simulation/middleware/internal-methods/index.js.map +0 -1
  488. package/dist/esm/internals/simulation/middleware/internal-methods/middleware.js +0 -37
  489. package/dist/esm/internals/simulation/middleware/internal-methods/middleware.js.map +0 -1
  490. package/dist/esm/internals/simulation/middleware/internal-methods/provider-state.js +0 -23
  491. package/dist/esm/internals/simulation/middleware/internal-methods/provider-state.js.map +0 -1
  492. package/dist/esm/internals/simulation/middleware/mock.js +0 -18
  493. package/dist/esm/internals/simulation/middleware/mock.js.map +0 -1
  494. package/dist/esm/internals/simulation/options.js +0 -20
  495. package/dist/esm/internals/simulation/options.js.map +0 -1
  496. package/dist/esm/internals/simulation/simulation.js +0 -128
  497. package/dist/esm/internals/simulation/simulation.js.map +0 -1
  498. package/dist/esm/internals/simulation/store/index.js +0 -6
  499. package/dist/esm/internals/simulation/store/index.js.map +0 -1
  500. package/dist/esm/internals/simulation/store/mocks.js +0 -32
  501. package/dist/esm/internals/simulation/store/mocks.js.map +0 -1
  502. package/dist/esm/internals/simulation/store/notifications.js +0 -30
  503. package/dist/esm/internals/simulation/store/notifications.js.map +0 -1
  504. package/dist/esm/internals/simulation/store/state.js +0 -47
  505. package/dist/esm/internals/simulation/store/state.js.map +0 -1
  506. package/dist/esm/internals/simulation/store/store.js +0 -50
  507. package/dist/esm/internals/simulation/store/store.js.map +0 -1
  508. package/dist/esm/internals/simulation/store/ui.js +0 -21
  509. package/dist/esm/internals/simulation/store/ui.js.map +0 -1
  510. package/dist/esm/internals/structs.js +0 -135
  511. package/dist/esm/internals/structs.js.map +0 -1
  512. package/dist/esm/matchers.js +0 -111
  513. package/dist/esm/matchers.js.map +0 -1
  514. package/dist/esm/options.js +0 -20
  515. package/dist/esm/options.js.map +0 -1
  516. package/dist/esm/setup.js +0 -6
  517. package/dist/esm/setup.js.map +0 -1
  518. package/dist/esm/types.js +0 -3
  519. package/dist/esm/types.js.map +0 -1
@@ -1,77 +0,0 @@
1
- import { unwrapError } from '@metamask/snaps-utils';
2
- import { getSafeJson, hasProperty, isPlainObject } from '@metamask/utils';
3
- import { nanoid } from '@reduxjs/toolkit';
4
- import { clearNotifications, getInterface, getNotifications } from './simulation';
5
- /**
6
- * Send a JSON-RPC request to the Snap, and wrap the response in a
7
- * {@link SnapResponse} object.
8
- *
9
- * @param options - The request options.
10
- * @param options.snapId - The ID of the Snap to send the request to.
11
- * @param options.store - The Redux store.
12
- * @param options.executionService - The execution service to use to send the
13
- * request.
14
- * @param options.handler - The handler to use to send the request.
15
- * @param options.controllerMessenger - The controller messenger used to call actions.
16
- * @param options.runSaga - A function to run a saga outside the usual Redux
17
- * flow.
18
- * @param options.request - The request to send.
19
- * @param options.request.id - The ID of the request. If not provided, a random
20
- * ID will be generated.
21
- * @param options.request.origin - The origin of the request. Defaults to
22
- * `https://metamask.io`.
23
- * @returns The response, wrapped in a {@link SnapResponse} object.
24
- */ export function handleRequest({ snapId, store, executionService, handler, controllerMessenger, runSaga, request: { id = nanoid(), origin = 'https://metamask.io', ...options } }) {
25
- const promise = executionService.handleRpcRequest(snapId, {
26
- origin,
27
- handler,
28
- request: {
29
- jsonrpc: '2.0',
30
- id: 1,
31
- ...options
32
- }
33
- }).then((result)=>{
34
- const notifications = getNotifications(store.getState());
35
- store.dispatch(clearNotifications());
36
- const content = getContentFromResult(result, snapId, controllerMessenger);
37
- return {
38
- id: String(id),
39
- response: {
40
- result: getSafeJson(result)
41
- },
42
- notifications,
43
- content
44
- };
45
- }).catch((error)=>{
46
- const [unwrappedError] = unwrapError(error);
47
- return {
48
- id: String(id),
49
- response: {
50
- error: unwrappedError.serialize()
51
- },
52
- notifications: []
53
- };
54
- });
55
- promise.getInterface = async ()=>{
56
- return await runSaga(getInterface, runSaga, snapId, controllerMessenger).toPromise();
57
- };
58
- return promise;
59
- }
60
- /**
61
- * Get the response content either from the SnapInterfaceController or the response object if there is one.
62
- *
63
- * @param result - The handler result object.
64
- * @param snapId - The Snap ID.
65
- * @param controllerMessenger - The controller messenger.
66
- * @returns The content components if any.
67
- */ export function getContentFromResult(result, snapId, controllerMessenger) {
68
- if (isPlainObject(result) && hasProperty(result, 'id')) {
69
- return controllerMessenger.call('SnapInterfaceController:getInterface', snapId, result.id).content;
70
- }
71
- if (isPlainObject(result) && hasProperty(result, 'content')) {
72
- return result.content;
73
- }
74
- return undefined;
75
- }
76
-
77
- //# sourceMappingURL=request.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/internals/request.ts"],"sourcesContent":["import type { AbstractExecutionService } from '@metamask/snaps-controllers';\nimport type { SnapId, Component } from '@metamask/snaps-sdk';\nimport type { HandlerType } from '@metamask/snaps-utils';\nimport { unwrapError } from '@metamask/snaps-utils';\nimport { getSafeJson, hasProperty, isPlainObject } from '@metamask/utils';\nimport { nanoid } from '@reduxjs/toolkit';\n\nimport type { RequestOptions, SnapRequest } from '../types';\nimport {\n clearNotifications,\n getInterface,\n getNotifications,\n} from './simulation';\nimport type { RunSagaFunction, Store } from './simulation';\nimport type { RootControllerMessenger } from './simulation/controllers';\n\nexport type HandleRequestOptions = {\n snapId: SnapId;\n store: Store;\n executionService: AbstractExecutionService<unknown>;\n handler: HandlerType;\n controllerMessenger: RootControllerMessenger;\n runSaga: RunSagaFunction;\n request: RequestOptions;\n};\n\n/**\n * Send a JSON-RPC request to the Snap, and wrap the response in a\n * {@link SnapResponse} object.\n *\n * @param options - The request options.\n * @param options.snapId - The ID of the Snap to send the request to.\n * @param options.store - The Redux store.\n * @param options.executionService - The execution service to use to send the\n * request.\n * @param options.handler - The handler to use to send the request.\n * @param options.controllerMessenger - The controller messenger used to call actions.\n * @param options.runSaga - A function to run a saga outside the usual Redux\n * flow.\n * @param options.request - The request to send.\n * @param options.request.id - The ID of the request. If not provided, a random\n * ID will be generated.\n * @param options.request.origin - The origin of the request. Defaults to\n * `https://metamask.io`.\n * @returns The response, wrapped in a {@link SnapResponse} object.\n */\nexport function handleRequest({\n snapId,\n store,\n executionService,\n handler,\n controllerMessenger,\n runSaga,\n request: { id = nanoid(), origin = 'https://metamask.io', ...options },\n}: HandleRequestOptions): SnapRequest {\n const promise = executionService\n .handleRpcRequest(snapId, {\n origin,\n handler,\n request: {\n jsonrpc: '2.0',\n id: 1,\n ...options,\n },\n })\n .then((result) => {\n const notifications = getNotifications(store.getState());\n store.dispatch(clearNotifications());\n\n const content = getContentFromResult(result, snapId, controllerMessenger);\n\n return {\n id: String(id),\n response: {\n result: getSafeJson(result),\n },\n notifications,\n content,\n };\n })\n .catch((error) => {\n const [unwrappedError] = unwrapError(error);\n\n return {\n id: String(id),\n response: {\n error: unwrappedError.serialize(),\n },\n notifications: [],\n };\n }) as unknown as SnapRequest;\n\n promise.getInterface = async () => {\n return await runSaga(\n getInterface,\n runSaga,\n snapId,\n controllerMessenger,\n ).toPromise();\n };\n\n return promise;\n}\n\n/**\n * Get the response content either from the SnapInterfaceController or the response object if there is one.\n *\n * @param result - The handler result object.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger.\n * @returns The content components if any.\n */\nexport function getContentFromResult(\n result: unknown,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n): Component | undefined {\n if (isPlainObject(result) && hasProperty(result, 'id')) {\n return controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n result.id as string,\n ).content;\n }\n\n if (isPlainObject(result) && hasProperty(result, 'content')) {\n return result.content as Component;\n }\n\n return undefined;\n}\n"],"names":["unwrapError","getSafeJson","hasProperty","isPlainObject","nanoid","clearNotifications","getInterface","getNotifications","handleRequest","snapId","store","executionService","handler","controllerMessenger","runSaga","request","id","origin","options","promise","handleRpcRequest","jsonrpc","then","result","notifications","getState","dispatch","content","getContentFromResult","String","response","catch","error","unwrappedError","serialize","toPromise","call","undefined"],"mappings":"AAGA,SAASA,WAAW,QAAQ,wBAAwB;AACpD,SAASC,WAAW,EAAEC,WAAW,EAAEC,aAAa,QAAQ,kBAAkB;AAC1E,SAASC,MAAM,QAAQ,mBAAmB;AAG1C,SACEC,kBAAkB,EAClBC,YAAY,EACZC,gBAAgB,QACX,eAAe;AActB;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,SAASC,cAAc,EAC5BC,MAAM,EACNC,KAAK,EACLC,gBAAgB,EAChBC,OAAO,EACPC,mBAAmB,EACnBC,OAAO,EACPC,SAAS,EAAEC,KAAKZ,QAAQ,EAAEa,SAAS,qBAAqB,EAAE,GAAGC,SAAS,EACjD;IACrB,MAAMC,UAAUR,iBACbS,gBAAgB,CAACX,QAAQ;QACxBQ;QACAL;QACAG,SAAS;YACPM,SAAS;YACTL,IAAI;YACJ,GAAGE,OAAO;QACZ;IACF,GACCI,IAAI,CAAC,CAACC;QACL,MAAMC,gBAAgBjB,iBAAiBG,MAAMe,QAAQ;QACrDf,MAAMgB,QAAQ,CAACrB;QAEf,MAAMsB,UAAUC,qBAAqBL,QAAQd,QAAQI;QAErD,OAAO;YACLG,IAAIa,OAAOb;YACXc,UAAU;gBACRP,QAAQtB,YAAYsB;YACtB;YACAC;YACAG;QACF;IACF,GACCI,KAAK,CAAC,CAACC;QACN,MAAM,CAACC,eAAe,GAAGjC,YAAYgC;QAErC,OAAO;YACLhB,IAAIa,OAAOb;YACXc,UAAU;gBACRE,OAAOC,eAAeC,SAAS;YACjC;YACAV,eAAe,EAAE;QACnB;IACF;IAEFL,QAAQb,YAAY,GAAG;QACrB,OAAO,MAAMQ,QACXR,cACAQ,SACAL,QACAI,qBACAsB,SAAS;IACb;IAEA,OAAOhB;AACT;AAEA;;;;;;;CAOC,GACD,OAAO,SAASS,qBACdL,MAAe,EACfd,MAAc,EACdI,mBAA4C;IAE5C,IAAIV,cAAcoB,WAAWrB,YAAYqB,QAAQ,OAAO;QACtD,OAAOV,oBAAoBuB,IAAI,CAC7B,wCACA3B,QACAc,OAAOP,EAAE,EACTW,OAAO;IACX;IAEA,IAAIxB,cAAcoB,WAAWrB,YAAYqB,QAAQ,YAAY;QAC3D,OAAOA,OAAOI,OAAO;IACvB;IAEA,OAAOU;AACT"}
@@ -1,64 +0,0 @@
1
- import { assertIsSnapManifest, isDirectory, isFile } from '@metamask/snaps-utils';
2
- import { createModuleLogger } from '@metamask/utils';
3
- import express from 'express';
4
- import { promises as fs } from 'fs';
5
- import { createServer } from 'http';
6
- import { resolve as pathResolve } from 'path';
7
- import { rootLogger } from './logger';
8
- /**
9
- * Check that:
10
- *
11
- * - The root directory exists.
12
- * - The root directory contains a `snap.manifest.json` file.
13
- * - The file path in the manifest exists.
14
- *
15
- * @param root - The root directory.
16
- * @throws If any of the checks fail.
17
- */ async function assertRoot(root) {
18
- if (!root) {
19
- throw new Error('You must specify a root directory.');
20
- }
21
- if (!await isDirectory(root, false)) {
22
- throw new Error(`Root directory "${root}" is not a directory.`);
23
- }
24
- const manifestPath = pathResolve(root, 'snap.manifest.json');
25
- const manifest = await fs.readFile(manifestPath, 'utf8').then(JSON.parse);
26
- assertIsSnapManifest(manifest);
27
- const filePath = pathResolve(root, manifest.source.location.npm.filePath);
28
- if (!await isFile(filePath)) {
29
- throw new Error(`File "${filePath}" does not exist, or is not a file. Did you forget to build your snap?`);
30
- }
31
- }
32
- /**
33
- * Start an HTTP server on `localhost` with a random port. This is used to serve
34
- * the static files for the environment.
35
- *
36
- * @param options - The options to use.
37
- * @param options.port - The port to use for the server.
38
- * @param options.root - The root directory to serve from the server.
39
- * @returns The HTTP server.
40
- */ export async function startServer(options) {
41
- await assertRoot(options.root);
42
- const log = createModuleLogger(rootLogger, 'server');
43
- const app = express();
44
- app.use((_request, response, next)=>{
45
- response.header('Access-Control-Allow-Origin', '*');
46
- response.header('Access-Control-Allow-Credentials', 'true');
47
- response.header('Access-Control-Allow-Methods', 'GET, OPTIONS');
48
- response.header('Access-Control-Allow-Headers', 'Content-Type');
49
- next();
50
- });
51
- app.use(express.static(pathResolve(process.cwd(), options.root)));
52
- const server = createServer(app);
53
- return await new Promise((resolve, reject)=>{
54
- server.listen(options.port, ()=>{
55
- resolve(server);
56
- });
57
- server.on('error', (error)=>{
58
- log(error);
59
- reject(error);
60
- });
61
- });
62
- }
63
-
64
- //# sourceMappingURL=server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/internals/server.ts"],"sourcesContent":["import type { SnapManifest } from '@metamask/snaps-utils';\nimport {\n assertIsSnapManifest,\n isDirectory,\n isFile,\n} from '@metamask/snaps-utils';\nimport { createModuleLogger } from '@metamask/utils';\nimport express from 'express';\nimport { promises as fs } from 'fs';\nimport type { Server } from 'http';\nimport { createServer } from 'http';\nimport { resolve as pathResolve } from 'path';\n\nimport type { SnapsEnvironmentOptions } from '../options';\nimport { rootLogger } from './logger';\n\nexport type ServerOptions = Required<\n // We need a double `Required` for the type to be inferred correctly.\n Required<SnapsEnvironmentOptions>['server']\n>;\n\n/**\n * Check that:\n *\n * - The root directory exists.\n * - The root directory contains a `snap.manifest.json` file.\n * - The file path in the manifest exists.\n *\n * @param root - The root directory.\n * @throws If any of the checks fail.\n */\nasync function assertRoot(root: string) {\n if (!root) {\n throw new Error('You must specify a root directory.');\n }\n\n if (!(await isDirectory(root, false))) {\n throw new Error(`Root directory \"${root}\" is not a directory.`);\n }\n\n const manifestPath = pathResolve(root, 'snap.manifest.json');\n const manifest: SnapManifest = await fs\n .readFile(manifestPath, 'utf8')\n .then(JSON.parse);\n\n assertIsSnapManifest(manifest);\n const filePath = pathResolve(root, manifest.source.location.npm.filePath);\n\n if (!(await isFile(filePath))) {\n throw new Error(\n `File \"${filePath}\" does not exist, or is not a file. Did you forget to build your snap?`,\n );\n }\n}\n\n/**\n * Start an HTTP server on `localhost` with a random port. This is used to serve\n * the static files for the environment.\n *\n * @param options - The options to use.\n * @param options.port - The port to use for the server.\n * @param options.root - The root directory to serve from the server.\n * @returns The HTTP server.\n */\nexport async function startServer(options: ServerOptions) {\n await assertRoot(options.root);\n\n const log = createModuleLogger(rootLogger, 'server');\n const app = express();\n\n app.use((_request, response, next) => {\n response.header('Access-Control-Allow-Origin', '*');\n response.header('Access-Control-Allow-Credentials', 'true');\n response.header('Access-Control-Allow-Methods', 'GET, OPTIONS');\n response.header('Access-Control-Allow-Headers', 'Content-Type');\n\n next();\n });\n\n app.use(express.static(pathResolve(process.cwd(), options.root)));\n\n const server = createServer(app);\n return await new Promise<Server>((resolve, reject) => {\n server.listen(options.port, () => {\n resolve(server);\n });\n\n server.on('error', (error) => {\n log(error);\n reject(error);\n });\n });\n}\n"],"names":["assertIsSnapManifest","isDirectory","isFile","createModuleLogger","express","promises","fs","createServer","resolve","pathResolve","rootLogger","assertRoot","root","Error","manifestPath","manifest","readFile","then","JSON","parse","filePath","source","location","npm","startServer","options","log","app","use","_request","response","next","header","static","process","cwd","server","Promise","reject","listen","port","on","error"],"mappings":"AACA,SACEA,oBAAoB,EACpBC,WAAW,EACXC,MAAM,QACD,wBAAwB;AAC/B,SAASC,kBAAkB,QAAQ,kBAAkB;AACrD,OAAOC,aAAa,UAAU;AAC9B,SAASC,YAAYC,EAAE,QAAQ,KAAK;AAEpC,SAASC,YAAY,QAAQ,OAAO;AACpC,SAASC,WAAWC,WAAW,QAAQ,OAAO;AAG9C,SAASC,UAAU,QAAQ,WAAW;AAOtC;;;;;;;;;CASC,GACD,eAAeC,WAAWC,IAAY;IACpC,IAAI,CAACA,MAAM;QACT,MAAM,IAAIC,MAAM;IAClB;IAEA,IAAI,CAAE,MAAMZ,YAAYW,MAAM,QAAS;QACrC,MAAM,IAAIC,MAAM,CAAC,gBAAgB,EAAED,KAAK,qBAAqB,CAAC;IAChE;IAEA,MAAME,eAAeL,YAAYG,MAAM;IACvC,MAAMG,WAAyB,MAAMT,GAClCU,QAAQ,CAACF,cAAc,QACvBG,IAAI,CAACC,KAAKC,KAAK;IAElBnB,qBAAqBe;IACrB,MAAMK,WAAWX,YAAYG,MAAMG,SAASM,MAAM,CAACC,QAAQ,CAACC,GAAG,CAACH,QAAQ;IAExE,IAAI,CAAE,MAAMlB,OAAOkB,WAAY;QAC7B,MAAM,IAAIP,MACR,CAAC,MAAM,EAAEO,SAAS,sEAAsE,CAAC;IAE7F;AACF;AAEA;;;;;;;;CAQC,GACD,OAAO,eAAeI,YAAYC,OAAsB;IACtD,MAAMd,WAAWc,QAAQb,IAAI;IAE7B,MAAMc,MAAMvB,mBAAmBO,YAAY;IAC3C,MAAMiB,MAAMvB;IAEZuB,IAAIC,GAAG,CAAC,CAACC,UAAUC,UAAUC;QAC3BD,SAASE,MAAM,CAAC,+BAA+B;QAC/CF,SAASE,MAAM,CAAC,oCAAoC;QACpDF,SAASE,MAAM,CAAC,gCAAgC;QAChDF,SAASE,MAAM,CAAC,gCAAgC;QAEhDD;IACF;IAEAJ,IAAIC,GAAG,CAACxB,QAAQ6B,MAAM,CAACxB,YAAYyB,QAAQC,GAAG,IAAIV,QAAQb,IAAI;IAE9D,MAAMwB,SAAS7B,aAAaoB;IAC5B,OAAO,MAAM,IAAIU,QAAgB,CAAC7B,SAAS8B;QACzCF,OAAOG,MAAM,CAACd,QAAQe,IAAI,EAAE;YAC1BhC,QAAQ4B;QACV;QAEAA,OAAOK,EAAE,CAAC,SAAS,CAACC;YAClBhB,IAAIgB;YACJJ,OAAOI;QACT;IACF;AACF"}
@@ -1,12 +0,0 @@
1
- /**
2
- * A secret recovery phrase that is used for testing purposes. Do not use this
3
- * to store any real funds!
4
- */ export const DEFAULT_SRP = 'test test test test test test test test test test test ball';
5
- /**
6
- * The default locale.
7
- */ export const DEFAULT_LOCALE = 'en';
8
- /**
9
- * The default JSON-RPC endpoint for Ethereum requests.
10
- */ export const DEFAULT_JSON_RPC_ENDPOINT = 'https://cloudflare-eth.com/';
11
-
12
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/internals/simulation/constants.ts"],"sourcesContent":["/**\n * A secret recovery phrase that is used for testing purposes. Do not use this\n * to store any real funds!\n */\nexport const DEFAULT_SRP =\n 'test test test test test test test test test test test ball';\n\n/**\n * The default locale.\n */\nexport const DEFAULT_LOCALE = 'en';\n\n/**\n * The default JSON-RPC endpoint for Ethereum requests.\n */\nexport const DEFAULT_JSON_RPC_ENDPOINT = 'https://cloudflare-eth.com/';\n"],"names":["DEFAULT_SRP","DEFAULT_LOCALE","DEFAULT_JSON_RPC_ENDPOINT"],"mappings":"AAAA;;;CAGC,GACD,OAAO,MAAMA,cACX,8DAA8D;AAEhE;;CAEC,GACD,OAAO,MAAMC,iBAAiB,KAAK;AAEnC;;CAEC,GACD,OAAO,MAAMC,4BAA4B,8BAA8B"}
@@ -1,90 +0,0 @@
1
- import { PermissionController, SubjectMetadataController, SubjectType } from '@metamask/permission-controller';
2
- import { SnapInterfaceController } from '@metamask/snaps-controllers';
3
- import { caveatSpecifications as snapsCaveatsSpecifications, endowmentCaveatSpecifications as snapsEndowmentCaveatSpecifications, processSnapPermissions } from '@metamask/snaps-rpc-methods';
4
- import { getSafeJson } from '@metamask/utils';
5
- import { getPermissionSpecifications } from './methods';
6
- import { UNRESTRICTED_METHODS } from './methods/constants';
7
- /**
8
- * Get the controllers for the Snap.
9
- *
10
- * @param options - The options.
11
- * @returns The controllers for the Snap.
12
- */ export function getControllers(options) {
13
- const { controllerMessenger } = options;
14
- const subjectMetadataController = new SubjectMetadataController({
15
- messenger: controllerMessenger.getRestricted({
16
- name: 'SubjectMetadataController'
17
- }),
18
- subjectCacheLimit: 100
19
- });
20
- const interfaceController = new SnapInterfaceController({
21
- messenger: controllerMessenger.getRestricted({
22
- name: 'SnapInterfaceController',
23
- allowedActions: [
24
- 'PhishingController:maybeUpdateState',
25
- 'PhishingController:testOrigin'
26
- ]
27
- })
28
- });
29
- const permissionController = getPermissionController(options);
30
- return {
31
- permissionController,
32
- subjectMetadataController,
33
- interfaceController
34
- };
35
- }
36
- /**
37
- * Get the permission controller for the Snap.
38
- *
39
- * @param options - The options.
40
- * @param options.controllerMessenger - The controller messenger.
41
- * @param options.options - Miscellaneous options.
42
- * @returns The permission controller for the Snap.
43
- */ function getPermissionController(options) {
44
- const { controllerMessenger } = options;
45
- const permissionSpecifications = getPermissionSpecifications(options);
46
- return new PermissionController({
47
- messenger: controllerMessenger.getRestricted({
48
- name: 'PermissionController',
49
- allowedActions: [
50
- `ApprovalController:addRequest`,
51
- `ApprovalController:hasRequest`,
52
- `ApprovalController:acceptRequest`,
53
- `ApprovalController:rejectRequest`,
54
- `SnapController:getPermitted`,
55
- `SnapController:install`,
56
- `SubjectMetadataController:getSubjectMetadata`
57
- ]
58
- }),
59
- caveatSpecifications: {
60
- ...snapsCaveatsSpecifications,
61
- ...snapsEndowmentCaveatSpecifications
62
- },
63
- permissionSpecifications,
64
- unrestrictedMethods: UNRESTRICTED_METHODS
65
- });
66
- }
67
- /**
68
- * Register the Snap. This sets up the Snap's permissions and subject metadata.
69
- *
70
- * @param snapId - The ID of the Snap to install.
71
- * @param manifest - The parsed manifest.
72
- * @param controllers - The controllers for the Snap.
73
- * @param controllers.permissionController - The permission controller.
74
- * @param controllers.subjectMetadataController - The subject metadata controller.
75
- */ export async function registerSnap(snapId, manifest, { permissionController, subjectMetadataController }) {
76
- subjectMetadataController.addSubjectMetadata({
77
- origin: snapId,
78
- subjectType: SubjectType.Snap
79
- });
80
- const approvedPermissions = processSnapPermissions(getSafeJson(manifest.initialPermissions));
81
- permissionController.grantPermissions({
82
- approvedPermissions,
83
- subject: {
84
- origin: snapId
85
- },
86
- preserveExistingPermissions: false
87
- });
88
- }
89
-
90
- //# sourceMappingURL=controllers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/internals/simulation/controllers.ts"],"sourcesContent":["import type { ControllerMessenger } from '@metamask/base-controller';\nimport type {\n CaveatSpecificationConstraint,\n PermissionSpecificationConstraint,\n PermissionControllerActions,\n SubjectMetadataControllerActions,\n} from '@metamask/permission-controller';\nimport {\n PermissionController,\n SubjectMetadataController,\n SubjectType,\n} from '@metamask/permission-controller';\nimport { SnapInterfaceController } from '@metamask/snaps-controllers';\nimport type {\n ExecutionServiceActions,\n SnapInterfaceControllerActions,\n SnapInterfaceControllerAllowedActions,\n} from '@metamask/snaps-controllers';\nimport {\n caveatSpecifications as snapsCaveatsSpecifications,\n endowmentCaveatSpecifications as snapsEndowmentCaveatSpecifications,\n processSnapPermissions,\n} from '@metamask/snaps-rpc-methods';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport type { SnapManifest } from '@metamask/snaps-utils';\nimport { getSafeJson } from '@metamask/utils';\n\nimport { getPermissionSpecifications } from './methods';\nimport { UNRESTRICTED_METHODS } from './methods/constants';\nimport type { SimulationOptions } from './options';\nimport type { MiddlewareHooks } from './simulation';\nimport type { RunSagaFunction } from './store';\n\nexport type RootControllerAllowedActions =\n | SnapInterfaceControllerActions\n | SnapInterfaceControllerAllowedActions\n | PermissionControllerActions\n | ExecutionServiceActions\n | SubjectMetadataControllerActions;\n\nexport type RootControllerMessenger = ControllerMessenger<\n RootControllerAllowedActions,\n any\n>;\n\nexport type GetControllersOptions = {\n controllerMessenger: ControllerMessenger<any, any>;\n hooks: MiddlewareHooks;\n runSaga: RunSagaFunction;\n options: SimulationOptions;\n};\n\nexport type Controllers = {\n permissionController: PermissionController<\n PermissionSpecificationConstraint,\n CaveatSpecificationConstraint\n >;\n subjectMetadataController: SubjectMetadataController;\n interfaceController: SnapInterfaceController;\n};\n\n/**\n * Get the controllers for the Snap.\n *\n * @param options - The options.\n * @returns The controllers for the Snap.\n */\nexport function getControllers(options: GetControllersOptions): Controllers {\n const { controllerMessenger } = options;\n const subjectMetadataController = new SubjectMetadataController({\n messenger: controllerMessenger.getRestricted({\n name: 'SubjectMetadataController',\n }),\n subjectCacheLimit: 100,\n });\n\n const interfaceController = new SnapInterfaceController({\n messenger: controllerMessenger.getRestricted({\n name: 'SnapInterfaceController',\n allowedActions: [\n 'PhishingController:maybeUpdateState',\n 'PhishingController:testOrigin',\n ],\n }),\n });\n\n const permissionController = getPermissionController(options);\n\n return {\n permissionController,\n subjectMetadataController,\n interfaceController,\n };\n}\n\n/**\n * Get the permission controller for the Snap.\n *\n * @param options - The options.\n * @param options.controllerMessenger - The controller messenger.\n * @param options.options - Miscellaneous options.\n * @returns The permission controller for the Snap.\n */\nfunction getPermissionController(options: GetControllersOptions) {\n const { controllerMessenger } = options;\n const permissionSpecifications = getPermissionSpecifications(options);\n return new PermissionController({\n messenger: controllerMessenger.getRestricted({\n name: 'PermissionController',\n allowedActions: [\n `ApprovalController:addRequest`,\n `ApprovalController:hasRequest`,\n `ApprovalController:acceptRequest`,\n `ApprovalController:rejectRequest`,\n `SnapController:getPermitted`,\n `SnapController:install`,\n `SubjectMetadataController:getSubjectMetadata`,\n ],\n }),\n caveatSpecifications: {\n ...snapsCaveatsSpecifications,\n ...snapsEndowmentCaveatSpecifications,\n },\n permissionSpecifications,\n unrestrictedMethods: UNRESTRICTED_METHODS,\n });\n}\n\n/**\n * Register the Snap. This sets up the Snap's permissions and subject metadata.\n *\n * @param snapId - The ID of the Snap to install.\n * @param manifest - The parsed manifest.\n * @param controllers - The controllers for the Snap.\n * @param controllers.permissionController - The permission controller.\n * @param controllers.subjectMetadataController - The subject metadata controller.\n */\nexport async function registerSnap(\n snapId: SnapId,\n manifest: SnapManifest,\n {\n permissionController,\n subjectMetadataController,\n }: Omit<Controllers, 'interfaceController'>,\n) {\n subjectMetadataController.addSubjectMetadata({\n origin: snapId,\n subjectType: SubjectType.Snap,\n });\n\n const approvedPermissions = processSnapPermissions(\n getSafeJson(manifest.initialPermissions),\n );\n\n permissionController.grantPermissions({\n approvedPermissions,\n subject: { origin: snapId },\n preserveExistingPermissions: false,\n });\n}\n"],"names":["PermissionController","SubjectMetadataController","SubjectType","SnapInterfaceController","caveatSpecifications","snapsCaveatsSpecifications","endowmentCaveatSpecifications","snapsEndowmentCaveatSpecifications","processSnapPermissions","getSafeJson","getPermissionSpecifications","UNRESTRICTED_METHODS","getControllers","options","controllerMessenger","subjectMetadataController","messenger","getRestricted","name","subjectCacheLimit","interfaceController","allowedActions","permissionController","getPermissionController","permissionSpecifications","unrestrictedMethods","registerSnap","snapId","manifest","addSubjectMetadata","origin","subjectType","Snap","approvedPermissions","initialPermissions","grantPermissions","subject","preserveExistingPermissions"],"mappings":"AAOA,SACEA,oBAAoB,EACpBC,yBAAyB,EACzBC,WAAW,QACN,kCAAkC;AACzC,SAASC,uBAAuB,QAAQ,8BAA8B;AAMtE,SACEC,wBAAwBC,0BAA0B,EAClDC,iCAAiCC,kCAAkC,EACnEC,sBAAsB,QACjB,8BAA8B;AAGrC,SAASC,WAAW,QAAQ,kBAAkB;AAE9C,SAASC,2BAA2B,QAAQ,YAAY;AACxD,SAASC,oBAAoB,QAAQ,sBAAsB;AAiC3D;;;;;CAKC,GACD,OAAO,SAASC,eAAeC,OAA8B;IAC3D,MAAM,EAAEC,mBAAmB,EAAE,GAAGD;IAChC,MAAME,4BAA4B,IAAId,0BAA0B;QAC9De,WAAWF,oBAAoBG,aAAa,CAAC;YAC3CC,MAAM;QACR;QACAC,mBAAmB;IACrB;IAEA,MAAMC,sBAAsB,IAAIjB,wBAAwB;QACtDa,WAAWF,oBAAoBG,aAAa,CAAC;YAC3CC,MAAM;YACNG,gBAAgB;gBACd;gBACA;aACD;QACH;IACF;IAEA,MAAMC,uBAAuBC,wBAAwBV;IAErD,OAAO;QACLS;QACAP;QACAK;IACF;AACF;AAEA;;;;;;;CAOC,GACD,SAASG,wBAAwBV,OAA8B;IAC7D,MAAM,EAAEC,mBAAmB,EAAE,GAAGD;IAChC,MAAMW,2BAA2Bd,4BAA4BG;IAC7D,OAAO,IAAIb,qBAAqB;QAC9BgB,WAAWF,oBAAoBG,aAAa,CAAC;YAC3CC,MAAM;YACNG,gBAAgB;gBACd,CAAC,6BAA6B,CAAC;gBAC/B,CAAC,6BAA6B,CAAC;gBAC/B,CAAC,gCAAgC,CAAC;gBAClC,CAAC,gCAAgC,CAAC;gBAClC,CAAC,2BAA2B,CAAC;gBAC7B,CAAC,sBAAsB,CAAC;gBACxB,CAAC,4CAA4C,CAAC;aAC/C;QACH;QACAjB,sBAAsB;YACpB,GAAGC,0BAA0B;YAC7B,GAAGE,kCAAkC;QACvC;QACAiB;QACAC,qBAAqBd;IACvB;AACF;AAEA;;;;;;;;CAQC,GACD,OAAO,eAAee,aACpBC,MAAc,EACdC,QAAsB,EACtB,EACEN,oBAAoB,EACpBP,yBAAyB,EACgB;IAE3CA,0BAA0Bc,kBAAkB,CAAC;QAC3CC,QAAQH;QACRI,aAAa7B,YAAY8B,IAAI;IAC/B;IAEA,MAAMC,sBAAsBzB,uBAC1BC,YAAYmB,SAASM,kBAAkB;IAGzCZ,qBAAqBa,gBAAgB,CAAC;QACpCF;QACAG,SAAS;YAAEN,QAAQH;QAAO;QAC1BU,6BAA6B;IAC/B;AACF"}
@@ -1,19 +0,0 @@
1
- import { AuxiliaryFileEncoding } from '@metamask/snaps-sdk';
2
- import { encodeAuxiliaryFile, normalizeRelative } from '@metamask/snaps-utils';
3
- /**
4
- * Get a statically defined Snap file from an array of files.
5
- *
6
- * @param files - The Snap files.
7
- * @param path - The file path.
8
- * @param encoding - The requested file encoding.
9
- * @returns The file in the requested encoding if found, otherwise null.
10
- */ export async function getSnapFile(files, path, encoding = AuxiliaryFileEncoding.Base64) {
11
- const normalizedPath = normalizeRelative(path);
12
- const base64 = files.find((file)=>file.path === normalizedPath)?.toString('base64');
13
- if (!base64) {
14
- return null;
15
- }
16
- return await encodeAuxiliaryFile(base64, encoding);
17
- }
18
-
19
- //# sourceMappingURL=files.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/internals/simulation/files.ts"],"sourcesContent":["import { AuxiliaryFileEncoding } from '@metamask/snaps-sdk';\nimport type { VirtualFile } from '@metamask/snaps-utils';\nimport { encodeAuxiliaryFile, normalizeRelative } from '@metamask/snaps-utils';\n\n/**\n * Get a statically defined Snap file from an array of files.\n *\n * @param files - The Snap files.\n * @param path - The file path.\n * @param encoding - The requested file encoding.\n * @returns The file in the requested encoding if found, otherwise null.\n */\nexport async function getSnapFile(\n files: VirtualFile[],\n path: string,\n encoding: AuxiliaryFileEncoding = AuxiliaryFileEncoding.Base64,\n) {\n const normalizedPath = normalizeRelative(path);\n const base64 = files\n .find((file) => file.path === normalizedPath)\n ?.toString('base64');\n\n if (!base64) {\n return null;\n }\n\n return await encodeAuxiliaryFile(base64, encoding);\n}\n"],"names":["AuxiliaryFileEncoding","encodeAuxiliaryFile","normalizeRelative","getSnapFile","files","path","encoding","Base64","normalizedPath","base64","find","file","toString"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,sBAAsB;AAE5D,SAASC,mBAAmB,EAAEC,iBAAiB,QAAQ,wBAAwB;AAE/E;;;;;;;CAOC,GACD,OAAO,eAAeC,YACpBC,KAAoB,EACpBC,IAAY,EACZC,WAAkCN,sBAAsBO,MAAM;IAE9D,MAAMC,iBAAiBN,kBAAkBG;IACzC,MAAMI,SAASL,MACZM,IAAI,CAAC,CAACC,OAASA,KAAKN,IAAI,KAAKG,iBAC5BI,SAAS;IAEb,IAAI,CAACH,QAAQ;QACX,OAAO;IACT;IAEA,OAAO,MAAMR,oBAAoBQ,QAAQH;AAC3C"}
@@ -1,7 +0,0 @@
1
- export * from './constants';
2
- export * from './interface';
3
- export * from './simulation';
4
- export * from './options';
5
- export * from './store';
6
-
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/internals/simulation/index.ts"],"sourcesContent":["export * from './constants';\nexport * from './interface';\nexport * from './simulation';\nexport * from './options';\nexport * from './store';\n"],"names":[],"mappings":"AAAA,cAAc,cAAc;AAC5B,cAAc,cAAc;AAC5B,cAAc,eAAe;AAC7B,cAAc,YAAY;AAC1B,cAAc,UAAU"}
@@ -1,95 +0,0 @@
1
- import { DialogType } from '@metamask/snaps-sdk';
2
- import { put, select, take } from 'redux-saga/effects';
3
- import { getCurrentInterface, resolveInterface, setInterface } from './store';
4
- /**
5
- * Get a user interface object from a type and content object.
6
- *
7
- * @param runSaga - A function to run a saga outside the usual Redux flow.
8
- * @param type - The type of the interface.
9
- * @param content - The content to show in the interface.
10
- * @returns The user interface object.
11
- */ export function getInterfaceResponse(runSaga, type, content) {
12
- switch(type){
13
- case DialogType.Alert:
14
- return {
15
- type,
16
- content,
17
- ok: resolveWith(runSaga, null)
18
- };
19
- case DialogType.Confirmation:
20
- return {
21
- type,
22
- content,
23
- ok: resolveWith(runSaga, true),
24
- cancel: resolveWith(runSaga, false)
25
- };
26
- case DialogType.Prompt:
27
- return {
28
- type,
29
- content,
30
- ok: resolveWithInput(runSaga),
31
- cancel: resolveWith(runSaga, null)
32
- };
33
- default:
34
- throw new Error(`Unknown or unsupported dialog type: "${String(type)}".`);
35
- }
36
- }
37
- /**
38
- * Resolve the current user interface with the given value. This returns a
39
- * function that can be used to resolve the user interface.
40
- *
41
- * @param runSaga - A function to run a saga outside the usual Redux flow.
42
- * @param value - The value to resolve the user interface with.
43
- * @returns A function that can be used to resolve the user interface.
44
- */ function resolveWith(runSaga, value) {
45
- /**
46
- * Resolve the current user interface with the given value.
47
- *
48
- * @yields Puts the resolve user interface action.
49
- */ function* resolveWithSaga() {
50
- yield put(resolveInterface(value));
51
- }
52
- return async ()=>{
53
- await runSaga(resolveWithSaga).toPromise();
54
- };
55
- }
56
- /**
57
- * Resolve the current user interface with the provided input. This returns a
58
- * function that can be used to resolve the user interface.
59
- *
60
- * @param runSaga - A function to run a saga outside the usual Redux flow.
61
- * @returns A function that can be used to resolve the user interface.
62
- */ function resolveWithInput(runSaga) {
63
- /**
64
- * Resolve the current user interface with the given value.
65
- *
66
- * @param value - The value to resolve the user interface with.
67
- * @yields Puts the resolve user interface action.
68
- */ function* resolveWithSaga(value) {
69
- yield put(resolveInterface(value));
70
- }
71
- return async (value = '')=>{
72
- await runSaga(resolveWithSaga, value).toPromise();
73
- };
74
- }
75
- /**
76
- * Get a user interface object from a Snap.
77
- *
78
- * @param runSaga - A function to run a saga outside the usual Redux flow.
79
- * @param snapId - The Snap ID.
80
- * @param controllerMessenger - The controller messenger used to call actions.
81
- * @yields Takes the set interface action.
82
- * @returns The user interface object.
83
- */ export function* getInterface(runSaga, snapId, controllerMessenger) {
84
- const currentInterface = yield select(getCurrentInterface);
85
- if (currentInterface) {
86
- const { content } = controllerMessenger.call('SnapInterfaceController:getInterface', snapId, currentInterface.id);
87
- return getInterfaceResponse(runSaga, currentInterface.type, content);
88
- }
89
- const { payload } = yield take(setInterface.type);
90
- const { type, id } = payload;
91
- const { content } = controllerMessenger.call('SnapInterfaceController:getInterface', snapId, id);
92
- return getInterfaceResponse(runSaga, type, content);
93
- }
94
-
95
- //# sourceMappingURL=interface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/internals/simulation/interface.ts"],"sourcesContent":["import type { Component, SnapId } from '@metamask/snaps-sdk';\nimport { DialogType } from '@metamask/snaps-sdk';\nimport type { PayloadAction } from '@reduxjs/toolkit';\nimport type { SagaIterator } from 'redux-saga';\nimport { put, select, take } from 'redux-saga/effects';\n\nimport type { SnapInterface } from '../../types';\nimport type { RootControllerMessenger } from './controllers';\nimport type { Interface, RunSagaFunction } from './store';\nimport { getCurrentInterface, resolveInterface, setInterface } from './store';\n\n/**\n * Get a user interface object from a type and content object.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @param type - The type of the interface.\n * @param content - The content to show in the interface.\n * @returns The user interface object.\n */\nexport function getInterfaceResponse(\n runSaga: RunSagaFunction,\n type: DialogType,\n content: Component,\n): SnapInterface {\n switch (type) {\n case DialogType.Alert:\n return {\n type,\n content,\n ok: resolveWith(runSaga, null),\n };\n\n case DialogType.Confirmation:\n return {\n type,\n content,\n\n ok: resolveWith(runSaga, true),\n cancel: resolveWith(runSaga, false),\n };\n\n case DialogType.Prompt:\n return {\n type,\n content,\n\n ok: resolveWithInput(runSaga),\n cancel: resolveWith(runSaga, null),\n };\n\n default:\n throw new Error(`Unknown or unsupported dialog type: \"${String(type)}\".`);\n }\n}\n\n/**\n * Resolve the current user interface with the given value. This returns a\n * function that can be used to resolve the user interface.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @param value - The value to resolve the user interface with.\n * @returns A function that can be used to resolve the user interface.\n */\nfunction resolveWith(runSaga: RunSagaFunction, value: unknown) {\n /**\n * Resolve the current user interface with the given value.\n *\n * @yields Puts the resolve user interface action.\n */\n function* resolveWithSaga(): SagaIterator {\n yield put(resolveInterface(value));\n }\n\n return async () => {\n await runSaga(resolveWithSaga).toPromise();\n };\n}\n\n/**\n * Resolve the current user interface with the provided input. This returns a\n * function that can be used to resolve the user interface.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @returns A function that can be used to resolve the user interface.\n */\nfunction resolveWithInput(runSaga: RunSagaFunction) {\n /**\n * Resolve the current user interface with the given value.\n *\n * @param value - The value to resolve the user interface with.\n * @yields Puts the resolve user interface action.\n */\n function* resolveWithSaga(value: string): SagaIterator {\n yield put(resolveInterface(value));\n }\n\n return async (value = '') => {\n await runSaga(resolveWithSaga, value).toPromise();\n };\n}\n\n/**\n * Get a user interface object from a Snap.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger used to call actions.\n * @yields Takes the set interface action.\n * @returns The user interface object.\n */\nexport function* getInterface(\n runSaga: RunSagaFunction,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n): SagaIterator<SnapInterface> {\n const currentInterface: Interface | null = yield select(getCurrentInterface);\n if (currentInterface) {\n const { content } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n currentInterface.id,\n );\n return getInterfaceResponse(runSaga, currentInterface.type, content);\n }\n\n const { payload }: PayloadAction<Interface> = yield take(setInterface.type);\n const { type, id } = payload;\n\n const { content } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n return getInterfaceResponse(runSaga, type, content);\n}\n"],"names":["DialogType","put","select","take","getCurrentInterface","resolveInterface","setInterface","getInterfaceResponse","runSaga","type","content","Alert","ok","resolveWith","Confirmation","cancel","Prompt","resolveWithInput","Error","String","value","resolveWithSaga","toPromise","getInterface","snapId","controllerMessenger","currentInterface","call","id","payload"],"mappings":"AACA,SAASA,UAAU,QAAQ,sBAAsB;AAGjD,SAASC,GAAG,EAAEC,MAAM,EAAEC,IAAI,QAAQ,qBAAqB;AAKvD,SAASC,mBAAmB,EAAEC,gBAAgB,EAAEC,YAAY,QAAQ,UAAU;AAE9E;;;;;;;CAOC,GACD,OAAO,SAASC,qBACdC,OAAwB,EACxBC,IAAgB,EAChBC,OAAkB;IAElB,OAAQD;QACN,KAAKT,WAAWW,KAAK;YACnB,OAAO;gBACLF;gBACAC;gBACAE,IAAIC,YAAYL,SAAS;YAC3B;QAEF,KAAKR,WAAWc,YAAY;YAC1B,OAAO;gBACLL;gBACAC;gBAEAE,IAAIC,YAAYL,SAAS;gBACzBO,QAAQF,YAAYL,SAAS;YAC/B;QAEF,KAAKR,WAAWgB,MAAM;YACpB,OAAO;gBACLP;gBACAC;gBAEAE,IAAIK,iBAAiBT;gBACrBO,QAAQF,YAAYL,SAAS;YAC/B;QAEF;YACE,MAAM,IAAIU,MAAM,CAAC,qCAAqC,EAAEC,OAAOV,MAAM,EAAE,CAAC;IAC5E;AACF;AAEA;;;;;;;CAOC,GACD,SAASI,YAAYL,OAAwB,EAAEY,KAAc;IAC3D;;;;GAIC,GACD,UAAUC;QACR,MAAMpB,IAAII,iBAAiBe;IAC7B;IAEA,OAAO;QACL,MAAMZ,QAAQa,iBAAiBC,SAAS;IAC1C;AACF;AAEA;;;;;;CAMC,GACD,SAASL,iBAAiBT,OAAwB;IAChD;;;;;GAKC,GACD,UAAUa,gBAAgBD,KAAa;QACrC,MAAMnB,IAAII,iBAAiBe;IAC7B;IAEA,OAAO,OAAOA,QAAQ,EAAE;QACtB,MAAMZ,QAAQa,iBAAiBD,OAAOE,SAAS;IACjD;AACF;AAEA;;;;;;;;CAQC,GACD,OAAO,UAAUC,aACff,OAAwB,EACxBgB,MAAc,EACdC,mBAA4C;IAE5C,MAAMC,mBAAqC,MAAMxB,OAAOE;IACxD,IAAIsB,kBAAkB;QACpB,MAAM,EAAEhB,OAAO,EAAE,GAAGe,oBAAoBE,IAAI,CAC1C,wCACAH,QACAE,iBAAiBE,EAAE;QAErB,OAAOrB,qBAAqBC,SAASkB,iBAAiBjB,IAAI,EAAEC;IAC9D;IAEA,MAAM,EAAEmB,OAAO,EAAE,GAA6B,MAAM1B,KAAKG,aAAaG,IAAI;IAC1E,MAAM,EAAEA,IAAI,EAAEmB,EAAE,EAAE,GAAGC;IAErB,MAAM,EAAEnB,OAAO,EAAE,GAAGe,oBAAoBE,IAAI,CAC1C,wCACAH,QACAI;IAGF,OAAOrB,qBAAqBC,SAASC,MAAMC;AAC7C"}
@@ -1,69 +0,0 @@
1
- export const EXCLUDED_SNAP_ENDOWMENTS = [];
2
- export const EXCLUDED_SNAP_PERMISSIONS = [];
3
- /**
4
- * All unrestricted methods recognized by the `PermissionController`.
5
- * Unrestricted methods are ignored by the permission system, but every
6
- * JSON-RPC request seen by the permission system must correspond to a
7
- * restricted or unrestricted method, or the request will be rejected with a
8
- * "method not found" error.
9
- */ export const UNRESTRICTED_METHODS = Object.freeze([
10
- 'eth_blockNumber',
11
- 'eth_call',
12
- 'eth_chainId',
13
- 'eth_coinbase',
14
- 'eth_decrypt',
15
- 'eth_estimateGas',
16
- 'eth_feeHistory',
17
- 'eth_gasPrice',
18
- 'eth_getBalance',
19
- 'eth_getBlockByHash',
20
- 'eth_getBlockByNumber',
21
- 'eth_getBlockTransactionCountByHash',
22
- 'eth_getBlockTransactionCountByNumber',
23
- 'eth_getCode',
24
- 'eth_getEncryptionPublicKey',
25
- 'eth_getFilterChanges',
26
- 'eth_getFilterLogs',
27
- 'eth_getLogs',
28
- 'eth_getProof',
29
- 'eth_getStorageAt',
30
- 'eth_getTransactionByBlockHashAndIndex',
31
- 'eth_getTransactionByBlockNumberAndIndex',
32
- 'eth_getTransactionByHash',
33
- 'eth_getTransactionCount',
34
- 'eth_getTransactionReceipt',
35
- 'eth_getUncleByBlockHashAndIndex',
36
- 'eth_getUncleByBlockNumberAndIndex',
37
- 'eth_getUncleCountByBlockHash',
38
- 'eth_getUncleCountByBlockNumber',
39
- 'eth_getWork',
40
- 'eth_hashrate',
41
- 'eth_mining',
42
- 'eth_newBlockFilter',
43
- 'eth_newFilter',
44
- 'eth_newPendingTransactionFilter',
45
- 'eth_protocolVersion',
46
- 'eth_sendRawTransaction',
47
- 'eth_sendTransaction',
48
- 'eth_sign',
49
- 'eth_signTypedData',
50
- 'eth_signTypedData_v1',
51
- 'eth_signTypedData_v3',
52
- 'eth_signTypedData_v4',
53
- 'eth_submitHashrate',
54
- 'eth_submitWork',
55
- 'eth_syncing',
56
- 'eth_uninstallFilter',
57
- 'metamask_getProviderState',
58
- 'metamask_watchAsset',
59
- 'net_listening',
60
- 'net_peerCount',
61
- 'net_version',
62
- 'personal_ecRecover',
63
- 'personal_sign',
64
- 'wallet_watchAsset',
65
- 'web3_clientVersion',
66
- 'web3_sha3'
67
- ]);
68
-
69
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/internals/simulation/methods/constants.ts"],"sourcesContent":["export const EXCLUDED_SNAP_ENDOWMENTS = [];\n\nexport const EXCLUDED_SNAP_PERMISSIONS = [];\n\n/**\n * All unrestricted methods recognized by the `PermissionController`.\n * Unrestricted methods are ignored by the permission system, but every\n * JSON-RPC request seen by the permission system must correspond to a\n * restricted or unrestricted method, or the request will be rejected with a\n * \"method not found\" error.\n */\nexport const UNRESTRICTED_METHODS = Object.freeze([\n 'eth_blockNumber',\n 'eth_call',\n 'eth_chainId',\n 'eth_coinbase',\n 'eth_decrypt',\n 'eth_estimateGas',\n 'eth_feeHistory',\n 'eth_gasPrice',\n 'eth_getBalance',\n 'eth_getBlockByHash',\n 'eth_getBlockByNumber',\n 'eth_getBlockTransactionCountByHash',\n 'eth_getBlockTransactionCountByNumber',\n 'eth_getCode',\n 'eth_getEncryptionPublicKey',\n 'eth_getFilterChanges',\n 'eth_getFilterLogs',\n 'eth_getLogs',\n 'eth_getProof',\n 'eth_getStorageAt',\n 'eth_getTransactionByBlockHashAndIndex',\n 'eth_getTransactionByBlockNumberAndIndex',\n 'eth_getTransactionByHash',\n 'eth_getTransactionCount',\n 'eth_getTransactionReceipt',\n 'eth_getUncleByBlockHashAndIndex',\n 'eth_getUncleByBlockNumberAndIndex',\n 'eth_getUncleCountByBlockHash',\n 'eth_getUncleCountByBlockNumber',\n 'eth_getWork',\n 'eth_hashrate',\n 'eth_mining',\n 'eth_newBlockFilter',\n 'eth_newFilter',\n 'eth_newPendingTransactionFilter',\n 'eth_protocolVersion',\n 'eth_sendRawTransaction',\n 'eth_sendTransaction',\n 'eth_sign',\n 'eth_signTypedData',\n 'eth_signTypedData_v1',\n 'eth_signTypedData_v3',\n 'eth_signTypedData_v4',\n 'eth_submitHashrate',\n 'eth_submitWork',\n 'eth_syncing',\n 'eth_uninstallFilter',\n 'metamask_getProviderState',\n 'metamask_watchAsset',\n 'net_listening',\n 'net_peerCount',\n 'net_version',\n 'personal_ecRecover',\n 'personal_sign',\n 'wallet_watchAsset',\n 'web3_clientVersion',\n 'web3_sha3',\n]);\n"],"names":["EXCLUDED_SNAP_ENDOWMENTS","EXCLUDED_SNAP_PERMISSIONS","UNRESTRICTED_METHODS","Object","freeze"],"mappings":"AAAA,OAAO,MAAMA,2BAA2B,EAAE,CAAC;AAE3C,OAAO,MAAMC,4BAA4B,EAAE,CAAC;AAE5C;;;;;;CAMC,GACD,OAAO,MAAMC,uBAAuBC,OAAOC,MAAM,CAAC;IAChD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE"}
@@ -1,39 +0,0 @@
1
- /**
2
- * Mocks encrypting a value using a password. This is not a real encryption
3
- * method, but rather is used to simulate encryption in the tests.
4
- *
5
- * Ideally we would use a real encryption method, such as
6
- * `@metamask/browser-passworder`, but it doesn't seem to work with Node.js 18
7
- * without some mocking. We can switch to a real encryption method once we
8
- * drop support for Node.js 18.
9
- *
10
- * @param password - The password to use.
11
- * @param value - The value to encrypt.
12
- * @returns The "encrypted" value.
13
- */ export function encryptImplementation(password, value) {
14
- return JSON.stringify({
15
- password,
16
- value
17
- });
18
- }
19
- /**
20
- * Mocks decrypting a value using a password. This is not a real encryption
21
- * method, but rather is used to simulate encryption in the tests.
22
- *
23
- * Ideally we would use a real decryption method, such as
24
- * `@metamask/browser-passworder`, but it doesn't seem to work with Node.js 18
25
- * without some mocking. We can switch to a real encryption method once we
26
- * drop support for Node.js 18.
27
- *
28
- * @param password - The password to use.
29
- * @param value - The value to decrypt.
30
- * @returns The "decrypted" value.
31
- */ export function decryptImplementation(password, value) {
32
- const decryptedValue = JSON.parse(value);
33
- if (decryptedValue.password !== password) {
34
- throw new Error('Incorrect password. This is a bug in `@metamask/snaps-jest`, please report it.');
35
- }
36
- return decryptedValue.value;
37
- }
38
-
39
- //# sourceMappingURL=encryption.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../src/internals/simulation/methods/hooks/encryption.ts"],"sourcesContent":["import type { Json } from '@metamask/utils';\n\n/**\n * Mocks encrypting a value using a password. This is not a real encryption\n * method, but rather is used to simulate encryption in the tests.\n *\n * Ideally we would use a real encryption method, such as\n * `@metamask/browser-passworder`, but it doesn't seem to work with Node.js 18\n * without some mocking. We can switch to a real encryption method once we\n * drop support for Node.js 18.\n *\n * @param password - The password to use.\n * @param value - The value to encrypt.\n * @returns The \"encrypted\" value.\n */\nexport function encryptImplementation(password: string, value: Json) {\n return JSON.stringify({\n password,\n value,\n });\n}\n\n/**\n * Mocks decrypting a value using a password. This is not a real encryption\n * method, but rather is used to simulate encryption in the tests.\n *\n * Ideally we would use a real decryption method, such as\n * `@metamask/browser-passworder`, but it doesn't seem to work with Node.js 18\n * without some mocking. We can switch to a real encryption method once we\n * drop support for Node.js 18.\n *\n * @param password - The password to use.\n * @param value - The value to decrypt.\n * @returns The \"decrypted\" value.\n */\nexport function decryptImplementation(password: string, value: string) {\n const decryptedValue = JSON.parse(value);\n if (decryptedValue.password !== password) {\n throw new Error(\n 'Incorrect password. This is a bug in `@metamask/snaps-jest`, please report it.',\n );\n }\n\n return decryptedValue.value;\n}\n"],"names":["encryptImplementation","password","value","JSON","stringify","decryptImplementation","decryptedValue","parse","Error"],"mappings":"AAEA;;;;;;;;;;;;CAYC,GACD,OAAO,SAASA,sBAAsBC,QAAgB,EAAEC,KAAW;IACjE,OAAOC,KAAKC,SAAS,CAAC;QACpBH;QACAC;IACF;AACF;AAEA;;;;;;;;;;;;CAYC,GACD,OAAO,SAASG,sBAAsBJ,QAAgB,EAAEC,KAAa;IACnE,MAAMI,iBAAiBH,KAAKI,KAAK,CAACL;IAClC,IAAII,eAAeL,QAAQ,KAAKA,UAAU;QACxC,MAAM,IAAIO,MACR;IAEJ;IAEA,OAAOF,eAAeJ,KAAK;AAC7B"}
@@ -1,13 +0,0 @@
1
- /**
2
- * Get the implementation of the `getLocale` hook.
3
- *
4
- * @param options - The simulation options.
5
- * @param options.locale - The locale to use.
6
- * @returns The implementation of the `getLocale` hook.
7
- */ export function getGetLocaleMethodImplementation({ locale }) {
8
- return async ()=>{
9
- return locale;
10
- };
11
- }
12
-
13
- //# sourceMappingURL=get-locale.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../src/internals/simulation/methods/hooks/get-locale.ts"],"sourcesContent":["import type { SimulationOptions } from '../../options';\n\n/**\n * Get the implementation of the `getLocale` hook.\n *\n * @param options - The simulation options.\n * @param options.locale - The locale to use.\n * @returns The implementation of the `getLocale` hook.\n */\nexport function getGetLocaleMethodImplementation({\n locale,\n}: SimulationOptions) {\n return async () => {\n return locale;\n };\n}\n"],"names":["getGetLocaleMethodImplementation","locale"],"mappings":"AAEA;;;;;;CAMC,GACD,OAAO,SAASA,iCAAiC,EAC/CC,MAAM,EACY;IAClB,OAAO;QACL,OAAOA;IACT;AACF"}
@@ -1,8 +0,0 @@
1
- export * from './encryption';
2
- export * from './get-locale';
3
- export * from './notifications';
4
- export * from './show-dialog';
5
- export * from './state';
6
- export * from './interface';
7
-
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../src/internals/simulation/methods/hooks/index.ts"],"sourcesContent":["export * from './encryption';\nexport * from './get-locale';\nexport * from './notifications';\nexport * from './show-dialog';\nexport * from './state';\nexport * from './interface';\n"],"names":[],"mappings":"AAAA,cAAc,eAAe;AAC7B,cAAc,eAAe;AAC7B,cAAc,kBAAkB;AAChC,cAAc,gBAAgB;AAC9B,cAAc,UAAU;AACxB,cAAc,cAAc"}
@@ -1,18 +0,0 @@
1
- /**
2
- * Get the implementation of the `createInterface` hook.
3
- *
4
- * @param controllerMessenger - The controller messenger used to call actions.
5
- * @returns The implementation of the `createInterface` hook.
6
- */ export function getCreateInterfaceImplementation(controllerMessenger) {
7
- return async (snapId, content)=>controllerMessenger.call('SnapInterfaceController:createInterface', snapId, content);
8
- }
9
- /**
10
- * Get the implementation of the `getInterface` hook.
11
- *
12
- * @param controllerMessenger - The controller messenger used to call actions.
13
- * @returns The implementation of the `getInterface` hook.
14
- */ export function getGetInterfaceImplementation(controllerMessenger) {
15
- return (snapId, id)=>controllerMessenger.call('SnapInterfaceController:getInterface', snapId, id);
16
- }
17
-
18
- //# sourceMappingURL=interface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../src/internals/simulation/methods/hooks/interface.ts"],"sourcesContent":["import type { Component, SnapId } from '@metamask/snaps-sdk';\n\nimport type { RootControllerMessenger } from '../../controllers';\n\n/**\n * Get the implementation of the `createInterface` hook.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @returns The implementation of the `createInterface` hook.\n */\nexport function getCreateInterfaceImplementation(\n controllerMessenger: RootControllerMessenger,\n) {\n return async (snapId: SnapId, content: Component) =>\n controllerMessenger.call(\n 'SnapInterfaceController:createInterface',\n snapId,\n content,\n );\n}\n\n/**\n * Get the implementation of the `getInterface` hook.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @returns The implementation of the `getInterface` hook.\n */\nexport function getGetInterfaceImplementation(\n controllerMessenger: RootControllerMessenger,\n) {\n return (snapId: SnapId, id: string) =>\n controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n}\n"],"names":["getCreateInterfaceImplementation","controllerMessenger","snapId","content","call","getGetInterfaceImplementation","id"],"mappings":"AAIA;;;;;CAKC,GACD,OAAO,SAASA,iCACdC,mBAA4C;IAE5C,OAAO,OAAOC,QAAgBC,UAC5BF,oBAAoBG,IAAI,CACtB,2CACAF,QACAC;AAEN;AAEA;;;;;CAKC,GACD,OAAO,SAASE,8BACdJ,mBAA4C;IAE5C,OAAO,CAACC,QAAgBI,KACtBL,oBAAoBG,IAAI,CACtB,wCACAF,QACAI;AAEN"}