@metamask/snaps-jest 8.3.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 +11 -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} +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 -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} +6 -5
- 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} +6 -5
- 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} +6 -5
- 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} +2 -1
- 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} +6 -5
- 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/internals/index.mjs
CHANGED
|
@@ -1,150 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
getInterfaceFromResult,
|
|
8
|
-
handleRequest
|
|
9
|
-
} from "../chunk-PDOVVC74.mjs";
|
|
10
|
-
import "../chunk-5ZFHFICZ.mjs";
|
|
11
|
-
import {
|
|
12
|
-
getHooks,
|
|
13
|
-
handleInstallSnap,
|
|
14
|
-
registerActions
|
|
15
|
-
} from "../chunk-Q3I6P2ZF.mjs";
|
|
16
|
-
import "../chunk-ZG33OGC3.mjs";
|
|
17
|
-
import "../chunk-3J2IBWXV.mjs";
|
|
18
|
-
import "../chunk-6HHV6YFQ.mjs";
|
|
19
|
-
import "../chunk-Q2OQXAUM.mjs";
|
|
20
|
-
import "../chunk-VOYBI6T4.mjs";
|
|
21
|
-
import "../chunk-IXKO6X55.mjs";
|
|
22
|
-
import "../chunk-FP4H3ADT.mjs";
|
|
23
|
-
import {
|
|
24
|
-
clickElement,
|
|
25
|
-
getElement,
|
|
26
|
-
getElementByType,
|
|
27
|
-
getInterface,
|
|
28
|
-
getInterfaceActions,
|
|
29
|
-
getInterfaceResponse,
|
|
30
|
-
mergeValue,
|
|
31
|
-
resolveWithSaga,
|
|
32
|
-
selectFromRadioGroup,
|
|
33
|
-
selectInDropdown,
|
|
34
|
-
typeInField,
|
|
35
|
-
uploadFile
|
|
36
|
-
} from "../chunk-6JPBXAHM.mjs";
|
|
37
|
-
import "../chunk-IWJ4HKDR.mjs";
|
|
38
|
-
import {
|
|
39
|
-
getOptions
|
|
40
|
-
} from "../chunk-G333FBBL.mjs";
|
|
41
|
-
import {
|
|
42
|
-
startServer
|
|
43
|
-
} from "../chunk-SLU4FNKX.mjs";
|
|
44
|
-
import {
|
|
45
|
-
rootLogger
|
|
46
|
-
} from "../chunk-J4ZPUCLX.mjs";
|
|
47
|
-
import {
|
|
48
|
-
InterfaceStruct,
|
|
49
|
-
JsonRpcMockOptionsStruct,
|
|
50
|
-
SignatureOptionsStruct,
|
|
51
|
-
SnapOptionsStruct,
|
|
52
|
-
SnapResponseStruct,
|
|
53
|
-
SnapResponseWithInterfaceStruct,
|
|
54
|
-
SnapResponseWithoutInterfaceStruct,
|
|
55
|
-
TransactionOptionsStruct
|
|
56
|
-
} from "../chunk-C26TYXXD.mjs";
|
|
57
|
-
import {
|
|
58
|
-
DEFAULT_CURRENCY,
|
|
59
|
-
DEFAULT_JSON_RPC_ENDPOINT,
|
|
60
|
-
DEFAULT_LOCALE,
|
|
61
|
-
DEFAULT_SRP
|
|
62
|
-
} from "../chunk-LVNNGMJ2.mjs";
|
|
63
|
-
import "../chunk-LSKT2AUS.mjs";
|
|
64
|
-
import "../chunk-NTOY6Y4Q.mjs";
|
|
65
|
-
import "../chunk-OHRFO2BL.mjs";
|
|
66
|
-
import "../chunk-UDOXICJK.mjs";
|
|
67
|
-
import "../chunk-QRVFWATH.mjs";
|
|
68
|
-
import "../chunk-FQWOVTBB.mjs";
|
|
69
|
-
import "../chunk-ALRZENWP.mjs";
|
|
70
|
-
import "../chunk-24CGIQLL.mjs";
|
|
71
|
-
import "../chunk-5U5WB3SM.mjs";
|
|
72
|
-
import "../chunk-RQKT6BQ2.mjs";
|
|
73
|
-
import {
|
|
74
|
-
createStore
|
|
75
|
-
} from "../chunk-ORR7AE5X.mjs";
|
|
76
|
-
import {
|
|
77
|
-
closeInterface,
|
|
78
|
-
getCurrentInterface,
|
|
79
|
-
resolveInterface,
|
|
80
|
-
setInterface,
|
|
81
|
-
uiSlice
|
|
82
|
-
} from "../chunk-ZJQSGRNK.mjs";
|
|
83
|
-
import "../chunk-H2464AXT.mjs";
|
|
84
|
-
import {
|
|
85
|
-
addNotification,
|
|
86
|
-
clearNotifications,
|
|
87
|
-
getNotifications,
|
|
88
|
-
notificationsSlice,
|
|
89
|
-
removeNotification
|
|
90
|
-
} from "../chunk-LB4R3BUA.mjs";
|
|
91
|
-
import {
|
|
92
|
-
clearState,
|
|
93
|
-
getState,
|
|
94
|
-
setState,
|
|
95
|
-
stateSlice
|
|
96
|
-
} from "../chunk-MPZOXW6I.mjs";
|
|
97
|
-
import "../chunk-57SGDM5B.mjs";
|
|
98
|
-
import "../chunk-JMDSN227.mjs";
|
|
99
|
-
export {
|
|
100
|
-
DEFAULT_CURRENCY,
|
|
101
|
-
DEFAULT_JSON_RPC_ENDPOINT,
|
|
102
|
-
DEFAULT_LOCALE,
|
|
103
|
-
DEFAULT_SRP,
|
|
104
|
-
InterfaceStruct,
|
|
105
|
-
JsonRpcMockOptionsStruct,
|
|
106
|
-
SignatureOptionsStruct,
|
|
107
|
-
SnapOptionsStruct,
|
|
108
|
-
SnapResponseStruct,
|
|
109
|
-
SnapResponseWithInterfaceStruct,
|
|
110
|
-
SnapResponseWithoutInterfaceStruct,
|
|
111
|
-
TransactionOptionsStruct,
|
|
112
|
-
addNotification,
|
|
113
|
-
clearNotifications,
|
|
114
|
-
clearState,
|
|
115
|
-
clickElement,
|
|
116
|
-
closeInterface,
|
|
117
|
-
createStore,
|
|
118
|
-
getCurrentInterface,
|
|
119
|
-
getElement,
|
|
120
|
-
getElementByType,
|
|
121
|
-
getEnvironment,
|
|
122
|
-
getHooks,
|
|
123
|
-
getInterface,
|
|
124
|
-
getInterfaceActions,
|
|
125
|
-
getInterfaceApi,
|
|
126
|
-
getInterfaceFromResult,
|
|
127
|
-
getInterfaceResponse,
|
|
128
|
-
getNotifications,
|
|
129
|
-
getOptions,
|
|
130
|
-
getState,
|
|
131
|
-
handleInstallSnap,
|
|
132
|
-
handleRequest,
|
|
133
|
-
mergeValue,
|
|
134
|
-
notificationsSlice,
|
|
135
|
-
registerActions,
|
|
136
|
-
removeNotification,
|
|
137
|
-
resolveInterface,
|
|
138
|
-
resolveWithSaga,
|
|
139
|
-
rootLogger,
|
|
140
|
-
selectFromRadioGroup,
|
|
141
|
-
selectInDropdown,
|
|
142
|
-
setInterface,
|
|
143
|
-
setState,
|
|
144
|
-
startServer,
|
|
145
|
-
stateSlice,
|
|
146
|
-
typeInField,
|
|
147
|
-
uiSlice,
|
|
148
|
-
uploadFile
|
|
149
|
-
};
|
|
1
|
+
export * from "./environment.mjs";
|
|
2
|
+
export * from "./logger.mjs";
|
|
3
|
+
export * from "./request.mjs";
|
|
4
|
+
export * from "./server.mjs";
|
|
5
|
+
export * from "./simulation/index.mjs";
|
|
6
|
+
export * from "./structs.mjs";
|
|
150
7
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/internals/index.ts"],"names":[],"mappings":"AAAA,kCAA8B;AAC9B,6BAAyB;AACzB,8BAA0B;AAC1B,6BAAyB;AACzB,uCAA6B;AAC7B,8BAA0B","sourcesContent":["export * from './environment';\nexport * from './logger';\nexport * from './request';\nexport * from './server';\nexport * from './simulation';\nexport * from './structs';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.cjs","sourceRoot":"","sources":["../../src/internals/logger.ts"],"names":[],"mappings":";;;AAAA,2CAAsD;AAEzC,QAAA,UAAU,GAAG,IAAA,2BAAmB,EAAC,YAAY,CAAC,CAAC","sourcesContent":["import { createProjectLogger } from '@metamask/utils';\n\nexport const rootLogger = createProjectLogger('snaps-jest');\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.cts","sourceRoot":"","sources":["../../src/internals/logger.ts"],"names":[],"mappings":";AAEA,eAAO,MAAM,UAAU,0BAAoC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.mts","sourceRoot":"","sources":["../../src/internals/logger.ts"],"names":[],"mappings":";AAEA,eAAO,MAAM,UAAU,0BAAoC,CAAC"}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from "../chunk-J4ZPUCLX.mjs";
|
|
4
|
-
import "../chunk-JMDSN227.mjs";
|
|
5
|
-
export {
|
|
6
|
-
rootLogger
|
|
7
|
-
};
|
|
1
|
+
import { createProjectLogger } from "@metamask/utils";
|
|
2
|
+
export const rootLogger = createProjectLogger('snaps-jest');
|
|
8
3
|
//# sourceMappingURL=logger.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"logger.mjs","sourceRoot":"","sources":["../../src/internals/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,wBAAwB;AAEtD,MAAM,CAAC,MAAM,UAAU,GAAG,mBAAmB,CAAC,YAAY,CAAC,CAAC","sourcesContent":["import { createProjectLogger } from '@metamask/utils';\n\nexport const rootLogger = createProjectLogger('snaps-jest');\n"]}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getInterfaceApi = exports.getInterfaceFromResult = exports.handleRequest = void 0;
|
|
4
|
+
const snaps_sdk_1 = require("@metamask/snaps-sdk");
|
|
5
|
+
const snaps_utils_1 = require("@metamask/snaps-utils");
|
|
6
|
+
const superstruct_1 = require("@metamask/superstruct");
|
|
7
|
+
const utils_1 = require("@metamask/utils");
|
|
8
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
9
|
+
const simulation_1 = require("./simulation/index.cjs");
|
|
10
|
+
const structs_1 = require("./structs.cjs");
|
|
11
|
+
/**
|
|
12
|
+
* Send a JSON-RPC request to the Snap, and wrap the response in a
|
|
13
|
+
* {@link SnapResponse} object.
|
|
14
|
+
*
|
|
15
|
+
* @param options - The request options.
|
|
16
|
+
* @param options.snapId - The ID of the Snap to send the request to.
|
|
17
|
+
* @param options.store - The Redux store.
|
|
18
|
+
* @param options.executionService - The execution service to use to send the
|
|
19
|
+
* request.
|
|
20
|
+
* @param options.handler - The handler to use to send the request.
|
|
21
|
+
* @param options.controllerMessenger - The controller messenger used to call actions.
|
|
22
|
+
* @param options.runSaga - A function to run a saga outside the usual Redux
|
|
23
|
+
* flow.
|
|
24
|
+
* @param options.request - The request to send.
|
|
25
|
+
* @param options.request.id - The ID of the request. If not provided, a random
|
|
26
|
+
* ID will be generated.
|
|
27
|
+
* @param options.request.origin - The origin of the request. Defaults to
|
|
28
|
+
* `https://metamask.io`.
|
|
29
|
+
* @returns The response, wrapped in a {@link SnapResponse} object.
|
|
30
|
+
*/
|
|
31
|
+
function handleRequest({ snapId, store, executionService, handler, controllerMessenger, runSaga, request: { id = (0, toolkit_1.nanoid)(), origin = 'https://metamask.io', ...options }, }) {
|
|
32
|
+
const getInterfaceError = () => {
|
|
33
|
+
throw new Error('Unable to get the interface from the Snap: The request to the Snap failed.');
|
|
34
|
+
};
|
|
35
|
+
const promise = executionService
|
|
36
|
+
.handleRpcRequest(snapId, {
|
|
37
|
+
origin,
|
|
38
|
+
handler,
|
|
39
|
+
request: {
|
|
40
|
+
jsonrpc: '2.0',
|
|
41
|
+
id: 1,
|
|
42
|
+
...options,
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
.then(async (result) => {
|
|
46
|
+
const notifications = (0, simulation_1.getNotifications)(store.getState());
|
|
47
|
+
store.dispatch((0, simulation_1.clearNotifications)());
|
|
48
|
+
try {
|
|
49
|
+
const getInterfaceFn = await getInterfaceApi(result, snapId, controllerMessenger);
|
|
50
|
+
return {
|
|
51
|
+
id: String(id),
|
|
52
|
+
response: {
|
|
53
|
+
result: (0, utils_1.getSafeJson)(result),
|
|
54
|
+
},
|
|
55
|
+
notifications,
|
|
56
|
+
...(getInterfaceFn ? { getInterface: getInterfaceFn } : {}),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
const [unwrappedError] = (0, snaps_utils_1.unwrapError)(error);
|
|
61
|
+
return {
|
|
62
|
+
id: String(id),
|
|
63
|
+
response: {
|
|
64
|
+
error: unwrappedError.serialize(),
|
|
65
|
+
},
|
|
66
|
+
notifications: [],
|
|
67
|
+
getInterface: getInterfaceError,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
.catch((error) => {
|
|
72
|
+
const [unwrappedError] = (0, snaps_utils_1.unwrapError)(error);
|
|
73
|
+
return {
|
|
74
|
+
id: String(id),
|
|
75
|
+
response: {
|
|
76
|
+
error: unwrappedError.serialize(),
|
|
77
|
+
},
|
|
78
|
+
notifications: [],
|
|
79
|
+
getInterface: getInterfaceError,
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
promise.getInterface = async () => {
|
|
83
|
+
const sagaPromise = runSaga(simulation_1.getInterface, runSaga, snapId, controllerMessenger).toPromise();
|
|
84
|
+
const result = await Promise.race([promise, sagaPromise]);
|
|
85
|
+
// If the request promise has resolved to an error, we should throw
|
|
86
|
+
// instead of waiting for an interface that likely will never be displayed
|
|
87
|
+
if ((0, superstruct_1.is)(result, structs_1.SnapResponseStruct) &&
|
|
88
|
+
(0, utils_1.hasProperty)(result.response, 'error')) {
|
|
89
|
+
throw new Error(`Unable to get the interface from the Snap: The returned interface may be invalid. The error message received was: ${result.response.error.message}`);
|
|
90
|
+
}
|
|
91
|
+
return await sagaPromise;
|
|
92
|
+
};
|
|
93
|
+
return promise;
|
|
94
|
+
}
|
|
95
|
+
exports.handleRequest = handleRequest;
|
|
96
|
+
/**
|
|
97
|
+
* Get the interface ID from the result if it's available or create a new interface if the result contains static components.
|
|
98
|
+
*
|
|
99
|
+
* @param result - The handler result object.
|
|
100
|
+
* @param snapId - The Snap ID.
|
|
101
|
+
* @param controllerMessenger - The controller messenger.
|
|
102
|
+
* @returns The interface ID or undefined if the result doesn't include content.
|
|
103
|
+
*/
|
|
104
|
+
async function getInterfaceFromResult(result, snapId, controllerMessenger) {
|
|
105
|
+
if ((0, utils_1.isPlainObject)(result) && (0, utils_1.hasProperty)(result, 'id')) {
|
|
106
|
+
return result.id;
|
|
107
|
+
}
|
|
108
|
+
if ((0, utils_1.isPlainObject)(result) && (0, utils_1.hasProperty)(result, 'content')) {
|
|
109
|
+
(0, utils_1.assert)((0, superstruct_1.is)(result.content, snaps_sdk_1.ComponentOrElementStruct), 'The Snap returned an invalid interface.');
|
|
110
|
+
const id = await controllerMessenger.call('SnapInterfaceController:createInterface', snapId, result.content);
|
|
111
|
+
return id;
|
|
112
|
+
}
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
exports.getInterfaceFromResult = getInterfaceFromResult;
|
|
116
|
+
/**
|
|
117
|
+
* Get the response content from the `SnapInterfaceController` and include the
|
|
118
|
+
* interaction methods.
|
|
119
|
+
*
|
|
120
|
+
* @param result - The handler result object.
|
|
121
|
+
* @param snapId - The Snap ID.
|
|
122
|
+
* @param controllerMessenger - The controller messenger.
|
|
123
|
+
* @returns The content components if any.
|
|
124
|
+
*/
|
|
125
|
+
async function getInterfaceApi(result, snapId, controllerMessenger) {
|
|
126
|
+
const interfaceId = await getInterfaceFromResult(result, snapId, controllerMessenger);
|
|
127
|
+
if (interfaceId) {
|
|
128
|
+
return () => {
|
|
129
|
+
const { content } = controllerMessenger.call('SnapInterfaceController:getInterface', snapId, interfaceId);
|
|
130
|
+
const actions = (0, simulation_1.getInterfaceActions)(snapId, controllerMessenger, {
|
|
131
|
+
id: interfaceId,
|
|
132
|
+
content,
|
|
133
|
+
});
|
|
134
|
+
return {
|
|
135
|
+
content,
|
|
136
|
+
...actions,
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
exports.getInterfaceApi = getInterfaceApi;
|
|
143
|
+
//# sourceMappingURL=request.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.cjs","sourceRoot":"","sources":["../../src/internals/request.ts"],"names":[],"mappings":"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","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"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { AbstractExecutionService } from
|
|
2
|
-
import { type SnapId } from
|
|
3
|
-
import type { HandlerType } from
|
|
4
|
-
import type { RequestOptions, SnapHandlerInterface, SnapRequest } from
|
|
5
|
-
import type { RunSagaFunction, Store } from
|
|
6
|
-
import type { RootControllerMessenger } from
|
|
1
|
+
import type { AbstractExecutionService } from "@metamask/snaps-controllers";
|
|
2
|
+
import { type SnapId } from "@metamask/snaps-sdk";
|
|
3
|
+
import type { HandlerType } from "@metamask/snaps-utils";
|
|
4
|
+
import type { RequestOptions, SnapHandlerInterface, SnapRequest } from "../types/index.cjs";
|
|
5
|
+
import type { RunSagaFunction, Store } from "./simulation/index.cjs";
|
|
6
|
+
import type { RootControllerMessenger } from "./simulation/controllers.cjs";
|
|
7
7
|
export type HandleRequestOptions = {
|
|
8
8
|
snapId: SnapId;
|
|
9
9
|
store: Store;
|
|
@@ -53,3 +53,4 @@ export declare function getInterfaceFromResult(result: unknown, snapId: SnapId,
|
|
|
53
53
|
* @returns The content components if any.
|
|
54
54
|
*/
|
|
55
55
|
export declare function getInterfaceApi(result: unknown, snapId: SnapId, controllerMessenger: RootControllerMessenger): Promise<(() => SnapHandlerInterface) | undefined>;
|
|
56
|
+
//# sourceMappingURL=request.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.cts","sourceRoot":"","sources":["../../src/internals/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,oCAAoC;AAC5E,OAAO,EAIL,KAAK,MAAM,EACZ,4BAA4B;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,8BAA8B;AAWzD,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,WAAW,EACZ,2BAAiB;AAClB,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,+BAAqB;AAO3D,OAAO,KAAK,EAAE,uBAAuB,EAAE,qCAAiC;AAGxE,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;IACb,gBAAgB,EAAE,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACpD,OAAO,EAAE,WAAW,CAAC;IACrB,mBAAmB,EAAE,uBAAuB,CAAC;IAC7C,OAAO,EAAE,eAAe,CAAC;IACzB,OAAO,EAAE,cAAc,CAAC;CACzB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,KAAK,EACL,gBAAgB,EAChB,OAAO,EACP,mBAAmB,EACnB,OAAO,EACP,OAAO,EAAE,EAAE,EAAa,EAAE,MAA8B,EAAE,GAAG,OAAO,EAAE,GACvE,EAAE,oBAAoB,GAAG,WAAW,CAuFpC;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,uBAAuB,+BAqB7C;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,uBAAuB,GAC3C,OAAO,CAAC,CAAC,MAAM,oBAAoB,CAAC,GAAG,SAAS,CAAC,CA4BnD"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { AbstractExecutionService } from "@metamask/snaps-controllers";
|
|
2
|
+
import { type SnapId } from "@metamask/snaps-sdk";
|
|
3
|
+
import type { HandlerType } from "@metamask/snaps-utils";
|
|
4
|
+
import type { RequestOptions, SnapHandlerInterface, SnapRequest } from "../types/index.mjs";
|
|
5
|
+
import type { RunSagaFunction, Store } from "./simulation/index.mjs";
|
|
6
|
+
import type { RootControllerMessenger } from "./simulation/controllers.mjs";
|
|
7
|
+
export type HandleRequestOptions = {
|
|
8
|
+
snapId: SnapId;
|
|
9
|
+
store: Store;
|
|
10
|
+
executionService: AbstractExecutionService<unknown>;
|
|
11
|
+
handler: HandlerType;
|
|
12
|
+
controllerMessenger: RootControllerMessenger;
|
|
13
|
+
runSaga: RunSagaFunction;
|
|
14
|
+
request: RequestOptions;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Send a JSON-RPC request to the Snap, and wrap the response in a
|
|
18
|
+
* {@link SnapResponse} object.
|
|
19
|
+
*
|
|
20
|
+
* @param options - The request options.
|
|
21
|
+
* @param options.snapId - The ID of the Snap to send the request to.
|
|
22
|
+
* @param options.store - The Redux store.
|
|
23
|
+
* @param options.executionService - The execution service to use to send the
|
|
24
|
+
* request.
|
|
25
|
+
* @param options.handler - The handler to use to send the request.
|
|
26
|
+
* @param options.controllerMessenger - The controller messenger used to call actions.
|
|
27
|
+
* @param options.runSaga - A function to run a saga outside the usual Redux
|
|
28
|
+
* flow.
|
|
29
|
+
* @param options.request - The request to send.
|
|
30
|
+
* @param options.request.id - The ID of the request. If not provided, a random
|
|
31
|
+
* ID will be generated.
|
|
32
|
+
* @param options.request.origin - The origin of the request. Defaults to
|
|
33
|
+
* `https://metamask.io`.
|
|
34
|
+
* @returns The response, wrapped in a {@link SnapResponse} object.
|
|
35
|
+
*/
|
|
36
|
+
export declare function handleRequest({ snapId, store, executionService, handler, controllerMessenger, runSaga, request: { id, origin, ...options }, }: HandleRequestOptions): SnapRequest;
|
|
37
|
+
/**
|
|
38
|
+
* Get the interface ID from the result if it's available or create a new interface if the result contains static components.
|
|
39
|
+
*
|
|
40
|
+
* @param result - The handler result object.
|
|
41
|
+
* @param snapId - The Snap ID.
|
|
42
|
+
* @param controllerMessenger - The controller messenger.
|
|
43
|
+
* @returns The interface ID or undefined if the result doesn't include content.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getInterfaceFromResult(result: unknown, snapId: SnapId, controllerMessenger: RootControllerMessenger): Promise<string | undefined>;
|
|
46
|
+
/**
|
|
47
|
+
* Get the response content from the `SnapInterfaceController` and include the
|
|
48
|
+
* interaction methods.
|
|
49
|
+
*
|
|
50
|
+
* @param result - The handler result object.
|
|
51
|
+
* @param snapId - The Snap ID.
|
|
52
|
+
* @param controllerMessenger - The controller messenger.
|
|
53
|
+
* @returns The content components if any.
|
|
54
|
+
*/
|
|
55
|
+
export declare function getInterfaceApi(result: unknown, snapId: SnapId, controllerMessenger: RootControllerMessenger): Promise<(() => SnapHandlerInterface) | undefined>;
|
|
56
|
+
//# sourceMappingURL=request.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.mts","sourceRoot":"","sources":["../../src/internals/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,oCAAoC;AAC5E,OAAO,EAIL,KAAK,MAAM,EACZ,4BAA4B;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,8BAA8B;AAWzD,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,WAAW,EACZ,2BAAiB;AAClB,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,+BAAqB;AAO3D,OAAO,KAAK,EAAE,uBAAuB,EAAE,qCAAiC;AAGxE,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;IACb,gBAAgB,EAAE,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACpD,OAAO,EAAE,WAAW,CAAC;IACrB,mBAAmB,EAAE,uBAAuB,CAAC;IAC7C,OAAO,EAAE,eAAe,CAAC;IACzB,OAAO,EAAE,cAAc,CAAC;CACzB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,KAAK,EACL,gBAAgB,EAChB,OAAO,EACP,mBAAmB,EACnB,OAAO,EACP,OAAO,EAAE,EAAE,EAAa,EAAE,MAA8B,EAAE,GAAG,OAAO,EAAE,GACvE,EAAE,oBAAoB,GAAG,WAAW,CAuFpC;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,uBAAuB,+BAqB7C;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,uBAAuB,GAC3C,OAAO,CAAC,CAAC,MAAM,oBAAoB,CAAC,GAAG,SAAS,CAAC,CA4BnD"}
|
|
@@ -1,42 +1,138 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import "
|
|
8
|
-
import "
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
1
|
+
import { ComponentOrElementStruct } from "@metamask/snaps-sdk";
|
|
2
|
+
import { unwrapError } from "@metamask/snaps-utils";
|
|
3
|
+
import { is } from "@metamask/superstruct";
|
|
4
|
+
import { assert, getSafeJson, hasProperty, isPlainObject } from "@metamask/utils";
|
|
5
|
+
import $reduxjstoolkit from "@reduxjs/toolkit";
|
|
6
|
+
const { nanoid } = $reduxjstoolkit;
|
|
7
|
+
import { clearNotifications, getInterface, getInterfaceActions, getNotifications } from "./simulation/index.mjs";
|
|
8
|
+
import { SnapResponseStruct } from "./structs.mjs";
|
|
9
|
+
/**
|
|
10
|
+
* Send a JSON-RPC request to the Snap, and wrap the response in a
|
|
11
|
+
* {@link SnapResponse} object.
|
|
12
|
+
*
|
|
13
|
+
* @param options - The request options.
|
|
14
|
+
* @param options.snapId - The ID of the Snap to send the request to.
|
|
15
|
+
* @param options.store - The Redux store.
|
|
16
|
+
* @param options.executionService - The execution service to use to send the
|
|
17
|
+
* request.
|
|
18
|
+
* @param options.handler - The handler to use to send the request.
|
|
19
|
+
* @param options.controllerMessenger - The controller messenger used to call actions.
|
|
20
|
+
* @param options.runSaga - A function to run a saga outside the usual Redux
|
|
21
|
+
* flow.
|
|
22
|
+
* @param options.request - The request to send.
|
|
23
|
+
* @param options.request.id - The ID of the request. If not provided, a random
|
|
24
|
+
* ID will be generated.
|
|
25
|
+
* @param options.request.origin - The origin of the request. Defaults to
|
|
26
|
+
* `https://metamask.io`.
|
|
27
|
+
* @returns The response, wrapped in a {@link SnapResponse} object.
|
|
28
|
+
*/
|
|
29
|
+
export function handleRequest({ snapId, store, executionService, handler, controllerMessenger, runSaga, request: { id = nanoid(), origin = 'https://metamask.io', ...options }, }) {
|
|
30
|
+
const getInterfaceError = () => {
|
|
31
|
+
throw new Error('Unable to get the interface from the Snap: The request to the Snap failed.');
|
|
32
|
+
};
|
|
33
|
+
const promise = executionService
|
|
34
|
+
.handleRpcRequest(snapId, {
|
|
35
|
+
origin,
|
|
36
|
+
handler,
|
|
37
|
+
request: {
|
|
38
|
+
jsonrpc: '2.0',
|
|
39
|
+
id: 1,
|
|
40
|
+
...options,
|
|
41
|
+
},
|
|
42
|
+
})
|
|
43
|
+
.then(async (result) => {
|
|
44
|
+
const notifications = getNotifications(store.getState());
|
|
45
|
+
store.dispatch(clearNotifications());
|
|
46
|
+
try {
|
|
47
|
+
const getInterfaceFn = await getInterfaceApi(result, snapId, controllerMessenger);
|
|
48
|
+
return {
|
|
49
|
+
id: String(id),
|
|
50
|
+
response: {
|
|
51
|
+
result: getSafeJson(result),
|
|
52
|
+
},
|
|
53
|
+
notifications,
|
|
54
|
+
...(getInterfaceFn ? { getInterface: getInterfaceFn } : {}),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
const [unwrappedError] = unwrapError(error);
|
|
59
|
+
return {
|
|
60
|
+
id: String(id),
|
|
61
|
+
response: {
|
|
62
|
+
error: unwrappedError.serialize(),
|
|
63
|
+
},
|
|
64
|
+
notifications: [],
|
|
65
|
+
getInterface: getInterfaceError,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
.catch((error) => {
|
|
70
|
+
const [unwrappedError] = unwrapError(error);
|
|
71
|
+
return {
|
|
72
|
+
id: String(id),
|
|
73
|
+
response: {
|
|
74
|
+
error: unwrappedError.serialize(),
|
|
75
|
+
},
|
|
76
|
+
notifications: [],
|
|
77
|
+
getInterface: getInterfaceError,
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
promise.getInterface = async () => {
|
|
81
|
+
const sagaPromise = runSaga(getInterface, runSaga, snapId, controllerMessenger).toPromise();
|
|
82
|
+
const result = await Promise.race([promise, sagaPromise]);
|
|
83
|
+
// If the request promise has resolved to an error, we should throw
|
|
84
|
+
// instead of waiting for an interface that likely will never be displayed
|
|
85
|
+
if (is(result, SnapResponseStruct) &&
|
|
86
|
+
hasProperty(result.response, 'error')) {
|
|
87
|
+
throw new Error(`Unable to get the interface from the Snap: The returned interface may be invalid. The error message received was: ${result.response.error.message}`);
|
|
88
|
+
}
|
|
89
|
+
return await sagaPromise;
|
|
90
|
+
};
|
|
91
|
+
return promise;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get the interface ID from the result if it's available or create a new interface if the result contains static components.
|
|
95
|
+
*
|
|
96
|
+
* @param result - The handler result object.
|
|
97
|
+
* @param snapId - The Snap ID.
|
|
98
|
+
* @param controllerMessenger - The controller messenger.
|
|
99
|
+
* @returns The interface ID or undefined if the result doesn't include content.
|
|
100
|
+
*/
|
|
101
|
+
export async function getInterfaceFromResult(result, snapId, controllerMessenger) {
|
|
102
|
+
if (isPlainObject(result) && hasProperty(result, 'id')) {
|
|
103
|
+
return result.id;
|
|
104
|
+
}
|
|
105
|
+
if (isPlainObject(result) && hasProperty(result, 'content')) {
|
|
106
|
+
assert(is(result.content, ComponentOrElementStruct), 'The Snap returned an invalid interface.');
|
|
107
|
+
const id = await controllerMessenger.call('SnapInterfaceController:createInterface', snapId, result.content);
|
|
108
|
+
return id;
|
|
109
|
+
}
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get the response content from the `SnapInterfaceController` and include the
|
|
114
|
+
* interaction methods.
|
|
115
|
+
*
|
|
116
|
+
* @param result - The handler result object.
|
|
117
|
+
* @param snapId - The Snap ID.
|
|
118
|
+
* @param controllerMessenger - The controller messenger.
|
|
119
|
+
* @returns The content components if any.
|
|
120
|
+
*/
|
|
121
|
+
export async function getInterfaceApi(result, snapId, controllerMessenger) {
|
|
122
|
+
const interfaceId = await getInterfaceFromResult(result, snapId, controllerMessenger);
|
|
123
|
+
if (interfaceId) {
|
|
124
|
+
return () => {
|
|
125
|
+
const { content } = controllerMessenger.call('SnapInterfaceController:getInterface', snapId, interfaceId);
|
|
126
|
+
const actions = getInterfaceActions(snapId, controllerMessenger, {
|
|
127
|
+
id: interfaceId,
|
|
128
|
+
content,
|
|
129
|
+
});
|
|
130
|
+
return {
|
|
131
|
+
content,
|
|
132
|
+
...actions,
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
42
138
|
//# sourceMappingURL=request.mjs.map
|