1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-23 23:08:14 +00:00

fix(core/ui): T3T1: ethereum signtx hold

[no changelog]
This commit is contained in:
Martin Milata 2024-06-05 20:33:14 +02:00 committed by matejcik
parent 09fc0ebf3e
commit 6911870654
2 changed files with 35 additions and 26 deletions

View File

@ -63,6 +63,7 @@ impl FlowState for ConfirmAction {
Decision::Goto(ConfirmAction::Intro, SwipeDirection::Right) Decision::Goto(ConfirmAction::Intro, SwipeDirection::Right)
} }
(ConfirmAction::Menu, FlowMsg::Choice(0)) => Decision::Return(FlowMsg::Cancelled), (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::Confirmed) => Decision::Return(FlowMsg::Confirmed),
(ConfirmAction::Confirm, FlowMsg::Info) => { (ConfirmAction::Confirm, FlowMsg::Info) => {
Decision::Goto(ConfirmAction::Menu, SwipeDirection::Left) Decision::Goto(ConfirmAction::Menu, SwipeDirection::Left)
@ -97,6 +98,7 @@ impl FlowState for ConfirmActionSimple {
Decision::Goto(ConfirmActionSimple::Intro, SwipeDirection::Right) Decision::Goto(ConfirmActionSimple::Intro, SwipeDirection::Right)
} }
(ConfirmActionSimple::Menu, FlowMsg::Choice(0)) => Decision::Return(FlowMsg::Cancelled), (ConfirmActionSimple::Menu, FlowMsg::Choice(0)) => Decision::Return(FlowMsg::Cancelled),
(ConfirmActionSimple::Menu, FlowMsg::Choice(1)) => Decision::Return(FlowMsg::Info),
_ => Decision::Nothing, _ => Decision::Nothing,
} }
} }
@ -166,6 +168,7 @@ fn new_confirm_action_obj(_args: &[Obj], kwargs: &Map) -> Result<Obj, error::Err
verb_cancel, verb_cancel,
prompt_screen.then_some(prompt_title), prompt_screen.then_some(prompt_title),
hold, hold,
false,
) )
} }
@ -177,6 +180,7 @@ pub fn new_confirm_action_simple<T: Component + Paginate + MaybeTrace + 'static>
verb_cancel: Option<TString<'static>>, verb_cancel: Option<TString<'static>>,
prompt_screen: Option<TString<'static>>, prompt_screen: Option<TString<'static>>,
hold: bool, hold: bool,
info: bool,
) -> Result<Obj, error::Error> { ) -> Result<Obj, error::Error> {
let mut content_intro = let mut content_intro =
Frame::left_aligned(title, SwipeContent::new(SwipePage::vertical(content))) Frame::left_aligned(title, SwipeContent::new(SwipePage::vertical(content)))
@ -198,23 +202,23 @@ pub fn new_confirm_action_simple<T: Component + Paginate + MaybeTrace + 'static>
}) })
.with_pages(move |intro_pages| intro_pages + prompt_pages); .with_pages(move |intro_pages| intro_pages + prompt_pages);
let content_menu = if let Some(verb_cancel) = verb_cancel { let mut menu_choices = VerticalMenu::empty().danger(
Frame::left_aligned( theme::ICON_CANCEL,
"".into(), verb_cancel.unwrap_or(TR::buttons__cancel.into()),
VerticalMenu::empty().danger(theme::ICON_CANCEL, verb_cancel), );
) if info {
} else { menu_choices = menu_choices.item(
Frame::left_aligned( theme::ICON_CHEVRON_RIGHT,
"".into(), TR::words__title_information.into(),
VerticalMenu::empty().danger(theme::ICON_CANCEL, TR::buttons__cancel.into()), );
)
} }
.with_cancel_button() let content_menu = Frame::left_aligned("".into(), menu_choices)
.with_swipe(SwipeDirection::Right, SwipeSettings::immediate()) .with_cancel_button()
.map(move |msg| match msg { .with_swipe(SwipeDirection::Right, SwipeSettings::immediate())
FrameMsg::Content(VerticalMenuChoiceMsg::Selected(_)) => Some(FlowMsg::Choice(0)), .map(move |msg| match msg {
FrameMsg::Button(_) => Some(FlowMsg::Cancelled), FrameMsg::Content(VerticalMenuChoiceMsg::Selected(i)) => Some(FlowMsg::Choice(i)),
}); FrameMsg::Button(_) => Some(FlowMsg::Cancelled),
});
if let Some(prompt_title) = prompt_screen { if let Some(prompt_title) = prompt_screen {
let (prompt, prompt_action) = if hold { let (prompt, prompt_action) = if hold {

View File

@ -295,6 +295,7 @@ extern "C" fn new_confirm_emphasized(n_args: usize, args: *const Obj, kwargs: *m
None, None,
Some(title), Some(title),
false, false,
false,
) )
}; };
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
@ -391,6 +392,7 @@ impl ConfirmBlobParams {
self.verb_cancel, self.verb_cancel,
self.prompt.then_some(self.title), self.prompt.then_some(self.title),
self.hold, 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(); .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) } 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, None,
hold.then_some(title), hold.then_some(title),
hold, hold,
false,
) )
}; };
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } 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)); paragraphs.add(Paragraph::new(&theme::TEXT_MONO, value));
} }
// FIXME: hold flow::new_confirm_action_simple(
let obj = LayoutObj::new(SwipeUpScreen::new( paragraphs.into_paragraphs(),
Frame::left_aligned(title, SwipeContent::new(paragraphs.into_paragraphs())) title,
.with_menu_button() None,
.with_footer(TR::instructions__swipe_up.into(), None) None,
.with_swipe(SwipeDirection::Up, SwipeSettings::default()), Some(title),
))?; true,
Ok(obj.into()) true,
)
}; };
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } 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, None,
Some(TR::coinjoin__title.into()), Some(TR::coinjoin__title.into()),
true, true,
false,
) )
}; };
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } 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 { 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( let obj = LayoutObj::new(Frame::left_aligned(
TR::recovery__num_of_words.into(), TR::recovery__num_of_words.into(),
SelectWordCount::new(), SelectWordCount::new(),