@acala-network/chopsticks 0.5.5 → 0.5.7
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/api.js +5 -1
- package/lib/blockchain/block-builder.js +43 -36
- package/lib/blockchain/block.js +28 -24
- package/lib/blockchain/head-state.js +14 -9
- package/lib/blockchain/index.js +28 -24
- package/lib/blockchain/inherent/index.js +20 -11
- package/lib/blockchain/inherent/para-enter.js +7 -3
- package/lib/blockchain/inherent/parachain/babe-randomness.js +7 -3
- package/lib/blockchain/inherent/parachain/nimbus-author-inherent.js +7 -3
- package/lib/blockchain/inherent/parachain/validation-data.js +33 -26
- package/lib/blockchain/storage-layer.js +16 -8
- package/lib/blockchain/txpool.js +20 -13
- package/lib/cli.js +35 -30
- package/lib/db/entities.js +9 -6
- package/lib/db/index.js +32 -5
- package/lib/dry-run-preimage.js +27 -23
- package/lib/dry-run.js +16 -12
- package/lib/executor.js +36 -24
- package/lib/genesis-provider.js +24 -17
- package/lib/index.js +31 -7
- package/lib/logger.js +10 -3
- package/lib/rpc/dev/dry-run.js +28 -21
- package/lib/rpc/dev/index.js +16 -14
- package/lib/rpc/index.js +16 -9
- package/lib/rpc/shared.js +7 -3
- package/lib/rpc/substrate/author.js +10 -8
- package/lib/rpc/substrate/chain.js +7 -5
- package/lib/rpc/substrate/index.js +16 -11
- package/lib/rpc/substrate/payment.js +9 -7
- package/lib/rpc/substrate/state.js +7 -5
- package/lib/rpc/substrate/system.js +11 -6
- package/lib/run-block.js +16 -12
- package/lib/schema/index.js +25 -22
- package/lib/server.js +35 -8
- package/lib/setup-with-server.js +12 -8
- package/lib/setup.js +30 -26
- package/lib/utils/decoder.js +25 -16
- package/lib/utils/generate-html-diff.js +20 -12
- package/lib/utils/import-storage.js +19 -11
- package/lib/utils/index.js +19 -10
- package/lib/utils/open-html.js +7 -3
- package/lib/utils/proof.js +17 -9
- package/lib/utils/set-storage.js +14 -10
- package/lib/utils/time-travel.js +28 -21
- package/lib/xcm/downward.js +15 -11
- package/lib/xcm/horizontal.js +11 -7
- package/lib/xcm/index.js +19 -14
- package/lib/xcm/upward.js +10 -6
- package/package.json +2 -2
package/lib/utils/proof.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hrmpChannels = exports.hrmpEgressChannelIndex = exports.hrmpIngressChannelIndex = exports.upgradeGoAheadSignal = exports.dmqMqcHead = exports.WELL_KNOWN_KEYS = void 0;
|
|
4
|
+
const util_1 = require("@polkadot/util");
|
|
5
|
+
const util_crypto_1 = require("@polkadot/util-crypto");
|
|
6
|
+
exports.WELL_KNOWN_KEYS = {
|
|
4
7
|
EPOCH_INDEX: '0x1cb6f36e027abb2091cfb5110ab5087f38316cbf8fa0da822a20ac1c55bf1be3',
|
|
5
8
|
CURRENT_BLOCK_RANDOMNESS: '0x1cb6f36e027abb2091cfb5110ab5087fd077dfdb8adb10f78f10a5df8742c545',
|
|
6
9
|
ONE_EPOCH_AGO_RANDOMNESS: '0x1cb6f36e027abb2091cfb5110ab5087f7ce678799d3eff024253b90e84927cc6',
|
|
@@ -9,25 +12,30 @@ export const WELL_KNOWN_KEYS = {
|
|
|
9
12
|
ACTIVE_CONFIG: '0x06de3d8a54d27e44a9d5ce189618f22db4b49d95320d9021994c850f25b8e385',
|
|
10
13
|
};
|
|
11
14
|
const hash = (prefix, suffix) => {
|
|
12
|
-
return u8aToHex(u8aConcat(hexToU8a(prefix), xxhashAsU8a(suffix, 64), suffix));
|
|
15
|
+
return (0, util_1.u8aToHex)((0, util_1.u8aConcat)((0, util_1.hexToU8a)(prefix), (0, util_crypto_1.xxhashAsU8a)(suffix, 64), suffix));
|
|
13
16
|
};
|
|
14
|
-
|
|
17
|
+
const dmqMqcHead = (paraId) => {
|
|
15
18
|
const prefix = '0x63f78c98723ddc9073523ef3beefda0c4d7fefc408aac59dbfe80a72ac8e3ce5';
|
|
16
19
|
return hash(prefix, paraId.toU8a());
|
|
17
20
|
};
|
|
18
|
-
|
|
21
|
+
exports.dmqMqcHead = dmqMqcHead;
|
|
22
|
+
const upgradeGoAheadSignal = (paraId) => {
|
|
19
23
|
const prefix = '0xcd710b30bd2eab0352ddcc26417aa1949e94c040f5e73d9b7addd6cb603d15d3';
|
|
20
24
|
return hash(prefix, paraId.toU8a());
|
|
21
25
|
};
|
|
22
|
-
|
|
26
|
+
exports.upgradeGoAheadSignal = upgradeGoAheadSignal;
|
|
27
|
+
const hrmpIngressChannelIndex = (paraId) => {
|
|
23
28
|
const prefix = '0x6a0da05ca59913bc38a8630590f2627c1d3719f5b0b12c7105c073c507445948';
|
|
24
29
|
return hash(prefix, paraId.toU8a());
|
|
25
30
|
};
|
|
26
|
-
|
|
31
|
+
exports.hrmpIngressChannelIndex = hrmpIngressChannelIndex;
|
|
32
|
+
const hrmpEgressChannelIndex = (paraId) => {
|
|
27
33
|
const prefix = '0x6a0da05ca59913bc38a8630590f2627cf12b746dcf32e843354583c9702cc020';
|
|
28
34
|
return hash(prefix, paraId.toU8a());
|
|
29
35
|
};
|
|
30
|
-
|
|
36
|
+
exports.hrmpEgressChannelIndex = hrmpEgressChannelIndex;
|
|
37
|
+
const hrmpChannels = (channelId) => {
|
|
31
38
|
const prefix = '0x6a0da05ca59913bc38a8630590f2627cb6604cff828a6e3f579ca6c59ace013d';
|
|
32
39
|
return hash(prefix, channelId.toU8a());
|
|
33
40
|
};
|
|
41
|
+
exports.hrmpChannels = hrmpChannels;
|
package/lib/utils/set-storage.js
CHANGED
|
@@ -1,36 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setStorage = void 0;
|
|
4
|
+
const types_1 = require("@polkadot/types");
|
|
5
|
+
const string_1 = require("@polkadot/util/string");
|
|
6
|
+
const util_1 = require("@polkadot/util");
|
|
4
7
|
function objectToStorageItems(meta, storage) {
|
|
5
8
|
const storageItems = [];
|
|
6
9
|
for (const sectionName in storage) {
|
|
7
10
|
const section = storage[sectionName];
|
|
8
|
-
const pallet = meta.query[stringCamelCase(sectionName)];
|
|
11
|
+
const pallet = meta.query[(0, string_1.stringCamelCase)(sectionName)];
|
|
9
12
|
if (!pallet)
|
|
10
13
|
throw Error(`Cannot find pallet ${sectionName}`);
|
|
11
14
|
for (const storageName in section) {
|
|
12
15
|
const storage = section[storageName];
|
|
13
16
|
if (storageName === '$removePrefix') {
|
|
14
17
|
for (const mapName of storage) {
|
|
15
|
-
const storageEntry = pallet[stringCamelCase(mapName)];
|
|
18
|
+
const storageEntry = pallet[(0, string_1.stringCamelCase)(mapName)];
|
|
16
19
|
if (!storageEntry)
|
|
17
20
|
throw Error(`Cannot find storage ${mapName} in pallet ${sectionName}`);
|
|
18
21
|
const prefix = storageEntry.keyPrefix();
|
|
19
|
-
storageItems.push([u8aToHex(prefix), "DeletedPrefix" /* StorageValueKind.DeletedPrefix */]);
|
|
22
|
+
storageItems.push([(0, util_1.u8aToHex)(prefix), "DeletedPrefix" /* StorageValueKind.DeletedPrefix */]);
|
|
20
23
|
}
|
|
21
24
|
continue;
|
|
22
25
|
}
|
|
23
|
-
const storageEntry = pallet[stringCamelCase(storageName)];
|
|
26
|
+
const storageEntry = pallet[(0, string_1.stringCamelCase)(storageName)];
|
|
24
27
|
if (!storageEntry)
|
|
25
28
|
throw Error(`Cannot find storage ${storageName} in pallet ${sectionName}`);
|
|
26
29
|
if (storageEntry.meta.type.isPlain) {
|
|
27
|
-
const key = new StorageKey(meta.registry, [storageEntry]);
|
|
30
|
+
const key = new types_1.StorageKey(meta.registry, [storageEntry]);
|
|
28
31
|
const type = storageEntry.meta.modifier.isOptional ? `Option<${key.outputType}>` : key.outputType;
|
|
29
32
|
storageItems.push([key.toHex(), storage ? meta.registry.createType(type, storage).toHex() : null]);
|
|
30
33
|
}
|
|
31
34
|
else {
|
|
32
35
|
for (const [keys, value] of storage) {
|
|
33
|
-
const key = new StorageKey(meta.registry, [storageEntry, keys]);
|
|
36
|
+
const key = new types_1.StorageKey(meta.registry, [storageEntry, keys]);
|
|
34
37
|
const type = storageEntry.meta.modifier.isOptional ? `Option<${key.outputType}>` : key.outputType;
|
|
35
38
|
storageItems.push([key.toHex(), value ? meta.registry.createType(type, value).toHex() : null]);
|
|
36
39
|
}
|
|
@@ -39,7 +42,7 @@ function objectToStorageItems(meta, storage) {
|
|
|
39
42
|
}
|
|
40
43
|
return storageItems;
|
|
41
44
|
}
|
|
42
|
-
|
|
45
|
+
const setStorage = async (chain, storage, blockHash) => {
|
|
43
46
|
const block = await chain.getBlock(blockHash);
|
|
44
47
|
if (!block)
|
|
45
48
|
throw Error(`Cannot find block ${blockHash || 'latest'}`);
|
|
@@ -53,3 +56,4 @@ export const setStorage = async (chain, storage, blockHash) => {
|
|
|
53
56
|
block.pushStorageLayer().setAll(storageItems);
|
|
54
57
|
return block.hash;
|
|
55
58
|
};
|
|
59
|
+
exports.setStorage = setStorage;
|
package/lib/utils/time-travel.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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) => {
|
|
6
9
|
const meta = await chain.head.meta;
|
|
7
10
|
// use raw key here because some chain did not expose those storage to metadata
|
|
8
11
|
const slotRaw = meta.consts.babe
|
|
@@ -10,49 +13,53 @@ export const getCurrentSlot = async (chain) => {
|
|
|
10
13
|
: await chain.head.get('0x57f8dc2f5ab09467896f47300f04243806155b3cd9a8c9e5e9a23fd5dc13a5ed'); // aura.currentSlot
|
|
11
14
|
if (!slotRaw)
|
|
12
15
|
throw new Error('Cannot find current slot');
|
|
13
|
-
return meta.registry.createType('Slot', hexToU8a(slotRaw)).toNumber();
|
|
16
|
+
return meta.registry.createType('Slot', (0, util_1.hexToU8a)(slotRaw)).toNumber();
|
|
14
17
|
};
|
|
15
|
-
|
|
18
|
+
exports.getCurrentSlot = getCurrentSlot;
|
|
19
|
+
const getCurrentTimestamp = async (chain) => {
|
|
16
20
|
const meta = await chain.head.meta;
|
|
17
|
-
const currentTimestampRaw = (await chain.head.get(compactHex(meta.query.timestamp.now()))) || '0x';
|
|
18
|
-
return meta.registry.createType('u64', hexToU8a(currentTimestampRaw)).toNumber();
|
|
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();
|
|
19
23
|
};
|
|
20
|
-
|
|
24
|
+
exports.getCurrentTimestamp = getCurrentTimestamp;
|
|
25
|
+
const getSlotDuration = async (chain) => {
|
|
21
26
|
const meta = await chain.head.meta;
|
|
22
27
|
return meta.consts.babe
|
|
23
28
|
? meta.consts.babe.expectedBlockTime.toNumber()
|
|
24
29
|
: meta.query.aura
|
|
25
|
-
? getAuraSlotDuration(await chain.head.wasm, meta.registry)
|
|
30
|
+
? (0, executor_1.getAuraSlotDuration)(await chain.head.wasm, meta.registry)
|
|
26
31
|
: 12_000;
|
|
27
32
|
};
|
|
28
|
-
|
|
33
|
+
exports.getSlotDuration = getSlotDuration;
|
|
34
|
+
const timeTravel = async (chain, timestamp) => {
|
|
29
35
|
const meta = await chain.head.meta;
|
|
30
|
-
const slotDuration = await getSlotDuration(chain);
|
|
36
|
+
const slotDuration = await (0, exports.getSlotDuration)(chain);
|
|
31
37
|
const newSlot = Math.floor(timestamp / slotDuration);
|
|
32
38
|
// new timestamp
|
|
33
39
|
const storage = [
|
|
34
|
-
[compactHex(meta.query.timestamp.now()), u8aToHex(meta.registry.createType('u64', timestamp).toU8a())],
|
|
40
|
+
[(0, _1.compactHex)(meta.query.timestamp.now()), (0, util_1.u8aToHex)(meta.registry.createType('u64', timestamp).toU8a())],
|
|
35
41
|
];
|
|
36
42
|
if (meta.consts.babe) {
|
|
37
43
|
// new slot
|
|
38
44
|
storage.push([
|
|
39
|
-
compactHex(meta.query.babe.currentSlot()),
|
|
40
|
-
u8aToHex(meta.registry.createType('Slot', newSlot).toU8a()),
|
|
45
|
+
(0, _1.compactHex)(meta.query.babe.currentSlot()),
|
|
46
|
+
(0, util_1.u8aToHex)(meta.registry.createType('Slot', newSlot).toU8a()),
|
|
41
47
|
]);
|
|
42
48
|
// new epoch
|
|
43
49
|
const epochDuration = meta.consts.babe.epochDuration.toNumber();
|
|
44
50
|
const newEpoch = Math.floor(timestamp / epochDuration);
|
|
45
51
|
storage.push([
|
|
46
|
-
compactHex(meta.query.babe.epochIndex()),
|
|
47
|
-
u8aToHex(meta.registry.createType('u64', newEpoch).toU8a()),
|
|
52
|
+
(0, _1.compactHex)(meta.query.babe.epochIndex()),
|
|
53
|
+
(0, util_1.u8aToHex)(meta.registry.createType('u64', newEpoch).toU8a()),
|
|
48
54
|
]);
|
|
49
55
|
}
|
|
50
56
|
else if (meta.query.aura) {
|
|
51
57
|
// new slot
|
|
52
58
|
storage.push([
|
|
53
|
-
compactHex(meta.query.aura.currentSlot()),
|
|
54
|
-
u8aToHex(meta.registry.createType('Slot', newSlot).toU8a()),
|
|
59
|
+
(0, _1.compactHex)(meta.query.aura.currentSlot()),
|
|
60
|
+
(0, util_1.u8aToHex)(meta.registry.createType('Slot', newSlot).toU8a()),
|
|
55
61
|
]);
|
|
56
62
|
}
|
|
57
|
-
await setStorage(chain, storage);
|
|
63
|
+
await (0, set_storage_1.setStorage)(chain, storage);
|
|
58
64
|
};
|
|
65
|
+
exports.timeTravel = timeTravel;
|
package/lib/xcm/downward.js
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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) => {
|
|
6
9
|
const meta = await relaychain.head.meta;
|
|
7
|
-
const paraId = await getParaId(parachain);
|
|
8
|
-
const downwardMessageQueuesKey = compactHex(meta.query.dmp.downwardMessageQueues(paraId));
|
|
10
|
+
const paraId = await (0, utils_1.getParaId)(parachain);
|
|
11
|
+
const downwardMessageQueuesKey = (0, utils_1.compactHex)(meta.query.dmp.downwardMessageQueues(paraId));
|
|
9
12
|
await relaychain.headState.subscribeStorage([downwardMessageQueuesKey], async (head, pairs) => {
|
|
10
13
|
const value = pairs[0][1];
|
|
11
14
|
if (!value)
|
|
12
15
|
return;
|
|
13
16
|
const meta = await head.meta;
|
|
14
|
-
const downwardMessageQueuesKey = compactHex(meta.query.dmp.downwardMessageQueues(paraId));
|
|
17
|
+
const downwardMessageQueuesKey = (0, utils_1.compactHex)(meta.query.dmp.downwardMessageQueues(paraId));
|
|
15
18
|
// clear relaychain message queue
|
|
16
|
-
await setStorage(relaychain, [[downwardMessageQueuesKey, null]], head.hash);
|
|
19
|
+
await (0, set_storage_1.setStorage)(relaychain, [[downwardMessageQueuesKey, null]], head.hash);
|
|
17
20
|
const downwardMessages = meta.registry
|
|
18
|
-
.createType('Vec<PolkadotCorePrimitivesInboundDownwardMessage>', hexToU8a(value))
|
|
21
|
+
.createType('Vec<PolkadotCorePrimitivesInboundDownwardMessage>', (0, util_1.hexToU8a)(value))
|
|
19
22
|
.toJSON();
|
|
20
23
|
if (downwardMessages.length === 0)
|
|
21
24
|
return;
|
|
22
|
-
logger.debug({ downwardMessages }, 'downward_message');
|
|
25
|
+
_1.logger.debug({ downwardMessages }, 'downward_message');
|
|
23
26
|
parachain.submitDownwardMessages(downwardMessages);
|
|
24
27
|
});
|
|
25
28
|
};
|
|
29
|
+
exports.connectDownward = connectDownward;
|
package/lib/xcm/horizontal.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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) => {
|
|
5
8
|
for (const [id, chain] of Object.entries(parachains)) {
|
|
6
9
|
const meta = await chain.head.meta;
|
|
7
|
-
const hrmpOutboundMessagesKey = compactHex(meta.query.parachainSystem.hrmpOutboundMessages());
|
|
10
|
+
const hrmpOutboundMessagesKey = (0, utils_1.compactHex)(meta.query.parachainSystem.hrmpOutboundMessages());
|
|
8
11
|
await chain.headState.subscribeStorage([hrmpOutboundMessagesKey], async (head, pairs) => {
|
|
9
12
|
const value = pairs[0][1];
|
|
10
13
|
if (!value)
|
|
11
14
|
return;
|
|
12
15
|
const meta = await head.meta;
|
|
13
16
|
const outboundHrmpMessage = meta.registry
|
|
14
|
-
.createType('Vec<PolkadotCorePrimitivesOutboundHrmpMessage>', hexToU8a(value))
|
|
17
|
+
.createType('Vec<PolkadotCorePrimitivesOutboundHrmpMessage>', (0, util_1.hexToU8a)(value))
|
|
15
18
|
.toJSON();
|
|
16
|
-
logger.info({ outboundHrmpMessage }, 'outboundHrmpMessage');
|
|
19
|
+
_1.logger.info({ outboundHrmpMessage }, 'outboundHrmpMessage');
|
|
17
20
|
for (const { recipient, data } of outboundHrmpMessage) {
|
|
18
21
|
const receiver = parachains[recipient];
|
|
19
22
|
if (receiver) {
|
|
@@ -23,3 +26,4 @@ export const connectHorizontal = async (parachains) => {
|
|
|
23
26
|
});
|
|
24
27
|
}
|
|
25
28
|
};
|
|
29
|
+
exports.connectHorizontal = connectHorizontal;
|
package/lib/xcm/index.js
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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()}'`);
|
|
11
14
|
};
|
|
12
|
-
|
|
15
|
+
exports.connectVertical = connectVertical;
|
|
16
|
+
const connectParachains = async (parachains) => {
|
|
13
17
|
const list = {};
|
|
14
18
|
for (const chain of parachains) {
|
|
15
|
-
const paraId = await getParaId(chain);
|
|
19
|
+
const paraId = await (0, utils_1.getParaId)(chain);
|
|
16
20
|
list[paraId.toNumber()] = chain;
|
|
17
21
|
}
|
|
18
|
-
await connectHorizontal(list);
|
|
19
|
-
logger.info(`Connected parachains [${Object.keys(list)}]`);
|
|
22
|
+
await (0, horizontal_1.connectHorizontal)(list);
|
|
23
|
+
exports.logger.info(`Connected parachains [${Object.keys(list)}]`);
|
|
20
24
|
};
|
|
25
|
+
exports.connectParachains = connectParachains;
|
package/lib/xcm/upward.js
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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) => {
|
|
4
7
|
const meta = await parachain.head.meta;
|
|
5
|
-
const paraId = (await getParaId(parachain)).toNumber();
|
|
6
|
-
const upwardMessagesKey = compactHex(meta.query.parachainSystem.upwardMessages());
|
|
8
|
+
const paraId = (await (0, utils_1.getParaId)(parachain)).toNumber();
|
|
9
|
+
const upwardMessagesKey = (0, utils_1.compactHex)(meta.query.parachainSystem.upwardMessages());
|
|
7
10
|
await parachain.headState.subscribeStorage([upwardMessagesKey], async (_head, pairs) => {
|
|
8
11
|
const value = pairs[0][1];
|
|
9
12
|
if (!value)
|
|
10
13
|
return;
|
|
11
14
|
const meta = await relaychain.head.meta;
|
|
12
|
-
const upwardMessages = meta.registry.createType('Vec<Bytes>', hexToU8a(value));
|
|
15
|
+
const upwardMessages = meta.registry.createType('Vec<Bytes>', (0, util_1.hexToU8a)(value));
|
|
13
16
|
if (upwardMessages.length === 0)
|
|
14
17
|
return;
|
|
15
18
|
relaychain.submitUpwardMessages(paraId, upwardMessages.map((x) => x.toHex()));
|
|
16
19
|
});
|
|
17
20
|
};
|
|
21
|
+
exports.connectUpward = connectUpward;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acala-network/chopsticks",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.7",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"author": "Bryan Chen <xlchen1291@gmail.com>",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dev:moonbeam": "ts-node-dev --transpile-only --inspect --notify=false src/cli.ts -- dev --config=../../configs/moonbeam.yml"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@acala-network/chopsticks-executor": "0.5.
|
|
20
|
+
"@acala-network/chopsticks-executor": "0.5.7",
|
|
21
21
|
"@polkadot/api": "^9.14.2",
|
|
22
22
|
"@polkadot/rpc-provider": "^9.14.2",
|
|
23
23
|
"@polkadot/types": "^9.14.2",
|