mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-12 23:52:39 +00:00
refactor(core): use warning_hi_prio in ETH flow
Commit c300576d6c
introduced the
`default_cancel` parameter to `show_warning` and `confirm_blob` rather
using the already existing `flow_warning_hi_prio` which was doing the
same thing. This commit reverts all the nonsense.
[no changelog]
This commit is contained in:
parent
e434aabc77
commit
6d2c1566be
@ -224,7 +224,6 @@ static void _librust_qstrs(void) {
|
|||||||
MP_QSTR_debug__loading_seed;
|
MP_QSTR_debug__loading_seed;
|
||||||
MP_QSTR_debug__loading_seed_not_recommended;
|
MP_QSTR_debug__loading_seed_not_recommended;
|
||||||
MP_QSTR_decode;
|
MP_QSTR_decode;
|
||||||
MP_QSTR_default_cancel;
|
|
||||||
MP_QSTR_deinit;
|
MP_QSTR_deinit;
|
||||||
MP_QSTR_description;
|
MP_QSTR_description;
|
||||||
MP_QSTR_description_font_green;
|
MP_QSTR_description_font_green;
|
||||||
|
@ -96,40 +96,6 @@ impl FlowController for ConfirmActionSimple {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Flow similar to ConfirmActionSimple, but having swipe up cancel the flow
|
|
||||||
/// rather than confirm. To confirm, the user needs to open the menu.
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
|
||||||
pub enum ConfirmActionSimpleDefaultCancel {
|
|
||||||
Intro,
|
|
||||||
Menu,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FlowController for ConfirmActionSimpleDefaultCancel {
|
|
||||||
#[inline]
|
|
||||||
fn index(&'static self) -> usize {
|
|
||||||
*self as usize
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_swipe(&'static self, direction: Direction) -> Decision {
|
|
||||||
match (self, direction) {
|
|
||||||
(Self::Intro, Direction::Left) => Self::Menu.swipe(direction),
|
|
||||||
(Self::Menu, Direction::Right) => Self::Intro.swipe(direction),
|
|
||||||
(Self::Intro, Direction::Up) => self.return_msg(FlowMsg::Cancelled),
|
|
||||||
_ => self.do_nothing(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_event(&'static self, msg: FlowMsg) -> Decision {
|
|
||||||
match (self, msg) {
|
|
||||||
(Self::Intro, FlowMsg::Info) => Self::Menu.goto(),
|
|
||||||
(Self::Menu, FlowMsg::Cancelled) => Self::Intro.swipe_right(),
|
|
||||||
(Self::Menu, FlowMsg::Choice(0)) => self.return_msg(FlowMsg::Cancelled),
|
|
||||||
(Self::Menu, FlowMsg::Choice(1)) => self.return_msg(FlowMsg::Confirmed),
|
|
||||||
_ => self.do_nothing(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct ConfirmActionMenu {
|
pub struct ConfirmActionMenu {
|
||||||
verb_cancel: Option<TString<'static>>,
|
verb_cancel: Option<TString<'static>>,
|
||||||
info: bool,
|
info: bool,
|
||||||
@ -231,28 +197,16 @@ fn new_confirm_action_uni<T: Component + MaybeTrace + 'static>(
|
|||||||
menu: ConfirmActionMenu,
|
menu: ConfirmActionMenu,
|
||||||
strings: ConfirmActionStrings,
|
strings: ConfirmActionStrings,
|
||||||
hold: bool,
|
hold: bool,
|
||||||
default_cancel: bool,
|
|
||||||
) -> Result<Obj, error::Error> {
|
) -> Result<Obj, error::Error> {
|
||||||
let (prompt_screen, prompt_pages, flow, page) =
|
let (prompt_screen, prompt_pages, flow, page) =
|
||||||
create_flow(strings.title, strings.prompt_screen, hold, default_cancel);
|
create_flow(strings.title, strings.prompt_screen, hold);
|
||||||
|
|
||||||
let mut content_intro = Frame::left_aligned(strings.title, content)
|
let mut content_intro = Frame::left_aligned(strings.title, content)
|
||||||
.with_swipe(Direction::Up, SwipeSettings::default())
|
.with_swipe(Direction::Up, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Left, SwipeSettings::default())
|
.with_swipe(Direction::Left, SwipeSettings::default())
|
||||||
.with_vertical_pages();
|
.with_vertical_pages()
|
||||||
|
.with_menu_button()
|
||||||
if default_cancel {
|
.with_footer(TR::instructions__swipe_up.into(), None);
|
||||||
content_intro = content_intro.title_styled(theme::TEXT_WARNING);
|
|
||||||
content_intro = content_intro.with_danger_menu_button();
|
|
||||||
content_intro = content_intro.with_footer(
|
|
||||||
TR::instructions__swipe_up.into(),
|
|
||||||
Some(TR::send__cancel_sign.into()),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
content_intro = content_intro.with_menu_button();
|
|
||||||
// TODO: conditionally add the verb to the footer as well?
|
|
||||||
content_intro = content_intro.with_footer(TR::instructions__swipe_up.into(), None);
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(subtitle) = strings.subtitle {
|
if let Some(subtitle) = strings.subtitle {
|
||||||
content_intro = content_intro.with_subtitle(subtitle);
|
content_intro = content_intro.with_subtitle(subtitle);
|
||||||
@ -267,7 +221,7 @@ fn new_confirm_action_uni<T: Component + MaybeTrace + 'static>(
|
|||||||
|
|
||||||
let flow = flow?.with_page(page, content_intro)?;
|
let flow = flow?.with_page(page, content_intro)?;
|
||||||
|
|
||||||
let flow = create_menu(flow, menu, default_cancel, prompt_screen)?;
|
let flow = create_menu(flow, menu, prompt_screen)?;
|
||||||
|
|
||||||
let flow = create_confirm(flow, strings.subtitle, hold, prompt_screen)?;
|
let flow = create_confirm(flow, strings.subtitle, hold, prompt_screen)?;
|
||||||
|
|
||||||
@ -278,7 +232,6 @@ fn create_flow(
|
|||||||
title: TString<'static>,
|
title: TString<'static>,
|
||||||
prompt_screen: Option<TString<'static>>,
|
prompt_screen: Option<TString<'static>>,
|
||||||
hold: bool,
|
hold: bool,
|
||||||
default_cancel: bool,
|
|
||||||
) -> (
|
) -> (
|
||||||
Option<TString<'static>>,
|
Option<TString<'static>>,
|
||||||
usize,
|
usize,
|
||||||
@ -290,11 +243,6 @@ fn create_flow(
|
|||||||
|
|
||||||
let (flow, page): (Result<SwipeFlow, Error>, &dyn FlowController) = if prompt_screen.is_some() {
|
let (flow, page): (Result<SwipeFlow, Error>, &dyn FlowController) = if prompt_screen.is_some() {
|
||||||
(SwipeFlow::new(&ConfirmAction::Intro), &ConfirmAction::Intro)
|
(SwipeFlow::new(&ConfirmAction::Intro), &ConfirmAction::Intro)
|
||||||
} else if default_cancel {
|
|
||||||
(
|
|
||||||
SwipeFlow::new(&ConfirmActionSimpleDefaultCancel::Intro),
|
|
||||||
&ConfirmActionSimpleDefaultCancel::Intro,
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
(
|
(
|
||||||
SwipeFlow::new(&ConfirmActionSimple::Intro),
|
SwipeFlow::new(&ConfirmActionSimple::Intro),
|
||||||
@ -308,29 +256,19 @@ fn create_flow(
|
|||||||
fn create_menu(
|
fn create_menu(
|
||||||
flow: SwipeFlow,
|
flow: SwipeFlow,
|
||||||
menu: ConfirmActionMenu,
|
menu: ConfirmActionMenu,
|
||||||
default_cancel: bool,
|
|
||||||
prompt_screen: Option<TString<'static>>,
|
prompt_screen: Option<TString<'static>>,
|
||||||
) -> Result<SwipeFlow, Error> {
|
) -> Result<SwipeFlow, Error> {
|
||||||
let mut menu_choices = VerticalMenu::empty();
|
let mut menu_choices = VerticalMenu::empty().danger(
|
||||||
if default_cancel {
|
theme::ICON_CANCEL,
|
||||||
|
menu.verb_cancel.unwrap_or(TR::buttons__cancel.into()),
|
||||||
|
);
|
||||||
|
|
||||||
|
if menu.info {
|
||||||
menu_choices = menu_choices.item(
|
menu_choices = menu_choices.item(
|
||||||
theme::ICON_CANCEL,
|
theme::ICON_CHEVRON_RIGHT,
|
||||||
menu.verb_cancel.unwrap_or(TR::buttons__cancel.into()),
|
menu.verb_info
|
||||||
|
.unwrap_or(TR::words__title_information.into()),
|
||||||
);
|
);
|
||||||
menu_choices =
|
|
||||||
menu_choices.danger(theme::ICON_CHEVRON_RIGHT, TR::words__continue_anyway.into());
|
|
||||||
} else {
|
|
||||||
menu_choices = menu_choices.danger(
|
|
||||||
theme::ICON_CANCEL,
|
|
||||||
menu.verb_cancel.unwrap_or(TR::buttons__cancel.into()),
|
|
||||||
);
|
|
||||||
if menu.info {
|
|
||||||
menu_choices = menu_choices.item(
|
|
||||||
theme::ICON_CHEVRON_RIGHT,
|
|
||||||
menu.verb_info
|
|
||||||
.unwrap_or(TR::words__title_information.into()),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let content_menu = Frame::left_aligned("".into(), menu_choices)
|
let content_menu = Frame::left_aligned("".into(), menu_choices)
|
||||||
@ -403,23 +341,5 @@ pub fn new_confirm_action_simple<T: Component + Paginate + MaybeTrace + 'static>
|
|||||||
menu,
|
menu,
|
||||||
strings,
|
strings,
|
||||||
hold,
|
hold,
|
||||||
false,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline(never)]
|
|
||||||
pub fn new_confirm_action_simple_default_cancel<T: Component + Paginate + MaybeTrace + 'static>(
|
|
||||||
content: T,
|
|
||||||
menu: ConfirmActionMenu,
|
|
||||||
strings: ConfirmActionStrings,
|
|
||||||
hold: bool,
|
|
||||||
page_limit: Option<usize>,
|
|
||||||
) -> Result<Obj, error::Error> {
|
|
||||||
new_confirm_action_uni(
|
|
||||||
SwipeContent::new(SwipePage::vertical(content).with_limit(page_limit)),
|
|
||||||
menu,
|
|
||||||
strings,
|
|
||||||
hold,
|
|
||||||
true,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,7 @@ pub mod warning_hi_prio;
|
|||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
pub use confirm_action::{
|
pub use confirm_action::{
|
||||||
new_confirm_action, new_confirm_action_simple, new_confirm_action_simple_default_cancel,
|
new_confirm_action, new_confirm_action_simple, ConfirmActionMenu, ConfirmActionStrings,
|
||||||
ConfirmActionMenu, ConfirmActionStrings,
|
|
||||||
};
|
};
|
||||||
#[cfg(feature = "universal_fw")]
|
#[cfg(feature = "universal_fw")]
|
||||||
pub use confirm_fido::new_confirm_fido;
|
pub use confirm_fido::new_confirm_fido;
|
||||||
|
@ -70,10 +70,15 @@ impl WarningHiPrio {
|
|||||||
let title: TString = kwargs.get_or(Qstr::MP_QSTR_title, TR::words__warning.into())?;
|
let title: TString = kwargs.get_or(Qstr::MP_QSTR_title, TR::words__warning.into())?;
|
||||||
let description: TString = kwargs.get(Qstr::MP_QSTR_description)?.try_into()?;
|
let description: TString = kwargs.get(Qstr::MP_QSTR_description)?.try_into()?;
|
||||||
let value: TString = kwargs.get_or(Qstr::MP_QSTR_value, "".into())?;
|
let value: TString = kwargs.get_or(Qstr::MP_QSTR_value, "".into())?;
|
||||||
let cancel: TString = TR::words__cancel_and_exit.into();
|
let verb_cancel: Option<TString> = kwargs
|
||||||
|
.get(Qstr::MP_QSTR_verb_cancel)
|
||||||
|
.unwrap_or_else(|_| Obj::const_none())
|
||||||
|
.try_into_option()?;
|
||||||
let confirm: TString = TR::words__continue_anyway.into();
|
let confirm: TString = TR::words__continue_anyway.into();
|
||||||
let done_title: TString = TR::words__operation_cancelled.into();
|
let done_title: TString = TR::words__operation_cancelled.into();
|
||||||
|
|
||||||
|
let verb_cancel = verb_cancel.unwrap_or(TR::words__cancel_and_exit.into());
|
||||||
|
|
||||||
// Message
|
// Message
|
||||||
let paragraphs = [
|
let paragraphs = [
|
||||||
Paragraph::new(&theme::TEXT_MAIN_GREY_LIGHT, description),
|
Paragraph::new(&theme::TEXT_MAIN_GREY_LIGHT, description),
|
||||||
@ -83,7 +88,7 @@ impl WarningHiPrio {
|
|||||||
.into_paragraphs();
|
.into_paragraphs();
|
||||||
let content_message = Frame::left_aligned(title, SwipeContent::new(paragraphs))
|
let content_message = Frame::left_aligned(title, SwipeContent::new(paragraphs))
|
||||||
.with_menu_button()
|
.with_menu_button()
|
||||||
.with_footer(TR::instructions__swipe_up.into(), Some(cancel))
|
.with_footer(TR::instructions__swipe_up.into(), Some(verb_cancel))
|
||||||
.with_danger()
|
.with_danger()
|
||||||
.with_swipe(Direction::Up, SwipeSettings::default())
|
.with_swipe(Direction::Up, SwipeSettings::default())
|
||||||
.with_swipe(Direction::Left, SwipeSettings::default())
|
.with_swipe(Direction::Left, SwipeSettings::default())
|
||||||
@ -94,7 +99,7 @@ impl WarningHiPrio {
|
|||||||
let content_menu = Frame::left_aligned(
|
let content_menu = Frame::left_aligned(
|
||||||
"".into(),
|
"".into(),
|
||||||
VerticalMenu::empty()
|
VerticalMenu::empty()
|
||||||
.item(theme::ICON_CANCEL, TR::buttons__cancel.into())
|
.item(theme::ICON_CANCEL, verb_cancel)
|
||||||
.danger(theme::ICON_CHEVRON_RIGHT, confirm),
|
.danger(theme::ICON_CHEVRON_RIGHT, confirm),
|
||||||
)
|
)
|
||||||
.with_cancel_button()
|
.with_cancel_button()
|
||||||
|
@ -51,10 +51,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
model_mercury::{
|
model_mercury::{
|
||||||
component::{check_homescreen_format, SwipeContent},
|
component::{check_homescreen_format, SwipeContent},
|
||||||
flow::{
|
flow::{new_confirm_action_simple, ConfirmActionMenu, ConfirmActionStrings},
|
||||||
new_confirm_action_simple, new_confirm_action_simple_default_cancel,
|
|
||||||
ConfirmActionMenu, ConfirmActionStrings,
|
|
||||||
},
|
|
||||||
theme::ICON_BULLET_CHECKMARK,
|
theme::ICON_BULLET_CHECKMARK,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -269,7 +266,6 @@ struct ConfirmBlobParams {
|
|||||||
chunkify: bool,
|
chunkify: bool,
|
||||||
text_mono: bool,
|
text_mono: bool,
|
||||||
page_limit: Option<usize>,
|
page_limit: Option<usize>,
|
||||||
default_cancel: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConfirmBlobParams {
|
impl ConfirmBlobParams {
|
||||||
@ -298,7 +294,6 @@ impl ConfirmBlobParams {
|
|||||||
chunkify: false,
|
chunkify: false,
|
||||||
text_mono: true,
|
text_mono: true,
|
||||||
page_limit: None,
|
page_limit: None,
|
||||||
default_cancel: false,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,11 +332,6 @@ impl ConfirmBlobParams {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn with_default_cancel(mut self, default_cancel: bool) -> Self {
|
|
||||||
self.default_cancel = default_cancel;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
fn with_description_font(mut self, description_font: &'static TextStyle) -> Self {
|
fn with_description_font(mut self, description_font: &'static TextStyle) -> Self {
|
||||||
self.description_font = description_font;
|
self.description_font = description_font;
|
||||||
self
|
self
|
||||||
@ -365,13 +355,7 @@ impl ConfirmBlobParams {
|
|||||||
}
|
}
|
||||||
.into_paragraphs();
|
.into_paragraphs();
|
||||||
|
|
||||||
let build_flow = if self.default_cancel {
|
new_confirm_action_simple(
|
||||||
new_confirm_action_simple_default_cancel
|
|
||||||
} else {
|
|
||||||
new_confirm_action_simple
|
|
||||||
};
|
|
||||||
|
|
||||||
build_flow(
|
|
||||||
paragraphs,
|
paragraphs,
|
||||||
ConfirmActionMenu::new(self.verb_cancel, self.info_button, self.verb_info),
|
ConfirmActionMenu::new(self.verb_cancel, self.info_button, self.verb_info),
|
||||||
ConfirmActionStrings::new(
|
ConfirmActionStrings::new(
|
||||||
@ -419,7 +403,6 @@ extern "C" fn new_confirm_blob(n_args: usize, args: *const Obj, kwargs: *mut Map
|
|||||||
let hold: bool = kwargs.get_or(Qstr::MP_QSTR_hold, false)?;
|
let hold: bool = kwargs.get_or(Qstr::MP_QSTR_hold, false)?;
|
||||||
let chunkify: bool = kwargs.get_or(Qstr::MP_QSTR_chunkify, false)?;
|
let chunkify: bool = kwargs.get_or(Qstr::MP_QSTR_chunkify, false)?;
|
||||||
let prompt_screen: bool = kwargs.get_or(Qstr::MP_QSTR_prompt_screen, true)?;
|
let prompt_screen: bool = kwargs.get_or(Qstr::MP_QSTR_prompt_screen, true)?;
|
||||||
let default_cancel: bool = kwargs.get_or(Qstr::MP_QSTR_default_cancel, false)?;
|
|
||||||
let page_limit: Option<usize> = kwargs
|
let page_limit: Option<usize> = kwargs
|
||||||
.get(Qstr::MP_QSTR_page_limit)
|
.get(Qstr::MP_QSTR_page_limit)
|
||||||
.unwrap_or_else(|_| Obj::const_none())
|
.unwrap_or_else(|_| Obj::const_none())
|
||||||
@ -447,7 +430,6 @@ extern "C" fn new_confirm_blob(n_args: usize, args: *const Obj, kwargs: *mut Map
|
|||||||
.with_extra(extra)
|
.with_extra(extra)
|
||||||
.with_info_button(info)
|
.with_info_button(info)
|
||||||
.with_chunkify(chunkify)
|
.with_chunkify(chunkify)
|
||||||
.with_default_cancel(default_cancel)
|
|
||||||
.with_page_limit(page_limit)
|
.with_page_limit(page_limit)
|
||||||
.into_flow()
|
.into_flow()
|
||||||
};
|
};
|
||||||
@ -1277,7 +1259,6 @@ pub static mp_module_trezorui2: Module = obj_module! {
|
|||||||
/// hold: bool = False,
|
/// hold: bool = False,
|
||||||
/// chunkify: bool = False,
|
/// chunkify: bool = False,
|
||||||
/// prompt_screen: bool = False,
|
/// prompt_screen: bool = False,
|
||||||
/// default_cancel: bool = False,
|
|
||||||
/// page_limit: int | None = None,
|
/// page_limit: int | None = None,
|
||||||
/// ) -> LayoutObj[UiResult]:
|
/// ) -> LayoutObj[UiResult]:
|
||||||
/// """Confirm byte sequence data."""
|
/// """Confirm byte sequence data."""
|
||||||
@ -1681,6 +1662,7 @@ pub static mp_module_trezorui2: Module = obj_module! {
|
|||||||
/// title: str,
|
/// title: str,
|
||||||
/// description: str,
|
/// description: str,
|
||||||
/// value: str = "",
|
/// value: str = "",
|
||||||
|
/// verb_cancel: str | None = None,
|
||||||
/// ) -> LayoutObj[UiResult]:
|
/// ) -> LayoutObj[UiResult]:
|
||||||
/// """Warning modal with multiple steps to confirm."""
|
/// """Warning modal with multiple steps to confirm."""
|
||||||
Qstr::MP_QSTR_flow_warning_hi_prio => obj_fn_kw!(0, flow::warning_hi_prio::new_warning_hi_prio).as_obj(),
|
Qstr::MP_QSTR_flow_warning_hi_prio => obj_fn_kw!(0, flow::warning_hi_prio::new_warning_hi_prio).as_obj(),
|
||||||
|
@ -1752,7 +1752,6 @@ pub static mp_module_trezorui2: Module = obj_module! {
|
|||||||
/// hold: bool = False,
|
/// hold: bool = False,
|
||||||
/// chunkify: bool = False,
|
/// chunkify: bool = False,
|
||||||
/// prompt_screen: bool = False,
|
/// prompt_screen: bool = False,
|
||||||
/// default_cancel: bool = False,
|
|
||||||
/// page_limit: int | None = None,
|
/// page_limit: int | None = None,
|
||||||
/// ) -> LayoutObj[UiResult]:
|
/// ) -> LayoutObj[UiResult]:
|
||||||
/// """Confirm byte sequence data."""
|
/// """Confirm byte sequence data."""
|
||||||
|
@ -1805,7 +1805,6 @@ pub static mp_module_trezorui2: Module = obj_module! {
|
|||||||
/// hold: bool = False,
|
/// hold: bool = False,
|
||||||
/// chunkify: bool = False,
|
/// chunkify: bool = False,
|
||||||
/// prompt_screen: bool = False,
|
/// prompt_screen: bool = False,
|
||||||
/// default_cancel: bool = False,
|
|
||||||
/// page_limit: int | None = None,
|
/// page_limit: int | None = None,
|
||||||
/// ) -> LayoutObj[UiResult]:
|
/// ) -> LayoutObj[UiResult]:
|
||||||
/// """Confirm byte sequence data."""
|
/// """Confirm byte sequence data."""
|
||||||
|
@ -70,7 +70,6 @@ def confirm_blob(
|
|||||||
hold: bool = False,
|
hold: bool = False,
|
||||||
chunkify: bool = False,
|
chunkify: bool = False,
|
||||||
prompt_screen: bool = False,
|
prompt_screen: bool = False,
|
||||||
default_cancel: bool = False,
|
|
||||||
page_limit: int | None = None,
|
page_limit: int | None = None,
|
||||||
) -> LayoutObj[UiResult]:
|
) -> LayoutObj[UiResult]:
|
||||||
"""Confirm byte sequence data."""
|
"""Confirm byte sequence data."""
|
||||||
@ -513,6 +512,7 @@ def flow_warning_hi_prio(
|
|||||||
title: str,
|
title: str,
|
||||||
description: str,
|
description: str,
|
||||||
value: str = "",
|
value: str = "",
|
||||||
|
verb_cancel: str | None = None,
|
||||||
) -> LayoutObj[UiResult]:
|
) -> LayoutObj[UiResult]:
|
||||||
"""Warning modal with multiple steps to confirm."""
|
"""Warning modal with multiple steps to confirm."""
|
||||||
|
|
||||||
@ -643,7 +643,6 @@ def confirm_blob(
|
|||||||
hold: bool = False,
|
hold: bool = False,
|
||||||
chunkify: bool = False,
|
chunkify: bool = False,
|
||||||
prompt_screen: bool = False,
|
prompt_screen: bool = False,
|
||||||
default_cancel: bool = False,
|
|
||||||
page_limit: int | None = None,
|
page_limit: int | None = None,
|
||||||
) -> LayoutObj[UiResult]:
|
) -> LayoutObj[UiResult]:
|
||||||
"""Confirm byte sequence data."""
|
"""Confirm byte sequence data."""
|
||||||
@ -1216,7 +1215,6 @@ def confirm_blob(
|
|||||||
hold: bool = False,
|
hold: bool = False,
|
||||||
chunkify: bool = False,
|
chunkify: bool = False,
|
||||||
prompt_screen: bool = False,
|
prompt_screen: bool = False,
|
||||||
default_cancel: bool = False,
|
|
||||||
page_limit: int | None = None,
|
page_limit: int | None = None,
|
||||||
) -> LayoutObj[UiResult]:
|
) -> LayoutObj[UiResult]:
|
||||||
"""Confirm byte sequence data."""
|
"""Confirm byte sequence data."""
|
||||||
|
@ -145,15 +145,9 @@ async def require_confirm_claim(
|
|||||||
async def require_confirm_unknown_token(address_bytes: bytes) -> None:
|
async def require_confirm_unknown_token(address_bytes: bytes) -> None:
|
||||||
from ubinascii import hexlify
|
from ubinascii import hexlify
|
||||||
|
|
||||||
from trezor.ui.layouts import confirm_address, show_warning
|
from trezor.ui.layouts import confirm_address, confirm_unknown_contract_warning
|
||||||
|
|
||||||
await show_warning(
|
await confirm_unknown_contract_warning()
|
||||||
"unknown_contract_warning",
|
|
||||||
TR.ethereum__unknown_contract_address,
|
|
||||||
default_cancel=True,
|
|
||||||
verb_cancel=TR.send__cancel_sign,
|
|
||||||
br_code=ButtonRequestType.Other,
|
|
||||||
)
|
|
||||||
|
|
||||||
contract_address_hex = "0x" + hexlify(address_bytes).decode()
|
contract_address_hex = "0x" + hexlify(address_bytes).decode()
|
||||||
await confirm_address(
|
await confirm_address(
|
||||||
|
@ -139,6 +139,20 @@ def confirm_multisig_warning() -> Awaitable[None]:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if not utils.BITCOIN_ONLY:
|
||||||
|
|
||||||
|
def confirm_unknown_contract_warning() -> Awaitable[None]:
|
||||||
|
return raise_if_not_confirmed(
|
||||||
|
trezorui2.flow_warning_hi_prio(
|
||||||
|
title=TR.words__warning,
|
||||||
|
description=TR.ethereum__unknown_contract_address,
|
||||||
|
verb_cancel=TR.send__cancel_sign,
|
||||||
|
),
|
||||||
|
"unknown_contract_warning",
|
||||||
|
ButtonRequestType.Warning,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def confirm_homescreen(
|
def confirm_homescreen(
|
||||||
image: bytes,
|
image: bytes,
|
||||||
) -> Awaitable[None]:
|
) -> Awaitable[None]:
|
||||||
@ -301,36 +315,19 @@ def show_warning(
|
|||||||
content: str,
|
content: str,
|
||||||
subheader: str | None = None,
|
subheader: str | None = None,
|
||||||
button: str | None = None,
|
button: str | None = None,
|
||||||
default_cancel: bool = False,
|
|
||||||
verb_cancel: str | None = None,
|
|
||||||
br_code: ButtonRequestType = ButtonRequestType.Warning,
|
br_code: ButtonRequestType = ButtonRequestType.Warning,
|
||||||
) -> Awaitable[None]:
|
) -> Awaitable[None]:
|
||||||
button = button or TR.buttons__continue # def_arg
|
button = button or TR.buttons__continue # def_arg
|
||||||
if default_cancel:
|
return raise_if_not_confirmed(
|
||||||
# a kind of warning which makes it easy (swipe up) to cancel
|
trezorui2.show_warning(
|
||||||
# and makes it harder to continue
|
title=TR.words__important,
|
||||||
return confirm_blob(
|
value=content,
|
||||||
br_name,
|
button=subheader or TR.words__continue_anyway_question,
|
||||||
TR.words__warning,
|
danger=True,
|
||||||
content,
|
),
|
||||||
text_mono=False,
|
br_name,
|
||||||
verb_cancel=verb_cancel,
|
br_code,
|
||||||
default_cancel=True,
|
)
|
||||||
prompt_screen=False,
|
|
||||||
br_code=br_code,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
# traditional warning
|
|
||||||
return raise_if_not_confirmed(
|
|
||||||
trezorui2.show_warning(
|
|
||||||
title=TR.words__important,
|
|
||||||
value=content,
|
|
||||||
button=subheader or TR.words__continue_anyway_question,
|
|
||||||
danger=True,
|
|
||||||
),
|
|
||||||
br_name,
|
|
||||||
br_code,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def show_success(
|
def show_success(
|
||||||
@ -518,7 +515,6 @@ def confirm_blob(
|
|||||||
hold: bool = False,
|
hold: bool = False,
|
||||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||||
chunkify: bool = False,
|
chunkify: bool = False,
|
||||||
default_cancel: bool = False,
|
|
||||||
prompt_screen: bool = True,
|
prompt_screen: bool = True,
|
||||||
) -> Awaitable[None]:
|
) -> Awaitable[None]:
|
||||||
layout = trezorui2.confirm_blob(
|
layout = trezorui2.confirm_blob(
|
||||||
@ -533,7 +529,6 @@ def confirm_blob(
|
|||||||
hold=hold,
|
hold=hold,
|
||||||
chunkify=chunkify,
|
chunkify=chunkify,
|
||||||
prompt_screen=prompt_screen,
|
prompt_screen=prompt_screen,
|
||||||
default_cancel=default_cancel,
|
|
||||||
)
|
)
|
||||||
return raise_if_not_confirmed(
|
return raise_if_not_confirmed(
|
||||||
layout,
|
layout,
|
||||||
|
@ -181,6 +181,15 @@ def confirm_multisig_warning() -> Awaitable[ui.UiResult]:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if not utils.BITCOIN_ONLY:
|
||||||
|
|
||||||
|
def confirm_unknown_contract_warning() -> Awaitable[ui.UiResult]:
|
||||||
|
return show_warning(
|
||||||
|
"unknown_contract_warning",
|
||||||
|
TR.ethereum__unknown_contract_address,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def confirm_homescreen(image: bytes) -> Awaitable[None]:
|
def confirm_homescreen(image: bytes) -> Awaitable[None]:
|
||||||
return raise_if_not_confirmed(
|
return raise_if_not_confirmed(
|
||||||
trezorui2.confirm_homescreen(
|
trezorui2.confirm_homescreen(
|
||||||
@ -385,7 +394,6 @@ def show_warning(
|
|||||||
content: str,
|
content: str,
|
||||||
subheader: str | None = None,
|
subheader: str | None = None,
|
||||||
button: str | None = None,
|
button: str | None = None,
|
||||||
default_cancel: bool = False, # NB: model R does not implement "default_cancel"-style warnings
|
|
||||||
verb_cancel: str | None = None,
|
verb_cancel: str | None = None,
|
||||||
br_code: ButtonRequestType = ButtonRequestType.Warning,
|
br_code: ButtonRequestType = ButtonRequestType.Warning,
|
||||||
exc: ExceptionType | None = ActionCancelled,
|
exc: ExceptionType | None = ActionCancelled,
|
||||||
@ -588,7 +596,6 @@ def confirm_blob(
|
|||||||
hold: bool = False,
|
hold: bool = False,
|
||||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||||
chunkify: bool = False,
|
chunkify: bool = False,
|
||||||
default_cancel: bool = False,
|
|
||||||
prompt_screen: bool = True,
|
prompt_screen: bool = True,
|
||||||
ask_pagination: bool = False,
|
ask_pagination: bool = False,
|
||||||
) -> Awaitable[None]:
|
) -> Awaitable[None]:
|
||||||
|
@ -162,6 +162,16 @@ def confirm_multisig_warning() -> Awaitable[None]:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if not utils.BITCOIN_ONLY:
|
||||||
|
|
||||||
|
def confirm_unknown_contract_warning() -> Awaitable[None]:
|
||||||
|
return show_warning(
|
||||||
|
"unknown_contract_warning",
|
||||||
|
TR.ethereum__unknown_contract_address,
|
||||||
|
TR.words__warning,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def confirm_homescreen(image: bytes) -> Awaitable[None]:
|
def confirm_homescreen(image: bytes) -> Awaitable[None]:
|
||||||
return raise_if_not_confirmed(
|
return raise_if_not_confirmed(
|
||||||
trezorui2.confirm_homescreen(
|
trezorui2.confirm_homescreen(
|
||||||
@ -349,7 +359,6 @@ def show_warning(
|
|||||||
content: str,
|
content: str,
|
||||||
subheader: str | None = None,
|
subheader: str | None = None,
|
||||||
button: str | None = None,
|
button: str | None = None,
|
||||||
default_cancel: bool = False, # NB: model T does not implement "default_cancel"-style warnings
|
|
||||||
verb_cancel: str | None = None,
|
verb_cancel: str | None = None,
|
||||||
br_code: ButtonRequestType = ButtonRequestType.Warning,
|
br_code: ButtonRequestType = ButtonRequestType.Warning,
|
||||||
) -> Awaitable[None]:
|
) -> Awaitable[None]:
|
||||||
@ -590,7 +599,6 @@ def confirm_blob(
|
|||||||
hold: bool = False,
|
hold: bool = False,
|
||||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||||
chunkify: bool = False,
|
chunkify: bool = False,
|
||||||
default_cancel: bool = False,
|
|
||||||
prompt_screen: bool = True,
|
prompt_screen: bool = True,
|
||||||
) -> Awaitable[None]:
|
) -> Awaitable[None]:
|
||||||
verb = verb or TR.buttons__confirm # def_arg
|
verb = verb or TR.buttons__confirm # def_arg
|
||||||
|
Loading…
Reference in New Issue
Block a user