From 4fe8cd6ab4e84825d1b1c972f54ec3460601e459 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Mon, 9 Oct 2023 11:02:13 +0200 Subject: [PATCH] fix: Fixed 'migration failed no chrysalis data to migrate' --- .../profiles/migrateDbChrysalisToStardust.ts | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/shared/lib/core/profile/actions/profiles/migrateDbChrysalisToStardust.ts b/packages/shared/lib/core/profile/actions/profiles/migrateDbChrysalisToStardust.ts index 00cbbcb53be..e6a09549754 100644 --- a/packages/shared/lib/core/profile/actions/profiles/migrateDbChrysalisToStardust.ts +++ b/packages/shared/lib/core/profile/actions/profiles/migrateDbChrysalisToStardust.ts @@ -3,6 +3,8 @@ import { api } from '@core/profile-manager' import { updateProfile } from '@core/profile/stores' import { getStorageDirectoryOfProfile } from '@core/profile/utils' +const ATTEMPT_MIGRATION_CHRYSALIS_TO_STARUDST_ERROR = 'migration failed no chrysalis data to migrate' + /** * Updates the profile underlying DB from chrysalis model to stardust. * @param profileId The profile that needs migration. @@ -16,20 +18,28 @@ export async function migrateDbChrysalisToStardust(profileId: string, pinCode: s if (response instanceof Error) { updateProfile(profileId, { needsChrysalisToStardustDbMigration: true }) let reason = '' + let migrate = false try { reason = JSON.parse(response.message).payload?.error + + // If there is no chrysalis data to migrate only happens when we are in Stardust, so we can safely skip this error. + if (reason === ATTEMPT_MIGRATION_CHRYSALIS_TO_STARUDST_ERROR) { + migrate = true + } } finally { - logAndNotifyError({ - type: 'wallet', - message: `Chrysalis database migration failed: ${reason}`, - saveToErrorLog: true, - showNotification: true, - originalError: response, - }) + if (!migrate) { + logAndNotifyError({ + type: 'wallet', + message: `Chrysalis database migration failed: ${reason}`, + saveToErrorLog: true, + showNotification: true, + originalError: response, + }) + } } - return false + return migrate } else { updateProfile(profileId, { needsChrysalisToStardustDbMigration: undefined }) return true