From 6911870654ffd5dd2799e64a0881ca61b6125dd3 Mon Sep 17 00:00:00 2001 From: Martin Milata Date: Wed, 5 Jun 2024 20:33:14 +0200 Subject: [PATCH] fix(core/ui): T3T1: ethereum signtx hold [no changelog] --- .../ui/model_mercury/flow/confirm_action.rs | 36 ++++++++++--------- .../embed/rust/src/ui/model_mercury/layout.rs | 25 +++++++------ 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/core/embed/rust/src/ui/model_mercury/flow/confirm_action.rs b/core/embed/rust/src/ui/model_mercury/flow/confirm_action.rs index 394dff2b23..72f001816a 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/confirm_action.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/confirm_action.rs @@ -63,6 +63,7 @@ impl FlowState for ConfirmAction { Decision::Goto(ConfirmAction::Intro, SwipeDirection::Right) } (ConfirmAction::Menu, FlowMsg::Choice(0)) => Decision::Return(FlowMsg::Cancelled), + (ConfirmAction::Menu, FlowMsg::Choice(1)) => Decision::Return(FlowMsg::Info), (ConfirmAction::Confirm, FlowMsg::Confirmed) => Decision::Return(FlowMsg::Confirmed), (ConfirmAction::Confirm, FlowMsg::Info) => { Decision::Goto(ConfirmAction::Menu, SwipeDirection::Left) @@ -97,6 +98,7 @@ impl FlowState for ConfirmActionSimple { Decision::Goto(ConfirmActionSimple::Intro, SwipeDirection::Right) } (ConfirmActionSimple::Menu, FlowMsg::Choice(0)) => Decision::Return(FlowMsg::Cancelled), + (ConfirmActionSimple::Menu, FlowMsg::Choice(1)) => Decision::Return(FlowMsg::Info), _ => Decision::Nothing, } } @@ -166,6 +168,7 @@ fn new_confirm_action_obj(_args: &[Obj], kwargs: &Map) -> Result verb_cancel: Option>, prompt_screen: Option>, hold: bool, + info: bool, ) -> Result { let mut content_intro = Frame::left_aligned(title, SwipeContent::new(SwipePage::vertical(content))) @@ -198,23 +202,23 @@ pub fn new_confirm_action_simple }) .with_pages(move |intro_pages| intro_pages + prompt_pages); - let content_menu = if let Some(verb_cancel) = verb_cancel { - Frame::left_aligned( - "".into(), - VerticalMenu::empty().danger(theme::ICON_CANCEL, verb_cancel), - ) - } else { - Frame::left_aligned( - "".into(), - VerticalMenu::empty().danger(theme::ICON_CANCEL, TR::buttons__cancel.into()), - ) + let mut menu_choices = VerticalMenu::empty().danger( + theme::ICON_CANCEL, + verb_cancel.unwrap_or(TR::buttons__cancel.into()), + ); + if info { + menu_choices = menu_choices.item( + theme::ICON_CHEVRON_RIGHT, + TR::words__title_information.into(), + ); } - .with_cancel_button() - .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) - .map(move |msg| match msg { - FrameMsg::Content(VerticalMenuChoiceMsg::Selected(_)) => Some(FlowMsg::Choice(0)), - FrameMsg::Button(_) => Some(FlowMsg::Cancelled), - }); + let content_menu = Frame::left_aligned("".into(), menu_choices) + .with_cancel_button() + .with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) + .map(move |msg| match msg { + FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)), + FrameMsg::Button(_) => Some(FlowMsg::Cancelled), + }); if let Some(prompt_title) = prompt_screen { let (prompt, prompt_action) = if hold { diff --git a/core/embed/rust/src/ui/model_mercury/layout.rs b/core/embed/rust/src/ui/model_mercury/layout.rs index 16111d4dfb..2b821713bf 100644 --- a/core/embed/rust/src/ui/model_mercury/layout.rs +++ b/core/embed/rust/src/ui/model_mercury/layout.rs @@ -295,6 +295,7 @@ extern "C" fn new_confirm_emphasized(n_args: usize, args: *const Obj, kwargs: *m None, Some(title), false, + false, ) }; unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } @@ -391,6 +392,7 @@ impl ConfirmBlobParams { self.verb_cancel, self.prompt.then_some(self.title), self.hold, + self.info_button, ) } } @@ -459,7 +461,7 @@ extern "C" fn new_confirm_address(n_args: usize, args: *const Obj, kwargs: *mut } .into_paragraphs(); - flow::new_confirm_action_simple(paragraphs, title, None, None, None, false) + flow::new_confirm_action_simple(paragraphs, title, None, None, None, false, false) }; unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } } @@ -484,6 +486,7 @@ extern "C" fn new_confirm_properties(n_args: usize, args: *const Obj, kwargs: *m None, hold.then_some(title), hold, + false, ) }; unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } @@ -613,14 +616,15 @@ extern "C" fn new_confirm_total(n_args: usize, args: *const Obj, kwargs: *mut Ma paragraphs.add(Paragraph::new(&theme::TEXT_MONO, value)); } - // FIXME: hold - let obj = LayoutObj::new(SwipeUpScreen::new( - Frame::left_aligned(title, SwipeContent::new(paragraphs.into_paragraphs())) - .with_menu_button() - .with_footer(TR::instructions__swipe_up.into(), None) - .with_swipe(SwipeDirection::Up, SwipeSettings::default()), - ))?; - Ok(obj.into()) + flow::new_confirm_action_simple( + paragraphs.into_paragraphs(), + title, + None, + None, + Some(title), + true, + true, + ) }; unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } } @@ -923,6 +927,7 @@ extern "C" fn new_confirm_coinjoin(n_args: usize, args: *const Obj, kwargs: *mut None, Some(TR::coinjoin__title.into()), true, + false, ) }; unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } @@ -1083,7 +1088,7 @@ extern "C" fn new_confirm_recovery(n_args: usize, args: *const Obj, kwargs: *mut } extern "C" fn new_select_word_count(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { - let block = move |_args: &[Obj], kwargs: &Map| { + let block = move |_args: &[Obj], _kwargs: &Map| { let obj = LayoutObj::new(Frame::left_aligned( TR::recovery__num_of_words.into(), SelectWordCount::new(),