Abstract Class: AbiParserInterface
Defined in: src/utils/calldata/parser/interface.ts:11
Abi parser interface
Beyond reading the abi's shape, a parser is what turns a value into felts and reads one back.
Both directions go through parseRequestField and parseResponse, so that a caller — CallData,
parseEvents — never has to know which parser it holds, nor how that one serializes.
Constructors
Constructor
new AbiParserInterface():
AbiParserInterface
Returns
AbiParserInterface
Properties
parsingStrategies
abstractparsingStrategies:CairoTypeStrategy[]
Defined in: src/utils/calldata/parser/interface.ts:28
The strategies this parser drives the Cairo type classes with, assembled from the abi.
Reachable because it is the only way to get a strategy that knows a contract's own types: the
language's types are in cairoTypeStrategy, but a struct or a custom enum is keyed by the
name the contract chose, and this is where those names are registered. Building a
CairoStruct or a CairoArray over one of them takes what is here:
const strategies = myCallData.parser.parsingStrategies;
const points = new CairoArray(list, 'core::array::Array::<my::Point>', strategies);
Empty on a Cairo 0 parser, which serializes without those classes — never absent, so that a caller reading it does not have to prove it exists before using it.
Methods
methodInputsLength()
abstractmethodInputsLength(abiMethod):number
Defined in: src/utils/calldata/parser/interface.ts:35
Helper to calculate inputs length from abi
Parameters
abiMethod
FunctionAbi
Returns
number
number
getMethod()
abstractgetMethod(name):FunctionAbi|undefined
Defined in: src/utils/calldata/parser/interface.ts:42
get method definition from abi
Parameters
name
string
string
Returns
FunctionAbi | undefined
FunctionAbi | undefined
getLegacyFormat()
abstractgetLegacyFormat():Abi
Defined in: src/utils/calldata/parser/interface.ts:48
Return Abi in legacy format
Returns
Abi
validateRequestFields()
abstractvalidateRequestFields(abiMethod,args):void
Defined in: src/utils/calldata/parser/interface.ts:60
Check the arguments of a method before any of them is serialized
Only a parser that does not build Cairo types has anything to do here: where those classes are what serializes, they check as they build, and checking beforehand would build twice.
Parameters
abiMethod
the method the arguments are meant for
args
any[]
the arguments, in the abi's order
Returns
void
parseRequestField()
abstractparseRequestField(value,input):string|string[]
Defined in: src/utils/calldata/parser/interface.ts:68
Serialize one argument to the felts a contract call carries
Parameters
value
unknown
the argument to serialize
input
the abi entry this argument stands for, whose name the errors quote
Returns
string | string[]
string | string[]
parseResponse()
abstractparseResponse(responseIterator,output,parsedResult?):any
Defined in: src/utils/calldata/parser/interface.ts:77
Read one value off a contract response, advancing the iterator past it
Parameters
responseIterator
Iterator<string>
the response felts, positioned on this value
output
the abi entry describing what to read
parsedResult?
what has been read so far, where a Cairo 0 array finds its ${name}_len
Returns
any
any