diff --git a/packages/desktop/features/network.features.ts b/packages/desktop/features/network.features.ts index 46e5469254..4aa3ab67d4 100644 --- a/packages/desktop/features/network.features.ts +++ b/packages/desktop/features/network.features.ts @@ -8,9 +8,6 @@ const networkFeatures: INetworkFeatures = { enabled: false, }, }, - evmNetworks: { - enabled: false, - }, } export default networkFeatures diff --git a/packages/desktop/features/onboarding.features.ts b/packages/desktop/features/onboarding.features.ts index 41d31406ef..54ec956446 100644 --- a/packages/desktop/features/onboarding.features.ts +++ b/packages/desktop/features/onboarding.features.ts @@ -44,6 +44,9 @@ const onboardingFeaturesForIota: IOnboardingFeaturesForNetwork = { defaultIscChains: { enabled: false, }, + defaultEvmChains: { + enabled: false, + }, } const onboardingFeaturesForShimmer: IOnboardingFeaturesForNetwork = { @@ -88,6 +91,9 @@ const onboardingFeaturesForShimmer: IOnboardingFeaturesForNetwork = { defaultIscChains: { enabled: true, }, + defaultEvmChains: { + enabled: false, + }, } const onboardingFeaturesForTestnet: IOnboardingFeaturesForNetwork = { @@ -132,6 +138,9 @@ const onboardingFeaturesForTestnet: IOnboardingFeaturesForNetwork = { defaultIscChains: { enabled: true, }, + defaultEvmChains: { + enabled: true, + }, } const onboardingFeaturesForCustom: IOnboardingFeaturesForNetwork = { @@ -176,6 +185,9 @@ const onboardingFeaturesForCustom: IOnboardingFeaturesForNetwork = { defaultIscChains: { enabled: false, }, + defaultEvmChains: { + enabled: false, + }, } const onboardingFeatures: OnboardingFeatures = { diff --git a/packages/shared/src/lib/contexts/onboarding/helpers/convertOnboardingProfileToPersistedProfile.ts b/packages/shared/src/lib/contexts/onboarding/helpers/convertOnboardingProfileToPersistedProfile.ts index 1e734047bb..49d7211333 100644 --- a/packages/shared/src/lib/contexts/onboarding/helpers/convertOnboardingProfileToPersistedProfile.ts +++ b/packages/shared/src/lib/contexts/onboarding/helpers/convertOnboardingProfileToPersistedProfile.ts @@ -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 @@ -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), diff --git a/packages/shared/src/lib/core/network/constants/default-evm-network-configurations-for-stardust-network.constant.ts b/packages/shared/src/lib/core/network/constants/default-evm-network-configurations-for-stardust-network.constant.ts new file mode 100644 index 0000000000..3952b292bb --- /dev/null +++ b/packages/shared/src/lib/core/network/constants/default-evm-network-configurations-for-stardust-network.constant.ts @@ -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], + }), +} diff --git a/packages/shared/src/lib/core/network/constants/default-l1-evm-network-configurations.constant.ts b/packages/shared/src/lib/core/network/constants/default-l1-evm-network-configurations.constant.ts deleted file mode 100644 index 689fadb358..0000000000 --- a/packages/shared/src/lib/core/network/constants/default-l1-evm-network-configurations.constant.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { ChainId, NetworkType, NetworkNamespace } from '../enums' -import { IPureEvmNetworkConfiguration } from '../interfaces' -import { EvmNetworkId } from '../types' -import { DEFAULT_COIN_TYPE } from './default-coin-type.constant' -import { SupportedL1EvmNetworkId, SupportedNetworkId } from './supported-network-id.constant' -import { DEFAULT_EXPLORER_URLS } from './default-explorer-urls.constant' -import { EVM_BASE_TOKEN } from './default-base-token.constant' - -export const DEFAULT_L1_EVM_NETWORK_CONFIGURATION: Readonly<{ - [key in EvmNetworkId]: IPureEvmNetworkConfiguration -}> = { - [SupportedL1EvmNetworkId.Ethereum]: { - 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', - }, - [SupportedL1EvmNetworkId.Sepolia]: { - 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', - }, -} diff --git a/packages/shared/src/lib/core/network/constants/index.ts b/packages/shared/src/lib/core/network/constants/index.ts index 42325d40c8..ca78462814 100644 --- a/packages/shared/src/lib/core/network/constants/index.ts +++ b/packages/shared/src/lib/core/network/constants/index.ts @@ -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' diff --git a/packages/shared/src/lib/core/network/stores/networks.store.ts b/packages/shared/src/lib/core/network/stores/networks.store.ts index d9fe024537..90769f2a2f 100644 --- a/packages/shared/src/lib/core/network/stores/networks.store.ts +++ b/packages/shared/src/lib/core/network/stores/networks.store.ts @@ -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' @@ -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) } diff --git a/packages/shared/src/lib/features/interfaces/network-features.interface.ts b/packages/shared/src/lib/features/interfaces/network-features.interface.ts index 1534e6e447..6fc43109fd 100644 --- a/packages/shared/src/lib/features/interfaces/network-features.interface.ts +++ b/packages/shared/src/lib/features/interfaces/network-features.interface.ts @@ -4,5 +4,4 @@ export interface INetworkFeatures extends IFeatureFlag { config: IFeatureFlag & { addChain: IFeatureFlag } - evmNetworks: IFeatureFlag } diff --git a/packages/shared/src/lib/features/interfaces/onboarding-features-for-network.interface.ts b/packages/shared/src/lib/features/interfaces/onboarding-features-for-network.interface.ts index 6fc84fc93c..d9221b46b6 100644 --- a/packages/shared/src/lib/features/interfaces/onboarding-features-for-network.interface.ts +++ b/packages/shared/src/lib/features/interfaces/onboarding-features-for-network.interface.ts @@ -18,4 +18,5 @@ export interface IOnboardingFeaturesForNetwork extends IFeatureFlag { ledgerBackup: IFeatureFlag } defaultIscChains: IFeatureFlag + defaultEvmChains: IFeatureFlag }