@acala-network/chopsticks-core 0.9.4 → 0.9.5-1
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.
|
@@ -4,11 +4,11 @@ import { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
|
|
|
4
4
|
import { HexString } from '@polkadot/util/types';
|
|
5
5
|
import { StorageEntry } from '@polkadot/types/primitive/types';
|
|
6
6
|
import { StorageKey } from '@polkadot/types';
|
|
7
|
-
export declare const decodeKey: (meta: DecoratedMeta,
|
|
7
|
+
export declare const decodeKey: (meta: DecoratedMeta, key: HexString) => {
|
|
8
8
|
storage?: StorageEntry | undefined;
|
|
9
9
|
decodedKey?: StorageKey<import("@polkadot/types-codec/types").AnyTuple> | undefined;
|
|
10
10
|
};
|
|
11
|
-
export declare const decodeKeyValue: (meta: DecoratedMeta,
|
|
11
|
+
export declare const decodeKeyValue: (meta: DecoratedMeta, key: HexString, value?: HexString | null, toHuman?: boolean) => {
|
|
12
12
|
section: string;
|
|
13
13
|
method: string;
|
|
14
14
|
key: any[];
|
|
@@ -48,8 +48,8 @@ const getCache = (uid)=>{
|
|
|
48
48
|
}
|
|
49
49
|
return _CACHE[uid];
|
|
50
50
|
};
|
|
51
|
-
const getStorageEntry = (meta,
|
|
52
|
-
const cache = getCache(
|
|
51
|
+
const getStorageEntry = (meta, key)=>{
|
|
52
|
+
const cache = getCache(meta.registry.metadata.hash.toHex());
|
|
53
53
|
for (const prefix of cache.keys()){
|
|
54
54
|
if (key.startsWith(prefix)) // update the recency of the cache entry
|
|
55
55
|
return cache.get(prefix);
|
|
@@ -65,8 +65,8 @@ const getStorageEntry = (meta, block, key)=>{
|
|
|
65
65
|
}
|
|
66
66
|
return undefined;
|
|
67
67
|
};
|
|
68
|
-
const decodeKey = (meta,
|
|
69
|
-
const storage = getStorageEntry(meta,
|
|
68
|
+
const decodeKey = (meta, key)=>{
|
|
69
|
+
const storage = getStorageEntry(meta, key);
|
|
70
70
|
const decodedKey = meta.registry.createType('StorageKey', key);
|
|
71
71
|
if (storage) {
|
|
72
72
|
decodedKey.setMeta(storage.meta);
|
|
@@ -77,7 +77,7 @@ const decodeKey = (meta, block, key)=>{
|
|
|
77
77
|
}
|
|
78
78
|
return {};
|
|
79
79
|
};
|
|
80
|
-
const decodeKeyValue = (meta,
|
|
80
|
+
const decodeKeyValue = (meta, key, value, toHuman = true)=>{
|
|
81
81
|
const res = (0, _wellknownkeys.decodeWellKnownKey)(meta.registry, key, value);
|
|
82
82
|
if (res) {
|
|
83
83
|
return {
|
|
@@ -87,7 +87,7 @@ const decodeKeyValue = (meta, block, key, value, toHuman = true)=>{
|
|
|
87
87
|
value: res.value
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
|
-
const { storage, decodedKey } = decodeKey(meta,
|
|
90
|
+
const { storage, decodedKey } = decodeKey(meta, key);
|
|
91
91
|
if (!storage || !decodedKey) {
|
|
92
92
|
logger.warn({
|
|
93
93
|
key,
|
|
@@ -149,11 +149,11 @@ const decodeBlockStorageDiff = async (block, diff)=>{
|
|
|
149
149
|
const meta = await block.meta;
|
|
150
150
|
for (const [key, value] of diff){
|
|
151
151
|
const oldValue = await block.get(key);
|
|
152
|
-
const oldDecoded = toStorageObject(decodeKeyValue(meta,
|
|
152
|
+
const oldDecoded = toStorageObject(decodeKeyValue(meta, key, oldValue)) ?? {
|
|
153
153
|
[key]: oldValue
|
|
154
154
|
};
|
|
155
155
|
_lodash.default.merge(oldState, oldDecoded);
|
|
156
|
-
const newDecoded = toStorageObject(decodeKeyValue(meta,
|
|
156
|
+
const newDecoded = toStorageObject(decodeKeyValue(meta, key, value)) ?? {
|
|
157
157
|
[key]: value
|
|
158
158
|
};
|
|
159
159
|
_lodash.default.merge(newState, newDecoded);
|
|
@@ -4,11 +4,11 @@ import { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
|
|
|
4
4
|
import { HexString } from '@polkadot/util/types';
|
|
5
5
|
import { StorageEntry } from '@polkadot/types/primitive/types';
|
|
6
6
|
import { StorageKey } from '@polkadot/types';
|
|
7
|
-
export declare const decodeKey: (meta: DecoratedMeta,
|
|
7
|
+
export declare const decodeKey: (meta: DecoratedMeta, key: HexString) => {
|
|
8
8
|
storage?: StorageEntry | undefined;
|
|
9
9
|
decodedKey?: StorageKey<import("@polkadot/types-codec/types").AnyTuple> | undefined;
|
|
10
10
|
};
|
|
11
|
-
export declare const decodeKeyValue: (meta: DecoratedMeta,
|
|
11
|
+
export declare const decodeKeyValue: (meta: DecoratedMeta, key: HexString, value?: HexString | null, toHuman?: boolean) => {
|
|
12
12
|
section: string;
|
|
13
13
|
method: string;
|
|
14
14
|
key: any[];
|
|
@@ -19,8 +19,8 @@ const getCache = (uid)=>{
|
|
|
19
19
|
}
|
|
20
20
|
return _CACHE[uid];
|
|
21
21
|
};
|
|
22
|
-
const getStorageEntry = (meta,
|
|
23
|
-
const cache = getCache(
|
|
22
|
+
const getStorageEntry = (meta, key)=>{
|
|
23
|
+
const cache = getCache(meta.registry.metadata.hash.toHex());
|
|
24
24
|
for (const prefix of cache.keys()){
|
|
25
25
|
if (key.startsWith(prefix)) // update the recency of the cache entry
|
|
26
26
|
return cache.get(prefix);
|
|
@@ -36,8 +36,8 @@ const getStorageEntry = (meta, block, key)=>{
|
|
|
36
36
|
}
|
|
37
37
|
return undefined;
|
|
38
38
|
};
|
|
39
|
-
export const decodeKey = (meta,
|
|
40
|
-
const storage = getStorageEntry(meta,
|
|
39
|
+
export const decodeKey = (meta, key)=>{
|
|
40
|
+
const storage = getStorageEntry(meta, key);
|
|
41
41
|
const decodedKey = meta.registry.createType('StorageKey', key);
|
|
42
42
|
if (storage) {
|
|
43
43
|
decodedKey.setMeta(storage.meta);
|
|
@@ -48,7 +48,7 @@ export const decodeKey = (meta, block, key)=>{
|
|
|
48
48
|
}
|
|
49
49
|
return {};
|
|
50
50
|
};
|
|
51
|
-
export const decodeKeyValue = (meta,
|
|
51
|
+
export const decodeKeyValue = (meta, key, value, toHuman = true)=>{
|
|
52
52
|
const res = decodeWellKnownKey(meta.registry, key, value);
|
|
53
53
|
if (res) {
|
|
54
54
|
return {
|
|
@@ -58,7 +58,7 @@ export const decodeKeyValue = (meta, block, key, value, toHuman = true)=>{
|
|
|
58
58
|
value: res.value
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
-
const { storage, decodedKey } = decodeKey(meta,
|
|
61
|
+
const { storage, decodedKey } = decodeKey(meta, key);
|
|
62
62
|
if (!storage || !decodedKey) {
|
|
63
63
|
logger.warn({
|
|
64
64
|
key,
|
|
@@ -125,11 +125,11 @@ export const toStorageObject = (decoded)=>{
|
|
|
125
125
|
const meta = await block.meta;
|
|
126
126
|
for (const [key, value] of diff){
|
|
127
127
|
const oldValue = await block.get(key);
|
|
128
|
-
const oldDecoded = toStorageObject(decodeKeyValue(meta,
|
|
128
|
+
const oldDecoded = toStorageObject(decodeKeyValue(meta, key, oldValue)) ?? {
|
|
129
129
|
[key]: oldValue
|
|
130
130
|
};
|
|
131
131
|
_.merge(oldState, oldDecoded);
|
|
132
|
-
const newDecoded = toStorageObject(decodeKeyValue(meta,
|
|
132
|
+
const newDecoded = toStorageObject(decodeKeyValue(meta, key, value)) ?? {
|
|
133
133
|
[key]: value
|
|
134
134
|
};
|
|
135
135
|
_.merge(newState, newDecoded);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acala-network/chopsticks-core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5-1",
|
|
4
4
|
"author": "Acala Developers <hello@acala.network>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"docs:prep": "typedoc"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@acala-network/chopsticks-executor": "0.9.
|
|
15
|
+
"@acala-network/chopsticks-executor": "0.9.5-1",
|
|
16
16
|
"@polkadot/rpc-provider": "^10.10.1",
|
|
17
17
|
"@polkadot/types": "^10.10.1",
|
|
18
18
|
"@polkadot/types-codec": "^10.10.1",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"comlink": "^4.4.1",
|
|
23
23
|
"eventemitter3": "^5.0.1",
|
|
24
24
|
"lodash": "^4.17.21",
|
|
25
|
-
"lru-cache": "^10.0
|
|
25
|
+
"lru-cache": "^10.1.0",
|
|
26
26
|
"pino": "^8.16.2",
|
|
27
27
|
"pino-pretty": "^10.2.3",
|
|
28
28
|
"rxjs": "^7.8.1",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@swc/cli": "0.1.63",
|
|
33
|
-
"@swc/core": "^1.3.
|
|
33
|
+
"@swc/core": "^1.3.100",
|
|
34
34
|
"@types/lodash": "^4.14.202",
|
|
35
|
-
"typescript": "^5.
|
|
36
|
-
"vitest": "^1.0.
|
|
35
|
+
"typescript": "^5.3.3",
|
|
36
|
+
"vitest": "^1.0.4"
|
|
37
37
|
},
|
|
38
38
|
"files": [
|
|
39
39
|
"dist/esm/**",
|