mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 06:18:07 +00:00
fix(core): unify button requests in modify amount flow
[no changelog]
This commit is contained in:
parent
5b52db1ed3
commit
9a53ba9f44
@ -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(
|
||||
|
@ -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(
|
||||
|
@ -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
|
||||
|
@ -1080,20 +1080,45 @@ async def confirm_modify_output(
|
||||
amount_change: str,
|
||||
amount_new: str,
|
||||
) -> None:
|
||||
await raise_if_not_confirmed(
|
||||
interact(
|
||||
RustLayout(
|
||||
trezorui2.confirm_modify_output(
|
||||
address=address,
|
||||
sign=sign,
|
||||
amount_change=amount_change,
|
||||
amount_new=amount_new,
|
||||
)
|
||||
),
|
||||
"modify_output",
|
||||
ButtonRequestType.ConfirmOutput,
|
||||
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(
|
||||
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(
|
||||
|
@ -1033,44 +1033,42 @@ async def confirm_modify_output(
|
||||
amount_change: str,
|
||||
amount_new: str,
|
||||
) -> None:
|
||||
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(
|
||||
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(
|
||||
RustLayout(
|
||||
trezorui2.confirm_blob(
|
||||
title="MODIFY AMOUNT",
|
||||
data=address,
|
||||
verb="CONTINUE",
|
||||
verb_cancel=None,
|
||||
description="Address:",
|
||||
extra=None,
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
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
|
||||
|
@ -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),
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user