@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
@@ -0,0 +1,233 @@
1
+ // src/internals/structs.ts
2
+ import {
3
+ NotificationType,
4
+ ComponentStruct,
5
+ enumValue
6
+ } from "@metamask/snaps-sdk";
7
+ import {
8
+ bytesToHex,
9
+ JsonStruct,
10
+ StrictHexStruct,
11
+ valueToBytes
12
+ } from "@metamask/utils";
13
+ import { randomBytes } from "crypto";
14
+ import {
15
+ array,
16
+ assign,
17
+ bigint,
18
+ coerce,
19
+ defaulted,
20
+ instance,
21
+ literal,
22
+ number,
23
+ object,
24
+ optional,
25
+ string,
26
+ type,
27
+ union,
28
+ record,
29
+ any
30
+ } from "superstruct";
31
+ var BytesLikeStruct = union([
32
+ bigint(),
33
+ number(),
34
+ string(),
35
+ instance(Uint8Array)
36
+ ]);
37
+ var TransactionOptionsStruct = object({
38
+ /**
39
+ * The CAIP-2 chain ID to send the transaction on. Defaults to `eip155:1`.
40
+ */
41
+ chainId: defaulted(string(), "eip155:1"),
42
+ /**
43
+ * The origin to send the transaction from. Defaults to `metamask.io`.
44
+ */
45
+ origin: defaulted(string(), "metamask.io"),
46
+ /**
47
+ * The address to send the transaction from. Defaults to a randomly generated
48
+ * address.
49
+ */
50
+ // TODO: Move this coercer to `@metamask/utils`.
51
+ from: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {
52
+ if (value) {
53
+ return bytesToHex(valueToBytes(value));
54
+ }
55
+ return bytesToHex(randomBytes(20));
56
+ }),
57
+ /**
58
+ * The address to send the transaction to. Defaults to a randomly generated
59
+ * address.
60
+ */
61
+ // TODO: Move this coercer to `@metamask/utils`.
62
+ to: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {
63
+ if (value) {
64
+ return bytesToHex(valueToBytes(value));
65
+ }
66
+ return bytesToHex(randomBytes(20));
67
+ }),
68
+ /**
69
+ * The value to send with the transaction. The value may be specified as a
70
+ * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.
71
+ */
72
+ value: defaulted(
73
+ coerce(
74
+ StrictHexStruct,
75
+ BytesLikeStruct,
76
+ (value) => bytesToHex(valueToBytes(value))
77
+ ),
78
+ "0x0"
79
+ ),
80
+ /**
81
+ * The gas limit to use for the transaction. The gas limit may be specified
82
+ * as a `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `21_000`.
83
+ */
84
+ gasLimit: defaulted(
85
+ coerce(
86
+ StrictHexStruct,
87
+ BytesLikeStruct,
88
+ (value) => bytesToHex(valueToBytes(value))
89
+ ),
90
+ valueToBytes(21e3)
91
+ ),
92
+ /**
93
+ * The max fee per gas (in Wei) to use for the transaction. The max fee per
94
+ * gas may be specified as a `number`, `bigint`, `string`, or `Uint8Array`.
95
+ * Defaults to `1`.
96
+ */
97
+ maxFeePerGas: defaulted(
98
+ coerce(
99
+ StrictHexStruct,
100
+ BytesLikeStruct,
101
+ (value) => bytesToHex(valueToBytes(value))
102
+ ),
103
+ valueToBytes(1)
104
+ ),
105
+ /**
106
+ * The max priority fee per gas (in Wei) to use for the transaction. The max
107
+ * priority fee per gas may be specified as a `number`, `bigint`, `string`,
108
+ * or `Uint8Array`. Defaults to `1`.
109
+ */
110
+ maxPriorityFeePerGas: defaulted(
111
+ coerce(
112
+ StrictHexStruct,
113
+ BytesLikeStruct,
114
+ (value) => bytesToHex(valueToBytes(value))
115
+ ),
116
+ valueToBytes(1)
117
+ ),
118
+ /**
119
+ * The nonce to use for the transaction. The nonce may be specified as a
120
+ * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.
121
+ */
122
+ nonce: defaulted(
123
+ coerce(
124
+ StrictHexStruct,
125
+ BytesLikeStruct,
126
+ (value) => bytesToHex(valueToBytes(value))
127
+ ),
128
+ valueToBytes(0)
129
+ ),
130
+ /**
131
+ * The data to send with the transaction. The data may be specified as a
132
+ * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0x`.
133
+ */
134
+ data: defaulted(
135
+ coerce(
136
+ union([StrictHexStruct, literal("0x")]),
137
+ BytesLikeStruct,
138
+ (value) => bytesToHex(valueToBytes(value))
139
+ ),
140
+ "0x"
141
+ )
142
+ });
143
+ var SignatureOptionsStruct = object({
144
+ /**
145
+ * The origin making the signature request.
146
+ */
147
+ origin: defaulted(string(), "metamask.io"),
148
+ /**
149
+ * The address signing the signature request. Defaults to a randomly generated
150
+ * address.
151
+ */
152
+ from: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {
153
+ if (value) {
154
+ return bytesToHex(valueToBytes(value));
155
+ }
156
+ return bytesToHex(randomBytes(20));
157
+ }),
158
+ /**
159
+ * The data to send with the transaction. The data may be specified as a
160
+ * `string`, an object, or an array of objects. This covers the data types
161
+ * for the supported signature methods. Defaults to `0x`.
162
+ */
163
+ data: defaulted(
164
+ union([
165
+ StrictHexStruct,
166
+ literal("0x"),
167
+ record(string(), any()),
168
+ array(record(string(), any()))
169
+ ]),
170
+ "0x"
171
+ ),
172
+ /**
173
+ * The signature method being used.
174
+ */
175
+ signatureMethod: defaulted(
176
+ union([
177
+ literal("eth_sign"),
178
+ literal("personal_sign"),
179
+ literal("eth_signTypedData"),
180
+ literal("eth_signTypedData_v3"),
181
+ literal("eth_signTypedData_v4")
182
+ ]),
183
+ "personal_sign"
184
+ )
185
+ });
186
+ var SnapOptionsStruct = object({
187
+ /**
188
+ * The timeout in milliseconds to use for requests to the snap. Defaults to
189
+ * `1000`.
190
+ */
191
+ timeout: defaulted(optional(number()), 1e3)
192
+ });
193
+ var JsonRpcMockOptionsStruct = object({
194
+ method: string(),
195
+ result: JsonStruct
196
+ });
197
+ var InterfaceStruct = type({
198
+ content: optional(ComponentStruct)
199
+ });
200
+ var SnapResponseStruct = assign(
201
+ InterfaceStruct,
202
+ object({
203
+ id: string(),
204
+ response: union([
205
+ object({
206
+ result: JsonStruct
207
+ }),
208
+ object({
209
+ error: JsonStruct
210
+ })
211
+ ]),
212
+ notifications: array(
213
+ object({
214
+ id: string(),
215
+ message: string(),
216
+ type: union([
217
+ enumValue(NotificationType.InApp),
218
+ enumValue(NotificationType.Native)
219
+ ])
220
+ })
221
+ )
222
+ })
223
+ );
224
+
225
+ export {
226
+ TransactionOptionsStruct,
227
+ SignatureOptionsStruct,
228
+ SnapOptionsStruct,
229
+ JsonRpcMockOptionsStruct,
230
+ InterfaceStruct,
231
+ SnapResponseStruct
232
+ };
233
+ //# sourceMappingURL=chunk-BN5VBVT3.mjs.map
@@ -0,0 +1 @@
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 record,\n any,\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 SignatureOptionsStruct = object({\n /**\n * The origin making the signature request.\n */\n origin: defaulted(string(), 'metamask.io'),\n\n /**\n * The address signing the signature request. Defaults to a randomly generated\n * address.\n */\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 data to send with the transaction. The data may be specified as a\n * `string`, an object, or an array of objects. This covers the data types\n * for the supported signature methods. Defaults to `0x`.\n */\n data: defaulted(\n union([\n StrictHexStruct,\n literal('0x'),\n record(string(), any()),\n array(record(string(), any())),\n ]),\n '0x',\n ),\n\n /**\n * The signature method being used.\n */\n signatureMethod: defaulted(\n union([\n literal('eth_sign'),\n literal('personal_sign'),\n literal('eth_signTypedData'),\n literal('eth_signTypedData_v3'),\n literal('eth_signTypedData_v4'),\n ]),\n 'personal_sign',\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 JsonRpcMockOptionsStruct = object({\n method: string(),\n result: JsonStruct,\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"],"mappings":"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","names":[]}
@@ -0,0 +1,22 @@
1
+ // src/internals/simulation/middleware/internal-methods/accounts.ts
2
+ import { BIP44Node } from "@metamask/key-tree";
3
+ async function getAccountsHandler(_request, response, _next, end, hooks) {
4
+ const { getMnemonic } = hooks;
5
+ const node = await BIP44Node.fromDerivationPath({
6
+ derivationPath: [
7
+ await getMnemonic(),
8
+ `bip32:44'`,
9
+ `bip32:60'`,
10
+ `bip32:0'`,
11
+ `bip32:0`,
12
+ `bip32:0`
13
+ ]
14
+ });
15
+ response.result = [node.address];
16
+ return end();
17
+ }
18
+
19
+ export {
20
+ getAccountsHandler
21
+ };
22
+ //# sourceMappingURL=chunk-CKOGTHM4.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internals/simulation/middleware/internal-methods/accounts.ts"],"sourcesContent":["import type {\n JsonRpcEngineEndCallback,\n JsonRpcEngineNextCallback,\n} from '@metamask/json-rpc-engine';\nimport { BIP44Node } from '@metamask/key-tree';\nimport type {\n Json,\n JsonRpcRequest,\n PendingJsonRpcResponse,\n} from '@metamask/utils';\n\nexport type GetAccountsHandlerHooks = {\n getMnemonic: () => Promise<Uint8Array>;\n};\n\n/**\n * A mock handler for account related methods that always returns the first\n * address for the selected secret recovery phrase.\n *\n * @param _request - Incoming JSON-RPC request. This is ignored for this\n * specific handler.\n * @param response - The outgoing JSON-RPC response, modified to return the\n * result.\n * @param _next - The `json-rpc-engine` middleware next handler.\n * @param end - The `json-rpc-engine` middleware end handler.\n * @param hooks - Any hooks required by this handler.\n */\nexport async function getAccountsHandler(\n _request: JsonRpcRequest,\n response: PendingJsonRpcResponse<Json>,\n _next: JsonRpcEngineNextCallback,\n end: JsonRpcEngineEndCallback,\n hooks: GetAccountsHandlerHooks,\n) {\n const { getMnemonic } = hooks;\n\n const node = await BIP44Node.fromDerivationPath({\n derivationPath: [\n await getMnemonic(),\n `bip32:44'`,\n `bip32:60'`,\n `bip32:0'`,\n `bip32:0`,\n `bip32:0`,\n ],\n });\n\n response.result = [node.address];\n return end();\n}\n"],"mappings":";AAIA,SAAS,iBAAiB;AAuB1B,eAAsB,mBACpB,UACA,UACA,OACA,KACA,OACA;AACA,QAAM,EAAE,YAAY,IAAI;AAExB,QAAM,OAAO,MAAM,UAAU,mBAAmB;AAAA,IAC9C,gBAAgB;AAAA,MACd,MAAM,YAAY;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AAED,WAAS,SAAS,CAAC,KAAK,OAAO;AAC/B,SAAO,IAAI;AACb;","names":[]}
@@ -0,0 +1,11 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/internals/simulation/constants.ts
2
+ var DEFAULT_SRP = "test test test test test test test test test test test ball";
3
+ var DEFAULT_LOCALE = "en";
4
+ var DEFAULT_JSON_RPC_ENDPOINT = "https://cloudflare-eth.com/";
5
+
6
+
7
+
8
+
9
+
10
+ exports.DEFAULT_SRP = DEFAULT_SRP; exports.DEFAULT_LOCALE = DEFAULT_LOCALE; exports.DEFAULT_JSON_RPC_ENDPOINT = DEFAULT_JSON_RPC_ENDPOINT;
11
+ //# sourceMappingURL=chunk-CZQKOZLR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internals/simulation/constants.ts"],"names":[],"mappings":";AAIO,IAAM,cACX;AAKK,IAAM,iBAAiB;AAKvB,IAAM,4BAA4B","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"]}
@@ -0,0 +1,24 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+ var _chunkJA7RJLI7js = require('./chunk-JA7RJLI7.js');
6
+
7
+ // src/internals/simulation/methods/hooks/show-dialog.ts
8
+ var _effects = require('redux-saga/effects');
9
+ function* showDialogImplementation(_snapId, type, id, _placeholder) {
10
+ yield _effects.put.call(void 0, _chunkJA7RJLI7js.setInterface.call(void 0, { type, id }));
11
+ const { payload } = yield _effects.take.call(void 0, _chunkJA7RJLI7js.resolveInterface.type);
12
+ yield _effects.put.call(void 0, _chunkJA7RJLI7js.closeInterface.call(void 0, ));
13
+ return payload;
14
+ }
15
+ function getShowDialogImplementation(runSaga) {
16
+ return async (...args) => {
17
+ return await runSaga(showDialogImplementation, ...args).toPromise();
18
+ };
19
+ }
20
+
21
+
22
+
23
+ exports.getShowDialogImplementation = getShowDialogImplementation;
24
+ //# sourceMappingURL=chunk-D36QBJ35.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internals/simulation/methods/hooks/show-dialog.ts"],"names":[],"mappings":";;;;;;;AAEA,SAAS,KAAK,YAAY;AAmB1B,UAAU,yBACR,SACA,MACA,IACA,cACuB;AACvB,QAAM,IAAI,aAAa,EAAE,MAAM,GAAG,CAAC,CAAC;AAIpC,QAAM,EAAE,QAAQ,IAAI,MAAM,KAAK,iBAAiB,IAAI;AACpD,QAAM,IAAI,eAAe,CAAC;AAE1B,SAAO;AACT;AAQO,SAAS,4BAA4B,SAA0B;AACpE,SAAO,UAAU,SAAsD;AACrE,WAAO,MAAM,QAAQ,0BAA0B,GAAG,IAAI,EAAE,UAAU;AAAA,EACpE;AACF","sourcesContent":["import type { DialogType } from '@metamask/snaps-sdk';\nimport type { SagaIterator } from 'redux-saga';\nimport { put, take } from 'redux-saga/effects';\n\nimport type { RunSagaFunction } from '../../store';\nimport { resolveInterface, setInterface, closeInterface } from '../../store';\n\n/**\n * Show a dialog to the user. This will wait for `resolveUserInterface` to be\n * dispatched before returning.\n *\n * @param _snapId - The ID of the Snap that created the dialog. This is ignored\n * because the simulator only supports one Snap.\n * @param type - The type of dialog to show.\n * @param id - The interface ID.\n * @param _placeholder - The placeholder text to show in the dialog. This is\n * not implemented yet.\n * @yields Sets the dialog in the store, waits for the user to resolve the\n * dialog, and closes the dialog.\n * @returns The result of the dialog.\n */\nfunction* showDialogImplementation(\n _snapId: string,\n type: DialogType,\n id: string,\n _placeholder?: string,\n): SagaIterator<unknown> {\n yield put(setInterface({ type, id }));\n\n // We use `take` to wait for `resolveUserInterface` to be dispatched, which\n // indicates that the user has resolved the dialog.\n const { payload } = yield take(resolveInterface.type);\n yield put(closeInterface());\n\n return payload;\n}\n\n/**\n * Get the implementation of the `showDialog` hook.\n *\n * @param runSaga - The function to run a saga outside the usual Redux flow.\n * @returns The implementation of the `showDialog` hook.\n */\nexport function getShowDialogImplementation(runSaga: RunSagaFunction) {\n return async (...args: Parameters<typeof showDialogImplementation>) => {\n return await runSaga(showDialogImplementation, ...args).toPromise();\n };\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import {
2
+ closeInterface,
3
+ resolveInterface,
4
+ setInterface
5
+ } from "./chunk-4VCE3DRR.mjs";
6
+
7
+ // src/internals/simulation/methods/hooks/show-dialog.ts
8
+ import { put, take } from "redux-saga/effects";
9
+ function* showDialogImplementation(_snapId, type, id, _placeholder) {
10
+ yield put(setInterface({ type, id }));
11
+ const { payload } = yield take(resolveInterface.type);
12
+ yield put(closeInterface());
13
+ return payload;
14
+ }
15
+ function getShowDialogImplementation(runSaga) {
16
+ return async (...args) => {
17
+ return await runSaga(showDialogImplementation, ...args).toPromise();
18
+ };
19
+ }
20
+
21
+ export {
22
+ getShowDialogImplementation
23
+ };
24
+ //# sourceMappingURL=chunk-DEFFA5IJ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internals/simulation/methods/hooks/show-dialog.ts"],"sourcesContent":["import type { DialogType } from '@metamask/snaps-sdk';\nimport type { SagaIterator } from 'redux-saga';\nimport { put, take } from 'redux-saga/effects';\n\nimport type { RunSagaFunction } from '../../store';\nimport { resolveInterface, setInterface, closeInterface } from '../../store';\n\n/**\n * Show a dialog to the user. This will wait for `resolveUserInterface` to be\n * dispatched before returning.\n *\n * @param _snapId - The ID of the Snap that created the dialog. This is ignored\n * because the simulator only supports one Snap.\n * @param type - The type of dialog to show.\n * @param id - The interface ID.\n * @param _placeholder - The placeholder text to show in the dialog. This is\n * not implemented yet.\n * @yields Sets the dialog in the store, waits for the user to resolve the\n * dialog, and closes the dialog.\n * @returns The result of the dialog.\n */\nfunction* showDialogImplementation(\n _snapId: string,\n type: DialogType,\n id: string,\n _placeholder?: string,\n): SagaIterator<unknown> {\n yield put(setInterface({ type, id }));\n\n // We use `take` to wait for `resolveUserInterface` to be dispatched, which\n // indicates that the user has resolved the dialog.\n const { payload } = yield take(resolveInterface.type);\n yield put(closeInterface());\n\n return payload;\n}\n\n/**\n * Get the implementation of the `showDialog` hook.\n *\n * @param runSaga - The function to run a saga outside the usual Redux flow.\n * @returns The implementation of the `showDialog` hook.\n */\nexport function getShowDialogImplementation(runSaga: RunSagaFunction) {\n return async (...args: Parameters<typeof showDialogImplementation>) => {\n return await runSaga(showDialogImplementation, ...args).toPromise();\n };\n}\n"],"mappings":";;;;;;;AAEA,SAAS,KAAK,YAAY;AAmB1B,UAAU,yBACR,SACA,MACA,IACA,cACuB;AACvB,QAAM,IAAI,aAAa,EAAE,MAAM,GAAG,CAAC,CAAC;AAIpC,QAAM,EAAE,QAAQ,IAAI,MAAM,KAAK,iBAAiB,IAAI;AACpD,QAAM,IAAI,eAAe,CAAC;AAE1B,SAAO;AACT;AAQO,SAAS,4BAA4B,SAA0B;AACpE,SAAO,UAAU,SAAsD;AACrE,WAAO,MAAM,QAAQ,0BAA0B,GAAG,IAAI,EAAE,UAAU;AAAA,EACpE;AACF;","names":[]}
@@ -0,0 +1,36 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunkCZQKOZLRjs = require('./chunk-CZQKOZLR.js');
5
+
6
+ // src/internals/simulation/options.ts
7
+ var _utils = require('@metamask/utils');
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+ var _superstruct = require('superstruct');
17
+ var SimulationOptionsStruct = _superstruct.object.call(void 0, {
18
+ secretRecoveryPhrase: _superstruct.defaulted.call(void 0, _superstruct.optional.call(void 0, _superstruct.string.call(void 0, )), _chunkCZQKOZLRjs.DEFAULT_SRP),
19
+ locale: _superstruct.defaulted.call(void 0, _superstruct.optional.call(void 0, _superstruct.string.call(void 0, )), _chunkCZQKOZLRjs.DEFAULT_LOCALE),
20
+ state: _superstruct.defaulted.call(void 0, _superstruct.optional.call(void 0, _superstruct.nullable.call(void 0, _superstruct.record.call(void 0, _superstruct.string.call(void 0, ), _utils.JsonStruct))), null),
21
+ unencryptedState: _superstruct.defaulted.call(void 0,
22
+ _superstruct.optional.call(void 0, _superstruct.nullable.call(void 0, _superstruct.record.call(void 0, _superstruct.string.call(void 0, ), _utils.JsonStruct))),
23
+ null
24
+ )
25
+ });
26
+ function getOptions(options) {
27
+ return _superstruct.create.call(void 0,
28
+ options,
29
+ SimulationOptionsStruct
30
+ );
31
+ }
32
+
33
+
34
+
35
+ exports.getOptions = getOptions;
36
+ //# sourceMappingURL=chunk-EFB6AQPB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internals/simulation/options.ts"],"names":[],"mappings":";;;;;;AAAA,SAAS,kBAAkB;AAE3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAIP,IAAM,0BAA0B,OAAO;AAAA,EACrC,sBAAsB,UAAU,SAAS,OAAO,CAAC,GAAG,WAAW;AAAA,EAC/D,QAAQ,UAAU,SAAS,OAAO,CAAC,GAAG,cAAc;AAAA,EACpD,OAAO,UAAU,SAAS,SAAS,OAAO,OAAO,GAAG,UAAU,CAAC,CAAC,GAAG,IAAI;AAAA,EACvE,kBAAkB;AAAA,IAChB,SAAS,SAAS,OAAO,OAAO,GAAG,UAAU,CAAC,CAAC;AAAA,IAC/C;AAAA,EACF;AACF,CAAC;AA2BM,SAAS,WAAW,SAAmD;AAC5E,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF","sourcesContent":["import { JsonStruct } from '@metamask/utils';\nimport type { Infer } from 'superstruct';\nimport {\n create,\n defaulted,\n nullable,\n object,\n optional,\n record,\n string,\n} from 'superstruct';\n\nimport { DEFAULT_LOCALE, DEFAULT_SRP } from './constants';\n\nconst SimulationOptionsStruct = object({\n secretRecoveryPhrase: defaulted(optional(string()), DEFAULT_SRP),\n locale: defaulted(optional(string()), DEFAULT_LOCALE),\n state: defaulted(optional(nullable(record(string(), JsonStruct))), null),\n unencryptedState: defaulted(\n optional(nullable(record(string(), JsonStruct))),\n null,\n ),\n});\n\n/**\n * Options for the simulation.\n *\n * @property secretRecoveryPhrase - The secret recovery phrase to use. This is\n * used to derive addresses and private keys. Defaults to a test recovery\n * phrase.\n * @property locale - The locale to use. Defaults to `en`.\n * @property state - The initial state of the Snap, if any. Defaults to `null`.\n */\nexport type SimulationUserOptions = Infer<typeof SimulationOptionsStruct>;\n\n/**\n * Options for the simulation, with defaults filled in.\n *\n * See {@link SimulationUserOptions} for documentation.\n */\nexport type SimulationOptions = Required<SimulationUserOptions>;\n\n/**\n * Get the options for the simulation.\n *\n * @param options - The user options. Any options not specified will be filled\n * in with default values.\n * @returns The simulation options.\n */\nexport function getOptions(options: SimulationUserOptions): SimulationOptions {\n return create(\n options,\n SimulationOptionsStruct,\n ) as Required<SimulationUserOptions>;\n}\n"]}
@@ -0,0 +1,97 @@
1
+ import {
2
+ decryptImplementation,
3
+ encryptImplementation
4
+ } from "./chunk-VYKYQSUI.mjs";
5
+ import {
6
+ getGetLocaleMethodImplementation
7
+ } from "./chunk-MSQ7Q2VJ.mjs";
8
+ import {
9
+ getCreateInterfaceImplementation,
10
+ getGetInterfaceImplementation
11
+ } from "./chunk-OC64PNDU.mjs";
12
+ import {
13
+ getShowInAppNotificationImplementation,
14
+ getShowNativeNotificationImplementation
15
+ } from "./chunk-AKFRQ5EJ.mjs";
16
+ import {
17
+ getShowDialogImplementation
18
+ } from "./chunk-DEFFA5IJ.mjs";
19
+ import {
20
+ getClearSnapStateMethodImplementation,
21
+ getGetSnapStateMethodImplementation,
22
+ getUpdateSnapStateMethodImplementation
23
+ } from "./chunk-6RDNSELT.mjs";
24
+ import {
25
+ EXCLUDED_SNAP_ENDOWMENTS,
26
+ EXCLUDED_SNAP_PERMISSIONS
27
+ } from "./chunk-I5LVU57H.mjs";
28
+
29
+ // src/internals/simulation/methods/specifications.ts
30
+ import {
31
+ endowmentPermissionBuilders,
32
+ buildSnapEndowmentSpecifications,
33
+ buildSnapRestrictedMethodSpecifications
34
+ } from "@metamask/snaps-rpc-methods";
35
+ import { DEFAULT_ENDOWMENTS } from "@metamask/snaps-utils";
36
+ function resolve(result) {
37
+ return () => result;
38
+ }
39
+ function asyncResolve(result) {
40
+ return async () => result;
41
+ }
42
+ function getPermissionSpecifications({
43
+ controllerMessenger,
44
+ hooks,
45
+ runSaga,
46
+ options
47
+ }) {
48
+ return {
49
+ ...buildSnapEndowmentSpecifications(EXCLUDED_SNAP_ENDOWMENTS),
50
+ ...buildSnapRestrictedMethodSpecifications(EXCLUDED_SNAP_PERMISSIONS, {
51
+ // Shared hooks.
52
+ ...hooks,
53
+ // Encryption and decryption hooks.
54
+ // TODO: Swap these out for the real implementations.
55
+ encrypt: encryptImplementation,
56
+ decrypt: decryptImplementation,
57
+ // Snaps-specific hooks.
58
+ clearSnapState: getClearSnapStateMethodImplementation(runSaga),
59
+ getLocale: getGetLocaleMethodImplementation(options),
60
+ getSnapState: getGetSnapStateMethodImplementation(runSaga),
61
+ getUnlockPromise: asyncResolve(true),
62
+ // TODO: Allow the user to specify the result of this function.
63
+ isOnPhishingList: resolve(false),
64
+ maybeUpdatePhishingList: asyncResolve(),
65
+ showDialog: getShowDialogImplementation(runSaga),
66
+ showInAppNotification: getShowInAppNotificationImplementation(runSaga),
67
+ showNativeNotification: getShowNativeNotificationImplementation(runSaga),
68
+ updateSnapState: getUpdateSnapStateMethodImplementation(runSaga),
69
+ createInterface: getCreateInterfaceImplementation(controllerMessenger),
70
+ getInterface: getGetInterfaceImplementation(controllerMessenger)
71
+ })
72
+ };
73
+ }
74
+ async function getEndowments(permissionController, snapId) {
75
+ const allEndowments = await Object.keys(endowmentPermissionBuilders).reduce(async (promise, permissionName) => {
76
+ const accumulator = await promise;
77
+ if (permissionController.hasPermission(snapId, permissionName)) {
78
+ const endowments = await permissionController.getEndowments(
79
+ snapId,
80
+ permissionName
81
+ );
82
+ if (endowments) {
83
+ return accumulator.concat(endowments);
84
+ }
85
+ }
86
+ return accumulator;
87
+ }, Promise.resolve([]));
88
+ return [.../* @__PURE__ */ new Set([...DEFAULT_ENDOWMENTS, ...allEndowments])];
89
+ }
90
+
91
+ export {
92
+ resolve,
93
+ asyncResolve,
94
+ getPermissionSpecifications,
95
+ getEndowments
96
+ };
97
+ //# sourceMappingURL=chunk-EOCDSPT7.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internals/simulation/methods/specifications.ts"],"sourcesContent":["import type { GenericPermissionController } from '@metamask/permission-controller';\nimport {\n endowmentPermissionBuilders,\n buildSnapEndowmentSpecifications,\n buildSnapRestrictedMethodSpecifications,\n} from '@metamask/snaps-rpc-methods';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { DEFAULT_ENDOWMENTS } from '@metamask/snaps-utils';\n\nimport type { RootControllerMessenger } from '../controllers';\nimport type { SimulationOptions } from '../options';\nimport type { RunSagaFunction } from '../store';\nimport {\n EXCLUDED_SNAP_ENDOWMENTS,\n EXCLUDED_SNAP_PERMISSIONS,\n} from './constants';\nimport {\n getGetLocaleMethodImplementation,\n getClearSnapStateMethodImplementation,\n getGetSnapStateMethodImplementation,\n getUpdateSnapStateMethodImplementation,\n getShowDialogImplementation,\n getShowInAppNotificationImplementation,\n getShowNativeNotificationImplementation,\n encryptImplementation,\n decryptImplementation,\n getCreateInterfaceImplementation,\n getGetInterfaceImplementation,\n} from './hooks';\n\nexport type PermissionSpecificationsHooks = {\n /**\n * A hook that returns the user's secret recovery phrase.\n *\n * @returns The user's secret recovery phrase.\n */\n getMnemonic: () => Promise<Uint8Array>;\n};\n\nexport type GetPermissionSpecificationsOptions = {\n controllerMessenger: RootControllerMessenger;\n hooks: PermissionSpecificationsHooks;\n runSaga: RunSagaFunction;\n options: SimulationOptions;\n};\n\n/**\n * Get a function which resolves with the specified result.\n *\n * @param result - The result to return.\n * @returns The function implementation.\n */\nexport function resolve(result: unknown) {\n return () => result;\n}\n\n/**\n * Get a function which resolves with the specified result.\n *\n * @param result - The result to return. If not specified, the function will\n * resolve with `undefined`.\n * @returns The function implementation.\n */\nexport function asyncResolve(result?: unknown) {\n return async () => result;\n}\n\n/**\n * Get the permission specifications for the Snap.\n *\n * @param options - The options.\n * @param options.controllerMessenger - The controller messenger.\n * @param options.hooks - The hooks.\n * @param options.runSaga - The function to run a saga outside the usual Redux\n * flow.\n * @param options.options - The simulation options.\n * @returns The permission specifications for the Snap.\n */\nexport function getPermissionSpecifications({\n controllerMessenger,\n hooks,\n runSaga,\n options,\n}: GetPermissionSpecificationsOptions) {\n return {\n ...buildSnapEndowmentSpecifications(EXCLUDED_SNAP_ENDOWMENTS),\n ...buildSnapRestrictedMethodSpecifications(EXCLUDED_SNAP_PERMISSIONS, {\n // Shared hooks.\n ...hooks,\n\n // Encryption and decryption hooks.\n // TODO: Swap these out for the real implementations.\n encrypt: encryptImplementation,\n decrypt: decryptImplementation,\n\n // Snaps-specific hooks.\n clearSnapState: getClearSnapStateMethodImplementation(runSaga),\n getLocale: getGetLocaleMethodImplementation(options),\n getSnapState: getGetSnapStateMethodImplementation(runSaga),\n getUnlockPromise: asyncResolve(true),\n\n // TODO: Allow the user to specify the result of this function.\n isOnPhishingList: resolve(false),\n\n maybeUpdatePhishingList: asyncResolve(),\n showDialog: getShowDialogImplementation(runSaga),\n showInAppNotification: getShowInAppNotificationImplementation(runSaga),\n showNativeNotification: getShowNativeNotificationImplementation(runSaga),\n updateSnapState: getUpdateSnapStateMethodImplementation(runSaga),\n createInterface: getCreateInterfaceImplementation(controllerMessenger),\n getInterface: getGetInterfaceImplementation(controllerMessenger),\n }),\n };\n}\n\n/**\n * Get the endowments for the Snap.\n *\n * @param permissionController - The permission controller.\n * @param snapId - The ID of the Snap.\n * @returns The endowments for the Snap.\n */\nexport async function getEndowments(\n permissionController: GenericPermissionController,\n snapId: SnapId,\n) {\n const allEndowments = await Object.keys(endowmentPermissionBuilders).reduce<\n Promise<string[]>\n >(async (promise, permissionName) => {\n const accumulator = await promise;\n if (permissionController.hasPermission(snapId, permissionName)) {\n const endowments = await permissionController.getEndowments(\n snapId,\n permissionName,\n );\n\n if (endowments) {\n return accumulator.concat(endowments as string[]);\n }\n }\n\n return accumulator;\n }, Promise.resolve([]));\n\n return [...new Set([...DEFAULT_ENDOWMENTS, ...allEndowments])];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,0BAA0B;AA6C5B,SAAS,QAAQ,QAAiB;AACvC,SAAO,MAAM;AACf;AASO,SAAS,aAAa,QAAkB;AAC7C,SAAO,YAAY;AACrB;AAaO,SAAS,4BAA4B;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAuC;AACrC,SAAO;AAAA,IACL,GAAG,iCAAiC,wBAAwB;AAAA,IAC5D,GAAG,wCAAwC,2BAA2B;AAAA;AAAA,MAEpE,GAAG;AAAA;AAAA;AAAA,MAIH,SAAS;AAAA,MACT,SAAS;AAAA;AAAA,MAGT,gBAAgB,sCAAsC,OAAO;AAAA,MAC7D,WAAW,iCAAiC,OAAO;AAAA,MACnD,cAAc,oCAAoC,OAAO;AAAA,MACzD,kBAAkB,aAAa,IAAI;AAAA;AAAA,MAGnC,kBAAkB,QAAQ,KAAK;AAAA,MAE/B,yBAAyB,aAAa;AAAA,MACtC,YAAY,4BAA4B,OAAO;AAAA,MAC/C,uBAAuB,uCAAuC,OAAO;AAAA,MACrE,wBAAwB,wCAAwC,OAAO;AAAA,MACvE,iBAAiB,uCAAuC,OAAO;AAAA,MAC/D,iBAAiB,iCAAiC,mBAAmB;AAAA,MACrE,cAAc,8BAA8B,mBAAmB;AAAA,IACjE,CAAC;AAAA,EACH;AACF;AASA,eAAsB,cACpB,sBACA,QACA;AACA,QAAM,gBAAgB,MAAM,OAAO,KAAK,2BAA2B,EAAE,OAEnE,OAAO,SAAS,mBAAmB;AACnC,UAAM,cAAc,MAAM;AAC1B,QAAI,qBAAqB,cAAc,QAAQ,cAAc,GAAG;AAC9D,YAAM,aAAa,MAAM,qBAAqB;AAAA,QAC5C;AAAA,QACA;AAAA,MACF;AAEA,UAAI,YAAY;AACd,eAAO,YAAY,OAAO,UAAsB;AAAA,MAClD;AAAA,IACF;AAEA,WAAO;AAAA,EACT,GAAG,QAAQ,QAAQ,CAAC,CAAC,CAAC;AAEtB,SAAO,CAAC,GAAG,oBAAI,IAAI,CAAC,GAAG,oBAAoB,GAAG,aAAa,CAAC,CAAC;AAC/D;","names":[]}
@@ -0,0 +1,36 @@
1
+ import {
2
+ DEFAULT_LOCALE,
3
+ DEFAULT_SRP
4
+ } from "./chunk-JXOKRTEH.mjs";
5
+
6
+ // src/internals/simulation/options.ts
7
+ import { JsonStruct } from "@metamask/utils";
8
+ import {
9
+ create,
10
+ defaulted,
11
+ nullable,
12
+ object,
13
+ optional,
14
+ record,
15
+ string
16
+ } from "superstruct";
17
+ var SimulationOptionsStruct = object({
18
+ secretRecoveryPhrase: defaulted(optional(string()), DEFAULT_SRP),
19
+ locale: defaulted(optional(string()), DEFAULT_LOCALE),
20
+ state: defaulted(optional(nullable(record(string(), JsonStruct))), null),
21
+ unencryptedState: defaulted(
22
+ optional(nullable(record(string(), JsonStruct))),
23
+ null
24
+ )
25
+ });
26
+ function getOptions(options) {
27
+ return create(
28
+ options,
29
+ SimulationOptionsStruct
30
+ );
31
+ }
32
+
33
+ export {
34
+ getOptions
35
+ };
36
+ //# sourceMappingURL=chunk-FPFX5AKR.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internals/simulation/options.ts"],"sourcesContent":["import { JsonStruct } from '@metamask/utils';\nimport type { Infer } from 'superstruct';\nimport {\n create,\n defaulted,\n nullable,\n object,\n optional,\n record,\n string,\n} from 'superstruct';\n\nimport { DEFAULT_LOCALE, DEFAULT_SRP } from './constants';\n\nconst SimulationOptionsStruct = object({\n secretRecoveryPhrase: defaulted(optional(string()), DEFAULT_SRP),\n locale: defaulted(optional(string()), DEFAULT_LOCALE),\n state: defaulted(optional(nullable(record(string(), JsonStruct))), null),\n unencryptedState: defaulted(\n optional(nullable(record(string(), JsonStruct))),\n null,\n ),\n});\n\n/**\n * Options for the simulation.\n *\n * @property secretRecoveryPhrase - The secret recovery phrase to use. This is\n * used to derive addresses and private keys. Defaults to a test recovery\n * phrase.\n * @property locale - The locale to use. Defaults to `en`.\n * @property state - The initial state of the Snap, if any. Defaults to `null`.\n */\nexport type SimulationUserOptions = Infer<typeof SimulationOptionsStruct>;\n\n/**\n * Options for the simulation, with defaults filled in.\n *\n * See {@link SimulationUserOptions} for documentation.\n */\nexport type SimulationOptions = Required<SimulationUserOptions>;\n\n/**\n * Get the options for the simulation.\n *\n * @param options - The user options. Any options not specified will be filled\n * in with default values.\n * @returns The simulation options.\n */\nexport function getOptions(options: SimulationUserOptions): SimulationOptions {\n return create(\n options,\n SimulationOptionsStruct,\n ) as Required<SimulationUserOptions>;\n}\n"],"mappings":";;;;;;AAAA,SAAS,kBAAkB;AAE3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAIP,IAAM,0BAA0B,OAAO;AAAA,EACrC,sBAAsB,UAAU,SAAS,OAAO,CAAC,GAAG,WAAW;AAAA,EAC/D,QAAQ,UAAU,SAAS,OAAO,CAAC,GAAG,cAAc;AAAA,EACpD,OAAO,UAAU,SAAS,SAAS,OAAO,OAAO,GAAG,UAAU,CAAC,CAAC,GAAG,IAAI;AAAA,EACvE,kBAAkB;AAAA,IAChB,SAAS,SAAS,OAAO,OAAO,GAAG,UAAU,CAAC,CAAC;AAAA,IAC/C;AAAA,EACF;AACF,CAAC;AA2BM,SAAS,WAAW,SAAmD;AAC5E,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-HBT34TJ2.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,80 @@
1
+ import {
2
+ getInterface
3
+ } from "./chunk-WL2GRM5E.mjs";
4
+ import {
5
+ clearNotifications,
6
+ getNotifications
7
+ } from "./chunk-AIZADBRK.mjs";
8
+
9
+ // src/internals/request.ts
10
+ import { unwrapError } from "@metamask/snaps-utils";
11
+ import { getSafeJson, hasProperty, isPlainObject } from "@metamask/utils";
12
+ import { nanoid } from "@reduxjs/toolkit";
13
+ function handleRequest({
14
+ snapId,
15
+ store,
16
+ executionService,
17
+ handler,
18
+ controllerMessenger,
19
+ runSaga,
20
+ request: { id = nanoid(), origin = "https://metamask.io", ...options }
21
+ }) {
22
+ const promise = executionService.handleRpcRequest(snapId, {
23
+ origin,
24
+ handler,
25
+ request: {
26
+ jsonrpc: "2.0",
27
+ id: 1,
28
+ ...options
29
+ }
30
+ }).then((result) => {
31
+ const notifications = getNotifications(store.getState());
32
+ store.dispatch(clearNotifications());
33
+ const content = getContentFromResult(result, snapId, controllerMessenger);
34
+ return {
35
+ id: String(id),
36
+ response: {
37
+ result: getSafeJson(result)
38
+ },
39
+ notifications,
40
+ content
41
+ };
42
+ }).catch((error) => {
43
+ const [unwrappedError] = unwrapError(error);
44
+ return {
45
+ id: String(id),
46
+ response: {
47
+ error: unwrappedError.serialize()
48
+ },
49
+ notifications: []
50
+ };
51
+ });
52
+ promise.getInterface = async () => {
53
+ return await runSaga(
54
+ getInterface,
55
+ runSaga,
56
+ snapId,
57
+ controllerMessenger
58
+ ).toPromise();
59
+ };
60
+ return promise;
61
+ }
62
+ function getContentFromResult(result, snapId, controllerMessenger) {
63
+ if (isPlainObject(result) && hasProperty(result, "id")) {
64
+ return controllerMessenger.call(
65
+ "SnapInterfaceController:getInterface",
66
+ snapId,
67
+ result.id
68
+ ).content;
69
+ }
70
+ if (isPlainObject(result) && hasProperty(result, "content")) {
71
+ return result.content;
72
+ }
73
+ return void 0;
74
+ }
75
+
76
+ export {
77
+ handleRequest,
78
+ getContentFromResult
79
+ };
80
+ //# sourceMappingURL=chunk-HBVDXIVN.mjs.map
@@ -0,0 +1 @@
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"],"mappings":";;;;;;;;;AAGA,SAAS,mBAAmB;AAC5B,SAAS,aAAa,aAAa,qBAAqB;AACxD,SAAS,cAAc;AAyChB,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS,EAAE,KAAK,OAAO,GAAG,SAAS,uBAAuB,GAAG,QAAQ;AACvE,GAAsC;AACpC,QAAM,UAAU,iBACb,iBAAiB,QAAQ;AAAA,IACxB;AAAA,IACA;AAAA,IACA,SAAS;AAAA,MACP,SAAS;AAAA,MACT,IAAI;AAAA,MACJ,GAAG;AAAA,IACL;AAAA,EACF,CAAC,EACA,KAAK,CAAC,WAAW;AAChB,UAAM,gBAAgB,iBAAiB,MAAM,SAAS,CAAC;AACvD,UAAM,SAAS,mBAAmB,CAAC;AAEnC,UAAM,UAAU,qBAAqB,QAAQ,QAAQ,mBAAmB;AAExE,WAAO;AAAA,MACL,IAAI,OAAO,EAAE;AAAA,MACb,UAAU;AAAA,QACR,QAAQ,YAAY,MAAM;AAAA,MAC5B;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC,EACA,MAAM,CAAC,UAAU;AAChB,UAAM,CAAC,cAAc,IAAI,YAAY,KAAK;AAE1C,WAAO;AAAA,MACL,IAAI,OAAO,EAAE;AAAA,MACb,UAAU;AAAA,QACR,OAAO,eAAe,UAAU;AAAA,MAClC;AAAA,MACA,eAAe,CAAC;AAAA,IAClB;AAAA,EACF,CAAC;AAEH,UAAQ,eAAe,YAAY;AACjC,WAAO,MAAM;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,EAAE,UAAU;AAAA,EACd;AAEA,SAAO;AACT;AAUO,SAAS,qBACd,QACA,QACA,qBACuB;AACvB,MAAI,cAAc,MAAM,KAAK,YAAY,QAAQ,IAAI,GAAG;AACtD,WAAO,oBAAoB;AAAA,MACzB;AAAA,MACA;AAAA,MACA,OAAO;AAAA,IACT,EAAE;AAAA,EACJ;AAEA,MAAI,cAAc,MAAM,KAAK,YAAY,QAAQ,SAAS,GAAG;AAC3D,WAAO,OAAO;AAAA,EAChB;AAEA,SAAO;AACT;","names":[]}