Skip to content

Commit

Permalink
chore: feature-flag for geo-block feature (cowprotocol#3940)
Browse files Browse the repository at this point in the history
  • Loading branch information
shoom3301 authored Feb 28, 2024
1 parent bce2f42 commit fe9501e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { EthFlowDeadlineUpdater, EthFlowSlippageUpdater } from 'modules/swap/sta
import { useOnTokenListAddingError } from 'modules/tokensList'
import { UsdPricesUpdater } from 'modules/usdAmount'

import { useFeatureFlags } from 'common/hooks/featureFlags/useFeatureFlags'
import { TotalSurplusUpdater } from 'common/state/totalSurplusState'
import { ApplicationUpdater } from 'common/updaters/ApplicationUpdater'
import { CancelReplaceTxUpdater } from 'common/updaters/CancelReplaceTxUpdater'
Expand All @@ -34,6 +35,7 @@ export function Updaters() {
const { chainId, account } = useWalletInfo()
const { tokenLists, appCode } = useInjectedWidgetParams()
const onTokenListAddingError = useOnTokenListAddingError()
const { isGeoBlockEnabled } = useFeatureFlags()

return (
<>
Expand Down Expand Up @@ -62,7 +64,7 @@ export function Updaters() {
<CowEventsUpdater />
<TotalSurplusUpdater />
<UsdPricesUpdater />
<TokensListsUpdater chainId={chainId} />
<TokensListsUpdater chainId={chainId} isGeoBlockEnabled={isGeoBlockEnabled} />
<WidgetTokensListsUpdater
tokenLists={tokenLists}
appCode={appCode}
Expand Down
7 changes: 4 additions & 3 deletions libs/tokens/src/updaters/TokensListsUpdater/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ const NETWORKS_WITHOUT_RESTRICTIONS = [SupportedChainId.SEPOLIA, SupportedChainI

interface TokensListsUpdaterProps {
chainId: SupportedChainId
isGeoBlockEnabled: boolean
}

export function TokensListsUpdater({ chainId: currentChainId }: TokensListsUpdaterProps) {
export function TokensListsUpdater({ chainId: currentChainId, isGeoBlockEnabled }: TokensListsUpdaterProps) {
const { chainId } = useAtomValue(environmentAtom)
const setEnvironment = useSetAtom(updateEnvironmentAtom)
const allTokensLists = useAtomValue(allListsSourcesAtom)
Expand Down Expand Up @@ -72,7 +73,7 @@ export function TokensListsUpdater({ chainId: currentChainId }: TokensListsUpdat

// Check if a user is from US and use Uniswap list, because of the SEC regulations
useEffect(() => {
if (isInjectedWidget()) return
if (!isGeoBlockEnabled || isInjectedWidget()) return

if (NETWORKS_WITHOUT_RESTRICTIONS.includes(chainId)) {
setEnvironment({ useCuratedListOnly: false })
Expand Down Expand Up @@ -101,7 +102,7 @@ export function TokensListsUpdater({ chainId: currentChainId }: TokensListsUpdat
})
})
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [chainId])
}, [chainId, isGeoBlockEnabled])

return null
}

0 comments on commit fe9501e

Please sign in to comment.