Skip to content

Commit

Permalink
fix: Fixed 'migration failed no chrysalis data to migrate'
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 committed Oct 9, 2023
1 parent 331cbe4 commit 4fe8cd6
Showing 1 changed file with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down

0 comments on commit 4fe8cd6

Please sign in to comment.