Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(cherry-pick) fix: enable earn button navigation on unsupported networks (#12988) #13012

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 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 { strings } from '../../../../../../locales/i18n';
import { RootState } from '../../../../../reducers';
import useStakingEligibility from '../../hooks/useStakingEligibility';
import { StakeSDKProvider } from '../../sdk/stakeSdkProvider';
import useStakingChain from '../../hooks/useStakingChain';
import Engine from '../../../../../core/Engine';

interface StakeButtonProps {
asset: TokenI;
Expand All @@ -37,12 +39,15 @@ 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 (isPooledStakingFeatureEnabled() && isEligible) {
amitabh94 marked this conversation as resolved.
Show resolved Hide resolved
if (!isStakingSupportedChain) {
const { NetworkController } = Engine.context;
await NetworkController.setActiveNetwork('mainnet');
}
if (isEligible) {
navigation.navigate('StakeScreens', { screen: Routes.STAKING.STAKE });
} else {
const existingStakeTab = browserTabs.find((tab: BrowserTab) =>
Expand Down
10 changes: 7 additions & 3 deletions app/components/UI/Tokens/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,14 @@ jest.mock('../../UI/Stake/hooks/useStakingEligibility', () => ({
})),
}));

jest.mock('../Stake/hooks/useStakingChain', () => ({
useStakingChainByChainId: () => ({
jest.mock('../../UI/Stake/hooks/useStakingChain', () => ({
__esModule: true,
default: jest.fn(() => ({
isStakingSupportedChain: true,
}),
})),
useStakingChainByChainId: jest.fn(() => ({
isStakingSupportedChain: true,
})),
}));

const Stack = createStackNavigator();
Expand Down
Loading