Skip to content

Commit

Permalink
chore: adds profile migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
jeeanribeiro committed Sep 12, 2024
1 parent e63799e commit 383e239
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { localize } from '@core/i18n'
import {
addNewEvmNetwork,
KNOWN_EVM_NETWORKS_CONFIGURATIONS,
KNOWN_EVM_MAINNET_NETWORKS_CONFIGURATIONS,
KNOWN_EVM_TESTNET_NETWORKS_CONFIGURATIONS,
SupportedNetworkId,
} from '@core/network'
Expand All @@ -20,7 +20,7 @@
const networkConfigurations = isTestnet
? KNOWN_EVM_TESTNET_NETWORKS_CONFIGURATIONS
: KNOWN_EVM_NETWORKS_CONFIGURATIONS
: KNOWN_EVM_MAINNET_NETWORKS_CONFIGURATIONS
const selectedChains = networkConfigurations.reduce((acc, networkConfiguration) => {
acc[networkConfiguration.id] = $activeProfile?.evmNetworks.some(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export const IMMUTABLE_TESTNET_NETWORK_CONFIGURATION: IPureEvmNetworkConfigurati
rpcEndpoint: 'https://rpc.testnet.immutable.com',
}

export const KNOWN_EVM_NETWORKS_CONFIGURATIONS: Readonly<IPureEvmNetworkConfiguration[]> = [
export const KNOWN_EVM_MAINNET_NETWORKS_CONFIGURATIONS: Readonly<IPureEvmNetworkConfiguration[]> = [
ETHEREUM_NETWORK_CONFIGURATION,
ARBITRUM_NETWORK_CONFIGURATION,
BASE_NETWORK_CONFIGURATION,
Expand All @@ -195,6 +195,11 @@ export const KNOWN_EVM_TESTNET_NETWORKS_CONFIGURATIONS: Readonly<IPureEvmNetwork
IMMUTABLE_TESTNET_NETWORK_CONFIGURATION,
]

export const KNOWN_EVM_NETWORKS_CONFIGURATIONS: Readonly<IPureEvmNetworkConfiguration[]> = [
...KNOWN_EVM_MAINNET_NETWORKS_CONFIGURATIONS,
...KNOWN_EVM_TESTNET_NETWORKS_CONFIGURATIONS,
]

export const DEFAULT_EVM_NETWORK_CONFIGURATIONS_FOR_STARDUST_NETWORK: Readonly<{
[key in StardustNetworkId]: IPureEvmNetworkConfiguration[]
}> = {
Expand Down
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]: 25,
[AppStage.ALPHA]: 26,
[AppStage.BETA]: 1,
[AppStage.PROD]: 15,
[AppStage.PROD]: 16,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { IIscChainConfiguration } from '@core/network'
import { KNOWN_EVM_NETWORKS_CONFIGURATIONS } from '@core/network/constants'
import { IPersistedProfile } from '@core/profile/interfaces'

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

const chainConfigurations = profile.network.chainConfigurations as (IIscChainConfiguration & {
explorerUrl?: string
})[]
chainConfigurations.forEach((chainConfiguration) => {
delete chainConfiguration.explorerUrl
chainConfiguration.explorer = KNOWN_EVM_NETWORKS_CONFIGURATIONS.find(
(networkConfiguration) => networkConfiguration.id === chainConfiguration.id
)?.explorer
})

return Promise.resolve()
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { alphaProfileMigration21To22 } from './alpha-profile-migration-21-to-22'
import { alphaProfileMigration22To23 } from './alpha-profile-migration-22-to-23'
import { alphaProfileMigration23To24 } from './alpha-profile-migration-23-to-24'
import { alphaProfileMigration24To25 } from './alpha-profile-migration-24-to-25'
import { alphaProfileMigration25To26 } from './alpha-profile-migration-25-to-26'
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 @@ -57,4 +58,5 @@ export const ALPHA_PROFILE_MIGRATION_MAP: ProfileMigrationMap = {
23: alphaProfileMigration23To24,
// ^^^ release 1.1.3 ^^^
24: alphaProfileMigration24To25,
25: alphaProfileMigration25To26,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { IIscChainConfiguration } from '@core/network'
import { KNOWN_EVM_NETWORKS_CONFIGURATIONS } from '@core/network/constants'
import { IPersistedProfile } from '@core/profile/interfaces'

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

const chainConfigurations = profile.network.chainConfigurations as (IIscChainConfiguration & {
explorerUrl?: string
})[]
chainConfigurations.forEach((chainConfiguration) => {
delete chainConfiguration.explorerUrl
chainConfiguration.explorer = KNOWN_EVM_NETWORKS_CONFIGURATIONS.find(
(networkConfiguration) => networkConfiguration.id === chainConfiguration.id
)?.explorer
})

return Promise.resolve()
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { prodProfileMigration11To12 } from './prod-profile-migration-11-to-12'
import { prodProfileMigration12To13 } from './prod-profile-migration-12-to-13'
import { prodProfileMigration13To14 } from './prod-profile-migration-13-to-14'
import { prodProfileMigration14To15 } from './prod-profile-migration-14-to-15'
import { prodProfileMigration15To16 } from './prod-profile-migration-15-to-16'

export const PROD_PROFILE_MIGRATION_MAP: ProfileMigrationMap = {
0: prodProfileMigration0To1,
Expand All @@ -38,4 +39,5 @@ export const PROD_PROFILE_MIGRATION_MAP: ProfileMigrationMap = {
13: prodProfileMigration13To14,
// ^^^ release 1.1.3 ^^^
14: prodProfileMigration14To15,
15: prodProfileMigration15To16,
}

0 comments on commit 383e239

Please sign in to comment.