Cater for named event fields (#4915)

* Cater for named event fields

* Adjust name extraction

* Rebuild with named events

* Empty object

* Adjust

* Additional

* Adjust
This commit is contained in:
Jaco
2022-06-09 13:44:31 +03:00
committed by GitHub
parent 322ac0861d
commit 7461527448
14 changed files with 824 additions and 766 deletions
+7 -1
View File
@@ -42,13 +42,19 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes,
const args = fields
.map(({ type }) => lookup.getTypeDef(type))
.map((typeDef) => typeDef.lookupName || formatType(registry, allDefs, typeDef, imports));
const names = fields
.map(({ name }) => registry.lookup.sanitizeField(name)[0])
.filter((n): n is string => !!n);
setImports(allDefs, imports, args);
return {
docs,
fields: names.length === args.length
? `{ ${names.map((n, i) => `${n}: ${args[i]}`).join(', ')} }`
: '{}',
name: name.toString(),
type: args.join(', ')
type: `[${args.join(', ')}]`
};
})
.sort(compareName),
+1 -1
View File
@@ -8,7 +8,7 @@ declare module '@polkadot/api-base/types/events' {
{{{name}}}: {
{{#each items}}
{{> docs}}
{{{name}}}: AugmentedEvent<ApiType, [{{{type}}}]>;
{{{name}}}: AugmentedEvent<ApiType, {{{type}}}, {{{fields}}}>;
{{/each}}
{{#unless @root.isStrict}}
/**