@acala-network/chopsticks 0.9.4-6 → 0.9.5-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/dist/cjs/cli.js +6 -34
- package/dist/cjs/context.js +3 -3
- package/dist/cjs/plugins/decode-key/cli.js +4 -6
- package/dist/cjs/plugins/dry-run/cli.js +31 -34
- package/dist/cjs/plugins/dry-run/dry-run-extrinsic.d.ts +2 -2
- package/dist/cjs/plugins/dry-run/dry-run-preimage.d.ts +2 -2
- package/dist/cjs/plugins/dry-run/index.d.ts +160 -0
- package/dist/cjs/plugins/dry-run/index.js +32 -0
- package/dist/cjs/plugins/follow-chain/cli.js +31 -32
- package/dist/cjs/plugins/run-block/__snapshots__/index.test.ts.snap +3301 -0
- package/dist/cjs/plugins/run-block/cli.js +16 -16
- package/dist/cjs/plugins/run-block/rpc.js +2 -1
- package/dist/cjs/plugins/try-runtime/index.js +24 -22
- package/dist/cjs/rpc/index.js +5 -2
- package/dist/cjs/schema/index.d.ts +24 -16
- package/dist/cjs/schema/index.js +85 -16
- package/dist/cjs/setup-with-server.js +3 -4
- package/dist/esm/cli.js +8 -36
- package/dist/esm/context.js +3 -3
- package/dist/esm/plugins/decode-key/cli.js +4 -6
- package/dist/esm/plugins/dry-run/cli.js +31 -34
- package/dist/esm/plugins/dry-run/dry-run-extrinsic.d.ts +2 -2
- package/dist/esm/plugins/dry-run/dry-run-preimage.d.ts +2 -2
- package/dist/esm/plugins/dry-run/index.d.ts +160 -0
- package/dist/esm/plugins/dry-run/index.js +26 -0
- package/dist/esm/plugins/follow-chain/cli.js +30 -31
- package/dist/esm/plugins/run-block/__snapshots__/index.test.ts.snap +3301 -0
- package/dist/esm/plugins/run-block/cli.js +16 -16
- package/dist/esm/plugins/run-block/rpc.js +2 -1
- package/dist/esm/plugins/try-runtime/index.js +24 -22
- package/dist/esm/rpc/index.js +6 -3
- package/dist/esm/schema/index.d.ts +24 -16
- package/dist/esm/schema/index.js +82 -16
- package/dist/esm/setup-with-server.js +3 -4
- package/package.json +8 -8
- package/dist/cjs/cli-options.d.ts +0 -40
- package/dist/cjs/cli-options.js +0 -58
- package/dist/esm/cli-options.d.ts +0 -40
- package/dist/esm/cli-options.js +0 -40
|
@@ -1,2 +1,162 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const dryRunSchema: z.ZodObject<{
|
|
3
|
+
extrinsic: z.ZodString;
|
|
4
|
+
address: z.ZodOptional<z.ZodString>;
|
|
5
|
+
preimage: z.ZodOptional<z.ZodString>;
|
|
6
|
+
at: z.ZodOptional<z.ZodString>;
|
|
7
|
+
"output-path": z.ZodOptional<z.ZodString>;
|
|
8
|
+
html: z.ZodOptional<z.ZodBoolean>;
|
|
9
|
+
open: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
port: z.ZodDefault<z.ZodNumber>;
|
|
11
|
+
endpoint: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
12
|
+
block: z.ZodOptional<z.ZodUnion<[z.ZodIntersection<z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>>, z.ZodNumber, z.ZodNull]>>;
|
|
13
|
+
'build-block-mode': z.ZodDefault<z.ZodNativeEnum<typeof import("@acala-network/chopsticks-core").BuildBlockMode>>;
|
|
14
|
+
'import-storage': z.ZodOptional<z.ZodAny>;
|
|
15
|
+
'allow-unresolved-imports': z.ZodOptional<z.ZodBoolean>;
|
|
16
|
+
'mock-signature-host': z.ZodOptional<z.ZodBoolean>;
|
|
17
|
+
'max-memory-block-count': z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
db: z.ZodOptional<z.ZodString>;
|
|
19
|
+
'wasm-override': z.ZodOptional<z.ZodString>;
|
|
20
|
+
genesis: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
name: z.ZodString;
|
|
23
|
+
properties: z.ZodObject<{
|
|
24
|
+
ss58Format: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
tokenDecimals: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodArray<z.ZodNumber, "many">]>>;
|
|
26
|
+
tokenSymbol: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
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
|
+
}>;
|
|
36
|
+
genesis: z.ZodObject<{
|
|
37
|
+
raw: z.ZodObject<{
|
|
38
|
+
top: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
top: Record<string, string>;
|
|
41
|
+
}, {
|
|
42
|
+
top: Record<string, string>;
|
|
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", z.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
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
81
|
+
'registered-types': z.ZodOptional<z.ZodAny>;
|
|
82
|
+
'runtime-log-level': z.ZodOptional<z.ZodNumber>;
|
|
83
|
+
'offchain-worker': z.ZodOptional<z.ZodBoolean>;
|
|
84
|
+
resume: z.ZodOptional<z.ZodUnion<[z.ZodIntersection<z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>>, z.ZodNumber, z.ZodBoolean]>>;
|
|
85
|
+
}, "strip", z.ZodTypeAny, {
|
|
86
|
+
port: number;
|
|
87
|
+
'build-block-mode': import("@acala-network/chopsticks-core").BuildBlockMode;
|
|
88
|
+
extrinsic: string;
|
|
89
|
+
address?: string | undefined;
|
|
90
|
+
preimage?: string | undefined;
|
|
91
|
+
at?: string | undefined;
|
|
92
|
+
"output-path"?: string | undefined;
|
|
93
|
+
html?: boolean | undefined;
|
|
94
|
+
open?: boolean | undefined;
|
|
95
|
+
endpoint?: string | string[] | undefined;
|
|
96
|
+
block?: number | `0x${string}` | null | undefined;
|
|
97
|
+
'import-storage'?: any;
|
|
98
|
+
'allow-unresolved-imports'?: boolean | undefined;
|
|
99
|
+
'mock-signature-host'?: boolean | undefined;
|
|
100
|
+
'max-memory-block-count'?: number | undefined;
|
|
101
|
+
db?: string | undefined;
|
|
102
|
+
'wasm-override'?: string | undefined;
|
|
103
|
+
genesis?: string | {
|
|
104
|
+
name: string;
|
|
105
|
+
id: string;
|
|
106
|
+
properties: {
|
|
107
|
+
ss58Format?: number | undefined;
|
|
108
|
+
tokenDecimals?: number | number[] | undefined;
|
|
109
|
+
tokenSymbol?: string | string[] | undefined;
|
|
110
|
+
};
|
|
111
|
+
genesis: {
|
|
112
|
+
raw: {
|
|
113
|
+
top: Record<string, string>;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
} | undefined;
|
|
117
|
+
timestamp?: number | undefined;
|
|
118
|
+
'registered-types'?: any;
|
|
119
|
+
'runtime-log-level'?: number | undefined;
|
|
120
|
+
'offchain-worker'?: boolean | undefined;
|
|
121
|
+
resume?: number | boolean | `0x${string}` | undefined;
|
|
122
|
+
}, {
|
|
123
|
+
extrinsic: string;
|
|
124
|
+
address?: string | undefined;
|
|
125
|
+
preimage?: string | undefined;
|
|
126
|
+
at?: string | undefined;
|
|
127
|
+
"output-path"?: string | undefined;
|
|
128
|
+
html?: boolean | undefined;
|
|
129
|
+
open?: boolean | undefined;
|
|
130
|
+
port?: number | undefined;
|
|
131
|
+
endpoint?: string | string[] | undefined;
|
|
132
|
+
block?: number | `0x${string}` | null | undefined;
|
|
133
|
+
'build-block-mode'?: import("@acala-network/chopsticks-core").BuildBlockMode | undefined;
|
|
134
|
+
'import-storage'?: any;
|
|
135
|
+
'allow-unresolved-imports'?: boolean | undefined;
|
|
136
|
+
'mock-signature-host'?: boolean | undefined;
|
|
137
|
+
'max-memory-block-count'?: number | undefined;
|
|
138
|
+
db?: string | undefined;
|
|
139
|
+
'wasm-override'?: string | undefined;
|
|
140
|
+
genesis?: string | {
|
|
141
|
+
name: string;
|
|
142
|
+
id: string;
|
|
143
|
+
properties: {
|
|
144
|
+
ss58Format?: number | undefined;
|
|
145
|
+
tokenDecimals?: number | number[] | undefined;
|
|
146
|
+
tokenSymbol?: string | string[] | undefined;
|
|
147
|
+
};
|
|
148
|
+
genesis: {
|
|
149
|
+
raw: {
|
|
150
|
+
top: Record<string, string>;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
} | undefined;
|
|
154
|
+
timestamp?: number | undefined;
|
|
155
|
+
'registered-types'?: any;
|
|
156
|
+
'runtime-log-level'?: number | undefined;
|
|
157
|
+
'offchain-worker'?: boolean | undefined;
|
|
158
|
+
resume?: number | boolean | `0x${string}` | undefined;
|
|
159
|
+
}>;
|
|
160
|
+
export type DryRunSchemaType = z.infer<typeof dryRunSchema>;
|
|
1
161
|
export * from './cli.js';
|
|
2
162
|
export * from './rpc.js';
|
|
@@ -1,2 +1,28 @@
|
|
|
1
|
+
import { configSchema } from '../../schema/index.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export const dryRunSchema = z.object({
|
|
4
|
+
...configSchema.shape,
|
|
5
|
+
extrinsic: z.string({
|
|
6
|
+
description: 'Extrinsic or call to dry run. If you pass call here then address is required to fake signature'
|
|
7
|
+
}),
|
|
8
|
+
address: z.string({
|
|
9
|
+
description: 'Address to fake sign extrinsic'
|
|
10
|
+
}).optional(),
|
|
11
|
+
preimage: z.string({
|
|
12
|
+
description: 'Preimage to dry run'
|
|
13
|
+
}).optional(),
|
|
14
|
+
at: z.string({
|
|
15
|
+
description: 'Block hash to dry run'
|
|
16
|
+
}).optional(),
|
|
17
|
+
['output-path']: z.string({
|
|
18
|
+
description: 'File path to print output'
|
|
19
|
+
}).optional(),
|
|
20
|
+
html: z.boolean({
|
|
21
|
+
description: 'Generate html with storage diff'
|
|
22
|
+
}).optional(),
|
|
23
|
+
open: z.boolean({
|
|
24
|
+
description: 'Open generated html'
|
|
25
|
+
}).optional()
|
|
26
|
+
});
|
|
1
27
|
export * from './cli.js';
|
|
2
28
|
export * from './rpc.js';
|
|
@@ -1,49 +1,48 @@
|
|
|
1
1
|
import { Block, defaultLogger, runTask, taskHandler } from '@acala-network/chopsticks-core';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
import _ from 'lodash';
|
|
4
|
+
import { configSchema, getYargsOptions } from '../../schema/index.js';
|
|
3
5
|
import { createServer } from '../../server.js';
|
|
4
|
-
import { defaultOptions } from '../../cli-options.js';
|
|
5
6
|
import { handler } from '../../rpc/index.js';
|
|
6
7
|
import { setupContext } from '../../context.js';
|
|
7
8
|
const logger = defaultLogger.child({
|
|
8
9
|
name: 'follow-chain'
|
|
9
10
|
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
var HeadMode;
|
|
12
|
+
(function(HeadMode) {
|
|
13
|
+
HeadMode["Latest"] = "Latest";
|
|
14
|
+
HeadMode["Finalized"] = "Finalized";
|
|
15
|
+
})(HeadMode || (HeadMode = {}));
|
|
16
|
+
const schema = z.object({
|
|
17
|
+
..._.pick(configSchema.shape, [
|
|
18
|
+
'endpoint',
|
|
19
|
+
'port',
|
|
20
|
+
'wasm-override',
|
|
21
|
+
'runtime-log-level',
|
|
22
|
+
'offchain-worker'
|
|
23
|
+
]),
|
|
24
|
+
'head-mode': z.nativeEnum(HeadMode).default("Latest")
|
|
25
|
+
});
|
|
16
26
|
export const cli = (y)=>{
|
|
17
|
-
y.command('follow-chain', 'Always follow the latest block on upstream', (yargs)=>yargs.options({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
desc: 'Head mode',
|
|
25
|
-
choices: [
|
|
26
|
-
'latest',
|
|
27
|
-
'finalized'
|
|
28
|
-
],
|
|
29
|
-
default: 'finalized'
|
|
27
|
+
y.command('follow-chain', 'Always follow the latest block on upstream', (yargs)=>yargs.options(getYargsOptions(schema.shape)), async (argv)=>{
|
|
28
|
+
const config = schema.parse(argv);
|
|
29
|
+
Array.isArray(config.endpoint) ? config.endpoint : [
|
|
30
|
+
config.endpoint || ''
|
|
31
|
+
].forEach((endpoint)=>{
|
|
32
|
+
if (/^(https|http):\/\//.test(endpoint)) {
|
|
33
|
+
throw Error('http provider is not supported');
|
|
30
34
|
}
|
|
31
|
-
})
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
if (/^(https|http):\/\//.test(endpoint || '')) {
|
|
35
|
-
throw Error('http provider is not supported');
|
|
36
|
-
}
|
|
37
|
-
const context = await setupContext(argv, true);
|
|
38
|
-
const { close, port: listenPort } = await createServer(handler(context), port);
|
|
35
|
+
});
|
|
36
|
+
const context = await setupContext(config, true);
|
|
37
|
+
const { close, port: listenPort } = await createServer(handler(context), config.port);
|
|
39
38
|
logger.info(`${await context.chain.api.getSystemChain()} RPC listening on port ${listenPort}`);
|
|
40
39
|
const chain = context.chain;
|
|
41
|
-
chain.api[
|
|
40
|
+
chain.api[config['head-mode'] === "Latest" ? 'subscribeRemoteNewHeads' : 'subscribeRemoteFinalizedHeads'](async (error, data)=>{
|
|
42
41
|
try {
|
|
43
42
|
if (error) throw error;
|
|
44
43
|
logger.info({
|
|
45
44
|
header: data
|
|
46
|
-
}, `Follow ${
|
|
45
|
+
}, `Follow ${config['head-mode']} head from upstream`);
|
|
47
46
|
const parent = await chain.getBlock(data.parentHash);
|
|
48
47
|
if (!parent) throw Error(`Cannot find parent', ${data.parentHash}`);
|
|
49
48
|
const registry = await parent.registry;
|
|
@@ -76,7 +75,7 @@ export const cli = (y)=>{
|
|
|
76
75
|
calls,
|
|
77
76
|
mockSignatureHost: false,
|
|
78
77
|
allowUnresolvedImports: false,
|
|
79
|
-
runtimeLogLevel:
|
|
78
|
+
runtimeLogLevel: config['runtime-log-level'] || 0
|
|
80
79
|
}, taskHandler(parent));
|
|
81
80
|
if ('Error' in result) {
|
|
82
81
|
throw new Error(result.Error);
|