Metadata v14 types (#3765)
* Metadata v14 types * Linting w/ CHANGELOG * Previous-gen SiType as SiType0
This commit is contained in:
@@ -33,13 +33,13 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes,
|
||||
|
||||
const items = constants
|
||||
.sort(compareName)
|
||||
.map(({ documentation, name, type }) => {
|
||||
.map(({ docs, name, type }) => {
|
||||
const returnType = formatType(allDefs, type.toString(), imports);
|
||||
|
||||
setImports(allDefs, imports, [returnType]);
|
||||
|
||||
return {
|
||||
docs: documentation,
|
||||
docs,
|
||||
name: stringCamelCase(name),
|
||||
type: returnType
|
||||
};
|
||||
|
||||
@@ -24,8 +24,8 @@ function generateForMeta (meta: Metadata, dest: string, isStrict: boolean): void
|
||||
.map(({ errors, name }) => ({
|
||||
items: errors
|
||||
.sort(compareName)
|
||||
.map(({ documentation, name }) => ({
|
||||
docs: documentation,
|
||||
.map(({ docs, name }) => ({
|
||||
docs,
|
||||
name: name.toString()
|
||||
})),
|
||||
name: stringCamelCase(name)
|
||||
|
||||
@@ -30,13 +30,13 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes,
|
||||
items: events
|
||||
.unwrap()
|
||||
.sort(compareName)
|
||||
.map(({ args, documentation, name }) => {
|
||||
.map(({ args, docs, name }) => {
|
||||
const types = args.map((type) => formatType(allDefs, type.toString(), imports));
|
||||
|
||||
setImports(allDefs, imports, types);
|
||||
|
||||
return {
|
||||
docs: documentation,
|
||||
docs,
|
||||
name: name.toString(),
|
||||
type: types.join(', ')
|
||||
};
|
||||
|
||||
@@ -107,7 +107,7 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
|
||||
|
||||
return {
|
||||
args,
|
||||
docs: storageEntry.documentation,
|
||||
docs: storageEntry.docs,
|
||||
entryType: 'AugmentedQuery',
|
||||
name: stringCamelCase(storageEntry.name),
|
||||
params,
|
||||
|
||||
@@ -44,7 +44,7 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
|
||||
|
||||
const items = calls.unwrap()
|
||||
.sort(compareName)
|
||||
.map(({ args, documentation, name }) => {
|
||||
.map(({ args, docs, name }) => {
|
||||
const params = args
|
||||
.map(({ name, type }) => {
|
||||
const typeStr = type.toString();
|
||||
@@ -58,7 +58,7 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
|
||||
|
||||
return {
|
||||
args: args.map(({ type }) => formatType(allDefs, type.toString(), imports)).join(', '),
|
||||
docs: documentation,
|
||||
docs,
|
||||
name: stringCamelCase(name),
|
||||
params
|
||||
};
|
||||
|
||||
@@ -43,7 +43,7 @@ const DESC_RPC = 'The following sections contain RPC methods that are Remote Cal
|
||||
const DESC_STORAGE = `The following sections contain Storage methods are part of the default Substrate runtime. On the api, these are exposed via \`api.query.<module>.<method>\`. ${STATIC_TEXT}`;
|
||||
|
||||
/** @internal */
|
||||
function documentationVecToMarkdown (docLines: Vec<Text>, indent = 0): string {
|
||||
function docsVecToMarkdown (docLines: Vec<Text>, indent = 0): string {
|
||||
const md = docLines
|
||||
.map((docLine) => docLine && docLine.substring(1)) // trim the leading space
|
||||
.reduce((md, docLine): string => // generate paragraphs
|
||||
@@ -94,7 +94,7 @@ function renderPage (page: Page): string {
|
||||
md += `\n- **${bullet}**: ${
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||
item[bullet] instanceof Vec
|
||||
? documentationVecToMarkdown(item[bullet] as Vec<Text>, 2).toString()
|
||||
? docsVecToMarkdown(item[bullet] as Vec<Text>, 2).toString()
|
||||
: item[bullet]
|
||||
}`;
|
||||
});
|
||||
@@ -180,7 +180,7 @@ function addConstants (metadata: MetadataLatest): string {
|
||||
return {
|
||||
interface: '`' + `api.consts.${sectionName}.${methodName}` + '`',
|
||||
name: `${methodName}: ` + '`' + func.type.toString() + '`',
|
||||
...(func.documentation.length && { summary: func.documentation })
|
||||
...(func.docs.length && { summary: func.docs })
|
||||
};
|
||||
}),
|
||||
name: sectionName
|
||||
@@ -216,7 +216,7 @@ function addStorage (metadata: MetadataLatest): string {
|
||||
return {
|
||||
interface: '`' + `api.query.${sectionName}.${methodName}` + '`',
|
||||
name: `${methodName}(${arg}): ` + '`' + outputType + '`',
|
||||
...(func.documentation.length && { summary: func.documentation })
|
||||
...(func.docs.length && { summary: func.docs })
|
||||
};
|
||||
}),
|
||||
name: sectionName
|
||||
@@ -239,7 +239,7 @@ function addStorage (metadata: MetadataLatest): string {
|
||||
return {
|
||||
interface: '`' + `api.query.substrate.${methodName}` + '`',
|
||||
name: `${methodName}(${arg}): ` + '`' + outputType + '`',
|
||||
summary: meta.documentation
|
||||
summary: meta.docs
|
||||
};
|
||||
}),
|
||||
name: 'substrate'
|
||||
@@ -268,7 +268,7 @@ function addExtrinsics (metadata: MetadataLatest): string {
|
||||
return {
|
||||
interface: '`' + `api.tx.${sectionName}.${methodName}` + '`',
|
||||
name: `${methodName}(${args})`,
|
||||
...(func.documentation.length && { summary: func.documentation })
|
||||
...(func.docs.length && { summary: func.docs })
|
||||
};
|
||||
}),
|
||||
name: sectionName
|
||||
@@ -295,7 +295,7 @@ function addEvents (metadata: MetadataLatest): string {
|
||||
return {
|
||||
interface: '`' + `api.events.${stringCamelCase(meta.name)}.${methodName}.is` + '`',
|
||||
name: `${methodName}(${args})`,
|
||||
...(func.documentation.length && { summary: func.documentation })
|
||||
...(func.docs.length && { summary: func.docs })
|
||||
};
|
||||
}),
|
||||
name: stringCamelCase(meta.name)
|
||||
@@ -317,7 +317,7 @@ function addErrors (metadata: MetadataLatest): string {
|
||||
.map((error) => ({
|
||||
interface: '`' + `api.errors.${stringCamelCase(moduleMetadata.name)}.${error.name.toString()}.is` + '`',
|
||||
name: error.name.toString(),
|
||||
...(error.documentation.length && { summary: error.documentation })
|
||||
...(error.docs.length && { summary: error.docs })
|
||||
})),
|
||||
name: stringLowerFirst(moduleMetadata.name)
|
||||
})),
|
||||
|
||||
Reference in New Issue
Block a user