diff --git a/core/embed/rust/src/ui/api/firmware_upy.rs b/core/embed/rust/src/ui/api/firmware_upy.rs index 7b713c236c..6384b270f1 100644 --- a/core/embed/rust/src/ui/api/firmware_upy.rs +++ b/core/embed/rust/src/ui/api/firmware_upy.rs @@ -122,6 +122,41 @@ extern "C" fn new_confirm_homescreen(n_args: usize, args: *const Obj, kwargs: *m unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } } +extern "C" fn new_confirm_modify_fee(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()?; + let sign: i32 = kwargs.get(Qstr::MP_QSTR_sign)?.try_into()?; + let user_fee_change: TString = kwargs.get(Qstr::MP_QSTR_user_fee_change)?.try_into()?; + let total_fee_new: TString = kwargs.get(Qstr::MP_QSTR_total_fee_new)?.try_into()?; + let fee_rate_amount: Option = kwargs + .get(Qstr::MP_QSTR_fee_rate_amount) + .unwrap_or_else(|_| Obj::const_none()) + .try_into_option()?; + + let layout = ModelUI::confirm_modify_fee( + title, + sign, + user_fee_change, + total_fee_new, + fee_rate_amount, + )?; + Ok(LayoutObj::new_root(layout)?.into()) + }; + unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } +} + +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 sign: i32 = kwargs.get(Qstr::MP_QSTR_sign)?.try_into()?; + let amount_change: TString = kwargs.get(Qstr::MP_QSTR_amount_change)?.try_into()?; + let amount_new: TString = kwargs.get(Qstr::MP_QSTR_amount_new)?.try_into()?; + + let layout = ModelUI::confirm_modify_output(sign, amount_change, amount_new)?; + Ok(LayoutObj::new_root(layout)?.into()) + }; + unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } +} + extern "C" fn new_confirm_reset_device(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { let block = move |_args: &[Obj], kwargs: &Map| { let recovery: bool = kwargs.get(Qstr::MP_QSTR_recovery)?.try_into()?; @@ -532,6 +567,26 @@ pub static mp_module_trezorui_api: Module = obj_module! { /// """Confirm homescreen.""" Qstr::MP_QSTR_confirm_homescreen => obj_fn_kw!(0, new_confirm_homescreen).as_obj(), + /// def confirm_modify_fee( + /// *, + /// title: str, + /// sign: int, + /// user_fee_change: str, + /// total_fee_new: str, + /// fee_rate_amount: str | None, + /// ) -> LayoutObj[UiResult]: + /// """Decrease or increase transaction fee.""" + Qstr::MP_QSTR_confirm_modify_fee => obj_fn_kw!(0, new_confirm_modify_fee).as_obj(), + + /// def confirm_modify_output( + /// *, + /// sign: int, + /// amount_change: str, + /// amount_new: str, + /// ) -> LayoutObj[UiResult]: + /// """Decrease or increase output amount.""" + Qstr::MP_QSTR_confirm_modify_output => obj_fn_kw!(0, new_confirm_modify_output).as_obj(), + /// def confirm_reset_device(recovery: bool) -> LayoutObj[UiResult]: /// """Confirm TOS before creating wallet creation or wallet recovery.""" Qstr::MP_QSTR_confirm_reset_device => obj_fn_kw!(0, new_confirm_reset_device).as_obj(), diff --git a/core/embed/rust/src/ui/model_mercury/layout.rs b/core/embed/rust/src/ui/model_mercury/layout.rs index 864e5b9714..dba0c67a3c 100644 --- a/core/embed/rust/src/ui/model_mercury/layout.rs +++ b/core/embed/rust/src/ui/model_mercury/layout.rs @@ -695,81 +695,6 @@ extern "C" fn new_confirm_total(n_args: usize, args: *const Obj, kwargs: *mut Ma unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } } -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 sign: i32 = kwargs.get(Qstr::MP_QSTR_sign)?.try_into()?; - let amount_change: TString = kwargs.get(Qstr::MP_QSTR_amount_change)?.try_into()?; - let amount_new: TString = kwargs.get(Qstr::MP_QSTR_amount_new)?.try_into()?; - - let description = if sign < 0 { - TR::modify_amount__decrease_amount - } else { - TR::modify_amount__increase_amount - }; - - let paragraphs = ParagraphVecShort::from_iter([ - Paragraph::new(&theme::TEXT_NORMAL, description), - Paragraph::new(&theme::TEXT_MONO, amount_change), - Paragraph::new(&theme::TEXT_NORMAL, TR::modify_amount__new_amount), - Paragraph::new(&theme::TEXT_MONO, amount_new), - ]) - .into_paragraphs(); - - let obj = LayoutObj::new(SwipeUpScreen::new( - Frame::left_aligned(TR::modify_amount__title.into(), paragraphs) - .with_cancel_button() - .with_footer(TR::instructions__swipe_up.into(), None) - .with_swipe(Direction::Up, SwipeSettings::default()), - ))?; - Ok(obj.into()) - }; - unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } -} - -extern "C" fn new_confirm_modify_fee(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()?; - let sign: i32 = kwargs.get(Qstr::MP_QSTR_sign)?.try_into()?; - let user_fee_change: TString = kwargs.get(Qstr::MP_QSTR_user_fee_change)?.try_into()?; - let total_fee_new: TString = kwargs.get(Qstr::MP_QSTR_total_fee_new)?.try_into()?; - - let (description, change, total_label) = match sign { - s if s < 0 => ( - TR::modify_fee__decrease_fee, - user_fee_change, - TR::modify_fee__new_transaction_fee, - ), - s if s > 0 => ( - TR::modify_fee__increase_fee, - user_fee_change, - TR::modify_fee__new_transaction_fee, - ), - _ => ( - TR::modify_fee__no_change, - "".into(), - TR::modify_fee__transaction_fee, - ), - }; - - let paragraphs = ParagraphVecShort::from_iter([ - Paragraph::new(&theme::TEXT_SUB_GREY, description), - Paragraph::new(&theme::TEXT_MONO, change), - Paragraph::new(&theme::TEXT_SUB_GREY, total_label), - Paragraph::new(&theme::TEXT_MONO, total_fee_new), - ]); - - let flow = flow::new_confirm_with_info( - title, - None, - TR::words__title_information.into(), - paragraphs, - Some(title), - )?; - Ok(LayoutObj::new_root(flow)?.into()) - }; - unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } -} - extern "C" fn new_show_error(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()?; @@ -1168,26 +1093,6 @@ pub static mp_module_trezorui2: Module = obj_module! { /// """Transaction summary. Always hold to confirm.""" Qstr::MP_QSTR_confirm_total => obj_fn_kw!(0, new_confirm_total).as_obj(), - /// def confirm_modify_output( - /// *, - /// sign: int, - /// amount_change: str, - /// amount_new: str, - /// ) -> LayoutObj[UiResult]: - /// """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( - /// *, - /// title: str, - /// sign: int, - /// user_fee_change: str, - /// total_fee_new: str, - /// fee_rate_amount: str | None, # ignored - /// ) -> LayoutObj[UiResult]: - /// """Decrease or increase transaction fee.""" - Qstr::MP_QSTR_confirm_modify_fee => obj_fn_kw!(0, new_confirm_modify_fee).as_obj(), - /// def confirm_fido( /// *, /// title: str, 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 cc85a4a254..e329f8d2d4 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 @@ -141,6 +141,76 @@ impl UIFeaturesFirmware for ModelMercuryFeatures { Ok(flow) } + fn confirm_modify_fee( + title: TString<'static>, + sign: i32, + user_fee_change: TString<'static>, + total_fee_new: TString<'static>, + fee_rate_amount: Option>, + ) -> Result { + let (description, change, total_label) = match sign { + s if s < 0 => ( + TR::modify_fee__decrease_fee, + user_fee_change, + TR::modify_fee__new_transaction_fee, + ), + s if s > 0 => ( + TR::modify_fee__increase_fee, + user_fee_change, + TR::modify_fee__new_transaction_fee, + ), + _ => ( + TR::modify_fee__no_change, + "".into(), + TR::modify_fee__transaction_fee, + ), + }; + + let paragraphs = ParagraphVecShort::from_iter([ + Paragraph::new(&theme::TEXT_SUB_GREY, description), + Paragraph::new(&theme::TEXT_MONO, change), + Paragraph::new(&theme::TEXT_SUB_GREY, total_label), + Paragraph::new(&theme::TEXT_MONO, total_fee_new), + ]); + + let flow = flow::new_confirm_with_info( + title, + None, + TR::words__title_information.into(), + paragraphs, + Some(title), + )?; + Ok(flow) + } + + fn confirm_modify_output( + sign: i32, + amount_change: TString<'static>, + amount_new: TString<'static>, + ) -> Result { + let description = if sign < 0 { + TR::modify_amount__decrease_amount + } else { + TR::modify_amount__increase_amount + }; + + let paragraphs = ParagraphVecShort::from_iter([ + Paragraph::new(&theme::TEXT_NORMAL, description), + Paragraph::new(&theme::TEXT_MONO, amount_change), + Paragraph::new(&theme::TEXT_NORMAL, TR::modify_amount__new_amount), + Paragraph::new(&theme::TEXT_MONO, amount_new), + ]) + .into_paragraphs(); + + let layout = RootComponent::new(SwipeUpScreen::new( + Frame::left_aligned(TR::modify_amount__title.into(), paragraphs) + .with_cancel_button() + .with_footer(TR::instructions__swipe_up.into(), None) + .with_swipe(Direction::Up, SwipeSettings::default()), + )); + Ok(layout) + } + fn confirm_reset_device(recovery: bool) -> Result { let flow = flow::confirm_reset::new_confirm_reset(recovery)?; Ok(flow) diff --git a/core/embed/rust/src/ui/model_tr/layout.rs b/core/embed/rust/src/ui/model_tr/layout.rs index 860d9fa5d2..f30d21b886 100644 --- a/core/embed/rust/src/ui/model_tr/layout.rs +++ b/core/embed/rust/src/ui/model_tr/layout.rs @@ -478,36 +478,6 @@ extern "C" fn new_confirm_joint_total(n_args: usize, args: *const Obj, kwargs: * unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } } -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 sign: i32 = kwargs.get(Qstr::MP_QSTR_sign)?.try_into()?; - let amount_change: TString = kwargs.get(Qstr::MP_QSTR_amount_change)?.try_into()?; - let amount_new: TString = kwargs.get(Qstr::MP_QSTR_amount_new)?.try_into()?; - - let description = if sign < 0 { - TR::modify_amount__decrease_amount - } else { - TR::modify_amount__increase_amount - }; - - let paragraphs = Paragraphs::new([ - Paragraph::new(&theme::TEXT_NORMAL, description), - Paragraph::new(&theme::TEXT_MONO, amount_change).break_after(), - Paragraph::new(&theme::TEXT_BOLD, TR::modify_amount__new_amount), - Paragraph::new(&theme::TEXT_MONO, amount_new), - ]); - - content_in_button_page( - TR::modify_amount__title.into(), - paragraphs, - TR::buttons__confirm.into(), - Some("".into()), - false, - ) - }; - unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } -} - extern "C" fn new_confirm_output_address(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { let block = |_args: &[Obj], kwargs: &Map| { let address: TString = kwargs.get(Qstr::MP_QSTR_address)?.try_into()?; @@ -753,45 +723,6 @@ extern "C" fn new_confirm_address(n_args: usize, args: *const Obj, kwargs: *mut unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } } -extern "C" fn new_confirm_modify_fee(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { - let block = move |_args: &[Obj], kwargs: &Map| { - let sign: i32 = kwargs.get(Qstr::MP_QSTR_sign)?.try_into()?; - let user_fee_change: TString = kwargs.get(Qstr::MP_QSTR_user_fee_change)?.try_into()?; - let total_fee_new: TString = kwargs.get(Qstr::MP_QSTR_total_fee_new)?.try_into()?; - let fee_rate_amount: Option = kwargs - .get(Qstr::MP_QSTR_fee_rate_amount)? - .try_into_option()?; - - let (description, change) = match sign { - s if s < 0 => (TR::modify_fee__decrease_fee, user_fee_change), - s if s > 0 => (TR::modify_fee__increase_fee, user_fee_change), - _ => (TR::modify_fee__no_change, "".into()), - }; - - let mut paragraphs_vec = ParagraphVecShort::new(); - paragraphs_vec - .add(Paragraph::new(&theme::TEXT_BOLD, description)) - .add(Paragraph::new(&theme::TEXT_MONO, change)) - .add(Paragraph::new(&theme::TEXT_BOLD, TR::modify_fee__transaction_fee).no_break()) - .add(Paragraph::new(&theme::TEXT_MONO, total_fee_new)); - - if let Some(fee_rate_amount) = fee_rate_amount { - paragraphs_vec - .add(Paragraph::new(&theme::TEXT_BOLD, TR::modify_fee__fee_rate).no_break()) - .add(Paragraph::new(&theme::TEXT_MONO, fee_rate_amount)); - } - - content_in_button_page( - TR::modify_fee__title.into(), - paragraphs_vec.into_paragraphs(), - TR::buttons__confirm.into(), - Some("".into()), - false, - ) - }; - unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } -} - extern "C" fn new_multiple_pages_texts(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()?; @@ -1198,15 +1129,6 @@ pub static mp_module_trezorui2: Module = obj_module! { /// """Confirm total if there are external inputs.""" Qstr::MP_QSTR_confirm_joint_total => obj_fn_kw!(0, new_confirm_joint_total).as_obj(), - /// def confirm_modify_output( - /// *, - /// sign: int, - /// amount_change: str, - /// amount_new: str, - /// ) -> LayoutObj[UiResult]: - /// """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( /// *, /// address: str, @@ -1250,17 +1172,6 @@ pub static mp_module_trezorui2: Module = obj_module! { /// """Confirm details about altcoin transaction.""" Qstr::MP_QSTR_altcoin_tx_summary => obj_fn_kw!(0, new_altcoin_tx_summary).as_obj(), - /// def confirm_modify_fee( - /// *, - /// title: str, # ignored - /// sign: int, - /// user_fee_change: str, - /// total_fee_new: str, - /// fee_rate_amount: str | None, - /// ) -> LayoutObj[UiResult]: - /// """Decrease or increase transaction fee.""" - Qstr::MP_QSTR_confirm_modify_fee => obj_fn_kw!(0, new_confirm_modify_fee).as_obj(), - /// def confirm_fido( /// *, /// title: 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 a39bc59a36..6921a62b92 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 @@ -142,6 +142,68 @@ impl UIFeaturesFirmware for ModelTRFeatures { Ok(layout) } + fn confirm_modify_fee( + title: TString<'static>, + sign: i32, + user_fee_change: TString<'static>, + total_fee_new: TString<'static>, + fee_rate_amount: Option>, + ) -> Result { + let (description, change) = match sign { + s if s < 0 => (TR::modify_fee__decrease_fee, user_fee_change), + s if s > 0 => (TR::modify_fee__increase_fee, user_fee_change), + _ => (TR::modify_fee__no_change, "".into()), + }; + + let mut paragraphs_vec = ParagraphVecShort::new(); + paragraphs_vec + .add(Paragraph::new(&theme::TEXT_BOLD, description)) + .add(Paragraph::new(&theme::TEXT_MONO, change)) + .add(Paragraph::new(&theme::TEXT_BOLD, TR::modify_fee__transaction_fee).no_break()) + .add(Paragraph::new(&theme::TEXT_MONO, total_fee_new)); + + if let Some(fee_rate_amount) = fee_rate_amount { + paragraphs_vec + .add(Paragraph::new(&theme::TEXT_BOLD, TR::modify_fee__fee_rate).no_break()) + .add(Paragraph::new(&theme::TEXT_MONO, fee_rate_amount)); + } + + content_in_button_page( + TR::modify_fee__title.into(), + paragraphs_vec.into_paragraphs(), + TR::buttons__confirm.into(), + Some("".into()), + false, + ) + } + + fn confirm_modify_output( + sign: i32, + amount_change: TString<'static>, + amount_new: TString<'static>, + ) -> Result { + let description = if sign < 0 { + TR::modify_amount__decrease_amount + } else { + TR::modify_amount__increase_amount + }; + + let paragraphs = Paragraphs::new([ + Paragraph::new(&theme::TEXT_NORMAL, description), + Paragraph::new(&theme::TEXT_MONO, amount_change).break_after(), + Paragraph::new(&theme::TEXT_BOLD, TR::modify_amount__new_amount), + Paragraph::new(&theme::TEXT_MONO, amount_new), + ]); + + content_in_button_page( + TR::modify_amount__title.into(), + paragraphs, + TR::buttons__confirm.into(), + Some("".into()), + false, + ) + } + fn confirm_reset_device(recovery: bool) -> Result { let (title, button) = if recovery { ( diff --git a/core/embed/rust/src/ui/model_tt/layout.rs b/core/embed/rust/src/ui/model_tt/layout.rs index fdce3bcda4..df9cd15a76 100644 --- a/core/embed/rust/src/ui/model_tt/layout.rs +++ b/core/embed/rust/src/ui/model_tt/layout.rs @@ -689,83 +689,6 @@ extern "C" fn new_confirm_total(n_args: usize, args: *const Obj, kwargs: *mut Ma unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } } -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 sign: i32 = kwargs.get(Qstr::MP_QSTR_sign)?.try_into()?; - let amount_change: TString = kwargs.get(Qstr::MP_QSTR_amount_change)?.try_into()?; - let amount_new: TString = kwargs.get(Qstr::MP_QSTR_amount_new)?.try_into()?; - - let description = if sign < 0 { - TR::modify_amount__decrease_amount - } else { - TR::modify_amount__increase_amount - }; - - let paragraphs = Paragraphs::new([ - Paragraph::new(&theme::TEXT_NORMAL, description), - Paragraph::new(&theme::TEXT_MONO, amount_change), - Paragraph::new(&theme::TEXT_NORMAL, TR::modify_amount__new_amount), - Paragraph::new(&theme::TEXT_MONO, amount_new), - ]); - - let obj = LayoutObj::new(Frame::left_aligned( - theme::label_title(), - TR::modify_amount__title.into(), - ButtonPage::new(paragraphs, theme::BG) - .with_cancel_confirm(Some("^".into()), Some(TR::buttons__continue.into())), - ))?; - Ok(obj.into()) - }; - unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } -} - -extern "C" fn new_confirm_modify_fee(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()?; - let sign: i32 = kwargs.get(Qstr::MP_QSTR_sign)?.try_into()?; - let user_fee_change: TString = kwargs.get(Qstr::MP_QSTR_user_fee_change)?.try_into()?; - let total_fee_new: TString = kwargs.get(Qstr::MP_QSTR_total_fee_new)?.try_into()?; - - let (description, change, total_label) = match sign { - s if s < 0 => ( - TR::modify_fee__decrease_fee, - user_fee_change, - TR::modify_fee__new_transaction_fee, - ), - s if s > 0 => ( - TR::modify_fee__increase_fee, - user_fee_change, - TR::modify_fee__new_transaction_fee, - ), - _ => ( - TR::modify_fee__no_change, - "".into(), - TR::modify_fee__transaction_fee, - ), - }; - - let paragraphs = Paragraphs::new([ - Paragraph::new(&theme::TEXT_NORMAL, description), - Paragraph::new(&theme::TEXT_MONO, change), - Paragraph::new(&theme::TEXT_NORMAL, total_label), - Paragraph::new(&theme::TEXT_MONO, total_fee_new), - ]); - - let obj = LayoutObj::new( - Frame::left_aligned( - theme::label_title(), - title, - ButtonPage::new(paragraphs, theme::BG) - .with_hold()? - .with_swipe_left(), - ) - .with_info_button(), - )?; - Ok(obj.into()) - }; - unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } -} - fn new_show_modal( kwargs: &Map, icon: BlendedImage, @@ -1241,26 +1164,6 @@ pub static mp_module_trezorui2: Module = obj_module! { /// """Transaction summary. Always hold to confirm.""" Qstr::MP_QSTR_confirm_total => obj_fn_kw!(0, new_confirm_total).as_obj(), - /// def confirm_modify_output( - /// *, - /// sign: int, - /// amount_change: str, - /// amount_new: str, - /// ) -> LayoutObj[UiResult]: - /// """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( - /// *, - /// title: str, - /// sign: int, - /// user_fee_change: str, - /// total_fee_new: str, - /// fee_rate_amount: str | None, # ignored - /// ) -> LayoutObj[UiResult]: - /// """Decrease or increase transaction fee.""" - Qstr::MP_QSTR_confirm_modify_fee => obj_fn_kw!(0, new_confirm_modify_fee).as_obj(), - /// def confirm_fido( /// *, /// 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 c4dade3747..1f666aa884 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 @@ -141,6 +141,78 @@ impl UIFeaturesFirmware for ModelTTFeatures { Ok(layout) } + fn confirm_modify_fee( + title: TString<'static>, + sign: i32, + user_fee_change: TString<'static>, + total_fee_new: TString<'static>, + fee_rate_amount: Option>, + ) -> Result { + let (description, change, total_label) = match sign { + s if s < 0 => ( + TR::modify_fee__decrease_fee, + user_fee_change, + TR::modify_fee__new_transaction_fee, + ), + s if s > 0 => ( + TR::modify_fee__increase_fee, + user_fee_change, + TR::modify_fee__new_transaction_fee, + ), + _ => ( + TR::modify_fee__no_change, + "".into(), + TR::modify_fee__transaction_fee, + ), + }; + + let paragraphs = Paragraphs::new([ + Paragraph::new(&theme::TEXT_NORMAL, description), + Paragraph::new(&theme::TEXT_MONO, change), + Paragraph::new(&theme::TEXT_NORMAL, total_label), + Paragraph::new(&theme::TEXT_MONO, total_fee_new), + ]); + + let layout = RootComponent::new( + Frame::left_aligned( + theme::label_title(), + title, + ButtonPage::new(paragraphs, theme::BG) + .with_hold()? + .with_swipe_left(), + ) + .with_info_button(), + ); + Ok(layout) + } + + fn confirm_modify_output( + sign: i32, + amount_change: TString<'static>, + amount_new: TString<'static>, + ) -> Result { + let description = if sign < 0 { + TR::modify_amount__decrease_amount + } else { + TR::modify_amount__increase_amount + }; + + let paragraphs = Paragraphs::new([ + Paragraph::new(&theme::TEXT_NORMAL, description), + Paragraph::new(&theme::TEXT_MONO, amount_change), + Paragraph::new(&theme::TEXT_NORMAL, TR::modify_amount__new_amount), + Paragraph::new(&theme::TEXT_MONO, amount_new), + ]); + + let layout = RootComponent::new(Frame::left_aligned( + theme::label_title(), + TR::modify_amount__title.into(), + ButtonPage::new(paragraphs, theme::BG) + .with_cancel_confirm(Some("^".into()), Some(TR::buttons__continue.into())), + )); + Ok(layout) + } + fn confirm_reset_device(recovery: bool) -> Result { let (title, button) = if recovery { ( diff --git a/core/embed/rust/src/ui/ui_features_fw.rs b/core/embed/rust/src/ui/ui_features_fw.rs index c4db947c90..32fe7a350e 100644 --- a/core/embed/rust/src/ui/ui_features_fw.rs +++ b/core/embed/rust/src/ui/ui_features_fw.rs @@ -35,6 +35,20 @@ pub trait UIFeaturesFirmware { fingerprint: TString<'static>, ) -> Result; + fn confirm_modify_fee( + title: TString<'static>, + sign: i32, + user_fee_change: TString<'static>, + total_fee_new: TString<'static>, + fee_rate_amount: Option>, + ) -> Result; + + fn confirm_modify_output( + sign: i32, + amount_change: TString<'static>, + amount_new: TString<'static>, + ) -> Result; + fn confirm_reset_device(recovery: bool) -> Result; fn check_homescreen_format(image: BinaryData, accept_toif: bool) -> bool; diff --git a/core/mocks/generated/trezorui2.pyi b/core/mocks/generated/trezorui2.pyi index 0f42a6543f..69fdfa359b 100644 --- a/core/mocks/generated/trezorui2.pyi +++ b/core/mocks/generated/trezorui2.pyi @@ -124,28 +124,6 @@ def confirm_total( """Transaction summary. Always hold to confirm.""" -# rust/src/ui/model_mercury/layout.rs -def confirm_modify_output( - *, - sign: int, - amount_change: str, - amount_new: str, -) -> LayoutObj[UiResult]: - """Decrease or increase output amount.""" - - -# rust/src/ui/model_mercury/layout.rs -def confirm_modify_fee( - *, - title: str, - sign: int, - user_fee_change: str, - total_fee_new: str, - fee_rate_amount: str | None, # ignored -) -> LayoutObj[UiResult]: - """Decrease or increase transaction fee.""" - - # rust/src/ui/model_mercury/layout.rs def confirm_fido( *, @@ -416,16 +394,6 @@ def confirm_joint_total( """Confirm total if there are external inputs.""" -# rust/src/ui/model_tr/layout.rs -def confirm_modify_output( - *, - sign: int, - amount_change: str, - amount_new: str, -) -> LayoutObj[UiResult]: - """Decrease or increase output amount.""" - - # rust/src/ui/model_tr/layout.rs def confirm_output_address( *, @@ -473,18 +441,6 @@ def altcoin_tx_summary( """Confirm details about altcoin transaction.""" -# rust/src/ui/model_tr/layout.rs -def confirm_modify_fee( - *, - title: str, # ignored - sign: int, - user_fee_change: str, - total_fee_new: str, - fee_rate_amount: str | None, -) -> LayoutObj[UiResult]: - """Decrease or increase transaction fee.""" - - # rust/src/ui/model_tr/layout.rs def confirm_fido( *, @@ -718,28 +674,6 @@ def confirm_total( """Transaction summary. Always hold to confirm.""" -# rust/src/ui/model_tt/layout.rs -def confirm_modify_output( - *, - sign: int, - amount_change: str, - amount_new: str, -) -> LayoutObj[UiResult]: - """Decrease or increase output amount.""" - - -# rust/src/ui/model_tt/layout.rs -def confirm_modify_fee( - *, - title: str, - sign: int, - user_fee_change: str, - total_fee_new: str, - fee_rate_amount: str | None, # ignored -) -> LayoutObj[UiResult]: - """Decrease or increase transaction fee.""" - - # rust/src/ui/model_tt/layout.rs def confirm_fido( *, diff --git a/core/mocks/generated/trezorui_api.pyi b/core/mocks/generated/trezorui_api.pyi index eef24c70b3..224b4bb55d 100644 --- a/core/mocks/generated/trezorui_api.pyi +++ b/core/mocks/generated/trezorui_api.pyi @@ -123,6 +123,28 @@ def confirm_homescreen( """Confirm homescreen.""" +# rust/src/ui/api/firmware_upy.rs +def confirm_modify_fee( + *, + title: str, + sign: int, + user_fee_change: str, + total_fee_new: str, + fee_rate_amount: str | None, +) -> LayoutObj[UiResult]: + """Decrease or increase transaction fee.""" + + +# rust/src/ui/api/firmware_upy.rs +def confirm_modify_output( + *, + sign: int, + amount_change: str, + amount_new: str, +) -> LayoutObj[UiResult]: + """Decrease or increase output amount.""" + + # rust/src/ui/api/firmware_upy.rs def confirm_reset_device(recovery: bool) -> LayoutObj[UiResult]: """Confirm TOS before creating wallet creation or wallet recovery.""" diff --git a/core/src/trezor/ui/layouts/mercury/__init__.py b/core/src/trezor/ui/layouts/mercury/__init__.py index 2fe765d2da..f5cf6487b4 100644 --- a/core/src/trezor/ui/layouts/mercury/__init__.py +++ b/core/src/trezor/ui/layouts/mercury/__init__.py @@ -914,7 +914,7 @@ async def confirm_modify_output( verb_cancel=None, description=f"{TR.words__address}:", ) - modify_layout = trezorui2.confirm_modify_output( + modify_layout = trezorui_api.confirm_modify_output( sign=sign, amount_change=amount_change, amount_new=amount_new, @@ -946,7 +946,7 @@ def confirm_modify_fee( total_fee_new: str, fee_rate_amount: str | None = None, ) -> Awaitable[None]: - fee_layout = trezorui2.confirm_modify_fee( + fee_layout = trezorui_api.confirm_modify_fee( title=title, sign=sign, user_fee_change=user_fee_change, diff --git a/core/src/trezor/ui/layouts/tr/__init__.py b/core/src/trezor/ui/layouts/tr/__init__.py index fa4a7dd97f..6167e0a449 100644 --- a/core/src/trezor/ui/layouts/tr/__init__.py +++ b/core/src/trezor/ui/layouts/tr/__init__.py @@ -1004,7 +1004,7 @@ async def confirm_modify_output( description=f"{TR.words__address}:", ) - modify_layout = trezorui2.confirm_modify_output( + modify_layout = trezorui_api.confirm_modify_output( sign=sign, amount_change=amount_change, amount_new=amount_new, @@ -1038,7 +1038,7 @@ def confirm_modify_fee( fee_rate_amount: str | None = None, ) -> Awaitable[None]: return raise_if_not_confirmed( - trezorui2.confirm_modify_fee( + trezorui_api.confirm_modify_fee( title=title, sign=sign, user_fee_change=user_fee_change, diff --git a/core/src/trezor/ui/layouts/tt/__init__.py b/core/src/trezor/ui/layouts/tt/__init__.py index f09525eebc..fb67b8026f 100644 --- a/core/src/trezor/ui/layouts/tt/__init__.py +++ b/core/src/trezor/ui/layouts/tt/__init__.py @@ -970,7 +970,7 @@ async def confirm_modify_output( try: await interact( - trezorui2.confirm_modify_output( + trezorui_api.confirm_modify_output( sign=sign, amount_change=amount_change, amount_new=amount_new, @@ -993,7 +993,7 @@ def confirm_modify_fee( total_fee_new: str, fee_rate_amount: str | None = None, ) -> Awaitable[None]: - fee_layout = trezorui2.confirm_modify_fee( + fee_layout = trezorui_api.confirm_modify_fee( title=title, sign=sign, user_fee_change=user_fee_change,