Skip to content

Commit

Permalink
Merge pull request #919 from eth-brownie/feat-event-types
Browse files Browse the repository at this point in the history
Event return types and comparisons
  • Loading branch information
iamdefinitelyahuman authored Jan 4, 2021
2 parents 4b12faa + cf8290b commit e9f5360
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions brownie/network/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from eth_event import EventError

from brownie._config import _get_data_folder
from brownie.convert.datatypes import ReturnValue
from brownie.convert.normalize import format_event
from brownie.exceptions import EventLookupError

Expand Down Expand Up @@ -163,20 +164,23 @@ def __iter__(self) -> Iterator:

def __eq__(self, other: object) -> bool:
if len(self._ordered) == 1:
if isinstance(other, (tuple, list, ReturnValue)):
# sequences compare directly against the event values
return self._ordered[0].values() == other
return other == self._ordered[0]
return other == self._ordered

def items(self) -> List:
def items(self) -> ReturnValue:
"""_EventItem.items() -> a list object providing a view on _EventItem[0]'s items"""
return [(i, self[i]) for i in self.keys()]
return ReturnValue([(i, self[i]) for i in self.keys()])

def keys(self) -> List:
def keys(self) -> ReturnValue:
"""_EventItem.keys() -> a list object providing a view on _EventItem[0]'s keys"""
return [i.replace(" (indexed)", "") for i in self._ordered[0].keys()]
return ReturnValue([i.replace(" (indexed)", "") for i in self._ordered[0].keys()])

def values(self) -> List:
def values(self) -> ReturnValue:
"""_EventItem.values() -> a list object providing a view on _EventItem[0]'s values"""
return list(self._ordered[0].values())
return ReturnValue(self._ordered[0].values())


def __get_path() -> Path:
Expand Down

0 comments on commit e9f5360

Please sign in to comment.