Bump dev (incl. lint fixes) (#2126)

* Bump dev (incl. lint fixes)

* Fix call encoding (stepped into that one)

* Event struct order

* Update with missing tuple type (getTypeDef type)
This commit is contained in:
Jaco Greeff
2020-04-01 22:44:34 +02:00
committed by GitHub
parent 7d3464ae2c
commit 0dc46445bc
130 changed files with 718 additions and 483 deletions
@@ -15,11 +15,13 @@ try {
['module-resolver', {
alias: {
'^@polkadot/api-derive(.*)': './packages/api-derive/src\\1',
'^@polkadot/metadata(.*)': './packages/metadata/src\\1',
// eslint-disable-next-line sort-keys
'^@polkadot/api(.*)': './packages/api/src/\\1',
'^@polkadot/metadata(.*)': './packages/metadata/src\\1',
'^@polkadot/rpc-core(.*)': './packages/rpc-core/src\\1',
'^@polkadot/rpc-provider(.*)': './packages/rpc-provider/src\\1',
'^@polkadot/types-known(.*)': './packages/types-known/src\\1',
// eslint-disable-next-line sort-keys
'^@polkadot/types(.*)': './packages/types/src\\1'
}
}]
@@ -16,6 +16,7 @@ try {
alias: {
'^@polkadot/metadata(.*)': './packages/metadata/src\\1',
'^@polkadot/types-known(.*)': './packages/types-known/src\\1',
// eslint-disable-next-line sort-keys
'^@polkadot/types(.*)': './packages/types/src\\1'
}
}]
@@ -17,6 +17,7 @@ try {
'^@polkadot/metadata(.*)': './packages/metadata/src\\1',
'^@polkadot/typegen(.*)': './packages/typegen/src\\1',
'^@polkadot/types-known(.*)': './packages/types-known/src\\1',
// eslint-disable-next-line sort-keys
'^@polkadot/types(.*)': './packages/types/src\\1'
}
}]
@@ -16,6 +16,7 @@ try {
alias: {
'^@polkadot/metadata(.*)': './packages/metadata/src\\1',
'^@polkadot/types-known(.*)': './packages/types-known/src\\1',
// eslint-disable-next-line sort-keys
'^@polkadot/types(.*)': './packages/types/src\\1'
}
}]
@@ -16,6 +16,7 @@ try {
alias: {
'^@polkadot/metadata(.*)': './packages/metadata/src\\1',
'^@polkadot/types-known(.*)': './packages/types-known/src\\1',
// eslint-disable-next-line sort-keys
'^@polkadot/types(.*)': './packages/types/src\\1'
}
}]
+2 -2
View File
@@ -35,8 +35,8 @@ export default function main (): void {
ws: {
default: 'ws://127.0.0.1:9944',
description: 'The API endpoint to connect to, e.g. wss://kusama-rpc.polkadot.io',
type: 'string',
required: true
required: true,
type: 'string'
}
}).argv;
+4 -4
View File
@@ -62,13 +62,13 @@ export default function main (): void {
const { endpoint, output, package: pkg, strict: isStrict } = yargs.strict().options({
endpoint: {
description: 'The endpoint to connect to (e.g. wss://kusama-rpc.polkadot.io) or relative path to a file containing the JSON output of an RPC state_getMetadata call',
type: 'string',
required: true
required: true,
type: 'string'
},
output: {
description: 'The target directory to write the data to',
type: 'string',
required: true
required: true,
type: 'string'
},
package: {
description: 'Optional package in output location (for extra definitions)',
+4 -4
View File
@@ -13,13 +13,13 @@ export default function main (): void {
const { input, package: pkg } = yargs.strict().options({
input: {
description: 'The directory to use for the user definitions',
type: 'string',
required: true
required: true,
type: 'string'
},
package: {
description: 'The package name & path to use for the user types',
type: 'string',
required: true
required: true,
type: 'string'
}
}).argv;
+32 -32
View File
@@ -105,7 +105,6 @@ function addRpc (): string {
.filter((key) => Object.keys(definitions[key as 'babe'].rpc || {}).length !== 0);
return renderPage({
title: 'JSON-RPC',
description: DESC_RPC,
sections: sections
.sort()
@@ -113,33 +112,33 @@ function addRpc (): string {
const section = definitions[sectionName as 'babe'];
return {
name: sectionName,
// description: section.description,
items: Object.keys(section.rpc)
.sort()
.map((methodName) => {
const method = section.rpc[methodName];
const args = method.params.map(({ name, isOptional, type }: any): string => {
const args = method.params.map(({ isOptional, name, type }: any): string => {
return name + (isOptional ? '?' : '') + ': `' + type + '`';
}).join(', ');
const type = '`' + method.type + '`';
return {
name: `${methodName}(${args}): ${type}`,
jsonrpc: '`' + `${sectionName}_${methodName}` + '`',
interface: '`' + `api.rpc.${sectionName}.${methodName}` + '`',
jsonrpc: '`' + `${sectionName}_${methodName}` + '`',
name: `${methodName}(${args}): ${type}`,
...(method.description && { summary: method.description })
};
})
}),
name: sectionName
};
})
}),
title: 'JSON-RPC'
});
}
/** @internal */
function addConstants (metadata: MetadataLatest): string {
return renderPage({
title: 'Constants',
description: DESC_CONSTANTS,
sections: metadata.modules
.sort(sortByName)
@@ -148,20 +147,21 @@ function addConstants (metadata: MetadataLatest): string {
const sectionName = stringLowerFirst(moduleMetadata.name.toString());
return {
name: sectionName,
items: moduleMetadata.constants
.sort(sortByName)
.map((func) => {
const methodName = stringCamelCase(func.name.toString());
return {
name: `${methodName}: ` + '`' + func.type + '`',
interface: '`' + `api.consts.${sectionName}.${methodName}` + '`',
name: `${methodName}: ` + '`' + func.type + '`',
...(func.documentation.length && { summary: func.documentation })
};
})
}),
name: sectionName
};
})
}),
title: 'Constants'
});
}
@@ -174,7 +174,6 @@ function addStorage (metadata: MetadataLatest): string {
const sectionName = stringLowerFirst(moduleMetadata.name.toString());
return {
name: sectionName,
items: moduleMetadata.storage.unwrap().items
.sort(sortByName)
.map((func) => {
@@ -187,28 +186,28 @@ function addStorage (metadata: MetadataLatest): string {
const outputType = unwrapStorageType(func.type, func.modifier.isOptional);
return {
name: `${methodName}(${arg}): ` + '`' + outputType + '`',
interface: '`' + `api.query.${sectionName}.${methodName}` + '`',
name: `${methodName}(${arg}): ` + '`' + outputType + '`',
...(func.documentation.length && { summary: func.documentation })
};
})
}),
name: sectionName
};
});
const options = { flags: 'r', encoding: 'utf8' };
const options = { encoding: 'utf8', flags: 'r' };
const knownSection = JSON.parse(fs.readFileSync('docs/substrate/storage-known-section.json', options));
return renderPage({
title: 'Storage',
description: DESC_STORAGE,
sections: moduleSections.concat([knownSection])
sections: moduleSections.concat([knownSection]),
title: 'Storage'
});
}
/** @internal */
function addExtrinsics (metadata: MetadataLatest): string {
return renderPage({
title: 'Extrinsics',
description: DESC_EXTRINSICS,
sections: metadata.modules
.sort(sortByName)
@@ -217,7 +216,6 @@ function addExtrinsics (metadata: MetadataLatest): string {
const sectionName = stringCamelCase(meta.name.toString());
return {
name: sectionName,
items: meta.calls.unwrap()
.sort(sortByName)
.map((func) => {
@@ -225,26 +223,26 @@ function addExtrinsics (metadata: MetadataLatest): string {
const args = Call.filterOrigin(func).map(({ name, type }): string => `${name}: ` + '`' + type + '`').join(', ');
return {
name: `${methodName}(${args})`,
interface: '`' + `api.tx.${sectionName}.${methodName}` + '`',
name: `${methodName}(${args})`,
...(func.documentation.length && { summary: func.documentation })
};
})
}),
name: sectionName
};
})
}),
title: 'Extrinsics'
});
}
/** @internal */
function addEvents (metadata: MetadataLatest): string {
return renderPage({
title: 'Events',
description: DESC_EVENTS,
sections: metadata.modules
.sort(sortByName)
.filter((meta) => !meta.events.isNone && meta.events.unwrap().length)
.map((meta) => ({
name: stringCamelCase(meta.name.toString()),
items: meta.events.unwrap()
.sort(sortByName)
.map((func) => {
@@ -255,34 +253,36 @@ function addEvents (metadata: MetadataLatest): string {
name: `${methodName}(${args})`,
...(func.documentation.length && { summary: func.documentation })
};
})
}))
}),
name: stringCamelCase(meta.name.toString())
})),
title: 'Events'
});
}
/** @internal */
function addErrors (metadata: MetadataLatest): string {
return renderPage({
title: 'Errors',
description: DESC_ERRORS,
sections: metadata.modules
.sort(sortByName)
.filter((moduleMetadata) => !moduleMetadata.errors.isEmpty)
.map((moduleMetadata) => ({
name: stringLowerFirst(moduleMetadata.name.toString()),
items: moduleMetadata.errors
.sort(sortByName)
.map((error) => ({
name: error.name.toString(),
...(error.documentation.length && { summary: error.documentation })
}))
}))
})),
name: stringLowerFirst(moduleMetadata.name.toString())
})),
title: 'Errors'
});
}
/** @internal */
function writeFile (name: string, ...chunks: any[]): void {
const options = { flags: 'w', encoding: 'utf8' };
const options = { encoding: 'utf8', flags: 'w' };
const writeStream = fs.createWriteStream(name, options);
writeStream.on('finish', (): void => {
+6 -6
View File
@@ -44,21 +44,21 @@ export function getDerivedTypes (definitions: object, type: string, primitiveNam
const types = [
{
info: TypeDefInfo.Option,
type,
sub: def
sub: def,
type
},
{
info: TypeDefInfo.Vec,
type,
sub: def
sub: def,
type
}
];
if (isCompact) {
types.unshift({
info: TypeDefInfo.Compact,
type,
sub: def
sub: def,
type
});
}
+2 -2
View File
@@ -116,7 +116,7 @@ export function createImports (importDefinitions: Record<string, object>, { type
return local;
}, {}),
primitiveTypes: {},
typesTypes: {},
typeToModule
typeToModule,
typesTypes: {}
};
}