From aaee1284ad1fd79a8bff336843c915b38801741c Mon Sep 17 00:00:00 2001 From: Matt Gleason Date: Thu, 22 Aug 2024 18:56:34 -0400 Subject: [PATCH] SFT-4094: improved multisig import flow --- .../flows/import_multisig_wallet_flow.py | 53 ++++++++++++------- .../modules/flows/sign_psbt_common_flow.py | 6 ++- .../Passport/modules/multisig_wallet.py | 9 +--- .../boards/Passport/modules/pages/page.py | 4 +- 4 files changed, 42 insertions(+), 30 deletions(-) diff --git a/ports/stm32/boards/Passport/modules/flows/import_multisig_wallet_flow.py b/ports/stm32/boards/Passport/modules/flows/import_multisig_wallet_flow.py index 32899264a..8797966a3 100644 --- a/ports/stm32/boards/Passport/modules/flows/import_multisig_wallet_flow.py +++ b/ports/stm32/boards/Passport/modules/flows/import_multisig_wallet_flow.py @@ -16,35 +16,50 @@ async def show_overview(self): msg, is_dup = self.ms.format_overview() if is_dup: - await ErrorPage(text="Duplicate wallet will not be imported.").show() + await ErrorPage(text="Duplicate multisig wallet will not be imported.").show() self.set_result(False) return - else: - result = await LongTextPage(card_header={'title': 'Confirm Import'}, text=msg, centered=True).show() - if not result: - self.set_result(False) - return + + await LongTextPage(card_header={'title': 'Confirm Import'}, text=msg, centered=True, left_micron=None).show() self.goto(self.show_details) async def show_details(self): - from errors import Error - from utils import spinner_task, escape_text - from tasks import save_multisig_wallet_task + from utils import escape_text msg = self.ms.format_details() result = await LongTextPage(card_header={'title': escape_text(self.ms.name)}, text=msg, centered=True).show() + if not result: self.back() + return + + self.goto(self.confirm_import) + + async def confirm_import(self): + from pages import QuestionPage + + result = await QuestionPage('Create new multisig wallet?').show() + + if not result: + self.set_result(False) + return + + self.goto(self.import_wallet) + + async def import_wallet(self): + from utils import spinner_task + from errors import Error + from tasks import save_multisig_wallet_task + + # User confirmed the import, so save + (error,) = await spinner_task('Saving multisig', save_multisig_wallet_task, args=[self.ms]) + if not error: + self.set_result(True) + elif error is Error.USER_SETTINGS_FULL: + await ErrorPage(text='Out of space in user settings. Too many multisig configs?').show() + self.set_result(False) else: - # User confirmed the import, so save - (error,) = await spinner_task('Saving multisig', save_multisig_wallet_task, args=[self.ms]) - if not error: - self.set_result(True) - elif error is Error.USER_SETTINGS_FULL: - await ErrorPage(text='Out of space in user settings. Too many multisig configs?').show() - self.set_result(False) - else: - await ErrorPage(text='Unable to save multisig config.').show() - self.set_result(False) + await ErrorPage(text='Unable to save multisig config.').show() + self.set_result(False) diff --git a/ports/stm32/boards/Passport/modules/flows/sign_psbt_common_flow.py b/ports/stm32/boards/Passport/modules/flows/sign_psbt_common_flow.py index dc74b1835..1624de0be 100644 --- a/ports/stm32/boards/Passport/modules/flows/sign_psbt_common_flow.py +++ b/ports/stm32/boards/Passport/modules/flows/sign_psbt_common_flow.py @@ -49,8 +49,10 @@ async def check_multisig_import(self): if self.psbt.multisig_import_needs_approval: result = await ImportMultisigWalletFlow(self.psbt.active_multisig).run() if not result: - await ErrorPage( - 'The transaction can still be signed, but this multisig config will not be saved.').show() + text = 'The transaction can still be signed, but this multisig config will not be saved.' + result2 = await ErrorPage(text=text, left_micron=microns.Back).show() + if not result2: + return self.goto(self.show_transaction_details) diff --git a/ports/stm32/boards/Passport/modules/multisig_wallet.py b/ports/stm32/boards/Passport/modules/multisig_wallet.py index bd58ad3ce..b50f9d41f 100644 --- a/ports/stm32/boards/Passport/modules/multisig_wallet.py +++ b/ports/stm32/boards/Passport/modules/multisig_wallet.py @@ -976,18 +976,13 @@ def format_overview(self, importing=True): wallet first. Differences: '''.format(recolor(COPPER_HEX, 'WARNING:')) + ', '.join(diff_items) is_dup = True elif importing and num_dups: - msg = 'Duplicate wallet. All details are the same as an existing wallet, so it will not be added.' + msg = 'Duplicate wallet. All details are the same as an existing wallet, so it will not be added.\n\n' is_dup = True - elif not importing: - msg = '' else: - msg = 'Create new multisig wallet?' + msg = '' derivs, dsum = self.get_deriv_paths() - if importing: - msg += '\n\n' - msg += '''{name_title} {name} diff --git a/ports/stm32/boards/Passport/modules/pages/page.py b/ports/stm32/boards/Passport/modules/pages/page.py index 452276dfc..b7aca95c8 100644 --- a/ports/stm32/boards/Passport/modules/pages/page.py +++ b/ports/stm32/boards/Passport/modules/pages/page.py @@ -60,12 +60,12 @@ def detach(self): def left_action(self, is_pressed): # print('Page.right_action()') - if not is_pressed: + if not is_pressed and self.left_micron: self.set_result(False) def right_action(self, is_pressed): # print('Page.right_action()') - if not is_pressed: + if not is_pressed and self.right_micron: self.set_result(True) # By default, returns None so caller can differentiate between user pressing a button to back out