Skip to main content
Version: 11.x

Function: isCairoType()

isCairoType(value): value is CairoType

Defined in: src/utils/cairoDataTypes/cairoType.interface.ts:44

Is this value one of the Cairo type classes, rather than the raw data one is built from?

The composites accept both — [1, 2] and [new CairoUint8(1), new CairoUint8(2)] describe the same array — and this is what tells them apart. It asks for a callable toApiRequest, so an object merely carrying a property of that name is not mistaken for one.

Parameters

value

unknown

the value to test

Returns

value is CairoType

true when the value can serialize itself

Example

const result = isCairoType(new CairoUint8(44));
// result = true
const result2 = isCairoType(44);
// result2 = false
const result3 = isCairoType({ toApiRequest: 'not a function' });
// result3 = false