@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.
Files changed (149) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/dist/cronjob.d.cts +9 -9
  3. package/dist/cronjob.d.mts +9 -9
  4. package/dist/eval-worker.cjs +4 -5
  5. package/dist/eval-worker.cjs.map +1 -1
  6. package/dist/eval-worker.mjs +3 -4
  7. package/dist/eval-worker.mjs.map +1 -1
  8. package/dist/handlers/asset-historical-price.cjs +25 -0
  9. package/dist/handlers/asset-historical-price.cjs.map +1 -0
  10. package/dist/handlers/asset-historical-price.d.cts +37 -0
  11. package/dist/handlers/asset-historical-price.d.cts.map +1 -0
  12. package/dist/handlers/asset-historical-price.d.mts +37 -0
  13. package/dist/handlers/asset-historical-price.d.mts.map +1 -0
  14. package/dist/handlers/asset-historical-price.mjs +22 -0
  15. package/dist/handlers/asset-historical-price.mjs.map +1 -0
  16. package/dist/handlers/assets-conversion.cjs +38 -0
  17. package/dist/handlers/assets-conversion.cjs.map +1 -0
  18. package/dist/handlers/assets-conversion.d.cts +90 -0
  19. package/dist/handlers/assets-conversion.d.cts.map +1 -0
  20. package/dist/handlers/assets-conversion.d.mts +90 -0
  21. package/dist/handlers/assets-conversion.d.mts.map +1 -0
  22. package/dist/handlers/assets-conversion.mjs +35 -0
  23. package/dist/handlers/assets-conversion.mjs.map +1 -0
  24. package/dist/handlers/exports.cjs +113 -0
  25. package/dist/handlers/exports.cjs.map +1 -0
  26. package/dist/handlers/exports.d.cts +81 -0
  27. package/dist/handlers/exports.d.cts.map +1 -0
  28. package/dist/handlers/exports.d.mts +81 -0
  29. package/dist/handlers/exports.d.mts.map +1 -0
  30. package/dist/{handlers.mjs → handlers/exports.mjs} +10 -45
  31. package/dist/handlers/exports.mjs.map +1 -0
  32. package/dist/handlers/home-page.cjs +16 -0
  33. package/dist/handlers/home-page.cjs.map +1 -0
  34. package/dist/handlers/home-page.d.cts +268 -0
  35. package/dist/handlers/home-page.d.cts.map +1 -0
  36. package/dist/handlers/home-page.d.mts +268 -0
  37. package/dist/handlers/home-page.d.mts.map +1 -0
  38. package/dist/handlers/home-page.mjs +13 -0
  39. package/dist/handlers/home-page.mjs.map +1 -0
  40. package/dist/handlers/index.cjs +26 -0
  41. package/dist/handlers/index.cjs.map +1 -0
  42. package/dist/handlers/index.d.cts +10 -0
  43. package/dist/handlers/index.d.cts.map +1 -0
  44. package/dist/handlers/index.d.mts +10 -0
  45. package/dist/handlers/index.d.mts.map +1 -0
  46. package/dist/handlers/index.mjs +10 -0
  47. package/dist/handlers/index.mjs.map +1 -0
  48. package/dist/handlers/name-lookup.cjs +21 -0
  49. package/dist/handlers/name-lookup.cjs.map +1 -0
  50. package/dist/handlers/name-lookup.d.cts +67 -0
  51. package/dist/handlers/name-lookup.d.cts.map +1 -0
  52. package/dist/handlers/name-lookup.d.mts +67 -0
  53. package/dist/handlers/name-lookup.d.mts.map +1 -0
  54. package/dist/handlers/name-lookup.mjs +18 -0
  55. package/dist/handlers/name-lookup.mjs.map +1 -0
  56. package/dist/handlers/settings-page.cjs +6 -0
  57. package/dist/handlers/settings-page.cjs.map +1 -0
  58. package/dist/handlers/settings-page.d.cts +90 -0
  59. package/dist/handlers/settings-page.d.cts.map +1 -0
  60. package/dist/handlers/settings-page.d.mts +90 -0
  61. package/dist/handlers/settings-page.d.mts.map +1 -0
  62. package/dist/handlers/settings-page.mjs +3 -0
  63. package/dist/handlers/settings-page.mjs.map +1 -0
  64. package/dist/handlers/signature.cjs +6 -0
  65. package/dist/handlers/signature.cjs.map +1 -0
  66. package/dist/handlers/signature.d.cts +92 -0
  67. package/dist/handlers/signature.d.cts.map +1 -0
  68. package/dist/handlers/signature.d.mts +92 -0
  69. package/dist/handlers/signature.d.mts.map +1 -0
  70. package/dist/handlers/signature.mjs +3 -0
  71. package/dist/handlers/signature.mjs.map +1 -0
  72. package/dist/handlers/transaction.cjs +19 -0
  73. package/dist/handlers/transaction.cjs.map +1 -0
  74. package/dist/handlers/transaction.d.cts +280 -0
  75. package/dist/handlers/transaction.d.cts.map +1 -0
  76. package/dist/handlers/transaction.d.mts +280 -0
  77. package/dist/handlers/transaction.d.mts.map +1 -0
  78. package/dist/handlers/transaction.mjs +16 -0
  79. package/dist/handlers/transaction.mjs.map +1 -0
  80. package/dist/{handler-types.cjs → handlers/types.cjs} +3 -3
  81. package/dist/handlers/types.cjs.map +1 -0
  82. package/dist/{handler-types.d.mts → handlers/types.d.cts} +22 -2
  83. package/dist/handlers/types.d.cts.map +1 -0
  84. package/dist/{handler-types.d.cts → handlers/types.d.mts} +22 -2
  85. package/dist/handlers/types.d.mts.map +1 -0
  86. package/dist/{handler-types.mjs → handlers/types.mjs} +2 -2
  87. package/dist/handlers/types.mjs.map +1 -0
  88. package/dist/iframe.test.browser.cjs +20 -19
  89. package/dist/iframe.test.browser.cjs.map +1 -1
  90. package/dist/iframe.test.browser.mjs +2 -1
  91. package/dist/iframe.test.browser.mjs.map +1 -1
  92. package/dist/index.cjs +2 -2
  93. package/dist/index.cjs.map +1 -1
  94. package/dist/index.d.cts +2 -2
  95. package/dist/index.d.cts.map +1 -1
  96. package/dist/index.d.mts +2 -2
  97. package/dist/index.d.mts.map +1 -1
  98. package/dist/index.executionenv.cjs +3 -2
  99. package/dist/index.executionenv.cjs.map +1 -1
  100. package/dist/index.executionenv.d.cts +3 -2
  101. package/dist/index.executionenv.d.cts.map +1 -1
  102. package/dist/index.executionenv.d.mts +3 -2
  103. package/dist/index.executionenv.d.mts.map +1 -1
  104. package/dist/index.executionenv.mjs +3 -2
  105. package/dist/index.executionenv.mjs.map +1 -1
  106. package/dist/index.mjs +2 -2
  107. package/dist/index.mjs.map +1 -1
  108. package/dist/json-rpc.cjs.map +1 -1
  109. package/dist/json-rpc.d.cts +2 -2
  110. package/dist/json-rpc.d.cts.map +1 -1
  111. package/dist/json-rpc.d.mts +2 -2
  112. package/dist/json-rpc.d.mts.map +1 -1
  113. package/dist/json-rpc.mjs.map +1 -1
  114. package/dist/json.cjs +5 -1
  115. package/dist/json.cjs.map +1 -1
  116. package/dist/json.d.cts +3 -0
  117. package/dist/json.d.cts.map +1 -1
  118. package/dist/json.d.mts +3 -0
  119. package/dist/json.d.mts.map +1 -1
  120. package/dist/json.mjs +5 -1
  121. package/dist/json.mjs.map +1 -1
  122. package/dist/localization.d.cts +5 -5
  123. package/dist/localization.d.mts +5 -5
  124. package/dist/manifest/validation.d.cts +12 -12
  125. package/dist/manifest/validation.d.mts +12 -12
  126. package/dist/time.cjs +34 -0
  127. package/dist/time.cjs.map +1 -0
  128. package/dist/time.d.cts +9 -0
  129. package/dist/time.d.cts.map +1 -0
  130. package/dist/time.d.mts +9 -0
  131. package/dist/time.d.mts.map +1 -0
  132. package/dist/time.mjs +31 -0
  133. package/dist/time.mjs.map +1 -0
  134. package/dist/types.d.cts +2 -2
  135. package/dist/types.d.cts.map +1 -1
  136. package/dist/types.d.mts +2 -2
  137. package/dist/types.d.mts.map +1 -1
  138. package/package.json +17 -24
  139. package/dist/handler-types.cjs.map +0 -1
  140. package/dist/handler-types.d.cts.map +0 -1
  141. package/dist/handler-types.d.mts.map +0 -1
  142. package/dist/handler-types.mjs.map +0 -1
  143. package/dist/handlers.cjs +0 -148
  144. package/dist/handlers.cjs.map +0 -1
  145. package/dist/handlers.d.cts +0 -887
  146. package/dist/handlers.d.cts.map +0 -1
  147. package/dist/handlers.d.mts +0 -887
  148. package/dist/handlers.d.mts.map +0 -1
  149. 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.0...HEAD
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
@@ -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">;
@@ -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">;
@@ -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 handler_types_1 = require("./handler-types.cjs");
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
- mathTaming: 'unsafe',
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) => !handler_types_1.SNAP_EXPORT_NAMES.includes(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')}`);
@@ -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,uDAAoD;AACpD,qCAAgD;AAIhD,QAAQ,CAAC;IACP,aAAa,EAAE,QAAQ;IACvB,WAAW,EAAE,QAAQ;IACrB,UAAU,EAAE,QAAQ;IACpB,UAAU,EAAE,QAAQ;IACpB,cAAc,EAAE,QAAQ;IAExB,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,iCAAiB,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 './handler-types';\nimport { SNAP_EXPORT_NAMES } from './handler-types';\nimport { generateMockEndowments } from './mock';\n\ndeclare let lockdown: any, Compartment: any;\n\nlockdown({\n consoleTaming: 'unsafe',\n errorTaming: 'unsafe',\n mathTaming: 'unsafe',\n dateTaming: 'unsafe',\n overrideTaming: 'severe',\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"]}
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"]}
@@ -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 "./handler-types.mjs";
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
- mathTaming: 'unsafe',
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.
@@ -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,4BAAwB;AACpD,OAAO,EAAE,sBAAsB,EAAE,mBAAe;AAIhD,QAAQ,CAAC;IACP,aAAa,EAAE,QAAQ;IACvB,WAAW,EAAE,QAAQ;IACrB,UAAU,EAAE,QAAQ;IACpB,UAAU,EAAE,QAAQ;IACpB,cAAc,EAAE,QAAQ;IAExB,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 './handler-types';\nimport { SNAP_EXPORT_NAMES } from './handler-types';\nimport { generateMockEndowments } from './mock';\n\ndeclare let lockdown: any, Compartment: any;\n\nlockdown({\n consoleTaming: 'unsafe',\n errorTaming: 'unsafe',\n mathTaming: 'unsafe',\n dateTaming: 'unsafe',\n overrideTaming: 'severe',\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"]}
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"}