-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/shared/src/lib/core/profile/constants/profile-version.constant.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]: 19, | ||
[AppStage.ALPHA]: 20, | ||
[AppStage.BETA]: 1, | ||
[AppStage.PROD]: 10, | ||
[AppStage.PROD]: 11, | ||
} |
23 changes: 23 additions & 0 deletions
23
packages/shared/src/lib/core/profile/migrations/actions/migrateEvmContacts.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { IContactAddressMap } from '@core/contact' | ||
import { isEvmNetwork, NetworkId, SupportedNetworkId } from '@core/network' | ||
import { IPersistedProfile } from '@core/profile/interfaces' | ||
|
||
export function migrateEvmContacts(profile: IPersistedProfile): void { | ||
const evmNetworks = Object.keys(profile.networkContactAddresses).filter((networkId) => | ||
isEvmNetwork(networkId as NetworkId) | ||
) | ||
|
||
const migratedContacts: IContactAddressMap = structuredClone( | ||
profile.networkContactAddresses[SupportedNetworkId.GenericEvm] ?? {} | ||
) | ||
|
||
evmNetworks.forEach((network) => { | ||
const networkContacts: IContactAddressMap = profile.networkContactAddresses[network] ?? {} | ||
Object.entries(networkContacts).forEach(([address, contactAddress]) => { | ||
migratedContacts[address] = contactAddress | ||
}) | ||
delete profile.networkContactAddresses[network] | ||
}) | ||
|
||
profile.networkContactAddresses[SupportedNetworkId.GenericEvm] = migratedContacts | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/shared/src/lib/core/profile/migrations/alpha/alpha-profile-migration-19-to-20.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { IPersistedProfile } from '../../interfaces' | ||
import { migrateEvmContacts } from '../../migrations/actions/migrateEvmContacts' | ||
|
||
export function alphaProfileMigration19To20(existingProfile: unknown): Promise<void> { | ||
const profile = existingProfile as IPersistedProfile | ||
|
||
migrateEvmContacts(profile) | ||
|
||
return Promise.resolve() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/shared/src/lib/core/profile/migrations/prod/prod-profile-migration-10-to-11.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { IPersistedProfile } from '../../interfaces' | ||
import { migrateEvmContacts } from '../actions/migrateEvmContacts' | ||
|
||
export function prodProfileMigration10To11(existingProfile: unknown): Promise<void> { | ||
const profile = existingProfile as IPersistedProfile | ||
|
||
migrateEvmContacts(profile) | ||
|
||
return Promise.resolve() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters