mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-19 12:58:13 +00:00
ethereum/signing: display data fix
This commit is contained in:
parent
7d0cafecc3
commit
aa8bb77e32
@ -1,42 +1,37 @@
|
|||||||
|
from apps.common.confirm import *
|
||||||
from trezor import wire, ui
|
from trezor import wire, ui
|
||||||
from trezor.utils import unimport, chunks
|
from trezor.utils import unimport, chunks
|
||||||
from trezor.messages import ButtonRequestType
|
from trezor.messages import ButtonRequestType
|
||||||
from trezor.ui.text import Text
|
from trezor.ui.text import Text
|
||||||
from apps.common.confirm import *
|
from ubinascii import hexlify
|
||||||
from . import networks
|
from . import networks
|
||||||
|
|
||||||
|
|
||||||
@unimport
|
@unimport
|
||||||
async def confirm_tx(ctx, to, value, chain_id, token=None):
|
async def confirm_tx(ctx, to, value, chain_id, token=None): # todo wording
|
||||||
|
str_to = '0x' + hexlify(to).decode() # todo use ethereum address format
|
||||||
content = Text('Confirm transaction', ui.ICON_RESET,
|
content = Text('Confirm transaction', ui.ICON_RESET,
|
||||||
ui.BOLD, format_amount(value, token, chain_id),
|
ui.BOLD, format_amount(value, token, chain_id),
|
||||||
ui.NORMAL, 'to',
|
ui.NORMAL, 'to',
|
||||||
ui.MONO, *split_address(to)) # todo no addres shown, why?
|
ui.MONO, *split_address(str_to))
|
||||||
return await confirm(ctx, content, ButtonRequestType.ConfirmOutput)
|
return await confirm(ctx, content, ButtonRequestType.ConfirmOutput)
|
||||||
|
|
||||||
|
|
||||||
@unimport
|
@unimport
|
||||||
async def confirm_fee(ctx, spending, fee, chain_id, token=None):
|
async def confirm_fee(ctx, spending, gas_price, gas_limit, chain_id, token=None): # todo wording
|
||||||
content = Text('Confirm transaction', ui.ICON_RESET,
|
content = Text('Confirm fee', ui.ICON_RESET,
|
||||||
'Sending: %s' % format_amount(spending, token, chain_id),
|
'Sending: %s' % format_amount(spending, token, chain_id),
|
||||||
'Fee: %s' % format_amount(fee, token, chain_id))
|
'Gas: %s' % format_amount(gas_price, token, chain_id),
|
||||||
|
'Limit: %s' % format_amount(gas_limit, token, chain_id))
|
||||||
return await hold_to_confirm(ctx, content, ButtonRequestType.SignTx)
|
return await hold_to_confirm(ctx, content, ButtonRequestType.SignTx)
|
||||||
|
|
||||||
|
|
||||||
@unimport
|
@unimport
|
||||||
async def confirm_data(ctx, data, data_total):
|
async def confirm_data(ctx, data, data_total): # todo wording
|
||||||
content = Text('Confirm data', ui.ICON_RESET,
|
str_data = hexlify(data[:8]).decode() + '..'
|
||||||
ui.MONO, data[:16], # todo nothing displayed?
|
content = Text('Confirm data:', ui.ICON_RESET,
|
||||||
'of total: ', data_total)
|
ui.MONO, str_data,
|
||||||
return await confirm(ctx, content, ButtonRequestType.ConfirmOutput)
|
'Total: ', str(data_total) + 'B')
|
||||||
|
|
||||||
|
|
||||||
@unimport
|
|
||||||
async def confirm_fee(ctx, value, gas_price, gas_limit, token):
|
|
||||||
content = Text('Confirm fee', ui.ICON_RESET,
|
|
||||||
'price:', ui.MONO, gas_price, # todo wording
|
|
||||||
'limit:', ui.MONO, gas_limit,
|
|
||||||
'value: ', value)
|
|
||||||
return await confirm(ctx, content, ButtonRequestType.ConfirmOutput)
|
return await confirm(ctx, content, ButtonRequestType.ConfirmOutput)
|
||||||
|
|
||||||
|
|
||||||
@ -45,7 +40,7 @@ def split_address(address):
|
|||||||
|
|
||||||
|
|
||||||
def format_amount(value, token, chain_id):
|
def format_amount(value, token, chain_id):
|
||||||
value = int.from_bytes(value, 'little')
|
value = int.from_bytes(value, 'big')
|
||||||
if token:
|
if token:
|
||||||
suffix = token.ticker
|
suffix = token.ticker
|
||||||
decimals = token.decimals
|
decimals = token.decimals
|
||||||
|
@ -37,7 +37,7 @@ async def ethereum_sign_tx(ctx, msg):
|
|||||||
if token is None and msg.data_length > 0:
|
if token is None and msg.data_length > 0:
|
||||||
await layout.confirm_data(ctx, msg.data_initial_chunk, data_total)
|
await layout.confirm_data(ctx, msg.data_initial_chunk, data_total)
|
||||||
|
|
||||||
await layout.confirm_fee(ctx, msg.value, msg.gas_price, msg.gas_limit, token)
|
await layout.confirm_fee(ctx, msg.value, msg.gas_price, msg.gas_limit, msg.chain_id, token)
|
||||||
|
|
||||||
data = bytearray()
|
data = bytearray()
|
||||||
data += msg.data_initial_chunk
|
data += msg.data_initial_chunk
|
||||||
|
Loading…
Reference in New Issue
Block a user