diff --git a/core/embed/rust/librust_qstr.h b/core/embed/rust/librust_qstr.h index 584d42d9b..0435e810c 100644 --- a/core/embed/rust/librust_qstr.h +++ b/core/embed/rust/librust_qstr.h @@ -23,10 +23,10 @@ static void _librust_qstrs(void) { MP_QSTR_confirm_modify_fee; MP_QSTR_confirm_modify_output; MP_QSTR_confirm_output; - MP_QSTR_confirm_payment_request; MP_QSTR_confirm_reset_device; MP_QSTR_confirm_text; MP_QSTR_confirm_total; + MP_QSTR_confirm_with_info; MP_QSTR_show_checklist; MP_QSTR_show_error; MP_QSTR_show_qr; @@ -84,4 +84,5 @@ static void _librust_qstrs(void) { MP_QSTR_max_count; MP_QSTR_items; MP_QSTR_active; + MP_QSTR_info_button; } diff --git a/core/embed/rust/src/ui/model_tt/layout.rs b/core/embed/rust/src/ui/model_tt/layout.rs index 35268be38..c3a5c00df 100644 --- a/core/embed/rust/src/ui/model_tt/layout.rs +++ b/core/embed/rust/src/ui/model_tt/layout.rs @@ -610,29 +610,27 @@ extern "C" fn new_show_simple(n_args: usize, args: *const Obj, kwargs: *mut Map) unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } } -extern "C" fn new_confirm_payment_request( - n_args: usize, - args: *const Obj, - kwargs: *mut Map, -) -> Obj { +extern "C" fn new_confirm_with_info(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { let block = move |_args: &[Obj], kwargs: &Map| { - let description: StrBuffer = kwargs.get(Qstr::MP_QSTR_description)?.try_into()?; - let memos: Obj = kwargs.get(Qstr::MP_QSTR_memos)?; + let title: StrBuffer = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?; + let button: StrBuffer = kwargs.get(Qstr::MP_QSTR_button)?.try_into()?; + let info_button: StrBuffer = kwargs.get(Qstr::MP_QSTR_info_button)?.try_into()?; + let items: Obj = kwargs.get(Qstr::MP_QSTR_items)?; - let mut paragraphs = Paragraphs::new().add(theme::TEXT_NORMAL, description); + let mut paragraphs = Paragraphs::new(); let mut iter_buf = IterBuf::new(); - let iter = Iter::try_from_obj_with_buf(memos, &mut iter_buf)?; - for memo in iter { - let text: StrBuffer = memo.try_into()?; + let iter = Iter::try_from_obj_with_buf(items, &mut iter_buf)?; + for text in iter { + let text: StrBuffer = text.try_into()?; paragraphs = paragraphs.add(theme::TEXT_NORMAL, text); } - let buttons = Button::cancel_info_confirm("CONFIRM", "DETAILS"); + let buttons = Button::cancel_info_confirm(button, info_button); let obj = LayoutObj::new( Frame::new( - "SENDING", + title, SwipePage::new(paragraphs, buttons, theme::BG).with_button_rows(2), ) .into_child(), @@ -988,13 +986,15 @@ pub static mp_module_trezorui2: Module = obj_module! { /// """Simple dialog with text and one button.""" Qstr::MP_QSTR_show_simple => obj_fn_kw!(0, new_show_simple).as_obj(), - /// def confirm_payment_request( + /// def confirm_with_info( /// *, - /// description: str, - /// memos: Iterable[str], + /// title: str, + /// button: str, + /// info_button: str, + /// items: Iterable[str], /// ) -> object: - /// """Confirm payment request.""" - Qstr::MP_QSTR_confirm_payment_request => obj_fn_kw!(0, new_confirm_payment_request).as_obj(), + /// """Confirm action but with third button.""" + Qstr::MP_QSTR_confirm_with_info => obj_fn_kw!(0, new_confirm_with_info).as_obj(), /// def confirm_coinjoin( /// *, diff --git a/core/mocks/generated/trezorui2.pyi b/core/mocks/generated/trezorui2.pyi index ee493eb44..1e4e0bb16 100644 --- a/core/mocks/generated/trezorui2.pyi +++ b/core/mocks/generated/trezorui2.pyi @@ -210,12 +210,14 @@ def show_simple( # rust/src/ui/model_tt/layout.rs -def confirm_payment_request( +def confirm_with_info( *, - description: str, - memos: Iterable[str], + title: str, + button: str, + info_button: str, + items: Iterable[str], ) -> object: - """Confirm payment request.""" + """Confirm action but with third button.""" # rust/src/ui/model_tt/layout.rs diff --git a/core/src/trezor/ui/layouts/tt_v2/__init__.py b/core/src/trezor/ui/layouts/tt_v2/__init__.py index 9edfe9389..192944dbd 100644 --- a/core/src/trezor/ui/layouts/tt_v2/__init__.py +++ b/core/src/trezor/ui/layouts/tt_v2/__init__.py @@ -526,9 +526,11 @@ async def confirm_payment_request( result = await interact( ctx, _RustLayout( - trezorui2.confirm_payment_request( - description=f"{amount} to\n{recipient_name}", - memos=memos, + trezorui2.confirm_with_info( + title="SENDING", + items=[f"{amount} to\n{recipient_name}"] + memos, + button="CONFIRM", + info_button="DETAILS", ) ), "confirm_payment_request", @@ -554,7 +556,39 @@ async def should_show_more( confirm: str | bytes | None = None, major_confirm: bool = False, ) -> bool: - raise NotImplementedError + """Return True if the user wants to show more (they click a special button) + and False when the user wants to continue without showing details. + + Raises ActionCancelled if the user cancels. + """ + if confirm is None or not isinstance(confirm, str): + confirm = "CONFIRM" + + items = [] + for _font, text in para: + items.append(text) + + result = await interact( + ctx, + _RustLayout( + trezorui2.confirm_with_info( + title=title.upper(), + items=items, + button=confirm.upper(), + info_button=button_text.upper(), + ) + ), + br_type, + br_code, + ) + + if result is trezorui2.CONFIRMED: + return False + elif result is trezorui2.INFO: + return True + else: + assert result is trezorui2.CANCELLED + raise wire.ActionCancelled async def confirm_blob(