Namespace: cairo
Functions​
isCairo1Abi​
â–¸ isCairo1Abi(abi
): boolean
Test if an ABI comes from a Cairo 1 contract
Parameters​
Name | Type | Description |
---|---|---|
abi | Abi | representing the interface of a Cairo contract |
Returns​
boolean
TRUE if it is an ABI from a Cairo1 contract
Example
const isCairo1: boolean = isCairo1Abi(myAbi: Abi);
Defined in​
src/utils/calldata/cairo.ts:169
isTypeNonZero​
â–¸ isTypeNonZero(type
): boolean
Checks if the given type is a NonZero type.
Parameters​
Name | Type | Description |
---|---|---|
type | string | The type to check. |
Returns​
boolean
true
if the type is NonZero type, false
otherwise.
Example
const result = cairo.isTypeNonZero("core::zeroable::NonZero::<u8>");
//result = true
Defined in​
src/utils/calldata/cairo.ts:188
getAbiContractVersion​
â–¸ getAbiContractVersion(abi
): ContractVersion
Return ContractVersion (Abi version) based on Abi or undefined for unknown version
Parameters​
Name | Type |
---|---|
abi | Abi |
Returns​
string
Defined in​
src/utils/calldata/cairo.ts:198
felt​
â–¸ felt(it
): string
Create felt Cairo type (cairo type helper)
Parameters​
Name | Type |
---|---|
it | BigNumberish |
Returns​
string
format: felt-string
Defined in​
src/utils/calldata/cairo.ts:264
isLen​
â–¸ isLen(name
): boolean
Checks if the given name ends with "_len".
Parameters​
Name | Type | Description |
---|---|---|
name | string | The name to be checked. |
Returns​
boolean
- True if the name ends with "_len", false otherwise.
Defined in​
src/utils/calldata/cairo.ts:23
isTypeFelt​
â–¸ isTypeFelt(type
): boolean
Checks if a given type is felt.
Parameters​
Name | Type | Description |
---|---|---|
type | string | The type to check. |
Returns​
boolean
- True if the type is felt, false otherwise.
Defined in​
src/utils/calldata/cairo.ts:30
isTypeArray​
â–¸ isTypeArray(type
): boolean
Checks if the given type is an array type.
Parameters​
Name | Type | Description |
---|---|---|
type | string | The type to check. |
Returns​
boolean
true
if the type is an array type,false
otherwise.
Defined in​
src/utils/calldata/cairo.ts:37
isTypeTuple​
â–¸ isTypeTuple(type
): boolean
Checks if the given type is a tuple type.
Parameters​
Name | Type | Description |
---|---|---|
type | string | The type to be checked. |
Returns​
boolean
true
if the type is a tuple type, otherwisefalse
.
Defined in​
src/utils/calldata/cairo.ts:47
isTypeNamedTuple​
â–¸ isTypeNamedTuple(type
): boolean
Checks whether a given type is a named tuple.
Parameters​
Name | Type | Description |
---|---|---|
type | string | The type to be checked. |
Returns​
boolean
- True if the type is a named tuple, false otherwise.
Defined in​
src/utils/calldata/cairo.ts:54
isTypeStruct​
â–¸ isTypeStruct(type
, structs
): boolean
Checks if a given type is a struct.
Parameters​
Name | Type | Description |
---|---|---|
type | string | The type to check for existence. |
structs | AbiStructs | The collection of structs to search in. |
Returns​
boolean
- True if the type exists in the structs, false otherwise.
Defined in​
src/utils/calldata/cairo.ts:62
isTypeEnum​
â–¸ isTypeEnum(type
, enums
): boolean
Checks if a given type is an enum.
Parameters​
Name | Type | Description |
---|---|---|
type | string | The type to check. |
enums | AbiEnums | The enumeration to search in. |
Returns​
boolean
- True if the type exists in the enumeration, otherwise false.
Defined in​
src/utils/calldata/cairo.ts:70
isTypeOption​
â–¸ isTypeOption(type
): boolean
Determines if the given type is an Option type.
Parameters​
Name | Type | Description |
---|---|---|
type | string | The type to check. |
Returns​
boolean
- True if the type is an Option type, false otherwise.
Defined in​
src/utils/calldata/cairo.ts:77
isTypeResult​
â–¸ isTypeResult(type
): boolean
Checks whether a given type starts with 'core::result::Result::'.
Parameters​
Name | Type | Description |
---|---|---|
type | string | The type to check. |
Returns​
boolean
- True if the type starts with 'core::result::Result::', false otherwise.
Defined in​
src/utils/calldata/cairo.ts:84
isTypeUint​
â–¸ isTypeUint(type
): boolean
Checks if the given value is a valid Uint type.
Parameters​
Name | Type | Description |
---|---|---|
type | string | The value to check. |
Returns​
boolean
- Returns true if the value is a valid Uint type, otherwise false.
Defined in​
src/utils/calldata/cairo.ts:91
isTypeUint256​
â–¸ isTypeUint256(type
): boolean
Checks if the given type is uint256
.
Parameters​
Name | Type | Description |
---|---|---|
type | string | The type to be checked. |
Returns​
boolean
- Returns true if the type is
uint256
, otherwise false.
Defined in​
src/utils/calldata/cairo.ts:99
isTypeLiteral​
â–¸ isTypeLiteral(type
): boolean
Checks if the given type is a literal type.
Parameters​
Name | Type | Description |
---|---|---|
type | string | The type to check. |
Returns​
boolean
- True if the type is a literal type, false otherwise.
Defined in​
src/utils/calldata/cairo.ts:106
isTypeBool​
â–¸ isTypeBool(type
): boolean
Checks if the given type is a boolean type.
Parameters​
Name | Type | Description |
---|---|---|
type | string | The type to be checked. |
Returns​
boolean
- Returns true if the type is a boolean type, otherwise false.
Defined in​
src/utils/calldata/cairo.ts:113
isTypeContractAddress​
â–¸ isTypeContractAddress(type
): boolean
Checks if the provided type is equal to 'core::starknet::contract_address::ContractAddress'.
Parameters​
Name | Type | Description |
---|---|---|
type | string | The type to be checked. |
Returns​
boolean
- true if the type matches 'core::starknet::contract_address::ContractAddress', false otherwise.
Defined in​
src/utils/calldata/cairo.ts:119
isTypeEthAddress​
â–¸ isTypeEthAddress(type
): boolean
Determines if the given type is an Ethereum address type.
Parameters​
Name | Type | Description |
---|---|---|
type | string | The type to check. |
Returns​
boolean
- Returns true if the given type is 'core::starknet::eth_address::EthAddress', otherwise false.
Defined in​
src/utils/calldata/cairo.ts:127
isTypeBytes31​
â–¸ isTypeBytes31(type
): boolean
Checks if the given type is 'core::bytes_31::bytes31'.
Parameters​
Name | Type | Description |
---|---|---|
type | string | The type to check. |
Returns​
boolean
- True if the type is 'core::bytes_31::bytes31', false otherwise.
Defined in​
src/utils/calldata/cairo.ts:135
isTypeByteArray​
â–¸ isTypeByteArray(type
): boolean
Checks if the given type is equal to the 'core::byte_array::ByteArray'.
Parameters​
Name | Type | Description |
---|---|---|
type | string | The type to check. |
Returns​
boolean
- True if the given type is equal to 'core::byte_array::ByteArray', false otherwise.
Defined in​
src/utils/calldata/cairo.ts:142
isTypeSecp256k1Point​
â–¸ isTypeSecp256k1Point(type
): boolean
Parameters​
Name | Type |
---|---|
type | string |
Returns​
boolean
Defined in​
src/utils/calldata/cairo.ts:143
isCairo1Type​
â–¸ isCairo1Type(type
): boolean
Parameters​
Name | Type |
---|---|
type | string |
Returns​
boolean
Defined in​
src/utils/calldata/cairo.ts:145
getArrayType​
â–¸ getArrayType(type
): string
Retrieves the array type from the given type string.
Works also for core::zeroable::NonZero type.
Parameters​
Name | Type | Description |
---|---|---|
type | string | The type string. |
Returns​
string
- The array type.
Defined in​
src/utils/calldata/cairo.ts:153
uint256​
â–¸ uint256(it
): Uint256
Create Uint256 Cairo type (helper for common struct type)
Parameters​
Name | Type |
---|---|
it | BigNumberish |
Returns​
Example
uint256('892349863487563453485768723498');
Defined in​
src/utils/calldata/cairo.ts:232
uint512​
â–¸ uint512(it
): Uint512
Create Uint512 Cairo type (helper for common struct type)
Parameters​
Name | Type | Description |
---|---|---|
it | BigNumberish | BigNumberish representation of a 512 bits unsigned number |
Returns​
Uint512 struct
Example
uint512('345745685892349863487563453485768723498');
Defined in​
src/utils/calldata/cairo.ts:245
tuple​
â–¸ tuple(...args
): Record
<number
, boolean
| object
| BigNumberish
>
Create unnamed tuple Cairo type (helper same as common struct type)
Parameters​
Name | Type |
---|---|
...args | (boolean | object | BigNumberish )[] |
Returns​
Record
<number
, boolean
| object
| BigNumberish
>
Example
tuple(1, '0x101', 16);