Bump common, string* with String (#2799)

* Bump common, string* with String

* Linting, TS 4.0.5
This commit is contained in:
Jaco Greeff
2020-10-28 14:28:49 +01:00
committed by GitHub
parent 3f48b3c29f
commit 1476e5e5e9
28 changed files with 128 additions and 122 deletions
+2 -1
View File
@@ -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 -4
View File
@@ -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 {
+3 -2
View File
@@ -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();
}
+1 -1
View File
@@ -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;