name: Enum

description: A codec wrapper for an enum. Enums are encoded as a single byte, where the byte is a zero-indexed value. This class allows you to retrieve the value either by toNumber() exposing the actual raw index, or toString() returning a string representation (as provided as part of the constructor)

Hierarchy

Base<number>

↳ Enum

↳ StorageFunctionModifier

↳ NewAccountOutcome

↳ VoteThreshold

Implements

Constructors

constructor

⊕ new Enum(def: EnumDef, value?: Enum | Uint8Array | string | number): Enum

Overrides Base.constructor

Defined in codec/Enum.ts:29

Parameters:

Name Type Default value
def EnumDef -
Default value value Enum | Uint8Array | string | number 0

Returns: Enum


Accessors

encodedLength

get encodedLength(): number

Defined in codec/Enum.ts:64

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

Returns: number


isEmpty

get isEmpty(): boolean

Defined in codec/Enum.ts:71

description: Checks if the value is an empty value (always false)

Returns: boolean


Methods

eq

▸ eq(other?: any): boolean

Implementation of Codec.eq

Defined in codec/Enum.ts:78

description: Compares the value of the input to see if there is a match

Parameters:

Name Type
Optional other any

Returns: boolean


toHex

▸ toHex(): string

Implementation of Codec.toHex

Defined in codec/Enum.ts:91

description: Returns a hex string representation of the value

Returns: string


toJSON

▸ toJSON(): any

Implementation of Codec.toJSON

Defined in codec/Enum.ts:98

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

Returns: any


toNumber

▸ toNumber(): number

Defined in codec/Enum.ts:105

description: Returns the number representation for the value

Returns: number


toString

▸ toString(): string

Implementation of Codec.toString

Defined in codec/Enum.ts:112

description: Returns the string representation of the value

Returns: string


toU8a

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

Implementation of Codec.toU8a

Defined in codec/Enum.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> decodeEnum

▸ decodeEnum(def: EnumDef, value: Enum | Uint8Array | string | number): number | undefined

Defined in codec/Enum.ts:47

Parameters:

Name Type
def EnumDef
value Enum | Uint8Array | string | number

Returns: number | undefined


Last Updated: 2/25/2019, 4:39:16 PM