diff --git a/src/puya/awst/function_traverser.py b/src/puya/awst/function_traverser.py index 2ccc23c776..f1d519b42b 100644 --- a/src/puya/awst/function_traverser.py +++ b/src/puya/awst/function_traverser.py @@ -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: diff --git a/src/puya/awst/nodes.py b/src/puya/awst/nodes.py index 7ce87fa7cc..efeb28254c 100644 --- a/src/puya/awst/nodes.py +++ b/src/puya/awst/nodes.py @@ -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 @@ -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): """ @@ -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)) diff --git a/src/puya/awst/to_code_visitor.py b/src/puya/awst/to_code_visitor.py index 81a5b7d9e6..6e9dbc5a01 100644 --- a/src/puya/awst/to_code_visitor.py +++ b/src/puya/awst/to_code_visitor.py @@ -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)}' diff --git a/src/puya/awst/visitors.py b/src/puya/awst/visitors.py index c864c9041a..d7901cca64 100644 --- a/src/puya/awst/visitors.py +++ b/src/puya/awst/visitors.py @@ -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 diff --git a/src/puya/ir/builder/itxn.py b/src/puya/ir/builder/itxn.py index 1ca7f6d1cc..fdf6fa9b15 100644 --- a/src/puya/ir/builder/itxn.py +++ b/src/puya/ir/builder/itxn.py @@ -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: @@ -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) diff --git a/src/puya/ir/builder/main.py b/src/puya/ir/builder/main.py index 57e416f55e..ff64b40a87 100644 --- a/src/puya/ir/builder/main.py +++ b/src/puya/ir/builder/main.py @@ -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: diff --git a/test_cases_awst/itxn_compose/module.awst.json b/test_cases_awst/itxn_compose/module.awst.json index 83d926710d..55fdbf0bb4 100644 --- a/test_cases_awst/itxn_compose/module.awst.json +++ b/test_cases_awst/itxn_compose/module.awst.json @@ -7688,6 +7688,7 @@ }, { "expr": { + "_type": "StageInnerTransactions", "source_location": { "file": "%DIR%/itxn-compose.algo.ts", "line": 31, @@ -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" }, @@ -8249,6 +8264,7 @@ }, { "expr": { + "_type": "StageInnerTransactions", "source_location": { "file": "%DIR%/itxn-compose.algo.ts", "line": 34, @@ -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" } @@ -8494,6 +8524,7 @@ }, { "expr": { + "_type": "StageInnerTransactions", "source_location": { "file": "%DIR%/itxn-compose.algo.ts", "line": 40, @@ -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, @@ -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" }, @@ -10261,6 +10321,7 @@ "body": [ { "expr": { + "_type": "StageInnerTransactions", "source_location": { "file": "%DIR%/itxn-compose.algo.ts", "line": 60, @@ -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" } @@ -10498,6 +10573,7 @@ "body": [ { "expr": { + "_type": "StageInnerTransactions", "source_location": { "file": "%DIR%/itxn-compose.algo.ts", "line": 62, @@ -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" } diff --git a/test_cases_awst/ops_should_be_mutated/module.awst.json b/test_cases_awst/ops_should_be_mutated/module.awst.json index c840e58711..308e9c26a0 100644 --- a/test_cases_awst/ops_should_be_mutated/module.awst.json +++ b/test_cases_awst/ops_should_be_mutated/module.awst.json @@ -239,6 +239,7 @@ "_type": "ARC4Struct" }, "key": { + "_type": "MapPrefixedKeyExpression", "source_location": { "file": "%DIR%/tests/approvals/mutable-object.algo.ts", "line": 4, @@ -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" diff --git a/tests/analyse/reti.awst.json.gz b/tests/analyse/reti.awst.json.gz index 4c7a882bcd..ef0ac93de6 100644 Binary files a/tests/analyse/reti.awst.json.gz and b/tests/analyse/reti.awst.json.gz differ diff --git a/tests/output/nodes.ts.txt b/tests/output/nodes.ts.txt index a62275c80b..bb9d156693 100644 --- a/tests/output/nodes.ts.txt +++ b/tests/output/nodes.ts.txt @@ -558,20 +558,6 @@ export class InnerTransactionField extends Expression { return visitor.visitInnerTransactionField(this) } } -export class SetInnerTransactionFields extends Expression { - constructor(props: Props) { - super(props) - this.itxns = props.itxns - this.startWithBegin = props.startWithBegin - this.wtype = props.wtype - } - readonly itxns: Array - readonly startWithBegin: boolean - readonly wtype: wtypes.WType - accept(visitor: ExpressionVisitor): T { - return visitor.visitSetInnerTransactionFields(this) - } -} export class SubmitInnerTransaction extends Expression { constructor(props: Props) { super(props) @@ -689,16 +675,6 @@ export class MapPrefixedKeyExpression extends Expression { return visitor.visitMapPrefixedKeyExpression(this) } } -export class BoxPrefixedKeyExpression extends MapPrefixedKeyExpression { - constructor(props: Props) { - super(props) - this.wtype = props.wtype - } - readonly wtype: wtypes.WType - accept(visitor: ExpressionVisitor): T { - return visitor.visitBoxPrefixedKeyExpression(this) - } -} export class BoxValueExpression extends Expression { constructor(props: Props) { super(props) @@ -1625,7 +1601,6 @@ export const concreteNodes = { namedTupleExpression: NamedTupleExpression, varExpression: VarExpression, innerTransactionField: InnerTransactionField, - setInnerTransactionFields: SetInnerTransactionFields, submitInnerTransaction: SubmitInnerTransaction, fieldExpression: FieldExpression, indexExpression: IndexExpression, @@ -1634,7 +1609,6 @@ export const concreteNodes = { appStateExpression: AppStateExpression, appAccountStateExpression: AppAccountStateExpression, mapPrefixedKeyExpression: MapPrefixedKeyExpression, - boxPrefixedKeyExpression: BoxPrefixedKeyExpression, boxValueExpression: BoxValueExpression, singleEvaluation: SingleEvaluation, reinterpretCast: ReinterpretCast, @@ -1744,7 +1718,6 @@ export interface ExpressionVisitor { visitNamedTupleExpression(expression: NamedTupleExpression): T visitVarExpression(expression: VarExpression): T visitInnerTransactionField(expression: InnerTransactionField): T - visitSetInnerTransactionFields(expression: SetInnerTransactionFields): T visitSubmitInnerTransaction(expression: SubmitInnerTransaction): T visitFieldExpression(expression: FieldExpression): T visitIndexExpression(expression: IndexExpression): T @@ -1753,7 +1726,6 @@ export interface ExpressionVisitor { visitAppStateExpression(expression: AppStateExpression): T visitAppAccountStateExpression(expression: AppAccountStateExpression): T visitMapPrefixedKeyExpression(expression: MapPrefixedKeyExpression): T - visitBoxPrefixedKeyExpression(expression: BoxPrefixedKeyExpression): T visitBoxValueExpression(expression: BoxValueExpression): T visitSingleEvaluation(expression: SingleEvaluation): T visitReinterpretCast(expression: ReinterpretCast): T