1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-04-22 18:19:03 +00:00

chore(eckhart) update get_address flow to use xpubs

update test to scroll throiugh an entire page
This commit is contained in:
Lukas Bielesch 2025-03-29 23:19:38 +01:00
parent 8104979fe7
commit 5ab0733ee7
3 changed files with 35 additions and 9 deletions

View File

@ -1,12 +1,12 @@
use crate::{
error,
micropython::obj::Obj,
micropython::{obj::Obj, util},
strutil::TString,
translations::TR,
ui::{
button_request::ButtonRequest,
component::{
text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecShort, VecExt},
text::paragraphs::{Paragraph, ParagraphSource, ParagraphVecLong, VecExt},
ButtonRequestExt, ComponentExt, Qr,
},
flow::{
@ -16,6 +16,7 @@ use crate::{
geometry::{Alignment, Direction, LinearPlacement, Offset},
},
};
use heapless::Vec;
use super::super::{
component::Button,
@ -28,6 +29,7 @@ use super::super::{
const ITEM_PADDING: i16 = 16;
const GROUP_PADDING: i16 = 20;
const MAX_XPUBS: usize = 3;
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum GetAddress {
@ -78,7 +80,7 @@ pub fn new_get_address(
case_sensitive: bool,
account: Option<TString<'static>>,
path: Option<TString<'static>>,
_xpubs: Obj, // TODO: get rid of Obj
xpubs: Obj, // TODO: get rid of Obj
title_success: TString<'static>,
br_code: u16,
br_name: TString<'static>,
@ -171,7 +173,7 @@ pub fn new_get_address(
.map(|_| Some(FlowMsg::Cancelled));
// AccountInfo
let mut para = ParagraphVecShort::new();
let mut para = ParagraphVecLong::new();
if let Some(a) = account {
para.add(Paragraph::new::<TString>(
&theme::TEXT_SMALL_LIGHT,
@ -186,9 +188,25 @@ pub fn new_get_address(
&theme::TEXT_SMALL_LIGHT,
TR::address_details__derivation_path.into(),
)
.with_top_padding(GROUP_PADDING),
.with_top_padding(GROUP_PADDING)
.no_break(),
);
para.add(
Paragraph::new(&theme::TEXT_MONO_EXTRA_LIGHT, p)
.with_top_padding(ITEM_PADDING)
.break_after(),
);
}
let xpub_items: Vec<Obj, MAX_XPUBS> = util::iter_into_vec(xpubs).unwrap_or(Vec::new());
for i in xpub_items.into_iter() {
let [label, value]: [TString; 2] = util::iter_into_array(i)?;
para.add(Paragraph::new(&theme::TEXT_SMALL_LIGHT, label).no_break());
para.add(
Paragraph::new(&theme::TEXT_MONO_LIGHT, value)
.with_top_padding(ITEM_PADDING)
.break_after(),
);
para.add(Paragraph::new(&theme::TEXT_MONO_EXTRA_LIGHT, p).with_top_padding(ITEM_PADDING));
}
let content_account = TextScreen::new(

View File

@ -54,7 +54,7 @@ def test_reset_recovery(client: Client):
device.wipe(client)
set_language(client, lang[:2])
recover(client, combination)
recover(client, combination, True)
address_after = btc.get_address(
client, "Bitcoin", parse_path("m/44h/0h/0h/0/0")
)
@ -90,9 +90,9 @@ def reset(client: Client, strength: int = 128) -> list[str]:
return IF.mnemonics
def recover(client: Client, shares: list[str]):
def recover(client: Client, shares: list[str], click_info: bool = False):
with client:
IF = InputFlowSlip39AdvancedRecovery(client, shares, False)
IF = InputFlowSlip39AdvancedRecovery(client, shares, click_info)
client.set_input_flow(IF.get())
device.recover(client, pin_protection=False, label="label")

View File

@ -374,6 +374,14 @@ class RecoveryFlow:
self.debug.synchronize_at("VerticalMenu")
self.debug.click(self.debug.screen_buttons.vertical_menu_items()[0])
br = yield
# Scroll through remaining share pages
assert br.pages is not None
for _ in range(br.pages - 1):
if self.client.layout_type is LayoutType.Delizia:
self.debug.swipe_up()
elif self.client.layout_type is LayoutType.Eckhart:
self.debug.click(self.debug.screen_buttons.ok())
assert br.name == "show_shares"
assert br.code == B.Other
# Getting back to the homepage