Skip to main content
Version: 5.19.5

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)

Type parameters​

Name
T
U

Parameters​

NameType
variantCairoResultVariant
resultContentT | U

Defined in​

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

Properties​

Ok​

• Optional Readonly Ok: T

Defined in​

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


Err​

• Optional Readonly Err: U

Defined in​

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

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:37


isOk​

â–¸ isOk(): boolean

Returns​

boolean

true if the valid variant is 'Ok'.

Defined in​

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


isErr​

â–¸ isErr(): boolean

Returns​

boolean

true if the valid variant is 'isErr'.

Defined in​

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