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

Scripts should have access to authorized accounts #539

Closed
turbolent opened this issue Jan 19, 2021 · 3 comments · Fixed by #1240
Closed

Scripts should have access to authorized accounts #539

turbolent opened this issue Jan 19, 2021 · 3 comments · Fixed by #1240
Assignees

Comments

@turbolent
Copy link
Member

turbolent commented Jan 19, 2021

Issue To Be Solved

It is currently not possible to query account storage of accounts, as scripts do not have access to authorized accounts.

Suggested Solution

  • Add a global function fun getAuthAccount(_ address: Address): AuthAccount,
    which returns an authorized account for a given address,
    to scripts, but not transactions!
@rheaplex
Copy link
Contributor

We currently handle this by ensuring that data that would otherwise require authorized access can be accessed in a non-privileged way (and without trying to return a resource...). For more complex queries we use a method that copies the needed results into a struct. This has the advantage of working in a transaction as well. It has the disadvantage of being more complex.

@rheaplex
Copy link
Contributor

What happens when the script calls functions that attempt to update storage? Should this revert, should it be simulated, or should there be a keyword for script-safe functions? I'm trying to avoid accidentally introducing const... :-)

@turbolent
Copy link
Member Author

Yeah, this issue originated from the feedback on how complicated (or even impossible) is is to read account storage currently. It really shouldn't be necessary to write boilerplate (e.g. add read capabilities or copy data).

What happens when the script calls functions that attempt to update storage?

No, currently scripts don't revert if they mutate state, as this is way too common. If they do, the state changes are simply ignored at the end of the script, and I think we can keep this behavior.

@turbolent turbolent removed their assignment Oct 28, 2021
@dsainati1 dsainati1 self-assigned this Nov 15, 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.

3 participants