mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-27 08:38:07 +00:00
core: require hold to confirm
This commit is contained in:
parent
6478b2705c
commit
aa71c20f2c
@ -13,7 +13,7 @@ from trezor.ui.text import Text
|
||||
|
||||
from . import helpers
|
||||
|
||||
from apps.common.confirm import hold_to_confirm
|
||||
from apps.common.confirm import require_hold_to_confirm
|
||||
from apps.common.layout import split_address
|
||||
|
||||
|
||||
@ -38,7 +38,9 @@ async def require_confirm_transfer(ctx, msg: BinanceTransferMsg):
|
||||
for txoutput in msg.outputs:
|
||||
pages.extend(make_input_output_pages(txoutput, "output"))
|
||||
|
||||
return await hold_to_confirm(ctx, Paginated(pages), ButtonRequestType.ConfirmOutput)
|
||||
return await require_hold_to_confirm(
|
||||
ctx, Paginated(pages), ButtonRequestType.ConfirmOutput
|
||||
)
|
||||
|
||||
|
||||
async def require_confirm_cancel(ctx, msg: BinanceCancelMsg):
|
||||
@ -52,7 +54,7 @@ async def require_confirm_cancel(ctx, msg: BinanceCancelMsg):
|
||||
page2.normal("Order ID:")
|
||||
page2.bold(msg.refid)
|
||||
|
||||
return await hold_to_confirm(
|
||||
return await require_hold_to_confirm(
|
||||
ctx, Paginated([page1, page2]), ButtonRequestType.SignTx
|
||||
)
|
||||
|
||||
@ -77,6 +79,6 @@ async def require_confirm_order(ctx, msg: BinanceOrderMsg):
|
||||
page3.normal("Price:")
|
||||
page3.bold(format_amount(msg.price, helpers.DECIMALS))
|
||||
|
||||
return await hold_to_confirm(
|
||||
return await require_hold_to_confirm(
|
||||
ctx, Paginated([page1, page2, page3]), ButtonRequestType.SignTx
|
||||
)
|
||||
|
@ -6,7 +6,7 @@ from trezor.ui.scroll import Paginated
|
||||
from trezor.ui.text import Text
|
||||
from trezor.utils import chunks
|
||||
|
||||
from apps.common.confirm import confirm, hold_to_confirm
|
||||
from apps.common.confirm import require_confirm, require_hold_to_confirm
|
||||
|
||||
|
||||
def format_coin_amount(amount):
|
||||
@ -32,7 +32,7 @@ async def confirm_sending(ctx, amount, to):
|
||||
t.bold(line)
|
||||
pages.append(t)
|
||||
|
||||
return await confirm(ctx, Paginated(pages))
|
||||
await require_confirm(ctx, Paginated(pages))
|
||||
|
||||
|
||||
async def confirm_transaction(ctx, amount, fee, network_name):
|
||||
@ -46,4 +46,4 @@ async def confirm_transaction(ctx, amount, fee, network_name):
|
||||
t2.normal("Network:")
|
||||
t2.bold(network_name)
|
||||
|
||||
return await hold_to_confirm(ctx, Paginated([t1, t2]))
|
||||
await require_hold_to_confirm(ctx, Paginated([t1, t2]))
|
||||
|
@ -47,19 +47,15 @@ async def show_tx(
|
||||
network_name: str,
|
||||
raw_inputs: list,
|
||||
raw_outputs: list,
|
||||
) -> bool:
|
||||
) -> None:
|
||||
for index, output in enumerate(outputs):
|
||||
if is_change(raw_outputs[index].address_n, raw_inputs):
|
||||
continue
|
||||
|
||||
if not await confirm_sending(ctx, outcoins[index], output):
|
||||
return False
|
||||
await confirm_sending(ctx, outcoins[index], output)
|
||||
|
||||
total_amount = sum(outcoins)
|
||||
if not await confirm_transaction(ctx, total_amount, fee, network_name):
|
||||
return False
|
||||
|
||||
return True
|
||||
await confirm_transaction(ctx, total_amount, fee, network_name)
|
||||
|
||||
|
||||
async def request_transaction(ctx, tx_req: CardanoTxRequest, index: int):
|
||||
@ -114,7 +110,7 @@ async def sign_tx(ctx, msg):
|
||||
raise wire.ProcessError("Signing failed")
|
||||
|
||||
# display the transaction in UI
|
||||
if not await show_tx(
|
||||
await show_tx(
|
||||
ctx,
|
||||
transaction.output_addresses,
|
||||
transaction.outgoing_coins,
|
||||
@ -122,8 +118,7 @@ async def sign_tx(ctx, msg):
|
||||
transaction.network_name,
|
||||
transaction.inputs,
|
||||
transaction.outputs,
|
||||
):
|
||||
raise wire.ActionCancelled("Signing cancelled")
|
||||
)
|
||||
|
||||
return tx
|
||||
|
||||
|
@ -11,7 +11,7 @@ from trezor.ui.num_input import NumInput
|
||||
from trezor.ui.scroll import Paginated
|
||||
from trezor.ui.text import Text
|
||||
|
||||
from apps.common.confirm import confirm, hold_to_confirm, require_confirm
|
||||
from apps.common.confirm import confirm, require_confirm, require_hold_to_confirm
|
||||
from apps.common.layout import show_success
|
||||
|
||||
if __debug__:
|
||||
@ -127,7 +127,7 @@ async def _show_share_words(ctx, share_words, share_index=None, group_index=None
|
||||
utils.ensure(share_words == shares_words_check)
|
||||
|
||||
# confirm the share
|
||||
await hold_to_confirm(ctx, paginated, ButtonRequestType.ResetDevice)
|
||||
await require_hold_to_confirm(ctx, paginated, ButtonRequestType.ResetDevice)
|
||||
|
||||
|
||||
def _split_share_into_pages(share_words):
|
||||
|
Loading…
Reference in New Issue
Block a user