@acala-network/chopsticks 0.9.8 → 0.9.9-2
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/plugins/types.d.ts +0 -7
- package/dist/cjs/plugins/types.js +3 -27
- package/dist/cjs/rpc/index.js +2 -2
- package/dist/cjs/schema/index.js +1 -1
- package/dist/cjs/types.d.ts +1 -0
- package/dist/cjs/types.js +48 -0
- package/dist/esm/plugins/types.d.ts +0 -7
- package/dist/esm/plugins/types.js +0 -6
- package/dist/esm/rpc/index.js +3 -3
- package/dist/esm/schema/index.js +1 -1
- package/dist/esm/types.d.ts +1 -0
- package/dist/esm/types.js +1 -0
- package/package.json +3 -3
- package/dist/cjs/plugins/new-block/index.d.ts +0 -1
- package/dist/cjs/plugins/new-block/index.js +0 -18
- package/dist/cjs/plugins/new-block/rpc.d.ts +0 -128
- package/dist/cjs/plugins/new-block/rpc.js +0 -58
- package/dist/cjs/plugins/set-block-build-mode/index.d.ts +0 -1
- package/dist/cjs/plugins/set-block-build-mode/index.js +0 -18
- package/dist/cjs/plugins/set-block-build-mode/rpc.d.ts +0 -20
- package/dist/cjs/plugins/set-block-build-mode/rpc.js +0 -21
- package/dist/cjs/plugins/set-head/index.d.ts +0 -1
- package/dist/cjs/plugins/set-head/index.js +0 -18
- package/dist/cjs/plugins/set-head/rpc.d.ts +0 -21
- package/dist/cjs/plugins/set-head/rpc.js +0 -29
- package/dist/cjs/plugins/set-runtime-log-level/index.d.ts +0 -1
- package/dist/cjs/plugins/set-runtime-log-level/index.js +0 -18
- package/dist/cjs/plugins/set-runtime-log-level/rpc.d.ts +0 -17
- package/dist/cjs/plugins/set-runtime-log-level/rpc.js +0 -21
- package/dist/cjs/plugins/set-storage/index.d.ts +0 -1
- package/dist/cjs/plugins/set-storage/index.js +0 -18
- package/dist/cjs/plugins/set-storage/rpc.d.ts +0 -28
- package/dist/cjs/plugins/set-storage/rpc.js +0 -23
- package/dist/cjs/plugins/time-travel/index.d.ts +0 -1
- package/dist/cjs/plugins/time-travel/index.js +0 -18
- package/dist/cjs/plugins/time-travel/rpc.d.ts +0 -17
- package/dist/cjs/plugins/time-travel/rpc.js +0 -17
- package/dist/esm/plugins/new-block/index.d.ts +0 -1
- package/dist/esm/plugins/new-block/index.js +0 -1
- package/dist/esm/plugins/new-block/rpc.d.ts +0 -128
- package/dist/esm/plugins/new-block/rpc.js +0 -85
- package/dist/esm/plugins/set-block-build-mode/index.d.ts +0 -1
- package/dist/esm/plugins/set-block-build-mode/index.js +0 -1
- package/dist/esm/plugins/set-block-build-mode/rpc.d.ts +0 -20
- package/dist/esm/plugins/set-block-build-mode/rpc.js +0 -28
- package/dist/esm/plugins/set-head/index.d.ts +0 -1
- package/dist/esm/plugins/set-head/index.js +0 -1
- package/dist/esm/plugins/set-head/rpc.d.ts +0 -21
- package/dist/esm/plugins/set-head/rpc.js +0 -33
- package/dist/esm/plugins/set-runtime-log-level/index.d.ts +0 -1
- package/dist/esm/plugins/set-runtime-log-level/index.js +0 -1
- package/dist/esm/plugins/set-runtime-log-level/rpc.d.ts +0 -17
- package/dist/esm/plugins/set-runtime-log-level/rpc.js +0 -25
- package/dist/esm/plugins/set-storage/index.d.ts +0 -1
- package/dist/esm/plugins/set-storage/index.js +0 -1
- package/dist/esm/plugins/set-storage/rpc.d.ts +0 -28
- package/dist/esm/plugins/set-storage/rpc.js +0 -37
- package/dist/esm/plugins/time-travel/index.d.ts +0 -1
- package/dist/esm/plugins/time-travel/index.js +0 -1
- package/dist/esm/plugins/time-travel/rpc.d.ts +0 -17
- package/dist/esm/plugins/time-travel/rpc.js +0 -21
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
_export_star(require("./rpc.js"), exports);
|
|
6
|
-
function _export_star(from, to) {
|
|
7
|
-
Object.keys(from).forEach(function(k) {
|
|
8
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
9
|
-
Object.defineProperty(to, k, {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function() {
|
|
12
|
-
return from[k];
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
return from;
|
|
18
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Context, StorageValues } from '@acala-network/chopsticks-core';
|
|
2
|
-
import { HexString } from '@polkadot/util/types';
|
|
3
|
-
/**
|
|
4
|
-
* Set storage values.
|
|
5
|
-
*
|
|
6
|
-
* This function is a dev rpc handler. Use `dev_setStorage` 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
|
|
12
|
-
* ```ts
|
|
13
|
-
* import { WsProvider } from '@polkadot/rpc-provider'
|
|
14
|
-
* import { Keyring } from '@polkadot/keyring'
|
|
15
|
-
*
|
|
16
|
-
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
17
|
-
* const keyring = new Keyring({ type: 'ed25519' })
|
|
18
|
-
* const bob = keyring.addFromUri('//Bob')
|
|
19
|
-
*
|
|
20
|
-
* const storage = {
|
|
21
|
-
* System: {
|
|
22
|
-
* Account: [[[bob.address], { data: { free: 100000 }, nonce: 1 }]],
|
|
23
|
-
* },
|
|
24
|
-
* }
|
|
25
|
-
* await ws.send('dev_setStorage', [storage])
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export declare const rpc: (context: Context, params: [StorageValues, HexString?]) => Promise<`0x${string}`>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "rpc", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return rpc;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _chopstickscore = require("@acala-network/chopsticks-core");
|
|
12
|
-
const _logger = require("../../logger.js");
|
|
13
|
-
const rpc = async (context, params)=>{
|
|
14
|
-
const [values, blockHash] = params;
|
|
15
|
-
const hash = await (0, _chopstickscore.setStorage)(context.chain, values, blockHash).catch((error)=>{
|
|
16
|
-
throw new _chopstickscore.ResponseError(1, error.toString());
|
|
17
|
-
});
|
|
18
|
-
_logger.defaultLogger.debug({
|
|
19
|
-
hash,
|
|
20
|
-
values
|
|
21
|
-
}, 'dev_setStorage');
|
|
22
|
-
return hash;
|
|
23
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './rpc.js';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
_export_star(require("./rpc.js"), exports);
|
|
6
|
-
function _export_star(from, to) {
|
|
7
|
-
Object.keys(from).forEach(function(k) {
|
|
8
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
9
|
-
Object.defineProperty(to, k, {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function() {
|
|
12
|
-
return from[k];
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
return from;
|
|
18
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Context } from '@acala-network/chopsticks-core';
|
|
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/rpc-provider'
|
|
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>;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "rpc", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return rpc;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _chopstickscore = require("@acala-network/chopsticks-core");
|
|
12
|
-
const rpc = async (context, [date])=>{
|
|
13
|
-
const timestamp = typeof date === 'string' ? Date.parse(date) : date;
|
|
14
|
-
if (Number.isNaN(timestamp)) throw new _chopstickscore.ResponseError(1, 'Invalid date');
|
|
15
|
-
await (0, _chopstickscore.timeTravel)(context.chain, timestamp);
|
|
16
|
-
return timestamp;
|
|
17
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './rpc.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './rpc.js';
|
|
@@ -1,128 +0,0 @@
|
|
|
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.ZodUnion<[z.ZodNumber, z.ZodString]>, 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<string | 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<string | 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,85 +0,0 @@
|
|
|
1
|
-
import { ResponseError } from '@acala-network/chopsticks-core';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { defaultLogger } from '../../logger.js';
|
|
4
|
-
import { zHex } from '../../schema/index.js';
|
|
5
|
-
const schema = z.object({
|
|
6
|
-
count: z.number().optional(),
|
|
7
|
-
to: z.number().optional(),
|
|
8
|
-
dmp: z.array(z.object({
|
|
9
|
-
sentAt: z.number(),
|
|
10
|
-
msg: zHex
|
|
11
|
-
})).min(1).optional(),
|
|
12
|
-
ump: z.record(z.number(), z.array(zHex).min(1)).optional(),
|
|
13
|
-
hrmp: z.record(z.union([
|
|
14
|
-
z.number(),
|
|
15
|
-
z.string()
|
|
16
|
-
]), z.array(z.object({
|
|
17
|
-
sentAt: z.number(),
|
|
18
|
-
data: zHex
|
|
19
|
-
})).min(1)).optional(),
|
|
20
|
-
transactions: z.array(zHex).min(1).optional(),
|
|
21
|
-
unsafeBlockHeight: z.number().optional()
|
|
22
|
-
});
|
|
23
|
-
/**
|
|
24
|
-
* Build new blocks.
|
|
25
|
-
*
|
|
26
|
-
* This function is a dev rpc handler. Use `dev_newBlock` as the method name when calling it.
|
|
27
|
-
*
|
|
28
|
-
* @param context - The context object of the rpc handler
|
|
29
|
-
* @param params - The parameters of the rpc handler
|
|
30
|
-
*
|
|
31
|
-
* @example Build 2 blocks
|
|
32
|
-
* ```ts
|
|
33
|
-
* import { WsProvider } from '@polkadot/rpc-provider'
|
|
34
|
-
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
35
|
-
* await ws.send('dev_newBlock', [{ count: 2 }])
|
|
36
|
-
* ```
|
|
37
|
-
* @example Build a block with upward messages
|
|
38
|
-
* ```ts
|
|
39
|
-
* import { WsProvider } from '@polkadot/rpc-provider'
|
|
40
|
-
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
41
|
-
* await ws.send('dev_newBlock', [
|
|
42
|
-
* {
|
|
43
|
-
* ump: {
|
|
44
|
-
* // https://acala.subscan.io/xcm_message/polkadot-ff66f28818d0b74573e62db8317e354b253fbc80
|
|
45
|
-
* 2000: [
|
|
46
|
-
* '0x021000040000000007903fc4db080a130000000007903fc4db08000d010004000101009c4b11a0974cba4a395c94832fba812868a6cb0ba09e8519b3521093ea359905',
|
|
47
|
-
* ],
|
|
48
|
-
* }
|
|
49
|
-
* }
|
|
50
|
-
* ])
|
|
51
|
-
* ```
|
|
52
|
-
*
|
|
53
|
-
* @example Build two blocks with unsafeBlockHeight
|
|
54
|
-
* ```ts
|
|
55
|
-
* import { WsProvider } from '@polkadot/rpc-provider'
|
|
56
|
-
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
57
|
-
* // this will create two blocks with block height 100000001 and 100000002
|
|
58
|
-
* await ws.send('dev_newBlock', [{ count: 2, unsafeBlockHeight: 100000001 }])
|
|
59
|
-
* ```
|
|
60
|
-
*/ export const rpc = async (context, [params])=>{
|
|
61
|
-
const { count, to, hrmp, ump, dmp, transactions, unsafeBlockHeight } = schema.parse(params || {});
|
|
62
|
-
const now = context.chain.head.number;
|
|
63
|
-
const diff = to ? to - now : count;
|
|
64
|
-
const finalCount = diff !== undefined ? Math.max(diff, 1) : 1;
|
|
65
|
-
let finalHash;
|
|
66
|
-
if (unsafeBlockHeight !== undefined && unsafeBlockHeight <= now) {
|
|
67
|
-
throw new ResponseError(1, 'unsafeBlockHeight must be greater than current block height');
|
|
68
|
-
}
|
|
69
|
-
for(let i = 0; i < finalCount; i++){
|
|
70
|
-
const block = await context.chain.newBlock({
|
|
71
|
-
transactions,
|
|
72
|
-
horizontalMessages: hrmp,
|
|
73
|
-
upwardMessages: ump,
|
|
74
|
-
downwardMessages: dmp,
|
|
75
|
-
unsafeBlockHeight: i === 0 ? unsafeBlockHeight : undefined
|
|
76
|
-
}).catch((error)=>{
|
|
77
|
-
throw new ResponseError(1, error.toString());
|
|
78
|
-
});
|
|
79
|
-
defaultLogger.debug({
|
|
80
|
-
hash: block.hash
|
|
81
|
-
}, 'dev_newBlock');
|
|
82
|
-
finalHash = block.hash;
|
|
83
|
-
}
|
|
84
|
-
return finalHash;
|
|
85
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './rpc.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './rpc.js';
|
|
@@ -1,20 +0,0 @@
|
|
|
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,28 +0,0 @@
|
|
|
1
|
-
import { BuildBlockMode, ResponseError } from '@acala-network/chopsticks-core';
|
|
2
|
-
import { defaultLogger } from '../../logger.js';
|
|
3
|
-
/**
|
|
4
|
-
* Set a build block mode. See [BuildBlockMode](../core/enums/BuildBlockMode).
|
|
5
|
-
*
|
|
6
|
-
* 1 - Batch, 2 - Instant, 3 - Manual
|
|
7
|
-
*
|
|
8
|
-
* This function is a dev rpc handler. Use `dev_setBlockBuildMode` as the method name when calling it.
|
|
9
|
-
*
|
|
10
|
-
* @param context - The context object of the rpc handler
|
|
11
|
-
* @param params - The parameters of the rpc handler
|
|
12
|
-
*
|
|
13
|
-
* @example Set build block mode to instant
|
|
14
|
-
* ```ts
|
|
15
|
-
* import { WsProvider } from '@polkadot/rpc-provider'
|
|
16
|
-
* import { BuildBlockMode } from '@acala-network/chopsticks-core'
|
|
17
|
-
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
18
|
-
* await ws.send('dev_setBlockBuildMode', [BuildBlockMode.Instant])
|
|
19
|
-
* ```
|
|
20
|
-
*/ export const rpc = async (context, [mode])=>{
|
|
21
|
-
defaultLogger.debug({
|
|
22
|
-
mode: BuildBlockMode[mode]
|
|
23
|
-
}, 'dev_setBlockBuildMode');
|
|
24
|
-
if (BuildBlockMode[mode] === undefined) {
|
|
25
|
-
throw new ResponseError(1, `Invalid mode ${mode}`);
|
|
26
|
-
}
|
|
27
|
-
context.chain.txPool.mode = mode;
|
|
28
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './rpc.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './rpc.js';
|
|
@@ -1,21 +0,0 @@
|
|
|
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,33 +0,0 @@
|
|
|
1
|
-
import { ResponseError } from '@acala-network/chopsticks-core';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { zHash } from '../../schema/index.js';
|
|
4
|
-
const schema = zHash.or(z.number());
|
|
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
|
-
*/ export const rpc = async (context, [params])=>{
|
|
20
|
-
const hashOrNumber = schema.parse(params);
|
|
21
|
-
let block;
|
|
22
|
-
if (typeof hashOrNumber === 'number') {
|
|
23
|
-
const blockNumber = hashOrNumber > 0 ? hashOrNumber : context.chain.head.number + hashOrNumber;
|
|
24
|
-
block = await context.chain.getBlockAt(blockNumber);
|
|
25
|
-
} else {
|
|
26
|
-
block = await context.chain.getBlock(hashOrNumber);
|
|
27
|
-
}
|
|
28
|
-
if (!block) {
|
|
29
|
-
throw new ResponseError(1, `Block not found ${hashOrNumber}`);
|
|
30
|
-
}
|
|
31
|
-
await context.chain.setHead(block);
|
|
32
|
-
return block.hash;
|
|
33
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './rpc.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './rpc.js';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Context } from '@acala-network/chopsticks-core';
|
|
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,25 +0,0 @@
|
|
|
1
|
-
import { ResponseError } from '@acala-network/chopsticks-core';
|
|
2
|
-
import { defaultLogger } from '../../logger.js';
|
|
3
|
-
/**
|
|
4
|
-
* Set runtime log level.
|
|
5
|
-
*
|
|
6
|
-
* This function is a dev rpc handler. Use `dev_setRuntimeLogLevel` as the method name when calling it.
|
|
7
|
-
*
|
|
8
|
-
* @param context - The context object of the rpc handler
|
|
9
|
-
* @param runtimeLogLevel - The runtime log level to set
|
|
10
|
-
*
|
|
11
|
-
* @example Set runtime log level to 1
|
|
12
|
-
* ```ts
|
|
13
|
-
* import { WsProvider } from '@polkadot/rpc-provider'
|
|
14
|
-
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
15
|
-
* await ws.send('dev_setRuntimeLogLevel', [1])
|
|
16
|
-
* ```
|
|
17
|
-
*/ export const rpc = async (context, [runtimeLogLevel])=>{
|
|
18
|
-
defaultLogger.debug({
|
|
19
|
-
runtimeLogLevel
|
|
20
|
-
}, 'dev_setRuntimeLogLevel');
|
|
21
|
-
if (typeof runtimeLogLevel !== 'number') {
|
|
22
|
-
throw new ResponseError(1, `Invalid runtimeLogLevel ${runtimeLogLevel}`);
|
|
23
|
-
}
|
|
24
|
-
context.chain.runtimeLogLevel = runtimeLogLevel;
|
|
25
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './rpc.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './rpc.js';
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Context, StorageValues } from '@acala-network/chopsticks-core';
|
|
2
|
-
import { HexString } from '@polkadot/util/types';
|
|
3
|
-
/**
|
|
4
|
-
* Set storage values.
|
|
5
|
-
*
|
|
6
|
-
* This function is a dev rpc handler. Use `dev_setStorage` 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
|
|
12
|
-
* ```ts
|
|
13
|
-
* import { WsProvider } from '@polkadot/rpc-provider'
|
|
14
|
-
* import { Keyring } from '@polkadot/keyring'
|
|
15
|
-
*
|
|
16
|
-
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
17
|
-
* const keyring = new Keyring({ type: 'ed25519' })
|
|
18
|
-
* const bob = keyring.addFromUri('//Bob')
|
|
19
|
-
*
|
|
20
|
-
* const storage = {
|
|
21
|
-
* System: {
|
|
22
|
-
* Account: [[[bob.address], { data: { free: 100000 }, nonce: 1 }]],
|
|
23
|
-
* },
|
|
24
|
-
* }
|
|
25
|
-
* await ws.send('dev_setStorage', [storage])
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export declare const rpc: (context: Context, params: [StorageValues, HexString?]) => Promise<`0x${string}`>;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { ResponseError, setStorage } from '@acala-network/chopsticks-core';
|
|
2
|
-
import { defaultLogger } from '../../logger.js';
|
|
3
|
-
/**
|
|
4
|
-
* Set storage values.
|
|
5
|
-
*
|
|
6
|
-
* This function is a dev rpc handler. Use `dev_setStorage` 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
|
|
12
|
-
* ```ts
|
|
13
|
-
* import { WsProvider } from '@polkadot/rpc-provider'
|
|
14
|
-
* import { Keyring } from '@polkadot/keyring'
|
|
15
|
-
*
|
|
16
|
-
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
17
|
-
* const keyring = new Keyring({ type: 'ed25519' })
|
|
18
|
-
* const bob = keyring.addFromUri('//Bob')
|
|
19
|
-
*
|
|
20
|
-
* const storage = {
|
|
21
|
-
* System: {
|
|
22
|
-
* Account: [[[bob.address], { data: { free: 100000 }, nonce: 1 }]],
|
|
23
|
-
* },
|
|
24
|
-
* }
|
|
25
|
-
* await ws.send('dev_setStorage', [storage])
|
|
26
|
-
* ```
|
|
27
|
-
*/ export const rpc = async (context, params)=>{
|
|
28
|
-
const [values, blockHash] = params;
|
|
29
|
-
const hash = await setStorage(context.chain, values, blockHash).catch((error)=>{
|
|
30
|
-
throw new ResponseError(1, error.toString());
|
|
31
|
-
});
|
|
32
|
-
defaultLogger.debug({
|
|
33
|
-
hash,
|
|
34
|
-
values
|
|
35
|
-
}, 'dev_setStorage');
|
|
36
|
-
return hash;
|
|
37
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './rpc.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './rpc.js';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Context } from '@acala-network/chopsticks-core';
|
|
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/rpc-provider'
|
|
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>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ResponseError, timeTravel } from '@acala-network/chopsticks-core';
|
|
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/rpc-provider'
|
|
13
|
-
* const ws = new WsProvider(`ws://localhost:8000`)
|
|
14
|
-
* await ws.send('dev_timeTravel', ['Jan 1, 2023'])
|
|
15
|
-
* ```
|
|
16
|
-
*/ export const rpc = async (context, [date])=>{
|
|
17
|
-
const timestamp = typeof date === 'string' ? Date.parse(date) : date;
|
|
18
|
-
if (Number.isNaN(timestamp)) throw new ResponseError(1, 'Invalid date');
|
|
19
|
-
await timeTravel(context.chain, timestamp);
|
|
20
|
-
return timestamp;
|
|
21
|
-
};
|