1111from algokit_algod_client .exceptions import UnexpectedStatusError
1212from algokit_algod_client .models import SimulateTransactionResult
1313from algokit_common .constants import MAX_TRANSACTION_GROUP_SIZE
14- from algokit_transact import decode_signed_transaction , encode_signed_transactions , make_empty_transaction_signer
15- from algokit_transact .models . signed_transaction import SignedTransaction
14+ from algokit_transact import make_empty_transaction_signer
15+ from algokit_transact .codec . signed import decode_signed_transactions
1616from algokit_transact .models .transaction import Transaction , TransactionType
1717from algokit_transact .ops .fees import calculate_fee
1818from algokit_transact .ops .group import group_transactions
1919from algokit_transact .ops .ids import get_transaction_id
20- from algokit_transact .ops .validate import validate_signed_transaction , validate_transaction
20+ from algokit_transact .ops .validate import validate_transaction
2121from algokit_transact .signer import AddressWithTransactionSigner , TransactionSigner
2222from algokit_utils .applications .abi import ABIReturn
2323from algokit_utils .applications .app_manager import AppManager
@@ -262,7 +262,7 @@ def __init__(self, params: TransactionComposerParams) -> None:
262262
263263 self ._queued : list [_QueuedTransaction ] = []
264264 self ._transactions_with_signers : list [TransactionWithSigner ] | None = None
265- self ._signed_transactions : list [SignedTransaction ] | None = None
265+ self ._signed_transactions : list [bytes ] | None = None
266266 self ._raw_built_transactions : list [Transaction ] | None = None
267267
268268 def clone (self , composer_config : TransactionComposerConfig | None = None ) -> "TransactionComposer" :
@@ -459,7 +459,7 @@ def build_transactions(self) -> BuiltTransactions:
459459 signers = {index : entry .signer for index , entry in enumerate (built_entries ) if entry .signer is not None }
460460 return BuiltTransactions (transactions = transactions , method_calls = method_calls , signers = signers )
461461
462- def gather_signatures (self ) -> list [SignedTransaction ]:
462+ def gather_signatures (self ) -> list [bytes ]:
463463 self ._ensure_built ()
464464 if self ._signed_transactions is None :
465465 self ._signed_transactions = self ._sign_transactions (self ._transactions_with_signers or [])
@@ -503,8 +503,7 @@ def send(self, params: SendParams | None = None) -> SendTransactionComposerResul
503503
504504 # Send transactions and handle network errors
505505 try :
506- blobs = encode_signed_transactions (signed_transactions )
507- self ._algod .send_raw_transaction (blobs )
506+ self ._algod .send_raw_transaction (signed_transactions )
508507
509508 tx_ids = [get_transaction_id (entry .txn ) for entry in self ._transactions_with_signers or []]
510509 group_id = self ._group_id ()
@@ -627,7 +626,8 @@ def simulate(
627626 )
628627 for entry in txns_with_signers
629628 ]
630- signed_transactions = self ._sign_transactions (signing_entries )
629+ encoded_signed_transactions = self ._sign_transactions (signing_entries )
630+ signed_transactions = decode_signed_transactions (encoded_signed_transactions )
631631
632632 request = algod_models .SimulateRequest (
633633 txn_groups = [algod_models .SimulateRequestTransactionGroup (txns = signed_transactions )],
@@ -813,9 +813,10 @@ def _analyze_group_requirements( # noqa: C901, PLR0912
813813 transactions_to_simulate = group_transactions (transactions_to_simulate )
814814
815815 empty_signer : TransactionSigner = make_empty_transaction_signer ()
816- signed_transactions = self ._sign_transactions (
816+ encoded_signed_transactions = self ._sign_transactions (
817817 [TransactionWithSigner (txn = txn , signer = empty_signer ) for txn in transactions_to_simulate ]
818818 )
819+ signed_transactions = decode_signed_transactions (encoded_signed_transactions )
819820
820821 simulate_request = algod_models .SimulateRequest (
821822 txn_groups = [algod_models .SimulateRequestTransactionGroup (txns = signed_transactions )],
@@ -1348,7 +1349,7 @@ def _resolve_param_signer(
13481349 return resolved
13491350 return signer
13501351
1351- def _sign_transactions (self , txns_with_signers : Sequence [TransactionWithSigner ]) -> list [SignedTransaction ]: # noqa: C901
1352+ def _sign_transactions (self , txns_with_signers : Sequence [TransactionWithSigner ]) -> list [bytes ]:
13521353 if not txns_with_signers :
13531354 raise ValueError ("No transactions available to sign" )
13541355
@@ -1365,33 +1366,19 @@ def _sign_transactions(self, txns_with_signers: Sequence[TransactionWithSigner])
13651366 blobs = signer (transactions , indexes )
13661367 signed_blobs [key ] = list (blobs )
13671368
1368- raw_signed_transactions : list [bytes | None ] = [None ] * len (transactions )
1369+ encoded_signed_transactions : list [bytes | None ] = [None ] * len (transactions )
13691370
13701371 for key , (_ , indexes ) in signer_groups .items ():
13711372 blobs = signed_blobs [key ]
13721373 for blob_index , txn_index in enumerate (indexes ):
13731374 if blob_index < len (blobs ):
1374- raw_signed_transactions [txn_index ] = blobs [blob_index ]
1375+ encoded_signed_transactions [txn_index ] = blobs [blob_index ]
13751376
1376- unsigned_indexes = [i for i , item in enumerate (raw_signed_transactions ) if item is None ]
1377+ unsigned_indexes = [i for i , item in enumerate (encoded_signed_transactions ) if item is None ]
13771378 if unsigned_indexes :
13781379 raise ValueError (f"Transactions at indexes [{ ', ' .join (map (str , unsigned_indexes ))} ] were not signed" )
13791380
1380- # Decode and validate all signed transactions
1381- signed_transactions : list [SignedTransaction ] = []
1382- for index , stxn in enumerate (raw_signed_transactions ):
1383- if stxn is None :
1384- # This shouldn't happen due to the check above, but ensures type safety
1385- raise ValueError (f"Transaction at index { index } was not signed" )
1386-
1387- try :
1388- signed_transaction = decode_signed_transaction (stxn )
1389- validate_signed_transaction (signed_transaction )
1390- signed_transactions .append (signed_transaction )
1391- except Exception as err :
1392- raise ValueError (f"Invalid signed transaction at index { index } . { err } " ) from err
1393-
1394- return signed_transactions
1381+ return cast (list [bytes ], encoded_signed_transactions ) # The guard above ensures no None values
13951382
13961383 def _group_id (self ) -> str | None :
13971384 txns = self ._transactions_with_signers or []
@@ -1468,9 +1455,10 @@ def _simulate_error_context(
14681455 """
14691456 try :
14701457 empty_signer : TransactionSigner = make_empty_transaction_signer ()
1471- signed_transactions = self ._sign_transactions (
1458+ encoded_signed_transactions = self ._sign_transactions (
14721459 [TransactionWithSigner (txn = txn , signer = empty_signer ) for txn in sent_transactions ]
14731460 )
1461+ signed_transactions = decode_signed_transactions (encoded_signed_transactions )
14741462 request = algod_models .SimulateRequest (
14751463 txn_groups = [algod_models .SimulateRequestTransactionGroup (txns = signed_transactions )],
14761464 allow_empty_signatures = True ,
0 commit comments