mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-18 05:28:40 +00:00
apps: split_address moved to show only (#307)
This commit is contained in:
parent
f7c1465d57
commit
a08a1a5e2a
@ -11,10 +11,11 @@ from trezor.utils import chunks
|
||||
from apps.common.confirm import confirm, require_confirm
|
||||
|
||||
|
||||
async def show_address(ctx, address: str):
|
||||
lines = split_address(address)
|
||||
async def show_address(ctx, address: str, network: str = None):
|
||||
text = Text("Confirm address", ui.ICON_RECEIVE, icon_color=ui.GREEN)
|
||||
text.mono(*lines)
|
||||
if network:
|
||||
text.normal("%s network" % network)
|
||||
text.mono(*split_address(address))
|
||||
return await confirm(
|
||||
ctx, text, code=ButtonRequestType.Address, cancel="QR", cancel_style=ui.BTN_KEY
|
||||
)
|
||||
|
@ -6,6 +6,7 @@ from trezor.ui.text import Text
|
||||
from trezor.utils import chunks, format_amount
|
||||
|
||||
from apps.common.confirm import require_confirm, require_hold_to_confirm
|
||||
from apps.common.show import split_address
|
||||
from apps.ethereum import networks, tokens
|
||||
from apps.ethereum.get_address import _ethereum_address_hex
|
||||
|
||||
@ -50,10 +51,6 @@ async def require_confirm_data(ctx, data, data_total):
|
||||
await require_confirm(ctx, text, ButtonRequestType.SignTx)
|
||||
|
||||
|
||||
def split_address(address):
|
||||
return chunks(address, 17)
|
||||
|
||||
|
||||
def format_ethereum_amount(value: int, token, chain_id: int, tx_type=None):
|
||||
if token:
|
||||
if token is tokens.UNKNOWN_TOKEN:
|
||||
|
@ -6,7 +6,7 @@ from trezor.utils import chunks
|
||||
from .helpers import get_vote_tx_text
|
||||
|
||||
from apps.common.confirm import require_confirm, require_hold_to_confirm
|
||||
from apps.common.show import show_pubkey
|
||||
from apps.common.show import show_pubkey, split_address
|
||||
|
||||
|
||||
async def require_confirm_tx(ctx, to, value):
|
||||
@ -53,7 +53,3 @@ async def require_confirm_fee(ctx, value, fee):
|
||||
|
||||
def format_amount(value):
|
||||
return "%s LSK" % (int(value) / 100000000)
|
||||
|
||||
|
||||
def split_address(address):
|
||||
return chunks(address, 16)
|
||||
|
@ -1,15 +1,10 @@
|
||||
from trezor import ui
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.messages.NEMAddress import NEMAddress
|
||||
from trezor.ui.text import Text
|
||||
|
||||
from .helpers import NEM_CURVE, get_network_str
|
||||
from .layout import split_address
|
||||
from .validators import validate_network
|
||||
|
||||
from apps.common import seed
|
||||
from apps.common.confirm import confirm
|
||||
from apps.common.show import show_qr
|
||||
from apps.common.show import show_address, show_qr
|
||||
|
||||
|
||||
async def get_address(ctx, msg):
|
||||
@ -19,19 +14,9 @@ async def get_address(ctx, msg):
|
||||
|
||||
if msg.show_display:
|
||||
while True:
|
||||
if await _show_address(ctx, address, network):
|
||||
if await show_address(ctx, address, get_network_str(network)):
|
||||
break
|
||||
if await show_qr(ctx, address.upper()):
|
||||
break
|
||||
|
||||
return NEMAddress(address=address)
|
||||
|
||||
|
||||
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.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
|
||||
)
|
||||
|
@ -1,7 +1,7 @@
|
||||
from trezor import ui
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.ui.text import Text
|
||||
from trezor.utils import chunks, format_amount, split_words
|
||||
from trezor.utils import format_amount, split_words
|
||||
|
||||
from .helpers import NEM_MAX_DIVISIBILITY
|
||||
|
||||
@ -38,10 +38,6 @@ async def require_confirm_final(ctx, fee: int):
|
||||
await require_hold_to_confirm(ctx, text, ButtonRequestType.SignTx)
|
||||
|
||||
|
||||
def split_address(address: str):
|
||||
return chunks(address, 17)
|
||||
|
||||
|
||||
def trim(payload: str, length: int) -> str:
|
||||
if len(payload) > length:
|
||||
return payload[:length] + ".."
|
||||
|
@ -19,10 +19,11 @@ from ..layout import (
|
||||
require_confirm_fee,
|
||||
require_confirm_final,
|
||||
require_confirm_text,
|
||||
split_address,
|
||||
trim,
|
||||
)
|
||||
|
||||
from apps.common.show import split_address
|
||||
|
||||
|
||||
async def ask_mosaic_creation(
|
||||
ctx, common: NEMTransactionCommon, creation: NEMMosaicCreation
|
||||
|
@ -14,9 +14,10 @@ from ..layout import (
|
||||
require_confirm_fee,
|
||||
require_confirm_final,
|
||||
require_confirm_text,
|
||||
split_address,
|
||||
)
|
||||
|
||||
from apps.common.show import split_address
|
||||
|
||||
|
||||
async def ask_multisig(ctx, msg: NEMSignTx):
|
||||
address = nem.compute_address(msg.multisig.signer, msg.transaction.network)
|
||||
|
@ -16,10 +16,11 @@ from ..helpers import (
|
||||
NEM_MAX_DIVISIBILITY,
|
||||
NEM_MOSAIC_AMOUNT_DIVISOR,
|
||||
)
|
||||
from ..layout import require_confirm_final, require_confirm_text, split_address
|
||||
from ..layout import require_confirm_final, require_confirm_text
|
||||
from ..mosaic.helpers import get_mosaic_definition, is_nem_xem_mosaic
|
||||
|
||||
from apps.common.confirm import require_confirm
|
||||
from apps.common.show import split_address
|
||||
|
||||
|
||||
async def ask_transfer(
|
||||
|
Loading…
Reference in New Issue
Block a user