-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Add statemutability field to ABI #2732
Conversation
Changelog.md
Outdated
@@ -1,6 +1,7 @@ | |||
### 0.4.16 (unreleased) | |||
|
|||
Features: | |||
* ABI: Include new field ``statemutability`` with values ``view``, ``nonpayable`` and ``payable``. |
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.
More specifically: json-ABI. Also, why is pure
not a valid option? Should we name it stateaccess
? Or stateaccessrestrictions
?
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.
Argh, sorry, of course because pure
is not yet part of this PR...
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.
Going to add pure
in a separate PR.
libsolidity/ast/ASTEnums.h
Outdated
// How a function can mutate the EVM state. | ||
enum class StateMutability { View, NonPayable, Payable }; | ||
|
||
inline std::string stateMutabilityToString(StateMutability const& _stateMutability) |
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.
C++ has nicely-usable overloads, we can call this just toString
.
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 this part of the review belongs to #2722.
libsolidity/ast/Types.h
Outdated
@@ -985,6 +982,7 @@ class FunctionType: public Type | |||
/// @returns true if the ABI is used for this call (only meaningful for external calls) | |||
bool isBareCall() const; | |||
Kind const& kind() const { return m_kind; } | |||
StateMutability const& stateMutability() const { return m_stateMutability; } |
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 is probably better to return by value.
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.
Addressed this in the real PR.
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.
Only minor requests, can also be merged as is, if needed.
b9db2ef
to
db10c9f
Compare
Need to update tests. |
c0baac5
to
3cbf446
Compare
test/libsolidity/SolidityABIJSON.cpp
Outdated
@@ -548,12 +561,44 @@ BOOST_AUTO_TEST_CASE(constructor_abi) | |||
} | |||
], | |||
"payable": false, | |||
"statemutability" :"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.
Wrong space around colon.
test/libsolidity/SolidityABIJSON.cpp
Outdated
} | ||
], | ||
"payable": true, | ||
"statemutability" :"payable", |
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.
Wrong space around colon.
3cbf446
to
557e379
Compare
@chriseth ready to merge |
8b1efdd
to
56a7881
Compare
56a7881
to
1f5ab60
Compare
@chriseth check this? :) |
Depends on #2722. Part of #992.