@metamask/snaps-simulation 4.1.4 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -2
- package/dist/simulation.cjs +18 -4
- package/dist/simulation.cjs.map +1 -1
- package/dist/simulation.d.cts +12 -1
- package/dist/simulation.d.cts.map +1 -1
- package/dist/simulation.d.mts +12 -1
- package/dist/simulation.d.mts.map +1 -1
- package/dist/simulation.mjs +18 -4
- package/dist/simulation.mjs.map +1 -1
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -7,13 +7,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [4.3.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add support for `endowment:messenger` ([#4055](https://github.com/MetaMask/snaps/pull/4055))
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- Bump `@metamask/messenger` from `^1.2.0` to `^2.0.0` ([#4064](https://github.com/MetaMask/snaps/pull/4064))
|
|
19
|
+
- Bump `@metamask/superstruct` from `^3.2.1` to `^3.3.0` ([#4062](https://github.com/MetaMask/snaps/pull/4062))
|
|
20
|
+
- Bump `@metamask/chain-agnostic-permission` from `^1.6.1` to `^1.6.2` ([#4036](https://github.com/MetaMask/snaps/pull/4036))
|
|
21
|
+
|
|
22
|
+
## [4.2.0]
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
|
|
26
|
+
- Use `withKeyringV2Unsafe` for accessing entropy ([#4009](https://github.com/MetaMask/snaps/pull/4009))
|
|
27
|
+
- Bump `@metamask/snaps-rpc-methods` from `16.0.0` to `17.0.0` ([#4020](https://github.com/MetaMask/snaps/pull/4020))
|
|
28
|
+
|
|
10
29
|
## [4.1.4]
|
|
11
30
|
|
|
12
31
|
### Changed
|
|
13
32
|
|
|
14
33
|
- Bump `@metamask/snaps-rpc-methods` from `^15.1.1` to `16.0.0` and handle breaking changes ([#3968](https://github.com/MetaMask/snaps/pull/3968), [#3987](https://github.com/MetaMask/snaps/pull/3987), [#3993](https://github.com/MetaMask/snaps/pull/3993))
|
|
15
34
|
- Bump `@metamask/permission-controller` `12.3.0` to `^13.1.0` ([#3984](https://github.com/MetaMask/snaps/pull/3984), [#3989](https://github.com/MetaMask/snaps/pull/3989))
|
|
16
|
-
- Bump `@metamask/json-rpc-engine` from `^10.2.4` to `^10.5.0` ([#3982](https://github.com/MetaMask/snaps/pull/3982),[#3992](https://github.com/MetaMask/snaps/pull/3992), [#3998](https://github.com/MetaMask/snaps/pull/3998))
|
|
35
|
+
- Bump `@metamask/json-rpc-engine` from `^10.2.4` to `^10.5.0` ([#3982](https://github.com/MetaMask/snaps/pull/3982), [#3992](https://github.com/MetaMask/snaps/pull/3992), [#3998](https://github.com/MetaMask/snaps/pull/3998))
|
|
17
36
|
- Bump `@metamask/messenger` from `^1.1.1` to `^1.2.0` ([#3981](https://github.com/MetaMask/snaps/pull/3981))
|
|
18
37
|
- Bump `@metamask/chain-agnostic-permission` from `^1.5.0` to `^1.6.0` ([#3997](https://github.com/MetaMask/snaps/pull/3997))
|
|
19
38
|
|
|
@@ -310,7 +329,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
310
329
|
|
|
311
330
|
- Initial release of `@metamask/snaps-simulation` package ([#2727](https://github.com/MetaMask/snaps/pull/2727))
|
|
312
331
|
|
|
313
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-simulation@4.
|
|
332
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-simulation@4.3.0...HEAD
|
|
333
|
+
[4.3.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-simulation@4.2.0...@metamask/snaps-simulation@4.3.0
|
|
334
|
+
[4.2.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-simulation@4.1.4...@metamask/snaps-simulation@4.2.0
|
|
314
335
|
[4.1.4]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-simulation@4.1.3...@metamask/snaps-simulation@4.1.4
|
|
315
336
|
[4.1.3]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-simulation@4.1.2...@metamask/snaps-simulation@4.1.3
|
|
316
337
|
[4.1.2]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-simulation@4.1.1...@metamask/snaps-simulation@4.1.2
|
package/dist/simulation.cjs
CHANGED
|
@@ -51,7 +51,7 @@ async function installSnap(snapId, { executionService, executionServiceOptions,
|
|
|
51
51
|
registerActions(controllerMessenger, runSaga, options, snapId, snapFiles.auxiliaryFiles);
|
|
52
52
|
// Set up controllers and JSON-RPC stack.
|
|
53
53
|
const restrictedHooks = getRestrictedHooks(options, store, runSaga);
|
|
54
|
-
const permittedHooks = getPermittedHooks(runSaga);
|
|
54
|
+
const permittedHooks = getPermittedHooks(snapId, controllerMessenger, runSaga);
|
|
55
55
|
const multichainHooks = getMultichainHooks(snapId, options, controllerMessenger);
|
|
56
56
|
const { subjectMetadataController, permissionController } = (0, controllers_1.getControllers)({
|
|
57
57
|
controllerMessenger,
|
|
@@ -160,10 +160,12 @@ exports.getRestrictedHooks = getRestrictedHooks;
|
|
|
160
160
|
/**
|
|
161
161
|
* Get the permitted hooks for the simulation.
|
|
162
162
|
*
|
|
163
|
+
* @param snapId - The Snap ID.
|
|
164
|
+
* @param controllerMessenger - The controller messenger.
|
|
163
165
|
* @param runSaga - The run saga function.
|
|
164
166
|
* @returns The permitted hooks for the simulation.
|
|
165
167
|
*/
|
|
166
|
-
function getPermittedHooks(runSaga) {
|
|
168
|
+
function getPermittedHooks(snapId, controllerMessenger, runSaga) {
|
|
167
169
|
return {
|
|
168
170
|
getUnlockPromise: (0, methods_1.asyncResolve)(),
|
|
169
171
|
getIsActive: () => true,
|
|
@@ -173,6 +175,18 @@ function getPermittedHooks(runSaga) {
|
|
|
173
175
|
trackEvent: (0, hooks_1.getTrackEventImplementation)(runSaga),
|
|
174
176
|
startTrace: (0, hooks_1.getStartTraceImplementation)(runSaga),
|
|
175
177
|
endTrace: (0, hooks_1.getEndTraceImplementation)(runSaga),
|
|
178
|
+
getMessenger: ({ actions, events }) => {
|
|
179
|
+
const messenger = new messenger_1.Messenger({
|
|
180
|
+
namespace: `${snapId}-messenger`,
|
|
181
|
+
parent: controllerMessenger,
|
|
182
|
+
});
|
|
183
|
+
controllerMessenger.delegate({
|
|
184
|
+
actions: actions,
|
|
185
|
+
events: events,
|
|
186
|
+
messenger,
|
|
187
|
+
});
|
|
188
|
+
return messenger;
|
|
189
|
+
},
|
|
176
190
|
};
|
|
177
191
|
}
|
|
178
192
|
exports.getPermittedHooks = getPermittedHooks;
|
|
@@ -341,7 +355,7 @@ function registerActions(controllerMessenger, runSaga, options, snapId, auxiliar
|
|
|
341
355
|
}));
|
|
342
356
|
controllerMessenger.registerActionHandler(
|
|
343
357
|
// @ts-expect-error - `KeyringController` is not part of the simulation messenger types.
|
|
344
|
-
'KeyringController:
|
|
358
|
+
'KeyringController:withKeyringV2Unsafe', async (selector, operation) => {
|
|
345
359
|
const source = (0, utils_1.hasProperty)(selector, 'id')
|
|
346
360
|
? selector.id
|
|
347
361
|
: undefined;
|
|
@@ -349,7 +363,7 @@ function registerActions(controllerMessenger, runSaga, options, snapId, auxiliar
|
|
|
349
363
|
const seed = await (0, key_tree_1.mnemonicToSeed)(mnemonic);
|
|
350
364
|
return await operation({
|
|
351
365
|
keyring: {
|
|
352
|
-
type: '
|
|
366
|
+
type: 'hd',
|
|
353
367
|
mnemonic,
|
|
354
368
|
seed,
|
|
355
369
|
},
|
package/dist/simulation.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simulation.cjs","sourceRoot":"","sources":["../src/simulation.ts"],"names":[],"mappings":";;;AAAA,qFAA0E;AAE1E,iDAAoD;AAOpD,mDAAoE;AACpE,2E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wF;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"]}
|
|
1
|
+
{"version":3,"file":"simulation.cjs","sourceRoot":"","sources":["../src/simulation.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IAAA,oCAA4B,EAC9C,OAAO,CAAC,oBAAoB,CAC7B,CAAC;IAEF,mBAAmB,CAAC,qBAAqB;IACvC,wFAAwF;IACxF,4BAA4B,EAC5B,GAAG,EAAE,CAAC,CAAC;QACL,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,aAAa;gBACnB,QAAQ,EAAE;oBACR,EAAE,EAAE,SAAS;oBACb,IAAI,EAAE,gCAAgC;iBACvC;aACF;YACD;gBACE,IAAI,EAAE,aAAa;gBACnB,QAAQ,EAAE;oBACR,EAAE,EAAE,aAAa;oBACjB,IAAI,EAAE,oCAAoC;iBAC3C;aACF;SACF;KACF,CAAC,CACH,CAAC;IAEF,mBAAmB,CAAC,qBAAqB;IACvC,wFAAwF;IACxF,uCAAuC,EACvC,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,IAAI;gBACV,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 /**\n * A hook that returns a specialized messenger for the Snap.\n *\n * @returns The messenger.\n */\n getMessenger(args: {\n actions?: string[];\n events?: string[];\n }): Messenger<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(\n snapId,\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 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 snapId - The Snap ID.\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: string,\n controllerMessenger: RootControllerMessenger,\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 getMessenger: ({ actions, events }) => {\n const messenger = new Messenger({\n namespace: `${snapId}-messenger`,\n parent: controllerMessenger,\n });\n\n controllerMessenger.delegate({\n actions: actions as never[],\n events: events as never[],\n messenger,\n });\n\n return messenger;\n },\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:withKeyringV2Unsafe',\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',\n mnemonic,\n seed,\n },\n });\n },\n );\n}\n"]}
|
package/dist/simulation.d.cts
CHANGED
|
@@ -135,6 +135,15 @@ export type PermittedMiddlewareHooks = {
|
|
|
135
135
|
* @returns The keyring methods.
|
|
136
136
|
*/
|
|
137
137
|
getAllowedKeyringMethods(): string[];
|
|
138
|
+
/**
|
|
139
|
+
* A hook that returns a specialized messenger for the Snap.
|
|
140
|
+
*
|
|
141
|
+
* @returns The messenger.
|
|
142
|
+
*/
|
|
143
|
+
getMessenger(args: {
|
|
144
|
+
actions?: string[];
|
|
145
|
+
events?: string[];
|
|
146
|
+
}): Messenger<string>;
|
|
138
147
|
};
|
|
139
148
|
export type MultichainMiddlewareHooks = {
|
|
140
149
|
/**
|
|
@@ -192,10 +201,12 @@ export declare function getRestrictedHooks(options: SimulationOptions, store: St
|
|
|
192
201
|
/**
|
|
193
202
|
* Get the permitted hooks for the simulation.
|
|
194
203
|
*
|
|
204
|
+
* @param snapId - The Snap ID.
|
|
205
|
+
* @param controllerMessenger - The controller messenger.
|
|
195
206
|
* @param runSaga - The run saga function.
|
|
196
207
|
* @returns The permitted hooks for the simulation.
|
|
197
208
|
*/
|
|
198
|
-
export declare function getPermittedHooks(runSaga: RunSagaFunction): PermittedMiddlewareHooks;
|
|
209
|
+
export declare function getPermittedHooks(snapId: string, controllerMessenger: RootControllerMessenger, runSaga: RunSagaFunction): PermittedMiddlewareHooks;
|
|
199
210
|
/**
|
|
200
211
|
* Get the hooks for the multichain middleware simulation.
|
|
201
212
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simulation.d.cts","sourceRoot":"","sources":["../src/simulation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,2BAA2B;AAEjE,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,MAAM,EACN,YAAY,EACZ,eAAe,EACf,YAAY,EACb,4BAA4B;AAC7B,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,8BAA8B;AAG/D,OAAO,KAAK,EAAiB,GAAG,EAAE,IAAI,EAAE,wBAAwB;AAMhE,OAAO,KAAK,EAAE,uBAAuB,EAAE,0BAAsB;AAG7D,OAAO,KAAK,EAAE,WAAW,EAAE,sBAAkB;AAoB7C,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACtB,sBAAkB;AAEnB,OAAO,KAAK,EACV,gBAAgB,EAEhB,eAAe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,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"}
|
package/dist/simulation.d.mts
CHANGED
|
@@ -135,6 +135,15 @@ export type PermittedMiddlewareHooks = {
|
|
|
135
135
|
* @returns The keyring methods.
|
|
136
136
|
*/
|
|
137
137
|
getAllowedKeyringMethods(): string[];
|
|
138
|
+
/**
|
|
139
|
+
* A hook that returns a specialized messenger for the Snap.
|
|
140
|
+
*
|
|
141
|
+
* @returns The messenger.
|
|
142
|
+
*/
|
|
143
|
+
getMessenger(args: {
|
|
144
|
+
actions?: string[];
|
|
145
|
+
events?: string[];
|
|
146
|
+
}): Messenger<string>;
|
|
138
147
|
};
|
|
139
148
|
export type MultichainMiddlewareHooks = {
|
|
140
149
|
/**
|
|
@@ -192,10 +201,12 @@ export declare function getRestrictedHooks(options: SimulationOptions, store: St
|
|
|
192
201
|
/**
|
|
193
202
|
* Get the permitted hooks for the simulation.
|
|
194
203
|
*
|
|
204
|
+
* @param snapId - The Snap ID.
|
|
205
|
+
* @param controllerMessenger - The controller messenger.
|
|
195
206
|
* @param runSaga - The run saga function.
|
|
196
207
|
* @returns The permitted hooks for the simulation.
|
|
197
208
|
*/
|
|
198
|
-
export declare function getPermittedHooks(runSaga: RunSagaFunction): PermittedMiddlewareHooks;
|
|
209
|
+
export declare function getPermittedHooks(snapId: string, controllerMessenger: RootControllerMessenger, runSaga: RunSagaFunction): PermittedMiddlewareHooks;
|
|
199
210
|
/**
|
|
200
211
|
* Get the hooks for the multichain middleware simulation.
|
|
201
212
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simulation.d.mts","s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E,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CAChD,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,WAAW,CAC/B,OAAO,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,CA0ItC;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,eAAe,GACvB,yBAAyB,CAS3B;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,uBAAuB,EAC5C,OAAO,EAAE,eAAe,GACvB,wBAAwB,CA4B1B;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"}
|
package/dist/simulation.mjs
CHANGED
|
@@ -48,7 +48,7 @@ export async function installSnap(snapId, { executionService, executionServiceOp
|
|
|
48
48
|
registerActions(controllerMessenger, runSaga, options, snapId, snapFiles.auxiliaryFiles);
|
|
49
49
|
// Set up controllers and JSON-RPC stack.
|
|
50
50
|
const restrictedHooks = getRestrictedHooks(options, store, runSaga);
|
|
51
|
-
const permittedHooks = getPermittedHooks(runSaga);
|
|
51
|
+
const permittedHooks = getPermittedHooks(snapId, controllerMessenger, runSaga);
|
|
52
52
|
const multichainHooks = getMultichainHooks(snapId, options, controllerMessenger);
|
|
53
53
|
const { subjectMetadataController, permissionController } = getControllers({
|
|
54
54
|
controllerMessenger,
|
|
@@ -155,10 +155,12 @@ export function getRestrictedHooks(options, store, runSaga) {
|
|
|
155
155
|
/**
|
|
156
156
|
* Get the permitted hooks for the simulation.
|
|
157
157
|
*
|
|
158
|
+
* @param snapId - The Snap ID.
|
|
159
|
+
* @param controllerMessenger - The controller messenger.
|
|
158
160
|
* @param runSaga - The run saga function.
|
|
159
161
|
* @returns The permitted hooks for the simulation.
|
|
160
162
|
*/
|
|
161
|
-
export function getPermittedHooks(runSaga) {
|
|
163
|
+
export function getPermittedHooks(snapId, controllerMessenger, runSaga) {
|
|
162
164
|
return {
|
|
163
165
|
getUnlockPromise: asyncResolve(),
|
|
164
166
|
getIsActive: () => true,
|
|
@@ -168,6 +170,18 @@ export function getPermittedHooks(runSaga) {
|
|
|
168
170
|
trackEvent: getTrackEventImplementation(runSaga),
|
|
169
171
|
startTrace: getStartTraceImplementation(runSaga),
|
|
170
172
|
endTrace: getEndTraceImplementation(runSaga),
|
|
173
|
+
getMessenger: ({ actions, events }) => {
|
|
174
|
+
const messenger = new Messenger({
|
|
175
|
+
namespace: `${snapId}-messenger`,
|
|
176
|
+
parent: controllerMessenger,
|
|
177
|
+
});
|
|
178
|
+
controllerMessenger.delegate({
|
|
179
|
+
actions: actions,
|
|
180
|
+
events: events,
|
|
181
|
+
messenger,
|
|
182
|
+
});
|
|
183
|
+
return messenger;
|
|
184
|
+
},
|
|
171
185
|
};
|
|
172
186
|
}
|
|
173
187
|
/**
|
|
@@ -334,7 +348,7 @@ export function registerActions(controllerMessenger, runSaga, options, snapId, a
|
|
|
334
348
|
}));
|
|
335
349
|
controllerMessenger.registerActionHandler(
|
|
336
350
|
// @ts-expect-error - `KeyringController` is not part of the simulation messenger types.
|
|
337
|
-
'KeyringController:
|
|
351
|
+
'KeyringController:withKeyringV2Unsafe', async (selector, operation) => {
|
|
338
352
|
const source = hasProperty(selector, 'id')
|
|
339
353
|
? selector.id
|
|
340
354
|
: undefined;
|
|
@@ -342,7 +356,7 @@ export function registerActions(controllerMessenger, runSaga, options, snapId, a
|
|
|
342
356
|
const seed = await mnemonicToSeed(mnemonic);
|
|
343
357
|
return await operation({
|
|
344
358
|
keyring: {
|
|
345
|
-
type: '
|
|
359
|
+
type: 'hd',
|
|
346
360
|
mnemonic,
|
|
347
361
|
seed,
|
|
348
362
|
},
|
package/dist/simulation.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simulation.mjs","sourceRoot":"","sources":["../src/simulation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,6CAA6C;AAE1E,OAAO,EAAE,cAAc,EAAE,2BAA2B;AAOpD,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,4BAA4B;AACpE,OAAO,EACL,2BAA2B,EAG5B,wCAAwC;AAEzC,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,0BAA0B,EAC1B,cAAc,EACf,yCAAyC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,oCAAoC;AASpE,OAAO,EAAE,QAAQ,EAAE,8BAA8B;AACjD,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,wBAAwB;AAGhE,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,4BAA4B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AAa;YACzB,CAAC,CAAC,SAAS,CAAC;QAEd,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,IAAI,GAAG,MAAM,cAAc,CAAC,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","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"]}
|
|
1
|
+
{"version":3,"file":"simulation.mjs","sourceRoot":"","sources":["../src/simulation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,6CAA6C;AAE1E,OAAO,EAAE,cAAc,EAAE,2BAA2B;AAOpD,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,4BAA4B;AACpE,OAAO,EACL,2BAA2B,EAG5B,wCAAwC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F,CAAC;AACJ,CAAC","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 /**\n * A hook that returns a specialized messenger for the Snap.\n *\n * @returns The messenger.\n */\n getMessenger(args: {\n actions?: string[];\n events?: string[];\n }): Messenger<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(\n snapId,\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 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 snapId - The Snap ID.\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: string,\n controllerMessenger: RootControllerMessenger,\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 getMessenger: ({ actions, events }) => {\n const messenger = new Messenger({\n namespace: `${snapId}-messenger`,\n parent: controllerMessenger,\n });\n\n controllerMessenger.delegate({\n actions: actions as never[],\n events: events as never[],\n messenger,\n });\n\n return messenger;\n },\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:withKeyringV2Unsafe',\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',\n mnemonic,\n seed,\n },\n });\n },\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/snaps-simulation",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "A simulation framework for MetaMask Snaps, enabling headless testing of Snaps in a controlled environment",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -55,19 +55,19 @@
|
|
|
55
55
|
"test:watch": "jest --watch"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@metamask/chain-agnostic-permission": "^1.6.
|
|
58
|
+
"@metamask/chain-agnostic-permission": "^1.6.2",
|
|
59
59
|
"@metamask/json-rpc-engine": "^10.5.0",
|
|
60
60
|
"@metamask/json-rpc-middleware-stream": "^8.0.8",
|
|
61
61
|
"@metamask/key-tree": "^10.1.1",
|
|
62
|
-
"@metamask/messenger": "^
|
|
63
|
-
"@metamask/permission-controller": "^13.1.
|
|
62
|
+
"@metamask/messenger": "^2.0.0",
|
|
63
|
+
"@metamask/permission-controller": "^13.1.1",
|
|
64
64
|
"@metamask/rpc-errors": "^7.0.3",
|
|
65
|
-
"@metamask/snaps-controllers": "^
|
|
66
|
-
"@metamask/snaps-execution-environments": "^11.1.
|
|
67
|
-
"@metamask/snaps-rpc-methods": "^
|
|
68
|
-
"@metamask/snaps-sdk": "^11.
|
|
69
|
-
"@metamask/snaps-utils": "^12.
|
|
70
|
-
"@metamask/superstruct": "^3.
|
|
65
|
+
"@metamask/snaps-controllers": "^21.0.0",
|
|
66
|
+
"@metamask/snaps-execution-environments": "^11.1.1",
|
|
67
|
+
"@metamask/snaps-rpc-methods": "^17.1.0",
|
|
68
|
+
"@metamask/snaps-sdk": "^11.2.0",
|
|
69
|
+
"@metamask/snaps-utils": "^12.3.0",
|
|
70
|
+
"@metamask/superstruct": "^3.3.0",
|
|
71
71
|
"@metamask/utils": "^11.11.0",
|
|
72
72
|
"@reduxjs/toolkit": "^1.9.5",
|
|
73
73
|
"ethers": "^6.16.0",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@lavamoat/allow-scripts": "^4.0.0",
|
|
82
|
-
"@metamask/auto-changelog": "^6.1.
|
|
82
|
+
"@metamask/auto-changelog": "^6.1.1",
|
|
83
83
|
"@ts-bridge/cli": "^0.6.1",
|
|
84
84
|
"@types/express": "^5.0.1",
|
|
85
85
|
"@types/jest": "^27.5.1",
|