@acala-network/chopsticks 1.0.2-2 → 1.0.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.js +10 -11
- package/dist/cjs/context.d.ts +1 -1
- package/dist/cjs/context.js +4 -3
- package/dist/cjs/logger.js +1 -1
- package/dist/cjs/plugins/decode-key/cli.js +1 -1
- package/dist/cjs/plugins/dry-run/cli.js +2 -2
- package/dist/cjs/plugins/dry-run/dry-run-extrinsic.d.ts +1 -1
- package/dist/cjs/plugins/dry-run/dry-run-extrinsic.js +10 -10
- package/dist/cjs/plugins/dry-run/dry-run-preimage.d.ts +1 -1
- package/dist/cjs/plugins/dry-run/dry-run-preimage.js +11 -11
- package/dist/cjs/plugins/dry-run/index.d.ts +3 -3
- package/dist/cjs/plugins/dry-run/index.js +2 -2
- package/dist/cjs/plugins/dry-run/rpc.d.ts +1 -1
- package/dist/cjs/plugins/dry-run/rpc.js +1 -1
- package/dist/cjs/plugins/fetch-storage/cli.js +1 -1
- package/dist/cjs/plugins/follow-chain/cli.js +7 -7
- package/dist/cjs/plugins/index.d.ts +1 -1
- package/dist/cjs/plugins/index.js +2 -2
- package/dist/cjs/plugins/run-block/cli.js +2 -2
- package/dist/cjs/plugins/run-block/rpc.d.ts +2 -2
- package/dist/cjs/plugins/trace-transaction/index.d.ts +1 -1
- package/dist/cjs/plugins/trace-transaction/index.js +3 -3
- package/dist/cjs/plugins/trace-transaction/types.d.ts +2 -2
- package/dist/cjs/plugins/trace-transaction/utils.d.ts +3 -3
- package/dist/cjs/plugins/trace-transaction/utils.js +4 -4
- package/dist/cjs/plugins/try-runtime/index.js +5 -5
- package/dist/cjs/rpc/index.d.ts +1 -1
- package/dist/cjs/schema/index.d.ts +2 -2
- package/dist/cjs/schema/index.js +4 -4
- package/dist/cjs/server.d.ts +1 -1
- package/dist/cjs/server.js +3 -3
- package/dist/cjs/setup-with-server.d.ts +1 -1
- package/dist/cjs/setup-with-server.js +2 -2
- package/dist/cjs/utils/decoder.d.ts +2 -2
- package/dist/cjs/utils/fetch-storages-worker.js +1 -1
- package/dist/cjs/utils/fetch-storages.d.ts +1 -1
- package/dist/cjs/utils/fetch-storages.js +5 -5
- package/dist/cjs/utils/generate-html-diff.d.ts +2 -2
- package/dist/cjs/utils/generate-html-diff.js +1 -1
- package/dist/cjs/utils/open-html.js +2 -2
- package/dist/cjs/utils/override.d.ts +2 -2
- package/dist/cjs/utils/override.js +2 -2
- package/dist/esm/cli.js +5 -6
- package/dist/esm/context.d.ts +1 -1
- package/dist/esm/context.js +4 -3
- package/dist/esm/logger.js +1 -1
- package/dist/esm/plugins/decode-key/cli.js +1 -1
- package/dist/esm/plugins/dry-run/cli.js +2 -2
- package/dist/esm/plugins/dry-run/dry-run-extrinsic.d.ts +1 -1
- package/dist/esm/plugins/dry-run/dry-run-extrinsic.js +10 -10
- package/dist/esm/plugins/dry-run/dry-run-preimage.d.ts +1 -1
- package/dist/esm/plugins/dry-run/dry-run-preimage.js +11 -11
- package/dist/esm/plugins/dry-run/index.d.ts +3 -3
- package/dist/esm/plugins/dry-run/index.js +2 -2
- package/dist/esm/plugins/dry-run/rpc.d.ts +1 -1
- package/dist/esm/plugins/dry-run/rpc.js +1 -1
- package/dist/esm/plugins/fetch-storage/cli.js +1 -1
- package/dist/esm/plugins/follow-chain/cli.js +3 -3
- package/dist/esm/plugins/index.d.ts +1 -1
- package/dist/esm/plugins/index.js +2 -2
- package/dist/esm/plugins/run-block/cli.js +2 -2
- package/dist/esm/plugins/run-block/rpc.d.ts +2 -2
- package/dist/esm/plugins/trace-transaction/index.d.ts +1 -1
- package/dist/esm/plugins/trace-transaction/index.js +3 -3
- package/dist/esm/plugins/trace-transaction/types.d.ts +2 -2
- package/dist/esm/plugins/trace-transaction/utils.d.ts +3 -3
- package/dist/esm/plugins/trace-transaction/utils.js +4 -4
- package/dist/esm/plugins/try-runtime/index.js +5 -5
- package/dist/esm/rpc/index.d.ts +1 -1
- package/dist/esm/schema/index.d.ts +2 -2
- package/dist/esm/schema/index.js +4 -4
- package/dist/esm/server.d.ts +1 -1
- package/dist/esm/server.js +3 -3
- package/dist/esm/setup-with-server.d.ts +1 -1
- package/dist/esm/setup-with-server.js +2 -2
- package/dist/esm/utils/decoder.d.ts +2 -2
- package/dist/esm/utils/fetch-storages-worker.js +1 -1
- package/dist/esm/utils/fetch-storages.d.ts +1 -1
- package/dist/esm/utils/fetch-storages.js +5 -5
- package/dist/esm/utils/generate-html-diff.d.ts +2 -2
- package/dist/esm/utils/generate-html-diff.js +1 -1
- package/dist/esm/utils/open-html.js +2 -2
- package/dist/esm/utils/override.d.ts +2 -2
- package/dist/esm/utils/override.js +2 -2
- package/package.json +20 -20
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
const _comlink = /*#__PURE__*/ _interop_require_wildcard(require("comlink"));
|
|
6
5
|
const _nodeworker_threads = require("node:worker_threads");
|
|
6
|
+
const _comlink = /*#__PURE__*/ _interop_require_wildcard(require("comlink"));
|
|
7
7
|
const _nodeadapter = /*#__PURE__*/ _interop_require_default(require("comlink/dist/umd/node-adapter.js"));
|
|
8
8
|
const _fetchstorages = require("./fetch-storages.js");
|
|
9
9
|
function _interop_require_default(obj) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApiPromise } from '@polkadot/api';
|
|
2
|
-
import { HexString } from '@polkadot/util/types';
|
|
2
|
+
import type { HexString } from '@polkadot/util/types';
|
|
3
3
|
export declare const logger: import("pino").default.Logger<never, boolean>;
|
|
4
4
|
type FetchStorageConfigItem = HexString | string | Record<string, string | Record<string, any[]> | Record<string, any>[] | (string | any)[]>;
|
|
5
5
|
export type FetchStorageConfig = FetchStorageConfigItem[];
|
|
@@ -22,17 +22,17 @@ _export(exports, {
|
|
|
22
22
|
return startFetchStorageWorker;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
+
const _nodeworker_threads = /*#__PURE__*/ _interop_require_default(require("node:worker_threads"));
|
|
25
26
|
const _chopstickscore = require("@acala-network/chopsticks-core");
|
|
26
|
-
const _api = require("@polkadot/api");
|
|
27
27
|
const _chopsticksdb = require("@acala-network/chopsticks-db");
|
|
28
|
+
const _api = require("@polkadot/api");
|
|
28
29
|
const _rpcprovider = require("@polkadot/rpc-provider");
|
|
29
|
-
const _util = require("@polkadot/util");
|
|
30
30
|
const _types = require("@polkadot/types");
|
|
31
|
-
const
|
|
31
|
+
const _util = require("@polkadot/util");
|
|
32
32
|
const _utilcrypto = require("@polkadot/util-crypto");
|
|
33
|
-
const
|
|
33
|
+
const _comlink = require("comlink");
|
|
34
34
|
const _nodeadapter = /*#__PURE__*/ _interop_require_default(require("comlink/dist/umd/node-adapter.js"));
|
|
35
|
-
const
|
|
35
|
+
const _lodash = /*#__PURE__*/ _interop_require_default(require("lodash"));
|
|
36
36
|
function _interop_require_default(obj) {
|
|
37
37
|
return obj && obj.__esModule ? obj : {
|
|
38
38
|
default: obj
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Block } from '@acala-network/chopsticks-core';
|
|
2
|
-
import { HexString } from '@polkadot/util/types';
|
|
1
|
+
import type { Block } from '@acala-network/chopsticks-core';
|
|
2
|
+
import type { HexString } from '@polkadot/util/types';
|
|
3
3
|
export declare const generateHtmlDiff: (block: Block, diff: [HexString, HexString | null][]) => Promise<string>;
|
|
4
4
|
export declare const generateHtmlDiffPreviewFile: (block: Block, diff: [HexString, HexString | null][], filename: string) => Promise<string>;
|
|
@@ -16,9 +16,9 @@ _export(exports, {
|
|
|
16
16
|
return generateHtmlDiffPreviewFile;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
const _decoder = require("./decoder.js");
|
|
20
19
|
const _nodefs = require("node:fs");
|
|
21
20
|
const _lodash = /*#__PURE__*/ _interop_require_default(require("lodash"));
|
|
21
|
+
const _decoder = require("./decoder.js");
|
|
22
22
|
function _interop_require_default(obj) {
|
|
23
23
|
return obj && obj.__esModule ? obj : {
|
|
24
24
|
default: obj
|
|
@@ -10,6 +10,6 @@ Object.defineProperty(exports, "openHtml", {
|
|
|
10
10
|
});
|
|
11
11
|
const _nodechild_process = require("node:child_process");
|
|
12
12
|
const openHtml = (filePath)=>{
|
|
13
|
-
const start = process.platform
|
|
14
|
-
(0, _nodechild_process.execSync)(start
|
|
13
|
+
const start = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open';
|
|
14
|
+
(0, _nodechild_process.execSync)(`${start} ${filePath}`);
|
|
15
15
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Blockchain, StorageValues } from '@acala-network/chopsticks-core';
|
|
2
|
-
import { HexString } from '@polkadot/util/types';
|
|
1
|
+
import { type Blockchain, type StorageValues } from '@acala-network/chopsticks-core';
|
|
2
|
+
import type { HexString } from '@polkadot/util/types';
|
|
3
3
|
export declare const overrideStorage: (chain: Blockchain, storage?: string | StorageValues, at?: HexString) => Promise<void>;
|
|
4
4
|
export declare const overrideWasm: (chain: Blockchain, wasmPath?: string, at?: HexString) => Promise<void>;
|
|
@@ -16,8 +16,8 @@ _export(exports, {
|
|
|
16
16
|
return overrideWasm;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
const _chopstickscore = require("@acala-network/chopsticks-core");
|
|
20
19
|
const _nodefs = require("node:fs");
|
|
20
|
+
const _chopstickscore = require("@acala-network/chopsticks-core");
|
|
21
21
|
const _axios = /*#__PURE__*/ _interop_require_default(require("axios"));
|
|
22
22
|
const _jsyaml = /*#__PURE__*/ _interop_require_default(require("js-yaml"));
|
|
23
23
|
const _logger = require("../logger.js");
|
|
@@ -61,7 +61,7 @@ const overrideWasm = async (chain, wasmPath, at)=>{
|
|
|
61
61
|
// starts with 0x
|
|
62
62
|
wasmHex = wasm.toString().trim();
|
|
63
63
|
} else {
|
|
64
|
-
wasmHex =
|
|
64
|
+
wasmHex = `0x${wasm.toString('hex')}`;
|
|
65
65
|
}
|
|
66
66
|
if (at) {
|
|
67
67
|
const block = await chain.getBlock(at);
|
package/dist/esm/cli.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { config as dotenvConfig } from 'dotenv';
|
|
2
|
-
import { hideBin } from 'yargs/helpers';
|
|
3
|
-
import { z } from 'zod';
|
|
4
2
|
import _ from 'lodash';
|
|
5
3
|
import yargs from 'yargs';
|
|
4
|
+
import { hideBin } from 'yargs/helpers';
|
|
5
|
+
import { z } from 'zod';
|
|
6
6
|
import { connectParachains, connectVertical, environment } from '@acala-network/chopsticks-core';
|
|
7
|
-
import { configSchema, fetchConfig, getYargsOptions } from './schema/index.js';
|
|
8
|
-
import { loadRpcMethodsByScripts, pluginExtendCli } from './plugins/index.js';
|
|
9
7
|
import { setupWithServer } from './index.js';
|
|
8
|
+
import { loadRpcMethodsByScripts, pluginExtendCli } from './plugins/index.js';
|
|
9
|
+
import { configSchema, fetchConfig, getYargsOptions } from './schema/index.js';
|
|
10
10
|
dotenvConfig();
|
|
11
11
|
const processArgv = async (argv)=>{
|
|
12
12
|
try {
|
|
@@ -24,9 +24,8 @@ const processArgv = async (argv)=>{
|
|
|
24
24
|
throw new Error('Bad argv', {
|
|
25
25
|
cause: error.flatten().fieldErrors
|
|
26
26
|
});
|
|
27
|
-
} else {
|
|
28
|
-
throw error;
|
|
29
27
|
}
|
|
28
|
+
throw error;
|
|
30
29
|
}
|
|
31
30
|
};
|
|
32
31
|
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)).deprecateOption('addr', '⚠️ Use --host instead.'), async (argv)=>{
|
package/dist/esm/context.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './utils/tunnel.js';
|
|
2
2
|
import { GenesisProvider } from '@acala-network/chopsticks-core';
|
|
3
|
-
import { Config } from './schema/index.js';
|
|
3
|
+
import type { Config } from './schema/index.js';
|
|
4
4
|
export declare const genesisFromUrl: (url: string) => Promise<GenesisProvider>;
|
|
5
5
|
export declare const setupContext: (argv: Config, overrideParent?: boolean) => Promise<{
|
|
6
6
|
chain: import("@acala-network/chopsticks-core").Blockchain;
|
package/dist/esm/context.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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 axios from 'axios';
|
|
4
5
|
import { apiFetching } from './logger.js';
|
|
5
|
-
import { overrideStorage, overrideWasm } from './utils/override.js';
|
|
6
6
|
import { startFetchStorageWorker } from './utils/fetch-storages.js';
|
|
7
|
-
import
|
|
7
|
+
import { overrideStorage, overrideWasm } from './utils/override.js';
|
|
8
8
|
const logger = defaultLogger.child({
|
|
9
9
|
name: 'setup-context'
|
|
10
10
|
});
|
|
@@ -12,7 +12,8 @@ export const genesisFromUrl = async (url)=>{
|
|
|
12
12
|
const getFile = async (url)=>{
|
|
13
13
|
if (isUrl(url)) {
|
|
14
14
|
return axios.get(url).then((x)=>x.data);
|
|
15
|
-
}
|
|
15
|
+
}
|
|
16
|
+
if (typeof process === 'object') {
|
|
16
17
|
const { lstatSync, readFileSync } = await import('node:fs');
|
|
17
18
|
if (lstatSync(url).isFile()) {
|
|
18
19
|
return JSON.parse(String(readFileSync(url)));
|
package/dist/esm/logger.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
export { defaultLogger, truncate } from '@acala-network/chopsticks-core';
|
|
3
|
-
const showProgress = process.stdout.isTTY && !process.env
|
|
3
|
+
const showProgress = process.stdout.isTTY && !process.env.CI && !process.env.TEST;
|
|
4
4
|
export const spinnerFrames = process.platform === 'win32' ? [
|
|
5
5
|
'-',
|
|
6
6
|
'\\',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { configSchema, getYargsOptions } from '../../schema/index.js';
|
|
2
1
|
import { decodeKey } from '@acala-network/chopsticks-core';
|
|
3
2
|
import { setupContext } from '../../context.js';
|
|
3
|
+
import { configSchema, getYargsOptions } from '../../schema/index.js';
|
|
4
4
|
export const cli = (y)=>{
|
|
5
5
|
y.command('decode-key <key>', 'Deocde a key', (yargs)=>yargs.options(getYargsOptions(configSchema.shape)).positional('key', {
|
|
6
6
|
desc: 'Key to decode',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import { configSchema, getYargsOptions } from '../../schema/index.js';
|
|
2
3
|
import { dryRunExtrinsic } from './dry-run-extrinsic.js';
|
|
3
4
|
import { dryRunPreimage } from './dry-run-preimage.js';
|
|
4
|
-
import { z } from 'zod';
|
|
5
5
|
const schema = z.object({
|
|
6
6
|
...configSchema.shape,
|
|
7
7
|
extrinsic: z.string({
|
|
@@ -16,7 +16,7 @@ const schema = z.object({
|
|
|
16
16
|
at: z.string({
|
|
17
17
|
description: 'Block hash to dry run'
|
|
18
18
|
}).optional(),
|
|
19
|
-
|
|
19
|
+
'output-path': z.string({
|
|
20
20
|
description: 'File path to print output'
|
|
21
21
|
}).optional(),
|
|
22
22
|
html: z.boolean({
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DryRunSchemaType } from './index.js';
|
|
1
|
+
import type { DryRunSchemaType } from './index.js';
|
|
2
2
|
export declare const dryRunExtrinsic: (argv: DryRunSchemaType) => Promise<never>;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { blake2AsHex } from '@polkadot/util-crypto';
|
|
2
1
|
import { writeFileSync } from 'node:fs';
|
|
2
|
+
import { blake2AsHex } from '@polkadot/util-crypto';
|
|
3
|
+
import { setupContext } from '../../context.js';
|
|
3
4
|
import { defaultLogger } from '../../logger.js';
|
|
4
5
|
import { generateHtmlDiffPreviewFile } from '../../utils/generate-html-diff.js';
|
|
5
6
|
import { openHtml } from '../../utils/open-html.js';
|
|
6
|
-
import { setupContext } from '../../context.js';
|
|
7
7
|
export const dryRunExtrinsic = async (argv)=>{
|
|
8
8
|
const context = await setupContext(argv);
|
|
9
9
|
if (!argv.extrinsic) {
|
|
10
10
|
throw new Error('Extrinsic is required');
|
|
11
11
|
}
|
|
12
|
-
const input = argv
|
|
13
|
-
call: argv
|
|
14
|
-
address: argv
|
|
15
|
-
} : argv
|
|
16
|
-
const { outcome, storageDiff } = await context.chain.dryRunExtrinsic(input, argv
|
|
12
|
+
const input = argv.address ? {
|
|
13
|
+
call: argv.extrinsic,
|
|
14
|
+
address: argv.address
|
|
15
|
+
} : argv.extrinsic;
|
|
16
|
+
const { outcome, storageDiff } = await context.chain.dryRunExtrinsic(input, argv.at);
|
|
17
17
|
if (outcome.isErr) {
|
|
18
18
|
throw new Error(outcome.asErr.toString());
|
|
19
19
|
}
|
|
20
20
|
defaultLogger.info(outcome.toHuman(), 'dry_run_outcome');
|
|
21
|
-
if (argv
|
|
22
|
-
const filePath = await generateHtmlDiffPreviewFile(context.chain.head, storageDiff, blake2AsHex(argv
|
|
21
|
+
if (argv.html) {
|
|
22
|
+
const filePath = await generateHtmlDiffPreviewFile(context.chain.head, storageDiff, blake2AsHex(argv.extrinsic, 256));
|
|
23
23
|
console.log(`Generated preview ${filePath}`);
|
|
24
|
-
if (argv
|
|
24
|
+
if (argv.open) {
|
|
25
25
|
openHtml(filePath);
|
|
26
26
|
}
|
|
27
27
|
} else if (argv['output-path']) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DryRunSchemaType } from './index.js';
|
|
1
|
+
import type { DryRunSchemaType } from './index.js';
|
|
2
2
|
export declare const dryRunPreimage: (argv: DryRunSchemaType) => Promise<never>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { blake2AsHex } from '@polkadot/util-crypto';
|
|
2
1
|
import { compactAddLength, hexToU8a } from '@polkadot/util';
|
|
2
|
+
import { blake2AsHex } from '@polkadot/util-crypto';
|
|
3
3
|
import { Block, newHeader, runTask, setStorage, taskHandler } from '@acala-network/chopsticks-core';
|
|
4
|
+
import { setupContext } from '../../context.js';
|
|
4
5
|
import { defaultLogger } from '../../logger.js';
|
|
5
6
|
import { generateHtmlDiffPreviewFile } from '../../utils/generate-html-diff.js';
|
|
6
7
|
import { openHtml } from '../../utils/open-html.js';
|
|
7
|
-
import { setupContext } from '../../context.js';
|
|
8
8
|
export const dryRunPreimage = async (argv)=>{
|
|
9
9
|
const context = await setupContext(argv);
|
|
10
|
-
const extrinsic = argv
|
|
10
|
+
const extrinsic = argv.preimage;
|
|
11
11
|
const block = context.chain.head;
|
|
12
12
|
const registry = await block.registry;
|
|
13
13
|
const header = await newHeader(block);
|
|
@@ -124,25 +124,25 @@ export const dryRunPreimage = async (argv)=>{
|
|
|
124
124
|
}
|
|
125
125
|
const filePath = await generateHtmlDiffPreviewFile(block, result.Call.storageDiff, hash);
|
|
126
126
|
console.log(`Generated preview ${filePath}`);
|
|
127
|
-
if (argv
|
|
127
|
+
if (argv.open) {
|
|
128
128
|
openHtml(filePath);
|
|
129
129
|
}
|
|
130
130
|
// if dry-run preimage has extrinsic arguments then dry-run extrinsic
|
|
131
131
|
// this is useful to test something after preimage is applied
|
|
132
|
-
if (argv
|
|
132
|
+
if (argv.extrinsic) {
|
|
133
133
|
await context.chain.newBlock();
|
|
134
|
-
const input = argv
|
|
135
|
-
call: argv
|
|
136
|
-
address: argv
|
|
137
|
-
} : argv
|
|
134
|
+
const input = argv.address ? {
|
|
135
|
+
call: argv.extrinsic,
|
|
136
|
+
address: argv.address
|
|
137
|
+
} : argv.extrinsic;
|
|
138
138
|
const { outcome, storageDiff } = await context.chain.dryRunExtrinsic(input);
|
|
139
139
|
if (outcome.isErr) {
|
|
140
140
|
throw new Error(outcome.asErr.toString());
|
|
141
141
|
}
|
|
142
142
|
defaultLogger.info(outcome.toHuman(), 'dry_run_outcome');
|
|
143
|
-
const filePath = await generateHtmlDiffPreviewFile(context.chain.head, storageDiff, blake2AsHex(argv
|
|
143
|
+
const filePath = await generateHtmlDiffPreviewFile(context.chain.head, storageDiff, blake2AsHex(argv.extrinsic, 256));
|
|
144
144
|
console.log(`Generated preview ${filePath}`);
|
|
145
|
-
if (argv
|
|
145
|
+
if (argv.open) {
|
|
146
146
|
openHtml(filePath);
|
|
147
147
|
}
|
|
148
148
|
}
|
|
@@ -4,7 +4,7 @@ export declare const dryRunSchema: z.ZodObject<{
|
|
|
4
4
|
address: z.ZodOptional<z.ZodString>;
|
|
5
5
|
preimage: z.ZodOptional<z.ZodString>;
|
|
6
6
|
at: z.ZodOptional<z.ZodString>;
|
|
7
|
-
|
|
7
|
+
'output-path': z.ZodOptional<z.ZodString>;
|
|
8
8
|
html: z.ZodOptional<z.ZodBoolean>;
|
|
9
9
|
open: z.ZodOptional<z.ZodBoolean>;
|
|
10
10
|
addr: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"localhost">, z.ZodString]>>;
|
|
@@ -196,10 +196,10 @@ export declare const dryRunSchema: z.ZodObject<{
|
|
|
196
196
|
'process-queued-messages'?: boolean | undefined;
|
|
197
197
|
'prefetch-storages'?: any;
|
|
198
198
|
open?: boolean | undefined;
|
|
199
|
-
"output-path"?: string | undefined;
|
|
200
199
|
extrinsic?: string | undefined;
|
|
201
200
|
address?: string | undefined;
|
|
202
201
|
preimage?: string | undefined;
|
|
202
|
+
'output-path'?: string | undefined;
|
|
203
203
|
html?: boolean | undefined;
|
|
204
204
|
}, {
|
|
205
205
|
at?: string | undefined;
|
|
@@ -251,10 +251,10 @@ export declare const dryRunSchema: z.ZodObject<{
|
|
|
251
251
|
'process-queued-messages'?: boolean | undefined;
|
|
252
252
|
'prefetch-storages'?: any;
|
|
253
253
|
open?: boolean | undefined;
|
|
254
|
-
"output-path"?: string | undefined;
|
|
255
254
|
extrinsic?: string | undefined;
|
|
256
255
|
address?: string | undefined;
|
|
257
256
|
preimage?: string | undefined;
|
|
257
|
+
'output-path'?: string | undefined;
|
|
258
258
|
html?: boolean | undefined;
|
|
259
259
|
}>;
|
|
260
260
|
export type DryRunSchemaType = z.infer<typeof dryRunSchema>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { configSchema } from '../../schema/index.js';
|
|
2
1
|
import { z } from 'zod';
|
|
2
|
+
import { configSchema } from '../../schema/index.js';
|
|
3
3
|
export const dryRunSchema = z.object({
|
|
4
4
|
...configSchema.shape,
|
|
5
5
|
extrinsic: z.string({
|
|
@@ -14,7 +14,7 @@ export const dryRunSchema = z.object({
|
|
|
14
14
|
at: z.string({
|
|
15
15
|
description: 'Block hash to dry run'
|
|
16
16
|
}).optional(),
|
|
17
|
-
|
|
17
|
+
'output-path': z.string({
|
|
18
18
|
description: 'File path to print output'
|
|
19
19
|
}).optional(),
|
|
20
20
|
html: z.boolean({
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ResponseError } from '@acala-network/chopsticks-core';
|
|
3
|
+
import { zHash, zHex } from '../../schema/index.js';
|
|
3
4
|
import { decodeStorageDiff } from '../../utils/decoder.js';
|
|
4
5
|
import { generateHtmlDiff } from '../../utils/generate-html-diff.js';
|
|
5
|
-
import { zHash, zHex } from '../../schema/index.js';
|
|
6
6
|
const zParaId = z.string().regex(/^\d+$/).transform(Number);
|
|
7
7
|
const schema = z.object({
|
|
8
8
|
raw: z.boolean().optional(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import _ from 'lodash';
|
|
2
|
+
import { z } from 'zod';
|
|
3
3
|
import { configSchema, getYargsOptions } from '../../schema/index.js';
|
|
4
4
|
import { fetchStorages, logger } from '../../utils/fetch-storages.js';
|
|
5
5
|
const schema = z.object(_.pick(configSchema.shape, [
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Block, defaultLogger, runTask, taskHandler } from '@acala-network/chopsticks-core';
|
|
2
|
-
import { z } from 'zod';
|
|
3
2
|
import _ from 'lodash';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { setupContext } from '../../context.js';
|
|
5
|
+
import { handler } from '../../rpc/index.js';
|
|
4
6
|
import { configSchema, getYargsOptions } from '../../schema/index.js';
|
|
5
7
|
import { createServer } from '../../server.js';
|
|
6
|
-
import { handler } from '../../rpc/index.js';
|
|
7
|
-
import { setupContext } from '../../context.js';
|
|
8
8
|
const logger = defaultLogger.child({
|
|
9
9
|
name: 'follow-chain'
|
|
10
10
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { environment } from '@acala-network/chopsticks-core';
|
|
2
1
|
import { lstatSync, readFileSync, readdirSync } from 'node:fs';
|
|
2
|
+
import { environment } from '@acala-network/chopsticks-core';
|
|
3
3
|
import _ from 'lodash';
|
|
4
|
-
import { defaultLogger } from '../logger.js';
|
|
5
4
|
import { resolve } from 'node:path';
|
|
5
|
+
import { defaultLogger } from '../logger.js';
|
|
6
6
|
const logger = defaultLogger.child({
|
|
7
7
|
name: 'plugin'
|
|
8
8
|
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { writeFileSync } from 'node:fs';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { runTask, taskHandler } from '@acala-network/chopsticks-core';
|
|
4
|
+
import { setupContext } from '../../context.js';
|
|
4
5
|
import { configSchema, getYargsOptions } from '../../schema/index.js';
|
|
5
6
|
import { generateHtmlDiffPreviewFile } from '../../utils/generate-html-diff.js';
|
|
6
7
|
import { openHtml } from '../../utils/open-html.js';
|
|
7
|
-
import { setupContext } from '../../context.js';
|
|
8
8
|
const schema = z.object({
|
|
9
9
|
...configSchema.shape,
|
|
10
|
-
|
|
10
|
+
'output-path': z.string({
|
|
11
11
|
description: 'File path to print output'
|
|
12
12
|
}).optional(),
|
|
13
13
|
html: z.boolean({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HexString } from '@polkadot/util/types';
|
|
1
|
+
import type { HexString } from '@polkadot/util/types';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { Context, RuntimeLog } from '@acala-network/chopsticks-core';
|
|
3
|
+
import { type Context, type RuntimeLog } from '@acala-network/chopsticks-core';
|
|
4
4
|
declare const schema: z.ZodObject<{
|
|
5
5
|
includeRaw: z.ZodOptional<z.ZodBoolean>;
|
|
6
6
|
includeParsed: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Argv } from 'yargs';
|
|
1
|
+
import type { Argv } from 'yargs';
|
|
2
2
|
export declare const cli: (y: Argv) => void;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { pinoLogger } from '@acala-network/chopsticks-core';
|
|
2
1
|
import { writeFileSync } from 'node:fs';
|
|
2
|
+
import { pinoLogger } from '@acala-network/chopsticks-core';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
+
import { setupContext } from '../../context.js';
|
|
4
5
|
import { configSchema, getYargsOptions } from '../../schema/index.js';
|
|
5
6
|
import { fetchEVMTransaction, prepareBlock, traceCalls, traceVM } from './utils.js';
|
|
6
|
-
import { setupContext } from '../../context.js';
|
|
7
7
|
const schema = configSchema.extend({
|
|
8
8
|
vm: z.boolean({
|
|
9
9
|
description: 'Trace VM opcode'
|
|
@@ -29,7 +29,7 @@ export const cli = (y)=>{
|
|
|
29
29
|
}), async (argv)=>{
|
|
30
30
|
const config = schema.parse(argv);
|
|
31
31
|
const wasmPath = config['wasm-override'];
|
|
32
|
-
|
|
32
|
+
config['wasm-override'] = undefined;
|
|
33
33
|
const context = await setupContext(config, false);
|
|
34
34
|
const txHash = argv['tx-hash'];
|
|
35
35
|
if (!txHash) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Registry } from '@polkadot/types/types';
|
|
2
|
+
import type { HexString } from '@polkadot/util/types';
|
|
3
3
|
export type CallTrace = {
|
|
4
4
|
type: 'CALL' | 'CALLCODE' | 'STATICCALL' | 'DELEGATECALL' | 'CREATE' | 'SUICIDE';
|
|
5
5
|
from: HexString;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Block, Blockchain, RuntimeVersion } from '@acala-network/chopsticks-core';
|
|
2
|
-
import { HexString } from '@polkadot/util/types';
|
|
3
|
-
import { Step } from './types.js';
|
|
1
|
+
import { Block, type Blockchain, type RuntimeVersion } from '@acala-network/chopsticks-core';
|
|
2
|
+
import type { HexString } from '@polkadot/util/types';
|
|
3
|
+
import { type Step } from './types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Fetches the runtime with tracing feature from Github releases.
|
|
6
6
|
* @param runtimeVersion - The version of the runtime.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Block, pinoLogger } from '@acala-network/chopsticks-core';
|
|
2
2
|
import { blake2AsHex } from '@polkadot/util-crypto';
|
|
3
3
|
import _ from 'lodash';
|
|
4
|
-
import { registerTypes } from './types.js';
|
|
5
|
-
import { opName } from './table.js';
|
|
6
4
|
import { overrideWasm } from '../../utils/override.js';
|
|
5
|
+
import { opName } from './table.js';
|
|
6
|
+
import { registerTypes } from './types.js';
|
|
7
7
|
/**
|
|
8
8
|
* Fetches the runtime with tracing feature from Github releases.
|
|
9
9
|
* @param runtimeVersion - The version of the runtime.
|
|
@@ -113,7 +113,7 @@ export const fetchEVMTransaction = async (runtimeVersion, txHash)=>{
|
|
|
113
113
|
}) : null
|
|
114
114
|
})));
|
|
115
115
|
page += 1;
|
|
116
|
-
traceNextPage = outcome.steps.length
|
|
116
|
+
traceNextPage = outcome.steps.length === pageSize;
|
|
117
117
|
}
|
|
118
118
|
return steps;
|
|
119
119
|
};
|
|
@@ -149,7 +149,7 @@ export const fetchEVMTransaction = async (runtimeVersion, txHash)=>{
|
|
|
149
149
|
* @throws Error if the block or parent block is not found, or if the runtime wasm with tracing feature cannot be found.
|
|
150
150
|
*/ export const prepareBlock = async (chain, blockHashNumber, txHash, wasmPath)=>{
|
|
151
151
|
let wasm = wasmPath;
|
|
152
|
-
const block = typeof blockHashNumber
|
|
152
|
+
const block = typeof blockHashNumber === 'number' ? await chain.getBlockAt(blockHashNumber) : await chain.getBlock(blockHashNumber);
|
|
153
153
|
if (!block) {
|
|
154
154
|
throw new Error(`Block not found ${blockHashNumber}`);
|
|
155
155
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { BuildBlockMode } from '@acala-network/chopsticks-core';
|
|
2
1
|
import { writeFileSync } from 'node:fs';
|
|
2
|
+
import { BuildBlockMode } from '@acala-network/chopsticks-core';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
+
import { setupContext } from '../../context.js';
|
|
4
5
|
import { configSchema, getYargsOptions } from '../../schema/index.js';
|
|
5
6
|
import { overrideWasm } from '../../utils/override.js';
|
|
6
|
-
import { setupContext } from '../../context.js';
|
|
7
7
|
const schema = z.object({
|
|
8
8
|
endpoint: configSchema.shape.endpoint,
|
|
9
9
|
block: configSchema.shape.block,
|
|
10
10
|
db: configSchema.shape.db,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
'runtime-log-level': configSchema.shape['runtime-log-level'].default(5),
|
|
12
|
+
runtime: z.string({
|
|
13
13
|
description: 'Path to WASM built with feature `try-runtime` enabled'
|
|
14
14
|
}),
|
|
15
15
|
'import-storage': configSchema.shape['import-storage'],
|
|
@@ -22,7 +22,7 @@ const schema = z.object({
|
|
|
22
22
|
'disable-spec-check': z.boolean({
|
|
23
23
|
description: 'Disable spec name/version check'
|
|
24
24
|
}).optional(),
|
|
25
|
-
|
|
25
|
+
'output-path': z.string({
|
|
26
26
|
description: 'File path to print output'
|
|
27
27
|
}).optional()
|
|
28
28
|
});
|
package/dist/esm/rpc/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context, SubscriptionManager } from '@acala-network/chopsticks-core';
|
|
1
|
+
import { type Context, type SubscriptionManager } from '@acala-network/chopsticks-core';
|
|
2
2
|
export declare const handler: (context: Context) => ({ method, params }: {
|
|
3
3
|
method: string;
|
|
4
4
|
params: any[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BuildBlockMode } from '@acala-network/chopsticks-core';
|
|
2
|
-
import { Options } from 'yargs';
|
|
3
|
-
import { ZodNativeEnum, ZodRawShape, ZodTypeAny, z } from 'zod';
|
|
2
|
+
import type { Options } from 'yargs';
|
|
3
|
+
import { ZodNativeEnum, type ZodRawShape, type ZodTypeAny, z } from 'zod';
|
|
4
4
|
export declare const zHex: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
|
|
5
5
|
export declare const zHash: z.ZodIntersection<z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>>;
|
|
6
6
|
export declare const configSchema: z.ZodObject<{
|
package/dist/esm/schema/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { BuildBlockMode, defaultLogger, genesisSchema, isUrl } from '@acala-network/chopsticks-core';
|
|
2
|
-
import { ZodNativeEnum, z } from 'zod';
|
|
3
|
-
import { basename, extname } from 'node:path';
|
|
4
1
|
import { readFileSync } from 'node:fs';
|
|
5
|
-
import
|
|
2
|
+
import { basename, extname } from 'node:path';
|
|
3
|
+
import { BuildBlockMode, defaultLogger, genesisSchema, isUrl } from '@acala-network/chopsticks-core';
|
|
6
4
|
import axios from 'axios';
|
|
7
5
|
import yaml from 'js-yaml';
|
|
6
|
+
import _ from 'lodash';
|
|
7
|
+
import { ZodNativeEnum, z } from 'zod';
|
|
8
8
|
export const zHex = z.custom((val)=>/^0x\w+$/.test(val));
|
|
9
9
|
export const zHash = z.string().length(66).and(zHex);
|
|
10
10
|
export const configSchema = z.object({
|
package/dist/esm/server.d.ts
CHANGED
package/dist/esm/server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import http from 'node:http';
|
|
2
2
|
import { ResponseError } from '@acala-network/chopsticks-core';
|
|
3
|
+
import { WebSocket, WebSocketServer } from 'ws';
|
|
3
4
|
import { z } from 'zod';
|
|
4
|
-
import http from 'node:http';
|
|
5
5
|
import { defaultLogger, truncate } from './logger.js';
|
|
6
6
|
const httpLogger = defaultLogger.child({
|
|
7
7
|
name: 'http'
|
|
@@ -113,7 +113,7 @@ export const createServer = async (handler, port, host)=>{
|
|
|
113
113
|
const parsed = await requestSchema.safeParseAsync(parseRequest(body));
|
|
114
114
|
if (!parsed.success) {
|
|
115
115
|
httpLogger.error('Invalid request: %s', body);
|
|
116
|
-
throw new Error(
|
|
116
|
+
throw new Error(`Invalid request: ${body}`);
|
|
117
117
|
}
|
|
118
118
|
httpLogger.trace({
|
|
119
119
|
req: parsed.data
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createServer } from './server.js';
|
|
2
1
|
import { defaultLogger } from '@acala-network/chopsticks-core';
|
|
3
|
-
import { handler } from './rpc/index.js';
|
|
4
2
|
import { setupContext } from './context.js';
|
|
3
|
+
import { handler } from './rpc/index.js';
|
|
4
|
+
import { createServer } from './server.js';
|
|
5
5
|
export const setupWithServer = async (argv)=>{
|
|
6
6
|
if (argv.addr) {
|
|
7
7
|
defaultLogger.warn({}, `⚠️ Option --addr is deprecated, please use --host instead.`);
|