Support new versioned metadata format (#632)

* Start something...

* Parsing via proxy (everything still all-ok)

* Imp[ort order (minor)

* WIP expanding the structure

* Adjust V1 structure

* Parsing seems to do the trick...

* Add CodeHash and Schedule types

* //v0/ -> /v0/

* Update Extrinsic.ts

* Updated with compact outerDispatch, non-throw construction

* v1 to V0 conversion

* Bubble non-magic errors in constructor

* Update e2e after testing them

* Bump version with CHANGELOG  (potentially breaking change)
This commit is contained in:
Jaco Greeff
2019-01-26 16:27:00 +01:00
committed by GitHub
parent f32404b1e4
commit fd93fbc4a6
55 changed files with 6081 additions and 240 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/storage",
"version": "0.40.26",
"version": "0.41.0",
"description": "Generic wrapper wrapper around state storage",
"main": "index.js",
"engines": {
@@ -31,7 +31,7 @@
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/keyring": "^0.33.36",
"@polkadot/types": "^0.40.26",
"@polkadot/types": "^0.41.0",
"@polkadot/util": "^0.33.36",
"@polkadot/util-crypto": "^0.33.36"
}
@@ -2,13 +2,13 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import Metadata from '@polkadot/types/Metadata';
import json from '@polkadot/types/Metadata/static';
import { Metadata } from '@polkadot/types/index';
import json from '@polkadot/types/Metadata/v0/static';
import fromMetadata from './fromMetadata';
// Use the pre-generated metadata
const metadata = new Metadata(json);
const metadata = new Metadata(json).asV0;
const newStorage = fromMetadata(metadata);
describe('fromMetadata', () => {
+2 -2
View File
@@ -4,7 +4,7 @@
import { ModuleStorage, Storage } from './types';
import Metadata from '@polkadot/types/Metadata';
import MetadataV0 from '@polkadot/types/Metadata/v0';
import { stringLowerFirst } from '@polkadot/util';
import createFunction from './utils/createFunction';
@@ -17,7 +17,7 @@ import storage from './index';
* @param storage - A storage object to be extended.
* @param metadata - The metadata to extend the storage object against.
*/
export default function fromMetadata (metadata: Metadata): Storage {
export default function fromMetadata (metadata: MetadataV0): Storage {
return metadata.modules.reduce((result, moduleMetadata) => {
if (moduleMetadata.storage.isNone) {
return result;
+3 -3
View File
@@ -2,11 +2,11 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import metadataRpc from '@polkadot/types/Metadata/static';
import Metadata from '@polkadot/types/Metadata';
import { Metadata } from '@polkadot/types/index';
import metadataRpc from '@polkadot/types/Metadata/v0/static';
import fromMetadata from './fromMetadata';
export default fromMetadata(
new Metadata(metadataRpc)
new Metadata(metadataRpc).asV0
);
+1 -1
View File
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { StorageFunctionMetadata, StorageFunctionModifier, StorageFunctionType } from '@polkadot/types/Metadata/Modules';
import { StorageFunctionMetadata, StorageFunctionModifier, StorageFunctionType } from '@polkadot/types/Metadata/v0/Modules';
import { StorageFunction } from '@polkadot/types/StorageKey';
import Text from '@polkadot/types/Text';
import Vector from '@polkadot/types/codec/Vector';
@@ -4,7 +4,7 @@
import Compact from '@polkadot/types/codec/Compact';
import { createType } from '@polkadot/types/codec';
import { StorageFunctionMetadata } from '@polkadot/types/Metadata/Modules';
import { StorageFunctionMetadata } from '@polkadot/types/Metadata/v0/Modules';
import { StorageFunction } from '@polkadot/types/StorageKey';
import { Text } from '@polkadot/types/index';
import { assert, isNull, isUndefined, stringLowerFirst, stringToU8a, u8aConcat } from '@polkadot/util';