@metamask/snaps-sdk 6.1.1 → 6.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.
- package/CHANGELOG.md +8 -2
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -0
- package/dist/index.mjs.map +1 -1
- package/dist/jsx/index.js +70 -42
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +70 -42
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/jsx-dev-runtime.js +16 -0
- package/dist/jsx/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx/jsx-dev-runtime.mjs +16 -0
- package/dist/jsx/jsx-dev-runtime.mjs.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/errors.d.ts +1 -1
- package/dist/types/images.d.ts +1 -1
- package/dist/types/internals/error-wrappers.d.ts +1 -1
- package/dist/types/internals/helpers.d.ts +2 -2
- package/dist/types/internals/jsx.d.ts +3 -3
- package/dist/types/jsx/component.d.ts +9 -9
- package/dist/types/jsx/components/Address.d.ts +2 -2
- package/dist/types/jsx/components/Box.d.ts +2 -2
- package/dist/types/jsx/components/Card.d.ts +2 -2
- package/dist/types/jsx/components/Container.d.ts +2 -2
- package/dist/types/jsx/components/Copyable.d.ts +2 -2
- package/dist/types/jsx/components/Divider.d.ts +1 -1
- package/dist/types/jsx/components/Footer.d.ts +2 -2
- package/dist/types/jsx/components/Heading.d.ts +2 -2
- package/dist/types/jsx/components/Image.d.ts +2 -2
- package/dist/types/jsx/components/Link.d.ts +3 -3
- package/dist/types/jsx/components/Row.d.ts +3 -3
- package/dist/types/jsx/components/Spinner.d.ts +1 -1
- package/dist/types/jsx/components/Text.d.ts +3 -3
- package/dist/types/jsx/components/Tooltip.d.ts +3 -3
- package/dist/types/jsx/components/Value.d.ts +2 -2
- package/dist/types/jsx/components/form/Button.d.ts +2 -2
- package/dist/types/jsx/components/form/Checkbox.d.ts +2 -2
- package/dist/types/jsx/components/form/Dropdown.d.ts +2 -2
- package/dist/types/jsx/components/form/Field.d.ts +4 -3
- package/dist/types/jsx/components/form/FileInput.d.ts +2 -2
- package/dist/types/jsx/components/form/Form.d.ts +2 -2
- package/dist/types/jsx/components/form/Input.d.ts +2 -2
- package/dist/types/jsx/components/form/Option.d.ts +2 -2
- package/dist/types/jsx/components/form/Radio.d.ts +35 -0
- package/dist/types/jsx/components/form/RadioGroup.d.ts +29 -0
- package/dist/types/jsx/components/form/index.d.ts +5 -1
- package/dist/types/jsx/components/formatting/Bold.d.ts +3 -3
- package/dist/types/jsx/components/formatting/Italic.d.ts +3 -3
- package/dist/types/jsx/components/formatting/index.d.ts +1 -1
- package/dist/types/jsx/components/index.d.ts +1 -1
- package/dist/types/jsx/validation.d.ts +33 -4
- package/dist/types/types/caip.d.ts +2 -2
- package/dist/types/types/handlers/cronjob.d.ts +1 -1
- package/dist/types/types/handlers/home-page.d.ts +2 -2
- package/dist/types/types/handlers/keyring.d.ts +1 -1
- package/dist/types/types/handlers/lifecycle.d.ts +3 -3
- package/dist/types/types/handlers/name-lookup.d.ts +8 -8
- package/dist/types/types/handlers/rpc-request.d.ts +1 -1
- package/dist/types/types/handlers/signature.d.ts +8 -8
- package/dist/types/types/handlers/transaction.d.ts +5 -5
- package/dist/types/types/handlers/user-input.d.ts +7 -7
- package/dist/types/types/interface.d.ts +13 -6
- package/dist/types/types/methods/create-interface.d.ts +2 -2
- package/dist/types/types/methods/dialog.d.ts +6 -6
- package/dist/types/types/methods/get-bip32-entropy.d.ts +2 -2
- package/dist/types/types/methods/get-bip32-public-key.d.ts +2 -2
- package/dist/types/types/methods/get-bip44-entropy.d.ts +2 -2
- package/dist/types/types/methods/get-client-status.d.ts +2 -2
- package/dist/types/types/methods/get-entropy.d.ts +2 -2
- package/dist/types/types/methods/get-file.d.ts +2 -2
- package/dist/types/types/methods/get-interface-state.d.ts +2 -2
- package/dist/types/types/methods/get-locale.d.ts +2 -2
- package/dist/types/types/methods/get-preferences.d.ts +15 -0
- package/dist/types/types/methods/get-snaps.d.ts +2 -2
- package/dist/types/types/methods/index.d.ts +1 -0
- package/dist/types/types/methods/invoke-keyring.d.ts +2 -2
- package/dist/types/types/methods/invoke-snap.d.ts +2 -2
- package/dist/types/types/methods/manage-accounts.d.ts +2 -2
- package/dist/types/types/methods/manage-state.d.ts +5 -5
- package/dist/types/types/methods/methods.d.ts +4 -2
- package/dist/types/types/methods/notify.d.ts +2 -2
- package/dist/types/types/methods/request-snaps.d.ts +2 -2
- package/dist/types/types/methods/resolve-interface.d.ts +2 -2
- package/dist/types/types/methods/update-interface.d.ts +2 -2
- package/dist/types/types/permissions.d.ts +7 -7
- package/dist/types/types/provider.d.ts +3 -3
- package/dist/types/types/snap.d.ts +2 -2
- package/dist/types/ui/builder.d.ts +2 -2
- package/dist/types/ui/components/address.d.ts +1 -1
- package/dist/types/ui/components/button.d.ts +1 -1
- package/dist/types/ui/components/copyable.d.ts +1 -1
- package/dist/types/ui/components/divider.d.ts +1 -1
- package/dist/types/ui/components/form.d.ts +2 -2
- package/dist/types/ui/components/heading.d.ts +1 -1
- package/dist/types/ui/components/image.d.ts +1 -1
- package/dist/types/ui/components/input.d.ts +1 -1
- package/dist/types/ui/components/panel.d.ts +3 -3
- package/dist/types/ui/components/row.d.ts +1 -1
- package/dist/types/ui/components/spinner.d.ts +1 -1
- package/dist/types/ui/components/text.d.ts +1 -1
- package/dist/types/ui/nodes.d.ts +2 -2
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Struct } from '@metamask/superstruct';
|
|
2
2
|
import type { Describe } from '../internals';
|
|
3
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';
|
|
4
|
+
import type { AddressElement, BoldElement, BoxElement, ButtonElement, CheckboxElement, CardElement, CopyableElement, DividerElement, DropdownElement, OptionElement, RadioElement, RadioGroupElement, 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
|
*/
|
|
@@ -34,6 +34,14 @@ export declare const OptionStruct: Describe<OptionElement>;
|
|
|
34
34
|
* A struct for the {@link DropdownElement} type.
|
|
35
35
|
*/
|
|
36
36
|
export declare const DropdownStruct: Describe<DropdownElement>;
|
|
37
|
+
/**
|
|
38
|
+
* A struct for the {@link RadioElement} type.
|
|
39
|
+
*/
|
|
40
|
+
export declare const RadioStruct: Describe<RadioElement>;
|
|
41
|
+
/**
|
|
42
|
+
* A struct for the {@link RadioGroupElement} type.
|
|
43
|
+
*/
|
|
44
|
+
export declare const RadioGroupStruct: Describe<RadioGroupElement>;
|
|
37
45
|
/**
|
|
38
46
|
* A struct for the {@link FileInputElement} type.
|
|
39
47
|
*/
|
|
@@ -42,7 +50,14 @@ export declare const FileInputStruct: Describe<FileInputElement>;
|
|
|
42
50
|
* A union of the allowed children of the Field component.
|
|
43
51
|
* This is mainly used in the simulator for validation purposes.
|
|
44
52
|
*/
|
|
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<
|
|
53
|
+
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<{
|
|
54
|
+
name: string;
|
|
55
|
+
value?: string | undefined;
|
|
56
|
+
children: SnapsChildren<SnapElement<{
|
|
57
|
+
value: string;
|
|
58
|
+
children: string;
|
|
59
|
+
}, "Radio">>;
|
|
60
|
+
}, "RadioGroup"> | SnapElement<import("./components").FileInputProps, "FileInput">, null>;
|
|
46
61
|
/**
|
|
47
62
|
* A struct for the {@link FieldElement} type.
|
|
48
63
|
*/
|
|
@@ -153,7 +168,14 @@ export declare const SpinnerStruct: Describe<SpinnerElement>;
|
|
|
153
168
|
* This set includes all components, except components that need to be nested in
|
|
154
169
|
* another component (e.g., Field must be contained in a Form).
|
|
155
170
|
*/
|
|
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<
|
|
171
|
+
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<{
|
|
172
|
+
name: string;
|
|
173
|
+
value?: string | undefined;
|
|
174
|
+
children: SnapsChildren<SnapElement<{
|
|
175
|
+
value: string;
|
|
176
|
+
children: string;
|
|
177
|
+
}, "Radio">>;
|
|
178
|
+
}, "RadioGroup"> | 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<{
|
|
157
179
|
children: StringElement;
|
|
158
180
|
}, "Heading"> | SnapElement<{
|
|
159
181
|
src: string;
|
|
@@ -163,7 +185,14 @@ export declare const BoxChildStruct: Struct<SnapElement<import("./components").B
|
|
|
163
185
|
* For now, the allowed JSX elements at the root are the same as the allowed
|
|
164
186
|
* children of the Box component.
|
|
165
187
|
*/
|
|
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<
|
|
188
|
+
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<{
|
|
189
|
+
name: string;
|
|
190
|
+
value?: string | undefined;
|
|
191
|
+
children: SnapsChildren<SnapElement<{
|
|
192
|
+
value: string;
|
|
193
|
+
children: string;
|
|
194
|
+
}, "Radio">>;
|
|
195
|
+
}, "RadioGroup"> | 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<{
|
|
167
196
|
children: StringElement;
|
|
168
197
|
}, "Heading"> | SnapElement<{
|
|
169
198
|
src: string;
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @see https://chainagnostic.org/CAIPs/caip-2
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export type ChainId = `${string}:${string}`;
|
|
7
7
|
/**
|
|
8
8
|
* A CAIP-10 account ID, i.e., a chain ID and an account address.
|
|
9
9
|
*
|
|
10
10
|
* @see https://chainagnostic.org/CAIPs/caip-10
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export type AccountId = `${ChainId}:${string}`;
|
|
@@ -9,6 +9,6 @@ import type { JsonRpcParams, JsonRpcRequest } from '@metamask/utils';
|
|
|
9
9
|
* @param args.request - The JSON-RPC request sent to the snap. The parameters
|
|
10
10
|
* are defined by the Snap's manifest.
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export type OnCronjobHandler<Params extends JsonRpcParams = JsonRpcParams> = (args: {
|
|
13
13
|
request: JsonRpcRequest<Params>;
|
|
14
14
|
}) => Promise<unknown>;
|
|
@@ -8,14 +8,14 @@ import type { ComponentOrElement } from '..';
|
|
|
8
8
|
* @returns The content to display on the home page. See
|
|
9
9
|
* {@link OnHomePageResponse}.
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export type OnHomePageHandler = () => Promise<OnHomePageResponse>;
|
|
12
12
|
/**
|
|
13
13
|
* The content to display on the home page.
|
|
14
14
|
*
|
|
15
15
|
* @property content - A custom UI component, that will be shown in MetaMask.
|
|
16
16
|
* @property id - A custom UI interface ID, that will be shown in MetaMask.
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export type OnHomePageResponse = {
|
|
19
19
|
content: ComponentOrElement;
|
|
20
20
|
} | {
|
|
21
21
|
id: string;
|
|
@@ -14,7 +14,7 @@ import type { Json, JsonRpcParams, JsonRpcRequest } from '@metamask/utils';
|
|
|
14
14
|
* JSON-serializable value. In order to return an error, throw a `SnapError`
|
|
15
15
|
* instead.
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export type OnKeyringRequestHandler<Params extends JsonRpcParams = JsonRpcParams> = (args: {
|
|
18
18
|
origin: string;
|
|
19
19
|
request: JsonRpcRequest<Params>;
|
|
20
20
|
}) => Promise<Json>;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @param args - The request arguments.
|
|
9
9
|
* @param args.origin - The origin that triggered the lifecycle event hook.
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export type LifecycleEventHandler = (args: {
|
|
12
12
|
origin: string;
|
|
13
13
|
}) => Promise<unknown>;
|
|
14
14
|
/**
|
|
@@ -22,7 +22,7 @@ export declare type LifecycleEventHandler = (args: {
|
|
|
22
22
|
* @param args - The request arguments.
|
|
23
23
|
* @param args.origin - The origin that triggered the lifecycle event hook.
|
|
24
24
|
*/
|
|
25
|
-
export
|
|
25
|
+
export type OnInstallHandler = LifecycleEventHandler;
|
|
26
26
|
/**
|
|
27
27
|
* The `onUpdate` handler. This is called after the Snap is updated.
|
|
28
28
|
*
|
|
@@ -34,4 +34,4 @@ export declare type OnInstallHandler = LifecycleEventHandler;
|
|
|
34
34
|
* @param args - The request arguments.
|
|
35
35
|
* @param args.origin - The origin that triggered the lifecycle event hook.
|
|
36
36
|
*/
|
|
37
|
-
export
|
|
37
|
+
export type OnUpdateHandler = LifecycleEventHandler;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NonEmptyArray } from '@metamask/utils';
|
|
2
2
|
import type { ChainId } from '../caip';
|
|
3
|
-
|
|
3
|
+
type BaseOnNameLookupArgs = {
|
|
4
4
|
chainId: ChainId;
|
|
5
5
|
};
|
|
6
6
|
/**
|
|
@@ -8,7 +8,7 @@ declare type BaseOnNameLookupArgs = {
|
|
|
8
8
|
*
|
|
9
9
|
* @property domain - The human-readable domain name that is to be resolved.
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export type DomainLookupArgs = BaseOnNameLookupArgs & {
|
|
12
12
|
domain: string;
|
|
13
13
|
address?: never;
|
|
14
14
|
};
|
|
@@ -17,7 +17,7 @@ export declare type DomainLookupArgs = BaseOnNameLookupArgs & {
|
|
|
17
17
|
*
|
|
18
18
|
* @property address - The address that is to be resolved.
|
|
19
19
|
*/
|
|
20
|
-
export
|
|
20
|
+
export type AddressLookupArgs = BaseOnNameLookupArgs & {
|
|
21
21
|
address: string;
|
|
22
22
|
domain?: never;
|
|
23
23
|
};
|
|
@@ -27,7 +27,7 @@ export declare type AddressLookupArgs = BaseOnNameLookupArgs & {
|
|
|
27
27
|
* @property protocol - The protocol that resolved the domain.
|
|
28
28
|
* @property resolvedAddress - The resolved address.
|
|
29
29
|
*/
|
|
30
|
-
export
|
|
30
|
+
export type AddressResolution = {
|
|
31
31
|
protocol: string;
|
|
32
32
|
resolvedAddress: string;
|
|
33
33
|
domainName: string;
|
|
@@ -38,7 +38,7 @@ export declare type AddressResolution = {
|
|
|
38
38
|
* @property protocol - The protocol that resolved the address.
|
|
39
39
|
* @property resolvedDomain - The resolved domain.
|
|
40
40
|
*/
|
|
41
|
-
export
|
|
41
|
+
export type DomainResolution = {
|
|
42
42
|
protocol: string;
|
|
43
43
|
resolvedDomain: string;
|
|
44
44
|
};
|
|
@@ -47,7 +47,7 @@ export declare type DomainResolution = {
|
|
|
47
47
|
*
|
|
48
48
|
* @property resolvedAddress - The resolved address.
|
|
49
49
|
*/
|
|
50
|
-
export
|
|
50
|
+
export type DomainLookupResult = {
|
|
51
51
|
resolvedAddresses: NonEmptyArray<AddressResolution>;
|
|
52
52
|
resolvedDomains?: never;
|
|
53
53
|
};
|
|
@@ -56,7 +56,7 @@ export declare type DomainLookupResult = {
|
|
|
56
56
|
*
|
|
57
57
|
* @property resolvedDomain - The resolved domain name.
|
|
58
58
|
*/
|
|
59
|
-
export
|
|
59
|
+
export type AddressLookupResult = {
|
|
60
60
|
resolvedDomains: NonEmptyArray<DomainResolution>;
|
|
61
61
|
resolvedAddresses?: never;
|
|
62
62
|
};
|
|
@@ -77,5 +77,5 @@ export declare type AddressLookupResult = {
|
|
|
77
77
|
* {@link AddressLookupResult}, {@link DomainLookupResult}, or `null` if the
|
|
78
78
|
* address or domain could not be resolved.
|
|
79
79
|
*/
|
|
80
|
-
export
|
|
80
|
+
export type OnNameLookupHandler = (args: AddressLookupArgs | DomainLookupArgs) => Promise<AddressLookupResult | DomainLookupResult | null>;
|
|
81
81
|
export {};
|
|
@@ -15,7 +15,7 @@ import type { Json, JsonRpcParams, JsonRpcRequest } from '@metamask/utils';
|
|
|
15
15
|
* JSON-serializable value. In order to return an error, throw a `SnapError`
|
|
16
16
|
* instead.
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export type OnRpcRequestHandler<Params extends JsonRpcParams = JsonRpcParams> = (args: {
|
|
19
19
|
origin: string;
|
|
20
20
|
request: JsonRpcRequest<Params>;
|
|
21
21
|
}) => Promise<Json>;
|
|
@@ -8,7 +8,7 @@ import type { SeverityLevel } from './transaction';
|
|
|
8
8
|
* @property data - The data (hex string) that is being signed.
|
|
9
9
|
* @property signatureMethod - The signature method, which in this case is eth_sign
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export type EthSignature = {
|
|
12
12
|
from: string;
|
|
13
13
|
data: string;
|
|
14
14
|
signatureMethod: 'eth_sign';
|
|
@@ -20,7 +20,7 @@ export declare type EthSignature = {
|
|
|
20
20
|
* @property data - The data (hex string) that is being signed.
|
|
21
21
|
* @property signatureMethod - The signature method, which in this case is personal_sign
|
|
22
22
|
*/
|
|
23
|
-
export
|
|
23
|
+
export type PersonalSignature = {
|
|
24
24
|
from: string;
|
|
25
25
|
data: string;
|
|
26
26
|
signatureMethod: 'personal_sign';
|
|
@@ -32,7 +32,7 @@ export declare type PersonalSignature = {
|
|
|
32
32
|
* @property data - The data that is being signed.
|
|
33
33
|
* @property signatureMethod - The signature method, which in this case is eth_signTypedData
|
|
34
34
|
*/
|
|
35
|
-
export
|
|
35
|
+
export type SignTypedDataSignature = {
|
|
36
36
|
from: string;
|
|
37
37
|
data: Record<string, any>[];
|
|
38
38
|
signatureMethod: 'eth_signTypedData';
|
|
@@ -44,7 +44,7 @@ export declare type SignTypedDataSignature = {
|
|
|
44
44
|
* @property data - The data that is being signed.
|
|
45
45
|
* @property signatureMethod - The signature method, which in this case is eth_signTypedData_v3
|
|
46
46
|
*/
|
|
47
|
-
export
|
|
47
|
+
export type SignTypedDataV3Signature = {
|
|
48
48
|
from: string;
|
|
49
49
|
data: Record<string, any>;
|
|
50
50
|
signatureMethod: 'eth_signTypedData_v3';
|
|
@@ -56,7 +56,7 @@ export declare type SignTypedDataV3Signature = {
|
|
|
56
56
|
* @property data - The data that is being signed.
|
|
57
57
|
* @property signatureMethod - The signature method, which in this case is eth_signTypedData_v4
|
|
58
58
|
*/
|
|
59
|
-
export
|
|
59
|
+
export type SignTypedDataV4Signature = {
|
|
60
60
|
from: string;
|
|
61
61
|
data: Record<string, any>;
|
|
62
62
|
signatureMethod: 'eth_signTypedData_v4';
|
|
@@ -70,7 +70,7 @@ export declare type SignTypedDataV4Signature = {
|
|
|
70
70
|
* @see SignTypedDataV3Signature
|
|
71
71
|
* @see SignTypedDataV4Signature
|
|
72
72
|
*/
|
|
73
|
-
export
|
|
73
|
+
export type Signature = EthSignature | PersonalSignature | SignTypedDataSignature | SignTypedDataV3Signature | SignTypedDataV4Signature;
|
|
74
74
|
/**
|
|
75
75
|
* The `onSignature` handler. This is called whenever a signature is
|
|
76
76
|
* submitted to the snap. It can return insights about the signature, which
|
|
@@ -90,7 +90,7 @@ export declare type Signature = EthSignature | PersonalSignature | SignTypedData
|
|
|
90
90
|
* {@link OnSignatureResponse}. Can also return `null` if no insights are
|
|
91
91
|
* available.
|
|
92
92
|
*/
|
|
93
|
-
export
|
|
93
|
+
export type OnSignatureHandler = (args: {
|
|
94
94
|
signature: Signature;
|
|
95
95
|
signatureOrigin?: string;
|
|
96
96
|
}) => Promise<OnSignatureResponse | null>;
|
|
@@ -102,7 +102,7 @@ export declare type OnSignatureHandler = (args: {
|
|
|
102
102
|
* @property severity - The severity level of the content. Currently only one
|
|
103
103
|
* level is supported: `critical`.
|
|
104
104
|
*/
|
|
105
|
-
export
|
|
105
|
+
export type OnSignatureResponse = {
|
|
106
106
|
content: Component;
|
|
107
107
|
severity?: EnumToUnion<SeverityLevel>;
|
|
108
108
|
} | {
|
|
@@ -27,7 +27,7 @@ export declare enum SeverityLevel {
|
|
|
27
27
|
* @property estimateUsed - The gas price used for the transaction.
|
|
28
28
|
* @see https://eips.ethereum.org/EIPS/eip-1559
|
|
29
29
|
*/
|
|
30
|
-
export
|
|
30
|
+
export type EIP1559Transaction = {
|
|
31
31
|
from: string;
|
|
32
32
|
to: string;
|
|
33
33
|
nonce: string;
|
|
@@ -52,7 +52,7 @@ export declare type EIP1559Transaction = {
|
|
|
52
52
|
* @property estimateSuggested - The suggested gas price for the transaction.
|
|
53
53
|
* @property estimateUsed - The gas price used for the transaction.
|
|
54
54
|
*/
|
|
55
|
-
export
|
|
55
|
+
export type LegacyTransaction = {
|
|
56
56
|
from: string;
|
|
57
57
|
to: string;
|
|
58
58
|
nonce: string;
|
|
@@ -70,7 +70,7 @@ export declare type LegacyTransaction = {
|
|
|
70
70
|
* @see EIP1559Transaction
|
|
71
71
|
* @see LegacyTransaction
|
|
72
72
|
*/
|
|
73
|
-
export
|
|
73
|
+
export type Transaction = EIP1559Transaction | LegacyTransaction;
|
|
74
74
|
/**
|
|
75
75
|
* The `onTransaction` handler. This is called whenever a transaction is
|
|
76
76
|
* submitted to the snap. It can return insights about the transaction, which
|
|
@@ -92,7 +92,7 @@ export declare type Transaction = EIP1559Transaction | LegacyTransaction;
|
|
|
92
92
|
* {@link OnTransactionResponse}. Can also return `null` if no insights are
|
|
93
93
|
* available.
|
|
94
94
|
*/
|
|
95
|
-
export
|
|
95
|
+
export type OnTransactionHandler = (args: {
|
|
96
96
|
transaction: Transaction;
|
|
97
97
|
chainId: ChainId;
|
|
98
98
|
transactionOrigin?: string;
|
|
@@ -105,7 +105,7 @@ export declare type OnTransactionHandler = (args: {
|
|
|
105
105
|
* @property severity - The severity level of the content. Currently only one
|
|
106
106
|
* level is supported: `critical`.
|
|
107
107
|
*/
|
|
108
|
-
export
|
|
108
|
+
export type OnTransactionResponse = {
|
|
109
109
|
content: ComponentOrElement;
|
|
110
110
|
severity?: EnumToUnion<SeverityLevel>;
|
|
111
111
|
} | {
|
|
@@ -37,7 +37,7 @@ export declare const ButtonClickEventStruct: import("@metamask/superstruct").Str
|
|
|
37
37
|
* the different types. This is always `ButtonClickEvent`.
|
|
38
38
|
* @property name - The optional component name that fired the event.
|
|
39
39
|
*/
|
|
40
|
-
export
|
|
40
|
+
export type ButtonClickEvent = Infer<typeof ButtonClickEventStruct>;
|
|
41
41
|
export declare const FileStruct: import("@metamask/superstruct").Struct<{
|
|
42
42
|
name: string;
|
|
43
43
|
size: number;
|
|
@@ -58,7 +58,7 @@ export declare const FileStruct: import("@metamask/superstruct").Struct<{
|
|
|
58
58
|
* @property contentType - The content type of the file.
|
|
59
59
|
* @property contents - The base64 encoded contents of the file.
|
|
60
60
|
*/
|
|
61
|
-
export
|
|
61
|
+
export type File = Infer<typeof FileStruct>;
|
|
62
62
|
export declare const FormSubmitEventStruct: import("@metamask/superstruct").Struct<{
|
|
63
63
|
value: Record<string, string | boolean | {
|
|
64
64
|
name: string;
|
|
@@ -91,7 +91,7 @@ export declare const FormSubmitEventStruct: import("@metamask/superstruct").Stru
|
|
|
91
91
|
* name, size, content type, and the base64 encoded contents of the file. See
|
|
92
92
|
* {@link File}.
|
|
93
93
|
*/
|
|
94
|
-
export
|
|
94
|
+
export type FormSubmitEvent = Infer<typeof FormSubmitEventStruct>;
|
|
95
95
|
export declare const InputChangeEventStruct: import("@metamask/superstruct").Struct<{
|
|
96
96
|
value: string | boolean;
|
|
97
97
|
type: UserInputEventType.InputChangeEvent;
|
|
@@ -109,7 +109,7 @@ export declare const InputChangeEventStruct: import("@metamask/superstruct").Str
|
|
|
109
109
|
* @property name - The name of the input field that changed.
|
|
110
110
|
* @property value - The new value of the input field.
|
|
111
111
|
*/
|
|
112
|
-
export
|
|
112
|
+
export type InputChangeEvent = Infer<typeof InputChangeEventStruct>;
|
|
113
113
|
export declare const FileUploadEventStruct: import("@metamask/superstruct").Struct<{
|
|
114
114
|
type: UserInputEventType.FileUploadEvent;
|
|
115
115
|
name: string;
|
|
@@ -144,7 +144,7 @@ export declare const FileUploadEventStruct: import("@metamask/superstruct").Stru
|
|
|
144
144
|
* content type, and the base64 encoded contents of the file.
|
|
145
145
|
* @see File
|
|
146
146
|
*/
|
|
147
|
-
export
|
|
147
|
+
export type FileUploadEvent = Infer<typeof FileUploadEventStruct>;
|
|
148
148
|
export declare const UserInputEventStruct: import("@metamask/superstruct").Struct<{
|
|
149
149
|
type: UserInputEventType.ButtonClickEvent;
|
|
150
150
|
name?: string | undefined;
|
|
@@ -180,7 +180,7 @@ export declare const UserInputEventStruct: import("@metamask/superstruct").Struc
|
|
|
180
180
|
* @property value - The value associated with the event. Only available when an
|
|
181
181
|
* {@link UserInputEventType.FormSubmitEvent} is fired. It contains the form values submitted.
|
|
182
182
|
*/
|
|
183
|
-
export
|
|
183
|
+
export type UserInputEvent = ButtonClickEvent | FormSubmitEvent | InputChangeEvent | FileUploadEvent;
|
|
184
184
|
/**
|
|
185
185
|
* The `onUserInput` handler. This is called when an user input event is fired in the UI.
|
|
186
186
|
*
|
|
@@ -188,7 +188,7 @@ export declare type UserInputEvent = ButtonClickEvent | FormSubmitEvent | InputC
|
|
|
188
188
|
* @param args.id - The user interface id.
|
|
189
189
|
* @param args.event - The {@link UserInputEvent} object, containing the data about the fired event.
|
|
190
190
|
*/
|
|
191
|
-
export
|
|
191
|
+
export type OnUserInputHandler = (args: {
|
|
192
192
|
id: string;
|
|
193
193
|
event: UserInputEvent;
|
|
194
194
|
context: InterfaceContext | null;
|
|
@@ -30,10 +30,10 @@ export declare const InterfaceStateStruct: import("@metamask/superstruct").Struc
|
|
|
30
30
|
contentType: string;
|
|
31
31
|
contents: string;
|
|
32
32
|
} | null> | null>, null>;
|
|
33
|
-
export
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export
|
|
33
|
+
export type State = Infer<typeof StateStruct>;
|
|
34
|
+
export type FormState = Infer<typeof FormStateStruct>;
|
|
35
|
+
export type InterfaceState = Infer<typeof InterfaceStateStruct>;
|
|
36
|
+
export type ComponentOrElement = Component | JSXElement;
|
|
37
37
|
export declare const ComponentOrElementStruct: import("@metamask/superstruct").Struct<{
|
|
38
38
|
value: string;
|
|
39
39
|
type: import("../ui").NodeType.Copyable;
|
|
@@ -102,11 +102,18 @@ export declare const ComponentOrElementStruct: import("@metamask/superstruct").S
|
|
|
102
102
|
variant?: "primary" | "secondary" | undefined;
|
|
103
103
|
buttonType?: "button" | "submit" | undefined;
|
|
104
104
|
})[];
|
|
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<
|
|
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<{
|
|
106
|
+
name: string;
|
|
107
|
+
value?: string | undefined;
|
|
108
|
+
children: import("../jsx").SnapsChildren<import("../jsx").SnapElement<{
|
|
109
|
+
value: string;
|
|
110
|
+
children: string;
|
|
111
|
+
}, "Radio">>;
|
|
112
|
+
}, "RadioGroup"> | 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<{
|
|
106
113
|
children: import("../jsx").StringElement;
|
|
107
114
|
}, "Heading"> | import("../jsx").SnapElement<{
|
|
108
115
|
src: string;
|
|
109
116
|
alt?: string | undefined;
|
|
110
117
|
}, "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
118
|
export declare const InterfaceContextStruct: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
|
|
112
|
-
export
|
|
119
|
+
export type InterfaceContext = Infer<typeof InterfaceContextStruct>;
|
|
@@ -4,11 +4,11 @@ import type { ComponentOrElement, InterfaceContext } from '..';
|
|
|
4
4
|
*
|
|
5
5
|
* @property ui - The components to display in the interface.
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type CreateInterfaceParams = {
|
|
8
8
|
ui: ComponentOrElement;
|
|
9
9
|
context?: InterfaceContext;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
12
|
* The result returned by the `snap_createInterface` method, which is the id of the created interface.
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export type CreateInterfaceResult = string;
|
|
@@ -14,7 +14,7 @@ export declare enum DialogType {
|
|
|
14
14
|
Confirmation = "confirmation",
|
|
15
15
|
Prompt = "prompt"
|
|
16
16
|
}
|
|
17
|
-
export
|
|
17
|
+
export type DefaultDialog = {
|
|
18
18
|
id: string;
|
|
19
19
|
} | {
|
|
20
20
|
content: ComponentOrElement;
|
|
@@ -26,7 +26,7 @@ export declare type DefaultDialog = {
|
|
|
26
26
|
* @property content - The content to display in the dialog.
|
|
27
27
|
* @property id - The Snap interface ID.
|
|
28
28
|
*/
|
|
29
|
-
export
|
|
29
|
+
export type AlertDialog = {
|
|
30
30
|
type: EnumToUnion<DialogType.Alert>;
|
|
31
31
|
content: ComponentOrElement;
|
|
32
32
|
} | {
|
|
@@ -40,7 +40,7 @@ export declare type AlertDialog = {
|
|
|
40
40
|
* @property content - The content to display in the dialog.
|
|
41
41
|
* @property id - The Snap interface ID.
|
|
42
42
|
*/
|
|
43
|
-
export
|
|
43
|
+
export type ConfirmationDialog = {
|
|
44
44
|
type: EnumToUnion<DialogType.Confirmation>;
|
|
45
45
|
content: ComponentOrElement;
|
|
46
46
|
} | {
|
|
@@ -56,7 +56,7 @@ export declare type ConfirmationDialog = {
|
|
|
56
56
|
* @property placeholder - An optional placeholder text to display in the text
|
|
57
57
|
* input.
|
|
58
58
|
*/
|
|
59
|
-
export
|
|
59
|
+
export type PromptDialog = {
|
|
60
60
|
type: EnumToUnion<DialogType.Prompt>;
|
|
61
61
|
content: ComponentOrElement;
|
|
62
62
|
placeholder?: string;
|
|
@@ -74,7 +74,7 @@ export declare type PromptDialog = {
|
|
|
74
74
|
* @property placeholder - The placeholder text to display in the dialog. Only
|
|
75
75
|
* applicable for the `prompt` dialog.
|
|
76
76
|
*/
|
|
77
|
-
export
|
|
77
|
+
export type DialogParams = AlertDialog | ConfirmationDialog | PromptDialog | DefaultDialog;
|
|
78
78
|
/**
|
|
79
79
|
* The result returned by the `snap_dialog` method.
|
|
80
80
|
*
|
|
@@ -84,4 +84,4 @@ export declare type DialogParams = AlertDialog | ConfirmationDialog | PromptDial
|
|
|
84
84
|
* - If the dialog is a `prompt`, the result is the value entered by
|
|
85
85
|
* the user.
|
|
86
86
|
*/
|
|
87
|
-
export
|
|
87
|
+
export type DialogResult = null | boolean | string | Json;
|
|
@@ -6,10 +6,10 @@ import type { Bip32Entropy } from '../permissions';
|
|
|
6
6
|
* @property path - The BIP-32 path to derive the entropy from.
|
|
7
7
|
* @property curve - The curve to use when deriving the entropy.
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export type GetBip32EntropyParams = Bip32Entropy;
|
|
10
10
|
/**
|
|
11
11
|
* The result returned by the `snap_getBip32Entropy` method.
|
|
12
12
|
*
|
|
13
13
|
* @see https://github.com/MetaMask/key-tree#usage
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export type GetBip32EntropyResult = JsonSLIP10Node;
|
|
@@ -7,7 +7,7 @@ import type { Bip32Entropy } from '../permissions';
|
|
|
7
7
|
* @property compressed - Whether to return the compressed public key. Defaults
|
|
8
8
|
* to `false`.
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export type GetBip32PublicKeyParams = Bip32Entropy & {
|
|
11
11
|
compressed?: boolean;
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
@@ -16,4 +16,4 @@ export declare type GetBip32PublicKeyParams = Bip32Entropy & {
|
|
|
16
16
|
* It is the public key in hexadecimal format, in either compressed or
|
|
17
17
|
* uncompressed format, depending on the `compressed` parameter.
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
19
|
+
export type GetBip32PublicKeyResult = string;
|
|
@@ -5,10 +5,10 @@ import type { Bip44Entropy } from '../permissions';
|
|
|
5
5
|
*
|
|
6
6
|
* @property coinType - The BIP-44 coin type to derive the entropy from.
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export type GetBip44EntropyParams = Bip44Entropy;
|
|
9
9
|
/**
|
|
10
10
|
* The result returned by the `snap_getBip44Entropy` method.
|
|
11
11
|
*
|
|
12
12
|
* @see https://github.com/MetaMask/key-tree#usage
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export type GetBip44EntropyResult = JsonBIP44CoinTypeNode;
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This method does not accept any parameters.
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export type GetClientStatusParams = never;
|
|
7
7
|
/**
|
|
8
8
|
* The result returned by the `snap_getClientStatus` method.
|
|
9
9
|
*
|
|
10
10
|
* It returns an object containing useful information about the client.
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export type GetClientStatusResult = {
|
|
13
13
|
locked: boolean;
|
|
14
14
|
};
|
|
@@ -6,11 +6,11 @@ import type { Hex } from '@metamask/utils';
|
|
|
6
6
|
* backwards compatibility. As of now, only version 1 is supported.
|
|
7
7
|
* @property salt - The optional salt to use when deriving the entropy.
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export type GetEntropyParams = {
|
|
10
10
|
version: 1;
|
|
11
11
|
salt?: string;
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
14
|
* The result returned by the `snap_getEntropy` method.
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export type GetEntropyResult = Hex;
|
|
@@ -13,11 +13,11 @@ export declare enum AuxiliaryFileEncoding {
|
|
|
13
13
|
* @property path - The path to the file to retrieve.
|
|
14
14
|
* @property encoding - The encoding to use when retrieving the file.
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export type GetFileParams = {
|
|
17
17
|
path: string;
|
|
18
18
|
encoding?: EnumToUnion<AuxiliaryFileEncoding>;
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
21
|
* The result returned by the `snap_getFile` method.
|
|
22
22
|
*/
|
|
23
|
-
export
|
|
23
|
+
export type GetFileResult = string;
|
|
@@ -4,10 +4,10 @@ import type { InterfaceState } from '../interface';
|
|
|
4
4
|
*
|
|
5
5
|
* @property id - The interface id.
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type GetInterfaceStateParams = {
|
|
8
8
|
id: string;
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
11
11
|
* The result returned by the `snap_getInterfaceState` method, which is the state of the interface.
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export type GetInterfaceStateResult = InterfaceState;
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This method does not accept any parameters.
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export type GetLocaleParams = never;
|
|
7
7
|
/**
|
|
8
8
|
* The result returned by the `snap_getLocale` method.
|
|
9
9
|
*
|
|
10
10
|
* It is the locale of the user's MetaMask extension.
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export type GetLocaleResult = string;
|