Parse#

nethermind.starknet_abi.parse.extract_inner_type(abi_type: str) str#

Extracts the inner type from a type string

>>> extract_inner_type("core::array::Array::<core::option::Option::<core::felt252>>")
'core::option::Option::<core::felt252>'
nethermind.starknet_abi.parse.group_abi_by_type(abi_json: list[dict]) defaultdict[Literal['function', 'l1_handler', 'struct', 'constructor', 'event', 'interface', 'impl', 'type_def'], list[dict]]#

Groups ABI JSON by ABI Type. If type is ‘struct’ or ‘enum’, it is grouped as a ‘type_def’

nethermind.starknet_abi.parse.parse_abi_event(abi_event: dict[str, Any], custom_types: dict[str, nethermind.starknet_abi.abi_types.StarknetStruct | nethermind.starknet_abi.abi_types.StarknetEnum]) AbiEvent | None#

Parses JSON Representation of an Event into an AbiEvent object.

Parameters:
  • abi_event

  • custom_types

nethermind.starknet_abi.parse.parse_abi_function(abi_function: dict[str, Any], custom_types: dict[str, nethermind.starknet_abi.abi_types.StarknetStruct | nethermind.starknet_abi.abi_types.StarknetEnum]) AbiFunction#

Parses JSON Representation of a Function into an AbiFunction object.

Parameters:
  • abi_function

  • custom_types

nethermind.starknet_abi.parse.parse_abi_parameters(names: list[str], types: list[str], custom_types: dict[str, nethermind.starknet_abi.abi_types.StarknetStruct | nethermind.starknet_abi.abi_types.StarknetEnum])#

Parses ABIs with wildcard syntax. If felt* is detected, it is parsed as an array of Felt, and the felt_len parameter is omitted from the parsed type

nethermind.starknet_abi.parse.parse_abi_types(types: list[str], custom_types: dict[str, nethermind.starknet_abi.abi_types.StarknetStruct | nethermind.starknet_abi.abi_types.StarknetEnum])#

Parses a list of ABI types into StarknetTypes while maintaining wildcard syntax definitions.

nethermind.starknet_abi.parse.parse_enums_and_structs(abi_structs: list[dict]) dict[str, nethermind.starknet_abi.abi_types.StarknetStruct | nethermind.starknet_abi.abi_types.StarknetEnum]#

Parses an ordered array of ABI structs into a dictionary of StarknetStructs, mapping struct name to struct.

Parameters:

abi_structs

nethermind.starknet_abi.parse.topo_sort_type_defs(type_defs: list[dict]) list[dict]#

Topographically sorts Struct and Enum definitions. If ABI Parsing fails.

Since most StarknetABIs are already sorted, the parser optimistically runs through the ABI, and if an error occurs, the Enum and Struct definitions are sorted before re-parsing. If this second attempt at parsing fails, it raises a detailed error message with the ABI Type that is not defined.

Parameters:

type_defs