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
+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;