Skip to content

Commit

Permalink
update migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkNerdi committed Apr 26, 2024
1 parent 8b41563 commit cf0026b
Show file tree
Hide file tree
Showing 5 changed files with 46 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]: 15,
[AppStage.ALPHA]: 16,
[AppStage.BETA]: 1,
[AppStage.PROD]: 8,
[AppStage.PROD]: 9,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { DappVerification } from '@auxiliary/wallet-connect/enums'
import { persistDapp, persistedDappNamespaces } from '@auxiliary/wallet-connect/stores'
import { IPersistedProfile } from '@core/profile/interfaces'
import { get } from 'svelte/store'

export function alphaProfileMigration15To16(existingProfile: unknown): Promise<void> {
const profile = existingProfile as IPersistedProfile

const namespaces = get(persistedDappNamespaces)[profile.id] ?? {}
for (const dappUrl of Object.keys(namespaces)) {
persistDapp(dappUrl, DappVerification.Unknown, namespaces[dappUrl])
}

persistedDappNamespaces.update((state) => {
delete state[profile.id]
return state
})

return Promise.resolve()
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { alphaProfileMigration11To12 } from './alpha-profile-migration-11-to-12'
import { alphaProfileMigration12To13 } from './alpha-profile-migration-12-to-13'
import { alphaProfileMigration13To14 } from './alpha-profile-migration-13-to-14'
import { alphaProfileMigration14To15 } from './alpha-profile-migration-14-to-15'
import { alphaProfileMigration15To16 } from './alpha-profile-migration-15-to-16'
import { alphaProfileMigration2To3 } from './alpha-profile-migration-2-to-3'
import { alphaProfileMigration3To4 } from './alpha-profile-migration-3-to-4'
import { alphaProfileMigration4To5 } from './alpha-profile-migration-4-to-5'
Expand All @@ -31,4 +32,5 @@ export const ALPHA_PROFILE_MIGRATION_MAP: ProfileMigrationMap = {
12: alphaProfileMigration12To13,
13: alphaProfileMigration13To14,
14: alphaProfileMigration14To15,
15: alphaProfileMigration15To16,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { DappVerification } from '@auxiliary/wallet-connect/enums'
import { persistDapp, persistedDappNamespaces } from '@auxiliary/wallet-connect/stores'
import { IPersistedProfile } from '@core/profile/interfaces'
import { get } from 'svelte/store'

export function prodProfileMigration8To9(existingProfile: unknown): Promise<void> {
const profile = existingProfile as IPersistedProfile

const namespaces = get(persistedDappNamespaces)[profile.id] ?? {}
for (const dappUrl of Object.keys(namespaces)) {
persistDapp(dappUrl, DappVerification.Unknown, namespaces[dappUrl])
}

persistedDappNamespaces.update((state) => {
delete state[profile.id]
return state
})

return Promise.resolve()
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { prodProfileMigration4To5 } from './prod-profile-migration-4-to-5'
import { prodProfileMigration5To6 } from './prod-profile-migration-5-to-6'
import { prodProfileMigration6To7 } from './prod-profile-migration-6-to-7'
import { prodProfileMigration7To8 } from './prod-profile-migration-7-to-8'
import { prodProfileMigration8To9 } from './prod-profile-migration-8-to-9'

export const PROD_PROFILE_MIGRATION_MAP: ProfileMigrationMap = {
0: prodProfileMigration0To1,
Expand All @@ -18,4 +19,5 @@ export const PROD_PROFILE_MIGRATION_MAP: ProfileMigrationMap = {
5: prodProfileMigration5To6,
6: prodProfileMigration6To7,
7: prodProfileMigration7To8,
8: prodProfileMigration8To9,
}

0 comments on commit cf0026b

Please sign in to comment.