@@ -16,13 +16,11 @@ import {
1616 TransactionType ,
1717 assignFee ,
1818 calculateFee ,
19- decodeSignedTransaction ,
19+ decodeSignedTransactions ,
2020 decodeTransaction ,
21- encodeSignedTransactions ,
2221 encodeTransactionRaw ,
2322 groupTransactions ,
2423 makeEmptyTransactionSigner ,
25- validateSignedTransaction ,
2624 validateTransaction ,
2725} from '@algorandfoundation/algokit-transact'
2826import { Buffer } from 'buffer'
@@ -250,7 +248,7 @@ export class TransactionComposer {
250248
251249 private transactionsWithSigners ?: TransactionWithSigner [ ]
252250
253- private signedTransactions ?: SignedTransaction [ ]
251+ private signedTransactions ?: Uint8Array [ ]
254252
255253 // Cache the raw transactions before resource population for error handling
256254 private rawBuildTransactions ?: Transaction [ ]
@@ -1858,19 +1856,18 @@ export class TransactionComposer {
18581856 } )
18591857 }
18601858
1861- const group = this . signedTransactions [ 0 ] . txn . group
1859+ const group = this . transactionsWithSigners [ 0 ] . txn . group
18621860
18631861 let waitRounds = params ?. maxRoundsToWaitForConfirmation
18641862
18651863 if ( waitRounds === undefined ) {
18661864 const suggestedParams = await this . getSuggestedParams ( )
18671865 const firstRound = suggestedParams . firstValid
1868- const lastRound = this . signedTransactions . reduce ( ( max , txn ) => ( txn . txn . lastValid > max ? txn . txn . lastValid : max ) , 0n )
1866+ const lastRound = this . transactionsWithSigners . reduce ( ( max , txn ) => ( txn . txn . lastValid > max ? txn . txn . lastValid : max ) , 0n )
18691867 waitRounds = Number ( lastRound - firstRound ) + 1
18701868 }
18711869
1872- const encodedTxns = encodeSignedTransactions ( this . signedTransactions )
1873- await this . algod . sendRawTransaction ( encodedTxns )
1870+ await this . algod . sendRawTransaction ( this . signedTransactions )
18741871
18751872 if ( transactionsToSend . length > 1 && group ) {
18761873 Config . getLogger ( params ?. suppressLog ) . verbose (
@@ -1927,7 +1924,9 @@ export class TransactionComposer {
19271924 txn,
19281925 signer : makeEmptyTransactionSigner ( ) ,
19291926 } ) )
1930- const signedTransactions = await this . signTransactions ( transactionsWithEmptySigners )
1927+ const encodedSignedTransactions = await this . signTransactions ( transactionsWithEmptySigners )
1928+ const signedTransactions = decodeSignedTransactions ( encodedSignedTransactions )
1929+
19311930 const simulateResponse = await this . algod . simulateTransactions ( {
19321931 txnGroups : [ { txns : signedTransactions } ] ,
19331932 allowEmptySignatures : true ,
@@ -2030,7 +2029,8 @@ export class TransactionComposer {
20302029 }
20312030
20322031 const transactions = transactionsWithSigner . map ( ( e ) => e . txn )
2033- const signedTransactions = await this . signTransactions ( transactionsWithSigner )
2032+ const encodedSignedTransactions = await this . signTransactions ( transactionsWithSigner )
2033+ const signedTransactions = decodeSignedTransactions ( encodedSignedTransactions )
20342034
20352035 const simulateRequest = {
20362036 txnGroups : [
@@ -2097,7 +2097,7 @@ export class TransactionComposer {
20972097 return encoder . encode ( arc2Payload )
20982098 }
20992099
2100- public async gatherSignatures ( ) : Promise < SignedTransaction [ ] > {
2100+ public async gatherSignatures ( ) : Promise < Uint8Array [ ] > {
21012101 if ( this . signedTransactions ) {
21022102 return this . signedTransactions
21032103 }
@@ -2112,7 +2112,7 @@ export class TransactionComposer {
21122112 return this . signedTransactions
21132113 }
21142114
2115- private async signTransactions ( transactionsWithSigners : TransactionWithSigner [ ] ) : Promise < SignedTransaction [ ] > {
2115+ private async signTransactions ( transactionsWithSigners : TransactionWithSigner [ ] ) : Promise < Uint8Array [ ] > {
21162116 if ( transactionsWithSigners . length === 0 ) {
21172117 throw new Error ( 'No transactions available to sign' )
21182118 }
@@ -2132,40 +2132,24 @@ export class TransactionComposer {
21322132 const signedGroups = await Promise . all ( signerEntries . map ( ( [ signer , indexes ] ) => signer ( transactions , indexes ) ) )
21332133
21342134 // Reconstruct signed transactions in original order
2135- const rawSignedTransactions : ( Uint8Array | null ) [ ] = new Array ( transactionsWithSigners . length ) . fill ( null )
2135+ const encodedSignedTransactions : ( Uint8Array | null ) [ ] = new Array ( transactionsWithSigners . length ) . fill ( null )
21362136 signerEntries . forEach ( ( [ , indexes ] , signerIndex ) => {
21372137 const stxs = signedGroups [ signerIndex ]
21382138 indexes . forEach ( ( txIndex , stxIndex ) => {
2139- rawSignedTransactions [ txIndex ] = stxs [ stxIndex ] ?? null
2139+ encodedSignedTransactions [ txIndex ] = stxs [ stxIndex ] ?? null
21402140 } )
21412141 } )
21422142
21432143 // Verify all transactions were signed
2144- const unsignedIndexes = rawSignedTransactions
2144+ const unsignedIndexes = encodedSignedTransactions
21452145 . map ( ( stxn , index ) => ( stxn == null ? index : null ) )
21462146 . filter ( ( index ) : index is number => index !== null )
21472147
21482148 if ( unsignedIndexes . length > 0 ) {
21492149 throw new Error ( `Transactions at indexes [${ unsignedIndexes . join ( ', ' ) } ] were not signed` )
21502150 }
21512151
2152- // Decode and validate all signed transactions
2153- const signedTransactions = rawSignedTransactions . map ( ( stxn , index ) => {
2154- if ( stxn == null ) {
2155- // This shouldn't happen due to the check above, but ensures type safety
2156- throw new Error ( `Transaction at index ${ index } was not signed` )
2157- }
2158-
2159- try {
2160- const signedTransaction = decodeSignedTransaction ( stxn )
2161- validateSignedTransaction ( signedTransaction )
2162- return signedTransaction
2163- } catch ( err ) {
2164- throw new Error ( `Invalid signed transaction at index ${ index } . ${ err } ` )
2165- }
2166- } )
2167-
2168- return signedTransactions
2152+ return encodedSignedTransactions as Uint8Array [ ] // The guard above ensures no nulls
21692153 }
21702154
21712155 private parseAbiReturnValues ( confirmations : PendingTransactionResponse [ ] ) : ABIReturn [ ] {
0 commit comments