-
Notifications
You must be signed in to change notification settings - Fork 140
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
Allow scripts to access authorized accounts #1240
Conversation
Cadence Benchstat comparisonThis branch with compared with the base branch onflow:master commit ad6895c Results
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exciting! 🎉 🥳
Codecov Report
@@ Coverage Diff @@
## master #1240 +/- ##
==========================================
+ Coverage 77.59% 77.61% +0.01%
==========================================
Files 274 274
Lines 35232 35260 +28
==========================================
+ Hits 27339 27367 +28
Misses 6806 6806
Partials 1087 1087
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
Why not extend |
Co-authored-by: Bastian Müller <[email protected]>
Having the same type mean different things in different contexts is confusing; we don't want to change what a |
I know it is already merged, but here is my 2 cents. This is the diff of AuthAccount from PublicAccount:
Below is the function that makes sense in script ( read only ): (considering getCapability is useless)
technically load and copy are same (in script context) borrow is useless when you have load. So we end up with:
In my opinion exposing 14 functions where in reality 1 is needed outweights the benefit. Also instead of
But I think it would also make sense to just put |
@bluesign The difference between a transaction context and a script context is that in a transaction context state changes are written, and in the script context the changes are ignored. It is much simpler for the implementation to behave exactly the same in both contexts and I would assume that it is also the same for developers/users. I don't really think that changing the definitions and APIs (e.g. adding new / removing existing functions) is worth it. Having the existing definitions behave the same in a scripting context as in a transaction context is also useful for future features like testing, where you might want to perform state-changing actions, but are not interested in the state changes being applied. If the API were reduced to just a "read-only" API it would be limiting for some actions you might want to perform. |
Oh thats exactly the point that I missed, I now see how this can be a powerful feature. Thanks for the clarification. |
Any eta on this to be included in Cadence ? |
This will be out in Secure Cadence I believe |
Closes #539
Description
Because scripts discard their changes upon completion, there is no harm in allowing them to access
AuthAccount
s. This adds a function:That loads an
AuthAccount
in the same way thatgetAccount
loads aPublicAccount
. This is only available in scripts; trying to use this function outside of a script will cause an error in the checker.master
branchFiles changed
in the Github PR explorer