Fix augmented generation for RPC w/ alias (#2994)

* Fix augmented generation for RPC w/ alias

* Fix

* Rebuild
This commit is contained in:
Jaco Greeff
2020-12-28 13:21:43 +01:00
committed by GitHub
parent 1ba8f71da1
commit 9164637c44
3 changed files with 61 additions and 24 deletions
+24 -20
View File
@@ -152,10 +152,6 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Returns the chain ID used for transaction signing at the current best block. None is returned if not available.
**/
chainId: AugmentedRpc<() => Observable<U64>>;
/**
* Returns current client version.
**/
clientVersion: AugmentedRpc<() => Observable<Text>>;
/**
* Returns block author.
**/
@@ -248,18 +244,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Returns the number of hashes per second that the node is mining with.
**/
hashrate: AugmentedRpc<() => Observable<U256>>;
/**
* Returns true if client is actively listening for network connections. Otherwise false.
**/
listening: AugmentedRpc<() => Observable<bool>>;
/**
* Returns true if client is actively mining new blocks.
**/
mining: AugmentedRpc<() => Observable<bool>>;
/**
* Returns number of peers connected to node.
**/
peerCount: AugmentedRpc<() => Observable<Text>>;
/**
* Returns protocol version encoded as a string (quotes are necessary).
**/
@@ -272,10 +260,6 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Sends transaction; will block waiting for signer to return the transaction hash
**/
sendTransaction: AugmentedRpc<(tx: EthTransactionRequest | { from?: any; to?: any; gasPrice?: any; gas?: any; value?: any; data?: any; nonce?: any } | string | Uint8Array) => Observable<H256>>;
/**
* Returns sha3 of the given data
**/
sha3: AugmentedRpc<(_: Bytes | string | Uint8Array) => Observable<H256>>;
/**
* Used for submitting mining hashrate.
**/
@@ -292,10 +276,6 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Returns an object with data about the sync status or false.
**/
syncing: AugmentedRpc<() => Observable<EthSyncStatus>>;
/**
* Returns protocol version.
**/
version: AugmentedRpc<() => Observable<Text>>;
};
grandpa: {
/**
@@ -311,6 +291,20 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
**/
subscribeJustifications: AugmentedRpc<() => Observable<JustificationNotification>>;
};
net: {
/**
* Returns true if client is actively listening for network connections. Otherwise false.
**/
listening: AugmentedRpc<() => Observable<bool>>;
/**
* Returns number of peers connected to node.
**/
peerCount: AugmentedRpc<() => Observable<Text>>;
/**
* Returns protocol version.
**/
version: AugmentedRpc<() => Observable<Text>>;
};
offchain: {
/**
* Get offchain local storage under given key and prefix
@@ -487,5 +481,15 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
**/
version: AugmentedRpc<() => Observable<Text>>;
};
web3: {
/**
* Returns current client version.
**/
clientVersion: AugmentedRpc<() => Observable<Text>>;
/**
* Returns sha3 of the given data
**/
sha3: AugmentedRpc<(data: Bytes | string | Uint8Array) => Observable<H256>>;
};
}
}
+4
View File
@@ -110,6 +110,8 @@ export class RpcCore implements RpcInterface {
public readonly grandpa!: RpcInterface['grandpa'];
public readonly net!: RpcInterface['net'];
public readonly offchain!: RpcInterface['offchain'];
public readonly payment!: RpcInterface['payment'];
@@ -122,6 +124,8 @@ export class RpcCore implements RpcInterface {
public readonly system!: RpcInterface['system'];
public readonly web3!: RpcInterface['web3'];
/**
* @constructor
* Default constructor for the Api Object
+33 -4
View File
@@ -10,6 +10,19 @@ import * as defaultDefinitions from '@polkadot/types/interfaces/definitions';
import { createImports, formatType, getSimilarTypes, readTemplate, registerDefinitions, setImports, writeFile } from '../util';
interface ItemDef {
args: string;
docs: string[];
generic: string | undefined;
name: string;
type: string | undefined;
}
interface ModuleDef {
items: ItemDef[];
name: string;
}
const StorageKeyTye = 'StorageKey | string | Uint8Array | any';
const template = readTemplate('rpc');
@@ -30,6 +43,7 @@ export function generateRpcTypes (registry: TypeRegistry, importDefinitions: Rec
.filter((key) => Object.keys(definitions[key].rpc || {}).length !== 0)
.sort();
const additional: Record<string, ModuleDef> = {};
const modules = rpcKeys.map((sectionFullName) => {
const rpc = definitions[sectionFullName].rpc;
const section = sectionFullName.split('/').pop();
@@ -79,20 +93,35 @@ export function generateRpcTypes (registry: TypeRegistry, importDefinitions: Rec
generic = '';
}
return {
const item = {
args: args.join(', '),
docs: [def.description],
generic,
name: methodName,
type
};
});
if (def.aliasSection) {
if (!additional[def.aliasSection]) {
additional[def.aliasSection] = {
items: [],
name: def.aliasSection
};
}
additional[def.aliasSection].items.push(item);
return null;
}
return item;
}).filter((item): item is ItemDef => !!item);
return {
items: allMethods,
name: section
name: section || 'unknown'
};
});
}).concat(...Object.values(additional)).sort((a, b) => a.name.localeCompare(b.name));
imports.typesTypes.Observable = true;