From 640238443238e272433875f7f202d3b0d49d1677 Mon Sep 17 00:00:00 2001 From: lmcmz Date: Tue, 24 Feb 2026 16:43:58 +1100 Subject: [PATCH] fix: handle emptyMainAccount error for revoked key during multi-restore When a user's on-chain key is revoked, keyIndexer returns no account for the public key. This causes validateKeyProvider to classify it as "provider without account" instead of detecting the revoked state. restoreLogin then throws WalletError.emptyMainAccount, which was not caught by RestoreMultiAccountViewModel, falling into the generic error handler. Add a catch for WalletError.emptyMainAccount that follows the same recovery path as noActiveKeys: cleanup the revoked account and add a new key. Co-Authored-By: Claude Opus 4.6 --- .../ViewModel/RestoreMultiAccountViewModel.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/FRW/Modules/MultiRestore/ViewModel/RestoreMultiAccountViewModel.swift b/FRW/Modules/MultiRestore/ViewModel/RestoreMultiAccountViewModel.swift index 31bbf939..08162e40 100644 --- a/FRW/Modules/MultiRestore/ViewModel/RestoreMultiAccountViewModel.swift +++ b/FRW/Modules/MultiRestore/ViewModel/RestoreMultiAccountViewModel.swift @@ -66,6 +66,13 @@ class RestoreMultiAccountViewModel: ObservableObject { await WalletManager.shared.cleanupRevokedAccount(userId: selectedUserId) // Add the key again with new data addKey(item: selectedUser) + } catch WalletError.emptyMainAccount { + log.warning("[RestoreMultiAccountVM] Key revoked and no on-chain account found, cleaning up and adding new key") + HUD.dismissLoading() + // Key was revoked so keyIndexer returns no account for this public key + // Clean up and create a new key + await WalletManager.shared.cleanupRevokedAccount(userId: selectedUserId) + addKey(item: selectedUser) } catch { log.error("switch account failed", context: error) HUD.dismissLoading()