From 846eca36ca53fa61e136f905a454cde0226f4b75 Mon Sep 17 00:00:00 2001 From: matejcik Date: Wed, 20 Oct 2021 13:15:11 +0200 Subject: [PATCH] feat(python): add type information to the UI object --- python/src/trezorlib/ui.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/python/src/trezorlib/ui.py b/python/src/trezorlib/ui.py index 4b4a05ea0..546e780a1 100644 --- a/python/src/trezorlib/ui.py +++ b/python/src/trezorlib/ui.py @@ -15,11 +15,13 @@ # If not, see . import os +from typing import Union import click from mnemonic import Mnemonic +from typing_extensions import Protocol -from . import device +from . import device, messages from .client import MAX_PIN_LENGTH, PASSPHRASE_ON_DEVICE from .exceptions import Cancelled from .messages import PinMatrixRequestType, WordRequestType @@ -53,6 +55,17 @@ WIPE_CODE_NEW = PinMatrixRequestType.WipeCodeFirst WIPE_CODE_CONFIRM = PinMatrixRequestType.WipeCodeSecond +class TrezorClientUI(Protocol): + def button_request(self, br: messages.ButtonRequest) -> None: + ... + + def get_pin(self, code: PinMatrixRequestType) -> str: + ... + + def get_passphrase(self, available_on_device: bool) -> Union[str, object]: + ... + + def echo(*args, **kwargs): return click.echo(*args, err=True, **kwargs)