@acala-network/chopsticks 0.15.0 → 0.16.0
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.
- package/dist/cjs/plugins/dry-run/index.d.ts +3 -0
- package/dist/cjs/plugins/follow-chain/cli.js +2 -2
- package/dist/cjs/plugins/try-runtime/index.js +1 -0
- package/dist/cjs/schema/index.d.ts +3 -0
- package/dist/cjs/schema/index.js +7 -1
- package/dist/cjs/server.d.ts +1 -1
- package/dist/cjs/server.js +2 -2
- package/dist/cjs/setup-with-server.d.ts +1 -0
- package/dist/cjs/setup-with-server.js +4 -2
- package/dist/cjs/utils/override.js +10 -1
- package/dist/esm/plugins/dry-run/index.d.ts +3 -0
- package/dist/esm/plugins/follow-chain/cli.js +2 -2
- package/dist/esm/plugins/try-runtime/index.js +1 -0
- package/dist/esm/schema/index.d.ts +3 -0
- package/dist/esm/schema/index.js +7 -1
- package/dist/esm/server.d.ts +1 -1
- package/dist/esm/server.js +2 -2
- package/dist/esm/setup-with-server.d.ts +1 -0
- package/dist/esm/setup-with-server.js +4 -2
- package/dist/esm/utils/override.js +11 -2
- package/package.json +3 -3
|
@@ -7,6 +7,7 @@ export declare const dryRunSchema: z.ZodObject<{
|
|
|
7
7
|
"output-path": z.ZodOptional<z.ZodString>;
|
|
8
8
|
html: z.ZodOptional<z.ZodBoolean>;
|
|
9
9
|
open: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
addr: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"localhost">, z.ZodString]>>;
|
|
10
11
|
port: z.ZodDefault<z.ZodNumber>;
|
|
11
12
|
endpoint: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
12
13
|
block: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodNull]>>;
|
|
@@ -145,6 +146,7 @@ export declare const dryRunSchema: z.ZodObject<{
|
|
|
145
146
|
'process-queued-messages': z.ZodOptional<z.ZodBoolean>;
|
|
146
147
|
'prefetch-storages': z.ZodOptional<z.ZodAny>;
|
|
147
148
|
}, "strip", z.ZodTypeAny, {
|
|
149
|
+
addr: string;
|
|
148
150
|
port: number;
|
|
149
151
|
'build-block-mode': import("@acala-network/chopsticks-core").BuildBlockMode;
|
|
150
152
|
at?: string | undefined;
|
|
@@ -199,6 +201,7 @@ export declare const dryRunSchema: z.ZodObject<{
|
|
|
199
201
|
html?: boolean | undefined;
|
|
200
202
|
}, {
|
|
201
203
|
at?: string | undefined;
|
|
204
|
+
addr?: string | undefined;
|
|
202
205
|
port?: number | undefined;
|
|
203
206
|
endpoint?: string | string[] | undefined;
|
|
204
207
|
block?: string | number | null | undefined;
|
|
@@ -49,8 +49,8 @@ const cli = (y)=>{
|
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
const context = await (0, _context.setupContext)(config, true);
|
|
52
|
-
const { close, port: listenPort } = await (0, _server.createServer)((0, _index1.handler)(context), config.port);
|
|
53
|
-
logger.info(`${await context.chain.api.getSystemChain()} RPC listening on
|
|
52
|
+
const { close, port: listenPort } = await (0, _server.createServer)((0, _index1.handler)(context), config.addr, config.port);
|
|
53
|
+
logger.info(`${await context.chain.api.getSystemChain()} RPC listening on ${config.addr}:${listenPort}`);
|
|
54
54
|
const chain = context.chain;
|
|
55
55
|
chain.api[config['head-mode'] === "Latest" ? 'subscribeRemoteNewHeads' : 'subscribeRemoteFinalizedHeads'](async (error, data)=>{
|
|
56
56
|
try {
|
|
@@ -4,6 +4,7 @@ import { ZodNativeEnum, ZodRawShape, ZodTypeAny, z } from 'zod';
|
|
|
4
4
|
export declare const zHex: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
|
|
5
5
|
export declare const zHash: z.ZodIntersection<z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>>;
|
|
6
6
|
export declare const configSchema: z.ZodObject<{
|
|
7
|
+
addr: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"localhost">, z.ZodString]>>;
|
|
7
8
|
port: z.ZodDefault<z.ZodNumber>;
|
|
8
9
|
endpoint: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
9
10
|
block: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodNull]>>;
|
|
@@ -142,6 +143,7 @@ export declare const configSchema: z.ZodObject<{
|
|
|
142
143
|
'process-queued-messages': z.ZodOptional<z.ZodBoolean>;
|
|
143
144
|
'prefetch-storages': z.ZodOptional<z.ZodAny>;
|
|
144
145
|
}, "strip", ZodTypeAny, {
|
|
146
|
+
addr: string;
|
|
145
147
|
port: number;
|
|
146
148
|
'build-block-mode': BuildBlockMode;
|
|
147
149
|
endpoint?: string | string[] | undefined;
|
|
@@ -188,6 +190,7 @@ export declare const configSchema: z.ZodObject<{
|
|
|
188
190
|
'process-queued-messages'?: boolean | undefined;
|
|
189
191
|
'prefetch-storages'?: any;
|
|
190
192
|
}, {
|
|
193
|
+
addr?: string | undefined;
|
|
191
194
|
port?: number | undefined;
|
|
192
195
|
endpoint?: string | string[] | undefined;
|
|
193
196
|
block?: string | number | null | undefined;
|
package/dist/cjs/schema/index.js
CHANGED
|
@@ -40,8 +40,14 @@ function _interop_require_default(obj) {
|
|
|
40
40
|
const zHex = _zod.z.custom((val)=>/^0x\w+$/.test(val));
|
|
41
41
|
const zHash = _zod.z.string().length(66).and(zHex);
|
|
42
42
|
const configSchema = _zod.z.object({
|
|
43
|
+
addr: _zod.z.union([
|
|
44
|
+
_zod.z.literal('localhost'),
|
|
45
|
+
_zod.z.string().ip()
|
|
46
|
+
], {
|
|
47
|
+
description: 'Server listening interface'
|
|
48
|
+
}).default('localhost'),
|
|
43
49
|
port: _zod.z.number({
|
|
44
|
-
description: '
|
|
50
|
+
description: 'Server listening port'
|
|
45
51
|
}).default(8000),
|
|
46
52
|
endpoint: _zod.z.union([
|
|
47
53
|
_zod.z.string(),
|
package/dist/cjs/server.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type Handler = (data: {
|
|
|
3
3
|
method: string;
|
|
4
4
|
params: string[];
|
|
5
5
|
}, subscriptionManager: SubscriptionManager) => Promise<any>;
|
|
6
|
-
export declare const createServer: (handler: Handler, port: number) => Promise<{
|
|
6
|
+
export declare const createServer: (handler: Handler, addr: string, port: number) => Promise<{
|
|
7
7
|
port: number;
|
|
8
8
|
close: () => Promise<void>;
|
|
9
9
|
}>;
|
package/dist/cjs/server.js
CHANGED
|
@@ -86,7 +86,7 @@ const portInUse = async (port)=>{
|
|
|
86
86
|
server.unref();
|
|
87
87
|
return inUse;
|
|
88
88
|
};
|
|
89
|
-
const createServer = async (handler, port)=>{
|
|
89
|
+
const createServer = async (handler, addr, port)=>{
|
|
90
90
|
let wss;
|
|
91
91
|
let listenPort;
|
|
92
92
|
const emptySubscriptionManager = {
|
|
@@ -164,7 +164,7 @@ const createServer = async (handler, port)=>{
|
|
|
164
164
|
reject(e);
|
|
165
165
|
};
|
|
166
166
|
server.once('error', onError);
|
|
167
|
-
server.listen(preferPort, ()=>{
|
|
167
|
+
server.listen(preferPort, addr, ()=>{
|
|
168
168
|
wss = new _ws.WebSocketServer({
|
|
169
169
|
server,
|
|
170
170
|
maxPayload: 1024 * 1024 * 100
|
|
@@ -14,10 +14,12 @@ const _index = require("./rpc/index.js");
|
|
|
14
14
|
const _context = require("./context.js");
|
|
15
15
|
const setupWithServer = async (argv)=>{
|
|
16
16
|
const context = await (0, _context.setupContext)(argv);
|
|
17
|
-
const
|
|
18
|
-
|
|
17
|
+
const addr = argv.addr ?? 'localhost';
|
|
18
|
+
const { close, port: listenPort } = await (0, _server.createServer)((0, _index.handler)(context), addr, argv.port);
|
|
19
|
+
_chopstickscore.defaultLogger.info(`${await context.chain.api.getSystemChain()} RPC listening on ${addr}:${listenPort}`);
|
|
19
20
|
return {
|
|
20
21
|
...context,
|
|
22
|
+
addr: argv.addr,
|
|
21
23
|
listenPort,
|
|
22
24
|
async close () {
|
|
23
25
|
await context.chain.close();
|
|
@@ -18,6 +18,7 @@ _export(exports, {
|
|
|
18
18
|
});
|
|
19
19
|
const _chopstickscore = require("@acala-network/chopsticks-core");
|
|
20
20
|
const _nodefs = require("node:fs");
|
|
21
|
+
const _axios = /*#__PURE__*/ _interop_require_default(require("axios"));
|
|
21
22
|
const _jsyaml = /*#__PURE__*/ _interop_require_default(require("js-yaml"));
|
|
22
23
|
const _logger = require("../logger.js");
|
|
23
24
|
function _interop_require_default(obj) {
|
|
@@ -46,7 +47,15 @@ const overrideWasm = async (chain, wasmPath, at)=>{
|
|
|
46
47
|
if (wasmPath == null) {
|
|
47
48
|
return;
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
+
let wasm;
|
|
51
|
+
if ((0, _chopstickscore.isUrl)(wasmPath)) {
|
|
52
|
+
const res = await _axios.default.get(wasmPath, {
|
|
53
|
+
responseType: 'arraybuffer'
|
|
54
|
+
});
|
|
55
|
+
wasm = res.data;
|
|
56
|
+
} else {
|
|
57
|
+
wasm = (0, _nodefs.readFileSync)(wasmPath);
|
|
58
|
+
}
|
|
50
59
|
let wasmHex;
|
|
51
60
|
if (wasm.at(0) === 0x30 && wasm.at(1) === 0x78) {
|
|
52
61
|
// starts with 0x
|
|
@@ -7,6 +7,7 @@ export declare const dryRunSchema: z.ZodObject<{
|
|
|
7
7
|
"output-path": z.ZodOptional<z.ZodString>;
|
|
8
8
|
html: z.ZodOptional<z.ZodBoolean>;
|
|
9
9
|
open: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
addr: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"localhost">, z.ZodString]>>;
|
|
10
11
|
port: z.ZodDefault<z.ZodNumber>;
|
|
11
12
|
endpoint: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
12
13
|
block: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodNull]>>;
|
|
@@ -145,6 +146,7 @@ export declare const dryRunSchema: z.ZodObject<{
|
|
|
145
146
|
'process-queued-messages': z.ZodOptional<z.ZodBoolean>;
|
|
146
147
|
'prefetch-storages': z.ZodOptional<z.ZodAny>;
|
|
147
148
|
}, "strip", z.ZodTypeAny, {
|
|
149
|
+
addr: string;
|
|
148
150
|
port: number;
|
|
149
151
|
'build-block-mode': import("@acala-network/chopsticks-core").BuildBlockMode;
|
|
150
152
|
at?: string | undefined;
|
|
@@ -199,6 +201,7 @@ export declare const dryRunSchema: z.ZodObject<{
|
|
|
199
201
|
html?: boolean | undefined;
|
|
200
202
|
}, {
|
|
201
203
|
at?: string | undefined;
|
|
204
|
+
addr?: string | undefined;
|
|
202
205
|
port?: number | undefined;
|
|
203
206
|
endpoint?: string | string[] | undefined;
|
|
204
207
|
block?: string | number | null | undefined;
|
|
@@ -34,8 +34,8 @@ export const cli = (y)=>{
|
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
const context = await setupContext(config, true);
|
|
37
|
-
const { close, port: listenPort } = await createServer(handler(context), config.port);
|
|
38
|
-
logger.info(`${await context.chain.api.getSystemChain()} RPC listening on
|
|
37
|
+
const { close, port: listenPort } = await createServer(handler(context), config.addr, config.port);
|
|
38
|
+
logger.info(`${await context.chain.api.getSystemChain()} RPC listening on ${config.addr}:${listenPort}`);
|
|
39
39
|
const chain = context.chain;
|
|
40
40
|
chain.api[config['head-mode'] === "Latest" ? 'subscribeRemoteNewHeads' : 'subscribeRemoteFinalizedHeads'](async (error, data)=>{
|
|
41
41
|
try {
|
|
@@ -4,6 +4,7 @@ import { ZodNativeEnum, ZodRawShape, ZodTypeAny, z } from 'zod';
|
|
|
4
4
|
export declare const zHex: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
|
|
5
5
|
export declare const zHash: z.ZodIntersection<z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>>;
|
|
6
6
|
export declare const configSchema: z.ZodObject<{
|
|
7
|
+
addr: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"localhost">, z.ZodString]>>;
|
|
7
8
|
port: z.ZodDefault<z.ZodNumber>;
|
|
8
9
|
endpoint: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
9
10
|
block: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodNull]>>;
|
|
@@ -142,6 +143,7 @@ export declare const configSchema: z.ZodObject<{
|
|
|
142
143
|
'process-queued-messages': z.ZodOptional<z.ZodBoolean>;
|
|
143
144
|
'prefetch-storages': z.ZodOptional<z.ZodAny>;
|
|
144
145
|
}, "strip", ZodTypeAny, {
|
|
146
|
+
addr: string;
|
|
145
147
|
port: number;
|
|
146
148
|
'build-block-mode': BuildBlockMode;
|
|
147
149
|
endpoint?: string | string[] | undefined;
|
|
@@ -188,6 +190,7 @@ export declare const configSchema: z.ZodObject<{
|
|
|
188
190
|
'process-queued-messages'?: boolean | undefined;
|
|
189
191
|
'prefetch-storages'?: any;
|
|
190
192
|
}, {
|
|
193
|
+
addr?: string | undefined;
|
|
191
194
|
port?: number | undefined;
|
|
192
195
|
endpoint?: string | string[] | undefined;
|
|
193
196
|
block?: string | number | null | undefined;
|
package/dist/esm/schema/index.js
CHANGED
|
@@ -8,8 +8,14 @@ import yaml from 'js-yaml';
|
|
|
8
8
|
export const zHex = z.custom((val)=>/^0x\w+$/.test(val));
|
|
9
9
|
export const zHash = z.string().length(66).and(zHex);
|
|
10
10
|
export const configSchema = z.object({
|
|
11
|
+
addr: z.union([
|
|
12
|
+
z.literal('localhost'),
|
|
13
|
+
z.string().ip()
|
|
14
|
+
], {
|
|
15
|
+
description: 'Server listening interface'
|
|
16
|
+
}).default('localhost'),
|
|
11
17
|
port: z.number({
|
|
12
|
-
description: '
|
|
18
|
+
description: 'Server listening port'
|
|
13
19
|
}).default(8000),
|
|
14
20
|
endpoint: z.union([
|
|
15
21
|
z.string(),
|
package/dist/esm/server.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type Handler = (data: {
|
|
|
3
3
|
method: string;
|
|
4
4
|
params: string[];
|
|
5
5
|
}, subscriptionManager: SubscriptionManager) => Promise<any>;
|
|
6
|
-
export declare const createServer: (handler: Handler, port: number) => Promise<{
|
|
6
|
+
export declare const createServer: (handler: Handler, addr: string, port: number) => Promise<{
|
|
7
7
|
port: number;
|
|
8
8
|
close: () => Promise<void>;
|
|
9
9
|
}>;
|
package/dist/esm/server.js
CHANGED
|
@@ -71,7 +71,7 @@ const portInUse = async (port)=>{
|
|
|
71
71
|
server.unref();
|
|
72
72
|
return inUse;
|
|
73
73
|
};
|
|
74
|
-
export const createServer = async (handler, port)=>{
|
|
74
|
+
export const createServer = async (handler, addr, port)=>{
|
|
75
75
|
let wss;
|
|
76
76
|
let listenPort;
|
|
77
77
|
const emptySubscriptionManager = {
|
|
@@ -149,7 +149,7 @@ export const createServer = async (handler, port)=>{
|
|
|
149
149
|
reject(e);
|
|
150
150
|
};
|
|
151
151
|
server.once('error', onError);
|
|
152
|
-
server.listen(preferPort, ()=>{
|
|
152
|
+
server.listen(preferPort, addr, ()=>{
|
|
153
153
|
wss = new WebSocketServer({
|
|
154
154
|
server,
|
|
155
155
|
maxPayload: 1024 * 1024 * 100
|
|
@@ -4,10 +4,12 @@ import { handler } from './rpc/index.js';
|
|
|
4
4
|
import { setupContext } from './context.js';
|
|
5
5
|
export const setupWithServer = async (argv)=>{
|
|
6
6
|
const context = await setupContext(argv);
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const addr = argv.addr ?? 'localhost';
|
|
8
|
+
const { close, port: listenPort } = await createServer(handler(context), addr, argv.port);
|
|
9
|
+
defaultLogger.info(`${await context.chain.api.getSystemChain()} RPC listening on ${addr}:${listenPort}`);
|
|
9
10
|
return {
|
|
10
11
|
...context,
|
|
12
|
+
addr: argv.addr,
|
|
11
13
|
listenPort,
|
|
12
14
|
async close () {
|
|
13
15
|
await context.chain.close();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { setStorage } from '@acala-network/chopsticks-core';
|
|
1
|
+
import { isUrl, setStorage } from '@acala-network/chopsticks-core';
|
|
2
2
|
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
+
import axios from 'axios';
|
|
3
4
|
import yaml from 'js-yaml';
|
|
4
5
|
import { defaultLogger } from '../logger.js';
|
|
5
6
|
export const overrideStorage = async (chain, storage, at)=>{
|
|
@@ -23,7 +24,15 @@ export const overrideWasm = async (chain, wasmPath, at)=>{
|
|
|
23
24
|
if (wasmPath == null) {
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
26
|
-
|
|
27
|
+
let wasm;
|
|
28
|
+
if (isUrl(wasmPath)) {
|
|
29
|
+
const res = await axios.get(wasmPath, {
|
|
30
|
+
responseType: 'arraybuffer'
|
|
31
|
+
});
|
|
32
|
+
wasm = res.data;
|
|
33
|
+
} else {
|
|
34
|
+
wasm = readFileSync(wasmPath);
|
|
35
|
+
}
|
|
27
36
|
let wasmHex;
|
|
28
37
|
if (wasm.at(0) === 0x30 && wasm.at(1) === 0x78) {
|
|
29
38
|
// starts with 0x
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acala-network/chopsticks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"author": "Acala Developers <hello@acala.network>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"bin": "./chopsticks.cjs",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"depcheck": "npx depcheck --ignore-patterns='*.test.ts'"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@acala-network/chopsticks-core": "0.
|
|
16
|
-
"@acala-network/chopsticks-db": "0.
|
|
15
|
+
"@acala-network/chopsticks-core": "0.16.0",
|
|
16
|
+
"@acala-network/chopsticks-db": "0.16.0",
|
|
17
17
|
"@pnpm/npm-conf": "^2.2.2",
|
|
18
18
|
"@polkadot/api": "^12.3.1",
|
|
19
19
|
"@polkadot/api-augment": "^12.3.1",
|