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,13 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
|
|
3
|
+
from algokit_common.constants import ZERO_ADDRESS
|
|
4
|
+
from algokit_transact.codec.serde import addr, wire
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass(slots=True, frozen=True)
|
|
8
|
+
class AssetTransferTransactionFields:
|
|
9
|
+
asset_id: int = field(default=0, metadata=wire("xaid"))
|
|
10
|
+
receiver: str = field(default=ZERO_ADDRESS, metadata=addr("arcv"))
|
|
11
|
+
amount: int = field(default=0, metadata=wire("aamt"))
|
|
12
|
+
close_remainder_to: str | None = field(default=None, metadata=addr("aclose", omit_if_none=True))
|
|
13
|
+
asset_sender: str | None = field(default=None, metadata=addr("asnd", omit_if_none=True))
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from enum import Enum
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class OnApplicationComplete(Enum):
|
|
6
|
+
NoOp = 0
|
|
7
|
+
OptIn = 1
|
|
8
|
+
CloseOut = 2
|
|
9
|
+
ClearState = 3
|
|
10
|
+
UpdateApplication = 4
|
|
11
|
+
DeleteApplication = 5
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass(slots=True, frozen=True)
|
|
15
|
+
class StateSchema:
|
|
16
|
+
num_uints: int = field(default=0, metadata={"kind": "wire", "alias": "nui"})
|
|
17
|
+
num_byte_slices: int = field(default=0, metadata={"kind": "wire", "alias": "nbs"})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
|
|
3
|
+
from algokit_transact.codec.serde import addr, nested, wire
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass(slots=True, frozen=True)
|
|
7
|
+
class HeartbeatProof:
|
|
8
|
+
signature: bytes | None = field(default=None, metadata=wire("s"))
|
|
9
|
+
public_key: bytes | None = field(default=None, metadata=wire("p"))
|
|
10
|
+
public_key_2: bytes | None = field(default=None, metadata=wire("p2"))
|
|
11
|
+
public_key_1_signature: bytes | None = field(default=None, metadata=wire("p1s"))
|
|
12
|
+
public_key_2_signature: bytes | None = field(default=None, metadata=wire("p2s"))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass(slots=True, frozen=True)
|
|
16
|
+
class HeartbeatTransactionFields:
|
|
17
|
+
address: str | None = field(default=None, metadata=addr("a", omit_if_none=True))
|
|
18
|
+
proof: HeartbeatProof | None = field(default=None, metadata=nested("prf", HeartbeatProof))
|
|
19
|
+
seed: bytes | None = field(default=None, metadata=wire("sd"))
|
|
20
|
+
vote_id: bytes | None = field(default=None, metadata=wire("vid"))
|
|
21
|
+
key_dilution: int | None = field(default=None, metadata=wire("kd", keep_zero=True))
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
|
|
3
|
+
from algokit_transact.codec.serde import wire
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass(slots=True, frozen=True)
|
|
7
|
+
class KeyRegistrationTransactionFields:
|
|
8
|
+
vote_key: bytes | None = field(default=None, metadata=wire("votekey"))
|
|
9
|
+
selection_key: bytes | None = field(default=None, metadata=wire("selkey"))
|
|
10
|
+
vote_first: int | None = field(default=None, metadata=wire("votefst"))
|
|
11
|
+
vote_last: int | None = field(default=None, metadata=wire("votelst"))
|
|
12
|
+
vote_key_dilution: int | None = field(default=None, metadata=wire("votekd"))
|
|
13
|
+
state_proof_key: bytes | None = field(default=None, metadata=wire("sprfkey"))
|
|
14
|
+
non_participation: bool | None = field(default=None, metadata=wire("nonpart"))
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
|
|
3
|
+
from algokit_common.constants import ZERO_ADDRESS
|
|
4
|
+
from algokit_transact.codec.serde import addr, wire
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass(slots=True, frozen=True)
|
|
8
|
+
class PaymentTransactionFields:
|
|
9
|
+
amount: int = field(default=0, metadata=wire("amt"))
|
|
10
|
+
receiver: str = field(default=ZERO_ADDRESS, metadata=addr("rcv"))
|
|
11
|
+
close_remainder_to: str | None = field(
|
|
12
|
+
default=None,
|
|
13
|
+
metadata=addr("close", omit_if_none=True),
|
|
14
|
+
)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
|
|
3
|
+
from algokit_transact.codec.serde import addr, nested, wire
|
|
4
|
+
from algokit_transact.models.transaction import Transaction
|
|
5
|
+
from algokit_transact.signing.logic_signature import LogicSignature
|
|
6
|
+
from algokit_transact.signing.types import MultisigSignature
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass(slots=True, frozen=True)
|
|
10
|
+
class SignedTransaction:
|
|
11
|
+
txn: Transaction = field(metadata=nested("txn", Transaction))
|
|
12
|
+
sig: bytes | None = field(default=None, metadata=wire("sig"))
|
|
13
|
+
msig: MultisigSignature | None = field(
|
|
14
|
+
default=None,
|
|
15
|
+
metadata=nested("msig", MultisigSignature),
|
|
16
|
+
)
|
|
17
|
+
lsig: LogicSignature | None = field(
|
|
18
|
+
default=None,
|
|
19
|
+
metadata=nested("lsig", LogicSignature),
|
|
20
|
+
)
|
|
21
|
+
auth_address: str | None = field(default=None, metadata=addr("sgnr"))
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
from collections.abc import Iterable, Mapping
|
|
2
|
+
from dataclasses import dataclass, field
|
|
3
|
+
from typing import cast
|
|
4
|
+
|
|
5
|
+
from algokit_transact.codec.serde import bytes_seq, from_wire, int_seq, nested, to_wire, wire
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass(slots=True, frozen=True)
|
|
9
|
+
class HashFactory:
|
|
10
|
+
hash_type: int | None = field(default=None, metadata=wire("t"))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass(slots=True, frozen=True)
|
|
14
|
+
class MerkleArrayProof:
|
|
15
|
+
path: list[bytes] | None = field(default=None, metadata=bytes_seq("pth"))
|
|
16
|
+
hash_factory: HashFactory | None = field(default=None, metadata=nested("hsh", HashFactory))
|
|
17
|
+
tree_depth: int | None = field(default=None, metadata=wire("td"))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass(slots=True, frozen=True)
|
|
21
|
+
class MerkleSignatureVerifier:
|
|
22
|
+
commitment: bytes | None = field(default=None, metadata=wire("cmt"))
|
|
23
|
+
key_lifetime: int | None = field(default=None, metadata=wire("lf"))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass(slots=True, frozen=True)
|
|
27
|
+
class Participant:
|
|
28
|
+
verifier: MerkleSignatureVerifier | None = field(default=None, metadata=nested("p", MerkleSignatureVerifier))
|
|
29
|
+
weight: int | None = field(default=None, metadata=wire("w"))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@dataclass(slots=True, frozen=True)
|
|
33
|
+
class FalconVerifier:
|
|
34
|
+
public_key: bytes | None = field(default=None, metadata=wire("k"))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@dataclass(slots=True, frozen=True)
|
|
38
|
+
class FalconSignatureStruct:
|
|
39
|
+
signature: bytes | None = field(default=None, metadata=wire("sig"))
|
|
40
|
+
vector_commitment_index: int | None = field(default=None, metadata=wire("idx"))
|
|
41
|
+
proof: MerkleArrayProof | None = field(default=None, metadata=nested("prf", MerkleArrayProof))
|
|
42
|
+
verifying_key: FalconVerifier | None = field(default=None, metadata=nested("vkey", FalconVerifier))
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@dataclass(slots=True, frozen=True)
|
|
46
|
+
class SigslotCommit:
|
|
47
|
+
sig: FalconSignatureStruct | None = field(default=None, metadata=nested("s", FalconSignatureStruct))
|
|
48
|
+
lower_sig_weight: int | None = field(default=None, metadata=wire("l"))
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@dataclass(slots=True, frozen=True)
|
|
52
|
+
class Reveal:
|
|
53
|
+
participant: Participant | None = field(default=None, metadata=nested("p", Participant))
|
|
54
|
+
sigslot: SigslotCommit | None = field(default=None, metadata=nested("s", SigslotCommit))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@dataclass(slots=True, frozen=True)
|
|
58
|
+
class StateProof:
|
|
59
|
+
sig_commit: bytes | None = field(default=None, metadata=wire("c"))
|
|
60
|
+
signed_weight: int | None = field(default=None, metadata=wire("w", keep_zero=True))
|
|
61
|
+
sig_proofs: MerkleArrayProof | None = field(default=None, metadata=nested("S", MerkleArrayProof))
|
|
62
|
+
part_proofs: MerkleArrayProof | None = field(default=None, metadata=nested("P", MerkleArrayProof))
|
|
63
|
+
merkle_signature_salt_version: int | None = field(default=None, metadata=wire("v"))
|
|
64
|
+
reveals: dict[int, Reveal] | None = field(
|
|
65
|
+
default=None,
|
|
66
|
+
metadata=wire(
|
|
67
|
+
"r",
|
|
68
|
+
encode=lambda obj: _encode_reveals(cast(dict[int, Reveal] | None, obj)),
|
|
69
|
+
decode=lambda obj: _decode_reveals(obj),
|
|
70
|
+
),
|
|
71
|
+
)
|
|
72
|
+
positions_to_reveal: list[int] | None = field(default=None, metadata=int_seq("pr"))
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@dataclass(slots=True, frozen=True)
|
|
76
|
+
class StateProofMessage:
|
|
77
|
+
block_headers_commitment: bytes | None = field(default=None, metadata=wire("b"))
|
|
78
|
+
voters_commitment: bytes | None = field(default=None, metadata=wire("v"))
|
|
79
|
+
ln_proven_weight: int | None = field(default=None, metadata=wire("P"))
|
|
80
|
+
first_attested_round: int | None = field(default=None, metadata=wire("f"))
|
|
81
|
+
last_attested_round: int | None = field(default=None, metadata=wire("l"))
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
@dataclass(slots=True, frozen=True)
|
|
85
|
+
class StateProofTransactionFields:
|
|
86
|
+
state_proof_type: int | None = field(default=None, metadata=wire("sptype"))
|
|
87
|
+
# Flatten state proof and message at the transaction level (aliases under root: sp and spmsg)
|
|
88
|
+
state_proof: StateProof | None = field(default=None, metadata=nested("sp", StateProof))
|
|
89
|
+
message: StateProofMessage | None = field(default=None, metadata=nested("spmsg", StateProofMessage))
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def _encode_reveals(mapping: Mapping[int, Reveal] | Iterable[Reveal] | None) -> dict[int, dict[str, object]] | None:
|
|
93
|
+
if mapping is None:
|
|
94
|
+
return None
|
|
95
|
+
entries: Iterable[tuple[int, Reveal]]
|
|
96
|
+
if isinstance(mapping, Mapping):
|
|
97
|
+
entries = (
|
|
98
|
+
(key if isinstance(key, int) else _coerce_reveal_position(key, idx), reveal)
|
|
99
|
+
for idx, (key, reveal) in enumerate(mapping.items())
|
|
100
|
+
)
|
|
101
|
+
else:
|
|
102
|
+
entries = ((_coerce_reveal_position(None, idx), reveal) for idx, reveal in enumerate(mapping))
|
|
103
|
+
encoded: dict[int, dict[str, object]] = {}
|
|
104
|
+
for position, reveal in entries:
|
|
105
|
+
data = to_wire(reveal)
|
|
106
|
+
payload = {key: value for key in ("p", "s") if (value := data.get(key)) is not None}
|
|
107
|
+
if payload:
|
|
108
|
+
encoded[int(position)] = payload
|
|
109
|
+
return encoded or None
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _decode_reveals(obj: object | None) -> dict[int, Reveal] | None:
|
|
113
|
+
if obj is None:
|
|
114
|
+
return None
|
|
115
|
+
|
|
116
|
+
if isinstance(obj, Mapping):
|
|
117
|
+
decoded: dict[int, Reveal] = {}
|
|
118
|
+
for key, value in obj.items():
|
|
119
|
+
if not isinstance(value, Mapping):
|
|
120
|
+
continue
|
|
121
|
+
position = _coerce_reveal_position(key, len(decoded))
|
|
122
|
+
payload = {k: v for k, v in value.items() if k in {"p", "s"}}
|
|
123
|
+
if payload:
|
|
124
|
+
decoded[position] = from_wire(Reveal, payload)
|
|
125
|
+
return decoded or None
|
|
126
|
+
|
|
127
|
+
if isinstance(obj, list):
|
|
128
|
+
decoded_list: dict[int, Reveal] = {}
|
|
129
|
+
for idx, value in enumerate(obj):
|
|
130
|
+
if not isinstance(value, Mapping):
|
|
131
|
+
continue
|
|
132
|
+
position = _coerce_reveal_position(value.get("pos"), idx)
|
|
133
|
+
payload = {k: v for k, v in value.items() if k in {"p", "s"}}
|
|
134
|
+
if payload:
|
|
135
|
+
decoded_list[position] = from_wire(Reveal, payload)
|
|
136
|
+
return decoded_list or None
|
|
137
|
+
|
|
138
|
+
return None
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def _coerce_reveal_position(raw: object, fallback: int) -> int:
|
|
142
|
+
if isinstance(raw, int):
|
|
143
|
+
return raw
|
|
144
|
+
if isinstance(raw, str):
|
|
145
|
+
try:
|
|
146
|
+
return int(raw)
|
|
147
|
+
except ValueError:
|
|
148
|
+
return fallback
|
|
149
|
+
# Fallback silently to preserve legacy behavior when nodes omit this field.
|
|
150
|
+
return fallback
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
from collections.abc import Mapping
|
|
2
|
+
from dataclasses import dataclass, field
|
|
3
|
+
from enum import Enum
|
|
4
|
+
|
|
5
|
+
from algokit_common.constants import ZERO_ADDRESS
|
|
6
|
+
from algokit_transact.codec.serde import addr, enum_value, flatten, nested, wire
|
|
7
|
+
from algokit_transact.models.app_call import AppCallTransactionFields
|
|
8
|
+
from algokit_transact.models.asset_config import AssetConfigTransactionFields
|
|
9
|
+
from algokit_transact.models.asset_freeze import AssetFreezeTransactionFields
|
|
10
|
+
from algokit_transact.models.asset_transfer import AssetTransferTransactionFields
|
|
11
|
+
from algokit_transact.models.heartbeat import HeartbeatTransactionFields
|
|
12
|
+
from algokit_transact.models.key_registration import KeyRegistrationTransactionFields
|
|
13
|
+
from algokit_transact.models.payment import PaymentTransactionFields
|
|
14
|
+
from algokit_transact.models.state_proof import StateProofTransactionFields
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class TransactionType(Enum):
|
|
18
|
+
Payment = "pay"
|
|
19
|
+
AssetTransfer = "axfer"
|
|
20
|
+
AssetFreeze = "afrz"
|
|
21
|
+
AssetConfig = "acfg"
|
|
22
|
+
KeyRegistration = "keyreg"
|
|
23
|
+
AppCall = "appl"
|
|
24
|
+
StateProof = "stpf"
|
|
25
|
+
Heartbeat = "hb"
|
|
26
|
+
# Unknown transaction type - used when decoding transactions with unrecognized type values.
|
|
27
|
+
# This should not be used when creating new transactions.
|
|
28
|
+
Unknown = "unknown"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _get_tx_type(payload: Mapping[str, object]) -> str | None:
|
|
32
|
+
"""Helper to extract transaction type from payload, normalizing bytes to str."""
|
|
33
|
+
type_val = payload.get("type")
|
|
34
|
+
if type_val is None:
|
|
35
|
+
return None
|
|
36
|
+
if isinstance(type_val, bytes | bytearray | memoryview):
|
|
37
|
+
return bytes(type_val).decode("utf-8")
|
|
38
|
+
return str(type_val)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@dataclass(slots=True, frozen=True)
|
|
42
|
+
class Transaction:
|
|
43
|
+
transaction_type: TransactionType = field(
|
|
44
|
+
metadata=enum_value("type", TransactionType, fallback=TransactionType.Unknown)
|
|
45
|
+
)
|
|
46
|
+
sender: str = field(default=ZERO_ADDRESS, metadata=addr("snd"))
|
|
47
|
+
first_valid: int = field(default=0, metadata=wire("fv"))
|
|
48
|
+
last_valid: int = field(default=0, metadata=wire("lv"))
|
|
49
|
+
|
|
50
|
+
fee: int | None = field(default=None, metadata=wire("fee"))
|
|
51
|
+
genesis_hash: bytes | None = field(default=None, metadata=wire("gh"))
|
|
52
|
+
genesis_id: str | None = field(default=None, metadata=wire("gen"))
|
|
53
|
+
note: bytes | None = field(default=None, metadata=wire("note"))
|
|
54
|
+
rekey_to: str | None = field(default=None, metadata=addr("rekey"))
|
|
55
|
+
lease: bytes | None = field(default=None, metadata=wire("lx"))
|
|
56
|
+
group: bytes | None = field(default=None, metadata=wire("grp"))
|
|
57
|
+
|
|
58
|
+
payment: PaymentTransactionFields | None = field(
|
|
59
|
+
default=None, metadata=flatten(PaymentTransactionFields, present_if=lambda p: _get_tx_type(p) == "pay")
|
|
60
|
+
)
|
|
61
|
+
asset_transfer: AssetTransferTransactionFields | None = field(
|
|
62
|
+
default=None, metadata=flatten(AssetTransferTransactionFields, present_if=lambda p: _get_tx_type(p) == "axfer")
|
|
63
|
+
)
|
|
64
|
+
asset_config: AssetConfigTransactionFields | None = field(
|
|
65
|
+
default=None, metadata=flatten(AssetConfigTransactionFields, present_if=lambda p: _get_tx_type(p) == "acfg")
|
|
66
|
+
)
|
|
67
|
+
application_call: AppCallTransactionFields | None = field(
|
|
68
|
+
default=None, metadata=flatten(AppCallTransactionFields, present_if=lambda p: _get_tx_type(p) == "appl")
|
|
69
|
+
)
|
|
70
|
+
key_registration: KeyRegistrationTransactionFields | None = field(
|
|
71
|
+
default=None,
|
|
72
|
+
metadata=flatten(KeyRegistrationTransactionFields, present_if=lambda p: _get_tx_type(p) == "keyreg"),
|
|
73
|
+
)
|
|
74
|
+
asset_freeze: AssetFreezeTransactionFields | None = field(
|
|
75
|
+
default=None, metadata=flatten(AssetFreezeTransactionFields, present_if=lambda p: _get_tx_type(p) == "afrz")
|
|
76
|
+
)
|
|
77
|
+
heartbeat: HeartbeatTransactionFields | None = field(
|
|
78
|
+
default=None, metadata=nested("hb", HeartbeatTransactionFields)
|
|
79
|
+
)
|
|
80
|
+
state_proof: StateProofTransactionFields | None = field(
|
|
81
|
+
default=None, metadata=flatten(StateProofTransactionFields, present_if=lambda p: _get_tx_type(p) == "stpf")
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
def tx_id(self) -> str:
|
|
85
|
+
"""Return the transaction ID."""
|
|
86
|
+
from algokit_transact.ops.ids import get_transaction_id
|
|
87
|
+
|
|
88
|
+
return get_transaction_id(self)
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import dataclasses
|
|
4
|
+
from collections.abc import Callable, Sequence
|
|
5
|
+
from functools import cached_property
|
|
6
|
+
|
|
7
|
+
from algokit_common import address_from_public_key
|
|
8
|
+
from algokit_transact.codec.signed import encode_signed_transaction
|
|
9
|
+
from algokit_transact.codec.transaction import encode_transaction
|
|
10
|
+
from algokit_transact.models.signed_transaction import SignedTransaction
|
|
11
|
+
from algokit_transact.models.transaction import Transaction as AlgokitTransaction
|
|
12
|
+
from algokit_transact.signer import AddressWithSigners, TransactionSigner
|
|
13
|
+
from algokit_transact.signing.multisig import (
|
|
14
|
+
address_from_multisig_signature,
|
|
15
|
+
apply_multisig_subsignature,
|
|
16
|
+
new_multisig_signature,
|
|
17
|
+
)
|
|
18
|
+
from algokit_transact.signing.types import MultisigSignature
|
|
19
|
+
|
|
20
|
+
__all__ = [
|
|
21
|
+
"MultisigAccount",
|
|
22
|
+
"MultisigMetadata",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclasses.dataclass(kw_only=True)
|
|
27
|
+
class MultisigMetadata:
|
|
28
|
+
"""Metadata for a multisig account."""
|
|
29
|
+
|
|
30
|
+
version: int
|
|
31
|
+
threshold: int
|
|
32
|
+
addrs: list[str]
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@dataclasses.dataclass(frozen=True)
|
|
36
|
+
class MultisigAccount:
|
|
37
|
+
"""Account wrapper for multisig signing. Supports secretless signing."""
|
|
38
|
+
|
|
39
|
+
params: MultisigMetadata
|
|
40
|
+
"""The multisig account parameters."""
|
|
41
|
+
sub_signers: Sequence[AddressWithSigners]
|
|
42
|
+
"""The list of signing accounts."""
|
|
43
|
+
|
|
44
|
+
@cached_property
|
|
45
|
+
def _multisig_signature(self) -> MultisigSignature:
|
|
46
|
+
return new_multisig_signature(
|
|
47
|
+
self.params.version,
|
|
48
|
+
self.params.threshold,
|
|
49
|
+
self.params.addrs,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
@cached_property
|
|
53
|
+
def signer(self) -> TransactionSigner:
|
|
54
|
+
address_to_signer: dict[str, Callable[[bytes], bytes]] = {
|
|
55
|
+
account.addr: account.bytes_signer for account in self.sub_signers
|
|
56
|
+
}
|
|
57
|
+
msig_address = self.address
|
|
58
|
+
base_multisig = self._multisig_signature
|
|
59
|
+
|
|
60
|
+
def signer(txn_group: Sequence[AlgokitTransaction], indexes_to_sign: Sequence[int]) -> list[bytes]:
|
|
61
|
+
blobs: list[bytes] = []
|
|
62
|
+
for index in indexes_to_sign:
|
|
63
|
+
txn = txn_group[index]
|
|
64
|
+
payload = encode_transaction(txn)
|
|
65
|
+
|
|
66
|
+
multisig_sig = base_multisig
|
|
67
|
+
for subsig in base_multisig.subsigs:
|
|
68
|
+
subsig_addr = address_from_public_key(subsig.public_key)
|
|
69
|
+
if subsig_addr in address_to_signer:
|
|
70
|
+
signature = address_to_signer[subsig_addr](payload)
|
|
71
|
+
multisig_sig = apply_multisig_subsignature(multisig_sig, subsig_addr, signature)
|
|
72
|
+
|
|
73
|
+
signed = SignedTransaction(
|
|
74
|
+
txn=txn,
|
|
75
|
+
sig=None,
|
|
76
|
+
msig=multisig_sig,
|
|
77
|
+
lsig=None,
|
|
78
|
+
auth_address=msig_address if txn.sender != msig_address else None,
|
|
79
|
+
)
|
|
80
|
+
blobs.append(encode_signed_transaction(signed))
|
|
81
|
+
return blobs
|
|
82
|
+
|
|
83
|
+
return signer
|
|
84
|
+
|
|
85
|
+
@cached_property
|
|
86
|
+
def address(self) -> str:
|
|
87
|
+
"""The multisig account address."""
|
|
88
|
+
return address_from_multisig_signature(self._multisig_signature)
|
|
89
|
+
|
|
90
|
+
@property
|
|
91
|
+
def addr(self) -> str:
|
|
92
|
+
"""Alias for address property (matching TypeScript's get addr())."""
|
|
93
|
+
return self.address
|
|
File without changes
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from dataclasses import replace
|
|
2
|
+
|
|
3
|
+
from algokit_common.constants import SIGNATURE_ENCODING_INCR
|
|
4
|
+
from algokit_transact.codec.transaction import encode_transaction_raw
|
|
5
|
+
from algokit_transact.models.transaction import Transaction
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def estimate_transaction_size(tx: Transaction) -> int:
|
|
9
|
+
raw = encode_transaction_raw(tx)
|
|
10
|
+
return len(raw) + SIGNATURE_ENCODING_INCR
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def calculate_fee(
|
|
14
|
+
tx: Transaction,
|
|
15
|
+
*,
|
|
16
|
+
fee_per_byte: int,
|
|
17
|
+
min_fee: int,
|
|
18
|
+
extra_fee: int | None = None,
|
|
19
|
+
max_fee: int | None = None,
|
|
20
|
+
) -> int:
|
|
21
|
+
fee = 0
|
|
22
|
+
if fee_per_byte > 0:
|
|
23
|
+
fee = fee_per_byte * estimate_transaction_size(tx)
|
|
24
|
+
fee = max(fee, min_fee)
|
|
25
|
+
if extra_fee is not None:
|
|
26
|
+
fee += extra_fee
|
|
27
|
+
if max_fee is not None and fee > max_fee:
|
|
28
|
+
raise ValueError(f"Transaction fee {fee} µALGO is greater than max fee {max_fee} µALGO")
|
|
29
|
+
return fee
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def assign_fee(
|
|
33
|
+
tx: Transaction,
|
|
34
|
+
*,
|
|
35
|
+
fee_per_byte: int,
|
|
36
|
+
min_fee: int,
|
|
37
|
+
extra_fee: int | None = None,
|
|
38
|
+
max_fee: int | None = None,
|
|
39
|
+
) -> Transaction:
|
|
40
|
+
fee = calculate_fee(
|
|
41
|
+
tx,
|
|
42
|
+
fee_per_byte=fee_per_byte,
|
|
43
|
+
min_fee=min_fee,
|
|
44
|
+
extra_fee=extra_fee,
|
|
45
|
+
max_fee=max_fee,
|
|
46
|
+
)
|
|
47
|
+
return replace(tx, fee=fee)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from collections.abc import Iterable
|
|
2
|
+
from dataclasses import replace
|
|
3
|
+
|
|
4
|
+
from algokit_common import sha512_256
|
|
5
|
+
from algokit_common.constants import MAX_TRANSACTION_GROUP_SIZE, TRANSACTION_GROUP_DOMAIN_SEPARATOR
|
|
6
|
+
from algokit_transact.codec.msgpack import encode_msgpack
|
|
7
|
+
from algokit_transact.models.transaction import Transaction
|
|
8
|
+
from algokit_transact.ops.ids import get_transaction_id_raw
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def group_transactions(transactions: Iterable[Transaction]) -> list[Transaction]:
|
|
12
|
+
txs = list(transactions)
|
|
13
|
+
|
|
14
|
+
if not txs:
|
|
15
|
+
raise ValueError("Transaction group cannot be empty")
|
|
16
|
+
if len(txs) > MAX_TRANSACTION_GROUP_SIZE:
|
|
17
|
+
raise ValueError(f"Transaction group size exceeds the max limit of {MAX_TRANSACTION_GROUP_SIZE}")
|
|
18
|
+
|
|
19
|
+
tx_hashes = []
|
|
20
|
+
for tx in txs:
|
|
21
|
+
if tx.group is not None:
|
|
22
|
+
raise ValueError("Transactions must not already be grouped")
|
|
23
|
+
tx_hashes.append(get_transaction_id_raw(tx))
|
|
24
|
+
|
|
25
|
+
encoded = encode_msgpack({"txlist": tx_hashes})
|
|
26
|
+
group = sha512_256(TRANSACTION_GROUP_DOMAIN_SEPARATOR.encode() + encoded)
|
|
27
|
+
|
|
28
|
+
return [replace(tx, group=group) for tx in txs]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from algokit_common import base32_nopad_encode, sha512_256
|
|
2
|
+
from algokit_common.constants import TRANSACTION_ID_LENGTH
|
|
3
|
+
from algokit_transact.codec.transaction import encode_transaction
|
|
4
|
+
from algokit_transact.models.transaction import Transaction
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def get_transaction_id_raw(transaction: Transaction) -> bytes:
|
|
8
|
+
encoded = encode_transaction(transaction)
|
|
9
|
+
return sha512_256(encoded)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def get_transaction_id(transaction: Transaction) -> str:
|
|
13
|
+
raw = get_transaction_id_raw(transaction)
|
|
14
|
+
return base32_nopad_encode(raw)[:TRANSACTION_ID_LENGTH]
|