@acala-network/chopsticks 0.8.0-5 → 0.8.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/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/plugins/dry-run/rpc.js +16 -19
- package/lib/plugins/new-block/index.js +2 -1
- package/lib/plugins/set-runtime-log-level/index.d.ts +2 -0
- package/lib/plugins/set-runtime-log-level/index.js +13 -0
- package/lib/utils/index.d.ts +5 -0
- package/lib/utils/index.js +21 -0
- package/lib/utils/signFake.d.ts +6 -0
- package/lib/utils/signFake.js +23 -0
- package/package.json +5 -6
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.fetchConfig = exports.setupWithServer = void 0;
|
|
18
|
+
require("@polkadot/api-augment");
|
|
18
19
|
__exportStar(require("@acala-network/chopsticks-core"), exports);
|
|
19
20
|
var setup_with_server_1 = require("./setup-with-server");
|
|
20
21
|
Object.defineProperty(exports, "setupWithServer", { enumerable: true, get: function () { return setup_with_server_1.setupWithServer; } });
|
|
@@ -1,41 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.rpc = exports.name = void 0;
|
|
7
|
-
const zod_1 =
|
|
4
|
+
const zod_1 = require("zod");
|
|
8
5
|
const shared_1 = require("../../rpc/shared");
|
|
9
6
|
const decoder_1 = require("../../utils/decoder");
|
|
10
7
|
const generate_html_diff_1 = require("../../utils/generate-html-diff");
|
|
11
|
-
const zHex = zod_1.
|
|
12
|
-
const zHash = zod_1.
|
|
13
|
-
const zParaId = zod_1.
|
|
14
|
-
const schema = zod_1.
|
|
15
|
-
raw: zod_1.
|
|
16
|
-
html: zod_1.
|
|
8
|
+
const zHex = zod_1.z.custom((val) => /^0x\w+$/.test(val));
|
|
9
|
+
const zHash = zod_1.z.string().length(66).and(zHex);
|
|
10
|
+
const zParaId = zod_1.z.string().regex(/^\d+$/).transform(Number);
|
|
11
|
+
const schema = zod_1.z.object({
|
|
12
|
+
raw: zod_1.z.boolean().optional(),
|
|
13
|
+
html: zod_1.z.boolean().optional(),
|
|
17
14
|
extrinsic: zHex
|
|
18
|
-
.or(zod_1.
|
|
15
|
+
.or(zod_1.z.object({
|
|
19
16
|
call: zHex,
|
|
20
17
|
address: zHex,
|
|
21
18
|
}))
|
|
22
19
|
.optional(),
|
|
23
|
-
hrmp: zod_1.
|
|
24
|
-
.record(zParaId, zod_1.
|
|
25
|
-
.array(zod_1.
|
|
26
|
-
sentAt: zod_1.
|
|
20
|
+
hrmp: zod_1.z
|
|
21
|
+
.record(zParaId, zod_1.z
|
|
22
|
+
.array(zod_1.z.object({
|
|
23
|
+
sentAt: zod_1.z.number(),
|
|
27
24
|
data: zHex,
|
|
28
25
|
}))
|
|
29
26
|
.min(1))
|
|
30
27
|
.optional(),
|
|
31
|
-
dmp: zod_1.
|
|
32
|
-
.array(zod_1.
|
|
33
|
-
sentAt: zod_1.
|
|
28
|
+
dmp: zod_1.z
|
|
29
|
+
.array(zod_1.z.object({
|
|
30
|
+
sentAt: zod_1.z.number(),
|
|
34
31
|
msg: zHex,
|
|
35
32
|
}))
|
|
36
33
|
.min(1)
|
|
37
34
|
.optional(),
|
|
38
|
-
ump: zod_1.
|
|
35
|
+
ump: zod_1.z.record(zParaId, zod_1.z.array(zHex).min(1)).optional(),
|
|
39
36
|
at: zHash.optional(),
|
|
40
37
|
});
|
|
41
38
|
// custom rpc name (optional). e.g. dryRun will be called as dev_dryRun
|
|
@@ -4,7 +4,7 @@ exports.rpc = void 0;
|
|
|
4
4
|
const shared_1 = require("../../rpc/shared");
|
|
5
5
|
const logger_1 = require("../../logger");
|
|
6
6
|
const rpc = async (context, [param]) => {
|
|
7
|
-
const { count, to, hrmp, ump, dmp, transactions } = param || {};
|
|
7
|
+
const { count, to, hrmp, ump, dmp, transactions, unsafeBlockHeight } = param || {};
|
|
8
8
|
const now = context.chain.head.number;
|
|
9
9
|
const diff = to ? to - now : count;
|
|
10
10
|
const finalCount = diff > 0 ? diff : 1;
|
|
@@ -16,6 +16,7 @@ const rpc = async (context, [param]) => {
|
|
|
16
16
|
horizontalMessages: hrmp,
|
|
17
17
|
upwardMessages: ump,
|
|
18
18
|
downwardMessages: dmp,
|
|
19
|
+
unsafeBlockHeight: i === 0 ? unsafeBlockHeight : undefined,
|
|
19
20
|
})
|
|
20
21
|
.catch((error) => {
|
|
21
22
|
throw new shared_1.ResponseError(1, error.toString());
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rpc = void 0;
|
|
4
|
+
const shared_1 = require("../../rpc/shared");
|
|
5
|
+
const logger_1 = require("../../logger");
|
|
6
|
+
const rpc = async (context, [runtimeLogLevel]) => {
|
|
7
|
+
logger_1.defaultLogger.debug({ runtimeLogLevel }, 'dev_setRuntimeLogLevel');
|
|
8
|
+
if (typeof runtimeLogLevel !== 'number') {
|
|
9
|
+
throw new shared_1.ResponseError(1, `Invalid runtimeLogLevel ${runtimeLogLevel}`);
|
|
10
|
+
}
|
|
11
|
+
context.chain.runtimeLogLevel = runtimeLogLevel;
|
|
12
|
+
};
|
|
13
|
+
exports.rpc = rpc;
|
|
@@ -0,0 +1,21 @@
|
|
|
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);
|
|
21
|
+
__exportStar(require("./signFake"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ApiPromise } from '@polkadot/api';
|
|
2
|
+
import { GenericExtrinsic } from '@polkadot/types';
|
|
3
|
+
import { SignatureOptions } from '@polkadot/types/types';
|
|
4
|
+
export type SignFakeOptions = Partial<SignatureOptions>;
|
|
5
|
+
export declare const signFakeWithApi: (api: ApiPromise, tx: GenericExtrinsic, addr: string, options?: SignFakeOptions) => Promise<GenericExtrinsic<import("@polkadot/types/types").AnyTuple>>;
|
|
6
|
+
export declare const signFake: (tx: GenericExtrinsic, addr: string, options: SignatureOptions) => GenericExtrinsic<import("@polkadot/types/types").AnyTuple>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.signFake = exports.signFakeWithApi = void 0;
|
|
4
|
+
const signFakeWithApi = async (api, tx, addr, options = {}) => {
|
|
5
|
+
const nonce = options.nonce ?? (await api.query.system.account(addr)).nonce;
|
|
6
|
+
return (0, exports.signFake)(tx, addr, {
|
|
7
|
+
nonce,
|
|
8
|
+
genesisHash: api.genesisHash,
|
|
9
|
+
runtimeVersion: api.runtimeVersion,
|
|
10
|
+
blockHash: api.genesisHash,
|
|
11
|
+
...options,
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
exports.signFakeWithApi = signFakeWithApi;
|
|
15
|
+
const signFake = (tx, addr, options) => {
|
|
16
|
+
const mockSignature = new Uint8Array(64);
|
|
17
|
+
mockSignature.fill(0xcd);
|
|
18
|
+
mockSignature.set([0xde, 0xad, 0xbe, 0xef]);
|
|
19
|
+
tx.signFake(addr, options);
|
|
20
|
+
tx.signature.set(mockSignature);
|
|
21
|
+
return tx;
|
|
22
|
+
};
|
|
23
|
+
exports.signFake = signFake;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acala-network/chopsticks",
|
|
3
|
-
"version": "0.8.0
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"author": "Bryan Chen <xlchen1291@gmail.com>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"bin": "./chopsticks.js",
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"dev:moonbeam": "cd ../..; ts-node-dev --transpile-only --inspect -r tsconfig-paths/register --notify=false packages/chopsticks/src/cli.ts -- --config=configs/moonbeam.yml"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@acala-network/chopsticks-core": "0.8.0
|
|
19
|
+
"@acala-network/chopsticks-core": "0.8.0",
|
|
20
20
|
"@pnpm/npm-conf": "^2.2.2",
|
|
21
21
|
"@polkadot/api": "^10.9.1",
|
|
22
|
-
"axios": "^1.
|
|
22
|
+
"axios": "^1.5.0",
|
|
23
23
|
"dotenv": "^16.3.1",
|
|
24
24
|
"global-agent": "^3.0.0",
|
|
25
25
|
"js-yaml": "^4.1.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@types/global-agent": "^2.1.1",
|
|
34
34
|
"@types/js-yaml": "^4.0.5",
|
|
35
35
|
"@types/lodash": "^4.14.197",
|
|
36
|
-
"@types/node": "^20.5.
|
|
36
|
+
"@types/node": "^20.5.7",
|
|
37
37
|
"@types/ws": "^8.5.5",
|
|
38
38
|
"@types/yargs": "^17.0.24",
|
|
39
39
|
"ts-node": "^10.9.1",
|
|
@@ -57,6 +57,5 @@
|
|
|
57
57
|
"default": "./lib/*.js"
|
|
58
58
|
},
|
|
59
59
|
"./package.json": "./package.json"
|
|
60
|
-
}
|
|
61
|
-
"stableVersion": "0.7.3"
|
|
60
|
+
}
|
|
62
61
|
}
|