@metamask/snaps-execution-environments 10.4.0 → 11.0.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 +16 -1
- package/dist/common/BaseSnapExecutor.cjs +130 -189
- package/dist/common/BaseSnapExecutor.cjs.map +1 -1
- package/dist/common/BaseSnapExecutor.d.cts +0 -57
- package/dist/common/BaseSnapExecutor.d.cts.map +1 -1
- package/dist/common/BaseSnapExecutor.d.mts +0 -57
- package/dist/common/BaseSnapExecutor.d.mts.map +1 -1
- package/dist/common/BaseSnapExecutor.mjs +135 -194
- package/dist/common/BaseSnapExecutor.mjs.map +1 -1
- package/dist/common/commands.cjs +23 -29
- package/dist/common/commands.cjs.map +1 -1
- package/dist/common/commands.d.cts +12 -20
- package/dist/common/commands.d.cts.map +1 -1
- package/dist/common/commands.d.mts +12 -20
- package/dist/common/commands.d.mts.map +1 -1
- package/dist/common/commands.mjs +21 -27
- package/dist/common/commands.mjs.map +1 -1
- package/dist/common/utils.cjs +41 -1
- package/dist/common/utils.cjs.map +1 -1
- package/dist/common/utils.d.cts +7 -0
- package/dist/common/utils.d.cts.map +1 -1
- package/dist/common/utils.d.mts +7 -0
- package/dist/common/utils.d.mts.map +1 -1
- package/dist/common/utils.mjs +39 -0
- package/dist/common/utils.mjs.map +1 -1
- package/dist/common/validation.cjs +13 -25
- package/dist/common/validation.cjs.map +1 -1
- package/dist/common/validation.d.cts +69 -42
- package/dist/common/validation.d.cts.map +1 -1
- package/dist/common/validation.d.mts +69 -42
- package/dist/common/validation.d.mts.map +1 -1
- package/dist/common/validation.mjs +15 -27
- package/dist/common/validation.mjs.map +1 -1
- package/dist/webpack/iframe/bundle.js +1 -1
- package/dist/webpack/node-process/bundle.js +1 -1
- package/dist/webpack/node-thread/bundle.js +1 -1
- package/dist/webpack/webview/index.html +1 -1
- package/package.json +3 -3
- package/dist/common/lockdown/lockdown.cjs +0 -29
- package/dist/common/lockdown/lockdown.cjs.map +0 -1
- package/dist/common/lockdown/lockdown.d.cts +0 -7
- package/dist/common/lockdown/lockdown.d.cts.map +0 -1
- package/dist/common/lockdown/lockdown.d.mts +0 -7
- package/dist/common/lockdown/lockdown.d.mts.map +0 -1
- package/dist/common/lockdown/lockdown.mjs +0 -25
- package/dist/common/lockdown/lockdown.mjs.map +0 -1
- package/dist/common/sortParams.cjs +0 -35
- package/dist/common/sortParams.cjs.map +0 -1
- package/dist/common/sortParams.d.cts +0 -17
- package/dist/common/sortParams.d.cts.map +0 -1
- package/dist/common/sortParams.d.mts +0 -17
- package/dist/common/sortParams.d.mts.map +0 -1
- package/dist/common/sortParams.mjs +0 -31
- package/dist/common/sortParams.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/snaps-execution-environments",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "Snap sandbox environments for executing SES javascript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"@metamask/providers": "^22.1.1",
|
|
73
73
|
"@metamask/rpc-errors": "^7.0.3",
|
|
74
74
|
"@metamask/snaps-sdk": "^10.4.0",
|
|
75
|
-
"@metamask/snaps-utils": "^12.
|
|
75
|
+
"@metamask/snaps-utils": "^12.1.0",
|
|
76
76
|
"@metamask/superstruct": "^3.2.1",
|
|
77
77
|
"@metamask/utils": "^11.9.0",
|
|
78
78
|
"readable-stream": "^3.6.2"
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"jest-environment-node": "^29.5.0",
|
|
102
102
|
"jest-fetch-mock": "^3.0.3",
|
|
103
103
|
"jest-silent-reporter": "^0.6.0",
|
|
104
|
-
"lavamoat": "^10.0
|
|
104
|
+
"lavamoat": "^10.1.0",
|
|
105
105
|
"prettier": "^3.3.3",
|
|
106
106
|
"rimraf": "^4.1.2",
|
|
107
107
|
"serve-handler": "^6.1.5",
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// eslint-disable-next-line @typescript-eslint/triple-slash-reference, spaced-comment
|
|
3
|
-
/// <reference path="../../../../../node_modules/ses/types.d.ts" />
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.executeLockdown = void 0;
|
|
6
|
-
const snaps_utils_1 = require("@metamask/snaps-utils");
|
|
7
|
-
/**
|
|
8
|
-
* Execute SES lockdown in the current context, i.e., the current iframe.
|
|
9
|
-
*
|
|
10
|
-
* @throws If the SES lockdown failed.
|
|
11
|
-
*/
|
|
12
|
-
function executeLockdown() {
|
|
13
|
-
try {
|
|
14
|
-
lockdown({
|
|
15
|
-
consoleTaming: 'unsafe',
|
|
16
|
-
errorTaming: 'unsafe',
|
|
17
|
-
mathTaming: 'unsafe',
|
|
18
|
-
dateTaming: 'unsafe',
|
|
19
|
-
overrideTaming: 'severe',
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
// If the `lockdown` call throws an exception, it should not be able to continue
|
|
24
|
-
(0, snaps_utils_1.logError)('Lockdown failed:', error);
|
|
25
|
-
throw error;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.executeLockdown = executeLockdown;
|
|
29
|
-
//# sourceMappingURL=lockdown.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lockdown.cjs","sourceRoot":"","sources":["../../../src/common/lockdown/lockdown.ts"],"names":[],"mappings":";AAAA,qFAAqF;AACrF,mEAAmE;;;AAEnE,uDAAiD;AAEjD;;;;GAIG;AACH,SAAgB,eAAe;IAC7B,IAAI,CAAC;QACH,QAAQ,CAAC;YACP,aAAa,EAAE,QAAQ;YACvB,WAAW,EAAE,QAAQ;YACrB,UAAU,EAAE,QAAQ;YACpB,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,QAAQ;SACzB,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,gFAAgF;QAChF,IAAA,sBAAQ,EAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;QACpC,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAdD,0CAcC","sourcesContent":["// eslint-disable-next-line @typescript-eslint/triple-slash-reference, spaced-comment\n/// <reference path=\"../../../../../node_modules/ses/types.d.ts\" />\n\nimport { logError } from '@metamask/snaps-utils';\n\n/**\n * Execute SES lockdown in the current context, i.e., the current iframe.\n *\n * @throws If the SES lockdown failed.\n */\nexport function executeLockdown() {\n try {\n lockdown({\n consoleTaming: 'unsafe',\n errorTaming: 'unsafe',\n mathTaming: 'unsafe',\n dateTaming: 'unsafe',\n overrideTaming: 'severe',\n });\n } catch (error) {\n // If the `lockdown` call throws an exception, it should not be able to continue\n logError('Lockdown failed:', error);\n throw error;\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lockdown.d.cts","sourceRoot":"","sources":["../../../src/common/lockdown/lockdown.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,wBAAgB,eAAe,SAc9B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lockdown.d.mts","sourceRoot":"","sources":["../../../src/common/lockdown/lockdown.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,wBAAgB,eAAe,SAc9B"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/triple-slash-reference, spaced-comment
|
|
2
|
-
/// <reference path="../../../../../node_modules/ses/types.d.ts" />
|
|
3
|
-
import { logError } from "@metamask/snaps-utils";
|
|
4
|
-
/**
|
|
5
|
-
* Execute SES lockdown in the current context, i.e., the current iframe.
|
|
6
|
-
*
|
|
7
|
-
* @throws If the SES lockdown failed.
|
|
8
|
-
*/
|
|
9
|
-
export function executeLockdown() {
|
|
10
|
-
try {
|
|
11
|
-
lockdown({
|
|
12
|
-
consoleTaming: 'unsafe',
|
|
13
|
-
errorTaming: 'unsafe',
|
|
14
|
-
mathTaming: 'unsafe',
|
|
15
|
-
dateTaming: 'unsafe',
|
|
16
|
-
overrideTaming: 'severe',
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
catch (error) {
|
|
20
|
-
// If the `lockdown` call throws an exception, it should not be able to continue
|
|
21
|
-
logError('Lockdown failed:', error);
|
|
22
|
-
throw error;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=lockdown.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lockdown.mjs","sourceRoot":"","sources":["../../../src/common/lockdown/lockdown.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,mEAAmE;AAEnE,OAAO,EAAE,QAAQ,EAAE,8BAA8B;AAEjD;;;;GAIG;AACH,MAAM,UAAU,eAAe;IAC7B,IAAI,CAAC;QACH,QAAQ,CAAC;YACP,aAAa,EAAE,QAAQ;YACvB,WAAW,EAAE,QAAQ;YACrB,UAAU,EAAE,QAAQ;YACpB,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,QAAQ;SACzB,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,gFAAgF;QAChF,QAAQ,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;QACpC,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["// eslint-disable-next-line @typescript-eslint/triple-slash-reference, spaced-comment\n/// <reference path=\"../../../../../node_modules/ses/types.d.ts\" />\n\nimport { logError } from '@metamask/snaps-utils';\n\n/**\n * Execute SES lockdown in the current context, i.e., the current iframe.\n *\n * @throws If the SES lockdown failed.\n */\nexport function executeLockdown() {\n try {\n lockdown({\n consoleTaming: 'unsafe',\n errorTaming: 'unsafe',\n mathTaming: 'unsafe',\n dateTaming: 'unsafe',\n overrideTaming: 'severe',\n });\n } catch (error) {\n // If the `lockdown` call throws an exception, it should not be able to continue\n logError('Lockdown failed:', error);\n throw error;\n }\n}\n"]}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// original source sortParamKeys from: https://github.com/etclabscore/sig.tools/blob/master/src/postMessageServer/postMessageServer.ts#L75-L77
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.sortParamKeys = void 0;
|
|
5
|
-
/**
|
|
6
|
-
* Deterministically sort JSON-RPC parameter keys. This makes it possible to
|
|
7
|
-
* support both arrays and objects as parameters. Objects are sorted and turned
|
|
8
|
-
* into arrays, for easier consumption by the snap.
|
|
9
|
-
*
|
|
10
|
-
* The order is defined by the `method` parameter.
|
|
11
|
-
*
|
|
12
|
-
* @param methodParams - The parameters of the JSON-RPC method, which
|
|
13
|
-
* determines the ordering for the parameters.
|
|
14
|
-
* @param params - JSON-RPC parameters as object or array.
|
|
15
|
-
* @returns The values for the sorted keys. If `params` is not provided, this
|
|
16
|
-
* returns an empty array. If `params` is an array, this returns the same
|
|
17
|
-
* `params`.
|
|
18
|
-
*/
|
|
19
|
-
const sortParamKeys = (methodParams, params) => {
|
|
20
|
-
if (!params) {
|
|
21
|
-
return [];
|
|
22
|
-
}
|
|
23
|
-
if (params instanceof Array) {
|
|
24
|
-
return params;
|
|
25
|
-
}
|
|
26
|
-
const methodParamsOrder = methodParams.reduce((paramsOrderObj, paramsName, i) => ({
|
|
27
|
-
...paramsOrderObj,
|
|
28
|
-
[paramsName]: i,
|
|
29
|
-
}), {});
|
|
30
|
-
return Object.entries(params)
|
|
31
|
-
.sort(([name1, _1], [name2, _2]) => methodParamsOrder[name1] - methodParamsOrder[name2])
|
|
32
|
-
.map(([_, val]) => val);
|
|
33
|
-
};
|
|
34
|
-
exports.sortParamKeys = sortParamKeys;
|
|
35
|
-
//# sourceMappingURL=sortParams.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sortParams.cjs","sourceRoot":"","sources":["../../src/common/sortParams.ts"],"names":[],"mappings":";AAAA,8IAA8I;;;AAI9I;;;;;;;;;;;;;GAaG;AACI,MAAM,aAAa,GAAG,CAC3B,YAAsB,EACtB,MAAsB,EACtB,EAAE;IACF,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,MAAM,YAAY,KAAK,EAAE,CAAC;QAC5B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,iBAAiB,GAA4B,YAAY,CAAC,MAAM,CACpE,CAAC,cAAc,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAClC,GAAG,cAAc;QACjB,CAAC,UAAU,CAAC,EAAE,CAAC;KAChB,CAAC,EACF,EAAE,CACH,CAAC;IAEF,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;SAC1B,IAAI,CACH,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE,CAC3B,iBAAiB,CAAC,KAAK,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,CACtD;SACA,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC,CAAC;AA1BW,QAAA,aAAa,iBA0BxB","sourcesContent":["// original source sortParamKeys from: https://github.com/etclabscore/sig.tools/blob/master/src/postMessageServer/postMessageServer.ts#L75-L77\n\nimport type { JsonRpcParams } from '@metamask/utils';\n\n/**\n * Deterministically sort JSON-RPC parameter keys. This makes it possible to\n * support both arrays and objects as parameters. Objects are sorted and turned\n * into arrays, for easier consumption by the snap.\n *\n * The order is defined by the `method` parameter.\n *\n * @param methodParams - The parameters of the JSON-RPC method, which\n * determines the ordering for the parameters.\n * @param params - JSON-RPC parameters as object or array.\n * @returns The values for the sorted keys. If `params` is not provided, this\n * returns an empty array. If `params` is an array, this returns the same\n * `params`.\n */\nexport const sortParamKeys = (\n methodParams: string[],\n params?: JsonRpcParams,\n) => {\n if (!params) {\n return [];\n }\n\n if (params instanceof Array) {\n return params;\n }\n\n const methodParamsOrder: { [k: string]: number } = methodParams.reduce(\n (paramsOrderObj, paramsName, i) => ({\n ...paramsOrderObj,\n [paramsName]: i,\n }),\n {},\n );\n\n return Object.entries(params)\n .sort(\n ([name1, _1], [name2, _2]) =>\n methodParamsOrder[name1] - methodParamsOrder[name2],\n )\n .map(([_, val]) => val);\n};\n"]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { JsonRpcParams } from "@metamask/utils";
|
|
2
|
-
/**
|
|
3
|
-
* Deterministically sort JSON-RPC parameter keys. This makes it possible to
|
|
4
|
-
* support both arrays and objects as parameters. Objects are sorted and turned
|
|
5
|
-
* into arrays, for easier consumption by the snap.
|
|
6
|
-
*
|
|
7
|
-
* The order is defined by the `method` parameter.
|
|
8
|
-
*
|
|
9
|
-
* @param methodParams - The parameters of the JSON-RPC method, which
|
|
10
|
-
* determines the ordering for the parameters.
|
|
11
|
-
* @param params - JSON-RPC parameters as object or array.
|
|
12
|
-
* @returns The values for the sorted keys. If `params` is not provided, this
|
|
13
|
-
* returns an empty array. If `params` is an array, this returns the same
|
|
14
|
-
* `params`.
|
|
15
|
-
*/
|
|
16
|
-
export declare const sortParamKeys: (methodParams: string[], params?: JsonRpcParams) => import("@metamask/utils").Json[];
|
|
17
|
-
//# sourceMappingURL=sortParams.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sortParams.d.cts","sourceRoot":"","sources":["../../src/common/sortParams.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAErD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa,iBACV,MAAM,EAAE,WACb,aAAa,qCAwBvB,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { JsonRpcParams } from "@metamask/utils";
|
|
2
|
-
/**
|
|
3
|
-
* Deterministically sort JSON-RPC parameter keys. This makes it possible to
|
|
4
|
-
* support both arrays and objects as parameters. Objects are sorted and turned
|
|
5
|
-
* into arrays, for easier consumption by the snap.
|
|
6
|
-
*
|
|
7
|
-
* The order is defined by the `method` parameter.
|
|
8
|
-
*
|
|
9
|
-
* @param methodParams - The parameters of the JSON-RPC method, which
|
|
10
|
-
* determines the ordering for the parameters.
|
|
11
|
-
* @param params - JSON-RPC parameters as object or array.
|
|
12
|
-
* @returns The values for the sorted keys. If `params` is not provided, this
|
|
13
|
-
* returns an empty array. If `params` is an array, this returns the same
|
|
14
|
-
* `params`.
|
|
15
|
-
*/
|
|
16
|
-
export declare const sortParamKeys: (methodParams: string[], params?: JsonRpcParams) => import("@metamask/utils").Json[];
|
|
17
|
-
//# sourceMappingURL=sortParams.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sortParams.d.mts","sourceRoot":"","sources":["../../src/common/sortParams.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAErD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa,iBACV,MAAM,EAAE,WACb,aAAa,qCAwBvB,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// original source sortParamKeys from: https://github.com/etclabscore/sig.tools/blob/master/src/postMessageServer/postMessageServer.ts#L75-L77
|
|
2
|
-
/**
|
|
3
|
-
* Deterministically sort JSON-RPC parameter keys. This makes it possible to
|
|
4
|
-
* support both arrays and objects as parameters. Objects are sorted and turned
|
|
5
|
-
* into arrays, for easier consumption by the snap.
|
|
6
|
-
*
|
|
7
|
-
* The order is defined by the `method` parameter.
|
|
8
|
-
*
|
|
9
|
-
* @param methodParams - The parameters of the JSON-RPC method, which
|
|
10
|
-
* determines the ordering for the parameters.
|
|
11
|
-
* @param params - JSON-RPC parameters as object or array.
|
|
12
|
-
* @returns The values for the sorted keys. If `params` is not provided, this
|
|
13
|
-
* returns an empty array. If `params` is an array, this returns the same
|
|
14
|
-
* `params`.
|
|
15
|
-
*/
|
|
16
|
-
export const sortParamKeys = (methodParams, params) => {
|
|
17
|
-
if (!params) {
|
|
18
|
-
return [];
|
|
19
|
-
}
|
|
20
|
-
if (params instanceof Array) {
|
|
21
|
-
return params;
|
|
22
|
-
}
|
|
23
|
-
const methodParamsOrder = methodParams.reduce((paramsOrderObj, paramsName, i) => ({
|
|
24
|
-
...paramsOrderObj,
|
|
25
|
-
[paramsName]: i,
|
|
26
|
-
}), {});
|
|
27
|
-
return Object.entries(params)
|
|
28
|
-
.sort(([name1, _1], [name2, _2]) => methodParamsOrder[name1] - methodParamsOrder[name2])
|
|
29
|
-
.map(([_, val]) => val);
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=sortParams.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sortParams.mjs","sourceRoot":"","sources":["../../src/common/sortParams.ts"],"names":[],"mappings":"AAAA,8IAA8I;AAI9I;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,YAAsB,EACtB,MAAsB,EACtB,EAAE;IACF,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,MAAM,YAAY,KAAK,EAAE,CAAC;QAC5B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,iBAAiB,GAA4B,YAAY,CAAC,MAAM,CACpE,CAAC,cAAc,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAClC,GAAG,cAAc;QACjB,CAAC,UAAU,CAAC,EAAE,CAAC;KAChB,CAAC,EACF,EAAE,CACH,CAAC;IAEF,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;SAC1B,IAAI,CACH,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE,CAC3B,iBAAiB,CAAC,KAAK,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,CACtD;SACA,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC,CAAC","sourcesContent":["// original source sortParamKeys from: https://github.com/etclabscore/sig.tools/blob/master/src/postMessageServer/postMessageServer.ts#L75-L77\n\nimport type { JsonRpcParams } from '@metamask/utils';\n\n/**\n * Deterministically sort JSON-RPC parameter keys. This makes it possible to\n * support both arrays and objects as parameters. Objects are sorted and turned\n * into arrays, for easier consumption by the snap.\n *\n * The order is defined by the `method` parameter.\n *\n * @param methodParams - The parameters of the JSON-RPC method, which\n * determines the ordering for the parameters.\n * @param params - JSON-RPC parameters as object or array.\n * @returns The values for the sorted keys. If `params` is not provided, this\n * returns an empty array. If `params` is an array, this returns the same\n * `params`.\n */\nexport const sortParamKeys = (\n methodParams: string[],\n params?: JsonRpcParams,\n) => {\n if (!params) {\n return [];\n }\n\n if (params instanceof Array) {\n return params;\n }\n\n const methodParamsOrder: { [k: string]: number } = methodParams.reduce(\n (paramsOrderObj, paramsName, i) => ({\n ...paramsOrderObj,\n [paramsName]: i,\n }),\n {},\n );\n\n return Object.entries(params)\n .sort(\n ([name1, _1], [name2, _2]) =>\n methodParamsOrder[name1] - methodParamsOrder[name2],\n )\n .map(([_, val]) => val);\n};\n"]}
|