@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,40 +1,50 @@
1
1
  import { WebSocket, WebSocketServer } from 'ws';
2
2
  import { ResponseError } from '@acala-network/chopsticks-core';
3
3
  import { z } from 'zod';
4
- import { defaultLogger, truncate } from './logger';
5
- const logger = defaultLogger.child({ name: 'ws' });
4
+ import { defaultLogger, truncate } from './logger.js';
5
+ const logger = defaultLogger.child({
6
+ name: 'ws'
7
+ });
6
8
  const singleRequest = z.object({
7
9
  id: z.number(),
8
10
  jsonrpc: z.literal('2.0'),
9
11
  method: z.string(),
10
- params: z.array(z.any()).default([]),
12
+ params: z.array(z.any()).default([])
11
13
  });
12
14
  const batchRequest = z.array(singleRequest);
13
- const requestSchema = z.union([singleRequest, batchRequest]);
14
- const parseRequest = (request) => {
15
+ const requestSchema = z.union([
16
+ singleRequest,
17
+ batchRequest
18
+ ]);
19
+ const parseRequest = (request)=>{
15
20
  try {
16
21
  return JSON.parse(request);
17
- }
18
- catch (e) {
22
+ } catch (e) {
19
23
  return undefined;
20
24
  }
21
25
  };
22
- const createWS = async (port) => {
23
- const wss = new WebSocketServer({ port, maxPayload: 1024 * 1024 * 100 });
24
- const promise = new Promise((resolve) => {
25
- wss.on('listening', () => {
26
- resolve([wss, wss.address().port]);
26
+ const createWS = async (port)=>{
27
+ const wss = new WebSocketServer({
28
+ port,
29
+ maxPayload: 1024 * 1024 * 100
30
+ });
31
+ const promise = new Promise((resolve)=>{
32
+ wss.on('listening', ()=>{
33
+ resolve([
34
+ wss,
35
+ wss.address().port
36
+ ]);
27
37
  });
28
- wss.on('error', (_) => {
38
+ wss.on('error', (_)=>{
29
39
  resolve([]);
30
40
  });
31
41
  });
32
42
  return promise;
33
43
  };
34
- export const createServer = async (handler, port) => {
44
+ export const createServer = async (handler, port)=>{
35
45
  let wss;
36
46
  let listenPort;
37
- for (let i = 0; i < 10; i++) {
47
+ for(let i = 0; i < 10; i++){
38
48
  const preferPort = (port ?? 0) > 0 ? (port ?? 0) + i : 0;
39
49
  logger.debug('Try starting on port %d', preferPort);
40
50
  const [maybeWss, maybeListenPort] = await createWS(preferPort);
@@ -47,80 +57,86 @@ export const createServer = async (handler, port) => {
47
57
  if (!wss || !listenPort) {
48
58
  throw new Error(`Failed to create WebsocketServer at port ${port}`);
49
59
  }
50
- wss.on('connection', (ws) => {
60
+ wss.on('connection', (ws)=>{
51
61
  logger.debug('New connection');
52
- const send = (data) => {
62
+ const send = (data)=>{
53
63
  if (ws.readyState === WebSocket.OPEN) {
54
64
  ws.send(JSON.stringify(data));
55
65
  }
56
66
  };
57
67
  const subscriptions = {};
58
68
  const subscriptionManager = {
59
- subscribe: (method, subid, onCancel = () => { }) => {
69
+ subscribe: (method, subid, onCancel = ()=>{})=>{
60
70
  subscriptions[subid] = onCancel;
61
- return (data) => {
71
+ return (data)=>{
62
72
  if (subscriptions[subid]) {
63
- logger.trace({ method, subid, data: truncate(data) }, 'Subscription notification');
73
+ logger.trace({
74
+ method,
75
+ subid,
76
+ data: truncate(data)
77
+ }, 'Subscription notification');
64
78
  send({
65
79
  jsonrpc: '2.0',
66
80
  method,
67
81
  params: {
68
82
  result: data,
69
- subscription: subid,
70
- },
83
+ subscription: subid
84
+ }
71
85
  });
72
86
  }
73
87
  };
74
88
  },
75
- unsubscribe: (subid) => {
89
+ unsubscribe: (subid)=>{
76
90
  if (subscriptions[subid]) {
77
91
  subscriptions[subid](subid);
78
92
  delete subscriptions[subid];
79
93
  }
80
- },
94
+ }
81
95
  };
82
- const processRequest = async (req) => {
96
+ const processRequest = async (req)=>{
83
97
  logger.trace({
84
98
  id: req.id,
85
- method: req.method,
99
+ method: req.method
86
100
  }, 'Received message');
87
101
  try {
88
102
  const resp = await handler(req, subscriptionManager);
89
103
  logger.trace({
90
104
  id: req.id,
91
105
  method: req.method,
92
- result: truncate(resp),
106
+ result: truncate(resp)
93
107
  }, 'Response for request');
94
108
  return {
95
109
  id: req.id,
96
110
  jsonrpc: '2.0',
97
- result: resp ?? null,
111
+ result: resp ?? null
98
112
  };
99
- }
100
- catch (e) {
113
+ } catch (e) {
101
114
  logger.info('Error handling request: %s %o', e, e.stack);
102
115
  return {
103
116
  id: req.id,
104
117
  jsonrpc: '2.0',
105
- error: e instanceof ResponseError ? e : { code: -32603, message: `Internal ${e}` },
118
+ error: e instanceof ResponseError ? e : {
119
+ code: -32603,
120
+ message: `Internal ${e}`
121
+ }
106
122
  };
107
123
  }
108
124
  };
109
- ws.on('close', () => {
125
+ ws.on('close', ()=>{
110
126
  logger.debug('Connection closed');
111
- for (const [subid, onCancel] of Object.entries(subscriptions)) {
127
+ for (const [subid, onCancel] of Object.entries(subscriptions)){
112
128
  onCancel(subid);
113
129
  }
114
130
  ws.removeAllListeners();
115
131
  });
116
- ws.on('error', () => {
132
+ ws.on('error', ()=>{
117
133
  logger.debug('Connection error');
118
- for (const [subid, onCancel] of Object.entries(subscriptions)) {
134
+ for (const [subid, onCancel] of Object.entries(subscriptions)){
119
135
  onCancel(subid);
120
136
  }
121
137
  ws.removeAllListeners();
122
138
  });
123
- ws.on('message', async (message) => {
139
+ ws.on('message', async (message)=>{
124
140
  const parsed = await requestSchema.safeParseAsync(parseRequest(message.toString()));
125
141
  if (!parsed.success) {
126
142
  logger.info('Invalid request: %s', message);
@@ -129,19 +145,22 @@ export const createServer = async (handler, port) => {
129
145
  jsonrpc: '2.0',
130
146
  error: {
131
147
  code: -32600,
132
- message: 'Invalid JSON Request',
133
- },
148
+ message: 'Invalid JSON Request'
149
+ }
134
150
  });
135
151
  return;
136
152
  }
137
153
  const { data: req } = parsed;
138
154
  if (Array.isArray(req)) {
139
- logger.trace({ req }, 'Received batch request');
155
+ logger.trace({
156
+ req
157
+ }, 'Received batch request');
140
158
  const resp = await Promise.all(req.map(processRequest));
141
159
  send(resp);
142
- }
143
- else {
144
- logger.trace({ req }, 'Received single request');
160
+ } else {
161
+ logger.trace({
162
+ req
163
+ }, 'Received single request');
145
164
  const resp = await processRequest(req);
146
165
  send(resp);
147
166
  }
@@ -149,16 +168,15 @@ export const createServer = async (handler, port) => {
149
168
  });
150
169
  return {
151
170
  port: listenPort,
152
- close: () => new Promise((resolve, reject) => {
153
- wss?.clients.forEach((socket) => socket.close());
154
- wss?.close((err) => {
155
- if (err) {
156
- reject(err);
157
- }
158
- else {
159
- resolve();
160
- }
161
- });
162
- }),
171
+ close: ()=>new Promise((resolve, reject)=>{
172
+ wss?.clients.forEach((socket)=>socket.close());
173
+ wss?.close((err)=>{
174
+ if (err) {
175
+ reject(err);
176
+ } else {
177
+ resolve();
178
+ }
179
+ });
180
+ })
163
181
  };
164
182
  };
@@ -1,8 +1,8 @@
1
- import { createServer } from './server';
2
- import { handler } from './rpc';
1
+ import { createServer } from './server.js';
2
+ import { handler } from './rpc/index.js';
3
3
  import { logger } from '@acala-network/chopsticks-core';
4
- import { setupContext } from './context';
5
- export const setupWithServer = async (argv) => {
4
+ import { setupContext } from './context.js';
5
+ export const setupWithServer = async (argv)=>{
6
6
  const context = await setupContext(argv);
7
7
  const port = argv.port ?? 8000;
8
8
  if (argv.genesis) {
@@ -14,9 +14,9 @@ export const setupWithServer = async (argv) => {
14
14
  return {
15
15
  ...context,
16
16
  listenPort,
17
- async close() {
17
+ async close () {
18
18
  await context.chain.close();
19
19
  await close();
20
- },
20
+ }
21
21
  };
22
22
  };
package/dist/esm/types.js CHANGED
@@ -1,2 +1,13 @@
1
- export * from '@acala-network/chopsticks-core/src/rpc/substrate';
2
- export * from './plugins/types';
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
+ */ export * from '@acala-network/chopsticks-core/rpc/substrate/index.js';
13
+ export * from './plugins/types.js';
@@ -2,14 +2,22 @@ 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: { detectMove: false },
6
- textDiff: { minLength: Number.MAX_VALUE }, // skip text diff
5
+ array: {
6
+ detectMove: false
7
+ },
8
+ textDiff: {
9
+ minLength: Number.MAX_VALUE
10
+ }
7
11
  });
8
- export const decodeStorageDiff = async (block, diff) => {
12
+ export const decodeStorageDiff = async (block, diff)=>{
9
13
  const [oldState, newState] = await decodeBlockStorageDiff(block, diff);
10
14
  const oldStateWithoutEvents = _.cloneDeep(oldState);
11
15
  if (oldStateWithoutEvents['system']?.['events']) {
12
16
  oldStateWithoutEvents['system']['events'] = [];
13
17
  }
14
- return { oldState, newState, delta: diffPatcher.diff(oldStateWithoutEvents, newState) };
18
+ return {
19
+ oldState,
20
+ newState,
21
+ delta: diffPatcher.diff(oldStateWithoutEvents, newState)
22
+ };
15
23
  };
@@ -1,15 +1,19 @@
1
- import { decodeStorageDiff } from './decoder';
1
+ import { decodeStorageDiff } from './decoder.js';
2
2
  import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
3
3
  import _ from 'lodash';
4
- import url from 'node:url';
5
- export const generateHtmlDiff = async (block, diff) => {
4
+ export const generateHtmlDiff = async (block, diff)=>{
6
5
  const { oldState, delta } = await decodeStorageDiff(block, diff);
7
- const htmlTemplate = readFileSync(url.resolve(__filename, './template/diff.html'), 'utf-8');
8
- return _.template(htmlTemplate)({ left: JSON.stringify(oldState), delta: JSON.stringify(delta) });
6
+ const htmlTemplate = readFileSync(new URL('template/diff.html', import.meta.url), 'utf-8');
7
+ return _.template(htmlTemplate)({
8
+ left: JSON.stringify(oldState),
9
+ delta: JSON.stringify(delta)
10
+ });
9
11
  };
10
- export const generateHtmlDiffPreviewFile = async (block, diff, filename) => {
12
+ export const generateHtmlDiffPreviewFile = async (block, diff, filename)=>{
11
13
  const html = await generateHtmlDiff(block, diff);
12
- mkdirSync('./preview', { recursive: true });
14
+ mkdirSync('./preview', {
15
+ recursive: true
16
+ });
13
17
  const filePath = `./preview/${filename}.html`;
14
18
  writeFileSync(filePath, html);
15
19
  return filePath;
@@ -1,4 +1,4 @@
1
- export * from './decoder';
2
- export * from './generate-html-diff';
3
- export * from './open-html';
4
- export * from './override';
1
+ export * from './decoder.js';
2
+ export * from './generate-html-diff.js';
3
+ export * from './open-html.js';
4
+ export * from './override.js';
@@ -1,5 +1,5 @@
1
1
  import { execSync } from 'node:child_process';
2
- export const openHtml = (filePath) => {
2
+ export const openHtml = (filePath)=>{
3
3
  const start = process.platform == 'darwin' ? 'open' : process.platform == 'win32' ? 'start' : 'xdg-open';
4
4
  execSync(start + ' ' + filePath);
5
5
  };
@@ -1,24 +1,25 @@
1
1
  import { setStorage } from '@acala-network/chopsticks-core';
2
2
  import { existsSync, readFileSync } from 'node:fs';
3
3
  import yaml from 'js-yaml';
4
- import { defaultLogger } from '../logger';
5
- export const overrideStorage = async (chain, storage, at) => {
4
+ import { defaultLogger } from '../logger.js';
5
+ export const overrideStorage = async (chain, storage, at)=>{
6
6
  if (storage == null) {
7
7
  return;
8
8
  }
9
9
  let storageValue;
10
10
  if (typeof storage === 'string') {
11
- if (!existsSync(storage))
12
- throw Error(`File ${storage} does not exist`);
11
+ if (!existsSync(storage)) throw Error(`File ${storage} does not exist`);
13
12
  storageValue = yaml.load(String(readFileSync(storage)));
14
- }
15
- else {
13
+ } else {
16
14
  storageValue = storage;
17
15
  }
18
16
  const blockHash = await setStorage(chain, storageValue, at);
19
- defaultLogger.trace({ blockHash, storage }, 'OverrideStorage');
17
+ defaultLogger.trace({
18
+ blockHash,
19
+ storage
20
+ }, 'OverrideStorage');
20
21
  };
21
- export const overrideWasm = async (chain, wasmPath, at) => {
22
+ export const overrideWasm = async (chain, wasmPath, at)=>{
22
23
  if (wasmPath == null) {
23
24
  return;
24
25
  }
@@ -27,17 +28,14 @@ export const overrideWasm = async (chain, wasmPath, at) => {
27
28
  if (wasm.at(0) === 0x30 && wasm.at(1) === 0x78) {
28
29
  // starts with 0x
29
30
  wasmHex = wasm.toString().trim();
30
- }
31
- else {
31
+ } else {
32
32
  wasmHex = '0x' + wasm.toString('hex');
33
33
  }
34
34
  if (at) {
35
35
  const block = await chain.getBlock(at);
36
- if (!block)
37
- throw new Error(`Cannot find block ${at}`);
36
+ if (!block) throw new Error(`Cannot find block ${at}`);
38
37
  block.setWasm(wasmHex);
39
- }
40
- else {
38
+ } else {
41
39
  chain.head.setWasm(wasmHex);
42
40
  }
43
41
  };
@@ -1,11 +1,4 @@
1
1
  import 'global-agent/bootstrap';
2
2
  import npmConf from '@pnpm/npm-conf';
3
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;
4
+ 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;
@@ -1,6 +1,6 @@
1
- import './utils/tunnel';
1
+ import './utils/tunnel.js';
2
2
  import { GenesisProvider } from '@acala-network/chopsticks-core';
3
- import { Config } from './schema';
3
+ import { Config } from './schema/index.js';
4
4
  export declare const genesisFromUrl: (url: string) => Promise<GenesisProvider>;
5
5
  export declare const setupContext: (argv: Config, overrideParent?: boolean) => Promise<{
6
6
  chain: import("@acala-network/chopsticks-core").Blockchain;
@@ -1,4 +1,4 @@
1
1
  import '@polkadot/api-augment';
2
2
  export * from '@acala-network/chopsticks-core';
3
- export { setupWithServer } from './setup-with-server';
4
- export { fetchConfig } from './schema';
3
+ export { setupWithServer } from './setup-with-server.js';
4
+ export { fetchConfig } from './schema/index.js';
@@ -1,2 +1,2 @@
1
- import { Config } from '../../schema';
1
+ import { Config } from '../../schema/index.js';
2
2
  export declare const dryRunExtrinsic: (argv: Config) => Promise<never>;
@@ -1,2 +1,2 @@
1
- import { Config } from '../../schema';
1
+ import { Config } from '../../schema/index.js';
2
2
  export declare const dryRunPreimage: (argv: Config) => Promise<never>;
@@ -1,2 +1,2 @@
1
- export * from './cli';
2
- export * from './rpc';
1
+ export * from './cli.js';
2
+ export * from './rpc.js';
@@ -52,7 +52,7 @@ export interface RunBlockParams {
52
52
  */
53
53
  includeBlockDetails: Params['includeBlockDetails'];
54
54
  /**
55
- * The parent block hash to run on top of. Deafult to chain head.
55
+ * The parent block hash to run on top of. Default to chain head.
56
56
  */
57
57
  parent: Params['parent'];
58
58
  /**
@@ -1,11 +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';
1
+ export { rpc as newBlock } from './new-block/index.js';
2
+ export { rpc as dryRun } from './dry-run/index.js';
3
+ export { rpc as setBlockBuildMode } from './set-block-build-mode/index.js';
4
+ export { rpc as setHead } from './set-head/index.js';
5
+ export { rpc as setRuntimeLogLevel } from './set-runtime-log-level/index.js';
6
+ export { rpc as setStorage } from './set-storage/index.js';
7
+ export { rpc as timeTravel } from './time-travel/index.js';
8
+ export { rpc as runBlock } from './run-block/index.js';
9
+ export type { NewBlockParams } from './new-block/index.js';
10
+ export type { DryRunParams } from './dry-run/index.js';
11
+ export type { RunBlockParams } from './run-block/index.js';
@@ -1,4 +1,4 @@
1
- import { Config } from './schema';
1
+ import { Config } from './schema/index.js';
2
2
  export declare const setupWithServer: (argv: Config) => Promise<{
3
3
  listenPort: number;
4
4
  close(): Promise<void>;
@@ -11,5 +11,5 @@
11
11
  * @packageDocumentation
12
12
  */
13
13
  export type { ChainProperties, RuntimeVersion, Context, SubscriptionManager, Handler, } from '@acala-network/chopsticks-core';
14
- export * from '@acala-network/chopsticks-core/src/rpc/substrate';
15
- export * from './plugins/types';
14
+ export * from '@acala-network/chopsticks-core/rpc/substrate/index.js';
15
+ export * from './plugins/types.js';
@@ -1,4 +1,4 @@
1
- export * from './decoder';
2
- export * from './generate-html-diff';
3
- export * from './open-html';
4
- export * from './override';
1
+ export * from './decoder.js';
2
+ export * from './generate-html-diff.js';
3
+ export * from './open-html.js';
4
+ export * from './override.js';
package/package.json CHANGED
@@ -1,25 +1,21 @@
1
1
  {
2
2
  "name": "@acala-network/chopsticks",
3
- "version": "0.9.1-2",
3
+ "version": "0.9.1-4",
4
4
  "author": "Acala Developers <hello@acala.network>",
5
5
  "license": "Apache-2.0",
6
- "bin": "./chopsticks.js",
6
+ "bin": "./chopsticks.cjs",
7
+ "type": "module",
7
8
  "scripts": {
8
9
  "clean": "rm -rf dist",
9
- "build": "yarn clean && tsc -p ./tsconfig.json && tsc -p ./tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./dist/esm/package.json && yarn copyfiles",
10
- "copyfiles": "cp -r src/utils/template dist/cjs/utils/ && cp -r src/utils/template dist/esm/utils/",
11
- "script:start": "cd ../..; ts-node --transpile-only -r tsconfig-paths/register packages/chopsticks/src/cli.ts",
12
- "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",
13
- "dev:karura": "cd ../..; ts-node-dev --transpile-only --inspect -r tsconfig-paths/register --notify=false packages/chopsticks/src/cli.ts -- --config=configs/karura.yml",
14
- "dev:acala": "cd ../..; ts-node-dev --transpile-only --inspect -r tsconfig-paths/register --notify=false packages/chopsticks/src/cli.ts -- --config=configs/acala.yml",
15
- "dev:polkadot": "cd ../..; ts-node-dev --transpile-only --inspect -r tsconfig-paths/register --notify=false packages/chopsticks/src/cli.ts -- --config=configs/polkadot.yml",
16
- "dev:moonriver": "cd ../..; ts-node-dev --transpile-only --inspect -r tsconfig-paths/register --notify=false packages/chopsticks/src/cli.ts -- --config=configs/moonriver.yml",
17
- "dev:moonbeam": "cd ../..; ts-node-dev --transpile-only --inspect -r tsconfig-paths/register --notify=false packages/chopsticks/src/cli.ts -- --config=configs/moonbeam.yml",
10
+ "build": "yarn clean && yarn build:cjs && yarn build:esm && yarn build:types",
11
+ "build:cjs": "swc ./src --config-file ../../.cjsswcrc -d dist/cjs --copy-files && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
12
+ "build:esm": "swc ./src --config-file ../../.esmswcrc -d dist/esm --copy-files",
13
+ "build:types": "tsc -p tsconfig.json --emitDeclarationOnly --outDir dist/types",
18
14
  "docs:prep": "typedoc"
19
15
  },
20
16
  "dependencies": {
21
- "@acala-network/chopsticks-core": "0.9.1-2",
22
- "@acala-network/chopsticks-db": "0.9.1-2",
17
+ "@acala-network/chopsticks-core": "0.9.1-4",
18
+ "@acala-network/chopsticks-db": "0.9.1-4",
23
19
  "@pnpm/npm-conf": "^2.2.2",
24
20
  "axios": "^1.6.0",
25
21
  "dotenv": "^16.3.1",
@@ -32,21 +28,21 @@
32
28
  "zod": "^3.22.3"
33
29
  },
34
30
  "devDependencies": {
31
+ "@swc/cli": "0.1.62",
32
+ "@swc/core": "^1.3.96",
35
33
  "@types/global-agent": "^2.1.1",
36
34
  "@types/js-yaml": "^4.0.5",
37
35
  "@types/lodash": "^4.14.199",
38
36
  "@types/node": "^20.5.7",
39
37
  "@types/ws": "^8.5.6",
40
38
  "@types/yargs": "^17.0.29",
41
- "ts-node": "^10.9.1",
42
- "ts-node-dev": "^2.0.0",
43
39
  "typescript": "^5.1.6"
44
40
  },
45
41
  "files": [
46
42
  "dist/esm/**",
47
43
  "dist/cjs/**",
48
44
  "dist/types/**",
49
- "chopsticks.js"
45
+ "chopsticks.cjs"
50
46
  ],
51
47
  "main": "./dist/cjs/index.js",
52
48
  "module": "./dist/esm/index.js",
@@ -59,10 +55,10 @@
59
55
  "default": "./dist/esm/index.js"
60
56
  },
61
57
  "./*": {
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"
58
+ "types": "./dist/types/*.d.ts",
59
+ "require": "./dist/cjs/*.js",
60
+ "import": "./dist/esm/*.js",
61
+ "default": "./dist/esm/*.js"
66
62
  },
67
63
  "./plugins/*": {
68
64
  "types": "./dist/types/plugins/*.d.ts",
@@ -71,6 +67,6 @@
71
67
  "default": "./dist/esm/plugins/*.js"
72
68
  },
73
69
  "./package.json": "./package.json",
74
- "./package.esm.json": "./dist/esm/package.json"
70
+ "./package.cjs.json": "./dist/cjs/package.json"
75
71
  }
76
72
  }
@@ -1 +0,0 @@
1
- {"type": "module"}
File without changes