mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-11 16:00:57 +00:00
eth: unknown token transfer is recognized and displayed as unknown
updates #198
This commit is contained in:
parent
a8351d1bda
commit
2d0d360944
@ -1,4 +1,5 @@
|
|||||||
from apps.common.confirm import *
|
from apps.common.confirm import *
|
||||||
|
from apps.ethereum import tokens
|
||||||
from trezor import ui
|
from trezor import ui
|
||||||
from trezor.utils import chunks, format_amount
|
from trezor.utils import chunks, format_amount
|
||||||
from trezor.messages import ButtonRequestType
|
from trezor.messages import ButtonRequestType
|
||||||
@ -53,6 +54,8 @@ def split_address(address):
|
|||||||
|
|
||||||
def format_ethereum_amount(value: int, token, chain_id: int, tx_type=None):
|
def format_ethereum_amount(value: int, token, chain_id: int, tx_type=None):
|
||||||
if token:
|
if token:
|
||||||
|
if token is tokens.UNKNOWN_TOKEN:
|
||||||
|
return 'Unknown token value'
|
||||||
suffix = token[2]
|
suffix = token[2]
|
||||||
decimals = token[3]
|
decimals = token[3]
|
||||||
else:
|
else:
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
def token_by_chain_address(chain_id, address):
|
def token_by_chain_address(chain_id, address):
|
||||||
if not address:
|
|
||||||
return None
|
|
||||||
for token in tokens:
|
for token in tokens:
|
||||||
if chain_id == token[0] and address == token[1]:
|
if chain_id == token[0] and address == token[1]:
|
||||||
return token
|
return token
|
||||||
return None
|
return UNKNOWN_TOKEN
|
||||||
|
|
||||||
|
|
||||||
|
UNKNOWN_TOKEN = True
|
||||||
|
|
||||||
# rest of the file is generated using trezor-common/ethereum_tokens-gen.py
|
# rest of the file is generated using trezor-common/ethereum_tokens-gen.py
|
||||||
# DO NOT EDIT MANUALLY!
|
# DO NOT EDIT MANUALLY!
|
||||||
tokens = [
|
tokens = [
|
||||||
|
@ -22,7 +22,7 @@ class TestEthereumTokens(unittest.TestCase):
|
|||||||
|
|
||||||
# invalid adress, invalid chain
|
# invalid adress, invalid chain
|
||||||
token = tokens.token_by_chain_address(999, b'\x00\xFF')
|
token = tokens.token_by_chain_address(999, b'\x00\xFF')
|
||||||
self.assertEqual(token, None)
|
self.assertEqual(token, tokens.UNKNOWN_TOKEN)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user