@metamask/snaps-jest 8.1.3 → 8.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 +19 -1
- package/README.md +2 -2
- package/dist/chunk-24CGIQLL.mjs +30 -0
- package/dist/chunk-24CGIQLL.mjs.map +1 -0
- package/dist/{chunk-T2PHS5FY.js → chunk-2RJYSYUB.js} +2 -2
- package/dist/chunk-2RJYSYUB.js.map +1 -0
- package/dist/{chunk-KNJNL723.mjs → chunk-3J2IBWXV.mjs} +2 -2
- package/dist/{chunk-EDFQDZNY.js → chunk-3NP6BDGK.js} +50 -17
- package/dist/chunk-3NP6BDGK.js.map +1 -0
- package/dist/{chunk-AFA4KKWW.mjs → chunk-6JPBXAHM.mjs} +250 -47
- package/dist/chunk-6JPBXAHM.mjs.map +1 -0
- package/dist/{chunk-VXPCUDBI.js → chunk-6V6MFT67.js} +8 -6
- package/dist/chunk-6V6MFT67.js.map +1 -0
- package/dist/{chunk-6V5GEUDO.mjs → chunk-7PCHIR6O.mjs} +7 -37
- package/dist/chunk-7PCHIR6O.mjs.map +1 -0
- package/dist/{chunk-2OHD2VKS.js → chunk-AMAL4SJH.js} +11 -37
- package/dist/chunk-AMAL4SJH.js.map +1 -0
- package/dist/{chunk-HOI6FPLR.mjs → chunk-C26TYXXD.mjs} +9 -9
- package/dist/chunk-C26TYXXD.mjs.map +1 -0
- package/dist/{chunk-K55LIE3W.mjs → chunk-CACRY3TX.mjs} +3 -3
- package/dist/{chunk-PZDTZGSI.js → chunk-D653LBAY.js} +1 -1
- package/dist/chunk-D653LBAY.js.map +1 -0
- package/dist/chunk-DUVKGPX5.js +509 -0
- package/dist/chunk-DUVKGPX5.js.map +1 -0
- package/dist/{chunk-IH7UNS5A.mjs → chunk-G333FBBL.mjs} +6 -4
- package/dist/chunk-G333FBBL.mjs.map +1 -0
- package/dist/{chunk-YNUVT3HC.js → chunk-GLPGOEVE.js} +4 -4
- package/dist/chunk-GLPGOEVE.js.map +1 -0
- package/dist/chunk-IWJ4HKDR.mjs +50 -0
- package/dist/chunk-IWJ4HKDR.mjs.map +1 -0
- package/dist/{chunk-WMLSD6B5.js → chunk-K7MK6LQU.js} +3 -3
- package/dist/{chunk-B73P64TE.mjs → chunk-KOPPL55J.mjs} +2 -2
- package/dist/chunk-KOPPL55J.mjs.map +1 -0
- package/dist/{chunk-XKJHFUHE.js → chunk-KPRLFCKD.js} +4 -2
- package/dist/chunk-KPRLFCKD.js.map +1 -0
- package/dist/{chunk-3FDEYMQU.js → chunk-LPMHPAZK.js} +54 -14
- package/dist/chunk-LPMHPAZK.js.map +1 -0
- package/dist/{chunk-GG2BCPQH.mjs → chunk-LSKT2AUS.mjs} +5 -3
- package/dist/chunk-LSKT2AUS.mjs.map +1 -0
- package/dist/{chunk-6KXCBUNZ.mjs → chunk-LVNNGMJ2.mjs} +3 -1
- package/dist/{chunk-6KXCBUNZ.mjs.map → chunk-LVNNGMJ2.mjs.map} +1 -1
- package/dist/{chunk-TMAWGVZP.mjs → chunk-OHRFO2BL.mjs} +7 -7
- package/dist/chunk-OHRFO2BL.mjs.map +1 -0
- package/dist/{chunk-JXAJWUVZ.js → chunk-OO6IVUCV.js} +5 -5
- package/dist/{chunk-3M4GRUMH.mjs → chunk-ORR7AE5X.mjs} +2 -2
- package/dist/{chunk-UPR3PTSA.mjs → chunk-PDOVVC74.mjs} +10 -36
- package/dist/chunk-PDOVVC74.mjs.map +1 -0
- package/dist/{chunk-E2BYTLOT.mjs → chunk-Q3I6P2ZF.mjs} +43 -10
- package/dist/chunk-Q3I6P2ZF.mjs.map +1 -0
- package/dist/chunk-QRVFWATH.mjs +14 -0
- package/dist/chunk-QRVFWATH.mjs.map +1 -0
- package/dist/{chunk-MBQHVBLA.js → chunk-QYHQ2WWX.js} +5 -5
- package/dist/chunk-QYHQ2WWX.js.map +1 -0
- package/dist/{chunk-XWGECIXI.js → chunk-RJNNNCZJ.js} +3 -3
- package/dist/{chunk-U3DVRTS2.mjs → chunk-ROCGQYSK.mjs} +46 -6
- package/dist/chunk-ROCGQYSK.mjs.map +1 -0
- package/dist/chunk-SNXRXX2O.js +30 -0
- package/dist/chunk-SNXRXX2O.js.map +1 -0
- package/dist/chunk-SW65QYFV.js +50 -0
- package/dist/chunk-SW65QYFV.js.map +1 -0
- package/dist/{chunk-44ARQBXS.js → chunk-WZ57PU2K.js} +6 -4
- package/dist/chunk-WZ57PU2K.js.map +1 -0
- package/dist/chunk-XP4YGQJA.js +14 -0
- package/dist/chunk-XP4YGQJA.js.map +1 -0
- package/dist/{chunk-KQBJQLZG.js → chunk-Y2U3ZPCK.js} +15 -45
- package/dist/chunk-Y2U3ZPCK.js.map +1 -0
- package/dist/{chunk-74TIKA2T.mjs → chunk-ZJQSGRNK.mjs} +1 -1
- package/dist/chunk-ZJQSGRNK.mjs.map +1 -0
- package/dist/environment.js +17 -17
- package/dist/environment.mjs +16 -16
- package/dist/helpers.js +30 -16
- package/dist/helpers.mjs +29 -15
- package/dist/index.js +32 -18
- package/dist/index.mjs +31 -17
- package/dist/internals/index.js +33 -21
- package/dist/internals/index.mjs +35 -23
- package/dist/internals/request.js +15 -15
- package/dist/internals/request.mjs +14 -14
- package/dist/internals/simulation/constants.js +4 -2
- package/dist/internals/simulation/constants.mjs +3 -1
- package/dist/internals/simulation/controllers.js +7 -7
- package/dist/internals/simulation/controllers.mjs +6 -6
- package/dist/internals/simulation/files.js +8 -2
- package/dist/internals/simulation/files.mjs +7 -1
- package/dist/internals/simulation/index.js +31 -19
- package/dist/internals/simulation/index.mjs +33 -21
- package/dist/internals/simulation/interface.js +15 -4
- package/dist/internals/simulation/interface.mjs +16 -5
- package/dist/internals/simulation/methods/hooks/get-preferences.js +8 -0
- package/dist/internals/simulation/methods/hooks/get-preferences.mjs +8 -0
- package/dist/internals/simulation/methods/hooks/index.js +5 -5
- package/dist/internals/simulation/methods/hooks/index.mjs +8 -8
- package/dist/internals/simulation/methods/hooks/notifications.js +2 -2
- package/dist/internals/simulation/methods/hooks/notifications.mjs +2 -2
- package/dist/internals/simulation/methods/hooks/request-user-approval.js +14 -0
- package/dist/internals/simulation/methods/hooks/request-user-approval.mjs +14 -0
- package/dist/internals/simulation/methods/hooks/state.js +2 -2
- package/dist/internals/simulation/methods/hooks/state.mjs +2 -2
- package/dist/internals/simulation/methods/index.js +6 -6
- package/dist/internals/simulation/methods/index.mjs +5 -5
- package/dist/internals/simulation/methods/specifications.js +6 -6
- package/dist/internals/simulation/methods/specifications.mjs +5 -5
- package/dist/internals/simulation/middleware/engine.js +3 -3
- package/dist/internals/simulation/middleware/engine.mjs +2 -2
- package/dist/internals/simulation/middleware/index.js +3 -3
- package/dist/internals/simulation/middleware/index.mjs +2 -2
- package/dist/internals/simulation/options.js +3 -3
- package/dist/internals/simulation/options.mjs +2 -2
- package/dist/internals/simulation/simulation.js +13 -12
- package/dist/internals/simulation/simulation.mjs +12 -11
- package/dist/internals/simulation/store/index.js +3 -3
- package/dist/internals/simulation/store/index.mjs +2 -2
- package/dist/internals/simulation/store/store.js +3 -3
- package/dist/internals/simulation/store/store.mjs +2 -2
- package/dist/internals/simulation/store/ui.js +2 -2
- package/dist/internals/simulation/store/ui.mjs +1 -1
- package/dist/internals/structs.js +2 -2
- package/dist/internals/structs.mjs +1 -1
- package/dist/matchers.js +16 -18
- package/dist/matchers.mjs +15 -17
- package/dist/options.js +2 -2
- package/dist/options.mjs +1 -1
- package/dist/setup.js +15 -15
- package/dist/setup.mjs +15 -15
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/helpers.d.ts +43 -1
- package/dist/types/internals/request.d.ts +3 -2
- package/dist/types/internals/server.d.ts +1 -1
- package/dist/types/internals/simulation/constants.d.ts +4 -0
- package/dist/types/internals/simulation/controllers.d.ts +4 -4
- package/dist/types/internals/simulation/files.d.ts +36 -0
- package/dist/types/internals/simulation/interface.d.ts +70 -8
- package/dist/types/internals/simulation/methods/hooks/get-preferences.d.ts +13 -0
- package/dist/types/internals/simulation/methods/hooks/index.d.ts +2 -2
- package/dist/types/internals/simulation/methods/hooks/request-user-approval.d.ts +15 -0
- package/dist/types/internals/simulation/methods/specifications.d.ts +2 -2
- package/dist/types/internals/simulation/middleware/engine.d.ts +1 -1
- package/dist/types/internals/simulation/middleware/internal-methods/accounts.d.ts +1 -1
- package/dist/types/internals/simulation/middleware/internal-methods/middleware.d.ts +1 -1
- package/dist/types/internals/simulation/options.d.ts +10 -8
- package/dist/types/internals/simulation/simulation.d.ts +8 -5
- package/dist/types/internals/simulation/store/mocks.d.ts +2 -2
- package/dist/types/internals/simulation/store/notifications.d.ts +2 -2
- package/dist/types/internals/simulation/store/state.d.ts +1 -1
- package/dist/types/internals/simulation/store/store.d.ts +4 -4
- package/dist/types/internals/simulation/store/ui.d.ts +4 -3
- package/dist/types/internals/structs.d.ts +41 -41
- package/dist/types/matchers.d.ts +0 -10
- package/dist/types/options.d.ts +7 -7
- package/dist/types/types.d.ts +91 -20
- package/package.json +18 -16
- package/dist/chunk-265BMFM5.js +0 -13
- package/dist/chunk-265BMFM5.js.map +0 -1
- package/dist/chunk-2OHD2VKS.js.map +0 -1
- package/dist/chunk-3FDEYMQU.js.map +0 -1
- package/dist/chunk-44ARQBXS.js.map +0 -1
- package/dist/chunk-6V5GEUDO.mjs.map +0 -1
- package/dist/chunk-74TIKA2T.mjs.map +0 -1
- package/dist/chunk-AFA4KKWW.mjs.map +0 -1
- package/dist/chunk-B73P64TE.mjs.map +0 -1
- package/dist/chunk-E2BYTLOT.mjs.map +0 -1
- package/dist/chunk-EDFQDZNY.js.map +0 -1
- package/dist/chunk-GG2BCPQH.mjs.map +0 -1
- package/dist/chunk-HOI6FPLR.mjs.map +0 -1
- package/dist/chunk-IH7UNS5A.mjs.map +0 -1
- package/dist/chunk-KQBJQLZG.js.map +0 -1
- package/dist/chunk-KSIBNOB2.mjs +0 -13
- package/dist/chunk-KSIBNOB2.mjs.map +0 -1
- package/dist/chunk-MBQHVBLA.js.map +0 -1
- package/dist/chunk-ORO3T6BU.mjs +0 -24
- package/dist/chunk-ORO3T6BU.mjs.map +0 -1
- package/dist/chunk-PZDTZGSI.js.map +0 -1
- package/dist/chunk-R55KAAM4.js +0 -306
- package/dist/chunk-R55KAAM4.js.map +0 -1
- package/dist/chunk-RAMAN5RM.js +0 -24
- package/dist/chunk-RAMAN5RM.js.map +0 -1
- package/dist/chunk-T2PHS5FY.js.map +0 -1
- package/dist/chunk-TBDYQSRT.mjs +0 -16
- package/dist/chunk-TBDYQSRT.mjs.map +0 -1
- package/dist/chunk-TMAWGVZP.mjs.map +0 -1
- package/dist/chunk-TVD4SWH7.js +0 -16
- package/dist/chunk-TVD4SWH7.js.map +0 -1
- package/dist/chunk-U3DVRTS2.mjs.map +0 -1
- package/dist/chunk-UPR3PTSA.mjs.map +0 -1
- package/dist/chunk-VXPCUDBI.js.map +0 -1
- package/dist/chunk-XKJHFUHE.js.map +0 -1
- package/dist/chunk-YNUVT3HC.js.map +0 -1
- package/dist/internals/simulation/methods/hooks/get-locale.js +0 -8
- package/dist/internals/simulation/methods/hooks/get-locale.mjs +0 -8
- package/dist/internals/simulation/methods/hooks/show-dialog.js +0 -14
- package/dist/internals/simulation/methods/hooks/show-dialog.mjs +0 -14
- package/dist/types/internals/simulation/methods/hooks/get-locale.d.ts +0 -9
- package/dist/types/internals/simulation/methods/hooks/show-dialog.d.ts +0 -9
- /package/dist/{chunk-KNJNL723.mjs.map → chunk-3J2IBWXV.mjs.map} +0 -0
- /package/dist/{chunk-K55LIE3W.mjs.map → chunk-CACRY3TX.mjs.map} +0 -0
- /package/dist/{chunk-WMLSD6B5.js.map → chunk-K7MK6LQU.js.map} +0 -0
- /package/dist/{chunk-JXAJWUVZ.js.map → chunk-OO6IVUCV.js.map} +0 -0
- /package/dist/{chunk-3M4GRUMH.mjs.map → chunk-ORR7AE5X.mjs.map} +0 -0
- /package/dist/{chunk-XWGECIXI.js.map → chunk-RJNNNCZJ.js.map} +0 -0
- /package/dist/internals/simulation/methods/hooks/{get-locale.js.map → get-preferences.js.map} +0 -0
- /package/dist/internals/simulation/methods/hooks/{get-locale.mjs.map → get-preferences.mjs.map} +0 -0
- /package/dist/internals/simulation/methods/hooks/{show-dialog.js.map → request-user-approval.js.map} +0 -0
- /package/dist/internals/simulation/methods/hooks/{show-dialog.mjs.map → request-user-approval.mjs.map} +0 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// src/internals/simulation/files.ts
|
|
2
|
+
import { AuxiliaryFileEncoding } from "@metamask/snaps-sdk";
|
|
3
|
+
import { encodeAuxiliaryFile, normalizeRelative } from "@metamask/snaps-utils";
|
|
4
|
+
import { bytesToBase64 } from "@metamask/utils";
|
|
5
|
+
import { readFile, stat } from "fs/promises";
|
|
6
|
+
import mime from "mime";
|
|
7
|
+
import { basename, extname, resolve } from "path";
|
|
8
|
+
async function getSnapFile(files, path, encoding = AuxiliaryFileEncoding.Base64) {
|
|
9
|
+
const normalizedPath = normalizeRelative(path);
|
|
10
|
+
const base64 = files.find((file) => file.path === normalizedPath)?.toString("base64");
|
|
11
|
+
if (!base64) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return await encodeAuxiliaryFile(base64, encoding);
|
|
15
|
+
}
|
|
16
|
+
function getContentType(extension) {
|
|
17
|
+
return mime.getType(extension) ?? "application/octet-stream";
|
|
18
|
+
}
|
|
19
|
+
async function getFileSize(file) {
|
|
20
|
+
if (typeof file === "string") {
|
|
21
|
+
const { size } = await stat(resolve(process.cwd(), file));
|
|
22
|
+
return size;
|
|
23
|
+
}
|
|
24
|
+
return file.length;
|
|
25
|
+
}
|
|
26
|
+
async function getFileToUpload(file, { fileName, contentType } = {}) {
|
|
27
|
+
if (typeof file === "string") {
|
|
28
|
+
const buffer = await readFile(resolve(process.cwd(), file));
|
|
29
|
+
return {
|
|
30
|
+
name: fileName ?? basename(file),
|
|
31
|
+
size: buffer.byteLength,
|
|
32
|
+
contentType: contentType ?? getContentType(extname(file)),
|
|
33
|
+
contents: bytesToBase64(buffer)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
name: fileName ?? "",
|
|
38
|
+
size: file.length,
|
|
39
|
+
contentType: contentType ?? "application/octet-stream",
|
|
40
|
+
contents: bytesToBase64(file)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
getSnapFile,
|
|
46
|
+
getContentType,
|
|
47
|
+
getFileSize,
|
|
48
|
+
getFileToUpload
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=chunk-IWJ4HKDR.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/internals/simulation/files.ts"],"sourcesContent":["import type { File } from '@metamask/snaps-sdk';\nimport { AuxiliaryFileEncoding } from '@metamask/snaps-sdk';\nimport type { VirtualFile } from '@metamask/snaps-utils';\nimport { encodeAuxiliaryFile, normalizeRelative } from '@metamask/snaps-utils';\nimport { bytesToBase64 } from '@metamask/utils';\nimport { readFile, stat } from 'fs/promises';\nimport mime from 'mime';\nimport { basename, extname, resolve } from 'path';\n\nimport type { FileOptions } from '../../types';\n\n/**\n * Get a statically defined Snap file from an array of files.\n *\n * @param files - The Snap files.\n * @param path - The file path.\n * @param encoding - The requested file encoding.\n * @returns The file in the requested encoding if found, otherwise null.\n */\nexport async function getSnapFile(\n files: VirtualFile[],\n path: string,\n encoding: AuxiliaryFileEncoding = AuxiliaryFileEncoding.Base64,\n) {\n const normalizedPath = normalizeRelative(path);\n const base64 = files\n .find((file) => file.path === normalizedPath)\n ?.toString('base64');\n\n if (!base64) {\n return null;\n }\n\n return await encodeAuxiliaryFile(base64, encoding);\n}\n\n/**\n * Get the content type of a file based on its extension.\n *\n * @param extension - The file extension.\n * @returns The content type of the file. If the content type cannot be inferred\n * from the extension, `application/octet-stream` is returned.\n */\nexport function getContentType(extension: string) {\n return mime.getType(extension) ?? 'application/octet-stream';\n}\n\n/**\n * Get the size of a file, from a file path or a `Uint8Array`.\n *\n * @param file - The file to get the size of. This can be a path to a file or a\n * `Uint8Array` containing the file contents. If this is a path, the file is\n * resolved relative to the current working directory.\n * @returns The size of the file in bytes.\n */\nexport async function getFileSize(file: string | Uint8Array) {\n if (typeof file === 'string') {\n const { size } = await stat(resolve(process.cwd(), file));\n return size;\n }\n\n return file.length;\n}\n\n/**\n * Get a file object to upload, from a file path or a `Uint8Array`, with an\n * optional file name and content type.\n *\n * @param file - The file to upload. This can be a path to a file or a\n * `Uint8Array` containing the file contents. If this is a path, the file is\n * resolved relative to the current working directory.\n * @param options - The file options.\n * @param options.fileName - The name of the file. By default, this is\n * inferred from the file path if it's a path, and defaults to an empty string\n * if it's a `Uint8Array`.\n * @param options.contentType - The content type of the file. By default, this\n * is inferred from the file name if it's a path, and defaults to\n * `application/octet-stream` if it's a `Uint8Array` or the content type\n * cannot be inferred from the file name.\n */\nexport async function getFileToUpload(\n file: string | Uint8Array,\n { fileName, contentType }: FileOptions = {},\n): Promise<File> {\n if (typeof file === 'string') {\n const buffer = await readFile(resolve(process.cwd(), file));\n\n return {\n name: fileName ?? basename(file),\n size: buffer.byteLength,\n contentType: contentType ?? getContentType(extname(file)),\n contents: bytesToBase64(buffer),\n };\n }\n\n return {\n name: fileName ?? '',\n size: file.length,\n contentType: contentType ?? 'application/octet-stream',\n contents: bytesToBase64(file),\n };\n}\n"],"mappings":";AACA,SAAS,6BAA6B;AAEtC,SAAS,qBAAqB,yBAAyB;AACvD,SAAS,qBAAqB;AAC9B,SAAS,UAAU,YAAY;AAC/B,OAAO,UAAU;AACjB,SAAS,UAAU,SAAS,eAAe;AAY3C,eAAsB,YACpB,OACA,MACA,WAAkC,sBAAsB,QACxD;AACA,QAAM,iBAAiB,kBAAkB,IAAI;AAC7C,QAAM,SAAS,MACZ,KAAK,CAAC,SAAS,KAAK,SAAS,cAAc,GAC1C,SAAS,QAAQ;AAErB,MAAI,CAAC,QAAQ;AACX,WAAO;AAAA,EACT;AAEA,SAAO,MAAM,oBAAoB,QAAQ,QAAQ;AACnD;AASO,SAAS,eAAe,WAAmB;AAChD,SAAO,KAAK,QAAQ,SAAS,KAAK;AACpC;AAUA,eAAsB,YAAY,MAA2B;AAC3D,MAAI,OAAO,SAAS,UAAU;AAC5B,UAAM,EAAE,KAAK,IAAI,MAAM,KAAK,QAAQ,QAAQ,IAAI,GAAG,IAAI,CAAC;AACxD,WAAO;AAAA,EACT;AAEA,SAAO,KAAK;AACd;AAkBA,eAAsB,gBACpB,MACA,EAAE,UAAU,YAAY,IAAiB,CAAC,GAC3B;AACf,MAAI,OAAO,SAAS,UAAU;AAC5B,UAAM,SAAS,MAAM,SAAS,QAAQ,QAAQ,IAAI,GAAG,IAAI,CAAC;AAE1D,WAAO;AAAA,MACL,MAAM,YAAY,SAAS,IAAI;AAAA,MAC/B,MAAM,OAAO;AAAA,MACb,aAAa,eAAe,eAAe,QAAQ,IAAI,CAAC;AAAA,MACxD,UAAU,cAAc,MAAM;AAAA,IAChC;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM,YAAY;AAAA,IAClB,MAAM,KAAK;AAAA,IACX,aAAa,eAAe;AAAA,IAC5B,UAAU,cAAc,IAAI;AAAA,EAC9B;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkD653LBAYjs = require('./chunk-D653LBAY.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkLACTK6EOjs = require('./chunk-LACTK6EO.js');
|
|
@@ -22,7 +22,7 @@ function createStore({ state, unencryptedState }) {
|
|
|
22
22
|
mocks: _chunkLACTK6EOjs.mocksSlice.reducer,
|
|
23
23
|
notifications: _chunk2YE2P5BZjs.notificationsSlice.reducer,
|
|
24
24
|
state: _chunkLBC2OGSNjs.stateSlice.reducer,
|
|
25
|
-
ui:
|
|
25
|
+
ui: _chunkD653LBAYjs.uiSlice.reducer
|
|
26
26
|
},
|
|
27
27
|
middleware: (getDefaultMiddleware) => getDefaultMiddleware({ thunk: false }).concat(sagaMiddleware)
|
|
28
28
|
});
|
|
@@ -51,4 +51,4 @@ function createStore({ state, unencryptedState }) {
|
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
exports.createStore = createStore;
|
|
54
|
-
//# sourceMappingURL=chunk-
|
|
54
|
+
//# sourceMappingURL=chunk-K7MK6LQU.js.map
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
object,
|
|
8
8
|
string,
|
|
9
9
|
type
|
|
10
|
-
} from "superstruct";
|
|
10
|
+
} from "@metamask/superstruct";
|
|
11
11
|
var SnapsEnvironmentOptionsStruct = type({
|
|
12
12
|
server: defaulted(
|
|
13
13
|
object({
|
|
@@ -25,4 +25,4 @@ function getOptions(testEnvironmentOptions) {
|
|
|
25
25
|
export {
|
|
26
26
|
getOptions
|
|
27
27
|
};
|
|
28
|
-
//# sourceMappingURL=chunk-
|
|
28
|
+
//# sourceMappingURL=chunk-KOPPL55J.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/options.ts"],"sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport {\n boolean,\n create,\n defaulted,\n number,\n object,\n string,\n type,\n} from '@metamask/superstruct';\n\nconst SnapsEnvironmentOptionsStruct = type({\n server: defaulted(\n object({\n enabled: defaulted(boolean(), true),\n port: defaulted(number(), 0),\n root: defaulted(string(), process.cwd()),\n }),\n {},\n ),\n});\n\n/**\n * The options for the environment. These can be specified in the Jest\n * configuration under `testEnvironmentOptions`.\n *\n * @example\n * {\n * \"testEnvironment\": \"@metamask/snaps-jest\",\n * \"testEnvironmentOptions\": {\n * \"executionEnvironmentUrl\": \"http://localhost:8080\",\n * \"server\": {\n * \"port\": 8080,\n * /* ... *\\/\n * }\n * }\n * }\n * @property server - The options for the built-in HTTP server.\n * @property server.enabled - Whether to run the built-in HTTP server. Defaults\n * to `true`.\n * @property server.port - The port to use for the built-in HTTP server. If this\n * is not provided, a random available port will be used.\n * @property server.root - The root directory to serve from the built-in HTTP\n * server. Defaults to the current working directory. This is assumed to be the\n * directory containing the snap manifest and `dist` files. If this is a\n * relative path, it will be resolved relative to the current working directory.\n */\nexport type SnapsEnvironmentOptions = Infer<\n typeof SnapsEnvironmentOptionsStruct\n>;\n\n/**\n * Get the environment options. This validates the options, and returns the\n * default options if none are provided.\n *\n * @param testEnvironmentOptions - The test environment options as defined in\n * the Jest configuration.\n * @returns The environment options.\n */\nexport function getOptions(testEnvironmentOptions: Record<string, unknown>) {\n return create(testEnvironmentOptions, SnapsEnvironmentOptionsStruct);\n}\n"],"mappings":";AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,IAAM,gCAAgC,KAAK;AAAA,EACzC,QAAQ;AAAA,IACN,OAAO;AAAA,MACL,SAAS,UAAU,QAAQ,GAAG,IAAI;AAAA,MAClC,MAAM,UAAU,OAAO,GAAG,CAAC;AAAA,MAC3B,MAAM,UAAU,OAAO,GAAG,QAAQ,IAAI,CAAC;AAAA,IACzC,CAAC;AAAA,IACD,CAAC;AAAA,EACH;AACF,CAAC;AAuCM,SAAS,WAAW,wBAAiD;AAC1E,SAAO,OAAO,wBAAwB,6BAA6B;AACrE;","names":[]}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/internals/simulation/constants.ts
|
|
2
2
|
var DEFAULT_SRP = "test test test test test test test test test test test ball";
|
|
3
3
|
var DEFAULT_LOCALE = "en";
|
|
4
|
+
var DEFAULT_CURRENCY = "usd";
|
|
4
5
|
var DEFAULT_JSON_RPC_ENDPOINT = "https://cloudflare-eth.com/";
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
exports.DEFAULT_SRP = DEFAULT_SRP; exports.DEFAULT_LOCALE = DEFAULT_LOCALE; exports.DEFAULT_CURRENCY = DEFAULT_CURRENCY; exports.DEFAULT_JSON_RPC_ENDPOINT = DEFAULT_JSON_RPC_ENDPOINT;
|
|
13
|
+
//# sourceMappingURL=chunk-KPRLFCKD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/internals/simulation/constants.ts"],"names":[],"mappings":";AAIO,IAAM,cACX;AAKK,IAAM,iBAAiB;AAKvB,IAAM,mBAAmB;AAKzB,IAAM,4BAA4B","sourcesContent":["/**\n * A secret recovery phrase that is used for testing purposes. Do not use this\n * to store any real funds!\n */\nexport const DEFAULT_SRP =\n 'test test test test test test test test test test test ball';\n\n/**\n * The default locale.\n */\nexport const DEFAULT_LOCALE = 'en';\n\n/**\n * The default currency.\n */\nexport const DEFAULT_CURRENCY = 'usd';\n\n/**\n * The default JSON-RPC endpoint for Ethereum requests.\n */\nexport const DEFAULT_JSON_RPC_ENDPOINT = 'https://cloudflare-eth.com/';\n"]}
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
var _chunk2JTGBHPRjs = require('./chunk-2JTGBHPR.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkAMAL4SJHjs = require('./chunk-AMAL4SJH.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkDUVKGPX5js = require('./chunk-DUVKGPX5.js');
|
|
7
10
|
|
|
8
11
|
|
|
9
12
|
var _chunkTZB4LBT7js = require('./chunk-TZB4LBT7.js');
|
|
@@ -12,16 +15,22 @@ var _chunkTZB4LBT7js = require('./chunk-TZB4LBT7.js');
|
|
|
12
15
|
|
|
13
16
|
|
|
14
17
|
|
|
15
|
-
var
|
|
18
|
+
var _chunkGLPGOEVEjs = require('./chunk-GLPGOEVE.js');
|
|
16
19
|
|
|
17
20
|
|
|
18
21
|
|
|
19
22
|
var _chunkLACTK6EOjs = require('./chunk-LACTK6EO.js');
|
|
20
23
|
|
|
21
24
|
// src/helpers.ts
|
|
25
|
+
var _snapssdk = require('@metamask/snaps-sdk');
|
|
22
26
|
var _snapsutils = require('@metamask/snaps-utils');
|
|
27
|
+
var _superstruct = require('@metamask/superstruct');
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
23
33
|
var _utils = require('@metamask/utils');
|
|
24
|
-
var _superstruct = require('superstruct');
|
|
25
34
|
var log = _utils.createModuleLogger.call(void 0, _chunkTZB4LBT7js.rootLogger, "helpers");
|
|
26
35
|
function getOptions(snapId, options) {
|
|
27
36
|
if (typeof snapId === "object") {
|
|
@@ -30,7 +39,31 @@ function getOptions(snapId, options) {
|
|
|
30
39
|
return [snapId, options];
|
|
31
40
|
}
|
|
32
41
|
function assertIsResponseWithInterface(response) {
|
|
33
|
-
_utils.assertStruct.call(void 0, response,
|
|
42
|
+
_utils.assertStruct.call(void 0, response, _chunkGLPGOEVEjs.SnapResponseWithInterfaceStruct);
|
|
43
|
+
}
|
|
44
|
+
function assertIsAlertDialog(ui) {
|
|
45
|
+
_utils.assert.call(void 0, _utils.hasProperty.call(void 0, ui, "type") && ui.type === _snapssdk.DialogType.Alert);
|
|
46
|
+
}
|
|
47
|
+
function assertIsConfirmationDialog(ui) {
|
|
48
|
+
_utils.assert.call(void 0, _utils.hasProperty.call(void 0, ui, "type") && ui.type === _snapssdk.DialogType.Confirmation);
|
|
49
|
+
}
|
|
50
|
+
function assertIsPromptDialog(ui) {
|
|
51
|
+
_utils.assert.call(void 0, _utils.hasProperty.call(void 0, ui, "type") && ui.type === _snapssdk.DialogType.Prompt);
|
|
52
|
+
}
|
|
53
|
+
function assertIsCustomDialog(ui) {
|
|
54
|
+
_utils.assert.call(void 0, !_utils.hasProperty.call(void 0, ui, "type"));
|
|
55
|
+
}
|
|
56
|
+
function assertCustomDialogHasFooter(ui) {
|
|
57
|
+
const footer = _chunkDUVKGPX5js.getElementByType.call(void 0, ui.content, "Footer");
|
|
58
|
+
_utils.assert.call(void 0, footer && _snapsutils.getJsxChildren.call(void 0, footer).length === 2);
|
|
59
|
+
}
|
|
60
|
+
function assertCustomDialogHasPartialFooter(ui) {
|
|
61
|
+
const footer = _chunkDUVKGPX5js.getElementByType.call(void 0, ui.content, "Footer");
|
|
62
|
+
_utils.assert.call(void 0, footer && _snapsutils.getJsxChildren.call(void 0, footer).length === 1);
|
|
63
|
+
}
|
|
64
|
+
function assertCustomDialogHasNoFooter(ui) {
|
|
65
|
+
const footer = _chunkDUVKGPX5js.getElementByType.call(void 0, ui.content, "Footer");
|
|
66
|
+
_utils.assert.call(void 0, !footer);
|
|
34
67
|
}
|
|
35
68
|
async function installSnap(snapId, options = {}) {
|
|
36
69
|
const resolvedOptions = getOptions(snapId, options);
|
|
@@ -47,8 +80,8 @@ async function installSnap(snapId, options = {}) {
|
|
|
47
80
|
origin: transactionOrigin,
|
|
48
81
|
chainId,
|
|
49
82
|
...transaction
|
|
50
|
-
} = _superstruct.create.call(void 0, request,
|
|
51
|
-
const response = await
|
|
83
|
+
} = _superstruct.create.call(void 0, request, _chunkGLPGOEVEjs.TransactionOptionsStruct);
|
|
84
|
+
const response = await _chunkAMAL4SJHjs.handleRequest.call(void 0, {
|
|
52
85
|
snapId: installedSnapId,
|
|
53
86
|
store,
|
|
54
87
|
executionService,
|
|
@@ -69,7 +102,7 @@ async function installSnap(snapId, options = {}) {
|
|
|
69
102
|
};
|
|
70
103
|
const onCronjob = (request) => {
|
|
71
104
|
log("Running cronjob %o.", options);
|
|
72
|
-
return
|
|
105
|
+
return _chunkAMAL4SJHjs.handleRequest.call(void 0, {
|
|
73
106
|
snapId: installedSnapId,
|
|
74
107
|
store,
|
|
75
108
|
executionService,
|
|
@@ -82,7 +115,7 @@ async function installSnap(snapId, options = {}) {
|
|
|
82
115
|
return {
|
|
83
116
|
request: (request) => {
|
|
84
117
|
log("Sending request %o.", request);
|
|
85
|
-
return
|
|
118
|
+
return _chunkAMAL4SJHjs.handleRequest.call(void 0, {
|
|
86
119
|
snapId: installedSnapId,
|
|
87
120
|
store,
|
|
88
121
|
executionService,
|
|
@@ -98,9 +131,9 @@ async function installSnap(snapId, options = {}) {
|
|
|
98
131
|
log("Requesting signature %o.", request);
|
|
99
132
|
const { origin: signatureOrigin, ...signature } = _superstruct.create.call(void 0,
|
|
100
133
|
request,
|
|
101
|
-
|
|
134
|
+
_chunkGLPGOEVEjs.SignatureOptionsStruct
|
|
102
135
|
);
|
|
103
|
-
const response = await
|
|
136
|
+
const response = await _chunkAMAL4SJHjs.handleRequest.call(void 0, {
|
|
104
137
|
snapId: installedSnapId,
|
|
105
138
|
store,
|
|
106
139
|
executionService,
|
|
@@ -122,7 +155,7 @@ async function installSnap(snapId, options = {}) {
|
|
|
122
155
|
runCronjob: onCronjob,
|
|
123
156
|
onHomePage: async () => {
|
|
124
157
|
log("Rendering home page.");
|
|
125
|
-
const response = await
|
|
158
|
+
const response = await _chunkAMAL4SJHjs.handleRequest.call(void 0, {
|
|
126
159
|
snapId: installedSnapId,
|
|
127
160
|
store,
|
|
128
161
|
executionService,
|
|
@@ -138,7 +171,7 @@ async function installSnap(snapId, options = {}) {
|
|
|
138
171
|
},
|
|
139
172
|
mockJsonRpc(mock) {
|
|
140
173
|
log("Mocking JSON-RPC request %o.", mock);
|
|
141
|
-
const { method, result } = _superstruct.create.call(void 0, mock,
|
|
174
|
+
const { method, result } = _superstruct.create.call(void 0, mock, _chunkGLPGOEVEjs.JsonRpcMockOptionsStruct);
|
|
142
175
|
store.dispatch(_chunkLACTK6EOjs.addJsonRpcMock.call(void 0, { method, result }));
|
|
143
176
|
return {
|
|
144
177
|
unmock() {
|
|
@@ -159,5 +192,12 @@ async function installSnap(snapId, options = {}) {
|
|
|
159
192
|
|
|
160
193
|
|
|
161
194
|
|
|
162
|
-
|
|
163
|
-
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
exports.assertIsAlertDialog = assertIsAlertDialog; exports.assertIsConfirmationDialog = assertIsConfirmationDialog; exports.assertIsPromptDialog = assertIsPromptDialog; exports.assertIsCustomDialog = assertIsCustomDialog; exports.assertCustomDialogHasFooter = assertCustomDialogHasFooter; exports.assertCustomDialogHasPartialFooter = assertCustomDialogHasPartialFooter; exports.assertCustomDialogHasNoFooter = assertCustomDialogHasNoFooter; exports.installSnap = installSnap;
|
|
203
|
+
//# sourceMappingURL=chunk-LPMHPAZK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/helpers.ts"],"names":[],"mappings":"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","sourcesContent":["import type { AbstractExecutionService } from '@metamask/snaps-controllers';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { DialogType } from '@metamask/snaps-sdk';\nimport type { FooterElement } from '@metamask/snaps-sdk/jsx';\nimport { HandlerType, getJsxChildren, logInfo } from '@metamask/snaps-utils';\nimport { create } from '@metamask/superstruct';\nimport {\n assert,\n assertStruct,\n createModuleLogger,\n hasProperty,\n} from '@metamask/utils';\n\nimport {\n rootLogger,\n handleRequest,\n TransactionOptionsStruct,\n getEnvironment,\n JsonRpcMockOptionsStruct,\n SignatureOptionsStruct,\n SnapResponseWithInterfaceStruct,\n getElementByType,\n} from './internals';\nimport type { InstallSnapOptions } from './internals';\nimport {\n addJsonRpcMock,\n removeJsonRpcMock,\n} from './internals/simulation/store/mocks';\nimport type {\n SnapResponseWithInterface,\n CronjobOptions,\n JsonRpcMockOptions,\n Snap,\n SnapResponse,\n TransactionOptions,\n SnapInterface,\n SnapAlertInterface,\n SnapInterfaceActions,\n SnapConfirmationInterface,\n SnapPromptInterface,\n DefaultSnapInterface,\n DefaultSnapInterfaceWithFooter,\n DefaultSnapInterfaceWithPartialFooter,\n DefaultSnapInterfaceWithoutFooter,\n} from './types';\n\nconst log = createModuleLogger(rootLogger, 'helpers');\n\n/**\n * Get the options for {@link installSnap}.\n *\n * @param snapId - The ID of the Snap, or the options.\n * @param options - The options, if any.\n * @returns The options.\n */\nfunction getOptions<\n Service extends new (...args: any[]) => InstanceType<\n typeof AbstractExecutionService\n >,\n>(\n snapId: SnapId | Partial<InstallSnapOptions<Service>> | undefined,\n options: Partial<InstallSnapOptions<Service>>,\n): [SnapId | undefined, Partial<InstallSnapOptions<Service>>] {\n if (typeof snapId === 'object') {\n return [undefined, snapId];\n }\n\n return [snapId, options];\n}\n\n/**\n * Ensure that the actual response contains `getInterface`.\n *\n * @param response - The response of the handler.\n */\nfunction assertIsResponseWithInterface(\n response: SnapResponse,\n): asserts response is SnapResponseWithInterface {\n assertStruct(response, SnapResponseWithInterfaceStruct);\n}\n\n/**\n * Ensure that the actual interface is an alert dialog.\n *\n * @param ui - The interface to verify.\n */\nexport function assertIsAlertDialog(\n ui: SnapInterface,\n): asserts ui is SnapAlertInterface & SnapInterfaceActions {\n assert(hasProperty(ui, 'type') && ui.type === DialogType.Alert);\n}\n\n/**\n * Ensure that the actual interface is a confirmation dialog.\n *\n * @param ui - The interface to verify.\n */\nexport function assertIsConfirmationDialog(\n ui: SnapInterface,\n): asserts ui is SnapConfirmationInterface & SnapInterfaceActions {\n assert(hasProperty(ui, 'type') && ui.type === DialogType.Confirmation);\n}\n\n/**\n * Ensure that the actual interface is a Prompt dialog.\n *\n * @param ui - The interface to verify.\n */\nexport function assertIsPromptDialog(\n ui: SnapInterface,\n): asserts ui is SnapPromptInterface & SnapInterfaceActions {\n assert(hasProperty(ui, 'type') && ui.type === DialogType.Prompt);\n}\n\n/**\n * Ensure that the actual interface is a custom dialog.\n *\n * @param ui - The interface to verify.\n */\nexport function assertIsCustomDialog(\n ui: SnapInterface,\n): asserts ui is DefaultSnapInterface & SnapInterfaceActions {\n assert(!hasProperty(ui, 'type'));\n}\n\n/**\n * Ensure that the actual interface is a custom dialog with a complete footer.\n *\n * @param ui - The interface to verify.\n */\nexport function assertCustomDialogHasFooter(\n ui: DefaultSnapInterface & SnapInterfaceActions,\n): asserts ui is DefaultSnapInterfaceWithFooter & SnapInterfaceActions {\n const footer = getElementByType<FooterElement>(ui.content, 'Footer');\n\n assert(footer && getJsxChildren(footer).length === 2);\n}\n\n/**\n * Ensure that the actual interface is a custom dialog with a partial footer.\n *\n * @param ui - The interface to verify.\n */\nexport function assertCustomDialogHasPartialFooter(\n ui: DefaultSnapInterface & SnapInterfaceActions,\n): asserts ui is DefaultSnapInterfaceWithPartialFooter & SnapInterfaceActions {\n const footer = getElementByType<FooterElement>(ui.content, 'Footer');\n\n assert(footer && getJsxChildren(footer).length === 1);\n}\n\n/**\n * Ensure that the actual interface is a custom dialog without a footer.\n *\n * @param ui - The interface to verify.\n */\nexport function assertCustomDialogHasNoFooter(\n ui: DefaultSnapInterface & SnapInterfaceActions,\n): asserts ui is DefaultSnapInterfaceWithoutFooter & SnapInterfaceActions {\n const footer = getElementByType<FooterElement>(ui.content, 'Footer');\n\n assert(!footer);\n}\n\n/**\n * Load a snap into the environment. This is the main entry point for testing\n * snaps: It returns a {@link Snap} object that can be used to interact with the\n * snap.\n *\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * describe('My Snap', () => {\n * it('should do something', async () => {\n * const { request } = await installSnap('local:my-snap');\n * const response = await request({\n * method: 'foo',\n * params: ['bar'],\n * });\n * expect(response).toRespondWith('bar');\n * });\n * });\n * @returns The snap.\n * @throws If the built-in server is not running, and no snap ID is provided.\n */\nexport async function installSnap(): Promise<Snap>;\n\n/**\n * Load a snap into the environment. This is the main entry point for testing\n * snaps: It returns a {@link Snap} object that can be used to interact with the\n * snap.\n *\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * describe('My Snap', () => {\n * it('should do something', async () => {\n * const { request } = await installSnap('local:my-snap');\n * const response = await request({\n * method: 'foo',\n * params: ['bar'],\n * });\n * expect(response).toRespondWith('bar');\n * });\n * });\n * @param options - The options to use.\n * @param options.executionService - The execution service to use. Defaults to\n * {@link NodeThreadExecutionService}. You do not need to provide this unless\n * you are testing a custom execution service.\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 snap.\n * @throws If the built-in server is not running, and no snap ID is provided.\n */\nexport async function installSnap<\n Service extends new (...args: any[]) => InstanceType<\n typeof AbstractExecutionService\n >,\n>(options: Partial<InstallSnapOptions<Service>>): Promise<Snap>;\n\n/**\n * Load a snap into the environment. This is the main entry point for testing\n * snaps: It returns a {@link Snap} object that can be used to interact with the\n * snap.\n *\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * describe('My Snap', () => {\n * it('should do something', async () => {\n * const { request } = await installSnap('local:my-snap');\n * const response = await request({\n * method: 'foo',\n * params: ['bar'],\n * });\n * expect(response).toRespondWith('bar');\n * });\n * });\n * @param snapId - The ID of the snap, including the prefix (`local:`). Defaults\n * to the URL of the built-in server, if it is running. This supports both\n * local snap IDs and NPM snap IDs.\n * @param options - The options to use.\n * @param options.executionService - The execution service to use. Defaults to\n * {@link NodeThreadExecutionService}. You do not need to provide this unless\n * you are testing a custom execution service.\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 snap.\n * @throws If the built-in server is not running, and no snap ID is provided.\n */\nexport async function installSnap<\n Service extends new (...args: any[]) => InstanceType<\n typeof AbstractExecutionService\n >,\n>(\n snapId: SnapId,\n options?: Partial<InstallSnapOptions<Service>>,\n): Promise<Snap>;\n\n/**\n * Load a snap into the environment. This is the main entry point for testing\n * snaps: It returns a {@link Snap} object that can be used to interact with the\n * snap.\n *\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * describe('My Snap', () => {\n * it('should do something', async () => {\n * const { request } = await installSnap('local:my-snap');\n * const response = await request({\n * method: 'foo',\n * params: ['bar'],\n * });\n * expect(response).toRespondWith('bar');\n * });\n * });\n * @param snapId - The ID of the snap, including the prefix (`local:`). Defaults\n * to the URL of the built-in server, if it is running. This supports both\n * local snap IDs and NPM snap IDs.\n * @param options - The options to use.\n * @param options.executionService - The execution service to use. Defaults to\n * {@link NodeThreadExecutionService}. You do not need to provide this unless\n * you are testing a custom execution service.\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 snap.\n * @throws If the built-in server is not running, and no snap ID is provided.\n */\nexport async function installSnap<\n Service extends new (...args: any[]) => InstanceType<\n typeof AbstractExecutionService\n >,\n>(\n snapId?: SnapId | Partial<InstallSnapOptions<Service>>,\n options: Partial<InstallSnapOptions<Service>> = {},\n): Promise<Snap> {\n const resolvedOptions = getOptions(snapId, options);\n const {\n snapId: installedSnapId,\n store,\n executionService,\n runSaga,\n controllerMessenger,\n } = await getEnvironment().installSnap(...resolvedOptions);\n\n const onTransaction = async (\n request: TransactionOptions,\n ): Promise<SnapResponseWithInterface> => {\n log('Sending transaction %o.', request);\n\n const {\n origin: transactionOrigin,\n chainId,\n ...transaction\n } = create(request, TransactionOptionsStruct);\n\n const response = await handleRequest({\n snapId: installedSnapId,\n store,\n executionService,\n runSaga,\n controllerMessenger,\n handler: HandlerType.OnTransaction,\n request: {\n method: '',\n params: {\n chainId,\n transaction,\n transactionOrigin,\n },\n },\n });\n\n assertIsResponseWithInterface(response);\n\n return response;\n };\n\n const onCronjob = (request: CronjobOptions) => {\n log('Running cronjob %o.', options);\n\n return handleRequest({\n snapId: installedSnapId,\n store,\n executionService,\n controllerMessenger,\n runSaga,\n handler: HandlerType.OnCronjob,\n request,\n });\n };\n\n return {\n request: (request) => {\n log('Sending request %o.', request);\n\n return handleRequest({\n snapId: installedSnapId,\n store,\n executionService,\n controllerMessenger,\n runSaga,\n handler: HandlerType.OnRpcRequest,\n request,\n });\n },\n\n onTransaction,\n sendTransaction: onTransaction,\n\n onSignature: async (\n request: unknown,\n ): Promise<SnapResponseWithInterface> => {\n log('Requesting signature %o.', request);\n\n const { origin: signatureOrigin, ...signature } = create(\n request,\n SignatureOptionsStruct,\n );\n\n const response = await handleRequest({\n snapId: installedSnapId,\n store,\n executionService,\n controllerMessenger,\n runSaga,\n handler: HandlerType.OnSignature,\n request: {\n method: '',\n params: {\n signature,\n signatureOrigin,\n },\n },\n });\n\n assertIsResponseWithInterface(response);\n\n return response;\n },\n\n onCronjob,\n runCronjob: onCronjob,\n\n onHomePage: async (): Promise<SnapResponseWithInterface> => {\n log('Rendering home page.');\n\n const response = await handleRequest({\n snapId: installedSnapId,\n store,\n executionService,\n controllerMessenger,\n runSaga,\n handler: HandlerType.OnHomePage,\n request: {\n method: '',\n },\n });\n\n assertIsResponseWithInterface(response);\n\n return response;\n },\n\n mockJsonRpc(mock: JsonRpcMockOptions) {\n log('Mocking JSON-RPC request %o.', mock);\n\n const { method, result } = create(mock, JsonRpcMockOptionsStruct);\n store.dispatch(addJsonRpcMock({ method, result }));\n\n return {\n unmock() {\n log('Unmocking JSON-RPC request %o.', mock);\n\n store.dispatch(removeJsonRpcMock(method));\n },\n };\n },\n\n close: async () => {\n log('Closing execution service.');\n logInfo(\n 'Calling `snap.close()` is deprecated, and will be removed in a future release. Snaps are now automatically closed when the test ends.',\n );\n\n await executionService.terminateAllSnaps();\n },\n };\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getPermissionSpecifications
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OHRFO2BL.mjs";
|
|
4
4
|
import {
|
|
5
5
|
UNRESTRICTED_METHODS
|
|
6
6
|
} from "./chunk-57SGDM5B.mjs";
|
|
@@ -33,7 +33,9 @@ function getControllers(options) {
|
|
|
33
33
|
name: "SnapInterfaceController",
|
|
34
34
|
allowedActions: [
|
|
35
35
|
"PhishingController:maybeUpdateState",
|
|
36
|
-
"PhishingController:testOrigin"
|
|
36
|
+
"PhishingController:testOrigin",
|
|
37
|
+
"ApprovalController:hasRequest",
|
|
38
|
+
"ApprovalController:acceptRequest"
|
|
37
39
|
],
|
|
38
40
|
allowedEvents: []
|
|
39
41
|
})
|
|
@@ -92,4 +94,4 @@ export {
|
|
|
92
94
|
getControllers,
|
|
93
95
|
registerSnap
|
|
94
96
|
};
|
|
95
|
-
//# sourceMappingURL=chunk-
|
|
97
|
+
//# sourceMappingURL=chunk-LSKT2AUS.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/internals/simulation/controllers.ts"],"sourcesContent":["import type { ControllerMessenger } from '@metamask/base-controller';\nimport type {\n CaveatSpecificationConstraint,\n PermissionSpecificationConstraint,\n PermissionControllerActions,\n SubjectMetadataControllerActions,\n} from '@metamask/permission-controller';\nimport {\n PermissionController,\n SubjectMetadataController,\n SubjectType,\n} from '@metamask/permission-controller';\nimport { SnapInterfaceController } from '@metamask/snaps-controllers';\nimport type {\n ExecutionServiceActions,\n SnapInterfaceControllerActions,\n SnapInterfaceControllerAllowedActions,\n} from '@metamask/snaps-controllers';\nimport {\n caveatSpecifications as snapsCaveatsSpecifications,\n endowmentCaveatSpecifications as snapsEndowmentCaveatSpecifications,\n processSnapPermissions,\n} from '@metamask/snaps-rpc-methods';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport type { SnapManifest } from '@metamask/snaps-utils';\nimport { getSafeJson } from '@metamask/utils';\n\nimport { getPermissionSpecifications } from './methods';\nimport { UNRESTRICTED_METHODS } from './methods/constants';\nimport type { SimulationOptions } from './options';\nimport type { MiddlewareHooks } from './simulation';\nimport type { RunSagaFunction } from './store';\n\nexport type RootControllerAllowedActions =\n | SnapInterfaceControllerActions\n | SnapInterfaceControllerAllowedActions\n | PermissionControllerActions\n | ExecutionServiceActions\n | SubjectMetadataControllerActions;\n\nexport type RootControllerMessenger = ControllerMessenger<\n RootControllerAllowedActions,\n any\n>;\n\nexport type GetControllersOptions = {\n controllerMessenger: ControllerMessenger<any, any>;\n hooks: MiddlewareHooks;\n runSaga: RunSagaFunction;\n options: SimulationOptions;\n};\n\nexport type Controllers = {\n permissionController: PermissionController<\n PermissionSpecificationConstraint,\n CaveatSpecificationConstraint\n >;\n subjectMetadataController: SubjectMetadataController;\n interfaceController: SnapInterfaceController;\n};\n\n/**\n * Get the controllers for the Snap.\n *\n * @param options - The options.\n * @returns The controllers for the Snap.\n */\nexport function getControllers(options: GetControllersOptions): Controllers {\n const { controllerMessenger } = options;\n const subjectMetadataController = new SubjectMetadataController({\n messenger: controllerMessenger.getRestricted({\n name: 'SubjectMetadataController',\n allowedActions: [],\n allowedEvents: [],\n }),\n subjectCacheLimit: 100,\n });\n\n const interfaceController = new SnapInterfaceController({\n messenger: controllerMessenger.getRestricted({\n name: 'SnapInterfaceController',\n allowedActions: [\n 'PhishingController:maybeUpdateState',\n 'PhishingController:testOrigin',\n 'ApprovalController:hasRequest',\n 'ApprovalController:acceptRequest',\n ],\n allowedEvents: [],\n }),\n });\n\n const permissionController = getPermissionController(options);\n\n return {\n permissionController,\n subjectMetadataController,\n interfaceController,\n };\n}\n\n/**\n * Get the permission controller for the Snap.\n *\n * @param options - The options.\n * @param options.controllerMessenger - The controller messenger.\n * @param options.options - Miscellaneous options.\n * @returns The permission controller for the Snap.\n */\nfunction getPermissionController(options: GetControllersOptions) {\n const { controllerMessenger } = options;\n const permissionSpecifications = getPermissionSpecifications(options);\n return new PermissionController({\n messenger: controllerMessenger.getRestricted({\n name: 'PermissionController',\n allowedActions: [\n `ApprovalController:addRequest`,\n `ApprovalController:hasRequest`,\n `ApprovalController:acceptRequest`,\n `ApprovalController:rejectRequest`,\n `SnapController:getPermitted`,\n `SnapController:install`,\n `SubjectMetadataController:getSubjectMetadata`,\n ],\n allowedEvents: [],\n }),\n caveatSpecifications: {\n ...snapsCaveatsSpecifications,\n ...snapsEndowmentCaveatSpecifications,\n },\n permissionSpecifications,\n unrestrictedMethods: UNRESTRICTED_METHODS,\n });\n}\n\n/**\n * Register the Snap. This sets up the Snap's permissions and subject metadata.\n *\n * @param snapId - The ID of the Snap to install.\n * @param manifest - The parsed manifest.\n * @param controllers - The controllers for the Snap.\n * @param controllers.permissionController - The permission controller.\n * @param controllers.subjectMetadataController - The subject metadata controller.\n */\nexport async function registerSnap(\n snapId: SnapId,\n manifest: SnapManifest,\n {\n permissionController,\n subjectMetadataController,\n }: Omit<Controllers, 'interfaceController'>,\n) {\n subjectMetadataController.addSubjectMetadata({\n origin: snapId,\n subjectType: SubjectType.Snap,\n });\n\n const approvedPermissions = processSnapPermissions(\n getSafeJson(manifest.initialPermissions),\n );\n\n permissionController.grantPermissions({\n approvedPermissions,\n subject: { origin: snapId },\n preserveExistingPermissions: false,\n });\n}\n"],"mappings":";;;;;;;;AAOA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,+BAA+B;AAMxC;AAAA,EACE,wBAAwB;AAAA,EACxB,iCAAiC;AAAA,EACjC;AAAA,OACK;AAGP,SAAS,mBAAmB;AA0CrB,SAAS,eAAe,SAA6C;AAC1E,QAAM,EAAE,oBAAoB,IAAI;AAChC,QAAM,4BAA4B,IAAI,0BAA0B;AAAA,IAC9D,WAAW,oBAAoB,cAAc;AAAA,MAC3C,MAAM;AAAA,MACN,gBAAgB,CAAC;AAAA,MACjB,eAAe,CAAC;AAAA,IAClB,CAAC;AAAA,IACD,mBAAmB;AAAA,EACrB,CAAC;AAED,QAAM,sBAAsB,IAAI,wBAAwB;AAAA,IACtD,WAAW,oBAAoB,cAAc;AAAA,MAC3C,MAAM;AAAA,MACN,gBAAgB;AAAA,QACd;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,eAAe,CAAC;AAAA,IAClB,CAAC;AAAA,EACH,CAAC;AAED,QAAM,uBAAuB,wBAAwB,OAAO;AAE5D,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAUA,SAAS,wBAAwB,SAAgC;AAC/D,QAAM,EAAE,oBAAoB,IAAI;AAChC,QAAM,2BAA2B,4BAA4B,OAAO;AACpE,SAAO,IAAI,qBAAqB;AAAA,IAC9B,WAAW,oBAAoB,cAAc;AAAA,MAC3C,MAAM;AAAA,MACN,gBAAgB;AAAA,QACd;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,eAAe,CAAC;AAAA,IAClB,CAAC;AAAA,IACD,sBAAsB;AAAA,MACpB,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AAAA,IACA;AAAA,IACA,qBAAqB;AAAA,EACvB,CAAC;AACH;AAWA,eAAsB,aACpB,QACA,UACA;AAAA,EACE;AAAA,EACA;AACF,GACA;AACA,4BAA0B,mBAAmB;AAAA,IAC3C,QAAQ;AAAA,IACR,aAAa,YAAY;AAAA,EAC3B,CAAC;AAED,QAAM,sBAAsB;AAAA,IAC1B,YAAY,SAAS,kBAAkB;AAAA,EACzC;AAEA,uBAAqB,iBAAiB;AAAA,IACpC;AAAA,IACA,SAAS,EAAE,QAAQ,OAAO;AAAA,IAC1B,6BAA6B;AAAA,EAC/B,CAAC;AACH;","names":[]}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
// src/internals/simulation/constants.ts
|
|
2
2
|
var DEFAULT_SRP = "test test test test test test test test test test test ball";
|
|
3
3
|
var DEFAULT_LOCALE = "en";
|
|
4
|
+
var DEFAULT_CURRENCY = "usd";
|
|
4
5
|
var DEFAULT_JSON_RPC_ENDPOINT = "https://cloudflare-eth.com/";
|
|
5
6
|
|
|
6
7
|
export {
|
|
7
8
|
DEFAULT_SRP,
|
|
8
9
|
DEFAULT_LOCALE,
|
|
10
|
+
DEFAULT_CURRENCY,
|
|
9
11
|
DEFAULT_JSON_RPC_ENDPOINT
|
|
10
12
|
};
|
|
11
|
-
//# sourceMappingURL=chunk-
|
|
13
|
+
//# sourceMappingURL=chunk-LVNNGMJ2.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internals/simulation/constants.ts"],"sourcesContent":["/**\n * A secret recovery phrase that is used for testing purposes. Do not use this\n * to store any real funds!\n */\nexport const DEFAULT_SRP =\n 'test test test test test test test test test test test ball';\n\n/**\n * The default locale.\n */\nexport const DEFAULT_LOCALE = 'en';\n\n/**\n * The default JSON-RPC endpoint for Ethereum requests.\n */\nexport const DEFAULT_JSON_RPC_ENDPOINT = 'https://cloudflare-eth.com/';\n"],"mappings":";AAIO,IAAM,cACX;AAKK,IAAM,iBAAiB;AAKvB,IAAM,4BAA4B;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/internals/simulation/constants.ts"],"sourcesContent":["/**\n * A secret recovery phrase that is used for testing purposes. Do not use this\n * to store any real funds!\n */\nexport const DEFAULT_SRP =\n 'test test test test test test test test test test test ball';\n\n/**\n * The default locale.\n */\nexport const DEFAULT_LOCALE = 'en';\n\n/**\n * The default currency.\n */\nexport const DEFAULT_CURRENCY = 'usd';\n\n/**\n * The default JSON-RPC endpoint for Ethereum requests.\n */\nexport const DEFAULT_JSON_RPC_ENDPOINT = 'https://cloudflare-eth.com/';\n"],"mappings":";AAIO,IAAM,cACX;AAKK,IAAM,iBAAiB;AAKvB,IAAM,mBAAmB;AAKzB,IAAM,4BAA4B;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
getGetPreferencesMethodImplementation
|
|
3
|
+
} from "./chunk-QRVFWATH.mjs";
|
|
4
4
|
import {
|
|
5
5
|
getCreateInterfaceImplementation,
|
|
6
6
|
getGetInterfaceImplementation
|
|
@@ -10,8 +10,8 @@ import {
|
|
|
10
10
|
getShowNativeNotificationImplementation
|
|
11
11
|
} from "./chunk-ALRZENWP.mjs";
|
|
12
12
|
import {
|
|
13
|
-
|
|
14
|
-
} from "./chunk-
|
|
13
|
+
getRequestUserApprovalImplementation
|
|
14
|
+
} from "./chunk-24CGIQLL.mjs";
|
|
15
15
|
import {
|
|
16
16
|
getClearSnapStateMethodImplementation,
|
|
17
17
|
getGetSnapStateMethodImplementation,
|
|
@@ -48,13 +48,13 @@ function getPermissionSpecifications({
|
|
|
48
48
|
...hooks,
|
|
49
49
|
// Snaps-specific hooks.
|
|
50
50
|
clearSnapState: getClearSnapStateMethodImplementation(runSaga),
|
|
51
|
-
|
|
51
|
+
getPreferences: getGetPreferencesMethodImplementation(options),
|
|
52
52
|
getSnapState: getGetSnapStateMethodImplementation(runSaga),
|
|
53
53
|
getUnlockPromise: asyncResolve(true),
|
|
54
54
|
// TODO: Allow the user to specify the result of this function.
|
|
55
55
|
isOnPhishingList: resolve(false),
|
|
56
56
|
maybeUpdatePhishingList: asyncResolve(),
|
|
57
|
-
|
|
57
|
+
requestUserApproval: getRequestUserApprovalImplementation(runSaga),
|
|
58
58
|
showInAppNotification: getShowInAppNotificationImplementation(runSaga),
|
|
59
59
|
showNativeNotification: getShowNativeNotificationImplementation(runSaga),
|
|
60
60
|
updateSnapState: getUpdateSnapStateMethodImplementation(runSaga),
|
|
@@ -86,4 +86,4 @@ export {
|
|
|
86
86
|
getPermissionSpecifications,
|
|
87
87
|
getEndowments
|
|
88
88
|
};
|
|
89
|
-
//# sourceMappingURL=chunk-
|
|
89
|
+
//# sourceMappingURL=chunk-OHRFO2BL.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/internals/simulation/methods/specifications.ts"],"sourcesContent":["import type { GenericPermissionController } from '@metamask/permission-controller';\nimport {\n endowmentPermissionBuilders,\n buildSnapEndowmentSpecifications,\n buildSnapRestrictedMethodSpecifications,\n} from '@metamask/snaps-rpc-methods';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { DEFAULT_ENDOWMENTS } from '@metamask/snaps-utils';\n\nimport type { RootControllerMessenger } from '../controllers';\nimport type { SimulationOptions } from '../options';\nimport type { RunSagaFunction } from '../store';\nimport {\n EXCLUDED_SNAP_ENDOWMENTS,\n EXCLUDED_SNAP_PERMISSIONS,\n} from './constants';\nimport {\n getGetPreferencesMethodImplementation,\n getClearSnapStateMethodImplementation,\n getGetSnapStateMethodImplementation,\n getUpdateSnapStateMethodImplementation,\n getShowInAppNotificationImplementation,\n getShowNativeNotificationImplementation,\n getCreateInterfaceImplementation,\n getGetInterfaceImplementation,\n getRequestUserApprovalImplementation,\n} from './hooks';\n\nexport type PermissionSpecificationsHooks = {\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\nexport type GetPermissionSpecificationsOptions = {\n controllerMessenger: RootControllerMessenger;\n hooks: PermissionSpecificationsHooks;\n runSaga: RunSagaFunction;\n options: SimulationOptions;\n};\n\n/**\n * Get a function which resolves with the specified result.\n *\n * @param result - The result to return.\n * @returns The function implementation.\n */\nexport function resolve(result: unknown) {\n return () => result;\n}\n\n/**\n * Get a function which resolves with the specified result.\n *\n * @param result - The result to return. If not specified, the function will\n * resolve with `undefined`.\n * @returns The function implementation.\n */\nexport function asyncResolve(result?: unknown) {\n return async () => result;\n}\n\n/**\n * Get the permission specifications for the Snap.\n *\n * @param options - The options.\n * @param options.controllerMessenger - The controller messenger.\n * @param options.hooks - The hooks.\n * @param options.runSaga - The function to run a saga outside the usual Redux\n * flow.\n * @param options.options - The simulation options.\n * @returns The permission specifications for the Snap.\n */\nexport function getPermissionSpecifications({\n controllerMessenger,\n hooks,\n runSaga,\n options,\n}: GetPermissionSpecificationsOptions) {\n return {\n ...buildSnapEndowmentSpecifications(EXCLUDED_SNAP_ENDOWMENTS),\n ...buildSnapRestrictedMethodSpecifications(EXCLUDED_SNAP_PERMISSIONS, {\n // Shared hooks.\n ...hooks,\n\n // Snaps-specific hooks.\n clearSnapState: getClearSnapStateMethodImplementation(runSaga),\n getPreferences: getGetPreferencesMethodImplementation(options),\n getSnapState: getGetSnapStateMethodImplementation(runSaga),\n getUnlockPromise: asyncResolve(true),\n\n // TODO: Allow the user to specify the result of this function.\n isOnPhishingList: resolve(false),\n\n maybeUpdatePhishingList: asyncResolve(),\n requestUserApproval: getRequestUserApprovalImplementation(runSaga),\n showInAppNotification: getShowInAppNotificationImplementation(runSaga),\n showNativeNotification: getShowNativeNotificationImplementation(runSaga),\n updateSnapState: getUpdateSnapStateMethodImplementation(runSaga),\n createInterface: getCreateInterfaceImplementation(controllerMessenger),\n getInterface: getGetInterfaceImplementation(controllerMessenger),\n }),\n };\n}\n\n/**\n * Get the endowments for the Snap.\n *\n * @param permissionController - The permission controller.\n * @param snapId - The ID of the Snap.\n * @returns The endowments for the Snap.\n */\nexport async function getEndowments(\n permissionController: GenericPermissionController,\n snapId: SnapId,\n) {\n const allEndowments = await Object.keys(endowmentPermissionBuilders).reduce<\n Promise<string[]>\n >(async (promise, permissionName) => {\n const accumulator = await promise;\n if (permissionController.hasPermission(snapId, permissionName)) {\n const endowments = await permissionController.getEndowments(\n snapId,\n permissionName,\n );\n\n if (endowments) {\n return accumulator.concat(endowments as string[]);\n }\n }\n\n return accumulator;\n }, Promise.resolve([]));\n\n return [...new Set([...DEFAULT_ENDOWMENTS, ...allEndowments])];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,0BAA0B;AA2C5B,SAAS,QAAQ,QAAiB;AACvC,SAAO,MAAM;AACf;AASO,SAAS,aAAa,QAAkB;AAC7C,SAAO,YAAY;AACrB;AAaO,SAAS,4BAA4B;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAuC;AACrC,SAAO;AAAA,IACL,GAAG,iCAAiC,wBAAwB;AAAA,IAC5D,GAAG,wCAAwC,2BAA2B;AAAA;AAAA,MAEpE,GAAG;AAAA;AAAA,MAGH,gBAAgB,sCAAsC,OAAO;AAAA,MAC7D,gBAAgB,sCAAsC,OAAO;AAAA,MAC7D,cAAc,oCAAoC,OAAO;AAAA,MACzD,kBAAkB,aAAa,IAAI;AAAA;AAAA,MAGnC,kBAAkB,QAAQ,KAAK;AAAA,MAE/B,yBAAyB,aAAa;AAAA,MACtC,qBAAqB,qCAAqC,OAAO;AAAA,MACjE,uBAAuB,uCAAuC,OAAO;AAAA,MACrE,wBAAwB,wCAAwC,OAAO;AAAA,MACvE,iBAAiB,uCAAuC,OAAO;AAAA,MAC/D,iBAAiB,iCAAiC,mBAAmB;AAAA,MACrE,cAAc,8BAA8B,mBAAmB;AAAA,IACjE,CAAC;AAAA,EACH;AACF;AASA,eAAsB,cACpB,sBACA,QACA;AACA,QAAM,gBAAgB,MAAM,OAAO,KAAK,2BAA2B,EAAE,OAEnE,OAAO,SAAS,mBAAmB;AACnC,UAAM,cAAc,MAAM;AAC1B,QAAI,qBAAqB,cAAc,QAAQ,cAAc,GAAG;AAC9D,YAAM,aAAa,MAAM,qBAAqB;AAAA,QAC5C;AAAA,QACA;AAAA,MACF;AAEA,UAAI,YAAY;AACd,eAAO,YAAY,OAAO,UAAsB;AAAA,MAClD;AAAA,IACF;AAEA,WAAO;AAAA,EACT,GAAG,QAAQ,QAAQ,CAAC,CAAC,CAAC;AAEtB,SAAO,CAAC,GAAG,oBAAI,IAAI,CAAC,GAAG,oBAAoB,GAAG,aAAa,CAAC,CAAC;AAC/D;","names":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk2RJYSYUBjs = require('./chunk-2RJYSYUB.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk3NP6BDGKjs = require('./chunk-3NP6BDGK.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkN6MAO223js = require('./chunk-N6MAO223.js');
|
|
@@ -33,7 +33,7 @@ var SnapsEnvironment = class extends _jestenvironmentnode2.default {
|
|
|
33
33
|
_chunkPHUTP7NBjs.__privateAdd.call(void 0, this, _options, void 0);
|
|
34
34
|
_chunkPHUTP7NBjs.__privateAdd.call(void 0, this, _server, void 0);
|
|
35
35
|
_chunkPHUTP7NBjs.__privateAdd.call(void 0, this, _instance, void 0);
|
|
36
|
-
_chunkPHUTP7NBjs.__privateSet.call(void 0, this, _options,
|
|
36
|
+
_chunkPHUTP7NBjs.__privateSet.call(void 0, this, _options, _chunk2RJYSYUBjs.getOptions.call(void 0, options.projectConfig.testEnvironmentOptions));
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* Set up the environment. This starts the built-in HTTP server, and creates a
|
|
@@ -72,7 +72,7 @@ var SnapsEnvironment = class extends _jestenvironmentnode2.default {
|
|
|
72
72
|
*/
|
|
73
73
|
async installSnap(snapId = this.snapId, options = {}) {
|
|
74
74
|
await _chunkPHUTP7NBjs.__privateGet.call(void 0, this, _instance)?.executionService.terminateAllSnaps();
|
|
75
|
-
_chunkPHUTP7NBjs.__privateSet.call(void 0, this, _instance, await
|
|
75
|
+
_chunkPHUTP7NBjs.__privateSet.call(void 0, this, _instance, await _chunk3NP6BDGKjs.handleInstallSnap.call(void 0, snapId, options));
|
|
76
76
|
return _chunkPHUTP7NBjs.__privateGet.call(void 0, this, _instance);
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
@@ -101,4 +101,4 @@ var environment_default = SnapsEnvironment;
|
|
|
101
101
|
|
|
102
102
|
|
|
103
103
|
exports.SnapsEnvironment = SnapsEnvironment; exports.environment_default = environment_default;
|
|
104
|
-
//# sourceMappingURL=chunk-
|
|
104
|
+
//# sourceMappingURL=chunk-OO6IVUCV.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
uiSlice
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZJQSGRNK.mjs";
|
|
4
4
|
import {
|
|
5
5
|
mocksSlice
|
|
6
6
|
} from "./chunk-H2464AXT.mjs";
|
|
@@ -51,4 +51,4 @@ function createStore({ state, unencryptedState }) {
|
|
|
51
51
|
export {
|
|
52
52
|
createStore
|
|
53
53
|
};
|
|
54
|
-
//# sourceMappingURL=chunk-
|
|
54
|
+
//# sourceMappingURL=chunk-ORR7AE5X.mjs.map
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
clickElement,
|
|
3
2
|
getInterface,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "./chunk-AFA4KKWW.mjs";
|
|
3
|
+
getInterfaceActions
|
|
4
|
+
} from "./chunk-6JPBXAHM.mjs";
|
|
7
5
|
import {
|
|
8
6
|
SnapResponseStruct
|
|
9
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-C26TYXXD.mjs";
|
|
10
8
|
import {
|
|
11
9
|
clearNotifications,
|
|
12
10
|
getNotifications
|
|
@@ -17,6 +15,7 @@ import {
|
|
|
17
15
|
ComponentOrElementStruct
|
|
18
16
|
} from "@metamask/snaps-sdk";
|
|
19
17
|
import { unwrapError } from "@metamask/snaps-utils";
|
|
18
|
+
import { is } from "@metamask/superstruct";
|
|
20
19
|
import {
|
|
21
20
|
assert,
|
|
22
21
|
getSafeJson,
|
|
@@ -24,7 +23,6 @@ import {
|
|
|
24
23
|
isPlainObject
|
|
25
24
|
} from "@metamask/utils";
|
|
26
25
|
import { nanoid } from "@reduxjs/toolkit";
|
|
27
|
-
import { is } from "superstruct";
|
|
28
26
|
function handleRequest({
|
|
29
27
|
snapId,
|
|
30
28
|
store,
|
|
@@ -134,37 +132,13 @@ async function getInterfaceApi(result, snapId, controllerMessenger) {
|
|
|
134
132
|
snapId,
|
|
135
133
|
interfaceId
|
|
136
134
|
);
|
|
135
|
+
const actions = getInterfaceActions(snapId, controllerMessenger, {
|
|
136
|
+
id: interfaceId,
|
|
137
|
+
content
|
|
138
|
+
});
|
|
137
139
|
return {
|
|
138
140
|
content,
|
|
139
|
-
|
|
140
|
-
await clickElement(
|
|
141
|
-
controllerMessenger,
|
|
142
|
-
interfaceId,
|
|
143
|
-
content,
|
|
144
|
-
snapId,
|
|
145
|
-
name
|
|
146
|
-
);
|
|
147
|
-
},
|
|
148
|
-
typeInField: async (name, value) => {
|
|
149
|
-
await typeInField(
|
|
150
|
-
controllerMessenger,
|
|
151
|
-
interfaceId,
|
|
152
|
-
content,
|
|
153
|
-
snapId,
|
|
154
|
-
name,
|
|
155
|
-
value
|
|
156
|
-
);
|
|
157
|
-
},
|
|
158
|
-
selectInDropdown: async (name, value) => {
|
|
159
|
-
await selectInDropdown(
|
|
160
|
-
controllerMessenger,
|
|
161
|
-
interfaceId,
|
|
162
|
-
content,
|
|
163
|
-
snapId,
|
|
164
|
-
name,
|
|
165
|
-
value
|
|
166
|
-
);
|
|
167
|
-
}
|
|
141
|
+
...actions
|
|
168
142
|
};
|
|
169
143
|
};
|
|
170
144
|
}
|
|
@@ -176,4 +150,4 @@ export {
|
|
|
176
150
|
getInterfaceFromResult,
|
|
177
151
|
getInterfaceApi
|
|
178
152
|
};
|
|
179
|
-
//# sourceMappingURL=chunk-
|
|
153
|
+
//# sourceMappingURL=chunk-PDOVVC74.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/internals/request.ts"],"sourcesContent":["import type { AbstractExecutionService } from '@metamask/snaps-controllers';\nimport {\n type ComponentOrElement,\n ComponentOrElementStruct,\n type JsonRpcError,\n type SnapId,\n} from '@metamask/snaps-sdk';\nimport type { HandlerType } from '@metamask/snaps-utils';\nimport { unwrapError } from '@metamask/snaps-utils';\nimport { is } from '@metamask/superstruct';\nimport {\n assert,\n getSafeJson,\n hasProperty,\n isPlainObject,\n} from '@metamask/utils';\nimport { nanoid } from '@reduxjs/toolkit';\n\nimport type {\n RequestOptions,\n SnapHandlerInterface,\n SnapRequest,\n} from '../types';\nimport type { RunSagaFunction, Store } from './simulation';\nimport {\n clearNotifications,\n getInterface,\n getInterfaceActions,\n getNotifications,\n} from './simulation';\nimport type { RootControllerMessenger } from './simulation/controllers';\nimport { SnapResponseStruct } from './structs';\n\nexport type HandleRequestOptions = {\n snapId: SnapId;\n store: Store;\n executionService: AbstractExecutionService<unknown>;\n handler: HandlerType;\n controllerMessenger: RootControllerMessenger;\n runSaga: RunSagaFunction;\n request: RequestOptions;\n};\n\n/**\n * Send a JSON-RPC request to the Snap, and wrap the response in a\n * {@link SnapResponse} object.\n *\n * @param options - The request options.\n * @param options.snapId - The ID of the Snap to send the request to.\n * @param options.store - The Redux store.\n * @param options.executionService - The execution service to use to send the\n * request.\n * @param options.handler - The handler to use to send the request.\n * @param options.controllerMessenger - The controller messenger used to call actions.\n * @param options.runSaga - A function to run a saga outside the usual Redux\n * flow.\n * @param options.request - The request to send.\n * @param options.request.id - The ID of the request. If not provided, a random\n * ID will be generated.\n * @param options.request.origin - The origin of the request. Defaults to\n * `https://metamask.io`.\n * @returns The response, wrapped in a {@link SnapResponse} object.\n */\nexport function handleRequest({\n snapId,\n store,\n executionService,\n handler,\n controllerMessenger,\n runSaga,\n request: { id = nanoid(), origin = 'https://metamask.io', ...options },\n}: HandleRequestOptions): SnapRequest {\n const getInterfaceError = () => {\n throw new Error(\n 'Unable to get the interface from the Snap: The request to the Snap failed.',\n );\n };\n\n const promise = executionService\n .handleRpcRequest(snapId, {\n origin,\n handler,\n request: {\n jsonrpc: '2.0',\n id: 1,\n ...options,\n },\n })\n .then(async (result) => {\n const notifications = getNotifications(store.getState());\n store.dispatch(clearNotifications());\n\n try {\n const getInterfaceFn = await getInterfaceApi(\n result,\n snapId,\n controllerMessenger,\n );\n\n return {\n id: String(id),\n response: {\n result: getSafeJson(result),\n },\n notifications,\n ...(getInterfaceFn ? { getInterface: getInterfaceFn } : {}),\n };\n } catch (error) {\n const [unwrappedError] = unwrapError(error);\n return {\n id: String(id),\n response: {\n error: unwrappedError.serialize(),\n },\n notifications: [],\n getInterface: getInterfaceError,\n };\n }\n })\n .catch((error) => {\n const [unwrappedError] = unwrapError(error);\n\n return {\n id: String(id),\n response: {\n error: unwrappedError.serialize(),\n },\n notifications: [],\n getInterface: getInterfaceError,\n };\n }) as unknown as SnapRequest;\n\n promise.getInterface = async () => {\n const sagaPromise = runSaga(\n getInterface,\n runSaga,\n snapId,\n controllerMessenger,\n ).toPromise();\n const result = await Promise.race([promise, sagaPromise]);\n\n // If the request promise has resolved to an error, we should throw\n // instead of waiting for an interface that likely will never be displayed\n if (\n is(result, SnapResponseStruct) &&\n hasProperty(result.response, 'error')\n ) {\n throw new Error(\n `Unable to get the interface from the Snap: The returned interface may be invalid. The error message received was: ${\n (result.response.error as JsonRpcError).message\n }`,\n );\n }\n\n return await sagaPromise;\n };\n\n return promise;\n}\n\n/**\n * Get the interface ID from the result if it's available or create a new interface if the result contains static components.\n *\n * @param result - The handler result object.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger.\n * @returns The interface ID or undefined if the result doesn't include content.\n */\nexport async function getInterfaceFromResult(\n result: unknown,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n) {\n if (isPlainObject(result) && hasProperty(result, 'id')) {\n return result.id as string;\n }\n\n if (isPlainObject(result) && hasProperty(result, 'content')) {\n assert(\n is(result.content, ComponentOrElementStruct),\n 'The Snap returned an invalid interface.',\n );\n const id = await controllerMessenger.call(\n 'SnapInterfaceController:createInterface',\n snapId,\n result.content as ComponentOrElement,\n );\n\n return id;\n }\n\n return undefined;\n}\n\n/**\n * Get the response content from the `SnapInterfaceController` and include the\n * interaction methods.\n *\n * @param result - The handler result object.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger.\n * @returns The content components if any.\n */\nexport async function getInterfaceApi(\n result: unknown,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n): Promise<(() => SnapHandlerInterface) | undefined> {\n const interfaceId = await getInterfaceFromResult(\n result,\n snapId,\n controllerMessenger,\n );\n\n if (interfaceId) {\n return () => {\n const { content } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n interfaceId,\n );\n\n const actions = getInterfaceActions(snapId, controllerMessenger, {\n id: interfaceId,\n content,\n });\n\n return {\n content,\n ...actions,\n };\n };\n }\n\n return undefined;\n}\n"],"mappings":"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","names":[]}
|