@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,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,99 +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;
|
|
3
4
|
const chopsticks_core_1 = require("@acala-network/chopsticks-core");
|
|
4
5
|
const shared_1 = require("../shared");
|
|
5
6
|
const logger_1 = require("../../logger");
|
|
6
7
|
const logger = logger_1.defaultLogger.child({ name: 'rpc-state' });
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
state_getStorage: async (context, [key, hash]) => {
|
|
17
|
-
const block = await context.chain.getBlock(hash);
|
|
18
|
-
return block?.get(key);
|
|
19
|
-
},
|
|
20
|
-
state_getKeysPaged: async (context, [prefix, pageSize, startKey, hash]) => {
|
|
21
|
-
const block = await context.chain.getBlock(hash);
|
|
22
|
-
return block?.getKeysPaged({ prefix, pageSize, startKey });
|
|
23
|
-
},
|
|
24
|
-
state_queryStorageAt: async (context, [keys, hash]) => {
|
|
25
|
-
const block = await context.chain.getBlock(hash);
|
|
26
|
-
if (!block) {
|
|
27
|
-
return [];
|
|
28
|
-
}
|
|
29
|
-
const values = await Promise.all(keys.map(async (key) => [key, await block.get(key)]));
|
|
30
|
-
return [
|
|
31
|
-
{
|
|
32
|
-
block: block.hash,
|
|
33
|
-
changes: values,
|
|
34
|
-
},
|
|
35
|
-
];
|
|
36
|
-
},
|
|
37
|
-
state_call: async (context, [method, data, hash]) => {
|
|
38
|
-
const block = await context.chain.getBlock(hash);
|
|
39
|
-
if (!block) {
|
|
40
|
-
throw new shared_1.ResponseError(1, `Block ${hash} not found`);
|
|
41
|
-
}
|
|
42
|
-
const resp = await block.call(method, [data]);
|
|
43
|
-
return resp.result;
|
|
44
|
-
},
|
|
45
|
-
state_subscribeRuntimeVersion: async (context, _params, { subscribe }) => {
|
|
46
|
-
let update = (_block) => { };
|
|
47
|
-
const id = await context.chain.headState.subscrubeRuntimeVersion((block) => update(block));
|
|
48
|
-
const callback = subscribe('state_runtimeVersion', id);
|
|
49
|
-
update = async (block) => callback(await block.runtimeVersion);
|
|
50
|
-
context.chain.head.runtimeVersion.then(callback);
|
|
51
|
-
return id;
|
|
52
|
-
},
|
|
53
|
-
state_unsubscribeRuntimeVersion: async (_context, [subid], { unsubscribe }) => {
|
|
54
|
-
unsubscribe(subid);
|
|
55
|
-
},
|
|
56
|
-
state_subscribeStorage: async (context, [keys], { subscribe }) => {
|
|
57
|
-
let update = (_block, _pairs) => { };
|
|
58
|
-
const id = await context.chain.headState.subscribeStorage(keys, (block, pairs) => update(block, pairs));
|
|
59
|
-
const callback = subscribe('state_storage', id, () => context.chain.headState.unsubscribeStorage(id));
|
|
60
|
-
update = async (block, pairs) => {
|
|
61
|
-
logger.trace({ hash: block.hash }, 'state_subscribeStorage');
|
|
62
|
-
callback({
|
|
63
|
-
block: block.hash,
|
|
64
|
-
changes: pairs,
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
(async () => {
|
|
68
|
-
const pairs = await Promise.all(keys.map(async (key) => {
|
|
69
|
-
const val = await context.chain.head.get(key);
|
|
70
|
-
return [key, val];
|
|
71
|
-
}));
|
|
72
|
-
callback({
|
|
73
|
-
block: context.chain.head.hash,
|
|
74
|
-
changes: pairs,
|
|
75
|
-
});
|
|
76
|
-
})();
|
|
77
|
-
return id;
|
|
78
|
-
},
|
|
79
|
-
state_unsubscribeStorage: async (_context, [subid], { unsubscribe }) => {
|
|
80
|
-
unsubscribe(subid);
|
|
81
|
-
},
|
|
82
|
-
childstate_getStorage: async (context, [child, key, hash]) => {
|
|
83
|
-
if (!(0, chopsticks_core_1.isPrefixedChildKey)(child)) {
|
|
84
|
-
throw new shared_1.ResponseError(-32000, 'Client error: Invalid child storage key');
|
|
85
|
-
}
|
|
86
|
-
const block = await context.chain.getBlock(hash);
|
|
87
|
-
return block?.get((0, chopsticks_core_1.prefixedChildKey)(child, key));
|
|
88
|
-
},
|
|
89
|
-
childstate_getKeysPaged: async (context, [child, prefix, pageSize, startKey, hash]) => {
|
|
90
|
-
if (!(0, chopsticks_core_1.isPrefixedChildKey)(child)) {
|
|
91
|
-
throw new shared_1.ResponseError(-32000, 'Client error: Invalid child storage key');
|
|
92
|
-
}
|
|
93
|
-
const block = await context.chain.getBlock(hash);
|
|
94
|
-
return block
|
|
95
|
-
?.getKeysPaged({ prefix: (0, chopsticks_core_1.prefixedChildKey)(child, prefix), pageSize, startKey: (0, chopsticks_core_1.prefixedChildKey)(child, startKey) })
|
|
96
|
-
.then((keys) => keys.map(chopsticks_core_1.stripChildPrefix));
|
|
97
|
-
},
|
|
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;
|
|
98
17
|
};
|
|
99
|
-
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/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/lib/utils/signFake.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import { ApiPromise } from '@polkadot/api';
|
|
|
2
2
|
import { GenericExtrinsic } from '@polkadot/types';
|
|
3
3
|
import { SignatureOptions } from '@polkadot/types/types';
|
|
4
4
|
export type SignFakeOptions = Partial<SignatureOptions>;
|
|
5
|
-
export declare const signFakeWithApi: (api: ApiPromise, tx: GenericExtrinsic, addr: string, options?: SignFakeOptions) => Promise<
|
|
6
|
-
export declare const signFake: (tx: GenericExtrinsic, addr: string, options: SignatureOptions) =>
|
|
5
|
+
export declare const signFakeWithApi: (api: ApiPromise, tx: GenericExtrinsic, addr: string, options?: SignFakeOptions) => Promise<void>;
|
|
6
|
+
export declare const signFake: (tx: GenericExtrinsic, addr: string, options: SignatureOptions) => void;
|
package/lib/utils/signFake.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.signFake = exports.signFakeWithApi = void 0;
|
|
4
4
|
const signFakeWithApi = async (api, tx, addr, options = {}) => {
|
|
5
5
|
const nonce = options.nonce ?? (await api.query.system.account(addr)).nonce;
|
|
6
|
-
|
|
6
|
+
(0, exports.signFake)(tx, addr, {
|
|
7
7
|
nonce,
|
|
8
8
|
genesisHash: api.genesisHash,
|
|
9
9
|
runtimeVersion: api.runtimeVersion,
|
|
@@ -18,6 +18,5 @@ const signFake = (tx, addr, options) => {
|
|
|
18
18
|
mockSignature.set([0xde, 0xad, 0xbe, 0xef]);
|
|
19
19
|
tx.signFake(addr, options);
|
|
20
20
|
tx.signature.set(mockSignature);
|
|
21
|
-
return tx;
|
|
22
21
|
};
|
|
23
22
|
exports.signFake = signFake;
|
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.3",
|
|
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.3",
|
|
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",
|