@metamask/snaps-sdk 8.1.0 → 9.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/CHANGELOG.md +23 -3
  2. package/dist/error-wrappers.d.cts +192 -192
  3. package/dist/error-wrappers.d.mts +192 -192
  4. package/dist/errors.cjs +53 -1
  5. package/dist/errors.cjs.map +1 -1
  6. package/dist/errors.d.cts +24 -0
  7. package/dist/errors.d.cts.map +1 -1
  8. package/dist/errors.d.mts +24 -0
  9. package/dist/errors.d.mts.map +1 -1
  10. package/dist/errors.mjs +52 -1
  11. package/dist/errors.mjs.map +1 -1
  12. package/dist/internals/error-wrappers.d.cts +12 -12
  13. package/dist/internals/error-wrappers.d.mts +12 -12
  14. package/dist/internals/errors.cjs +67 -25
  15. package/dist/internals/errors.cjs.map +1 -1
  16. package/dist/internals/errors.d.cts +19 -4
  17. package/dist/internals/errors.d.cts.map +1 -1
  18. package/dist/internals/errors.d.mts +19 -4
  19. package/dist/internals/errors.d.mts.map +1 -1
  20. package/dist/internals/errors.mjs +64 -24
  21. package/dist/internals/errors.mjs.map +1 -1
  22. package/dist/jsx/validation.d.cts +3 -3
  23. package/dist/jsx/validation.d.mts +3 -3
  24. package/dist/types/handlers/assets-conversion.cjs.map +1 -1
  25. package/dist/types/handlers/assets-conversion.d.cts +0 -25
  26. package/dist/types/handlers/assets-conversion.d.cts.map +1 -1
  27. package/dist/types/handlers/assets-conversion.d.mts +0 -25
  28. package/dist/types/handlers/assets-conversion.d.mts.map +1 -1
  29. package/dist/types/handlers/assets-conversion.mjs.map +1 -1
  30. package/dist/types/handlers/assets-market-data.cjs +3 -0
  31. package/dist/types/handlers/assets-market-data.cjs.map +1 -0
  32. package/dist/types/handlers/assets-market-data.d.cts +56 -0
  33. package/dist/types/handlers/assets-market-data.d.cts.map +1 -0
  34. package/dist/types/handlers/assets-market-data.d.mts +56 -0
  35. package/dist/types/handlers/assets-market-data.d.mts.map +1 -0
  36. package/dist/types/handlers/assets-market-data.mjs +2 -0
  37. package/dist/types/handlers/assets-market-data.mjs.map +1 -0
  38. package/dist/types/handlers/index.cjs.map +1 -1
  39. package/dist/types/handlers/index.d.cts +1 -0
  40. package/dist/types/handlers/index.d.cts.map +1 -1
  41. package/dist/types/handlers/index.d.mts +1 -0
  42. package/dist/types/handlers/index.d.mts.map +1 -1
  43. package/dist/types/handlers/index.mjs.map +1 -1
  44. package/dist/types/handlers/user-input.d.cts +6 -6
  45. package/dist/types/handlers/user-input.d.mts +6 -6
  46. package/dist/types/interface.d.cts +5 -5
  47. package/dist/types/interface.d.mts +5 -5
  48. package/dist/types/methods/end-trace.cjs +3 -0
  49. package/dist/types/methods/end-trace.cjs.map +1 -0
  50. package/dist/types/methods/end-trace.d.cts +31 -0
  51. package/dist/types/methods/end-trace.d.cts.map +1 -0
  52. package/dist/types/methods/end-trace.d.mts +31 -0
  53. package/dist/types/methods/end-trace.d.mts.map +1 -0
  54. package/dist/types/methods/end-trace.mjs +2 -0
  55. package/dist/types/methods/end-trace.mjs.map +1 -0
  56. package/dist/types/methods/index.cjs.map +1 -1
  57. package/dist/types/methods/index.d.cts +3 -0
  58. package/dist/types/methods/index.d.cts.map +1 -1
  59. package/dist/types/methods/index.d.mts +3 -0
  60. package/dist/types/methods/index.d.mts.map +1 -1
  61. package/dist/types/methods/index.mjs.map +1 -1
  62. package/dist/types/methods/methods.cjs.map +1 -1
  63. package/dist/types/methods/methods.d.cts +6 -0
  64. package/dist/types/methods/methods.d.cts.map +1 -1
  65. package/dist/types/methods/methods.d.mts +6 -0
  66. package/dist/types/methods/methods.d.mts.map +1 -1
  67. package/dist/types/methods/methods.mjs.map +1 -1
  68. package/dist/types/methods/start-trace.cjs +3 -0
  69. package/dist/types/methods/start-trace.cjs.map +1 -0
  70. package/dist/types/methods/start-trace.d.cts +58 -0
  71. package/dist/types/methods/start-trace.d.cts.map +1 -0
  72. package/dist/types/methods/start-trace.d.mts +58 -0
  73. package/dist/types/methods/start-trace.d.mts.map +1 -0
  74. package/dist/types/methods/start-trace.mjs +2 -0
  75. package/dist/types/methods/start-trace.mjs.map +1 -0
  76. package/dist/types/methods/track-error.cjs +3 -0
  77. package/dist/types/methods/track-error.cjs.map +1 -0
  78. package/dist/types/methods/track-error.d.cts +41 -0
  79. package/dist/types/methods/track-error.d.cts.map +1 -0
  80. package/dist/types/methods/track-error.d.mts +41 -0
  81. package/dist/types/methods/track-error.d.mts.map +1 -0
  82. package/dist/types/methods/track-error.mjs +2 -0
  83. package/dist/types/methods/track-error.mjs.map +1 -0
  84. package/dist/ui/components/button.d.cts +3 -3
  85. package/dist/ui/components/button.d.mts +3 -3
  86. package/dist/ui/components/form.d.cts +17 -17
  87. package/dist/ui/components/form.d.mts +17 -17
  88. package/dist/ui/components/input.d.cts +3 -3
  89. package/dist/ui/components/input.d.mts +3 -3
  90. package/dist/ui/components/panel.d.cts +25 -25
  91. package/dist/ui/components/panel.d.mts +25 -25
  92. package/package.json +3 -3
@@ -1,6 +1,41 @@
1
1
  import { hasProperty, isObject, isValidJson } from "@metamask/utils";
2
2
  export const SNAP_ERROR_CODE = -31002;
3
3
  export const SNAP_ERROR_MESSAGE = 'Snap Error';
4
+ /**
5
+ * Get a property from an object, or return a fallback value if the property
6
+ * does not exist.
7
+ *
8
+ * @param object - The object to get the property from.
9
+ * @param property - The property to get from the object.
10
+ * @param fallback - The fallback value to return if the property does not
11
+ * exist.
12
+ * @returns The value of the property if it exists, or the fallback value if
13
+ * the property does not exist.
14
+ */
15
+ function getObjectProperty(object, property, fallback = null) {
16
+ if (isObject(object) && hasProperty(object, property)) {
17
+ return object[property];
18
+ }
19
+ return fallback;
20
+ }
21
+ /**
22
+ * Get a string property from an object, or convert the object to a string
23
+ * if the property does not exist or is not a string.
24
+ *
25
+ * @param object - The object to get the property from.
26
+ * @param property - The property to get from the object.
27
+ * @param fallback - The fallback value to return if the property does not exist
28
+ * or is not a string. Defaults to the string representation of the object.
29
+ * @returns The value of the property if it exists and is a string, or the
30
+ * fallback value if it does not exist or is not a string.
31
+ */
32
+ function getObjectStringProperty(object, property, fallback = String(object)) {
33
+ const value = getObjectProperty(object, property);
34
+ if (typeof value === 'string') {
35
+ return value;
36
+ }
37
+ return fallback;
38
+ }
4
39
  /**
5
40
  * Get the error message from an unknown error type.
6
41
  *
@@ -12,12 +47,7 @@ export const SNAP_ERROR_MESSAGE = 'Snap Error';
12
47
  * @internal
13
48
  */
14
49
  export function getErrorMessage(error) {
15
- if (isObject(error) &&
16
- hasProperty(error, 'message') &&
17
- typeof error.message === 'string') {
18
- return error.message;
19
- }
20
- return String(error);
50
+ return getObjectStringProperty(error, 'message');
21
51
  }
22
52
  /**
23
53
  * Get the error stack from an unknown error type.
@@ -28,12 +58,18 @@ export function getErrorMessage(error) {
28
58
  * @internal
29
59
  */
30
60
  export function getErrorStack(error) {
31
- if (isObject(error) &&
32
- hasProperty(error, 'stack') &&
33
- typeof error.stack === 'string') {
34
- return error.stack;
35
- }
36
- return undefined;
61
+ return getObjectStringProperty(error, 'stack', null);
62
+ }
63
+ /**
64
+ * Get the error name from an unknown error type.
65
+ *
66
+ * @param error - The error to get the name from.
67
+ * @returns The error name, or `'Error'` if the error does not have a valid
68
+ * name.
69
+ */
70
+ export function getErrorName(error) {
71
+ const fallbackName = error instanceof Error ? error.name : 'Error';
72
+ return getObjectStringProperty(error, 'name', fallbackName);
37
73
  }
38
74
  /**
39
75
  * Get the error code from an unknown error type.
@@ -43,14 +79,22 @@ export function getErrorStack(error) {
43
79
  * @internal
44
80
  */
45
81
  export function getErrorCode(error) {
46
- if (isObject(error) &&
47
- hasProperty(error, 'code') &&
48
- typeof error.code === 'number' &&
49
- Number.isInteger(error.code)) {
50
- return error.code;
82
+ const value = getObjectProperty(error, 'code');
83
+ if (typeof value === 'number' && Number.isInteger(value)) {
84
+ return value;
51
85
  }
52
86
  return -32603;
53
87
  }
88
+ /**
89
+ * Get the error cause from an unknown error type.
90
+ *
91
+ * @param error - The error to get the cause from.
92
+ * @returns The error cause, or `null` if the error does not have a valid
93
+ * cause.
94
+ */
95
+ export function getErrorCause(error) {
96
+ return getObjectProperty(error, 'cause');
97
+ }
54
98
  /**
55
99
  * Get the error data from an unknown error type.
56
100
  *
@@ -60,13 +104,9 @@ export function getErrorCode(error) {
60
104
  * @internal
61
105
  */
62
106
  export function getErrorData(error) {
63
- if (isObject(error) &&
64
- hasProperty(error, 'data') &&
65
- typeof error.data === 'object' &&
66
- error.data !== null &&
67
- isValidJson(error.data) &&
68
- !Array.isArray(error.data)) {
69
- return error.data;
107
+ const value = getObjectProperty(error, 'data');
108
+ if (value !== null && isValidJson(value) && !Array.isArray(value)) {
109
+ return value;
70
110
  }
71
111
  return {};
72
112
  }
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","sourceRoot":"","sources":["../../src/internals/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,wBAAwB;AAErE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAK,CAAC;AACtC,MAAM,CAAC,MAAM,kBAAkB,GAAG,YAAY,CAAC;AAE/C;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IACE,QAAQ,CAAC,KAAK,CAAC;QACf,WAAW,CAAC,KAAK,EAAE,SAAS,CAAC;QAC7B,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EACjC,CAAC;QACD,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IAED,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,IACE,QAAQ,CAAC,KAAK,CAAC;QACf,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC;QAC3B,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,EAC/B,CAAC;QACD,OAAO,KAAK,CAAC,KAAK,CAAC;IACrB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,IACE,QAAQ,CAAC,KAAK,CAAC;QACf,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC;QAC1B,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,EAC5B,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC;IACpB,CAAC;IAED,OAAO,CAAC,KAAK,CAAC;AAChB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,IACE,QAAQ,CAAC,KAAK,CAAC;QACf,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC;QAC1B,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,KAAK,CAAC,IAAI,KAAK,IAAI;QACnB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC;QACvB,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAC1B,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC;IACpB,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import { hasProperty, isObject, isValidJson } from '@metamask/utils';\n\nexport const SNAP_ERROR_CODE = -31002;\nexport const SNAP_ERROR_MESSAGE = 'Snap Error';\n\n/**\n * Get the error message from an unknown error type.\n *\n * - If the error is an object with a `message` property, return the message.\n * - Otherwise, return the error converted to a string.\n *\n * @param error - The error to get the message from.\n * @returns The error message.\n * @internal\n */\nexport function getErrorMessage(error: unknown) {\n if (\n isObject(error) &&\n hasProperty(error, 'message') &&\n typeof error.message === 'string'\n ) {\n return error.message;\n }\n\n return String(error);\n}\n\n/**\n * Get the error stack from an unknown error type.\n *\n * @param error - The error to get the stack from.\n * @returns The error stack, or undefined if the error does not have a valid\n * stack.\n * @internal\n */\nexport function getErrorStack(error: unknown) {\n if (\n isObject(error) &&\n hasProperty(error, 'stack') &&\n typeof error.stack === 'string'\n ) {\n return error.stack;\n }\n\n return undefined;\n}\n\n/**\n * Get the error code from an unknown error type.\n *\n * @param error - The error to get the code from.\n * @returns The error code, or `-32603` if the error does not have a valid code.\n * @internal\n */\nexport function getErrorCode(error: unknown) {\n if (\n isObject(error) &&\n hasProperty(error, 'code') &&\n typeof error.code === 'number' &&\n Number.isInteger(error.code)\n ) {\n return error.code;\n }\n\n return -32603;\n}\n\n/**\n * Get the error data from an unknown error type.\n *\n * @param error - The error to get the data from.\n * @returns The error data, or an empty object if the error does not have valid\n * data.\n * @internal\n */\nexport function getErrorData(error: unknown) {\n if (\n isObject(error) &&\n hasProperty(error, 'data') &&\n typeof error.data === 'object' &&\n error.data !== null &&\n isValidJson(error.data) &&\n !Array.isArray(error.data)\n ) {\n return error.data;\n }\n\n return {};\n}\n"]}
1
+ {"version":3,"file":"errors.mjs","sourceRoot":"","sources":["../../src/internals/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,wBAAwB;AAErE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAK,CAAC;AACtC,MAAM,CAAC,MAAM,kBAAkB,GAAG,YAAY,CAAC;AAE/C;;;;;;;;;;GAUG;AACH,SAAS,iBAAiB,CACxB,MAAe,EACf,QAAgB,EAChB,WAAqB,IAAgB;IAErC,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC;QACtD,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC1B,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAS,uBAAuB,CAC9B,MAAe,EACf,QAAgB,EAChB,WAAqB,MAAM,CAAC,MAAM,CAAa;IAE/C,MAAM,KAAK,GAAG,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,uBAAuB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AACnD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,uBAAuB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;IACnE,OAAO,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AAC9D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,MAAM,KAAK,GAAG,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QACzD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,CAAC,KAAK,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,MAAM,KAAK,GAAG,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC/C,IAAI,KAAK,KAAK,IAAI,IAAI,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAClE,OAAO,KAA6B,CAAC;IACvC,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import type { Json } from '@metamask/utils';\nimport { hasProperty, isObject, isValidJson } from '@metamask/utils';\n\nexport const SNAP_ERROR_CODE = -31002;\nexport const SNAP_ERROR_MESSAGE = 'Snap Error';\n\n/**\n * Get a property from an object, or return a fallback value if the property\n * does not exist.\n *\n * @param object - The object to get the property from.\n * @param property - The property to get from the object.\n * @param fallback - The fallback value to return if the property does not\n * exist.\n * @returns The value of the property if it exists, or the fallback value if\n * the property does not exist.\n */\nfunction getObjectProperty<Fallback = null>(\n object: unknown,\n property: string,\n fallback: Fallback = null as Fallback,\n): unknown {\n if (isObject(object) && hasProperty(object, property)) {\n return object[property];\n }\n\n return fallback;\n}\n\n/**\n * Get a string property from an object, or convert the object to a string\n * if the property does not exist or is not a string.\n *\n * @param object - The object to get the property from.\n * @param property - The property to get from the object.\n * @param fallback - The fallback value to return if the property does not exist\n * or is not a string. Defaults to the string representation of the object.\n * @returns The value of the property if it exists and is a string, or the\n * fallback value if it does not exist or is not a string.\n */\nfunction getObjectStringProperty<Fallback = string>(\n object: unknown,\n property: string,\n fallback: Fallback = String(object) as Fallback,\n): string | Fallback {\n const value = getObjectProperty(object, property);\n if (typeof value === 'string') {\n return value;\n }\n\n return fallback;\n}\n\n/**\n * Get the error message from an unknown error type.\n *\n * - If the error is an object with a `message` property, return the message.\n * - Otherwise, return the error converted to a string.\n *\n * @param error - The error to get the message from.\n * @returns The error message.\n * @internal\n */\nexport function getErrorMessage(error: unknown) {\n return getObjectStringProperty(error, 'message');\n}\n\n/**\n * Get the error stack from an unknown error type.\n *\n * @param error - The error to get the stack from.\n * @returns The error stack, or undefined if the error does not have a valid\n * stack.\n * @internal\n */\nexport function getErrorStack(error: unknown) {\n return getObjectStringProperty(error, 'stack', null);\n}\n\n/**\n * Get the error name from an unknown error type.\n *\n * @param error - The error to get the name from.\n * @returns The error name, or `'Error'` if the error does not have a valid\n * name.\n */\nexport function getErrorName(error: unknown) {\n const fallbackName = error instanceof Error ? error.name : 'Error';\n return getObjectStringProperty(error, 'name', fallbackName);\n}\n\n/**\n * Get the error code from an unknown error type.\n *\n * @param error - The error to get the code from.\n * @returns The error code, or `-32603` if the error does not have a valid code.\n * @internal\n */\nexport function getErrorCode(error: unknown) {\n const value = getObjectProperty(error, 'code');\n if (typeof value === 'number' && Number.isInteger(value)) {\n return value;\n }\n\n return -32603;\n}\n\n/**\n * Get the error cause from an unknown error type.\n *\n * @param error - The error to get the cause from.\n * @returns The error cause, or `null` if the error does not have a valid\n * cause.\n */\nexport function getErrorCause(error: unknown) {\n return getObjectProperty(error, 'cause');\n}\n\n/**\n * Get the error data from an unknown error type.\n *\n * @param error - The error to get the data from.\n * @returns The error data, or an empty object if the error does not have valid\n * data.\n * @internal\n */\nexport function getErrorData(error: unknown) {\n const value = getObjectProperty(error, 'data');\n if (value !== null && isValidJson(value) && !Array.isArray(value)) {\n return value as Record<string, Json>;\n }\n\n return {};\n}\n"]}
@@ -52,8 +52,8 @@ export declare const GenericInputPropsStruct: Struct<{
52
52
  * A struct for the text type input props.
53
53
  */
54
54
  export declare const TextInputPropsStruct: Struct<{
55
- name: string;
56
55
  type: "text";
56
+ name: string;
57
57
  value?: string | undefined;
58
58
  placeholder?: string | undefined;
59
59
  disabled?: boolean | undefined;
@@ -68,8 +68,8 @@ export declare const TextInputPropsStruct: Struct<{
68
68
  * A struct for the password type input props.
69
69
  */
70
70
  export declare const PasswordInputPropsStruct: Struct<{
71
- name: string;
72
71
  type: "password";
72
+ name: string;
73
73
  value?: string | undefined;
74
74
  placeholder?: string | undefined;
75
75
  disabled?: boolean | undefined;
@@ -84,8 +84,8 @@ export declare const PasswordInputPropsStruct: Struct<{
84
84
  * A struct for the number type input props.
85
85
  */
86
86
  export declare const NumberInputPropsStruct: Struct<{
87
- name: string;
88
87
  type: "number";
88
+ name: string;
89
89
  value?: string | undefined;
90
90
  placeholder?: string | undefined;
91
91
  disabled?: boolean | undefined;
@@ -52,8 +52,8 @@ export declare const GenericInputPropsStruct: Struct<{
52
52
  * A struct for the text type input props.
53
53
  */
54
54
  export declare const TextInputPropsStruct: Struct<{
55
- name: string;
56
55
  type: "text";
56
+ name: string;
57
57
  value?: string | undefined;
58
58
  placeholder?: string | undefined;
59
59
  disabled?: boolean | undefined;
@@ -68,8 +68,8 @@ export declare const TextInputPropsStruct: Struct<{
68
68
  * A struct for the password type input props.
69
69
  */
70
70
  export declare const PasswordInputPropsStruct: Struct<{
71
- name: string;
72
71
  type: "password";
72
+ name: string;
73
73
  value?: string | undefined;
74
74
  placeholder?: string | undefined;
75
75
  disabled?: boolean | undefined;
@@ -84,8 +84,8 @@ export declare const PasswordInputPropsStruct: Struct<{
84
84
  * A struct for the number type input props.
85
85
  */
86
86
  export declare const NumberInputPropsStruct: Struct<{
87
- name: string;
88
87
  type: "number";
88
+ name: string;
89
89
  value?: string | undefined;
90
90
  placeholder?: string | undefined;
91
91
  disabled?: boolean | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"assets-conversion.cjs","sourceRoot":"","sources":["../../../src/types/handlers/assets-conversion.ts"],"names":[],"mappings":"","sourcesContent":["import { type CaipAssetType } from '@metamask/utils';\n\n/**\n * The market data for an asset.\n *\n * @property marketCap - The market capitalization of the asset.\n * @property totalVolume - The total volume of the asset.\n * @property circulatingSupply - The circulating supply of the asset.\n * @property allTimeHigh - The all-time high price of the asset.\n * @property allTimeLow - The all-time low price of the asset.\n * @property pricePercentChange - The percentage change in price over different intervals.\n * @property pricePercentChange.interval - The time interval for the price change as a ISO 8601 duration\n * or the string \"all\" to represent the all-time change.\n */\nexport type MarketData = {\n marketCap: string;\n totalVolume: string;\n circulatingSupply: string;\n allTimeHigh: string;\n allTimeLow: string;\n pricePercentChange: {\n [interval: string]: number;\n };\n};\n\n/**\n * The conversion rate between two assets.\n *\n * @property rate - The conversion rate between the two assets.\n * @property marketData - The market data for the asset, if requested.\n * @property conversionTime - The time at which the conversion rate was calculated.\n * @property expirationTime - The time at which the conversion rate expires.\n */\nexport type AssetConversion = {\n rate: string;\n marketData?: MarketData;\n conversionTime: number;\n expirationTime?: number;\n};\n\n/**\n * The arguments for the `onAssetsConversion` handler.\n *\n * @property conversions - An array of objects containing the `from` and `to` asset types.\n * @property includeMarketData - Whether to include market data in the response.\n */\nexport type OnAssetsConversionArguments = {\n conversions: { from: CaipAssetType; to: CaipAssetType }[];\n includeMarketData?: boolean;\n};\n\n/**\n * The `onAssetsConversion` handler. This is called by MetaMask when querying about asset conversion on specific chains.\n *\n * @param args - The arguments for the handler.\n * see {@link OnAssetsConversionArguments}.\n * @returns The conversion for each asset. See\n * {@link OnAssetsConversionResponse}.\n */\nexport type OnAssetsConversionHandler = (\n args: OnAssetsConversionArguments,\n) => Promise<OnAssetsConversionResponse>;\n\n/**\n * The response from the conversion query, containing rates about each requested asset pair.\n *\n * @property conversionRates - A nested object with two CAIP-19 keys that contains a conversion rate or null between the two keys.\n */\nexport type OnAssetsConversionResponse = {\n conversionRates: Record<\n CaipAssetType,\n Record<CaipAssetType, AssetConversion | null>\n >;\n};\n"]}
1
+ {"version":3,"file":"assets-conversion.cjs","sourceRoot":"","sources":["../../../src/types/handlers/assets-conversion.ts"],"names":[],"mappings":"","sourcesContent":["import { type CaipAssetType } from '@metamask/utils';\n/**\n * The conversion rate between two assets.\n *\n * @property rate - The conversion rate between the two assets.\n * @property conversionTime - The time at which the conversion rate was calculated.\n * @property expirationTime - The time at which the conversion rate expires.\n */\nexport type AssetConversion = {\n rate: string;\n conversionTime: number;\n expirationTime?: number;\n};\n\n/**\n * The arguments for the `onAssetsConversion` handler.\n *\n * @property conversions - An array of objects containing the `from` and `to` asset types.\n * @property includeMarketData - Whether to include market data in the response.\n */\nexport type OnAssetsConversionArguments = {\n conversions: { from: CaipAssetType; to: CaipAssetType }[];\n};\n\n/**\n * The `onAssetsConversion` handler. This is called by MetaMask when querying about asset conversion on specific chains.\n *\n * @param args - The arguments for the handler.\n * see {@link OnAssetsConversionArguments}.\n * @returns The conversion for each asset. See\n * {@link OnAssetsConversionResponse}.\n */\nexport type OnAssetsConversionHandler = (\n args: OnAssetsConversionArguments,\n) => Promise<OnAssetsConversionResponse>;\n\n/**\n * The response from the conversion query, containing rates about each requested asset pair.\n *\n * @property conversionRates - A nested object with two CAIP-19 keys that contains a conversion rate or null between the two keys.\n */\nexport type OnAssetsConversionResponse = {\n conversionRates: Record<\n CaipAssetType,\n Record<CaipAssetType, AssetConversion | null>\n >;\n};\n"]}
@@ -1,37 +1,13 @@
1
1
  import { type CaipAssetType } from "@metamask/utils";
2
- /**
3
- * The market data for an asset.
4
- *
5
- * @property marketCap - The market capitalization of the asset.
6
- * @property totalVolume - The total volume of the asset.
7
- * @property circulatingSupply - The circulating supply of the asset.
8
- * @property allTimeHigh - The all-time high price of the asset.
9
- * @property allTimeLow - The all-time low price of the asset.
10
- * @property pricePercentChange - The percentage change in price over different intervals.
11
- * @property pricePercentChange.interval - The time interval for the price change as a ISO 8601 duration
12
- * or the string "all" to represent the all-time change.
13
- */
14
- export type MarketData = {
15
- marketCap: string;
16
- totalVolume: string;
17
- circulatingSupply: string;
18
- allTimeHigh: string;
19
- allTimeLow: string;
20
- pricePercentChange: {
21
- [interval: string]: number;
22
- };
23
- };
24
2
  /**
25
3
  * The conversion rate between two assets.
26
4
  *
27
5
  * @property rate - The conversion rate between the two assets.
28
- * @property marketData - The market data for the asset, if requested.
29
6
  * @property conversionTime - The time at which the conversion rate was calculated.
30
7
  * @property expirationTime - The time at which the conversion rate expires.
31
8
  */
32
9
  export type AssetConversion = {
33
10
  rate: string;
34
- marketData?: MarketData;
35
11
  conversionTime: number;
36
12
  expirationTime?: number;
37
13
  };
@@ -46,7 +22,6 @@ export type OnAssetsConversionArguments = {
46
22
  from: CaipAssetType;
47
23
  to: CaipAssetType;
48
24
  }[];
49
- includeMarketData?: boolean;
50
25
  };
51
26
  /**
52
27
  * The `onAssetsConversion` handler. This is called by MetaMask when querying about asset conversion on specific chains.
@@ -1 +1 @@
1
- {"version":3,"file":"assets-conversion.d.cts","sourceRoot":"","sources":["../../../src/types/handlers/assets-conversion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,wBAAwB;AAErD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE;QAClB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;KAC5B,CAAC;CACH,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,WAAW,EAAE;QAAE,IAAI,EAAE,aAAa,CAAC;QAAC,EAAE,EAAE,aAAa,CAAA;KAAE,EAAE,CAAC;IAC1D,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,yBAAyB,GAAG,CACtC,IAAI,EAAE,2BAA2B,KAC9B,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAEzC;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,eAAe,EAAE,MAAM,CACrB,aAAa,EACb,MAAM,CAAC,aAAa,EAAE,eAAe,GAAG,IAAI,CAAC,CAC9C,CAAC;CACH,CAAC"}
1
+ {"version":3,"file":"assets-conversion.d.cts","sourceRoot":"","sources":["../../../src/types/handlers/assets-conversion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,wBAAwB;AACrD;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,WAAW,EAAE;QAAE,IAAI,EAAE,aAAa,CAAC;QAAC,EAAE,EAAE,aAAa,CAAA;KAAE,EAAE,CAAC;CAC3D,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,yBAAyB,GAAG,CACtC,IAAI,EAAE,2BAA2B,KAC9B,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAEzC;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,eAAe,EAAE,MAAM,CACrB,aAAa,EACb,MAAM,CAAC,aAAa,EAAE,eAAe,GAAG,IAAI,CAAC,CAC9C,CAAC;CACH,CAAC"}
@@ -1,37 +1,13 @@
1
1
  import { type CaipAssetType } from "@metamask/utils";
2
- /**
3
- * The market data for an asset.
4
- *
5
- * @property marketCap - The market capitalization of the asset.
6
- * @property totalVolume - The total volume of the asset.
7
- * @property circulatingSupply - The circulating supply of the asset.
8
- * @property allTimeHigh - The all-time high price of the asset.
9
- * @property allTimeLow - The all-time low price of the asset.
10
- * @property pricePercentChange - The percentage change in price over different intervals.
11
- * @property pricePercentChange.interval - The time interval for the price change as a ISO 8601 duration
12
- * or the string "all" to represent the all-time change.
13
- */
14
- export type MarketData = {
15
- marketCap: string;
16
- totalVolume: string;
17
- circulatingSupply: string;
18
- allTimeHigh: string;
19
- allTimeLow: string;
20
- pricePercentChange: {
21
- [interval: string]: number;
22
- };
23
- };
24
2
  /**
25
3
  * The conversion rate between two assets.
26
4
  *
27
5
  * @property rate - The conversion rate between the two assets.
28
- * @property marketData - The market data for the asset, if requested.
29
6
  * @property conversionTime - The time at which the conversion rate was calculated.
30
7
  * @property expirationTime - The time at which the conversion rate expires.
31
8
  */
32
9
  export type AssetConversion = {
33
10
  rate: string;
34
- marketData?: MarketData;
35
11
  conversionTime: number;
36
12
  expirationTime?: number;
37
13
  };
@@ -46,7 +22,6 @@ export type OnAssetsConversionArguments = {
46
22
  from: CaipAssetType;
47
23
  to: CaipAssetType;
48
24
  }[];
49
- includeMarketData?: boolean;
50
25
  };
51
26
  /**
52
27
  * The `onAssetsConversion` handler. This is called by MetaMask when querying about asset conversion on specific chains.
@@ -1 +1 @@
1
- {"version":3,"file":"assets-conversion.d.mts","sourceRoot":"","sources":["../../../src/types/handlers/assets-conversion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,wBAAwB;AAErD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE;QAClB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;KAC5B,CAAC;CACH,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,WAAW,EAAE;QAAE,IAAI,EAAE,aAAa,CAAC;QAAC,EAAE,EAAE,aAAa,CAAA;KAAE,EAAE,CAAC;IAC1D,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,yBAAyB,GAAG,CACtC,IAAI,EAAE,2BAA2B,KAC9B,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAEzC;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,eAAe,EAAE,MAAM,CACrB,aAAa,EACb,MAAM,CAAC,aAAa,EAAE,eAAe,GAAG,IAAI,CAAC,CAC9C,CAAC;CACH,CAAC"}
1
+ {"version":3,"file":"assets-conversion.d.mts","sourceRoot":"","sources":["../../../src/types/handlers/assets-conversion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,wBAAwB;AACrD;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,WAAW,EAAE;QAAE,IAAI,EAAE,aAAa,CAAC;QAAC,EAAE,EAAE,aAAa,CAAA;KAAE,EAAE,CAAC;CAC3D,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,yBAAyB,GAAG,CACtC,IAAI,EAAE,2BAA2B,KAC9B,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAEzC;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,eAAe,EAAE,MAAM,CACrB,aAAa,EACb,MAAM,CAAC,aAAa,EAAE,eAAe,GAAG,IAAI,CAAC,CAC9C,CAAC;CACH,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"assets-conversion.mjs","sourceRoot":"","sources":["../../../src/types/handlers/assets-conversion.ts"],"names":[],"mappings":"","sourcesContent":["import { type CaipAssetType } from '@metamask/utils';\n\n/**\n * The market data for an asset.\n *\n * @property marketCap - The market capitalization of the asset.\n * @property totalVolume - The total volume of the asset.\n * @property circulatingSupply - The circulating supply of the asset.\n * @property allTimeHigh - The all-time high price of the asset.\n * @property allTimeLow - The all-time low price of the asset.\n * @property pricePercentChange - The percentage change in price over different intervals.\n * @property pricePercentChange.interval - The time interval for the price change as a ISO 8601 duration\n * or the string \"all\" to represent the all-time change.\n */\nexport type MarketData = {\n marketCap: string;\n totalVolume: string;\n circulatingSupply: string;\n allTimeHigh: string;\n allTimeLow: string;\n pricePercentChange: {\n [interval: string]: number;\n };\n};\n\n/**\n * The conversion rate between two assets.\n *\n * @property rate - The conversion rate between the two assets.\n * @property marketData - The market data for the asset, if requested.\n * @property conversionTime - The time at which the conversion rate was calculated.\n * @property expirationTime - The time at which the conversion rate expires.\n */\nexport type AssetConversion = {\n rate: string;\n marketData?: MarketData;\n conversionTime: number;\n expirationTime?: number;\n};\n\n/**\n * The arguments for the `onAssetsConversion` handler.\n *\n * @property conversions - An array of objects containing the `from` and `to` asset types.\n * @property includeMarketData - Whether to include market data in the response.\n */\nexport type OnAssetsConversionArguments = {\n conversions: { from: CaipAssetType; to: CaipAssetType }[];\n includeMarketData?: boolean;\n};\n\n/**\n * The `onAssetsConversion` handler. This is called by MetaMask when querying about asset conversion on specific chains.\n *\n * @param args - The arguments for the handler.\n * see {@link OnAssetsConversionArguments}.\n * @returns The conversion for each asset. See\n * {@link OnAssetsConversionResponse}.\n */\nexport type OnAssetsConversionHandler = (\n args: OnAssetsConversionArguments,\n) => Promise<OnAssetsConversionResponse>;\n\n/**\n * The response from the conversion query, containing rates about each requested asset pair.\n *\n * @property conversionRates - A nested object with two CAIP-19 keys that contains a conversion rate or null between the two keys.\n */\nexport type OnAssetsConversionResponse = {\n conversionRates: Record<\n CaipAssetType,\n Record<CaipAssetType, AssetConversion | null>\n >;\n};\n"]}
1
+ {"version":3,"file":"assets-conversion.mjs","sourceRoot":"","sources":["../../../src/types/handlers/assets-conversion.ts"],"names":[],"mappings":"","sourcesContent":["import { type CaipAssetType } from '@metamask/utils';\n/**\n * The conversion rate between two assets.\n *\n * @property rate - The conversion rate between the two assets.\n * @property conversionTime - The time at which the conversion rate was calculated.\n * @property expirationTime - The time at which the conversion rate expires.\n */\nexport type AssetConversion = {\n rate: string;\n conversionTime: number;\n expirationTime?: number;\n};\n\n/**\n * The arguments for the `onAssetsConversion` handler.\n *\n * @property conversions - An array of objects containing the `from` and `to` asset types.\n * @property includeMarketData - Whether to include market data in the response.\n */\nexport type OnAssetsConversionArguments = {\n conversions: { from: CaipAssetType; to: CaipAssetType }[];\n};\n\n/**\n * The `onAssetsConversion` handler. This is called by MetaMask when querying about asset conversion on specific chains.\n *\n * @param args - The arguments for the handler.\n * see {@link OnAssetsConversionArguments}.\n * @returns The conversion for each asset. See\n * {@link OnAssetsConversionResponse}.\n */\nexport type OnAssetsConversionHandler = (\n args: OnAssetsConversionArguments,\n) => Promise<OnAssetsConversionResponse>;\n\n/**\n * The response from the conversion query, containing rates about each requested asset pair.\n *\n * @property conversionRates - A nested object with two CAIP-19 keys that contains a conversion rate or null between the two keys.\n */\nexport type OnAssetsConversionResponse = {\n conversionRates: Record<\n CaipAssetType,\n Record<CaipAssetType, AssetConversion | null>\n >;\n};\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=assets-market-data.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assets-market-data.cjs","sourceRoot":"","sources":["../../../src/types/handlers/assets-market-data.ts"],"names":[],"mappings":"","sourcesContent":["import type { CaipAssetType } from '@metamask/utils';\n\n/**\n * The market data for a fungible asset.\n *\n * @property fungible - Indicates that this is a fungible asset.\n * This is always `true` for fungible assets.\n * @property marketCap - The market capitalization of the asset.\n * @property totalVolume - The total volume of the asset.\n * @property circulatingSupply - The circulating supply of the asset.\n * @property allTimeHigh - The all-time high price of the asset.\n * @property allTimeLow - The all-time low price of the asset.\n * @property pricePercentChange - The percentage change in price over different intervals.\n * @property pricePercentChange.interval - The time interval for the price change as a ISO 8601 duration\n * or the string \"all\" to represent the all-time change.\n */\nexport type FungibleAssetMarketData = {\n fungible: true;\n marketCap?: string;\n totalVolume?: string;\n circulatingSupply?: string;\n allTimeHigh?: string;\n allTimeLow?: string;\n pricePercentChange?: {\n [interval: string]: number;\n };\n};\n\n/**\n * The arguments for the `onAssetsMarketData` handler.\n *\n * @property assets - An array of objects containing the asset and unit types.\n * @property assets.asset - The CAIP-19 asset type of the asset.\n * @property assets.unit - The CAIP-19 asset type of the unit to use.\n */\nexport type OnAssetsMarketDataArguments = {\n assets: {\n asset: CaipAssetType;\n unit: CaipAssetType;\n }[];\n};\n\n/**\n * The `onAssetsMarketData` handler. This is called by MetaMask when querying about market data for a specific asset.\n *\n * @param args - The arguments for the handler.\n * see {@link OnAssetsMarketDataArguments}.\n * @returns The market data for the asset. See {@link OnAssetsMarketDataResponse}.\n */\nexport type OnAssetsMarketDataHandler = (\n args: OnAssetsMarketDataArguments,\n) => Promise<OnAssetsMarketDataResponse>;\n\n/**\n * The response from the market data query, containing market data for the requested assets.\n *\n * @property marketData - A nested object with two CAIP-19 keys that contains a {@link FungibleAssetMarketData} object or null between the two keys.\n */\nexport type OnAssetsMarketDataResponse = {\n marketData: Record<\n CaipAssetType,\n Record<CaipAssetType, FungibleAssetMarketData | null>\n >;\n};\n"]}
@@ -0,0 +1,56 @@
1
+ import type { CaipAssetType } from "@metamask/utils";
2
+ /**
3
+ * The market data for a fungible asset.
4
+ *
5
+ * @property fungible - Indicates that this is a fungible asset.
6
+ * This is always `true` for fungible assets.
7
+ * @property marketCap - The market capitalization of the asset.
8
+ * @property totalVolume - The total volume of the asset.
9
+ * @property circulatingSupply - The circulating supply of the asset.
10
+ * @property allTimeHigh - The all-time high price of the asset.
11
+ * @property allTimeLow - The all-time low price of the asset.
12
+ * @property pricePercentChange - The percentage change in price over different intervals.
13
+ * @property pricePercentChange.interval - The time interval for the price change as a ISO 8601 duration
14
+ * or the string "all" to represent the all-time change.
15
+ */
16
+ export type FungibleAssetMarketData = {
17
+ fungible: true;
18
+ marketCap?: string;
19
+ totalVolume?: string;
20
+ circulatingSupply?: string;
21
+ allTimeHigh?: string;
22
+ allTimeLow?: string;
23
+ pricePercentChange?: {
24
+ [interval: string]: number;
25
+ };
26
+ };
27
+ /**
28
+ * The arguments for the `onAssetsMarketData` handler.
29
+ *
30
+ * @property assets - An array of objects containing the asset and unit types.
31
+ * @property assets.asset - The CAIP-19 asset type of the asset.
32
+ * @property assets.unit - The CAIP-19 asset type of the unit to use.
33
+ */
34
+ export type OnAssetsMarketDataArguments = {
35
+ assets: {
36
+ asset: CaipAssetType;
37
+ unit: CaipAssetType;
38
+ }[];
39
+ };
40
+ /**
41
+ * The `onAssetsMarketData` handler. This is called by MetaMask when querying about market data for a specific asset.
42
+ *
43
+ * @param args - The arguments for the handler.
44
+ * see {@link OnAssetsMarketDataArguments}.
45
+ * @returns The market data for the asset. See {@link OnAssetsMarketDataResponse}.
46
+ */
47
+ export type OnAssetsMarketDataHandler = (args: OnAssetsMarketDataArguments) => Promise<OnAssetsMarketDataResponse>;
48
+ /**
49
+ * The response from the market data query, containing market data for the requested assets.
50
+ *
51
+ * @property marketData - A nested object with two CAIP-19 keys that contains a {@link FungibleAssetMarketData} object or null between the two keys.
52
+ */
53
+ export type OnAssetsMarketDataResponse = {
54
+ marketData: Record<CaipAssetType, Record<CaipAssetType, FungibleAssetMarketData | null>>;
55
+ };
56
+ //# sourceMappingURL=assets-market-data.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assets-market-data.d.cts","sourceRoot":"","sources":["../../../src/types/handlers/assets-market-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAErD;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,IAAI,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE;QACnB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;KAC5B,CAAC;CACH,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,EAAE;QACN,KAAK,EAAE,aAAa,CAAC;QACrB,IAAI,EAAE,aAAa,CAAC;KACrB,EAAE,CAAC;CACL,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,yBAAyB,GAAG,CACtC,IAAI,EAAE,2BAA2B,KAC9B,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAEzC;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,UAAU,EAAE,MAAM,CAChB,aAAa,EACb,MAAM,CAAC,aAAa,EAAE,uBAAuB,GAAG,IAAI,CAAC,CACtD,CAAC;CACH,CAAC"}
@@ -0,0 +1,56 @@
1
+ import type { CaipAssetType } from "@metamask/utils";
2
+ /**
3
+ * The market data for a fungible asset.
4
+ *
5
+ * @property fungible - Indicates that this is a fungible asset.
6
+ * This is always `true` for fungible assets.
7
+ * @property marketCap - The market capitalization of the asset.
8
+ * @property totalVolume - The total volume of the asset.
9
+ * @property circulatingSupply - The circulating supply of the asset.
10
+ * @property allTimeHigh - The all-time high price of the asset.
11
+ * @property allTimeLow - The all-time low price of the asset.
12
+ * @property pricePercentChange - The percentage change in price over different intervals.
13
+ * @property pricePercentChange.interval - The time interval for the price change as a ISO 8601 duration
14
+ * or the string "all" to represent the all-time change.
15
+ */
16
+ export type FungibleAssetMarketData = {
17
+ fungible: true;
18
+ marketCap?: string;
19
+ totalVolume?: string;
20
+ circulatingSupply?: string;
21
+ allTimeHigh?: string;
22
+ allTimeLow?: string;
23
+ pricePercentChange?: {
24
+ [interval: string]: number;
25
+ };
26
+ };
27
+ /**
28
+ * The arguments for the `onAssetsMarketData` handler.
29
+ *
30
+ * @property assets - An array of objects containing the asset and unit types.
31
+ * @property assets.asset - The CAIP-19 asset type of the asset.
32
+ * @property assets.unit - The CAIP-19 asset type of the unit to use.
33
+ */
34
+ export type OnAssetsMarketDataArguments = {
35
+ assets: {
36
+ asset: CaipAssetType;
37
+ unit: CaipAssetType;
38
+ }[];
39
+ };
40
+ /**
41
+ * The `onAssetsMarketData` handler. This is called by MetaMask when querying about market data for a specific asset.
42
+ *
43
+ * @param args - The arguments for the handler.
44
+ * see {@link OnAssetsMarketDataArguments}.
45
+ * @returns The market data for the asset. See {@link OnAssetsMarketDataResponse}.
46
+ */
47
+ export type OnAssetsMarketDataHandler = (args: OnAssetsMarketDataArguments) => Promise<OnAssetsMarketDataResponse>;
48
+ /**
49
+ * The response from the market data query, containing market data for the requested assets.
50
+ *
51
+ * @property marketData - A nested object with two CAIP-19 keys that contains a {@link FungibleAssetMarketData} object or null between the two keys.
52
+ */
53
+ export type OnAssetsMarketDataResponse = {
54
+ marketData: Record<CaipAssetType, Record<CaipAssetType, FungibleAssetMarketData | null>>;
55
+ };
56
+ //# sourceMappingURL=assets-market-data.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assets-market-data.d.mts","sourceRoot":"","sources":["../../../src/types/handlers/assets-market-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAErD;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,IAAI,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE;QACnB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;KAC5B,CAAC;CACH,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,EAAE;QACN,KAAK,EAAE,aAAa,CAAC;QACrB,IAAI,EAAE,aAAa,CAAC;KACrB,EAAE,CAAC;CACL,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,yBAAyB,GAAG,CACtC,IAAI,EAAE,2BAA2B,KAC9B,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAEzC;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,UAAU,EAAE,MAAM,CAChB,aAAa,EACb,MAAM,CAAC,aAAa,EAAE,uBAAuB,GAAG,IAAI,CAAC,CACtD,CAAC;CACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=assets-market-data.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assets-market-data.mjs","sourceRoot":"","sources":["../../../src/types/handlers/assets-market-data.ts"],"names":[],"mappings":"","sourcesContent":["import type { CaipAssetType } from '@metamask/utils';\n\n/**\n * The market data for a fungible asset.\n *\n * @property fungible - Indicates that this is a fungible asset.\n * This is always `true` for fungible assets.\n * @property marketCap - The market capitalization of the asset.\n * @property totalVolume - The total volume of the asset.\n * @property circulatingSupply - The circulating supply of the asset.\n * @property allTimeHigh - The all-time high price of the asset.\n * @property allTimeLow - The all-time low price of the asset.\n * @property pricePercentChange - The percentage change in price over different intervals.\n * @property pricePercentChange.interval - The time interval for the price change as a ISO 8601 duration\n * or the string \"all\" to represent the all-time change.\n */\nexport type FungibleAssetMarketData = {\n fungible: true;\n marketCap?: string;\n totalVolume?: string;\n circulatingSupply?: string;\n allTimeHigh?: string;\n allTimeLow?: string;\n pricePercentChange?: {\n [interval: string]: number;\n };\n};\n\n/**\n * The arguments for the `onAssetsMarketData` handler.\n *\n * @property assets - An array of objects containing the asset and unit types.\n * @property assets.asset - The CAIP-19 asset type of the asset.\n * @property assets.unit - The CAIP-19 asset type of the unit to use.\n */\nexport type OnAssetsMarketDataArguments = {\n assets: {\n asset: CaipAssetType;\n unit: CaipAssetType;\n }[];\n};\n\n/**\n * The `onAssetsMarketData` handler. This is called by MetaMask when querying about market data for a specific asset.\n *\n * @param args - The arguments for the handler.\n * see {@link OnAssetsMarketDataArguments}.\n * @returns The market data for the asset. See {@link OnAssetsMarketDataResponse}.\n */\nexport type OnAssetsMarketDataHandler = (\n args: OnAssetsMarketDataArguments,\n) => Promise<OnAssetsMarketDataResponse>;\n\n/**\n * The response from the market data query, containing market data for the requested assets.\n *\n * @property marketData - A nested object with two CAIP-19 keys that contains a {@link FungibleAssetMarketData} object or null between the two keys.\n */\nexport type OnAssetsMarketDataResponse = {\n marketData: Record<\n CaipAssetType,\n Record<CaipAssetType, FungibleAssetMarketData | null>\n >;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/types/handlers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAEA,sDAAgC;AAShC,oDAA8B;AAE9B,mDAA6B","sourcesContent":["export type * from './asset-historical-price';\nexport type * from './assets-conversion';\nexport * from './assets-lookup';\nexport type * from './client-request';\nexport type * from './cronjob';\nexport type * from './home-page';\nexport type * from './keyring';\nexport type * from './lifecycle';\nexport type * from './name-lookup';\nexport type * from './protocol';\nexport type * from './rpc-request';\nexport * from './transaction';\nexport type * from './signature';\nexport * from './user-input';\nexport type * from './settings-page';\nexport type * from './web-socket-event';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/types/handlers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAGA,sDAAgC;AAShC,oDAA8B;AAE9B,mDAA6B","sourcesContent":["export type * from './asset-historical-price';\nexport type * from './assets-conversion';\nexport type * from './assets-market-data';\nexport * from './assets-lookup';\nexport type * from './client-request';\nexport type * from './cronjob';\nexport type * from './home-page';\nexport type * from './keyring';\nexport type * from './lifecycle';\nexport type * from './name-lookup';\nexport type * from './protocol';\nexport type * from './rpc-request';\nexport * from './transaction';\nexport type * from './signature';\nexport * from './user-input';\nexport type * from './settings-page';\nexport type * from './web-socket-event';\n"]}
@@ -1,5 +1,6 @@
1
1
  export type * from "./asset-historical-price.cjs";
2
2
  export type * from "./assets-conversion.cjs";
3
+ export type * from "./assets-market-data.cjs";
3
4
  export * from "./assets-lookup.cjs";
4
5
  export type * from "./client-request.cjs";
5
6
  export type * from "./cronjob.cjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/types/handlers/index.ts"],"names":[],"mappings":"AAAA,kDAA8C;AAC9C,6CAAyC;AACzC,oCAAgC;AAChC,0CAAsC;AACtC,mCAA+B;AAC/B,qCAAiC;AACjC,mCAA+B;AAC/B,qCAAiC;AACjC,uCAAmC;AACnC,oCAAgC;AAChC,uCAAmC;AACnC,kCAA8B;AAC9B,qCAAiC;AACjC,iCAA6B;AAC7B,yCAAqC;AACrC,4CAAwC"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/types/handlers/index.ts"],"names":[],"mappings":"AAAA,kDAA8C;AAC9C,6CAAyC;AACzC,8CAA0C;AAC1C,oCAAgC;AAChC,0CAAsC;AACtC,mCAA+B;AAC/B,qCAAiC;AACjC,mCAA+B;AAC/B,qCAAiC;AACjC,uCAAmC;AACnC,oCAAgC;AAChC,uCAAmC;AACnC,kCAA8B;AAC9B,qCAAiC;AACjC,iCAA6B;AAC7B,yCAAqC;AACrC,4CAAwC"}
@@ -1,5 +1,6 @@
1
1
  export type * from "./asset-historical-price.mjs";
2
2
  export type * from "./assets-conversion.mjs";
3
+ export type * from "./assets-market-data.mjs";
3
4
  export * from "./assets-lookup.mjs";
4
5
  export type * from "./client-request.mjs";
5
6
  export type * from "./cronjob.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/types/handlers/index.ts"],"names":[],"mappings":"AAAA,kDAA8C;AAC9C,6CAAyC;AACzC,oCAAgC;AAChC,0CAAsC;AACtC,mCAA+B;AAC/B,qCAAiC;AACjC,mCAA+B;AAC/B,qCAAiC;AACjC,uCAAmC;AACnC,oCAAgC;AAChC,uCAAmC;AACnC,kCAA8B;AAC9B,qCAAiC;AACjC,iCAA6B;AAC7B,yCAAqC;AACrC,4CAAwC"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/types/handlers/index.ts"],"names":[],"mappings":"AAAA,kDAA8C;AAC9C,6CAAyC;AACzC,8CAA0C;AAC1C,oCAAgC;AAChC,0CAAsC;AACtC,mCAA+B;AAC/B,qCAAiC;AACjC,mCAA+B;AAC/B,qCAAiC;AACjC,uCAAmC;AACnC,oCAAgC;AAChC,uCAAmC;AACnC,kCAA8B;AAC9B,qCAAiC;AACjC,iCAA6B;AAC7B,yCAAqC;AACrC,4CAAwC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/types/handlers/index.ts"],"names":[],"mappings":"AAEA,oCAAgC;AAShC,kCAA8B;AAE9B,iCAA6B","sourcesContent":["export type * from './asset-historical-price';\nexport type * from './assets-conversion';\nexport * from './assets-lookup';\nexport type * from './client-request';\nexport type * from './cronjob';\nexport type * from './home-page';\nexport type * from './keyring';\nexport type * from './lifecycle';\nexport type * from './name-lookup';\nexport type * from './protocol';\nexport type * from './rpc-request';\nexport * from './transaction';\nexport type * from './signature';\nexport * from './user-input';\nexport type * from './settings-page';\nexport type * from './web-socket-event';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/types/handlers/index.ts"],"names":[],"mappings":"AAGA,oCAAgC;AAShC,kCAA8B;AAE9B,iCAA6B","sourcesContent":["export type * from './asset-historical-price';\nexport type * from './assets-conversion';\nexport type * from './assets-market-data';\nexport * from './assets-lookup';\nexport type * from './client-request';\nexport type * from './cronjob';\nexport type * from './home-page';\nexport type * from './keyring';\nexport type * from './lifecycle';\nexport type * from './name-lookup';\nexport type * from './protocol';\nexport type * from './rpc-request';\nexport * from './transaction';\nexport type * from './signature';\nexport * from './user-input';\nexport type * from './settings-page';\nexport type * from './web-socket-event';\n"]}
@@ -104,8 +104,8 @@ export declare const FormSubmitEventStruct: import("@metamask/superstruct").Stru
104
104
  name: string;
105
105
  asset: `${string}:${string}/${string}:${string}`;
106
106
  } | null>;
107
- name: string;
108
107
  type: UserInputEventType.FormSubmitEvent;
108
+ name: string;
109
109
  }, {
110
110
  type: import("@metamask/superstruct").Struct<UserInputEventType.FormSubmitEvent, null>;
111
111
  value: import("@metamask/superstruct").Struct<Record<string, string | boolean | {
@@ -146,8 +146,8 @@ export declare const InputChangeEventStruct: import("@metamask/superstruct").Str
146
146
  name: string;
147
147
  asset: `${string}:${string}/${string}:${string}`;
148
148
  };
149
- name: string;
150
149
  type: UserInputEventType.InputChangeEvent;
150
+ name: string;
151
151
  }, {
152
152
  type: import("@metamask/superstruct").Struct<UserInputEventType.InputChangeEvent, null>;
153
153
  name: import("@metamask/superstruct").Struct<string, null>;
@@ -170,8 +170,8 @@ export declare const InputChangeEventStruct: import("@metamask/superstruct").Str
170
170
  */
171
171
  export type InputChangeEvent = Infer<typeof InputChangeEventStruct>;
172
172
  export declare const FileUploadEventStruct: import("@metamask/superstruct").Struct<{
173
- name: string;
174
173
  type: UserInputEventType.FileUploadEvent;
174
+ name: string;
175
175
  file: {
176
176
  name: string;
177
177
  size: number;
@@ -221,8 +221,8 @@ export declare const UserInputEventStruct: import("@metamask/superstruct").Struc
221
221
  name: string;
222
222
  asset: `${string}:${string}/${string}:${string}`;
223
223
  } | null>;
224
- name: string;
225
224
  type: UserInputEventType.FormSubmitEvent;
225
+ name: string;
226
226
  } | {
227
227
  value: string | boolean | {
228
228
  addresses: `${string}:${string}:${string}`[];
@@ -232,11 +232,11 @@ export declare const UserInputEventStruct: import("@metamask/superstruct").Struc
232
232
  name: string;
233
233
  asset: `${string}:${string}/${string}:${string}`;
234
234
  };
235
- name: string;
236
235
  type: UserInputEventType.InputChangeEvent;
237
- } | {
238
236
  name: string;
237
+ } | {
239
238
  type: UserInputEventType.FileUploadEvent;
239
+ name: string;
240
240
  file: {
241
241
  name: string;
242
242
  size: number;