UNPKG

@metamask/snaps-simulation

Version:

A simulation framework for MetaMask Snaps, enabling headless testing of Snaps in a controlled environment

1 lines 2.6 kB
{"version":3,"file":"get-snap.cjs","sourceRoot":"","sources":["../../../src/methods/hooks/get-snap.ts"],"names":[],"mappings":";;;AAEA,uDAAmD;AAGnD;;;;;;;GAOG;AACH,SAAgB,wBAAwB,CAAC,eAAwB,IAAI;IACnE,OAAO,CAAC,OAAe,EAAQ,EAAE;QAC/B,0EAA0E;QAC1E,oDAAoD;QACpD,OAAO;YACL,EAAE,EAAE,gCAA0C;YAC9C,OAAO,EAAE,OAAwB;YACjC,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,wBAAU,CAAC,OAAO;YAC1B,cAAc,EAAE,EAAE;YAClB,kBAAkB,EAAE,EAAE;YACtB,UAAU,EAAE,EAAE;YACd,QAAQ,EAAE;gBACR,OAAO,EAAE,OAAwB;gBACjC,YAAY,EAAE,WAAW;gBACzB,WAAW,EAAE,sCAAsC;gBACnD,UAAU,EAAE;oBACV,IAAI,EAAE,KAAK;oBACX,GAAG,EAAE,uCAAuC;iBAC7C;gBACD,MAAM,EAAE;oBACN,MAAM,EAAE,QAAQ;oBAChB,QAAQ,EAAE;wBACR,GAAG,EAAE;4BACH,QAAQ,EAAE,eAAe;4BACzB,WAAW,EAAE,4BAA4B;4BACzC,QAAQ,EAAE,4BAA4B;yBACvC;qBACF;iBACF;gBACD,kBAAkB,EAAE,EAAE;gBACtB,eAAe,EAAE,KAAK;aACvB;YACD,YAAY;SACb,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AArCD,4DAqCC","sourcesContent":["import type { SnapId } from '@metamask/snaps-sdk';\nimport type { Snap } from '@metamask/snaps-utils';\nimport { SnapStatus } from '@metamask/snaps-utils';\nimport type { SemVerVersion } from '@metamask/utils';\n\n/**\n * Get a method that gets a Snap by its ID.\n *\n * @param preinstalled - Whether the Snap is preinstalled. If `true`, the Snap\n * will be returned as a preinstalled Snap.\n * @returns A method that gets a Snap by its ID. It will always return a mock\n * Snap for simulation purposes.\n */\nexport function getGetSnapImplementation(preinstalled: boolean = true) {\n return (_snapId: string): Snap => {\n // This is a mock Snap for simulation purposes. Most of the fields are not\n // actually used, but returned for type-safety sake.\n return {\n id: 'npm:@metamask/snaps-simulation' as SnapId,\n version: '0.1.0' as SemVerVersion,\n enabled: true,\n blocked: false,\n status: SnapStatus.Running,\n versionHistory: [],\n initialPermissions: {},\n sourceCode: '',\n manifest: {\n version: '0.1.0' as SemVerVersion,\n proposedName: 'Test Snap',\n description: 'A test Snap for simulation purposes.',\n repository: {\n type: 'git',\n url: 'https://github.com/MetaMask/snaps.git',\n },\n source: {\n shasum: 'unused',\n location: {\n npm: {\n filePath: 'dist/index.js',\n packageName: '@metamask/snaps-simulation',\n registry: 'https://registry.npmjs.org',\n },\n },\n },\n initialPermissions: {},\n manifestVersion: '0.1',\n },\n preinstalled,\n };\n };\n}\n"]}