mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-06-26 09:52:34 +00:00
refactor(core): convert apps.ripple to layouts
This commit is contained in:
parent
16094df0c5
commit
6aeaadfe16
@ -1,31 +1,33 @@
|
|||||||
from trezor import ui
|
|
||||||
from trezor.enums import ButtonRequestType
|
from trezor.enums import ButtonRequestType
|
||||||
from trezor.strings import format_amount
|
from trezor.strings import format_amount
|
||||||
from trezor.ui.components.tt.text import Text
|
from trezor.ui.layouts import confirm_metadata, confirm_total_ripple
|
||||||
|
|
||||||
from apps.common.confirm import require_confirm, require_hold_to_confirm
|
|
||||||
from apps.common.layout import split_address
|
|
||||||
|
|
||||||
from . import helpers
|
from . import helpers
|
||||||
|
|
||||||
|
|
||||||
async def require_confirm_fee(ctx, fee):
|
async def require_confirm_fee(ctx, fee):
|
||||||
text = Text("Confirm fee", ui.ICON_SEND, ui.GREEN)
|
await confirm_metadata(
|
||||||
text.normal("Transaction fee:")
|
ctx,
|
||||||
text.bold(format_amount(fee, helpers.DECIMALS) + " XRP")
|
"confirm_fee",
|
||||||
await require_confirm(ctx, text, ButtonRequestType.ConfirmOutput)
|
title="Confirm fee",
|
||||||
|
content="Transaction fee:\n{}",
|
||||||
|
param=format_amount(fee, helpers.DECIMALS) + " XRP",
|
||||||
|
hide_continue=True,
|
||||||
|
br_code=ButtonRequestType.ConfirmOutput,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def require_confirm_destination_tag(ctx, tag):
|
async def require_confirm_destination_tag(ctx, tag):
|
||||||
text = Text("Confirm tag", ui.ICON_SEND, ui.GREEN)
|
await confirm_metadata(
|
||||||
text.normal("Destination tag:")
|
ctx,
|
||||||
text.bold(str(tag))
|
"confirm_destination_tag",
|
||||||
await require_confirm(ctx, text, ButtonRequestType.ConfirmOutput)
|
title="Confirm tag",
|
||||||
|
content="Destination tag:\n{}",
|
||||||
|
param=str(tag),
|
||||||
|
hide_continue=True,
|
||||||
|
br_code=ButtonRequestType.ConfirmOutput,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def require_confirm_tx(ctx, to, value):
|
async def require_confirm_tx(ctx, to, value):
|
||||||
text = Text("Confirm sending", ui.ICON_SEND, ui.GREEN)
|
await confirm_total_ripple(ctx, to, format_amount(value, helpers.DECIMALS))
|
||||||
text.bold(format_amount(value, helpers.DECIMALS) + " XRP")
|
|
||||||
text.normal("to")
|
|
||||||
text.mono(*split_address(to))
|
|
||||||
await require_hold_to_confirm(ctx, text, ButtonRequestType.SignTx)
|
|
||||||
|
@ -54,6 +54,7 @@ __all__ = (
|
|||||||
"confirm_hex",
|
"confirm_hex",
|
||||||
"confirm_total",
|
"confirm_total",
|
||||||
"confirm_total_ethereum",
|
"confirm_total_ethereum",
|
||||||
|
"confirm_total_ripple",
|
||||||
"confirm_joint_total",
|
"confirm_joint_total",
|
||||||
"confirm_metadata",
|
"confirm_metadata",
|
||||||
"confirm_replacement",
|
"confirm_replacement",
|
||||||
@ -555,6 +556,23 @@ async def confirm_total_ethereum(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO cleanup @ redesign
|
||||||
|
async def confirm_total_ripple(
|
||||||
|
ctx: wire.GenericContext,
|
||||||
|
address: str,
|
||||||
|
amount: str,
|
||||||
|
) -> None:
|
||||||
|
title = "Confirm sending"
|
||||||
|
text = Text(title, ui.ICON_SEND, ui.GREEN, new_lines=False)
|
||||||
|
text.bold("{} XRP\n".format(amount))
|
||||||
|
text.normal("to\n")
|
||||||
|
text.mono(*_split_address(address))
|
||||||
|
|
||||||
|
await raise_if_cancelled(
|
||||||
|
interact(ctx, HoldToConfirm(text), "confirm_output", ButtonRequestType.SignTx)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def confirm_joint_total(
|
async def confirm_joint_total(
|
||||||
ctx: wire.GenericContext, spending_amount: str, total_amount: str
|
ctx: wire.GenericContext, spending_amount: str, total_amount: str
|
||||||
) -> None:
|
) -> None:
|
||||||
|
Loading…
Reference in New Issue
Block a user