@metamask/snaps-utils 4.0.1 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -1
- package/dist/cjs/auxiliary-files.js +3 -3
- package/dist/cjs/auxiliary-files.js.map +1 -1
- package/dist/cjs/base64.js +44 -0
- package/dist/cjs/base64.js.map +1 -0
- package/dist/cjs/bytes.js +23 -0
- package/dist/cjs/bytes.js.map +1 -0
- package/dist/cjs/checksum.js +2 -14
- package/dist/cjs/checksum.js.map +1 -1
- package/dist/cjs/cronjob.js +6 -7
- package/dist/cjs/cronjob.js.map +1 -1
- package/dist/cjs/index.browser.js +2 -1
- package/dist/cjs/index.browser.js.map +1 -1
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/manifest/manifest.js +4 -3
- package/dist/cjs/manifest/manifest.js.map +1 -1
- package/dist/cjs/structs.js +0 -22
- package/dist/cjs/structs.js.map +1 -1
- package/dist/cjs/virtual-file/VirtualFile.js +1 -0
- package/dist/cjs/virtual-file/VirtualFile.js.map +1 -1
- package/dist/esm/auxiliary-files.js +3 -3
- package/dist/esm/auxiliary-files.js.map +1 -1
- package/dist/esm/base64.js +36 -0
- package/dist/esm/base64.js.map +1 -0
- package/dist/esm/bytes.js +18 -0
- package/dist/esm/bytes.js.map +1 -0
- package/dist/esm/checksum.js +3 -17
- package/dist/esm/checksum.js.map +1 -1
- package/dist/esm/cronjob.js +8 -9
- package/dist/esm/cronjob.js.map +1 -1
- package/dist/esm/index.browser.js +2 -1
- package/dist/esm/index.browser.js.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/manifest/manifest.js +5 -3
- package/dist/esm/manifest/manifest.js.map +1 -1
- package/dist/esm/structs.js +1 -48
- package/dist/esm/structs.js.map +1 -1
- package/dist/esm/virtual-file/VirtualFile.js +1 -0
- package/dist/esm/virtual-file/VirtualFile.js.map +1 -1
- package/dist/types/auxiliary-files.d.ts +1 -1
- package/dist/types/base64.d.ts +15 -0
- package/dist/types/bytes.d.ts +8 -0
- package/dist/types/checksum.d.ts +1 -8
- package/dist/types/cronjob.d.ts +15 -15
- package/dist/types/handlers.d.ts +72 -0
- package/dist/types/index.browser.d.ts +2 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/localization.d.ts +1 -1
- package/dist/types/manifest/manifest.d.ts +3 -1
- package/dist/types/manifest/validation.d.ts +17 -17
- package/dist/types/structs.d.ts +2 -40
- package/package.json +6 -6
- package/dist/cjs/enum.js +0 -16
- package/dist/cjs/enum.js.map +0 -1
- package/dist/esm/enum.js +0 -12
- package/dist/esm/enum.js.map +0 -1
- package/dist/types/enum.d.ts +0 -10
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { VirtualFile } from './virtual-file';
|
|
2
|
+
/**
|
|
3
|
+
* Provides fast, asynchronous base64 encoding.
|
|
4
|
+
*
|
|
5
|
+
* @param input - The input value, assumed to be coercable to bytes.
|
|
6
|
+
* @returns A base64 string.
|
|
7
|
+
*/
|
|
8
|
+
export declare function encodeBase64(input: Uint8Array | VirtualFile | string): Promise<unknown>;
|
|
9
|
+
/**
|
|
10
|
+
* Provides fast, asynchronous base64 decoding.
|
|
11
|
+
*
|
|
12
|
+
* @param base64 - A base64 string.
|
|
13
|
+
* @returns A Uint8Array of bytes.
|
|
14
|
+
*/
|
|
15
|
+
export declare function decodeBase64(base64: string): Promise<Uint8Array>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { VirtualFile } from './virtual-file';
|
|
2
|
+
/**
|
|
3
|
+
* Convert a bytes-like input value to a Uint8Array.
|
|
4
|
+
*
|
|
5
|
+
* @param bytes - A bytes-like value.
|
|
6
|
+
* @returns The input value converted to a Uint8Array if necessary.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getBytes(bytes: VirtualFile | Uint8Array | string): Uint8Array;
|
package/dist/types/checksum.d.ts
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import { VirtualFile } from './virtual-file/VirtualFile';
|
|
2
|
-
/**
|
|
3
|
-
* Convert an input value to a Uint8Array for use in a checksum.
|
|
4
|
-
*
|
|
5
|
-
* @param bytes - A value to use for a checksum calculation.
|
|
6
|
-
* @returns The input value converted to a Uint8Array if necessary.
|
|
7
|
-
*/
|
|
8
|
-
export declare function getChecksumBytes(bytes: VirtualFile | Uint8Array | string): Uint8Array;
|
|
1
|
+
import type { VirtualFile } from './virtual-file/VirtualFile';
|
|
9
2
|
/**
|
|
10
3
|
* Calculates checksum for a single byte array.
|
|
11
4
|
*
|
package/dist/types/cronjob.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Infer } from 'superstruct';
|
|
2
2
|
export declare const CronjobRpcRequestStruct: import("superstruct").Struct<{
|
|
3
3
|
method: string;
|
|
4
|
-
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
5
4
|
id?: string | number | null | undefined;
|
|
6
5
|
jsonrpc?: "2.0" | undefined;
|
|
6
|
+
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
7
7
|
}, {
|
|
8
|
-
|
|
8
|
+
jsonrpc: import("superstruct").Struct<"2.0" | undefined, "2.0">;
|
|
9
|
+
id: import("superstruct").Struct<string | number | null | undefined, null>;
|
|
9
10
|
method: import("superstruct").Struct<string, null>;
|
|
10
|
-
|
|
11
|
-
jsonrpc: import("superstruct").Struct<"2.0" | undefined, unknown>;
|
|
11
|
+
params: import("superstruct").Struct<Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined, null>;
|
|
12
12
|
}>;
|
|
13
13
|
export declare type CronjobRpcRequest = Infer<typeof CronjobRpcRequestStruct>;
|
|
14
14
|
export declare const CronExpressionStruct: import("superstruct").Struct<string, null>;
|
|
@@ -23,23 +23,23 @@ export declare function parseCronExpression(expression: string | object): import
|
|
|
23
23
|
export declare const CronjobSpecificationStruct: import("superstruct").Struct<{
|
|
24
24
|
request: {
|
|
25
25
|
method: string;
|
|
26
|
-
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
27
26
|
id?: string | number | null | undefined;
|
|
28
27
|
jsonrpc?: "2.0" | undefined;
|
|
28
|
+
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
29
29
|
};
|
|
30
30
|
expression: string;
|
|
31
31
|
}, {
|
|
32
32
|
expression: import("superstruct").Struct<string, null>;
|
|
33
33
|
request: import("superstruct").Struct<{
|
|
34
34
|
method: string;
|
|
35
|
-
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
36
35
|
id?: string | number | null | undefined;
|
|
37
36
|
jsonrpc?: "2.0" | undefined;
|
|
37
|
+
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
38
38
|
}, {
|
|
39
|
-
|
|
39
|
+
jsonrpc: import("superstruct").Struct<"2.0" | undefined, "2.0">;
|
|
40
|
+
id: import("superstruct").Struct<string | number | null | undefined, null>;
|
|
40
41
|
method: import("superstruct").Struct<string, null>;
|
|
41
|
-
|
|
42
|
-
jsonrpc: import("superstruct").Struct<"2.0" | undefined, unknown>;
|
|
42
|
+
params: import("superstruct").Struct<Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined, null>;
|
|
43
43
|
}>;
|
|
44
44
|
}>;
|
|
45
45
|
export declare type CronjobSpecification = Infer<typeof CronjobSpecificationStruct>;
|
|
@@ -53,31 +53,31 @@ export declare function isCronjobSpecification(value: unknown): boolean;
|
|
|
53
53
|
export declare const CronjobSpecificationArrayStruct: import("superstruct").Struct<{
|
|
54
54
|
request: {
|
|
55
55
|
method: string;
|
|
56
|
-
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
57
56
|
id?: string | number | null | undefined;
|
|
58
57
|
jsonrpc?: "2.0" | undefined;
|
|
58
|
+
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
59
59
|
};
|
|
60
60
|
expression: string;
|
|
61
61
|
}[], import("superstruct").Struct<{
|
|
62
62
|
request: {
|
|
63
63
|
method: string;
|
|
64
|
-
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
65
64
|
id?: string | number | null | undefined;
|
|
66
65
|
jsonrpc?: "2.0" | undefined;
|
|
66
|
+
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
67
67
|
};
|
|
68
68
|
expression: string;
|
|
69
69
|
}, {
|
|
70
70
|
expression: import("superstruct").Struct<string, null>;
|
|
71
71
|
request: import("superstruct").Struct<{
|
|
72
72
|
method: string;
|
|
73
|
-
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
74
73
|
id?: string | number | null | undefined;
|
|
75
74
|
jsonrpc?: "2.0" | undefined;
|
|
75
|
+
params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined;
|
|
76
76
|
}, {
|
|
77
|
-
|
|
77
|
+
jsonrpc: import("superstruct").Struct<"2.0" | undefined, "2.0">;
|
|
78
|
+
id: import("superstruct").Struct<string | number | null | undefined, null>;
|
|
78
79
|
method: import("superstruct").Struct<string, null>;
|
|
79
|
-
|
|
80
|
-
jsonrpc: import("superstruct").Struct<"2.0" | undefined, unknown>;
|
|
80
|
+
params: import("superstruct").Struct<Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | undefined, null>;
|
|
81
81
|
}>;
|
|
82
82
|
}>>;
|
|
83
83
|
/**
|
package/dist/types/handlers.d.ts
CHANGED
|
@@ -68,6 +68,24 @@ export declare const OnTransactionResponseStruct: import("superstruct").Struct<{
|
|
|
68
68
|
value: string;
|
|
69
69
|
type: import("@metamask/snaps-sdk").NodeType.Text;
|
|
70
70
|
markdown?: boolean | undefined;
|
|
71
|
+
} | {
|
|
72
|
+
value: string;
|
|
73
|
+
type: import("@metamask/snaps-sdk").NodeType.Address;
|
|
74
|
+
} | {
|
|
75
|
+
value: {
|
|
76
|
+
value: string;
|
|
77
|
+
type: import("@metamask/snaps-sdk").NodeType.Image;
|
|
78
|
+
} | {
|
|
79
|
+
value: string;
|
|
80
|
+
type: import("@metamask/snaps-sdk").NodeType.Text;
|
|
81
|
+
markdown?: boolean | undefined;
|
|
82
|
+
} | {
|
|
83
|
+
value: string;
|
|
84
|
+
type: import("@metamask/snaps-sdk").NodeType.Address;
|
|
85
|
+
};
|
|
86
|
+
type: import("@metamask/snaps-sdk").NodeType.Row;
|
|
87
|
+
label: string;
|
|
88
|
+
variant?: "default" | "warning" | "critical" | undefined;
|
|
71
89
|
};
|
|
72
90
|
severity?: SeverityLevel | undefined;
|
|
73
91
|
} | null, {
|
|
@@ -89,6 +107,24 @@ export declare const OnTransactionResponseStruct: import("superstruct").Struct<{
|
|
|
89
107
|
value: string;
|
|
90
108
|
type: import("@metamask/snaps-sdk").NodeType.Text;
|
|
91
109
|
markdown?: boolean | undefined;
|
|
110
|
+
} | {
|
|
111
|
+
value: string;
|
|
112
|
+
type: import("@metamask/snaps-sdk").NodeType.Address;
|
|
113
|
+
} | {
|
|
114
|
+
value: {
|
|
115
|
+
value: string;
|
|
116
|
+
type: import("@metamask/snaps-sdk").NodeType.Image;
|
|
117
|
+
} | {
|
|
118
|
+
value: string;
|
|
119
|
+
type: import("@metamask/snaps-sdk").NodeType.Text;
|
|
120
|
+
markdown?: boolean | undefined;
|
|
121
|
+
} | {
|
|
122
|
+
value: string;
|
|
123
|
+
type: import("@metamask/snaps-sdk").NodeType.Address;
|
|
124
|
+
};
|
|
125
|
+
type: import("@metamask/snaps-sdk").NodeType.Row;
|
|
126
|
+
label: string;
|
|
127
|
+
variant?: "default" | "warning" | "critical" | undefined;
|
|
92
128
|
}, null>;
|
|
93
129
|
severity: import("superstruct").Struct<SeverityLevel | undefined, SeverityLevel>;
|
|
94
130
|
}>;
|
|
@@ -111,6 +147,24 @@ export declare const OnHomePageResponseStruct: import("superstruct").Struct<{
|
|
|
111
147
|
value: string;
|
|
112
148
|
type: import("@metamask/snaps-sdk").NodeType.Text;
|
|
113
149
|
markdown?: boolean | undefined;
|
|
150
|
+
} | {
|
|
151
|
+
value: string;
|
|
152
|
+
type: import("@metamask/snaps-sdk").NodeType.Address;
|
|
153
|
+
} | {
|
|
154
|
+
value: {
|
|
155
|
+
value: string;
|
|
156
|
+
type: import("@metamask/snaps-sdk").NodeType.Image;
|
|
157
|
+
} | {
|
|
158
|
+
value: string;
|
|
159
|
+
type: import("@metamask/snaps-sdk").NodeType.Text;
|
|
160
|
+
markdown?: boolean | undefined;
|
|
161
|
+
} | {
|
|
162
|
+
value: string;
|
|
163
|
+
type: import("@metamask/snaps-sdk").NodeType.Address;
|
|
164
|
+
};
|
|
165
|
+
type: import("@metamask/snaps-sdk").NodeType.Row;
|
|
166
|
+
label: string;
|
|
167
|
+
variant?: "default" | "warning" | "critical" | undefined;
|
|
114
168
|
};
|
|
115
169
|
}, {
|
|
116
170
|
content: import("superstruct").Struct<import("@metamask/snaps-sdk").Panel | {
|
|
@@ -131,6 +185,24 @@ export declare const OnHomePageResponseStruct: import("superstruct").Struct<{
|
|
|
131
185
|
value: string;
|
|
132
186
|
type: import("@metamask/snaps-sdk").NodeType.Text;
|
|
133
187
|
markdown?: boolean | undefined;
|
|
188
|
+
} | {
|
|
189
|
+
value: string;
|
|
190
|
+
type: import("@metamask/snaps-sdk").NodeType.Address;
|
|
191
|
+
} | {
|
|
192
|
+
value: {
|
|
193
|
+
value: string;
|
|
194
|
+
type: import("@metamask/snaps-sdk").NodeType.Image;
|
|
195
|
+
} | {
|
|
196
|
+
value: string;
|
|
197
|
+
type: import("@metamask/snaps-sdk").NodeType.Text;
|
|
198
|
+
markdown?: boolean | undefined;
|
|
199
|
+
} | {
|
|
200
|
+
value: string;
|
|
201
|
+
type: import("@metamask/snaps-sdk").NodeType.Address;
|
|
202
|
+
};
|
|
203
|
+
type: import("@metamask/snaps-sdk").NodeType.Row;
|
|
204
|
+
label: string;
|
|
205
|
+
variant?: "default" | "warning" | "critical" | undefined;
|
|
134
206
|
}, null>;
|
|
135
207
|
}>;
|
|
136
208
|
/**
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export * from './array';
|
|
2
2
|
export * from './auxiliary-files';
|
|
3
|
+
export * from './base64';
|
|
4
|
+
export * from './bytes';
|
|
3
5
|
export * from './caveats';
|
|
4
6
|
export * from './checksum';
|
|
5
7
|
export * from './cronjob';
|
|
6
8
|
export * from './deep-clone';
|
|
7
9
|
export * from './default-endowments';
|
|
8
10
|
export * from './entropy';
|
|
9
|
-
export * from './enum';
|
|
10
11
|
export * from './errors';
|
|
11
12
|
export * from './handlers';
|
|
12
13
|
export * from './handler-types';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export * from './array';
|
|
2
2
|
export * from './auxiliary-files';
|
|
3
|
+
export * from './base64';
|
|
4
|
+
export * from './bytes';
|
|
3
5
|
export * from './caveats';
|
|
4
6
|
export * from './cronjob';
|
|
5
7
|
export * from './checksum';
|
|
6
8
|
export * from './deep-clone';
|
|
7
9
|
export * from './default-endowments';
|
|
8
10
|
export * from './entropy';
|
|
9
|
-
export * from './enum';
|
|
10
11
|
export * from './eval';
|
|
11
12
|
export * from './errors';
|
|
12
13
|
export * from './fs';
|
|
@@ -108,9 +108,9 @@ export declare function getLocalizedSnapManifest(snapManifest: SnapManifest, loc
|
|
|
108
108
|
jobs: {
|
|
109
109
|
request: {
|
|
110
110
|
method: string;
|
|
111
|
-
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
112
111
|
id?: string | number | null | undefined;
|
|
113
112
|
jsonrpc?: "2.0" | undefined;
|
|
113
|
+
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
114
114
|
};
|
|
115
115
|
expression: string;
|
|
116
116
|
}[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import type { Json } from '@metamask/utils';
|
|
2
3
|
import { ProgrammaticallyFixableSnapError } from '../snaps';
|
|
3
4
|
import type { SnapFiles } from '../types';
|
|
@@ -80,9 +81,10 @@ export declare function getSnapFilePaths(manifest: Json, selector: (manifest: Pa
|
|
|
80
81
|
*
|
|
81
82
|
* @param basePath - The path to the folder with the manifest files.
|
|
82
83
|
* @param paths - The paths to the files.
|
|
84
|
+
* @param encoding - An optional encoding to pass down to readVirtualFile.
|
|
83
85
|
* @returns A list of auxiliary files and their contents, if any.
|
|
84
86
|
*/
|
|
85
|
-
export declare function getSnapFiles(basePath: string, paths: string[] | undefined): Promise<VirtualFile[] | undefined>;
|
|
87
|
+
export declare function getSnapFiles(basePath: string, paths: string[] | undefined, encoding?: BufferEncoding | null): Promise<VirtualFile[] | undefined>;
|
|
86
88
|
/**
|
|
87
89
|
* Sorts the given manifest in our preferred sort order and removes the
|
|
88
90
|
* `repository` field if it is falsy (it may be `null`).
|
|
@@ -66,9 +66,9 @@ export declare const PermissionsStruct: Struct<{
|
|
|
66
66
|
jobs: {
|
|
67
67
|
request: {
|
|
68
68
|
method: string;
|
|
69
|
-
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
70
69
|
id?: string | number | null | undefined;
|
|
71
70
|
jsonrpc?: "2.0" | undefined;
|
|
71
|
+
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
72
72
|
};
|
|
73
73
|
expression: string;
|
|
74
74
|
}[];
|
|
@@ -95,9 +95,9 @@ export declare const PermissionsStruct: Struct<{
|
|
|
95
95
|
jobs: {
|
|
96
96
|
request: {
|
|
97
97
|
method: string;
|
|
98
|
-
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
99
98
|
id?: string | number | null | undefined;
|
|
100
99
|
jsonrpc?: "2.0" | undefined;
|
|
100
|
+
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
101
101
|
};
|
|
102
102
|
expression: string;
|
|
103
103
|
}[];
|
|
@@ -105,31 +105,31 @@ export declare const PermissionsStruct: Struct<{
|
|
|
105
105
|
jobs: Struct<{
|
|
106
106
|
request: {
|
|
107
107
|
method: string;
|
|
108
|
-
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
109
108
|
id?: string | number | null | undefined;
|
|
110
109
|
jsonrpc?: "2.0" | undefined;
|
|
110
|
+
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
111
111
|
};
|
|
112
112
|
expression: string;
|
|
113
113
|
}[], Struct<{
|
|
114
114
|
request: {
|
|
115
115
|
method: string;
|
|
116
|
-
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
117
116
|
id?: string | number | null | undefined;
|
|
118
117
|
jsonrpc?: "2.0" | undefined;
|
|
118
|
+
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
119
119
|
};
|
|
120
120
|
expression: string;
|
|
121
121
|
}, {
|
|
122
122
|
expression: Struct<string, null>;
|
|
123
123
|
request: Struct<{
|
|
124
124
|
method: string;
|
|
125
|
-
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
126
125
|
id?: string | number | null | undefined;
|
|
127
126
|
jsonrpc?: "2.0" | undefined;
|
|
127
|
+
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
128
128
|
}, {
|
|
129
|
-
|
|
129
|
+
jsonrpc: Struct<"2.0" | undefined, "2.0">;
|
|
130
|
+
id: Struct<string | number | null | undefined, null>;
|
|
130
131
|
method: Struct<string, null>;
|
|
131
|
-
|
|
132
|
-
jsonrpc: Struct<"2.0" | undefined, unknown>;
|
|
132
|
+
params: Struct<Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined, null>;
|
|
133
133
|
}>;
|
|
134
134
|
}>>;
|
|
135
135
|
}>;
|
|
@@ -239,9 +239,9 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
239
239
|
jobs: {
|
|
240
240
|
request: {
|
|
241
241
|
method: string;
|
|
242
|
-
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
243
242
|
id?: string | number | null | undefined;
|
|
244
243
|
jsonrpc?: "2.0" | undefined;
|
|
244
|
+
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
245
245
|
};
|
|
246
246
|
expression: string;
|
|
247
247
|
}[];
|
|
@@ -340,9 +340,9 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
340
340
|
jobs: {
|
|
341
341
|
request: {
|
|
342
342
|
method: string;
|
|
343
|
-
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
344
343
|
id?: string | number | null | undefined;
|
|
345
344
|
jsonrpc?: "2.0" | undefined;
|
|
345
|
+
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
346
346
|
};
|
|
347
347
|
expression: string;
|
|
348
348
|
}[];
|
|
@@ -369,9 +369,9 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
369
369
|
jobs: {
|
|
370
370
|
request: {
|
|
371
371
|
method: string;
|
|
372
|
-
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
373
372
|
id?: string | number | null | undefined;
|
|
374
373
|
jsonrpc?: "2.0" | undefined;
|
|
374
|
+
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
375
375
|
};
|
|
376
376
|
expression: string;
|
|
377
377
|
}[];
|
|
@@ -379,31 +379,31 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
379
379
|
jobs: Struct<{
|
|
380
380
|
request: {
|
|
381
381
|
method: string;
|
|
382
|
-
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
383
382
|
id?: string | number | null | undefined;
|
|
384
383
|
jsonrpc?: "2.0" | undefined;
|
|
384
|
+
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
385
385
|
};
|
|
386
386
|
expression: string;
|
|
387
387
|
}[], Struct<{
|
|
388
388
|
request: {
|
|
389
389
|
method: string;
|
|
390
|
-
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
391
390
|
id?: string | number | null | undefined;
|
|
392
391
|
jsonrpc?: "2.0" | undefined;
|
|
392
|
+
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
393
393
|
};
|
|
394
394
|
expression: string;
|
|
395
395
|
}, {
|
|
396
396
|
expression: Struct<string, null>;
|
|
397
397
|
request: Struct<{
|
|
398
398
|
method: string;
|
|
399
|
-
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
400
399
|
id?: string | number | null | undefined;
|
|
401
400
|
jsonrpc?: "2.0" | undefined;
|
|
401
|
+
params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
|
|
402
402
|
}, {
|
|
403
|
-
|
|
403
|
+
jsonrpc: Struct<"2.0" | undefined, "2.0">;
|
|
404
|
+
id: Struct<string | number | null | undefined, null>;
|
|
404
405
|
method: Struct<string, null>;
|
|
405
|
-
|
|
406
|
-
jsonrpc: Struct<"2.0" | undefined, unknown>;
|
|
406
|
+
params: Struct<Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined, null>;
|
|
407
407
|
}>;
|
|
408
408
|
}>>;
|
|
409
409
|
}>;
|
package/dist/types/structs.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Failure
|
|
1
|
+
import type { Failure } from 'superstruct';
|
|
2
2
|
import { Struct, StructError } from 'superstruct';
|
|
3
|
-
import type { AnyStruct
|
|
3
|
+
import type { AnyStruct } from 'superstruct/dist/utils';
|
|
4
4
|
/**
|
|
5
5
|
* Infer a struct type, only if it matches the specified type. This is useful
|
|
6
6
|
* for defining types and structs that are related to each other in separate
|
|
@@ -24,44 +24,6 @@ import type { AnyStruct, InferStructTuple } from 'superstruct/dist/utils';
|
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
26
|
export declare type InferMatching<StructType extends Struct<any, any>, Type> = StructType['TYPE'] extends Type ? Type : never;
|
|
27
|
-
/**
|
|
28
|
-
* A wrapper of `superstruct`'s `literal` struct that also defines the name of
|
|
29
|
-
* the struct as the literal value.
|
|
30
|
-
*
|
|
31
|
-
* This is useful for improving the error messages returned by `superstruct`.
|
|
32
|
-
* For example, instead of returning an error like:
|
|
33
|
-
*
|
|
34
|
-
* ```
|
|
35
|
-
* Expected the value to satisfy a union of `literal | literal`, but received: \"baz\"
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* This struct will return an error like:
|
|
39
|
-
*
|
|
40
|
-
* ```
|
|
41
|
-
* Expected the value to satisfy a union of `"foo" | "bar"`, but received: \"baz\"
|
|
42
|
-
* ```
|
|
43
|
-
*
|
|
44
|
-
* @param value - The literal value.
|
|
45
|
-
* @returns The `superstruct` struct, which validates that the value is equal
|
|
46
|
-
* to the literal value.
|
|
47
|
-
*/
|
|
48
|
-
export declare function literal<Type extends string | number | boolean>(value: Type): Struct<Type, null>;
|
|
49
|
-
/**
|
|
50
|
-
* A wrapper of `superstruct`'s `union` struct that also defines the schema as
|
|
51
|
-
* the union of the schemas of the structs.
|
|
52
|
-
*
|
|
53
|
-
* This is useful for improving the error messages returned by `superstruct`.
|
|
54
|
-
*
|
|
55
|
-
* @param structs - The structs to union.
|
|
56
|
-
* @param structs."0" - The first struct.
|
|
57
|
-
* @param structs."1" - The remaining structs.
|
|
58
|
-
* @returns The `superstruct` struct, which validates that the value satisfies
|
|
59
|
-
* one of the structs.
|
|
60
|
-
*/
|
|
61
|
-
export declare function union<Head extends AnyStruct, Tail extends AnyStruct[]>([head, ...tail]: [head: Head, ...tail: Tail]): Struct<Infer<Head> | InferStructTuple<Tail>[number], [
|
|
62
|
-
head: Head,
|
|
63
|
-
...tail: Tail
|
|
64
|
-
]>;
|
|
65
27
|
/**
|
|
66
28
|
* A wrapper of `superstruct`'s `string` struct that coerces a value to a string
|
|
67
29
|
* and resolves it relative to the current working directory. This is useful
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/snaps-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/MetaMask/snaps.git"
|
|
@@ -67,13 +67,13 @@
|
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@babel/core": "^7.23.2",
|
|
69
69
|
"@babel/types": "^7.23.0",
|
|
70
|
-
"@metamask/base-controller": "^
|
|
70
|
+
"@metamask/base-controller": "^4.0.0",
|
|
71
71
|
"@metamask/key-tree": "^9.0.0",
|
|
72
|
-
"@metamask/permission-controller": "^
|
|
72
|
+
"@metamask/permission-controller": "^6.0.0",
|
|
73
73
|
"@metamask/rpc-errors": "^6.1.0",
|
|
74
|
-
"@metamask/snaps-registry": "^2.1.
|
|
75
|
-
"@metamask/snaps-sdk": "^1.
|
|
76
|
-
"@metamask/utils": "^8.1
|
|
74
|
+
"@metamask/snaps-registry": "^2.1.1",
|
|
75
|
+
"@metamask/snaps-sdk": "^1.3.0",
|
|
76
|
+
"@metamask/utils": "^8.2.1",
|
|
77
77
|
"@noble/hashes": "^1.3.1",
|
|
78
78
|
"@scure/base": "^1.1.1",
|
|
79
79
|
"chalk": "^4.1.2",
|
package/dist/cjs/enum.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "enumValue", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return enumValue;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _structs = require("./structs");
|
|
12
|
-
function enumValue(constant) {
|
|
13
|
-
return (0, _structs.literal)(constant);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=enum.js.map
|
package/dist/cjs/enum.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/enum.ts"],"sourcesContent":["import type { EnumToUnion } from '@metamask/snaps-sdk';\nimport type { Struct } from 'superstruct';\n\nimport { literal } from './structs';\n\n/**\n * Superstruct struct for validating an enum value. This allows using both the\n * enum string values and the enum itself as values.\n *\n * @param constant - The enum to validate against.\n * @returns The superstruct struct.\n */\nexport function enumValue<Type extends string>(\n constant: Type,\n): Struct<EnumToUnion<Type>, null> {\n return literal(constant as EnumToUnion<Type>);\n}\n"],"names":["enumValue","constant","literal"],"mappings":";;;;+BAYgBA;;;eAAAA;;;yBATQ;AASjB,SAASA,UACdC,QAAc;IAEd,OAAOC,IAAAA,gBAAO,EAACD;AACjB"}
|
package/dist/esm/enum.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { literal } from './structs';
|
|
2
|
-
/**
|
|
3
|
-
* Superstruct struct for validating an enum value. This allows using both the
|
|
4
|
-
* enum string values and the enum itself as values.
|
|
5
|
-
*
|
|
6
|
-
* @param constant - The enum to validate against.
|
|
7
|
-
* @returns The superstruct struct.
|
|
8
|
-
*/ export function enumValue(constant) {
|
|
9
|
-
return literal(constant);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=enum.js.map
|
package/dist/esm/enum.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/enum.ts"],"sourcesContent":["import type { EnumToUnion } from '@metamask/snaps-sdk';\nimport type { Struct } from 'superstruct';\n\nimport { literal } from './structs';\n\n/**\n * Superstruct struct for validating an enum value. This allows using both the\n * enum string values and the enum itself as values.\n *\n * @param constant - The enum to validate against.\n * @returns The superstruct struct.\n */\nexport function enumValue<Type extends string>(\n constant: Type,\n): Struct<EnumToUnion<Type>, null> {\n return literal(constant as EnumToUnion<Type>);\n}\n"],"names":["literal","enumValue","constant"],"mappings":"AAGA,SAASA,OAAO,QAAQ,YAAY;AAEpC;;;;;;CAMC,GACD,OAAO,SAASC,UACdC,QAAc;IAEd,OAAOF,QAAQE;AACjB"}
|
package/dist/types/enum.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { EnumToUnion } from '@metamask/snaps-sdk';
|
|
2
|
-
import type { Struct } from 'superstruct';
|
|
3
|
-
/**
|
|
4
|
-
* Superstruct struct for validating an enum value. This allows using both the
|
|
5
|
-
* enum string values and the enum itself as values.
|
|
6
|
-
*
|
|
7
|
-
* @param constant - The enum to validate against.
|
|
8
|
-
* @returns The superstruct struct.
|
|
9
|
-
*/
|
|
10
|
-
export declare function enumValue<Type extends string>(constant: Type): Struct<EnumToUnion<Type>, null>;
|