-
Notifications
You must be signed in to change notification settings - Fork 187
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
Set function access in Json ABI based on presence of ctx and self parameter #783
Conversation
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.
mut
would be launched soon. So I think it'd be better to finish the PR after its deployment.
crates/abi/src/function.rs
Outdated
has_self: bool, | ||
has_ctx: bool, |
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.
It's better to take simply state_mutability
instead of introducing Fe-specific concepts like self
and ctx
to avoid unnecessary tight coupling with Fe language specification.
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.
mut
would be launched soon. So I think it'd be better to finish the PR after its deployment.
Okay. I got it!
"soon" has finally come, a couple months late 😅. I didn't update the json abi in the |
Thanks ~~. I will update it on my PR! |
Sorry @vuvoth, I just removed CtxDecl because it seemed pointless. Didn't mean to make extra work for you 😬 |
No problem! |
crates/abi/src/function.rs
Outdated
// |none self | self | mut self | | ||
// | none ctx | pure | view | payable/nonpayable | | ||
// | ctx | view | view | payable/nonpayable | | ||
// | mut ctx | payable/nopayable | view | payable/nonpayable | |
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.
@cburgdorf mut ctx
+ self
should be payable/nonpayable
, right?
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.
Yes, as soon as we have mut
in a public contract function, then it needs to be payable
(we don't have nonpayable
)
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.
I think more sense if we only allow mut ctx
follow after mut self
because we want to modify
something and this should be payable/nopayable
.
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.
These are two different things. You can take self
non mutable but take mut ctx
because e.g. you want to emit an event. So you aren't changing any storage of the contract but you are still making changes to the blockchain. In terms of the ABI both of these should be marked as payable
. There's a longer form write-up of the different access classes under that scheme: #558
@vuvoth I pushed a commit to your branch, changing the |
CI book fails because the request to |
What was wrong?
Resolve #678
How was it fixed?
To-Do
OPTIONAL: Update Spec if applicable
Add entry to the release notes (may forgo for trivial changes)
Clean up commit history