Fix metadata V13 decoding (on NMap) (#3548)
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
|
||||
import type { Codec, Constructor, Registry } from '../../types';
|
||||
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
/**
|
||||
* Given an u8a, and an array of Type constructors, decode the u8a against the
|
||||
* types, and return an array of decoded values.
|
||||
@@ -26,7 +28,15 @@ export function decodeU8a (registry: Registry, u8a: Uint8Array, _types: Construc
|
||||
result.push(value);
|
||||
offset += value.encodedLength;
|
||||
} catch (error) {
|
||||
throw new Error(`decodeU8a: failed on ${keys[i] ? `${keys[i]}: ` : ''}${new Type(registry).toRawType()}:: ${(error as Error).message}`);
|
||||
let rawType: string;
|
||||
|
||||
try {
|
||||
rawType = new Type(registry).toRawType();
|
||||
} catch {
|
||||
rawType = '';
|
||||
}
|
||||
|
||||
throw new Error(`decodeU8a: failed at ${u8aToHex(u8a.subarray(offset).slice(0, 8))}… on ${keys[i] ? `${keys[i]}` : ''}${rawType ? `: ${rawType}` : ''}:: ${(error as Error).message}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -269,8 +269,8 @@ export default {
|
||||
index: 'u8'
|
||||
},
|
||||
NMapTypeV13: {
|
||||
hashers: 'Vec<StorageHasherV13>',
|
||||
keyVec: 'Vec<Type>',
|
||||
hashers: 'Vec<StorageHasherV13>',
|
||||
value: 'Type'
|
||||
},
|
||||
StorageEntryModifierV13: 'StorageEntryModifierV12',
|
||||
|
||||
@@ -301,8 +301,8 @@ export interface NMapTypeLatest extends NMapTypeV13 {}
|
||||
|
||||
/** @name NMapTypeV13 */
|
||||
export interface NMapTypeV13 extends Struct {
|
||||
readonly hashers: Vec<StorageHasherV13>;
|
||||
readonly keyVec: Vec<Type>;
|
||||
readonly hashers: Vec<StorageHasherV13>;
|
||||
readonly value: Type;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user