@dedot/api 0.0.1-alpha.34 → 0.0.1-alpha.36
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/chaintypes/substrate/consts.js +1 -0
- package/chaintypes/substrate/errors.js +1 -0
- package/chaintypes/substrate/events.js +1 -0
- package/chaintypes/substrate/index.js +1 -0
- package/chaintypes/substrate/json-rpc.d.ts +1 -1
- package/chaintypes/substrate/json-rpc.js +1 -0
- package/chaintypes/substrate/query.js +1 -0
- package/chaintypes/substrate/runtime.js +1 -0
- package/chaintypes/substrate/tx.js +1 -0
- package/chaintypes/substrate/types.d.ts +377 -377
- package/chaintypes/substrate/types.js +1 -0
- package/cjs/chaintypes/substrate/consts.js +1 -0
- package/cjs/chaintypes/substrate/errors.js +1 -0
- package/cjs/chaintypes/substrate/events.js +1 -0
- package/cjs/chaintypes/substrate/index.js +1 -0
- package/cjs/chaintypes/substrate/json-rpc.js +1 -0
- package/cjs/chaintypes/substrate/query.js +1 -0
- package/cjs/chaintypes/substrate/runtime.js +1 -0
- package/cjs/chaintypes/substrate/tx.js +1 -0
- package/cjs/chaintypes/substrate/types.js +1 -0
- package/cjs/client/DedotClient.js +2 -1
- package/cjs/client/LegacyClient.js +5 -4
- package/cjs/executor/ErrorExecutor.js +3 -3
- package/cjs/executor/EventExecutor.js +2 -2
- package/cjs/executor/StorageQueryExecutor.js +1 -1
- package/cjs/executor/TxExecutor.js +3 -3
- package/cjs/executor/v2/StorageQueryExecutorV2.js +4 -4
- package/cjs/extrinsic/extensions/known/ChargeAssetTxPayment.js +2 -2
- package/cjs/extrinsic/extensions/known/StorageWeightReclaim.js +10 -0
- package/cjs/extrinsic/extensions/known/index.js +2 -0
- package/cjs/extrinsic/submittable/SubmittableExtrinsic.js +2 -2
- package/cjs/extrinsic/submittable/SubmittableExtrinsicV2.js +11 -11
- package/cjs/storage/QueryableStorage.js +17 -17
- package/client/BaseSubstrateClient.d.ts +10 -11
- package/client/DedotClient.d.ts +2 -1
- package/client/DedotClient.js +2 -1
- package/client/LegacyClient.d.ts +5 -4
- package/client/LegacyClient.js +5 -4
- package/executor/ErrorExecutor.js +3 -3
- package/executor/EventExecutor.js +2 -2
- package/executor/Executor.d.ts +12 -12
- package/executor/StorageQueryExecutor.js +1 -1
- package/executor/TxExecutor.js +3 -3
- package/executor/v2/StorageQueryExecutorV2.js +4 -4
- package/extrinsic/extensions/known/ChargeAssetTxPayment.js +2 -2
- package/extrinsic/extensions/known/StorageWeightReclaim.d.ts +6 -0
- package/extrinsic/extensions/known/StorageWeightReclaim.js +6 -0
- package/extrinsic/extensions/known/index.js +2 -0
- package/extrinsic/submittable/SubmittableExtrinsic.js +2 -2
- package/extrinsic/submittable/SubmittableExtrinsicV2.js +11 -11
- package/package.json +10 -10
- package/storage/QueryableStorage.js +17 -17
package/executor/Executor.d.ts
CHANGED
|
@@ -19,13 +19,13 @@ export declare abstract class Executor<ChainApi extends GenericSubstrateApi = Ge
|
|
|
19
19
|
name: string;
|
|
20
20
|
typeId: number | undefined;
|
|
21
21
|
}[];
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
typeDef: {
|
|
23
|
+
type: "Struct";
|
|
24
24
|
value: {
|
|
25
25
|
fields: import("@dedot/codecs").Field[];
|
|
26
26
|
};
|
|
27
27
|
} | {
|
|
28
|
-
|
|
28
|
+
type: "Enum";
|
|
29
29
|
value: {
|
|
30
30
|
members: {
|
|
31
31
|
name: string;
|
|
@@ -35,33 +35,33 @@ export declare abstract class Executor<ChainApi extends GenericSubstrateApi = Ge
|
|
|
35
35
|
}[];
|
|
36
36
|
};
|
|
37
37
|
} | {
|
|
38
|
-
|
|
38
|
+
type: "Sequence";
|
|
39
39
|
value: {
|
|
40
40
|
typeParam: number;
|
|
41
41
|
};
|
|
42
42
|
} | {
|
|
43
|
-
|
|
43
|
+
type: "SizedVec";
|
|
44
44
|
value: {
|
|
45
45
|
len: number;
|
|
46
46
|
typeParam: number;
|
|
47
47
|
};
|
|
48
48
|
} | {
|
|
49
|
-
|
|
49
|
+
type: "Tuple";
|
|
50
50
|
value: {
|
|
51
51
|
fields: number[];
|
|
52
52
|
};
|
|
53
53
|
} | {
|
|
54
|
-
|
|
54
|
+
type: "Primitive";
|
|
55
55
|
value: {
|
|
56
56
|
kind: "bool" | "char" | "str" | "u8" | "u16" | "u32" | "u64" | "u128" | "u256" | "i8" | "i16" | "i32" | "i64" | "i128" | "i256";
|
|
57
57
|
};
|
|
58
58
|
} | {
|
|
59
|
-
|
|
59
|
+
type: "Compact";
|
|
60
60
|
value: {
|
|
61
61
|
typeParam: number;
|
|
62
62
|
};
|
|
63
63
|
} | {
|
|
64
|
-
|
|
64
|
+
type: "BitSequence";
|
|
65
65
|
value: {
|
|
66
66
|
bitOrderType: number;
|
|
67
67
|
bitStoreType: number;
|
|
@@ -76,13 +76,13 @@ export declare abstract class Executor<ChainApi extends GenericSubstrateApi = Ge
|
|
|
76
76
|
entries: {
|
|
77
77
|
name: string;
|
|
78
78
|
modifier: string;
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
storageType: {
|
|
80
|
+
type: "Plain";
|
|
81
81
|
value: {
|
|
82
82
|
valueTypeId: number;
|
|
83
83
|
};
|
|
84
84
|
} | {
|
|
85
|
-
|
|
85
|
+
type: "Map";
|
|
86
86
|
value: {
|
|
87
87
|
hashers: ("identity" | "blake2_128" | "blake2_256" | "blake2_128Concat" | "twox128" | "twox256" | "twox64Concat")[];
|
|
88
88
|
keyTypeId: number;
|
|
@@ -49,7 +49,7 @@ export class StorageQueryExecutor extends Executor {
|
|
|
49
49
|
palletIndex: entry.pallet.index,
|
|
50
50
|
...entry.storageEntry,
|
|
51
51
|
};
|
|
52
|
-
const isMap = entry.storageEntry.type
|
|
52
|
+
const isMap = entry.storageEntry.storageType.type === 'Map';
|
|
53
53
|
if (isMap) {
|
|
54
54
|
const queryMultiFn = async (...args) => {
|
|
55
55
|
const [inArgs, callback] = extractArgs(args);
|
package/executor/TxExecutor.js
CHANGED
|
@@ -10,9 +10,9 @@ export class TxExecutor extends Executor {
|
|
|
10
10
|
const targetPallet = this.getPallet(pallet);
|
|
11
11
|
assert(targetPallet.calls, new UnknownApiError(`Tx calls are not available for pallet ${targetPallet.name}`));
|
|
12
12
|
const txType = this.metadata.types[targetPallet.calls];
|
|
13
|
-
assert(txType.type
|
|
14
|
-
const isFlatEnum = txType.
|
|
15
|
-
const txCallDef = txType.
|
|
13
|
+
assert(txType.typeDef.type === 'Enum', new UnknownApiError('Tx type defs should be enum'));
|
|
14
|
+
const isFlatEnum = txType.typeDef.value.members.every((m) => m.fields.length === 0);
|
|
15
|
+
const txCallDef = txType.typeDef.value.members.find((m) => stringCamelCase(m.name) === functionName);
|
|
16
16
|
assert(txCallDef, new UnknownApiError(`Tx call spec not found for ${pallet}.${functionName}`));
|
|
17
17
|
const txCallFn = (...args) => {
|
|
18
18
|
let call;
|
|
@@ -37,20 +37,20 @@ export class StorageQueryExecutorV2 extends StorageQueryExecutor {
|
|
|
37
37
|
// TODO subscribe to finalized data source
|
|
38
38
|
// initialHash = this.chainHead.finalizedHash;
|
|
39
39
|
// eventToListen = 'finalizedBlock';
|
|
40
|
-
const latestChanges =
|
|
40
|
+
const latestChanges = new Map();
|
|
41
41
|
const pull = async ({ hash }) => {
|
|
42
42
|
const results = await this.queryStorage(keys, hash);
|
|
43
43
|
let changed = false;
|
|
44
44
|
keys.forEach((key) => {
|
|
45
45
|
const newValue = results[key];
|
|
46
|
-
if (latestChanges
|
|
46
|
+
if (latestChanges.size > 0 && latestChanges.get(key) === newValue)
|
|
47
47
|
return;
|
|
48
48
|
changed = true;
|
|
49
|
-
latestChanges
|
|
49
|
+
latestChanges.set(key, newValue);
|
|
50
50
|
});
|
|
51
51
|
if (!changed)
|
|
52
52
|
return;
|
|
53
|
-
callback(keys.map((key) => latestChanges
|
|
53
|
+
callback(keys.map((key) => latestChanges.get(key)));
|
|
54
54
|
};
|
|
55
55
|
await pull(best);
|
|
56
56
|
const unsub = this.chainHead.on(eventToListen, pull);
|
|
@@ -27,8 +27,8 @@ export class ChargeAssetTxPayment extends SignedExtension {
|
|
|
27
27
|
}
|
|
28
28
|
$AssetId() {
|
|
29
29
|
const extensionTypeDef = this.registry.findType(this.signedExtensionDef.typeId);
|
|
30
|
-
assert(extensionTypeDef.type
|
|
31
|
-
const assetIdTypeDef = extensionTypeDef.
|
|
30
|
+
assert(extensionTypeDef.typeDef.type === 'Struct');
|
|
31
|
+
const assetIdTypeDef = extensionTypeDef.typeDef.value.fields.find((f) => f.name === 'asset_id');
|
|
32
32
|
const $codec = this.registry.findCodec(assetIdTypeDef.typeId);
|
|
33
33
|
const codecMetadata = $codec.metadata[0];
|
|
34
34
|
if (codecMetadata.name === '$.option') {
|
|
@@ -9,6 +9,7 @@ import { CheckSpecVersion } from './CheckSpecVersion.js';
|
|
|
9
9
|
import { CheckTxVersion } from './CheckTxVersion.js';
|
|
10
10
|
import { CheckWeight } from './CheckWeight.js';
|
|
11
11
|
import { PrevalidateAttests } from './PrevalidateAttests.js';
|
|
12
|
+
import { StorageWeightReclaim } from './StorageWeightReclaim.js';
|
|
12
13
|
export const knownSignedExtensions = {
|
|
13
14
|
CheckNonZeroSender,
|
|
14
15
|
CheckSpecVersion,
|
|
@@ -21,4 +22,5 @@ export const knownSignedExtensions = {
|
|
|
21
22
|
PrevalidateAttests,
|
|
22
23
|
ChargeAssetTxPayment,
|
|
23
24
|
CheckMetadataHash,
|
|
25
|
+
StorageWeightReclaim,
|
|
24
26
|
};
|
|
@@ -20,7 +20,7 @@ export class SubmittableExtrinsic extends BaseSubmittableExtrinsic {
|
|
|
20
20
|
const txHash = this.hash;
|
|
21
21
|
if (isSubscription) {
|
|
22
22
|
return this.api.rpc.author_submitAndWatchExtrinsic(txHex, async (status) => {
|
|
23
|
-
if (status.
|
|
23
|
+
if (status.type === 'InBlock' || status.type === 'Finalized') {
|
|
24
24
|
const blockHash = status.value;
|
|
25
25
|
const [signedBlock, blockEvents] = await Promise.all([
|
|
26
26
|
this.api.rpc.chain_getBlock(blockHash),
|
|
@@ -28,7 +28,7 @@ export class SubmittableExtrinsic extends BaseSubmittableExtrinsic {
|
|
|
28
28
|
]);
|
|
29
29
|
const txIndex = signedBlock.block.extrinsics.indexOf(txHex);
|
|
30
30
|
assert(txIndex >= 0, 'Extrinsic not found!');
|
|
31
|
-
const events = blockEvents.filter(({ phase }) => phase.
|
|
31
|
+
const events = blockEvents.filter(({ phase }) => phase.type === 'ApplyExtrinsic' && phase.value === txIndex);
|
|
32
32
|
return callback(new SubmittableResult({ status, txHash, events, txIndex }));
|
|
33
33
|
}
|
|
34
34
|
else {
|
|
@@ -25,10 +25,10 @@ export class SubmittableExtrinsicV2 extends BaseSubmittableExtrinsic {
|
|
|
25
25
|
};
|
|
26
26
|
const validation = await validateTx(finalizedHash);
|
|
27
27
|
if (validation.isOk) {
|
|
28
|
-
callback(new SubmittableResult({ status: {
|
|
28
|
+
callback(new SubmittableResult({ status: { type: 'Validated' }, txHash }));
|
|
29
29
|
}
|
|
30
30
|
else if (validation.isErr) {
|
|
31
|
-
throw new InvalidTxError(`Invalid Tx: ${validation.err.
|
|
31
|
+
throw new InvalidTxError(`Invalid Tx: ${validation.err.type} - ${validation.err.value.type}`, validation);
|
|
32
32
|
}
|
|
33
33
|
const checkTxIsOnChain = async (blockHash) => {
|
|
34
34
|
if (blockHash === finalizedHash)
|
|
@@ -39,7 +39,7 @@ export class SubmittableExtrinsicV2 extends BaseSubmittableExtrinsic {
|
|
|
39
39
|
return checkTxIsOnChain(api.chainHead.findBlock(blockHash).parent);
|
|
40
40
|
}
|
|
41
41
|
const events = await this.getSystemEventsAt(blockHash);
|
|
42
|
-
const txEvents = events.filter(({ phase }) => phase.
|
|
42
|
+
const txEvents = events.filter(({ phase }) => phase.type == 'ApplyExtrinsic' && phase.value === txIndex);
|
|
43
43
|
return {
|
|
44
44
|
blockHash,
|
|
45
45
|
index: txIndex,
|
|
@@ -85,7 +85,7 @@ export class SubmittableExtrinsicV2 extends BaseSubmittableExtrinsic {
|
|
|
85
85
|
if (txFound && bestChainChanged) {
|
|
86
86
|
txFound = undefined;
|
|
87
87
|
callback(new SubmittableResult({
|
|
88
|
-
status: {
|
|
88
|
+
status: { type: 'NoLongerInBestChain' },
|
|
89
89
|
txHash,
|
|
90
90
|
}));
|
|
91
91
|
}
|
|
@@ -98,7 +98,7 @@ export class SubmittableExtrinsicV2 extends BaseSubmittableExtrinsic {
|
|
|
98
98
|
txFound = inBlock;
|
|
99
99
|
const { index: txIndex, events, blockHash } = inBlock;
|
|
100
100
|
callback(new SubmittableResult({
|
|
101
|
-
status: {
|
|
101
|
+
status: { type: 'BestChainBlockIncluded', value: { blockHash, txIndex } },
|
|
102
102
|
txHash,
|
|
103
103
|
events,
|
|
104
104
|
txIndex,
|
|
@@ -131,7 +131,7 @@ export class SubmittableExtrinsicV2 extends BaseSubmittableExtrinsic {
|
|
|
131
131
|
if (inBlock) {
|
|
132
132
|
const { index: txIndex, events, blockHash } = inBlock;
|
|
133
133
|
callback(new SubmittableResult({
|
|
134
|
-
status: {
|
|
134
|
+
status: { type: 'Finalized', value: { blockHash, txIndex } },
|
|
135
135
|
txHash,
|
|
136
136
|
events,
|
|
137
137
|
txIndex,
|
|
@@ -145,8 +145,8 @@ export class SubmittableExtrinsicV2 extends BaseSubmittableExtrinsic {
|
|
|
145
145
|
return;
|
|
146
146
|
callback(new SubmittableResult({
|
|
147
147
|
status: {
|
|
148
|
-
|
|
149
|
-
value: { error: `Invalid Tx: ${validation.err.
|
|
148
|
+
type: 'Invalid',
|
|
149
|
+
value: { error: `Invalid Tx: ${validation.err.type} - ${validation.err.value.type}` },
|
|
150
150
|
},
|
|
151
151
|
txHash,
|
|
152
152
|
}));
|
|
@@ -155,7 +155,7 @@ export class SubmittableExtrinsicV2 extends BaseSubmittableExtrinsic {
|
|
|
155
155
|
};
|
|
156
156
|
stopBroadcastFn = await api.txBroadcaster.broadcastTx(txHex);
|
|
157
157
|
callback(new SubmittableResult({
|
|
158
|
-
status: {
|
|
158
|
+
status: { type: 'Broadcasting' },
|
|
159
159
|
txHash,
|
|
160
160
|
}));
|
|
161
161
|
const stopBestBlockTrackingFn = api.chainHead.on('bestBlock', checkBestBlockIncluded);
|
|
@@ -181,11 +181,11 @@ export class SubmittableExtrinsicV2 extends BaseSubmittableExtrinsic {
|
|
|
181
181
|
try {
|
|
182
182
|
// TODO handle timeout for this with the Drop status, just in-case we somehow can't find the tx in any block
|
|
183
183
|
const unsub = await this.#send(({ status, txHash }) => {
|
|
184
|
-
if (status.
|
|
184
|
+
if (status.type === 'BestChainBlockIncluded' || status.type === 'Finalized') {
|
|
185
185
|
defer.resolve(txHash);
|
|
186
186
|
unsub().catch(noop);
|
|
187
187
|
}
|
|
188
|
-
else if (status.
|
|
188
|
+
else if (status.type === 'Invalid' || status.type === 'Drop') {
|
|
189
189
|
defer.reject(new Error(status.value.error));
|
|
190
190
|
unsub().catch(noop);
|
|
191
191
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dedot/api",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.36",
|
|
4
4
|
"description": "A delightful JavaScript/TypeScript client for Polkadot & Substrate",
|
|
5
5
|
"author": "Thang X. Vu <thang@coongcrafts.io>",
|
|
6
6
|
"homepage": "https://github.com/dedotdev/dedot",
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"type": "module",
|
|
14
14
|
"sideEffects": false,
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@dedot/codecs": "0.0.1-alpha.
|
|
17
|
-
"@dedot/providers": "0.0.1-alpha.
|
|
18
|
-
"@dedot/runtime-specs": "0.0.1-alpha.
|
|
19
|
-
"@dedot/shape": "0.0.1-alpha.
|
|
20
|
-
"@dedot/storage": "0.0.1-alpha.
|
|
21
|
-
"@dedot/types": "0.0.1-alpha.
|
|
22
|
-
"@dedot/utils": "0.0.1-alpha.
|
|
16
|
+
"@dedot/codecs": "0.0.1-alpha.36",
|
|
17
|
+
"@dedot/providers": "0.0.1-alpha.36",
|
|
18
|
+
"@dedot/runtime-specs": "0.0.1-alpha.36",
|
|
19
|
+
"@dedot/shape": "0.0.1-alpha.36",
|
|
20
|
+
"@dedot/storage": "0.0.1-alpha.36",
|
|
21
|
+
"@dedot/types": "0.0.1-alpha.36",
|
|
22
|
+
"@dedot/utils": "0.0.1-alpha.36"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "tsc --project tsconfig.build.json && tsc --project tsconfig.build.cjs.json",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
},
|
|
47
47
|
"license": "Apache-2.0",
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@polkadot/types": "^
|
|
49
|
+
"@polkadot/types": "^12.0.1"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "798f0b8ce218baf212b8853e4e6eb0cf45157f6e",
|
|
52
52
|
"module": "./index.js",
|
|
53
53
|
"types": "./index.d.ts"
|
|
54
54
|
}
|
|
@@ -36,14 +36,14 @@ export class QueryableStorage {
|
|
|
36
36
|
const storageItemHash = xxhashAsU8a(this.storageEntry.name, 128);
|
|
37
37
|
return concatU8a(palletNameHash, storageItemHash);
|
|
38
38
|
}
|
|
39
|
-
#getStorageMapInfo(
|
|
40
|
-
assert(type
|
|
41
|
-
const { hashers, keyTypeId } =
|
|
39
|
+
#getStorageMapInfo(storageType) {
|
|
40
|
+
assert(storageType.type === 'Map');
|
|
41
|
+
const { hashers, keyTypeId } = storageType.value;
|
|
42
42
|
let keyTypeIds = [keyTypeId];
|
|
43
43
|
if (hashers.length > 1) {
|
|
44
|
-
const {
|
|
45
|
-
assert(type
|
|
46
|
-
keyTypeIds =
|
|
44
|
+
const { typeDef } = this.registry.findType(keyTypeId);
|
|
45
|
+
assert(typeDef.type === 'Tuple', 'Key type should be a tuple!');
|
|
46
|
+
keyTypeIds = typeDef.value.fields;
|
|
47
47
|
}
|
|
48
48
|
return { hashers, keyTypeIds };
|
|
49
49
|
}
|
|
@@ -53,12 +53,12 @@ export class QueryableStorage {
|
|
|
53
53
|
* @param keyInput
|
|
54
54
|
*/
|
|
55
55
|
encodeKey(keyInput) {
|
|
56
|
-
const {
|
|
57
|
-
if (type
|
|
56
|
+
const { storageType } = this.storageEntry;
|
|
57
|
+
if (storageType.type === 'Plain') {
|
|
58
58
|
return this.prefixKey;
|
|
59
59
|
}
|
|
60
|
-
else if (type
|
|
61
|
-
const { hashers, keyTypeIds } = this.#getStorageMapInfo(
|
|
60
|
+
else if (storageType.type === 'Map') {
|
|
61
|
+
const { hashers, keyTypeIds } = this.#getStorageMapInfo(storageType);
|
|
62
62
|
const extractedInputs = this.#extractRequiredKeyInputs(keyInput, hashers.length);
|
|
63
63
|
const keyParts = keyTypeIds.map((keyId, index) => {
|
|
64
64
|
const input = extractedInputs[index];
|
|
@@ -68,7 +68,7 @@ export class QueryableStorage {
|
|
|
68
68
|
});
|
|
69
69
|
return u8aToHex(concatU8a(this.prefixKeyAsU8a, ...keyParts));
|
|
70
70
|
}
|
|
71
|
-
throw Error(`Invalid storage entry type: ${
|
|
71
|
+
throw Error(`Invalid storage entry type: ${JSON.stringify(storageType)}`);
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
74
|
* Decode storage key to plain key input
|
|
@@ -77,16 +77,16 @@ export class QueryableStorage {
|
|
|
77
77
|
* @param key
|
|
78
78
|
*/
|
|
79
79
|
decodeKey(key) {
|
|
80
|
-
const {
|
|
81
|
-
if (type
|
|
80
|
+
const { storageType } = this.storageEntry;
|
|
81
|
+
if (storageType.type === 'Plain') {
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
else if (type
|
|
84
|
+
else if (storageType.type === 'Map') {
|
|
85
85
|
const prefix = this.prefixKey;
|
|
86
86
|
if (!key.startsWith(prefix)) {
|
|
87
87
|
throw new Error(`Storage key does not match this storage entry (${this.palletName}.${this.storageItem})`);
|
|
88
88
|
}
|
|
89
|
-
const { hashers, keyTypeIds } = this.#getStorageMapInfo(
|
|
89
|
+
const { hashers, keyTypeIds } = this.#getStorageMapInfo(storageType);
|
|
90
90
|
let keyData = hexToU8a(hexAddPrefix(key.slice(prefix.length)));
|
|
91
91
|
const results = keyTypeIds.map((keyId, index) => {
|
|
92
92
|
const [hashLen, canDecode] = HASHER_INFO[hashers[index]];
|
|
@@ -101,7 +101,7 @@ export class QueryableStorage {
|
|
|
101
101
|
});
|
|
102
102
|
return hashers.length > 1 ? results : results[0];
|
|
103
103
|
}
|
|
104
|
-
throw Error(`Invalid storage entry type: ${
|
|
104
|
+
throw Error(`Invalid storage entry type: ${JSON.stringify(storageType)}`);
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
107
107
|
* Decode raw/bytes storage data to plain value
|
|
@@ -109,7 +109,7 @@ export class QueryableStorage {
|
|
|
109
109
|
* @param raw
|
|
110
110
|
*/
|
|
111
111
|
decodeValue(raw) {
|
|
112
|
-
const { modifier,
|
|
112
|
+
const { modifier, storageType: { value: { valueTypeId }, }, default: defaultValue, } = this.storageEntry;
|
|
113
113
|
if (raw === null || raw === undefined) {
|
|
114
114
|
if (modifier === 'Optional') {
|
|
115
115
|
return undefined;
|