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
7 changes: 0 additions & 7 deletions src/puya/awst/function_traverser.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,6 @@ def visit_stage_inner_transactions(self, node: awst_nodes.StageInnerTransactions
for expr in node.itxns:
expr.accept(self)

@typing.override
def visit_set_inner_transaction_fields(
self, node: awst_nodes.SetInnerTransactionFields
) -> None:
for expr in node.itxns:
expr.accept(self)

@typing.override
def visit_submit_inner_transaction(self, call: awst_nodes.SubmitInnerTransaction) -> None:
for expr in call.itxns:
Expand Down
31 changes: 0 additions & 31 deletions src/puya/awst/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import attrs
from immutabledict import immutabledict
from typing_extensions import deprecated

from puya import log
from puya.algo_constants import SUPPORTED_AVM_VERSIONS
Expand Down Expand Up @@ -1098,30 +1097,6 @@ def accept(self, visitor: ExpressionVisitor[T]) -> T:
return visitor.visit_inner_transaction_field(self)


@deprecated("replaced by StageInnerTransactions")
@attrs.frozen
class SetInnerTransactionFields(Expression):
"""
Emits an `itxn_begin` or `itxn_next` plus the relevant `itxn_field` ops for each field
in each itxn of itxns.
"""

itxns: Sequence[Expression] = attrs.field(converter=tuple[Expression, ...])
"""A sequence of inner transaction fields expressions"""
start_with_begin: bool = attrs.field()
"""Use `itxn_begin` for the first itxn in itxns (else use `itxn_next`)"""
wtype: WType = attrs.field(init=False, default=wtypes.void_wtype)

@itxns.validator
def _check_itxns(self, _attribute: object, itxns: Sequence[Expression]) -> None:
for expr in itxns:
if not isinstance(expr.wtype, wtypes.WInnerTransactionFields):
raise CodeError("invalid expression type for set", expr.source_location)

def accept(self, visitor: ExpressionVisitor[T]) -> T:
return visitor.visit_set_inner_transaction_fields(self)


@attrs.frozen
class SubmitInnerTransaction(Expression):
"""
Expand Down Expand Up @@ -1363,12 +1338,6 @@ def accept(self, visitor: ExpressionVisitor[T]) -> T:
return visitor.visit_map_prefixed_key_expression(self)


@deprecated("replaced by MapPrefixedKeyExpression")
@attrs.frozen
class BoxPrefixedKeyExpression(MapPrefixedKeyExpression):
wtype: WType = attrs.field(default=wtypes.box_key, init=False)


@attrs.frozen
class BoxValueExpression(Expression):
key: Expression = attrs.field(validator=expression_has_wtype(wtypes.box_key))
Expand Down
7 changes: 0 additions & 7 deletions src/puya/awst/to_code_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,13 +491,6 @@ def visit_stage_inner_transactions(self, node: nodes.StageInnerTransactions) ->

return f"stage_itxns=([{itxns}], start_new_group={start_new_group})"

@typing.override
def visit_set_inner_transaction_fields(self, node: nodes.SetInnerTransactionFields) -> str:
begin_or_next = "begin" if node.start_with_begin else "next"
itxns = f'{", ".join(itxn.accept(self) for itxn in node.itxns)}'

return f"{begin_or_next}_txn({itxns})"

@typing.override
def visit_submit_inner_transaction(self, call: nodes.SubmitInnerTransaction) -> str:
itxns = f'{", ".join(itxn.accept(self) for itxn in call.itxns)}'
Expand Down
5 changes: 0 additions & 5 deletions src/puya/awst/visitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,6 @@ def visit_stage_inner_transactions(
self, node: puya.awst.nodes.StageInnerTransactions
) -> T: ...

@abstractmethod
def visit_set_inner_transaction_fields(
self, node: puya.awst.nodes.SetInnerTransactionFields
) -> T: ...

@abstractmethod
def visit_submit_inner_transaction(
self, submit: puya.awst.nodes.SubmitInnerTransaction
Expand Down
10 changes: 2 additions & 8 deletions src/puya/ir/builder/itxn.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,14 @@ def _emit_itxn_fields(
def handle_stage_inner_transactions(
self,
itxns: Sequence[awst_nodes.Expression],
start_new_group: awst_nodes.Expression | bool,
start_new_group: awst_nodes.Expression,
source_location: SourceLocation,
) -> None:
group = self._expand_abi_calls(itxns)
for idx, itxn in enumerate(group):
if idx == 0:
match start_new_group:
case bool(val) | awst_nodes.BoolConstant(value=val):
case awst_nodes.BoolConstant(value=val):
if val:
op = AVMOp.itxn_begin
else:
Expand Down Expand Up @@ -1121,12 +1121,6 @@ def _empty_actions_from_wtype(self, expr: awst_nodes.Expression) -> list[_Source
logger.error("unsupported inner transaction expression", location=expr.source_location)
return [None] * len(ir_types)

@typing.override
def visit_set_inner_transaction_fields(
self, expr: awst_nodes.SetInnerTransactionFields
) -> list[_SourceAction]:
return self._empty_actions_from_wtype(expr)

@typing.override
def visit_state_delete(self, expr: awst_nodes.StateDelete) -> list[_SourceAction]:
return self._empty_actions_from_wtype(expr)
Expand Down
7 changes: 0 additions & 7 deletions src/puya/ir/builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,13 +650,6 @@ def visit_stage_inner_transactions(self, node: awst_nodes.StageInnerTransactions
node.itxns, node.start_new_group, node.source_location
)

def visit_set_inner_transaction_fields(
self, node: awst_nodes.SetInnerTransactionFields
) -> None:
self._itxn.handle_stage_inner_transactions(
node.itxns, node.start_with_begin, node.source_location
)

def visit_submit_inner_transaction(
self, submit: awst_nodes.SubmitInnerTransaction
) -> TExpression:
Expand Down
114 changes: 102 additions & 12 deletions test_cases_awst/itxn_compose/module.awst.json
Original file line number Diff line number Diff line change
Expand Up @@ -7688,6 +7688,7 @@
},
{
"expr": {
"_type": "StageInnerTransactions",
"source_location": {
"file": "%DIR%/itxn-compose.algo.ts",
"line": 31,
Expand Down Expand Up @@ -7928,8 +7929,22 @@
"_type": "CreateInnerTransaction"
}
],
"start_with_begin": true,
"_type": "SetInnerTransactionFields"
"start_new_group": {
"_type": "BoolConstant",
"source_location": {
"file": "%DIR%/itxn-compose.algo.ts",
"line": 31,
"end_line": 31,
"column": 4,
"end_column": 32
},
"wtype": {
"_type": "WType",
"name": "bool",
"immutable": true
},
"value": true
}
},
"_type": "ExpressionStatement"
},
Expand Down Expand Up @@ -8249,6 +8264,7 @@
},
{
"expr": {
"_type": "StageInnerTransactions",
"source_location": {
"file": "%DIR%/itxn-compose.algo.ts",
"line": 34,
Expand Down Expand Up @@ -8470,8 +8486,22 @@
"_type": "CreateInnerTransaction"
}
],
"start_with_begin": false,
"_type": "SetInnerTransactionFields"
"start_new_group": {
"_type": "BoolConstant",
"source_location": {
"file": "%DIR%/itxn-compose.algo.ts",
"line": 34,
"end_line": 37,
"column": 6,
"end_column": 8
},
"wtype": {
"_type": "WType",
"name": "bool",
"immutable": true
},
"value": false
}
},
"_type": "ExpressionStatement"
}
Expand All @@ -8494,6 +8524,7 @@
},
{
"expr": {
"_type": "StageInnerTransactions",
"source_location": {
"file": "%DIR%/itxn-compose.algo.ts",
"line": 40,
Expand Down Expand Up @@ -8628,13 +8659,28 @@
"_type": "CreateInnerTransaction"
}
],
"start_with_begin": false,
"_type": "SetInnerTransactionFields"
"start_new_group": {
"_type": "BoolConstant",
"source_location": {
"file": "%DIR%/itxn-compose.algo.ts",
"line": 40,
"end_line": 44,
"column": 4,
"end_column": 6
},
"wtype": {
"_type": "WType",
"name": "bool",
"immutable": true
},
"value": false
}
},
"_type": "ExpressionStatement"
},
{
"expr": {
"_type": "StageInnerTransactions",
"source_location": {
"file": "%DIR%/itxn-compose.algo.ts",
"line": 46,
Expand Down Expand Up @@ -8717,8 +8763,22 @@
"_type": "CreateInnerTransaction"
}
],
"start_with_begin": false,
"_type": "SetInnerTransactionFields"
"start_new_group": {
"_type": "BoolConstant",
"source_location": {
"file": "%DIR%/itxn-compose.algo.ts",
"line": 46,
"end_line": 50,
"column": 4,
"end_column": 5
},
"wtype": {
"_type": "WType",
"name": "bool",
"immutable": true
},
"value": false
}
},
"_type": "ExpressionStatement"
},
Expand Down Expand Up @@ -10261,6 +10321,7 @@
"body": [
{
"expr": {
"_type": "StageInnerTransactions",
"source_location": {
"file": "%DIR%/itxn-compose.algo.ts",
"line": 60,
Expand Down Expand Up @@ -10461,8 +10522,22 @@
"_type": "CreateInnerTransaction"
}
],
"start_with_begin": true,
"_type": "SetInnerTransactionFields"
"start_new_group": {
"_type": "BoolConstant",
"source_location": {
"file": "%DIR%/itxn-compose.algo.ts",
"line": 60,
"end_line": 60,
"column": 8,
"end_column": 81
},
"wtype": {
"_type": "WType",
"name": "bool",
"immutable": true
},
"value": true
}
},
"_type": "ExpressionStatement"
}
Expand Down Expand Up @@ -10498,6 +10573,7 @@
"body": [
{
"expr": {
"_type": "StageInnerTransactions",
"source_location": {
"file": "%DIR%/itxn-compose.algo.ts",
"line": 62,
Expand Down Expand Up @@ -10698,8 +10774,22 @@
"_type": "CreateInnerTransaction"
}
],
"start_with_begin": false,
"_type": "SetInnerTransactionFields"
"start_new_group": {
"_type": "BoolConstant",
"source_location": {
"file": "%DIR%/itxn-compose.algo.ts",
"line": 62,
"end_line": 62,
"column": 8,
"end_column": 80
},
"wtype": {
"_type": "WType",
"name": "bool",
"immutable": true
},
"value": false
}
},
"_type": "ExpressionStatement"
}
Expand Down
7 changes: 6 additions & 1 deletion test_cases_awst/ops_should_be_mutated/module.awst.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
"_type": "ARC4Struct"
},
"key": {
"_type": "MapPrefixedKeyExpression",
"source_location": {
"file": "%DIR%/tests/approvals/mutable-object.algo.ts",
"line": 4,
Expand Down Expand Up @@ -282,7 +283,11 @@
"name": "key",
"_type": "VarExpression"
},
"_type": "BoxPrefixedKeyExpression"
"wtype": {
"name": "box_key",
"immutable": true,
"_type": "WType"
}
},
"exists_assertion_message": "Box must have value",
"_type": "BoxValueExpression"
Expand Down
Binary file modified tests/analyse/reti.awst.json.gz
Binary file not shown.
Loading
Loading