From bbb03f370800d97930b56e23e58542e95c0532c2 Mon Sep 17 00:00:00 2001 From: Ken Carpenter <62639971+FoundationKen@users.noreply.github.com> Date: Thu, 29 Jul 2021 15:38:26 -0700 Subject: [PATCH] PASS1-122_b (#23) * PASS1-102: Fix backwards microSD issue Found that `ErrorCode` in `SD_HandleTypeDef` was not reset after a failure. Updated `HAL_SD_Init()` to reset it before attempting initialization. * Update user messaging for found/not found case of Verify Address Fix bug with trailing space at end of line in `word_wrap()` * Strip ever time through the loop --- ports/stm32/boards/Passport/modules/actions.py | 12 +++++++++--- ports/stm32/boards/Passport/modules/utils.py | 10 ++++++---- ports/stm32/boards/Passport/modules/ux.py | 6 ++---- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/ports/stm32/boards/Passport/modules/actions.py b/ports/stm32/boards/Passport/modules/actions.py index 9b1dc51..7ce0e51 100644 --- a/ports/stm32/boards/Passport/modules/actions.py +++ b/ports/stm32/boards/Passport/modules/actions.py @@ -296,10 +296,16 @@ class VerifyAddressUX(UXStateMachine): save_next_addr(self.acct_num, addr_type, addr_idx, is_change) address = format_btc_address(address, addr_type) - result = await ux_show_story('''{} + result = await ux_show_story('''Address Verified! -Found at index: {}\nType: {}'''.format(address, addr_idx, 'Change' if is_change == 1 else 'Receive'), title='Verified', left_btn='BACK', - right_btn='CONTINUE', center=True, center_vertically=True) +{} + +This is a {} address at index {}.'''.format(address, 'change' if is_change == 1 else 'receive', addr_idx), + title='Verify', + left_btn='BACK', + right_btn='CONTINUE', + center=True, + center_vertically=True) if result == 'x': if not self.goto_prev(): # Nothing to return back to, so we must have skipped one or more steps...we're done diff --git a/ports/stm32/boards/Passport/modules/utils.py b/ports/stm32/boards/Passport/modules/utils.py index 3668ebb..243489e 100644 --- a/ports/stm32/boards/Passport/modules/utils.py +++ b/ports/stm32/boards/Passport/modules/utils.py @@ -675,16 +675,18 @@ async def scan_for_address(acct_num, address, addr_type, deriv_path, ms_wallet): return addr_idx, True if is_change else False else: # Address was not found in that batch of 100, so offer to keep searching - msg = 'Addresses Checked:\n\n' + msg = 'Address Not Found.\n\nPassport checked ' # Build a merged range for receive and one for change addresses merged_range = [] for is_change in range(0, 2): - msg += '{}: {}-{}\n'.format('Change' if is_change == 1 else 'Receive', low_range[is_change][0], high_range[is_change][1] - 1) + msg += '{} addresses {}-{}{}'.format( + 'change' if is_change == 1 else 'receive', low_range[is_change][0], high_range[is_change][1] - 1, + '.' if is_change == 1 else ', and ') - msg += '\nContinue searching?' + msg += '\n\nContinue searching?' - result = await ux_show_story(msg, title='Not Found', left_btn='NO', right_btn='YES', + result = await ux_show_story(msg, title='Verify', left_btn='NO', right_btn='YES', center=True, center_vertically=True) if result == 'x': return -1, False diff --git a/ports/stm32/boards/Passport/modules/ux.py b/ports/stm32/boards/Passport/modules/ux.py index ba8498c..cb8334c 100644 --- a/ports/stm32/boards/Passport/modules/ux.py +++ b/ports/stm32/boards/Passport/modules/ux.py @@ -599,10 +599,8 @@ def word_wrap(ln, font): line_width = 0 first_non_space = 0 - # Skip leading spaces - while ln[sp].isspace(): - sp += 1 - first_non_space = sp + # Strip out leading and trailing spaces + ln = ln.strip() while sp < len(ln): ch = ln[sp]