-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set function access in Json ABI based on presence of ctx and self par…
…ameter (#783) Co-authored-by: Sean Billig <sean.billig@gmail.com>
- Loading branch information
Showing
8 changed files
with
160 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
When the Fe compiler generates a JSON ABI file for a contract, the | ||
"stateMutability" field for each function now reflects whether the function can | ||
read or modify chain or contract state, based on the presence or absence of the | ||
`self` and `ctx` parameters, and whether those parameters are `mut`able. | ||
|
||
If a function doesn't take `self` or `ctx`, it's "pure". | ||
If a function takes `self` or `ctx` immutably, it can read state but not mutate | ||
state, so it's a "view" | ||
If a function takes `mut self` or `mut ctx`, it can mutate state, and is thus | ||
marked "payable". | ||
|
||
Note that we're following the convention set by Solidity for this field, which | ||
isn't a perfect fit for Fe. The primary issue is that Fe doesn't currently | ||
distinguish between "payable" and "nonpayable" functions; if you want a function | ||
to revert when Eth is sent, you need to do it manually | ||
(eg `assert ctx.msg_value() == 0`). |