Skip to content

Commit

Permalink
feat(suite-naive): release L2 networks
Browse files Browse the repository at this point in the history
  • Loading branch information
vytick committed Feb 11, 2025
1 parent 65583b2 commit 448f707
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 49 deletions.
29 changes: 17 additions & 12 deletions suite-native/config/src/supportedNetworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,25 @@ export const orderedAccountTypes: AccountType[] = [
'ledger',
];

const discoveryBlacklist: NetworkSymbol[] = ['op', 'base', 'arb'];

// All supported coins for device discovery
export const networkSymbolsWhitelistMap: Record<'mainnet' | 'testnet', readonly NetworkSymbol[]> = {
mainnet: ['btc', 'eth', 'pol', 'sol', 'bsc', 'ltc', 'etc', 'ada', 'xrp', 'bch', 'doge', 'zec'],
mainnet: [
'btc',
'eth',
'pol',
'sol',
'bsc',
'ltc',
'etc',
'ada',
'xrp',
'bch',
'doge',
'zec',
'op',
'base',
'arb',
],
testnet: ['test', 'regtest', 'tsep', 'thol', 'dsol', 'tada', 'txrp'],
};

Expand All @@ -48,15 +62,6 @@ export const filterTestnetNetworks = (
return networkSymbols.filter(networkSymbol => !isTestnet(networkSymbol));
};

export const filterBlacklistedNetworks = (
networksToFilter: Network[],
allowList: NetworkSymbol[],
) =>
networksToFilter.filter(
network =>
!discoveryBlacklist.includes(network.symbol) || allowList.includes(network.symbol),
);

export const portfolioTrackerMainnets = sortNetworks(
getMainnets().filter(network => networkSymbolsWhitelistMap.mainnet.includes(network.symbol)),
).map(network => network.symbol);
Expand Down
28 changes: 4 additions & 24 deletions suite-native/discovery/src/discoveryConfigSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
selectDeviceSupportedNetworks,
} from '@suite-common/wallet-core';
import {
filterBlacklistedNetworks,
filterTestnetNetworks,
isDetoxTestBuild,
portfolioTrackerMainnets,
Expand Down Expand Up @@ -105,34 +104,20 @@ const createMemoizedSelector = createWeakMapSelector.withTypes<
DeviceRootState & DiscoveryConfigSliceRootState & FeatureFlagsRootState
>();

export const selectFeatureFlagEnabledNetworkSymbols = createMemoizedSelector(
[state => selectIsFeatureFlagEnabled(state, FeatureFlag.AreEthL2sEnabled)],
areEthL2sEnabled => {
const allowlist: NetworkSymbol[] = [];

if (areEthL2sEnabled) {
allowlist.push('base', 'op', 'arb');
}

return returnStableArrayIfEmpty(allowlist);
},
);

export const selectDiscoverySupportedNetworks = createMemoizedSelector(
[
selectDeviceSupportedNetworks,
selectAreTestnetsEnabled,
selectFeatureFlagEnabledNetworkSymbols,

(_state, forcedAreTestnetsEnabled?: boolean) => forcedAreTestnetsEnabled,
],
(deviceNetworks, defaultAreTestnetsEnabled, allowlist, forcedAreTestnetsEnabled) => {
(deviceNetworks, defaultAreTestnetsEnabled, forcedAreTestnetsEnabled) => {
const areTestnetsEnabled = forcedAreTestnetsEnabled ?? defaultAreTestnetsEnabled;

return pipe(
deviceNetworks,
networkSymbols => filterTestnetNetworks(networkSymbols, areTestnetsEnabled),
filterUnavailableNetworks,
availableNetworks => filterBlacklistedNetworks(availableNetworks, allowlist),
sortNetworks,
returnStableArrayIfEmpty,
);
Expand All @@ -147,11 +132,6 @@ export const selectDiscoveryNetworkSymbols = createMemoizedSelector(
supportedNetworks => returnStableArrayIfEmpty(supportedNetworks.map(n => n.symbol)),
);

export const selectPortfolioTrackerMainnetNetworkSymbols = createMemoizedSelector(
[selectFeatureFlagEnabledNetworkSymbols],
allowlist => returnStableArrayIfEmpty([...portfolioTrackerMainnets, ...allowlist]),
);

export const selectPortfolioTrackerTestnetNetworkSymbols = createMemoizedSelector(
[state => selectIsFeatureFlagEnabled(state, FeatureFlag.IsRegtestEnabled)],
isRegtestEnabled =>
Expand All @@ -163,8 +143,8 @@ export const selectPortfolioTrackerTestnetNetworkSymbols = createMemoizedSelecto
);

export const selectPortfolioTrackerNetworkSymbols = createMemoizedSelector(
[selectPortfolioTrackerMainnetNetworkSymbols, selectPortfolioTrackerTestnetNetworkSymbols],
(mainnets, testnets) => returnStableArrayIfEmpty([...mainnets, ...testnets]),
[selectPortfolioTrackerTestnetNetworkSymbols],
testnets => returnStableArrayIfEmpty([...portfolioTrackerMainnets, ...testnets]),
);

export const selectIsCoinEnablingInitFinished = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ describe('featureFlagsSlice', () => {
isCardanoSendEnabled: true,
isRegtestEnabled: true,
isConnectPopupEnabled: true,
areEthL2sEnabled: true,
isTradingEnabled: true,
isDeviceOnboardingEnabled: true,
IsFwRevisionCheckEnabled: true,
Expand All @@ -52,7 +51,6 @@ describe('featureFlagsSlice', () => {
isCardanoSendEnabled: false,
isRegtestEnabled: false,
isConnectPopupEnabled: false,
areEthL2sEnabled: false,
isTradingEnabled: false,
isDeviceOnboardingEnabled: false,
IsFwRevisionCheckEnabled: false,
Expand All @@ -79,7 +77,6 @@ describe('featureFlagsSlice', () => {
isCardanoSendEnabled: false,
isRegtestEnabled: false,
isConnectPopupEnabled: false,
areEthL2sEnabled: false,
isTradingEnabled: false,
isDeviceOnboardingEnabled: false,
IsFwRevisionCheckEnabled: false,
Expand Down
3 changes: 0 additions & 3 deletions suite-native/feature-flags/src/featureFlagsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const FeatureFlag = {
IsCardanoSendEnabled: 'isCardanoSendEnabled',
IsRegtestEnabled: 'isRegtestEnabled',
IsConnectPopupEnabled: 'isConnectPopupEnabled',
AreEthL2sEnabled: 'areEthL2sEnabled',
IsDeviceOnboardingEnabled: 'isDeviceOnboardingEnabled',
IsTradingEnabled: 'isTradingEnabled',
IsFwRevisionCheckEnabled: 'IsFwRevisionCheckEnabled',
Expand All @@ -27,7 +26,6 @@ export const featureFlagsInitialState: FeatureFlagsState = {
[FeatureFlag.IsCardanoSendEnabled]: isAndroid() && isDevelopOrDebugEnv(),
[FeatureFlag.IsRegtestEnabled]: isDebugEnv() || isDetoxTestBuild(),
[FeatureFlag.IsConnectPopupEnabled]: isDevelopOrDebugEnv(),
[FeatureFlag.AreEthL2sEnabled]: isDebugEnv(),
[FeatureFlag.IsDeviceOnboardingEnabled]: isDebugEnv() && !isDetoxTestBuild(),
[FeatureFlag.IsTradingEnabled]: isDebugEnv(),
[FeatureFlag.IsFwRevisionCheckEnabled]: isDevelopOrDebugEnv(),
Expand All @@ -38,7 +36,6 @@ export const featureFlagsPersistedKeys: Array<keyof FeatureFlagsState> = [
FeatureFlag.IsCardanoSendEnabled,
FeatureFlag.IsRegtestEnabled,
FeatureFlag.IsConnectPopupEnabled,
FeatureFlag.AreEthL2sEnabled,
FeatureFlag.IsDeviceOnboardingEnabled,
FeatureFlag.IsTradingEnabled,
FeatureFlag.IsFwRevisionCheckEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import { useSelector } from 'react-redux';
import { type NetworkSymbol } from '@suite-common/wallet-config';
import { SelectableNetworkItem } from '@suite-native/accounts';
import { HeaderedCard, VStack } from '@suite-native/atoms';
import {
selectPortfolioTrackerMainnetNetworkSymbols,
selectPortfolioTrackerTestnetNetworkSymbols,
} from '@suite-native/discovery';
import { portfolioTrackerMainnets } from '@suite-native/config';
import { selectPortfolioTrackerTestnetNetworkSymbols } from '@suite-native/discovery';
import { Translation } from '@suite-native/intl';

type SelectableAssetListProps = {
Expand All @@ -33,7 +31,6 @@ const NetworkItemSection = ({
);

export const SelectableNetworkList = ({ onSelectItem }: SelectableAssetListProps) => {
const portfolioMainnetNetworkSymbols = useSelector(selectPortfolioTrackerMainnetNetworkSymbols);
const portfolioTestnetsNetworkSymbols = useSelector(
selectPortfolioTrackerTestnetNetworkSymbols,
);
Expand All @@ -42,7 +39,7 @@ export const SelectableNetworkList = ({ onSelectItem }: SelectableAssetListProps
<VStack spacing="sp24">
<NetworkItemSection
title={<Translation id="moduleAccountImport.coinList.mainnets" />}
symbols={portfolioMainnetNetworkSymbols}
symbols={portfolioTrackerMainnets}
onSelectItem={onSelectItem}
/>
<NetworkItemSection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const featureFlagsTitleMap = {
[FeatureFlagEnum.IsCardanoSendEnabled]: 'Cardano send',
[FeatureFlagEnum.IsRegtestEnabled]: 'Regtest',
[FeatureFlagEnum.IsConnectPopupEnabled]: 'Connect Popup',
[FeatureFlagEnum.AreEthL2sEnabled]: 'Eth L2s',
[FeatureFlagEnum.IsDeviceOnboardingEnabled]: 'Device onboarding',
[FeatureFlagEnum.IsTradingEnabled]: 'Trading',
[FeatureFlagEnum.IsFwRevisionCheckEnabled]: 'Firmware Revision Check',
Expand Down

0 comments on commit 448f707

Please sign in to comment.