1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-07-14 10:38:09 +00:00
trezor-firmware/core/src/apps/management/get_next_u2f_counter.py

25 lines
797 B
Python

from typing import TYPE_CHECKING
if TYPE_CHECKING:
from trezor.messages import GetNextU2FCounter, NextU2FCounter
async def get_next_u2f_counter(msg: GetNextU2FCounter) -> NextU2FCounter:
import storage.device as storage_device
from trezor.wire import NotInitialized
from trezor.enums import ButtonRequestType
from trezor.messages import NextU2FCounter
from trezor.ui.layouts import confirm_action
if not storage_device.is_initialized():
raise NotInitialized("Device is not initialized")
await confirm_action(
"get_u2f_counter",
"Get U2F counter",
description="Increase and retrieve the U2F counter?",
br_code=ButtonRequestType.ProtectCall,
)
return NextU2FCounter(u2f_counter=storage_device.next_u2f_counter())