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

fixup! chore(core): adapt wipe pin flow

This commit is contained in:
Lukas Bielesch 2024-12-19 17:52:26 +01:00
parent 3d7720e660
commit 5e9dc98b90
8 changed files with 29 additions and 97 deletions

View File

@ -244,7 +244,6 @@ static void _librust_qstrs(void) {
MP_QSTR_firmware_update__title_fingerprint; MP_QSTR_firmware_update__title_fingerprint;
MP_QSTR_flow_confirm_output; MP_QSTR_flow_confirm_output;
MP_QSTR_flow_confirm_set_new_pin; MP_QSTR_flow_confirm_set_new_pin;
MP_QSTR_flow_confirm_set_new_wipe_code;
MP_QSTR_flow_get_address; MP_QSTR_flow_get_address;
MP_QSTR_get_language; MP_QSTR_get_language;
MP_QSTR_get_transition_out; MP_QSTR_get_transition_out;
@ -301,6 +300,7 @@ static void _librust_qstrs(void) {
MP_QSTR_instructions__tap_to_start; MP_QSTR_instructions__tap_to_start;
MP_QSTR_instructions__view_all_data; MP_QSTR_instructions__view_all_data;
MP_QSTR_is_type_of; MP_QSTR_is_type_of;
MP_QSTR_is_wipe_code;
MP_QSTR_items; MP_QSTR_items;
MP_QSTR_joint__title; MP_QSTR_joint__title;
MP_QSTR_joint__to_the_total_amount; MP_QSTR_joint__to_the_total_amount;

View File

@ -533,24 +533,10 @@ extern "C" fn new_flow_confirm_set_new_pin(
let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?; let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?;
let description: TString = kwargs.get(Qstr::MP_QSTR_description)?.try_into()?; let description: TString = kwargs.get(Qstr::MP_QSTR_description)?.try_into()?;
let cancel_title: TString = kwargs.get(Qstr::MP_QSTR_cancel_title)?.try_into()?; let cancel_title: TString = kwargs.get(Qstr::MP_QSTR_cancel_title)?.try_into()?;
let is_wipe_code: bool = kwargs.get(Qstr::MP_QSTR_is_wipe_code)?.try_into()?;
let layout = ModelUI::flow_confirm_set_new_pin(title, description, cancel_title)?; let layout =
Ok(LayoutObj::new_root(layout)?.into()) ModelUI::flow_confirm_set_new_pin(title, description, cancel_title, is_wipe_code)?;
};
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
}
extern "C" fn new_flow_confirm_set_new_wipe_code(
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 description: TString = kwargs.get(Qstr::MP_QSTR_description)?.try_into()?;
let cancel_title: TString = kwargs.get(Qstr::MP_QSTR_cancel_title)?.try_into()?;
let layout = ModelUI::flow_confirm_set_new_wipe_code(title, description, cancel_title)?;
Ok(LayoutObj::new_root(layout)?.into()) Ok(LayoutObj::new_root(layout)?.into())
}; };
unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) }
@ -1400,19 +1386,11 @@ pub static mp_module_trezorui_api: Module = obj_module! {
/// title: str, /// title: str,
/// description: str, /// description: str,
/// cancel_title: str, /// cancel_title: str,
/// is_wipe_code: bool,
/// ) -> LayoutObj[UiResult]: /// ) -> LayoutObj[UiResult]:
/// """Confirm new PIN setup with an option to cancel action.""" /// """Confirm new PIN setup with an option to cancel action."""
Qstr::MP_QSTR_flow_confirm_set_new_pin => obj_fn_kw!(0, new_flow_confirm_set_new_pin).as_obj(), Qstr::MP_QSTR_flow_confirm_set_new_pin => obj_fn_kw!(0, new_flow_confirm_set_new_pin).as_obj(),
/// def flow_confirm_set_new_wipe_code(
/// *,
/// title: str,
/// description: str,
/// cancel_title: str,
/// ) -> LayoutObj[UiResult]:
/// """Confirm new wipe code setup with an option to cancel action."""
Qstr::MP_QSTR_flow_confirm_set_new_wipe_code => obj_fn_kw!(0, new_flow_confirm_set_new_wipe_code).as_obj(),
/// def flow_get_address( /// def flow_get_address(
/// *, /// *,
/// address: str | bytes, /// address: str | bytes,

View File

@ -632,21 +632,17 @@ impl FirmwareUI for UIMercury {
title: TString<'static>, title: TString<'static>,
description: TString<'static>, description: TString<'static>,
cancel_title: TString<'static>, cancel_title: TString<'static>,
is_wipe_code: bool,
) -> Result<impl LayoutMaybeTrace, Error> { ) -> Result<impl LayoutMaybeTrace, Error> {
let flow = flow::confirm_set_new_pin::new_set_new_pin(title, description, cancel_title)?; let flow = if is_wipe_code {
Ok(flow) flow::confirm_set_new_wipe_code::new_set_new_wipe_code(
} title,
description,
fn flow_confirm_set_new_wipe_code( cancel_title,
title: TString<'static>, )?
description: TString<'static>, } else {
cancel_title: TString<'static>, flow::confirm_set_new_pin::new_set_new_pin(title, description, cancel_title)?
) -> Result<impl LayoutMaybeTrace, Error> { };
let flow = flow::confirm_set_new_wipe_code::new_set_new_wipe_code(
title,
description,
cancel_title,
)?;
Ok(flow) Ok(flow)
} }

View File

@ -725,22 +725,13 @@ impl FirmwareUI for UIModelTR {
_title: TString<'static>, _title: TString<'static>,
_description: TString<'static>, _description: TString<'static>,
_cancel_title: TString<'static>, _cancel_title: TString<'static>,
_is_wipe_code: bool,
) -> Result<impl LayoutMaybeTrace, Error> { ) -> Result<impl LayoutMaybeTrace, Error> {
Err::<RootComponent<Empty, ModelUI>, Error>(Error::ValueError( Err::<RootComponent<Empty, ModelUI>, Error>(Error::ValueError(
c"flow_confirm_set_new_pin not supported", c"flow_confirm_set_new_pin not supported",
)) ))
} }
fn flow_confirm_set_new_wipe_code(
_title: TString<'static>,
_description: TString<'static>,
_cancel_title: TString<'static>,
) -> Result<impl LayoutMaybeTrace, Error> {
Err::<RootComponent<Empty, ModelUI>, Error>(Error::ValueError(
c"flow_confirm_set_new_wipe_code not supported",
))
}
fn flow_get_address( fn flow_get_address(
_address: Obj, _address: Obj,
_title: TString<'static>, _title: TString<'static>,

View File

@ -576,22 +576,13 @@ impl FirmwareUI for UIModelTT {
_title: TString<'static>, _title: TString<'static>,
_description: TString<'static>, _description: TString<'static>,
_cancel_title: TString<'static>, _cancel_title: TString<'static>,
_is_wipe_code: bool,
) -> Result<impl LayoutMaybeTrace, Error> { ) -> Result<impl LayoutMaybeTrace, Error> {
Err::<RootComponent<Empty, ModelUI>, Error>(Error::ValueError( Err::<RootComponent<Empty, ModelUI>, Error>(Error::ValueError(
c"flow_confirm_set_new_pin not supported", c"flow_confirm_set_new_pin not supported",
)) ))
} }
fn flow_confirm_set_new_wipe_code(
_title: TString<'static>,
_description: TString<'static>,
_cancel_title: TString<'static>,
) -> Result<impl LayoutMaybeTrace, Error> {
Err::<RootComponent<Empty, ModelUI>, Error>(Error::ValueError(
c"flow_confirm_set_new_wipe_code not supported",
))
}
fn flow_get_address( fn flow_get_address(
_address: Obj, _address: Obj,
_title: TString<'static>, _title: TString<'static>,

View File

@ -198,12 +198,7 @@ pub trait FirmwareUI {
title: TString<'static>, title: TString<'static>,
description: TString<'static>, description: TString<'static>,
cancel_title: TString<'static>, cancel_title: TString<'static>,
) -> Result<impl LayoutMaybeTrace, Error>; is_wipe_code: bool,
fn flow_confirm_set_new_wipe_code(
title: TString<'static>,
description: TString<'static>,
cancel_title: TString<'static>,
) -> Result<impl LayoutMaybeTrace, Error>; ) -> Result<impl LayoutMaybeTrace, Error>;
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]

View File

@ -341,20 +341,11 @@ def flow_confirm_set_new_pin(
title: str, title: str,
description: str, description: str,
cancel_title: str, cancel_title: str,
is_wipe_code: bool,
) -> LayoutObj[UiResult]: ) -> LayoutObj[UiResult]:
"""Confirm new PIN setup with an option to cancel action.""" """Confirm new PIN setup with an option to cancel action."""
# rust/src/ui/api/firmware_micropython.rs
def flow_confirm_set_new_wipe_code(
*,
title: str,
description: str,
cancel_title: str,
) -> LayoutObj[UiResult]:
"""Confirm new wipe code setup with an option to cancel action."""
# rust/src/ui/api/firmware_micropython.rs # rust/src/ui/api/firmware_micropython.rs
def flow_get_address( def flow_get_address(
*, *,

View File

@ -1211,26 +1211,16 @@ def confirm_set_new_pin(
is_wipe_code: bool = False, is_wipe_code: bool = False,
br_code: ButtonRequestType = BR_CODE_OTHER, br_code: ButtonRequestType = BR_CODE_OTHER,
) -> Awaitable[None]: ) -> Awaitable[None]:
if is_wipe_code: return raise_if_not_confirmed(
return raise_if_not_confirmed( trezorui_api.flow_confirm_set_new_pin(
trezorui_api.flow_confirm_set_new_wipe_code( title=title,
title=title, description=description + "\n" + information,
description=description + "\n" + information, cancel_title=cancel_title,
cancel_title=cancel_title, is_wipe_code=is_wipe_code,
), ),
br_name, br_name,
br_code, br_code,
) )
else:
return raise_if_not_confirmed(
trezorui_api.flow_confirm_set_new_pin(
title=title,
description=description + "\n" + information,
cancel_title=cancel_title,
),
br_name,
br_code,
)
def confirm_firmware_update(description: str, fingerprint: str) -> Awaitable[None]: def confirm_firmware_update(description: str, fingerprint: str) -> Awaitable[None]: