Skip to content

Commit

Permalink
fix: corrupted profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
begonaalvarezd committed Oct 6, 2023
1 parent 3c3bf61 commit 0a541be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0a541be

Please sign in to comment.