From 9fbdc3cab1021ce362c863995191894621cd9a96 Mon Sep 17 00:00:00 2001 From: eddie <66155195+just-toby@users.noreply.github.com> Date: Thu, 10 Aug 2023 11:05:48 -0700 Subject: [PATCH] feat: base flag cleanup (#7134) feat: remove base feature flag --- .../MiniPortfolio/Pools/hooks.ts | 6 ++---- .../MiniPortfolio/PortfolioLogo.tsx | 4 +--- .../FeatureFlagModal/FeatureFlagModal.tsx | 7 ------- src/components/NavBar/ChainSelector.tsx | 13 ++----------- src/components/NavBar/ChainSelectorRow.tsx | 4 +--- src/components/NetworkAlert/NetworkAlert.tsx | 4 +--- src/featureFlags/flags/baseEnabled.ts | 19 ------------------- src/featureFlags/index.tsx | 1 - src/pages/Pool/index.tsx | 4 +--- src/pages/Swap/index.tsx | 4 +--- .../RadialGradientByChainUpdater.ts | 8 +------- 11 files changed, 10 insertions(+), 64 deletions(-) delete mode 100644 src/featureFlags/flags/baseEnabled.ts diff --git a/src/components/AccountDrawer/MiniPortfolio/Pools/hooks.ts b/src/components/AccountDrawer/MiniPortfolio/Pools/hooks.ts index 2a42682b07..956a201f59 100644 --- a/src/components/AccountDrawer/MiniPortfolio/Pools/hooks.ts +++ b/src/components/AccountDrawer/MiniPortfolio/Pools/hooks.ts @@ -11,7 +11,6 @@ import { useWeb3React } from '@web3-react/core' import { isSupportedChain } from 'constants/chains' import { RPC_PROVIDERS } from 'constants/providers' import { BaseContract } from 'ethers/lib/ethers' -import { useBaseEnabledChains } from 'featureFlags/flags/baseEnabled' import { ContractInput, useUniswapPricesQuery } from 'graphql/data/__generated__/types-and-hooks' import { toContractInput } from 'graphql/data/util' import useStablecoinPrice from 'hooks/useStablecoinPrice' @@ -31,14 +30,13 @@ function useContractMultichain( chainIds?: ChainId[] ): ContractMap { const { chainId: walletChainId, provider: walletProvider } = useWeb3React() - const baseEnabledChains = useBaseEnabledChains() return useMemo(() => { const relevantChains = chainIds ?? Object.keys(addressMap) .map((chainId) => parseInt(chainId)) - .filter((chainId) => isSupportedChain(chainId, baseEnabledChains)) + .filter((chainId) => isSupportedChain(chainId)) return relevantChains.reduce((acc: ContractMap, chainId) => { const provider = @@ -52,7 +50,7 @@ function useContractMultichain( } return acc }, {}) - }, [ABI, addressMap, baseEnabledChains, chainIds, walletChainId, walletProvider]) + }, [ABI, addressMap, chainIds, walletChainId, walletProvider]) } export function useV3ManagerContracts(chainIds: ChainId[]): ContractMap { diff --git a/src/components/AccountDrawer/MiniPortfolio/PortfolioLogo.tsx b/src/components/AccountDrawer/MiniPortfolio/PortfolioLogo.tsx index b2289a5024..404fe16159 100644 --- a/src/components/AccountDrawer/MiniPortfolio/PortfolioLogo.tsx +++ b/src/components/AccountDrawer/MiniPortfolio/PortfolioLogo.tsx @@ -5,7 +5,6 @@ import { MissingImageLogo } from 'components/Logo/AssetLogo' import CurrencyLogo from 'components/Logo/CurrencyLogo' import { Unicon } from 'components/Unicon' import { getChainInfo } from 'constants/chainInfo' -import { useBaseEnabledChains } from 'featureFlags/flags/baseEnabled' import useTokenLogoSource from 'hooks/useAssetLogoSource' import useENSAvatar from 'hooks/useENSAvatar' import React from 'react' @@ -99,8 +98,7 @@ export function PortfolioLogo({ size = '40px', style, }: MultiLogoProps) { - const baseEnabledChains = useBaseEnabledChains() - const chainInfo = getChainInfo(chainId, baseEnabledChains) + const chainInfo = getChainInfo(chainId) const squareLogoUrl = chainInfo?.squareLogoUrl const logoUrl = chainInfo?.logoUrl const chainLogo = squareLogoUrl ?? logoUrl diff --git a/src/components/FeatureFlagModal/FeatureFlagModal.tsx b/src/components/FeatureFlagModal/FeatureFlagModal.tsx index 5d9bc9f0df..88fbc0d1e0 100644 --- a/src/components/FeatureFlagModal/FeatureFlagModal.tsx +++ b/src/components/FeatureFlagModal/FeatureFlagModal.tsx @@ -1,5 +1,4 @@ import { BaseVariant, FeatureFlag, featureFlagSettings, useUpdateFlag } from 'featureFlags' -import { useBaseEnabledFlag } from 'featureFlags/flags/baseEnabled' import { useForceUniswapXOnFlag } from 'featureFlags/flags/forceUniswapXOn' import { useMultichainUXFlag } from 'featureFlags/flags/multichainUx' import { useRoutingAPIForPriceFlag } from 'featureFlags/flags/priceRoutingApi' @@ -237,12 +236,6 @@ export default function FeatureFlagModal() { featureFlag={FeatureFlag.routingAPIPrice} label="Use the routing-api v2 for price fetches" /> - { const theme = useTheme() - const baseEnabled = useBaseEnabled() const showTestnets = useAtomValue(showTestnetsAtom) const walletSupportsChain = useWalletSupportedChains() const [supportedChains, unsupportedChains] = useMemo(() => { const { supported, unsupported } = NETWORK_SELECTOR_CHAINS.filter((chain: number) => { - if (chain === ChainId.BASE) { - return baseEnabled - } - if (chain === ChainId.BASE_GOERLI) { - return showTestnets && baseEnabled - } return showTestnets || !TESTNET_CHAIN_IDS.includes(chain) }) .sort((a, b) => getChainPriority(a) - getChainPriority(b)) @@ -87,14 +79,13 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => { { supported: [], unsupported: [] } as Record ) return [supported, unsupported] - }, [baseEnabled, showTestnets, walletSupportsChain]) + }, [showTestnets, walletSupportsChain]) const ref = useRef(null) const modalRef = useRef(null) useOnClickOutside(ref, () => setIsOpen(false), [modalRef]) - const baseEnabledChains = useBaseEnabledChains() - const info = getChainInfo(chainId, baseEnabledChains) + const info = getChainInfo(chainId) const selectChain = useSelectChain() useSyncChainQuery() diff --git a/src/components/NavBar/ChainSelectorRow.tsx b/src/components/NavBar/ChainSelectorRow.tsx index c3ab2d9e3f..0762f8e1c4 100644 --- a/src/components/NavBar/ChainSelectorRow.tsx +++ b/src/components/NavBar/ChainSelectorRow.tsx @@ -3,7 +3,6 @@ import { ChainId } from '@uniswap/sdk-core' import { useWeb3React } from '@web3-react/core' import Loader from 'components/Icons/LoadingSpinner' import { getChainInfo } from 'constants/chainInfo' -import { useBaseEnabledChains } from 'featureFlags/flags/baseEnabled' import { CheckMarkIcon } from 'nft/components/icons' import styled, { useTheme } from 'styled-components' @@ -71,8 +70,7 @@ interface ChainSelectorRowProps { export default function ChainSelectorRow({ disabled, targetChain, onSelectChain, isPending }: ChainSelectorRowProps) { const { chainId } = useWeb3React() const active = chainId === targetChain - const baseEnabledChains = useBaseEnabledChains() - const chainInfo = getChainInfo(targetChain, baseEnabledChains) + const chainInfo = getChainInfo(targetChain) const label = chainInfo?.label const logoUrl = chainInfo?.logoUrl diff --git a/src/components/NetworkAlert/NetworkAlert.tsx b/src/components/NetworkAlert/NetworkAlert.tsx index e84c3a37d8..8eeb7305be 100644 --- a/src/components/NetworkAlert/NetworkAlert.tsx +++ b/src/components/NetworkAlert/NetworkAlert.tsx @@ -2,7 +2,6 @@ import { Trans } from '@lingui/macro' import { ChainId } from '@uniswap/sdk-core' import { useWeb3React } from '@web3-react/core' import { getChainInfo } from 'constants/chainInfo' -import { useBaseEnabledChains } from 'featureFlags/flags/baseEnabled' import { ArrowUpRight } from 'react-feather' import styled from 'styled-components' import { ExternalLink, HideSmall } from 'theme' @@ -171,13 +170,12 @@ function shouldShowAlert(chainId: number | undefined): chainId is NetworkAlertCh export function NetworkAlert() { const { chainId } = useWeb3React() const [darkMode] = useDarkModeManager() - const baseEnabledChains = useBaseEnabledChains() if (!shouldShowAlert(chainId)) { return null } - const chainInfo = getChainInfo(chainId, baseEnabledChains) + const chainInfo = getChainInfo(chainId) if (!chainInfo) return null diff --git a/src/featureFlags/flags/baseEnabled.ts b/src/featureFlags/flags/baseEnabled.ts deleted file mode 100644 index 77a663ea48..0000000000 --- a/src/featureFlags/flags/baseEnabled.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { ChainId } from '@uniswap/sdk-core' - -import { BaseVariant, FeatureFlag, useBaseFlag } from '../index' - -export function useBaseEnabledFlag(): BaseVariant { - return useBaseFlag(FeatureFlag.baseEnabled) -} - -export function useBaseEnabled(): boolean { - return useBaseEnabledFlag() === BaseVariant.Enabled -} - -export function useBaseEnabledChains(): Record { - const baseEnabled = useBaseEnabled() - return { - [ChainId.BASE]: baseEnabled, - [ChainId.BASE_GOERLI]: baseEnabled, - } -} diff --git a/src/featureFlags/index.tsx b/src/featureFlags/index.tsx index 5ad7f609d4..5062eb9f3c 100644 --- a/src/featureFlags/index.tsx +++ b/src/featureFlags/index.tsx @@ -15,7 +15,6 @@ export enum FeatureFlag { routingAPIPrice = 'routing_api_price', forceUniswapXOn = 'uniswapx_force_on', // forces routing-api's feature flag for uniswapx to turn on as well uniswapXEthOutputEnabled = 'uniswapx_eth_output_enabled', - baseEnabled = 'base_enabled', multichainUX = 'multichain_ux', } diff --git a/src/pages/Pool/index.tsx b/src/pages/Pool/index.tsx index 1c7b232cf9..67930a196e 100644 --- a/src/pages/Pool/index.tsx +++ b/src/pages/Pool/index.tsx @@ -10,7 +10,6 @@ import PositionList from 'components/PositionList' import { RowBetween, RowFixed } from 'components/Row' import { SwitchLocaleLink } from 'components/SwitchLocaleLink' import { isSupportedChain } from 'constants/chains' -import { useBaseEnabledChains } from 'featureFlags/flags/baseEnabled' import { useFilterPossiblyMaliciousPositions } from 'hooks/useFilterPossiblyMaliciousPositions' import { useNetworkSupportsV2 } from 'hooks/useNetworkSupportsV2' import { useV3Positions } from 'hooks/useV3Positions' @@ -213,9 +212,8 @@ export default function Pool() { ) const filteredPositions = useFilterPossiblyMaliciousPositions(userSelectedPositionSet) - const baseEnabledChains = useBaseEnabledChains() - if (!isSupportedChain(chainId, baseEnabledChains)) { + if (!isSupportedChain(chainId)) { return } diff --git a/src/pages/Swap/index.tsx b/src/pages/Swap/index.tsx index a9789aac3d..237a41fcdb 100644 --- a/src/pages/Swap/index.tsx +++ b/src/pages/Swap/index.tsx @@ -32,7 +32,6 @@ import TokenSafetyModal from 'components/TokenSafety/TokenSafetyModal' import { getChainInfo } from 'constants/chainInfo' import { asSupportedChain, isSupportedChain } from 'constants/chains' import { getSwapCurrencyId, TOKEN_SHORTHANDS } from 'constants/tokens' -import { useBaseEnabledChains } from 'featureFlags/flags/baseEnabled' import { useCurrency, useDefaultActiveTokens } from 'hooks/Tokens' import { useIsSwapUnsupported } from 'hooks/useIsSwapUnsupported' import { useMaxAmountIn } from 'hooks/useMaxAmountIn' @@ -136,11 +135,10 @@ function largerPercentValue(a?: Percent, b?: Percent) { export default function SwapPage({ className }: { className?: string }) { const { chainId: connectedChainId } = useWeb3React() const loadedUrlParams = useDefaultsFromURLSearch() - const baseEnabledChains = useBaseEnabledChains() const location = useLocation() - const supportedChainId = asSupportedChain(connectedChainId, baseEnabledChains) + const supportedChainId = asSupportedChain(connectedChainId) return ( diff --git a/src/theme/components/RadialGradientByChainUpdater.ts b/src/theme/components/RadialGradientByChainUpdater.ts index ee54b6fe3b..d408e4bb6c 100644 --- a/src/theme/components/RadialGradientByChainUpdater.ts +++ b/src/theme/components/RadialGradientByChainUpdater.ts @@ -1,6 +1,5 @@ import { ChainId } from '@uniswap/sdk-core' import { useWeb3React } from '@web3-react/core' -import { useBaseEnabled } from 'featureFlags/flags/baseEnabled' import { useIsNftPage } from 'hooks/useIsNftPage' import { useEffect } from 'react' import { useDarkModeManager } from 'theme/components/ThemeToggle' @@ -40,7 +39,6 @@ export default function RadialGradientByChainUpdater(): null { const { chainId } = useWeb3React() const [darkMode] = useDarkModeManager() const isNftPage = useIsNftPage() - const baseEnabled = useBaseEnabled() // manage background color useEffect(() => { @@ -117,10 +115,6 @@ export default function RadialGradientByChainUpdater(): null { } case ChainId.BASE: case ChainId.BASE_GOERLI: { - if (!baseEnabled) { - setDefaultBackground(backgroundRadialGradientElement, darkMode) - return - } setBackground(backgroundResetStyles) const baseLightGradient = 'radial-gradient(100% 100% at 50% 0%, rgba(0, 82, 255, 0.20) 0%, rgba(0, 82, 255, 0.08) 40.0%, rgba(252, 255, 82, 0.00) 100%), rgb(255, 255, 255)' @@ -133,6 +127,6 @@ export default function RadialGradientByChainUpdater(): null { setDefaultBackground(backgroundRadialGradientElement, darkMode) } } - }, [darkMode, chainId, isNftPage, baseEnabled]) + }, [darkMode, chainId, isNftPage]) return null }