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