@acala-network/chopsticks 0.7.2 → 0.7.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/cli.d.ts CHANGED
@@ -1,2 +1 @@
1
- import { Config } from './schema';
2
- export declare const fetchConfig: (path: string) => Promise<Config>;
1
+ export {};
package/lib/cli.js CHANGED
@@ -3,56 +3,20 @@ 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.fetchConfig = void 0;
7
- const node_path_1 = require("node:path");
8
6
  const dotenv_1 = require("dotenv");
9
7
  const helpers_1 = require("yargs/helpers");
10
- const node_fs_1 = require("node:fs");
11
- const lodash_1 = __importDefault(require("lodash"));
12
- const axios_1 = __importDefault(require("axios"));
13
- const js_yaml_1 = __importDefault(require("js-yaml"));
14
8
  const yargs_1 = __importDefault(require("yargs"));
15
9
  const _1 = require(".");
16
- const schema_1 = require("./schema");
17
10
  const decoder_1 = require("./utils/decoder");
18
11
  const dry_run_1 = require("./dry-run");
19
12
  const dry_run_preimage_1 = require("./dry-run-preimage");
20
- const utils_1 = require("./utils");
21
- const shared_1 = require("./rpc/shared");
13
+ const schema_1 = require("./schema");
22
14
  const run_block_1 = require("./run-block");
23
15
  const try_runtime_1 = require("./try-runtime");
24
16
  (0, dotenv_1.config)();
25
- const CONFIGS_BASE_URL = 'https://raw.githubusercontent.com/AcalaNetwork/chopsticks/master/configs/';
26
- const fetchConfig = async (path) => {
27
- let file;
28
- if ((0, utils_1.isUrl)(path)) {
29
- file = await axios_1.default.get(path).then((x) => x.data);
30
- }
31
- else {
32
- try {
33
- file = (0, node_fs_1.readFileSync)(path, 'utf8');
34
- }
35
- catch (err) {
36
- if ((0, node_path_1.basename)(path) === path && ['', '.yml', '.yaml', '.json'].includes((0, node_path_1.extname)(path))) {
37
- if ((0, node_path_1.extname)(path) === '') {
38
- path += '.yml';
39
- }
40
- const url = CONFIGS_BASE_URL + path;
41
- shared_1.logger.info(`Loading config file ${url}`);
42
- file = await axios_1.default.get(url).then((x) => x.data);
43
- }
44
- else {
45
- throw err;
46
- }
47
- }
48
- }
49
- const config = js_yaml_1.default.load(lodash_1.default.template(file, { variable: 'env' })(process.env));
50
- return schema_1.configSchema.parse(config);
51
- };
52
- exports.fetchConfig = fetchConfig;
53
17
  const processArgv = async (argv) => {
54
18
  if (argv.config) {
55
- argv = { ...(await (0, exports.fetchConfig)(argv.config)), ...argv };
19
+ argv = { ...(await (0, schema_1.fetchConfig)(argv.config)), ...argv };
56
20
  }
57
21
  argv.port = argv.port ?? (process.env.PORT ? Number(process.env.PORT) : 8000);
58
22
  return argv;
@@ -225,14 +189,14 @@ const mockOptions = {
225
189
  .alias('parachain', 'p'), async (argv) => {
226
190
  const parachains = [];
227
191
  for (const config of argv.parachain) {
228
- const { chain } = await (0, _1.setupWithServer)(await (0, exports.fetchConfig)(config));
192
+ const { chain } = await (0, _1.setupWithServer)(await (0, schema_1.fetchConfig)(config));
229
193
  parachains.push(chain);
230
194
  }
231
195
  if (parachains.length > 1) {
232
196
  await (0, _1.connectParachains)(parachains);
233
197
  }
234
198
  if (argv.relaychain) {
235
- const { chain: relaychain } = await (0, _1.setupWithServer)(await (0, exports.fetchConfig)(argv.relaychain));
199
+ const { chain: relaychain } = await (0, _1.setupWithServer)(await (0, schema_1.fetchConfig)(argv.relaychain));
236
200
  for (const parachain of parachains) {
237
201
  await (0, _1.connectVertical)(relaychain, parachain);
238
202
  }
package/lib/index.d.ts CHANGED
@@ -4,5 +4,5 @@ export { BuildBlockMode } from './blockchain/txpool';
4
4
  export { connectParachains, connectVertical } from './xcm';
5
5
  export { setup } from './setup';
6
6
  export { setupWithServer } from './setup-with-server';
7
- export { fetchConfig } from './cli';
7
+ export { Config, fetchConfig } from './schema';
8
8
  export * from './blockchain/inherent';
package/lib/index.js CHANGED
@@ -28,6 +28,6 @@ var setup_1 = require("./setup");
28
28
  Object.defineProperty(exports, "setup", { enumerable: true, get: function () { return setup_1.setup; } });
29
29
  var setup_with_server_1 = require("./setup-with-server");
30
30
  Object.defineProperty(exports, "setupWithServer", { enumerable: true, get: function () { return setup_with_server_1.setupWithServer; } });
31
- var cli_1 = require("./cli");
32
- Object.defineProperty(exports, "fetchConfig", { enumerable: true, get: function () { return cli_1.fetchConfig; } });
31
+ var schema_1 = require("./schema");
32
+ Object.defineProperty(exports, "fetchConfig", { enumerable: true, get: function () { return schema_1.fetchConfig; } });
33
33
  __exportStar(require("./blockchain/inherent"), exports);
@@ -1,5 +1,5 @@
1
- import { BuildBlockMode } from '../blockchain/txpool';
2
1
  import { z } from 'zod';
2
+ import { BuildBlockMode } from '../blockchain/txpool';
3
3
  export declare const genesisSchema: z.ZodObject<{
4
4
  id: z.ZodString;
5
5
  name: z.ZodString;
@@ -190,3 +190,4 @@ export declare const configSchema: z.ZodObject<{
190
190
  'offchain-worker'?: boolean | undefined;
191
191
  }>;
192
192
  export type Config = z.infer<typeof configSchema>;
193
+ export declare const fetchConfig: (path: string) => Promise<Config>;
@@ -1,8 +1,18 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.configSchema = exports.genesisSchema = void 0;
4
- const txpool_1 = require("../blockchain/txpool");
6
+ exports.fetchConfig = exports.configSchema = exports.genesisSchema = void 0;
7
+ const node_path_1 = require("node:path");
8
+ const node_fs_1 = require("node:fs");
5
9
  const zod_1 = require("zod");
10
+ const lodash_1 = __importDefault(require("lodash"));
11
+ const axios_1 = __importDefault(require("axios"));
12
+ const js_yaml_1 = __importDefault(require("js-yaml"));
13
+ const txpool_1 = require("../blockchain/txpool");
14
+ const utils_1 = require("../utils");
15
+ const shared_1 = require("../rpc/shared");
6
16
  exports.genesisSchema = zod_1.z.object({
7
17
  id: zod_1.z.string(),
8
18
  name: zod_1.z.string(),
@@ -30,3 +40,31 @@ exports.configSchema = zod_1.z
30
40
  'offchain-worker': zod_1.z.boolean().optional(),
31
41
  })
32
42
  .strict();
43
+ const CONFIGS_BASE_URL = 'https://raw.githubusercontent.com/AcalaNetwork/chopsticks/master/configs/';
44
+ const fetchConfig = async (path) => {
45
+ let file;
46
+ if ((0, utils_1.isUrl)(path)) {
47
+ file = await axios_1.default.get(path).then((x) => x.data);
48
+ }
49
+ else {
50
+ try {
51
+ file = (0, node_fs_1.readFileSync)(path, 'utf8');
52
+ }
53
+ catch (err) {
54
+ if ((0, node_path_1.basename)(path) === path && ['', '.yml', '.yaml', '.json'].includes((0, node_path_1.extname)(path))) {
55
+ if ((0, node_path_1.extname)(path) === '') {
56
+ path += '.yml';
57
+ }
58
+ const url = CONFIGS_BASE_URL + path;
59
+ shared_1.logger.info(`Loading config file ${url}`);
60
+ file = await axios_1.default.get(url).then((x) => x.data);
61
+ }
62
+ else {
63
+ throw err;
64
+ }
65
+ }
66
+ }
67
+ const config = js_yaml_1.default.load(lodash_1.default.template(file, { variable: 'env' })(process.env));
68
+ return exports.configSchema.parse(config);
69
+ };
70
+ exports.fetchConfig = fetchConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acala-network/chopsticks",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "author": "Bryan Chen <xlchen1291@gmail.com>",
5
5
  "license": "Apache-2.0",
6
6
  "bin": "./chopsticks.js",
@@ -16,7 +16,7 @@
16
16
  "dev:moonbeam": "cd ../..; ts-node-dev --transpile-only --inspect --notify=false packages/chopsticks/src/cli.ts -- --config=configs/moonbeam.yml"
17
17
  },
18
18
  "dependencies": {
19
- "@acala-network/chopsticks-executor": "0.7.2",
19
+ "@acala-network/chopsticks-executor": "0.7.3",
20
20
  "@pnpm/npm-conf": "^2.2.2",
21
21
  "@polkadot/api": "^10.9.1",
22
22
  "axios": "^1.4.0",