Bump common, string* with String (#2799)
* Bump common, string* with String * Linting, TS 4.0.5
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
"@polkadot/api": "^2.4.2-8",
|
||||
"@polkadot/rpc-core": "^2.4.2-8",
|
||||
"@polkadot/types": "^2.4.2-8",
|
||||
"@polkadot/util": "^3.6.2-6",
|
||||
"@polkadot/util": "^3.6.2-7",
|
||||
"bn.js": "^5.1.3",
|
||||
"rxjs": "^6.6.3"
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ export default class Abi {
|
||||
assert(isObject(arg.type), 'Invalid type definition found');
|
||||
|
||||
return {
|
||||
name: stringCamelCase(arg.name.toString()),
|
||||
name: stringCamelCase(arg.name),
|
||||
type: this.registry.getMetaTypeDef(arg.type)
|
||||
};
|
||||
} catch (error) {
|
||||
|
||||
@@ -32,13 +32,13 @@
|
||||
"@polkadot/rpc-core": "^2.4.2-8",
|
||||
"@polkadot/rpc-provider": "^2.4.2-8",
|
||||
"@polkadot/types": "^2.4.2-8",
|
||||
"@polkadot/util": "^3.6.2-6",
|
||||
"@polkadot/util-crypto": "^3.6.2-6",
|
||||
"@polkadot/util": "^3.6.2-7",
|
||||
"@polkadot/util-crypto": "^3.6.2-7",
|
||||
"bn.js": "^5.1.3",
|
||||
"memoizee": "^0.4.14",
|
||||
"rxjs": "^6.6.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^3.6.2-6"
|
||||
"@polkadot/keyring": "^3.6.2-7"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,19 +28,19 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.1",
|
||||
"@polkadot/api-derive": "^2.4.2-8",
|
||||
"@polkadot/keyring": "^3.6.2-6",
|
||||
"@polkadot/keyring": "^3.6.2-7",
|
||||
"@polkadot/metadata": "^2.4.2-8",
|
||||
"@polkadot/rpc-core": "^2.4.2-8",
|
||||
"@polkadot/rpc-provider": "^2.4.2-8",
|
||||
"@polkadot/types": "^2.4.2-8",
|
||||
"@polkadot/types-known": "^2.4.2-8",
|
||||
"@polkadot/util": "^3.6.2-6",
|
||||
"@polkadot/util-crypto": "^3.6.2-6",
|
||||
"@polkadot/util": "^3.6.2-7",
|
||||
"@polkadot/util-crypto": "^3.6.2-7",
|
||||
"bn.js": "^5.1.3",
|
||||
"eventemitter3": "^4.0.7",
|
||||
"rxjs": "^6.6.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^3.6.2-6"
|
||||
"@polkadot/keyring": "^3.6.2-7"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,11 +29,11 @@
|
||||
"@babel/runtime": "^7.12.1",
|
||||
"@polkadot/types": "^2.4.2-8",
|
||||
"@polkadot/types-known": "^2.4.2-8",
|
||||
"@polkadot/util": "^3.6.2-6",
|
||||
"@polkadot/util-crypto": "^3.6.2-6",
|
||||
"@polkadot/util": "^3.6.2-7",
|
||||
"@polkadot/util-crypto": "^3.6.2-7",
|
||||
"bn.js": "^5.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^3.6.2-6"
|
||||
"@polkadot/keyring": "^3.6.2-7"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,13 +19,13 @@ export default function fromMetadata (registry: Registry, metadata: Metadata): C
|
||||
const { name } = moduleMetadata;
|
||||
|
||||
// For access, we change the index names, i.e. Democracy.EnactmentPeriod -> democracy.enactmentPeriod
|
||||
result[stringCamelCase(name.toString())] = moduleMetadata.constants.reduce((newModule: ModuleConstants, meta): ModuleConstants => {
|
||||
result[stringCamelCase(name)] = moduleMetadata.constants.reduce((newModule: ModuleConstants, meta): ModuleConstants => {
|
||||
// convert to the natural type as received
|
||||
const type = meta.type.toString();
|
||||
const codec: ConstantCodec = createTypeUnsafe(registry, type, [hexToU8a(meta.value.toHex())]);
|
||||
|
||||
codec.meta = meta;
|
||||
newModule[stringCamelCase(meta.name.toString())] = codec;
|
||||
newModule[stringCamelCase(meta.name)] = codec;
|
||||
|
||||
return newModule;
|
||||
}, {} as ModuleConstants);
|
||||
|
||||
@@ -10,7 +10,7 @@ import { assert, stringCamelCase } from '@polkadot/util';
|
||||
export default function createDescriptor (registry: Registry, section: string, sectionIndex: number, methodIndex: number, callMetadata: RegistryMetadataCall): CallFunction {
|
||||
const callIndex = new Uint8Array([sectionIndex, methodIndex]);
|
||||
const expectedArgs = callMetadata.args;
|
||||
const funcName = stringCamelCase(callMetadata.name.toString());
|
||||
const funcName = stringCamelCase(callMetadata.name);
|
||||
|
||||
const extrinsicFn = (...args: any[]): Call => {
|
||||
assert(
|
||||
|
||||
@@ -19,10 +19,10 @@ export default function fromMetadata (registry: Registry, metadata: RegistryMeta
|
||||
const sectionIndex = isIndexed
|
||||
? index.toNumber()
|
||||
: _sectionIndex;
|
||||
const section = stringCamelCase(name.toString());
|
||||
const section = stringCamelCase(name);
|
||||
|
||||
result[section] = calls.unwrap().reduce((newModule: Calls, callMetadata, methodIndex): Calls => {
|
||||
const method = stringCamelCase(callMetadata.name.toString());
|
||||
const method = stringCamelCase(callMetadata.name);
|
||||
|
||||
newModule[method] = createUnchecked(registry, section, sectionIndex, methodIndex, callMetadata);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ export default function fromMetadata (registry: Registry, metadata: Metadata): S
|
||||
}
|
||||
|
||||
const { name } = moduleMetadata;
|
||||
const section = stringCamelCase(name.toString());
|
||||
const section = stringCamelCase(name);
|
||||
const unwrapped = moduleMetadata.storage.unwrap();
|
||||
const prefix = unwrapped.prefix.toString();
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ export default function extractTypes (types: string[]): Extracted[] {
|
||||
case TypeDefInfo.HashMap:
|
||||
case TypeDefInfo.Result:
|
||||
case TypeDefInfo.Tuple:
|
||||
return extractTypes((decoded.sub as TypeDef[]).map((sub): string => sub.type));
|
||||
return extractTypes((decoded.sub as TypeDef[]).map(({ type }) => type));
|
||||
|
||||
default:
|
||||
throw new Error(`Unhandled: Unable to create and validate type from ${type}`);
|
||||
|
||||
@@ -128,7 +128,7 @@ export default function toLatest (registry: Registry, { extrinsic, modules }: Me
|
||||
const calls = mod.calls.unwrapOr(null);
|
||||
const events = mod.events.unwrapOr(null);
|
||||
const storage = mod.storage.unwrapOr(null);
|
||||
const sectionTypes = getModuleTypes(registry, stringCamelCase(mod.name.toString()));
|
||||
const sectionTypes = getModuleTypes(registry, stringCamelCase(mod.name));
|
||||
|
||||
return registry.createType('ModuleMetadataLatest', {
|
||||
...mod,
|
||||
|
||||
@@ -30,11 +30,11 @@
|
||||
"@polkadot/metadata": "^2.4.2-8",
|
||||
"@polkadot/rpc-provider": "^2.4.2-8",
|
||||
"@polkadot/types": "^2.4.2-8",
|
||||
"@polkadot/util": "^3.6.2-6",
|
||||
"@polkadot/util": "^3.6.2-7",
|
||||
"memoizee": "^0.4.14",
|
||||
"rxjs": "^6.6.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^3.6.2-6"
|
||||
"@polkadot/keyring": "^3.6.2-7"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,15 +29,15 @@
|
||||
"@babel/runtime": "^7.12.1",
|
||||
"@polkadot/metadata": "^2.4.2-8",
|
||||
"@polkadot/types": "^2.4.2-8",
|
||||
"@polkadot/util": "^3.6.2-6",
|
||||
"@polkadot/util-crypto": "^3.6.2-6",
|
||||
"@polkadot/util": "^3.6.2-7",
|
||||
"@polkadot/util-crypto": "^3.6.2-7",
|
||||
"@polkadot/x-fetch": "^0.3.5",
|
||||
"@polkadot/x-ws": "^0.3.5",
|
||||
"bn.js": "^5.1.3",
|
||||
"eventemitter3": "^4.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^3.6.2-6",
|
||||
"@polkadot/keyring": "^3.6.2-7",
|
||||
"mock-socket": "^9.0.3",
|
||||
"nock": "^13.0.4"
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
"@polkadot/metadata": "^2.4.2-8",
|
||||
"@polkadot/rpc-provider": "^2.4.2-8",
|
||||
"@polkadot/types": "^2.4.2-8",
|
||||
"@polkadot/util": "^3.6.2-6",
|
||||
"@polkadot/util": "^3.6.2-7",
|
||||
"handlebars": "^4.7.6",
|
||||
"websocket": "^1.0.32",
|
||||
"yargs": "^16.1.0"
|
||||
|
||||
@@ -40,14 +40,14 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: Record<strin
|
||||
|
||||
return {
|
||||
docs: documentation,
|
||||
name: stringCamelCase(name.toString()),
|
||||
name: stringCamelCase(name),
|
||||
type: returnType
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
items,
|
||||
name: stringCamelCase(name.toString())
|
||||
name: stringCamelCase(name)
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -91,14 +91,14 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
|
||||
args,
|
||||
docs: storageEntry.documentation,
|
||||
entryType,
|
||||
name: stringCamelCase(storageEntry.name.toString()),
|
||||
name: stringCamelCase(storageEntry.name),
|
||||
returnType
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
items,
|
||||
name: stringCamelCase(name.toString())
|
||||
name: stringCamelCase(name)
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ function generateInterfaces (definitions: Record<string, ModuleTypes>, { types }
|
||||
};
|
||||
|
||||
return Object.entries(types).map(([name, type]): [string, string] => {
|
||||
const def = getTypeDef(isString(type) ? type.toString() : JSON.stringify(type), { name });
|
||||
const def = getTypeDef(isString(type) ? type : JSON.stringify(type), { name });
|
||||
|
||||
return [name, generators[def.info](definitions, def, imports)];
|
||||
});
|
||||
|
||||
@@ -19,7 +19,7 @@ const MAPPED_NAMES: Record<string, string> = {
|
||||
};
|
||||
|
||||
function mapName (_name: Text): string {
|
||||
const name = stringCamelCase(_name.toString());
|
||||
const name = stringCamelCase(_name);
|
||||
|
||||
return MAPPED_NAMES[name] || name;
|
||||
}
|
||||
@@ -58,14 +58,14 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
|
||||
|
||||
return {
|
||||
docs: documentation,
|
||||
name: stringCamelCase(name.toString()),
|
||||
name: stringCamelCase(name),
|
||||
params
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
items,
|
||||
name: stringCamelCase(name.toString())
|
||||
name: stringCamelCase(name)
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -148,13 +148,13 @@ function addConstants (metadata: MetadataLatest): string {
|
||||
.sort(sortByName)
|
||||
.filter((moduleMetadata) => !moduleMetadata.constants.isEmpty)
|
||||
.map((moduleMetadata) => {
|
||||
const sectionName = stringLowerFirst(moduleMetadata.name.toString());
|
||||
const sectionName = stringLowerFirst(moduleMetadata.name);
|
||||
|
||||
return {
|
||||
items: moduleMetadata.constants
|
||||
.sort(sortByName)
|
||||
.map((func) => {
|
||||
const methodName = stringCamelCase(func.name.toString());
|
||||
const methodName = stringCamelCase(func.name);
|
||||
|
||||
return {
|
||||
interface: '`' + `api.consts.${sectionName}.${methodName}` + '`',
|
||||
@@ -175,7 +175,7 @@ function addStorage (metadata: MetadataLatest): string {
|
||||
.sort(sortByName)
|
||||
.filter((moduleMetadata) => !moduleMetadata.storage.isNone)
|
||||
.map((moduleMetadata) => {
|
||||
const sectionName = stringLowerFirst(moduleMetadata.name.toString());
|
||||
const sectionName = stringLowerFirst(moduleMetadata.name);
|
||||
|
||||
return {
|
||||
items: moduleMetadata.storage.unwrap().items
|
||||
@@ -186,7 +186,7 @@ function addStorage (metadata: MetadataLatest): string {
|
||||
: func.type.isDoubleMap
|
||||
? ('`' + func.type.asDoubleMap.key1.toString() + ', ' + func.type.asDoubleMap.key2.toString() + '`')
|
||||
: '';
|
||||
const methodName = stringLowerFirst(func.name.toString());
|
||||
const methodName = stringLowerFirst(func.name);
|
||||
const outputType = unwrapStorageType(func.type, func.modifier.isOptional);
|
||||
|
||||
return {
|
||||
@@ -217,13 +217,13 @@ function addExtrinsics (metadata: MetadataLatest): string {
|
||||
.sort(sortByName)
|
||||
.filter((meta) => !meta.calls.isNone && meta.calls.unwrap().length !== 0)
|
||||
.map((meta) => {
|
||||
const sectionName = stringCamelCase(meta.name.toString());
|
||||
const sectionName = stringCamelCase(meta.name);
|
||||
|
||||
return {
|
||||
items: meta.calls.unwrap()
|
||||
.sort(sortByName)
|
||||
.map((func) => {
|
||||
const methodName = stringCamelCase(func.name.toString());
|
||||
const methodName = stringCamelCase(func.name);
|
||||
const args = Call.filterOrigin(func).map(({ name, type }) => `${name.toString()}: ` + '`' + type.toString() + '`').join(', ');
|
||||
|
||||
return {
|
||||
@@ -258,7 +258,7 @@ function addEvents (metadata: MetadataLatest): string {
|
||||
...(func.documentation.length && { summary: func.documentation })
|
||||
};
|
||||
}),
|
||||
name: stringCamelCase(meta.name.toString())
|
||||
name: stringCamelCase(meta.name)
|
||||
})),
|
||||
title: 'Events'
|
||||
});
|
||||
@@ -278,7 +278,7 @@ function addErrors (metadata: MetadataLatest): string {
|
||||
name: error.name.toString(),
|
||||
...(error.documentation.length && { summary: error.documentation })
|
||||
})),
|
||||
name: stringLowerFirst(moduleMetadata.name.toString())
|
||||
name: stringLowerFirst(moduleMetadata.name)
|
||||
})),
|
||||
title: 'Errors'
|
||||
});
|
||||
|
||||
@@ -7,6 +7,7 @@ import { TypeDef, TypeDefInfo } from '@polkadot/types/create/types';
|
||||
|
||||
import { getTypeDef } from '@polkadot/types/create';
|
||||
import { paramsNotation } from '@polkadot/types/codec/utils';
|
||||
import { isString } from '@polkadot/util';
|
||||
|
||||
import { setImports, ModuleTypes, TypeImports } from './imports';
|
||||
import { readTemplate } from './file';
|
||||
@@ -180,14 +181,17 @@ function formatVec (inner: string): string {
|
||||
* Correctly format a given type
|
||||
*/
|
||||
/** @internal */
|
||||
export function formatType (definitions: Record<string, ModuleTypes>, type: string | TypeDef, imports: TypeImports): string {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
export function formatType (definitions: Record<string, ModuleTypes>, type: string | String | TypeDef, imports: TypeImports): string {
|
||||
let typeDef: TypeDef;
|
||||
|
||||
if (typeof type === 'string') {
|
||||
if (isString(type)) {
|
||||
const _type = type.toString();
|
||||
|
||||
// If type is "unorthodox" (i.e. `{ something: any }` for an Enum input or `[a | b | c, d | e | f]` for a Tuple's similar types),
|
||||
// we return it as-is
|
||||
if (/(^{.+:.+})|^\([^,]+\)|^\(.+\)\[\]|^\[.+\]/.exec(type) && !/\[\w+;\w+\]/.exec(type)) {
|
||||
return type;
|
||||
if (/(^{.+:.+})|^\([^,]+\)|^\(.+\)\[\]|^\[.+\]/.exec(_type) && !/\[\w+;\w+\]/.exec(_type)) {
|
||||
return _type;
|
||||
}
|
||||
|
||||
typeDef = getTypeDef(type);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.1",
|
||||
"@polkadot/types": "^2.4.2-8",
|
||||
"@polkadot/util": "^3.6.2-6",
|
||||
"@polkadot/util": "^3.6.2-7",
|
||||
"bn.js": "^5.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -28,15 +28,15 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.1",
|
||||
"@polkadot/metadata": "^2.4.2-8",
|
||||
"@polkadot/util": "^3.6.2-6",
|
||||
"@polkadot/util-crypto": "^3.6.2-6",
|
||||
"@polkadot/util": "^3.6.2-7",
|
||||
"@polkadot/util-crypto": "^3.6.2-7",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"bn.js": "^5.1.3",
|
||||
"memoizee": "^0.4.14",
|
||||
"rxjs": "^6.6.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^3.6.2-6",
|
||||
"@polkadot/keyring": "^3.6.2-7",
|
||||
"@types/memoizee": "^0.4.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +166,8 @@ function extractSubType (type: string, [start, end]: [string, string, TypeDefInf
|
||||
return type.substr(start.length, type.length - start.length - end.length);
|
||||
}
|
||||
|
||||
export function getTypeDef (_type: string, { displayName, name }: TypeDefOptions = {}, count = 0): TypeDef {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
export function getTypeDef (_type: String | string, { displayName, name }: TypeDefOptions = {}, count = 0): TypeDef {
|
||||
// create the type via Type, allowing types to be sanitized
|
||||
const type = sanitize(_type);
|
||||
const value: TypeDef = { displayName, info: TypeDefInfo.Plain, name, type };
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
|
||||
import { ChainProperties, DispatchErrorModule, H256 } from '../interfaces/types';
|
||||
import { CallFunction, Codec, Constructor, InterfaceTypes, RegistryError, RegistryTypes, Registry, RegistryMetadata, RegisteredTypes, TypeDef } from '../types';
|
||||
import { CallFunction, Codec, Constructor, InterfaceTypes, RegistryError, RegistryTypes, Registry, RegistryMetadata, RegisteredTypes } from '../types';
|
||||
|
||||
import extrinsicsFromMeta from '@polkadot/metadata/Decorated/extrinsics/fromMetadata';
|
||||
import { BN_ZERO, assert, formatBalance, isFunction, isString, isU8a, isUndefined, logger, stringCamelCase, u8aToHex } from '@polkadot/util';
|
||||
@@ -31,7 +31,7 @@ function decorateErrors (_: Registry, metadata: RegistryMetadata, metadataErrors
|
||||
const sectionIndex = isIndexed
|
||||
? section.index.toNumber()
|
||||
: _sectionIndex;
|
||||
const sectionName = stringCamelCase(section.name.toString());
|
||||
const sectionName = stringCamelCase(section.name);
|
||||
|
||||
section.errors.forEach(({ documentation, name }, index): void => {
|
||||
const eventIndex = new Uint8Array([sectionIndex, index]);
|
||||
@@ -58,13 +58,13 @@ function decorateEvents (registry: Registry, metadata: RegistryMetadata, metadat
|
||||
const sectionIndex = isIndexed
|
||||
? section.index.toNumber()
|
||||
: _sectionIndex;
|
||||
const sectionName = stringCamelCase(section.name.toString());
|
||||
const sectionName = stringCamelCase(section.name);
|
||||
|
||||
section.events.unwrap().forEach((meta, methodIndex): void => {
|
||||
const methodName = meta.name.toString();
|
||||
const eventIndex = new Uint8Array([sectionIndex, methodIndex]);
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
||||
const typeDef = meta.args.map((arg): TypeDef => getTypeDef(arg.toString()));
|
||||
const typeDef = meta.args.map((arg) => getTypeDef(arg));
|
||||
let Types: Constructor<Codec>[] = [];
|
||||
|
||||
try {
|
||||
|
||||
@@ -211,8 +211,9 @@ export function removeWrap (_check: string): Mapper {
|
||||
};
|
||||
}
|
||||
|
||||
export default function sanitize (value: string, options?: SanitizeOptions): string {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
export default function sanitize (value: String | string, options?: SanitizeOptions): string {
|
||||
return mappings.reduce((result, fn): string => {
|
||||
return fn(result, options);
|
||||
}, value).trim();
|
||||
}, value.toString()).trim();
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ interface DecodedMethod extends DecodeMethodInput {
|
||||
function getArgsDef (registry: Registry, meta: FunctionMetadataLatest): ArgsDef {
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
return Call.filterOrigin(meta).reduce((result, { name, type }): ArgsDef => {
|
||||
const Type = getTypeClass(registry, getTypeDef(type.toString()));
|
||||
const Type = getTypeClass(registry, getTypeDef(type));
|
||||
|
||||
result[name.toString()] = Type;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user