2018-08-22 11:48:32 +00:00
|
|
|
# generated from tokens.py.mako
|
|
|
|
# do not edit manually!
|
2019-05-22 13:06:23 +00:00
|
|
|
# flake8: noqa
|
|
|
|
# fmt: off
|
2019-05-20 13:51:30 +00:00
|
|
|
<%
|
|
|
|
from collections import defaultdict
|
2018-08-22 11:48:32 +00:00
|
|
|
|
2019-05-20 13:51:30 +00:00
|
|
|
def group_tokens(tokens):
|
|
|
|
r = defaultdict(list)
|
2019-05-20 16:04:12 +00:00
|
|
|
for t in sorted(tokens, key=lambda t: t.chain_id):
|
2019-05-20 13:51:30 +00:00
|
|
|
r[t.chain_id].append(t)
|
|
|
|
return r
|
2019-05-22 13:06:23 +00:00
|
|
|
%>\
|
2018-08-22 11:48:32 +00:00
|
|
|
|
|
|
|
UNKNOWN_TOKEN = (None, None, None, None)
|
|
|
|
|
|
|
|
|
2019-05-20 13:51:30 +00:00
|
|
|
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)}:
|
2019-05-20 16:04:12 +00:00
|
|
|
return (chain_id, address, ${black_repr(t.symbol)}, ${t.decimals}) # ${t.chain} / ${t.name.strip()}
|
2019-05-20 13:51:30 +00:00
|
|
|
% endfor
|
2018-08-22 11:48:32 +00:00
|
|
|
% endfor
|
2019-05-20 13:51:30 +00:00
|
|
|
return UNKNOWN_TOKEN
|