-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Export all events #10996
Export all events #10996
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -220,9 +220,9 @@ vector<EventDefinition const*> const& ContractDefinition::definedInterfaceEvents | |
/// 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(); | ||
FunctionType const* functionType = e->functionType(true); | ||
solAssert(functionType, ""); | ||
string eventSignature = functionType->externalSignature(); | ||
if (eventsSeen.count(eventSignature) == 0) | ||
{ | ||
eventsSeen.insert(eventSignature); | ||
|
@@ -243,6 +243,21 @@ vector<EventDefinition const*> const ContractDefinition::usedInterfaceEvents() c | |
); | ||
} | ||
|
||
vector<EventDefinition const*> ContractDefinition::interfaceEvents(bool _requireCallGraph) const | ||
{ | ||
set<EventDefinition const*, CompareByID> result; | ||
for (ContractDefinition const* contract: annotation().linearizedBaseContracts) | ||
result += contract->events(); | ||
solAssert(annotation().creationCallGraph.set() == annotation().deployedCallGraph.set()); | ||
if (_requireCallGraph) | ||
solAssert(annotation().creationCallGraph.set()); | ||
if (annotation().creationCallGraph.set()) | ||
result += usedInterfaceEvents(); | ||
// We could filter out all events that do not have an external interface | ||
// if _requireCallGraph is false. | ||
Comment on lines
+256
to
+257
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand this comment. My best guess is that it refers to events that are not a part of the external interface of the contract. Is that correct? BTW, is this a TODO note? If so, any reason not to do this right away? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this was meant to filter out events whose arguments have types that are not valid in an external interface. Maybe I was thinking about errors at that point? Because for events this is not really possible while for errors it might. |
||
return util::convertContainer<vector<EventDefinition const*>>(std::move(result)); | ||
} | ||
|
||
vector<ErrorDefinition const*> ContractDefinition::interfaceErrors(bool _requireCallGraph) const | ||
{ | ||
set<ErrorDefinition const*, CompareByID> result; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--abi --pretty-json --json-indent 4 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity >=0.0; | ||
library L { | ||
event e1(uint b); | ||
} | ||
|
||
function f() { | ||
emit L.e1(5); | ||
} | ||
|
||
contract C { | ||
event e1(uint indexed a); | ||
function g() public { | ||
f(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
|
||
======= events_in_abi/input.sol:C ======= | ||
Contract JSON ABI | ||
[ | ||
{ | ||
"anonymous": false, | ||
"inputs": | ||
[ | ||
{ | ||
"indexed": false, | ||
"internalType": "uint256", | ||
"name": "b", | ||
"type": "uint256" | ||
} | ||
], | ||
"name": "e1", | ||
"type": "event" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": | ||
[ | ||
{ | ||
"indexed": true, | ||
"internalType": "uint256", | ||
"name": "a", | ||
"type": "uint256" | ||
} | ||
], | ||
"name": "e1", | ||
"type": "event" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "g", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
} | ||
] | ||
|
||
======= events_in_abi/input.sol:L ======= | ||
Contract JSON ABI | ||
[ | ||
{ | ||
"anonymous": false, | ||
"inputs": | ||
[ | ||
{ | ||
"indexed": false, | ||
"internalType": "uint256", | ||
"name": "b", | ||
"type": "uint256" | ||
} | ||
], | ||
"name": "e1", | ||
"type": "event" | ||
} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
library L { event E(uint8); } | ||
|
||
contract B { | ||
constructor() { | ||
emit L.E(0); | ||
} | ||
} | ||
|
||
contract C is B {} | ||
|
||
// ---- | ||
// :B | ||
// [ | ||
// { | ||
// "inputs": [], | ||
// "stateMutability": "nonpayable", | ||
// "type": "constructor" | ||
// }, | ||
// { | ||
// "anonymous": false, | ||
// "inputs": | ||
// [ | ||
// { | ||
// "indexed": false, | ||
// "internalType": "uint8", | ||
// "name": "", | ||
// "type": "uint8" | ||
// } | ||
// ], | ||
// "name": "E", | ||
// "type": "event" | ||
// } | ||
// ] | ||
// | ||
// | ||
// :C | ||
// [ | ||
// { | ||
// "anonymous": false, | ||
// "inputs": | ||
// [ | ||
// { | ||
// "indexed": false, | ||
// "internalType": "uint8", | ||
// "name": "", | ||
// "type": "uint8" | ||
// } | ||
// ], | ||
// "name": "E", | ||
// "type": "event" | ||
// } | ||
// ] | ||
// | ||
// | ||
// :L | ||
// [ | ||
// { | ||
// "anonymous": false, | ||
// "inputs": | ||
// [ | ||
// { | ||
// "indexed": false, | ||
// "internalType": "uint8", | ||
// "name": "", | ||
// "type": "uint8" | ||
// } | ||
// ], | ||
// "name": "E", | ||
// "type": "event" | ||
// } | ||
// ] |
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.
Why is this line showing up in the diff by the way? Not sure if I'm blind, but I don't see any change in it...
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.
Capitalized
A
inAdd
at the beginning of the sentence... had to look a dozen of times to spot it :)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.
Haha, lol - but that's also a bug in github - it usually highlights the actual change, here it doesn't :-)