name: Compact

description: A compact length-encoding codec wrapper. It performs the same function as Length, however differs in that it uses a variable number of bytes to do the actual encoding. This is mostly used by other types to add length-prefixed encoding, or in the case of wrapped types, taking a number and making the compact representation thereof

Hierarchy

Base< UInt | Moment>

↳ Compact

Implements

Constructors

constructor

⊕ new Compact(Type: Constructor< UInt | Moment>, value?: AnyNumber): Compact

Overrides Base.constructor

Defined in codec/Compact.ts:23

Parameters:

Name Type Default value
Type Constructor< UInt | Moment> -
Default value value AnyNumber 0

Returns: Compact


Properties

<Static> addLengthPrefix

● addLengthPrefix: compactAddLength = compactAddLength

Defined in codec/Compact.ts:41

Prepend a Uint8Array with its compact length. param: The Uint8Array to be prefixed


<Static> decodeU8a

● decodeU8a: compactFromU8a = compactFromU8a

Defined in codec/Compact.ts:42


<Static> encodeU8a

● encodeU8a: compactToU8a = compactToU8a

Defined in codec/Compact.ts:43


Accessors

encodedLength

getencodedLength(): number

Defined in codec/Compact.ts:70

description: The length of the value when encoded as a Uint8Array

Returns: number


Methods

bitLength

▸ bitLength(): UIntBitLength

Defined in codec/Compact.ts:77

description: Returns the number of bits in the value

Returns: UIntBitLength


toBn

▸ toBn(): BN

Defined in codec/Compact.ts:84

description: Returns the BN representation of the number

Returns: BN


toHex

▸ toHex(): any

Implementation of Codec.toHex

Defined in codec/Compact.ts:91

description: Returns a hex string representation of the value

Returns: any


toJSON

▸ toJSON(): any

Implementation of Codec.toJSON

Defined in codec/Compact.ts:98

description: Converts the Object to JSON, typically used for RPC transfers

Returns: any


toNumber

▸ toNumber(): number

Defined in codec/Compact.ts:105

description: Returns the number representation for the value

Returns: number


toString

▸ toString(): string

Implementation of Codec.toString

Defined in codec/Compact.ts:112

description: Returns the string representation of the value

Returns: string


toU8a

▸ toU8a(isBare?: undefined | false | true): Uint8Array

Defined in codec/Compact.ts:120

description: Encodes the value as a Uint8Array as per the parity-codec specifications

Parameters:

Name Type Description
Optional isBare undefined | false | true true when the value has none of the type-specific prefixes (internal)

Returns: Uint8Array


<Static> decodeCompact

▸ decodeCompact(Type: Constructor< UInt | Moment>, value: AnyNumber): Moment | UInt

Defined in codec/Compact.ts:51

Parameters:

Name Type
Type Constructor< UInt | Moment>
value AnyNumber

Returns: Moment | UInt


<Static> stripLengthPrefix

▸ stripLengthPrefix(u8a: Uint8Array, bitLength?: UIntBitLength): Uint8Array

Defined in codec/Compact.ts:45

Parameters:

Name Type Default value
u8a Uint8Array -
Default value bitLength UIntBitLength DEFAULT_BITLENGTH

Returns: Uint8Array


<Static> with

▸ with(Type: Constructor< UInt | Moment>): Constructor<Compact>

Defined in codec/Compact.ts:28

Parameters:

Name Type
Type Constructor< UInt | Moment>

Returns: Constructor<Compact>


results matching ""

    No results matching ""