@metamask/snaps-sdk 4.0.1 → 4.2.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 (72) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/dist/index.js +147 -6
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +162 -5
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/jsx/index.js +327 -0
  7. package/dist/jsx/index.js.map +1 -0
  8. package/dist/jsx/index.mjs +325 -0
  9. package/dist/jsx/index.mjs.map +1 -0
  10. package/dist/jsx/jsx-dev-runtime.js +217 -0
  11. package/dist/jsx/jsx-dev-runtime.js.map +1 -0
  12. package/dist/jsx/jsx-dev-runtime.mjs +215 -0
  13. package/dist/jsx/jsx-dev-runtime.mjs.map +1 -0
  14. package/dist/jsx/jsx-runtime.js +45 -0
  15. package/dist/jsx/jsx-runtime.js.map +1 -0
  16. package/dist/jsx/jsx-runtime.mjs +24 -0
  17. package/dist/jsx/jsx-runtime.mjs.map +1 -0
  18. package/dist/tsconfig.build.tsbuildinfo +1 -1
  19. package/dist/types/internals/index.d.ts +1 -0
  20. package/dist/types/internals/jsx.d.ts +31 -0
  21. package/dist/types/jsx/component.d.ts +66 -0
  22. package/dist/types/jsx/components/Address.d.ts +28 -0
  23. package/dist/types/jsx/components/Box.d.ts +27 -0
  24. package/dist/types/jsx/components/Copyable.d.ts +32 -0
  25. package/dist/types/jsx/components/Divider.d.ts +17 -0
  26. package/dist/types/jsx/components/Heading.d.ts +26 -0
  27. package/dist/types/jsx/components/Image.d.ts +36 -0
  28. package/dist/types/jsx/components/Link.d.ts +35 -0
  29. package/dist/types/jsx/components/Row.d.ts +41 -0
  30. package/dist/types/jsx/components/Spinner.d.ts +17 -0
  31. package/dist/types/jsx/components/Text.d.ts +33 -0
  32. package/dist/types/jsx/components/form/Button.d.ts +37 -0
  33. package/dist/types/jsx/components/form/Field.d.ts +34 -0
  34. package/dist/types/jsx/components/form/Form.d.ts +39 -0
  35. package/dist/types/jsx/components/form/Input.d.ts +37 -0
  36. package/dist/types/jsx/components/form/index.d.ts +9 -0
  37. package/dist/types/jsx/components/formatting/Bold.d.ts +32 -0
  38. package/dist/types/jsx/components/formatting/Italic.d.ts +34 -0
  39. package/dist/types/jsx/components/formatting/index.d.ts +5 -0
  40. package/dist/types/jsx/components/index.d.ts +28 -0
  41. package/dist/types/jsx/index.d.ts +5 -0
  42. package/dist/types/jsx/jsx-dev-runtime.d.ts +17 -0
  43. package/dist/types/jsx/jsx-runtime.d.ts +35 -0
  44. package/dist/types/jsx/validation.d.ts +110 -0
  45. package/dist/types/types/handlers/home-page.d.ts +2 -2
  46. package/dist/types/types/handlers/transaction.d.ts +2 -2
  47. package/dist/types/types/interface.d.ts +72 -0
  48. package/dist/types/types/methods/create-interface.d.ts +2 -2
  49. package/dist/types/types/methods/dialog.d.ts +4 -4
  50. package/dist/types/types/methods/update-interface.d.ts +2 -2
  51. package/dist/types/types/permissions.d.ts +2 -1
  52. package/dist/types/ui/components/address.d.ts +2 -0
  53. package/dist/types/ui/components/button.d.ts +2 -0
  54. package/dist/types/ui/components/copyable.d.ts +2 -0
  55. package/dist/types/ui/components/divider.d.ts +2 -0
  56. package/dist/types/ui/components/form.d.ts +9 -7
  57. package/dist/types/ui/components/heading.d.ts +2 -0
  58. package/dist/types/ui/components/image.d.ts +2 -0
  59. package/dist/types/ui/components/input.d.ts +5 -3
  60. package/dist/types/ui/components/panel.d.ts +88 -86
  61. package/dist/types/ui/components/row.d.ts +2 -0
  62. package/dist/types/ui/components/spinner.d.ts +2 -0
  63. package/dist/types/ui/components/text.d.ts +2 -0
  64. package/dist/types/ui/index.d.ts +0 -1
  65. package/dist/types/ui/nodes.d.ts +0 -5
  66. package/jsx-dev-runtime.d.ts +1 -0
  67. package/jsx-dev-runtime.js +5 -0
  68. package/jsx-runtime.d.ts +1 -0
  69. package/jsx-runtime.js +5 -0
  70. package/jsx.d.ts +1 -0
  71. package/jsx.js +5 -0
  72. package/package.json +27 -6
@@ -5,39 +5,7 @@ import { NodeType } from '../nodes';
5
5
  */
6
6
  export declare const ParentStruct: Struct<{
7
7
  type: string;
8
- children: (Panel | {
9
- type: NodeType.Input;
10
- name: string;
11
- value?: string | undefined;
12
- error?: string | undefined;
13
- inputType?: "number" | "text" | "password" | undefined;
14
- placeholder?: string | undefined;
15
- label?: string | undefined;
16
- } | {
17
- value: string;
18
- type: NodeType.Button;
19
- name?: string | undefined;
20
- variant?: "primary" | "secondary" | undefined;
21
- buttonType?: "button" | "submit" | undefined;
22
- } | {
23
- type: NodeType.Form;
24
- name: string;
25
- children: ({
26
- type: NodeType.Input;
27
- name: string;
28
- value?: string | undefined;
29
- error?: string | undefined;
30
- inputType?: "number" | "text" | "password" | undefined;
31
- placeholder?: string | undefined;
32
- label?: string | undefined;
33
- } | {
34
- value: string;
35
- type: NodeType.Button;
36
- name?: string | undefined;
37
- variant?: "primary" | "secondary" | undefined;
38
- buttonType?: "button" | "submit" | undefined;
39
- })[];
40
- } | {
8
+ children: ({
41
9
  value: string;
42
10
  type: NodeType.Copyable;
43
11
  sensitive?: boolean | undefined;
@@ -49,7 +17,7 @@ export declare const ParentStruct: Struct<{
49
17
  } | {
50
18
  value: string;
51
19
  type: NodeType.Image;
52
- } | {
20
+ } | Panel | {
53
21
  type: NodeType.Spinner;
54
22
  } | {
55
23
  value: string;
@@ -73,16 +41,14 @@ export declare const ParentStruct: Struct<{
73
41
  type: NodeType.Row;
74
42
  label: string;
75
43
  variant?: "default" | "warning" | "critical" | undefined;
76
- })[];
77
- }, {
78
- children: Struct<(Panel | {
44
+ } | {
79
45
  type: NodeType.Input;
80
46
  name: string;
81
47
  value?: string | undefined;
82
48
  error?: string | undefined;
83
- inputType?: "number" | "text" | "password" | undefined;
84
49
  placeholder?: string | undefined;
85
50
  label?: string | undefined;
51
+ inputType?: "number" | "text" | "password" | undefined;
86
52
  } | {
87
53
  value: string;
88
54
  type: NodeType.Button;
@@ -97,9 +63,9 @@ export declare const ParentStruct: Struct<{
97
63
  name: string;
98
64
  value?: string | undefined;
99
65
  error?: string | undefined;
100
- inputType?: "number" | "text" | "password" | undefined;
101
66
  placeholder?: string | undefined;
102
67
  label?: string | undefined;
68
+ inputType?: "number" | "text" | "password" | undefined;
103
69
  } | {
104
70
  value: string;
105
71
  type: NodeType.Button;
@@ -107,7 +73,9 @@ export declare const ParentStruct: Struct<{
107
73
  variant?: "primary" | "secondary" | undefined;
108
74
  buttonType?: "button" | "submit" | undefined;
109
75
  })[];
110
- } | {
76
+ })[];
77
+ }, {
78
+ children: Struct<({
111
79
  value: string;
112
80
  type: NodeType.Copyable;
113
81
  sensitive?: boolean | undefined;
@@ -119,7 +87,7 @@ export declare const ParentStruct: Struct<{
119
87
  } | {
120
88
  value: string;
121
89
  type: NodeType.Image;
122
- } | {
90
+ } | Panel | {
123
91
  type: NodeType.Spinner;
124
92
  } | {
125
93
  value: string;
@@ -143,14 +111,14 @@ export declare const ParentStruct: Struct<{
143
111
  type: NodeType.Row;
144
112
  label: string;
145
113
  variant?: "default" | "warning" | "critical" | undefined;
146
- })[], Struct<Panel | {
114
+ } | {
147
115
  type: NodeType.Input;
148
116
  name: string;
149
117
  value?: string | undefined;
150
118
  error?: string | undefined;
151
- inputType?: "number" | "text" | "password" | undefined;
152
119
  placeholder?: string | undefined;
153
120
  label?: string | undefined;
121
+ inputType?: "number" | "text" | "password" | undefined;
154
122
  } | {
155
123
  value: string;
156
124
  type: NodeType.Button;
@@ -165,9 +133,9 @@ export declare const ParentStruct: Struct<{
165
133
  name: string;
166
134
  value?: string | undefined;
167
135
  error?: string | undefined;
168
- inputType?: "number" | "text" | "password" | undefined;
169
136
  placeholder?: string | undefined;
170
137
  label?: string | undefined;
138
+ inputType?: "number" | "text" | "password" | undefined;
171
139
  } | {
172
140
  value: string;
173
141
  type: NodeType.Button;
@@ -175,7 +143,7 @@ export declare const ParentStruct: Struct<{
175
143
  variant?: "primary" | "secondary" | undefined;
176
144
  buttonType?: "button" | "submit" | undefined;
177
145
  })[];
178
- } | {
146
+ })[], Struct<{
179
147
  value: string;
180
148
  type: NodeType.Copyable;
181
149
  sensitive?: boolean | undefined;
@@ -187,7 +155,7 @@ export declare const ParentStruct: Struct<{
187
155
  } | {
188
156
  value: string;
189
157
  type: NodeType.Image;
190
- } | {
158
+ } | Panel | {
191
159
  type: NodeType.Spinner;
192
160
  } | {
193
161
  value: string;
@@ -211,6 +179,38 @@ export declare const ParentStruct: Struct<{
211
179
  type: NodeType.Row;
212
180
  label: string;
213
181
  variant?: "default" | "warning" | "critical" | undefined;
182
+ } | {
183
+ type: NodeType.Input;
184
+ name: string;
185
+ value?: string | undefined;
186
+ error?: string | undefined;
187
+ placeholder?: string | undefined;
188
+ label?: string | undefined;
189
+ inputType?: "number" | "text" | "password" | undefined;
190
+ } | {
191
+ value: string;
192
+ type: NodeType.Button;
193
+ name?: string | undefined;
194
+ variant?: "primary" | "secondary" | undefined;
195
+ buttonType?: "button" | "submit" | undefined;
196
+ } | {
197
+ type: NodeType.Form;
198
+ name: string;
199
+ children: ({
200
+ type: NodeType.Input;
201
+ name: string;
202
+ value?: string | undefined;
203
+ error?: string | undefined;
204
+ placeholder?: string | undefined;
205
+ label?: string | undefined;
206
+ inputType?: "number" | "text" | "password" | undefined;
207
+ } | {
208
+ value: string;
209
+ type: NodeType.Button;
210
+ name?: string | undefined;
211
+ variant?: "primary" | "secondary" | undefined;
212
+ buttonType?: "button" | "submit" | undefined;
213
+ })[];
214
214
  }, null>>;
215
215
  type: Struct<string, null>;
216
216
  }>;
@@ -246,6 +246,8 @@ export declare type Panel = {
246
246
  * @param args.children - The child nodes of the panel. This can be any valid
247
247
  * {@link Component}.
248
248
  * @returns The panel node as object.
249
+ * @deprecated Snaps component functions are deprecated, in favor of the new JSX
250
+ * components. This function will be removed in a future release.
249
251
  * @example
250
252
  * const node = panel({
251
253
  * children: [
@@ -259,39 +261,7 @@ export declare type Panel = {
259
261
  * text('This is a panel.'),
260
262
  * ]);
261
263
  */
262
- export declare const panel: (...args: [Omit<Panel, "type">] | (Panel | {
263
- type: NodeType.Input;
264
- name: string;
265
- value?: string | undefined;
266
- error?: string | undefined;
267
- inputType?: "number" | "text" | "password" | undefined;
268
- placeholder?: string | undefined;
269
- label?: string | undefined;
270
- } | {
271
- value: string;
272
- type: NodeType.Button;
273
- name?: string | undefined;
274
- variant?: "primary" | "secondary" | undefined;
275
- buttonType?: "button" | "submit" | undefined;
276
- } | {
277
- type: NodeType.Form;
278
- name: string;
279
- children: ({
280
- type: NodeType.Input;
281
- name: string;
282
- value?: string | undefined;
283
- error?: string | undefined;
284
- inputType?: "number" | "text" | "password" | undefined;
285
- placeholder?: string | undefined;
286
- label?: string | undefined;
287
- } | {
288
- value: string;
289
- type: NodeType.Button;
290
- name?: string | undefined;
291
- variant?: "primary" | "secondary" | undefined;
292
- buttonType?: "button" | "submit" | undefined;
293
- })[];
294
- } | {
264
+ export declare const panel: (...args: [Omit<Panel, "type">] | ({
295
265
  value: string;
296
266
  type: NodeType.Copyable;
297
267
  sensitive?: boolean | undefined;
@@ -303,7 +273,7 @@ export declare const panel: (...args: [Omit<Panel, "type">] | (Panel | {
303
273
  } | {
304
274
  value: string;
305
275
  type: NodeType.Image;
306
- } | {
276
+ } | Panel | {
307
277
  type: NodeType.Spinner;
308
278
  } | {
309
279
  value: string;
@@ -327,15 +297,14 @@ export declare const panel: (...args: [Omit<Panel, "type">] | (Panel | {
327
297
  type: NodeType.Row;
328
298
  label: string;
329
299
  variant?: "default" | "warning" | "critical" | undefined;
330
- })[][]) => Panel;
331
- export declare const ComponentStruct: Struct<Panel | {
300
+ } | {
332
301
  type: NodeType.Input;
333
302
  name: string;
334
303
  value?: string | undefined;
335
304
  error?: string | undefined;
336
- inputType?: "number" | "text" | "password" | undefined;
337
305
  placeholder?: string | undefined;
338
306
  label?: string | undefined;
307
+ inputType?: "number" | "text" | "password" | undefined;
339
308
  } | {
340
309
  value: string;
341
310
  type: NodeType.Button;
@@ -350,9 +319,9 @@ export declare const ComponentStruct: Struct<Panel | {
350
319
  name: string;
351
320
  value?: string | undefined;
352
321
  error?: string | undefined;
353
- inputType?: "number" | "text" | "password" | undefined;
354
322
  placeholder?: string | undefined;
355
323
  label?: string | undefined;
324
+ inputType?: "number" | "text" | "password" | undefined;
356
325
  } | {
357
326
  value: string;
358
327
  type: NodeType.Button;
@@ -360,7 +329,8 @@ export declare const ComponentStruct: Struct<Panel | {
360
329
  variant?: "primary" | "secondary" | undefined;
361
330
  buttonType?: "button" | "submit" | undefined;
362
331
  })[];
363
- } | {
332
+ })[][]) => Panel;
333
+ export declare const ComponentStruct: Struct<{
364
334
  value: string;
365
335
  type: NodeType.Copyable;
366
336
  sensitive?: boolean | undefined;
@@ -372,7 +342,7 @@ export declare const ComponentStruct: Struct<Panel | {
372
342
  } | {
373
343
  value: string;
374
344
  type: NodeType.Image;
375
- } | {
345
+ } | Panel | {
376
346
  type: NodeType.Spinner;
377
347
  } | {
378
348
  value: string;
@@ -396,6 +366,38 @@ export declare const ComponentStruct: Struct<Panel | {
396
366
  type: NodeType.Row;
397
367
  label: string;
398
368
  variant?: "default" | "warning" | "critical" | undefined;
369
+ } | {
370
+ type: NodeType.Input;
371
+ name: string;
372
+ value?: string | undefined;
373
+ error?: string | undefined;
374
+ placeholder?: string | undefined;
375
+ label?: string | undefined;
376
+ inputType?: "number" | "text" | "password" | undefined;
377
+ } | {
378
+ value: string;
379
+ type: NodeType.Button;
380
+ name?: string | undefined;
381
+ variant?: "primary" | "secondary" | undefined;
382
+ buttonType?: "button" | "submit" | undefined;
383
+ } | {
384
+ type: NodeType.Form;
385
+ name: string;
386
+ children: ({
387
+ type: NodeType.Input;
388
+ name: string;
389
+ value?: string | undefined;
390
+ error?: string | undefined;
391
+ placeholder?: string | undefined;
392
+ label?: string | undefined;
393
+ inputType?: "number" | "text" | "password" | undefined;
394
+ } | {
395
+ value: string;
396
+ type: NodeType.Button;
397
+ name?: string | undefined;
398
+ variant?: "primary" | "secondary" | undefined;
399
+ buttonType?: "button" | "submit" | undefined;
400
+ })[];
399
401
  }, null>;
400
402
  /**
401
403
  * All supported component types.
@@ -55,6 +55,8 @@ export declare type Row = Infer<typeof RowStruct>;
55
55
  * @param args.value - Another component, is currently limited to `image`, `text` and `address`.
56
56
  * @param args.variant - An optional variant, either `default`, `warning` or `critical`.
57
57
  * @returns The row node as an object.
58
+ * @deprecated Snaps component functions are deprecated, in favor of the new JSX
59
+ * components. This function will be removed in a future release.
58
60
  * @example
59
61
  * const node = row({ label: 'Address', value: address('0x4bbeeb066ed09b7aed07bf39eee0460dfa261520') });
60
62
  * const node = row({ label: 'Address', value: address('0x4bbeeb066ed09b7aed07bf39eee0460dfa261520'), variant: RowVariant.Warning });
@@ -14,6 +14,8 @@ export declare type Spinner = Infer<typeof SpinnerStruct>;
14
14
  * Create a {@link Spinner} node.
15
15
  *
16
16
  * @returns The spinner node as object.
17
+ * @deprecated Snaps component functions are deprecated, in favor of the new JSX
18
+ * components. This function will be removed in a future release.
17
19
  * @example
18
20
  * const node = spinner();
19
21
  */
@@ -29,6 +29,8 @@ export declare type Text = Infer<typeof TextStruct>;
29
29
  * @param args.markdown - An optional flag to enable or disable markdown. This
30
30
  * is enabled by default.
31
31
  * @returns The text node as object.
32
+ * @deprecated Snaps component functions are deprecated, in favor of the new JSX
33
+ * components. This function will be removed in a future release.
32
34
  * @example
33
35
  * const node = text({ value: 'Hello, world!' });
34
36
  * const node = text('Hello, world!');
@@ -1,4 +1,3 @@
1
1
  export * from './components';
2
2
  export * from './component';
3
- export type { NodeWithChildren } from './nodes';
4
3
  export { NodeType } from './nodes';
@@ -1,5 +1,4 @@
1
1
  import type { Infer } from 'superstruct';
2
- import type { Form, Panel } from './components';
3
2
  /**
4
3
  * The supported node types. This is based on SIP-7.
5
4
  *
@@ -19,10 +18,6 @@ export declare enum NodeType {
19
18
  Input = "input",
20
19
  Form = "form"
21
20
  }
22
- /**
23
- * The nodes with a children.
24
- */
25
- export declare type NodeWithChildren = Panel | Form;
26
21
  /**
27
22
  * @internal
28
23
  */
@@ -0,0 +1 @@
1
+ export * from './dist/types/jsx/jsx-dev-runtime';
@@ -0,0 +1,5 @@
1
+ /* eslint-disable */
2
+
3
+ // Re-exported for compatibility with build tools that don't support the
4
+ // `exports` field in package.json
5
+ module.exports = require('./dist/jsx/jsx-dev-runtime');
@@ -0,0 +1 @@
1
+ export * from './dist/types/jsx/jsx-runtime';
package/jsx-runtime.js ADDED
@@ -0,0 +1,5 @@
1
+ /* eslint-disable */
2
+
3
+ // Re-exported for compatibility with build tools that don't support the
4
+ // `exports` field in package.json
5
+ module.exports = require('./dist/jsx/jsx-runtime');
package/jsx.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/types/jsx';
package/jsx.js ADDED
@@ -0,0 +1,5 @@
1
+ /* eslint-disable */
2
+
3
+ // Re-exported for compatibility with build tools that don't support the
4
+ // `exports` field in package.json
5
+ module.exports = require('./dist/jsx/index');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/snaps-sdk",
3
- "version": "4.0.1",
3
+ "version": "4.2.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/MetaMask/snaps.git"
@@ -8,9 +8,24 @@
8
8
  "sideEffects": false,
9
9
  "exports": {
10
10
  ".": {
11
+ "types": "./dist/types/index.d.ts",
11
12
  "import": "./dist/index.mjs",
12
- "require": "./dist/index.js",
13
- "types": "./dist/types/index.d.ts"
13
+ "require": "./dist/index.js"
14
+ },
15
+ "./jsx": {
16
+ "types": "./dist/types/jsx/index.d.ts",
17
+ "import": "./dist/jsx/index.mjs",
18
+ "require": "./dist/jsx/index.js"
19
+ },
20
+ "./jsx-runtime": {
21
+ "types": "./dist/types/jsx/jsx-runtime.d.ts",
22
+ "import": "./dist/jsx/jsx-runtime.mjs",
23
+ "require": "./dist/jsx/jsx-runtime.js"
24
+ },
25
+ "./jsx-dev-runtime": {
26
+ "types": "./dist/types/jsx/jsx-dev-runtime.d.ts",
27
+ "import": "./dist/jsx/jsx-dev-runtime.mjs",
28
+ "require": "./dist/jsx/jsx-dev-runtime.js"
14
29
  },
15
30
  "./package.json": "./package.json"
16
31
  },
@@ -18,7 +33,13 @@
18
33
  "module": "./dist/index.mjs",
19
34
  "types": "./dist/types/index.d.ts",
20
35
  "files": [
21
- "dist"
36
+ "dist",
37
+ "jsx.js",
38
+ "jsx-dev-runtime.js",
39
+ "jsx-runtime.js",
40
+ "jsx.d.ts",
41
+ "jsx-dev-runtime.d.ts",
42
+ "jsx-runtime.d.ts"
22
43
  ],
23
44
  "scripts": {
24
45
  "test": "jest && yarn posttest",
@@ -38,8 +59,8 @@
38
59
  "build:ci": "tsup --clean"
39
60
  },
40
61
  "dependencies": {
41
- "@metamask/key-tree": "^9.0.0",
42
- "@metamask/providers": "^16.0.0",
62
+ "@metamask/key-tree": "^9.1.0",
63
+ "@metamask/providers": "^16.1.0",
43
64
  "@metamask/rpc-errors": "^6.2.1",
44
65
  "@metamask/utils": "^8.3.0",
45
66
  "fast-xml-parser": "^4.3.4",