@acala-network/chopsticks 0.9.2-2 → 0.9.2-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/context.js +0 -4
- package/dist/cjs/plugins/decode-key/cli.js +30 -0
- package/dist/cjs/plugins/decode-key/index.js +12 -24
- package/dist/cjs/plugins/dry-run/rpc.js +11 -21
- package/dist/cjs/plugins/follow-chain/cli.js +106 -0
- package/dist/cjs/plugins/follow-chain/index.js +12 -100
- package/dist/cjs/plugins/index.js +21 -14
- package/dist/cjs/plugins/new-block/index.js +14 -35
- package/dist/cjs/plugins/new-block/rpc.js +55 -0
- package/dist/cjs/plugins/run-block/cli.js +84 -0
- package/dist/cjs/plugins/run-block/index.js +12 -229
- package/dist/cjs/plugins/run-block/rpc.js +159 -0
- package/dist/cjs/plugins/set-block-build-mode/index.js +14 -17
- package/dist/cjs/plugins/set-block-build-mode/rpc.js +21 -0
- package/dist/cjs/plugins/set-head/index.js +14 -21
- package/dist/cjs/plugins/set-head/rpc.js +29 -0
- package/dist/cjs/plugins/set-runtime-log-level/index.js +14 -17
- package/dist/cjs/plugins/set-runtime-log-level/rpc.js +21 -0
- package/dist/cjs/plugins/set-storage/index.js +13 -18
- package/dist/cjs/plugins/set-storage/rpc.js +23 -0
- package/dist/cjs/plugins/time-travel/index.js +14 -13
- package/dist/cjs/plugins/time-travel/rpc.js +17 -0
- package/dist/cjs/rpc/index.js +5 -5
- package/dist/cjs/schema/index.js +8 -0
- package/dist/esm/context.js +0 -4
- package/dist/esm/plugins/decode-key/cli.js +20 -0
- package/dist/esm/plugins/decode-key/index.js +1 -20
- package/dist/esm/plugins/dry-run/rpc.js +1 -4
- package/dist/esm/plugins/follow-chain/cli.js +91 -0
- package/dist/esm/plugins/follow-chain/index.js +1 -91
- package/dist/esm/plugins/index.js +15 -10
- package/dist/esm/plugins/new-block/index.js +1 -66
- package/dist/esm/plugins/new-block/rpc.js +82 -0
- package/dist/esm/plugins/run-block/cli.js +74 -0
- package/dist/esm/plugins/run-block/index.js +2 -222
- package/dist/esm/plugins/run-block/rpc.js +148 -0
- package/dist/esm/plugins/set-block-build-mode/index.js +1 -26
- package/dist/esm/plugins/set-block-build-mode/rpc.js +28 -0
- package/dist/esm/plugins/set-head/index.js +1 -29
- package/dist/esm/plugins/set-head/rpc.js +33 -0
- package/dist/esm/plugins/set-runtime-log-level/index.js +1 -25
- package/dist/esm/plugins/set-runtime-log-level/rpc.js +25 -0
- package/dist/esm/plugins/set-storage/index.js +1 -37
- package/dist/esm/plugins/set-storage/rpc.js +37 -0
- package/dist/esm/plugins/time-travel/index.js +1 -21
- package/dist/esm/plugins/time-travel/rpc.js +21 -0
- package/dist/esm/rpc/index.js +6 -6
- package/dist/esm/schema/index.js +2 -0
- package/dist/types/plugins/decode-key/cli.d.ts +2 -0
- package/dist/types/plugins/decode-key/index.d.ts +1 -2
- package/dist/types/plugins/dry-run/rpc.d.ts +0 -1
- package/dist/types/plugins/follow-chain/cli.d.ts +2 -0
- package/dist/types/plugins/follow-chain/index.d.ts +1 -2
- package/dist/types/plugins/index.d.ts +3 -2
- package/dist/types/plugins/new-block/index.d.ts +1 -71
- package/dist/types/plugins/new-block/rpc.d.ts +128 -0
- package/dist/types/plugins/run-block/cli.d.ts +2 -0
- package/dist/types/plugins/run-block/index.d.ts +2 -141
- package/dist/types/plugins/run-block/rpc.d.ts +139 -0
- package/dist/types/plugins/set-block-build-mode/index.d.ts +1 -18
- package/dist/types/plugins/set-block-build-mode/rpc.d.ts +20 -0
- package/dist/types/plugins/set-head/index.d.ts +1 -18
- package/dist/types/plugins/set-head/rpc.d.ts +21 -0
- package/dist/types/plugins/set-runtime-log-level/index.d.ts +1 -17
- package/dist/types/plugins/set-runtime-log-level/rpc.d.ts +17 -0
- package/dist/types/plugins/set-storage/index.d.ts +1 -28
- package/dist/types/plugins/set-storage/rpc.d.ts +28 -0
- package/dist/types/plugins/time-travel/index.d.ts +1 -17
- package/dist/types/plugins/time-travel/rpc.d.ts +17 -0
- package/dist/types/schema/index.d.ts +2 -0
- package/package.json +3 -3
package/dist/esm/rpc/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { ResponseError, logger, substrate } from '@acala-network/chopsticks-core';
|
|
2
|
-
import {
|
|
2
|
+
import { loadRpcPlugin, rpcPluginMethods } from '../plugins/index.js';
|
|
3
3
|
const allHandlers = {
|
|
4
4
|
...substrate,
|
|
5
5
|
rpc_methods: async ()=>Promise.resolve({
|
|
6
6
|
version: 1,
|
|
7
7
|
methods: [
|
|
8
8
|
...Object.keys(allHandlers),
|
|
9
|
-
...
|
|
9
|
+
...rpcPluginMethods
|
|
10
10
|
]
|
|
11
11
|
})
|
|
12
12
|
};
|
|
13
|
-
const getHandler = (method)=>{
|
|
13
|
+
const getHandler = async (method)=>{
|
|
14
14
|
const handler = allHandlers[method];
|
|
15
15
|
if (!handler) {
|
|
16
16
|
// no handler for this method, check if it's a plugin
|
|
17
|
-
return
|
|
17
|
+
return loadRpcPlugin(method);
|
|
18
18
|
}
|
|
19
19
|
return handler;
|
|
20
20
|
};
|
|
21
|
-
export const handler = (context)=>({ method, params }, subscriptionManager)=>{
|
|
21
|
+
export const handler = (context)=>async ({ method, params }, subscriptionManager)=>{
|
|
22
22
|
logger.trace('Handling %s', method);
|
|
23
|
-
const handler = getHandler(method);
|
|
23
|
+
const handler = await getHandler(method);
|
|
24
24
|
if (!handler) {
|
|
25
25
|
logger.warn('Method not found %s', method);
|
|
26
26
|
throw new ResponseError(-32601, `Method not found: ${method}`);
|
package/dist/esm/schema/index.js
CHANGED
|
@@ -5,6 +5,8 @@ import { z } from 'zod';
|
|
|
5
5
|
import _ from 'lodash';
|
|
6
6
|
import axios from 'axios';
|
|
7
7
|
import yaml from 'js-yaml';
|
|
8
|
+
export const zHex = z.custom((val)=>/^0x\w+$/.test(val));
|
|
9
|
+
export const zHash = z.string().length(66).and(zHex);
|
|
8
10
|
export const configSchema = z.object({
|
|
9
11
|
port: z.number().optional(),
|
|
10
12
|
endpoint: z.string().optional(),
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const cli: (y: Argv) => void;
|
|
1
|
+
export * from './cli.js';
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const cli: (y: Argv) => void;
|
|
1
|
+
export * from './cli.js';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Handlers } from '@acala-network/chopsticks-core';
|
|
2
2
|
import type { Argv } from 'yargs';
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
3
|
+
export declare const rpcPluginHandlers: Handlers;
|
|
4
|
+
export declare const rpcPluginMethods: string[];
|
|
5
|
+
export declare const loadRpcPlugin: (method: string) => Promise<any>;
|
|
5
6
|
export declare const pluginExtendCli: (y: Argv) => Promise<void>;
|
|
@@ -1,71 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { HexString } from '@polkadot/util/types';
|
|
3
|
-
export interface NewBlockParams {
|
|
4
|
-
/**
|
|
5
|
-
* The number of blocks to build
|
|
6
|
-
*/
|
|
7
|
-
count: number;
|
|
8
|
-
/**
|
|
9
|
-
* The block number to build to
|
|
10
|
-
*/
|
|
11
|
-
to: number;
|
|
12
|
-
/**
|
|
13
|
-
* The downward messages to include in the block
|
|
14
|
-
*/
|
|
15
|
-
dmp: DownwardMessage[];
|
|
16
|
-
/**
|
|
17
|
-
* The upward messages to include in the block
|
|
18
|
-
*/
|
|
19
|
-
ump: Record<number, HexString[]>;
|
|
20
|
-
/**
|
|
21
|
-
* The horizontal messages to include in the block
|
|
22
|
-
*/
|
|
23
|
-
hrmp: Record<number, HorizontalMessage[]>;
|
|
24
|
-
/**
|
|
25
|
-
* The transactions to include in the block
|
|
26
|
-
*/
|
|
27
|
-
transactions: HexString[];
|
|
28
|
-
/**
|
|
29
|
-
* Build block using a specific block height (unsafe)
|
|
30
|
-
*/
|
|
31
|
-
unsafeBlockHeight: number;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Build new blocks.
|
|
35
|
-
*
|
|
36
|
-
* This function is a dev rpc handler. Use `dev_newBlock` as the method name when calling it.
|
|
37
|
-
*
|
|
38
|
-
* @param context - The context object of the rpc handler
|
|
39
|
-
* @param params - The parameters of the rpc handler
|
|
40
|
-
*
|
|
41
|
-
* @example Build 2 blocks
|
|
42
|
-
* ```ts
|
|
43
|
-
* import { WsProvider } from '@polkadot/rpc-provider'
|
|
44
|
-
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
45
|
-
* await ws.send('dev_newBlock', [{ count: 2 }])
|
|
46
|
-
* ```
|
|
47
|
-
* @example Build a block with upward messages
|
|
48
|
-
* ```ts
|
|
49
|
-
* import { WsProvider } from '@polkadot/rpc-provider'
|
|
50
|
-
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
51
|
-
* await ws.send('dev_newBlock', [
|
|
52
|
-
* {
|
|
53
|
-
* ump: {
|
|
54
|
-
* // https://acala.subscan.io/xcm_message/polkadot-ff66f28818d0b74573e62db8317e354b253fbc80
|
|
55
|
-
* 2000: [
|
|
56
|
-
* '0x021000040000000007903fc4db080a130000000007903fc4db08000d010004000101009c4b11a0974cba4a395c94832fba812868a6cb0ba09e8519b3521093ea359905',
|
|
57
|
-
* ],
|
|
58
|
-
* }
|
|
59
|
-
* }
|
|
60
|
-
* ])
|
|
61
|
-
* ```
|
|
62
|
-
*
|
|
63
|
-
* @example Build two blocks with unsafeBlockHeight
|
|
64
|
-
* ```ts
|
|
65
|
-
* import { WsProvider } from '@polkadot/rpc-provider'
|
|
66
|
-
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
67
|
-
* // this will create two blocks with block height 100000001 and 100000002
|
|
68
|
-
* await ws.send('dev_newBlock', [{ count: 2, unsafeBlockHeight: 100000001 }])
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
export declare const rpc: (context: Context, params: [NewBlockParams]) => Promise<string | undefined>;
|
|
1
|
+
export * from './rpc.js';
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Context } from '@acala-network/chopsticks-core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
declare const schema: z.ZodObject<{
|
|
4
|
+
count: z.ZodOptional<z.ZodNumber>;
|
|
5
|
+
to: z.ZodOptional<z.ZodNumber>;
|
|
6
|
+
dmp: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
7
|
+
sentAt: z.ZodNumber;
|
|
8
|
+
msg: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
sentAt: number;
|
|
11
|
+
msg: `0x${string}`;
|
|
12
|
+
}, {
|
|
13
|
+
sentAt: number;
|
|
14
|
+
msg: `0x${string}`;
|
|
15
|
+
}>, "many">>;
|
|
16
|
+
ump: z.ZodOptional<z.ZodRecord<z.ZodNumber, z.ZodArray<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, "many">>>;
|
|
17
|
+
hrmp: z.ZodOptional<z.ZodRecord<z.ZodNumber, z.ZodArray<z.ZodObject<{
|
|
18
|
+
sentAt: z.ZodNumber;
|
|
19
|
+
data: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
data: `0x${string}`;
|
|
22
|
+
sentAt: number;
|
|
23
|
+
}, {
|
|
24
|
+
data: `0x${string}`;
|
|
25
|
+
sentAt: number;
|
|
26
|
+
}>, "many">>>;
|
|
27
|
+
transactions: z.ZodOptional<z.ZodArray<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, "many">>;
|
|
28
|
+
unsafeBlockHeight: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
}, "strip", z.ZodTypeAny, {
|
|
30
|
+
count?: number | undefined;
|
|
31
|
+
to?: number | undefined;
|
|
32
|
+
dmp?: {
|
|
33
|
+
sentAt: number;
|
|
34
|
+
msg: `0x${string}`;
|
|
35
|
+
}[] | undefined;
|
|
36
|
+
ump?: Record<number, `0x${string}`[]> | undefined;
|
|
37
|
+
hrmp?: Record<number, {
|
|
38
|
+
data: `0x${string}`;
|
|
39
|
+
sentAt: number;
|
|
40
|
+
}[]> | undefined;
|
|
41
|
+
transactions?: `0x${string}`[] | undefined;
|
|
42
|
+
unsafeBlockHeight?: number | undefined;
|
|
43
|
+
}, {
|
|
44
|
+
count?: number | undefined;
|
|
45
|
+
to?: number | undefined;
|
|
46
|
+
dmp?: {
|
|
47
|
+
sentAt: number;
|
|
48
|
+
msg: `0x${string}`;
|
|
49
|
+
}[] | undefined;
|
|
50
|
+
ump?: Record<number, `0x${string}`[]> | undefined;
|
|
51
|
+
hrmp?: Record<number, {
|
|
52
|
+
data: `0x${string}`;
|
|
53
|
+
sentAt: number;
|
|
54
|
+
}[]> | undefined;
|
|
55
|
+
transactions?: `0x${string}`[] | undefined;
|
|
56
|
+
unsafeBlockHeight?: number | undefined;
|
|
57
|
+
}>;
|
|
58
|
+
type Params = z.infer<typeof schema>;
|
|
59
|
+
export interface NewBlockParams {
|
|
60
|
+
/**
|
|
61
|
+
* The number of blocks to build
|
|
62
|
+
*/
|
|
63
|
+
count: Params['count'];
|
|
64
|
+
/**
|
|
65
|
+
* The block number to build to
|
|
66
|
+
*/
|
|
67
|
+
to: Params['to'];
|
|
68
|
+
/**
|
|
69
|
+
* The downward messages to include in the block
|
|
70
|
+
*/
|
|
71
|
+
dmp: Params['dmp'];
|
|
72
|
+
/**
|
|
73
|
+
* The upward messages to include in the block
|
|
74
|
+
*/
|
|
75
|
+
ump: Params['ump'];
|
|
76
|
+
/**
|
|
77
|
+
* The horizontal messages to include in the block
|
|
78
|
+
*/
|
|
79
|
+
hrmp: Params['hrmp'];
|
|
80
|
+
/**
|
|
81
|
+
* The transactions to include in the block
|
|
82
|
+
*/
|
|
83
|
+
transactions: Params['transactions'];
|
|
84
|
+
/**
|
|
85
|
+
* Build block using a specific block height (unsafe)
|
|
86
|
+
*/
|
|
87
|
+
unsafeBlockHeight: Params['unsafeBlockHeight'];
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Build new blocks.
|
|
91
|
+
*
|
|
92
|
+
* This function is a dev rpc handler. Use `dev_newBlock` as the method name when calling it.
|
|
93
|
+
*
|
|
94
|
+
* @param context - The context object of the rpc handler
|
|
95
|
+
* @param params - The parameters of the rpc handler
|
|
96
|
+
*
|
|
97
|
+
* @example Build 2 blocks
|
|
98
|
+
* ```ts
|
|
99
|
+
* import { WsProvider } from '@polkadot/rpc-provider'
|
|
100
|
+
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
101
|
+
* await ws.send('dev_newBlock', [{ count: 2 }])
|
|
102
|
+
* ```
|
|
103
|
+
* @example Build a block with upward messages
|
|
104
|
+
* ```ts
|
|
105
|
+
* import { WsProvider } from '@polkadot/rpc-provider'
|
|
106
|
+
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
107
|
+
* await ws.send('dev_newBlock', [
|
|
108
|
+
* {
|
|
109
|
+
* ump: {
|
|
110
|
+
* // https://acala.subscan.io/xcm_message/polkadot-ff66f28818d0b74573e62db8317e354b253fbc80
|
|
111
|
+
* 2000: [
|
|
112
|
+
* '0x021000040000000007903fc4db080a130000000007903fc4db08000d010004000101009c4b11a0974cba4a395c94832fba812868a6cb0ba09e8519b3521093ea359905',
|
|
113
|
+
* ],
|
|
114
|
+
* }
|
|
115
|
+
* }
|
|
116
|
+
* ])
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* @example Build two blocks with unsafeBlockHeight
|
|
120
|
+
* ```ts
|
|
121
|
+
* import { WsProvider } from '@polkadot/rpc-provider'
|
|
122
|
+
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
123
|
+
* // this will create two blocks with block height 100000001 and 100000002
|
|
124
|
+
* await ws.send('dev_newBlock', [{ count: 2, unsafeBlockHeight: 100000001 }])
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export declare const rpc: (context: Context, [params]: [NewBlockParams]) => Promise<string | undefined>;
|
|
128
|
+
export {};
|
|
@@ -1,141 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type { Argv } from 'yargs';
|
|
4
|
-
import { Context, RuntimeLog } from '@acala-network/chopsticks-core';
|
|
5
|
-
export declare const cli: (y: Argv) => void;
|
|
6
|
-
declare const schema: z.ZodObject<{
|
|
7
|
-
includeRaw: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
-
includeParsed: z.ZodOptional<z.ZodBoolean>;
|
|
9
|
-
includeBlockDetails: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
-
parent: z.ZodOptional<z.ZodIntersection<z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>>>;
|
|
11
|
-
block: z.ZodObject<{
|
|
12
|
-
header: z.ZodAny;
|
|
13
|
-
extrinsics: z.ZodArray<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, "many">;
|
|
14
|
-
}, "strip", z.ZodTypeAny, {
|
|
15
|
-
extrinsics: `0x${string}`[];
|
|
16
|
-
header?: any;
|
|
17
|
-
}, {
|
|
18
|
-
extrinsics: `0x${string}`[];
|
|
19
|
-
header?: any;
|
|
20
|
-
}>;
|
|
21
|
-
}, "strip", z.ZodTypeAny, {
|
|
22
|
-
block: {
|
|
23
|
-
extrinsics: `0x${string}`[];
|
|
24
|
-
header?: any;
|
|
25
|
-
};
|
|
26
|
-
includeRaw?: boolean | undefined;
|
|
27
|
-
includeParsed?: boolean | undefined;
|
|
28
|
-
includeBlockDetails?: boolean | undefined;
|
|
29
|
-
parent?: `0x${string}` | undefined;
|
|
30
|
-
}, {
|
|
31
|
-
block: {
|
|
32
|
-
extrinsics: `0x${string}`[];
|
|
33
|
-
header?: any;
|
|
34
|
-
};
|
|
35
|
-
includeRaw?: boolean | undefined;
|
|
36
|
-
includeParsed?: boolean | undefined;
|
|
37
|
-
includeBlockDetails?: boolean | undefined;
|
|
38
|
-
parent?: `0x${string}` | undefined;
|
|
39
|
-
}>;
|
|
40
|
-
type Params = z.infer<typeof schema>;
|
|
41
|
-
export interface RunBlockParams {
|
|
42
|
-
/**
|
|
43
|
-
* Include raw storage diff. Default to true
|
|
44
|
-
*/
|
|
45
|
-
includeRaw: Params['includeRaw'];
|
|
46
|
-
/**
|
|
47
|
-
* Include parsed storage diff in json format
|
|
48
|
-
*/
|
|
49
|
-
includeParsed: Params['includeParsed'];
|
|
50
|
-
/**
|
|
51
|
-
* Include block details such as parsed extrinsics in json format
|
|
52
|
-
*/
|
|
53
|
-
includeBlockDetails: Params['includeBlockDetails'];
|
|
54
|
-
/**
|
|
55
|
-
* The parent block hash to run on top of. Default to chain head.
|
|
56
|
-
*/
|
|
57
|
-
parent: Params['parent'];
|
|
58
|
-
/**
|
|
59
|
-
* Block to run
|
|
60
|
-
*/
|
|
61
|
-
block: Params['block'];
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* The phase of an execution.
|
|
65
|
-
* `number` means the phase is ApplyExtrinsic and the value is the extrinsic index.
|
|
66
|
-
*/
|
|
67
|
-
export type Phase = 'Initialization' | 'Finalization' | number;
|
|
68
|
-
export interface RunBlockResponse {
|
|
69
|
-
/**
|
|
70
|
-
* The storage diff of each phase.
|
|
71
|
-
*/
|
|
72
|
-
phases: {
|
|
73
|
-
/**
|
|
74
|
-
* The phase of the execution. See {@link Phase}.
|
|
75
|
-
*/
|
|
76
|
-
phase: Phase;
|
|
77
|
-
/**
|
|
78
|
-
* The modified storages of this phase.
|
|
79
|
-
*/
|
|
80
|
-
storageDiff: {
|
|
81
|
-
/**
|
|
82
|
-
* Raw storage diff in bytes. Only available when `includeRaw` is true.
|
|
83
|
-
*/
|
|
84
|
-
raw?: {
|
|
85
|
-
key: HexString;
|
|
86
|
-
value: HexString | null;
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* Decoded storage diff. Only available when `includeParsed` is true.
|
|
90
|
-
*/
|
|
91
|
-
parsed?: {
|
|
92
|
-
method: string;
|
|
93
|
-
section: string;
|
|
94
|
-
key: any[];
|
|
95
|
-
value: any;
|
|
96
|
-
};
|
|
97
|
-
}[];
|
|
98
|
-
/**
|
|
99
|
-
* Runtime logs.
|
|
100
|
-
*/
|
|
101
|
-
logs?: RuntimeLog[];
|
|
102
|
-
}[];
|
|
103
|
-
/**
|
|
104
|
-
* Block details. Only available when `includeBlockDetails` is true.
|
|
105
|
-
*/
|
|
106
|
-
blockDetails?: {
|
|
107
|
-
/**
|
|
108
|
-
* Block timestamp in ms
|
|
109
|
-
*/
|
|
110
|
-
timestamp?: string;
|
|
111
|
-
/**
|
|
112
|
-
* Parsed events in this block.
|
|
113
|
-
*/
|
|
114
|
-
events?: {
|
|
115
|
-
phase: Phase;
|
|
116
|
-
section: string;
|
|
117
|
-
method: string;
|
|
118
|
-
args: any[];
|
|
119
|
-
}[];
|
|
120
|
-
/**
|
|
121
|
-
* Parsed extrinsics in this block.
|
|
122
|
-
*/
|
|
123
|
-
extrinsics: {
|
|
124
|
-
section: string;
|
|
125
|
-
method: string;
|
|
126
|
-
args: any[];
|
|
127
|
-
success: boolean;
|
|
128
|
-
}[];
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
export declare const name = "runBlock";
|
|
132
|
-
/**
|
|
133
|
-
* Run a set of extrinsics on top of a block and get the storage diff
|
|
134
|
-
* and optionally the parsed storage diff and block details.
|
|
135
|
-
* NOTE: The extrinsics should include inherents or tranasctions may have unexpected results.
|
|
136
|
-
* NOTE: system.events and system.extrinsicData are excluded from storage diff to reduce size.
|
|
137
|
-
*
|
|
138
|
-
* This function is a dev rpc handler. Use `dev_runBlock` as the method name when calling it.
|
|
139
|
-
*/
|
|
140
|
-
export declare const rpc: ({ chain }: Context, [params]: [RunBlockParams]) => Promise<RunBlockResponse>;
|
|
141
|
-
export {};
|
|
1
|
+
export * from './cli.js';
|
|
2
|
+
export * from './rpc.js';
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { HexString } from '@polkadot/util/types';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { Context, RuntimeLog } from '@acala-network/chopsticks-core';
|
|
4
|
+
declare const schema: z.ZodObject<{
|
|
5
|
+
includeRaw: z.ZodOptional<z.ZodBoolean>;
|
|
6
|
+
includeParsed: z.ZodOptional<z.ZodBoolean>;
|
|
7
|
+
includeBlockDetails: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
parent: z.ZodOptional<z.ZodIntersection<z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>>>;
|
|
9
|
+
block: z.ZodObject<{
|
|
10
|
+
header: z.ZodAny;
|
|
11
|
+
extrinsics: z.ZodArray<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, "many">;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
extrinsics: `0x${string}`[];
|
|
14
|
+
header?: any;
|
|
15
|
+
}, {
|
|
16
|
+
extrinsics: `0x${string}`[];
|
|
17
|
+
header?: any;
|
|
18
|
+
}>;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
block: {
|
|
21
|
+
extrinsics: `0x${string}`[];
|
|
22
|
+
header?: any;
|
|
23
|
+
};
|
|
24
|
+
includeRaw?: boolean | undefined;
|
|
25
|
+
includeParsed?: boolean | undefined;
|
|
26
|
+
includeBlockDetails?: boolean | undefined;
|
|
27
|
+
parent?: `0x${string}` | undefined;
|
|
28
|
+
}, {
|
|
29
|
+
block: {
|
|
30
|
+
extrinsics: `0x${string}`[];
|
|
31
|
+
header?: any;
|
|
32
|
+
};
|
|
33
|
+
includeRaw?: boolean | undefined;
|
|
34
|
+
includeParsed?: boolean | undefined;
|
|
35
|
+
includeBlockDetails?: boolean | undefined;
|
|
36
|
+
parent?: `0x${string}` | undefined;
|
|
37
|
+
}>;
|
|
38
|
+
type Params = z.infer<typeof schema>;
|
|
39
|
+
export interface RunBlockParams {
|
|
40
|
+
/**
|
|
41
|
+
* Include raw storage diff. Default to true
|
|
42
|
+
*/
|
|
43
|
+
includeRaw: Params['includeRaw'];
|
|
44
|
+
/**
|
|
45
|
+
* Include parsed storage diff in json format
|
|
46
|
+
*/
|
|
47
|
+
includeParsed: Params['includeParsed'];
|
|
48
|
+
/**
|
|
49
|
+
* Include block details such as parsed extrinsics in json format
|
|
50
|
+
*/
|
|
51
|
+
includeBlockDetails: Params['includeBlockDetails'];
|
|
52
|
+
/**
|
|
53
|
+
* The parent block hash to run on top of. Default to chain head.
|
|
54
|
+
*/
|
|
55
|
+
parent: Params['parent'];
|
|
56
|
+
/**
|
|
57
|
+
* Block to run
|
|
58
|
+
*/
|
|
59
|
+
block: Params['block'];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The phase of an execution.
|
|
63
|
+
* `number` means the phase is ApplyExtrinsic and the value is the extrinsic index.
|
|
64
|
+
*/
|
|
65
|
+
export type Phase = 'Initialization' | 'Finalization' | number;
|
|
66
|
+
export interface RunBlockResponse {
|
|
67
|
+
/**
|
|
68
|
+
* The storage diff of each phase.
|
|
69
|
+
*/
|
|
70
|
+
phases: {
|
|
71
|
+
/**
|
|
72
|
+
* The phase of the execution. See {@link Phase}.
|
|
73
|
+
*/
|
|
74
|
+
phase: Phase;
|
|
75
|
+
/**
|
|
76
|
+
* The modified storages of this phase.
|
|
77
|
+
*/
|
|
78
|
+
storageDiff: {
|
|
79
|
+
/**
|
|
80
|
+
* Raw storage diff in bytes. Only available when `includeRaw` is true.
|
|
81
|
+
*/
|
|
82
|
+
raw?: {
|
|
83
|
+
key: HexString;
|
|
84
|
+
value: HexString | null;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Decoded storage diff. Only available when `includeParsed` is true.
|
|
88
|
+
*/
|
|
89
|
+
parsed?: {
|
|
90
|
+
method: string;
|
|
91
|
+
section: string;
|
|
92
|
+
key: any[];
|
|
93
|
+
value: any;
|
|
94
|
+
};
|
|
95
|
+
}[];
|
|
96
|
+
/**
|
|
97
|
+
* Runtime logs.
|
|
98
|
+
*/
|
|
99
|
+
logs?: RuntimeLog[];
|
|
100
|
+
}[];
|
|
101
|
+
/**
|
|
102
|
+
* Block details. Only available when `includeBlockDetails` is true.
|
|
103
|
+
*/
|
|
104
|
+
blockDetails?: {
|
|
105
|
+
/**
|
|
106
|
+
* Block timestamp in ms
|
|
107
|
+
*/
|
|
108
|
+
timestamp?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Parsed events in this block.
|
|
111
|
+
*/
|
|
112
|
+
events?: {
|
|
113
|
+
phase: Phase;
|
|
114
|
+
section: string;
|
|
115
|
+
method: string;
|
|
116
|
+
args: any[];
|
|
117
|
+
}[];
|
|
118
|
+
/**
|
|
119
|
+
* Parsed extrinsics in this block.
|
|
120
|
+
*/
|
|
121
|
+
extrinsics: {
|
|
122
|
+
section: string;
|
|
123
|
+
method: string;
|
|
124
|
+
args: any[];
|
|
125
|
+
success: boolean;
|
|
126
|
+
}[];
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
export declare const name = "runBlock";
|
|
130
|
+
/**
|
|
131
|
+
* Run a set of extrinsics on top of a block and get the storage diff
|
|
132
|
+
* and optionally the parsed storage diff and block details.
|
|
133
|
+
* NOTE: The extrinsics should include inherents or tranasctions may have unexpected results.
|
|
134
|
+
* NOTE: system.events and system.extrinsicData are excluded from storage diff to reduce size.
|
|
135
|
+
*
|
|
136
|
+
* This function is a dev rpc handler. Use `dev_runBlock` as the method name when calling it.
|
|
137
|
+
*/
|
|
138
|
+
export declare const rpc: ({ chain }: Context, [params]: [RunBlockParams]) => Promise<RunBlockResponse>;
|
|
139
|
+
export {};
|
|
@@ -1,18 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Set a build block mode. See [BuildBlockMode](../core/enums/BuildBlockMode).
|
|
4
|
-
*
|
|
5
|
-
* This function is a dev rpc handler. Use `dev_setBlockBuildMode` as the method name when calling it.
|
|
6
|
-
*
|
|
7
|
-
* @param context - The context object of the rpc handler
|
|
8
|
-
* @param params - The parameters of the rpc handler
|
|
9
|
-
*
|
|
10
|
-
* @example Set build block mode to instant
|
|
11
|
-
* ```ts
|
|
12
|
-
* import { WsProvider } from '@polkadot/rpc-provider'
|
|
13
|
-
* import { BuildBlockMode } from '@acala-network/chopsticks-core'
|
|
14
|
-
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
15
|
-
* await ws.send('dev_setBlockBuildMode', [BuildBlockMode.Instant])
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare const rpc: (context: Context, [mode]: [BuildBlockMode]) => Promise<void>;
|
|
1
|
+
export * from './rpc.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BuildBlockMode, Context } from '@acala-network/chopsticks-core';
|
|
2
|
+
/**
|
|
3
|
+
* Set a build block mode. See [BuildBlockMode](../core/enums/BuildBlockMode).
|
|
4
|
+
*
|
|
5
|
+
* 1 - Batch, 2 - Instant, 3 - Manual
|
|
6
|
+
*
|
|
7
|
+
* This function is a dev rpc handler. Use `dev_setBlockBuildMode` as the method name when calling it.
|
|
8
|
+
*
|
|
9
|
+
* @param context - The context object of the rpc handler
|
|
10
|
+
* @param params - The parameters of the rpc handler
|
|
11
|
+
*
|
|
12
|
+
* @example Set build block mode to instant
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { WsProvider } from '@polkadot/rpc-provider'
|
|
15
|
+
* import { BuildBlockMode } from '@acala-network/chopsticks-core'
|
|
16
|
+
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
17
|
+
* await ws.send('dev_setBlockBuildMode', [BuildBlockMode.Instant])
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const rpc: (context: Context, [mode]: [BuildBlockMode]) => Promise<void>;
|
|
@@ -1,18 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { HexString } from '@polkadot/util/types';
|
|
3
|
-
/**
|
|
4
|
-
* Set head.
|
|
5
|
-
*
|
|
6
|
-
* This function is a dev rpc handler. Use `dev_setHead` as the method name when calling it.
|
|
7
|
-
*
|
|
8
|
-
* @param context - The context object of the rpc handler
|
|
9
|
-
* @param hashOrNumber - The block hash or number to set as head
|
|
10
|
-
*
|
|
11
|
-
* @example Set head to block 1000000
|
|
12
|
-
* ```ts
|
|
13
|
-
* import { WsProvider } from '@polkadot/rpc-provider'
|
|
14
|
-
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
15
|
-
* await ws.send('dev_setHead', [1000000])
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare const rpc: (context: Context, [hashOrNumber]: [HexString | number]) => Promise<`0x${string}`>;
|
|
1
|
+
export * from './rpc.js';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Context } from '@acala-network/chopsticks-core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
declare const schema: z.ZodUnion<[z.ZodIntersection<z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>>, z.ZodNumber]>;
|
|
4
|
+
type Params = z.infer<typeof schema>;
|
|
5
|
+
/**
|
|
6
|
+
* Set head.
|
|
7
|
+
*
|
|
8
|
+
* This function is a dev rpc handler. Use `dev_setHead` as the method name when calling it.
|
|
9
|
+
*
|
|
10
|
+
* @param context - The context object of the rpc handler
|
|
11
|
+
* @param hashOrNumber - The block hash or number to set as head
|
|
12
|
+
*
|
|
13
|
+
* @example Set head to block 1000000
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { WsProvider } from '@polkadot/rpc-provider'
|
|
16
|
+
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
17
|
+
* await ws.send('dev_setHead', [1000000])
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const rpc: (context: Context, [params]: [Params]) => Promise<`0x${string}`>;
|
|
21
|
+
export {};
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Set runtime log level.
|
|
4
|
-
*
|
|
5
|
-
* This function is a dev rpc handler. Use `dev_setRuntimeLogLevel` as the method name when calling it.
|
|
6
|
-
*
|
|
7
|
-
* @param context - The context object of the rpc handler
|
|
8
|
-
* @param runtimeLogLevel - The runtime log level to set
|
|
9
|
-
*
|
|
10
|
-
* @example Set runtime log level to 1
|
|
11
|
-
* ```ts
|
|
12
|
-
* import { WsProvider } from '@polkadot/rpc-provider'
|
|
13
|
-
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
14
|
-
* await ws.send('dev_setRuntimeLogLevel', [1])
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export declare const rpc: (context: Context, [runtimeLogLevel]: [number]) => Promise<void>;
|
|
1
|
+
export * from './rpc.js';
|