algokit-utils 5.0.0a3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- algokit_abi/__init__.py +9 -0
- algokit_abi/_arc32_to_arc56.py +242 -0
- algokit_abi/_arc56_serde.py +161 -0
- algokit_abi/abi.py +667 -0
- algokit_abi/arc32.py +210 -0
- algokit_abi/arc56.py +821 -0
- algokit_abi/py.typed +0 -0
- algokit_algo25/__init__.py +38 -0
- algokit_algo25/_encoding.py +46 -0
- algokit_algo25/_wordlist.py +2065 -0
- algokit_algo25/exceptions.py +29 -0
- algokit_algo25/mnemonic.py +128 -0
- algokit_algo25/py.typed +0 -0
- algokit_algod_client/__init__.py +10 -0
- algokit_algod_client/client.py +1585 -0
- algokit_algod_client/config.py +36 -0
- algokit_algod_client/exceptions.py +59 -0
- algokit_algod_client/models/__init__.py +229 -0
- algokit_algod_client/models/_account.py +150 -0
- algokit_algod_client/models/_account_application_response.py +25 -0
- algokit_algod_client/models/_account_asset_response.py +25 -0
- algokit_algod_client/models/_account_participation.py +53 -0
- algokit_algod_client/models/_account_state_delta.py +30 -0
- algokit_algod_client/models/_allocations_for_genesis_file.py +23 -0
- algokit_algod_client/models/_allocations_for_genesis_file_state_model.py +42 -0
- algokit_algod_client/models/_application.py +23 -0
- algokit_algod_client/models/_application_initial_states.py +37 -0
- algokit_algod_client/models/_application_kvstorage.py +29 -0
- algokit_algod_client/models/_application_local_state.py +33 -0
- algokit_algod_client/models/_application_params.py +63 -0
- algokit_algod_client/models/_application_state_operation.py +41 -0
- algokit_algod_client/models/_application_state_schema.py +22 -0
- algokit_algod_client/models/_asset.py +23 -0
- algokit_algod_client/models/_asset_holding.py +29 -0
- algokit_algod_client/models/_asset_params.py +102 -0
- algokit_algod_client/models/_avm_key_value.py +28 -0
- algokit_algod_client/models/_avm_value.py +32 -0
- algokit_algod_client/models/_block.py +363 -0
- algokit_algod_client/models/_block_hash_response.py +14 -0
- algokit_algod_client/models/_block_txids_response.py +14 -0
- algokit_algod_client/models/_box.py +36 -0
- algokit_algod_client/models/_box_descriptor.py +24 -0
- algokit_algod_client/models/_boxes_response.py +21 -0
- algokit_algod_client/models/_build_version_contains_the_current_algod_build_version_information.py +34 -0
- algokit_algod_client/models/_compile_response.py +24 -0
- algokit_algod_client/models/_disassemble_response.py +14 -0
- algokit_algod_client/models/_error_response.py +22 -0
- algokit_algod_client/models/_eval_delta.py +32 -0
- algokit_algod_client/models/_eval_delta_key_value.py +28 -0
- algokit_algod_client/models/_genesis_file_in_json.py +53 -0
- algokit_algod_client/models/_get_block_time_stamp_offset_response.py +14 -0
- algokit_algod_client/models/_get_sync_round_response.py +14 -0
- algokit_algod_client/models/_ledger_state_delta.py +389 -0
- algokit_algod_client/models/_light_block_header_proof.py +32 -0
- algokit_algod_client/models/_node_status_response.py +118 -0
- algokit_algod_client/models/_pending_transaction_response.py +91 -0
- algokit_algod_client/models/_pending_transactions_response.py +29 -0
- algokit_algod_client/models/_post_transactions_response.py +14 -0
- algokit_algod_client/models/_scratch_change.py +23 -0
- algokit_algod_client/models/_serde_helpers.py +241 -0
- algokit_algod_client/models/_simulate_initial_states.py +25 -0
- algokit_algod_client/models/_simulate_request.py +54 -0
- algokit_algod_client/models/_simulate_request_transaction_group.py +25 -0
- algokit_algod_client/models/_simulate_response.py +44 -0
- algokit_algod_client/models/_simulate_trace_config.py +30 -0
- algokit_algod_client/models/_simulate_transaction_group_result.py +46 -0
- algokit_algod_client/models/_simulate_transaction_result.py +41 -0
- algokit_algod_client/models/_simulate_unnamed_resources_accessed.py +64 -0
- algokit_algod_client/models/_simulation_eval_overrides.py +40 -0
- algokit_algod_client/models/_simulation_opcode_trace_unit.py +55 -0
- algokit_algod_client/models/_simulation_transaction_exec_trace.py +82 -0
- algokit_algod_client/models/_source_map.py +30 -0
- algokit_algod_client/models/_state_delta.py +6 -0
- algokit_algod_client/models/_state_proof.py +28 -0
- algokit_algod_client/models/_state_proof_message.py +44 -0
- algokit_algod_client/models/_supply_response.py +26 -0
- algokit_algod_client/models/_teal_key_value.py +28 -0
- algokit_algod_client/models/_teal_key_value_store.py +6 -0
- algokit_algod_client/models/_teal_value.py +32 -0
- algokit_algod_client/models/_transaction_group_ledger_state_deltas_for_round_response.py +21 -0
- algokit_algod_client/models/_transaction_parameters_response.py +45 -0
- algokit_algod_client/models/_transaction_proof.py +44 -0
- algokit_algod_client/models/_version_contains_the_current_algod_version.py +38 -0
- algokit_algod_client/models/suggested_params.py +42 -0
- algokit_algod_client/py.typed +1 -0
- algokit_algod_client/types.py +7 -0
- algokit_algosdk/__init__.py +38 -0
- algokit_algosdk/account.py +32 -0
- algokit_algosdk/app_access.py +228 -0
- algokit_algosdk/box_reference.py +100 -0
- algokit_algosdk/constants.py +147 -0
- algokit_algosdk/encoding.py +89 -0
- algokit_algosdk/error.py +180 -0
- algokit_algosdk/logic.py +61 -0
- algokit_algosdk/logicsig.py +218 -0
- algokit_algosdk/mnemonic.py +216 -0
- algokit_algosdk/multisig.py +161 -0
- algokit_algosdk/py.typed +0 -0
- algokit_algosdk/transaction.py +596 -0
- algokit_algosdk/wordlist.py +2054 -0
- algokit_common/__init__.py +50 -0
- algokit_common/address.py +34 -0
- algokit_common/constants.py +47 -0
- algokit_common/hashing.py +25 -0
- algokit_common/py.typed +0 -0
- algokit_common/serde/__init__.py +40 -0
- algokit_common/serde/_core.py +610 -0
- algokit_common/serde/_primitives.py +135 -0
- algokit_common/source_map.py +158 -0
- algokit_indexer_client/__init__.py +10 -0
- algokit_indexer_client/client.py +1456 -0
- algokit_indexer_client/config.py +36 -0
- algokit_indexer_client/exceptions.py +59 -0
- algokit_indexer_client/models/__init__.py +148 -0
- algokit_indexer_client/models/_account.py +161 -0
- algokit_indexer_client/models/_account_participation.py +53 -0
- algokit_indexer_client/models/_account_response.py +19 -0
- algokit_indexer_client/models/_account_state_delta.py +29 -0
- algokit_indexer_client/models/_accounts_response.py +29 -0
- algokit_indexer_client/models/_application.py +35 -0
- algokit_indexer_client/models/_application_local_state.py +45 -0
- algokit_indexer_client/models/_application_local_states_response.py +29 -0
- algokit_indexer_client/models/_application_log_data.py +28 -0
- algokit_indexer_client/models/_application_logs_response.py +33 -0
- algokit_indexer_client/models/_application_params.py +62 -0
- algokit_indexer_client/models/_application_response.py +20 -0
- algokit_indexer_client/models/_application_state_schema.py +22 -0
- algokit_indexer_client/models/_applications_response.py +29 -0
- algokit_indexer_client/models/_asset.py +35 -0
- algokit_indexer_client/models/_asset_balances_response.py +29 -0
- algokit_indexer_client/models/_asset_holding.py +41 -0
- algokit_indexer_client/models/_asset_holdings_response.py +29 -0
- algokit_indexer_client/models/_asset_params.py +102 -0
- algokit_indexer_client/models/_asset_response.py +19 -0
- algokit_indexer_client/models/_assets_response.py +29 -0
- algokit_indexer_client/models/_block.py +150 -0
- algokit_indexer_client/models/_block_headers_response.py +29 -0
- algokit_indexer_client/models/_block_rewards.py +38 -0
- algokit_indexer_client/models/_block_upgrade_state.py +34 -0
- algokit_indexer_client/models/_block_upgrade_vote.py +26 -0
- algokit_indexer_client/models/_box.py +36 -0
- algokit_indexer_client/models/_box_descriptor.py +24 -0
- algokit_indexer_client/models/_box_reference.py +28 -0
- algokit_indexer_client/models/_boxes_response.py +29 -0
- algokit_indexer_client/models/_error_response.py +18 -0
- algokit_indexer_client/models/_eval_delta.py +32 -0
- algokit_indexer_client/models/_eval_delta_key_value.py +28 -0
- algokit_indexer_client/models/_hash_factory.py +14 -0
- algokit_indexer_client/models/_hb_proof_fields.py +57 -0
- algokit_indexer_client/models/_health_check.py +42 -0
- algokit_indexer_client/models/_holding_ref.py +23 -0
- algokit_indexer_client/models/_indexer_state_proof_message.py +40 -0
- algokit_indexer_client/models/_locals_ref.py +23 -0
- algokit_indexer_client/models/_merkle_array_proof.py +29 -0
- algokit_indexer_client/models/_mini_asset_holding.py +38 -0
- algokit_indexer_client/models/_on_completion.py +25 -0
- algokit_indexer_client/models/_participation_updates.py +22 -0
- algokit_indexer_client/models/_resource_ref.py +42 -0
- algokit_indexer_client/models/_serde_helpers.py +241 -0
- algokit_indexer_client/models/_state_delta.py +6 -0
- algokit_indexer_client/models/_state_proof_fields.py +57 -0
- algokit_indexer_client/models/_state_proof_participant.py +20 -0
- algokit_indexer_client/models/_state_proof_reveal.py +25 -0
- algokit_indexer_client/models/_state_proof_sig_slot.py +20 -0
- algokit_indexer_client/models/_state_proof_signature.py +37 -0
- algokit_indexer_client/models/_state_proof_tracking.py +32 -0
- algokit_indexer_client/models/_state_proof_verifier.py +24 -0
- algokit_indexer_client/models/_state_schema.py +25 -0
- algokit_indexer_client/models/_teal_key_value.py +28 -0
- algokit_indexer_client/models/_teal_key_value_store.py +6 -0
- algokit_indexer_client/models/_teal_value.py +32 -0
- algokit_indexer_client/models/_transaction.py +213 -0
- algokit_indexer_client/models/_transaction_application.py +105 -0
- algokit_indexer_client/models/_transaction_asset_config.py +31 -0
- algokit_indexer_client/models/_transaction_asset_freeze.py +29 -0
- algokit_indexer_client/models/_transaction_asset_transfer.py +41 -0
- algokit_indexer_client/models/_transaction_heartbeat.py +52 -0
- algokit_indexer_client/models/_transaction_keyreg.py +59 -0
- algokit_indexer_client/models/_transaction_payment.py +33 -0
- algokit_indexer_client/models/_transaction_response.py +19 -0
- algokit_indexer_client/models/_transaction_signature.py +35 -0
- algokit_indexer_client/models/_transaction_signature_logicsig.py +59 -0
- algokit_indexer_client/models/_transaction_signature_multisig.py +36 -0
- algokit_indexer_client/models/_transaction_signature_multisig_subsignature.py +28 -0
- algokit_indexer_client/models/_transaction_state_proof.py +32 -0
- algokit_indexer_client/models/_transactions_response.py +29 -0
- algokit_indexer_client/py.typed +1 -0
- algokit_indexer_client/types.py +7 -0
- algokit_kmd_client/__init__.py +10 -0
- algokit_kmd_client/client.py +1240 -0
- algokit_kmd_client/config.py +36 -0
- algokit_kmd_client/exceptions.py +59 -0
- algokit_kmd_client/models/__init__.py +112 -0
- algokit_kmd_client/models/_classical_signatures.py +4 -0
- algokit_kmd_client/models/_create_wallet_request.py +30 -0
- algokit_kmd_client/models/_create_wallet_response.py +19 -0
- algokit_kmd_client/models/_delete_key_request.py +27 -0
- algokit_kmd_client/models/_delete_multisig_request.py +27 -0
- algokit_kmd_client/models/_digest_represents_a32_byte_value_holding_the256_bit_hash_digest.py +4 -0
- algokit_kmd_client/models/_ed25519_public_key.py +4 -0
- algokit_kmd_client/models/_export_key_request.py +27 -0
- algokit_kmd_client/models/_export_key_response.py +24 -0
- algokit_kmd_client/models/_export_master_key_request.py +22 -0
- algokit_kmd_client/models/_export_master_key_response.py +18 -0
- algokit_kmd_client/models/_export_multisig_request.py +23 -0
- algokit_kmd_client/models/_export_multisig_response.py +26 -0
- algokit_kmd_client/models/_generate_key_request.py +18 -0
- algokit_kmd_client/models/_generate_key_response.py +19 -0
- algokit_kmd_client/models/_import_key_request.py +28 -0
- algokit_kmd_client/models/_import_key_response.py +19 -0
- algokit_kmd_client/models/_import_multisig_request.py +30 -0
- algokit_kmd_client/models/_import_multisig_response.py +19 -0
- algokit_kmd_client/models/_init_wallet_handle_token_request.py +22 -0
- algokit_kmd_client/models/_init_wallet_handle_token_response.py +18 -0
- algokit_kmd_client/models/_list_keys_request.py +18 -0
- algokit_kmd_client/models/_list_keys_response.py +18 -0
- algokit_kmd_client/models/_list_multisig_request.py +18 -0
- algokit_kmd_client/models/_list_multisig_response.py +18 -0
- algokit_kmd_client/models/_list_wallets_request.py +11 -0
- algokit_kmd_client/models/_list_wallets_response.py +25 -0
- algokit_kmd_client/models/_master_derivation_key.py +4 -0
- algokit_kmd_client/models/_multisig_sig.py +33 -0
- algokit_kmd_client/models/_multisig_subsig.py +23 -0
- algokit_kmd_client/models/_public_key.py +4 -0
- algokit_kmd_client/models/_release_wallet_handle_token_request.py +18 -0
- algokit_kmd_client/models/_rename_wallet_request.py +26 -0
- algokit_kmd_client/models/_rename_wallet_response.py +19 -0
- algokit_kmd_client/models/_renew_wallet_handle_token_request.py +18 -0
- algokit_kmd_client/models/_renew_wallet_handle_token_response.py +19 -0
- algokit_kmd_client/models/_serde_helpers.py +241 -0
- algokit_kmd_client/models/_sign_multisig_response.py +24 -0
- algokit_kmd_client/models/_sign_multisig_txn_request.py +45 -0
- algokit_kmd_client/models/_sign_program_multisig_request.py +50 -0
- algokit_kmd_client/models/_sign_program_multisig_response.py +24 -0
- algokit_kmd_client/models/_sign_program_request.py +37 -0
- algokit_kmd_client/models/_sign_program_response.py +24 -0
- algokit_kmd_client/models/_sign_transaction_response.py +24 -0
- algokit_kmd_client/models/_sign_txn_request.py +36 -0
- algokit_kmd_client/models/_signature.py +4 -0
- algokit_kmd_client/models/_tx_type.py +4 -0
- algokit_kmd_client/models/_versions_request.py +11 -0
- algokit_kmd_client/models/_versions_response.py +19 -0
- algokit_kmd_client/models/_wallet.py +38 -0
- algokit_kmd_client/models/_wallet_handle.py +24 -0
- algokit_kmd_client/models/_wallet_info_request.py +18 -0
- algokit_kmd_client/models/_wallet_info_response.py +19 -0
- algokit_kmd_client/py.typed +1 -0
- algokit_kmd_client/types.py +7 -0
- algokit_transact/__init__.py +190 -0
- algokit_transact/codec/__init__.py +0 -0
- algokit_transact/codec/msgpack.py +11 -0
- algokit_transact/codec/serde.py +7 -0
- algokit_transact/codec/signed.py +57 -0
- algokit_transact/codec/transaction.py +65 -0
- algokit_transact/exceptions.py +17 -0
- algokit_transact/logicsig.py +220 -0
- algokit_transact/models/__init__.py +0 -0
- algokit_transact/models/app_call.py +447 -0
- algokit_transact/models/asset_config.py +19 -0
- algokit_transact/models/asset_freeze.py +11 -0
- algokit_transact/models/asset_transfer.py +13 -0
- algokit_transact/models/common.py +17 -0
- algokit_transact/models/heartbeat.py +21 -0
- algokit_transact/models/key_registration.py +14 -0
- algokit_transact/models/payment.py +14 -0
- algokit_transact/models/signed_transaction.py +21 -0
- algokit_transact/models/state_proof.py +150 -0
- algokit_transact/models/transaction.py +88 -0
- algokit_transact/multisig.py +93 -0
- algokit_transact/ops/__init__.py +0 -0
- algokit_transact/ops/fees.py +47 -0
- algokit_transact/ops/group.py +28 -0
- algokit_transact/ops/ids.py +14 -0
- algokit_transact/ops/validate.py +503 -0
- algokit_transact/py.typed +0 -0
- algokit_transact/signer.py +195 -0
- algokit_transact/signing/__init__.py +0 -0
- algokit_transact/signing/logic_signature.py +19 -0
- algokit_transact/signing/multisig.py +84 -0
- algokit_transact/signing/types.py +39 -0
- algokit_transact/signing/validation.py +63 -0
- algokit_utils/__init__.py +23 -0
- algokit_utils/_debugging.py +304 -0
- algokit_utils/accounts/__init__.py +2 -0
- algokit_utils/accounts/account_manager.py +1051 -0
- algokit_utils/accounts/kmd_account_manager.py +206 -0
- algokit_utils/algo25.py +46 -0
- algokit_utils/algorand.py +383 -0
- algokit_utils/applications/__init__.py +7 -0
- algokit_utils/applications/abi.py +280 -0
- algokit_utils/applications/app_client.py +2193 -0
- algokit_utils/applications/app_deployer.py +788 -0
- algokit_utils/applications/app_factory.py +1140 -0
- algokit_utils/applications/app_manager.py +575 -0
- algokit_utils/applications/app_spec/__init__.py +6 -0
- algokit_utils/applications/enums.py +40 -0
- algokit_utils/assets/__init__.py +1 -0
- algokit_utils/assets/asset_manager.py +344 -0
- algokit_utils/clients/__init__.py +41 -0
- algokit_utils/clients/client_manager.py +756 -0
- algokit_utils/clients/dispenser_api_client.py +212 -0
- algokit_utils/common.py +40 -0
- algokit_utils/config.py +159 -0
- algokit_utils/errors/__init__.py +1 -0
- algokit_utils/errors/logic_error.py +160 -0
- algokit_utils/models/__init__.py +7 -0
- algokit_utils/models/account.py +12 -0
- algokit_utils/models/amount.py +198 -0
- algokit_utils/models/application.py +90 -0
- algokit_utils/models/network.py +29 -0
- algokit_utils/models/simulate.py +7 -0
- algokit_utils/models/state.py +53 -0
- algokit_utils/models/transaction.py +49 -0
- algokit_utils/protocols/__init__.py +3 -0
- algokit_utils/protocols/account.py +11 -0
- algokit_utils/protocols/signer.py +17 -0
- algokit_utils/protocols/typed_clients.py +110 -0
- algokit_utils/py.typed +0 -0
- algokit_utils/transact.py +195 -0
- algokit_utils/transactions/__init__.py +3 -0
- algokit_utils/transactions/builders/__init__.py +67 -0
- algokit_utils/transactions/builders/app.py +248 -0
- algokit_utils/transactions/builders/asset.py +256 -0
- algokit_utils/transactions/builders/common.py +263 -0
- algokit_utils/transactions/builders/keyreg.py +103 -0
- algokit_utils/transactions/builders/method_call.py +380 -0
- algokit_utils/transactions/builders/payment.py +43 -0
- algokit_utils/transactions/composer_resources.py +409 -0
- algokit_utils/transactions/fee_coverage.py +79 -0
- algokit_utils/transactions/helpers.py +9 -0
- algokit_utils/transactions/transaction_composer.py +1574 -0
- algokit_utils/transactions/transaction_creator.py +699 -0
- algokit_utils/transactions/transaction_sender.py +1240 -0
- algokit_utils/transactions/types.py +262 -0
- algokit_utils-5.0.0a3.dist-info/METADATA +105 -0
- algokit_utils-5.0.0a3.dist-info/RECORD +337 -0
- algokit_utils-5.0.0a3.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import base64
|
|
4
|
+
import warnings
|
|
5
|
+
from collections.abc import Sequence
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from typing import TypeAlias, cast
|
|
8
|
+
|
|
9
|
+
from typing_extensions import deprecated
|
|
10
|
+
|
|
11
|
+
from algokit_abi import abi, arc56
|
|
12
|
+
from algokit_algod_client import models as algod_models
|
|
13
|
+
from algokit_utils.models.state import BoxName
|
|
14
|
+
|
|
15
|
+
ABIValue: TypeAlias = (
|
|
16
|
+
bool | int | str | bytes | bytearray | list["ABIValue"] | tuple["ABIValue"] | dict[str, "ABIValue"] | object
|
|
17
|
+
)
|
|
18
|
+
ABIStruct: TypeAlias = dict[str, list[dict[str, "ABIValue"]]] | object
|
|
19
|
+
Arc56ReturnValueType: TypeAlias = ABIValue | ABIStruct | None
|
|
20
|
+
|
|
21
|
+
ABIType: TypeAlias = abi.ABIType
|
|
22
|
+
ABIArgumentType: TypeAlias = abi.ABIType | arc56.TransactionType | arc56.ReferenceType
|
|
23
|
+
Arc56Method: TypeAlias = arc56.Method
|
|
24
|
+
ConfirmationResponse: TypeAlias = algod_models.PendingTransactionResponse
|
|
25
|
+
|
|
26
|
+
ABI_RETURN_HASH = b"\x15\x1f\x7c\x75"
|
|
27
|
+
ABI_RETURN_PREFIX_LENGTH = len(ABI_RETURN_HASH)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _warn_deprecated(message: str) -> None:
|
|
31
|
+
warnings.warn(message, DeprecationWarning, stacklevel=3)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@dataclass(slots=True)
|
|
35
|
+
class ABIReturn:
|
|
36
|
+
"""Represents the return value from an ABI method call.
|
|
37
|
+
|
|
38
|
+
Aligns with the Rust model: always carries the method, raw bytes, decoded value (if available),
|
|
39
|
+
and any decode error. Transaction context should live on the send result, not here.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
method: Arc56Method | None
|
|
43
|
+
raw_value: bytes
|
|
44
|
+
value: ABIValue | None
|
|
45
|
+
decode_error: Exception | None
|
|
46
|
+
_tx_info: ConfirmationResponse | None = None
|
|
47
|
+
|
|
48
|
+
def __init__(
|
|
49
|
+
self,
|
|
50
|
+
*,
|
|
51
|
+
method: Arc56Method | None,
|
|
52
|
+
raw_value: bytes = b"",
|
|
53
|
+
value: ABIValue | None = None,
|
|
54
|
+
decode_error: Exception | None = None,
|
|
55
|
+
tx_info: ConfirmationResponse | None = None,
|
|
56
|
+
) -> None:
|
|
57
|
+
self.method = method
|
|
58
|
+
self.raw_value = raw_value or b""
|
|
59
|
+
self.value = value
|
|
60
|
+
self.decode_error = decode_error
|
|
61
|
+
self._tx_info = tx_info
|
|
62
|
+
|
|
63
|
+
@property
|
|
64
|
+
def is_success(self) -> bool:
|
|
65
|
+
"""Returns True if the ABI call was decoded successfully."""
|
|
66
|
+
return self.decode_error is None
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
@deprecated(
|
|
70
|
+
"ABIReturn.tx_info is deprecated; read the transaction confirmation from the send result "
|
|
71
|
+
"(e.g. SendAppTransactionResult.confirmation)."
|
|
72
|
+
)
|
|
73
|
+
def tx_info(self) -> ConfirmationResponse | None:
|
|
74
|
+
"""Deprecated: transaction info now lives on the send result."""
|
|
75
|
+
_warn_deprecated(
|
|
76
|
+
"ABIReturn.tx_info is deprecated; read the transaction confirmation from the send result "
|
|
77
|
+
"(e.g. SendAppTransactionResult.confirmation)."
|
|
78
|
+
)
|
|
79
|
+
return self._tx_info
|
|
80
|
+
|
|
81
|
+
def get_arc56_value(self, method: arc56.Method, structs: dict[str, object] | None = None) -> Arc56ReturnValueType:
|
|
82
|
+
"""Deprecated: use `value` directly."""
|
|
83
|
+
_warn_deprecated("ABIReturn.get_arc56_value is deprecated; use `ABIReturn.value` instead.")
|
|
84
|
+
return get_arc56_value(self, method, structs)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@dataclass(slots=True)
|
|
88
|
+
@deprecated("ABIResult is deprecated; call extract_abi_return_from_logs(...) and work with ABIReturn instead.")
|
|
89
|
+
class ABIResult(ABIReturn):
|
|
90
|
+
"""Deprecated wrapper that previously carried tx context plus ABI data."""
|
|
91
|
+
|
|
92
|
+
tx_id: str | None = None
|
|
93
|
+
|
|
94
|
+
def __init__(
|
|
95
|
+
self,
|
|
96
|
+
*,
|
|
97
|
+
tx_id: str | None = None,
|
|
98
|
+
raw_value: bytes = b"",
|
|
99
|
+
value: ABIValue | None = None,
|
|
100
|
+
decode_error: Exception | None = None,
|
|
101
|
+
tx_info: ConfirmationResponse | None = None,
|
|
102
|
+
method: Arc56Method | None = None,
|
|
103
|
+
) -> None:
|
|
104
|
+
_warn_deprecated("ABIResult is deprecated; call extract_abi_return_from_logs(...) and use ABIReturn instead.")
|
|
105
|
+
super().__init__(method=method, raw_value=raw_value, value=value, decode_error=decode_error, tx_info=tx_info)
|
|
106
|
+
self.tx_id = tx_id
|
|
107
|
+
|
|
108
|
+
@classmethod
|
|
109
|
+
@deprecated(
|
|
110
|
+
"ABIResult.from_abireturn is deprecated; keep the tx_id alongside the send result and use ABIReturn directly."
|
|
111
|
+
)
|
|
112
|
+
def from_abireturn(cls, abi_return: ABIReturn, tx_id: str | None = None) -> ABIResult:
|
|
113
|
+
_warn_deprecated(
|
|
114
|
+
"ABIResult.from_abireturn is deprecated; keep the tx_id alongside the send result "
|
|
115
|
+
"and use ABIReturn directly."
|
|
116
|
+
)
|
|
117
|
+
return cls(
|
|
118
|
+
tx_id=tx_id,
|
|
119
|
+
raw_value=abi_return.raw_value,
|
|
120
|
+
value=abi_return.value,
|
|
121
|
+
decode_error=abi_return.decode_error,
|
|
122
|
+
tx_info=abi_return._tx_info, # noqa: SLF001
|
|
123
|
+
method=abi_return.method,
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def _decode_log_entry(log_entry: bytes | bytearray | memoryview | str) -> bytes:
|
|
128
|
+
return bytes(log_entry) if isinstance(log_entry, bytes | bytearray | memoryview) else base64.b64decode(log_entry)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def extract_abi_return_from_logs(confirmation: ConfirmationResponse, method: Arc56Method) -> ABIReturn:
|
|
132
|
+
"""Decode ABI return value from a transaction confirmation log."""
|
|
133
|
+
returns = method.returns
|
|
134
|
+
return_type = returns.type if returns else arc56.Void
|
|
135
|
+
|
|
136
|
+
if return_type == arc56.Void:
|
|
137
|
+
return ABIReturn(method=method, raw_value=b"", value=None, decode_error=None, tx_info=confirmation)
|
|
138
|
+
|
|
139
|
+
logs: Sequence[bytes | bytearray | memoryview | str | None] = confirmation.logs or []
|
|
140
|
+
if not logs:
|
|
141
|
+
return ABIReturn(
|
|
142
|
+
method=method,
|
|
143
|
+
raw_value=b"",
|
|
144
|
+
value=None,
|
|
145
|
+
decode_error=ValueError("App call transaction did not log a return value"),
|
|
146
|
+
tx_info=confirmation,
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
last_log = logs[-1]
|
|
150
|
+
if last_log is None:
|
|
151
|
+
return ABIReturn(
|
|
152
|
+
method=method,
|
|
153
|
+
raw_value=b"",
|
|
154
|
+
value=None,
|
|
155
|
+
decode_error=ValueError("App call transaction did not log a return value"),
|
|
156
|
+
tx_info=confirmation,
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
result_bytes = _decode_log_entry(last_log)
|
|
160
|
+
if len(result_bytes) < ABI_RETURN_PREFIX_LENGTH or result_bytes[:ABI_RETURN_PREFIX_LENGTH] != ABI_RETURN_HASH:
|
|
161
|
+
return ABIReturn(
|
|
162
|
+
method=method,
|
|
163
|
+
raw_value=b"",
|
|
164
|
+
value=None,
|
|
165
|
+
decode_error=ValueError("App call transaction did not log a return value"),
|
|
166
|
+
tx_info=confirmation,
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
raw_value = result_bytes[ABI_RETURN_PREFIX_LENGTH:]
|
|
170
|
+
method_return_type = cast(abi.ABIType, return_type)
|
|
171
|
+
try:
|
|
172
|
+
decoded = method_return_type.decode(raw_value)
|
|
173
|
+
return ABIReturn(
|
|
174
|
+
method=method,
|
|
175
|
+
raw_value=raw_value,
|
|
176
|
+
value=decoded,
|
|
177
|
+
decode_error=None,
|
|
178
|
+
tx_info=confirmation,
|
|
179
|
+
)
|
|
180
|
+
except Exception as err:
|
|
181
|
+
return ABIReturn(
|
|
182
|
+
method=method,
|
|
183
|
+
raw_value=raw_value,
|
|
184
|
+
value=None,
|
|
185
|
+
decode_error=err,
|
|
186
|
+
tx_info=confirmation,
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
@deprecated("parse_abi_method_result is deprecated; call extract_abi_return_from_logs(confirmation, method) instead.")
|
|
191
|
+
def parse_abi_method_result(method: Arc56Method, tx_id: str, txn: ConfirmationResponse) -> ABIResult:
|
|
192
|
+
"""Deprecated: use extract_abi_return_from_logs instead."""
|
|
193
|
+
_warn_deprecated("parse_abi_method_result is deprecated; call extract_abi_return_from_logs(confirmation, method).")
|
|
194
|
+
abi_return = extract_abi_return_from_logs(txn, method)
|
|
195
|
+
return ABIResult.from_abireturn(abi_return, tx_id)
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
@deprecated("get_arc56_value is deprecated; use ABIReturn.value instead.")
|
|
199
|
+
def get_arc56_value(
|
|
200
|
+
abi_return: ABIReturn, method: arc56.Method, structs: dict[str, object] | None = None
|
|
201
|
+
) -> Arc56ReturnValueType:
|
|
202
|
+
"""Deprecated: use `ABIReturn.value` instead."""
|
|
203
|
+
_warn_deprecated("get_arc56_value is deprecated; use ABIReturn.value instead.")
|
|
204
|
+
_ = method # Accepted for compatibility with generated clients
|
|
205
|
+
_ = structs # Accepted for compatibility with generated clients
|
|
206
|
+
if abi_return.decode_error:
|
|
207
|
+
raise ValueError(abi_return.decode_error)
|
|
208
|
+
return abi_return.value
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
__all__ = [
|
|
212
|
+
"ABIArgumentType",
|
|
213
|
+
"ABIResult",
|
|
214
|
+
"ABIReturn",
|
|
215
|
+
"ABIStruct",
|
|
216
|
+
"ABIType",
|
|
217
|
+
"ABIValue",
|
|
218
|
+
"Arc56ReturnValueType",
|
|
219
|
+
"BoxABIValue",
|
|
220
|
+
"extract_abi_return_from_logs",
|
|
221
|
+
"get_abi_decoded_value",
|
|
222
|
+
"get_abi_encoded_value",
|
|
223
|
+
"get_arc56_value",
|
|
224
|
+
"parse_abi_method_result",
|
|
225
|
+
]
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def get_abi_encoded_value(value: object, abi_type: abi.ABIType | arc56.AVMType) -> bytes:
|
|
229
|
+
"""Encodes a value according to its ABI type.
|
|
230
|
+
|
|
231
|
+
:param value: The value to encode
|
|
232
|
+
:param abi_type: The ABI or AVM type
|
|
233
|
+
:return: The ABI encoded bytes
|
|
234
|
+
"""
|
|
235
|
+
if isinstance(value, (bytes | bytearray)):
|
|
236
|
+
return bytes(value)
|
|
237
|
+
if abi_type == arc56.AVMType.UINT64 and isinstance(value, int):
|
|
238
|
+
return abi.ABIType.from_string("uint64").encode(value)
|
|
239
|
+
if abi_type == arc56.AVMType.STRING and isinstance(value, str):
|
|
240
|
+
return value.encode("utf-8")
|
|
241
|
+
if abi_type == arc56.AVMType.BYTES and isinstance(value, bytes | bytearray):
|
|
242
|
+
return bytes(value)
|
|
243
|
+
assert not isinstance(abi_type, arc56.AVMType), "unexpected AVMType"
|
|
244
|
+
return abi_type.encode(value)
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def get_abi_decoded_value(
|
|
248
|
+
value: bytes | int | str,
|
|
249
|
+
decode_type: arc56.AVMType | abi.ABIType | arc56.ReferenceType,
|
|
250
|
+
) -> ABIValue:
|
|
251
|
+
"""Decodes a value according to its ABI type.
|
|
252
|
+
|
|
253
|
+
:param value: The value to decode
|
|
254
|
+
:param decode_type: The ABI type string or type object
|
|
255
|
+
:return: The decoded ABI value
|
|
256
|
+
"""
|
|
257
|
+
|
|
258
|
+
# map reference types to their value equivalents
|
|
259
|
+
if decode_type in (arc56.ReferenceType.ASSET, arc56.ReferenceType.APPLICATION):
|
|
260
|
+
decode_type = abi.UintType(64)
|
|
261
|
+
elif decode_type == arc56.ReferenceType.ACCOUNT:
|
|
262
|
+
decode_type = abi.AddressType()
|
|
263
|
+
if decode_type == arc56.AVMType.UINT64:
|
|
264
|
+
decode_type = abi.UintType(64)
|
|
265
|
+
if decode_type == arc56.AVMType.BYTES or not isinstance(value, bytes):
|
|
266
|
+
return value
|
|
267
|
+
if decode_type == arc56.AVMType.STRING:
|
|
268
|
+
return value.decode("utf-8")
|
|
269
|
+
assert isinstance(decode_type, abi.ABIType), "unexpected ABIType"
|
|
270
|
+
return decode_type.decode(value) # type: ignore[no-any-return]
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
@dataclass(kw_only=True, frozen=True)
|
|
274
|
+
class BoxABIValue:
|
|
275
|
+
"""Represents an ABI value stored in a box."""
|
|
276
|
+
|
|
277
|
+
name: BoxName
|
|
278
|
+
"""The name of the box"""
|
|
279
|
+
value: ABIValue
|
|
280
|
+
"""The ABI value stored in the box"""
|