Use I* interfaces for extrinsic payload getters (#4814)

* Use `I*` interfaces for extrinsic payload getters

* Adjust with IText

* Text extends IText

* Adjust
This commit is contained in:
Jaco
2022-05-10 14:38:58 +03:00
committed by GitHub
parent 1808cb0a9d
commit 5c655ca029
11 changed files with 77 additions and 68 deletions
+2 -2
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import type { HexString } from '@polkadot/util/types';
import type { AnyU8a, Codec, Inspect, IU8a, Registry } from '../types';
import type { AnyU8a, Inspect, IText, IU8a, Registry } from '../types';
import { assert, compactAddLength, compactFromU8a, compactToU8a, hexToU8a, isHex, isString, isU8a, stringToU8a, u8aToHex, u8aToString } from '@polkadot/util';
@@ -47,7 +47,7 @@ function decodeText (value?: null | Text | string | AnyU8a | { toString: () => s
*/
// TODO
// - Strings should probably be trimmed (docs do come through with extra padding)
export class Text extends String implements Codec {
export class Text extends String implements IText {
public readonly registry: Registry;
public createdAtHash?: IU8a;
@@ -61,6 +61,10 @@ export interface IStruct<K = string, V extends Codec = Codec> extends Map<K, V>,
toArray (): Codec[];
}
export interface IText extends String, Codec {
// nothing additional
}
export type ITuple<T extends AnyTuple = Codec[]> = T & Codec;
export interface IU8a extends Uint8Array, Codec {