diff --git a/core/embed/rust/src/ui/api/firmware_upy.rs b/core/embed/rust/src/ui/api/firmware_upy.rs index 6cfda6ae5c..5049869126 100644 --- a/core/embed/rust/src/ui/api/firmware_upy.rs +++ b/core/embed/rust/src/ui/api/firmware_upy.rs @@ -527,6 +527,30 @@ extern "C" fn new_set_brightness(n_args: usize, args: *const Obj, kwargs: *mut M unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } } +extern "C" fn new_show_address_details(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { + let block = move |_args: &[Obj], kwargs: &Map| { + let qr_title: TString<'static> = kwargs.get(Qstr::MP_QSTR_qr_title)?.try_into()?; + let details_title: TString = kwargs.get(Qstr::MP_QSTR_details_title)?.try_into()?; + let address: TString = kwargs.get(Qstr::MP_QSTR_address)?.try_into()?; + let case_sensitive: bool = kwargs.get(Qstr::MP_QSTR_case_sensitive)?.try_into()?; + let account: Option = kwargs.get(Qstr::MP_QSTR_account)?.try_into_option()?; + let path: Option = kwargs.get(Qstr::MP_QSTR_path)?.try_into_option()?; + let xpubs: Obj = kwargs.get(Qstr::MP_QSTR_xpubs)?; + + let layout = ModelUI::show_address_details( + qr_title, + address, + case_sensitive, + details_title, + account, + path, + xpubs, + )?; + Ok(LayoutObj::new_root(layout)?.into()) + }; + unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } +} + extern "C" fn new_show_checklist(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()?; @@ -1202,6 +1226,19 @@ pub static mp_module_trezorui_api: Module = obj_module! { /// """Show the brightness configuration dialog.""" Qstr::MP_QSTR_set_brightness => obj_fn_kw!(0, new_set_brightness).as_obj(), + /// def show_address_details( + /// *, + /// qr_title: str, + /// address: str, + /// case_sensitive: bool, + /// details_title: str, + /// account: str | None, + /// path: str | None, + /// xpubs: list[tuple[str, str]], + /// ) -> LayoutObj[UiResult]: + /// """Show address details - QR code, account, path, cosigner xpubs.""" + Qstr::MP_QSTR_show_address_details => obj_fn_kw!(0, new_show_address_details).as_obj(), + /// def show_checklist( /// *, /// title: str, diff --git a/core/embed/rust/src/ui/model_mercury/ui_features_fw.rs b/core/embed/rust/src/ui/model_mercury/ui_features_fw.rs index 2ee5225f08..9cc2817c0f 100644 --- a/core/embed/rust/src/ui/model_mercury/ui_features_fw.rs +++ b/core/embed/rust/src/ui/model_mercury/ui_features_fw.rs @@ -572,6 +572,20 @@ impl UIFeaturesFirmware for ModelMercuryFeatures { Ok(flow) } + fn show_address_details( + _qr_title: TString<'static>, + _address: TString<'static>, + _case_sensitive: bool, + _details_title: TString<'static>, + _account: Option>, + _path: Option>, + _xpubs: Obj, + ) -> Result { + Err::, Error>(Error::ValueError( + c"show_address_details not implemented", + )) + } + fn show_checklist( title: TString<'static>, button: TString<'static>, diff --git a/core/embed/rust/src/ui/model_tr/layout.rs b/core/embed/rust/src/ui/model_tr/layout.rs index ed9c469b65..ed0d6fa00d 100644 --- a/core/embed/rust/src/ui/model_tr/layout.rs +++ b/core/embed/rust/src/ui/model_tr/layout.rs @@ -270,28 +270,6 @@ fn content_in_button_page( Ok(obj.into()) } -extern "C" fn new_show_address_details(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { - let block = move |_args: &[Obj], kwargs: &Map| { - let address: TString = kwargs.get(Qstr::MP_QSTR_address)?.try_into()?; - let case_sensitive: bool = kwargs.get(Qstr::MP_QSTR_case_sensitive)?.try_into()?; - let account: Option = kwargs.get(Qstr::MP_QSTR_account)?.try_into_option()?; - let path: Option = kwargs.get(Qstr::MP_QSTR_path)?.try_into_option()?; - - let xpubs: Obj = kwargs.get(Qstr::MP_QSTR_xpubs)?; - - let mut ad = AddressDetails::new(address, case_sensitive, account, path)?; - - for i in IterBuf::new().try_iterate(xpubs)? { - let [xtitle, text]: [TString; 2] = util::iter_into_array(i)?; - ad.add_xpub(xtitle, text)?; - } - - let obj = LayoutObj::new(ad)?; - Ok(obj.into()) - }; - unsafe { util::try_with_args_and_kwargs(n_args, args, kwargs, block) } -} - extern "C" fn new_confirm_joint_total(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { let block = move |_args: &[Obj], kwargs: &Map| { let spending_amount: TString = kwargs.get(Qstr::MP_QSTR_spending_amount)?.try_into()?; @@ -591,17 +569,6 @@ pub static mp_module_trezorui2: Module = obj_module! { /// Qstr::MP_QSTR___name__ => Qstr::MP_QSTR_trezorui2.to_obj(), - /// def show_address_details( - /// *, - /// address: str, - /// case_sensitive: bool, - /// account: str | None, - /// path: str | None, - /// xpubs: list[tuple[str, str]], - /// ) -> LayoutObj[UiResult]: - /// """Show address details - QR code, account, path, cosigner xpubs.""" - Qstr::MP_QSTR_show_address_details => obj_fn_kw!(0, new_show_address_details).as_obj(), - /// def confirm_joint_total( /// *, /// spending_amount: str, diff --git a/core/embed/rust/src/ui/model_tr/ui_features_fw.rs b/core/embed/rust/src/ui/model_tr/ui_features_fw.rs index 8f30278a9b..963fe772d0 100644 --- a/core/embed/rust/src/ui/model_tr/ui_features_fw.rs +++ b/core/embed/rust/src/ui/model_tr/ui_features_fw.rs @@ -35,9 +35,9 @@ use crate::{ use super::{ component::{ - ButtonDetails, ButtonPage, CoinJoinProgress, ConfirmHomescreen, Flow, FlowPages, Frame, - Homescreen, Lockscreen, NumberInput, PassphraseEntry, PinEntry, Progress, ScrollableFrame, - ShareWords, ShowMore, SimpleChoice, WordlistEntry, WordlistType, + AddressDetails, ButtonDetails, ButtonPage, CoinJoinProgress, ConfirmHomescreen, Flow, + FlowPages, Frame, Homescreen, Lockscreen, NumberInput, PassphraseEntry, PinEntry, Progress, + ScrollableFrame, ShareWords, ShowMore, SimpleChoice, WordlistEntry, WordlistType, }, theme, ModelTRFeatures, }; @@ -692,6 +692,26 @@ impl UIFeaturesFirmware for ModelTRFeatures { )) } + fn show_address_details( + _qr_title: TString<'static>, + address: TString<'static>, + case_sensitive: bool, + _details_title: TString<'static>, + account: Option>, + path: Option>, + xpubs: Obj, + ) -> Result { + let mut ad = AddressDetails::new(address, case_sensitive, account, path)?; + + for i in IterBuf::new().try_iterate(xpubs)? { + let [xtitle, text]: [TString; 2] = util::iter_into_array(i)?; + ad.add_xpub(xtitle, text)?; + } + + let layout = RootComponent::new(ad); + Ok(layout) + } + fn show_checklist( title: TString<'static>, button: TString<'static>, diff --git a/core/embed/rust/src/ui/model_tt/layout.rs b/core/embed/rust/src/ui/model_tt/layout.rs index a3bb33888f..6e0330f485 100644 --- a/core/embed/rust/src/ui/model_tt/layout.rs +++ b/core/embed/rust/src/ui/model_tt/layout.rs @@ -317,38 +317,6 @@ impl ComponentMsgObj for super::component::bl_confirm::Confirm<'_> { } } -extern "C" fn new_show_address_details(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { - let block = move |_args: &[Obj], kwargs: &Map| { - let qr_title: TString<'static> = kwargs.get(Qstr::MP_QSTR_qr_title)?.try_into()?; - let details_title: TString = kwargs.get(Qstr::MP_QSTR_details_title)?.try_into()?; - let address: TString = kwargs.get(Qstr::MP_QSTR_address)?.try_into()?; - let case_sensitive: bool = kwargs.get(Qstr::MP_QSTR_case_sensitive)?.try_into()?; - let account: Option = kwargs.get(Qstr::MP_QSTR_account)?.try_into_option()?; - let path: Option = kwargs.get(Qstr::MP_QSTR_path)?.try_into_option()?; - - let xpubs: Obj = kwargs.get(Qstr::MP_QSTR_xpubs)?; - - let mut ad = AddressDetails::new( - qr_title, - address, - case_sensitive, - details_title, - account, - path, - )?; - - for i in IterBuf::new().try_iterate(xpubs)? { - let [xtitle, text]: [TString; 2] = util::iter_into_array(i)?; - ad.add_xpub(xtitle, text)?; - } - - let obj = - LayoutObj::new(SimplePage::horizontal(ad, theme::BG).with_swipe_right_to_go_back())?; - Ok(obj.into()) - }; - 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 { let block = move |_args: &[Obj], kwargs: &Map| { let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?; @@ -386,19 +354,6 @@ pub static mp_module_trezorui2: Module = obj_module! { /// from trezorui_api import * /// - /// def show_address_details( - /// *, - /// qr_title: str, - /// address: str, - /// case_sensitive: bool, - /// details_title: str, - /// account: str | None, - /// path: str | None, - /// xpubs: list[tuple[str, str]], - /// ) -> LayoutObj[UiResult]: - /// """Show address details - QR code, account, path, cosigner xpubs.""" - Qstr::MP_QSTR_show_address_details => obj_fn_kw!(0, new_show_address_details).as_obj(), - /// def confirm_total( /// *, /// title: str, diff --git a/core/embed/rust/src/ui/model_tt/ui_features_fw.rs b/core/embed/rust/src/ui/model_tt/ui_features_fw.rs index 68710bf01e..0c0f2da926 100644 --- a/core/embed/rust/src/ui/model_tt/ui_features_fw.rs +++ b/core/embed/rust/src/ui/model_tt/ui_features_fw.rs @@ -31,10 +31,11 @@ use crate::{ use super::{ component::{ - check_homescreen_format, Bip39Input, Button, ButtonMsg, ButtonPage, ButtonStyleSheet, - CancelConfirmMsg, CoinJoinProgress, Dialog, FidoConfirm, Frame, Homescreen, IconDialog, - Lockscreen, MnemonicKeyboard, NumberInputDialog, PassphraseKeyboard, PinKeyboard, Progress, - SelectWordCount, SetBrightnessDialog, ShareWords, SimplePage, Slip39Input, + check_homescreen_format, AddressDetails, Bip39Input, Button, ButtonMsg, ButtonPage, + ButtonStyleSheet, CancelConfirmMsg, CoinJoinProgress, Dialog, FidoConfirm, Frame, + Homescreen, IconDialog, Lockscreen, MnemonicKeyboard, NumberInputDialog, + PassphraseKeyboard, PinKeyboard, Progress, SelectWordCount, SetBrightnessDialog, + ShareWords, SimplePage, Slip39Input, }, theme, ModelTTFeatures, }; @@ -643,6 +644,34 @@ impl UIFeaturesFirmware for ModelTTFeatures { Ok(layout) } + fn show_address_details( + qr_title: TString<'static>, + address: TString<'static>, + case_sensitive: bool, + details_title: TString<'static>, + account: Option>, + path: Option>, + xpubs: Obj, + ) -> Result { + let mut ad = AddressDetails::new( + qr_title, + address, + case_sensitive, + details_title, + account, + path, + )?; + + for i in IterBuf::new().try_iterate(xpubs)? { + let [xtitle, text]: [TString; 2] = util::iter_into_array(i)?; + ad.add_xpub(xtitle, text)?; + } + + let layout = + RootComponent::new(SimplePage::horizontal(ad, theme::BG).with_swipe_right_to_go_back()); + Ok(layout) + } + fn show_checklist( title: TString<'static>, button: TString<'static>, diff --git a/core/embed/rust/src/ui/ui_features_fw.rs b/core/embed/rust/src/ui/ui_features_fw.rs index 5bf0c21e1c..aa32fad8c8 100644 --- a/core/embed/rust/src/ui/ui_features_fw.rs +++ b/core/embed/rust/src/ui/ui_features_fw.rs @@ -188,6 +188,16 @@ pub trait UIFeaturesFirmware { fn set_brightness(current_brightness: Option) -> Result; + fn show_address_details( + qr_title: TString<'static>, + address: TString<'static>, + case_sensitive: bool, + details_title: TString<'static>, + account: Option>, + path: Option>, + xpubs: Obj, // TODO: replace Obj + ) -> Result; + fn show_checklist( title: TString<'static>, button: TString<'static>, diff --git a/core/mocks/generated/trezorui2.pyi b/core/mocks/generated/trezorui2.pyi index c49c50f0d2..35a0924164 100644 --- a/core/mocks/generated/trezorui2.pyi +++ b/core/mocks/generated/trezorui2.pyi @@ -17,6 +17,7 @@ def confirm_blob_intro( and instructing the user to access the menu in order to view all the data, which can then be confirmed using confirm_blob.""" + # rust/src/ui/model_mercury/layout.rs def flow_confirm_set_new_pin( *, @@ -99,18 +100,6 @@ from trezor import utils from trezorui_api import * -# rust/src/ui/model_tr/layout.rs -def show_address_details( - *, - address: str, - case_sensitive: bool, - account: str | None, - path: str | None, - xpubs: list[tuple[str, str]], -) -> LayoutObj[UiResult]: - """Show address details - QR code, account, path, cosigner xpubs.""" - - # rust/src/ui/model_tr/layout.rs def confirm_joint_total( *, @@ -179,20 +168,6 @@ from trezor import utils from trezorui_api import * -# rust/src/ui/model_tt/layout.rs -def show_address_details( - *, - qr_title: str, - address: str, - case_sensitive: bool, - details_title: str, - account: str | None, - path: str | None, - xpubs: list[tuple[str, str]], -) -> LayoutObj[UiResult]: - """Show address details - QR code, account, path, cosigner xpubs.""" - - # rust/src/ui/model_tt/layout.rs def confirm_total( *, diff --git a/core/mocks/generated/trezorui_api.pyi b/core/mocks/generated/trezorui_api.pyi index 29de793a84..e7d4bffc18 100644 --- a/core/mocks/generated/trezorui_api.pyi +++ b/core/mocks/generated/trezorui_api.pyi @@ -364,6 +364,20 @@ def set_brightness( """Show the brightness configuration dialog.""" +# rust/src/ui/api/firmware_upy.rs +def show_address_details( + *, + qr_title: str, + address: str, + case_sensitive: bool, + details_title: str, + account: str | None, + path: str | None, + xpubs: list[tuple[str, str]], +) -> LayoutObj[UiResult]: + """Show address details - QR code, account, path, cosigner xpubs.""" + + # rust/src/ui/api/firmware_upy.rs def show_checklist( *, diff --git a/core/src/trezor/ui/layouts/tr/__init__.py b/core/src/trezor/ui/layouts/tr/__init__.py index 2dd8e54d27..dcb1d40c1b 100644 --- a/core/src/trezor/ui/layouts/tr/__init__.py +++ b/core/src/trezor/ui/layouts/tr/__init__.py @@ -287,7 +287,7 @@ async def show_address( return result result = await interact( - trezorui2.show_address_details( + trezorui_api.show_address_details( qr_title="", # unused on this model address=address if address_qr is None else address_qr, case_sensitive=case_sensitive, diff --git a/core/src/trezor/ui/layouts/tt/__init__.py b/core/src/trezor/ui/layouts/tt/__init__.py index d2f6d69b82..44d1cbcec4 100644 --- a/core/src/trezor/ui/layouts/tt/__init__.py +++ b/core/src/trezor/ui/layouts/tt/__init__.py @@ -273,7 +273,7 @@ async def show_address( return result result = await interact( - trezorui2.show_address_details( + trezorui_api.show_address_details( qr_title=title, address=address if address_qr is None else address_qr, case_sensitive=case_sensitive,