Add metadata v10/11, blake2_128concat hasher (#1691)

* v11, blake2_128concat

* MetadataAll

* Add storage hasher v4 and v10

* Make lint pass

* Add correct interfaces

* Fix lint

* Update metadata definitions

* Update v10 metadata

* Update packages/types/src/interfaces/utility/definitions.ts

* Update v11

* Add HACK

* Skip v9 tests (part of HACK)

* Correct function names

Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>
This commit is contained in:
Keith Ingram
2020-01-02 18:04:42 +01:00
committed by Amaury Martiny
co-authored by Amaury Martiny
parent 131055c1d5
commit 82828d8e09
25 changed files with 6509 additions and 257 deletions
@@ -23,6 +23,17 @@ export default class Metadata extends MetadataVersioned {
// we adjust with the magic number and a manual version and re-try. As soon as
// we remove support for V0, we will just do a new here
private static decodeMetadata (registry: Registry, _value: Uint8Array | string = new Uint8Array()): MetadataVersioned {
/**
* HACK 01.02.2020
* There was a fk-up in the metadata upgrade process: Kusama's metadata got
* updated to a non-backward-compatible way, but the metadata version
* stayed at v9. Then v10 was merged in Substrate but not Kusama. Here,
* we're just saying that if it's a v9 metadata, decode as v10.
*/
if (isHex(_value) && _value.startsWith('0x6d65746109')) {
return Metadata.decodeMetadata(registry, _value.replace('0x6d65746109', '0x6d6574610a'));
}
const value = isHex(_value)
? hexToU8a(_value)
: _value;