@acala-network/chopsticks 0.12.2 → 0.13.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
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  const _dotenv = require("dotenv");
6
6
  const _helpers = require("yargs/helpers");
7
+ const _zod = require("zod");
7
8
  const _lodash = /*#__PURE__*/ _interop_require_default(require("lodash"));
8
9
  const _yargs = /*#__PURE__*/ _interop_require_default(require("yargs"));
9
10
  const _chopstickscore = require("@acala-network/chopsticks-core");
@@ -17,14 +18,24 @@ function _interop_require_default(obj) {
17
18
  }
18
19
  (0, _dotenv.config)();
19
20
  const processArgv = async (argv)=>{
20
- if (argv.unsafeRpcMethods) {
21
- await (0, _index1.loadRpcMethodsByScripts)(argv.unsafeRpcMethods);
22
- }
23
- if (argv.config) {
24
- Object.assign(argv, _lodash.default.defaults(argv, await (0, _index.fetchConfig)(argv.config)));
25
- }
26
- if (_chopstickscore.environment.PORT) {
27
- argv.port = Number(_chopstickscore.environment.PORT);
21
+ try {
22
+ if (argv.unsafeRpcMethods) {
23
+ await (0, _index1.loadRpcMethodsByScripts)(argv.unsafeRpcMethods);
24
+ }
25
+ if (argv.config) {
26
+ Object.assign(argv, _lodash.default.defaults(argv, await (0, _index.fetchConfig)(argv.config)));
27
+ }
28
+ if (_chopstickscore.environment.PORT) {
29
+ argv.port = Number(_chopstickscore.environment.PORT);
30
+ }
31
+ } catch (error) {
32
+ if (error instanceof _zod.z.ZodError) {
33
+ throw new Error('Bad argv', {
34
+ cause: error.flatten().fieldErrors
35
+ });
36
+ } else {
37
+ throw error;
38
+ }
28
39
  }
29
40
  };
30
41
  const commands = (0, _yargs.default)((0, _helpers.hideBin)(process.argv)).scriptName('chopsticks').middleware(processArgv, false).command('*', 'Dev mode, fork off a chain', (yargs)=>yargs.config('config', 'Path to config file with default options', ()=>({})).options((0, _index.getYargsOptions)(_index.configSchema.shape)), async (argv)=>{
@@ -7,9 +7,9 @@ export declare const setupContext: (argv: Config, overrideParent?: boolean) => P
7
7
  fetchStorageWorker: {
8
8
  worker: import("comlink").Remote<{
9
9
  startFetch: (options: {
10
- block?: string | number | null | undefined;
11
- endpoint?: string | string[] | undefined;
12
- dbPath?: string | undefined;
10
+ block?: number | string | null;
11
+ endpoint?: string | string[];
12
+ dbPath?: string;
13
13
  config: import("./utils/fetch-storages.js").FetchStorageConfig;
14
14
  }) => Promise<void>;
15
15
  }>;
@@ -1,4 +1,4 @@
1
1
  import _ from 'lodash';
2
2
  export { defaultLogger, truncate } from '@acala-network/chopsticks-core';
3
3
  export declare const spinnerFrames: string[];
4
- export declare const apiFetching: _.DebouncedFunc<() => void>;
4
+ export declare const apiFetching: _.DebouncedFuncLeading<() => void>;
@@ -1 +1 @@
1
- {"type": "commonjs"}
1
+ { "type": "commonjs" }
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import { Block, Blockchain, RuntimeVersion } from '@acala-network/chopsticks-core';
3
2
  import { HexString } from '@polkadot/util/types';
4
3
  import { Step } from './types.js';
@@ -1,4 +1,5 @@
1
1
  import { BuildBlockMode } from '@acala-network/chopsticks-core';
2
+ import { Options } from 'yargs';
2
3
  import { ZodNativeEnum, ZodRawShape, ZodTypeAny, z } from 'zod';
3
4
  export declare const zHex: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
4
5
  export declare const zHash: z.ZodIntersection<z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>>;
@@ -147,11 +148,6 @@ export declare const configSchema: z.ZodObject<{
147
148
  }>;
148
149
  export type Config = z.infer<typeof configSchema>;
149
150
  export declare const getYargsOptions: (zodShape: ZodRawShape) => {
150
- [x: string]: {
151
- demandOption: boolean;
152
- description: any;
153
- type: any;
154
- choices: any;
155
- };
151
+ [x: string]: Options;
156
152
  };
157
153
  export declare const fetchConfig: (path: string) => Promise<Config>;
@@ -6,9 +6,9 @@ export declare const setupWithServer: (argv: Config) => Promise<{
6
6
  fetchStorageWorker: {
7
7
  worker: import("comlink").Remote<{
8
8
  startFetch: (options: {
9
- block?: string | number | null | undefined;
10
- endpoint?: string | string[] | undefined;
11
- dbPath?: string | undefined;
9
+ block?: number | string | null;
10
+ endpoint?: string | string[];
11
+ dbPath?: string;
12
12
  config: import("./utils/fetch-storages.js").FetchStorageConfig;
13
13
  }) => Promise<void>;
14
14
  }>;
package/dist/esm/cli.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { config as dotenvConfig } from 'dotenv';
2
2
  import { hideBin } from 'yargs/helpers';
3
+ import { z } from 'zod';
3
4
  import _ from 'lodash';
4
5
  import yargs from 'yargs';
5
6
  import { connectParachains, connectVertical, environment } from '@acala-network/chopsticks-core';
@@ -8,14 +9,24 @@ import { loadRpcMethodsByScripts, pluginExtendCli } from './plugins/index.js';
8
9
  import { setupWithServer } from './index.js';
9
10
  dotenvConfig();
10
11
  const processArgv = async (argv)=>{
11
- if (argv.unsafeRpcMethods) {
12
- await loadRpcMethodsByScripts(argv.unsafeRpcMethods);
13
- }
14
- if (argv.config) {
15
- Object.assign(argv, _.defaults(argv, await fetchConfig(argv.config)));
16
- }
17
- if (environment.PORT) {
18
- argv.port = Number(environment.PORT);
12
+ try {
13
+ if (argv.unsafeRpcMethods) {
14
+ await loadRpcMethodsByScripts(argv.unsafeRpcMethods);
15
+ }
16
+ if (argv.config) {
17
+ Object.assign(argv, _.defaults(argv, await fetchConfig(argv.config)));
18
+ }
19
+ if (environment.PORT) {
20
+ argv.port = Number(environment.PORT);
21
+ }
22
+ } catch (error) {
23
+ if (error instanceof z.ZodError) {
24
+ throw new Error('Bad argv', {
25
+ cause: error.flatten().fieldErrors
26
+ });
27
+ } else {
28
+ throw error;
29
+ }
19
30
  }
20
31
  };
21
32
  const commands = yargs(hideBin(process.argv)).scriptName('chopsticks').middleware(processArgv, false).command('*', 'Dev mode, fork off a chain', (yargs)=>yargs.config('config', 'Path to config file with default options', ()=>({})).options(getYargsOptions(configSchema.shape)), async (argv)=>{
@@ -7,9 +7,9 @@ export declare const setupContext: (argv: Config, overrideParent?: boolean) => P
7
7
  fetchStorageWorker: {
8
8
  worker: import("comlink").Remote<{
9
9
  startFetch: (options: {
10
- block?: string | number | null | undefined;
11
- endpoint?: string | string[] | undefined;
12
- dbPath?: string | undefined;
10
+ block?: number | string | null;
11
+ endpoint?: string | string[];
12
+ dbPath?: string;
13
13
  config: import("./utils/fetch-storages.js").FetchStorageConfig;
14
14
  }) => Promise<void>;
15
15
  }>;
@@ -1,4 +1,4 @@
1
1
  import _ from 'lodash';
2
2
  export { defaultLogger, truncate } from '@acala-network/chopsticks-core';
3
3
  export declare const spinnerFrames: string[];
4
- export declare const apiFetching: _.DebouncedFunc<() => void>;
4
+ export declare const apiFetching: _.DebouncedFuncLeading<() => void>;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import { Block, Blockchain, RuntimeVersion } from '@acala-network/chopsticks-core';
3
2
  import { HexString } from '@polkadot/util/types';
4
3
  import { Step } from './types.js';
@@ -1,4 +1,5 @@
1
1
  import { BuildBlockMode } from '@acala-network/chopsticks-core';
2
+ import { Options } from 'yargs';
2
3
  import { ZodNativeEnum, ZodRawShape, ZodTypeAny, z } from 'zod';
3
4
  export declare const zHex: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
4
5
  export declare const zHash: z.ZodIntersection<z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>>;
@@ -147,11 +148,6 @@ export declare const configSchema: z.ZodObject<{
147
148
  }>;
148
149
  export type Config = z.infer<typeof configSchema>;
149
150
  export declare const getYargsOptions: (zodShape: ZodRawShape) => {
150
- [x: string]: {
151
- demandOption: boolean;
152
- description: any;
153
- type: any;
154
- choices: any;
155
- };
151
+ [x: string]: Options;
156
152
  };
157
153
  export declare const fetchConfig: (path: string) => Promise<Config>;
@@ -6,9 +6,9 @@ export declare const setupWithServer: (argv: Config) => Promise<{
6
6
  fetchStorageWorker: {
7
7
  worker: import("comlink").Remote<{
8
8
  startFetch: (options: {
9
- block?: string | number | null | undefined;
10
- endpoint?: string | string[] | undefined;
11
- dbPath?: string | undefined;
9
+ block?: number | string | null;
10
+ endpoint?: string | string[];
11
+ dbPath?: string;
12
12
  config: import("./utils/fetch-storages.js").FetchStorageConfig;
13
13
  }) => Promise<void>;
14
14
  }>;
package/package.json CHANGED
@@ -1,26 +1,24 @@
1
1
  {
2
2
  "name": "@acala-network/chopsticks",
3
- "version": "0.12.2",
3
+ "version": "0.13.1",
4
4
  "author": "Acala Developers <hello@acala.network>",
5
5
  "license": "Apache-2.0",
6
6
  "bin": "./chopsticks.cjs",
7
7
  "type": "module",
8
8
  "scripts": {
9
9
  "clean": "rm -rf dist tsconfig.tsbuildinfo",
10
- "build": "yarn clean && yarn build:cjs && yarn build:esm",
11
- "build:cjs": "swc ./src --config-file ../../.cjsswcrc -d dist/cjs --copy-files && tsc -p tsconfig.json --declarationDir dist/cjs && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
12
- "build:esm": "swc ./src --config-file ../../.esmswcrc -d dist/esm --copy-files && tsc -p tsconfig.json --declarationDir dist/esm",
10
+ "build": "yarn clean && ../../package-build.sh",
13
11
  "docs:prep": "typedoc",
14
12
  "depcheck": "npx depcheck --ignore-patterns='*.test.ts'"
15
13
  },
16
14
  "dependencies": {
17
- "@acala-network/chopsticks-core": "0.12.2",
18
- "@acala-network/chopsticks-db": "0.12.2",
15
+ "@acala-network/chopsticks-core": "0.13.1",
16
+ "@acala-network/chopsticks-db": "0.13.1",
19
17
  "@pnpm/npm-conf": "^2.2.2",
20
- "@polkadot/api": "^11.2.1",
21
- "@polkadot/api-augment": "^11.2.1",
22
- "@polkadot/rpc-provider": "^11.2.1",
23
- "@polkadot/types": "^11.2.1",
18
+ "@polkadot/api": "^12.1.1",
19
+ "@polkadot/api-augment": "^12.1.1",
20
+ "@polkadot/rpc-provider": "^12.1.1",
21
+ "@polkadot/types": "^12.1.1",
24
22
  "@polkadot/util": "^12.6.2",
25
23
  "@polkadot/util-crypto": "^12.6.2",
26
24
  "axios": "^1.6.8",
@@ -30,20 +28,20 @@
30
28
  "js-yaml": "^4.1.0",
31
29
  "jsondiffpatch": "^0.5.0",
32
30
  "lodash": "^4.17.21",
33
- "ws": "^8.16.0",
31
+ "ws": "^8.17.1",
34
32
  "yargs": "^17.7.2",
35
33
  "zod": "^3.22.4"
36
34
  },
37
35
  "devDependencies": {
38
- "@swc/cli": "0.1.65",
39
- "@swc/core": "^1.4.8",
36
+ "@swc/cli": "0.4.0",
37
+ "@swc/core": "^1.6.7",
40
38
  "@types/global-agent": "^2.1.3",
41
39
  "@types/js-yaml": "^4.0.9",
42
- "@types/lodash": "^4.17.0",
43
- "@types/node": "^20.11.5",
40
+ "@types/lodash": "^4.17.6",
41
+ "@types/node": "^20.14.9",
44
42
  "@types/ws": "^8.5.10",
45
43
  "@types/yargs": "^17.0.32",
46
- "typescript": "^5.3.3"
44
+ "typescript": "^5.5.3"
47
45
  },
48
46
  "files": [
49
47
  "dist/esm/**",