@metamask/snaps-jest 8.3.0 → 8.3.2
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 +16 -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} +5 -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 -56
- 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 -67
- 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} +2 -1
- 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 -149
- 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} +7 -6
- 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} +3 -2
- 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} +1 -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 -13
- 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} +11 -10
- 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 -110
- 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} +9 -8
- 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 -36
- 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/{types/internals/simulation/methods/hooks/get-preferences.d.ts → internals/simulation/methods/hooks/get-preferences.d.cts} +2 -1
- 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 +13 -7
- package/dist/internals/simulation/methods/hooks/get-preferences.mjs.map +1 -1
- 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/{types/internals/simulation/methods/hooks/request-user-approval.d.ts → internals/simulation/methods/hooks/request-user-approval.d.cts} +2 -1
- 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 +34 -13
- package/dist/internals/simulation/methods/hooks/request-user-approval.mjs.map +1 -1
- 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} +6 -5
- 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} +7 -6
- 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} +4 -2
- 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} +3 -2
- 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} +3 -2
- 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} +11 -9
- 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 -38
- 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} +9 -8
- 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} +9 -8
- 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} +12 -11
- 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 -8
- 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} +28 -27
- 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 -3
- 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 -47
- 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} +2 -1
- 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} +7 -6
- 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 +25 -23
- package/dist/chunk-24CGIQLL.mjs +0 -30
- package/dist/chunk-24CGIQLL.mjs.map +0 -1
- package/dist/chunk-2JTGBHPR.js +0 -14
- package/dist/chunk-2JTGBHPR.js.map +0 -1
- package/dist/chunk-2RJYSYUB.js +0 -28
- package/dist/chunk-2RJYSYUB.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-3J2IBWXV.mjs +0 -39
- package/dist/chunk-3J2IBWXV.mjs.map +0 -1
- package/dist/chunk-3NP6BDGK.js +0 -167
- package/dist/chunk-3NP6BDGK.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-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-6JPBXAHM.mjs +0 -509
- package/dist/chunk-6JPBXAHM.mjs.map +0 -1
- package/dist/chunk-6V6MFT67.js +0 -38
- package/dist/chunk-6V6MFT67.js.map +0 -1
- package/dist/chunk-7PCHIR6O.mjs +0 -181
- package/dist/chunk-7PCHIR6O.mjs.map +0 -1
- package/dist/chunk-ALRZENWP.mjs +0 -42
- package/dist/chunk-ALRZENWP.mjs.map +0 -1
- package/dist/chunk-AMAL4SJH.js +0 -153
- package/dist/chunk-AMAL4SJH.js.map +0 -1
- package/dist/chunk-C26TYXXD.mjs +0 -240
- package/dist/chunk-C26TYXXD.mjs.map +0 -1
- package/dist/chunk-CACRY3TX.mjs +0 -104
- package/dist/chunk-CACRY3TX.mjs.map +0 -1
- package/dist/chunk-CKRORVDW.js +0 -1
- package/dist/chunk-CKRORVDW.js.map +0 -1
- package/dist/chunk-D653LBAY.js +0 -34
- package/dist/chunk-D653LBAY.js.map +0 -1
- package/dist/chunk-DR6Y7IVX.js +0 -1
- package/dist/chunk-DR6Y7IVX.js.map +0 -1
- package/dist/chunk-DUVKGPX5.js +0 -509
- package/dist/chunk-DUVKGPX5.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-G333FBBL.mjs +0 -38
- package/dist/chunk-G333FBBL.mjs.map +0 -1
- package/dist/chunk-GECE47HW.js +0 -1
- package/dist/chunk-GECE47HW.js.map +0 -1
- package/dist/chunk-GLPGOEVE.js +0 -240
- package/dist/chunk-GLPGOEVE.js.map +0 -1
- package/dist/chunk-GMTKFAWO.js +0 -42
- package/dist/chunk-GMTKFAWO.js.map +0 -1
- package/dist/chunk-H2464AXT.mjs +0 -33
- package/dist/chunk-H2464AXT.mjs.map +0 -1
- package/dist/chunk-HROOL3VI.js +0 -1
- package/dist/chunk-HROOL3VI.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-K7MK6LQU.js +0 -54
- package/dist/chunk-K7MK6LQU.js.map +0 -1
- package/dist/chunk-KIQOUUEZ.mjs +0 -1
- package/dist/chunk-KIQOUUEZ.mjs.map +0 -1
- package/dist/chunk-KOPPL55J.mjs +0 -28
- package/dist/chunk-KOPPL55J.mjs.map +0 -1
- package/dist/chunk-KPRLFCKD.js +0 -13
- package/dist/chunk-KPRLFCKD.js.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-LPMHPAZK.js +0 -203
- package/dist/chunk-LPMHPAZK.js.map +0 -1
- package/dist/chunk-LSKT2AUS.mjs +0 -97
- package/dist/chunk-LSKT2AUS.mjs.map +0 -1
- package/dist/chunk-LVNNGMJ2.mjs +0 -13
- package/dist/chunk-LVNNGMJ2.mjs.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-NTOY6Y4Q.mjs +0 -1
- package/dist/chunk-NTOY6Y4Q.mjs.map +0 -1
- package/dist/chunk-OHRFO2BL.mjs +0 -89
- package/dist/chunk-OHRFO2BL.mjs.map +0 -1
- package/dist/chunk-OO6IVUCV.js +0 -104
- package/dist/chunk-OO6IVUCV.js.map +0 -1
- package/dist/chunk-ORR7AE5X.mjs +0 -54
- package/dist/chunk-ORR7AE5X.mjs.map +0 -1
- package/dist/chunk-PDOVVC74.mjs +0 -153
- package/dist/chunk-PDOVVC74.mjs.map +0 -1
- package/dist/chunk-PHUTP7NB.js +0 -25
- package/dist/chunk-PHUTP7NB.js.map +0 -1
- package/dist/chunk-Q2OQXAUM.mjs +0 -35
- package/dist/chunk-Q2OQXAUM.mjs.map +0 -1
- package/dist/chunk-Q3I6P2ZF.mjs +0 -167
- package/dist/chunk-Q3I6P2ZF.mjs.map +0 -1
- package/dist/chunk-QRVFWATH.mjs +0 -14
- package/dist/chunk-QRVFWATH.mjs.map +0 -1
- package/dist/chunk-QYHQ2WWX.js +0 -89
- package/dist/chunk-QYHQ2WWX.js.map +0 -1
- package/dist/chunk-RJNNNCZJ.js +0 -39
- package/dist/chunk-RJNNNCZJ.js.map +0 -1
- package/dist/chunk-ROCGQYSK.mjs +0 -203
- package/dist/chunk-ROCGQYSK.mjs.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-SNXRXX2O.js +0 -30
- package/dist/chunk-SNXRXX2O.js.map +0 -1
- package/dist/chunk-SW65QYFV.js +0 -50
- package/dist/chunk-SW65QYFV.js.map +0 -1
- package/dist/chunk-TGZ7WOTJ.mjs +0 -1
- package/dist/chunk-TGZ7WOTJ.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-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-WZ57PU2K.js +0 -97
- package/dist/chunk-WZ57PU2K.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-XP4YGQJA.js +0 -14
- package/dist/chunk-XP4YGQJA.js.map +0 -1
- package/dist/chunk-Y2U3ZPCK.js +0 -181
- package/dist/chunk-Y2U3ZPCK.js.map +0 -1
- package/dist/chunk-Y3JC4WGW.js +0 -35
- package/dist/chunk-Y3JC4WGW.js.map +0 -1
- package/dist/chunk-ZG33OGC3.mjs +0 -1
- package/dist/chunk-ZG33OGC3.mjs.map +0 -1
- package/dist/chunk-ZJQSGRNK.mjs +0 -34
- package/dist/chunk-ZJQSGRNK.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 -57
- package/dist/helpers.js.map +0 -1
- package/dist/index.js +0 -68
- 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 -150
- 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 -14
- 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 -111
- package/dist/internals/simulation/index.js.map +0 -1
- package/dist/internals/simulation/interface.js +0 -37
- 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-preferences.js +0 -8
- package/dist/internals/simulation/methods/hooks/get-preferences.js.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/request-user-approval.js +0 -14
- package/dist/internals/simulation/methods/hooks/request-user-approval.js.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 -39
- 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 -49
- 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/index.d.ts +0 -5
- 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-N6MAO223.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
-
|
|
3
|
-
var _chunkTZB4LBT7js = require('./chunk-TZB4LBT7.js');
|
|
4
|
-
|
|
5
|
-
// src/internals/server.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _node = require('@metamask/snaps-utils/node');
|
|
11
|
-
var _utils = require('@metamask/utils');
|
|
12
|
-
var _express = require('express'); var _express2 = _interopRequireDefault(_express);
|
|
13
|
-
var _fs = require('fs');
|
|
14
|
-
var _http = require('http');
|
|
15
|
-
var _path = require('path');
|
|
16
|
-
async function assertRoot(root) {
|
|
17
|
-
if (!root) {
|
|
18
|
-
throw new Error("You must specify a root directory.");
|
|
19
|
-
}
|
|
20
|
-
if (!await _node.isDirectory.call(void 0, root, false)) {
|
|
21
|
-
throw new Error(`Root directory "${root}" is not a directory.`);
|
|
22
|
-
}
|
|
23
|
-
const manifestPath = _path.resolve.call(void 0, root, "snap.manifest.json");
|
|
24
|
-
const manifest = await _fs.promises.readFile(manifestPath, "utf8").then(JSON.parse);
|
|
25
|
-
_node.assertIsSnapManifest.call(void 0, manifest);
|
|
26
|
-
const filePath = _path.resolve.call(void 0, root, manifest.source.location.npm.filePath);
|
|
27
|
-
if (!await _node.isFile.call(void 0, 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 = _utils.createModuleLogger.call(void 0, _chunkTZB4LBT7js.rootLogger, "server");
|
|
36
|
-
const app = _express2.default.call(void 0, );
|
|
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(_express2.default.static(_path.resolve.call(void 0, process.cwd(), options.root)));
|
|
45
|
-
const server = _http.createServer.call(void 0, 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
|
-
|
|
58
|
-
|
|
59
|
-
exports.startServer = startServer;
|
|
60
|
-
//# sourceMappingURL=chunk-N6MAO223.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internals/server.ts"],"names":[],"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","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"]}
|
package/dist/chunk-NTOY6Y4Q.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-NTOY6Y4Q.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/chunk-OHRFO2BL.mjs
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getGetPreferencesMethodImplementation
|
|
3
|
-
} from "./chunk-QRVFWATH.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
|
-
getRequestUserApprovalImplementation
|
|
14
|
-
} from "./chunk-24CGIQLL.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
|
-
getPreferences: getGetPreferencesMethodImplementation(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
|
-
requestUserApproval: getRequestUserApprovalImplementation(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-OHRFO2BL.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 getGetPreferencesMethodImplementation,\n getClearSnapStateMethodImplementation,\n getGetSnapStateMethodImplementation,\n getUpdateSnapStateMethodImplementation,\n getShowInAppNotificationImplementation,\n getShowNativeNotificationImplementation,\n getCreateInterfaceImplementation,\n getGetInterfaceImplementation,\n getRequestUserApprovalImplementation,\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 getPreferences: getGetPreferencesMethodImplementation(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 requestUserApproval: getRequestUserApprovalImplementation(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,gBAAgB,sCAAsC,OAAO;AAAA,MAC7D,cAAc,oCAAoC,OAAO;AAAA,MACzD,kBAAkB,aAAa,IAAI;AAAA;AAAA,MAGnC,kBAAkB,QAAQ,KAAK;AAAA,MAE/B,yBAAyB,aAAa;AAAA,MACtC,qBAAqB,qCAAqC,OAAO;AAAA,MACjE,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-OO6IVUCV.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 _chunk2RJYSYUBjs = require('./chunk-2RJYSYUB.js');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunk3NP6BDGKjs = require('./chunk-3NP6BDGK.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, _chunk2RJYSYUBjs.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 _chunk3NP6BDGKjs.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-OO6IVUCV.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"]}
|
package/dist/chunk-ORR7AE5X.mjs
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
uiSlice
|
|
3
|
-
} from "./chunk-ZJQSGRNK.mjs";
|
|
4
|
-
import {
|
|
5
|
-
mocksSlice
|
|
6
|
-
} from "./chunk-H2464AXT.mjs";
|
|
7
|
-
import {
|
|
8
|
-
notificationsSlice
|
|
9
|
-
} from "./chunk-LB4R3BUA.mjs";
|
|
10
|
-
import {
|
|
11
|
-
setState,
|
|
12
|
-
stateSlice
|
|
13
|
-
} from "./chunk-MPZOXW6I.mjs";
|
|
14
|
-
|
|
15
|
-
// src/internals/simulation/store/store.ts
|
|
16
|
-
import { configureStore } from "@reduxjs/toolkit";
|
|
17
|
-
import createSagaMiddleware from "redux-saga";
|
|
18
|
-
function createStore({ state, unencryptedState }) {
|
|
19
|
-
const sagaMiddleware = createSagaMiddleware();
|
|
20
|
-
const store = configureStore({
|
|
21
|
-
reducer: {
|
|
22
|
-
mocks: mocksSlice.reducer,
|
|
23
|
-
notifications: notificationsSlice.reducer,
|
|
24
|
-
state: stateSlice.reducer,
|
|
25
|
-
ui: uiSlice.reducer
|
|
26
|
-
},
|
|
27
|
-
middleware: (getDefaultMiddleware) => getDefaultMiddleware({ thunk: false }).concat(sagaMiddleware)
|
|
28
|
-
});
|
|
29
|
-
if (state) {
|
|
30
|
-
store.dispatch(
|
|
31
|
-
setState({
|
|
32
|
-
state: JSON.stringify(state),
|
|
33
|
-
encrypted: true
|
|
34
|
-
})
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
if (unencryptedState) {
|
|
38
|
-
store.dispatch(
|
|
39
|
-
setState({
|
|
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
|
-
export {
|
|
52
|
-
createStore
|
|
53
|
-
};
|
|
54
|
-
//# sourceMappingURL=chunk-ORR7AE5X.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internals/simulation/store/store.ts"],"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"],"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;","names":[]}
|
package/dist/chunk-PDOVVC74.mjs
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getInterface,
|
|
3
|
-
getInterfaceActions
|
|
4
|
-
} from "./chunk-6JPBXAHM.mjs";
|
|
5
|
-
import {
|
|
6
|
-
SnapResponseStruct
|
|
7
|
-
} from "./chunk-C26TYXXD.mjs";
|
|
8
|
-
import {
|
|
9
|
-
clearNotifications,
|
|
10
|
-
getNotifications
|
|
11
|
-
} from "./chunk-LB4R3BUA.mjs";
|
|
12
|
-
|
|
13
|
-
// src/internals/request.ts
|
|
14
|
-
import {
|
|
15
|
-
ComponentOrElementStruct
|
|
16
|
-
} from "@metamask/snaps-sdk";
|
|
17
|
-
import { unwrapError } from "@metamask/snaps-utils";
|
|
18
|
-
import { is } from "@metamask/superstruct";
|
|
19
|
-
import {
|
|
20
|
-
assert,
|
|
21
|
-
getSafeJson,
|
|
22
|
-
hasProperty,
|
|
23
|
-
isPlainObject
|
|
24
|
-
} from "@metamask/utils";
|
|
25
|
-
import { nanoid } from "@reduxjs/toolkit";
|
|
26
|
-
function handleRequest({
|
|
27
|
-
snapId,
|
|
28
|
-
store,
|
|
29
|
-
executionService,
|
|
30
|
-
handler,
|
|
31
|
-
controllerMessenger,
|
|
32
|
-
runSaga,
|
|
33
|
-
request: { id = nanoid(), origin = "https://metamask.io", ...options }
|
|
34
|
-
}) {
|
|
35
|
-
const getInterfaceError = () => {
|
|
36
|
-
throw new Error(
|
|
37
|
-
"Unable to get the interface from the Snap: The request to the Snap failed."
|
|
38
|
-
);
|
|
39
|
-
};
|
|
40
|
-
const promise = executionService.handleRpcRequest(snapId, {
|
|
41
|
-
origin,
|
|
42
|
-
handler,
|
|
43
|
-
request: {
|
|
44
|
-
jsonrpc: "2.0",
|
|
45
|
-
id: 1,
|
|
46
|
-
...options
|
|
47
|
-
}
|
|
48
|
-
}).then(async (result) => {
|
|
49
|
-
const notifications = getNotifications(store.getState());
|
|
50
|
-
store.dispatch(clearNotifications());
|
|
51
|
-
try {
|
|
52
|
-
const getInterfaceFn = await getInterfaceApi(
|
|
53
|
-
result,
|
|
54
|
-
snapId,
|
|
55
|
-
controllerMessenger
|
|
56
|
-
);
|
|
57
|
-
return {
|
|
58
|
-
id: String(id),
|
|
59
|
-
response: {
|
|
60
|
-
result: getSafeJson(result)
|
|
61
|
-
},
|
|
62
|
-
notifications,
|
|
63
|
-
...getInterfaceFn ? { getInterface: getInterfaceFn } : {}
|
|
64
|
-
};
|
|
65
|
-
} catch (error) {
|
|
66
|
-
const [unwrappedError] = unwrapError(error);
|
|
67
|
-
return {
|
|
68
|
-
id: String(id),
|
|
69
|
-
response: {
|
|
70
|
-
error: unwrappedError.serialize()
|
|
71
|
-
},
|
|
72
|
-
notifications: [],
|
|
73
|
-
getInterface: getInterfaceError
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
}).catch((error) => {
|
|
77
|
-
const [unwrappedError] = unwrapError(error);
|
|
78
|
-
return {
|
|
79
|
-
id: String(id),
|
|
80
|
-
response: {
|
|
81
|
-
error: unwrappedError.serialize()
|
|
82
|
-
},
|
|
83
|
-
notifications: [],
|
|
84
|
-
getInterface: getInterfaceError
|
|
85
|
-
};
|
|
86
|
-
});
|
|
87
|
-
promise.getInterface = async () => {
|
|
88
|
-
const sagaPromise = runSaga(
|
|
89
|
-
getInterface,
|
|
90
|
-
runSaga,
|
|
91
|
-
snapId,
|
|
92
|
-
controllerMessenger
|
|
93
|
-
).toPromise();
|
|
94
|
-
const result = await Promise.race([promise, sagaPromise]);
|
|
95
|
-
if (is(result, SnapResponseStruct) && hasProperty(result.response, "error")) {
|
|
96
|
-
throw new Error(
|
|
97
|
-
`Unable to get the interface from the Snap: The returned interface may be invalid. The error message received was: ${result.response.error.message}`
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
return await sagaPromise;
|
|
101
|
-
};
|
|
102
|
-
return promise;
|
|
103
|
-
}
|
|
104
|
-
async function getInterfaceFromResult(result, snapId, controllerMessenger) {
|
|
105
|
-
if (isPlainObject(result) && hasProperty(result, "id")) {
|
|
106
|
-
return result.id;
|
|
107
|
-
}
|
|
108
|
-
if (isPlainObject(result) && hasProperty(result, "content")) {
|
|
109
|
-
assert(
|
|
110
|
-
is(result.content, ComponentOrElementStruct),
|
|
111
|
-
"The Snap returned an invalid interface."
|
|
112
|
-
);
|
|
113
|
-
const id = await controllerMessenger.call(
|
|
114
|
-
"SnapInterfaceController:createInterface",
|
|
115
|
-
snapId,
|
|
116
|
-
result.content
|
|
117
|
-
);
|
|
118
|
-
return id;
|
|
119
|
-
}
|
|
120
|
-
return void 0;
|
|
121
|
-
}
|
|
122
|
-
async function getInterfaceApi(result, snapId, controllerMessenger) {
|
|
123
|
-
const interfaceId = await getInterfaceFromResult(
|
|
124
|
-
result,
|
|
125
|
-
snapId,
|
|
126
|
-
controllerMessenger
|
|
127
|
-
);
|
|
128
|
-
if (interfaceId) {
|
|
129
|
-
return () => {
|
|
130
|
-
const { content } = controllerMessenger.call(
|
|
131
|
-
"SnapInterfaceController:getInterface",
|
|
132
|
-
snapId,
|
|
133
|
-
interfaceId
|
|
134
|
-
);
|
|
135
|
-
const actions = getInterfaceActions(snapId, controllerMessenger, {
|
|
136
|
-
id: interfaceId,
|
|
137
|
-
content
|
|
138
|
-
});
|
|
139
|
-
return {
|
|
140
|
-
content,
|
|
141
|
-
...actions
|
|
142
|
-
};
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
return void 0;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export {
|
|
149
|
-
handleRequest,
|
|
150
|
-
getInterfaceFromResult,
|
|
151
|
-
getInterfaceApi
|
|
152
|
-
};
|
|
153
|
-
//# sourceMappingURL=chunk-PDOVVC74.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internals/request.ts"],"sourcesContent":["import type { AbstractExecutionService } from '@metamask/snaps-controllers';\nimport {\n type ComponentOrElement,\n ComponentOrElementStruct,\n type JsonRpcError,\n type SnapId,\n} from '@metamask/snaps-sdk';\nimport type { HandlerType } from '@metamask/snaps-utils';\nimport { unwrapError } from '@metamask/snaps-utils';\nimport { is } from '@metamask/superstruct';\nimport {\n assert,\n getSafeJson,\n hasProperty,\n isPlainObject,\n} from '@metamask/utils';\nimport { nanoid } from '@reduxjs/toolkit';\n\nimport type {\n RequestOptions,\n SnapHandlerInterface,\n SnapRequest,\n} from '../types';\nimport type { RunSagaFunction, Store } from './simulation';\nimport {\n clearNotifications,\n getInterface,\n getInterfaceActions,\n getNotifications,\n} from './simulation';\nimport type { RootControllerMessenger } from './simulation/controllers';\nimport { SnapResponseStruct } from './structs';\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 getInterfaceError = () => {\n throw new Error(\n 'Unable to get the interface from the Snap: The request to the Snap failed.',\n );\n };\n\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(async (result) => {\n const notifications = getNotifications(store.getState());\n store.dispatch(clearNotifications());\n\n try {\n const getInterfaceFn = await getInterfaceApi(\n result,\n snapId,\n controllerMessenger,\n );\n\n return {\n id: String(id),\n response: {\n result: getSafeJson(result),\n },\n notifications,\n ...(getInterfaceFn ? { getInterface: getInterfaceFn } : {}),\n };\n } catch (error) {\n const [unwrappedError] = unwrapError(error);\n return {\n id: String(id),\n response: {\n error: unwrappedError.serialize(),\n },\n notifications: [],\n getInterface: getInterfaceError,\n };\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 getInterface: getInterfaceError,\n };\n }) as unknown as SnapRequest;\n\n promise.getInterface = async () => {\n const sagaPromise = runSaga(\n getInterface,\n runSaga,\n snapId,\n controllerMessenger,\n ).toPromise();\n const result = await Promise.race([promise, sagaPromise]);\n\n // If the request promise has resolved to an error, we should throw\n // instead of waiting for an interface that likely will never be displayed\n if (\n is(result, SnapResponseStruct) &&\n hasProperty(result.response, 'error')\n ) {\n throw new Error(\n `Unable to get the interface from the Snap: The returned interface may be invalid. The error message received was: ${\n (result.response.error as JsonRpcError).message\n }`,\n );\n }\n\n return await sagaPromise;\n };\n\n return promise;\n}\n\n/**\n * Get the interface ID from the result if it's available or create a new interface if the result contains static components.\n *\n * @param result - The handler result object.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger.\n * @returns The interface ID or undefined if the result doesn't include content.\n */\nexport async function getInterfaceFromResult(\n result: unknown,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n) {\n if (isPlainObject(result) && hasProperty(result, 'id')) {\n return result.id as string;\n }\n\n if (isPlainObject(result) && hasProperty(result, 'content')) {\n assert(\n is(result.content, ComponentOrElementStruct),\n 'The Snap returned an invalid interface.',\n );\n const id = await controllerMessenger.call(\n 'SnapInterfaceController:createInterface',\n snapId,\n result.content as ComponentOrElement,\n );\n\n return id;\n }\n\n return undefined;\n}\n\n/**\n * Get the response content from the `SnapInterfaceController` and include the\n * interaction methods.\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 async function getInterfaceApi(\n result: unknown,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n): Promise<(() => SnapHandlerInterface) | undefined> {\n const interfaceId = await getInterfaceFromResult(\n result,\n snapId,\n controllerMessenger,\n );\n\n if (interfaceId) {\n return () => {\n const { content } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n interfaceId,\n );\n\n const actions = getInterfaceActions(snapId, controllerMessenger, {\n id: interfaceId,\n content,\n });\n\n return {\n content,\n ...actions,\n };\n };\n }\n\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;;;AACA;AAAA,EAEE;AAAA,OAGK;AAEP,SAAS,mBAAmB;AAC5B,SAAS,UAAU;AACnB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc;AA+ChB,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,oBAAoB,MAAM;AAC9B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,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,OAAO,WAAW;AACtB,UAAM,gBAAgB,iBAAiB,MAAM,SAAS,CAAC;AACvD,UAAM,SAAS,mBAAmB,CAAC;AAEnC,QAAI;AACF,YAAM,iBAAiB,MAAM;AAAA,QAC3B;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAEA,aAAO;AAAA,QACL,IAAI,OAAO,EAAE;AAAA,QACb,UAAU;AAAA,UACR,QAAQ,YAAY,MAAM;AAAA,QAC5B;AAAA,QACA;AAAA,QACA,GAAI,iBAAiB,EAAE,cAAc,eAAe,IAAI,CAAC;AAAA,MAC3D;AAAA,IACF,SAAS,OAAO;AACd,YAAM,CAAC,cAAc,IAAI,YAAY,KAAK;AAC1C,aAAO;AAAA,QACL,IAAI,OAAO,EAAE;AAAA,QACb,UAAU;AAAA,UACR,OAAO,eAAe,UAAU;AAAA,QAClC;AAAA,QACA,eAAe,CAAC;AAAA,QAChB,cAAc;AAAA,MAChB;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,MAChB,cAAc;AAAA,IAChB;AAAA,EACF,CAAC;AAEH,UAAQ,eAAe,YAAY;AACjC,UAAM,cAAc;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,EAAE,UAAU;AACZ,UAAM,SAAS,MAAM,QAAQ,KAAK,CAAC,SAAS,WAAW,CAAC;AAIxD,QACE,GAAG,QAAQ,kBAAkB,KAC7B,YAAY,OAAO,UAAU,OAAO,GACpC;AACA,YAAM,IAAI;AAAA,QACR,qHACG,OAAO,SAAS,MAAuB,OAC1C;AAAA,MACF;AAAA,IACF;AAEA,WAAO,MAAM;AAAA,EACf;AAEA,SAAO;AACT;AAUA,eAAsB,uBACpB,QACA,QACA,qBACA;AACA,MAAI,cAAc,MAAM,KAAK,YAAY,QAAQ,IAAI,GAAG;AACtD,WAAO,OAAO;AAAA,EAChB;AAEA,MAAI,cAAc,MAAM,KAAK,YAAY,QAAQ,SAAS,GAAG;AAC3D;AAAA,MACE,GAAG,OAAO,SAAS,wBAAwB;AAAA,MAC3C;AAAA,IACF;AACA,UAAM,KAAK,MAAM,oBAAoB;AAAA,MACnC;AAAA,MACA;AAAA,MACA,OAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAWA,eAAsB,gBACpB,QACA,QACA,qBACmD;AACnD,QAAM,cAAc,MAAM;AAAA,IACxB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,MAAI,aAAa;AACf,WAAO,MAAM;AACX,YAAM,EAAE,QAAQ,IAAI,oBAAoB;AAAA,QACtC;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAEA,YAAM,UAAU,oBAAoB,QAAQ,qBAAqB;AAAA,QAC/D,IAAI;AAAA,QACJ;AAAA,MACF,CAAC;AAED,aAAO;AAAA,QACL;AAAA,QACA,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
package/dist/chunk-PHUTP7NB.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __accessCheck = (obj, member, msg) => {
|
|
2
|
-
if (!member.has(obj))
|
|
3
|
-
throw TypeError("Cannot " + msg);
|
|
4
|
-
};
|
|
5
|
-
var __privateGet = (obj, member, getter) => {
|
|
6
|
-
__accessCheck(obj, member, "read from private field");
|
|
7
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
8
|
-
};
|
|
9
|
-
var __privateAdd = (obj, member, value) => {
|
|
10
|
-
if (member.has(obj))
|
|
11
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
12
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
13
|
-
};
|
|
14
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
15
|
-
__accessCheck(obj, member, "write to private field");
|
|
16
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
17
|
-
return value;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
exports.__privateGet = __privateGet; exports.__privateAdd = __privateAdd; exports.__privateSet = __privateSet;
|
|
25
|
-
//# sourceMappingURL=chunk-PHUTP7NB.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/chunk-Q2OQXAUM.mjs
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getAccountsHandler
|
|
3
|
-
} from "./chunk-VOYBI6T4.mjs";
|
|
4
|
-
import {
|
|
5
|
-
getProviderStateHandler
|
|
6
|
-
} from "./chunk-IXKO6X55.mjs";
|
|
7
|
-
|
|
8
|
-
// src/internals/simulation/middleware/internal-methods/middleware.ts
|
|
9
|
-
import { logError } from "@metamask/snaps-utils";
|
|
10
|
-
var methodHandlers = {
|
|
11
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
12
|
-
metamask_getProviderState: getProviderStateHandler,
|
|
13
|
-
eth_requestAccounts: getAccountsHandler,
|
|
14
|
-
eth_accounts: getAccountsHandler
|
|
15
|
-
/* eslint-enable @typescript-eslint/naming-convention */
|
|
16
|
-
};
|
|
17
|
-
function createInternalMethodsMiddleware(hooks) {
|
|
18
|
-
return async function methodMiddleware(request, response, next, end) {
|
|
19
|
-
const handler = methodHandlers[request.method];
|
|
20
|
-
if (handler) {
|
|
21
|
-
try {
|
|
22
|
-
return await handler(request, response, next, end, hooks);
|
|
23
|
-
} catch (error) {
|
|
24
|
-
logError(error);
|
|
25
|
-
return end(error);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return next();
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export {
|
|
33
|
-
createInternalMethodsMiddleware
|
|
34
|
-
};
|
|
35
|
-
//# sourceMappingURL=chunk-Q2OQXAUM.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internals/simulation/middleware/internal-methods/middleware.ts"],"sourcesContent":["import type { JsonRpcMiddleware } from '@metamask/json-rpc-engine';\nimport { logError } from '@metamask/snaps-utils';\nimport type { Json, JsonRpcParams } from '@metamask/utils';\n\nimport { getAccountsHandler } from './accounts';\nimport { getProviderStateHandler } from './provider-state';\n\nexport type InternalMethodsMiddlewareHooks = {\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\nconst methodHandlers = {\n /* eslint-disable @typescript-eslint/naming-convention */\n metamask_getProviderState: getProviderStateHandler,\n eth_requestAccounts: getAccountsHandler,\n eth_accounts: getAccountsHandler,\n /* eslint-enable @typescript-eslint/naming-convention */\n};\n\n/**\n * Create a middleware for handling JSON-RPC methods normally handled internally\n * by the MetaMask client.\n *\n * NOTE: This middleware provides all `hooks` to all handlers and should\n * therefore NOT be used outside of the simulation environment. It is intended\n * for testing purposes only.\n *\n * @param hooks - Any hooks used by the middleware handlers.\n * @returns A middleware function.\n */\nexport function createInternalMethodsMiddleware(\n hooks: InternalMethodsMiddlewareHooks,\n): JsonRpcMiddleware<JsonRpcParams, Json> {\n // This should probably use createAsyncMiddleware.\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n return async function methodMiddleware(request, response, next, end) {\n const handler =\n methodHandlers[request.method as keyof typeof methodHandlers];\n if (handler) {\n try {\n // Implementations may or may not be async, so we must await them.\n return await handler(request, response, next, end, hooks);\n } catch (error: any) {\n logError(error);\n return end(error);\n }\n }\n\n return next();\n };\n}\n"],"mappings":";;;;;;;;AACA,SAAS,gBAAgB;AAezB,IAAM,iBAAiB;AAAA;AAAA,EAErB,2BAA2B;AAAA,EAC3B,qBAAqB;AAAA,EACrB,cAAc;AAAA;AAEhB;AAaO,SAAS,gCACd,OACwC;AAGxC,SAAO,eAAe,iBAAiB,SAAS,UAAU,MAAM,KAAK;AACnE,UAAM,UACJ,eAAe,QAAQ,MAAqC;AAC9D,QAAI,SAAS;AACX,UAAI;AAEF,eAAO,MAAM,QAAQ,SAAS,UAAU,MAAM,KAAK,KAAK;AAAA,MAC1D,SAAS,OAAY;AACnB,iBAAS,KAAK;AACd,eAAO,IAAI,KAAK;AAAA,MAClB;AAAA,IACF;AAEA,WAAO,KAAK;AAAA,EACd;AACF;","names":[]}
|