mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-20 21:38:26 +00:00
refactor(core): send out ButtonRequest name
[no changelog]
This commit is contained in:
parent
1ef88117fe
commit
522d33a71f
@ -49,8 +49,14 @@ message Failure {
|
||||
* @next ButtonAck
|
||||
*/
|
||||
message ButtonRequest {
|
||||
optional ButtonRequestType code = 1; // enum identifier of the screen
|
||||
optional ButtonRequestType code = 1; // enum identifier of the screen (deprecated)
|
||||
optional uint32 pages = 2; // if the screen is paginated, number of pages
|
||||
|
||||
// this existed briefly: https://github.com/trezor/trezor-firmware/commit/1012ee8497b241e8ca559e386d936fa549bc0357
|
||||
reserved 3;
|
||||
|
||||
optional string name = 4; // name of the screen
|
||||
|
||||
/**
|
||||
* Type of button request
|
||||
*/
|
||||
|
@ -328,7 +328,7 @@ extern const pb_msgdesc_t UnlockBootloader_msg;
|
||||
/* Maximum encoded size of messages (where known) */
|
||||
/* FirmwareUpload_size depends on runtime parameters */
|
||||
#define ButtonAck_size 0
|
||||
#define ButtonRequest_size 2
|
||||
#define ButtonRequest_size 8
|
||||
#define Failure_size 260
|
||||
#define Features_size 497
|
||||
#define FirmwareErase_size 6
|
||||
|
@ -120,7 +120,7 @@ static void _librust_qstrs(void) {
|
||||
MP_QSTR_bitcoin__voting_rights;
|
||||
MP_QSTR_bootscreen;
|
||||
MP_QSTR_br_code;
|
||||
MP_QSTR_br_type;
|
||||
MP_QSTR_br_name;
|
||||
MP_QSTR_brightness__change_title;
|
||||
MP_QSTR_brightness__changed_title;
|
||||
MP_QSTR_brightness__title;
|
||||
|
@ -32,8 +32,8 @@ impl ButtonRequestCode {
|
||||
*self as u16
|
||||
}
|
||||
|
||||
pub fn with_type(self, br_type: &'static str) -> ButtonRequest {
|
||||
ButtonRequest::new(self, br_type.into())
|
||||
pub fn with_name(self, name: &'static str) -> ButtonRequest {
|
||||
ButtonRequest::new(self, name.into())
|
||||
}
|
||||
|
||||
pub fn from(i: u16) -> Self {
|
||||
@ -44,15 +44,15 @@ impl ButtonRequestCode {
|
||||
#[derive(Clone)]
|
||||
pub struct ButtonRequest {
|
||||
pub code: ButtonRequestCode,
|
||||
pub br_type: TString<'static>,
|
||||
pub name: TString<'static>,
|
||||
}
|
||||
|
||||
impl ButtonRequest {
|
||||
pub fn new(code: ButtonRequestCode, br_type: TString<'static>) -> Self {
|
||||
ButtonRequest { code, br_type }
|
||||
pub fn new(code: ButtonRequestCode, name: TString<'static>) -> Self {
|
||||
ButtonRequest { code, name }
|
||||
}
|
||||
|
||||
pub fn from_num(code: u16, br_type: TString<'static>) -> Self {
|
||||
ButtonRequest::new(ButtonRequestCode::from(code), br_type)
|
||||
pub fn from_num(code: u16, name: TString<'static>) -> Self {
|
||||
ButtonRequest::new(ButtonRequestCode::from(code), name)
|
||||
}
|
||||
}
|
||||
|
@ -505,10 +505,10 @@ impl EventCtx {
|
||||
self.page_count
|
||||
}
|
||||
|
||||
pub fn send_button_request(&mut self, code: ButtonRequestCode, br_type: TString<'static>) {
|
||||
pub fn send_button_request(&mut self, code: ButtonRequestCode, name: TString<'static>) {
|
||||
#[cfg(feature = "ui_debug")]
|
||||
assert!(self.button_request.is_none());
|
||||
self.button_request = Some(ButtonRequest::new(code, br_type));
|
||||
self.button_request = Some(ButtonRequest::new(code, name));
|
||||
}
|
||||
|
||||
pub fn button_request(&mut self) -> Option<ButtonRequest> {
|
||||
|
@ -34,7 +34,7 @@ impl<T: Component> Component for OneButtonRequest<T> {
|
||||
fn event(&mut self, ctx: &mut EventCtx, event: Event) -> Option<Self::Msg> {
|
||||
if matches!(event, Event::Attach(_)) {
|
||||
if let Some(button_request) = self.button_request.take() {
|
||||
ctx.send_button_request(button_request.code, button_request.br_type)
|
||||
ctx.send_button_request(button_request.code, button_request.name)
|
||||
}
|
||||
}
|
||||
self.inner.event(ctx, event)
|
||||
|
@ -301,9 +301,7 @@ impl LayoutObjInner {
|
||||
fn obj_button_request(&mut self) -> Result<Obj, Error> {
|
||||
match self.event_ctx.button_request() {
|
||||
None => Ok(Obj::const_none()),
|
||||
Some(ButtonRequest { code, br_type }) => {
|
||||
(code.num().into(), br_type.try_into()?).try_into()
|
||||
}
|
||||
Some(ButtonRequest { code, name }) => (code.num().into(), name.try_into()?).try_into(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ impl ConfirmOutput {
|
||||
let account: Option<TString> = kwargs.get(Qstr::MP_QSTR_account)?.try_into_option()?;
|
||||
let account_path: Option<TString> =
|
||||
kwargs.get(Qstr::MP_QSTR_account_path)?.try_into_option()?;
|
||||
let br_type: TString = kwargs.get(Qstr::MP_QSTR_br_type)?.try_into()?;
|
||||
let br_name: TString = kwargs.get(Qstr::MP_QSTR_br_name)?.try_into()?;
|
||||
let br_code: u16 = kwargs.get(Qstr::MP_QSTR_br_code)?.try_into()?;
|
||||
|
||||
let address: Obj = kwargs.get(Qstr::MP_QSTR_address)?;
|
||||
@ -99,7 +99,7 @@ impl ConfirmOutput {
|
||||
.with_chunkify(chunkify)
|
||||
.with_text_mono(text_mono)
|
||||
.into_layout()?
|
||||
.one_button_request(ButtonRequest::from_num(br_code, br_type));
|
||||
.one_button_request(ButtonRequest::from_num(br_code, br_name));
|
||||
|
||||
// Amount
|
||||
let content_amount = ConfirmBlobParams::new(TR::words__amount.into(), amount, None)
|
||||
@ -109,7 +109,7 @@ impl ConfirmOutput {
|
||||
.with_text_mono(text_mono)
|
||||
.with_swipe_down()
|
||||
.into_layout()?
|
||||
.one_button_request(ButtonRequest::from_num(br_code, br_type));
|
||||
.one_button_request(ButtonRequest::from_num(br_code, br_name));
|
||||
|
||||
// Menu
|
||||
let content_menu = Frame::left_aligned(
|
||||
|
@ -85,7 +85,7 @@ impl ConfirmResetCreate {
|
||||
.with_swipe(SwipeDirection::Up, SwipeSettings::default())
|
||||
.with_swipe(SwipeDirection::Left, SwipeSettings::default())
|
||||
.map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info))
|
||||
.one_button_request(ButtonRequestCode::ResetDevice.with_type("setup_device"));
|
||||
.one_button_request(ButtonRequestCode::ResetDevice.with_name("setup_device"));
|
||||
|
||||
// FIXME: TR::reset__cancel_create_wallet should be used but Button text on
|
||||
// multiple lines not supported yet
|
||||
@ -112,7 +112,7 @@ impl ConfirmResetCreate {
|
||||
FrameMsg::Content(()) => Some(FlowMsg::Confirmed),
|
||||
FrameMsg::Button(_) => Some(FlowMsg::Info),
|
||||
})
|
||||
.one_button_request(ButtonRequestCode::ResetDevice.with_type("confirm_setup_device"));
|
||||
.one_button_request(ButtonRequestCode::ResetDevice.with_name("confirm_setup_device"));
|
||||
|
||||
let res = SwipeFlow::new(&ConfirmResetCreate::Intro)?
|
||||
.with_page(&ConfirmResetCreate::Intro, content_intro)?
|
||||
|
@ -81,7 +81,7 @@ impl ConfirmResetRecover {
|
||||
.with_swipe(SwipeDirection::Up, SwipeSettings::default())
|
||||
.with_swipe(SwipeDirection::Left, SwipeSettings::default())
|
||||
.map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info))
|
||||
.one_button_request(ButtonRequestCode::ProtectCall.with_type("recover_device"));
|
||||
.one_button_request(ButtonRequestCode::ProtectCall.with_name("recover_device"));
|
||||
|
||||
let content_menu = Frame::left_aligned(
|
||||
"".into(),
|
||||
|
@ -79,7 +79,7 @@ impl ConfirmSummary {
|
||||
let items: Obj = kwargs.get(Qstr::MP_QSTR_items)?;
|
||||
let account_items: Obj = kwargs.get(Qstr::MP_QSTR_account_items)?;
|
||||
let fee_items: Obj = kwargs.get(Qstr::MP_QSTR_fee_items)?;
|
||||
let br_type: TString = kwargs.get(Qstr::MP_QSTR_br_type)?.try_into()?;
|
||||
let br_name: TString = kwargs.get(Qstr::MP_QSTR_br_name)?.try_into()?;
|
||||
let br_code: u16 = kwargs.get(Qstr::MP_QSTR_br_code)?.try_into()?;
|
||||
|
||||
// Summary
|
||||
@ -93,7 +93,7 @@ impl ConfirmSummary {
|
||||
}
|
||||
let content_summary = summary
|
||||
.into_layout()?
|
||||
.one_button_request(ButtonRequest::from_num(br_code, br_type))
|
||||
.one_button_request(ButtonRequest::from_num(br_code, br_name))
|
||||
// Summary(1) + Hold(1)
|
||||
.with_pages(|summary_pages| summary_pages + 1);
|
||||
|
||||
|
@ -105,7 +105,7 @@ impl GetAddress {
|
||||
let path: Option<TString> = kwargs.get(Qstr::MP_QSTR_path)?.try_into_option()?;
|
||||
let xpubs: Obj = kwargs.get(Qstr::MP_QSTR_xpubs)?;
|
||||
|
||||
let br_type: TString = kwargs.get(Qstr::MP_QSTR_br_type)?.try_into()?;
|
||||
let br_name: TString = kwargs.get(Qstr::MP_QSTR_br_name)?.try_into()?;
|
||||
let br_code: u16 = kwargs.get(Qstr::MP_QSTR_br_code)?.try_into()?;
|
||||
|
||||
// Address
|
||||
@ -132,7 +132,7 @@ impl GetAddress {
|
||||
.with_swipe(SwipeDirection::Left, SwipeSettings::default())
|
||||
.with_vertical_pages()
|
||||
.map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info))
|
||||
.one_button_request(ButtonRequest::from_num(br_code, br_type))
|
||||
.one_button_request(ButtonRequest::from_num(br_code, br_name))
|
||||
// Count tap-to-confirm screen towards page count
|
||||
.with_pages(|address_pages| address_pages + 1);
|
||||
|
||||
|
@ -76,7 +76,7 @@ impl RequestNumber {
|
||||
let info: Obj = kwargs.get(Qstr::MP_QSTR_info)?;
|
||||
assert!(description != Obj::const_none());
|
||||
assert!(info != Obj::const_none());
|
||||
let br_type: TString = kwargs.get(Qstr::MP_QSTR_br_type)?.try_into()?;
|
||||
let br_name: TString = kwargs.get(Qstr::MP_QSTR_br_name)?.try_into()?;
|
||||
let br_code: u16 = kwargs.get(Qstr::MP_QSTR_br_code)?.try_into()?;
|
||||
|
||||
let description_cb = move |i: u32| {
|
||||
@ -103,7 +103,7 @@ impl RequestNumber {
|
||||
FrameMsg::Button(_) => Some(FlowMsg::Info),
|
||||
FrameMsg::Content(NumberInputDialogMsg(n)) => Some(FlowMsg::Choice(n as usize)),
|
||||
})
|
||||
.one_button_request(ButtonRequest::from_num(br_code, br_type));
|
||||
.one_button_request(ButtonRequest::from_num(br_code, br_name));
|
||||
|
||||
let content_menu = Frame::left_aligned(
|
||||
"".into(),
|
||||
|
@ -98,7 +98,7 @@ impl ShowShareWords {
|
||||
.with_footer(TR::instructions__swipe_up.into(), description)
|
||||
.with_swipe(SwipeDirection::Up, SwipeSettings::default())
|
||||
.map(|msg| matches!(msg, FrameMsg::Content(_)).then_some(FlowMsg::Confirmed))
|
||||
.one_button_request(ButtonRequestCode::ResetDevice.with_type("share_words"))
|
||||
.one_button_request(ButtonRequestCode::ResetDevice.with_name("share_words"))
|
||||
.with_pages(move |_| nwords + 2);
|
||||
|
||||
let content_words =
|
||||
|
@ -87,7 +87,7 @@ impl WarningHiPrio {
|
||||
.with_swipe(SwipeDirection::Up, SwipeSettings::default())
|
||||
.with_swipe(SwipeDirection::Left, SwipeSettings::default())
|
||||
.map(|msg| matches!(msg, FrameMsg::Button(_)).then_some(FlowMsg::Info));
|
||||
// .one_button_request(ButtonRequestCode::Warning, br_type);
|
||||
// .one_button_request(ButtonRequestCode::Warning, br_name);
|
||||
|
||||
// Menu
|
||||
let content_menu = Frame::left_aligned(
|
||||
|
@ -1707,7 +1707,7 @@ pub static mp_module_trezorui2: Module = obj_module! {
|
||||
/// description: Callable[[int], str] | None = None,
|
||||
/// info: Callable[[int], str] | None = None,
|
||||
/// br_code: ButtonRequestType,
|
||||
/// br_type: str,
|
||||
/// br_name: str,
|
||||
/// ) -> LayoutObj[tuple[UiResult, int]]:
|
||||
/// """Numer input with + and - buttons, description, and context menu with cancel and
|
||||
/// info."""
|
||||
@ -1835,7 +1835,7 @@ pub static mp_module_trezorui2: Module = obj_module! {
|
||||
/// path: str | None,
|
||||
/// xpubs: list[tuple[str, str]],
|
||||
/// br_code: ButtonRequestType,
|
||||
/// br_type: str,
|
||||
/// br_name: str,
|
||||
/// ) -> LayoutObj[UiResult]:
|
||||
/// """Get address / receive funds."""
|
||||
Qstr::MP_QSTR_flow_get_address => obj_fn_kw!(0, flow::get_address::new_get_address).as_obj(),
|
||||
@ -1858,7 +1858,7 @@ pub static mp_module_trezorui2: Module = obj_module! {
|
||||
/// account: str | None,
|
||||
/// account_path: str | None,
|
||||
/// br_code: ButtonRequestType,
|
||||
/// br_type: str,
|
||||
/// br_name: str,
|
||||
/// ) -> LayoutObj[UiResult]:
|
||||
/// """Confirm recipient."""
|
||||
Qstr::MP_QSTR_flow_confirm_output => obj_fn_kw!(0, flow::new_confirm_output).as_obj(),
|
||||
@ -1870,7 +1870,7 @@ pub static mp_module_trezorui2: Module = obj_module! {
|
||||
/// account_items: Iterable[tuple[str, str]],
|
||||
/// fee_items: Iterable[tuple[str, str]],
|
||||
/// br_code: ButtonRequestType,
|
||||
/// br_type: str,
|
||||
/// br_name: str,
|
||||
/// ) -> LayoutObj[UiResult]:
|
||||
/// """Total summary and hold to confirm."""
|
||||
Qstr::MP_QSTR_flow_confirm_summary => obj_fn_kw!(0, flow::new_confirm_summary).as_obj(),
|
||||
|
@ -423,7 +423,7 @@ def flow_request_number(
|
||||
description: Callable[[int], str] | None = None,
|
||||
info: Callable[[int], str] | None = None,
|
||||
br_code: ButtonRequestType,
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
) -> LayoutObj[tuple[UiResult, int]]:
|
||||
"""Numer input with + and - buttons, description, and context menu with cancel and
|
||||
info."""
|
||||
@ -565,7 +565,7 @@ def flow_get_address(
|
||||
path: str | None,
|
||||
xpubs: list[tuple[str, str]],
|
||||
br_code: ButtonRequestType,
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
) -> LayoutObj[UiResult]:
|
||||
"""Get address / receive funds."""
|
||||
|
||||
@ -590,7 +590,7 @@ def flow_confirm_output(
|
||||
account: str | None,
|
||||
account_path: str | None,
|
||||
br_code: ButtonRequestType,
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
) -> LayoutObj[UiResult]:
|
||||
"""Confirm recipient."""
|
||||
|
||||
@ -603,7 +603,7 @@ def flow_confirm_summary(
|
||||
account_items: Iterable[tuple[str, str]],
|
||||
fee_items: Iterable[tuple[str, str]],
|
||||
br_code: ButtonRequestType,
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
) -> LayoutObj[UiResult]:
|
||||
"""Total summary and hold to confirm."""
|
||||
|
||||
|
@ -110,7 +110,7 @@ async def get_public_key(
|
||||
account=account,
|
||||
path=path,
|
||||
mismatch_title=TR.addr_mismatch__xpub_mismatch,
|
||||
br_type="show_xpub",
|
||||
br_name="show_xpub",
|
||||
)
|
||||
|
||||
return PublicKey(
|
||||
|
@ -294,7 +294,7 @@ async def confirm_reference_script(
|
||||
|
||||
|
||||
async def _confirm_data_chunk(
|
||||
br_type: str, title: str, first_chunk: bytes, data_size: int
|
||||
br_name: str, title: str, first_chunk: bytes, data_size: int
|
||||
) -> None:
|
||||
MAX_DISPLAYED_SIZE = 56
|
||||
displayed_bytes = first_chunk[:MAX_DISPLAYED_SIZE]
|
||||
@ -308,7 +308,7 @@ async def _confirm_data_chunk(
|
||||
if data_size > MAX_DISPLAYED_SIZE:
|
||||
props.append(("...", None))
|
||||
await confirm_properties(
|
||||
br_type,
|
||||
br_name,
|
||||
title=TR.cardano__confirm_transaction,
|
||||
props=props,
|
||||
br_code=BRT_Other,
|
||||
|
@ -36,12 +36,12 @@ is_last = False
|
||||
# Because icon and br_code are almost always the same
|
||||
# (and also calling with positional arguments takes less space)
|
||||
async def _confirm_properties(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
props: Iterable[PropertyType],
|
||||
) -> None:
|
||||
await confirm_properties(
|
||||
br_type,
|
||||
br_name,
|
||||
title,
|
||||
props,
|
||||
hold=is_last,
|
||||
|
@ -269,7 +269,7 @@ async def confirm_system_transfer(
|
||||
title=TR.words__recipient,
|
||||
value=base58.encode(transfer_instruction.recipient_account[0]),
|
||||
description="",
|
||||
br_type="confirm_recipient",
|
||||
br_name="confirm_recipient",
|
||||
br_code=ButtonRequestType.ConfirmOutput,
|
||||
verb=TR.buttons__continue,
|
||||
)
|
||||
@ -298,7 +298,7 @@ async def confirm_token_transfer(
|
||||
title=TR.words__recipient,
|
||||
value=base58.encode(destination_account),
|
||||
description="",
|
||||
br_type="confirm_recipient",
|
||||
br_name="confirm_recipient",
|
||||
br_code=ButtonRequestType.ConfirmOutput,
|
||||
verb=TR.buttons__continue,
|
||||
info_items=(
|
||||
@ -312,7 +312,7 @@ async def confirm_token_transfer(
|
||||
title=TR.solana__token_address,
|
||||
value=base58.encode(token_mint),
|
||||
description="",
|
||||
br_type="confirm_token_address",
|
||||
br_name="confirm_token_address",
|
||||
br_code=ButtonRequestType.ConfirmOutput,
|
||||
verb=TR.buttons__continue,
|
||||
)
|
||||
|
2
core/src/trezor/messages.py
generated
2
core/src/trezor/messages.py
generated
@ -308,12 +308,14 @@ if TYPE_CHECKING:
|
||||
class ButtonRequest(protobuf.MessageType):
|
||||
code: "ButtonRequestType | None"
|
||||
pages: "int | None"
|
||||
name: "str | None"
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
code: "ButtonRequestType | None" = None,
|
||||
pages: "int | None" = None,
|
||||
name: "str | None" = None,
|
||||
) -> None:
|
||||
pass
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor import log, workflow
|
||||
from trezor import workflow
|
||||
from trezor.enums import ButtonRequestType
|
||||
from trezor.messages import ButtonAck, ButtonRequest
|
||||
from trezor.wire import context
|
||||
@ -19,24 +19,24 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
async def button_request(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
code: ButtonRequestType = ButtonRequestType.Other,
|
||||
pages: int | None = None,
|
||||
) -> None:
|
||||
if __debug__:
|
||||
log.debug(__name__, "ButtonRequest.type=%s", br_type)
|
||||
workflow.close_others()
|
||||
await context.maybe_call(ButtonRequest(code=code, pages=pages), ButtonAck)
|
||||
await context.maybe_call(
|
||||
ButtonRequest(code=code, pages=pages, name=br_name), ButtonAck
|
||||
)
|
||||
|
||||
|
||||
async def interact(
|
||||
layout: LayoutType[T],
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
br_code: ButtonRequestType = ButtonRequestType.Other,
|
||||
) -> T:
|
||||
pages = None
|
||||
if hasattr(layout, "page_count") and layout.page_count() > 1: # type: ignore [Cannot access attribute "page_count" for class "LayoutType"]
|
||||
# We know for certain how many pages the layout will have
|
||||
pages = layout.page_count() # type: ignore [Cannot access attribute "page_count" for class "LayoutType"]
|
||||
await button_request(br_type, br_code, pages)
|
||||
await button_request(br_name, br_code, pages)
|
||||
return await layout
|
||||
|
@ -1,7 +1,7 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import trezorui2
|
||||
from trezor import TR, io, log, loop, ui, utils
|
||||
from trezor import TR, io, loop, ui, utils
|
||||
from trezor.enums import ButtonRequestType
|
||||
from trezor.messages import ButtonAck, ButtonRequest
|
||||
from trezor.wire import ActionCancelled, context
|
||||
@ -16,7 +16,7 @@ if TYPE_CHECKING:
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
BR_TYPE_OTHER = ButtonRequestType.Other # global_import_cache
|
||||
BR_CODE_OTHER = ButtonRequestType.Other # global_import_cache
|
||||
|
||||
CONFIRMED = trezorui2.CONFIRMED
|
||||
CANCELLED = trezorui2.CANCELLED
|
||||
@ -251,17 +251,18 @@ class RustLayout(ui.Layout):
|
||||
|
||||
async def handle_usb(self, ctx: context.Context):
|
||||
while True:
|
||||
br_code, br_type, page_count = await loop.race(
|
||||
br_code, br_name, page_count = await loop.race(
|
||||
ctx.read(()), self.br_chan.take()
|
||||
)
|
||||
log.debug(__name__, "ButtonRequest.type=%s", br_type)
|
||||
await ctx.call(ButtonRequest(code=br_code, pages=page_count), ButtonAck)
|
||||
await ctx.call(
|
||||
ButtonRequest(code=br_code, pages=page_count, name=br_name), ButtonAck
|
||||
)
|
||||
|
||||
def _send_button_request(self):
|
||||
res = self.layout.button_request()
|
||||
if res is not None:
|
||||
br_code, br_type = res
|
||||
self.br_chan.publish((br_code, br_type, self.layout.page_count()))
|
||||
br_code, br_name = res
|
||||
self.br_chan.publish((br_code, br_name, self.layout.page_count()))
|
||||
|
||||
def finalize(self):
|
||||
ui.LAST_TRANSITION_OUT = self.layout.get_transition_out()
|
||||
@ -288,7 +289,7 @@ async def raise_if_not_confirmed(
|
||||
|
||||
|
||||
def confirm_action(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
action: str | None = None,
|
||||
description: str | None = None,
|
||||
@ -300,7 +301,7 @@ def confirm_action(
|
||||
hold_danger: bool = False,
|
||||
reverse: bool = False,
|
||||
exc: ExceptionType = ActionCancelled,
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
prompt_screen: bool = False,
|
||||
prompt_title: str | None = None,
|
||||
) -> Awaitable[None]:
|
||||
@ -324,7 +325,7 @@ def confirm_action(
|
||||
prompt_title=prompt_title or title,
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
),
|
||||
exc,
|
||||
@ -332,7 +333,7 @@ def confirm_action(
|
||||
|
||||
|
||||
def confirm_single(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
description: str,
|
||||
description_param: str | None = None,
|
||||
@ -355,7 +356,7 @@ def confirm_single(
|
||||
verb=verb,
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
ButtonRequestType.ProtectCall,
|
||||
)
|
||||
)
|
||||
@ -463,7 +464,7 @@ async def show_address(
|
||||
xpubs: Sequence[str] = (),
|
||||
mismatch_title: str | None = None,
|
||||
details_title: str | None = None,
|
||||
br_type: str = "show_address",
|
||||
br_name: str = "show_address",
|
||||
br_code: ButtonRequestType = ButtonRequestType.Address,
|
||||
chunkify: bool = False,
|
||||
) -> None:
|
||||
@ -489,7 +490,7 @@ async def show_address(
|
||||
account=account,
|
||||
path=path,
|
||||
xpubs=[(xpub_title(i), xpub) for i, xpub in enumerate(xpubs)],
|
||||
br_type=br_type,
|
||||
br_name=br_name,
|
||||
br_code=br_code,
|
||||
)
|
||||
)
|
||||
@ -503,7 +504,7 @@ def show_pubkey(
|
||||
account: str | None = None,
|
||||
path: str | None = None,
|
||||
mismatch_title: str | None = None,
|
||||
br_type: str = "show_pubkey",
|
||||
br_name: str = "show_pubkey",
|
||||
) -> Awaitable[None]:
|
||||
title = title or TR.address__public_key # def_arg
|
||||
mismatch_title = mismatch_title or TR.addr_mismatch__key_mismatch # def_arg
|
||||
@ -512,7 +513,7 @@ def show_pubkey(
|
||||
title=title,
|
||||
account=account,
|
||||
path=path,
|
||||
br_type=br_type,
|
||||
br_name=br_name,
|
||||
br_code=ButtonRequestType.PublicKey,
|
||||
mismatch_title=mismatch_title,
|
||||
chunkify=False,
|
||||
@ -520,7 +521,7 @@ def show_pubkey(
|
||||
|
||||
|
||||
async def show_error_and_raise(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
content: str,
|
||||
subheader: str | None = None,
|
||||
button: str | None = None,
|
||||
@ -536,14 +537,14 @@ async def show_error_and_raise(
|
||||
allow_cancel=False,
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
BR_TYPE_OTHER,
|
||||
br_name,
|
||||
BR_CODE_OTHER,
|
||||
)
|
||||
raise exc
|
||||
|
||||
|
||||
def show_warning(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
content: str,
|
||||
subheader: str | None = None,
|
||||
button: str | None = None,
|
||||
@ -559,14 +560,14 @@ def show_warning(
|
||||
button=subheader or TR.words__continue_anyway,
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def show_success(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
content: str,
|
||||
subheader: str | None = None,
|
||||
button: str | None = None,
|
||||
@ -579,7 +580,7 @@ def show_success(
|
||||
description=subheader if subheader else "",
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
ButtonRequestType.Success,
|
||||
)
|
||||
)
|
||||
@ -616,7 +617,7 @@ async def confirm_output(
|
||||
account=source_account,
|
||||
account_path=source_account_path,
|
||||
br_code=br_code,
|
||||
br_type="confirm_output",
|
||||
br_name="confirm_output",
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -658,8 +659,8 @@ async def should_show_more(
|
||||
title: str,
|
||||
para: Iterable[tuple[int, str | bytes]],
|
||||
button_text: str | None = None,
|
||||
br_type: str = "should_show_more",
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_name: str = "should_show_more",
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
confirm: str | bytes | None = None,
|
||||
) -> bool:
|
||||
"""Return True if the user wants to show more (they click a special button)
|
||||
@ -680,7 +681,7 @@ async def should_show_more(
|
||||
info_button=button_text,
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
|
||||
@ -694,7 +695,7 @@ async def should_show_more(
|
||||
|
||||
|
||||
async def _confirm_ask_pagination(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
data: bytes | str,
|
||||
description: str,
|
||||
@ -710,7 +711,7 @@ async def _confirm_ask_pagination(
|
||||
if not await should_show_more(
|
||||
title,
|
||||
para=[(ui.NORMAL, description), (ui.MONO, data)],
|
||||
br_type=br_type,
|
||||
br_name=br_name,
|
||||
br_code=br_code,
|
||||
):
|
||||
return
|
||||
@ -726,21 +727,21 @@ async def _confirm_ask_pagination(
|
||||
else:
|
||||
paginated.request_complete_repaint()
|
||||
|
||||
result = await interact(paginated, br_type, br_code)
|
||||
result = await interact(paginated, br_name, br_code)
|
||||
assert result in (CONFIRMED, CANCELLED)
|
||||
|
||||
assert False
|
||||
|
||||
|
||||
def confirm_blob(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
data: bytes | str,
|
||||
description: str | None = None,
|
||||
verb: str | None = None,
|
||||
verb_cancel: str | None = None,
|
||||
hold: bool = False,
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
ask_pagination: bool = False,
|
||||
chunkify: bool = False,
|
||||
prompt_screen: bool = True,
|
||||
@ -761,13 +762,13 @@ def confirm_blob(
|
||||
|
||||
if ask_pagination and layout.page_count() > 1:
|
||||
assert not hold
|
||||
return _confirm_ask_pagination(br_type, title, data, description or "", br_code)
|
||||
return _confirm_ask_pagination(br_name, title, data, description or "", br_code)
|
||||
|
||||
else:
|
||||
return raise_if_not_confirmed(
|
||||
interact(
|
||||
layout,
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
)
|
||||
@ -777,31 +778,31 @@ def confirm_address(
|
||||
title: str,
|
||||
address: str,
|
||||
description: str | None = None,
|
||||
br_type: str = "confirm_address",
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_name: str = "confirm_address",
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
) -> Awaitable[None]:
|
||||
return confirm_value(
|
||||
title,
|
||||
address,
|
||||
description or "",
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
verb=TR.buttons__confirm,
|
||||
)
|
||||
|
||||
|
||||
def confirm_text(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
data: str,
|
||||
description: str | None = None,
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
) -> Awaitable[None]:
|
||||
return confirm_value(
|
||||
title,
|
||||
data,
|
||||
description or "",
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
verb=TR.buttons__confirm,
|
||||
)
|
||||
@ -811,15 +812,15 @@ def confirm_amount(
|
||||
title: str,
|
||||
amount: str,
|
||||
description: str | None = None,
|
||||
br_type: str = "confirm_amount",
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_name: str = "confirm_amount",
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
) -> Awaitable[None]:
|
||||
description = description or f"{TR.words__amount}:" # def_arg
|
||||
return confirm_value(
|
||||
title,
|
||||
amount,
|
||||
description,
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
verb=TR.buttons__confirm,
|
||||
)
|
||||
@ -829,8 +830,8 @@ def confirm_value(
|
||||
title: str,
|
||||
value: str,
|
||||
description: str,
|
||||
br_type: str,
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_name: str,
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
*,
|
||||
verb: str | None = None,
|
||||
subtitle: str | None = None,
|
||||
@ -869,14 +870,14 @@ def confirm_value(
|
||||
)
|
||||
),
|
||||
info_layout,
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def confirm_properties(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
props: Iterable[PropertyType],
|
||||
hold: bool = False,
|
||||
@ -894,7 +895,7 @@ def confirm_properties(
|
||||
hold=hold,
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
)
|
||||
@ -909,7 +910,7 @@ def confirm_total(
|
||||
source_account: str | None = None,
|
||||
source_account_path: str | None = None,
|
||||
fee_rate_amount: str | None = None,
|
||||
br_type: str = "confirm_total",
|
||||
br_name: str = "confirm_total",
|
||||
br_code: ButtonRequestType = ButtonRequestType.SignTx,
|
||||
) -> Awaitable[None]:
|
||||
title = title or TR.words__title_summary # def_arg
|
||||
@ -936,7 +937,7 @@ def confirm_total(
|
||||
items=items,
|
||||
fee_items=fee_items,
|
||||
account_items=account_items,
|
||||
br_type=br_type,
|
||||
br_name=br_name,
|
||||
br_code=br_code,
|
||||
)
|
||||
)
|
||||
@ -948,7 +949,7 @@ def confirm_summary(
|
||||
title: str | None = None,
|
||||
info_items: Iterable[tuple[str, str]] | None = None,
|
||||
info_title: str | None = None,
|
||||
br_type: str = "confirm_total",
|
||||
br_name: str = "confirm_total",
|
||||
br_code: ButtonRequestType = ButtonRequestType.SignTx,
|
||||
) -> Awaitable[None]:
|
||||
# TODO: info_title
|
||||
@ -961,7 +962,7 @@ def confirm_summary(
|
||||
items=items or (),
|
||||
fee_items=(),
|
||||
account_items=info_items or (),
|
||||
br_type=br_type,
|
||||
br_name=br_name,
|
||||
br_code=br_code,
|
||||
)
|
||||
)
|
||||
@ -975,7 +976,7 @@ if not utils.BITCOIN_ONLY:
|
||||
total_amount: str,
|
||||
maximum_fee: str,
|
||||
items: Iterable[tuple[str, str]],
|
||||
br_type: str = "confirm_ethereum_tx",
|
||||
br_name: str = "confirm_ethereum_tx",
|
||||
br_code: ButtonRequestType = ButtonRequestType.SignTx,
|
||||
chunkify: bool = False,
|
||||
) -> None:
|
||||
@ -1000,7 +1001,7 @@ if not utils.BITCOIN_ONLY:
|
||||
while True:
|
||||
# Allowing going back and forth between recipient and summary/details
|
||||
await confirm_blob(
|
||||
br_type,
|
||||
br_name,
|
||||
TR.words__recipient,
|
||||
recipient,
|
||||
verb=TR.buttons__continue,
|
||||
@ -1011,7 +1012,7 @@ if not utils.BITCOIN_ONLY:
|
||||
try:
|
||||
total_layout.request_complete_repaint()
|
||||
await raise_if_not_confirmed(
|
||||
with_info(total_layout, info_layout, br_type, br_code)
|
||||
with_info(total_layout, info_layout, br_name, br_code)
|
||||
)
|
||||
break
|
||||
except ActionCancelled:
|
||||
@ -1027,7 +1028,7 @@ if not utils.BITCOIN_ONLY:
|
||||
address_title: str,
|
||||
info_items: Iterable[tuple[str, str]],
|
||||
chunkify: bool = False,
|
||||
br_type: str = "confirm_ethereum_staking_tx",
|
||||
br_name: str = "confirm_ethereum_staking_tx",
|
||||
br_code: ButtonRequestType = ButtonRequestType.SignTx,
|
||||
) -> None:
|
||||
|
||||
@ -1036,7 +1037,7 @@ if not utils.BITCOIN_ONLY:
|
||||
title,
|
||||
intro_question,
|
||||
"",
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
verb=verb,
|
||||
value_text_mono=False,
|
||||
@ -1058,7 +1059,7 @@ if not utils.BITCOIN_ONLY:
|
||||
title=title,
|
||||
info_title=TR.confirm_total__title_fee,
|
||||
info_items=info_items,
|
||||
br_type=br_type,
|
||||
br_name=br_name,
|
||||
br_code=br_code,
|
||||
)
|
||||
|
||||
@ -1068,7 +1069,7 @@ if not utils.BITCOIN_ONLY:
|
||||
items: Iterable[tuple[str, str]],
|
||||
amount_title: str | None = None,
|
||||
fee_title: str | None = None,
|
||||
br_type: str = "confirm_solana_tx",
|
||||
br_name: str = "confirm_solana_tx",
|
||||
br_code: ButtonRequestType = ButtonRequestType.SignTx,
|
||||
) -> Awaitable[None]:
|
||||
amount_title = (
|
||||
@ -1078,7 +1079,7 @@ if not utils.BITCOIN_ONLY:
|
||||
return confirm_summary(
|
||||
((amount_title, amount), (fee_title, fee)),
|
||||
info_items=items,
|
||||
br_type=br_type,
|
||||
br_name=br_name,
|
||||
br_code=br_code,
|
||||
)
|
||||
|
||||
@ -1090,13 +1091,13 @@ def confirm_joint_total(spending_amount: str, total_amount: str) -> Awaitable[No
|
||||
(TR.send__to_the_total_amount, total_amount),
|
||||
],
|
||||
title=TR.send__title_joint_transaction,
|
||||
br_type="confirm_joint_total",
|
||||
br_name="confirm_joint_total",
|
||||
br_code=ButtonRequestType.SignTx,
|
||||
)
|
||||
|
||||
|
||||
def confirm_metadata(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
content: str,
|
||||
param: str | None = None,
|
||||
@ -1106,7 +1107,7 @@ def confirm_metadata(
|
||||
) -> Awaitable[None]:
|
||||
verb = verb or TR.buttons__continue # def_arg
|
||||
return confirm_action(
|
||||
br_type,
|
||||
br_name,
|
||||
title=title,
|
||||
action="",
|
||||
description=content,
|
||||
@ -1180,10 +1181,10 @@ async def confirm_modify_output(
|
||||
async def with_info(
|
||||
main_layout: RustLayout,
|
||||
info_layout: RustLayout,
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
br_code: ButtonRequestType,
|
||||
) -> Any:
|
||||
await button_request(br_type, br_code, pages=main_layout.page_count())
|
||||
await button_request(br_name, br_code, pages=main_layout.page_count())
|
||||
|
||||
while True:
|
||||
result = await main_layout
|
||||
@ -1238,7 +1239,7 @@ def confirm_coinjoin(max_rounds: int, max_fee_per_vbyte: str) -> Awaitable[None]
|
||||
)
|
||||
),
|
||||
"coinjoin_final",
|
||||
BR_TYPE_OTHER,
|
||||
BR_CODE_OTHER,
|
||||
)
|
||||
)
|
||||
|
||||
@ -1252,7 +1253,7 @@ def confirm_sign_identity(
|
||||
f"{TR.words__sign} {proto}",
|
||||
identity,
|
||||
challenge_visual + "\n" if challenge_visual else "",
|
||||
br_code=BR_TYPE_OTHER,
|
||||
br_code=BR_CODE_OTHER,
|
||||
)
|
||||
|
||||
|
||||
@ -1266,10 +1267,10 @@ async def confirm_signverify(
|
||||
) -> None:
|
||||
if verify:
|
||||
address_title = TR.sign_message__verify_address
|
||||
br_type = "verify_message"
|
||||
br_name = "verify_message"
|
||||
else:
|
||||
address_title = TR.sign_message__confirm_address
|
||||
br_type = "sign_message"
|
||||
br_name = "sign_message"
|
||||
|
||||
address_layout = RustLayout(
|
||||
trezorui2.confirm_address(
|
||||
@ -1315,7 +1316,7 @@ async def confirm_signverify(
|
||||
|
||||
while True:
|
||||
result = await with_info(
|
||||
address_layout, info_layout, br_type, br_code=BR_TYPE_OTHER
|
||||
address_layout, info_layout, br_name, br_code=BR_CODE_OTHER
|
||||
)
|
||||
if result is not CONFIRMED:
|
||||
result = await RustLayout(
|
||||
@ -1330,7 +1331,7 @@ async def confirm_signverify(
|
||||
continue
|
||||
|
||||
message_layout.request_complete_repaint()
|
||||
result = await interact(message_layout, br_type, BR_TYPE_OTHER)
|
||||
result = await interact(message_layout, br_name, BR_CODE_OTHER)
|
||||
if result is CONFIRMED:
|
||||
break
|
||||
|
||||
@ -1435,7 +1436,7 @@ async def confirm_reenter_pin(
|
||||
async def pin_mismatch_popup(
|
||||
is_wipe_code: bool = False,
|
||||
) -> None:
|
||||
await button_request("pin_mismatch", code=BR_TYPE_OTHER)
|
||||
await button_request("pin_mismatch", code=BR_CODE_OTHER)
|
||||
title = TR.wipe_code__mismatch if is_wipe_code else TR.pin__mismatch
|
||||
description = TR.wipe_code__enter_new if is_wipe_code else TR.pin__reenter_new
|
||||
|
||||
@ -1447,7 +1448,7 @@ async def pin_mismatch_popup(
|
||||
|
||||
|
||||
async def wipe_code_same_as_pin_popup() -> None:
|
||||
await button_request("wipe_code_same_as_pin", code=BR_TYPE_OTHER)
|
||||
await button_request("wipe_code_same_as_pin", code=BR_CODE_OTHER)
|
||||
return await show_error_popup(
|
||||
TR.wipe_code__invalid,
|
||||
TR.wipe_code__diff_from_pin,
|
||||
@ -1456,18 +1457,18 @@ async def wipe_code_same_as_pin_popup() -> None:
|
||||
|
||||
|
||||
def confirm_set_new_pin(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
description: str,
|
||||
information: str,
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
) -> Awaitable[None]:
|
||||
return raise_if_not_confirmed(
|
||||
interact(
|
||||
RustLayout(
|
||||
trezorui2.flow_confirm_set_new_pin(title=title, description=description)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
)
|
||||
@ -1482,7 +1483,7 @@ def confirm_firmware_update(description: str, fingerprint: str) -> Awaitable[Non
|
||||
)
|
||||
),
|
||||
"firmware_update",
|
||||
BR_TYPE_OTHER,
|
||||
BR_CODE_OTHER,
|
||||
)
|
||||
)
|
||||
|
||||
@ -1491,11 +1492,11 @@ async def set_brightness(current: int | None = None) -> None:
|
||||
await interact(
|
||||
RustLayout(trezorui2.set_brightness(current=current)),
|
||||
"set_brightness",
|
||||
BR_TYPE_OTHER,
|
||||
BR_CODE_OTHER,
|
||||
)
|
||||
|
||||
|
||||
def tutorial(br_code: ButtonRequestType = BR_TYPE_OTHER) -> Awaitable[None]:
|
||||
def tutorial(br_code: ButtonRequestType = BR_CODE_OTHER) -> Awaitable[None]:
|
||||
"""Showing users how to interact with the device."""
|
||||
return raise_if_not_confirmed(
|
||||
interact(
|
||||
|
@ -147,7 +147,7 @@ async def continue_recovery(
|
||||
|
||||
|
||||
async def show_recovery_warning(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
content: str,
|
||||
subheader: str | None = None,
|
||||
button: str | None = None,
|
||||
@ -164,7 +164,7 @@ async def show_recovery_warning(
|
||||
description="",
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
)
|
||||
|
@ -174,7 +174,7 @@ async def _prompt_number(
|
||||
max_count=max_count,
|
||||
info=info,
|
||||
br_code=ButtonRequestType.ResetDevice,
|
||||
br_type=br_name,
|
||||
br_name=br_name,
|
||||
)
|
||||
)
|
||||
|
||||
@ -352,7 +352,7 @@ async def show_success_backup() -> None:
|
||||
|
||||
|
||||
async def show_reset_warning(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
content: str,
|
||||
subheader: str | None = None,
|
||||
button: str | None = None,
|
||||
@ -369,7 +369,7 @@ async def show_reset_warning(
|
||||
allow_cancel=False,
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
)
|
||||
|
@ -26,7 +26,7 @@ CONFIRMED = trezorui2.CONFIRMED
|
||||
CANCELLED = trezorui2.CANCELLED
|
||||
INFO = trezorui2.INFO
|
||||
|
||||
BR_TYPE_OTHER = ButtonRequestType.Other # global_import_cache
|
||||
BR_CODE_OTHER = ButtonRequestType.Other # global_import_cache
|
||||
|
||||
|
||||
if __debug__:
|
||||
@ -291,17 +291,19 @@ class RustLayout(LayoutParentType[T]):
|
||||
|
||||
async def handle_usb(self, ctx: context.Context):
|
||||
while True:
|
||||
br_code, br_type, page_count = await loop.race(
|
||||
br_code, br_name, page_count = await loop.race(
|
||||
ctx.read(()), self.br_chan.take()
|
||||
)
|
||||
log.debug(__name__, "ButtonRequest.type=%s", br_type)
|
||||
await ctx.call(ButtonRequest(code=br_code, pages=page_count), ButtonAck)
|
||||
log.debug(__name__, "ButtonRequest.name=%s", br_name)
|
||||
await ctx.call(
|
||||
ButtonRequest(code=br_code, pages=page_count, name=br_name), ButtonAck
|
||||
)
|
||||
|
||||
def _send_button_request(self):
|
||||
res = self.layout.button_request()
|
||||
if res is not None:
|
||||
br_code, br_type = res
|
||||
self.br_chan.publish((br_code, br_type, self.layout.page_count()))
|
||||
br_code, br_name = res
|
||||
self.br_chan.publish((br_code, br_name, self.layout.page_count()))
|
||||
|
||||
|
||||
def draw_simple(layout: trezorui2.LayoutObj[Any]) -> None:
|
||||
@ -317,7 +319,7 @@ def draw_simple(layout: trezorui2.LayoutObj[Any]) -> None:
|
||||
# Temporary function, so we know where it is used
|
||||
# Should be gradually replaced by custom designs/layouts
|
||||
def _placeholder_confirm(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
data: str | None = None,
|
||||
description: str | None = None,
|
||||
@ -325,11 +327,11 @@ def _placeholder_confirm(
|
||||
verb: str | None = None,
|
||||
verb_cancel: str | None = "",
|
||||
hold: bool = False,
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
) -> Awaitable[None]:
|
||||
verb = verb or TR.buttons__confirm # def_arg
|
||||
return confirm_action(
|
||||
br_type,
|
||||
br_name,
|
||||
title,
|
||||
data,
|
||||
description,
|
||||
@ -342,14 +344,14 @@ def _placeholder_confirm(
|
||||
|
||||
|
||||
async def get_bool(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
data: str | None = None,
|
||||
description: str | None = None,
|
||||
verb: str | None = None,
|
||||
verb_cancel: str | None = "",
|
||||
hold: bool = False,
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
) -> bool:
|
||||
verb = verb or TR.buttons__confirm # def_arg
|
||||
result = await interact(
|
||||
@ -363,7 +365,7 @@ async def get_bool(
|
||||
hold=hold,
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
|
||||
@ -379,7 +381,7 @@ async def raise_if_not_confirmed(
|
||||
|
||||
|
||||
def confirm_action(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
action: str | None = None,
|
||||
description: str | None = None,
|
||||
@ -391,7 +393,7 @@ def confirm_action(
|
||||
hold_danger: bool = False,
|
||||
reverse: bool = False,
|
||||
exc: ExceptionType = ActionCancelled,
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
prompt_screen: bool = False,
|
||||
prompt_title: str | None = None,
|
||||
) -> Awaitable[None]:
|
||||
@ -413,7 +415,7 @@ def confirm_action(
|
||||
reverse=reverse,
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
),
|
||||
exc,
|
||||
@ -421,7 +423,7 @@ def confirm_action(
|
||||
|
||||
|
||||
def confirm_single(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
description: str,
|
||||
description_param: str | None = None,
|
||||
@ -436,7 +438,7 @@ def confirm_single(
|
||||
|
||||
begin, _separator, end = description.partition(template_str)
|
||||
return confirm_action(
|
||||
br_type,
|
||||
br_name,
|
||||
title,
|
||||
description=begin + description_param + end,
|
||||
verb=verb or TR.buttons__confirm,
|
||||
@ -477,19 +479,19 @@ async def show_wallet_created_success() -> None:
|
||||
|
||||
|
||||
async def prompt_backup() -> bool:
|
||||
br_type = "backup_device"
|
||||
br_name = "backup_device"
|
||||
br_code = ButtonRequestType.ResetDevice
|
||||
|
||||
result = await interact(
|
||||
RustLayout(trezorui2.confirm_backup()),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
if result is CONFIRMED:
|
||||
return True
|
||||
|
||||
return await get_bool(
|
||||
br_type,
|
||||
br_name,
|
||||
TR.backup__title_skip,
|
||||
description=TR.backup__want_to_skip,
|
||||
verb=TR.buttons__back_up,
|
||||
@ -546,7 +548,7 @@ async def show_address(
|
||||
multisig_index: int | None = None,
|
||||
xpubs: Sequence[str] = (),
|
||||
mismatch_title: str | None = None,
|
||||
br_type: str = "show_address",
|
||||
br_name: str = "show_address",
|
||||
br_code: ButtonRequestType = ButtonRequestType.Address,
|
||||
chunkify: bool = False,
|
||||
) -> None:
|
||||
@ -570,7 +572,7 @@ async def show_address(
|
||||
if send_button_request:
|
||||
send_button_request = False
|
||||
await button_request(
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
pages=layout.page_count(),
|
||||
)
|
||||
@ -624,7 +626,7 @@ def show_pubkey(
|
||||
account: str | None = None,
|
||||
path: str | None = None,
|
||||
mismatch_title: str | None = None,
|
||||
br_type: str = "show_pubkey",
|
||||
br_name: str = "show_pubkey",
|
||||
) -> Awaitable[None]:
|
||||
title = title or TR.address__public_key # def_arg
|
||||
mismatch_title = mismatch_title or TR.addr_mismatch__key_mismatch # def_arg
|
||||
@ -633,7 +635,7 @@ def show_pubkey(
|
||||
title=title,
|
||||
account=account,
|
||||
path=path,
|
||||
br_type=br_type,
|
||||
br_name=br_name,
|
||||
br_code=ButtonRequestType.PublicKey,
|
||||
mismatch_title=mismatch_title,
|
||||
chunkify=False,
|
||||
@ -641,7 +643,7 @@ def show_pubkey(
|
||||
|
||||
|
||||
def _show_modal(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
header: str,
|
||||
subheader: str | None,
|
||||
content: str,
|
||||
@ -651,7 +653,7 @@ def _show_modal(
|
||||
exc: ExceptionType = ActionCancelled,
|
||||
) -> Awaitable[None]:
|
||||
return confirm_action(
|
||||
br_type,
|
||||
br_name,
|
||||
header,
|
||||
subheader,
|
||||
content,
|
||||
@ -663,7 +665,7 @@ def _show_modal(
|
||||
|
||||
|
||||
async def show_error_and_raise(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
content: str,
|
||||
subheader: str | None = None,
|
||||
button: str | None = None,
|
||||
@ -671,17 +673,17 @@ async def show_error_and_raise(
|
||||
) -> NoReturn:
|
||||
button = button or TR.buttons__try_again # def_arg
|
||||
await show_warning(
|
||||
br_type,
|
||||
br_name,
|
||||
subheader or "",
|
||||
content,
|
||||
button=button,
|
||||
br_code=BR_TYPE_OTHER,
|
||||
br_code=BR_CODE_OTHER,
|
||||
)
|
||||
raise exc
|
||||
|
||||
|
||||
def show_warning(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
content: str,
|
||||
subheader: str | None = None,
|
||||
button: str | None = None,
|
||||
@ -706,13 +708,13 @@ def show_warning(
|
||||
description=subheader or "",
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
|
||||
|
||||
def show_success(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
content: str,
|
||||
subheader: str | None = None,
|
||||
button: str | None = None,
|
||||
@ -734,7 +736,7 @@ def show_success(
|
||||
title = ""
|
||||
|
||||
return _show_modal(
|
||||
br_type,
|
||||
br_name,
|
||||
title,
|
||||
subheader,
|
||||
content,
|
||||
@ -794,7 +796,7 @@ async def confirm_output(
|
||||
return
|
||||
|
||||
|
||||
def tutorial(br_code: ButtonRequestType = BR_TYPE_OTHER) -> Awaitable[None]:
|
||||
def tutorial(br_code: ButtonRequestType = BR_CODE_OTHER) -> Awaitable[None]:
|
||||
"""Showing users how to interact with the device."""
|
||||
return raise_if_not_confirmed(
|
||||
interact(
|
||||
@ -824,8 +826,8 @@ async def should_show_more(
|
||||
title: str,
|
||||
para: Iterable[tuple[int, str]],
|
||||
button_text: str | None = None,
|
||||
br_type: str = "should_show_more",
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_name: str = "should_show_more",
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
confirm: str | bytes | None = None,
|
||||
verb_cancel: str | None = None,
|
||||
) -> bool:
|
||||
@ -848,7 +850,7 @@ async def should_show_more(
|
||||
info_button=button_text, # unused on TR
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
|
||||
@ -862,14 +864,14 @@ async def should_show_more(
|
||||
|
||||
|
||||
def confirm_blob(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
data: bytes | str,
|
||||
description: str | None = None,
|
||||
verb: str | None = None,
|
||||
verb_cancel: str | None = "", # icon
|
||||
hold: bool = False,
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
ask_pagination: bool = False,
|
||||
chunkify: bool = False,
|
||||
prompt_screen: bool = True,
|
||||
@ -891,21 +893,21 @@ def confirm_blob(
|
||||
if ask_pagination and layout.page_count() > 1:
|
||||
assert not hold
|
||||
return _confirm_ask_pagination(
|
||||
br_type, title, data, description or "", verb_cancel, br_code
|
||||
br_name, title, data, description or "", verb_cancel, br_code
|
||||
)
|
||||
|
||||
else:
|
||||
return raise_if_not_confirmed(
|
||||
interact(
|
||||
layout,
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
async def _confirm_ask_pagination(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
data: bytes | str,
|
||||
description: str,
|
||||
@ -923,7 +925,7 @@ async def _confirm_ask_pagination(
|
||||
title,
|
||||
para=[(ui.NORMAL, description), (ui.MONO, data)],
|
||||
verb_cancel=verb_cancel,
|
||||
br_type=br_type,
|
||||
br_name=br_name,
|
||||
br_code=br_code,
|
||||
):
|
||||
return
|
||||
@ -942,7 +944,7 @@ async def _confirm_ask_pagination(
|
||||
else:
|
||||
paginated.request_complete_repaint()
|
||||
|
||||
result = await interact(paginated, br_type, br_code)
|
||||
result = await interact(paginated, br_name, br_code)
|
||||
assert result in (CONFIRMED, CANCELLED)
|
||||
|
||||
assert False
|
||||
@ -952,11 +954,11 @@ def confirm_address(
|
||||
title: str,
|
||||
address: str,
|
||||
description: str | None = None,
|
||||
br_type: str = "confirm_address",
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_name: str = "confirm_address",
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
) -> Awaitable[None]:
|
||||
return confirm_blob(
|
||||
br_type,
|
||||
br_name,
|
||||
title,
|
||||
address,
|
||||
description,
|
||||
@ -965,14 +967,14 @@ def confirm_address(
|
||||
|
||||
|
||||
def confirm_text(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
data: str,
|
||||
description: str | None = None,
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
) -> Awaitable[None]:
|
||||
return _placeholder_confirm(
|
||||
br_type,
|
||||
br_name,
|
||||
title,
|
||||
data,
|
||||
description,
|
||||
@ -984,12 +986,12 @@ def confirm_amount(
|
||||
title: str,
|
||||
amount: str,
|
||||
description: str | None = None,
|
||||
br_type: str = "confirm_amount",
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_name: str = "confirm_amount",
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
) -> Awaitable[None]:
|
||||
description = description or f"{TR.words__amount}:" # def_arg
|
||||
return confirm_blob(
|
||||
br_type,
|
||||
br_name,
|
||||
title,
|
||||
amount,
|
||||
description,
|
||||
@ -998,7 +1000,7 @@ def confirm_amount(
|
||||
|
||||
|
||||
def confirm_properties(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
props: Iterable[PropertyType],
|
||||
hold: bool = False,
|
||||
@ -1025,7 +1027,7 @@ def confirm_properties(
|
||||
hold=hold,
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
)
|
||||
@ -1035,8 +1037,8 @@ async def confirm_value(
|
||||
title: str,
|
||||
value: str,
|
||||
description: str,
|
||||
br_type: str,
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_name: str,
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
*,
|
||||
verb: str | None = None,
|
||||
hold: bool = False,
|
||||
@ -1060,7 +1062,7 @@ async def confirm_value(
|
||||
hold=hold,
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
)
|
||||
@ -1083,7 +1085,7 @@ async def confirm_value(
|
||||
if send_button_request:
|
||||
send_button_request = False
|
||||
await button_request(
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
should_show_more_layout.page_count(),
|
||||
)
|
||||
@ -1120,7 +1122,7 @@ def confirm_total(
|
||||
fee_label: str | None = None,
|
||||
source_account: str | None = None,
|
||||
source_account_path: str | None = None,
|
||||
br_type: str = "confirm_total",
|
||||
br_name: str = "confirm_total",
|
||||
br_code: ButtonRequestType = ButtonRequestType.SignTx,
|
||||
) -> Awaitable[None]:
|
||||
total_label = total_label or TR.send__total_amount_colon # def_arg
|
||||
@ -1138,7 +1140,7 @@ def confirm_total(
|
||||
fee_label=fee_label, # type: ignore [No parameter named]
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
)
|
||||
@ -1156,7 +1158,7 @@ if not utils.BITCOIN_ONLY:
|
||||
address_title: str,
|
||||
info_items: Iterable[tuple[str, str]],
|
||||
chunkify: bool = False,
|
||||
br_type: str = "confirm_ethereum_staking_tx",
|
||||
br_name: str = "confirm_ethereum_staking_tx",
|
||||
br_code: ButtonRequestType = ButtonRequestType.SignTx,
|
||||
) -> None:
|
||||
# intro
|
||||
@ -1164,7 +1166,7 @@ if not utils.BITCOIN_ONLY:
|
||||
title,
|
||||
intro_question,
|
||||
"",
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
verb=verb,
|
||||
info_items=((address_title, address),),
|
||||
@ -1190,7 +1192,7 @@ if not utils.BITCOIN_ONLY:
|
||||
cancel_cross=True,
|
||||
)
|
||||
),
|
||||
br_type=br_type,
|
||||
br_name=br_name,
|
||||
br_code=br_code,
|
||||
)
|
||||
)
|
||||
@ -1201,7 +1203,7 @@ if not utils.BITCOIN_ONLY:
|
||||
items: Iterable[tuple[str, str]],
|
||||
amount_title: str | None = None,
|
||||
fee_title: str | None = None,
|
||||
br_type: str = "confirm_solana_tx",
|
||||
br_name: str = "confirm_solana_tx",
|
||||
br_code: ButtonRequestType = ButtonRequestType.SignTx,
|
||||
) -> Awaitable[None]:
|
||||
amount_title = (
|
||||
@ -1220,7 +1222,7 @@ if not utils.BITCOIN_ONLY:
|
||||
cancel_cross=True,
|
||||
)
|
||||
),
|
||||
br_type=br_type,
|
||||
br_name=br_name,
|
||||
br_code=br_code,
|
||||
)
|
||||
)
|
||||
@ -1230,7 +1232,7 @@ if not utils.BITCOIN_ONLY:
|
||||
total_amount: str,
|
||||
maximum_fee: str,
|
||||
items: Iterable[tuple[str, str]],
|
||||
br_type: str = "confirm_ethereum_tx",
|
||||
br_name: str = "confirm_ethereum_tx",
|
||||
br_code: ButtonRequestType = ButtonRequestType.SignTx,
|
||||
chunkify: bool = False,
|
||||
) -> None:
|
||||
@ -1247,7 +1249,7 @@ if not utils.BITCOIN_ONLY:
|
||||
while True:
|
||||
# Allowing going back and forth between recipient and summary/details
|
||||
await confirm_blob(
|
||||
br_type,
|
||||
br_name,
|
||||
TR.words__recipient,
|
||||
recipient,
|
||||
verb=TR.buttons__continue,
|
||||
@ -1259,7 +1261,7 @@ if not utils.BITCOIN_ONLY:
|
||||
await raise_if_not_confirmed(
|
||||
interact(
|
||||
summary_layout,
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
)
|
||||
@ -1284,7 +1286,7 @@ def confirm_joint_total(spending_amount: str, total_amount: str) -> Awaitable[No
|
||||
|
||||
|
||||
def confirm_metadata(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
content: str,
|
||||
param: str | None = None,
|
||||
@ -1292,7 +1294,7 @@ def confirm_metadata(
|
||||
hold: bool = False,
|
||||
) -> Awaitable[None]:
|
||||
return _placeholder_confirm(
|
||||
br_type,
|
||||
br_name,
|
||||
title,
|
||||
description=content.format(param),
|
||||
hold=hold,
|
||||
@ -1394,7 +1396,7 @@ def confirm_coinjoin(max_rounds: int, max_fee_per_vbyte: str) -> Awaitable[None]
|
||||
)
|
||||
),
|
||||
"coinjoin_final",
|
||||
BR_TYPE_OTHER,
|
||||
BR_CODE_OTHER,
|
||||
)
|
||||
)
|
||||
|
||||
@ -1412,7 +1414,7 @@ def confirm_sign_identity(
|
||||
"confirm_sign_identity",
|
||||
f"{TR.words__sign} {proto}",
|
||||
text,
|
||||
br_code=BR_TYPE_OTHER,
|
||||
br_code=BR_CODE_OTHER,
|
||||
)
|
||||
|
||||
|
||||
@ -1424,25 +1426,25 @@ async def confirm_signverify(
|
||||
account: str | None = None,
|
||||
chunkify: bool = False,
|
||||
) -> None:
|
||||
br_type = "verify_message" if verify else "sign_message"
|
||||
br_name = "verify_message" if verify else "sign_message"
|
||||
|
||||
# Allowing to go back from the second screen
|
||||
while True:
|
||||
await confirm_blob(
|
||||
br_type,
|
||||
br_name,
|
||||
TR.sign_message__confirm_address,
|
||||
address,
|
||||
verb=TR.buttons__continue,
|
||||
br_code=BR_TYPE_OTHER,
|
||||
br_code=BR_CODE_OTHER,
|
||||
)
|
||||
|
||||
try:
|
||||
await confirm_blob(
|
||||
br_type,
|
||||
br_name,
|
||||
TR.sign_message__confirm_message,
|
||||
message,
|
||||
verb_cancel="^",
|
||||
br_code=BR_TYPE_OTHER,
|
||||
br_code=BR_CODE_OTHER,
|
||||
ask_pagination=True,
|
||||
)
|
||||
except ActionCancelled:
|
||||
@ -1538,27 +1540,27 @@ async def request_pin_on_device(
|
||||
|
||||
|
||||
def confirm_reenter_pin(is_wipe_code: bool = False) -> Awaitable[None]:
|
||||
br_type = "reenter_wipe_code" if is_wipe_code else "reenter_pin"
|
||||
br_name = "reenter_wipe_code" if is_wipe_code else "reenter_pin"
|
||||
title = TR.wipe_code__title_check if is_wipe_code else TR.pin__title_check_pin
|
||||
description = (
|
||||
TR.wipe_code__reenter_to_confirm if is_wipe_code else TR.pin__reenter_to_confirm
|
||||
)
|
||||
return confirm_action(
|
||||
br_type,
|
||||
br_name,
|
||||
title,
|
||||
description=description,
|
||||
verb=TR.buttons__continue,
|
||||
verb_cancel=None,
|
||||
br_code=BR_TYPE_OTHER,
|
||||
br_code=BR_CODE_OTHER,
|
||||
)
|
||||
|
||||
|
||||
def _confirm_multiple_pages_texts(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
items: list[str],
|
||||
verb: str,
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
) -> Awaitable[None]:
|
||||
return raise_if_not_confirmed(
|
||||
interact(
|
||||
@ -1569,7 +1571,7 @@ def _confirm_multiple_pages_texts(
|
||||
items=items,
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
)
|
||||
@ -1583,7 +1585,7 @@ def pin_mismatch_popup(is_wipe_code: bool = False) -> Awaitable[None]:
|
||||
description,
|
||||
TR.pin__please_check_again,
|
||||
TR.buttons__check_again,
|
||||
BR_TYPE_OTHER,
|
||||
BR_CODE_OTHER,
|
||||
)
|
||||
|
||||
|
||||
@ -1594,19 +1596,19 @@ def wipe_code_same_as_pin_popup() -> Awaitable[None]:
|
||||
description=TR.wipe_code__diff_from_pin,
|
||||
verb=TR.buttons__try_again,
|
||||
verb_cancel=None,
|
||||
br_code=BR_TYPE_OTHER,
|
||||
br_code=BR_CODE_OTHER,
|
||||
)
|
||||
|
||||
|
||||
async def confirm_set_new_pin(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
description: str,
|
||||
information: str,
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
) -> None:
|
||||
await _confirm_multiple_pages_texts(
|
||||
br_type,
|
||||
br_name,
|
||||
title,
|
||||
[description, information],
|
||||
TR.buttons__turn_on,
|
||||
@ -1614,7 +1616,7 @@ async def confirm_set_new_pin(
|
||||
)
|
||||
|
||||
# Not showing extra info for wipe code
|
||||
if "wipe_code" in br_type:
|
||||
if "wipe_code" in br_name:
|
||||
return
|
||||
|
||||
# Additional information for the user to know about PIN
|
||||
@ -1623,7 +1625,7 @@ async def confirm_set_new_pin(
|
||||
TR.pin__cursor_will_change,
|
||||
]
|
||||
await _confirm_multiple_pages_texts(
|
||||
br_type,
|
||||
br_name,
|
||||
title,
|
||||
next_info,
|
||||
TR.buttons__continue,
|
||||
@ -1640,6 +1642,6 @@ def confirm_firmware_update(description: str, fingerprint: str) -> Awaitable[Non
|
||||
)
|
||||
),
|
||||
"firmware_update",
|
||||
BR_TYPE_OTHER,
|
||||
BR_CODE_OTHER,
|
||||
)
|
||||
)
|
||||
|
@ -107,11 +107,11 @@ async def continue_recovery(
|
||||
|
||||
|
||||
async def show_recovery_warning(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
content: str,
|
||||
subheader: str | None = None,
|
||||
button: str | None = None,
|
||||
br_code: ButtonRequestType = ButtonRequestType.Warning,
|
||||
) -> None:
|
||||
button = button or TR.buttons__try_again # def_arg
|
||||
await show_warning(br_type, content, subheader, button, br_code)
|
||||
await show_warning(br_name, content, subheader, button, br_code)
|
||||
|
@ -17,7 +17,7 @@ async def show_share_words(
|
||||
group_index: int | None = None,
|
||||
) -> None:
|
||||
# Showing words, asking for write down confirmation and preparing for check
|
||||
br_type = "backup_words"
|
||||
br_name = "backup_words"
|
||||
br_code = ButtonRequestType.ResetDevice
|
||||
|
||||
if share_index is None:
|
||||
@ -36,7 +36,7 @@ async def show_share_words(
|
||||
# (by sending CANCELLED)
|
||||
while True:
|
||||
await confirm_action(
|
||||
br_type,
|
||||
br_name,
|
||||
title,
|
||||
description=TR.reset__write_down_words_template.format(len(share_words)),
|
||||
verb=TR.buttons__show_words,
|
||||
@ -50,14 +50,14 @@ async def show_share_words(
|
||||
share_words=share_words, # type: ignore [No parameter named "share_words"]
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
if result is CONFIRMED:
|
||||
break
|
||||
|
||||
await confirm_action(
|
||||
br_type,
|
||||
br_name,
|
||||
check_title,
|
||||
description=TR.reset__select_correct_word,
|
||||
verb=TR.buttons__continue,
|
||||
@ -290,7 +290,7 @@ async def show_success_backup() -> None:
|
||||
|
||||
|
||||
async def show_reset_warning(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
content: str,
|
||||
subheader: str | None = None,
|
||||
button: str | None = None,
|
||||
@ -299,7 +299,7 @@ async def show_reset_warning(
|
||||
button = button or TR.buttons__try_again # def_arg
|
||||
|
||||
await show_warning(
|
||||
br_type,
|
||||
br_name,
|
||||
subheader or "",
|
||||
content,
|
||||
button,
|
||||
|
@ -22,7 +22,7 @@ else:
|
||||
T = 0
|
||||
|
||||
|
||||
BR_TYPE_OTHER = ButtonRequestType.Other # global_import_cache
|
||||
BR_CODE_OTHER = ButtonRequestType.Other # global_import_cache
|
||||
|
||||
CONFIRMED = trezorui2.CONFIRMED
|
||||
CANCELLED = trezorui2.CANCELLED
|
||||
@ -254,17 +254,19 @@ class RustLayout(LayoutParentType[T]):
|
||||
|
||||
async def handle_usb(self, ctx: context.Context):
|
||||
while True:
|
||||
br_code, br_type, page_count = await loop.race(
|
||||
br_code, br_name, page_count = await loop.race(
|
||||
ctx.read(()), self.br_chan.take()
|
||||
)
|
||||
log.debug(__name__, "ButtonRequest.type=%s", br_type)
|
||||
await ctx.call(ButtonRequest(code=br_code, pages=page_count), ButtonAck)
|
||||
log.debug(__name__, "ButtonRequest.name=%s", br_name)
|
||||
await ctx.call(
|
||||
ButtonRequest(code=br_code, pages=page_count, name=br_name), ButtonAck
|
||||
)
|
||||
|
||||
def _send_button_request(self):
|
||||
res = self.layout.button_request()
|
||||
if res is not None:
|
||||
br_code, br_type = res
|
||||
self.br_chan.publish((br_code, br_type, self.layout.page_count()))
|
||||
br_code, br_name = res
|
||||
self.br_chan.publish((br_code, br_name, self.layout.page_count()))
|
||||
|
||||
|
||||
def draw_simple(layout: trezorui2.LayoutObj[Any]) -> None:
|
||||
@ -288,7 +290,7 @@ async def raise_if_not_confirmed(
|
||||
|
||||
|
||||
def confirm_action(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
action: str | None = None,
|
||||
description: str | None = None,
|
||||
@ -300,7 +302,7 @@ def confirm_action(
|
||||
hold_danger: bool = False,
|
||||
reverse: bool = False,
|
||||
exc: ExceptionType = ActionCancelled,
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
prompt_screen: bool = False,
|
||||
prompt_title: str | None = None,
|
||||
) -> Awaitable[None]:
|
||||
@ -322,7 +324,7 @@ def confirm_action(
|
||||
reverse=reverse,
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
),
|
||||
exc,
|
||||
@ -330,7 +332,7 @@ def confirm_action(
|
||||
|
||||
|
||||
def confirm_single(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
description: str,
|
||||
description_param: str | None = None,
|
||||
@ -353,7 +355,7 @@ def confirm_single(
|
||||
verb=verb,
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
ButtonRequestType.ProtectCall,
|
||||
)
|
||||
)
|
||||
@ -480,7 +482,7 @@ async def show_address(
|
||||
xpubs: Sequence[str] = (),
|
||||
mismatch_title: str | None = None,
|
||||
details_title: str | None = None,
|
||||
br_type: str = "show_address",
|
||||
br_name: str = "show_address",
|
||||
br_code: ButtonRequestType = ButtonRequestType.Address,
|
||||
chunkify: bool = False,
|
||||
) -> None:
|
||||
@ -509,7 +511,7 @@ async def show_address(
|
||||
if send_button_request:
|
||||
send_button_request = False
|
||||
await button_request(
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
pages=layout.page_count(),
|
||||
)
|
||||
@ -560,7 +562,7 @@ def show_pubkey(
|
||||
account: str | None = None,
|
||||
path: str | None = None,
|
||||
mismatch_title: str | None = None,
|
||||
br_type: str = "show_pubkey",
|
||||
br_name: str = "show_pubkey",
|
||||
) -> Awaitable[None]:
|
||||
title = title or TR.address__public_key # def_arg
|
||||
mismatch_title = mismatch_title or TR.addr_mismatch__key_mismatch # def_arg
|
||||
@ -569,7 +571,7 @@ def show_pubkey(
|
||||
title=title,
|
||||
account=account,
|
||||
path=path,
|
||||
br_type=br_type,
|
||||
br_name=br_name,
|
||||
br_code=ButtonRequestType.PublicKey,
|
||||
mismatch_title=mismatch_title,
|
||||
chunkify=False,
|
||||
@ -577,7 +579,7 @@ def show_pubkey(
|
||||
|
||||
|
||||
async def show_error_and_raise(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
content: str,
|
||||
subheader: str | None = None,
|
||||
button: str | None = None,
|
||||
@ -593,14 +595,14 @@ async def show_error_and_raise(
|
||||
allow_cancel=False,
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
BR_TYPE_OTHER,
|
||||
br_name,
|
||||
BR_CODE_OTHER,
|
||||
)
|
||||
raise exc
|
||||
|
||||
|
||||
def show_warning(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
content: str,
|
||||
subheader: str | None = None,
|
||||
button: str | None = None,
|
||||
@ -616,14 +618,14 @@ def show_warning(
|
||||
button=button,
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def show_success(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
content: str,
|
||||
subheader: str | None = None,
|
||||
button: str | None = None,
|
||||
@ -639,7 +641,7 @@ def show_success(
|
||||
allow_cancel=False,
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
ButtonRequestType.Success,
|
||||
)
|
||||
)
|
||||
@ -746,8 +748,8 @@ async def should_show_more(
|
||||
title: str,
|
||||
para: Iterable[tuple[int, str | bytes]],
|
||||
button_text: str | None = None,
|
||||
br_type: str = "should_show_more",
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_name: str = "should_show_more",
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
confirm: str | bytes | None = None,
|
||||
) -> bool:
|
||||
"""Return True if the user wants to show more (they click a special button)
|
||||
@ -768,7 +770,7 @@ async def should_show_more(
|
||||
info_button=button_text,
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
|
||||
@ -782,7 +784,7 @@ async def should_show_more(
|
||||
|
||||
|
||||
async def _confirm_ask_pagination(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
data: bytes | str,
|
||||
description: str,
|
||||
@ -798,7 +800,7 @@ async def _confirm_ask_pagination(
|
||||
if not await should_show_more(
|
||||
title,
|
||||
para=[(ui.NORMAL, description), (ui.MONO, data)],
|
||||
br_type=br_type,
|
||||
br_name=br_name,
|
||||
br_code=br_code,
|
||||
):
|
||||
return
|
||||
@ -814,21 +816,21 @@ async def _confirm_ask_pagination(
|
||||
else:
|
||||
paginated.request_complete_repaint()
|
||||
|
||||
result = await interact(paginated, br_type, br_code)
|
||||
result = await interact(paginated, br_name, br_code)
|
||||
assert result in (CONFIRMED, CANCELLED)
|
||||
|
||||
assert False
|
||||
|
||||
|
||||
def confirm_blob(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
data: bytes | str,
|
||||
description: str | None = None,
|
||||
verb: str | None = None,
|
||||
verb_cancel: str | None = None,
|
||||
hold: bool = False,
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
ask_pagination: bool = False,
|
||||
chunkify: bool = False,
|
||||
prompt_screen: bool = True,
|
||||
@ -849,13 +851,13 @@ def confirm_blob(
|
||||
|
||||
if ask_pagination and layout.page_count() > 1:
|
||||
assert not hold
|
||||
return _confirm_ask_pagination(br_type, title, data, description or "", br_code)
|
||||
return _confirm_ask_pagination(br_name, title, data, description or "", br_code)
|
||||
|
||||
else:
|
||||
return raise_if_not_confirmed(
|
||||
interact(
|
||||
layout,
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
)
|
||||
@ -865,31 +867,31 @@ def confirm_address(
|
||||
title: str,
|
||||
address: str,
|
||||
description: str | None = None,
|
||||
br_type: str = "confirm_address",
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_name: str = "confirm_address",
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
) -> Awaitable[None]:
|
||||
return confirm_value(
|
||||
title,
|
||||
address,
|
||||
description or "",
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
verb=TR.buttons__confirm,
|
||||
)
|
||||
|
||||
|
||||
def confirm_text(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
data: str,
|
||||
description: str | None = None,
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
) -> Awaitable[None]:
|
||||
return confirm_value(
|
||||
title,
|
||||
data,
|
||||
description or "",
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
verb=TR.buttons__confirm,
|
||||
)
|
||||
@ -899,15 +901,15 @@ def confirm_amount(
|
||||
title: str,
|
||||
amount: str,
|
||||
description: str | None = None,
|
||||
br_type: str = "confirm_amount",
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_name: str = "confirm_amount",
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
) -> Awaitable[None]:
|
||||
description = description or f"{TR.words__amount}:" # def_arg
|
||||
return confirm_value(
|
||||
title,
|
||||
amount,
|
||||
description,
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
verb=TR.buttons__confirm,
|
||||
)
|
||||
@ -917,8 +919,8 @@ def confirm_value(
|
||||
title: str,
|
||||
value: str,
|
||||
description: str,
|
||||
br_type: str,
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_name: str,
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
*,
|
||||
verb: str | None = None,
|
||||
subtitle: str | None = None,
|
||||
@ -957,14 +959,14 @@ def confirm_value(
|
||||
)
|
||||
),
|
||||
info_layout,
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def confirm_properties(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
props: Iterable[PropertyType],
|
||||
hold: bool = False,
|
||||
@ -982,7 +984,7 @@ def confirm_properties(
|
||||
hold=hold,
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
)
|
||||
@ -997,7 +999,7 @@ def confirm_total(
|
||||
source_account: str | None = None,
|
||||
source_account_path: str | None = None,
|
||||
fee_rate_amount: str | None = None,
|
||||
br_type: str = "confirm_total",
|
||||
br_name: str = "confirm_total",
|
||||
br_code: ButtonRequestType = ButtonRequestType.SignTx,
|
||||
) -> Awaitable[None]:
|
||||
title = title or TR.words__title_summary # def_arg
|
||||
@ -1018,7 +1020,7 @@ def confirm_total(
|
||||
items,
|
||||
TR.words__title_summary,
|
||||
info_items=info_items,
|
||||
br_type=br_type,
|
||||
br_name=br_name,
|
||||
br_code=br_code,
|
||||
)
|
||||
|
||||
@ -1028,7 +1030,7 @@ def confirm_summary(
|
||||
title: str | None = None,
|
||||
info_items: Iterable[tuple[str, str]] | None = None,
|
||||
info_title: str | None = None,
|
||||
br_type: str = "confirm_total",
|
||||
br_name: str = "confirm_total",
|
||||
br_code: ButtonRequestType = ButtonRequestType.SignTx,
|
||||
) -> Awaitable[None]:
|
||||
title = title or TR.words__title_summary # def_arg
|
||||
@ -1048,7 +1050,7 @@ def confirm_summary(
|
||||
)
|
||||
)
|
||||
return raise_if_not_confirmed(
|
||||
with_info(total_layout, info_layout, br_type, br_code)
|
||||
with_info(total_layout, info_layout, br_name, br_code)
|
||||
)
|
||||
|
||||
|
||||
@ -1059,7 +1061,7 @@ if not utils.BITCOIN_ONLY:
|
||||
total_amount: str,
|
||||
maximum_fee: str,
|
||||
items: Iterable[tuple[str, str]],
|
||||
br_type: str = "confirm_ethereum_tx",
|
||||
br_name: str = "confirm_ethereum_tx",
|
||||
br_code: ButtonRequestType = ButtonRequestType.SignTx,
|
||||
chunkify: bool = False,
|
||||
) -> None:
|
||||
@ -1084,7 +1086,7 @@ if not utils.BITCOIN_ONLY:
|
||||
while True:
|
||||
# Allowing going back and forth between recipient and summary/details
|
||||
await confirm_blob(
|
||||
br_type,
|
||||
br_name,
|
||||
TR.words__recipient,
|
||||
recipient,
|
||||
verb=TR.buttons__continue,
|
||||
@ -1094,7 +1096,7 @@ if not utils.BITCOIN_ONLY:
|
||||
try:
|
||||
total_layout.request_complete_repaint()
|
||||
await raise_if_not_confirmed(
|
||||
with_info(total_layout, info_layout, br_type, br_code)
|
||||
with_info(total_layout, info_layout, br_name, br_code)
|
||||
)
|
||||
break
|
||||
except ActionCancelled:
|
||||
@ -1110,7 +1112,7 @@ if not utils.BITCOIN_ONLY:
|
||||
address_title: str,
|
||||
info_items: Iterable[tuple[str, str]],
|
||||
chunkify: bool = False,
|
||||
br_type: str = "confirm_ethereum_staking_tx",
|
||||
br_name: str = "confirm_ethereum_staking_tx",
|
||||
br_code: ButtonRequestType = ButtonRequestType.SignTx,
|
||||
) -> None:
|
||||
# intro
|
||||
@ -1118,7 +1120,7 @@ if not utils.BITCOIN_ONLY:
|
||||
title,
|
||||
intro_question,
|
||||
"",
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
verb=verb,
|
||||
value_text_mono=False,
|
||||
@ -1140,7 +1142,7 @@ if not utils.BITCOIN_ONLY:
|
||||
title=title,
|
||||
info_title=TR.confirm_total__title_fee,
|
||||
info_items=info_items,
|
||||
br_type=br_type,
|
||||
br_name=br_name,
|
||||
br_code=br_code,
|
||||
)
|
||||
|
||||
@ -1150,7 +1152,7 @@ if not utils.BITCOIN_ONLY:
|
||||
items: Iterable[tuple[str, str]],
|
||||
amount_title: str | None = None,
|
||||
fee_title: str | None = None,
|
||||
br_type: str = "confirm_solana_tx",
|
||||
br_name: str = "confirm_solana_tx",
|
||||
br_code: ButtonRequestType = ButtonRequestType.SignTx,
|
||||
) -> Awaitable[None]:
|
||||
amount_title = (
|
||||
@ -1160,7 +1162,7 @@ if not utils.BITCOIN_ONLY:
|
||||
return confirm_summary(
|
||||
((amount_title, amount), (fee_title, fee)),
|
||||
info_items=items,
|
||||
br_type=br_type,
|
||||
br_name=br_name,
|
||||
br_code=br_code,
|
||||
)
|
||||
|
||||
@ -1184,7 +1186,7 @@ def confirm_joint_total(spending_amount: str, total_amount: str) -> Awaitable[No
|
||||
|
||||
|
||||
def confirm_metadata(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
content: str,
|
||||
param: str | None = None,
|
||||
@ -1194,7 +1196,7 @@ def confirm_metadata(
|
||||
) -> Awaitable[None]:
|
||||
verb = verb or TR.buttons__continue # def_arg
|
||||
return confirm_action(
|
||||
br_type,
|
||||
br_name,
|
||||
title=title,
|
||||
action="",
|
||||
description=content,
|
||||
@ -1268,10 +1270,10 @@ async def confirm_modify_output(
|
||||
async def with_info(
|
||||
main_layout: RustLayout[T],
|
||||
info_layout: RustLayout[Any],
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
br_code: ButtonRequestType,
|
||||
) -> T:
|
||||
await button_request(br_type, br_code, pages=main_layout.page_count())
|
||||
await button_request(br_name, br_code, pages=main_layout.page_count())
|
||||
|
||||
while True:
|
||||
result = await main_layout
|
||||
@ -1326,7 +1328,7 @@ def confirm_coinjoin(max_rounds: int, max_fee_per_vbyte: str) -> Awaitable[None]
|
||||
)
|
||||
),
|
||||
"coinjoin_final",
|
||||
BR_TYPE_OTHER,
|
||||
BR_CODE_OTHER,
|
||||
)
|
||||
)
|
||||
|
||||
@ -1340,7 +1342,7 @@ def confirm_sign_identity(
|
||||
f"{TR.words__sign} {proto}",
|
||||
identity,
|
||||
challenge_visual + "\n" if challenge_visual else "",
|
||||
br_code=BR_TYPE_OTHER,
|
||||
br_code=BR_CODE_OTHER,
|
||||
)
|
||||
|
||||
|
||||
@ -1354,10 +1356,10 @@ async def confirm_signverify(
|
||||
) -> None:
|
||||
if verify:
|
||||
address_title = TR.sign_message__verify_address
|
||||
br_type = "verify_message"
|
||||
br_name = "verify_message"
|
||||
else:
|
||||
address_title = TR.sign_message__confirm_address
|
||||
br_type = "sign_message"
|
||||
br_name = "sign_message"
|
||||
|
||||
address_layout = RustLayout(
|
||||
trezorui2.confirm_address(
|
||||
@ -1403,7 +1405,7 @@ async def confirm_signverify(
|
||||
|
||||
while True:
|
||||
result = await with_info(
|
||||
address_layout, info_layout, br_type, br_code=BR_TYPE_OTHER
|
||||
address_layout, info_layout, br_name, br_code=BR_CODE_OTHER
|
||||
)
|
||||
if result is not CONFIRMED:
|
||||
result = await RustLayout(
|
||||
@ -1418,7 +1420,7 @@ async def confirm_signverify(
|
||||
continue
|
||||
|
||||
message_layout.request_complete_repaint()
|
||||
result = await interact(message_layout, br_type, BR_TYPE_OTHER)
|
||||
result = await interact(message_layout, br_name, BR_CODE_OTHER)
|
||||
if result is CONFIRMED:
|
||||
break
|
||||
|
||||
@ -1520,7 +1522,7 @@ async def confirm_reenter_pin(is_wipe_code: bool = False) -> None:
|
||||
|
||||
|
||||
async def pin_mismatch_popup(is_wipe_code: bool = False) -> None:
|
||||
await button_request("pin_mismatch", code=BR_TYPE_OTHER)
|
||||
await button_request("pin_mismatch", code=BR_CODE_OTHER)
|
||||
title = TR.wipe_code__wipe_code_mismatch if is_wipe_code else TR.pin__pin_mismatch
|
||||
description = TR.wipe_code__mismatch if is_wipe_code else TR.pin__mismatch
|
||||
return await show_error_popup(
|
||||
@ -1531,7 +1533,7 @@ async def pin_mismatch_popup(is_wipe_code: bool = False) -> None:
|
||||
|
||||
|
||||
async def wipe_code_same_as_pin_popup() -> None:
|
||||
await button_request("wipe_code_same_as_pin", code=BR_TYPE_OTHER)
|
||||
await button_request("wipe_code_same_as_pin", code=BR_CODE_OTHER)
|
||||
return await show_error_popup(
|
||||
TR.wipe_code__invalid,
|
||||
TR.wipe_code__diff_from_pin,
|
||||
@ -1540,11 +1542,11 @@ async def wipe_code_same_as_pin_popup() -> None:
|
||||
|
||||
|
||||
def confirm_set_new_pin(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
title: str,
|
||||
description: str,
|
||||
information: str,
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
br_code: ButtonRequestType = BR_CODE_OTHER,
|
||||
) -> Awaitable[None]:
|
||||
return raise_if_not_confirmed(
|
||||
interact(
|
||||
@ -1558,7 +1560,7 @@ def confirm_set_new_pin(
|
||||
verb=TR.buttons__turn_on,
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
)
|
||||
@ -1573,7 +1575,7 @@ def confirm_firmware_update(description: str, fingerprint: str) -> Awaitable[Non
|
||||
)
|
||||
),
|
||||
"firmware_update",
|
||||
BR_TYPE_OTHER,
|
||||
BR_CODE_OTHER,
|
||||
)
|
||||
)
|
||||
|
||||
@ -1582,5 +1584,5 @@ async def set_brightness(current: int | None = None) -> None:
|
||||
await interact(
|
||||
RustLayout(trezorui2.set_brightness(current=current)),
|
||||
"set_brightness",
|
||||
BR_TYPE_OTHER,
|
||||
BR_CODE_OTHER,
|
||||
)
|
||||
|
@ -147,7 +147,7 @@ async def continue_recovery(
|
||||
|
||||
|
||||
async def show_recovery_warning(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
content: str,
|
||||
subheader: str | None = None,
|
||||
button: str | None = None,
|
||||
@ -164,7 +164,7 @@ async def show_recovery_warning(
|
||||
allow_cancel=False,
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
)
|
||||
|
@ -355,7 +355,7 @@ async def show_success_backup() -> None:
|
||||
|
||||
|
||||
async def show_reset_warning(
|
||||
br_type: str,
|
||||
br_name: str,
|
||||
content: str,
|
||||
subheader: str | None = None,
|
||||
button: str | None = None,
|
||||
@ -372,7 +372,7 @@ async def show_reset_warning(
|
||||
allow_cancel=False,
|
||||
)
|
||||
),
|
||||
br_type,
|
||||
br_name,
|
||||
br_code,
|
||||
)
|
||||
)
|
||||
|
@ -13,3 +13,5 @@ Deprecated_PassphraseStateRequest.state max_size:1
|
||||
HDNodeType.chain_code max_size:32
|
||||
HDNodeType.private_key max_size:32
|
||||
HDNodeType.public_key max_size:33
|
||||
|
||||
ButtonRequest.name max_size:32
|
||||
|
3
python/src/trezorlib/messages.py
generated
3
python/src/trezorlib/messages.py
generated
@ -892,6 +892,7 @@ class ButtonRequest(protobuf.MessageType):
|
||||
FIELDS = {
|
||||
1: protobuf.Field("code", "ButtonRequestType", repeated=False, required=False, default=None),
|
||||
2: protobuf.Field("pages", "uint32", repeated=False, required=False, default=None),
|
||||
4: protobuf.Field("name", "string", repeated=False, required=False, default=None),
|
||||
}
|
||||
|
||||
def __init__(
|
||||
@ -899,9 +900,11 @@ class ButtonRequest(protobuf.MessageType):
|
||||
*,
|
||||
code: Optional["ButtonRequestType"] = None,
|
||||
pages: Optional["int"] = None,
|
||||
name: Optional["str"] = None,
|
||||
) -> None:
|
||||
self.code = code
|
||||
self.pages = pages
|
||||
self.name = name
|
||||
|
||||
|
||||
class ButtonAck(protobuf.MessageType):
|
||||
|
@ -536,6 +536,8 @@ pub struct ButtonRequest {
|
||||
pub code: ::std::option::Option<::protobuf::EnumOrUnknown<button_request::ButtonRequestType>>,
|
||||
// @@protoc_insertion_point(field:hw.trezor.messages.common.ButtonRequest.pages)
|
||||
pub pages: ::std::option::Option<u32>,
|
||||
// @@protoc_insertion_point(field:hw.trezor.messages.common.ButtonRequest.name)
|
||||
pub name: ::std::option::Option<::std::string::String>,
|
||||
// special fields
|
||||
// @@protoc_insertion_point(special_field:hw.trezor.messages.common.ButtonRequest.special_fields)
|
||||
pub special_fields: ::protobuf::SpecialFields,
|
||||
@ -593,8 +595,44 @@ impl ButtonRequest {
|
||||
self.pages = ::std::option::Option::Some(v);
|
||||
}
|
||||
|
||||
// optional string name = 4;
|
||||
|
||||
pub fn name(&self) -> &str {
|
||||
match self.name.as_ref() {
|
||||
Some(v) => v,
|
||||
None => "",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clear_name(&mut self) {
|
||||
self.name = ::std::option::Option::None;
|
||||
}
|
||||
|
||||
pub fn has_name(&self) -> bool {
|
||||
self.name.is_some()
|
||||
}
|
||||
|
||||
// Param is passed by value, moved
|
||||
pub fn set_name(&mut self, v: ::std::string::String) {
|
||||
self.name = ::std::option::Option::Some(v);
|
||||
}
|
||||
|
||||
// Mutable pointer to the field.
|
||||
// If field is not initialized, it is initialized with default value first.
|
||||
pub fn mut_name(&mut self) -> &mut ::std::string::String {
|
||||
if self.name.is_none() {
|
||||
self.name = ::std::option::Option::Some(::std::string::String::new());
|
||||
}
|
||||
self.name.as_mut().unwrap()
|
||||
}
|
||||
|
||||
// Take field
|
||||
pub fn take_name(&mut self) -> ::std::string::String {
|
||||
self.name.take().unwrap_or_else(|| ::std::string::String::new())
|
||||
}
|
||||
|
||||
fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData {
|
||||
let mut fields = ::std::vec::Vec::with_capacity(2);
|
||||
let mut fields = ::std::vec::Vec::with_capacity(3);
|
||||
let mut oneofs = ::std::vec::Vec::with_capacity(0);
|
||||
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
|
||||
"code",
|
||||
@ -606,6 +644,11 @@ impl ButtonRequest {
|
||||
|m: &ButtonRequest| { &m.pages },
|
||||
|m: &mut ButtonRequest| { &mut m.pages },
|
||||
));
|
||||
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
|
||||
"name",
|
||||
|m: &ButtonRequest| { &m.name },
|
||||
|m: &mut ButtonRequest| { &mut m.name },
|
||||
));
|
||||
::protobuf::reflect::GeneratedMessageDescriptorData::new_2::<ButtonRequest>(
|
||||
"ButtonRequest",
|
||||
fields,
|
||||
@ -630,6 +673,9 @@ impl ::protobuf::Message for ButtonRequest {
|
||||
16 => {
|
||||
self.pages = ::std::option::Option::Some(is.read_uint32()?);
|
||||
},
|
||||
34 => {
|
||||
self.name = ::std::option::Option::Some(is.read_string()?);
|
||||
},
|
||||
tag => {
|
||||
::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?;
|
||||
},
|
||||
@ -648,6 +694,9 @@ impl ::protobuf::Message for ButtonRequest {
|
||||
if let Some(v) = self.pages {
|
||||
my_size += ::protobuf::rt::uint32_size(2, v);
|
||||
}
|
||||
if let Some(v) = self.name.as_ref() {
|
||||
my_size += ::protobuf::rt::string_size(4, &v);
|
||||
}
|
||||
my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields());
|
||||
self.special_fields.cached_size().set(my_size as u32);
|
||||
my_size
|
||||
@ -660,6 +709,9 @@ impl ::protobuf::Message for ButtonRequest {
|
||||
if let Some(v) = self.pages {
|
||||
os.write_uint32(2, v)?;
|
||||
}
|
||||
if let Some(v) = self.name.as_ref() {
|
||||
os.write_string(4, v)?;
|
||||
}
|
||||
os.write_unknown_fields(self.special_fields.unknown_fields())?;
|
||||
::std::result::Result::Ok(())
|
||||
}
|
||||
@ -679,6 +731,7 @@ impl ::protobuf::Message for ButtonRequest {
|
||||
fn clear(&mut self) {
|
||||
self.code = ::std::option::Option::None;
|
||||
self.pages = ::std::option::Option::None;
|
||||
self.name = ::std::option::Option::None;
|
||||
self.special_fields.clear();
|
||||
}
|
||||
|
||||
@ -686,6 +739,7 @@ impl ::protobuf::Message for ButtonRequest {
|
||||
static instance: ButtonRequest = ButtonRequest {
|
||||
code: ::std::option::Option::None,
|
||||
pages: ::std::option::Option::None,
|
||||
name: ::std::option::Option::None,
|
||||
special_fields: ::protobuf::SpecialFields::new(),
|
||||
};
|
||||
&instance
|
||||
@ -2438,43 +2492,44 @@ static file_descriptor_proto_data: &'static [u8] = b"\
|
||||
essError\x10\t\x12\x1a\n\x16Failure_NotEnoughFunds\x10\n\x12\x1a\n\x16Fa\
|
||||
ilure_NotInitialized\x10\x0b\x12\x17\n\x13Failure_PinMismatch\x10\x0c\
|
||||
\x12\x1c\n\x18Failure_WipeCodeMismatch\x10\r\x12\x1a\n\x16Failure_Invali\
|
||||
dSession\x10\x0e\x12\x19\n\x15Failure_FirmwareError\x10c\"\x91\x06\n\rBu\
|
||||
dSession\x10\x0e\x12\x19\n\x15Failure_FirmwareError\x10c\"\xab\x06\n\rBu\
|
||||
ttonRequest\x12N\n\x04code\x18\x01\x20\x01(\x0e2:.hw.trezor.messages.com\
|
||||
mon.ButtonRequest.ButtonRequestTypeR\x04code\x12\x14\n\x05pages\x18\x02\
|
||||
\x20\x01(\rR\x05pages\"\x99\x05\n\x11ButtonRequestType\x12\x17\n\x13Butt\
|
||||
onRequest_Other\x10\x01\x12\"\n\x1eButtonRequest_FeeOverThreshold\x10\
|
||||
\x02\x12\x1f\n\x1bButtonRequest_ConfirmOutput\x10\x03\x12\x1d\n\x19Butto\
|
||||
nRequest_ResetDevice\x10\x04\x12\x1d\n\x19ButtonRequest_ConfirmWord\x10\
|
||||
\x05\x12\x1c\n\x18ButtonRequest_WipeDevice\x10\x06\x12\x1d\n\x19ButtonRe\
|
||||
quest_ProtectCall\x10\x07\x12\x18\n\x14ButtonRequest_SignTx\x10\x08\x12\
|
||||
\x1f\n\x1bButtonRequest_FirmwareCheck\x10\t\x12\x19\n\x15ButtonRequest_A\
|
||||
ddress\x10\n\x12\x1b\n\x17ButtonRequest_PublicKey\x10\x0b\x12#\n\x1fButt\
|
||||
onRequest_MnemonicWordCount\x10\x0c\x12\x1f\n\x1bButtonRequest_MnemonicI\
|
||||
nput\x10\r\x120\n(_Deprecated_ButtonRequest_PassphraseType\x10\x0e\x1a\
|
||||
\x02\x08\x01\x12'\n#ButtonRequest_UnknownDerivationPath\x10\x0f\x12\"\n\
|
||||
\x1eButtonRequest_RecoveryHomepage\x10\x10\x12\x19\n\x15ButtonRequest_Su\
|
||||
ccess\x10\x11\x12\x19\n\x15ButtonRequest_Warning\x10\x12\x12!\n\x1dButto\
|
||||
nRequest_PassphraseEntry\x10\x13\x12\x1a\n\x16ButtonRequest_PinEntry\x10\
|
||||
\x14\"\x0b\n\tButtonAck\"\xbb\x02\n\x10PinMatrixRequest\x12T\n\x04type\
|
||||
\x18\x01\x20\x01(\x0e2@.hw.trezor.messages.common.PinMatrixRequest.PinMa\
|
||||
trixRequestTypeR\x04type\"\xd0\x01\n\x14PinMatrixRequestType\x12\x20\n\
|
||||
\x1cPinMatrixRequestType_Current\x10\x01\x12!\n\x1dPinMatrixRequestType_\
|
||||
NewFirst\x10\x02\x12\"\n\x1ePinMatrixRequestType_NewSecond\x10\x03\x12&\
|
||||
\n\"PinMatrixRequestType_WipeCodeFirst\x10\x04\x12'\n#PinMatrixRequestTy\
|
||||
pe_WipeCodeSecond\x10\x05\"\x20\n\x0cPinMatrixAck\x12\x10\n\x03pin\x18\
|
||||
\x01\x20\x02(\tR\x03pin\"5\n\x11PassphraseRequest\x12\x20\n\n_on_device\
|
||||
\x18\x01\x20\x01(\x08R\x08OnDeviceB\x02\x18\x01\"g\n\rPassphraseAck\x12\
|
||||
\x1e\n\npassphrase\x18\x01\x20\x01(\tR\npassphrase\x12\x19\n\x06_state\
|
||||
\x18\x02\x20\x01(\x0cR\x05StateB\x02\x18\x01\x12\x1b\n\ton_device\x18\
|
||||
\x03\x20\x01(\x08R\x08onDevice\"=\n!Deprecated_PassphraseStateRequest\
|
||||
\x12\x14\n\x05state\x18\x01\x20\x01(\x0cR\x05state:\x02\x18\x01\"#\n\x1d\
|
||||
Deprecated_PassphraseStateAck:\x02\x18\x01\"\xc0\x01\n\nHDNodeType\x12\
|
||||
\x14\n\x05depth\x18\x01\x20\x02(\rR\x05depth\x12\x20\n\x0bfingerprint\
|
||||
\x18\x02\x20\x02(\rR\x0bfingerprint\x12\x1b\n\tchild_num\x18\x03\x20\x02\
|
||||
(\rR\x08childNum\x12\x1d\n\nchain_code\x18\x04\x20\x02(\x0cR\tchainCode\
|
||||
\x12\x1f\n\x0bprivate_key\x18\x05\x20\x01(\x0cR\nprivateKey\x12\x1d\n\np\
|
||||
ublic_key\x18\x06\x20\x02(\x0cR\tpublicKeyB>\n#com.satoshilabs.trezor.li\
|
||||
b.protobufB\x13TrezorMessageCommon\x80\xa6\x1d\x01\
|
||||
\x20\x01(\rR\x05pages\x12\x12\n\x04name\x18\x04\x20\x01(\tR\x04name\"\
|
||||
\x99\x05\n\x11ButtonRequestType\x12\x17\n\x13ButtonRequest_Other\x10\x01\
|
||||
\x12\"\n\x1eButtonRequest_FeeOverThreshold\x10\x02\x12\x1f\n\x1bButtonRe\
|
||||
quest_ConfirmOutput\x10\x03\x12\x1d\n\x19ButtonRequest_ResetDevice\x10\
|
||||
\x04\x12\x1d\n\x19ButtonRequest_ConfirmWord\x10\x05\x12\x1c\n\x18ButtonR\
|
||||
equest_WipeDevice\x10\x06\x12\x1d\n\x19ButtonRequest_ProtectCall\x10\x07\
|
||||
\x12\x18\n\x14ButtonRequest_SignTx\x10\x08\x12\x1f\n\x1bButtonRequest_Fi\
|
||||
rmwareCheck\x10\t\x12\x19\n\x15ButtonRequest_Address\x10\n\x12\x1b\n\x17\
|
||||
ButtonRequest_PublicKey\x10\x0b\x12#\n\x1fButtonRequest_MnemonicWordCoun\
|
||||
t\x10\x0c\x12\x1f\n\x1bButtonRequest_MnemonicInput\x10\r\x120\n(_Depreca\
|
||||
ted_ButtonRequest_PassphraseType\x10\x0e\x1a\x02\x08\x01\x12'\n#ButtonRe\
|
||||
quest_UnknownDerivationPath\x10\x0f\x12\"\n\x1eButtonRequest_RecoveryHom\
|
||||
epage\x10\x10\x12\x19\n\x15ButtonRequest_Success\x10\x11\x12\x19\n\x15Bu\
|
||||
ttonRequest_Warning\x10\x12\x12!\n\x1dButtonRequest_PassphraseEntry\x10\
|
||||
\x13\x12\x1a\n\x16ButtonRequest_PinEntry\x10\x14J\x04\x08\x03\x10\x04\"\
|
||||
\x0b\n\tButtonAck\"\xbb\x02\n\x10PinMatrixRequest\x12T\n\x04type\x18\x01\
|
||||
\x20\x01(\x0e2@.hw.trezor.messages.common.PinMatrixRequest.PinMatrixRequ\
|
||||
estTypeR\x04type\"\xd0\x01\n\x14PinMatrixRequestType\x12\x20\n\x1cPinMat\
|
||||
rixRequestType_Current\x10\x01\x12!\n\x1dPinMatrixRequestType_NewFirst\
|
||||
\x10\x02\x12\"\n\x1ePinMatrixRequestType_NewSecond\x10\x03\x12&\n\"PinMa\
|
||||
trixRequestType_WipeCodeFirst\x10\x04\x12'\n#PinMatrixRequestType_WipeCo\
|
||||
deSecond\x10\x05\"\x20\n\x0cPinMatrixAck\x12\x10\n\x03pin\x18\x01\x20\
|
||||
\x02(\tR\x03pin\"5\n\x11PassphraseRequest\x12\x20\n\n_on_device\x18\x01\
|
||||
\x20\x01(\x08R\x08OnDeviceB\x02\x18\x01\"g\n\rPassphraseAck\x12\x1e\n\np\
|
||||
assphrase\x18\x01\x20\x01(\tR\npassphrase\x12\x19\n\x06_state\x18\x02\
|
||||
\x20\x01(\x0cR\x05StateB\x02\x18\x01\x12\x1b\n\ton_device\x18\x03\x20\
|
||||
\x01(\x08R\x08onDevice\"=\n!Deprecated_PassphraseStateRequest\x12\x14\n\
|
||||
\x05state\x18\x01\x20\x01(\x0cR\x05state:\x02\x18\x01\"#\n\x1dDeprecated\
|
||||
_PassphraseStateAck:\x02\x18\x01\"\xc0\x01\n\nHDNodeType\x12\x14\n\x05de\
|
||||
pth\x18\x01\x20\x02(\rR\x05depth\x12\x20\n\x0bfingerprint\x18\x02\x20\
|
||||
\x02(\rR\x0bfingerprint\x12\x1b\n\tchild_num\x18\x03\x20\x02(\rR\x08chil\
|
||||
dNum\x12\x1d\n\nchain_code\x18\x04\x20\x02(\x0cR\tchainCode\x12\x1f\n\
|
||||
\x0bprivate_key\x18\x05\x20\x01(\x0cR\nprivateKey\x12\x1d\n\npublic_key\
|
||||
\x18\x06\x20\x02(\x0cR\tpublicKeyB>\n#com.satoshilabs.trezor.lib.protobu\
|
||||
fB\x13TrezorMessageCommon\x80\xa6\x1d\x01\
|
||||
";
|
||||
|
||||
/// `FileDescriptorProto` object which was a source for this generated file
|
||||
|
@ -48,7 +48,9 @@ def test_wipe_code_activate_core(core_emulator: Emulator):
|
||||
ret = core_emulator.client.call_raw(messages.ButtonAck())
|
||||
|
||||
# Enter the wipe code instead of the current PIN
|
||||
assert ret == messages.ButtonRequest(code=messages.ButtonRequestType.PinEntry)
|
||||
assert ret == messages.ButtonRequest(
|
||||
code=messages.ButtonRequestType.PinEntry, name="pin_device"
|
||||
)
|
||||
core_emulator.client._raw_write(messages.ButtonAck())
|
||||
core_emulator.client.debug.input(WIPE_CODE)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user