@acala-network/chopsticks-core 0.9.4-2 → 0.9.4-4
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/blockchain/inherent/parachain/validation-data.js +1 -13
- package/dist/cjs/rpc/substrate/author.js +6 -0
- package/dist/cjs/utils/decoder.js +21 -1
- package/dist/cjs/wasm-executor/browser-wasm-executor.js +4 -4
- package/dist/{types → cjs}/wasm-executor/index.d.ts +6 -4
- package/dist/cjs/wasm-executor/index.js +4 -4
- package/dist/cjs/wasm-executor/node-wasm-executor.js +4 -4
- package/dist/esm/api.d.ts +56 -0
- package/dist/esm/blockchain/block-builder.d.ts +15 -0
- package/dist/esm/blockchain/block.d.ts +92 -0
- package/dist/esm/blockchain/head-state.d.ts +15 -0
- package/dist/esm/blockchain/index.d.ts +172 -0
- package/dist/esm/blockchain/inherent/index.d.ts +19 -0
- package/dist/esm/blockchain/inherent/para-enter.d.ts +7 -0
- package/dist/esm/blockchain/inherent/parachain/babe-randomness.d.ts +7 -0
- package/dist/esm/blockchain/inherent/parachain/nimbus-author-inherent.d.ts +7 -0
- package/dist/esm/blockchain/inherent/parachain/validation-data.d.ts +19 -0
- package/dist/esm/blockchain/inherent/parachain/validation-data.js +1 -13
- package/dist/esm/blockchain/storage-layer.d.ts +47 -0
- package/dist/esm/blockchain/txpool.d.ts +48 -0
- package/dist/esm/chopsticks-provider.d.ts +32 -0
- package/dist/esm/database.d.ts +26 -0
- package/dist/esm/genesis-provider.d.ts +52 -0
- package/dist/esm/index.d.ts +28 -0
- package/dist/esm/logger.d.ts +7 -0
- package/dist/esm/offchain.d.ts +10 -0
- package/dist/esm/rpc/index.d.ts +5 -0
- package/dist/esm/rpc/shared.d.ts +27 -0
- package/dist/esm/rpc/substrate/author.d.ts +28 -0
- package/dist/esm/rpc/substrate/author.js +6 -0
- package/dist/esm/rpc/substrate/chain.d.ts +45 -0
- package/dist/esm/rpc/substrate/index.d.ts +66 -0
- package/dist/esm/rpc/substrate/payment.d.ts +16 -0
- package/dist/esm/rpc/substrate/state.d.ts +97 -0
- package/dist/esm/rpc/substrate/system.d.ts +28 -0
- package/dist/esm/schema/index.d.ts +62 -0
- package/dist/esm/setup.d.ts +20 -0
- package/dist/esm/utils/decoder.d.ts +28 -0
- package/dist/esm/utils/decoder.js +21 -1
- package/dist/esm/utils/index.d.ts +23 -0
- package/dist/esm/utils/key-cache.d.ts +10 -0
- package/dist/esm/utils/proof.d.ts +16 -0
- package/dist/esm/utils/set-storage.d.ts +7 -0
- package/dist/esm/utils/time-travel.d.ts +5 -0
- package/dist/esm/utils/well-known-keys.d.ts +7 -0
- package/dist/esm/wasm-executor/browser-wasm-executor.js +4 -4
- package/dist/esm/wasm-executor/browser-worker.d.ts +4 -0
- package/dist/esm/wasm-executor/index.d.ts +82 -0
- package/dist/esm/wasm-executor/index.js +4 -4
- package/dist/esm/wasm-executor/node-wasm-executor.js +4 -4
- package/dist/esm/wasm-executor/node-worker.d.ts +4 -0
- package/dist/esm/xcm/downward.d.ts +2 -0
- package/dist/esm/xcm/horizontal.d.ts +2 -0
- package/dist/esm/xcm/index.d.ts +9 -0
- package/dist/esm/xcm/upward.d.ts +2 -0
- package/package.json +8 -15
- /package/dist/{types → cjs}/api.d.ts +0 -0
- /package/dist/{types → cjs}/blockchain/block-builder.d.ts +0 -0
- /package/dist/{types → cjs}/blockchain/block.d.ts +0 -0
- /package/dist/{types → cjs}/blockchain/head-state.d.ts +0 -0
- /package/dist/{types → cjs}/blockchain/index.d.ts +0 -0
- /package/dist/{types → cjs}/blockchain/inherent/index.d.ts +0 -0
- /package/dist/{types → cjs}/blockchain/inherent/para-enter.d.ts +0 -0
- /package/dist/{types → cjs}/blockchain/inherent/parachain/babe-randomness.d.ts +0 -0
- /package/dist/{types → cjs}/blockchain/inherent/parachain/nimbus-author-inherent.d.ts +0 -0
- /package/dist/{types → cjs}/blockchain/inherent/parachain/validation-data.d.ts +0 -0
- /package/dist/{types → cjs}/blockchain/storage-layer.d.ts +0 -0
- /package/dist/{types → cjs}/blockchain/txpool.d.ts +0 -0
- /package/dist/{types → cjs}/chopsticks-provider.d.ts +0 -0
- /package/dist/{types → cjs}/database.d.ts +0 -0
- /package/dist/{types → cjs}/genesis-provider.d.ts +0 -0
- /package/dist/{types → cjs}/index.d.ts +0 -0
- /package/dist/{types → cjs}/logger.d.ts +0 -0
- /package/dist/{types → cjs}/offchain.d.ts +0 -0
- /package/dist/{types → cjs}/rpc/index.d.ts +0 -0
- /package/dist/{types → cjs}/rpc/shared.d.ts +0 -0
- /package/dist/{types → cjs}/rpc/substrate/author.d.ts +0 -0
- /package/dist/{types → cjs}/rpc/substrate/chain.d.ts +0 -0
- /package/dist/{types → cjs}/rpc/substrate/index.d.ts +0 -0
- /package/dist/{types → cjs}/rpc/substrate/payment.d.ts +0 -0
- /package/dist/{types → cjs}/rpc/substrate/state.d.ts +0 -0
- /package/dist/{types → cjs}/rpc/substrate/system.d.ts +0 -0
- /package/dist/{types → cjs}/schema/index.d.ts +0 -0
- /package/dist/{types → cjs}/setup.d.ts +0 -0
- /package/dist/{types → cjs}/utils/decoder.d.ts +0 -0
- /package/dist/{types → cjs}/utils/index.d.ts +0 -0
- /package/dist/{types → cjs}/utils/key-cache.d.ts +0 -0
- /package/dist/{types → cjs}/utils/proof.d.ts +0 -0
- /package/dist/{types → cjs}/utils/set-storage.d.ts +0 -0
- /package/dist/{types → cjs}/utils/time-travel.d.ts +0 -0
- /package/dist/{types → cjs}/utils/well-known-keys.d.ts +0 -0
- /package/dist/{types → cjs}/wasm-executor/browser-worker.d.ts +0 -0
- /package/dist/{types → cjs}/wasm-executor/node-worker.d.ts +0 -0
- /package/dist/{types → cjs}/xcm/downward.d.ts +0 -0
- /package/dist/{types → cjs}/xcm/horizontal.d.ts +0 -0
- /package/dist/{types → cjs}/xcm/index.d.ts +0 -0
- /package/dist/{types → cjs}/xcm/upward.d.ts +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import '@polkadot/types-codec';
|
|
2
|
+
import { RegisteredTypes } from '@polkadot/types/types';
|
|
3
|
+
import { Blockchain } from './blockchain/index.js';
|
|
4
|
+
import { BuildBlockMode } from './blockchain/txpool.js';
|
|
5
|
+
import { Database } from './database.js';
|
|
6
|
+
import { GenesisProvider } from './genesis-provider.js';
|
|
7
|
+
export type SetupOptions = {
|
|
8
|
+
endpoint?: string | string[];
|
|
9
|
+
block?: string | number | null;
|
|
10
|
+
genesis?: GenesisProvider;
|
|
11
|
+
buildBlockMode?: BuildBlockMode;
|
|
12
|
+
db?: Database;
|
|
13
|
+
mockSignatureHost?: boolean;
|
|
14
|
+
allowUnresolvedImports?: boolean;
|
|
15
|
+
runtimeLogLevel?: number;
|
|
16
|
+
registeredTypes?: RegisteredTypes;
|
|
17
|
+
offchainWorker?: boolean;
|
|
18
|
+
maxMemoryBlockCount?: number;
|
|
19
|
+
};
|
|
20
|
+
export declare const setup: (options: SetupOptions) => Promise<Blockchain>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import '@polkadot/types-codec';
|
|
2
|
+
import { Block } from '../blockchain/block.js';
|
|
3
|
+
import { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
|
|
4
|
+
import { HexString } from '@polkadot/util/types';
|
|
5
|
+
import { StorageEntry } from '@polkadot/types/primitive/types';
|
|
6
|
+
import { StorageKey } from '@polkadot/types';
|
|
7
|
+
export declare const decodeKey: (meta: DecoratedMeta, block: Block, key: HexString) => {
|
|
8
|
+
storage?: StorageEntry | undefined;
|
|
9
|
+
decodedKey?: StorageKey<import("@polkadot/types-codec/types").AnyTuple> | undefined;
|
|
10
|
+
};
|
|
11
|
+
export declare const decodeKeyValue: (meta: DecoratedMeta, block: Block, key: HexString, value?: HexString | null, toHuman?: boolean) => {
|
|
12
|
+
section: string;
|
|
13
|
+
method: string;
|
|
14
|
+
key: any[];
|
|
15
|
+
value: import("@polkadot/types-codec/types").AnyJson;
|
|
16
|
+
} | undefined;
|
|
17
|
+
export declare const toStorageObject: (decoded: ReturnType<typeof decodeKeyValue>) => {
|
|
18
|
+
[x: string]: {
|
|
19
|
+
[x: string]: import("@polkadot/types-codec/types").AnyJson;
|
|
20
|
+
};
|
|
21
|
+
} | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Decode block storage diff
|
|
24
|
+
* @param block Block to compare storage diff
|
|
25
|
+
* @param diff Storage diff
|
|
26
|
+
* @returns decoded old state and new state
|
|
27
|
+
*/
|
|
28
|
+
export declare const decodeBlockStorageDiff: (block: Block, diff: [HexString, HexString | null][]) => Promise<{}[]>;
|
|
@@ -3,6 +3,10 @@ import { LRUCache } from 'lru-cache';
|
|
|
3
3
|
import { hexToU8a, u8aToHex } from '@polkadot/util';
|
|
4
4
|
import _ from 'lodash';
|
|
5
5
|
import { decodeWellKnownKey } from './well-known-keys.js';
|
|
6
|
+
import { defaultLogger } from '../logger.js';
|
|
7
|
+
const logger = defaultLogger.child({
|
|
8
|
+
module: 'decoder'
|
|
9
|
+
});
|
|
6
10
|
const _CACHE = {};
|
|
7
11
|
function createCache() {
|
|
8
12
|
return new LRUCache({
|
|
@@ -56,11 +60,27 @@ export const decodeKeyValue = (meta, block, key, value, toHuman = true)=>{
|
|
|
56
60
|
}
|
|
57
61
|
const { storage, decodedKey } = decodeKey(meta, block, key);
|
|
58
62
|
if (!storage || !decodedKey) {
|
|
63
|
+
logger.warn({
|
|
64
|
+
key,
|
|
65
|
+
value
|
|
66
|
+
}, 'Failed to decode storage key');
|
|
59
67
|
return undefined;
|
|
60
68
|
}
|
|
61
69
|
const decodeValue = ()=>{
|
|
62
70
|
if (!value) return null;
|
|
63
|
-
|
|
71
|
+
try {
|
|
72
|
+
return meta.registry.createType(decodedKey.outputType, hexToU8a(value))[toHuman ? 'toHuman' : 'toJSON']();
|
|
73
|
+
} catch (error) {
|
|
74
|
+
logger.warn(error, 'Failed to decode storage value');
|
|
75
|
+
logger.warn({
|
|
76
|
+
key,
|
|
77
|
+
value,
|
|
78
|
+
section: storage.section,
|
|
79
|
+
method: storage.method,
|
|
80
|
+
args: decodedKey.args
|
|
81
|
+
}, 'Failed to decode storage value');
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
64
84
|
};
|
|
65
85
|
return {
|
|
66
86
|
section: storage.section,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { HexString } from '@polkadot/util/types';
|
|
2
|
+
import { StorageKey } from '@polkadot/types';
|
|
3
|
+
import { Blockchain } from '../blockchain/index.js';
|
|
4
|
+
export * from './set-storage.js';
|
|
5
|
+
export * from './time-travel.js';
|
|
6
|
+
export * from './decoder.js';
|
|
7
|
+
export type GetKeys = (startKey?: string) => Promise<StorageKey<any>[]>;
|
|
8
|
+
export type ProcessKey = (key: StorageKey<any>) => any;
|
|
9
|
+
export declare function fetchKeys(getKeys: GetKeys, processKey: ProcessKey): Promise<void>;
|
|
10
|
+
export declare function fetchKeysToArray(getKeys: GetKeys): Promise<StorageKey<any>[]>;
|
|
11
|
+
export declare const compactHex: (value: Uint8Array) => HexString;
|
|
12
|
+
export declare const getParaId: (chain: Blockchain) => Promise<import("@polkadot/types").U32>;
|
|
13
|
+
export declare const isUrl: (url: string) => boolean;
|
|
14
|
+
export type Deferred<T> = {
|
|
15
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
16
|
+
reject: (reason?: any) => void;
|
|
17
|
+
promise: Promise<T>;
|
|
18
|
+
};
|
|
19
|
+
export declare function defer<T>(): Deferred<T>;
|
|
20
|
+
export declare const prefixedChildKey: (prefix: HexString, key: HexString) => string;
|
|
21
|
+
export declare const isPrefixedChildKey: (key: HexString) => boolean;
|
|
22
|
+
export declare const splitChildKey: (key: HexString) => never[] | [`0x${string}`, `0x${string}`];
|
|
23
|
+
export declare const stripChildPrefix: (key: HexString) => `0x${string}`;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HexString } from '@polkadot/util/types';
|
|
2
|
+
export declare const PREFIX_LENGTH = 66;
|
|
3
|
+
export default class KeyCache {
|
|
4
|
+
readonly ranges: Array<{
|
|
5
|
+
prefix: string;
|
|
6
|
+
keys: string[];
|
|
7
|
+
}>;
|
|
8
|
+
feed(keys: HexString[]): void;
|
|
9
|
+
next(startKey: HexString): Promise<HexString | undefined>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HrmpChannelId } from '@polkadot/types/interfaces';
|
|
2
|
+
import { u32 } from '@polkadot/types';
|
|
3
|
+
export declare const WELL_KNOWN_KEYS: {
|
|
4
|
+
EPOCH_INDEX: `0x${string}`;
|
|
5
|
+
CURRENT_BLOCK_RANDOMNESS: `0x${string}`;
|
|
6
|
+
ONE_EPOCH_AGO_RANDOMNESS: `0x${string}`;
|
|
7
|
+
TWO_EPOCHS_AGO_RANDOMNESS: `0x${string}`;
|
|
8
|
+
CURRENT_SLOT: `0x${string}`;
|
|
9
|
+
ACTIVE_CONFIG: `0x${string}`;
|
|
10
|
+
};
|
|
11
|
+
export declare const dmqMqcHead: (paraId: u32) => `0x${string}`;
|
|
12
|
+
export declare const upgradeGoAheadSignal: (paraId: u32) => `0x${string}`;
|
|
13
|
+
export declare const hrmpIngressChannelIndex: (paraId: u32) => `0x${string}`;
|
|
14
|
+
export declare const hrmpEgressChannelIndex: (paraId: u32) => `0x${string}`;
|
|
15
|
+
export declare const hrmpChannels: (channelId: HrmpChannelId) => `0x${string}`;
|
|
16
|
+
export declare const paraHead: (paraId: u32) => `0x${string}`;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HexString } from '@polkadot/util/types';
|
|
2
|
+
import { Blockchain } from '../blockchain/index.js';
|
|
3
|
+
type RawStorageValues = [string, string | null][];
|
|
4
|
+
type StorageConfig = Record<string, Record<string, any>>;
|
|
5
|
+
export type StorageValues = RawStorageValues | StorageConfig;
|
|
6
|
+
export declare const setStorage: (chain: Blockchain, storage: StorageValues, blockHash?: HexString) => Promise<HexString>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Blockchain } from '../blockchain/index.js';
|
|
2
|
+
export declare const getCurrentSlot: (chain: Blockchain) => Promise<number>;
|
|
3
|
+
export declare const getCurrentTimestamp: (chain: Blockchain) => Promise<bigint>;
|
|
4
|
+
export declare const getSlotDuration: (chain: Blockchain) => Promise<number>;
|
|
5
|
+
export declare const timeTravel: (chain: Blockchain, timestamp: number) => Promise<void>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HexString } from '@polkadot/util/types';
|
|
2
|
+
import { Registry } from '@polkadot/types-codec/types';
|
|
3
|
+
export declare const decodeWellKnownKey: (registry: Registry, key: HexString, value?: HexString | null) => {
|
|
4
|
+
name: string;
|
|
5
|
+
key: any[];
|
|
6
|
+
value: import("@polkadot/types-codec/types").AnyJson;
|
|
7
|
+
} | undefined;
|
|
@@ -7,11 +7,11 @@ const getRuntimeVersion = async (code)=>{
|
|
|
7
7
|
const calculateStateRoot = async (entries, trie_version)=>{
|
|
8
8
|
return pkg.calculate_state_root(entries, trie_version);
|
|
9
9
|
};
|
|
10
|
-
const decodeProof = async (trieRootHash,
|
|
11
|
-
return pkg.decode_proof(trieRootHash,
|
|
10
|
+
const decodeProof = async (trieRootHash, nodes)=>{
|
|
11
|
+
return pkg.decode_proof(trieRootHash, nodes);
|
|
12
12
|
};
|
|
13
|
-
const createProof = async (nodes,
|
|
14
|
-
return pkg.create_proof(nodes,
|
|
13
|
+
const createProof = async (nodes, updates)=>{
|
|
14
|
+
return pkg.create_proof(nodes, updates);
|
|
15
15
|
};
|
|
16
16
|
const runTask = async (task, callback)=>{
|
|
17
17
|
return pkg.run_task(task, callback, 'info');
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as Comlink from 'comlink';
|
|
2
|
+
import { HexString } from '@polkadot/util/types';
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
import { Block } from '../blockchain/block.js';
|
|
5
|
+
import type { JsCallback } from '@acala-network/chopsticks-executor';
|
|
6
|
+
export { JsCallback };
|
|
7
|
+
export type RuntimeVersion = {
|
|
8
|
+
specName: string;
|
|
9
|
+
implName: string;
|
|
10
|
+
authoringVersion: number;
|
|
11
|
+
specVersion: number;
|
|
12
|
+
implVersion: number;
|
|
13
|
+
apis: [HexString, number][];
|
|
14
|
+
transactionVersion: number;
|
|
15
|
+
stateVersion: number;
|
|
16
|
+
};
|
|
17
|
+
export type RuntimeLog = {
|
|
18
|
+
message: string;
|
|
19
|
+
level?: number;
|
|
20
|
+
target?: string;
|
|
21
|
+
};
|
|
22
|
+
export type TaskCallResponse = {
|
|
23
|
+
result: HexString;
|
|
24
|
+
storageDiff: [HexString, HexString | null][];
|
|
25
|
+
offchainStorageDiff: [HexString, HexString | null][];
|
|
26
|
+
runtimeLogs: RuntimeLog[];
|
|
27
|
+
};
|
|
28
|
+
export type TaskResponse = {
|
|
29
|
+
Call: TaskCallResponse;
|
|
30
|
+
} | {
|
|
31
|
+
Error: string;
|
|
32
|
+
};
|
|
33
|
+
export interface WasmExecutor {
|
|
34
|
+
getRuntimeVersion: (code: HexString) => Promise<RuntimeVersion>;
|
|
35
|
+
calculateStateRoot: (entries: [HexString, HexString][], trie_version: number) => Promise<HexString>;
|
|
36
|
+
createProof: (nodes: HexString[], updates: [HexString, HexString | null][]) => Promise<[HexString, HexString[]]>;
|
|
37
|
+
decodeProof: (trieRootHash: HexString, nodes: HexString[]) => Promise<[[HexString, HexString]]>;
|
|
38
|
+
runTask: (task: {
|
|
39
|
+
wasm: HexString;
|
|
40
|
+
calls: [string, HexString[]][];
|
|
41
|
+
mockSignatureHost: boolean;
|
|
42
|
+
allowUnresolvedImports: boolean;
|
|
43
|
+
runtimeLogLevel: number;
|
|
44
|
+
}, callback?: JsCallback) => Promise<TaskResponse>;
|
|
45
|
+
testing: (callback: JsCallback, key: any) => Promise<any>;
|
|
46
|
+
}
|
|
47
|
+
export declare const getWorker: () => Promise<{
|
|
48
|
+
remote: Comlink.Remote<WasmExecutor>;
|
|
49
|
+
terminate: () => Promise<void>;
|
|
50
|
+
}>;
|
|
51
|
+
export declare const getRuntimeVersion: ((code: HexString) => Promise<RuntimeVersion>) & _.MemoizedFunction;
|
|
52
|
+
export declare const calculateStateRoot: (entries: [HexString, HexString][], trie_version: number) => Promise<HexString>;
|
|
53
|
+
export declare const decodeProof: (trieRootHash: HexString, nodes: HexString[]) => Promise<{
|
|
54
|
+
[key: `0x${string}`]: `0x${string}`;
|
|
55
|
+
}>;
|
|
56
|
+
export declare const createProof: (nodes: HexString[], updates: [HexString, HexString | null][]) => Promise<{
|
|
57
|
+
trieRootHash: `0x${string}`;
|
|
58
|
+
nodes: `0x${string}`[];
|
|
59
|
+
}>;
|
|
60
|
+
export declare const runTask: (task: {
|
|
61
|
+
wasm: HexString;
|
|
62
|
+
calls: [string, HexString[]][];
|
|
63
|
+
mockSignatureHost: boolean;
|
|
64
|
+
allowUnresolvedImports: boolean;
|
|
65
|
+
runtimeLogLevel: number;
|
|
66
|
+
}, callback?: JsCallback) => Promise<{
|
|
67
|
+
Call: TaskCallResponse;
|
|
68
|
+
} | {
|
|
69
|
+
Error: string;
|
|
70
|
+
}>;
|
|
71
|
+
export declare const taskHandler: (block: Block) => JsCallback;
|
|
72
|
+
export declare const emptyTaskHandler: {
|
|
73
|
+
getStorage: (_key: HexString) => Promise<never>;
|
|
74
|
+
getStateRoot: () => Promise<never>;
|
|
75
|
+
getNextKey: (_prefix: HexString, _key: HexString) => Promise<never>;
|
|
76
|
+
offchainGetStorage: (_key: HexString) => Promise<never>;
|
|
77
|
+
offchainTimestamp: () => Promise<never>;
|
|
78
|
+
offchainRandomSeed: () => Promise<never>;
|
|
79
|
+
offchainSubmitTransaction: (_tx: HexString) => Promise<never>;
|
|
80
|
+
};
|
|
81
|
+
export declare const getAuraSlotDuration: ((wasm: HexString) => Promise<number>) & _.MemoizedFunction;
|
|
82
|
+
export declare const destroyWorker: () => Promise<void>;
|
|
@@ -33,17 +33,17 @@ export const calculateStateRoot = async (entries, trie_version)=>{
|
|
|
33
33
|
const worker = await getWorker();
|
|
34
34
|
return worker.remote.calculateStateRoot(entries, trie_version);
|
|
35
35
|
};
|
|
36
|
-
export const decodeProof = async (trieRootHash,
|
|
36
|
+
export const decodeProof = async (trieRootHash, nodes)=>{
|
|
37
37
|
const worker = await getWorker();
|
|
38
|
-
const result = await worker.remote.decodeProof(trieRootHash,
|
|
38
|
+
const result = await worker.remote.decodeProof(trieRootHash, nodes);
|
|
39
39
|
return result.reduce((accum, [key, value])=>{
|
|
40
40
|
accum[key] = value;
|
|
41
41
|
return accum;
|
|
42
42
|
}, {});
|
|
43
43
|
};
|
|
44
|
-
export const createProof = async (nodes,
|
|
44
|
+
export const createProof = async (nodes, updates)=>{
|
|
45
45
|
const worker = await getWorker();
|
|
46
|
-
const [trieRootHash, newNodes] = await worker.remote.createProof(nodes,
|
|
46
|
+
const [trieRootHash, newNodes] = await worker.remote.createProof(nodes, updates);
|
|
47
47
|
return {
|
|
48
48
|
trieRootHash,
|
|
49
49
|
nodes: newNodes
|
|
@@ -9,11 +9,11 @@ const getRuntimeVersion = async (code)=>{
|
|
|
9
9
|
const calculateStateRoot = async (entries, trie_version)=>{
|
|
10
10
|
return pkg.calculate_state_root(entries, trie_version);
|
|
11
11
|
};
|
|
12
|
-
const decodeProof = async (trieRootHash,
|
|
13
|
-
return pkg.decode_proof(trieRootHash,
|
|
12
|
+
const decodeProof = async (trieRootHash, nodes)=>{
|
|
13
|
+
return pkg.decode_proof(trieRootHash, nodes);
|
|
14
14
|
};
|
|
15
|
-
const createProof = async (nodes,
|
|
16
|
-
return pkg.create_proof(nodes,
|
|
15
|
+
const createProof = async (nodes, updates)=>{
|
|
16
|
+
return pkg.create_proof(nodes, updates);
|
|
17
17
|
};
|
|
18
18
|
const runTask = async (task, callback)=>{
|
|
19
19
|
return pkg.run_task(task, callback, process.env.RUST_LOG);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Blockchain } from '../blockchain/index.js';
|
|
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/package.json
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acala-network/chopsticks-core",
|
|
3
|
-
"version": "0.9.4-
|
|
3
|
+
"version": "0.9.4-4",
|
|
4
4
|
"author": "Acala Developers <hello@acala.network>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"clean": "rm -rf dist",
|
|
9
|
-
"build": "yarn clean && yarn build:cjs && yarn build:esm
|
|
10
|
-
"build:cjs": "swc ./src --config-file ../../.cjsswcrc -d dist/cjs && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
|
|
11
|
-
"build:esm": "swc ./src --config-file ../../.esmswcrc -d dist/esm",
|
|
12
|
-
"build:types": "tsc -p tsconfig.json --emitDeclarationOnly --outDir dist/types",
|
|
8
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo",
|
|
9
|
+
"build": "yarn clean && yarn build:cjs && yarn build:esm",
|
|
10
|
+
"build:cjs": "swc ./src --config-file ../../.cjsswcrc -d dist/cjs && tsc -p tsconfig.json --declarationDir dist/cjs && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
|
|
11
|
+
"build:esm": "swc ./src --config-file ../../.esmswcrc -d dist/esm && tsc -p tsconfig.json --declarationDir dist/esm",
|
|
13
12
|
"docs:prep": "typedoc"
|
|
14
13
|
},
|
|
15
14
|
"dependencies": {
|
|
16
|
-
"@acala-network/chopsticks-executor": "0.9.4-
|
|
15
|
+
"@acala-network/chopsticks-executor": "0.9.4-4",
|
|
17
16
|
"@polkadot/rpc-provider": "^10.10.1",
|
|
18
17
|
"@polkadot/types": "^10.10.1",
|
|
19
18
|
"@polkadot/types-codec": "^10.10.1",
|
|
@@ -38,27 +37,21 @@
|
|
|
38
37
|
},
|
|
39
38
|
"files": [
|
|
40
39
|
"dist/esm/**",
|
|
41
|
-
"dist/cjs/**"
|
|
42
|
-
"dist/types/**"
|
|
40
|
+
"dist/cjs/**"
|
|
43
41
|
],
|
|
44
42
|
"main": "./dist/cjs/index.js",
|
|
45
43
|
"module": "./dist/esm/index.js",
|
|
46
|
-
"types": "./dist/types/index.d.ts",
|
|
47
44
|
"exports": {
|
|
48
45
|
".": {
|
|
49
|
-
"types": "./dist/types/index.d.ts",
|
|
50
46
|
"require": "./dist/cjs/index.js",
|
|
51
47
|
"import": "./dist/esm/index.js",
|
|
52
48
|
"default": "./dist/esm/index.js"
|
|
53
49
|
},
|
|
54
50
|
"./*": {
|
|
55
|
-
"types": "./dist/types/*.d.ts",
|
|
56
51
|
"require": "./dist/cjs/*.js",
|
|
57
52
|
"import": "./dist/esm/*.js",
|
|
58
53
|
"default": "./dist/esm/*.js"
|
|
59
|
-
}
|
|
60
|
-
"./package.json": "./package.json",
|
|
61
|
-
"./package.cjs.json": "./dist/cjs/package.json"
|
|
54
|
+
}
|
|
62
55
|
},
|
|
63
56
|
"browser": {
|
|
64
57
|
"./dist/cjs/wasm-executor/node-worker.js": "./dist/cjs/wasm-executor/browser-worker.js",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|