@acala-network/chopsticks 0.9.7 → 0.9.8-2

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.
@@ -10,9 +10,9 @@ Object.defineProperty(exports, "dryRunPreimage", {
10
10
  });
11
11
  const _utilcrypto = require("@polkadot/util-crypto");
12
12
  const _util = require("@polkadot/util");
13
+ const _chopstickscore = require("@acala-network/chopsticks-core");
13
14
  const _logger = require("../../logger.js");
14
15
  const _generatehtmldiff = require("../../utils/generate-html-diff.js");
15
- const _chopstickscore = require("@acala-network/chopsticks-core");
16
16
  const _openhtml = require("../../utils/open-html.js");
17
17
  const _context = require("../../context.js");
18
18
  const dryRunPreimage = async (argv)=>{
@@ -33,7 +33,7 @@ const dryRunPreimage = async (argv)=>{
33
33
  data.byteLength
34
34
  ]
35
35
  ],
36
- extrinsic
36
+ (0, _util.compactAddLength)(data)
37
37
  ]
38
38
  ],
39
39
  StatusFor: [
@@ -88,6 +88,12 @@ const dryRunPreimage = async (argv)=>{
88
88
  ]
89
89
  }
90
90
  });
91
+ const newBlockHash = `0x${Math.round(Math.random() * 100000000).toString(16).padEnd(64, '0')}`;
92
+ const newBlock = new _chopstickscore.Block(block.chain, block.number + 1, newBlockHash, block, {
93
+ header,
94
+ extrinsics: [],
95
+ storage: block.storage
96
+ });
91
97
  const calls = [
92
98
  [
93
99
  'Core_initialize_block',
@@ -96,12 +102,17 @@ const dryRunPreimage = async (argv)=>{
96
102
  ]
97
103
  ]
98
104
  ];
99
- for (const inherent of (await block.chain.getInherents())){
105
+ for (const inherentProvider of block.chain.getInherents()){
106
+ const extrinsics = await inherentProvider.createInherents(newBlock, {
107
+ transactions: [],
108
+ downwardMessages: [],
109
+ upwardMessages: [],
110
+ horizontalMessages: {}
111
+ });
112
+ if (extrinsics.length === 0) continue;
100
113
  calls.push([
101
114
  'BlockBuilder_apply_extrinsic',
102
- [
103
- inherent
104
- ]
115
+ extrinsics
105
116
  ]);
106
117
  }
107
118
  calls.push([
@@ -134,6 +134,6 @@ export interface DryRunParams {
134
134
  export declare const rpc: (context: Context, [params]: [DryRunParams]) => Promise<string | [`0x${string}`, `0x${string}` | null][] | {
135
135
  old: {};
136
136
  new: {};
137
- delta: import("jsondiffpatch").Delta | undefined;
137
+ delta: import("jsondiffpatch").Delta;
138
138
  }>;
139
139
  export {};
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "handler", {
11
11
  const _chopstickscore = require("@acala-network/chopsticks-core");
12
12
  const _index = require("../plugins/index.js");
13
13
  const rpcLogger = _chopstickscore.defaultLogger.child({
14
- module: 'rpc'
14
+ name: 'rpc'
15
15
  });
16
16
  const allHandlers = {
17
17
  ..._chopstickscore.substrate,
@@ -121,7 +121,7 @@ const createServer = async (handler, port)=>{
121
121
  result: resp ?? null
122
122
  };
123
123
  } catch (e) {
124
- logger.info('Error handling request: %s %o', e, e.stack);
124
+ logger.info('Error handling request: %o', e.stack);
125
125
  return {
126
126
  id: req.id,
127
127
  jsonrpc: '2.0',
@@ -3,5 +3,5 @@ import { HexString } from '@polkadot/util/types';
3
3
  export declare const decodeStorageDiff: (block: Block, diff: [HexString, HexString | null][]) => Promise<{
4
4
  oldState: {};
5
5
  newState: {};
6
- delta: import("jsondiffpatch").Delta | undefined;
6
+ delta: import("jsondiffpatch").Delta;
7
7
  }>;
@@ -17,7 +17,7 @@ function _interop_require_default(obj) {
17
17
  };
18
18
  }
19
19
  const diffPatcher = (0, _jsondiffpatch.create)({
20
- array: {
20
+ arrays: {
21
21
  detectMove: false
22
22
  },
23
23
  textDiff: {
@@ -1,8 +1,8 @@
1
1
  import { blake2AsHex } from '@polkadot/util-crypto';
2
- import { hexToU8a } from '@polkadot/util';
2
+ import { compactAddLength, hexToU8a } from '@polkadot/util';
3
+ import { Block, newHeader, runTask, setStorage, taskHandler } from '@acala-network/chopsticks-core';
3
4
  import { defaultLogger } from '../../logger.js';
4
5
  import { generateHtmlDiffPreviewFile } from '../../utils/generate-html-diff.js';
5
- import { newHeader, runTask, setStorage, taskHandler } from '@acala-network/chopsticks-core';
6
6
  import { openHtml } from '../../utils/open-html.js';
7
7
  import { setupContext } from '../../context.js';
8
8
  export const dryRunPreimage = async (argv)=>{
@@ -23,7 +23,7 @@ export const dryRunPreimage = async (argv)=>{
23
23
  data.byteLength
24
24
  ]
25
25
  ],
26
- extrinsic
26
+ compactAddLength(data)
27
27
  ]
28
28
  ],
29
29
  StatusFor: [
@@ -78,6 +78,12 @@ export const dryRunPreimage = async (argv)=>{
78
78
  ]
79
79
  }
80
80
  });
81
+ const newBlockHash = `0x${Math.round(Math.random() * 100000000).toString(16).padEnd(64, '0')}`;
82
+ const newBlock = new Block(block.chain, block.number + 1, newBlockHash, block, {
83
+ header,
84
+ extrinsics: [],
85
+ storage: block.storage
86
+ });
81
87
  const calls = [
82
88
  [
83
89
  'Core_initialize_block',
@@ -86,12 +92,17 @@ export const dryRunPreimage = async (argv)=>{
86
92
  ]
87
93
  ]
88
94
  ];
89
- for (const inherent of (await block.chain.getInherents())){
95
+ for (const inherentProvider of block.chain.getInherents()){
96
+ const extrinsics = await inherentProvider.createInherents(newBlock, {
97
+ transactions: [],
98
+ downwardMessages: [],
99
+ upwardMessages: [],
100
+ horizontalMessages: {}
101
+ });
102
+ if (extrinsics.length === 0) continue;
90
103
  calls.push([
91
104
  'BlockBuilder_apply_extrinsic',
92
- [
93
- inherent
94
- ]
105
+ extrinsics
95
106
  ]);
96
107
  }
97
108
  calls.push([
@@ -134,6 +134,6 @@ export interface DryRunParams {
134
134
  export declare const rpc: (context: Context, [params]: [DryRunParams]) => Promise<string | [`0x${string}`, `0x${string}` | null][] | {
135
135
  old: {};
136
136
  new: {};
137
- delta: import("jsondiffpatch").Delta | undefined;
137
+ delta: import("jsondiffpatch").Delta;
138
138
  }>;
139
139
  export {};
@@ -1,7 +1,7 @@
1
1
  import { ResponseError, defaultLogger, substrate } from '@acala-network/chopsticks-core';
2
2
  import { loadRpcPlugin, rpcPluginMethods } from '../plugins/index.js';
3
3
  const rpcLogger = defaultLogger.child({
4
- module: 'rpc'
4
+ name: 'rpc'
5
5
  });
6
6
  const allHandlers = {
7
7
  ...substrate,
@@ -111,7 +111,7 @@ export const createServer = async (handler, port)=>{
111
111
  result: resp ?? null
112
112
  };
113
113
  } catch (e) {
114
- logger.info('Error handling request: %s %o', e, e.stack);
114
+ logger.info('Error handling request: %o', e.stack);
115
115
  return {
116
116
  id: req.id,
117
117
  jsonrpc: '2.0',
@@ -3,5 +3,5 @@ import { HexString } from '@polkadot/util/types';
3
3
  export declare const decodeStorageDiff: (block: Block, diff: [HexString, HexString | null][]) => Promise<{
4
4
  oldState: {};
5
5
  newState: {};
6
- delta: import("jsondiffpatch").Delta | undefined;
6
+ delta: import("jsondiffpatch").Delta;
7
7
  }>;
@@ -2,7 +2,7 @@ import { decodeBlockStorageDiff } from '@acala-network/chopsticks-core';
2
2
  import { create } from 'jsondiffpatch';
3
3
  import _ from 'lodash';
4
4
  const diffPatcher = create({
5
- array: {
5
+ arrays: {
6
6
  detectMove: false
7
7
  },
8
8
  textDiff: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acala-network/chopsticks",
3
- "version": "0.9.7",
3
+ "version": "0.9.8-2",
4
4
  "author": "Acala Developers <hello@acala.network>",
5
5
  "license": "Apache-2.0",
6
6
  "bin": "./chopsticks.cjs",
@@ -13,34 +13,34 @@
13
13
  "docs:prep": "typedoc"
14
14
  },
15
15
  "dependencies": {
16
- "@acala-network/chopsticks-core": "0.9.7",
17
- "@acala-network/chopsticks-db": "0.9.7",
16
+ "@acala-network/chopsticks-core": "0.9.8-2",
17
+ "@acala-network/chopsticks-db": "0.9.8-2",
18
18
  "@pnpm/npm-conf": "^2.2.2",
19
- "@polkadot/api-augment": "^10.10.1",
20
- "@polkadot/types": "^10.10.1",
21
- "@polkadot/util": "^12.5.1",
22
- "@polkadot/util-crypto": "^12.5.1",
23
- "axios": "^1.6.3",
24
- "dotenv": "^16.3.1",
19
+ "@polkadot/api-augment": "^10.11.2",
20
+ "@polkadot/types": "^10.11.2",
21
+ "@polkadot/util": "^12.6.2",
22
+ "@polkadot/util-crypto": "^12.6.2",
23
+ "axios": "^1.6.5",
24
+ "dotenv": "^16.4.0",
25
25
  "global-agent": "^3.0.0",
26
26
  "js-yaml": "^4.1.0",
27
- "jsondiffpatch": "^0.5.0",
27
+ "jsondiffpatch": "^0.6.0",
28
28
  "lodash": "^4.17.21",
29
- "ws": "^8.15.0",
29
+ "ws": "^8.16.0",
30
30
  "yargs": "^17.7.2",
31
31
  "zod": "^3.22.4"
32
32
  },
33
33
  "devDependencies": {
34
- "@swc/cli": "0.1.63",
35
- "@swc/core": "^1.3.100",
34
+ "@swc/cli": "0.1.65",
35
+ "@swc/core": "^1.3.105",
36
36
  "@types/global-agent": "^2.1.3",
37
37
  "@types/js-yaml": "^4.0.9",
38
38
  "@types/lodash": "^4.14.202",
39
- "@types/node": "^20.10.4",
39
+ "@types/node": "^20.11.5",
40
40
  "@types/ws": "^8.5.10",
41
41
  "@types/yargs": "^17.0.32",
42
42
  "typescript": "^5.3.3",
43
- "vitest": "^1.0.4"
43
+ "vitest": "^1.2.1"
44
44
  },
45
45
  "files": [
46
46
  "dist/esm/**",