mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-18 05:28:40 +00:00
refactor(core/ui): more consistent layout parameter names
This commit is contained in:
parent
d33c61bbe7
commit
ffb400180d
@ -18,7 +18,7 @@ async def get_address(ctx, msg: BinanceGetAddress, keychain: Keychain):
|
|||||||
pubkey = node.public_key()
|
pubkey = node.public_key()
|
||||||
address = address_from_public_key(pubkey, HRP)
|
address = address_from_public_key(pubkey, HRP)
|
||||||
if msg.show_display:
|
if msg.show_display:
|
||||||
desc = address_n_to_str(msg.address_n)
|
title = address_n_to_str(msg.address_n)
|
||||||
await show_address(ctx, address=address, address_qr=address, desc=desc)
|
await show_address(ctx, address=address, address_qr=address, title=title)
|
||||||
|
|
||||||
return BinanceAddress(address=address)
|
return BinanceAddress(address=address)
|
||||||
|
@ -82,19 +82,19 @@ async def get_address(
|
|||||||
pubnodes = [hd.node for hd in msg.multisig.pubkeys]
|
pubnodes = [hd.node for hd in msg.multisig.pubkeys]
|
||||||
multisig_index = multisig_pubkey_index(msg.multisig, node.public_key())
|
multisig_index = multisig_pubkey_index(msg.multisig, node.public_key())
|
||||||
|
|
||||||
desc = "Multisig %d of %d" % (msg.multisig.m, len(pubnodes))
|
title = "Multisig %d of %d" % (msg.multisig.m, len(pubnodes))
|
||||||
await show_address(
|
await show_address(
|
||||||
ctx,
|
ctx,
|
||||||
address=address_short,
|
address=address_short,
|
||||||
address_qr=address_qr,
|
address_qr=address_qr,
|
||||||
desc=desc,
|
title=title,
|
||||||
multisig_index=multisig_index,
|
multisig_index=multisig_index,
|
||||||
xpubs=_get_xpubs(coin, multisig_xpub_magic, pubnodes),
|
xpubs=_get_xpubs(coin, multisig_xpub_magic, pubnodes),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
desc = address_n_to_str(msg.address_n)
|
title = address_n_to_str(msg.address_n)
|
||||||
await show_address(
|
await show_address(
|
||||||
ctx, address=address_short, address_qr=address_qr, desc=desc
|
ctx, address=address_short, address_qr=address_qr, title=title
|
||||||
)
|
)
|
||||||
|
|
||||||
return Address(address=address)
|
return Address(address=address)
|
||||||
|
@ -27,7 +27,7 @@ async def get_address(ctx, msg, keychain):
|
|||||||
address = address_from_bytes(address_bytes, network)
|
address = address_from_bytes(address_bytes, network)
|
||||||
|
|
||||||
if msg.show_display:
|
if msg.show_display:
|
||||||
desc = address_n_to_str(msg.address_n)
|
title = address_n_to_str(msg.address_n)
|
||||||
await show_address(ctx, address=address, address_qr=address, desc=desc)
|
await show_address(ctx, address=address, address_qr=address, title=title)
|
||||||
|
|
||||||
return EthereumAddress(address=address)
|
return EthereumAddress(address=address)
|
||||||
|
@ -18,7 +18,7 @@ async def get_address(ctx, msg, keychain):
|
|||||||
address = get_address_from_public_key(pubkey)
|
address = get_address_from_public_key(pubkey)
|
||||||
|
|
||||||
if msg.show_display:
|
if msg.show_display:
|
||||||
desc = address_n_to_str(msg.address_n)
|
title = address_n_to_str(msg.address_n)
|
||||||
await show_address(ctx, address=address, address_qr=address, desc=desc)
|
await show_address(ctx, address=address, address_qr=address, title=title)
|
||||||
|
|
||||||
return LiskAddress(address=address)
|
return LiskAddress(address=address)
|
||||||
|
@ -41,12 +41,12 @@ async def get_address(ctx, msg, keychain):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if msg.show_display:
|
if msg.show_display:
|
||||||
desc = address_n_to_str(msg.address_n)
|
title = address_n_to_str(msg.address_n)
|
||||||
await show_address(
|
await show_address(
|
||||||
ctx,
|
ctx,
|
||||||
address=addr.decode(),
|
address=addr.decode(),
|
||||||
address_qr="monero:" + addr.decode(),
|
address_qr="monero:" + addr.decode(),
|
||||||
desc=desc,
|
title=title,
|
||||||
)
|
)
|
||||||
|
|
||||||
return MoneroAddress(address=addr)
|
return MoneroAddress(address=addr)
|
||||||
|
@ -21,12 +21,12 @@ async def get_address(ctx, msg, keychain):
|
|||||||
address = node.nem_address(network)
|
address = node.nem_address(network)
|
||||||
|
|
||||||
if msg.show_display:
|
if msg.show_display:
|
||||||
desc = address_n_to_str(msg.address_n)
|
title = address_n_to_str(msg.address_n)
|
||||||
await show_address(
|
await show_address(
|
||||||
ctx,
|
ctx,
|
||||||
address=address,
|
address=address,
|
||||||
address_qr=address.upper(),
|
address_qr=address.upper(),
|
||||||
desc=desc,
|
title=title,
|
||||||
network=get_network_str(network),
|
network=get_network_str(network),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ async def get_address(ctx, msg: RippleGetAddress, keychain):
|
|||||||
address = address_from_public_key(pubkey)
|
address = address_from_public_key(pubkey)
|
||||||
|
|
||||||
if msg.show_display:
|
if msg.show_display:
|
||||||
desc = address_n_to_str(msg.address_n)
|
title = address_n_to_str(msg.address_n)
|
||||||
await show_address(ctx, address=address, address_qr=address, desc=desc)
|
await show_address(ctx, address=address, address_qr=address, title=title)
|
||||||
|
|
||||||
return RippleAddress(address=address)
|
return RippleAddress(address=address)
|
||||||
|
@ -17,7 +17,9 @@ async def get_address(ctx, msg: StellarGetAddress, keychain):
|
|||||||
address = helpers.address_from_public_key(pubkey)
|
address = helpers.address_from_public_key(pubkey)
|
||||||
|
|
||||||
if msg.show_display:
|
if msg.show_display:
|
||||||
desc = address_n_to_str(msg.address_n)
|
title = address_n_to_str(msg.address_n)
|
||||||
await show_address(ctx, address=address, address_qr=address.upper(), desc=desc)
|
await show_address(
|
||||||
|
ctx, address=address, address_qr=address.upper(), title=title
|
||||||
|
)
|
||||||
|
|
||||||
return StellarAddress(address=address)
|
return StellarAddress(address=address)
|
||||||
|
@ -22,7 +22,7 @@ async def get_address(ctx, msg, keychain):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if msg.show_display:
|
if msg.show_display:
|
||||||
desc = address_n_to_str(msg.address_n)
|
title = address_n_to_str(msg.address_n)
|
||||||
await show_address(ctx, address=address, address_qr=address, desc=desc)
|
await show_address(ctx, address=address, address_qr=address, title=title)
|
||||||
|
|
||||||
return TezosAddress(address=address)
|
return TezosAddress(address=address)
|
||||||
|
@ -199,12 +199,12 @@ async def confirm_path_warning(ctx: wire.GenericContext, path: str) -> None:
|
|||||||
|
|
||||||
def _show_qr(
|
def _show_qr(
|
||||||
address: str,
|
address: str,
|
||||||
desc: str,
|
title: str,
|
||||||
cancel: str = "Address",
|
cancel: str = "Address",
|
||||||
) -> Confirm:
|
) -> Confirm:
|
||||||
QR_COEF = const(4) if len(address) < QR_SIZE_THRESHOLD else const(3)
|
QR_COEF = const(4) if len(address) < QR_SIZE_THRESHOLD else const(3)
|
||||||
qr = Qr(address, QR_X, QR_Y, QR_COEF)
|
qr = Qr(address, QR_X, QR_Y, QR_COEF)
|
||||||
text = Text(desc, ui.ICON_RECEIVE, ui.GREEN)
|
text = Text(title, ui.ICON_RECEIVE, ui.GREEN)
|
||||||
|
|
||||||
return Confirm(Container(qr, text), cancel=cancel, cancel_style=ButtonDefault)
|
return Confirm(Container(qr, text), cancel=cancel, cancel_style=ButtonDefault)
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ def _truncate_hex(
|
|||||||
|
|
||||||
def _show_address(
|
def _show_address(
|
||||||
address: str,
|
address: str,
|
||||||
desc: str,
|
title: str,
|
||||||
network: str | None = None,
|
network: str | None = None,
|
||||||
) -> Confirm | Paginated:
|
) -> Confirm | Paginated:
|
||||||
para = [(ui.NORMAL, "%s network" % network)] if network is not None else []
|
para = [(ui.NORMAL, "%s network" % network)] if network is not None else []
|
||||||
@ -244,17 +244,17 @@ def _show_address(
|
|||||||
)
|
)
|
||||||
return paginate_paragraphs(
|
return paginate_paragraphs(
|
||||||
para,
|
para,
|
||||||
header=desc,
|
header=title,
|
||||||
header_icon=ui.ICON_RECEIVE,
|
header_icon=ui.ICON_RECEIVE,
|
||||||
icon_color=ui.GREEN,
|
icon_color=ui.GREEN,
|
||||||
confirm_kwargs={"cancel": "QR", "cancel_style": ButtonDefault},
|
confirm_kwargs={"cancel": "QR", "cancel_style": ButtonDefault},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _show_xpub(xpub: str, desc: str, cancel: str) -> Paginated:
|
def _show_xpub(xpub: str, title: str, cancel: str) -> Paginated:
|
||||||
pages: list[ui.Component] = []
|
pages: list[ui.Component] = []
|
||||||
for lines in chunks(list(chunks_intersperse(xpub, 16)), TEXT_MAX_LINES * 2):
|
for lines in chunks(list(chunks_intersperse(xpub, 16)), TEXT_MAX_LINES * 2):
|
||||||
text = Text(desc, ui.ICON_RECEIVE, ui.GREEN, new_lines=False)
|
text = Text(title, ui.ICON_RECEIVE, ui.GREEN, new_lines=False)
|
||||||
text.mono(*lines)
|
text.mono(*lines)
|
||||||
pages.append(text)
|
pages.append(text)
|
||||||
|
|
||||||
@ -270,12 +270,12 @@ def _show_xpub(xpub: str, desc: str, cancel: str) -> Paginated:
|
|||||||
|
|
||||||
|
|
||||||
async def show_xpub(
|
async def show_xpub(
|
||||||
ctx: wire.GenericContext, xpub: str, desc: str, cancel: str
|
ctx: wire.GenericContext, xpub: str, title: str, cancel: str
|
||||||
) -> None:
|
) -> None:
|
||||||
await raise_if_cancelled(
|
await raise_if_cancelled(
|
||||||
interact(
|
interact(
|
||||||
ctx,
|
ctx,
|
||||||
_show_xpub(xpub, desc, cancel),
|
_show_xpub(xpub, title, cancel),
|
||||||
"show_xpub",
|
"show_xpub",
|
||||||
ButtonRequestType.PublicKey,
|
ButtonRequestType.PublicKey,
|
||||||
)
|
)
|
||||||
@ -286,7 +286,7 @@ async def show_address(
|
|||||||
ctx: wire.GenericContext,
|
ctx: wire.GenericContext,
|
||||||
address: str,
|
address: str,
|
||||||
address_qr: str | None = None,
|
address_qr: str | None = None,
|
||||||
desc: str = "Confirm address",
|
title: str = "Confirm address",
|
||||||
network: str | None = None,
|
network: str | None = None,
|
||||||
multisig_index: int | None = None,
|
multisig_index: int | None = None,
|
||||||
xpubs: Sequence[str] = [],
|
xpubs: Sequence[str] = [],
|
||||||
@ -296,7 +296,11 @@ async def show_address(
|
|||||||
if is_confirmed(
|
if is_confirmed(
|
||||||
await interact(
|
await interact(
|
||||||
ctx,
|
ctx,
|
||||||
_show_address(address, desc, network),
|
_show_address(
|
||||||
|
address,
|
||||||
|
title,
|
||||||
|
network,
|
||||||
|
),
|
||||||
"show_address",
|
"show_address",
|
||||||
ButtonRequestType.Address,
|
ButtonRequestType.Address,
|
||||||
)
|
)
|
||||||
@ -307,7 +311,7 @@ async def show_address(
|
|||||||
ctx,
|
ctx,
|
||||||
_show_qr(
|
_show_qr(
|
||||||
address if address_qr is None else address_qr,
|
address if address_qr is None else address_qr,
|
||||||
desc,
|
title,
|
||||||
cancel="XPUBs" if is_multisig else "Address",
|
cancel="XPUBs" if is_multisig else "Address",
|
||||||
),
|
),
|
||||||
"show_qr",
|
"show_qr",
|
||||||
@ -319,12 +323,12 @@ async def show_address(
|
|||||||
if is_multisig:
|
if is_multisig:
|
||||||
for i, xpub in enumerate(xpubs):
|
for i, xpub in enumerate(xpubs):
|
||||||
cancel = "Next" if i < len(xpubs) - 1 else "Address"
|
cancel = "Next" if i < len(xpubs) - 1 else "Address"
|
||||||
desc_xpub = "XPUB #%d" % (i + 1)
|
title_xpub = "XPUB #%d" % (i + 1)
|
||||||
desc_xpub += " (yours)" if i == multisig_index else " (cosigner)"
|
title_xpub += " (yours)" if i == multisig_index else " (cosigner)"
|
||||||
if is_confirmed(
|
if is_confirmed(
|
||||||
await interact(
|
await interact(
|
||||||
ctx,
|
ctx,
|
||||||
_show_xpub(xpub, desc=desc_xpub, cancel=cancel),
|
_show_xpub(xpub, title=title_xpub, cancel=cancel),
|
||||||
"show_xpub",
|
"show_xpub",
|
||||||
ButtonRequestType.PublicKey,
|
ButtonRequestType.PublicKey,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user