syncState RPCs (#2797)

* syncState RPCs

* Use endpoint override as available

* Allow Json construction, update syncstate_get def
This commit is contained in:
Jaco Greeff
2020-10-28 13:26:37 +01:00
committed by GitHub
parent db3fe7d103
commit 9debb854f9
16 changed files with 87 additions and 14 deletions
+3 -3
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import { MetadataLatest } from '@polkadot/types/interfaces/metadata';
import { Codec } from '@polkadot/types/types';
import { Codec, DefinitionRpcParam } from '@polkadot/types/types';
import fs from 'fs';
import Metadata from '@polkadot/metadata/Metadata';
@@ -120,7 +120,7 @@ function addRpc (): string {
.sort()
.map((methodName) => {
const method = section.rpc[methodName];
const args = method.params.map(({ isOptional, name, type }: any): string => {
const args = method.params.map(({ isOptional, name, type }: DefinitionRpcParam): string => {
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
return name + (isOptional ? '?' : '') + ': `' + type + '`';
}).join(', ');
@@ -128,7 +128,7 @@ function addRpc (): string {
return {
interface: '`' + `api.rpc.${sectionName}.${methodName}` + '`',
jsonrpc: '`' + `${sectionName}_${methodName}` + '`',
jsonrpc: '`' + (method.endpoint || `${sectionName}_${methodName}`) + '`',
name: `${methodName}(${args}): ${type}`,
...(method.description && { summary: method.description })
};