1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 14:28:07 +00:00

fix(core): unify button requests in modify amount flow

[no changelog]
This commit is contained in:
grdddj 2023-11-07 11:06:08 +01:00 committed by matejcik
parent 5b52db1ed3
commit 9a53ba9f44
7 changed files with 65 additions and 49 deletions

View File

@ -578,7 +578,6 @@ extern "C" fn new_confirm_joint_total(n_args: usize, args: *const Obj, kwargs: *
extern "C" fn new_confirm_modify_output(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
let block = move |_args: &[Obj], kwargs: &Map| {
let address: StrBuffer = kwargs.get(Qstr::MP_QSTR_address)?.try_into()?;
let sign: i32 = kwargs.get(Qstr::MP_QSTR_sign)?.try_into()?;
let amount_change: StrBuffer = kwargs.get(Qstr::MP_QSTR_amount_change)?.try_into()?;
let amount_new: StrBuffer = kwargs.get(Qstr::MP_QSTR_amount_new)?.try_into()?;
@ -590,8 +589,6 @@ extern "C" fn new_confirm_modify_output(n_args: usize, args: *const Obj, kwargs:
};
let paragraphs = Paragraphs::new([
Paragraph::new(&theme::TEXT_BOLD, "Address:".into()),
Paragraph::new(&theme::TEXT_MONO, address).break_after(),
Paragraph::new(&theme::TEXT_NORMAL, description.into()),
Paragraph::new(&theme::TEXT_MONO, amount_change).break_after(),
Paragraph::new(&theme::TEXT_BOLD, "New amount:".into()),
@ -1759,12 +1756,11 @@ pub static mp_module_trezorui2: Module = obj_module! {
/// def confirm_modify_output(
/// *,
/// address: str,
/// sign: int,
/// amount_change: str,
/// amount_new: str,
/// ) -> object:
/// """Decrease or increase amount for given address."""
/// """Decrease or increase output amount."""
Qstr::MP_QSTR_confirm_modify_output => obj_fn_kw!(0, new_confirm_modify_output).as_obj(),
/// def confirm_output_address(

View File

@ -1766,12 +1766,11 @@ pub static mp_module_trezorui2: Module = obj_module! {
/// def confirm_modify_output(
/// *,
/// address: str, # ignored
/// sign: int,
/// amount_change: str,
/// amount_new: str,
/// ) -> object:
/// """Decrease or increase amount for given address."""
/// """Decrease or increase output amount."""
Qstr::MP_QSTR_confirm_modify_output => obj_fn_kw!(0, new_confirm_modify_output).as_obj(),
/// def confirm_modify_fee(

View File

@ -128,12 +128,11 @@ def confirm_joint_total(
# rust/src/ui/model_tr/layout.rs
def confirm_modify_output(
*,
address: str,
sign: int,
amount_change: str,
amount_new: str,
) -> object:
"""Decrease or increase amount for given address."""
"""Decrease or increase output amount."""
# rust/src/ui/model_tr/layout.rs
@ -597,12 +596,11 @@ def confirm_total(
# rust/src/ui/model_tt/layout.rs
def confirm_modify_output(
*,
address: str, # ignored
sign: int,
amount_change: str,
amount_new: str,
) -> object:
"""Decrease or increase amount for given address."""
"""Decrease or increase output amount."""
# rust/src/ui/model_tt/layout.rs

View File

@ -1080,20 +1080,45 @@ async def confirm_modify_output(
amount_change: str,
amount_new: str,
) -> None:
await raise_if_not_confirmed(
interact(
RustLayout(
address_layout = RustLayout(
trezorui2.confirm_blob(
title="MODIFY AMOUNT",
data=address,
verb="CONTINUE",
verb_cancel=None,
description="Address:",
extra=None,
)
)
modify_layout = RustLayout(
trezorui2.confirm_modify_output(
address=address,
sign=sign,
amount_change=amount_change,
amount_new=amount_new,
)
),
)
send_button_request = True
while True:
if send_button_request:
await button_request(
"modify_output",
ButtonRequestType.ConfirmOutput,
address_layout.page_count(),
)
await raise_if_not_confirmed(ctx_wait(address_layout))
if send_button_request:
send_button_request = False
await button_request(
"modify_output",
ButtonRequestType.ConfirmOutput,
modify_layout.page_count(),
)
result = await ctx_wait(modify_layout)
if result is CONFIRMED:
break
async def confirm_modify_fee(

View File

@ -1033,16 +1033,7 @@ async def confirm_modify_output(
amount_change: str,
amount_new: str,
) -> None:
send_button_request = True
while True:
if send_button_request:
await button_request(
"modify_output",
ButtonRequestType.ConfirmOutput,
)
await raise_if_not_confirmed(
ctx_wait(
RustLayout(
address_layout = RustLayout(
trezorui2.confirm_blob(
title="MODIFY AMOUNT",
data=address,
@ -1052,25 +1043,32 @@ async def confirm_modify_output(
extra=None,
)
)
modify_layout = RustLayout(
trezorui2.confirm_modify_output(
sign=sign,
amount_change=amount_change,
amount_new=amount_new,
)
)
send_button_request = True
while True:
if send_button_request:
await button_request(
"modify_output",
ButtonRequestType.ConfirmOutput,
address_layout.page_count(),
)
await raise_if_not_confirmed(ctx_wait(address_layout))
if send_button_request:
send_button_request = False
await button_request(
"modify_output",
ButtonRequestType.ConfirmOutput,
modify_layout.page_count(),
)
result = await ctx_wait(
RustLayout(
trezorui2.confirm_modify_output(
address=address,
sign=sign,
amount_change=amount_change,
amount_new=amount_new,
)
),
)
result = await ctx_wait(modify_layout)
if result is CONFIRMED:
break

View File

@ -600,7 +600,6 @@ def test_p2wpkh_in_p2sh_fee_bump_from_external(client: Client):
orig_index=0,
)
is_tr = client.features.model == "Safe 3"
with client:
client.set_expected_responses(
[
@ -613,7 +612,7 @@ def test_p2wpkh_in_p2sh_fee_bump_from_external(client: Client):
request_output(0),
request_orig_output(0, TXHASH_334cd7),
messages.ButtonRequest(code=B.ConfirmOutput),
(not is_tr, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.ConfirmOutput),
request_orig_output(1, TXHASH_334cd7),
messages.ButtonRequest(code=B.SignTx),
request_input(0),

View File

@ -683,6 +683,7 @@ class InputFlowSignTxInformationReplacement(InputFlowBase):
self.debug.press_right()
self.debug.press_right()
self.debug.press_right()
yield
def lock_time_input_flow_tt(