Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Array Reference #109

Closed
barnjamin opened this issue Sep 6, 2021 · 2 comments · Fixed by #115
Closed

Dynamic Array Reference #109

barnjamin opened this issue Sep 6, 2021 · 2 comments · Fixed by #115

Comments

@barnjamin
Copy link
Contributor

barnjamin commented Sep 6, 2021

Problem

I'd like to be able to reference the elements of the Txn.application_args array dynamically using the looping construct with ScratchVars. Currently this is not supported but I see support is available in the Gtxn array.

example of what I'd like to do:

def set_properties(acct, args, start):
    idx = ScratchVar()

    init = idx.store(Int(start))
    cond = idx.load()<args.length()
    step = idx.store(idx.load() + Int(2))

    return Seq([
        For(init, cond, step).Do(
            App.localPut(acct, args[idx.load()], args[idx.load() + Int(1)])
        ),
        Int(1)
    ])

This may be supported in some way but I can't seem to find it.

Solution

Accept the Union[int,Expr] in the Txn array items __getitem__ call

@barnjamin barnjamin added the new-feature-request Feature request that needs triage label Sep 6, 2021
@barnjamin
Copy link
Contributor Author

algorand/go-algorand#2847 this may be a prerequisite?

@jasonpaulos
Copy link
Contributor

jasonpaulos commented Sep 8, 2021

This will be added for TEAL 5. We will also support dynamically getting arguments with Arg for LogicSigs.

@jasonpaulos jasonpaulos added Team Scytale and removed new-feature-request Feature request that needs triage labels Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants