refactor(core/delizia): remove ShowInfoParams
What changed, and why it matters
This commit is a straightforward internal code cleanup in the Trezor firmware's user-interface layer. It replaces a small helper struct called ShowInfoParams with a direct function call (show_info_screen) that builds the same on-screen information pages. There is no change to security behavior, no bug fix, and no externally visible feature change.
No security action required. Treat as a normal code-quality refactor during review.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors the Delizia UI layout code in core/embed/rust/src/ui/layout_delizia. ShowInfoParams, which previously held a title and a heapless Vec of up to four key/value pairs and provided an into_layout() method, is removed. A new public type alias ShowInfoScreen = MoreInfoScreen<ParagraphVecLong<’static>> and a free function show_info_screen() are introduced to construct the same MoreInfoScreen directly. Call sites in confirm_summary.rs and ui_firmware.rs are updated to build the key/value vector locally and pass it to show_info_screen(). The resulting UI component and its behavior are unchanged.
Changed components
core/embed/rust/src/ui/layout_delizia/flow/confirm_summary.rscore/embed/rust/src/ui/layout_delizia/flow/mod.rscore/embed/rust/src/ui/layout_delizia/flow/util.rscore/embed/rust/src/ui/layout_delizia/ui_firmware.rsInspect captured patch +49 / −79
### core/embed/rust/src/ui/layout_delizia/flow/confirm_summary.rs
@@ -4,7 +4,7 @@ use super::super::component::{
Frame, Header, PromptScreen, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg,
};
use super::super::theme;
-use super::util::{dummy_page, ShowInfoParams};
+use super::util::{dummy_page, ShowInfoScreen};
use crate::micropython::Error;
use crate::strutil::TString;
use crate::translations::TR;
@@ -68,9 +68,9 @@ pub fn new_confirm_summary(
amount_label: Option<TString<'static>>,
fee: TString<'static>,
fee_label: TString<'static>,
- account_params: Option<ShowInfoParams>,
+ account_info: Option<ShowInfoScreen>,
account_title: Option<TString<'static>>,
- extra_params: Option<ShowInfoParams>,
+ extra_info: Option<ShowInfoScreen>,
extra_title: Option<TString<'static>>,
verb_cancel: Option<TString<'static>>,
can_go_back: bool,
@@ -114,26 +114,17 @@ pub fn new_confirm_summary(
.with_swipe(Direction::Down, SwipeSettings::Default)
.map(super::util::map_to_confirm);
- // ExtraInfo
- let content_extra = extra_params
- .map(|params| params.into_layout())
- .transpose()?;
- // AccountInfo
- let content_account = account_params
- .map(|params| params.into_layout())
- .transpose()?;
-
// Menu with provided info and cancel
let mut menu = VerticalMenu::empty();
let mut menu_items = Vec::<usize, 3>::new();
- if content_extra.is_some() {
+ if extra_info.is_some() {
menu = menu.item(
theme::ICON_CHEVRON_RIGHT,
extra_title.unwrap_or(TR::buttons__more_info.into()),
);
unwrap!(menu_items.push(MENU_ITEM_EXTRA_INFO));
}
- if content_account.is_some() {
+ if account_info.is_some() {
menu = menu.item(
theme::ICON_CHEVRON_RIGHT,
account_title.unwrap_or(TR::address_details__account_info.into()),
@@ -165,12 +156,12 @@ pub fn new_confirm_summary(
res.add_page(&ConfirmSummary::Summary, content_summary)?
.add_page(&ConfirmSummary::Hold, content_hold)?
.add_page(&ConfirmSummary::Menu, content_menu)?;
- if let Some(content_extra) = content_extra {
+ if let Some(content_extra) = extra_info {
res.add_page(&ConfirmSummary::ExtraInfo, content_extra)?;
} else {
res.add_page(&ConfirmSummary::ExtraInfo, dummy_page())?;
};
- if let Some(content_account) = content_account {
+ if let Some(content_account) = account_info {
res.add_page(&ConfirmSummary::AccountInfo, content_account)?;
} else {
res.add_page(&ConfirmSummary::AccountInfo, dummy_page())?;
### core/embed/rust/src/ui/layout_delizia/flow/mod.rs
@@ -33,4 +33,4 @@ pub use set_brightness::SetBrightness;
pub use show_danger::ShowDanger;
pub use show_share_words::ShowShareWords;
pub use show_tutorial::ShowTutorial;
-pub use util::{ConfirmValue, ShowInfoParams};
+pub use util::{show_info_screen, ConfirmValue, ShowInfoScreen};
### core/embed/rust/src/ui/layout_delizia/flow/util.rs
@@ -1,5 +1,3 @@
-use heapless::Vec;
-
use super::super::component::{
Frame, Header, MoreInfoScreen, PromptMsg, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg,
};
@@ -287,51 +285,32 @@ impl ConfirmValue {
}
}
-pub struct ShowInfoParams {
- title: TString<'static>,
- items: Vec<(TString<'static>, TString<'static>), 4>,
-}
-
-impl ShowInfoParams {
- pub const fn new(title: TString<'static>) -> Self {
- Self {
- title,
- items: Vec::new(),
- }
- }
+pub type ShowInfoScreen = MoreInfoScreen<ParagraphVecLong<'static>>;
- pub fn add(mut self, key: TString<'static>, value: TString<'static>) -> Option<Self> {
- if self.items.push((key, value)).is_ok() {
- Some(self)
- } else {
- None
+/// Simple read-only screen showing a list of key-value pairs with a close
+/// button. Paginates automatically via action bar buttons when the content
+/// does not fit on a single page.
+#[inline(never)]
+pub fn show_info_screen(
+ title: TString<'static>,
+ items: impl IntoIterator<Item = (TString<'static>, TString<'static>)>,
+) -> ShowInfoScreen {
+ let mut paragraphs = ParagraphVecLong::new();
+ let mut first: bool = true;
+ for (key, value) in items {
+ // FIXME: padding:
+ if !first {
+ paragraphs.add(Paragraph::new::<TString<'static>>(
+ &theme::TEXT_SUB_GREY,
+ " ".into(),
+ ));
}
+ first = false;
+ paragraphs.add(Paragraph::new(&theme::TEXT_SUB_GREY, key).no_break());
+ paragraphs.add(Paragraph::new(&theme::TEXT_MONO_GREY_LIGHT, value));
}
- #[inline(never)]
- pub fn into_layout(
- self,
- ) -> Result<impl Component<Msg = FlowMsg> + Swipable + MaybeTrace, Error> {
- let mut paragraphs = ParagraphVecLong::new();
- let mut first: bool = true;
- for item in self.items {
- // FIXME: padding:
- if !first {
- paragraphs.add(Paragraph::new::<TString<'static>>(
- &theme::TEXT_SUB_GREY,
- " ".into(),
- ));
- }
- first = false;
- paragraphs.add(Paragraph::new(&theme::TEXT_SUB_GREY, item.0).no_break());
- paragraphs.add(Paragraph::new(&theme::TEXT_MONO_GREY_LIGHT, item.1));
- }
-
- Ok(MoreInfoScreen::new(
- self.title,
- paragraphs.into_paragraphs(),
- ))
- }
+ MoreInfoScreen::new(title, paragraphs.into_paragraphs())
}
pub fn map_to_confirm(msg: PromptMsg) -> Option<FlowMsg> {
### core/embed/rust/src/ui/layout_delizia/ui_firmware.rs
@@ -10,8 +10,8 @@ use super::component::{
VerticalMenuItem, VerticalMenuItems,
};
use super::flow::{
- self, new_confirm_action_simple, ConfirmActionExtra, ConfirmActionMenuStrings,
- ConfirmActionOptions, ConfirmActionStrings, ConfirmValue, ShowInfoParams,
+ self, new_confirm_action_simple, show_info_screen, ConfirmActionExtra,
+ ConfirmActionMenuStrings, ConfirmActionOptions, ConfirmActionStrings, ConfirmValue,
};
use super::{fonts, theme, UIDelizia};
use crate::io::BinaryData;
@@ -398,25 +398,29 @@ impl FirmwareUI for UIDelizia {
_external_menu: bool, // TODO: will eventually replace the internal menu
) -> Result<impl LayoutMaybeTrace, Error> {
// collect available info
- let account_params = if let Some(items) = account_items {
- let account_title = account_title.unwrap_or(TR::send__send_from.into());
- let mut account_params = ShowInfoParams::new(account_title);
+ let account_info = if let Some(items) = account_items {
+ let mut pairs = Vec::<(TString<'static>, TString<'static>), 4>::new();
for pair in IterBuf::new().try_iterate(items)? {
let [key, value, _is_data]: [Obj; 3] = util::iter_into_array(pair)?;
- account_params = unwrap!(account_params.add(key.try_into()?, value.try_into()?));
+ unwrap!(pairs.push((key.try_into()?, value.try_into()?)));
}
- Some(account_params)
+ Some(show_info_screen(
+ account_title.unwrap_or(TR::send__send_from.into()),
+ pairs,
+ ))
} else {
None
};
- let extra_params = if let Some(items) = extra_items {
- let extra_title = extra_title.unwrap_or(TR::buttons__more_info.into());
- let mut extra_params = ShowInfoParams::new(extra_title);
+ let extra_info = if let Some(items) = extra_items {
+ let mut pairs = Vec::<(TString<'static>, TString<'static>), 4>::new();
for pair in IterBuf::new().try_iterate(items)? {
let [label, value, _is_data]: [Obj; 3] = util::iter_into_array(pair)?;
- extra_params = unwrap!(extra_params.add(label.try_into()?, value.try_into()?));
+ unwrap!(pairs.push((label.try_into()?, value.try_into()?)));
}
- Some(extra_params)
+ Some(show_info_screen(
+ extra_title.unwrap_or(TR::buttons__more_info.into()),
+ pairs,
+ ))
} else {
None
};
@@ -427,9 +431,9 @@ impl FirmwareUI for UIDelizia {
amount_label,
fee,
fee_label,
- account_params,
+ account_info,
account_title,
- extra_params,
+ extra_info,
extra_title,
verb_cancel,
back_button,
@@ -1109,11 +1113,7 @@ impl FirmwareUI for UIDelizia {
let layout = confirm.into_layout()?;
flow::util::single_page(layout.map(|_| Some(FlowMsg::Confirmed)))
} else {
- let mut params = ShowInfoParams::new(title);
- for (header, text, _is_data) in items {
- params = unwrap!(params.add(header, text));
- }
- let layout = params.into_layout()?;
+ let layout = show_info_screen(title, items.into_iter().map(|(h, t, _is_data)| (h, t)));
flow::util::single_page(layout.map(|_| Some(FlowMsg::Confirmed)))
}
}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.