@metamask/snaps-utils 9.1.0 → 9.2.1
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 +18 -1
- package/dist/cronjob.d.cts +9 -9
- package/dist/cronjob.d.mts +9 -9
- package/dist/eval-worker.cjs +4 -5
- package/dist/eval-worker.cjs.map +1 -1
- package/dist/eval-worker.mjs +3 -4
- package/dist/eval-worker.mjs.map +1 -1
- package/dist/handlers/asset-historical-price.cjs +25 -0
- package/dist/handlers/asset-historical-price.cjs.map +1 -0
- package/dist/handlers/asset-historical-price.d.cts +37 -0
- package/dist/handlers/asset-historical-price.d.cts.map +1 -0
- package/dist/handlers/asset-historical-price.d.mts +37 -0
- package/dist/handlers/asset-historical-price.d.mts.map +1 -0
- package/dist/handlers/asset-historical-price.mjs +22 -0
- package/dist/handlers/asset-historical-price.mjs.map +1 -0
- package/dist/handlers/assets-conversion.cjs +38 -0
- package/dist/handlers/assets-conversion.cjs.map +1 -0
- package/dist/handlers/assets-conversion.d.cts +90 -0
- package/dist/handlers/assets-conversion.d.cts.map +1 -0
- package/dist/handlers/assets-conversion.d.mts +90 -0
- package/dist/handlers/assets-conversion.d.mts.map +1 -0
- package/dist/handlers/assets-conversion.mjs +35 -0
- package/dist/handlers/assets-conversion.mjs.map +1 -0
- package/dist/handlers/exports.cjs +113 -0
- package/dist/handlers/exports.cjs.map +1 -0
- package/dist/handlers/exports.d.cts +81 -0
- package/dist/handlers/exports.d.cts.map +1 -0
- package/dist/handlers/exports.d.mts +81 -0
- package/dist/handlers/exports.d.mts.map +1 -0
- package/dist/{handlers.mjs → handlers/exports.mjs} +10 -45
- package/dist/handlers/exports.mjs.map +1 -0
- package/dist/handlers/home-page.cjs +16 -0
- package/dist/handlers/home-page.cjs.map +1 -0
- package/dist/handlers/home-page.d.cts +268 -0
- package/dist/handlers/home-page.d.cts.map +1 -0
- package/dist/handlers/home-page.d.mts +268 -0
- package/dist/handlers/home-page.d.mts.map +1 -0
- package/dist/handlers/home-page.mjs +13 -0
- package/dist/handlers/home-page.mjs.map +1 -0
- package/dist/handlers/index.cjs +26 -0
- package/dist/handlers/index.cjs.map +1 -0
- package/dist/handlers/index.d.cts +10 -0
- package/dist/handlers/index.d.cts.map +1 -0
- package/dist/handlers/index.d.mts +10 -0
- package/dist/handlers/index.d.mts.map +1 -0
- package/dist/handlers/index.mjs +10 -0
- package/dist/handlers/index.mjs.map +1 -0
- package/dist/handlers/name-lookup.cjs +21 -0
- package/dist/handlers/name-lookup.cjs.map +1 -0
- package/dist/handlers/name-lookup.d.cts +67 -0
- package/dist/handlers/name-lookup.d.cts.map +1 -0
- package/dist/handlers/name-lookup.d.mts +67 -0
- package/dist/handlers/name-lookup.d.mts.map +1 -0
- package/dist/handlers/name-lookup.mjs +18 -0
- package/dist/handlers/name-lookup.mjs.map +1 -0
- package/dist/handlers/settings-page.cjs +6 -0
- package/dist/handlers/settings-page.cjs.map +1 -0
- package/dist/handlers/settings-page.d.cts +90 -0
- package/dist/handlers/settings-page.d.cts.map +1 -0
- package/dist/handlers/settings-page.d.mts +90 -0
- package/dist/handlers/settings-page.d.mts.map +1 -0
- package/dist/handlers/settings-page.mjs +3 -0
- package/dist/handlers/settings-page.mjs.map +1 -0
- package/dist/handlers/signature.cjs +6 -0
- package/dist/handlers/signature.cjs.map +1 -0
- package/dist/handlers/signature.d.cts +92 -0
- package/dist/handlers/signature.d.cts.map +1 -0
- package/dist/handlers/signature.d.mts +92 -0
- package/dist/handlers/signature.d.mts.map +1 -0
- package/dist/handlers/signature.mjs +3 -0
- package/dist/handlers/signature.mjs.map +1 -0
- package/dist/handlers/transaction.cjs +19 -0
- package/dist/handlers/transaction.cjs.map +1 -0
- package/dist/handlers/transaction.d.cts +280 -0
- package/dist/handlers/transaction.d.cts.map +1 -0
- package/dist/handlers/transaction.d.mts +280 -0
- package/dist/handlers/transaction.d.mts.map +1 -0
- package/dist/handlers/transaction.mjs +16 -0
- package/dist/handlers/transaction.mjs.map +1 -0
- package/dist/{handler-types.cjs → handlers/types.cjs} +3 -3
- package/dist/handlers/types.cjs.map +1 -0
- package/dist/{handler-types.d.mts → handlers/types.d.cts} +22 -2
- package/dist/handlers/types.d.cts.map +1 -0
- package/dist/{handler-types.d.cts → handlers/types.d.mts} +22 -2
- package/dist/handlers/types.d.mts.map +1 -0
- package/dist/{handler-types.mjs → handlers/types.mjs} +2 -2
- package/dist/handlers/types.mjs.map +1 -0
- package/dist/iframe.test.browser.cjs +20 -19
- package/dist/iframe.test.browser.cjs.map +1 -1
- package/dist/iframe.test.browser.mjs +2 -1
- package/dist/iframe.test.browser.mjs.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.executionenv.cjs +3 -2
- package/dist/index.executionenv.cjs.map +1 -1
- package/dist/index.executionenv.d.cts +3 -2
- package/dist/index.executionenv.d.cts.map +1 -1
- package/dist/index.executionenv.d.mts +3 -2
- package/dist/index.executionenv.d.mts.map +1 -1
- package/dist/index.executionenv.mjs +3 -2
- package/dist/index.executionenv.mjs.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/json-rpc.cjs.map +1 -1
- package/dist/json-rpc.d.cts +2 -2
- package/dist/json-rpc.d.cts.map +1 -1
- package/dist/json-rpc.d.mts +2 -2
- package/dist/json-rpc.d.mts.map +1 -1
- package/dist/json-rpc.mjs.map +1 -1
- package/dist/json.cjs +5 -1
- package/dist/json.cjs.map +1 -1
- package/dist/json.d.cts +3 -0
- package/dist/json.d.cts.map +1 -1
- package/dist/json.d.mts +3 -0
- package/dist/json.d.mts.map +1 -1
- package/dist/json.mjs +5 -1
- package/dist/json.mjs.map +1 -1
- package/dist/localization.d.cts +5 -5
- package/dist/localization.d.mts +5 -5
- package/dist/manifest/validation.d.cts +12 -12
- package/dist/manifest/validation.d.mts +12 -12
- package/dist/time.cjs +34 -0
- package/dist/time.cjs.map +1 -0
- package/dist/time.d.cts +9 -0
- package/dist/time.d.cts.map +1 -0
- package/dist/time.d.mts +9 -0
- package/dist/time.d.mts.map +1 -0
- package/dist/time.mjs +31 -0
- package/dist/time.mjs.map +1 -0
- package/dist/types.d.cts +2 -2
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +2 -2
- package/dist/types.d.mts.map +1 -1
- package/package.json +17 -24
- package/dist/handler-types.cjs.map +0 -1
- package/dist/handler-types.d.cts.map +0 -1
- package/dist/handler-types.d.mts.map +0 -1
- package/dist/handler-types.mjs.map +0 -1
- package/dist/handlers.cjs +0 -148
- package/dist/handlers.cjs.map +0 -1
- package/dist/handlers.d.cts +0 -887
- package/dist/handlers.d.cts.map +0 -1
- package/dist/handlers.d.mts +0 -887
- package/dist/handlers.d.mts.map +0 -1
- package/dist/handlers.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [9.2.1]
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Reduce unnecessary validation on responses ([#3350](https://github.com/MetaMask/snaps/pull/3350))
|
|
15
|
+
- Speed up JSON size calculation ([#3348](https://github.com/MetaMask/snaps/pull/3348))
|
|
16
|
+
|
|
17
|
+
## [9.2.0]
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- Add ISO 8601 time structs ([#3287](https://github.com/MetaMask/snaps/pull/3287))
|
|
22
|
+
- Add support for market data to `onAssetsConversion` handler ([#3299](https://github.com/MetaMask/snaps/pull/3299))
|
|
23
|
+
- Add support for `onAssetHistoricalPrice` handler ([#3282](https://github.com/MetaMask/snaps/pull/3282))
|
|
24
|
+
|
|
10
25
|
## [9.1.0]
|
|
11
26
|
|
|
12
27
|
### Added
|
|
@@ -582,7 +597,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
582
597
|
- The version of the package no longer needs to match the version of all other
|
|
583
598
|
MetaMask Snaps packages.
|
|
584
599
|
|
|
585
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@9.1
|
|
600
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@9.2.1...HEAD
|
|
601
|
+
[9.2.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@9.2.0...@metamask/snaps-utils@9.2.1
|
|
602
|
+
[9.2.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@9.1.0...@metamask/snaps-utils@9.2.0
|
|
586
603
|
[9.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@9.0.1...@metamask/snaps-utils@9.1.0
|
|
587
604
|
[9.0.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@9.0.0...@metamask/snaps-utils@9.0.1
|
|
588
605
|
[9.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@8.10.0...@metamask/snaps-utils@9.0.0
|
package/dist/cronjob.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Infer } from "@metamask/superstruct";
|
|
2
2
|
export declare const CronjobRpcRequestStruct: import("@metamask/superstruct").Struct<{
|
|
3
3
|
method: string;
|
|
4
|
-
id?: string | number | null | undefined;
|
|
5
4
|
jsonrpc?: "2.0" | undefined;
|
|
5
|
+
id?: string | number | null | undefined;
|
|
6
6
|
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
7
7
|
}, {
|
|
8
8
|
jsonrpc: import("@metamask/superstruct").Struct<"2.0" | undefined, "2.0">;
|
|
@@ -21,19 +21,19 @@ export type CronExpression = Infer<typeof CronExpressionStruct>;
|
|
|
21
21
|
*/
|
|
22
22
|
export declare function parseCronExpression(expression: string | object): import("cron-parser").CronExpression<false>;
|
|
23
23
|
export declare const CronjobSpecificationStruct: import("@metamask/superstruct").Struct<{
|
|
24
|
+
expression: string;
|
|
24
25
|
request: {
|
|
25
26
|
method: string;
|
|
26
|
-
id?: string | number | null | undefined;
|
|
27
27
|
jsonrpc?: "2.0" | undefined;
|
|
28
|
+
id?: string | number | null | undefined;
|
|
28
29
|
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
29
30
|
};
|
|
30
|
-
expression: string;
|
|
31
31
|
}, {
|
|
32
32
|
expression: import("@metamask/superstruct").Struct<string, null>;
|
|
33
33
|
request: import("@metamask/superstruct").Struct<{
|
|
34
34
|
method: string;
|
|
35
|
-
id?: string | number | null | undefined;
|
|
36
35
|
jsonrpc?: "2.0" | undefined;
|
|
36
|
+
id?: string | number | null | undefined;
|
|
37
37
|
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
38
38
|
}, {
|
|
39
39
|
jsonrpc: import("@metamask/superstruct").Struct<"2.0" | undefined, "2.0">;
|
|
@@ -51,27 +51,27 @@ export type CronjobSpecification = Infer<typeof CronjobSpecificationStruct>;
|
|
|
51
51
|
*/
|
|
52
52
|
export declare function isCronjobSpecification(value: unknown): boolean;
|
|
53
53
|
export declare const CronjobSpecificationArrayStruct: import("@metamask/superstruct").Struct<{
|
|
54
|
+
expression: string;
|
|
54
55
|
request: {
|
|
55
56
|
method: string;
|
|
56
|
-
id?: string | number | null | undefined;
|
|
57
57
|
jsonrpc?: "2.0" | undefined;
|
|
58
|
+
id?: string | number | null | undefined;
|
|
58
59
|
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
59
60
|
};
|
|
60
|
-
expression: string;
|
|
61
61
|
}[], import("@metamask/superstruct").Struct<{
|
|
62
|
+
expression: string;
|
|
62
63
|
request: {
|
|
63
64
|
method: string;
|
|
64
|
-
id?: string | number | null | undefined;
|
|
65
65
|
jsonrpc?: "2.0" | undefined;
|
|
66
|
+
id?: string | number | null | undefined;
|
|
66
67
|
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
67
68
|
};
|
|
68
|
-
expression: string;
|
|
69
69
|
}, {
|
|
70
70
|
expression: import("@metamask/superstruct").Struct<string, null>;
|
|
71
71
|
request: import("@metamask/superstruct").Struct<{
|
|
72
72
|
method: string;
|
|
73
|
-
id?: string | number | null | undefined;
|
|
74
73
|
jsonrpc?: "2.0" | undefined;
|
|
74
|
+
id?: string | number | null | undefined;
|
|
75
75
|
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
76
76
|
}, {
|
|
77
77
|
jsonrpc: import("@metamask/superstruct").Struct<"2.0" | undefined, "2.0">;
|
package/dist/cronjob.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Infer } from "@metamask/superstruct";
|
|
2
2
|
export declare const CronjobRpcRequestStruct: import("@metamask/superstruct").Struct<{
|
|
3
3
|
method: string;
|
|
4
|
-
id?: string | number | null | undefined;
|
|
5
4
|
jsonrpc?: "2.0" | undefined;
|
|
5
|
+
id?: string | number | null | undefined;
|
|
6
6
|
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
7
7
|
}, {
|
|
8
8
|
jsonrpc: import("@metamask/superstruct").Struct<"2.0" | undefined, "2.0">;
|
|
@@ -21,19 +21,19 @@ export type CronExpression = Infer<typeof CronExpressionStruct>;
|
|
|
21
21
|
*/
|
|
22
22
|
export declare function parseCronExpression(expression: string | object): import("cron-parser").CronExpression<false>;
|
|
23
23
|
export declare const CronjobSpecificationStruct: import("@metamask/superstruct").Struct<{
|
|
24
|
+
expression: string;
|
|
24
25
|
request: {
|
|
25
26
|
method: string;
|
|
26
|
-
id?: string | number | null | undefined;
|
|
27
27
|
jsonrpc?: "2.0" | undefined;
|
|
28
|
+
id?: string | number | null | undefined;
|
|
28
29
|
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
29
30
|
};
|
|
30
|
-
expression: string;
|
|
31
31
|
}, {
|
|
32
32
|
expression: import("@metamask/superstruct").Struct<string, null>;
|
|
33
33
|
request: import("@metamask/superstruct").Struct<{
|
|
34
34
|
method: string;
|
|
35
|
-
id?: string | number | null | undefined;
|
|
36
35
|
jsonrpc?: "2.0" | undefined;
|
|
36
|
+
id?: string | number | null | undefined;
|
|
37
37
|
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
38
38
|
}, {
|
|
39
39
|
jsonrpc: import("@metamask/superstruct").Struct<"2.0" | undefined, "2.0">;
|
|
@@ -51,27 +51,27 @@ export type CronjobSpecification = Infer<typeof CronjobSpecificationStruct>;
|
|
|
51
51
|
*/
|
|
52
52
|
export declare function isCronjobSpecification(value: unknown): boolean;
|
|
53
53
|
export declare const CronjobSpecificationArrayStruct: import("@metamask/superstruct").Struct<{
|
|
54
|
+
expression: string;
|
|
54
55
|
request: {
|
|
55
56
|
method: string;
|
|
56
|
-
id?: string | number | null | undefined;
|
|
57
57
|
jsonrpc?: "2.0" | undefined;
|
|
58
|
+
id?: string | number | null | undefined;
|
|
58
59
|
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
59
60
|
};
|
|
60
|
-
expression: string;
|
|
61
61
|
}[], import("@metamask/superstruct").Struct<{
|
|
62
|
+
expression: string;
|
|
62
63
|
request: {
|
|
63
64
|
method: string;
|
|
64
|
-
id?: string | number | null | undefined;
|
|
65
65
|
jsonrpc?: "2.0" | undefined;
|
|
66
|
+
id?: string | number | null | undefined;
|
|
66
67
|
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
67
68
|
};
|
|
68
|
-
expression: string;
|
|
69
69
|
}, {
|
|
70
70
|
expression: import("@metamask/superstruct").Struct<string, null>;
|
|
71
71
|
request: import("@metamask/superstruct").Struct<{
|
|
72
72
|
method: string;
|
|
73
|
-
id?: string | number | null | undefined;
|
|
74
73
|
jsonrpc?: "2.0" | undefined;
|
|
74
|
+
id?: string | number | null | undefined;
|
|
75
75
|
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
76
76
|
}, {
|
|
77
77
|
jsonrpc: import("@metamask/superstruct").Struct<"2.0" | undefined, "2.0">;
|
package/dist/eval-worker.cjs
CHANGED
|
@@ -6,14 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
// eslint-disable-next-line import-x/no-unassigned-import
|
|
7
7
|
require("ses/lockdown");
|
|
8
8
|
const fs_1 = require("fs");
|
|
9
|
-
const
|
|
9
|
+
const handlers_1 = require("./handlers/index.cjs");
|
|
10
10
|
const mock_1 = require("./mock.cjs");
|
|
11
11
|
lockdown({
|
|
12
|
-
consoleTaming: 'unsafe',
|
|
13
12
|
errorTaming: 'unsafe',
|
|
14
|
-
|
|
15
|
-
dateTaming: 'unsafe',
|
|
13
|
+
stackFiltering: 'verbose',
|
|
16
14
|
overrideTaming: 'severe',
|
|
15
|
+
localeTaming: 'unsafe',
|
|
17
16
|
// We disable domain taming, because it does not work in certain cases when
|
|
18
17
|
// running tests. This is unlikely to be a problem in production, because
|
|
19
18
|
// Node.js domains are deprecated.
|
|
@@ -31,7 +30,7 @@ compartment.globalThis.self = compartment.globalThis;
|
|
|
31
30
|
compartment.globalThis.global = compartment.globalThis;
|
|
32
31
|
compartment.globalThis.window = compartment.globalThis;
|
|
33
32
|
compartment.evaluate((0, fs_1.readFileSync)(snapFilePath, 'utf8'));
|
|
34
|
-
const invalidExports = Object.keys(snapModule.exports).filter((snapExport) => !
|
|
33
|
+
const invalidExports = Object.keys(snapModule.exports).filter((snapExport) => !handlers_1.SNAP_EXPORT_NAMES.includes(snapExport));
|
|
35
34
|
if (invalidExports.length > 0) {
|
|
36
35
|
// eslint-disable-next-line no-console
|
|
37
36
|
console.warn(`Invalid snap exports detected:\n${invalidExports.join('\n')}`);
|
package/dist/eval-worker.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eval-worker.cjs","sourceRoot":"","sources":["../src/eval-worker.ts"],"names":[],"mappings":";;AAAA,6DAA6D;AAC7D,4EAA4E;AAC5E,6CAA6C;AAC7C,yDAAyD;AACzD,wBAAsB;AAEtB,2BAAkC;AAGlC,
|
|
1
|
+
{"version":3,"file":"eval-worker.cjs","sourceRoot":"","sources":["../src/eval-worker.ts"],"names":[],"mappings":";;AAAA,6DAA6D;AAC7D,4EAA4E;AAC5E,6CAA6C;AAC7C,yDAAyD;AACzD,wBAAsB;AAEtB,2BAAkC;AAGlC,mDAA+C;AAC/C,qCAAgD;AAIhD,QAAQ,CAAC;IACP,WAAW,EAAE,QAAQ;IACrB,cAAc,EAAE,SAAS;IACzB,cAAc,EAAE,QAAQ;IACxB,YAAY,EAAE,QAAQ;IAEtB,2EAA2E;IAC3E,yEAAyE;IACzE,kCAAkC;IAClC,YAAY,EAAE,QAAQ;CACvB,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAErC,MAAM,UAAU,GAAsB,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAEtD,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC;IAClC,GAAG,IAAA,6BAAsB,GAAE;IAC3B,MAAM,EAAE,UAAU;IAClB,OAAO,EAAE,UAAU,CAAC,OAAO;CAC5B,CAAC,CAAC;AAEH,0BAA0B;AAC1B,WAAW,CAAC,UAAU,CAAC,IAAI,GAAG,WAAW,CAAC,UAAU,CAAC;AACrD,WAAW,CAAC,UAAU,CAAC,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC;AACvD,WAAW,CAAC,UAAU,CAAC,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC;AAEvD,WAAW,CAAC,QAAQ,CAAC,IAAA,iBAAY,EAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;AAEzD,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,MAAM,CAC3D,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,4BAAiB,CAAC,QAAQ,CAAC,UAAyB,CAAC,CACvE,CAAC;AAEF,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;IAC9B,sCAAsC;IACtC,OAAO,CAAC,IAAI,CAAC,mCAAmC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC/E,CAAC;AAED,0DAA0D;AAC1D,0EAA0E;AAC1E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC","sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore - TypeScript complains about this being ESM in a CJS file, but\n// `ses/lockdown` has a CommonJS entry point.\n// eslint-disable-next-line import-x/no-unassigned-import\nimport 'ses/lockdown';\n\nimport { readFileSync } from 'fs';\n\nimport type { HandlerType } from './handlers';\nimport { SNAP_EXPORT_NAMES } from './handlers';\nimport { generateMockEndowments } from './mock';\n\ndeclare let lockdown: any, Compartment: any;\n\nlockdown({\n errorTaming: 'unsafe',\n stackFiltering: 'verbose',\n overrideTaming: 'severe',\n localeTaming: 'unsafe',\n\n // We disable domain taming, because it does not work in certain cases when\n // running tests. This is unlikely to be a problem in production, because\n // Node.js domains are deprecated.\n domainTaming: 'unsafe',\n});\n\nconst snapFilePath = process.argv[2];\n\nconst snapModule: { exports?: any } = { exports: {} };\n\nconst compartment = new Compartment({\n ...generateMockEndowments(),\n module: snapModule,\n exports: snapModule.exports,\n});\n\n// Mirror BaseSnapExecutor\ncompartment.globalThis.self = compartment.globalThis;\ncompartment.globalThis.global = compartment.globalThis;\ncompartment.globalThis.window = compartment.globalThis;\n\ncompartment.evaluate(readFileSync(snapFilePath, 'utf8'));\n\nconst invalidExports = Object.keys(snapModule.exports).filter(\n (snapExport) => !SNAP_EXPORT_NAMES.includes(snapExport as HandlerType),\n);\n\nif (invalidExports.length > 0) {\n // eslint-disable-next-line no-console\n console.warn(`Invalid snap exports detected:\\n${invalidExports.join('\\n')}`);\n}\n\n// To ensure the worker exits we explicitly call exit here\n// If we didn't the eval would wait for timers set during Compartment eval\nprocess.exit(0);\n"]}
|
package/dist/eval-worker.mjs
CHANGED
|
@@ -4,14 +4,13 @@
|
|
|
4
4
|
// eslint-disable-next-line import-x/no-unassigned-import
|
|
5
5
|
import "ses/lockdown";
|
|
6
6
|
import { readFileSync } from "fs";
|
|
7
|
-
import { SNAP_EXPORT_NAMES } from "./
|
|
7
|
+
import { SNAP_EXPORT_NAMES } from "./handlers/index.mjs";
|
|
8
8
|
import { generateMockEndowments } from "./mock.mjs";
|
|
9
9
|
lockdown({
|
|
10
|
-
consoleTaming: 'unsafe',
|
|
11
10
|
errorTaming: 'unsafe',
|
|
12
|
-
|
|
13
|
-
dateTaming: 'unsafe',
|
|
11
|
+
stackFiltering: 'verbose',
|
|
14
12
|
overrideTaming: 'severe',
|
|
13
|
+
localeTaming: 'unsafe',
|
|
15
14
|
// We disable domain taming, because it does not work in certain cases when
|
|
16
15
|
// running tests. This is unlikely to be a problem in production, because
|
|
17
16
|
// Node.js domains are deprecated.
|
package/dist/eval-worker.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eval-worker.mjs","sourceRoot":"","sources":["../src/eval-worker.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,4EAA4E;AAC5E,6CAA6C;AAC7C,yDAAyD;AACzD,sBAAsB;AAEtB,OAAO,EAAE,YAAY,EAAE,WAAW;AAGlC,OAAO,EAAE,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"eval-worker.mjs","sourceRoot":"","sources":["../src/eval-worker.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,4EAA4E;AAC5E,6CAA6C;AAC7C,yDAAyD;AACzD,sBAAsB;AAEtB,OAAO,EAAE,YAAY,EAAE,WAAW;AAGlC,OAAO,EAAE,iBAAiB,EAAE,6BAAmB;AAC/C,OAAO,EAAE,sBAAsB,EAAE,mBAAe;AAIhD,QAAQ,CAAC;IACP,WAAW,EAAE,QAAQ;IACrB,cAAc,EAAE,SAAS;IACzB,cAAc,EAAE,QAAQ;IACxB,YAAY,EAAE,QAAQ;IAEtB,2EAA2E;IAC3E,yEAAyE;IACzE,kCAAkC;IAClC,YAAY,EAAE,QAAQ;CACvB,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAErC,MAAM,UAAU,GAAsB,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAEtD,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC;IAClC,GAAG,sBAAsB,EAAE;IAC3B,MAAM,EAAE,UAAU;IAClB,OAAO,EAAE,UAAU,CAAC,OAAO;CAC5B,CAAC,CAAC;AAEH,0BAA0B;AAC1B,WAAW,CAAC,UAAU,CAAC,IAAI,GAAG,WAAW,CAAC,UAAU,CAAC;AACrD,WAAW,CAAC,UAAU,CAAC,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC;AACvD,WAAW,CAAC,UAAU,CAAC,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC;AAEvD,WAAW,CAAC,QAAQ,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;AAEzD,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,MAAM,CAC3D,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,iBAAiB,CAAC,QAAQ,CAAC,UAAyB,CAAC,CACvE,CAAC;AAEF,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;IAC9B,sCAAsC;IACtC,OAAO,CAAC,IAAI,CAAC,mCAAmC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC/E,CAAC;AAED,0DAA0D;AAC1D,0EAA0E;AAC1E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC","sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore - TypeScript complains about this being ESM in a CJS file, but\n// `ses/lockdown` has a CommonJS entry point.\n// eslint-disable-next-line import-x/no-unassigned-import\nimport 'ses/lockdown';\n\nimport { readFileSync } from 'fs';\n\nimport type { HandlerType } from './handlers';\nimport { SNAP_EXPORT_NAMES } from './handlers';\nimport { generateMockEndowments } from './mock';\n\ndeclare let lockdown: any, Compartment: any;\n\nlockdown({\n errorTaming: 'unsafe',\n stackFiltering: 'verbose',\n overrideTaming: 'severe',\n localeTaming: 'unsafe',\n\n // We disable domain taming, because it does not work in certain cases when\n // running tests. This is unlikely to be a problem in production, because\n // Node.js domains are deprecated.\n domainTaming: 'unsafe',\n});\n\nconst snapFilePath = process.argv[2];\n\nconst snapModule: { exports?: any } = { exports: {} };\n\nconst compartment = new Compartment({\n ...generateMockEndowments(),\n module: snapModule,\n exports: snapModule.exports,\n});\n\n// Mirror BaseSnapExecutor\ncompartment.globalThis.self = compartment.globalThis;\ncompartment.globalThis.global = compartment.globalThis;\ncompartment.globalThis.window = compartment.globalThis;\n\ncompartment.evaluate(readFileSync(snapFilePath, 'utf8'));\n\nconst invalidExports = Object.keys(snapModule.exports).filter(\n (snapExport) => !SNAP_EXPORT_NAMES.includes(snapExport as HandlerType),\n);\n\nif (invalidExports.length > 0) {\n // eslint-disable-next-line no-console\n console.warn(`Invalid snap exports detected:\\n${invalidExports.join('\\n')}`);\n}\n\n// To ensure the worker exits we explicitly call exit here\n// If we didn't the eval would wait for timers set during Compartment eval\nprocess.exit(0);\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OnAssetHistoricalPriceResponseStruct = exports.AssetHistoricalPriceStruct = exports.HistoricalPriceStruct = void 0;
|
|
4
|
+
const snaps_sdk_1 = require("@metamask/snaps-sdk");
|
|
5
|
+
const superstruct_1 = require("@metamask/superstruct");
|
|
6
|
+
const time_1 = require("../time.cjs");
|
|
7
|
+
/**
|
|
8
|
+
* A struct representing a historical price.
|
|
9
|
+
*/
|
|
10
|
+
exports.HistoricalPriceStruct = (0, snaps_sdk_1.nonEmptyRecord)((0, superstruct_1.union)([(0, superstruct_1.literal)('all'), time_1.ISO8601DurationStruct]), (0, superstruct_1.array)((0, superstruct_1.tuple)([(0, superstruct_1.number)(), (0, superstruct_1.string)()])));
|
|
11
|
+
/**
|
|
12
|
+
* A struct representing an asset's historical price.
|
|
13
|
+
*/
|
|
14
|
+
exports.AssetHistoricalPriceStruct = (0, superstruct_1.nullable)((0, superstruct_1.object)({
|
|
15
|
+
intervals: exports.HistoricalPriceStruct,
|
|
16
|
+
updateTime: (0, superstruct_1.number)(),
|
|
17
|
+
expirationTime: (0, superstruct_1.optional)((0, superstruct_1.number)()),
|
|
18
|
+
}));
|
|
19
|
+
/**
|
|
20
|
+
* A struct representing the response of the `onAssetHistoricalPrice` method.
|
|
21
|
+
*/
|
|
22
|
+
exports.OnAssetHistoricalPriceResponseStruct = (0, superstruct_1.object)({
|
|
23
|
+
historicalPrice: exports.AssetHistoricalPriceStruct,
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=asset-historical-price.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-historical-price.cjs","sourceRoot":"","sources":["../../src/handlers/asset-historical-price.ts"],"names":[],"mappings":";;;AAAA,mDAAqD;AACrD,uDAU+B;AAE/B,sCAAgD;AAEhD;;GAEG;AACU,QAAA,qBAAqB,GAAG,IAAA,0BAAc,EACjD,IAAA,mBAAK,EAAC,CAAC,IAAA,qBAAO,EAAC,KAAK,CAAC,EAAE,4BAAqB,CAAC,CAAC,EAC9C,IAAA,mBAAK,EAAC,IAAA,mBAAK,EAAC,CAAC,IAAA,oBAAM,GAAE,EAAE,IAAA,oBAAM,GAAE,CAAC,CAAC,CAAC,CACnC,CAAC;AAEF;;GAEG;AACU,QAAA,0BAA0B,GAAG,IAAA,sBAAQ,EAChD,IAAA,oBAAM,EAAC;IACL,SAAS,EAAE,6BAAqB;IAChC,UAAU,EAAE,IAAA,oBAAM,GAAE;IACpB,cAAc,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;CACnC,CAAC,CACH,CAAC;AAEF;;GAEG;AACU,QAAA,oCAAoC,GAAG,IAAA,oBAAM,EAAC;IACzD,eAAe,EAAE,kCAA0B;CAC5C,CAAC,CAAC","sourcesContent":["import { nonEmptyRecord } from '@metamask/snaps-sdk';\nimport {\n array,\n literal,\n nullable,\n number,\n object,\n optional,\n string,\n tuple,\n union,\n} from '@metamask/superstruct';\n\nimport { ISO8601DurationStruct } from '../time';\n\n/**\n * A struct representing a historical price.\n */\nexport const HistoricalPriceStruct = nonEmptyRecord(\n union([literal('all'), ISO8601DurationStruct]),\n array(tuple([number(), string()])),\n);\n\n/**\n * A struct representing an asset's historical price.\n */\nexport const AssetHistoricalPriceStruct = nullable(\n object({\n intervals: HistoricalPriceStruct,\n updateTime: number(),\n expirationTime: optional(number()),\n }),\n);\n\n/**\n * A struct representing the response of the `onAssetHistoricalPrice` method.\n */\nexport const OnAssetHistoricalPriceResponseStruct = object({\n historicalPrice: AssetHistoricalPriceStruct,\n});\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A struct representing a historical price.
|
|
3
|
+
*/
|
|
4
|
+
export declare const HistoricalPriceStruct: import("@metamask/superstruct").Struct<Record<string, [number, string][]>, null>;
|
|
5
|
+
/**
|
|
6
|
+
* A struct representing an asset's historical price.
|
|
7
|
+
*/
|
|
8
|
+
export declare const AssetHistoricalPriceStruct: import("@metamask/superstruct").Struct<{
|
|
9
|
+
intervals: Record<string, [number, string][]>;
|
|
10
|
+
updateTime: number;
|
|
11
|
+
expirationTime?: number | undefined;
|
|
12
|
+
} | null, {
|
|
13
|
+
intervals: import("@metamask/superstruct").Struct<Record<string, [number, string][]>, null>;
|
|
14
|
+
updateTime: import("@metamask/superstruct").Struct<number, null>;
|
|
15
|
+
expirationTime: import("@metamask/superstruct").Struct<number | undefined, null>;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* A struct representing the response of the `onAssetHistoricalPrice` method.
|
|
19
|
+
*/
|
|
20
|
+
export declare const OnAssetHistoricalPriceResponseStruct: import("@metamask/superstruct").Struct<{
|
|
21
|
+
historicalPrice: {
|
|
22
|
+
intervals: Record<string, [number, string][]>;
|
|
23
|
+
updateTime: number;
|
|
24
|
+
expirationTime?: number | undefined;
|
|
25
|
+
} | null;
|
|
26
|
+
}, {
|
|
27
|
+
historicalPrice: import("@metamask/superstruct").Struct<{
|
|
28
|
+
intervals: Record<string, [number, string][]>;
|
|
29
|
+
updateTime: number;
|
|
30
|
+
expirationTime?: number | undefined;
|
|
31
|
+
} | null, {
|
|
32
|
+
intervals: import("@metamask/superstruct").Struct<Record<string, [number, string][]>, null>;
|
|
33
|
+
updateTime: import("@metamask/superstruct").Struct<number, null>;
|
|
34
|
+
expirationTime: import("@metamask/superstruct").Struct<number | undefined, null>;
|
|
35
|
+
}>;
|
|
36
|
+
}>;
|
|
37
|
+
//# sourceMappingURL=asset-historical-price.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-historical-price.d.cts","sourceRoot":"","sources":["../../src/handlers/asset-historical-price.ts"],"names":[],"mappings":"AAeA;;GAEG;AACH,eAAO,MAAM,qBAAqB,kFAGjC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;EAMtC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oCAAoC;;;;;;;;;;;;;;;;EAE/C,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A struct representing a historical price.
|
|
3
|
+
*/
|
|
4
|
+
export declare const HistoricalPriceStruct: import("@metamask/superstruct").Struct<Record<string, [number, string][]>, null>;
|
|
5
|
+
/**
|
|
6
|
+
* A struct representing an asset's historical price.
|
|
7
|
+
*/
|
|
8
|
+
export declare const AssetHistoricalPriceStruct: import("@metamask/superstruct").Struct<{
|
|
9
|
+
intervals: Record<string, [number, string][]>;
|
|
10
|
+
updateTime: number;
|
|
11
|
+
expirationTime?: number | undefined;
|
|
12
|
+
} | null, {
|
|
13
|
+
intervals: import("@metamask/superstruct").Struct<Record<string, [number, string][]>, null>;
|
|
14
|
+
updateTime: import("@metamask/superstruct").Struct<number, null>;
|
|
15
|
+
expirationTime: import("@metamask/superstruct").Struct<number | undefined, null>;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* A struct representing the response of the `onAssetHistoricalPrice` method.
|
|
19
|
+
*/
|
|
20
|
+
export declare const OnAssetHistoricalPriceResponseStruct: import("@metamask/superstruct").Struct<{
|
|
21
|
+
historicalPrice: {
|
|
22
|
+
intervals: Record<string, [number, string][]>;
|
|
23
|
+
updateTime: number;
|
|
24
|
+
expirationTime?: number | undefined;
|
|
25
|
+
} | null;
|
|
26
|
+
}, {
|
|
27
|
+
historicalPrice: import("@metamask/superstruct").Struct<{
|
|
28
|
+
intervals: Record<string, [number, string][]>;
|
|
29
|
+
updateTime: number;
|
|
30
|
+
expirationTime?: number | undefined;
|
|
31
|
+
} | null, {
|
|
32
|
+
intervals: import("@metamask/superstruct").Struct<Record<string, [number, string][]>, null>;
|
|
33
|
+
updateTime: import("@metamask/superstruct").Struct<number, null>;
|
|
34
|
+
expirationTime: import("@metamask/superstruct").Struct<number | undefined, null>;
|
|
35
|
+
}>;
|
|
36
|
+
}>;
|
|
37
|
+
//# sourceMappingURL=asset-historical-price.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-historical-price.d.mts","sourceRoot":"","sources":["../../src/handlers/asset-historical-price.ts"],"names":[],"mappings":"AAeA;;GAEG;AACH,eAAO,MAAM,qBAAqB,kFAGjC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;EAMtC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oCAAoC;;;;;;;;;;;;;;;;EAE/C,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { nonEmptyRecord } from "@metamask/snaps-sdk";
|
|
2
|
+
import { array, literal, nullable, number, object, optional, string, tuple, union } from "@metamask/superstruct";
|
|
3
|
+
import { ISO8601DurationStruct } from "../time.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* A struct representing a historical price.
|
|
6
|
+
*/
|
|
7
|
+
export const HistoricalPriceStruct = nonEmptyRecord(union([literal('all'), ISO8601DurationStruct]), array(tuple([number(), string()])));
|
|
8
|
+
/**
|
|
9
|
+
* A struct representing an asset's historical price.
|
|
10
|
+
*/
|
|
11
|
+
export const AssetHistoricalPriceStruct = nullable(object({
|
|
12
|
+
intervals: HistoricalPriceStruct,
|
|
13
|
+
updateTime: number(),
|
|
14
|
+
expirationTime: optional(number()),
|
|
15
|
+
}));
|
|
16
|
+
/**
|
|
17
|
+
* A struct representing the response of the `onAssetHistoricalPrice` method.
|
|
18
|
+
*/
|
|
19
|
+
export const OnAssetHistoricalPriceResponseStruct = object({
|
|
20
|
+
historicalPrice: AssetHistoricalPriceStruct,
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=asset-historical-price.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-historical-price.mjs","sourceRoot":"","sources":["../../src/handlers/asset-historical-price.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,4BAA4B;AACrD,OAAO,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,EACN,QAAQ,EACR,MAAM,EACN,KAAK,EACL,KAAK,EACN,8BAA8B;AAE/B,OAAO,EAAE,qBAAqB,EAAE,oBAAgB;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,cAAc,CACjD,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,qBAAqB,CAAC,CAAC,EAC9C,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CACnC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,QAAQ,CAChD,MAAM,CAAC;IACL,SAAS,EAAE,qBAAqB;IAChC,UAAU,EAAE,MAAM,EAAE;IACpB,cAAc,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;CACnC,CAAC,CACH,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,MAAM,CAAC;IACzD,eAAe,EAAE,0BAA0B;CAC5C,CAAC,CAAC","sourcesContent":["import { nonEmptyRecord } from '@metamask/snaps-sdk';\nimport {\n array,\n literal,\n nullable,\n number,\n object,\n optional,\n string,\n tuple,\n union,\n} from '@metamask/superstruct';\n\nimport { ISO8601DurationStruct } from '../time';\n\n/**\n * A struct representing a historical price.\n */\nexport const HistoricalPriceStruct = nonEmptyRecord(\n union([literal('all'), ISO8601DurationStruct]),\n array(tuple([number(), string()])),\n);\n\n/**\n * A struct representing an asset's historical price.\n */\nexport const AssetHistoricalPriceStruct = nullable(\n object({\n intervals: HistoricalPriceStruct,\n updateTime: number(),\n expirationTime: optional(number()),\n }),\n);\n\n/**\n * A struct representing the response of the `onAssetHistoricalPrice` method.\n */\nexport const OnAssetHistoricalPriceResponseStruct = object({\n historicalPrice: AssetHistoricalPriceStruct,\n});\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OnAssetsConversionResponseStruct = exports.AssetConversionStruct = exports.MarketDataStruct = exports.PricePercentChangeStruct = void 0;
|
|
4
|
+
const snaps_sdk_1 = require("@metamask/snaps-sdk");
|
|
5
|
+
const superstruct_1 = require("@metamask/superstruct");
|
|
6
|
+
const utils_1 = require("@metamask/utils");
|
|
7
|
+
const time_1 = require("../time.cjs");
|
|
8
|
+
/**
|
|
9
|
+
* A struct representing the market data for an asset.
|
|
10
|
+
*/
|
|
11
|
+
exports.PricePercentChangeStruct = (0, snaps_sdk_1.nonEmptyRecord)((0, superstruct_1.union)([(0, superstruct_1.literal)('all'), time_1.ISO8601DurationStruct]), (0, superstruct_1.number)());
|
|
12
|
+
/**
|
|
13
|
+
* A struct representing the market data for an asset.
|
|
14
|
+
*/
|
|
15
|
+
exports.MarketDataStruct = (0, superstruct_1.object)({
|
|
16
|
+
marketCap: (0, superstruct_1.string)(),
|
|
17
|
+
totalVolume: (0, superstruct_1.string)(),
|
|
18
|
+
circulatingSupply: (0, superstruct_1.string)(),
|
|
19
|
+
allTimeHigh: (0, superstruct_1.string)(),
|
|
20
|
+
allTimeLow: (0, superstruct_1.string)(),
|
|
21
|
+
pricePercentChange: (0, superstruct_1.optional)(exports.PricePercentChangeStruct),
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* A struct representing the conversion rate between two assets.
|
|
25
|
+
*/
|
|
26
|
+
exports.AssetConversionStruct = (0, superstruct_1.object)({
|
|
27
|
+
rate: (0, superstruct_1.string)(),
|
|
28
|
+
marketData: (0, superstruct_1.optional)(exports.MarketDataStruct),
|
|
29
|
+
conversionTime: (0, superstruct_1.number)(),
|
|
30
|
+
expirationTime: (0, superstruct_1.optional)((0, superstruct_1.number)()),
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* A struct representing the response of the `onAssetsConversion` method.
|
|
34
|
+
*/
|
|
35
|
+
exports.OnAssetsConversionResponseStruct = (0, superstruct_1.object)({
|
|
36
|
+
conversionRates: (0, superstruct_1.record)(utils_1.CaipAssetTypeStruct, (0, superstruct_1.record)(utils_1.CaipAssetTypeStruct, (0, superstruct_1.nullable)(exports.AssetConversionStruct))),
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=assets-conversion.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets-conversion.cjs","sourceRoot":"","sources":["../../src/handlers/assets-conversion.ts"],"names":[],"mappings":";;;AAAA,mDAAqD;AACrD,uDAS+B;AAC/B,2CAAsD;AAEtD,sCAAgD;AAEhD;;GAEG;AACU,QAAA,wBAAwB,GAAG,IAAA,0BAAc,EACpD,IAAA,mBAAK,EAAC,CAAC,IAAA,qBAAO,EAAC,KAAK,CAAC,EAAE,4BAAqB,CAAC,CAAC,EAC9C,IAAA,oBAAM,GAAE,CACT,CAAC;AAEF;;GAEG;AACU,QAAA,gBAAgB,GAAG,IAAA,oBAAM,EAAC;IACrC,SAAS,EAAE,IAAA,oBAAM,GAAE;IACnB,WAAW,EAAE,IAAA,oBAAM,GAAE;IACrB,iBAAiB,EAAE,IAAA,oBAAM,GAAE;IAC3B,WAAW,EAAE,IAAA,oBAAM,GAAE;IACrB,UAAU,EAAE,IAAA,oBAAM,GAAE;IACpB,kBAAkB,EAAE,IAAA,sBAAQ,EAAC,gCAAwB,CAAC;CACvD,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,qBAAqB,GAAG,IAAA,oBAAM,EAAC;IAC1C,IAAI,EAAE,IAAA,oBAAM,GAAE;IACd,UAAU,EAAE,IAAA,sBAAQ,EAAC,wBAAgB,CAAC;IACtC,cAAc,EAAE,IAAA,oBAAM,GAAE;IACxB,cAAc,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;CACnC,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,gCAAgC,GAAG,IAAA,oBAAM,EAAC;IACrD,eAAe,EAAE,IAAA,oBAAM,EACrB,2BAAmB,EACnB,IAAA,oBAAM,EAAC,2BAAmB,EAAE,IAAA,sBAAQ,EAAC,6BAAqB,CAAC,CAAC,CAC7D;CACF,CAAC,CAAC","sourcesContent":["import { nonEmptyRecord } from '@metamask/snaps-sdk';\nimport {\n literal,\n nullable,\n number,\n object,\n optional,\n record,\n string,\n union,\n} from '@metamask/superstruct';\nimport { CaipAssetTypeStruct } from '@metamask/utils';\n\nimport { ISO8601DurationStruct } from '../time';\n\n/**\n * A struct representing the market data for an asset.\n */\nexport const PricePercentChangeStruct = nonEmptyRecord(\n union([literal('all'), ISO8601DurationStruct]),\n number(),\n);\n\n/**\n * A struct representing the market data for an asset.\n */\nexport const MarketDataStruct = object({\n marketCap: string(),\n totalVolume: string(),\n circulatingSupply: string(),\n allTimeHigh: string(),\n allTimeLow: string(),\n pricePercentChange: optional(PricePercentChangeStruct),\n});\n\n/**\n * A struct representing the conversion rate between two assets.\n */\nexport const AssetConversionStruct = object({\n rate: string(),\n marketData: optional(MarketDataStruct),\n conversionTime: number(),\n expirationTime: optional(number()),\n});\n\n/**\n * A struct representing the response of the `onAssetsConversion` method.\n */\nexport const OnAssetsConversionResponseStruct = object({\n conversionRates: record(\n CaipAssetTypeStruct,\n record(CaipAssetTypeStruct, nullable(AssetConversionStruct)),\n ),\n});\n"]}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A struct representing the market data for an asset.
|
|
3
|
+
*/
|
|
4
|
+
export declare const PricePercentChangeStruct: import("@metamask/superstruct").Struct<Record<string, number>, null>;
|
|
5
|
+
/**
|
|
6
|
+
* A struct representing the market data for an asset.
|
|
7
|
+
*/
|
|
8
|
+
export declare const MarketDataStruct: import("@metamask/superstruct").Struct<{
|
|
9
|
+
marketCap: string;
|
|
10
|
+
totalVolume: string;
|
|
11
|
+
circulatingSupply: string;
|
|
12
|
+
allTimeHigh: string;
|
|
13
|
+
allTimeLow: string;
|
|
14
|
+
pricePercentChange?: Record<string, number> | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
marketCap: import("@metamask/superstruct").Struct<string, null>;
|
|
17
|
+
totalVolume: import("@metamask/superstruct").Struct<string, null>;
|
|
18
|
+
circulatingSupply: import("@metamask/superstruct").Struct<string, null>;
|
|
19
|
+
allTimeHigh: import("@metamask/superstruct").Struct<string, null>;
|
|
20
|
+
allTimeLow: import("@metamask/superstruct").Struct<string, null>;
|
|
21
|
+
pricePercentChange: import("@metamask/superstruct").Struct<Record<string, number> | undefined, null>;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* A struct representing the conversion rate between two assets.
|
|
25
|
+
*/
|
|
26
|
+
export declare const AssetConversionStruct: import("@metamask/superstruct").Struct<{
|
|
27
|
+
rate: string;
|
|
28
|
+
conversionTime: number;
|
|
29
|
+
expirationTime?: number | undefined;
|
|
30
|
+
marketData?: {
|
|
31
|
+
marketCap: string;
|
|
32
|
+
totalVolume: string;
|
|
33
|
+
circulatingSupply: string;
|
|
34
|
+
allTimeHigh: string;
|
|
35
|
+
allTimeLow: string;
|
|
36
|
+
pricePercentChange?: Record<string, number> | undefined;
|
|
37
|
+
} | undefined;
|
|
38
|
+
}, {
|
|
39
|
+
rate: import("@metamask/superstruct").Struct<string, null>;
|
|
40
|
+
marketData: import("@metamask/superstruct").Struct<{
|
|
41
|
+
marketCap: string;
|
|
42
|
+
totalVolume: string;
|
|
43
|
+
circulatingSupply: string;
|
|
44
|
+
allTimeHigh: string;
|
|
45
|
+
allTimeLow: string;
|
|
46
|
+
pricePercentChange?: Record<string, number> | undefined;
|
|
47
|
+
} | undefined, {
|
|
48
|
+
marketCap: import("@metamask/superstruct").Struct<string, null>;
|
|
49
|
+
totalVolume: import("@metamask/superstruct").Struct<string, null>;
|
|
50
|
+
circulatingSupply: import("@metamask/superstruct").Struct<string, null>;
|
|
51
|
+
allTimeHigh: import("@metamask/superstruct").Struct<string, null>;
|
|
52
|
+
allTimeLow: import("@metamask/superstruct").Struct<string, null>;
|
|
53
|
+
pricePercentChange: import("@metamask/superstruct").Struct<Record<string, number> | undefined, null>;
|
|
54
|
+
}>;
|
|
55
|
+
conversionTime: import("@metamask/superstruct").Struct<number, null>;
|
|
56
|
+
expirationTime: import("@metamask/superstruct").Struct<number | undefined, null>;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* A struct representing the response of the `onAssetsConversion` method.
|
|
60
|
+
*/
|
|
61
|
+
export declare const OnAssetsConversionResponseStruct: import("@metamask/superstruct").Struct<{
|
|
62
|
+
conversionRates: Record<`${string}:${string}/${string}:${string}`, Record<`${string}:${string}/${string}:${string}`, {
|
|
63
|
+
rate: string;
|
|
64
|
+
conversionTime: number;
|
|
65
|
+
expirationTime?: number | undefined;
|
|
66
|
+
marketData?: {
|
|
67
|
+
marketCap: string;
|
|
68
|
+
totalVolume: string;
|
|
69
|
+
circulatingSupply: string;
|
|
70
|
+
allTimeHigh: string;
|
|
71
|
+
allTimeLow: string;
|
|
72
|
+
pricePercentChange?: Record<string, number> | undefined;
|
|
73
|
+
} | undefined;
|
|
74
|
+
} | null>>;
|
|
75
|
+
}, {
|
|
76
|
+
conversionRates: import("@metamask/superstruct").Struct<Record<`${string}:${string}/${string}:${string}`, Record<`${string}:${string}/${string}:${string}`, {
|
|
77
|
+
rate: string;
|
|
78
|
+
conversionTime: number;
|
|
79
|
+
expirationTime?: number | undefined;
|
|
80
|
+
marketData?: {
|
|
81
|
+
marketCap: string;
|
|
82
|
+
totalVolume: string;
|
|
83
|
+
circulatingSupply: string;
|
|
84
|
+
allTimeHigh: string;
|
|
85
|
+
allTimeLow: string;
|
|
86
|
+
pricePercentChange?: Record<string, number> | undefined;
|
|
87
|
+
} | undefined;
|
|
88
|
+
} | null>>, null>;
|
|
89
|
+
}>;
|
|
90
|
+
//# sourceMappingURL=assets-conversion.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets-conversion.d.cts","sourceRoot":"","sources":["../../src/handlers/assets-conversion.ts"],"names":[],"mappings":"AAeA;;GAEG;AACH,eAAO,MAAM,wBAAwB,sEAGpC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;EAO3B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK3C,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A struct representing the market data for an asset.
|
|
3
|
+
*/
|
|
4
|
+
export declare const PricePercentChangeStruct: import("@metamask/superstruct").Struct<Record<string, number>, null>;
|
|
5
|
+
/**
|
|
6
|
+
* A struct representing the market data for an asset.
|
|
7
|
+
*/
|
|
8
|
+
export declare const MarketDataStruct: import("@metamask/superstruct").Struct<{
|
|
9
|
+
marketCap: string;
|
|
10
|
+
totalVolume: string;
|
|
11
|
+
circulatingSupply: string;
|
|
12
|
+
allTimeHigh: string;
|
|
13
|
+
allTimeLow: string;
|
|
14
|
+
pricePercentChange?: Record<string, number> | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
marketCap: import("@metamask/superstruct").Struct<string, null>;
|
|
17
|
+
totalVolume: import("@metamask/superstruct").Struct<string, null>;
|
|
18
|
+
circulatingSupply: import("@metamask/superstruct").Struct<string, null>;
|
|
19
|
+
allTimeHigh: import("@metamask/superstruct").Struct<string, null>;
|
|
20
|
+
allTimeLow: import("@metamask/superstruct").Struct<string, null>;
|
|
21
|
+
pricePercentChange: import("@metamask/superstruct").Struct<Record<string, number> | undefined, null>;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* A struct representing the conversion rate between two assets.
|
|
25
|
+
*/
|
|
26
|
+
export declare const AssetConversionStruct: import("@metamask/superstruct").Struct<{
|
|
27
|
+
rate: string;
|
|
28
|
+
conversionTime: number;
|
|
29
|
+
expirationTime?: number | undefined;
|
|
30
|
+
marketData?: {
|
|
31
|
+
marketCap: string;
|
|
32
|
+
totalVolume: string;
|
|
33
|
+
circulatingSupply: string;
|
|
34
|
+
allTimeHigh: string;
|
|
35
|
+
allTimeLow: string;
|
|
36
|
+
pricePercentChange?: Record<string, number> | undefined;
|
|
37
|
+
} | undefined;
|
|
38
|
+
}, {
|
|
39
|
+
rate: import("@metamask/superstruct").Struct<string, null>;
|
|
40
|
+
marketData: import("@metamask/superstruct").Struct<{
|
|
41
|
+
marketCap: string;
|
|
42
|
+
totalVolume: string;
|
|
43
|
+
circulatingSupply: string;
|
|
44
|
+
allTimeHigh: string;
|
|
45
|
+
allTimeLow: string;
|
|
46
|
+
pricePercentChange?: Record<string, number> | undefined;
|
|
47
|
+
} | undefined, {
|
|
48
|
+
marketCap: import("@metamask/superstruct").Struct<string, null>;
|
|
49
|
+
totalVolume: import("@metamask/superstruct").Struct<string, null>;
|
|
50
|
+
circulatingSupply: import("@metamask/superstruct").Struct<string, null>;
|
|
51
|
+
allTimeHigh: import("@metamask/superstruct").Struct<string, null>;
|
|
52
|
+
allTimeLow: import("@metamask/superstruct").Struct<string, null>;
|
|
53
|
+
pricePercentChange: import("@metamask/superstruct").Struct<Record<string, number> | undefined, null>;
|
|
54
|
+
}>;
|
|
55
|
+
conversionTime: import("@metamask/superstruct").Struct<number, null>;
|
|
56
|
+
expirationTime: import("@metamask/superstruct").Struct<number | undefined, null>;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* A struct representing the response of the `onAssetsConversion` method.
|
|
60
|
+
*/
|
|
61
|
+
export declare const OnAssetsConversionResponseStruct: import("@metamask/superstruct").Struct<{
|
|
62
|
+
conversionRates: Record<`${string}:${string}/${string}:${string}`, Record<`${string}:${string}/${string}:${string}`, {
|
|
63
|
+
rate: string;
|
|
64
|
+
conversionTime: number;
|
|
65
|
+
expirationTime?: number | undefined;
|
|
66
|
+
marketData?: {
|
|
67
|
+
marketCap: string;
|
|
68
|
+
totalVolume: string;
|
|
69
|
+
circulatingSupply: string;
|
|
70
|
+
allTimeHigh: string;
|
|
71
|
+
allTimeLow: string;
|
|
72
|
+
pricePercentChange?: Record<string, number> | undefined;
|
|
73
|
+
} | undefined;
|
|
74
|
+
} | null>>;
|
|
75
|
+
}, {
|
|
76
|
+
conversionRates: import("@metamask/superstruct").Struct<Record<`${string}:${string}/${string}:${string}`, Record<`${string}:${string}/${string}:${string}`, {
|
|
77
|
+
rate: string;
|
|
78
|
+
conversionTime: number;
|
|
79
|
+
expirationTime?: number | undefined;
|
|
80
|
+
marketData?: {
|
|
81
|
+
marketCap: string;
|
|
82
|
+
totalVolume: string;
|
|
83
|
+
circulatingSupply: string;
|
|
84
|
+
allTimeHigh: string;
|
|
85
|
+
allTimeLow: string;
|
|
86
|
+
pricePercentChange?: Record<string, number> | undefined;
|
|
87
|
+
} | undefined;
|
|
88
|
+
} | null>>, null>;
|
|
89
|
+
}>;
|
|
90
|
+
//# sourceMappingURL=assets-conversion.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets-conversion.d.mts","sourceRoot":"","sources":["../../src/handlers/assets-conversion.ts"],"names":[],"mappings":"AAeA;;GAEG;AACH,eAAO,MAAM,wBAAwB,sEAGpC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;EAO3B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK3C,CAAC"}
|