Skip to content

Commit

Permalink
chore: adds profile migration
Browse files Browse the repository at this point in the history
  • Loading branch information
jeeanribeiro committed Jul 1, 2024
1 parent 063deb5 commit 1599975
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AppStage } from '@core/app/enums'

export const PROFILE_VERSION: Record<AppStage, number> = {
[AppStage.ALPHA]: 22,
[AppStage.ALPHA]: 23,
[AppStage.BETA]: 1,
[AppStage.PROD]: 12,
[AppStage.PROD]: 13,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CryptoCurrency, FiatCurrency } from '@core/market'
import { IPersistedProfile } from '@core/profile/interfaces'

export function alphaProfileMigration22To23(existingProfile: unknown): Promise<void> {
const profile = existingProfile as IPersistedProfile
const marketCurrencies = [...Object.values(FiatCurrency), ...Object.values(CryptoCurrency)]

if (!marketCurrencies.includes(profile?.settings?.marketCurrency)) {
profile.settings.marketCurrency = FiatCurrency.USD
}

return Promise.resolve()
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { alphaProfileMigration19To20 } from './alpha-profile-migration-19-to-20'
import { alphaProfileMigration2To3 } from './alpha-profile-migration-2-to-3'
import { alphaProfileMigration20To21 } from './alpha-profile-migration-20-to-21'
import { alphaProfileMigration21To22 } from './alpha-profile-migration-21-to-22'
import { alphaProfileMigration22To23 } from './alpha-profile-migration-22-to-23'
import { alphaProfileMigration3To4 } from './alpha-profile-migration-3-to-4'
import { alphaProfileMigration4To5 } from './alpha-profile-migration-4-to-5'
import { alphaProfileMigration5To6 } from './alpha-profile-migration-5-to-6'
Expand Down Expand Up @@ -48,5 +49,6 @@ export const ALPHA_PROFILE_MIGRATION_MAP: ProfileMigrationMap = {
20: alphaProfileMigration20To21,
// ^^^ release 1.0.4 ^^^
21: alphaProfileMigration21To22,
22: alphaProfileMigration22To23,
// ^^^ release 1.0.8 ^^^
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CryptoCurrency, FiatCurrency } from '@core/market'
import { IPersistedProfile } from '@core/profile/interfaces'

export function prodProfileMigration12To13(existingProfile: unknown): Promise<void> {
const profile = existingProfile as IPersistedProfile
const marketCurrencies = [...Object.values(FiatCurrency), ...Object.values(CryptoCurrency)]

if (!marketCurrencies.includes(profile?.settings?.marketCurrency)) {
profile.settings.marketCurrency = FiatCurrency.USD
}

return Promise.resolve()
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { prodProfileMigration9To10 } from './prod-profile-migration-9-to-10'
import { prodProfileMigration8To9 } from './prod-profile-migration-8-to-9'
import { prodProfileMigration10To11 } from './prod-profile-migration-10-to-11'
import { prodProfileMigration11To12 } from './prod-profile-migration-11-to-12'
import { prodProfileMigration12To13 } from './prod-profile-migration-12-to-13'

export const PROD_PROFILE_MIGRATION_MAP: ProfileMigrationMap = {
0: prodProfileMigration0To1,
Expand All @@ -29,5 +30,6 @@ export const PROD_PROFILE_MIGRATION_MAP: ProfileMigrationMap = {
10: prodProfileMigration10To11,
// ^^^ release 1.0.4 ^^^
11: prodProfileMigration11To12,
12: prodProfileMigration12To13,
// ^^^ release 1.0.8 ^^^
}

0 comments on commit 1599975

Please sign in to comment.