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