mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-01 18:30:56 +00:00
refactor(core): model_r confirm_summary
- altcoin_tx_summary removed and replaced with confirm_summary [no changelog]
This commit is contained in:
parent
6e94748e92
commit
af6240b52c
@ -40,7 +40,6 @@ static void _librust_qstrs(void) {
|
|||||||
MP_QSTR_account_info;
|
MP_QSTR_account_info;
|
||||||
MP_QSTR_account_items;
|
MP_QSTR_account_items;
|
||||||
MP_QSTR_account_items_title;
|
MP_QSTR_account_items_title;
|
||||||
MP_QSTR_account_label;
|
|
||||||
MP_QSTR_account_path;
|
MP_QSTR_account_path;
|
||||||
MP_QSTR_accounts;
|
MP_QSTR_accounts;
|
||||||
MP_QSTR_action;
|
MP_QSTR_action;
|
||||||
@ -70,13 +69,11 @@ static void _librust_qstrs(void) {
|
|||||||
MP_QSTR_address_qr;
|
MP_QSTR_address_qr;
|
||||||
MP_QSTR_address_title;
|
MP_QSTR_address_title;
|
||||||
MP_QSTR_allow_cancel;
|
MP_QSTR_allow_cancel;
|
||||||
MP_QSTR_altcoin_tx_summary;
|
|
||||||
MP_QSTR_amount;
|
MP_QSTR_amount;
|
||||||
MP_QSTR_amount_change;
|
MP_QSTR_amount_change;
|
||||||
MP_QSTR_amount_label;
|
MP_QSTR_amount_label;
|
||||||
MP_QSTR_amount_new;
|
MP_QSTR_amount_new;
|
||||||
MP_QSTR_amount_title;
|
MP_QSTR_amount_title;
|
||||||
MP_QSTR_amount_value;
|
|
||||||
MP_QSTR_app_name;
|
MP_QSTR_app_name;
|
||||||
MP_QSTR_area_bytesize;
|
MP_QSTR_area_bytesize;
|
||||||
MP_QSTR_attach_timer_fn;
|
MP_QSTR_attach_timer_fn;
|
||||||
@ -178,7 +175,6 @@ static void _librust_qstrs(void) {
|
|||||||
MP_QSTR_can_go_back;
|
MP_QSTR_can_go_back;
|
||||||
MP_QSTR_cancel;
|
MP_QSTR_cancel;
|
||||||
MP_QSTR_cancel_arrow;
|
MP_QSTR_cancel_arrow;
|
||||||
MP_QSTR_cancel_cross;
|
|
||||||
MP_QSTR_cancel_text;
|
MP_QSTR_cancel_text;
|
||||||
MP_QSTR_case_sensitive;
|
MP_QSTR_case_sensitive;
|
||||||
MP_QSTR_check_homescreen_format;
|
MP_QSTR_check_homescreen_format;
|
||||||
@ -212,7 +208,6 @@ static void _librust_qstrs(void) {
|
|||||||
MP_QSTR_confirm_recovery;
|
MP_QSTR_confirm_recovery;
|
||||||
MP_QSTR_confirm_reset_device;
|
MP_QSTR_confirm_reset_device;
|
||||||
MP_QSTR_confirm_summary;
|
MP_QSTR_confirm_summary;
|
||||||
MP_QSTR_confirm_total;
|
|
||||||
MP_QSTR_confirm_total__fee_rate;
|
MP_QSTR_confirm_total__fee_rate;
|
||||||
MP_QSTR_confirm_total__fee_rate_colon;
|
MP_QSTR_confirm_total__fee_rate_colon;
|
||||||
MP_QSTR_confirm_total__sending_from_account;
|
MP_QSTR_confirm_total__sending_from_account;
|
||||||
@ -247,13 +242,10 @@ static void _librust_qstrs(void) {
|
|||||||
MP_QSTR_extra;
|
MP_QSTR_extra;
|
||||||
MP_QSTR_extra_info;
|
MP_QSTR_extra_info;
|
||||||
MP_QSTR_fee;
|
MP_QSTR_fee;
|
||||||
MP_QSTR_fee_amount;
|
|
||||||
MP_QSTR_fee_info;
|
MP_QSTR_fee_info;
|
||||||
MP_QSTR_fee_items;
|
MP_QSTR_fee_items;
|
||||||
MP_QSTR_fee_label;
|
MP_QSTR_fee_label;
|
||||||
MP_QSTR_fee_rate_amount;
|
MP_QSTR_fee_rate_amount;
|
||||||
MP_QSTR_fee_title;
|
|
||||||
MP_QSTR_fee_value;
|
|
||||||
MP_QSTR_fingerprint;
|
MP_QSTR_fingerprint;
|
||||||
MP_QSTR_firmware_update__title;
|
MP_QSTR_firmware_update__title;
|
||||||
MP_QSTR_firmware_update__title_fingerprint;
|
MP_QSTR_firmware_update__title_fingerprint;
|
||||||
@ -323,7 +315,6 @@ static void _librust_qstrs(void) {
|
|||||||
MP_QSTR_instructions__view_all_data;
|
MP_QSTR_instructions__view_all_data;
|
||||||
MP_QSTR_is_type_of;
|
MP_QSTR_is_type_of;
|
||||||
MP_QSTR_items;
|
MP_QSTR_items;
|
||||||
MP_QSTR_items_title;
|
|
||||||
MP_QSTR_joint__title;
|
MP_QSTR_joint__title;
|
||||||
MP_QSTR_joint__to_the_total_amount;
|
MP_QSTR_joint__to_the_total_amount;
|
||||||
MP_QSTR_joint__you_are_contributing;
|
MP_QSTR_joint__you_are_contributing;
|
||||||
@ -703,7 +694,6 @@ static void _librust_qstrs(void) {
|
|||||||
MP_QSTR_title;
|
MP_QSTR_title;
|
||||||
MP_QSTR_total_amount;
|
MP_QSTR_total_amount;
|
||||||
MP_QSTR_total_fee_new;
|
MP_QSTR_total_fee_new;
|
||||||
MP_QSTR_total_label;
|
|
||||||
MP_QSTR_total_len;
|
MP_QSTR_total_len;
|
||||||
MP_QSTR_touch_event;
|
MP_QSTR_touch_event;
|
||||||
MP_QSTR_trace;
|
MP_QSTR_trace;
|
||||||
|
@ -915,6 +915,15 @@ impl ButtonActions {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Cancelling with left and confirming with middle
|
||||||
|
pub fn cancel_confirm_none() -> Self {
|
||||||
|
Self::new(
|
||||||
|
Some(ButtonAction::Cancel),
|
||||||
|
Some(ButtonAction::Confirm),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/// Cancelling with left, confirming with middle and info with right
|
/// Cancelling with left, confirming with middle and info with right
|
||||||
pub fn cancel_confirm_info() -> Self {
|
pub fn cancel_confirm_info() -> Self {
|
||||||
Self::new(
|
Self::new(
|
||||||
|
@ -45,6 +45,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
ComponentExt, FormattedText, Label, LineBreaking, Never, Timeout,
|
ComponentExt, FormattedText, Label, LineBreaking, Never, Timeout,
|
||||||
},
|
},
|
||||||
|
display::Font,
|
||||||
geometry,
|
geometry,
|
||||||
layout::{
|
layout::{
|
||||||
base::LAYOUT_STATE,
|
base::LAYOUT_STATE,
|
||||||
@ -638,131 +639,109 @@ extern "C" fn new_confirm_output_amount(n_args: usize, args: *const Obj, kwargs:
|
|||||||
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" fn new_confirm_total(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
|
extern "C" fn new_confirm_summary(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
|
||||||
let block = |_args: &[Obj], kwargs: &Map| {
|
let block = |_args: &[Obj], kwargs: &Map| {
|
||||||
let total_amount: TString = kwargs.get(Qstr::MP_QSTR_total_amount)?.try_into()?;
|
let amount: TString = kwargs.get(Qstr::MP_QSTR_amount)?.try_into()?;
|
||||||
let fee_amount: TString = kwargs.get(Qstr::MP_QSTR_fee_amount)?.try_into()?;
|
let amount_label: TString = kwargs.get(Qstr::MP_QSTR_amount_label)?.try_into()?;
|
||||||
let fee_rate_amount: Option<TString> = kwargs
|
let fee: TString = kwargs.get(Qstr::MP_QSTR_fee)?.try_into()?;
|
||||||
.get(Qstr::MP_QSTR_fee_rate_amount)?
|
|
||||||
.try_into_option()?;
|
|
||||||
let account_label: Option<TString> =
|
|
||||||
kwargs.get(Qstr::MP_QSTR_account_label)?.try_into_option()?;
|
|
||||||
let total_label: TString = kwargs.get(Qstr::MP_QSTR_total_label)?.try_into()?;
|
|
||||||
let fee_label: TString = kwargs.get(Qstr::MP_QSTR_fee_label)?.try_into()?;
|
let fee_label: TString = kwargs.get(Qstr::MP_QSTR_fee_label)?.try_into()?;
|
||||||
|
let _title: Option<TString> = kwargs
|
||||||
|
.get(Qstr::MP_QSTR_title)
|
||||||
|
.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())
|
||||||
|
.try_into_option()?;
|
||||||
|
let extra_items: Option<Obj> = kwargs
|
||||||
|
.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()?;
|
||||||
|
|
||||||
|
// collect available info pages
|
||||||
|
let mut info_pages: Vec<(TString, Obj), 2> = Vec::new();
|
||||||
|
if let Some(info) = extra_items {
|
||||||
|
// put extra items first as it's typically used for fee info
|
||||||
|
let extra_title = extra_title.unwrap_or(TR::words__title_information.into());
|
||||||
|
unwrap!(info_pages.push((extra_title, info)));
|
||||||
|
}
|
||||||
|
if let Some(info) = account_items {
|
||||||
|
unwrap!(info_pages.push((TR::confirm_total__title_sending_from.into(), info)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// button layouts and actions
|
||||||
|
let verb_cancel: TString = verb_cancel.unwrap_or(TString::empty());
|
||||||
|
let btns_summary_page = move |has_pages_after: bool| -> (ButtonLayout, ButtonActions) {
|
||||||
|
// if there are no info pages, the right button is not needed
|
||||||
|
// if verb_cancel is "^", the left button is an arrow pointing up
|
||||||
|
let left_btn = Some(ButtonDetails::from_text_possible_icon(verb_cancel));
|
||||||
|
let right_btn = has_pages_after.then(|| {
|
||||||
|
ButtonDetails::text("i".into())
|
||||||
|
.with_fixed_width(theme::BUTTON_ICON_WIDTH)
|
||||||
|
.with_font(Font::NORMAL)
|
||||||
|
});
|
||||||
|
let middle_btn = Some(ButtonDetails::armed_text(TR::buttons__confirm.into()));
|
||||||
|
|
||||||
|
(
|
||||||
|
ButtonLayout::new(left_btn, middle_btn, right_btn),
|
||||||
|
if has_pages_after {
|
||||||
|
ButtonActions::cancel_confirm_next()
|
||||||
|
} else {
|
||||||
|
ButtonActions::cancel_confirm_none()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
};
|
||||||
|
let btns_info_page = |is_last: bool| -> (ButtonLayout, ButtonActions) {
|
||||||
|
// on the last info page, the right button is not needed
|
||||||
|
if is_last {
|
||||||
|
(
|
||||||
|
ButtonLayout::arrow_none_none(),
|
||||||
|
ButtonActions::prev_none_none(),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
(
|
||||||
|
ButtonLayout::arrow_none_arrow(),
|
||||||
|
ButtonActions::prev_none_next(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let total_pages = 1 + info_pages.len();
|
||||||
let get_page = move |page_index| {
|
let get_page = move |page_index| {
|
||||||
match page_index {
|
match page_index {
|
||||||
0 => {
|
0 => {
|
||||||
// Total amount + fee
|
// Total amount + fee
|
||||||
let btn_layout = ButtonLayout::cancel_armed_info(TR::buttons__confirm.into());
|
let (btn_layout, btn_actions) = btns_summary_page(!info_pages.is_empty());
|
||||||
let btn_actions = ButtonActions::cancel_confirm_next();
|
|
||||||
|
|
||||||
let ops = OpTextLayout::new(theme::TEXT_MONO)
|
let ops = OpTextLayout::new(theme::TEXT_MONO)
|
||||||
.text_bold(total_label)
|
.text_bold(amount_label)
|
||||||
.newline()
|
.newline()
|
||||||
.text_mono(total_amount)
|
.text_mono(amount)
|
||||||
.newline()
|
.newline()
|
||||||
.newline()
|
.newline()
|
||||||
.text_bold(fee_label)
|
.text_bold(fee_label)
|
||||||
.newline()
|
.newline()
|
||||||
.text_mono(fee_amount);
|
.text_mono(fee);
|
||||||
|
|
||||||
let formatted = FormattedText::new(ops);
|
let formatted = FormattedText::new(ops);
|
||||||
Page::new(btn_layout, btn_actions, formatted)
|
Page::new(btn_layout, btn_actions, formatted)
|
||||||
}
|
}
|
||||||
1 => {
|
i => {
|
||||||
// Fee rate info
|
// Other info pages as provided
|
||||||
let btn_layout = ButtonLayout::arrow_none_arrow();
|
let (title, info_obj) = &info_pages[i - 1];
|
||||||
let btn_actions = ButtonActions::prev_none_next();
|
let is_last = i == total_pages - 1;
|
||||||
|
let (btn_layout, btn_actions) = btns_info_page(is_last);
|
||||||
let fee_rate_amount = fee_rate_amount.unwrap_or("".into());
|
|
||||||
|
|
||||||
let ops = OpTextLayout::new(theme::TEXT_MONO)
|
|
||||||
.text_bold_upper(TR::confirm_total__title_fee)
|
|
||||||
.newline()
|
|
||||||
.newline()
|
|
||||||
.newline_half()
|
|
||||||
.text_bold(TR::confirm_total__fee_rate_colon)
|
|
||||||
.newline()
|
|
||||||
.text_mono(fee_rate_amount);
|
|
||||||
|
|
||||||
let formatted = FormattedText::new(ops);
|
|
||||||
Page::new(btn_layout, btn_actions, formatted)
|
|
||||||
}
|
|
||||||
2 => {
|
|
||||||
// Wallet and account info
|
|
||||||
let btn_layout = ButtonLayout::arrow_none_none();
|
|
||||||
let btn_actions = ButtonActions::prev_none_none();
|
|
||||||
|
|
||||||
let account_label = account_label.unwrap_or("".into());
|
|
||||||
|
|
||||||
// TODO: include wallet info when available
|
|
||||||
|
|
||||||
let ops = OpTextLayout::new(theme::TEXT_MONO)
|
|
||||||
.text_bold_upper(TR::confirm_total__title_sending_from)
|
|
||||||
.newline()
|
|
||||||
.newline()
|
|
||||||
.newline_half()
|
|
||||||
.text_bold(TR::words__account_colon)
|
|
||||||
.newline()
|
|
||||||
.text_mono(account_label);
|
|
||||||
|
|
||||||
let formatted = FormattedText::new(ops);
|
|
||||||
Page::new(btn_layout, btn_actions, formatted)
|
|
||||||
}
|
|
||||||
_ => unreachable!(),
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let pages = FlowPages::new(get_page, 3);
|
|
||||||
|
|
||||||
let obj = LayoutObj::new(Flow::new(pages))?;
|
|
||||||
Ok(obj.into())
|
|
||||||
};
|
|
||||||
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" fn new_altcoin_tx_summary(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
|
|
||||||
let block = |_args: &[Obj], kwargs: &Map| {
|
|
||||||
let amount_title: TString = kwargs.get(Qstr::MP_QSTR_amount_title)?.try_into()?;
|
|
||||||
let amount_value: TString = kwargs.get(Qstr::MP_QSTR_amount_value)?.try_into()?;
|
|
||||||
let fee_title: TString = kwargs.get(Qstr::MP_QSTR_fee_title)?.try_into()?;
|
|
||||||
let fee_value: TString = kwargs.get(Qstr::MP_QSTR_fee_value)?.try_into()?;
|
|
||||||
let items_title: TString = kwargs.get(Qstr::MP_QSTR_items_title)?.try_into()?;
|
|
||||||
let items: Obj = kwargs.get(Qstr::MP_QSTR_items)?;
|
|
||||||
let cancel_cross: bool = kwargs.get_or(Qstr::MP_QSTR_cancel_cross, false)?;
|
|
||||||
|
|
||||||
let get_page = move |page_index| {
|
|
||||||
match page_index {
|
|
||||||
0 => {
|
|
||||||
// Amount + fee
|
|
||||||
let btn_layout = if cancel_cross {
|
|
||||||
ButtonLayout::cancel_armed_info(TR::buttons__confirm.into())
|
|
||||||
} else {
|
|
||||||
ButtonLayout::up_arrow_armed_info(TR::buttons__confirm.into())
|
|
||||||
};
|
|
||||||
let btn_actions = ButtonActions::cancel_confirm_next();
|
|
||||||
|
|
||||||
let ops = OpTextLayout::new(theme::TEXT_MONO)
|
|
||||||
.text_bold(amount_title)
|
|
||||||
.newline()
|
|
||||||
.text_mono(amount_value)
|
|
||||||
.newline()
|
|
||||||
.newline_half()
|
|
||||||
.text_bold(fee_title)
|
|
||||||
.newline()
|
|
||||||
.text_mono(fee_value);
|
|
||||||
|
|
||||||
let formatted = FormattedText::new(ops);
|
|
||||||
Page::new(btn_layout, btn_actions, formatted)
|
|
||||||
}
|
|
||||||
1 => {
|
|
||||||
// Other information
|
|
||||||
let btn_layout = ButtonLayout::arrow_none_none();
|
|
||||||
let btn_actions = ButtonActions::prev_none_none();
|
|
||||||
|
|
||||||
let mut ops = OpTextLayout::new(theme::TEXT_MONO);
|
let mut ops = OpTextLayout::new(theme::TEXT_MONO);
|
||||||
|
for item in unwrap!(IterBuf::new().try_iterate(*info_obj)) {
|
||||||
for item in unwrap!(IterBuf::new().try_iterate(items)) {
|
|
||||||
let [key, value]: [Obj; 2] = unwrap!(util::iter_into_array(item));
|
let [key, value]: [Obj; 2] = unwrap!(util::iter_into_array(item));
|
||||||
if !ops.is_empty() {
|
if !ops.is_empty() {
|
||||||
// Each key-value pair is on its own page
|
// Each key-value pair is on its own page
|
||||||
@ -776,13 +755,12 @@ extern "C" fn new_altcoin_tx_summary(n_args: usize, args: *const Obj, kwargs: *m
|
|||||||
|
|
||||||
let formatted = FormattedText::new(ops).vertically_centered();
|
let formatted = FormattedText::new(ops).vertically_centered();
|
||||||
Page::new(btn_layout, btn_actions, formatted)
|
Page::new(btn_layout, btn_actions, formatted)
|
||||||
.with_title(items_title)
|
|
||||||
.with_slim_arrows()
|
.with_slim_arrows()
|
||||||
|
.with_title(*title)
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let pages = FlowPages::new(get_page, 2);
|
let pages = FlowPages::new(get_page, total_pages);
|
||||||
|
|
||||||
let obj = LayoutObj::new(Flow::new(pages).with_scrollbar(false))?;
|
let obj = LayoutObj::new(Flow::new(pages).with_scrollbar(false))?;
|
||||||
Ok(obj.into())
|
Ok(obj.into())
|
||||||
@ -1810,30 +1788,20 @@ pub static mp_module_trezorui2: Module = obj_module! {
|
|||||||
/// """Confirm output amount."""
|
/// """Confirm output amount."""
|
||||||
Qstr::MP_QSTR_confirm_output_amount => obj_fn_kw!(0, new_confirm_output_amount).as_obj(),
|
Qstr::MP_QSTR_confirm_output_amount => obj_fn_kw!(0, new_confirm_output_amount).as_obj(),
|
||||||
|
|
||||||
/// def confirm_total(
|
/// def confirm_summary(
|
||||||
/// *,
|
/// *,
|
||||||
/// total_amount: str,
|
/// amount: str,
|
||||||
/// fee_amount: str,
|
/// amount_label: str,
|
||||||
/// fee_rate_amount: str | None,
|
/// fee: str,
|
||||||
/// account_label: str | None,
|
|
||||||
/// total_label: str,
|
|
||||||
/// fee_label: str,
|
/// fee_label: str,
|
||||||
|
/// title: 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]:
|
/// ) -> LayoutObj[UiResult]:
|
||||||
/// """Confirm summary of a transaction."""
|
/// """Confirm summary of a transaction."""
|
||||||
Qstr::MP_QSTR_confirm_total => obj_fn_kw!(0, new_confirm_total).as_obj(),
|
Qstr::MP_QSTR_confirm_summary => obj_fn_kw!(0, new_confirm_summary).as_obj(),
|
||||||
|
|
||||||
/// def altcoin_tx_summary(
|
|
||||||
/// *,
|
|
||||||
/// amount_title: str,
|
|
||||||
/// amount_value: str,
|
|
||||||
/// fee_title: str,
|
|
||||||
/// fee_value: str,
|
|
||||||
/// items_title: str,
|
|
||||||
/// items: Iterable[Tuple[str, str]],
|
|
||||||
/// cancel_cross: bool = False,
|
|
||||||
/// ) -> LayoutObj[UiResult]:
|
|
||||||
/// """Confirm details about altcoin transaction."""
|
|
||||||
Qstr::MP_QSTR_altcoin_tx_summary => obj_fn_kw!(0, new_altcoin_tx_summary).as_obj(),
|
|
||||||
|
|
||||||
/// def tutorial() -> LayoutObj[UiResult]:
|
/// def tutorial() -> LayoutObj[UiResult]:
|
||||||
/// """Show user how to interact with the device."""
|
/// """Show user how to interact with the device."""
|
||||||
|
@ -743,32 +743,21 @@ def confirm_output_amount(
|
|||||||
|
|
||||||
|
|
||||||
# rust/src/ui/model_tr/layout.rs
|
# rust/src/ui/model_tr/layout.rs
|
||||||
def confirm_total(
|
def confirm_summary(
|
||||||
*,
|
*,
|
||||||
total_amount: str,
|
amount: str,
|
||||||
fee_amount: str,
|
amount_label: str,
|
||||||
fee_rate_amount: str | None,
|
fee: str,
|
||||||
account_label: str | None,
|
|
||||||
total_label: str,
|
|
||||||
fee_label: str,
|
fee_label: str,
|
||||||
|
title: 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]:
|
) -> LayoutObj[UiResult]:
|
||||||
"""Confirm summary of a transaction."""
|
"""Confirm summary of a transaction."""
|
||||||
|
|
||||||
|
|
||||||
# rust/src/ui/model_tr/layout.rs
|
|
||||||
def altcoin_tx_summary(
|
|
||||||
*,
|
|
||||||
amount_title: str,
|
|
||||||
amount_value: str,
|
|
||||||
fee_title: str,
|
|
||||||
fee_value: str,
|
|
||||||
items_title: str,
|
|
||||||
items: Iterable[Tuple[str, str]],
|
|
||||||
cancel_cross: bool = False,
|
|
||||||
) -> LayoutObj[UiResult]:
|
|
||||||
"""Confirm details about altcoin transaction."""
|
|
||||||
|
|
||||||
|
|
||||||
# rust/src/ui/model_tr/layout.rs
|
# rust/src/ui/model_tr/layout.rs
|
||||||
def tutorial() -> LayoutObj[UiResult]:
|
def tutorial() -> LayoutObj[UiResult]:
|
||||||
"""Show user how to interact with the device."""
|
"""Show user how to interact with the device."""
|
||||||
|
@ -814,15 +814,23 @@ def confirm_total(
|
|||||||
) -> Awaitable[None]:
|
) -> Awaitable[None]:
|
||||||
total_label = total_label or f"{TR.send__total_amount}:" # def_arg
|
total_label = total_label or f"{TR.send__total_amount}:" # def_arg
|
||||||
fee_label = fee_label or TR.send__including_fee # def_arg
|
fee_label = fee_label or TR.send__including_fee # def_arg
|
||||||
return interact(
|
|
||||||
# TODO: resolve these differences in TT's and TR's confirm_total
|
fee_info_items = []
|
||||||
trezorui2.confirm_total( # type: ignore [Arguments missing]
|
if fee_rate_amount:
|
||||||
total_amount=total_amount, # type: ignore [No parameter named]
|
fee_info_items.append((TR.confirm_total__fee_rate_colon, fee_rate_amount))
|
||||||
fee_amount=fee_amount, # type: ignore [No parameter named]
|
account_info_items = []
|
||||||
fee_rate_amount=fee_rate_amount, # type: ignore [No parameter named]
|
if source_account:
|
||||||
account_label=source_account, # type: ignore [No parameter named]
|
account_info_items.append((TR.words__account_colon, source_account))
|
||||||
total_label=total_label, # type: ignore [No parameter named]
|
|
||||||
fee_label=fee_label, # type: ignore [No parameter named]
|
return raise_if_not_confirmed(
|
||||||
|
trezorui2.confirm_summary(
|
||||||
|
amount=total_amount,
|
||||||
|
amount_label=total_label,
|
||||||
|
fee=fee_amount,
|
||||||
|
fee_label=fee_label,
|
||||||
|
account_items=account_info_items or None,
|
||||||
|
extra_items=fee_info_items or None,
|
||||||
|
extra_title=TR.confirm_total__title_fee,
|
||||||
),
|
),
|
||||||
br_name,
|
br_name,
|
||||||
br_code,
|
br_code,
|
||||||
@ -871,14 +879,13 @@ if not utils.BITCOIN_ONLY:
|
|||||||
amount_title = f"{TR.words__amount}:"
|
amount_title = f"{TR.words__amount}:"
|
||||||
amount_value = total_amount
|
amount_value = total_amount
|
||||||
await raise_if_not_confirmed(
|
await raise_if_not_confirmed(
|
||||||
trezorui2.altcoin_tx_summary(
|
trezorui2.confirm_summary(
|
||||||
amount_title=amount_title,
|
amount=amount_value,
|
||||||
amount_value=amount_value,
|
amount_label=amount_title,
|
||||||
fee_title=f"{TR.send__maximum_fee}:",
|
fee=maximum_fee,
|
||||||
fee_value=maximum_fee,
|
fee_label=f"{TR.send__maximum_fee}:",
|
||||||
items_title=TR.confirm_total__title_fee,
|
extra_items=[(f"{k}:", v) for (k, v) in info_items],
|
||||||
items=[(f"{k}:", v) for (k, v) in info_items],
|
extra_title=TR.confirm_total__title_fee,
|
||||||
cancel_cross=True,
|
|
||||||
),
|
),
|
||||||
br_name=br_name,
|
br_name=br_name,
|
||||||
br_code=br_code,
|
br_code=br_code,
|
||||||
@ -898,14 +905,12 @@ if not utils.BITCOIN_ONLY:
|
|||||||
) # def_arg
|
) # def_arg
|
||||||
fee_title = fee_title or TR.words__fee # def_arg
|
fee_title = fee_title or TR.words__fee # def_arg
|
||||||
return raise_if_not_confirmed(
|
return raise_if_not_confirmed(
|
||||||
trezorui2.altcoin_tx_summary(
|
trezorui2.confirm_summary(
|
||||||
amount_title=amount_title,
|
amount=amount,
|
||||||
amount_value=amount,
|
amount_label=amount_title,
|
||||||
fee_title=fee_title,
|
fee=fee,
|
||||||
fee_value=fee,
|
fee_label=fee_title,
|
||||||
items_title=TR.confirm_total__title_fee,
|
extra_items=items, # TODO: extra_title here?
|
||||||
items=items,
|
|
||||||
cancel_cross=True,
|
|
||||||
),
|
),
|
||||||
br_name=br_name,
|
br_name=br_name,
|
||||||
br_code=br_code,
|
br_code=br_code,
|
||||||
@ -922,14 +927,12 @@ if not utils.BITCOIN_ONLY:
|
|||||||
fee_title = TR.send__including_fee
|
fee_title = TR.send__including_fee
|
||||||
|
|
||||||
return raise_if_not_confirmed(
|
return raise_if_not_confirmed(
|
||||||
trezorui2.altcoin_tx_summary(
|
trezorui2.confirm_summary(
|
||||||
amount_title=amount_title,
|
amount=amount,
|
||||||
amount_value=amount,
|
amount_label=amount_title,
|
||||||
fee_title=fee_title,
|
fee=fee,
|
||||||
fee_value=fee,
|
fee_label=fee_title,
|
||||||
items_title=TR.words__title_information,
|
extra_items=items,
|
||||||
items=items,
|
|
||||||
cancel_cross=True,
|
|
||||||
),
|
),
|
||||||
br_name="confirm_cardano_tx",
|
br_name="confirm_cardano_tx",
|
||||||
br_code=ButtonRequestType.SignTx,
|
br_code=ButtonRequestType.SignTx,
|
||||||
@ -947,13 +950,13 @@ if not utils.BITCOIN_ONLY:
|
|||||||
br_code: ButtonRequestType = ButtonRequestType.SignTx,
|
br_code: ButtonRequestType = ButtonRequestType.SignTx,
|
||||||
chunkify: bool = False,
|
chunkify: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
summary_layout = trezorui2.altcoin_tx_summary(
|
summary_layout = trezorui2.confirm_summary(
|
||||||
amount_title=f"{TR.words__amount}:",
|
amount=total_amount,
|
||||||
amount_value=total_amount,
|
amount_label=f"{TR.words__amount}:",
|
||||||
fee_title=f"{TR.send__maximum_fee}:",
|
fee=maximum_fee,
|
||||||
fee_value=maximum_fee,
|
fee_label=f"{TR.send__maximum_fee}:",
|
||||||
items_title=TR.confirm_total__title_fee,
|
extra_items=[(f"{k}:", v) for (k, v) in fee_info_items],
|
||||||
items=[(f"{k}:", v) for (k, v) in fee_info_items],
|
extra_title=TR.confirm_total__title_fee,
|
||||||
)
|
)
|
||||||
|
|
||||||
if not is_contract_interaction:
|
if not is_contract_interaction:
|
||||||
|
@ -835,10 +835,10 @@ def sign_tx_go_to_info_tr(
|
|||||||
yield
|
yield
|
||||||
|
|
||||||
layout = client.debug.press_right()
|
layout = client.debug.press_right()
|
||||||
screen_texts.append(layout.text_content())
|
screen_texts.append(layout.visible_screen())
|
||||||
|
|
||||||
layout = client.debug.press_right()
|
layout = client.debug.press_right()
|
||||||
screen_texts.append(layout.text_content())
|
screen_texts.append(layout.visible_screen())
|
||||||
|
|
||||||
client.debug.press_left()
|
client.debug.press_left()
|
||||||
client.debug.press_left()
|
client.debug.press_left()
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user