@metamask/snaps-jest 8.3.1 → 8.4.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 (296) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/dist/environment.cjs +2 -1
  3. package/dist/environment.cjs.map +1 -1
  4. package/dist/environment.d.cts +1 -1
  5. package/dist/environment.d.cts.map +1 -1
  6. package/dist/environment.d.mts +1 -1
  7. package/dist/environment.d.mts.map +1 -1
  8. package/dist/environment.mjs +3 -2
  9. package/dist/environment.mjs.map +1 -1
  10. package/dist/helpers.cjs +13 -80
  11. package/dist/helpers.cjs.map +1 -1
  12. package/dist/helpers.d.cts +2 -44
  13. package/dist/helpers.d.cts.map +1 -1
  14. package/dist/helpers.d.mts +2 -44
  15. package/dist/helpers.d.mts.map +1 -1
  16. package/dist/helpers.mjs +4 -64
  17. package/dist/helpers.mjs.map +1 -1
  18. package/dist/index.cjs +8 -1
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +1 -0
  21. package/dist/index.d.cts.map +1 -1
  22. package/dist/index.d.mts +1 -0
  23. package/dist/index.d.mts.map +1 -1
  24. package/dist/index.mjs +1 -0
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/internals/environment.d.cts +1 -1
  27. package/dist/internals/environment.d.mts +1 -1
  28. package/dist/internals/index.cjs +0 -3
  29. package/dist/internals/index.cjs.map +1 -1
  30. package/dist/internals/index.d.cts +0 -3
  31. package/dist/internals/index.d.cts.map +1 -1
  32. package/dist/internals/index.d.mts +0 -3
  33. package/dist/internals/index.d.mts.map +1 -1
  34. package/dist/internals/index.mjs +0 -3
  35. package/dist/internals/index.mjs.map +1 -1
  36. package/dist/matchers.cjs +3 -3
  37. package/dist/matchers.cjs.map +1 -1
  38. package/dist/matchers.d.cts.map +1 -1
  39. package/dist/matchers.d.mts.map +1 -1
  40. package/dist/matchers.mjs +1 -1
  41. package/dist/matchers.mjs.map +1 -1
  42. package/dist/types/types.cjs.map +1 -1
  43. package/dist/types/types.d.cts +8 -1
  44. package/dist/types/types.d.cts.map +1 -1
  45. package/dist/types/types.d.mts +8 -1
  46. package/dist/types/types.d.mts.map +1 -1
  47. package/dist/types/types.mjs.map +1 -1
  48. package/package.json +7 -20
  49. package/dist/internals/request.cjs +0 -143
  50. package/dist/internals/request.cjs.map +0 -1
  51. package/dist/internals/request.d.cts +0 -56
  52. package/dist/internals/request.d.cts.map +0 -1
  53. package/dist/internals/request.d.mts +0 -56
  54. package/dist/internals/request.d.mts.map +0 -1
  55. package/dist/internals/request.mjs +0 -138
  56. package/dist/internals/request.mjs.map +0 -1
  57. package/dist/internals/simulation/constants.cjs +0 -21
  58. package/dist/internals/simulation/constants.cjs.map +0 -1
  59. package/dist/internals/simulation/constants.d.cts +0 -18
  60. package/dist/internals/simulation/constants.d.cts.map +0 -1
  61. package/dist/internals/simulation/constants.d.mts +0 -18
  62. package/dist/internals/simulation/constants.d.mts.map +0 -1
  63. package/dist/internals/simulation/constants.mjs +0 -18
  64. package/dist/internals/simulation/constants.mjs.map +0 -1
  65. package/dist/internals/simulation/controllers.cjs +0 -101
  66. package/dist/internals/simulation/controllers.cjs.map +0 -1
  67. package/dist/internals/simulation/controllers.d.cts +0 -41
  68. package/dist/internals/simulation/controllers.d.cts.map +0 -1
  69. package/dist/internals/simulation/controllers.d.mts +0 -41
  70. package/dist/internals/simulation/controllers.d.mts.map +0 -1
  71. package/dist/internals/simulation/controllers.mjs +0 -96
  72. package/dist/internals/simulation/controllers.mjs.map +0 -1
  73. package/dist/internals/simulation/files.cjs +0 -94
  74. package/dist/internals/simulation/files.cjs.map +0 -1
  75. package/dist/internals/simulation/files.d.cts +0 -49
  76. package/dist/internals/simulation/files.d.cts.map +0 -1
  77. package/dist/internals/simulation/files.d.mts +0 -49
  78. package/dist/internals/simulation/files.d.mts.map +0 -1
  79. package/dist/internals/simulation/files.mjs +0 -91
  80. package/dist/internals/simulation/files.mjs.map +0 -1
  81. package/dist/internals/simulation/index.cjs +0 -22
  82. package/dist/internals/simulation/index.cjs.map +0 -1
  83. package/dist/internals/simulation/index.d.cts +0 -6
  84. package/dist/internals/simulation/index.d.cts.map +0 -1
  85. package/dist/internals/simulation/index.d.mts +0 -6
  86. package/dist/internals/simulation/index.d.mts.map +0 -1
  87. package/dist/internals/simulation/index.mjs +0 -6
  88. package/dist/internals/simulation/index.mjs.map +0 -1
  89. package/dist/internals/simulation/interface.cjs +0 -527
  90. package/dist/internals/simulation/interface.cjs.map +0 -1
  91. package/dist/internals/simulation/interface.d.cts +0 -152
  92. package/dist/internals/simulation/interface.d.cts.map +0 -1
  93. package/dist/internals/simulation/interface.d.mts +0 -152
  94. package/dist/internals/simulation/interface.d.mts.map +0 -1
  95. package/dist/internals/simulation/interface.mjs +0 -513
  96. package/dist/internals/simulation/interface.mjs.map +0 -1
  97. package/dist/internals/simulation/methods/constants.cjs +0 -72
  98. package/dist/internals/simulation/methods/constants.cjs.map +0 -1
  99. package/dist/internals/simulation/methods/constants.d.cts +0 -11
  100. package/dist/internals/simulation/methods/constants.d.cts.map +0 -1
  101. package/dist/internals/simulation/methods/constants.d.mts +0 -11
  102. package/dist/internals/simulation/methods/constants.d.mts.map +0 -1
  103. package/dist/internals/simulation/methods/constants.mjs +0 -69
  104. package/dist/internals/simulation/methods/constants.mjs.map +0 -1
  105. package/dist/internals/simulation/methods/hooks/get-preferences.cjs +0 -18
  106. package/dist/internals/simulation/methods/hooks/get-preferences.cjs.map +0 -1
  107. package/dist/internals/simulation/methods/hooks/get-preferences.d.cts +0 -14
  108. package/dist/internals/simulation/methods/hooks/get-preferences.d.cts.map +0 -1
  109. package/dist/internals/simulation/methods/hooks/get-preferences.d.mts +0 -14
  110. package/dist/internals/simulation/methods/hooks/get-preferences.d.mts.map +0 -1
  111. package/dist/internals/simulation/methods/hooks/get-preferences.mjs +0 -14
  112. package/dist/internals/simulation/methods/hooks/get-preferences.mjs.map +0 -1
  113. package/dist/internals/simulation/methods/hooks/index.cjs +0 -22
  114. package/dist/internals/simulation/methods/hooks/index.cjs.map +0 -1
  115. package/dist/internals/simulation/methods/hooks/index.d.cts +0 -6
  116. package/dist/internals/simulation/methods/hooks/index.d.cts.map +0 -1
  117. package/dist/internals/simulation/methods/hooks/index.d.mts +0 -6
  118. package/dist/internals/simulation/methods/hooks/index.d.mts.map +0 -1
  119. package/dist/internals/simulation/methods/hooks/index.mjs +0 -6
  120. package/dist/internals/simulation/methods/hooks/index.mjs.map +0 -1
  121. package/dist/internals/simulation/methods/hooks/interface.cjs +0 -24
  122. package/dist/internals/simulation/methods/hooks/interface.cjs.map +0 -1
  123. package/dist/internals/simulation/methods/hooks/interface.d.cts +0 -17
  124. package/dist/internals/simulation/methods/hooks/interface.d.cts.map +0 -1
  125. package/dist/internals/simulation/methods/hooks/interface.d.mts +0 -17
  126. package/dist/internals/simulation/methods/hooks/interface.d.mts.map +0 -1
  127. package/dist/internals/simulation/methods/hooks/interface.mjs +0 -19
  128. package/dist/internals/simulation/methods/hooks/interface.mjs.map +0 -1
  129. package/dist/internals/simulation/methods/hooks/notifications.cjs +0 -58
  130. package/dist/internals/simulation/methods/hooks/notifications.cjs.map +0 -1
  131. package/dist/internals/simulation/methods/hooks/notifications.d.cts +0 -17
  132. package/dist/internals/simulation/methods/hooks/notifications.d.cts.map +0 -1
  133. package/dist/internals/simulation/methods/hooks/notifications.d.mts +0 -17
  134. package/dist/internals/simulation/methods/hooks/notifications.d.mts.map +0 -1
  135. package/dist/internals/simulation/methods/hooks/notifications.mjs +0 -55
  136. package/dist/internals/simulation/methods/hooks/notifications.mjs.map +0 -1
  137. package/dist/internals/simulation/methods/hooks/request-user-approval.cjs +0 -38
  138. package/dist/internals/simulation/methods/hooks/request-user-approval.cjs.map +0 -1
  139. package/dist/internals/simulation/methods/hooks/request-user-approval.d.cts +0 -16
  140. package/dist/internals/simulation/methods/hooks/request-user-approval.d.cts.map +0 -1
  141. package/dist/internals/simulation/methods/hooks/request-user-approval.d.mts +0 -16
  142. package/dist/internals/simulation/methods/hooks/request-user-approval.d.mts.map +0 -1
  143. package/dist/internals/simulation/methods/hooks/request-user-approval.mjs +0 -35
  144. package/dist/internals/simulation/methods/hooks/request-user-approval.mjs.map +0 -1
  145. package/dist/internals/simulation/methods/hooks/state.cjs +0 -84
  146. package/dist/internals/simulation/methods/hooks/state.cjs.map +0 -1
  147. package/dist/internals/simulation/methods/hooks/state.d.cts +0 -24
  148. package/dist/internals/simulation/methods/hooks/state.d.cts.map +0 -1
  149. package/dist/internals/simulation/methods/hooks/state.d.mts +0 -24
  150. package/dist/internals/simulation/methods/hooks/state.d.mts.map +0 -1
  151. package/dist/internals/simulation/methods/hooks/state.mjs +0 -79
  152. package/dist/internals/simulation/methods/hooks/state.mjs.map +0 -1
  153. package/dist/internals/simulation/methods/index.cjs +0 -18
  154. package/dist/internals/simulation/methods/index.cjs.map +0 -1
  155. package/dist/internals/simulation/methods/index.d.cts +0 -2
  156. package/dist/internals/simulation/methods/index.d.cts.map +0 -1
  157. package/dist/internals/simulation/methods/index.d.mts +0 -2
  158. package/dist/internals/simulation/methods/index.d.mts.map +0 -1
  159. package/dist/internals/simulation/methods/index.mjs +0 -2
  160. package/dist/internals/simulation/methods/index.mjs.map +0 -1
  161. package/dist/internals/simulation/methods/specifications.cjs +0 -85
  162. package/dist/internals/simulation/methods/specifications.cjs.map +0 -1
  163. package/dist/internals/simulation/methods/specifications.d.cts +0 -57
  164. package/dist/internals/simulation/methods/specifications.d.cts.map +0 -1
  165. package/dist/internals/simulation/methods/specifications.d.mts +0 -57
  166. package/dist/internals/simulation/methods/specifications.d.mts.map +0 -1
  167. package/dist/internals/simulation/methods/specifications.mjs +0 -78
  168. package/dist/internals/simulation/methods/specifications.mjs.map +0 -1
  169. package/dist/internals/simulation/middleware/engine.cjs +0 -37
  170. package/dist/internals/simulation/middleware/engine.cjs.map +0 -1
  171. package/dist/internals/simulation/middleware/engine.d.cts +0 -27
  172. package/dist/internals/simulation/middleware/engine.d.cts.map +0 -1
  173. package/dist/internals/simulation/middleware/engine.d.mts +0 -27
  174. package/dist/internals/simulation/middleware/engine.d.mts.map +0 -1
  175. package/dist/internals/simulation/middleware/engine.mjs +0 -34
  176. package/dist/internals/simulation/middleware/engine.mjs.map +0 -1
  177. package/dist/internals/simulation/middleware/index.cjs +0 -18
  178. package/dist/internals/simulation/middleware/index.cjs.map +0 -1
  179. package/dist/internals/simulation/middleware/index.d.cts +0 -2
  180. package/dist/internals/simulation/middleware/index.d.cts.map +0 -1
  181. package/dist/internals/simulation/middleware/index.d.mts +0 -2
  182. package/dist/internals/simulation/middleware/index.d.mts.map +0 -1
  183. package/dist/internals/simulation/middleware/index.mjs +0 -2
  184. package/dist/internals/simulation/middleware/index.mjs.map +0 -1
  185. package/dist/internals/simulation/middleware/internal-methods/accounts.cjs +0 -34
  186. package/dist/internals/simulation/middleware/internal-methods/accounts.cjs.map +0 -1
  187. package/dist/internals/simulation/middleware/internal-methods/accounts.d.cts +0 -20
  188. package/dist/internals/simulation/middleware/internal-methods/accounts.d.cts.map +0 -1
  189. package/dist/internals/simulation/middleware/internal-methods/accounts.d.mts +0 -20
  190. package/dist/internals/simulation/middleware/internal-methods/accounts.d.mts.map +0 -1
  191. package/dist/internals/simulation/middleware/internal-methods/accounts.mjs +0 -30
  192. package/dist/internals/simulation/middleware/internal-methods/accounts.mjs.map +0 -1
  193. package/dist/internals/simulation/middleware/internal-methods/index.cjs +0 -18
  194. package/dist/internals/simulation/middleware/internal-methods/index.cjs.map +0 -1
  195. package/dist/internals/simulation/middleware/internal-methods/index.d.cts +0 -2
  196. package/dist/internals/simulation/middleware/internal-methods/index.d.cts.map +0 -1
  197. package/dist/internals/simulation/middleware/internal-methods/index.d.mts +0 -2
  198. package/dist/internals/simulation/middleware/internal-methods/index.d.mts.map +0 -1
  199. package/dist/internals/simulation/middleware/internal-methods/index.mjs +0 -2
  200. package/dist/internals/simulation/middleware/internal-methods/index.mjs.map +0 -1
  201. package/dist/internals/simulation/middleware/internal-methods/middleware.cjs +0 -44
  202. package/dist/internals/simulation/middleware/internal-methods/middleware.cjs.map +0 -1
  203. package/dist/internals/simulation/middleware/internal-methods/middleware.d.cts +0 -23
  204. package/dist/internals/simulation/middleware/internal-methods/middleware.d.cts.map +0 -1
  205. package/dist/internals/simulation/middleware/internal-methods/middleware.d.mts +0 -23
  206. package/dist/internals/simulation/middleware/internal-methods/middleware.d.mts.map +0 -1
  207. package/dist/internals/simulation/middleware/internal-methods/middleware.mjs +0 -40
  208. package/dist/internals/simulation/middleware/internal-methods/middleware.mjs.map +0 -1
  209. package/dist/internals/simulation/middleware/internal-methods/provider-state.cjs +0 -28
  210. package/dist/internals/simulation/middleware/internal-methods/provider-state.cjs.map +0 -1
  211. package/dist/internals/simulation/middleware/internal-methods/provider-state.d.cts +0 -16
  212. package/dist/internals/simulation/middleware/internal-methods/provider-state.d.cts.map +0 -1
  213. package/dist/internals/simulation/middleware/internal-methods/provider-state.d.mts +0 -16
  214. package/dist/internals/simulation/middleware/internal-methods/provider-state.d.mts.map +0 -1
  215. package/dist/internals/simulation/middleware/internal-methods/provider-state.mjs +0 -24
  216. package/dist/internals/simulation/middleware/internal-methods/provider-state.mjs.map +0 -1
  217. package/dist/internals/simulation/middleware/mock.cjs +0 -22
  218. package/dist/internals/simulation/middleware/mock.cjs.map +0 -1
  219. package/dist/internals/simulation/middleware/mock.d.cts +0 -11
  220. package/dist/internals/simulation/middleware/mock.d.cts.map +0 -1
  221. package/dist/internals/simulation/middleware/mock.d.mts +0 -11
  222. package/dist/internals/simulation/middleware/mock.d.mts.map +0 -1
  223. package/dist/internals/simulation/middleware/mock.mjs +0 -18
  224. package/dist/internals/simulation/middleware/mock.mjs.map +0 -1
  225. package/dist/internals/simulation/options.cjs +0 -25
  226. package/dist/internals/simulation/options.cjs.map +0 -1
  227. package/dist/internals/simulation/options.d.cts +0 -40
  228. package/dist/internals/simulation/options.d.cts.map +0 -1
  229. package/dist/internals/simulation/options.d.mts +0 -40
  230. package/dist/internals/simulation/options.d.mts.map +0 -1
  231. package/dist/internals/simulation/options.mjs +0 -21
  232. package/dist/internals/simulation/options.mjs.map +0 -1
  233. package/dist/internals/simulation/simulation.cjs +0 -155
  234. package/dist/internals/simulation/simulation.cjs.map +0 -1
  235. package/dist/internals/simulation/simulation.d.cts +0 -103
  236. package/dist/internals/simulation/simulation.d.cts.map +0 -1
  237. package/dist/internals/simulation/simulation.d.mts +0 -103
  238. package/dist/internals/simulation/simulation.d.mts.map +0 -1
  239. package/dist/internals/simulation/simulation.mjs +0 -150
  240. package/dist/internals/simulation/simulation.mjs.map +0 -1
  241. package/dist/internals/simulation/store/index.cjs +0 -21
  242. package/dist/internals/simulation/store/index.cjs.map +0 -1
  243. package/dist/internals/simulation/store/index.d.cts +0 -5
  244. package/dist/internals/simulation/store/index.d.cts.map +0 -1
  245. package/dist/internals/simulation/store/index.d.mts +0 -5
  246. package/dist/internals/simulation/store/index.d.mts.map +0 -1
  247. package/dist/internals/simulation/store/index.mjs +0 -5
  248. package/dist/internals/simulation/store/index.mjs.map +0 -1
  249. package/dist/internals/simulation/store/mocks.cjs +0 -39
  250. package/dist/internals/simulation/store/mocks.cjs.map +0 -1
  251. package/dist/internals/simulation/store/mocks.d.cts +0 -36
  252. package/dist/internals/simulation/store/mocks.d.cts.map +0 -1
  253. package/dist/internals/simulation/store/mocks.d.mts +0 -36
  254. package/dist/internals/simulation/store/mocks.d.mts.map +0 -1
  255. package/dist/internals/simulation/store/mocks.mjs +0 -35
  256. package/dist/internals/simulation/store/mocks.mjs.map +0 -1
  257. package/dist/internals/simulation/store/notifications.cjs +0 -35
  258. package/dist/internals/simulation/store/notifications.cjs.map +0 -1
  259. package/dist/internals/simulation/store/notifications.d.cts +0 -45
  260. package/dist/internals/simulation/store/notifications.d.cts.map +0 -1
  261. package/dist/internals/simulation/store/notifications.d.mts +0 -45
  262. package/dist/internals/simulation/store/notifications.d.mts.map +0 -1
  263. package/dist/internals/simulation/store/notifications.mjs +0 -32
  264. package/dist/internals/simulation/store/notifications.mjs.map +0 -1
  265. package/dist/internals/simulation/store/state.cjs +0 -54
  266. package/dist/internals/simulation/store/state.cjs.map +0 -1
  267. package/dist/internals/simulation/store/state.d.cts +0 -56
  268. package/dist/internals/simulation/store/state.d.cts.map +0 -1
  269. package/dist/internals/simulation/store/state.d.mts +0 -56
  270. package/dist/internals/simulation/store/state.d.mts.map +0 -1
  271. package/dist/internals/simulation/store/state.mjs +0 -50
  272. package/dist/internals/simulation/store/state.mjs.map +0 -1
  273. package/dist/internals/simulation/store/store.cjs +0 -51
  274. package/dist/internals/simulation/store/store.cjs.map +0 -1
  275. package/dist/internals/simulation/store/store.d.cts +0 -22
  276. package/dist/internals/simulation/store/store.d.cts.map +0 -1
  277. package/dist/internals/simulation/store/store.d.mts +0 -22
  278. package/dist/internals/simulation/store/store.d.mts.map +0 -1
  279. package/dist/internals/simulation/store/store.mjs +0 -45
  280. package/dist/internals/simulation/store/store.mjs.map +0 -1
  281. package/dist/internals/simulation/store/ui.cjs +0 -24
  282. package/dist/internals/simulation/store/ui.cjs.map +0 -1
  283. package/dist/internals/simulation/store/ui.d.cts +0 -27
  284. package/dist/internals/simulation/store/ui.d.cts.map +0 -1
  285. package/dist/internals/simulation/store/ui.d.mts +0 -27
  286. package/dist/internals/simulation/store/ui.d.mts.map +0 -1
  287. package/dist/internals/simulation/store/ui.mjs +0 -21
  288. package/dist/internals/simulation/store/ui.mjs.map +0 -1
  289. package/dist/internals/structs.cjs +0 -157
  290. package/dist/internals/structs.cjs.map +0 -1
  291. package/dist/internals/structs.d.cts +0 -205
  292. package/dist/internals/structs.d.cts.map +0 -1
  293. package/dist/internals/structs.d.mts +0 -205
  294. package/dist/internals/structs.d.mts.map +0 -1
  295. package/dist/internals/structs.mjs +0 -154
  296. package/dist/internals/structs.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.mjs","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAA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C,CAAC;YAEnD,OAAO;gBACL,MAAM;oBACJ,GAAG,CAAC,gCAAgC,EAAE,IAAI,CAAC,CAAC;oBAE5C,KAAK,CAAC,QAAQ,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC5C,CAAC;aACF,CAAC;QACJ,CAAC;QAED,KAAK,EAAE,KAAK,IAAI,EAAE;YAChB,GAAG,CAAC,4BAA4B,CAAC,CAAC;YAClC,OAAO,CACL,uIAAuI,CACxI,CAAC;YAEF,MAAM,gBAAgB,CAAC,iBAAiB,EAAE,CAAC;QAC7C,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { AbstractExecutionService } from '@metamask/snaps-controllers';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { DialogType } from '@metamask/snaps-sdk';\nimport type { FooterElement } from '@metamask/snaps-sdk/jsx';\nimport { HandlerType, getJsxChildren, logInfo } from '@metamask/snaps-utils';\nimport { create } from '@metamask/superstruct';\nimport {\n assert,\n assertStruct,\n createModuleLogger,\n hasProperty,\n} from '@metamask/utils';\n\nimport {\n rootLogger,\n handleRequest,\n TransactionOptionsStruct,\n getEnvironment,\n JsonRpcMockOptionsStruct,\n SignatureOptionsStruct,\n SnapResponseWithInterfaceStruct,\n getElementByType,\n} from './internals';\nimport type { InstallSnapOptions } from './internals';\nimport {\n addJsonRpcMock,\n removeJsonRpcMock,\n} from './internals/simulation/store/mocks';\nimport type {\n SnapResponseWithInterface,\n CronjobOptions,\n JsonRpcMockOptions,\n Snap,\n SnapResponse,\n TransactionOptions,\n SnapInterface,\n SnapAlertInterface,\n SnapInterfaceActions,\n SnapConfirmationInterface,\n SnapPromptInterface,\n DefaultSnapInterface,\n DefaultSnapInterfaceWithFooter,\n DefaultSnapInterfaceWithPartialFooter,\n DefaultSnapInterfaceWithoutFooter,\n} from './types';\n\nconst log = createModuleLogger(rootLogger, 'helpers');\n\n/**\n * Get the options for {@link installSnap}.\n *\n * @param snapId - The ID of the Snap, or the options.\n * @param options - The options, if any.\n * @returns The options.\n */\nfunction getOptions<\n Service extends new (...args: any[]) => InstanceType<\n typeof AbstractExecutionService\n >,\n>(\n snapId: SnapId | Partial<InstallSnapOptions<Service>> | undefined,\n options: Partial<InstallSnapOptions<Service>>,\n): [SnapId | undefined, Partial<InstallSnapOptions<Service>>] {\n if (typeof snapId === 'object') {\n return [undefined, snapId];\n }\n\n return [snapId, options];\n}\n\n/**\n * Ensure that the actual response contains `getInterface`.\n *\n * @param response - The response of the handler.\n */\nfunction assertIsResponseWithInterface(\n response: SnapResponse,\n): asserts response is SnapResponseWithInterface {\n assertStruct(response, SnapResponseWithInterfaceStruct);\n}\n\n/**\n * Ensure that the actual interface is an alert dialog.\n *\n * @param ui - The interface to verify.\n */\nexport function assertIsAlertDialog(\n ui: SnapInterface,\n): asserts ui is SnapAlertInterface & SnapInterfaceActions {\n assert(hasProperty(ui, 'type') && ui.type === DialogType.Alert);\n}\n\n/**\n * Ensure that the actual interface is a confirmation dialog.\n *\n * @param ui - The interface to verify.\n */\nexport function assertIsConfirmationDialog(\n ui: SnapInterface,\n): asserts ui is SnapConfirmationInterface & SnapInterfaceActions {\n assert(hasProperty(ui, 'type') && ui.type === DialogType.Confirmation);\n}\n\n/**\n * Ensure that the actual interface is a Prompt dialog.\n *\n * @param ui - The interface to verify.\n */\nexport function assertIsPromptDialog(\n ui: SnapInterface,\n): asserts ui is SnapPromptInterface & SnapInterfaceActions {\n assert(hasProperty(ui, 'type') && ui.type === DialogType.Prompt);\n}\n\n/**\n * Ensure that the actual interface is a custom dialog.\n *\n * @param ui - The interface to verify.\n */\nexport function assertIsCustomDialog(\n ui: SnapInterface,\n): asserts ui is DefaultSnapInterface & SnapInterfaceActions {\n assert(!hasProperty(ui, 'type'));\n}\n\n/**\n * Ensure that the actual interface is a custom dialog with a complete footer.\n *\n * @param ui - The interface to verify.\n */\nexport function assertCustomDialogHasFooter(\n ui: DefaultSnapInterface & SnapInterfaceActions,\n): asserts ui is DefaultSnapInterfaceWithFooter & SnapInterfaceActions {\n const footer = getElementByType<FooterElement>(ui.content, 'Footer');\n\n assert(footer && getJsxChildren(footer).length === 2);\n}\n\n/**\n * Ensure that the actual interface is a custom dialog with a partial footer.\n *\n * @param ui - The interface to verify.\n */\nexport function assertCustomDialogHasPartialFooter(\n ui: DefaultSnapInterface & SnapInterfaceActions,\n): asserts ui is DefaultSnapInterfaceWithPartialFooter & SnapInterfaceActions {\n const footer = getElementByType<FooterElement>(ui.content, 'Footer');\n\n assert(footer && getJsxChildren(footer).length === 1);\n}\n\n/**\n * Ensure that the actual interface is a custom dialog without a footer.\n *\n * @param ui - The interface to verify.\n */\nexport function assertCustomDialogHasNoFooter(\n ui: DefaultSnapInterface & SnapInterfaceActions,\n): asserts ui is DefaultSnapInterfaceWithoutFooter & SnapInterfaceActions {\n const footer = getElementByType<FooterElement>(ui.content, 'Footer');\n\n assert(!footer);\n}\n\n/**\n * Load a snap into the environment. This is the main entry point for testing\n * snaps: It returns a {@link Snap} object that can be used to interact with the\n * snap.\n *\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * describe('My Snap', () => {\n * it('should do something', async () => {\n * const { request } = await installSnap('local:my-snap');\n * const response = await request({\n * method: 'foo',\n * params: ['bar'],\n * });\n * expect(response).toRespondWith('bar');\n * });\n * });\n * @returns The snap.\n * @throws If the built-in server is not running, and no snap ID is provided.\n */\nexport async function installSnap(): Promise<Snap>;\n\n/**\n * Load a snap into the environment. This is the main entry point for testing\n * snaps: It returns a {@link Snap} object that can be used to interact with the\n * snap.\n *\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * describe('My Snap', () => {\n * it('should do something', async () => {\n * const { request } = await installSnap('local:my-snap');\n * const response = await request({\n * method: 'foo',\n * params: ['bar'],\n * });\n * expect(response).toRespondWith('bar');\n * });\n * });\n * @param options - The options to use.\n * @param options.executionService - The execution service to use. Defaults to\n * {@link NodeThreadExecutionService}. You do not need to provide this unless\n * you are testing a custom execution service.\n * @param options.executionServiceOptions - The options to use when creating the\n * execution service, if any. This should only include options specific to the\n * provided execution service.\n * @param options.options - The simulation options.\n * @returns The snap.\n * @throws If the built-in server is not running, and no snap ID is provided.\n */\nexport async function installSnap<\n Service extends new (...args: any[]) => InstanceType<\n typeof AbstractExecutionService\n >,\n>(options: Partial<InstallSnapOptions<Service>>): Promise<Snap>;\n\n/**\n * Load a snap into the environment. This is the main entry point for testing\n * snaps: It returns a {@link Snap} object that can be used to interact with the\n * snap.\n *\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * describe('My Snap', () => {\n * it('should do something', async () => {\n * const { request } = await installSnap('local:my-snap');\n * const response = await request({\n * method: 'foo',\n * params: ['bar'],\n * });\n * expect(response).toRespondWith('bar');\n * });\n * });\n * @param snapId - The ID of the snap, including the prefix (`local:`). Defaults\n * to the URL of the built-in server, if it is running. This supports both\n * local snap IDs and NPM snap IDs.\n * @param options - The options to use.\n * @param options.executionService - The execution service to use. Defaults to\n * {@link NodeThreadExecutionService}. You do not need to provide this unless\n * you are testing a custom execution service.\n * @param options.executionServiceOptions - The options to use when creating the\n * execution service, if any. This should only include options specific to the\n * provided execution service.\n * @param options.options - The simulation options.\n * @returns The snap.\n * @throws If the built-in server is not running, and no snap ID is provided.\n */\nexport async function installSnap<\n Service extends new (...args: any[]) => InstanceType<\n typeof AbstractExecutionService\n >,\n>(\n snapId: SnapId,\n options?: Partial<InstallSnapOptions<Service>>,\n): Promise<Snap>;\n\n/**\n * Load a snap into the environment. This is the main entry point for testing\n * snaps: It returns a {@link Snap} object that can be used to interact with the\n * snap.\n *\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * describe('My Snap', () => {\n * it('should do something', async () => {\n * const { request } = await installSnap('local:my-snap');\n * const response = await request({\n * method: 'foo',\n * params: ['bar'],\n * });\n * expect(response).toRespondWith('bar');\n * });\n * });\n * @param snapId - The ID of the snap, including the prefix (`local:`). Defaults\n * to the URL of the built-in server, if it is running. This supports both\n * local snap IDs and NPM snap IDs.\n * @param options - The options to use.\n * @param options.executionService - The execution service to use. Defaults to\n * {@link NodeThreadExecutionService}. You do not need to provide this unless\n * you are testing a custom execution service.\n * @param options.executionServiceOptions - The options to use when creating the\n * execution service, if any. This should only include options specific to the\n * provided execution service.\n * @param options.options - The simulation options.\n * @returns The snap.\n * @throws If the built-in server is not running, and no snap ID is provided.\n */\nexport async function installSnap<\n Service extends new (...args: any[]) => InstanceType<\n typeof AbstractExecutionService\n >,\n>(\n snapId?: SnapId | Partial<InstallSnapOptions<Service>>,\n options: Partial<InstallSnapOptions<Service>> = {},\n): Promise<Snap> {\n const resolvedOptions = getOptions(snapId, options);\n const {\n snapId: installedSnapId,\n store,\n executionService,\n runSaga,\n controllerMessenger,\n } = await getEnvironment().installSnap(...resolvedOptions);\n\n const onTransaction = async (\n request: TransactionOptions,\n ): Promise<SnapResponseWithInterface> => {\n log('Sending transaction %o.', request);\n\n const {\n origin: transactionOrigin,\n chainId,\n ...transaction\n } = create(request, TransactionOptionsStruct);\n\n const response = await handleRequest({\n snapId: installedSnapId,\n store,\n executionService,\n runSaga,\n controllerMessenger,\n handler: HandlerType.OnTransaction,\n request: {\n method: '',\n params: {\n chainId,\n transaction,\n transactionOrigin,\n },\n },\n });\n\n assertIsResponseWithInterface(response);\n\n return response;\n };\n\n const onCronjob = (request: CronjobOptions) => {\n log('Running cronjob %o.', options);\n\n return handleRequest({\n snapId: installedSnapId,\n store,\n executionService,\n controllerMessenger,\n runSaga,\n handler: HandlerType.OnCronjob,\n request,\n });\n };\n\n return {\n request: (request) => {\n log('Sending request %o.', request);\n\n return handleRequest({\n snapId: installedSnapId,\n store,\n executionService,\n controllerMessenger,\n runSaga,\n handler: HandlerType.OnRpcRequest,\n request,\n });\n },\n\n onTransaction,\n sendTransaction: onTransaction,\n\n onSignature: async (\n request: unknown,\n ): Promise<SnapResponseWithInterface> => {\n log('Requesting signature %o.', request);\n\n const { origin: signatureOrigin, ...signature } = create(\n request,\n SignatureOptionsStruct,\n );\n\n const response = await handleRequest({\n snapId: installedSnapId,\n store,\n executionService,\n controllerMessenger,\n runSaga,\n handler: HandlerType.OnSignature,\n request: {\n method: '',\n params: {\n signature,\n signatureOrigin,\n },\n },\n });\n\n assertIsResponseWithInterface(response);\n\n return response;\n },\n\n onCronjob,\n runCronjob: onCronjob,\n\n onHomePage: async (): Promise<SnapResponseWithInterface> => {\n log('Rendering home page.');\n\n const response = await handleRequest({\n snapId: installedSnapId,\n store,\n executionService,\n controllerMessenger,\n runSaga,\n handler: HandlerType.OnHomePage,\n request: {\n method: '',\n },\n });\n\n assertIsResponseWithInterface(response);\n\n return response;\n },\n\n mockJsonRpc(mock: JsonRpcMockOptions) {\n log('Mocking JSON-RPC request %o.', mock);\n\n const { method, result } = create(mock, JsonRpcMockOptionsStruct);\n store.dispatch(addJsonRpcMock({ method, result }));\n\n return {\n unmock() {\n log('Unmocking JSON-RPC request %o.', mock);\n\n store.dispatch(removeJsonRpcMock(method));\n },\n };\n },\n\n close: async () => {\n log('Closing execution service.');\n logInfo(\n 'Calling `snap.close()` is deprecated, and will be removed in a future release. Snaps are now automatically closed when the test ends.',\n );\n\n await executionService.terminateAllSnaps();\n },\n };\n}\n"]}
1
+ {"version":3,"file":"helpers.mjs","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,aAAa,EACb,wBAAwB,EACxB,cAAc,EACd,iBAAiB,EACjB,+BAA+B,EAChC,mCAAmC;AACpC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,8BAA8B;AAC7D,OAAO,EAAE,MAAM,EAAE,8BAA8B;AAC/C,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,wBAAwB;AAEnE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,8BAAoB;AAUzD,MAAM,GAAG,GAAG,kBAAkB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;AAEtD;;;;;;GAMG;AACH,SAAS,UAAU,CA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U,EAAE,KAAK,IAAwC,EAAE;YACzD,GAAG,CAAC,sBAAsB,CAAC,CAAC;YAE5B,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC;gBACnC,MAAM,EAAE,eAAe;gBACvB,KAAK;gBACL,gBAAgB;gBAChB,mBAAmB;gBACnB,OAAO;gBACP,OAAO,EAAE,WAAW,CAAC,UAAU;gBAC/B,OAAO,EAAE;oBACP,MAAM,EAAE,EAAE;iBACX;aACF,CAAC,CAAC;YAEH,6BAA6B,CAAC,QAAQ,CAAC,CAAC;YAExC,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,WAAW,CAAC,IAAwB;YAClC,GAAG,CAAC,8BAA8B,EAAE,IAAI,CAAC,CAAC;YAE1C,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE,wBAAwB,CAAC,CAAC;YAClE,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;YAEnD,OAAO;gBACL,MAAM;oBACJ,GAAG,CAAC,gCAAgC,EAAE,IAAI,CAAC,CAAC;oBAE5C,KAAK,CAAC,QAAQ,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC5C,CAAC;aACF,CAAC;QACJ,CAAC;QAED,KAAK,EAAE,KAAK,IAAI,EAAE;YAChB,GAAG,CAAC,4BAA4B,CAAC,CAAC;YAClC,OAAO,CACL,uIAAuI,CACxI,CAAC;YAEF,MAAM,gBAAgB,CAAC,iBAAiB,EAAE,CAAC;QAC7C,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { AbstractExecutionService } from '@metamask/snaps-controllers';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport type { InstallSnapOptions } from '@metamask/snaps-simulation';\nimport {\n JsonRpcMockOptionsStruct,\n SignatureOptionsStruct,\n handleRequest,\n TransactionOptionsStruct,\n addJsonRpcMock,\n removeJsonRpcMock,\n SnapResponseWithInterfaceStruct,\n} from '@metamask/snaps-simulation';\nimport { HandlerType, logInfo } from '@metamask/snaps-utils';\nimport { create } from '@metamask/superstruct';\nimport { assertStruct, createModuleLogger } from '@metamask/utils';\n\nimport { rootLogger, getEnvironment } from './internals';\nimport type {\n SnapResponseWithInterface,\n CronjobOptions,\n JsonRpcMockOptions,\n Snap,\n SnapResponse,\n TransactionOptions,\n} from './types';\n\nconst log = createModuleLogger(rootLogger, 'helpers');\n\n/**\n * Get the options for {@link installSnap}.\n *\n * @param snapId - The ID of the Snap, or the options.\n * @param options - The options, if any.\n * @returns The options.\n */\nfunction getOptions<\n Service extends new (...args: any[]) => InstanceType<\n typeof AbstractExecutionService\n >,\n>(\n snapId: SnapId | Partial<InstallSnapOptions<Service>> | undefined,\n options: Partial<InstallSnapOptions<Service>>,\n): [SnapId | undefined, Partial<InstallSnapOptions<Service>>] {\n if (typeof snapId === 'object') {\n return [undefined, snapId];\n }\n\n return [snapId, options];\n}\n\n/**\n * Ensure that the actual response contains `getInterface`.\n *\n * @param response - The response of the handler.\n */\nfunction assertIsResponseWithInterface(\n response: SnapResponse,\n): asserts response is SnapResponseWithInterface {\n assertStruct(response, SnapResponseWithInterfaceStruct);\n}\n\n/**\n * Load a snap into the environment. This is the main entry point for testing\n * snaps: It returns a {@link Snap} object that can be used to interact with the\n * snap.\n *\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * describe('My Snap', () => {\n * it('should do something', async () => {\n * const { request } = await installSnap('local:my-snap');\n * const response = await request({\n * method: 'foo',\n * params: ['bar'],\n * });\n * expect(response).toRespondWith('bar');\n * });\n * });\n * @returns The snap.\n * @throws If the built-in server is not running, and no snap ID is provided.\n */\nexport async function installSnap(): Promise<Snap>;\n\n/**\n * Load a snap into the environment. This is the main entry point for testing\n * snaps: It returns a {@link Snap} object that can be used to interact with the\n * snap.\n *\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * describe('My Snap', () => {\n * it('should do something', async () => {\n * const { request } = await installSnap('local:my-snap');\n * const response = await request({\n * method: 'foo',\n * params: ['bar'],\n * });\n * expect(response).toRespondWith('bar');\n * });\n * });\n * @param options - The options to use.\n * @param options.executionService - The execution service to use. Defaults to\n * {@link NodeThreadExecutionService}. You do not need to provide this unless\n * you are testing a custom execution service.\n * @param options.executionServiceOptions - The options to use when creating the\n * execution service, if any. This should only include options specific to the\n * provided execution service.\n * @param options.options - The simulation options.\n * @returns The snap.\n * @throws If the built-in server is not running, and no snap ID is provided.\n */\nexport async function installSnap<\n Service extends new (...args: any[]) => InstanceType<\n typeof AbstractExecutionService\n >,\n>(options: Partial<InstallSnapOptions<Service>>): Promise<Snap>;\n\n/**\n * Load a snap into the environment. This is the main entry point for testing\n * snaps: It returns a {@link Snap} object that can be used to interact with the\n * snap.\n *\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * describe('My Snap', () => {\n * it('should do something', async () => {\n * const { request } = await installSnap('local:my-snap');\n * const response = await request({\n * method: 'foo',\n * params: ['bar'],\n * });\n * expect(response).toRespondWith('bar');\n * });\n * });\n * @param snapId - The ID of the snap, including the prefix (`local:`). Defaults\n * to the URL of the built-in server, if it is running. This supports both\n * local snap IDs and NPM snap IDs.\n * @param options - The options to use.\n * @param options.executionService - The execution service to use. Defaults to\n * {@link NodeThreadExecutionService}. You do not need to provide this unless\n * you are testing a custom execution service.\n * @param options.executionServiceOptions - The options to use when creating the\n * execution service, if any. This should only include options specific to the\n * provided execution service.\n * @param options.options - The simulation options.\n * @returns The snap.\n * @throws If the built-in server is not running, and no snap ID is provided.\n */\nexport async function installSnap<\n Service extends new (...args: any[]) => InstanceType<\n typeof AbstractExecutionService\n >,\n>(\n snapId: SnapId,\n options?: Partial<InstallSnapOptions<Service>>,\n): Promise<Snap>;\n\n/**\n * Load a snap into the environment. This is the main entry point for testing\n * snaps: It returns a {@link Snap} object that can be used to interact with the\n * snap.\n *\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * describe('My Snap', () => {\n * it('should do something', async () => {\n * const { request } = await installSnap('local:my-snap');\n * const response = await request({\n * method: 'foo',\n * params: ['bar'],\n * });\n * expect(response).toRespondWith('bar');\n * });\n * });\n * @param snapId - The ID of the snap, including the prefix (`local:`). Defaults\n * to the URL of the built-in server, if it is running. This supports both\n * local snap IDs and NPM snap IDs.\n * @param options - The options to use.\n * @param options.executionService - The execution service to use. Defaults to\n * {@link NodeThreadExecutionService}. You do not need to provide this unless\n * you are testing a custom execution service.\n * @param options.executionServiceOptions - The options to use when creating the\n * execution service, if any. This should only include options specific to the\n * provided execution service.\n * @param options.options - The simulation options.\n * @returns The snap.\n * @throws If the built-in server is not running, and no snap ID is provided.\n */\nexport async function installSnap<\n Service extends new (...args: any[]) => InstanceType<\n typeof AbstractExecutionService\n >,\n>(\n snapId?: SnapId | Partial<InstallSnapOptions<Service>>,\n options: Partial<InstallSnapOptions<Service>> = {},\n): Promise<Snap> {\n const resolvedOptions = getOptions(snapId, options);\n const {\n snapId: installedSnapId,\n store,\n executionService,\n runSaga,\n controllerMessenger,\n } = await getEnvironment().installSnap(...resolvedOptions);\n\n const onTransaction = async (\n request: TransactionOptions,\n ): Promise<SnapResponseWithInterface> => {\n log('Sending transaction %o.', request);\n\n const {\n origin: transactionOrigin,\n chainId,\n ...transaction\n } = create(request, TransactionOptionsStruct);\n\n const response = await handleRequest({\n snapId: installedSnapId,\n store,\n executionService,\n runSaga,\n controllerMessenger,\n handler: HandlerType.OnTransaction,\n request: {\n method: '',\n params: {\n chainId,\n transaction,\n transactionOrigin,\n },\n },\n });\n\n assertIsResponseWithInterface(response);\n\n return response;\n };\n\n const onCronjob = (request: CronjobOptions) => {\n log('Running cronjob %o.', options);\n\n return handleRequest({\n snapId: installedSnapId,\n store,\n executionService,\n controllerMessenger,\n runSaga,\n handler: HandlerType.OnCronjob,\n request,\n });\n };\n\n return {\n request: (request) => {\n log('Sending request %o.', request);\n\n return handleRequest({\n snapId: installedSnapId,\n store,\n executionService,\n controllerMessenger,\n runSaga,\n handler: HandlerType.OnRpcRequest,\n request,\n });\n },\n\n onTransaction,\n sendTransaction: onTransaction,\n\n onSignature: async (\n request: unknown,\n ): Promise<SnapResponseWithInterface> => {\n log('Requesting signature %o.', request);\n\n const { origin: signatureOrigin, ...signature } = create(\n request,\n SignatureOptionsStruct,\n );\n\n const response = await handleRequest({\n snapId: installedSnapId,\n store,\n executionService,\n controllerMessenger,\n runSaga,\n handler: HandlerType.OnSignature,\n request: {\n method: '',\n params: {\n signature,\n signatureOrigin,\n },\n },\n });\n\n assertIsResponseWithInterface(response);\n\n return response;\n },\n\n onCronjob,\n runCronjob: onCronjob,\n\n onHomePage: async (): Promise<SnapResponseWithInterface> => {\n log('Rendering home page.');\n\n const response = await handleRequest({\n snapId: installedSnapId,\n store,\n executionService,\n controllerMessenger,\n runSaga,\n handler: HandlerType.OnHomePage,\n request: {\n method: '',\n },\n });\n\n assertIsResponseWithInterface(response);\n\n return response;\n },\n\n mockJsonRpc(mock: JsonRpcMockOptions) {\n log('Mocking JSON-RPC request %o.', mock);\n\n const { method, result } = create(mock, JsonRpcMockOptionsStruct);\n store.dispatch(addJsonRpcMock({ method, result }));\n\n return {\n unmock() {\n log('Unmocking JSON-RPC request %o.', mock);\n\n store.dispatch(removeJsonRpcMock(method));\n },\n };\n },\n\n close: async () => {\n log('Closing execution service.');\n logInfo(\n 'Calling `snap.close()` is deprecated, and will be removed in a future release. Snaps are now automatically closed when the test ends.',\n );\n\n await executionService.terminateAllSnaps();\n },\n };\n}\n"]}
package/dist/index.cjs CHANGED
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.TestEnvironment = exports.default = void 0;
20
+ exports.assertIsPromptDialog = exports.assertIsCustomDialog = exports.assertIsConfirmationDialog = exports.assertIsAlertDialog = exports.assertCustomDialogHasPartialFooter = exports.assertCustomDialogHasNoFooter = exports.TestEnvironment = exports.default = void 0;
21
21
  // eslint-disable-next-line import/no-unassigned-import
22
22
  require("./global.cjs");
23
23
  var environment_1 = require("./environment.cjs");
@@ -26,4 +26,11 @@ Object.defineProperty(exports, "TestEnvironment", { enumerable: true, get: funct
26
26
  __exportStar(require("./helpers.cjs"), exports);
27
27
  __exportStar(require("./options.cjs"), exports);
28
28
  __exportStar(require("./types/index.cjs"), exports);
29
+ var snaps_simulation_1 = require("@metamask/snaps-simulation");
30
+ Object.defineProperty(exports, "assertCustomDialogHasNoFooter", { enumerable: true, get: function () { return snaps_simulation_1.assertCustomDialogHasNoFooter; } });
31
+ Object.defineProperty(exports, "assertCustomDialogHasPartialFooter", { enumerable: true, get: function () { return snaps_simulation_1.assertCustomDialogHasPartialFooter; } });
32
+ Object.defineProperty(exports, "assertIsAlertDialog", { enumerable: true, get: function () { return snaps_simulation_1.assertIsAlertDialog; } });
33
+ Object.defineProperty(exports, "assertIsConfirmationDialog", { enumerable: true, get: function () { return snaps_simulation_1.assertIsConfirmationDialog; } });
34
+ Object.defineProperty(exports, "assertIsCustomDialog", { enumerable: true, get: function () { return snaps_simulation_1.assertIsCustomDialog; } });
35
+ Object.defineProperty(exports, "assertIsPromptDialog", { enumerable: true, get: function () { return snaps_simulation_1.assertIsPromptDialog; } });
29
36
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,wBAAkB;AAElB,iDAAoE;AAA3D,uHAAA,OAAO,OAAA;AAAE,+HAAA,OAAO,OAAmB;AAC5C,gDAA0B;AAC1B,gDAA0B;AAC1B,oDAAwB","sourcesContent":["// eslint-disable-next-line import/no-unassigned-import\nimport './global';\n\nexport { default, default as TestEnvironment } from './environment';\nexport * from './helpers';\nexport * from './options';\nexport * from './types';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,wBAAkB;AAElB,iDAAoE;AAA3D,uHAAA,OAAO,OAAA;AAAE,+HAAA,OAAO,OAAmB;AAC5C,gDAA0B;AAC1B,gDAA0B;AAC1B,oDAAwB;AAExB,+DAOoC;AANlC,iIAAA,6BAA6B,OAAA;AAC7B,sIAAA,kCAAkC,OAAA;AAClC,uHAAA,mBAAmB,OAAA;AACnB,8HAAA,0BAA0B,OAAA;AAC1B,wHAAA,oBAAoB,OAAA;AACpB,wHAAA,oBAAoB,OAAA","sourcesContent":["// eslint-disable-next-line import/no-unassigned-import\nimport './global';\n\nexport { default, default as TestEnvironment } from './environment';\nexport * from './helpers';\nexport * from './options';\nexport * from './types';\n\nexport {\n assertCustomDialogHasNoFooter,\n assertCustomDialogHasPartialFooter,\n assertIsAlertDialog,\n assertIsConfirmationDialog,\n assertIsCustomDialog,\n assertIsPromptDialog,\n} from '@metamask/snaps-simulation';\n"]}
package/dist/index.d.cts CHANGED
@@ -3,4 +3,5 @@ export { default, default as TestEnvironment } from "./environment.cjs";
3
3
  export * from "./helpers.cjs";
4
4
  export * from "./options.cjs";
5
5
  export * from "./types/index.cjs";
6
+ export { assertCustomDialogHasNoFooter, assertCustomDialogHasPartialFooter, assertIsAlertDialog, assertIsConfirmationDialog, assertIsCustomDialog, assertIsPromptDialog, } from "@metamask/snaps-simulation";
6
7
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,sBAAkB;AAElB,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,0BAAsB;AACpE,8BAA0B;AAC1B,8BAA0B;AAC1B,kCAAwB"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,sBAAkB;AAElB,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,0BAAsB;AACpE,8BAA0B;AAC1B,8BAA0B;AAC1B,kCAAwB;AAExB,OAAO,EACL,6BAA6B,EAC7B,kCAAkC,EAClC,mBAAmB,EACnB,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,GACrB,mCAAmC"}
package/dist/index.d.mts CHANGED
@@ -3,4 +3,5 @@ export { default, default as TestEnvironment } from "./environment.mjs";
3
3
  export * from "./helpers.mjs";
4
4
  export * from "./options.mjs";
5
5
  export * from "./types/index.mjs";
6
+ export { assertCustomDialogHasNoFooter, assertCustomDialogHasPartialFooter, assertIsAlertDialog, assertIsConfirmationDialog, assertIsCustomDialog, assertIsPromptDialog, } from "@metamask/snaps-simulation";
6
7
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,sBAAkB;AAElB,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,0BAAsB;AACpE,8BAA0B;AAC1B,8BAA0B;AAC1B,kCAAwB"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,sBAAkB;AAElB,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,0BAAsB;AACpE,8BAA0B;AAC1B,8BAA0B;AAC1B,kCAAwB;AAExB,OAAO,EACL,6BAA6B,EAC7B,kCAAkC,EAClC,mBAAmB,EACnB,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,GACrB,mCAAmC"}
package/dist/index.mjs CHANGED
@@ -4,4 +4,5 @@ export { default, default as TestEnvironment } from "./environment.mjs";
4
4
  export * from "./helpers.mjs";
5
5
  export * from "./options.mjs";
6
6
  export * from "./types/index.mjs";
7
+ export { assertCustomDialogHasNoFooter, assertCustomDialogHasPartialFooter, assertIsAlertDialog, assertIsConfirmationDialog, assertIsCustomDialog, assertIsPromptDialog } from "@metamask/snaps-simulation";
7
8
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,sBAAkB;AAElB,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,0BAAsB;AACpE,8BAA0B;AAC1B,8BAA0B;AAC1B,kCAAwB","sourcesContent":["// eslint-disable-next-line import/no-unassigned-import\nimport './global';\n\nexport { default, default as TestEnvironment } from './environment';\nexport * from './helpers';\nexport * from './options';\nexport * from './types';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,sBAAkB;AAElB,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,0BAAsB;AACpE,8BAA0B;AAC1B,8BAA0B;AAC1B,kCAAwB;AAExB,OAAO,EACL,6BAA6B,EAC7B,kCAAkC,EAClC,mBAAmB,EACnB,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,EACrB,mCAAmC","sourcesContent":["// eslint-disable-next-line import/no-unassigned-import\nimport './global';\n\nexport { default, default as TestEnvironment } from './environment';\nexport * from './helpers';\nexport * from './options';\nexport * from './types';\n\nexport {\n assertCustomDialogHasNoFooter,\n assertCustomDialogHasPartialFooter,\n assertIsAlertDialog,\n assertIsConfirmationDialog,\n assertIsCustomDialog,\n assertIsPromptDialog,\n} from '@metamask/snaps-simulation';\n"]}
@@ -4,5 +4,5 @@
4
4
  *
5
5
  * @returns The Snaps environment.
6
6
  */
7
- export declare function getEnvironment(): import("..").default;
7
+ export declare function getEnvironment(): import("../index.cjs").default;
8
8
  //# sourceMappingURL=environment.d.cts.map
@@ -4,5 +4,5 @@
4
4
  *
5
5
  * @returns The Snaps environment.
6
6
  */
7
- export declare function getEnvironment(): import("..").default;
7
+ export declare function getEnvironment(): import("../index.mjs").default;
8
8
  //# sourceMappingURL=environment.d.mts.map
@@ -16,8 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./environment.cjs"), exports);
18
18
  __exportStar(require("./logger.cjs"), exports);
19
- __exportStar(require("./request.cjs"), exports);
20
19
  __exportStar(require("./server.cjs"), exports);
21
- __exportStar(require("./simulation/index.cjs"), exports);
22
- __exportStar(require("./structs.cjs"), exports);
23
20
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/internals/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAA8B;AAC9B,+CAAyB;AACzB,gDAA0B;AAC1B,+CAAyB;AACzB,yDAA6B;AAC7B,gDAA0B","sourcesContent":["export * from './environment';\nexport * from './logger';\nexport * from './request';\nexport * from './server';\nexport * from './simulation';\nexport * from './structs';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/internals/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAA8B;AAC9B,+CAAyB;AACzB,+CAAyB","sourcesContent":["export * from './environment';\nexport * from './logger';\nexport * from './server';\n"]}
@@ -1,7 +1,4 @@
1
1
  export * from "./environment.cjs";
2
2
  export * from "./logger.cjs";
3
- export * from "./request.cjs";
4
3
  export * from "./server.cjs";
5
- export * from "./simulation/index.cjs";
6
- export * from "./structs.cjs";
7
4
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/internals/index.ts"],"names":[],"mappings":"AAAA,kCAA8B;AAC9B,6BAAyB;AACzB,8BAA0B;AAC1B,6BAAyB;AACzB,uCAA6B;AAC7B,8BAA0B"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/internals/index.ts"],"names":[],"mappings":"AAAA,kCAA8B;AAC9B,6BAAyB;AACzB,6BAAyB"}
@@ -1,7 +1,4 @@
1
1
  export * from "./environment.mjs";
2
2
  export * from "./logger.mjs";
3
- export * from "./request.mjs";
4
3
  export * from "./server.mjs";
5
- export * from "./simulation/index.mjs";
6
- export * from "./structs.mjs";
7
4
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/internals/index.ts"],"names":[],"mappings":"AAAA,kCAA8B;AAC9B,6BAAyB;AACzB,8BAA0B;AAC1B,6BAAyB;AACzB,uCAA6B;AAC7B,8BAA0B"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/internals/index.ts"],"names":[],"mappings":"AAAA,kCAA8B;AAC9B,6BAAyB;AACzB,6BAAyB"}
@@ -1,7 +1,4 @@
1
1
  export * from "./environment.mjs";
2
2
  export * from "./logger.mjs";
3
- export * from "./request.mjs";
4
3
  export * from "./server.mjs";
5
- export * from "./simulation/index.mjs";
6
- export * from "./structs.mjs";
7
4
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/internals/index.ts"],"names":[],"mappings":"AAAA,kCAA8B;AAC9B,6BAAyB;AACzB,8BAA0B;AAC1B,6BAAyB;AACzB,uCAA6B;AAC7B,8BAA0B","sourcesContent":["export * from './environment';\nexport * from './logger';\nexport * from './request';\nexport * from './server';\nexport * from './simulation';\nexport * from './structs';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/internals/index.ts"],"names":[],"mappings":"AAAA,kCAA8B;AAC9B,6BAAyB;AACzB,6BAAyB","sourcesContent":["export * from './environment';\nexport * from './logger';\nexport * from './server';\n"]}
package/dist/matchers.cjs CHANGED
@@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.toRender = exports.toSendNotification = exports.toRespondWithError = exports.toRespondWith = void 0;
5
5
  const globals_1 = require("@jest/globals");
6
6
  const jsx_1 = require("@metamask/snaps-sdk/jsx");
7
+ const snaps_simulation_1 = require("@metamask/snaps-simulation");
7
8
  const snaps_utils_1 = require("@metamask/snaps-utils");
8
9
  const superstruct_1 = require("@metamask/superstruct");
9
10
  const utils_1 = require("@metamask/utils");
10
11
  const jest_matcher_utils_1 = require("jest-matcher-utils");
11
- const internals_1 = require("./internals/index.cjs");
12
12
  /**
13
13
  * Ensure that the actual value is a response from the `request` function.
14
14
  *
@@ -17,7 +17,7 @@ const internals_1 = require("./internals/index.cjs");
17
17
  * @param options - The matcher options.
18
18
  */
19
19
  function assertActualIsSnapResponse(actual, matcherName, options) {
20
- if (!(0, superstruct_1.is)(actual, internals_1.SnapResponseStruct)) {
20
+ if (!(0, superstruct_1.is)(actual, snaps_simulation_1.SnapResponseStruct)) {
21
21
  throw new Error((0, jest_matcher_utils_1.matcherErrorMessage)((0, jest_matcher_utils_1.matcherHint)(matcherName, undefined, undefined, options), `${(0, jest_matcher_utils_1.RECEIVED_COLOR)('received')} value must be a response from the \`request\` function`, (0, jest_matcher_utils_1.printWithType)('Received', actual, jest_matcher_utils_1.printReceived)));
22
22
  }
23
23
  }
@@ -30,7 +30,7 @@ function assertActualIsSnapResponse(actual, matcherName, options) {
30
30
  * @param options - The matcher options.
31
31
  */
32
32
  function assertHasInterface(actual, matcherName, options) {
33
- if (!(0, superstruct_1.is)(actual, internals_1.InterfaceStruct) || !actual.content) {
33
+ if (!(0, superstruct_1.is)(actual, snaps_simulation_1.InterfaceStruct) || !actual.content) {
34
34
  throw new Error((0, jest_matcher_utils_1.matcherErrorMessage)((0, jest_matcher_utils_1.matcherHint)(matcherName, undefined, undefined, options), `${(0, jest_matcher_utils_1.RECEIVED_COLOR)('received')} value must have a \`content\` property`, (0, jest_matcher_utils_1.printWithType)('Received', actual, jest_matcher_utils_1.printReceived)));
35
35
  }
36
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"matchers.cjs","sourceRoot":"","sources":["../src/matchers.ts"],"names":[],"mappings":";AAAA,oCAAoC;;;AAMp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nE,MAAM,UAAU,GAAG,IAAA,yBAAI,EACrB,IAAA,0BAAY,EAAC,QAAQ,CAAC,EACtB,IAAA,0BAAY,EAAC,OAAO,CAAC,CACZ,CAAC;IAEZ,MAAM,OAAO,GAAG,IAAI;QAClB,CAAC,CAAC,GAAG,EAAE,CACH,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,eAAe,CAAC,MAAM;YAChD,cAAc,IAAA,mCAAc,EAAC,IAAA,0BAAY,EAAC,QAAQ,CAAC,CAAC,MAAM;YAC1D,cAAc,IAAA,mCAAc,EAAC,IAAA,0BAAY,EAAC,OAAO,CAAC,CAAC,EAAE;YACrD,sBAAsB,UAAU,EAAE;QACtC,CAAC,CAAC,GAAG,EAAE,CACH,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,MAAM;YAC5C,cAAc,IAAA,mCAAc,EAAC,IAAA,0BAAY,EAAC,QAAQ,CAAC,CAAC,MAAM;YAC1D,cAAc,IAAA,mCAAc,EAAC,IAAA,0BAAY,EAAC,OAAO,CAAC,CAAC,EAAE;YACrD,sBAAsB,UAAU,EAAE,CAAC;IAEzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC,CAAC;AAhCS,QAAA,QAAQ,YAgCjB;AAEJ,gBAAM,CAAC,MAAM,CAAC;IACZ,aAAa,EAAb,qBAAa;IACb,kBAAkB,EAAlB,0BAAkB;IAClB,kBAAkB,EAAlB,0BAAkB;IAClB,QAAQ,EAAR,gBAAQ;CACT,CAAC,CAAC","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 ComponentOrElement,\n Component,\n} from '@metamask/snaps-sdk';\nimport type { JSXElement } from '@metamask/snaps-sdk/jsx';\nimport { isJSXElementUnsafe } from '@metamask/snaps-sdk/jsx';\nimport {\n getJsxElementFromComponent,\n serialiseJsx,\n} from '@metamask/snaps-utils';\nimport { is } from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\nimport { hasProperty } from '@metamask/utils';\nimport type { MatcherHintOptions } from 'jest-matcher-utils';\nimport {\n EXPECTED_COLOR,\n diff,\n matcherErrorMessage,\n matcherHint,\n printReceived,\n printWithType,\n RECEIVED_COLOR,\n} from 'jest-matcher-utils';\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: JSXElement } {\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> = 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\nconst toRenderLegacy: MatcherFunction<[expected: Component]> = function (\n actual,\n expected,\n) {\n assertHasInterface(actual, 'toRender');\n\n const { content } = actual;\n const expectedElement = getJsxElementFromComponent(expected);\n const pass = this.equals(content, expectedElement);\n\n // This is typed as `string | null`, but in practice it's always a string.\n // The function only returns `null` if both the expected and actual values\n // are numbers, bigints, or booleans, which is never the case here.\n const difference = diff(expectedElement, content) as string;\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRender')}\\n\\n` +\n `Expected:\\n${this.utils.printExpected(expectedElement)}\\n\\n` +\n `Received:\\n${this.utils.printReceived(content)}` +\n `\\n\\nDifference:\\n\\n${difference}`\n : () =>\n `${this.utils.matcherHint('.toRender')}\\n\\n` +\n `Expected:\\n${this.utils.printExpected(expectedElement)}\\n\\n` +\n `Received:\\n${this.utils.printReceived(content)}` +\n `\\n\\nDifference:\\n\\n${difference}`;\n\n return { message, pass };\n};\n\nexport const toRender: MatcherFunction<[expected: ComponentOrElement]> =\n function (actual, expected) {\n assertHasInterface(actual, 'toRender');\n\n if (!isJSXElementUnsafe(expected)) {\n return toRenderLegacy.call(this, actual, expected);\n }\n\n const { content } = actual;\n const pass = this.equals(content, expected);\n\n // This is typed as `string | null`, but in practice it's always a string.\n // The function only returns `null` if both the expected and actual values\n // are numbers, bigints, or booleans, which is never the case here.\n const difference = diff(\n serialiseJsx(expected),\n serialiseJsx(content),\n ) as string;\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRender')}\\n\\n` +\n `Expected:\\n${EXPECTED_COLOR(serialiseJsx(expected))}\\n\\n` +\n `Received:\\n${RECEIVED_COLOR(serialiseJsx(content))}` +\n `\\n\\nDifference:\\n\\n${difference}`\n : () =>\n `${this.utils.matcherHint('.toRender')}\\n\\n` +\n `Expected:\\n${EXPECTED_COLOR(serialiseJsx(expected))}\\n\\n` +\n `Received:\\n${RECEIVED_COLOR(serialiseJsx(content))}` +\n `\\n\\nDifference:\\n\\n${difference}`;\n\n return { message, pass };\n };\n\nexpect.extend({\n toRespondWith,\n toRespondWithError,\n toSendNotification,\n toRender,\n});\n"]}
1
+ {"version":3,"file":"matchers.cjs","sourceRoot":"","sources":["../src/matchers.ts"],"names":[],"mappings":";AAAA,oCAAoC;;;AAMpC,2CAAuC;AAQvC,iDAA6D;AAC7D,iEAGoC;AACpC,uDAG+B;AAC/B,uDAA2C;AAE3C,2CAA8C;AAE9C,2DAQ4B;AAI5B;;;;;;GAMG;AACH,SAAS,0BAA0B,CACjC,MAAe,EACf,WAAmB,EACnB,OAA4B;IAE5B,IAAI,CAAC,IAAA,gBAAE,EAAC,MAAM,EAAE,qCAAkB,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CACb,IAAA,wCAAmB,EACjB,IAAA,gCAAW,EAAC,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,EACvD,GAAG,IAAA,mCAAc,EACf,UAAU,CACX,yDAAyD,EAC1D,IAAA,kCAAa,EAAC,UAAU,EAAE,MAAM,EAAE,kCAAa,CAAC,CACjD,CACF,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,kBAAkB,CACzB,MAAe,EACf,WAAmB,EACnB,OAA4B;IAE5B,IAAI,CAAC,IAAA,gBAAE,EAAC,MAAM,EAAE,kCAAe,CAAC,IAAI,CAA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ACrD,sBAAsB,UAAU,EAAE,CAAC;IAEzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC,CAAC;AAhCS,QAAA,QAAQ,YAgCjB;AAEJ,gBAAM,CAAC,MAAM,CAAC;IACZ,aAAa,EAAb,qBAAa;IACb,kBAAkB,EAAlB,0BAAkB;IAClB,kBAAkB,EAAlB,0BAAkB;IAClB,QAAQ,EAAR,gBAAQ;CACT,CAAC,CAAC","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 ComponentOrElement,\n Component,\n} from '@metamask/snaps-sdk';\nimport type { JSXElement } from '@metamask/snaps-sdk/jsx';\nimport { isJSXElementUnsafe } from '@metamask/snaps-sdk/jsx';\nimport {\n InterfaceStruct,\n SnapResponseStruct,\n} from '@metamask/snaps-simulation';\nimport {\n getJsxElementFromComponent,\n serialiseJsx,\n} from '@metamask/snaps-utils';\nimport { is } from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\nimport { hasProperty } from '@metamask/utils';\nimport type { MatcherHintOptions } from 'jest-matcher-utils';\nimport {\n EXPECTED_COLOR,\n diff,\n matcherErrorMessage,\n matcherHint,\n printReceived,\n printWithType,\n RECEIVED_COLOR,\n} from 'jest-matcher-utils';\n\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: JSXElement } {\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> = 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\nconst toRenderLegacy: MatcherFunction<[expected: Component]> = function (\n actual,\n expected,\n) {\n assertHasInterface(actual, 'toRender');\n\n const { content } = actual;\n const expectedElement = getJsxElementFromComponent(expected);\n const pass = this.equals(content, expectedElement);\n\n // This is typed as `string | null`, but in practice it's always a string.\n // The function only returns `null` if both the expected and actual values\n // are numbers, bigints, or booleans, which is never the case here.\n const difference = diff(expectedElement, content) as string;\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRender')}\\n\\n` +\n `Expected:\\n${this.utils.printExpected(expectedElement)}\\n\\n` +\n `Received:\\n${this.utils.printReceived(content)}` +\n `\\n\\nDifference:\\n\\n${difference}`\n : () =>\n `${this.utils.matcherHint('.toRender')}\\n\\n` +\n `Expected:\\n${this.utils.printExpected(expectedElement)}\\n\\n` +\n `Received:\\n${this.utils.printReceived(content)}` +\n `\\n\\nDifference:\\n\\n${difference}`;\n\n return { message, pass };\n};\n\nexport const toRender: MatcherFunction<[expected: ComponentOrElement]> =\n function (actual, expected) {\n assertHasInterface(actual, 'toRender');\n\n if (!isJSXElementUnsafe(expected)) {\n return toRenderLegacy.call(this, actual, expected);\n }\n\n const { content } = actual;\n const pass = this.equals(content, expected);\n\n // This is typed as `string | null`, but in practice it's always a string.\n // The function only returns `null` if both the expected and actual values\n // are numbers, bigints, or booleans, which is never the case here.\n const difference = diff(\n serialiseJsx(expected),\n serialiseJsx(content),\n ) as string;\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRender')}\\n\\n` +\n `Expected:\\n${EXPECTED_COLOR(serialiseJsx(expected))}\\n\\n` +\n `Received:\\n${RECEIVED_COLOR(serialiseJsx(content))}` +\n `\\n\\nDifference:\\n\\n${difference}`\n : () =>\n `${this.utils.matcherHint('.toRender')}\\n\\n` +\n `Expected:\\n${EXPECTED_COLOR(serialiseJsx(expected))}\\n\\n` +\n `Received:\\n${RECEIVED_COLOR(serialiseJsx(content))}` +\n `\\n\\nDifference:\\n\\n${difference}`;\n\n return { message, pass };\n };\n\nexpect.extend({\n toRespondWith,\n toRespondWithError,\n toSendNotification,\n toRender,\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"matchers.d.cts","sourceRoot":"","sources":["../src/matchers.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB;AAEpD,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAE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1 @@
1
- {"version":3,"file":"matchers.d.mts","sourceRoot":"","sources":["../src/matchers.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB;AAEpD,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAEnB,4BAA4B;AAQ7B,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAiE5C;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,eAAe,CAAC,CAAC,QAAQ,EAAE,IAAI,CAAC,CA4B3D,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAAC,CAAC,QAAQ,EAAE,IAAI,CAAC,CA4BhE,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAC9C;IAAC,QAAQ,EAAE,MAAM;IAAE,IAAI,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,GAAG,SAAS;CAAC,CAwBrE,CAAC;AAgCF,eAAO,MAAM,QAAQ,EAAE,eAAe,CAAC,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAgClE,CAAC"}
1
+ {"version":3,"file":"matchers.d.mts","sourceRoot":"","sources":["../src/matchers.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB;AAEpD,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAEnB,4BAA4B;AAY7B,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAgE5C;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,eAAe,CAAC,CAAC,QAAQ,EAAE,IAAI,CAAC,CA4B3D,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAAC,CAAC,QAAQ,EAAE,IAAI,CAAC,CA4BhE,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAC9C;IAAC,QAAQ,EAAE,MAAM;IAAE,IAAI,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,GAAG,SAAS;CAAC,CAwBrE,CAAC;AAgCF,eAAO,MAAM,QAAQ,EAAE,eAAe,CAAC,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAgClE,CAAC"}
package/dist/matchers.mjs CHANGED
@@ -2,11 +2,11 @@
2
2
  import $jestglobals from "@jest/globals";
3
3
  const { expect } = $jestglobals;
4
4
  import { isJSXElementUnsafe } from "@metamask/snaps-sdk/jsx";
5
+ import { InterfaceStruct, SnapResponseStruct } from "@metamask/snaps-simulation";
5
6
  import { getJsxElementFromComponent, serialiseJsx } from "@metamask/snaps-utils";
6
7
  import { is } from "@metamask/superstruct";
7
8
  import { hasProperty } from "@metamask/utils";
8
9
  import { EXPECTED_COLOR, diff, matcherErrorMessage, matcherHint, printReceived, printWithType, RECEIVED_COLOR } from "jest-matcher-utils";
9
- import { InterfaceStruct, SnapResponseStruct } from "./internals/index.mjs";
10
10
  /**
11
11
  * Ensure that the actual value is a response from the `request` function.
12
12
  *
@@ -1 +1 @@
1
- {"version":3,"file":"matchers.mjs","sourceRoot":"","sources":["../src/matchers.ts"],"names":[],"mappings":"AAAA,oCAAoC;;;AAcpC,OAAO,EAAE,kBAAkB,EAAE,gCAAgC;AAC7D,OAAO,EACL,0BAA0B,EAC1B,YAAY,EACb,8BAA8B;AAC/B,OAAO,EAAE,EAAE,EAAE,8BAA8B;AAE3C,OAAO,EAAE,WAAW,EAAE,wBAAwB;AAE9C,OAAO,EACL,cAAc,EACd,IAAI,EACJ,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,aAAa,EACb,cAAc,EACf,2BAA2B;AAE5B,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,8BAAoB;AAGlE;;;;;;GAMG;AACH,SAAS,0BAA0B,CACjC,MAAe,EACf,WAAmB,EACnB,OAA4B;IAE5B,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAAE,CAAC;QACpC,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ACH,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,MAAM;YAC5C,cAAc,cAAc,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,MAAM;YAC1D,cAAc,cAAc,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,EAAE;YACrD,sBAAsB,UAAU,EAAE,CAAC;IAEzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC,CAAC;AAEJ,MAAM,CAAC,MAAM,CAAC;IACZ,aAAa;IACb,kBAAkB;IAClB,kBAAkB;IAClB,QAAQ;CACT,CAAC,CAAC","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 ComponentOrElement,\n Component,\n} from '@metamask/snaps-sdk';\nimport type { JSXElement } from '@metamask/snaps-sdk/jsx';\nimport { isJSXElementUnsafe } from '@metamask/snaps-sdk/jsx';\nimport {\n getJsxElementFromComponent,\n serialiseJsx,\n} from '@metamask/snaps-utils';\nimport { is } from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\nimport { hasProperty } from '@metamask/utils';\nimport type { MatcherHintOptions } from 'jest-matcher-utils';\nimport {\n EXPECTED_COLOR,\n diff,\n matcherErrorMessage,\n matcherHint,\n printReceived,\n printWithType,\n RECEIVED_COLOR,\n} from 'jest-matcher-utils';\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: JSXElement } {\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> = 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\nconst toRenderLegacy: MatcherFunction<[expected: Component]> = function (\n actual,\n expected,\n) {\n assertHasInterface(actual, 'toRender');\n\n const { content } = actual;\n const expectedElement = getJsxElementFromComponent(expected);\n const pass = this.equals(content, expectedElement);\n\n // This is typed as `string | null`, but in practice it's always a string.\n // The function only returns `null` if both the expected and actual values\n // are numbers, bigints, or booleans, which is never the case here.\n const difference = diff(expectedElement, content) as string;\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRender')}\\n\\n` +\n `Expected:\\n${this.utils.printExpected(expectedElement)}\\n\\n` +\n `Received:\\n${this.utils.printReceived(content)}` +\n `\\n\\nDifference:\\n\\n${difference}`\n : () =>\n `${this.utils.matcherHint('.toRender')}\\n\\n` +\n `Expected:\\n${this.utils.printExpected(expectedElement)}\\n\\n` +\n `Received:\\n${this.utils.printReceived(content)}` +\n `\\n\\nDifference:\\n\\n${difference}`;\n\n return { message, pass };\n};\n\nexport const toRender: MatcherFunction<[expected: ComponentOrElement]> =\n function (actual, expected) {\n assertHasInterface(actual, 'toRender');\n\n if (!isJSXElementUnsafe(expected)) {\n return toRenderLegacy.call(this, actual, expected);\n }\n\n const { content } = actual;\n const pass = this.equals(content, expected);\n\n // This is typed as `string | null`, but in practice it's always a string.\n // The function only returns `null` if both the expected and actual values\n // are numbers, bigints, or booleans, which is never the case here.\n const difference = diff(\n serialiseJsx(expected),\n serialiseJsx(content),\n ) as string;\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRender')}\\n\\n` +\n `Expected:\\n${EXPECTED_COLOR(serialiseJsx(expected))}\\n\\n` +\n `Received:\\n${RECEIVED_COLOR(serialiseJsx(content))}` +\n `\\n\\nDifference:\\n\\n${difference}`\n : () =>\n `${this.utils.matcherHint('.toRender')}\\n\\n` +\n `Expected:\\n${EXPECTED_COLOR(serialiseJsx(expected))}\\n\\n` +\n `Received:\\n${RECEIVED_COLOR(serialiseJsx(content))}` +\n `\\n\\nDifference:\\n\\n${difference}`;\n\n return { message, pass };\n };\n\nexpect.extend({\n toRespondWith,\n toRespondWithError,\n toSendNotification,\n toRender,\n});\n"]}
1
+ {"version":3,"file":"matchers.mjs","sourceRoot":"","sources":["../src/matchers.ts"],"names":[],"mappings":"AAAA,oCAAoC;;;AAcpC,OAAO,EAAE,kBAA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C;IAE5C,0EAA0E;IAC1E,0EAA0E;IAC1E,mEAAmE;IACnE,MAAM,UAAU,GAAG,IAAI,CACrB,YAAY,CAAC,QAAQ,CAAC,EACtB,YAAY,CAAC,OAAO,CAAC,CACZ,CAAC;IAEZ,MAAM,OAAO,GAAG,IAAI;QAClB,CAAC,CAAC,GAAG,EAAE,CACH,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,eAAe,CAAC,MAAM;YAChD,cAAc,cAAc,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,MAAM;YAC1D,cAAc,cAAc,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,EAAE;YACrD,sBAAsB,UAAU,EAAE;QACtC,CAAC,CAAC,GAAG,EAAE,CACH,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,MAAM;YAC5C,cAAc,cAAc,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,MAAM;YAC1D,cAAc,cAAc,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,EAAE;YACrD,sBAAsB,UAAU,EAAE,CAAC;IAEzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC,CAAC;AAEJ,MAAM,CAAC,MAAM,CAAC;IACZ,aAAa;IACb,kBAAkB;IAClB,kBAAkB;IAClB,QAAQ;CACT,CAAC,CAAC","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 ComponentOrElement,\n Component,\n} from '@metamask/snaps-sdk';\nimport type { JSXElement } from '@metamask/snaps-sdk/jsx';\nimport { isJSXElementUnsafe } from '@metamask/snaps-sdk/jsx';\nimport {\n InterfaceStruct,\n SnapResponseStruct,\n} from '@metamask/snaps-simulation';\nimport {\n getJsxElementFromComponent,\n serialiseJsx,\n} from '@metamask/snaps-utils';\nimport { is } from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\nimport { hasProperty } from '@metamask/utils';\nimport type { MatcherHintOptions } from 'jest-matcher-utils';\nimport {\n EXPECTED_COLOR,\n diff,\n matcherErrorMessage,\n matcherHint,\n printReceived,\n printWithType,\n RECEIVED_COLOR,\n} from 'jest-matcher-utils';\n\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: JSXElement } {\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> = 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\nconst toRenderLegacy: MatcherFunction<[expected: Component]> = function (\n actual,\n expected,\n) {\n assertHasInterface(actual, 'toRender');\n\n const { content } = actual;\n const expectedElement = getJsxElementFromComponent(expected);\n const pass = this.equals(content, expectedElement);\n\n // This is typed as `string | null`, but in practice it's always a string.\n // The function only returns `null` if both the expected and actual values\n // are numbers, bigints, or booleans, which is never the case here.\n const difference = diff(expectedElement, content) as string;\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRender')}\\n\\n` +\n `Expected:\\n${this.utils.printExpected(expectedElement)}\\n\\n` +\n `Received:\\n${this.utils.printReceived(content)}` +\n `\\n\\nDifference:\\n\\n${difference}`\n : () =>\n `${this.utils.matcherHint('.toRender')}\\n\\n` +\n `Expected:\\n${this.utils.printExpected(expectedElement)}\\n\\n` +\n `Received:\\n${this.utils.printReceived(content)}` +\n `\\n\\nDifference:\\n\\n${difference}`;\n\n return { message, pass };\n};\n\nexport const toRender: MatcherFunction<[expected: ComponentOrElement]> =\n function (actual, expected) {\n assertHasInterface(actual, 'toRender');\n\n if (!isJSXElementUnsafe(expected)) {\n return toRenderLegacy.call(this, actual, expected);\n }\n\n const { content } = actual;\n const pass = this.equals(content, expected);\n\n // This is typed as `string | null`, but in practice it's always a string.\n // The function only returns `null` if both the expected and actual values\n // are numbers, bigints, or booleans, which is never the case here.\n const difference = diff(\n serialiseJsx(expected),\n serialiseJsx(content),\n ) as string;\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRender')}\\n\\n` +\n `Expected:\\n${EXPECTED_COLOR(serialiseJsx(expected))}\\n\\n` +\n `Received:\\n${RECEIVED_COLOR(serialiseJsx(content))}` +\n `\\n\\nDifference:\\n\\n${difference}`\n : () =>\n `${this.utils.matcherHint('.toRender')}\\n\\n` +\n `Expected:\\n${EXPECTED_COLOR(serialiseJsx(expected))}\\n\\n` +\n `Received:\\n${RECEIVED_COLOR(serialiseJsx(content))}` +\n `\\n\\nDifference:\\n\\n${difference}`;\n\n return { message, pass };\n };\n\nexpect.extend({\n toRespondWith,\n toRespondWithError,\n toSendNotification,\n toRender,\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { NotificationType, EnumToUnion } from '@metamask/snaps-sdk';\nimport type { JSXElement } from '@metamask/snaps-sdk/jsx';\nimport type { InferMatching } from '@metamask/snaps-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport type { Json, JsonRpcId, JsonRpcParams } from '@metamask/utils';\n\nimport type {\n SignatureOptionsStruct,\n SnapOptionsStruct,\n SnapResponseStruct,\n TransactionOptionsStruct,\n} from '../internals';\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 signature requests.\n *\n * @property origin - The origin to send the signature request from. Defaults to\n * `metamask.io`.\n * @property from - The address to send the signature from. Defaults to a\n * randomly generated address.\n * @property data - The data to sign. Defaults to `0x`.\n * @property signatureMethod - The signature method.\n */\nexport type SignatureOptions = Infer<typeof SignatureOptionsStruct>;\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 * Options for uploading a file.\n *\n * @property fileName - The name of the file. By default, this is inferred from\n * the file path if it's a path, and defaults to an empty string if it's a\n * `Uint8Array`.\n * @property contentType - The content type of the file. By default, this is\n * inferred from the file name if it's a path, and defaults to\n * `application/octet-stream` if it's a `Uint8Array` or the content type cannot\n * be inferred from the file name.\n */\nexport type FileOptions = {\n fileName?: string;\n contentType?: string;\n};\n\nexport type SnapInterfaceActions = {\n /**\n * Click on an interface element.\n *\n * @param name - The element name to click.\n */\n clickElement(name: string): Promise<void>;\n\n /**\n * Type a value in a interface field.\n *\n * @param name - The element name to type in.\n * @param value - The value to type.\n */\n typeInField(name: string, value: string): Promise<void>;\n\n /**\n * Select an option with a value in a dropdown.\n *\n * @param name - The element name to type in.\n * @param value - The value to type.\n */\n selectInDropdown(name: string, value: string): Promise<void>;\n\n /**\n * Choose an option with a value from radio group.\n *\n * @param name - The element name to type in.\n * @param value - The value to type.\n */\n selectFromRadioGroup(name: string, value: string): Promise<void>;\n\n /**\n * Upload a file.\n *\n * @param name - The element name to upload the file to.\n * @param file - The file to upload. This can be a path to a file or a\n * `Uint8Array` containing the file contents. If this is a path, the file is\n * resolved relative to the current working directory.\n * @param options - The file options.\n * @param options.fileName - The name of the file. By default, this is\n * inferred from the file path if it's a path, and defaults to an empty string\n * if it's a `Uint8Array`.\n * @param options.contentType - The content type of the file. By default, this\n * is inferred from the file name if it's a path, and defaults to\n * `application/octet-stream` if it's a `Uint8Array` or the content type\n * cannot be inferred from the file name.\n */\n uploadFile(\n name: string,\n file: string | Uint8Array,\n options?: FileOptions,\n ): Promise<void>;\n};\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: JSXElement;\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: JSXElement;\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: JSXElement;\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\n/**\n * A `snap_dialog` default interface that has a Footer with two buttons defined.\n * The approval of this confirmation is handled by the snap.\n */\nexport type DefaultSnapInterfaceWithFooter = {\n /**\n * The content to show in the interface.\n */\n content: JSXElement;\n};\n\n/**\n * A `snap_dialog` default interface that has a Footer with one button defined.\n * A cancel button is automatically applied to the interface in this case.\n */\nexport type DefaultSnapInterfaceWithPartialFooter =\n DefaultSnapInterfaceWithFooter & {\n /**\n * Cancel the dialog.\n */\n cancel(): Promise<void>;\n };\n\n/**\n * A `snap_dialog` default interface that has no Footer defined.\n * A cancel and ok button is automatically applied to the interface in this case.\n */\nexport type DefaultSnapInterfaceWithoutFooter =\n DefaultSnapInterfaceWithPartialFooter & {\n /**\n * Close the dialog.\n *\n */\n ok(): Promise<void>;\n };\n\nexport type DefaultSnapInterface =\n | DefaultSnapInterfaceWithFooter\n | DefaultSnapInterfaceWithPartialFooter\n | DefaultSnapInterfaceWithoutFooter;\n\nexport type SnapInterface = (\n | SnapAlertInterface\n | SnapConfirmationInterface\n | SnapPromptInterface\n | DefaultSnapInterface\n) &\n SnapInterfaceActions;\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 * The options to use for mocking a JSON-RPC request.\n */\nexport type JsonRpcMockOptions = {\n /**\n * The JSON-RPC request method.\n */\n method: string;\n\n /**\n * The JSON-RPC response, which will be returned when a request with the\n * specified method is sent.\n */\n result: Json;\n};\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 * 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 */\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 onTransaction(\n transaction?: Partial<TransactionOptions>,\n ): Promise<SnapResponseWithInterface>;\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 * @deprecated Use {@link onTransaction} instead.\n */\n sendTransaction(\n transaction?: Partial<TransactionOptions>,\n ): Promise<SnapResponseWithInterface>;\n\n /**\n * Send a signature request to the snap.\n *\n * @param signature - The signature request object. Contains the params from\n * the various signature methods, but has an extra `origin` and `signatureMethod` field.\n * Any missing fields will be filled in with default values.\n * @returns The response.\n */\n onSignature(\n signature?: Partial<SignatureOptions>,\n ): Promise<SnapResponseWithInterface>;\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 onCronjob(cronjob?: Partial<CronjobOptions>): SnapRequest;\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 * @deprecated Use {@link onCronjob} instead.\n */\n runCronjob(cronjob: CronjobOptions): SnapRequest;\n\n /**\n * Get the response from the snap's `onHomePage` method.\n *\n * @returns The response.\n */\n onHomePage(): Promise<SnapResponseWithInterface>;\n\n /**\n * Mock a JSON-RPC request. This will cause the snap to respond with the\n * specified response when a request with the specified method is sent.\n *\n * @param mock - The mock options.\n * @param mock.method - The JSON-RPC request method.\n * @param mock.result - The JSON-RPC response, which will be returned when a\n * request with the specified method is sent.\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * // In the test\n * const snap = await installSnap();\n * snap.mockJsonRpc({ method: 'eth_accounts', result: ['0x1234'] });\n *\n * // In the Snap\n * const response =\n * await ethereum.request({ method: 'eth_accounts' }); // ['0x1234']\n */\n mockJsonRpc(mock: JsonRpcMockOptions): {\n /**\n * Remove the mock.\n */\n unmock(): void;\n };\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 * @deprecated Snaps are now automatically closed when the test ends. This\n * method will be removed in a future release.\n */\n close(): Promise<void>;\n};\n\nexport type SnapHandlerInterface = {\n content: JSXElement;\n} & SnapInterfaceActions;\n\nexport type SnapResponseWithInterface = {\n id: string;\n response: { result: Json } | { error: Json };\n notifications: {\n id: string;\n message: string;\n type: EnumToUnion<NotificationType>;\n }[];\n getInterface(): SnapHandlerInterface;\n};\n\nexport type SnapResponseWithoutInterface = Omit<\n SnapResponseWithInterface,\n 'getInterface'\n>;\n\nexport type SnapResponseType =\n | SnapResponseWithoutInterface\n | SnapResponseWithInterface;\n\nexport type SnapResponse = InferMatching<\n typeof SnapResponseStruct,\n SnapResponseType\n>;\n"]}
1
+ {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { NotificationType, EnumToUnion } from '@metamask/snaps-sdk';\nimport type { JSXElement } from '@metamask/snaps-sdk/jsx';\nimport type {\n SignatureOptionsStruct,\n SnapOptionsStruct,\n SnapResponseStruct,\n TransactionOptionsStruct,\n} from '@metamask/snaps-simulation';\nimport type { InferMatching } from '@metamask/snaps-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport type { Json, JsonRpcId, JsonRpcParams } from '@metamask/utils';\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 signature requests.\n *\n * @property origin - The origin to send the signature request from. Defaults to\n * `metamask.io`.\n * @property from - The address to send the signature from. Defaults to a\n * randomly generated address.\n * @property data - The data to sign. Defaults to `0x`.\n * @property signatureMethod - The signature method.\n */\nexport type SignatureOptions = Infer<typeof SignatureOptionsStruct>;\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 * Options for uploading a file.\n *\n * @property fileName - The name of the file. By default, this is inferred from\n * the file path if it's a path, and defaults to an empty string if it's a\n * `Uint8Array`.\n * @property contentType - The content type of the file. By default, this is\n * inferred from the file name if it's a path, and defaults to\n * `application/octet-stream` if it's a `Uint8Array` or the content type cannot\n * be inferred from the file name.\n */\nexport type FileOptions = {\n fileName?: string;\n contentType?: string;\n};\n\nexport type SnapInterfaceActions = {\n /**\n * Click on an interface element.\n *\n * @param name - The element name to click.\n */\n clickElement(name: string): Promise<void>;\n\n /**\n * Type a value in a interface field.\n *\n * @param name - The element name to type in.\n * @param value - The value to type.\n */\n typeInField(name: string, value: string): Promise<void>;\n\n /**\n * Select an option with a value in a dropdown.\n *\n * @param name - The element name to type in.\n * @param value - The value to type.\n */\n selectInDropdown(name: string, value: string): Promise<void>;\n\n /**\n * Choose an option with a value from radio group.\n *\n * @param name - The element name to type in.\n * @param value - The value to type.\n */\n selectFromRadioGroup(name: string, value: string): Promise<void>;\n\n /**\n * Choose an option with a value from Selector component.\n *\n * @param name - The element name to type in.\n * @param value - The value to type.\n */\n selectFromSelector(name: string, value: string): Promise<void>;\n\n /**\n * Upload a file.\n *\n * @param name - The element name to upload the file to.\n * @param file - The file to upload. This can be a path to a file or a\n * `Uint8Array` containing the file contents. If this is a path, the file is\n * resolved relative to the current working directory.\n * @param options - The file options.\n * @param options.fileName - The name of the file. By default, this is\n * inferred from the file path if it's a path, and defaults to an empty string\n * if it's a `Uint8Array`.\n * @param options.contentType - The content type of the file. By default, this\n * is inferred from the file name if it's a path, and defaults to\n * `application/octet-stream` if it's a `Uint8Array` or the content type\n * cannot be inferred from the file name.\n */\n uploadFile(\n name: string,\n file: string | Uint8Array,\n options?: FileOptions,\n ): Promise<void>;\n};\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: JSXElement;\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: JSXElement;\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: JSXElement;\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\n/**\n * A `snap_dialog` default interface that has a Footer with two buttons defined.\n * The approval of this confirmation is handled by the snap.\n */\nexport type DefaultSnapInterfaceWithFooter = {\n /**\n * The content to show in the interface.\n */\n content: JSXElement;\n};\n\n/**\n * A `snap_dialog` default interface that has a Footer with one button defined.\n * A cancel button is automatically applied to the interface in this case.\n */\nexport type DefaultSnapInterfaceWithPartialFooter =\n DefaultSnapInterfaceWithFooter & {\n /**\n * Cancel the dialog.\n */\n cancel(): Promise<void>;\n };\n\n/**\n * A `snap_dialog` default interface that has no Footer defined.\n * A cancel and ok button is automatically applied to the interface in this case.\n */\nexport type DefaultSnapInterfaceWithoutFooter =\n DefaultSnapInterfaceWithPartialFooter & {\n /**\n * Close the dialog.\n *\n */\n ok(): Promise<void>;\n };\n\nexport type DefaultSnapInterface =\n | DefaultSnapInterfaceWithFooter\n | DefaultSnapInterfaceWithPartialFooter\n | DefaultSnapInterfaceWithoutFooter;\n\nexport type SnapInterface = (\n | SnapAlertInterface\n | SnapConfirmationInterface\n | SnapPromptInterface\n | DefaultSnapInterface\n) &\n SnapInterfaceActions;\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 * The options to use for mocking a JSON-RPC request.\n */\nexport type JsonRpcMockOptions = {\n /**\n * The JSON-RPC request method.\n */\n method: string;\n\n /**\n * The JSON-RPC response, which will be returned when a request with the\n * specified method is sent.\n */\n result: Json;\n};\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 * 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 */\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 onTransaction(\n transaction?: Partial<TransactionOptions>,\n ): Promise<SnapResponseWithInterface>;\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 * @deprecated Use {@link onTransaction} instead.\n */\n sendTransaction(\n transaction?: Partial<TransactionOptions>,\n ): Promise<SnapResponseWithInterface>;\n\n /**\n * Send a signature request to the snap.\n *\n * @param signature - The signature request object. Contains the params from\n * the various signature methods, but has an extra `origin` and `signatureMethod` field.\n * Any missing fields will be filled in with default values.\n * @returns The response.\n */\n onSignature(\n signature?: Partial<SignatureOptions>,\n ): Promise<SnapResponseWithInterface>;\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 onCronjob(cronjob?: Partial<CronjobOptions>): SnapRequest;\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 * @deprecated Use {@link onCronjob} instead.\n */\n runCronjob(cronjob: CronjobOptions): SnapRequest;\n\n /**\n * Get the response from the snap's `onHomePage` method.\n *\n * @returns The response.\n */\n onHomePage(): Promise<SnapResponseWithInterface>;\n\n /**\n * Mock a JSON-RPC request. This will cause the snap to respond with the\n * specified response when a request with the specified method is sent.\n *\n * @param mock - The mock options.\n * @param mock.method - The JSON-RPC request method.\n * @param mock.result - The JSON-RPC response, which will be returned when a\n * request with the specified method is sent.\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * // In the test\n * const snap = await installSnap();\n * snap.mockJsonRpc({ method: 'eth_accounts', result: ['0x1234'] });\n *\n * // In the Snap\n * const response =\n * await ethereum.request({ method: 'eth_accounts' }); // ['0x1234']\n */\n mockJsonRpc(mock: JsonRpcMockOptions): {\n /**\n * Remove the mock.\n */\n unmock(): void;\n };\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 * @deprecated Snaps are now automatically closed when the test ends. This\n * method will be removed in a future release.\n */\n close(): Promise<void>;\n};\n\nexport type SnapHandlerInterface = {\n content: JSXElement;\n} & SnapInterfaceActions;\n\nexport type SnapResponseWithInterface = {\n id: string;\n response: { result: Json } | { error: Json };\n notifications: {\n id: string;\n message: string;\n type: EnumToUnion<NotificationType>;\n }[];\n getInterface(): SnapHandlerInterface;\n};\n\nexport type SnapResponseWithoutInterface = Omit<\n SnapResponseWithInterface,\n 'getInterface'\n>;\n\nexport type SnapResponseType =\n | SnapResponseWithoutInterface\n | SnapResponseWithInterface;\n\nexport type SnapResponse = InferMatching<\n typeof SnapResponseStruct,\n SnapResponseType\n>;\n"]}
@@ -1,9 +1,9 @@
1
1
  import type { NotificationType, EnumToUnion } from "@metamask/snaps-sdk";
2
2
  import type { JSXElement } from "@metamask/snaps-sdk/jsx";
3
+ import type { SignatureOptionsStruct, SnapOptionsStruct, SnapResponseStruct, TransactionOptionsStruct } from "@metamask/snaps-simulation";
3
4
  import type { InferMatching } from "@metamask/snaps-utils";
4
5
  import type { Infer } from "@metamask/superstruct";
5
6
  import type { Json, JsonRpcId, JsonRpcParams } from "@metamask/utils";
6
- import type { SignatureOptionsStruct, SnapOptionsStruct, SnapResponseStruct, TransactionOptionsStruct } from "../internals/index.cjs";
7
7
  export type RequestOptions = {
8
8
  /**
9
9
  * The JSON-RPC request ID.
@@ -109,6 +109,13 @@ export type SnapInterfaceActions = {
109
109
  * @param value - The value to type.
110
110
  */
111
111
  selectFromRadioGroup(name: string, value: string): Promise<void>;
112
+ /**
113
+ * Choose an option with a value from Selector component.
114
+ *
115
+ * @param name - The element name to type in.
116
+ * @param value - The value to type.
117
+ */
118
+ selectFromSelector(name: string, value: string): Promise<void>;
112
119
  /**
113
120
  * Upload a file.
114
121
  *
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,4BAA4B;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,gCAAgC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,8BAA8B;AAC3D,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AACnD,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,wBAAwB;AAEtE,OAAO,KAAK,EACV,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,EACzB,+BAAqB;AAEtB,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,E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"}
@@ -1,9 +1,9 @@
1
1
  import type { NotificationType, EnumToUnion } from "@metamask/snaps-sdk";
2
2
  import type { JSXElement } from "@metamask/snaps-sdk/jsx";
3
+ import type { SignatureOptionsStruct, SnapOptionsStruct, SnapResponseStruct, TransactionOptionsStruct } from "@metamask/snaps-simulation";
3
4
  import type { InferMatching } from "@metamask/snaps-utils";
4
5
  import type { Infer } from "@metamask/superstruct";
5
6
  import type { Json, JsonRpcId, JsonRpcParams } from "@metamask/utils";
6
- import type { SignatureOptionsStruct, SnapOptionsStruct, SnapResponseStruct, TransactionOptionsStruct } from "../internals/index.mjs";
7
7
  export type RequestOptions = {
8
8
  /**
9
9
  * The JSON-RPC request ID.
@@ -109,6 +109,13 @@ export type SnapInterfaceActions = {
109
109
  * @param value - The value to type.
110
110
  */
111
111
  selectFromRadioGroup(name: string, value: string): Promise<void>;
112
+ /**
113
+ * Choose an option with a value from Selector component.
114
+ *
115
+ * @param name - The element name to type in.
116
+ * @param value - The value to type.
117
+ */
118
+ selectFromSelector(name: string, value: string): Promise<void>;
112
119
  /**
113
120
  * Upload a file.
114
121
  *