@acala-network/chopsticks-core 1.0.2-2 → 1.0.2
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/api.d.ts +4 -4
- package/dist/cjs/api.js +20 -23
- package/dist/cjs/blockchain/block-builder.d.ts +5 -5
- package/dist/cjs/blockchain/block-builder.js +17 -18
- package/dist/cjs/blockchain/block.d.ts +6 -6
- package/dist/cjs/blockchain/block.js +1 -1
- package/dist/cjs/blockchain/head-state.d.ts +1 -1
- package/dist/cjs/blockchain/index.d.ts +9 -9
- package/dist/cjs/blockchain/index.js +5 -5
- package/dist/cjs/blockchain/inherent/index.d.ts +5 -5
- package/dist/cjs/blockchain/inherent/index.js +1 -1
- package/dist/cjs/blockchain/inherent/para-enter.d.ts +4 -4
- package/dist/cjs/blockchain/inherent/parachain/babe-randomness.d.ts +4 -4
- package/dist/cjs/blockchain/inherent/parachain/nimbus-author-inherent.d.ts +4 -4
- package/dist/cjs/blockchain/inherent/parachain/validation-data.d.ts +4 -4
- package/dist/cjs/blockchain/inherent/parachain/validation-data.js +3 -3
- package/dist/cjs/blockchain/inherent/timestamp.d.ts +3 -3
- package/dist/cjs/blockchain/storage-layer.d.ts +3 -3
- package/dist/cjs/blockchain/storage-layer.js +5 -4
- package/dist/cjs/blockchain/txpool.d.ts +3 -3
- package/dist/cjs/blockchain/txpool.js +2 -2
- package/dist/cjs/chopsticks-provider.d.ts +3 -3
- package/dist/cjs/chopsticks-provider.js +8 -9
- package/dist/cjs/database.d.ts +1 -1
- package/dist/cjs/genesis-provider.d.ts +4 -4
- package/dist/cjs/genesis-provider.js +12 -12
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/logger.js +2 -3
- package/dist/cjs/offchain.d.ts +2 -2
- package/dist/cjs/offchain.js +1 -1
- package/dist/cjs/rpc/dev/new-block.d.ts +5 -5
- package/dist/cjs/rpc/dev/new-block.js +1 -1
- package/dist/cjs/rpc/dev/set-block-build-mode.d.ts +1 -1
- package/dist/cjs/rpc/dev/set-block-build-mode.js +1 -1
- package/dist/cjs/rpc/dev/set-head.d.ts +1 -1
- package/dist/cjs/rpc/dev/set-head.js +1 -1
- package/dist/cjs/rpc/dev/set-runtime-log-level.d.ts +1 -1
- package/dist/cjs/rpc/dev/set-runtime-log-level.js +1 -1
- package/dist/cjs/rpc/dev/set-storage.d.ts +3 -3
- package/dist/cjs/rpc/dev/set-storage.js +1 -1
- package/dist/cjs/rpc/dev/time-travel.d.ts +1 -1
- package/dist/cjs/rpc/dev/time-travel.js +1 -1
- package/dist/cjs/rpc/index.d.ts +1 -1
- package/dist/cjs/rpc/rpc-spec/chainHead_v1.d.ts +11 -2
- package/dist/cjs/rpc/rpc-spec/chainHead_v1.js +33 -2
- package/dist/cjs/rpc/rpc-spec/chainSpec_v1.d.ts +3 -3
- package/dist/cjs/rpc/rpc-spec/transaction_v1.d.ts +2 -2
- package/dist/cjs/rpc/shared.d.ts +1 -1
- package/dist/cjs/rpc/substrate/archive.d.ts +2 -2
- package/dist/cjs/rpc/substrate/author.d.ts +2 -2
- package/dist/cjs/rpc/substrate/author.js +1 -1
- package/dist/cjs/rpc/substrate/chain.d.ts +2 -2
- package/dist/cjs/rpc/substrate/payment.d.ts +2 -2
- package/dist/cjs/rpc/substrate/state.d.ts +3 -3
- package/dist/cjs/rpc/substrate/state.js +1 -1
- package/dist/cjs/rpc/substrate/system.d.ts +3 -3
- package/dist/cjs/setup.d.ts +4 -4
- package/dist/cjs/setup.js +1 -1
- package/dist/cjs/utils/decoder.d.ts +5 -5
- package/dist/cjs/utils/decoder.js +2 -2
- package/dist/cjs/utils/index.d.ts +4 -4
- package/dist/cjs/utils/index.js +1 -1
- package/dist/cjs/utils/key-cache.d.ts +1 -1
- package/dist/cjs/utils/proof.d.ts +3 -3
- package/dist/cjs/utils/set-storage.d.ts +2 -2
- package/dist/cjs/utils/set-storage.js +1 -1
- package/dist/cjs/utils/time-travel.d.ts +1 -1
- package/dist/cjs/utils/well-known-keys.d.ts +2 -2
- package/dist/cjs/utils/well-known-keys.js +2 -2
- package/dist/cjs/wasm-executor/browser-wasm-executor.js +1 -1
- package/dist/cjs/wasm-executor/index.d.ts +3 -3
- package/dist/cjs/wasm-executor/index.js +14 -20
- package/dist/cjs/wasm-executor/node-wasm-executor.js +1 -1
- package/dist/cjs/wasm-executor/node-worker.js +1 -1
- package/dist/cjs/xcm/downward.d.ts +1 -1
- package/dist/cjs/xcm/horizontal.d.ts +1 -1
- package/dist/cjs/xcm/index.d.ts +1 -1
- package/dist/cjs/xcm/index.js +2 -2
- package/dist/cjs/xcm/upward.d.ts +1 -1
- package/dist/esm/api.d.ts +4 -4
- package/dist/esm/api.js +20 -23
- package/dist/esm/blockchain/block-builder.d.ts +5 -5
- package/dist/esm/blockchain/block-builder.js +17 -18
- package/dist/esm/blockchain/block.d.ts +6 -6
- package/dist/esm/blockchain/block.js +1 -1
- package/dist/esm/blockchain/head-state.d.ts +1 -1
- package/dist/esm/blockchain/index.d.ts +9 -9
- package/dist/esm/blockchain/index.js +5 -5
- package/dist/esm/blockchain/inherent/index.d.ts +5 -5
- package/dist/esm/blockchain/inherent/index.js +1 -1
- package/dist/esm/blockchain/inherent/para-enter.d.ts +4 -4
- package/dist/esm/blockchain/inherent/parachain/babe-randomness.d.ts +4 -4
- package/dist/esm/blockchain/inherent/parachain/nimbus-author-inherent.d.ts +4 -4
- package/dist/esm/blockchain/inherent/parachain/validation-data.d.ts +4 -4
- package/dist/esm/blockchain/inherent/parachain/validation-data.js +3 -3
- package/dist/esm/blockchain/inherent/timestamp.d.ts +3 -3
- package/dist/esm/blockchain/storage-layer.d.ts +3 -3
- package/dist/esm/blockchain/storage-layer.js +5 -4
- package/dist/esm/blockchain/txpool.d.ts +3 -3
- package/dist/esm/blockchain/txpool.js +2 -2
- package/dist/esm/chopsticks-provider.d.ts +3 -3
- package/dist/esm/chopsticks-provider.js +8 -9
- package/dist/esm/database.d.ts +1 -1
- package/dist/esm/genesis-provider.d.ts +4 -4
- package/dist/esm/genesis-provider.js +3 -3
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/logger.js +2 -3
- package/dist/esm/offchain.d.ts +2 -2
- package/dist/esm/offchain.js +1 -1
- package/dist/esm/rpc/dev/new-block.d.ts +5 -5
- package/dist/esm/rpc/dev/new-block.js +1 -1
- package/dist/esm/rpc/dev/set-block-build-mode.d.ts +1 -1
- package/dist/esm/rpc/dev/set-block-build-mode.js +1 -1
- package/dist/esm/rpc/dev/set-head.d.ts +1 -1
- package/dist/esm/rpc/dev/set-head.js +1 -1
- package/dist/esm/rpc/dev/set-runtime-log-level.d.ts +1 -1
- package/dist/esm/rpc/dev/set-runtime-log-level.js +1 -1
- package/dist/esm/rpc/dev/set-storage.d.ts +3 -3
- package/dist/esm/rpc/dev/set-storage.js +1 -1
- package/dist/esm/rpc/dev/time-travel.d.ts +1 -1
- package/dist/esm/rpc/dev/time-travel.js +1 -1
- package/dist/esm/rpc/index.d.ts +1 -1
- package/dist/esm/rpc/rpc-spec/chainHead_v1.d.ts +11 -2
- package/dist/esm/rpc/rpc-spec/chainHead_v1.js +42 -2
- package/dist/esm/rpc/rpc-spec/chainSpec_v1.d.ts +3 -3
- package/dist/esm/rpc/rpc-spec/transaction_v1.d.ts +2 -2
- package/dist/esm/rpc/shared.d.ts +1 -1
- package/dist/esm/rpc/substrate/archive.d.ts +2 -2
- package/dist/esm/rpc/substrate/author.d.ts +2 -2
- package/dist/esm/rpc/substrate/author.js +1 -1
- package/dist/esm/rpc/substrate/chain.d.ts +2 -2
- package/dist/esm/rpc/substrate/payment.d.ts +2 -2
- package/dist/esm/rpc/substrate/state.d.ts +3 -3
- package/dist/esm/rpc/substrate/state.js +1 -1
- package/dist/esm/rpc/substrate/system.d.ts +3 -3
- package/dist/esm/setup.d.ts +4 -4
- package/dist/esm/setup.js +1 -1
- package/dist/esm/utils/decoder.d.ts +5 -5
- package/dist/esm/utils/decoder.js +2 -2
- package/dist/esm/utils/index.d.ts +4 -4
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/key-cache.d.ts +1 -1
- package/dist/esm/utils/proof.d.ts +3 -3
- package/dist/esm/utils/set-storage.d.ts +2 -2
- package/dist/esm/utils/set-storage.js +1 -1
- package/dist/esm/utils/time-travel.d.ts +1 -1
- package/dist/esm/utils/well-known-keys.d.ts +2 -2
- package/dist/esm/utils/well-known-keys.js +2 -2
- package/dist/esm/wasm-executor/browser-wasm-executor.js +1 -1
- package/dist/esm/wasm-executor/index.d.ts +3 -3
- package/dist/esm/wasm-executor/index.js +14 -20
- package/dist/esm/wasm-executor/node-wasm-executor.js +1 -1
- package/dist/esm/wasm-executor/node-worker.js +1 -1
- package/dist/esm/xcm/downward.d.ts +1 -1
- package/dist/esm/xcm/horizontal.d.ts +1 -1
- package/dist/esm/xcm/index.d.ts +1 -1
- package/dist/esm/xcm/index.js +2 -2
- package/dist/esm/xcm/upward.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Context } from '../shared.js';
|
|
2
1
|
import { z } from 'zod';
|
|
2
|
+
import { type Context } from '../shared.js';
|
|
3
3
|
declare const schema: z.ZodObject<{
|
|
4
4
|
count: z.ZodOptional<z.ZodNumber>;
|
|
5
5
|
to: z.ZodOptional<z.ZodNumber>;
|
|
@@ -31,6 +31,8 @@ declare const schema: z.ZodObject<{
|
|
|
31
31
|
}, "strip", z.ZodTypeAny, {
|
|
32
32
|
transactions?: `0x${string}`[] | undefined;
|
|
33
33
|
unsafeBlockHeight?: number | undefined;
|
|
34
|
+
relayChainStateOverrides?: [`0x${string}`, `0x${string}` | null][] | undefined;
|
|
35
|
+
relayParentNumber?: number | undefined;
|
|
34
36
|
ump?: Record<number, `0x${string}`[]> | undefined;
|
|
35
37
|
dmp?: {
|
|
36
38
|
msg: `0x${string}`;
|
|
@@ -40,13 +42,13 @@ declare const schema: z.ZodObject<{
|
|
|
40
42
|
data: `0x${string}`;
|
|
41
43
|
sentAt: number;
|
|
42
44
|
}[]> | undefined;
|
|
43
|
-
relayChainStateOverrides?: [`0x${string}`, `0x${string}` | null][] | undefined;
|
|
44
|
-
relayParentNumber?: number | undefined;
|
|
45
45
|
count?: number | undefined;
|
|
46
46
|
to?: number | undefined;
|
|
47
47
|
}, {
|
|
48
48
|
transactions?: `0x${string}`[] | undefined;
|
|
49
49
|
unsafeBlockHeight?: number | undefined;
|
|
50
|
+
relayChainStateOverrides?: [`0x${string}`, `0x${string}` | null][] | undefined;
|
|
51
|
+
relayParentNumber?: number | undefined;
|
|
50
52
|
ump?: Record<number, `0x${string}`[]> | undefined;
|
|
51
53
|
dmp?: {
|
|
52
54
|
msg: `0x${string}`;
|
|
@@ -56,8 +58,6 @@ declare const schema: z.ZodObject<{
|
|
|
56
58
|
data: `0x${string}`;
|
|
57
59
|
sentAt: number;
|
|
58
60
|
}[]> | undefined;
|
|
59
|
-
relayChainStateOverrides?: [`0x${string}`, `0x${string}` | null][] | undefined;
|
|
60
|
-
relayParentNumber?: number | undefined;
|
|
61
61
|
count?: number | undefined;
|
|
62
62
|
to?: number | undefined;
|
|
63
63
|
}>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Context } from '../shared.js';
|
|
2
1
|
import { z } from 'zod';
|
|
2
|
+
import { type Context } from '../shared.js';
|
|
3
3
|
declare const schema: z.ZodUnion<[z.ZodIntersection<z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>>, z.ZodNumber]>;
|
|
4
4
|
type Params = z.infer<typeof schema>;
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { StorageValues } from '../../utils/set-storage.js';
|
|
1
|
+
import type { HexString } from '@polkadot/util/types';
|
|
2
|
+
import { type Context } from '../shared.js';
|
|
3
|
+
import { type StorageValues } from '../../utils/set-storage.js';
|
|
4
4
|
/**
|
|
5
5
|
* Set storage values.
|
|
6
6
|
*
|
package/dist/esm/rpc/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { HexString } from '@polkadot/util/types';
|
|
2
|
+
import { type Handler } from '../shared.js';
|
|
3
3
|
/**
|
|
4
4
|
* Start a chainHead follow subscription
|
|
5
5
|
*
|
|
@@ -54,6 +54,15 @@ export interface StorageItemRequest {
|
|
|
54
54
|
* @param params - [`followSubscription`, `hash`, `items`, `childTrie`]
|
|
55
55
|
*
|
|
56
56
|
* @return OperationStarted event with operationId to receive the result on the follow subscription
|
|
57
|
+
*
|
|
58
|
+
* The query type `closestDescendantMerkleValue` is not up to spec.
|
|
59
|
+
* According to the spec, the result should be the Merkle value of the key or
|
|
60
|
+
* the closest descendant of the key.
|
|
61
|
+
* As chopsticks doesn't have direct access to the Merkle tree, it will return
|
|
62
|
+
* a string that will change every time that one of the descendant changes, but
|
|
63
|
+
* it won't be the actual Merkle value.
|
|
64
|
+
* This should be enough for applications that don't rely on the actual Merkle
|
|
65
|
+
* value, but just use it to detect for storage changes.
|
|
57
66
|
*/
|
|
58
67
|
export declare const chainHead_v1_storage: Handler<[
|
|
59
68
|
string,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ResponseError } from '../shared.js';
|
|
2
1
|
import { defaultLogger } from '../../logger.js';
|
|
2
|
+
import { ResponseError } from '../shared.js';
|
|
3
3
|
const logger = defaultLogger.child({
|
|
4
4
|
name: 'rpc-chainHead_v1'
|
|
5
5
|
});
|
|
@@ -47,6 +47,16 @@ async function afterResponse(fn) {
|
|
|
47
47
|
],
|
|
48
48
|
prunedBlockHashes: []
|
|
49
49
|
});
|
|
50
|
+
const storageDiffs = following.get(id)?.storageDiffs;
|
|
51
|
+
if (storageDiffs?.size) {
|
|
52
|
+
// Fetch the storage diffs and update the `closestDescendantMerkleValue` for those that changed
|
|
53
|
+
const diffKeys = Object.keys(await block.storageDiff());
|
|
54
|
+
for (const [prefix, value] of storageDiffs.entries()){
|
|
55
|
+
if (diffKeys.some((key)=>key.startsWith(prefix))) {
|
|
56
|
+
storageDiffs.set(prefix, value + 1);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
50
60
|
};
|
|
51
61
|
const id = context.chain.headState.subscribeHead(update);
|
|
52
62
|
const cleanup = ()=>{
|
|
@@ -56,7 +66,8 @@ async function afterResponse(fn) {
|
|
|
56
66
|
const callback = subscribe('chainHead_v1_followEvent', id, cleanup);
|
|
57
67
|
following.set(id, {
|
|
58
68
|
callback,
|
|
59
|
-
pendingDescendantValues: new Map()
|
|
69
|
+
pendingDescendantValues: new Map(),
|
|
70
|
+
storageDiffs: new Map()
|
|
60
71
|
});
|
|
61
72
|
afterResponse(async ()=>{
|
|
62
73
|
callback({
|
|
@@ -165,6 +176,15 @@ async function getDescendantValues(block, params) {
|
|
|
165
176
|
* @param params - [`followSubscription`, `hash`, `items`, `childTrie`]
|
|
166
177
|
*
|
|
167
178
|
* @return OperationStarted event with operationId to receive the result on the follow subscription
|
|
179
|
+
*
|
|
180
|
+
* The query type `closestDescendantMerkleValue` is not up to spec.
|
|
181
|
+
* According to the spec, the result should be the Merkle value of the key or
|
|
182
|
+
* the closest descendant of the key.
|
|
183
|
+
* As chopsticks doesn't have direct access to the Merkle tree, it will return
|
|
184
|
+
* a string that will change every time that one of the descendant changes, but
|
|
185
|
+
* it won't be the actual Merkle value.
|
|
186
|
+
* This should be enough for applications that don't rely on the actual Merkle
|
|
187
|
+
* value, but just use it to detect for storage changes.
|
|
168
188
|
*/ export const chainHead_v1_storage = async (context, [followSubscription, hash, items, _childTrie])=>{
|
|
169
189
|
const operationId = randomId();
|
|
170
190
|
afterResponse(async ()=>{
|
|
@@ -209,6 +229,26 @@ async function getDescendantValues(block, params) {
|
|
|
209
229
|
});
|
|
210
230
|
return next;
|
|
211
231
|
}
|
|
232
|
+
case 'closestDescendantMerkleValue':
|
|
233
|
+
{
|
|
234
|
+
const followingSubscription = following.get(followSubscription);
|
|
235
|
+
if (!followingSubscription) return null;
|
|
236
|
+
if (!followingSubscription.storageDiffs.has(sir.key)) {
|
|
237
|
+
// Set up a diff watch for this key
|
|
238
|
+
followingSubscription.storageDiffs.set(sir.key, 0);
|
|
239
|
+
}
|
|
240
|
+
followingSubscription.callback({
|
|
241
|
+
event: 'operationStorageItems',
|
|
242
|
+
operationId,
|
|
243
|
+
items: [
|
|
244
|
+
{
|
|
245
|
+
key: sir.key,
|
|
246
|
+
closestDescendantMerkleValue: String(followingSubscription.storageDiffs.get(sir.key))
|
|
247
|
+
}
|
|
248
|
+
]
|
|
249
|
+
});
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
212
252
|
default:
|
|
213
253
|
// TODO
|
|
214
254
|
console.warn(`Storage type not implemented ${sir.type}`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { HexString } from '@polkadot/util/types';
|
|
2
|
+
import type { ChainProperties } from '../../index.js';
|
|
3
|
+
import { type Handler } from '../shared.js';
|
|
4
4
|
export declare const chainSpec_v1_chainName: Handler<[], string>;
|
|
5
5
|
export declare const chainSpec_v1_genesisHash: Handler<[], HexString>;
|
|
6
6
|
export declare const chainSpec_v1_properties: Handler<[], ChainProperties>;
|
package/dist/esm/rpc/shared.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { Blockchain } from '../blockchain/index.js';
|
|
2
|
+
import type { Blockchain } from '../blockchain/index.js';
|
|
3
3
|
export declare const logger: import("pino").default.Logger<never, boolean>;
|
|
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}`>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { APPLY_EXTRINSIC_ERROR } from '../../blockchain/txpool.js';
|
|
2
|
-
import { ResponseError } from '../shared.js';
|
|
3
2
|
import { defaultLogger } from '../../logger.js';
|
|
3
|
+
import { ResponseError } from '../shared.js';
|
|
4
4
|
const logger = defaultLogger.child({
|
|
5
5
|
name: 'rpc-author'
|
|
6
6
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HexString } from '@polkadot/util/types';
|
|
2
|
-
import { Handler } from '../shared.js';
|
|
1
|
+
import type { HexString } from '@polkadot/util/types';
|
|
3
2
|
import type { Header } from '../../index.js';
|
|
3
|
+
import { type Handler } from '../shared.js';
|
|
4
4
|
/**
|
|
5
5
|
* @param context
|
|
6
6
|
* @param params - [`blockNumber` | `blockNumber[]` | null]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HexString } from '@polkadot/util/types';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { HexString } from '@polkadot/util/types';
|
|
2
|
+
import type { RuntimeVersion } from '../../wasm-executor/index.js';
|
|
3
|
+
import { type Handler } from '../shared.js';
|
|
4
4
|
/**
|
|
5
5
|
* @param context
|
|
6
6
|
* @param params - [`blockhash`]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { stringToHex } from '@polkadot/util';
|
|
2
|
-
import { ResponseError } from '../shared.js';
|
|
3
2
|
import { defaultLogger } from '../../logger.js';
|
|
4
3
|
import { isPrefixedChildKey, prefixedChildKey, stripChildPrefix } from '../../utils/index.js';
|
|
4
|
+
import { ResponseError } from '../shared.js';
|
|
5
5
|
const logger = defaultLogger.child({
|
|
6
6
|
name: 'rpc-state'
|
|
7
7
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HexString } from '@polkadot/util/types';
|
|
2
|
-
import { ChainProperties } from '../../index.js';
|
|
3
|
-
import { Handler } from '../shared.js';
|
|
1
|
+
import type { HexString } from '@polkadot/util/types';
|
|
2
|
+
import type { ChainProperties } from '../../index.js';
|
|
3
|
+
import type { Handler } from '../shared.js';
|
|
4
4
|
export declare const system_localPeerId: () => Promise<string>;
|
|
5
5
|
export declare const system_nodeRoles: () => Promise<string[]>;
|
|
6
6
|
export declare const system_localListenAddresses: () => Promise<never[]>;
|
package/dist/esm/setup.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import '@polkadot/types-codec';
|
|
2
|
-
import { RegisteredTypes } from '@polkadot/types/types';
|
|
2
|
+
import type { RegisteredTypes } from '@polkadot/types/types';
|
|
3
3
|
import { Api } from './api.js';
|
|
4
4
|
import { Blockchain } from './blockchain/index.js';
|
|
5
|
-
import { BuildBlockMode } from './blockchain/txpool.js';
|
|
6
|
-
import { Database } from './database.js';
|
|
7
|
-
import { GenesisProvider } from './genesis-provider.js';
|
|
5
|
+
import type { BuildBlockMode } from './blockchain/txpool.js';
|
|
6
|
+
import type { Database } from './database.js';
|
|
7
|
+
import type { GenesisProvider } from './genesis-provider.js';
|
|
8
8
|
export type SetupOptions = {
|
|
9
9
|
endpoint?: string | string[];
|
|
10
10
|
block?: string | number | null;
|
package/dist/esm/setup.js
CHANGED
|
@@ -2,8 +2,8 @@ import '@polkadot/types-codec';
|
|
|
2
2
|
import { HttpProvider, WsProvider } from '@polkadot/rpc-provider';
|
|
3
3
|
import { Api } from './api.js';
|
|
4
4
|
import { Blockchain } from './blockchain/index.js';
|
|
5
|
-
import { defaultLogger } from './logger.js';
|
|
6
5
|
import { inherentProviders } from './blockchain/inherent/index.js';
|
|
6
|
+
import { defaultLogger } from './logger.js';
|
|
7
7
|
export const processOptions = async (options)=>{
|
|
8
8
|
defaultLogger.debug(options, 'Setup options');
|
|
9
9
|
let provider;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import '@polkadot/types-codec';
|
|
2
|
-
import {
|
|
3
|
-
import { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import type { StorageKey } from '@polkadot/types';
|
|
3
|
+
import type { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
|
|
4
|
+
import type { StorageEntry } from '@polkadot/types/primitive/types';
|
|
5
|
+
import type { HexString } from '@polkadot/util/types';
|
|
6
|
+
import type { Block } from '../blockchain/block.js';
|
|
7
7
|
export declare const decodeKey: (meta: DecoratedMeta, key: HexString) => {
|
|
8
8
|
storage?: StorageEntry;
|
|
9
9
|
decodedKey?: StorageKey;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import '@polkadot/types-codec';
|
|
2
|
-
import { LRUCache } from 'lru-cache';
|
|
3
2
|
import { hexToU8a, u8aToHex } from '@polkadot/util';
|
|
4
3
|
import _ from 'lodash';
|
|
5
|
-
import {
|
|
4
|
+
import { LRUCache } from 'lru-cache';
|
|
6
5
|
import { defaultLogger } from '../logger.js';
|
|
6
|
+
import { decodeWellKnownKey } from './well-known-keys.js';
|
|
7
7
|
const logger = defaultLogger.child({
|
|
8
8
|
name: 'decoder'
|
|
9
9
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Block } from '../blockchain/block.js';
|
|
4
|
-
import { Blockchain } from '../blockchain/index.js';
|
|
1
|
+
import type { StorageKey } from '@polkadot/types';
|
|
2
|
+
import type { HexString } from '@polkadot/util/types';
|
|
3
|
+
import type { Block } from '../blockchain/block.js';
|
|
4
|
+
import type { Blockchain } from '../blockchain/index.js';
|
|
5
5
|
export * from './set-storage.js';
|
|
6
6
|
export * from './time-travel.js';
|
|
7
7
|
export * from './decoder.js';
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { compactStripLength, u8aToHex } from '@polkadot/util';
|
|
2
|
-
import { getAuraSlotDuration } from '../wasm-executor/index.js';
|
|
3
2
|
import { hexAddPrefix, hexStripPrefix } from '@polkadot/util/hex';
|
|
3
|
+
import { getAuraSlotDuration } from '../wasm-executor/index.js';
|
|
4
4
|
export * from './set-storage.js';
|
|
5
5
|
export * from './time-travel.js';
|
|
6
6
|
export * from './decoder.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { HrmpChannelId } from '@polkadot/types/interfaces';
|
|
3
|
-
import {
|
|
1
|
+
import type { u32 } from '@polkadot/types';
|
|
2
|
+
import type { HrmpChannelId } from '@polkadot/types/interfaces';
|
|
3
|
+
import type { HexString } from '@polkadot/util/types';
|
|
4
4
|
export declare const WELL_KNOWN_KEYS: {
|
|
5
5
|
EPOCH_INDEX: HexString;
|
|
6
6
|
CURRENT_BLOCK_RANDOMNESS: HexString;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HexString } from '@polkadot/util/types';
|
|
2
|
-
import { Blockchain } from '../blockchain/index.js';
|
|
1
|
+
import type { HexString } from '@polkadot/util/types';
|
|
2
|
+
import type { Blockchain } from '../blockchain/index.js';
|
|
3
3
|
type RawStorageValues = [string, string | null][];
|
|
4
4
|
type StorageConfig = Record<string, Record<string, any>>;
|
|
5
5
|
export type StorageValues = RawStorageValues | StorageConfig;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StorageKey } from '@polkadot/types';
|
|
2
|
-
import { stringCamelCase } from '@polkadot/util/string';
|
|
3
2
|
import { u8aToHex } from '@polkadot/util';
|
|
3
|
+
import { stringCamelCase } from '@polkadot/util/string';
|
|
4
4
|
import { StorageValueKind } from '../blockchain/storage-layer.js';
|
|
5
5
|
function objectToStorageItems(meta, storage) {
|
|
6
6
|
const storageItems = [];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Blockchain } from '../blockchain/index.js';
|
|
1
|
+
import type { Blockchain } from '../blockchain/index.js';
|
|
2
2
|
export declare const timeTravel: (chain: Blockchain, timestamp: number) => Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Registry } from '@polkadot/types-codec/types';
|
|
2
|
+
import type { HexString } from '@polkadot/util/types';
|
|
3
3
|
export declare const decodeWellKnownKey: (registry: Registry, key: HexString, value?: HexString | null) => {
|
|
4
4
|
name: string;
|
|
5
5
|
key: any[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { blake2AsHex } from '@polkadot/util-crypto';
|
|
2
1
|
import { hexToU8a, stringToHex } from '@polkadot/util';
|
|
2
|
+
import { blake2AsHex } from '@polkadot/util-crypto';
|
|
3
3
|
const decodeValue = (type)=>(registry, value)=>{
|
|
4
4
|
return registry.createType(type, hexToU8a(value)).toJSON();
|
|
5
5
|
};
|
|
@@ -52,7 +52,7 @@ const wellKnownKeys = [
|
|
|
52
52
|
prefixHex: '0xf5207f03cfdce586301014700e2c2593fad157e461d71fd4c1f936839a5f1f3e',
|
|
53
53
|
decodeKey: (registry, key)=>{
|
|
54
54
|
// get last 4 bytes
|
|
55
|
-
const last4Bytes =
|
|
55
|
+
const last4Bytes = `0x${key.slice(-8)}`;
|
|
56
56
|
return [
|
|
57
57
|
registry.createType('u32', hexToU8a(last4Bytes)).toJSON()
|
|
58
58
|
];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import type { HexString } from '@polkadot/util/types';
|
|
1
2
|
import * as Comlink from 'comlink';
|
|
2
|
-
import { HexString } from '@polkadot/util/types';
|
|
3
3
|
import _ from 'lodash';
|
|
4
|
-
import { Block } from '../blockchain/block.js';
|
|
4
|
+
import type { Block } from '../blockchain/block.js';
|
|
5
5
|
import type { JsCallback } from '@acala-network/chopsticks-executor';
|
|
6
|
-
export { JsCallback };
|
|
6
|
+
export type { JsCallback };
|
|
7
7
|
export type RuntimeVersion = {
|
|
8
8
|
specName: string;
|
|
9
9
|
implName: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as Comlink from 'comlink';
|
|
2
1
|
import { hexToString, hexToU8a, u8aToBn } from '@polkadot/util';
|
|
3
2
|
import { randomAsHex } from '@polkadot/util-crypto';
|
|
3
|
+
import * as Comlink from 'comlink';
|
|
4
4
|
import _ from 'lodash';
|
|
5
|
-
import { PREFIX_LENGTH, stripChildPrefix } from '../utils/index.js';
|
|
6
5
|
import { defaultLogger, truncate } from '../logger.js';
|
|
6
|
+
import { PREFIX_LENGTH, stripChildPrefix } from '../utils/index.js';
|
|
7
7
|
const logger = defaultLogger.child({
|
|
8
8
|
name: 'executor'
|
|
9
9
|
});
|
|
@@ -67,10 +67,8 @@ export const runTask = async (task, callback = emptyTaskHandler)=>{
|
|
|
67
67
|
};
|
|
68
68
|
export const taskHandler = (block)=>{
|
|
69
69
|
return {
|
|
70
|
-
getStorage: async
|
|
71
|
-
|
|
72
|
-
},
|
|
73
|
-
getNextKey: async function(prefix, key) {
|
|
70
|
+
getStorage: async (key)=>block.get(key),
|
|
71
|
+
getNextKey: async (prefix, key)=>{
|
|
74
72
|
const [nextKey] = await block.getKeysPaged({
|
|
75
73
|
prefix: prefix.length === 2 /** 0x */ ? key.slice(0, PREFIX_LENGTH) : prefix,
|
|
76
74
|
pageSize: 1,
|
|
@@ -78,17 +76,13 @@ export const taskHandler = (block)=>{
|
|
|
78
76
|
});
|
|
79
77
|
return nextKey && stripChildPrefix(nextKey);
|
|
80
78
|
},
|
|
81
|
-
offchainGetStorage: async
|
|
79
|
+
offchainGetStorage: async (key)=>{
|
|
82
80
|
if (!block.chain.offchainWorker) throw new Error('offchain worker not found');
|
|
83
81
|
return block.chain.offchainWorker.get(key);
|
|
84
82
|
},
|
|
85
|
-
offchainTimestamp: async
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
offchainRandomSeed: async function() {
|
|
89
|
-
return randomAsHex(32);
|
|
90
|
-
},
|
|
91
|
-
offchainSubmitTransaction: async function(tx) {
|
|
83
|
+
offchainTimestamp: async ()=>Date.now(),
|
|
84
|
+
offchainRandomSeed: async ()=>randomAsHex(32),
|
|
85
|
+
offchainSubmitTransaction: async (tx)=>{
|
|
92
86
|
if (!block.chain.offchainWorker) throw new Error('offchain worker not found');
|
|
93
87
|
try {
|
|
94
88
|
const hash = await block.chain.offchainWorker.pushExtrinsic(block, tx);
|
|
@@ -106,22 +100,22 @@ export const taskHandler = (block)=>{
|
|
|
106
100
|
};
|
|
107
101
|
};
|
|
108
102
|
export const emptyTaskHandler = {
|
|
109
|
-
getStorage: async
|
|
103
|
+
getStorage: async (_key)=>{
|
|
110
104
|
throw new Error('Method not implemented');
|
|
111
105
|
},
|
|
112
|
-
getNextKey: async
|
|
106
|
+
getNextKey: async (_prefix, _key)=>{
|
|
113
107
|
throw new Error('Method not implemented');
|
|
114
108
|
},
|
|
115
|
-
offchainGetStorage: async
|
|
109
|
+
offchainGetStorage: async (_key)=>{
|
|
116
110
|
throw new Error('Method not implemented');
|
|
117
111
|
},
|
|
118
|
-
offchainTimestamp: async
|
|
112
|
+
offchainTimestamp: async ()=>{
|
|
119
113
|
throw new Error('Method not implemented');
|
|
120
114
|
},
|
|
121
|
-
offchainRandomSeed: async
|
|
115
|
+
offchainRandomSeed: async ()=>{
|
|
122
116
|
throw new Error('Method not implemented');
|
|
123
117
|
},
|
|
124
|
-
offchainSubmitTransaction: async
|
|
118
|
+
offchainSubmitTransaction: async (_tx)=>{
|
|
125
119
|
throw new Error('Method not implemented');
|
|
126
120
|
}
|
|
127
121
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as Comlink from 'comlink';
|
|
2
1
|
import * as pkg from '@acala-network/chopsticks-executor';
|
|
2
|
+
import * as Comlink from 'comlink';
|
|
3
3
|
import { parentPort } from 'node:worker_threads';
|
|
4
4
|
import nodeEndpoint from 'comlink/dist/umd/node-adapter.js';
|
|
5
5
|
const getRuntimeVersion = async (code)=>{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import threads from 'node:worker_threads';
|
|
1
2
|
import { wrap } from 'comlink';
|
|
2
3
|
import nodeEndpoint from 'comlink/dist/umd/node-adapter.js';
|
|
3
|
-
import threads from 'node:worker_threads';
|
|
4
4
|
export const startWorker = async ()=>{
|
|
5
5
|
const worker = new threads.Worker(new URL('node-wasm-executor.js', import.meta.url), {
|
|
6
6
|
name: 'chopsticks-wasm-executor'
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Blockchain } from '../blockchain/index.js';
|
|
1
|
+
import type { Blockchain } from '../blockchain/index.js';
|
|
2
2
|
export declare const connectDownward: (relaychain: Blockchain, parachain: Blockchain) => Promise<void>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Blockchain } from '../blockchain/index.js';
|
|
1
|
+
import type { Blockchain } from '../blockchain/index.js';
|
|
2
2
|
export declare const connectHorizontal: (parachains: Record<number, Blockchain>, disableAutoHrmp?: boolean) => Promise<void>;
|
package/dist/esm/xcm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Blockchain } from '../blockchain/index.js';
|
|
1
|
+
import type { Blockchain } from '../blockchain/index.js';
|
|
2
2
|
export declare const xcmLogger: import("pino").default.Logger<never, boolean>;
|
|
3
3
|
export declare const connectVertical: (relaychain: Blockchain, parachain: Blockchain) => Promise<void>;
|
|
4
4
|
export declare const connectParachains: (parachains: Blockchain[], disableAutoHrmp?: boolean) => Promise<void>;
|