@acala-network/chopsticks 0.9.1-2 → 0.9.1-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/dist/cjs/cli-options.js +30 -15
- package/dist/cjs/cli.js +69 -80
- package/dist/cjs/context.js +93 -64
- package/dist/cjs/index.js +32 -20
- package/dist/cjs/logger.js +18 -5
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/plugins/decode-key/index.js +23 -20
- package/dist/cjs/plugins/dry-run/cli.js +46 -41
- package/dist/cjs/plugins/dry-run/dry-run-extrinsic.js +37 -21
- package/dist/cjs/plugins/dry-run/dry-run-preimage.js +101 -47
- package/dist/cjs/plugins/dry-run/index.js +18 -17
- package/dist/cjs/plugins/dry-run/rpc.js +48 -74
- package/dist/cjs/plugins/follow-chain/index.js +78 -46
- package/dist/cjs/plugins/index.js +76 -40
- package/dist/cjs/plugins/new-block/index.js +21 -53
- package/dist/cjs/plugins/run-block/index.js +145 -104
- package/dist/cjs/plugins/set-block-build-mode/index.js +17 -25
- package/dist/cjs/plugins/set-head/index.js +13 -23
- package/dist/cjs/plugins/set-runtime-log-level/index.js +16 -23
- package/dist/cjs/plugins/set-storage/index.js +16 -35
- package/dist/cjs/plugins/time-travel/index.js +13 -23
- package/dist/cjs/plugins/try-runtime/index.js +51 -42
- package/dist/cjs/plugins/types.js +43 -18
- package/dist/cjs/rpc/index.js +30 -21
- package/dist/cjs/schema/index.js +77 -48
- package/dist/cjs/server.js +89 -65
- package/dist/cjs/setup-with-server.js +19 -13
- package/dist/cjs/types.js +30 -18
- package/dist/cjs/utils/decoder.js +32 -16
- package/dist/cjs/utils/generate-html-diff.js +38 -19
- package/dist/cjs/utils/index.js +20 -19
- package/dist/cjs/utils/open-html.js +12 -6
- package/dist/cjs/utils/override.js +40 -27
- package/dist/cjs/utils/tunnel.js +11 -14
- package/dist/esm/cli-options.js +11 -11
- package/dist/esm/cli.js +45 -60
- package/dist/esm/context.js +20 -24
- package/dist/esm/plugins/decode-key/index.js +9 -12
- package/dist/esm/plugins/dry-run/cli.js +32 -33
- package/dist/esm/plugins/dry-run/dry-run-extrinsic.js +18 -8
- package/dist/esm/plugins/dry-run/dry-run-preimage.js +72 -24
- package/dist/esm/plugins/dry-run/rpc.js +14 -24
- package/dist/esm/plugins/follow-chain/index.js +52 -28
- package/dist/esm/plugins/index.js +8 -6
- package/dist/esm/plugins/new-block/index.js +8 -9
- package/dist/esm/plugins/run-block/index.js +97 -65
- package/dist/esm/plugins/set-block-build-mode/index.js +4 -3
- package/dist/esm/plugins/set-head/index.js +2 -4
- package/dist/esm/plugins/set-runtime-log-level/index.js +4 -3
- package/dist/esm/plugins/set-storage/index.js +3 -4
- package/dist/esm/plugins/time-travel/index.js +2 -4
- package/dist/esm/plugins/try-runtime/index.js +33 -30
- package/dist/esm/rpc/index.js +18 -15
- package/dist/esm/schema/index.js +31 -18
- package/dist/esm/server.js +70 -52
- package/dist/esm/setup-with-server.js +3 -3
- package/dist/esm/types.js +12 -1
- package/dist/esm/utils/decoder.js +12 -4
- package/dist/esm/utils/generate-html-diff.js +10 -6
- package/dist/esm/utils/open-html.js +1 -1
- package/dist/esm/utils/override.js +11 -13
- package/dist/esm/utils/tunnel.js +1 -8
- package/package.json +13 -17
- package/dist/esm/package.json +0 -1
- /package/{chopsticks.js → chopsticks.cjs} +0 -0
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "setupWithServer", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return setupWithServer;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _server = require("./server");
|
|
12
|
+
const _rpc = require("./rpc");
|
|
13
|
+
const _chopstickscore = require("@acala-network/chopsticks-core");
|
|
14
|
+
const _context = require("./context");
|
|
15
|
+
const setupWithServer = async (argv)=>{
|
|
16
|
+
const context = await (0, _context.setupContext)(argv);
|
|
10
17
|
const port = argv.port ?? 8000;
|
|
11
18
|
if (argv.genesis) {
|
|
12
19
|
// mine 1st block when starting from genesis to set some mock validation data
|
|
13
20
|
await context.chain.newBlock();
|
|
14
21
|
}
|
|
15
|
-
const { close, port: listenPort } = await (0,
|
|
16
|
-
|
|
22
|
+
const { close, port: listenPort } = await (0, _server.createServer)((0, _rpc.handler)(context), port);
|
|
23
|
+
_chopstickscore.logger.info(`${await context.chain.api.getSystemChain()} RPC listening on port ${listenPort}`);
|
|
17
24
|
return {
|
|
18
25
|
...context,
|
|
19
26
|
listenPort,
|
|
20
|
-
async close() {
|
|
27
|
+
async close () {
|
|
21
28
|
await context.chain.close();
|
|
22
29
|
await close();
|
|
23
|
-
}
|
|
30
|
+
}
|
|
24
31
|
};
|
|
25
32
|
};
|
|
26
|
-
exports.setupWithServer = setupWithServer;
|
package/dist/cjs/types.js
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
+
*/ "use strict";
|
|
13
|
+
Object.defineProperty(exports, "__esModule", {
|
|
14
|
+
value: true
|
|
15
|
+
});
|
|
16
|
+
_export_star(require("@acala-network/chopsticks-core/src/rpc/substrate"), exports);
|
|
17
|
+
_export_star(require("./plugins/types"), exports);
|
|
18
|
+
function _export_star(from, to) {
|
|
19
|
+
Object.keys(from).forEach(function(k) {
|
|
20
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
21
|
+
Object.defineProperty(to, k, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function() {
|
|
24
|
+
return from[k];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return from;
|
|
30
|
+
}
|
|
@@ -1,22 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "decodeStorageDiff", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return decodeStorageDiff;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _chopstickscore = require("@acala-network/chopsticks-core");
|
|
12
|
+
const _jsondiffpatch = require("jsondiffpatch");
|
|
13
|
+
const _lodash = /*#__PURE__*/ _interop_require_default(require("lodash"));
|
|
14
|
+
function _interop_require_default(obj) {
|
|
15
|
+
return obj && obj.__esModule ? obj : {
|
|
16
|
+
default: obj
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const diffPatcher = (0, _jsondiffpatch.create)({
|
|
20
|
+
array: {
|
|
21
|
+
detectMove: false
|
|
22
|
+
},
|
|
23
|
+
textDiff: {
|
|
24
|
+
minLength: Number.MAX_VALUE
|
|
25
|
+
}
|
|
13
26
|
});
|
|
14
|
-
const decodeStorageDiff = async (block, diff)
|
|
15
|
-
const [oldState, newState] = await (0,
|
|
16
|
-
const oldStateWithoutEvents =
|
|
27
|
+
const decodeStorageDiff = async (block, diff)=>{
|
|
28
|
+
const [oldState, newState] = await (0, _chopstickscore.decodeBlockStorageDiff)(block, diff);
|
|
29
|
+
const oldStateWithoutEvents = _lodash.default.cloneDeep(oldState);
|
|
17
30
|
if (oldStateWithoutEvents['system']?.['events']) {
|
|
18
31
|
oldStateWithoutEvents['system']['events'] = [];
|
|
19
32
|
}
|
|
20
|
-
return {
|
|
33
|
+
return {
|
|
34
|
+
oldState,
|
|
35
|
+
newState,
|
|
36
|
+
delta: diffPatcher.diff(oldStateWithoutEvents, newState)
|
|
37
|
+
};
|
|
21
38
|
};
|
|
22
|
-
exports.decodeStorageDiff = decodeStorageDiff;
|
|
@@ -1,24 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
generateHtmlDiff: function() {
|
|
13
|
+
return generateHtmlDiff;
|
|
14
|
+
},
|
|
15
|
+
generateHtmlDiffPreviewFile: function() {
|
|
16
|
+
return generateHtmlDiffPreviewFile;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _decoder = require("./decoder");
|
|
20
|
+
const _nodefs = require("node:fs");
|
|
21
|
+
const _lodash = /*#__PURE__*/ _interop_require_default(require("lodash"));
|
|
22
|
+
function _interop_require_default(obj) {
|
|
23
|
+
return obj && obj.__esModule ? obj : {
|
|
24
|
+
default: obj
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const generateHtmlDiff = async (block, diff)=>{
|
|
28
|
+
const { oldState, delta } = await (0, _decoder.decodeStorageDiff)(block, diff);
|
|
29
|
+
const htmlTemplate = (0, _nodefs.readFileSync)(new URL('template/diff.html', require("url").pathToFileURL(__filename).toString()), 'utf-8');
|
|
30
|
+
return _lodash.default.template(htmlTemplate)({
|
|
31
|
+
left: JSON.stringify(oldState),
|
|
32
|
+
delta: JSON.stringify(delta)
|
|
33
|
+
});
|
|
4
34
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const node_url_1 = __importDefault(require("node:url"));
|
|
11
|
-
const generateHtmlDiff = async (block, diff) => {
|
|
12
|
-
const { oldState, delta } = await (0, decoder_1.decodeStorageDiff)(block, diff);
|
|
13
|
-
const htmlTemplate = (0, node_fs_1.readFileSync)(node_url_1.default.resolve(__filename, './template/diff.html'), 'utf-8');
|
|
14
|
-
return lodash_1.default.template(htmlTemplate)({ left: JSON.stringify(oldState), delta: JSON.stringify(delta) });
|
|
15
|
-
};
|
|
16
|
-
exports.generateHtmlDiff = generateHtmlDiff;
|
|
17
|
-
const generateHtmlDiffPreviewFile = async (block, diff, filename) => {
|
|
18
|
-
const html = await (0, exports.generateHtmlDiff)(block, diff);
|
|
19
|
-
(0, node_fs_1.mkdirSync)('./preview', { recursive: true });
|
|
35
|
+
const generateHtmlDiffPreviewFile = async (block, diff, filename)=>{
|
|
36
|
+
const html = await generateHtmlDiff(block, diff);
|
|
37
|
+
(0, _nodefs.mkdirSync)('./preview', {
|
|
38
|
+
recursive: true
|
|
39
|
+
});
|
|
20
40
|
const filePath = `./preview/${filename}.html`;
|
|
21
|
-
(0,
|
|
41
|
+
(0, _nodefs.writeFileSync)(filePath, html);
|
|
22
42
|
return filePath;
|
|
23
43
|
};
|
|
24
|
-
exports.generateHtmlDiffPreviewFile = generateHtmlDiffPreviewFile;
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./decoder"), exports);
|
|
6
|
+
_export_star(require("./generate-html-diff"), exports);
|
|
7
|
+
_export_star(require("./open-html"), exports);
|
|
8
|
+
_export_star(require("./override"), exports);
|
|
9
|
+
function _export_star(from, to) {
|
|
10
|
+
Object.keys(from).forEach(function(k) {
|
|
11
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
12
|
+
Object.defineProperty(to, k, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function() {
|
|
15
|
+
return from[k];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return from;
|
|
21
|
+
}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "openHtml", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return openHtml;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _nodechild_process = require("node:child_process");
|
|
12
|
+
const openHtml = (filePath)=>{
|
|
6
13
|
const start = process.platform == 'darwin' ? 'open' : process.platform == 'win32' ? 'start' : 'xdg-open';
|
|
7
|
-
(0,
|
|
14
|
+
(0, _nodechild_process.execSync)(start + ' ' + filePath);
|
|
8
15
|
};
|
|
9
|
-
exports.openHtml = openHtml;
|
|
@@ -1,51 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
overrideStorage: function() {
|
|
13
|
+
return overrideStorage;
|
|
14
|
+
},
|
|
15
|
+
overrideWasm: function() {
|
|
16
|
+
return overrideWasm;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _chopstickscore = require("@acala-network/chopsticks-core");
|
|
20
|
+
const _nodefs = require("node:fs");
|
|
21
|
+
const _jsyaml = /*#__PURE__*/ _interop_require_default(require("js-yaml"));
|
|
22
|
+
const _logger = require("../logger");
|
|
23
|
+
function _interop_require_default(obj) {
|
|
24
|
+
return obj && obj.__esModule ? obj : {
|
|
25
|
+
default: obj
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const overrideStorage = async (chain, storage, at)=>{
|
|
12
29
|
if (storage == null) {
|
|
13
30
|
return;
|
|
14
31
|
}
|
|
15
32
|
let storageValue;
|
|
16
33
|
if (typeof storage === 'string') {
|
|
17
|
-
if (!(0,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
34
|
+
if (!(0, _nodefs.existsSync)(storage)) throw Error(`File ${storage} does not exist`);
|
|
35
|
+
storageValue = _jsyaml.default.load(String((0, _nodefs.readFileSync)(storage)));
|
|
36
|
+
} else {
|
|
22
37
|
storageValue = storage;
|
|
23
38
|
}
|
|
24
|
-
const blockHash = await (0,
|
|
25
|
-
|
|
39
|
+
const blockHash = await (0, _chopstickscore.setStorage)(chain, storageValue, at);
|
|
40
|
+
_logger.defaultLogger.trace({
|
|
41
|
+
blockHash,
|
|
42
|
+
storage
|
|
43
|
+
}, 'OverrideStorage');
|
|
26
44
|
};
|
|
27
|
-
|
|
28
|
-
const overrideWasm = async (chain, wasmPath, at) => {
|
|
45
|
+
const overrideWasm = async (chain, wasmPath, at)=>{
|
|
29
46
|
if (wasmPath == null) {
|
|
30
47
|
return;
|
|
31
48
|
}
|
|
32
|
-
const wasm = (0,
|
|
49
|
+
const wasm = (0, _nodefs.readFileSync)(wasmPath);
|
|
33
50
|
let wasmHex;
|
|
34
51
|
if (wasm.at(0) === 0x30 && wasm.at(1) === 0x78) {
|
|
35
52
|
// starts with 0x
|
|
36
53
|
wasmHex = wasm.toString().trim();
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
54
|
+
} else {
|
|
39
55
|
wasmHex = '0x' + wasm.toString('hex');
|
|
40
56
|
}
|
|
41
57
|
if (at) {
|
|
42
58
|
const block = await chain.getBlock(at);
|
|
43
|
-
if (!block)
|
|
44
|
-
throw new Error(`Cannot find block ${at}`);
|
|
59
|
+
if (!block) throw new Error(`Cannot find block ${at}`);
|
|
45
60
|
block.setWasm(wasmHex);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
61
|
+
} else {
|
|
48
62
|
chain.head.setWasm(wasmHex);
|
|
49
63
|
}
|
|
50
64
|
};
|
|
51
|
-
exports.overrideWasm = overrideWasm;
|
package/dist/cjs/utils/tunnel.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
6
5
|
require("global-agent/bootstrap");
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
npmConfig.get('https-proxy') ||
|
|
16
|
-
global.GLOBAL_AGENT.HTTP_PROXY;
|
|
6
|
+
const _npmconf = /*#__PURE__*/ _interop_require_default(require("@pnpm/npm-conf"));
|
|
7
|
+
function _interop_require_default(obj) {
|
|
8
|
+
return obj && obj.__esModule ? obj : {
|
|
9
|
+
default: obj
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
const npmConfig = (0, _npmconf.default)().config;
|
|
13
|
+
global.GLOBAL_AGENT.HTTP_PROXY = process.env.HTTP_PROXY || process.env.http_proxy || process.env.HTTPS_PROXY || process.env.https_proxy || npmConfig.get('proxy') || npmConfig.get('https-proxy') || global.GLOBAL_AGENT.HTTP_PROXY;
|
package/dist/esm/cli-options.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
export const defaultOptions = {
|
|
2
2
|
endpoint: {
|
|
3
3
|
desc: 'Endpoint to connect to',
|
|
4
|
-
string: true
|
|
4
|
+
string: true
|
|
5
5
|
},
|
|
6
6
|
block: {
|
|
7
7
|
desc: 'Block hash or block number. Default to latest block',
|
|
8
|
-
string: true
|
|
8
|
+
string: true
|
|
9
9
|
},
|
|
10
10
|
'wasm-override': {
|
|
11
11
|
desc: 'Path to wasm override',
|
|
12
|
-
string: true
|
|
12
|
+
string: true
|
|
13
13
|
},
|
|
14
14
|
db: {
|
|
15
15
|
desc: 'Path to database',
|
|
16
|
-
string: true
|
|
16
|
+
string: true
|
|
17
17
|
},
|
|
18
18
|
config: {
|
|
19
19
|
desc: 'Path to config file with default options',
|
|
20
|
-
string: true
|
|
20
|
+
string: true
|
|
21
21
|
},
|
|
22
22
|
'runtime-log-level': {
|
|
23
23
|
desc: 'Runtime maximum log level [off = 0; error = 1; warn = 2; info = 3; debug = 4; trace = 5]',
|
|
24
|
-
number: true
|
|
24
|
+
number: true
|
|
25
25
|
},
|
|
26
26
|
'offchain-worker': {
|
|
27
27
|
desc: 'Enable offchain worker',
|
|
28
|
-
boolean: true
|
|
29
|
-
}
|
|
28
|
+
boolean: true
|
|
29
|
+
}
|
|
30
30
|
};
|
|
31
31
|
export const mockOptions = {
|
|
32
32
|
'import-storage': {
|
|
33
33
|
desc: 'Pre-defined JSON/YAML storage file path',
|
|
34
|
-
string: true
|
|
34
|
+
string: true
|
|
35
35
|
},
|
|
36
36
|
'mock-signature-host': {
|
|
37
37
|
desc: 'Mock signature host so any signature starts with 0xdeadbeef and filled by 0xcd is considered valid',
|
|
38
|
-
boolean: true
|
|
39
|
-
}
|
|
38
|
+
boolean: true
|
|
39
|
+
}
|
|
40
40
|
};
|
package/dist/esm/cli.js
CHANGED
|
@@ -8,60 +8,57 @@ import { defaultOptions, mockOptions } from './cli-options';
|
|
|
8
8
|
import { pluginExtendCli } from './plugins';
|
|
9
9
|
import { setupWithServer } from '.';
|
|
10
10
|
dotenvConfig();
|
|
11
|
-
const processArgv = async (argv)
|
|
11
|
+
const processArgv = async (argv)=>{
|
|
12
12
|
if (argv.config) {
|
|
13
13
|
Object.assign(argv, _.defaults(argv, await fetchConfig(argv.config)));
|
|
14
14
|
}
|
|
15
15
|
argv.port = argv.port ?? (process.env.PORT ? Number(process.env.PORT) : 8000);
|
|
16
16
|
};
|
|
17
|
-
const commands = yargs(hideBin(process.argv))
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
17
|
+
const commands = yargs(hideBin(process.argv)).scriptName('chopsticks').middleware(processArgv, false).command('*', 'Dev mode, fork off a chain', (yargs)=>yargs.options({
|
|
18
|
+
...defaultOptions,
|
|
19
|
+
...mockOptions,
|
|
20
|
+
port: {
|
|
21
|
+
desc: 'Port to listen on',
|
|
22
|
+
number: true
|
|
23
|
+
},
|
|
24
|
+
'build-block-mode': {
|
|
25
|
+
desc: 'Build block mode. Default to Batch',
|
|
26
|
+
enum: [
|
|
27
|
+
BuildBlockMode.Batch,
|
|
28
|
+
BuildBlockMode.Manual,
|
|
29
|
+
BuildBlockMode.Instant
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
'allow-unresolved-imports': {
|
|
33
|
+
desc: 'Allow wasm unresolved imports',
|
|
34
|
+
boolean: true
|
|
35
|
+
},
|
|
36
|
+
'max-memory-block-count': {
|
|
37
|
+
desc: 'Max memory block count',
|
|
38
|
+
number: true
|
|
39
|
+
},
|
|
40
|
+
resume: {
|
|
41
|
+
desc: `Resume from the specified block hash or block number in db.
|
|
41
42
|
If true, it will resume from the latest block in db.
|
|
42
43
|
Note this will override the block option`,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}), async (argv)
|
|
44
|
+
string: true
|
|
45
|
+
}
|
|
46
|
+
}), async (argv)=>{
|
|
46
47
|
await setupWithServer(argv);
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
})
|
|
61
|
-
.alias('relaychain', 'r')
|
|
62
|
-
.alias('parachain', 'p'), async (argv) => {
|
|
48
|
+
}).command('xcm', 'XCM setup with relaychain and parachains', (yargs)=>yargs.options({
|
|
49
|
+
relaychain: {
|
|
50
|
+
desc: 'Relaychain config file path',
|
|
51
|
+
string: true
|
|
52
|
+
},
|
|
53
|
+
parachain: {
|
|
54
|
+
desc: 'Parachain config file path',
|
|
55
|
+
type: 'array',
|
|
56
|
+
string: true,
|
|
57
|
+
required: true
|
|
58
|
+
}
|
|
59
|
+
}).alias('relaychain', 'r').alias('parachain', 'p'), async (argv)=>{
|
|
63
60
|
const parachains = [];
|
|
64
|
-
for (const config of argv.parachain)
|
|
61
|
+
for (const config of argv.parachain){
|
|
65
62
|
const { chain } = await setupWithServer(await fetchConfig(config));
|
|
66
63
|
parachains.push(chain);
|
|
67
64
|
}
|
|
@@ -70,21 +67,9 @@ const commands = yargs(hideBin(process.argv))
|
|
|
70
67
|
}
|
|
71
68
|
if (argv.relaychain) {
|
|
72
69
|
const { chain: relaychain } = await setupWithServer(await fetchConfig(argv.relaychain));
|
|
73
|
-
for (const parachain of parachains)
|
|
70
|
+
for (const parachain of parachains){
|
|
74
71
|
await connectVertical(relaychain, parachain);
|
|
75
72
|
}
|
|
76
73
|
}
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
.help()
|
|
80
|
-
.alias('help', 'h')
|
|
81
|
-
.alias('version', 'v')
|
|
82
|
-
.alias('config', 'c')
|
|
83
|
-
.alias('endpoint', 'e')
|
|
84
|
-
.alias('port', 'p')
|
|
85
|
-
.alias('block', 'b')
|
|
86
|
-
.alias('import-storage', 's')
|
|
87
|
-
.alias('wasm-override', 'w')
|
|
88
|
-
.usage('Usage: $0 <command> [options]')
|
|
89
|
-
.example('$0', '-c acala');
|
|
90
|
-
pluginExtendCli(commands).then(() => commands.parse());
|
|
74
|
+
}).strict().help().alias('help', 'h').alias('version', 'v').alias('config', 'c').alias('endpoint', 'e').alias('port', 'p').alias('block', 'b').alias('import-storage', 's').alias('wasm-override', 'w').usage('Usage: $0 <command> [options]').example('$0', '-c acala');
|
|
75
|
+
pluginExtendCli(commands).then(()=>commands.parse());
|