Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Features:
* Introduce ``pure`` functions. The pureness is not enforced yet, use with care.
* ABI JSON: Include new field ``statemutability`` with values ``pure``, ``view``, ``nonpayable`` and ``payable``.
* ABI JSON: Include new field ``stateMutability`` with values ``pure``, ``view``, ``nonpayable`` and ``payable``.
* Analyzer: Experimental partial support for Z3 SMT checker.
* Parser: Display previous visibility specifier in error if multiple are found.
* Parser: Introduce ``view`` keyword on functions (``constant`` remains an alias for ``view``).
Expand Down
2 changes: 1 addition & 1 deletion docs/abi-spec.rst
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ The JSON format for a contract's interface is given by an array of function and/
- `outputs`: an array of objects similar to `inputs`, can be omitted if function doesn't return anything;
- `constant`: `true` if function is :ref:`specified to not modify blockchain state <view-functions>`);
- `payable`: `true` if function accepts ether, defaults to `false`;
- `statemutability`: a string with one of the following values: `pure` (:ref:`specified to not read blockchain state <pure-functions>`), `view` (same as `constant` above), `nonpayable` and `payable` (same as `payable` above).
- `stateMutability`: a string with one of the following values: `pure` (:ref:`specified to not read blockchain state <pure-functions>`), `view` (same as `constant` above), `nonpayable` and `payable` (same as `payable` above).

`type` can be omitted, defaulting to `"function"`.

Expand Down
4 changes: 2 additions & 2 deletions libsolidity/ast/ASTJsonConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ bool ASTJsonConverter::visit(FunctionDefinition const& _node)
// FIXME: remove with next breaking release
make_pair(m_legacy ? "constant" : "isDeclaredConst", _node.stateMutability() <= StateMutability::View),
make_pair("payable", _node.isPayable()),
make_pair("statemutability", stateMutabilityToString(_node.stateMutability())),
make_pair("stateMutability", stateMutabilityToString(_node.stateMutability())),
make_pair("visibility", Declaration::visibilityToString(_node.visibility())),
make_pair("parameters", toJson(_node.parameterList())),
make_pair("isConstructor", _node.isConstructor()),
Expand Down Expand Up @@ -416,7 +416,7 @@ bool ASTJsonConverter::visit(FunctionTypeName const& _node)
setJsonNode(_node, "FunctionTypeName", {
make_pair("payable", _node.isPayable()),
make_pair("visibility", Declaration::visibilityToString(_node.visibility())),
make_pair("statemutability", stateMutabilityToString(_node.stateMutability())),
make_pair("stateMutability", stateMutabilityToString(_node.stateMutability())),
// FIXME: remove with next breaking release
make_pair(m_legacy ? "constant" : "isDeclaredConst", _node.stateMutability() <= StateMutability::View),
make_pair("parameterTypes", toJson(*_node.parameterTypeList())),
Expand Down
6 changes: 3 additions & 3 deletions libsolidity/interface/ABI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Json::Value ABI::generate(ContractDefinition const& _contractDef)
// TODO: deprecate constant in a future release
method["constant"] = it.second->stateMutability() == StateMutability::Pure || it.second->stateMutability() == StateMutability::View;
method["payable"] = it.second->isPayable();
method["statemutability"] = stateMutabilityToString(it.second->stateMutability());
method["stateMutability"] = stateMutabilityToString(it.second->stateMutability());
method["inputs"] = formatTypeList(
externalFunctionType->parameterNames(),
externalFunctionType->parameterTypes(),
Expand All @@ -58,7 +58,7 @@ Json::Value ABI::generate(ContractDefinition const& _contractDef)
auto externalFunction = FunctionType(*_contractDef.constructor(), false).interfaceFunctionType();
solAssert(!!externalFunction, "");
method["payable"] = externalFunction->isPayable();
method["statemutability"] = stateMutabilityToString(externalFunction->stateMutability());
method["stateMutability"] = stateMutabilityToString(externalFunction->stateMutability());
method["inputs"] = formatTypeList(
externalFunction->parameterNames(),
externalFunction->parameterTypes(),
Expand All @@ -73,7 +73,7 @@ Json::Value ABI::generate(ContractDefinition const& _contractDef)
Json::Value method;
method["type"] = "fallback";
method["payable"] = externalFunctionType->isPayable();
method["statemutability"] = stateMutabilityToString(externalFunctionType->stateMutability());
method["stateMutability"] = stateMutabilityToString(externalFunctionType->stateMutability());
abi.append(method);
}
for (auto const& it: _contractDef.interfaceEvents())
Expand Down
56 changes: 28 additions & 28 deletions test/libsolidity/SolidityABIJSON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ BOOST_AUTO_TEST_CASE(basic_test)
"name": "f",
"constant": false,
"payable" : false,
"statemutability": "nonpayable",
"stateMutability": "nonpayable",
"type": "function",
"inputs": [
{
Expand Down Expand Up @@ -120,7 +120,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods)
"name": "f",
"constant": false,
"payable" : false,
"statemutability": "nonpayable",
"stateMutability": "nonpayable",
"type": "function",
"inputs": [
{
Expand All @@ -139,7 +139,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods)
"name": "g",
"constant": false,
"payable" : false,
"statemutability": "nonpayable",
"stateMutability": "nonpayable",
"type": "function",
"inputs": [
{
Expand Down Expand Up @@ -172,7 +172,7 @@ BOOST_AUTO_TEST_CASE(multiple_params)
"name": "f",
"constant": false,
"payable" : false,
"statemutability": "nonpayable",
"stateMutability": "nonpayable",
"type": "function",
"inputs": [
{
Expand Down Expand Up @@ -211,7 +211,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods_order)
"name": "c",
"constant": false,
"payable" : false,
"statemutability": "nonpayable",
"stateMutability": "nonpayable",
"type": "function",
"inputs": [
{
Expand All @@ -230,7 +230,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods_order)
"name": "f",
"constant": false,
"payable" : false,
"statemutability": "nonpayable",
"stateMutability": "nonpayable",
"type": "function",
"inputs": [
{
Expand Down Expand Up @@ -264,7 +264,7 @@ BOOST_AUTO_TEST_CASE(view_function)
"name": "foo",
"constant": false,
"payable" : false,
"statemutability": "nonpayable",
"stateMutability": "nonpayable",
"type": "function",
"inputs": [
{
Expand All @@ -287,7 +287,7 @@ BOOST_AUTO_TEST_CASE(view_function)
"name": "boo",
"constant": true,
"payable" : false,
"statemutability": "view",
"stateMutability": "view",
"type": "function",
"inputs": [{
"name": "a",
Expand Down Expand Up @@ -320,7 +320,7 @@ BOOST_AUTO_TEST_CASE(constant_function)
"name": "foo",
"constant": false,
"payable" : false,
"statemutability": "nonpayable",
"stateMutability": "nonpayable",
"type": "function",
"inputs": [
{
Expand All @@ -343,7 +343,7 @@ BOOST_AUTO_TEST_CASE(constant_function)
"name": "boo",
"constant": true,
"payable" : false,
"statemutability": "view",
"stateMutability": "view",
"type": "function",
"inputs": [{
"name": "a",
Expand Down Expand Up @@ -375,7 +375,7 @@ BOOST_AUTO_TEST_CASE(pure_function)
"name": "foo",
"constant": false,
"payable" : false,
"statemutability": "nonpayable",
"stateMutability": "nonpayable",
"type": "function",
"inputs": [
{
Expand All @@ -398,7 +398,7 @@ BOOST_AUTO_TEST_CASE(pure_function)
"name": "boo",
"constant": true,
"payable" : false,
"statemutability": "pure",
"stateMutability": "pure",
"type": "function",
"inputs": [{
"name": "a",
Expand Down Expand Up @@ -430,7 +430,7 @@ BOOST_AUTO_TEST_CASE(events)
"name": "f",
"constant": false,
"payable" : false,
"statemutability": "nonpayable",
"stateMutability": "nonpayable",
"type": "function",
"inputs": [
{
Expand Down Expand Up @@ -512,7 +512,7 @@ BOOST_AUTO_TEST_CASE(inherited)
"name": "baseFunction",
"constant": false,
"payable" : false,
"statemutability": "nonpayable",
"stateMutability": "nonpayable",
"type": "function",
"inputs":
[{
Expand All @@ -529,7 +529,7 @@ BOOST_AUTO_TEST_CASE(inherited)
"name": "derivedFunction",
"constant": false,
"payable" : false,
"statemutability": "nonpayable",
"stateMutability": "nonpayable",
"type": "function",
"inputs":
[{
Expand Down Expand Up @@ -585,7 +585,7 @@ BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one)
"name": "f",
"constant": false,
"payable" : false,
"statemutability": "nonpayable",
"stateMutability": "nonpayable",
"type": "function",
"inputs": [
{
Expand Down Expand Up @@ -628,7 +628,7 @@ BOOST_AUTO_TEST_CASE(empty_name_return_parameter)
"name": "f",
"constant": false,
"payable" : false,
"statemutability": "nonpayable",
"stateMutability": "nonpayable",
"type": "function",
"inputs": [
{
Expand Down Expand Up @@ -672,7 +672,7 @@ BOOST_AUTO_TEST_CASE(constructor_abi)
}
],
"payable": false,
"statemutability": "nonpayable",
"stateMutability": "nonpayable",
"type": "constructor"
}
])";
Expand Down Expand Up @@ -704,7 +704,7 @@ BOOST_AUTO_TEST_CASE(payable_constructor_abi)
}
],
"payable": true,
"statemutability": "payable",
"stateMutability": "payable",
"type": "constructor"
}
])";
Expand All @@ -730,7 +730,7 @@ BOOST_AUTO_TEST_CASE(return_param_in_abi)
{
"constant" : false,
"payable" : false,
"statemutability": "nonpayable",
"stateMutability": "nonpayable",
"inputs" : [],
"name" : "ret",
"outputs" : [
Expand All @@ -749,7 +749,7 @@ BOOST_AUTO_TEST_CASE(return_param_in_abi)
}
],
"payable": false,
"statemutability": "nonpayable",
"stateMutability": "nonpayable",
"type": "constructor"
}
]
Expand All @@ -771,7 +771,7 @@ BOOST_AUTO_TEST_CASE(strings_and_arrays)
{
"constant" : false,
"payable" : false,
"statemutability": "nonpayable",
"stateMutability": "nonpayable",
"name": "f",
"inputs": [
{ "name": "a", "type": "string" },
Expand Down Expand Up @@ -800,7 +800,7 @@ BOOST_AUTO_TEST_CASE(library_function)
{
"constant" : false,
"payable" : false,
"statemutability": "nonpayable",
"stateMutability": "nonpayable",
"name": "f",
"inputs": [
{ "name": "b", "type": "test.StructType storage" },
Expand Down Expand Up @@ -830,7 +830,7 @@ BOOST_AUTO_TEST_CASE(include_fallback_function)
[
{
"payable": false,
"statemutability": "nonpayable",
"stateMutability": "nonpayable",
"type" : "fallback"
}
]
Expand All @@ -852,7 +852,7 @@ BOOST_AUTO_TEST_CASE(payable_function)
{
"constant" : false,
"payable": false,
"statemutability": "nonpayable",
"stateMutability": "nonpayable",
"inputs": [],
"name": "f",
"outputs": [],
Expand All @@ -861,7 +861,7 @@ BOOST_AUTO_TEST_CASE(payable_function)
{
"constant" : false,
"payable": true,
"statemutability": "payable",
"stateMutability": "payable",
"inputs": [],
"name": "g",
"outputs": [],
Expand All @@ -884,7 +884,7 @@ BOOST_AUTO_TEST_CASE(payable_fallback_function)
[
{
"payable": true,
"statemutability": "payable",
"stateMutability": "payable",
"type" : "fallback"
}
]
Expand All @@ -905,7 +905,7 @@ BOOST_AUTO_TEST_CASE(function_type)
{
"constant" : false,
"payable": false,
"statemutability": "nonpayable",
"stateMutability": "nonpayable",
"inputs": [{
"name": "x",
"type": "function"
Expand Down