@metamask/snaps-jest 4.0.1 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -1
- package/README.md +66 -179
- 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/chunk-D36QBJ35.js.map +1 -0
- 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/environment.d.ts +14 -15
- package/dist/types/helpers.d.ts +64 -3
- package/dist/types/internals/index.d.ts +1 -4
- package/dist/types/internals/request.d.ts +38 -74
- package/dist/types/internals/simulation/constants.d.ts +13 -0
- package/dist/types/internals/simulation/controllers.d.ts +40 -0
- package/dist/types/internals/simulation/files.d.ts +11 -0
- package/dist/types/internals/simulation/index.d.ts +5 -0
- package/dist/types/internals/simulation/interface.d.ts +25 -0
- package/dist/types/internals/simulation/methods/constants.d.ts +10 -0
- package/dist/types/internals/simulation/methods/hooks/encryption.d.ts +29 -0
- package/dist/types/internals/simulation/methods/hooks/get-locale.d.ts +9 -0
- package/dist/types/internals/simulation/methods/hooks/index.d.ts +6 -0
- package/dist/types/internals/simulation/methods/hooks/interface.d.ts +16 -0
- package/dist/types/internals/simulation/methods/hooks/notifications.d.ts +16 -0
- package/dist/types/internals/simulation/methods/hooks/show-dialog.d.ts +9 -0
- package/dist/types/internals/simulation/methods/hooks/state.d.ts +22 -0
- package/dist/types/internals/simulation/methods/index.d.ts +1 -0
- package/dist/types/internals/simulation/methods/specifications.d.ts +56 -0
- package/dist/types/internals/simulation/middleware/engine.d.ts +26 -0
- package/dist/types/internals/simulation/middleware/index.d.ts +1 -0
- package/dist/types/internals/simulation/middleware/internal-methods/accounts.d.ts +18 -0
- package/dist/types/internals/simulation/middleware/internal-methods/index.d.ts +1 -0
- package/dist/types/internals/simulation/middleware/internal-methods/middleware.d.ts +22 -0
- package/dist/types/internals/simulation/middleware/internal-methods/provider-state.d.ts +14 -0
- package/dist/types/internals/simulation/middleware/mock.d.ts +10 -0
- package/dist/types/internals/simulation/options.d.ts +37 -0
- package/dist/types/internals/simulation/simulation.d.ts +98 -0
- package/dist/types/internals/simulation/store/index.d.ts +4 -0
- package/dist/types/internals/simulation/store/mocks.d.ts +35 -0
- package/dist/types/internals/simulation/store/notifications.d.ts +44 -0
- package/dist/types/internals/simulation/store/state.d.ts +55 -0
- package/dist/types/internals/simulation/store/store.d.ts +22 -0
- package/dist/types/internals/simulation/store/ui.d.ts +25 -0
- package/dist/types/internals/structs.d.ts +153 -0
- package/dist/types/options.d.ts +3 -35
- package/dist/types/types.d.ts +88 -41
- 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 +37 -24
- package/dist/cjs/environment.js +0 -205
- package/dist/cjs/environment.js.map +0 -1
- package/dist/cjs/helpers.js +0 -67
- 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 -28
- package/dist/cjs/internals/index.js.map +0 -1
- package/dist/cjs/internals/interface.js +0 -103
- package/dist/cjs/internals/interface.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/network.js +0 -148
- package/dist/cjs/internals/network.js.map +0 -1
- package/dist/cjs/internals/request.js +0 -121
- package/dist/cjs/internals/request.js.map +0 -1
- package/dist/cjs/internals/server.js +0 -75
- package/dist/cjs/internals/server.js.map +0 -1
- package/dist/cjs/internals/structs.js +0 -122
- package/dist/cjs/internals/structs.js.map +0 -1
- package/dist/cjs/internals/types.js +0 -6
- package/dist/cjs/internals/types.js.map +0 -1
- package/dist/cjs/internals/wait-for.js +0 -63
- package/dist/cjs/internals/wait-for.js.map +0 -1
- package/dist/cjs/matchers.js +0 -117
- package/dist/cjs/matchers.js.map +0 -1
- package/dist/cjs/options.js +0 -29
- 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 -182
- package/dist/esm/environment.js.map +0 -1
- package/dist/esm/helpers.js +0 -82
- 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 -12
- package/dist/esm/internals/index.js.map +0 -1
- package/dist/esm/internals/interface.js +0 -100
- package/dist/esm/internals/interface.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/network.js +0 -143
- package/dist/esm/internals/network.js.map +0 -1
- package/dist/esm/internals/request.js +0 -120
- package/dist/esm/internals/request.js.map +0 -1
- package/dist/esm/internals/server.js +0 -68
- package/dist/esm/internals/server.js.map +0 -1
- package/dist/esm/internals/structs.js +0 -98
- package/dist/esm/internals/structs.js.map +0 -1
- package/dist/esm/internals/types.js +0 -3
- package/dist/esm/internals/types.js.map +0 -1
- package/dist/esm/internals/wait-for.js +0 -63
- package/dist/esm/internals/wait-for.js.map +0 -1
- package/dist/esm/matchers.js +0 -108
- package/dist/esm/matchers.js.map +0 -1
- package/dist/esm/options.js +0 -26
- 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/dist/types/internals/interface.d.ts +0 -25
- package/dist/types/internals/network.d.ts +0 -87
- package/dist/types/internals/types.d.ts +0 -18
- package/dist/types/internals/wait-for.d.ts +0 -38
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,28 @@ 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
|
+
|
|
17
|
+
## [5.0.0]
|
|
18
|
+
### Added
|
|
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))
|
|
20
|
+
- The network mocking functionality was removed, but may be reintroduced in a future version.
|
|
21
|
+
- `mockJsonRpc` no longer returns a `Promise`.
|
|
22
|
+
- `runCronjob` was renamed to `onCronjob`, and `sendTransaction` was renamed to `onTransaction`.
|
|
23
|
+
- For backwards compatibility, the old methods are still available, but will be removed in a future version.
|
|
24
|
+
- Add `onHomePage` support ([#2104](https://github.com/MetaMask/snaps/pull/2104))
|
|
25
|
+
- Add `onSignature` support ([#2114](https://github.com/MetaMask/snaps/pull/2114))
|
|
26
|
+
- Add `snap_getClientStatus` support ([#2159](https://github.com/MetaMask/snaps/pull/2159))
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
- Bump several MetaMask dependencies ([#2101](https://github.com/MetaMask/snaps/pull/2101), [#2100](https://github.com/MetaMask/snaps/pull/2100), [#2129](https://github.com/MetaMask/snaps/pull/2129), [#2140](https://github.com/MetaMask/snaps/pull/2140), [#2141](https://github.com/MetaMask/snaps/pull/2141), [#2142](https://github.com/MetaMask/snaps/pull/2142))
|
|
30
|
+
|
|
9
31
|
## [4.0.1]
|
|
10
32
|
### Fixed
|
|
11
33
|
- Fix coercing of address values in `sendTransaction` function ([#1970](https://github.com/MetaMask/snaps/pull/1970))
|
|
@@ -81,7 +103,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
81
103
|
- The version of the package no longer needs to match the version of all other
|
|
82
104
|
MetaMask Snaps packages.
|
|
83
105
|
|
|
84
|
-
[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
|
|
108
|
+
[5.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@4.0.1...@metamask/snaps-jest@5.0.0
|
|
85
109
|
[4.0.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@4.0.0...@metamask/snaps-jest@4.0.1
|
|
86
110
|
[4.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@3.1.0...@metamask/snaps-jest@4.0.0
|
|
87
111
|
[3.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@3.0.0...@metamask/snaps-jest@3.1.0
|
package/README.md
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
# `@metamask/snaps-jest`
|
|
2
2
|
|
|
3
3
|
A [Jest](https://jestjs.io/) preset for end-to-end testing MetaMask Snaps,
|
|
4
|
-
including a Jest environment, and a set of Jest matchers.
|
|
5
|
-
currently experimental, and the API may change in the future.
|
|
4
|
+
including a Jest environment, and a set of Jest matchers.
|
|
6
5
|
|
|
7
6
|
- [Installation](#installation)
|
|
8
7
|
- [Usage](#usage)
|
|
@@ -10,11 +9,12 @@ currently experimental, and the API may change in the future.
|
|
|
10
9
|
- [API](#api)
|
|
11
10
|
- [Install a snap](#install-a-snap)
|
|
12
11
|
- [`snap.request`](#snaprequest)
|
|
13
|
-
- [`snap.
|
|
14
|
-
- [`snap.
|
|
12
|
+
- [`snap.onTransaction`](#snapontransaction)
|
|
13
|
+
- [`snap.onSignature`](#snaponsignature)
|
|
14
|
+
- [`snap.onCronjob`](#snaponcronjob)
|
|
15
|
+
- [`snap.onHomePage`](#snaponhomepage)
|
|
15
16
|
- [Jest matchers](#jest-matchers)
|
|
16
17
|
- [Interacting with user interfaces](#interacting-with-user-interfaces)
|
|
17
|
-
- [Network mocking](#network-mocking-snapmock)
|
|
18
18
|
- [Options](#options)
|
|
19
19
|
|
|
20
20
|
## Installation
|
|
@@ -66,8 +66,8 @@ module.exports = {
|
|
|
66
66
|
### Install a snap
|
|
67
67
|
|
|
68
68
|
`@metamask/snaps-jest` exposes a `installSnap` function that can be used to
|
|
69
|
-
install a snap in the
|
|
70
|
-
test, to ensure that each test starts with a clean slate.
|
|
69
|
+
install a snap in the execution environment. It's recommended to use this
|
|
70
|
+
function in each test, to ensure that each test starts with a clean slate.
|
|
71
71
|
|
|
72
72
|
By default, if the built-in server is enabled, it will install the snap from
|
|
73
73
|
the built-in server. Otherwise, you must specify a snap ID to install.
|
|
@@ -174,9 +174,9 @@ describe('MySnap', () => {
|
|
|
174
174
|
});
|
|
175
175
|
```
|
|
176
176
|
|
|
177
|
-
### `snap.
|
|
177
|
+
### `snap.onTransaction`
|
|
178
178
|
|
|
179
|
-
The `
|
|
179
|
+
The `onTransaction` function can be used to send a transaction to the snap. It
|
|
180
180
|
takes a single argument, which is an object with the following properties:
|
|
181
181
|
|
|
182
182
|
- `origin`: The origin of the transaction.
|
|
@@ -204,8 +204,8 @@ import { panel, text } from '@metamask/snaps-sdk';
|
|
|
204
204
|
|
|
205
205
|
describe('MySnap', () => {
|
|
206
206
|
it('should do something', async () => {
|
|
207
|
-
const {
|
|
208
|
-
const response = await
|
|
207
|
+
const { onTransaction } = await installSnap(/* optional snap ID */);
|
|
208
|
+
const response = await onTransaction({
|
|
209
209
|
value: '0x0',
|
|
210
210
|
data: '0x',
|
|
211
211
|
gasLimit: '0x5208',
|
|
@@ -219,9 +219,43 @@ describe('MySnap', () => {
|
|
|
219
219
|
});
|
|
220
220
|
```
|
|
221
221
|
|
|
222
|
-
### `snap.
|
|
222
|
+
### `snap.onSignature`
|
|
223
223
|
|
|
224
|
-
The `
|
|
224
|
+
The `onSignature` function can be used to send a signature request to the snap. It
|
|
225
|
+
takes a single argument, which is an object with the following properties:
|
|
226
|
+
|
|
227
|
+
- `origin`: The origin of the signature request.
|
|
228
|
+
- `from`: The address of the signer.
|
|
229
|
+
- `data`: The data of the signature.
|
|
230
|
+
- `signatureMethod`: The signature method being used in the request.
|
|
231
|
+
|
|
232
|
+
All properties are optional, and have sensible defaults. The addresses are
|
|
233
|
+
randomly generated by default. Most values can be specified as a hex string, or
|
|
234
|
+
a decimal number.
|
|
235
|
+
|
|
236
|
+
It returns an object with the user interface that was shown by the snap, in the
|
|
237
|
+
[onSignature](https://docs.metamask.io/snaps/reference/exports/#onsignature)
|
|
238
|
+
function.
|
|
239
|
+
|
|
240
|
+
```js
|
|
241
|
+
import { installSnap } from '@metamask/snaps-jest';
|
|
242
|
+
import { panel, text } from '@metamask/snaps-sdk';
|
|
243
|
+
|
|
244
|
+
describe('MySnap', () => {
|
|
245
|
+
it('should do something', async () => {
|
|
246
|
+
const { onSignature } = await installSnap(/* optional snap ID */);
|
|
247
|
+
const response = await onSignature();
|
|
248
|
+
|
|
249
|
+
expect(response).toRender(
|
|
250
|
+
panel([text('You are using the personal_sign method')]),
|
|
251
|
+
);
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### `snap.onCronjob`
|
|
257
|
+
|
|
258
|
+
The `onCronjob` function can be used to run a cronjob in the snap. It takes
|
|
225
259
|
a single argument, which is similar to a JSON-RPC request object. It returns
|
|
226
260
|
a promise that resolves to the response from the
|
|
227
261
|
[onCronjob](https://docs.metamask.io/snaps/reference/exports/#oncronjob)
|
|
@@ -236,8 +270,8 @@ import { installSnap } from '@metamask/snaps-jest';
|
|
|
236
270
|
|
|
237
271
|
describe('MySnap', () => {
|
|
238
272
|
it('should do something', async () => {
|
|
239
|
-
const {
|
|
240
|
-
const response = await
|
|
273
|
+
const { onCronjob } = await installSnap(/* optional snap ID */);
|
|
274
|
+
const response = await onCronjob({
|
|
241
275
|
method: 'foo',
|
|
242
276
|
params: [],
|
|
243
277
|
});
|
|
@@ -254,8 +288,8 @@ import { installSnap } from '@metamask/snaps-jest';
|
|
|
254
288
|
|
|
255
289
|
describe('MySnap', () => {
|
|
256
290
|
it('should do something', async () => {
|
|
257
|
-
const {
|
|
258
|
-
const response = await
|
|
291
|
+
const { onCronjob } = await installSnap(/* optional snap ID */);
|
|
292
|
+
const response = await onCronjob({
|
|
259
293
|
method: 'foo',
|
|
260
294
|
params: [],
|
|
261
295
|
});
|
|
@@ -266,21 +300,25 @@ describe('MySnap', () => {
|
|
|
266
300
|
});
|
|
267
301
|
```
|
|
268
302
|
|
|
269
|
-
### `snap.
|
|
303
|
+
### `snap.onHomePage`
|
|
270
304
|
|
|
271
|
-
The `
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
305
|
+
The `onHomePage` function can be used to request the home page of the snap. It
|
|
306
|
+
takes no arguments, and returns a promise that resolves to the response from the
|
|
307
|
+
[onHomePage](https://docs.metamask.io/snaps/reference/entry-points/#onhomepage)
|
|
308
|
+
function.
|
|
275
309
|
|
|
276
310
|
```js
|
|
277
311
|
import { installSnap } from '@metamask/snaps-jest';
|
|
278
312
|
|
|
279
313
|
describe('MySnap', () => {
|
|
280
314
|
it('should do something', async () => {
|
|
281
|
-
const {
|
|
282
|
-
|
|
283
|
-
|
|
315
|
+
const { onHomePage } = await installSnap(/* optional snap ID */);
|
|
316
|
+
const response = await onHomePage({
|
|
317
|
+
method: 'foo',
|
|
318
|
+
params: [],
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
expect(response).toRender(/* ... */);
|
|
284
322
|
});
|
|
285
323
|
});
|
|
286
324
|
```
|
|
@@ -300,8 +338,9 @@ assert that a response from a snap matches an expected value:
|
|
|
300
338
|
- `toRender(expectedInterface)`: Check if a snap rendered an interface. This is
|
|
301
339
|
useful for testing the UI of a snap, either for a
|
|
302
340
|
[`snap_dialog`](https://docs.metamask.io/snaps/reference/rpc-api/#snap_dialog),
|
|
303
|
-
|
|
304
|
-
[the transaction insights API](https://docs.metamask.io/snaps/reference/exports/#ontransaction)
|
|
341
|
+
UI rendered by
|
|
342
|
+
[the transaction insights API](https://docs.metamask.io/snaps/reference/exports/#ontransaction) or
|
|
343
|
+
[the signature insights API](https://docs.metamask.io/snaps/reference/exports/#onsignature).
|
|
305
344
|
|
|
306
345
|
### Interacting with user interfaces
|
|
307
346
|
|
|
@@ -345,59 +384,6 @@ describe('MySnap', () => {
|
|
|
345
384
|
});
|
|
346
385
|
```
|
|
347
386
|
|
|
348
|
-
### Network mocking (`snap.mock`)
|
|
349
|
-
|
|
350
|
-
`@metamask/snaps-jest` includes basic network mocking functionality. This can
|
|
351
|
-
be used to mock the response of any network request made by the snap through
|
|
352
|
-
the `endowment:network-access` functionality.
|
|
353
|
-
|
|
354
|
-
The mock function takes a single argument, which is an object with the
|
|
355
|
-
following properties:
|
|
356
|
-
|
|
357
|
-
- `url` (`string | RegExp`): The URL of the request. This can be a string, or a
|
|
358
|
-
regular expression.
|
|
359
|
-
- `partial` (`boolean`): If enabled, the request will be mocked if the URL
|
|
360
|
-
starts with the given URL. This option is ignored if a RegExp is provided to
|
|
361
|
-
the `url` option. Defaults to `false`.
|
|
362
|
-
- `response` (`object`): An object with the response.
|
|
363
|
-
- `status` (`number`): The status code of the response. Defaults to `200`.
|
|
364
|
-
- `body` (`string`): The body of the response. Defaults to an empty string.
|
|
365
|
-
- `headers` (`object`): An object with the headers of the response. By
|
|
366
|
-
default, this will use headers that enable CORS.
|
|
367
|
-
- `contentType` (`string`): The content type of the response. Defaults to
|
|
368
|
-
`text/plain`.
|
|
369
|
-
|
|
370
|
-
Except for the `url` option, all options are optional.
|
|
371
|
-
|
|
372
|
-
#### Unmocking (`mock.unmock`)
|
|
373
|
-
|
|
374
|
-
The mock function returns an object with an `unmock` function that can be
|
|
375
|
-
used to remove the mock. Mocking happens on a per-snap-install basis. If the
|
|
376
|
-
mock is not removed, it will remain active for the rest of the snap
|
|
377
|
-
installation, so it does not affect other tests with a fresh snap installation.
|
|
378
|
-
|
|
379
|
-
#### Example
|
|
380
|
-
|
|
381
|
-
```js
|
|
382
|
-
import { installSnap } from '@metamask/snaps-jest';
|
|
383
|
-
|
|
384
|
-
describe('MySnap', () => {
|
|
385
|
-
it('should do something', async () => {
|
|
386
|
-
const { mock, request } = await installSnap(/* optional snap ID */);
|
|
387
|
-
|
|
388
|
-
const { unmock } = mock({
|
|
389
|
-
url: 'https://example.com',
|
|
390
|
-
status: 200,
|
|
391
|
-
body: 'Hello, world!',
|
|
392
|
-
});
|
|
393
|
-
|
|
394
|
-
// ...
|
|
395
|
-
|
|
396
|
-
unmock();
|
|
397
|
-
});
|
|
398
|
-
});
|
|
399
|
-
```
|
|
400
|
-
|
|
401
387
|
## Options
|
|
402
388
|
|
|
403
389
|
You can pass options to the test environment by adding a
|
|
@@ -414,44 +400,6 @@ module.exports = {
|
|
|
414
400
|
|
|
415
401
|
All options are optional, and have sensible defaults.
|
|
416
402
|
|
|
417
|
-
### `keepAlive`
|
|
418
|
-
|
|
419
|
-
- Type: `boolean`
|
|
420
|
-
- Default: `false`
|
|
421
|
-
|
|
422
|
-
Whether to keep the Jest environment running after the tests have finished. This
|
|
423
|
-
is useful for debugging, but should not be used in CI environments: When this is
|
|
424
|
-
enabled, the `jest` process will not exit on its own, and will need to be
|
|
425
|
-
manually killed (e.g., with <kbd>Ctrl</kbd> + <kbd>C</kbd>).
|
|
426
|
-
|
|
427
|
-
#### Example
|
|
428
|
-
|
|
429
|
-
```js
|
|
430
|
-
module.exports = {
|
|
431
|
-
preset: '@metamask/snaps-jest',
|
|
432
|
-
testEnvironmentOptions: {
|
|
433
|
-
keepAlive: true,
|
|
434
|
-
},
|
|
435
|
-
};
|
|
436
|
-
```
|
|
437
|
-
|
|
438
|
-
### `browser`
|
|
439
|
-
|
|
440
|
-
- Type: `object`
|
|
441
|
-
|
|
442
|
-
Options for the browser that is used to run the tests.
|
|
443
|
-
|
|
444
|
-
#### `browser.headless`
|
|
445
|
-
|
|
446
|
-
- Type: `boolean`
|
|
447
|
-
- Default: `true`
|
|
448
|
-
|
|
449
|
-
Whether to run the browser in headless mode. By default, it will be enabled. If
|
|
450
|
-
you want to see the browser window while the tests are running, you can disable
|
|
451
|
-
this option. Note that this will require you to have a graphical environment
|
|
452
|
-
available, so it is not recommended for CI environments, but can be useful for
|
|
453
|
-
debugging in conjunction with the `keepAlive` option.
|
|
454
|
-
|
|
455
403
|
### `server`
|
|
456
404
|
|
|
457
405
|
- Type: `object`
|
|
@@ -524,64 +472,3 @@ module.exports = {
|
|
|
524
472
|
},
|
|
525
473
|
};
|
|
526
474
|
```
|
|
527
|
-
|
|
528
|
-
##### Example
|
|
529
|
-
|
|
530
|
-
```js
|
|
531
|
-
module.exports = {
|
|
532
|
-
preset: '@metamask/snaps-jest',
|
|
533
|
-
testEnvironmentOptions: {
|
|
534
|
-
browser: {
|
|
535
|
-
headless: false,
|
|
536
|
-
},
|
|
537
|
-
},
|
|
538
|
-
};
|
|
539
|
-
```
|
|
540
|
-
|
|
541
|
-
### `executionEnvironmentUrl`
|
|
542
|
-
|
|
543
|
-
- Type: `string`
|
|
544
|
-
|
|
545
|
-
The URL of the execution environment to use for testing. This is the URL that
|
|
546
|
-
will be loaded by the Snaps Simulator in the tests. By default, it will use the
|
|
547
|
-
URL of the built-in HTTP server that is included with this package.
|
|
548
|
-
|
|
549
|
-
> **Note**: This option is intended for advanced use cases. In most cases, you
|
|
550
|
-
> should not need to change this option.
|
|
551
|
-
|
|
552
|
-
See also: [`@metamask/snaps-execution-environments`](../snaps-execution-environments/README.md).
|
|
553
|
-
|
|
554
|
-
#### Example
|
|
555
|
-
|
|
556
|
-
```js
|
|
557
|
-
module.exports = {
|
|
558
|
-
preset: '@metamask/snaps-jest',
|
|
559
|
-
testEnvironmentOptions: {
|
|
560
|
-
executionEnvironmentUrl: 'http://localhost:8080',
|
|
561
|
-
},
|
|
562
|
-
};
|
|
563
|
-
```
|
|
564
|
-
|
|
565
|
-
### `simulatorUrl`
|
|
566
|
-
|
|
567
|
-
- Type: `string`
|
|
568
|
-
|
|
569
|
-
The URL of the simulator to use for testing. This is the URL that will be
|
|
570
|
-
loaded in the browser when running tests. By default, it will use the URL of
|
|
571
|
-
the built-in HTTP server that is included with this package.
|
|
572
|
-
|
|
573
|
-
> **Note**: This option is intended for advanced use cases. In most cases, you
|
|
574
|
-
> should not need to change this option.
|
|
575
|
-
|
|
576
|
-
See also: [`@metamask/snaps-simulator`](../snaps-simulator/README.md).
|
|
577
|
-
|
|
578
|
-
#### Example
|
|
579
|
-
|
|
580
|
-
```js
|
|
581
|
-
module.exports = {
|
|
582
|
-
preset: '@metamask/snaps-jest',
|
|
583
|
-
testEnvironmentOptions: {
|
|
584
|
-
simulatorUrl: 'http://localhost:8081',
|
|
585
|
-
},
|
|
586
|
-
};
|
|
587
|
-
```
|
|
@@ -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"]}
|