@metamask/snaps-jest 5.0.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -1
- package/dist/chunk-2KLZ7GOW.js +15 -0
- package/dist/chunk-2KLZ7GOW.js.map +1 -0
- package/dist/chunk-2M7WQ26F.js +28 -0
- package/dist/chunk-2M7WQ26F.js.map +1 -0
- package/dist/chunk-34GS3AHA.js +33 -0
- package/dist/chunk-34GS3AHA.js.map +1 -0
- package/dist/chunk-3CC2NI7R.js +80 -0
- package/dist/chunk-3CC2NI7R.js.map +1 -0
- package/dist/chunk-3IUQA6YL.mjs +1 -0
- package/dist/chunk-3IUQA6YL.mjs.map +1 -0
- package/dist/chunk-3KCEPGJA.js +39 -0
- package/dist/chunk-3KCEPGJA.js.map +1 -0
- package/dist/chunk-3KQYPQZY.js +20 -0
- package/dist/chunk-3KQYPQZY.js.map +1 -0
- package/dist/chunk-3O5OISLU.js +16 -0
- package/dist/chunk-3O5OISLU.js.map +1 -0
- package/dist/chunk-3ZW2EE3B.js +1 -0
- package/dist/chunk-3ZW2EE3B.js.map +1 -0
- package/dist/chunk-4FCRZDOX.js +134 -0
- package/dist/chunk-4FCRZDOX.js.map +1 -0
- package/dist/chunk-4HY4SM3A.js +1 -0
- package/dist/chunk-4HY4SM3A.js.map +1 -0
- package/dist/chunk-4JUUFDTC.js +104 -0
- package/dist/chunk-4JUUFDTC.js.map +1 -0
- package/dist/chunk-4VCE3DRR.mjs +34 -0
- package/dist/chunk-4VCE3DRR.mjs.map +1 -0
- package/dist/chunk-4WCFXE73.js +48 -0
- package/dist/chunk-4WCFXE73.js.map +1 -0
- package/dist/chunk-5IUHGC5S.js +153 -0
- package/dist/chunk-5IUHGC5S.js.map +1 -0
- package/dist/chunk-5O6VBW42.js +42 -0
- package/dist/chunk-5O6VBW42.js.map +1 -0
- package/dist/chunk-6IMEYERE.js +137 -0
- package/dist/chunk-6IMEYERE.js.map +1 -0
- package/dist/chunk-6KNT4UMX.mjs +35 -0
- package/dist/chunk-6KNT4UMX.mjs.map +1 -0
- package/dist/chunk-6RDNSELT.mjs +39 -0
- package/dist/chunk-6RDNSELT.mjs.map +1 -0
- package/dist/chunk-72YN2D26.mjs +60 -0
- package/dist/chunk-72YN2D26.mjs.map +1 -0
- package/dist/chunk-7JLVQJK7.js +14 -0
- package/dist/chunk-7JLVQJK7.js.map +1 -0
- package/dist/chunk-AH7YNG6N.js +22 -0
- package/dist/chunk-AH7YNG6N.js.map +1 -0
- package/dist/chunk-AIZADBRK.mjs +36 -0
- package/dist/chunk-AIZADBRK.mjs.map +1 -0
- package/dist/chunk-AKFRQ5EJ.mjs +42 -0
- package/dist/chunk-AKFRQ5EJ.mjs.map +1 -0
- package/dist/chunk-AUB7XPDH.mjs +28 -0
- package/dist/chunk-AUB7XPDH.mjs.map +1 -0
- package/dist/chunk-BJMTD7H2.mjs +20 -0
- package/dist/chunk-BJMTD7H2.mjs.map +1 -0
- package/dist/chunk-BN5VBVT3.mjs +233 -0
- package/dist/chunk-BN5VBVT3.mjs.map +1 -0
- package/dist/chunk-CKOGTHM4.mjs +22 -0
- package/dist/chunk-CKOGTHM4.mjs.map +1 -0
- package/dist/chunk-CZQKOZLR.js +11 -0
- package/dist/chunk-CZQKOZLR.js.map +1 -0
- package/dist/chunk-D36QBJ35.js +24 -0
- package/dist/{cjs/internals/simulation/methods/hooks/show-dialog.js.map → chunk-D36QBJ35.js.map} +1 -1
- package/dist/chunk-DEFFA5IJ.mjs +24 -0
- package/dist/chunk-DEFFA5IJ.mjs.map +1 -0
- package/dist/chunk-EFB6AQPB.js +36 -0
- package/dist/chunk-EFB6AQPB.js.map +1 -0
- package/dist/chunk-EOCDSPT7.mjs +97 -0
- package/dist/chunk-EOCDSPT7.mjs.map +1 -0
- package/dist/chunk-FPFX5AKR.mjs +36 -0
- package/dist/chunk-FPFX5AKR.mjs.map +1 -0
- package/dist/chunk-HBT34TJ2.mjs +1 -0
- package/dist/chunk-HBT34TJ2.mjs.map +1 -0
- package/dist/chunk-HBVDXIVN.mjs +80 -0
- package/dist/chunk-HBVDXIVN.mjs.map +1 -0
- package/dist/chunk-HMF2CKYT.mjs +39 -0
- package/dist/chunk-HMF2CKYT.mjs.map +1 -0
- package/dist/chunk-HP56MLQ3.js +1 -0
- package/dist/chunk-HP56MLQ3.js.map +1 -0
- package/dist/chunk-I5LVU57H.mjs +69 -0
- package/dist/chunk-I5LVU57H.mjs.map +1 -0
- package/dist/chunk-I7FLOZU7.mjs +1 -0
- package/dist/chunk-I7FLOZU7.mjs.map +1 -0
- package/dist/chunk-J2ID3DS7.mjs +33 -0
- package/dist/chunk-J2ID3DS7.mjs.map +1 -0
- package/dist/chunk-JA7RJLI7.js +34 -0
- package/dist/chunk-JA7RJLI7.js.map +1 -0
- package/dist/chunk-JB2H2XEL.mjs +1 -0
- package/dist/chunk-JB2H2XEL.mjs.map +1 -0
- package/dist/chunk-JDN3VGMO.js +21 -0
- package/dist/chunk-JDN3VGMO.js.map +1 -0
- package/dist/chunk-JGQJFYU4.js +57 -0
- package/dist/chunk-JGQJFYU4.js.map +1 -0
- package/dist/chunk-JJCX335U.mjs +91 -0
- package/dist/chunk-JJCX335U.mjs.map +1 -0
- package/dist/chunk-JMDSN227.mjs +25 -0
- package/dist/chunk-JMDSN227.mjs.map +1 -0
- package/dist/chunk-JXOKRTEH.mjs +11 -0
- package/dist/chunk-JXOKRTEH.mjs.map +1 -0
- package/dist/chunk-JZJWUVD7.mjs +1 -0
- package/dist/chunk-JZJWUVD7.mjs.map +1 -0
- package/dist/chunk-K2KTKFLP.js +76 -0
- package/dist/chunk-K2KTKFLP.js.map +1 -0
- package/dist/chunk-KGIWSGTT.js +91 -0
- package/dist/chunk-KGIWSGTT.js.map +1 -0
- package/dist/chunk-KPXLJ6RH.js +60 -0
- package/dist/chunk-KPXLJ6RH.js.map +1 -0
- package/dist/chunk-LD5PSHHT.mjs +57 -0
- package/dist/chunk-LD5PSHHT.mjs.map +1 -0
- package/dist/chunk-LNNKGOHQ.mjs +16 -0
- package/dist/chunk-LNNKGOHQ.mjs.map +1 -0
- package/dist/chunk-MNDF32ZV.js +8 -0
- package/dist/chunk-MNDF32ZV.js.map +1 -0
- package/dist/chunk-MSQ7Q2VJ.mjs +13 -0
- package/dist/chunk-MSQ7Q2VJ.mjs.map +1 -0
- package/dist/chunk-O3VJYBFN.mjs +15 -0
- package/dist/chunk-O3VJYBFN.mjs.map +1 -0
- package/dist/chunk-O4MJRHZD.js +69 -0
- package/dist/chunk-O4MJRHZD.js.map +1 -0
- package/dist/chunk-OC64PNDU.mjs +21 -0
- package/dist/chunk-OC64PNDU.mjs.map +1 -0
- package/dist/chunk-ON6M4WG5.js +36 -0
- package/dist/chunk-ON6M4WG5.js.map +1 -0
- package/dist/chunk-P7JA42ZC.mjs +153 -0
- package/dist/chunk-P7JA42ZC.mjs.map +1 -0
- package/dist/chunk-PHUTP7NB.js +25 -0
- package/dist/chunk-PHUTP7NB.js.map +1 -0
- package/dist/chunk-QFPRGU5L.mjs +104 -0
- package/dist/chunk-QFPRGU5L.mjs.map +1 -0
- package/dist/chunk-QMHWGASM.js +1 -0
- package/dist/chunk-QMHWGASM.js.map +1 -0
- package/dist/chunk-QNDLJ2W7.js +1 -0
- package/dist/chunk-QNDLJ2W7.js.map +1 -0
- package/dist/chunk-QUUILTDY.mjs +137 -0
- package/dist/chunk-QUUILTDY.mjs.map +1 -0
- package/dist/chunk-R7ORBTUD.js +1 -0
- package/dist/chunk-R7ORBTUD.js.map +1 -0
- package/dist/chunk-RQBZLDXL.js +233 -0
- package/dist/chunk-RQBZLDXL.js.map +1 -0
- package/dist/chunk-S3DHQTXB.js +1 -0
- package/dist/chunk-S3DHQTXB.js.map +1 -0
- package/dist/chunk-SWSSV3LK.js +35 -0
- package/dist/chunk-SWSSV3LK.js.map +1 -0
- package/dist/chunk-T4TRX3ZR.js +22 -0
- package/dist/chunk-T4TRX3ZR.js.map +1 -0
- package/dist/chunk-UXHKMILA.mjs +1 -0
- package/dist/chunk-UXHKMILA.mjs.map +1 -0
- package/dist/chunk-VCXM6FKU.mjs +1 -0
- package/dist/chunk-VCXM6FKU.mjs.map +1 -0
- package/dist/chunk-VHTVUQWR.mjs +14 -0
- package/dist/chunk-VHTVUQWR.mjs.map +1 -0
- package/dist/chunk-VNQIROKZ.js +97 -0
- package/dist/chunk-VNQIROKZ.js.map +1 -0
- package/dist/chunk-VXQOXWRO.mjs +48 -0
- package/dist/chunk-VXQOXWRO.mjs.map +1 -0
- package/dist/chunk-VYKYQSUI.mjs +22 -0
- package/dist/chunk-VYKYQSUI.mjs.map +1 -0
- package/dist/chunk-WEI35OIM.mjs +8 -0
- package/dist/chunk-WEI35OIM.mjs.map +1 -0
- package/dist/chunk-WL2GRM5E.mjs +76 -0
- package/dist/chunk-WL2GRM5E.mjs.map +1 -0
- package/dist/chunk-XDZPH5WD.js +39 -0
- package/dist/chunk-XDZPH5WD.js.map +1 -0
- package/dist/chunk-Y5NWZU43.js +13 -0
- package/dist/chunk-Y5NWZU43.js.map +1 -0
- package/dist/chunk-YZFWCFMG.js +1 -0
- package/dist/chunk-YZFWCFMG.js.map +1 -0
- package/dist/chunk-ZCE26WZM.mjs +1 -0
- package/dist/chunk-ZCE26WZM.mjs.map +1 -0
- package/dist/chunk-ZZPKZRJQ.mjs +134 -0
- package/dist/chunk-ZZPKZRJQ.mjs.map +1 -0
- package/dist/environment.js +47 -0
- package/dist/environment.js.map +1 -0
- package/dist/environment.mjs +47 -0
- package/dist/environment.mjs.map +1 -0
- package/dist/helpers.js +44 -0
- package/dist/helpers.js.map +1 -0
- package/dist/helpers.mjs +44 -0
- package/dist/helpers.mjs.map +1 -0
- package/dist/index.js +54 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +54 -0
- package/dist/index.mjs.map +1 -0
- package/dist/internals/environment.js +8 -0
- package/dist/internals/environment.js.map +1 -0
- package/dist/internals/environment.mjs +8 -0
- package/dist/internals/environment.mjs.map +1 -0
- package/dist/internals/index.js +123 -0
- package/dist/internals/index.js.map +1 -0
- package/dist/internals/index.mjs +123 -0
- package/dist/internals/index.mjs.map +1 -0
- package/dist/internals/logger.js +8 -0
- package/dist/internals/logger.js.map +1 -0
- package/dist/internals/logger.mjs +8 -0
- package/dist/internals/logger.mjs.map +1 -0
- package/dist/internals/request.js +40 -0
- package/dist/internals/request.js.map +1 -0
- package/dist/internals/request.mjs +40 -0
- package/dist/internals/request.mjs.map +1 -0
- package/dist/internals/server.js +9 -0
- package/dist/internals/server.js.map +1 -0
- package/dist/internals/server.mjs +9 -0
- package/dist/internals/server.mjs.map +1 -0
- package/dist/internals/simulation/constants.js +12 -0
- package/dist/internals/simulation/constants.js.map +1 -0
- package/dist/internals/simulation/constants.mjs +12 -0
- package/dist/internals/simulation/constants.mjs.map +1 -0
- package/dist/internals/simulation/controllers.js +26 -0
- package/dist/internals/simulation/controllers.js.map +1 -0
- package/dist/internals/simulation/controllers.mjs +26 -0
- package/dist/internals/simulation/controllers.mjs.map +1 -0
- package/dist/internals/simulation/files.js +8 -0
- package/dist/internals/simulation/files.js.map +1 -0
- package/dist/internals/simulation/files.mjs +8 -0
- package/dist/internals/simulation/files.mjs.map +1 -0
- package/dist/internals/simulation/index.js +90 -0
- package/dist/internals/simulation/index.js.map +1 -0
- package/dist/internals/simulation/index.mjs +90 -0
- package/dist/internals/simulation/index.mjs.map +1 -0
- package/dist/internals/simulation/interface.js +16 -0
- package/dist/internals/simulation/interface.js.map +1 -0
- package/dist/internals/simulation/interface.mjs +16 -0
- package/dist/internals/simulation/interface.mjs.map +1 -0
- package/dist/internals/simulation/methods/constants.js +12 -0
- package/dist/internals/simulation/methods/constants.js.map +1 -0
- package/dist/internals/simulation/methods/constants.mjs +12 -0
- package/dist/internals/simulation/methods/constants.mjs.map +1 -0
- package/dist/internals/simulation/methods/hooks/encryption.js +10 -0
- package/dist/internals/simulation/methods/hooks/encryption.js.map +1 -0
- package/dist/internals/simulation/methods/hooks/encryption.mjs +10 -0
- package/dist/internals/simulation/methods/hooks/encryption.mjs.map +1 -0
- package/dist/internals/simulation/methods/hooks/get-locale.js +8 -0
- package/dist/internals/simulation/methods/hooks/get-locale.js.map +1 -0
- package/dist/internals/simulation/methods/hooks/get-locale.mjs +8 -0
- package/dist/internals/simulation/methods/hooks/get-locale.mjs.map +1 -0
- package/dist/internals/simulation/methods/hooks/index.js +45 -0
- package/dist/internals/simulation/methods/hooks/index.js.map +1 -0
- package/dist/internals/simulation/methods/hooks/index.mjs +45 -0
- package/dist/internals/simulation/methods/hooks/index.mjs.map +1 -0
- package/dist/internals/simulation/methods/hooks/interface.js +10 -0
- package/dist/internals/simulation/methods/hooks/interface.js.map +1 -0
- package/dist/internals/simulation/methods/hooks/interface.mjs +10 -0
- package/dist/internals/simulation/methods/hooks/interface.mjs.map +1 -0
- package/dist/internals/simulation/methods/hooks/notifications.js +16 -0
- package/dist/internals/simulation/methods/hooks/notifications.js.map +1 -0
- package/dist/internals/simulation/methods/hooks/notifications.mjs +16 -0
- package/dist/internals/simulation/methods/hooks/notifications.mjs.map +1 -0
- package/dist/internals/simulation/methods/hooks/show-dialog.js +14 -0
- package/dist/internals/simulation/methods/hooks/show-dialog.js.map +1 -0
- package/dist/internals/simulation/methods/hooks/show-dialog.mjs +14 -0
- package/dist/internals/simulation/methods/hooks/show-dialog.mjs.map +1 -0
- package/dist/internals/simulation/methods/hooks/state.js +18 -0
- package/dist/internals/simulation/methods/hooks/state.js.map +1 -0
- package/dist/internals/simulation/methods/hooks/state.mjs +18 -0
- package/dist/internals/simulation/methods/hooks/state.mjs.map +1 -0
- package/dist/internals/simulation/methods/index.js +29 -0
- package/dist/internals/simulation/methods/index.js.map +1 -0
- package/dist/internals/simulation/methods/index.mjs +29 -0
- package/dist/internals/simulation/methods/index.mjs.map +1 -0
- package/dist/internals/simulation/methods/specifications.js +28 -0
- package/dist/internals/simulation/methods/specifications.js.map +1 -0
- package/dist/internals/simulation/methods/specifications.mjs +28 -0
- package/dist/internals/simulation/methods/specifications.mjs.map +1 -0
- package/dist/internals/simulation/middleware/engine.js +15 -0
- package/dist/internals/simulation/middleware/engine.js.map +1 -0
- package/dist/internals/simulation/middleware/engine.mjs +15 -0
- package/dist/internals/simulation/middleware/engine.mjs.map +1 -0
- package/dist/internals/simulation/middleware/index.js +16 -0
- package/dist/internals/simulation/middleware/index.js.map +1 -0
- package/dist/internals/simulation/middleware/index.mjs +16 -0
- package/dist/internals/simulation/middleware/index.mjs.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/accounts.js +8 -0
- package/dist/internals/simulation/middleware/internal-methods/accounts.js.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/accounts.mjs +8 -0
- package/dist/internals/simulation/middleware/internal-methods/accounts.mjs.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/index.js +11 -0
- package/dist/internals/simulation/middleware/internal-methods/index.js.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/index.mjs +11 -0
- package/dist/internals/simulation/middleware/internal-methods/index.mjs.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/middleware.js +10 -0
- package/dist/internals/simulation/middleware/internal-methods/middleware.js.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/middleware.mjs +10 -0
- package/dist/internals/simulation/middleware/internal-methods/middleware.mjs.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/provider-state.js +8 -0
- package/dist/internals/simulation/middleware/internal-methods/provider-state.js.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/provider-state.mjs +8 -0
- package/dist/internals/simulation/middleware/internal-methods/provider-state.mjs.map +1 -0
- package/dist/internals/simulation/middleware/mock.js +9 -0
- package/dist/internals/simulation/middleware/mock.js.map +1 -0
- package/dist/internals/simulation/middleware/mock.mjs +9 -0
- package/dist/internals/simulation/middleware/mock.mjs.map +1 -0
- package/dist/internals/simulation/options.js +9 -0
- package/dist/internals/simulation/options.js.map +1 -0
- package/dist/internals/simulation/options.mjs +9 -0
- package/dist/internals/simulation/options.mjs.map +1 -0
- package/dist/internals/simulation/simulation.js +39 -0
- package/dist/internals/simulation/simulation.js.map +1 -0
- package/dist/internals/simulation/simulation.mjs +39 -0
- package/dist/internals/simulation/simulation.mjs.map +1 -0
- package/dist/internals/simulation/store/index.js +44 -0
- package/dist/internals/simulation/store/index.js.map +1 -0
- package/dist/internals/simulation/store/index.mjs +44 -0
- package/dist/internals/simulation/store/index.mjs.map +1 -0
- package/dist/internals/simulation/store/mocks.js +16 -0
- package/dist/internals/simulation/store/mocks.js.map +1 -0
- package/dist/internals/simulation/store/mocks.mjs +16 -0
- package/dist/internals/simulation/store/mocks.mjs.map +1 -0
- package/dist/internals/simulation/store/notifications.js +16 -0
- package/dist/internals/simulation/store/notifications.js.map +1 -0
- package/dist/internals/simulation/store/notifications.mjs +16 -0
- package/dist/internals/simulation/store/notifications.mjs.map +1 -0
- package/dist/internals/simulation/store/state.js +14 -0
- package/dist/internals/simulation/store/state.js.map +1 -0
- package/dist/internals/simulation/store/state.mjs +14 -0
- package/dist/internals/simulation/store/state.mjs.map +1 -0
- package/dist/internals/simulation/store/store.js +12 -0
- package/dist/internals/simulation/store/store.js.map +1 -0
- package/dist/internals/simulation/store/store.mjs +12 -0
- package/dist/internals/simulation/store/store.mjs.map +1 -0
- package/dist/internals/simulation/store/ui.js +16 -0
- package/dist/internals/simulation/store/ui.js.map +1 -0
- package/dist/internals/simulation/store/ui.mjs +16 -0
- package/dist/internals/simulation/store/ui.mjs.map +1 -0
- package/dist/internals/structs.js +18 -0
- package/dist/internals/structs.js.map +1 -0
- package/dist/internals/structs.mjs +18 -0
- package/dist/internals/structs.mjs.map +1 -0
- package/dist/matchers.js +50 -0
- package/dist/matchers.js.map +1 -0
- package/dist/matchers.mjs +50 -0
- package/dist/matchers.mjs.map +1 -0
- package/dist/options.js +8 -0
- package/dist/options.js.map +1 -0
- package/dist/options.mjs +8 -0
- package/dist/options.mjs.map +1 -0
- package/dist/setup.js +39 -0
- package/dist/setup.js.map +1 -0
- package/dist/setup.mjs +39 -0
- package/dist/setup.mjs.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/vendor/readable-stream.d.js +1 -0
- package/dist/types/vendor/readable-stream.d.js.map +1 -0
- package/dist/types/vendor/readable-stream.d.mjs +1 -0
- package/dist/types/vendor/readable-stream.d.mjs.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -0
- package/jest-preset.js +1 -1
- package/package.json +24 -20
- package/dist/cjs/environment.js +0 -144
- package/dist/cjs/environment.js.map +0 -1
- package/dist/cjs/helpers.js +0 -142
- package/dist/cjs/helpers.js.map +0 -1
- package/dist/cjs/index.js +0 -42
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/internals/environment.js +0 -19
- package/dist/cjs/internals/environment.js.map +0 -1
- package/dist/cjs/internals/index.js +0 -25
- package/dist/cjs/internals/index.js.map +0 -1
- package/dist/cjs/internals/logger.js +0 -14
- package/dist/cjs/internals/logger.js.map +0 -1
- package/dist/cjs/internals/request.js +0 -69
- package/dist/cjs/internals/request.js.map +0 -1
- package/dist/cjs/internals/server.js +0 -71
- package/dist/cjs/internals/server.js.map +0 -1
- package/dist/cjs/internals/simulation/constants.js +0 -29
- package/dist/cjs/internals/simulation/constants.js.map +0 -1
- package/dist/cjs/internals/simulation/controllers.js +0 -95
- package/dist/cjs/internals/simulation/controllers.js.map +0 -1
- package/dist/cjs/internals/simulation/files.js +0 -22
- package/dist/cjs/internals/simulation/files.js.map +0 -1
- package/dist/cjs/internals/simulation/index.js +0 -24
- package/dist/cjs/internals/simulation/index.js.map +0 -1
- package/dist/cjs/internals/simulation/interface.js +0 -98
- package/dist/cjs/internals/simulation/interface.js.map +0 -1
- package/dist/cjs/internals/simulation/methods/constants.js +0 -84
- package/dist/cjs/internals/simulation/methods/constants.js.map +0 -1
- package/dist/cjs/internals/simulation/methods/hooks/encryption.js +0 -33
- package/dist/cjs/internals/simulation/methods/hooks/encryption.js.map +0 -1
- package/dist/cjs/internals/simulation/methods/hooks/get-locale.js +0 -17
- package/dist/cjs/internals/simulation/methods/hooks/get-locale.js.map +0 -1
- package/dist/cjs/internals/simulation/methods/hooks/index.js +0 -25
- package/dist/cjs/internals/simulation/methods/hooks/index.js.map +0 -1
- package/dist/cjs/internals/simulation/methods/hooks/interface.js +0 -26
- package/dist/cjs/internals/simulation/methods/hooks/interface.js.map +0 -1
- package/dist/cjs/internals/simulation/methods/hooks/notifications.js +0 -66
- package/dist/cjs/internals/simulation/methods/hooks/notifications.js.map +0 -1
- package/dist/cjs/internals/simulation/methods/hooks/show-dialog.js +0 -43
- package/dist/cjs/internals/simulation/methods/hooks/state.js +0 -80
- package/dist/cjs/internals/simulation/methods/hooks/state.js.map +0 -1
- package/dist/cjs/internals/simulation/methods/index.js +0 -20
- package/dist/cjs/internals/simulation/methods/index.js.map +0 -1
- package/dist/cjs/internals/simulation/methods/specifications.js +0 -81
- package/dist/cjs/internals/simulation/methods/specifications.js.map +0 -1
- package/dist/cjs/internals/simulation/middleware/engine.js +0 -31
- package/dist/cjs/internals/simulation/middleware/engine.js.map +0 -1
- package/dist/cjs/internals/simulation/middleware/index.js +0 -20
- package/dist/cjs/internals/simulation/middleware/index.js.map +0 -1
- package/dist/cjs/internals/simulation/middleware/internal-methods/accounts.js +0 -30
- package/dist/cjs/internals/simulation/middleware/internal-methods/accounts.js.map +0 -1
- package/dist/cjs/internals/simulation/middleware/internal-methods/index.js +0 -20
- package/dist/cjs/internals/simulation/middleware/internal-methods/index.js.map +0 -1
- package/dist/cjs/internals/simulation/middleware/internal-methods/middleware.js +0 -37
- package/dist/cjs/internals/simulation/middleware/internal-methods/middleware.js.map +0 -1
- package/dist/cjs/internals/simulation/middleware/internal-methods/provider-state.js +0 -23
- package/dist/cjs/internals/simulation/middleware/internal-methods/provider-state.js.map +0 -1
- package/dist/cjs/internals/simulation/middleware/mock.js +0 -23
- package/dist/cjs/internals/simulation/middleware/mock.js.map +0 -1
- package/dist/cjs/internals/simulation/options.js +0 -24
- package/dist/cjs/internals/simulation/options.js.map +0 -1
- package/dist/cjs/internals/simulation/simulation.js +0 -124
- package/dist/cjs/internals/simulation/simulation.js.map +0 -1
- package/dist/cjs/internals/simulation/store/index.js +0 -23
- package/dist/cjs/internals/simulation/store/index.js.map +0 -1
- package/dist/cjs/internals/simulation/store/mocks.js +0 -52
- package/dist/cjs/internals/simulation/store/mocks.js.map +0 -1
- package/dist/cjs/internals/simulation/store/notifications.js +0 -52
- package/dist/cjs/internals/simulation/store/notifications.js.map +0 -1
- package/dist/cjs/internals/simulation/store/state.js +0 -64
- package/dist/cjs/internals/simulation/store/state.js.map +0 -1
- package/dist/cjs/internals/simulation/store/store.js +0 -57
- package/dist/cjs/internals/simulation/store/store.js.map +0 -1
- package/dist/cjs/internals/simulation/store/ui.js +0 -48
- package/dist/cjs/internals/simulation/store/ui.js.map +0 -1
- package/dist/cjs/internals/structs.js +0 -165
- package/dist/cjs/internals/structs.js.map +0 -1
- package/dist/cjs/matchers.js +0 -120
- package/dist/cjs/matchers.js.map +0 -1
- package/dist/cjs/options.js +0 -23
- package/dist/cjs/options.js.map +0 -1
- package/dist/cjs/setup.js +0 -10
- package/dist/cjs/setup.js.map +0 -1
- package/dist/cjs/types.js +0 -6
- package/dist/cjs/types.js.map +0 -1
- package/dist/esm/environment.js +0 -121
- package/dist/esm/environment.js.map +0 -1
- package/dist/esm/helpers.js +0 -163
- package/dist/esm/helpers.js.map +0 -1
- package/dist/esm/index.js +0 -6
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/internals/environment.js +0 -14
- package/dist/esm/internals/environment.js.map +0 -1
- package/dist/esm/internals/index.js +0 -8
- package/dist/esm/internals/index.js.map +0 -1
- package/dist/esm/internals/logger.js +0 -4
- package/dist/esm/internals/logger.js.map +0 -1
- package/dist/esm/internals/request.js +0 -77
- package/dist/esm/internals/request.js.map +0 -1
- package/dist/esm/internals/server.js +0 -64
- package/dist/esm/internals/server.js.map +0 -1
- package/dist/esm/internals/simulation/constants.js +0 -12
- package/dist/esm/internals/simulation/constants.js.map +0 -1
- package/dist/esm/internals/simulation/controllers.js +0 -90
- package/dist/esm/internals/simulation/controllers.js.map +0 -1
- package/dist/esm/internals/simulation/files.js +0 -19
- package/dist/esm/internals/simulation/files.js.map +0 -1
- package/dist/esm/internals/simulation/index.js +0 -7
- package/dist/esm/internals/simulation/index.js.map +0 -1
- package/dist/esm/internals/simulation/interface.js +0 -95
- package/dist/esm/internals/simulation/interface.js.map +0 -1
- package/dist/esm/internals/simulation/methods/constants.js +0 -69
- package/dist/esm/internals/simulation/methods/constants.js.map +0 -1
- package/dist/esm/internals/simulation/methods/hooks/encryption.js +0 -39
- package/dist/esm/internals/simulation/methods/hooks/encryption.js.map +0 -1
- package/dist/esm/internals/simulation/methods/hooks/get-locale.js +0 -13
- package/dist/esm/internals/simulation/methods/hooks/get-locale.js.map +0 -1
- package/dist/esm/internals/simulation/methods/hooks/index.js +0 -8
- package/dist/esm/internals/simulation/methods/hooks/index.js.map +0 -1
- package/dist/esm/internals/simulation/methods/hooks/interface.js +0 -18
- package/dist/esm/internals/simulation/methods/hooks/interface.js.map +0 -1
- package/dist/esm/internals/simulation/methods/hooks/notifications.js +0 -58
- package/dist/esm/internals/simulation/methods/hooks/notifications.js.map +0 -1
- package/dist/esm/internals/simulation/methods/hooks/show-dialog.js +0 -38
- package/dist/esm/internals/simulation/methods/hooks/show-dialog.js.map +0 -1
- package/dist/esm/internals/simulation/methods/hooks/state.js +0 -74
- package/dist/esm/internals/simulation/methods/hooks/state.js.map +0 -1
- package/dist/esm/internals/simulation/methods/index.js +0 -3
- package/dist/esm/internals/simulation/methods/index.js.map +0 -1
- package/dist/esm/internals/simulation/methods/specifications.js +0 -84
- package/dist/esm/internals/simulation/methods/specifications.js.map +0 -1
- package/dist/esm/internals/simulation/middleware/engine.js +0 -33
- package/dist/esm/internals/simulation/middleware/engine.js.map +0 -1
- package/dist/esm/internals/simulation/middleware/index.js +0 -3
- package/dist/esm/internals/simulation/middleware/index.js.map +0 -1
- package/dist/esm/internals/simulation/middleware/internal-methods/accounts.js +0 -31
- package/dist/esm/internals/simulation/middleware/internal-methods/accounts.js.map +0 -1
- package/dist/esm/internals/simulation/middleware/internal-methods/index.js +0 -3
- package/dist/esm/internals/simulation/middleware/internal-methods/index.js.map +0 -1
- package/dist/esm/internals/simulation/middleware/internal-methods/middleware.js +0 -37
- package/dist/esm/internals/simulation/middleware/internal-methods/middleware.js.map +0 -1
- package/dist/esm/internals/simulation/middleware/internal-methods/provider-state.js +0 -23
- package/dist/esm/internals/simulation/middleware/internal-methods/provider-state.js.map +0 -1
- package/dist/esm/internals/simulation/middleware/mock.js +0 -18
- package/dist/esm/internals/simulation/middleware/mock.js.map +0 -1
- package/dist/esm/internals/simulation/options.js +0 -20
- package/dist/esm/internals/simulation/options.js.map +0 -1
- package/dist/esm/internals/simulation/simulation.js +0 -128
- package/dist/esm/internals/simulation/simulation.js.map +0 -1
- package/dist/esm/internals/simulation/store/index.js +0 -6
- package/dist/esm/internals/simulation/store/index.js.map +0 -1
- package/dist/esm/internals/simulation/store/mocks.js +0 -32
- package/dist/esm/internals/simulation/store/mocks.js.map +0 -1
- package/dist/esm/internals/simulation/store/notifications.js +0 -30
- package/dist/esm/internals/simulation/store/notifications.js.map +0 -1
- package/dist/esm/internals/simulation/store/state.js +0 -47
- package/dist/esm/internals/simulation/store/state.js.map +0 -1
- package/dist/esm/internals/simulation/store/store.js +0 -50
- package/dist/esm/internals/simulation/store/store.js.map +0 -1
- package/dist/esm/internals/simulation/store/ui.js +0 -21
- package/dist/esm/internals/simulation/store/ui.js.map +0 -1
- package/dist/esm/internals/structs.js +0 -135
- package/dist/esm/internals/structs.js.map +0 -1
- package/dist/esm/matchers.js +0 -111
- package/dist/esm/matchers.js.map +0 -1
- package/dist/esm/options.js +0 -20
- package/dist/esm/options.js.map +0 -1
- package/dist/esm/setup.js +0 -6
- package/dist/esm/setup.js.map +0 -1
- package/dist/esm/types.js +0 -3
- package/dist/esm/types.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [6.0.0]
|
|
10
|
+
### Changed
|
|
11
|
+
- **BREAKING:** Update ESM build to be fully compliant with the ESM standard ([#2210](https://github.com/MetaMask/snaps/pull/2210))
|
|
12
|
+
- **BREAKING:** Move Node.js exports to separate export ([#2210](https://github.com/MetaMask/snaps/pull/2210))
|
|
13
|
+
- The default export is now browser-compatible.
|
|
14
|
+
- Node.js APIs can be imported from `<package>/node`.
|
|
15
|
+
- Bump `@metamask/rpc-errors` to `^6.2.1` ([#2209](https://github.com/MetaMask/snaps/pull/2209))
|
|
16
|
+
|
|
9
17
|
## [5.0.0]
|
|
10
18
|
### Added
|
|
11
19
|
- **BREAKING:** Implement testing framework using Node.js executor ([#1982](https://github.com/MetaMask/snaps/pull/1982), [#2118](https://github.com/MetaMask/snaps/pull/2118))
|
|
@@ -95,7 +103,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
95
103
|
- The version of the package no longer needs to match the version of all other
|
|
96
104
|
MetaMask Snaps packages.
|
|
97
105
|
|
|
98
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@
|
|
106
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@6.0.0...HEAD
|
|
107
|
+
[6.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@5.0.0...@metamask/snaps-jest@6.0.0
|
|
99
108
|
[5.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@4.0.1...@metamask/snaps-jest@5.0.0
|
|
100
109
|
[4.0.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@4.0.0...@metamask/snaps-jest@4.0.1
|
|
101
110
|
[4.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@3.1.0...@metamask/snaps-jest@4.0.0
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/internals/simulation/middleware/internal-methods/provider-state.ts
|
|
2
|
+
async function getProviderStateHandler(_request, response, _next, end) {
|
|
3
|
+
response.result = {
|
|
4
|
+
isUnlocked: true,
|
|
5
|
+
chainId: "0x01",
|
|
6
|
+
networkVersion: "0x01",
|
|
7
|
+
accounts: []
|
|
8
|
+
};
|
|
9
|
+
return end();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
exports.getProviderStateHandler = getProviderStateHandler;
|
|
15
|
+
//# sourceMappingURL=chunk-2KLZ7GOW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/internals/simulation/middleware/internal-methods/provider-state.ts"],"names":[],"mappings":";AAqBA,eAAsB,wBACpB,UACA,UACA,OACA,KACA;AAGA,WAAS,SAAS;AAAA,IAChB,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,gBAAgB;AAAA,IAChB,UAAU,CAAC;AAAA,EACb;AAEA,SAAO,IAAI;AACb","sourcesContent":["import type {\n JsonRpcEngineEndCallback,\n JsonRpcEngineNextCallback,\n} from '@metamask/json-rpc-engine';\nimport type {\n Json,\n JsonRpcRequest,\n PendingJsonRpcResponse,\n} from '@metamask/utils';\n\n/**\n * A mock handler for metamask_getProviderState that always returns a specific\n * hardcoded result.\n *\n * @param _request - Incoming JSON-RPC request. Ignored for this specific\n * handler.\n * @param response - The outgoing JSON-RPC response, modified to return the\n * result.\n * @param _next - The `json-rpc-engine` middleware next handler.\n * @param end - The `json-rpc-engine` middleware end handler.\n */\nexport async function getProviderStateHandler(\n _request: JsonRpcRequest,\n response: PendingJsonRpcResponse<Json>,\n _next: JsonRpcEngineNextCallback,\n end: JsonRpcEngineEndCallback,\n) {\n // For now this will return a mocked result, this should probably match\n // whatever network the simulation is using.\n response.result = {\n isUnlocked: true,\n chainId: '0x01',\n networkVersion: '0x01',\n accounts: [],\n };\n\n return end();\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/options.ts
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _superstruct = require('superstruct');
|
|
11
|
+
var SnapsEnvironmentOptionsStruct = _superstruct.type.call(void 0, {
|
|
12
|
+
server: _superstruct.defaulted.call(void 0,
|
|
13
|
+
_superstruct.object.call(void 0, {
|
|
14
|
+
enabled: _superstruct.defaulted.call(void 0, _superstruct.boolean.call(void 0, ), true),
|
|
15
|
+
port: _superstruct.defaulted.call(void 0, _superstruct.number.call(void 0, ), 0),
|
|
16
|
+
root: _superstruct.defaulted.call(void 0, _superstruct.string.call(void 0, ), process.cwd())
|
|
17
|
+
}),
|
|
18
|
+
{}
|
|
19
|
+
)
|
|
20
|
+
});
|
|
21
|
+
function getOptions(testEnvironmentOptions) {
|
|
22
|
+
return _superstruct.create.call(void 0, testEnvironmentOptions, SnapsEnvironmentOptionsStruct);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
exports.getOptions = getOptions;
|
|
28
|
+
//# sourceMappingURL=chunk-2M7WQ26F.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/options.ts"],"names":[],"mappings":";AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,IAAM,gCAAgC,KAAK;AAAA,EACzC,QAAQ;AAAA,IACN,OAAO;AAAA,MACL,SAAS,UAAU,QAAQ,GAAG,IAAI;AAAA,MAClC,MAAM,UAAU,OAAO,GAAG,CAAC;AAAA,MAC3B,MAAM,UAAU,OAAO,GAAG,QAAQ,IAAI,CAAC;AAAA,IACzC,CAAC;AAAA,IACD,CAAC;AAAA,EACH;AACF,CAAC;AAuCM,SAAS,WAAW,wBAAiD;AAC1E,SAAO,OAAO,wBAAwB,6BAA6B;AACrE","sourcesContent":["import type { Infer } from 'superstruct';\nimport {\n boolean,\n create,\n defaulted,\n number,\n object,\n string,\n type,\n} from 'superstruct';\n\nconst SnapsEnvironmentOptionsStruct = type({\n server: defaulted(\n object({\n enabled: defaulted(boolean(), true),\n port: defaulted(number(), 0),\n root: defaulted(string(), process.cwd()),\n }),\n {},\n ),\n});\n\n/**\n * The options for the environment. These can be specified in the Jest\n * configuration under `testEnvironmentOptions`.\n *\n * @example\n * {\n * \"testEnvironment\": \"@metamask/snaps-jest\",\n * \"testEnvironmentOptions\": {\n * \"executionEnvironmentUrl\": \"http://localhost:8080\",\n * \"server\": {\n * \"port\": 8080,\n * /* ... *\\/\n * }\n * }\n * }\n * @property server - The options for the built-in HTTP server.\n * @property server.enabled - Whether to run the built-in HTTP server. Defaults\n * to `true`.\n * @property server.port - The port to use for the built-in HTTP server. If this\n * is not provided, a random available port will be used.\n * @property server.root - The root directory to serve from the built-in HTTP\n * server. Defaults to the current working directory. This is assumed to be the\n * directory containing the snap manifest and `dist` files. If this is a\n * relative path, it will be resolved relative to the current working directory.\n */\nexport type SnapsEnvironmentOptions = Infer<\n typeof SnapsEnvironmentOptionsStruct\n>;\n\n/**\n * Get the environment options. This validates the options, and returns the\n * default options if none are provided.\n *\n * @param testEnvironmentOptions - The test environment options as defined in\n * the Jest configuration.\n * @returns The environment options.\n */\nexport function getOptions(testEnvironmentOptions: Record<string, unknown>) {\n return create(testEnvironmentOptions, SnapsEnvironmentOptionsStruct);\n}\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/internals/simulation/store/mocks.ts
|
|
2
|
+
var _toolkit = require('@reduxjs/toolkit');
|
|
3
|
+
var INITIAL_STATE = {
|
|
4
|
+
jsonRpc: {}
|
|
5
|
+
};
|
|
6
|
+
var mocksSlice = _toolkit.createSlice.call(void 0, {
|
|
7
|
+
name: "mocks",
|
|
8
|
+
initialState: INITIAL_STATE,
|
|
9
|
+
reducers: {
|
|
10
|
+
addJsonRpcMock: (state, action) => {
|
|
11
|
+
state.jsonRpc[action.payload.method] = action.payload.result;
|
|
12
|
+
},
|
|
13
|
+
removeJsonRpcMock: (state, action) => {
|
|
14
|
+
delete state.jsonRpc[action.payload];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var { addJsonRpcMock, removeJsonRpcMock } = mocksSlice.actions;
|
|
19
|
+
var getJsonRpcMocks = (state) => state.mocks.jsonRpc;
|
|
20
|
+
var getJsonRpcMock = _toolkit.createSelector.call(void 0,
|
|
21
|
+
getJsonRpcMocks,
|
|
22
|
+
(_, method) => method,
|
|
23
|
+
(jsonRpcMocks, method) => jsonRpcMocks[method]
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
exports.mocksSlice = mocksSlice; exports.addJsonRpcMock = addJsonRpcMock; exports.removeJsonRpcMock = removeJsonRpcMock; exports.getJsonRpcMocks = getJsonRpcMocks; exports.getJsonRpcMock = getJsonRpcMock;
|
|
33
|
+
//# sourceMappingURL=chunk-34GS3AHA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/internals/simulation/store/mocks.ts"],"names":[],"mappings":";AAEA,SAAS,gBAAgB,mBAAmB;AAgB5C,IAAM,gBAA4B;AAAA,EAChC,SAAS,CAAC;AACZ;AAEO,IAAM,aAAa,YAAY;AAAA,EACpC,MAAM;AAAA,EACN,cAAc;AAAA,EACd,UAAU;AAAA,IACR,gBAAgB,CAAC,OAAO,WAAuC;AAG7D,YAAM,QAAQ,OAAO,QAAQ,MAAM,IAAI,OAAO,QAAQ;AAAA,IACxD;AAAA,IACA,mBAAmB,CAAC,OAAO,WAAkC;AAC3D,aAAO,MAAM,QAAQ,OAAO,OAAO;AAAA,IACrC;AAAA,EACF;AACF,CAAC;AAEM,IAAM,EAAE,gBAAgB,kBAAkB,IAAI,WAAW;AAQzD,IAAM,kBAAkB,CAAC,UAA4B,MAAM,MAAM;AAKjE,IAAM,iBAAiB;AAAA,EAC5B;AAAA,EACA,CAAC,GAAY,WAAmB;AAAA,EAChC,CAAC,cAAc,WAAW,aAAa,MAAM;AAC/C","sourcesContent":["import type { Json } from '@metamask/utils';\nimport type { PayloadAction } from '@reduxjs/toolkit';\nimport { createSelector, createSlice } from '@reduxjs/toolkit';\n\nimport type { ApplicationState } from './store';\n\nexport type JsonRpcMock = {\n method: string;\n result: Json;\n};\n\nexport type MocksState = {\n jsonRpc: Record<string, Json>;\n};\n\n/**\n * The initial notifications state.\n */\nconst INITIAL_STATE: MocksState = {\n jsonRpc: {},\n};\n\nexport const mocksSlice = createSlice({\n name: 'mocks',\n initialState: INITIAL_STATE,\n reducers: {\n addJsonRpcMock: (state, action: PayloadAction<JsonRpcMock>) => {\n // @ts-expect-error - TS2589: Type instantiation is excessively deep and\n // possibly infinite.\n state.jsonRpc[action.payload.method] = action.payload.result;\n },\n removeJsonRpcMock: (state, action: PayloadAction<string>) => {\n delete state.jsonRpc[action.payload];\n },\n },\n});\n\nexport const { addJsonRpcMock, removeJsonRpcMock } = mocksSlice.actions;\n\n/**\n * Get the JSON-RPC mocks from the state.\n *\n * @param state - The application state.\n * @returns The JSON-RPC mocks.\n */\nexport const getJsonRpcMocks = (state: ApplicationState) => state.mocks.jsonRpc;\n\n/**\n * Get the JSON-RPC mock for a given method from the state.\n */\nexport const getJsonRpcMock = createSelector(\n getJsonRpcMocks,\n (_: unknown, method: string) => method,\n (jsonRpcMocks, method) => jsonRpcMocks[method],\n);\n"]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkK2KTKFLPjs = require('./chunk-K2KTKFLP.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkON6M4WG5js = require('./chunk-ON6M4WG5.js');
|
|
8
|
+
|
|
9
|
+
// src/internals/request.ts
|
|
10
|
+
var _snapsutils = require('@metamask/snaps-utils');
|
|
11
|
+
var _utils = require('@metamask/utils');
|
|
12
|
+
var _toolkit = require('@reduxjs/toolkit');
|
|
13
|
+
function handleRequest({
|
|
14
|
+
snapId,
|
|
15
|
+
store,
|
|
16
|
+
executionService,
|
|
17
|
+
handler,
|
|
18
|
+
controllerMessenger,
|
|
19
|
+
runSaga,
|
|
20
|
+
request: { id = _toolkit.nanoid.call(void 0, ), origin = "https://metamask.io", ...options }
|
|
21
|
+
}) {
|
|
22
|
+
const promise = executionService.handleRpcRequest(snapId, {
|
|
23
|
+
origin,
|
|
24
|
+
handler,
|
|
25
|
+
request: {
|
|
26
|
+
jsonrpc: "2.0",
|
|
27
|
+
id: 1,
|
|
28
|
+
...options
|
|
29
|
+
}
|
|
30
|
+
}).then((result) => {
|
|
31
|
+
const notifications = _chunkON6M4WG5js.getNotifications.call(void 0, store.getState());
|
|
32
|
+
store.dispatch(_chunkON6M4WG5js.clearNotifications.call(void 0, ));
|
|
33
|
+
const content = getContentFromResult(result, snapId, controllerMessenger);
|
|
34
|
+
return {
|
|
35
|
+
id: String(id),
|
|
36
|
+
response: {
|
|
37
|
+
result: _utils.getSafeJson.call(void 0, result)
|
|
38
|
+
},
|
|
39
|
+
notifications,
|
|
40
|
+
content
|
|
41
|
+
};
|
|
42
|
+
}).catch((error) => {
|
|
43
|
+
const [unwrappedError] = _snapsutils.unwrapError.call(void 0, error);
|
|
44
|
+
return {
|
|
45
|
+
id: String(id),
|
|
46
|
+
response: {
|
|
47
|
+
error: unwrappedError.serialize()
|
|
48
|
+
},
|
|
49
|
+
notifications: []
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
promise.getInterface = async () => {
|
|
53
|
+
return await runSaga(
|
|
54
|
+
_chunkK2KTKFLPjs.getInterface,
|
|
55
|
+
runSaga,
|
|
56
|
+
snapId,
|
|
57
|
+
controllerMessenger
|
|
58
|
+
).toPromise();
|
|
59
|
+
};
|
|
60
|
+
return promise;
|
|
61
|
+
}
|
|
62
|
+
function getContentFromResult(result, snapId, controllerMessenger) {
|
|
63
|
+
if (_utils.isPlainObject.call(void 0, result) && _utils.hasProperty.call(void 0, result, "id")) {
|
|
64
|
+
return controllerMessenger.call(
|
|
65
|
+
"SnapInterfaceController:getInterface",
|
|
66
|
+
snapId,
|
|
67
|
+
result.id
|
|
68
|
+
).content;
|
|
69
|
+
}
|
|
70
|
+
if (_utils.isPlainObject.call(void 0, result) && _utils.hasProperty.call(void 0, result, "content")) {
|
|
71
|
+
return result.content;
|
|
72
|
+
}
|
|
73
|
+
return void 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
exports.handleRequest = handleRequest; exports.getContentFromResult = getContentFromResult;
|
|
80
|
+
//# sourceMappingURL=chunk-3CC2NI7R.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/internals/request.ts"],"names":[],"mappings":";;;;;;;;;AAGA,SAAS,mBAAmB;AAC5B,SAAS,aAAa,aAAa,qBAAqB;AACxD,SAAS,cAAc;AAyChB,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS,EAAE,KAAK,OAAO,GAAG,SAAS,uBAAuB,GAAG,QAAQ;AACvE,GAAsC;AACpC,QAAM,UAAU,iBACb,iBAAiB,QAAQ;AAAA,IACxB;AAAA,IACA;AAAA,IACA,SAAS;AAAA,MACP,SAAS;AAAA,MACT,IAAI;AAAA,MACJ,GAAG;AAAA,IACL;AAAA,EACF,CAAC,EACA,KAAK,CAAC,WAAW;AAChB,UAAM,gBAAgB,iBAAiB,MAAM,SAAS,CAAC;AACvD,UAAM,SAAS,mBAAmB,CAAC;AAEnC,UAAM,UAAU,qBAAqB,QAAQ,QAAQ,mBAAmB;AAExE,WAAO;AAAA,MACL,IAAI,OAAO,EAAE;AAAA,MACb,UAAU;AAAA,QACR,QAAQ,YAAY,MAAM;AAAA,MAC5B;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC,EACA,MAAM,CAAC,UAAU;AAChB,UAAM,CAAC,cAAc,IAAI,YAAY,KAAK;AAE1C,WAAO;AAAA,MACL,IAAI,OAAO,EAAE;AAAA,MACb,UAAU;AAAA,QACR,OAAO,eAAe,UAAU;AAAA,MAClC;AAAA,MACA,eAAe,CAAC;AAAA,IAClB;AAAA,EACF,CAAC;AAEH,UAAQ,eAAe,YAAY;AACjC,WAAO,MAAM;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,EAAE,UAAU;AAAA,EACd;AAEA,SAAO;AACT;AAUO,SAAS,qBACd,QACA,QACA,qBACuB;AACvB,MAAI,cAAc,MAAM,KAAK,YAAY,QAAQ,IAAI,GAAG;AACtD,WAAO,oBAAoB;AAAA,MACzB;AAAA,MACA;AAAA,MACA,OAAO;AAAA,IACT,EAAE;AAAA,EACJ;AAEA,MAAI,cAAc,MAAM,KAAK,YAAY,QAAQ,SAAS,GAAG;AAC3D,WAAO,OAAO;AAAA,EAChB;AAEA,SAAO;AACT","sourcesContent":["import type { AbstractExecutionService } from '@metamask/snaps-controllers';\nimport type { SnapId, Component } from '@metamask/snaps-sdk';\nimport type { HandlerType } from '@metamask/snaps-utils';\nimport { unwrapError } from '@metamask/snaps-utils';\nimport { getSafeJson, hasProperty, isPlainObject } from '@metamask/utils';\nimport { nanoid } from '@reduxjs/toolkit';\n\nimport type { RequestOptions, SnapRequest } from '../types';\nimport {\n clearNotifications,\n getInterface,\n getNotifications,\n} from './simulation';\nimport type { RunSagaFunction, Store } from './simulation';\nimport type { RootControllerMessenger } from './simulation/controllers';\n\nexport type HandleRequestOptions = {\n snapId: SnapId;\n store: Store;\n executionService: AbstractExecutionService<unknown>;\n handler: HandlerType;\n controllerMessenger: RootControllerMessenger;\n runSaga: RunSagaFunction;\n request: RequestOptions;\n};\n\n/**\n * Send a JSON-RPC request to the Snap, and wrap the response in a\n * {@link SnapResponse} object.\n *\n * @param options - The request options.\n * @param options.snapId - The ID of the Snap to send the request to.\n * @param options.store - The Redux store.\n * @param options.executionService - The execution service to use to send the\n * request.\n * @param options.handler - The handler to use to send the request.\n * @param options.controllerMessenger - The controller messenger used to call actions.\n * @param options.runSaga - A function to run a saga outside the usual Redux\n * flow.\n * @param options.request - The request to send.\n * @param options.request.id - The ID of the request. If not provided, a random\n * ID will be generated.\n * @param options.request.origin - The origin of the request. Defaults to\n * `https://metamask.io`.\n * @returns The response, wrapped in a {@link SnapResponse} object.\n */\nexport function handleRequest({\n snapId,\n store,\n executionService,\n handler,\n controllerMessenger,\n runSaga,\n request: { id = nanoid(), origin = 'https://metamask.io', ...options },\n}: HandleRequestOptions): SnapRequest {\n const promise = executionService\n .handleRpcRequest(snapId, {\n origin,\n handler,\n request: {\n jsonrpc: '2.0',\n id: 1,\n ...options,\n },\n })\n .then((result) => {\n const notifications = getNotifications(store.getState());\n store.dispatch(clearNotifications());\n\n const content = getContentFromResult(result, snapId, controllerMessenger);\n\n return {\n id: String(id),\n response: {\n result: getSafeJson(result),\n },\n notifications,\n content,\n };\n })\n .catch((error) => {\n const [unwrappedError] = unwrapError(error);\n\n return {\n id: String(id),\n response: {\n error: unwrappedError.serialize(),\n },\n notifications: [],\n };\n }) as unknown as SnapRequest;\n\n promise.getInterface = async () => {\n return await runSaga(\n getInterface,\n runSaga,\n snapId,\n controllerMessenger,\n ).toPromise();\n };\n\n return promise;\n}\n\n/**\n * Get the response content either from the SnapInterfaceController or the response object if there is one.\n *\n * @param result - The handler result object.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger.\n * @returns The content components if any.\n */\nexport function getContentFromResult(\n result: unknown,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n): Component | undefined {\n if (isPlainObject(result) && hasProperty(result, 'id')) {\n return controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n result.id as string,\n ).content;\n }\n\n if (isPlainObject(result) && hasProperty(result, 'content')) {\n return result.content as Component;\n }\n\n return undefined;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-3IUQA6YL.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunk4WCFXE73js = require('./chunk-4WCFXE73.js');
|
|
6
|
+
|
|
7
|
+
// src/internals/simulation/methods/hooks/state.ts
|
|
8
|
+
var _effects = require('redux-saga/effects');
|
|
9
|
+
function* getSnapStateImplementation(_snapId, encrypted = true) {
|
|
10
|
+
return yield _effects.select.call(void 0, _chunk4WCFXE73js.getState.call(void 0, encrypted));
|
|
11
|
+
}
|
|
12
|
+
function getGetSnapStateMethodImplementation(runSaga) {
|
|
13
|
+
return (...args) => {
|
|
14
|
+
return runSaga(getSnapStateImplementation, ...args).result();
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function* updateSnapStateImplementation(_snapId, newState, encrypted = true) {
|
|
18
|
+
yield _effects.put.call(void 0, _chunk4WCFXE73js.setState.call(void 0, { state: newState, encrypted }));
|
|
19
|
+
}
|
|
20
|
+
function getUpdateSnapStateMethodImplementation(runSaga) {
|
|
21
|
+
return (...args) => {
|
|
22
|
+
runSaga(updateSnapStateImplementation, ...args).result();
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function* clearSnapStateImplementation(_snapId, encrypted = true) {
|
|
26
|
+
yield _effects.put.call(void 0, _chunk4WCFXE73js.clearState.call(void 0, { encrypted }));
|
|
27
|
+
}
|
|
28
|
+
function getClearSnapStateMethodImplementation(runSaga) {
|
|
29
|
+
return async (...args) => {
|
|
30
|
+
runSaga(clearSnapStateImplementation, ...args).result();
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
exports.getGetSnapStateMethodImplementation = getGetSnapStateMethodImplementation; exports.getUpdateSnapStateMethodImplementation = getUpdateSnapStateMethodImplementation; exports.getClearSnapStateMethodImplementation = getClearSnapStateMethodImplementation;
|
|
39
|
+
//# sourceMappingURL=chunk-3KCEPGJA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/internals/simulation/methods/hooks/state.ts"],"names":[],"mappings":";;;;;;;AACA,SAAS,KAAK,cAAc;AAe5B,UAAU,2BACR,SACA,YAAY,MACU;AACtB,SAAO,MAAM,OAAO,SAAS,SAAS,CAAC;AACzC;AAQO,SAAS,oCAAoC,SAA0B;AAC5E,SAAO,IAAI,SAAwD;AACjE,WAAO,QAAQ,4BAA4B,GAAG,IAAI,EAAE,OAAO;AAAA,EAC7D;AACF;AAYA,UAAU,8BACR,SACA,UACA,YAAY,MACQ;AACpB,QAAM,IAAI,SAAS,EAAE,OAAO,UAAU,UAAU,CAAC,CAAC;AACpD;AAQO,SAAS,uCACd,SACA;AACA,SAAO,IAAI,SAA2D;AACpE,YAAQ,+BAA+B,GAAG,IAAI,EAAE,OAAO;AAAA,EACzD;AACF;AAWA,UAAU,6BACR,SACA,YAAY,MACQ;AACpB,QAAM,IAAI,WAAW,EAAE,UAAU,CAAC,CAAC;AACrC;AAQO,SAAS,sCACd,SACA;AACA,SAAO,UAAU,SAA0D;AACzE,YAAQ,8BAA8B,GAAG,IAAI,EAAE,OAAO;AAAA,EACxD;AACF","sourcesContent":["import type { SagaIterator } from 'redux-saga';\nimport { put, select } from 'redux-saga/effects';\n\nimport type { RunSagaFunction } from '../../store';\nimport { clearState, getState, setState } from '../../store';\n\n/**\n * Get the Snap state from the store.\n *\n * @param _snapId - The ID of the Snap to get the state for. This is ignored\n * because the simulator only supports one Snap.\n * @param encrypted - Whether to get the encrypted or unencrypted state.\n * Defaults to encrypted state.\n * @returns The state of the Snap.\n * @yields Selects the state from the store.\n */\nfunction* getSnapStateImplementation(\n _snapId: string,\n encrypted = true,\n): SagaIterator<string> {\n return yield select(getState(encrypted));\n}\n\n/**\n * Get the implementation of the `getSnapState` hook.\n *\n * @param runSaga - The function to run a saga outside the usual Redux flow.\n * @returns The implementation of the `getSnapState` hook.\n */\nexport function getGetSnapStateMethodImplementation(runSaga: RunSagaFunction) {\n return (...args: Parameters<typeof getSnapStateImplementation>) => {\n return runSaga(getSnapStateImplementation, ...args).result();\n };\n}\n\n/**\n * Update the Snap state in the store.\n *\n * @param _snapId - The ID of the Snap to update the state for. This is ignored\n * because the simulator only supports one Snap.\n * @param newState - The new state.\n * @param encrypted - Whether to update the encrypted or unencrypted state.\n * Defaults to encrypted state.\n * @yields Puts the new state in the store.\n */\nfunction* updateSnapStateImplementation(\n _snapId: string,\n newState: string,\n encrypted = true,\n): SagaIterator<void> {\n yield put(setState({ state: newState, encrypted }));\n}\n\n/**\n * Get the implementation of the `updateSnapState` hook.\n *\n * @param runSaga - The function to run a saga outside the usual Redux flow.\n * @returns The implementation of the `updateSnapState` hook.\n */\nexport function getUpdateSnapStateMethodImplementation(\n runSaga: RunSagaFunction,\n) {\n return (...args: Parameters<typeof updateSnapStateImplementation>) => {\n runSaga(updateSnapStateImplementation, ...args).result();\n };\n}\n\n/**\n * Clear the Snap state in the store.\n *\n * @param _snapId - The ID of the Snap to clear the state for. This is ignored\n * because the simulator only supports one Snap.\n * @param encrypted - Whether to clear the encrypted or unencrypted state.\n * Defaults to encrypted state.\n * @yields Puts the new state in the store.\n */\nfunction* clearSnapStateImplementation(\n _snapId: string,\n encrypted = true,\n): SagaIterator<void> {\n yield put(clearState({ encrypted }));\n}\n\n/**\n * Get the implementation of the `clearSnapState` hook.\n *\n * @param runSaga - The function to run a saga outside the usual Redux flow.\n * @returns The implementation of the `clearSnapState` hook.\n */\nexport function getClearSnapStateMethodImplementation(\n runSaga: RunSagaFunction,\n) {\n return async (...args: Parameters<typeof clearSnapStateImplementation>) => {\n runSaga(clearSnapStateImplementation, ...args).result();\n };\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunk34GS3AHAjs = require('./chunk-34GS3AHA.js');
|
|
4
|
+
|
|
5
|
+
// src/internals/simulation/middleware/mock.ts
|
|
6
|
+
function createMockMiddleware(store) {
|
|
7
|
+
return function mockMiddleware(request, response, next, end) {
|
|
8
|
+
const result = _chunk34GS3AHAjs.getJsonRpcMock.call(void 0, store.getState(), request.method);
|
|
9
|
+
if (result) {
|
|
10
|
+
response.result = result;
|
|
11
|
+
return end();
|
|
12
|
+
}
|
|
13
|
+
return next();
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
exports.createMockMiddleware = createMockMiddleware;
|
|
20
|
+
//# sourceMappingURL=chunk-3KQYPQZY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/internals/simulation/middleware/mock.ts"],"names":[],"mappings":";;;;;AAYO,SAAS,qBACd,OACwC;AACxC,SAAO,SAAS,eAAe,SAAS,UAAU,MAAM,KAAK;AAC3D,UAAM,SAAS,eAAe,MAAM,SAAS,GAAG,QAAQ,MAAM;AAC9D,QAAI,QAAQ;AACV,eAAS,SAAS;AAClB,aAAO,IAAI;AAAA,IACb;AAEA,WAAO,KAAK;AAAA,EACd;AACF","sourcesContent":["import type { JsonRpcMiddleware } from '@metamask/json-rpc-engine';\nimport type { Json, JsonRpcParams } from '@metamask/utils';\n\nimport type { Store } from '../store';\nimport { getJsonRpcMock } from '../store/mocks';\n\n/**\n * Create a middleware for handling JSON-RPC methods that have been mocked.\n *\n * @param store - The Redux store to use.\n * @returns A middleware function.\n */\nexport function createMockMiddleware(\n store: Store,\n): JsonRpcMiddleware<JsonRpcParams, Json> {\n return function mockMiddleware(request, response, next, end) {\n const result = getJsonRpcMock(store.getState(), request.method);\n if (result) {\n response.result = result;\n return end();\n }\n\n return next();\n };\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/internals/simulation/files.ts
|
|
2
|
+
var _snapssdk = require('@metamask/snaps-sdk');
|
|
3
|
+
var _snapsutils = require('@metamask/snaps-utils');
|
|
4
|
+
async function getSnapFile(files, path, encoding = _snapssdk.AuxiliaryFileEncoding.Base64) {
|
|
5
|
+
const normalizedPath = _snapsutils.normalizeRelative.call(void 0, path);
|
|
6
|
+
const base64 = _optionalChain([files, 'access', _ => _.find, 'call', _2 => _2((file) => file.path === normalizedPath), 'optionalAccess', _3 => _3.toString, 'call', _4 => _4("base64")]);
|
|
7
|
+
if (!base64) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return await _snapsutils.encodeAuxiliaryFile.call(void 0, base64, encoding);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
exports.getSnapFile = getSnapFile;
|
|
16
|
+
//# sourceMappingURL=chunk-3O5OISLU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/internals/simulation/files.ts"],"names":[],"mappings":";AAAA,SAAS,6BAA6B;AAEtC,SAAS,qBAAqB,yBAAyB;AAUvD,eAAsB,YACpB,OACA,MACA,WAAkC,sBAAsB,QACxD;AACA,QAAM,iBAAiB,kBAAkB,IAAI;AAC7C,QAAM,SAAS,MACZ,KAAK,CAAC,SAAS,KAAK,SAAS,cAAc,GAC1C,SAAS,QAAQ;AAErB,MAAI,CAAC,QAAQ;AACX,WAAO;AAAA,EACT;AAEA,SAAO,MAAM,oBAAoB,QAAQ,QAAQ;AACnD","sourcesContent":["import { AuxiliaryFileEncoding } from '@metamask/snaps-sdk';\nimport type { VirtualFile } from '@metamask/snaps-utils';\nimport { encodeAuxiliaryFile, normalizeRelative } from '@metamask/snaps-utils';\n\n/**\n * Get a statically defined Snap file from an array of files.\n *\n * @param files - The Snap files.\n * @param path - The file path.\n * @param encoding - The requested file encoding.\n * @returns The file in the requested encoding if found, otherwise null.\n */\nexport async function getSnapFile(\n files: VirtualFile[],\n path: string,\n encoding: AuxiliaryFileEncoding = AuxiliaryFileEncoding.Base64,\n) {\n const normalizedPath = normalizeRelative(path);\n const base64 = files\n .find((file) => file.path === normalizedPath)\n ?.toString('base64');\n\n if (!base64) {\n return null;\n }\n\n return await encodeAuxiliaryFile(base64, encoding);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";//# sourceMappingURL=chunk-3ZW2EE3B.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkRQBZLDXLjs = require('./chunk-RQBZLDXL.js');
|
|
5
|
+
|
|
6
|
+
// src/matchers.ts
|
|
7
|
+
var _globals = require('@jest/globals');
|
|
8
|
+
var _utils = require('@metamask/utils');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
var _jestmatcherutils = require('jest-matcher-utils');
|
|
17
|
+
var _superstruct = require('superstruct');
|
|
18
|
+
function assertActualIsSnapResponse(actual, matcherName, options) {
|
|
19
|
+
if (!_superstruct.is.call(void 0, actual, _chunkRQBZLDXLjs.SnapResponseStruct)) {
|
|
20
|
+
throw new Error(
|
|
21
|
+
_jestmatcherutils.matcherErrorMessage.call(void 0,
|
|
22
|
+
_jestmatcherutils.matcherHint.call(void 0, matcherName, void 0, void 0, options),
|
|
23
|
+
`${_jestmatcherutils.RECEIVED_COLOR.call(void 0,
|
|
24
|
+
"received"
|
|
25
|
+
)} value must be a response from the \`request\` function`,
|
|
26
|
+
_jestmatcherutils.printWithType.call(void 0, "Received", actual, _jestmatcherutils.printReceived)
|
|
27
|
+
)
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function assertHasInterface(actual, matcherName, options) {
|
|
32
|
+
if (!_superstruct.is.call(void 0, actual, _chunkRQBZLDXLjs.InterfaceStruct) || !actual.content) {
|
|
33
|
+
throw new Error(
|
|
34
|
+
_jestmatcherutils.matcherErrorMessage.call(void 0,
|
|
35
|
+
_jestmatcherutils.matcherHint.call(void 0, matcherName, void 0, void 0, options),
|
|
36
|
+
`${_jestmatcherutils.RECEIVED_COLOR.call(void 0, "received")} value must have a \`content\` property`,
|
|
37
|
+
_jestmatcherutils.printWithType.call(void 0, "Received", actual, _jestmatcherutils.printReceived)
|
|
38
|
+
)
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
var toRespondWith = function(actual, expected) {
|
|
43
|
+
assertActualIsSnapResponse(actual, "toRespondWith");
|
|
44
|
+
const { response } = actual;
|
|
45
|
+
if (_utils.hasProperty.call(void 0, response, "error")) {
|
|
46
|
+
const message2 = () => `${this.utils.matcherHint(".toRespondWith")}
|
|
47
|
+
|
|
48
|
+
Expected response: ${this.utils.printExpected(expected)}
|
|
49
|
+
Received error: ${this.utils.printReceived(response.error)}`;
|
|
50
|
+
return { message: message2, pass: false };
|
|
51
|
+
}
|
|
52
|
+
const pass = this.equals(response.result, expected);
|
|
53
|
+
const message = pass ? () => `${this.utils.matcherHint(".not.toRespondWith")}
|
|
54
|
+
|
|
55
|
+
Expected: ${this.utils.printExpected(expected)}
|
|
56
|
+
Received: ${this.utils.printReceived(response.result)}` : () => `${this.utils.matcherHint(".toRespondWith")}
|
|
57
|
+
|
|
58
|
+
Expected: ${this.utils.printExpected(expected)}
|
|
59
|
+
Received: ${this.utils.printReceived(response.result)}`;
|
|
60
|
+
return { message, pass };
|
|
61
|
+
};
|
|
62
|
+
var toRespondWithError = function(actual, expected) {
|
|
63
|
+
assertActualIsSnapResponse(actual, "toRespondWithError");
|
|
64
|
+
const { response } = actual;
|
|
65
|
+
if (_utils.hasProperty.call(void 0, response, "result")) {
|
|
66
|
+
const message2 = () => `${this.utils.matcherHint(".toRespondWithError")}
|
|
67
|
+
|
|
68
|
+
Expected error: ${this.utils.printExpected(expected)}
|
|
69
|
+
Received result: ${this.utils.printReceived(response.result)}`;
|
|
70
|
+
return { message: message2, pass: false };
|
|
71
|
+
}
|
|
72
|
+
const pass = this.equals(response.error, expected);
|
|
73
|
+
const message = pass ? () => `${this.utils.matcherHint(".not.toRespondWithError")}
|
|
74
|
+
|
|
75
|
+
Expected: ${this.utils.printExpected(expected)}
|
|
76
|
+
Received: ${this.utils.printReceived(response.error)}` : () => `${this.utils.matcherHint(".toRespondWithError")}
|
|
77
|
+
|
|
78
|
+
Expected: ${this.utils.printExpected(expected)}
|
|
79
|
+
Received: ${this.utils.printReceived(response.error)}`;
|
|
80
|
+
return { message, pass };
|
|
81
|
+
};
|
|
82
|
+
var toSendNotification = function(actual, expected, type) {
|
|
83
|
+
assertActualIsSnapResponse(actual, "toSendNotification");
|
|
84
|
+
const { notifications } = actual;
|
|
85
|
+
const pass = notifications.some(
|
|
86
|
+
(notification) => this.equals(notification.message, expected) && (type === void 0 || notification.type === type)
|
|
87
|
+
);
|
|
88
|
+
const message = pass ? () => `${this.utils.matcherHint(".not.toSendNotification")}
|
|
89
|
+
|
|
90
|
+
Expected: ${this.utils.printExpected(expected)}
|
|
91
|
+
Expected type: ${this.utils.printExpected(type)}
|
|
92
|
+
Received: ${this.utils.printReceived(notifications)}` : () => `${this.utils.matcherHint(".toSendNotification")}
|
|
93
|
+
|
|
94
|
+
Expected: ${this.utils.printExpected(expected)}
|
|
95
|
+
Expected type: ${this.utils.printExpected(type)}
|
|
96
|
+
Received: ${this.utils.printReceived(notifications)}`;
|
|
97
|
+
return { message, pass };
|
|
98
|
+
};
|
|
99
|
+
var toRender = function(actual, expected) {
|
|
100
|
+
assertHasInterface(actual, "toRender");
|
|
101
|
+
const { content } = actual;
|
|
102
|
+
const pass = this.equals(content, expected);
|
|
103
|
+
const difference = _jestmatcherutils.diff.call(void 0, expected, content);
|
|
104
|
+
const message = pass ? () => `${this.utils.matcherHint(".not.toRender")}
|
|
105
|
+
|
|
106
|
+
Expected: ${this.utils.printExpected(expected)}
|
|
107
|
+
Received: ${this.utils.printReceived(content)}
|
|
108
|
+
|
|
109
|
+
Difference:
|
|
110
|
+
|
|
111
|
+
${difference}` : () => `${this.utils.matcherHint(".toRender")}
|
|
112
|
+
|
|
113
|
+
Expected: ${this.utils.printExpected(expected)}
|
|
114
|
+
Received: ${this.utils.printReceived(content)}
|
|
115
|
+
|
|
116
|
+
Difference:
|
|
117
|
+
|
|
118
|
+
${difference}`;
|
|
119
|
+
return { message, pass };
|
|
120
|
+
};
|
|
121
|
+
_globals.expect.extend({
|
|
122
|
+
toRespondWith,
|
|
123
|
+
toRespondWithError,
|
|
124
|
+
toSendNotification,
|
|
125
|
+
toRender
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
exports.toRespondWith = toRespondWith; exports.toRespondWithError = toRespondWithError; exports.toSendNotification = toSendNotification; exports.toRender = toRender;
|
|
134
|
+
//# sourceMappingURL=chunk-4FCRZDOX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/matchers.ts"],"names":["message"],"mappings":";;;;;;AAMA,SAAS,cAAc;AAOvB,SAAS,mBAAmB;AAE5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,UAAU;AAYnB,SAAS,2BACP,QACA,aACA,SACgC;AAChC,MAAI,CAAC,GAAG,QAAQ,kBAAkB,GAAG;AACnC,UAAM,IAAI;AAAA,MACR;AAAA,QACE,YAAY,aAAa,QAAW,QAAW,OAAO;AAAA,QACtD,GAAG;AAAA,UACD;AAAA,QACF,CAAC;AAAA,QACD,cAAc,YAAY,QAAQ,aAAa;AAAA,MACjD;AAAA,IACF;AAAA,EACF;AACF;AAUA,SAAS,mBACP,QACA,aACA,SAC0C;AAC1C,MAAI,CAAC,GAAG,QAAQ,eAAe,KAAK,CAAC,OAAO,SAAS;AACnD,UAAM,IAAI;AAAA,MACR;AAAA,QACE,YAAY,aAAa,QAAW,QAAW,OAAO;AAAA,QACtD,GAAG,eAAe,UAAU,CAAC;AAAA,QAC7B,cAAc,YAAY,QAAQ,aAAa;AAAA,MACjD;AAAA,IACF;AAAA,EACF;AACF;AAUO,IAAM,gBAAmD,SAC9D,QACA,UACA;AACA,6BAA2B,QAAQ,eAAe;AAElD,QAAM,EAAE,SAAS,IAAI;AACrB,MAAI,YAAY,UAAU,OAAO,GAAG;AAClC,UAAMA,WAAU,MACd,GAAG,KAAK,MAAM,YAAY,gBAAgB,CAAC;AAAA;AAAA,qBACrB,KAAK,MAAM,cAAc,QAAQ,CAAC;AAAA,kBACrC,KAAK,MAAM,cAAc,SAAS,KAAK,CAAC;AAE7D,WAAO,EAAE,SAAAA,UAAS,MAAM,MAAM;AAAA,EAChC;AAEA,QAAM,OAAO,KAAK,OAAO,SAAS,QAAQ,QAAQ;AAClD,QAAM,UAAU,OACZ,MACE,GAAG,KAAK,MAAM,YAAY,oBAAoB,CAAC;AAAA;AAAA,YAClC,KAAK,MAAM,cAAc,QAAQ,CAAC;AAAA,YAClC,KAAK,MAAM,cAAc,SAAS,MAAM,CAAC,KACxD,MACE,GAAG,KAAK,MAAM,YAAY,gBAAgB,CAAC;AAAA;AAAA,YAC9B,KAAK,MAAM,cAAc,QAAQ,CAAC;AAAA,YAClC,KAAK,MAAM,cAAc,SAAS,MAAM,CAAC;AAE5D,SAAO,EAAE,SAAS,KAAK;AACzB;AAEO,IAAM,qBAAwD,SACnE,QACA,UACA;AACA,6BAA2B,QAAQ,oBAAoB;AAEvD,QAAM,EAAE,SAAS,IAAI;AACrB,MAAI,YAAY,UAAU,QAAQ,GAAG;AACnC,UAAMA,WAAU,MACd,GAAG,KAAK,MAAM,YAAY,qBAAqB,CAAC;AAAA;AAAA,kBAC7B,KAAK,MAAM,cAAc,QAAQ,CAAC;AAAA,mBACjC,KAAK,MAAM,cAAc,SAAS,MAAM,CAAC;AAE/D,WAAO,EAAE,SAAAA,UAAS,MAAM,MAAM;AAAA,EAChC;AAEA,QAAM,OAAO,KAAK,OAAO,SAAS,OAAO,QAAQ;AACjD,QAAM,UAAU,OACZ,MACE,GAAG,KAAK,MAAM,YAAY,yBAAyB,CAAC;AAAA;AAAA,YACvC,KAAK,MAAM,cAAc,QAAQ,CAAC;AAAA,YAClC,KAAK,MAAM,cAAc,SAAS,KAAK,CAAC,KACvD,MACE,GAAG,KAAK,MAAM,YAAY,qBAAqB,CAAC;AAAA;AAAA,YACnC,KAAK,MAAM,cAAc,QAAQ,CAAC;AAAA,YAClC,KAAK,MAAM,cAAc,SAAS,KAAK,CAAC;AAE3D,SAAO,EAAE,SAAS,KAAK;AACzB;AAWO,IAAM,qBAET,SAAU,QAAQ,UAAU,MAAM;AACpC,6BAA2B,QAAQ,oBAAoB;AAEvD,QAAM,EAAE,cAAc,IAAI;AAC1B,QAAM,OAAO,cAAc;AAAA,IACzB,CAAC,iBACC,KAAK,OAAO,aAAa,SAAS,QAAQ,MACzC,SAAS,UAAa,aAAa,SAAS;AAAA,EACjD;AAEA,QAAM,UAAU,OACZ,MACE,GAAG,KAAK,MAAM,YAAY,yBAAyB,CAAC;AAAA;AAAA,YACvC,KAAK,MAAM,cAAc,QAAQ,CAAC;AAAA,iBAC7B,KAAK,MAAM,cAAc,IAAI,CAAC;AAAA,YACnC,KAAK,MAAM,cAAc,aAAa,CAAC,KACtD,MACE,GAAG,KAAK,MAAM,YAAY,qBAAqB,CAAC;AAAA;AAAA,YACnC,KAAK,MAAM,cAAc,QAAQ,CAAC;AAAA,iBAC7B,KAAK,MAAM,cAAc,IAAI,CAAC;AAAA,YACnC,KAAK,MAAM,cAAc,aAAa,CAAC;AAE1D,SAAO,EAAE,SAAS,KAAK;AACzB;AAEO,IAAM,WAAmD,SAC9D,QACA,UACA;AACA,qBAAmB,QAAQ,UAAU;AAErC,QAAM,EAAE,QAAQ,IAAI;AACpB,QAAM,OAAO,KAAK,OAAO,SAAS,QAAQ;AAK1C,QAAM,aAAa,KAAK,UAAU,OAAO;AAEzC,QAAM,UAAU,OACZ,MACE,GAAG,KAAK,MAAM,YAAY,eAAe,CAAC;AAAA;AAAA,YAC7B,KAAK,MAAM,cAAc,QAAQ,CAAC;AAAA,YAClC,KAAK,MAAM,cAAc,OAAO,CAAC;AAAA;AAAA;AAAA;AAAA,EACxB,UAAoB,KAC5C,MACE,GAAG,KAAK,MAAM,YAAY,WAAW,CAAC;AAAA;AAAA,YACzB,KAAK,MAAM,cAAc,QAAQ,CAAC;AAAA,YAClC,KAAK,MAAM,cAAc,OAAO,CAAC;AAAA;AAAA;AAAA;AAAA,EACxB,UAAoB;AAEhD,SAAO,EAAE,SAAS,KAAK;AACzB;AAEA,OAAO,OAAO;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,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 Component,\n} from '@metamask/snaps-sdk';\nimport type { Json } from '@metamask/utils';\nimport { hasProperty } from '@metamask/utils';\nimport type { MatcherHintOptions } from 'jest-matcher-utils';\nimport {\n diff,\n matcherErrorMessage,\n matcherHint,\n printReceived,\n printWithType,\n RECEIVED_COLOR,\n} from 'jest-matcher-utils';\nimport { is } from 'superstruct';\n\nimport { InterfaceStruct, SnapResponseStruct } from './internals';\nimport type { SnapResponse } from './types';\n\n/**\n * Ensure that the actual value is a response from the `request` function.\n *\n * @param actual - The actual value.\n * @param matcherName - The name of the matcher.\n * @param options - The matcher options.\n */\nfunction assertActualIsSnapResponse(\n actual: unknown,\n matcherName: string,\n options?: MatcherHintOptions,\n): asserts actual is SnapResponse {\n if (!is(actual, SnapResponseStruct)) {\n throw new Error(\n matcherErrorMessage(\n matcherHint(matcherName, undefined, undefined, options),\n `${RECEIVED_COLOR(\n 'received',\n )} value must be a response from the \\`request\\` function`,\n printWithType('Received', actual, printReceived),\n ),\n );\n }\n}\n\n/**\n * Ensure that the actual value is a response from the `request` function, and\n * that it has a `ui` property.\n *\n * @param actual - The actual value.\n * @param matcherName - The name of the matcher.\n * @param options - The matcher options.\n */\nfunction assertHasInterface(\n actual: unknown,\n matcherName: string,\n options?: MatcherHintOptions,\n): asserts actual is { content: Component } {\n if (!is(actual, InterfaceStruct) || !actual.content) {\n throw new Error(\n matcherErrorMessage(\n matcherHint(matcherName, undefined, undefined, options),\n `${RECEIVED_COLOR('received')} value must have a \\`content\\` property`,\n printWithType('Received', actual, printReceived),\n ),\n );\n }\n}\n\n/**\n * Check if a JSON-RPC response matches the expected value. This matcher is\n * intended to be used with the `expect` global.\n *\n * @param actual - The actual response.\n * @param expected - The expected response.\n * @returns The status and message.\n */\nexport const toRespondWith: MatcherFunction<[expected: Json]> = function (\n actual,\n expected,\n) {\n assertActualIsSnapResponse(actual, 'toRespondWith');\n\n const { response } = actual;\n if (hasProperty(response, 'error')) {\n const message = () =>\n `${this.utils.matcherHint('.toRespondWith')}\\n\\n` +\n `Expected response: ${this.utils.printExpected(expected)}\\n` +\n `Received error: ${this.utils.printReceived(response.error)}`;\n\n return { message, pass: false };\n }\n\n const pass = this.equals(response.result, expected);\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRespondWith')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.result)}`\n : () =>\n `${this.utils.matcherHint('.toRespondWith')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.result)}`;\n\n return { message, pass };\n};\n\nexport const toRespondWithError: MatcherFunction<[expected: Json]> = function (\n actual,\n expected,\n) {\n assertActualIsSnapResponse(actual, 'toRespondWithError');\n\n const { response } = actual;\n if (hasProperty(response, 'result')) {\n const message = () =>\n `${this.utils.matcherHint('.toRespondWithError')}\\n\\n` +\n `Expected error: ${this.utils.printExpected(expected)}\\n` +\n `Received result: ${this.utils.printReceived(response.result)}`;\n\n return { message, pass: false };\n }\n\n const pass = this.equals(response.error, expected);\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRespondWithError')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.error)}`\n : () =>\n `${this.utils.matcherHint('.toRespondWithError')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.error)}`;\n\n return { message, pass };\n};\n\n/**\n * Check if the snap sent a notification with the expected message. This matcher\n * is intended to be used with the `expect` global.\n *\n * @param actual - The actual response.\n * @param expected - The expected notification message.\n * @param type - The expected notification type.\n * @returns The status and message.\n */\nexport const toSendNotification: MatcherFunction<\n [expected: string, type?: EnumToUnion<NotificationType> | undefined]\n> = function (actual, expected, type) {\n assertActualIsSnapResponse(actual, 'toSendNotification');\n\n const { notifications } = actual;\n const pass = notifications.some(\n (notification) =>\n this.equals(notification.message, expected) &&\n (type === undefined || notification.type === type),\n );\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toSendNotification')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Expected type: ${this.utils.printExpected(type)}\\n` +\n `Received: ${this.utils.printReceived(notifications)}`\n : () =>\n `${this.utils.matcherHint('.toSendNotification')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Expected type: ${this.utils.printExpected(type)}\\n` +\n `Received: ${this.utils.printReceived(notifications)}`;\n\n return { message, pass };\n};\n\nexport const toRender: MatcherFunction<[expected: Component]> = function (\n actual,\n expected,\n) {\n assertHasInterface(actual, 'toRender');\n\n const { content } = actual;\n const pass = this.equals(content, expected);\n\n // This is typed as `string | null`, but in practice it's always a string. The\n // function only returns `null` if both the expected and actual values are\n // numbers, bigints, or booleans, which is never the case here.\n const difference = diff(expected, content);\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRender')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(content)}` +\n `\\n\\nDifference:\\n\\n${difference as string}`\n : () =>\n `${this.utils.matcherHint('.toRender')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(content)}` +\n `\\n\\nDifference:\\n\\n${difference as string}`;\n\n return { message, pass };\n};\n\nexpect.extend({\n toRespondWith,\n toRespondWithError,\n toSendNotification,\n toRender,\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";//# sourceMappingURL=chunk-4HY4SM3A.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunk2M7WQ26Fjs = require('./chunk-2M7WQ26F.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunk6IMEYEREjs = require('./chunk-6IMEYERE.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkKPXLJ6RHjs = require('./chunk-KPXLJ6RH.js');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _chunkMNDF32ZVjs = require('./chunk-MNDF32ZV.js');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
var _chunkPHUTP7NBjs = require('./chunk-PHUTP7NB.js');
|
|
18
|
+
|
|
19
|
+
// src/environment.ts
|
|
20
|
+
var _utils = require('@metamask/utils');
|
|
21
|
+
var _jestenvironmentnode = require('jest-environment-node'); var _jestenvironmentnode2 = _interopRequireDefault(_jestenvironmentnode);
|
|
22
|
+
var log = _utils.createModuleLogger.call(void 0, _chunkMNDF32ZVjs.rootLogger, "environment");
|
|
23
|
+
var _options, _server, _instance;
|
|
24
|
+
var SnapsEnvironment = class extends _jestenvironmentnode2.default {
|
|
25
|
+
/**
|
|
26
|
+
* Constructor.
|
|
27
|
+
*
|
|
28
|
+
* @param options - The environment options.
|
|
29
|
+
* @param context - The environment context.
|
|
30
|
+
*/
|
|
31
|
+
constructor(options, context) {
|
|
32
|
+
super(options, context);
|
|
33
|
+
_chunkPHUTP7NBjs.__privateAdd.call(void 0, this, _options, void 0);
|
|
34
|
+
_chunkPHUTP7NBjs.__privateAdd.call(void 0, this, _server, void 0);
|
|
35
|
+
_chunkPHUTP7NBjs.__privateAdd.call(void 0, this, _instance, void 0);
|
|
36
|
+
_chunkPHUTP7NBjs.__privateSet.call(void 0, this, _options, _chunk2M7WQ26Fjs.getOptions.call(void 0, options.projectConfig.testEnvironmentOptions));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Set up the environment. This starts the built-in HTTP server, and creates a
|
|
40
|
+
* new browser instance.
|
|
41
|
+
*/
|
|
42
|
+
async setup() {
|
|
43
|
+
await super.setup();
|
|
44
|
+
if (_chunkPHUTP7NBjs.__privateGet.call(void 0, this, _options).server.enabled) {
|
|
45
|
+
log("Starting server.");
|
|
46
|
+
_chunkPHUTP7NBjs.__privateSet.call(void 0, this, _server, await _chunkKPXLJ6RHjs.startServer.call(void 0, _chunkPHUTP7NBjs.__privateGet.call(void 0, this, _options).server));
|
|
47
|
+
}
|
|
48
|
+
this.global.snapsEnvironment = this;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Tear down the environment. This closes the browser, and stops the built-in
|
|
52
|
+
* HTTP server.
|
|
53
|
+
*/
|
|
54
|
+
async teardown() {
|
|
55
|
+
await _optionalChain([_chunkPHUTP7NBjs.__privateGet.call(void 0, this, _instance), 'optionalAccess', _ => _.executionService, 'access', _2 => _2.terminateAllSnaps, 'call', _3 => _3()]);
|
|
56
|
+
_optionalChain([_chunkPHUTP7NBjs.__privateGet.call(void 0, this, _server), 'optionalAccess', _4 => _4.close, 'call', _5 => _5()]);
|
|
57
|
+
await super.teardown();
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Install a Snap in the environment. This will terminate any previously
|
|
61
|
+
* installed Snaps, and run the Snap code in a new execution service.
|
|
62
|
+
*
|
|
63
|
+
* @param snapId - The ID of the Snap to install.
|
|
64
|
+
* @param options - The options to use when installing the Snap.
|
|
65
|
+
* @param options.executionService - The execution service to use.
|
|
66
|
+
* @param options.executionServiceOptions - The options to use when creating the
|
|
67
|
+
* execution service, if any. This should only include options specific to the
|
|
68
|
+
* provided execution service.
|
|
69
|
+
* @param options.options - The simulation options.
|
|
70
|
+
* @template Service - The type of the execution service.
|
|
71
|
+
* @returns The installed Snap.
|
|
72
|
+
*/
|
|
73
|
+
async installSnap(snapId = this.snapId, options = {}) {
|
|
74
|
+
await _optionalChain([_chunkPHUTP7NBjs.__privateGet.call(void 0, this, _instance), 'optionalAccess', _6 => _6.executionService, 'access', _7 => _7.terminateAllSnaps, 'call', _8 => _8()]);
|
|
75
|
+
_chunkPHUTP7NBjs.__privateSet.call(void 0, this, _instance, await _chunk6IMEYEREjs.handleInstallSnap.call(void 0, snapId, options));
|
|
76
|
+
return _chunkPHUTP7NBjs.__privateGet.call(void 0, this, _instance);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get the snap ID for the current environment, which is used if no snap ID is
|
|
80
|
+
* passed to {@link installSnap}. This assumes that the built-in server is
|
|
81
|
+
* running.
|
|
82
|
+
*
|
|
83
|
+
* @returns The snap ID.
|
|
84
|
+
* @throws If the server is not running.
|
|
85
|
+
*/
|
|
86
|
+
get snapId() {
|
|
87
|
+
_utils.assert.call(void 0,
|
|
88
|
+
_chunkPHUTP7NBjs.__privateGet.call(void 0, this, _server),
|
|
89
|
+
"You must specify a snap ID, because the built-in server is not running."
|
|
90
|
+
);
|
|
91
|
+
const { port } = _chunkPHUTP7NBjs.__privateGet.call(void 0, this, _server).address();
|
|
92
|
+
return `local:http://localhost:${port}`;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
_options = new WeakMap();
|
|
96
|
+
_server = new WeakMap();
|
|
97
|
+
_instance = new WeakMap();
|
|
98
|
+
var environment_default = SnapsEnvironment;
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
exports.SnapsEnvironment = SnapsEnvironment; exports.environment_default = environment_default;
|
|
104
|
+
//# sourceMappingURL=chunk-4JUUFDTC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/environment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAMA,SAAS,QAAQ,0BAA0B;AAE3C,OAAO,qBAAqB;AAc5B,IAAM,MAAM,mBAAmB,YAAY,aAAa;AAtBxD;AAwBO,IAAM,mBAAN,cAA+B,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAapD,YAAY,SAAgC,SAA6B;AACvE,UAAM,SAAS,OAAO;AAbxB;AAEA;AAEA;AAUE,uBAAK,UAAW,WAAW,QAAQ,cAAc,sBAAsB;AAAA,EACzE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,QAAQ;AACZ,UAAM,MAAM,MAAM;AAElB,QAAI,mBAAK,UAAS,OAAO,SAAS;AAChC,UAAI,kBAAkB;AACtB,yBAAK,SAAU,MAAM,YAAY,mBAAK,UAAS,MAAM;AAAA,IACvD;AAEA,SAAK,OAAO,mBAAmB;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,WAAW;AACf,UAAM,mBAAK,YAAW,iBAAiB,kBAAkB;AACzD,uBAAK,UAAS,MAAM;AACpB,UAAM,MAAM,SAAS;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBA,MAAM,YAKJ,SAAiB,KAAK,QACtB,UAAgD,CAAC,GACjD;AACA,UAAM,mBAAK,YAAW,iBAAiB,kBAAkB;AACzD,uBAAK,WAAY,MAAM,kBAAkB,QAAkB,OAAO;AAClE,WAAO,mBAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,IAAI,SAAS;AACX;AAAA,MACE,mBAAK;AAAA,MACL;AAAA,IACF;AAEA,UAAM,EAAE,KAAK,IAAI,mBAAK,SAAQ,QAAQ;AACtC,WAAO,0BAA0B,IAAI;AAAA,EACvC;AACF;AAtFE;AAEA;AAEA;AAoFF,IAAO,sBAAQ","sourcesContent":["import type {\n EnvironmentContext,\n JestEnvironmentConfig,\n} from '@jest/environment';\nimport type { AbstractExecutionService } from '@metamask/snaps-controllers';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { assert, createModuleLogger } from '@metamask/utils';\nimport type { Server } from 'http';\nimport NodeEnvironment from 'jest-environment-node';\nimport type { AddressInfo } from 'net';\n\nimport type { InstalledSnap, InstallSnapOptions } from './internals';\nimport { handleInstallSnap, rootLogger, startServer } from './internals';\nimport type { SnapsEnvironmentOptions } from './options';\nimport { getOptions } from './options';\n\n/* eslint-disable */\ndeclare global {\n const snapsEnvironment: SnapsEnvironment;\n}\n/* eslint-enable */\n\nconst log = createModuleLogger(rootLogger, 'environment');\n\nexport class SnapsEnvironment extends NodeEnvironment {\n #options: SnapsEnvironmentOptions;\n\n #server: Server | undefined;\n\n #instance: InstalledSnap | undefined;\n\n /**\n * Constructor.\n *\n * @param options - The environment options.\n * @param context - The environment context.\n */\n constructor(options: JestEnvironmentConfig, context: EnvironmentContext) {\n super(options, context);\n this.#options = getOptions(options.projectConfig.testEnvironmentOptions);\n }\n\n /**\n * Set up the environment. This starts the built-in HTTP server, and creates a\n * new browser instance.\n */\n async setup() {\n await super.setup();\n\n if (this.#options.server.enabled) {\n log('Starting server.');\n this.#server = await startServer(this.#options.server);\n }\n\n this.global.snapsEnvironment = this;\n }\n\n /**\n * Tear down the environment. This closes the browser, and stops the built-in\n * HTTP server.\n */\n async teardown() {\n await this.#instance?.executionService.terminateAllSnaps();\n this.#server?.close();\n await super.teardown();\n }\n\n /**\n * Install a Snap in the environment. This will terminate any previously\n * installed Snaps, and run the Snap code in a new execution service.\n *\n * @param snapId - The ID of the Snap to install.\n * @param options - The options to use when installing the Snap.\n * @param options.executionService - The execution service to use.\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 * @template Service - The type of the execution service.\n * @returns The installed Snap.\n */\n async installSnap<\n Service extends new (...args: any[]) => InstanceType<\n typeof AbstractExecutionService\n >,\n >(\n snapId: string = this.snapId,\n options: Partial<InstallSnapOptions<Service>> = {},\n ) {\n await this.#instance?.executionService.terminateAllSnaps();\n this.#instance = await handleInstallSnap(snapId as SnapId, options);\n return this.#instance;\n }\n\n /**\n * Get the snap ID for the current environment, which is used if no snap ID is\n * passed to {@link installSnap}. This assumes that the built-in server is\n * running.\n *\n * @returns The snap ID.\n * @throws If the server is not running.\n */\n get snapId() {\n assert(\n this.#server,\n 'You must specify a snap ID, because the built-in server is not running.',\n );\n\n const { port } = this.#server.address() as AddressInfo;\n return `local:http://localhost:${port}`;\n }\n}\n\nexport default SnapsEnvironment;\n"]}
|