diff --git a/app/components/UI/Stake/components/StakeButton/index.tsx b/app/components/UI/Stake/components/StakeButton/index.tsx index 9b13d2fe4bf..dda6b83917b 100644 --- a/app/components/UI/Stake/components/StakeButton/index.tsx +++ b/app/components/UI/Stake/components/StakeButton/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useCallback } from 'react'; import { TokenI, BrowserTab } from '../../../Tokens/types'; import { useNavigation } from '@react-navigation/native'; import Routes from '../../../../../constants/navigation/Routes'; @@ -25,6 +25,8 @@ import { RootState } from '../../../../../reducers'; import useStakingEligibility from '../../hooks/useStakingEligibility'; import { StakeSDKProvider } from '../../sdk/stakeSdkProvider'; import { EVENT_LOCATIONS } from '../../constants/events'; +import useStakingChain from '../../hooks/useStakingChain'; +import Engine from '../../../../../core/Engine'; interface StakeButtonProps { asset: TokenI; @@ -37,10 +39,22 @@ const StakeButtonContent = ({ asset }: StakeButtonProps) => { const browserTabs = useSelector((state: RootState) => state.browser.tabs); const chainId = useSelector(selectChainId); + const { isStakingSupportedChain } = useStakingChain(); const { refreshPooledStakingEligibility } = useStakingEligibility(); + const switchToMainnet = useCallback(() => { + const { NetworkController } = Engine.context; + NetworkController.setActiveNetwork('mainnet'); + }, []); + const onStakeButtonPress = async () => { + // Check if current chain is supported for stakings + + if (!isStakingSupportedChain) { + switchToMainnet(); + } + const { isEligible } = await refreshPooledStakingEligibility(); if (isEligible) { navigation.navigate('StakeScreens', { screen: Routes.STAKING.STAKE });