@acala-network/chopsticks 0.9.1-4 → 0.9.1-5
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.js +5 -1
- package/dist/cjs/context.js +4 -0
- package/dist/cjs/plugins/index.js +14 -19
- package/dist/cjs/utils/tunnel.js +2 -1
- package/dist/esm/cli.js +5 -1
- package/dist/esm/context.js +4 -0
- package/dist/esm/plugins/index.js +11 -19
- package/dist/esm/utils/tunnel.js +2 -1
- package/dist/types/plugins/index.d.ts +1 -0
- package/dist/types/utils/tunnel.d.ts +1 -1
- package/package.json +3 -3
package/dist/cjs/cli.js
CHANGED
|
@@ -81,4 +81,8 @@ const commands = (0, _yargs.default)((0, _helpers.hideBin)(process.argv)).script
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
}).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');
|
|
84
|
-
|
|
84
|
+
if (!process.env.DISABLE_PLUGINS) {
|
|
85
|
+
(0, _index1.pluginExtendCli)(commands).then(()=>commands.parse());
|
|
86
|
+
} else {
|
|
87
|
+
commands.parse();
|
|
88
|
+
}
|
package/dist/cjs/context.js
CHANGED
|
@@ -19,6 +19,7 @@ _export(exports, {
|
|
|
19
19
|
require("./utils/tunnel.js");
|
|
20
20
|
const _chopstickscore = require("@acala-network/chopsticks-core");
|
|
21
21
|
const _chopsticksdb = require("@acala-network/chopsticks-db");
|
|
22
|
+
const _index = require("./plugins/index.js");
|
|
22
23
|
const _override = require("./utils/override.js");
|
|
23
24
|
const _axios = /*#__PURE__*/ _interop_require_default(require("axios"));
|
|
24
25
|
function _interop_require_default(obj) {
|
|
@@ -140,6 +141,9 @@ const setupContext = async (argv, overrideParent = false)=>{
|
|
|
140
141
|
// added that have storage imports
|
|
141
142
|
await (0, _override.overrideWasm)(chain, argv['wasm-override'], at);
|
|
142
143
|
await (0, _override.overrideStorage)(chain, argv['import-storage'], at);
|
|
144
|
+
if (!process.env.DISABLE_PLUGINS) {
|
|
145
|
+
await (0, _index.loadRPCPlugins)();
|
|
146
|
+
}
|
|
143
147
|
return {
|
|
144
148
|
chain
|
|
145
149
|
};
|
|
@@ -9,6 +9,9 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
+
loadRPCPlugins: function() {
|
|
13
|
+
return loadRPCPlugins;
|
|
14
|
+
},
|
|
12
15
|
pluginExtendCli: function() {
|
|
13
16
|
return pluginExtendCli;
|
|
14
17
|
},
|
|
@@ -16,6 +19,7 @@ _export(exports, {
|
|
|
16
19
|
return pluginHandlers;
|
|
17
20
|
}
|
|
18
21
|
});
|
|
22
|
+
const _fs = require("fs");
|
|
19
23
|
const _lodash = /*#__PURE__*/ _interop_require_default(require("lodash"));
|
|
20
24
|
const _logger = require("../logger.js");
|
|
21
25
|
function _interop_require_default(obj) {
|
|
@@ -68,35 +72,26 @@ const logger = _logger.defaultLogger.child({
|
|
|
68
72
|
name: 'plugin'
|
|
69
73
|
});
|
|
70
74
|
const pluginHandlers = {};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
'follow-chain',
|
|
75
|
-
'new-block',
|
|
76
|
-
'run-block',
|
|
77
|
-
'set-block-build-mode',
|
|
78
|
-
'set-head',
|
|
79
|
-
'set-runtime-log-level',
|
|
80
|
-
'set-storage',
|
|
81
|
-
'time-travel',
|
|
82
|
-
'try-runtime'
|
|
83
|
-
];
|
|
84
|
-
(async ()=>{
|
|
75
|
+
// list of plugins directory
|
|
76
|
+
const plugins = (0, _fs.readdirSync)(new URL('.', require("url").pathToFileURL(__filename).toString())).filter((file)=>(0, _fs.lstatSync)(new URL(file, require("url").pathToFileURL(__filename).toString())).isDirectory());
|
|
77
|
+
const loadRPCPlugins = async ()=>{
|
|
85
78
|
for (const plugin of plugins){
|
|
86
|
-
const
|
|
79
|
+
const location = new URL(`${plugin}/index.js`, require("url").pathToFileURL(__filename).toString());
|
|
80
|
+
const { rpc, name } = await Promise.resolve(location.pathname).then((p)=>/*#__PURE__*/ _interop_require_wildcard(require(p)));
|
|
87
81
|
if (rpc) {
|
|
88
82
|
const methodName = name || _lodash.default.camelCase(plugin);
|
|
89
83
|
pluginHandlers[`dev_${methodName}`] = rpc;
|
|
90
|
-
logger.debug(`Registered plugin ${
|
|
84
|
+
logger.debug(`Registered plugin RPC: ${`dev_${methodName}`}`);
|
|
91
85
|
}
|
|
92
86
|
}
|
|
93
|
-
}
|
|
87
|
+
};
|
|
94
88
|
const pluginExtendCli = async (y)=>{
|
|
95
89
|
for (const plugin of plugins){
|
|
96
|
-
const
|
|
90
|
+
const location = new URL(`${plugin}/index.js`, require("url").pathToFileURL(__filename).toString());
|
|
91
|
+
const { cli } = await Promise.resolve(location.pathname).then((p)=>/*#__PURE__*/ _interop_require_wildcard(require(p)));
|
|
97
92
|
if (cli) {
|
|
98
93
|
cli(y);
|
|
99
|
-
logger.debug(`Registered plugin ${plugin}
|
|
94
|
+
logger.debug(`Registered plugin CLI: ${plugin}`);
|
|
100
95
|
}
|
|
101
96
|
}
|
|
102
97
|
};
|
package/dist/cjs/utils/tunnel.js
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
require("global-agent
|
|
5
|
+
const _globalagent = require("global-agent");
|
|
6
6
|
const _npmconf = /*#__PURE__*/ _interop_require_default(require("@pnpm/npm-conf"));
|
|
7
7
|
function _interop_require_default(obj) {
|
|
8
8
|
return obj && obj.__esModule ? obj : {
|
|
9
9
|
default: obj
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
+
(0, _globalagent.bootstrap)();
|
|
12
13
|
const npmConfig = (0, _npmconf.default)().config;
|
|
13
14
|
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.js
CHANGED
|
@@ -72,4 +72,8 @@ const commands = yargs(hideBin(process.argv)).scriptName('chopsticks').middlewar
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
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
|
-
|
|
75
|
+
if (!process.env.DISABLE_PLUGINS) {
|
|
76
|
+
pluginExtendCli(commands).then(()=>commands.parse());
|
|
77
|
+
} else {
|
|
78
|
+
commands.parse();
|
|
79
|
+
}
|
package/dist/esm/context.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import './utils/tunnel.js';
|
|
2
2
|
import { GenesisProvider, defaultLogger, isUrl, setup, timeTravel } from '@acala-network/chopsticks-core';
|
|
3
3
|
import { SqliteDatabase } from '@acala-network/chopsticks-db';
|
|
4
|
+
import { loadRPCPlugins } from './plugins/index.js';
|
|
4
5
|
import { overrideStorage, overrideWasm } from './utils/override.js';
|
|
5
6
|
import axios from 'axios';
|
|
6
7
|
const logger = defaultLogger.child({
|
|
@@ -76,6 +77,9 @@ export const setupContext = async (argv, overrideParent = false)=>{
|
|
|
76
77
|
// added that have storage imports
|
|
77
78
|
await overrideWasm(chain, argv['wasm-override'], at);
|
|
78
79
|
await overrideStorage(chain, argv['import-storage'], at);
|
|
80
|
+
if (!process.env.DISABLE_PLUGINS) {
|
|
81
|
+
await loadRPCPlugins();
|
|
82
|
+
}
|
|
79
83
|
return {
|
|
80
84
|
chain
|
|
81
85
|
};
|
|
@@ -1,38 +1,30 @@
|
|
|
1
|
+
import { lstatSync, readdirSync } from 'fs';
|
|
1
2
|
import _ from 'lodash';
|
|
2
3
|
import { defaultLogger } from '../logger.js';
|
|
3
4
|
const logger = defaultLogger.child({
|
|
4
5
|
name: 'plugin'
|
|
5
6
|
});
|
|
6
7
|
export const pluginHandlers = {};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
'follow-chain',
|
|
11
|
-
'new-block',
|
|
12
|
-
'run-block',
|
|
13
|
-
'set-block-build-mode',
|
|
14
|
-
'set-head',
|
|
15
|
-
'set-runtime-log-level',
|
|
16
|
-
'set-storage',
|
|
17
|
-
'time-travel',
|
|
18
|
-
'try-runtime'
|
|
19
|
-
];
|
|
20
|
-
(async ()=>{
|
|
8
|
+
// list of plugins directory
|
|
9
|
+
const plugins = readdirSync(new URL('.', import.meta.url)).filter((file)=>lstatSync(new URL(file, import.meta.url)).isDirectory());
|
|
10
|
+
export const loadRPCPlugins = async ()=>{
|
|
21
11
|
for (const plugin of plugins){
|
|
22
|
-
const
|
|
12
|
+
const location = new URL(`${plugin}/index.js`, import.meta.url);
|
|
13
|
+
const { rpc, name } = await import(location.pathname);
|
|
23
14
|
if (rpc) {
|
|
24
15
|
const methodName = name || _.camelCase(plugin);
|
|
25
16
|
pluginHandlers[`dev_${methodName}`] = rpc;
|
|
26
|
-
logger.debug(`Registered plugin ${
|
|
17
|
+
logger.debug(`Registered plugin RPC: ${`dev_${methodName}`}`);
|
|
27
18
|
}
|
|
28
19
|
}
|
|
29
|
-
}
|
|
20
|
+
};
|
|
30
21
|
export const pluginExtendCli = async (y)=>{
|
|
31
22
|
for (const plugin of plugins){
|
|
32
|
-
const
|
|
23
|
+
const location = new URL(`${plugin}/index.js`, import.meta.url);
|
|
24
|
+
const { cli } = await import(location.pathname);
|
|
33
25
|
if (cli) {
|
|
34
26
|
cli(y);
|
|
35
|
-
logger.debug(`Registered plugin ${plugin}
|
|
27
|
+
logger.debug(`Registered plugin CLI: ${plugin}`);
|
|
36
28
|
}
|
|
37
29
|
}
|
|
38
30
|
};
|
package/dist/esm/utils/tunnel.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import 'global-agent
|
|
1
|
+
import { bootstrap } from 'global-agent';
|
|
2
|
+
bootstrap();
|
|
2
3
|
import npmConf from '@pnpm/npm-conf';
|
|
3
4
|
const npmConfig = npmConf().config;
|
|
4
5
|
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;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Handlers } from '@acala-network/chopsticks-core';
|
|
2
2
|
import type { Argv } from 'yargs';
|
|
3
3
|
export declare const pluginHandlers: Handlers;
|
|
4
|
+
export declare const loadRPCPlugins: () => Promise<void>;
|
|
4
5
|
export declare const pluginExtendCli: (y: Argv) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acala-network/chopsticks",
|
|
3
|
-
"version": "0.9.1-
|
|
3
|
+
"version": "0.9.1-5",
|
|
4
4
|
"author": "Acala Developers <hello@acala.network>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"bin": "./chopsticks.cjs",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"docs:prep": "typedoc"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@acala-network/chopsticks-core": "0.9.1-
|
|
18
|
-
"@acala-network/chopsticks-db": "0.9.1-
|
|
17
|
+
"@acala-network/chopsticks-core": "0.9.1-5",
|
|
18
|
+
"@acala-network/chopsticks-db": "0.9.1-5",
|
|
19
19
|
"@pnpm/npm-conf": "^2.2.2",
|
|
20
20
|
"axios": "^1.6.0",
|
|
21
21
|
"dotenv": "^16.3.1",
|