@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.
Files changed (98) hide show
  1. package/chopsticks.js +1 -1
  2. package/{lib → dist/cjs}/plugins/dry-run/dry-run-preimage.js +1 -3
  3. package/{lib → dist/cjs}/plugins/run-block/index.js +1 -4
  4. package/{lib → dist/cjs}/utils/generate-html-diff.js +1 -1
  5. package/dist/esm/cli-options.js +40 -0
  6. package/dist/esm/cli.js +90 -0
  7. package/dist/esm/context.js +86 -0
  8. package/dist/esm/plugins/decode-key/index.js +23 -0
  9. package/dist/esm/plugins/dry-run/cli.js +42 -0
  10. package/dist/esm/plugins/dry-run/dry-run-extrinsic.js +29 -0
  11. package/dist/esm/plugins/dry-run/dry-run-preimage.js +92 -0
  12. package/dist/esm/plugins/dry-run/rpc.js +101 -0
  13. package/dist/esm/plugins/index.js +25 -0
  14. package/dist/esm/plugins/new-block/index.js +67 -0
  15. package/dist/esm/plugins/run-block/index.js +176 -0
  16. package/dist/esm/plugins/set-block-build-mode/index.js +25 -0
  17. package/dist/esm/plugins/set-head/index.js +31 -0
  18. package/dist/esm/plugins/set-runtime-log-level/index.js +24 -0
  19. package/dist/esm/plugins/set-storage/index.js +38 -0
  20. package/dist/esm/plugins/time-travel/index.js +23 -0
  21. package/dist/esm/plugins/try-runtime/index.js +54 -0
  22. package/{lib/plugins/types.d.ts → dist/esm/plugins/types.js} +3 -3
  23. package/dist/esm/rpc/index.js +26 -0
  24. package/dist/esm/schema/index.js +53 -0
  25. package/dist/esm/server.js +164 -0
  26. package/dist/esm/setup-with-server.js +22 -0
  27. package/dist/esm/types.js +2 -0
  28. package/dist/esm/utils/decoder.js +15 -0
  29. package/dist/esm/utils/generate-html-diff.js +16 -0
  30. package/dist/esm/utils/open-html.js +5 -0
  31. package/dist/esm/utils/override.js +43 -0
  32. package/dist/esm/utils/tunnel.js +11 -0
  33. package/dist/types/index.d.ts +4 -0
  34. package/dist/types/logger.d.ts +1 -0
  35. package/dist/types/plugins/dry-run/index.d.ts +2 -0
  36. package/dist/types/plugins/types.d.ts +11 -0
  37. package/dist/types/utils/index.d.ts +4 -0
  38. package/package.json +23 -14
  39. /package/{lib → dist/cjs}/cli-options.js +0 -0
  40. /package/{lib → dist/cjs}/cli.js +0 -0
  41. /package/{lib → dist/cjs}/context.js +0 -0
  42. /package/{lib → dist/cjs}/index.js +0 -0
  43. /package/{lib → dist/cjs}/logger.js +0 -0
  44. /package/{lib → dist/cjs}/plugins/decode-key/index.js +0 -0
  45. /package/{lib → dist/cjs}/plugins/dry-run/cli.js +0 -0
  46. /package/{lib → dist/cjs}/plugins/dry-run/dry-run-extrinsic.js +0 -0
  47. /package/{lib → dist/cjs}/plugins/dry-run/index.js +0 -0
  48. /package/{lib → dist/cjs}/plugins/dry-run/rpc.js +0 -0
  49. /package/{lib → dist/cjs}/plugins/index.js +0 -0
  50. /package/{lib → dist/cjs}/plugins/new-block/index.js +0 -0
  51. /package/{lib → dist/cjs}/plugins/set-block-build-mode/index.js +0 -0
  52. /package/{lib → dist/cjs}/plugins/set-head/index.js +0 -0
  53. /package/{lib → dist/cjs}/plugins/set-runtime-log-level/index.js +0 -0
  54. /package/{lib → dist/cjs}/plugins/set-storage/index.js +0 -0
  55. /package/{lib → dist/cjs}/plugins/time-travel/index.js +0 -0
  56. /package/{lib → dist/cjs}/plugins/try-runtime/index.js +0 -0
  57. /package/{lib → dist/cjs}/plugins/types.js +0 -0
  58. /package/{lib → dist/cjs}/rpc/index.js +0 -0
  59. /package/{lib → dist/cjs}/schema/index.js +0 -0
  60. /package/{lib → dist/cjs}/server.js +0 -0
  61. /package/{lib → dist/cjs}/setup-with-server.js +0 -0
  62. /package/{lib → dist/cjs}/types.js +0 -0
  63. /package/{lib → dist/cjs}/utils/decoder.js +0 -0
  64. /package/{lib → dist/cjs}/utils/index.js +0 -0
  65. /package/{lib → dist/cjs}/utils/open-html.js +0 -0
  66. /package/{lib → dist/cjs}/utils/override.js +0 -0
  67. /package/{lib → dist/cjs}/utils/tunnel.js +0 -0
  68. /package/{lib/index.d.ts → dist/esm/index.js} +0 -0
  69. /package/{lib/logger.d.ts → dist/esm/logger.js} +0 -0
  70. /package/{lib/plugins/dry-run/index.d.ts → dist/esm/plugins/dry-run/index.js} +0 -0
  71. /package/{lib/utils/index.d.ts → dist/esm/utils/index.js} +0 -0
  72. /package/{lib → dist/types}/cli-options.d.ts +0 -0
  73. /package/{lib → dist/types}/cli.d.ts +0 -0
  74. /package/{lib → dist/types}/context.d.ts +0 -0
  75. /package/{lib → dist/types}/plugins/decode-key/index.d.ts +0 -0
  76. /package/{lib → dist/types}/plugins/dry-run/cli.d.ts +0 -0
  77. /package/{lib → dist/types}/plugins/dry-run/dry-run-extrinsic.d.ts +0 -0
  78. /package/{lib → dist/types}/plugins/dry-run/dry-run-preimage.d.ts +0 -0
  79. /package/{lib → dist/types}/plugins/dry-run/rpc.d.ts +0 -0
  80. /package/{lib → dist/types}/plugins/index.d.ts +0 -0
  81. /package/{lib → dist/types}/plugins/new-block/index.d.ts +0 -0
  82. /package/{lib → dist/types}/plugins/run-block/index.d.ts +0 -0
  83. /package/{lib → dist/types}/plugins/set-block-build-mode/index.d.ts +0 -0
  84. /package/{lib → dist/types}/plugins/set-head/index.d.ts +0 -0
  85. /package/{lib → dist/types}/plugins/set-runtime-log-level/index.d.ts +0 -0
  86. /package/{lib → dist/types}/plugins/set-storage/index.d.ts +0 -0
  87. /package/{lib → dist/types}/plugins/time-travel/index.d.ts +0 -0
  88. /package/{lib → dist/types}/plugins/try-runtime/index.d.ts +0 -0
  89. /package/{lib → dist/types}/rpc/index.d.ts +0 -0
  90. /package/{lib → dist/types}/schema/index.d.ts +0 -0
  91. /package/{lib → dist/types}/server.d.ts +0 -0
  92. /package/{lib → dist/types}/setup-with-server.d.ts +0 -0
  93. /package/{lib → dist/types}/types.d.ts +0 -0
  94. /package/{lib → dist/types}/utils/decoder.d.ts +0 -0
  95. /package/{lib → dist/types}/utils/generate-html-diff.d.ts +0 -0
  96. /package/{lib → dist/types}/utils/open-html.d.ts +0 -0
  97. /package/{lib → dist/types}/utils/override.d.ts +0 -0
  98. /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,5 @@
1
+ import { execSync } from 'node:child_process';
2
+ export const openHtml = (filePath) => {
3
+ const start = process.platform == 'darwin' ? 'open' : process.platform == 'win32' ? 'start' : 'xdg-open';
4
+ execSync(start + ' ' + filePath);
5
+ };
@@ -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,4 @@
1
+ import '@polkadot/api-augment';
2
+ export * from '@acala-network/chopsticks-core';
3
+ export { setupWithServer } from './setup-with-server';
4
+ export { fetchConfig } from './schema';
@@ -0,0 +1 @@
1
+ export { defaultLogger, truncate } from '@acala-network/chopsticks-core';
@@ -0,0 +1,2 @@
1
+ export * from './cli';
2
+ export * from './rpc';
@@ -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';
@@ -0,0 +1,4 @@
1
+ export * from './decoder';
2
+ export * from './generate-html-diff';
3
+ export * from './open-html';
4
+ export * from './override';
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@acala-network/chopsticks",
3
- "version": "0.8.5-4",
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 lib tsconfig.tsbuildinfo",
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-4",
21
- "@acala-network/chopsticks-db": "0.8.5-4",
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
- "lib",
45
+ "dist/esm/**",
46
+ "dist/cjs/**",
47
+ "dist/types/**",
46
48
  "template",
47
49
  "chopsticks.js"
48
50
  ],
49
- "main": "./lib/index.js",
50
- "types": "./lib/index.d.ts",
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": "./lib/index.d.ts",
54
- "default": "./lib/index.js"
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": "./lib/*.d.ts",
58
- "default": "./lib/*.js"
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": "./lib/plugins/*.d.ts",
62
- "default": "./lib/plugins/*.js"
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
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