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,344 @@
|
|
|
1
|
+
from collections.abc import Callable
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
|
|
4
|
+
from algokit_algod_client import AlgodClient
|
|
5
|
+
from algokit_common import MAX_TRANSACTION_GROUP_SIZE
|
|
6
|
+
from algokit_transact.signer import AddressWithSigners, AddressWithTransactionSigner, TransactionSigner
|
|
7
|
+
from algokit_utils.models.amount import AlgoAmount
|
|
8
|
+
from algokit_utils.models.transaction import SendParams
|
|
9
|
+
from algokit_utils.transactions.transaction_composer import (
|
|
10
|
+
AssetOptInParams,
|
|
11
|
+
AssetOptOutParams,
|
|
12
|
+
TransactionComposer,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
__all__ = ["AccountAssetInformation", "AssetInformation", "AssetManager", "BulkAssetOptInOutResult"]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass(kw_only=True, frozen=True)
|
|
19
|
+
class AccountAssetInformation:
|
|
20
|
+
"""Information about an account's holding of a particular asset."""
|
|
21
|
+
|
|
22
|
+
asset_id: int
|
|
23
|
+
"""The ID of the asset"""
|
|
24
|
+
balance: int
|
|
25
|
+
"""The amount of the asset held by the account"""
|
|
26
|
+
frozen: bool
|
|
27
|
+
"""Whether the asset is frozen for this account"""
|
|
28
|
+
round: int
|
|
29
|
+
"""The round this information was retrieved at"""
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@dataclass(kw_only=True, frozen=True)
|
|
33
|
+
class AssetInformation:
|
|
34
|
+
"""Information about an Algorand Standard Asset (ASA)."""
|
|
35
|
+
|
|
36
|
+
asset_id: int
|
|
37
|
+
"""The ID of the asset"""
|
|
38
|
+
creator: str
|
|
39
|
+
"""The address of the account that created the asset"""
|
|
40
|
+
total: int
|
|
41
|
+
"""The total amount of the smallest divisible units that were created of the asset"""
|
|
42
|
+
decimals: int
|
|
43
|
+
"""The amount of decimal places the asset was created with"""
|
|
44
|
+
default_frozen: bool | None = None
|
|
45
|
+
"""Whether the asset was frozen by default for all accounts, defaults to None"""
|
|
46
|
+
manager: str | None = None
|
|
47
|
+
"""The address of the optional account that can manage the configuration of the asset and destroy it,
|
|
48
|
+
defaults to None"""
|
|
49
|
+
reserve: str | None = None
|
|
50
|
+
"""The address of the optional account that holds the reserve (uncirculated supply) units of the asset,
|
|
51
|
+
defaults to None"""
|
|
52
|
+
freeze: str | None = None
|
|
53
|
+
"""The address of the optional account that can be used to freeze or unfreeze holdings of this asset,
|
|
54
|
+
defaults to None"""
|
|
55
|
+
clawback: str | None = None
|
|
56
|
+
"""The address of the optional account that can clawback holdings of this asset from any account,
|
|
57
|
+
defaults to None"""
|
|
58
|
+
unit_name: str | None = None
|
|
59
|
+
"""The optional name of the unit of this asset (e.g. ticker name), defaults to None"""
|
|
60
|
+
unit_name_b64: bytes | None = None
|
|
61
|
+
"""The optional name of the unit of this asset as bytes, defaults to None"""
|
|
62
|
+
asset_name: str | None = None
|
|
63
|
+
"""The optional name of the asset, defaults to None"""
|
|
64
|
+
asset_name_b64: bytes | None = None
|
|
65
|
+
"""The optional name of the asset as bytes, defaults to None"""
|
|
66
|
+
url: str | None = None
|
|
67
|
+
"""The optional URL where more information about the asset can be retrieved, defaults to None"""
|
|
68
|
+
url_b64: bytes | None = None
|
|
69
|
+
"""The optional URL where more information about the asset can be retrieved as bytes, defaults to None"""
|
|
70
|
+
metadata_hash: bytes | None = None
|
|
71
|
+
"""The 32-byte hash of some metadata that is relevant to the asset and/or asset holders, defaults to None"""
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
@dataclass(kw_only=True, frozen=True)
|
|
75
|
+
class BulkAssetOptInOutResult:
|
|
76
|
+
"""Result from performing a bulk opt-in or bulk opt-out for an account against a series of assets.
|
|
77
|
+
|
|
78
|
+
:ivar asset_id: The ID of the asset opted into / out of
|
|
79
|
+
:ivar transaction_id: The transaction ID of the resulting opt in / out
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
asset_id: int
|
|
83
|
+
"""The ID of the asset opted into / out of"""
|
|
84
|
+
transaction_id: str
|
|
85
|
+
"""The transaction ID of the resulting opt in / out"""
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class AssetManager:
|
|
89
|
+
"""A manager for Algorand Standard Assets (ASAs).
|
|
90
|
+
|
|
91
|
+
:param algod_client: An AlgodClient instance
|
|
92
|
+
:param new_group: A function that creates a new TransactionComposer transaction group
|
|
93
|
+
|
|
94
|
+
:example:
|
|
95
|
+
>>> asset_manager = AssetManager(algod_client)
|
|
96
|
+
"""
|
|
97
|
+
|
|
98
|
+
def __init__(self, algod_client: AlgodClient, new_group: Callable[[], TransactionComposer]):
|
|
99
|
+
self._algod = algod_client
|
|
100
|
+
self._new_group = new_group
|
|
101
|
+
|
|
102
|
+
def get_by_id(self, asset_id: int) -> AssetInformation:
|
|
103
|
+
"""Returns the current asset information for the asset with the given ID.
|
|
104
|
+
|
|
105
|
+
Uses typed algod client `get_asset_by_id` and maps `asset.params.*` fields into an
|
|
106
|
+
`AssetInformation` dataclass. All values are sourced from typed model attributes
|
|
107
|
+
(e.g. `asset.params.total`, `asset.params.manager`, `asset.params.unit_name`)
|
|
108
|
+
rather than dictionary keys (legacy: `asset_info["params"]["total"]`, etc.).
|
|
109
|
+
|
|
110
|
+
:param asset_id: The asset identifier
|
|
111
|
+
:return: `AssetInformation` with strongly typed fields
|
|
112
|
+
|
|
113
|
+
:example:
|
|
114
|
+
>>> asset_manager = AssetManager(algod_client)
|
|
115
|
+
>>> info = asset_manager.get_by_id(1234567890)
|
|
116
|
+
>>> print(info.total, info.creator, info.unit_name)
|
|
117
|
+
"""
|
|
118
|
+
asset = self._algod.get_asset_by_id(asset_id)
|
|
119
|
+
params = asset.params
|
|
120
|
+
|
|
121
|
+
return AssetInformation(
|
|
122
|
+
asset_id=asset_id,
|
|
123
|
+
total=params.total,
|
|
124
|
+
decimals=params.decimals,
|
|
125
|
+
asset_name=params.name,
|
|
126
|
+
asset_name_b64=params.name_b64,
|
|
127
|
+
unit_name=params.unit_name,
|
|
128
|
+
unit_name_b64=params.unit_name_b64,
|
|
129
|
+
url=params.url,
|
|
130
|
+
url_b64=params.url_b64,
|
|
131
|
+
creator=params.creator,
|
|
132
|
+
manager=params.manager,
|
|
133
|
+
clawback=params.clawback,
|
|
134
|
+
freeze=params.freeze,
|
|
135
|
+
reserve=params.reserve,
|
|
136
|
+
default_frozen=bool(params.default_frozen) if params.default_frozen is not None else None,
|
|
137
|
+
metadata_hash=params.metadata_hash,
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
def get_account_information(
|
|
141
|
+
self, sender: str | AddressWithTransactionSigner, asset_id: int
|
|
142
|
+
) -> AccountAssetInformation:
|
|
143
|
+
"""Returns the given sender account's asset holding for a given asset.
|
|
144
|
+
|
|
145
|
+
:param sender: The address of the sender/account to look up
|
|
146
|
+
:param asset_id: The ID of the asset to return a holding for
|
|
147
|
+
:return: The account asset holding information
|
|
148
|
+
:raises ValueError: If the account has no holding for the specified asset
|
|
149
|
+
|
|
150
|
+
:example:
|
|
151
|
+
>>> asset_manager = AssetManager(algod_client)
|
|
152
|
+
>>> account_asset_info = asset_manager.get_account_information(sender, asset_id)
|
|
153
|
+
"""
|
|
154
|
+
address = self._get_address_from_sender(sender)
|
|
155
|
+
info = self._algod.account_asset_information(address, asset_id)
|
|
156
|
+
holding = info.asset_holding
|
|
157
|
+
if holding is None:
|
|
158
|
+
raise ValueError("Account has no holding for the specified asset")
|
|
159
|
+
|
|
160
|
+
return AccountAssetInformation(
|
|
161
|
+
asset_id=asset_id,
|
|
162
|
+
balance=holding.amount,
|
|
163
|
+
# TODO: resolve bool val resolution in api generator
|
|
164
|
+
frozen=bool(holding.is_frozen) if holding.is_frozen is not None else False,
|
|
165
|
+
round=info.round_,
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
def bulk_opt_in( # noqa: PLR0913
|
|
169
|
+
self,
|
|
170
|
+
account: str,
|
|
171
|
+
asset_ids: list[int],
|
|
172
|
+
signer: TransactionSigner | None = None,
|
|
173
|
+
rekey_to: str | None = None,
|
|
174
|
+
note: bytes | None = None,
|
|
175
|
+
lease: bytes | None = None,
|
|
176
|
+
static_fee: AlgoAmount | None = None,
|
|
177
|
+
extra_fee: AlgoAmount | None = None,
|
|
178
|
+
max_fee: AlgoAmount | None = None,
|
|
179
|
+
validity_window: int | None = None,
|
|
180
|
+
first_valid_round: int | None = None,
|
|
181
|
+
last_valid_round: int | None = None,
|
|
182
|
+
send_params: SendParams | None = None,
|
|
183
|
+
) -> list[BulkAssetOptInOutResult]:
|
|
184
|
+
"""Opt an account in to a list of Algorand Standard Assets.
|
|
185
|
+
|
|
186
|
+
:param account: The account to opt-in
|
|
187
|
+
:param asset_ids: The list of asset IDs to opt-in to
|
|
188
|
+
:param signer: The signer to use for the transaction, defaults to None
|
|
189
|
+
:param rekey_to: The address to rekey the account to, defaults to None
|
|
190
|
+
:param note: The note to include in the transaction, defaults to None
|
|
191
|
+
:param lease: The lease to include in the transaction, defaults to None
|
|
192
|
+
:param static_fee: The static fee to include in the transaction, defaults to None
|
|
193
|
+
:param extra_fee: The extra fee to include in the transaction, defaults to None
|
|
194
|
+
:param max_fee: The maximum fee to include in the transaction, defaults to None
|
|
195
|
+
:param validity_window: The validity window to include in the transaction, defaults to None
|
|
196
|
+
:param first_valid_round: The first valid round to include in the transaction, defaults to None
|
|
197
|
+
:param last_valid_round: The last valid round to include in the transaction, defaults to None
|
|
198
|
+
:param send_params: The send parameters to use for the transaction, defaults to None
|
|
199
|
+
:return: An array of records matching asset ID to transaction ID of the opt in
|
|
200
|
+
|
|
201
|
+
:example:
|
|
202
|
+
>>> asset_manager = AssetManager(algod_client)
|
|
203
|
+
>>> results = asset_manager.bulk_opt_in(account, asset_ids)
|
|
204
|
+
"""
|
|
205
|
+
results: list[BulkAssetOptInOutResult] = []
|
|
206
|
+
sender = self._get_address_from_sender(account)
|
|
207
|
+
|
|
208
|
+
for asset_group in _chunk_array(asset_ids, MAX_TRANSACTION_GROUP_SIZE):
|
|
209
|
+
composer = self._new_group()
|
|
210
|
+
|
|
211
|
+
for asset_id in asset_group:
|
|
212
|
+
params = AssetOptInParams(
|
|
213
|
+
sender=sender,
|
|
214
|
+
asset_id=asset_id,
|
|
215
|
+
signer=signer,
|
|
216
|
+
rekey_to=rekey_to,
|
|
217
|
+
note=note,
|
|
218
|
+
lease=lease,
|
|
219
|
+
static_fee=static_fee,
|
|
220
|
+
extra_fee=extra_fee,
|
|
221
|
+
max_fee=max_fee,
|
|
222
|
+
validity_window=validity_window,
|
|
223
|
+
first_valid_round=first_valid_round,
|
|
224
|
+
last_valid_round=last_valid_round,
|
|
225
|
+
)
|
|
226
|
+
composer.add_asset_opt_in(params)
|
|
227
|
+
|
|
228
|
+
result = composer.send(send_params)
|
|
229
|
+
|
|
230
|
+
for i, asset_id in enumerate(asset_group):
|
|
231
|
+
results.append(BulkAssetOptInOutResult(asset_id=asset_id, transaction_id=result.tx_ids[i]))
|
|
232
|
+
|
|
233
|
+
return results
|
|
234
|
+
|
|
235
|
+
def bulk_opt_out( # noqa: C901, PLR0913
|
|
236
|
+
self,
|
|
237
|
+
*,
|
|
238
|
+
account: str,
|
|
239
|
+
asset_ids: list[int],
|
|
240
|
+
ensure_zero_balance: bool = True,
|
|
241
|
+
signer: TransactionSigner | None = None,
|
|
242
|
+
rekey_to: str | None = None,
|
|
243
|
+
note: bytes | None = None,
|
|
244
|
+
lease: bytes | None = None,
|
|
245
|
+
static_fee: AlgoAmount | None = None,
|
|
246
|
+
extra_fee: AlgoAmount | None = None,
|
|
247
|
+
max_fee: AlgoAmount | None = None,
|
|
248
|
+
validity_window: int | None = None,
|
|
249
|
+
first_valid_round: int | None = None,
|
|
250
|
+
last_valid_round: int | None = None,
|
|
251
|
+
send_params: SendParams | None = None,
|
|
252
|
+
) -> list[BulkAssetOptInOutResult]:
|
|
253
|
+
"""Opt an account out of a list of Algorand Standard Assets.
|
|
254
|
+
|
|
255
|
+
:param account: The account to opt-out
|
|
256
|
+
:param asset_ids: The list of asset IDs to opt-out of
|
|
257
|
+
:param ensure_zero_balance: Whether to check if the account has a zero balance first, defaults to True
|
|
258
|
+
:param signer: The signer to use for the transaction, defaults to None
|
|
259
|
+
:param rekey_to: The address to rekey the account to, defaults to None
|
|
260
|
+
:param note: The note to include in the transaction, defaults to None
|
|
261
|
+
:param lease: The lease to include in the transaction, defaults to None
|
|
262
|
+
:param static_fee: The static fee to include in the transaction, defaults to None
|
|
263
|
+
:param extra_fee: The extra fee to include in the transaction, defaults to None
|
|
264
|
+
:param max_fee: The maximum fee to include in the transaction, defaults to None
|
|
265
|
+
:param validity_window: The validity window to include in the transaction, defaults to None
|
|
266
|
+
:param first_valid_round: The first valid round to include in the transaction, defaults to None
|
|
267
|
+
:param last_valid_round: The last valid round to include in the transaction, defaults to None
|
|
268
|
+
:param send_params: The send parameters to use for the transaction, defaults to None
|
|
269
|
+
:raises ValueError: If ensure_zero_balance is True and account has non-zero balance or is not opted in
|
|
270
|
+
:return: An array of records matching asset ID to transaction ID of the opt out
|
|
271
|
+
|
|
272
|
+
:example:
|
|
273
|
+
>>> asset_manager = AssetManager(algod_client)
|
|
274
|
+
>>> results = asset_manager.bulk_opt_out(account, asset_ids)
|
|
275
|
+
"""
|
|
276
|
+
results: list[BulkAssetOptInOutResult] = []
|
|
277
|
+
sender = self._get_address_from_sender(account)
|
|
278
|
+
|
|
279
|
+
for asset_group in _chunk_array(asset_ids, MAX_TRANSACTION_GROUP_SIZE):
|
|
280
|
+
composer = self._new_group()
|
|
281
|
+
|
|
282
|
+
not_opted_in_asset_ids: list[int] = []
|
|
283
|
+
non_zero_balance_asset_ids: list[int] = []
|
|
284
|
+
|
|
285
|
+
if ensure_zero_balance:
|
|
286
|
+
for asset_id in asset_group:
|
|
287
|
+
try:
|
|
288
|
+
account_asset_info = self.get_account_information(sender, asset_id)
|
|
289
|
+
if account_asset_info.balance != 0:
|
|
290
|
+
non_zero_balance_asset_ids.append(asset_id)
|
|
291
|
+
except Exception:
|
|
292
|
+
not_opted_in_asset_ids.append(asset_id)
|
|
293
|
+
|
|
294
|
+
if not_opted_in_asset_ids or non_zero_balance_asset_ids:
|
|
295
|
+
error_message = f"Account {sender}"
|
|
296
|
+
if not_opted_in_asset_ids:
|
|
297
|
+
error_message += f" is not opted-in to Asset(s) {', '.join(map(str, not_opted_in_asset_ids))}"
|
|
298
|
+
if non_zero_balance_asset_ids:
|
|
299
|
+
error_message += (
|
|
300
|
+
f" has non-zero balance for Asset(s) {', '.join(map(str, non_zero_balance_asset_ids))}"
|
|
301
|
+
)
|
|
302
|
+
error_message += "; can't opt-out."
|
|
303
|
+
raise ValueError(error_message)
|
|
304
|
+
|
|
305
|
+
for asset_id in asset_group:
|
|
306
|
+
asset_info = self.get_by_id(asset_id)
|
|
307
|
+
params = AssetOptOutParams(
|
|
308
|
+
sender=sender,
|
|
309
|
+
asset_id=asset_id,
|
|
310
|
+
creator=asset_info.creator,
|
|
311
|
+
signer=signer,
|
|
312
|
+
rekey_to=rekey_to,
|
|
313
|
+
note=note,
|
|
314
|
+
lease=lease,
|
|
315
|
+
static_fee=static_fee,
|
|
316
|
+
extra_fee=extra_fee,
|
|
317
|
+
max_fee=max_fee,
|
|
318
|
+
validity_window=validity_window,
|
|
319
|
+
first_valid_round=first_valid_round,
|
|
320
|
+
last_valid_round=last_valid_round,
|
|
321
|
+
)
|
|
322
|
+
composer.add_asset_opt_out(params)
|
|
323
|
+
|
|
324
|
+
result = composer.send(send_params)
|
|
325
|
+
|
|
326
|
+
for i, asset_id in enumerate(asset_group):
|
|
327
|
+
results.append(BulkAssetOptInOutResult(asset_id=asset_id, transaction_id=result.tx_ids[i]))
|
|
328
|
+
|
|
329
|
+
return results
|
|
330
|
+
|
|
331
|
+
@staticmethod
|
|
332
|
+
def _get_address_from_sender(
|
|
333
|
+
sender: str | AddressWithTransactionSigner | AddressWithSigners,
|
|
334
|
+
) -> str:
|
|
335
|
+
if isinstance(sender, str):
|
|
336
|
+
return sender
|
|
337
|
+
# Both AddressWithSigners and AddressWithTransactionSigner now use 'addr'
|
|
338
|
+
if isinstance(sender, AddressWithSigners | AddressWithTransactionSigner):
|
|
339
|
+
return sender.addr
|
|
340
|
+
raise ValueError(f"Unsupported sender type: {type(sender)}")
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
def _chunk_array(array: list, size: int) -> list[list]:
|
|
344
|
+
return [array[i : i + size] for i in range(0, len(array), size)]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from algokit_algod_client import AlgodClient
|
|
2
|
+
from algokit_algod_client import models as algod_models
|
|
3
|
+
from algokit_algod_client.exceptions import UnexpectedStatusError
|
|
4
|
+
from algokit_indexer_client import IndexerClient
|
|
5
|
+
from algokit_kmd_client import KmdClient
|
|
6
|
+
from algokit_utils.clients.client_manager import (
|
|
7
|
+
AlgoSdkClients,
|
|
8
|
+
ClientManager,
|
|
9
|
+
NetworkDetail,
|
|
10
|
+
)
|
|
11
|
+
from algokit_utils.clients.dispenser_api_client import (
|
|
12
|
+
DISPENSER_ACCESS_TOKEN_KEY,
|
|
13
|
+
DISPENSER_ASSETS,
|
|
14
|
+
DISPENSER_REQUEST_TIMEOUT,
|
|
15
|
+
DispenserApiConfig,
|
|
16
|
+
DispenserAsset,
|
|
17
|
+
DispenserAssetName,
|
|
18
|
+
DispenserFundResponse,
|
|
19
|
+
DispenserLimitResponse,
|
|
20
|
+
TestNetDispenserApiClient,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
__all__ = [
|
|
24
|
+
"DISPENSER_ACCESS_TOKEN_KEY",
|
|
25
|
+
"DISPENSER_ASSETS",
|
|
26
|
+
"DISPENSER_REQUEST_TIMEOUT",
|
|
27
|
+
"AlgoSdkClients",
|
|
28
|
+
"AlgodClient",
|
|
29
|
+
"ClientManager",
|
|
30
|
+
"DispenserApiConfig",
|
|
31
|
+
"DispenserAsset",
|
|
32
|
+
"DispenserAssetName",
|
|
33
|
+
"DispenserFundResponse",
|
|
34
|
+
"DispenserLimitResponse",
|
|
35
|
+
"IndexerClient",
|
|
36
|
+
"KmdClient",
|
|
37
|
+
"NetworkDetail",
|
|
38
|
+
"TestNetDispenserApiClient",
|
|
39
|
+
"UnexpectedStatusError",
|
|
40
|
+
"algod_models",
|
|
41
|
+
]
|