Skip to content

Commit

Permalink
fix(core): Changes acc to review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
amanCypherock committed Dec 23, 2023
1 parent 0b3ed3e commit 4e391d9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
30 changes: 22 additions & 8 deletions src/card_flows/card_flow_delete_wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#include "constant_texts.h"
#include "core_error.h"
#include "nfc.h"
#include "ui_instruction.h"
#include "ui_screens.h"
/*****************************************************************************
* EXTERN VARIABLES
*****************************************************************************/
Expand Down Expand Up @@ -131,6 +131,7 @@ static void check_card_state_and_delete_wallet(const char *wallet_name) {
if (0 == get_wallet_card_state(flash_wallet_index)) {
ASSERT(SUCCESS_ == delete_wallet_share_from_sec_flash(flash_wallet_index));
ASSERT(SUCCESS_ == delete_wallet_from_flash(flash_wallet_index));
delay_scr_init(ui_text_wallet_deleted_successfully, DELAY_TIME);
}
return;
}
Expand Down Expand Up @@ -197,22 +198,35 @@ card_error_type_e card_flow_delete_wallet(Wallet *selected_wallet) {
error_code = card_fetch_share(&fetch_cfg, &response);

if (CARD_OPERATION_SUCCESS != error_code) {
if ((SW_RECORD_NOT_FOUND == response.card_info.status) &&
(CARD_OPERATION_ABORT_OPERATION == error_code ||
CARD_OPERATION_VERIFICATION_FAILED == error_code)) {
// In case wallet is not found on card or wallet verification fails,
// consider it as a success case as wallet is already deleted, not
// created on card or wallet on card does not match with the required
// verification.
if (CARD_OPERATION_ABORT_OPERATION == error_code &&
SW_RECORD_NOT_FOUND == response.card_info.status) {
// In case wallet is not found on card, consider it as a success case as
// wallet is already deleted or not created on the card.
clear_core_error_screen();
// Let it pass to wallet delete flow as the card operation will get
// completed there.
} else if (CARD_OPERATION_VERIFICATION_FAILED == error_code) {
// In case wallet verification fails, consider it as a success case
// wallet on card does not match with the required verification.
clear_core_error_screen();
handle_wallet_deleted_from_card(&delete_cfg);

// NOTE: When this case occurs, we are skipping card removal. This is
// because it is not possible to detect card's presence after desection.
// Card deselection is performed in fetch_card_share in this case.
buzzer_start(BUZZER_DURATION);
// TODO: Inform user that wallets with same name but failed verification
// might exist.
continue;
} else {
break;
}
}

if (STM_SUCCESS != nfc_wait_for_card(DEFAULT_NFC_TG_INIT_TIME)) {
instruction_scr_change_text(ui_text_card_removed_fast, true);
}

// Operation to delete wallet from card and update card state on flash
error_code =
card_delete_share(&delete_cfg, &handle_wallet_deleted_from_card);
Expand Down
2 changes: 1 addition & 1 deletion src/constant_texts.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ const char *ui_text_card_null_pointer_exception =
const char *ui_text_card_crypto_exception =
"Operation failed on card (Crypto Exp)";
const char *ui_text_card_invalid_apdu_length =
"Operation failed on card (APDU len exp)";
"Wallet with same name or seed already exists";
const char *ui_text_card_invalid_tag_in_apdu =
"Operation failed on card (Tag exp)";
const char *ui_text_unknown_error_contact_support =
Expand Down

0 comments on commit 4e391d9

Please sign in to comment.