Fix linked maps with defaults (#1162)

* isPedantic matches [] with isEmpty

* Fix undefined.undefined on  headKey

* Adjust fallback for linked maps

* Add tests for the linked map fallbacks (head and value)
This commit is contained in:
Jaco Greeff
2019-07-23 10:56:45 +02:00
committed by GitHub
parent 6858cd0212
commit f9a3f3e53f
4 changed files with 105 additions and 34 deletions
+8 -3
View File
@@ -24,6 +24,11 @@ interface Decoded {
section?: string;
}
interface StorageKeyExtra {
method: string;
section: string;
}
/**
* @name StorageKey
* @description
@@ -39,15 +44,15 @@ export default class StorageKey extends Bytes {
private _section?: string;
public constructor (value?: AnyU8a | StorageKey | StorageEntry | [StorageEntry, any]) {
public constructor (value?: AnyU8a | StorageKey | StorageEntry | [StorageEntry, any], override: Partial<StorageKeyExtra> = {}) {
const { key, method, section } = StorageKey.decodeStorageKey(value);
super(key);
this._meta = StorageKey.getMeta(value as StorageKey);
this._method = method;
this._method = override.method || method;
this._outputType = StorageKey.getType(value as StorageKey);
this._section = section;
this._section = override.section || section;
}
public static decodeStorageKey (value?: AnyU8a | StorageKey | StorageEntry | [StorageEntry, any]): Decoded {