From aa9c5e99b19c1018c31a495ce4f2d9739dc3b88b Mon Sep 17 00:00:00 2001 From: salimtb Date: Sat, 28 Sep 2024 22:21:59 +0200 Subject: [PATCH] fix: remove feature flag --- .../CellSelectWithMenu.test.tsx.snap | 10 +- .../ListItemMultiSelectButton.test.tsx.snap | 10 +- app/components/Nav/App/index.js | 13 +- .../NetworkSwitcher.test.tsx.snap | 72 +- .../MultiRpcModal/MultiRpcModal.test.tsx | 2 +- .../Views/MultiRpcModal/MultiRpcModal.tsx | 2 +- .../NetworkSearchTextInput.tsx | 36 +- .../NetworkSelector/NetworkSelector.styles.ts | 9 +- .../NetworkSelector/NetworkSelector.test.tsx | 25 - .../Views/NetworkSelector/NetworkSelector.tsx | 279 +- .../NetworkSelector.test.tsx.snap | 2597 +++++++++++++---- .../CustomNetworkView/CustomNetwork.tsx | 3 +- .../__snapshots__/index.test.tsx.snap | 62 - .../NetworksSettings/NetworkSettings/index.js | 312 +- .../NetworkSettings/index.test.tsx | 32 - .../NetworkSettings/styles.ts | 3 +- .../__snapshots__/index.test.tsx.snap | 5 +- app/components/Views/Wallet/index.tsx | 20 +- .../networks/isNetworkUiRedesignEnabled.ts | 5 +- app/util/test/initial-background-state.json | 1 + bitrise.yml | 3 - ...tamask+preferences-controller+11.0.0.patch | 8 +- 22 files changed, 2364 insertions(+), 1145 deletions(-) diff --git a/app/component-library/components-temp/CellSelectWithMenu/__snapshots__/CellSelectWithMenu.test.tsx.snap b/app/component-library/components-temp/CellSelectWithMenu/__snapshots__/CellSelectWithMenu.test.tsx.snap index 5b97c76e34c9..267192b91aaa 100644 --- a/app/component-library/components-temp/CellSelectWithMenu/__snapshots__/CellSelectWithMenu.test.tsx.snap +++ b/app/component-library/components-temp/CellSelectWithMenu/__snapshots__/CellSelectWithMenu.test.tsx.snap @@ -19,7 +19,7 @@ exports[`CellSelectWithMenu should render with default settings correctly 1`] = "opacity": 1, "padding": 16, "position": "relative", - "width": "95%", + "width": "90%", "zIndex": 1, } } @@ -278,7 +278,13 @@ exports[`CellSelectWithMenu should render with default settings correctly 1`] = - + - + { component={AddNetworkFlow} options={{ animationEnabled: true }} /> - {isNetworkUiRedesignEnabled() ? ( - - ) : null} + { const allowButton = getByTestId('allow'); fireEvent.press(allowButton); - expect(setShowMultiRpcModalSpy).toHaveBeenCalledWith(true); + expect(setShowMultiRpcModalSpy).toHaveBeenCalledWith(false); }); }); diff --git a/app/components/Views/MultiRpcModal/MultiRpcModal.tsx b/app/components/Views/MultiRpcModal/MultiRpcModal.tsx index 637644e525ad..dfb582b3f1b5 100644 --- a/app/components/Views/MultiRpcModal/MultiRpcModal.tsx +++ b/app/components/Views/MultiRpcModal/MultiRpcModal.tsx @@ -83,7 +83,7 @@ const MultiRpcModal = () => { {Object.values(networkConfigurations).map( (networkConfiguration: NetworkConfiguration, index) => - networkConfiguration.rpcEndpoints.length > 0 ? ( + networkConfiguration.rpcEndpoints.length > 1 ? ( { - isNetworkUiRedesignEnabled() && setIsSearchFieldFocused(true); - }, - onBlur: () => { - isNetworkUiRedesignEnabled() && setIsSearchFieldFocused(false); - }, - } - : {}; + const propsWhichAreFeatureFlagged = { + onFocus: () => { + setIsSearchFieldFocused(true); + }, + onBlur: () => { + setIsSearchFieldFocused(false); + }, + }; - const inputStylesWhichAreFeatureFlagged = !isNetworkUiRedesignEnabled() - ? styles.input - : isSearchFieldFocused + const inputStylesWhichAreFeatureFlagged = isSearchFieldFocused ? styles.input : styles.unfocusedInput; - const containerInputStylesWhichAreFeatureFlagged = - !isNetworkUiRedesignEnabled() - ? styles.inputWrapper - : isSearchFieldFocused - ? styles.focusedInputWrapper - : styles.inputWrapper; + const containerInputStylesWhichAreFeatureFlagged = isSearchFieldFocused + ? styles.focusedInputWrapper + : styles.inputWrapper; return ( diff --git a/app/components/Views/NetworkSelector/NetworkSelector.styles.ts b/app/components/Views/NetworkSelector/NetworkSelector.styles.ts index abb26c22f9ef..b3421b35c72c 100644 --- a/app/components/Views/NetworkSelector/NetworkSelector.styles.ts +++ b/app/components/Views/NetworkSelector/NetworkSelector.styles.ts @@ -3,7 +3,6 @@ import Device from '../../../util/device'; import { StyleSheet } from 'react-native'; import { fontStyles } from '../../../styles/common'; import { Colors } from '../../../util/theme/models'; -import { isNetworkUiRedesignEnabled } from '../../../util/networks/isNetworkUiRedesignEnabled'; /** * Style sheet function for NetworkSelector screen. @@ -13,11 +12,7 @@ const createStyles = (colors: Colors) => StyleSheet.create({ addNetworkButton: { marginHorizontal: 16, - marginBottom: Device.isAndroid() - ? 16 - : isNetworkUiRedesignEnabled() - ? 12 - : 0, + marginBottom: Device.isAndroid() ? 16 : 12, }, networkMenu: { alignItems: 'center', @@ -109,7 +104,7 @@ const createStyles = (colors: Colors) => marginTop: 1, }, networkListContainer: { - height: isNetworkUiRedesignEnabled() ? '100%' : undefined, + height: '100%', }, networkIcon: { width: 20, diff --git a/app/components/Views/NetworkSelector/NetworkSelector.test.tsx b/app/components/Views/NetworkSelector/NetworkSelector.test.tsx index 91d7319187de..1c385f87dd77 100644 --- a/app/components/Views/NetworkSelector/NetworkSelector.test.tsx +++ b/app/components/Views/NetworkSelector/NetworkSelector.test.tsx @@ -11,7 +11,6 @@ import { backgroundState } from '../../../util/test/initial-root-state'; import NetworkSelector from './NetworkSelector'; import { CHAIN_IDS } from '@metamask/transaction-controller'; import { NetworkListModalSelectorsIDs } from '../../../../e2e/selectors/Modals/NetworkListModal.selectors'; -import { isNetworkUiRedesignEnabled } from '../../../util/networks/isNetworkUiRedesignEnabled'; import { mockNetworkState } from '../../../util/test/network'; const mockEngine = Engine; @@ -21,11 +20,6 @@ const setShowTestNetworksSpy = jest.spyOn( 'setShowTestNetworks', ); -// Mock the entire module -jest.mock('../../../util/networks/isNetworkUiRedesignEnabled', () => ({ - isNetworkUiRedesignEnabled: jest.fn(), -})); - jest.mock('../../../util/transaction-controller', () => ({ updateIncomingTransactions: jest.fn(), })); @@ -180,13 +174,11 @@ const renderComponent = (state: any = {}) => describe('Network Selector', () => { it('renders correctly', () => { - (isNetworkUiRedesignEnabled as jest.Mock).mockImplementation(() => false); const { toJSON } = renderComponent(initialState); expect(toJSON()).toMatchSnapshot(); }); it('changes network when another network cell is pressed', async () => { - (isNetworkUiRedesignEnabled as jest.Mock).mockImplementation(() => false); const { getByText } = renderComponent(initialState); const polygonCell = getByText('Polygon Mainnet'); @@ -196,7 +188,6 @@ describe('Network Selector', () => { }); it('toggles the test networks switch correctly', () => { - (isNetworkUiRedesignEnabled as jest.Mock).mockImplementation(() => false); const { getByTestId } = renderComponent(initialState); const testNetworksSwitch = getByTestId( NetworkListModalSelectorsIDs.TEST_NET_TOGGLE, @@ -208,7 +199,6 @@ describe('Network Selector', () => { }); it('toggle test network is disabled and is on when a testnet is selected', () => { - (isNetworkUiRedesignEnabled as jest.Mock).mockImplementation(() => false); const { getByTestId } = renderComponent({ navigation: { currentBottomNavRoute: 'Wallet' }, settings: { @@ -333,7 +323,6 @@ describe('Network Selector', () => { expect(mockEngine.context.NetworkController.setActiveNetwork).toBeCalled(); }); it('renders correctly with no network configurations', async () => { - (isNetworkUiRedesignEnabled as jest.Mock).mockImplementation(() => true); const stateWithNoNetworkConfigurations = { ...initialState, engine: { @@ -360,7 +349,6 @@ describe('Network Selector', () => { }); it('renders the multi-RPC selection modal correctly', async () => { - (isNetworkUiRedesignEnabled as jest.Mock).mockImplementation(() => true); const { getByText } = renderComponent(initialState); const polygonCell = getByText('Polygon Mainnet'); @@ -372,17 +360,4 @@ describe('Network Selector', () => { expect(rpcOption).toBeTruthy(); }); }); - - it('switches RPC URL when a different RPC URL is selected', async () => { - (isNetworkUiRedesignEnabled as jest.Mock).mockImplementation(() => true); - const { getByText } = renderComponent(initialState); - const polygonCell = getByText('Polygon Mainnet'); - - fireEvent.press(polygonCell); - - await waitFor(() => { - const rpcOption = getByText('polygon-mainnet.infura.io/v3'); - fireEvent.press(rpcOption); - }); - }); }); diff --git a/app/components/Views/NetworkSelector/NetworkSelector.tsx b/app/components/Views/NetworkSelector/NetworkSelector.tsx index 93dc8d7baaab..64c397d66289 100644 --- a/app/components/Views/NetworkSelector/NetworkSelector.tsx +++ b/app/components/Views/NetworkSelector/NetworkSelector.tsx @@ -85,7 +85,6 @@ import { ButtonsAlignment } from '../../../component-library/components/BottomSh import { ButtonProps } from '../../../component-library/components/Buttons/Button/Button.types'; import BottomSheetFooter from '../../../component-library/components/BottomSheets/BottomSheetFooter/BottomSheetFooter'; import { ExtendedNetwork } from '../Settings/NetworksSettings/NetworkSettings/CustomNetworkView/CustomNetwork.types'; -import { isNetworkUiRedesignEnabled } from '../../../util/networks/isNetworkUiRedesignEnabled'; import { Hex } from '@metamask/utils'; import ListItemSelect from '../../../component-library/components/List/ListItemSelect'; import hideProtocolFromUrl from '../../../util/hideProtocolFromUrl'; @@ -146,16 +145,10 @@ const NetworkSelector = () => { networkName: selectedNetworkName, } = useNetworkInfo(origin); - const avatarSize = isNetworkUiRedesignEnabled() ? AvatarSize.Sm : undefined; - const modalTitle = isNetworkUiRedesignEnabled() - ? 'networks.additional_network_information_title' - : 'networks.network_warning_title'; - const modalDescription = isNetworkUiRedesignEnabled() - ? 'networks.additonial_network_information_desc' - : 'networks.network_warning_desc'; - const buttonLabelAddNetwork = isNetworkUiRedesignEnabled() - ? 'app_settings.network_add_custom_network' - : 'app_settings.network_add_network'; + const avatarSize = AvatarSize.Sm; + const modalTitle = 'networks.additional_network_information_title'; + const modalDescription = 'networks.additonial_network_information_desc'; + const buttonLabelAddNetwork = 'app_settings.network_add_custom_network'; const [showConfirmDeleteModal, setShowConfirmDeleteModal] = useState({ isVisible: false, @@ -402,53 +395,35 @@ const NetworkSelector = () => { networkConfigurations?.[chainId]?.defaultRpcEndpointIndex ].url; - if (isNetworkUiRedesignEnabled() && isNoSearchResults(MAINNET)) return null; - - if (isNetworkUiRedesignEnabled()) { - return ( - onNetworkChange(MAINNET, chainId)} - style={styles.networkCell} - buttonIcon={IconName.MoreVertical} - onButtonClick={() => { - openModal(chainId, false, MAINNET, true); - }} - // TODO: Substitute with the new network controller's RPC array. - onTextClick={() => - openRpcModal({ - rpcUrls: [hideKeyFromUrl(MAINNET_DEFAULT_RPC_URL)], - chainId, - networkName: mainnetName, - }) - } - /> - ); - } + if (isNoSearchResults(MAINNET)) return null; return ( onNetworkChange(MAINNET, chainId)} style={styles.networkCell} + buttonIcon={IconName.MoreVertical} + onButtonClick={() => { + openModal(chainId, false, MAINNET, true); + }} + // TODO: Substitute with the new network controller's RPC array. + onTextClick={() => + openRpcModal({ + rpcUrls: [hideKeyFromUrl(MAINNET_DEFAULT_RPC_URL)], + chainId, + networkName: mainnetName, + }) + } /> ); }; @@ -456,53 +431,35 @@ const NetworkSelector = () => { const renderLineaMainnet = () => { const { name: lineaMainnetName, chainId } = Networks['linea-mainnet']; - if (isNetworkUiRedesignEnabled() && isNoSearchResults('linea-mainnet')) - return null; - - if (isNetworkUiRedesignEnabled()) { - return ( - onNetworkChange(LINEA_MAINNET, chainId)} - style={styles.networkCell} - buttonIcon={IconName.MoreVertical} - secondaryText={hideKeyFromUrl(LINEA_DEFAULT_RPC_URL)} - onButtonClick={() => { - openModal(chainId, false, LINEA_MAINNET, true); - }} - // TODO: Substitute with the new network controller's RPC array. - onTextClick={() => - openRpcModal({ - rpcUrls: [LINEA_DEFAULT_RPC_URL], - chainId, - networkName: lineaMainnetName, - }) - } - /> - ); - } + if (isNoSearchResults('linea-mainnet')) return null; return ( onNetworkChange(LINEA_MAINNET, chainId)} + style={styles.networkCell} + buttonIcon={IconName.MoreVertical} + secondaryText={hideKeyFromUrl(LINEA_DEFAULT_RPC_URL)} + onButtonClick={() => { + openModal(chainId, false, LINEA_MAINNET, true); + }} + // TODO: Substitute with the new network controller's RPC array. + onTextClick={() => + openRpcModal({ + rpcUrls: [LINEA_DEFAULT_RPC_URL], + chainId, + networkName: lineaMainnetName, + }) + } /> ); }; @@ -525,59 +482,37 @@ const NetworkSelector = () => { const name = nickname || rpcName; - if (isNetworkUiRedesignEnabled() && isNoSearchResults(name)) - return null; + if (isNoSearchResults(name)) return null; //@ts-expect-error - The utils/network file is still JS and this function expects a networkType, and should be optional const image = getNetworkImageSource({ chainId: chainId?.toString() }); - if (isNetworkUiRedesignEnabled()) { - return ( - onSetRpcTarget(rpcUrl)} - style={styles.networkCell} - buttonIcon={IconName.MoreVertical} - secondaryText={hideProtocolFromUrl(hideKeyFromUrl(rpcUrl))} - onButtonClick={() => { - openModal(chainId, true, rpcUrl, false); - }} - onTextClick={() => - openRpcModal({ - rpcUrls: [hideKeyFromUrl(rpcUrl)], - chainId, - networkName: name, - }) - } - /> - ); - } - return ( onSetRpcTarget(rpcUrl)} style={styles.networkCell} + buttonIcon={IconName.MoreVertical} + secondaryText={hideProtocolFromUrl(hideKeyFromUrl(rpcUrl))} + onButtonClick={() => { + openModal(chainId, true, rpcUrl, false); + }} + onTextClick={() => + openRpcModal({ + rpcUrls: [hideKeyFromUrl(rpcUrl)], + chainId, + networkName: name, + }) + } /> ); }, @@ -603,53 +538,34 @@ const NetworkSelector = () => { networkConfiguration?.defaultRpcEndpointIndex ].url ?? ''; - if (isNetworkUiRedesignEnabled() && isNoSearchResults(name)) return null; - - if (isNetworkUiRedesignEnabled()) { - return ( - onNetworkChange(networkType, chainId)} - style={styles.networkCell} - buttonIcon={IconName.MoreVertical} - onButtonClick={() => { - openModal(chainId, false, networkType, true); - }} - onTextClick={() => - openRpcModal({ - rpcUrls: [hideKeyFromUrl(rpcUrl)], - chainId, - networkName: name, - }) - } - /> - ); - } + if (isNoSearchResults(name)) return null; return ( onNetworkChange(networkType, chainId)} style={styles.networkCell} + buttonIcon={IconName.MoreVertical} + onButtonClick={() => { + openModal(chainId, false, networkType, true); + }} + onTextClick={() => + openRpcModal({ + rpcUrls: [hideKeyFromUrl(rpcUrl)], + chainId, + networkName: name, + }) + } /> ); }); @@ -690,7 +606,7 @@ const NetworkSelector = () => { const renderAdditonalNetworks = () => { let filteredNetworks; - if (isNetworkUiRedesignEnabled() && searchString.length > 0) + if (searchString.length > 0) filteredNetworks = PopularList.filter(({ nickname }) => nickname.toLowerCase().includes(searchString.toLowerCase()), ); @@ -868,35 +784,37 @@ const NetworkSelector = () => { ); - }, [showMultiRpcSelectModal, rpcMenuSheetRef, closeRpcModal, styles]); + }, [ + showMultiRpcSelectModal, + rpcMenuSheetRef, + closeRpcModal, + styles, + networkConfigurations, + providerConfig.chainId, + selectedNetworkClientId, + ]); const renderBottomSheetContent = () => ( <> - {isNetworkUiRedesignEnabled() && ( - - - - )} - {isNetworkUiRedesignEnabled() && - searchString.length === 0 && - renderEnabledNetworksTitle()} + + + + {searchString.length === 0 && renderEnabledNetworksTitle()} {renderMainnet()} {renderLineaMainnet()} {renderRpcNetworks()} - {isNetworkUiRedesignEnabled() && - searchString.length === 0 && - renderPopularNetworksTitle()} - {isNetworkUiRedesignEnabled() && renderAdditonalNetworks()} + {searchString.length === 0 && renderPopularNetworksTitle()} + {renderAdditonalNetworks()} {searchString.length === 0 && renderTestNetworksSwitch()} {showTestNetworks && renderOtherNetworks()} @@ -915,14 +833,9 @@ const NetworkSelector = () => { return ( - {isNetworkUiRedesignEnabled() ? ( - - {renderBottomSheetContent()} - - ) : ( - renderBottomSheetContent() - )} - + + {renderBottomSheetContent()} + {showWarningModal ? ( - - Select a network - - - - - - + + Select a network + + + + + @@ -496,671 +486,2290 @@ exports[`Network Selector renders correctly 1`] = ` style={ { "alignItems": "center", + "borderColor": "#bbc0c5", + "borderRadius": 5, + "borderWidth": 1, + "color": "#141618", "flexDirection": "row", + "paddingHorizontal": 10, + "paddingVertical": 10, } } > - - - - +  + + - - Ethereum Main Network - - + testID="network-search-input" + value="" + /> - + > + Enabled networks + - - - - + + + + + + Ethereum Main Network + + + + + + - + + - - Linea Main Network - - + width={16} + /> + - - - - + > + + + + + + Linea Main Network + + + + https://linea-mainnet.infura.io/v3 + + + + + - + + - - Avalanche Mainnet C-Chain - - + width={16} + /> + - - - - + > + + + + + + Avalanche Mainnet C-Chain + + + + api.avax.network/ext/bc/C + + + + + - + + - - Polygon Mainnet - - + width={16} + /> + - - - - + > + + + + + + Polygon Mainnet + + + + polygon-mainnet.infura.io/v3 + + + + + - + + - - Optimism - - + width={16} + /> + - - - - - G - + + + + + + Optimism + + + + optimism-mainnet.infura.io/v3 + + + + + - + + - - Gnosis Chain - - + width={16} + /> + - - - - Show test networks - - + + + + + G + + + + + Gnosis Chain + + + + rpc.gnosischain.com + + + + + + + + + + + + + + + + Additional networks + + + +  + + + + + + + + + + + + + Arbitrum One + + + + + Add + + + + + + + + + + + + BNB Chain + + + + + Add + + + + + + + + + + + + Base + + + + + Add + + + + + + + + + + + + Palm + + + + + Add + + + + + + + + + + + + zkSync Era Mainnet + + + + + Add + + + + + + > + + Show test networks + + + - - - - + - Add Network - - + + Add a custom network + + + diff --git a/app/components/Views/Settings/NetworksSettings/NetworkSettings/CustomNetworkView/CustomNetwork.tsx b/app/components/Views/Settings/NetworksSettings/NetworkSettings/CustomNetworkView/CustomNetwork.tsx index fa297b73a7bc..48d3d5a93e56 100644 --- a/app/components/Views/Settings/NetworksSettings/NetworkSettings/CustomNetworkView/CustomNetwork.tsx +++ b/app/components/Views/Settings/NetworksSettings/NetworkSettings/CustomNetworkView/CustomNetwork.tsx @@ -17,7 +17,6 @@ import { } from '../../../../../../selectors/networkController'; import AvatarNetwork from '../../../../../../component-library/components/Avatars/Avatar/variants/AvatarNetwork'; import { AvatarSize } from '../../../../../../component-library/components/Avatars/Avatar'; -import { isNetworkUiRedesignEnabled } from '../../../../../../util/networks/isNetworkUiRedesignEnabled'; import { useSafeChains } from '../../../../../../components/hooks/useSafeChains'; const CustomNetwork = ({ @@ -103,7 +102,7 @@ const CustomNetwork = ({ } /> - + {networkConfiguration.nickname} diff --git a/app/components/Views/Settings/NetworksSettings/NetworkSettings/__snapshots__/index.test.tsx.snap b/app/components/Views/Settings/NetworksSettings/NetworkSettings/__snapshots__/index.test.tsx.snap index ba068aa9447c..089bd439b1f0 100644 --- a/app/components/Views/Settings/NetworksSettings/NetworkSettings/__snapshots__/index.test.tsx.snap +++ b/app/components/Views/Settings/NetworksSettings/NetworkSettings/__snapshots__/index.test.tsx.snap @@ -30,65 +30,3 @@ exports[`NetworkSettings should render correctly 1`] = ` `; - -exports[`NetworkSettings should render the component correctly when isNetworkUiRedesignEnabled is false 1`] = ` - - - -`; - -exports[`NetworkSettings should render the component correctly when isNetworkUiRedesignEnabled is true 1`] = ` - - - -`; diff --git a/app/components/Views/Settings/NetworksSettings/NetworkSettings/index.js b/app/components/Views/Settings/NetworksSettings/NetworkSettings/index.js index e0c22862ad2a..070c281056d3 100644 --- a/app/components/Views/Settings/NetworksSettings/NetworkSettings/index.js +++ b/app/components/Views/Settings/NetworksSettings/NetworkSettings/index.js @@ -75,7 +75,6 @@ import Icon, { IconName, IconSize, } from '../../../../../component-library/components/Icons/Icon'; -import { isNetworkUiRedesignEnabled } from '../../../../../util/networks/isNetworkUiRedesignEnabled'; import Cell, { CellVariant, } from '../../../../../component-library/components/Cells/Cell'; @@ -85,7 +84,6 @@ import { TextVariant } from '../../../../../component-library/components/Texts/T import ButtonLink from '../../../../../component-library/components/Buttons/Button/variants/ButtonLink'; import ButtonPrimary from '../../../../../component-library/components/Buttons/Button/variants/ButtonPrimary'; import { RpcEndpointType } from '@metamask/network-controller'; -import BottomSheetOverlay from '../../../../../component-library/components/BottomSheets/BottomSheet/foundation/BottomSheetOverlay'; const createStyles = (colors) => StyleSheet.create({ @@ -679,8 +677,7 @@ export class NetworkSettings extends PureComponent { (item) => item.chainId === hexChainId, ); - // Return true if the chainId exists and the UI redesign is enabled, otherwise false - return isNetworkUiRedesignEnabled() && chainIdExists; + return chainIdExists; }; checkIfNetworkExists = async (rpcUrl) => { @@ -689,13 +686,9 @@ export class NetworkSettings extends PureComponent { ).filter((item) => item.rpcUrl === rpcUrl); if (checkCustomNetworks.length > 0) { - if (!isNetworkUiRedesignEnabled()) { - this.setState({ - warningRpcUrl: strings('app_settings.network_exists'), - }); - return checkCustomNetworks; - } - + this.setState({ + warningRpcUrl: strings('app_settings.network_exists'), + }); return checkCustomNetworks; } const defaultNetworks = getAllNetworks().map((item) => Networks[item]); @@ -840,13 +833,9 @@ export class NetworkSettings extends PureComponent { // Conditionally check existence of network (Only check in Add Mode) let isNetworkExists; - if (isNetworkUiRedesignEnabled()) { - isNetworkExists = addMode - ? await this.checkIfNetworkNotExistsByChainId(stateChainId) - : []; - } else { - isNetworkExists = editable ? [] : await this.checkIfNetworkExists(rpcUrl); - } + isNetworkExists = addMode + ? await this.checkIfNetworkNotExistsByChainId(stateChainId) + : []; const isOnboarded = getIsNetworkOnboarded( stateChainId, @@ -912,17 +901,11 @@ export class NetworkSettings extends PureComponent { } if (isNetworkExists.length > 0) { - if (isNetworkUiRedesignEnabled()) { - return this.setState({ - validatedRpcURL: false, - warningRpcUrl: strings( - 'app_settings.url_associated_to_another_chain_id', - ), - }); - } return this.setState({ - validatedRpcURL: true, - warningRpcUrl: strings('app_settings.network_exists'), + validatedRpcURL: false, + warningRpcUrl: strings( + 'app_settings.url_associated_to_another_chain_id', + ), }); } const url = new URL(rpcUrl); @@ -948,12 +931,7 @@ export class NetworkSettings extends PureComponent { const isChainIdExists = await this.checkIfChainIdExists(chainId); const isNetworkExists = await this.checkIfNetworkExists(rpcUrl); - if ( - isChainIdExists && - isNetworkExists.length > 0 && - isNetworkUiRedesignEnabled() && - !editable - ) { + if (isChainIdExists && isNetworkExists.length > 0 && !editable) { return this.setState({ validateChainId: true, warningChainId: strings( @@ -962,12 +940,7 @@ export class NetworkSettings extends PureComponent { }); } - if ( - isChainIdExists && - isNetworkExists.length === 0 && - isNetworkUiRedesignEnabled() && - !editable - ) { + if (isChainIdExists && isNetworkExists.length === 0 && !editable) { return this.setState({ validateChainId: true, warningChainId: strings('app_settings.network_already_exist'), @@ -1025,10 +998,7 @@ export class NetworkSettings extends PureComponent { providerError = err; } - if ( - (providerError || typeof endpointChainId !== 'string') && - isNetworkUiRedesignEnabled() - ) { + if (providerError || typeof endpointChainId !== 'string') { return this.setState({ validatedRpcURL: false, warningRpcUrl: strings('app_settings.unMatched_chain'), @@ -1036,15 +1006,13 @@ export class NetworkSettings extends PureComponent { } if (endpointChainId !== toHex(chainId)) { - if (isNetworkUiRedesignEnabled()) { - return this.setState({ - warningRpcUrl: strings( - 'app_settings.url_associated_to_another_chain_id', - ), - validatedRpcURL: false, - warningChainId: strings('app_settings.unMatched_chain_name'), - }); - } + return this.setState({ + warningRpcUrl: strings( + 'app_settings.url_associated_to_another_chain_id', + ), + validatedRpcURL: false, + warningChainId: strings('app_settings.unMatched_chain_name'), + }); } this.validateRpcAndChainId(); @@ -1148,15 +1116,10 @@ export class NetworkSettings extends PureComponent { */ disabledByChainId = () => { const { chainId, validatedChainId, warningChainId } = this.state; - - if (isNetworkUiRedesignEnabled()) { - return ( - !chainId || - (chainId && (!validatedChainId || warningChainId !== undefined)) - ); - } - if (!chainId) return true; - return validatedChainId && !!warningChainId; + return ( + !chainId || + (chainId && (!validatedChainId || warningChainId !== undefined)) + ); }; /** @@ -1615,9 +1578,7 @@ export class NetworkSettings extends PureComponent { const renderWarningChainId = () => { const CHAIN_LIST_URL = 'https://chainid.network/'; - const containerStyle = isNetworkUiRedesignEnabled() - ? styles.newWarningContainer - : styles.warningContainer; + const containerStyle = styles.newWarningContainer; if (warningChainId) { if (warningChainId === strings('app_settings.unMatched_chain_name')) { @@ -1715,66 +1676,22 @@ export class NetworkSettings extends PureComponent { }; const renderButtons = () => { - if (isNetworkUiRedesignEnabled()) { - return ( - - -