1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-05 21:10:57 +00:00

wip fix cardano part 3

This commit is contained in:
M1nd3r 2024-11-22 16:35:22 +01:00
parent 0074b62d43
commit ac8d853b70
2 changed files with 9 additions and 8 deletions

View File

@ -1162,6 +1162,7 @@ class SessionDebugWrapper(Session):
] = {}
self.button_callback = self.client.button_callback
self.pin_callback = self.client.pin_callback
self.passphrase_callback = self._session.passphrase_callback
def __enter__(self) -> "SessionDebugWrapper":
# For usage in with/expected_responses

View File

@ -4,9 +4,9 @@ import logging
import typing as t
from mnemonic import Mnemonic
from trezorlib.client import MAX_PASSPHRASE_LENGTH, PASSPHRASE_ON_DEVICE
from ..client import MAX_PASSPHRASE_LENGTH, PASSPHRASE_ON_DEVICE
from trezor.enums import Capability
from ..messages import Capability
from .. import exceptions, messages, models
from .thp.protocol_v1 import ProtocolV1
@ -23,13 +23,16 @@ class Session:
pin_callback: t.Callable[[Session, t.Any], t.Any] | None = None
passphrase_callback: t.Callable[[Session, t.Any], t.Any] | None = None
def __init__(self, client: TrezorClient, id: bytes) -> None:
def __init__(
self, client: TrezorClient, id: bytes, passphrase: str | object | None = None
) -> None:
self.client = client
self._id = id
self.passphrase = passphrase
@classmethod
def new(
cls, client: TrezorClient, passphrase: str | None, derive_cardano: bool
cls, client: TrezorClient, passphrase: str | object | None, derive_cardano: bool
) -> Session:
raise NotImplementedError
@ -130,7 +133,6 @@ def _callback_button(session: Session, msg: t.Any) -> t.Any:
def _callback_passphrase(session: Session, msg: messages.PassphraseRequest) -> t.Any:
available_on_device = Capability.PassphraseEntry in Session.features.capabilities
def send_passphrase(
passphrase: str | None = None, on_device: bool | None = None
) -> t.Any:
@ -146,9 +148,7 @@ def _callback_passphrase(session: Session, msg: messages.PassphraseRequest) -> t
return send_passphrase(None, None)
try:
passphrase = session.client.ui.get_passphrase(
available_on_device=available_on_device
) # TODO
passphrase = session.passphrase
except exceptions.Cancelled:
session.call_raw(messages.Cancel())
raise