Skip to content

Commit

Permalink
Include all overloaded events in ABI
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Aug 28, 2017
1 parent 3d228e9 commit 0e11e5a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Features:
* Type Checker: Warn on using literals as tight packing parameters in ``keccak256``, ``sha3``, ``sha256`` and ``ripemd160``.

Bugfixes:
* ABI JSON: Include all overloaded events.
* Parser: Crash fix related to parseTypeName.


### 0.4.16 (2017-08-24)

Features:
Expand Down
12 changes: 10 additions & 2 deletions libsolidity/ast/AST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,19 @@ vector<EventDefinition const*> const& ContractDefinition::interfaceEvents() cons
m_interfaceEvents.reset(new vector<EventDefinition const*>());
for (ContractDefinition const* contract: annotation().linearizedBaseContracts)
for (EventDefinition const* e: contract->events())
if (eventsSeen.count(e->name()) == 0)
{
/// NOTE: this requires the "internal" version of an Event,
/// though here internal strictly refers to visibility,
/// and not to function encoding (jump vs. call)
auto const& function = e->functionType(true);
solAssert(function, "");
string eventSignature = function->externalSignature();
if (eventsSeen.count(eventSignature) == 0)
{
eventsSeen.insert(e->name());
eventsSeen.insert(eventSignature);
m_interfaceEvents->push_back(e);
}
}
}
return *m_interfaceEvents;
}
Expand Down
20 changes: 20 additions & 0 deletions test/libsolidity/SolidityABIJSON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,8 @@ BOOST_AUTO_TEST_CASE(events)
function f(uint a) returns(uint d) { return a * 7; }
event e1(uint b, address indexed c);
event e2();
event e2(uint a);
event e3() anonymous;
}
)";
char const* interface = R"([
Expand Down Expand Up @@ -467,6 +469,24 @@ BOOST_AUTO_TEST_CASE(events)
"type": "event",
"anonymous": false,
"inputs": []
},
{
"name": "e2",
"type": "event",
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "a",
"type": "uint256"
}
]
},
{
"name": "e3",
"type": "event",
"anonymous": true,
"inputs": []
}
])";
Expand Down

0 comments on commit 0e11e5a

Please sign in to comment.