Add a Decorated class, which will be offline decorated Metadata (#1463)
* Move Metadata to api-metadata * Make tests in api-metadata pass * Make tests in api-metadata pass * Refactor fromMetadata into decorated * Fix some linting * Replace headers * Fix all tests * Small lint * Fix tests * Fix metadata docs scripts * Fix import ordering * Add line breaks * Grumbles * Fix forgotten import * rpcMetadata everywhere * Fixlint * s/api-metadata/metadata * Fix latest tests * Fix lint * Fix tests
This commit is contained in:
committed by
Jaco Greeff
parent
c87ba33893
commit
16e0ea9315
+1
-1
@@ -15,7 +15,7 @@ yarn polkadot-dev-build-ts
|
||||
copy_folder "api" "api"
|
||||
copy_folder "api-contract" "api-contract"
|
||||
copy_folder "api-derive" "api-derive"
|
||||
copy_folder "api-metadata" "api-metadata"
|
||||
copy_folder "metadata" "metadata"
|
||||
copy_folder "rpc-core" "rpc-core"
|
||||
copy_folder "rpc-provider" "rpc-provider"
|
||||
copy_folder "type-jsonrpc" "jsonrpc"
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@ module.exports = Object.assign({}, config, {
|
||||
moduleNameMapper: {
|
||||
'@polkadot/api-contract(.*)$': '<rootDir>/packages/api-contract/src/$1',
|
||||
'@polkadot/api-derive(.*)$': '<rootDir>/packages/api-derive/src/$1',
|
||||
'@polkadot/api-metadata(.*)$': '<rootDir>/packages/api-metadata/src/$1',
|
||||
'@polkadot/api(.*)$': '<rootDir>/packages/api/src/$1',
|
||||
'@polkadot/metadata(.*)$': '<rootDir>/packages/metadata/src/$1',
|
||||
'@polkadot/rpc-(core|provider)(.*)$': '<rootDir>/packages/rpc-$1/src/$2',
|
||||
'@polkadot/jsonrpc(.*)$': '<rootDir>/packages/type-jsonrpc/src/$1',
|
||||
'@polkadot/types(.*)$': '<rootDir>/packages/types/src/$1'
|
||||
@@ -16,7 +16,7 @@ module.exports = Object.assign({}, config, {
|
||||
'<rootDir>/packages/api/build',
|
||||
'<rootDir>/packages/api-derive/build',
|
||||
'<rootDir>/packages/api-contract/build',
|
||||
'<rootDir>/packages/api-metadata/build',
|
||||
'<rootDir>/packages/metadata/build',
|
||||
'<rootDir>/packages/rpc-core/build',
|
||||
'<rootDir>/packages/rpc-provider/build',
|
||||
'<rootDir>/packages/type-jsonrpc/build',
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
# @polkadot/api-metadata
|
||||
@@ -1,3 +0,0 @@
|
||||
# @polkadot/api-metadata/consts
|
||||
|
||||
A base interface to the parameter types
|
||||
@@ -1,12 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/api-metadata authors & contributors
|
||||
// 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';
|
||||
import metadataRpc from '@polkadot/types/Metadata/static';
|
||||
|
||||
import fromMetadata from './fromMetadata';
|
||||
|
||||
export default fromMetadata(
|
||||
new Metadata(metadataRpc)
|
||||
);
|
||||
@@ -1,3 +0,0 @@
|
||||
# @polkadot/api-metadata/extrinsics
|
||||
|
||||
Base extrinsic definitions & codecs
|
||||
@@ -1,15 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/api-metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ModulesWithCalls } from '@polkadot/types/types';
|
||||
|
||||
import Metadata from '@polkadot/types/Metadata';
|
||||
import metadataRpc from '@polkadot/types/Metadata/static';
|
||||
|
||||
import fromMetadata from './fromMetadata';
|
||||
|
||||
const staticMetadata: ModulesWithCalls = fromMetadata(
|
||||
new Metadata(metadataRpc)
|
||||
);
|
||||
export default staticMetadata;
|
||||
@@ -1,3 +0,0 @@
|
||||
# @polkadot/api-metadata/storage
|
||||
|
||||
A base interface to the storage layer
|
||||
@@ -1,12 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/api-metadata authors & contributors
|
||||
// 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';
|
||||
import metadataRpc from '@polkadot/types/Metadata/static';
|
||||
|
||||
import fromMetadata from './fromMetadata';
|
||||
|
||||
export default fromMetadata(
|
||||
new Metadata(metadataRpc)
|
||||
);
|
||||
@@ -1,14 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/api-metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { StorageEntry } from '@polkadot/types/primitive/StorageKey';
|
||||
|
||||
export interface ModuleStorage {
|
||||
[key: string]: StorageEntry;
|
||||
}
|
||||
|
||||
export interface Storage {
|
||||
[key: string]: ModuleStorage; // Will hold modules returned by state_getMetadata
|
||||
substrate: { [key: string]: StorageEntry };
|
||||
}
|
||||
@@ -28,7 +28,7 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.7.1",
|
||||
"@polkadot/api-derive": "^0.97.0-beta.2",
|
||||
"@polkadot/api-metadata": "^0.97.0-beta.2",
|
||||
"@polkadot/metadata": "^0.97.0-beta.2",
|
||||
"@polkadot/keyring": "^1.7.0-beta.6",
|
||||
"@polkadot/rpc-core": "^0.97.0-beta.2",
|
||||
"@polkadot/rpc-provider": "^0.97.0-beta.2",
|
||||
|
||||
@@ -2,6 +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 { Constants, Storage } from '@polkadot/metadata/Decorated/types';
|
||||
import { RpcInterface } from '@polkadot/rpc-core/jsonrpc.types';
|
||||
import { Call, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import { AnyFunction, CallFunction, Codec, CodecArg as Arg, ModulesWithCalls } from '@polkadot/types/types';
|
||||
@@ -17,8 +18,6 @@ import BN from 'bn.js';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import decorateDerive, { ExactDerive } from '@polkadot/api-derive';
|
||||
import { Constants } from '@polkadot/api-metadata/consts/types';
|
||||
import { Storage } from '@polkadot/api-metadata/storage/types';
|
||||
import RpcCore from '@polkadot/rpc-core';
|
||||
import { WsProvider } from '@polkadot/rpc-provider';
|
||||
import { Metadata, Null, u64 } from '@polkadot/types';
|
||||
@@ -164,7 +163,7 @@ export default abstract class Decorate<ApiType extends ApiTypes> extends Events
|
||||
this.filterRpcMethods(methods);
|
||||
}
|
||||
|
||||
protected filterRpcMethods (methods: string[]): void{
|
||||
protected filterRpcMethods (methods: string[]): void {
|
||||
// this is true when the RPC has entries
|
||||
const hasResults = methods.length !== 0;
|
||||
|
||||
|
||||
@@ -6,9 +6,7 @@ import { SignedBlock } from '@polkadot/types/interfaces';
|
||||
import { RegistryTypes } from '@polkadot/types/types';
|
||||
import { ApiBase, ApiOptions, ApiTypes, DecorateMethod } from '../types';
|
||||
|
||||
import constantsFromMeta from '@polkadot/api-metadata/consts/fromMetadata';
|
||||
import extrinsicsFromMeta from '@polkadot/api-metadata/extrinsics/fromMetadata';
|
||||
import storageFromMeta from '@polkadot/api-metadata/storage/fromMetadata';
|
||||
import DecoratedMeta from '@polkadot/metadata';
|
||||
import { GenericCall, GenericEvent, Metadata, u32 as U32 } from '@polkadot/types';
|
||||
import { LATEST_EXTRINSIC_VERSION } from '@polkadot/types/primitive/Extrinsic/Extrinsic';
|
||||
import { logger } from '@polkadot/util';
|
||||
@@ -167,9 +165,7 @@ export default abstract class Init<ApiType extends ApiTypes> extends Decorate<Ap
|
||||
this.registerTypes(TYPES_SUBSTRATE_1);
|
||||
}
|
||||
|
||||
const extrinsics = extrinsicsFromMeta(metadata);
|
||||
const storage = storageFromMeta(metadata);
|
||||
const constants = constantsFromMeta(metadata);
|
||||
const decoratedMeta = new DecoratedMeta(metadata);
|
||||
|
||||
// only inject if we are not a clone (global init)
|
||||
if (!this._options.source) {
|
||||
@@ -183,16 +179,16 @@ export default abstract class Init<ApiType extends ApiTypes> extends Decorate<Ap
|
||||
this._extrinsicType = firstTx ? firstTx.type : LATEST_EXTRINSIC_VERSION;
|
||||
}
|
||||
|
||||
this._extrinsics = this.decorateExtrinsics(extrinsics, this.decorateMethod);
|
||||
this._query = this.decorateStorage(storage, this.decorateMethod);
|
||||
this._consts = constants;
|
||||
this._extrinsics = this.decorateExtrinsics(decoratedMeta.tx, this.decorateMethod);
|
||||
this._query = this.decorateStorage(decoratedMeta.query, this.decorateMethod);
|
||||
this._consts = decoratedMeta.consts;
|
||||
|
||||
this._rx.extrinsicType = this._extrinsicType;
|
||||
this._rx.genesisHash = this._genesisHash;
|
||||
this._rx.runtimeVersion = this._runtimeVersion;
|
||||
this._rx.tx = this.decorateExtrinsics(extrinsics, this.rxDecorateMethod);
|
||||
this._rx.query = this.decorateStorage(storage, this.rxDecorateMethod);
|
||||
this._rx.consts = constants;
|
||||
this._rx.tx = this.decorateExtrinsics(decoratedMeta.tx, this.rxDecorateMethod);
|
||||
this._rx.query = this.decorateStorage(decoratedMeta.query, this.rxDecorateMethod);
|
||||
this._rx.consts = decoratedMeta.consts;
|
||||
|
||||
// derive is last, since it uses the decorated rx
|
||||
this._rx.derive = this.decorateDeriveRx(this.rxDecorateMethod);
|
||||
|
||||
@@ -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 { Constants } from '@polkadot/metadata/Decorated/types';
|
||||
import { RpcInterface } from '@polkadot/rpc-core/jsonrpc.types';
|
||||
import { Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import { InterfaceRegistry } from '@polkadot/types/interfaceRegistry';
|
||||
import { CallFunction, InterfaceTypes, RegistryTypes, SignerPayloadRawBase } from '@polkadot/types/types';
|
||||
import { ApiInterfaceRx, ApiOptions, ApiTypes, DecoratedRpc, DecorateMethod, QueryableStorage, QueryableStorageMulti, SubmittableExtrinsics, Signer } from '../types';
|
||||
|
||||
import { Constants } from '@polkadot/api-metadata/consts/types';
|
||||
import { GenericCall, Metadata, createType, getTypeRegistry } from '@polkadot/types';
|
||||
import { assert, isString, isUndefined, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
// Simple non-runnable checks to test type definitions in the editor itself
|
||||
|
||||
import { ConstantCodec } from '@polkadot/api-metadata/consts/types';
|
||||
import { ConstantCodec } from '@polkadot/metadata/Decorated/types';
|
||||
import { Balance, Header, Index } from '@polkadot/types/interfaces';
|
||||
import { IExtrinsic, IMethod } from '@polkadot/types/types';
|
||||
|
||||
|
||||
@@ -2,6 +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 { Constants } from '@polkadot/metadata/Decorated/types';
|
||||
import { UserRpc } from '@polkadot/rpc-core/types';
|
||||
import { Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import { AnyFunction, Callback, CallFunction, Codec, CodecArg, RegistryTypes, SignatureOptions, SignerPayloadJSON, SignerPayloadRaw } from '@polkadot/types/types';
|
||||
@@ -11,7 +12,6 @@ import { DeriveAllSections } from './util/decorate';
|
||||
import BN from 'bn.js';
|
||||
import { Observable } from 'rxjs';
|
||||
import { DeriveCustom, ExactDerive } from '@polkadot/api-derive';
|
||||
import { Constants } from '@polkadot/api-metadata/consts/types';
|
||||
import { RpcInterface } from '@polkadot/rpc-core/jsonrpc.types';
|
||||
import { ProviderInterface, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types';
|
||||
import { Metadata, u64 } from '@polkadot/types';
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
import { BlockNumber, Index, SignedBlock } from '@polkadot/types/interfaces';
|
||||
|
||||
import storage from '@polkadot/api-metadata/storage/static';
|
||||
import Metadata from '@polkadot/metadata';
|
||||
import rpcMetadata from '@polkadot/metadata/Metadata/static';
|
||||
import WsProvider from '@polkadot/rpc-provider/ws';
|
||||
import { ClassOf } from '@polkadot/types';
|
||||
|
||||
@@ -13,6 +14,7 @@ import Rpc from '@polkadot/rpc-core';
|
||||
import { describeE2E } from '../../util';
|
||||
|
||||
const randomAccount = '5HTqyWJHAVUieZnpb1V8gK4T1E4mnhkrUVSSzWBQd6kYgsVJ';
|
||||
const metadata = new Metadata(rpcMetadata);
|
||||
|
||||
describeE2E({
|
||||
only: [
|
||||
@@ -29,8 +31,8 @@ describeE2E({
|
||||
it('subscribes to storage', (done): void => {
|
||||
rpc.state
|
||||
.subscribeStorage<[BlockNumber, Index]>([
|
||||
[storage.system.accountNonce, randomAccount],
|
||||
[storage.session.currentIndex]
|
||||
[metadata.query.system.accountNonce, randomAccount],
|
||||
[metadata.query.session.currentIndex]
|
||||
])
|
||||
.subscribe((data): void => {
|
||||
expect(data).toHaveLength(2);
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
import { Balance, Moment, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
|
||||
import storage from '@polkadot/api-metadata/storage/static';
|
||||
import DecorateMeta from '@polkadot/metadata';
|
||||
import rpcMetadata from '@polkadot/metadata/Metadata/static';
|
||||
import Rpc from '@polkadot/rpc-core';
|
||||
import WsProvider from '@polkadot/rpc-provider/ws';
|
||||
import { Bytes, ClassOf, Metadata, StorageKey } from '@polkadot/types';
|
||||
@@ -13,6 +14,7 @@ import { describeE2E } from '../../util';
|
||||
|
||||
const BOB_STASH = '5HpG9w8EBLe5XCrbczpwq5TSXvedjrBGCwqxK1iQ7qUsSWFc';
|
||||
const CODE = '0x3a636f6465'; // :code
|
||||
const metadata = new DecorateMeta(rpcMetadata);
|
||||
|
||||
describeE2E({
|
||||
except: [
|
||||
@@ -59,7 +61,7 @@ describeE2E({
|
||||
it('retrieves code', (done): void => {
|
||||
rpc.state
|
||||
.getStorage<Bytes>([
|
||||
storage.substrate.code
|
||||
metadata.query.substrate.code
|
||||
])
|
||||
.subscribe((code: Bytes): void => {
|
||||
expect(code).toBeDefined();
|
||||
@@ -71,7 +73,7 @@ describeE2E({
|
||||
it('retrieves balances', (done): void => {
|
||||
rpc.state
|
||||
.getStorage<Balance>([
|
||||
storage.balances.freeBalance, BOB_STASH
|
||||
metadata.query.balances.freeBalance, BOB_STASH
|
||||
])
|
||||
.subscribe((balance): void => {
|
||||
expect(balance.isZero()).not.toEqual(true);
|
||||
@@ -82,7 +84,7 @@ describeE2E({
|
||||
it('retrieves timestamp', (done): void => {
|
||||
rpc.state
|
||||
.getStorage<Moment>([
|
||||
storage.timestamp.now
|
||||
metadata.query.timestamp.now
|
||||
])
|
||||
.subscribe((moment: Moment): void => {
|
||||
expect(moment.toNumber()).not.toEqual(0);
|
||||
|
||||
@@ -2,15 +2,18 @@
|
||||
// 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/metadata';
|
||||
import rpcMetadata from '@polkadot/metadata/Metadata/static';
|
||||
import testingPairs from '@polkadot/keyring/testingPairs';
|
||||
import WsProvider from '@polkadot/rpc-provider/ws';
|
||||
import storage from '@polkadot/api-metadata/storage/static';
|
||||
import Rpc from '@polkadot/rpc-core';
|
||||
import { Index, Moment, SessionIndex } from '@polkadot/types/interfaces';
|
||||
import { ClassOf } from '@polkadot/types';
|
||||
|
||||
import { describeE2E } from '../../util';
|
||||
|
||||
const metadata = new Metadata(rpcMetadata);
|
||||
|
||||
describeE2E({
|
||||
except: [
|
||||
'remote-polkadot-alexander',
|
||||
@@ -28,8 +31,8 @@ describeE2E({
|
||||
it('subscribes to storage', (done): void => {
|
||||
rpc.state
|
||||
.subscribeStorage<[Index, SessionIndex]>([
|
||||
[storage.system.accountNonce, keyring.eve.address],
|
||||
[storage.session.currentIndex]
|
||||
[metadata.query.system.accountNonce, keyring.eve.address],
|
||||
[metadata.query.session.currentIndex]
|
||||
])
|
||||
.subscribe((data): void => {
|
||||
expect(data).toHaveLength(2);
|
||||
@@ -48,7 +51,7 @@ describeE2E({
|
||||
let count = 0;
|
||||
|
||||
rpc.state
|
||||
.subscribeStorage<Moment>([[storage.timestamp.now]])
|
||||
.subscribeStorage<Moment>([[metadata.query.timestamp.now]])
|
||||
.subscribe((data): void => {
|
||||
expect(data).toBeDefined();
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
# @polkadot/metadata
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "@polkadot/api-metadata",
|
||||
"name": "@polkadot/metadata",
|
||||
"version": "0.97.0-beta.2",
|
||||
"description": "Helpers to extract information from runtime metadata",
|
||||
"main": "index.js",
|
||||
@@ -0,0 +1,49 @@
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import '@polkadot/types/injector';
|
||||
|
||||
import { ClassOf, createType } from '@polkadot/types/codec/create';
|
||||
|
||||
import Decorated from './Decorated';
|
||||
import json from '../Metadata/static';
|
||||
|
||||
const decorated = new Decorated(json);
|
||||
|
||||
describe('Decorated', () => {
|
||||
it('should correctly get Alice\'s freeBalance storage key (u8a)', (): void => {
|
||||
expect(
|
||||
decorated.query
|
||||
.balances
|
||||
.freeBalance('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY')
|
||||
).toEqual(
|
||||
// length prefix attached
|
||||
Uint8Array.from([
|
||||
128, 127, 134, 78, 24, 227, 221, 139, 88, 56, 99, 16, 210, 254, 9, 25, 238, 242, 124, 110, 85, 133, 100, 183, 246, 127, 34, 217, 157, 32, 245, 135, 187
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
it('should return properly-encoded transactions', (): void => {
|
||||
expect(
|
||||
createType('Extrinsic', decorated.tx.timestamp.set([10101])).toU8a()
|
||||
).toEqual(
|
||||
new Uint8Array([
|
||||
// length (encoded)
|
||||
4 << 2,
|
||||
// version, no signature
|
||||
1,
|
||||
// index
|
||||
3, 0,
|
||||
// values, Compact<Moment>
|
||||
116
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
it('should return constants with the correct type and value', (): void => {
|
||||
expect(decorated.consts.democracy.cooloffPeriod).toBeInstanceOf(ClassOf('BlockNumber'));
|
||||
expect(decorated.consts.democracy.cooloffPeriod.toHex()).toEqual('0x000c4e00');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ModulesWithCalls } from '@polkadot/types/types';
|
||||
import { Constants, Storage } from './types';
|
||||
|
||||
import Metadata from '../Metadata';
|
||||
import constantsFromMeta from './consts/fromMetadata';
|
||||
import extrinsicsFromMeta from './extrinsics/fromMetadata';
|
||||
import storageFromMeta from './storage/fromMetadata';
|
||||
|
||||
/**
|
||||
* This class represents a decorated wrapper over the [[Metadata]]. The
|
||||
* [[Metadata]] type is a Codec type returned by the node, and `Decorated`
|
||||
* composes it and populates the `.query`, `.tx` and `.consts` sections.
|
||||
*/
|
||||
export default class Decorated {
|
||||
public readonly consts: Constants;
|
||||
|
||||
public readonly metadata: Metadata;
|
||||
|
||||
public readonly query: Storage;
|
||||
|
||||
public readonly tx: ModulesWithCalls;
|
||||
|
||||
constructor (value?: Uint8Array | string | Metadata) {
|
||||
this.metadata = value instanceof Metadata ? value : new Metadata(value);
|
||||
this.tx = extrinsicsFromMeta(this.metadata);
|
||||
this.query = storageFromMeta(this.metadata);
|
||||
this.consts = constantsFromMeta(this.metadata);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
# @polkadot/metadata/consts
|
||||
|
||||
A base interface to the parameter types
|
||||
+3
-3
@@ -1,16 +1,16 @@
|
||||
// Copyright 2017-2019 @polkadot/api-metadata authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import '@polkadot/types/injector';
|
||||
|
||||
import { ClassOf, Metadata } from '@polkadot/types';
|
||||
import json from '@polkadot/types/Metadata/static';
|
||||
|
||||
import rpcMetadata from '../../../Metadata/static';
|
||||
import fromMetadata from '../fromMetadata';
|
||||
|
||||
// Use the pre-generated metadata
|
||||
const metadata = new Metadata(json);
|
||||
const metadata = new Metadata(rpcMetadata);
|
||||
const consts = fromMetadata(metadata);
|
||||
|
||||
describe('fromMetadata', (): void => {
|
||||
+4
-3
@@ -1,13 +1,14 @@
|
||||
// Copyright 2017-2019 @polkadot/api-metadata authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Constants, ConstantCodec, ModuleConstants } from '../types';
|
||||
import { Constants, ConstantCodec, ModuleConstants } from '../../types';
|
||||
|
||||
import { createTypeUnsafe } from '@polkadot/types/codec';
|
||||
import Metadata from '@polkadot/types/Metadata';
|
||||
import { stringCamelCase } from '@polkadot/util';
|
||||
|
||||
import Metadata from '../../../Metadata';
|
||||
|
||||
/**
|
||||
* Retrieve the parameter types (module constants) from the runtime metadata.
|
||||
*
|
||||
@@ -0,0 +1,3 @@
|
||||
# @polkadot/metadata/extrinsics
|
||||
|
||||
Base extrinsic definitions & codecs
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-metadata authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
// Copyright 2017-2019 @polkadot/api-metadata authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import '@polkadot/types/injector';
|
||||
|
||||
import { createType, Metadata } from '@polkadot/types';
|
||||
import json from '@polkadot/types/Metadata/static';
|
||||
|
||||
import json from '../../../Metadata/static';
|
||||
import fromMetadata from '.';
|
||||
|
||||
// Use the pre-generated metadata
|
||||
+3
-3
@@ -1,13 +1,13 @@
|
||||
// Copyright 2017-2019 @polkadot/api-metadata authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Calls, ModulesWithCalls } from '@polkadot/types/types';
|
||||
|
||||
import { ModuleMetadataV8 } from '@polkadot/types/Metadata/v8/Metadata';
|
||||
import Metadata from '@polkadot/types/Metadata';
|
||||
import { stringCamelCase } from '@polkadot/util';
|
||||
|
||||
import { ModuleMetadataV8 } from '../../../Metadata/v8/Metadata';
|
||||
import Metadata from '../../../Metadata';
|
||||
import extrinsics from '../';
|
||||
import createUnchecked from './createUnchecked';
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-metadata authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -9,8 +9,8 @@ import '@polkadot/types/injector';
|
||||
import BN from 'bn.js';
|
||||
import testingPairs from '@polkadot/keyring/testingPairs';
|
||||
import { createType, Metadata } from '@polkadot/types';
|
||||
import metadataStatic from '@polkadot/types/Metadata/static';
|
||||
|
||||
import metadataStatic from '../../Metadata/static';
|
||||
import fromMetadata from './fromMetadata';
|
||||
|
||||
const keyring = testingPairs({ type: 'ed25519' }, false);
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-metadata authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import Decorated from './Decorated';
|
||||
|
||||
export default Decorated;
|
||||
@@ -0,0 +1,3 @@
|
||||
# @polkadot/metadata/storage
|
||||
|
||||
A base interface to the storage layer
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-metadata authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-metadata authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -6,10 +6,10 @@ import { Codec } from '@polkadot/types/types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { Compact, U8a, createType, createTypeUnsafe } from '@polkadot/types/codec';
|
||||
import { StorageEntryMetadata, StorageEntryType } from '@polkadot/types/Metadata/v8/Storage';
|
||||
import { StorageEntry } from '@polkadot/types/primitive/StorageKey';
|
||||
import { assert, isNull, isUndefined, stringLowerFirst, stringToU8a, u8aConcat } from '@polkadot/util';
|
||||
|
||||
import { StorageEntryMetadata, StorageEntryType } from '../../../Metadata/v8/Storage';
|
||||
import getHasher, { HasherFunction } from './getHasher';
|
||||
|
||||
export interface CreateItemOptions {
|
||||
+7
-5
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-metadata authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -7,23 +7,25 @@ import '@polkadot/types/injector';
|
||||
import testingPairs from '@polkadot/keyring/testingPairs';
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
import storage from '../static';
|
||||
import rpcMetadata from '../../../Metadata/static';
|
||||
import Decorated from '../../Decorated';
|
||||
|
||||
const keyring = testingPairs({ type: 'ed25519' });
|
||||
const decorated = new Decorated(rpcMetadata);
|
||||
|
||||
describe('fromMetadata', (): void => {
|
||||
it('should throw if the storage function expects an argument', (): void => {
|
||||
expect((): any => storage.balances.freeBalance()).toThrowError(/requires one argument/);
|
||||
expect((): any => decorated.query.balances.freeBalance()).toThrowError(/requires one argument/);
|
||||
});
|
||||
|
||||
it('should return a value if the storage function does not expect an argument', (): void => {
|
||||
expect((): any => storage.timestamp.now()).not.toThrow();
|
||||
expect((): any => decorated.query.timestamp.now()).not.toThrow();
|
||||
});
|
||||
|
||||
it('should return the correct length-prefixed storage key', (): void => {
|
||||
expect(
|
||||
u8aToHex(
|
||||
storage.balances.freeBalance(keyring.alice.address)
|
||||
decorated.query.balances.freeBalance(keyring.alice.address)
|
||||
)
|
||||
).toEqual(
|
||||
'0x807f864e18e3dd8b58386310d2fe0919eef27c6e558564b7f67f22d99d20f587bb'
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-metadata authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-metadata authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+3
-3
@@ -1,12 +1,12 @@
|
||||
// Copyright 2017-2019 @polkadot/api-metadata authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ModuleStorage, Storage } from '../types';
|
||||
import { ModuleStorage, Storage } from '../../types';
|
||||
|
||||
import Metadata from '@polkadot/types/Metadata';
|
||||
import { stringCamelCase, stringLowerFirst } from '@polkadot/util';
|
||||
|
||||
import Metadata from '../../../Metadata';
|
||||
import createFunction from './createFunction';
|
||||
import { storage } from './storage';
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-metadata authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
// Copyright 2017-2019 @polkadot/api-metadata authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Storage } from '../types';
|
||||
import { Storage } from '../../types';
|
||||
import * as substrate from './substrate';
|
||||
|
||||
export const storage: Storage = {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-metadata authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
// Copyright 2017-2019 @polkadot/api-metadata authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { StorageEntryMetadata, StorageEntryType } from '@polkadot/types/Metadata/v8/Storage';
|
||||
import { StorageEntry } from '@polkadot/types/primitive/StorageKey';
|
||||
import { createType } from '@polkadot/types/codec';
|
||||
import { StorageEntryMetadata, StorageEntryType } from '../../../Metadata/v8/Storage';
|
||||
|
||||
import createFunction from './createFunction';
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/api-metadata authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+11
-1
@@ -1,7 +1,8 @@
|
||||
// Copyright 2017-2019 @polkadot/api-metadata authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { StorageEntry } from '@polkadot/types/primitive/StorageKey';
|
||||
import { Codec } from '@polkadot/types/types';
|
||||
import { ModuleConstantMetadataLatest } from '@polkadot/types/interfaces';
|
||||
|
||||
@@ -12,3 +13,12 @@ export interface ConstantCodec extends Codec {
|
||||
export type ModuleConstants = Record<string, Codec>;
|
||||
|
||||
export type Constants = Record<string, ModuleConstants>;
|
||||
|
||||
export interface ModuleStorage {
|
||||
[key: string]: StorageEntry;
|
||||
}
|
||||
|
||||
export interface Storage {
|
||||
[key: string]: ModuleStorage; // Will hold modules returned by state_getMetadata
|
||||
substrate: { [key: string]: StorageEntry };
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import U32 from '../primitive/U32';
|
||||
import U32 from '@polkadot/types/primitive/U32';
|
||||
|
||||
export const MAGIC_NUMBER = new U32(0x6174656d); // `meta`, reversed for Little Endian encoding
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+6
-5
@@ -1,13 +1,14 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { MetadataV0, MetadataV1 } from '../interfaces/metadata';
|
||||
import { MetadataV0, MetadataV1 } from '@polkadot/types/interfaces/metadata';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import Enum from '../codec/Enum';
|
||||
import Struct from '../codec/Struct';
|
||||
import Enum from '@polkadot/types/codec/Enum';
|
||||
import Struct from '@polkadot/types/codec/Struct';
|
||||
|
||||
import MagicNumber from './MagicNumber';
|
||||
import MetadataV2 from './v2';
|
||||
import MetadataV3 from './v3';
|
||||
@@ -218,7 +219,7 @@ export default class MetadataVersioned extends Struct {
|
||||
return this.version === version;
|
||||
}
|
||||
|
||||
private getVersion <T extends MetaMapped, F extends MetaMapped> (version: MetaVersions, fromPrev: (input: F) => T): T {
|
||||
private getVersion<T extends MetaMapped, F extends MetaMapped> (version: MetaVersions, fromPrev: (input: F) => T): T {
|
||||
const asCurr: MetaAsX = `asV${version}` as any;
|
||||
const asPrev: MetaAsX = `asV${version - 1}` as any;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Vec } from '../codec';
|
||||
import { Codec } from '../types';
|
||||
import { Codec } from '@polkadot/types/types';
|
||||
import Vec from '@polkadot/types/codec/Vec';
|
||||
|
||||
export interface MetadataInterface<Modules extends Codec> extends Codec {
|
||||
modules: Vec<Modules>;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+4
-4
@@ -1,11 +1,11 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Codec } from '../../types';
|
||||
import { Codec } from '@polkadot/types/types';
|
||||
|
||||
import { Option, Vec } from '../../codec';
|
||||
import { Text, Type } from '../../primitive';
|
||||
import { Option, Vec } from '@polkadot/types/codec';
|
||||
import { Text, Type } from '@polkadot/types/primitive';
|
||||
|
||||
import flattenUniq from './flattenUniq';
|
||||
import validateTypes from './validateTypes';
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+8
-6
@@ -1,15 +1,17 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import '../../injector';
|
||||
import '@polkadot/types/injector';
|
||||
|
||||
import { createTypeUnsafe } from '../../codec/create';
|
||||
import Metadata from '../Metadata';
|
||||
import Call from '../../primitive/Generic/Call';
|
||||
import { Codec } from '@polkadot/types/types';
|
||||
import { MetadataInterface } from '../types';
|
||||
import { Codec } from '../../types';
|
||||
|
||||
import { createTypeUnsafe } from '@polkadot/types/codec/create';
|
||||
import Call from '@polkadot/types/primitive/Generic/Call';
|
||||
|
||||
import getUniqTypes from './getUniqTypes';
|
||||
import Metadata from '../Metadata';
|
||||
|
||||
/**
|
||||
* Given the static `rpcData` and the `staticSubstrate` JSON file, Metadata
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import '../../injector';
|
||||
import '@polkadot/types/injector';
|
||||
|
||||
import staticData from '../static';
|
||||
import Metadata from '..';
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+4
-4
@@ -1,12 +1,12 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { TypeDef, TypeDefInfo, TypeDefExtVecFixed } from '../../codec/types';
|
||||
import { TypeDef, TypeDefInfo, TypeDefExtVecFixed } from '@polkadot/types/codec/types';
|
||||
|
||||
import { getTypeDef, getTypeRegistry } from '@polkadot/types/codec/create';
|
||||
|
||||
import { getTypeDef } from '../../codec/create';
|
||||
import flattenUniq from './flattenUniq';
|
||||
import { getTypeRegistry } from '../../codec';
|
||||
|
||||
function extractTypes (types: string[]): any[] {
|
||||
return types.map((type): any => {
|
||||
+3
-2
@@ -1,8 +1,9 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { createType } from '../../codec';
|
||||
import { createType } from '@polkadot/types/codec';
|
||||
|
||||
import Metadata from '../';
|
||||
import latestSubstrateV0 from './static-substrate.json';
|
||||
import rpcData from './static';
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { EventMetadataV1, FunctionMetadataV1, MetadataV0, MetadataV1, ModuleMetadataV1, RuntimeModuleMetadataV0, StorageFunctionMetadataV1 } from '../../interfaces/metadata';
|
||||
import { EventMetadataV1, FunctionMetadataV1, MetadataV0, MetadataV1, ModuleMetadataV1, RuntimeModuleMetadataV0, StorageFunctionMetadataV1 } from '@polkadot/types/interfaces/metadata';
|
||||
|
||||
import { stringUpperFirst } from '@polkadot/util';
|
||||
|
||||
import { createType, Option, Vec } from '../../codec';
|
||||
import { Text } from '../../primitive';
|
||||
import { createType, Option, Vec } from '@polkadot/types/codec';
|
||||
import { Text } from '@polkadot/types/primitive';
|
||||
|
||||
function toV1Calls ({ module: { call: { functions } } }: RuntimeModuleMetadataV0): Option<FunctionMetadataV1> {
|
||||
return functions.length
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { MetadataV1 } from '../../interfaces/metadata';
|
||||
import { MetadataV1 } from '@polkadot/types/interfaces/metadata';
|
||||
|
||||
import MetadataV2 from '../v2';
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+6
-6
@@ -1,14 +1,14 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { EventMetadataV2, FunctionMetadataV2 } from '../../interfaces/metadata';
|
||||
import { EventMetadataV2, FunctionMetadataV2 } from '@polkadot/types/interfaces/metadata';
|
||||
import { MetadataInterface } from '../types';
|
||||
|
||||
import Option from '../../codec/Option';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Text from '../../primitive/Text';
|
||||
import Option from '@polkadot/types/codec/Option';
|
||||
import Struct from '@polkadot/types/codec/Struct';
|
||||
import Vec from '@polkadot/types/codec/Vec';
|
||||
import Text from '@polkadot/types/primitive/Text';
|
||||
|
||||
import { StorageFunctionMetadata } from './Storage';
|
||||
|
||||
+8
-8
@@ -1,17 +1,17 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { MapTypeV2, PlainTypeV2, StorageFunctionModifierV2 } from '../../interfaces/metadata';
|
||||
import { AnyNumber } from '../../types';
|
||||
import { MapTypeV2, PlainTypeV2, StorageFunctionModifierV2 } from '@polkadot/types/interfaces/metadata';
|
||||
import { AnyNumber } from '@polkadot/types/types';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import Enum from '../../codec/Enum';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Bytes from '../../primitive/Bytes';
|
||||
import Text from '../../primitive/Text';
|
||||
import Enum from '@polkadot/types/codec/Enum';
|
||||
import Struct from '@polkadot/types/codec/Struct';
|
||||
import Vec from '@polkadot/types/codec/Vec';
|
||||
import Bytes from '@polkadot/types/primitive/Bytes';
|
||||
import Text from '@polkadot/types/primitive/Text';
|
||||
|
||||
export class StorageFunctionType extends Enum {
|
||||
constructor (value?: any, index?: number) {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+6
-6
@@ -1,14 +1,14 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { EventMetadataV3, FunctionMetadataV3 } from '../../interfaces/metadata';
|
||||
import { EventMetadataV3, FunctionMetadataV3 } from '@polkadot/types/interfaces/metadata';
|
||||
import { MetadataInterface } from '../types';
|
||||
|
||||
import Option from '../../codec/Option';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Text from '../../primitive/Text';
|
||||
import Option from '@polkadot/types/codec/Option';
|
||||
import Struct from '@polkadot/types/codec/Struct';
|
||||
import Vec from '@polkadot/types/codec/Vec';
|
||||
import Text from '@polkadot/types/primitive/Text';
|
||||
|
||||
import { StorageFunctionMetadata } from './Storage';
|
||||
|
||||
+8
-8
@@ -1,17 +1,17 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { DoubleMapTypeV3, MapTypeV3, PlainTypeV3, StorageFunctionModifierV3 } from '../../interfaces/metadata';
|
||||
import { AnyNumber } from '../../types';
|
||||
import { DoubleMapTypeV3, MapTypeV3, PlainTypeV3, StorageFunctionModifierV3 } from '@polkadot/types/interfaces/metadata';
|
||||
import { AnyNumber } from '@polkadot/types/types';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import Enum from '../../codec/Enum';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Bytes from '../../primitive/Bytes';
|
||||
import Text from '../../primitive/Text';
|
||||
import Enum from '@polkadot/types/codec/Enum';
|
||||
import Struct from '@polkadot/types/codec/Struct';
|
||||
import Vec from '@polkadot/types/codec/Vec';
|
||||
import Bytes from '@polkadot/types/primitive/Bytes';
|
||||
import Text from '@polkadot/types/primitive/Text';
|
||||
|
||||
export class StorageFunctionType extends Enum {
|
||||
constructor (value?: any, index?: number) {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { createType, Option, Vec } from '../../codec';
|
||||
import StorageHasher from '@polkadot/types/primitive/StorageHasher';
|
||||
import { createType, Option, Vec } from '@polkadot/types/codec';
|
||||
|
||||
import MetadataV3 from './Metadata';
|
||||
import StorageHasher from '../../primitive/StorageHasher';
|
||||
import MetadataV4 from '../v4';
|
||||
import { ModuleMetadataV4 } from '../v4/Metadata';
|
||||
import { StorageFunctionMetadata, StorageFunctionType } from '../v4/Storage';
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+6
-6
@@ -1,14 +1,14 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { EventMetadataV4, FunctionMetadataV4 } from '../../interfaces/metadata';
|
||||
import { EventMetadataV4, FunctionMetadataV4 } from '@polkadot/types/interfaces/metadata';
|
||||
import { MetadataInterface } from '../types';
|
||||
|
||||
import Option from '../../codec/Option';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Text from '../../primitive/Text';
|
||||
import Option from '@polkadot/types/codec/Option';
|
||||
import Struct from '@polkadot/types/codec/Struct';
|
||||
import Vec from '@polkadot/types/codec/Vec';
|
||||
import Text from '@polkadot/types/primitive/Text';
|
||||
import { StorageFunctionMetadata } from './Storage';
|
||||
|
||||
/**
|
||||
+8
-8
@@ -1,17 +1,17 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { DoubleMapTypeV4, MapTypeV4, PlainTypeV4, StorageFunctionModifierV4 } from '../../interfaces/metadata';
|
||||
import { AnyNumber } from '../../types';
|
||||
import { DoubleMapTypeV4, MapTypeV4, PlainTypeV4, StorageFunctionModifierV4 } from '@polkadot/types/interfaces/metadata';
|
||||
import { AnyNumber } from '@polkadot/types/types';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import Enum from '../../codec/Enum';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Bytes from '../../primitive/Bytes';
|
||||
import Text from '../../primitive/Text';
|
||||
import Enum from '@polkadot/types/codec/Enum';
|
||||
import Struct from '@polkadot/types/codec/Struct';
|
||||
import Vec from '@polkadot/types/codec/Vec';
|
||||
import Bytes from '@polkadot/types/primitive/Bytes';
|
||||
import Text from '@polkadot/types/primitive/Text';
|
||||
|
||||
export class StorageFunctionType extends Enum {
|
||||
constructor (value?: any, index?: number) {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import { createType, Option, Vec } from '../../codec';
|
||||
import Text from '../../primitive/Text';
|
||||
import { createType, Option, Vec } from '@polkadot/types/codec';
|
||||
import StorageHasher from '@polkadot/types/primitive/StorageHasher';
|
||||
import Text from '@polkadot/types/primitive/Text';
|
||||
import MetadataV4 from './Metadata';
|
||||
import StorageHasher from '../../primitive/StorageHasher';
|
||||
import MetadataV5 from '../v5';
|
||||
import { ModuleMetadataV5 } from '../v5/Metadata';
|
||||
import { StorageFunctionMetadata, StorageFunctionType } from '../v5/Storage';
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+6
-6
@@ -1,14 +1,14 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { EventMetadataV5, FunctionMetadataV5 } from '../../interfaces/metadata';
|
||||
import { EventMetadataV5, FunctionMetadataV5 } from '@polkadot/types/interfaces/metadata';
|
||||
import { MetadataInterface } from '../types';
|
||||
|
||||
import Option from '../../codec/Option';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Text from '../../primitive/Text';
|
||||
import Option from '@polkadot/types/codec/Option';
|
||||
import Struct from '@polkadot/types/codec/Struct';
|
||||
import Vec from '@polkadot/types/codec/Vec';
|
||||
import Text from '@polkadot/types/primitive/Text';
|
||||
import { StorageFunctionMetadata } from './Storage';
|
||||
|
||||
/**
|
||||
+8
-8
@@ -1,17 +1,17 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { DoubleMapTypeV5, MapTypeV5, PlainTypeV5, StorageFunctionModifierV5 } from '../../interfaces/metadata';
|
||||
import { AnyNumber } from '../../types';
|
||||
import { DoubleMapTypeV5, MapTypeV5, PlainTypeV5, StorageFunctionModifierV5 } from '@polkadot/types/interfaces/metadata';
|
||||
import { AnyNumber } from '@polkadot/types/types';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import Enum from '../../codec/Enum';
|
||||
import Struct from '../../codec/Struct';
|
||||
import Vec from '../../codec/Vec';
|
||||
import Bytes from '../../primitive/Bytes';
|
||||
import Text from '../../primitive/Text';
|
||||
import Enum from '@polkadot/types/codec/Enum';
|
||||
import Struct from '@polkadot/types/codec/Struct';
|
||||
import Vec from '@polkadot/types/codec/Vec';
|
||||
import Bytes from '@polkadot/types/primitive/Bytes';
|
||||
import Text from '@polkadot/types/primitive/Text';
|
||||
|
||||
export class StorageFunctionType extends Enum {
|
||||
constructor (value?: any, index?: number) {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// Copyright 2017-2019 @polkadot/metadata authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user