Skip to main content
Version: Next

Class: CairoOption<T>

Class to handle Cairo Option

Param

CairoOptionVariant.Some or CairoOptionVariant.None

Param

value of type T.

Example

const myOption = new CairoOption<BigNumberish>(CairoOptionVariant.Some, "0x54dda8");

Type parameters

Name
T

Constructors

constructor

new CairoOption<T>(variant, someContent?)

Type parameters

Name
T

Parameters

NameType
variantCairoOptionVariant
someContent?T

Defined in

src/utils/calldata/enum/CairoOption.ts:20

Properties

Some

Optional Readonly Some: T

Defined in

src/utils/calldata/enum/CairoOption.ts:16


None

Optional Readonly None: boolean

Defined in

src/utils/calldata/enum/CairoOption.ts:18

Methods

unwrap

unwrap(): undefined | T

Returns

undefined | T

the content of the valid variant of a Cairo custom Enum. If None, returns 'undefined'.

Defined in

src/utils/calldata/enum/CairoOption.ts:43


isSome

isSome(): boolean

Returns

boolean

true if the valid variant is 'isSome'.

Defined in

src/utils/calldata/enum/CairoOption.ts:54


isNone

isNone(): boolean

Returns

boolean

true if the valid variant is 'isNone'.

Defined in

src/utils/calldata/enum/CairoOption.ts:62