ui.text: type -> normal

pull/25/head
Jan Pochyla 6 years ago
parent ec06ccf43f
commit 2b66deb3d6

@ -14,7 +14,7 @@ from apps.common.cache import get_state
@ui.layout
async def request_passphrase_entry(ctx):
text = Text('Enter passphrase', ui.ICON_CONFIG)
text.type('Where to enter your', 'passphrase?')
text.normal('Where to enter your', 'passphrase?')
text.render()
ack = await ctx.call(
@ -32,7 +32,7 @@ async def request_passphrase_entry(ctx):
async def request_passphrase_ack(ctx, on_device):
if not on_device:
text = Text('Passphrase entry', ui.ICON_CONFIG)
text.type('Please, type passphrase', 'on connected host.')
text.normal('Please, type passphrase', 'on connected host.')
text.render()
req = PassphraseRequest(on_device=on_device)

@ -17,7 +17,7 @@ async def require_confirm_tx(ctx, to, value, chain_id, token=None, tx_type=None)
to_str = 'new contract?'
text = Text('Confirm sending', ui.ICON_SEND, icon_color=ui.GREEN)
text.bold(format_ethereum_amount(value, token, chain_id, tx_type))
text.type('to')
text.normal('to')
text.mono(*split_address(to_str))
# we use SignTx, not ConfirmOutput, for compatibility with T1
await require_confirm(ctx, text, ButtonRequestType.SignTx)
@ -26,9 +26,9 @@ async def require_confirm_tx(ctx, to, value, chain_id, token=None, tx_type=None)
async def require_confirm_fee(ctx, spending, gas_price, gas_limit, chain_id, token=None, tx_type=None):
text = Text('Confirm transaction', ui.ICON_SEND, icon_color=ui.GREEN)
text.bold(format_ethereum_amount(spending, token, chain_id, tx_type))
text.type('Gas price:')
text.normal('Gas price:')
text.bold(format_ethereum_amount(gas_price, None, chain_id, tx_type))
text.type('Maximum fee:')
text.normal('Maximum fee:')
text.bold(format_ethereum_amount(gas_price * gas_limit, None, chain_id, tx_type))
await require_hold_to_confirm(ctx, text, ButtonRequestType.SignTx)

@ -38,5 +38,5 @@ async def ethereum_sign_message(ctx, msg):
async def require_confirm_sign_message(ctx, message):
message = split_message(message)
text = Text('Sign ETH message')
text.type(*message)
text.normal(*message)
await require_confirm(ctx, text)

@ -392,7 +392,7 @@ class ConfirmState:
if bytes(self.app_id) == _BOGUS_APPID:
text = Text('U2F mismatch', ui.ICON_WRONG, icon_color=ui.RED)
text.type('Another U2F device', 'was used to register', 'in this application.')
text.normal('Another U2F device', 'was used to register', 'in this application.')
text.render()
await loop.sleep(3 * 1000 * 1000)
self.confirmed = True

@ -11,22 +11,22 @@ from .helpers import get_vote_tx_text
async def require_confirm_tx(ctx, to, value):
text = Text('Confirm sending', ui.ICON_SEND, icon_color=ui.GREEN)
text.bold(format_amount(value))
text.type('to')
text.normal('to')
text.mono(*split_address(to))
return await require_confirm(ctx, text, ButtonRequestType.SignTx)
async def require_confirm_delegate_registration(ctx, delegate_name):
text = Text('Confirm transaction', ui.ICON_SEND, icon_color=ui.GREEN)
text.type('Do you really want to')
text.type('register a delegate?')
text.normal('Do you really want to')
text.normal('register a delegate?')
text.bold(*chunks(delegate_name, 20))
return await require_confirm(ctx, text, ButtonRequestType.SignTx)
async def require_confirm_vote_tx(ctx, votes):
text = Text('Confirm transaction', ui.ICON_SEND, icon_color=ui.GREEN)
text.type(*get_vote_tx_text(votes))
text.normal(*get_vote_tx_text(votes))
return await require_confirm(ctx, text, ButtonRequestType.SignTx)
@ -36,16 +36,16 @@ async def require_confirm_public_key(ctx, public_key):
async def require_confirm_multisig(ctx, multisignature):
text = Text('Confirm transaction', ui.ICON_SEND, icon_color=ui.GREEN)
text.type('Keys group length: %s' % len(multisignature.keys_group))
text.type('Life time: %s' % multisignature.life_time)
text.type('Min: %s' % multisignature.min)
text.normal('Keys group length: %s' % len(multisignature.keys_group))
text.normal('Life time: %s' % multisignature.life_time)
text.normal('Min: %s' % multisignature.min)
return await require_confirm(ctx, text, ButtonRequestType.SignTx)
async def require_confirm_fee(ctx, value, fee):
text = Text('Confirm transaction', ui.ICON_SEND, icon_color=ui.GREEN)
text.bold(format_amount(value))
text.type('fee:')
text.normal('fee:')
text.bold(format_amount(fee))
await require_hold_to_confirm(ctx, text, ButtonRequestType.ConfirmOutput)

@ -40,5 +40,5 @@ async def lisk_sign_message(ctx, msg):
async def require_confirm_sign_message(ctx, message):
text = Text('Sign Lisk message')
text.type(*split_message(message))
text.normal(*split_message(message))
await require_confirm(ctx, text)

@ -34,22 +34,22 @@ async def apply_settings(ctx, msg):
async def require_confirm_change_homescreen(ctx):
text = Text('Change homescreen', ui.ICON_CONFIG)
text.type('Do you really want to', 'change homescreen?')
text.normal('Do you really want to', 'change homescreen?')
await require_confirm(ctx, text, code=ButtonRequestType.ProtectCall)
async def require_confirm_change_label(ctx, label):
text = Text('Change label', ui.ICON_CONFIG)
text.type('Do you really want to', 'change label to')
text.normal('Do you really want to', 'change label to')
text.bold('%s?' % label)
await require_confirm(ctx, text, code=ButtonRequestType.ProtectCall)
async def require_confirm_change_passphrase(ctx, use):
text = Text('Enable passphrase' if use else 'Disable passphrase', ui.ICON_CONFIG)
text.type('Do you really want to')
text.type('enable passphrase' if use else 'disable passphrase')
text.type('encryption?')
text.normal('Do you really want to')
text.normal('enable passphrase' if use else 'disable passphrase')
text.normal('encryption?')
await require_confirm(ctx, text, code=ButtonRequestType.ProtectCall)
@ -61,6 +61,6 @@ async def require_confirm_change_passphrase_source(ctx, source):
else:
desc = 'ASK'
text = Text('Passphrase source', ui.ICON_CONFIG)
text.type('Do you really want to', 'change the passphrase', 'source to')
text.normal('Do you really want to', 'change the passphrase', 'source to')
text.bold('ALWAYS %s?' % desc)
await require_confirm(ctx, text, code=ButtonRequestType.ProtectCall)

@ -43,19 +43,19 @@ def require_confirm_change_pin(ctx, msg):
if msg.remove and has_pin: # removing pin
text = Text('Remove PIN', ui.ICON_CONFIG)
text.type('Do you really want to')
text.normal('Do you really want to')
text.bold('remove current PIN?')
return require_confirm(ctx, text)
if not msg.remove and has_pin: # changing pin
text = Text('Remove PIN', ui.ICON_CONFIG)
text.type('Do you really want to')
text.normal('Do you really want to')
text.bold('change current PIN?')
return require_confirm(ctx, text)
if not msg.remove and not has_pin: # setting new pin
text = Text('Remove PIN', ui.ICON_CONFIG)
text.type('Do you really want to')
text.normal('Do you really want to')
text.bold('set new PIN?')
return require_confirm(ctx, text)
@ -80,8 +80,8 @@ async def request_pin_ack(ctx, *args, **kwargs):
@ui.layout
async def pin_mismatch():
text = Text('PIN mismatch', ui.ICON_WRONG, icon_color=ui.RED)
text.type('Entered PINs do not', 'match each other.')
text.type('')
text.type('Please, try again...')
text.normal('Entered PINs do not', 'match each other.')
text.normal('')
text.normal('Please, try again...')
text.render()
await loop.sleep(3 * 1000 * 1000)

@ -20,7 +20,7 @@ async def load_device(ctx, msg):
text = Text('Loading seed')
text.bold('Loading private seed', 'is not recommended.')
text.type('Continue only if you', 'know what you are doing!')
text.normal('Continue only if you', 'know what you are doing!')
await require_confirm(ctx, text)
storage.load_mnemonic(

@ -62,7 +62,7 @@ async def request_wordcount(ctx):
await ctx.call(ButtonRequest(code=MnemonicWordCount), ButtonAck)
text = Text('Device recovery', ui.ICON_RECOVERY)
text.type('Number of words?')
text.normal('Number of words?')
count = await ctx.wait(WordSelector(text))
return count

@ -89,7 +89,7 @@ def generate_mnemonic(strength: int,
async def show_warning(ctx):
text = Text('Backup your seed', ui.ICON_NOCOPY)
text.type(
text.normal(
'Never make a digital',
'copy of your recovery',
'seed and never upload',
@ -104,7 +104,7 @@ async def show_warning(ctx):
async def show_wrong_entry(ctx):
text = Text('Wrong entry!', ui.ICON_WRONG, icon_color=ui.RED)
text.type(
text.normal(
'You have entered',
'wrong seed word.',
'Please check again.')
@ -118,7 +118,7 @@ async def show_wrong_entry(ctx):
async def show_success(ctx):
text = Text('Backup is done!', ui.ICON_CONFIRM, icon_color=ui.GREEN)
text.type(
text.normal(
'Never make a digital',
'copy of your recovery',
'seed and never upload',

@ -11,7 +11,7 @@ async def set_u2f_counter(ctx, msg):
raise wire.ProcessError('No value provided')
text = Text('Set U2F counter', ui.ICON_CONFIG)
text.type('Do you really want to', 'set the U2F counter')
text.normal('Do you really want to', 'set the U2F counter')
text.bold('to %d?' % msg.u2f_counter)
await require_confirm(ctx, text, code=ButtonRequestType.ProtectCall)

@ -9,7 +9,7 @@ from apps.common.confirm import require_hold_to_confirm
async def wipe_device(ctx, msg):
text = Text('Wipe device', ui.ICON_WIPE, icon_color=ui.RED)
text.type('Do you really want to', 'wipe the device?', '')
text.normal('Do you really want to', 'wipe the device?', '')
text.bold('All data will be lost.')
await require_hold_to_confirm(ctx, text,

@ -31,6 +31,6 @@ async def get_address(ctx, msg):
async def _show_address(ctx, address: str, network: int):
lines = split_address(address)
text = Text('Confirm address', ui.ICON_RECEIVE, icon_color=ui.GREEN)
text.type('%s network' % get_network_str(network))
text.normal('%s network' % get_network_str(network))
text.mono(*lines)
return await confirm(ctx, text, code=ButtonRequestType.Address, cancel='QR', cancel_style=ui.BTN_KEY)

@ -23,15 +23,15 @@ async def require_confirm_fee(ctx, action: str, fee: int):
async def require_confirm_content(ctx, headline: str, content: list):
text = Text(headline, ui.ICON_SEND, icon_color=ui.GREEN)
text.type(*content)
text.normal(*content)
await require_confirm(ctx, text, ButtonRequestType.ConfirmOutput)
async def require_confirm_final(ctx, fee: int):
text = Text('Final confirm', ui.ICON_SEND, icon_color=ui.GREEN)
text.type('Sign this transaction')
text.normal('Sign this transaction')
text.bold('and pay %s XEM' % format_amount(fee, NEM_MAX_DIVISIBILITY))
text.type('for network fee?')
text.normal('for network fee?')
# we use SignTx, not ConfirmOutput, for compatibility with T1
await require_hold_to_confirm(ctx, text, ButtonRequestType.SignTx)

@ -72,7 +72,7 @@ def _get_mosaic_properties(definition: NEMMosaicDefinition):
if definition.description:
t = Text('Confirm properties', ui.ICON_SEND)
t.bold('Description:')
t.type(*split_words(trim(definition.description, 70), 22))
t.normal(*split_words(trim(definition.description, 70), 22))
properties.append(t)
# transferable
@ -82,7 +82,7 @@ def _get_mosaic_properties(definition: NEMMosaicDefinition):
transferable = 'No'
t = Text('Confirm properties', ui.ICON_SEND)
t.bold('Transferable?')
t.type(transferable)
t.normal(transferable)
properties.append(t)
# mutable_supply
@ -93,11 +93,11 @@ def _get_mosaic_properties(definition: NEMMosaicDefinition):
if definition.supply:
t = Text('Confirm properties', ui.ICON_SEND)
t.bold('Initial supply:')
t.type(str(definition.supply), imm)
t.normal(str(definition.supply), imm)
else:
t = Text('Confirm properties', ui.ICON_SEND)
t.bold('Initial supply:')
t.type(imm)
t.normal(imm)
properties.append(t)
# levy
@ -110,16 +110,16 @@ def _get_mosaic_properties(definition: NEMMosaicDefinition):
t = Text('Confirm properties', ui.ICON_SEND)
t.bold('Levy fee:')
t.type(str(definition.fee))
t.normal(str(definition.fee))
t.bold('Levy divisibility:')
t.type(str(definition.divisibility))
t.normal(str(definition.divisibility))
properties.append(t)
t = Text('Confirm properties', ui.ICON_SEND)
t.bold('Levy namespace:')
t.type(definition.levy_namespace)
t.normal(definition.levy_namespace)
t.bold('Levy mosaic:')
t.type(definition.levy_mosaic)
t.normal(definition.levy_mosaic)
properties.append(t)
if definition.levy == NEMMosaicLevy.MosaicLevy_Absolute:
@ -128,7 +128,7 @@ def _get_mosaic_properties(definition: NEMMosaicDefinition):
levy_type = 'percentile'
t = Text('Confirm properties', ui.ICON_SEND)
t.bold('Levy type:')
t.type(levy_type)
t.normal(levy_type)
properties.append(t)
return properties

@ -43,6 +43,6 @@ async def ask_aggregate_modification(ctx, common: NEMTransactionCommon, mod: NEM
async def _require_confirm_address(ctx, action: str, address: str):
text = Text('Confirm address', ui.ICON_SEND, icon_color=ui.GREEN)
text.type(action)
text.normal(action)
text.mono(*split_address(address))
await require_confirm(ctx, text, ButtonRequestType.ConfirmOutput)

@ -31,29 +31,29 @@ async def ask_transfer_mosaic(ctx, common: NEMTransactionCommon, transfer: NEMTr
if definition:
msg = Text('Confirm mosaic', ui.ICON_SEND, icon_color=ui.GREEN)
msg.type('Confirm transfer of')
msg.normal('Confirm transfer of')
msg.bold(format_amount(mosaic_quantity, definition['divisibility']) + definition['ticker'])
msg.type('of')
msg.normal('of')
msg.bold(definition['name'])
await require_confirm(ctx, msg, ButtonRequestType.ConfirmOutput)
if 'levy' in definition and 'fee' in definition:
levy_msg = _get_levy_msg(definition, mosaic_quantity, common.network)
msg = Text('Confirm mosaic', ui.ICON_SEND, icon_color=ui.GREEN)
msg.type('Confirm mosaic', 'levy fee of')
msg.normal('Confirm mosaic', 'levy fee of')
msg.bold(levy_msg)
await require_confirm(ctx, msg, ButtonRequestType.ConfirmOutput)
else:
msg = Text('Confirm mosaic', ui.ICON_SEND, icon_color=ui.RED)
msg.bold('Unknown mosaic!')
msg.type(*split_words('Divisibility and levy cannot be shown for unknown mosaics', 22))
msg.normal(*split_words('Divisibility and levy cannot be shown for unknown mosaics', 22))
await require_confirm(ctx, msg, ButtonRequestType.ConfirmOutput)
msg = Text('Confirm mosaic', ui.ICON_SEND, icon_color=ui.GREEN)
msg.type('Confirm transfer of')
msg.normal('Confirm transfer of')
msg.bold('%s raw units' % mosaic_quantity)
msg.type('of')
msg.normal('of')
msg.bold('%s.%s' % (mosaic.namespace, mosaic.mosaic))
await require_confirm(ctx, msg, ButtonRequestType.ConfirmOutput)
@ -97,7 +97,7 @@ async def ask_importance_transfer(ctx, common: NEMTransactionCommon, imp: NEMImp
async def _require_confirm_transfer(ctx, recipient, value):
text = Text('Confirm transfer', ui.ICON_SEND, icon_color=ui.GREEN)
text.bold('Send %s XEM' % format_amount(value, NEM_MAX_DIVISIBILITY))
text.type('to')
text.normal('to')
text.mono(*split_address(recipient))
await require_confirm(ctx, text, ButtonRequestType.ConfirmOutput)
@ -110,9 +110,9 @@ async def _require_confirm_payload(ctx, payload: bytes, encrypt=False):
if encrypt:
text = Text('Confirm payload', ui.ICON_SEND, icon_color=ui.GREEN)
text.bold('Encrypted:')
text.type(*split_words(payload, 22))
text.normal(*split_words(payload, 22))
else:
text = Text('Confirm payload', ui.ICON_SEND, icon_color=ui.RED)
text.bold('Unencrypted:')
text.type(*split_words(payload, 22))
text.normal(*split_words(payload, 22))
await require_confirm(ctx, text, ButtonRequestType.ConfirmOutput)

@ -21,7 +21,7 @@ async def cipher_key_value(ctx, msg):
else:
title = 'Decrypt value'
text = Text(title)
text.type(msg.key)
text.normal(msg.key)
await require_confirm(ctx, text)
node = await seed.derive_node(ctx, msg.address_n)

@ -10,7 +10,7 @@ async def get_entropy(ctx, msg):
text = Text('Confirm entropy')
text.bold('Do you really want', 'to send entropy?')
text.type('Continue only if you', 'know what you are doing!')
text.normal('Continue only if you', 'know what you are doing!')
await require_confirm(ctx, text, code=ButtonRequestType.ProtectCall)
size = min(msg.size, 1024)

@ -54,7 +54,7 @@ async def require_confirm_sign_identity(ctx, identity, challenge_visual):
proto = identity.proto.upper() if identity.proto else 'identity'
text = Text('Sign %s' % proto)
text.type(*lines)
text.normal(*lines)
await require_confirm(ctx, text)

@ -40,5 +40,5 @@ async def sign_message(ctx, msg):
async def require_confirm_sign_message(ctx, message):
message = split_message(message)
text = Text('Sign message')
text.type(*message)
text.normal(*message)
await require_confirm(ctx, text)

@ -32,31 +32,31 @@ async def confirm_output(ctx, output, coin):
address = output.address
address_short = addresses.address_short(coin, address)
text = Text('Confirm sending', ui.ICON_SEND, icon_color=ui.GREEN)
text.type(format_coin_amount(output.amount, coin) + ' to')
text.normal(format_coin_amount(output.amount, coin) + ' to')
text.mono(*split_address(address_short))
return await confirm(ctx, text, ButtonRequestType.ConfirmOutput)
async def confirm_total(ctx, spending, fee, coin):
text = Text('Confirm transaction', ui.ICON_SEND, icon_color=ui.GREEN)
text.type('Total amount:')
text.normal('Total amount:')
text.bold(format_coin_amount(spending, coin))
text.type('including fee:')
text.normal('including fee:')
text.bold(format_coin_amount(fee, coin))
return await hold_to_confirm(ctx, text, ButtonRequestType.SignTx)
async def confirm_feeoverthreshold(ctx, fee, coin):
text = Text('High fee', ui.ICON_SEND, icon_color=ui.GREEN)
text.type('The fee of')
text.normal('The fee of')
text.bold(format_coin_amount(fee, coin))
text.type('is unexpectedly high.', 'Continue?')
text.normal('is unexpectedly high.', 'Continue?')
return await confirm(ctx, text, ButtonRequestType.FeeOverThreshold)
async def confirm_foreign_address(ctx, address_n, coin):
text = Text('Confirm sending', ui.ICON_SEND, icon_color=ui.RED)
text.type(
text.normal(
'Trying to spend',
'coins from another chain.',
'Continue?')

@ -62,5 +62,5 @@ async def require_confirm_verify_message(ctx, address, message):
await require_confirm(ctx, text)
text = Text('Verify message')
text.type(*split_message(message))
text.normal(*split_message(message))
await require_confirm(ctx, text)

@ -112,7 +112,7 @@ class Text(ui.LazyWidget):
self.new_lines = new_lines
self.content = []
def type(self, *content):
def normal(self, *content):
self.content.extend(content)
def bold(self, *content):

Loading…
Cancel
Save