diff --git a/src/apps/nem/get_address.py b/src/apps/nem/get_address.py index d7660f2f30..14c1554857 100644 --- a/src/apps/nem/get_address.py +++ b/src/apps/nem/get_address.py @@ -1,7 +1,11 @@ -from apps.wallet.get_address import _show_address -from apps.common import seed -from trezor.messages.NEMAddress import NEMAddress from .validators import * +from apps.common import seed +from apps.common.confirm import confirm +from trezor import ui +from trezor.messages.NEMAddress import NEMAddress +from trezor.messages import ButtonRequestType +from trezor.ui.text import Text +from trezor.utils import chunks async def nem_get_address(ctx, msg): @@ -11,7 +15,35 @@ async def nem_get_address(ctx, msg): if msg.show_display: while True: - if await _show_address(ctx, address): + if await _show_address(ctx, address, network): break return NEMAddress(address=address) + + +async def _show_address(ctx, address: str, network: int): + lines = _split_address(address) + print(network) + content = Text('Export NEM address', ui.ICON_RECEIVE, + ui.MONO, _get_network_str(network) + ' network', + ui.MONO, *lines, + icon_color=ui.GREEN) + + return await confirm( + ctx, + content, + code=ButtonRequestType.Address, + cancel_style=ui.BTN_KEY) + + +def _split_address(address: str): + return chunks(address, 17) + + +def _get_network_str(network: int) -> str: + if network == NEM_NETWORK_MAINNET: + return 'Mainnet' + elif network == NEM_NETWORK_TESTNET: + return 'Testnet' + elif network == NEM_NETWORK_MIJIN: + return 'Mijin' diff --git a/src/apps/nem/validators.py b/src/apps/nem/validators.py index 5dc748baa3..677cce8e4f 100644 --- a/src/apps/nem/validators.py +++ b/src/apps/nem/validators.py @@ -18,7 +18,7 @@ def validate(msg: NEMSignTx): if msg.provision_namespace or msg.mosaic_creation or msg.supply_change or msg.aggregate_modification \ or msg.importance_transfer: - raise ValueError('Not yet implemented') + raise ValueError('Not yet implemented') # todo _validate_single_tx(msg) _validate_common(msg.transaction)