@metamask/snaps-jest 8.2.0 → 8.3.1
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 +20 -1
- package/README.md +2 -2
- package/dist/environment.cjs +96 -0
- package/dist/environment.cjs.map +1 -0
- package/dist/{types/environment.d.ts → environment.d.cts} +5 -4
- package/dist/environment.d.cts.map +1 -0
- package/dist/environment.d.mts +53 -0
- package/dist/environment.d.mts.map +1 -0
- package/dist/environment.mjs +94 -44
- package/dist/environment.mjs.map +1 -1
- package/dist/global.cjs +4 -0
- package/dist/global.cjs.map +1 -0
- package/dist/{types/global.d.ts → global.d.cts} +2 -1
- package/dist/global.d.cts.map +1 -0
- package/dist/global.d.mts +70 -0
- package/dist/global.d.mts.map +1 -0
- package/dist/global.mjs +2 -1
- package/dist/global.mjs.map +1 -1
- package/dist/helpers.cjs +240 -0
- package/dist/helpers.cjs.map +1 -0
- package/dist/{types/helpers.d.ts → helpers.d.cts} +47 -4
- package/dist/helpers.d.cts.map +1 -0
- package/dist/helpers.d.mts +132 -0
- package/dist/helpers.d.mts.map +1 -0
- package/dist/helpers.mjs +228 -42
- package/dist/helpers.mjs.map +1 -1
- package/dist/index.cjs +29 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +6 -53
- package/dist/index.mjs.map +1 -1
- package/dist/internals/environment.cjs +18 -0
- package/dist/internals/environment.cjs.map +1 -0
- package/dist/{types/internals/environment.d.ts → internals/environment.d.cts} +1 -0
- package/dist/internals/environment.d.cts.map +1 -0
- package/dist/internals/environment.d.mts +8 -0
- package/dist/internals/environment.d.mts.map +1 -0
- package/dist/internals/environment.mjs +13 -7
- package/dist/internals/environment.mjs.map +1 -1
- package/dist/internals/index.cjs +23 -0
- package/dist/internals/index.cjs.map +1 -0
- package/dist/internals/index.d.cts +7 -0
- package/dist/internals/index.d.cts.map +1 -0
- package/dist/internals/index.d.mts +7 -0
- package/dist/internals/index.d.mts.map +1 -0
- package/dist/internals/index.mjs +6 -141
- package/dist/internals/index.mjs.map +1 -1
- package/dist/internals/logger.cjs +6 -0
- package/dist/internals/logger.cjs.map +1 -0
- package/dist/{types/internals/logger.d.ts → internals/logger.d.cts} +1 -0
- package/dist/internals/logger.d.cts.map +1 -0
- package/dist/internals/logger.d.mts +3 -0
- package/dist/internals/logger.d.mts.map +1 -0
- package/dist/internals/logger.mjs +2 -7
- package/dist/internals/logger.mjs.map +1 -1
- package/dist/internals/request.cjs +143 -0
- package/dist/internals/request.cjs.map +1 -0
- package/dist/{types/internals/request.d.ts → internals/request.d.cts} +8 -7
- package/dist/internals/request.d.cts.map +1 -0
- package/dist/internals/request.d.mts +56 -0
- package/dist/internals/request.d.mts.map +1 -0
- package/dist/internals/request.mjs +137 -41
- package/dist/internals/request.mjs.map +1 -1
- package/dist/internals/server.cjs +74 -0
- package/dist/internals/server.cjs.map +1 -0
- package/dist/{types/internals/server.d.ts → internals/server.d.cts} +4 -3
- package/dist/internals/server.d.cts.map +1 -0
- package/dist/internals/server.d.mts +15 -0
- package/dist/internals/server.d.mts.map +1 -0
- package/dist/internals/server.mjs +73 -8
- package/dist/internals/server.mjs.map +1 -1
- package/dist/internals/simulation/constants.cjs +21 -0
- package/dist/internals/simulation/constants.cjs.map +1 -0
- package/dist/{types/internals/simulation/constants.d.ts → internals/simulation/constants.d.cts} +5 -0
- package/dist/internals/simulation/constants.d.cts.map +1 -0
- package/dist/internals/simulation/constants.d.mts +18 -0
- package/dist/internals/simulation/constants.d.mts.map +1 -0
- package/dist/internals/simulation/constants.mjs +17 -11
- package/dist/internals/simulation/constants.mjs.map +1 -1
- package/dist/internals/simulation/controllers.cjs +101 -0
- package/dist/internals/simulation/controllers.cjs.map +1 -0
- package/dist/{types/internals/simulation/controllers.d.ts → internals/simulation/controllers.d.cts} +15 -14
- package/dist/internals/simulation/controllers.d.cts.map +1 -0
- package/dist/internals/simulation/controllers.d.mts +41 -0
- package/dist/internals/simulation/controllers.d.mts.map +1 -0
- package/dist/internals/simulation/controllers.mjs +95 -24
- package/dist/internals/simulation/controllers.mjs.map +1 -1
- package/dist/internals/simulation/files.cjs +94 -0
- package/dist/internals/simulation/files.cjs.map +1 -0
- package/dist/{types/internals/simulation/files.d.ts → internals/simulation/files.d.cts} +6 -4
- package/dist/internals/simulation/files.d.cts.map +1 -0
- package/dist/internals/simulation/files.d.mts +49 -0
- package/dist/internals/simulation/files.d.mts.map +1 -0
- package/dist/internals/simulation/files.mjs +90 -13
- package/dist/internals/simulation/files.mjs.map +1 -1
- package/dist/internals/simulation/index.cjs +22 -0
- package/dist/internals/simulation/index.cjs.map +1 -0
- package/dist/internals/simulation/index.d.cts +6 -0
- package/dist/internals/simulation/index.d.cts.map +1 -0
- package/dist/internals/simulation/index.d.mts +6 -0
- package/dist/internals/simulation/index.d.mts.map +1 -0
- package/dist/internals/simulation/index.mjs +5 -102
- package/dist/internals/simulation/index.mjs.map +1 -1
- package/dist/internals/simulation/interface.cjs +527 -0
- package/dist/internals/simulation/interface.cjs.map +1 -0
- package/dist/{types/internals/simulation/interface.d.ts → internals/simulation/interface.d.cts} +38 -10
- package/dist/internals/simulation/interface.d.cts.map +1 -0
- package/dist/internals/simulation/interface.d.mts +152 -0
- package/dist/internals/simulation/interface.d.mts.map +1 -0
- package/dist/internals/simulation/interface.mjs +512 -30
- package/dist/internals/simulation/interface.mjs.map +1 -1
- package/dist/internals/simulation/methods/constants.cjs +72 -0
- package/dist/internals/simulation/methods/constants.cjs.map +1 -0
- package/dist/{types/internals/simulation/methods/constants.d.ts → internals/simulation/methods/constants.d.cts} +1 -0
- package/dist/internals/simulation/methods/constants.d.cts.map +1 -0
- package/dist/internals/simulation/methods/constants.d.mts +11 -0
- package/dist/internals/simulation/methods/constants.d.mts.map +1 -0
- package/dist/internals/simulation/methods/constants.mjs +68 -11
- package/dist/internals/simulation/methods/constants.mjs.map +1 -1
- package/dist/internals/simulation/methods/hooks/get-preferences.cjs +18 -0
- package/dist/internals/simulation/methods/hooks/get-preferences.cjs.map +1 -0
- package/dist/internals/simulation/methods/hooks/get-preferences.d.cts +14 -0
- package/dist/internals/simulation/methods/hooks/get-preferences.d.cts.map +1 -0
- package/dist/internals/simulation/methods/hooks/get-preferences.d.mts +14 -0
- package/dist/internals/simulation/methods/hooks/get-preferences.d.mts.map +1 -0
- package/dist/internals/simulation/methods/hooks/get-preferences.mjs +14 -0
- package/dist/internals/simulation/methods/hooks/get-preferences.mjs.map +1 -0
- package/dist/internals/simulation/methods/hooks/index.cjs +22 -0
- package/dist/internals/simulation/methods/hooks/index.cjs.map +1 -0
- package/dist/internals/simulation/methods/hooks/index.d.cts +6 -0
- package/dist/internals/simulation/methods/hooks/index.d.cts.map +1 -0
- package/dist/internals/simulation/methods/hooks/index.d.mts +6 -0
- package/dist/internals/simulation/methods/hooks/index.d.mts.map +1 -0
- package/dist/internals/simulation/methods/hooks/index.mjs +5 -38
- package/dist/internals/simulation/methods/hooks/index.mjs.map +1 -1
- package/dist/internals/simulation/methods/hooks/interface.cjs +24 -0
- package/dist/internals/simulation/methods/hooks/interface.cjs.map +1 -0
- package/dist/{types/internals/simulation/methods/hooks/interface.d.ts → internals/simulation/methods/hooks/interface.d.cts} +3 -2
- package/dist/internals/simulation/methods/hooks/interface.d.cts.map +1 -0
- package/dist/internals/simulation/methods/hooks/interface.d.mts +17 -0
- package/dist/internals/simulation/methods/hooks/interface.d.mts.map +1 -0
- package/dist/internals/simulation/methods/hooks/interface.mjs +18 -9
- package/dist/internals/simulation/methods/hooks/interface.mjs.map +1 -1
- package/dist/internals/simulation/methods/hooks/notifications.cjs +58 -0
- package/dist/internals/simulation/methods/hooks/notifications.cjs.map +1 -0
- package/dist/{types/internals/simulation/methods/hooks/notifications.d.ts → internals/simulation/methods/hooks/notifications.d.cts} +5 -4
- package/dist/internals/simulation/methods/hooks/notifications.d.cts.map +1 -0
- package/dist/internals/simulation/methods/hooks/notifications.d.mts +17 -0
- package/dist/internals/simulation/methods/hooks/notifications.d.mts.map +1 -0
- package/dist/internals/simulation/methods/hooks/notifications.mjs +54 -15
- package/dist/internals/simulation/methods/hooks/notifications.mjs.map +1 -1
- package/dist/internals/simulation/methods/hooks/request-user-approval.cjs +38 -0
- package/dist/internals/simulation/methods/hooks/request-user-approval.cjs.map +1 -0
- package/dist/internals/simulation/methods/hooks/request-user-approval.d.cts +16 -0
- package/dist/internals/simulation/methods/hooks/request-user-approval.d.cts.map +1 -0
- package/dist/internals/simulation/methods/hooks/request-user-approval.d.mts +16 -0
- package/dist/internals/simulation/methods/hooks/request-user-approval.d.mts.map +1 -0
- package/dist/internals/simulation/methods/hooks/request-user-approval.mjs +35 -0
- package/dist/internals/simulation/methods/hooks/request-user-approval.mjs.map +1 -0
- package/dist/internals/simulation/methods/hooks/state.cjs +84 -0
- package/dist/internals/simulation/methods/hooks/state.cjs.map +1 -0
- package/dist/{types/internals/simulation/methods/hooks/state.d.ts → internals/simulation/methods/hooks/state.d.cts} +3 -2
- package/dist/internals/simulation/methods/hooks/state.d.cts.map +1 -0
- package/dist/internals/simulation/methods/hooks/state.d.mts +24 -0
- package/dist/internals/simulation/methods/hooks/state.d.mts.map +1 -0
- package/dist/internals/simulation/methods/hooks/state.mjs +78 -17
- package/dist/internals/simulation/methods/hooks/state.mjs.map +1 -1
- package/dist/internals/simulation/methods/index.cjs +18 -0
- package/dist/internals/simulation/methods/index.cjs.map +1 -0
- package/dist/internals/simulation/methods/index.d.cts +2 -0
- package/dist/internals/simulation/methods/index.d.cts.map +1 -0
- package/dist/internals/simulation/methods/index.d.mts +2 -0
- package/dist/internals/simulation/methods/index.d.mts.map +1 -0
- package/dist/internals/simulation/methods/index.mjs +1 -27
- package/dist/internals/simulation/methods/index.mjs.map +1 -1
- package/dist/internals/simulation/methods/specifications.cjs +85 -0
- package/dist/internals/simulation/methods/specifications.cjs.map +1 -0
- package/dist/{types/internals/simulation/methods/specifications.d.ts → internals/simulation/methods/specifications.d.cts} +8 -7
- package/dist/internals/simulation/methods/specifications.d.cts.map +1 -0
- package/dist/internals/simulation/methods/specifications.d.mts +57 -0
- package/dist/internals/simulation/methods/specifications.d.mts.map +1 -0
- package/dist/internals/simulation/methods/specifications.mjs +77 -26
- package/dist/internals/simulation/methods/specifications.mjs.map +1 -1
- package/dist/internals/simulation/middleware/engine.cjs +37 -0
- package/dist/internals/simulation/middleware/engine.cjs.map +1 -0
- package/dist/{types/internals/simulation/middleware/engine.d.ts → internals/simulation/middleware/engine.d.cts} +8 -7
- package/dist/internals/simulation/middleware/engine.d.cts.map +1 -0
- package/dist/internals/simulation/middleware/engine.d.mts +27 -0
- package/dist/internals/simulation/middleware/engine.d.mts.map +1 -0
- package/dist/internals/simulation/middleware/engine.mjs +33 -14
- package/dist/internals/simulation/middleware/engine.mjs.map +1 -1
- package/dist/internals/simulation/middleware/index.cjs +18 -0
- package/dist/internals/simulation/middleware/index.cjs.map +1 -0
- package/dist/internals/simulation/middleware/index.d.cts +2 -0
- package/dist/internals/simulation/middleware/index.d.cts.map +1 -0
- package/dist/internals/simulation/middleware/index.d.mts +2 -0
- package/dist/internals/simulation/middleware/index.d.mts.map +1 -0
- package/dist/internals/simulation/middleware/index.mjs +1 -15
- package/dist/internals/simulation/middleware/index.mjs.map +1 -1
- package/dist/internals/simulation/middleware/internal-methods/accounts.cjs +34 -0
- package/dist/internals/simulation/middleware/internal-methods/accounts.cjs.map +1 -0
- package/dist/{types/internals/simulation/middleware/internal-methods/accounts.d.ts → internals/simulation/middleware/internal-methods/accounts.d.cts} +5 -3
- package/dist/internals/simulation/middleware/internal-methods/accounts.d.cts.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/accounts.d.mts +20 -0
- package/dist/internals/simulation/middleware/internal-methods/accounts.d.mts.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/accounts.mjs +29 -7
- package/dist/internals/simulation/middleware/internal-methods/accounts.mjs.map +1 -1
- package/dist/internals/simulation/middleware/internal-methods/index.cjs +18 -0
- package/dist/internals/simulation/middleware/internal-methods/index.cjs.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/index.d.cts +2 -0
- package/dist/internals/simulation/middleware/internal-methods/index.d.cts.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/index.d.mts +2 -0
- package/dist/internals/simulation/middleware/internal-methods/index.d.mts.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/index.mjs +1 -10
- package/dist/internals/simulation/middleware/internal-methods/index.mjs.map +1 -1
- package/dist/internals/simulation/middleware/internal-methods/middleware.cjs +44 -0
- package/dist/internals/simulation/middleware/internal-methods/middleware.cjs.map +1 -0
- package/dist/{types/internals/simulation/middleware/internal-methods/middleware.d.ts → internals/simulation/middleware/internal-methods/middleware.d.cts} +4 -3
- package/dist/internals/simulation/middleware/internal-methods/middleware.d.cts.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/middleware.d.mts +23 -0
- package/dist/internals/simulation/middleware/internal-methods/middleware.d.mts.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/middleware.mjs +38 -8
- package/dist/internals/simulation/middleware/internal-methods/middleware.mjs.map +1 -1
- package/dist/internals/simulation/middleware/internal-methods/provider-state.cjs +28 -0
- package/dist/internals/simulation/middleware/internal-methods/provider-state.cjs.map +1 -0
- package/dist/{types/internals/simulation/middleware/internal-methods/provider-state.d.ts → internals/simulation/middleware/internal-methods/provider-state.d.cts} +4 -2
- package/dist/internals/simulation/middleware/internal-methods/provider-state.d.cts.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/provider-state.d.mts +16 -0
- package/dist/internals/simulation/middleware/internal-methods/provider-state.d.mts.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/provider-state.mjs +23 -7
- package/dist/internals/simulation/middleware/internal-methods/provider-state.mjs.map +1 -1
- package/dist/internals/simulation/middleware/mock.cjs +22 -0
- package/dist/internals/simulation/middleware/mock.cjs.map +1 -0
- package/dist/{types/internals/simulation/middleware/mock.d.ts → internals/simulation/middleware/mock.d.cts} +4 -3
- package/dist/internals/simulation/middleware/mock.d.cts.map +1 -0
- package/dist/internals/simulation/middleware/mock.d.mts +11 -0
- package/dist/internals/simulation/middleware/mock.d.mts.map +1 -0
- package/dist/internals/simulation/middleware/mock.mjs +17 -8
- package/dist/internals/simulation/middleware/mock.mjs.map +1 -1
- package/dist/internals/simulation/options.cjs +25 -0
- package/dist/internals/simulation/options.cjs.map +1 -0
- package/dist/{types/internals/simulation/options.d.ts → internals/simulation/options.d.cts} +11 -8
- package/dist/internals/simulation/options.d.cts.map +1 -0
- package/dist/internals/simulation/options.d.mts +40 -0
- package/dist/internals/simulation/options.d.mts.map +1 -0
- package/dist/internals/simulation/options.mjs +20 -8
- package/dist/internals/simulation/options.mjs.map +1 -1
- package/dist/internals/simulation/simulation.cjs +155 -0
- package/dist/internals/simulation/simulation.cjs.map +1 -0
- package/dist/{types/internals/simulation/simulation.d.ts → internals/simulation/simulation.d.cts} +18 -13
- package/dist/internals/simulation/simulation.d.cts.map +1 -0
- package/dist/internals/simulation/simulation.d.mts +103 -0
- package/dist/internals/simulation/simulation.d.mts.map +1 -0
- package/dist/internals/simulation/simulation.mjs +149 -37
- package/dist/internals/simulation/simulation.mjs.map +1 -1
- package/dist/internals/simulation/store/index.cjs +21 -0
- package/dist/internals/simulation/store/index.cjs.map +1 -0
- package/dist/internals/simulation/store/index.d.cts +5 -0
- package/dist/internals/simulation/store/index.d.cts.map +1 -0
- package/dist/internals/simulation/store/index.d.mts +5 -0
- package/dist/internals/simulation/store/index.d.mts.map +1 -0
- package/dist/internals/simulation/store/index.mjs +4 -43
- package/dist/internals/simulation/store/index.mjs.map +1 -1
- package/dist/internals/simulation/store/mocks.cjs +39 -0
- package/dist/internals/simulation/store/mocks.cjs.map +1 -0
- package/dist/{types/internals/simulation/store/mocks.d.ts → internals/simulation/store/mocks.d.cts} +8 -7
- package/dist/internals/simulation/store/mocks.d.cts.map +1 -0
- package/dist/internals/simulation/store/mocks.d.mts +36 -0
- package/dist/internals/simulation/store/mocks.d.mts.map +1 -0
- package/dist/internals/simulation/store/mocks.mjs +33 -14
- package/dist/internals/simulation/store/mocks.mjs.map +1 -1
- package/dist/internals/simulation/store/notifications.cjs +35 -0
- package/dist/internals/simulation/store/notifications.cjs.map +1 -0
- package/dist/{types/internals/simulation/store/notifications.d.ts → internals/simulation/store/notifications.d.cts} +8 -7
- package/dist/internals/simulation/store/notifications.d.cts.map +1 -0
- package/dist/internals/simulation/store/notifications.d.mts +45 -0
- package/dist/internals/simulation/store/notifications.d.mts.map +1 -0
- package/dist/internals/simulation/store/notifications.mjs +30 -14
- package/dist/internals/simulation/store/notifications.mjs.map +1 -1
- package/dist/internals/simulation/store/state.cjs +54 -0
- package/dist/internals/simulation/store/state.cjs.map +1 -0
- package/dist/{types/internals/simulation/store/state.d.ts → internals/simulation/store/state.d.cts} +7 -6
- package/dist/internals/simulation/store/state.d.cts.map +1 -0
- package/dist/internals/simulation/store/state.d.mts +56 -0
- package/dist/internals/simulation/store/state.d.mts.map +1 -0
- package/dist/internals/simulation/store/state.mjs +48 -12
- package/dist/internals/simulation/store/state.mjs.map +1 -1
- package/dist/internals/simulation/store/store.cjs +51 -0
- package/dist/internals/simulation/store/store.cjs.map +1 -0
- package/dist/{types/internals/simulation/store/store.d.ts → internals/simulation/store/store.d.cts} +6 -5
- package/dist/internals/simulation/store/store.d.cts.map +1 -0
- package/dist/internals/simulation/store/store.d.mts +22 -0
- package/dist/internals/simulation/store/store.d.mts.map +1 -0
- package/dist/internals/simulation/store/store.mjs +44 -11
- package/dist/internals/simulation/store/store.mjs.map +1 -1
- package/dist/internals/simulation/store/ui.cjs +24 -0
- package/dist/internals/simulation/store/ui.cjs.map +1 -0
- package/dist/{types/internals/simulation/store/ui.d.ts → internals/simulation/store/ui.d.cts} +9 -7
- package/dist/internals/simulation/store/ui.d.cts.map +1 -0
- package/dist/internals/simulation/store/ui.d.mts +27 -0
- package/dist/internals/simulation/store/ui.d.mts.map +1 -0
- package/dist/internals/simulation/store/ui.mjs +19 -14
- package/dist/internals/simulation/store/ui.mjs.map +1 -1
- package/dist/internals/structs.cjs +157 -0
- package/dist/internals/structs.cjs.map +1 -0
- package/dist/{types/internals/structs.d.ts → internals/structs.d.cts} +67 -66
- package/dist/internals/structs.d.cts.map +1 -0
- package/dist/internals/structs.d.mts +205 -0
- package/dist/internals/structs.d.mts.map +1 -0
- package/dist/internals/structs.mjs +153 -21
- package/dist/internals/structs.mjs.map +1 -1
- package/dist/matchers.cjs +160 -0
- package/dist/matchers.cjs.map +1 -0
- package/dist/{types/matchers.d.ts → matchers.d.cts} +4 -13
- package/dist/matchers.d.cts.map +1 -0
- package/dist/matchers.d.mts +28 -0
- package/dist/matchers.d.mts.map +1 -0
- package/dist/matchers.mjs +152 -49
- package/dist/matchers.mjs.map +1 -1
- package/dist/options.cjs +24 -0
- package/dist/options.cjs.map +1 -0
- package/dist/{types/options.d.ts → options.d.cts} +8 -7
- package/dist/options.d.cts.map +1 -0
- package/dist/options.d.mts +61 -0
- package/dist/options.d.mts.map +1 -0
- package/dist/options.mjs +19 -7
- package/dist/options.mjs.map +1 -1
- package/dist/setup.cjs +7 -0
- package/dist/setup.cjs.map +1 -0
- package/dist/setup.d.cts +2 -0
- package/dist/setup.d.cts.map +1 -0
- package/dist/setup.d.mts +2 -0
- package/dist/setup.d.mts.map +1 -0
- package/dist/setup.mjs +4 -37
- package/dist/setup.mjs.map +1 -1
- package/dist/types/index.cjs +18 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +2 -0
- package/dist/types/index.d.cts.map +1 -0
- package/dist/types/index.d.mts +2 -0
- package/dist/types/index.d.mts.map +1 -0
- package/dist/types/index.mjs +2 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/types/types.cjs +3 -0
- package/dist/types/types.cjs.map +1 -0
- package/dist/types/{types.d.ts → types.d.cts} +66 -26
- package/dist/types/types.d.cts.map +1 -0
- package/dist/types/types.d.mts +386 -0
- package/dist/types/types.d.mts.map +1 -0
- package/dist/types/types.mjs +2 -0
- package/dist/types/types.mjs.map +1 -0
- package/jest-preset.js +1 -1
- package/package.json +32 -30
- package/dist/chunk-265BMFM5.js +0 -13
- package/dist/chunk-265BMFM5.js.map +0 -1
- package/dist/chunk-2JTGBHPR.js +0 -14
- package/dist/chunk-2JTGBHPR.js.map +0 -1
- package/dist/chunk-2YE2P5BZ.js +0 -36
- package/dist/chunk-2YE2P5BZ.js.map +0 -1
- package/dist/chunk-3FNLFVV2.js +0 -15
- package/dist/chunk-3FNLFVV2.js.map +0 -1
- package/dist/chunk-3M4GRUMH.mjs +0 -54
- package/dist/chunk-3M4GRUMH.mjs.map +0 -1
- package/dist/chunk-43HRTFLS.mjs +0 -421
- package/dist/chunk-43HRTFLS.mjs.map +0 -1
- package/dist/chunk-44ARQBXS.js +0 -95
- package/dist/chunk-44ARQBXS.js.map +0 -1
- package/dist/chunk-4MAA7WGJ.js +0 -153
- package/dist/chunk-4MAA7WGJ.js.map +0 -1
- package/dist/chunk-55J6XMHW.js +0 -1
- package/dist/chunk-55J6XMHW.js.map +0 -1
- package/dist/chunk-57SGDM5B.mjs +0 -69
- package/dist/chunk-57SGDM5B.mjs.map +0 -1
- package/dist/chunk-5SGLRSWR.mjs +0 -153
- package/dist/chunk-5SGLRSWR.mjs.map +0 -1
- package/dist/chunk-5U5WB3SM.mjs +0 -41
- package/dist/chunk-5U5WB3SM.mjs.map +0 -1
- package/dist/chunk-5ZFHFICZ.mjs +0 -1
- package/dist/chunk-5ZFHFICZ.mjs.map +0 -1
- package/dist/chunk-6HHV6YFQ.mjs +0 -1
- package/dist/chunk-6HHV6YFQ.mjs.map +0 -1
- package/dist/chunk-6KXCBUNZ.mjs +0 -11
- package/dist/chunk-6KXCBUNZ.mjs.map +0 -1
- package/dist/chunk-74TIKA2T.mjs +0 -34
- package/dist/chunk-74TIKA2T.mjs.map +0 -1
- package/dist/chunk-7Y27L2EV.js +0 -211
- package/dist/chunk-7Y27L2EV.js.map +0 -1
- package/dist/chunk-ALRZENWP.mjs +0 -42
- package/dist/chunk-ALRZENWP.mjs.map +0 -1
- package/dist/chunk-B73P64TE.mjs +0 -28
- package/dist/chunk-B73P64TE.mjs.map +0 -1
- package/dist/chunk-CKRORVDW.js +0 -1
- package/dist/chunk-CKRORVDW.js.map +0 -1
- package/dist/chunk-CYPP66I7.mjs +0 -163
- package/dist/chunk-CYPP66I7.mjs.map +0 -1
- package/dist/chunk-DR6Y7IVX.js +0 -1
- package/dist/chunk-DR6Y7IVX.js.map +0 -1
- package/dist/chunk-DVDAOXO7.js +0 -134
- package/dist/chunk-DVDAOXO7.js.map +0 -1
- package/dist/chunk-EMTW3H54.js +0 -20
- package/dist/chunk-EMTW3H54.js.map +0 -1
- package/dist/chunk-FP4H3ADT.mjs +0 -20
- package/dist/chunk-FP4H3ADT.mjs.map +0 -1
- package/dist/chunk-FQWOVTBB.mjs +0 -22
- package/dist/chunk-FQWOVTBB.mjs.map +0 -1
- package/dist/chunk-GECE47HW.js +0 -1
- package/dist/chunk-GECE47HW.js.map +0 -1
- package/dist/chunk-GG2BCPQH.mjs +0 -95
- package/dist/chunk-GG2BCPQH.mjs.map +0 -1
- package/dist/chunk-GMTKFAWO.js +0 -42
- package/dist/chunk-GMTKFAWO.js.map +0 -1
- package/dist/chunk-GVTDUKXK.js +0 -421
- package/dist/chunk-GVTDUKXK.js.map +0 -1
- package/dist/chunk-H2464AXT.mjs +0 -33
- package/dist/chunk-H2464AXT.mjs.map +0 -1
- package/dist/chunk-HOI6FPLR.mjs +0 -240
- package/dist/chunk-HOI6FPLR.mjs.map +0 -1
- package/dist/chunk-HROOL3VI.js +0 -1
- package/dist/chunk-HROOL3VI.js.map +0 -1
- package/dist/chunk-IH7UNS5A.mjs +0 -36
- package/dist/chunk-IH7UNS5A.mjs.map +0 -1
- package/dist/chunk-IVFVB4VR.js +0 -163
- package/dist/chunk-IVFVB4VR.js.map +0 -1
- package/dist/chunk-IWJ4HKDR.mjs +0 -50
- package/dist/chunk-IWJ4HKDR.mjs.map +0 -1
- package/dist/chunk-IXKO6X55.mjs +0 -15
- package/dist/chunk-IXKO6X55.mjs.map +0 -1
- package/dist/chunk-J3I5KZIF.js +0 -22
- package/dist/chunk-J3I5KZIF.js.map +0 -1
- package/dist/chunk-J4ZPUCLX.mjs +0 -8
- package/dist/chunk-J4ZPUCLX.mjs.map +0 -1
- package/dist/chunk-JMDSN227.mjs +0 -25
- package/dist/chunk-JMDSN227.mjs.map +0 -1
- package/dist/chunk-KIQOUUEZ.mjs +0 -1
- package/dist/chunk-KIQOUUEZ.mjs.map +0 -1
- package/dist/chunk-KNJNL723.mjs +0 -39
- package/dist/chunk-KNJNL723.mjs.map +0 -1
- package/dist/chunk-KSIBNOB2.mjs +0 -13
- package/dist/chunk-KSIBNOB2.mjs.map +0 -1
- package/dist/chunk-LACTK6EO.js +0 -33
- package/dist/chunk-LACTK6EO.js.map +0 -1
- package/dist/chunk-LB4R3BUA.mjs +0 -36
- package/dist/chunk-LB4R3BUA.mjs.map +0 -1
- package/dist/chunk-LBC2OGSN.js +0 -48
- package/dist/chunk-LBC2OGSN.js.map +0 -1
- package/dist/chunk-MAT5SBM7.mjs +0 -211
- package/dist/chunk-MAT5SBM7.mjs.map +0 -1
- package/dist/chunk-MBQHVBLA.js +0 -89
- package/dist/chunk-MBQHVBLA.js.map +0 -1
- package/dist/chunk-MF43OG3Z.mjs +0 -1
- package/dist/chunk-MF43OG3Z.mjs.map +0 -1
- package/dist/chunk-MPZOXW6I.mjs +0 -48
- package/dist/chunk-MPZOXW6I.mjs.map +0 -1
- package/dist/chunk-N6MAO223.js +0 -60
- package/dist/chunk-N6MAO223.js.map +0 -1
- package/dist/chunk-NSMTFK33.mjs +0 -104
- package/dist/chunk-NSMTFK33.mjs.map +0 -1
- package/dist/chunk-NTOY6Y4Q.mjs +0 -1
- package/dist/chunk-NTOY6Y4Q.mjs.map +0 -1
- package/dist/chunk-O24GTINW.mjs +0 -134
- package/dist/chunk-O24GTINW.mjs.map +0 -1
- package/dist/chunk-ORO3T6BU.mjs +0 -24
- package/dist/chunk-ORO3T6BU.mjs.map +0 -1
- package/dist/chunk-PHUTP7NB.js +0 -25
- package/dist/chunk-PHUTP7NB.js.map +0 -1
- package/dist/chunk-PZDTZGSI.js +0 -34
- package/dist/chunk-PZDTZGSI.js.map +0 -1
- package/dist/chunk-Q2OQXAUM.mjs +0 -35
- package/dist/chunk-Q2OQXAUM.mjs.map +0 -1
- package/dist/chunk-RAMAN5RM.js +0 -24
- package/dist/chunk-RAMAN5RM.js.map +0 -1
- package/dist/chunk-RQKT6BQ2.mjs +0 -1
- package/dist/chunk-RQKT6BQ2.mjs.map +0 -1
- package/dist/chunk-S2HLITUN.js +0 -1
- package/dist/chunk-S2HLITUN.js.map +0 -1
- package/dist/chunk-SB5EPHE3.js +0 -41
- package/dist/chunk-SB5EPHE3.js.map +0 -1
- package/dist/chunk-SLU4FNKX.mjs +0 -60
- package/dist/chunk-SLU4FNKX.mjs.map +0 -1
- package/dist/chunk-SW65QYFV.js +0 -50
- package/dist/chunk-SW65QYFV.js.map +0 -1
- package/dist/chunk-T2PHS5FY.js +0 -28
- package/dist/chunk-T2PHS5FY.js.map +0 -1
- package/dist/chunk-TGZ7WOTJ.mjs +0 -1
- package/dist/chunk-TGZ7WOTJ.mjs.map +0 -1
- package/dist/chunk-TMAWGVZP.mjs +0 -89
- package/dist/chunk-TMAWGVZP.mjs.map +0 -1
- package/dist/chunk-TZB4LBT7.js +0 -8
- package/dist/chunk-TZB4LBT7.js.map +0 -1
- package/dist/chunk-UDOXICJK.mjs +0 -1
- package/dist/chunk-UDOXICJK.mjs.map +0 -1
- package/dist/chunk-VHJZERIC.js +0 -1
- package/dist/chunk-VHJZERIC.js.map +0 -1
- package/dist/chunk-VOYBI6T4.mjs +0 -22
- package/dist/chunk-VOYBI6T4.mjs.map +0 -1
- package/dist/chunk-VXPCUDBI.js +0 -36
- package/dist/chunk-VXPCUDBI.js.map +0 -1
- package/dist/chunk-WDYPMEZB.js +0 -22
- package/dist/chunk-WDYPMEZB.js.map +0 -1
- package/dist/chunk-WHGYMK5B.js +0 -1
- package/dist/chunk-WHGYMK5B.js.map +0 -1
- package/dist/chunk-WMLSD6B5.js +0 -54
- package/dist/chunk-WMLSD6B5.js.map +0 -1
- package/dist/chunk-WRKY2DLV.js +0 -104
- package/dist/chunk-WRKY2DLV.js.map +0 -1
- package/dist/chunk-XAOCS6ZD.js +0 -69
- package/dist/chunk-XAOCS6ZD.js.map +0 -1
- package/dist/chunk-XK5HPZZC.mjs +0 -14
- package/dist/chunk-XK5HPZZC.mjs.map +0 -1
- package/dist/chunk-XKJHFUHE.js +0 -11
- package/dist/chunk-XKJHFUHE.js.map +0 -1
- package/dist/chunk-XWGECIXI.js +0 -39
- package/dist/chunk-XWGECIXI.js.map +0 -1
- package/dist/chunk-Y3JC4WGW.js +0 -35
- package/dist/chunk-Y3JC4WGW.js.map +0 -1
- package/dist/chunk-YNUVT3HC.js +0 -240
- package/dist/chunk-YNUVT3HC.js.map +0 -1
- package/dist/chunk-ZG33OGC3.mjs +0 -1
- package/dist/chunk-ZG33OGC3.mjs.map +0 -1
- package/dist/chunk-ZTX624YO.js +0 -1
- package/dist/chunk-ZTX624YO.js.map +0 -1
- package/dist/environment.js +0 -46
- package/dist/environment.js.map +0 -1
- package/dist/global.js +0 -2
- package/dist/global.js.map +0 -1
- package/dist/helpers.js +0 -43
- package/dist/helpers.js.map +0 -1
- package/dist/index.js +0 -54
- package/dist/index.js.map +0 -1
- package/dist/internals/environment.js +0 -8
- package/dist/internals/environment.js.map +0 -1
- package/dist/internals/index.js +0 -142
- package/dist/internals/index.js.map +0 -1
- package/dist/internals/logger.js +0 -8
- package/dist/internals/logger.js.map +0 -1
- package/dist/internals/request.js +0 -42
- package/dist/internals/request.js.map +0 -1
- package/dist/internals/server.js +0 -9
- package/dist/internals/server.js.map +0 -1
- package/dist/internals/simulation/constants.js +0 -12
- package/dist/internals/simulation/constants.js.map +0 -1
- package/dist/internals/simulation/controllers.js +0 -25
- package/dist/internals/simulation/controllers.js.map +0 -1
- package/dist/internals/simulation/files.js +0 -14
- package/dist/internals/simulation/files.js.map +0 -1
- package/dist/internals/simulation/index.js +0 -103
- package/dist/internals/simulation/index.js.map +0 -1
- package/dist/internals/simulation/interface.js +0 -31
- package/dist/internals/simulation/interface.js.map +0 -1
- package/dist/internals/simulation/methods/constants.js +0 -12
- package/dist/internals/simulation/methods/constants.js.map +0 -1
- package/dist/internals/simulation/methods/hooks/get-locale.js +0 -8
- package/dist/internals/simulation/methods/hooks/get-locale.js.map +0 -1
- package/dist/internals/simulation/methods/hooks/get-locale.mjs +0 -8
- package/dist/internals/simulation/methods/hooks/get-locale.mjs.map +0 -1
- package/dist/internals/simulation/methods/hooks/index.js +0 -39
- package/dist/internals/simulation/methods/hooks/index.js.map +0 -1
- package/dist/internals/simulation/methods/hooks/interface.js +0 -10
- package/dist/internals/simulation/methods/hooks/interface.js.map +0 -1
- package/dist/internals/simulation/methods/hooks/notifications.js +0 -16
- package/dist/internals/simulation/methods/hooks/notifications.js.map +0 -1
- package/dist/internals/simulation/methods/hooks/show-dialog.js +0 -14
- package/dist/internals/simulation/methods/hooks/show-dialog.js.map +0 -1
- package/dist/internals/simulation/methods/hooks/show-dialog.mjs +0 -14
- package/dist/internals/simulation/methods/hooks/show-dialog.mjs.map +0 -1
- package/dist/internals/simulation/methods/hooks/state.js +0 -18
- package/dist/internals/simulation/methods/hooks/state.js.map +0 -1
- package/dist/internals/simulation/methods/index.js +0 -28
- package/dist/internals/simulation/methods/index.js.map +0 -1
- package/dist/internals/simulation/methods/specifications.js +0 -27
- package/dist/internals/simulation/methods/specifications.js.map +0 -1
- package/dist/internals/simulation/middleware/engine.js +0 -15
- package/dist/internals/simulation/middleware/engine.js.map +0 -1
- package/dist/internals/simulation/middleware/index.js +0 -16
- package/dist/internals/simulation/middleware/index.js.map +0 -1
- package/dist/internals/simulation/middleware/internal-methods/accounts.js +0 -8
- package/dist/internals/simulation/middleware/internal-methods/accounts.js.map +0 -1
- package/dist/internals/simulation/middleware/internal-methods/index.js +0 -11
- package/dist/internals/simulation/middleware/internal-methods/index.js.map +0 -1
- package/dist/internals/simulation/middleware/internal-methods/middleware.js +0 -10
- package/dist/internals/simulation/middleware/internal-methods/middleware.js.map +0 -1
- package/dist/internals/simulation/middleware/internal-methods/provider-state.js +0 -8
- package/dist/internals/simulation/middleware/internal-methods/provider-state.js.map +0 -1
- package/dist/internals/simulation/middleware/mock.js +0 -9
- package/dist/internals/simulation/middleware/mock.js.map +0 -1
- package/dist/internals/simulation/options.js +0 -9
- package/dist/internals/simulation/options.js.map +0 -1
- package/dist/internals/simulation/simulation.js +0 -38
- package/dist/internals/simulation/simulation.js.map +0 -1
- package/dist/internals/simulation/store/index.js +0 -44
- package/dist/internals/simulation/store/index.js.map +0 -1
- package/dist/internals/simulation/store/mocks.js +0 -16
- package/dist/internals/simulation/store/mocks.js.map +0 -1
- package/dist/internals/simulation/store/notifications.js +0 -16
- package/dist/internals/simulation/store/notifications.js.map +0 -1
- package/dist/internals/simulation/store/state.js +0 -14
- package/dist/internals/simulation/store/state.js.map +0 -1
- package/dist/internals/simulation/store/store.js +0 -12
- package/dist/internals/simulation/store/store.js.map +0 -1
- package/dist/internals/simulation/store/ui.js +0 -16
- package/dist/internals/simulation/store/ui.js.map +0 -1
- package/dist/internals/structs.js +0 -22
- package/dist/internals/structs.js.map +0 -1
- package/dist/matchers.js +0 -51
- package/dist/matchers.js.map +0 -1
- package/dist/options.js +0 -8
- package/dist/options.js.map +0 -1
- package/dist/setup.js +0 -38
- package/dist/setup.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/types/index.d.ts +0 -5
- package/dist/types/internals/index.d.ts +0 -6
- package/dist/types/internals/simulation/index.d.ts +0 -5
- package/dist/types/internals/simulation/methods/hooks/get-locale.d.ts +0 -9
- package/dist/types/internals/simulation/methods/hooks/index.d.ts +0 -5
- package/dist/types/internals/simulation/methods/hooks/show-dialog.d.ts +0 -9
- package/dist/types/internals/simulation/methods/index.d.ts +0 -1
- package/dist/types/internals/simulation/middleware/index.d.ts +0 -1
- package/dist/types/internals/simulation/middleware/internal-methods/index.d.ts +0 -1
- package/dist/types/internals/simulation/store/index.d.ts +0 -4
- package/dist/types/setup.d.ts +0 -1
- package/dist/types/vendor/readable-stream.d.js +0 -1
- package/dist/types/vendor/readable-stream.d.js.map +0 -1
- package/dist/types/vendor/readable-stream.d.mjs +0 -1
- package/dist/types/vendor/readable-stream.d.mjs.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/types.mjs +0 -2
- package/dist/types.mjs.map +0 -1
package/dist/chunk-SLU4FNKX.mjs
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
rootLogger
|
|
3
|
-
} from "./chunk-J4ZPUCLX.mjs";
|
|
4
|
-
|
|
5
|
-
// src/internals/server.ts
|
|
6
|
-
import {
|
|
7
|
-
assertIsSnapManifest,
|
|
8
|
-
isDirectory,
|
|
9
|
-
isFile
|
|
10
|
-
} from "@metamask/snaps-utils/node";
|
|
11
|
-
import { createModuleLogger } from "@metamask/utils";
|
|
12
|
-
import express from "express";
|
|
13
|
-
import { promises as fs } from "fs";
|
|
14
|
-
import { createServer } from "http";
|
|
15
|
-
import { resolve as pathResolve } from "path";
|
|
16
|
-
async function assertRoot(root) {
|
|
17
|
-
if (!root) {
|
|
18
|
-
throw new Error("You must specify a root directory.");
|
|
19
|
-
}
|
|
20
|
-
if (!await isDirectory(root, false)) {
|
|
21
|
-
throw new Error(`Root directory "${root}" is not a directory.`);
|
|
22
|
-
}
|
|
23
|
-
const manifestPath = pathResolve(root, "snap.manifest.json");
|
|
24
|
-
const manifest = await fs.readFile(manifestPath, "utf8").then(JSON.parse);
|
|
25
|
-
assertIsSnapManifest(manifest);
|
|
26
|
-
const filePath = pathResolve(root, manifest.source.location.npm.filePath);
|
|
27
|
-
if (!await isFile(filePath)) {
|
|
28
|
-
throw new Error(
|
|
29
|
-
`File "${filePath}" does not exist, or is not a file. Did you forget to build your snap?`
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
async function startServer(options) {
|
|
34
|
-
await assertRoot(options.root);
|
|
35
|
-
const log = createModuleLogger(rootLogger, "server");
|
|
36
|
-
const app = express();
|
|
37
|
-
app.use((_request, response, next) => {
|
|
38
|
-
response.header("Access-Control-Allow-Origin", "*");
|
|
39
|
-
response.header("Access-Control-Allow-Credentials", "true");
|
|
40
|
-
response.header("Access-Control-Allow-Methods", "GET, OPTIONS");
|
|
41
|
-
response.header("Access-Control-Allow-Headers", "Content-Type");
|
|
42
|
-
next();
|
|
43
|
-
});
|
|
44
|
-
app.use(express.static(pathResolve(process.cwd(), options.root)));
|
|
45
|
-
const server = createServer(app);
|
|
46
|
-
return await new Promise((resolve, reject) => {
|
|
47
|
-
server.listen(options.port, () => {
|
|
48
|
-
resolve(server);
|
|
49
|
-
});
|
|
50
|
-
server.on("error", (error) => {
|
|
51
|
-
log(error);
|
|
52
|
-
reject(error);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export {
|
|
58
|
-
startServer
|
|
59
|
-
};
|
|
60
|
-
//# sourceMappingURL=chunk-SLU4FNKX.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internals/server.ts"],"sourcesContent":["import type { SnapManifest } from '@metamask/snaps-utils';\nimport {\n assertIsSnapManifest,\n isDirectory,\n isFile,\n} from '@metamask/snaps-utils/node';\nimport { createModuleLogger } from '@metamask/utils';\nimport express from 'express';\nimport { promises as fs } from 'fs';\nimport type { Server } from 'http';\nimport { createServer } from 'http';\nimport { resolve as pathResolve } from 'path';\n\nimport type { SnapsEnvironmentOptions } from '../options';\nimport { rootLogger } from './logger';\n\nexport type ServerOptions = Required<\n // We need a double `Required` for the type to be inferred correctly.\n Required<SnapsEnvironmentOptions>['server']\n>;\n\n/**\n * Check that:\n *\n * - The root directory exists.\n * - The root directory contains a `snap.manifest.json` file.\n * - The file path in the manifest exists.\n *\n * @param root - The root directory.\n * @throws If any of the checks fail.\n */\nasync function assertRoot(root: string) {\n if (!root) {\n throw new Error('You must specify a root directory.');\n }\n\n if (!(await isDirectory(root, false))) {\n throw new Error(`Root directory \"${root}\" is not a directory.`);\n }\n\n const manifestPath = pathResolve(root, 'snap.manifest.json');\n const manifest: SnapManifest = await fs\n .readFile(manifestPath, 'utf8')\n .then(JSON.parse);\n\n assertIsSnapManifest(manifest);\n const filePath = pathResolve(root, manifest.source.location.npm.filePath);\n\n if (!(await isFile(filePath))) {\n throw new Error(\n `File \"${filePath}\" does not exist, or is not a file. Did you forget to build your snap?`,\n );\n }\n}\n\n/**\n * Start an HTTP server on `localhost` with a random port. This is used to serve\n * the static files for the environment.\n *\n * @param options - The options to use.\n * @param options.port - The port to use for the server.\n * @param options.root - The root directory to serve from the server.\n * @returns The HTTP server.\n */\nexport async function startServer(options: ServerOptions) {\n await assertRoot(options.root);\n\n const log = createModuleLogger(rootLogger, 'server');\n const app = express();\n\n app.use((_request, response, next) => {\n response.header('Access-Control-Allow-Origin', '*');\n response.header('Access-Control-Allow-Credentials', 'true');\n response.header('Access-Control-Allow-Methods', 'GET, OPTIONS');\n response.header('Access-Control-Allow-Headers', 'Content-Type');\n\n next();\n });\n\n app.use(express.static(pathResolve(process.cwd(), options.root)));\n\n const server = createServer(app);\n return await new Promise<Server>((resolve, reject) => {\n server.listen(options.port, () => {\n resolve(server);\n });\n\n server.on('error', (error) => {\n log(error);\n reject(error);\n });\n });\n}\n"],"mappings":";;;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;AACnC,OAAO,aAAa;AACpB,SAAS,YAAY,UAAU;AAE/B,SAAS,oBAAoB;AAC7B,SAAS,WAAW,mBAAmB;AAoBvC,eAAe,WAAW,MAAc;AACtC,MAAI,CAAC,MAAM;AACT,UAAM,IAAI,MAAM,oCAAoC;AAAA,EACtD;AAEA,MAAI,CAAE,MAAM,YAAY,MAAM,KAAK,GAAI;AACrC,UAAM,IAAI,MAAM,mBAAmB,IAAI,uBAAuB;AAAA,EAChE;AAEA,QAAM,eAAe,YAAY,MAAM,oBAAoB;AAC3D,QAAM,WAAyB,MAAM,GAClC,SAAS,cAAc,MAAM,EAC7B,KAAK,KAAK,KAAK;AAElB,uBAAqB,QAAQ;AAC7B,QAAM,WAAW,YAAY,MAAM,SAAS,OAAO,SAAS,IAAI,QAAQ;AAExE,MAAI,CAAE,MAAM,OAAO,QAAQ,GAAI;AAC7B,UAAM,IAAI;AAAA,MACR,SAAS,QAAQ;AAAA,IACnB;AAAA,EACF;AACF;AAWA,eAAsB,YAAY,SAAwB;AACxD,QAAM,WAAW,QAAQ,IAAI;AAE7B,QAAM,MAAM,mBAAmB,YAAY,QAAQ;AACnD,QAAM,MAAM,QAAQ;AAEpB,MAAI,IAAI,CAAC,UAAU,UAAU,SAAS;AACpC,aAAS,OAAO,+BAA+B,GAAG;AAClD,aAAS,OAAO,oCAAoC,MAAM;AAC1D,aAAS,OAAO,gCAAgC,cAAc;AAC9D,aAAS,OAAO,gCAAgC,cAAc;AAE9D,SAAK;AAAA,EACP,CAAC;AAED,MAAI,IAAI,QAAQ,OAAO,YAAY,QAAQ,IAAI,GAAG,QAAQ,IAAI,CAAC,CAAC;AAEhE,QAAM,SAAS,aAAa,GAAG;AAC/B,SAAO,MAAM,IAAI,QAAgB,CAAC,SAAS,WAAW;AACpD,WAAO,OAAO,QAAQ,MAAM,MAAM;AAChC,cAAQ,MAAM;AAAA,IAChB,CAAC;AAED,WAAO,GAAG,SAAS,CAAC,UAAU;AAC5B,UAAI,KAAK;AACT,aAAO,KAAK;AAAA,IACd,CAAC;AAAA,EACH,CAAC;AACH;","names":[]}
|
package/dist/chunk-SW65QYFV.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/internals/simulation/files.ts
|
|
2
|
-
var _snapssdk = require('@metamask/snaps-sdk');
|
|
3
|
-
var _snapsutils = require('@metamask/snaps-utils');
|
|
4
|
-
var _utils = require('@metamask/utils');
|
|
5
|
-
var _promises = require('fs/promises');
|
|
6
|
-
var _mime = require('mime'); var _mime2 = _interopRequireDefault(_mime);
|
|
7
|
-
var _path = require('path');
|
|
8
|
-
async function getSnapFile(files, path, encoding = _snapssdk.AuxiliaryFileEncoding.Base64) {
|
|
9
|
-
const normalizedPath = _snapsutils.normalizeRelative.call(void 0, path);
|
|
10
|
-
const base64 = files.find((file) => file.path === normalizedPath)?.toString("base64");
|
|
11
|
-
if (!base64) {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
return await _snapsutils.encodeAuxiliaryFile.call(void 0, base64, encoding);
|
|
15
|
-
}
|
|
16
|
-
function getContentType(extension) {
|
|
17
|
-
return _mime2.default.getType(extension) ?? "application/octet-stream";
|
|
18
|
-
}
|
|
19
|
-
async function getFileSize(file) {
|
|
20
|
-
if (typeof file === "string") {
|
|
21
|
-
const { size } = await _promises.stat.call(void 0, _path.resolve.call(void 0, process.cwd(), file));
|
|
22
|
-
return size;
|
|
23
|
-
}
|
|
24
|
-
return file.length;
|
|
25
|
-
}
|
|
26
|
-
async function getFileToUpload(file, { fileName, contentType } = {}) {
|
|
27
|
-
if (typeof file === "string") {
|
|
28
|
-
const buffer = await _promises.readFile.call(void 0, _path.resolve.call(void 0, process.cwd(), file));
|
|
29
|
-
return {
|
|
30
|
-
name: fileName ?? _path.basename.call(void 0, file),
|
|
31
|
-
size: buffer.byteLength,
|
|
32
|
-
contentType: contentType ?? getContentType(_path.extname.call(void 0, file)),
|
|
33
|
-
contents: _utils.bytesToBase64.call(void 0, buffer)
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
name: fileName ?? "",
|
|
38
|
-
size: file.length,
|
|
39
|
-
contentType: contentType ?? "application/octet-stream",
|
|
40
|
-
contents: _utils.bytesToBase64.call(void 0, file)
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
exports.getSnapFile = getSnapFile; exports.getContentType = getContentType; exports.getFileSize = getFileSize; exports.getFileToUpload = getFileToUpload;
|
|
50
|
-
//# sourceMappingURL=chunk-SW65QYFV.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internals/simulation/files.ts"],"names":[],"mappings":";AACA,SAAS,6BAA6B;AAEtC,SAAS,qBAAqB,yBAAyB;AACvD,SAAS,qBAAqB;AAC9B,SAAS,UAAU,YAAY;AAC/B,OAAO,UAAU;AACjB,SAAS,UAAU,SAAS,eAAe;AAY3C,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;AASO,SAAS,eAAe,WAAmB;AAChD,SAAO,KAAK,QAAQ,SAAS,KAAK;AACpC;AAUA,eAAsB,YAAY,MAA2B;AAC3D,MAAI,OAAO,SAAS,UAAU;AAC5B,UAAM,EAAE,KAAK,IAAI,MAAM,KAAK,QAAQ,QAAQ,IAAI,GAAG,IAAI,CAAC;AACxD,WAAO;AAAA,EACT;AAEA,SAAO,KAAK;AACd;AAkBA,eAAsB,gBACpB,MACA,EAAE,UAAU,YAAY,IAAiB,CAAC,GAC3B;AACf,MAAI,OAAO,SAAS,UAAU;AAC5B,UAAM,SAAS,MAAM,SAAS,QAAQ,QAAQ,IAAI,GAAG,IAAI,CAAC;AAE1D,WAAO;AAAA,MACL,MAAM,YAAY,SAAS,IAAI;AAAA,MAC/B,MAAM,OAAO;AAAA,MACb,aAAa,eAAe,eAAe,QAAQ,IAAI,CAAC;AAAA,MACxD,UAAU,cAAc,MAAM;AAAA,IAChC;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM,YAAY;AAAA,IAClB,MAAM,KAAK;AAAA,IACX,aAAa,eAAe;AAAA,IAC5B,UAAU,cAAc,IAAI;AAAA,EAC9B;AACF","sourcesContent":["import type { File } from '@metamask/snaps-sdk';\nimport { AuxiliaryFileEncoding } from '@metamask/snaps-sdk';\nimport type { VirtualFile } from '@metamask/snaps-utils';\nimport { encodeAuxiliaryFile, normalizeRelative } from '@metamask/snaps-utils';\nimport { bytesToBase64 } from '@metamask/utils';\nimport { readFile, stat } from 'fs/promises';\nimport mime from 'mime';\nimport { basename, extname, resolve } from 'path';\n\nimport type { FileOptions } from '../../types';\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\n/**\n * Get the content type of a file based on its extension.\n *\n * @param extension - The file extension.\n * @returns The content type of the file. If the content type cannot be inferred\n * from the extension, `application/octet-stream` is returned.\n */\nexport function getContentType(extension: string) {\n return mime.getType(extension) ?? 'application/octet-stream';\n}\n\n/**\n * Get the size of a file, from a file path or a `Uint8Array`.\n *\n * @param file - The file to get the size of. This can be a path to a file or a\n * `Uint8Array` containing the file contents. If this is a path, the file is\n * resolved relative to the current working directory.\n * @returns The size of the file in bytes.\n */\nexport async function getFileSize(file: string | Uint8Array) {\n if (typeof file === 'string') {\n const { size } = await stat(resolve(process.cwd(), file));\n return size;\n }\n\n return file.length;\n}\n\n/**\n * Get a file object to upload, from a file path or a `Uint8Array`, with an\n * optional file name and content type.\n *\n * @param file - The file to upload. This can be a path to a file or a\n * `Uint8Array` containing the file contents. If this is a path, the file is\n * resolved relative to the current working directory.\n * @param options - The file options.\n * @param options.fileName - The name of the file. By default, this is\n * inferred from the file path if it's a path, and defaults to an empty string\n * if it's a `Uint8Array`.\n * @param options.contentType - The content type of the file. By default, this\n * is inferred from the file name if it's a path, and defaults to\n * `application/octet-stream` if it's a `Uint8Array` or the content type\n * cannot be inferred from the file name.\n */\nexport async function getFileToUpload(\n file: string | Uint8Array,\n { fileName, contentType }: FileOptions = {},\n): Promise<File> {\n if (typeof file === 'string') {\n const buffer = await readFile(resolve(process.cwd(), file));\n\n return {\n name: fileName ?? basename(file),\n size: buffer.byteLength,\n contentType: contentType ?? getContentType(extname(file)),\n contents: bytesToBase64(buffer),\n };\n }\n\n return {\n name: fileName ?? '',\n size: file.length,\n contentType: contentType ?? 'application/octet-stream',\n contents: bytesToBase64(file),\n };\n}\n"]}
|
package/dist/chunk-T2PHS5FY.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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-T2PHS5FY.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
package/dist/chunk-TGZ7WOTJ.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-TGZ7WOTJ.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/chunk-TMAWGVZP.mjs
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getGetLocaleMethodImplementation
|
|
3
|
-
} from "./chunk-KSIBNOB2.mjs";
|
|
4
|
-
import {
|
|
5
|
-
getCreateInterfaceImplementation,
|
|
6
|
-
getGetInterfaceImplementation
|
|
7
|
-
} from "./chunk-FQWOVTBB.mjs";
|
|
8
|
-
import {
|
|
9
|
-
getShowInAppNotificationImplementation,
|
|
10
|
-
getShowNativeNotificationImplementation
|
|
11
|
-
} from "./chunk-ALRZENWP.mjs";
|
|
12
|
-
import {
|
|
13
|
-
getShowDialogImplementation
|
|
14
|
-
} from "./chunk-ORO3T6BU.mjs";
|
|
15
|
-
import {
|
|
16
|
-
getClearSnapStateMethodImplementation,
|
|
17
|
-
getGetSnapStateMethodImplementation,
|
|
18
|
-
getUpdateSnapStateMethodImplementation
|
|
19
|
-
} from "./chunk-5U5WB3SM.mjs";
|
|
20
|
-
import {
|
|
21
|
-
EXCLUDED_SNAP_ENDOWMENTS,
|
|
22
|
-
EXCLUDED_SNAP_PERMISSIONS
|
|
23
|
-
} from "./chunk-57SGDM5B.mjs";
|
|
24
|
-
|
|
25
|
-
// src/internals/simulation/methods/specifications.ts
|
|
26
|
-
import {
|
|
27
|
-
endowmentPermissionBuilders,
|
|
28
|
-
buildSnapEndowmentSpecifications,
|
|
29
|
-
buildSnapRestrictedMethodSpecifications
|
|
30
|
-
} from "@metamask/snaps-rpc-methods";
|
|
31
|
-
import { DEFAULT_ENDOWMENTS } from "@metamask/snaps-utils";
|
|
32
|
-
function resolve(result) {
|
|
33
|
-
return () => result;
|
|
34
|
-
}
|
|
35
|
-
function asyncResolve(result) {
|
|
36
|
-
return async () => result;
|
|
37
|
-
}
|
|
38
|
-
function getPermissionSpecifications({
|
|
39
|
-
controllerMessenger,
|
|
40
|
-
hooks,
|
|
41
|
-
runSaga,
|
|
42
|
-
options
|
|
43
|
-
}) {
|
|
44
|
-
return {
|
|
45
|
-
...buildSnapEndowmentSpecifications(EXCLUDED_SNAP_ENDOWMENTS),
|
|
46
|
-
...buildSnapRestrictedMethodSpecifications(EXCLUDED_SNAP_PERMISSIONS, {
|
|
47
|
-
// Shared hooks.
|
|
48
|
-
...hooks,
|
|
49
|
-
// Snaps-specific hooks.
|
|
50
|
-
clearSnapState: getClearSnapStateMethodImplementation(runSaga),
|
|
51
|
-
getLocale: getGetLocaleMethodImplementation(options),
|
|
52
|
-
getSnapState: getGetSnapStateMethodImplementation(runSaga),
|
|
53
|
-
getUnlockPromise: asyncResolve(true),
|
|
54
|
-
// TODO: Allow the user to specify the result of this function.
|
|
55
|
-
isOnPhishingList: resolve(false),
|
|
56
|
-
maybeUpdatePhishingList: asyncResolve(),
|
|
57
|
-
showDialog: getShowDialogImplementation(runSaga),
|
|
58
|
-
showInAppNotification: getShowInAppNotificationImplementation(runSaga),
|
|
59
|
-
showNativeNotification: getShowNativeNotificationImplementation(runSaga),
|
|
60
|
-
updateSnapState: getUpdateSnapStateMethodImplementation(runSaga),
|
|
61
|
-
createInterface: getCreateInterfaceImplementation(controllerMessenger),
|
|
62
|
-
getInterface: getGetInterfaceImplementation(controllerMessenger)
|
|
63
|
-
})
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
async function getEndowments(permissionController, snapId) {
|
|
67
|
-
const allEndowments = await Object.keys(endowmentPermissionBuilders).reduce(async (promise, permissionName) => {
|
|
68
|
-
const accumulator = await promise;
|
|
69
|
-
if (permissionController.hasPermission(snapId, permissionName)) {
|
|
70
|
-
const endowments = await permissionController.getEndowments(
|
|
71
|
-
snapId,
|
|
72
|
-
permissionName
|
|
73
|
-
);
|
|
74
|
-
if (endowments) {
|
|
75
|
-
return accumulator.concat(endowments);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return accumulator;
|
|
79
|
-
}, Promise.resolve([]));
|
|
80
|
-
return [.../* @__PURE__ */ new Set([...DEFAULT_ENDOWMENTS, ...allEndowments])];
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export {
|
|
84
|
-
resolve,
|
|
85
|
-
asyncResolve,
|
|
86
|
-
getPermissionSpecifications,
|
|
87
|
-
getEndowments
|
|
88
|
-
};
|
|
89
|
-
//# sourceMappingURL=chunk-TMAWGVZP.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internals/simulation/methods/specifications.ts"],"sourcesContent":["import type { GenericPermissionController } from '@metamask/permission-controller';\nimport {\n endowmentPermissionBuilders,\n buildSnapEndowmentSpecifications,\n buildSnapRestrictedMethodSpecifications,\n} from '@metamask/snaps-rpc-methods';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { DEFAULT_ENDOWMENTS } from '@metamask/snaps-utils';\n\nimport type { RootControllerMessenger } from '../controllers';\nimport type { SimulationOptions } from '../options';\nimport type { RunSagaFunction } from '../store';\nimport {\n EXCLUDED_SNAP_ENDOWMENTS,\n EXCLUDED_SNAP_PERMISSIONS,\n} from './constants';\nimport {\n getGetLocaleMethodImplementation,\n getClearSnapStateMethodImplementation,\n getGetSnapStateMethodImplementation,\n getUpdateSnapStateMethodImplementation,\n getShowDialogImplementation,\n getShowInAppNotificationImplementation,\n getShowNativeNotificationImplementation,\n getCreateInterfaceImplementation,\n getGetInterfaceImplementation,\n} from './hooks';\n\nexport type PermissionSpecificationsHooks = {\n /**\n * A hook that returns the user's secret recovery phrase.\n *\n * @returns The user's secret recovery phrase.\n */\n getMnemonic: () => Promise<Uint8Array>;\n};\n\nexport type GetPermissionSpecificationsOptions = {\n controllerMessenger: RootControllerMessenger;\n hooks: PermissionSpecificationsHooks;\n runSaga: RunSagaFunction;\n options: SimulationOptions;\n};\n\n/**\n * Get a function which resolves with the specified result.\n *\n * @param result - The result to return.\n * @returns The function implementation.\n */\nexport function resolve(result: unknown) {\n return () => result;\n}\n\n/**\n * Get a function which resolves with the specified result.\n *\n * @param result - The result to return. If not specified, the function will\n * resolve with `undefined`.\n * @returns The function implementation.\n */\nexport function asyncResolve(result?: unknown) {\n return async () => result;\n}\n\n/**\n * Get the permission specifications for the Snap.\n *\n * @param options - The options.\n * @param options.controllerMessenger - The controller messenger.\n * @param options.hooks - The hooks.\n * @param options.runSaga - The function to run a saga outside the usual Redux\n * flow.\n * @param options.options - The simulation options.\n * @returns The permission specifications for the Snap.\n */\nexport function getPermissionSpecifications({\n controllerMessenger,\n hooks,\n runSaga,\n options,\n}: GetPermissionSpecificationsOptions) {\n return {\n ...buildSnapEndowmentSpecifications(EXCLUDED_SNAP_ENDOWMENTS),\n ...buildSnapRestrictedMethodSpecifications(EXCLUDED_SNAP_PERMISSIONS, {\n // Shared hooks.\n ...hooks,\n\n // Snaps-specific hooks.\n clearSnapState: getClearSnapStateMethodImplementation(runSaga),\n getLocale: getGetLocaleMethodImplementation(options),\n getSnapState: getGetSnapStateMethodImplementation(runSaga),\n getUnlockPromise: asyncResolve(true),\n\n // TODO: Allow the user to specify the result of this function.\n isOnPhishingList: resolve(false),\n\n maybeUpdatePhishingList: asyncResolve(),\n showDialog: getShowDialogImplementation(runSaga),\n showInAppNotification: getShowInAppNotificationImplementation(runSaga),\n showNativeNotification: getShowNativeNotificationImplementation(runSaga),\n updateSnapState: getUpdateSnapStateMethodImplementation(runSaga),\n createInterface: getCreateInterfaceImplementation(controllerMessenger),\n getInterface: getGetInterfaceImplementation(controllerMessenger),\n }),\n };\n}\n\n/**\n * Get the endowments for the Snap.\n *\n * @param permissionController - The permission controller.\n * @param snapId - The ID of the Snap.\n * @returns The endowments for the Snap.\n */\nexport async function getEndowments(\n permissionController: GenericPermissionController,\n snapId: SnapId,\n) {\n const allEndowments = await Object.keys(endowmentPermissionBuilders).reduce<\n Promise<string[]>\n >(async (promise, permissionName) => {\n const accumulator = await promise;\n if (permissionController.hasPermission(snapId, permissionName)) {\n const endowments = await permissionController.getEndowments(\n snapId,\n permissionName,\n );\n\n if (endowments) {\n return accumulator.concat(endowments as string[]);\n }\n }\n\n return accumulator;\n }, Promise.resolve([]));\n\n return [...new Set([...DEFAULT_ENDOWMENTS, ...allEndowments])];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,0BAA0B;AA2C5B,SAAS,QAAQ,QAAiB;AACvC,SAAO,MAAM;AACf;AASO,SAAS,aAAa,QAAkB;AAC7C,SAAO,YAAY;AACrB;AAaO,SAAS,4BAA4B;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAuC;AACrC,SAAO;AAAA,IACL,GAAG,iCAAiC,wBAAwB;AAAA,IAC5D,GAAG,wCAAwC,2BAA2B;AAAA;AAAA,MAEpE,GAAG;AAAA;AAAA,MAGH,gBAAgB,sCAAsC,OAAO;AAAA,MAC7D,WAAW,iCAAiC,OAAO;AAAA,MACnD,cAAc,oCAAoC,OAAO;AAAA,MACzD,kBAAkB,aAAa,IAAI;AAAA;AAAA,MAGnC,kBAAkB,QAAQ,KAAK;AAAA,MAE/B,yBAAyB,aAAa;AAAA,MACtC,YAAY,4BAA4B,OAAO;AAAA,MAC/C,uBAAuB,uCAAuC,OAAO;AAAA,MACrE,wBAAwB,wCAAwC,OAAO;AAAA,MACvE,iBAAiB,uCAAuC,OAAO;AAAA,MAC/D,iBAAiB,iCAAiC,mBAAmB;AAAA,MACrE,cAAc,8BAA8B,mBAAmB;AAAA,IACjE,CAAC;AAAA,EACH;AACF;AASA,eAAsB,cACpB,sBACA,QACA;AACA,QAAM,gBAAgB,MAAM,OAAO,KAAK,2BAA2B,EAAE,OAEnE,OAAO,SAAS,mBAAmB;AACnC,UAAM,cAAc,MAAM;AAC1B,QAAI,qBAAqB,cAAc,QAAQ,cAAc,GAAG;AAC9D,YAAM,aAAa,MAAM,qBAAqB;AAAA,QAC5C;AAAA,QACA;AAAA,MACF;AAEA,UAAI,YAAY;AACd,eAAO,YAAY,OAAO,UAAsB;AAAA,MAClD;AAAA,IACF;AAEA,WAAO;AAAA,EACT,GAAG,QAAQ,QAAQ,CAAC,CAAC,CAAC;AAEtB,SAAO,CAAC,GAAG,oBAAI,IAAI,CAAC,GAAG,oBAAoB,GAAG,aAAa,CAAC,CAAC;AAC/D;","names":[]}
|
package/dist/chunk-TZB4LBT7.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/internals/logger.ts
|
|
2
|
-
var _utils = require('@metamask/utils');
|
|
3
|
-
var rootLogger = _utils.createProjectLogger.call(void 0, "snaps-jest");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.rootLogger = rootLogger;
|
|
8
|
-
//# sourceMappingURL=chunk-TZB4LBT7.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internals/logger.ts"],"names":[],"mappings":";AAAA,SAAS,2BAA2B;AAE7B,IAAM,aAAa,oBAAoB,YAAY","sourcesContent":["import { createProjectLogger } from '@metamask/utils';\n\nexport const rootLogger = createProjectLogger('snaps-jest');\n"]}
|
package/dist/chunk-UDOXICJK.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-UDOXICJK.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/chunk-VHJZERIC.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";//# sourceMappingURL=chunk-VHJZERIC.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/chunk-VOYBI6T4.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// src/internals/simulation/middleware/internal-methods/accounts.ts
|
|
2
|
-
import { BIP44Node } from "@metamask/key-tree";
|
|
3
|
-
async function getAccountsHandler(_request, response, _next, end, hooks) {
|
|
4
|
-
const { getMnemonic } = hooks;
|
|
5
|
-
const node = await BIP44Node.fromDerivationPath({
|
|
6
|
-
derivationPath: [
|
|
7
|
-
await getMnemonic(),
|
|
8
|
-
`bip32:44'`,
|
|
9
|
-
`bip32:60'`,
|
|
10
|
-
`bip32:0'`,
|
|
11
|
-
`bip32:0`,
|
|
12
|
-
`bip32:0`
|
|
13
|
-
]
|
|
14
|
-
});
|
|
15
|
-
response.result = [node.address];
|
|
16
|
-
return end();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export {
|
|
20
|
-
getAccountsHandler
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=chunk-VOYBI6T4.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internals/simulation/middleware/internal-methods/accounts.ts"],"sourcesContent":["import type {\n JsonRpcEngineEndCallback,\n JsonRpcEngineNextCallback,\n} from '@metamask/json-rpc-engine';\nimport { BIP44Node } from '@metamask/key-tree';\nimport type {\n Json,\n JsonRpcRequest,\n PendingJsonRpcResponse,\n} from '@metamask/utils';\n\nexport type GetAccountsHandlerHooks = {\n getMnemonic: () => Promise<Uint8Array>;\n};\n\n/**\n * A mock handler for account related methods that always returns the first\n * address for the selected secret recovery phrase.\n *\n * @param _request - Incoming JSON-RPC request. This is ignored for this\n * specific handler.\n * @param response - The outgoing JSON-RPC response, modified to return the\n * result.\n * @param _next - The `json-rpc-engine` middleware next handler.\n * @param end - The `json-rpc-engine` middleware end handler.\n * @param hooks - Any hooks required by this handler.\n */\nexport async function getAccountsHandler(\n _request: JsonRpcRequest,\n response: PendingJsonRpcResponse<Json>,\n _next: JsonRpcEngineNextCallback,\n end: JsonRpcEngineEndCallback,\n hooks: GetAccountsHandlerHooks,\n) {\n const { getMnemonic } = hooks;\n\n const node = await BIP44Node.fromDerivationPath({\n derivationPath: [\n await getMnemonic(),\n `bip32:44'`,\n `bip32:60'`,\n `bip32:0'`,\n `bip32:0`,\n `bip32:0`,\n ],\n });\n\n response.result = [node.address];\n return end();\n}\n"],"mappings":";AAIA,SAAS,iBAAiB;AAuB1B,eAAsB,mBACpB,UACA,UACA,OACA,KACA,OACA;AACA,QAAM,EAAE,YAAY,IAAI;AAExB,QAAM,OAAO,MAAM,UAAU,mBAAmB;AAAA,IAC9C,gBAAgB;AAAA,MACd,MAAM,YAAY;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AAED,WAAS,SAAS,CAAC,KAAK,OAAO;AAC/B,SAAO,IAAI;AACb;","names":[]}
|
package/dist/chunk-VXPCUDBI.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _chunkXKJHFUHEjs = require('./chunk-XKJHFUHE.js');
|
|
5
|
-
|
|
6
|
-
// src/internals/simulation/options.ts
|
|
7
|
-
var _utils = require('@metamask/utils');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var _superstruct = require('superstruct');
|
|
17
|
-
var SimulationOptionsStruct = _superstruct.object.call(void 0, {
|
|
18
|
-
secretRecoveryPhrase: _superstruct.defaulted.call(void 0, _superstruct.optional.call(void 0, _superstruct.string.call(void 0, )), _chunkXKJHFUHEjs.DEFAULT_SRP),
|
|
19
|
-
locale: _superstruct.defaulted.call(void 0, _superstruct.optional.call(void 0, _superstruct.string.call(void 0, )), _chunkXKJHFUHEjs.DEFAULT_LOCALE),
|
|
20
|
-
state: _superstruct.defaulted.call(void 0, _superstruct.optional.call(void 0, _superstruct.nullable.call(void 0, _superstruct.record.call(void 0, _superstruct.string.call(void 0, ), _utils.JsonStruct))), null),
|
|
21
|
-
unencryptedState: _superstruct.defaulted.call(void 0,
|
|
22
|
-
_superstruct.optional.call(void 0, _superstruct.nullable.call(void 0, _superstruct.record.call(void 0, _superstruct.string.call(void 0, ), _utils.JsonStruct))),
|
|
23
|
-
null
|
|
24
|
-
)
|
|
25
|
-
});
|
|
26
|
-
function getOptions(options) {
|
|
27
|
-
return _superstruct.create.call(void 0,
|
|
28
|
-
options,
|
|
29
|
-
SimulationOptionsStruct
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
exports.getOptions = getOptions;
|
|
36
|
-
//# sourceMappingURL=chunk-VXPCUDBI.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internals/simulation/options.ts"],"names":[],"mappings":";;;;;;AAAA,SAAS,kBAAkB;AAE3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAIP,IAAM,0BAA0B,OAAO;AAAA,EACrC,sBAAsB,UAAU,SAAS,OAAO,CAAC,GAAG,WAAW;AAAA,EAC/D,QAAQ,UAAU,SAAS,OAAO,CAAC,GAAG,cAAc;AAAA,EACpD,OAAO,UAAU,SAAS,SAAS,OAAO,OAAO,GAAG,UAAU,CAAC,CAAC,GAAG,IAAI;AAAA,EACvE,kBAAkB;AAAA,IAChB,SAAS,SAAS,OAAO,OAAO,GAAG,UAAU,CAAC,CAAC;AAAA,IAC/C;AAAA,EACF;AACF,CAAC;AA2BM,SAAS,WAAW,SAAmD;AAC5E,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF","sourcesContent":["import { JsonStruct } from '@metamask/utils';\nimport type { Infer } from 'superstruct';\nimport {\n create,\n defaulted,\n nullable,\n object,\n optional,\n record,\n string,\n} from 'superstruct';\n\nimport { DEFAULT_LOCALE, DEFAULT_SRP } from './constants';\n\nconst SimulationOptionsStruct = object({\n secretRecoveryPhrase: defaulted(optional(string()), DEFAULT_SRP),\n locale: defaulted(optional(string()), DEFAULT_LOCALE),\n state: defaulted(optional(nullable(record(string(), JsonStruct))), null),\n unencryptedState: defaulted(\n optional(nullable(record(string(), JsonStruct))),\n null,\n ),\n});\n\n/**\n * Options for the simulation.\n *\n * @property secretRecoveryPhrase - The secret recovery phrase to use. This is\n * used to derive addresses and private keys. Defaults to a test recovery\n * phrase.\n * @property locale - The locale to use. Defaults to `en`.\n * @property state - The initial state of the Snap, if any. Defaults to `null`.\n */\nexport type SimulationUserOptions = Infer<typeof SimulationOptionsStruct>;\n\n/**\n * Options for the simulation, with defaults filled in.\n *\n * See {@link SimulationUserOptions} for documentation.\n */\nexport type SimulationOptions = Required<SimulationUserOptions>;\n\n/**\n * Get the options for the simulation.\n *\n * @param options - The user options. Any options not specified will be filled\n * in with default values.\n * @returns The simulation options.\n */\nexport function getOptions(options: SimulationUserOptions): SimulationOptions {\n return create(\n options,\n SimulationOptionsStruct,\n ) as Required<SimulationUserOptions>;\n}\n"]}
|
package/dist/chunk-WDYPMEZB.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/internals/simulation/middleware/internal-methods/accounts.ts
|
|
2
|
-
var _keytree = require('@metamask/key-tree');
|
|
3
|
-
async function getAccountsHandler(_request, response, _next, end, hooks) {
|
|
4
|
-
const { getMnemonic } = hooks;
|
|
5
|
-
const node = await _keytree.BIP44Node.fromDerivationPath({
|
|
6
|
-
derivationPath: [
|
|
7
|
-
await getMnemonic(),
|
|
8
|
-
`bip32:44'`,
|
|
9
|
-
`bip32:60'`,
|
|
10
|
-
`bip32:0'`,
|
|
11
|
-
`bip32:0`,
|
|
12
|
-
`bip32:0`
|
|
13
|
-
]
|
|
14
|
-
});
|
|
15
|
-
response.result = [node.address];
|
|
16
|
-
return end();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
exports.getAccountsHandler = getAccountsHandler;
|
|
22
|
-
//# sourceMappingURL=chunk-WDYPMEZB.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internals/simulation/middleware/internal-methods/accounts.ts"],"names":[],"mappings":";AAIA,SAAS,iBAAiB;AAuB1B,eAAsB,mBACpB,UACA,UACA,OACA,KACA,OACA;AACA,QAAM,EAAE,YAAY,IAAI;AAExB,QAAM,OAAO,MAAM,UAAU,mBAAmB;AAAA,IAC9C,gBAAgB;AAAA,MACd,MAAM,YAAY;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AAED,WAAS,SAAS,CAAC,KAAK,OAAO;AAC/B,SAAO,IAAI;AACb","sourcesContent":["import type {\n JsonRpcEngineEndCallback,\n JsonRpcEngineNextCallback,\n} from '@metamask/json-rpc-engine';\nimport { BIP44Node } from '@metamask/key-tree';\nimport type {\n Json,\n JsonRpcRequest,\n PendingJsonRpcResponse,\n} from '@metamask/utils';\n\nexport type GetAccountsHandlerHooks = {\n getMnemonic: () => Promise<Uint8Array>;\n};\n\n/**\n * A mock handler for account related methods that always returns the first\n * address for the selected secret recovery phrase.\n *\n * @param _request - Incoming JSON-RPC request. This is ignored for this\n * specific handler.\n * @param response - The outgoing JSON-RPC response, modified to return the\n * result.\n * @param _next - The `json-rpc-engine` middleware next handler.\n * @param end - The `json-rpc-engine` middleware end handler.\n * @param hooks - Any hooks required by this handler.\n */\nexport async function getAccountsHandler(\n _request: JsonRpcRequest,\n response: PendingJsonRpcResponse<Json>,\n _next: JsonRpcEngineNextCallback,\n end: JsonRpcEngineEndCallback,\n hooks: GetAccountsHandlerHooks,\n) {\n const { getMnemonic } = hooks;\n\n const node = await BIP44Node.fromDerivationPath({\n derivationPath: [\n await getMnemonic(),\n `bip32:44'`,\n `bip32:60'`,\n `bip32:0'`,\n `bip32:0`,\n `bip32:0`,\n ],\n });\n\n response.result = [node.address];\n return end();\n}\n"]}
|
package/dist/chunk-WHGYMK5B.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";//# sourceMappingURL=chunk-WHGYMK5B.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/chunk-WMLSD6B5.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
-
|
|
3
|
-
var _chunkPZDTZGSIjs = require('./chunk-PZDTZGSI.js');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunkLACTK6EOjs = require('./chunk-LACTK6EO.js');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _chunk2YE2P5BZjs = require('./chunk-2YE2P5BZ.js');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var _chunkLBC2OGSNjs = require('./chunk-LBC2OGSN.js');
|
|
14
|
-
|
|
15
|
-
// src/internals/simulation/store/store.ts
|
|
16
|
-
var _toolkit = require('@reduxjs/toolkit');
|
|
17
|
-
var _reduxsaga = require('redux-saga'); var _reduxsaga2 = _interopRequireDefault(_reduxsaga);
|
|
18
|
-
function createStore({ state, unencryptedState }) {
|
|
19
|
-
const sagaMiddleware = _reduxsaga2.default.call(void 0, );
|
|
20
|
-
const store = _toolkit.configureStore.call(void 0, {
|
|
21
|
-
reducer: {
|
|
22
|
-
mocks: _chunkLACTK6EOjs.mocksSlice.reducer,
|
|
23
|
-
notifications: _chunk2YE2P5BZjs.notificationsSlice.reducer,
|
|
24
|
-
state: _chunkLBC2OGSNjs.stateSlice.reducer,
|
|
25
|
-
ui: _chunkPZDTZGSIjs.uiSlice.reducer
|
|
26
|
-
},
|
|
27
|
-
middleware: (getDefaultMiddleware) => getDefaultMiddleware({ thunk: false }).concat(sagaMiddleware)
|
|
28
|
-
});
|
|
29
|
-
if (state) {
|
|
30
|
-
store.dispatch(
|
|
31
|
-
_chunkLBC2OGSNjs.setState.call(void 0, {
|
|
32
|
-
state: JSON.stringify(state),
|
|
33
|
-
encrypted: true
|
|
34
|
-
})
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
if (unencryptedState) {
|
|
38
|
-
store.dispatch(
|
|
39
|
-
_chunkLBC2OGSNjs.setState.call(void 0, {
|
|
40
|
-
state: JSON.stringify(unencryptedState),
|
|
41
|
-
encrypted: false
|
|
42
|
-
})
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
store,
|
|
47
|
-
runSaga: sagaMiddleware.run.bind(sagaMiddleware)
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
exports.createStore = createStore;
|
|
54
|
-
//# sourceMappingURL=chunk-WMLSD6B5.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internals/simulation/store/store.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,sBAAsB;AAC/B,OAAO,0BAA0B;AAgB1B,SAAS,YAAY,EAAE,OAAO,iBAAiB,GAAsB;AAC1E,QAAM,iBAAiB,qBAAqB;AAC5C,QAAM,QAAQ,eAAe;AAAA,IAC3B,SAAS;AAAA,MACP,OAAO,WAAW;AAAA,MAClB,eAAe,mBAAmB;AAAA,MAClC,OAAO,WAAW;AAAA,MAClB,IAAI,QAAQ;AAAA,IACd;AAAA,IACA,YAAY,CAAC,yBACX,qBAAqB,EAAE,OAAO,MAAM,CAAC,EAAE,OAAO,cAAc;AAAA,EAChE,CAAC;AAGD,MAAI,OAAO;AACT,UAAM;AAAA,MACJ,SAAS;AAAA,QACP,OAAO,KAAK,UAAU,KAAK;AAAA,QAC3B,WAAW;AAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF;AAEA,MAAI,kBAAkB;AACpB,UAAM;AAAA,MACJ,SAAS;AAAA,QACP,OAAO,KAAK,UAAU,gBAAgB;AAAA,QACtC,WAAW;AAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA,SAAS,eAAe,IAAI,KAAK,cAAc;AAAA,EACjD;AACF","sourcesContent":["import { configureStore } from '@reduxjs/toolkit';\nimport createSagaMiddleware from 'redux-saga';\n\nimport type { SimulationOptions } from '../options';\nimport { mocksSlice } from './mocks';\nimport { notificationsSlice } from './notifications';\nimport { setState, stateSlice } from './state';\nimport { uiSlice } from './ui';\n\n/**\n * Create a Redux store.\n *\n * @param options - The simulation options.\n * @param options.state - The initial state for the Snap.\n * @param options.unencryptedState - The initial unencrypted state for the Snap.\n * @returns A Redux store with the default state.\n */\nexport function createStore({ state, unencryptedState }: SimulationOptions) {\n const sagaMiddleware = createSagaMiddleware();\n const store = configureStore({\n reducer: {\n mocks: mocksSlice.reducer,\n notifications: notificationsSlice.reducer,\n state: stateSlice.reducer,\n ui: uiSlice.reducer,\n },\n middleware: (getDefaultMiddleware) =>\n getDefaultMiddleware({ thunk: false }).concat(sagaMiddleware),\n });\n\n // Set initial state for the Snap.\n if (state) {\n store.dispatch(\n setState({\n state: JSON.stringify(state),\n encrypted: true,\n }),\n );\n }\n\n if (unencryptedState) {\n store.dispatch(\n setState({\n state: JSON.stringify(unencryptedState),\n encrypted: false,\n }),\n );\n }\n\n return {\n store,\n runSaga: sagaMiddleware.run.bind(sagaMiddleware),\n };\n}\n\nexport type Store = ReturnType<typeof createStore>['store'];\nexport type ApplicationState = ReturnType<Store['getState']>;\nexport type RunSagaFunction = ReturnType<typeof createStore>['runSaga'];\n"]}
|
package/dist/chunk-WRKY2DLV.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
-
|
|
3
|
-
var _chunkT2PHS5FYjs = require('./chunk-T2PHS5FY.js');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunkDVDAOXO7js = require('./chunk-DVDAOXO7.js');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _chunkN6MAO223js = require('./chunk-N6MAO223.js');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _chunkTZB4LBT7js = require('./chunk-TZB4LBT7.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, _chunkTZB4LBT7js.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, _chunkT2PHS5FYjs.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 _chunkN6MAO223js.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 _chunkPHUTP7NBjs.__privateGet.call(void 0, this, _instance)?.executionService.terminateAllSnaps();
|
|
56
|
-
_chunkPHUTP7NBjs.__privateGet.call(void 0, this, _server)?.close();
|
|
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 _chunkPHUTP7NBjs.__privateGet.call(void 0, this, _instance)?.executionService.terminateAllSnaps();
|
|
75
|
-
_chunkPHUTP7NBjs.__privateSet.call(void 0, this, _instance, await _chunkDVDAOXO7js.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-WRKY2DLV.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|