1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-04 13:38:28 +00:00

fixup! refactor(core): model_t confirm_summary

This commit is contained in:
obrusvit 2024-12-04 00:31:51 +01:00
parent c3ac40889f
commit 83afdc4e32
3 changed files with 9 additions and 15 deletions

View File

@ -773,10 +773,6 @@ extern "C" fn new_confirm_summary(n_args: usize, args: *const Obj, kwargs: *mut
.get(Qstr::MP_QSTR_title)
.unwrap_or_else(|_| Obj::const_none())
.try_into_option()?;
let fee_items: Option<Obj> = kwargs
.get(Qstr::MP_QSTR_fee_items)
.unwrap_or_else(|_| Obj::const_none())
.try_into_option()?;
let account_items: Option<Obj> = kwargs
.get(Qstr::MP_QSTR_account_items)
.unwrap_or_else(|_| Obj::const_none())
@ -785,13 +781,16 @@ extern "C" fn new_confirm_summary(n_args: usize, args: *const Obj, kwargs: *mut
.get(Qstr::MP_QSTR_extra_items)
.unwrap_or_else(|_| Obj::const_none())
.try_into_option()?;
let _extra_title: Option<TString> = kwargs
.get(Qstr::MP_QSTR_extra_title)
.unwrap_or_else(|_| Obj::const_none())
.try_into_option()?;
let verb_cancel: Option<TString<'static>> = kwargs
.get(Qstr::MP_QSTR_verb_cancel)
.unwrap_or_else(|_| Obj::const_none())
.try_into_option()?;
let info_button: bool =
fee_items.is_some() || account_items.is_some() || extra_items.is_some();
let info_button: bool = account_items.is_some() || extra_items.is_some();
let paragraphs = ParagraphVecShort::from_iter([
Paragraph::new(&theme::TEXT_NORMAL, amount_label).no_break(),
Paragraph::new(&theme::TEXT_MONO, amount),
@ -1899,9 +1898,9 @@ pub static mp_module_trezorui2: Module = obj_module! {
/// fee: str,
/// fee_label: str,
/// title: str | None = None,
/// fee_items: Iterable[tuple[str, str]] | None = None,
/// account_items: Iterable[tuple[str, str]] | None = None,
/// extra_items: Iterable[tuple[str, str]] | None = None,
/// extra_title: str | None = None,
/// verb_cancel: str | None = None,
/// ) -> LayoutObj[UiResult]:
/// """Confirm summary of a transaction."""

View File

@ -1287,9 +1287,9 @@ def confirm_summary(
fee: str,
fee_label: str,
title: str | None = None,
fee_items: Iterable[tuple[str, str]] | None = None,
account_items: Iterable[tuple[str, str]] | None = None,
extra_items: Iterable[tuple[str, str]] | None = None,
extra_title: str | None = None,
verb_cancel: str | None = None,
) -> LayoutObj[UiResult]:
"""Confirm summary of a transaction."""

View File

@ -727,14 +727,13 @@ def confirm_total(
fee_label = fee_label or TR.send__including_fee # def_arg
account_info_items = []
fee_info_items = []
extra_info_items = []
if source_account:
account_info_items.append(
(TR.confirm_total__sending_from_account, source_account)
)
if fee_rate_amount:
fee_info_items.append((f"{TR.confirm_total__fee_rate}:", fee_rate_amount))
extra_info_items.append((f"{TR.confirm_total__fee_rate}:", fee_rate_amount))
return _confirm_summary(
total_amount,
@ -742,9 +741,9 @@ def confirm_total(
fee_amount,
fee_label,
title=title,
fee_items=fee_info_items,
account_items=account_info_items,
extra_items=extra_info_items,
extra_title=TR.words__title_information,
br_name=br_name,
br_code=br_code,
)
@ -756,7 +755,6 @@ def _confirm_summary(
fee: str,
fee_label: str,
title: str | None = None,
fee_items: Iterable[tuple[str, str]] | None = None,
account_items: Iterable[tuple[str, str]] | None = None,
extra_items: Iterable[tuple[str, str]] | None = None,
extra_title: str | None = None,
@ -771,15 +769,12 @@ def _confirm_summary(
fee=fee,
fee_label=fee_label,
title=title,
fee_items=fee_items or None,
account_items=account_items or None,
extra_items=extra_items or None,
)
# TODO: use `_info` params directly in this^ layout instead of using `with_info`
info_items = []
if fee_items:
info_items.extend(fee_items)
if account_items:
info_items.extend(account_items)
if extra_items: