Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cleanup network feature flags #2445

Merged
merged 3 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions packages/desktop/features/network.features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ const networkFeatures: INetworkFeatures = {
enabled: false,
},
},
evmNetworks: {
enabled: false,
},
}

export default networkFeatures
12 changes: 12 additions & 0 deletions packages/desktop/features/onboarding.features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ const onboardingFeaturesForIota: IOnboardingFeaturesForNetwork = {
defaultIscChains: {
enabled: false,
},
defaultEvmChains: {
enabled: false,
},
}

const onboardingFeaturesForShimmer: IOnboardingFeaturesForNetwork = {
Expand Down Expand Up @@ -88,6 +91,9 @@ const onboardingFeaturesForShimmer: IOnboardingFeaturesForNetwork = {
defaultIscChains: {
enabled: true,
},
defaultEvmChains: {
enabled: false,
},
}

const onboardingFeaturesForTestnet: IOnboardingFeaturesForNetwork = {
Expand Down Expand Up @@ -132,6 +138,9 @@ const onboardingFeaturesForTestnet: IOnboardingFeaturesForNetwork = {
defaultIscChains: {
enabled: true,
},
defaultEvmChains: {
enabled: true,
},
}

const onboardingFeaturesForCustom: IOnboardingFeaturesForNetwork = {
Expand Down Expand Up @@ -176,6 +185,9 @@ const onboardingFeaturesForCustom: IOnboardingFeaturesForNetwork = {
defaultIscChains: {
enabled: false,
},
defaultEvmChains: {
enabled: false,
},
}

const onboardingFeatures: OnboardingFeatures = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { IPersistedProfile } from '@core/profile/interfaces'
import { DEFAULT_PERSISTED_PROFILE_OBJECT } from '@core/profile/constants'

import { IOnboardingProfile } from '../interfaces'
import { DEFAULT_L1_EVM_NETWORK_CONFIGURATION, SupportedNetworkId } from '@core/network/constants'
import features from '@features/features'
import { IPureEvmNetworkConfiguration } from '@core/network/interfaces'
import { DEFAULT_EVM_NETWORK_CONFIGURATIONS_FOR_STARDUST_NETWORK } from '@core/network/constants'

export function convertOnboardingProfileToPersistedProfile(
onboardingProfile?: Partial<IOnboardingProfile>
Expand All @@ -14,15 +12,7 @@ export function convertOnboardingProfileToPersistedProfile(
throw new Error('Network is undefined!')
}

let evmNetworks: IPureEvmNetworkConfiguration[] | undefined
if (features.network.evmNetworks.enabled) {
const addMainnetEthereum = [SupportedNetworkId.Shimmer, SupportedNetworkId.Iota].includes(network.id)
evmNetworks = [
DEFAULT_L1_EVM_NETWORK_CONFIGURATION[
addMainnetEthereum ? SupportedNetworkId.Ethereum : SupportedNetworkId.Sepolia
],
]
}
const evmNetworks = DEFAULT_EVM_NETWORK_CONFIGURATIONS_FOR_STARDUST_NETWORK[network.id] ?? []

return {
...structuredClone(DEFAULT_PERSISTED_PROFILE_OBJECT),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { isFeatureEnabled } from '@lib/features/utils'
import { ChainId, NetworkNamespace, NetworkType } from '../enums'
import { IPureEvmNetworkConfiguration } from '../interfaces'
import { StardustNetworkId } from '../types'
import { EVM_BASE_TOKEN } from './default-base-token.constant'
import { DEFAULT_COIN_TYPE } from './default-coin-type.constant'
import { DEFAULT_EXPLORER_URLS } from './default-explorer-urls.constant'
import {
SupportedL1EvmNetworkId,
SupportedNetworkId,
SupportedStardustNetworkId,
} from './supported-network-id.constant'

const ETHEREUM_NETWORK_CONFIGURATION: IPureEvmNetworkConfiguration = {
type: NetworkType.Evm,
name: 'Ethereum',
baseToken: EVM_BASE_TOKEN,
id: SupportedL1EvmNetworkId.Ethereum,
chainId: ChainId.Ethereum,
namespace: NetworkNamespace.Evm,
coinType: DEFAULT_COIN_TYPE[SupportedNetworkId.Ethereum] ?? 0,
explorerUrl: DEFAULT_EXPLORER_URLS[SupportedNetworkId.Ethereum],
rpcEndpoint: 'https://ethereum-rpc.publicnode.com',
}

export const SEPOLIA_NETWORK_CONFIGURATION: IPureEvmNetworkConfiguration = {
type: NetworkType.Evm,
name: 'Sepolia Testnet',
baseToken: EVM_BASE_TOKEN,
id: SupportedL1EvmNetworkId.Sepolia,
chainId: ChainId.Sepolia,
namespace: NetworkNamespace.Evm,
coinType: DEFAULT_COIN_TYPE[SupportedNetworkId.Sepolia] ?? 0,
explorerUrl: DEFAULT_EXPLORER_URLS[SupportedNetworkId.Sepolia],
rpcEndpoint: 'https://ethereum-sepolia-rpc.publicnode.com',
}

export const DEFAULT_EVM_NETWORK_CONFIGURATIONS_FOR_STARDUST_NETWORK: Readonly<{
[key in StardustNetworkId]: IPureEvmNetworkConfiguration[]
}> = {
...(isFeatureEnabled('onboarding.iota.defaultEvmChains') && {
[SupportedStardustNetworkId.Iota]: [ETHEREUM_NETWORK_CONFIGURATION],
}),
...(isFeatureEnabled('onboarding.shimmer.defaultEvmChains') && {
[SupportedStardustNetworkId.Shimmer]: [ETHEREUM_NETWORK_CONFIGURATION],
}),
...(isFeatureEnabled('onboarding.testnet.defaultEvmChains') && {
[SupportedStardustNetworkId.Testnet]: [SEPOLIA_NETWORK_CONFIGURATION],
}),
}

This file was deleted.

2 changes: 1 addition & 1 deletion packages/shared/src/lib/core/network/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export * from './default-coin-type.constant'
export * from './default-bech32-hrp.constant'
export * from './default-base-token.constant'
export * from './default-isc-chains-configurations.constant'
export * from './default-l1-evm-network-configurations.constant'
export * from './default-evm-network-configurations-for-stardust-network.constant'
export * from './default-explorer-urls.constant'
export * from './default-protocol.constant'
export * from './default-network-metadata.constant'
Expand Down
11 changes: 3 additions & 8 deletions packages/shared/src/lib/core/network/stores/networks.store.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { Writable, writable, get } from 'svelte/store'

import { activeProfile } from '@core/profile/stores'
import features from '@features/features'

import { IscChain, EvmNetwork, StardustNetwork } from '../classes'
import { IEvmNetwork, IIscChain, IStardustNetwork } from '../interfaces'
import { EvmNetworkId, Network, NetworkId, StardustNetworkId } from '../types'
Expand All @@ -18,11 +15,9 @@ export function initializeNetworks(): void {
_networks.push(stardustNetwork, ...stardustNetwork.iscChains)
}

if (features.network.evmNetworks.enabled) {
profile.evmNetworks?.forEach((evmNetwork) => {
_networks.push(new EvmNetwork(evmNetwork))
})
}
profile.evmNetworks?.forEach((evmNetwork) => {
_networks.push(new EvmNetwork(evmNetwork))
})

networks.set(_networks)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ export interface INetworkFeatures extends IFeatureFlag {
config: IFeatureFlag & {
addChain: IFeatureFlag
}
evmNetworks: IFeatureFlag
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ export interface IOnboardingFeaturesForNetwork extends IFeatureFlag {
ledgerBackup: IFeatureFlag
}
defaultIscChains: IFeatureFlag
defaultEvmChains: IFeatureFlag
}
Loading