Skip to content

Commit d91923b

Browse files
committed
chore(core/eckhart): Update passphrase-related flows
[no changelog]
1 parent 41a852c commit d91923b

File tree

17 files changed

+4529
-4388
lines changed

17 files changed

+4529
-4388
lines changed

core/embed/rust/librust_qstr.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,14 +394,17 @@ static void _librust_qstrs(void) {
394394
MP_QSTR_pages;
395395
MP_QSTR_paint;
396396
MP_QSTR_paired_devices;
397+
MP_QSTR_passphrase__access_hidden_wallet;
397398
MP_QSTR_passphrase__access_wallet;
398399
MP_QSTR_passphrase__always_on_device;
399400
MP_QSTR_passphrase__continue_with_empty_passphrase;
400401
MP_QSTR_passphrase__from_host_not_shown;
402+
MP_QSTR_passphrase__hidden_wallet;
401403
MP_QSTR_passphrase__hide;
402404
MP_QSTR_passphrase__next_screen_will_show_passphrase;
403405
MP_QSTR_passphrase__please_enter;
404406
MP_QSTR_passphrase__revoke_on_device;
407+
MP_QSTR_passphrase__show;
405408
MP_QSTR_passphrase__title_confirm;
406409
MP_QSTR_passphrase__title_enter;
407410
MP_QSTR_passphrase__title_hide;

core/embed/rust/src/translations/generated/translated_string.rs

Lines changed: 17 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/embed/rust/src/ui/layout_eckhart/firmware/keyboard/passphrase.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl PassphraseKeyboard {
131131
input: PassphraseInput::new(),
132132
input_prompt: Label::left_aligned(
133133
TString::from_translation(TR::passphrase__title_enter),
134-
theme::TEXT_SMALL,
134+
theme::firmware::TEXT_SMALL,
135135
)
136136
.vertically_centered(),
137137
next_btn,

core/embed/rust/src/ui/layout_eckhart/firmware/text_screen.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ where
5454
const SUBTITLE_HEIGHT: i16 = 44;
5555
const SUBTITLE_DOUBLE_HEIGHT: i16 = 76;
5656
const SUBTITLE_STYLE: TextStyle = theme::TEXT_MEDIUM_EXTRA_LIGHT;
57+
const CONTENT_INSETS_NO_HEADER: Insets = Insets::top(38);
5758

5859
pub fn new(content: T) -> Self {
5960
Self {
@@ -169,10 +170,11 @@ where
169170
};
170171

171172
// Introduce side insets + top padding if the header is not present
173+
content_area = content_area.inset(SIDE_INSETS);
172174
content_area = if self.header.is_none() {
173-
content_area.inset(Insets::top(38)).inset(SIDE_INSETS)
175+
content_area.inset(Self::CONTENT_INSETS_NO_HEADER)
174176
} else {
175-
content_area.inset(SIDE_INSETS)
177+
content_area
176178
};
177179

178180
self.content.place(content_area);

core/embed/rust/src/ui/layout_eckhart/flow/request_passphrase.rs

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ use crate::{
33
strutil::ShortString,
44
translations::TR,
55
ui::{
6-
component::{text::op::OpTextLayout, ComponentExt, FormattedText},
6+
component::{
7+
text::paragraphs::{Paragraph, ParagraphSource},
8+
ComponentExt,
9+
},
710
flow::{
811
base::{Decision, DecisionBuilder as _},
912
FlowController, FlowMsg, SwipeFlow,
1013
},
11-
geometry::Direction,
14+
geometry::{Direction, LinearPlacement},
1215
},
1316
};
1417

@@ -17,7 +20,7 @@ use super::super::{
1720
firmware::{
1821
ActionBar, Header, PassphraseKeyboard, PassphraseKeyboardMsg, TextScreen, TextScreenMsg,
1922
},
20-
fonts, theme,
23+
theme,
2124
};
2225

2326
#[derive(Copy, Clone, PartialEq, Eq)]
@@ -56,22 +59,24 @@ impl FlowController for RequestPassphrase {
5659
}
5760

5861
pub fn new_request_passphrase() -> Result<SwipeFlow, error::Error> {
59-
let op_confirm = OpTextLayout::new(theme::TEXT_NORMAL).text(
60-
TR::passphrase__continue_with_empty_passphrase,
61-
fonts::FONT_SATOSHI_REGULAR_38,
62-
);
63-
64-
let content_confirm_empty = TextScreen::new(FormattedText::new(op_confirm))
65-
.with_header(Header::new("".into()))
66-
.with_action_bar(ActionBar::new_double(
67-
Button::with_icon(theme::ICON_CROSS).styled(theme::button_cancel()),
68-
Button::with_icon(theme::ICON_CHECKMARK).styled(theme::button_confirm()),
69-
))
70-
.map(|msg| match msg {
71-
TextScreenMsg::Cancelled => Some(FlowMsg::Cancelled),
72-
TextScreenMsg::Confirmed => Some(FlowMsg::Confirmed),
73-
_ => Some(FlowMsg::Cancelled),
74-
});
62+
let content_confirm_empty = TextScreen::new(
63+
Paragraph::new(
64+
&theme::TEXT_NORMAL,
65+
TR::passphrase__continue_with_empty_passphrase,
66+
)
67+
.into_paragraphs()
68+
.with_placement(LinearPlacement::vertical()),
69+
)
70+
.with_header(Header::new(TR::passphrase__title_enter.into()))
71+
.with_action_bar(ActionBar::new_double(
72+
Button::with_icon(theme::ICON_CHEVRON_LEFT),
73+
Button::with_text(TR::buttons__confirm.into()).styled(theme::button_default()),
74+
))
75+
.map(|msg| match msg {
76+
TextScreenMsg::Cancelled => Some(FlowMsg::Cancelled),
77+
TextScreenMsg::Confirmed => Some(FlowMsg::Confirmed),
78+
_ => Some(FlowMsg::Cancelled),
79+
});
7580

7681
let content_keypad = PassphraseKeyboard::new().map(|msg| match msg {
7782
PassphraseKeyboardMsg::Confirmed(s) => Some(FlowMsg::Text(s)),

core/embed/rust/src/ui/layout_eckhart/ui_firmware.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,9 @@ impl FirmwareUI for UIEckhart {
12221222
title: Option<TString<'static>>,
12231223
button: Option<TString<'static>>,
12241224
) -> Result<Gc<LayoutObj>, Error> {
1225-
let paragraphs = Paragraph::new(&theme::TEXT_REGULAR, text).into_paragraphs();
1225+
let paragraphs = Paragraph::new(&theme::TEXT_REGULAR, text)
1226+
.into_paragraphs()
1227+
.with_placement(LinearPlacement::vertical());
12261228

12271229
let mut screen = TextScreen::new(paragraphs);
12281230
if let Some(title) = title {

core/mocks/trezortranslate_keys.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,14 +506,17 @@ class TR:
506506
nem__unencrypted: str = "Unencrypted"
507507
nem__unknown_mosaic: str = "Unknown mosaic!"
508508
nostr__event_kind_template: str = "Event kind: {0}"
509+
passphrase__access_hidden_wallet: str = "Access hidden wallet"
509510
passphrase__access_wallet: str = "Access passphrase wallet?"
510511
passphrase__always_on_device: str = "Always enter your passphrase on Trezor?"
511512
passphrase__continue_with_empty_passphrase: str = "Continue with empty passphrase?"
512513
passphrase__from_host_not_shown: str = "Passphrase provided by host will be used but will not be displayed due to the device settings."
514+
passphrase__hidden_wallet: str = "Hidden wallet"
513515
passphrase__hide: str = "Hide passphrase coming from host?"
514516
passphrase__next_screen_will_show_passphrase: str = "The next screen shows your passphrase."
515517
passphrase__please_enter: str = "Please enter your passphrase."
516518
passphrase__revoke_on_device: str = "Do you want to revoke the passphrase on device setting?"
519+
passphrase__show: str = "Show passphrase"
517520
passphrase__title_confirm: str = "Confirm passphrase"
518521
passphrase__title_enter: str = "Enter passphrase"
519522
passphrase__title_hide: str = "Hide passphrase"

core/src/apps/common/passphrase.py

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ async def get() -> str:
3030

3131

3232
async def _request_on_host() -> str:
33-
from trezor import TR
3433
from trezor.messages import PassphraseAck, PassphraseRequest
35-
from trezor.ui.layouts import request_passphrase_on_host
34+
from trezor.ui.layouts import (
35+
confirm_hidden_passphrase_from_host,
36+
request_passphrase_on_host,
37+
show_passphrase_from_host,
38+
)
3639
from trezor.wire.context import call
3740

3841
request_passphrase_on_host()
@@ -55,30 +58,10 @@ async def _request_on_host() -> str:
5558

5659
# non-empty passphrase
5760
if passphrase:
58-
from trezor.ui.layouts import confirm_action, confirm_blob
59-
6061
# We want to hide the passphrase, or show it, according to settings.
6162
if storage_device.get_hide_passphrase_from_host():
62-
await confirm_action(
63-
"passphrase_host1_hidden",
64-
TR.passphrase__wallet,
65-
description=TR.passphrase__from_host_not_shown,
66-
prompt_screen=True,
67-
prompt_title=TR.passphrase__access_wallet,
68-
)
63+
await confirm_hidden_passphrase_from_host()
6964
else:
70-
await confirm_action(
71-
"passphrase_host1",
72-
TR.passphrase__wallet,
73-
description=TR.passphrase__next_screen_will_show_passphrase,
74-
verb=TR.buttons__continue,
75-
)
76-
77-
await confirm_blob(
78-
"passphrase_host2",
79-
TR.passphrase__title_confirm,
80-
passphrase,
81-
info=False,
82-
)
65+
await show_passphrase_from_host(passphrase)
8366

8467
return passphrase

core/src/trezor/ui/layouts/bolt/__init__.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,32 @@ def confirm_hide_passphrase_from_host() -> Awaitable[None]:
197197
)
198198

199199

200+
async def confirm_hidden_passphrase_from_host() -> None:
201+
await confirm_action(
202+
"passphrase_host1_hidden",
203+
TR.passphrase__wallet,
204+
description=TR.passphrase__from_host_not_shown,
205+
prompt_screen=True,
206+
prompt_title=TR.passphrase__access_wallet,
207+
)
208+
209+
210+
async def show_passphrase_from_host(passphrase: str | None) -> None:
211+
await confirm_action(
212+
"passphrase_host1",
213+
TR.passphrase__wallet,
214+
description=TR.passphrase__next_screen_will_show_passphrase,
215+
verb=TR.buttons__continue,
216+
)
217+
218+
await confirm_blob(
219+
"passphrase_host2",
220+
TR.passphrase__title_confirm,
221+
passphrase or "",
222+
info=False,
223+
)
224+
225+
200226
def confirm_change_passphrase_source(
201227
passphrase_always_on_device: bool,
202228
) -> Awaitable[None]:
@@ -709,6 +735,7 @@ def confirm_value(
709735
info_title: str | None = None,
710736
chunkify: bool = False,
711737
chunkify_info: bool = False,
738+
cancel: bool = False,
712739
) -> Awaitable[None]:
713740
"""General confirmation dialog, used by many other confirm_* functions."""
714741

@@ -734,6 +761,7 @@ def confirm_value(
734761
verb_cancel=verb_cancel,
735762
info=bool(info_items),
736763
hold=hold,
764+
cancel=cancel,
737765
),
738766
info_layout,
739767
br_name,

core/src/trezor/ui/layouts/caesar/__init__.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,32 @@ def confirm_hide_passphrase_from_host() -> Awaitable[None]:
214214
)
215215

216216

217+
async def confirm_hidden_passphrase_from_host() -> None:
218+
await confirm_action(
219+
"passphrase_host1_hidden",
220+
TR.passphrase__wallet,
221+
description=TR.passphrase__from_host_not_shown,
222+
prompt_screen=True,
223+
prompt_title=TR.passphrase__access_wallet,
224+
)
225+
226+
227+
async def show_passphrase_from_host(passphrase: str | None) -> None:
228+
await confirm_action(
229+
"passphrase_host1",
230+
TR.passphrase__wallet,
231+
description=TR.passphrase__next_screen_will_show_passphrase,
232+
verb=TR.buttons__continue,
233+
)
234+
235+
await confirm_blob(
236+
"passphrase_host2",
237+
TR.passphrase__title_confirm,
238+
passphrase or "",
239+
info=False,
240+
)
241+
242+
217243
def confirm_change_passphrase_source(
218244
passphrase_always_on_device: bool,
219245
) -> Awaitable[None]:
@@ -776,6 +802,7 @@ async def confirm_value(
776802
info_items: Iterable[tuple[str, str]] | None = None,
777803
chunkify: bool = False,
778804
chunkify_info: bool = False,
805+
cancel: bool = False,
779806
) -> None:
780807
"""General confirmation dialog, used by many other confirm_* functions."""
781808

@@ -794,6 +821,7 @@ async def confirm_value(
794821
hold=hold,
795822
is_data=is_data,
796823
chunkify=chunkify,
824+
cancel=cancel,
797825
),
798826
br_name,
799827
br_code,

0 commit comments

Comments
 (0)