コード例 #1
0
ファイル: event.py プロジェクト: tangy-ong/brownie
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)
コード例 #2
0
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)
コード例 #3
0
ファイル: event.py プロジェクト: thebureaugroup/brownie
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)
コード例 #4
0
ファイル: event.py プロジェクト: tbrent/brownie
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)
コード例 #5
0
ファイル: event.py プロジェクト: thebureaugroup/brownie
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)
コード例 #6
0
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)
コード例 #7
0
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]
コード例 #8
0
ファイル: event.py プロジェクト: tbrent/brownie
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)
コード例 #9
0
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)