Adjust for last remaining circular deps (#2971)
* Adjust for last remaining circular deps * Remove RegistryMetadata duplication * Update packages/typegen/scripts/polkadot-types-internal-interfaces.js * typo * Direct decorateExtrinsics import
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Constants, DecoratedMeta } from '@polkadot/metadata/decorate/types';
|
||||
import type { DecoratedMeta } from '@polkadot/metadata/decorate/types';
|
||||
import type { RpcInterface } from '@polkadot/rpc-core/types';
|
||||
import type { Option, Raw, StorageKey, Text, u64 } from '@polkadot/types';
|
||||
import type { Call, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
@@ -84,7 +84,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
protected _runtimeVersion?: RuntimeVersion;
|
||||
|
||||
protected _rx: ApiInterfaceRx = {
|
||||
consts: {} as Constants,
|
||||
consts: {} as QueryableConsts<'rxjs'>,
|
||||
query: {} as QueryableStorage<'rxjs'>,
|
||||
tx: {} as SubmittableExtrinsics<'rxjs'>
|
||||
} as ApiInterfaceRx;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2019 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Metadata, storageFromMeta } from '@polkadot/metadata';
|
||||
import { decorateStorage, Metadata } from '@polkadot/metadata';
|
||||
import { Storage } from '@polkadot/metadata/decorate/types';
|
||||
import metaStatic from '@polkadot/metadata/static';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
@@ -15,7 +15,7 @@ describe('extractStorageArgs', (): void => {
|
||||
beforeEach((): void => {
|
||||
const metadata = new Metadata(registry, metaStatic);
|
||||
|
||||
storage = storageFromMeta(registry, metadata);
|
||||
storage = decorateStorage(registry, metadata.asLatest, metadata.version);
|
||||
});
|
||||
|
||||
it('validates no-arg plain', (): void => {
|
||||
|
||||
+4
-3
@@ -1,6 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { BlockNumber } from '@polkadot/types/interfaces';
|
||||
import type { Constants } from '../types';
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
@@ -8,7 +9,7 @@ import { TypeRegistry } from '@polkadot/types/create';
|
||||
import { Metadata } from '../../Metadata';
|
||||
import rpcMetadata from '../../static';
|
||||
import rpcMetadataV10 from '../../v10/static';
|
||||
import { constantsFromMeta } from './fromMetadata';
|
||||
import { decorateConstants } from '..';
|
||||
|
||||
function init (meta: string): [Constants, TypeRegistry] {
|
||||
const registry = new TypeRegistry();
|
||||
@@ -16,7 +17,7 @@ function init (meta: string): [Constants, TypeRegistry] {
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
return [constantsFromMeta(registry, metadata), registry];
|
||||
return [decorateConstants(registry, metadata.asLatest), registry];
|
||||
}
|
||||
|
||||
describe('fromMetadata', (): void => {
|
||||
@@ -25,7 +26,7 @@ describe('fromMetadata', (): void => {
|
||||
|
||||
expect(consts.democracy.cooloffPeriod).toBeInstanceOf(registry.createClass('BlockNumber'));
|
||||
// 3 second blocks, 28 days
|
||||
expect(consts.democracy.cooloffPeriod.toNumber()).toEqual(28 * 24 * 60 * (60 / 3));
|
||||
expect((consts.democracy.cooloffPeriod as unknown as BlockNumber).toNumber()).toEqual(28 * 24 * 60 * (60 / 3));
|
||||
});
|
||||
|
||||
// removed from session
|
||||
+3
-4
@@ -1,16 +1,15 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { MetadataLatest } from '@polkadot/types/interfaces';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { ConstantCodec, Constants, ModuleConstants } from '../types';
|
||||
|
||||
import { hexToU8a, stringCamelCase } from '@polkadot/util';
|
||||
|
||||
import { Metadata } from '../../Metadata';
|
||||
|
||||
/** @internal */
|
||||
export function constantsFromMeta (registry: Registry, metadata: Metadata): Constants {
|
||||
return metadata.asLatest.modules.reduce((result: Constants, moduleMetadata): Constants => {
|
||||
export function decorateConstants (registry: Registry, { modules }: MetadataLatest): Constants {
|
||||
return modules.reduce((result: Constants, moduleMetadata): Constants => {
|
||||
if (moduleMetadata.constants.isEmpty) {
|
||||
return result;
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Call } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson, CallFunction, Registry, RegistryMetadataCall } from '@polkadot/types/types';
|
||||
import type { Call, FunctionMetadataLatest } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson, CallFunction, Registry } from '@polkadot/types/types';
|
||||
|
||||
import { assert, stringCamelCase } from '@polkadot/util';
|
||||
|
||||
/** @internal */
|
||||
export function createUnchecked (registry: Registry, section: string, callIndex: Uint8Array, callMetadata: RegistryMetadataCall): CallFunction {
|
||||
export function createUnchecked (registry: Registry, section: string, callIndex: Uint8Array, callMetadata: FunctionMetadataLatest): CallFunction {
|
||||
const expectedArgs = callMetadata.args;
|
||||
const funcName = stringCamelCase(callMetadata.name);
|
||||
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import { Metadata } from '../../Metadata';
|
||||
import json from '../../static';
|
||||
import { extrinsicsFromMeta } from './fromMetadata';
|
||||
|
||||
// Use the pre-generated metadata
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, json);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
const newExtrinsics = extrinsicsFromMeta(registry, metadata);
|
||||
|
||||
describe('fromMetadata', (): void => {
|
||||
it('should throw if an incorrect number of args is supplied', (): void => {
|
||||
expect((): any => newExtrinsics.balances.setBalance()).toThrowError(/expects 3 arguments/);
|
||||
});
|
||||
|
||||
it('should return a value if the storage function does not expect an argument', (): void => {
|
||||
expect((): any => newExtrinsics.balances.setBalance('5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF', 2, 3)).not.toThrow();
|
||||
});
|
||||
|
||||
it('should return properly-encoded transactions', (): void => {
|
||||
expect(
|
||||
registry.createType('Extrinsic', newExtrinsics.timestamp.set([10101])).toU8a()
|
||||
).toEqual(
|
||||
new Uint8Array([
|
||||
// length (encoded)
|
||||
4 << 2,
|
||||
// version, no signature
|
||||
4,
|
||||
// index
|
||||
3, 0,
|
||||
// values, Compact<Moment>
|
||||
116
|
||||
])
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,34 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Calls, ModulesWithCalls, Registry, RegistryMetadata, RegistryMetadataModule } from '@polkadot/types/types';
|
||||
|
||||
import { stringCamelCase } from '@polkadot/util';
|
||||
|
||||
import { createUnchecked } from './createUnchecked';
|
||||
import extrinsics from '.';
|
||||
|
||||
/** @internal */
|
||||
export function extrinsicsFromMeta (registry: Registry, metadata: RegistryMetadata): ModulesWithCalls {
|
||||
const modules = metadata.asLatest.modules;
|
||||
const isIndexed = modules.some(({ index }) => !index.eqn(255));
|
||||
|
||||
return modules
|
||||
.filter(({ calls }) => calls.isSome)
|
||||
.reduce((result, { calls, index, name }: RegistryMetadataModule, _sectionIndex): ModulesWithCalls => {
|
||||
const sectionIndex = isIndexed
|
||||
? index.toNumber()
|
||||
: _sectionIndex;
|
||||
const section = stringCamelCase(name);
|
||||
|
||||
result[section] = calls.unwrap().reduce((newModule: Calls, callMetadata, methodIndex): Calls => {
|
||||
const method = stringCamelCase(callMetadata.name);
|
||||
|
||||
newModule[method] = createUnchecked(registry, section, new Uint8Array([sectionIndex, methodIndex]), callMetadata);
|
||||
|
||||
return newModule;
|
||||
}, {});
|
||||
|
||||
return result;
|
||||
}, { ...extrinsics });
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import { Metadata } from '../../Metadata';
|
||||
import metadataStatic from '../../static';
|
||||
import { extrinsicsFromMeta } from './fromMetadata';
|
||||
import { decorateExtrinsics } from '..';
|
||||
|
||||
const keyring = createTestPairs({ type: 'ed25519' }, false);
|
||||
const registry = new TypeRegistry();
|
||||
@@ -16,7 +16,7 @@ const metadata = new Metadata(registry, metadataStatic);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
const extrinsics = extrinsicsFromMeta(registry, metadata);
|
||||
const extrinsics = decorateExtrinsics(registry, metadata.asLatest);
|
||||
|
||||
describe('extrinsics', (): void => {
|
||||
it('encodes an actual transfer (actual data)', (): void => {
|
||||
@@ -52,3 +52,30 @@ describe('extrinsics', (): void => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('fromMetadata', (): void => {
|
||||
it('should throw if an incorrect number of args is supplied', (): void => {
|
||||
expect(() => extrinsics.balances.setBalance()).toThrowError(/expects 3 arguments/);
|
||||
});
|
||||
|
||||
it('should return a value if the storage function does not expect an argument', (): void => {
|
||||
expect(() => extrinsics.balances.setBalance('5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF', 2, 3)).not.toThrow();
|
||||
});
|
||||
|
||||
it('should return properly-encoded transactions', (): void => {
|
||||
expect(
|
||||
registry.createType('Extrinsic', extrinsics.timestamp.set([10101])).toU8a()
|
||||
).toEqual(
|
||||
new Uint8Array([
|
||||
// length (encoded)
|
||||
4 << 2,
|
||||
// version, no signature
|
||||
4,
|
||||
// index
|
||||
3, 0,
|
||||
// values, Compact<Moment>
|
||||
116
|
||||
])
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,8 +1,32 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ModulesWithCalls } from '@polkadot/types/types';
|
||||
import type { MetadataLatest } from '@polkadot/types/interfaces';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { Extrinsics, ModuleExtrinsics } from '../types';
|
||||
|
||||
const extrinsics: ModulesWithCalls = {};
|
||||
import { stringCamelCase } from '@polkadot/util';
|
||||
|
||||
export default extrinsics;
|
||||
import { createUnchecked } from './createUnchecked';
|
||||
|
||||
/** @internal */
|
||||
export function decorateExtrinsics (registry: Registry, { modules }: MetadataLatest): Extrinsics {
|
||||
const isIndexed = modules.some(({ index }) => !index.eqn(255));
|
||||
|
||||
return modules
|
||||
.filter(({ calls }) => calls.isSome)
|
||||
.reduce((result: Extrinsics, { calls, index, name }, _sectionIndex): Extrinsics => {
|
||||
const sectionIndex = isIndexed
|
||||
? index.toNumber()
|
||||
: _sectionIndex;
|
||||
const section = stringCamelCase(name);
|
||||
|
||||
result[section] = calls.unwrap().reduce((newModule: ModuleExtrinsics, callMetadata, methodIndex): ModuleExtrinsics => {
|
||||
newModule[stringCamelCase(callMetadata.name)] = createUnchecked(registry, section, new Uint8Array([sectionIndex, methodIndex]), callMetadata);
|
||||
|
||||
return newModule;
|
||||
}, {});
|
||||
|
||||
return result;
|
||||
}, {});
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { Metadata } from '../Metadata';
|
||||
import json from '../static';
|
||||
import { constantsFromMeta, extrinsicsFromMeta, storageFromMeta } from './';
|
||||
import { decorateConstants, decorateExtrinsics, decorateStorage } from './';
|
||||
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, json);
|
||||
@@ -15,7 +15,7 @@ registry.setMetadata(metadata);
|
||||
|
||||
describe('Decorated', () => {
|
||||
it('should correctly get Alice\'s nonce storage key (u8a)', (): void => {
|
||||
const query = storageFromMeta(registry, metadata);
|
||||
const query = decorateStorage(registry, metadata.asLatest, metadata.version);
|
||||
|
||||
expect(
|
||||
u8aToHex(
|
||||
@@ -27,7 +27,7 @@ describe('Decorated', () => {
|
||||
});
|
||||
|
||||
it('should return properly-encoded transactions', (): void => {
|
||||
const tx = extrinsicsFromMeta(registry, metadata);
|
||||
const tx = decorateExtrinsics(registry, metadata.asLatest);
|
||||
|
||||
expect(
|
||||
registry.createType('Extrinsic', tx.timestamp.set([10101])).toU8a()
|
||||
@@ -46,7 +46,7 @@ describe('Decorated', () => {
|
||||
});
|
||||
|
||||
it('should return constants with the correct type and value', (): void => {
|
||||
const consts = constantsFromMeta(registry, metadata);
|
||||
const consts = decorateConstants(registry, metadata.asLatest);
|
||||
|
||||
expect(consts.democracy.cooloffPeriod).toBeInstanceOf(registry.createClass('BlockNumber'));
|
||||
expect(consts.democracy.cooloffPeriod.toHex()).toEqual('0x000c4e00');
|
||||
|
||||
@@ -7,21 +7,23 @@ import type { DecoratedMeta } from './types';
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import { Metadata } from '../Metadata';
|
||||
import { constantsFromMeta } from './consts/fromMetadata';
|
||||
import { extrinsicsFromMeta } from './extrinsics/fromMetadata';
|
||||
import { storageFromMeta } from './storage/fromMetadata';
|
||||
import { decorateConstants } from './constants';
|
||||
import { decorateExtrinsics } from './extrinsics';
|
||||
import { decorateStorage } from './storage';
|
||||
|
||||
/**
|
||||
* Expands the metadata by decoration int consts, query and tx sections
|
||||
* Expands the metadata by decoration into consts, query and tx sections
|
||||
*/
|
||||
export function expandMetadata (registry: Registry, value: Metadata): DecoratedMeta {
|
||||
assert(value instanceof Metadata, 'You need to pass a valid Metadata instance to Decorated');
|
||||
export function expandMetadata (registry: Registry, metadata: Metadata): DecoratedMeta {
|
||||
assert(metadata instanceof Metadata, 'You need to pass a valid Metadata instance to Decorated');
|
||||
|
||||
const latest = metadata.asLatest;
|
||||
|
||||
return {
|
||||
consts: constantsFromMeta(registry, value),
|
||||
query: storageFromMeta(registry, value),
|
||||
tx: extrinsicsFromMeta(registry, value)
|
||||
consts: decorateConstants(registry, latest),
|
||||
query: decorateStorage(registry, latest, metadata.version),
|
||||
tx: decorateExtrinsics(registry, latest)
|
||||
};
|
||||
}
|
||||
|
||||
export { constantsFromMeta, extrinsicsFromMeta, storageFromMeta };
|
||||
export { decorateConstants, decorateExtrinsics, decorateStorage };
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { ModuleStorage, Storage } from '../types';
|
||||
|
||||
import { stringCamelCase, stringLowerFirst } from '@polkadot/util';
|
||||
|
||||
import { Metadata } from '../../Metadata';
|
||||
import { createFunction } from './createFunction';
|
||||
import { getStorage } from './storage';
|
||||
|
||||
/** @internal */
|
||||
export function storageFromMeta (registry: Registry, metadata: Metadata): Storage {
|
||||
return metadata.asLatest.modules.reduce((result: Storage, moduleMetadata): Storage => {
|
||||
if (moduleMetadata.storage.isNone) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const { name } = moduleMetadata;
|
||||
const section = stringCamelCase(name);
|
||||
const unwrapped = moduleMetadata.storage.unwrap();
|
||||
const prefix = unwrapped.prefix.toString();
|
||||
|
||||
// For access, we change the index names, i.e. System.Account -> system.account
|
||||
result[section] = unwrapped.items.reduce((newModule, meta): ModuleStorage => {
|
||||
const method = meta.name.toString();
|
||||
|
||||
newModule[stringLowerFirst(method)] = createFunction(registry, {
|
||||
meta,
|
||||
method,
|
||||
prefix,
|
||||
section
|
||||
}, { metaVersion: metadata.version });
|
||||
|
||||
return newModule;
|
||||
}, {} as ModuleStorage);
|
||||
|
||||
return result;
|
||||
}, { ...getStorage(registry, metadata.version) });
|
||||
}
|
||||
+2
-2
@@ -3,9 +3,9 @@
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import { getStorage } from './storage';
|
||||
import { getStorage } from './getStorage';
|
||||
|
||||
describe('storage', (): void => {
|
||||
describe('getSorage', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
const storage = getStorage(registry, 8);
|
||||
|
||||
+4
-4
@@ -7,7 +7,7 @@ import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { Metadata } from '../../';
|
||||
import rpcMetadata from '../../static';
|
||||
import { storageFromMeta } from '../';
|
||||
import { decorateStorage } from '..';
|
||||
|
||||
const keyring = createTestPairs({ type: 'ed25519' });
|
||||
|
||||
@@ -18,14 +18,14 @@ describe('fromMetadata', (): void => {
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
const query = storageFromMeta(registry, metadata);
|
||||
const query = decorateStorage(registry, metadata.asLatest, metadata.version);
|
||||
|
||||
it('should throw if the storage function expects an argument', (): void => {
|
||||
expect((): any => query.balances.account()).toThrowError(/requires one argument/);
|
||||
expect(() => query.balances.account()).toThrowError(/requires one argument/);
|
||||
});
|
||||
|
||||
it('should return a value if the storage function does not expect an argument', (): void => {
|
||||
expect((): any => query.timestamp.now()).not.toThrow();
|
||||
expect(() => query.timestamp.now()).not.toThrow();
|
||||
});
|
||||
|
||||
it('should return the correct length-prefixed storage key', (): void => {
|
||||
@@ -1,6 +1,41 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { getStorage } from './storage';
|
||||
import type { MetadataLatest } from '@polkadot/types/interfaces';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { ModuleStorage, Storage } from '../types';
|
||||
|
||||
export default getStorage;
|
||||
import { stringCamelCase, stringLowerFirst } from '@polkadot/util';
|
||||
|
||||
import { createFunction } from './createFunction';
|
||||
import { getStorage } from './getStorage';
|
||||
|
||||
/** @internal */
|
||||
export function decorateStorage (registry: Registry, { modules }: MetadataLatest, metaVersion: number): Storage {
|
||||
return modules.reduce((result: Storage, moduleMetadata): Storage => {
|
||||
if (moduleMetadata.storage.isNone) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const { name } = moduleMetadata;
|
||||
const section = stringCamelCase(name);
|
||||
const unwrapped = moduleMetadata.storage.unwrap();
|
||||
const prefix = unwrapped.prefix.toString();
|
||||
|
||||
// For access, we change the index names, i.e. System.Account -> system.account
|
||||
result[section] = unwrapped.items.reduce((newModule, meta): ModuleStorage => {
|
||||
const method = meta.name.toString();
|
||||
|
||||
newModule[stringLowerFirst(method)] = createFunction(registry, {
|
||||
meta,
|
||||
method,
|
||||
prefix,
|
||||
section
|
||||
}, { metaVersion });
|
||||
|
||||
return newModule;
|
||||
}, {} as ModuleStorage);
|
||||
|
||||
return result;
|
||||
}, { ...getStorage(registry, metaVersion) });
|
||||
}
|
||||
|
||||
@@ -1,27 +1,28 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { AugmentedConst, QueryableConsts, QueryableModuleConsts } from '@polkadot/api/types/consts';
|
||||
import type { ModuleConstantMetadataLatest } from '@polkadot/types/interfaces';
|
||||
import type { StorageEntry } from '@polkadot/types/primitive/types';
|
||||
import type { Codec, ModulesWithCalls } from '@polkadot/types/types';
|
||||
import type { CallFunction, Codec } from '@polkadot/types/types';
|
||||
|
||||
export interface ModuleStorage {
|
||||
[key: string]: StorageEntry;
|
||||
export interface ConstantCodec extends Codec {
|
||||
meta: ModuleConstantMetadataLatest;
|
||||
}
|
||||
|
||||
export type Constants = QueryableConsts<'rxjs'>;
|
||||
export type ModuleConstants = Record<string, ConstantCodec>
|
||||
|
||||
export type ConstantCodec = Codec & AugmentedConst<'rxjs'>;
|
||||
export type ModuleExtrinsics = Record<string, CallFunction>;
|
||||
|
||||
export type ModuleConstants = QueryableModuleConsts;
|
||||
export type ModuleStorage = Record<string, StorageEntry>
|
||||
|
||||
export interface Storage {
|
||||
[key: string]: ModuleStorage;
|
||||
substrate: ModuleStorage;
|
||||
}
|
||||
export type Constants = Record<string, ModuleConstants>;
|
||||
|
||||
export type Extrinsics = Record<string, ModuleExtrinsics>
|
||||
|
||||
export type Storage = Record<string, ModuleStorage>;
|
||||
|
||||
export interface DecoratedMeta {
|
||||
consts: Constants;
|
||||
query: Storage;
|
||||
tx: ModulesWithCalls
|
||||
tx: Extrinsics
|
||||
}
|
||||
|
||||
@@ -4,4 +4,4 @@
|
||||
import './detectPackage';
|
||||
|
||||
export { Metadata } from './Metadata';
|
||||
export { constantsFromMeta, expandMetadata, extrinsicsFromMeta, storageFromMeta } from './decorate';
|
||||
export { decorateConstants, decorateExtrinsics, decorateStorage, expandMetadata } from './decorate';
|
||||
|
||||
@@ -12,7 +12,7 @@ import BN from 'bn.js';
|
||||
import EventEmitter from 'eventemitter3';
|
||||
|
||||
import { createTestKeyring } from '@polkadot/keyring/testing';
|
||||
import { Metadata, storageFromMeta } from '@polkadot/metadata';
|
||||
import { decorateStorage, Metadata } from '@polkadot/metadata';
|
||||
import rpcMetadata from '@polkadot/metadata/static';
|
||||
import jsonrpc from '@polkadot/types/interfaces/jsonrpc';
|
||||
import rpcHeader from '@polkadot/types/json/Header.004.json';
|
||||
@@ -168,7 +168,7 @@ export class MockProvider implements ProviderInterface {
|
||||
|
||||
this.registry.setMetadata(metadata);
|
||||
|
||||
const query = storageFromMeta(this.registry, metadata);
|
||||
const query = decorateStorage(this.registry, metadata.asLatest, metadata.version);
|
||||
|
||||
// Do something every 1 seconds
|
||||
setInterval((): void => {
|
||||
|
||||
@@ -26,7 +26,7 @@ import type { AssetOptions, Owner, PermissionLatest, PermissionVersions, Permiss
|
||||
import type { AuthorityIndex, AuthorityList, AuthorityWeight, EncodedFinalityProofs, GrandpaEquivocation, GrandpaEquivocationProof, GrandpaEquivocationValue, GrandpaPrevote, JustificationNotification, KeyOwnerProof, NextAuthority, PendingPause, PendingResume, Precommits, Prevotes, ReportedRoundStates, RoundState, SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfaces/grandpa';
|
||||
import type { IdentityFields, IdentityInfo, IdentityInfoAdditional, IdentityJudgement, RegistrarIndex, RegistrarInfo, Registration, RegistrationJudgement } from '@polkadot/types/interfaces/identity';
|
||||
import type { AuthIndex, AuthoritySignature, Heartbeat, HeartbeatTo244, OpaqueMultiaddr, OpaqueNetworkState, OpaquePeerId } from '@polkadot/types/interfaces/imOnline';
|
||||
import type { DoubleMapTypeLatest, DoubleMapTypeV10, DoubleMapTypeV11, DoubleMapTypeV12, DoubleMapTypeV9, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV12, ErrorMetadataV9, EventMetadataLatest, EventMetadataV10, EventMetadataV11, EventMetadataV12, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, ExtrinsicMetadataV12, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV12, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV12, FunctionMetadataV9, MapTypeLatest, MapTypeV10, MapTypeV11, MapTypeV12, MapTypeV9, MetadataAll, MetadataLatest, MetadataV10, MetadataV11, MetadataV12, MetadataV9, ModuleConstantMetadataLatest, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV12, ModuleConstantMetadataV9, ModuleMetadataLatest, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV12, ModuleMetadataV9, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV12, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV12, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV12, StorageEntryTypeV9, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV12, StorageHasherV9, StorageMetadataLatest, StorageMetadataV10, StorageMetadataV11, StorageMetadataV12, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
|
||||
import type { DoubleMapTypeLatest, DoubleMapTypeV10, DoubleMapTypeV11, DoubleMapTypeV12, DoubleMapTypeV9, ErrorMetadataLatest, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV12, ErrorMetadataV9, EventMetadataLatest, EventMetadataV10, EventMetadataV11, EventMetadataV12, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, ExtrinsicMetadataV12, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV12, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV12, FunctionMetadataV9, MapTypeLatest, MapTypeV10, MapTypeV11, MapTypeV12, MapTypeV9, MetadataAll, MetadataLatest, MetadataV10, MetadataV11, MetadataV12, MetadataV9, ModuleConstantMetadataLatest, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV12, ModuleConstantMetadataV9, ModuleMetadataLatest, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV12, ModuleMetadataV9, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV12, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV12, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV12, StorageEntryTypeV9, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV12, StorageHasherV9, StorageMetadataLatest, StorageMetadataV10, StorageMetadataV11, StorageMetadataV12, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
|
||||
import type { StorageKind } from '@polkadot/types/interfaces/offchain';
|
||||
import type { DeferredOffenceOf, Kind, OffenceDetails, Offender, OpaqueTimeSlot, ReportIdOf, Reporter } from '@polkadot/types/interfaces/offences';
|
||||
import type { AbridgedCandidateReceipt, AbstractFungible, AbstractNonFungible, AccountId32Junction, AccountIndex64Junction, AccountKey20Junction, AssetInstance, AssignmentId, AssignmentKind, AttestedCandidate, AuctionIndex, AuthorityDiscoveryId, AvailabilityBitfield, AvailabilityBitfieldRecord, BackedCandidate, Balances, Bidder, BufferedSessionChange, CandidateCommitments, CandidateDescriptor, CandidateHash, CandidatePendingAvailability, CandidateReceipt, CollatorId, CollatorSignature, CommittedCandidateReceipt, ConcreteFungible, ConcreteNonFungible, CoreAssignment, CoreIndex, CoreOccupied, DepositAsset, DepositReserveAsset, DoubleVoteReport, DownwardMessage, ExchangeAsset, GlobalValidationSchedule, GroupIndex, HeadData, HostConfiguration, HrmpChannel, HrmpChannelId, HrmpOpenChannelRequest, InboundDownwardMessage, InboundHrmpMessage, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, InitiateReserveWithdraw, InitiateTeleport, Junction, LeasePeriod, LeasePeriodOf, LocalValidationData, MultiAsset, MultiLocation, NetworkId, NewBidder, Order, OriginKind, OutboundHrmpMessage, ParaId, ParaInfo, ParaPastCodeMeta, ParaScheduling, ParachainDispatchOrigin, ParachainProposal, ParathreadClaim, ParathreadClaimQueue, ParathreadEntry, PersistedValidationData, QueryHolding, QueuedParathread, RegisteredParachainInfo, RelayChainBlockNumber, RelayTo, RelayedFrom, Remark, ReserveAssetDeposit, Retriable, Scheduling, SessionInfo, SignedAvailabilityBitfield, SignedAvailabilityBitfields, SigningContext, SlotRange, Statement, SubId, TeleportAsset, Transact, TransientValidationData, UpwardMessage, ValidationCode, ValidationData, ValidationFunctionParams, ValidatorGroup, ValidatorSignature, ValidityAttestation, VersionedMultiAsset, VersionedMultiLocation, VersionedXcm, WinningData, WinningDataEntry, WithdrawAsset, Xcm, XcmError, XcmResult } from '@polkadot/types/interfaces/parachains';
|
||||
@@ -2000,6 +2000,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
DoubleMapTypeLatest: DoubleMapTypeLatest;
|
||||
'Option<DoubleMapTypeLatest>': Option<DoubleMapTypeLatest>;
|
||||
'Vec<DoubleMapTypeLatest>': Vec<DoubleMapTypeLatest>;
|
||||
ErrorMetadataLatest: ErrorMetadataLatest;
|
||||
'Option<ErrorMetadataLatest>': Option<ErrorMetadataLatest>;
|
||||
'Vec<ErrorMetadataLatest>': Vec<ErrorMetadataLatest>;
|
||||
EventMetadataLatest: EventMetadataLatest;
|
||||
'Option<EventMetadataLatest>': Option<EventMetadataLatest>;
|
||||
'Vec<EventMetadataLatest>': Vec<EventMetadataLatest>;
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
|
||||
import type { ChainProperties, DispatchErrorModule, H256 } from '../interfaces/types';
|
||||
import type { CallFunction, Codec, Constructor, InterfaceTypes, RegisteredTypes, Registry, RegistryError, RegistryMetadata, RegistryTypes } from '../types';
|
||||
import type { CallFunction, Codec, Constructor, InterfaceTypes, RegisteredTypes, Registry, RegistryError, RegistryTypes } from '../types';
|
||||
|
||||
// we are attempting to avoid circular refs, hence the Metadata path import
|
||||
import { extrinsicsFromMeta } from '@polkadot/metadata/decorate/extrinsics/fromMetadata';
|
||||
import { decorateExtrinsics } from '@polkadot/metadata/decorate/extrinsics';
|
||||
import { Metadata } from '@polkadot/metadata/Metadata';
|
||||
import { assert, assertReturn, BN_ZERO, formatBalance, isFunction, isString, isU8a, logger, stringCamelCase, u8aToHex } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
@@ -26,7 +26,7 @@ import { getTypeDef } from './getTypeDef';
|
||||
const l = logger('registry');
|
||||
|
||||
// create error mapping from metadata
|
||||
function decorateErrors (_: Registry, metadata: RegistryMetadata, metadataErrors: Record<string, RegistryError>): void {
|
||||
function injectErrors (_: Registry, metadata: Metadata, metadataErrors: Record<string, RegistryError>): void {
|
||||
const modules = metadata.asLatest.modules;
|
||||
const isIndexed = modules.some(({ index }) => !index.eqn(255));
|
||||
|
||||
@@ -51,7 +51,7 @@ function decorateErrors (_: Registry, metadata: RegistryMetadata, metadataErrors
|
||||
}
|
||||
|
||||
// create event classes from metadata
|
||||
function decorateEvents (registry: Registry, metadata: RegistryMetadata, metadataEvents: Record<string, Constructor<GenericEventData>>): void {
|
||||
function injectEvents (registry: Registry, metadata: Metadata, metadataEvents: Record<string, Constructor<GenericEventData>>): void {
|
||||
const modules = metadata.asLatest.modules;
|
||||
const isIndexed = modules.some(({ index }) => !index.eqn(255));
|
||||
|
||||
@@ -87,8 +87,8 @@ function decorateEvents (registry: Registry, metadata: RegistryMetadata, metadat
|
||||
}
|
||||
|
||||
// create extrinsic mapping from metadata
|
||||
function decorateExtrinsics (registry: Registry, metadata: RegistryMetadata, metadataCalls: Record<string, CallFunction>): void {
|
||||
const extrinsics = extrinsicsFromMeta(registry, metadata);
|
||||
function injectExtrinsics (registry: Registry, metadata: Metadata, metadataCalls: Record<string, CallFunction>): void {
|
||||
const extrinsics = decorateExtrinsics(registry, metadata.asLatest);
|
||||
|
||||
// decorate the extrinsics
|
||||
Object.values(extrinsics).forEach((methods): void =>
|
||||
@@ -345,10 +345,10 @@ export class TypeRegistry implements Registry {
|
||||
}
|
||||
|
||||
// sets the metadata
|
||||
public setMetadata (metadata: RegistryMetadata, signedExtensions?: string[]): void {
|
||||
decorateExtrinsics(this, metadata, this.#metadataCalls);
|
||||
decorateErrors(this, metadata, this.#metadataErrors);
|
||||
decorateEvents(this, metadata, this.#metadataEvents);
|
||||
public setMetadata (metadata: Metadata, signedExtensions?: string[]): void {
|
||||
injectExtrinsics(this, metadata, this.#metadataCalls);
|
||||
injectErrors(this, metadata, this.#metadataErrors);
|
||||
injectEvents(this, metadata, this.#metadataEvents);
|
||||
|
||||
// setup the available extensions
|
||||
this.setSignedExtensions(
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { createTestPairs } from '@polkadot/keyring/testingPairs';
|
||||
import { extrinsicsFromMeta, Metadata } from '@polkadot/metadata';
|
||||
import { decorateExtrinsics, Metadata } from '@polkadot/metadata';
|
||||
import rpcMetadata from '@polkadot/metadata/static';
|
||||
|
||||
import { TypeRegistry } from '../../create';
|
||||
@@ -16,7 +16,7 @@ const keyring = createTestPairs({ type: 'ed25519' }, false);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
const tx = extrinsicsFromMeta(registry, metadata);
|
||||
const tx = decorateExtrinsics(registry, metadata.asLatest);
|
||||
|
||||
describe('ExtrinsicV4', (): void => {
|
||||
it.only('constructs a sane Uint8Array (default)', (): void => {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import type { TypeDef } from '../create/types';
|
||||
import type { EventMetadataLatest } from '../interfaces/metadata';
|
||||
import type { EventId } from '../interfaces/system';
|
||||
import type { AnyJson, Constructor, Registry, RegistryMetadataEvent } from '../types';
|
||||
import type { AnyJson, Constructor, Registry } from '../types';
|
||||
|
||||
import { Struct } from '../codec/Struct';
|
||||
import { Tuple } from '../codec/Tuple';
|
||||
@@ -24,10 +24,10 @@ export class GenericEventData extends Tuple {
|
||||
|
||||
readonly #typeDef: TypeDef[];
|
||||
|
||||
constructor (registry: Registry, value: Uint8Array, Types: Constructor[] = [], typeDef: TypeDef[] = [], meta: RegistryMetadataEvent, section = '<unknown>', method = '<unknown>') {
|
||||
constructor (registry: Registry, value: Uint8Array, Types: Constructor[] = [], typeDef: TypeDef[] = [], meta: EventMetadataLatest, section = '<unknown>', method = '<unknown>') {
|
||||
super(registry, Types, value);
|
||||
|
||||
this.#meta = meta as EventMetadataLatest;
|
||||
this.#meta = meta;
|
||||
this.#method = method;
|
||||
this.#section = section;
|
||||
this.#typeDef = typeDef;
|
||||
|
||||
@@ -250,6 +250,7 @@ export default {
|
||||
|
||||
// This always maps to the latest
|
||||
DoubleMapTypeLatest: 'DoubleMapTypeV12',
|
||||
ErrorMetadataLatest: 'ErrorMetadataV12',
|
||||
EventMetadataLatest: 'EventMetadataV12',
|
||||
ExtrinsicMetadataLatest: 'ExtrinsicMetadataV12',
|
||||
FunctionArgumentMetadataLatest: 'FunctionArgumentMetadataV12',
|
||||
|
||||
@@ -36,6 +36,9 @@ export interface DoubleMapTypeV9 extends Struct {
|
||||
readonly key2Hasher: StorageHasherV9;
|
||||
}
|
||||
|
||||
/** @name ErrorMetadataLatest */
|
||||
export interface ErrorMetadataLatest extends ErrorMetadataV12 {}
|
||||
|
||||
/** @name ErrorMetadataV10 */
|
||||
export interface ErrorMetadataV10 extends ErrorMetadataV9 {}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Metadata, storageFromMeta } from '@polkadot/metadata';
|
||||
import { decorateStorage, Metadata } from '@polkadot/metadata';
|
||||
import rpcDataV11 from '@polkadot/metadata/v11/static';
|
||||
|
||||
import { TypeRegistry } from '../create';
|
||||
@@ -15,7 +15,7 @@ describe('StorageKey', (): void => {
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
const query = storageFromMeta(registry, metadata);
|
||||
const query = decorateStorage(registry, metadata.asLatest, metadata.version);
|
||||
|
||||
it('should allow decoding of a DoubleMap key', (): void => {
|
||||
const key = new StorageKey(registry, '0x5f3e4907f716ac89b6347d15ececedca8bde0a0ea8864605e3b68ed9cb2da01b66ccada06515787c10000000e535263148daaf49be5ddb1579b72e84524fc29e78609e3caf42e85aa118ebfe0b0ad404b5bdd25f');
|
||||
|
||||
@@ -15,7 +15,3 @@ export interface CallBase {
|
||||
export interface CallFunction extends CallBase {
|
||||
(...args: any[]): Call;
|
||||
}
|
||||
|
||||
export type Calls = Record<string, CallFunction>;
|
||||
|
||||
export type ModulesWithCalls = Record<string, Calls>;
|
||||
|
||||
@@ -3,9 +3,29 @@
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import type { H256 } from '../interfaces/runtime';
|
||||
import type { AnyJson, BareOpts } from './helpers';
|
||||
import type { Registry } from './registry';
|
||||
|
||||
export type AnyJson = string | number | boolean | null | undefined | AnyJson[] | { [index: string]: AnyJson };
|
||||
|
||||
export type AnyFunction = (...args: any[]) => any;
|
||||
|
||||
export type AnyNumber = BN | BigInt | Uint8Array | number | string;
|
||||
|
||||
export type AnyString = string | string;
|
||||
|
||||
export type AnyU8a = Uint8Array | number[] | string;
|
||||
|
||||
// helper to extract keys from an array
|
||||
export type ArrayElementType<T extends ReadonlyArray<unknown>> = T extends ReadonlyArray<infer ElementType>
|
||||
? ElementType
|
||||
: never;
|
||||
|
||||
export type BareOpts = boolean | Record<string, boolean>;
|
||||
|
||||
export type Callback<T, E = undefined> = E extends Codec
|
||||
? (result: T, extra: E) => void | Promise<void>
|
||||
: (result: T) => void | Promise<void>;
|
||||
|
||||
export type CodecTo = 'toHex' | 'toJSON' | 'toString' | 'toU8a';
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,8 +5,7 @@ import { ExtrinsicStatus } from '../interfaces/author';
|
||||
import { EcdsaSignature, Ed25519Signature, Sr25519Signature } from '../interfaces/extrinsics';
|
||||
import { Address, Balance, Call, H256, Index } from '../interfaces/runtime';
|
||||
import { DispatchError, DispatchInfo, EventRecord } from '../interfaces/system';
|
||||
import { Codec } from './codec';
|
||||
import { AnyJson, AnyNumber, AnyU8a } from './helpers';
|
||||
import { AnyJson, AnyNumber, AnyU8a, Codec } from './codec';
|
||||
import { ICompact, IKeyringPair, IMethod, IRuntimeVersion } from './interfaces';
|
||||
|
||||
export interface ISubmittableResult {
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import type { Codec } from './codec';
|
||||
|
||||
export type AnyFunction = (...args: any[]) => any;
|
||||
|
||||
export type AnyJson = string | number | boolean | null | undefined | AnyJson[] | { [index: string]: AnyJson };
|
||||
|
||||
export type AnyNumber = BN | BigInt | Uint8Array | number | string;
|
||||
|
||||
export type AnyString = string | string;
|
||||
|
||||
export type AnyU8a = Uint8Array | number[] | string;
|
||||
|
||||
// helper to extract keys from an array
|
||||
export type ArrayElementType<T extends ReadonlyArray<unknown>> = T extends ReadonlyArray<infer ElementType>
|
||||
? ElementType
|
||||
: never;
|
||||
|
||||
export type BareOpts = boolean | Record<string, boolean>;
|
||||
|
||||
export type Callback<T, E = undefined> = E extends Codec
|
||||
? (result: T, extra: E) => void | Promise<void>
|
||||
: (result: T) => void | Promise<void>;
|
||||
@@ -9,7 +9,6 @@ export * from './calls';
|
||||
export * from './codec';
|
||||
export * from './definitions';
|
||||
export * from './extrinsic';
|
||||
export * from './helpers';
|
||||
export * from './interfaces';
|
||||
export * from './registry';
|
||||
|
||||
|
||||
@@ -2,15 +2,13 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import type { Metadata } from '@polkadot/metadata';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { H256 } from '../interfaces/runtime';
|
||||
import { ChainProperties } from '../interfaces/system';
|
||||
import { u8 } from '../primitive';
|
||||
import { CallFunction } from './calls';
|
||||
import { Codec, Constructor } from './codec';
|
||||
import { DefinitionRpc, DefinitionRpcSub } from './definitions';
|
||||
import { AnyJson } from './helpers';
|
||||
import type { H256 } from '../interfaces/runtime';
|
||||
import type { ChainProperties } from '../interfaces/system';
|
||||
import type { CallFunction } from './calls';
|
||||
import type { Codec, Constructor } from './codec';
|
||||
import type { DefinitionRpc, DefinitionRpcSub } from './definitions';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface InterfaceTypes { }
|
||||
@@ -28,27 +26,6 @@ export interface ChainUpgrades {
|
||||
|
||||
export type RegistryTypes = Record<string, Constructor | string | Record<string, string> | { _enum: string[] | Record<string, string | null> } | { _set: Record<string, number> }>;
|
||||
|
||||
export interface RegistryMetadataText extends String, Codec {
|
||||
setOverride (override: string): void;
|
||||
}
|
||||
|
||||
export interface RegistryMetadataCallArg {
|
||||
name: RegistryMetadataText;
|
||||
type: RegistryMetadataText;
|
||||
}
|
||||
|
||||
export interface RegistryMetadataCall {
|
||||
args: RegistryMetadataCallArg[];
|
||||
name: RegistryMetadataText;
|
||||
|
||||
toJSON (): AnyJson;
|
||||
}
|
||||
|
||||
export interface RegistryMetadataCalls {
|
||||
isSome: boolean;
|
||||
unwrap (): RegistryMetadataCall[];
|
||||
}
|
||||
|
||||
export interface RegistryError {
|
||||
documentation: string[];
|
||||
index: number;
|
||||
@@ -56,46 +33,6 @@ export interface RegistryError {
|
||||
section: string;
|
||||
}
|
||||
|
||||
export interface RegistryMetadataError {
|
||||
name: RegistryMetadataText;
|
||||
documentation: RegistryMetadataText[];
|
||||
}
|
||||
|
||||
export type RegistryMetadataErrors = RegistryMetadataError[];
|
||||
|
||||
export interface RegistryMetadataEvent {
|
||||
args: any[];
|
||||
name: RegistryMetadataText;
|
||||
}
|
||||
|
||||
export interface RegistryMetadataEvents {
|
||||
isSome: boolean;
|
||||
unwrap (): RegistryMetadataEvent[];
|
||||
}
|
||||
|
||||
export interface RegistryMetadataExtrinsic {
|
||||
version: BN;
|
||||
signedExtensions: RegistryMetadataText[];
|
||||
}
|
||||
|
||||
export interface RegistryMetadataModule {
|
||||
calls: RegistryMetadataCalls;
|
||||
errors: RegistryMetadataErrors;
|
||||
events: RegistryMetadataEvents;
|
||||
index: u8;
|
||||
name: RegistryMetadataText;
|
||||
}
|
||||
|
||||
export interface RegistryMetadataLatest {
|
||||
modules: RegistryMetadataModule[];
|
||||
extrinsic: RegistryMetadataExtrinsic;
|
||||
}
|
||||
|
||||
export interface RegistryMetadata {
|
||||
asLatest: RegistryMetadataLatest;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface OverrideVersionedType {
|
||||
minmax: [number?, number?]; // min (v >= min) and max (v <= max)
|
||||
types: RegistryTypes;
|
||||
@@ -174,6 +111,6 @@ export interface Registry {
|
||||
register (arg1: string | Constructor | RegistryTypes, arg2?: Constructor): void;
|
||||
setChainProperties (properties?: ChainProperties): void;
|
||||
setHasher (hasher?: (data: Uint8Array) => Uint8Array): void;
|
||||
setMetadata (metadata: RegistryMetadata, signedExtensions?: string[]): void;
|
||||
setMetadata (metadata: Metadata, signedExtensions?: string[]): void;
|
||||
setSignedExtensions (signedExtensions?: string[]): void;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user