def _decode_logs(logs: List) -> EventDict: if not logs: return EventDict() idx = 0 events: List = [] while True: address = logs[idx]["address"] try: new_idx = logs.index( next(i for i in logs[idx:] if i["address"] != address)) log_slice = logs[idx:new_idx] idx = new_idx except StopIteration: log_slice = logs[idx:] topics_map = _deployment_topics.get(address, _topics) for item in log_slice: try: events.extend( eth_event.decode_logs([item], topics_map, allow_undecoded=True)) except EventError as exc: warnings.warn(str(exc)) if log_slice[-1] == logs[-1]: break events = [format_event(i) for i in events] return EventDict(events)
def _decode_logs(logs: List) -> Union["EventDict", List[None]]: if not logs: return [] idx = 0 events: List = [] while True: address = logs[idx]["address"] try: new_idx = logs.index( next(i for i in logs[idx:] if i["address"] != address)) log_slice = logs[idx:new_idx] idx = new_idx except StopIteration: log_slice = logs[idx:] topics_map = _deployment_topics.get(address, _topics) events.extend( eth_event.decode_logs(log_slice, topics_map, allow_undecoded=True)) if log_slice[-1] == logs[-1]: break events = [format_event(i) for i in events] return EventDict(events)
def _decode_logs(logs: List, contracts: Optional[Dict] = None) -> EventDict: if not logs: return EventDict() idx = 0 events: List = [] while True: address = logs[idx]["address"] try: new_idx = logs.index(next(i for i in logs[idx:] if i["address"] != address)) log_slice = logs[idx:new_idx] idx = new_idx except StopIteration: log_slice = logs[idx:] topics_map = _deployment_topics.get(address, _topics) for item in log_slice: if contracts and contracts[item.address]: note = _decode_ds_note(item, contracts[item.address]) if note: events.append(note) continue try: events.extend(eth_event.decode_logs([item], topics_map, allow_undecoded=True)) except EventError as exc: warnings.warn(f"{address}: {exc}") if log_slice[-1] == logs[-1]: break events = [format_event(i) for i in events] return EventDict(events)
def _decode_trace(trace: Sequence) -> Union["EventDict", List[None]]: if not trace: return [] events = eth_event.decode_traceTransaction(trace, _topics, allow_undecoded=True) events = [format_event(i) for i in events] return EventDict(events)
def _decode_trace(trace: Sequence, initial_address: str) -> EventDict: if not trace: return EventDict() events = eth_event.decode_traceTransaction( trace, _topics, allow_undecoded=True, initial_address=initial_address ) events = [format_event(i) for i in events] return EventDict(events)
def _decode_logs(logs: List) -> Union["EventDict", List[None]]: if not logs: return [] events: List = [] for value in logs: try: events += eth_event.decode_logs([value], _topics) except KeyError: pass events = [format_event(i) for i in events] return EventDict(events)
def decode_log(tx, contract, event_name): """ Get transaction logs for specific event name :param tx: transaction object :param contract: Contract object :param event_name: name of the event :return: EventDict with the events parsed """ topic_map = eth_event.get_topic_map(contract.abi) logs = eth_event.decode_logs(tx.logs, topic_map, True) events = list(filter(lambda tx_: tx_['name'] == event_name, logs)) return EventDict([format_event(i) for i in events])[event_name]
def _decode_logs(logs: List) -> Union["EventDict", List[None]]: if not logs: return [] events = eth_event.decode_logs(logs, _topics, allow_undecoded=True) events = [format_event(i) for i in events] return EventDict(events)
def _decode_trace(trace: Sequence) -> Union["EventDict", List[None]]: if not trace: return [] events = eth_event.decode_trace(trace, _topics) events = [format_event(i) for i in events] return EventDict(events)