From b5d5084b55644ab0601381ca2101ac54813db876 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 16 May 2019 14:14:18 +0200 Subject: [PATCH] Add Codec toRawType (#921) * Add Codec toType * Revert i* & u* (toType, catered for in base) * toType -> toRawType --- packages/types/src/codec/AbstractArray.ts | 7 ++++++- packages/types/src/codec/AbstractInt.ts | 7 ++++++- packages/types/src/codec/Compact.ts | 9 ++++++++- packages/types/src/codec/EnumType.ts | 20 ++++++++++++++++++- packages/types/src/codec/Int.ts | 9 ++++++++- packages/types/src/codec/Option.ts | 9 ++++++++- packages/types/src/codec/Set.ts | 14 ++++++++++++- packages/types/src/codec/Struct.ts | 13 +++++++++++- packages/types/src/codec/Tuple.ts | 15 +++++++++++++- packages/types/src/codec/U8a.ts | 9 ++++++++- packages/types/src/codec/U8aFixed.ts | 8 ++++++++ packages/types/src/codec/UInt.ts | 9 ++++++++- packages/types/src/codec/Vector.ts | 7 +++++++ packages/types/src/codec/VectorAny.ts | 9 ++++++++- packages/types/src/primitive/AccountId.ts | 7 +++++++ packages/types/src/primitive/AccountIndex.ts | 7 +++++++ packages/types/src/primitive/Address.ts | 9 ++++++++- packages/types/src/primitive/Bool.ts | 9 ++++++++- packages/types/src/primitive/Bytes.ts | 9 ++++++++- packages/types/src/primitive/Data.ts | 6 ++++++ packages/types/src/primitive/H160.ts | 7 +++++++ packages/types/src/primitive/H256.ts | 7 +++++++ packages/types/src/primitive/H512.ts | 7 +++++++ packages/types/src/primitive/Method.ts | 7 +++++++ packages/types/src/primitive/Moment.ts | 9 ++++++++- packages/types/src/primitive/Null.ts | 9 ++++++++- packages/types/src/primitive/Origin.ts | 7 +++++++ packages/types/src/primitive/Text.ts | 9 ++++++++- packages/types/src/primitive/Type.ts | 9 ++++++++- packages/types/src/primitive/USize.ts | 6 ++++++ packages/types/src/rpc/Json.ts | 7 +++++++ packages/types/src/type/Extrinsic.ts | 2 +- packages/types/src/type/ExtrinsicSignature.ts | 2 +- packages/types/src/types.ts | 7 ++++++- 34 files changed, 265 insertions(+), 22 deletions(-) diff --git a/packages/types/src/codec/AbstractArray.ts b/packages/types/src/codec/AbstractArray.ts index 638ac7f816..816302afd0 100644 --- a/packages/types/src/codec/AbstractArray.ts +++ b/packages/types/src/codec/AbstractArray.ts @@ -70,6 +70,11 @@ export default abstract class AbstractArray extends Array im ); } + /** + * @description Returns the base runtime type name for this instance + */ + abstract toRawType (): string; + /** * @description Returns the string representation of the value */ @@ -83,7 +88,7 @@ export default abstract class AbstractArray extends Array im } /** - * @description Encodes the value as a Uint8Array as per the parity-codec specifications + * @description Encodes the value as a Uint8Array as per the SCALE specifications * @param isBare true when the value has none of the type-specific prefixes (internal) */ toU8a (isBare?: boolean): Uint8Array { diff --git a/packages/types/src/codec/AbstractInt.ts b/packages/types/src/codec/AbstractInt.ts index e5e78f958d..624e2c7039 100644 --- a/packages/types/src/codec/AbstractInt.ts +++ b/packages/types/src/codec/AbstractInt.ts @@ -114,6 +114,11 @@ export default abstract class AbstractInt extends BN implements Codec { : this.toNumber(); } + /** + * @description Returns the base runtime type name for this instance + */ + abstract toRawType (): string; + /** * @description Returns the string representation of the value * @param base The base to use for the conversion @@ -124,7 +129,7 @@ export default abstract class AbstractInt extends BN implements Codec { } /** - * @description Encodes the value as a Uint8Array as per the parity-codec specifications + * @description Encodes the value as a Uint8Array as per the SCALE specifications * @param isBare true when the value has none of the type-specific prefixes (internal) */ abstract toU8a (isBare?: boolean): Uint8Array; diff --git a/packages/types/src/codec/Compact.ts b/packages/types/src/codec/Compact.ts index 22c3016623..a8742fcadf 100644 --- a/packages/types/src/codec/Compact.ts +++ b/packages/types/src/codec/Compact.ts @@ -126,6 +126,13 @@ export default class Compact extends Base implements Codec { return this.raw.toNumber(); } + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + return `Compact<${this.raw.toRawType()}>`; + } + /** * @description Returns the string representation of the value */ @@ -134,7 +141,7 @@ export default class Compact extends Base implements Codec { } /** - * @description Encodes the value as a Uint8Array as per the parity-codec specifications + * @description Encodes the value as a Uint8Array as per the SCALE specifications * @param isBare true when the value has none of the type-specific prefixes (internal) */ toU8a (isBare?: boolean): Uint8Array { diff --git a/packages/types/src/codec/EnumType.ts b/packages/types/src/codec/EnumType.ts index 583b9e6c29..2ea8d3f269 100644 --- a/packages/types/src/codec/EnumType.ts +++ b/packages/types/src/codec/EnumType.ts @@ -218,6 +218,24 @@ export default class Enum extends Base implements Codec { return this._index; } + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + const kv = this._isBasic + ? Object.keys(this._def).map((key) => + `"${key}"` + ) + : Object.entries(this._def).map(([key, Type]) => + `"${key}":"${new Type().toRawType()}"` + ); + const braces = this._isBasic + ? '[]' + : '{}'; + + return `{"_enum":${braces[0]}${kv.join(',')}${braces[1]}}`; + } + /** * @description Returns the string representation of the value */ @@ -228,7 +246,7 @@ export default class Enum extends Base implements Codec { } /** - * @description Encodes the value as a Uint8Array as per the parity-codec specifications + * @description Encodes the value as a Uint8Array as per the SCALE specifications * @param isBare true when the value has none of the type-specific prefixes (internal) */ toU8a (isBare?: boolean): Uint8Array { diff --git a/packages/types/src/codec/Int.ts b/packages/types/src/codec/Int.ts index 887bbf8f2a..6edfd4e16b 100644 --- a/packages/types/src/codec/Int.ts +++ b/packages/types/src/codec/Int.ts @@ -42,7 +42,14 @@ export default class Int extends AbstractInt { } /** - * @description Encodes the value as a Uint8Array as per the parity-codec specifications + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + return `i${this._bitLength}`; + } + + /** + * @description Encodes the value as a Uint8Array as per the SCALE specifications * @param isBare true when the value has none of the type-specific prefixes (internal) */ toU8a (isBare?: boolean): Uint8Array { diff --git a/packages/types/src/codec/Option.ts b/packages/types/src/codec/Option.ts index 357d3887ca..c35b174c42 100644 --- a/packages/types/src/codec/Option.ts +++ b/packages/types/src/codec/Option.ts @@ -111,6 +111,13 @@ export default class Option extends Base implements Codec { return this.raw.toJSON(); } + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + return `Option<${this.raw.toRawType()}>`; + } + /** * @description Returns the string representation of the value */ @@ -119,7 +126,7 @@ export default class Option extends Base implements Codec { } /** - * @description Encodes the value as a Uint8Array as per the parity-codec specifications + * @description Encodes the value as a Uint8Array as per the SCALE specifications * @param isBare true when the value has none of the type-specific prefixes (internal) */ toU8a (isBare?: boolean): Uint8Array { diff --git a/packages/types/src/codec/Set.ts b/packages/types/src/codec/Set.ts index 5ddbdcfdfb..d6b0945019 100644 --- a/packages/types/src/codec/Set.ts +++ b/packages/types/src/codec/Set.ts @@ -138,6 +138,18 @@ export default class CodecSet extends Set implements Codec { return this.strings; } + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + const kv = Object.entries(this._setValues).map(([key, value]) => + `"${key}":${value}` // JSON format + ); + + // FIXME We don't cater for this in createType as of yet + return `{"_set":{${kv.join(',')}}}`; + } + /** * @description Returns the string representation of the value */ @@ -146,7 +158,7 @@ export default class CodecSet extends Set implements Codec { } /** - * @description Encodes the value as a Uint8Array as per the parity-codec specifications + * @description Encodes the value as a Uint8Array as per the SCALE specifications * @param isBare true when the value has none of the type-specific prefixes (internal) */ toU8a (isBare?: boolean): Uint8Array { diff --git a/packages/types/src/codec/Struct.ts b/packages/types/src/codec/Struct.ts index d05e6e2213..3b937d04d2 100644 --- a/packages/types/src/codec/Struct.ts +++ b/packages/types/src/codec/Struct.ts @@ -232,6 +232,17 @@ export default class Struct< }, {} as any); } + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + const kv = [...this.entries()].map(([key, value]) => + `"${key}":"${value.toRawType()}"` // double-quotes, JSON + ); + + return `{${kv.join(',')}}`; + } + /** * @description Returns the string representation of the value */ @@ -240,7 +251,7 @@ export default class Struct< } /** - * @description Encodes the value as a Uint8Array as per the parity-codec specifications + * @description Encodes the value as a Uint8Array as per the SCALE specifications * @param isBare true when the value has none of the type-specific prefixes (internal) */ toU8a (isBare?: boolean): Uint8Array { diff --git a/packages/types/src/codec/Tuple.ts b/packages/types/src/codec/Tuple.ts index f7e880da42..8cf01b019d 100644 --- a/packages/types/src/codec/Tuple.ts +++ b/packages/types/src/codec/Tuple.ts @@ -77,6 +77,19 @@ export default class Tuple extends AbstractArray { : Object.keys(this._Types); } + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + const types = ( + Array.isArray(this._Types) + ? this._Types.map((Type) => new Type().toRawType()) + : Object.keys(this._Types) + ); + + return `(${types.join(',')})`; + } + /** * @description Returns the string representation of the value */ @@ -86,7 +99,7 @@ export default class Tuple extends AbstractArray { } /** - * @description Encodes the value as a Uint8Array as per the parity-codec specifications + * @description Encodes the value as a Uint8Array as per the SCALE specifications * @param isBare true when the value has none of the type-specific prefixes (internal) */ toU8a (isBare?: boolean): Uint8Array { diff --git a/packages/types/src/codec/U8a.ts b/packages/types/src/codec/U8a.ts index 3690f8dd88..de3ba17cfb 100644 --- a/packages/types/src/codec/U8a.ts +++ b/packages/types/src/codec/U8a.ts @@ -88,6 +88,13 @@ export default class U8a extends Uint8Array implements Codec { return this.toHex(); } + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + return `Vec`; + } + /** * @description Returns the string representation of the value */ @@ -96,7 +103,7 @@ export default class U8a extends Uint8Array implements Codec { } /** - * @description Encodes the value as a Uint8Array as per the parity-codec specifications + * @description Encodes the value as a Uint8Array as per the SCALE specifications * @param isBare true when the value has none of the type-specific prefixes (internal) */ toU8a (isBare?: boolean): Uint8Array { diff --git a/packages/types/src/codec/U8aFixed.ts b/packages/types/src/codec/U8aFixed.ts index 0df9dec7d4..ac05d01878 100644 --- a/packages/types/src/codec/U8aFixed.ts +++ b/packages/types/src/codec/U8aFixed.ts @@ -52,4 +52,12 @@ export default class U8aFixed extends U8a { bitLength () { return this.length * 8; } + + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + // FIEXME We don't cater for this in createType + return `[u8;${this.length}]`; + } } diff --git a/packages/types/src/codec/UInt.ts b/packages/types/src/codec/UInt.ts index d375b1a2cf..bcf9c00c8a 100644 --- a/packages/types/src/codec/UInt.ts +++ b/packages/types/src/codec/UInt.ts @@ -42,7 +42,14 @@ export default class UInt extends AbstractInt { } /** - * @description Encodes the value as a Uint8Array as per the parity-codec specifications + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + return `u${this._bitLength}`; + } + + /** + * @description Encodes the value as a Uint8Array as per the SCALE specifications * @param isBare true when the value has none of the type-specific prefixes (internal) */ toU8a (isBare?: boolean): Uint8Array { diff --git a/packages/types/src/codec/Vector.ts b/packages/types/src/codec/Vector.ts index abc01f3e7b..9fcc5e1858 100644 --- a/packages/types/src/codec/Vector.ts +++ b/packages/types/src/codec/Vector.ts @@ -84,4 +84,11 @@ export default class Vector extends AbstractArray { return -1; } + + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + return `Vec<${new this._Type().toRawType()}>`; + } } diff --git a/packages/types/src/codec/VectorAny.ts b/packages/types/src/codec/VectorAny.ts index 6fbb4da865..4f3c750d13 100644 --- a/packages/types/src/codec/VectorAny.ts +++ b/packages/types/src/codec/VectorAny.ts @@ -9,8 +9,15 @@ import AbstractArray from './AbstractArray'; * @name VectorAny * @description * This manages codec arrays, assuming that the inputs are already of type Codec. Unlike - * a vector, this cane be used to manage array-like structures with variable arguments of + * a vector, this can be used to manage array-like structures with variable arguments of * any types */ export default class VectorAny extends AbstractArray { + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + // FIXME This is basically an any type, cannot instantiate via createType + return 'Vec'; + } } diff --git a/packages/types/src/primitive/AccountId.ts b/packages/types/src/primitive/AccountId.ts index 66fed70d70..c21b5bf6d8 100644 --- a/packages/types/src/primitive/AccountId.ts +++ b/packages/types/src/primitive/AccountId.ts @@ -60,6 +60,13 @@ export default class AccountId extends U8aFixed { toString (): string { return AccountId.encode(this); } + + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + return 'AccountId'; + } } /** diff --git a/packages/types/src/primitive/AccountIndex.ts b/packages/types/src/primitive/AccountIndex.ts index 355c3f650e..63109d2e5f 100644 --- a/packages/types/src/primitive/AccountIndex.ts +++ b/packages/types/src/primitive/AccountIndex.ts @@ -110,4 +110,11 @@ export default class AccountIndex extends U32 { return encodeAddress(this.toU8a().subarray(0, length)); } + + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + return 'AccountIndex'; + } } diff --git a/packages/types/src/primitive/Address.ts b/packages/types/src/primitive/Address.ts index af170e6209..7e61e41280 100644 --- a/packages/types/src/primitive/Address.ts +++ b/packages/types/src/primitive/Address.ts @@ -121,7 +121,14 @@ export default class Address extends Base implements C } /** - * @description Encodes the value as a Uint8Array as per the parity-codec specifications + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + return 'Address'; + } + + /** + * @description Encodes the value as a Uint8Array as per the SCALE specifications * @param isBare true when the value has none of the type-specific prefixes (internal) */ toU8a (isBare?: boolean): Uint8Array { diff --git a/packages/types/src/primitive/Bool.ts b/packages/types/src/primitive/Bool.ts index 084dd8b5b8..a1e65d5fb5 100644 --- a/packages/types/src/primitive/Bool.ts +++ b/packages/types/src/primitive/Bool.ts @@ -68,6 +68,13 @@ export default class Bool extends Boolean implements Codec { return this.valueOf(); } + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + return 'bool'; + } + /** * @description Returns the string representation of the value */ @@ -76,7 +83,7 @@ export default class Bool extends Boolean implements Codec { } /** - * @description Encodes the value as a Uint8Array as per the parity-codec specifications + * @description Encodes the value as a Uint8Array as per the SCALE specifications * @param isBare true when the value has none of the type-specific prefixes (internal) */ toU8a (isBare?: boolean): Uint8Array { diff --git a/packages/types/src/primitive/Bytes.ts b/packages/types/src/primitive/Bytes.ts index ea75f42595..38289e87f0 100644 --- a/packages/types/src/primitive/Bytes.ts +++ b/packages/types/src/primitive/Bytes.ts @@ -70,7 +70,14 @@ export default class Bytes extends U8a { } /** - * @description Encodes the value as a Uint8Array as per the parity-codec specifications + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + return 'Bytes'; + } + + /** + * @description Encodes the value as a Uint8Array as per the SCALE specifications * @param isBare true when the value has none of the type-specific prefixes (internal) */ toU8a (isBare?: boolean): Uint8Array { diff --git a/packages/types/src/primitive/Data.ts b/packages/types/src/primitive/Data.ts index 5a58674477..e51ec23755 100644 --- a/packages/types/src/primitive/Data.ts +++ b/packages/types/src/primitive/Data.ts @@ -10,4 +10,10 @@ import U8a from '../codec/U8a'; * A raw data structure. It is just an encoding of a U8a, without any length encoding */ export default class Data extends U8a { + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + return 'Data'; + } } diff --git a/packages/types/src/primitive/H160.ts b/packages/types/src/primitive/H160.ts index e960100640..2a06f77a85 100644 --- a/packages/types/src/primitive/H160.ts +++ b/packages/types/src/primitive/H160.ts @@ -16,4 +16,11 @@ export default class H160 extends U8aFixed { constructor (value?: AnyU8a) { super(value, 160); } + + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + return 'H160'; + } } diff --git a/packages/types/src/primitive/H256.ts b/packages/types/src/primitive/H256.ts index 124237c01c..3342678270 100644 --- a/packages/types/src/primitive/H256.ts +++ b/packages/types/src/primitive/H256.ts @@ -16,4 +16,11 @@ export default class H256 extends U8aFixed { constructor (value?: AnyU8a) { super(value, 256); } + + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + return 'H256'; + } } diff --git a/packages/types/src/primitive/H512.ts b/packages/types/src/primitive/H512.ts index 444fb984b8..8e934fd86f 100644 --- a/packages/types/src/primitive/H512.ts +++ b/packages/types/src/primitive/H512.ts @@ -15,4 +15,11 @@ export default class H512 extends U8aFixed { constructor (value?: AnyU8a) { super(value, 512); } + + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + return 'H512'; + } } diff --git a/packages/types/src/primitive/Method.ts b/packages/types/src/primitive/Method.ts index ba54dc8cd7..04e0a817e1 100644 --- a/packages/types/src/primitive/Method.ts +++ b/packages/types/src/primitive/Method.ts @@ -226,4 +226,11 @@ export default class Method extends Struct implements IMethod { get meta (): FunctionMetadataV4 { return this._meta; } + + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + return 'Call'; + } } diff --git a/packages/types/src/primitive/Moment.ts b/packages/types/src/primitive/Moment.ts index 70936c66f6..6352296ebb 100644 --- a/packages/types/src/primitive/Moment.ts +++ b/packages/types/src/primitive/Moment.ts @@ -101,6 +101,13 @@ export default class Moment extends Date implements Codec { return Math.ceil(this.getTime() / 1000); } + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + return 'Moment'; + } + /** * @description Returns the string representation of the value */ @@ -110,7 +117,7 @@ export default class Moment extends Date implements Codec { } /** - * @description Encodes the value as a Uint8Array as per the parity-codec specifications + * @description Encodes the value as a Uint8Array as per the SCALE specifications * @param isBare true when the value has none of the type-specific prefixes (internal) */ toU8a (isBare?: boolean): Uint8Array { diff --git a/packages/types/src/primitive/Null.ts b/packages/types/src/primitive/Null.ts index b85901ee13..61b90083c3 100644 --- a/packages/types/src/primitive/Null.ts +++ b/packages/types/src/primitive/Null.ts @@ -46,6 +46,13 @@ export default class Null implements Codec { return null; } + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + return 'Null'; + } + /** * @description Returns the string representation of the value */ @@ -54,7 +61,7 @@ export default class Null implements Codec { } /** - * @description Encodes the value as a Uint8Array as per the parity-codec specifications + * @description Encodes the value as a Uint8Array as per the SCALE specifications * @param isBare true when the value has none of the type-specific prefixes (internal) */ toU8a (isBare?: boolean): Uint8Array { diff --git a/packages/types/src/primitive/Origin.ts b/packages/types/src/primitive/Origin.ts index 12e0ba4839..7a25a0f90a 100644 --- a/packages/types/src/primitive/Origin.ts +++ b/packages/types/src/primitive/Origin.ts @@ -16,4 +16,11 @@ export default class Origin extends Null { throw new Error('Origin should not be constructed, it is only a placeholder for compatibility'); } + + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + return 'Origin'; // yes, we cannot instantiate, but for consistency + } } diff --git a/packages/types/src/primitive/Text.ts b/packages/types/src/primitive/Text.ts index 7f6247fe9a..e4a13fc3dd 100644 --- a/packages/types/src/primitive/Text.ts +++ b/packages/types/src/primitive/Text.ts @@ -91,6 +91,13 @@ export default class Text extends String implements Codec { return this.toString(); } + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + return 'Text'; + } + /** * @description Returns the string representation of the value */ @@ -100,7 +107,7 @@ export default class Text extends String implements Codec { } /** - * @description Encodes the value as a Uint8Array as per the parity-codec specifications + * @description Encodes the value as a Uint8Array as per the SCALE specifications * @param isBare true when the value has none of the type-specific prefixes (internal) */ toU8a (isBare?: boolean): Uint8Array { diff --git a/packages/types/src/primitive/Type.ts b/packages/types/src/primitive/Type.ts index a592502d49..a5431b08a8 100644 --- a/packages/types/src/primitive/Type.ts +++ b/packages/types/src/primitive/Type.ts @@ -83,7 +83,7 @@ export default class Type extends Text { } /** - * @description Encodes the value as a Uint8Array as per the parity-codec specifications + * @description Encodes the value as a Uint8Array as per the SCALE specifications * @param isBare true when the value has none of the type-specific prefixes (internal) */ toU8a (isBare?: boolean): Uint8Array { @@ -233,4 +233,11 @@ export default class Type extends Text { return value; }; } + + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + return 'Type'; + } } diff --git a/packages/types/src/primitive/USize.ts b/packages/types/src/primitive/USize.ts index 6e51ee0274..cf33a68d56 100644 --- a/packages/types/src/primitive/USize.ts +++ b/packages/types/src/primitive/USize.ts @@ -11,4 +11,10 @@ import U32 from './U32'; * data. It is a wrapper for [[U32]] as a WASM default (as generated by Rust bindings) */ export default class USize extends U32 { + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + return 'usize'; + } } diff --git a/packages/types/src/rpc/Json.ts b/packages/types/src/rpc/Json.ts index 41f9f4af20..b9e3b5749e 100644 --- a/packages/types/src/rpc/Json.ts +++ b/packages/types/src/rpc/Json.ts @@ -61,6 +61,13 @@ export default class Json extends Map implements Codec { }, {} as any); } + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string { + return 'Json'; + } + /** * @description Returns the string representation of the value */ diff --git a/packages/types/src/type/Extrinsic.ts b/packages/types/src/type/Extrinsic.ts index c96f793377..fe0b960e67 100644 --- a/packages/types/src/type/Extrinsic.ts +++ b/packages/types/src/type/Extrinsic.ts @@ -198,7 +198,7 @@ export default class Extrinsic extends Struct implements IExtrinsic { } /** - * @description Encodes the value as a Uint8Array as per the parity-codec specifications + * @description Encodes the value as a Uint8Array as per the SCALE specifications * @param isBare true when the value has none of the type-specific prefixes (internal) */ toU8a (isBare?: boolean): Uint8Array { diff --git a/packages/types/src/type/ExtrinsicSignature.ts b/packages/types/src/type/ExtrinsicSignature.ts index 3b30353bec..09accab5b9 100644 --- a/packages/types/src/type/ExtrinsicSignature.ts +++ b/packages/types/src/type/ExtrinsicSignature.ts @@ -154,7 +154,7 @@ export default class ExtrinsicSignature extends Struct implements IExtrinsicSign } /** - * @description Encodes the value as a Uint8Array as per the parity-codec specifications + * @description Encodes the value as a Uint8Array as per the SCALE specifications * @param isBare true when the value has none of the type-specific prefixes (internal) */ toU8a (isBare?: boolean): Uint8Array { diff --git a/packages/types/src/types.ts b/packages/types/src/types.ts index 0f8c1337f4..63d4902ec6 100644 --- a/packages/types/src/types.ts +++ b/packages/types/src/types.ts @@ -60,13 +60,18 @@ export interface Codec { */ toJSON (): any; + /** + * @description Returns the base runtime type name for this instance + */ + toRawType (): string; + /** * @description Returns the string representation of the value */ toString (): string; /** - * @description Encodes the value as a Uint8Array as per the parity-codec specifications + * @description Encodes the value as a Uint8Array as per the SCALE specifications * @param isBare true when the value has none of the type-specific prefixes (internal) */ toU8a (isBare?: boolean): Uint8Array;