mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-10 23:40:58 +00:00
nem: layout improved
This commit is contained in:
parent
d30d6859ba
commit
0e1b3aa904
src/apps/nem
@ -2,34 +2,38 @@ from apps.common.confirm import *
|
||||
from trezor import ui
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.ui.text import Text
|
||||
|
||||
# todo wording, ui
|
||||
from trezor.utils import chunks, format_amount, split_words
|
||||
from .helpers import *
|
||||
|
||||
|
||||
async def require_confirm_tx(ctx, recipient, value):
|
||||
content = Text('Confirm sending', ui.ICON_SEND,
|
||||
ui.BOLD, value,
|
||||
ui.BOLD, format_amount(value, NEM_MAX_DIVISIBILITY) + ' NEM',
|
||||
ui.NORMAL, 'to',
|
||||
ui.MONO, recipient,
|
||||
ui.MONO, *split_address(recipient),
|
||||
icon_color=ui.GREEN)
|
||||
await require_hold_to_confirm(ctx, content, ButtonRequestType.SignTx) # we use SignTx, not ConfirmOutput, for compatibility with T1
|
||||
|
||||
|
||||
async def require_confirm_fee(ctx, value, fee):
|
||||
content = Text('Confirm transaction', ui.ICON_SEND,
|
||||
ui.BOLD, value,
|
||||
ui.NORMAL, 'fee:',
|
||||
ui.BOLD, fee,
|
||||
async def require_confirm_fee(ctx, fee):
|
||||
content = Text('Confirm fee', ui.ICON_SEND,
|
||||
'Pay ', ui.BOLD, format_amount(fee, NEM_MAX_DIVISIBILITY) + ' NEM',
|
||||
ui.NORMAL, 'for transaction fee?',
|
||||
icon_color=ui.GREEN)
|
||||
await require_confirm(ctx, content, ButtonRequestType.ConfirmOutput)
|
||||
|
||||
|
||||
async def require_confirm_action(ctx, payload, encrypt=False):
|
||||
async def require_confirm_action(ctx, payload: bytes, encrypt=False):
|
||||
payload = str(payload, 'utf-8')
|
||||
if encrypt:
|
||||
content = Text("Send payload encrypted?", ui.ICON_SEND,
|
||||
ui.NORMAL, payload)
|
||||
content = Text('Send encrypted?', ui.ICON_SEND,
|
||||
ui.NORMAL, *split_words(payload, 18))
|
||||
else:
|
||||
content = Text("Send payload unencrypted?", ui.ICON_SEND,
|
||||
ui.NORMAL, payload,
|
||||
content = Text('Send unencrypted?', ui.ICON_SEND,
|
||||
ui.NORMAL, *split_words(payload, 18),
|
||||
icon_color=ui.RED)
|
||||
await require_confirm(ctx, content, ButtonRequestType.ConfirmOutput)
|
||||
|
||||
|
||||
def split_address(data):
|
||||
return chunks(data, 17)
|
||||
|
@ -36,8 +36,8 @@ async def nem_sign_tx(ctx, msg: NEMSignTx):
|
||||
if payload: # confirm unencrypted
|
||||
await require_confirm_action(ctx, msg.transfer.payload, encrypted)
|
||||
|
||||
await require_confirm_fee(ctx, msg.transfer.amount, msg.transaction.fee) # todo
|
||||
await require_confirm_tx(ctx, msg.transfer.recipient, msg.transfer.amount) # todo
|
||||
await require_confirm_fee(ctx, msg.transaction.fee)
|
||||
await require_confirm_tx(ctx, msg.transfer.recipient, msg.transfer.amount)
|
||||
|
||||
signature = ed25519.sign(node.private_key(), tx, helpers.NEM_HASH_ALG)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user