Class: CallData
Constructors​
constructor​
• new CallData(abi
)
Parameters​
Name | Type |
---|---|
abi | Abi |
Defined in​
src/utils/calldata/index.ts:33
Properties​
abi​
• abi: Abi
Defined in​
src/utils/calldata/index.ts:29
structs​
• Protected
Readonly
structs: AbiStructs
Defined in​
src/utils/calldata/index.ts:31
Methods​
compile​
â–¸ Static
compile(rawArgs
): Calldata
Compile contract callData without abi
Parameters​
Name | Type | Description |
---|---|---|
rawArgs | RawArgs | RawArgs representing cairo method arguments or string array of compiled data |
Returns​
Calldata
Defined in​
src/utils/calldata/index.ts:120
abiInputsLength​
â–¸ Static
abiInputsLength(inputs
): number
Helper to calculate inputs from abi
Parameters​
Name | Type | Description |
---|---|---|
inputs | AbiEntry [] | AbiEntry |
Returns​
number
number
Defined in​
src/utils/calldata/index.ts:201
getAbiStruct​
â–¸ Static
getAbiStruct(abi
): AbiStructs
Helper to extract structs from abi
Parameters​
Name | Type | Description |
---|---|---|
abi | Abi | Abi |
Returns​
AbiStructs - structs from abi
Defined in​
src/utils/calldata/index.ts:210
toCalldata​
â–¸ Static
toCalldata(rawCalldata?
): Calldata
Helper: Compile HexCalldata | RawCalldata | RawArgs
Parameters​
Name | Type | Default value | Description |
---|---|---|---|
rawCalldata | RawArgs | [] | HexCalldata | RawCalldata | RawArgs |
Returns​
Calldata
Defined in​
src/utils/calldata/index.ts:227
toHex​
â–¸ Static
toHex(raw?
): HexCalldata
Helper: Convert raw to HexCalldata
Parameters​
Name | Type | Default value | Description |
---|---|---|---|
raw | RawArgs | [] | HexCalldata | RawCalldata | RawArgs |
Returns​
HexCalldata
Defined in​
src/utils/calldata/index.ts:236
validate​
â–¸ validate(type
, method
, args?
): void
Validate arguments passed to the method as corresponding to the ones in the abi
Parameters​
Name | Type | Default value | Description |
---|---|---|---|
type | "DEPLOY" | "INVOKE" | "CALL" | undefined | string - type of the method |
method | string | undefined | string - name of the method |
args | ArgsOrCalldata | [] | ArgsOrCalldata - arguments that are passed to the method |
Returns​
void
Defined in​
src/utils/calldata/index.ts:44
compile​
â–¸ compile(method
, argsCalldata
): Calldata
Compile contract callData with abi Parse the calldata by using input fields from the abi for that method
Example
const calldata = myCallData.compile('constructor', ['0x34a', [1, 3n]]);
const calldata2 = myCallData.compile('constructor', { list: [1, 3n], balance: '0x34' }); // wrong order is valid
Parameters​
Name | Type | Description |
---|---|---|
method | string | string - method name |
argsCalldata | RawArgs | - |
Returns​
Calldata - parsed arguments in format that contract is expecting
Defined in​
src/utils/calldata/index.ts:93
parse​
â–¸ parse(method
, response
): Result
Parse elements of the response array and structuring them into response object
Parameters​
Name | Type | Description |
---|---|---|
method | string | string - method name |
response | string [] | string[] - response from the method |
Returns​
Result - parsed response corresponding to the abi
Defined in​
src/utils/calldata/index.ts:167
format​
â–¸ format(method
, response
, format
): Result
Format cairo method response data to native js values based on provided format schema
Parameters​
Name | Type | Description |
---|---|---|
method | string | string - cairo method name |
response | string [] | string[] - cairo method response |
format | object | object - formatter object schema |
Returns​
Result - parsed and formatted response object