Skip to main content
Version: Next

Function: parseCalldataField()

parseCalldataField(argsIterator): string | string[]

Defined in: src/utils/calldata/requestParser.ts:416

Parse one field of the calldata by using input field from the abi for that method

Parameters

argsIterator

Iterator for value of the field

argsIterator

Iterator<any>

input

AbiEntry

structs

AbiStructs

enums

AbiEnums

parser

AbiParserInterface

Returns

string | string[]

  • parsed arguments in format that contract is expecting

Example

const abiEntry = { name: 'test', type: 'struct' };
const abiStructs: AbiStructs = {
struct: {
members: [
{
name: 'test_name',
type: 'test_type',
offset: 1,
},
],
size: 2,
name: 'cairo__struct',
type: 'struct',
},
};

const abiEnums: AbiEnums = {
enum: {
variants: [
{
name: 'test_name',
type: 'cairo_struct_variant',
offset: 1,
},
],
size: 2,
name: 'test_cairo',
type: 'enum',
},
};

const args = [{ test_name: 'test' }];
const argsIterator = args[Symbol.iterator]();
const parsedField = parseCalldataField(
argsIterator,
abiEntry,
abiStructs,
abiEnums
);
// parsedField === ['1952805748']