@acala-network/chopsticks 0.7.2 → 0.8.0-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/cli-options.d.ts +40 -0
- package/lib/cli-options.js +43 -0
- package/lib/cli.d.ts +1 -2
- package/lib/cli.js +20 -183
- package/lib/context.d.ts +5 -0
- package/lib/context.js +37 -0
- package/lib/index.d.ts +2 -7
- package/lib/index.js +4 -15
- package/lib/logger.d.ts +1 -7
- package/lib/logger.js +3 -38
- package/lib/plugins/decode-key/index.d.ts +2 -0
- package/lib/plugins/decode-key/index.js +27 -0
- package/lib/plugins/dry-run/cli.d.ts +2 -0
- package/lib/plugins/dry-run/cli.js +46 -0
- package/lib/plugins/dry-run/dry-run-extrinsic.d.ts +2 -0
- package/lib/{dry-run.js → plugins/dry-run/dry-run-extrinsic.js} +8 -8
- package/lib/{dry-run-preimage.d.ts → plugins/dry-run/dry-run-preimage.d.ts} +1 -1
- package/lib/{dry-run-preimage.js → plugins/dry-run/dry-run-preimage.js} +10 -12
- package/lib/plugins/dry-run/index.d.ts +2 -0
- package/lib/plugins/dry-run/index.js +18 -0
- package/lib/plugins/dry-run/rpc.d.ts +3 -0
- package/lib/{rpc/dev/dry-run.js → plugins/dry-run/rpc.js} +10 -7
- package/lib/plugins/index.d.ts +4 -0
- package/lib/plugins/index.js +52 -0
- package/lib/plugins/new-block/index.d.ts +2 -0
- package/lib/plugins/new-block/index.js +28 -0
- package/lib/plugins/run-block/index.d.ts +2 -0
- package/lib/plugins/run-block/index.js +67 -0
- package/lib/plugins/set-block-build-mode/index.d.ts +2 -0
- package/lib/plugins/set-block-build-mode/index.js +14 -0
- package/lib/plugins/set-head/index.d.ts +2 -0
- package/lib/plugins/set-head/index.js +20 -0
- package/lib/plugins/set-storage/index.d.ts +2 -0
- package/lib/plugins/set-storage/index.js +18 -0
- package/lib/plugins/time-travel/index.d.ts +2 -0
- package/lib/plugins/time-travel/index.js +13 -0
- package/lib/plugins/try-runtime/index.d.ts +2 -0
- package/lib/plugins/try-runtime/index.js +58 -0
- package/lib/rpc/index.d.ts +1 -1
- package/lib/rpc/index.js +11 -4
- package/lib/rpc/shared.d.ts +1 -1
- package/lib/rpc/shared.js +1 -1
- package/lib/rpc/substrate/author.js +3 -3
- package/lib/schema/index.d.ts +9 -66
- package/lib/schema/index.js +41 -14
- package/lib/server.js +2 -1
- package/lib/setup-with-server.d.ts +1 -3
- package/lib/setup-with-server.js +2 -2
- package/lib/utils/decoder.d.ts +1 -1
- package/lib/utils/generate-html-diff.d.ts +1 -1
- package/lib/utils/override.d.ts +4 -0
- package/lib/utils/{import-storage.js → override.js} +6 -6
- package/package.json +13 -16
- package/lib/api.d.ts +0 -43
- package/lib/api.js +0 -79
- package/lib/blockchain/block-builder.d.ts +0 -10
- package/lib/blockchain/block-builder.js +0 -297
- package/lib/blockchain/block.d.ts +0 -45
- package/lib/blockchain/block.js +0 -194
- package/lib/blockchain/head-state.d.ts +0 -15
- package/lib/blockchain/head-state.js +0 -71
- package/lib/blockchain/index.d.ts +0 -64
- package/lib/blockchain/index.js +0 -243
- package/lib/blockchain/inherent/index.d.ts +0 -19
- package/lib/blockchain/inherent/index.js +0 -36
- package/lib/blockchain/inherent/para-enter.d.ts +0 -7
- package/lib/blockchain/inherent/para-enter.js +0 -33
- package/lib/blockchain/inherent/parachain/babe-randomness.d.ts +0 -7
- package/lib/blockchain/inherent/parachain/babe-randomness.js +0 -15
- package/lib/blockchain/inherent/parachain/nimbus-author-inherent.d.ts +0 -7
- package/lib/blockchain/inherent/parachain/nimbus-author-inherent.js +0 -15
- package/lib/blockchain/inherent/parachain/validation-data.d.ts +0 -19
- package/lib/blockchain/inherent/parachain/validation-data.js +0 -172
- package/lib/blockchain/storage-layer.d.ts +0 -32
- package/lib/blockchain/storage-layer.js +0 -200
- package/lib/blockchain/txpool.d.ts +0 -45
- package/lib/blockchain/txpool.js +0 -184
- package/lib/db/entities.d.ts +0 -5
- package/lib/db/entities.js +0 -33
- package/lib/db/index.d.ts +0 -3
- package/lib/db/index.js +0 -41
- package/lib/dry-run.d.ts +0 -2
- package/lib/executor.d.ts +0 -40
- package/lib/executor.js +0 -131
- package/lib/genesis-provider.d.ts +0 -44
- package/lib/genesis-provider.js +0 -155
- package/lib/offchain.d.ts +0 -10
- package/lib/offchain.js +0 -37
- package/lib/rpc/dev/dry-run.d.ts +0 -2
- package/lib/rpc/dev/index.d.ts +0 -3
- package/lib/rpc/dev/index.js +0 -75
- package/lib/run-block.d.ts +0 -2
- package/lib/run-block.js +0 -51
- package/lib/setup.d.ts +0 -11
- package/lib/setup.js +0 -86
- package/lib/try-runtime.d.ts +0 -2
- package/lib/try-runtime.js +0 -36
- package/lib/utils/import-storage.d.ts +0 -5
- package/lib/utils/index.d.ts +0 -16
- package/lib/utils/index.js +0 -59
- package/lib/utils/key-cache.d.ts +0 -10
- package/lib/utils/key-cache.js +0 -66
- package/lib/utils/proof.d.ts +0 -15
- package/lib/utils/proof.js +0 -41
- package/lib/utils/set-storage.d.ts +0 -7
- package/lib/utils/set-storage.js +0 -59
- package/lib/utils/time-travel.d.ts +0 -5
- package/lib/utils/time-travel.js +0 -65
- package/lib/xcm/downward.d.ts +0 -2
- package/lib/xcm/downward.js +0 -29
- package/lib/xcm/horizontal.d.ts +0 -2
- package/lib/xcm/horizontal.js +0 -29
- package/lib/xcm/index.d.ts +0 -9
- package/lib/xcm/index.js +0 -25
- package/lib/xcm/upward.d.ts +0 -2
- package/lib/xcm/upward.js +0 -21
package/lib/utils/time-travel.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.timeTravel = exports.getSlotDuration = exports.getCurrentTimestamp = exports.getCurrentSlot = void 0;
|
|
4
|
-
const util_1 = require("@polkadot/util");
|
|
5
|
-
const _1 = require(".");
|
|
6
|
-
const executor_1 = require("../executor");
|
|
7
|
-
const set_storage_1 = require("./set-storage");
|
|
8
|
-
const getCurrentSlot = async (chain) => {
|
|
9
|
-
const meta = await chain.head.meta;
|
|
10
|
-
// use raw key here because some chain did not expose those storage to metadata
|
|
11
|
-
const slotRaw = meta.consts.babe
|
|
12
|
-
? await chain.head.get('0x1cb6f36e027abb2091cfb5110ab5087f06155b3cd9a8c9e5e9a23fd5dc13a5ed') // babe.currentSlot
|
|
13
|
-
: await chain.head.get('0x57f8dc2f5ab09467896f47300f04243806155b3cd9a8c9e5e9a23fd5dc13a5ed'); // aura.currentSlot
|
|
14
|
-
if (!slotRaw)
|
|
15
|
-
throw new Error('Cannot find current slot');
|
|
16
|
-
return meta.registry.createType('Slot', (0, util_1.hexToU8a)(slotRaw)).toNumber();
|
|
17
|
-
};
|
|
18
|
-
exports.getCurrentSlot = getCurrentSlot;
|
|
19
|
-
const getCurrentTimestamp = async (chain) => {
|
|
20
|
-
const meta = await chain.head.meta;
|
|
21
|
-
const currentTimestampRaw = (await chain.head.get((0, _1.compactHex)(meta.query.timestamp.now()))) || '0x';
|
|
22
|
-
return meta.registry.createType('u64', (0, util_1.hexToU8a)(currentTimestampRaw)).toNumber();
|
|
23
|
-
};
|
|
24
|
-
exports.getCurrentTimestamp = getCurrentTimestamp;
|
|
25
|
-
const getSlotDuration = async (chain) => {
|
|
26
|
-
const meta = await chain.head.meta;
|
|
27
|
-
return meta.consts.babe
|
|
28
|
-
? meta.consts.babe.expectedBlockTime.toNumber()
|
|
29
|
-
: meta.query.aura
|
|
30
|
-
? (0, executor_1.getAuraSlotDuration)(await chain.head.wasm, meta.registry)
|
|
31
|
-
: 12_000;
|
|
32
|
-
};
|
|
33
|
-
exports.getSlotDuration = getSlotDuration;
|
|
34
|
-
const timeTravel = async (chain, timestamp) => {
|
|
35
|
-
const meta = await chain.head.meta;
|
|
36
|
-
const slotDuration = await (0, exports.getSlotDuration)(chain);
|
|
37
|
-
const newSlot = Math.floor(timestamp / slotDuration);
|
|
38
|
-
// new timestamp
|
|
39
|
-
const storage = [
|
|
40
|
-
[(0, _1.compactHex)(meta.query.timestamp.now()), (0, util_1.u8aToHex)(meta.registry.createType('u64', timestamp).toU8a())],
|
|
41
|
-
];
|
|
42
|
-
if (meta.consts.babe) {
|
|
43
|
-
// new slot
|
|
44
|
-
storage.push([
|
|
45
|
-
(0, _1.compactHex)(meta.query.babe.currentSlot()),
|
|
46
|
-
(0, util_1.u8aToHex)(meta.registry.createType('Slot', newSlot).toU8a()),
|
|
47
|
-
]);
|
|
48
|
-
// new epoch
|
|
49
|
-
const epochDuration = meta.consts.babe.epochDuration.toNumber();
|
|
50
|
-
const newEpoch = Math.floor(timestamp / epochDuration);
|
|
51
|
-
storage.push([
|
|
52
|
-
(0, _1.compactHex)(meta.query.babe.epochIndex()),
|
|
53
|
-
(0, util_1.u8aToHex)(meta.registry.createType('u64', newEpoch).toU8a()),
|
|
54
|
-
]);
|
|
55
|
-
}
|
|
56
|
-
else if (meta.query.aura) {
|
|
57
|
-
// new slot
|
|
58
|
-
storage.push([
|
|
59
|
-
(0, _1.compactHex)(meta.query.aura.currentSlot()),
|
|
60
|
-
(0, util_1.u8aToHex)(meta.registry.createType('Slot', newSlot).toU8a()),
|
|
61
|
-
]);
|
|
62
|
-
}
|
|
63
|
-
await (0, set_storage_1.setStorage)(chain, storage);
|
|
64
|
-
};
|
|
65
|
-
exports.timeTravel = timeTravel;
|
package/lib/xcm/downward.d.ts
DELETED
package/lib/xcm/downward.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.connectDownward = void 0;
|
|
4
|
-
const util_1 = require("@polkadot/util");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
const _1 = require(".");
|
|
7
|
-
const set_storage_1 = require("../utils/set-storage");
|
|
8
|
-
const connectDownward = async (relaychain, parachain) => {
|
|
9
|
-
const meta = await relaychain.head.meta;
|
|
10
|
-
const paraId = await (0, utils_1.getParaId)(parachain);
|
|
11
|
-
const downwardMessageQueuesKey = (0, utils_1.compactHex)(meta.query.dmp.downwardMessageQueues(paraId));
|
|
12
|
-
await relaychain.headState.subscribeStorage([downwardMessageQueuesKey], async (head, pairs) => {
|
|
13
|
-
const value = pairs[0][1];
|
|
14
|
-
if (!value)
|
|
15
|
-
return;
|
|
16
|
-
const meta = await head.meta;
|
|
17
|
-
const downwardMessageQueuesKey = (0, utils_1.compactHex)(meta.query.dmp.downwardMessageQueues(paraId));
|
|
18
|
-
// clear relaychain message queue
|
|
19
|
-
await (0, set_storage_1.setStorage)(relaychain, [[downwardMessageQueuesKey, null]], head.hash);
|
|
20
|
-
const downwardMessages = meta.registry
|
|
21
|
-
.createType('Vec<PolkadotCorePrimitivesInboundDownwardMessage>', (0, util_1.hexToU8a)(value))
|
|
22
|
-
.toJSON();
|
|
23
|
-
if (downwardMessages.length === 0)
|
|
24
|
-
return;
|
|
25
|
-
_1.logger.debug({ downwardMessages }, 'downward_message');
|
|
26
|
-
parachain.submitDownwardMessages(downwardMessages);
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
exports.connectDownward = connectDownward;
|
package/lib/xcm/horizontal.d.ts
DELETED
package/lib/xcm/horizontal.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.connectHorizontal = void 0;
|
|
4
|
-
const util_1 = require("@polkadot/util");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
const _1 = require(".");
|
|
7
|
-
const connectHorizontal = async (parachains) => {
|
|
8
|
-
for (const [id, chain] of Object.entries(parachains)) {
|
|
9
|
-
const meta = await chain.head.meta;
|
|
10
|
-
const hrmpOutboundMessagesKey = (0, utils_1.compactHex)(meta.query.parachainSystem.hrmpOutboundMessages());
|
|
11
|
-
await chain.headState.subscribeStorage([hrmpOutboundMessagesKey], async (head, pairs) => {
|
|
12
|
-
const value = pairs[0][1];
|
|
13
|
-
if (!value)
|
|
14
|
-
return;
|
|
15
|
-
const meta = await head.meta;
|
|
16
|
-
const outboundHrmpMessage = meta.registry
|
|
17
|
-
.createType('Vec<PolkadotCorePrimitivesOutboundHrmpMessage>', (0, util_1.hexToU8a)(value))
|
|
18
|
-
.toJSON();
|
|
19
|
-
_1.logger.info({ outboundHrmpMessage }, 'outboundHrmpMessage');
|
|
20
|
-
for (const { recipient, data } of outboundHrmpMessage) {
|
|
21
|
-
const receiver = parachains[recipient];
|
|
22
|
-
if (receiver) {
|
|
23
|
-
receiver.submitHorizontalMessages(Number(id), [{ sentAt: head.number, data }]);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
exports.connectHorizontal = connectHorizontal;
|
package/lib/xcm/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Blockchain } from '../blockchain';
|
|
2
|
-
export declare const logger: import("pino").default.Logger<{
|
|
3
|
-
level: string;
|
|
4
|
-
transport: {
|
|
5
|
-
target: string;
|
|
6
|
-
};
|
|
7
|
-
}>;
|
|
8
|
-
export declare const connectVertical: (relaychain: Blockchain, parachain: Blockchain) => Promise<void>;
|
|
9
|
-
export declare const connectParachains: (parachains: Blockchain[]) => Promise<void>;
|
package/lib/xcm/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.connectParachains = exports.connectVertical = exports.logger = void 0;
|
|
4
|
-
const downward_1 = require("./downward");
|
|
5
|
-
const horizontal_1 = require("./horizontal");
|
|
6
|
-
const upward_1 = require("./upward");
|
|
7
|
-
const logger_1 = require("../logger");
|
|
8
|
-
const utils_1 = require("../utils");
|
|
9
|
-
exports.logger = logger_1.defaultLogger.child({ name: 'xcm' });
|
|
10
|
-
const connectVertical = async (relaychain, parachain) => {
|
|
11
|
-
await (0, downward_1.connectDownward)(relaychain, parachain);
|
|
12
|
-
await (0, upward_1.connectUpward)(parachain, relaychain);
|
|
13
|
-
exports.logger.info(`Connected relaychain '${await relaychain.api.getSystemChain()}' with parachain '${await parachain.api.getSystemChain()}'`);
|
|
14
|
-
};
|
|
15
|
-
exports.connectVertical = connectVertical;
|
|
16
|
-
const connectParachains = async (parachains) => {
|
|
17
|
-
const list = {};
|
|
18
|
-
for (const chain of parachains) {
|
|
19
|
-
const paraId = await (0, utils_1.getParaId)(chain);
|
|
20
|
-
list[paraId.toNumber()] = chain;
|
|
21
|
-
}
|
|
22
|
-
await (0, horizontal_1.connectHorizontal)(list);
|
|
23
|
-
exports.logger.info(`Connected parachains [${Object.keys(list)}]`);
|
|
24
|
-
};
|
|
25
|
-
exports.connectParachains = connectParachains;
|
package/lib/xcm/upward.d.ts
DELETED
package/lib/xcm/upward.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.connectUpward = void 0;
|
|
4
|
-
const util_1 = require("@polkadot/util");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
const connectUpward = async (parachain, relaychain) => {
|
|
7
|
-
const meta = await parachain.head.meta;
|
|
8
|
-
const paraId = (await (0, utils_1.getParaId)(parachain)).toNumber();
|
|
9
|
-
const upwardMessagesKey = (0, utils_1.compactHex)(meta.query.parachainSystem.upwardMessages());
|
|
10
|
-
await parachain.headState.subscribeStorage([upwardMessagesKey], async (_head, pairs) => {
|
|
11
|
-
const value = pairs[0][1];
|
|
12
|
-
if (!value)
|
|
13
|
-
return;
|
|
14
|
-
const meta = await relaychain.head.meta;
|
|
15
|
-
const upwardMessages = meta.registry.createType('Vec<Bytes>', (0, util_1.hexToU8a)(value));
|
|
16
|
-
if (upwardMessages.length === 0)
|
|
17
|
-
return;
|
|
18
|
-
relaychain.submitUpwardMessages(paraId, upwardMessages.map((x) => x.toHex()));
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
exports.connectUpward = connectUpward;
|