I want to wrap for loops in PyTeal for readability purposes. I want to pass the scratch_var
as an argument to the for_loop_wrapper
function. I am getting an error in PyTeal:
Argument at index 0 of subroutine call is not a PyTeal expression: <pyteal.ScratchVar object at 0x7ff5089dddc0>
Below is the my code:
@Subroutine(TealType.none)
def for_loop_wrapper(scratch_var, start: TealType.uint64, stopping_condition: TealType.uint64, increment: TealType.uint64):
return Seq([
For(scratch_var.store(start), scratch_var.load() < stopping_condition, scratch_var.store(scratch_var.load() + increment)).Do(Seq([
Log(Itob(scratch_var.load())),
])),
Return()
])
@Subroutine(TealType.none)
def for_loop():
scratch_var = ScratchVar(TealType.uint64)
return Seq([
for_loop(scratch_var, Int(0), Int(20), Int(1)),
Return()
])
Any thoughts on this?
Javier