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

Add opcode support for itxnas and gitxnas #193

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
61ef1bf
Merge branch 'master' into more-teal6-ops
michaeldiamant Feb 11, 2022
cdd2f41
Add opcode support for itxnas and gitxnas
michaeldiamant Feb 12, 2022
515f3fd
Merge branch 'more-teal6-ops' of github.com:algorand/pyteal into more…
michaeldiamant Feb 14, 2022
cee11f9
Merge remote-tracking branch 'algo/more-teal6-ops' into more-teal6-op…
michaeldiamant Feb 14, 2022
dc5289f
Update stale reference to inner transaction limit
michaeldiamant Feb 14, 2022
1a78b6b
Fix allowed types for GitxnaExpr txnIndex
michaeldiamant Feb 14, 2022
1e94439
Remove obsolete logic for handling GitxnaExpr.teal construction
michaeldiamant Feb 14, 2022
57725e0
Remove unnecessary cast and fix gitxna runtime type checking
michaeldiamant Feb 14, 2022
5ee2179
Move type validation to constructors for gtxn and gitxn variants
michaeldiamant Feb 15, 2022
2344d12
Add missed tests from prior commit
michaeldiamant Feb 15, 2022
acd8f35
Fix duplicate test case
michaeldiamant Feb 16, 2022
4409cd1
Move index validation from subclasses to TxnaExpr
michaeldiamant Feb 16, 2022
3fe7f40
Inline validation functions per PR feedback
michaeldiamant Feb 16, 2022
5b87d47
Remove unused imports
michaeldiamant Feb 16, 2022
922ad26
Refactor to isinstance tupled check
michaeldiamant Feb 16, 2022
6d9cb3c
Remove TEAL v1 min version test per PR feedback
michaeldiamant Feb 16, 2022
4b3440a
Fix constructor type checking for GtxnExpr
michaeldiamant Feb 16, 2022
6201c46
Refactor to remove duplicate type check function
michaeldiamant Feb 16, 2022
fdb4833
Merge pull request #1 from michaeldiamant/more-teal6-ops_gitxnas_itxn…
michaeldiamant Feb 16, 2022
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
11 changes: 10 additions & 1 deletion pyteal/ast/gitxn.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ def __str__(self):
def __teal__(self, options: "CompileOptions"):
verifyFieldVersion(self.field.arg_name, self.field.min_version, options.version)

if type(self.txnIndex) is not int or not (
type(self.index) is int or isinstance(self.index, Expr)
):
raise TealInputError(
"Invalid gitxna syntax with immediate transaction index {}, transaction field {}, array index {}".format(
self.txnIndex, self.field, self.index
)
)

if type(self.index) is int:
opToUse = Op.gitxna
else:
Expand Down Expand Up @@ -98,7 +107,7 @@ def __getitem__(self, txnIndex: int) -> TxnObject:

return TxnObject(
lambda field: GitxnExpr(txnIndex, field),
lambda field, index: GitxnaExpr(txnIndex, field, cast(int, index)),
lambda field, index: GitxnaExpr(txnIndex, field, index),
)


Expand Down
15 changes: 13 additions & 2 deletions pyteal/ast/gitxn_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,21 @@ def test_gitxn_invalid():


def test_gitxn_valid():
GitxnaExpr(0, TxnField.application_args, 1).__teal__(teal6Options)

for i in range(MAX_GROUP_SIZE):
Gitxn[i].sender()


def test_gitxna_invalid():
with pytest.raises(TealInputError):
GitxnaExpr("Invalid_type", TxnField.application_args, 1).__teal__(teal6Options)

with pytest.raises(TealInputError):
GitxnaExpr(0, TxnField.application_args, "Invalid_type").__teal__(teal6Options)


def test_gitxna_valid():
GitxnaExpr(0, TxnField.application_args, 1).__teal__(teal6Options)
GitxnaExpr(0, TxnField.application_args, Assert(Int(1))).__teal__(teal6Options)


# txn_test.py performs additional testing