@metamask/snaps-sdk 5.0.0 → 6.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.
- package/CHANGELOG.md +35 -1
- package/dist/index.js +226 -91
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +261 -89
- package/dist/index.mjs.map +1 -1
- package/dist/jsx/index.js +237 -89
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +243 -94
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/jsx-dev-runtime.js +167 -51
- package/dist/jsx/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx/jsx-dev-runtime.mjs +173 -56
- package/dist/jsx/jsx-dev-runtime.mjs.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/internals/jsx.d.ts +2 -3
- package/dist/types/internals/structs.d.ts +12 -3
- package/dist/types/internals/svg.d.ts +1 -1
- package/dist/types/jsx/component.d.ts +6 -9
- package/dist/types/jsx/components/Box.d.ts +4 -4
- package/dist/types/jsx/components/Card.d.ts +36 -0
- package/dist/types/jsx/components/Container.d.ts +34 -0
- package/dist/types/jsx/components/Footer.d.ts +28 -0
- package/dist/types/jsx/components/Link.d.ts +2 -2
- package/dist/types/jsx/components/Row.d.ts +1 -1
- package/dist/types/jsx/components/Text.d.ts +7 -2
- package/dist/types/jsx/components/Tooltip.d.ts +38 -0
- package/dist/types/jsx/components/form/Checkbox.d.ts +35 -0
- package/dist/types/jsx/components/form/Dropdown.d.ts +4 -5
- package/dist/types/jsx/components/form/Field.d.ts +7 -1
- package/dist/types/jsx/components/form/FileInput.d.ts +47 -0
- package/dist/types/jsx/components/form/Form.d.ts +4 -7
- package/dist/types/jsx/components/form/Input.d.ts +1 -2
- package/dist/types/jsx/components/form/index.d.ts +5 -1
- package/dist/types/jsx/components/formatting/Bold.d.ts +2 -2
- package/dist/types/jsx/components/formatting/Italic.d.ts +2 -2
- package/dist/types/jsx/components/index.d.ts +9 -1
- package/dist/types/jsx/index.d.ts +1 -1
- package/dist/types/jsx/validation.d.ts +67 -40
- package/dist/types/types/handlers/user-input.d.ts +140 -25
- package/dist/types/types/interface.d.ts +32 -24
- package/dist/types/types/methods/dialog.d.ts +8 -2
- package/dist/types/types/methods/index.d.ts +1 -0
- package/dist/types/types/methods/methods.d.ts +2 -0
- package/dist/types/types/methods/resolve-interface.d.ts +15 -0
- package/dist/types/ui/builder.d.ts +1 -1
- package/dist/types/ui/components/address.d.ts +4 -4
- package/dist/types/ui/components/button.d.ts +7 -7
- package/dist/types/ui/components/copyable.d.ts +5 -5
- package/dist/types/ui/components/divider.d.ts +3 -3
- package/dist/types/ui/components/form.d.ts +7 -7
- package/dist/types/ui/components/heading.d.ts +4 -4
- package/dist/types/ui/components/image.d.ts +4 -4
- package/dist/types/ui/components/input.d.ts +9 -9
- package/dist/types/ui/components/panel.d.ts +1 -1
- package/dist/types/ui/components/row.d.ts +6 -6
- package/dist/types/ui/components/spinner.d.ts +3 -3
- package/dist/types/ui/components/text.d.ts +5 -5
- package/dist/types/ui/nodes.d.ts +6 -6
- package/package.json +6 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Struct } from 'superstruct';
|
|
1
|
+
import type { Struct } from '@metamask/superstruct';
|
|
2
2
|
import type { Describe } from '../internals';
|
|
3
|
-
import type { GenericSnapElement, Key,
|
|
4
|
-
import type { AddressElement, BoldElement, BoxElement, ButtonElement, CopyableElement, DividerElement, DropdownElement, OptionElement, FieldElement, FormElement, HeadingElement, ImageElement, InputElement, ItalicElement, JSXElement, LinkElement, RowElement, SpinnerElement, StandardFormattingElement, TextElement, ValueElement } from './components';
|
|
3
|
+
import type { GenericSnapElement, Key, SnapElement, SnapsChildren, StringElement } from './component';
|
|
4
|
+
import type { AddressElement, BoldElement, BoxElement, ButtonElement, CheckboxElement, CardElement, CopyableElement, DividerElement, DropdownElement, OptionElement, FieldElement, FormElement, HeadingElement, ImageElement, InputElement, ItalicElement, JSXElement, LinkElement, RowElement, SpinnerElement, StandardFormattingElement, TextElement, TooltipElement, ValueElement, FileInputElement, ContainerElement, FooterElement } from './components';
|
|
5
5
|
/**
|
|
6
6
|
* A struct for the {@link Key} type.
|
|
7
7
|
*/
|
|
@@ -18,6 +18,10 @@ export declare const ElementStruct: Describe<GenericSnapElement>;
|
|
|
18
18
|
* A struct for the {@link ButtonElement} type.
|
|
19
19
|
*/
|
|
20
20
|
export declare const ButtonStruct: Describe<ButtonElement>;
|
|
21
|
+
/**
|
|
22
|
+
* A struct for the {@link CheckboxElement} type.
|
|
23
|
+
*/
|
|
24
|
+
export declare const CheckboxStruct: Describe<CheckboxElement>;
|
|
21
25
|
/**
|
|
22
26
|
* A struct for the {@link InputElement} type.
|
|
23
27
|
*/
|
|
@@ -30,10 +34,23 @@ export declare const OptionStruct: Describe<OptionElement>;
|
|
|
30
34
|
* A struct for the {@link DropdownElement} type.
|
|
31
35
|
*/
|
|
32
36
|
export declare const DropdownStruct: Describe<DropdownElement>;
|
|
37
|
+
/**
|
|
38
|
+
* A struct for the {@link FileInputElement} type.
|
|
39
|
+
*/
|
|
40
|
+
export declare const FileInputStruct: Describe<FileInputElement>;
|
|
41
|
+
/**
|
|
42
|
+
* A union of the allowed children of the Field component.
|
|
43
|
+
* This is mainly used in the simulator for validation purposes.
|
|
44
|
+
*/
|
|
45
|
+
export declare const FieldChildUnionStruct: Struct<SnapElement<import("./components").ButtonProps, "Button"> | SnapElement<import("./components").CheckboxProps, "Checkbox"> | SnapElement<import("./components").InputProps, "Input"> | SnapElement<import("./components").DropdownProps, "Dropdown"> | SnapElement<import("./components").FileInputProps, "FileInput">, null>;
|
|
33
46
|
/**
|
|
34
47
|
* A struct for the {@link FieldElement} type.
|
|
35
48
|
*/
|
|
36
49
|
export declare const FieldStruct: Describe<FieldElement>;
|
|
50
|
+
/**
|
|
51
|
+
* A subset of JSX elements that are allowed as children of the Form component.
|
|
52
|
+
*/
|
|
53
|
+
export declare const FormChildStruct: Struct<SnapsChildren<GenericSnapElement>, null>;
|
|
37
54
|
/**
|
|
38
55
|
* A struct for the {@link FormElement} type.
|
|
39
56
|
*/
|
|
@@ -51,10 +68,29 @@ export declare const FormattingStruct: Describe<StandardFormattingElement>;
|
|
|
51
68
|
* A struct for the {@link AddressElement} type.
|
|
52
69
|
*/
|
|
53
70
|
export declare const AddressStruct: Describe<AddressElement>;
|
|
71
|
+
export declare const BoxChildrenStruct: Struct<SnapsChildren<GenericSnapElement>, null>;
|
|
54
72
|
/**
|
|
55
73
|
* A struct for the {@link BoxElement} type.
|
|
56
74
|
*/
|
|
57
75
|
export declare const BoxStruct: Describe<BoxElement>;
|
|
76
|
+
/**
|
|
77
|
+
* A subset of JSX elements that are allowed as children of the Footer component.
|
|
78
|
+
* This set should include a single button or a tuple of two buttons.
|
|
79
|
+
*/
|
|
80
|
+
export declare const FooterChildStruct: Struct<SnapElement<import("./components").ButtonProps, "Button"> | [SnapElement<import("./components").ButtonProps, "Button">, SnapElement<import("./components").ButtonProps, "Button">], null>;
|
|
81
|
+
/**
|
|
82
|
+
* A struct for the {@link FooterElement} type.
|
|
83
|
+
*/
|
|
84
|
+
export declare const FooterStruct: Describe<FooterElement>;
|
|
85
|
+
/**
|
|
86
|
+
* A subset of JSX elements that are allowed as children of the Container component.
|
|
87
|
+
* This set should include a single Box or a tuple of a Box and a Footer component.
|
|
88
|
+
*/
|
|
89
|
+
export declare const ContainerChildStruct: Struct<SnapElement<import("./components").BoxProps, "Box"> | [SnapElement<import("./components").BoxProps, "Box">, SnapElement<import("./components").FooterProps, "Footer">], null>;
|
|
90
|
+
/**
|
|
91
|
+
* A struct for the {@link ContainerElement} type.
|
|
92
|
+
*/
|
|
93
|
+
export declare const ContainerStruct: Describe<ContainerElement>;
|
|
58
94
|
/**
|
|
59
95
|
* A struct for the {@link CopyableElement} type.
|
|
60
96
|
*/
|
|
@@ -67,6 +103,10 @@ export declare const DividerStruct: Describe<DividerElement>;
|
|
|
67
103
|
* A struct for the {@link ValueElement} type.
|
|
68
104
|
*/
|
|
69
105
|
export declare const ValueStruct: Describe<ValueElement>;
|
|
106
|
+
/**
|
|
107
|
+
* A struct for the {@link CardElement} type.
|
|
108
|
+
*/
|
|
109
|
+
export declare const CardStruct: Describe<CardElement>;
|
|
70
110
|
/**
|
|
71
111
|
* A struct for the {@link HeadingElement} type.
|
|
72
112
|
*/
|
|
@@ -83,6 +123,23 @@ export declare const LinkStruct: Describe<LinkElement>;
|
|
|
83
123
|
* A struct for the {@link TextElement} type.
|
|
84
124
|
*/
|
|
85
125
|
export declare const TextStruct: Describe<TextElement>;
|
|
126
|
+
/**
|
|
127
|
+
* A subset of JSX elements that are allowed as children of the Tooltip component.
|
|
128
|
+
* This set should include all text components and the Image.
|
|
129
|
+
*/
|
|
130
|
+
export declare const TooltipChildStruct: Struct<boolean | SnapElement<import("./components").BoldProps, "Bold"> | SnapElement<import("./components").ItalicProps, "Italic"> | SnapElement<{
|
|
131
|
+
src: string;
|
|
132
|
+
alt?: string | undefined;
|
|
133
|
+
}, "Image"> | SnapElement<import("./components").LinkProps, "Link"> | SnapElement<import("./components").TextProps, "Text">, null>;
|
|
134
|
+
/**
|
|
135
|
+
* A subset of JSX elements that are allowed as content of the Tooltip component.
|
|
136
|
+
* This set should include all text components.
|
|
137
|
+
*/
|
|
138
|
+
export declare const TooltipContentStruct: Struct<string | SnapElement<import("./components").BoldProps, "Bold"> | SnapElement<import("./components").ItalicProps, "Italic"> | SnapElement<import("./components").LinkProps, "Link"> | SnapElement<import("./components").TextProps, "Text">, null>;
|
|
139
|
+
/**
|
|
140
|
+
* A struct for the {@link TooltipElement} type.
|
|
141
|
+
*/
|
|
142
|
+
export declare const TooltipStruct: Describe<TooltipElement>;
|
|
86
143
|
/**
|
|
87
144
|
* A struct for the {@link RowElement} type.
|
|
88
145
|
*/
|
|
@@ -93,55 +150,25 @@ export declare const RowStruct: Describe<RowElement>;
|
|
|
93
150
|
export declare const SpinnerStruct: Describe<SpinnerElement>;
|
|
94
151
|
/**
|
|
95
152
|
* A subset of JSX elements that are allowed as children of the Box component.
|
|
96
|
-
* This set
|
|
97
|
-
*
|
|
98
|
-
*/
|
|
99
|
-
export declare const BoxChildStruct: Struct<SnapElement<import("./components").ButtonProps, "Button"> | SnapElement<{
|
|
100
|
-
name: string;
|
|
101
|
-
type?: "number" | "text" | "password" | undefined;
|
|
102
|
-
value?: string | undefined;
|
|
103
|
-
placeholder?: string | undefined;
|
|
104
|
-
}, "Input"> | SnapElement<{
|
|
105
|
-
name: string;
|
|
106
|
-
value?: string | undefined;
|
|
107
|
-
children: MaybeArray<SnapElement<{
|
|
108
|
-
value: string;
|
|
109
|
-
children: string;
|
|
110
|
-
}, "Option">>;
|
|
111
|
-
}, "Dropdown"> | SnapElement<{
|
|
112
|
-
children: MaybeArray<SnapElement<import("./components").ButtonProps, "Button"> | SnapElement<import("./components").FieldProps, "Field">>;
|
|
113
|
-
name: string;
|
|
114
|
-
}, "Form"> | SnapElement<import("./components").BoldProps, "Bold"> | SnapElement<import("./components").ItalicProps, "Italic"> | SnapElement<import("./components").AddressProps, "Address"> | SnapElement<import("./components").BoxProps, "Box"> | SnapElement<import("./components").CopyableProps, "Copyable"> | SnapElement<Record<string, never>, "Divider"> | SnapElement<{
|
|
153
|
+
* This set includes all components, except components that need to be nested in
|
|
154
|
+
* another component (e.g., Field must be contained in a Form).
|
|
155
|
+
*/
|
|
156
|
+
export declare const BoxChildStruct: Struct<SnapElement<import("./components").ButtonProps, "Button"> | SnapElement<import("./components").CheckboxProps, "Checkbox"> | SnapElement<import("./components").FormProps, "Form"> | SnapElement<import("./components").InputProps, "Input"> | SnapElement<import("./components").DropdownProps, "Dropdown"> | SnapElement<import("./components").FileInputProps, "FileInput"> | SnapElement<import("./components").BoldProps, "Bold"> | SnapElement<import("./components").ItalicProps, "Italic"> | SnapElement<import("./components").AddressProps, "Address"> | SnapElement<import("./components").BoxProps, "Box"> | SnapElement<import("./components").CardProps, "Card"> | SnapElement<import("./components").CopyableProps, "Copyable"> | SnapElement<Record<string, never>, "Divider"> | SnapElement<{
|
|
115
157
|
children: StringElement;
|
|
116
158
|
}, "Heading"> | SnapElement<{
|
|
117
159
|
src: string;
|
|
118
160
|
alt?: string | undefined;
|
|
119
|
-
}, "Image"> | SnapElement<import("./components").LinkProps, "Link"> | SnapElement<import("./components").TextProps, "Text"> | SnapElement<import("./components").RowProps, "Row"> | SnapElement<Record<string, never>, "Spinner">, null>;
|
|
161
|
+
}, "Image"> | SnapElement<import("./components").LinkProps, "Link"> | SnapElement<import("./components").TextProps, "Text"> | SnapElement<import("./components").RowProps, "Row"> | SnapElement<Record<string, never>, "Spinner"> | SnapElement<import("./components").TooltipProps, "Tooltip">, null>;
|
|
120
162
|
/**
|
|
121
163
|
* For now, the allowed JSX elements at the root are the same as the allowed
|
|
122
164
|
* children of the Box component.
|
|
123
165
|
*/
|
|
124
|
-
export declare const RootJSXElementStruct: Struct<SnapElement<import("./components").ButtonProps, "Button"> | SnapElement<{
|
|
125
|
-
name: string;
|
|
126
|
-
type?: "number" | "text" | "password" | undefined;
|
|
127
|
-
value?: string | undefined;
|
|
128
|
-
placeholder?: string | undefined;
|
|
129
|
-
}, "Input"> | SnapElement<{
|
|
130
|
-
name: string;
|
|
131
|
-
value?: string | undefined;
|
|
132
|
-
children: MaybeArray<SnapElement<{
|
|
133
|
-
value: string;
|
|
134
|
-
children: string;
|
|
135
|
-
}, "Option">>;
|
|
136
|
-
}, "Dropdown"> | SnapElement<{
|
|
137
|
-
children: MaybeArray<SnapElement<import("./components").ButtonProps, "Button"> | SnapElement<import("./components").FieldProps, "Field">>;
|
|
138
|
-
name: string;
|
|
139
|
-
}, "Form"> | SnapElement<import("./components").BoldProps, "Bold"> | SnapElement<import("./components").ItalicProps, "Italic"> | SnapElement<import("./components").AddressProps, "Address"> | SnapElement<import("./components").BoxProps, "Box"> | SnapElement<import("./components").CopyableProps, "Copyable"> | SnapElement<Record<string, never>, "Divider"> | SnapElement<{
|
|
166
|
+
export declare const RootJSXElementStruct: Struct<SnapElement<import("./components").ButtonProps, "Button"> | SnapElement<import("./components").CheckboxProps, "Checkbox"> | SnapElement<import("./components").FormProps, "Form"> | SnapElement<import("./components").InputProps, "Input"> | SnapElement<import("./components").DropdownProps, "Dropdown"> | SnapElement<import("./components").FileInputProps, "FileInput"> | SnapElement<import("./components").BoldProps, "Bold"> | SnapElement<import("./components").ItalicProps, "Italic"> | SnapElement<import("./components").AddressProps, "Address"> | SnapElement<import("./components").BoxProps, "Box"> | SnapElement<import("./components").CardProps, "Card"> | SnapElement<import("./components").ContainerProps, "Container"> | SnapElement<import("./components").CopyableProps, "Copyable"> | SnapElement<Record<string, never>, "Divider"> | SnapElement<{
|
|
140
167
|
children: StringElement;
|
|
141
168
|
}, "Heading"> | SnapElement<{
|
|
142
169
|
src: string;
|
|
143
170
|
alt?: string | undefined;
|
|
144
|
-
}, "Image"> | SnapElement<import("./components").LinkProps, "Link"> | SnapElement<import("./components").TextProps, "Text"> | SnapElement<import("./components").RowProps, "Row"> | SnapElement<Record<string, never>, "Spinner">, null>;
|
|
171
|
+
}, "Image"> | SnapElement<import("./components").LinkProps, "Link"> | SnapElement<import("./components").TextProps, "Text"> | SnapElement<import("./components").RowProps, "Row"> | SnapElement<Record<string, never>, "Spinner"> | SnapElement<import("./components").TooltipProps, "Tooltip">, null>;
|
|
145
172
|
/**
|
|
146
173
|
* A struct for the {@link JSXElement} type.
|
|
147
174
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Infer } from 'superstruct';
|
|
1
|
+
import type { Infer } from '@metamask/superstruct';
|
|
2
2
|
import type { InterfaceContext } from '../interface';
|
|
3
3
|
/**
|
|
4
4
|
* The type of user input event fired.
|
|
@@ -7,65 +7,180 @@ import type { InterfaceContext } from '../interface';
|
|
|
7
7
|
* - `ButtonClickEvent` - A button has been clicked in the UI.
|
|
8
8
|
* - `FormSubmitEvent` - A Form has been submitted in the UI.
|
|
9
9
|
* - `InputChangeEvent` - The value of an input field has changed in the UI.
|
|
10
|
+
* - `FileUploadEvent` - A file has been uploaded in the UI.
|
|
10
11
|
*/
|
|
11
12
|
export declare enum UserInputEventType {
|
|
12
13
|
ButtonClickEvent = "ButtonClickEvent",
|
|
13
14
|
FormSubmitEvent = "FormSubmitEvent",
|
|
14
|
-
InputChangeEvent = "InputChangeEvent"
|
|
15
|
+
InputChangeEvent = "InputChangeEvent",
|
|
16
|
+
FileUploadEvent = "FileUploadEvent"
|
|
15
17
|
}
|
|
16
|
-
export declare const GenericEventStruct: import("superstruct").Struct<{
|
|
18
|
+
export declare const GenericEventStruct: import("@metamask/superstruct").Struct<{
|
|
17
19
|
type: string;
|
|
18
20
|
name?: string | undefined;
|
|
19
21
|
}, {
|
|
20
|
-
type: import("superstruct").Struct<string, null>;
|
|
21
|
-
name: import("superstruct").Struct<string | undefined, null>;
|
|
22
|
+
type: import("@metamask/superstruct").Struct<string, null>;
|
|
23
|
+
name: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
22
24
|
}>;
|
|
23
|
-
export declare const ButtonClickEventStruct: import("superstruct").Struct<{
|
|
25
|
+
export declare const ButtonClickEventStruct: import("@metamask/superstruct").Struct<{
|
|
24
26
|
type: UserInputEventType.ButtonClickEvent;
|
|
25
27
|
name?: string | undefined;
|
|
26
28
|
}, {
|
|
27
|
-
type: import("superstruct").Struct<UserInputEventType.ButtonClickEvent, UserInputEventType.ButtonClickEvent>;
|
|
28
|
-
name: import("superstruct").Struct<string | undefined, null>;
|
|
29
|
+
type: import("@metamask/superstruct").Struct<UserInputEventType.ButtonClickEvent, UserInputEventType.ButtonClickEvent>;
|
|
30
|
+
name: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
29
31
|
}>;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
/**
|
|
33
|
+
* A button click event fired in the UI. This is passed to the params of the
|
|
34
|
+
* `onUserInput` handler.
|
|
35
|
+
*
|
|
36
|
+
* @property type - The type of event fired. See {@link UserInputEventType} for
|
|
37
|
+
* the different types. This is always `ButtonClickEvent`.
|
|
38
|
+
* @property name - The optional component name that fired the event.
|
|
39
|
+
*/
|
|
40
|
+
export declare type ButtonClickEvent = Infer<typeof ButtonClickEventStruct>;
|
|
41
|
+
export declare const FileStruct: import("@metamask/superstruct").Struct<{
|
|
42
|
+
name: string;
|
|
43
|
+
size: number;
|
|
44
|
+
contentType: string;
|
|
45
|
+
contents: string;
|
|
46
|
+
}, {
|
|
47
|
+
name: import("@metamask/superstruct").Struct<string, null>;
|
|
48
|
+
size: import("@metamask/superstruct").Struct<number, null>;
|
|
49
|
+
contentType: import("@metamask/superstruct").Struct<string, null>;
|
|
50
|
+
contents: import("@metamask/superstruct").Struct<string, null>;
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* A file object containing the file name, size, content type, and the base64
|
|
54
|
+
* encoded contents of the file.
|
|
55
|
+
*
|
|
56
|
+
* @property name - The name of the file.
|
|
57
|
+
* @property size - The size of the file in bytes.
|
|
58
|
+
* @property contentType - The content type of the file.
|
|
59
|
+
* @property contents - The base64 encoded contents of the file.
|
|
60
|
+
*/
|
|
61
|
+
export declare type File = Infer<typeof FileStruct>;
|
|
62
|
+
export declare const FormSubmitEventStruct: import("@metamask/superstruct").Struct<{
|
|
63
|
+
value: Record<string, string | boolean | {
|
|
64
|
+
name: string;
|
|
65
|
+
size: number;
|
|
66
|
+
contentType: string;
|
|
67
|
+
contents: string;
|
|
68
|
+
} | null>;
|
|
32
69
|
type: UserInputEventType.FormSubmitEvent;
|
|
33
70
|
name: string;
|
|
34
71
|
}, {
|
|
35
|
-
type: import("superstruct").Struct<UserInputEventType.FormSubmitEvent, UserInputEventType.FormSubmitEvent>;
|
|
36
|
-
value: import("superstruct").Struct<Record<string, string |
|
|
37
|
-
|
|
72
|
+
type: import("@metamask/superstruct").Struct<UserInputEventType.FormSubmitEvent, UserInputEventType.FormSubmitEvent>;
|
|
73
|
+
value: import("@metamask/superstruct").Struct<Record<string, string | boolean | {
|
|
74
|
+
name: string;
|
|
75
|
+
size: number;
|
|
76
|
+
contentType: string;
|
|
77
|
+
contents: string;
|
|
78
|
+
} | null>, null>;
|
|
79
|
+
name: import("@metamask/superstruct").Struct<string, null>;
|
|
38
80
|
}>;
|
|
39
|
-
|
|
40
|
-
|
|
81
|
+
/**
|
|
82
|
+
* A form submit event, which is fired when a submit button is clicked.
|
|
83
|
+
*
|
|
84
|
+
* @property type - The type of event fired. This is always `FormSubmitEvent`.
|
|
85
|
+
* @property name - The name of the form that was submitted.
|
|
86
|
+
* @property value - The form values submitted as an object. The keys are the
|
|
87
|
+
* names of the form fields and the values are the values of the form fields. If
|
|
88
|
+
* a form field is empty, the value is `null` or an empty string.
|
|
89
|
+
* @property files - The files uploaded in the form. The keys are the names of
|
|
90
|
+
* the file input fields and the values are the file objects containing the file
|
|
91
|
+
* name, size, content type, and the base64 encoded contents of the file. See
|
|
92
|
+
* {@link File}.
|
|
93
|
+
*/
|
|
94
|
+
export declare type FormSubmitEvent = Infer<typeof FormSubmitEventStruct>;
|
|
95
|
+
export declare const InputChangeEventStruct: import("@metamask/superstruct").Struct<{
|
|
96
|
+
value: string | boolean;
|
|
41
97
|
type: UserInputEventType.InputChangeEvent;
|
|
42
98
|
name: string;
|
|
43
99
|
}, {
|
|
44
|
-
type: import("superstruct").Struct<UserInputEventType.InputChangeEvent, UserInputEventType.InputChangeEvent>;
|
|
45
|
-
name: import("superstruct").Struct<string, null>;
|
|
46
|
-
value: import("superstruct").Struct<string, null>;
|
|
100
|
+
type: import("@metamask/superstruct").Struct<UserInputEventType.InputChangeEvent, UserInputEventType.InputChangeEvent>;
|
|
101
|
+
name: import("@metamask/superstruct").Struct<string, null>;
|
|
102
|
+
value: import("@metamask/superstruct").Struct<string | boolean, null>;
|
|
47
103
|
}>;
|
|
48
|
-
|
|
104
|
+
/**
|
|
105
|
+
* An input change event, which is fired when the value of an input field
|
|
106
|
+
* changes.
|
|
107
|
+
*
|
|
108
|
+
* @property type - The type of event fired. This is always `InputChangeEvent`.
|
|
109
|
+
* @property name - The name of the input field that changed.
|
|
110
|
+
* @property value - The new value of the input field.
|
|
111
|
+
*/
|
|
112
|
+
export declare type InputChangeEvent = Infer<typeof InputChangeEventStruct>;
|
|
113
|
+
export declare const FileUploadEventStruct: import("@metamask/superstruct").Struct<{
|
|
114
|
+
type: UserInputEventType.FileUploadEvent;
|
|
115
|
+
name: string;
|
|
116
|
+
file: {
|
|
117
|
+
name: string;
|
|
118
|
+
size: number;
|
|
119
|
+
contentType: string;
|
|
120
|
+
contents: string;
|
|
121
|
+
} | null;
|
|
122
|
+
}, {
|
|
123
|
+
type: import("@metamask/superstruct").Struct<UserInputEventType.FileUploadEvent, UserInputEventType.FileUploadEvent>;
|
|
124
|
+
name: import("@metamask/superstruct").Struct<string, null>;
|
|
125
|
+
file: import("@metamask/superstruct").Struct<{
|
|
126
|
+
name: string;
|
|
127
|
+
size: number;
|
|
128
|
+
contentType: string;
|
|
129
|
+
contents: string;
|
|
130
|
+
} | null, {
|
|
131
|
+
name: import("@metamask/superstruct").Struct<string, null>;
|
|
132
|
+
size: import("@metamask/superstruct").Struct<number, null>;
|
|
133
|
+
contentType: import("@metamask/superstruct").Struct<string, null>;
|
|
134
|
+
contents: import("@metamask/superstruct").Struct<string, null>;
|
|
135
|
+
}>;
|
|
136
|
+
}>;
|
|
137
|
+
/**
|
|
138
|
+
* A file upload event, which is fired when a file is uploaded.
|
|
139
|
+
*
|
|
140
|
+
* @property type - The type of event fired. This is always `FileUploadEvent`.
|
|
141
|
+
* @property name - The name of the file input field that was used to upload the
|
|
142
|
+
* file.
|
|
143
|
+
* @property file - The file object containing the file name, size,
|
|
144
|
+
* content type, and the base64 encoded contents of the file.
|
|
145
|
+
* @see File
|
|
146
|
+
*/
|
|
147
|
+
export declare type FileUploadEvent = Infer<typeof FileUploadEventStruct>;
|
|
148
|
+
export declare const UserInputEventStruct: import("@metamask/superstruct").Struct<{
|
|
49
149
|
type: UserInputEventType.ButtonClickEvent;
|
|
50
150
|
name?: string | undefined;
|
|
51
151
|
} | {
|
|
52
|
-
value: Record<string, string |
|
|
152
|
+
value: Record<string, string | boolean | {
|
|
153
|
+
name: string;
|
|
154
|
+
size: number;
|
|
155
|
+
contentType: string;
|
|
156
|
+
contents: string;
|
|
157
|
+
} | null>;
|
|
53
158
|
type: UserInputEventType.FormSubmitEvent;
|
|
54
159
|
name: string;
|
|
55
160
|
} | {
|
|
56
|
-
value: string;
|
|
161
|
+
value: string | boolean;
|
|
57
162
|
type: UserInputEventType.InputChangeEvent;
|
|
58
163
|
name: string;
|
|
164
|
+
} | {
|
|
165
|
+
type: UserInputEventType.FileUploadEvent;
|
|
166
|
+
name: string;
|
|
167
|
+
file: {
|
|
168
|
+
name: string;
|
|
169
|
+
size: number;
|
|
170
|
+
contentType: string;
|
|
171
|
+
contents: string;
|
|
172
|
+
} | null;
|
|
59
173
|
}, null>;
|
|
60
174
|
/**
|
|
61
175
|
* A user input event fired in the UI. This is passed to the params of the `onUserInput` handler.
|
|
62
176
|
*
|
|
63
177
|
* @property type - The type of event fired. See {@link UserInputEventType} for the different types.
|
|
64
|
-
* @property name - The component name that fired the event. It is optional for
|
|
65
|
-
*
|
|
66
|
-
*
|
|
178
|
+
* @property name - The component name that fired the event. It is optional for
|
|
179
|
+
* an {@link UserInputEventType.ButtonClickEvent}.
|
|
180
|
+
* @property value - The value associated with the event. Only available when an
|
|
181
|
+
* {@link UserInputEventType.FormSubmitEvent} is fired. It contains the form values submitted.
|
|
67
182
|
*/
|
|
68
|
-
export declare type UserInputEvent =
|
|
183
|
+
export declare type UserInputEvent = ButtonClickEvent | FormSubmitEvent | InputChangeEvent | FileUploadEvent;
|
|
69
184
|
/**
|
|
70
185
|
* The `onUserInput` handler. This is called when an user input event is fired in the UI.
|
|
71
186
|
*
|
|
@@ -1,17 +1,40 @@
|
|
|
1
|
-
import type { Infer } from 'superstruct';
|
|
1
|
+
import type { Infer } from '@metamask/superstruct';
|
|
2
2
|
import type { JSXElement } from '../jsx';
|
|
3
3
|
import type { Component } from '../ui';
|
|
4
4
|
/**
|
|
5
|
-
* To avoid typing problems with the interface state when manipulating it we
|
|
6
|
-
* a form (that will be contained inside the
|
|
5
|
+
* To avoid typing problems with the interface state when manipulating it we
|
|
6
|
+
* have to differentiate the state of a form (that will be contained inside the
|
|
7
|
+
* root state) and the root state since a key in the root stat can contain
|
|
7
8
|
* either the value of an input or a sub-state of a form.
|
|
8
9
|
*/
|
|
9
|
-
export declare const
|
|
10
|
-
|
|
10
|
+
export declare const StateStruct: import("@metamask/superstruct").Struct<string | boolean | {
|
|
11
|
+
name: string;
|
|
12
|
+
size: number;
|
|
13
|
+
contentType: string;
|
|
14
|
+
contents: string;
|
|
15
|
+
}, null>;
|
|
16
|
+
export declare const FormStateStruct: import("@metamask/superstruct").Struct<Record<string, string | boolean | {
|
|
17
|
+
name: string;
|
|
18
|
+
size: number;
|
|
19
|
+
contentType: string;
|
|
20
|
+
contents: string;
|
|
21
|
+
} | null>, null>;
|
|
22
|
+
export declare const InterfaceStateStruct: import("@metamask/superstruct").Struct<Record<string, string | boolean | {
|
|
23
|
+
name: string;
|
|
24
|
+
size: number;
|
|
25
|
+
contentType: string;
|
|
26
|
+
contents: string;
|
|
27
|
+
} | Record<string, string | boolean | {
|
|
28
|
+
name: string;
|
|
29
|
+
size: number;
|
|
30
|
+
contentType: string;
|
|
31
|
+
contents: string;
|
|
32
|
+
} | null> | null>, null>;
|
|
33
|
+
export declare type State = Infer<typeof StateStruct>;
|
|
11
34
|
export declare type FormState = Infer<typeof FormStateStruct>;
|
|
12
35
|
export declare type InterfaceState = Infer<typeof InterfaceStateStruct>;
|
|
13
36
|
export declare type ComponentOrElement = Component | JSXElement;
|
|
14
|
-
export declare const ComponentOrElementStruct: import("superstruct").Struct<{
|
|
37
|
+
export declare const ComponentOrElementStruct: import("@metamask/superstruct").Struct<{
|
|
15
38
|
value: string;
|
|
16
39
|
type: import("../ui").NodeType.Copyable;
|
|
17
40
|
sensitive?: boolean | undefined;
|
|
@@ -79,26 +102,11 @@ export declare const ComponentOrElementStruct: import("superstruct").Struct<{
|
|
|
79
102
|
variant?: "primary" | "secondary" | undefined;
|
|
80
103
|
buttonType?: "button" | "submit" | undefined;
|
|
81
104
|
})[];
|
|
82
|
-
} | import("../jsx").SnapElement<import("../jsx").ButtonProps, "Button"> | import("../jsx").SnapElement<{
|
|
83
|
-
name: string;
|
|
84
|
-
type?: "number" | "text" | "password" | undefined;
|
|
85
|
-
value?: string | undefined;
|
|
86
|
-
placeholder?: string | undefined;
|
|
87
|
-
}, "Input"> | import("../jsx").SnapElement<{
|
|
88
|
-
name: string;
|
|
89
|
-
value?: string | undefined;
|
|
90
|
-
children: import("../jsx").MaybeArray<import("../jsx").SnapElement<{
|
|
91
|
-
value: string;
|
|
92
|
-
children: string;
|
|
93
|
-
}, "Option">>;
|
|
94
|
-
}, "Dropdown"> | import("../jsx").SnapElement<{
|
|
95
|
-
children: import("../jsx").MaybeArray<import("../jsx").SnapElement<import("../jsx").ButtonProps, "Button"> | import("../jsx").SnapElement<import("../jsx").FieldProps, "Field">>;
|
|
96
|
-
name: string;
|
|
97
|
-
}, "Form"> | import("../jsx").SnapElement<import("../jsx").BoldProps, "Bold"> | import("../jsx").SnapElement<import("../jsx").ItalicProps, "Italic"> | import("../jsx").SnapElement<import("../jsx").AddressProps, "Address"> | import("../jsx").SnapElement<import("../jsx").BoxProps, "Box"> | import("../jsx").SnapElement<import("../jsx").CopyableProps, "Copyable"> | import("../jsx").SnapElement<Record<string, never>, "Divider"> | import("../jsx").SnapElement<{
|
|
105
|
+
} | import("../jsx").SnapElement<import("../jsx").ButtonProps, "Button"> | import("../jsx").SnapElement<import("../jsx").CheckboxProps, "Checkbox"> | import("../jsx").SnapElement<import("../jsx").FormProps, "Form"> | import("../jsx").SnapElement<import("../jsx").InputProps, "Input"> | import("../jsx").SnapElement<import("../jsx").DropdownProps, "Dropdown"> | import("../jsx").SnapElement<import("../jsx").FileInputProps, "FileInput"> | import("../jsx").SnapElement<import("../jsx").BoldProps, "Bold"> | import("../jsx").SnapElement<import("../jsx").ItalicProps, "Italic"> | import("../jsx").SnapElement<import("../jsx").AddressProps, "Address"> | import("../jsx").SnapElement<import("../jsx").BoxProps, "Box"> | import("../jsx").SnapElement<import("../jsx").CardProps, "Card"> | import("../jsx").SnapElement<import("../jsx").ContainerProps, "Container"> | import("../jsx").SnapElement<import("../jsx").CopyableProps, "Copyable"> | import("../jsx").SnapElement<Record<string, never>, "Divider"> | import("../jsx").SnapElement<{
|
|
98
106
|
children: import("../jsx").StringElement;
|
|
99
107
|
}, "Heading"> | import("../jsx").SnapElement<{
|
|
100
108
|
src: string;
|
|
101
109
|
alt?: string | undefined;
|
|
102
|
-
}, "Image"> | import("../jsx").SnapElement<import("../jsx").LinkProps, "Link"> | import("../jsx").SnapElement<import("../jsx").TextProps, "Text"> | import("../jsx").SnapElement<import("../jsx").RowProps, "Row"> | import("../jsx").SnapElement<Record<string, never>, "Spinner">, null>;
|
|
103
|
-
export declare const InterfaceContextStruct: import("superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
|
|
110
|
+
}, "Image"> | import("../jsx").SnapElement<import("../jsx").LinkProps, "Link"> | import("../jsx").SnapElement<import("../jsx").TextProps, "Text"> | import("../jsx").SnapElement<import("../jsx").RowProps, "Row"> | import("../jsx").SnapElement<Record<string, never>, "Spinner"> | import("../jsx").SnapElement<import("../jsx").TooltipProps, "Tooltip">, null>;
|
|
111
|
+
export declare const InterfaceContextStruct: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
|
|
104
112
|
export declare type InterfaceContext = Infer<typeof InterfaceContextStruct>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Json } from '@metamask/utils';
|
|
1
2
|
import type { ComponentOrElement } from '..';
|
|
2
3
|
import type { EnumToUnion } from '../../internals';
|
|
3
4
|
/**
|
|
@@ -13,6 +14,11 @@ export declare enum DialogType {
|
|
|
13
14
|
Confirmation = "confirmation",
|
|
14
15
|
Prompt = "prompt"
|
|
15
16
|
}
|
|
17
|
+
export declare type DefaultDialog = {
|
|
18
|
+
id: string;
|
|
19
|
+
} | {
|
|
20
|
+
content: ComponentOrElement;
|
|
21
|
+
};
|
|
16
22
|
/**
|
|
17
23
|
* An alert dialog.
|
|
18
24
|
*
|
|
@@ -68,7 +74,7 @@ export declare type PromptDialog = {
|
|
|
68
74
|
* @property placeholder - The placeholder text to display in the dialog. Only
|
|
69
75
|
* applicable for the `prompt` dialog.
|
|
70
76
|
*/
|
|
71
|
-
export declare type DialogParams = AlertDialog | ConfirmationDialog | PromptDialog;
|
|
77
|
+
export declare type DialogParams = AlertDialog | ConfirmationDialog | PromptDialog | DefaultDialog;
|
|
72
78
|
/**
|
|
73
79
|
* The result returned by the `snap_dialog` method.
|
|
74
80
|
*
|
|
@@ -78,4 +84,4 @@ export declare type DialogParams = AlertDialog | ConfirmationDialog | PromptDial
|
|
|
78
84
|
* - If the dialog is a `prompt`, the result is the value entered by
|
|
79
85
|
* the user.
|
|
80
86
|
*/
|
|
81
|
-
export declare type DialogResult = null | boolean | string;
|
|
87
|
+
export declare type DialogResult = null | boolean | string | Json;
|
|
@@ -16,6 +16,7 @@ import type { ManageAccountsParams, ManageAccountsResult } from './manage-accoun
|
|
|
16
16
|
import type { ManageStateParams, ManageStateResult } from './manage-state';
|
|
17
17
|
import type { NotifyParams, NotifyResult } from './notify';
|
|
18
18
|
import type { RequestSnapsParams, RequestSnapsResult } from './request-snaps';
|
|
19
|
+
import type { ResolveInterfaceParams, ResolveInterfaceResult } from './resolve-interface';
|
|
19
20
|
import type { UpdateInterfaceParams, UpdateInterfaceResult } from './update-interface';
|
|
20
21
|
/**
|
|
21
22
|
* The methods that are available to the Snap. Each method is a tuple of the
|
|
@@ -36,6 +37,7 @@ export declare type SnapMethods = {
|
|
|
36
37
|
snap_createInterface: [CreateInterfaceParams, CreateInterfaceResult];
|
|
37
38
|
snap_updateInterface: [UpdateInterfaceParams, UpdateInterfaceResult];
|
|
38
39
|
snap_getInterfaceState: [GetInterfaceStateParams, GetInterfaceStateResult];
|
|
40
|
+
snap_resolveInterface: [ResolveInterfaceParams, ResolveInterfaceResult];
|
|
39
41
|
wallet_getSnaps: [GetSnapsParams, GetSnapsResult];
|
|
40
42
|
wallet_invokeKeyring: [InvokeKeyringParams, InvokeKeyringResult];
|
|
41
43
|
wallet_invokeSnap: [InvokeSnapParams, InvokeSnapResult];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Json } from '@metamask/utils';
|
|
2
|
+
/**
|
|
3
|
+
* The request parameters for the `snap_resolveInterface` method.
|
|
4
|
+
*
|
|
5
|
+
* @property id - The interface id.
|
|
6
|
+
* @property value - The value to resolve the interface with.
|
|
7
|
+
*/
|
|
8
|
+
export declare type ResolveInterfaceParams = {
|
|
9
|
+
id: string;
|
|
10
|
+
value: Json;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The result returned by the `snap_resolveInterface` method.
|
|
14
|
+
*/
|
|
15
|
+
export declare type ResolveInterfaceResult = null;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { Infer } from 'superstruct';
|
|
1
|
+
import type { Infer } from '@metamask/superstruct';
|
|
2
2
|
import { NodeType } from '../nodes';
|
|
3
|
-
export declare const AddressStruct: import("superstruct").Struct<{
|
|
3
|
+
export declare const AddressStruct: import("@metamask/superstruct").Struct<{
|
|
4
4
|
value: `0x${string}`;
|
|
5
5
|
type: NodeType.Address;
|
|
6
6
|
}, {
|
|
7
|
-
type: import("superstruct").Struct<NodeType.Address, NodeType.Address>;
|
|
8
|
-
value: import("superstruct").Struct<`0x${string}`, null>;
|
|
7
|
+
type: import("@metamask/superstruct").Struct<NodeType.Address, NodeType.Address>;
|
|
8
|
+
value: import("@metamask/superstruct").Struct<`0x${string}`, null>;
|
|
9
9
|
}>;
|
|
10
10
|
/**
|
|
11
11
|
* A address node, that renders an EVM-like address and its icon.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Infer } from 'superstruct';
|
|
1
|
+
import type { Infer } from '@metamask/superstruct';
|
|
2
2
|
import { NodeType } from '../nodes';
|
|
3
3
|
export declare enum ButtonVariant {
|
|
4
4
|
Primary = "primary",
|
|
@@ -8,18 +8,18 @@ export declare enum ButtonType {
|
|
|
8
8
|
Button = "button",
|
|
9
9
|
Submit = "submit"
|
|
10
10
|
}
|
|
11
|
-
export declare const ButtonStruct: import("superstruct").Struct<{
|
|
11
|
+
export declare const ButtonStruct: import("@metamask/superstruct").Struct<{
|
|
12
12
|
value: string;
|
|
13
13
|
type: NodeType.Button;
|
|
14
14
|
name?: string | undefined;
|
|
15
15
|
variant?: "primary" | "secondary" | undefined;
|
|
16
16
|
buttonType?: "button" | "submit" | undefined;
|
|
17
17
|
}, {
|
|
18
|
-
type: import("superstruct").Struct<NodeType.Button, NodeType.Button>;
|
|
19
|
-
value: import("superstruct").Struct<string, null>;
|
|
20
|
-
variant: import("superstruct").Struct<"primary" | "secondary" | undefined, null>;
|
|
21
|
-
buttonType: import("superstruct").Struct<"button" | "submit" | undefined, null>;
|
|
22
|
-
name: import("superstruct").Struct<string | undefined, null>;
|
|
18
|
+
type: import("@metamask/superstruct").Struct<NodeType.Button, NodeType.Button>;
|
|
19
|
+
value: import("@metamask/superstruct").Struct<string, null>;
|
|
20
|
+
variant: import("@metamask/superstruct").Struct<"primary" | "secondary" | undefined, null>;
|
|
21
|
+
buttonType: import("@metamask/superstruct").Struct<"button" | "submit" | undefined, null>;
|
|
22
|
+
name: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
23
23
|
}>;
|
|
24
24
|
/**
|
|
25
25
|
* A button node, that renders either a primary or a secondary button.
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { Infer } from 'superstruct';
|
|
1
|
+
import type { Infer } from '@metamask/superstruct';
|
|
2
2
|
import { NodeType } from '../nodes';
|
|
3
|
-
export declare const CopyableStruct: import("superstruct").Struct<{
|
|
3
|
+
export declare const CopyableStruct: import("@metamask/superstruct").Struct<{
|
|
4
4
|
value: string;
|
|
5
5
|
type: NodeType.Copyable;
|
|
6
6
|
sensitive?: boolean | undefined;
|
|
7
7
|
}, {
|
|
8
|
-
type: import("superstruct").Struct<NodeType.Copyable, NodeType.Copyable>;
|
|
9
|
-
value: import("superstruct").Struct<string, null>;
|
|
10
|
-
sensitive: import("superstruct").Struct<boolean | undefined, null>;
|
|
8
|
+
type: import("@metamask/superstruct").Struct<NodeType.Copyable, NodeType.Copyable>;
|
|
9
|
+
value: import("@metamask/superstruct").Struct<string, null>;
|
|
10
|
+
sensitive: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
|
11
11
|
}>;
|
|
12
12
|
/**
|
|
13
13
|
* Text that can be copied to the clipboard. It can optionally be marked as
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Infer } from 'superstruct';
|
|
1
|
+
import type { Infer } from '@metamask/superstruct';
|
|
2
2
|
import { NodeType } from '../nodes';
|
|
3
|
-
export declare const DividerStruct: import("superstruct").Struct<{
|
|
3
|
+
export declare const DividerStruct: import("@metamask/superstruct").Struct<{
|
|
4
4
|
type: NodeType.Divider;
|
|
5
5
|
}, {
|
|
6
|
-
type: import("superstruct").Struct<NodeType.Divider, NodeType.Divider>;
|
|
6
|
+
type: import("@metamask/superstruct").Struct<NodeType.Divider, NodeType.Divider>;
|
|
7
7
|
}>;
|
|
8
8
|
/**
|
|
9
9
|
* A divider node, that renders a line between other nodes.
|