1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-29 00:31:02 +00:00
trezor-firmware/core/src/apps/ethereum/tokens.py.mako
matejcik 984c6b6236 style: drop tokens.py from style checks
because pyflakes / stdlib's ast will exceed recursion depth
while analyzing the main function
2019-05-22 15:06:23 +02:00

31 lines
804 B
Mako

# generated from tokens.py.mako
# do not edit manually!
# flake8: noqa
# fmt: off
<%
from collections import defaultdict
def group_tokens(tokens):
r = defaultdict(list)
for t in sorted(tokens, key=lambda t: t.chain_id):
r[t.chain_id].append(t)
return r
%>\
UNKNOWN_TOKEN = (None, None, None, None)
def token_by_chain_address(chain_id, address):
if False:
pass
% for token_chain_id, tokens in group_tokens(supported_on("trezor2", erc20)).items():
elif chain_id == ${token_chain_id}:
if False:
pass
% for t in tokens:
elif address == ${black_repr(t.address_bytes)}:
return (chain_id, address, ${black_repr(t.symbol)}, ${t.decimals}) # ${t.chain} / ${t.name.strip()}
% endfor
% endfor
return UNKNOWN_TOKEN