@acala-network/chopsticks 0.9.1-2 → 0.9.1-4

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 (81) hide show
  1. package/dist/cjs/cli-options.js +30 -15
  2. package/dist/cjs/cli.js +69 -80
  3. package/dist/cjs/context.js +94 -65
  4. package/dist/cjs/index.js +32 -20
  5. package/dist/cjs/logger.js +18 -5
  6. package/dist/cjs/package.json +1 -0
  7. package/dist/cjs/plugins/decode-key/index.js +23 -20
  8. package/dist/cjs/plugins/dry-run/cli.js +46 -41
  9. package/dist/cjs/plugins/dry-run/dry-run-extrinsic.js +37 -21
  10. package/dist/cjs/plugins/dry-run/dry-run-preimage.js +102 -48
  11. package/dist/cjs/plugins/dry-run/index.js +18 -17
  12. package/dist/cjs/plugins/dry-run/rpc.js +48 -74
  13. package/dist/cjs/plugins/follow-chain/index.js +78 -46
  14. package/dist/cjs/plugins/index.js +76 -40
  15. package/dist/cjs/plugins/new-block/index.js +21 -53
  16. package/dist/cjs/plugins/run-block/__snapshots__/index.test.ts.snap +16745 -0
  17. package/dist/cjs/plugins/run-block/index.js +145 -104
  18. package/dist/cjs/plugins/set-block-build-mode/index.js +17 -25
  19. package/dist/cjs/plugins/set-head/index.js +13 -23
  20. package/dist/cjs/plugins/set-runtime-log-level/index.js +16 -23
  21. package/dist/cjs/plugins/set-storage/index.js +16 -35
  22. package/dist/cjs/plugins/time-travel/index.js +13 -23
  23. package/dist/cjs/plugins/try-runtime/index.js +51 -42
  24. package/dist/cjs/plugins/types.js +43 -18
  25. package/dist/cjs/rpc/index.js +30 -21
  26. package/dist/cjs/schema/index.js +77 -48
  27. package/dist/cjs/server.js +89 -65
  28. package/dist/cjs/setup-with-server.js +19 -13
  29. package/dist/cjs/types.js +30 -18
  30. package/dist/cjs/utils/decoder.js +32 -16
  31. package/dist/cjs/utils/generate-html-diff.js +38 -19
  32. package/dist/cjs/utils/index.js +20 -19
  33. package/dist/cjs/utils/open-html.js +12 -6
  34. package/dist/cjs/utils/override.js +40 -27
  35. package/dist/cjs/utils/tunnel.js +11 -14
  36. package/dist/esm/cli-options.js +11 -11
  37. package/dist/esm/cli.js +49 -64
  38. package/dist/esm/context.js +22 -26
  39. package/dist/esm/index.js +2 -2
  40. package/dist/esm/plugins/decode-key/index.js +11 -14
  41. package/dist/esm/plugins/dry-run/cli.js +35 -36
  42. package/dist/esm/plugins/dry-run/dry-run-extrinsic.js +22 -12
  43. package/dist/esm/plugins/dry-run/dry-run-preimage.js +77 -29
  44. package/dist/esm/plugins/dry-run/index.js +2 -2
  45. package/dist/esm/plugins/dry-run/rpc.js +16 -26
  46. package/dist/esm/plugins/follow-chain/index.js +56 -32
  47. package/dist/esm/plugins/index.js +9 -7
  48. package/dist/esm/plugins/new-block/index.js +9 -10
  49. package/dist/esm/plugins/run-block/__snapshots__/index.test.ts.snap +16745 -0
  50. package/dist/esm/plugins/run-block/index.js +101 -69
  51. package/dist/esm/plugins/set-block-build-mode/index.js +5 -4
  52. package/dist/esm/plugins/set-head/index.js +2 -4
  53. package/dist/esm/plugins/set-runtime-log-level/index.js +5 -4
  54. package/dist/esm/plugins/set-storage/index.js +4 -5
  55. package/dist/esm/plugins/time-travel/index.js +2 -4
  56. package/dist/esm/plugins/try-runtime/index.js +37 -34
  57. package/dist/esm/plugins/types.js +8 -8
  58. package/dist/esm/rpc/index.js +19 -16
  59. package/dist/esm/schema/index.js +31 -18
  60. package/dist/esm/server.js +71 -53
  61. package/dist/esm/setup-with-server.js +6 -6
  62. package/dist/esm/types.js +13 -2
  63. package/dist/esm/utils/decoder.js +12 -4
  64. package/dist/esm/utils/generate-html-diff.js +11 -7
  65. package/dist/esm/utils/index.js +4 -4
  66. package/dist/esm/utils/open-html.js +1 -1
  67. package/dist/esm/utils/override.js +12 -14
  68. package/dist/esm/utils/tunnel.js +1 -8
  69. package/dist/types/context.d.ts +2 -2
  70. package/dist/types/index.d.ts +2 -2
  71. package/dist/types/plugins/dry-run/dry-run-extrinsic.d.ts +1 -1
  72. package/dist/types/plugins/dry-run/dry-run-preimage.d.ts +1 -1
  73. package/dist/types/plugins/dry-run/index.d.ts +2 -2
  74. package/dist/types/plugins/run-block/index.d.ts +1 -1
  75. package/dist/types/plugins/types.d.ts +11 -11
  76. package/dist/types/setup-with-server.d.ts +1 -1
  77. package/dist/types/types.d.ts +2 -2
  78. package/dist/types/utils/index.d.ts +4 -4
  79. package/package.json +17 -21
  80. package/dist/esm/package.json +0 -1
  81. /package/{chopsticks.js → chopsticks.cjs} +0 -0
@@ -1,91 +1,115 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rpc = exports.name = exports.cli = void 0;
4
- const util_1 = require("@polkadot/util");
5
- const node_fs_1 = require("node:fs");
6
- const zod_1 = require("zod");
7
- const chopsticks_core_1 = require("@acala-network/chopsticks-core");
8
- const cli_options_1 = require("../../cli-options");
9
- const generate_html_diff_1 = require("../../utils/generate-html-diff");
10
- const open_html_1 = require("../../utils/open-html");
11
- const context_1 = require("../../context");
12
- const cli = (y) => {
13
- y.command('run-block', 'Replay a block', (yargs) => yargs.options({
14
- ...cli_options_1.defaultOptions,
15
- ...cli_options_1.mockOptions,
16
- 'output-path': {
17
- desc: 'File path to print output',
18
- string: true,
19
- },
20
- html: {
21
- desc: 'Generate html with storage diff',
22
- },
23
- open: {
24
- desc: 'Open generated html',
25
- },
26
- }), async (argv) => {
27
- const context = await (0, context_1.setupContext)(argv, true);
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ cli: function() {
13
+ return cli;
14
+ },
15
+ name: function() {
16
+ return name;
17
+ },
18
+ rpc: function() {
19
+ return rpc;
20
+ }
21
+ });
22
+ const _util = require("@polkadot/util");
23
+ const _nodefs = require("node:fs");
24
+ const _zod = require("zod");
25
+ const _chopstickscore = require("@acala-network/chopsticks-core");
26
+ const _clioptions = require("../../cli-options.js");
27
+ const _generatehtmldiff = require("../../utils/generate-html-diff.js");
28
+ const _openhtml = require("../../utils/open-html.js");
29
+ const _context = require("../../context.js");
30
+ const cli = (y)=>{
31
+ y.command('run-block', 'Replay a block', (yargs)=>yargs.options({
32
+ ..._clioptions.defaultOptions,
33
+ ..._clioptions.mockOptions,
34
+ 'output-path': {
35
+ desc: 'File path to print output',
36
+ string: true
37
+ },
38
+ html: {
39
+ desc: 'Generate html with storage diff'
40
+ },
41
+ open: {
42
+ desc: 'Open generated html'
43
+ }
44
+ }), async (argv)=>{
45
+ const context = await (0, _context.setupContext)(argv, true);
28
46
  const header = await context.chain.head.header;
29
47
  const block = context.chain.head;
30
48
  const parent = await block.parentBlock;
31
- if (!parent)
32
- throw Error('cant find parent block');
49
+ if (!parent) throw Error('cant find parent block');
33
50
  const wasm = await parent.wasm;
34
- const calls = [['Core_initialize_block', [header.toHex()]]];
35
- for (const extrinsic of await block.extrinsics) {
36
- calls.push(['BlockBuilder_apply_extrinsic', [extrinsic]]);
51
+ const calls = [
52
+ [
53
+ 'Core_initialize_block',
54
+ [
55
+ header.toHex()
56
+ ]
57
+ ]
58
+ ];
59
+ for (const extrinsic of (await block.extrinsics)){
60
+ calls.push([
61
+ 'BlockBuilder_apply_extrinsic',
62
+ [
63
+ extrinsic
64
+ ]
65
+ ]);
37
66
  }
38
- calls.push(['BlockBuilder_finalize_block', []]);
39
- const result = await (0, chopsticks_core_1.runTask)({
67
+ calls.push([
68
+ 'BlockBuilder_finalize_block',
69
+ []
70
+ ]);
71
+ const result = await (0, _chopstickscore.runTask)({
40
72
  wasm,
41
73
  calls,
42
74
  mockSignatureHost: false,
43
75
  allowUnresolvedImports: false,
44
- runtimeLogLevel: argv.runtimeLogLevel || 0,
45
- }, (0, chopsticks_core_1.taskHandler)(parent));
76
+ runtimeLogLevel: argv.runtimeLogLevel || 0
77
+ }, (0, _chopstickscore.taskHandler)(parent));
46
78
  if ('Error' in result) {
47
79
  throw new Error(result.Error);
48
80
  }
49
- (0, chopsticks_core_1.printRuntimeLogs)(result.Call.runtimeLogs);
81
+ (0, _chopstickscore.printRuntimeLogs)(result.Call.runtimeLogs);
50
82
  if (argv.html) {
51
- const filePath = await (0, generate_html_diff_1.generateHtmlDiffPreviewFile)(parent, result.Call.storageDiff, block.hash);
83
+ const filePath = await (0, _generatehtmldiff.generateHtmlDiffPreviewFile)(parent, result.Call.storageDiff, block.hash);
52
84
  console.log(`Generated preview ${filePath}`);
53
85
  if (argv.open) {
54
- (0, open_html_1.openHtml)(filePath);
86
+ (0, _openhtml.openHtml)(filePath);
55
87
  }
56
- }
57
- else if (argv.outputPath) {
58
- (0, node_fs_1.writeFileSync)(argv.outputPath, JSON.stringify(result, null, 2));
59
- }
60
- else {
61
- console.dir(result, { depth: null, colors: false });
88
+ } else if (argv.outputPath) {
89
+ (0, _nodefs.writeFileSync)(argv.outputPath, JSON.stringify(result, null, 2));
90
+ } else {
91
+ console.dir(result, {
92
+ depth: null,
93
+ colors: false
94
+ });
62
95
  }
63
96
  process.exit(0);
64
97
  });
65
98
  };
66
- exports.cli = cli;
67
- const zHex = zod_1.z.custom((val) => /^0x\w+$/.test(val));
68
- const zHash = zod_1.z.string().length(66).and(zHex);
69
- const schema = zod_1.z.object({
70
- includeRaw: zod_1.z.boolean().optional(),
71
- includeParsed: zod_1.z.boolean().optional(),
72
- includeBlockDetails: zod_1.z.boolean().optional(),
99
+ const zHex = _zod.z.custom((val)=>/^0x\w+$/.test(val));
100
+ const zHash = _zod.z.string().length(66).and(zHex);
101
+ const schema = _zod.z.object({
102
+ includeRaw: _zod.z.boolean().optional(),
103
+ includeParsed: _zod.z.boolean().optional(),
104
+ includeBlockDetails: _zod.z.boolean().optional(),
73
105
  parent: zHash.optional(),
74
- block: zod_1.z.object({
75
- header: zod_1.z.any(),
76
- extrinsics: zod_1.z.array(zHex),
77
- }),
106
+ block: _zod.z.object({
107
+ header: _zod.z.any(),
108
+ extrinsics: _zod.z.array(zHex)
109
+ })
78
110
  });
79
- exports.name = 'runBlock';
80
- /**
81
- * Run a set of extrinsics on top of a block and get the storage diff
82
- * and optionally the parsed storage diff and block details.
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.
85
- *
86
- * This function is a dev rpc handler. Use `dev_runBlock` as the method name when calling it.
87
- */
88
- const rpc = async ({ chain }, [params]) => {
111
+ const name = 'runBlock';
112
+ const rpc = async ({ chain }, [params])=>{
89
113
  const { includeRaw, includeParsed, includeBlockDetails, parent, block } = schema.parse(params);
90
114
  const includeRawStorage = includeRaw ?? true;
91
115
  const parentBlock = await chain.getBlock(parent);
@@ -97,36 +121,41 @@ const rpc = async ({ chain }, [params]) => {
97
121
  const wasm = await parentBlock.wasm;
98
122
  const meta = await parentBlock.meta;
99
123
  const blockNumber = parentBlock.number + 1;
100
- const hash = `0x${Math.round(Math.random() * 100000000)
101
- .toString(16)
102
- .padEnd(64, '0')}`;
103
- const newBlock = new chopsticks_core_1.Block(chain, blockNumber, hash, parentBlock, {
124
+ const hash = `0x${Math.round(Math.random() * 100000000).toString(16).padEnd(64, '0')}`;
125
+ const newBlock = new _chopstickscore.Block(chain, blockNumber, hash, parentBlock, {
104
126
  header,
105
127
  extrinsics: [],
106
- storage: parentBlock.storage,
128
+ storage: parentBlock.storage
107
129
  });
108
130
  const resp = {
109
- phases: [],
131
+ phases: []
110
132
  };
111
133
  // exclude system events because it can be stupidly large and redudant
112
- const systemEventsKey = (0, chopsticks_core_1.compactHex)(meta.query.system.events());
134
+ const systemEventsKey = (0, _chopstickscore.compactHex)(meta.query.system.events());
113
135
  // large and not really useful
114
- const systemExtrinsicDataKey = (0, util_1.u8aToHex)(meta.query.system.extrinsicData.keyPrefix());
115
- const run = async (fn, args) => {
116
- const result = await (0, chopsticks_core_1.runTask)({
136
+ const systemExtrinsicDataKey = (0, _util.u8aToHex)(meta.query.system.extrinsicData.keyPrefix());
137
+ const run = async (fn, args)=>{
138
+ const result = await (0, _chopstickscore.runTask)({
117
139
  wasm,
118
- calls: [[fn, args]],
140
+ calls: [
141
+ [
142
+ fn,
143
+ args
144
+ ]
145
+ ],
119
146
  mockSignatureHost: false,
120
147
  allowUnresolvedImports: false,
121
- runtimeLogLevel: 5,
122
- }, (0, chopsticks_core_1.taskHandler)(newBlock));
148
+ runtimeLogLevel: 5
149
+ }, (0, _chopstickscore.taskHandler)(newBlock));
123
150
  if ('Error' in result) {
124
151
  throw new Error(result.Error);
125
152
  }
126
- const resp = { storageDiff: [] };
153
+ const resp = {
154
+ storageDiff: []
155
+ };
127
156
  const raw = result.Call.storageDiff;
128
157
  newBlock.pushStorageLayer().setAll(raw);
129
- for (const [key, value] of raw) {
158
+ for (const [key, value] of raw){
130
159
  if (key === systemEventsKey) {
131
160
  continue;
132
161
  }
@@ -135,16 +164,19 @@ const rpc = async ({ chain }, [params]) => {
135
164
  }
136
165
  const obj = {};
137
166
  if (includeRawStorage) {
138
- obj.raw = { key, value };
167
+ obj.raw = {
168
+ key,
169
+ value
170
+ };
139
171
  }
140
172
  if (includeParsed) {
141
- const decoded = (0, chopsticks_core_1.decodeKeyValue)(await newBlock.meta, newBlock, key, value, false);
173
+ const decoded = (0, _chopstickscore.decodeKeyValue)(await newBlock.meta, newBlock, key, value, false);
142
174
  if (decoded) {
143
175
  obj.parsed = {
144
176
  section: decoded.section,
145
177
  method: decoded.method,
146
178
  key: decoded.key,
147
- value: decoded.value,
179
+ value: decoded.value
148
180
  };
149
181
  }
150
182
  }
@@ -153,44 +185,53 @@ const rpc = async ({ chain }, [params]) => {
153
185
  resp.logs = result.Call.runtimeLogs;
154
186
  return resp;
155
187
  };
156
- const resInit = await run('Core_initialize_block', [header.toHex()]);
157
- resp.phases.push({ phase: 'Initialization', ...resInit });
158
- for (const extrinsic of block.extrinsics) {
159
- const res = await run('BlockBuilder_apply_extrinsic', [extrinsic]);
160
- resp.phases.push({ phase: resp.phases.length - 1, ...res });
188
+ const resInit = await run('Core_initialize_block', [
189
+ header.toHex()
190
+ ]);
191
+ resp.phases.push({
192
+ phase: 'Initialization',
193
+ ...resInit
194
+ });
195
+ for (const extrinsic of block.extrinsics){
196
+ const res = await run('BlockBuilder_apply_extrinsic', [
197
+ extrinsic
198
+ ]);
199
+ resp.phases.push({
200
+ phase: resp.phases.length - 1,
201
+ ...res
202
+ });
161
203
  }
162
204
  const resFinalize = await run('BlockBuilder_finalize_block', []);
163
- resp.phases.push({ phase: 'Finalization', ...resFinalize });
205
+ resp.phases.push({
206
+ phase: 'Finalization',
207
+ ...resFinalize
208
+ });
164
209
  if (includeBlockDetails) {
165
210
  const meta = await newBlock.meta;
166
211
  const registry = await newBlock.registry;
167
212
  const timestamp = await newBlock.read('u64', meta.query.timestamp.now);
168
213
  const events = await newBlock.read('Vec<EventRecord>', meta.query.system.events);
169
- const parsedEvents = events?.map((event) => ({
170
- phase: event.phase.isApplyExtrinsic ? event.phase.asApplyExtrinsic.toNumber() : event.phase.toString(),
171
- section: event.event.section,
172
- method: event.event.method,
173
- args: event.event.data.map((arg) => arg.toJSON()),
174
- }));
175
- const extrinsics = block.extrinsics.map((extrinsic, idx) => {
214
+ const parsedEvents = events?.map((event)=>({
215
+ phase: event.phase.isApplyExtrinsic ? event.phase.asApplyExtrinsic.toNumber() : event.phase.toString(),
216
+ section: event.event.section,
217
+ method: event.event.method,
218
+ args: event.event.data.map((arg)=>arg.toJSON())
219
+ }));
220
+ const extrinsics = block.extrinsics.map((extrinsic, idx)=>{
176
221
  const parsed = registry.createType('GenericExtrinsic', extrinsic);
177
- const resultEvent = events?.find(({ event, phase }) => event.section === 'system' &&
178
- (event.method === 'ExtrinsicSuccess' || event.method === 'ExtrinsicFailed') &&
179
- phase.isApplyExtrinsic &&
180
- phase.asApplyExtrinsic.eq(idx));
222
+ const resultEvent = events?.find(({ event, phase })=>event.section === 'system' && (event.method === 'ExtrinsicSuccess' || event.method === 'ExtrinsicFailed') && phase.isApplyExtrinsic && phase.asApplyExtrinsic.eq(idx));
181
223
  return {
182
224
  section: parsed.method.section,
183
225
  method: parsed.method.method,
184
- args: parsed.method.args.map((arg) => arg.toJSON()),
185
- success: resultEvent?.event.method === 'ExtrinsicSuccess',
226
+ args: parsed.method.args.map((arg)=>arg.toJSON()),
227
+ success: resultEvent?.event.method === 'ExtrinsicSuccess'
186
228
  };
187
229
  });
188
230
  resp.blockDetails = {
189
231
  timestamp: timestamp?.toString(),
190
232
  events: parsedEvents,
191
- extrinsics,
233
+ extrinsics
192
234
  };
193
235
  }
194
236
  return resp;
195
237
  };
196
- exports.rpc = rpc;
@@ -1,29 +1,21 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rpc = void 0;
4
- const chopsticks_core_1 = require("@acala-network/chopsticks-core");
5
- const logger_1 = require("../../logger");
6
- /**
7
- * Set a build block mode. See [BuildBlockMode](../core/enums/BuildBlockMode).
8
- *
9
- * This function is a dev rpc handler. Use `dev_setBlockBuildMode` as the method name when calling it.
10
- *
11
- * @param context - The context object of the rpc handler
12
- * @param params - The parameters of the rpc handler
13
- *
14
- * @example Set build block mode to instant
15
- * ```ts
16
- * import { WsProvider } from '@polkadot/rpc-provider'
17
- * import { BuildBlockMode } from '@acala-network/chopsticks-core'
18
- * const ws = new WsProvider(`ws://localhost:8000`)
19
- * await ws.send('dev_setBlockBuildMode', [BuildBlockMode.Instant])
20
- * ```
21
- */
22
- const rpc = async (context, [mode]) => {
23
- logger_1.defaultLogger.debug({ mode }, 'dev_setBlockBuildMode');
24
- if (chopsticks_core_1.BuildBlockMode[mode] === undefined) {
25
- throw new chopsticks_core_1.ResponseError(1, `Invalid mode ${mode}`);
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "rpc", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return rpc;
9
+ }
10
+ });
11
+ const _chopstickscore = require("@acala-network/chopsticks-core");
12
+ const _logger = require("../../logger.js");
13
+ const rpc = async (context, [mode])=>{
14
+ _logger.defaultLogger.debug({
15
+ mode
16
+ }, 'dev_setBlockBuildMode');
17
+ if (_chopstickscore.BuildBlockMode[mode] === undefined) {
18
+ throw new _chopstickscore.ResponseError(1, `Invalid mode ${mode}`);
26
19
  }
27
20
  context.chain.txPool.mode = mode;
28
21
  };
29
- exports.rpc = rpc;
@@ -1,35 +1,25 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rpc = void 0;
4
- const chopsticks_core_1 = require("@acala-network/chopsticks-core");
5
- /**
6
- * Set head.
7
- *
8
- * This function is a dev rpc handler. Use `dev_setHead` as the method name when calling it.
9
- *
10
- * @param context - The context object of the rpc handler
11
- * @param hashOrNumber - The block hash or number to set as head
12
- *
13
- * @example Set head to block 1000000
14
- * ```ts
15
- * import { WsProvider } from '@polkadot/rpc-provider'
16
- * const ws = new WsProvider(`ws://localhost:8000`)
17
- * await ws.send('dev_setHead', [1000000])
18
- * ```
19
- */
20
- const rpc = async (context, [hashOrNumber]) => {
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "rpc", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return rpc;
9
+ }
10
+ });
11
+ const _chopstickscore = require("@acala-network/chopsticks-core");
12
+ const rpc = async (context, [hashOrNumber])=>{
21
13
  let block;
22
14
  if (typeof hashOrNumber === 'number') {
23
15
  const blockNumber = hashOrNumber > 0 ? hashOrNumber : context.chain.head.number + hashOrNumber;
24
16
  block = await context.chain.getBlockAt(blockNumber);
25
- }
26
- else {
17
+ } else {
27
18
  block = await context.chain.getBlock(hashOrNumber);
28
19
  }
29
20
  if (!block) {
30
- throw new chopsticks_core_1.ResponseError(1, `Block not found ${hashOrNumber}`);
21
+ throw new _chopstickscore.ResponseError(1, `Block not found ${hashOrNumber}`);
31
22
  }
32
23
  await context.chain.setHead(block);
33
24
  return block.hash;
34
25
  };
35
- exports.rpc = rpc;
@@ -1,28 +1,21 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rpc = void 0;
4
- const chopsticks_core_1 = require("@acala-network/chopsticks-core");
5
- const logger_1 = require("../../logger");
6
- /**
7
- * Set runtime log level.
8
- *
9
- * This function is a dev rpc handler. Use `dev_setRuntimeLogLevel` as the method name when calling it.
10
- *
11
- * @param context - The context object of the rpc handler
12
- * @param runtimeLogLevel - The runtime log level to set
13
- *
14
- * @example Set runtime log level to 1
15
- * ```ts
16
- * import { WsProvider } from '@polkadot/rpc-provider'
17
- * const ws = new WsProvider(`ws://localhost:8000`)
18
- * await ws.send('dev_setRuntimeLogLevel', [1])
19
- * ```
20
- */
21
- const rpc = async (context, [runtimeLogLevel]) => {
22
- logger_1.defaultLogger.debug({ runtimeLogLevel }, 'dev_setRuntimeLogLevel');
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "rpc", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return rpc;
9
+ }
10
+ });
11
+ const _chopstickscore = require("@acala-network/chopsticks-core");
12
+ const _logger = require("../../logger.js");
13
+ const rpc = async (context, [runtimeLogLevel])=>{
14
+ _logger.defaultLogger.debug({
15
+ runtimeLogLevel
16
+ }, 'dev_setRuntimeLogLevel');
23
17
  if (typeof runtimeLogLevel !== 'number') {
24
- throw new chopsticks_core_1.ResponseError(1, `Invalid runtimeLogLevel ${runtimeLogLevel}`);
18
+ throw new _chopstickscore.ResponseError(1, `Invalid runtimeLogLevel ${runtimeLogLevel}`);
25
19
  }
26
20
  context.chain.runtimeLogLevel = runtimeLogLevel;
27
21
  };
28
- exports.rpc = rpc;
@@ -1,42 +1,23 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rpc = void 0;
4
- const chopsticks_core_1 = require("@acala-network/chopsticks-core");
5
- const logger_1 = require("../../logger");
6
- /**
7
- * Set storage values.
8
- *
9
- * This function is a dev rpc handler. Use `dev_setStorage` as the method name when calling it.
10
- *
11
- * @param context - The context object of the rpc handler
12
- * @param params - The parameters of the rpc handler
13
- *
14
- * @example
15
- * ```ts
16
- * import { WsProvider } from '@polkadot/rpc-provider'
17
- * import { Keyring } from '@polkadot/keyring'
18
- *
19
- * const ws = new WsProvider(`ws://localhost:8000`)
20
- * const keyring = new Keyring({ type: 'ed25519' })
21
- * const bob = keyring.addFromUri('//Bob')
22
- *
23
- * const storage = {
24
- * System: {
25
- * Account: [[[bob.address], { data: { free: 100000 }, nonce: 1 }]],
26
- * },
27
- * }
28
- * await ws.send('dev_setStorage', [storage])
29
- * ```
30
- */
31
- const rpc = async (context, params) => {
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "rpc", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return rpc;
9
+ }
10
+ });
11
+ const _chopstickscore = require("@acala-network/chopsticks-core");
12
+ const _logger = require("../../logger.js");
13
+ const rpc = async (context, params)=>{
32
14
  const [values, blockHash] = params;
33
- const hash = await (0, chopsticks_core_1.setStorage)(context.chain, values, blockHash).catch((error) => {
34
- throw new chopsticks_core_1.ResponseError(1, error.toString());
15
+ const hash = await (0, _chopstickscore.setStorage)(context.chain, values, blockHash).catch((error)=>{
16
+ throw new _chopstickscore.ResponseError(1, error.toString());
35
17
  });
36
- logger_1.defaultLogger.debug({
18
+ _logger.defaultLogger.debug({
37
19
  hash,
38
- values,
20
+ values
39
21
  }, 'dev_setStorage');
40
22
  return hash;
41
23
  };
42
- exports.rpc = rpc;
@@ -1,27 +1,17 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rpc = void 0;
4
- const chopsticks_core_1 = require("@acala-network/chopsticks-core");
5
- /**
6
- * Travel to a specific time.
7
- *
8
- * This function is a dev rpc handler. Use `dev_timeTravel` as the method name when calling it.
9
- *
10
- * @param context - The context object of the rpc handler
11
- * @param date - Timestamp or date string to set
12
- *
13
- * @example
14
- * ```ts
15
- * import { WsProvider } from '@polkadot/rpc-provider'
16
- * const ws = new WsProvider(`ws://localhost:8000`)
17
- * await ws.send('dev_timeTravel', ['Jan 1, 2023'])
18
- * ```
19
- */
20
- const rpc = async (context, [date]) => {
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "rpc", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return rpc;
9
+ }
10
+ });
11
+ const _chopstickscore = require("@acala-network/chopsticks-core");
12
+ const rpc = async (context, [date])=>{
21
13
  const timestamp = typeof date === 'string' ? Date.parse(date) : date;
22
- if (Number.isNaN(timestamp))
23
- throw new chopsticks_core_1.ResponseError(1, 'Invalid date');
24
- await (0, chopsticks_core_1.timeTravel)(context.chain, timestamp);
14
+ if (Number.isNaN(timestamp)) throw new _chopstickscore.ResponseError(1, 'Invalid date');
15
+ await (0, _chopstickscore.timeTravel)(context.chain, timestamp);
25
16
  return timestamp;
26
17
  };
27
- exports.rpc = rpc;