Skip to main content
Version: Next

Class: CairoCustomEnum

Class to handle Cairo custom Enum

Param

object containing the variants and its content. Example : {Success: 234, Warning: undefined, Error: undefined}. Only one variant with a value, object, array.

Example

const myCairoEnum = new CairoCustomEnum( {Success: undefined, Warning: "0x7f32ea", Error: undefined})

Constructors​

constructor​

• new CairoCustomEnum(enumContent): CairoCustomEnum

Parameters​

NameTypeDescription
enumContentCairoEnumRawan object with the variants as keys and the content as value. Only one content shall be defined.

Returns​

CairoCustomEnum

Defined in​

src/utils/calldata/enum/CairoCustomEnum.ts:29

Properties​

variant​

• Readonly variant: CairoEnumRaw

direct readonly access to variants of the Cairo Custom Enum.

Example

const successValue = myCairoEnum.variant.Success;

#### Defined in

[src/utils/calldata/enum/CairoCustomEnum.ts:24](https://github.com/starknet-io/starknet.js/blob/develop/src/utils/calldata/enum/CairoCustomEnum.ts#L24)

## Methods

### unwrap

â–¸ **unwrap**(): `any`

#### Returns

`any`

the content of the valid variant of a Cairo custom Enum.

#### Defined in

[src/utils/calldata/enum/CairoCustomEnum.ts:45](https://github.com/starknet-io/starknet.js/blob/develop/src/utils/calldata/enum/CairoCustomEnum.ts#L45)

___

### activeVariant

â–¸ **activeVariant**(): `string`

#### Returns

`string`

the name of the valid variant of a Cairo custom Enum.

#### Defined in

[src/utils/calldata/enum/CairoCustomEnum.ts:54](https://github.com/starknet-io/starknet.js/blob/develop/src/utils/calldata/enum/CairoCustomEnum.ts#L54)