/**
* Send the transaction group to the network and wait until it's committed to a block. An error
* will be thrown if submission or execution fails.
*
* The composer's status must be SUBMITTED or lower before calling this method, since execution is
* only allowed once. If submission is successful, this composer's status will update to SUBMITTED.
* If the execution is also successful, this composer's status will update to COMMITTED.
*
* Note: a group can only be submitted again if it fails.
*
* @returns an object containing the confirmed round for this transaction, the txIDs of the submitted
*   transactions, and an array of results containing one element for each method call transaction in
*   this group. If a method has no return value (void), then the method results array will contain
*   null for that method's return value.
 */
Send the transaction group to the network and wait until it's committed to a block. An error
will be thrown if submission or execution fails.

The composer's status must be SUBMITTED or lower before calling this method, since execution is
only allowed once. If submission is successful, this composer's status will update to SUBMITTED.
If the execution is also successful, this composer's status will update to COMMITTED.

a group can only be submitted again if it fails.

@returns an object containing the confirmed round for this transaction, the txIDs of the submitted
transactions, and an array of results containing one element for each method call transaction in
this group. If a method has no return value (void), then the method results array will contain
null for that method's return value.
/ ** * Send the transaction group to the network and wait until it ' s committed to a block . An error * will be thrown if submission or execution fails . * * The composer ' s status must be SUBMITTED or lower before calling this method since execution is * only allowed once . If submission is successful this composer ' s status will update to SUBMITTED . * If the execution is also successful this composer ' s status will update to COMMITTED . * * Note : a group can only be submitted again if it fails . * * @returns an object containing the confirmed round for this transaction the txIDs of the submitted * transactions and an array of results containing one element for each method call transaction in * this group . If a method has no return value ( void ) then the method results array will contain * null for that method ' s return value . * /
func (atc *AtomicTransactionComposer) Execute(client *algod.Client, ctx context.Context, waitRounds uint64) (uint64, []string, []ABIResult, error) {
	if atc.status == COMMITTED {
		return 0, nil, nil, errors.New("status is already committed")
	}
	_, err := atc.Submit(client, ctx)
	if err != nil {
		return 0, nil, nil, err
	}
	txinfo, err := WaitForConfirmation(client, atc.txContexts[0].txID(), waitRounds, ctx)
	if err != nil {
		return 0, nil, nil, err
	}
	atc.status = COMMITTED
	var returnValues []ABIResult
	for _, txContext := range atc.txContexts {
		txid := txContext.txID()
		if !txContext.isMethodCallTx() {
			continue
		}
		txinfo, _, err := client.PendingTransactionInformation(txid).Do(ctx)
		if err != nil {
			returnValues = append(returnValues, ABIResult{TxID: txid, RawReturnValue: []byte{}, ReturnValue: nil, DecodeError: err})
			continue
		}
		if txContext.method.Returns.AbiType == "void" {
			returnValues = append(returnValues, ABIResult{TxID: txid, RawReturnValue: []byte{}, ReturnValue: nil, DecodeError: nil})
			continue
		}
		failedToFindResult := true
		for j := len(txinfo.Logs) - 1; j >= 0; j-- {
			log := txinfo.Logs[j]
			if len(log) >= 4 && bytes.Equal(log[:4], ABI_RETURN_HASH) {
				failedToFindResult = false
				abiType, err := abi.TypeOf(txContext.method.Returns.AbiType)
				if err != nil {
					returnValues = append(returnValues, ABIResult{TxID: txid, RawReturnValue: log[4:], ReturnValue: nil, DecodeError: err})
					break
				}
				abiValue, err := abiType.Decode(log[4:])
				if err != nil {
					returnValues = append(returnValues, ABIResult{TxID: txid, RawReturnValue: log[4:], ReturnValue: nil, DecodeError: err})
					break
				}
				returnValues = append(returnValues, ABIResult{TxID: txid, RawReturnValue: log[4:], ReturnValue: abiValue, DecodeError: nil})
				break
			}
		}
		if failedToFindResult {
			returnValues = append(returnValues, ABIResult{
				TxID:           txid,
				RawReturnValue: nil,
				ReturnValue:    nil,
				DecodeError:    fmt.Errorf("no return value found when one was expected"),
			})
		}
	}
	return txinfo.ConfirmedRound, atc.getTxIDs(), returnValues, err
}
func ( atc * AtomicTransactionComposer ) Execute ( client * algod . Client , ctx context . Context , waitRounds uint64 ) ( uint64 , [ ] string , [ ] ABIResult , error ) { if atc . status == COMMITTED { return 0 , nil , nil , errors . New ( " " ) } _ , err := atc . Submit ( client , ctx ) if err != nil { return 0 , nil , nil , err } txinfo , err := WaitForConfirmation ( client , atc . txContexts [ 0 ] . txID ( ) , waitRounds , ctx ) if err != nil { return 0 , nil , nil , err } atc . status = COMMITTED var returnValues [ ] ABIResult for _ , txContext := range atc . txContexts { txid := txContext . txID ( ) if ! txContext . isMethodCallTx ( ) { continue } txinfo , _ , err := client . PendingTransactionInformation ( txid ) . Do ( ctx ) if err != nil { returnValues = append ( returnValues , ABIResult { TxID : txid , RawReturnValue : [ ] byte { } , ReturnValue : nil , DecodeError : err } ) continue } if txContext . method . Returns . AbiType == " " { returnValues = append ( returnValues , ABIResult { TxID : txid , RawReturnValue : [ ] byte { } , ReturnValue : nil , DecodeError : nil } ) continue } failedToFindResult := true for j := len ( txinfo . Logs ) - 1 ; j >= 0 ; j -- { log := txinfo . Logs [ j ] if len ( log ) >= 4 && bytes . Equal ( log [ : 4 ] , ABI_RETURN_HASH ) { failedToFindResult = false abiType , err := abi . TypeOf ( txContext . method . Returns . AbiType ) if err != nil { returnValues = append ( returnValues , ABIResult { TxID : txid , RawReturnValue : log [ 4 : ] , ReturnValue : nil , DecodeError : err } ) break } abiValue , err := abiType . Decode ( log [ 4 : ] ) if err != nil { returnValues = append ( returnValues , ABIResult { TxID : txid , RawReturnValue : log [ 4 : ] , ReturnValue : nil , DecodeError : err } ) break } returnValues = append ( returnValues , ABIResult { TxID : txid , RawReturnValue : log [ 4 : ] , ReturnValue : abiValue , DecodeError : nil } ) break } } if failedToFindResult { returnValues = append ( returnValues , ABIResult { TxID : txid , RawReturnValue : nil , ReturnValue : nil , DecodeError : fmt . Errorf ( " " ) , } ) } } return txinfo . ConfirmedRound , atc . getTxIDs ( ) , returnValues , err }
Send the transaction group to the network and wait until it's committed to a block.
Send the transaction group to the network and wait until it ' s committed to a block .
// Verify method call is available. This may not be the case if the App Call Tx wasn't created // by AddMethodCall().