1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-23 14:58:09 +00:00

Merge pull request #603 from trezor/tsusanka/groups-info

Small refactor in Info dialog
This commit is contained in:
Tomas Susanka 2019-10-09 10:15:34 +02:00 committed by GitHub
commit a2fed79f7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 10 deletions

View File

@ -219,7 +219,7 @@ async def _show_remaining_groups_and_shares(ctx: wire.Context) -> None:
"""
shares_remaining = storage.recovery.fetch_slip39_remaining_shares()
identifiers = []
groups = set()
first_entered_index = -1
for i in range(len(shares_remaining)):
if shares_remaining[i] < slip39.MAX_SHARE_COUNT:
@ -232,17 +232,13 @@ async def _show_remaining_groups_and_shares(ctx: wire.Context) -> None:
if not share:
share = slip39.decode_mnemonic(m)
identifier = m.split(" ")[0:3]
identifiers.append([remaining, identifier])
groups.add((remaining, tuple(identifier)))
elif remaining == slip39.MAX_SHARE_COUNT: # no shares yet
identifier = storage.recovery_shares.fetch_group(first_entered_index)[
0
].split(" ")[0:2]
try:
# we only add the group (two words) identifier once
identifiers.index([remaining, identifier])
except ValueError:
identifiers.append([remaining, identifier])
groups.add((remaining, tuple(identifier)))
return await layout.show_remaining_shares(
ctx, identifiers, shares_remaining, share.group_threshold
ctx, groups, shares_remaining, share.group_threshold
)

View File

@ -21,7 +21,7 @@ if __debug__:
from apps.debug import input_signal
if False:
from typing import List, Optional, Callable
from typing import List, Optional, Callable, Iterable, Tuple
from trezor.messages.ResetDevice import EnumTypeBackupType
@ -152,7 +152,7 @@ async def check_word_validity(
async def show_remaining_shares(
ctx: wire.Context,
groups: List[int, List[str]], # remaining + list 3 words
groups: Iterable[Tuple[int, Tuple[str]]], # remaining + list 3 words
shares_remaining: List[int],
group_threshold: int,
) -> None: