Fixing PIN change exception handling
This commit is contained in:
parent
88feeeb21c
commit
8b0e2b0aa0
|
@ -1,13 +1,10 @@
|
|||
from trezor import res
|
||||
from trezor import ui
|
||||
|
||||
|
||||
class PinCancelled(Exception):
|
||||
pass
|
||||
|
||||
from trezor import TrezorException
|
||||
|
||||
@ui.layout(delay=5000)
|
||||
async def request_pin(label: str = None) -> str:
|
||||
from trezor.messages.FailureType import PinCancelled
|
||||
from trezor.ui.confirm import ConfirmDialog, CONFIRMED
|
||||
from trezor.ui.pin import PinMatrix
|
||||
|
||||
|
@ -39,4 +36,4 @@ async def request_pin(label: str = None) -> str:
|
|||
matrix.change('')
|
||||
continue
|
||||
else:
|
||||
raise PinCancelled()
|
||||
raise TrezorException(PinCancelled, 'PIN entry cancelled')
|
||||
|
|
|
@ -23,7 +23,7 @@ async def request_pin_confirm(ctx):
|
|||
# TODO: display a message and wait
|
||||
|
||||
|
||||
def confirm_change_pin(ctx, msg):
|
||||
def confirm_change_pin(ctx, msg: str):
|
||||
from apps.common.confirm import require_confirm
|
||||
from trezor.ui.text import Text
|
||||
|
||||
|
@ -49,10 +49,10 @@ def confirm_change_pin(ctx, msg):
|
|||
|
||||
|
||||
@unimport
|
||||
async def layout_change_pin(ctx, msg):
|
||||
async def layout_change_pin(ctx, msg: str):
|
||||
from trezor.messages.Success import Success
|
||||
from trezor.messages.Failure import Failure
|
||||
from trezor.messages.FailureType import PinInvalid
|
||||
from trezor.messages.FailureType import PinCancelled
|
||||
|
||||
await confirm_change_pin(ctx, msg)
|
||||
|
||||
|
@ -71,4 +71,4 @@ async def layout_change_pin(ctx, msg):
|
|||
else:
|
||||
return Success(message='PIN removed')
|
||||
else:
|
||||
return Failure(code=PinInvalid, message='PIN invalid')
|
||||
return Failure(code=PinCancelled, message='PIN entry cancelled')
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
import trezorconfig as config
|
||||
import trezorio as io
|
||||
from trezor.wire import FailureError
|
||||
|
||||
class TrezorException(FailureError): pass
|
||||
|
|
Loading…
Reference in New Issue