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:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/extrinsics",
|
||||
"version": "0.40.26",
|
||||
"version": "0.41.0",
|
||||
"main": "index.js",
|
||||
"repository": "https://github.com/polkadot-js/api.git",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
@@ -11,7 +11,7 @@
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.2.0",
|
||||
"@polkadot/types": "^0.40.26",
|
||||
"@polkadot/types": "^0.41.0",
|
||||
"@polkadot/util": "^0.33.36"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Extrinsic, Metadata } from '@polkadot/types/index';
|
||||
import json from '@polkadot/types/Metadata/static';
|
||||
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 newExtrinsics = fromMetadata(metadata);
|
||||
|
||||
describe('fromMetadata', () => {
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { RuntimeModuleMetadata } from '@polkadot/types/Metadata/Modules';
|
||||
import { RuntimeModuleMetadata } from '@polkadot/types/Metadata/v0/Modules';
|
||||
import { Methods, ModulesWithMethods } from '@polkadot/types/Method';
|
||||
import { Metadata } from '@polkadot/types/index';
|
||||
import MetadataV0 from '@polkadot/types/Metadata/v0';
|
||||
|
||||
import { stringCamelCase } from '@polkadot/util';
|
||||
|
||||
@@ -18,7 +18,7 @@ import extrinsics from './index';
|
||||
* @param extrinsics - An extrinsics object to be extended.
|
||||
* @param metadata - The metadata to extend the storage object against.
|
||||
*/
|
||||
export default function fromMetadata (metadata: Metadata): ModulesWithMethods {
|
||||
export default function fromMetadata (metadata: MetadataV0): ModulesWithMethods {
|
||||
let indexCount = -1;
|
||||
|
||||
const findIndex = (prefix: string): number => {
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
@@ -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 { FunctionMetadata } from '@polkadot/types/Metadata/Modules';
|
||||
import { FunctionMetadata } from '@polkadot/types/Metadata/v0/Modules';
|
||||
import { MethodFunction } from '@polkadot/types/Method';
|
||||
import { Method } from '@polkadot/types/index';
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
Reference in New Issue
Block a user