refactor: extract `ConfirmActionOptions`
What changed, and why it matters
This commit is a straightforward code cleanup: it bundles several settings for confirmation screens into a single ConfirmActionOptions struct instead of passing them as separate function arguments. There is no change to user-facing behavior, no bug fix, and no security-related change.
No security action needed; this is a non-functional refactor. Reviewers may verify that all call-site argument mappings are equivalent to the previous positional parameters.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors the confirm-action UI flow in the Trezor firmware’s Delizia layout. It introduces a ConfirmActionOptions builder-style struct with fields hold, swipe_down, page_limit, page_counter, and frame_margin, and replaces multiple positional parameters in new_confirm_action_simple, new_confirm_action_uni, and call sites with a single options argument. The default values and all call-site behavior are preserved exactly.
Changed components
core/embed/rust/src/ui/layout_delizia/flow/confirm_action.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 +71 / −68
diff --git a/core/embed/rust/src/ui/layout_delizia/flow/confirm_action.rs b/core/embed/rust/src/ui/layout_delizia/flow/confirm_action.rs
index 7f32b1bf..ede9d9c2 100644
--- a/core/embed/rust/src/ui/layout_delizia/flow/confirm_action.rs
+++ b/core/embed/rust/src/ui/layout_delizia/flow/confirm_action.rs
@@ -68,6 +68,51 @@ impl ConfirmActionStrings {
}
}
+pub struct ConfirmActionOptions {
+ hold: bool,
+ swipe_down: bool,
+ page_limit: Option<u16>,
+ page_counter: bool,
+ frame_margin: usize,
+}
+
+impl ConfirmActionOptions {
+ pub fn new() -> Self {
+ Self {
+ hold: false,
+ swipe_down: false,
+ page_limit: None,
+ page_counter: false,
+ frame_margin: 0,
+ }
+ }
+
+ pub fn with_hold(mut self, hold: bool) -> Self {
+ self.hold = hold;
+ self
+ }
+
+ pub fn with_swipe_down(mut self, swipe_down: bool) -> Self {
+ self.swipe_down = swipe_down;
+ self
+ }
+
+ pub fn with_page_limit(mut self, page_limit: Option<u16>) -> Self {
+ self.page_limit = page_limit;
+ self
+ }
+
+ pub fn with_page_counter(mut self, page_counter: bool) -> Self {
+ self.page_counter = page_counter;
+ self
+ }
+
+ pub fn with_frame_margin(mut self, frame_margin: usize) -> Self {
+ self.frame_margin = frame_margin;
+ self
+ }
+}
+
#[derive(PartialEq)]
pub struct ConfirmActionMenuStrings {
verb_cancel: TString<'static>,
@@ -267,11 +312,7 @@ pub fn new_confirm_action(
ConfirmActionExtra::Menu(ConfirmActionMenuStrings::new().with_verb_cancel(verb_cancel))
},
ConfirmActionStrings::new(title, subtitle, None, prompt_screen.then_some(prompt_title)),
- hold,
- false,
- None,
- 0,
- false,
+ ConfirmActionOptions::new().with_hold(hold),
)
}
@@ -280,19 +321,16 @@ fn new_confirm_action_uni<T: Component + Paginate + MaybeTrace + 'static>(
content: SwipeContent<SwipePage<T>>,
extra: ConfirmActionExtra,
strings: ConfirmActionStrings,
- hold: bool,
- swipe_down: bool,
- frame_margin: usize,
- page_counter: bool,
+ options: ConfirmActionOptions,
) -> Result<SwipeFlow, error::Error> {
let (prompt_screen, prompt_pages, flow, page) =
- create_flow(strings.title, strings.prompt_screen, hold, &extra);
+ create_flow(strings.title, strings.prompt_screen, options.hold, &extra);
let mut content = Frame::left_aligned(strings.title, content)
- .with_margin(frame_margin)
+ .with_margin(options.frame_margin)
.with_swipeup_footer(strings.footer_description)
.with_vertical_pages();
- if swipe_down {
+ if options.swipe_down {
content = content.with_swipe(Direction::Down, SwipeSettings::Default);
}
@@ -302,7 +340,7 @@ fn new_confirm_action_uni<T: Component + Paginate + MaybeTrace + 'static>(
ConfirmActionExtra::Cancel => content.with_cancel_button(),
};
- if page_counter {
+ if options.page_counter {
fn footer_update_fn<T: Component + Paginate>(
content: &SwipeContent<SwipePage<T>>,
ctx: &mut EventCtx,
@@ -348,7 +386,7 @@ fn new_confirm_action_uni<T: Component + Paginate + MaybeTrace + 'static>(
&mut flow,
&extra,
strings.subtitle,
- hold,
+ options.hold,
prompt_title,
prompt_state,
)?;
@@ -458,24 +496,16 @@ fn create_confirm(
}
#[inline(never)]
-#[allow(clippy::too_many_arguments)]
pub fn new_confirm_action_simple<T: Component + Paginate + MaybeTrace + 'static>(
content: T,
extra: ConfirmActionExtra,
strings: ConfirmActionStrings,
- hold: bool,
- swipe_down: bool,
- page_limit: Option<u16>,
- frame_margin: usize,
- page_counter: bool,
+ options: ConfirmActionOptions,
) -> Result<SwipeFlow, error::Error> {
new_confirm_action_uni(
- SwipeContent::new(SwipePage::vertical(content).with_limit(page_limit)),
+ SwipeContent::new(SwipePage::vertical(content).with_limit(options.page_limit)),
extra,
strings,
- hold,
- swipe_down,
- frame_margin,
- page_counter,
+ options,
)
}
diff --git a/core/embed/rust/src/ui/layout_delizia/flow/mod.rs b/core/embed/rust/src/ui/layout_delizia/flow/mod.rs
index 32e66e4f..89d563fb 100644
--- a/core/embed/rust/src/ui/layout_delizia/flow/mod.rs
+++ b/core/embed/rust/src/ui/layout_delizia/flow/mod.rs
@@ -20,7 +20,7 @@ pub mod util;
pub use confirm_action::{
new_confirm_action, new_confirm_action_simple, ConfirmActionExtra, ConfirmActionMenuStrings,
- ConfirmActionStrings,
+ ConfirmActionOptions, ConfirmActionStrings,
};
#[cfg(feature = "universal_fw")]
pub use confirm_fido::new_confirm_fido;
diff --git a/core/embed/rust/src/ui/layout_delizia/flow/util.rs b/core/embed/rust/src/ui/layout_delizia/flow/util.rs
index 053cde96..6f363db5 100644
--- a/core/embed/rust/src/ui/layout_delizia/flow/util.rs
+++ b/core/embed/rust/src/ui/layout_delizia/flow/util.rs
@@ -27,7 +27,7 @@ use super::{
component::{Frame, PromptMsg, SwipeContent, VerticalMenu, VerticalMenuChoiceMsg},
flow, theme,
},
- ConfirmActionExtra, ConfirmActionMenuStrings, ConfirmActionStrings,
+ ConfirmActionExtra, ConfirmActionMenuStrings, ConfirmActionOptions, ConfirmActionStrings,
};
pub struct ConfirmValue {
@@ -336,11 +336,12 @@ impl ConfirmValue {
self.prompt.then_some(self.title),
)
.with_footer_description(self.footer_description),
- self.hold,
- self.swipe_down,
- self.page_limit,
- self.frame_margin,
- self.page_counter,
+ ConfirmActionOptions::new()
+ .with_hold(self.hold)
+ .with_swipe_down(self.swipe_down)
+ .with_page_limit(self.page_limit)
+ .with_frame_margin(self.frame_margin)
+ .with_page_counter(self.page_counter),
)
}
diff --git a/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs b/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs
index 1da86a3e..08a7cbb5 100644
--- a/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs
+++ b/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs
@@ -43,7 +43,7 @@ use super::{
},
flow::{
self, new_confirm_action_simple, ConfirmActionExtra, ConfirmActionMenuStrings,
- ConfirmActionStrings, ConfirmValue, ShowInfoParams,
+ ConfirmActionOptions, ConfirmActionStrings, ConfirmValue, ShowInfoParams,
},
fonts, theme, UIDelizia,
};
@@ -101,11 +101,7 @@ impl FirmwareUI for UIDelizia {
TradeScreen::new(sell_amount, buy_amount),
ConfirmActionExtra::ExternalMenu,
ConfirmActionStrings::new(title, Some(subtitle), None, None),
- false,
- false,
- None,
- 0,
- false,
+ ConfirmActionOptions::new(),
)
}
@@ -206,11 +202,7 @@ impl FirmwareUI for UIDelizia {
None,
Some(TR::homescreen__settings_title.into()),
),
- false,
- false,
- None,
- 0,
- false,
+ ConfirmActionOptions::new(),
)?
} else {
if !check_homescreen_format(image) {
@@ -243,11 +235,7 @@ impl FirmwareUI for UIDelizia {
None,
Some(TR::coinjoin__title.into()),
),
- true,
- false,
- None,
- 0,
- false,
+ ConfirmActionOptions::new().with_hold(true),
)?;
Ok(flow)
}
@@ -273,11 +261,7 @@ impl FirmwareUI for UIDelizia {
FormattedText::new(ops).vertically_centered(),
ConfirmActionExtra::Menu(ConfirmActionMenuStrings::new()),
ConfirmActionStrings::new(title, None, None, Some(title)),
- false,
- false,
- None,
- 0,
- false,
+ ConfirmActionOptions::new(),
)?;
Ok(flow)
}
@@ -342,11 +326,7 @@ impl FirmwareUI for UIDelizia {
.with_verb_info(Some(TR::words__title_information.into())),
),
ConfirmActionStrings::new(title, None, None, Some(title)),
- true,
- false,
- None,
- 0,
- false,
+ ConfirmActionOptions::new().with_hold(true),
)?;
Ok(flow)
}
@@ -465,11 +445,7 @@ impl FirmwareUI for UIDelizia {
paragraphs.into_paragraphs(),
ConfirmActionExtra::Menu(ConfirmActionMenuStrings::new()),
ConfirmActionStrings::new(title, subtitle, None, hold.then_some(title)),
- hold,
- false,
- None,
- 0,
- false,
+ ConfirmActionOptions::new().with_hold(hold),
)?;
Ok(flow)
}
@@ -506,11 +482,7 @@ impl FirmwareUI for UIDelizia {
ConfirmActionMenuStrings::new().with_verb_info(Some(verb_info)),
),
ConfirmActionStrings::new(title, None, None, None).with_footer_description(Some(verb)),
- false,
- false,
- None,
- 0,
- false,
+ ConfirmActionOptions::new(),
)?;
Ok(flow)
}
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.