mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-19 19:12:03 +00:00
Merge pull request #603 from trezor/tsusanka/groups-info
Small refactor in Info dialog
This commit is contained in:
commit
a2fed79f7e
@ -219,7 +219,7 @@ async def _show_remaining_groups_and_shares(ctx: wire.Context) -> None:
|
|||||||
"""
|
"""
|
||||||
shares_remaining = storage.recovery.fetch_slip39_remaining_shares()
|
shares_remaining = storage.recovery.fetch_slip39_remaining_shares()
|
||||||
|
|
||||||
identifiers = []
|
groups = set()
|
||||||
first_entered_index = -1
|
first_entered_index = -1
|
||||||
for i in range(len(shares_remaining)):
|
for i in range(len(shares_remaining)):
|
||||||
if shares_remaining[i] < slip39.MAX_SHARE_COUNT:
|
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:
|
if not share:
|
||||||
share = slip39.decode_mnemonic(m)
|
share = slip39.decode_mnemonic(m)
|
||||||
identifier = m.split(" ")[0:3]
|
identifier = m.split(" ")[0:3]
|
||||||
identifiers.append([remaining, identifier])
|
groups.add((remaining, tuple(identifier)))
|
||||||
elif remaining == slip39.MAX_SHARE_COUNT: # no shares yet
|
elif remaining == slip39.MAX_SHARE_COUNT: # no shares yet
|
||||||
identifier = storage.recovery_shares.fetch_group(first_entered_index)[
|
identifier = storage.recovery_shares.fetch_group(first_entered_index)[
|
||||||
0
|
0
|
||||||
].split(" ")[0:2]
|
].split(" ")[0:2]
|
||||||
try:
|
groups.add((remaining, tuple(identifier)))
|
||||||
# we only add the group (two words) identifier once
|
|
||||||
identifiers.index([remaining, identifier])
|
|
||||||
except ValueError:
|
|
||||||
identifiers.append([remaining, identifier])
|
|
||||||
|
|
||||||
return await layout.show_remaining_shares(
|
return await layout.show_remaining_shares(
|
||||||
ctx, identifiers, shares_remaining, share.group_threshold
|
ctx, groups, shares_remaining, share.group_threshold
|
||||||
)
|
)
|
||||||
|
@ -21,7 +21,7 @@ if __debug__:
|
|||||||
from apps.debug import input_signal
|
from apps.debug import input_signal
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
from typing import List, Optional, Callable
|
from typing import List, Optional, Callable, Iterable, Tuple
|
||||||
from trezor.messages.ResetDevice import EnumTypeBackupType
|
from trezor.messages.ResetDevice import EnumTypeBackupType
|
||||||
|
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ async def check_word_validity(
|
|||||||
|
|
||||||
async def show_remaining_shares(
|
async def show_remaining_shares(
|
||||||
ctx: wire.Context,
|
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],
|
shares_remaining: List[int],
|
||||||
group_threshold: int,
|
group_threshold: int,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
Loading…
Reference in New Issue
Block a user