diff options
author | chriseth <chris@ethereum.org> | 2016-08-30 21:21:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-30 21:21:19 +0800 |
commit | cf974fd103dbb56313eee40ce9ffe4d03d6c1b04 (patch) | |
tree | 8fd3ec7a2fa41ffdd5f0442b78e34b0204f6ef46 | |
parent | 29b8965b9541e75905bb688954649ee7b0b0fefc (diff) | |
parent | 4019c832cad989ddb246d2189d19f38273d29661 (diff) | |
download | dexon-solidity-cf974fd103dbb56313eee40ce9ffe4d03d6c1b04.tar dexon-solidity-cf974fd103dbb56313eee40ce9ffe4d03d6c1b04.tar.gz dexon-solidity-cf974fd103dbb56313eee40ce9ffe4d03d6c1b04.tar.bz2 dexon-solidity-cf974fd103dbb56313eee40ce9ffe4d03d6c1b04.tar.lz dexon-solidity-cf974fd103dbb56313eee40ce9ffe4d03d6c1b04.tar.xz dexon-solidity-cf974fd103dbb56313eee40ce9ffe4d03d6c1b04.tar.zst dexon-solidity-cf974fd103dbb56313eee40ce9ffe4d03d6c1b04.zip |
Merge pull request #664 from axic/feature/interface-fallback
Introduce fallback entry in the ABI
-rw-r--r-- | libsolidity/interface/InterfaceHandler.cpp | 10 | ||||
-rw-r--r-- | test/libsolidity/SolidityABIJSON.cpp | 28 |
2 files changed, 28 insertions, 10 deletions
diff --git a/libsolidity/interface/InterfaceHandler.cpp b/libsolidity/interface/InterfaceHandler.cpp index f5c10356..5d24e1bf 100644 --- a/libsolidity/interface/InterfaceHandler.cpp +++ b/libsolidity/interface/InterfaceHandler.cpp @@ -74,7 +74,15 @@ string InterfaceHandler::abiInterface(ContractDefinition const& _contractDef) ); abi.append(method); } - + if (_contractDef.fallbackFunction()) + { + auto externalFunctionType = FunctionType(*_contractDef.fallbackFunction()).interfaceFunctionType(); + solAssert(!!externalFunctionType, ""); + Json::Value method; + method["type"] = "fallback"; + method["constant"] = externalFunctionType->isConstant(); + abi.append(method); + } for (auto const& it: _contractDef.interfaceEvents()) { Json::Value event; diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp index b21e03eb..cfc7b9bd 100644 --- a/test/libsolidity/SolidityABIJSON.cpp +++ b/test/libsolidity/SolidityABIJSON.cpp @@ -273,15 +273,6 @@ BOOST_AUTO_TEST_CASE(const_function) checkInterface(sourceCode, interface); } -BOOST_AUTO_TEST_CASE(exclude_fallback_function) -{ - char const* sourceCode = "contract test { function() {} }"; - - char const* interface = "[]"; - - checkInterface(sourceCode, interface); -} - BOOST_AUTO_TEST_CASE(events) { char const* sourceCode = "contract test {\n" @@ -626,6 +617,25 @@ BOOST_AUTO_TEST_CASE(library_function) checkInterface(sourceCode, interface); } +BOOST_AUTO_TEST_CASE(include_fallback_function) +{ + char const* sourceCode = R"( + contract test { + function() {} + } + )"; + + char const* interface = R"( + [ + { + "constant" : false, + "type" : "fallback" + } + ] + )"; + checkInterface(sourceCode, interface); +} + BOOST_AUTO_TEST_SUITE_END() } |