diff --git a/core/embed/rust/src/ui/api/firmware_upy.rs b/core/embed/rust/src/ui/api/firmware_upy.rs index fcece645f7..7b713c236c 100644 --- a/core/embed/rust/src/ui/api/firmware_upy.rs +++ b/core/embed/rust/src/ui/api/firmware_upy.rs @@ -80,6 +80,18 @@ extern "C" fn new_confirm_action(n_args: usize, args: *const Obj, kwargs: *mut M }; unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } } + +extern "C" fn new_confirm_coinjoin(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { + let block = move |_args: &[Obj], kwargs: &Map| { + let max_rounds: TString = kwargs.get(Qstr::MP_QSTR_max_rounds)?.try_into()?; + let max_feerate: TString = kwargs.get(Qstr::MP_QSTR_max_feerate)?.try_into()?; + + let layout = ModelUI::confirm_coinjoin(max_rounds, max_feerate)?; + Ok(LayoutObj::new_root(layout)?.into()) + }; + unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } +} + // TODO: there was `no_mangle` attribute in TT, should we apply it? extern "C" fn new_confirm_firmware_update( n_args: usize, @@ -496,6 +508,14 @@ pub static mp_module_trezorui_api: Module = obj_module! { /// """Confirm action.""" Qstr::MP_QSTR_confirm_action => obj_fn_kw!(0, new_confirm_action).as_obj(), + /// def confirm_coinjoin( + /// *, + /// max_rounds: str, + /// max_feerate: str, + /// ) -> LayoutObj[UiResult]: + /// """Confirm coinjoin authorization.""" + Qstr::MP_QSTR_confirm_coinjoin => obj_fn_kw!(0, new_confirm_coinjoin).as_obj(), + /// def confirm_firmware_update( /// *, /// description: str, diff --git a/core/embed/rust/src/ui/model_mercury/layout.rs b/core/embed/rust/src/ui/model_mercury/layout.rs index 5dd68a9364..a699b86515 100644 --- a/core/embed/rust/src/ui/model_mercury/layout.rs +++ b/core/embed/rust/src/ui/model_mercury/layout.rs @@ -908,37 +908,6 @@ extern "C" fn new_confirm_more(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_coinjoin(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { - let block = move |_args: &[Obj], kwargs: &Map| { - let max_rounds: TString = kwargs.get(Qstr::MP_QSTR_max_rounds)?.try_into()?; - let max_feerate: TString = kwargs.get(Qstr::MP_QSTR_max_feerate)?.try_into()?; - - let paragraphs = ParagraphVecShort::from_iter([ - Paragraph::new(&theme::TEXT_NORMAL, TR::coinjoin__max_rounds), - Paragraph::new(&theme::TEXT_MONO, max_rounds), - Paragraph::new(&theme::TEXT_NORMAL, TR::coinjoin__max_mining_fee), - Paragraph::new(&theme::TEXT_MONO, max_feerate), - ]) - .into_paragraphs(); - - new_confirm_action_simple( - paragraphs, - ConfirmActionMenu::new(None, false, None), - ConfirmActionStrings::new( - TR::coinjoin__title.into(), - None, - None, - Some(TR::coinjoin__title.into()), - ), - true, - None, - ) - .and_then(LayoutObj::new_root) - .map(Into::into) - }; - unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } -} - extern "C" fn new_continue_recovery(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { let block = move |_args: &[Obj], kwargs: &Map| { let first_screen: bool = kwargs.get(Qstr::MP_QSTR_first_screen)?.try_into()?; @@ -1271,14 +1240,6 @@ pub static mp_module_trezorui2: Module = obj_module! { /// Meant to be used with confirm_with_info.""" Qstr::MP_QSTR_confirm_more => obj_fn_kw!(0, new_confirm_more).as_obj(), - /// def confirm_coinjoin( - /// *, - /// max_rounds: str, - /// max_feerate: str, - /// ) -> LayoutObj[UiResult]: - /// """Confirm coinjoin authorization.""" - Qstr::MP_QSTR_confirm_coinjoin => obj_fn_kw!(0, new_confirm_coinjoin).as_obj(), - /// def flow_prompt_backup() -> LayoutObj[UiResult]: /// """Prompt a user to create backup with an option to skip.""" Qstr::MP_QSTR_flow_prompt_backup => obj_fn_0!(new_prompt_backup).as_obj(), diff --git a/core/embed/rust/src/ui/model_mercury/ui_features_fw.rs b/core/embed/rust/src/ui/model_mercury/ui_features_fw.rs index a209421cf9..c2196a2fbd 100644 --- a/core/embed/rust/src/ui/model_mercury/ui_features_fw.rs +++ b/core/embed/rust/src/ui/model_mercury/ui_features_fw.rs @@ -98,6 +98,33 @@ impl UIFeaturesFirmware for ModelMercuryFeatures { Ok(layout) } + fn confirm_coinjoin( + max_rounds: TString<'static>, + max_feerate: TString<'static>, + ) -> Result { + let paragraphs = ParagraphVecShort::from_iter([ + Paragraph::new(&theme::TEXT_NORMAL, TR::coinjoin__max_rounds), + Paragraph::new(&theme::TEXT_MONO, max_rounds), + Paragraph::new(&theme::TEXT_NORMAL, TR::coinjoin__max_mining_fee), + Paragraph::new(&theme::TEXT_MONO, max_feerate), + ]) + .into_paragraphs(); + + let flow = flow::new_confirm_action_simple( + paragraphs, + ConfirmActionMenu::new(None, false, None), + ConfirmActionStrings::new( + TR::coinjoin__title.into(), + None, + None, + Some(TR::coinjoin__title.into()), + ), + true, + None, + )?; + Ok(flow) + } + fn confirm_firmware_update( description: TString<'static>, fingerprint: TString<'static>, diff --git a/core/embed/rust/src/ui/model_tr/layout.rs b/core/embed/rust/src/ui/model_tr/layout.rs index 00b0d1a719..65775996d8 100644 --- a/core/embed/rust/src/ui/model_tr/layout.rs +++ b/core/embed/rust/src/ui/model_tr/layout.rs @@ -1026,32 +1026,6 @@ extern "C" fn new_confirm_more(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_coinjoin(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { - let block = move |_args: &[Obj], kwargs: &Map| { - let max_rounds: TString = kwargs.get(Qstr::MP_QSTR_max_rounds)?.try_into()?; - let max_feerate: TString = kwargs.get(Qstr::MP_QSTR_max_feerate)?.try_into()?; - - // Decreasing bottom padding between paragraphs to fit one screen - let paragraphs = Paragraphs::new([ - Paragraph::new(&theme::TEXT_BOLD, TR::coinjoin__max_rounds).with_bottom_padding(2), - Paragraph::new(&theme::TEXT_MONO, max_rounds), - Paragraph::new(&theme::TEXT_BOLD, TR::coinjoin__max_mining_fee) - .with_bottom_padding(2) - .no_break(), - Paragraph::new(&theme::TEXT_MONO, max_feerate).with_bottom_padding(2), - ]); - - content_in_button_page( - TR::coinjoin__title.into(), - paragraphs, - TR::buttons__hold_to_confirm.into(), - None, - true, - ) - }; - unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } -} - extern "C" fn new_show_share_words(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { let block = |_args: &[Obj], kwargs: &Map| { let share_words_obj: Obj = kwargs.get(Qstr::MP_QSTR_share_words)?; @@ -1343,14 +1317,6 @@ pub static mp_module_trezorui2: Module = obj_module! { /// Meant to be used with confirm_with_info.""" Qstr::MP_QSTR_confirm_more => obj_fn_kw!(0, new_confirm_more).as_obj(), - /// def confirm_coinjoin( - /// *, - /// max_rounds: str, - /// max_feerate: str, - /// ) -> LayoutObj[UiResult]: - /// """Confirm coinjoin authorization.""" - Qstr::MP_QSTR_confirm_coinjoin => obj_fn_kw!(0, new_confirm_coinjoin).as_obj(), - /// def show_share_words( /// *, /// share_words: Iterable[str], diff --git a/core/embed/rust/src/ui/model_tr/ui_features_fw.rs b/core/embed/rust/src/ui/model_tr/ui_features_fw.rs index 96e94c0931..a39bc59a36 100644 --- a/core/embed/rust/src/ui/model_tr/ui_features_fw.rs +++ b/core/embed/rust/src/ui/model_tr/ui_features_fw.rs @@ -89,6 +89,29 @@ impl UIFeaturesFirmware for ModelTRFeatures { Ok(layout) } + fn confirm_coinjoin( + max_rounds: TString<'static>, + max_feerate: TString<'static>, + ) -> Result { + // Decreasing bottom padding between paragraphs to fit one screen + let paragraphs = Paragraphs::new([ + Paragraph::new(&theme::TEXT_BOLD, TR::coinjoin__max_rounds).with_bottom_padding(2), + Paragraph::new(&theme::TEXT_MONO, max_rounds), + Paragraph::new(&theme::TEXT_BOLD, TR::coinjoin__max_mining_fee) + .with_bottom_padding(2) + .no_break(), + Paragraph::new(&theme::TEXT_MONO, max_feerate).with_bottom_padding(2), + ]); + + content_in_button_page( + TR::coinjoin__title.into(), + paragraphs, + TR::buttons__hold_to_confirm.into(), + None, + true, + ) + } + fn confirm_firmware_update( description: TString<'static>, fingerprint: TString<'static>, diff --git a/core/embed/rust/src/ui/model_tt/layout.rs b/core/embed/rust/src/ui/model_tt/layout.rs index 6b47aef134..8c5de8d4df 100644 --- a/core/embed/rust/src/ui/model_tt/layout.rs +++ b/core/embed/rust/src/ui/model_tt/layout.rs @@ -1033,28 +1033,6 @@ extern "C" fn new_confirm_more(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_coinjoin(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { - let block = move |_args: &[Obj], kwargs: &Map| { - let max_rounds: TString = kwargs.get(Qstr::MP_QSTR_max_rounds)?.try_into()?; - let max_feerate: TString = kwargs.get(Qstr::MP_QSTR_max_feerate)?.try_into()?; - - let paragraphs = Paragraphs::new([ - Paragraph::new(&theme::TEXT_NORMAL, TR::coinjoin__max_rounds), - Paragraph::new(&theme::TEXT_MONO, max_rounds), - Paragraph::new(&theme::TEXT_NORMAL, TR::coinjoin__max_mining_fee), - Paragraph::new(&theme::TEXT_MONO, max_feerate), - ]); - - let obj = LayoutObj::new(Frame::left_aligned( - theme::label_title(), - TR::coinjoin__title.into(), - ButtonPage::new(paragraphs, theme::BG).with_hold()?, - ))?; - Ok(obj.into()) - }; - unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } -} - extern "C" fn new_show_share_words(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { let block = move |_args: &[Obj], kwargs: &Map| { let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?; @@ -1374,14 +1352,6 @@ pub static mp_module_trezorui2: Module = obj_module! { /// Meant to be used with confirm_with_info.""" Qstr::MP_QSTR_confirm_more => obj_fn_kw!(0, new_confirm_more).as_obj(), - /// def confirm_coinjoin( - /// *, - /// max_rounds: str, - /// max_feerate: str, - /// ) -> LayoutObj[UiResult]: - /// """Confirm coinjoin authorization.""" - Qstr::MP_QSTR_confirm_coinjoin => obj_fn_kw!(0, new_confirm_coinjoin).as_obj(), - /// def show_share_words( /// *, /// title: str, diff --git a/core/embed/rust/src/ui/model_tt/ui_features_fw.rs b/core/embed/rust/src/ui/model_tt/ui_features_fw.rs index dcdff4d91c..c4dade3747 100644 --- a/core/embed/rust/src/ui/model_tt/ui_features_fw.rs +++ b/core/embed/rust/src/ui/model_tt/ui_features_fw.rs @@ -99,6 +99,25 @@ impl UIFeaturesFirmware for ModelTTFeatures { Ok(layout) } + fn confirm_coinjoin( + max_rounds: TString<'static>, + max_feerate: TString<'static>, + ) -> Result { + let paragraphs = Paragraphs::new([ + Paragraph::new(&theme::TEXT_NORMAL, TR::coinjoin__max_rounds), + Paragraph::new(&theme::TEXT_MONO, max_rounds), + Paragraph::new(&theme::TEXT_NORMAL, TR::coinjoin__max_mining_fee), + Paragraph::new(&theme::TEXT_MONO, max_feerate), + ]); + + let layout = RootComponent::new(Frame::left_aligned( + theme::label_title(), + TR::coinjoin__title.into(), + ButtonPage::new(paragraphs, theme::BG).with_hold()?, + )); + Ok(layout) + } + fn confirm_firmware_update( description: TString<'static>, fingerprint: TString<'static>, diff --git a/core/embed/rust/src/ui/ui_features_fw.rs b/core/embed/rust/src/ui/ui_features_fw.rs index f719c2b6da..c4db947c90 100644 --- a/core/embed/rust/src/ui/ui_features_fw.rs +++ b/core/embed/rust/src/ui/ui_features_fw.rs @@ -25,6 +25,11 @@ pub trait UIFeaturesFirmware { image: BinaryData<'static>, ) -> Result; + fn confirm_coinjoin( + max_rounds: TString<'static>, + max_feerate: TString<'static>, + ) -> Result; + fn confirm_firmware_update( description: TString<'static>, fingerprint: TString<'static>, diff --git a/core/mocks/generated/trezorui2.pyi b/core/mocks/generated/trezorui2.pyi index c84dd0ef1e..0af3cf7bf8 100644 --- a/core/mocks/generated/trezorui2.pyi +++ b/core/mocks/generated/trezorui2.pyi @@ -214,15 +214,6 @@ def confirm_more( Meant to be used with confirm_with_info.""" -# rust/src/ui/model_mercury/layout.rs -def confirm_coinjoin( - *, - max_rounds: str, - max_feerate: str, -) -> LayoutObj[UiResult]: - """Confirm coinjoin authorization.""" - - # rust/src/ui/model_mercury/layout.rs def flow_prompt_backup() -> LayoutObj[UiResult]: """Prompt a user to create backup with an option to skip.""" @@ -550,15 +541,6 @@ def confirm_more( Meant to be used with confirm_with_info.""" -# rust/src/ui/model_tr/layout.rs -def confirm_coinjoin( - *, - max_rounds: str, - max_feerate: str, -) -> LayoutObj[UiResult]: - """Confirm coinjoin authorization.""" - - # rust/src/ui/model_tr/layout.rs def show_share_words( *, @@ -836,15 +818,6 @@ def confirm_more( Meant to be used with confirm_with_info.""" -# rust/src/ui/model_tt/layout.rs -def confirm_coinjoin( - *, - max_rounds: str, - max_feerate: str, -) -> LayoutObj[UiResult]: - """Confirm coinjoin authorization.""" - - # rust/src/ui/model_tt/layout.rs def show_share_words( *, diff --git a/core/mocks/generated/trezorui_api.pyi b/core/mocks/generated/trezorui_api.pyi index fb8fd4a73b..eef24c70b3 100644 --- a/core/mocks/generated/trezorui_api.pyi +++ b/core/mocks/generated/trezorui_api.pyi @@ -96,6 +96,15 @@ def confirm_action( """Confirm action.""" +# rust/src/ui/api/firmware_upy.rs +def confirm_coinjoin( + *, + max_rounds: str, + max_feerate: str, +) -> LayoutObj[UiResult]: + """Confirm coinjoin authorization.""" + + # rust/src/ui/api/firmware_upy.rs def confirm_firmware_update( *, diff --git a/core/src/trezor/ui/layouts/mercury/__init__.py b/core/src/trezor/ui/layouts/mercury/__init__.py index f764da85df..e85dc7b5bf 100644 --- a/core/src/trezor/ui/layouts/mercury/__init__.py +++ b/core/src/trezor/ui/layouts/mercury/__init__.py @@ -966,7 +966,7 @@ def confirm_modify_fee( def confirm_coinjoin(max_rounds: int, max_fee_per_vbyte: str) -> Awaitable[None]: return raise_if_not_confirmed( - trezorui2.confirm_coinjoin( + trezorui_api.confirm_coinjoin( max_rounds=str(max_rounds), max_feerate=max_fee_per_vbyte, ), diff --git a/core/src/trezor/ui/layouts/tr/__init__.py b/core/src/trezor/ui/layouts/tr/__init__.py index 22e96eaad0..c0b22fa2f2 100644 --- a/core/src/trezor/ui/layouts/tr/__init__.py +++ b/core/src/trezor/ui/layouts/tr/__init__.py @@ -1047,7 +1047,7 @@ def confirm_modify_fee( def confirm_coinjoin(max_rounds: int, max_fee_per_vbyte: str) -> Awaitable[None]: return raise_if_not_confirmed( - trezorui2.confirm_coinjoin( + trezorui_api.confirm_coinjoin( max_rounds=str(max_rounds), max_feerate=max_fee_per_vbyte, ), diff --git a/core/src/trezor/ui/layouts/tt/__init__.py b/core/src/trezor/ui/layouts/tt/__init__.py index bdbcb11772..dd5a6cb741 100644 --- a/core/src/trezor/ui/layouts/tt/__init__.py +++ b/core/src/trezor/ui/layouts/tt/__init__.py @@ -1012,7 +1012,7 @@ def confirm_modify_fee( def confirm_coinjoin(max_rounds: int, max_fee_per_vbyte: str) -> Awaitable[None]: return raise_if_not_confirmed( - trezorui2.confirm_coinjoin( + trezorui_api.confirm_coinjoin( max_rounds=str(max_rounds), max_feerate=max_fee_per_vbyte, ),