@acala-network/chopsticks-core 1.0.2-2 → 1.0.3
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 +5 -4
- package/dist/cjs/api.js +23 -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 +10 -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 +13 -12
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/logger.js +5 -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 +2 -2
- 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 +5 -4
- package/dist/esm/api.js +23 -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 +10 -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 +4 -3
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/logger.js +5 -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 +2 -2
- 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 +16 -16
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'eventemitter3';
|
|
2
|
-
import { allHandlers } from './rpc/index.js';
|
|
3
2
|
import { defaultLogger } from './logger.js';
|
|
3
|
+
import { allHandlers } from './rpc/index.js';
|
|
4
4
|
import { setup } from './setup.js';
|
|
5
5
|
const providerHandlers = {
|
|
6
6
|
...allHandlers
|
|
@@ -94,15 +94,14 @@ const logger = defaultLogger.child({
|
|
|
94
94
|
type: subscription.type
|
|
95
95
|
};
|
|
96
96
|
return subid;
|
|
97
|
-
} else {
|
|
98
|
-
logger.debug('call', {
|
|
99
|
-
method,
|
|
100
|
-
params
|
|
101
|
-
});
|
|
102
|
-
return rpcHandler({
|
|
103
|
-
chain: this.chain
|
|
104
|
-
}, params, this.subscriptionManager);
|
|
105
97
|
}
|
|
98
|
+
logger.debug('call', {
|
|
99
|
+
method,
|
|
100
|
+
params
|
|
101
|
+
});
|
|
102
|
+
return rpcHandler({
|
|
103
|
+
chain: this.chain
|
|
104
|
+
}, params, this.subscriptionManager);
|
|
106
105
|
} catch (e) {
|
|
107
106
|
logger.error('send error.', e);
|
|
108
107
|
throw e;
|
package/dist/esm/database.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Genesis } from './schema/index.js';
|
|
4
|
-
import { JsCallback } from './wasm-executor/index.js';
|
|
1
|
+
import type { ProviderInterface, ProviderInterfaceCallback, ProviderInterfaceEmitCb, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types';
|
|
2
|
+
import type { HexString } from '@polkadot/util/types';
|
|
3
|
+
import { type Genesis } from './schema/index.js';
|
|
4
|
+
import { type JsCallback } from './wasm-executor/index.js';
|
|
5
5
|
/**
|
|
6
6
|
* Provider to start a chain from genesis
|
|
7
7
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EventEmitter } from 'eventemitter3';
|
|
2
|
+
import { defaultLogger, isPrefixedChildKey } from './index.js';
|
|
2
3
|
import { genesisSchema } from './schema/index.js';
|
|
3
4
|
import { calculateStateRoot, emptyTaskHandler } from './wasm-executor/index.js';
|
|
4
|
-
import { defaultLogger, isPrefixedChildKey } from './index.js';
|
|
5
5
|
/**
|
|
6
6
|
* Provider to start a chain from genesis
|
|
7
7
|
*/ export class GenesisProvider {
|
|
@@ -86,7 +86,7 @@ import { defaultLogger, isPrefixedChildKey } from './index.js';
|
|
|
86
86
|
const storage = this.#genesis.genesis.raw.top;
|
|
87
87
|
return {
|
|
88
88
|
...emptyTaskHandler,
|
|
89
|
-
getStorage: async
|
|
89
|
+
getStorage: async (key)=>{
|
|
90
90
|
if (isPrefixedChildKey(key)) {
|
|
91
91
|
defaultLogger.warn({
|
|
92
92
|
key
|
|
@@ -95,7 +95,7 @@ import { defaultLogger, isPrefixedChildKey } from './index.js';
|
|
|
95
95
|
}
|
|
96
96
|
return storage[key];
|
|
97
97
|
},
|
|
98
|
-
getNextKey: async
|
|
98
|
+
getNextKey: async (prefix, key)=>{
|
|
99
99
|
if (isPrefixedChildKey(key)) {
|
|
100
100
|
defaultLogger.warn({
|
|
101
101
|
prefix,
|
|
@@ -127,6 +127,7 @@ import { defaultLogger, isPrefixedChildKey } from './index.js';
|
|
|
127
127
|
case 'chain_getBlock':
|
|
128
128
|
return this.getBlock();
|
|
129
129
|
case 'chain_getBlockHash':
|
|
130
|
+
case 'chain_getFinalizedHead':
|
|
130
131
|
return this.blockHash;
|
|
131
132
|
case 'state_getKeysPaged':
|
|
132
133
|
case 'state_getKeysPagedAt':
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/logger.js
CHANGED
|
@@ -24,9 +24,11 @@ const innerTruncate = (level = 0)=>(val)=>{
|
|
|
24
24
|
}
|
|
25
25
|
switch(typeof val){
|
|
26
26
|
case 'string':
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
{
|
|
28
|
+
const maxLength = verboseLog ? 10 * 1024 : 66;
|
|
29
|
+
if (val.length > maxLength) {
|
|
30
|
+
return `${val.slice(0, 34)}…${val.slice(-32)}`;
|
|
31
|
+
}
|
|
30
32
|
return val;
|
|
31
33
|
}
|
|
32
34
|
case 'object':
|
package/dist/esm/offchain.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { HexString } from '@polkadot/util/types';
|
|
2
|
+
import type { Block } from './blockchain/block.js';
|
|
3
3
|
export declare class OffchainWorker {
|
|
4
4
|
readonly pendingExtrinsics: HexString[];
|
|
5
5
|
readonly offchainStorage: Map<string, string | null | undefined>;
|
package/dist/esm/offchain.js
CHANGED
|
@@ -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;
|
|
@@ -20,7 +20,7 @@ export const processOptions = async (options)=>{
|
|
|
20
20
|
await api.isReady;
|
|
21
21
|
let blockHash;
|
|
22
22
|
if (options.block == null) {
|
|
23
|
-
blockHash = await api.
|
|
23
|
+
blockHash = await api.getFinalizedHead().then((hash)=>{
|
|
24
24
|
if (!hash) {
|
|
25
25
|
// should not happen, but just in case
|
|
26
26
|
throw new Error('Cannot find block hash');
|
|
@@ -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[];
|