@acala-network/chopsticks 0.8.1 → 0.8.3
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/lib/plugins/dry-run/rpc.d.ts +139 -2
- package/lib/plugins/dry-run/rpc.js +30 -0
- package/lib/plugins/new-block/index.d.ts +72 -2
- package/lib/plugins/new-block/index.js +40 -1
- package/lib/plugins/set-block-build-mode/index.d.ts +19 -2
- package/lib/plugins/set-block-build-mode/index.js +16 -0
- package/lib/plugins/set-head/index.d.ts +18 -2
- package/lib/plugins/set-head/index.js +15 -0
- package/lib/plugins/set-runtime-log-level/index.d.ts +17 -2
- package/lib/plugins/set-runtime-log-level/index.js +15 -0
- package/lib/plugins/set-storage/index.d.ts +29 -2
- package/lib/plugins/set-storage/index.js +25 -0
- package/lib/plugins/time-travel/index.d.ts +17 -2
- package/lib/plugins/time-travel/index.js +15 -0
- package/lib/plugins/types.d.ts +7 -0
- package/lib/plugins/types.js +17 -0
- package/lib/rpc/index.d.ts +1 -1
- package/lib/rpc/shared.d.ts +4 -1
- package/lib/rpc/substrate/author.d.ts +28 -3
- package/lib/rpc/substrate/author.js +78 -54
- package/lib/rpc/substrate/chain.d.ts +44 -6
- package/lib/rpc/substrate/chain.js +84 -61
- package/lib/rpc/substrate/index.d.ts +64 -2
- package/lib/rpc/substrate/index.js +38 -12
- package/lib/rpc/substrate/payment.d.ts +16 -3
- package/lib/rpc/substrate/payment.js +41 -29
- package/lib/rpc/substrate/state.d.ts +97 -3
- package/lib/rpc/substrate/state.js +170 -92
- package/lib/rpc/substrate/system.d.ts +28 -3
- package/lib/rpc/substrate/system.js +60 -41
- package/lib/types.d.ts +16 -0
- package/lib/types.js +18 -0
- package/lib/utils/signFake.d.ts +2 -2
- package/lib/utils/signFake.js +1 -2
- package/package.json +10 -9
|
@@ -1,3 +1,140 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../rpc/shared';
|
|
3
|
+
declare const schema: z.ZodObject<{
|
|
4
|
+
raw: z.ZodOptional<z.ZodBoolean>;
|
|
5
|
+
html: z.ZodOptional<z.ZodBoolean>;
|
|
6
|
+
extrinsic: z.ZodOptional<z.ZodUnion<[z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodObject<{
|
|
7
|
+
call: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
|
|
8
|
+
address: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
address: `0x${string}`;
|
|
11
|
+
call: `0x${string}`;
|
|
12
|
+
}, {
|
|
13
|
+
address: `0x${string}`;
|
|
14
|
+
call: `0x${string}`;
|
|
15
|
+
}>]>>;
|
|
16
|
+
hrmp: z.ZodOptional<z.ZodRecord<z.ZodEffects<z.ZodString, number, string>, z.ZodArray<z.ZodObject<{
|
|
17
|
+
sentAt: z.ZodNumber;
|
|
18
|
+
data: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
data: `0x${string}`;
|
|
21
|
+
sentAt: number;
|
|
22
|
+
}, {
|
|
23
|
+
data: `0x${string}`;
|
|
24
|
+
sentAt: number;
|
|
25
|
+
}>, "many">>>;
|
|
26
|
+
dmp: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
27
|
+
sentAt: z.ZodNumber;
|
|
28
|
+
msg: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
|
|
29
|
+
}, "strip", z.ZodTypeAny, {
|
|
30
|
+
sentAt: number;
|
|
31
|
+
msg: `0x${string}`;
|
|
32
|
+
}, {
|
|
33
|
+
sentAt: number;
|
|
34
|
+
msg: `0x${string}`;
|
|
35
|
+
}>, "many">>;
|
|
36
|
+
ump: z.ZodOptional<z.ZodRecord<z.ZodEffects<z.ZodString, number, string>, z.ZodArray<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, "many">>>;
|
|
37
|
+
at: z.ZodOptional<z.ZodIntersection<z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>>>;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
raw?: boolean | undefined;
|
|
40
|
+
html?: boolean | undefined;
|
|
41
|
+
extrinsic?: `0x${string}` | {
|
|
42
|
+
address: `0x${string}`;
|
|
43
|
+
call: `0x${string}`;
|
|
44
|
+
} | undefined;
|
|
45
|
+
hrmp?: Record<number, {
|
|
46
|
+
data: `0x${string}`;
|
|
47
|
+
sentAt: number;
|
|
48
|
+
}[]> | undefined;
|
|
49
|
+
dmp?: {
|
|
50
|
+
sentAt: number;
|
|
51
|
+
msg: `0x${string}`;
|
|
52
|
+
}[] | undefined;
|
|
53
|
+
ump?: Record<number, `0x${string}`[]> | undefined;
|
|
54
|
+
at?: `0x${string}` | undefined;
|
|
55
|
+
}, {
|
|
56
|
+
raw?: boolean | undefined;
|
|
57
|
+
html?: boolean | undefined;
|
|
58
|
+
extrinsic?: `0x${string}` | {
|
|
59
|
+
address: `0x${string}`;
|
|
60
|
+
call: `0x${string}`;
|
|
61
|
+
} | undefined;
|
|
62
|
+
hrmp?: Record<string, {
|
|
63
|
+
data: `0x${string}`;
|
|
64
|
+
sentAt: number;
|
|
65
|
+
}[]> | undefined;
|
|
66
|
+
dmp?: {
|
|
67
|
+
sentAt: number;
|
|
68
|
+
msg: `0x${string}`;
|
|
69
|
+
}[] | undefined;
|
|
70
|
+
ump?: Record<string, `0x${string}`[]> | undefined;
|
|
71
|
+
at?: `0x${string}` | undefined;
|
|
72
|
+
}>;
|
|
2
73
|
export declare const name = "dryRun";
|
|
3
|
-
|
|
74
|
+
type Params = z.infer<typeof schema>;
|
|
75
|
+
export interface DryRunParams {
|
|
76
|
+
/**
|
|
77
|
+
* Return the raw storage diff
|
|
78
|
+
*/
|
|
79
|
+
raw: Params['raw'];
|
|
80
|
+
/**
|
|
81
|
+
* Return the html storage diff
|
|
82
|
+
*/
|
|
83
|
+
html: Params['html'];
|
|
84
|
+
/**
|
|
85
|
+
* The extrinsic to run
|
|
86
|
+
*/
|
|
87
|
+
extrinsic: Params['extrinsic'];
|
|
88
|
+
/**
|
|
89
|
+
* The horizontal messages to run
|
|
90
|
+
*/
|
|
91
|
+
hrmp: Params['hrmp'];
|
|
92
|
+
/**
|
|
93
|
+
* The downward messages to run
|
|
94
|
+
*/
|
|
95
|
+
dmp: Params['dmp'];
|
|
96
|
+
/**
|
|
97
|
+
* The upward messages to run
|
|
98
|
+
*/
|
|
99
|
+
ump: Params['ump'];
|
|
100
|
+
/**
|
|
101
|
+
* The block hash or number to run the extrinsic at
|
|
102
|
+
*/
|
|
103
|
+
at: Params['at'];
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Dry run an extrinsic or messages.
|
|
107
|
+
* If `html` is true, return the generated storage diff html string.
|
|
108
|
+
* If `raw` is true, return the raw storage diff.
|
|
109
|
+
* Otherwise, return `{ oldState, newState, delta }`.
|
|
110
|
+
*
|
|
111
|
+
* This function is a dev rpc handler. Use `dev_dryRun` as the method name when calling it.
|
|
112
|
+
*
|
|
113
|
+
* @param context - The context object of the rpc handler
|
|
114
|
+
* @param params - The parameters of the rpc handler
|
|
115
|
+
*
|
|
116
|
+
* @example Dry run an dmp
|
|
117
|
+
* ```ts
|
|
118
|
+
* import { WsProvider } from '@polkadot/api'
|
|
119
|
+
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
120
|
+
* const params = [
|
|
121
|
+
{
|
|
122
|
+
raw: false,
|
|
123
|
+
dmp: [
|
|
124
|
+
// https://acala.subscan.io/xcm_message/polkadot-2ab22918c567455af3563989d852f307f4cc1250
|
|
125
|
+
{
|
|
126
|
+
sentAt: 14471353,
|
|
127
|
+
msg: '0x02100104000100000b00280b9bba030a13000100000b00280b9bba03010300286bee0d0100040001010070c53d8e216f9c0f2e3b11c53f5f4bf3e078b995d5f0ed590f889f41e20e6531',
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
]
|
|
132
|
+
* await ws.send('dev_dryRun', params)
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
export declare const rpc: (context: Context, [params]: [DryRunParams]) => Promise<string | [`0x${string}`, `0x${string}` | null][] | {
|
|
136
|
+
old: {};
|
|
137
|
+
new: {};
|
|
138
|
+
delta: import("jsondiffpatch").Delta | undefined;
|
|
139
|
+
}>;
|
|
140
|
+
export {};
|
|
@@ -37,6 +37,36 @@ const schema = zod_1.z.object({
|
|
|
37
37
|
});
|
|
38
38
|
// custom rpc name (optional). e.g. dryRun will be called as dev_dryRun
|
|
39
39
|
exports.name = 'dryRun';
|
|
40
|
+
/**
|
|
41
|
+
* Dry run an extrinsic or messages.
|
|
42
|
+
* If `html` is true, return the generated storage diff html string.
|
|
43
|
+
* If `raw` is true, return the raw storage diff.
|
|
44
|
+
* Otherwise, return `{ oldState, newState, delta }`.
|
|
45
|
+
*
|
|
46
|
+
* This function is a dev rpc handler. Use `dev_dryRun` as the method name when calling it.
|
|
47
|
+
*
|
|
48
|
+
* @param context - The context object of the rpc handler
|
|
49
|
+
* @param params - The parameters of the rpc handler
|
|
50
|
+
*
|
|
51
|
+
* @example Dry run an dmp
|
|
52
|
+
* ```ts
|
|
53
|
+
* import { WsProvider } from '@polkadot/api'
|
|
54
|
+
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
55
|
+
* const params = [
|
|
56
|
+
{
|
|
57
|
+
raw: false,
|
|
58
|
+
dmp: [
|
|
59
|
+
// https://acala.subscan.io/xcm_message/polkadot-2ab22918c567455af3563989d852f307f4cc1250
|
|
60
|
+
{
|
|
61
|
+
sentAt: 14471353,
|
|
62
|
+
msg: '0x02100104000100000b00280b9bba030a13000100000b00280b9bba03010300286bee0d0100040001010070c53d8e216f9c0f2e3b11c53f5f4bf3e078b995d5f0ed590f889f41e20e6531',
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
]
|
|
67
|
+
* await ws.send('dev_dryRun', params)
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
40
70
|
const rpc = async (context, [params]) => {
|
|
41
71
|
const { html, extrinsic, hrmp, dmp, ump, raw, at } = schema.parse(params);
|
|
42
72
|
const dryRun = async () => {
|
|
@@ -1,2 +1,72 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Context } from '../../rpc/shared';
|
|
2
|
+
import { DownwardMessage, HorizontalMessage } from '@acala-network/chopsticks-core';
|
|
3
|
+
import { HexString } from '@polkadot/util/types';
|
|
4
|
+
export interface NewBlockParams {
|
|
5
|
+
/**
|
|
6
|
+
* The number of blocks to build
|
|
7
|
+
*/
|
|
8
|
+
count: number;
|
|
9
|
+
/**
|
|
10
|
+
* The block number to build to
|
|
11
|
+
*/
|
|
12
|
+
to: number;
|
|
13
|
+
/**
|
|
14
|
+
* The downward messages to include in the block
|
|
15
|
+
*/
|
|
16
|
+
dmp: DownwardMessage[];
|
|
17
|
+
/**
|
|
18
|
+
* The upward messages to include in the block
|
|
19
|
+
*/
|
|
20
|
+
ump: Record<number, HexString[]>;
|
|
21
|
+
/**
|
|
22
|
+
* The horizontal messages to include in the block
|
|
23
|
+
*/
|
|
24
|
+
hrmp: Record<number, HorizontalMessage[]>;
|
|
25
|
+
/**
|
|
26
|
+
* The transactions to include in the block
|
|
27
|
+
*/
|
|
28
|
+
transactions: HexString[];
|
|
29
|
+
/**
|
|
30
|
+
* Build block using a specific block height (unsafe)
|
|
31
|
+
*/
|
|
32
|
+
unsafeBlockHeight: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Build new blocks.
|
|
36
|
+
*
|
|
37
|
+
* This function is a dev rpc handler. Use `dev_newBlock` as the method name when calling it.
|
|
38
|
+
*
|
|
39
|
+
* @param context - The context object of the rpc handler
|
|
40
|
+
* @param params - The parameters of the rpc handler
|
|
41
|
+
*
|
|
42
|
+
* @example Build 2 blocks
|
|
43
|
+
* ```ts
|
|
44
|
+
* import { WsProvider } from '@polkadot/api'
|
|
45
|
+
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
46
|
+
* await ws.send('dev_newBlock', [{ count: 2 }])
|
|
47
|
+
* ```
|
|
48
|
+
* @example Build a block with upward messages
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { WsProvider } from '@polkadot/api'
|
|
51
|
+
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
52
|
+
* await ws.send('dev_newBlock', [
|
|
53
|
+
* {
|
|
54
|
+
* ump: {
|
|
55
|
+
* // https://acala.subscan.io/xcm_message/polkadot-ff66f28818d0b74573e62db8317e354b253fbc80
|
|
56
|
+
* 2000: [
|
|
57
|
+
* '0x021000040000000007903fc4db080a130000000007903fc4db08000d010004000101009c4b11a0974cba4a395c94832fba812868a6cb0ba09e8519b3521093ea359905',
|
|
58
|
+
* ],
|
|
59
|
+
* }
|
|
60
|
+
* }
|
|
61
|
+
* ])
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @example Build two blocks with unsafeBlockHeight
|
|
65
|
+
* ```ts
|
|
66
|
+
* import { WsProvider } from '@polkadot/api'
|
|
67
|
+
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
68
|
+
* // this will create two blocks with block height 100000001 and 100000002
|
|
69
|
+
* await ws.send('dev_newBlock', [{ count: 2, unsafeBlockHeight: 100000001 }])
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare const rpc: (context: Context, params: [NewBlockParams]) => Promise<string | undefined>;
|
|
@@ -3,7 +3,46 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.rpc = void 0;
|
|
4
4
|
const shared_1 = require("../../rpc/shared");
|
|
5
5
|
const logger_1 = require("../../logger");
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Build new blocks.
|
|
8
|
+
*
|
|
9
|
+
* This function is a dev rpc handler. Use `dev_newBlock` as the method name when calling it.
|
|
10
|
+
*
|
|
11
|
+
* @param context - The context object of the rpc handler
|
|
12
|
+
* @param params - The parameters of the rpc handler
|
|
13
|
+
*
|
|
14
|
+
* @example Build 2 blocks
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { WsProvider } from '@polkadot/api'
|
|
17
|
+
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
18
|
+
* await ws.send('dev_newBlock', [{ count: 2 }])
|
|
19
|
+
* ```
|
|
20
|
+
* @example Build a block with upward messages
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { WsProvider } from '@polkadot/api'
|
|
23
|
+
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
24
|
+
* await ws.send('dev_newBlock', [
|
|
25
|
+
* {
|
|
26
|
+
* ump: {
|
|
27
|
+
* // https://acala.subscan.io/xcm_message/polkadot-ff66f28818d0b74573e62db8317e354b253fbc80
|
|
28
|
+
* 2000: [
|
|
29
|
+
* '0x021000040000000007903fc4db080a130000000007903fc4db08000d010004000101009c4b11a0974cba4a395c94832fba812868a6cb0ba09e8519b3521093ea359905',
|
|
30
|
+
* ],
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* ])
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example Build two blocks with unsafeBlockHeight
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { WsProvider } from '@polkadot/api'
|
|
39
|
+
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
40
|
+
* // this will create two blocks with block height 100000001 and 100000002
|
|
41
|
+
* await ws.send('dev_newBlock', [{ count: 2, unsafeBlockHeight: 100000001 }])
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
const rpc = async (context, params) => {
|
|
45
|
+
const [param] = params;
|
|
7
46
|
const { count, to, hrmp, ump, dmp, transactions, unsafeBlockHeight } = param || {};
|
|
8
47
|
const now = context.chain.head.number;
|
|
9
48
|
const diff = to ? to - now : count;
|
|
@@ -1,2 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { BuildBlockMode } from '@acala-network/chopsticks-core';
|
|
2
|
+
import { Context } from '../../rpc/shared';
|
|
3
|
+
/**
|
|
4
|
+
* Set a build block mode. See [BuildBlockMode](../core/enums/BuildBlockMode).
|
|
5
|
+
*
|
|
6
|
+
* This function is a dev rpc handler. Use `dev_setBlockBuildMode` as the method name when calling it.
|
|
7
|
+
*
|
|
8
|
+
* @param context - The context object of the rpc handler
|
|
9
|
+
* @param params - The parameters of the rpc handler
|
|
10
|
+
*
|
|
11
|
+
* @example Set build block mode to instant
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { WsProvider } from '@polkadot/api'
|
|
14
|
+
* import { BuildBlockMode } from '@acala-network/chopsticks'
|
|
15
|
+
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
16
|
+
* await ws.send('dev_setBlockBuildMode', [BuildBlockMode.Instant])
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare const rpc: (context: Context, [mode]: [BuildBlockMode]) => Promise<void>;
|
|
@@ -4,6 +4,22 @@ exports.rpc = void 0;
|
|
|
4
4
|
const chopsticks_core_1 = require("@acala-network/chopsticks-core");
|
|
5
5
|
const shared_1 = require("../../rpc/shared");
|
|
6
6
|
const logger_1 = require("../../logger");
|
|
7
|
+
/**
|
|
8
|
+
* Set a build block mode. See [BuildBlockMode](../core/enums/BuildBlockMode).
|
|
9
|
+
*
|
|
10
|
+
* This function is a dev rpc handler. Use `dev_setBlockBuildMode` as the method name when calling it.
|
|
11
|
+
*
|
|
12
|
+
* @param context - The context object of the rpc handler
|
|
13
|
+
* @param params - The parameters of the rpc handler
|
|
14
|
+
*
|
|
15
|
+
* @example Set build block mode to instant
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { WsProvider } from '@polkadot/api'
|
|
18
|
+
* import { BuildBlockMode } from '@acala-network/chopsticks'
|
|
19
|
+
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
20
|
+
* await ws.send('dev_setBlockBuildMode', [BuildBlockMode.Instant])
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
7
23
|
const rpc = async (context, [mode]) => {
|
|
8
24
|
logger_1.defaultLogger.debug({ mode }, 'dev_setBlockBuildMode');
|
|
9
25
|
if (chopsticks_core_1.BuildBlockMode[mode] === undefined) {
|
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Context } from '../../rpc/shared';
|
|
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/api'
|
|
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}`>;
|
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.rpc = void 0;
|
|
4
4
|
const shared_1 = require("../../rpc/shared");
|
|
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/api'
|
|
16
|
+
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
17
|
+
* await ws.send('dev_setHead', [1000000])
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
5
20
|
const rpc = async (context, [hashOrNumber]) => {
|
|
6
21
|
let block;
|
|
7
22
|
if (typeof hashOrNumber === 'number') {
|
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Context } from '../../rpc/shared';
|
|
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/api'
|
|
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>;
|
|
@@ -3,6 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.rpc = void 0;
|
|
4
4
|
const shared_1 = require("../../rpc/shared");
|
|
5
5
|
const logger_1 = require("../../logger");
|
|
6
|
+
/**
|
|
7
|
+
* Set runtime log level.
|
|
8
|
+
*
|
|
9
|
+
* This function is a dev rpc handler. Use `dev_setRuntimeLogLevel` as the method name when calling it.
|
|
10
|
+
*
|
|
11
|
+
* @param context - The context object of the rpc handler
|
|
12
|
+
* @param runtimeLogLevel - The runtime log level to set
|
|
13
|
+
*
|
|
14
|
+
* @example Set runtime log level to 1
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { WsProvider } from '@polkadot/api'
|
|
17
|
+
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
18
|
+
* await ws.send('dev_setRuntimeLogLevel', [1])
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
6
21
|
const rpc = async (context, [runtimeLogLevel]) => {
|
|
7
22
|
logger_1.defaultLogger.debug({ runtimeLogLevel }, 'dev_setRuntimeLogLevel');
|
|
8
23
|
if (typeof runtimeLogLevel !== 'number') {
|
|
@@ -1,2 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { HexString } from '@polkadot/util/types';
|
|
2
|
+
import { Context } from '../../rpc/shared';
|
|
3
|
+
import { StorageValues } from '@acala-network/chopsticks-core';
|
|
4
|
+
/**
|
|
5
|
+
* Set storage values.
|
|
6
|
+
*
|
|
7
|
+
* This function is a dev rpc handler. Use `dev_setStorage` 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
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { WsProvider } from '@polkadot/api'
|
|
15
|
+
* import { Keyring } from '@polkadot/keyring'
|
|
16
|
+
*
|
|
17
|
+
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
18
|
+
* const keyring = new Keyring({ type: 'ed25519' })
|
|
19
|
+
* const bob = keyring.addFromUri('//Bob')
|
|
20
|
+
*
|
|
21
|
+
* const storage = {
|
|
22
|
+
* System: {
|
|
23
|
+
* Account: [[[bob.address], { data: { free: 100000 }, nonce: 1 }]],
|
|
24
|
+
* },
|
|
25
|
+
* }
|
|
26
|
+
* await ws.send('dev_setStorage', [storage])
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare const rpc: (context: Context, params: [StorageValues, HexString?]) => Promise<`0x${string}`>;
|
|
@@ -4,6 +4,31 @@ exports.rpc = void 0;
|
|
|
4
4
|
const shared_1 = require("../../rpc/shared");
|
|
5
5
|
const chopsticks_core_1 = require("@acala-network/chopsticks-core");
|
|
6
6
|
const logger_1 = require("../../logger");
|
|
7
|
+
/**
|
|
8
|
+
* Set storage values.
|
|
9
|
+
*
|
|
10
|
+
* This function is a dev rpc handler. Use `dev_setStorage` as the method name when calling it.
|
|
11
|
+
*
|
|
12
|
+
* @param context - The context object of the rpc handler
|
|
13
|
+
* @param params - The parameters of the rpc handler
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { WsProvider } from '@polkadot/api'
|
|
18
|
+
* import { Keyring } from '@polkadot/keyring'
|
|
19
|
+
*
|
|
20
|
+
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
21
|
+
* const keyring = new Keyring({ type: 'ed25519' })
|
|
22
|
+
* const bob = keyring.addFromUri('//Bob')
|
|
23
|
+
*
|
|
24
|
+
* const storage = {
|
|
25
|
+
* System: {
|
|
26
|
+
* Account: [[[bob.address], { data: { free: 100000 }, nonce: 1 }]],
|
|
27
|
+
* },
|
|
28
|
+
* }
|
|
29
|
+
* await ws.send('dev_setStorage', [storage])
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
7
32
|
const rpc = async (context, params) => {
|
|
8
33
|
const [values, blockHash] = params;
|
|
9
34
|
const hash = await (0, chopsticks_core_1.setStorage)(context.chain, values, blockHash).catch((error) => {
|
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Context } from '../../rpc/shared';
|
|
2
|
+
/**
|
|
3
|
+
* Travel to a specific time.
|
|
4
|
+
*
|
|
5
|
+
* This function is a dev rpc handler. Use `dev_timeTravel` as the method name when calling it.
|
|
6
|
+
*
|
|
7
|
+
* @param context - The context object of the rpc handler
|
|
8
|
+
* @param date - Timestamp or date string to set
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { WsProvider } from '@polkadot/api'
|
|
13
|
+
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
14
|
+
* await ws.send('dev_timeTravel', ['Jan 1, 2023'])
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const rpc: (context: Context, [date]: [string | number]) => Promise<number>;
|
|
@@ -3,6 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.rpc = void 0;
|
|
4
4
|
const shared_1 = require("../../rpc/shared");
|
|
5
5
|
const chopsticks_core_1 = require("@acala-network/chopsticks-core");
|
|
6
|
+
/**
|
|
7
|
+
* Travel to a specific time.
|
|
8
|
+
*
|
|
9
|
+
* This function is a dev rpc handler. Use `dev_timeTravel` as the method name when calling it.
|
|
10
|
+
*
|
|
11
|
+
* @param context - The context object of the rpc handler
|
|
12
|
+
* @param date - Timestamp or date string to set
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { WsProvider } from '@polkadot/api'
|
|
17
|
+
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
18
|
+
* await ws.send('dev_timeTravel', ['Jan 1, 2023'])
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
6
21
|
const rpc = async (context, [date]) => {
|
|
7
22
|
const timestamp = typeof date === 'string' ? Date.parse(date) : date;
|
|
8
23
|
if (Number.isNaN(timestamp))
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { rpc as newBlock, NewBlockParams } from './new-block';
|
|
2
|
+
export { rpc as dryRun, DryRunParams } from './dry-run';
|
|
3
|
+
export { rpc as setBlockBuildMode } from './set-block-build-mode';
|
|
4
|
+
export { rpc as setHead } from './set-head';
|
|
5
|
+
export { rpc as setRuntimeLogLevel } from './set-runtime-log-level';
|
|
6
|
+
export { rpc as setStorage } from './set-storage';
|
|
7
|
+
export { rpc as timeTravel } from './time-travel';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.timeTravel = exports.setStorage = exports.setRuntimeLogLevel = exports.setHead = exports.setBlockBuildMode = exports.dryRun = exports.newBlock = void 0;
|
|
4
|
+
var new_block_1 = require("./new-block");
|
|
5
|
+
Object.defineProperty(exports, "newBlock", { enumerable: true, get: function () { return new_block_1.rpc; } });
|
|
6
|
+
var dry_run_1 = require("./dry-run");
|
|
7
|
+
Object.defineProperty(exports, "dryRun", { enumerable: true, get: function () { return dry_run_1.rpc; } });
|
|
8
|
+
var set_block_build_mode_1 = require("./set-block-build-mode");
|
|
9
|
+
Object.defineProperty(exports, "setBlockBuildMode", { enumerable: true, get: function () { return set_block_build_mode_1.rpc; } });
|
|
10
|
+
var set_head_1 = require("./set-head");
|
|
11
|
+
Object.defineProperty(exports, "setHead", { enumerable: true, get: function () { return set_head_1.rpc; } });
|
|
12
|
+
var set_runtime_log_level_1 = require("./set-runtime-log-level");
|
|
13
|
+
Object.defineProperty(exports, "setRuntimeLogLevel", { enumerable: true, get: function () { return set_runtime_log_level_1.rpc; } });
|
|
14
|
+
var set_storage_1 = require("./set-storage");
|
|
15
|
+
Object.defineProperty(exports, "setStorage", { enumerable: true, get: function () { return set_storage_1.rpc; } });
|
|
16
|
+
var time_travel_1 = require("./time-travel");
|
|
17
|
+
Object.defineProperty(exports, "timeTravel", { enumerable: true, get: function () { return time_travel_1.rpc; } });
|
package/lib/rpc/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ import { Context, SubscriptionManager } from './shared';
|
|
|
2
2
|
export declare const handler: (context: Context) => ({ method, params }: {
|
|
3
3
|
method: string;
|
|
4
4
|
params: any[];
|
|
5
|
-
}, subscriptionManager: SubscriptionManager) => Promise<
|
|
5
|
+
}, subscriptionManager: SubscriptionManager) => Promise<any>;
|
package/lib/rpc/shared.d.ts
CHANGED
|
@@ -14,11 +14,14 @@ export declare class ResponseError extends Error {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
export interface Context {
|
|
17
|
+
/**
|
|
18
|
+
* The blockchain instance, see `Blockchain` type in the `core` package
|
|
19
|
+
*/
|
|
17
20
|
chain: Blockchain;
|
|
18
21
|
}
|
|
19
22
|
export interface SubscriptionManager {
|
|
20
23
|
subscribe: (method: string, subid: string, onCancel?: () => void) => (data: any) => void;
|
|
21
24
|
unsubscribe: (subid: string) => void;
|
|
22
25
|
}
|
|
23
|
-
export type Handler = (context: Context, params:
|
|
26
|
+
export type Handler<TParams = any, TReturn = any> = (context: Context, params: TParams, subscriptionManager: SubscriptionManager) => Promise<TReturn>;
|
|
24
27
|
export type Handlers = Record<string, Handler>;
|
|
@@ -1,3 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { HexString } from '@polkadot/util/types';
|
|
2
|
+
import { Handler } from '../shared';
|
|
3
|
+
/**
|
|
4
|
+
* @param context
|
|
5
|
+
* @param params - [`extrinsic`]
|
|
6
|
+
*
|
|
7
|
+
* @return Hash
|
|
8
|
+
*/
|
|
9
|
+
export declare const author_submitExtrinsic: Handler<[HexString], HexString>;
|
|
10
|
+
/**
|
|
11
|
+
* @param context
|
|
12
|
+
* @param params - [`extrinsic`]
|
|
13
|
+
* @param subscriptionManager
|
|
14
|
+
*
|
|
15
|
+
* @return subscription id
|
|
16
|
+
*/
|
|
17
|
+
export declare const author_submitAndWatchExtrinsic: Handler<[HexString], string>;
|
|
18
|
+
/**
|
|
19
|
+
* @param _context
|
|
20
|
+
* @param params - [`subid`]
|
|
21
|
+
*/
|
|
22
|
+
export declare const author_unwatchExtrinsic: Handler<[string], void>;
|
|
23
|
+
/**
|
|
24
|
+
* Get pending extrinsics
|
|
25
|
+
*
|
|
26
|
+
* @return Array of pending extrinsics
|
|
27
|
+
*/
|
|
28
|
+
export declare const author_pendingExtrinsics: Handler<void, HexString[]>;
|