Skip to content

Commit

Permalink
Fix tealdbg Accounts array (algorand#1872)
Browse files Browse the repository at this point in the history
Currently the `Accounts` array is not displayed properly in tealdbg. The debugger does not account for the special case that index 0 of the `Accounts` array is always the sender. This means that if the ForeignAccounts txn field contains `n` accounts, the `Accounts` array in tealdbg contains the sender's account followed by `n-1` of the ForeignAccounts. The last account never gets displayed.

This PR fixes this problem by making tealdbg aware that the `Accounts` array has 1 more member (the sender's account) than `len(txn.Accounts)`. As a consequence of this, the sender's account will always appear at index 0 of the `Accounts` array in the debugger, even when the transaction's ForeignAccounts array is empty. This aligns with the behavior of the TEAL op `txna Accounts 0` always returning the sender's address, even in stateless TEAL.
  • Loading branch information
jasonpaulos authored Jan 29, 2021
1 parent 95a0eb2 commit 4625663
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/tealdbg/cdtState.go
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ func makeTxnImpl(txn *transactions.Transaction, groupIndex int, preview bool) (d
var length int
switch logic.TxnField(fieldIdx) {
case logic.Accounts:
length = len(txn.Accounts)
length = len(txn.Accounts) + 1
case logic.ApplicationArgs:
length = len(txn.ApplicationArgs)
}
Expand Down Expand Up @@ -765,7 +765,7 @@ func makeTxnArrayField(s *cdtState, groupIndex int, fieldIdx int) (desc []cdt.Ru
var length int
switch logic.TxnField(fieldIdx) {
case logic.Accounts:
length = len(txn.Accounts)
length = len(txn.Accounts) + 1
case logic.ApplicationArgs:
length = len(txn.ApplicationArgs)
}
Expand Down

0 comments on commit 4625663

Please sign in to comment.