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
algokit_abi/arc56.py
ADDED
|
@@ -0,0 +1,821 @@
|
|
|
1
|
+
import base64
|
|
2
|
+
import enum
|
|
3
|
+
import json
|
|
4
|
+
import typing
|
|
5
|
+
from collections.abc import Callable, Mapping, Sequence
|
|
6
|
+
from dataclasses import dataclass, field, replace
|
|
7
|
+
from functools import cached_property
|
|
8
|
+
|
|
9
|
+
from Cryptodome.Hash import SHA512
|
|
10
|
+
from typing_extensions import deprecated
|
|
11
|
+
|
|
12
|
+
from algokit_abi import _arc56_serde as serde
|
|
13
|
+
from algokit_abi import abi
|
|
14
|
+
from algokit_common import from_wire, nested, to_wire, wire
|
|
15
|
+
|
|
16
|
+
if typing.TYPE_CHECKING:
|
|
17
|
+
from algokit_abi import arc32
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
"ENUM_ALIASES",
|
|
21
|
+
"AVMType",
|
|
22
|
+
"Actions",
|
|
23
|
+
"Arc56Contract",
|
|
24
|
+
"Argument",
|
|
25
|
+
"Boxes",
|
|
26
|
+
"ByteCode",
|
|
27
|
+
"CallEnum",
|
|
28
|
+
"Compiler",
|
|
29
|
+
"CompilerInfo",
|
|
30
|
+
"CompilerVersion",
|
|
31
|
+
"CreateEnum",
|
|
32
|
+
"DefaultValue",
|
|
33
|
+
"Event",
|
|
34
|
+
"EventArg",
|
|
35
|
+
"Global",
|
|
36
|
+
"Keys",
|
|
37
|
+
"Local",
|
|
38
|
+
"Maps",
|
|
39
|
+
"Method",
|
|
40
|
+
"Network",
|
|
41
|
+
"PcOffsetMethod",
|
|
42
|
+
"ProgramSourceInfo",
|
|
43
|
+
"Recommendations",
|
|
44
|
+
"ReferenceType",
|
|
45
|
+
"Returns",
|
|
46
|
+
"Schema",
|
|
47
|
+
"ScratchVariables",
|
|
48
|
+
"Source",
|
|
49
|
+
"SourceInfo",
|
|
50
|
+
"SourceInfoModel",
|
|
51
|
+
"State",
|
|
52
|
+
"StorageKey",
|
|
53
|
+
"StorageMap",
|
|
54
|
+
"TemplateVariables",
|
|
55
|
+
"TransactionType",
|
|
56
|
+
"Void",
|
|
57
|
+
"VoidType",
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@typing.final
|
|
62
|
+
@enum.unique
|
|
63
|
+
class AVMType(str, enum.Enum):
|
|
64
|
+
"""Enum representing native AVM types"""
|
|
65
|
+
|
|
66
|
+
BYTES = "AVMBytes"
|
|
67
|
+
STRING = "AVMString"
|
|
68
|
+
UINT64 = "AVMUint64"
|
|
69
|
+
|
|
70
|
+
def __str__(self) -> str:
|
|
71
|
+
return self.value
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
@typing.final
|
|
75
|
+
@enum.unique
|
|
76
|
+
class CallEnum(str, enum.Enum):
|
|
77
|
+
"""Enum representing different call types for application transactions."""
|
|
78
|
+
|
|
79
|
+
CLEAR_STATE = "ClearState"
|
|
80
|
+
CLOSE_OUT = "CloseOut"
|
|
81
|
+
DELETE_APPLICATION = "DeleteApplication"
|
|
82
|
+
NO_OP = "NoOp"
|
|
83
|
+
OPT_IN = "OptIn"
|
|
84
|
+
UPDATE_APPLICATION = "UpdateApplication"
|
|
85
|
+
|
|
86
|
+
def __str__(self) -> str:
|
|
87
|
+
return self.value
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
@typing.final
|
|
91
|
+
@enum.unique
|
|
92
|
+
class CreateEnum(str, enum.Enum):
|
|
93
|
+
"""Enum representing different create types for application transactions."""
|
|
94
|
+
|
|
95
|
+
DELETE_APPLICATION = "DeleteApplication"
|
|
96
|
+
NO_OP = "NoOp"
|
|
97
|
+
OPT_IN = "OptIn"
|
|
98
|
+
|
|
99
|
+
def __str__(self) -> str:
|
|
100
|
+
return self.value
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
@typing.final
|
|
104
|
+
@enum.unique
|
|
105
|
+
class ReferenceType(str, enum.Enum):
|
|
106
|
+
ASSET = "asset"
|
|
107
|
+
ACCOUNT = "account"
|
|
108
|
+
APPLICATION = "application"
|
|
109
|
+
|
|
110
|
+
def __str__(self) -> str:
|
|
111
|
+
return self.value
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@typing.final
|
|
115
|
+
@enum.unique
|
|
116
|
+
class TransactionType(str, enum.Enum):
|
|
117
|
+
ANY = "txn"
|
|
118
|
+
"""Any transaction"""
|
|
119
|
+
PAY = "pay"
|
|
120
|
+
"""Payment transaction"""
|
|
121
|
+
KEYREG = "keyreg"
|
|
122
|
+
"Key registration transaction"
|
|
123
|
+
ACFG = "acfg"
|
|
124
|
+
"""Asset configuration transaction"""
|
|
125
|
+
AXFER = "axfer"
|
|
126
|
+
"""Asset transfer transaction"""
|
|
127
|
+
AFRZ = "afrz"
|
|
128
|
+
"""Asset freeze transaction"""
|
|
129
|
+
APPL = "appl"
|
|
130
|
+
"""App call transaction, allows creating, deleting, and interacting with an application"""
|
|
131
|
+
|
|
132
|
+
def __str__(self) -> str:
|
|
133
|
+
return self.value
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
VoidType = typing.Literal["void"]
|
|
137
|
+
Void: VoidType = "void"
|
|
138
|
+
|
|
139
|
+
ENUM_ALIASES: Mapping[str, ReferenceType | TransactionType | VoidType | AVMType] = {
|
|
140
|
+
**{r.value: r for r in ReferenceType},
|
|
141
|
+
**{t.value: t for t in TransactionType},
|
|
142
|
+
**{a.value: a for a in AVMType},
|
|
143
|
+
Void: Void,
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
class _StorageTypePropertyDescriptor:
|
|
148
|
+
def __set_name__(self, owner: type, name: str) -> None:
|
|
149
|
+
self._backing_field = f"_{name}"
|
|
150
|
+
self._resolved_field = f"_{name}_resolved"
|
|
151
|
+
|
|
152
|
+
def __get__(self, instance: object, owner: type) -> abi.ABIType | AVMType:
|
|
153
|
+
try:
|
|
154
|
+
value = getattr(instance, self._resolved_field)
|
|
155
|
+
except AttributeError:
|
|
156
|
+
raise AttributeError("resolved types not available until contract is initialized") from None
|
|
157
|
+
return typing.cast(abi.ABIType | AVMType, value)
|
|
158
|
+
|
|
159
|
+
def __set__(self, instance: object, value: abi.ABIType | AVMType) -> None:
|
|
160
|
+
assert isinstance(value, abi.ABIType | AVMType), "expected ABIType or AVMType"
|
|
161
|
+
setattr(instance, self._resolved_field, value)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
@dataclass(frozen=True)
|
|
165
|
+
class DefaultValue:
|
|
166
|
+
"""Default value information for method arguments."""
|
|
167
|
+
|
|
168
|
+
data: str
|
|
169
|
+
"""The default value data"""
|
|
170
|
+
source: typing.Literal["box", "global", "local", "literal", "method"]
|
|
171
|
+
"""The source of the default value"""
|
|
172
|
+
type: AVMType | abi.ABIType | None = field(default=None, metadata=serde.abi_type("type"))
|
|
173
|
+
"""The optional type of the default value"""
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
@dataclass
|
|
177
|
+
class Argument:
|
|
178
|
+
"""
|
|
179
|
+
Represents an argument for an ABI method
|
|
180
|
+
|
|
181
|
+
Args:
|
|
182
|
+
type (ABIType | ReferenceType | TransactionType | str): ABI type, reference type or transaction type
|
|
183
|
+
name (string, optional): name of this argument
|
|
184
|
+
desc (string, optional): description of this argument
|
|
185
|
+
"""
|
|
186
|
+
|
|
187
|
+
type: abi.ABIType | ReferenceType | TransactionType = field(metadata=serde.abi_type("type"))
|
|
188
|
+
default_value: DefaultValue | None = field(default=None, metadata=nested("defaultValue", DefaultValue))
|
|
189
|
+
desc: str | None = None
|
|
190
|
+
name: str | None = None
|
|
191
|
+
struct: str | None = None
|
|
192
|
+
|
|
193
|
+
def __str__(self) -> str:
|
|
194
|
+
if isinstance(self.type, abi.ABIType):
|
|
195
|
+
return self.type.name
|
|
196
|
+
else:
|
|
197
|
+
return self.type
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
@dataclass
|
|
201
|
+
class Returns:
|
|
202
|
+
"""
|
|
203
|
+
Represents a return type for an ABI method
|
|
204
|
+
|
|
205
|
+
Args:
|
|
206
|
+
type (ABIType | VoidType | str): ABI type of this return argument
|
|
207
|
+
desc (string, optional): description of this return argument
|
|
208
|
+
"""
|
|
209
|
+
|
|
210
|
+
type: abi.ABIType | VoidType = field(metadata=serde.abi_type("type"))
|
|
211
|
+
desc: str | None = None
|
|
212
|
+
struct: str | None = None
|
|
213
|
+
|
|
214
|
+
def __str__(self) -> str:
|
|
215
|
+
if isinstance(self.type, abi.ABIType):
|
|
216
|
+
return self.type.name
|
|
217
|
+
else:
|
|
218
|
+
return self.type
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
@dataclass
|
|
222
|
+
class Actions:
|
|
223
|
+
"""Method actions information."""
|
|
224
|
+
|
|
225
|
+
call: Sequence[CallEnum] = field(default=(), metadata=serde.sequence("call", CallEnum, omit_empty_seq=False))
|
|
226
|
+
"""The optional list of allowed call actions"""
|
|
227
|
+
create: Sequence[CreateEnum] = field(
|
|
228
|
+
default=(), metadata=serde.sequence("create", CreateEnum, omit_empty_seq=False)
|
|
229
|
+
)
|
|
230
|
+
"""The optional list of allowed create actions"""
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
@dataclass
|
|
234
|
+
class EventArg:
|
|
235
|
+
"""Event argument information."""
|
|
236
|
+
|
|
237
|
+
type: abi.ABIType = field(metadata=serde.abi_type("type"))
|
|
238
|
+
"""The type of the event argument"""
|
|
239
|
+
name: str | None = None
|
|
240
|
+
"""The optional name of the argument"""
|
|
241
|
+
desc: str | None = None
|
|
242
|
+
"""The optional description of the argument"""
|
|
243
|
+
struct: str | None = None
|
|
244
|
+
"""The struct name, references a struct defined on the contract"""
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
@dataclass
|
|
248
|
+
class Event:
|
|
249
|
+
"""Event information."""
|
|
250
|
+
|
|
251
|
+
args: Sequence[EventArg] = field(metadata=serde.nested_sequence("args", EventArg))
|
|
252
|
+
"""The list of event arguments"""
|
|
253
|
+
name: str
|
|
254
|
+
"""The name of the event"""
|
|
255
|
+
desc: str | None = None
|
|
256
|
+
"""The optional description of the event"""
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
@dataclass
|
|
260
|
+
class Boxes:
|
|
261
|
+
"""Box storage requirements."""
|
|
262
|
+
|
|
263
|
+
key: str
|
|
264
|
+
"""The box key"""
|
|
265
|
+
read_bytes: int
|
|
266
|
+
"""The number of bytes to read"""
|
|
267
|
+
write_bytes: int
|
|
268
|
+
"""The number of bytes to write"""
|
|
269
|
+
app: int | None = None
|
|
270
|
+
"""The optional application ID"""
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
@dataclass(frozen=True)
|
|
274
|
+
class Recommendations:
|
|
275
|
+
"""Method execution recommendations."""
|
|
276
|
+
|
|
277
|
+
accounts: list[str] = field(default_factory=list, metadata=serde.sequence("accounts", str))
|
|
278
|
+
"""The optional list of accounts"""
|
|
279
|
+
apps: list[int] = field(default_factory=list, metadata=serde.sequence("apps", int))
|
|
280
|
+
"""The optional list of applications"""
|
|
281
|
+
assets: list[int] = field(default_factory=list, metadata=serde.sequence("assets", int))
|
|
282
|
+
"""The optional list of assets"""
|
|
283
|
+
boxes: Boxes | None = None
|
|
284
|
+
"""The optional box storage requirements"""
|
|
285
|
+
inner_transaction_count: int | None = field(default=None, metadata=wire("innerTransactionCount"))
|
|
286
|
+
"""The optional inner transaction count"""
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
@dataclass(kw_only=True)
|
|
290
|
+
class Method:
|
|
291
|
+
"""
|
|
292
|
+
Represents an ABI method description.
|
|
293
|
+
|
|
294
|
+
Args:
|
|
295
|
+
name (string): name of the method
|
|
296
|
+
args (tuple): tuplet of Argument objects with type, name, and optional description
|
|
297
|
+
returns (Returns): a Returns object with a type and optional description
|
|
298
|
+
desc (string, optional): optional description of the method
|
|
299
|
+
"""
|
|
300
|
+
|
|
301
|
+
actions: Actions = field(default_factory=Actions)
|
|
302
|
+
"""The allowed actions"""
|
|
303
|
+
args: Sequence[Argument] = field(metadata=serde.nested_sequence("args", Argument))
|
|
304
|
+
"""The method arguments"""
|
|
305
|
+
name: str
|
|
306
|
+
"""The method name"""
|
|
307
|
+
returns: Returns
|
|
308
|
+
"""The return information"""
|
|
309
|
+
desc: str | None = None
|
|
310
|
+
"""The optional description"""
|
|
311
|
+
events: Sequence[Event] = field(default=(), metadata=serde.nested_sequence("events", Event))
|
|
312
|
+
"""The events the method can raise"""
|
|
313
|
+
readonly: bool | None = field(default=None, metadata=wire("readonly", keep_false=True))
|
|
314
|
+
"""The flag indicating if method is readonly, None if unknown"""
|
|
315
|
+
recommendations: Recommendations | None = field(
|
|
316
|
+
default=None, metadata=nested("recommendations", Recommendations, omit_empty_seq=False)
|
|
317
|
+
)
|
|
318
|
+
"""The execution recommendations"""
|
|
319
|
+
|
|
320
|
+
def get_txn_calls(self) -> int:
|
|
321
|
+
return sum(1 for a in self.args if isinstance(a.type, TransactionType))
|
|
322
|
+
|
|
323
|
+
@cached_property
|
|
324
|
+
def signature(self) -> str:
|
|
325
|
+
args_str = ",".join(map(str, self.args))
|
|
326
|
+
return f"{self.name}({args_str}){self.returns}"
|
|
327
|
+
|
|
328
|
+
@cached_property
|
|
329
|
+
def selector(self) -> bytes:
|
|
330
|
+
"""
|
|
331
|
+
Returns the ABI method signature, which is the first four bytes of the
|
|
332
|
+
SHA-512/256 hash of the method signature.
|
|
333
|
+
|
|
334
|
+
Returns:
|
|
335
|
+
bytes: first four bytes of the method signature hash
|
|
336
|
+
"""
|
|
337
|
+
sha_512_256 = SHA512.new(truncate="256")
|
|
338
|
+
sha_512_256.update(self.signature.encode("utf-8"))
|
|
339
|
+
return sha_512_256.digest()[:4]
|
|
340
|
+
|
|
341
|
+
def __str__(self) -> str:
|
|
342
|
+
return self.signature
|
|
343
|
+
|
|
344
|
+
def get_selector(self) -> bytes:
|
|
345
|
+
"""Compatibility helper matching algosdk ABI Method API."""
|
|
346
|
+
|
|
347
|
+
return self.selector
|
|
348
|
+
|
|
349
|
+
def get_signature(self) -> str:
|
|
350
|
+
"""Compatibility helper matching algosdk ABI Method API."""
|
|
351
|
+
|
|
352
|
+
return self.signature
|
|
353
|
+
|
|
354
|
+
@staticmethod
|
|
355
|
+
def from_signature(s: str) -> "Method":
|
|
356
|
+
name, args_str, returns_str = _parse_method_string(s)
|
|
357
|
+
|
|
358
|
+
args = []
|
|
359
|
+
for arg_str in abi.split_tuple_str(args_str):
|
|
360
|
+
try:
|
|
361
|
+
alias = ENUM_ALIASES[arg_str]
|
|
362
|
+
except KeyError:
|
|
363
|
+
arg_type: abi.ABIType | ReferenceType | TransactionType = abi.ABIType.from_string(arg_str)
|
|
364
|
+
else:
|
|
365
|
+
if not isinstance(alias, ReferenceType | TransactionType):
|
|
366
|
+
raise ValueError(f"invalid arg: {args_str}")
|
|
367
|
+
arg_type = alias
|
|
368
|
+
args.append(Argument(arg_type))
|
|
369
|
+
|
|
370
|
+
if returns_str == Void:
|
|
371
|
+
returns = Returns(Void)
|
|
372
|
+
else:
|
|
373
|
+
returns = Returns(abi.ABIType.from_string(returns_str))
|
|
374
|
+
return Method(name=name, args=tuple(args), returns=returns, actions=Actions(call=(), create=()))
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
def _parse_method_string(value: str) -> tuple[str, str, str]:
|
|
378
|
+
# Parses a method signature into three tokens, (name,args,returns)
|
|
379
|
+
# e.g. 'a(b,c)d' -> ('a', 'b,c', 'd')
|
|
380
|
+
stack = []
|
|
381
|
+
for i, char in enumerate(value):
|
|
382
|
+
if char == "(":
|
|
383
|
+
stack.append(i)
|
|
384
|
+
elif char == ")":
|
|
385
|
+
if not stack:
|
|
386
|
+
break
|
|
387
|
+
left_index = stack.pop()
|
|
388
|
+
if not stack:
|
|
389
|
+
return value[:left_index], value[left_index + 1 : i], value[i + 1 :]
|
|
390
|
+
|
|
391
|
+
raise ValueError(f"ABI method string has mismatched parentheses: {value}")
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
class Compiler(str, enum.Enum):
|
|
395
|
+
"""Enum representing different compiler types."""
|
|
396
|
+
|
|
397
|
+
ALGOD = "algod"
|
|
398
|
+
PUYA = "puya"
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
@dataclass
|
|
402
|
+
class ByteCode:
|
|
403
|
+
"""Represents the approval and clear program bytecode."""
|
|
404
|
+
|
|
405
|
+
approval: bytes = field(metadata=serde.base64_encoded_bytes("approval"))
|
|
406
|
+
"""The approval program bytecode"""
|
|
407
|
+
clear: bytes = field(metadata=serde.base64_encoded_bytes("clear"))
|
|
408
|
+
"""The clear program bytecode"""
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
@dataclass
|
|
412
|
+
class CompilerVersion:
|
|
413
|
+
"""Represents compiler version information."""
|
|
414
|
+
|
|
415
|
+
commit_hash: str | None = field(default=None, metadata=wire("commitHash"))
|
|
416
|
+
"""The git commit hash of the compiler"""
|
|
417
|
+
major: int | None = None
|
|
418
|
+
"""The major version number"""
|
|
419
|
+
minor: int | None = None
|
|
420
|
+
"""The minor version number"""
|
|
421
|
+
patch: int | None = None
|
|
422
|
+
"""The patch version number"""
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
@dataclass
|
|
426
|
+
class CompilerInfo:
|
|
427
|
+
"""Information about the compiler used."""
|
|
428
|
+
|
|
429
|
+
# TODO: make this just a str?
|
|
430
|
+
compiler: Compiler = field(metadata=wire("compiler", encode=Compiler))
|
|
431
|
+
"""The type of compiler used"""
|
|
432
|
+
compiler_version: CompilerVersion = field(metadata=nested("compilerVersion", CompilerVersion))
|
|
433
|
+
"""Version information for the compiler"""
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
@dataclass
|
|
437
|
+
class Network:
|
|
438
|
+
"""Network-specific application information."""
|
|
439
|
+
|
|
440
|
+
app_id: int = field(metadata=wire("appId"))
|
|
441
|
+
"""The application ID on the network"""
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
@dataclass
|
|
445
|
+
class ScratchVariables:
|
|
446
|
+
"""Information about scratch space variables."""
|
|
447
|
+
|
|
448
|
+
slot: int
|
|
449
|
+
"""The scratch slot number"""
|
|
450
|
+
_type: abi.ABIType | AVMType | str = field(metadata=serde.storage("type"))
|
|
451
|
+
type = _StorageTypePropertyDescriptor()
|
|
452
|
+
"""The type of the scratch variable"""
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
@dataclass
|
|
456
|
+
class Source:
|
|
457
|
+
"""Source code for approval and clear programs."""
|
|
458
|
+
|
|
459
|
+
approval: str
|
|
460
|
+
"""The base64 encoded approval program source"""
|
|
461
|
+
clear: str
|
|
462
|
+
"""The base64 encoded clear program source"""
|
|
463
|
+
|
|
464
|
+
# TODO: just make this the source properties?
|
|
465
|
+
def get_decoded_approval(self) -> str:
|
|
466
|
+
"""Get decoded approval program source.
|
|
467
|
+
|
|
468
|
+
:return: Decoded approval program source code
|
|
469
|
+
"""
|
|
470
|
+
return self._decode_source(self.approval)
|
|
471
|
+
|
|
472
|
+
def get_decoded_clear(self) -> str:
|
|
473
|
+
"""Get decoded clear program source.
|
|
474
|
+
|
|
475
|
+
:return: Decoded clear program source code
|
|
476
|
+
"""
|
|
477
|
+
return self._decode_source(self.clear)
|
|
478
|
+
|
|
479
|
+
def _decode_source(self, b64_text: str) -> str:
|
|
480
|
+
return base64.b64decode(b64_text).decode("utf-8")
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
@dataclass
|
|
484
|
+
class Global:
|
|
485
|
+
"""Global state schema."""
|
|
486
|
+
|
|
487
|
+
bytes: int = field(default=0, metadata=wire("bytes", keep_zero=True))
|
|
488
|
+
"""The number of byte slices in global state"""
|
|
489
|
+
ints: int = field(default=0, metadata=wire("ints", keep_zero=True))
|
|
490
|
+
"""The number of integers in global state"""
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
@dataclass
|
|
494
|
+
class Local:
|
|
495
|
+
"""Local state schema."""
|
|
496
|
+
|
|
497
|
+
bytes: int = field(default=0, metadata=wire("bytes", keep_zero=True))
|
|
498
|
+
"""The number of byte slices in local state"""
|
|
499
|
+
ints: int = field(default=0, metadata=wire("ints", keep_zero=True))
|
|
500
|
+
"""The number of integers in local state"""
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
@dataclass
|
|
504
|
+
class Schema:
|
|
505
|
+
"""Application state schema."""
|
|
506
|
+
|
|
507
|
+
global_state: Global = field(default_factory=Global, metadata=nested("global", Global))
|
|
508
|
+
"""The global state schema"""
|
|
509
|
+
local_state: Local = field(default_factory=Local, metadata=nested("local", Local))
|
|
510
|
+
"""The local state schema"""
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
@dataclass
|
|
514
|
+
class TemplateVariables:
|
|
515
|
+
"""Template variable information."""
|
|
516
|
+
|
|
517
|
+
_type: abi.ABIType | AVMType | str = field(metadata=serde.storage("type"))
|
|
518
|
+
type = _StorageTypePropertyDescriptor()
|
|
519
|
+
"""The type of the template variable"""
|
|
520
|
+
value: str | None = None
|
|
521
|
+
"""The optional value of the template variable"""
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
class PcOffsetMethod(str, enum.Enum):
|
|
525
|
+
"""PC offset method types."""
|
|
526
|
+
|
|
527
|
+
CBLOCKS = "cblocks"
|
|
528
|
+
NONE = "none"
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
@dataclass
|
|
532
|
+
class SourceInfo:
|
|
533
|
+
"""Source code location information."""
|
|
534
|
+
|
|
535
|
+
pc: list[int] = field(metadata=serde.sequence("pc", int))
|
|
536
|
+
"""The list of program counter values"""
|
|
537
|
+
error_message: str | None = field(default=None, metadata=wire("errorMessage"))
|
|
538
|
+
"""The optional error message"""
|
|
539
|
+
source: str | None = None
|
|
540
|
+
"""The optional source code"""
|
|
541
|
+
teal: int | None = None
|
|
542
|
+
"""The optional TEAL version"""
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
@dataclass
|
|
546
|
+
class StorageKey:
|
|
547
|
+
"""Storage key information."""
|
|
548
|
+
|
|
549
|
+
key: str
|
|
550
|
+
"""The storage key"""
|
|
551
|
+
_key_type: abi.ABIType | AVMType | str = field(metadata=serde.storage("keyType"))
|
|
552
|
+
"""The type of the key"""
|
|
553
|
+
_value_type: abi.ABIType | AVMType | str = field(metadata=serde.storage("valueType"))
|
|
554
|
+
"""The type of the value"""
|
|
555
|
+
desc: str | None = None
|
|
556
|
+
"""The optional description"""
|
|
557
|
+
|
|
558
|
+
key_type = _StorageTypePropertyDescriptor()
|
|
559
|
+
value_type = _StorageTypePropertyDescriptor()
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
@dataclass
|
|
563
|
+
class StorageMap:
|
|
564
|
+
"""Storage map information."""
|
|
565
|
+
|
|
566
|
+
_key_type: abi.ABIType | AVMType | str = field(metadata=serde.storage("keyType"))
|
|
567
|
+
"""The type of the map keys"""
|
|
568
|
+
_value_type: abi.ABIType | AVMType | str = field(metadata=serde.storage("valueType"))
|
|
569
|
+
"""The type of the map values"""
|
|
570
|
+
desc: str | None = None
|
|
571
|
+
"""The optional description"""
|
|
572
|
+
prefix: str | None = None
|
|
573
|
+
"""The optional key prefix"""
|
|
574
|
+
key_type = _StorageTypePropertyDescriptor()
|
|
575
|
+
value_type = _StorageTypePropertyDescriptor()
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
@dataclass
|
|
579
|
+
class Keys:
|
|
580
|
+
"""Storage keys for different storage types."""
|
|
581
|
+
|
|
582
|
+
box: dict[str, StorageKey] = field(default_factory=dict, metadata=serde.mapping("box", StorageKey))
|
|
583
|
+
"""The box storage keys"""
|
|
584
|
+
global_state: dict[str, StorageKey] = field(default_factory=dict, metadata=serde.mapping("global", StorageKey))
|
|
585
|
+
"""The global state storage keys"""
|
|
586
|
+
local_state: dict[str, StorageKey] = field(default_factory=dict, metadata=serde.mapping("local", StorageKey))
|
|
587
|
+
"""The local state storage keys"""
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
@dataclass
|
|
591
|
+
class Maps:
|
|
592
|
+
"""Storage maps for different storage types."""
|
|
593
|
+
|
|
594
|
+
box: dict[str, StorageMap] = field(default_factory=dict, metadata=serde.mapping("box", StorageMap))
|
|
595
|
+
"""The box storage maps"""
|
|
596
|
+
global_state: dict[str, StorageMap] = field(default_factory=dict, metadata=serde.mapping("global", StorageMap))
|
|
597
|
+
"""The global state storage maps"""
|
|
598
|
+
local_state: dict[str, StorageMap] = field(default_factory=dict, metadata=serde.mapping("local", StorageMap))
|
|
599
|
+
"""The local state storage maps"""
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
@dataclass
|
|
603
|
+
class State:
|
|
604
|
+
"""Application state information."""
|
|
605
|
+
|
|
606
|
+
keys: Keys = field(default_factory=Keys)
|
|
607
|
+
"""The storage keys"""
|
|
608
|
+
maps: Maps = field(default_factory=Maps)
|
|
609
|
+
"""The storage maps"""
|
|
610
|
+
schema: Schema = field(default_factory=Schema)
|
|
611
|
+
"""The state schema"""
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
@dataclass
|
|
615
|
+
class ProgramSourceInfo:
|
|
616
|
+
"""Program source information."""
|
|
617
|
+
|
|
618
|
+
pc_offset_method: PcOffsetMethod = field(metadata=wire("pcOffsetMethod"))
|
|
619
|
+
"""The PC offset method"""
|
|
620
|
+
source_info: list[SourceInfo] = field(metadata=serde.nested_sequence("sourceInfo", SourceInfo))
|
|
621
|
+
"""The list of source info entries"""
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
@dataclass
|
|
625
|
+
class SourceInfoModel:
|
|
626
|
+
"""Source information for approval and clear programs."""
|
|
627
|
+
|
|
628
|
+
approval: ProgramSourceInfo
|
|
629
|
+
"""The approval program source info"""
|
|
630
|
+
clear: ProgramSourceInfo
|
|
631
|
+
"""The clear program source info"""
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
_HasStructField = Argument | Returns | EventArg
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
@dataclass(kw_only=True)
|
|
638
|
+
class Arc56Contract:
|
|
639
|
+
"""ARC-0056 application specification.
|
|
640
|
+
|
|
641
|
+
See https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0056.md
|
|
642
|
+
"""
|
|
643
|
+
|
|
644
|
+
arcs: list[int] = field(default_factory=list, metadata=serde.sequence("arcs", int, omit_empty_seq=False))
|
|
645
|
+
"""The list of supported ARC version numbers"""
|
|
646
|
+
bare_actions: Actions = field(default_factory=Actions, metadata=nested("bareActions", Actions))
|
|
647
|
+
"""The bare call and create actions"""
|
|
648
|
+
methods: list[Method] = field(metadata=serde.nested_sequence("methods", Method))
|
|
649
|
+
"""The list of contract methods"""
|
|
650
|
+
name: str
|
|
651
|
+
"""The contract name"""
|
|
652
|
+
state: State = field(default_factory=State)
|
|
653
|
+
"""The contract state information"""
|
|
654
|
+
structs: dict[str, abi.StructType] = field(default_factory=dict, metadata=serde.struct_metadata)
|
|
655
|
+
"""The contract struct definitions"""
|
|
656
|
+
byte_code: ByteCode | None = field(default=None, metadata=nested("byteCode", ByteCode))
|
|
657
|
+
"""The optional bytecode for approval and clear programs"""
|
|
658
|
+
compiler_info: CompilerInfo | None = field(default=None, metadata=nested("compilerInfo", CompilerInfo))
|
|
659
|
+
"""The optional compiler information"""
|
|
660
|
+
desc: str | None = None
|
|
661
|
+
"""The optional contract description"""
|
|
662
|
+
events: list[Event] | None = field(default=None, metadata=serde.nested_sequence("events", Event))
|
|
663
|
+
"""The optional list of contract events"""
|
|
664
|
+
networks: dict[str, Network] | None = field(default=None, metadata=serde.mapping("networks", Network))
|
|
665
|
+
"""The optional network deployment information"""
|
|
666
|
+
scratch_variables: dict[str, ScratchVariables] | None = field(
|
|
667
|
+
default=None, metadata=serde.mapping("scratchVariables", ScratchVariables)
|
|
668
|
+
)
|
|
669
|
+
"""The optional scratch variable information"""
|
|
670
|
+
source: Source | None = None
|
|
671
|
+
"""The optional source code"""
|
|
672
|
+
source_info: SourceInfoModel | None = field(default=None, metadata=nested("sourceInfo", SourceInfoModel))
|
|
673
|
+
"""The optional source code information"""
|
|
674
|
+
template_variables: dict[str, TemplateVariables] | None = field(
|
|
675
|
+
default=None, metadata=serde.mapping("templateVariables", TemplateVariables)
|
|
676
|
+
)
|
|
677
|
+
"""The optional template variable information"""
|
|
678
|
+
|
|
679
|
+
def __post_init__(self) -> None:
|
|
680
|
+
self._update_contract_structs()
|
|
681
|
+
|
|
682
|
+
def apply_decode_types(self, resolve_struct_type: Callable[[abi.StructType], type]) -> "Arc56Contract":
|
|
683
|
+
"""
|
|
684
|
+
Returns a new contract specification where each StructType's decode_type
|
|
685
|
+
is updated with the result of resolve_struct_type, useful for supplying custom types used in
|
|
686
|
+
struct decoding
|
|
687
|
+
|
|
688
|
+
:param resolve_struct_type: Callback that can be used to supply custom types for any Struct types
|
|
689
|
+
:return: Arc56Contract instance
|
|
690
|
+
"""
|
|
691
|
+
return replace(
|
|
692
|
+
self,
|
|
693
|
+
structs={
|
|
694
|
+
struct_name: _apply_struct_types(struct_type, resolve_struct_type)
|
|
695
|
+
for struct_name, struct_type in self.structs.items()
|
|
696
|
+
},
|
|
697
|
+
)
|
|
698
|
+
|
|
699
|
+
@classmethod
|
|
700
|
+
def from_dict(
|
|
701
|
+
cls, application_spec: dict, resolve_struct_type: Callable[[abi.StructType], type] | None = None
|
|
702
|
+
) -> "Arc56Contract":
|
|
703
|
+
"""Create Arc56Contract from dictionary.
|
|
704
|
+
|
|
705
|
+
:param application_spec: Dictionary containing contract specification
|
|
706
|
+
:param resolve_struct_type: Optional callback that can be used to supply custom types for any Struct types
|
|
707
|
+
:return: Arc56Contract instance
|
|
708
|
+
"""
|
|
709
|
+
contract = from_wire(cls, application_spec)
|
|
710
|
+
if resolve_struct_type is not None:
|
|
711
|
+
contract = contract.apply_decode_types(resolve_struct_type)
|
|
712
|
+
return contract
|
|
713
|
+
|
|
714
|
+
@staticmethod
|
|
715
|
+
def from_json(
|
|
716
|
+
application_spec: str, resolve_struct_type: Callable[[abi.StructType], type] | None = None
|
|
717
|
+
) -> "Arc56Contract":
|
|
718
|
+
"""
|
|
719
|
+
Creates an instance from an ARC-56 application spec
|
|
720
|
+
|
|
721
|
+
:param application_spec: Dictionary containing contract specification
|
|
722
|
+
:param resolve_struct_type: Optional callback that can be used to supply custom types for any Struct types
|
|
723
|
+
:return: Arc56Contract instance
|
|
724
|
+
"""
|
|
725
|
+
return Arc56Contract.from_dict(json.loads(application_spec), resolve_struct_type)
|
|
726
|
+
|
|
727
|
+
@staticmethod
|
|
728
|
+
@deprecated("Arc32 contracts are being deprecated; prefer converting to Arc56 instead.")
|
|
729
|
+
def from_arc32(arc32_application_spec: typing.Union[str, "arc32.Arc32Contract"]) -> "Arc56Contract":
|
|
730
|
+
from algokit_abi import arc32_to_arc56
|
|
731
|
+
|
|
732
|
+
return arc32_to_arc56(arc32_application_spec)
|
|
733
|
+
|
|
734
|
+
def to_json(self, indent: int | None = None) -> str:
|
|
735
|
+
return json.dumps(self.dictify(), indent=indent)
|
|
736
|
+
|
|
737
|
+
def dictify(self) -> dict:
|
|
738
|
+
return to_wire(self)
|
|
739
|
+
|
|
740
|
+
def get_abi_method(self, method_name_or_signature: str) -> Method:
|
|
741
|
+
if "(" in method_name_or_signature:
|
|
742
|
+
methods = [m for m in self.methods if m.signature == method_name_or_signature]
|
|
743
|
+
else:
|
|
744
|
+
methods = [m for m in self.methods if m.name == method_name_or_signature]
|
|
745
|
+
|
|
746
|
+
if not methods:
|
|
747
|
+
raise ValueError(f"Unable to find method {method_name_or_signature} in {self.name} contract.")
|
|
748
|
+
try:
|
|
749
|
+
(method,) = methods
|
|
750
|
+
except ValueError:
|
|
751
|
+
signatures = [m.signature for m in methods]
|
|
752
|
+
raise ValueError(
|
|
753
|
+
f"Received a call to method {method_name_or_signature} in contract {self.name}, "
|
|
754
|
+
f"but this resolved to multiple methods; please pass in an ABI signature instead: "
|
|
755
|
+
f"{', '.join(signatures)}"
|
|
756
|
+
) from None
|
|
757
|
+
return method
|
|
758
|
+
|
|
759
|
+
def _update_contract_structs(self) -> None:
|
|
760
|
+
for method in self.methods:
|
|
761
|
+
for arg in method.args:
|
|
762
|
+
self._maybe_update_struct(arg)
|
|
763
|
+
self._maybe_update_struct(method.returns)
|
|
764
|
+
for event in method.events or []:
|
|
765
|
+
for event_arg in event.args:
|
|
766
|
+
self._maybe_update_struct(event_arg)
|
|
767
|
+
for event in self.events or []:
|
|
768
|
+
for event_arg in event.args:
|
|
769
|
+
self._maybe_update_struct(event_arg)
|
|
770
|
+
self._replace_state_structs()
|
|
771
|
+
for template in (self.template_variables or {}).values():
|
|
772
|
+
self._maybe_update_abi_struct_type(template, "type")
|
|
773
|
+
for scratch in (self.scratch_variables or {}).values():
|
|
774
|
+
self._maybe_update_abi_struct_type(scratch, "type")
|
|
775
|
+
|
|
776
|
+
def _replace_state_structs(self) -> None:
|
|
777
|
+
keys = self.state.keys
|
|
778
|
+
maps = self.state.maps
|
|
779
|
+
for storage_maps in (
|
|
780
|
+
keys.box,
|
|
781
|
+
keys.global_state,
|
|
782
|
+
keys.local_state,
|
|
783
|
+
maps.box,
|
|
784
|
+
maps.global_state,
|
|
785
|
+
maps.local_state,
|
|
786
|
+
):
|
|
787
|
+
for storage in storage_maps.values():
|
|
788
|
+
self._maybe_update_abi_struct_type(storage, "key_type", "value_type")
|
|
789
|
+
|
|
790
|
+
def _maybe_update_struct(self, has_struct: _HasStructField) -> None:
|
|
791
|
+
if has_struct.struct is not None:
|
|
792
|
+
has_struct.type = self.structs[has_struct.struct]
|
|
793
|
+
|
|
794
|
+
def _maybe_update_abi_struct_type(self, storage: object, *names: str) -> None:
|
|
795
|
+
for name in names:
|
|
796
|
+
backing_type = getattr(storage, f"_{name}")
|
|
797
|
+
if type(backing_type) is str: # only match str exactly, so enums are not used
|
|
798
|
+
resolved_type = self.structs[backing_type]
|
|
799
|
+
else:
|
|
800
|
+
resolved_type = backing_type
|
|
801
|
+
setattr(storage, name, resolved_type)
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
_TABIType = typing.TypeVar("_TABIType", bound=abi.ABIType)
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
def _apply_struct_types(abi_type: _TABIType, resolve_type: Callable[[abi.StructType], type]) -> _TABIType:
|
|
808
|
+
if isinstance(abi_type, abi.StructType):
|
|
809
|
+
return replace(
|
|
810
|
+
abi_type,
|
|
811
|
+
decode_type=resolve_type(abi_type),
|
|
812
|
+
fields={
|
|
813
|
+
field_name: _apply_struct_types(field_type, resolve_type)
|
|
814
|
+
for field_name, field_type in abi_type.fields.items()
|
|
815
|
+
},
|
|
816
|
+
)
|
|
817
|
+
elif isinstance(abi_type, abi.StaticArrayType | abi.DynamicArrayType):
|
|
818
|
+
return replace(abi_type, element=_apply_struct_types(abi_type.element, resolve_type))
|
|
819
|
+
elif isinstance(abi_type, abi.TupleType):
|
|
820
|
+
return replace(abi_type, elements=tuple(_apply_struct_types(e, resolve_type) for e in abi_type.elements))
|
|
821
|
+
return abi_type
|