Skip to content

Commit

Permalink
Revert "Add Execute Method (#444)"
Browse files Browse the repository at this point in the history
This reverts commit c936cbc.
  • Loading branch information
barnjamin authored Jul 20, 2022
1 parent c936cbc commit e091b97
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 64 deletions.
21 changes: 0 additions & 21 deletions pyteal/ast/itxn.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,27 +180,6 @@ def SetField(cls, field: TxnField, value: Union[Expr, List[Expr]]) -> Expr:
]
)

@classmethod
def Execute(cls, fields: Dict[TxnField, Union[Expr, List[Expr]]]) -> Expr:
"""Performs a single transaction given fields passed in.
A convenience method that accepts fields to submit a single inner transaction, which is equivalent to:
.. code-block:: python
InnerTxnBuilder.Begin()
InnerTxnBuilder.SetFields(fields)
InnerTxnBuilder.End()
Requires TEAL version 5 or higher. This operation is only permitted in application mode.
Args:
fields: A dictionary whose keys are fields to set and whose values are the value each
field should take. Each value must evaluate to a type that is compatible with the
field being set.
"""
return Seq(cls.Begin(), cls.SetFields(fields), cls.Submit())

@classmethod
def SetFields(cls, fields: Dict[TxnField, Union[Expr, List[Expr]]]) -> Expr:
"""Set multiple fields of the current inner transaction.
Expand Down
62 changes: 19 additions & 43 deletions pyteal/ast/itxn_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,29 +92,28 @@ def test_InnerTxnBuilder_SetField():
expr.__teal__(teal4Options)


ITXN_FIELDS_CASES = [
({}, pt.Seq()),
(
{pt.TxnField.amount: pt.Int(5)},
pt.InnerTxnBuilder.SetField(pt.TxnField.amount, pt.Int(5)),
),
(
{
pt.TxnField.type_enum: pt.TxnType.Payment,
pt.TxnField.close_remainder_to: pt.Txn.sender(),
},
pt.Seq(
pt.InnerTxnBuilder.SetField(pt.TxnField.type_enum, pt.TxnType.Payment),
pt.InnerTxnBuilder.SetField(
pt.TxnField.close_remainder_to, pt.Txn.sender()
def test_InnerTxnBuilder_SetFields():
cases = (
({}, pt.Seq()),
(
{pt.TxnField.amount: pt.Int(5)},
pt.InnerTxnBuilder.SetField(pt.TxnField.amount, pt.Int(5)),
),
(
{
pt.TxnField.type_enum: pt.TxnType.Payment,
pt.TxnField.close_remainder_to: pt.Txn.sender(),
},
pt.Seq(
pt.InnerTxnBuilder.SetField(pt.TxnField.type_enum, pt.TxnType.Payment),
pt.InnerTxnBuilder.SetField(
pt.TxnField.close_remainder_to, pt.Txn.sender()
),
),
),
),
]

)

def test_InnerTxnBuilder_SetFields():
for fields, expectedExpr in ITXN_FIELDS_CASES:
for fields, expectedExpr in cases:
expr = pt.InnerTxnBuilder.SetFields(fields)
assert expr.type_of() == pt.TealType.none
assert not expr.has_return()
Expand All @@ -135,27 +134,4 @@ def test_InnerTxnBuilder_SetFields():
expr.__teal__(teal4Options)


def test_InnerTxnBuilder_Execute():
for fields, expectedExpr in ITXN_FIELDS_CASES:
expr = pt.InnerTxnBuilder.Execute(fields)

expected, _ = pt.Seq(
pt.InnerTxnBuilder.Begin(),
expectedExpr,
pt.InnerTxnBuilder.Submit(),
).__teal__(teal5Options)
expected.addIncoming()
expected = pt.TealBlock.NormalizeBlocks(expected)

actual, _ = expr.__teal__(teal5Options)
actual.addIncoming()
actual = pt.TealBlock.NormalizeBlocks(actual)

with pt.TealComponent.Context.ignoreExprEquality():
assert actual == expected

with pytest.raises(pt.TealInputError):
expr.__teal__(teal4Options)


# txn_test.py performs additional testing

0 comments on commit e091b97

Please sign in to comment.