mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-04 13:38:28 +00:00
refactor(core): move show_address_details
- not implemented on mercury
This commit is contained in:
parent
14ff8f7fd6
commit
1824437911
@ -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<TString> = kwargs.get(Qstr::MP_QSTR_account)?.try_into_option()?;
|
||||
let path: Option<TString> = 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,
|
||||
|
@ -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<TString<'static>>,
|
||||
_path: Option<TString<'static>>,
|
||||
_xpubs: Obj,
|
||||
) -> Result<impl LayoutMaybeTrace, Error> {
|
||||
Err::<RootComponent<Empty, ModelMercuryFeatures>, Error>(Error::ValueError(
|
||||
c"show_address_details not implemented",
|
||||
))
|
||||
}
|
||||
|
||||
fn show_checklist(
|
||||
title: TString<'static>,
|
||||
button: TString<'static>,
|
||||
|
@ -270,28 +270,6 @@ fn content_in_button_page<T: Component + Paginate + MaybeTrace + 'static>(
|
||||
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<TString> = kwargs.get(Qstr::MP_QSTR_account)?.try_into_option()?;
|
||||
let path: Option<TString> = 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,
|
||||
|
@ -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<TString<'static>>,
|
||||
path: Option<TString<'static>>,
|
||||
xpubs: Obj,
|
||||
) -> Result<impl LayoutMaybeTrace, Error> {
|
||||
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>,
|
||||
|
@ -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<TString> = kwargs.get(Qstr::MP_QSTR_account)?.try_into_option()?;
|
||||
let path: Option<TString> = 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,
|
||||
|
@ -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<TString<'static>>,
|
||||
path: Option<TString<'static>>,
|
||||
xpubs: Obj,
|
||||
) -> Result<impl LayoutMaybeTrace, Error> {
|
||||
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>,
|
||||
|
@ -188,6 +188,16 @@ pub trait UIFeaturesFirmware {
|
||||
|
||||
fn set_brightness(current_brightness: Option<u8>) -> Result<impl LayoutMaybeTrace, Error>;
|
||||
|
||||
fn show_address_details(
|
||||
qr_title: TString<'static>,
|
||||
address: TString<'static>,
|
||||
case_sensitive: bool,
|
||||
details_title: TString<'static>,
|
||||
account: Option<TString<'static>>,
|
||||
path: Option<TString<'static>>,
|
||||
xpubs: Obj, // TODO: replace Obj
|
||||
) -> Result<impl LayoutMaybeTrace, Error>;
|
||||
|
||||
fn show_checklist(
|
||||
title: TString<'static>,
|
||||
button: TString<'static>,
|
||||
|
@ -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(
|
||||
*,
|
||||
|
@ -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(
|
||||
*,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user