Add runtime decoration defaults (#4993)
* Add runtime decoration defaults * Default exports * Additional * hash + version
This commit is contained in:
@@ -7,4 +7,5 @@ import './errors';
|
||||
import './events';
|
||||
import './query';
|
||||
import './registry';
|
||||
import './runtime';
|
||||
import './tx';
|
||||
|
||||
@@ -5,15 +5,18 @@ import type { ApiTypes } from '@polkadot/api-base/types';
|
||||
import type { Bytes, Option, Vec, u32 } from '@polkadot/types-codec';
|
||||
import type { AnyNumber, ITuple } from '@polkadot/types-codec/types';
|
||||
import type { BabeGenesisConfiguration, Epoch, OpaqueKeyOwnershipProof } from '@polkadot/types/interfaces/babe';
|
||||
import type { ValidatorSet } from '@polkadot/types/interfaces/beefy';
|
||||
import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
|
||||
import type { AuthorityList, SetId } from '@polkadot/types/interfaces/grandpa';
|
||||
import type { OpaqueMetadata } from '@polkadot/types/interfaces/metadata';
|
||||
import type { FeeDetails, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
|
||||
import type { AccountId, Index, KeyTypeId, Slot } from '@polkadot/types/interfaces/runtime';
|
||||
import type { RuntimeVersion } from '@polkadot/types/interfaces/state';
|
||||
import type { Observable } from '@polkadot/types/types';
|
||||
|
||||
declare module '@polkadot/api-base/types/calls' {
|
||||
export interface AugmentedCalls<ApiType extends ApiTypes> {
|
||||
/** 0xbc9d89904f5b923f/1 */
|
||||
accountNonceApi: {
|
||||
/**
|
||||
* The API to query account nonce (aka transaction index)
|
||||
@@ -24,6 +27,18 @@ declare module '@polkadot/api-base/types/calls' {
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0x687ad44ad37f03c2/1 */
|
||||
authorityDiscoveryApi: {
|
||||
/**
|
||||
* Retrieve authority identifiers of the current and next authority set.
|
||||
**/
|
||||
authorities: AugmentedCall<ApiType, () => Observable<Vec<AuthorityId>>>;
|
||||
/**
|
||||
* Generic call
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0xcbca25e39f142387/2 */
|
||||
babeApi: {
|
||||
/**
|
||||
* Return the genesis configuration for BABE. The configuration is only read on genesis.
|
||||
@@ -50,6 +65,29 @@ declare module '@polkadot/api-base/types/calls' {
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0x49eaaf1b548a0cb0/1 */
|
||||
beefyApi: {
|
||||
/**
|
||||
* Return the current active BEEFY validator set
|
||||
**/
|
||||
validatorSet: AugmentedCall<ApiType, () => Observable<Option<ValidatorSet>>>;
|
||||
/**
|
||||
* Generic call
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0xdf6acb689907609b/4 */
|
||||
core: {
|
||||
/**
|
||||
* Returns the version of the runtime.
|
||||
**/
|
||||
version: AugmentedCall<ApiType, () => Observable<RuntimeVersion>>;
|
||||
/**
|
||||
* Generic call
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0xed99c5acb25eedf5/3 */
|
||||
grandpaApi: {
|
||||
/**
|
||||
* Get current GRANDPA authority set id.
|
||||
@@ -64,6 +102,7 @@ declare module '@polkadot/api-base/types/calls' {
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0x37e397fc7c91f5e4/1 */
|
||||
metadata: {
|
||||
/**
|
||||
* Returns the metadata of a runtime
|
||||
@@ -74,6 +113,7 @@ declare module '@polkadot/api-base/types/calls' {
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0xab3c0572291feb8b/1 */
|
||||
sessionKeys: {
|
||||
/**
|
||||
* Decode the given public session keys.
|
||||
@@ -88,6 +128,7 @@ declare module '@polkadot/api-base/types/calls' {
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0x37c8bb1350a9a2a8/1 */
|
||||
transactionPaymentApi: {
|
||||
/**
|
||||
* The transaction fee details
|
||||
|
||||
@@ -7,4 +7,5 @@ import './errors';
|
||||
import './events';
|
||||
import './query';
|
||||
import './registry';
|
||||
import './runtime';
|
||||
import './tx';
|
||||
|
||||
@@ -5,15 +5,18 @@ import type { ApiTypes } from '@polkadot/api-base/types';
|
||||
import type { Bytes, Option, Vec, u32 } from '@polkadot/types-codec';
|
||||
import type { AnyNumber, ITuple } from '@polkadot/types-codec/types';
|
||||
import type { BabeGenesisConfiguration, Epoch, OpaqueKeyOwnershipProof } from '@polkadot/types/interfaces/babe';
|
||||
import type { ValidatorSet } from '@polkadot/types/interfaces/beefy';
|
||||
import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
|
||||
import type { AuthorityList, SetId } from '@polkadot/types/interfaces/grandpa';
|
||||
import type { OpaqueMetadata } from '@polkadot/types/interfaces/metadata';
|
||||
import type { FeeDetails, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
|
||||
import type { AccountId, Index, KeyTypeId, Slot } from '@polkadot/types/interfaces/runtime';
|
||||
import type { RuntimeVersion } from '@polkadot/types/interfaces/state';
|
||||
import type { Observable } from '@polkadot/types/types';
|
||||
|
||||
declare module '@polkadot/api-base/types/calls' {
|
||||
export interface AugmentedCalls<ApiType extends ApiTypes> {
|
||||
/** 0xbc9d89904f5b923f/1 */
|
||||
accountNonceApi: {
|
||||
/**
|
||||
* The API to query account nonce (aka transaction index)
|
||||
@@ -24,6 +27,18 @@ declare module '@polkadot/api-base/types/calls' {
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0x687ad44ad37f03c2/1 */
|
||||
authorityDiscoveryApi: {
|
||||
/**
|
||||
* Retrieve authority identifiers of the current and next authority set.
|
||||
**/
|
||||
authorities: AugmentedCall<ApiType, () => Observable<Vec<AuthorityId>>>;
|
||||
/**
|
||||
* Generic call
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0xcbca25e39f142387/2 */
|
||||
babeApi: {
|
||||
/**
|
||||
* Return the genesis configuration for BABE. The configuration is only read on genesis.
|
||||
@@ -50,6 +65,29 @@ declare module '@polkadot/api-base/types/calls' {
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0x49eaaf1b548a0cb0/1 */
|
||||
beefyApi: {
|
||||
/**
|
||||
* Return the current active BEEFY validator set
|
||||
**/
|
||||
validatorSet: AugmentedCall<ApiType, () => Observable<Option<ValidatorSet>>>;
|
||||
/**
|
||||
* Generic call
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0xdf6acb689907609b/4 */
|
||||
core: {
|
||||
/**
|
||||
* Returns the version of the runtime.
|
||||
**/
|
||||
version: AugmentedCall<ApiType, () => Observable<RuntimeVersion>>;
|
||||
/**
|
||||
* Generic call
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0xed99c5acb25eedf5/3 */
|
||||
grandpaApi: {
|
||||
/**
|
||||
* Get current GRANDPA authority set id.
|
||||
@@ -64,6 +102,7 @@ declare module '@polkadot/api-base/types/calls' {
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0x37e397fc7c91f5e4/1 */
|
||||
metadata: {
|
||||
/**
|
||||
* Returns the metadata of a runtime
|
||||
@@ -74,6 +113,7 @@ declare module '@polkadot/api-base/types/calls' {
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0xab3c0572291feb8b/1 */
|
||||
sessionKeys: {
|
||||
/**
|
||||
* Decode the given public session keys.
|
||||
@@ -88,6 +128,7 @@ declare module '@polkadot/api-base/types/calls' {
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0x37c8bb1350a9a2a8/1 */
|
||||
transactionPaymentApi: {
|
||||
/**
|
||||
* The transaction fee details
|
||||
|
||||
@@ -7,4 +7,5 @@ import './errors';
|
||||
import './events';
|
||||
import './query';
|
||||
import './registry';
|
||||
import './runtime';
|
||||
import './tx';
|
||||
|
||||
@@ -11,10 +11,12 @@ import type { AuthorityList, SetId } from '@polkadot/types/interfaces/grandpa';
|
||||
import type { OpaqueMetadata } from '@polkadot/types/interfaces/metadata';
|
||||
import type { FeeDetails, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
|
||||
import type { AccountId, Balance, Index, KeyTypeId, Slot } from '@polkadot/types/interfaces/runtime';
|
||||
import type { RuntimeVersion } from '@polkadot/types/interfaces/state';
|
||||
import type { Observable } from '@polkadot/types/types';
|
||||
|
||||
declare module '@polkadot/api-base/types/calls' {
|
||||
export interface AugmentedCalls<ApiType extends ApiTypes> {
|
||||
/** 0xbc9d89904f5b923f/1 */
|
||||
accountNonceApi: {
|
||||
/**
|
||||
* The API to query account nonce (aka transaction index)
|
||||
@@ -25,6 +27,18 @@ declare module '@polkadot/api-base/types/calls' {
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0x687ad44ad37f03c2/1 */
|
||||
authorityDiscoveryApi: {
|
||||
/**
|
||||
* Retrieve authority identifiers of the current and next authority set.
|
||||
**/
|
||||
authorities: AugmentedCall<ApiType, () => Observable<Vec<AuthorityId>>>;
|
||||
/**
|
||||
* Generic call
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0xcbca25e39f142387/2 */
|
||||
babeApi: {
|
||||
/**
|
||||
* Return the genesis configuration for BABE. The configuration is only read on genesis.
|
||||
@@ -51,6 +65,7 @@ declare module '@polkadot/api-base/types/calls' {
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0x68b66ba122c93fa7/1 */
|
||||
contractsApi: {
|
||||
/**
|
||||
* Perform a call from a specified account to a given contract.
|
||||
@@ -73,6 +88,18 @@ declare module '@polkadot/api-base/types/calls' {
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0xdf6acb689907609b/4 */
|
||||
core: {
|
||||
/**
|
||||
* Returns the version of the runtime.
|
||||
**/
|
||||
version: AugmentedCall<ApiType, () => Observable<RuntimeVersion>>;
|
||||
/**
|
||||
* Generic call
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0xed99c5acb25eedf5/3 */
|
||||
grandpaApi: {
|
||||
/**
|
||||
* Get current GRANDPA authority set id.
|
||||
@@ -87,6 +114,7 @@ declare module '@polkadot/api-base/types/calls' {
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0x37e397fc7c91f5e4/1 */
|
||||
metadata: {
|
||||
/**
|
||||
* Returns the metadata of a runtime
|
||||
@@ -97,6 +125,7 @@ declare module '@polkadot/api-base/types/calls' {
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0xab3c0572291feb8b/1 */
|
||||
sessionKeys: {
|
||||
/**
|
||||
* Decode the given public session keys.
|
||||
@@ -111,6 +140,7 @@ declare module '@polkadot/api-base/types/calls' {
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0x37c8bb1350a9a2a8/1 */
|
||||
transactionPaymentApi: {
|
||||
/**
|
||||
* The transaction fee details
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { AnyFunction, Codec, DefinitionCall } from '@polkadot/types/types';
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { ApiTypes, ReturnCodec } from './base';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/no-empty-interface
|
||||
@@ -32,6 +33,6 @@ export interface DefinitionCallNamed extends DefinitionCall {
|
||||
method: string;
|
||||
name: string;
|
||||
section: string;
|
||||
sectionHash: Uint8Array;
|
||||
sectionHash: HexString;
|
||||
version: number;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ import type { Option, Raw, StorageKey, Text, u64 } from '@polkadot/types';
|
||||
import type { Call, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import type { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
|
||||
import type { StorageEntry } from '@polkadot/types/primitive/types';
|
||||
import type { AnyFunction, AnyTuple, CallFunction, Codec, DefinitionRpc, DefinitionRpcSub, DetectCodec, IMethod, IStorageKey, Registry, RegistryError, RegistryTypes } from '@polkadot/types/types';
|
||||
import type { AnyFunction, AnyTuple, CallFunction, Codec, DefinitionRpc, DefinitionRpcSub, Definitions, DefinitionsCall, DetectCodec, IMethod, IStorageKey, Registry, RegistryError, RegistryTypes } from '@polkadot/types/types';
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { SubmittableExtrinsic } from '../submittable/types';
|
||||
import type { ApiDecoration, ApiInterfaceRx, ApiOptions, ApiTypes, AugmentedQuery, DecoratedErrors, DecoratedEvents, DecoratedRpc, DecorateMethod, GenericStorageEntryFunction, PaginationOptions, QueryableConsts, QueryableStorage, QueryableStorageEntry, QueryableStorageEntryAt, QueryableStorageMulti, QueryableStorageMultiArg, SubmittableExtrinsicFunction, SubmittableExtrinsics } from '../types';
|
||||
import type { VersionedRegistry } from './types';
|
||||
@@ -18,9 +19,9 @@ import { BehaviorSubject, combineLatest, from, map, of, switchMap, tap, toArray
|
||||
import { getAvailableDerives } from '@polkadot/api-derive';
|
||||
import { memo, RpcCore } from '@polkadot/rpc-core';
|
||||
import { WsProvider } from '@polkadot/rpc-provider';
|
||||
import { expandMetadata, Metadata, TypeRegistry, unwrapStorageType } from '@polkadot/types';
|
||||
import { expandMetadata, Metadata, typeDefinitions, TypeRegistry, unwrapStorageType } from '@polkadot/types';
|
||||
import { arrayChunk, arrayFlatten, assert, assertReturn, BN, compactStripLength, lazyMethod, lazyMethods, logger, nextTick, objectSpread, stringCamelCase, u8aConcatStrict, u8aToHex } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
import { blake2AsHex } from '@polkadot/util-crypto';
|
||||
|
||||
import { createSubmittable } from '../submittable';
|
||||
import { augmentObject } from '../util/augmentObject';
|
||||
@@ -413,48 +414,88 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
return out as DecoratedRpc<ApiType, RpcInterface>;
|
||||
}
|
||||
|
||||
// extract all runtime definitions
|
||||
protected _getRuntimeDefs (): DefinitionsCall {
|
||||
const result = objectSpread<DefinitionsCall>({}, this._options.runtime);
|
||||
const defValues = Object.values(typeDefinitions) as Definitions[];
|
||||
|
||||
for (let i = 0; i < defValues.length; i++) {
|
||||
const rt = defValues[i].runtime;
|
||||
|
||||
if (rt) {
|
||||
const apiEntries = Object.entries(rt);
|
||||
|
||||
for (let j = 0; j < apiEntries.length; j++) {
|
||||
const [key, defs] = apiEntries[j];
|
||||
|
||||
if (!result[key]) {
|
||||
// we don't have this runtime definition, add it
|
||||
result[key] = defs;
|
||||
} else {
|
||||
for (let k = 0; k < defs.length; k++) {
|
||||
const def = defs[k];
|
||||
|
||||
if (!result[key].some(({ version }) => def.version === version)) {
|
||||
// we don't have this specific version, add it
|
||||
result[key].push(def);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// pre-metadata decoration
|
||||
protected _decorateCalls<ApiType extends ApiTypes> ({ registry, runtimeVersion: { apis } }: VersionedRegistry<ApiType>, decorateMethod: DecorateMethod<ApiType>, blockHash?: Uint8Array | string | null): QueryableCalls<ApiType> {
|
||||
const result = {} as QueryableCalls<ApiType>;
|
||||
|
||||
if (!this._options.runtime) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const named: Record<string, Record<string, DefinitionCallNamed>> = {};
|
||||
const sections = Object.entries(this._options.runtime);
|
||||
const sections = Object.entries(this._getRuntimeDefs());
|
||||
const hashes: HexString[] = [];
|
||||
|
||||
for (let i = 0; i < sections.length; i++) {
|
||||
const [_section, secs] = sections[i];
|
||||
const sectionHash = blake2AsU8a(_section, 64);
|
||||
const sectionHash = blake2AsHex(_section, 64);
|
||||
const rtApi = apis.find(([a]) => a.eq(sectionHash));
|
||||
|
||||
hashes.push(sectionHash);
|
||||
|
||||
if (rtApi) {
|
||||
const sec = secs.find(({ version = 1 }) => rtApi[1].eq(version));
|
||||
const sec = secs.find(({ version }) => rtApi[1].eq(version));
|
||||
|
||||
if (sec) {
|
||||
const section = stringCamelCase(_section);
|
||||
|
||||
if (!named[section]) {
|
||||
named[section] = {};
|
||||
}
|
||||
|
||||
const methods = Object.entries(sec.methods);
|
||||
|
||||
for (let m = 0; m < methods.length; m++) {
|
||||
const [_method, def] = methods[m];
|
||||
const method = stringCamelCase(_method);
|
||||
if (methods.length) {
|
||||
if (!named[section]) {
|
||||
named[section] = {};
|
||||
}
|
||||
|
||||
named[section][method] = objectSpread({ method, name: `${_section}_${_method}`, section, sectionHash, version: 1 }, def);
|
||||
for (let m = 0; m < methods.length; m++) {
|
||||
const [_method, def] = methods[m];
|
||||
const method = stringCamelCase(_method);
|
||||
|
||||
named[section][method] = objectSpread({ method, name: `${_section}_${_method}`, section, sectionHash }, def);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
l.warn(`Not decorating runtime ${_section}, unable to find version ${rtApi[1].toString()}`);
|
||||
}
|
||||
} else {
|
||||
l.warn(`Not decorating runtime ${_section}, not found in available apis`);
|
||||
}
|
||||
}
|
||||
|
||||
// find the runtimes that we don't have hashes for
|
||||
const notFound = apis
|
||||
.filter(([a]) => !hashes.includes(a.toHex()))
|
||||
.map(([a, v]) => `${a.toHex()}/${v.toString()}`);
|
||||
|
||||
if (notFound.length) {
|
||||
l.warn(`Not decorating runtime apis ${notFound.join(', ')}`);
|
||||
}
|
||||
|
||||
const stateCall = blockHash
|
||||
? (name: string, bytes: Uint8Array) => this._rpcCore.state.call(name, bytes, blockHash)
|
||||
: (name: string, bytes: Uint8Array) => this._rpcCore.state.call(name, bytes);
|
||||
|
||||
@@ -54,7 +54,7 @@ function generate (metaHex: HexString, version: Version | null, pkg: string | un
|
||||
[
|
||||
HEADER('chain'),
|
||||
...[
|
||||
...['consts', 'errors', 'events', 'query', 'tx', 'rpc']
|
||||
...['consts', 'errors', 'events', 'query', 'tx', 'rpc', 'runtime']
|
||||
.filter((key) => !!key)
|
||||
.map((key) => `./augment-api-${key}`)
|
||||
].map((path) => `import '${path}';\n`)
|
||||
|
||||
@@ -33,11 +33,11 @@ function getDefs (apis: Apis | null, defs: Record<string, Definitions>): Record<
|
||||
|
||||
for (let i = 0; i < sections.length; i++) {
|
||||
const [_section, sec] = sections[i];
|
||||
const apiHash = blake2AsHex(_section, 64);
|
||||
const api = apis && apis.find(([h]) => h === apiHash);
|
||||
const sectionHash = blake2AsHex(_section, 64);
|
||||
const api = apis && apis.find(([h]) => h === sectionHash);
|
||||
|
||||
if (api) {
|
||||
const ver = sec.find(({ version = 1 }) => version === api[1]);
|
||||
const ver = sec.find(({ version }) => version === api[1]);
|
||||
|
||||
if (ver) {
|
||||
const methods = Object.entries(ver.methods);
|
||||
@@ -53,7 +53,7 @@ function getDefs (apis: Apis | null, defs: Record<string, Definitions>): Record<
|
||||
const [_method, def] = methods[m];
|
||||
const method = stringCamelCase(_method);
|
||||
|
||||
named[section][method] = objectSpread({ method, name: `${_section}_${method}`, section }, def);
|
||||
named[section][method] = objectSpread({ method, name: `${_section}_${method}`, section, sectionHash, version: ver.version }, def);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -107,15 +107,21 @@ export function generateCallTypes (registry: TypeRegistry, dest: string, apis: A
|
||||
args: args.join(', '),
|
||||
docs: [def.description],
|
||||
name: methodName,
|
||||
sectionHash: def.sectionHash,
|
||||
sectionName: def.section,
|
||||
sectionVersion: def.version,
|
||||
type: formatType(registry, allDefs, def.type, imports)
|
||||
};
|
||||
}).sort((a, b) => a.name.localeCompare(b.name));
|
||||
|
||||
return {
|
||||
items: allMethods,
|
||||
name: section || 'unknown'
|
||||
name: section || 'unknown',
|
||||
sectionHash: allMethods.length && allMethods[0].sectionHash,
|
||||
sectionName: allMethods.length && allMethods[0].sectionName,
|
||||
sectionVersion: allMethods.length && allMethods[0].sectionVersion
|
||||
};
|
||||
}).sort((a, b) => a.name.localeCompare(b.name));
|
||||
}).filter(({ items }) => items.length).sort((a, b) => a.name.localeCompare(b.name));
|
||||
|
||||
if (modules.length) {
|
||||
imports.typesTypes.Observable = true;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
declare module '@polkadot/api-base/types/calls' {
|
||||
export interface AugmentedCalls<ApiType extends ApiTypes> {
|
||||
{{#each modules}}
|
||||
/** {{{sectionHash}}}/{{{sectionVersion}}} */
|
||||
{{{name}}}: {
|
||||
{{#each items}}
|
||||
{{> docs}}
|
||||
|
||||
@@ -10,7 +10,7 @@ import type { ExtrinsicOrHash, ExtrinsicStatus } from '@polkadot/types/interface
|
||||
import type { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
|
||||
import type { AllowedSlots, BabeAuthorityWeight, BabeBlockWeight, BabeEpochConfiguration, BabeEquivocationProof, BabeGenesisConfiguration, BabeGenesisConfigurationV1, BabeWeight, Epoch, EpochAuthorship, MaybeRandomness, MaybeVrf, NextConfigDescriptor, NextConfigDescriptorV1, OpaqueKeyOwnershipProof, Randomness, RawBabePreDigest, RawBabePreDigestCompat, RawBabePreDigestPrimary, RawBabePreDigestPrimaryTo159, RawBabePreDigestSecondaryPlain, RawBabePreDigestSecondaryTo159, RawBabePreDigestSecondaryVRF, RawBabePreDigestTo159, SlotNumber, VrfData, VrfOutput, VrfProof } from '@polkadot/types/interfaces/babe';
|
||||
import type { AccountData, BalanceLock, BalanceLockTo212, BalanceStatus, Reasons, ReserveData, ReserveIdentifier, VestingSchedule, WithdrawReasons } from '@polkadot/types/interfaces/balances';
|
||||
import type { BeefyAuthoritySet, BeefyCommitment, BeefyId, BeefyNextAuthoritySet, BeefyPayload, BeefyPayloadId, BeefySignedCommitment, MmrRootHash, ValidatorSetId } from '@polkadot/types/interfaces/beefy';
|
||||
import type { BeefyAuthoritySet, BeefyCommitment, BeefyId, BeefyNextAuthoritySet, BeefyPayload, BeefyPayloadId, BeefySignedCommitment, MmrRootHash, ValidatorSet, ValidatorSetId } from '@polkadot/types/interfaces/beefy';
|
||||
import type { BridgeMessageId, BridgedBlockHash, BridgedBlockNumber, BridgedHeader, CallOrigin, ChainId, DeliveredMessages, DispatchFeePayment, InboundLaneData, InboundRelayer, InitializationData, LaneId, MessageData, MessageKey, MessageNonce, MessagesDeliveryProofOf, MessagesProofOf, OperatingMode, OutboundLaneData, OutboundMessageFee, OutboundPayload, Parameter, RelayerId, UnrewardedRelayer, UnrewardedRelayersState } from '@polkadot/types/interfaces/bridges';
|
||||
import type { BlockHash } from '@polkadot/types/interfaces/chain';
|
||||
import type { PrefixedStorageKey } from '@polkadot/types/interfaces/childstate';
|
||||
@@ -1059,6 +1059,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
ValidatorPrefsTo196: ValidatorPrefsTo196;
|
||||
ValidatorPrefsWithBlocked: ValidatorPrefsWithBlocked;
|
||||
ValidatorPrefsWithCommission: ValidatorPrefsWithCommission;
|
||||
ValidatorSet: ValidatorSet;
|
||||
ValidatorSetId: ValidatorSetId;
|
||||
ValidatorSignature: ValidatorSignature;
|
||||
ValidDisputeStatementKind: ValidDisputeStatementKind;
|
||||
|
||||
@@ -17,7 +17,8 @@ export const runtime: DefinitionsCall = {
|
||||
params: [],
|
||||
type: 'SlotDuration'
|
||||
}
|
||||
}
|
||||
},
|
||||
version: 1
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
@@ -35,7 +35,7 @@ const V1_V2_SHARED: Record<string, DefinitionCall> = {
|
||||
params: [],
|
||||
type: 'Epoch'
|
||||
}
|
||||
// TDODO Add submit_report_equivocation_unsigned_extrinsic
|
||||
// TODO Add submit_report_equivocation_unsigned_extrinsic
|
||||
};
|
||||
|
||||
export const runtime: DefinitionsCall = {
|
||||
|
||||
@@ -36,6 +36,10 @@ export default {
|
||||
BeefyPayload: 'Vec<(BeefyPayloadId, Bytes)>',
|
||||
BeefyPayloadId: '[u8;2]',
|
||||
MmrRootHash: 'H256',
|
||||
ValidatorSetId: 'u64'
|
||||
ValidatorSetId: 'u64',
|
||||
ValidatorSet: {
|
||||
validators: 'Vec<AuthorityId>',
|
||||
id: 'ValidatorSetId'
|
||||
}
|
||||
}
|
||||
} as Definitions;
|
||||
|
||||
@@ -4,6 +4,18 @@
|
||||
import type { DefinitionsCall } from '../../types';
|
||||
|
||||
export const runtime: DefinitionsCall = {
|
||||
BeefyApi: [
|
||||
{
|
||||
methods: {
|
||||
validator_set: {
|
||||
description: 'Return the current active BEEFY validator set',
|
||||
params: [],
|
||||
type: 'Option<ValidatorSet>'
|
||||
}
|
||||
},
|
||||
version: 1
|
||||
}
|
||||
],
|
||||
BeefyMmrApi: [
|
||||
{
|
||||
methods: {
|
||||
@@ -17,7 +29,8 @@ export const runtime: DefinitionsCall = {
|
||||
params: [],
|
||||
type: 'BeefyNextAuthoritySet'
|
||||
}
|
||||
}
|
||||
},
|
||||
version: 1
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
import type { Bytes, Option, Struct, U8aFixed, Vec, u32, u64 } from '@polkadot/types-codec';
|
||||
import type { ITuple } from '@polkadot/types-codec/types';
|
||||
import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
|
||||
import type { EcdsaSignature } from '@polkadot/types/interfaces/extrinsics';
|
||||
import type { BlockNumber, H256 } from '@polkadot/types/interfaces/runtime';
|
||||
|
||||
@@ -45,6 +46,12 @@ export interface BeefySignedCommitment extends Struct {
|
||||
/** @name MmrRootHash */
|
||||
export interface MmrRootHash extends H256 {}
|
||||
|
||||
/** @name ValidatorSet */
|
||||
export interface ValidatorSet extends Struct {
|
||||
readonly validators: Vec<AuthorityId>;
|
||||
readonly id: ValidatorSetId;
|
||||
}
|
||||
|
||||
/** @name ValidatorSetId */
|
||||
export interface ValidatorSetId extends u64 {}
|
||||
|
||||
|
||||
@@ -103,7 +103,8 @@ export const runtime: DefinitionsCall = {
|
||||
],
|
||||
type: 'CodeUploadResult'
|
||||
}
|
||||
}
|
||||
},
|
||||
version: 1
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
@@ -15,6 +15,7 @@ export { default as consensus } from './consensus/definitions';
|
||||
export { default as contracts } from './contracts/definitions';
|
||||
export { default as democracy } from './democracy/definitions';
|
||||
export { default as dev } from './dev/definitions';
|
||||
export { default as discovery } from './discovery/definitions';
|
||||
export { default as elections } from './elections/definitions';
|
||||
export { default as engine } from './engine/definitions';
|
||||
export { default as evm } from './evm/definitions';
|
||||
@@ -48,6 +49,7 @@ export { default as bridges } from './bridges/definitions';
|
||||
export { default as claims } from './claims/definitions';
|
||||
export { default as crowdloan } from './crowdloan/definitions';
|
||||
export { default as cumulus } from './cumulus/definitions';
|
||||
export { default as finality } from './finality/definitions';
|
||||
export { default as parachains } from './parachains/definitions';
|
||||
export { default as poll } from './poll/definitions';
|
||||
export { default as purchase } from './purchase/definitions';
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright 2017-2022 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types';
|
||||
|
||||
import { runtime } from './runtime';
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
runtime,
|
||||
types: {}
|
||||
} as Definitions;
|
||||
@@ -0,0 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable */
|
||||
|
||||
export * from './types';
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright 2017-2022 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { DefinitionsCall } from '../../types';
|
||||
|
||||
export const runtime: DefinitionsCall = {
|
||||
AuthorityDiscoveryApi: [
|
||||
{
|
||||
methods: {
|
||||
authorities: {
|
||||
description: 'Retrieve authority identifiers of the current and next authority set.',
|
||||
params: [],
|
||||
type: 'Vec<AuthorityId>'
|
||||
}
|
||||
},
|
||||
version: 1
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable */
|
||||
|
||||
export type PHANTOM_DISCOVERY = 'discovery';
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright 2017-2022 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types';
|
||||
|
||||
import { runtime } from './runtime';
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
runtime,
|
||||
types: {}
|
||||
} as Definitions;
|
||||
@@ -0,0 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable */
|
||||
|
||||
export * from './types';
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright 2017-2022 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { DefinitionsCall } from '../../types';
|
||||
|
||||
// implemented by chains bridging into the relay, not the relay itself
|
||||
const finalityV1 = {
|
||||
methods: {
|
||||
best_finalized: {
|
||||
description: 'Returns number and hash of the best finalized header known to the bridge module.',
|
||||
params: [],
|
||||
type: '(BlockNumber, Hash)'
|
||||
}
|
||||
},
|
||||
version: 1
|
||||
};
|
||||
|
||||
export const runtime: DefinitionsCall = {
|
||||
KusamaFinalityApi: [finalityV1],
|
||||
PolkadotFinalityApi: [finalityV1],
|
||||
RococoFinalityApi: [finalityV1],
|
||||
WestendFinalityApi: [finalityV1]
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable */
|
||||
|
||||
export type PHANTOM_FINALITY = 'finality';
|
||||
@@ -17,6 +17,7 @@ export const runtime: DefinitionsCall = {
|
||||
params: [],
|
||||
type: 'AuthorityList'
|
||||
}
|
||||
// TODO submit_report_equivocation_unsigned_extrinsic, generate_key_ownership_proof
|
||||
},
|
||||
version: 3
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ export const runtime: DefinitionsCall = {
|
||||
params: [],
|
||||
type: 'OpaqueMetadata'
|
||||
}
|
||||
}
|
||||
},
|
||||
version: 1
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
@@ -35,7 +35,8 @@ export const runtime: DefinitionsCall = {
|
||||
],
|
||||
type: 'RuntimeDispatchInfo'
|
||||
}
|
||||
}
|
||||
},
|
||||
version: 1
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
@@ -8,6 +8,8 @@ import type { Definitions } from '../../types';
|
||||
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
import { runtime } from './runtime';
|
||||
|
||||
const numberTypes = {
|
||||
Fixed64: 'Int<64, Fixed64>',
|
||||
FixedI64: 'Int<64, FixedI64>',
|
||||
@@ -47,6 +49,7 @@ export const knownOrigins: Record<string, string> = {
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
runtime,
|
||||
types: objectSpread({}, numberTypes, {
|
||||
AccountId: 'AccountId32',
|
||||
AccountId20: 'GenericEthereumAccountId',
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright 2017-2022 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { DefinitionsCall } from '../../types';
|
||||
|
||||
export const runtime: DefinitionsCall = {
|
||||
Core: [
|
||||
{
|
||||
methods: {
|
||||
version: {
|
||||
description: 'Returns the version of the runtime.',
|
||||
params: [],
|
||||
type: 'RuntimeVersion'
|
||||
}
|
||||
},
|
||||
version: 4
|
||||
// TODO Add execute_block & initialize_block
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -27,7 +27,8 @@ export const runtime: DefinitionsCall = {
|
||||
],
|
||||
type: 'Bytes'
|
||||
}
|
||||
}
|
||||
},
|
||||
version: 1
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
@@ -17,7 +17,8 @@ export const runtime: DefinitionsCall = {
|
||||
],
|
||||
type: 'Index'
|
||||
}
|
||||
}
|
||||
},
|
||||
version: 1
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
@@ -21,11 +21,13 @@ export * from './crowdloan/types';
|
||||
export * from './cumulus/types';
|
||||
export * from './democracy/types';
|
||||
export * from './dev/types';
|
||||
export * from './discovery/types';
|
||||
export * from './elections/types';
|
||||
export * from './engine/types';
|
||||
export * from './eth/types';
|
||||
export * from './evm/types';
|
||||
export * from './extrinsics/types';
|
||||
export * from './finality/types';
|
||||
export * from './genericAsset/types';
|
||||
export * from './gilt/types';
|
||||
export * from './grandpa/types';
|
||||
|
||||
@@ -61,7 +61,7 @@ export type DefinitionsRpc = Record<string, DefinitionRpc | DefinitionRpcSub>;
|
||||
|
||||
export type DefinitionsCall = Record<string, {
|
||||
methods: Record<string, DefinitionCall>;
|
||||
version?: number;
|
||||
version: number;
|
||||
}[]>;
|
||||
|
||||
export type DefinitionsTypes = Record<string, DefinitionType>;
|
||||
|
||||
Reference in New Issue
Block a user