Skip to content

Commit

Permalink
feat: enhance staking button functionality with chain support check
Browse files Browse the repository at this point in the history
This update introduces a check for staking support based on the current chain before proceeding with staking actions. It integrates the `useStakingChain` hook to determine if the active chain supports staking, and sets the active network to 'mainnet' if it does not.
  • Loading branch information
amitabh94 committed Jan 15, 2025
1 parent 261975f commit 34d989a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/components/UI/Stake/components/StakeButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -37,11 +39,14 @@ const StakeButtonContent = ({ asset }: StakeButtonProps) => {

const browserTabs = useSelector((state: RootState) => state.browser.tabs);
const chainId = useSelector(selectChainId);

const { refreshPooledStakingEligibility } = useStakingEligibility();
const { isEligible } = useStakingEligibility();
const { isStakingSupportedChain } = useStakingChain();

const onStakeButtonPress = async () => {
const { isEligible } = await refreshPooledStakingEligibility();
if (!isStakingSupportedChain) {
const { NetworkController } = Engine.context;
await NetworkController.setActiveNetwork('mainnet');
}
if (isEligible) {
navigation.navigate('StakeScreens', { screen: Routes.STAKING.STAKE });
} else {
Expand Down

0 comments on commit 34d989a

Please sign in to comment.