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,380 @@
|
|
|
1
|
+
from collections.abc import Sequence
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
|
|
4
|
+
from typing_extensions import assert_never, assert_type
|
|
5
|
+
|
|
6
|
+
from algokit_abi import abi, arc56
|
|
7
|
+
from algokit_transact.models.app_call import AppCallTransactionFields
|
|
8
|
+
from algokit_transact.models.common import OnApplicationComplete, StateSchema
|
|
9
|
+
from algokit_transact.models.transaction import TransactionType
|
|
10
|
+
from algokit_utils.applications.app_manager import AppManager
|
|
11
|
+
from algokit_utils.transactions.builders.app import _compile_program, _convert_box_references
|
|
12
|
+
from algokit_utils.transactions.builders.common import (
|
|
13
|
+
BuiltTransaction,
|
|
14
|
+
SuggestedParamsLike,
|
|
15
|
+
TransactionHeader,
|
|
16
|
+
apply_transaction_fees,
|
|
17
|
+
build_transaction,
|
|
18
|
+
build_transaction_header,
|
|
19
|
+
)
|
|
20
|
+
from algokit_utils.transactions.helpers import calculate_extra_program_pages
|
|
21
|
+
from algokit_utils.transactions.types import (
|
|
22
|
+
AppCallMethodCallParams,
|
|
23
|
+
AppCreateMethodCallParams,
|
|
24
|
+
AppDeleteMethodCallParams,
|
|
25
|
+
AppUpdateMethodCallParams,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
ARGS_TUPLE_PACKING_THRESHOLD = 14
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
"build_app_call_method_call_transaction",
|
|
32
|
+
"build_app_create_method_call_transaction",
|
|
33
|
+
"build_app_delete_method_call_transaction",
|
|
34
|
+
"build_app_update_method_call_transaction",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def build_app_call_method_call_transaction(
|
|
39
|
+
params: AppCallMethodCallParams | AppDeleteMethodCallParams,
|
|
40
|
+
suggested_params: SuggestedParamsLike,
|
|
41
|
+
*,
|
|
42
|
+
method_args: Sequence | None,
|
|
43
|
+
app_manager: AppManager,
|
|
44
|
+
default_validity_window: int,
|
|
45
|
+
default_validity_window_is_explicit: bool,
|
|
46
|
+
is_localnet: bool,
|
|
47
|
+
) -> BuiltTransaction:
|
|
48
|
+
header, fee_config = build_transaction_header(
|
|
49
|
+
params,
|
|
50
|
+
suggested_params,
|
|
51
|
+
default_validity_window=default_validity_window,
|
|
52
|
+
default_validity_window_is_explicit=default_validity_window_is_explicit,
|
|
53
|
+
is_localnet=is_localnet,
|
|
54
|
+
)
|
|
55
|
+
common = _build_method_call_common(
|
|
56
|
+
params.app_id,
|
|
57
|
+
params.method,
|
|
58
|
+
method_args,
|
|
59
|
+
header,
|
|
60
|
+
params.account_references,
|
|
61
|
+
params.app_references,
|
|
62
|
+
params.asset_references,
|
|
63
|
+
)
|
|
64
|
+
fields = AppCallTransactionFields(
|
|
65
|
+
app_id=params.app_id,
|
|
66
|
+
on_complete=params.on_complete or OnApplicationComplete.NoOp,
|
|
67
|
+
args=common.args,
|
|
68
|
+
account_references=_to_maybe_list(common.account_references),
|
|
69
|
+
app_references=_to_maybe_list(common.app_references),
|
|
70
|
+
asset_references=_to_maybe_list(common.asset_references),
|
|
71
|
+
box_references=_convert_box_references(params.box_references, app_manager),
|
|
72
|
+
)
|
|
73
|
+
txn = build_transaction(TransactionType.AppCall, header, application_call=fields)
|
|
74
|
+
return apply_transaction_fees(txn, params, fee_config)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def build_app_delete_method_call_transaction(
|
|
78
|
+
params: AppDeleteMethodCallParams,
|
|
79
|
+
suggested_params: SuggestedParamsLike,
|
|
80
|
+
*,
|
|
81
|
+
method_args: Sequence | None,
|
|
82
|
+
app_manager: AppManager,
|
|
83
|
+
default_validity_window: int,
|
|
84
|
+
default_validity_window_is_explicit: bool,
|
|
85
|
+
is_localnet: bool,
|
|
86
|
+
) -> BuiltTransaction:
|
|
87
|
+
return build_app_call_method_call_transaction(
|
|
88
|
+
params,
|
|
89
|
+
suggested_params,
|
|
90
|
+
method_args=method_args,
|
|
91
|
+
app_manager=app_manager,
|
|
92
|
+
default_validity_window=default_validity_window,
|
|
93
|
+
default_validity_window_is_explicit=default_validity_window_is_explicit,
|
|
94
|
+
is_localnet=is_localnet,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def build_app_create_method_call_transaction(
|
|
99
|
+
params: AppCreateMethodCallParams,
|
|
100
|
+
suggested_params: SuggestedParamsLike,
|
|
101
|
+
*,
|
|
102
|
+
method_args: Sequence | None,
|
|
103
|
+
app_manager: AppManager,
|
|
104
|
+
default_validity_window: int,
|
|
105
|
+
default_validity_window_is_explicit: bool,
|
|
106
|
+
is_localnet: bool,
|
|
107
|
+
) -> BuiltTransaction:
|
|
108
|
+
header, fee_config = build_transaction_header(
|
|
109
|
+
params,
|
|
110
|
+
suggested_params,
|
|
111
|
+
default_validity_window=default_validity_window,
|
|
112
|
+
default_validity_window_is_explicit=default_validity_window_is_explicit,
|
|
113
|
+
is_localnet=is_localnet,
|
|
114
|
+
)
|
|
115
|
+
approval_program = _compile_program(app_manager, params.approval_program)
|
|
116
|
+
clear_state_program = _compile_program(app_manager, params.clear_state_program)
|
|
117
|
+
schema = params.schema
|
|
118
|
+
global_schema = StateSchema(
|
|
119
|
+
num_uints=schema["global_ints"] if schema else 0,
|
|
120
|
+
num_byte_slices=schema["global_byte_slices"] if schema else 0,
|
|
121
|
+
)
|
|
122
|
+
local_schema = StateSchema(
|
|
123
|
+
num_uints=schema["local_ints"] if schema else 0,
|
|
124
|
+
num_byte_slices=schema["local_byte_slices"] if schema else 0,
|
|
125
|
+
)
|
|
126
|
+
extra_pages = params.extra_program_pages or calculate_extra_program_pages(approval_program, clear_state_program)
|
|
127
|
+
common = _build_method_call_common(
|
|
128
|
+
0,
|
|
129
|
+
params.method,
|
|
130
|
+
method_args,
|
|
131
|
+
header,
|
|
132
|
+
params.account_references,
|
|
133
|
+
params.app_references,
|
|
134
|
+
params.asset_references,
|
|
135
|
+
)
|
|
136
|
+
fields = AppCallTransactionFields(
|
|
137
|
+
app_id=0,
|
|
138
|
+
on_complete=params.on_complete or OnApplicationComplete.NoOp,
|
|
139
|
+
approval_program=approval_program,
|
|
140
|
+
clear_state_program=clear_state_program,
|
|
141
|
+
global_state_schema=global_schema,
|
|
142
|
+
local_state_schema=local_schema,
|
|
143
|
+
extra_program_pages=extra_pages,
|
|
144
|
+
args=common.args,
|
|
145
|
+
account_references=_to_maybe_list(common.account_references),
|
|
146
|
+
app_references=_to_maybe_list(common.app_references),
|
|
147
|
+
asset_references=_to_maybe_list(common.asset_references),
|
|
148
|
+
box_references=_convert_box_references(params.box_references, app_manager),
|
|
149
|
+
)
|
|
150
|
+
txn = build_transaction(TransactionType.AppCall, header, application_call=fields)
|
|
151
|
+
return apply_transaction_fees(txn, params, fee_config)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def build_app_update_method_call_transaction(
|
|
155
|
+
params: AppUpdateMethodCallParams,
|
|
156
|
+
suggested_params: SuggestedParamsLike,
|
|
157
|
+
*,
|
|
158
|
+
method_args: Sequence | None,
|
|
159
|
+
app_manager: AppManager,
|
|
160
|
+
default_validity_window: int,
|
|
161
|
+
default_validity_window_is_explicit: bool,
|
|
162
|
+
is_localnet: bool,
|
|
163
|
+
) -> BuiltTransaction:
|
|
164
|
+
header, fee_config = build_transaction_header(
|
|
165
|
+
params,
|
|
166
|
+
suggested_params,
|
|
167
|
+
default_validity_window=default_validity_window,
|
|
168
|
+
default_validity_window_is_explicit=default_validity_window_is_explicit,
|
|
169
|
+
is_localnet=is_localnet,
|
|
170
|
+
)
|
|
171
|
+
approval_program = _compile_program(app_manager, params.approval_program)
|
|
172
|
+
clear_state_program = _compile_program(app_manager, params.clear_state_program)
|
|
173
|
+
common = _build_method_call_common(
|
|
174
|
+
params.app_id,
|
|
175
|
+
params.method,
|
|
176
|
+
method_args,
|
|
177
|
+
header,
|
|
178
|
+
params.account_references,
|
|
179
|
+
params.app_references,
|
|
180
|
+
params.asset_references,
|
|
181
|
+
)
|
|
182
|
+
fields = AppCallTransactionFields(
|
|
183
|
+
app_id=params.app_id,
|
|
184
|
+
on_complete=OnApplicationComplete.UpdateApplication,
|
|
185
|
+
approval_program=approval_program,
|
|
186
|
+
clear_state_program=clear_state_program,
|
|
187
|
+
args=common.args,
|
|
188
|
+
account_references=_to_maybe_list(common.account_references),
|
|
189
|
+
app_references=_to_maybe_list(common.app_references),
|
|
190
|
+
asset_references=_to_maybe_list(common.asset_references),
|
|
191
|
+
box_references=_convert_box_references(params.box_references, app_manager),
|
|
192
|
+
)
|
|
193
|
+
txn = build_transaction(TransactionType.AppCall, header, application_call=fields)
|
|
194
|
+
return apply_transaction_fees(txn, params, fee_config)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
@dataclass(slots=True)
|
|
198
|
+
class _MethodCallCommon:
|
|
199
|
+
args: list[bytes]
|
|
200
|
+
account_references: list[str]
|
|
201
|
+
app_references: list[int]
|
|
202
|
+
asset_references: list[int]
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def _build_method_call_common(
|
|
206
|
+
app_id: int,
|
|
207
|
+
method: arc56.Method,
|
|
208
|
+
method_args: Sequence | None,
|
|
209
|
+
header: TransactionHeader,
|
|
210
|
+
account_references: Sequence[str] | None,
|
|
211
|
+
app_references: Sequence[int] | None,
|
|
212
|
+
asset_references: Sequence[int] | None,
|
|
213
|
+
) -> _MethodCallCommon:
|
|
214
|
+
accounts, apps, assets = _populate_method_args_into_reference_arrays(
|
|
215
|
+
header.sender,
|
|
216
|
+
app_id,
|
|
217
|
+
method,
|
|
218
|
+
method_args or [],
|
|
219
|
+
account_references,
|
|
220
|
+
app_references,
|
|
221
|
+
asset_references,
|
|
222
|
+
)
|
|
223
|
+
encoded_args = _encode_method_arguments(
|
|
224
|
+
method,
|
|
225
|
+
method_args or [],
|
|
226
|
+
header.sender,
|
|
227
|
+
app_id,
|
|
228
|
+
accounts,
|
|
229
|
+
apps,
|
|
230
|
+
assets,
|
|
231
|
+
)
|
|
232
|
+
return _MethodCallCommon(
|
|
233
|
+
args=encoded_args, account_references=accounts, app_references=apps, asset_references=assets
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def _populate_method_args_into_reference_arrays(
|
|
238
|
+
sender: str,
|
|
239
|
+
app_id: int,
|
|
240
|
+
method: arc56.Method,
|
|
241
|
+
method_args: Sequence,
|
|
242
|
+
account_references: Sequence[str] | None,
|
|
243
|
+
app_references: Sequence[int] | None,
|
|
244
|
+
asset_references: Sequence[int] | None,
|
|
245
|
+
) -> tuple[list[str], list[int], list[int]]:
|
|
246
|
+
accounts = list(account_references or [])
|
|
247
|
+
apps = list(app_references or [])
|
|
248
|
+
assets = list(asset_references or [])
|
|
249
|
+
|
|
250
|
+
for arg_value, arg in zip(method_args, method.args, strict=False):
|
|
251
|
+
if arg_value is None:
|
|
252
|
+
continue
|
|
253
|
+
arg_type = arg.type
|
|
254
|
+
if (
|
|
255
|
+
arg_type == arc56.ReferenceType.ACCOUNT
|
|
256
|
+
and isinstance(arg_value, str)
|
|
257
|
+
and arg_value != sender
|
|
258
|
+
and arg_value not in accounts
|
|
259
|
+
):
|
|
260
|
+
accounts.append(arg_value)
|
|
261
|
+
elif arg_type == arc56.ReferenceType.ASSET and isinstance(arg_value, int) and arg_value not in assets:
|
|
262
|
+
assets.append(arg_value)
|
|
263
|
+
elif (
|
|
264
|
+
arg_type == arc56.ReferenceType.APPLICATION
|
|
265
|
+
and isinstance(arg_value, int)
|
|
266
|
+
and arg_value != app_id
|
|
267
|
+
and arg_value not in apps
|
|
268
|
+
):
|
|
269
|
+
apps.append(arg_value)
|
|
270
|
+
# Non-reference args do not change reference arrays
|
|
271
|
+
return accounts, apps, assets
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
def _encode_method_arguments(
|
|
275
|
+
method: arc56.Method,
|
|
276
|
+
method_args: Sequence,
|
|
277
|
+
sender: str,
|
|
278
|
+
app_id: int,
|
|
279
|
+
account_references: Sequence[str],
|
|
280
|
+
app_references: Sequence[int],
|
|
281
|
+
asset_references: Sequence[int],
|
|
282
|
+
) -> list[bytes]:
|
|
283
|
+
encoded_args = list[bytes]()
|
|
284
|
+
encoded_args.append(method.selector)
|
|
285
|
+
|
|
286
|
+
abi_types = list[abi.ABIType]()
|
|
287
|
+
abi_values = []
|
|
288
|
+
|
|
289
|
+
for arg, arg_value in zip(method.args, method_args, strict=False):
|
|
290
|
+
if arg_value is None:
|
|
291
|
+
continue
|
|
292
|
+
arg_type = arg.type
|
|
293
|
+
if isinstance(arg_type, arc56.TransactionType):
|
|
294
|
+
continue
|
|
295
|
+
if isinstance(arg_type, abi.ABIType):
|
|
296
|
+
abi_type = arg_type
|
|
297
|
+
abi_value = arg_value
|
|
298
|
+
else:
|
|
299
|
+
assert_type(arg_type, arc56.ReferenceType)
|
|
300
|
+
index = _calculate_reference_index(
|
|
301
|
+
arg_value,
|
|
302
|
+
arg_type,
|
|
303
|
+
sender,
|
|
304
|
+
app_id,
|
|
305
|
+
account_references,
|
|
306
|
+
app_references,
|
|
307
|
+
asset_references,
|
|
308
|
+
)
|
|
309
|
+
abi_type = abi.UintType(8)
|
|
310
|
+
abi_value = index
|
|
311
|
+
abi_types.append(abi_type)
|
|
312
|
+
abi_values.append(abi_value)
|
|
313
|
+
|
|
314
|
+
if len(abi_types) != len(abi_values):
|
|
315
|
+
raise ValueError("Mismatch between ABI argument types and values")
|
|
316
|
+
|
|
317
|
+
encoded_args.extend(_encode_args_with_tuple_packing(abi_types, abi_values))
|
|
318
|
+
return encoded_args
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
def _calculate_reference_index(
|
|
322
|
+
value: str | int,
|
|
323
|
+
reference_type: arc56.ReferenceType,
|
|
324
|
+
sender: str,
|
|
325
|
+
app_id: int,
|
|
326
|
+
account_references: Sequence[str],
|
|
327
|
+
app_references: Sequence[int],
|
|
328
|
+
asset_references: Sequence[int],
|
|
329
|
+
) -> int:
|
|
330
|
+
if reference_type == arc56.ReferenceType.ACCOUNT:
|
|
331
|
+
return _calculate_account_reference_index(value, sender, account_references)
|
|
332
|
+
if reference_type == arc56.ReferenceType.ASSET:
|
|
333
|
+
return _calculate_asset_reference_index(value, asset_references)
|
|
334
|
+
if reference_type == arc56.ReferenceType.APPLICATION:
|
|
335
|
+
return _calculate_application_reference_index(value, app_id, app_references)
|
|
336
|
+
assert_never(reference_type)
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
def _calculate_account_reference_index(value: str | int, sender: str, account_references: Sequence[str]) -> int:
|
|
340
|
+
if not isinstance(value, str):
|
|
341
|
+
raise ValueError("Account reference arguments must be base32 addresses")
|
|
342
|
+
if value == sender:
|
|
343
|
+
return 0
|
|
344
|
+
if value not in account_references:
|
|
345
|
+
raise ValueError(f"Account reference {value} not present in reference array")
|
|
346
|
+
return account_references.index(value) + 1
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
def _calculate_asset_reference_index(value: str | int, asset_references: Sequence[int]) -> int:
|
|
350
|
+
if not isinstance(value, int):
|
|
351
|
+
raise ValueError("Asset reference arguments must be integers")
|
|
352
|
+
if value not in asset_references:
|
|
353
|
+
raise ValueError(f"Asset reference {value} not present in reference array")
|
|
354
|
+
return asset_references.index(value)
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
def _calculate_application_reference_index(value: str | int, app_id: int, app_references: Sequence[int]) -> int:
|
|
358
|
+
if not isinstance(value, int):
|
|
359
|
+
raise ValueError("Application reference arguments must be integers")
|
|
360
|
+
if value == app_id:
|
|
361
|
+
return 0
|
|
362
|
+
if value not in app_references:
|
|
363
|
+
raise ValueError(f"Application reference {value} not present in reference array")
|
|
364
|
+
return app_references.index(value) + 1
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
def _encode_args_with_tuple_packing(abi_types: Sequence[abi.ABIType], abi_values: Sequence) -> list[bytes]:
|
|
368
|
+
type_value_pairs = list(zip(abi_types, abi_values, strict=True))
|
|
369
|
+
unpacked_pairs = type_value_pairs[:ARGS_TUPLE_PACKING_THRESHOLD]
|
|
370
|
+
packed_pairs = type_value_pairs[ARGS_TUPLE_PACKING_THRESHOLD:]
|
|
371
|
+
encoded = [abi_type.encode(abi_value) for abi_type, abi_value in unpacked_pairs]
|
|
372
|
+
|
|
373
|
+
if packed_pairs:
|
|
374
|
+
tuple_type = abi.TupleType([t[0] for t in packed_pairs])
|
|
375
|
+
encoded.append(tuple_type.encode([t[1] for t in packed_pairs]))
|
|
376
|
+
return encoded
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
def _to_maybe_list(values: Sequence | None) -> list | None:
|
|
380
|
+
return list(values) if values else None
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from algokit_transact.models.payment import PaymentTransactionFields
|
|
2
|
+
from algokit_transact.models.transaction import TransactionType
|
|
3
|
+
from algokit_utils.transactions.builders.common import (
|
|
4
|
+
BuiltTransaction,
|
|
5
|
+
SuggestedParamsLike,
|
|
6
|
+
apply_transaction_fees,
|
|
7
|
+
build_transaction,
|
|
8
|
+
build_transaction_header,
|
|
9
|
+
)
|
|
10
|
+
from algokit_utils.transactions.types import PaymentParams
|
|
11
|
+
|
|
12
|
+
__all__ = ["build_payment_transaction"]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def build_payment_transaction(
|
|
16
|
+
params: PaymentParams,
|
|
17
|
+
suggested_params: SuggestedParamsLike,
|
|
18
|
+
*,
|
|
19
|
+
default_validity_window: int,
|
|
20
|
+
default_validity_window_is_explicit: bool,
|
|
21
|
+
is_localnet: bool,
|
|
22
|
+
) -> BuiltTransaction:
|
|
23
|
+
header, fee_config = build_transaction_header(
|
|
24
|
+
params,
|
|
25
|
+
suggested_params,
|
|
26
|
+
default_validity_window=default_validity_window,
|
|
27
|
+
default_validity_window_is_explicit=default_validity_window_is_explicit,
|
|
28
|
+
is_localnet=is_localnet,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
payment_fields = PaymentTransactionFields(
|
|
32
|
+
amount=params.amount.micro_algo,
|
|
33
|
+
receiver=params.receiver,
|
|
34
|
+
close_remainder_to=params.close_remainder_to,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
txn = build_transaction(
|
|
38
|
+
TransactionType.Payment,
|
|
39
|
+
header,
|
|
40
|
+
payment=payment_fields,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
return apply_transaction_fees(txn, params, fee_config)
|