algokit_utils.applications.abi ============================== .. py:module:: algokit_utils.applications.abi Attributes ---------- .. autoapisummary:: algokit_utils.applications.abi.ABIValue algokit_utils.applications.abi.ABIStruct algokit_utils.applications.abi.Arc56ReturnValueType algokit_utils.applications.abi.ABIType algokit_utils.applications.abi.ABIArgumentType Classes ------- .. autoapisummary:: algokit_utils.applications.abi.ABIReturn algokit_utils.applications.abi.BoxABIValue Functions --------- .. autoapisummary:: algokit_utils.applications.abi.get_arc56_value algokit_utils.applications.abi.get_abi_encoded_value algokit_utils.applications.abi.get_abi_decoded_value algokit_utils.applications.abi.get_abi_tuple_from_abi_struct algokit_utils.applications.abi.get_abi_tuple_type_from_abi_struct_definition algokit_utils.applications.abi.get_abi_struct_from_abi_tuple Module Contents --------------- .. py:data:: ABIValue :type: TypeAlias :value: bool | int | str | bytes | bytearray | list['ABIValue'] | tuple['ABIValue'] | dict[str, 'ABIValue'] .. py:data:: ABIStruct :type: TypeAlias :value: dict[str, list[dict[str, 'ABIValue']]] .. py:data:: Arc56ReturnValueType :type: TypeAlias :value: ABIValue | ABIStruct | None .. py:data:: ABIType :type: TypeAlias :value: algosdk.abi.ABIType .. py:data:: ABIArgumentType :type: TypeAlias :value: algosdk.abi.ABIType | algosdk.abi.ABITransactionType | algosdk.abi.ABIReferenceType .. py:class:: ABIReturn(result: algosdk.atomic_transaction_composer.ABIResult) Represents the return value from an ABI method call. Wraps the raw return value and decoded value along with any decode errors. .. py:attribute:: raw_value :type: bytes | None :value: None The raw return value from the method call .. py:attribute:: value :type: ABIValue | None :value: None The decoded return value from the method call .. py:attribute:: method :type: algosdk.abi.method.Method | None :value: None The ABI method definition .. py:attribute:: decode_error :type: Exception | None :value: None The exception that occurred during decoding, if any .. py:attribute:: tx_info :type: dict[str, Any] | None :value: None The transaction info for the method call from raw algosdk `ABIResult` .. py:property:: is_success :type: bool Returns True if the ABI call was successful (no decode error) :return: True if no decode error occurred, False otherwise .. py:method:: get_arc56_value(method: algokit_utils.applications.app_spec.arc56.Method | algosdk.abi.method.Method, structs: dict[str, list[algokit_utils.applications.app_spec.arc56.StructField]]) -> Arc56ReturnValueType Gets the ARC-56 formatted return value. :param method: The ABI method definition :param structs: Dictionary of struct definitions :return: The decoded return value in ARC-56 format .. py:function:: get_arc56_value(abi_return: ABIReturn, method: algokit_utils.applications.app_spec.arc56.Method | algosdk.abi.method.Method, structs: dict[str, list[algokit_utils.applications.app_spec.arc56.StructField]]) -> Arc56ReturnValueType Gets the ARC-56 formatted return value from an ABI return. :param abi_return: The ABI return value to decode :param method: The ABI method definition :param structs: Dictionary of struct definitions :raises ValueError: If there was an error decoding the return value :return: The decoded return value in ARC-56 format .. py:function:: get_abi_encoded_value(value: Any, type_str: str, structs: dict[str, list[algokit_utils.applications.app_spec.arc56.StructField]]) -> bytes Encodes a value according to its ABI type. :param value: The value to encode :param type_str: The ABI type string :param structs: Dictionary of struct definitions :raises ValueError: If the value cannot be encoded for the given type :return: The ABI encoded bytes .. py:function:: get_abi_decoded_value(value: bytes | int | str, type_str: str | ABIArgumentType, structs: dict[str, list[algokit_utils.applications.app_spec.arc56.StructField]]) -> ABIValue Decodes a value according to its ABI type. :param value: The value to decode :param type_str: The ABI type string or type object :param structs: Dictionary of struct definitions :return: The decoded ABI value .. py:function:: get_abi_tuple_from_abi_struct(struct_value: dict[str, Any], struct_fields: list[algokit_utils.applications.app_spec.arc56.StructField], structs: dict[str, list[algokit_utils.applications.app_spec.arc56.StructField]]) -> list[Any] Converts an ABI struct to a tuple representation. :param struct_value: The struct value as a dictionary :param struct_fields: List of struct field definitions :param structs: Dictionary of struct definitions :raises ValueError: If a required field is missing from the struct :return: The struct as a tuple .. py:function:: get_abi_tuple_type_from_abi_struct_definition(struct_def: list[algokit_utils.applications.app_spec.arc56.StructField], structs: dict[str, list[algokit_utils.applications.app_spec.arc56.StructField]]) -> algosdk.abi.TupleType Creates a TupleType from a struct definition. :param struct_def: The struct field definitions :param structs: Dictionary of struct definitions :raises ValueError: If a field type is invalid :return: The TupleType representing the struct .. py:function:: get_abi_struct_from_abi_tuple(decoded_tuple: Any, struct_fields: list[algokit_utils.applications.app_spec.arc56.StructField], structs: dict[str, list[algokit_utils.applications.app_spec.arc56.StructField]]) -> dict[str, Any] Converts a decoded tuple to an ABI struct. :param decoded_tuple: The tuple to convert :param struct_fields: List of struct field definitions :param structs: Dictionary of struct definitions :return: The tuple as a struct dictionary .. py:class:: BoxABIValue Represents an ABI value stored in a box. .. py:attribute:: name :type: algokit_utils.models.state.BoxName The name of the box .. py:attribute:: value :type: ABIValue The ABI value stored in the box