Ejemplo n.º 1
0
def get_topics(abi):
    new_topics = _topics.copy()
    new_topics.update(eth_event.get_event_abi(abi))
    if new_topics != _topics:
        _topics.update(new_topics)
        with _get_path().open('w') as fp:
            json.dump(new_topics, fp, sort_keys=True, indent=2)
    return eth_event.get_topics(abi)
Ejemplo n.º 2
0
def topics():
    '''Generates event topics and saves them in brownie/topics.json'''
    if _topics:
        return _topics
    try:
        topics = json.load(open(
            CONFIG['folders']['brownie']+"/topics.json",
            encoding="utf-8"
        ))
    except (FileNotFoundError, json.decoder.JSONDecodeError):
        topics = {}
    contracts = compile_contracts()
    events = [x for i in contracts.values() for x in i['abi'] if x['type']=="event"]
    _topics.update(eth_event.get_event_abi(events))
    json.dump(
        _topics,
        open(CONFIG['folders']['brownie']+"/topics.json", 'w', encoding="utf-8"),
        sort_keys=True,
        indent=4
    )
    return _topics