@acala-network/chopsticks 0.9.0 → 0.9.1-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.
@@ -110,8 +110,8 @@ const setupContext = async (argv, overrideParent = false) => {
110
110
  }
111
111
  // override wasm before importing storage, in case new pallets have been
112
112
  // added that have storage imports
113
- await (0, override_1.overrideStorage)(chain, argv['import-storage'], at);
114
113
  await (0, override_1.overrideWasm)(chain, argv['wasm-override'], at);
114
+ await (0, override_1.overrideStorage)(chain, argv['import-storage'], at);
115
115
  return { chain };
116
116
  };
117
117
  exports.setupContext = setupContext;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.rpc = exports.name = exports.cli = void 0;
4
+ const util_1 = require("@polkadot/util");
4
5
  const node_fs_1 = require("node:fs");
5
6
  const zod_1 = require("zod");
6
7
  const chopsticks_core_1 = require("@acala-network/chopsticks-core");
@@ -80,6 +81,7 @@ exports.name = 'runBlock';
80
81
  * Run a set of extrinsics on top of a block and get the storage diff
81
82
  * and optionally the parsed storage diff and block details.
82
83
  * NOTE: The extrinsics should include inherents or tranasctions may have unexpected results.
84
+ * NOTE: system.events and system.extrinsicData are excluded from storage diff to reduce size.
83
85
  *
84
86
  * This function is a dev rpc handler. Use `dev_runBlock` as the method name when calling it.
85
87
  */
@@ -108,6 +110,8 @@ const rpc = async ({ chain }, [params]) => {
108
110
  };
109
111
  // exclude system events because it can be stupidly large and redudant
110
112
  const systemEventsKey = (0, chopsticks_core_1.compactHex)(meta.query.system.events());
113
+ // large and not really useful
114
+ const systemExtrinsicDataKey = (0, util_1.u8aToHex)(meta.query.system.extrinsicData.keyPrefix());
111
115
  const run = async (fn, args) => {
112
116
  const result = await (0, chopsticks_core_1.runTask)({
113
117
  wasm,
@@ -126,12 +130,23 @@ const rpc = async ({ chain }, [params]) => {
126
130
  if (key === systemEventsKey) {
127
131
  continue;
128
132
  }
133
+ if (key.startsWith(systemExtrinsicDataKey)) {
134
+ continue;
135
+ }
129
136
  const obj = {};
130
137
  if (includeRawStorage) {
131
138
  obj.raw = { key, value };
132
139
  }
133
140
  if (includeParsed) {
134
- obj.parsed = (0, chopsticks_core_1.decodeKeyValue)(await newBlock.meta, newBlock, key, value, false);
141
+ const decoded = (0, chopsticks_core_1.decodeKeyValue)(await newBlock.meta, newBlock, key, value, false);
142
+ if (decoded) {
143
+ obj.parsed = {
144
+ section: decoded.section,
145
+ method: decoded.method,
146
+ key: decoded.key,
147
+ value: decoded.value,
148
+ };
149
+ }
135
150
  }
136
151
  resp.storageDiff.push(obj);
137
152
  }
@@ -10,7 +10,7 @@ const lodash_1 = require("lodash");
10
10
  const node_path_1 = __importDefault(require("node:path"));
11
11
  const generateHtmlDiff = async (block, diff) => {
12
12
  const { oldState, delta } = await (0, decoder_1.decodeStorageDiff)(block, diff);
13
- const htmlTemplate = (0, node_fs_1.readFileSync)(node_path_1.default.join(__dirname, '../../../template/diff.html'), 'utf-8');
13
+ const htmlTemplate = (0, node_fs_1.readFileSync)(node_path_1.default.join(__dirname, '../../template/diff.html'), 'utf-8');
14
14
  return (0, lodash_1.template)(htmlTemplate)({ left: JSON.stringify(oldState), delta: JSON.stringify(delta) });
15
15
  };
16
16
  exports.generateHtmlDiff = generateHtmlDiff;
@@ -80,7 +80,7 @@ export const setupContext = async (argv, overrideParent = false) => {
80
80
  }
81
81
  // override wasm before importing storage, in case new pallets have been
82
82
  // added that have storage imports
83
- await overrideStorage(chain, argv['import-storage'], at);
84
83
  await overrideWasm(chain, argv['wasm-override'], at);
84
+ await overrideStorage(chain, argv['import-storage'], at);
85
85
  return { chain };
86
86
  };
@@ -1,3 +1,4 @@
1
+ import { u8aToHex } from '@polkadot/util';
1
2
  import { writeFileSync } from 'node:fs';
2
3
  import { z } from 'zod';
3
4
  import { Block, compactHex, decodeKeyValue, printRuntimeLogs, runTask, taskHandler, } from '@acala-network/chopsticks-core';
@@ -76,6 +77,7 @@ export const name = 'runBlock';
76
77
  * Run a set of extrinsics on top of a block and get the storage diff
77
78
  * and optionally the parsed storage diff and block details.
78
79
  * NOTE: The extrinsics should include inherents or tranasctions may have unexpected results.
80
+ * NOTE: system.events and system.extrinsicData are excluded from storage diff to reduce size.
79
81
  *
80
82
  * This function is a dev rpc handler. Use `dev_runBlock` as the method name when calling it.
81
83
  */
@@ -104,6 +106,8 @@ export const rpc = async ({ chain }, [params]) => {
104
106
  };
105
107
  // exclude system events because it can be stupidly large and redudant
106
108
  const systemEventsKey = compactHex(meta.query.system.events());
109
+ // large and not really useful
110
+ const systemExtrinsicDataKey = u8aToHex(meta.query.system.extrinsicData.keyPrefix());
107
111
  const run = async (fn, args) => {
108
112
  const result = await runTask({
109
113
  wasm,
@@ -122,12 +126,23 @@ export const rpc = async ({ chain }, [params]) => {
122
126
  if (key === systemEventsKey) {
123
127
  continue;
124
128
  }
129
+ if (key.startsWith(systemExtrinsicDataKey)) {
130
+ continue;
131
+ }
125
132
  const obj = {};
126
133
  if (includeRawStorage) {
127
134
  obj.raw = { key, value };
128
135
  }
129
136
  if (includeParsed) {
130
- obj.parsed = decodeKeyValue(await newBlock.meta, newBlock, key, value, false);
137
+ const decoded = decodeKeyValue(await newBlock.meta, newBlock, key, value, false);
138
+ if (decoded) {
139
+ obj.parsed = {
140
+ section: decoded.section,
141
+ method: decoded.method,
142
+ key: decoded.key,
143
+ value: decoded.value,
144
+ };
145
+ }
131
146
  }
132
147
  resp.storageDiff.push(obj);
133
148
  }
@@ -4,7 +4,7 @@ import { template } from 'lodash';
4
4
  import path from 'node:path';
5
5
  export const generateHtmlDiff = async (block, diff) => {
6
6
  const { oldState, delta } = await decodeStorageDiff(block, diff);
7
- const htmlTemplate = readFileSync(path.join(__dirname, '../../../template/diff.html'), 'utf-8');
7
+ const htmlTemplate = readFileSync(path.join(__dirname, '../../template/diff.html'), 'utf-8');
8
8
  return template(htmlTemplate)({ left: JSON.stringify(oldState), delta: JSON.stringify(delta) });
9
9
  };
10
10
  export const generateHtmlDiffPreviewFile = async (block, diff, filename) => {
@@ -1,7 +1,7 @@
1
1
  import { HexString } from '@polkadot/util/types';
2
2
  import { z } from 'zod';
3
3
  import type yargs from 'yargs';
4
- import { Context } from '@acala-network/chopsticks-core';
4
+ import { Context, RuntimeLog } from '@acala-network/chopsticks-core';
5
5
  export declare const cli: (y: yargs.Argv) => void;
6
6
  declare const schema: z.ZodObject<{
7
7
  includeRaw: z.ZodOptional<z.ZodBoolean>;
@@ -88,12 +88,17 @@ export interface RunBlockResponse {
88
88
  /**
89
89
  * Decoded storage diff. Only available when `includeParsed` is true.
90
90
  */
91
- parsed?: any;
91
+ parsed?: {
92
+ method: string;
93
+ section: string;
94
+ key: any[];
95
+ value: any;
96
+ };
92
97
  }[];
93
98
  /**
94
99
  * Runtime logs.
95
100
  */
96
- logs?: string[];
101
+ logs?: RuntimeLog[];
97
102
  }[];
98
103
  /**
99
104
  * Block details. Only available when `includeBlockDetails` is true.
@@ -128,6 +133,7 @@ export declare const name = "runBlock";
128
133
  * Run a set of extrinsics on top of a block and get the storage diff
129
134
  * and optionally the parsed storage diff and block details.
130
135
  * NOTE: The extrinsics should include inherents or tranasctions may have unexpected results.
136
+ * NOTE: system.events and system.extrinsicData are excluded from storage diff to reduce size.
131
137
  *
132
138
  * This function is a dev rpc handler. Use `dev_runBlock` as the method name when calling it.
133
139
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acala-network/chopsticks",
3
- "version": "0.9.0",
3
+ "version": "0.9.1-1",
4
4
  "author": "Acala Developers <hello@acala.network>",
5
5
  "license": "Apache-2.0",
6
6
  "bin": "./chopsticks.js",
@@ -17,10 +17,10 @@
17
17
  "docs:prep": "typedoc"
18
18
  },
19
19
  "dependencies": {
20
- "@acala-network/chopsticks-core": "0.9.0",
21
- "@acala-network/chopsticks-db": "0.9.0",
20
+ "@acala-network/chopsticks-core": "0.9.1-1",
21
+ "@acala-network/chopsticks-db": "0.9.1-1",
22
22
  "@pnpm/npm-conf": "^2.2.2",
23
- "axios": "^1.5.1",
23
+ "axios": "^1.6.0",
24
24
  "dotenv": "^16.3.1",
25
25
  "global-agent": "^3.0.0",
26
26
  "js-yaml": "^4.1.0",
@@ -36,7 +36,7 @@
36
36
  "@types/lodash": "^4.14.199",
37
37
  "@types/node": "^20.5.7",
38
38
  "@types/ws": "^8.5.6",
39
- "@types/yargs": "^17.0.24",
39
+ "@types/yargs": "^17.0.29",
40
40
  "ts-node": "^10.9.1",
41
41
  "ts-node-dev": "^2.0.0",
42
42
  "typescript": "^5.1.6"