From 7cb944c9037d065632a37b48bb91982c2235694d Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Tue, 17 Mar 2015 11:34:56 +0100 Subject: [PATCH] added anonymous to ABI --- libsolidity/AST.h | 2 +- libsolidity/ExpressionCompiler.cpp | 2 +- libsolidity/InterfaceHandler.cpp | 2 +- test/SolidityABIJSON.cpp | 21 +++++++++++++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/libsolidity/AST.h b/libsolidity/AST.h index 5564d83db..37ddc657e 100644 --- a/libsolidity/AST.h +++ b/libsolidity/AST.h @@ -570,7 +570,7 @@ public: std::vector> const& getParameters() const { return m_parameters->getParameters(); } ParameterList const& getParameterList() const { return *m_parameters; } - bool IsAnonymous() const { return m_anonymous; } + bool isAnonymous() const { return m_anonymous; } virtual TypePointer getType(ContractDefinition const* = nullptr) const override { diff --git a/libsolidity/ExpressionCompiler.cpp b/libsolidity/ExpressionCompiler.cpp index bff27e9c7..61b17f663 100644 --- a/libsolidity/ExpressionCompiler.cpp +++ b/libsolidity/ExpressionCompiler.cpp @@ -542,7 +542,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) appendTypeConversion(*arguments[arg - 1]->getType(), *function.getParameterTypes()[arg - 1], true); } - if (!event.IsAnonymous()) + if (!event.isAnonymous()) { m_context << u256(h256::Arith(dev::sha3(function.getCanonicalSignature(event.getName())))); ++numIndexed; diff --git a/libsolidity/InterfaceHandler.cpp b/libsolidity/InterfaceHandler.cpp index 2b855e243..406d1e24a 100644 --- a/libsolidity/InterfaceHandler.cpp +++ b/libsolidity/InterfaceHandler.cpp @@ -70,7 +70,7 @@ std::unique_ptr InterfaceHandler::getABIInterface(ContractDefinitio Json::Value event; event["type"] = "event"; event["name"] = it->getName(); - //todo add anonymous!; + event["anonymous"] = it->isAnonymous(); Json::Value params(Json::arrayValue); for (auto const& p: it->getParameters()) { diff --git a/test/SolidityABIJSON.cpp b/test/SolidityABIJSON.cpp index 195270138..f7f968ea8 100644 --- a/test/SolidityABIJSON.cpp +++ b/test/SolidityABIJSON.cpp @@ -309,6 +309,7 @@ BOOST_AUTO_TEST_CASE(events) { "name": "e1", "type": "event", + "anonymous": false, "inputs": [ { "indexed": false, @@ -325,6 +326,7 @@ BOOST_AUTO_TEST_CASE(events) { "name": "e2", "type": "event", + "anonymous": false, "inputs": [] } @@ -333,6 +335,23 @@ BOOST_AUTO_TEST_CASE(events) checkInterface(sourceCode, interface); } +BOOST_AUTO_TEST_CASE(events_anonymous) +{ + char const* sourceCode = "contract test {\n" + " event e() anonymous; \n" + "}\n"; + char const* interface = R"([ + { + "name": "e", + "type": "event", + "anonymous": true, + "inputs": [] + } + + ])"; + + checkInterface(sourceCode, interface); +} BOOST_AUTO_TEST_CASE(inherited) { @@ -380,6 +399,7 @@ BOOST_AUTO_TEST_CASE(inherited) { "name": "derivedEvent", "type": "event", + "anonymous": false, "inputs": [{ "indexed": true, @@ -390,6 +410,7 @@ BOOST_AUTO_TEST_CASE(inherited) { "name": "baseEvent", "type": "event", + "anonymous": false, "inputs": [{ "indexed": true,