@acala-network/chopsticks 0.8.5-4 → 0.8.5-6
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/chopsticks.js +1 -1
- package/{lib → dist/cjs}/plugins/dry-run/dry-run-preimage.js +1 -3
- package/{lib → dist/cjs}/plugins/run-block/index.js +1 -4
- package/{lib → dist/cjs}/utils/generate-html-diff.js +1 -1
- package/dist/esm/cli-options.js +40 -0
- package/dist/esm/cli.js +90 -0
- package/dist/esm/context.js +86 -0
- package/dist/esm/plugins/decode-key/index.js +23 -0
- package/dist/esm/plugins/dry-run/cli.js +42 -0
- package/dist/esm/plugins/dry-run/dry-run-extrinsic.js +29 -0
- package/dist/esm/plugins/dry-run/dry-run-preimage.js +92 -0
- package/dist/esm/plugins/dry-run/rpc.js +101 -0
- package/dist/esm/plugins/index.js +25 -0
- package/dist/esm/plugins/new-block/index.js +67 -0
- package/dist/esm/plugins/run-block/index.js +176 -0
- package/dist/esm/plugins/set-block-build-mode/index.js +25 -0
- package/dist/esm/plugins/set-head/index.js +31 -0
- package/dist/esm/plugins/set-runtime-log-level/index.js +24 -0
- package/dist/esm/plugins/set-storage/index.js +38 -0
- package/dist/esm/plugins/time-travel/index.js +23 -0
- package/dist/esm/plugins/try-runtime/index.js +54 -0
- package/{lib/plugins/types.d.ts → dist/esm/plugins/types.js} +3 -3
- package/dist/esm/rpc/index.js +26 -0
- package/dist/esm/schema/index.js +53 -0
- package/dist/esm/server.js +164 -0
- package/dist/esm/setup-with-server.js +22 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/utils/decoder.js +15 -0
- package/dist/esm/utils/generate-html-diff.js +16 -0
- package/dist/esm/utils/open-html.js +5 -0
- package/dist/esm/utils/override.js +43 -0
- package/dist/esm/utils/tunnel.js +11 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/logger.d.ts +1 -0
- package/dist/types/plugins/dry-run/index.d.ts +2 -0
- package/dist/types/plugins/types.d.ts +11 -0
- package/dist/types/utils/index.d.ts +4 -0
- package/package.json +23 -14
- /package/{lib → dist/cjs}/cli-options.js +0 -0
- /package/{lib → dist/cjs}/cli.js +0 -0
- /package/{lib → dist/cjs}/context.js +0 -0
- /package/{lib → dist/cjs}/index.js +0 -0
- /package/{lib → dist/cjs}/logger.js +0 -0
- /package/{lib → dist/cjs}/plugins/decode-key/index.js +0 -0
- /package/{lib → dist/cjs}/plugins/dry-run/cli.js +0 -0
- /package/{lib → dist/cjs}/plugins/dry-run/dry-run-extrinsic.js +0 -0
- /package/{lib → dist/cjs}/plugins/dry-run/index.js +0 -0
- /package/{lib → dist/cjs}/plugins/dry-run/rpc.js +0 -0
- /package/{lib → dist/cjs}/plugins/index.js +0 -0
- /package/{lib → dist/cjs}/plugins/new-block/index.js +0 -0
- /package/{lib → dist/cjs}/plugins/set-block-build-mode/index.js +0 -0
- /package/{lib → dist/cjs}/plugins/set-head/index.js +0 -0
- /package/{lib → dist/cjs}/plugins/set-runtime-log-level/index.js +0 -0
- /package/{lib → dist/cjs}/plugins/set-storage/index.js +0 -0
- /package/{lib → dist/cjs}/plugins/time-travel/index.js +0 -0
- /package/{lib → dist/cjs}/plugins/try-runtime/index.js +0 -0
- /package/{lib → dist/cjs}/plugins/types.js +0 -0
- /package/{lib → dist/cjs}/rpc/index.js +0 -0
- /package/{lib → dist/cjs}/schema/index.js +0 -0
- /package/{lib → dist/cjs}/server.js +0 -0
- /package/{lib → dist/cjs}/setup-with-server.js +0 -0
- /package/{lib → dist/cjs}/types.js +0 -0
- /package/{lib → dist/cjs}/utils/decoder.js +0 -0
- /package/{lib → dist/cjs}/utils/index.js +0 -0
- /package/{lib → dist/cjs}/utils/open-html.js +0 -0
- /package/{lib → dist/cjs}/utils/override.js +0 -0
- /package/{lib → dist/cjs}/utils/tunnel.js +0 -0
- /package/{lib/index.d.ts → dist/esm/index.js} +0 -0
- /package/{lib/logger.d.ts → dist/esm/logger.js} +0 -0
- /package/{lib/plugins/dry-run/index.d.ts → dist/esm/plugins/dry-run/index.js} +0 -0
- /package/{lib/utils/index.d.ts → dist/esm/utils/index.js} +0 -0
- /package/{lib → dist/types}/cli-options.d.ts +0 -0
- /package/{lib → dist/types}/cli.d.ts +0 -0
- /package/{lib → dist/types}/context.d.ts +0 -0
- /package/{lib → dist/types}/plugins/decode-key/index.d.ts +0 -0
- /package/{lib → dist/types}/plugins/dry-run/cli.d.ts +0 -0
- /package/{lib → dist/types}/plugins/dry-run/dry-run-extrinsic.d.ts +0 -0
- /package/{lib → dist/types}/plugins/dry-run/dry-run-preimage.d.ts +0 -0
- /package/{lib → dist/types}/plugins/dry-run/rpc.d.ts +0 -0
- /package/{lib → dist/types}/plugins/index.d.ts +0 -0
- /package/{lib → dist/types}/plugins/new-block/index.d.ts +0 -0
- /package/{lib → dist/types}/plugins/run-block/index.d.ts +0 -0
- /package/{lib → dist/types}/plugins/set-block-build-mode/index.d.ts +0 -0
- /package/{lib → dist/types}/plugins/set-head/index.d.ts +0 -0
- /package/{lib → dist/types}/plugins/set-runtime-log-level/index.d.ts +0 -0
- /package/{lib → dist/types}/plugins/set-storage/index.d.ts +0 -0
- /package/{lib → dist/types}/plugins/time-travel/index.d.ts +0 -0
- /package/{lib → dist/types}/plugins/try-runtime/index.d.ts +0 -0
- /package/{lib → dist/types}/rpc/index.d.ts +0 -0
- /package/{lib → dist/types}/schema/index.d.ts +0 -0
- /package/{lib → dist/types}/server.d.ts +0 -0
- /package/{lib → dist/types}/setup-with-server.d.ts +0 -0
- /package/{lib → dist/types}/types.d.ts +0 -0
- /package/{lib → dist/types}/utils/decoder.d.ts +0 -0
- /package/{lib → dist/types}/utils/generate-html-diff.d.ts +0 -0
- /package/{lib → dist/types}/utils/open-html.d.ts +0 -0
- /package/{lib → dist/types}/utils/override.d.ts +0 -0
- /package/{lib → dist/types}/utils/tunnel.d.ts +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { decodeStorageDiff } from './decoder';
|
|
2
|
+
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { template } from 'lodash';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
export const generateHtmlDiff = async (block, diff) => {
|
|
6
|
+
const { oldState, delta } = await decodeStorageDiff(block, diff);
|
|
7
|
+
const htmlTemplate = readFileSync(path.join(__dirname, '../../../template/diff.html'), 'utf-8');
|
|
8
|
+
return template(htmlTemplate)({ left: JSON.stringify(oldState), delta: JSON.stringify(delta) });
|
|
9
|
+
};
|
|
10
|
+
export const generateHtmlDiffPreviewFile = async (block, diff, filename) => {
|
|
11
|
+
const html = await generateHtmlDiff(block, diff);
|
|
12
|
+
mkdirSync('./preview', { recursive: true });
|
|
13
|
+
const filePath = `./preview/${filename}.html`;
|
|
14
|
+
writeFileSync(filePath, html);
|
|
15
|
+
return filePath;
|
|
16
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { setStorage } from '@acala-network/chopsticks-core';
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
+
import yaml from 'js-yaml';
|
|
4
|
+
import { defaultLogger } from '../logger';
|
|
5
|
+
export const overrideStorage = async (chain, storage, at) => {
|
|
6
|
+
if (storage == null) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
let storageValue;
|
|
10
|
+
if (typeof storage === 'string') {
|
|
11
|
+
if (!existsSync(storage))
|
|
12
|
+
throw Error(`File ${storage} does not exist`);
|
|
13
|
+
storageValue = yaml.load(String(readFileSync(storage)));
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
storageValue = storage;
|
|
17
|
+
}
|
|
18
|
+
const blockHash = await setStorage(chain, storageValue, at);
|
|
19
|
+
defaultLogger.trace({ blockHash, storage }, 'OverrideStorage');
|
|
20
|
+
};
|
|
21
|
+
export const overrideWasm = async (chain, wasmPath, at) => {
|
|
22
|
+
if (wasmPath == null) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const wasm = readFileSync(wasmPath);
|
|
26
|
+
let wasmHex;
|
|
27
|
+
if (wasm.at(0) === 0x30 && wasm.at(1) === 0x78) {
|
|
28
|
+
// starts with 0x
|
|
29
|
+
wasmHex = wasm.toString().trim();
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
wasmHex = '0x' + wasm.toString('hex');
|
|
33
|
+
}
|
|
34
|
+
if (at) {
|
|
35
|
+
const block = await chain.getBlock(at);
|
|
36
|
+
if (!block)
|
|
37
|
+
throw new Error(`Cannot find block ${at}`);
|
|
38
|
+
block.setWasm(wasmHex);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
chain.head.setWasm(wasmHex);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import 'global-agent/bootstrap';
|
|
2
|
+
import npmConf from '@pnpm/npm-conf';
|
|
3
|
+
const npmConfig = npmConf().config;
|
|
4
|
+
global.GLOBAL_AGENT.HTTP_PROXY =
|
|
5
|
+
process.env.HTTP_PROXY ||
|
|
6
|
+
process.env.http_proxy ||
|
|
7
|
+
process.env.HTTPS_PROXY ||
|
|
8
|
+
process.env.https_proxy ||
|
|
9
|
+
npmConfig.get('proxy') ||
|
|
10
|
+
npmConfig.get('https-proxy') ||
|
|
11
|
+
global.GLOBAL_AGENT.HTTP_PROXY;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defaultLogger, truncate } from '@acala-network/chopsticks-core';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { rpc as newBlock } from './new-block';
|
|
2
|
+
export { rpc as dryRun } from './dry-run';
|
|
3
|
+
export { rpc as setBlockBuildMode } from './set-block-build-mode';
|
|
4
|
+
export { rpc as setHead } from './set-head';
|
|
5
|
+
export { rpc as setRuntimeLogLevel } from './set-runtime-log-level';
|
|
6
|
+
export { rpc as setStorage } from './set-storage';
|
|
7
|
+
export { rpc as timeTravel } from './time-travel';
|
|
8
|
+
export { rpc as runBlock } from './run-block';
|
|
9
|
+
export type { NewBlockParams } from './new-block';
|
|
10
|
+
export type { DryRunParams } from './dry-run';
|
|
11
|
+
export type { RunBlockParams } from './run-block';
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acala-network/chopsticks",
|
|
3
|
-
"version": "0.8.5-
|
|
3
|
+
"version": "0.8.5-6",
|
|
4
4
|
"author": "Acala Developers <hello@acala.network>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"bin": "./chopsticks.js",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"clean": "rm -rf
|
|
9
|
-
"build": "tsc -p ./tsconfig.json",
|
|
8
|
+
"clean": "rm -rf dist",
|
|
9
|
+
"build": "yarn clean && tsc -p ./tsconfig.json && tsc -p ./tsconfig.esm.json",
|
|
10
10
|
"script:start": "cd ../..; ts-node --transpile-only -r tsconfig-paths/register packages/chopsticks/src/cli.ts",
|
|
11
11
|
"script:run": "cd ../..; LOG_LEVEL=trace ts-node-dev --transpile-only -r tsconfig-paths/register --inspect --notify=false packages/chopsticks/src/cli.ts -- --config=configs/dev.yml",
|
|
12
12
|
"dev:karura": "cd ../..; ts-node-dev --transpile-only --inspect -r tsconfig-paths/register --notify=false packages/chopsticks/src/cli.ts -- --config=configs/karura.yml",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"docs:prep": "typedoc"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@acala-network/chopsticks-core": "0.8.5-
|
|
21
|
-
"@acala-network/chopsticks-db": "0.8.5-
|
|
20
|
+
"@acala-network/chopsticks-core": "0.8.5-6",
|
|
21
|
+
"@acala-network/chopsticks-db": "0.8.5-6",
|
|
22
22
|
"@pnpm/npm-conf": "^2.2.2",
|
|
23
23
|
"axios": "^1.5.1",
|
|
24
24
|
"dotenv": "^16.3.1",
|
|
@@ -42,24 +42,33 @@
|
|
|
42
42
|
"typescript": "^5.1.6"
|
|
43
43
|
},
|
|
44
44
|
"files": [
|
|
45
|
-
"
|
|
45
|
+
"dist/esm/**",
|
|
46
|
+
"dist/cjs/**",
|
|
47
|
+
"dist/types/**",
|
|
46
48
|
"template",
|
|
47
49
|
"chopsticks.js"
|
|
48
50
|
],
|
|
49
|
-
"main": "./
|
|
50
|
-
"
|
|
51
|
+
"main": "./dist/cjs/index.js",
|
|
52
|
+
"module": "./dist/esm/index.js",
|
|
53
|
+
"types": "./dist/types/index.d.ts",
|
|
51
54
|
"exports": {
|
|
52
55
|
".": {
|
|
53
|
-
"types": "./
|
|
54
|
-
"
|
|
56
|
+
"types": "./dist/types/index.d.ts",
|
|
57
|
+
"require": "./dist/cjs/index.js",
|
|
58
|
+
"import": "./dist/esm/index.js",
|
|
59
|
+
"default": "./dist/esm/index.js"
|
|
55
60
|
},
|
|
56
61
|
"./*": {
|
|
57
|
-
"types": "./
|
|
58
|
-
"
|
|
62
|
+
"types": "./dist/types/index.d.ts",
|
|
63
|
+
"require": "./dist/cjs/index.js",
|
|
64
|
+
"import": "./dist/esm/index.js",
|
|
65
|
+
"default": "./dist/esm/index.js"
|
|
59
66
|
},
|
|
60
67
|
"./plugins/*": {
|
|
61
|
-
"types": "./
|
|
62
|
-
"
|
|
68
|
+
"types": "./dist/types/plugins/*.d.ts",
|
|
69
|
+
"require": "./dist/cjs/plugins/*.js",
|
|
70
|
+
"import": "./dist/esm/plugins/*.js",
|
|
71
|
+
"default": "./dist/esm/plugins/*.js"
|
|
63
72
|
},
|
|
64
73
|
"./package.json": "./package.json"
|
|
65
74
|
}
|
|
File without changes
|
/package/{lib → dist/cjs}/cli.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|