Add tslint (#151)
This commit is contained in:
@@ -49,9 +49,9 @@ export default function decode (type: Param$Types, input: Uint8Array, version: E
|
||||
if (Array.isArray(type)) {
|
||||
// Arrays have single entries, Tuples will have multiple types
|
||||
if (type.length === 1) {
|
||||
return decodeArray((type as Param$Type$Array), input, version);
|
||||
return decodeArray(type, input, version);
|
||||
} else {
|
||||
return decodeTuple((type as Param$Type$Array), input, version);
|
||||
return decodeTuple(type, input, version);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,8 @@ export default function decodeValue (decode: Decoder, type: Param$Type, input: U
|
||||
return byte(input);
|
||||
|
||||
default:
|
||||
(type as never); // eslint-disable-line no-unused-expressions
|
||||
// tslint:disable-next-line
|
||||
(type as never);
|
||||
throw new Error(`No value decoder for type='${type}'`);
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@@ -90,7 +90,8 @@ export default function encodeType (type: Param$Type, value: any, version: Encod
|
||||
return bnToU8a(value || 0, 8, true);
|
||||
|
||||
default:
|
||||
(type as never); // eslint-disable-line no-unused-expressions
|
||||
// tslint:disable-next-line
|
||||
(type as never);
|
||||
throw new Error(`No formatter for ${type}`);
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@@ -7,16 +7,16 @@ import { SectionItem } from './types';
|
||||
import typeToString from './typeToString';
|
||||
|
||||
/**
|
||||
@name signature
|
||||
@signature jsonrpcSignature (method: InterfaceMethodDefinition): string
|
||||
@summary Returns a string representation of the method with inputs and outputs.
|
||||
@description
|
||||
Formats the name, inputs and outputs into a human-readable string. This contains the input parameter names, input types and output type.
|
||||
@example
|
||||
import signature from '@polkadot/params/signature';
|
||||
|
||||
console.log(signature({ name: 'test_method', params: [ { name: 'dest', type: 'Address' } ], type: 'Address' })); // => test_method (dest: Address): Address
|
||||
*/
|
||||
* @name signature
|
||||
* @signature jsonrpcSignature (method: InterfaceMethodDefinition): string
|
||||
* @summary Returns a string representation of the method with inputs and outputs.
|
||||
* @description
|
||||
* Formats the name, inputs and outputs into a human-readable string. This contains the input parameter names input types and output type.
|
||||
* @example
|
||||
* import signature from '@polkadot/params/signature';
|
||||
*
|
||||
* signature({ name: 'test_method', params: [ { name: 'dest', type: 'Address' } ], type: 'Address' }); // => test_method (dest: Address): Address
|
||||
*/
|
||||
export default function signature<T> ({ name, params, type }: SectionItem<T>): string {
|
||||
const inputs = params.map(({ name, type }) =>
|
||||
`${name}: ${typeToString(type)}`
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import { SizeType } from '@polkadot/primitives/sizes';
|
||||
import sizes, { SizeType } from '@polkadot/primitives/sizes';
|
||||
import { EncodingVersions } from './types';
|
||||
|
||||
import sizes from '@polkadot/primitives/sizes';
|
||||
|
||||
const Balance: Map<EncodingVersions, SizeType> = new Map([
|
||||
['latest' as EncodingVersions, sizes.Balance],
|
||||
['poc-1' as EncodingVersions, 64 as SizeType]
|
||||
|
||||
Reference in New Issue
Block a user