Skip to content

Commit

Permalink
fix: itxn arguments are now inferred correctly when using only a meth…
Browse files Browse the repository at this point in the history
…od name in `algopy.arc4.abi_call`
  • Loading branch information
daniel-makerx committed Oct 23, 2024
1 parent eaf2700 commit 7456894
Show file tree
Hide file tree
Showing 17 changed files with 1,781 additions and 701 deletions.
2 changes: 1 addition & 1 deletion examples/sizes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
tuple_support/TupleSupport 696 409 - | 381 180 -
typed_abi_call/Greeter 5239 3956 - | 2737 1866 -
typed_abi_call/Logger 1456 1139 1138 | 823 631 630
typed_abi_call_txn/Caller 468 406 - | 240 205 -
typed_abi_call_txn/Caller 586 514 - | 305 264 -
typed_abi_call_txn/Txn 312 248 - | 170 134 -
unary/Unary 130 67 - | 62 27 -
unassigned_expression/Unassigned 158 119 - | 80 58 -
Expand Down
3 changes: 3 additions & 0 deletions src/puyapy/awst_build/eb/arc4/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ def _implicit_arc4_type_conversion(typ: pytypes.PyType, loc: SourceLocation) ->
return pytypes.ARC4DynamicBytesType
case pytypes.IntLiteralType:
return pytypes.ARC4UIntN_Aliases[64]
# convert a txn type to it's equivalent group txn type
case pytypes.TransactionRelatedType(transaction_type=txn_type):
return pytypes.GroupTransactionTypes[txn_type]

def on_error(invalid_pytype: pytypes.PyType) -> typing.Never:
raise CodeError(
Expand Down
16 changes: 16 additions & 0 deletions test_cases/typed_abi_call_txn/caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Application,
ARC4Contract,
Bytes,
UInt64,
arc4,
itxn,
op,
Expand Down Expand Up @@ -42,6 +43,21 @@ def test_call_with_acfg(self, a: Bytes, b: Bytes, app: Application) -> None:
app_id=app,
)

@arc4.abimethod
def test_call_with_infer(self, a: Bytes, b: Bytes, app: Application) -> None:
txn = itxn.AssetConfig(
unit_name="TST",
asset_name="TEST",
total=1,
)
arc4.abi_call[UInt64](
"call_with_acfg",
a,
txn,
b,
app_id=app,
)

@arc4.abimethod
def test_call_with_acfg_no_return(self, a: Bytes, b: Bytes, app: Application) -> None:
acfg = itxn.AssetConfig(
Expand Down
804 changes: 456 additions & 348 deletions test_cases/typed_abi_call_txn/out/Caller.approval.mir

Large diffs are not rendered by default.

Loading

0 comments on commit 7456894

Please sign in to comment.