@acala-network/chopsticks 0.8.0 → 0.8.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/lib/cli.js +6 -0
- package/lib/context.js +22 -0
- 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 +171 -76
- package/lib/rpc/substrate/system.d.ts +28 -3
- package/lib/rpc/substrate/system.js +60 -41
- package/lib/schema/index.d.ts +7 -4
- package/lib/schema/index.js +1 -0
- package/lib/types.d.ts +16 -0
- package/lib/types.js +18 -0
- package/package.json +10 -9
|
@@ -1,3 +1,97 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { RuntimeVersion } from '@acala-network/chopsticks-core';
|
|
2
|
+
import { HexString } from '@polkadot/util/types';
|
|
3
|
+
import { Handler } from '../shared';
|
|
4
|
+
/**
|
|
5
|
+
* @param context
|
|
6
|
+
* @param params - [`blockhash`]
|
|
7
|
+
*
|
|
8
|
+
* @return runtime version
|
|
9
|
+
*/
|
|
10
|
+
export declare const state_getRuntimeVersion: Handler<[HexString], RuntimeVersion | undefined>;
|
|
11
|
+
/**
|
|
12
|
+
* @param context
|
|
13
|
+
* @param params - [`blockhash`]
|
|
14
|
+
*
|
|
15
|
+
* @return metadata
|
|
16
|
+
*/
|
|
17
|
+
export declare const state_getMetadata: Handler<[HexString], HexString | undefined>;
|
|
18
|
+
/**
|
|
19
|
+
* @param context
|
|
20
|
+
* @param params - [`key`, `blockhash`]
|
|
21
|
+
*
|
|
22
|
+
* @return storage value
|
|
23
|
+
*/
|
|
24
|
+
export declare const state_getStorage: Handler<[HexString, HexString], string | undefined>;
|
|
25
|
+
/**
|
|
26
|
+
* @param context
|
|
27
|
+
* @param params - [`prefix`, `pageSize`, `startKey`, `blockhash`]
|
|
28
|
+
*
|
|
29
|
+
* @return paged keys
|
|
30
|
+
*/
|
|
31
|
+
export declare const state_getKeysPaged: Handler<[string, number, string, HexString], string[] | undefined>;
|
|
32
|
+
/**
|
|
33
|
+
* @param context
|
|
34
|
+
* @param params - [`keys`, `blockhash`]
|
|
35
|
+
*
|
|
36
|
+
* @return storage values
|
|
37
|
+
*/
|
|
38
|
+
export declare const state_queryStorageAt: Handler<[
|
|
39
|
+
string[],
|
|
40
|
+
HexString
|
|
41
|
+
], [] | [
|
|
42
|
+
{
|
|
43
|
+
block: HexString;
|
|
44
|
+
changes: (string | undefined)[][];
|
|
45
|
+
}
|
|
46
|
+
]>;
|
|
47
|
+
/**
|
|
48
|
+
* @param context
|
|
49
|
+
* @param params - [`method`, `data`, `blockhash`]
|
|
50
|
+
*
|
|
51
|
+
* @return result in hash
|
|
52
|
+
*/
|
|
53
|
+
export declare const state_call: Handler<[HexString, HexString, HexString], HexString>;
|
|
54
|
+
/**
|
|
55
|
+
* @return subscription id
|
|
56
|
+
*/
|
|
57
|
+
export declare const state_subscribeRuntimeVersion: Handler<[], string>;
|
|
58
|
+
/**
|
|
59
|
+
* @param context
|
|
60
|
+
* @param params - [`subid`]
|
|
61
|
+
* @param subscriptionManager
|
|
62
|
+
*/
|
|
63
|
+
export declare const state_unsubscribeRuntimeVersion: Handler<[HexString], void>;
|
|
64
|
+
/**
|
|
65
|
+
* @param context
|
|
66
|
+
* @param params - [`keys`]
|
|
67
|
+
* @param subscriptionManager
|
|
68
|
+
*
|
|
69
|
+
* @return subscription id
|
|
70
|
+
*/
|
|
71
|
+
export declare const state_subscribeStorage: Handler<[string[]], string>;
|
|
72
|
+
/**
|
|
73
|
+
* @param context
|
|
74
|
+
* @param params - [`subid`]
|
|
75
|
+
* @param subscriptionManager
|
|
76
|
+
*/
|
|
77
|
+
export declare const state_unsubscribeStorage: Handler<[string], void>;
|
|
78
|
+
/**
|
|
79
|
+
* @param context
|
|
80
|
+
* @param params - [`child`, `key`, `blockhash`]
|
|
81
|
+
*
|
|
82
|
+
* @return storage valuse
|
|
83
|
+
*/
|
|
84
|
+
export declare const childstate_getStorage: Handler<[HexString, HexString, HexString], string | undefined>;
|
|
85
|
+
/**
|
|
86
|
+
* @param context
|
|
87
|
+
* @param params - [`child`, `prefix`, `pageSize`, `startKey`, `blockhash`]
|
|
88
|
+
*
|
|
89
|
+
* @return paged keys
|
|
90
|
+
*/
|
|
91
|
+
export declare const childstate_getKeysPaged: Handler<[
|
|
92
|
+
HexString,
|
|
93
|
+
HexString,
|
|
94
|
+
number,
|
|
95
|
+
HexString,
|
|
96
|
+
HexString
|
|
97
|
+
], HexString[] | undefined>;
|
|
@@ -1,82 +1,177 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.childstate_getKeysPaged = exports.childstate_getStorage = exports.state_unsubscribeStorage = exports.state_subscribeStorage = exports.state_unsubscribeRuntimeVersion = exports.state_subscribeRuntimeVersion = exports.state_call = exports.state_queryStorageAt = exports.state_getKeysPaged = exports.state_getStorage = exports.state_getMetadata = exports.state_getRuntimeVersion = void 0;
|
|
4
|
+
const chopsticks_core_1 = require("@acala-network/chopsticks-core");
|
|
3
5
|
const shared_1 = require("../shared");
|
|
4
6
|
const logger_1 = require("../../logger");
|
|
5
7
|
const logger = logger_1.defaultLogger.child({ name: 'rpc-state' });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
state_getStorage: async (context, [key, hash]) => {
|
|
16
|
-
const block = await context.chain.getBlock(hash);
|
|
17
|
-
return block?.get(key);
|
|
18
|
-
},
|
|
19
|
-
state_getKeysPaged: async (context, [prefix, pageSize, startKey, hash]) => {
|
|
20
|
-
const block = await context.chain.getBlock(hash);
|
|
21
|
-
return block?.getKeysPaged({ prefix, pageSize, startKey });
|
|
22
|
-
},
|
|
23
|
-
state_queryStorageAt: async (context, [keys, hash]) => {
|
|
24
|
-
const block = await context.chain.getBlock(hash);
|
|
25
|
-
if (!block) {
|
|
26
|
-
return [];
|
|
27
|
-
}
|
|
28
|
-
const values = await Promise.all(keys.map(async (key) => [key, await block.get(key)]));
|
|
29
|
-
return [
|
|
30
|
-
{
|
|
31
|
-
block: block.hash,
|
|
32
|
-
changes: values,
|
|
33
|
-
},
|
|
34
|
-
];
|
|
35
|
-
},
|
|
36
|
-
state_call: async (context, [method, data, hash]) => {
|
|
37
|
-
const block = await context.chain.getBlock(hash);
|
|
38
|
-
if (!block) {
|
|
39
|
-
throw new shared_1.ResponseError(1, `Block ${hash} not found`);
|
|
40
|
-
}
|
|
41
|
-
const resp = await block.call(method, [data]);
|
|
42
|
-
return resp.result;
|
|
43
|
-
},
|
|
44
|
-
state_subscribeRuntimeVersion: async (context, _params, { subscribe }) => {
|
|
45
|
-
let update = (_block) => { };
|
|
46
|
-
const id = await context.chain.headState.subscrubeRuntimeVersion((block) => update(block));
|
|
47
|
-
const callback = subscribe('state_runtimeVersion', id);
|
|
48
|
-
update = async (block) => callback(await block.runtimeVersion);
|
|
49
|
-
context.chain.head.runtimeVersion.then(callback);
|
|
50
|
-
return id;
|
|
51
|
-
},
|
|
52
|
-
state_unsubscribeRuntimeVersion: async (_context, [subid], { unsubscribe }) => {
|
|
53
|
-
unsubscribe(subid);
|
|
54
|
-
},
|
|
55
|
-
state_subscribeStorage: async (context, [keys], { subscribe }) => {
|
|
56
|
-
let update = (_block, _pairs) => { };
|
|
57
|
-
const id = await context.chain.headState.subscribeStorage(keys, (block, pairs) => update(block, pairs));
|
|
58
|
-
const callback = subscribe('state_storage', id, () => context.chain.headState.unsubscribeStorage(id));
|
|
59
|
-
update = async (block, pairs) => {
|
|
60
|
-
logger.trace({ hash: block.hash }, 'state_subscribeStorage');
|
|
61
|
-
callback({
|
|
62
|
-
block: block.hash,
|
|
63
|
-
changes: pairs,
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
(async () => {
|
|
67
|
-
const pairs = await Promise.all(keys.map(async (key) => {
|
|
68
|
-
const val = await context.chain.head.get(key);
|
|
69
|
-
return [key, val];
|
|
70
|
-
}));
|
|
71
|
-
callback({
|
|
72
|
-
block: context.chain.head.hash,
|
|
73
|
-
changes: pairs,
|
|
74
|
-
});
|
|
75
|
-
})();
|
|
76
|
-
return id;
|
|
77
|
-
},
|
|
78
|
-
state_unsubscribeStorage: async (_context, [subid], { unsubscribe }) => {
|
|
79
|
-
unsubscribe(subid);
|
|
80
|
-
},
|
|
8
|
+
/**
|
|
9
|
+
* @param context
|
|
10
|
+
* @param params - [`blockhash`]
|
|
11
|
+
*
|
|
12
|
+
* @return runtime version
|
|
13
|
+
*/
|
|
14
|
+
const state_getRuntimeVersion = async (context, [hash]) => {
|
|
15
|
+
const block = await context.chain.getBlock(hash);
|
|
16
|
+
return block?.runtimeVersion;
|
|
81
17
|
};
|
|
82
|
-
exports.
|
|
18
|
+
exports.state_getRuntimeVersion = state_getRuntimeVersion;
|
|
19
|
+
/**
|
|
20
|
+
* @param context
|
|
21
|
+
* @param params - [`blockhash`]
|
|
22
|
+
*
|
|
23
|
+
* @return metadata
|
|
24
|
+
*/
|
|
25
|
+
const state_getMetadata = async (context, [hash]) => {
|
|
26
|
+
const block = await context.chain.getBlock(hash);
|
|
27
|
+
return block?.metadata;
|
|
28
|
+
};
|
|
29
|
+
exports.state_getMetadata = state_getMetadata;
|
|
30
|
+
/**
|
|
31
|
+
* @param context
|
|
32
|
+
* @param params - [`key`, `blockhash`]
|
|
33
|
+
*
|
|
34
|
+
* @return storage value
|
|
35
|
+
*/
|
|
36
|
+
const state_getStorage = async (context, [key, hash]) => {
|
|
37
|
+
const block = await context.chain.getBlock(hash);
|
|
38
|
+
return block?.get(key);
|
|
39
|
+
};
|
|
40
|
+
exports.state_getStorage = state_getStorage;
|
|
41
|
+
/**
|
|
42
|
+
* @param context
|
|
43
|
+
* @param params - [`prefix`, `pageSize`, `startKey`, `blockhash`]
|
|
44
|
+
*
|
|
45
|
+
* @return paged keys
|
|
46
|
+
*/
|
|
47
|
+
const state_getKeysPaged = async (context, [prefix, pageSize, startKey, hash]) => {
|
|
48
|
+
const block = await context.chain.getBlock(hash);
|
|
49
|
+
return block?.getKeysPaged({ prefix, pageSize, startKey });
|
|
50
|
+
};
|
|
51
|
+
exports.state_getKeysPaged = state_getKeysPaged;
|
|
52
|
+
/**
|
|
53
|
+
* @param context
|
|
54
|
+
* @param params - [`keys`, `blockhash`]
|
|
55
|
+
*
|
|
56
|
+
* @return storage values
|
|
57
|
+
*/
|
|
58
|
+
const state_queryStorageAt = async (context, [keys, hash]) => {
|
|
59
|
+
const block = await context.chain.getBlock(hash);
|
|
60
|
+
if (!block) {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
const values = await Promise.all(keys.map(async (key) => [key, await block.get(key)]));
|
|
64
|
+
return [
|
|
65
|
+
{
|
|
66
|
+
block: block.hash,
|
|
67
|
+
changes: values,
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
};
|
|
71
|
+
exports.state_queryStorageAt = state_queryStorageAt;
|
|
72
|
+
/**
|
|
73
|
+
* @param context
|
|
74
|
+
* @param params - [`method`, `data`, `blockhash`]
|
|
75
|
+
*
|
|
76
|
+
* @return result in hash
|
|
77
|
+
*/
|
|
78
|
+
const state_call = async (context, [method, data, hash]) => {
|
|
79
|
+
const block = await context.chain.getBlock(hash);
|
|
80
|
+
if (!block) {
|
|
81
|
+
throw new shared_1.ResponseError(1, `Block ${hash} not found`);
|
|
82
|
+
}
|
|
83
|
+
const resp = await block.call(method, [data]);
|
|
84
|
+
return resp.result;
|
|
85
|
+
};
|
|
86
|
+
exports.state_call = state_call;
|
|
87
|
+
/**
|
|
88
|
+
* @return subscription id
|
|
89
|
+
*/
|
|
90
|
+
const state_subscribeRuntimeVersion = async (context, _params, { subscribe }) => {
|
|
91
|
+
let update = (_block) => { };
|
|
92
|
+
const id = await context.chain.headState.subscrubeRuntimeVersion((block) => update(block));
|
|
93
|
+
const callback = subscribe('state_runtimeVersion', id);
|
|
94
|
+
update = async (block) => callback(await block.runtimeVersion);
|
|
95
|
+
context.chain.head.runtimeVersion.then(callback);
|
|
96
|
+
return id;
|
|
97
|
+
};
|
|
98
|
+
exports.state_subscribeRuntimeVersion = state_subscribeRuntimeVersion;
|
|
99
|
+
/**
|
|
100
|
+
* @param context
|
|
101
|
+
* @param params - [`subid`]
|
|
102
|
+
* @param subscriptionManager
|
|
103
|
+
*/
|
|
104
|
+
const state_unsubscribeRuntimeVersion = async (_context, [subid], { unsubscribe }) => {
|
|
105
|
+
unsubscribe(subid);
|
|
106
|
+
};
|
|
107
|
+
exports.state_unsubscribeRuntimeVersion = state_unsubscribeRuntimeVersion;
|
|
108
|
+
/**
|
|
109
|
+
* @param context
|
|
110
|
+
* @param params - [`keys`]
|
|
111
|
+
* @param subscriptionManager
|
|
112
|
+
*
|
|
113
|
+
* @return subscription id
|
|
114
|
+
*/
|
|
115
|
+
const state_subscribeStorage = async (context, [keys], { subscribe }) => {
|
|
116
|
+
let update = (_block, _pairs) => { };
|
|
117
|
+
const id = await context.chain.headState.subscribeStorage(keys, (block, pairs) => update(block, pairs));
|
|
118
|
+
const callback = subscribe('state_storage', id, () => context.chain.headState.unsubscribeStorage(id));
|
|
119
|
+
update = async (block, pairs) => {
|
|
120
|
+
logger.trace({ hash: block.hash }, 'state_subscribeStorage');
|
|
121
|
+
callback({
|
|
122
|
+
block: block.hash,
|
|
123
|
+
changes: pairs,
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
(async () => {
|
|
127
|
+
const pairs = await Promise.all(keys.map(async (key) => {
|
|
128
|
+
const val = await context.chain.head.get(key);
|
|
129
|
+
return [key, val];
|
|
130
|
+
}));
|
|
131
|
+
callback({
|
|
132
|
+
block: context.chain.head.hash,
|
|
133
|
+
changes: pairs,
|
|
134
|
+
});
|
|
135
|
+
})();
|
|
136
|
+
return id;
|
|
137
|
+
};
|
|
138
|
+
exports.state_subscribeStorage = state_subscribeStorage;
|
|
139
|
+
/**
|
|
140
|
+
* @param context
|
|
141
|
+
* @param params - [`subid`]
|
|
142
|
+
* @param subscriptionManager
|
|
143
|
+
*/
|
|
144
|
+
const state_unsubscribeStorage = async (_context, [subid], { unsubscribe }) => {
|
|
145
|
+
unsubscribe(subid);
|
|
146
|
+
};
|
|
147
|
+
exports.state_unsubscribeStorage = state_unsubscribeStorage;
|
|
148
|
+
/**
|
|
149
|
+
* @param context
|
|
150
|
+
* @param params - [`child`, `key`, `blockhash`]
|
|
151
|
+
*
|
|
152
|
+
* @return storage valuse
|
|
153
|
+
*/
|
|
154
|
+
const childstate_getStorage = async (context, [child, key, hash]) => {
|
|
155
|
+
if (!(0, chopsticks_core_1.isPrefixedChildKey)(child)) {
|
|
156
|
+
throw new shared_1.ResponseError(-32000, 'Client error: Invalid child storage key');
|
|
157
|
+
}
|
|
158
|
+
const block = await context.chain.getBlock(hash);
|
|
159
|
+
return block?.get((0, chopsticks_core_1.prefixedChildKey)(child, key));
|
|
160
|
+
};
|
|
161
|
+
exports.childstate_getStorage = childstate_getStorage;
|
|
162
|
+
/**
|
|
163
|
+
* @param context
|
|
164
|
+
* @param params - [`child`, `prefix`, `pageSize`, `startKey`, `blockhash`]
|
|
165
|
+
*
|
|
166
|
+
* @return paged keys
|
|
167
|
+
*/
|
|
168
|
+
const childstate_getKeysPaged = async (context, [child, prefix, pageSize, startKey, hash]) => {
|
|
169
|
+
if (!(0, chopsticks_core_1.isPrefixedChildKey)(child)) {
|
|
170
|
+
throw new shared_1.ResponseError(-32000, 'Client error: Invalid child storage key');
|
|
171
|
+
}
|
|
172
|
+
const block = await context.chain.getBlock(hash);
|
|
173
|
+
return block
|
|
174
|
+
?.getKeysPaged({ prefix: (0, chopsticks_core_1.prefixedChildKey)(child, prefix), pageSize, startKey: (0, chopsticks_core_1.prefixedChildKey)(child, startKey) })
|
|
175
|
+
.then((keys) => keys.map(chopsticks_core_1.stripChildPrefix));
|
|
176
|
+
};
|
|
177
|
+
exports.childstate_getKeysPaged = childstate_getKeysPaged;
|
|
@@ -1,3 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { ChainProperties } from '@acala-network/chopsticks-core';
|
|
2
|
+
import { HexString } from '@polkadot/util/types';
|
|
3
|
+
import { Handler } from '../shared';
|
|
4
|
+
export declare const system_localPeerId: () => Promise<string>;
|
|
5
|
+
export declare const system_nodeRoles: () => Promise<string[]>;
|
|
6
|
+
export declare const system_localListenAddresses: () => Promise<never[]>;
|
|
7
|
+
export declare const system_chain: Handler<void, string>;
|
|
8
|
+
export declare const system_properties: Handler<void, ChainProperties>;
|
|
9
|
+
export declare const system_name: Handler<void, string>;
|
|
10
|
+
export declare const system_version: Handler<void, string>;
|
|
11
|
+
export declare const system_chainType: Handler<void, string>;
|
|
12
|
+
export declare const system_health: () => Promise<{
|
|
13
|
+
peers: number;
|
|
14
|
+
isSyncing: boolean;
|
|
15
|
+
shouldHavePeers: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* @param context
|
|
19
|
+
* @param params - [`extrinsic`, `at`]
|
|
20
|
+
*
|
|
21
|
+
* @return ApplyExtrinsicResult (see `@polkadot/types/interfaces`) in hash
|
|
22
|
+
*/
|
|
23
|
+
export declare const system_dryRun: Handler<[HexString, HexString], string>;
|
|
24
|
+
/**
|
|
25
|
+
* @param context
|
|
26
|
+
* @param params - [`address`]
|
|
27
|
+
*/
|
|
28
|
+
export declare const system_accountNextIndex: Handler<[HexString], number>;
|
|
@@ -3,47 +3,66 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.system_accountNextIndex = exports.system_dryRun = exports.system_health = exports.system_chainType = exports.system_version = exports.system_name = exports.system_properties = exports.system_chain = exports.system_localListenAddresses = exports.system_nodeRoles = exports.system_localPeerId = void 0;
|
|
6
7
|
const util_1 = require("@polkadot/util");
|
|
7
8
|
const node_fs_1 = require("node:fs");
|
|
8
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
10
|
+
const system_localPeerId = async () => '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
|
11
|
+
exports.system_localPeerId = system_localPeerId;
|
|
12
|
+
const system_nodeRoles = async () => ['Full'];
|
|
13
|
+
exports.system_nodeRoles = system_nodeRoles;
|
|
14
|
+
const system_localListenAddresses = async () => [];
|
|
15
|
+
exports.system_localListenAddresses = system_localListenAddresses;
|
|
16
|
+
const system_chain = async (context) => {
|
|
17
|
+
return context.chain.api.getSystemChain();
|
|
18
|
+
};
|
|
19
|
+
exports.system_chain = system_chain;
|
|
20
|
+
const system_properties = async (context) => {
|
|
21
|
+
return context.chain.api.getSystemProperties();
|
|
22
|
+
};
|
|
23
|
+
exports.system_properties = system_properties;
|
|
24
|
+
const system_name = async (context) => {
|
|
25
|
+
return context.chain.api.getSystemName();
|
|
26
|
+
};
|
|
27
|
+
exports.system_name = system_name;
|
|
28
|
+
const system_version = async (_context) => {
|
|
29
|
+
const { version } = JSON.parse((0, node_fs_1.readFileSync)(node_path_1.default.join(__dirname, '../../../package.json'), 'utf-8'));
|
|
30
|
+
return `chopsticks-v${version}`;
|
|
31
|
+
};
|
|
32
|
+
exports.system_version = system_version;
|
|
33
|
+
const system_chainType = async (_context) => {
|
|
34
|
+
return 'Development';
|
|
35
|
+
};
|
|
36
|
+
exports.system_chainType = system_chainType;
|
|
37
|
+
const system_health = async () => {
|
|
38
|
+
return {
|
|
39
|
+
peers: 0,
|
|
40
|
+
isSyncing: false,
|
|
41
|
+
shouldHavePeers: false,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
exports.system_health = system_health;
|
|
45
|
+
/**
|
|
46
|
+
* @param context
|
|
47
|
+
* @param params - [`extrinsic`, `at`]
|
|
48
|
+
*
|
|
49
|
+
* @return ApplyExtrinsicResult (see `@polkadot/types/interfaces`) in hash
|
|
50
|
+
*/
|
|
51
|
+
const system_dryRun = async (context, [extrinsic, at]) => {
|
|
52
|
+
const { outcome } = await context.chain.dryRunExtrinsic(extrinsic, at);
|
|
53
|
+
return outcome.toHex();
|
|
54
|
+
};
|
|
55
|
+
exports.system_dryRun = system_dryRun;
|
|
56
|
+
/**
|
|
57
|
+
* @param context
|
|
58
|
+
* @param params - [`address`]
|
|
59
|
+
*/
|
|
60
|
+
const system_accountNextIndex = async (context, [address]) => {
|
|
61
|
+
const head = context.chain.head;
|
|
62
|
+
const registry = await head.registry;
|
|
63
|
+
const account = registry.createType('AccountId', address);
|
|
64
|
+
const result = await head.call('AccountNonceApi_account_nonce', [account.toHex()]);
|
|
65
|
+
const nonce = registry.createType('Index', (0, util_1.hexToU8a)(result.result)).toNumber();
|
|
66
|
+
return nonce + context.chain.txPool.pendingExtrinsicsBy(address).length;
|
|
67
|
+
};
|
|
68
|
+
exports.system_accountNextIndex = system_accountNextIndex;
|
package/lib/schema/index.d.ts
CHANGED
|
@@ -45,12 +45,12 @@ export declare const configSchema: z.ZodObject<{
|
|
|
45
45
|
}>;
|
|
46
46
|
}, "strip", z.ZodTypeAny, {
|
|
47
47
|
name: string;
|
|
48
|
-
id: string;
|
|
49
48
|
properties: {
|
|
50
49
|
ss58Format?: number | undefined;
|
|
51
50
|
tokenDecimals?: number | number[] | undefined;
|
|
52
51
|
tokenSymbol?: string | string[] | undefined;
|
|
53
52
|
};
|
|
53
|
+
id: string;
|
|
54
54
|
genesis: {
|
|
55
55
|
raw: {
|
|
56
56
|
top: Record<string, string>;
|
|
@@ -58,12 +58,12 @@ export declare const configSchema: z.ZodObject<{
|
|
|
58
58
|
};
|
|
59
59
|
}, {
|
|
60
60
|
name: string;
|
|
61
|
-
id: string;
|
|
62
61
|
properties: {
|
|
63
62
|
ss58Format?: number | undefined;
|
|
64
63
|
tokenDecimals?: number | number[] | undefined;
|
|
65
64
|
tokenSymbol?: string | string[] | undefined;
|
|
66
65
|
};
|
|
66
|
+
id: string;
|
|
67
67
|
genesis: {
|
|
68
68
|
raw: {
|
|
69
69
|
top: Record<string, string>;
|
|
@@ -74,6 +74,7 @@ export declare const configSchema: z.ZodObject<{
|
|
|
74
74
|
'registered-types': z.ZodOptional<z.ZodAny>;
|
|
75
75
|
'runtime-log-level': z.ZodOptional<z.ZodNumber>;
|
|
76
76
|
'offchain-worker': z.ZodOptional<z.ZodBoolean>;
|
|
77
|
+
resume: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
77
78
|
}, "strict", z.ZodTypeAny, {
|
|
78
79
|
port?: number | undefined;
|
|
79
80
|
endpoint?: string | undefined;
|
|
@@ -86,12 +87,12 @@ export declare const configSchema: z.ZodObject<{
|
|
|
86
87
|
'wasm-override'?: string | undefined;
|
|
87
88
|
genesis?: string | {
|
|
88
89
|
name: string;
|
|
89
|
-
id: string;
|
|
90
90
|
properties: {
|
|
91
91
|
ss58Format?: number | undefined;
|
|
92
92
|
tokenDecimals?: number | number[] | undefined;
|
|
93
93
|
tokenSymbol?: string | string[] | undefined;
|
|
94
94
|
};
|
|
95
|
+
id: string;
|
|
95
96
|
genesis: {
|
|
96
97
|
raw: {
|
|
97
98
|
top: Record<string, string>;
|
|
@@ -102,6 +103,7 @@ export declare const configSchema: z.ZodObject<{
|
|
|
102
103
|
'registered-types'?: any;
|
|
103
104
|
'runtime-log-level'?: number | undefined;
|
|
104
105
|
'offchain-worker'?: boolean | undefined;
|
|
106
|
+
resume?: string | number | boolean | undefined;
|
|
105
107
|
}, {
|
|
106
108
|
port?: number | undefined;
|
|
107
109
|
endpoint?: string | undefined;
|
|
@@ -114,12 +116,12 @@ export declare const configSchema: z.ZodObject<{
|
|
|
114
116
|
'wasm-override'?: string | undefined;
|
|
115
117
|
genesis?: string | {
|
|
116
118
|
name: string;
|
|
117
|
-
id: string;
|
|
118
119
|
properties: {
|
|
119
120
|
ss58Format?: number | undefined;
|
|
120
121
|
tokenDecimals?: number | number[] | undefined;
|
|
121
122
|
tokenSymbol?: string | string[] | undefined;
|
|
122
123
|
};
|
|
124
|
+
id: string;
|
|
123
125
|
genesis: {
|
|
124
126
|
raw: {
|
|
125
127
|
top: Record<string, string>;
|
|
@@ -130,6 +132,7 @@ export declare const configSchema: z.ZodObject<{
|
|
|
130
132
|
'registered-types'?: any;
|
|
131
133
|
'runtime-log-level'?: number | undefined;
|
|
132
134
|
'offchain-worker'?: boolean | undefined;
|
|
135
|
+
resume?: string | number | boolean | undefined;
|
|
133
136
|
}>;
|
|
134
137
|
export type Config = z.infer<typeof configSchema>;
|
|
135
138
|
export declare const fetchConfig: (path: string) => Promise<Config>;
|
package/lib/schema/index.js
CHANGED
|
@@ -27,6 +27,7 @@ exports.configSchema = zod_1.z
|
|
|
27
27
|
'registered-types': zod_1.z.any().optional(),
|
|
28
28
|
'runtime-log-level': zod_1.z.number().min(0).max(5).optional(),
|
|
29
29
|
'offchain-worker': zod_1.z.boolean().optional(),
|
|
30
|
+
resume: zod_1.z.union([zod_1.z.string().length(66).startsWith('0x'), zod_1.z.number(), zod_1.z.boolean()]).optional(),
|
|
30
31
|
})
|
|
31
32
|
.strict();
|
|
32
33
|
const CONFIGS_BASE_URL = 'https://raw.githubusercontent.com/AcalaNetwork/chopsticks/master/configs/';
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chopsticks JSON RPC and CLI.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This package extends the `@acala-network/chopsticks-core` package a with JSON RPC server and CLI support.
|
|
6
|
+
*
|
|
7
|
+
* @privateRemarks
|
|
8
|
+
* Above is the package documentation for 'chopsticks' package.
|
|
9
|
+
* `export` below is for tsdoc.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
export { ChainProperties, RuntimeVersion } from '@acala-network/chopsticks-core';
|
|
14
|
+
export * from './plugins/types';
|
|
15
|
+
export * from './rpc/substrate';
|
|
16
|
+
export { Context, SubscriptionManager, Handler } from './rpc/shared';
|
package/lib/types.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./plugins/types"), exports);
|
|
18
|
+
__exportStar(require("./rpc/substrate"), exports);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acala-network/chopsticks",
|
|
3
|
-
"version": "0.8.
|
|
4
|
-
"author": "
|
|
3
|
+
"version": "0.8.2",
|
|
4
|
+
"author": "Acala Developers <hello@acala.network>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"bin": "./chopsticks.js",
|
|
7
7
|
"scripts": {
|
|
@@ -13,28 +13,29 @@
|
|
|
13
13
|
"dev:acala": "cd ../..; ts-node-dev --transpile-only --inspect -r tsconfig-paths/register --notify=false packages/chopsticks/src/cli.ts -- --config=configs/acala.yml",
|
|
14
14
|
"dev:polkadot": "cd ../..; ts-node-dev --transpile-only --inspect -r tsconfig-paths/register --notify=false packages/chopsticks/src/cli.ts -- --config=configs/polkadot.yml",
|
|
15
15
|
"dev:moonriver": "cd ../..; ts-node-dev --transpile-only --inspect -r tsconfig-paths/register --notify=false packages/chopsticks/src/cli.ts -- --config=configs/moonriver.yml",
|
|
16
|
-
"dev:moonbeam": "cd ../..; ts-node-dev --transpile-only --inspect -r tsconfig-paths/register --notify=false packages/chopsticks/src/cli.ts -- --config=configs/moonbeam.yml"
|
|
16
|
+
"dev:moonbeam": "cd ../..; ts-node-dev --transpile-only --inspect -r tsconfig-paths/register --notify=false packages/chopsticks/src/cli.ts -- --config=configs/moonbeam.yml",
|
|
17
|
+
"docs:prep": "typedoc"
|
|
17
18
|
},
|
|
18
19
|
"dependencies": {
|
|
19
|
-
"@acala-network/chopsticks-core": "0.8.
|
|
20
|
+
"@acala-network/chopsticks-core": "0.8.2",
|
|
20
21
|
"@pnpm/npm-conf": "^2.2.2",
|
|
21
22
|
"@polkadot/api": "^10.9.1",
|
|
22
|
-
"axios": "^1.5.
|
|
23
|
+
"axios": "^1.5.1",
|
|
23
24
|
"dotenv": "^16.3.1",
|
|
24
25
|
"global-agent": "^3.0.0",
|
|
25
26
|
"js-yaml": "^4.1.0",
|
|
26
27
|
"jsondiffpatch": "^0.5.0",
|
|
27
28
|
"lodash": "^4.17.21",
|
|
28
|
-
"ws": "^8.
|
|
29
|
+
"ws": "^8.14.2",
|
|
29
30
|
"yargs": "^17.7.2",
|
|
30
|
-
"zod": "^3.22.
|
|
31
|
+
"zod": "^3.22.3"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@types/global-agent": "^2.1.1",
|
|
34
35
|
"@types/js-yaml": "^4.0.5",
|
|
35
|
-
"@types/lodash": "^4.14.
|
|
36
|
+
"@types/lodash": "^4.14.199",
|
|
36
37
|
"@types/node": "^20.5.7",
|
|
37
|
-
"@types/ws": "^8.5.
|
|
38
|
+
"@types/ws": "^8.5.6",
|
|
38
39
|
"@types/yargs": "^17.0.24",
|
|
39
40
|
"ts-node": "^10.9.1",
|
|
40
41
|
"ts-node-dev": "^2.0.0",
|