Skip to main content
Version: 6.11.0

Class: CairoResult<T, U>

Class to handle Cairo Result

Param

CairoResultVariant.Ok or CairoResultVariant.Err

Param

value of type T or U.

Example

const myOption = new CairoResult<BigNumberish, CustomError>(CairoResultVariant.Ok, '0x54dda8');

Type parameters​

Name
T
U

Constructors​

constructor​

• new CairoResult<T, U>(variant, resultContent): CairoResult<T, U>

Type parameters​

Name
T
U

Parameters​

NameType
variantCairoResultVariant
resultContentT | U

Returns​

CairoResult<T, U>

Defined in​

src/utils/calldata/enum/CairoResult.ts:21

Properties​

Ok​

• Optional Readonly Ok: T

Defined in​

src/utils/calldata/enum/CairoResult.ts:17


Err​

• Optional Readonly Err: U

Defined in​

src/utils/calldata/enum/CairoResult.ts:19

Methods​

unwrap​

â–¸ unwrap(): T | U

Returns​

T | U

the content of the valid variant of a Cairo Result.

Defined in​

src/utils/calldata/enum/CairoResult.ts:38


isOk​

â–¸ isOk(): boolean

Returns​

boolean

true if the valid variant is 'Ok'.

Defined in​

src/utils/calldata/enum/CairoResult.ts:52


isErr​

â–¸ isErr(): boolean

Returns​

boolean

true if the valid variant is 'isErr'.

Defined in​

src/utils/calldata/enum/CairoResult.ts:60