@acala-network/chopsticks 1.5.1 → 1.6.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/dist/cjs/bridge.js +1 -0
- package/dist/cjs/context.js +8 -19
- package/dist/cjs/plugins/dry-run/cli.js +7 -21
- package/dist/cjs/plugins/dry-run/index.d.ts +21 -227
- package/dist/cjs/plugins/dry-run/index.js +7 -21
- package/dist/cjs/plugins/dry-run/rpc.d.ts +12 -64
- package/dist/cjs/plugins/index.js +8 -19
- package/dist/cjs/plugins/run-block/cli.js +3 -9
- package/dist/cjs/plugins/run-block/rpc.d.ts +4 -28
- package/dist/cjs/plugins/trace-transaction/index.js +5 -15
- package/dist/cjs/plugins/try-runtime/index.js +3 -9
- package/dist/cjs/schema/index.d.ts +25 -217
- package/dist/cjs/schema/index.js +80 -72
- package/dist/cjs/types.js +8 -19
- package/dist/cjs/utils/fetch-storages-worker.js +8 -19
- package/dist/cjs/utils/override.js +32 -2
- package/dist/esm/bridge.js +1 -0
- package/dist/esm/plugins/dry-run/cli.js +7 -21
- package/dist/esm/plugins/dry-run/index.d.ts +21 -227
- package/dist/esm/plugins/dry-run/index.js +7 -21
- package/dist/esm/plugins/dry-run/rpc.d.ts +12 -64
- package/dist/esm/plugins/run-block/cli.js +3 -9
- package/dist/esm/plugins/run-block/rpc.d.ts +4 -28
- package/dist/esm/plugins/trace-transaction/index.js +5 -15
- package/dist/esm/plugins/try-runtime/index.js +3 -9
- package/dist/esm/schema/index.d.ts +25 -217
- package/dist/esm/schema/index.js +50 -72
- package/dist/esm/utils/override.js +1 -1
- package/package.json +82 -78
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { BuildBlockMode } from '@acala-network/chopsticks-core';
|
|
2
2
|
import type { Options } from 'yargs';
|
|
3
|
-
import {
|
|
4
|
-
export declare const zHex: z.
|
|
5
|
-
export declare const zHash: z.ZodIntersection<z.ZodString, z.
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export declare const zHex: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
5
|
+
export declare const zHash: z.ZodIntersection<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
6
6
|
export declare const configSchema: z.ZodObject<{
|
|
7
|
-
addr: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"localhost">, z.
|
|
8
|
-
host: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"localhost">, z.
|
|
7
|
+
addr: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"localhost">, z.ZodUnion<readonly [z.ZodIPv4, z.ZodIPv6]>]>>;
|
|
8
|
+
host: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"localhost">, z.ZodUnion<readonly [z.ZodIPv4, z.ZodIPv6]>]>>;
|
|
9
9
|
port: z.ZodDefault<z.ZodNumber>;
|
|
10
|
-
endpoint: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString
|
|
11
|
-
block: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodNull]>>;
|
|
12
|
-
'build-block-mode': z.ZodDefault<
|
|
10
|
+
endpoint: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
11
|
+
block: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>;
|
|
12
|
+
'build-block-mode': z.ZodDefault<z.ZodEnum<typeof BuildBlockMode>>;
|
|
13
13
|
'import-storage': z.ZodOptional<z.ZodAny>;
|
|
14
14
|
'allow-unresolved-imports': z.ZodOptional<z.ZodBoolean>;
|
|
15
15
|
'mock-signature-host': z.ZodOptional<z.ZodBoolean>;
|
|
@@ -17,237 +17,45 @@ export declare const configSchema: z.ZodObject<{
|
|
|
17
17
|
db: z.ZodOptional<z.ZodString>;
|
|
18
18
|
'save-blocks': z.ZodOptional<z.ZodBoolean>;
|
|
19
19
|
'wasm-override': z.ZodOptional<z.ZodString>;
|
|
20
|
-
genesis: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
20
|
+
genesis: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
21
21
|
id: z.ZodString;
|
|
22
22
|
name: z.ZodString;
|
|
23
23
|
properties: z.ZodObject<{
|
|
24
24
|
ss58Format: z.ZodOptional<z.ZodNumber>;
|
|
25
|
-
tokenDecimals: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodArray<z.ZodNumber
|
|
26
|
-
tokenSymbol: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString
|
|
27
|
-
},
|
|
28
|
-
ss58Format?: number | undefined;
|
|
29
|
-
tokenDecimals?: number | number[] | undefined;
|
|
30
|
-
tokenSymbol?: string | string[] | undefined;
|
|
31
|
-
}, {
|
|
32
|
-
ss58Format?: number | undefined;
|
|
33
|
-
tokenDecimals?: number | number[] | undefined;
|
|
34
|
-
tokenSymbol?: string | string[] | undefined;
|
|
35
|
-
}>;
|
|
25
|
+
tokenDecimals: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodArray<z.ZodNumber>]>>;
|
|
26
|
+
tokenSymbol: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
27
|
+
}, z.core.$strip>;
|
|
36
28
|
genesis: z.ZodObject<{
|
|
37
29
|
raw: z.ZodObject<{
|
|
38
30
|
top: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}>;
|
|
44
|
-
}, "strip", z.ZodTypeAny, {
|
|
45
|
-
raw: {
|
|
46
|
-
top: Record<string, string>;
|
|
47
|
-
};
|
|
48
|
-
}, {
|
|
49
|
-
raw: {
|
|
50
|
-
top: Record<string, string>;
|
|
51
|
-
};
|
|
52
|
-
}>;
|
|
53
|
-
}, "strip", ZodTypeAny, {
|
|
54
|
-
name: string;
|
|
55
|
-
id: string;
|
|
56
|
-
properties: {
|
|
57
|
-
ss58Format?: number | undefined;
|
|
58
|
-
tokenDecimals?: number | number[] | undefined;
|
|
59
|
-
tokenSymbol?: string | string[] | undefined;
|
|
60
|
-
};
|
|
61
|
-
genesis: {
|
|
62
|
-
raw: {
|
|
63
|
-
top: Record<string, string>;
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
}, {
|
|
67
|
-
name: string;
|
|
68
|
-
id: string;
|
|
69
|
-
properties: {
|
|
70
|
-
ss58Format?: number | undefined;
|
|
71
|
-
tokenDecimals?: number | number[] | undefined;
|
|
72
|
-
tokenSymbol?: string | string[] | undefined;
|
|
73
|
-
};
|
|
74
|
-
genesis: {
|
|
75
|
-
raw: {
|
|
76
|
-
top: Record<string, string>;
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
}>]>>;
|
|
80
|
-
'chain-spec': z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
}, z.core.$strip>]>>;
|
|
34
|
+
'chain-spec': z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
81
35
|
id: z.ZodString;
|
|
82
36
|
name: z.ZodString;
|
|
83
37
|
properties: z.ZodObject<{
|
|
84
38
|
ss58Format: z.ZodOptional<z.ZodNumber>;
|
|
85
|
-
tokenDecimals: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodArray<z.ZodNumber
|
|
86
|
-
tokenSymbol: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString
|
|
87
|
-
},
|
|
88
|
-
ss58Format?: number | undefined;
|
|
89
|
-
tokenDecimals?: number | number[] | undefined;
|
|
90
|
-
tokenSymbol?: string | string[] | undefined;
|
|
91
|
-
}, {
|
|
92
|
-
ss58Format?: number | undefined;
|
|
93
|
-
tokenDecimals?: number | number[] | undefined;
|
|
94
|
-
tokenSymbol?: string | string[] | undefined;
|
|
95
|
-
}>;
|
|
39
|
+
tokenDecimals: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodArray<z.ZodNumber>]>>;
|
|
40
|
+
tokenSymbol: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
41
|
+
}, z.core.$strip>;
|
|
96
42
|
genesis: z.ZodObject<{
|
|
97
43
|
raw: z.ZodObject<{
|
|
98
44
|
top: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
top: Record<string, string>;
|
|
103
|
-
}>;
|
|
104
|
-
}, "strip", z.ZodTypeAny, {
|
|
105
|
-
raw: {
|
|
106
|
-
top: Record<string, string>;
|
|
107
|
-
};
|
|
108
|
-
}, {
|
|
109
|
-
raw: {
|
|
110
|
-
top: Record<string, string>;
|
|
111
|
-
};
|
|
112
|
-
}>;
|
|
113
|
-
}, "strip", ZodTypeAny, {
|
|
114
|
-
name: string;
|
|
115
|
-
id: string;
|
|
116
|
-
properties: {
|
|
117
|
-
ss58Format?: number | undefined;
|
|
118
|
-
tokenDecimals?: number | number[] | undefined;
|
|
119
|
-
tokenSymbol?: string | string[] | undefined;
|
|
120
|
-
};
|
|
121
|
-
genesis: {
|
|
122
|
-
raw: {
|
|
123
|
-
top: Record<string, string>;
|
|
124
|
-
};
|
|
125
|
-
};
|
|
126
|
-
}, {
|
|
127
|
-
name: string;
|
|
128
|
-
id: string;
|
|
129
|
-
properties: {
|
|
130
|
-
ss58Format?: number | undefined;
|
|
131
|
-
tokenDecimals?: number | number[] | undefined;
|
|
132
|
-
tokenSymbol?: string | string[] | undefined;
|
|
133
|
-
};
|
|
134
|
-
genesis: {
|
|
135
|
-
raw: {
|
|
136
|
-
top: Record<string, string>;
|
|
137
|
-
};
|
|
138
|
-
};
|
|
139
|
-
}>]>>;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
}, z.core.$strip>]>>;
|
|
140
48
|
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
141
49
|
'registered-types': z.ZodOptional<z.ZodAny>;
|
|
142
50
|
'runtime-log-level': z.ZodOptional<z.ZodNumber>;
|
|
143
51
|
'offchain-worker': z.ZodOptional<z.ZodBoolean>;
|
|
144
|
-
resume: z.ZodOptional<z.ZodUnion<[z.ZodIntersection<z.ZodString, z.
|
|
52
|
+
resume: z.ZodOptional<z.ZodUnion<readonly [z.ZodIntersection<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>, z.ZodNumber, z.ZodBoolean]>>;
|
|
145
53
|
'process-queued-messages': z.ZodOptional<z.ZodBoolean>;
|
|
146
54
|
'prefetch-storages': z.ZodOptional<z.ZodAny>;
|
|
147
55
|
'rpc-timeout': z.ZodOptional<z.ZodNumber>;
|
|
148
|
-
},
|
|
149
|
-
port: number;
|
|
150
|
-
'build-block-mode': BuildBlockMode;
|
|
151
|
-
addr?: string | undefined;
|
|
152
|
-
host?: string | undefined;
|
|
153
|
-
endpoint?: string | string[] | undefined;
|
|
154
|
-
block?: string | number | null | undefined;
|
|
155
|
-
'import-storage'?: any;
|
|
156
|
-
'allow-unresolved-imports'?: boolean | undefined;
|
|
157
|
-
'mock-signature-host'?: boolean | undefined;
|
|
158
|
-
'max-memory-block-count'?: number | undefined;
|
|
159
|
-
db?: string | undefined;
|
|
160
|
-
'save-blocks'?: boolean | undefined;
|
|
161
|
-
'wasm-override'?: string | undefined;
|
|
162
|
-
genesis?: string | {
|
|
163
|
-
name: string;
|
|
164
|
-
id: string;
|
|
165
|
-
properties: {
|
|
166
|
-
ss58Format?: number | undefined;
|
|
167
|
-
tokenDecimals?: number | number[] | undefined;
|
|
168
|
-
tokenSymbol?: string | string[] | undefined;
|
|
169
|
-
};
|
|
170
|
-
genesis: {
|
|
171
|
-
raw: {
|
|
172
|
-
top: Record<string, string>;
|
|
173
|
-
};
|
|
174
|
-
};
|
|
175
|
-
} | undefined;
|
|
176
|
-
'chain-spec'?: string | {
|
|
177
|
-
name: string;
|
|
178
|
-
id: string;
|
|
179
|
-
properties: {
|
|
180
|
-
ss58Format?: number | undefined;
|
|
181
|
-
tokenDecimals?: number | number[] | undefined;
|
|
182
|
-
tokenSymbol?: string | string[] | undefined;
|
|
183
|
-
};
|
|
184
|
-
genesis: {
|
|
185
|
-
raw: {
|
|
186
|
-
top: Record<string, string>;
|
|
187
|
-
};
|
|
188
|
-
};
|
|
189
|
-
} | undefined;
|
|
190
|
-
timestamp?: number | undefined;
|
|
191
|
-
'registered-types'?: any;
|
|
192
|
-
'runtime-log-level'?: number | undefined;
|
|
193
|
-
'offchain-worker'?: boolean | undefined;
|
|
194
|
-
resume?: number | boolean | `0x${string}` | undefined;
|
|
195
|
-
'process-queued-messages'?: boolean | undefined;
|
|
196
|
-
'prefetch-storages'?: any;
|
|
197
|
-
'rpc-timeout'?: number | undefined;
|
|
198
|
-
}, {
|
|
199
|
-
addr?: string | undefined;
|
|
200
|
-
host?: string | undefined;
|
|
201
|
-
port?: number | undefined;
|
|
202
|
-
endpoint?: string | string[] | undefined;
|
|
203
|
-
block?: string | number | null | undefined;
|
|
204
|
-
'build-block-mode'?: BuildBlockMode | undefined;
|
|
205
|
-
'import-storage'?: any;
|
|
206
|
-
'allow-unresolved-imports'?: boolean | undefined;
|
|
207
|
-
'mock-signature-host'?: boolean | undefined;
|
|
208
|
-
'max-memory-block-count'?: number | undefined;
|
|
209
|
-
db?: string | undefined;
|
|
210
|
-
'save-blocks'?: boolean | undefined;
|
|
211
|
-
'wasm-override'?: string | undefined;
|
|
212
|
-
genesis?: string | {
|
|
213
|
-
name: string;
|
|
214
|
-
id: string;
|
|
215
|
-
properties: {
|
|
216
|
-
ss58Format?: number | undefined;
|
|
217
|
-
tokenDecimals?: number | number[] | undefined;
|
|
218
|
-
tokenSymbol?: string | string[] | undefined;
|
|
219
|
-
};
|
|
220
|
-
genesis: {
|
|
221
|
-
raw: {
|
|
222
|
-
top: Record<string, string>;
|
|
223
|
-
};
|
|
224
|
-
};
|
|
225
|
-
} | undefined;
|
|
226
|
-
'chain-spec'?: string | {
|
|
227
|
-
name: string;
|
|
228
|
-
id: string;
|
|
229
|
-
properties: {
|
|
230
|
-
ss58Format?: number | undefined;
|
|
231
|
-
tokenDecimals?: number | number[] | undefined;
|
|
232
|
-
tokenSymbol?: string | string[] | undefined;
|
|
233
|
-
};
|
|
234
|
-
genesis: {
|
|
235
|
-
raw: {
|
|
236
|
-
top: Record<string, string>;
|
|
237
|
-
};
|
|
238
|
-
};
|
|
239
|
-
} | undefined;
|
|
240
|
-
timestamp?: number | undefined;
|
|
241
|
-
'registered-types'?: any;
|
|
242
|
-
'runtime-log-level'?: number | undefined;
|
|
243
|
-
'offchain-worker'?: boolean | undefined;
|
|
244
|
-
resume?: number | boolean | `0x${string}` | undefined;
|
|
245
|
-
'process-queued-messages'?: boolean | undefined;
|
|
246
|
-
'prefetch-storages'?: any;
|
|
247
|
-
'rpc-timeout'?: number | undefined;
|
|
248
|
-
}>;
|
|
56
|
+
}, z.core.$strip>;
|
|
249
57
|
export type Config = z.infer<typeof configSchema>;
|
|
250
|
-
export declare const getYargsOptions: (zodShape:
|
|
58
|
+
export declare const getYargsOptions: (zodShape: Record<string, any>) => {
|
|
251
59
|
[x: string]: Options;
|
|
252
60
|
};
|
|
253
61
|
export declare const fetchConfig: (path: string) => Promise<Config>;
|
package/dist/esm/schema/index.js
CHANGED
|
@@ -2,135 +2,113 @@ import { readFileSync } from 'node:fs';
|
|
|
2
2
|
import { basename, extname } from 'node:path';
|
|
3
3
|
import { BuildBlockMode, defaultLogger, genesisSchema, isUrl } from '@acala-network/chopsticks-core';
|
|
4
4
|
import axios from 'axios';
|
|
5
|
-
import yaml from 'js-yaml';
|
|
5
|
+
import * as yaml from 'js-yaml';
|
|
6
6
|
import _ from 'lodash';
|
|
7
|
-
import {
|
|
7
|
+
import { z } from 'zod';
|
|
8
8
|
export const zHex = z.custom((val)=>/^0x\w+$/.test(val));
|
|
9
9
|
export const zHash = z.string().length(66).and(zHex);
|
|
10
|
+
const ipAddress = z.union([
|
|
11
|
+
z.ipv4(),
|
|
12
|
+
z.ipv6()
|
|
13
|
+
]);
|
|
10
14
|
export const configSchema = z.object({
|
|
11
15
|
addr: z.union([
|
|
12
16
|
z.literal('localhost'),
|
|
13
|
-
|
|
17
|
+
ipAddress
|
|
14
18
|
]).optional(),
|
|
15
19
|
host: z.union([
|
|
16
20
|
z.literal('localhost'),
|
|
17
|
-
|
|
18
|
-
],
|
|
19
|
-
|
|
20
|
-
}).optional(),
|
|
21
|
-
port: z.number({
|
|
22
|
-
description: 'Server listening port'
|
|
23
|
-
}).default(8000),
|
|
21
|
+
ipAddress
|
|
22
|
+
]).describe('Server listening interface').optional(),
|
|
23
|
+
port: z.number().describe('Server listening port').default(8000),
|
|
24
24
|
endpoint: z.union([
|
|
25
25
|
z.string(),
|
|
26
26
|
z.array(z.string())
|
|
27
|
-
],
|
|
28
|
-
description: 'Endpoint to connect to'
|
|
29
|
-
}).optional(),
|
|
27
|
+
]).describe('Endpoint to connect to').optional(),
|
|
30
28
|
block: z.union([
|
|
31
29
|
z.string(),
|
|
32
30
|
z.number().max(Number.MAX_SAFE_INTEGER, 'Number is too big, please make it a string if you are using a hex string'),
|
|
33
31
|
z.null()
|
|
34
|
-
],
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
'build-block-mode': z.nativeEnum(BuildBlockMode).default(BuildBlockMode.Batch),
|
|
38
|
-
'import-storage': z.any({
|
|
39
|
-
description: 'Pre-defined JSON/YAML storage file path'
|
|
40
|
-
}).optional(),
|
|
32
|
+
]).describe('Block hash or block number. Default to latest block').optional(),
|
|
33
|
+
'build-block-mode': z.enum(BuildBlockMode).default(BuildBlockMode.Batch),
|
|
34
|
+
'import-storage': z.any().describe('Pre-defined JSON/YAML storage file path').optional(),
|
|
41
35
|
'allow-unresolved-imports': z.boolean().optional(),
|
|
42
|
-
'mock-signature-host': z.boolean(
|
|
43
|
-
description: 'Mock signature host so any signature starts with 0xdeadbeef and filled by 0xcd is considered valid'
|
|
44
|
-
}).optional(),
|
|
36
|
+
'mock-signature-host': z.boolean().describe('Mock signature host so any signature starts with 0xdeadbeef and filled by 0xcd is considered valid').optional(),
|
|
45
37
|
'max-memory-block-count': z.number().optional(),
|
|
46
|
-
db: z.string(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
'save-blocks': z.boolean({
|
|
50
|
-
description: 'Save blocks to database. Default to true.'
|
|
51
|
-
}).optional(),
|
|
52
|
-
'wasm-override': z.string({
|
|
53
|
-
description: 'Path to wasm override'
|
|
54
|
-
}).optional(),
|
|
38
|
+
db: z.string().describe('Path to database').optional(),
|
|
39
|
+
'save-blocks': z.boolean().describe('Save blocks to database. Default to true.').optional(),
|
|
40
|
+
'wasm-override': z.string().describe('Path to wasm override').optional(),
|
|
55
41
|
genesis: z.union([
|
|
56
42
|
z.string(),
|
|
57
43
|
genesisSchema
|
|
58
|
-
],
|
|
59
|
-
description: 'Alias to `chain-spec`. URL to chain spec file. NOTE: Only parachains with AURA consensus are supported!'
|
|
60
|
-
}).optional(),
|
|
44
|
+
]).describe('Alias to `chain-spec`. URL to chain spec file. NOTE: Only parachains with AURA consensus are supported!').optional(),
|
|
61
45
|
'chain-spec': z.union([
|
|
62
46
|
z.string(),
|
|
63
47
|
genesisSchema
|
|
64
|
-
],
|
|
65
|
-
description: 'URL to chain spec file. NOTE: Only parachains with AURA consensus are supported!'
|
|
66
|
-
}).optional(),
|
|
48
|
+
]).describe('URL to chain spec file. NOTE: Only parachains with AURA consensus are supported!').optional(),
|
|
67
49
|
timestamp: z.number().optional(),
|
|
68
50
|
'registered-types': z.any().optional(),
|
|
69
|
-
'runtime-log-level': z.number(
|
|
70
|
-
|
|
71
|
-
}).min(0).max(5).optional(),
|
|
72
|
-
'offchain-worker': z.boolean({
|
|
73
|
-
description: 'Enable offchain worker'
|
|
74
|
-
}).optional(),
|
|
51
|
+
'runtime-log-level': z.number().describe('Runtime maximum log level [off = 0; error = 1; warn = 2; info = 3; debug = 4; trace = 5]').min(0).max(5).optional(),
|
|
52
|
+
'offchain-worker': z.boolean().describe('Enable offchain worker').optional(),
|
|
75
53
|
resume: z.union([
|
|
76
54
|
zHash,
|
|
77
55
|
z.number(),
|
|
78
56
|
z.boolean()
|
|
79
|
-
],
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
'
|
|
83
|
-
description: 'Produce extra block when queued messages are detected. Default to true. Set to false to disable it.'
|
|
84
|
-
}).optional(),
|
|
85
|
-
'prefetch-storages': z.any({
|
|
86
|
-
description: 'Storage key prefixes config for fetching storage, useful for testing big migrations, see README for examples'
|
|
87
|
-
}).optional(),
|
|
88
|
-
'rpc-timeout': z.number({
|
|
89
|
-
description: 'RPC timeout in milliseconds'
|
|
90
|
-
}).optional()
|
|
57
|
+
]).describe('Resume from the specified block hash or block number in db. If true, it will resume from the latest block in db. Note this will override the block option').optional(),
|
|
58
|
+
'process-queued-messages': z.boolean().describe('Produce extra block when queued messages are detected. Default to true. Set to false to disable it.').optional(),
|
|
59
|
+
'prefetch-storages': z.any().describe('Storage key prefixes config for fetching storage, useful for testing big migrations, see README for examples').optional(),
|
|
60
|
+
'rpc-timeout': z.number().describe('RPC timeout in milliseconds').optional()
|
|
91
61
|
});
|
|
62
|
+
const unwrapOption = (option)=>{
|
|
63
|
+
if ([
|
|
64
|
+
'optional',
|
|
65
|
+
'nullable',
|
|
66
|
+
'default'
|
|
67
|
+
].includes(option.def.type)) return unwrapOption(option.def.innerType);
|
|
68
|
+
return option;
|
|
69
|
+
};
|
|
92
70
|
const getZodType = (option)=>{
|
|
93
|
-
|
|
94
|
-
|
|
71
|
+
option = unwrapOption(option);
|
|
72
|
+
switch(option.def.type){
|
|
73
|
+
case 'string':
|
|
95
74
|
return 'string';
|
|
96
|
-
case '
|
|
75
|
+
case 'number':
|
|
97
76
|
return 'number';
|
|
98
|
-
case '
|
|
77
|
+
case 'boolean':
|
|
99
78
|
return 'boolean';
|
|
100
79
|
default:
|
|
101
80
|
break;
|
|
102
81
|
}
|
|
103
|
-
if (option.
|
|
104
|
-
return
|
|
82
|
+
if (option.def.type === 'union') {
|
|
83
|
+
return getZodFirstOption(option);
|
|
84
|
+
}
|
|
85
|
+
if (option.def.type === 'intersection') {
|
|
86
|
+
return getZodType(option.def.left);
|
|
105
87
|
}
|
|
106
88
|
return undefined;
|
|
107
89
|
};
|
|
108
90
|
const getZodChoices = (option)=>{
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (option._def.innerType) {
|
|
113
|
-
return getZodChoices(option._def.innerType);
|
|
91
|
+
option = unwrapOption(option);
|
|
92
|
+
if (option.def.type === 'enum') {
|
|
93
|
+
return Object.values(option.def.entries).filter((x)=>typeof x === 'string');
|
|
114
94
|
}
|
|
115
95
|
return undefined;
|
|
116
96
|
};
|
|
117
97
|
const getZodFirstOption = (option)=>{
|
|
118
|
-
|
|
98
|
+
option = unwrapOption(option);
|
|
99
|
+
const options = option.def.type === 'union' ? option.def.options : undefined;
|
|
119
100
|
if (options) {
|
|
120
101
|
for (const option of options){
|
|
121
102
|
const type = getZodType(option);
|
|
122
103
|
if (type) return type;
|
|
123
104
|
}
|
|
124
105
|
}
|
|
125
|
-
if (option._def.innerType) {
|
|
126
|
-
return getZodFirstOption(option._def.innerType);
|
|
127
|
-
}
|
|
128
106
|
return undefined;
|
|
129
107
|
};
|
|
130
108
|
export const getYargsOptions = (zodShape)=>{
|
|
131
109
|
return _.mapValues(zodShape, (option)=>({
|
|
132
110
|
demandOption: !option.isOptional(),
|
|
133
|
-
description: option.
|
|
111
|
+
description: unwrapOption(option).description,
|
|
134
112
|
type: getZodType(option) || getZodFirstOption(option),
|
|
135
113
|
choices: getZodChoices(option)
|
|
136
114
|
}));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { isUrl, setStorage } from '@acala-network/chopsticks-core';
|
|
3
3
|
import axios from 'axios';
|
|
4
|
-
import yaml from 'js-yaml';
|
|
4
|
+
import * as yaml from 'js-yaml';
|
|
5
5
|
import { defaultLogger } from '../logger.js';
|
|
6
6
|
export const overrideStorage = async (chain, storage, at)=>{
|
|
7
7
|
if (storage == null) {
|
package/package.json
CHANGED
|
@@ -1,79 +1,83 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
2
|
+
"name": "@acala-network/chopsticks",
|
|
3
|
+
"version": "1.6.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/AcalaNetwork/chopsticks"
|
|
7
|
+
},
|
|
8
|
+
"author": "Acala Developers <hello@acala.network>",
|
|
9
|
+
"license": "Apache-2.0",
|
|
10
|
+
"bin": "./chopsticks.cjs",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=v24"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo",
|
|
17
|
+
"build": "bun run clean && ../../package-build.sh",
|
|
18
|
+
"docs:prep": "typedoc",
|
|
19
|
+
"depcheck": "bunx depcheck --ignore-patterns='*.test.ts'"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@acala-network/chopsticks-core": "workspace:*",
|
|
23
|
+
"@acala-network/chopsticks-db": "workspace:*",
|
|
24
|
+
"@dmsnell/diff-match-patch": "^1.1.0",
|
|
25
|
+
"@pnpm/npm-conf": "^3.0.3",
|
|
26
|
+
"@polkadot/api": "^17.0.2",
|
|
27
|
+
"@polkadot/api-augment": "^17.0.2",
|
|
28
|
+
"@polkadot/rpc-provider": "^17.0.2",
|
|
29
|
+
"@polkadot/types": "^17.0.2",
|
|
30
|
+
"@polkadot/util": "^14.0.3",
|
|
31
|
+
"@polkadot/util-crypto": "^14.0.3",
|
|
32
|
+
"axios": "^1.21.1",
|
|
33
|
+
"comlink": "^4.4.2",
|
|
34
|
+
"dotenv": "^18.0.10",
|
|
35
|
+
"global-agent": "^4.1.7",
|
|
36
|
+
"js-yaml": "^5.5.0",
|
|
37
|
+
"jsondiffpatch": "^0.7.7",
|
|
38
|
+
"lodash": "^4.18.1",
|
|
39
|
+
"ws": "^8.22.2",
|
|
40
|
+
"yargs": "^18.2.0",
|
|
41
|
+
"zod": "^4.6.7"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@swc/cli": "0.8.2",
|
|
45
|
+
"@swc/core": "^1.16.22",
|
|
46
|
+
"@types/global-agent": "^3.0.0",
|
|
47
|
+
"@types/js-yaml": "^4.0.9",
|
|
48
|
+
"@types/lodash": "^4.17.27",
|
|
49
|
+
"@types/node": "^26.6.6",
|
|
50
|
+
"@types/ws": "^8.18.2",
|
|
51
|
+
"@types/yargs": "^17.0.35",
|
|
52
|
+
"typescript": "^6.0.3"
|
|
53
|
+
},
|
|
54
|
+
"files": [
|
|
55
|
+
"dist/esm/**",
|
|
56
|
+
"dist/cjs/**",
|
|
57
|
+
"chopsticks.cjs"
|
|
58
|
+
],
|
|
59
|
+
"main": "./dist/cjs/index.js",
|
|
60
|
+
"module": "./dist/esm/index.js",
|
|
61
|
+
"exports": {
|
|
62
|
+
".": {
|
|
63
|
+
"require": "./dist/cjs/index.js",
|
|
64
|
+
"import": "./dist/esm/index.js",
|
|
65
|
+
"default": "./dist/esm/index.js"
|
|
66
|
+
},
|
|
67
|
+
"./*": {
|
|
68
|
+
"require": "./dist/cjs/*.js",
|
|
69
|
+
"import": "./dist/esm/*.js",
|
|
70
|
+
"default": "./dist/esm/*.js"
|
|
71
|
+
},
|
|
72
|
+
"./plugins/*": {
|
|
73
|
+
"require": "./dist/cjs/plugins/*.js",
|
|
74
|
+
"import": "./dist/esm/plugins/*.js",
|
|
75
|
+
"default": "./dist/esm/plugins/*.js"
|
|
76
|
+
},
|
|
77
|
+
"./utils/*": {
|
|
78
|
+
"require": "./dist/cjs/utils/*.js",
|
|
79
|
+
"import": "./dist/esm/utils/*.js",
|
|
80
|
+
"default": "./dist/esm/utils/*.js"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|