@acala-network/chopsticks 0.9.1-1 → 0.9.1-3

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 (72) 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 +93 -64
  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 +101 -47
  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 +107 -0
  14. package/dist/cjs/plugins/index.js +89 -39
  15. package/dist/cjs/plugins/new-block/index.js +21 -53
  16. package/dist/cjs/plugins/run-block/index.js +145 -104
  17. package/dist/cjs/plugins/set-block-build-mode/index.js +17 -25
  18. package/dist/cjs/plugins/set-head/index.js +13 -23
  19. package/dist/cjs/plugins/set-runtime-log-level/index.js +16 -23
  20. package/dist/cjs/plugins/set-storage/index.js +16 -35
  21. package/dist/cjs/plugins/time-travel/index.js +13 -23
  22. package/dist/cjs/plugins/try-runtime/index.js +51 -42
  23. package/dist/cjs/plugins/types.js +43 -18
  24. package/dist/cjs/rpc/index.js +30 -21
  25. package/dist/cjs/schema/index.js +77 -48
  26. package/dist/cjs/server.js +89 -65
  27. package/dist/cjs/setup-with-server.js +19 -13
  28. package/dist/cjs/types.js +30 -18
  29. package/dist/cjs/utils/decoder.js +32 -16
  30. package/dist/cjs/utils/generate-html-diff.js +38 -19
  31. package/dist/cjs/utils/index.js +20 -19
  32. package/dist/cjs/utils/open-html.js +12 -6
  33. package/dist/cjs/utils/override.js +40 -27
  34. package/dist/cjs/utils/tunnel.js +11 -14
  35. package/dist/esm/cli-options.js +11 -11
  36. package/dist/esm/cli.js +45 -60
  37. package/dist/esm/context.js +20 -24
  38. package/dist/esm/plugins/decode-key/index.js +9 -12
  39. package/dist/esm/plugins/dry-run/cli.js +32 -33
  40. package/dist/esm/plugins/dry-run/dry-run-extrinsic.js +18 -8
  41. package/dist/esm/plugins/dry-run/dry-run-preimage.js +72 -24
  42. package/dist/esm/plugins/dry-run/rpc.js +14 -24
  43. package/dist/esm/plugins/follow-chain/index.js +92 -0
  44. package/dist/esm/plugins/index.js +22 -9
  45. package/dist/esm/plugins/new-block/index.js +8 -9
  46. package/dist/esm/plugins/run-block/index.js +97 -65
  47. package/dist/esm/plugins/set-block-build-mode/index.js +4 -3
  48. package/dist/esm/plugins/set-head/index.js +2 -4
  49. package/dist/esm/plugins/set-runtime-log-level/index.js +4 -3
  50. package/dist/esm/plugins/set-storage/index.js +3 -4
  51. package/dist/esm/plugins/time-travel/index.js +2 -4
  52. package/dist/esm/plugins/try-runtime/index.js +33 -30
  53. package/dist/esm/rpc/index.js +18 -15
  54. package/dist/esm/schema/index.js +31 -18
  55. package/dist/esm/server.js +70 -52
  56. package/dist/esm/setup-with-server.js +3 -3
  57. package/dist/esm/types.js +12 -1
  58. package/dist/esm/utils/decoder.js +12 -4
  59. package/dist/esm/utils/generate-html-diff.js +11 -7
  60. package/dist/esm/utils/open-html.js +1 -1
  61. package/dist/esm/utils/override.js +11 -13
  62. package/dist/esm/utils/template/diff.html +304 -0
  63. package/dist/esm/utils/tunnel.js +1 -8
  64. package/dist/types/plugins/decode-key/index.d.ts +2 -2
  65. package/dist/types/plugins/dry-run/cli.d.ts +2 -2
  66. package/dist/types/plugins/follow-chain/index.d.ts +2 -0
  67. package/dist/types/plugins/index.d.ts +2 -2
  68. package/dist/types/plugins/run-block/index.d.ts +2 -2
  69. package/dist/types/plugins/try-runtime/index.d.ts +2 -2
  70. package/package.json +14 -17
  71. /package/{chopsticks.js → chopsticks.cjs} +0 -0
  72. /package/{template → dist/cjs/utils/template}/diff.html +0 -0
@@ -1,43 +1,60 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createServer = void 0;
4
- const ws_1 = require("ws");
5
- const chopsticks_core_1 = require("@acala-network/chopsticks-core");
6
- const zod_1 = require("zod");
7
- const logger_1 = require("./logger");
8
- const logger = logger_1.defaultLogger.child({ name: 'ws' });
9
- const singleRequest = zod_1.z.object({
10
- id: zod_1.z.number(),
11
- jsonrpc: zod_1.z.literal('2.0'),
12
- method: zod_1.z.string(),
13
- params: zod_1.z.array(zod_1.z.any()).default([]),
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
14
4
  });
15
- const batchRequest = zod_1.z.array(singleRequest);
16
- const requestSchema = zod_1.z.union([singleRequest, batchRequest]);
17
- const parseRequest = (request) => {
5
+ Object.defineProperty(exports, "createServer", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return createServer;
9
+ }
10
+ });
11
+ const _ws = require("ws");
12
+ const _chopstickscore = require("@acala-network/chopsticks-core");
13
+ const _zod = require("zod");
14
+ const _logger = require("./logger");
15
+ const logger = _logger.defaultLogger.child({
16
+ name: 'ws'
17
+ });
18
+ const singleRequest = _zod.z.object({
19
+ id: _zod.z.number(),
20
+ jsonrpc: _zod.z.literal('2.0'),
21
+ method: _zod.z.string(),
22
+ params: _zod.z.array(_zod.z.any()).default([])
23
+ });
24
+ const batchRequest = _zod.z.array(singleRequest);
25
+ const requestSchema = _zod.z.union([
26
+ singleRequest,
27
+ batchRequest
28
+ ]);
29
+ const parseRequest = (request)=>{
18
30
  try {
19
31
  return JSON.parse(request);
20
- }
21
- catch (e) {
32
+ } catch (e) {
22
33
  return undefined;
23
34
  }
24
35
  };
25
- const createWS = async (port) => {
26
- const wss = new ws_1.WebSocketServer({ port, maxPayload: 1024 * 1024 * 100 });
27
- const promise = new Promise((resolve) => {
28
- wss.on('listening', () => {
29
- resolve([wss, wss.address().port]);
36
+ const createWS = async (port)=>{
37
+ const wss = new _ws.WebSocketServer({
38
+ port,
39
+ maxPayload: 1024 * 1024 * 100
40
+ });
41
+ const promise = new Promise((resolve)=>{
42
+ wss.on('listening', ()=>{
43
+ resolve([
44
+ wss,
45
+ wss.address().port
46
+ ]);
30
47
  });
31
- wss.on('error', (_) => {
48
+ wss.on('error', (_)=>{
32
49
  resolve([]);
33
50
  });
34
51
  });
35
52
  return promise;
36
53
  };
37
- const createServer = async (handler, port) => {
54
+ const createServer = async (handler, port)=>{
38
55
  let wss;
39
56
  let listenPort;
40
- for (let i = 0; i < 10; i++) {
57
+ for(let i = 0; i < 10; i++){
41
58
  const preferPort = (port ?? 0) > 0 ? (port ?? 0) + i : 0;
42
59
  logger.debug('Try starting on port %d', preferPort);
43
60
  const [maybeWss, maybeListenPort] = await createWS(preferPort);
@@ -50,80 +67,86 @@ const createServer = async (handler, port) => {
50
67
  if (!wss || !listenPort) {
51
68
  throw new Error(`Failed to create WebsocketServer at port ${port}`);
52
69
  }
53
- wss.on('connection', (ws) => {
70
+ wss.on('connection', (ws)=>{
54
71
  logger.debug('New connection');
55
- const send = (data) => {
56
- if (ws.readyState === ws_1.WebSocket.OPEN) {
72
+ const send = (data)=>{
73
+ if (ws.readyState === _ws.WebSocket.OPEN) {
57
74
  ws.send(JSON.stringify(data));
58
75
  }
59
76
  };
60
77
  const subscriptions = {};
61
78
  const subscriptionManager = {
62
- subscribe: (method, subid, onCancel = () => { }) => {
79
+ subscribe: (method, subid, onCancel = ()=>{})=>{
63
80
  subscriptions[subid] = onCancel;
64
- return (data) => {
81
+ return (data)=>{
65
82
  if (subscriptions[subid]) {
66
- logger.trace({ method, subid, data: (0, logger_1.truncate)(data) }, 'Subscription notification');
83
+ logger.trace({
84
+ method,
85
+ subid,
86
+ data: (0, _logger.truncate)(data)
87
+ }, 'Subscription notification');
67
88
  send({
68
89
  jsonrpc: '2.0',
69
90
  method,
70
91
  params: {
71
92
  result: data,
72
- subscription: subid,
73
- },
93
+ subscription: subid
94
+ }
74
95
  });
75
96
  }
76
97
  };
77
98
  },
78
- unsubscribe: (subid) => {
99
+ unsubscribe: (subid)=>{
79
100
  if (subscriptions[subid]) {
80
101
  subscriptions[subid](subid);
81
102
  delete subscriptions[subid];
82
103
  }
83
- },
104
+ }
84
105
  };
85
- const processRequest = async (req) => {
106
+ const processRequest = async (req)=>{
86
107
  logger.trace({
87
108
  id: req.id,
88
- method: req.method,
109
+ method: req.method
89
110
  }, 'Received message');
90
111
  try {
91
112
  const resp = await handler(req, subscriptionManager);
92
113
  logger.trace({
93
114
  id: req.id,
94
115
  method: req.method,
95
- result: (0, logger_1.truncate)(resp),
116
+ result: (0, _logger.truncate)(resp)
96
117
  }, 'Response for request');
97
118
  return {
98
119
  id: req.id,
99
120
  jsonrpc: '2.0',
100
- result: resp ?? null,
121
+ result: resp ?? null
101
122
  };
102
- }
103
- catch (e) {
123
+ } catch (e) {
104
124
  logger.info('Error handling request: %s %o', e, e.stack);
105
125
  return {
106
126
  id: req.id,
107
127
  jsonrpc: '2.0',
108
- error: e instanceof chopsticks_core_1.ResponseError ? e : { code: -32603, message: `Internal ${e}` },
128
+ error: e instanceof _chopstickscore.ResponseError ? e : {
129
+ code: -32603,
130
+ message: `Internal ${e}`
131
+ }
109
132
  };
110
133
  }
111
134
  };
112
- ws.on('close', () => {
135
+ ws.on('close', ()=>{
113
136
  logger.debug('Connection closed');
114
- for (const [subid, onCancel] of Object.entries(subscriptions)) {
137
+ for (const [subid, onCancel] of Object.entries(subscriptions)){
115
138
  onCancel(subid);
116
139
  }
117
140
  ws.removeAllListeners();
118
141
  });
119
- ws.on('error', () => {
142
+ ws.on('error', ()=>{
120
143
  logger.debug('Connection error');
121
- for (const [subid, onCancel] of Object.entries(subscriptions)) {
144
+ for (const [subid, onCancel] of Object.entries(subscriptions)){
122
145
  onCancel(subid);
123
146
  }
124
147
  ws.removeAllListeners();
125
148
  });
126
- ws.on('message', async (message) => {
149
+ ws.on('message', async (message)=>{
127
150
  const parsed = await requestSchema.safeParseAsync(parseRequest(message.toString()));
128
151
  if (!parsed.success) {
129
152
  logger.info('Invalid request: %s', message);
@@ -132,19 +155,22 @@ const createServer = async (handler, port) => {
132
155
  jsonrpc: '2.0',
133
156
  error: {
134
157
  code: -32600,
135
- message: 'Invalid JSON Request',
136
- },
158
+ message: 'Invalid JSON Request'
159
+ }
137
160
  });
138
161
  return;
139
162
  }
140
163
  const { data: req } = parsed;
141
164
  if (Array.isArray(req)) {
142
- logger.trace({ req }, 'Received batch request');
165
+ logger.trace({
166
+ req
167
+ }, 'Received batch request');
143
168
  const resp = await Promise.all(req.map(processRequest));
144
169
  send(resp);
145
- }
146
- else {
147
- logger.trace({ req }, 'Received single request');
170
+ } else {
171
+ logger.trace({
172
+ req
173
+ }, 'Received single request');
148
174
  const resp = await processRequest(req);
149
175
  send(resp);
150
176
  }
@@ -152,17 +178,15 @@ const createServer = async (handler, port) => {
152
178
  });
153
179
  return {
154
180
  port: listenPort,
155
- close: () => new Promise((resolve, reject) => {
156
- wss?.clients.forEach((socket) => socket.close());
157
- wss?.close((err) => {
158
- if (err) {
159
- reject(err);
160
- }
161
- else {
162
- resolve();
163
- }
164
- });
165
- }),
181
+ close: ()=>new Promise((resolve, reject)=>{
182
+ wss?.clients.forEach((socket)=>socket.close());
183
+ wss?.close((err)=>{
184
+ if (err) {
185
+ reject(err);
186
+ } else {
187
+ resolve();
188
+ }
189
+ });
190
+ })
166
191
  };
167
192
  };
168
- exports.createServer = createServer;
@@ -1,26 +1,32 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setupWithServer = void 0;
4
- const server_1 = require("./server");
5
- const rpc_1 = require("./rpc");
6
- const chopsticks_core_1 = require("@acala-network/chopsticks-core");
7
- const context_1 = require("./context");
8
- const setupWithServer = async (argv) => {
9
- const context = await (0, context_1.setupContext)(argv);
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "setupWithServer", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return setupWithServer;
9
+ }
10
+ });
11
+ const _server = require("./server");
12
+ const _rpc = require("./rpc");
13
+ const _chopstickscore = require("@acala-network/chopsticks-core");
14
+ const _context = require("./context");
15
+ const setupWithServer = async (argv)=>{
16
+ const context = await (0, _context.setupContext)(argv);
10
17
  const port = argv.port ?? 8000;
11
18
  if (argv.genesis) {
12
19
  // mine 1st block when starting from genesis to set some mock validation data
13
20
  await context.chain.newBlock();
14
21
  }
15
- const { close, port: listenPort } = await (0, server_1.createServer)((0, rpc_1.handler)(context), port);
16
- chopsticks_core_1.logger.info(`${await context.chain.api.getSystemChain()} RPC listening on port ${listenPort}`);
22
+ const { close, port: listenPort } = await (0, _server.createServer)((0, _rpc.handler)(context), port);
23
+ _chopstickscore.logger.info(`${await context.chain.api.getSystemChain()} RPC listening on port ${listenPort}`);
17
24
  return {
18
25
  ...context,
19
26
  listenPort,
20
- async close() {
27
+ async close () {
21
28
  await context.chain.close();
22
29
  await close();
23
- },
30
+ }
24
31
  };
25
32
  };
26
- exports.setupWithServer = setupWithServer;
package/dist/cjs/types.js CHANGED
@@ -1,18 +1,30 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("@acala-network/chopsticks-core/src/rpc/substrate"), exports);
18
- __exportStar(require("./plugins/types"), exports);
1
+ /**
2
+ * Chopsticks JSON RPC and CLI.
3
+ *
4
+ * @remarks
5
+ * This package extends the `@acala-network/chopsticks-core` package a with JSON RPC server and CLI support.
6
+ *
7
+ * @privateRemarks
8
+ * Above is the package documentation for 'chopsticks' package.
9
+ * `export` below is for tsdoc.
10
+ *
11
+ * @packageDocumentation
12
+ */ "use strict";
13
+ Object.defineProperty(exports, "__esModule", {
14
+ value: true
15
+ });
16
+ _export_star(require("@acala-network/chopsticks-core/src/rpc/substrate"), exports);
17
+ _export_star(require("./plugins/types"), exports);
18
+ function _export_star(from, to) {
19
+ Object.keys(from).forEach(function(k) {
20
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
21
+ Object.defineProperty(to, k, {
22
+ enumerable: true,
23
+ get: function() {
24
+ return from[k];
25
+ }
26
+ });
27
+ }
28
+ });
29
+ return from;
30
+ }
@@ -1,22 +1,38 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.decodeStorageDiff = void 0;
7
- const chopsticks_core_1 = require("@acala-network/chopsticks-core");
8
- const jsondiffpatch_1 = require("jsondiffpatch");
9
- const lodash_1 = __importDefault(require("lodash"));
10
- const diffPatcher = (0, jsondiffpatch_1.create)({
11
- array: { detectMove: false },
12
- textDiff: { minLength: Number.MAX_VALUE }, // skip text diff
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "decodeStorageDiff", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return decodeStorageDiff;
9
+ }
10
+ });
11
+ const _chopstickscore = require("@acala-network/chopsticks-core");
12
+ const _jsondiffpatch = require("jsondiffpatch");
13
+ const _lodash = /*#__PURE__*/ _interop_require_default(require("lodash"));
14
+ function _interop_require_default(obj) {
15
+ return obj && obj.__esModule ? obj : {
16
+ default: obj
17
+ };
18
+ }
19
+ const diffPatcher = (0, _jsondiffpatch.create)({
20
+ array: {
21
+ detectMove: false
22
+ },
23
+ textDiff: {
24
+ minLength: Number.MAX_VALUE
25
+ }
13
26
  });
14
- const decodeStorageDiff = async (block, diff) => {
15
- const [oldState, newState] = await (0, chopsticks_core_1.decodeBlockStorageDiff)(block, diff);
16
- const oldStateWithoutEvents = lodash_1.default.cloneDeep(oldState);
27
+ const decodeStorageDiff = async (block, diff)=>{
28
+ const [oldState, newState] = await (0, _chopstickscore.decodeBlockStorageDiff)(block, diff);
29
+ const oldStateWithoutEvents = _lodash.default.cloneDeep(oldState);
17
30
  if (oldStateWithoutEvents['system']?.['events']) {
18
31
  oldStateWithoutEvents['system']['events'] = [];
19
32
  }
20
- return { oldState, newState, delta: diffPatcher.diff(oldStateWithoutEvents, newState) };
33
+ return {
34
+ oldState,
35
+ newState,
36
+ delta: diffPatcher.diff(oldStateWithoutEvents, newState)
37
+ };
21
38
  };
22
- exports.decodeStorageDiff = decodeStorageDiff;
@@ -1,24 +1,43 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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
+ generateHtmlDiff: function() {
13
+ return generateHtmlDiff;
14
+ },
15
+ generateHtmlDiffPreviewFile: function() {
16
+ return generateHtmlDiffPreviewFile;
17
+ }
18
+ });
19
+ const _decoder = require("./decoder");
20
+ const _nodefs = require("node:fs");
21
+ const _lodash = /*#__PURE__*/ _interop_require_default(require("lodash"));
22
+ function _interop_require_default(obj) {
23
+ return obj && obj.__esModule ? obj : {
24
+ default: obj
25
+ };
26
+ }
27
+ const generateHtmlDiff = async (block, diff)=>{
28
+ const { oldState, delta } = await (0, _decoder.decodeStorageDiff)(block, diff);
29
+ const htmlTemplate = (0, _nodefs.readFileSync)(new URL('template/diff.html', require("url").pathToFileURL(__filename).toString()), 'utf-8');
30
+ return _lodash.default.template(htmlTemplate)({
31
+ left: JSON.stringify(oldState),
32
+ delta: JSON.stringify(delta)
33
+ });
4
34
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.generateHtmlDiffPreviewFile = exports.generateHtmlDiff = void 0;
7
- const decoder_1 = require("./decoder");
8
- const node_fs_1 = require("node:fs");
9
- const lodash_1 = require("lodash");
10
- const node_path_1 = __importDefault(require("node:path"));
11
- const generateHtmlDiff = async (block, diff) => {
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');
14
- return (0, lodash_1.template)(htmlTemplate)({ left: JSON.stringify(oldState), delta: JSON.stringify(delta) });
15
- };
16
- exports.generateHtmlDiff = generateHtmlDiff;
17
- const generateHtmlDiffPreviewFile = async (block, diff, filename) => {
18
- const html = await (0, exports.generateHtmlDiff)(block, diff);
19
- (0, node_fs_1.mkdirSync)('./preview', { recursive: true });
35
+ const generateHtmlDiffPreviewFile = async (block, diff, filename)=>{
36
+ const html = await generateHtmlDiff(block, diff);
37
+ (0, _nodefs.mkdirSync)('./preview', {
38
+ recursive: true
39
+ });
20
40
  const filePath = `./preview/${filename}.html`;
21
- (0, node_fs_1.writeFileSync)(filePath, html);
41
+ (0, _nodefs.writeFileSync)(filePath, html);
22
42
  return filePath;
23
43
  };
24
- exports.generateHtmlDiffPreviewFile = generateHtmlDiffPreviewFile;
@@ -1,20 +1,21 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./decoder"), exports);
18
- __exportStar(require("./generate-html-diff"), exports);
19
- __exportStar(require("./open-html"), exports);
20
- __exportStar(require("./override"), exports);
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ _export_star(require("./decoder"), exports);
6
+ _export_star(require("./generate-html-diff"), exports);
7
+ _export_star(require("./open-html"), exports);
8
+ _export_star(require("./override"), exports);
9
+ function _export_star(from, to) {
10
+ Object.keys(from).forEach(function(k) {
11
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
12
+ Object.defineProperty(to, k, {
13
+ enumerable: true,
14
+ get: function() {
15
+ return from[k];
16
+ }
17
+ });
18
+ }
19
+ });
20
+ return from;
21
+ }
@@ -1,9 +1,15 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.openHtml = void 0;
4
- const node_child_process_1 = require("node:child_process");
5
- const openHtml = (filePath) => {
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "openHtml", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return openHtml;
9
+ }
10
+ });
11
+ const _nodechild_process = require("node:child_process");
12
+ const openHtml = (filePath)=>{
6
13
  const start = process.platform == 'darwin' ? 'open' : process.platform == 'win32' ? 'start' : 'xdg-open';
7
- (0, node_child_process_1.execSync)(start + ' ' + filePath);
14
+ (0, _nodechild_process.execSync)(start + ' ' + filePath);
8
15
  };
9
- exports.openHtml = openHtml;
@@ -1,51 +1,64 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.overrideWasm = exports.overrideStorage = void 0;
7
- const chopsticks_core_1 = require("@acala-network/chopsticks-core");
8
- const node_fs_1 = require("node:fs");
9
- const js_yaml_1 = __importDefault(require("js-yaml"));
10
- const logger_1 = require("../logger");
11
- const overrideStorage = async (chain, storage, at) => {
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
+ overrideStorage: function() {
13
+ return overrideStorage;
14
+ },
15
+ overrideWasm: function() {
16
+ return overrideWasm;
17
+ }
18
+ });
19
+ const _chopstickscore = require("@acala-network/chopsticks-core");
20
+ const _nodefs = require("node:fs");
21
+ const _jsyaml = /*#__PURE__*/ _interop_require_default(require("js-yaml"));
22
+ const _logger = require("../logger");
23
+ function _interop_require_default(obj) {
24
+ return obj && obj.__esModule ? obj : {
25
+ default: obj
26
+ };
27
+ }
28
+ const overrideStorage = async (chain, storage, at)=>{
12
29
  if (storage == null) {
13
30
  return;
14
31
  }
15
32
  let storageValue;
16
33
  if (typeof storage === 'string') {
17
- if (!(0, node_fs_1.existsSync)(storage))
18
- throw Error(`File ${storage} does not exist`);
19
- storageValue = js_yaml_1.default.load(String((0, node_fs_1.readFileSync)(storage)));
20
- }
21
- else {
34
+ if (!(0, _nodefs.existsSync)(storage)) throw Error(`File ${storage} does not exist`);
35
+ storageValue = _jsyaml.default.load(String((0, _nodefs.readFileSync)(storage)));
36
+ } else {
22
37
  storageValue = storage;
23
38
  }
24
- const blockHash = await (0, chopsticks_core_1.setStorage)(chain, storageValue, at);
25
- logger_1.defaultLogger.trace({ blockHash, storage }, 'OverrideStorage');
39
+ const blockHash = await (0, _chopstickscore.setStorage)(chain, storageValue, at);
40
+ _logger.defaultLogger.trace({
41
+ blockHash,
42
+ storage
43
+ }, 'OverrideStorage');
26
44
  };
27
- exports.overrideStorage = overrideStorage;
28
- const overrideWasm = async (chain, wasmPath, at) => {
45
+ const overrideWasm = async (chain, wasmPath, at)=>{
29
46
  if (wasmPath == null) {
30
47
  return;
31
48
  }
32
- const wasm = (0, node_fs_1.readFileSync)(wasmPath);
49
+ const wasm = (0, _nodefs.readFileSync)(wasmPath);
33
50
  let wasmHex;
34
51
  if (wasm.at(0) === 0x30 && wasm.at(1) === 0x78) {
35
52
  // starts with 0x
36
53
  wasmHex = wasm.toString().trim();
37
- }
38
- else {
54
+ } else {
39
55
  wasmHex = '0x' + wasm.toString('hex');
40
56
  }
41
57
  if (at) {
42
58
  const block = await chain.getBlock(at);
43
- if (!block)
44
- throw new Error(`Cannot find block ${at}`);
59
+ if (!block) throw new Error(`Cannot find block ${at}`);
45
60
  block.setWasm(wasmHex);
46
- }
47
- else {
61
+ } else {
48
62
  chain.head.setWasm(wasmHex);
49
63
  }
50
64
  };
51
- exports.overrideWasm = overrideWasm;
@@ -1,16 +1,13 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
6
5
  require("global-agent/bootstrap");
7
- const npm_conf_1 = __importDefault(require("@pnpm/npm-conf"));
8
- const npmConfig = (0, npm_conf_1.default)().config;
9
- global.GLOBAL_AGENT.HTTP_PROXY =
10
- process.env.HTTP_PROXY ||
11
- process.env.http_proxy ||
12
- process.env.HTTPS_PROXY ||
13
- process.env.https_proxy ||
14
- npmConfig.get('proxy') ||
15
- npmConfig.get('https-proxy') ||
16
- global.GLOBAL_AGENT.HTTP_PROXY;
6
+ const _npmconf = /*#__PURE__*/ _interop_require_default(require("@pnpm/npm-conf"));
7
+ function _interop_require_default(obj) {
8
+ return obj && obj.__esModule ? obj : {
9
+ default: obj
10
+ };
11
+ }
12
+ const npmConfig = (0, _npmconf.default)().config;
13
+ global.GLOBAL_AGENT.HTTP_PROXY = process.env.HTTP_PROXY || process.env.http_proxy || process.env.HTTPS_PROXY || process.env.https_proxy || npmConfig.get('proxy') || npmConfig.get('https-proxy') || global.GLOBAL_AGENT.HTTP_PROXY;