From 6428f658e0cc0b18297b95531d812c76c03a6015 Mon Sep 17 00:00:00 2001 From: Alexandr Kazachenko Date: Mon, 8 Jan 2024 19:43:42 +0600 Subject: [PATCH] chore: fix supported network check for Sepolia (#3581) --- .../hooks/useIsProviderNetworkUnsupported.ts | 14 ++++++++++---- apps/cowswap-frontend/src/cow-react/index.tsx | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/cowswap-frontend/src/common/hooks/useIsProviderNetworkUnsupported.ts b/apps/cowswap-frontend/src/common/hooks/useIsProviderNetworkUnsupported.ts index 0fe73bbf8b..e25ff95e90 100644 --- a/apps/cowswap-frontend/src/common/hooks/useIsProviderNetworkUnsupported.ts +++ b/apps/cowswap-frontend/src/common/hooks/useIsProviderNetworkUnsupported.ts @@ -1,3 +1,5 @@ +import { useMemo } from 'react' + import { SupportedChainId } from '@cowprotocol/cow-sdk' import { useWeb3React } from '@web3-react/core' @@ -7,9 +9,13 @@ export function useIsProviderNetworkUnsupported(): boolean { const { chainId } = useWeb3React() const { isSepoliaEnabled } = useFeatureFlags() - if (chainId === SupportedChainId.SEPOLIA && !isSepoliaEnabled) { - return true - } + return useMemo(() => { + if (!chainId) return false + + if (chainId === SupportedChainId.SEPOLIA) { + return !isSepoliaEnabled + } - return !!chainId && !(chainId in SupportedChainId) + return !(chainId in SupportedChainId) + }, [chainId, isSepoliaEnabled]) } diff --git a/apps/cowswap-frontend/src/cow-react/index.tsx b/apps/cowswap-frontend/src/cow-react/index.tsx index 542973e525..14289ed526 100644 --- a/apps/cowswap-frontend/src/cow-react/index.tsx +++ b/apps/cowswap-frontend/src/cow-react/index.tsx @@ -61,9 +61,9 @@ function Main() { - + {!isInjectedWidgetMode && (