Fix metadata V13 decoding (on NMap) (#3548)
This commit is contained in:
@@ -4,9 +4,11 @@
|
||||
|
||||
Changes:
|
||||
|
||||
- Fix metadata v13 storage decoding on `NMap`
|
||||
- Return additional error information from internal u8a decoding failures
|
||||
- Adjust Westend types for 16 nominators-only
|
||||
- Add support for `DisallowSigned` (as per shell runtime) extension
|
||||
- Display small hex-slice with u8a decoding failures
|
||||
|
||||
|
||||
## 4.10.1 May 17, 2021
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { Bytes, Data, Option, U8aFixed, Vec, bool, u32, u64 } from '@polkadot/types';
|
||||
import type { AnyNumber, ITuple, Observable } from '@polkadot/types/types';
|
||||
import type { AssetApproval, AssetApprovalKey, AssetBalance, AssetDetails, AssetMetadata } from '@polkadot/types/interfaces/assets';
|
||||
import type { AssetApproval, AssetBalance, AssetDetails, AssetMetadata } from '@polkadot/types/interfaces/assets';
|
||||
import type { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
|
||||
import type { BabeAuthorityWeight, BabeEpochConfiguration, MaybeRandomness, NextConfigDescriptor, Randomness } from '@polkadot/types/interfaces/babe';
|
||||
import type { AccountData, BalanceLock } from '@polkadot/types/interfaces/balances';
|
||||
@@ -43,8 +43,9 @@ declare module '@polkadot/api/types/storage' {
|
||||
/**
|
||||
* Approved balance transfers. First balance is the amount approved for transfer. Second
|
||||
* is the amount of `T::Currency` reserved for storing this.
|
||||
* First key is the asset ID, second key is the owner and third key is the delegate.
|
||||
**/
|
||||
approvals: AugmentedQueryDoubleMap<ApiType, (key1: AssetId | AnyNumber | Uint8Array, key2: AssetApprovalKey | { owner?: any; delegate?: any } | string | Uint8Array) => Observable<Option<AssetApproval>>, [AssetId, AssetApprovalKey]> & QueryableStorageEntry<ApiType, [AssetId, AssetApprovalKey]>;
|
||||
approvals: AugmentedQuery<ApiType, (key1: AssetId | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array, key3: AccountId | string | Uint8Array) => Observable<Option<AssetApproval>>, [AssetId, AccountId, AccountId]> & QueryableStorageEntry<ApiType, [AssetId, AccountId, AccountId]>;
|
||||
/**
|
||||
* Details of an asset.
|
||||
**/
|
||||
|
||||
@@ -12602,18 +12602,25 @@
|
||||
"name": "Approvals",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"doubleMap": {
|
||||
"hasher": "Blake2_128Concat",
|
||||
"key1": "AssetId",
|
||||
"key2": "AssetApprovalKey",
|
||||
"value": "AssetApproval",
|
||||
"key2Hasher": "Blake2_128Concat"
|
||||
"nMap": {
|
||||
"keyVec": [
|
||||
"AssetId",
|
||||
"AccountId",
|
||||
"AccountId"
|
||||
],
|
||||
"hashers": [
|
||||
"Blake2_128Concat",
|
||||
"Blake2_128Concat",
|
||||
"Blake2_128Concat"
|
||||
],
|
||||
"value": "AssetApproval"
|
||||
}
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" Approved balance transfers. First balance is the amount approved for transfer. Second",
|
||||
" is the amount of `T::Currency` reserved for storing this."
|
||||
" is the amount of `T::Currency` reserved for storing this.",
|
||||
" First key is the asset ID, second key is the owner and third key is the delegate."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -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