@metamask/snaps-jest 8.3.2 → 8.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -1
- package/dist/environment.cjs +2 -1
- package/dist/environment.cjs.map +1 -1
- package/dist/environment.d.cts +1 -1
- package/dist/environment.d.cts.map +1 -1
- package/dist/environment.d.mts +1 -1
- package/dist/environment.d.mts.map +1 -1
- package/dist/environment.mjs +3 -2
- package/dist/environment.mjs.map +1 -1
- package/dist/helpers.cjs +13 -80
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.d.cts +2 -44
- package/dist/helpers.d.cts.map +1 -1
- package/dist/helpers.d.mts +2 -44
- package/dist/helpers.d.mts.map +1 -1
- package/dist/helpers.mjs +4 -64
- package/dist/helpers.mjs.map +1 -1
- package/dist/index.cjs +8 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -1
- package/dist/internals/index.cjs +0 -3
- package/dist/internals/index.cjs.map +1 -1
- package/dist/internals/index.d.cts +0 -3
- package/dist/internals/index.d.cts.map +1 -1
- package/dist/internals/index.d.mts +0 -3
- package/dist/internals/index.d.mts.map +1 -1
- package/dist/internals/index.mjs +0 -3
- package/dist/internals/index.mjs.map +1 -1
- package/dist/matchers.cjs +3 -3
- package/dist/matchers.cjs.map +1 -1
- package/dist/matchers.d.cts.map +1 -1
- package/dist/matchers.d.mts.map +1 -1
- package/dist/matchers.mjs +1 -1
- package/dist/matchers.mjs.map +1 -1
- package/dist/types/types.cjs.map +1 -1
- package/dist/types/types.d.cts +8 -1
- package/dist/types/types.d.cts.map +1 -1
- package/dist/types/types.d.mts +8 -1
- package/dist/types/types.d.mts.map +1 -1
- package/dist/types/types.mjs.map +1 -1
- package/package.json +4 -17
- package/dist/internals/request.cjs +0 -143
- package/dist/internals/request.cjs.map +0 -1
- package/dist/internals/request.d.cts +0 -56
- package/dist/internals/request.d.cts.map +0 -1
- package/dist/internals/request.d.mts +0 -56
- package/dist/internals/request.d.mts.map +0 -1
- package/dist/internals/request.mjs +0 -138
- package/dist/internals/request.mjs.map +0 -1
- package/dist/internals/simulation/constants.cjs +0 -21
- package/dist/internals/simulation/constants.cjs.map +0 -1
- package/dist/internals/simulation/constants.d.cts +0 -18
- package/dist/internals/simulation/constants.d.cts.map +0 -1
- package/dist/internals/simulation/constants.d.mts +0 -18
- package/dist/internals/simulation/constants.d.mts.map +0 -1
- package/dist/internals/simulation/constants.mjs +0 -18
- package/dist/internals/simulation/constants.mjs.map +0 -1
- package/dist/internals/simulation/controllers.cjs +0 -101
- package/dist/internals/simulation/controllers.cjs.map +0 -1
- package/dist/internals/simulation/controllers.d.cts +0 -41
- package/dist/internals/simulation/controllers.d.cts.map +0 -1
- package/dist/internals/simulation/controllers.d.mts +0 -41
- package/dist/internals/simulation/controllers.d.mts.map +0 -1
- package/dist/internals/simulation/controllers.mjs +0 -96
- package/dist/internals/simulation/controllers.mjs.map +0 -1
- package/dist/internals/simulation/files.cjs +0 -94
- package/dist/internals/simulation/files.cjs.map +0 -1
- package/dist/internals/simulation/files.d.cts +0 -49
- package/dist/internals/simulation/files.d.cts.map +0 -1
- package/dist/internals/simulation/files.d.mts +0 -49
- package/dist/internals/simulation/files.d.mts.map +0 -1
- package/dist/internals/simulation/files.mjs +0 -91
- package/dist/internals/simulation/files.mjs.map +0 -1
- package/dist/internals/simulation/index.cjs +0 -22
- package/dist/internals/simulation/index.cjs.map +0 -1
- package/dist/internals/simulation/index.d.cts +0 -6
- package/dist/internals/simulation/index.d.cts.map +0 -1
- package/dist/internals/simulation/index.d.mts +0 -6
- package/dist/internals/simulation/index.d.mts.map +0 -1
- package/dist/internals/simulation/index.mjs +0 -6
- package/dist/internals/simulation/index.mjs.map +0 -1
- package/dist/internals/simulation/interface.cjs +0 -527
- package/dist/internals/simulation/interface.cjs.map +0 -1
- package/dist/internals/simulation/interface.d.cts +0 -152
- package/dist/internals/simulation/interface.d.cts.map +0 -1
- package/dist/internals/simulation/interface.d.mts +0 -152
- package/dist/internals/simulation/interface.d.mts.map +0 -1
- package/dist/internals/simulation/interface.mjs +0 -513
- package/dist/internals/simulation/interface.mjs.map +0 -1
- package/dist/internals/simulation/methods/constants.cjs +0 -72
- package/dist/internals/simulation/methods/constants.cjs.map +0 -1
- package/dist/internals/simulation/methods/constants.d.cts +0 -11
- package/dist/internals/simulation/methods/constants.d.cts.map +0 -1
- package/dist/internals/simulation/methods/constants.d.mts +0 -11
- package/dist/internals/simulation/methods/constants.d.mts.map +0 -1
- package/dist/internals/simulation/methods/constants.mjs +0 -69
- package/dist/internals/simulation/methods/constants.mjs.map +0 -1
- package/dist/internals/simulation/methods/hooks/get-preferences.cjs +0 -18
- package/dist/internals/simulation/methods/hooks/get-preferences.cjs.map +0 -1
- package/dist/internals/simulation/methods/hooks/get-preferences.d.cts +0 -14
- package/dist/internals/simulation/methods/hooks/get-preferences.d.cts.map +0 -1
- package/dist/internals/simulation/methods/hooks/get-preferences.d.mts +0 -14
- package/dist/internals/simulation/methods/hooks/get-preferences.d.mts.map +0 -1
- package/dist/internals/simulation/methods/hooks/get-preferences.mjs +0 -14
- package/dist/internals/simulation/methods/hooks/get-preferences.mjs.map +0 -1
- package/dist/internals/simulation/methods/hooks/index.cjs +0 -22
- package/dist/internals/simulation/methods/hooks/index.cjs.map +0 -1
- package/dist/internals/simulation/methods/hooks/index.d.cts +0 -6
- package/dist/internals/simulation/methods/hooks/index.d.cts.map +0 -1
- package/dist/internals/simulation/methods/hooks/index.d.mts +0 -6
- package/dist/internals/simulation/methods/hooks/index.d.mts.map +0 -1
- package/dist/internals/simulation/methods/hooks/index.mjs +0 -6
- package/dist/internals/simulation/methods/hooks/index.mjs.map +0 -1
- package/dist/internals/simulation/methods/hooks/interface.cjs +0 -24
- package/dist/internals/simulation/methods/hooks/interface.cjs.map +0 -1
- package/dist/internals/simulation/methods/hooks/interface.d.cts +0 -17
- package/dist/internals/simulation/methods/hooks/interface.d.cts.map +0 -1
- package/dist/internals/simulation/methods/hooks/interface.d.mts +0 -17
- package/dist/internals/simulation/methods/hooks/interface.d.mts.map +0 -1
- package/dist/internals/simulation/methods/hooks/interface.mjs +0 -19
- package/dist/internals/simulation/methods/hooks/interface.mjs.map +0 -1
- package/dist/internals/simulation/methods/hooks/notifications.cjs +0 -58
- package/dist/internals/simulation/methods/hooks/notifications.cjs.map +0 -1
- package/dist/internals/simulation/methods/hooks/notifications.d.cts +0 -17
- package/dist/internals/simulation/methods/hooks/notifications.d.cts.map +0 -1
- package/dist/internals/simulation/methods/hooks/notifications.d.mts +0 -17
- package/dist/internals/simulation/methods/hooks/notifications.d.mts.map +0 -1
- package/dist/internals/simulation/methods/hooks/notifications.mjs +0 -55
- package/dist/internals/simulation/methods/hooks/notifications.mjs.map +0 -1
- package/dist/internals/simulation/methods/hooks/request-user-approval.cjs +0 -38
- package/dist/internals/simulation/methods/hooks/request-user-approval.cjs.map +0 -1
- package/dist/internals/simulation/methods/hooks/request-user-approval.d.cts +0 -16
- package/dist/internals/simulation/methods/hooks/request-user-approval.d.cts.map +0 -1
- package/dist/internals/simulation/methods/hooks/request-user-approval.d.mts +0 -16
- package/dist/internals/simulation/methods/hooks/request-user-approval.d.mts.map +0 -1
- package/dist/internals/simulation/methods/hooks/request-user-approval.mjs +0 -35
- package/dist/internals/simulation/methods/hooks/request-user-approval.mjs.map +0 -1
- package/dist/internals/simulation/methods/hooks/state.cjs +0 -84
- package/dist/internals/simulation/methods/hooks/state.cjs.map +0 -1
- package/dist/internals/simulation/methods/hooks/state.d.cts +0 -24
- package/dist/internals/simulation/methods/hooks/state.d.cts.map +0 -1
- package/dist/internals/simulation/methods/hooks/state.d.mts +0 -24
- package/dist/internals/simulation/methods/hooks/state.d.mts.map +0 -1
- package/dist/internals/simulation/methods/hooks/state.mjs +0 -79
- package/dist/internals/simulation/methods/hooks/state.mjs.map +0 -1
- package/dist/internals/simulation/methods/index.cjs +0 -18
- package/dist/internals/simulation/methods/index.cjs.map +0 -1
- package/dist/internals/simulation/methods/index.d.cts +0 -2
- package/dist/internals/simulation/methods/index.d.cts.map +0 -1
- package/dist/internals/simulation/methods/index.d.mts +0 -2
- package/dist/internals/simulation/methods/index.d.mts.map +0 -1
- package/dist/internals/simulation/methods/index.mjs +0 -2
- package/dist/internals/simulation/methods/index.mjs.map +0 -1
- package/dist/internals/simulation/methods/specifications.cjs +0 -85
- package/dist/internals/simulation/methods/specifications.cjs.map +0 -1
- package/dist/internals/simulation/methods/specifications.d.cts +0 -57
- package/dist/internals/simulation/methods/specifications.d.cts.map +0 -1
- package/dist/internals/simulation/methods/specifications.d.mts +0 -57
- package/dist/internals/simulation/methods/specifications.d.mts.map +0 -1
- package/dist/internals/simulation/methods/specifications.mjs +0 -78
- package/dist/internals/simulation/methods/specifications.mjs.map +0 -1
- package/dist/internals/simulation/middleware/engine.cjs +0 -37
- package/dist/internals/simulation/middleware/engine.cjs.map +0 -1
- package/dist/internals/simulation/middleware/engine.d.cts +0 -27
- package/dist/internals/simulation/middleware/engine.d.cts.map +0 -1
- package/dist/internals/simulation/middleware/engine.d.mts +0 -27
- package/dist/internals/simulation/middleware/engine.d.mts.map +0 -1
- package/dist/internals/simulation/middleware/engine.mjs +0 -34
- package/dist/internals/simulation/middleware/engine.mjs.map +0 -1
- package/dist/internals/simulation/middleware/index.cjs +0 -18
- package/dist/internals/simulation/middleware/index.cjs.map +0 -1
- package/dist/internals/simulation/middleware/index.d.cts +0 -2
- package/dist/internals/simulation/middleware/index.d.cts.map +0 -1
- package/dist/internals/simulation/middleware/index.d.mts +0 -2
- package/dist/internals/simulation/middleware/index.d.mts.map +0 -1
- package/dist/internals/simulation/middleware/index.mjs +0 -2
- package/dist/internals/simulation/middleware/index.mjs.map +0 -1
- package/dist/internals/simulation/middleware/internal-methods/accounts.cjs +0 -34
- package/dist/internals/simulation/middleware/internal-methods/accounts.cjs.map +0 -1
- package/dist/internals/simulation/middleware/internal-methods/accounts.d.cts +0 -20
- package/dist/internals/simulation/middleware/internal-methods/accounts.d.cts.map +0 -1
- package/dist/internals/simulation/middleware/internal-methods/accounts.d.mts +0 -20
- package/dist/internals/simulation/middleware/internal-methods/accounts.d.mts.map +0 -1
- package/dist/internals/simulation/middleware/internal-methods/accounts.mjs +0 -30
- package/dist/internals/simulation/middleware/internal-methods/accounts.mjs.map +0 -1
- package/dist/internals/simulation/middleware/internal-methods/index.cjs +0 -18
- package/dist/internals/simulation/middleware/internal-methods/index.cjs.map +0 -1
- package/dist/internals/simulation/middleware/internal-methods/index.d.cts +0 -2
- package/dist/internals/simulation/middleware/internal-methods/index.d.cts.map +0 -1
- package/dist/internals/simulation/middleware/internal-methods/index.d.mts +0 -2
- package/dist/internals/simulation/middleware/internal-methods/index.d.mts.map +0 -1
- package/dist/internals/simulation/middleware/internal-methods/index.mjs +0 -2
- package/dist/internals/simulation/middleware/internal-methods/index.mjs.map +0 -1
- package/dist/internals/simulation/middleware/internal-methods/middleware.cjs +0 -44
- package/dist/internals/simulation/middleware/internal-methods/middleware.cjs.map +0 -1
- package/dist/internals/simulation/middleware/internal-methods/middleware.d.cts +0 -23
- package/dist/internals/simulation/middleware/internal-methods/middleware.d.cts.map +0 -1
- package/dist/internals/simulation/middleware/internal-methods/middleware.d.mts +0 -23
- package/dist/internals/simulation/middleware/internal-methods/middleware.d.mts.map +0 -1
- package/dist/internals/simulation/middleware/internal-methods/middleware.mjs +0 -40
- package/dist/internals/simulation/middleware/internal-methods/middleware.mjs.map +0 -1
- package/dist/internals/simulation/middleware/internal-methods/provider-state.cjs +0 -28
- package/dist/internals/simulation/middleware/internal-methods/provider-state.cjs.map +0 -1
- package/dist/internals/simulation/middleware/internal-methods/provider-state.d.cts +0 -16
- package/dist/internals/simulation/middleware/internal-methods/provider-state.d.cts.map +0 -1
- package/dist/internals/simulation/middleware/internal-methods/provider-state.d.mts +0 -16
- package/dist/internals/simulation/middleware/internal-methods/provider-state.d.mts.map +0 -1
- package/dist/internals/simulation/middleware/internal-methods/provider-state.mjs +0 -24
- package/dist/internals/simulation/middleware/internal-methods/provider-state.mjs.map +0 -1
- package/dist/internals/simulation/middleware/mock.cjs +0 -22
- package/dist/internals/simulation/middleware/mock.cjs.map +0 -1
- package/dist/internals/simulation/middleware/mock.d.cts +0 -11
- package/dist/internals/simulation/middleware/mock.d.cts.map +0 -1
- package/dist/internals/simulation/middleware/mock.d.mts +0 -11
- package/dist/internals/simulation/middleware/mock.d.mts.map +0 -1
- package/dist/internals/simulation/middleware/mock.mjs +0 -18
- package/dist/internals/simulation/middleware/mock.mjs.map +0 -1
- package/dist/internals/simulation/options.cjs +0 -25
- package/dist/internals/simulation/options.cjs.map +0 -1
- package/dist/internals/simulation/options.d.cts +0 -40
- package/dist/internals/simulation/options.d.cts.map +0 -1
- package/dist/internals/simulation/options.d.mts +0 -40
- package/dist/internals/simulation/options.d.mts.map +0 -1
- package/dist/internals/simulation/options.mjs +0 -21
- package/dist/internals/simulation/options.mjs.map +0 -1
- package/dist/internals/simulation/simulation.cjs +0 -155
- package/dist/internals/simulation/simulation.cjs.map +0 -1
- package/dist/internals/simulation/simulation.d.cts +0 -103
- package/dist/internals/simulation/simulation.d.cts.map +0 -1
- package/dist/internals/simulation/simulation.d.mts +0 -103
- package/dist/internals/simulation/simulation.d.mts.map +0 -1
- package/dist/internals/simulation/simulation.mjs +0 -150
- package/dist/internals/simulation/simulation.mjs.map +0 -1
- package/dist/internals/simulation/store/index.cjs +0 -21
- package/dist/internals/simulation/store/index.cjs.map +0 -1
- package/dist/internals/simulation/store/index.d.cts +0 -5
- package/dist/internals/simulation/store/index.d.cts.map +0 -1
- package/dist/internals/simulation/store/index.d.mts +0 -5
- package/dist/internals/simulation/store/index.d.mts.map +0 -1
- package/dist/internals/simulation/store/index.mjs +0 -5
- package/dist/internals/simulation/store/index.mjs.map +0 -1
- package/dist/internals/simulation/store/mocks.cjs +0 -39
- package/dist/internals/simulation/store/mocks.cjs.map +0 -1
- package/dist/internals/simulation/store/mocks.d.cts +0 -36
- package/dist/internals/simulation/store/mocks.d.cts.map +0 -1
- package/dist/internals/simulation/store/mocks.d.mts +0 -36
- package/dist/internals/simulation/store/mocks.d.mts.map +0 -1
- package/dist/internals/simulation/store/mocks.mjs +0 -35
- package/dist/internals/simulation/store/mocks.mjs.map +0 -1
- package/dist/internals/simulation/store/notifications.cjs +0 -35
- package/dist/internals/simulation/store/notifications.cjs.map +0 -1
- package/dist/internals/simulation/store/notifications.d.cts +0 -45
- package/dist/internals/simulation/store/notifications.d.cts.map +0 -1
- package/dist/internals/simulation/store/notifications.d.mts +0 -45
- package/dist/internals/simulation/store/notifications.d.mts.map +0 -1
- package/dist/internals/simulation/store/notifications.mjs +0 -32
- package/dist/internals/simulation/store/notifications.mjs.map +0 -1
- package/dist/internals/simulation/store/state.cjs +0 -54
- package/dist/internals/simulation/store/state.cjs.map +0 -1
- package/dist/internals/simulation/store/state.d.cts +0 -56
- package/dist/internals/simulation/store/state.d.cts.map +0 -1
- package/dist/internals/simulation/store/state.d.mts +0 -56
- package/dist/internals/simulation/store/state.d.mts.map +0 -1
- package/dist/internals/simulation/store/state.mjs +0 -50
- package/dist/internals/simulation/store/state.mjs.map +0 -1
- package/dist/internals/simulation/store/store.cjs +0 -51
- package/dist/internals/simulation/store/store.cjs.map +0 -1
- package/dist/internals/simulation/store/store.d.cts +0 -22
- package/dist/internals/simulation/store/store.d.cts.map +0 -1
- package/dist/internals/simulation/store/store.d.mts +0 -22
- package/dist/internals/simulation/store/store.d.mts.map +0 -1
- package/dist/internals/simulation/store/store.mjs +0 -45
- package/dist/internals/simulation/store/store.mjs.map +0 -1
- package/dist/internals/simulation/store/ui.cjs +0 -24
- package/dist/internals/simulation/store/ui.cjs.map +0 -1
- package/dist/internals/simulation/store/ui.d.cts +0 -27
- package/dist/internals/simulation/store/ui.d.cts.map +0 -1
- package/dist/internals/simulation/store/ui.d.mts +0 -27
- package/dist/internals/simulation/store/ui.d.mts.map +0 -1
- package/dist/internals/simulation/store/ui.mjs +0 -21
- package/dist/internals/simulation/store/ui.mjs.map +0 -1
- package/dist/internals/structs.cjs +0 -157
- package/dist/internals/structs.cjs.map +0 -1
- package/dist/internals/structs.d.cts +0 -205
- package/dist/internals/structs.d.cts.map +0 -1
- package/dist/internals/structs.d.mts +0 -205
- package/dist/internals/structs.d.mts.map +0 -1
- package/dist/internals/structs.mjs +0 -154
- package/dist/internals/structs.mjs.map +0 -1
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import type { ActionConstraint, EventConstraint } from "@metamask/base-controller";
|
|
2
|
-
import { ControllerMessenger } from "@metamask/base-controller";
|
|
3
|
-
import type { AbstractExecutionService } from "@metamask/snaps-controllers";
|
|
4
|
-
import type { AuxiliaryFileEncoding, Component, InterfaceState, SnapId } from "@metamask/snaps-sdk";
|
|
5
|
-
import type { FetchedSnapFiles } from "@metamask/snaps-utils";
|
|
6
|
-
import type { Json } from "@metamask/utils";
|
|
7
|
-
import type { RootControllerMessenger } from "./controllers.cjs";
|
|
8
|
-
import type { SimulationOptions, SimulationUserOptions } from "./options.cjs";
|
|
9
|
-
import type { RunSagaFunction, Store } from "./store/index.cjs";
|
|
10
|
-
/**
|
|
11
|
-
* Options for the execution service, without the options that are shared
|
|
12
|
-
* between all execution services.
|
|
13
|
-
*
|
|
14
|
-
* @template Service - The type of the execution service, i.e., the class that
|
|
15
|
-
* creates the execution service.
|
|
16
|
-
*/
|
|
17
|
-
export type ExecutionServiceOptions<Service extends new (...args: any[]) => any> = Omit<ConstructorParameters<Service>[0], keyof ConstructorParameters<typeof AbstractExecutionService<unknown>>[0]>;
|
|
18
|
-
/**
|
|
19
|
-
* The options for running a Snap in a simulated environment.
|
|
20
|
-
*
|
|
21
|
-
* @property executionService - The execution service to use.
|
|
22
|
-
* @property executionServiceOptions - The options to use when creating the
|
|
23
|
-
* execution service, if any. This should only include options specific to the
|
|
24
|
-
* provided execution service.
|
|
25
|
-
* @property options - The simulation options.
|
|
26
|
-
* @template Service - The type of the execution service.
|
|
27
|
-
*/
|
|
28
|
-
export type InstallSnapOptions<Service extends new (...args: any[]) => InstanceType<typeof AbstractExecutionService<unknown>>> = ExecutionServiceOptions<Service> extends Record<string, never> ? {
|
|
29
|
-
executionService: Service;
|
|
30
|
-
executionServiceOptions?: ExecutionServiceOptions<Service>;
|
|
31
|
-
options?: SimulationUserOptions;
|
|
32
|
-
} : {
|
|
33
|
-
executionService: Service;
|
|
34
|
-
executionServiceOptions: ExecutionServiceOptions<Service>;
|
|
35
|
-
options?: SimulationUserOptions;
|
|
36
|
-
};
|
|
37
|
-
export type InstalledSnap = {
|
|
38
|
-
snapId: SnapId;
|
|
39
|
-
store: Store;
|
|
40
|
-
executionService: InstanceType<typeof AbstractExecutionService>;
|
|
41
|
-
controllerMessenger: ControllerMessenger<ActionConstraint, EventConstraint>;
|
|
42
|
-
runSaga: RunSagaFunction;
|
|
43
|
-
};
|
|
44
|
-
export type MiddlewareHooks = {
|
|
45
|
-
/**
|
|
46
|
-
* A hook that returns the user's secret recovery phrase.
|
|
47
|
-
*
|
|
48
|
-
* @returns The user's secret recovery phrase.
|
|
49
|
-
*/
|
|
50
|
-
getMnemonic: () => Promise<Uint8Array>;
|
|
51
|
-
/**
|
|
52
|
-
* A hook that returns the Snap's auxiliary file for the given path.
|
|
53
|
-
*
|
|
54
|
-
* @param path - The path of the auxiliary file to get.
|
|
55
|
-
* @param encoding - The encoding to use when returning the file.
|
|
56
|
-
* @returns The Snap's auxiliary file for the given path.
|
|
57
|
-
*/
|
|
58
|
-
getSnapFile: (path: string, encoding: AuxiliaryFileEncoding) => Promise<string | null>;
|
|
59
|
-
/**
|
|
60
|
-
* A hook that returns whether the client is locked or not.
|
|
61
|
-
*
|
|
62
|
-
* @returns A boolean flag signaling whether the client is locked.
|
|
63
|
-
*/
|
|
64
|
-
getIsLocked: () => boolean;
|
|
65
|
-
createInterface: (content: Component) => Promise<string>;
|
|
66
|
-
updateInterface: (id: string, content: Component) => Promise<void>;
|
|
67
|
-
getInterfaceState: (id: string) => InterfaceState;
|
|
68
|
-
resolveInterface: (id: string, value: Json) => Promise<void>;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Install a Snap in a simulated environment. This will fetch the Snap files,
|
|
72
|
-
* create a Redux store, set up the controllers and JSON-RPC stack, register the
|
|
73
|
-
* Snap, and run the Snap code in the execution service.
|
|
74
|
-
*
|
|
75
|
-
* @param snapId - The ID of the Snap to install.
|
|
76
|
-
* @param options - The options to use when installing the Snap.
|
|
77
|
-
* @param options.executionService - The execution service to use.
|
|
78
|
-
* @param options.executionServiceOptions - The options to use when creating the
|
|
79
|
-
* execution service, if any. This should only include options specific to the
|
|
80
|
-
* provided execution service.
|
|
81
|
-
* @param options.options - The simulation options.
|
|
82
|
-
* @returns The installed Snap object.
|
|
83
|
-
* @template Service - The type of the execution service.
|
|
84
|
-
*/
|
|
85
|
-
export declare function handleInstallSnap<Service extends new (...args: any[]) => InstanceType<typeof AbstractExecutionService>>(snapId: SnapId, { executionService, executionServiceOptions, options: rawOptions, }?: Partial<InstallSnapOptions<Service>>): Promise<InstalledSnap>;
|
|
86
|
-
/**
|
|
87
|
-
* Get the hooks for the simulation.
|
|
88
|
-
*
|
|
89
|
-
* @param options - The simulation options.
|
|
90
|
-
* @param snapFiles - The Snap files.
|
|
91
|
-
* @param snapId - The Snap ID.
|
|
92
|
-
* @param controllerMessenger - The controller messenger.
|
|
93
|
-
* @returns The hooks for the simulation.
|
|
94
|
-
*/
|
|
95
|
-
export declare function getHooks(options: SimulationOptions, snapFiles: FetchedSnapFiles, snapId: SnapId, controllerMessenger: RootControllerMessenger): MiddlewareHooks;
|
|
96
|
-
/**
|
|
97
|
-
* Register mocked action handlers.
|
|
98
|
-
*
|
|
99
|
-
* @param controllerMessenger - The controller messenger.
|
|
100
|
-
* @param runSaga - The run saga function.
|
|
101
|
-
*/
|
|
102
|
-
export declare function registerActions(controllerMessenger: RootControllerMessenger, runSaga: RunSagaFunction): void;
|
|
103
|
-
//# sourceMappingURL=simulation.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simulation.d.cts","sourceRoot":"","sources":["../../../src/internals/simulation/simulation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EAChB,kCAAkC;AACnC,OAAO,EAAE,mBAAmB,EAAE,kCAAkC;AAIhE,OAAO,KAAK,EAAE,wBAAwB,EAAE,oCAAoC;AAQ5E,OAAO,KAAK,EACV,qBAAqB,EACrB,SAAS,EACT,cAAc,EACd,MAAM,EACP,4BAA4B;AAC7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,8BAA8B;AAE9D,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAM5C,OAAO,KAAK,EAAE,uBAAuB,EAAE,0BAAsB;AAM7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,sBAAkB;AAE1E,OAAO,KAAK,EAAa,eAAe,EAAE,KAAK,EAAE,0BAAgB;AAGjE;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,CACjC,OAAO,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,IACzC,IAAI,CACN,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EACjC,MAAM,qBAAqB,CAAC,OAAO,wBAAwB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CACzE,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,kBAAkB,CAC5B,OAAO,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,YAAY,CAClD,OAAO,wBAAwB,CAAC,OAAO,CAAC,CACzC,IACC,uBAAuB,CAAC,OAAO,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAC9D;IACE,gBAAgB,EAAE,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AAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,YAAY,CAClD,OAAO,wBAAwB,CAChC,EAED,MAAM,EAAE,MAAM,EACd,EACE,gBAAgB,EAChB,uBAAuB,EACvB,OAAO,EAAE,UAAe,GACzB,GAAE,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAM,GAC3C,OAAO,CAAC,aAAa,CAAC,CAgFxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,iBAAiB,EAC1B,SAAS,EAAE,gBAAgB,EAC3B,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,uBAAuB,GAC3C,eAAe,CAgCjB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,mBAAmB,EAAE,uBAAuB,EAC5C,OAAO,EAAE,eAAe,QA4CzB"}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import type { ActionConstraint, EventConstraint } from "@metamask/base-controller";
|
|
2
|
-
import { ControllerMessenger } from "@metamask/base-controller";
|
|
3
|
-
import type { AbstractExecutionService } from "@metamask/snaps-controllers";
|
|
4
|
-
import type { AuxiliaryFileEncoding, Component, InterfaceState, SnapId } from "@metamask/snaps-sdk";
|
|
5
|
-
import type { FetchedSnapFiles } from "@metamask/snaps-utils";
|
|
6
|
-
import type { Json } from "@metamask/utils";
|
|
7
|
-
import type { RootControllerMessenger } from "./controllers.mjs";
|
|
8
|
-
import type { SimulationOptions, SimulationUserOptions } from "./options.mjs";
|
|
9
|
-
import type { RunSagaFunction, Store } from "./store/index.mjs";
|
|
10
|
-
/**
|
|
11
|
-
* Options for the execution service, without the options that are shared
|
|
12
|
-
* between all execution services.
|
|
13
|
-
*
|
|
14
|
-
* @template Service - The type of the execution service, i.e., the class that
|
|
15
|
-
* creates the execution service.
|
|
16
|
-
*/
|
|
17
|
-
export type ExecutionServiceOptions<Service extends new (...args: any[]) => any> = Omit<ConstructorParameters<Service>[0], keyof ConstructorParameters<typeof AbstractExecutionService<unknown>>[0]>;
|
|
18
|
-
/**
|
|
19
|
-
* The options for running a Snap in a simulated environment.
|
|
20
|
-
*
|
|
21
|
-
* @property executionService - The execution service to use.
|
|
22
|
-
* @property executionServiceOptions - The options to use when creating the
|
|
23
|
-
* execution service, if any. This should only include options specific to the
|
|
24
|
-
* provided execution service.
|
|
25
|
-
* @property options - The simulation options.
|
|
26
|
-
* @template Service - The type of the execution service.
|
|
27
|
-
*/
|
|
28
|
-
export type InstallSnapOptions<Service extends new (...args: any[]) => InstanceType<typeof AbstractExecutionService<unknown>>> = ExecutionServiceOptions<Service> extends Record<string, never> ? {
|
|
29
|
-
executionService: Service;
|
|
30
|
-
executionServiceOptions?: ExecutionServiceOptions<Service>;
|
|
31
|
-
options?: SimulationUserOptions;
|
|
32
|
-
} : {
|
|
33
|
-
executionService: Service;
|
|
34
|
-
executionServiceOptions: ExecutionServiceOptions<Service>;
|
|
35
|
-
options?: SimulationUserOptions;
|
|
36
|
-
};
|
|
37
|
-
export type InstalledSnap = {
|
|
38
|
-
snapId: SnapId;
|
|
39
|
-
store: Store;
|
|
40
|
-
executionService: InstanceType<typeof AbstractExecutionService>;
|
|
41
|
-
controllerMessenger: ControllerMessenger<ActionConstraint, EventConstraint>;
|
|
42
|
-
runSaga: RunSagaFunction;
|
|
43
|
-
};
|
|
44
|
-
export type MiddlewareHooks = {
|
|
45
|
-
/**
|
|
46
|
-
* A hook that returns the user's secret recovery phrase.
|
|
47
|
-
*
|
|
48
|
-
* @returns The user's secret recovery phrase.
|
|
49
|
-
*/
|
|
50
|
-
getMnemonic: () => Promise<Uint8Array>;
|
|
51
|
-
/**
|
|
52
|
-
* A hook that returns the Snap's auxiliary file for the given path.
|
|
53
|
-
*
|
|
54
|
-
* @param path - The path of the auxiliary file to get.
|
|
55
|
-
* @param encoding - The encoding to use when returning the file.
|
|
56
|
-
* @returns The Snap's auxiliary file for the given path.
|
|
57
|
-
*/
|
|
58
|
-
getSnapFile: (path: string, encoding: AuxiliaryFileEncoding) => Promise<string | null>;
|
|
59
|
-
/**
|
|
60
|
-
* A hook that returns whether the client is locked or not.
|
|
61
|
-
*
|
|
62
|
-
* @returns A boolean flag signaling whether the client is locked.
|
|
63
|
-
*/
|
|
64
|
-
getIsLocked: () => boolean;
|
|
65
|
-
createInterface: (content: Component) => Promise<string>;
|
|
66
|
-
updateInterface: (id: string, content: Component) => Promise<void>;
|
|
67
|
-
getInterfaceState: (id: string) => InterfaceState;
|
|
68
|
-
resolveInterface: (id: string, value: Json) => Promise<void>;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Install a Snap in a simulated environment. This will fetch the Snap files,
|
|
72
|
-
* create a Redux store, set up the controllers and JSON-RPC stack, register the
|
|
73
|
-
* Snap, and run the Snap code in the execution service.
|
|
74
|
-
*
|
|
75
|
-
* @param snapId - The ID of the Snap to install.
|
|
76
|
-
* @param options - The options to use when installing the Snap.
|
|
77
|
-
* @param options.executionService - The execution service to use.
|
|
78
|
-
* @param options.executionServiceOptions - The options to use when creating the
|
|
79
|
-
* execution service, if any. This should only include options specific to the
|
|
80
|
-
* provided execution service.
|
|
81
|
-
* @param options.options - The simulation options.
|
|
82
|
-
* @returns The installed Snap object.
|
|
83
|
-
* @template Service - The type of the execution service.
|
|
84
|
-
*/
|
|
85
|
-
export declare function handleInstallSnap<Service extends new (...args: any[]) => InstanceType<typeof AbstractExecutionService>>(snapId: SnapId, { executionService, executionServiceOptions, options: rawOptions, }?: Partial<InstallSnapOptions<Service>>): Promise<InstalledSnap>;
|
|
86
|
-
/**
|
|
87
|
-
* Get the hooks for the simulation.
|
|
88
|
-
*
|
|
89
|
-
* @param options - The simulation options.
|
|
90
|
-
* @param snapFiles - The Snap files.
|
|
91
|
-
* @param snapId - The Snap ID.
|
|
92
|
-
* @param controllerMessenger - The controller messenger.
|
|
93
|
-
* @returns The hooks for the simulation.
|
|
94
|
-
*/
|
|
95
|
-
export declare function getHooks(options: SimulationOptions, snapFiles: FetchedSnapFiles, snapId: SnapId, controllerMessenger: RootControllerMessenger): MiddlewareHooks;
|
|
96
|
-
/**
|
|
97
|
-
* Register mocked action handlers.
|
|
98
|
-
*
|
|
99
|
-
* @param controllerMessenger - The controller messenger.
|
|
100
|
-
* @param runSaga - The run saga function.
|
|
101
|
-
*/
|
|
102
|
-
export declare function registerActions(controllerMessenger: RootControllerMessenger, runSaga: RunSagaFunction): void;
|
|
103
|
-
//# sourceMappingURL=simulation.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simulation.d.mts","sourceRoot":"","sources":["../../../src/internals/simulation/simulation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EAChB,kCAAkC;AACnC,OAAO,EAAE,mBAAmB,EAAE,kCAAkC;AAIhE,OAAO,KAAK,EAAE,wBAAwB,EAAE,oCAAoC;AAQ5E,OAAO,KAAK,EACV,qBAAqB,EACrB,SAAS,EACT,cAAc,EACd,MAAM,EACP,4BAA4B;AAC7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,8BAA8B;AAE9D,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAM5C,OAAO,KAAK,EAAE,uBAAuB,EAAE,0BAAsB;AAM7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,sBAAkB;AAE1E,OAAO,KAAK,EAAa,eAAe,EAAE,KAAK,EAAE,0BAAgB;AAGjE;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,CACjC,OAAO,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,IACzC,IAAI,CACN,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EACjC,MAAM,qBAAqB,CAAC,OAAO,wBAAwB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CACzE,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,kBAAkB,CAC5B,OAAO,SAAS,KAAK,GAAG,IAA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D,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9D,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,YAAY,CAClD,OAAO,wBAAwB,CAChC,EAED,MAAM,EAAE,MAAM,EACd,EACE,gBAAgB,EAChB,uBAAuB,EACvB,OAAO,EAAE,UAAe,GACzB,GAAE,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAM,GAC3C,OAAO,CAAC,aAAa,CAAC,CAgFxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,iBAAiB,EAC1B,SAAS,EAAE,gBAAgB,EAC3B,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,uBAAuB,GAC3C,eAAe,CAgCjB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,mBAAmB,EAAE,uBAAuB,EAC5C,OAAO,EAAE,eAAe,QA4CzB"}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { ControllerMessenger } from "@metamask/base-controller";
|
|
2
|
-
import { createEngineStream } from "@metamask/json-rpc-middleware-stream";
|
|
3
|
-
import { mnemonicPhraseToBytes } from "@metamask/key-tree";
|
|
4
|
-
import { PhishingDetectorResultType } from "@metamask/phishing-controller";
|
|
5
|
-
import { detectSnapLocation, fetchSnap, NodeThreadExecutionService, setupMultiplex } from "@metamask/snaps-controllers/node";
|
|
6
|
-
import { DIALOG_APPROVAL_TYPES } from "@metamask/snaps-rpc-methods";
|
|
7
|
-
import { logError } from "@metamask/snaps-utils";
|
|
8
|
-
import { pipeline } from "readable-stream";
|
|
9
|
-
import $reduxsagaeffects from "redux-saga/effects";
|
|
10
|
-
const { select } = $reduxsagaeffects;
|
|
11
|
-
import { getControllers, registerSnap } from "./controllers.mjs";
|
|
12
|
-
import { getSnapFile } from "./files.mjs";
|
|
13
|
-
import { resolveWithSaga } from "./interface.mjs";
|
|
14
|
-
import { getEndowments } from "./methods/index.mjs";
|
|
15
|
-
import { createJsonRpcEngine } from "./middleware/index.mjs";
|
|
16
|
-
import { getOptions } from "./options.mjs";
|
|
17
|
-
import { createStore, getCurrentInterface } from "./store/index.mjs";
|
|
18
|
-
/**
|
|
19
|
-
* Install a Snap in a simulated environment. This will fetch the Snap files,
|
|
20
|
-
* create a Redux store, set up the controllers and JSON-RPC stack, register the
|
|
21
|
-
* Snap, and run the Snap code in the execution service.
|
|
22
|
-
*
|
|
23
|
-
* @param snapId - The ID of the Snap to install.
|
|
24
|
-
* @param options - The options to use when installing the Snap.
|
|
25
|
-
* @param options.executionService - The execution service to use.
|
|
26
|
-
* @param options.executionServiceOptions - The options to use when creating the
|
|
27
|
-
* execution service, if any. This should only include options specific to the
|
|
28
|
-
* provided execution service.
|
|
29
|
-
* @param options.options - The simulation options.
|
|
30
|
-
* @returns The installed Snap object.
|
|
31
|
-
* @template Service - The type of the execution service.
|
|
32
|
-
*/
|
|
33
|
-
export async function handleInstallSnap(snapId, { executionService, executionServiceOptions, options: rawOptions = {}, } = {}) {
|
|
34
|
-
const options = getOptions(rawOptions);
|
|
35
|
-
// Fetch Snap files.
|
|
36
|
-
const location = detectSnapLocation(snapId, {
|
|
37
|
-
allowLocal: true,
|
|
38
|
-
});
|
|
39
|
-
const snapFiles = await fetchSnap(snapId, location);
|
|
40
|
-
// Create Redux store.
|
|
41
|
-
const { store, runSaga } = createStore(options);
|
|
42
|
-
const controllerMessenger = new ControllerMessenger();
|
|
43
|
-
registerActions(controllerMessenger, runSaga);
|
|
44
|
-
// Set up controllers and JSON-RPC stack.
|
|
45
|
-
const hooks = getHooks(options, snapFiles, snapId, controllerMessenger);
|
|
46
|
-
const { subjectMetadataController, permissionController } = getControllers({
|
|
47
|
-
controllerMessenger,
|
|
48
|
-
hooks,
|
|
49
|
-
runSaga,
|
|
50
|
-
options,
|
|
51
|
-
});
|
|
52
|
-
const engine = createJsonRpcEngine({
|
|
53
|
-
store,
|
|
54
|
-
hooks,
|
|
55
|
-
permissionMiddleware: permissionController.createPermissionMiddleware({
|
|
56
|
-
origin: snapId,
|
|
57
|
-
}),
|
|
58
|
-
});
|
|
59
|
-
// Create execution service.
|
|
60
|
-
const ExecutionService = executionService ?? NodeThreadExecutionService;
|
|
61
|
-
const service = new ExecutionService({
|
|
62
|
-
...executionServiceOptions,
|
|
63
|
-
messenger: controllerMessenger.getRestricted({
|
|
64
|
-
name: 'ExecutionService',
|
|
65
|
-
allowedActions: [],
|
|
66
|
-
allowedEvents: [],
|
|
67
|
-
}),
|
|
68
|
-
setupSnapProvider: (_snapId, rpcStream) => {
|
|
69
|
-
const mux = setupMultiplex(rpcStream, 'snapStream');
|
|
70
|
-
const stream = mux.createStream('metamask-provider');
|
|
71
|
-
const providerStream = createEngineStream({ engine });
|
|
72
|
-
// Error function is difficult to test, so we ignore it.
|
|
73
|
-
/* istanbul ignore next 2 */
|
|
74
|
-
pipeline(stream, providerStream, stream, (error) => {
|
|
75
|
-
if (error) {
|
|
76
|
-
logError(`Provider stream failure.`, error);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
// Register the Snap. This sets up the Snap's permissions and subject
|
|
82
|
-
// metadata.
|
|
83
|
-
await registerSnap(snapId, snapFiles.manifest.result, {
|
|
84
|
-
permissionController,
|
|
85
|
-
subjectMetadataController,
|
|
86
|
-
});
|
|
87
|
-
// Run the Snap code in the execution service.
|
|
88
|
-
await service.executeSnap({
|
|
89
|
-
snapId,
|
|
90
|
-
sourceCode: snapFiles.sourceCode.toString('utf8'),
|
|
91
|
-
endowments: await getEndowments(permissionController, snapId),
|
|
92
|
-
});
|
|
93
|
-
return {
|
|
94
|
-
snapId,
|
|
95
|
-
store,
|
|
96
|
-
executionService: service,
|
|
97
|
-
controllerMessenger,
|
|
98
|
-
runSaga,
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Get the hooks for the simulation.
|
|
103
|
-
*
|
|
104
|
-
* @param options - The simulation options.
|
|
105
|
-
* @param snapFiles - The Snap files.
|
|
106
|
-
* @param snapId - The Snap ID.
|
|
107
|
-
* @param controllerMessenger - The controller messenger.
|
|
108
|
-
* @returns The hooks for the simulation.
|
|
109
|
-
*/
|
|
110
|
-
export function getHooks(options, snapFiles, snapId, controllerMessenger) {
|
|
111
|
-
return {
|
|
112
|
-
getMnemonic: async () => Promise.resolve(mnemonicPhraseToBytes(options.secretRecoveryPhrase)),
|
|
113
|
-
getSnapFile: async (path, encoding) => await getSnapFile(snapFiles.auxiliaryFiles, path, encoding),
|
|
114
|
-
getIsLocked: () => false,
|
|
115
|
-
createInterface: async (...args) => controllerMessenger.call('SnapInterfaceController:createInterface', snapId, ...args),
|
|
116
|
-
updateInterface: async (...args) => controllerMessenger.call('SnapInterfaceController:updateInterface', snapId, ...args),
|
|
117
|
-
getInterfaceState: (...args) => controllerMessenger.call('SnapInterfaceController:getInterface', snapId, ...args).state,
|
|
118
|
-
resolveInterface: async (...args) => controllerMessenger.call('SnapInterfaceController:resolveInterface', snapId, ...args),
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Register mocked action handlers.
|
|
123
|
-
*
|
|
124
|
-
* @param controllerMessenger - The controller messenger.
|
|
125
|
-
* @param runSaga - The run saga function.
|
|
126
|
-
*/
|
|
127
|
-
export function registerActions(controllerMessenger, runSaga) {
|
|
128
|
-
controllerMessenger.registerActionHandler('PhishingController:maybeUpdateState', async () => Promise.resolve());
|
|
129
|
-
controllerMessenger.registerActionHandler('PhishingController:testOrigin', () => ({ result: false, type: PhishingDetectorResultType.All }));
|
|
130
|
-
controllerMessenger.registerActionHandler('ApprovalController:hasRequest', (opts) => {
|
|
131
|
-
/**
|
|
132
|
-
* Get the current interface from the store.
|
|
133
|
-
*
|
|
134
|
-
* @yields Selects the current interface from the store.
|
|
135
|
-
* @returns The current interface.
|
|
136
|
-
*/
|
|
137
|
-
function* getCurrentInterfaceSaga() {
|
|
138
|
-
const currentInterface = yield select(getCurrentInterface);
|
|
139
|
-
return currentInterface;
|
|
140
|
-
}
|
|
141
|
-
const currentInterface = runSaga(getCurrentInterfaceSaga).result();
|
|
142
|
-
return (currentInterface?.type === DIALOG_APPROVAL_TYPES.default &&
|
|
143
|
-
currentInterface?.id === opts?.id);
|
|
144
|
-
});
|
|
145
|
-
controllerMessenger.registerActionHandler('ApprovalController:acceptRequest', async (_id, value) => {
|
|
146
|
-
await runSaga(resolveWithSaga, value).toPromise();
|
|
147
|
-
return { value };
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
//# sourceMappingURL=simulation.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simulation.mjs","sourceRoot":"","sources":["../../../src/internals/simulation/simulation.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,kCAAkC;AAChE,OAAO,EAAE,kBAAkB,EAAE,6CAA6C;AAC1E,OAAO,EAAE,qBAAqB,EAAE,2BAA2B;AAC3D,OAAO,EAAE,0BAA0B,EAAE,sCAAsC;AAE3E,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,0BAA0B,EAC1B,cAAc,EACf,yCAAyC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,oCAAoC;AAQpE,OAAO,EAAE,QAAQ,EAAE,8BAA8B;AAGjD,OAAO,EAAE,QAAQ,EAAE,wBAAwB;;;AAK3C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,0BAAsB;AAC7D,OAAO,EAAE,WAAW,EAAE,oBAAgB;AACtC,OAAO,EAAE,eAAe,EAAE,wBAAoB;AAC9C,OAAO,EAAE,aAAa,EAAE,4BAAkB;AAC1C,OAAO,EAAE,mBAAmB,EAAE,+BAAqB;AAEnD,OAAO,EAAE,UAAU,EAAE,sBAAkB;AA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AAQ,CAAC,CAAC,uBAAuB;YAC/B,MAAM,gBAAgB,GAAc,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;YACtE,OAAO,gBAAgB,CAAC;QAC1B,CAAC;QAED,MAAM,gBAAgB,GAA0B,OAAO,CACrD,uBAAuB,CACxB,CAAC,MAAM,EAAE,CAAC;QACX,OAAO,CACL,gBAAgB,EAAE,IAAI,KAAK,qBAAqB,CAAC,OAAO;YACxD,gBAAgB,EAAE,EAAE,KAAK,IAAI,EAAE,EAAE,CAClC,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,mBAAmB,CAAC,qBAAqB,CACvC,kCAAkC,EAClC,KAAK,EAAE,GAAW,EAAE,KAAc,EAAE,EAAE;QACpC,MAAM,OAAO,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC,SAAS,EAAE,CAAC;QAElD,OAAO,EAAE,KAAK,EAAE,CAAC;IACnB,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ActionConstraint,\n EventConstraint,\n} from '@metamask/base-controller';\nimport { ControllerMessenger } from '@metamask/base-controller';\nimport { createEngineStream } from '@metamask/json-rpc-middleware-stream';\nimport { mnemonicPhraseToBytes } from '@metamask/key-tree';\nimport { PhishingDetectorResultType } from '@metamask/phishing-controller';\nimport type { AbstractExecutionService } from '@metamask/snaps-controllers';\nimport {\n detectSnapLocation,\n fetchSnap,\n NodeThreadExecutionService,\n setupMultiplex,\n} from '@metamask/snaps-controllers/node';\nimport { DIALOG_APPROVAL_TYPES } from '@metamask/snaps-rpc-methods';\nimport type {\n AuxiliaryFileEncoding,\n Component,\n InterfaceState,\n SnapId,\n} from '@metamask/snaps-sdk';\nimport type { FetchedSnapFiles } from '@metamask/snaps-utils';\nimport { logError } from '@metamask/snaps-utils';\nimport type { Json } from '@metamask/utils';\nimport type { Duplex } from 'readable-stream';\nimport { pipeline } from 'readable-stream';\nimport type { SagaIterator } from 'redux-saga';\nimport { select } from 'redux-saga/effects';\n\nimport type { RootControllerMessenger } from './controllers';\nimport { getControllers, registerSnap } from './controllers';\nimport { getSnapFile } from './files';\nimport { resolveWithSaga } from './interface';\nimport { getEndowments } from './methods';\nimport { createJsonRpcEngine } from './middleware';\nimport type { SimulationOptions, SimulationUserOptions } from './options';\nimport { getOptions } from './options';\nimport type { Interface, RunSagaFunction, Store } from './store';\nimport { createStore, getCurrentInterface } from './store';\n\n/**\n * Options for the execution service, without the options that are shared\n * between all execution services.\n *\n * @template Service - The type of the execution service, i.e., the class that\n * creates the execution service.\n */\nexport type ExecutionServiceOptions<\n Service extends new (...args: any[]) => any,\n> = Omit<\n ConstructorParameters<Service>[0],\n keyof ConstructorParameters<typeof AbstractExecutionService<unknown>>[0]\n>;\n\n/**\n * The options for running a Snap in a simulated environment.\n *\n * @property executionService - The execution service to use.\n * @property 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 * @property options - The simulation options.\n * @template Service - The type of the execution service.\n */\nexport type InstallSnapOptions<\n Service extends new (...args: any[]) => InstanceType<\n typeof AbstractExecutionService<unknown>\n >,\n> = ExecutionServiceOptions<Service> extends Record<string, never>\n ? {\n executionService: Service;\n executionServiceOptions?: ExecutionServiceOptions<Service>;\n options?: SimulationUserOptions;\n }\n : {\n executionService: Service;\n executionServiceOptions: ExecutionServiceOptions<Service>;\n options?: SimulationUserOptions;\n };\n\nexport type InstalledSnap = {\n snapId: SnapId;\n store: Store;\n executionService: InstanceType<typeof AbstractExecutionService>;\n controllerMessenger: ControllerMessenger<ActionConstraint, EventConstraint>;\n runSaga: RunSagaFunction;\n};\n\nexport type MiddlewareHooks = {\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 /**\n * A hook that returns the Snap's auxiliary file for the given path.\n *\n * @param path - The path of the auxiliary file to get.\n * @param encoding - The encoding to use when returning the file.\n * @returns The Snap's auxiliary file for the given path.\n */\n getSnapFile: (\n path: string,\n encoding: AuxiliaryFileEncoding,\n ) => Promise<string | null>;\n\n /**\n * A hook that returns whether the client is locked or not.\n *\n * @returns A boolean flag signaling whether the client is locked.\n */\n getIsLocked: () => boolean;\n createInterface: (content: Component) => Promise<string>;\n updateInterface: (id: string, content: Component) => Promise<void>;\n getInterfaceState: (id: string) => InterfaceState;\n resolveInterface: (id: string, value: Json) => Promise<void>;\n};\n\n/**\n * Install a Snap in a simulated environment. This will fetch the Snap files,\n * create a Redux store, set up the controllers and JSON-RPC stack, register the\n * Snap, and run the Snap code in the 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 * @returns The installed Snap object.\n * @template Service - The type of the execution service.\n */\nexport async function handleInstallSnap<\n Service extends new (...args: any[]) => InstanceType<\n typeof AbstractExecutionService\n >,\n>(\n snapId: SnapId,\n {\n executionService,\n executionServiceOptions,\n options: rawOptions = {},\n }: Partial<InstallSnapOptions<Service>> = {},\n): Promise<InstalledSnap> {\n const options = getOptions(rawOptions);\n\n // Fetch Snap files.\n const location = detectSnapLocation(snapId, {\n allowLocal: true,\n });\n\n const snapFiles = await fetchSnap(snapId, location);\n\n // Create Redux store.\n const { store, runSaga } = createStore(options);\n\n const controllerMessenger = new ControllerMessenger<any, any>();\n\n registerActions(controllerMessenger, runSaga);\n\n // Set up controllers and JSON-RPC stack.\n const hooks = getHooks(options, snapFiles, snapId, controllerMessenger);\n\n const { subjectMetadataController, permissionController } = getControllers({\n controllerMessenger,\n hooks,\n runSaga,\n options,\n });\n\n const engine = createJsonRpcEngine({\n store,\n hooks,\n permissionMiddleware: permissionController.createPermissionMiddleware({\n origin: snapId,\n }),\n });\n\n // Create execution service.\n const ExecutionService = executionService ?? NodeThreadExecutionService;\n const service = new ExecutionService({\n ...executionServiceOptions,\n messenger: controllerMessenger.getRestricted({\n name: 'ExecutionService',\n allowedActions: [],\n allowedEvents: [],\n }),\n setupSnapProvider: (_snapId: string, rpcStream: Duplex) => {\n const mux = setupMultiplex(rpcStream, 'snapStream');\n const stream = mux.createStream('metamask-provider');\n const providerStream = createEngineStream({ engine });\n\n // Error function is difficult to test, so we ignore it.\n /* istanbul ignore next 2 */\n pipeline(stream, providerStream, stream, (error: unknown) => {\n if (error) {\n logError(`Provider stream failure.`, error);\n }\n });\n },\n });\n\n // Register the Snap. This sets up the Snap's permissions and subject\n // metadata.\n await registerSnap(snapId, snapFiles.manifest.result, {\n permissionController,\n subjectMetadataController,\n });\n\n // Run the Snap code in the execution service.\n await service.executeSnap({\n snapId,\n sourceCode: snapFiles.sourceCode.toString('utf8'),\n endowments: await getEndowments(permissionController, snapId),\n });\n\n return {\n snapId,\n store,\n executionService: service,\n controllerMessenger,\n runSaga,\n };\n}\n\n/**\n * Get the hooks for the simulation.\n *\n * @param options - The simulation options.\n * @param snapFiles - The Snap files.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger.\n * @returns The hooks for the simulation.\n */\nexport function getHooks(\n options: SimulationOptions,\n snapFiles: FetchedSnapFiles,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n): MiddlewareHooks {\n return {\n getMnemonic: async () =>\n Promise.resolve(mnemonicPhraseToBytes(options.secretRecoveryPhrase)),\n getSnapFile: async (path: string, encoding: AuxiliaryFileEncoding) =>\n await getSnapFile(snapFiles.auxiliaryFiles, path, encoding),\n getIsLocked: () => false,\n createInterface: async (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:createInterface',\n snapId,\n ...args,\n ),\n updateInterface: async (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterface',\n snapId,\n ...args,\n ),\n getInterfaceState: (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n ...args,\n ).state,\n resolveInterface: async (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:resolveInterface',\n snapId,\n ...args,\n ),\n };\n}\n\n/**\n * Register mocked action handlers.\n *\n * @param controllerMessenger - The controller messenger.\n * @param runSaga - The run saga function.\n */\nexport function registerActions(\n controllerMessenger: RootControllerMessenger,\n runSaga: RunSagaFunction,\n) {\n controllerMessenger.registerActionHandler(\n 'PhishingController:maybeUpdateState',\n async () => Promise.resolve(),\n );\n\n controllerMessenger.registerActionHandler(\n 'PhishingController:testOrigin',\n () => ({ result: false, type: PhishingDetectorResultType.All }),\n );\n\n controllerMessenger.registerActionHandler(\n 'ApprovalController:hasRequest',\n (opts) => {\n /**\n * Get the current interface from the store.\n *\n * @yields Selects the current interface from the store.\n * @returns The current interface.\n */\n function* getCurrentInterfaceSaga(): SagaIterator {\n const currentInterface: Interface = yield select(getCurrentInterface);\n return currentInterface;\n }\n\n const currentInterface: Interface | undefined = runSaga(\n getCurrentInterfaceSaga,\n ).result();\n return (\n currentInterface?.type === DIALOG_APPROVAL_TYPES.default &&\n currentInterface?.id === opts?.id\n );\n },\n );\n\n controllerMessenger.registerActionHandler(\n 'ApprovalController:acceptRequest',\n async (_id: string, value: unknown) => {\n await runSaga(resolveWithSaga, value).toPromise();\n\n return { value };\n },\n );\n}\n"]}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./notifications.cjs"), exports);
|
|
18
|
-
__exportStar(require("./state.cjs"), exports);
|
|
19
|
-
__exportStar(require("./store.cjs"), exports);
|
|
20
|
-
__exportStar(require("./ui.cjs"), exports);
|
|
21
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../../src/internals/simulation/store/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAgC;AAChC,8CAAwB;AACxB,8CAAwB;AACxB,2CAAqB","sourcesContent":["export * from './notifications';\nexport * from './state';\nexport * from './store';\nexport * from './ui';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../../src/internals/simulation/store/index.ts"],"names":[],"mappings":"AAAA,oCAAgC;AAChC,4BAAwB;AACxB,4BAAwB;AACxB,yBAAqB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../../src/internals/simulation/store/index.ts"],"names":[],"mappings":"AAAA,oCAAgC;AAChC,4BAAwB;AACxB,4BAAwB;AACxB,yBAAqB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../src/internals/simulation/store/index.ts"],"names":[],"mappings":"AAAA,oCAAgC;AAChC,4BAAwB;AACxB,4BAAwB;AACxB,yBAAqB","sourcesContent":["export * from './notifications';\nexport * from './state';\nexport * from './store';\nexport * from './ui';\n"]}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.getJsonRpcMock = exports.getJsonRpcMocks = exports.removeJsonRpcMock = exports.addJsonRpcMock = exports.mocksSlice = void 0;
|
|
5
|
-
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
-
/**
|
|
7
|
-
* The initial notifications state.
|
|
8
|
-
*/
|
|
9
|
-
const INITIAL_STATE = {
|
|
10
|
-
jsonRpc: {},
|
|
11
|
-
};
|
|
12
|
-
exports.mocksSlice = (0, toolkit_1.createSlice)({
|
|
13
|
-
name: 'mocks',
|
|
14
|
-
initialState: INITIAL_STATE,
|
|
15
|
-
reducers: {
|
|
16
|
-
addJsonRpcMock: (state, action) => {
|
|
17
|
-
// @ts-expect-error - TS2589: Type instantiation is excessively deep and
|
|
18
|
-
// possibly infinite.
|
|
19
|
-
state.jsonRpc[action.payload.method] = action.payload.result;
|
|
20
|
-
},
|
|
21
|
-
removeJsonRpcMock: (state, action) => {
|
|
22
|
-
delete state.jsonRpc[action.payload];
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
_a = exports.mocksSlice.actions, exports.addJsonRpcMock = _a.addJsonRpcMock, exports.removeJsonRpcMock = _a.removeJsonRpcMock;
|
|
27
|
-
/**
|
|
28
|
-
* Get the JSON-RPC mocks from the state.
|
|
29
|
-
*
|
|
30
|
-
* @param state - The application state.
|
|
31
|
-
* @returns The JSON-RPC mocks.
|
|
32
|
-
*/
|
|
33
|
-
const getJsonRpcMocks = (state) => state.mocks.jsonRpc;
|
|
34
|
-
exports.getJsonRpcMocks = getJsonRpcMocks;
|
|
35
|
-
/**
|
|
36
|
-
* Get the JSON-RPC mock for a given method from the state.
|
|
37
|
-
*/
|
|
38
|
-
exports.getJsonRpcMock = (0, toolkit_1.createSelector)(exports.getJsonRpcMocks, (_, method) => method, (jsonRpcMocks, method) => jsonRpcMocks[method]);
|
|
39
|
-
//# sourceMappingURL=mocks.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mocks.cjs","sourceRoot":"","sources":["../../../../src/internals/simulation/store/mocks.ts"],"names":[],"mappings":";;;;AAEA,8CAA+D;AAa/D;;GAEG;AACH,MAAM,aAAa,GAAe;IAChC,OAAO,EAAE,EAAE;CACZ,CAAC;AAEW,QAAA,UAAU,GAAG,IAAA,qBAAW,EAAC;IACpC,IAAI,EAAE,OAAO;IACb,YAAY,EAAE,aAAa;IAC3B,QAAQ,EAAE;QACR,cAAc,EAAE,CAAC,KAAK,EAAE,MAAkC,EAAE,EAAE;YAC5D,wEAAwE;YACxE,qBAAqB;YACrB,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;QAC/D,CAAC;QACD,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAA6B,EAAE,EAAE;YAC1D,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;KACF;CACF,CAAC,CAAC;AAEU,KAAwC,kBAAU,CAAC,OAAO,EAAxD,sBAAc,sBAAE,yBAAiB,wBAAwB;AAExE;;;;;GAKG;AACI,MAAM,eAAe,GAAG,CAAC,KAAuB,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;AAAnE,QAAA,eAAe,mBAAoD;AAEhF;;GAEG;AACU,QAAA,cAAc,GAAG,IAAA,wBAAc,EAC1C,uBAAe,EACf,CAAC,CAAU,EAAE,MAAc,EAAE,EAAE,CAAC,MAAM,EACtC,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAC/C,CAAC","sourcesContent":["import type { Json } from '@metamask/utils';\nimport type { PayloadAction } from '@reduxjs/toolkit';\nimport { createSelector, createSlice } from '@reduxjs/toolkit';\n\nimport type { ApplicationState } from './store';\n\nexport type JsonRpcMock = {\n method: string;\n result: Json;\n};\n\nexport type MocksState = {\n jsonRpc: Record<string, Json>;\n};\n\n/**\n * The initial notifications state.\n */\nconst INITIAL_STATE: MocksState = {\n jsonRpc: {},\n};\n\nexport const mocksSlice = createSlice({\n name: 'mocks',\n initialState: INITIAL_STATE,\n reducers: {\n addJsonRpcMock: (state, action: PayloadAction<JsonRpcMock>) => {\n // @ts-expect-error - TS2589: Type instantiation is excessively deep and\n // possibly infinite.\n state.jsonRpc[action.payload.method] = action.payload.result;\n },\n removeJsonRpcMock: (state, action: PayloadAction<string>) => {\n delete state.jsonRpc[action.payload];\n },\n },\n});\n\nexport const { addJsonRpcMock, removeJsonRpcMock } = mocksSlice.actions;\n\n/**\n * Get the JSON-RPC mocks from the state.\n *\n * @param state - The application state.\n * @returns The JSON-RPC mocks.\n */\nexport const getJsonRpcMocks = (state: ApplicationState) => state.mocks.jsonRpc;\n\n/**\n * Get the JSON-RPC mock for a given method from the state.\n */\nexport const getJsonRpcMock = createSelector(\n getJsonRpcMocks,\n (_: unknown, method: string) => method,\n (jsonRpcMocks, method) => jsonRpcMocks[method],\n);\n"]}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { Json } from "@metamask/utils";
|
|
2
|
-
import type { PayloadAction } from "@reduxjs/toolkit";
|
|
3
|
-
import type { ApplicationState } from "./store.cjs";
|
|
4
|
-
export type JsonRpcMock = {
|
|
5
|
-
method: string;
|
|
6
|
-
result: Json;
|
|
7
|
-
};
|
|
8
|
-
export type MocksState = {
|
|
9
|
-
jsonRpc: Record<string, Json>;
|
|
10
|
-
};
|
|
11
|
-
export declare const mocksSlice: import("@reduxjs/toolkit").Slice<MocksState, {
|
|
12
|
-
addJsonRpcMock: (state: import("immer/dist/internal.js").WritableDraft<MocksState>, action: PayloadAction<JsonRpcMock>) => void;
|
|
13
|
-
removeJsonRpcMock: (state: import("immer/dist/internal.js").WritableDraft<MocksState>, action: PayloadAction<string>) => void;
|
|
14
|
-
}, "mocks">;
|
|
15
|
-
export declare const addJsonRpcMock: import("@reduxjs/toolkit").ActionCreatorWithPayload<JsonRpcMock, "mocks/addJsonRpcMock">, removeJsonRpcMock: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "mocks/removeJsonRpcMock">;
|
|
16
|
-
/**
|
|
17
|
-
* Get the JSON-RPC mocks from the state.
|
|
18
|
-
*
|
|
19
|
-
* @param state - The application state.
|
|
20
|
-
* @returns The JSON-RPC mocks.
|
|
21
|
-
*/
|
|
22
|
-
export declare const getJsonRpcMocks: (state: ApplicationState) => Record<string, Json>;
|
|
23
|
-
/**
|
|
24
|
-
* Get the JSON-RPC mock for a given method from the state.
|
|
25
|
-
*/
|
|
26
|
-
export declare const getJsonRpcMock: ((state: {
|
|
27
|
-
mocks: MocksState;
|
|
28
|
-
notifications: import("./notifications.cjs").NotificationsState;
|
|
29
|
-
state: import("./state.cjs").State;
|
|
30
|
-
ui: import("./ui.cjs").UiState;
|
|
31
|
-
}, method: string) => Json) & import("reselect").OutputSelectorFields<(args_0: Record<string, Json>, args_1: string) => Json, {
|
|
32
|
-
clearCache: () => void;
|
|
33
|
-
}> & {
|
|
34
|
-
clearCache: () => void;
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=mocks.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mocks.d.cts","sourceRoot":"","sources":["../../../../src/internals/simulation/store/mocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB;AAGtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAgB;AAEhD,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,IAAI,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;CAC/B,CAAC;AASF,eAAO,MAAM,UAAU;gGAIa,cAAc,WAAW,CAAC;mGAKvB,cAAc,MAAM,CAAC;WAI1D,CAAC;AAEH,eAAO,MAAQ,cAAc,4FAAE,iBAAiB,wFAAuB,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,eAAe,UAAW,gBAAgB,yBAAwB,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;CAI1B,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { Json } from "@metamask/utils";
|
|
2
|
-
import type { PayloadAction } from "@reduxjs/toolkit";
|
|
3
|
-
import type { ApplicationState } from "./store.mjs";
|
|
4
|
-
export type JsonRpcMock = {
|
|
5
|
-
method: string;
|
|
6
|
-
result: Json;
|
|
7
|
-
};
|
|
8
|
-
export type MocksState = {
|
|
9
|
-
jsonRpc: Record<string, Json>;
|
|
10
|
-
};
|
|
11
|
-
export declare const mocksSlice: import("@reduxjs/toolkit").Slice<MocksState, {
|
|
12
|
-
addJsonRpcMock: (state: import("immer/dist/internal.js").WritableDraft<MocksState>, action: PayloadAction<JsonRpcMock>) => void;
|
|
13
|
-
removeJsonRpcMock: (state: import("immer/dist/internal.js").WritableDraft<MocksState>, action: PayloadAction<string>) => void;
|
|
14
|
-
}, "mocks">;
|
|
15
|
-
export declare const addJsonRpcMock: import("@reduxjs/toolkit").ActionCreatorWithPayload<JsonRpcMock, "mocks/addJsonRpcMock">, removeJsonRpcMock: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "mocks/removeJsonRpcMock">;
|
|
16
|
-
/**
|
|
17
|
-
* Get the JSON-RPC mocks from the state.
|
|
18
|
-
*
|
|
19
|
-
* @param state - The application state.
|
|
20
|
-
* @returns The JSON-RPC mocks.
|
|
21
|
-
*/
|
|
22
|
-
export declare const getJsonRpcMocks: (state: ApplicationState) => Record<string, Json>;
|
|
23
|
-
/**
|
|
24
|
-
* Get the JSON-RPC mock for a given method from the state.
|
|
25
|
-
*/
|
|
26
|
-
export declare const getJsonRpcMock: ((state: {
|
|
27
|
-
mocks: MocksState;
|
|
28
|
-
notifications: import("./notifications.mjs").NotificationsState;
|
|
29
|
-
state: import("./state.mjs").State;
|
|
30
|
-
ui: import("./ui.mjs").UiState;
|
|
31
|
-
}, method: string) => Json) & import("reselect").OutputSelectorFields<(args_0: Record<string, Json>, args_1: string) => Json, {
|
|
32
|
-
clearCache: () => void;
|
|
33
|
-
}> & {
|
|
34
|
-
clearCache: () => void;
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=mocks.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mocks.d.mts","sourceRoot":"","sources":["../../../../src/internals/simulation/store/mocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB;AAGtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAgB;AAEhD,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,IAAI,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;CAC/B,CAAC;AASF,eAAO,MAAM,UAAU;gGAIa,cAAc,WAAW,CAAC;mGAKvB,cAAc,MAAM,CAAC;WAI1D,CAAC;AAEH,eAAO,MAAQ,cAAc,4FAAE,iBAAiB,wFAAuB,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,eAAe,UAAW,gBAAgB,yBAAwB,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;CAI1B,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import $reduxjstoolkit from "@reduxjs/toolkit";
|
|
2
|
-
const { createSelector, createSlice } = $reduxjstoolkit;
|
|
3
|
-
/**
|
|
4
|
-
* The initial notifications state.
|
|
5
|
-
*/
|
|
6
|
-
const INITIAL_STATE = {
|
|
7
|
-
jsonRpc: {},
|
|
8
|
-
};
|
|
9
|
-
export const mocksSlice = createSlice({
|
|
10
|
-
name: 'mocks',
|
|
11
|
-
initialState: INITIAL_STATE,
|
|
12
|
-
reducers: {
|
|
13
|
-
addJsonRpcMock: (state, action) => {
|
|
14
|
-
// @ts-expect-error - TS2589: Type instantiation is excessively deep and
|
|
15
|
-
// possibly infinite.
|
|
16
|
-
state.jsonRpc[action.payload.method] = action.payload.result;
|
|
17
|
-
},
|
|
18
|
-
removeJsonRpcMock: (state, action) => {
|
|
19
|
-
delete state.jsonRpc[action.payload];
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
export const { addJsonRpcMock, removeJsonRpcMock } = mocksSlice.actions;
|
|
24
|
-
/**
|
|
25
|
-
* Get the JSON-RPC mocks from the state.
|
|
26
|
-
*
|
|
27
|
-
* @param state - The application state.
|
|
28
|
-
* @returns The JSON-RPC mocks.
|
|
29
|
-
*/
|
|
30
|
-
export const getJsonRpcMocks = (state) => state.mocks.jsonRpc;
|
|
31
|
-
/**
|
|
32
|
-
* Get the JSON-RPC mock for a given method from the state.
|
|
33
|
-
*/
|
|
34
|
-
export const getJsonRpcMock = createSelector(getJsonRpcMocks, (_, method) => method, (jsonRpcMocks, method) => jsonRpcMocks[method]);
|
|
35
|
-
//# sourceMappingURL=mocks.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mocks.mjs","sourceRoot":"","sources":["../../../../src/internals/simulation/store/mocks.ts"],"names":[],"mappings":";;AAeA;;GAEG;AACH,MAAM,aAAa,GAAe;IAChC,OAAO,EAAE,EAAE;CACZ,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,CAAC;IACpC,IAAI,EAAE,OAAO;IACb,YAAY,EAAE,aAAa;IAC3B,QAAQ,EAAE;QACR,cAAc,EAAE,CAAC,KAAK,EAAE,MAAkC,EAAE,EAAE;YAC5D,wEAAwE;YACxE,qBAAqB;YACrB,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;QAC/D,CAAC;QACD,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAA6B,EAAE,EAAE;YAC1D,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;KACF;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,iBAAiB,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC;AAExE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAuB,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;AAEhF;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,cAAc,CAC1C,eAAe,EACf,CAAC,CAAU,EAAE,MAAc,EAAE,EAAE,CAAC,MAAM,EACtC,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAC/C,CAAC","sourcesContent":["import type { Json } from '@metamask/utils';\nimport type { PayloadAction } from '@reduxjs/toolkit';\nimport { createSelector, createSlice } from '@reduxjs/toolkit';\n\nimport type { ApplicationState } from './store';\n\nexport type JsonRpcMock = {\n method: string;\n result: Json;\n};\n\nexport type MocksState = {\n jsonRpc: Record<string, Json>;\n};\n\n/**\n * The initial notifications state.\n */\nconst INITIAL_STATE: MocksState = {\n jsonRpc: {},\n};\n\nexport const mocksSlice = createSlice({\n name: 'mocks',\n initialState: INITIAL_STATE,\n reducers: {\n addJsonRpcMock: (state, action: PayloadAction<JsonRpcMock>) => {\n // @ts-expect-error - TS2589: Type instantiation is excessively deep and\n // possibly infinite.\n state.jsonRpc[action.payload.method] = action.payload.result;\n },\n removeJsonRpcMock: (state, action: PayloadAction<string>) => {\n delete state.jsonRpc[action.payload];\n },\n },\n});\n\nexport const { addJsonRpcMock, removeJsonRpcMock } = mocksSlice.actions;\n\n/**\n * Get the JSON-RPC mocks from the state.\n *\n * @param state - The application state.\n * @returns The JSON-RPC mocks.\n */\nexport const getJsonRpcMocks = (state: ApplicationState) => state.mocks.jsonRpc;\n\n/**\n * Get the JSON-RPC mock for a given method from the state.\n */\nexport const getJsonRpcMock = createSelector(\n getJsonRpcMocks,\n (_: unknown, method: string) => method,\n (jsonRpcMocks, method) => jsonRpcMocks[method],\n);\n"]}
|