mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-08 14:31:06 +00:00
wip fix cardano part 3
This commit is contained in:
parent
0074b62d43
commit
ac8d853b70
@ -1162,6 +1162,7 @@ class SessionDebugWrapper(Session):
|
|||||||
] = {}
|
] = {}
|
||||||
self.button_callback = self.client.button_callback
|
self.button_callback = self.client.button_callback
|
||||||
self.pin_callback = self.client.pin_callback
|
self.pin_callback = self.client.pin_callback
|
||||||
|
self.passphrase_callback = self._session.passphrase_callback
|
||||||
|
|
||||||
def __enter__(self) -> "SessionDebugWrapper":
|
def __enter__(self) -> "SessionDebugWrapper":
|
||||||
# For usage in with/expected_responses
|
# For usage in with/expected_responses
|
||||||
|
@ -4,9 +4,9 @@ import logging
|
|||||||
import typing as t
|
import typing as t
|
||||||
|
|
||||||
from mnemonic import Mnemonic
|
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 .. import exceptions, messages, models
|
||||||
from .thp.protocol_v1 import ProtocolV1
|
from .thp.protocol_v1 import ProtocolV1
|
||||||
@ -23,13 +23,16 @@ class Session:
|
|||||||
pin_callback: t.Callable[[Session, t.Any], t.Any] | None = None
|
pin_callback: t.Callable[[Session, t.Any], t.Any] | None = None
|
||||||
passphrase_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.client = client
|
||||||
self._id = id
|
self._id = id
|
||||||
|
self.passphrase = passphrase
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def new(
|
def new(
|
||||||
cls, client: TrezorClient, passphrase: str | None, derive_cardano: bool
|
cls, client: TrezorClient, passphrase: str | object | None, derive_cardano: bool
|
||||||
) -> Session:
|
) -> Session:
|
||||||
raise NotImplementedError
|
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:
|
def _callback_passphrase(session: Session, msg: messages.PassphraseRequest) -> t.Any:
|
||||||
available_on_device = Capability.PassphraseEntry in Session.features.capabilities
|
available_on_device = Capability.PassphraseEntry in Session.features.capabilities
|
||||||
|
|
||||||
def send_passphrase(
|
def send_passphrase(
|
||||||
passphrase: str | None = None, on_device: bool | None = None
|
passphrase: str | None = None, on_device: bool | None = None
|
||||||
) -> t.Any:
|
) -> t.Any:
|
||||||
@ -146,9 +148,7 @@ def _callback_passphrase(session: Session, msg: messages.PassphraseRequest) -> t
|
|||||||
return send_passphrase(None, None)
|
return send_passphrase(None, None)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
passphrase = session.client.ui.get_passphrase(
|
passphrase = session.passphrase
|
||||||
available_on_device=available_on_device
|
|
||||||
) # TODO
|
|
||||||
except exceptions.Cancelled:
|
except exceptions.Cancelled:
|
||||||
session.call_raw(messages.Cancel())
|
session.call_raw(messages.Cancel())
|
||||||
raise
|
raise
|
||||||
|
Loading…
Reference in New Issue
Block a user