1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-24 23:38:09 +00:00

core/ethereum: simplify code for token list

This commit is contained in:
Pavol Rusnak 2019-05-20 18:04:12 +02:00
parent d56de2c5fe
commit 60d1460185
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 1175 additions and 1176 deletions

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@ from collections import defaultdict
def group_tokens(tokens): def group_tokens(tokens):
r = defaultdict(list) r = defaultdict(list)
for t in tokens: for t in sorted(tokens, key=lambda t: t.chain_id):
r[t.chain_id].append(t) r[t.chain_id].append(t)
return r return r
%> %>
@ -24,7 +24,7 @@ def token_by_chain_address(chain_id, address):
pass pass
% for t in tokens: % for t in tokens:
elif address == ${black_repr(t.address_bytes)}: elif address == ${black_repr(t.address_bytes)}:
return (${t.chain_id}, ${black_repr(t.address_bytes)}, ${black_repr(t.symbol)}, ${t.decimals}) # ${t.chain} / ${t.name.strip()} return (chain_id, address, ${black_repr(t.symbol)}, ${t.decimals}) # ${t.chain} / ${t.name.strip()}
% endfor % endfor
% endfor % endfor
# fmt: on # fmt: on