mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-05 20:31:01 +00:00
core/ethereum: store tokens as a decision tree
This commit is contained in:
parent
94de0aa9cb
commit
875579867e
File diff suppressed because it is too large
Load Diff
@ -1,21 +1,31 @@
|
|||||||
# generated from tokens.py.mako
|
# generated from tokens.py.mako
|
||||||
# do not edit manually!
|
# do not edit manually!
|
||||||
|
|
||||||
|
<%
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
def token_by_chain_address(chain_id, address):
|
def group_tokens(tokens):
|
||||||
for token in tokens:
|
r = defaultdict(list)
|
||||||
if chain_id == token[0] and address == token[1]:
|
for t in tokens:
|
||||||
return token
|
r[t.chain_id].append(t)
|
||||||
return UNKNOWN_TOKEN
|
return r
|
||||||
|
%>
|
||||||
|
|
||||||
UNKNOWN_TOKEN = (None, None, None, None)
|
UNKNOWN_TOKEN = (None, None, None, None)
|
||||||
|
|
||||||
|
|
||||||
# fmt: off
|
def token_by_chain_address(chain_id, address):
|
||||||
tokens = [
|
if False:
|
||||||
% for t in supported_on("trezor2", erc20):
|
pass
|
||||||
(${t.chain_id}, ${black_repr(t.address_bytes)}, ${black_repr(t.symbol)}, ${t.decimals}), # ${t.chain} / ${t.name.strip()}
|
# fmt: off
|
||||||
|
% 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 (${t.chain_id}, ${black_repr(t.address_bytes)}, ${black_repr(t.symbol)}, ${t.decimals}) # ${t.chain} / ${t.name.strip()}
|
||||||
|
% endfor
|
||||||
% endfor
|
% endfor
|
||||||
]
|
# fmt: on
|
||||||
# fmt: on
|
return UNKNOWN_TOKEN
|
||||||
|
Loading…
Reference in New Issue
Block a user