Class: CairoFixedArray
Defined in: src/utils/cairoDataTypes/fixedArray.ts:3
Constructors
Constructor
new CairoFixedArray(
content,arrayType):CairoFixedArray
Defined in: src/utils/cairoDataTypes/fixedArray.ts:19
Create an instance representing a Cairo fixed Array.
Parameters
content
any[]
JS array representing a Cairo fixed array.
arrayType
string
Cairo fixed array type.
Returns
CairoFixedArray
Properties
content
readonlycontent:any[]
Defined in: src/utils/cairoDataTypes/fixedArray.ts:7
JS array representing a Cairo fixed array.
arrayType
readonlyarrayType:string
Defined in: src/utils/cairoDataTypes/fixedArray.ts:12
Cairo fixed array type.
Methods
getFixedArraySize()
staticgetFixedArraySize(type):number
Defined in: src/utils/cairoDataTypes/fixedArray.ts:62
Retrieves the array size from the given type string representing a Cairo fixed array.
Parameters
type
string
The Cairo fixed array type.
Returns
number
The array size.
Example
const result = CairoFixedArray.getFixedArraySize("[core::integer::u32; 8]");
// result = 8
getFixedArrayType()
staticgetFixedArrayType(type):string
Defined in: src/utils/cairoDataTypes/fixedArray.ts:93
Retrieve the Cairo content type from a Cairo fixed array type.
Parameters
type
string
The type string.
Returns
string
The fixed-array type.
Example
const result = CairoFixedArray.getFixedArrayType("[core::integer::u32; 8]");
// result = "core::integer::u32"
compile()
staticcompile(input):Object
Defined in: src/utils/cairoDataTypes/fixedArray.ts:126
Create an object from a Cairo fixed array. Be sure to have an array length conform to the ABI. To be used with CallData.compile().
Parameters
input
any[]
JS array representing a Cairo fixed array.
Returns
Object
a specific struct representing a fixed Array.
Example
const result = CairoFixedArray.compile([10,20,30]);
// result = { '0': 10, '1': 20, '2': 30 }
isTypeFixedArray()
staticisTypeFixedArray(type):boolean
Defined in: src/utils/cairoDataTypes/fixedArray.ts:158
Checks if the given Cairo type is a fixed-array type. structure: [string; number]
Parameters
type
string
The type to check.
Returns
boolean
trueif the type is a fixed array type,falseotherwise.
const result = CairoFixedArray.isTypeFixedArray("[core::integer::u32; 8]");
// result = true
***
### getFixedArraySize()
> **getFixedArraySize**(): `number`
Defined in: [src/utils/cairoDataTypes/fixedArray.ts:79](https://github.com/starknet-io/starknet.js/blob/develop/src/utils/cairoDataTypes/fixedArray.ts#L79)
Retrieves the Cairo fixed array size from the CairoFixedArray instance.
#### Returns
`number`
The fixed array size.
#### Example
```typescript
const fArray = new CairoFixedArray([10,20,30], "[core::integer::u32; 3]");
const result = fArray.getFixedArraySize();
// result = 3
getFixedArrayType()
getFixedArrayType():
string
Defined in: src/utils/cairoDataTypes/fixedArray.ts:110
Retrieve the Cairo content type of the Cairo fixed array.
Returns
string
The fixed-array content type.
Example
const fArray = new CairoFixedArray([10,20,30], "[core::integer::u32; 3]");
const result = fArray.getFixedArrayType();
// result = "core::integer::u32"
compile()
compile():
Object
Defined in: src/utils/cairoDataTypes/fixedArray.ts:144
Generate an object from the Cairo fixed array instance. To be used with CallData.compile().
Returns
Object
a specific struct representing a fixed array.
Example
const fArray = new CairoFixedArray([10,20,30], "[core::integer::u32; 3]");
const result = fArray.compile();
// result = { '0': 10, '1': 20, '2': 30 }