@acala-network/chopsticks 0.9.1-4 → 0.9.1

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 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
- (0, _index1.pluginExtendCli)(commands).then(()=>commands.parse());
84
+ if (!process.env.DISABLE_PLUGINS) {
85
+ (0, _index1.pluginExtendCli)(commands).then(()=>commands.parse());
86
+ } else {
87
+ commands.parse();
88
+ }
@@ -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
- const plugins = [
72
- 'decode-key',
73
- 'dry-run',
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 { rpc, name } = await Promise.resolve(`./${plugin}`).then((p)=>/*#__PURE__*/ _interop_require_wildcard(require(p)));
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 ${plugin} RPC`);
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 { cli } = await Promise.resolve(`./${plugin}`).then((p)=>/*#__PURE__*/ _interop_require_wildcard(require(p)));
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} CLI`);
94
+ logger.debug(`Registered plugin CLI: ${plugin}`);
100
95
  }
101
96
  }
102
97
  };
@@ -2,12 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- require("global-agent/bootstrap");
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
- pluginExtendCli(commands).then(()=>commands.parse());
75
+ if (!process.env.DISABLE_PLUGINS) {
76
+ pluginExtendCli(commands).then(()=>commands.parse());
77
+ } else {
78
+ commands.parse();
79
+ }
@@ -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
- const plugins = [
8
- 'decode-key',
9
- 'dry-run',
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 { rpc, name } = await import(`./${plugin}`);
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 ${plugin} RPC`);
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 { cli } = await import(`./${plugin}`);
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} CLI`);
27
+ logger.debug(`Registered plugin CLI: ${plugin}`);
36
28
  }
37
29
  }
38
30
  };
@@ -1,4 +1,5 @@
1
- import 'global-agent/bootstrap';
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
- import 'global-agent/bootstrap';
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acala-network/chopsticks",
3
- "version": "0.9.1-4",
3
+ "version": "0.9.1",
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-4",
18
- "@acala-network/chopsticks-db": "0.9.1-4",
17
+ "@acala-network/chopsticks-core": "0.9.1",
18
+ "@acala-network/chopsticks-db": "0.9.1",
19
19
  "@pnpm/npm-conf": "^2.2.2",
20
20
  "axios": "^1.6.0",
21
21
  "dotenv": "^16.3.1",
@@ -25,18 +25,18 @@
25
25
  "lodash": "^4.17.21",
26
26
  "ws": "^8.14.2",
27
27
  "yargs": "^17.7.2",
28
- "zod": "^3.22.3"
28
+ "zod": "^3.22.4"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@swc/cli": "0.1.62",
32
32
  "@swc/core": "^1.3.96",
33
- "@types/global-agent": "^2.1.1",
34
- "@types/js-yaml": "^4.0.5",
35
- "@types/lodash": "^4.14.199",
36
- "@types/node": "^20.5.7",
37
- "@types/ws": "^8.5.6",
38
- "@types/yargs": "^17.0.29",
39
- "typescript": "^5.1.6"
33
+ "@types/global-agent": "^2.1.3",
34
+ "@types/js-yaml": "^4.0.9",
35
+ "@types/lodash": "^4.14.201",
36
+ "@types/node": "^20.9.0",
37
+ "@types/ws": "^8.5.9",
38
+ "@types/yargs": "^17.0.31",
39
+ "typescript": "^5.2.2"
40
40
  },
41
41
  "files": [
42
42
  "dist/esm/**",