Basic/configurable no-metadata state_call interfaces (#4987)

* Basic/configurable no-metadata state_call interfaces

* Decorate on a per-section/method basis

* Expose metadata

* Adjust

* s/calls/runtime/

* Adjust

* Adjust

* Adjust for AugmentedCall

* Adjust base type exports

* Basics for generation (not enabled)

* Non-exported basic generation test

* lint fixes

* yarn.lock

* Adjust with lookups

* Adjust

* Adjust

* api-base into tsconfig for typegen

* typegen with args

* manual test for args passing

* CHANGELOG

* Adjust with new call definitions

* Allow multiple historic versions

* Metadata_metadata
This commit is contained in:
Jaco
2022-06-29 13:12:21 +03:00
committed by GitHub
parent 0a9158befc
commit ac1837cdfe
37 changed files with 634 additions and 52 deletions
@@ -6,34 +6,12 @@
import type { Definitions } from '../../types';
import { rpc } from './rpc';
import { runtime } from './runtime';
export default {
rpc: {
proveFinality: {
description: 'Prove finality for the given block number, returning the Justification for the last block in the set.',
params: [
{
name: 'blockNumber',
type: 'BlockNumber'
}
],
type: 'Option<EncodedFinalityProofs>'
},
roundState: {
description: 'Returns the state of the current best round state as well as the ongoing background rounds',
params: [],
type: 'ReportedRoundStates'
},
subscribeJustifications: {
description: 'Subscribes to grandpa justifications',
params: [],
pubsub: [
'justifications',
'subscribeJustifications',
'unsubscribeJustifications'
],
type: 'JustificationNotification'
}
},
rpc,
runtime,
types: {
AuthorityIndex: 'u64',
AuthorityList: 'Vec<NextAuthority>',
@@ -0,0 +1,32 @@
// Copyright 2017-2022 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { DefinitionsRpc } from '../../types';
export const rpc: DefinitionsRpc = {
proveFinality: {
description: 'Prove finality for the given block number, returning the Justification for the last block in the set.',
params: [
{
name: 'blockNumber',
type: 'BlockNumber'
}
],
type: 'Option<EncodedFinalityProofs>'
},
roundState: {
description: 'Returns the state of the current best round state as well as the ongoing background rounds',
params: [],
type: 'ReportedRoundStates'
},
subscribeJustifications: {
description: 'Subscribes to grandpa justifications',
params: [],
pubsub: [
'justifications',
'subscribeJustifications',
'unsubscribeJustifications'
],
type: 'JustificationNotification'
}
};
@@ -0,0 +1,24 @@
// Copyright 2017-2022 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { DefinitionsCall } from '../../types';
export const runtime: DefinitionsCall = {
GrandpaApi: [
{
methods: {
current_set_id: {
description: 'Get current GRANDPA authority set id.',
params: [],
type: 'SetId'
},
grandpa_authorities: {
description: 'Get the current GRANDPA authorities and weights. This should not change except for when changes are scheduled and the corresponding delay has passed.',
params: [],
type: 'AuthorityList'
}
},
version: 3
}
]
};
@@ -9,6 +9,7 @@ import type { Definitions } from '../../types';
import { objectSpread } from '@polkadot/util';
import { AllHashers } from './hashers';
import { runtime } from './runtime';
import { v9 } from './v9';
import { v10 } from './v10';
import { v11 } from './v11';
@@ -20,6 +21,7 @@ export { AllHashers };
export default {
rpc: {},
runtime,
types: objectSpread({}, v9, v10, v11, v12, v13, v14, {
// latest mappings
ErrorMetadataLatest: 'ErrorMetadataV14',
@@ -41,6 +43,9 @@ export default {
StorageEntryTypeLatest: 'StorageEntryTypeV14',
StorageHasher: 'StorageHasherV14',
// additional types
OpaqueMetadata: 'Bytes',
// the enum containing all the mappings
MetadataAll: {
_enum: {
@@ -0,0 +1,18 @@
// Copyright 2017-2022 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { DefinitionsCall } from '../../types';
export const runtime: DefinitionsCall = {
Metadata: [
{
methods: {
metadata: {
description: 'Returns the metadata of a runtime',
params: [],
type: 'OpaqueMetadata'
}
}
}
]
};
@@ -275,6 +275,9 @@ export interface ModuleMetadataV9 extends Struct {
readonly errors: Vec<ErrorMetadataV9>;
}
/** @name OpaqueMetadata */
export interface OpaqueMetadata extends Bytes {}
/** @name PalletCallMetadataLatest */
export interface PalletCallMetadataLatest extends PalletCallMetadataV14 {}
@@ -454,7 +454,8 @@ export default {
},
RuntimeVersionPartial: {
specName: 'Text',
specVersion: 'u32'
specVersion: 'u32',
apis: 'Vec<RuntimeVersionApi>'
},
SpecVersion: 'u32',
StorageChangeSet: {
@@ -73,6 +73,7 @@ export interface RuntimeVersionApi extends ITuple<[ApiId, u32]> {}
export interface RuntimeVersionPartial extends Struct {
readonly specName: Text;
readonly specVersion: u32;
readonly apis: Vec<RuntimeVersionApi>;
}
/** @name SpecVersion */
@@ -7,9 +7,11 @@
import type { Definitions } from '../../types';
import { rpc } from './rpc';
import { runtime } from './runtime';
export default {
rpc,
runtime,
types: {
AccountInfo: 'AccountInfoWithTripleRefCount',
AccountInfoWithRefCountU8: {
@@ -1,8 +1,6 @@
// Copyright 2017-2022 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// As per frontier
import type { DefinitionsRpc } from '../../types';
export const rpc: DefinitionsRpc = {
@@ -0,0 +1,23 @@
// Copyright 2017-2022 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { DefinitionsCall } from '../../types';
export const runtime: DefinitionsCall = {
AccountNonceApi: [
{
methods: {
account_nonce: {
description: 'The API to query account nonce (aka transaction index)',
params: [
{
name: 'accountId',
type: 'AccountId'
}
],
type: 'Index'
}
}
}
]
};
+18 -1
View File
@@ -42,15 +42,32 @@ export interface DefinitionRpcExt extends DefinitionRpc {
section: string;
}
export interface DefinitionCallParam {
name: string;
type: DefinitionTypeType;
}
export interface DefinitionCall {
description: string;
params: DefinitionCallParam[];
type: DefinitionTypeType;
}
export interface DefinitionRpcSub extends DefinitionRpc {
pubsub: [string, string, string];
}
export type DefinitionsRpc = Record<string, DefinitionRpc | DefinitionRpcSub>;
export type DefinitionsCall = Record<string, {
methods: Record<string, DefinitionCall>;
version?: number;
}[]>;
export type DefinitionsTypes = Record<string, DefinitionType>;
export interface Definitions {
rpc: DefinitionsRpc;
rpc?: DefinitionsRpc;
runtime?: DefinitionsCall;
types: DefinitionsTypes;
}