feat(core/caesar): use new menu navigation
What changed, and why it matters
This commit is a user-interface refactor for Trezor's Caesar layout (used on certain hardware models). It replaces an older 'info button' navigation pattern with a new context-menu system: the left button opens a menu, holding it enables a 'Shift' mode to scroll back, and the right button scrolls down or confirms when held. The change is purely about how screens are navigated and how extra information is shown; it does not introduce or fix any cryptographic, firmware-flashing, or memory-safety vulnerability.
No security action required; treat as a normal UI/UX refactor. Reviewers may want to verify that the new menu navigation does not accidentally hide security-critical information or make confirmation/cancellation gestures ambiguous, but the diff itself does not indicate such an issue.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch removes the legacy ShowMore component and the CancelInfoConfirmMsg/Info action from the Caesar UI, unifying navigation around ButtonPage with MenuNav variants (Menu, ChoiceMenu, Close). It updates confirm_summary, confirm_with_info, confirm_firmware_update, confirm_address, and related flows so that extra information is shown through an external context menu rather than inline info pages. Test/debug helpers are updated to press left to open the menu and to navigate a SimpleChoice carousel. No security-relevant bug fixes or vulnerability mitigations are visible in the diff.
Changed components
core/embed/rust/src/ui/layout_caesar/component/*core/src/trezor/ui/layouts/caesar/__init__.pycore/src/trezor/ui/layouts/menu.pypython/src/trezorlib/debuglink.pytests/click_tests/test_autolock.pytests/device_tests/cardano/test_sign_tx.pytests/input_flows.pytests/input_flows_helpers.pyInspect captured patch +493 / −722
### core/.changelog.d/7694.changed
@@ -0,0 +1 @@
+[T2B1,T3B1] New navigation: the left button opens the context menu (or cancels when there is none), holding it activates Shift to scroll back with the right button. Summaries are confirmed by holding the right button.
### core/embed/rust/src/ui/api/firmware_micropython.rs
@@ -1663,9 +1663,10 @@ pub static mp_module_trezorui_api: Module = obj_module! {
/// """Confirm summary of a transaction.
///
/// account_items and extra_items need to be:
- /// * a list (on Eckhart and Caesar)
+ /// * a list (on Eckhart)
/// * an iterable (on Delizia)
/// * None / non-None on Bolt
+ /// * None on Caesar (shown in the external menu instead)
///
/// TODO: get rid of account_items and extra_items for consistency!
/// """
### core/embed/rust/src/ui/layout_caesar/component/address_details.rs
@@ -24,7 +24,7 @@ impl AddressDetails {
qr_code,
pad: Pad::with_background(theme::BG).with_clear(),
buttons: Child::new(ButtonController::new(ButtonLayout::new(
- Some(ButtonDetails::close_icon()),
+ Some(ButtonDetails::cancel_icon()),
None,
None,
))),
### core/embed/rust/src/ui/layout_caesar/component/button.rs
@@ -325,7 +325,6 @@ impl ButtonDetails {
"<" => Self::left_arrow_icon(),
"^" => Self::up_arrow_icon(),
"V" => Self::down_arrow_icon(),
- "i" => Self::info_icon(),
_ => Self::text(text),
})
}
@@ -335,9 +334,9 @@ impl ButtonDetails {
Self::text(text).with_arms()
}
- /// Cross-style-icon cancel button with no outline.
+ /// Cross-style-icon cancel/close button with no outline.
pub fn cancel_icon() -> Self {
- Self::icon(theme::ICON_CANCEL).with_offset(Offset::new(3, -3))
+ Self::icon(theme::ICON_CLOSE).with_offset(Offset::new(3, -3))
}
/// Hamburger icon opening the context menu. No outline.
@@ -354,14 +353,9 @@ impl ButtonDetails {
.with_shift()
}
- /// Cross closing the current screen. No outline.
- pub fn close_icon() -> Self {
- Self::icon(theme::ICON_CLOSE).with_offset(Offset::new(3, -3))
- }
-
- /// Cross in brackets. Closes the current screen when pressed briefly,
- /// engages "Shift" when held.
- pub fn close_shift_icon() -> Self {
+ /// Cross in brackets. Cancels/closes the current screen when pressed
+ /// briefly, engages "Shift" when held.
+ pub fn cancel_shift_icon() -> Self {
Self::icon(theme::ICON_CLOSE_SHIFT)
.with_fixed_width(theme::ICON_CLOSE_SHIFT.toif.width())
.with_offset(Offset::new(0, -3))
@@ -540,32 +534,6 @@ impl ButtonLayout {
)
}
- /// Left text, armed text and right info icon/text.
- pub fn text_armed_info(left: TString<'static>, middle: TString<'static>) -> Self {
- Self::new(
- Some(ButtonDetails::from_text_possible_icon(left)),
- Some(ButtonDetails::armed_text(middle)),
- Some(ButtonDetails::info_icon()),
- )
- }
-
- /// Left text, armed text and right info text.
- pub fn text_armed_text(
- left: TString<'static>,
- middle: TString<'static>,
- right: TString<'static>,
- ) -> Self {
- Self::new(
- Some(ButtonDetails::from_text_possible_icon(left)),
- Some(ButtonDetails::armed_text(middle)),
- if right.is_empty() {
- None
- } else {
- Some(ButtonDetails::from_text_possible_icon(right))
- },
- )
- }
-
/// Left cancel, armed text and right info icon.
pub fn cancel_armed_info(middle: TString<'static>) -> Self {
Self::new(
@@ -575,19 +543,6 @@ impl ButtonLayout {
)
}
- /// Left cancel, armed text and right info icon/text.
- pub fn cancel_armed_text(middle: TString<'static>, right: TString<'static>) -> Self {
- Self::new(
- Some(ButtonDetails::cancel_icon()),
- Some(ButtonDetails::armed_text(middle)),
- if right.is_empty() {
- None
- } else {
- Some(ButtonDetails::from_text_possible_icon(right))
- },
- )
- }
-
/// Left cancel, armed text and blank on right.
pub fn cancel_armed_none(middle: TString<'static>) -> Self {
Self::new(
@@ -696,15 +651,6 @@ impl ButtonLayout {
)
}
- /// Up arrow on left, middle text and info on the right.
- pub fn up_arrow_armed_info(text: TString<'static>) -> Self {
- Self::new(
- Some(ButtonDetails::up_arrow_icon()),
- Some(ButtonDetails::armed_text(text)),
- Some(ButtonDetails::info_icon()),
- )
- }
-
/// Cancel cross on left and right arrow facing down.
pub fn cancel_none_arrow_down() -> Self {
Self::new(
@@ -774,8 +720,6 @@ pub enum ButtonAction {
Cancel,
/// Confirm the whole layout - send Msg::Confirmed
Confirm,
- /// Send INFO message from layout - send Msg::Info
- Info,
}
/// Storing actions for all three possible buttons.
@@ -920,15 +864,6 @@ impl ButtonActions {
)
}
- /// Cancelling with left, confirming with middle and info with right
- pub fn cancel_confirm_info() -> Self {
- Self::new(
- Some(ButtonAction::Cancel),
- Some(ButtonAction::Confirm),
- Some(ButtonAction::Info),
- )
- }
-
/// Going to the beginning with left, confirming with right
pub fn beginning_none_confirm() -> Self {
Self::new(
### core/embed/rust/src/ui/layout_caesar/component/flow.rs
@@ -2,7 +2,7 @@ use super::scrollbar::SCROLLBAR_SPACE;
use super::title::Title;
use super::{
theme, ButtonAction, ButtonController, ButtonControllerMsg, ButtonLayout, ButtonPos,
- CancelInfoConfirmMsg, FlowPages, Page, ScrollBar,
+ CancelConfirmMsg, FlowPages, Page, ScrollBar,
};
use crate::strutil::TString;
use crate::ui::component::{Child, Component, ComponentExt, Event, EventCtx, Pad, Paginate};
@@ -32,8 +32,6 @@ where
/// Possibly enforcing the second button to be ignored after some time after
/// pressing the first button
ignore_second_button_ms: Option<u32>,
- #[cfg(feature = "ui_debug")]
- has_menu: bool,
}
impl<F> Flow<F>
@@ -60,8 +58,6 @@ where
return_confirmed_index: false,
show_scrollbar: true,
ignore_second_button_ms: None,
- #[cfg(feature = "ui_debug")]
- has_menu: false,
}
}
@@ -95,17 +91,6 @@ where
self.return_confirmed_index.then_some(self.page_counter)
}
- #[cfg(feature = "ui_debug")]
- pub fn with_menu(mut self, has_menu: bool) -> Self {
- self.has_menu = has_menu;
- self
- }
-
- #[cfg(not(feature = "ui_debug"))]
- pub fn with_menu(self, _has_menu: bool) -> Self {
- self
- }
-
/// Getting new current page according to page counter.
/// Also updating the possible title and moving the scrollbar to correct
/// position.
@@ -219,7 +204,7 @@ impl<F> Component for Flow<F>
where
F: Fn(usize) -> Page,
{
- type Msg = CancelInfoConfirmMsg;
+ type Msg = CancelConfirmMsg;
fn place(&mut self, bounds: Rect) -> Rect {
let (title_content_area, button_area) = bounds.split_bottom(theme::BUTTON_HEIGHT);
@@ -301,9 +286,8 @@ where
self.go_to_last_page(ctx);
return None;
}
- ButtonAction::Cancel => return Some(CancelInfoConfirmMsg::Cancelled),
- ButtonAction::Confirm => return Some(CancelInfoConfirmMsg::Confirmed),
- ButtonAction::Info => return Some(CancelInfoConfirmMsg::Info),
+ ButtonAction::Cancel => return Some(CancelConfirmMsg::Cancelled),
+ ButtonAction::Confirm => return Some(CancelConfirmMsg::Confirmed),
}
}
};
@@ -346,9 +330,5 @@ where
t.child("scrollbar", &self.scrollbar);
t.child("buttons", &self.buttons);
t.child("flow_page", &self.current_page);
- t.bool(
- "has_menu",
- self.has_menu && self.current_page.pager().is_last(),
- );
}
}
### core/embed/rust/src/ui/layout_caesar/component/input_methods/simple_choice.rs
@@ -23,8 +23,7 @@ struct ChoiceFactorySimple {
choices: Vec<TString<'static>, MAX_LENGTH>,
controls: ChoiceControls,
select_text: TString<'static>,
- /// Using the context menu buttons - arrow glyph to enter an item, cross to
- /// close the menu.
+ /// Using the context menu buttons - arrow glyph to enter an item.
menu_buttons: bool,
}
@@ -73,11 +72,7 @@ impl ChoiceFactory for ChoiceFactorySimple {
if self.controls != ChoiceControls::Carousel {
if choice_index == 0 {
if self.controls == ChoiceControls::Cancellable {
- choice_item.set_left_btn(Some(if self.menu_buttons {
- ButtonDetails::close_icon()
- } else {
- ButtonDetails::cancel_icon()
- }));
+ choice_item.set_left_btn(Some(ButtonDetails::cancel_icon()));
} else {
choice_item.set_left_btn(None);
}
@@ -150,8 +145,8 @@ impl SimpleChoice {
self
}
- /// Using the context menu buttons - arrow glyph to enter an item, cross to
- /// close the menu. `danger_items` marks the items that are dangerous.
+ /// Using the context menu buttons - arrow glyph to enter an item.
+ /// `danger_items` marks the items that are dangerous.
pub fn with_menu_buttons(mut self, danger_items: Vec<bool, MAX_LENGTH>) -> Self {
self.choice_page = self.choice_page.with_choice_factory(|choices| {
choices.menu_buttons = true;
### core/embed/rust/src/ui/layout_caesar/component/mod.rs
@@ -39,7 +39,6 @@ mod progress;
mod scrollbar;
#[cfg(feature = "translations")]
mod share_words;
-mod show_more;
mod title;
#[cfg(all(feature = "micropython", feature = "translations"))]
@@ -66,4 +65,3 @@ pub use progress::Progress;
pub use scrollbar::ScrollBar;
#[cfg(feature = "translations")]
pub use share_words::ShareWords;
-pub use show_more::{CancelInfoConfirmMsg, ShowMore};
### core/embed/rust/src/ui/layout_caesar/component/page.rs
@@ -14,10 +14,16 @@ use crate::ui::util::Pager;
/// `ButtonPage::with_menu_nav`).
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum MenuNav {
- /// Opens the context menu - the screen returns `PageMsg::Info`.
+ /// Opens the context menu with additional information - the screen returns
+ /// `PageMsg::Info`.
Menu,
- /// Closes the screen, e.g. the one opened from a context menu - the screen
- /// returns `PageMsg::Cancelled`.
+ /// Opens the context menu with choices how to continue the flow (e.g.
+ /// "Show all") - the screen returns `PageMsg::Info`. Unlike `Menu`, it is
+ /// not reported as an information menu to the debug tracing (automated
+ /// tests would otherwise pick the choices while visiting it).
+ ChoiceMenu,
+ /// Closes the screen, e.g. cancels the flow or closes the screen opened
+ /// from a context menu - the screen returns `PageMsg::Cancelled`.
Close,
}
@@ -31,9 +37,11 @@ where
confirm_btn_details: Option<ButtonDetails>,
back_btn_details: Option<ButtonDetails>,
next_btn_details: Option<ButtonDetails>,
- has_menu: bool,
/// Menu navigation, replacing the cancel/back/next buttons.
menu_nav: Option<MenuNav>,
+ /// Whether "Shift" + right button on the first page goes back to the
+ /// previous screen of the flow (menu navigation only).
+ back_on_first_page: bool,
/// Whether the left button is being held as "Shift" (menu navigation only).
shift_active: bool,
buttons: Child<ButtonController>,
@@ -51,8 +59,8 @@ where
confirm_btn_details: Some(ButtonDetails::text(TR::buttons__confirm.into())),
back_btn_details: Some(ButtonDetails::up_arrow_icon()),
next_btn_details: Some(ButtonDetails::down_arrow_icon_wide()),
- has_menu: false,
menu_nav: None,
+ back_on_first_page: false,
shift_active: false,
// Setting empty layout for now, we do not yet know the page count.
// Initial button layout will be set in `place()` after we can call
@@ -71,11 +79,6 @@ where
self
}
- pub fn with_menu(mut self, has_menu: bool) -> Self {
- self.has_menu = has_menu;
- self
- }
-
/// Navigation with the left button opening a context menu (or closing the
/// screen), and the right button scrolling down and finally confirming
/// (when there is a confirm button).
@@ -87,6 +90,15 @@ where
self
}
+ /// "Shift" is offered also on the first page, where it goes back to the
+ /// previous screen of the flow - the screen returns `PageMsg::Cancelled`.
+ /// Only for `MenuNav::Menu` and `MenuNav::ChoiceMenu`, where the left
+ /// button does not cancel.
+ pub fn with_back_on_first_page(mut self) -> Self {
+ self.back_on_first_page = true;
+ self
+ }
+
pub fn with_back_btn(mut self, btn_details: Option<ButtonDetails>) -> Self {
self.back_btn_details = btn_details;
self
@@ -141,15 +153,12 @@ where
} else {
self.back_btn_details.clone()
};
- let (btn_middle, btn_right) = match (has_next, self.has_menu) {
- (true, _) => (None, self.next_btn_details.clone()),
- (false, false) => (None, self.confirm_btn_details.clone()),
- (false, true) => (
- self.confirm_btn_details.clone().map(|b| b.with_arms()),
- Some(ButtonDetails::info_icon()),
- ),
+ let btn_right = if has_next {
+ self.next_btn_details.clone()
+ } else {
+ self.confirm_btn_details.clone()
};
- ButtonLayout::new(btn_left, btn_middle, btn_right)
+ ButtonLayout::new(btn_left, None, btn_right)
}
fn get_menu_nav_button_layout(
@@ -159,16 +168,17 @@ where
has_next: bool,
) -> ButtonLayout {
// The bracketed left icon advertises "Shift", which is offered only when
- // there is somewhere to scroll up to. It stays while "Shift" is held.
- let shift = has_prev || self.shift_active;
+ // there is somewhere to go back to. It stays while "Shift" is held.
+ let can_go_back = has_prev || self.back_on_first_page;
+ let shift = can_go_back || self.shift_active;
let btn_left = match (menu_nav, shift) {
- (MenuNav::Menu, false) => ButtonDetails::menu_icon(),
- (MenuNav::Menu, true) => ButtonDetails::menu_shift_icon(),
- (MenuNav::Close, false) => ButtonDetails::close_icon(),
- (MenuNav::Close, true) => ButtonDetails::close_shift_icon(),
+ (MenuNav::Menu | MenuNav::ChoiceMenu, false) => ButtonDetails::menu_icon(),
+ (MenuNav::Menu | MenuNav::ChoiceMenu, true) => ButtonDetails::menu_shift_icon(),
+ (MenuNav::Close, false) => ButtonDetails::cancel_icon(),
+ (MenuNav::Close, true) => ButtonDetails::cancel_shift_icon(),
};
let btn_right = if self.shift_active {
- has_prev.then(ButtonDetails::scroll_up_wide)
+ can_go_back.then(ButtonDetails::scroll_up_wide)
} else if has_next {
Some(ButtonDetails::scroll_down_wide())
} else {
@@ -186,7 +196,7 @@ where
match self.buttons.event(ctx, event) {
Some(ButtonControllerMsg::Triggered(ButtonPos::Left, _)) => {
return Some(match menu_nav {
- MenuNav::Menu => PageMsg::Info,
+ MenuNav::Menu | MenuNav::ChoiceMenu => PageMsg::Info,
MenuNav::Close => PageMsg::Cancelled,
});
}
@@ -202,9 +212,13 @@ where
self.shift_active = true;
self.update_buttons(ctx);
}
- Some(ButtonControllerMsg::ShiftedTriggered) if self.pager().has_prev() => {
- self.prev_page();
- self.change_page(ctx);
+ Some(ButtonControllerMsg::ShiftedTriggered) => {
+ if self.pager().has_prev() {
+ self.prev_page();
+ self.change_page(ctx);
+ } else if self.back_on_first_page {
+ return Some(PageMsg::Cancelled);
+ }
}
Some(ButtonControllerMsg::ShiftEnded) => {
self.shift_active = false;
@@ -279,8 +293,6 @@ where
// Clicked NEXT. Scroll down.
self.next_page();
self.change_page(ctx);
- } else if self.has_menu {
- return Some(PageMsg::Info);
} else {
return Some(PageMsg::Confirmed);
}
@@ -314,9 +326,9 @@ where
t.int("page_count", i64::from(self.pager().total()));
t.child("buttons", &self.buttons);
t.child("content", &self.content);
- let has_menu = self.has_menu || self.menu_nav == Some(MenuNav::Menu);
- t.bool("has_menu", has_menu && self.pager().is_last());
- // The context menu is opened by the left button.
- t.bool("left_menu", self.menu_nav == Some(MenuNav::Menu));
+ t.bool(
+ "has_menu",
+ self.menu_nav == Some(MenuNav::Menu) && self.pager().is_last(),
+ );
}
}
### core/embed/rust/src/ui/layout_caesar/component/show_more.rs
@@ -1,108 +0,0 @@
-use super::{theme, ButtonController, ButtonControllerMsg, ButtonLayout, ButtonPos};
-use crate::strutil::TString;
-use crate::ui::component::{Child, Component, Event, EventCtx, Never};
-use crate::ui::geometry::{Insets, Rect};
-use crate::ui::shape::Renderer;
-
-pub enum CancelInfoConfirmMsg {
- Cancelled,
- Info,
- Confirmed,
-}
-
-pub struct ShowMore<T> {
- content: Child<T>,
- buttons: Child<ButtonController>,
- #[cfg(feature = "ui_debug")]
- has_menu: bool,
-}
-
-impl<T> ShowMore<T>
-where
- T: Component,
-{
- pub fn new(
- content: T,
- cancel_button: Option<TString<'static>>,
- button: TString<'static>,
- verb_info: TString<'static>,
- ) -> Self {
- let btn_layout = if let Some(cancel_text) = cancel_button {
- ButtonLayout::text_armed_text(cancel_text, button, verb_info)
- } else {
- ButtonLayout::cancel_armed_text(button, verb_info)
- };
- Self {
- content: Child::new(content),
- buttons: Child::new(ButtonController::new(btn_layout)),
- #[cfg(feature = "ui_debug")]
- has_menu: false,
- }
- }
-
- #[cfg(feature = "ui_debug")]
- pub fn with_menu(mut self, has_menu: bool) -> Self {
- self.has_menu = has_menu;
- self
- }
-
- #[cfg(not(feature = "ui_debug"))]
- pub fn with_menu(self, _has_menu: bool) -> Self {
- self
- }
-}
-
-impl<T> Component for ShowMore<T>
-where
- T: Component<Msg = Never>,
-{
- type Msg = CancelInfoConfirmMsg;
-
- fn place(&mut self, bounds: Rect) -> Rect {
- let (content_area, button_area) = bounds.split_bottom(theme::BUTTON_HEIGHT);
- let content_area = content_area.inset(Insets::top(1));
- self.content.place(content_area);
- self.buttons.place(button_area);
- bounds
- }
-
- fn event(&mut self, ctx: &mut EventCtx, event: Event) -> Option<Self::Msg> {
- self.content.event(ctx, event);
- let button_event = self.buttons.event(ctx, event);
-
- if let Some(ButtonControllerMsg::Triggered(pos, _)) = button_event {
- match pos {
- ButtonPos::Left => {
- return Some(CancelInfoConfirmMsg::Cancelled);
- }
- ButtonPos::Middle => {
- return Some(CancelInfoConfirmMsg::Confirmed);
- }
- ButtonPos::Right => {
- return Some(CancelInfoConfirmMsg::Info);
- }
- }
- }
- None
- }
-
- fn render<'s>(&'s self, target: &mut impl Renderer<'s>) {
- self.content.render(target);
- self.buttons.render(target);
- }
-}
-
-// DEBUG-ONLY SECTION BELOW
-
-#[cfg(feature = "ui_debug")]
-impl<T> crate::trace::Trace for ShowMore<T>
-where
- T: crate::trace::Trace + Component,
-{
- fn trace(&self, t: &mut dyn crate::trace::Tracer) {
- t.component("ShowMore");
- t.child("buttons", &self.buttons);
- t.child("content", &self.content);
- t.bool("has_menu", self.has_menu);
- }
-}
### core/embed/rust/src/ui/layout_caesar/component_msg_obj.rs
@@ -1,9 +1,9 @@
use core::convert::TryInto;
use super::component::{
- AddressDetails, ButtonPage, CancelConfirmMsg, CancelInfoConfirmMsg, CoinJoinProgress,
- ConfirmHomescreen, Flow, Frame, Homescreen, Lockscreen, NumberInput, NumberInputAction, Page,
- PassphraseEntry, PinEntry, Progress, ScrollableFrame, ShowMore, WordlistEntry,
+ AddressDetails, ButtonPage, CancelConfirmMsg, CoinJoinProgress, ConfirmHomescreen, Flow, Frame,
+ Homescreen, Lockscreen, NumberInput, NumberInputAction, Page, PassphraseEntry, PinEntry,
+ Progress, ScrollableFrame, WordlistEntry,
};
use crate::micropython::{Error, Obj};
use crate::ui::component::base::Component;
@@ -24,19 +24,6 @@ impl From<CancelConfirmMsg> for Obj {
}
}
-impl<T> ComponentMsgObj for ShowMore<T>
-where
- T: Component<Msg = Never>,
-{
- fn msg_try_into_obj(&self, msg: Self::Msg) -> Result<Obj, Error> {
- match msg {
- CancelInfoConfirmMsg::Cancelled => Ok(CANCELLED.as_obj()),
- CancelInfoConfirmMsg::Info => Ok(INFO.as_obj()),
- CancelInfoConfirmMsg::Confirmed => Ok(CONFIRMED.as_obj()),
- }
- }
-}
-
impl<'a, T> ComponentMsgObj for Paragraphs<T>
where
T: ParagraphSource<'a>,
@@ -66,15 +53,14 @@ where
{
fn msg_try_into_obj(&self, msg: Self::Msg) -> Result<Obj, Error> {
match msg {
- CancelInfoConfirmMsg::Confirmed => {
+ CancelConfirmMsg::Confirmed => {
if let Some(index) = self.confirmed_index() {
index.try_into()
} else {
Ok(CONFIRMED.as_obj())
}
}
- CancelInfoConfirmMsg::Cancelled => Ok(CANCELLED.as_obj()),
- CancelInfoConfirmMsg::Info => Ok(INFO.as_obj()),
+ CancelConfirmMsg::Cancelled => Ok(CANCELLED.as_obj()),
}
}
}
@@ -197,12 +183,3 @@ impl ComponentMsgObj for ConfirmHomescreen {
}
}
}
-
-impl ComponentMsgObj for super::component::bl_confirm::Confirm<'_> {
- fn msg_try_into_obj(&self, msg: Self::Msg) -> Result<Obj, Error> {
- match msg {
- super::component::bl_confirm::ConfirmMsg::Cancel => Ok(CANCELLED.as_obj()),
- super::component::bl_confirm::ConfirmMsg::Confirm => Ok(CONFIRMED.as_obj()),
- }
- }
-}
### core/embed/rust/src/ui/layout_caesar/ui_firmware.rs
@@ -5,7 +5,7 @@ use heapless::Vec;
use super::component::{
AddressDetails, ButtonActions, ButtonDetails, ButtonLayout, ButtonPage, ChoiceControls,
CoinJoinProgress, ConfirmHomescreen, Flow, FlowPages, Frame, Homescreen, Lockscreen, MenuNav,
- NumberInput, Page, PassphraseEntry, PinEntry, Progress, ScrollableFrame, ShareWords, ShowMore,
+ NumberInput, Page, PassphraseEntry, PinEntry, Progress, ScrollableFrame, ShareWords,
SimpleChoice, WordlistEntry, WordlistType, SIMPLE_CHOICE_MAX_LENGTH,
};
use super::{constant, fonts, theme, UICaesar};
@@ -24,8 +24,7 @@ use crate::ui::component::text::paragraphs::{
};
use crate::ui::component::text::TextStyle;
use crate::ui::component::{
- Component, ComponentExt, Empty, FlowMsg, FormattedText, Label, LineBreaking, Never, PageMsg,
- Paginate, Timeout,
+ Component, ComponentExt, Empty, FlowMsg, FormattedText, Never, PageMsg, Paginate, Timeout,
};
use crate::ui::layout::menu_item_intent::MenuItemIntent;
use crate::ui::layout::obj::{LayoutMaybeTrace, LayoutObj, RootComponent};
@@ -51,7 +50,7 @@ impl FirmwareUI for UICaesar {
reverse: bool,
_prompt_screen: bool,
_prompt_title: Option<TString<'static>>,
- _external_menu: bool, // TODO: will eventually replace the internal menu
+ external_menu: bool,
) -> Result<impl LayoutMaybeTrace, Error> {
let paragraphs = {
let action = action.unwrap_or("".into());
@@ -75,7 +74,7 @@ impl FirmwareUI for UICaesar {
verb.unwrap_or(TString::empty()),
verb_cancel,
hold,
- false,
+ external_menu,
)
}
@@ -110,30 +109,20 @@ impl FirmwareUI for UICaesar {
FormattedText::new(ops).vertically_centered()
};
- if info_button {
- // The info is in the context menu, opened by the left button.
- let content = ButtonPage::new(address_ops(), theme::BG)
- .with_menu_nav(MenuNav::Menu)
- .with_confirm_btn(Some(ButtonDetails::text(verb)));
- let frame = ScrollableFrame::new(content)
- .with_title(title)
- .with_numeric_page_counter();
- return LayoutObj::new(frame);
- }
-
- let get_page = move |page_index| {
- assert!(page_index == 0);
- Page::new(
- ButtonLayout::cancel_none_text(verb),
- ButtonActions::cancel_none_confirm(),
- address_ops(),
- )
- .with_title(title)
+ // The info is in the context menu, opened by the left button. Without
+ // it, the left button cancels.
+ let menu_nav = if info_button {
+ MenuNav::Menu
+ } else {
+ MenuNav::Close
};
- let pages = FlowPages::new(get_page, 1);
-
- let obj = LayoutObj::new(Flow::new(pages))?;
- Ok(obj)
+ let content = ButtonPage::new(address_ops(), theme::BG)
+ .with_menu_nav(menu_nav)
+ .with_confirm_btn(Some(ButtonDetails::text(verb)));
+ let frame = ScrollableFrame::new(content)
+ .with_title(title)
+ .with_numeric_page_counter();
+ LayoutObj::new(frame)
}
fn confirm_trade(
@@ -163,7 +152,7 @@ impl FirmwareUI for UICaesar {
_cancel: bool,
_back_button: bool,
_footer: Option<(TString<'static>, bool)>,
- _external_menu: bool,
+ external_menu: bool,
) -> Result<impl LayoutMaybeTrace, Error> {
let paragraphs = ConfirmValueParams {
description: description.unwrap_or("".into()),
@@ -188,7 +177,7 @@ impl FirmwareUI for UICaesar {
verb.unwrap_or(TR::buttons__confirm.into()),
verb_cancel,
hold,
- false,
+ external_menu,
)
}
@@ -314,32 +303,17 @@ impl FirmwareUI for UICaesar {
fn confirm_firmware_update(
description: TString<'static>,
- fingerprint: TString<'static>,
+ _fingerprint: TString<'static>,
) -> Result<impl LayoutMaybeTrace, Error> {
- use super::component::bl_confirm::Confirm;
- let title = TR::firmware_update__title;
- let message = Label::left_aligned(description, theme::TEXT_NORMAL).vertically_centered();
- let fingerprint = Label::left_aligned(
- fingerprint,
- theme::TEXT_NORMAL.with_line_breaking(LineBreaking::BreakWordsNoHyphen),
- )
- .vertically_centered();
-
- let layout = RootComponent::new(
- Confirm::new(
- theme::BG,
- title.into(),
- message,
- None,
- TR::buttons__install.as_tstring(),
- false,
- )
- .with_info_screen(
- TR::firmware_update__title_fingerprint.as_tstring(),
- fingerprint,
- ),
- );
- Ok(layout)
+ // The fingerprint is shown in the context menu.
+ let paragraphs = Paragraph::new(&theme::TEXT_NORMAL, description).into_paragraphs();
+ let content = ButtonPage::new(paragraphs, theme::BG)
+ .with_menu_nav(MenuNav::Menu)
+ .with_confirm_btn(Some(ButtonDetails::text(TR::buttons__install.into())));
+ let frame = ScrollableFrame::new(content)
+ .with_title(TR::firmware_update__title.into())
+ .with_numeric_page_counter();
+ Ok(RootComponent::new(frame))
}
fn confirm_modify_fee(
@@ -493,139 +467,58 @@ impl FirmwareUI for UICaesar {
fee_label: TString<'static>,
title: Option<TString<'static>>,
account_items: Option<Obj>,
- account_title: Option<TString<'static>>,
+ _account_title: Option<TString<'static>>,
extra_items: Option<Obj>,
- extra_title: Option<TString<'static>>,
- verb_cancel: Option<TString<'static>>,
- _back_button: bool,
- external_menu: bool, // TODO: will eventually replace the internal menu
+ _extra_title: Option<TString<'static>>,
+ _verb_cancel: Option<TString<'static>>,
+ back_button: bool,
+ external_menu: bool,
) -> Result<impl LayoutMaybeTrace, Error> {
- // collect available info pages
- let mut info_pages: Vec<(TString, Obj), 2> = Vec::new();
- if let Some(info) = extra_items {
- // put extra items first as it's typically used for fee info
- let extra_title = extra_title.unwrap_or(TR::words__title_information.into());
- unwrap!(info_pages.push((extra_title, info)));
- }
- if let Some(info) = account_items {
- let account_title =
- account_title.unwrap_or(TR::confirm_total__title_sending_from.into());
- unwrap!(info_pages.push((account_title, info)));
- }
- if external_menu && !info_pages.is_empty() {
+ if account_items.is_some() || extra_items.is_some() {
+ // The information is shown in the context menu on this model.
return Err(Error::NotImplementedError);
}
- // button layouts and actions
- let verb_cancel: TString = verb_cancel.unwrap_or(TString::empty());
- let btns_summary_page = move |has_pages_after: bool| -> (ButtonLayout, ButtonActions) {
- // if there are no info pages, the right button is not needed
- // if verb_cancel is "^", the left button is an arrow pointing up
- let left_btn = Some(ButtonDetails::from_text_possible_icon(verb_cancel));
- let right_btn = (has_pages_after || external_menu).then(ButtonDetails::info_icon);
- let middle_btn = Some(ButtonDetails::armed_text(TR::buttons__confirm.into()));
-
- (
- ButtonLayout::new(left_btn, middle_btn, right_btn),
- if has_pages_after {
- ButtonActions::cancel_confirm_next()
- } else if external_menu {
- ButtonActions::cancel_confirm_info()
- } else {
- ButtonActions::cancel_confirm_none()
- },
- )
- };
- let btns_info_page = |is_last: bool| -> (ButtonLayout, ButtonActions) {
- // on the last info page, the right button is not needed
- if is_last {
- (
- ButtonLayout::arrow_none_none(),
- ButtonActions::prev_none_none(),
- )
- } else {
- (
- ButtonLayout::arrow_none_arrow(),
- ButtonActions::prev_none_next(),
- )
- }
- };
-
- let total_pages = 1 + info_pages.len();
- let get_page = move |page_index| {
- match page_index {
- 0 => {
- // Total amount + fee
- let (btn_layout, btn_actions) = btns_summary_page(!info_pages.is_empty());
-
- let mut ops = OpTextLayout::new(theme::TEXT_MONO);
- if let Some(title) = title {
- ops.add_text_with_font(title, fonts::FONT_BOLD_UPPER)
- .add_newline();
- }
-
- let mut has_amount = false;
- if let Some(amount) = amount {
- if let Some(amount_label) = amount_label {
- has_amount = true;
- ops.add_text_with_font(amount_label, fonts::FONT_BOLD);
- if !amount_label.is_empty() && !amount.is_empty() {
- ops.add_newline();
- }
- ops.add_text_with_font(amount, fonts::FONT_MONO);
- }
- }
-
- if !fee_label.is_empty() || !fee.is_empty() {
- if has_amount {
- ops.add_newline();
- }
- ops.add_newline()
- .add_text_with_font(fee_label, fonts::FONT_BOLD)
- .add_newline()
- .add_text_with_font(fee, fonts::FONT_MONO);
- }
-
- let formatted = FormattedText::new(ops);
- Page::new(btn_layout, btn_actions, formatted)
- }
- i => {
- // Other info pages as provided
- let (title, info_obj) = &info_pages[i - 1];
- let is_last = i == total_pages - 1;
- let (btn_layout, btn_actions) = btns_info_page(is_last);
-
- let mut ops = OpTextLayout::new(theme::TEXT_MONO);
- let mut iter_buf = IterBuf::new();
- for item in unwrap!(iter_buf.try_iterate(*info_obj)) {
- let [key, value, _is_data]: [Obj; 3] = unwrap!(util::iter_into_array(item));
- if !ops.is_empty() {
- // Each key-value pair is on its own page
- ops.add_next_page();
- }
- ops.add_text_with_font(unwrap!(TString::try_from(key)), fonts::FONT_BOLD)
- .add_newline()
- .add_text_with_font(
- unwrap!(TString::try_from(value)),
- fonts::FONT_MONO,
- );
- }
-
- let formatted = FormattedText::new(ops).vertically_centered();
- Page::new(btn_layout, btn_actions, formatted)
- .with_slim_arrows()
- .with_title(*title)
+ let mut ops = OpTextLayout::new(theme::TEXT_MONO);
+ let mut has_amount = false;
+ if let Some(amount) = amount {
+ if let Some(amount_label) = amount_label {
+ has_amount = true;
+ ops.add_text_with_font(amount_label, fonts::FONT_BOLD);
+ if !amount_label.is_empty() && !amount.is_empty() {
+ ops.add_newline();
}
+ ops.add_text_with_font(amount, fonts::FONT_MONO);
}
- };
- let pages = FlowPages::new(get_page, total_pages);
+ }
+ if !fee_label.is_empty() || !fee.is_empty() {
+ if has_amount {
+ ops.add_newline();
+ }
+ ops.add_newline()
+ .add_text_with_font(fee_label, fonts::FONT_BOLD)
+ .add_newline()
+ .add_text_with_font(fee, fonts::FONT_MONO);
+ }
- let layout = RootComponent::new(
- Flow::new(pages)
- .with_scrollbar(false)
- .with_menu(external_menu),
+ // The info is in the context menu, opened by the left button. Without
+ // it, the left button cancels.
+ let mut content = ButtonPage::new(FormattedText::new(ops), theme::BG).with_confirm_btn(
+ Some(ButtonDetails::text(TR::buttons__hold_to_confirm.into()).with_default_duration()),
);
- Ok(layout)
+ if external_menu {
+ content = content.with_menu_nav(MenuNav::Menu);
+ if back_button {
+ content = content.with_back_on_first_page();
+ }
+ } else {
+ content = content.with_menu_nav(MenuNav::Close);
+ }
+ let mut frame = ScrollableFrame::new(content).with_numeric_page_counter();
+ if let Some(title) = title {
+ frame = frame.with_title(title);
+ }
+ Ok(RootComponent::new(frame))
}
fn confirm_with_info(
@@ -634,7 +527,7 @@ impl FirmwareUI for UICaesar {
items: Obj,
verb: TString<'static>,
verb_info: Option<TString<'static>>,
- verb_cancel: Option<TString<'static>>,
+ _verb_cancel: Option<TString<'static>>,
external_menu: bool,
) -> Result<Gc<LayoutObj>, Error> {
let mut paragraphs = ParagraphVecShort::new();
@@ -647,7 +540,7 @@ impl FirmwareUI for UICaesar {
let [text, is_data]: [Obj; 2] = util::iter_into_array(para)?;
let is_data = is_data.try_into()?;
let style: &TextStyle = if is_data {
- &theme::TEXT_MONO_DATA_WITH_CLASSIC_ELLIPSIS
+ &theme::TEXT_MONO_DATA
} else {
&theme::TEXT_NORMAL
};
@@ -658,16 +551,28 @@ impl FirmwareUI for UICaesar {
}
}
- LayoutObj::new(Frame::new(
- title,
- ShowMore::<Paragraphs<ParagraphVecShort>>::new(
- paragraphs.into_paragraphs(),
- verb_cancel,
- verb,
- verb_info.unwrap_or_else(TString::empty),
- )
- .with_menu(external_menu),
- ))
+ // The info, or the choice to show more (`verb_info`), is in the context
+ // menu, opened by the left button. Without it, the left button cancels.
+ let menu_nav = if external_menu {
+ MenuNav::Menu
+ } else if verb_info.is_some_and(|verb_info| !verb_info.is_empty()) {
+ MenuNav::ChoiceMenu
+ } else {
+ MenuNav::Close
+ };
+ let confirm_btn = if verb == TString::Str(DOWN_ARROW) {
+ ButtonDetails::scroll_down_wide()
+ } else {
+ ButtonDetails::text(verb)
+ };
+ let content = ButtonPage::new(paragraphs.into_paragraphs(), theme::BG)
+ .with_menu_nav(menu_nav)
+ .with_confirm_btn(Some(confirm_btn));
+ LayoutObj::new(
+ ScrollableFrame::new(content)
+ .with_title(title)
+ .with_numeric_page_counter(),
+ )
}
fn check_homescreen_format(image: BinaryData, _accept_toif: bool) -> bool {
@@ -1481,10 +1386,16 @@ impl FirmwareUI for UICaesar {
}
}
+/// Text of the confirm button showing a wide down arrow instead.
+const DOWN_ARROW: &str = "V";
+
/// Function to create and call a `ButtonPage` dialog based on paginable content
/// (e.g. `Paragraphs` or `FormattedText`).
/// Has optional title (supply empty `TString` for that) and hold-to-confirm
/// functionality.
+///
+/// With `external_menu`, the left button opens the context menu. Otherwise, an
+/// empty `verb_cancel` puts a cross cancelling the flow on the left.
fn content_in_button_page<T: Component + Paginate + MaybeTrace + 'static>(
title: TString<'static>,
content: T,
@@ -1493,30 +1404,30 @@ fn content_in_button_page<T: Component + Paginate + MaybeTrace + 'static>(
hold: bool,
external_menu: bool,
) -> Result<impl LayoutMaybeTrace, Error> {
- // Left button - icon, text or nothing.
- let cancel_btn = verb_cancel.map(ButtonDetails::from_text_possible_icon);
-
// Right button - down arrow, text or nothing.
// Optional HoldToConfirm
- let mut confirm_btn = if !verb.is_empty() {
- if verb == TString::Str("V") {
- Some(ButtonDetails::down_arrow_icon_wide())
- } else {
- Some(ButtonDetails::text(verb))
- }
- } else {
+ let mut confirm_btn = if verb.is_empty() {
None
+ } else if verb == TString::Str(DOWN_ARROW) {
+ Some(ButtonDetails::scroll_down_wide())
+ } else {
+ Some(ButtonDetails::text(verb))
};
- if hold && !external_menu {
+ if hold {
confirm_btn = confirm_btn.map(|btn| btn.with_default_duration());
}
- let content = ButtonPage::new(content, theme::BG)
- .with_cancel_btn(cancel_btn)
- .with_confirm_btn(confirm_btn)
- .with_menu(external_menu);
+ let mut content = ButtonPage::new(content, theme::BG).with_confirm_btn(confirm_btn);
+ if external_menu {
+ content = content.with_menu_nav(MenuNav::Menu);
+ } else if verb_cancel.is_some_and(|verb_cancel| verb_cancel.is_empty()) {
+ content = content.with_menu_nav(MenuNav::Close);
+ } else {
+ // Left button - back arrow, text or nothing.
+ content = content.with_cancel_btn(verb_cancel.map(ButtonDetails::from_text_possible_icon));
+ }
- let mut frame = ScrollableFrame::new(content);
+ let mut frame = ScrollableFrame::new(content).with_numeric_page_counter();
if !title.is_empty() {
frame = frame.with_title(title);
}
### core/mocks/generated/trezorui_api.pyi
@@ -362,9 +362,10 @@ def confirm_summary(
) -> LayoutContext[UiResult]:
"""Confirm summary of a transaction.
account_items and extra_items need to be:
- * a list (on Eckhart and Caesar)
+ * a list (on Eckhart)
* an iterable (on Delizia)
* None / non-None on Bolt
+ * None on Caesar (shown in the external menu instead)
TODO: get rid of account_items and extra_items for consistency!
"""
### core/src/trezor/ui/layouts/caesar/__init__.py
@@ -13,20 +13,22 @@
from collections.abc import Awaitable, Callable, Iterable, Sequence
from typing import NoReturn
+ from typing_extensions import TypeVar
+
from apps.stellar.tokens import StellarToken
from ..common import ExceptionType, PropertyType, StrPropertyType
- from ..menu import MenuLeaf
+ from ..menu import Menu, MenuLeaf
from ..properties import AboveThreshold
from ..slip24 import Refund, Trade
+ R = TypeVar("R")
+
CONFIRMED = trezorui_api.CONFIRMED
CANCELLED = trezorui_api.CANCELLED
-INFO = trezorui_api.INFO
DOWN_ARROW = "V"
-INFO_ICON = "i"
BR_CODE_OTHER = ButtonRequestType.Other # global_import_cache
@@ -555,7 +557,7 @@ async def confirm_payment_request(
fee_info_items: Sequence[StrPropertyType] | None,
extra_menu_items: list[tuple[str, str]] | None = None,
) -> None:
- from trezor.ui.layouts.menu import Menu, confirm_with_menu
+ from trezor.ui.layouts.menu import confirm_with_menu
from ..properties import with_colon
from ..slip24 import is_swap
@@ -593,16 +595,17 @@ async def _task() -> None:
)
)
if menu_items:
- menu = Menu(menu_items)
-
with trezorui_api.confirm_with_info(
title=title,
items=[(TR.words__provider, True), (recipient_name, False)],
verb=TR.buttons__continue,
- verb_info=INFO_ICON,
external_menu=True,
) as main_layout:
- await confirm_with_menu(main_layout, menu, "confirm_payment_request")
+ await confirm_with_menu(
+ main_layout,
+ _menu_with_cancel(menu_items),
+ "confirm_payment_request",
+ )
else:
await confirm_properties(
"confirm_payment_request",
@@ -623,27 +626,18 @@ async def _task() -> None:
if transaction_fee is not None:
assert fee_info_items is not None
- summary_ctx = trezorui_api.confirm_summary(
- amount=None,
- amount_label=None,
+ await _confirm_summary(
+ "confirm_payment_request",
fee=transaction_fee,
fee_label=with_colon(TR.words__transaction_fee),
title=TR.words__title_summary,
- external_menu=True,
+ info=(
+ (TR.confirm_total__title_fee, fee_info_items),
+ (TR.address_details__account_info, account_items),
+ ),
+ br_code=BR_CODE_OTHER,
)
- summary_menu_items = [
- create_info_menu_leaf(TR.confirm_total__title_fee, fee_info_items),
- create_info_menu_leaf(TR.address_details__account_info, account_items),
- ]
-
- summary_menu = Menu(summary_menu_items)
-
- with summary_ctx as summary_layout:
- await confirm_with_menu(
- summary_layout, summary_menu, br_name="confirm_payment_request"
- )
-
async def confirm_output(
address: str,
@@ -715,29 +709,45 @@ async def should_show_more(
confirm: str | None = None,
verb_cancel: str | None = None,
) -> bool:
- """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.
+ """Return True if the user wants to show more (they choose `button_text`
+ from the menu, or scroll down if it is `DOWN_ARROW`) and False when the
+ user wants to continue without showing details (`confirm`).
Raises ActionCancelled if the user cancels.
"""
+ from trezor.ui.layouts.menu import MenuLeaf, MenuResult, interact_with_menu
+
+ confirm = confirm or TR.buttons__confirm # def_arg
+
+ # The right button continues, the other choice is in the menu.
+ if button_text == DOWN_ARROW:
+ verb, choice, show_more = DOWN_ARROW, confirm, False
+ else:
+ verb, choice, show_more = confirm, button_text, True
+ if choice is None:
+ choice = TR.buttons__show_all
- if button_text not in (DOWN_ARROW, ""):
- button_text = INFO_ICON
with trezorui_api.confirm_with_info(
title=title,
items=para,
- verb=confirm or TR.buttons__confirm,
- verb_cancel=verb_cancel,
- verb_info=button_text, # use info icon by default
- ) as layout_obj:
- result = await interact(layout_obj, br_name, br_code)
+ verb=verb,
+ verb_info=choice,
+ ) as layout:
+ if not choice:
+ # nothing to choose from, the left button cancels
+ await raise_if_not_confirmed(layout, br_name, br_code)
+ return False
- if result is CONFIRMED:
- return False
- elif result is INFO:
- return True
- else:
- raise ActionCancelled
+ async def choose() -> bool:
+ return show_more
+
+ menu = _menu_with_cancel([MenuLeaf(choice, choose)])
+ result = await interact_with_menu(layout, menu, br_name, br_code)
+
+ if isinstance(result, MenuResult):
+ return result.value
+ assert result is CONFIRMED
+ return not show_more
async def confirm_blob_intro(
@@ -962,7 +972,7 @@ async def confirm_value(
br_code,
)
- from trezor.ui.layouts.menu import Menu, confirm_with_menu, leaf_from_layout
+ from trezor.ui.layouts.menu import confirm_with_menu, leaf_from_layout
if chunkify:
main_ctx = trezorui_api.confirm_address(
@@ -979,7 +989,6 @@ async def confirm_value(
subtitle=description,
items=((value, False),),
verb=verb or TR.buttons__confirm,
- verb_info=INFO_ICON,
external_menu=True,
)
@@ -996,7 +1005,7 @@ def item_factory(
chunkify=chunkify_info,
)
- menu = Menu(
+ menu = _menu_with_cancel(
leaf_from_layout(name or "", item_factory(name or "", value or ""))
for name, value, _is_data in info_items
)
@@ -1021,29 +1030,29 @@ async def confirm_total(
from ..properties import with_colon
- with trezorui_api.confirm_summary(
+ await _confirm_summary(
+ br_name,
amount=total_amount,
amount_label=with_colon(total_label),
fee=fee_amount,
fee_label=with_colon(fee_label),
- account_title=account_title,
- account_items=with_colon(account_items),
- extra_items=with_colon(fee_items),
- extra_title=TR.confirm_total__title_fee,
- ) as layout:
- return await raise_if_not_confirmed(
- layout,
- br_name,
- br_code,
- )
+ info=(
+ (TR.confirm_total__title_fee, with_colon(fee_items)),
+ (
+ account_title or TR.confirm_total__title_sending_from,
+ with_colon(account_items),
+ ),
+ ),
+ br_code=br_code,
+ )
async def confirm_trade(
title: str,
trade: Trade,
extra_menu_items: list[tuple[str, str]],
) -> None:
- from trezor.ui.layouts.menu import Menu, confirm_with_menu
+ from trezor.ui.layouts.menu import confirm_with_menu
items = []
if trade.sell_amount is not None:
@@ -1068,7 +1077,7 @@ async def confirm_trade(
]
for k, v in extra_menu_items:
menu_items.append(create_info_menu_leaf(k, v))
- menu = Menu(menu_items)
+ menu = _menu_with_cancel(menu_items)
with trade_ctx as trade_layout:
await confirm_with_menu(trade_layout, menu, "confirm_trade")
@@ -1222,21 +1231,19 @@ async def confirm_ethereum_approve(
if account_path:
account_items = ((TR.address_details__derivation_path, account_path, None),)
- with trezorui_api.confirm_summary(
+ await _confirm_summary(
+ "confirm_ethereum_approve",
amount=native_amount,
amount_label=with_colon(TR.words__amount) if native_amount else None,
fee=maximum_fee,
fee_label=with_colon(TR.send__maximum_fee),
title=TR.words__title_summary,
- account_items=with_colon(account_items),
- account_title=TR.address_details__account_info,
- extra_items=with_colon(fee_info_items),
- extra_title=TR.confirm_total__title_fee,
- ) as layout:
- await raise_if_not_confirmed(
- layout,
- br_name="confirm_ethereum_approve",
- )
+ info=(
+ (TR.confirm_total__title_fee, with_colon(fee_info_items)),
+ (TR.address_details__account_info, with_colon(account_items)),
+ ),
+ br_code=BR_CODE_OTHER,
+ )
async def confirm_ethereum_clear_signing(
contract_name: str,
@@ -1249,7 +1256,7 @@ async def confirm_ethereum_clear_signing(
account: str | None = None,
account_path: str | None = None,
) -> None:
- from trezor.ui.layouts.menu import Menu, confirm_with_menu
+ from trezor.ui.layouts.menu import confirm_with_menu
from ..properties import with_colon
@@ -1282,7 +1289,7 @@ def _menu() -> Menu[None]:
TR.ethereum__contract_address, with_colon(contract_properties)
)
)
- return Menu(menu_items)
+ return _menu_with_cancel(menu_items)
await confirm_action(
f"{br_name}/provider", TR.ethereum__contract_address, contract_name
@@ -1299,15 +1306,12 @@ def _menu() -> Menu[None]:
layout, _menu(), br_name, ButtonRequestType.ConfirmOutput
)
- # NOTE: `account_items`/`extra_items` cannot be combined with an external
- # menu on Caesar, so all the context goes into the menu.
+ # all the context goes into the menu
with trezorui_api.confirm_summary(
amount=amount,
amount_label=with_colon(TR.words__amount) if amount is not None else None,
fee=maximum_fee,
fee_label=with_colon(TR.send__maximum_fee),
- extra_items=None,
- extra_title=None,
external_menu=True,
) as layout:
await confirm_with_menu(layout, _menu(), f"{br_name}/summary")
@@ -1348,19 +1352,15 @@ async def confirm_ethereum_staking_tx(
amount_title = with_colon(TR.words__amount)
amount_value = total_amount
- with trezorui_api.confirm_summary(
+ await _confirm_summary(
+ br_name,
amount=amount_value,
amount_label=amount_title,
fee=maximum_fee,
fee_label=with_colon(TR.send__maximum_fee),
- extra_items=with_colon(info_items),
- extra_title=TR.confirm_total__title_fee,
- ) as layout:
- await raise_if_not_confirmed(
- layout,
- br_name=br_name,
- br_code=br_code,
- )
+ info=((TR.confirm_total__title_fee, with_colon(info_items)),),
+ br_code=br_code,
+ )
async def confirm_ethereum_vault_tx(
title: str,
@@ -1461,20 +1461,14 @@ async def confirm_ethereum_vault_tx(
br_code=br_code,
)
- with trezorui_api.confirm_summary(
- amount=None,
- amount_label=None,
+ await _confirm_summary(
+ f"{br_name}/summary",
fee=maximum_fee,
fee_label=with_colon(TR.send__maximum_fee),
- extra_title=TR.confirm_total__title_fee,
- extra_items=with_colon(info_items),
title=title,
- ) as layout:
- await raise_if_not_confirmed(
- layout,
- br_name=f"{br_name}/summary",
- br_code=br_code,
- )
+ info=((TR.confirm_total__title_fee, with_colon(info_items)),),
+ br_code=br_code,
+ )
async def confirm_ethereum_vault_claim(
title: str,
@@ -1520,20 +1514,14 @@ async def confirm_ethereum_vault_claim(
br_code=br_code,
)
- with trezorui_api.confirm_summary(
- amount=None,
- amount_label=None,
+ await _confirm_summary(
+ f"{br_name}/summary",
fee=maximum_fee,
fee_label=with_colon(TR.send__maximum_fee),
- extra_title=TR.confirm_total__title_fee,
- extra_items=with_colon(info_items),
title=title,
- ) as layout:
- await raise_if_not_confirmed(
- layout,
- br_name=f"{br_name}/summary",
- br_code=br_code,
- )
+ info=((TR.confirm_total__title_fee, with_colon(info_items)),),
+ br_code=br_code,
+ )
async def confirm_ethereum_eip7702_auth(
delegate_name: str,
@@ -1543,7 +1531,7 @@ async def confirm_ethereum_eip7702_auth(
account_path: str,
nonce: int,
) -> None:
- from trezor.ui.layouts.menu import Menu, confirm_with_menu
+ from trezor.ui.layouts.menu import confirm_with_menu
with trezorui_api.show_warning(
title=TR.words__warning,
@@ -1586,8 +1574,7 @@ async def confirm_ethereum_eip7702_auth(
]
await confirm_with_menu(
layout,
- # no cancel entry: this model cancels with the hardware button
- Menu(children),
+ _menu_with_cancel(children),
"ethereum/auth7702/details",
ButtonRequestType.SignTx,
)
@@ -1598,21 +1585,20 @@ async def confirm_ethereum_eip7702_revoke(
account_path: str,
nonce: int,
) -> None:
- from trezor.ui.layouts.menu import Menu, confirm_with_menu
+ from trezor.ui.layouts.menu import confirm_with_menu
account_info = with_colon(
(
(TR.words__account, account, False),
(TR.address_details__derivation_path, account_path, False),
)
)
- # no cancel entry: this model cancels with the hardware button
- menu = Menu(
- children=[
+ menu = _menu_with_cancel(
+ [
create_info_menu_leaf(TR.address_details__account_info, account_info),
# TODO: switch to non-Cardano specific string
create_info_menu_leaf(TR.cardano__nonce, str(nonce)),
- ],
+ ]
)
with trezorui_api.confirm_action(
@@ -1692,19 +1678,15 @@ async def confirm_solana_tx(
amount_title if amount_title is not None else TR.words__amount
) # def_arg
fee_title = fee_title or TR.words__fee # def_arg
- with trezorui_api.confirm_summary(
+ await _confirm_summary(
+ br_name,
amount=amount,
amount_label=with_colon(amount_title),
fee=fee,
fee_label=with_colon(fee_title),
- extra_items=with_colon(items),
- extra_title=TR.words__title_information,
- ) as layout:
- return await raise_if_not_confirmed(
- layout,
- br_name=br_name,
- br_code=br_code,
- )
+ info=((TR.words__title_information, with_colon(items)),),
+ br_code=br_code,
+ )
async def confirm_solana_staking_tx(
title: str | None,
@@ -1721,7 +1703,7 @@ async def confirm_solana_staking_tx(
br_name: str = "confirm_solana_staking_tx",
br_code: ButtonRequestType = ButtonRequestType.SignTx,
) -> None:
- from trezor.ui.layouts.menu import Menu, confirm_with_menu
+ from trezor.ui.layouts.menu import confirm_with_menu
from ..properties import with_colon
@@ -1756,7 +1738,7 @@ async def confirm_solana_staking_tx(
fee_label="",
external_menu=True,
)
- menu = Menu(
+ menu = _menu_with_cancel(
create_info_menu_leaf(name or "", value or "")
for name, value, _is_data in items
)
@@ -1780,7 +1762,9 @@ async def confirm_solana_staking_tx(
(TR.confirm_total__title_fee, fee_details),
(TR.address_details__account_info, account_details),
]
- menu = Menu(create_info_menu_leaf(name, props) for name, props in iter)
+ menu = _menu_with_cancel(
+ create_info_menu_leaf(name, props) for name, props in iter
+ )
with main_ctx as main:
await confirm_with_menu(main, menu, br_name, br_code)
@@ -1795,18 +1779,14 @@ async def confirm_cardano_tx(
amount_title = TR.send__total_amount
fee_title = TR.send__including_fee
- with trezorui_api.confirm_summary(
+ await _confirm_summary(
+ "confirm_cardano_tx",
amount=amount,
amount_label=with_colon(amount_title),
fee=fee,
fee_label=with_colon(fee_title),
- extra_items=with_colon(items),
- ) as layout:
- return await raise_if_not_confirmed(
- layout,
- br_name="confirm_cardano_tx",
- br_code=ButtonRequestType.SignTx,
- )
+ info=((TR.words__title_information, with_colon(items)),),
+ )
async def confirm_ethereum_tx(
recipient: str | None,
@@ -1821,21 +1801,29 @@ async def confirm_ethereum_tx(
chunkify: bool = False,
native_amount: str | None = None,
) -> None:
+ from trezor.ui.layouts.menu import interact_with_menu
+
from ..properties import with_colon
if native_amount is not None:
# A non-zero native ETH value carried alongside a token transfer;
# show it next to the token amount so it can't be signed unseen.
total_amount = f"{total_amount}\n{native_amount}"
+ menu = _menu_with_cancel(
+ [
+ create_info_menu_leaf(
+ TR.confirm_total__title_fee, with_colon(fee_info_items)
+ )
+ ]
+ )
with trezorui_api.confirm_summary(
amount=total_amount,
amount_label=with_colon(TR.words__amount),
fee=maximum_fee,
fee_label=with_colon(TR.send__maximum_fee),
- extra_items=with_colon(fee_info_items),
- extra_title=TR.confirm_total__title_fee,
- verb_cancel="^",
+ back_button=True,
+ external_menu=True,
) as summary_layout:
if is_send:
title = TR.words__recipient
@@ -1853,15 +1841,12 @@ async def confirm_ethereum_tx(
chunkify=(chunkify if recipient else False),
)
- try:
- await raise_if_not_confirmed(
- summary_layout,
- br_name,
- br_code,
- )
+ # going back to the recipient returns CANCELLED
+ result = await interact_with_menu(
+ summary_layout, menu, br_name, br_code, raise_on_cancel=None
+ )
+ if result is CONFIRMED:
break
- except ActionCancelled:
- continue
async def confirm_stellar_tx(
fee: str,
@@ -1872,29 +1857,27 @@ async def confirm_stellar_tx(
) -> None:
from ..properties import with_colon
- with trezorui_api.confirm_summary(
- amount=None,
- amount_label=None,
+ await _confirm_summary(
+ "confirm_stellar_tx",
fee=fee,
fee_label=with_colon(TR.send__maximum_fee),
- account_items=with_colon(
+ info=(
+ (TR.words__title_information, with_colon(extra_items)),
(
- (TR.words__account, account_name, None),
- (TR.address_details__derivation_path, account_path, None),
- )
- ),
- account_title=(
- TR.send__send_from
- if is_sending_from_trezor_account
- else TR.stellar__sign_with
+ (
+ TR.send__send_from
+ if is_sending_from_trezor_account
+ else TR.stellar__sign_with
+ ),
+ with_colon(
+ (
+ (TR.words__account, account_name, None),
+ (TR.address_details__derivation_path, account_path, None),
+ )
+ ),
+ ),
),
- extra_items=with_colon(extra_items),
- ) as layout:
- return await raise_if_not_confirmed(
- layout,
- br_name="confirm_stellar_tx",
- br_code=ButtonRequestType.SignTx,
- )
+ )
def _stellar_title(title: str, subtitle: str) -> str:
# the layouts used here have no subtitle slot, join both parts into the title
@@ -2045,20 +2028,15 @@ async def confirm_tron_summary(
fee or "",
(TR.words__fee_limit if fee else ""),
)
- with trezorui_api.confirm_summary(
- title=title or TR.words__title_summary,
+ await _confirm_summary(
+ "tron/summary",
amount=display_amount,
amount_label=with_colon(display_amount_label),
fee=display_fee,
fee_label=with_colon(display_fee_label),
- account_items=with_colon(account_items),
- account_title=TR.address_details__account_info,
- ) as layout:
- await raise_if_not_confirmed(
- layout,
- br_name="tron/summary",
- br_code=ButtonRequestType.SignTx,
- )
+ title=title or TR.words__title_summary,
+ info=((TR.address_details__account_info, with_colon(account_items)),),
+ )
async def confirm_tron_send(
amount: str | None,
@@ -2149,8 +2127,6 @@ async def confirm_tron_approve(
fee=maximum_fee,
fee_label=with_colon(TR.words__fee_limit),
title=title,
- account_title=TR.address_details__account_info,
- extra_title=TR.confirm_total__title_fee,
) as layout:
await raise_if_not_confirmed(
layout,
@@ -2204,8 +2180,6 @@ async def confirm_tron_transfer(
fee=maximum_fee,
fee_label=with_colon(TR.words__fee_limit),
title=title,
- account_title=TR.address_details__account_info,
- extra_title=TR.confirm_total__title_fee,
) as layout:
await raise_if_not_confirmed(
layout,
@@ -2637,14 +2611,15 @@ async def success_pin_change(curpin: str | None, newpin: str | None) -> None:
async def confirm_firmware_update(description: str, fingerprint: str) -> None:
+ from trezor.ui.layouts.menu import confirm_with_menu
+
+ menu = _menu_with_cancel(
+ [create_info_menu_leaf(TR.firmware_update__title_fingerprint, fingerprint)]
+ )
with trezorui_api.confirm_firmware_update(
description=description, fingerprint=fingerprint
) as layout:
- return await raise_if_not_confirmed(
- layout,
- "firmware_update",
- BR_CODE_OTHER,
- )
+ await confirm_with_menu(layout, menu, "firmware_update", BR_CODE_OTHER)
def create_info_menu_leaf(
@@ -2655,3 +2630,47 @@ def create_info_menu_leaf(
return leaf_from_layout(
name, lambda: trezorui_api.show_properties(title=name, value=value)
)
+
+
+def _menu_with_cancel(items: Iterable[MenuLeaf[R]]) -> Menu[R]:
+ """Context menu with the given items, and the last one cancelling the flow."""
+ from trezor.ui.layouts.menu import Menu, cancel_leaf
+
+ items = list(items)
+ items.append(cancel_leaf(TR.buttons__cancel))
+ return Menu(items)
+
+
+async def _confirm_summary(
+ br_name: str,
+ *,
+ fee: str,
+ fee_label: str,
+ amount: str | None = None,
+ amount_label: str | None = None,
+ title: str | None = None,
+ info: Iterable[tuple[str, Sequence[StrPropertyType] | str | None]] = (),
+ br_code: ButtonRequestType = ButtonRequestType.SignTx,
+) -> None:
+ """Summary confirmed by holding the right button. Each non-empty `info`
+ (title and properties) is an item of the context menu."""
+ from trezor.ui.layouts.menu import confirm_with_menu
+
+ menu_items = [create_info_menu_leaf(name, value) for name, value in info if value]
+ with trezorui_api.confirm_summary(
+ amount=amount,
+ amount_label=amount_label,
+ fee=fee,
+ fee_label=fee_label,
+ title=title,
+ external_menu=bool(menu_items),
+ ) as layout:
+ if menu_items:
+ await confirm_with_menu(
+ layout,
+ _menu_with_cancel(menu_items, TR.buttons__cancel_sign),
+ br_name,
+ br_code,
+ )
+ else:
+ await raise_if_not_confirmed(layout, br_name, br_code)
### core/src/trezor/ui/layouts/menu.py
@@ -222,7 +222,7 @@ async def interact_with_menu(
menu: "Menu[None]",
br_name: str | None,
br_code: ButtonRequestType = ButtonRequestType.Other,
- raise_on_cancel: ExceptionType = ActionCancelled,
+ raise_on_cancel: ExceptionType | None = ActionCancelled,
*,
layout_type: type[Layout] = Layout,
) -> T:
@@ -234,7 +234,7 @@ async def interact_with_menu(
menu: "Menu[R]",
br_name: str | None,
br_code: ButtonRequestType = ButtonRequestType.Other,
- raise_on_cancel: ExceptionType = ActionCancelled,
+ raise_on_cancel: ExceptionType | None = ActionCancelled,
*,
layout_type: type[Layout] = Layout,
) -> T | MenuResult[R]:
@@ -246,7 +246,7 @@ async def interact_with_menu(
menu: Menu[R],
br_name: str | None,
br_code: ButtonRequestType = ButtonRequestType.Other,
- raise_on_cancel: ExceptionType = ActionCancelled,
+ raise_on_cancel: ExceptionType | None = ActionCancelled,
*,
layout_type: type[Layout] = Layout,
) -> T | MenuResult[R]:
### python/src/trezorlib/debuglink.py
@@ -488,10 +488,6 @@ def action_bar(self) -> str:
def has_menu(self) -> bool:
return bool(self.find_unique_value_by_key("has_menu", False, bool))
- def has_left_menu(self) -> bool:
- """Whether the menu is opened by the left button (Caesar)."""
- return bool(self.find_unique_value_by_key("left_menu", False, bool))
-
def danger_menu_items(self) -> list[bool]:
"""Which menu items are dangerous, e.g. cancelling the flow (Caesar)."""
return self.find_unique_value_by_key("danger_items", [], list)
@@ -1168,10 +1164,7 @@ def visit_menu_items(
if layout.has_menu():
is_menu = True
if self.debuglink.layout_type is LayoutType.Caesar:
- if layout.has_left_menu():
- self.debuglink.press_left()
- else:
- self.debuglink.press_right()
+ self.debuglink.press_left()
else:
self.debuglink.click(self.debuglink.screen_buttons.menu())
@@ -2326,8 +2319,32 @@ def _letter_coords_and_amount(self, letter: str) -> tuple[Coords, int]:
click_amount = BUTTON_LETTERS_BIP39[idx].index(letter) + 1
return self.debuglink.screen_buttons.mnemonic_from_index(idx), click_amount
+ def _navigate_to_caesar_menu_item(self, idx: int) -> str:
+ """Move to the nth item of the menu carousel and select it."""
+ layout = self.debuglink.synchronize_at("SimpleChoice")
+ current = layout.active_page()
+ for _ in range(idx - current):
+ self.debuglink.press_right()
+ for _ in range(current - idx):
+ self.debuglink.press_left()
+ layout = self.debuglink.read_layout()
+ assert layout.active_page() == idx
+ current_choice = layout.find_unique_value_by_key("current_choice", {}, dict)
+ self.debuglink.press_middle()
+ return current_choice.get("content", "")
+
+ def close_menu(self) -> None:
+ """Close the menu carousel (Caesar) by moving to its first item and
+ pressing the cross."""
+ assert self.debuglink.layout_type is LayoutType.Caesar
+ layout = self.debuglink.synchronize_at("SimpleChoice")
+ for _ in range(layout.active_page() + 1):
+ self.debuglink.press_left()
+
def navigate_to_menu_item(self, idx: int) -> str:
"""Navigate to the nth item in the vertical menu. Starts from 0. Returns the selected item text."""
+ if self.debuglink.layout_type is LayoutType.Caesar:
+ return self._navigate_to_caesar_menu_item(idx)
item_buttons = self.debuglink.screen_buttons.vertical_menu_items()
layout = self.debuglink.read_layout()
if self.debuglink.layout_type is LayoutType.Delizia:
### tests/click_tests/test_autolock.py
@@ -216,7 +216,8 @@ def sleepy_filter(msg: MessageType) -> MessageType:
if debug.layout_type in (LayoutType.Bolt, LayoutType.Eckhart):
debug.click(debug.screen_buttons.ok(), wait=False)
elif debug.layout_type is LayoutType.Caesar:
- debug.press_middle(wait=False)
+ # confirm immediately (holding the button would postpone the autolock)
+ debug.press_yes(wait=False)
elif debug.layout_type is LayoutType.Delizia:
debug.click(debug.screen_buttons.tap_to_confirm(), wait=False)
else:
### tests/device_tests/cardano/test_sign_tx.py
@@ -42,8 +42,9 @@ def show_details_input_flow(client: Client):
SHOW_ALL_BUTTON_POSITION = (143, 167)
client.debug.click(SHOW_ALL_BUTTON_POSITION)
elif client.layout_type is LayoutType.Caesar:
- # Caesar - right button for "Show all"
- client.debug.press_yes()
+ # Caesar - "Show all" from context menu
+ client.debug.press_left()
+ client.debug.button_actions.navigate_to_menu_item(0)
elif client.layout_type in (LayoutType.Delizia, LayoutType.Eckhart):
# Delizia - "Show all" button from context menu
client.debug.click(client.debug.screen_buttons.menu())
### tests/input_flows.py
@@ -63,6 +63,7 @@
PinFlow,
RecoveryFlow,
n1w1_handle_write,
+ read_caesar_menu_item,
)
B = messages.ButtonRequestType
@@ -404,7 +405,9 @@ def input_flow_caesar(self) -> BRGeneratorType:
self.debug.press_yes()
br = yield
- self.debug.press_info()
+ # "Show all" from the menu
+ self.debug.press_left()
+ self.debug.button_actions.navigate_to_menu_item(0)
# paginate through the whole message
br = yield
@@ -1050,19 +1053,29 @@ def input_flow_caesar(self) -> BRGeneratorType:
self.debug.press_yes()
br = yield
- # Go into details
- self.debug.press_right()
- # Go through details and back
- self.debug.press_right()
- self.debug.press_right()
- self.debug.press_right()
+ # qr code
self.debug.press_left()
+ self.debug.button_actions.navigate_to_menu_item(0)
+ self.debug.synchronize_at("Qr")
self.debug.press_left()
- assert br.pages is not None
- for _ in range(br.pages - 1):
+ # account info
+ self.debug.button_actions.navigate_to_menu_item(1)
+ self.debug.synchronize_at("Paragraphs")
+ self.debug.press_left()
+ self.debug.button_actions.close_menu()
+
+ # scroll down through the xpub, back up with "Shift" and down again
+ layout = self.debug.synchronize_at("ButtonPage")
+ pages = layout.page_count()
+ for _ in range(pages - 1):
self.debug.press_right()
+ if pages > 1:
+ self.debug.press_right_with_shift(pages - 1)
+ assert self.debug.read_layout().active_page() == 0
+ for _ in range(pages - 1):
+ self.debug.press_right()
# Confirm
- self.debug.press_middle()
+ self.debug.press_right()
def input_flow_delizia(self) -> BRGeneratorType:
if self.passphrase_request_expected:
@@ -1346,16 +1359,9 @@ def sign_tx_go_to_info_caesar(
client.debug.press_middle()
yield
- client.debug.press_right()
- layout = client.debug.read_layout()
- screen_texts.append(layout.visible_screen())
-
- client.debug.press_right()
- layout = client.debug.read_layout()
- screen_texts.append(layout.visible_screen())
-
- client.debug.press_left()
- client.debug.press_left()
+ # fee info and account info in the menu
+ for item in range(2):
+ screen_texts.append(read_caesar_menu_item(client.debug, item))
return "\n".join(screen_texts)
@@ -1522,7 +1528,9 @@ def input_flow_bolt(self) -> BRGeneratorType:
def input_flow_caesar(self) -> BRGeneratorType:
yield from sign_tx_go_to_info_caesar(self.client)
+ # cancel from the menu
self.debug.press_left()
+ self.debug.button_actions.navigate_to_menu_item(2)
def input_flow_delizia(self) -> BRGeneratorType:
yield from sign_tx_go_to_info_delizia(self.client)
@@ -1758,7 +1766,8 @@ def _confirm_show_more(self) -> None:
if self.layout_type is LayoutType.Bolt:
self.debug.click(self.SHOW_MORE)
elif self.layout_type is LayoutType.Caesar:
- self.debug.press_right()
+ self.debug.press_left()
+ self.debug.button_actions.navigate_to_menu_item(0)
elif self.layout_type in (LayoutType.Delizia, LayoutType.Eckhart):
self.debug.click(self.debug.screen_buttons.menu())
self.debug.button_actions.navigate_to_menu_item(0)
@@ -1895,7 +1904,9 @@ def input_flow_common(self) -> BRGeneratorType:
confirm_tx.send(br)
def _go_to_next_page(self, is_intro: bool):
- if self.client.layout_type in (LayoutType.Bolt, LayoutType.Caesar) or is_intro:
+ if self.client.layout_type is LayoutType.Caesar:
+ self.debug.press_yes() # pagination is the right button
+ elif self.client.layout_type is LayoutType.Bolt or is_intro:
self.debug.press_info() # pagination is a special button
elif self.client.layout_type in (LayoutType.Delizia, LayoutType.Eckhart):
self.debug.press_yes() # pagination is a regular button
@@ -1906,7 +1917,15 @@ def _cancel_flow(self):
self.debug.press_no()
def _confirm_all(self, is_intro: bool):
- if self.client.layout_type in (LayoutType.Bolt, LayoutType.Caesar) or is_intro:
+ if self.client.layout_type is LayoutType.Caesar:
+ layout = self.debug.read_layout()
+ if TR.buttons__confirm_all.lower() in layout.json_str.lower():
+ self.debug.press_yes() # confirmation is the right button
+ else:
+ # the right button scrolls, confirmation is in the menu
+ self.debug.press_left()
+ self.debug.button_actions.navigate_to_menu_item(0)
+ elif self.client.layout_type is LayoutType.Bolt or is_intro:
self.debug.press_yes() # confirmation is a regular button
elif self.client.layout_type in (LayoutType.Delizia, LayoutType.Eckhart):
self.debug.press_info() # confirmation is available via menu
### tests/input_flows_helpers.py
@@ -25,6 +25,21 @@
B = messages.ButtonRequestType
+def read_caesar_menu_item(debug: DebugLink, idx: int) -> str:
+ """Open the context menu (Caesar), read all pages of its `idx`-th item,
+ close the item and the menu."""
+ debug.press_left()
+ debug.button_actions.navigate_to_menu_item(idx)
+ layout = debug.synchronize_at(["Paragraphs", "Qr"])
+ contents = [layout.text_content()]
+ for _ in range(layout.page_count() - 1):
+ debug.press_right()
+ contents.append(debug.read_layout().text_content())
+ debug.press_left()
+ debug.button_actions.close_menu()
+ return " ".join(contents)
+
+
class PinFlow:
def __init__(self, client: Client):
self.client = client
@@ -498,18 +513,17 @@ def _confirm_tx_caesar(
assert (yield).name == "confirm_ethereum_tx"
assert TR.send__maximum_fee in self.debug.read_layout().text_content()
if go_back_from_summary:
- self.debug.press_left()
+ # "Shift" + right goes back from the first page
+ self.debug.press_right_with_shift()
assert (yield).name == "confirm_ethereum_tx"
self.debug.press_right()
assert (yield).name == "confirm_ethereum_tx"
if info:
- self.debug.press_right()
- assert TR.ethereum__gas_limit in self.debug.read_layout().text_content()
- self.debug.press_right()
- assert TR.ethereum__gas_price in self.debug.read_layout().text_content()
- self.debug.press_left()
- self.debug.press_left()
- self.debug.press_middle()
+ text = read_caesar_menu_item(self.debug, 0)
+ assert TR.ethereum__gas_limit in text
+ assert TR.ethereum__gas_price in text
+ # hold to confirm
+ self.debug.press_yes()
assert (yield).name == "confirm_ethereum_tx"
def _confirm_tx_delizia(
@@ -666,26 +680,23 @@ def confirm_tx_staking(
elif self.client.layout_type is LayoutType.Caesar:
# confirm intro
if info:
- self.debug.press_right() # enter menu
- self.debug.press_middle() # choose item
- assert self.debug.read_layout().title() in (
+ self.debug.press_left() # enter menu
+ self.debug.button_actions.navigate_to_menu_item(0)
+ assert self.debug.synchronize_at("Paragraphs").title() in (
TR.ethereum__staking_stake_address,
TR.ethereum__staking_claim_address,
)
self.debug.press_left() # back to menu
- self.debug.press_left() # close menu
- self.debug.press_middle()
+ self.debug.button_actions.close_menu()
+ self.debug.press_right()
yield
# confirm summary
if info:
- self.debug.press_right()
- assert TR.ethereum__gas_limit in self.debug.read_layout().text_content()
- self.debug.press_right()
- assert TR.ethereum__gas_price in self.debug.read_layout().text_content()
- self.debug.press_left()
- self.debug.press_left()
- self.debug.press_middle()
+ text = read_caesar_menu_item(self.debug, 0)
+ assert TR.ethereum__gas_limit in text
+ assert TR.ethereum__gas_price in text
+ self.debug.press_yes() # hold to confirm
yield
self.debug.press_yes()Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.