Polkadot JS APIGlobals"codec/Enum"Enum

# Class: Enum

name Enum

description This implements an enum, that based on the value wraps a different type. It is effectively an extension to enum where the value type is determined by the actual index.

# Hierarchy

# Implements

# Index

# Constructors

# Properties

# Accessors

# Methods

# Constructors

# constructor

+ new Enum(registry: Registry, def: Record‹string, keyof InterfaceTypes | Constructor› | string[], value?: unknown, index?: undefined | number): Enum

Overrides void

Defined in packages/types/src/codec/Enum.ts:124

Parameters:

Name Type
registry Registry
def Record‹string, keyof InterfaceTypes | Constructor› | string[]
value? unknown
index? undefined | number

Returns: Enum

# Properties

# Readonly registry

registry: Registry

Implementation of Codec.registry

Inherited from Base.registry

Defined in packages/types/src/codec/Base.ts:17

# Accessors

# defEntries

get defEntries(): string[]

Defined in packages/types/src/codec/Enum.ts:212

description The available keys for this enum

Returns: string[]


# defKeys

get defKeys(): string[]

Defined in packages/types/src/codec/Enum.ts:219

description The available keys for this enum

Returns: string[]


# encodedLength

get encodedLength(): number

Overrides Base.encodedLength

Defined in packages/types/src/codec/Enum.ts:177

description The length of the value when encoded as a Uint8Array

Returns: number


# hash

get hash(): H256

Inherited from Base.hash

Defined in packages/types/src/codec/Base.ts:36

description returns a hash of the contents

Returns: H256


# index

get index(): number

Defined in packages/types/src/codec/Enum.ts:184

description The index of the metadata value

Returns: number


# isBasic

get isBasic(): boolean

Defined in packages/types/src/codec/Enum.ts:191

description true if this is a basic enum (no values)

Returns: boolean


# isEmpty

get isEmpty(): boolean

Inherited from Base.isEmpty

Defined in packages/types/src/codec/Base.ts:43

description Checks if the value is an empty value

Returns: boolean


# isNone

get isNone(): boolean

Defined in packages/types/src/codec/Enum.ts:198

description Checks if the Enum points to a Null type

Returns: boolean


# isNull

get isNull(): boolean

Defined in packages/types/src/codec/Enum.ts:205

description Checks if the Enum points to a Null type (deprecated, use isNone)

Returns: boolean


# type

get type(): string

Defined in packages/types/src/codec/Enum.ts:226

description The name of the type this enum value represents

Returns: string


# value

get value(): Codec

Defined in packages/types/src/codec/Enum.ts:233

description The value of the enum

Returns: Codec

# Methods

# eq

eq(other?: unknown): boolean

Implementation of Codec

Overrides Base.eq

Defined in packages/types/src/codec/Enum.ts:240

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

Parameters:

Name Type
other? unknown

Returns: boolean


# toHex

toHex(): string

Overrides Base.toHex

Defined in packages/types/src/codec/Enum.ts:263

description Returns a hex string representation of the value

Returns: string


# toHuman

toHuman(isExtended?: undefined | false | true): AnyJson

Implementation of Codec

Overrides Base.toHuman

Defined in packages/types/src/codec/Enum.ts:270

description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information

Parameters:

Name Type
isExtended? undefined | false | true

Returns: AnyJson


# toJSON

toJSON(): AnyJson

Implementation of Codec

Overrides Base.toJSON

Defined in packages/types/src/codec/Enum.ts:279

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

Returns: AnyJson


# toNumber

toNumber(): number

Defined in packages/types/src/codec/Enum.ts:288

description Returns the number representation for the value

Returns: number


# toRawType

toRawType(): string

Implementation of Codec

Overrides Base.toRawType

Defined in packages/types/src/codec/Enum.ts:304

description Returns the base runtime type name for this instance

Returns: string


# toString

toString(): string

Implementation of Codec

Overrides Base.toString

Defined in packages/types/src/codec/Enum.ts:311

description Returns the string representation of the value

Returns: string


# toU8a

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

Overrides Base.toU8a

Defined in packages/types/src/codec/Enum.ts:321

description Encodes the value as a Uint8Array as per the SCALE specifications

Parameters:

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

Returns: Uint8Array


# Static with

with(Types: Record‹string, keyof InterfaceTypes | Constructor› | string[]): EnumConstructorEnum

Defined in packages/types/src/codec/Enum.ts:138

Parameters:

Name Type
Types Record‹string, keyof InterfaceTypes | Constructor› | string[]

Returns: EnumConstructorEnum