Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions data/transactions/logic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ Global fields are fields that are common to all the transactions in the group. I
| 8 | CurrentApplicationID | uint64 | ID of current application executing. Fails if no such application is executing. LogicSigVersion >= 2. |
| 9 | CreatorAddress | []byte | Address of the creator of the current application. Fails if no such application is executing. LogicSigVersion >= 3. |
| 10 | CurrentApplicationAddress | []byte | Address that the current application controls. Fails if no such application is executing. LogicSigVersion >= 5. |
| 11 | GroupID | []byte | ID of the transaction group. 32 zero bytes if the transaction is not part of a group. LogicSigVersion >= 5. |


**Asset Fields**
Expand Down
1 change: 1 addition & 0 deletions data/transactions/logic/TEAL_opcodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ FirstValidTime causes the program to fail. The field is reserved for future use.
| 8 | CurrentApplicationID | uint64 | ID of current application executing. Fails if no such application is executing. LogicSigVersion >= 2. |
| 9 | CreatorAddress | []byte | Address of the creator of the current application. Fails if no such application is executing. LogicSigVersion >= 3. |
| 10 | CurrentApplicationAddress | []byte | Address that the current application controls. Fails if no such application is executing. LogicSigVersion >= 5. |
| 11 | GroupID | []byte | ID of the transaction group. 32 zero bytes if the transaction is not part of a group. LogicSigVersion >= 5. |


## gtxn t f
Expand Down
1 change: 1 addition & 0 deletions data/transactions/logic/assembler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,7 @@ global Round
global LatestTimestamp
global CurrentApplicationID
global CreatorAddress
global GroupID
txn Sender
txn Fee
bnz label1
Expand Down
1 change: 1 addition & 0 deletions data/transactions/logic/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ var globalFieldDocs = map[string]string{
"CurrentApplicationID": "ID of current application executing. Fails if no such application is executing",
"CreatorAddress": "Address of the creator of the current application. Fails if no such application is executing",
"CurrentApplicationAddress": "Address that the current application controls. Fails if no such application is executing",
"GroupID": "ID of the transaction group. 32 zero bytes if the transaction is not part of a group.",
}

// GlobalFieldDocs are notes on fields available in `global` with extra versioning info if any
Expand Down
6 changes: 6 additions & 0 deletions data/transactions/logic/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -2346,6 +2346,10 @@ func (cx *EvalContext) getCreatorAddress() ([]byte, error) {
return creator[:], nil
}

func (cx *EvalContext) getGroupID() []byte {
return cx.Txn.Txn.Group[:]
}

var zeroAddress basics.Address

func (cx *EvalContext) globalFieldToValue(fs globalFieldSpec) (sv stackValue, err error) {
Expand Down Expand Up @@ -2374,6 +2378,8 @@ func (cx *EvalContext) globalFieldToValue(fs globalFieldSpec) (sv stackValue, er
sv.Bytes = addr[:]
case CreatorAddress:
sv.Bytes, err = cx.getCreatorAddress()
case GroupID:
sv.Bytes = cx.getGroupID()
default:
err = fmt.Errorf("invalid global field %d", fs.field)
}
Expand Down
7 changes: 6 additions & 1 deletion data/transactions/logic/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,10 @@ len
int 32
==
&&
global GroupID
byte 0x0706000000000000000000000000000000000000000000000000000000000000
==
&&
`

func TestGlobal(t *testing.T) {
Expand Down Expand Up @@ -1062,7 +1066,7 @@ func TestGlobal(t *testing.T) {
EvalStateful, CheckStateful,
},
5: {
CurrentApplicationAddress, globalV5TestProgram,
GroupID, globalV5TestProgram,
EvalStateful, CheckStateful,
},
}
Expand Down Expand Up @@ -1091,6 +1095,7 @@ func TestGlobal(t *testing.T) {
require.NoError(t, err)
var txn transactions.SignedTxn
txn.Lsig.Logic = ops.Program
txn.Txn.Group = crypto.Digest{0x07, 0x06}
txgroup := make([]transactions.SignedTxn, 1)
txgroup[0] = txn
sb := strings.Builder{}
Expand Down
3 changes: 3 additions & 0 deletions data/transactions/logic/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ const (

// CurrentApplicationAddress [32]byte
CurrentApplicationAddress
// GroupID [32]byte
GroupID

invalidGlobalField
)
Expand Down Expand Up @@ -364,6 +366,7 @@ var globalFieldSpecs = []globalFieldSpec{
{CurrentApplicationID, StackUint64, runModeApplication, 2},
{CreatorAddress, StackBytes, runModeApplication, 3},
{CurrentApplicationAddress, StackBytes, runModeApplication, 5},
{GroupID, StackBytes, modeAny, 5},
}

// GlobalFieldSpecByField maps GlobalField to spec
Expand Down
7 changes: 4 additions & 3 deletions data/transactions/logic/fields_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.