Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support FirstValidTime transaction field #424

Merged
merged 3 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 8 additions & 1 deletion pyteal/ast/txn.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class TxnField(Enum):
sender = (0, "Sender", TealType.bytes, False, 2)
fee = (1, "Fee", TealType.uint64, False, 2)
first_valid = (2, "FirstValid", TealType.uint64, False, 2)
first_valid_time = (3, "FirstValidTime", TealType.uint64, False, 2)
first_valid_time = (3, "FirstValidTime", TealType.uint64, False, 7)
last_valid = (4, "LastValid", TealType.uint64, False, 2)
note = (5, "Note", TealType.bytes, False, 2)
lease = (6, "Lease", TealType.bytes, False, 2)
Expand Down Expand Up @@ -303,6 +303,13 @@ def first_valid(self) -> TxnExpr:
"""
return self.makeTxnExpr(TxnField.first_valid)

def first_valid_time(self) -> TxnExpr:
"""Get the UNIX timestamp of block before txn.FirstValid. Fails if negative.

For more information, see https://developer.algorand.org/docs/reference/transactions/#firstvalidtime
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: First valid time is not yet documented on the transactions reference page.

"""
return self.makeTxnExpr(TxnField.first_valid_time)

def last_valid(self) -> TxnExpr:
"""Get the last valid round number.

Expand Down
1 change: 1 addition & 0 deletions pyteal/ast/txn_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
pt.TxnField.sender: lambda txn: txn.sender(),
pt.TxnField.fee: lambda txn: txn.fee(),
pt.TxnField.first_valid: lambda txn: txn.first_valid(),
pt.TxnField.first_valid_time: lambda txn: txn.first_valid_time(),
pt.TxnField.last_valid: lambda txn: txn.last_valid(),
pt.TxnField.note: lambda txn: txn.note(),
pt.TxnField.lease: lambda txn: txn.lease(),
Expand Down