@acala-network/chopsticks 0.9.4-6 → 0.9.4
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 +3 -5
- 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/cli.js +16 -16
- 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 +3 -5
- 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/cli.js +16 -16
- 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 +3 -3
- 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
package/dist/cjs/cli.js
CHANGED
|
@@ -8,7 +8,6 @@ const _lodash = /*#__PURE__*/ _interop_require_default(require("lodash"));
|
|
|
8
8
|
const _yargs = /*#__PURE__*/ _interop_require_default(require("yargs"));
|
|
9
9
|
const _chopstickscore = require("@acala-network/chopsticks-core");
|
|
10
10
|
const _index = require("./schema/index.js");
|
|
11
|
-
const _clioptions = require("./cli-options.js");
|
|
12
11
|
const _index1 = require("./plugins/index.js");
|
|
13
12
|
const _index2 = require("./index.js");
|
|
14
13
|
function _interop_require_default(obj) {
|
|
@@ -21,39 +20,12 @@ const processArgv = async (argv)=>{
|
|
|
21
20
|
if (argv.config) {
|
|
22
21
|
Object.assign(argv, _lodash.default.defaults(argv, await (0, _index.fetchConfig)(argv.config)));
|
|
23
22
|
}
|
|
24
|
-
|
|
23
|
+
if (process.env.PORT) {
|
|
24
|
+
argv.port = Number(process.env.PORT);
|
|
25
|
+
}
|
|
25
26
|
};
|
|
26
|
-
const commands = (0, _yargs.default)((0, _helpers.hideBin)(process.argv)).scriptName('chopsticks').middleware(processArgv, false).command('*', 'Dev mode, fork off a chain', (yargs)=>yargs.options({
|
|
27
|
-
|
|
28
|
-
..._clioptions.mockOptions,
|
|
29
|
-
port: {
|
|
30
|
-
desc: 'Port to listen on',
|
|
31
|
-
number: true
|
|
32
|
-
},
|
|
33
|
-
'build-block-mode': {
|
|
34
|
-
desc: 'Build block mode. Default to Batch',
|
|
35
|
-
enum: [
|
|
36
|
-
_chopstickscore.BuildBlockMode.Batch,
|
|
37
|
-
_chopstickscore.BuildBlockMode.Manual,
|
|
38
|
-
_chopstickscore.BuildBlockMode.Instant
|
|
39
|
-
]
|
|
40
|
-
},
|
|
41
|
-
'allow-unresolved-imports': {
|
|
42
|
-
desc: 'Allow wasm unresolved imports',
|
|
43
|
-
boolean: true
|
|
44
|
-
},
|
|
45
|
-
'max-memory-block-count': {
|
|
46
|
-
desc: 'Max memory block count',
|
|
47
|
-
number: true
|
|
48
|
-
},
|
|
49
|
-
resume: {
|
|
50
|
-
desc: `Resume from the specified block hash or block number in db.
|
|
51
|
-
If true, it will resume from the latest block in db.
|
|
52
|
-
Note this will override the block option`,
|
|
53
|
-
string: true
|
|
54
|
-
}
|
|
55
|
-
}), async (argv)=>{
|
|
56
|
-
await (0, _index2.setupWithServer)(argv);
|
|
27
|
+
const commands = (0, _yargs.default)((0, _helpers.hideBin)(process.argv)).scriptName('chopsticks').middleware(processArgv, false).command('*', 'Dev mode, fork off a chain', (yargs)=>yargs.config('config', 'Path to config file with default options', ()=>({})).options((0, _index.getYargsOptions)(_index.configSchema.shape)), async (argv)=>{
|
|
28
|
+
await (0, _index2.setupWithServer)(_index.configSchema.parse(argv));
|
|
57
29
|
}).command('xcm', 'XCM setup with relaychain and parachains', (yargs)=>yargs.options({
|
|
58
30
|
relaychain: {
|
|
59
31
|
desc: 'Relaychain config file path',
|
|
@@ -82,7 +54,7 @@ const commands = (0, _yargs.default)((0, _helpers.hideBin)(process.argv)).script
|
|
|
82
54
|
}
|
|
83
55
|
}).strict().help().alias('help', 'h').alias('version', 'v').alias('config', 'c').alias('endpoint', 'e').alias('port', 'p').alias('block', 'b').alias('import-storage', 's').alias('wasm-override', 'w').usage('Usage: $0 <command> [options]').example('$0', '-c acala');
|
|
84
56
|
if (!process.env.DISABLE_PLUGINS) {
|
|
85
|
-
(0, _index1.pluginExtendCli)(commands).then(()=>commands.parse());
|
|
57
|
+
(0, _index1.pluginExtendCli)(commands.config('config', 'Path to config file with default options', ()=>({}))).then(()=>commands.parse());
|
|
86
58
|
} else {
|
|
87
59
|
commands.parse();
|
|
88
60
|
}
|
package/dist/cjs/context.js
CHANGED
|
@@ -112,10 +112,10 @@ const setupContext = async (argv, overrideParent = false)=>{
|
|
|
112
112
|
let blockData = null;
|
|
113
113
|
if (typeof argv.resume === 'string' && argv.resume.startsWith('0x')) {
|
|
114
114
|
blockData = await chain.db.queryBlock(argv.resume);
|
|
115
|
-
} else if (typeof argv.resume === '
|
|
115
|
+
} else if (typeof argv.resume === 'number') {
|
|
116
|
+
blockData = await chain.db.queryBlockByNumber(argv.resume);
|
|
117
|
+
} else if (argv.resume === true) {
|
|
116
118
|
blockData = await chain.db.queryHighestBlock();
|
|
117
|
-
} else if (Number.isInteger(+argv.resume)) {
|
|
118
|
-
blockData = await chain.db.queryBlockByNumber(+argv.resume);
|
|
119
119
|
} else {
|
|
120
120
|
throw new Error(`Resume failed. Invalid resume option ${argv.resume}`);
|
|
121
121
|
}
|
|
@@ -8,17 +8,15 @@ Object.defineProperty(exports, "cli", {
|
|
|
8
8
|
return cli;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
+
const _index = require("../../schema/index.js");
|
|
11
12
|
const _chopstickscore = require("@acala-network/chopsticks-core");
|
|
12
|
-
const _clioptions = require("../../cli-options.js");
|
|
13
13
|
const _context = require("../../context.js");
|
|
14
14
|
const cli = (y)=>{
|
|
15
|
-
y.command('decode-key <key>', 'Deocde a key', (yargs)=>yargs.positional('key', {
|
|
15
|
+
y.command('decode-key <key>', 'Deocde a key', (yargs)=>yargs.options((0, _index.getYargsOptions)(_index.configSchema.shape)).positional('key', {
|
|
16
16
|
desc: 'Key to decode',
|
|
17
17
|
type: 'string'
|
|
18
|
-
}).options({
|
|
19
|
-
..._clioptions.defaultOptions
|
|
20
18
|
}), async (argv)=>{
|
|
21
|
-
const context = await (0, _context.setupContext)(argv);
|
|
19
|
+
const context = await (0, _context.setupContext)(_index.configSchema.parse(argv));
|
|
22
20
|
const { storage, decodedKey } = (0, _chopstickscore.decodeKey)(await context.chain.head.meta, context.chain.head, argv.key);
|
|
23
21
|
if (storage && decodedKey) {
|
|
24
22
|
console.log(`${storage.section}.${storage.method}`, decodedKey.args.map((x)=>JSON.stringify(x.toHuman())).join(', '));
|
|
@@ -8,44 +8,41 @@ Object.defineProperty(exports, "cli", {
|
|
|
8
8
|
return cli;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const
|
|
11
|
+
const _index = require("../../schema/index.js");
|
|
12
12
|
const _dryrunextrinsic = require("./dry-run-extrinsic.js");
|
|
13
13
|
const _dryrunpreimage = require("./dry-run-preimage.js");
|
|
14
|
+
const _zod = require("zod");
|
|
15
|
+
const schema = _zod.z.object({
|
|
16
|
+
..._index.configSchema.shape,
|
|
17
|
+
extrinsic: _zod.z.string({
|
|
18
|
+
description: 'Extrinsic or call to dry run. If you pass call here then address is required to fake signature'
|
|
19
|
+
}),
|
|
20
|
+
address: _zod.z.string({
|
|
21
|
+
description: 'Address to fake sign extrinsic'
|
|
22
|
+
}).optional(),
|
|
23
|
+
preimage: _zod.z.string({
|
|
24
|
+
description: 'Preimage to dry run'
|
|
25
|
+
}).optional(),
|
|
26
|
+
at: _zod.z.string({
|
|
27
|
+
description: 'Block hash to dry run'
|
|
28
|
+
}).optional(),
|
|
29
|
+
['output-path']: _zod.z.string({
|
|
30
|
+
description: 'File path to print output'
|
|
31
|
+
}).optional(),
|
|
32
|
+
html: _zod.z.boolean({
|
|
33
|
+
description: 'Generate html with storage diff'
|
|
34
|
+
}).optional(),
|
|
35
|
+
open: _zod.z.boolean({
|
|
36
|
+
description: 'Open generated html'
|
|
37
|
+
}).optional()
|
|
38
|
+
});
|
|
14
39
|
const cli = (y)=>{
|
|
15
|
-
y.command('dry-run', 'Dry run an extrinsic', (yargs)=>yargs.options({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
desc: 'Extrinsic or call to dry run. If you pass call here then address is required to fake signature',
|
|
20
|
-
string: true
|
|
21
|
-
},
|
|
22
|
-
address: {
|
|
23
|
-
desc: 'Address to fake sign extrinsic',
|
|
24
|
-
string: true
|
|
25
|
-
},
|
|
26
|
-
preimage: {
|
|
27
|
-
desc: 'Preimage to dry run',
|
|
28
|
-
string: true
|
|
29
|
-
},
|
|
30
|
-
at: {
|
|
31
|
-
desc: 'Block hash to dry run',
|
|
32
|
-
string: true
|
|
33
|
-
},
|
|
34
|
-
'output-path': {
|
|
35
|
-
desc: 'File path to print output',
|
|
36
|
-
string: true
|
|
37
|
-
},
|
|
38
|
-
html: {
|
|
39
|
-
desc: 'Generate html with storage diff'
|
|
40
|
-
},
|
|
41
|
-
open: {
|
|
42
|
-
desc: 'Open generated html'
|
|
43
|
-
}
|
|
44
|
-
}), async (argv)=>{
|
|
45
|
-
if (argv.preimage) {
|
|
46
|
-
await (0, _dryrunpreimage.dryRunPreimage)(argv);
|
|
40
|
+
y.command('dry-run', 'Dry run an extrinsic', (yargs)=>yargs.options((0, _index.getYargsOptions)(schema.shape)), async (argv)=>{
|
|
41
|
+
const config = schema.parse(argv);
|
|
42
|
+
if (config.preimage) {
|
|
43
|
+
await (0, _dryrunpreimage.dryRunPreimage)(config);
|
|
47
44
|
} else {
|
|
48
|
-
await (0, _dryrunextrinsic.dryRunExtrinsic)(
|
|
45
|
+
await (0, _dryrunextrinsic.dryRunExtrinsic)(config);
|
|
49
46
|
}
|
|
50
47
|
});
|
|
51
48
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const dryRunExtrinsic: (argv:
|
|
1
|
+
import { DryRunSchemaType } from './index.js';
|
|
2
|
+
export declare const dryRunExtrinsic: (argv: DryRunSchemaType) => Promise<never>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const dryRunPreimage: (argv:
|
|
1
|
+
import { DryRunSchemaType } from './index.js';
|
|
2
|
+
export declare const dryRunPreimage: (argv: DryRunSchemaType) => Promise<never>;
|
|
@@ -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';
|
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
+
Object.defineProperty(exports, "dryRunSchema", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return dryRunSchema;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _index = require("../../schema/index.js");
|
|
12
|
+
const _zod = require("zod");
|
|
5
13
|
_export_star(require("./cli.js"), exports);
|
|
6
14
|
_export_star(require("./rpc.js"), exports);
|
|
7
15
|
function _export_star(from, to) {
|
|
@@ -17,3 +25,27 @@ function _export_star(from, to) {
|
|
|
17
25
|
});
|
|
18
26
|
return from;
|
|
19
27
|
}
|
|
28
|
+
const dryRunSchema = _zod.z.object({
|
|
29
|
+
..._index.configSchema.shape,
|
|
30
|
+
extrinsic: _zod.z.string({
|
|
31
|
+
description: 'Extrinsic or call to dry run. If you pass call here then address is required to fake signature'
|
|
32
|
+
}),
|
|
33
|
+
address: _zod.z.string({
|
|
34
|
+
description: 'Address to fake sign extrinsic'
|
|
35
|
+
}).optional(),
|
|
36
|
+
preimage: _zod.z.string({
|
|
37
|
+
description: 'Preimage to dry run'
|
|
38
|
+
}).optional(),
|
|
39
|
+
at: _zod.z.string({
|
|
40
|
+
description: 'Block hash to dry run'
|
|
41
|
+
}).optional(),
|
|
42
|
+
['output-path']: _zod.z.string({
|
|
43
|
+
description: 'File path to print output'
|
|
44
|
+
}).optional(),
|
|
45
|
+
html: _zod.z.boolean({
|
|
46
|
+
description: 'Generate html with storage diff'
|
|
47
|
+
}).optional(),
|
|
48
|
+
open: _zod.z.boolean({
|
|
49
|
+
description: 'Open generated html'
|
|
50
|
+
}).optional()
|
|
51
|
+
});
|
|
@@ -9,10 +9,11 @@ Object.defineProperty(exports, "cli", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _chopstickscore = require("@acala-network/chopsticks-core");
|
|
12
|
+
const _zod = require("zod");
|
|
12
13
|
const _lodash = /*#__PURE__*/ _interop_require_default(require("lodash"));
|
|
14
|
+
const _index = require("../../schema/index.js");
|
|
13
15
|
const _server = require("../../server.js");
|
|
14
|
-
const
|
|
15
|
-
const _index = require("../../rpc/index.js");
|
|
16
|
+
const _index1 = require("../../rpc/index.js");
|
|
16
17
|
const _context = require("../../context.js");
|
|
17
18
|
function _interop_require_default(obj) {
|
|
18
19
|
return obj && obj.__esModule ? obj : {
|
|
@@ -22,43 +23,41 @@ function _interop_require_default(obj) {
|
|
|
22
23
|
const logger = _chopstickscore.defaultLogger.child({
|
|
23
24
|
name: 'follow-chain'
|
|
24
25
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
var HeadMode;
|
|
27
|
+
(function(HeadMode) {
|
|
28
|
+
HeadMode["Latest"] = "Latest";
|
|
29
|
+
HeadMode["Finalized"] = "Finalized";
|
|
30
|
+
})(HeadMode || (HeadMode = {}));
|
|
31
|
+
const schema = _zod.z.object({
|
|
32
|
+
..._lodash.default.pick(_index.configSchema.shape, [
|
|
33
|
+
'endpoint',
|
|
34
|
+
'port',
|
|
35
|
+
'wasm-override',
|
|
36
|
+
'runtime-log-level',
|
|
37
|
+
'offchain-worker'
|
|
38
|
+
]),
|
|
39
|
+
'head-mode': _zod.z.nativeEnum(HeadMode).default("Latest")
|
|
40
|
+
});
|
|
31
41
|
const cli = (y)=>{
|
|
32
|
-
y.command('follow-chain', 'Always follow the latest block on upstream', (yargs)=>yargs.options({
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
desc: 'Head mode',
|
|
40
|
-
choices: [
|
|
41
|
-
'latest',
|
|
42
|
-
'finalized'
|
|
43
|
-
],
|
|
44
|
-
default: 'finalized'
|
|
42
|
+
y.command('follow-chain', 'Always follow the latest block on upstream', (yargs)=>yargs.options((0, _index.getYargsOptions)(schema.shape)), async (argv)=>{
|
|
43
|
+
const config = schema.parse(argv);
|
|
44
|
+
Array.isArray(config.endpoint) ? config.endpoint : [
|
|
45
|
+
config.endpoint || ''
|
|
46
|
+
].forEach((endpoint)=>{
|
|
47
|
+
if (/^(https|http):\/\//.test(endpoint)) {
|
|
48
|
+
throw Error('http provider is not supported');
|
|
45
49
|
}
|
|
46
|
-
})
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
if (/^(https|http):\/\//.test(endpoint || '')) {
|
|
50
|
-
throw Error('http provider is not supported');
|
|
51
|
-
}
|
|
52
|
-
const context = await (0, _context.setupContext)(argv, true);
|
|
53
|
-
const { close, port: listenPort } = await (0, _server.createServer)((0, _index.handler)(context), port);
|
|
50
|
+
});
|
|
51
|
+
const context = await (0, _context.setupContext)(config, true);
|
|
52
|
+
const { close, port: listenPort } = await (0, _server.createServer)((0, _index1.handler)(context), config.port);
|
|
54
53
|
logger.info(`${await context.chain.api.getSystemChain()} RPC listening on port ${listenPort}`);
|
|
55
54
|
const chain = context.chain;
|
|
56
|
-
chain.api[
|
|
55
|
+
chain.api[config['head-mode'] === "Latest" ? 'subscribeRemoteNewHeads' : 'subscribeRemoteFinalizedHeads'](async (error, data)=>{
|
|
57
56
|
try {
|
|
58
57
|
if (error) throw error;
|
|
59
58
|
logger.info({
|
|
60
59
|
header: data
|
|
61
|
-
}, `Follow ${
|
|
60
|
+
}, `Follow ${config['head-mode']} head from upstream`);
|
|
62
61
|
const parent = await chain.getBlock(data.parentHash);
|
|
63
62
|
if (!parent) throw Error(`Cannot find parent', ${data.parentHash}`);
|
|
64
63
|
const registry = await parent.registry;
|
|
@@ -91,7 +90,7 @@ const cli = (y)=>{
|
|
|
91
90
|
calls,
|
|
92
91
|
mockSignatureHost: false,
|
|
93
92
|
allowUnresolvedImports: false,
|
|
94
|
-
runtimeLogLevel:
|
|
93
|
+
runtimeLogLevel: config['runtime-log-level'] || 0
|
|
95
94
|
}, (0, _chopstickscore.taskHandler)(parent));
|
|
96
95
|
if ('Error' in result) {
|
|
97
96
|
throw new Error(result.Error);
|
|
@@ -9,27 +9,27 @@ Object.defineProperty(exports, "cli", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _nodefs = require("node:fs");
|
|
12
|
+
const _zod = require("zod");
|
|
12
13
|
const _chopstickscore = require("@acala-network/chopsticks-core");
|
|
13
|
-
const
|
|
14
|
+
const _index = require("../../schema/index.js");
|
|
14
15
|
const _generatehtmldiff = require("../../utils/generate-html-diff.js");
|
|
15
16
|
const _openhtml = require("../../utils/open-html.js");
|
|
16
17
|
const _context = require("../../context.js");
|
|
18
|
+
const schema = _zod.z.object({
|
|
19
|
+
..._index.configSchema.shape,
|
|
20
|
+
['output-path']: _zod.z.string({
|
|
21
|
+
description: 'File path to print output'
|
|
22
|
+
}).optional(),
|
|
23
|
+
html: _zod.z.boolean({
|
|
24
|
+
description: 'Generate html with storage diff'
|
|
25
|
+
}).optional(),
|
|
26
|
+
open: _zod.z.boolean({
|
|
27
|
+
description: 'Open generated html'
|
|
28
|
+
}).optional()
|
|
29
|
+
});
|
|
17
30
|
const cli = (y)=>{
|
|
18
|
-
y.command('run-block', 'Replay a block', (yargs)=>yargs.options({
|
|
19
|
-
|
|
20
|
-
..._clioptions.mockOptions,
|
|
21
|
-
'output-path': {
|
|
22
|
-
desc: 'File path to print output',
|
|
23
|
-
string: true
|
|
24
|
-
},
|
|
25
|
-
html: {
|
|
26
|
-
desc: 'Generate html with storage diff'
|
|
27
|
-
},
|
|
28
|
-
open: {
|
|
29
|
-
desc: 'Open generated html'
|
|
30
|
-
}
|
|
31
|
-
}), async (argv)=>{
|
|
32
|
-
const context = await (0, _context.setupContext)(argv, true);
|
|
31
|
+
y.command('run-block', 'Replay a block', (yargs)=>yargs.options((0, _index.getYargsOptions)(schema.shape)), async (argv)=>{
|
|
32
|
+
const context = await (0, _context.setupContext)(schema.parse(argv), true);
|
|
33
33
|
const header = await context.chain.head.header;
|
|
34
34
|
const block = context.chain.head;
|
|
35
35
|
const parent = await block.parentBlock;
|
|
@@ -9,32 +9,34 @@ Object.defineProperty(exports, "cli", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _nodefs = require("node:fs");
|
|
12
|
-
const
|
|
12
|
+
const _zod = require("zod");
|
|
13
|
+
const _index = require("../../schema/index.js");
|
|
13
14
|
const _generatehtmldiff = require("../../utils/generate-html-diff.js");
|
|
14
15
|
const _openhtml = require("../../utils/open-html.js");
|
|
15
16
|
const _context = require("../../context.js");
|
|
17
|
+
const schema = _zod.z.object({
|
|
18
|
+
endpoint: _index.configSchema.shape.endpoint,
|
|
19
|
+
port: _index.configSchema.shape.port,
|
|
20
|
+
['build-block-mode']: _index.configSchema.shape['build-block-mode'],
|
|
21
|
+
block: _index.configSchema.shape.block,
|
|
22
|
+
db: _index.configSchema.shape.db,
|
|
23
|
+
['runtime-log-level']: _index.configSchema.shape['runtime-log-level'],
|
|
24
|
+
['wasm-override']: _zod.z.string({
|
|
25
|
+
description: 'Path to WASM built with feature `try-runtime` enabled'
|
|
26
|
+
}),
|
|
27
|
+
['output-path']: _zod.z.string({
|
|
28
|
+
description: 'File path to print output'
|
|
29
|
+
}).optional(),
|
|
30
|
+
html: _zod.z.boolean({
|
|
31
|
+
description: 'Generate html with storage diff'
|
|
32
|
+
}).optional(),
|
|
33
|
+
open: _zod.z.boolean({
|
|
34
|
+
description: 'Open generated html'
|
|
35
|
+
}).optional()
|
|
36
|
+
});
|
|
16
37
|
const cli = (y)=>{
|
|
17
|
-
y.command('try-runtime', 'Runs runtime upgrade', (yargs)=>yargs.options({
|
|
18
|
-
|
|
19
|
-
'wasm-override': {
|
|
20
|
-
desc: 'Path to WASM built with feature `try-runtime` enabled',
|
|
21
|
-
string: true,
|
|
22
|
-
required: true
|
|
23
|
-
},
|
|
24
|
-
'output-path': {
|
|
25
|
-
desc: 'File path to print output',
|
|
26
|
-
string: true
|
|
27
|
-
},
|
|
28
|
-
html: {
|
|
29
|
-
desc: 'Generate html with storage diff',
|
|
30
|
-
boolean: true
|
|
31
|
-
},
|
|
32
|
-
open: {
|
|
33
|
-
desc: 'Open generated html',
|
|
34
|
-
boolean: true
|
|
35
|
-
}
|
|
36
|
-
}), async (argv)=>{
|
|
37
|
-
const context = await (0, _context.setupContext)(argv);
|
|
38
|
+
y.command('try-runtime', 'Runs runtime upgrade', (yargs)=>yargs.options((0, _index.getYargsOptions)(schema.shape)), async (argv)=>{
|
|
39
|
+
const context = await (0, _context.setupContext)(schema.parse(argv));
|
|
38
40
|
const block = context.chain.head;
|
|
39
41
|
const registry = await block.registry;
|
|
40
42
|
registry.register({
|
package/dist/cjs/rpc/index.js
CHANGED
|
@@ -10,6 +10,9 @@ Object.defineProperty(exports, "handler", {
|
|
|
10
10
|
});
|
|
11
11
|
const _chopstickscore = require("@acala-network/chopsticks-core");
|
|
12
12
|
const _index = require("../plugins/index.js");
|
|
13
|
+
const rpcLogger = _chopstickscore.defaultLogger.child({
|
|
14
|
+
module: 'rpc'
|
|
15
|
+
});
|
|
13
16
|
const allHandlers = {
|
|
14
17
|
..._chopstickscore.substrate,
|
|
15
18
|
rpc_methods: async ()=>Promise.resolve({
|
|
@@ -29,10 +32,10 @@ const getHandler = async (method)=>{
|
|
|
29
32
|
return handler;
|
|
30
33
|
};
|
|
31
34
|
const handler = (context)=>async ({ method, params }, subscriptionManager)=>{
|
|
32
|
-
|
|
35
|
+
rpcLogger.trace('Handling %s', method);
|
|
33
36
|
const handler = await getHandler(method);
|
|
34
37
|
if (!handler) {
|
|
35
|
-
|
|
38
|
+
rpcLogger.warn('Method not found %s', method);
|
|
36
39
|
throw new _chopstickscore.ResponseError(-32601, `Method not found: ${method}`);
|
|
37
40
|
}
|
|
38
41
|
return handler(context, params, subscriptionManager);
|