Skip to content

Commit

Permalink
SFT-1728: fixed account index out of bounds when switching keys
Browse files Browse the repository at this point in the history
  • Loading branch information
mjg-foundation committed Jul 26, 2024
1 parent 38d20d7 commit df720a6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ async def clear_seed(self):
settings.exit_temporary_mode()
# await spinner_task('Clearing temporary seed', delay_task, args=[1000, False])
await SuccessPage(text='Temporary Seed Cleared').show()

self.set_result(True)
ui.full_cards_refresh()
await self.wait_to_die()
await self.finalize()

async def use_child_seed(self):
from derived_key import get_key_type_from_tn
Expand Down Expand Up @@ -84,7 +81,9 @@ async def use_child_seed(self):
return

await SuccessPage(text='Temporary Seed Applied').show()
await self.finalize()

async def finalize(self):
self.set_result(True)
ui.full_cards_refresh()
ui.full_cards_refresh(go_to_account_0=True)
await self.wait_to_die()
10 changes: 6 additions & 4 deletions ports/stm32/boards/Passport/modules/ui/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ def set_screen_bg_color(self, bg_color):
self.active_screen.set_bg_color(bg_color)

def set_cards(self, card_descs, active_idx=0):
assert(active_idx >= 0)
assert(active_idx < len(card_descs))
# An index out of bounds could occur when the account/passphrase/seed changes
# and the active_idx isnt updated
if active_idx < 0 or active_idx > len(card_descs):
active_idx = 1

# print('set_cards: len={}'.format(len(card_descs)))
self.card_descs = card_descs
Expand Down Expand Up @@ -336,13 +338,13 @@ def on_nav_right(self):
self.next_card()

# Full refresh
def full_cards_refresh(self):
def full_cards_refresh(self, go_to_account_0=False):
from utils import start_task

self.update_cards()

async def restart_main_task():
self.start_card_task(card_idx=self.active_card_idx)
self.start_card_task(card_idx=(1 if go_to_account_0 else self.active_card_idx))

start_task(restart_main_task())

Expand Down

0 comments on commit df720a6

Please sign in to comment.