From 0a541be83005aa6c61f7f73532b3b01ecafae9c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bego=C3=B1a=20Alvarez?= Date: Fri, 6 Oct 2023 12:54:18 +0200 Subject: [PATCH] fix: corrupted profiles --- .../actions/profiles/checkAndMigrateChrysalisProfiles.ts | 7 ++++++- .../profile/actions/profiles/checkAndMigrateProfiles.ts | 7 ++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateChrysalisProfiles.ts b/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateChrysalisProfiles.ts index 9d5b9468776..9fed0a610ee 100644 --- a/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateChrysalisProfiles.ts +++ b/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateChrysalisProfiles.ts @@ -114,7 +114,7 @@ function getMigratedNetworkId(chrysalisNetworkId: ChrysalisNetworkId): NetworkId case ChrysalisNetworkId.PrivateNet: return NetworkId.Custom default: - throw new Error(`Unable to migrate network: ${chrysalisNetworkId}`) + return NetworkId.Iota } } @@ -159,6 +159,11 @@ function isChrysalisProfile(profile: IPersistedProfile | IChrysalisPersistedProf if (chrysalisProfileAccounts.find((account) => account.id.startsWith('wallet-account://'))) { return true } + } else { + const partiallyStardustProfile = profile as IPersistedProfile + if (!partiallyStardustProfile.network || !partiallyStardustProfile.accountPersistedData) { + return true + } } return false } diff --git a/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateProfiles.ts b/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateProfiles.ts index fb787fd9c33..2f829640ed4 100644 --- a/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateProfiles.ts +++ b/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateProfiles.ts @@ -34,11 +34,8 @@ export function checkAndMigrateProfiles(): void { if (_currentProfileVersion === -1) currentProfileVersion.set(CHRYSALIS_TO_STARDUST_PROFILE_VERSION) const shouldMigratePersistedProfiles = (_currentProfileVersion ?? 3) < PROFILE_VERSION - // patch chrysalis unmigrated profiles - if ( - shouldMigratePersistedProfiles || - (_currentProfileVersion >= CHRYSALIS_TO_STARDUST_PROFILE_VERSION && _currentProfileVersion <= 16) - ) { + // patch chrysalis unmigrated profiles to re-check profiles until v16 + if (shouldMigratePersistedProfiles || _currentProfileVersion <= 16) { if (checkAndMigrateChrysalisProfiles()) { // If there was a migration, we need to update the currentProfileVersion // to the latest compatible with the chrysalis migration, which is 13