@metamask/snaps-simulation 3.4.2 → 3.5.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +19 -1
  2. package/dist/controllers.cjs +39 -32
  3. package/dist/controllers.cjs.map +1 -1
  4. package/dist/controllers.d.cts +3 -3
  5. package/dist/controllers.d.cts.map +1 -1
  6. package/dist/controllers.d.mts +3 -3
  7. package/dist/controllers.d.mts.map +1 -1
  8. package/dist/controllers.mjs +39 -32
  9. package/dist/controllers.mjs.map +1 -1
  10. package/dist/helpers.cjs +28 -9
  11. package/dist/helpers.cjs.map +1 -1
  12. package/dist/helpers.d.cts +61 -0
  13. package/dist/helpers.d.cts.map +1 -1
  14. package/dist/helpers.d.mts +61 -0
  15. package/dist/helpers.d.mts.map +1 -1
  16. package/dist/helpers.mjs +29 -9
  17. package/dist/helpers.mjs.map +1 -1
  18. package/dist/middleware/mock.cjs +16 -7
  19. package/dist/middleware/mock.cjs.map +1 -1
  20. package/dist/middleware/mock.d.cts +1 -1
  21. package/dist/middleware/mock.d.cts.map +1 -1
  22. package/dist/middleware/mock.d.mts +1 -1
  23. package/dist/middleware/mock.d.mts.map +1 -1
  24. package/dist/middleware/mock.mjs +17 -8
  25. package/dist/middleware/mock.mjs.map +1 -1
  26. package/dist/simulation.cjs +7 -6
  27. package/dist/simulation.cjs.map +1 -1
  28. package/dist/simulation.d.cts +3 -3
  29. package/dist/simulation.d.cts.map +1 -1
  30. package/dist/simulation.d.mts +3 -3
  31. package/dist/simulation.d.mts.map +1 -1
  32. package/dist/simulation.mjs +7 -6
  33. package/dist/simulation.mjs.map +1 -1
  34. package/dist/store/mocks.cjs +5 -8
  35. package/dist/store/mocks.cjs.map +1 -1
  36. package/dist/store/mocks.d.cts +6 -19
  37. package/dist/store/mocks.d.cts.map +1 -1
  38. package/dist/store/mocks.d.mts +6 -19
  39. package/dist/store/mocks.d.mts.map +1 -1
  40. package/dist/store/mocks.mjs +5 -8
  41. package/dist/store/mocks.mjs.map +1 -1
  42. package/dist/store/store.cjs +1 -1
  43. package/dist/store/store.cjs.map +1 -1
  44. package/dist/store/store.d.cts.map +1 -1
  45. package/dist/store/store.d.mts.map +1 -1
  46. package/dist/store/store.mjs +1 -1
  47. package/dist/store/store.mjs.map +1 -1
  48. package/dist/structs.d.cts +3 -3
  49. package/dist/structs.d.mts +3 -3
  50. package/dist/types.cjs.map +1 -1
  51. package/dist/types.d.cts +70 -2
  52. package/dist/types.d.cts.map +1 -1
  53. package/dist/types.d.mts +70 -2
  54. package/dist/types.d.mts.map +1 -1
  55. package/dist/types.mjs.map +1 -1
  56. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"simulation.d.cts","sourceRoot":"","sources":["../src/simulation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EAChB,kCAAkC;AACnC,OAAO,EAAE,SAAS,EAAE,kCAAkC;AAEtD,OAAO,KAAK,EAAE,sBAAsB,EAAE,2BAA2B;AAEjE,OAAO,KAAK,EAAE,wBAAwB,EAAE,oCAAoC;AAQ5E,OAAO,KAAK,EACV,gBAAgB,EAChB,qBAAqB,EACrB,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,MAAM,EACN,aAAa,EACb,YAAY,EACZ,eAAe,EACf,YAAY,EACb,4BAA4B;AAC7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,8BAA8B;AAEpE,OAAO,KAAK,EAAiB,IAAI,EAAE,wBAAwB;AAM3D,OAAO,KAAK,EAAE,uBAAuB,EAAE,0BAAsB;AAG7D,OAAO,KAAK,EAAE,WAAW,EAAE,sBAAkB;AAkB7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,sBAAkB;AAE1E,OAAO,KAAK,EAAa,eAAe,EAAE,KAAK,EAAE,0BAAgB;AAIjE;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,C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AmB,EAAE,uBAAuB,EAC5C,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,MAAM,QAoGf"}
@@ -1,6 +1,6 @@
1
- import type { ActionConstraint, EventConstraint } from "@metamask/base-controller";
2
- import { Messenger } from "@metamask/base-controller";
3
1
  import type { CryptographicFunctions } from "@metamask/key-tree";
2
+ import type { ActionConstraint, EventConstraint, NamespacedName } from "@metamask/messenger";
3
+ import { Messenger } from "@metamask/messenger";
4
4
  import type { AbstractExecutionService } from "@metamask/snaps-controllers";
5
5
  import type { TrackEventParams, AuxiliaryFileEncoding, Component, InterfaceState, InterfaceContext, SnapId, EntropySource, TraceRequest, EndTraceRequest, TraceContext } from "@metamask/snaps-sdk";
6
6
  import type { FetchedSnapFiles, Snap } from "@metamask/snaps-utils";
@@ -40,7 +40,7 @@ export type InstalledSnap = {
40
40
  snapId: SnapId;
41
41
  store: Store;
42
42
  executionService: InstanceType<typeof AbstractExecutionService>;
43
- controllerMessenger: Messenger<ActionConstraint, EventConstraint>;
43
+ controllerMessenger: Messenger<NamespacedName, ActionConstraint, EventConstraint>;
44
44
  runSaga: RunSagaFunction;
45
45
  };
46
46
  export type RestrictedMiddlewareHooks = {
@@ -1 +1 @@
1
- {"version":3,"file":"simulation.d.mts","sourceRoot":"","sources":["../src/simulation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EAChB,kCAAkC;AACnC,OAAO,EAAE,SAAS,EAAE,kCAAkC;AAEtD,OAAO,KAAK,EAAE,sBAAsB,EAAE,2BAA2B;AAEjE,OAAO,KAAK,EAAE,wBAAwB,EAAE,oCAAoC;AAQ5E,OAAO,KAAK,EACV,gBAAgB,EAChB,qBAAqB,EACrB,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,MAAM,EACN,aAAa,EACb,YAAY,EACZ,eAAe,EACf,YAAY,EACb,4BAA4B;AAC7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,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AAG,WAAW,CAAC,CAkGtC;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,iBAAiB,GACzB,yBAAyB,CAU3B;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,gBAAgB,EAC3B,mBAAmB,EAAE,uBAAuB,EAC5C,OAAO,EAAE,eAAe,GACvB,wBAAwB,CAoD1B;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,mBAAmB,EAAE,uBAAuB,EAC5C,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,MAAM,QAoGf"}
@@ -1,5 +1,5 @@
1
- import { Messenger } from "@metamask/base-controller";
2
1
  import { createEngineStream } from "@metamask/json-rpc-middleware-stream";
2
+ import { MOCK_ANY_NAMESPACE, Messenger } from "@metamask/messenger";
3
3
  import { PhishingDetectorResultType } from "@metamask/phishing-controller";
4
4
  import { detectSnapLocation, fetchSnap, NodeThreadExecutionService, setupMultiplex } from "@metamask/snaps-controllers/node";
5
5
  import { DIALOG_APPROVAL_TYPES } from "@metamask/snaps-rpc-methods";
@@ -41,7 +41,9 @@ export async function installSnap(snapId, { executionService, executionServiceOp
41
41
  const snapFiles = await fetchSnap(snapId, location);
42
42
  // Create Redux store.
43
43
  const { store, runSaga } = createStore(options);
44
- const controllerMessenger = new Messenger();
44
+ const controllerMessenger = new Messenger({
45
+ namespace: MOCK_ANY_NAMESPACE,
46
+ });
45
47
  registerActions(controllerMessenger, runSaga, options, snapId);
46
48
  // Set up controllers and JSON-RPC stack.
47
49
  const restrictedHooks = getRestrictedHooks(options);
@@ -64,10 +66,9 @@ export async function installSnap(snapId, { executionService, executionServiceOp
64
66
  const ExecutionService = executionService ?? NodeThreadExecutionService;
65
67
  const service = new ExecutionService({
66
68
  ...executionServiceOptions,
67
- messenger: controllerMessenger.getRestricted({
68
- name: 'ExecutionService',
69
- allowedActions: [],
70
- allowedEvents: [],
69
+ messenger: new Messenger({
70
+ namespace: 'ExecutionService',
71
+ parent: controllerMessenger,
71
72
  }),
72
73
  setupSnapProvider: (_snapId, rpcStream) => {
73
74
  const mux = setupMultiplex(rpcStream, 'snapStream');
@@ -1 +1 @@
1
- {"version":3,"file":"simulation.mjs","sourceRoot":"","sources":["../src/simulation.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,kCAAkC;AACtD,OAAO,EAAE,kBAAkB,EAAE,6CAA6C;AAE1E,OAAO,EAAE,0BAA0B,EAAE,sCAAsC;AAE3E,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,0BAA0B,EAC1B,cAAc,EACf,yCAAyC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,oCAAoC;AAcpE,OAAO,EAAE,QAAQ,EAAE,8BAA8B;AAGjD,OAAO,EAAE,QAAQ,EAAE,wBAAwB;AAE3C,OAAO,EAAE,MAAM,EAAE,2BAA2B;AAG5C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,0BAAsB;AAC7D,OAAO,EAAE,WAAW,EAAE,oBAAgB;AAEtC,OAAO,EAAE,UAAU,EAAE,sBAAkB;AACvC,OAAO,EAAE,eAAe,EAAE,wBAAoB;AAC9C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,4BAAkB;AACxD,OAAO,EACL,8CAA8C,EAC9C,4CAA4C,EAC5C,+CAA+C,EAC/C,kCAAkC,EAClC,4BAA4B,EAC5B,wBAAwB,EACxB,2BAA2B,EAC3B,2BAA2B,EAC3B,yBAAyB,EACzB,2BAA2B,EAC5B,kCAAwB;AACzB,OAAO,EAAE,gCAAgC,EAAE,8CAA0C;AACrF,OAAO,EAAE,mBAAmB,EAAE,+BAAqB;AAEnD,OAAO,EAAE,UAAU,EAAE,sBAAkB;AAEvC,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,0BAAgB;AAC3D,OAAO,EAAE,wBAAwB,EAAE,4BAAwB;AA+P3D;;;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Ac,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 { Messenger } from '@metamask/base-controller';\nimport { createEngineStream } from '@metamask/json-rpc-middleware-stream';\nimport type { CryptographicFunctions } 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 TrackEventParams,\n AuxiliaryFileEncoding,\n Component,\n InterfaceState,\n InterfaceContext,\n SnapId,\n EntropySource,\n TraceRequest,\n EndTraceRequest,\n TraceContext,\n} from '@metamask/snaps-sdk';\nimport type { FetchedSnapFiles, Snap } from '@metamask/snaps-utils';\nimport { logError } from '@metamask/snaps-utils';\nimport type { CaipAssetType, 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 type { SnapHelpers } from './helpers';\nimport { getHelpers } from './helpers';\nimport { resolveWithSaga } from './interface';\nimport { asyncResolve, getEndowments } from './methods';\nimport {\n getPermittedClearSnapStateMethodImplementation,\n getPermittedGetSnapStateMethodImplementation,\n getPermittedUpdateSnapStateMethodImplementation,\n getGetEntropySourcesImplementation,\n getGetMnemonicImplementation,\n getGetSnapImplementation,\n getTrackEventImplementation,\n getTrackErrorImplementation,\n getEndTraceImplementation,\n getStartTraceImplementation,\n} from './methods/hooks';\nimport { getGetMnemonicSeedImplementation } from './methods/hooks/get-mnemonic-seed';\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';\nimport { addSnapMetadataToAccount } from './utils/account';\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 (\n ...args: any[]\n ) => InstanceType<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: Messenger<ActionConstraint, EventConstraint>;\n runSaga: RunSagaFunction;\n};\n\nexport type RestrictedMiddlewareHooks = {\n /**\n * A hook that returns the user's secret recovery phrase.\n *\n * @param source - The entropy source to get the mnemonic from.\n * @returns The user's secret recovery phrase.\n */\n getMnemonic: (source?: string | undefined) => Promise<Uint8Array>;\n\n /**\n * A hook that returns the seed derived from the user's secret recovery phrase.\n *\n * @param source - The entropy source to get the seed from.\n * @returns The seed.\n */\n getMnemonicSeed: (source?: string | undefined) => Promise<Uint8Array>;\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\n /**\n * Get the cryptographic functions to use for the client. This may return an\n * empty object to fall back to the default cryptographic functions.\n *\n * @returns The cryptographic functions to use for the client.\n */\n getClientCryptography: () => CryptographicFunctions;\n\n /**\n * A hook that returns metadata about a given Snap.\n *\n * @param snapId - The ID of a Snap.\n * @returns The metadata for the given Snap.\n */\n getSnap: (snapId: string) => Snap;\n};\n\nexport type PermittedMiddlewareHooks = {\n /**\n * A hook that gets whether the requesting origin has a given permission.\n *\n * @param permissionName - The name of the permission to check.\n * @returns Whether the origin has the permission.\n */\n hasPermission: (permissionName: string) => boolean;\n\n /**\n * A hook that returns the entropy sources available to the Snap.\n *\n * @returns The entropy sources available to the Snap.\n */\n getEntropySources: () => EntropySource[];\n\n /**\n * A hook that returns a promise that resolves once the extension is unlocked.\n *\n * @param shouldShowUnlockRequest - Whether to show the unlock request.\n * @returns A promise that resolves once the extension is unlocked.\n */\n getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;\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\n /**\n * A hook that returns whether the client is active or not.\n *\n * @returns A boolean flag signaling whether the client is opened.\n */\n getIsActive: () => boolean;\n\n /**\n * A hook that returns the Snap's auxiliary file for the given path. This hook\n * is bound to the Snap ID.\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 gets the state of the Snap. This hook is bound to the Snap ID.\n *\n * @param encrypted - Whether to get the encrypted or unencrypted state.\n * @returns The current state of the Snap.\n */\n getSnapState: (encrypted: boolean) => Promise<Record<string, Json>>;\n\n /**\n * A hook that updates the state of the Snap. This hook is bound to the Snap\n * ID.\n *\n * @param newState - The new state.\n * @param encrypted - Whether to update the encrypted or unencrypted state.\n */\n updateSnapState: (\n newState: Record<string, Json>,\n encrypted: boolean,\n ) => Promise<void>;\n\n /**\n * A hook that clears the state of the Snap. This hook is bound to the Snap\n * ID.\n *\n * @param encrypted - Whether to clear the encrypted or unencrypted state.\n */\n clearSnapState: (encrypted: boolean) => Promise<void>;\n\n /**\n * A hook that creates an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param content - The content of the interface.\n * @param context - The context of the interface.\n * @returns The ID of the created interface.\n */\n createInterface: (content: Component, context?: InterfaceContext) => string;\n\n /**\n * A hook that updates an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param id - The ID of the interface to update.\n * @param content - The content of the interface.\n */\n updateInterface: (id: string, content: Component) => void;\n\n /**\n * A hook that gets the state of an interface for the Snap. This hook is bound\n * to the Snap ID.\n *\n * @param id - The ID of the interface to get.\n * @returns The state of the interface.\n */\n getInterfaceState: (id: string) => InterfaceState;\n\n /**\n * A hook that gets the context of an interface for the Snap. This hook is\n * bound to the Snap ID.\n *\n * @param id - The ID of the interface to get.\n * @returns The context of the interface.\n */\n getInterfaceContext: (id: string) => InterfaceContext | null;\n\n /**\n * A hook that resolves an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param id - The ID of the interface to resolve.\n * @param value - The value to resolve the interface with.\n */\n resolveInterface: (id: string, value: Json) => Promise<void>;\n\n /**\n * A hook that gets the Snap's metadata.\n *\n * @param snapId - The ID of the Snap to get.\n * @returns The Snap's metadata.\n */\n getSnap(snapId: string): Snap;\n\n /**\n * A hook that tracks an error.\n *\n * @param error - The error object containing error details and properties.\n */\n trackError(error: Error): void;\n\n /**\n * A hook that tracks an event.\n *\n * @param event - The event object containing event details and properties.\n */\n trackEvent(event: TrackEventParams['event']): void;\n\n /**\n * A hook that starts a performance trace.\n *\n * @param request - The trace request object containing trace details.\n */\n startTrace(request: TraceRequest): TraceContext;\n\n /**\n * A hook that ends a performance trace.\n *\n * @param request - The trace request object containing trace details.\n * @returns The trace data.\n */\n endTrace(request: EndTraceRequest): 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 installSnap<\n Service extends new (\n ...args: any[]\n ) => InstanceType<typeof AbstractExecutionService>,\n>(\n snapId: SnapId,\n {\n executionService,\n executionServiceOptions,\n options: rawOptions = {},\n }: Partial<InstallSnapOptions<Service>> = {},\n): Promise<InstalledSnap & SnapHelpers> {\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 Messenger<any, any>();\n\n registerActions(controllerMessenger, runSaga, options, snapId);\n\n // Set up controllers and JSON-RPC stack.\n const restrictedHooks = getRestrictedHooks(options);\n const permittedHooks = getPermittedHooks(\n snapId,\n snapFiles,\n controllerMessenger,\n runSaga,\n );\n\n const { subjectMetadataController, permissionController } = getControllers({\n controllerMessenger,\n hooks: restrictedHooks,\n runSaga,\n options,\n });\n\n const engine = createJsonRpcEngine({\n store,\n restrictedHooks,\n permittedHooks,\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) => {\n if (error && !error.message?.match('Premature close')) {\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 const helpers = getHelpers({\n snapId,\n store,\n controllerMessenger,\n runSaga,\n executionService: service,\n options,\n });\n\n return {\n snapId,\n store,\n executionService: service,\n controllerMessenger,\n runSaga,\n ...helpers,\n };\n}\n\n/**\n * Get the hooks for the simulation.\n *\n * @param options - The simulation options.\n * @returns The hooks for the simulation.\n */\nexport function getRestrictedHooks(\n options: SimulationOptions,\n): RestrictedMiddlewareHooks {\n return {\n getMnemonic: getGetMnemonicImplementation(options.secretRecoveryPhrase),\n getMnemonicSeed: getGetMnemonicSeedImplementation(\n options.secretRecoveryPhrase,\n ),\n getIsLocked: () => false,\n getClientCryptography: () => ({}),\n getSnap: getGetSnapImplementation(true),\n };\n}\n\n/**\n * Get the permitted hooks for the simulation.\n *\n * @param snapId - The ID of the Snap.\n * @param snapFiles - The fetched Snap files.\n * @param controllerMessenger - The controller messenger.\n * @param runSaga - The run saga function.\n * @returns The permitted hooks for the simulation.\n */\nexport function getPermittedHooks(\n snapId: SnapId,\n snapFiles: FetchedSnapFiles,\n controllerMessenger: RootControllerMessenger,\n runSaga: RunSagaFunction,\n): PermittedMiddlewareHooks {\n return {\n hasPermission: () => true,\n getUnlockPromise: asyncResolve(),\n getIsLocked: () => false,\n getIsActive: () => true,\n\n getSnapFile: async (path: string, encoding: AuxiliaryFileEncoding) =>\n await getSnapFile(snapFiles.auxiliaryFiles, path, encoding),\n\n createInterface: (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:createInterface',\n snapId,\n ...args,\n ),\n updateInterface: (...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 getInterfaceContext: (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n ...args,\n ).context,\n resolveInterface: async (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:resolveInterface',\n snapId,\n ...args,\n ),\n\n getEntropySources: getGetEntropySourcesImplementation(),\n getSnapState: getPermittedGetSnapStateMethodImplementation(runSaga),\n updateSnapState: getPermittedUpdateSnapStateMethodImplementation(runSaga),\n clearSnapState: getPermittedClearSnapStateMethodImplementation(runSaga),\n\n getSnap: getGetSnapImplementation(true),\n trackError: getTrackErrorImplementation(runSaga),\n trackEvent: getTrackEventImplementation(runSaga),\n startTrace: getStartTraceImplementation(runSaga),\n endTrace: getEndTraceImplementation(runSaga),\n };\n}\n\n/**\n * Register mocked action handlers.\n *\n * @param controllerMessenger - The controller messenger.\n * @param runSaga - The run saga function.\n * @param options - The simulation options.\n * @param snapId - The ID of the Snap.\n */\nexport function registerActions(\n controllerMessenger: RootControllerMessenger,\n runSaga: RunSagaFunction,\n options: SimulationOptions,\n snapId: SnapId,\n) {\n controllerMessenger.registerActionHandler(\n 'PhishingController:testOrigin',\n () => ({ result: false, type: PhishingDetectorResultType.All }),\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:getAccountByAddress',\n // @ts-expect-error - This is a partial account with only the necessary\n // data used by the interface controller.\n (address) => {\n const matchingAccount = options.accounts.find(\n (account) => address === account.address,\n );\n\n if (!matchingAccount) {\n return undefined;\n }\n\n return addSnapMetadataToAccount(matchingAccount, snapId);\n },\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:getSelectedMultichainAccount',\n // @ts-expect-error - This is a partial account with only the necessary\n // data used by the interface controller.\n () => {\n const selectedAccount = options.accounts.find(\n (account) => account.selected,\n );\n\n if (!selectedAccount) {\n return undefined;\n }\n\n return addSnapMetadataToAccount(selectedAccount, snapId);\n },\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:listMultichainAccounts',\n\n () =>\n // @ts-expect-error - These are partial accounts with only the necessary\n // data used by the interface controller.\n options.accounts.map((account) =>\n addSnapMetadataToAccount(account, snapId),\n ),\n );\n\n controllerMessenger.registerActionHandler(\n 'MultichainAssetsController:getState',\n () => ({\n // @ts-expect-error - These are partial assets with only the\n // necessary data used by the interface controller.\n assetsMetadata: options.assets,\n accountsAssets: options.accounts.reduce<Record<string, CaipAssetType[]>>(\n (acc, account) => {\n acc[account.id] = account.assets ?? [];\n return acc;\n },\n {},\n ),\n }),\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
+ {"version":3,"file":"simulation.mjs","sourceRoot":"","sources":["../src/simulation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,6CAA6C;AAQ1E,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,4BAA4B;AACpE,OAAO,EAAE,0BAA0B,EAAE,sCAAsC;AAE3E,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,0BAA0B,EAC1B,cAAc,EACf,yCAAyC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,oCAAoC;AAcpE,OAAO,EAAE,QAAQ,EAAE,8BAA8B;AAGjD,OAAO,EAAE,QAAQ,EAAE,wBAAwB;AAE3C,OAAO,EAAE,MAAM,EAAE,2BAA2B;AAG5C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,0BAAsB;AAC7D,OAAO,EAAE,WAAW,EAAE,oBAAgB;AAEtC,OAAO,EAAE,UAAU,EAAE,sBAAkB;AACvC,OAAO,EAAE,eAAe,EAAE,wBAAoB;AAC9C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,4BAAkB;AACxD,OAAO,EACL,8CAA8C,EAC9C,4CAA4C,EAC5C,+CAA+C,EAC/C,kCAAkC,EAClC,4BAA4B,EAC5B,wBAAwB,EACxB,2BAA2B,EAC3B,2BAA2B,EAC3B,yBAAyB,EACzB,2BAA2B,EAC5B,kCAAwB;AACzB,OAAO,EAAE,gCAAgC,EAAE,8CAA0C;AACrF,OAAO,EAAE,mBAAmB,EAAE,+BAAqB;AAEnD,OAAO,EAAE,UAAU,EAAE,sBAAkB;AAEvC,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,0BAAgB;AAC3D,OAAO,EAAE,wBAAwB,EAAE,4BAAw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;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 { createEngineStream } from '@metamask/json-rpc-middleware-stream';\nimport type { CryptographicFunctions } from '@metamask/key-tree';\nimport type {\n ActionConstraint,\n EventConstraint,\n MockAnyNamespace,\n NamespacedName,\n} from '@metamask/messenger';\nimport { MOCK_ANY_NAMESPACE, Messenger } from '@metamask/messenger';\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 TrackEventParams,\n AuxiliaryFileEncoding,\n Component,\n InterfaceState,\n InterfaceContext,\n SnapId,\n EntropySource,\n TraceRequest,\n EndTraceRequest,\n TraceContext,\n} from '@metamask/snaps-sdk';\nimport type { FetchedSnapFiles, Snap } from '@metamask/snaps-utils';\nimport { logError } from '@metamask/snaps-utils';\nimport type { CaipAssetType, 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 type { SnapHelpers } from './helpers';\nimport { getHelpers } from './helpers';\nimport { resolveWithSaga } from './interface';\nimport { asyncResolve, getEndowments } from './methods';\nimport {\n getPermittedClearSnapStateMethodImplementation,\n getPermittedGetSnapStateMethodImplementation,\n getPermittedUpdateSnapStateMethodImplementation,\n getGetEntropySourcesImplementation,\n getGetMnemonicImplementation,\n getGetSnapImplementation,\n getTrackEventImplementation,\n getTrackErrorImplementation,\n getEndTraceImplementation,\n getStartTraceImplementation,\n} from './methods/hooks';\nimport { getGetMnemonicSeedImplementation } from './methods/hooks/get-mnemonic-seed';\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';\nimport { addSnapMetadataToAccount } from './utils/account';\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 (\n ...args: any[]\n ) => InstanceType<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: Messenger<\n NamespacedName,\n ActionConstraint,\n EventConstraint\n >;\n runSaga: RunSagaFunction;\n};\n\nexport type RestrictedMiddlewareHooks = {\n /**\n * A hook that returns the user's secret recovery phrase.\n *\n * @param source - The entropy source to get the mnemonic from.\n * @returns The user's secret recovery phrase.\n */\n getMnemonic: (source?: string | undefined) => Promise<Uint8Array>;\n\n /**\n * A hook that returns the seed derived from the user's secret recovery phrase.\n *\n * @param source - The entropy source to get the seed from.\n * @returns The seed.\n */\n getMnemonicSeed: (source?: string | undefined) => Promise<Uint8Array>;\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\n /**\n * Get the cryptographic functions to use for the client. This may return an\n * empty object to fall back to the default cryptographic functions.\n *\n * @returns The cryptographic functions to use for the client.\n */\n getClientCryptography: () => CryptographicFunctions;\n\n /**\n * A hook that returns metadata about a given Snap.\n *\n * @param snapId - The ID of a Snap.\n * @returns The metadata for the given Snap.\n */\n getSnap: (snapId: string) => Snap;\n};\n\nexport type PermittedMiddlewareHooks = {\n /**\n * A hook that gets whether the requesting origin has a given permission.\n *\n * @param permissionName - The name of the permission to check.\n * @returns Whether the origin has the permission.\n */\n hasPermission: (permissionName: string) => boolean;\n\n /**\n * A hook that returns the entropy sources available to the Snap.\n *\n * @returns The entropy sources available to the Snap.\n */\n getEntropySources: () => EntropySource[];\n\n /**\n * A hook that returns a promise that resolves once the extension is unlocked.\n *\n * @param shouldShowUnlockRequest - Whether to show the unlock request.\n * @returns A promise that resolves once the extension is unlocked.\n */\n getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;\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\n /**\n * A hook that returns whether the client is active or not.\n *\n * @returns A boolean flag signaling whether the client is opened.\n */\n getIsActive: () => boolean;\n\n /**\n * A hook that returns the Snap's auxiliary file for the given path. This hook\n * is bound to the Snap ID.\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 gets the state of the Snap. This hook is bound to the Snap ID.\n *\n * @param encrypted - Whether to get the encrypted or unencrypted state.\n * @returns The current state of the Snap.\n */\n getSnapState: (encrypted: boolean) => Promise<Record<string, Json>>;\n\n /**\n * A hook that updates the state of the Snap. This hook is bound to the Snap\n * ID.\n *\n * @param newState - The new state.\n * @param encrypted - Whether to update the encrypted or unencrypted state.\n */\n updateSnapState: (\n newState: Record<string, Json>,\n encrypted: boolean,\n ) => Promise<void>;\n\n /**\n * A hook that clears the state of the Snap. This hook is bound to the Snap\n * ID.\n *\n * @param encrypted - Whether to clear the encrypted or unencrypted state.\n */\n clearSnapState: (encrypted: boolean) => Promise<void>;\n\n /**\n * A hook that creates an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param content - The content of the interface.\n * @param context - The context of the interface.\n * @returns The ID of the created interface.\n */\n createInterface: (content: Component, context?: InterfaceContext) => string;\n\n /**\n * A hook that updates an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param id - The ID of the interface to update.\n * @param content - The content of the interface.\n */\n updateInterface: (id: string, content: Component) => void;\n\n /**\n * A hook that gets the state of an interface for the Snap. This hook is bound\n * to the Snap ID.\n *\n * @param id - The ID of the interface to get.\n * @returns The state of the interface.\n */\n getInterfaceState: (id: string) => InterfaceState;\n\n /**\n * A hook that gets the context of an interface for the Snap. This hook is\n * bound to the Snap ID.\n *\n * @param id - The ID of the interface to get.\n * @returns The context of the interface.\n */\n getInterfaceContext: (id: string) => InterfaceContext | null;\n\n /**\n * A hook that resolves an interface for the Snap. This hook is bound to the\n * Snap ID.\n *\n * @param id - The ID of the interface to resolve.\n * @param value - The value to resolve the interface with.\n */\n resolveInterface: (id: string, value: Json) => Promise<void>;\n\n /**\n * A hook that gets the Snap's metadata.\n *\n * @param snapId - The ID of the Snap to get.\n * @returns The Snap's metadata.\n */\n getSnap(snapId: string): Snap;\n\n /**\n * A hook that tracks an error.\n *\n * @param error - The error object containing error details and properties.\n */\n trackError(error: Error): void;\n\n /**\n * A hook that tracks an event.\n *\n * @param event - The event object containing event details and properties.\n */\n trackEvent(event: TrackEventParams['event']): void;\n\n /**\n * A hook that starts a performance trace.\n *\n * @param request - The trace request object containing trace details.\n */\n startTrace(request: TraceRequest): TraceContext;\n\n /**\n * A hook that ends a performance trace.\n *\n * @param request - The trace request object containing trace details.\n * @returns The trace data.\n */\n endTrace(request: EndTraceRequest): 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 installSnap<\n Service extends new (\n ...args: any[]\n ) => InstanceType<typeof AbstractExecutionService>,\n>(\n snapId: SnapId,\n {\n executionService,\n executionServiceOptions,\n options: rawOptions = {},\n }: Partial<InstallSnapOptions<Service>> = {},\n): Promise<InstalledSnap & SnapHelpers> {\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 Messenger<MockAnyNamespace, any, any>({\n namespace: MOCK_ANY_NAMESPACE,\n });\n\n registerActions(controllerMessenger, runSaga, options, snapId);\n\n // Set up controllers and JSON-RPC stack.\n const restrictedHooks = getRestrictedHooks(options);\n const permittedHooks = getPermittedHooks(\n snapId,\n snapFiles,\n controllerMessenger,\n runSaga,\n );\n\n const { subjectMetadataController, permissionController } = getControllers({\n controllerMessenger,\n hooks: restrictedHooks,\n runSaga,\n options,\n });\n\n const engine = createJsonRpcEngine({\n store,\n restrictedHooks,\n permittedHooks,\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: new Messenger({\n namespace: 'ExecutionService',\n parent: controllerMessenger,\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) => {\n if (error && !error.message?.match('Premature close')) {\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 const helpers = getHelpers({\n snapId,\n store,\n controllerMessenger,\n runSaga,\n executionService: service,\n options,\n });\n\n return {\n snapId,\n store,\n executionService: service,\n controllerMessenger,\n runSaga,\n ...helpers,\n };\n}\n\n/**\n * Get the hooks for the simulation.\n *\n * @param options - The simulation options.\n * @returns The hooks for the simulation.\n */\nexport function getRestrictedHooks(\n options: SimulationOptions,\n): RestrictedMiddlewareHooks {\n return {\n getMnemonic: getGetMnemonicImplementation(options.secretRecoveryPhrase),\n getMnemonicSeed: getGetMnemonicSeedImplementation(\n options.secretRecoveryPhrase,\n ),\n getIsLocked: () => false,\n getClientCryptography: () => ({}),\n getSnap: getGetSnapImplementation(true),\n };\n}\n\n/**\n * Get the permitted hooks for the simulation.\n *\n * @param snapId - The ID of the Snap.\n * @param snapFiles - The fetched Snap files.\n * @param controllerMessenger - The controller messenger.\n * @param runSaga - The run saga function.\n * @returns The permitted hooks for the simulation.\n */\nexport function getPermittedHooks(\n snapId: SnapId,\n snapFiles: FetchedSnapFiles,\n controllerMessenger: RootControllerMessenger,\n runSaga: RunSagaFunction,\n): PermittedMiddlewareHooks {\n return {\n hasPermission: () => true,\n getUnlockPromise: asyncResolve(),\n getIsLocked: () => false,\n getIsActive: () => true,\n\n getSnapFile: async (path: string, encoding: AuxiliaryFileEncoding) =>\n await getSnapFile(snapFiles.auxiliaryFiles, path, encoding),\n\n createInterface: (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:createInterface',\n snapId,\n ...args,\n ),\n updateInterface: (...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 getInterfaceContext: (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n ...args,\n ).context,\n resolveInterface: async (...args) =>\n controllerMessenger.call(\n 'SnapInterfaceController:resolveInterface',\n snapId,\n ...args,\n ),\n\n getEntropySources: getGetEntropySourcesImplementation(),\n getSnapState: getPermittedGetSnapStateMethodImplementation(runSaga),\n updateSnapState: getPermittedUpdateSnapStateMethodImplementation(runSaga),\n clearSnapState: getPermittedClearSnapStateMethodImplementation(runSaga),\n\n getSnap: getGetSnapImplementation(true),\n trackError: getTrackErrorImplementation(runSaga),\n trackEvent: getTrackEventImplementation(runSaga),\n startTrace: getStartTraceImplementation(runSaga),\n endTrace: getEndTraceImplementation(runSaga),\n };\n}\n\n/**\n * Register mocked action handlers.\n *\n * @param controllerMessenger - The controller messenger.\n * @param runSaga - The run saga function.\n * @param options - The simulation options.\n * @param snapId - The ID of the Snap.\n */\nexport function registerActions(\n controllerMessenger: RootControllerMessenger,\n runSaga: RunSagaFunction,\n options: SimulationOptions,\n snapId: SnapId,\n) {\n controllerMessenger.registerActionHandler(\n 'PhishingController:testOrigin',\n () => ({ result: false, type: PhishingDetectorResultType.All }),\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:getAccountByAddress',\n // @ts-expect-error - This is a partial account with only the necessary\n // data used by the interface controller.\n (address) => {\n const matchingAccount = options.accounts.find(\n (account) => address === account.address,\n );\n\n if (!matchingAccount) {\n return undefined;\n }\n\n return addSnapMetadataToAccount(matchingAccount, snapId);\n },\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:getSelectedMultichainAccount',\n // @ts-expect-error - This is a partial account with only the necessary\n // data used by the interface controller.\n () => {\n const selectedAccount = options.accounts.find(\n (account) => account.selected,\n );\n\n if (!selectedAccount) {\n return undefined;\n }\n\n return addSnapMetadataToAccount(selectedAccount, snapId);\n },\n );\n\n controllerMessenger.registerActionHandler(\n 'AccountsController:listMultichainAccounts',\n\n () =>\n // @ts-expect-error - These are partial accounts with only the necessary\n // data used by the interface controller.\n options.accounts.map((account) =>\n addSnapMetadataToAccount(account, snapId),\n ),\n );\n\n controllerMessenger.registerActionHandler(\n 'MultichainAssetsController:getState',\n () => ({\n // @ts-expect-error - These are partial assets with only the\n // necessary data used by the interface controller.\n assetsMetadata: options.assets,\n accountsAssets: options.accounts.reduce<Record<string, CaipAssetType[]>>(\n (acc, account) => {\n acc[account.id] = account.assets ?? [];\n return acc;\n },\n {},\n ),\n }),\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,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getJsonRpcMock = exports.getJsonRpcMocks = exports.removeJsonRpcMock = exports.addJsonRpcMock = exports.mocksSlice = void 0;
4
+ exports.getJsonRpcMocks = exports.removeJsonRpcMock = exports.addJsonRpcMock = exports.mocksSlice = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  /**
7
7
  * The initial notifications state.
@@ -14,9 +14,10 @@ exports.mocksSlice = (0, toolkit_1.createSlice)({
14
14
  initialState: INITIAL_STATE,
15
15
  reducers: {
16
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;
17
+ state.jsonRpc[action.payload.id] = {
18
+ implementation: action.payload.implementation,
19
+ once: action.payload.once,
20
+ };
20
21
  },
21
22
  removeJsonRpcMock: (state, action) => {
22
23
  delete state.jsonRpc[action.payload];
@@ -32,8 +33,4 @@ _a = exports.mocksSlice.actions, exports.addJsonRpcMock = _a.addJsonRpcMock, exp
32
33
  */
33
34
  const getJsonRpcMocks = (state) => state.mocks.jsonRpc;
34
35
  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
36
  //# sourceMappingURL=mocks.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"mocks.cjs","sourceRoot":"","sources":["../../src/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
+ {"version":3,"file":"mocks.cjs","sourceRoot":"","sources":["../../src/store/mocks.ts"],"names":[],"mappings":";;;;AACA,8CAA+C;AAe/C;;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,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG;gBACjC,cAAc,EAAE,MAAM,CAAC,OAAO,CAAC,cAAc;gBAC7C,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI;aAC1B,CAAC;QACJ,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","sourcesContent":["import type { PayloadAction } from '@reduxjs/toolkit';\nimport { createSlice } from '@reduxjs/toolkit';\n\nimport type { ApplicationState } from './store';\nimport type { JsonRpcMockImplementation } from '../types';\n\nexport type JsonRpcMock = {\n id: string;\n implementation: JsonRpcMockImplementation;\n once?: boolean;\n};\n\nexport type MocksState = {\n jsonRpc: Record<string, Omit<JsonRpcMock, 'id'>>;\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 state.jsonRpc[action.payload.id] = {\n implementation: action.payload.implementation,\n once: action.payload.once,\n };\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"]}
@@ -1,12 +1,13 @@
1
- import type { Json } from "@metamask/utils";
2
1
  import type { PayloadAction } from "@reduxjs/toolkit";
3
2
  import type { ApplicationState } from "./store.cjs";
3
+ import type { JsonRpcMockImplementation } from "../types.cjs";
4
4
  export type JsonRpcMock = {
5
- method: string;
6
- result: Json;
5
+ id: string;
6
+ implementation: JsonRpcMockImplementation;
7
+ once?: boolean;
7
8
  };
8
9
  export type MocksState = {
9
- jsonRpc: Record<string, Json>;
10
+ jsonRpc: Record<string, Omit<JsonRpcMock, 'id'>>;
10
11
  };
11
12
  export declare const mocksSlice: import("@reduxjs/toolkit").Slice<MocksState, {
12
13
  addJsonRpcMock: (state: import("immer/dist/internal.js").WritableDraft<MocksState>, action: PayloadAction<JsonRpcMock>) => void;
@@ -19,19 +20,5 @@ export declare const addJsonRpcMock: import("@reduxjs/toolkit").ActionCreatorWit
19
20
  * @param state - The application state.
20
21
  * @returns The JSON-RPC mocks.
21
22
  */
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
- trackables: import("./trackables.cjs").TrackablesState;
31
- ui: import("./ui.cjs").UiState;
32
- }, method: string) => Json) & import("reselect").OutputSelectorFields<(args_0: Record<string, Json>, args_1: string) => Json, {
33
- clearCache: () => void;
34
- }> & {
35
- clearCache: () => void;
36
- };
23
+ export declare const getJsonRpcMocks: (state: ApplicationState) => Record<string, Omit<JsonRpcMock, "id">>;
37
24
  //# sourceMappingURL=mocks.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mocks.d.cts","sourceRoot":"","sources":["../../src/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
+ {"version":3,"file":"mocks.d.cts","sourceRoot":"","sources":["../../src/store/mocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB;AAGtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAgB;AAChD,OAAO,KAAK,EAAE,yBAAyB,EAAE,qBAAiB;AAE1D,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,yBAAyB,CAAC;IAC1C,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC;CAClD,CAAC;AASF,eAAO,MAAM,UAAU;gGAIa,cAAc,WAAW,CAAC;mGAMvB,cAAc,MAAM,CAAC;WAI1D,CAAC;AAEH,eAAO,MAAQ,cAAc,4FAAE,iBAAiB,wFAAuB,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,eAAe,UAAW,gBAAgB,4CAAwB,CAAC"}
@@ -1,12 +1,13 @@
1
- import type { Json } from "@metamask/utils";
2
1
  import type { PayloadAction } from "@reduxjs/toolkit";
3
2
  import type { ApplicationState } from "./store.mjs";
3
+ import type { JsonRpcMockImplementation } from "../types.mjs";
4
4
  export type JsonRpcMock = {
5
- method: string;
6
- result: Json;
5
+ id: string;
6
+ implementation: JsonRpcMockImplementation;
7
+ once?: boolean;
7
8
  };
8
9
  export type MocksState = {
9
- jsonRpc: Record<string, Json>;
10
+ jsonRpc: Record<string, Omit<JsonRpcMock, 'id'>>;
10
11
  };
11
12
  export declare const mocksSlice: import("@reduxjs/toolkit").Slice<MocksState, {
12
13
  addJsonRpcMock: (state: import("immer/dist/internal.js").WritableDraft<MocksState>, action: PayloadAction<JsonRpcMock>) => void;
@@ -19,19 +20,5 @@ export declare const addJsonRpcMock: import("@reduxjs/toolkit").ActionCreatorWit
19
20
  * @param state - The application state.
20
21
  * @returns The JSON-RPC mocks.
21
22
  */
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
- trackables: import("./trackables.mjs").TrackablesState;
31
- ui: import("./ui.mjs").UiState;
32
- }, method: string) => Json) & import("reselect").OutputSelectorFields<(args_0: Record<string, Json>, args_1: string) => Json, {
33
- clearCache: () => void;
34
- }> & {
35
- clearCache: () => void;
36
- };
23
+ export declare const getJsonRpcMocks: (state: ApplicationState) => Record<string, Omit<JsonRpcMock, "id">>;
37
24
  //# sourceMappingURL=mocks.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mocks.d.mts","sourceRoot":"","sources":["../../src/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
+ {"version":3,"file":"mocks.d.mts","sourceRoot":"","sources":["../../src/store/mocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB;AAGtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAgB;AAChD,OAAO,KAAK,EAAE,yBAAyB,EAAE,qBAAiB;AAE1D,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,yBAAyB,CAAC;IAC1C,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC;CAClD,CAAC;AASF,eAAO,MAAM,UAAU;gGAIa,cAAc,WAAW,CAAC;mGAMvB,cAAc,MAAM,CAAC;WAI1D,CAAC;AAEH,eAAO,MAAQ,cAAc,4FAAE,iBAAiB,wFAAuB,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,eAAe,UAAW,gBAAgB,4CAAwB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import $reduxjstoolkit from "@reduxjs/toolkit";
2
- const { createSelector, createSlice } = $reduxjstoolkit;
2
+ const { createSlice } = $reduxjstoolkit;
3
3
  /**
4
4
  * The initial notifications state.
5
5
  */
@@ -11,9 +11,10 @@ export const mocksSlice = createSlice({
11
11
  initialState: INITIAL_STATE,
12
12
  reducers: {
13
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;
14
+ state.jsonRpc[action.payload.id] = {
15
+ implementation: action.payload.implementation,
16
+ once: action.payload.once,
17
+ };
17
18
  },
18
19
  removeJsonRpcMock: (state, action) => {
19
20
  delete state.jsonRpc[action.payload];
@@ -28,8 +29,4 @@ export const { addJsonRpcMock, removeJsonRpcMock } = mocksSlice.actions;
28
29
  * @returns The JSON-RPC mocks.
29
30
  */
30
31
  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
32
  //# sourceMappingURL=mocks.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"mocks.mjs","sourceRoot":"","sources":["../../src/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"]}
1
+ {"version":3,"file":"mocks.mjs","sourceRoot":"","sources":["../../src/store/mocks.ts"],"names":[],"mappings":";;AAgBA;;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,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG;gBACjC,cAAc,EAAE,MAAM,CAAC,OAAO,CAAC,cAAc;gBAC7C,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI;aAC1B,CAAC;QACJ,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","sourcesContent":["import type { PayloadAction } from '@reduxjs/toolkit';\nimport { createSlice } from '@reduxjs/toolkit';\n\nimport type { ApplicationState } from './store';\nimport type { JsonRpcMockImplementation } from '../types';\n\nexport type JsonRpcMock = {\n id: string;\n implementation: JsonRpcMockImplementation;\n once?: boolean;\n};\n\nexport type MocksState = {\n jsonRpc: Record<string, Omit<JsonRpcMock, 'id'>>;\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 state.jsonRpc[action.payload.id] = {\n implementation: action.payload.implementation,\n once: action.payload.once,\n };\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"]}
@@ -29,7 +29,7 @@ function createStore({ state, unencryptedState }) {
29
29
  trackables: trackables_1.trackablesSlice.reducer,
30
30
  ui: ui_1.uiSlice.reducer,
31
31
  },
32
- middleware: (getDefaultMiddleware) => getDefaultMiddleware({ thunk: false }).concat(sagaMiddleware),
32
+ middleware: (getDefaultMiddleware) => getDefaultMiddleware({ thunk: false, serializableCheck: false }).concat(sagaMiddleware),
33
33
  });
34
34
  // Set initial state for the Snap.
35
35
  if (state) {
@@ -1 +1 @@
1
- {"version":3,"file":"store.cjs","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAkD;AAClD,4DAA8C;AAE9C,uCAAqC;AACrC,uDAAqD;AACrD,uCAA+C;AAC/C,iDAA+C;AAC/C,iCAA+B;AAG/B;;;;;;;GAOG;AACH,SAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAqB;IACxE,MAAM,cAAc,GAAG,IAAA,oBAAoB,GAAE,CAAC;IAC9C,MAAM,KAAK,GAAG,IAAA,wBAAc,EAAC;QAC3B,OAAO,EAAE;YACP,KAAK,EAAE,kBAAU,CAAC,OAAO;YACzB,aAAa,EAAE,kCAAkB,CAAC,OAAO;YACzC,KAAK,EAAE,kBAAU,CAAC,OAAO;YACzB,UAAU,EAAE,4BAAe,CAAC,OAAO;YACnC,EAAE,EAAE,YAAO,CAAC,OAAO;SACpB;QACD,UAAU,EAAE,CAAC,oBAAoB,EAAE,EAAE,CACnC,oBAAoB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC;KAChE,CAAC,CAAC;IAEH,kCAAkC;IAClC,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,CAAC,QAAQ,CACZ,IAAA,gBAAQ,EAAC;YACP,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;YAC5B,SAAS,EAAE,IAAI;SAChB,CAAC,CACH,CAAC;IACJ,CAAC;IAED,IAAI,gBAAgB,EAAE,CAAC;QACrB,KAAK,CAAC,QAAQ,CACZ,IAAA,gBAAQ,EAAC;YACP,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC;YACvC,SAAS,EAAE,KAAK;SACjB,CAAC,CACH,CAAC;IACJ,CAAC;IAED,OAAO;QACL,KAAK;QACL,OAAO,EAAE,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC;KACjD,CAAC;AACJ,CAAC;AArCD,kCAqCC","sourcesContent":["import { configureStore } from '@reduxjs/toolkit';\nimport createSagaMiddleware from 'redux-saga';\n\nimport { mocksSlice } from './mocks';\nimport { notificationsSlice } from './notifications';\nimport { setState, stateSlice } from './state';\nimport { trackablesSlice } from './trackables';\nimport { uiSlice } from './ui';\nimport type { SimulationOptions } from '../options';\n\n/**\n * Create a Redux store.\n *\n * @param options - The simulation options.\n * @param options.state - The initial state for the Snap.\n * @param options.unencryptedState - The initial unencrypted state for the Snap.\n * @returns A Redux store with the default state.\n */\nexport function createStore({ state, unencryptedState }: SimulationOptions) {\n const sagaMiddleware = createSagaMiddleware();\n const store = configureStore({\n reducer: {\n mocks: mocksSlice.reducer,\n notifications: notificationsSlice.reducer,\n state: stateSlice.reducer,\n trackables: trackablesSlice.reducer,\n ui: uiSlice.reducer,\n },\n middleware: (getDefaultMiddleware) =>\n getDefaultMiddleware({ thunk: false }).concat(sagaMiddleware),\n });\n\n // Set initial state for the Snap.\n if (state) {\n store.dispatch(\n setState({\n state: JSON.stringify(state),\n encrypted: true,\n }),\n );\n }\n\n if (unencryptedState) {\n store.dispatch(\n setState({\n state: JSON.stringify(unencryptedState),\n encrypted: false,\n }),\n );\n }\n\n return {\n store,\n runSaga: sagaMiddleware.run.bind(sagaMiddleware),\n };\n}\n\nexport type Store = ReturnType<typeof createStore>['store'];\nexport type ApplicationState = ReturnType<Store['getState']>;\nexport type RunSagaFunction = ReturnType<typeof createStore>['runSaga'];\n"]}
1
+ {"version":3,"file":"store.cjs","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAkD;AAClD,4DAA8C;AAE9C,uCAAqC;AACrC,uDAAqD;AACrD,uCAA+C;AAC/C,iDAA+C;AAC/C,iCAA+B;AAG/B;;;;;;;GAOG;AACH,SAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAqB;IACxE,MAAM,cAAc,GAAG,IAAA,oBAAoB,GAAE,CAAC;IAC9C,MAAM,KAAK,GAAG,IAAA,wBAAc,EAAC;QAC3B,OAAO,EAAE;YACP,KAAK,EAAE,kBAAU,CAAC,OAAO;YACzB,aAAa,EAAE,kCAAkB,CAAC,OAAO;YACzC,KAAK,EAAE,kBAAU,CAAC,OAAO;YACzB,UAAU,EAAE,4BAAe,CAAC,OAAO;YACnC,EAAE,EAAE,YAAO,CAAC,OAAO;SACpB;QACD,UAAU,EAAE,CAAC,oBAAoB,EAAE,EAAE,CACnC,oBAAoB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CACrE,cAAc,CACf;KACJ,CAAC,CAAC;IAEH,kCAAkC;IAClC,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,CAAC,QAAQ,CACZ,IAAA,gBAAQ,EAAC;YACP,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;YAC5B,SAAS,EAAE,IAAI;SAChB,CAAC,CACH,CAAC;IACJ,CAAC;IAED,IAAI,gBAAgB,EAAE,CAAC;QACrB,KAAK,CAAC,QAAQ,CACZ,IAAA,gBAAQ,EAAC;YACP,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC;YACvC,SAAS,EAAE,KAAK;SACjB,CAAC,CACH,CAAC;IACJ,CAAC;IAED,OAAO;QACL,KAAK;QACL,OAAO,EAAE,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC;KACjD,CAAC;AACJ,CAAC;AAvCD,kCAuCC","sourcesContent":["import { configureStore } from '@reduxjs/toolkit';\nimport createSagaMiddleware from 'redux-saga';\n\nimport { mocksSlice } from './mocks';\nimport { notificationsSlice } from './notifications';\nimport { setState, stateSlice } from './state';\nimport { trackablesSlice } from './trackables';\nimport { uiSlice } from './ui';\nimport type { SimulationOptions } from '../options';\n\n/**\n * Create a Redux store.\n *\n * @param options - The simulation options.\n * @param options.state - The initial state for the Snap.\n * @param options.unencryptedState - The initial unencrypted state for the Snap.\n * @returns A Redux store with the default state.\n */\nexport function createStore({ state, unencryptedState }: SimulationOptions) {\n const sagaMiddleware = createSagaMiddleware();\n const store = configureStore({\n reducer: {\n mocks: mocksSlice.reducer,\n notifications: notificationsSlice.reducer,\n state: stateSlice.reducer,\n trackables: trackablesSlice.reducer,\n ui: uiSlice.reducer,\n },\n middleware: (getDefaultMiddleware) =>\n getDefaultMiddleware({ thunk: false, serializableCheck: false }).concat(\n sagaMiddleware,\n ),\n });\n\n // Set initial state for the Snap.\n if (state) {\n store.dispatch(\n setState({\n state: JSON.stringify(state),\n encrypted: true,\n }),\n );\n }\n\n if (unencryptedState) {\n store.dispatch(\n setState({\n state: JSON.stringify(unencryptedState),\n encrypted: false,\n }),\n );\n }\n\n return {\n store,\n runSaga: sagaMiddleware.run.bind(sagaMiddleware),\n };\n}\n\nexport type Store = ReturnType<typeof createStore>['store'];\nexport type ApplicationState = ReturnType<Store['getState']>;\nexport type RunSagaFunction = ReturnType<typeof createStore>['runSaga'];\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.cts","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAmB;AAEpD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE,iBAAiB;;;;;;;;;EAqCzE;AAED,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC;AAC5D,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAC7D,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC"}
1
+ {"version":3,"file":"store.d.cts","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAmB;AAEpD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE,iBAAiB;;;;;;;;;EAuCzE;AAED,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC;AAC5D,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAC7D,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.mts","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAmB;AAEpD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE,iBAAiB;;;;;;;;;EAqCzE;AAED,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC;AAC5D,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAC7D,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC"}
1
+ {"version":3,"file":"store.d.mts","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAmB;AAEpD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE,iBAAiB;;;;;;;;;EAuCzE;AAED,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC;AAC5D,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAC7D,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC"}
@@ -24,7 +24,7 @@ export function createStore({ state, unencryptedState }) {
24
24
  trackables: trackablesSlice.reducer,
25
25
  ui: uiSlice.reducer,
26
26
  },
27
- middleware: (getDefaultMiddleware) => getDefaultMiddleware({ thunk: false }).concat(sagaMiddleware),
27
+ middleware: (getDefaultMiddleware) => getDefaultMiddleware({ thunk: false, serializableCheck: false }).concat(sagaMiddleware),
28
28
  });
29
29
  // Set initial state for the Snap.
30
30
  if (state) {
@@ -1 +1 @@
1
- {"version":3,"file":"store.mjs","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":";;AACA,OAAO,oBAAoB,mBAAmB;AAE9C,OAAO,EAAE,UAAU,EAAE,oBAAgB;AACrC,OAAO,EAAE,kB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';\n\nimport { mocksSlice } from './mocks';\nimport { notificationsSlice } from './notifications';\nimport { setState, stateSlice } from './state';\nimport { trackablesSlice } from './trackables';\nimport { uiSlice } from './ui';\nimport type { SimulationOptions } from '../options';\n\n/**\n * Create a Redux store.\n *\n * @param options - The simulation options.\n * @param options.state - The initial state for the Snap.\n * @param options.unencryptedState - The initial unencrypted state for the Snap.\n * @returns A Redux store with the default state.\n */\nexport function createStore({ state, unencryptedState }: SimulationOptions) {\n const sagaMiddleware = createSagaMiddleware();\n const store = configureStore({\n reducer: {\n mocks: mocksSlice.reducer,\n notifications: notificationsSlice.reducer,\n state: stateSlice.reducer,\n trackables: trackablesSlice.reducer,\n ui: uiSlice.reducer,\n },\n middleware: (getDefaultMiddleware) =>\n getDefaultMiddleware({ thunk: false }).concat(sagaMiddleware),\n });\n\n // Set initial state for the Snap.\n if (state) {\n store.dispatch(\n setState({\n state: JSON.stringify(state),\n encrypted: true,\n }),\n );\n }\n\n if (unencryptedState) {\n store.dispatch(\n setState({\n state: JSON.stringify(unencryptedState),\n encrypted: false,\n }),\n );\n }\n\n return {\n store,\n runSaga: sagaMiddleware.run.bind(sagaMiddleware),\n };\n}\n\nexport type Store = ReturnType<typeof createStore>['store'];\nexport type ApplicationState = ReturnType<Store['getState']>;\nexport type RunSagaFunction = ReturnType<typeof createStore>['runSaga'];\n"]}
1
+ {"version":3,"file":"store.mjs","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":";;AACA,OAAO,oBAAoB,mBAAmB;AAE9C,OAAO,EAAE,UAAU,EAAE,oBAAgB;AACrC,OAAO,EAAE,kBAAkB,EAAE,4BAAwB;AACrD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,oBAAgB;AAC/C,OAAO,EAAE,eAAe,EAAE,yBAAqB;AAC/C,OAAO,EAAE,OAAO,EAAE,iBAAa;AAG/B;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAqB;IACxE,MAAM,cAAc,GAAG,oBAAoB,EAAE,CAAC;IAC9C,MAAM,KAAK,GAAG,cAAc,CAAC;QAC3B,OAAO,EAAE;YACP,KAAK,EAAE,UAAU,CAAC,OAAO;YACzB,aAAa,EAAE,kBAAkB,CAAC,OAAO;YACzC,KAAK,EAAE,UAAU,CAAC,OAAO;YACzB,UAAU,EAAE,eAAe,CAAC,OAAO;YACnC,EAAE,EAAE,OAAO,CAAC,OAAO;SACpB;QACD,UAAU,EAAE,CAAC,oBAAoB,EAAE,EAAE,CACnC,oBAAoB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CACrE,cAAc,CACf;KACJ,CAAC,CAAC;IAEH,kCAAkC;IAClC,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,CAAC,QAAQ,CACZ,QAAQ,CAAC;YACP,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;YAC5B,SAAS,EAAE,IAAI;SAChB,CAAC,CACH,CAAC;IACJ,CAAC;IAED,IAAI,gBAAgB,EAAE,CAAC;QACrB,KAAK,CAAC,QAAQ,CACZ,QAAQ,CAAC;YACP,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC;YACvC,SAAS,EAAE,KAAK;SACjB,CAAC,CACH,CAAC;IACJ,CAAC;IAED,OAAO;QACL,KAAK;QACL,OAAO,EAAE,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC;KACjD,CAAC;AACJ,CAAC","sourcesContent":["import { configureStore } from '@reduxjs/toolkit';\nimport createSagaMiddleware from 'redux-saga';\n\nimport { mocksSlice } from './mocks';\nimport { notificationsSlice } from './notifications';\nimport { setState, stateSlice } from './state';\nimport { trackablesSlice } from './trackables';\nimport { uiSlice } from './ui';\nimport type { SimulationOptions } from '../options';\n\n/**\n * Create a Redux store.\n *\n * @param options - The simulation options.\n * @param options.state - The initial state for the Snap.\n * @param options.unencryptedState - The initial unencrypted state for the Snap.\n * @returns A Redux store with the default state.\n */\nexport function createStore({ state, unencryptedState }: SimulationOptions) {\n const sagaMiddleware = createSagaMiddleware();\n const store = configureStore({\n reducer: {\n mocks: mocksSlice.reducer,\n notifications: notificationsSlice.reducer,\n state: stateSlice.reducer,\n trackables: trackablesSlice.reducer,\n ui: uiSlice.reducer,\n },\n middleware: (getDefaultMiddleware) =>\n getDefaultMiddleware({ thunk: false, serializableCheck: false }).concat(\n sagaMiddleware,\n ),\n });\n\n // Set initial state for the Snap.\n if (state) {\n store.dispatch(\n setState({\n state: JSON.stringify(state),\n encrypted: true,\n }),\n );\n }\n\n if (unencryptedState) {\n store.dispatch(\n setState({\n state: JSON.stringify(unencryptedState),\n encrypted: false,\n }),\n );\n }\n\n return {\n store,\n runSaga: sagaMiddleware.run.bind(sagaMiddleware),\n };\n}\n\nexport type Store = ReturnType<typeof createStore>['store'];\nexport type ApplicationState = ReturnType<Store['getState']>;\nexport type RunSagaFunction = ReturnType<typeof createStore>['runSaga'];\n"]}
@@ -1,11 +1,11 @@
1
1
  import type { SnapResponse, SnapResponseWithInterface } from "./types.cjs";
2
2
  export declare const TransactionOptionsStruct: import("@metamask/superstruct").Struct<{
3
3
  data: `0x${string}`;
4
- value: `0x${string}`;
5
4
  chainId: string;
6
5
  origin: string;
7
6
  from: `0x${string}`;
8
7
  to: `0x${string}`;
8
+ value: `0x${string}`;
9
9
  gasLimit: `0x${string}`;
10
10
  maxFeePerGas: `0x${string}`;
11
11
  maxPriorityFeePerGas: `0x${string}`;
@@ -266,7 +266,6 @@ export declare const SnapResponseWithInterfaceStruct: import("@metamask/superstr
266
266
  href: string;
267
267
  } | undefined;
268
268
  }[];
269
- getInterface: Function;
270
269
  response: {
271
270
  result: import("@metamask/snaps-sdk").Json;
272
271
  } | {
@@ -288,6 +287,7 @@ export declare const SnapResponseWithInterfaceStruct: import("@metamask/superstr
288
287
  tags?: Record<string, string | number | boolean> | undefined;
289
288
  }[];
290
289
  };
290
+ getInterface: Function;
291
291
  }, {
292
292
  getInterface: import("@metamask/superstruct").Struct<Function, null>;
293
293
  id: import("@metamask/superstruct").Struct<string, null>;
@@ -431,7 +431,6 @@ export declare const SnapResponseStruct: import("@metamask/superstruct").Struct<
431
431
  href: string;
432
432
  } | undefined;
433
433
  }[];
434
- getInterface: Function;
435
434
  response: {
436
435
  result: import("@metamask/snaps-sdk").Json;
437
436
  } | {
@@ -453,6 +452,7 @@ export declare const SnapResponseStruct: import("@metamask/superstruct").Struct<
453
452
  tags?: Record<string, string | number | boolean> | undefined;
454
453
  }[];
455
454
  };
455
+ getInterface: Function;
456
456
  }, null>;
457
457
  /**
458
458
  * Ensure that the actual response contains `getInterface`.
@@ -1,11 +1,11 @@
1
1
  import type { SnapResponse, SnapResponseWithInterface } from "./types.mjs";
2
2
  export declare const TransactionOptionsStruct: import("@metamask/superstruct").Struct<{
3
3
  data: `0x${string}`;
4
- value: `0x${string}`;
5
4
  chainId: string;
6
5
  origin: string;
7
6
  from: `0x${string}`;
8
7
  to: `0x${string}`;
8
+ value: `0x${string}`;
9
9
  gasLimit: `0x${string}`;
10
10
  maxFeePerGas: `0x${string}`;
11
11
  maxPriorityFeePerGas: `0x${string}`;
@@ -266,7 +266,6 @@ export declare const SnapResponseWithInterfaceStruct: import("@metamask/superstr
266
266
  href: string;
267
267
  } | undefined;
268
268
  }[];
269
- getInterface: Function;
270
269
  response: {
271
270
  result: import("@metamask/snaps-sdk").Json;
272
271
  } | {
@@ -288,6 +287,7 @@ export declare const SnapResponseWithInterfaceStruct: import("@metamask/superstr
288
287
  tags?: Record<string, string | number | boolean> | undefined;
289
288
  }[];
290
289
  };
290
+ getInterface: Function;
291
291
  }, {
292
292
  getInterface: import("@metamask/superstruct").Struct<Function, null>;
293
293
  id: import("@metamask/superstruct").Struct<string, null>;
@@ -431,7 +431,6 @@ export declare const SnapResponseStruct: import("@metamask/superstruct").Struct<
431
431
  href: string;
432
432
  } | undefined;
433
433
  }[];
434
- getInterface: Function;
435
434
  response: {
436
435
  result: import("@metamask/snaps-sdk").Json;
437
436
  } | {
@@ -453,6 +452,7 @@ export declare const SnapResponseStruct: import("@metamask/superstruct").Struct<
453
452
  tags?: Record<string, string | number | boolean> | undefined;
454
453
  }[];
455
454
  };
455
+ getInterface: Function;
456
456
  }, null>;
457
457
  /**
458
458
  * Ensure that the actual response contains `getInterface`.