1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-16 04:29:08 +00:00

rust: support fee_rate_amount in confirm_modify_fee

This commit is contained in:
grdddj 2023-03-30 18:39:45 +02:00
parent d435142d3c
commit ab5f7bdc49
2 changed files with 18 additions and 6 deletions

View File

@ -119,4 +119,5 @@ static void _librust_qstrs(void) {
MP_QSTR_skip_first_paint; MP_QSTR_skip_first_paint;
MP_QSTR_wrong_pin; MP_QSTR_wrong_pin;
MP_QSTR_xpubs; MP_QSTR_xpubs;
MP_QSTR_fee_rate_amount;
} }

View File

@ -862,6 +862,9 @@ extern "C" fn new_confirm_modify_fee(n_args: usize, args: *const Obj, kwargs: *m
let sign: i32 = kwargs.get(Qstr::MP_QSTR_sign)?.try_into()?; let sign: i32 = kwargs.get(Qstr::MP_QSTR_sign)?.try_into()?;
let user_fee_change: StrBuffer = kwargs.get(Qstr::MP_QSTR_user_fee_change)?.try_into()?; let user_fee_change: StrBuffer = kwargs.get(Qstr::MP_QSTR_user_fee_change)?.try_into()?;
let total_fee_new: StrBuffer = kwargs.get(Qstr::MP_QSTR_total_fee_new)?.try_into()?; let total_fee_new: StrBuffer = kwargs.get(Qstr::MP_QSTR_total_fee_new)?.try_into()?;
let fee_rate_amount: Option<StrBuffer> = kwargs
.get(Qstr::MP_QSTR_fee_rate_amount)?
.try_into_option()?;
let (description, change) = match sign { let (description, change) = match sign {
s if s < 0 => ("Decrease your fee by:", user_fee_change), s if s < 0 => ("Decrease your fee by:", user_fee_change),
@ -869,12 +872,19 @@ extern "C" fn new_confirm_modify_fee(n_args: usize, args: *const Obj, kwargs: *m
_ => ("Your fee did not change.", StrBuffer::empty()), _ => ("Your fee did not change.", StrBuffer::empty()),
}; };
let paragraphs = Paragraphs::new([ let mut paragraphs_vec = ParagraphVecShort::new();
Paragraph::new(&theme::TEXT_NORMAL, description.into()), paragraphs_vec
Paragraph::new(&theme::TEXT_MONO, change), .add(Paragraph::new(&theme::TEXT_BOLD, description.into()))
Paragraph::new(&theme::TEXT_NORMAL, "\nTransaction fee:".into()), .add(Paragraph::new(&theme::TEXT_MONO, change))
Paragraph::new(&theme::TEXT_MONO, total_fee_new), .add(Paragraph::new(&theme::TEXT_BOLD, "Transaction fee:".into()))
]); .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, "Fee rate:".into()))
.add(Paragraph::new(&theme::TEXT_MONO, fee_rate_amount));
}
let paragraphs = paragraphs_vec.into_paragraphs();
let buttons = Button::cancel_confirm( let buttons = Button::cancel_confirm(
Button::with_icon(Icon::new(theme::ICON_CANCEL)), Button::with_icon(Icon::new(theme::ICON_CANCEL)),
@ -1744,6 +1754,7 @@ pub static mp_module_trezorui2: Module = obj_module! {
/// sign: int, /// sign: int,
/// user_fee_change: str, /// user_fee_change: str,
/// total_fee_new: str, /// total_fee_new: str,
/// fee_rate_amount: str | None,
/// ) -> object: /// ) -> object:
/// """Decrease or increase transaction fee.""" /// """Decrease or increase transaction fee."""
Qstr::MP_QSTR_confirm_modify_fee => obj_fn_kw!(0, new_confirm_modify_fee).as_obj(), Qstr::MP_QSTR_confirm_modify_fee => obj_fn_kw!(0, new_confirm_modify_fee).as_obj(),