@metamask/snaps-simulation 4.1.2 → 4.1.4

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 (72) hide show
  1. package/CHANGELOG.md +21 -2
  2. package/dist/controllers.cjs.map +1 -1
  3. package/dist/controllers.d.cts +2 -2
  4. package/dist/controllers.d.cts.map +1 -1
  5. package/dist/controllers.d.mts +2 -2
  6. package/dist/controllers.d.mts.map +1 -1
  7. package/dist/controllers.mjs.map +1 -1
  8. package/dist/methods/hooks/index.cjs +0 -2
  9. package/dist/methods/hooks/index.cjs.map +1 -1
  10. package/dist/methods/hooks/index.d.cts +0 -2
  11. package/dist/methods/hooks/index.d.cts.map +1 -1
  12. package/dist/methods/hooks/index.d.mts +0 -2
  13. package/dist/methods/hooks/index.d.mts.map +1 -1
  14. package/dist/methods/hooks/index.mjs +0 -2
  15. package/dist/methods/hooks/index.mjs.map +1 -1
  16. package/dist/methods/hooks/state.cjs +1 -1
  17. package/dist/methods/hooks/state.cjs.map +1 -1
  18. package/dist/methods/hooks/state.d.cts +1 -1
  19. package/dist/methods/hooks/state.d.cts.map +1 -1
  20. package/dist/methods/hooks/state.d.mts +1 -1
  21. package/dist/methods/hooks/state.d.mts.map +1 -1
  22. package/dist/methods/hooks/state.mjs +1 -1
  23. package/dist/methods/hooks/state.mjs.map +1 -1
  24. package/dist/methods/specifications.cjs +5 -14
  25. package/dist/methods/specifications.cjs.map +1 -1
  26. package/dist/methods/specifications.d.cts +7 -17
  27. package/dist/methods/specifications.d.cts.map +1 -1
  28. package/dist/methods/specifications.d.mts +7 -17
  29. package/dist/methods/specifications.d.mts.map +1 -1
  30. package/dist/methods/specifications.mjs +6 -15
  31. package/dist/methods/specifications.mjs.map +1 -1
  32. package/dist/middleware/engine.cjs +8 -4
  33. package/dist/middleware/engine.cjs.map +1 -1
  34. package/dist/middleware/engine.d.cts +7 -6
  35. package/dist/middleware/engine.d.cts.map +1 -1
  36. package/dist/middleware/engine.d.mts +7 -6
  37. package/dist/middleware/engine.d.mts.map +1 -1
  38. package/dist/middleware/engine.mjs +9 -5
  39. package/dist/middleware/engine.mjs.map +1 -1
  40. package/dist/simulation.cjs +82 -27
  41. package/dist/simulation.cjs.map +1 -1
  42. package/dist/simulation.d.cts +18 -114
  43. package/dist/simulation.d.cts.map +1 -1
  44. package/dist/simulation.d.mts +18 -114
  45. package/dist/simulation.d.mts.map +1 -1
  46. package/dist/simulation.mjs +83 -28
  47. package/dist/simulation.mjs.map +1 -1
  48. package/package.json +12 -12
  49. package/dist/methods/hooks/get-entropy-sources.cjs +0 -30
  50. package/dist/methods/hooks/get-entropy-sources.cjs.map +0 -1
  51. package/dist/methods/hooks/get-entropy-sources.d.cts +0 -14
  52. package/dist/methods/hooks/get-entropy-sources.d.cts.map +0 -1
  53. package/dist/methods/hooks/get-entropy-sources.d.mts +0 -14
  54. package/dist/methods/hooks/get-entropy-sources.d.mts.map +0 -1
  55. package/dist/methods/hooks/get-entropy-sources.mjs +0 -26
  56. package/dist/methods/hooks/get-entropy-sources.mjs.map +0 -1
  57. package/dist/methods/hooks/get-mnemonic-seed.cjs +0 -29
  58. package/dist/methods/hooks/get-mnemonic-seed.cjs.map +0 -1
  59. package/dist/methods/hooks/get-mnemonic-seed.d.cts +0 -9
  60. package/dist/methods/hooks/get-mnemonic-seed.d.cts.map +0 -1
  61. package/dist/methods/hooks/get-mnemonic-seed.d.mts +0 -9
  62. package/dist/methods/hooks/get-mnemonic-seed.d.mts.map +0 -1
  63. package/dist/methods/hooks/get-mnemonic-seed.mjs +0 -25
  64. package/dist/methods/hooks/get-mnemonic-seed.mjs.map +0 -1
  65. package/dist/methods/hooks/interface.cjs +0 -34
  66. package/dist/methods/hooks/interface.cjs.map +0 -1
  67. package/dist/methods/hooks/interface.d.cts +0 -24
  68. package/dist/methods/hooks/interface.d.cts.map +0 -1
  69. package/dist/methods/hooks/interface.d.mts +0 -24
  70. package/dist/methods/hooks/interface.d.mts.map +0 -1
  71. package/dist/methods/hooks/interface.mjs +0 -28
  72. package/dist/methods/hooks/interface.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"simulation.cjs","sourceRoot":"","sources":["../src/simulation.ts"],"names":[],"mappings":";;;AAAA,qFAA0E;AAQ1E,mDAAoE;AACpE,2EAIyC;AAEzC,2DAK0C;AAC1C,mEAAoE;AAcpE,uDAAiD;AAGjD,qDAA2C;AAE3C,gDAA4C;AAG5C,mDAA6D;AAC7D,uCAAsC;AAEtC,2CAAuC;AACvC,+CAA8C;AAC9C,iDAAwD;AACxD,qDAYyB;AACzB,6EAAqF;AACrF,uDAAmD;AAMnD,2CAAuC;AAOvC,6CAA2D;AAC3D,iDAA2D;AAyT3D;;;;;;;;;;;;;;GAcG;AACI,KAAK,UAAU,WAAW,CAG/B,MAAc,EACd,EACE,gBAAgB,EAChB,uBAAuB,EACvB,OAAO,EAAE,UAAU,GAAG,EAAE,MACgB,EAAE;IAE5C,MAAM,OAAO,GAAG,IAAA,oBAAU,EAAC,UAAU,CAAC,CAAC;IAEvC,oBAAoB;IACpB,MAAM,QAAQ,GAAG,IAAA,yBAAkB,EAAC,MAAM,EAAE;QAC1C,UAAU,EAAE,IAAI;KACjB,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,MAAM,IAAA,gBAAS,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAEpD,sBAAsB;IACtB,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,IAAA,mBAAW,EAAC,OAAO,CAAC,CAAC;IAEhD,MAAM,mBAAmB,GAAG,IAAI,qBAAS,CAA6B;QACpE,SAAS,EAAE,8BAAkB;KAC9B,CAAC,CAAC;IAEH,eAAe,CAAC,mBAAmB,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAE/D,yCAAyC;IACzC,MAAM,eAAe,GAAG,kBAAkB,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAEpE,MAAM,cAAc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AM,IAAI,EAAE,CAAC;YACvC,OAAO,GAAG,CAAC;QACb,CAAC,EACD,EAAE,CACH;KACF,CAAC,CACH,CAAC;IAEF,mBAAmB,CAAC,qBAAqB,CACvC,+BAA+B,EAC/B,CAAC,IAAI,EAAE,EAAE;QACP;;;;;WAKG;QACH,QAAQ,CAAC,CAAC,uBAAuB;YAC/B,MAAM,gBAAgB,GAAc,MAAM,IAAA,gBAAM,EAAC,2BAAmB,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,yCAAqB,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,2BAAe,EAAE,KAAK,CAAC,CAAC,SAAS,EAAE,CAAC;QAElD,OAAO,EAAE,KAAK,EAAE,CAAC;IACnB,CAAC,CACF,CAAC;AACJ,CAAC;AAxGD,0CAwGC","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 {\n PermissionDoesNotExistError,\n type Caveat,\n type RequestedPermissions,\n} from '@metamask/permission-controller';\nimport type { ExecutionService } 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, Hex, 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 getSetCurrentChainImplementation,\n} from './methods/hooks';\nimport { getGetMnemonicSeedImplementation } from './methods/hooks/get-mnemonic-seed';\nimport { createJsonRpcEngine } from './middleware';\nimport type {\n SimulationAccount,\n SimulationOptions,\n SimulationUserOptions,\n} from './options';\nimport { getOptions } from './options';\nimport type {\n ApplicationState,\n Interface,\n RunSagaFunction,\n Store,\n} 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 ExecutionService>[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<typeof ExecutionService>,\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 ExecutionService>;\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 /**\n * A hook that sets the current chain ID.\n *\n * @param chainId - The chain ID.\n */\n setCurrentChain: (chainId: Hex) => null;\n\n /**\n * A hook that gets the current simulation state.\n *\n * @returns The simulation state.\n */\n getSimulationState: () => ApplicationState;\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 client version.\n *\n * @returns A string that corresponds to the client version.\n */\n getVersion: () => string;\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\nexport type MultichainMiddlewareHooks = {\n /**\n * A hook that returns the simulated accounts.\n *\n * @returns The simulated accounts.\n */\n getAccounts: () => SimulationAccount[];\n\n /**\n * A hook that retrieves a caveat for a given permission.\n *\n * @param permission - The permission name.\n * @param caveatType - The caveat type.\n * @returns The caveat, if it exists.\n */\n getCaveat: (\n permission: string,\n caveatType: string,\n ) => Caveat<string, Json> | undefined;\n\n /**\n * A hook that grants permissions to the origin.\n *\n * @param permissions - The permissions.\n */\n grantPermissions: (permissions: RequestedPermissions) => void;\n\n /**\n * A hook that revokes a permission for the origin.\n *\n * @param permission - The permission name.\n */\n revokePermission: (permission: string) => 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 (...args: any[]) => InstanceType<typeof ExecutionService>,\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, store, runSaga);\n\n const permittedHooks = getPermittedHooks(\n snapId,\n snapFiles,\n controllerMessenger,\n runSaga,\n );\n\n const multichainHooks = getMultichainHooks(\n snapId,\n options,\n controllerMessenger,\n );\n\n const { subjectMetadataController, permissionController } = getControllers({\n controllerMessenger,\n hooks: restrictedHooks,\n runSaga,\n options,\n });\n\n const permissionMiddleware = permissionController.createPermissionMiddleware({\n origin: snapId,\n });\n\n const engine = createJsonRpcEngine({\n store,\n restrictedHooks,\n permittedHooks,\n permissionMiddleware,\n multichainHooks,\n isMultichain: false,\n });\n\n const multichainEngine = createJsonRpcEngine({\n store,\n restrictedHooks,\n permittedHooks,\n permissionMiddleware,\n multichainHooks,\n isMultichain: true,\n });\n\n // Create execution service.\n const ActualService = executionService ?? NodeThreadExecutionService;\n const service = new ActualService({\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 const multichainStream = mux.createStream('metamask-multichain-provider');\n const multichainProviderStream = createEngineStream({\n engine: multichainEngine,\n });\n\n /* istanbul ignore next 2 */\n pipeline(\n multichainStream,\n multichainProviderStream,\n multichainStream,\n (error) => {\n if (error && !error.message?.match('Premature close')) {\n logError(`Provider stream failure.`, error);\n }\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 * @param store - The Redux store.\n * @param runSaga - The run saga function.\n * @returns The hooks for the simulation.\n */\nexport function getRestrictedHooks(\n options: SimulationOptions,\n store: Store,\n runSaga: RunSagaFunction,\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 setCurrentChain: getSetCurrentChainImplementation(runSaga),\n getSimulationState: store.getState.bind(store),\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 getVersion: () => '13.6.0-flask.0',\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:getInterfaceState',\n snapId,\n ...args,\n ),\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 * Get the hooks for the multichain middleware simulation.\n *\n * @param snapId - The Snap ID.\n * @param options - The simulation options.\n * @param controllerMessenger - The controller messenger.\n * @returns The hooks for the middleware.\n */\nexport function getMultichainHooks(\n snapId: SnapId,\n options: SimulationOptions,\n controllerMessenger: RootControllerMessenger,\n): MultichainMiddlewareHooks {\n return {\n getAccounts: () => options.accounts,\n getCaveat: (permission: string, caveatType: string) => {\n try {\n return controllerMessenger.call(\n 'PermissionController:getCaveat',\n snapId,\n permission,\n caveatType,\n );\n } catch (error) {\n if (error instanceof PermissionDoesNotExistError) {\n return undefined;\n }\n /* istanbul ignore next */\n throw error;\n }\n },\n grantPermissions: (approvedPermissions: RequestedPermissions) => {\n controllerMessenger.call('PermissionController:grantPermissions', {\n subject: { origin: snapId },\n approvedPermissions,\n });\n },\n revokePermission: (permission: string) => {\n try {\n controllerMessenger.call('PermissionController:revokePermissions', {\n [snapId]: [permission],\n });\n } catch (error) {\n if (error instanceof PermissionDoesNotExistError) {\n return;\n }\n /* istanbul ignore next */\n throw error;\n }\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 * @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: '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.cjs","sourceRoot":"","sources":["../src/simulation.ts"],"names":[],"mappings":";;;AAAA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ACH,CAAC;IAEF,mBAAmB,CAAC,qBAAqB;IACvC,wFAAwF;IACxF,+BAA+B,EAC/B,KAAK,EACH,QAA2D,EAC3D,SAEsB,EACtB,EAAE;QACF,MAAM,MAAM,GAAG,IAAA,mBAAW,EAAC,QAAQ,EAAE,IAAI,CAAC;YACxC,CAAC,CAAE,QAAQ,CAAC,EAAa;YACzB,CAAC,CAAC,SAAS,CAAC;QAEd,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,IAAI,GAAG,MAAM,IAAA,yBAAc,EAAC,QAAQ,CAAC,CAAC;QAE5C,OAAO,MAAM,SAAS,CAAC;YACrB,OAAO,EAAE;gBACP,IAAI,EAAE,aAAa;gBACnB,QAAQ;gBACR,IAAI;aACL;SACF,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC;AA7ND,0CA6NC","sourcesContent":["import { createEngineStream } from '@metamask/json-rpc-middleware-stream';\nimport type { CryptographicFunctions } from '@metamask/key-tree';\nimport { mnemonicToSeed } 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 {\n PermissionDoesNotExistError,\n type Caveat,\n type RequestedPermissions,\n} from '@metamask/permission-controller';\nimport type { ExecutionService } 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 SnapId,\n TraceRequest,\n EndTraceRequest,\n TraceContext,\n} from '@metamask/snaps-sdk';\nimport type { Snap, VirtualFile } from '@metamask/snaps-utils';\nimport { logError } from '@metamask/snaps-utils';\nimport { assertExhaustive, hasProperty } from '@metamask/utils';\nimport type { CaipAssetType, Hex, 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 getGetMnemonicImplementation,\n getGetSnapImplementation,\n getTrackEventImplementation,\n getTrackErrorImplementation,\n getEndTraceImplementation,\n getStartTraceImplementation,\n getSetCurrentChainImplementation,\n getClearSnapStateMethodImplementation,\n getGetSnapStateMethodImplementation,\n getUpdateSnapStateMethodImplementation,\n getRequestUserApprovalImplementation,\n getShowInAppNotificationImplementation,\n getShowNativeNotificationImplementation,\n} from './methods/hooks';\nimport { createJsonRpcEngine } from './middleware';\nimport type {\n SimulationAccount,\n SimulationOptions,\n SimulationUserOptions,\n} from './options';\nimport { getOptions } from './options';\nimport type {\n ApplicationState,\n Interface,\n RunSagaFunction,\n Store,\n} 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 ExecutionService>[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<typeof ExecutionService>,\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 ExecutionService>;\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 * @returns The user's secret recovery phrase.\n */\n getMnemonic: () => 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 /**\n * A hook that sets the current chain ID.\n *\n * @param chainId - The chain ID.\n */\n setCurrentChain: (chainId: Hex) => null;\n\n /**\n * A hook that gets the current simulation state.\n *\n * @returns The simulation state.\n */\n getSimulationState: () => ApplicationState;\n};\n\nexport type PermittedMiddlewareHooks = {\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 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 client version.\n *\n * @returns A string that corresponds to the client version.\n */\n getVersion: () => string;\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 * A hook that returns the allowed keyring methods.\n *\n * @returns The keyring methods.\n */\n getAllowedKeyringMethods(): string[];\n};\n\nexport type MultichainMiddlewareHooks = {\n /**\n * A hook that returns the simulated accounts.\n *\n * @returns The simulated accounts.\n */\n getAccounts: () => SimulationAccount[];\n\n /**\n * A hook that retrieves a caveat for a given permission.\n *\n * @param permission - The permission name.\n * @param caveatType - The caveat type.\n * @returns The caveat, if it exists.\n */\n getCaveat: (\n permission: string,\n caveatType: string,\n ) => Caveat<string, Json> | undefined;\n\n /**\n * A hook that grants permissions to the origin.\n *\n * @param permissions - The permissions.\n */\n grantPermissions: (permissions: RequestedPermissions) => void;\n\n /**\n * A hook that revokes a permission for the origin.\n *\n * @param permission - The permission name.\n */\n revokePermission: (permission: string) => 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 (...args: any[]) => InstanceType<typeof ExecutionService>,\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(\n controllerMessenger,\n runSaga,\n options,\n snapId,\n snapFiles.auxiliaryFiles,\n );\n\n // Set up controllers and JSON-RPC stack.\n const restrictedHooks = getRestrictedHooks(options, store, runSaga);\n\n const permittedHooks = getPermittedHooks(runSaga);\n\n const multichainHooks = getMultichainHooks(\n snapId,\n options,\n controllerMessenger,\n );\n\n const { subjectMetadataController, permissionController } = getControllers({\n controllerMessenger,\n hooks: restrictedHooks,\n runSaga,\n options,\n });\n\n const engine = createJsonRpcEngine({\n snapId,\n messenger: controllerMessenger,\n store,\n restrictedHooks,\n permittedHooks,\n multichainHooks,\n isMultichain: false,\n });\n\n const multichainEngine = createJsonRpcEngine({\n snapId,\n messenger: controllerMessenger,\n store,\n restrictedHooks,\n permittedHooks,\n multichainHooks,\n isMultichain: true,\n });\n\n // Create execution service.\n const ActualService = executionService ?? NodeThreadExecutionService;\n const service = new ActualService({\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 const multichainStream = mux.createStream('metamask-multichain-provider');\n const multichainProviderStream = createEngineStream({\n engine: multichainEngine,\n });\n\n /* istanbul ignore next 2 */\n pipeline(\n multichainStream,\n multichainProviderStream,\n multichainStream,\n (error) => {\n if (error && !error.message?.match('Premature close')) {\n logError(`Provider stream failure.`, error);\n }\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 * @param store - The Redux store.\n * @param runSaga - The run saga function.\n * @returns The hooks for the simulation.\n */\nexport function getRestrictedHooks(\n options: SimulationOptions,\n store: Store,\n runSaga: RunSagaFunction,\n): RestrictedMiddlewareHooks {\n return {\n getMnemonic: getGetMnemonicImplementation(options.secretRecoveryPhrase),\n getIsLocked: () => false,\n getClientCryptography: () => ({}),\n getSnap: getGetSnapImplementation(true),\n setCurrentChain: getSetCurrentChainImplementation(runSaga),\n getSimulationState: store.getState.bind(store),\n };\n}\n\n/**\n * Get the permitted hooks for the simulation.\n *\n * @param runSaga - The run saga function.\n * @returns The permitted hooks for the simulation.\n */\nexport function getPermittedHooks(\n runSaga: RunSagaFunction,\n): PermittedMiddlewareHooks {\n return {\n getUnlockPromise: asyncResolve(),\n getIsActive: () => true,\n getVersion: () => '13.6.0-flask.0',\n\n getAllowedKeyringMethods: () => [],\n\n trackError: getTrackErrorImplementation(runSaga),\n trackEvent: getTrackEventImplementation(runSaga),\n startTrace: getStartTraceImplementation(runSaga),\n endTrace: getEndTraceImplementation(runSaga),\n };\n}\n\n/**\n * Get the hooks for the multichain middleware simulation.\n *\n * @param snapId - The Snap ID.\n * @param options - The simulation options.\n * @param controllerMessenger - The controller messenger.\n * @returns The hooks for the middleware.\n */\nexport function getMultichainHooks(\n snapId: SnapId,\n options: SimulationOptions,\n controllerMessenger: RootControllerMessenger,\n): MultichainMiddlewareHooks {\n return {\n getAccounts: () => options.accounts,\n getCaveat: (permission: string, caveatType: string) => {\n try {\n return controllerMessenger.call(\n 'PermissionController:getCaveat',\n snapId,\n permission,\n caveatType,\n );\n } catch (error) {\n if (error instanceof PermissionDoesNotExistError) {\n return undefined;\n }\n /* istanbul ignore next */\n throw error;\n }\n },\n grantPermissions: (approvedPermissions: RequestedPermissions) => {\n controllerMessenger.call('PermissionController:grantPermissions', {\n subject: { origin: snapId },\n approvedPermissions,\n });\n },\n revokePermission: (permission: string) => {\n try {\n controllerMessenger.call('PermissionController:revokePermissions', {\n [snapId]: [permission],\n });\n } catch (error) {\n if (error instanceof PermissionDoesNotExistError) {\n return;\n }\n /* istanbul ignore next */\n throw error;\n }\n },\n };\n}\n\n/**\n * Get the mock mnemonic for a given source ID.\n *\n * @param options - The simulation options.\n * @returns The mnemonic.\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 * @param auxiliaryFiles - Auxiliary files from the fetched Snap.\n */\nexport function registerActions(\n controllerMessenger: RootControllerMessenger,\n runSaga: RunSagaFunction,\n options: SimulationOptions,\n snapId: SnapId,\n auxiliaryFiles: VirtualFile[],\n) {\n controllerMessenger.registerActionHandler(\n 'PhishingController:testOrigin',\n () => ({ result: false, type: '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 controllerMessenger.registerActionHandler(\n 'ApprovalController:addRequest',\n // @ts-expect-error Types of property 'requestData' are incompatible.\n getRequestUserApprovalImplementation(runSaga),\n );\n\n controllerMessenger.registerActionHandler(\n 'SnapController:getSnap',\n getGetSnapImplementation(true),\n );\n\n controllerMessenger.registerActionHandler(\n 'SnapController:getSnapState',\n getGetSnapStateMethodImplementation(runSaga),\n );\n\n controllerMessenger.registerActionHandler(\n 'SnapController:updateSnapState',\n getUpdateSnapStateMethodImplementation(runSaga),\n );\n\n controllerMessenger.registerActionHandler(\n 'SnapController:clearSnapState',\n getClearSnapStateMethodImplementation(runSaga),\n );\n\n controllerMessenger.registerActionHandler(\n 'SnapController:getSnapFile',\n async (_snapId, path, encoding) =>\n getSnapFile(auxiliaryFiles, path, encoding),\n );\n\n const showNativeNotification =\n getShowNativeNotificationImplementation(runSaga);\n const showInAppNotification = getShowInAppNotificationImplementation(runSaga);\n\n controllerMessenger.registerActionHandler(\n // @ts-expect-error - `RateLimitController` is not part of the simulation messenger types.\n 'RateLimitController:call',\n async (\n _origin: string,\n type: 'showNativeNotification' | 'showInAppNotification',\n ...args: unknown[]\n ) => {\n switch (type) {\n case 'showNativeNotification':\n return await showNativeNotification(args[0] as string, {\n type: 'native',\n message: args[1] as string,\n });\n case 'showInAppNotification':\n return await showInAppNotification(\n args[0] as string,\n args[1] as Parameters<typeof showInAppNotification>[1],\n );\n /* istanbul ignore next */\n default:\n return assertExhaustive(type);\n }\n },\n );\n\n const getMnemonic = getGetMnemonicImplementation(\n options.secretRecoveryPhrase,\n );\n\n controllerMessenger.registerActionHandler(\n // @ts-expect-error - `KeyringController` is not part of the simulation messenger types.\n 'KeyringController:getState',\n () => ({\n isUnlocked: true,\n keyrings: [\n {\n type: 'HD Key Tree',\n metadata: {\n id: 'default',\n name: 'Default Secret Recovery Phrase',\n },\n },\n {\n type: 'HD Key Tree',\n metadata: {\n id: 'alternative',\n name: 'Alternative Secret Recovery Phrase',\n },\n },\n ],\n }),\n );\n\n controllerMessenger.registerActionHandler(\n // @ts-expect-error - `KeyringController` is not part of the simulation messenger types.\n 'KeyringController:withKeyring',\n async (\n selector: { type: string; index?: number } | { id: string },\n operation: (args: {\n keyring: { type: string; mnemonic: Uint8Array; seed: Uint8Array };\n }) => Promise<unknown>,\n ) => {\n const source = hasProperty(selector, 'id')\n ? (selector.id as string)\n : undefined;\n\n const mnemonic = await getMnemonic(source);\n const seed = await mnemonicToSeed(mnemonic);\n\n return await operation({\n keyring: {\n type: 'HD Key Tree',\n mnemonic,\n seed,\n },\n });\n },\n );\n}\n"]}
@@ -3,8 +3,8 @@ import type { ActionConstraint, EventConstraint, NamespacedName } from "@metamas
3
3
  import { Messenger } from "@metamask/messenger";
4
4
  import { type Caveat, type RequestedPermissions } from "@metamask/permission-controller";
5
5
  import type { ExecutionService } from "@metamask/snaps-controllers";
6
- import type { TrackEventParams, AuxiliaryFileEncoding, Component, InterfaceState, InterfaceContext, SnapId, EntropySource, TraceRequest, EndTraceRequest, TraceContext } from "@metamask/snaps-sdk";
7
- import type { FetchedSnapFiles, Snap } from "@metamask/snaps-utils";
6
+ import type { TrackEventParams, SnapId, TraceRequest, EndTraceRequest, TraceContext } from "@metamask/snaps-sdk";
7
+ import type { Snap, VirtualFile } from "@metamask/snaps-utils";
8
8
  import type { Hex, Json } from "@metamask/utils";
9
9
  import type { RootControllerMessenger } from "./controllers.cjs";
10
10
  import type { SnapHelpers } from "./helpers.cjs";
@@ -48,17 +48,9 @@ export type RestrictedMiddlewareHooks = {
48
48
  /**
49
49
  * A hook that returns the user's secret recovery phrase.
50
50
  *
51
- * @param source - The entropy source to get the mnemonic from.
52
51
  * @returns The user's secret recovery phrase.
53
52
  */
54
- getMnemonic: (source?: string | undefined) => Promise<Uint8Array>;
55
- /**
56
- * A hook that returns the seed derived from the user's secret recovery phrase.
57
- *
58
- * @param source - The entropy source to get the seed from.
59
- * @returns The seed.
60
- */
61
- getMnemonicSeed: (source?: string | undefined) => Promise<Uint8Array>;
53
+ getMnemonic: () => Promise<Uint8Array>;
62
54
  /**
63
55
  * A hook that returns whether the client is locked or not.
64
56
  *
@@ -93,19 +85,6 @@ export type RestrictedMiddlewareHooks = {
93
85
  getSimulationState: () => ApplicationState;
94
86
  };
95
87
  export type PermittedMiddlewareHooks = {
96
- /**
97
- * A hook that gets whether the requesting origin has a given permission.
98
- *
99
- * @param permissionName - The name of the permission to check.
100
- * @returns Whether the origin has the permission.
101
- */
102
- hasPermission: (permissionName: string) => boolean;
103
- /**
104
- * A hook that returns the entropy sources available to the Snap.
105
- *
106
- * @returns The entropy sources available to the Snap.
107
- */
108
- getEntropySources: () => EntropySource[];
109
88
  /**
110
89
  * A hook that returns a promise that resolves once the extension is unlocked.
111
90
  *
@@ -113,12 +92,6 @@ export type PermittedMiddlewareHooks = {
113
92
  * @returns A promise that resolves once the extension is unlocked.
114
93
  */
115
94
  getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;
116
- /**
117
- * A hook that returns whether the client is locked or not.
118
- *
119
- * @returns A boolean flag signaling whether the client is locked.
120
- */
121
- getIsLocked: () => boolean;
122
95
  /**
123
96
  * A hook that returns whether the client is active or not.
124
97
  *
@@ -131,85 +104,6 @@ export type PermittedMiddlewareHooks = {
131
104
  * @returns A string that corresponds to the client version.
132
105
  */
133
106
  getVersion: () => string;
134
- /**
135
- * A hook that returns the Snap's auxiliary file for the given path. This hook
136
- * is bound to the Snap ID.
137
- *
138
- * @param path - The path of the auxiliary file to get.
139
- * @param encoding - The encoding to use when returning the file.
140
- * @returns The Snap's auxiliary file for the given path.
141
- */
142
- getSnapFile: (path: string, encoding: AuxiliaryFileEncoding) => Promise<string | null>;
143
- /**
144
- * A hook that gets the state of the Snap. This hook is bound to the Snap ID.
145
- *
146
- * @param encrypted - Whether to get the encrypted or unencrypted state.
147
- * @returns The current state of the Snap.
148
- */
149
- getSnapState: (encrypted: boolean) => Promise<Record<string, Json>>;
150
- /**
151
- * A hook that updates the state of the Snap. This hook is bound to the Snap
152
- * ID.
153
- *
154
- * @param newState - The new state.
155
- * @param encrypted - Whether to update the encrypted or unencrypted state.
156
- */
157
- updateSnapState: (newState: Record<string, Json>, encrypted: boolean) => Promise<void>;
158
- /**
159
- * A hook that clears the state of the Snap. This hook is bound to the Snap
160
- * ID.
161
- *
162
- * @param encrypted - Whether to clear the encrypted or unencrypted state.
163
- */
164
- clearSnapState: (encrypted: boolean) => Promise<void>;
165
- /**
166
- * A hook that creates an interface for the Snap. This hook is bound to the
167
- * Snap ID.
168
- *
169
- * @param content - The content of the interface.
170
- * @param context - The context of the interface.
171
- * @returns The ID of the created interface.
172
- */
173
- createInterface: (content: Component, context?: InterfaceContext) => string;
174
- /**
175
- * A hook that updates an interface for the Snap. This hook is bound to the
176
- * Snap ID.
177
- *
178
- * @param id - The ID of the interface to update.
179
- * @param content - The content of the interface.
180
- */
181
- updateInterface: (id: string, content: Component) => void;
182
- /**
183
- * A hook that gets the state of an interface for the Snap. This hook is bound
184
- * to the Snap ID.
185
- *
186
- * @param id - The ID of the interface to get.
187
- * @returns The state of the interface.
188
- */
189
- getInterfaceState: (id: string) => InterfaceState;
190
- /**
191
- * A hook that gets the context of an interface for the Snap. This hook is
192
- * bound to the Snap ID.
193
- *
194
- * @param id - The ID of the interface to get.
195
- * @returns The context of the interface.
196
- */
197
- getInterfaceContext: (id: string) => InterfaceContext | null;
198
- /**
199
- * A hook that resolves an interface for the Snap. This hook is bound to the
200
- * Snap ID.
201
- *
202
- * @param id - The ID of the interface to resolve.
203
- * @param value - The value to resolve the interface with.
204
- */
205
- resolveInterface: (id: string, value: Json) => Promise<void>;
206
- /**
207
- * A hook that gets the Snap's metadata.
208
- *
209
- * @param snapId - The ID of the Snap to get.
210
- * @returns The Snap's metadata.
211
- */
212
- getSnap(snapId: string): Snap;
213
107
  /**
214
108
  * A hook that tracks an error.
215
109
  *
@@ -235,6 +129,12 @@ export type PermittedMiddlewareHooks = {
235
129
  * @returns The trace data.
236
130
  */
237
131
  endTrace(request: EndTraceRequest): void;
132
+ /**
133
+ * A hook that returns the allowed keyring methods.
134
+ *
135
+ * @returns The keyring methods.
136
+ */
137
+ getAllowedKeyringMethods(): string[];
238
138
  };
239
139
  export type MultichainMiddlewareHooks = {
240
140
  /**
@@ -292,13 +192,10 @@ export declare function getRestrictedHooks(options: SimulationOptions, store: St
292
192
  /**
293
193
  * Get the permitted hooks for the simulation.
294
194
  *
295
- * @param snapId - The ID of the Snap.
296
- * @param snapFiles - The fetched Snap files.
297
- * @param controllerMessenger - The controller messenger.
298
195
  * @param runSaga - The run saga function.
299
196
  * @returns The permitted hooks for the simulation.
300
197
  */
301
- export declare function getPermittedHooks(snapId: SnapId, snapFiles: FetchedSnapFiles, controllerMessenger: RootControllerMessenger, runSaga: RunSagaFunction): PermittedMiddlewareHooks;
198
+ export declare function getPermittedHooks(runSaga: RunSagaFunction): PermittedMiddlewareHooks;
302
199
  /**
303
200
  * Get the hooks for the multichain middleware simulation.
304
201
  *
@@ -308,6 +205,12 @@ export declare function getPermittedHooks(snapId: SnapId, snapFiles: FetchedSnap
308
205
  * @returns The hooks for the middleware.
309
206
  */
310
207
  export declare function getMultichainHooks(snapId: SnapId, options: SimulationOptions, controllerMessenger: RootControllerMessenger): MultichainMiddlewareHooks;
208
+ /**
209
+ * Get the mock mnemonic for a given source ID.
210
+ *
211
+ * @param options - The simulation options.
212
+ * @returns The mnemonic.
213
+ */
311
214
  /**
312
215
  * Register mocked action handlers.
313
216
  *
@@ -315,6 +218,7 @@ export declare function getMultichainHooks(snapId: SnapId, options: SimulationOp
315
218
  * @param runSaga - The run saga function.
316
219
  * @param options - The simulation options.
317
220
  * @param snapId - The ID of the Snap.
221
+ * @param auxiliaryFiles - Auxiliary files from the fetched Snap.
318
222
  */
319
- export declare function registerActions(controllerMessenger: RootControllerMessenger, runSaga: RunSagaFunction, options: SimulationOptions, snapId: SnapId): void;
223
+ export declare function registerActions(controllerMessenger: RootControllerMessenger, runSaga: RunSagaFunction, options: SimulationOptions, snapId: SnapId, auxiliaryFiles: VirtualFile[]): void;
320
224
  //# sourceMappingURL=simulation.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"simulation.d.cts","sourceRoot":"","sources":["../src/simulation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,2BAA2B;AACjE,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EAEf,cAAc,EACf,4BAA4B;AAC7B,OAAO,EAAsB,SAAS,EAAE,4BAA4B;AACpE,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,oBAAoB,EAC1B,wCAAwC;A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AAO,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,YAAY,CAAC,OAAO,gBAAgB,CAAC,EAE7E,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,GAAG,WAAW,CAAC,CAsItC;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,eAAe,GACvB,yBAAyB,CAS3B;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,eAAe,GACvB,wBAAwB,CAa1B;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,iBAAiB,EAC1B,mBAAmB,EAAE,uBAAuB,GAC3C,yBAAyB,CAuC3B;AAED;;;;;GAKG;AACH;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,mBAAmB,EAAE,uBAAuB,EAC5C,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,WAAW,EAAE,QAwN9B"}
@@ -3,8 +3,8 @@ import type { ActionConstraint, EventConstraint, NamespacedName } from "@metamas
3
3
  import { Messenger } from "@metamask/messenger";
4
4
  import { type Caveat, type RequestedPermissions } from "@metamask/permission-controller";
5
5
  import type { ExecutionService } from "@metamask/snaps-controllers";
6
- import type { TrackEventParams, AuxiliaryFileEncoding, Component, InterfaceState, InterfaceContext, SnapId, EntropySource, TraceRequest, EndTraceRequest, TraceContext } from "@metamask/snaps-sdk";
7
- import type { FetchedSnapFiles, Snap } from "@metamask/snaps-utils";
6
+ import type { TrackEventParams, SnapId, TraceRequest, EndTraceRequest, TraceContext } from "@metamask/snaps-sdk";
7
+ import type { Snap, VirtualFile } from "@metamask/snaps-utils";
8
8
  import type { Hex, Json } from "@metamask/utils";
9
9
  import type { RootControllerMessenger } from "./controllers.mjs";
10
10
  import type { SnapHelpers } from "./helpers.mjs";
@@ -48,17 +48,9 @@ export type RestrictedMiddlewareHooks = {
48
48
  /**
49
49
  * A hook that returns the user's secret recovery phrase.
50
50
  *
51
- * @param source - The entropy source to get the mnemonic from.
52
51
  * @returns The user's secret recovery phrase.
53
52
  */
54
- getMnemonic: (source?: string | undefined) => Promise<Uint8Array>;
55
- /**
56
- * A hook that returns the seed derived from the user's secret recovery phrase.
57
- *
58
- * @param source - The entropy source to get the seed from.
59
- * @returns The seed.
60
- */
61
- getMnemonicSeed: (source?: string | undefined) => Promise<Uint8Array>;
53
+ getMnemonic: () => Promise<Uint8Array>;
62
54
  /**
63
55
  * A hook that returns whether the client is locked or not.
64
56
  *
@@ -93,19 +85,6 @@ export type RestrictedMiddlewareHooks = {
93
85
  getSimulationState: () => ApplicationState;
94
86
  };
95
87
  export type PermittedMiddlewareHooks = {
96
- /**
97
- * A hook that gets whether the requesting origin has a given permission.
98
- *
99
- * @param permissionName - The name of the permission to check.
100
- * @returns Whether the origin has the permission.
101
- */
102
- hasPermission: (permissionName: string) => boolean;
103
- /**
104
- * A hook that returns the entropy sources available to the Snap.
105
- *
106
- * @returns The entropy sources available to the Snap.
107
- */
108
- getEntropySources: () => EntropySource[];
109
88
  /**
110
89
  * A hook that returns a promise that resolves once the extension is unlocked.
111
90
  *
@@ -113,12 +92,6 @@ export type PermittedMiddlewareHooks = {
113
92
  * @returns A promise that resolves once the extension is unlocked.
114
93
  */
115
94
  getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;
116
- /**
117
- * A hook that returns whether the client is locked or not.
118
- *
119
- * @returns A boolean flag signaling whether the client is locked.
120
- */
121
- getIsLocked: () => boolean;
122
95
  /**
123
96
  * A hook that returns whether the client is active or not.
124
97
  *
@@ -131,85 +104,6 @@ export type PermittedMiddlewareHooks = {
131
104
  * @returns A string that corresponds to the client version.
132
105
  */
133
106
  getVersion: () => string;
134
- /**
135
- * A hook that returns the Snap's auxiliary file for the given path. This hook
136
- * is bound to the Snap ID.
137
- *
138
- * @param path - The path of the auxiliary file to get.
139
- * @param encoding - The encoding to use when returning the file.
140
- * @returns The Snap's auxiliary file for the given path.
141
- */
142
- getSnapFile: (path: string, encoding: AuxiliaryFileEncoding) => Promise<string | null>;
143
- /**
144
- * A hook that gets the state of the Snap. This hook is bound to the Snap ID.
145
- *
146
- * @param encrypted - Whether to get the encrypted or unencrypted state.
147
- * @returns The current state of the Snap.
148
- */
149
- getSnapState: (encrypted: boolean) => Promise<Record<string, Json>>;
150
- /**
151
- * A hook that updates the state of the Snap. This hook is bound to the Snap
152
- * ID.
153
- *
154
- * @param newState - The new state.
155
- * @param encrypted - Whether to update the encrypted or unencrypted state.
156
- */
157
- updateSnapState: (newState: Record<string, Json>, encrypted: boolean) => Promise<void>;
158
- /**
159
- * A hook that clears the state of the Snap. This hook is bound to the Snap
160
- * ID.
161
- *
162
- * @param encrypted - Whether to clear the encrypted or unencrypted state.
163
- */
164
- clearSnapState: (encrypted: boolean) => Promise<void>;
165
- /**
166
- * A hook that creates an interface for the Snap. This hook is bound to the
167
- * Snap ID.
168
- *
169
- * @param content - The content of the interface.
170
- * @param context - The context of the interface.
171
- * @returns The ID of the created interface.
172
- */
173
- createInterface: (content: Component, context?: InterfaceContext) => string;
174
- /**
175
- * A hook that updates an interface for the Snap. This hook is bound to the
176
- * Snap ID.
177
- *
178
- * @param id - The ID of the interface to update.
179
- * @param content - The content of the interface.
180
- */
181
- updateInterface: (id: string, content: Component) => void;
182
- /**
183
- * A hook that gets the state of an interface for the Snap. This hook is bound
184
- * to the Snap ID.
185
- *
186
- * @param id - The ID of the interface to get.
187
- * @returns The state of the interface.
188
- */
189
- getInterfaceState: (id: string) => InterfaceState;
190
- /**
191
- * A hook that gets the context of an interface for the Snap. This hook is
192
- * bound to the Snap ID.
193
- *
194
- * @param id - The ID of the interface to get.
195
- * @returns The context of the interface.
196
- */
197
- getInterfaceContext: (id: string) => InterfaceContext | null;
198
- /**
199
- * A hook that resolves an interface for the Snap. This hook is bound to the
200
- * Snap ID.
201
- *
202
- * @param id - The ID of the interface to resolve.
203
- * @param value - The value to resolve the interface with.
204
- */
205
- resolveInterface: (id: string, value: Json) => Promise<void>;
206
- /**
207
- * A hook that gets the Snap's metadata.
208
- *
209
- * @param snapId - The ID of the Snap to get.
210
- * @returns The Snap's metadata.
211
- */
212
- getSnap(snapId: string): Snap;
213
107
  /**
214
108
  * A hook that tracks an error.
215
109
  *
@@ -235,6 +129,12 @@ export type PermittedMiddlewareHooks = {
235
129
  * @returns The trace data.
236
130
  */
237
131
  endTrace(request: EndTraceRequest): void;
132
+ /**
133
+ * A hook that returns the allowed keyring methods.
134
+ *
135
+ * @returns The keyring methods.
136
+ */
137
+ getAllowedKeyringMethods(): string[];
238
138
  };
239
139
  export type MultichainMiddlewareHooks = {
240
140
  /**
@@ -292,13 +192,10 @@ export declare function getRestrictedHooks(options: SimulationOptions, store: St
292
192
  /**
293
193
  * Get the permitted hooks for the simulation.
294
194
  *
295
- * @param snapId - The ID of the Snap.
296
- * @param snapFiles - The fetched Snap files.
297
- * @param controllerMessenger - The controller messenger.
298
195
  * @param runSaga - The run saga function.
299
196
  * @returns The permitted hooks for the simulation.
300
197
  */
301
- export declare function getPermittedHooks(snapId: SnapId, snapFiles: FetchedSnapFiles, controllerMessenger: RootControllerMessenger, runSaga: RunSagaFunction): PermittedMiddlewareHooks;
198
+ export declare function getPermittedHooks(runSaga: RunSagaFunction): PermittedMiddlewareHooks;
302
199
  /**
303
200
  * Get the hooks for the multichain middleware simulation.
304
201
  *
@@ -308,6 +205,12 @@ export declare function getPermittedHooks(snapId: SnapId, snapFiles: FetchedSnap
308
205
  * @returns The hooks for the middleware.
309
206
  */
310
207
  export declare function getMultichainHooks(snapId: SnapId, options: SimulationOptions, controllerMessenger: RootControllerMessenger): MultichainMiddlewareHooks;
208
+ /**
209
+ * Get the mock mnemonic for a given source ID.
210
+ *
211
+ * @param options - The simulation options.
212
+ * @returns The mnemonic.
213
+ */
311
214
  /**
312
215
  * Register mocked action handlers.
313
216
  *
@@ -315,6 +218,7 @@ export declare function getMultichainHooks(snapId: SnapId, options: SimulationOp
315
218
  * @param runSaga - The run saga function.
316
219
  * @param options - The simulation options.
317
220
  * @param snapId - The ID of the Snap.
221
+ * @param auxiliaryFiles - Auxiliary files from the fetched Snap.
318
222
  */
319
- export declare function registerActions(controllerMessenger: RootControllerMessenger, runSaga: RunSagaFunction, options: SimulationOptions, snapId: SnapId): void;
223
+ export declare function registerActions(controllerMessenger: RootControllerMessenger, runSaga: RunSagaFunction, options: SimulationOptions, snapId: SnapId, auxiliaryFiles: VirtualFile[]): void;
320
224
  //# sourceMappingURL=simulation.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"simulation.d.mts","sourceRoot":"","sources":["../src/simulation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,2BAA2B;AACjE,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EAEf,cAAc,EACf,4BAA4B;AAC7B,OAAO,EAAsB,SAAS,EAAE,4BAA4B;AACpE,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,oBAAoB,EAC1B,wCAAwC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,oCAAoC;AAQpE,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,GAAG,EAAE,IAAI,EAAE,wBAAwB;AAMhE,OAAO,KAAK,EAAE,uBAAuB,EAAE,0BAAsB;AAG7D,OAAO,KAAK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