1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 07:28:10 +00:00

refactor(core): move confirm_modify_output/fee

This commit is contained in:
obrusvit 2024-11-01 22:25:58 +01:00
parent 664597374b
commit 99b450545a
13 changed files with 301 additions and 353 deletions

View File

@ -122,6 +122,41 @@ extern "C" fn new_confirm_homescreen(n_args: usize, args: *const Obj, kwargs: *m
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
}
extern "C" fn new_confirm_modify_fee(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
let block = move |_args: &[Obj], kwargs: &Map| {
let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?;
let sign: i32 = kwargs.get(Qstr::MP_QSTR_sign)?.try_into()?;
let user_fee_change: TString = kwargs.get(Qstr::MP_QSTR_user_fee_change)?.try_into()?;
let total_fee_new: TString = kwargs.get(Qstr::MP_QSTR_total_fee_new)?.try_into()?;
let fee_rate_amount: Option<TString> = kwargs
.get(Qstr::MP_QSTR_fee_rate_amount)
.unwrap_or_else(|_| Obj::const_none())
.try_into_option()?;
let layout = ModelUI::confirm_modify_fee(
title,
sign,
user_fee_change,
total_fee_new,
fee_rate_amount,
)?;
Ok(LayoutObj::new_root(layout)?.into())
};
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
}
extern "C" fn new_confirm_modify_output(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
let block = move |_args: &[Obj], kwargs: &Map| {
let sign: i32 = kwargs.get(Qstr::MP_QSTR_sign)?.try_into()?;
let amount_change: TString = kwargs.get(Qstr::MP_QSTR_amount_change)?.try_into()?;
let amount_new: TString = kwargs.get(Qstr::MP_QSTR_amount_new)?.try_into()?;
let layout = ModelUI::confirm_modify_output(sign, amount_change, amount_new)?;
Ok(LayoutObj::new_root(layout)?.into())
};
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
}
extern "C" fn new_confirm_reset_device(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
let block = move |_args: &[Obj], kwargs: &Map| {
let recovery: bool = kwargs.get(Qstr::MP_QSTR_recovery)?.try_into()?;
@ -532,6 +567,26 @@ pub static mp_module_trezorui_api: Module = obj_module! {
/// """Confirm homescreen."""
Qstr::MP_QSTR_confirm_homescreen => obj_fn_kw!(0, new_confirm_homescreen).as_obj(),
/// def confirm_modify_fee(
/// *,
/// title: str,
/// sign: int,
/// user_fee_change: str,
/// total_fee_new: str,
/// fee_rate_amount: str | None,
/// ) -> LayoutObj[UiResult]:
/// """Decrease or increase transaction fee."""
Qstr::MP_QSTR_confirm_modify_fee => obj_fn_kw!(0, new_confirm_modify_fee).as_obj(),
/// def confirm_modify_output(
/// *,
/// sign: int,
/// amount_change: str,
/// amount_new: str,
/// ) -> LayoutObj[UiResult]:
/// """Decrease or increase output amount."""
Qstr::MP_QSTR_confirm_modify_output => obj_fn_kw!(0, new_confirm_modify_output).as_obj(),
/// def confirm_reset_device(recovery: bool) -> LayoutObj[UiResult]:
/// """Confirm TOS before creating wallet creation or wallet recovery."""
Qstr::MP_QSTR_confirm_reset_device => obj_fn_kw!(0, new_confirm_reset_device).as_obj(),

View File

@ -658,81 +658,6 @@ extern "C" fn new_confirm_total(n_args: usize, args: *const Obj, kwargs: *mut Ma
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
}
extern "C" fn new_confirm_modify_output(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
let block = move |_args: &[Obj], kwargs: &Map| {
let sign: i32 = kwargs.get(Qstr::MP_QSTR_sign)?.try_into()?;
let amount_change: TString = kwargs.get(Qstr::MP_QSTR_amount_change)?.try_into()?;
let amount_new: TString = kwargs.get(Qstr::MP_QSTR_amount_new)?.try_into()?;
let description = if sign < 0 {
TR::modify_amount__decrease_amount
} else {
TR::modify_amount__increase_amount
};
let paragraphs = ParagraphVecShort::from_iter([
Paragraph::new(&theme::TEXT_NORMAL, description),
Paragraph::new(&theme::TEXT_MONO, amount_change),
Paragraph::new(&theme::TEXT_NORMAL, TR::modify_amount__new_amount),
Paragraph::new(&theme::TEXT_MONO, amount_new),
])
.into_paragraphs();
let obj = LayoutObj::new(SwipeUpScreen::new(
Frame::left_aligned(TR::modify_amount__title.into(), paragraphs)
.with_cancel_button()
.with_footer(TR::instructions__swipe_up.into(), None)
.with_swipe(Direction::Up, SwipeSettings::default()),
))?;
Ok(obj.into())
};
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
}
extern "C" fn new_confirm_modify_fee(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
let block = move |_args: &[Obj], kwargs: &Map| {
let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?;
let sign: i32 = kwargs.get(Qstr::MP_QSTR_sign)?.try_into()?;
let user_fee_change: TString = kwargs.get(Qstr::MP_QSTR_user_fee_change)?.try_into()?;
let total_fee_new: TString = kwargs.get(Qstr::MP_QSTR_total_fee_new)?.try_into()?;
let (description, change, total_label) = match sign {
s if s < 0 => (
TR::modify_fee__decrease_fee,
user_fee_change,
TR::modify_fee__new_transaction_fee,
),
s if s > 0 => (
TR::modify_fee__increase_fee,
user_fee_change,
TR::modify_fee__new_transaction_fee,
),
_ => (
TR::modify_fee__no_change,
"".into(),
TR::modify_fee__transaction_fee,
),
};
let paragraphs = ParagraphVecShort::from_iter([
Paragraph::new(&theme::TEXT_NORMAL, description),
Paragraph::new(&theme::TEXT_MONO, change),
Paragraph::new(&theme::TEXT_NORMAL, total_label),
Paragraph::new(&theme::TEXT_MONO, total_fee_new),
])
.into_paragraphs();
let obj = LayoutObj::new(SwipeUpScreen::new(
Frame::left_aligned(title, paragraphs)
.with_menu_button()
.with_footer(TR::instructions__swipe_up.into(), None)
.with_swipe(Direction::Up, SwipeSettings::default()),
))?;
Ok(obj.into())
};
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
}
extern "C" fn new_show_error(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
let block = move |_args: &[Obj], kwargs: &Map| {
let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?;
@ -1142,26 +1067,6 @@ pub static mp_module_trezorui2: Module = obj_module! {
/// """Transaction summary. Always hold to confirm."""
Qstr::MP_QSTR_confirm_total => obj_fn_kw!(0, new_confirm_total).as_obj(),
/// def confirm_modify_output(
/// *,
/// sign: int,
/// amount_change: str,
/// amount_new: str,
/// ) -> LayoutObj[UiResult]:
/// """Decrease or increase output amount."""
Qstr::MP_QSTR_confirm_modify_output => obj_fn_kw!(0, new_confirm_modify_output).as_obj(),
/// def confirm_modify_fee(
/// *,
/// title: str,
/// sign: int,
/// user_fee_change: str,
/// total_fee_new: str,
/// fee_rate_amount: str | None, # ignored
/// ) -> LayoutObj[UiResult]:
/// """Decrease or increase transaction fee."""
Qstr::MP_QSTR_confirm_modify_fee => obj_fn_kw!(0, new_confirm_modify_fee).as_obj(),
/// def confirm_fido(
/// *,
/// title: str,

View File

@ -134,6 +134,76 @@ impl UIFeaturesFirmware for ModelMercuryFeatures {
Ok(flow)
}
fn confirm_modify_fee(
title: TString<'static>,
sign: i32,
user_fee_change: TString<'static>,
total_fee_new: TString<'static>,
fee_rate_amount: Option<TString<'static>>,
) -> Result<impl LayoutMaybeTrace, Error> {
let (description, change, total_label) = match sign {
s if s < 0 => (
TR::modify_fee__decrease_fee,
user_fee_change,
TR::modify_fee__new_transaction_fee,
),
s if s > 0 => (
TR::modify_fee__increase_fee,
user_fee_change,
TR::modify_fee__new_transaction_fee,
),
_ => (
TR::modify_fee__no_change,
"".into(),
TR::modify_fee__transaction_fee,
),
};
let paragraphs = ParagraphVecShort::from_iter([
Paragraph::new(&theme::TEXT_NORMAL, description),
Paragraph::new(&theme::TEXT_MONO, change),
Paragraph::new(&theme::TEXT_NORMAL, total_label),
Paragraph::new(&theme::TEXT_MONO, total_fee_new),
])
.into_paragraphs();
let obj = RootComponent::new(SwipeUpScreen::new(
Frame::left_aligned(title, paragraphs)
.with_menu_button()
.with_footer(TR::instructions__swipe_up.into(), None)
.with_swipe(Direction::Up, SwipeSettings::default()),
));
Ok(obj)
}
fn confirm_modify_output(
sign: i32,
amount_change: TString<'static>,
amount_new: TString<'static>,
) -> Result<impl LayoutMaybeTrace, Error> {
let description = if sign < 0 {
TR::modify_amount__decrease_amount
} else {
TR::modify_amount__increase_amount
};
let paragraphs = ParagraphVecShort::from_iter([
Paragraph::new(&theme::TEXT_NORMAL, description),
Paragraph::new(&theme::TEXT_MONO, amount_change),
Paragraph::new(&theme::TEXT_NORMAL, TR::modify_amount__new_amount),
Paragraph::new(&theme::TEXT_MONO, amount_new),
])
.into_paragraphs();
let layout = RootComponent::new(SwipeUpScreen::new(
Frame::left_aligned(TR::modify_amount__title.into(), paragraphs)
.with_cancel_button()
.with_footer(TR::instructions__swipe_up.into(), None)
.with_swipe(Direction::Up, SwipeSettings::default()),
));
Ok(layout)
}
fn confirm_reset_device(recovery: bool) -> Result<impl LayoutMaybeTrace, Error> {
let flow = flow::confirm_reset::new_confirm_reset(recovery)?;
Ok(flow)

View File

@ -478,36 +478,6 @@ extern "C" fn new_confirm_joint_total(n_args: usize, args: *const Obj, kwargs: *
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
}
extern "C" fn new_confirm_modify_output(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
let block = move |_args: &[Obj], kwargs: &Map| {
let sign: i32 = kwargs.get(Qstr::MP_QSTR_sign)?.try_into()?;
let amount_change: TString = kwargs.get(Qstr::MP_QSTR_amount_change)?.try_into()?;
let amount_new: TString = kwargs.get(Qstr::MP_QSTR_amount_new)?.try_into()?;
let description = if sign < 0 {
TR::modify_amount__decrease_amount
} else {
TR::modify_amount__increase_amount
};
let paragraphs = Paragraphs::new([
Paragraph::new(&theme::TEXT_NORMAL, description),
Paragraph::new(&theme::TEXT_MONO, amount_change).break_after(),
Paragraph::new(&theme::TEXT_BOLD, TR::modify_amount__new_amount),
Paragraph::new(&theme::TEXT_MONO, amount_new),
]);
content_in_button_page(
TR::modify_amount__title.into(),
paragraphs,
TR::buttons__confirm.into(),
Some("".into()),
false,
)
};
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
}
extern "C" fn new_confirm_output_address(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
let block = |_args: &[Obj], kwargs: &Map| {
let address: TString = kwargs.get(Qstr::MP_QSTR_address)?.try_into()?;
@ -753,45 +723,6 @@ extern "C" fn new_confirm_address(n_args: usize, args: *const Obj, kwargs: *mut
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
}
extern "C" fn new_confirm_modify_fee(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
let block = move |_args: &[Obj], kwargs: &Map| {
let sign: i32 = kwargs.get(Qstr::MP_QSTR_sign)?.try_into()?;
let user_fee_change: TString = kwargs.get(Qstr::MP_QSTR_user_fee_change)?.try_into()?;
let total_fee_new: TString = kwargs.get(Qstr::MP_QSTR_total_fee_new)?.try_into()?;
let fee_rate_amount: Option<TString> = kwargs
.get(Qstr::MP_QSTR_fee_rate_amount)?
.try_into_option()?;
let (description, change) = match sign {
s if s < 0 => (TR::modify_fee__decrease_fee, user_fee_change),
s if s > 0 => (TR::modify_fee__increase_fee, user_fee_change),
_ => (TR::modify_fee__no_change, "".into()),
};
let mut paragraphs_vec = ParagraphVecShort::new();
paragraphs_vec
.add(Paragraph::new(&theme::TEXT_BOLD, description))
.add(Paragraph::new(&theme::TEXT_MONO, change))
.add(Paragraph::new(&theme::TEXT_BOLD, TR::modify_fee__transaction_fee).no_break())
.add(Paragraph::new(&theme::TEXT_MONO, total_fee_new));
if let Some(fee_rate_amount) = fee_rate_amount {
paragraphs_vec
.add(Paragraph::new(&theme::TEXT_BOLD, TR::modify_fee__fee_rate).no_break())
.add(Paragraph::new(&theme::TEXT_MONO, fee_rate_amount));
}
content_in_button_page(
TR::modify_fee__title.into(),
paragraphs_vec.into_paragraphs(),
TR::buttons__confirm.into(),
Some("".into()),
false,
)
};
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
}
extern "C" fn new_multiple_pages_texts(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
let block = move |_args: &[Obj], kwargs: &Map| {
let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?;
@ -1197,15 +1128,6 @@ pub static mp_module_trezorui2: Module = obj_module! {
/// """Confirm total if there are external inputs."""
Qstr::MP_QSTR_confirm_joint_total => obj_fn_kw!(0, new_confirm_joint_total).as_obj(),
/// def confirm_modify_output(
/// *,
/// sign: int,
/// amount_change: str,
/// amount_new: str,
/// ) -> LayoutObj[UiResult]:
/// """Decrease or increase output amount."""
Qstr::MP_QSTR_confirm_modify_output => obj_fn_kw!(0, new_confirm_modify_output).as_obj(),
/// def confirm_output_address(
/// *,
/// address: str,
@ -1249,17 +1171,6 @@ pub static mp_module_trezorui2: Module = obj_module! {
/// """Confirm details about altcoin transaction."""
Qstr::MP_QSTR_altcoin_tx_summary => obj_fn_kw!(0, new_altcoin_tx_summary).as_obj(),
/// def confirm_modify_fee(
/// *,
/// title: str, # ignored
/// sign: int,
/// user_fee_change: str,
/// total_fee_new: str,
/// fee_rate_amount: str | None,
/// ) -> LayoutObj[UiResult]:
/// """Decrease or increase transaction fee."""
Qstr::MP_QSTR_confirm_modify_fee => obj_fn_kw!(0, new_confirm_modify_fee).as_obj(),
/// def confirm_fido(
/// *,
/// title: str,

View File

@ -142,6 +142,68 @@ impl UIFeaturesFirmware for ModelTRFeatures {
Ok(layout)
}
fn confirm_modify_fee(
title: TString<'static>,
sign: i32,
user_fee_change: TString<'static>,
total_fee_new: TString<'static>,
fee_rate_amount: Option<TString<'static>>,
) -> Result<impl LayoutMaybeTrace, Error> {
let (description, change) = match sign {
s if s < 0 => (TR::modify_fee__decrease_fee, user_fee_change),
s if s > 0 => (TR::modify_fee__increase_fee, user_fee_change),
_ => (TR::modify_fee__no_change, "".into()),
};
let mut paragraphs_vec = ParagraphVecShort::new();
paragraphs_vec
.add(Paragraph::new(&theme::TEXT_BOLD, description))
.add(Paragraph::new(&theme::TEXT_MONO, change))
.add(Paragraph::new(&theme::TEXT_BOLD, TR::modify_fee__transaction_fee).no_break())
.add(Paragraph::new(&theme::TEXT_MONO, total_fee_new));
if let Some(fee_rate_amount) = fee_rate_amount {
paragraphs_vec
.add(Paragraph::new(&theme::TEXT_BOLD, TR::modify_fee__fee_rate).no_break())
.add(Paragraph::new(&theme::TEXT_MONO, fee_rate_amount));
}
content_in_button_page(
TR::modify_fee__title.into(),
paragraphs_vec.into_paragraphs(),
TR::buttons__confirm.into(),
Some("".into()),
false,
)
}
fn confirm_modify_output(
sign: i32,
amount_change: TString<'static>,
amount_new: TString<'static>,
) -> Result<impl LayoutMaybeTrace, Error> {
let description = if sign < 0 {
TR::modify_amount__decrease_amount
} else {
TR::modify_amount__increase_amount
};
let paragraphs = Paragraphs::new([
Paragraph::new(&theme::TEXT_NORMAL, description),
Paragraph::new(&theme::TEXT_MONO, amount_change).break_after(),
Paragraph::new(&theme::TEXT_BOLD, TR::modify_amount__new_amount),
Paragraph::new(&theme::TEXT_MONO, amount_new),
]);
content_in_button_page(
TR::modify_amount__title.into(),
paragraphs,
TR::buttons__confirm.into(),
Some("".into()),
false,
)
}
fn confirm_reset_device(recovery: bool) -> Result<impl LayoutMaybeTrace, Error> {
let (title, button) = if recovery {
(

View File

@ -702,83 +702,6 @@ extern "C" fn new_confirm_total(n_args: usize, args: *const Obj, kwargs: *mut Ma
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
}
extern "C" fn new_confirm_modify_output(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
let block = move |_args: &[Obj], kwargs: &Map| {
let sign: i32 = kwargs.get(Qstr::MP_QSTR_sign)?.try_into()?;
let amount_change: TString = kwargs.get(Qstr::MP_QSTR_amount_change)?.try_into()?;
let amount_new: TString = kwargs.get(Qstr::MP_QSTR_amount_new)?.try_into()?;
let description = if sign < 0 {
TR::modify_amount__decrease_amount
} else {
TR::modify_amount__increase_amount
};
let paragraphs = Paragraphs::new([
Paragraph::new(&theme::TEXT_NORMAL, description),
Paragraph::new(&theme::TEXT_MONO, amount_change),
Paragraph::new(&theme::TEXT_NORMAL, TR::modify_amount__new_amount),
Paragraph::new(&theme::TEXT_MONO, amount_new),
]);
let obj = LayoutObj::new(Frame::left_aligned(
theme::label_title(),
TR::modify_amount__title.into(),
ButtonPage::new(paragraphs, theme::BG)
.with_cancel_confirm(Some("^".into()), Some(TR::buttons__continue.into())),
))?;
Ok(obj.into())
};
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
}
extern "C" fn new_confirm_modify_fee(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
let block = move |_args: &[Obj], kwargs: &Map| {
let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?;
let sign: i32 = kwargs.get(Qstr::MP_QSTR_sign)?.try_into()?;
let user_fee_change: TString = kwargs.get(Qstr::MP_QSTR_user_fee_change)?.try_into()?;
let total_fee_new: TString = kwargs.get(Qstr::MP_QSTR_total_fee_new)?.try_into()?;
let (description, change, total_label) = match sign {
s if s < 0 => (
TR::modify_fee__decrease_fee,
user_fee_change,
TR::modify_fee__new_transaction_fee,
),
s if s > 0 => (
TR::modify_fee__increase_fee,
user_fee_change,
TR::modify_fee__new_transaction_fee,
),
_ => (
TR::modify_fee__no_change,
"".into(),
TR::modify_fee__transaction_fee,
),
};
let paragraphs = Paragraphs::new([
Paragraph::new(&theme::TEXT_NORMAL, description),
Paragraph::new(&theme::TEXT_MONO, change),
Paragraph::new(&theme::TEXT_NORMAL, total_label),
Paragraph::new(&theme::TEXT_MONO, total_fee_new),
]);
let obj = LayoutObj::new(
Frame::left_aligned(
theme::label_title(),
title,
ButtonPage::new(paragraphs, theme::BG)
.with_hold()?
.with_swipe_left(),
)
.with_info_button(),
)?;
Ok(obj.into())
};
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
}
fn new_show_modal(
kwargs: &Map,
icon: BlendedImage,
@ -1253,26 +1176,6 @@ pub static mp_module_trezorui2: Module = obj_module! {
/// """Transaction summary. Always hold to confirm."""
Qstr::MP_QSTR_confirm_total => obj_fn_kw!(0, new_confirm_total).as_obj(),
/// def confirm_modify_output(
/// *,
/// sign: int,
/// amount_change: str,
/// amount_new: str,
/// ) -> LayoutObj[UiResult]:
/// """Decrease or increase output amount."""
Qstr::MP_QSTR_confirm_modify_output => obj_fn_kw!(0, new_confirm_modify_output).as_obj(),
/// def confirm_modify_fee(
/// *,
/// title: str,
/// sign: int,
/// user_fee_change: str,
/// total_fee_new: str,
/// fee_rate_amount: str | None, # ignored
/// ) -> LayoutObj[UiResult]:
/// """Decrease or increase transaction fee."""
Qstr::MP_QSTR_confirm_modify_fee => obj_fn_kw!(0, new_confirm_modify_fee).as_obj(),
/// def confirm_fido(
/// *,
/// title: str,

View File

@ -141,6 +141,78 @@ impl UIFeaturesFirmware for ModelTTFeatures {
Ok(layout)
}
fn confirm_modify_fee(
title: TString<'static>,
sign: i32,
user_fee_change: TString<'static>,
total_fee_new: TString<'static>,
fee_rate_amount: Option<TString<'static>>,
) -> Result<impl LayoutMaybeTrace, Error> {
let (description, change, total_label) = match sign {
s if s < 0 => (
TR::modify_fee__decrease_fee,
user_fee_change,
TR::modify_fee__new_transaction_fee,
),
s if s > 0 => (
TR::modify_fee__increase_fee,
user_fee_change,
TR::modify_fee__new_transaction_fee,
),
_ => (
TR::modify_fee__no_change,
"".into(),
TR::modify_fee__transaction_fee,
),
};
let paragraphs = Paragraphs::new([
Paragraph::new(&theme::TEXT_NORMAL, description),
Paragraph::new(&theme::TEXT_MONO, change),
Paragraph::new(&theme::TEXT_NORMAL, total_label),
Paragraph::new(&theme::TEXT_MONO, total_fee_new),
]);
let layout = RootComponent::new(
Frame::left_aligned(
theme::label_title(),
title,
ButtonPage::new(paragraphs, theme::BG)
.with_hold()?
.with_swipe_left(),
)
.with_info_button(),
);
Ok(layout)
}
fn confirm_modify_output(
sign: i32,
amount_change: TString<'static>,
amount_new: TString<'static>,
) -> Result<impl LayoutMaybeTrace, Error> {
let description = if sign < 0 {
TR::modify_amount__decrease_amount
} else {
TR::modify_amount__increase_amount
};
let paragraphs = Paragraphs::new([
Paragraph::new(&theme::TEXT_NORMAL, description),
Paragraph::new(&theme::TEXT_MONO, amount_change),
Paragraph::new(&theme::TEXT_NORMAL, TR::modify_amount__new_amount),
Paragraph::new(&theme::TEXT_MONO, amount_new),
]);
let layout = RootComponent::new(Frame::left_aligned(
theme::label_title(),
TR::modify_amount__title.into(),
ButtonPage::new(paragraphs, theme::BG)
.with_cancel_confirm(Some("^".into()), Some(TR::buttons__continue.into())),
));
Ok(layout)
}
fn confirm_reset_device(recovery: bool) -> Result<impl LayoutMaybeTrace, Error> {
let (title, button) = if recovery {
(

View File

@ -35,6 +35,20 @@ pub trait UIFeaturesFirmware {
fingerprint: TString<'static>,
) -> Result<impl LayoutMaybeTrace, Error>;
fn confirm_modify_fee(
title: TString<'static>,
sign: i32,
user_fee_change: TString<'static>,
total_fee_new: TString<'static>,
fee_rate_amount: Option<TString<'static>>,
) -> Result<impl LayoutMaybeTrace, Error>;
fn confirm_modify_output(
sign: i32,
amount_change: TString<'static>,
amount_new: TString<'static>,
) -> Result<impl LayoutMaybeTrace, Error>;
fn confirm_reset_device(recovery: bool) -> Result<impl LayoutMaybeTrace, Error>;
fn check_homescreen_format(image: BinaryData, accept_toif: bool) -> bool;

View File

@ -108,28 +108,6 @@ def confirm_total(
"""Transaction summary. Always hold to confirm."""
# rust/src/ui/model_mercury/layout.rs
def confirm_modify_output(
*,
sign: int,
amount_change: str,
amount_new: str,
) -> LayoutObj[UiResult]:
"""Decrease or increase output amount."""
# rust/src/ui/model_mercury/layout.rs
def confirm_modify_fee(
*,
title: str,
sign: int,
user_fee_change: str,
total_fee_new: str,
fee_rate_amount: str | None, # ignored
) -> LayoutObj[UiResult]:
"""Decrease or increase transaction fee."""
# rust/src/ui/model_mercury/layout.rs
def confirm_fido(
*,
@ -410,16 +388,6 @@ def confirm_joint_total(
"""Confirm total if there are external inputs."""
# rust/src/ui/model_tr/layout.rs
def confirm_modify_output(
*,
sign: int,
amount_change: str,
amount_new: str,
) -> LayoutObj[UiResult]:
"""Decrease or increase output amount."""
# rust/src/ui/model_tr/layout.rs
def confirm_output_address(
*,
@ -467,18 +435,6 @@ def altcoin_tx_summary(
"""Confirm details about altcoin transaction."""
# rust/src/ui/model_tr/layout.rs
def confirm_modify_fee(
*,
title: str, # ignored
sign: int,
user_fee_change: str,
total_fee_new: str,
fee_rate_amount: str | None,
) -> LayoutObj[UiResult]:
"""Decrease or increase transaction fee."""
# rust/src/ui/model_tr/layout.rs
def confirm_fido(
*,
@ -711,28 +667,6 @@ def confirm_total(
"""Transaction summary. Always hold to confirm."""
# rust/src/ui/model_tt/layout.rs
def confirm_modify_output(
*,
sign: int,
amount_change: str,
amount_new: str,
) -> LayoutObj[UiResult]:
"""Decrease or increase output amount."""
# rust/src/ui/model_tt/layout.rs
def confirm_modify_fee(
*,
title: str,
sign: int,
user_fee_change: str,
total_fee_new: str,
fee_rate_amount: str | None, # ignored
) -> LayoutObj[UiResult]:
"""Decrease or increase transaction fee."""
# rust/src/ui/model_tt/layout.rs
def confirm_fido(
*,

View File

@ -123,6 +123,28 @@ def confirm_homescreen(
"""Confirm homescreen."""
# rust/src/ui/api/firmware_upy.rs
def confirm_modify_fee(
*,
title: str,
sign: int,
user_fee_change: str,
total_fee_new: str,
fee_rate_amount: str | None,
) -> LayoutObj[UiResult]:
"""Decrease or increase transaction fee."""
# rust/src/ui/api/firmware_upy.rs
def confirm_modify_output(
*,
sign: int,
amount_change: str,
amount_new: str,
) -> LayoutObj[UiResult]:
"""Decrease or increase output amount."""
# rust/src/ui/api/firmware_upy.rs
def confirm_reset_device(recovery: bool) -> LayoutObj[UiResult]:
"""Confirm TOS before creating wallet creation or wallet recovery."""

View File

@ -915,7 +915,7 @@ async def confirm_modify_output(
verb_cancel=None,
description=f"{TR.words__address}:",
)
modify_layout = trezorui2.confirm_modify_output(
modify_layout = trezorui_api.confirm_modify_output(
sign=sign,
amount_change=amount_change,
amount_new=amount_new,
@ -947,7 +947,7 @@ def confirm_modify_fee(
total_fee_new: str,
fee_rate_amount: str | None = None,
) -> Awaitable[None]:
fee_layout = trezorui2.confirm_modify_fee(
fee_layout = trezorui_api.confirm_modify_fee(
title=title,
sign=sign,
user_fee_change=user_fee_change,

View File

@ -999,7 +999,7 @@ async def confirm_modify_output(
description=f"{TR.words__address}:",
)
modify_layout = trezorui2.confirm_modify_output(
modify_layout = trezorui_api.confirm_modify_output(
sign=sign,
amount_change=amount_change,
amount_new=amount_new,
@ -1033,7 +1033,7 @@ def confirm_modify_fee(
fee_rate_amount: str | None = None,
) -> Awaitable[None]:
return raise_if_not_confirmed(
trezorui2.confirm_modify_fee(
trezorui_api.confirm_modify_fee(
title=title,
sign=sign,
user_fee_change=user_fee_change,

View File

@ -970,7 +970,7 @@ async def confirm_modify_output(
try:
await interact(
trezorui2.confirm_modify_output(
trezorui_api.confirm_modify_output(
sign=sign,
amount_change=amount_change,
amount_new=amount_new,
@ -993,7 +993,7 @@ def confirm_modify_fee(
total_fee_new: str,
fee_rate_amount: str | None = None,
) -> Awaitable[None]:
fee_layout = trezorui2.confirm_modify_fee(
fee_layout = trezorui_api.confirm_modify_fee(
title=title,
sign=sign,
user_fee_change=user_fee_change,