CHANGELOG & small strict adjustments (#1940)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
|
||||
import { Codec } from '@polkadot/types/types';
|
||||
@@ -12,7 +12,7 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
|
||||
export interface Constants {
|
||||
[index: string]: ModuleConstants;
|
||||
babe: {
|
||||
[index: string]: Codec;
|
||||
[index: string]: AugmentedConst<object & Codec>;
|
||||
/**
|
||||
* The number of **slots** that an epoch takes. We couple sessions to
|
||||
* epochs, i.e. we start a new session once the new epoch begins.
|
||||
@@ -28,7 +28,7 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
|
||||
expectedBlockTime: AugmentedConst<Moment>;
|
||||
};
|
||||
timestamp: {
|
||||
[index: string]: Codec;
|
||||
[index: string]: AugmentedConst<object & Codec>;
|
||||
/**
|
||||
* The minimum period between blocks. Beware that this is different to the *expected* period
|
||||
* that the block production apparatus provides. Your chosen consensus system will generally
|
||||
@@ -38,14 +38,14 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
|
||||
minimumPeriod: AugmentedConst<Moment>;
|
||||
};
|
||||
balances: {
|
||||
[index: string]: Codec;
|
||||
[index: string]: AugmentedConst<object & Codec>;
|
||||
/**
|
||||
* The minimum amount required to keep an account open.
|
||||
**/
|
||||
existentialDeposit: AugmentedConst<Balance>;
|
||||
};
|
||||
transactionPayment: {
|
||||
[index: string]: Codec;
|
||||
[index: string]: AugmentedConst<object & Codec>;
|
||||
/**
|
||||
* The fee to be paid for making a transaction; the base.
|
||||
**/
|
||||
@@ -56,7 +56,7 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
|
||||
transactionByteFee: AugmentedConst<BalanceOf>;
|
||||
};
|
||||
staking: {
|
||||
[index: string]: Codec;
|
||||
[index: string]: AugmentedConst<object & Codec>;
|
||||
/**
|
||||
* Number of sessions per era.
|
||||
**/
|
||||
@@ -67,7 +67,7 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
|
||||
bondingDuration: AugmentedConst<EraIndex>;
|
||||
};
|
||||
session: {
|
||||
[index: string]: Codec;
|
||||
[index: string]: AugmentedConst<object & Codec>;
|
||||
/**
|
||||
* Used as first key for `NextKeys` and `KeyOwner` to put all the data into the same branch
|
||||
* of the trie.
|
||||
@@ -75,7 +75,7 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
|
||||
dedupKeyPrefix: AugmentedConst<Bytes>;
|
||||
};
|
||||
democracy: {
|
||||
[index: string]: Codec;
|
||||
[index: string]: AugmentedConst<object & Codec>;
|
||||
/**
|
||||
* The minimum period of locking and the period between a proposal being approved and enacted.
|
||||
* It should generally be a little more than the unstake period to ensure that
|
||||
@@ -109,7 +109,7 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
|
||||
preimageByteDeposit: AugmentedConst<BalanceOf>;
|
||||
};
|
||||
elections: {
|
||||
[index: string]: Codec;
|
||||
[index: string]: AugmentedConst<object & Codec>;
|
||||
candidacyBond: AugmentedConst<BalanceOf>;
|
||||
votingBond: AugmentedConst<BalanceOf>;
|
||||
desiredMembers: AugmentedConst<u32>;
|
||||
@@ -117,7 +117,7 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
|
||||
termDuration: AugmentedConst<BlockNumber>;
|
||||
};
|
||||
finalityTracker: {
|
||||
[index: string]: Codec;
|
||||
[index: string]: AugmentedConst<object & Codec>;
|
||||
/**
|
||||
* The number of recent samples to keep from this chain. Default is 101.
|
||||
**/
|
||||
@@ -128,7 +128,7 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
|
||||
reportLatency: AugmentedConst<BlockNumber>;
|
||||
};
|
||||
treasury: {
|
||||
[index: string]: Codec;
|
||||
[index: string]: AugmentedConst<object & Codec>;
|
||||
/**
|
||||
* Fraction of a proposal's value that should be bonded in order to place the proposal.
|
||||
* An accepted proposal gets these back. A rejected proposal does not.
|
||||
@@ -164,7 +164,7 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
|
||||
tipReportDepositPerByte: AugmentedConst<BalanceOf>;
|
||||
};
|
||||
contracts: {
|
||||
[index: string]: Codec;
|
||||
[index: string]: AugmentedConst<object & Codec>;
|
||||
/**
|
||||
* Number of block delay an extrinsic claim surcharge has.
|
||||
* When claim surcharge is called by an extrinsic the rent is checked
|
||||
@@ -237,7 +237,7 @@ declare module '@polkadot/metadata/Decorated/consts/types' {
|
||||
blockGasLimit: AugmentedConst<Gas>;
|
||||
};
|
||||
society: {
|
||||
[index: string]: Codec;
|
||||
[index: string]: AugmentedConst<object & Codec>;
|
||||
/**
|
||||
* The minimum amount of a deposit required for a bid to be made.
|
||||
**/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
|
||||
import { AnyNumber, ITuple } from '@polkadot/types/types';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
|
||||
import { AnyNumber, Codec, IExtrinsic } from '@polkadot/types/types';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
|
||||
import { AnyNumber, ITuple } from '@polkadot/types/types';
|
||||
@@ -17,8 +17,7 @@ import { SocietyJudgement } from '@polkadot/types/interfaces/society';
|
||||
import { EraIndex, RewardDestination, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
|
||||
import { Key } from '@polkadot/types/interfaces/system';
|
||||
import { Timepoint } from '@polkadot/types/interfaces/utility';
|
||||
import { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import { ApiTypes } from '@polkadot/api/types';
|
||||
import { ApiTypes, SubmittableExtrinsic } from '@polkadot/api/types';
|
||||
|
||||
declare module '@polkadot/api/types/submittable' {
|
||||
export interface AugmentedSubmittables<ApiType> {
|
||||
|
||||
@@ -19,10 +19,12 @@ function generateModule (allDefs: object, { constants, name }: ModuleMetadataLat
|
||||
return [];
|
||||
}
|
||||
|
||||
setImports(allDefs, imports, ['Codec']);
|
||||
if (!isStrict) {
|
||||
setImports(allDefs, imports, ['Codec']);
|
||||
}
|
||||
|
||||
return [indent(4)(`${stringCamelCase(name.toString())}: {`)]
|
||||
.concat(isStrict ? '' : indent(6)('[index: string]: Codec;'))
|
||||
.concat(isStrict ? '' : indent(6)('[index: string]: AugmentedConst<object & Codec>;'))
|
||||
.concat(constants.map(({ documentation, name, type }): string => {
|
||||
setImports(allDefs, imports, [type.toString()]);
|
||||
|
||||
@@ -43,7 +45,7 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: Record<strin
|
||||
const body = meta.asLatest.modules.reduce((acc, mod): string[] => {
|
||||
return acc.concat(generateModule(allDefs, mod, imports, isStrict));
|
||||
}, [] as string[]);
|
||||
const header = createImportCode(HEADER, imports, [
|
||||
const header = createImportCode(HEADER('chain'), imports, [
|
||||
...Object.keys(imports.localTypes).sort().map((moduleName): { file: string; types: string[] } => ({
|
||||
file: `${imports.moduleToPackage[moduleName]}/${moduleName}`,
|
||||
types: Object.keys(imports.localTypes[moduleName])
|
||||
|
||||
@@ -44,7 +44,7 @@ export function generateInterfaceTypes (importDefinitions: { [importPath: string
|
||||
].join('\n');
|
||||
}, '');
|
||||
|
||||
const header = createImportCode(HEADER, imports, [
|
||||
const header = createImportCode(HEADER('defs'), imports, [
|
||||
...Object.keys(imports.localTypes).sort().map((moduleName): { file: string; types: string[] } => ({
|
||||
file: `${imports.moduleToPackage[moduleName]}/${moduleName}`,
|
||||
types: Object.keys(imports.localTypes[moduleName])
|
||||
|
||||
@@ -46,7 +46,7 @@ function entrySignature (allDefs: object, registry: Registry, storageEntry: Stor
|
||||
formatType(allDefs, addModifier(storageEntry, storageEntry.type.asMap.value.toString()), imports)
|
||||
];
|
||||
} else if (storageEntry.type.isDoubleMap) {
|
||||
// Find similartypes of `key1` and `key2` types
|
||||
// Find similar types of `key1` and `key2` types
|
||||
const similarTypes1 = getSimilarTypes(allDefs, registry, storageEntry.type.asDoubleMap.key1.toString(), imports);
|
||||
const similarTypes2 = getSimilarTypes(allDefs, registry, storageEntry.type.asDoubleMap.key2.toString(), imports);
|
||||
|
||||
@@ -102,7 +102,7 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
|
||||
const body = meta.asLatest.modules.reduce((acc: string[], mod): string[] => {
|
||||
return acc.concat(generateModule(allDefs, registry, mod, imports, isStrict));
|
||||
}, []);
|
||||
const header = createImportCode(HEADER, imports, [
|
||||
const header = createImportCode(HEADER('chain'), imports, [
|
||||
...Object.keys(imports.localTypes).sort().map((moduleName): { file: string; types: string[] } => ({
|
||||
file: `${imports.moduleToPackage[moduleName]}/${moduleName}`,
|
||||
types: Object.keys(imports.localTypes[moduleName])
|
||||
|
||||
@@ -48,7 +48,7 @@ export default function generateRpcTypes (dest = 'packages/api/src/augment/rpc.t
|
||||
);
|
||||
}, []).join('\n');
|
||||
|
||||
const header = createImportCode(HEADER, imports, [
|
||||
const header = createImportCode(HEADER('chain'), imports, [
|
||||
...Object.keys(imports.localTypes).sort().map((moduleName): { file: string; types: string[] } => ({
|
||||
file: `@polkadot/types/interfaces/${moduleName}`,
|
||||
types: Object.keys(imports.localTypes[moduleName])
|
||||
|
||||
@@ -184,7 +184,7 @@ function generateTsDefFor (importDefinitions: { [importPath: string]: object },
|
||||
const interfaces = generateInterfaces(definitions, { types }, imports);
|
||||
const sortedDefs = interfaces.sort((a, b): number => a[0].localeCompare(b[0])).map(([, definition]): string => definition).join('\n\n');
|
||||
|
||||
const header = createImportCode(HEADER, imports, [
|
||||
const header = createImportCode(HEADER('defs'), imports, [
|
||||
...Object.keys(imports.localTypes).sort().map((moduleName): { file: string; types: string[] } => ({
|
||||
file: `${imports.moduleToPackage[moduleName]}/${moduleName}`,
|
||||
types: Object.keys(imports.localTypes[moduleName])
|
||||
@@ -192,7 +192,7 @@ function generateTsDefFor (importDefinitions: { [importPath: string]: object },
|
||||
]);
|
||||
|
||||
fs.writeFileSync(path.join(outputDir, defName, 'types.ts'), header.concat(sortedDefs).concat(FOOTER), { flag: 'w' });
|
||||
fs.writeFileSync(path.join(outputDir, defName, 'index.ts'), HEADER.concat('export * from \'./types\';').concat(FOOTER), { flag: 'w' });
|
||||
fs.writeFileSync(path.join(outputDir, defName, 'index.ts'), HEADER('defs').concat('export * from \'./types\';').concat(FOOTER), { flag: 'w' });
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
@@ -206,7 +206,7 @@ export function generateTsDef (importDefinitions: { [importPath: string]: object
|
||||
generateTsDefFor(importDefinitions, defName, obj, outputDir);
|
||||
});
|
||||
|
||||
return HEADER
|
||||
return HEADER('defs')
|
||||
.concat(
|
||||
Object
|
||||
.keys(definitions)
|
||||
@@ -216,7 +216,7 @@ export function generateTsDef (importDefinitions: { [importPath: string]: object
|
||||
.concat(FOOTER);
|
||||
});
|
||||
|
||||
fs.writeFileSync(path.join(outputDir, 'index.ts'), HEADER.concat('export * from \'./types\';').concat(FOOTER), { flag: 'w' });
|
||||
fs.writeFileSync(path.join(outputDir, 'index.ts'), HEADER('defs').concat('export * from \'./types\';').concat(FOOTER), { flag: 'w' });
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
||||
@@ -70,18 +70,14 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
|
||||
const body = meta.asLatest.modules.reduce((acc, mod): string[] => {
|
||||
return acc.concat(generateModule(registry, allDefs, mod, imports, isStrict));
|
||||
}, [] as string[]);
|
||||
const header = createImportCode(HEADER, imports, [
|
||||
const header = createImportCode(HEADER('chain'), imports, [
|
||||
...Object.keys(imports.localTypes).sort().map((moduleName): { file: string; types: string[] } => ({
|
||||
file: `${imports.moduleToPackage[moduleName]}/${moduleName}`,
|
||||
types: Object.keys(imports.localTypes[moduleName])
|
||||
})),
|
||||
{
|
||||
file: '@polkadot/api/submittable/types',
|
||||
types: ['SubmittableExtrinsic']
|
||||
},
|
||||
{
|
||||
file: '@polkadot/api/types',
|
||||
types: ['ApiTypes']
|
||||
types: ['ApiTypes', 'SubmittableExtrinsic']
|
||||
}
|
||||
]);
|
||||
const interfaceStart = [
|
||||
|
||||
@@ -9,7 +9,7 @@ import { paramsNotation } from '@polkadot/types/codec/utils';
|
||||
|
||||
import { setImports, TypeImports } from './imports';
|
||||
|
||||
export const HEADER = '// Auto-generated via `yarn polkadot-types-from-defs`, do not edit\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\n';
|
||||
export const HEADER = (type: 'chain' | 'defs'): string => `// Auto-generated via \`yarn polkadot-types-from-${type}\`, do not edit\n/* eslint-disable @typescript-eslint/no-empty-interface */\n\n`;
|
||||
export const FOOTER = '\n';
|
||||
|
||||
const TYPES_NON_PRIMITIVE = ['Metadata'];
|
||||
|
||||
Reference in New Issue
Block a user