Skip to content

Commit

Permalink
feat: STAKE-914 Remove MM_POOLED_STAKING_UI_ENABLED feature flag (#12852
Browse files Browse the repository at this point in the history
)

<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**
This PR removes the `MM_POOLED_STAKING_UI_ENABLED` feature flag, removed
related usages in the codebase, and updates breaking tests. We no longer
need this feature flag as pooled-staking is live.

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

## **Related issues**

- Jira ticket: [STAKE-914 Remove MM_POOLED_STAKING_UI_ENABLED feature
flag](https://consensyssoftware.atlassian.net/browse/STAKE-914)

## **Manual testing steps**

N/A

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->
N/A 
### **After**

<!-- [screenshots/recordings] -->
N/A
## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
  • Loading branch information
Matt561 authored Jan 14, 2025
1 parent 482f35c commit 261975f
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 52 deletions.
5 changes: 1 addition & 4 deletions app/components/UI/AssetOverview/Balance/Balance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import Text, {
} from '../../../../component-library/components/Texts/Text';
import { TokenI } from '../../Tokens/types';
import { useNavigation } from '@react-navigation/native';
import { isPooledStakingFeatureEnabled } from '../../Stake/constants';
import StakingBalance from '../../Stake/components/StakingBalance/StakingBalance';
import {
PopularList,
Expand Down Expand Up @@ -167,9 +166,7 @@ const Balance = ({ asset, mainBalance, secondaryBalance }: BalanceProps) => {
{asset.name || asset.symbol}
</Text>
</AssetElement>
{isPooledStakingFeatureEnabled() && asset?.isETH && (
<StakingBalance asset={asset} />
)}
{asset?.isETH && <StakingBalance asset={asset} />}
</View>
);
};
Expand Down
74 changes: 66 additions & 8 deletions app/components/UI/AssetOverview/Balance/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,21 @@ const mockETH = {
isNative: true,
};

const mockInitialState = {
engine: {
backgroundState,
jest.mock('../../../../core/Engine', () => ({
context: {
NetworkController: {
getNetworkClientById: () => ({
configuration: {
chainId: '0x1',
rpcUrl: 'https://mainnet.infura.io/v3',
ticker: 'ETH',
type: 'custom',
},
}),
findNetworkClientIdByChainId: () => 'mainnet',
},
},
};
}));

jest.mock('../../../../util/networks', () => ({
...jest.requireActual('../../../../util/networks'),
Expand All @@ -74,6 +84,48 @@ jest.mock('../../../../util/networks', () => ({
isPortfolioViewEnabled: jest.fn(),
}));

jest.mock('../../Stake/hooks/usePooledStakes', () => ({
__esModule: true,
default: () => ({
pooledStakesData: {
account: '0xabc',
assets: '10000000000000000',
exitRequests: [],
lifetimeRewards: '100000000000000',
},
exchangeRate: 1.018,
hasStakedPositions: true,
hasEthToUnstake: true,
isLoadingPooledStakesData: false,
}),
}));

jest.mock('../../Stake/hooks/useVaultData', () => ({
__esModule: true,
default: () => ({
vaultData: {
apy: '2.437033146840025387168141592920355',
capacity: '1000000000000000000000000000000000000000000000000000000000000',
feePercent: 1500,
totalAssets: '10000000000000000000000',
vaultAddress: '0xdef',
},
}),
}));

jest.mock('../../Stake/hooks/useStakingEligibility', () => ({
__esModule: true,
default: () => ({
isEligible: true,
}),
}));

const mockInitialState = {
engine: {
backgroundState,
},
};

describe('Balance', () => {
const mockStore = configureMockStore();
const store = mockStore(mockInitialState);
Expand Down Expand Up @@ -131,13 +183,19 @@ describe('Balance', () => {
});

it('should not fire navigation event for native tokens', () => {
const { queryByTestId } = render(
const { queryAllByTestId } = render(
<Provider store={store}>
<Balance asset={mockETH} mainBalance="100" secondaryBalance="200" />
<Balance asset={mockETH} mainBalance="100" secondaryBalance="200" />,
</Provider>,
);
const assetElement = queryByTestId('asset-ETH');
fireEvent.press(assetElement);

// Includes native ETH and staked ETH
const ethElements = queryAllByTestId('asset-ETH');

ethElements.forEach((ethElement) => {
fireEvent.press(ethElement);
});

expect(mockNavigate).toHaveBeenCalledTimes(0);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import Logger from '../../../../util/Logger';
import TokenDetailsList from './TokenDetailsList';
import MarketDetailsList from './MarketDetailsList';
import { TokenI } from '../../Tokens/types';
import { isPooledStakingFeatureEnabled } from '../../Stake/constants';
import StakingEarnings from '../../Stake/components/StakingEarnings';
import { isPortfolioViewEnabled } from '../../../../util/networks';

Expand Down Expand Up @@ -147,7 +146,7 @@ const TokenDetails: React.FC<TokenDetailsProps> = ({ asset }) => {

return (
<View style={styles.tokenDetailsContainer}>
{asset.isETH && isPooledStakingFeatureEnabled() && <StakingEarnings />}
{asset.isETH && <StakingEarnings />}
{(asset.isETH || tokenMetadata) && (
<TokenDetailsList tokenDetails={tokenDetails} />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ jest.mock('@react-navigation/native', () => {
};
});

jest.mock('../../constants', () => ({
isPooledStakingFeatureEnabled: jest.fn().mockReturnValue(true),
}));

jest.mock('../../../../hooks/useMetrics');

(useMetrics as jest.MockedFn<typeof useMetrics>).mockReturnValue({
Expand Down
7 changes: 2 additions & 5 deletions app/components/UI/Stake/components/StakeButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import { TokenI, BrowserTab } from '../../../Tokens/types';
import { useNavigation } from '@react-navigation/native';
import { isPooledStakingFeatureEnabled } from '../../constants';
import Routes from '../../../../../constants/navigation/Routes';
import { useSelector } from 'react-redux';
import AppConstants from '../../../../../core/AppConstants';
Expand Down Expand Up @@ -43,7 +42,7 @@ const StakeButtonContent = ({ asset }: StakeButtonProps) => {

const onStakeButtonPress = async () => {
const { isEligible } = await refreshPooledStakingEligibility();
if (isPooledStakingFeatureEnabled() && isEligible) {
if (isEligible) {
navigation.navigate('StakeScreens', { screen: Routes.STAKING.STAKE });
} else {
const existingStakeTab = browserTabs.find((tab: BrowserTab) =>
Expand Down Expand Up @@ -88,9 +87,7 @@ const StakeButtonContent = ({ asset }: StakeButtonProps) => {
<Text variant={TextVariant.BodyLGMedium}>
{' • '}
<Text color={TextColor.Primary} variant={TextVariant.BodyLGMedium}>
{isPooledStakingFeatureEnabled()
? `${strings('stake.earn')} `
: `${strings('stake.stake')} `}
{`${strings('stake.earn')} `}
</Text>
</Text>
<Icon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ const StakingBalanceContent = ({ asset }: StakingBalanceProps) => {

return (
<View>
{hasEthToUnstake && (
{hasEthToUnstake && !isLoadingPooledStakesData && (
<AssetElement
asset={asset}
mainBalance={stakedBalanceETH}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import renderWithProvider from '../../../../../util/test/renderWithProvider';
import { strings } from '../../../../../../locales/i18n';
import { mockNetworkState } from '../../../../../util/test/network';

jest.mock('../../constants', () => ({
isPooledStakingFeatureEnabled: jest.fn().mockReturnValue(true),
}));

const mockNavigate = jest.fn();

const STATE_MOCK = {
Expand Down
8 changes: 1 addition & 7 deletions app/components/UI/Stake/components/StakingEarnings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import ButtonIcon, {
} from '../../../../../component-library/components/Buttons/ButtonIcon';
import useTooltipModal from '../../../../../components/hooks/useTooltipModal';
import { strings } from '../../../../../../locales/i18n';
import { isPooledStakingFeatureEnabled } from '../../../Stake/constants';
import useStakingChain from '../../hooks/useStakingChain';
import { StakeSDKProvider } from '../../sdk/stakeSdkProvider';
import useStakingEarnings from '../../hooks/useStakingEarnings';
Expand Down Expand Up @@ -47,12 +46,7 @@ const StakingEarningsContent = () => {

const { isStakingSupportedChain } = useStakingChain();

if (
!isPooledStakingFeatureEnabled() ||
!isStakingSupportedChain ||
!hasStakedPositions
)
return <></>;
if (!isStakingSupportedChain || !hasStakedPositions) return <></>;

return (
<View style={styles.stakingEarningsContainer}>
Expand Down
4 changes: 0 additions & 4 deletions app/components/UI/Stake/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/* eslint-disable import/prefer-default-export */
export const isPooledStakingFeatureEnabled = () =>
process.env.MM_POOLED_STAKING_UI_ENABLED === 'true';

export const isStablecoinLendingFeatureEnabled = () =>
process.env.MM_STABLECOIN_LENDING_UI_ENABLED === 'true';

Expand Down
4 changes: 0 additions & 4 deletions app/components/UI/Stake/sdk/stakeSdkProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ import { View } from 'react-native';
import Text from '../../../../component-library/components/Texts/Text';
import { MOCK_POOL_STAKING_SDK } from '../__mocks__/mockData';

jest.mock('../../Stake/constants', () => ({
isPooledStakingFeatureEnabled: jest.fn().mockReturnValue(true),
}));

jest.mock('../../../../core/Engine', () => ({
context: {
NetworkController: {
Expand Down
4 changes: 0 additions & 4 deletions app/components/UI/Tokens/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,6 @@ jest.mock('@react-navigation/native', () => {
};
});

jest.mock('../../UI/Stake/constants', () => ({
isPooledStakingFeatureEnabled: jest.fn().mockReturnValue(true),
}));

jest.mock('../../UI/Stake/hooks/useStakingEligibility', () => ({
__esModule: true,
default: jest.fn(() => ({
Expand Down
3 changes: 1 addition & 2 deletions app/core/Engine/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ import { getSmartTransactionMetricsProperties } from '../../util/smart-transacti
import { trace } from '../../util/trace';
import { MetricsEventBuilder } from '../Analytics/MetricsEventBuilder';
import { JsonMap } from '../Analytics/MetaMetrics.types';
import { isPooledStakingFeatureEnabled } from '../../components/UI/Stake/constants';
import {
ControllerMessenger,
EngineState,
Expand Down Expand Up @@ -740,7 +739,7 @@ export class Engine {
assetsContractController.getStakedBalanceForChain.bind(
assetsContractController,
),
includeStakedAssets: isPooledStakingFeatureEnabled(),
includeStakedAssets: true,
});
const permissionController = new PermissionController({
messenger: this.controllerMessenger.getRestricted({
Expand Down
3 changes: 0 additions & 3 deletions bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1755,9 +1755,6 @@ app:
- opts:
is_expand: false
MM_PERMISSIONS_SETTINGS_V1_ENABLED: false
- opts:
is_expand: false
MM_POOLED_STAKING_UI_ENABLED: true
- opts:
is_expand: false
MM_SECURITY_ALERTS_API_ENABLED: true
Expand Down

0 comments on commit 261975f

Please sign in to comment.