@metamask/snaps-jest 4.0.1 → 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 (458) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/README.md +66 -179
  3. package/dist/chunk-2KLZ7GOW.js +15 -0
  4. package/dist/chunk-2KLZ7GOW.js.map +1 -0
  5. package/dist/chunk-2M7WQ26F.js +28 -0
  6. package/dist/chunk-2M7WQ26F.js.map +1 -0
  7. package/dist/chunk-34GS3AHA.js +33 -0
  8. package/dist/chunk-34GS3AHA.js.map +1 -0
  9. package/dist/chunk-3CC2NI7R.js +80 -0
  10. package/dist/chunk-3CC2NI7R.js.map +1 -0
  11. package/dist/chunk-3IUQA6YL.mjs +1 -0
  12. package/dist/chunk-3IUQA6YL.mjs.map +1 -0
  13. package/dist/chunk-3KCEPGJA.js +39 -0
  14. package/dist/chunk-3KCEPGJA.js.map +1 -0
  15. package/dist/chunk-3KQYPQZY.js +20 -0
  16. package/dist/chunk-3KQYPQZY.js.map +1 -0
  17. package/dist/chunk-3O5OISLU.js +16 -0
  18. package/dist/chunk-3O5OISLU.js.map +1 -0
  19. package/dist/chunk-3ZW2EE3B.js +1 -0
  20. package/dist/chunk-3ZW2EE3B.js.map +1 -0
  21. package/dist/chunk-4FCRZDOX.js +134 -0
  22. package/dist/chunk-4FCRZDOX.js.map +1 -0
  23. package/dist/chunk-4HY4SM3A.js +1 -0
  24. package/dist/chunk-4HY4SM3A.js.map +1 -0
  25. package/dist/chunk-4JUUFDTC.js +104 -0
  26. package/dist/chunk-4JUUFDTC.js.map +1 -0
  27. package/dist/chunk-4VCE3DRR.mjs +34 -0
  28. package/dist/chunk-4VCE3DRR.mjs.map +1 -0
  29. package/dist/chunk-4WCFXE73.js +48 -0
  30. package/dist/chunk-4WCFXE73.js.map +1 -0
  31. package/dist/chunk-5IUHGC5S.js +153 -0
  32. package/dist/chunk-5IUHGC5S.js.map +1 -0
  33. package/dist/chunk-5O6VBW42.js +42 -0
  34. package/dist/chunk-5O6VBW42.js.map +1 -0
  35. package/dist/chunk-6IMEYERE.js +137 -0
  36. package/dist/chunk-6IMEYERE.js.map +1 -0
  37. package/dist/chunk-6KNT4UMX.mjs +35 -0
  38. package/dist/chunk-6KNT4UMX.mjs.map +1 -0
  39. package/dist/chunk-6RDNSELT.mjs +39 -0
  40. package/dist/chunk-6RDNSELT.mjs.map +1 -0
  41. package/dist/chunk-72YN2D26.mjs +60 -0
  42. package/dist/chunk-72YN2D26.mjs.map +1 -0
  43. package/dist/chunk-7JLVQJK7.js +14 -0
  44. package/dist/chunk-7JLVQJK7.js.map +1 -0
  45. package/dist/chunk-AH7YNG6N.js +22 -0
  46. package/dist/chunk-AH7YNG6N.js.map +1 -0
  47. package/dist/chunk-AIZADBRK.mjs +36 -0
  48. package/dist/chunk-AIZADBRK.mjs.map +1 -0
  49. package/dist/chunk-AKFRQ5EJ.mjs +42 -0
  50. package/dist/chunk-AKFRQ5EJ.mjs.map +1 -0
  51. package/dist/chunk-AUB7XPDH.mjs +28 -0
  52. package/dist/chunk-AUB7XPDH.mjs.map +1 -0
  53. package/dist/chunk-BJMTD7H2.mjs +20 -0
  54. package/dist/chunk-BJMTD7H2.mjs.map +1 -0
  55. package/dist/chunk-BN5VBVT3.mjs +233 -0
  56. package/dist/chunk-BN5VBVT3.mjs.map +1 -0
  57. package/dist/chunk-CKOGTHM4.mjs +22 -0
  58. package/dist/chunk-CKOGTHM4.mjs.map +1 -0
  59. package/dist/chunk-CZQKOZLR.js +11 -0
  60. package/dist/chunk-CZQKOZLR.js.map +1 -0
  61. package/dist/chunk-D36QBJ35.js +24 -0
  62. package/dist/chunk-D36QBJ35.js.map +1 -0
  63. package/dist/chunk-DEFFA5IJ.mjs +24 -0
  64. package/dist/chunk-DEFFA5IJ.mjs.map +1 -0
  65. package/dist/chunk-EFB6AQPB.js +36 -0
  66. package/dist/chunk-EFB6AQPB.js.map +1 -0
  67. package/dist/chunk-EOCDSPT7.mjs +97 -0
  68. package/dist/chunk-EOCDSPT7.mjs.map +1 -0
  69. package/dist/chunk-FPFX5AKR.mjs +36 -0
  70. package/dist/chunk-FPFX5AKR.mjs.map +1 -0
  71. package/dist/chunk-HBT34TJ2.mjs +1 -0
  72. package/dist/chunk-HBT34TJ2.mjs.map +1 -0
  73. package/dist/chunk-HBVDXIVN.mjs +80 -0
  74. package/dist/chunk-HBVDXIVN.mjs.map +1 -0
  75. package/dist/chunk-HMF2CKYT.mjs +39 -0
  76. package/dist/chunk-HMF2CKYT.mjs.map +1 -0
  77. package/dist/chunk-HP56MLQ3.js +1 -0
  78. package/dist/chunk-HP56MLQ3.js.map +1 -0
  79. package/dist/chunk-I5LVU57H.mjs +69 -0
  80. package/dist/chunk-I5LVU57H.mjs.map +1 -0
  81. package/dist/chunk-I7FLOZU7.mjs +1 -0
  82. package/dist/chunk-I7FLOZU7.mjs.map +1 -0
  83. package/dist/chunk-J2ID3DS7.mjs +33 -0
  84. package/dist/chunk-J2ID3DS7.mjs.map +1 -0
  85. package/dist/chunk-JA7RJLI7.js +34 -0
  86. package/dist/chunk-JA7RJLI7.js.map +1 -0
  87. package/dist/chunk-JB2H2XEL.mjs +1 -0
  88. package/dist/chunk-JB2H2XEL.mjs.map +1 -0
  89. package/dist/chunk-JDN3VGMO.js +21 -0
  90. package/dist/chunk-JDN3VGMO.js.map +1 -0
  91. package/dist/chunk-JGQJFYU4.js +57 -0
  92. package/dist/chunk-JGQJFYU4.js.map +1 -0
  93. package/dist/chunk-JJCX335U.mjs +91 -0
  94. package/dist/chunk-JJCX335U.mjs.map +1 -0
  95. package/dist/chunk-JMDSN227.mjs +25 -0
  96. package/dist/chunk-JMDSN227.mjs.map +1 -0
  97. package/dist/chunk-JXOKRTEH.mjs +11 -0
  98. package/dist/chunk-JXOKRTEH.mjs.map +1 -0
  99. package/dist/chunk-JZJWUVD7.mjs +1 -0
  100. package/dist/chunk-JZJWUVD7.mjs.map +1 -0
  101. package/dist/chunk-K2KTKFLP.js +76 -0
  102. package/dist/chunk-K2KTKFLP.js.map +1 -0
  103. package/dist/chunk-KGIWSGTT.js +91 -0
  104. package/dist/chunk-KGIWSGTT.js.map +1 -0
  105. package/dist/chunk-KPXLJ6RH.js +60 -0
  106. package/dist/chunk-KPXLJ6RH.js.map +1 -0
  107. package/dist/chunk-LD5PSHHT.mjs +57 -0
  108. package/dist/chunk-LD5PSHHT.mjs.map +1 -0
  109. package/dist/chunk-LNNKGOHQ.mjs +16 -0
  110. package/dist/chunk-LNNKGOHQ.mjs.map +1 -0
  111. package/dist/chunk-MNDF32ZV.js +8 -0
  112. package/dist/chunk-MNDF32ZV.js.map +1 -0
  113. package/dist/chunk-MSQ7Q2VJ.mjs +13 -0
  114. package/dist/chunk-MSQ7Q2VJ.mjs.map +1 -0
  115. package/dist/chunk-O3VJYBFN.mjs +15 -0
  116. package/dist/chunk-O3VJYBFN.mjs.map +1 -0
  117. package/dist/chunk-O4MJRHZD.js +69 -0
  118. package/dist/chunk-O4MJRHZD.js.map +1 -0
  119. package/dist/chunk-OC64PNDU.mjs +21 -0
  120. package/dist/chunk-OC64PNDU.mjs.map +1 -0
  121. package/dist/chunk-ON6M4WG5.js +36 -0
  122. package/dist/chunk-ON6M4WG5.js.map +1 -0
  123. package/dist/chunk-P7JA42ZC.mjs +153 -0
  124. package/dist/chunk-P7JA42ZC.mjs.map +1 -0
  125. package/dist/chunk-PHUTP7NB.js +25 -0
  126. package/dist/chunk-PHUTP7NB.js.map +1 -0
  127. package/dist/chunk-QFPRGU5L.mjs +104 -0
  128. package/dist/chunk-QFPRGU5L.mjs.map +1 -0
  129. package/dist/chunk-QMHWGASM.js +1 -0
  130. package/dist/chunk-QMHWGASM.js.map +1 -0
  131. package/dist/chunk-QNDLJ2W7.js +1 -0
  132. package/dist/chunk-QNDLJ2W7.js.map +1 -0
  133. package/dist/chunk-QUUILTDY.mjs +137 -0
  134. package/dist/chunk-QUUILTDY.mjs.map +1 -0
  135. package/dist/chunk-R7ORBTUD.js +1 -0
  136. package/dist/chunk-R7ORBTUD.js.map +1 -0
  137. package/dist/chunk-RQBZLDXL.js +233 -0
  138. package/dist/chunk-RQBZLDXL.js.map +1 -0
  139. package/dist/chunk-S3DHQTXB.js +1 -0
  140. package/dist/chunk-S3DHQTXB.js.map +1 -0
  141. package/dist/chunk-SWSSV3LK.js +35 -0
  142. package/dist/chunk-SWSSV3LK.js.map +1 -0
  143. package/dist/chunk-T4TRX3ZR.js +22 -0
  144. package/dist/chunk-T4TRX3ZR.js.map +1 -0
  145. package/dist/chunk-UXHKMILA.mjs +1 -0
  146. package/dist/chunk-UXHKMILA.mjs.map +1 -0
  147. package/dist/chunk-VCXM6FKU.mjs +1 -0
  148. package/dist/chunk-VCXM6FKU.mjs.map +1 -0
  149. package/dist/chunk-VHTVUQWR.mjs +14 -0
  150. package/dist/chunk-VHTVUQWR.mjs.map +1 -0
  151. package/dist/chunk-VNQIROKZ.js +97 -0
  152. package/dist/chunk-VNQIROKZ.js.map +1 -0
  153. package/dist/chunk-VXQOXWRO.mjs +48 -0
  154. package/dist/chunk-VXQOXWRO.mjs.map +1 -0
  155. package/dist/chunk-VYKYQSUI.mjs +22 -0
  156. package/dist/chunk-VYKYQSUI.mjs.map +1 -0
  157. package/dist/chunk-WEI35OIM.mjs +8 -0
  158. package/dist/chunk-WEI35OIM.mjs.map +1 -0
  159. package/dist/chunk-WL2GRM5E.mjs +76 -0
  160. package/dist/chunk-WL2GRM5E.mjs.map +1 -0
  161. package/dist/chunk-XDZPH5WD.js +39 -0
  162. package/dist/chunk-XDZPH5WD.js.map +1 -0
  163. package/dist/chunk-Y5NWZU43.js +13 -0
  164. package/dist/chunk-Y5NWZU43.js.map +1 -0
  165. package/dist/chunk-YZFWCFMG.js +1 -0
  166. package/dist/chunk-YZFWCFMG.js.map +1 -0
  167. package/dist/chunk-ZCE26WZM.mjs +1 -0
  168. package/dist/chunk-ZCE26WZM.mjs.map +1 -0
  169. package/dist/chunk-ZZPKZRJQ.mjs +134 -0
  170. package/dist/chunk-ZZPKZRJQ.mjs.map +1 -0
  171. package/dist/environment.js +47 -0
  172. package/dist/environment.js.map +1 -0
  173. package/dist/environment.mjs +47 -0
  174. package/dist/environment.mjs.map +1 -0
  175. package/dist/helpers.js +44 -0
  176. package/dist/helpers.js.map +1 -0
  177. package/dist/helpers.mjs +44 -0
  178. package/dist/helpers.mjs.map +1 -0
  179. package/dist/index.js +54 -0
  180. package/dist/index.js.map +1 -0
  181. package/dist/index.mjs +54 -0
  182. package/dist/index.mjs.map +1 -0
  183. package/dist/internals/environment.js +8 -0
  184. package/dist/internals/environment.js.map +1 -0
  185. package/dist/internals/environment.mjs +8 -0
  186. package/dist/internals/environment.mjs.map +1 -0
  187. package/dist/internals/index.js +123 -0
  188. package/dist/internals/index.js.map +1 -0
  189. package/dist/internals/index.mjs +123 -0
  190. package/dist/internals/index.mjs.map +1 -0
  191. package/dist/internals/logger.js +8 -0
  192. package/dist/internals/logger.js.map +1 -0
  193. package/dist/internals/logger.mjs +8 -0
  194. package/dist/internals/logger.mjs.map +1 -0
  195. package/dist/internals/request.js +40 -0
  196. package/dist/internals/request.js.map +1 -0
  197. package/dist/internals/request.mjs +40 -0
  198. package/dist/internals/request.mjs.map +1 -0
  199. package/dist/internals/server.js +9 -0
  200. package/dist/internals/server.js.map +1 -0
  201. package/dist/internals/server.mjs +9 -0
  202. package/dist/internals/server.mjs.map +1 -0
  203. package/dist/internals/simulation/constants.js +12 -0
  204. package/dist/internals/simulation/constants.js.map +1 -0
  205. package/dist/internals/simulation/constants.mjs +12 -0
  206. package/dist/internals/simulation/constants.mjs.map +1 -0
  207. package/dist/internals/simulation/controllers.js +26 -0
  208. package/dist/internals/simulation/controllers.js.map +1 -0
  209. package/dist/internals/simulation/controllers.mjs +26 -0
  210. package/dist/internals/simulation/controllers.mjs.map +1 -0
  211. package/dist/internals/simulation/files.js +8 -0
  212. package/dist/internals/simulation/files.js.map +1 -0
  213. package/dist/internals/simulation/files.mjs +8 -0
  214. package/dist/internals/simulation/files.mjs.map +1 -0
  215. package/dist/internals/simulation/index.js +90 -0
  216. package/dist/internals/simulation/index.js.map +1 -0
  217. package/dist/internals/simulation/index.mjs +90 -0
  218. package/dist/internals/simulation/index.mjs.map +1 -0
  219. package/dist/internals/simulation/interface.js +16 -0
  220. package/dist/internals/simulation/interface.js.map +1 -0
  221. package/dist/internals/simulation/interface.mjs +16 -0
  222. package/dist/internals/simulation/interface.mjs.map +1 -0
  223. package/dist/internals/simulation/methods/constants.js +12 -0
  224. package/dist/internals/simulation/methods/constants.js.map +1 -0
  225. package/dist/internals/simulation/methods/constants.mjs +12 -0
  226. package/dist/internals/simulation/methods/constants.mjs.map +1 -0
  227. package/dist/internals/simulation/methods/hooks/encryption.js +10 -0
  228. package/dist/internals/simulation/methods/hooks/encryption.js.map +1 -0
  229. package/dist/internals/simulation/methods/hooks/encryption.mjs +10 -0
  230. package/dist/internals/simulation/methods/hooks/encryption.mjs.map +1 -0
  231. package/dist/internals/simulation/methods/hooks/get-locale.js +8 -0
  232. package/dist/internals/simulation/methods/hooks/get-locale.js.map +1 -0
  233. package/dist/internals/simulation/methods/hooks/get-locale.mjs +8 -0
  234. package/dist/internals/simulation/methods/hooks/get-locale.mjs.map +1 -0
  235. package/dist/internals/simulation/methods/hooks/index.js +45 -0
  236. package/dist/internals/simulation/methods/hooks/index.js.map +1 -0
  237. package/dist/internals/simulation/methods/hooks/index.mjs +45 -0
  238. package/dist/internals/simulation/methods/hooks/index.mjs.map +1 -0
  239. package/dist/internals/simulation/methods/hooks/interface.js +10 -0
  240. package/dist/internals/simulation/methods/hooks/interface.js.map +1 -0
  241. package/dist/internals/simulation/methods/hooks/interface.mjs +10 -0
  242. package/dist/internals/simulation/methods/hooks/interface.mjs.map +1 -0
  243. package/dist/internals/simulation/methods/hooks/notifications.js +16 -0
  244. package/dist/internals/simulation/methods/hooks/notifications.js.map +1 -0
  245. package/dist/internals/simulation/methods/hooks/notifications.mjs +16 -0
  246. package/dist/internals/simulation/methods/hooks/notifications.mjs.map +1 -0
  247. package/dist/internals/simulation/methods/hooks/show-dialog.js +14 -0
  248. package/dist/internals/simulation/methods/hooks/show-dialog.js.map +1 -0
  249. package/dist/internals/simulation/methods/hooks/show-dialog.mjs +14 -0
  250. package/dist/internals/simulation/methods/hooks/show-dialog.mjs.map +1 -0
  251. package/dist/internals/simulation/methods/hooks/state.js +18 -0
  252. package/dist/internals/simulation/methods/hooks/state.js.map +1 -0
  253. package/dist/internals/simulation/methods/hooks/state.mjs +18 -0
  254. package/dist/internals/simulation/methods/hooks/state.mjs.map +1 -0
  255. package/dist/internals/simulation/methods/index.js +29 -0
  256. package/dist/internals/simulation/methods/index.js.map +1 -0
  257. package/dist/internals/simulation/methods/index.mjs +29 -0
  258. package/dist/internals/simulation/methods/index.mjs.map +1 -0
  259. package/dist/internals/simulation/methods/specifications.js +28 -0
  260. package/dist/internals/simulation/methods/specifications.js.map +1 -0
  261. package/dist/internals/simulation/methods/specifications.mjs +28 -0
  262. package/dist/internals/simulation/methods/specifications.mjs.map +1 -0
  263. package/dist/internals/simulation/middleware/engine.js +15 -0
  264. package/dist/internals/simulation/middleware/engine.js.map +1 -0
  265. package/dist/internals/simulation/middleware/engine.mjs +15 -0
  266. package/dist/internals/simulation/middleware/engine.mjs.map +1 -0
  267. package/dist/internals/simulation/middleware/index.js +16 -0
  268. package/dist/internals/simulation/middleware/index.js.map +1 -0
  269. package/dist/internals/simulation/middleware/index.mjs +16 -0
  270. package/dist/internals/simulation/middleware/index.mjs.map +1 -0
  271. package/dist/internals/simulation/middleware/internal-methods/accounts.js +8 -0
  272. package/dist/internals/simulation/middleware/internal-methods/accounts.js.map +1 -0
  273. package/dist/internals/simulation/middleware/internal-methods/accounts.mjs +8 -0
  274. package/dist/internals/simulation/middleware/internal-methods/accounts.mjs.map +1 -0
  275. package/dist/internals/simulation/middleware/internal-methods/index.js +11 -0
  276. package/dist/internals/simulation/middleware/internal-methods/index.js.map +1 -0
  277. package/dist/internals/simulation/middleware/internal-methods/index.mjs +11 -0
  278. package/dist/internals/simulation/middleware/internal-methods/index.mjs.map +1 -0
  279. package/dist/internals/simulation/middleware/internal-methods/middleware.js +10 -0
  280. package/dist/internals/simulation/middleware/internal-methods/middleware.js.map +1 -0
  281. package/dist/internals/simulation/middleware/internal-methods/middleware.mjs +10 -0
  282. package/dist/internals/simulation/middleware/internal-methods/middleware.mjs.map +1 -0
  283. package/dist/internals/simulation/middleware/internal-methods/provider-state.js +8 -0
  284. package/dist/internals/simulation/middleware/internal-methods/provider-state.js.map +1 -0
  285. package/dist/internals/simulation/middleware/internal-methods/provider-state.mjs +8 -0
  286. package/dist/internals/simulation/middleware/internal-methods/provider-state.mjs.map +1 -0
  287. package/dist/internals/simulation/middleware/mock.js +9 -0
  288. package/dist/internals/simulation/middleware/mock.js.map +1 -0
  289. package/dist/internals/simulation/middleware/mock.mjs +9 -0
  290. package/dist/internals/simulation/middleware/mock.mjs.map +1 -0
  291. package/dist/internals/simulation/options.js +9 -0
  292. package/dist/internals/simulation/options.js.map +1 -0
  293. package/dist/internals/simulation/options.mjs +9 -0
  294. package/dist/internals/simulation/options.mjs.map +1 -0
  295. package/dist/internals/simulation/simulation.js +39 -0
  296. package/dist/internals/simulation/simulation.js.map +1 -0
  297. package/dist/internals/simulation/simulation.mjs +39 -0
  298. package/dist/internals/simulation/simulation.mjs.map +1 -0
  299. package/dist/internals/simulation/store/index.js +44 -0
  300. package/dist/internals/simulation/store/index.js.map +1 -0
  301. package/dist/internals/simulation/store/index.mjs +44 -0
  302. package/dist/internals/simulation/store/index.mjs.map +1 -0
  303. package/dist/internals/simulation/store/mocks.js +16 -0
  304. package/dist/internals/simulation/store/mocks.js.map +1 -0
  305. package/dist/internals/simulation/store/mocks.mjs +16 -0
  306. package/dist/internals/simulation/store/mocks.mjs.map +1 -0
  307. package/dist/internals/simulation/store/notifications.js +16 -0
  308. package/dist/internals/simulation/store/notifications.js.map +1 -0
  309. package/dist/internals/simulation/store/notifications.mjs +16 -0
  310. package/dist/internals/simulation/store/notifications.mjs.map +1 -0
  311. package/dist/internals/simulation/store/state.js +14 -0
  312. package/dist/internals/simulation/store/state.js.map +1 -0
  313. package/dist/internals/simulation/store/state.mjs +14 -0
  314. package/dist/internals/simulation/store/state.mjs.map +1 -0
  315. package/dist/internals/simulation/store/store.js +12 -0
  316. package/dist/internals/simulation/store/store.js.map +1 -0
  317. package/dist/internals/simulation/store/store.mjs +12 -0
  318. package/dist/internals/simulation/store/store.mjs.map +1 -0
  319. package/dist/internals/simulation/store/ui.js +16 -0
  320. package/dist/internals/simulation/store/ui.js.map +1 -0
  321. package/dist/internals/simulation/store/ui.mjs +16 -0
  322. package/dist/internals/simulation/store/ui.mjs.map +1 -0
  323. package/dist/internals/structs.js +18 -0
  324. package/dist/internals/structs.js.map +1 -0
  325. package/dist/internals/structs.mjs +18 -0
  326. package/dist/internals/structs.mjs.map +1 -0
  327. package/dist/matchers.js +50 -0
  328. package/dist/matchers.js.map +1 -0
  329. package/dist/matchers.mjs +50 -0
  330. package/dist/matchers.mjs.map +1 -0
  331. package/dist/options.js +8 -0
  332. package/dist/options.js.map +1 -0
  333. package/dist/options.mjs +8 -0
  334. package/dist/options.mjs.map +1 -0
  335. package/dist/setup.js +39 -0
  336. package/dist/setup.js.map +1 -0
  337. package/dist/setup.mjs +39 -0
  338. package/dist/setup.mjs.map +1 -0
  339. package/dist/tsconfig.build.tsbuildinfo +1 -0
  340. package/dist/types/environment.d.ts +14 -15
  341. package/dist/types/helpers.d.ts +64 -3
  342. package/dist/types/internals/index.d.ts +1 -4
  343. package/dist/types/internals/request.d.ts +38 -74
  344. package/dist/types/internals/simulation/constants.d.ts +13 -0
  345. package/dist/types/internals/simulation/controllers.d.ts +40 -0
  346. package/dist/types/internals/simulation/files.d.ts +11 -0
  347. package/dist/types/internals/simulation/index.d.ts +5 -0
  348. package/dist/types/internals/simulation/interface.d.ts +25 -0
  349. package/dist/types/internals/simulation/methods/constants.d.ts +10 -0
  350. package/dist/types/internals/simulation/methods/hooks/encryption.d.ts +29 -0
  351. package/dist/types/internals/simulation/methods/hooks/get-locale.d.ts +9 -0
  352. package/dist/types/internals/simulation/methods/hooks/index.d.ts +6 -0
  353. package/dist/types/internals/simulation/methods/hooks/interface.d.ts +16 -0
  354. package/dist/types/internals/simulation/methods/hooks/notifications.d.ts +16 -0
  355. package/dist/types/internals/simulation/methods/hooks/show-dialog.d.ts +9 -0
  356. package/dist/types/internals/simulation/methods/hooks/state.d.ts +22 -0
  357. package/dist/types/internals/simulation/methods/index.d.ts +1 -0
  358. package/dist/types/internals/simulation/methods/specifications.d.ts +56 -0
  359. package/dist/types/internals/simulation/middleware/engine.d.ts +26 -0
  360. package/dist/types/internals/simulation/middleware/index.d.ts +1 -0
  361. package/dist/types/internals/simulation/middleware/internal-methods/accounts.d.ts +18 -0
  362. package/dist/types/internals/simulation/middleware/internal-methods/index.d.ts +1 -0
  363. package/dist/types/internals/simulation/middleware/internal-methods/middleware.d.ts +22 -0
  364. package/dist/types/internals/simulation/middleware/internal-methods/provider-state.d.ts +14 -0
  365. package/dist/types/internals/simulation/middleware/mock.d.ts +10 -0
  366. package/dist/types/internals/simulation/options.d.ts +37 -0
  367. package/dist/types/internals/simulation/simulation.d.ts +98 -0
  368. package/dist/types/internals/simulation/store/index.d.ts +4 -0
  369. package/dist/types/internals/simulation/store/mocks.d.ts +35 -0
  370. package/dist/types/internals/simulation/store/notifications.d.ts +44 -0
  371. package/dist/types/internals/simulation/store/state.d.ts +55 -0
  372. package/dist/types/internals/simulation/store/store.d.ts +22 -0
  373. package/dist/types/internals/simulation/store/ui.d.ts +25 -0
  374. package/dist/types/internals/structs.d.ts +153 -0
  375. package/dist/types/options.d.ts +3 -35
  376. package/dist/types/types.d.ts +88 -41
  377. package/dist/types/vendor/readable-stream.d.js +1 -0
  378. package/dist/types/vendor/readable-stream.d.js.map +1 -0
  379. package/dist/types/vendor/readable-stream.d.mjs +1 -0
  380. package/dist/types/vendor/readable-stream.d.mjs.map +1 -0
  381. package/dist/types.js +2 -0
  382. package/dist/types.js.map +1 -0
  383. package/dist/types.mjs +2 -0
  384. package/dist/types.mjs.map +1 -0
  385. package/jest-preset.js +1 -1
  386. package/package.json +37 -24
  387. package/dist/cjs/environment.js +0 -205
  388. package/dist/cjs/environment.js.map +0 -1
  389. package/dist/cjs/helpers.js +0 -67
  390. package/dist/cjs/helpers.js.map +0 -1
  391. package/dist/cjs/index.js +0 -42
  392. package/dist/cjs/index.js.map +0 -1
  393. package/dist/cjs/internals/environment.js +0 -19
  394. package/dist/cjs/internals/environment.js.map +0 -1
  395. package/dist/cjs/internals/index.js +0 -28
  396. package/dist/cjs/internals/index.js.map +0 -1
  397. package/dist/cjs/internals/interface.js +0 -103
  398. package/dist/cjs/internals/interface.js.map +0 -1
  399. package/dist/cjs/internals/logger.js +0 -14
  400. package/dist/cjs/internals/logger.js.map +0 -1
  401. package/dist/cjs/internals/network.js +0 -148
  402. package/dist/cjs/internals/network.js.map +0 -1
  403. package/dist/cjs/internals/request.js +0 -121
  404. package/dist/cjs/internals/request.js.map +0 -1
  405. package/dist/cjs/internals/server.js +0 -75
  406. package/dist/cjs/internals/server.js.map +0 -1
  407. package/dist/cjs/internals/structs.js +0 -122
  408. package/dist/cjs/internals/structs.js.map +0 -1
  409. package/dist/cjs/internals/types.js +0 -6
  410. package/dist/cjs/internals/types.js.map +0 -1
  411. package/dist/cjs/internals/wait-for.js +0 -63
  412. package/dist/cjs/internals/wait-for.js.map +0 -1
  413. package/dist/cjs/matchers.js +0 -117
  414. package/dist/cjs/matchers.js.map +0 -1
  415. package/dist/cjs/options.js +0 -29
  416. package/dist/cjs/options.js.map +0 -1
  417. package/dist/cjs/setup.js +0 -10
  418. package/dist/cjs/setup.js.map +0 -1
  419. package/dist/cjs/types.js +0 -6
  420. package/dist/cjs/types.js.map +0 -1
  421. package/dist/esm/environment.js +0 -182
  422. package/dist/esm/environment.js.map +0 -1
  423. package/dist/esm/helpers.js +0 -82
  424. package/dist/esm/helpers.js.map +0 -1
  425. package/dist/esm/index.js +0 -6
  426. package/dist/esm/index.js.map +0 -1
  427. package/dist/esm/internals/environment.js +0 -14
  428. package/dist/esm/internals/environment.js.map +0 -1
  429. package/dist/esm/internals/index.js +0 -12
  430. package/dist/esm/internals/index.js.map +0 -1
  431. package/dist/esm/internals/interface.js +0 -100
  432. package/dist/esm/internals/interface.js.map +0 -1
  433. package/dist/esm/internals/logger.js +0 -4
  434. package/dist/esm/internals/logger.js.map +0 -1
  435. package/dist/esm/internals/network.js +0 -143
  436. package/dist/esm/internals/network.js.map +0 -1
  437. package/dist/esm/internals/request.js +0 -120
  438. package/dist/esm/internals/request.js.map +0 -1
  439. package/dist/esm/internals/server.js +0 -68
  440. package/dist/esm/internals/server.js.map +0 -1
  441. package/dist/esm/internals/structs.js +0 -98
  442. package/dist/esm/internals/structs.js.map +0 -1
  443. package/dist/esm/internals/types.js +0 -3
  444. package/dist/esm/internals/types.js.map +0 -1
  445. package/dist/esm/internals/wait-for.js +0 -63
  446. package/dist/esm/internals/wait-for.js.map +0 -1
  447. package/dist/esm/matchers.js +0 -108
  448. package/dist/esm/matchers.js.map +0 -1
  449. package/dist/esm/options.js +0 -26
  450. package/dist/esm/options.js.map +0 -1
  451. package/dist/esm/setup.js +0 -6
  452. package/dist/esm/setup.js.map +0 -1
  453. package/dist/esm/types.js +0 -3
  454. package/dist/esm/types.js.map +0 -1
  455. package/dist/types/internals/interface.d.ts +0 -25
  456. package/dist/types/internals/network.d.ts +0 -87
  457. package/dist/types/internals/types.d.ts +0 -18
  458. package/dist/types/internals/wait-for.d.ts +0 -38
@@ -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, dirname } from 'path';\n\nimport type { SnapsEnvironmentOptions } from '../options';\nimport { rootLogger } from './logger';\n\nconst SNAPS_EXECUTION_ENVIRONMENTS_PATH = pathResolve(\n dirname(\n require.resolve('@metamask/snaps-execution-environments/package.json'),\n ),\n 'dist',\n 'browserify',\n 'iframe',\n);\n\nconst SNAPS_SIMULATOR_PATH = pathResolve(\n dirname(require.resolve('@metamask/snaps-simulator/package.json')),\n 'dist',\n 'webpack',\n 'test',\n);\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('/environment', express.static(SNAPS_EXECUTION_ENVIRONMENTS_PATH));\n app.use('/simulator', express.static(SNAPS_SIMULATOR_PATH));\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","dirname","rootLogger","SNAPS_EXECUTION_ENVIRONMENTS_PATH","require","SNAPS_SIMULATOR_PATH","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,EAAEC,OAAO,QAAQ,OAAO;AAGvD,SAASC,UAAU,QAAQ,WAAW;AAEtC,MAAMC,oCAAoCH,YACxCC,QACEG,QAAQL,OAAO,CAAC,yDAElB,QACA,cACA;AAGF,MAAMM,uBAAuBL,YAC3BC,QAAQG,QAAQL,OAAO,CAAC,4CACxB,QACA,WACA;AAQF;;;;;;;;;CASC,GACD,eAAeO,WAAWC,IAAY;IACpC,IAAI,CAACA,MAAM;QACT,MAAM,IAAIC,MAAM;IAClB;IAEA,IAAI,CAAE,MAAMhB,YAAYe,MAAM,QAAS;QACrC,MAAM,IAAIC,MAAM,CAAC,gBAAgB,EAAED,KAAK,qBAAqB,CAAC;IAChE;IAEA,MAAME,eAAeT,YAAYO,MAAM;IACvC,MAAMG,WAAyB,MAAMb,GAClCc,QAAQ,CAACF,cAAc,QACvBG,IAAI,CAACC,KAAKC,KAAK;IAElBvB,qBAAqBmB;IACrB,MAAMK,WAAWf,YAAYO,MAAMG,SAASM,MAAM,CAACC,QAAQ,CAACC,GAAG,CAACH,QAAQ;IAExE,IAAI,CAAE,MAAMtB,OAAOsB,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,MAAM3B,mBAAmBQ,YAAY;IAC3C,MAAMoB,MAAM3B;IAEZ2B,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,CAAC,gBAAgB5B,QAAQiC,MAAM,CAACzB;IACvCmB,IAAIC,GAAG,CAAC,cAAc5B,QAAQiC,MAAM,CAACvB;IACrCiB,IAAIC,GAAG,CAAC5B,QAAQiC,MAAM,CAAC5B,YAAY6B,QAAQC,GAAG,IAAIV,QAAQb,IAAI;IAE9D,MAAMwB,SAASjC,aAAawB;IAC5B,OAAO,MAAM,IAAIU,QAAgB,CAACjC,SAASkC;QACzCF,OAAOG,MAAM,CAACd,QAAQe,IAAI,EAAE;YAC1BpC,QAAQgC;QACV;QAEAA,OAAOK,EAAE,CAAC,SAAS,CAACC;YAClBhB,IAAIgB;YACJJ,OAAOI;QACT;IACF;AACF"}
@@ -1,98 +0,0 @@
1
- import { NotificationType, ComponentStruct, enumValue } from '@metamask/snaps-sdk';
2
- import { bytesToHex, JsonStruct, StrictHexStruct, valueToBytes } from '@metamask/utils';
3
- import { randomBytes } from 'crypto';
4
- import { array, assign, bigint, coerce, defaulted, instance, literal, number, object, optional, string, type, union } from 'superstruct';
5
- // TODO: Export this from `@metamask/utils` instead.
6
- const BytesLikeStruct = union([
7
- bigint(),
8
- number(),
9
- string(),
10
- instance(Uint8Array)
11
- ]);
12
- export const TransactionOptionsStruct = object({
13
- /**
14
- * The CAIP-2 chain ID to send the transaction on. Defaults to `eip155:1`.
15
- */ chainId: defaulted(string(), 'eip155:1'),
16
- /**
17
- * The origin to send the transaction from. Defaults to `metamask.io`.
18
- */ origin: defaulted(string(), 'metamask.io'),
19
- /**
20
- * The address to send the transaction from. Defaults to a randomly generated
21
- * address.
22
- */ // TODO: Move this coercer to `@metamask/utils`.
23
- from: coerce(StrictHexStruct, optional(BytesLikeStruct), (value)=>{
24
- if (value) {
25
- return bytesToHex(valueToBytes(value));
26
- }
27
- return bytesToHex(randomBytes(20));
28
- }),
29
- /**
30
- * The address to send the transaction to. Defaults to a randomly generated
31
- * address.
32
- */ // TODO: Move this coercer to `@metamask/utils`.
33
- to: coerce(StrictHexStruct, optional(BytesLikeStruct), (value)=>{
34
- if (value) {
35
- return bytesToHex(valueToBytes(value));
36
- }
37
- return bytesToHex(randomBytes(20));
38
- }),
39
- /**
40
- * The value to send with the transaction. The value may be specified as a
41
- * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.
42
- */ value: defaulted(coerce(StrictHexStruct, BytesLikeStruct, (value)=>bytesToHex(valueToBytes(value))), '0x0'),
43
- /**
44
- * The gas limit to use for the transaction. The gas limit may be specified
45
- * as a `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `21_000`.
46
- */ gasLimit: defaulted(coerce(StrictHexStruct, BytesLikeStruct, (value)=>bytesToHex(valueToBytes(value))), valueToBytes(21000)),
47
- /**
48
- * The max fee per gas (in Wei) to use for the transaction. The max fee per
49
- * gas may be specified as a `number`, `bigint`, `string`, or `Uint8Array`.
50
- * Defaults to `1`.
51
- */ maxFeePerGas: defaulted(coerce(StrictHexStruct, BytesLikeStruct, (value)=>bytesToHex(valueToBytes(value))), valueToBytes(1)),
52
- /**
53
- * The max priority fee per gas (in Wei) to use for the transaction. The max
54
- * priority fee per gas may be specified as a `number`, `bigint`, `string`,
55
- * or `Uint8Array`. Defaults to `1`.
56
- */ maxPriorityFeePerGas: defaulted(coerce(StrictHexStruct, BytesLikeStruct, (value)=>bytesToHex(valueToBytes(value))), valueToBytes(1)),
57
- /**
58
- * The nonce to use for the transaction. The nonce may be specified as a
59
- * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.
60
- */ nonce: defaulted(coerce(StrictHexStruct, BytesLikeStruct, (value)=>bytesToHex(valueToBytes(value))), valueToBytes(0)),
61
- /**
62
- * The data to send with the transaction. The data may be specified as a
63
- * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0x`.
64
- */ data: defaulted(coerce(union([
65
- StrictHexStruct,
66
- literal('0x')
67
- ]), BytesLikeStruct, (value)=>bytesToHex(valueToBytes(value))), '0x')
68
- });
69
- export const SnapOptionsStruct = object({
70
- /**
71
- * The timeout in milliseconds to use for requests to the snap. Defaults to
72
- * `1000`.
73
- */ timeout: defaulted(optional(number()), 1000)
74
- });
75
- export const InterfaceStruct = type({
76
- content: optional(ComponentStruct)
77
- });
78
- export const SnapResponseStruct = assign(InterfaceStruct, object({
79
- id: string(),
80
- response: union([
81
- object({
82
- result: JsonStruct
83
- }),
84
- object({
85
- error: JsonStruct
86
- })
87
- ]),
88
- notifications: array(object({
89
- id: string(),
90
- message: string(),
91
- type: union([
92
- enumValue(NotificationType.InApp),
93
- enumValue(NotificationType.Native)
94
- ])
95
- }))
96
- }));
97
-
98
- //# sourceMappingURL=structs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/internals/structs.ts"],"sourcesContent":["import {\n NotificationType,\n ComponentStruct,\n enumValue,\n} from '@metamask/snaps-sdk';\nimport {\n bytesToHex,\n JsonStruct,\n StrictHexStruct,\n valueToBytes,\n} from '@metamask/utils';\nimport { randomBytes } from 'crypto';\nimport {\n array,\n assign,\n bigint,\n coerce,\n defaulted,\n instance,\n literal,\n number,\n object,\n optional,\n string,\n type,\n union,\n} from 'superstruct';\n\n// TODO: Export this from `@metamask/utils` instead.\nconst BytesLikeStruct = union([\n bigint(),\n number(),\n string(),\n instance(Uint8Array),\n]);\n\nexport const TransactionOptionsStruct = object({\n /**\n * The CAIP-2 chain ID to send the transaction on. Defaults to `eip155:1`.\n */\n chainId: defaulted(string(), 'eip155:1'),\n\n /**\n * The origin to send the transaction from. Defaults to `metamask.io`.\n */\n origin: defaulted(string(), 'metamask.io'),\n\n /**\n * The address to send the transaction from. Defaults to a randomly generated\n * address.\n */\n // TODO: Move this coercer to `@metamask/utils`.\n from: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The address to send the transaction to. Defaults to a randomly generated\n * address.\n */\n // TODO: Move this coercer to `@metamask/utils`.\n to: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The value to send with the transaction. The value may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.\n */\n value: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n '0x0',\n ),\n\n /**\n * The gas limit to use for the transaction. The gas limit may be specified\n * as a `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `21_000`.\n */\n gasLimit: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(21_000),\n ),\n\n /**\n * The max fee per gas (in Wei) to use for the transaction. The max fee per\n * gas may be specified as a `number`, `bigint`, `string`, or `Uint8Array`.\n * Defaults to `1`.\n */\n maxFeePerGas: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(1),\n ),\n\n /**\n * The max priority fee per gas (in Wei) to use for the transaction. The max\n * priority fee per gas may be specified as a `number`, `bigint`, `string`,\n * or `Uint8Array`. Defaults to `1`.\n */\n maxPriorityFeePerGas: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(1),\n ),\n\n /**\n * The nonce to use for the transaction. The nonce may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.\n */\n nonce: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(0),\n ),\n\n /**\n * The data to send with the transaction. The data may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0x`.\n */\n data: defaulted(\n coerce(union([StrictHexStruct, literal('0x')]), BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n '0x',\n ),\n});\n\nexport const SnapOptionsStruct = object({\n /**\n * The timeout in milliseconds to use for requests to the snap. Defaults to\n * `1000`.\n */\n timeout: defaulted(optional(number()), 1000),\n});\n\nexport const InterfaceStruct = type({\n content: optional(ComponentStruct),\n});\n\nexport const SnapResponseStruct = assign(\n InterfaceStruct,\n object({\n id: string(),\n\n response: union([\n object({\n result: JsonStruct,\n }),\n object({\n error: JsonStruct,\n }),\n ]),\n\n notifications: array(\n object({\n id: string(),\n message: string(),\n type: union([\n enumValue(NotificationType.InApp),\n enumValue(NotificationType.Native),\n ]),\n }),\n ),\n }),\n);\n"],"names":["NotificationType","ComponentStruct","enumValue","bytesToHex","JsonStruct","StrictHexStruct","valueToBytes","randomBytes","array","assign","bigint","coerce","defaulted","instance","literal","number","object","optional","string","type","union","BytesLikeStruct","Uint8Array","TransactionOptionsStruct","chainId","origin","from","value","to","gasLimit","maxFeePerGas","maxPriorityFeePerGas","nonce","data","SnapOptionsStruct","timeout","InterfaceStruct","content","SnapResponseStruct","id","response","result","error","notifications","message","InApp","Native"],"mappings":"AAAA,SACEA,gBAAgB,EAChBC,eAAe,EACfC,SAAS,QACJ,sBAAsB;AAC7B,SACEC,UAAU,EACVC,UAAU,EACVC,eAAe,EACfC,YAAY,QACP,kBAAkB;AACzB,SAASC,WAAW,QAAQ,SAAS;AACrC,SACEC,KAAK,EACLC,MAAM,EACNC,MAAM,EACNC,MAAM,EACNC,SAAS,EACTC,QAAQ,EACRC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,IAAI,EACJC,KAAK,QACA,cAAc;AAErB,oDAAoD;AACpD,MAAMC,kBAAkBD,MAAM;IAC5BV;IACAK;IACAG;IACAL,SAASS;CACV;AAED,OAAO,MAAMC,2BAA2BP,OAAO;IAC7C;;GAEC,GACDQ,SAASZ,UAAUM,UAAU;IAE7B;;GAEC,GACDO,QAAQb,UAAUM,UAAU;IAE5B;;;GAGC,GACD,gDAAgD;IAChDQ,MAAMf,OAAON,iBAAiBY,SAASI,kBAAkB,CAACM;QACxD,IAAIA,OAAO;YACT,OAAOxB,WAAWG,aAAaqB;QACjC;QAEA,OAAOxB,WAAWI,YAAY;IAChC;IAEA;;;GAGC,GACD,gDAAgD;IAChDqB,IAAIjB,OAAON,iBAAiBY,SAASI,kBAAkB,CAACM;QACtD,IAAIA,OAAO;YACT,OAAOxB,WAAWG,aAAaqB;QACjC;QAEA,OAAOxB,WAAWI,YAAY;IAChC;IAEA;;;GAGC,GACDoB,OAAOf,UACLD,OAAON,iBAAiBgB,iBAAiB,CAACM,QACxCxB,WAAWG,aAAaqB,UAE1B;IAGF;;;GAGC,GACDE,UAAUjB,UACRD,OAAON,iBAAiBgB,iBAAiB,CAACM,QACxCxB,WAAWG,aAAaqB,UAE1BrB,aAAa;IAGf;;;;GAIC,GACDwB,cAAclB,UACZD,OAAON,iBAAiBgB,iBAAiB,CAACM,QACxCxB,WAAWG,aAAaqB,UAE1BrB,aAAa;IAGf;;;;GAIC,GACDyB,sBAAsBnB,UACpBD,OAAON,iBAAiBgB,iBAAiB,CAACM,QACxCxB,WAAWG,aAAaqB,UAE1BrB,aAAa;IAGf;;;GAGC,GACD0B,OAAOpB,UACLD,OAAON,iBAAiBgB,iBAAiB,CAACM,QACxCxB,WAAWG,aAAaqB,UAE1BrB,aAAa;IAGf;;;GAGC,GACD2B,MAAMrB,UACJD,OAAOS,MAAM;QAACf;QAAiBS,QAAQ;KAAM,GAAGO,iBAAiB,CAACM,QAChExB,WAAWG,aAAaqB,UAE1B;AAEJ,GAAG;AAEH,OAAO,MAAMO,oBAAoBlB,OAAO;IACtC;;;GAGC,GACDmB,SAASvB,UAAUK,SAASF,WAAW;AACzC,GAAG;AAEH,OAAO,MAAMqB,kBAAkBjB,KAAK;IAClCkB,SAASpB,SAAShB;AACpB,GAAG;AAEH,OAAO,MAAMqC,qBAAqB7B,OAChC2B,iBACApB,OAAO;IACLuB,IAAIrB;IAEJsB,UAAUpB,MAAM;QACdJ,OAAO;YACLyB,QAAQrC;QACV;QACAY,OAAO;YACL0B,OAAOtC;QACT;KACD;IAEDuC,eAAenC,MACbQ,OAAO;QACLuB,IAAIrB;QACJ0B,SAAS1B;QACTC,MAAMC,MAAM;YACVlB,UAAUF,iBAAiB6C,KAAK;YAChC3C,UAAUF,iBAAiB8C,MAAM;SAClC;IACH;AAEJ,IACA"}
@@ -1,3 +0,0 @@
1
- export { };
2
-
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/internals/types.ts"],"sourcesContent":["import type { NotificationType, EnumToUnion } from '@metamask/snaps-sdk';\nimport type { ApplicationState, Dispatch } from '@metamask/snaps-simulator';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface Window {\n // This API is injected into the page by the simulator. It allows us to\n // dispatch actions to the simulator, and read the state directly from the\n // Redux store.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n __SIMULATOR_API__: {\n dispatch: Dispatch;\n subscribe: (listener: () => void) => () => void;\n getState: () => ApplicationState;\n getRequestId: () => string;\n getNotifications: (requestId: string) => {\n id: string;\n message: string;\n type: EnumToUnion<NotificationType>;\n }[];\n };\n }\n}\n\nexport {};\n"],"names":[],"mappings":"AAAA,WAwBU"}
@@ -1,63 +0,0 @@
1
- import { assert, createModuleLogger } from '@metamask/utils';
2
- import { waitFor as waitForPuppeteer } from 'pptr-testing-library';
3
- import { rootLogger } from './logger';
4
- const log = createModuleLogger(rootLogger, 'wait-for');
5
- /**
6
- * Wait for a condition to be true. This is a wrapper around
7
- * `pptr-testing-library`'s `waitFor` function, with the addition of a custom
8
- * error message.
9
- *
10
- * @param fn - The condition to wait for.
11
- * @param options - The options.
12
- * @param options.timeout - The timeout in milliseconds.
13
- * @param options.message - The error message to throw if the condition is not
14
- * met.
15
- * @returns A promise that resolves when the condition is met. The promise
16
- * resolves to the return value of the condition function.
17
- */ export async function waitFor(fn, { timeout = 3000, message } = {}) {
18
- try {
19
- let result;
20
- await waitForPuppeteer(// eslint-disable-next-line @typescript-eslint/no-misused-promises
21
- async ()=>{
22
- // Puppeteer's `waitFor` function does not support returning a value
23
- // from the condition function, so we need to use a variable outside
24
- // the scope of the function.
25
- result = await fn();
26
- }, {
27
- timeout
28
- });
29
- assert(result !== undefined);
30
- return result;
31
- } catch (error) {
32
- if (message) {
33
- throw new Error(message);
34
- }
35
- throw error;
36
- }
37
- }
38
- /**
39
- * Wait for a JSON-RPC response.
40
- *
41
- * @param page - The page to wait for the response on.
42
- * @param type - The type of response to wait for.
43
- * @returns The JSON-RPC response.
44
- */ export async function waitForResponse(page, type) {
45
- log('Waiting for response of type %s.', type);
46
- return await page.evaluate(async (_type)=>{
47
- return new Promise((resolve)=>{
48
- window.__SIMULATOR_API__.dispatch({
49
- type: `${_type}/clearResponse`
50
- });
51
- const unsubscribe = window.__SIMULATOR_API__.subscribe(()=>{
52
- const state = window.__SIMULATOR_API__.getState();
53
- const { pending, response } = state[_type];
54
- if (!pending && response) {
55
- unsubscribe();
56
- resolve(response);
57
- }
58
- });
59
- });
60
- }, type);
61
- }
62
-
63
- //# sourceMappingURL=wait-for.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/internals/wait-for.ts"],"sourcesContent":["import type { HandlerType } from '@metamask/snaps-utils';\nimport { assert, createModuleLogger } from '@metamask/utils';\nimport { waitFor as waitForPuppeteer } from 'pptr-testing-library';\nimport type { Page } from 'puppeteer';\n\nimport type { SnapResponse } from '../types';\nimport { rootLogger } from './logger';\n\nexport type WaitForOptions = {\n /**\n * The timeout in milliseconds.\n */\n timeout?: number;\n\n /**\n * The error message to throw if the condition is not met.\n */\n message?: string;\n};\n\nconst log = createModuleLogger(rootLogger, 'wait-for');\n\n/**\n * Wait for a condition to be true. This is a wrapper around\n * `pptr-testing-library`'s `waitFor` function, with the addition of a custom\n * error message.\n *\n * @param fn - The condition to wait for.\n * @param options - The options.\n * @param options.timeout - The timeout in milliseconds.\n * @param options.message - The error message to throw if the condition is not\n * met.\n * @returns A promise that resolves when the condition is met. The promise\n * resolves to the return value of the condition function.\n */\nexport async function waitFor<Result>(\n fn: () => Promise<Result>,\n { timeout = 3000, message }: WaitForOptions = {},\n) {\n try {\n let result: Result | undefined;\n\n await waitForPuppeteer(\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async () => {\n // Puppeteer's `waitFor` function does not support returning a value\n // from the condition function, so we need to use a variable outside\n // the scope of the function.\n result = await fn();\n },\n {\n timeout,\n },\n );\n\n assert(result !== undefined);\n return result;\n } catch (error) {\n if (message) {\n throw new Error(message);\n }\n\n throw error;\n }\n}\n\n/**\n * Wait for a JSON-RPC response.\n *\n * @param page - The page to wait for the response on.\n * @param type - The type of response to wait for.\n * @returns The JSON-RPC response.\n */\nexport async function waitForResponse(\n page: Page,\n type:\n | HandlerType.OnTransaction\n | HandlerType.OnRpcRequest\n | HandlerType.OnCronjob,\n) {\n log('Waiting for response of type %s.', type);\n\n return await page.evaluate(async (_type) => {\n return new Promise<SnapResponse['response']>((resolve) => {\n window.__SIMULATOR_API__.dispatch({\n type: `${_type}/clearResponse`,\n });\n\n const unsubscribe = window.__SIMULATOR_API__.subscribe(() => {\n const state = window.__SIMULATOR_API__.getState();\n const { pending, response } = state[_type];\n\n if (!pending && response) {\n unsubscribe();\n\n resolve(response);\n }\n });\n });\n }, type);\n}\n"],"names":["assert","createModuleLogger","waitFor","waitForPuppeteer","rootLogger","log","fn","timeout","message","result","undefined","error","Error","waitForResponse","page","type","evaluate","_type","Promise","resolve","window","__SIMULATOR_API__","dispatch","unsubscribe","subscribe","state","getState","pending","response"],"mappings":"AACA,SAASA,MAAM,EAAEC,kBAAkB,QAAQ,kBAAkB;AAC7D,SAASC,WAAWC,gBAAgB,QAAQ,uBAAuB;AAInE,SAASC,UAAU,QAAQ,WAAW;AActC,MAAMC,MAAMJ,mBAAmBG,YAAY;AAE3C;;;;;;;;;;;;CAYC,GACD,OAAO,eAAeF,QACpBI,EAAyB,EACzB,EAAEC,UAAU,IAAI,EAAEC,OAAO,EAAkB,GAAG,CAAC,CAAC;IAEhD,IAAI;QACF,IAAIC;QAEJ,MAAMN,iBACJ,kEAAkE;QAClE;YACE,oEAAoE;YACpE,oEAAoE;YACpE,6BAA6B;YAC7BM,SAAS,MAAMH;QACjB,GACA;YACEC;QACF;QAGFP,OAAOS,WAAWC;QAClB,OAAOD;IACT,EAAE,OAAOE,OAAO;QACd,IAAIH,SAAS;YACX,MAAM,IAAII,MAAMJ;QAClB;QAEA,MAAMG;IACR;AACF;AAEA;;;;;;CAMC,GACD,OAAO,eAAeE,gBACpBC,IAAU,EACVC,IAGyB;IAEzBV,IAAI,oCAAoCU;IAExC,OAAO,MAAMD,KAAKE,QAAQ,CAAC,OAAOC;QAChC,OAAO,IAAIC,QAAkC,CAACC;YAC5CC,OAAOC,iBAAiB,CAACC,QAAQ,CAAC;gBAChCP,MAAM,CAAC,EAAEE,MAAM,cAAc,CAAC;YAChC;YAEA,MAAMM,cAAcH,OAAOC,iBAAiB,CAACG,SAAS,CAAC;gBACrD,MAAMC,QAAQL,OAAOC,iBAAiB,CAACK,QAAQ;gBAC/C,MAAM,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GAAGH,KAAK,CAACR,MAAM;gBAE1C,IAAI,CAACU,WAAWC,UAAU;oBACxBL;oBAEAJ,QAAQS;gBACV;YACF;QACF;IACF,GAAGb;AACL"}
@@ -1,108 +0,0 @@
1
- /* eslint-disable no-invalid-this */ // Note: Because this file imports from `@jest/globals`, it can only be used in
2
- // a Jest environment. This is why it's not exported from the index file.
3
- import { expect } from '@jest/globals';
4
- import { hasProperty } from '@metamask/utils';
5
- import { diff, matcherErrorMessage, matcherHint, printReceived, printWithType, RECEIVED_COLOR } from 'jest-matcher-utils';
6
- import { is } from 'superstruct';
7
- import { InterfaceStruct, SnapResponseStruct } from './internals';
8
- /**
9
- * Ensure that the actual value is a response from the `request` function.
10
- *
11
- * @param actual - The actual value.
12
- * @param matcherName - The name of the matcher.
13
- * @param options - The matcher options.
14
- */ function assertActualIsSnapResponse(actual, matcherName, options) {
15
- if (!is(actual, SnapResponseStruct)) {
16
- throw new Error(matcherErrorMessage(matcherHint(matcherName, undefined, undefined, options), `${RECEIVED_COLOR('received')} value must be a response from the \`request\` function`, printWithType('Received', actual, printReceived)));
17
- }
18
- }
19
- /**
20
- * Ensure that the actual value is a response from the `request` function, and
21
- * that it has a `ui` property.
22
- *
23
- * @param actual - The actual value.
24
- * @param matcherName - The name of the matcher.
25
- * @param options - The matcher options.
26
- */ function assertHasInterface(actual, matcherName, options) {
27
- if (!is(actual, InterfaceStruct) || !actual.content) {
28
- throw new Error(matcherErrorMessage(matcherHint(matcherName, undefined, undefined, options), `${RECEIVED_COLOR('received')} value must have a \`content\` property`, printWithType('Received', actual, printReceived)));
29
- }
30
- }
31
- /**
32
- * Check if a JSON-RPC response matches the expected value. This matcher is
33
- * intended to be used with the `expect` global.
34
- *
35
- * @param actual - The actual response.
36
- * @param expected - The expected response.
37
- * @returns The status and message.
38
- */ export const toRespondWith = function(actual, expected) {
39
- assertActualIsSnapResponse(actual, 'toRespondWith');
40
- const { response } = actual;
41
- if (hasProperty(response, 'error')) {
42
- const message = ()=>`${this.utils.matcherHint('.toRespondWith')}\n\n` + `Expected response: ${this.utils.printExpected(expected)}\n` + `Received error: ${this.utils.printReceived(response.error)}`;
43
- return {
44
- message,
45
- pass: false
46
- };
47
- }
48
- const pass = this.equals(response.result, expected);
49
- const message = pass ? ()=>`${this.utils.matcherHint('.not.toRespondWith')}\n\n` + `Expected: ${this.utils.printExpected(expected)}\n` + `Received: ${this.utils.printReceived(response.result)}` : ()=>`${this.utils.matcherHint('.toRespondWith')}\n\n` + `Expected: ${this.utils.printExpected(expected)}\n` + `Received: ${this.utils.printReceived(response.result)}`;
50
- return {
51
- message,
52
- pass
53
- };
54
- };
55
- export const toRespondWithError = function(actual, expected) {
56
- assertActualIsSnapResponse(actual, 'toRespondWithError');
57
- const { response } = actual;
58
- if (hasProperty(response, 'result')) {
59
- const message = ()=>`${this.utils.matcherHint('.toRespondWithError')}\n\n` + `Expected error: ${this.utils.printExpected(expected)}\n` + `Received result: ${this.utils.printReceived(response.result)}`;
60
- return {
61
- message,
62
- pass: false
63
- };
64
- }
65
- const pass = this.equals(response.error, expected);
66
- const message = pass ? ()=>`${this.utils.matcherHint('.not.toRespondWithError')}\n\n` + `Expected: ${this.utils.printExpected(expected)}\n` + `Received: ${this.utils.printReceived(response.error)}` : ()=>`${this.utils.matcherHint('.toRespondWithError')}\n\n` + `Expected: ${this.utils.printExpected(expected)}\n` + `Received: ${this.utils.printReceived(response.error)}`;
67
- return {
68
- message,
69
- pass
70
- };
71
- };
72
- /**
73
- * Check if the snap sent a notification with the expected message. This matcher
74
- * is intended to be used with the `expect` global.
75
- *
76
- * @param actual - The actual response.
77
- * @param expected - The expected notification message.
78
- * @param type - The expected notification type.
79
- * @returns The status and message.
80
- */ export const toSendNotification = async function(actual, expected, type) {
81
- assertActualIsSnapResponse(actual, 'toSendNotification');
82
- const { notifications } = actual;
83
- const pass = notifications.some((notification)=>this.equals(notification.message, expected) && (type === undefined || notification.type === type));
84
- const message = pass ? ()=>`${this.utils.matcherHint('.not.toSendNotification')}\n\n` + `Expected: ${this.utils.printExpected(expected)}\n` + `Expected type: ${this.utils.printExpected(type)}\n` + `Received: ${this.utils.printReceived(notifications)}` : ()=>`${this.utils.matcherHint('.toSendNotification')}\n\n` + `Expected: ${this.utils.printExpected(expected)}\n` + `Expected type: ${this.utils.printExpected(type)}\n` + `Received: ${this.utils.printReceived(notifications)}`;
85
- return {
86
- message,
87
- pass
88
- };
89
- };
90
- export const toRender = function(actual, expected) {
91
- assertHasInterface(actual, 'toRender');
92
- const { content } = actual;
93
- const pass = this.equals(content, expected);
94
- const difference = diff(expected, content);
95
- const message = pass ? ()=>`${this.utils.matcherHint('.not.toShowInterface')}\n\n` + `Expected: ${this.utils.printExpected(expected)}\n` + `Received: ${this.utils.printReceived(content)}` + `${difference ? `\n\nDifference:\n\n${difference}` : ''}` : ()=>`${this.utils.matcherHint('.toShowInterface')}\n\n` + `Expected: ${this.utils.printExpected(expected)}\n` + `Received: ${this.utils.printReceived(content)}` + `${difference ? `\n\nDifference:\n\n${difference}` : ''}`;
96
- return {
97
- message,
98
- pass
99
- };
100
- };
101
- expect.extend({
102
- toRespondWith,
103
- toRespondWithError,
104
- toSendNotification,
105
- toRender
106
- });
107
-
108
- //# sourceMappingURL=matchers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/matchers.ts"],"sourcesContent":["/* eslint-disable no-invalid-this */\n\n// Note: Because this file imports from `@jest/globals`, it can only be used in\n// a Jest environment. This is why it's not exported from the index file.\n\nimport type { MatcherFunction } from '@jest/expect';\nimport { expect } from '@jest/globals';\nimport type {\n NotificationType,\n EnumToUnion,\n Component,\n} from '@metamask/snaps-sdk';\nimport type { Json } from '@metamask/utils';\nimport { hasProperty } from '@metamask/utils';\nimport type { MatcherHintOptions } from 'jest-matcher-utils';\nimport {\n diff,\n matcherErrorMessage,\n matcherHint,\n printReceived,\n printWithType,\n RECEIVED_COLOR,\n} from 'jest-matcher-utils';\nimport { is } from 'superstruct';\n\nimport { InterfaceStruct, SnapResponseStruct } from './internals';\nimport type { SnapResponse } from './types';\n\n/**\n * Ensure that the actual value is a response from the `request` function.\n *\n * @param actual - The actual value.\n * @param matcherName - The name of the matcher.\n * @param options - The matcher options.\n */\nfunction assertActualIsSnapResponse(\n actual: unknown,\n matcherName: string,\n options?: MatcherHintOptions,\n): asserts actual is SnapResponse {\n if (!is(actual, SnapResponseStruct)) {\n throw new Error(\n matcherErrorMessage(\n matcherHint(matcherName, undefined, undefined, options),\n `${RECEIVED_COLOR(\n 'received',\n )} value must be a response from the \\`request\\` function`,\n printWithType('Received', actual, printReceived),\n ),\n );\n }\n}\n\n/**\n * Ensure that the actual value is a response from the `request` function, and\n * that it has a `ui` property.\n *\n * @param actual - The actual value.\n * @param matcherName - The name of the matcher.\n * @param options - The matcher options.\n */\nfunction assertHasInterface(\n actual: unknown,\n matcherName: string,\n options?: MatcherHintOptions,\n): asserts actual is { content: Component } {\n if (!is(actual, InterfaceStruct) || !actual.content) {\n throw new Error(\n matcherErrorMessage(\n matcherHint(matcherName, undefined, undefined, options),\n `${RECEIVED_COLOR('received')} value must have a \\`content\\` property`,\n printWithType('Received', actual, printReceived),\n ),\n );\n }\n}\n\n/**\n * Check if a JSON-RPC response matches the expected value. This matcher is\n * intended to be used with the `expect` global.\n *\n * @param actual - The actual response.\n * @param expected - The expected response.\n * @returns The status and message.\n */\nexport const toRespondWith: MatcherFunction<[expected: Json]> = function (\n actual,\n expected,\n) {\n assertActualIsSnapResponse(actual, 'toRespondWith');\n\n const { response } = actual;\n if (hasProperty(response, 'error')) {\n const message = () =>\n `${this.utils.matcherHint('.toRespondWith')}\\n\\n` +\n `Expected response: ${this.utils.printExpected(expected)}\\n` +\n `Received error: ${this.utils.printReceived(response.error)}`;\n\n return { message, pass: false };\n }\n\n const pass = this.equals(response.result, expected);\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRespondWith')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.result)}`\n : () =>\n `${this.utils.matcherHint('.toRespondWith')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.result)}`;\n\n return { message, pass };\n};\n\nexport const toRespondWithError: MatcherFunction<[expected: Json]> = function (\n actual,\n expected,\n) {\n assertActualIsSnapResponse(actual, 'toRespondWithError');\n\n const { response } = actual;\n if (hasProperty(response, 'result')) {\n const message = () =>\n `${this.utils.matcherHint('.toRespondWithError')}\\n\\n` +\n `Expected error: ${this.utils.printExpected(expected)}\\n` +\n `Received result: ${this.utils.printReceived(response.result)}`;\n\n return { message, pass: false };\n }\n\n const pass = this.equals(response.error, expected);\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRespondWithError')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.error)}`\n : () =>\n `${this.utils.matcherHint('.toRespondWithError')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.error)}`;\n\n return { message, pass };\n};\n\n/**\n * Check if the snap sent a notification with the expected message. This matcher\n * is intended to be used with the `expect` global.\n *\n * @param actual - The actual response.\n * @param expected - The expected notification message.\n * @param type - The expected notification type.\n * @returns The status and message.\n */\nexport const toSendNotification: MatcherFunction<\n [expected: string, type?: EnumToUnion<NotificationType> | undefined]\n> = async function (actual, expected, type) {\n assertActualIsSnapResponse(actual, 'toSendNotification');\n\n const { notifications } = actual;\n const pass = notifications.some(\n (notification) =>\n this.equals(notification.message, expected) &&\n (type === undefined || notification.type === type),\n );\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toSendNotification')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Expected type: ${this.utils.printExpected(type)}\\n` +\n `Received: ${this.utils.printReceived(notifications)}`\n : () =>\n `${this.utils.matcherHint('.toSendNotification')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Expected type: ${this.utils.printExpected(type)}\\n` +\n `Received: ${this.utils.printReceived(notifications)}`;\n\n return { message, pass };\n};\n\nexport const toRender: MatcherFunction<[expected: Component]> = function (\n actual,\n expected,\n) {\n assertHasInterface(actual, 'toRender');\n\n const { content } = actual;\n const pass = this.equals(content, expected);\n\n const difference = diff(expected, content);\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toShowInterface')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(content)}` +\n `${difference ? `\\n\\nDifference:\\n\\n${difference}` : ''}`\n : () =>\n `${this.utils.matcherHint('.toShowInterface')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(content)}` +\n `${difference ? `\\n\\nDifference:\\n\\n${difference}` : ''}`;\n\n return { message, pass };\n};\n\nexpect.extend({\n toRespondWith,\n toRespondWithError,\n toSendNotification,\n toRender,\n});\n"],"names":["expect","hasProperty","diff","matcherErrorMessage","matcherHint","printReceived","printWithType","RECEIVED_COLOR","is","InterfaceStruct","SnapResponseStruct","assertActualIsSnapResponse","actual","matcherName","options","Error","undefined","assertHasInterface","content","toRespondWith","expected","response","message","utils","printExpected","error","pass","equals","result","toRespondWithError","toSendNotification","type","notifications","some","notification","toRender","difference","extend"],"mappings":"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"}
@@ -1,26 +0,0 @@
1
- import { boolean, create, defaulted, number, object, optional, string, type } from 'superstruct';
2
- const SnapsEnvironmentOptionsStruct = type({
3
- executionEnvironmentUrl: optional(string()),
4
- simulatorUrl: optional(string()),
5
- keepAlive: defaulted(boolean(), false),
6
- server: defaulted(object({
7
- enabled: defaulted(boolean(), true),
8
- port: defaulted(number(), 0),
9
- root: defaulted(string(), process.cwd())
10
- }), {}),
11
- browser: defaulted(object({
12
- headless: defaulted(boolean(), true)
13
- }), {})
14
- });
15
- /**
16
- * Get the environment options. This validates the options, and returns the
17
- * default options if none are provided.
18
- *
19
- * @param testEnvironmentOptions - The test environment options as defined in
20
- * the Jest configuration.
21
- * @returns The environment options.
22
- */ export function getOptions(testEnvironmentOptions) {
23
- return create(testEnvironmentOptions, SnapsEnvironmentOptionsStruct);
24
- }
25
-
26
- //# sourceMappingURL=options.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/options.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport {\n boolean,\n create,\n defaulted,\n number,\n object,\n optional,\n string,\n type,\n} from 'superstruct';\n\nconst SnapsEnvironmentOptionsStruct = type({\n executionEnvironmentUrl: optional(string()),\n simulatorUrl: optional(string()),\n keepAlive: defaulted(boolean(), false),\n\n server: defaulted(\n object({\n enabled: defaulted(boolean(), true),\n port: defaulted(number(), 0),\n root: defaulted(string(), process.cwd()),\n }),\n {},\n ),\n\n browser: defaulted(\n object({\n headless: defaulted(boolean(), true),\n }),\n {},\n ),\n});\n\n/**\n * The options for the environment. These can be specified in the Jest\n * configuration under `testEnvironmentOptions`.\n *\n * @example\n * ```json\n * {\n * \"testEnvironment\": \"@metamask/snaps-jest\",\n * \"testEnvironmentOptions\": {\n * \"executionEnvironmentUrl\": \"http://localhost:8080\",\n * \"server\": {\n * \"port\": 8080,\n * /* ... *\\/\n * }\n * }\n * }\n * ```\n * @property executionEnvironmentUrl - The URL of the execution environment. If\n * this is not provided, the execution environment will be served from the\n * built-in HTTP server.\n * @property simulatorUrl - The URL of the simulator. If this is not provided,\n * the simulator will be served from the built-in HTTP server.\n * @property keepAlive - Whether to keep the browser open after the tests have\n * finished. This is useful for debugging. Defaults to `false`.\n * @property server - The options for the built-in HTTP server.\n * @property server.enabled - Whether to run the built-in HTTP server. Defaults\n * to `true`.\n * @property server.port - The port to use for the built-in HTTP server. If this\n * is not provided, a random available port will be used.\n * @property server.root - The root directory to serve from the built-in HTTP\n * server. Defaults to the current working directory. This is assumed to be the\n * directory containing the snap manifest and `dist` files. If this is a\n * relative path, it will be resolved relative to the current working directory.\n * @property browser - The options for the browser.\n * @property browser.headless - Whether to run the browser in headless mode.\n * Defaults to `true`.\n */\nexport type SnapsEnvironmentOptions = Infer<\n typeof SnapsEnvironmentOptionsStruct\n>;\n\n/**\n * Get the environment options. This validates the options, and returns the\n * default options if none are provided.\n *\n * @param testEnvironmentOptions - The test environment options as defined in\n * the Jest configuration.\n * @returns The environment options.\n */\nexport function getOptions(testEnvironmentOptions: Record<string, unknown>) {\n return create(testEnvironmentOptions, SnapsEnvironmentOptionsStruct);\n}\n"],"names":["boolean","create","defaulted","number","object","optional","string","type","SnapsEnvironmentOptionsStruct","executionEnvironmentUrl","simulatorUrl","keepAlive","server","enabled","port","root","process","cwd","browser","headless","getOptions","testEnvironmentOptions"],"mappings":"AACA,SACEA,OAAO,EACPC,MAAM,EACNC,SAAS,EACTC,MAAM,EACNC,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,IAAI,QACC,cAAc;AAErB,MAAMC,gCAAgCD,KAAK;IACzCE,yBAAyBJ,SAASC;IAClCI,cAAcL,SAASC;IACvBK,WAAWT,UAAUF,WAAW;IAEhCY,QAAQV,UACNE,OAAO;QACLS,SAASX,UAAUF,WAAW;QAC9Bc,MAAMZ,UAAUC,UAAU;QAC1BY,MAAMb,UAAUI,UAAUU,QAAQC,GAAG;IACvC,IACA,CAAC;IAGHC,SAAShB,UACPE,OAAO;QACLe,UAAUjB,UAAUF,WAAW;IACjC,IACA,CAAC;AAEL;AA2CA;;;;;;;CAOC,GACD,OAAO,SAASoB,WAAWC,sBAA+C;IACxE,OAAOpB,OAAOoB,wBAAwBb;AACxC"}
package/dist/esm/setup.js DELETED
@@ -1,6 +0,0 @@
1
- // Setup file for Jest. This file is used in the Jest preset configuration, and
2
- // not intended to be exported or used directly.
3
- // eslint-disable-next-line import/no-unassigned-import
4
- import './matchers';
5
-
6
- //# sourceMappingURL=setup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/setup.ts"],"sourcesContent":["// Setup file for Jest. This file is used in the Jest preset configuration, and\n// not intended to be exported or used directly.\n\n// eslint-disable-next-line import/no-unassigned-import\nimport './matchers';\n"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,gDAAgD;AAEhD,uDAAuD;AACvD,OAAO,aAAa"}
package/dist/esm/types.js DELETED
@@ -1,3 +0,0 @@
1
- export { };
2
-
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/types.ts"],"sourcesContent":["import type {\n NotificationType,\n EnumToUnion,\n Component,\n} from '@metamask/snaps-sdk';\nimport type { JsonRpcId, JsonRpcParams } from '@metamask/utils';\nimport type { Infer } from 'superstruct';\n\nimport type {\n Mock,\n MockJsonRpcOptions,\n MockOptions,\n SnapOptionsStruct,\n SnapResponseStruct,\n TransactionOptionsStruct,\n} from './internals';\n\n/* eslint-disable @typescript-eslint/consistent-type-definitions */\ndeclare module 'expect' {\n interface AsymmetricMatchers {\n toRespondWith(response: unknown): void;\n toRespondWithError(error: unknown): void;\n toSendNotification(\n message: string,\n type?: EnumToUnion<NotificationType>,\n ): void;\n toRender(component: Component): void;\n }\n\n // Ideally we would use `Matchers<Result>` instead of `Matchers<R>`, but\n // TypeScript doesn't allow this:\n // TS2428: All declarations of 'Matchers' must have identical type parameters.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n interface Matchers<R> {\n toRespondWith(response: unknown): R;\n toRespondWithError(error: unknown): R;\n toSendNotification(\n message: string,\n type?: EnumToUnion<NotificationType>,\n ): R;\n toRender(component: Component): R;\n }\n}\n/* eslint-enable @typescript-eslint/consistent-type-definitions */\n\n/**\n * Deeply partialize a type.\n *\n * @template Type - The type to partialize.\n * @returns The deeply partialized type.\n * @example\n * ```ts\n * type Foo = {\n * bar: {\n * baz: string;\n * };\n * qux: number;\n * };\n *\n * type PartialFoo = DeepPartial<Foo>;\n * // { bar?: { baz?: string; }; qux?: number; }\n * ```\n */\nexport type DeepPartial<Type> = {\n [Key in keyof Type]?: Type[Key] extends Record<string, unknown>\n ? DeepPartial<Type[Key]>\n : Type[Key];\n};\n\nexport type RequestOptions = {\n /**\n * The JSON-RPC request ID.\n */\n id?: JsonRpcId;\n\n /**\n * The JSON-RPC method.\n */\n method: string;\n\n /**\n * The JSON-RPC params.\n */\n params?: JsonRpcParams;\n\n /**\n * The origin to send the request from.\n */\n origin?: string;\n};\n\n/**\n * The `runCronjob` options. This is the same as {@link RequestOptions}, except\n * that it does not have an `origin` property.\n */\nexport type CronjobOptions = Omit<RequestOptions, 'origin'>;\n\n/**\n * The options to use for transaction requests.\n *\n * @property chainId - The CAIP-2 chain ID to send the transaction on. Defaults\n * to `eip155:1`.\n * @property origin - The origin to send the transaction from. Defaults to\n * `metamask.io`.\n * @property from - The address to send the transaction from. Defaults to a\n * randomly generated address.\n * @property to - The address to send the transaction to. Defaults to a randomly\n * generated address.\n * @property value - The value to send with the transaction. Defaults to `0`.\n * @property data - The data to send with the transaction. Defaults to `0x`.\n * @property gasLimit - The gas limit to use for the transaction. Defaults to\n * `21_000`.\n * @property maxFeePerGas - The maximum fee per gas to use for the transaction.\n * Defaults to `1`.\n * @property maxPriorityFeePerGas - The maximum priority fee per gas to use for\n * the transaction. Defaults to `1`.\n * @property nonce - The nonce to use for the transaction. Defaults to `0`.\n */\nexport type TransactionOptions = Infer<typeof TransactionOptionsStruct>;\n\n/**\n * The options to use for requests to the snap.\n *\n * @property timeout - The timeout in milliseconds to use. Defaults to `1000`.\n */\nexport type SnapOptions = Infer<typeof SnapOptionsStruct>;\n\n/**\n * A `snap_dialog` alert interface.\n */\nexport type SnapAlertInterface = {\n /**\n * The type of the interface. This is always `alert`.\n */\n type: 'alert';\n\n /**\n * The content to show in the alert.\n */\n content: Component;\n\n /**\n * Close the alert.\n */\n ok(): Promise<void>;\n};\n\n/**\n * A `snap_dialog` confirmation interface.\n */\nexport type SnapConfirmationInterface = {\n /**\n * The type of the interface. This is always `confirmation`.\n */\n type: 'confirmation';\n\n /**\n * The content to show in the confirmation.\n */\n content: Component;\n\n /**\n * Close the confirmation.\n */\n ok(): Promise<void>;\n\n /**\n * Cancel the confirmation.\n */\n cancel(): Promise<void>;\n};\n\n/**\n * A `snap_dialog` prompt interface.\n */\nexport type SnapPromptInterface = {\n /**\n * The type of the interface. This is always `prompt`.\n */\n type: 'prompt';\n\n /**\n * The content to show in the prompt.\n */\n content: Component;\n\n /**\n * Close the prompt.\n *\n * @param value - The value to close the prompt with.\n */\n ok(value?: string): Promise<void>;\n\n /**\n * Cancel the prompt.\n */\n cancel(): Promise<void>;\n};\n\nexport type SnapInterface =\n | SnapAlertInterface\n | SnapConfirmationInterface\n | SnapPromptInterface;\n\nexport type SnapRequestObject = {\n /**\n * Get a user interface object from a snap. This will throw an error if the\n * snap does not show a user interface within the timeout.\n *\n * @param options - The options to use.\n * @param options.timeout - The timeout in milliseconds to use. Defaults to\n * `1000`.\n * @returns The user interface object.\n */\n getInterface(options?: SnapOptions): Promise<SnapInterface>;\n};\n\n/**\n * A pending request object. This is a promise with extra\n * {@link SnapRequestObject} fields.\n */\nexport type SnapRequest = Promise<SnapResponse> & SnapRequestObject;\n\n/**\n * This is the main entry point to interact with the snap. It is returned by\n * {@link installSnap}, and has methods to send requests to the snap.\n *\n * @example\n * ```ts\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * const snap = await installSnap();\n * const response = await snap.request({ method: 'hello' });\n *\n * expect(response).toRespondWith('Hello, world!');\n * ```\n */\nexport type Snap = {\n /**\n * Send a JSON-RPC request to the snap.\n *\n * @param request - The request. This is similar to a JSON-RPC request, but\n * has an extra `origin` field.\n * @returns The response promise, with extra {@link SnapRequestObject} fields.\n */\n request(request: RequestOptions): SnapRequest;\n\n /**\n * Send a transaction to the snap.\n *\n * @param transaction - The transaction. This is similar to an Ethereum\n * transaction object, but has an extra `origin` field. Any missing fields\n * will be filled in with default values.\n * @returns The response.\n */\n sendTransaction(\n transaction?: Partial<TransactionOptions>,\n ): Promise<SnapResponse>;\n\n /**\n * Run a cronjob in the snap. This is similar to {@link request}, but the\n * request will be sent to the `onCronjob` method of the snap.\n *\n * @param cronjob - The cronjob request. This is similar to a JSON-RPC\n * request, and is normally specified in the snap manifest, under the\n * `endowment:cronjob` permission.\n * @returns The response promise, with extra {@link SnapRequestObject} fields.\n */\n runCronjob(cronjob: CronjobOptions): SnapRequest;\n\n /**\n * Close the page running the snap. This is mainly useful for cleaning up\n * the test environment, and calling it is not strictly necessary.\n *\n * @returns A promise that resolves when the page is closed.\n */\n // TODO: Find a way to do this automatically.\n close(): Promise<void>;\n\n /**\n * Enable network mocking for the snap.\n *\n * @param options - The options for the network mocking.\n * @returns A {@link Mock} object, with an `unmock` function.\n */\n mock(options: DeepPartial<MockOptions>): Promise<Mock>;\n\n /**\n * Enable JSON-RPC provider mocking for the snap. This will mock any requests\n * sent through the `ethereum` global, with the specified `method`.\n *\n * @param options - The options for the JSON-RPC mocking.\n * @param options.method - The JSON-RPC method to mock, e.g.,\n * `eth_blockNumber`.\n * @param options.result - The JSON value to return.\n * @returns A {@link Mock} object, with an `unmock` function.\n */\n mockJsonRpc(options: MockJsonRpcOptions): Promise<Mock>;\n};\n\nexport type SnapResponse = Infer<typeof SnapResponseStruct>;\n"],"names":[],"mappings":"AAAA,WA4S4D"}
@@ -1,25 +0,0 @@
1
- import type { Page } from 'puppeteer';
2
- import type { SnapInterface, SnapOptions } from '../types';
3
- /**
4
- * Get the current snap user interface (i.e., dialog). This will throw an error
5
- * if the snap does not show a user interface within the timeout.
6
- *
7
- * @param page - The page to get the interface from.
8
- * @param options - The options to use.
9
- * @param options.timeout - The timeout in milliseconds to use. Defaults to
10
- * `1000`.
11
- * @returns The user interface object.
12
- */
13
- export declare function getInterface(page: Page, options?: SnapOptions): Promise<SnapInterface>;
14
- /**
15
- * Get the text of the notifications.
16
- *
17
- * @param page - The page to get the notifications from.
18
- * @param requestId - The ID of the request to get the notifications for.
19
- * @returns The text of the notifications, in order of appearance.
20
- */
21
- export declare function getNotifications(page: Page, requestId: string): Promise<{
22
- id: string;
23
- message: string;
24
- type: "native" | "inApp";
25
- }[]>;
@@ -1,87 +0,0 @@
1
- import type { Page, HTTPRequest } from 'puppeteer';
2
- import type { Infer, Struct } from 'superstruct';
3
- import type { DeepPartial } from '../types';
4
- export declare type Unmock = () => Promise<void>;
5
- export declare type Mock = {
6
- /**
7
- * A function that can be used to unmock the URL.
8
- */
9
- unmock: Unmock;
10
- };
11
- /**
12
- * A function that can return `true` if the given request should be mocked, or
13
- * false if not.
14
- *
15
- * @param request - The request to check.
16
- * @returns Whether to mock the request.
17
- */
18
- export declare type ConditionFunction = (request: HTTPRequest) => boolean;
19
- export declare const MockOptionsStruct: Struct<{
20
- response: {
21
- headers: Record<string, unknown>;
22
- status: number;
23
- body: string;
24
- contentType: string;
25
- };
26
- url: string | RegExp;
27
- partial?: boolean | undefined;
28
- } | {
29
- response: {
30
- headers: Record<string, unknown>;
31
- status: number;
32
- body: string;
33
- contentType: string;
34
- };
35
- condition: ConditionFunction;
36
- }, null>;
37
- /**
38
- * The options for the network mocking.
39
- *
40
- * @property url - The URL to mock. If a string is provided, the URL will be
41
- * matched exactly. If a RegExp is provided, the URL will be matched against it.
42
- * This option is incompatible with the `condition` option.
43
- * @property partial - If enabled, the request will be mocked if the URL starts
44
- * with the given URL. This option is ignored if a RegExp is provided to the
45
- * `url` option. This option is incompatible with the `condition` option.
46
- * @property condition - A function which gets the {@link HTTPRequest} as
47
- * parameter and returns a boolean to indicate whether the response should be
48
- * mocked or not. This option is incompatible with the `url` and `partial`
49
- * options.
50
- * @property response - The response to send for the request.
51
- * @property response.status - The status code to send for the response.
52
- * Defaults to `200`.
53
- * @property response.headers - The headers to send for the response. Defaults
54
- * to headers that enable CORS.
55
- * @property response.contentType - The content type to send for the response.
56
- * Defaults to `text/plain`.
57
- */
58
- export declare type MockOptions = Infer<typeof MockOptionsStruct>;
59
- /**
60
- * Enable network mocking for the given page, and all its sub-frames.
61
- *
62
- * @param page - The page to enable network mocking on.
63
- * @param options - The options for the network mocking.
64
- * @returns A {@link Mock} object, with an `unmock` function.
65
- */
66
- export declare function mock(page: Page, options: DeepPartial<MockOptions>): Promise<Mock>;
67
- declare const MockJsonRpcOptionsStruct: Struct<{
68
- result: import("@metamask/utils").Json;
69
- method: string;
70
- }, {
71
- method: Struct<string, null>;
72
- result: Struct<import("@metamask/utils").Json, unknown>;
73
- }>;
74
- export declare type MockJsonRpcOptions = Infer<typeof MockJsonRpcOptionsStruct>;
75
- /**
76
- * Mock an Ethereum JSON-RPC request. This intercepts all requests to the
77
- * Ethereum provider, and returns the `result` instead.
78
- *
79
- * @param page - The page to enable network JSON-RPC mocking on.
80
- * @param options - The options for the JSON-RPC mock.
81
- * @param options.method - The JSON-RPC method to mock. Any other methods will be
82
- * forwarded to the provider.
83
- * @param options.result - The JSON response to return.
84
- * @returns A {@link Mock} object, with an `unmock` function.
85
- */
86
- export declare function mockJsonRpc(page: Page, { method, result }: MockJsonRpcOptions): Promise<Mock>;
87
- export {};
@@ -1,18 +0,0 @@
1
- import type { NotificationType, EnumToUnion } from '@metamask/snaps-sdk';
2
- import type { ApplicationState, Dispatch } from '@metamask/snaps-simulator';
3
- declare global {
4
- interface Window {
5
- __SIMULATOR_API__: {
6
- dispatch: Dispatch;
7
- subscribe: (listener: () => void) => () => void;
8
- getState: () => ApplicationState;
9
- getRequestId: () => string;
10
- getNotifications: (requestId: string) => {
11
- id: string;
12
- message: string;
13
- type: EnumToUnion<NotificationType>;
14
- }[];
15
- };
16
- }
17
- }
18
- export {};
@@ -1,38 +0,0 @@
1
- import type { HandlerType } from '@metamask/snaps-utils';
2
- import type { Page } from 'puppeteer';
3
- export declare type WaitForOptions = {
4
- /**
5
- * The timeout in milliseconds.
6
- */
7
- timeout?: number;
8
- /**
9
- * The error message to throw if the condition is not met.
10
- */
11
- message?: string;
12
- };
13
- /**
14
- * Wait for a condition to be true. This is a wrapper around
15
- * `pptr-testing-library`'s `waitFor` function, with the addition of a custom
16
- * error message.
17
- *
18
- * @param fn - The condition to wait for.
19
- * @param options - The options.
20
- * @param options.timeout - The timeout in milliseconds.
21
- * @param options.message - The error message to throw if the condition is not
22
- * met.
23
- * @returns A promise that resolves when the condition is met. The promise
24
- * resolves to the return value of the condition function.
25
- */
26
- export declare function waitFor<Result>(fn: () => Promise<Result>, { timeout, message }?: WaitForOptions): Promise<Result & ({} | null)>;
27
- /**
28
- * Wait for a JSON-RPC response.
29
- *
30
- * @param page - The page to wait for the response on.
31
- * @param type - The type of response to wait for.
32
- * @returns The JSON-RPC response.
33
- */
34
- export declare function waitForResponse(page: Page, type: HandlerType.OnTransaction | HandlerType.OnRpcRequest | HandlerType.OnCronjob): Promise<{
35
- result: import("@metamask/utils").Json;
36
- } | {
37
- error: import("@metamask/utils").Json;
38
- }>;