Skip to content

Commit

Permalink
Merge branch 'NOTIFY-1236/add-GoogleService.plist-build-process' of g…
Browse files Browse the repository at this point in the history
…ithub.com:MetaMask/metamask-mobile into NOTIFY-1236/add-GoogleService.plist-build-process
  • Loading branch information
Jonathansoufer committed Oct 23, 2024
2 parents 56dc31e + 6d03751 commit 2e9b675
Show file tree
Hide file tree
Showing 47 changed files with 2,278 additions and 864 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback, useEffect, useRef } from 'react';
import { View, Image, Platform } from 'react-native';
import { View, Image } from 'react-native';
import { createStyles } from './styles';
import { strings } from '../../../../locales/i18n';
import Text, {
Expand All @@ -23,12 +23,7 @@ import {
import { MetaMetricsEvents } from '../../../core/Analytics';

import { ScrollView } from 'react-native-gesture-handler';
import {
ENABLE_AUTOMATIC_SECURITY_CHECK_CONTAINER_ID,
ENABLE_AUTOMATIC_SECURITY_CHECK_NO_THANKS_BUTTON_ID,
} from '../../../../wdio/screen-objects/testIDs/Screens/EnableAutomaticSecurityChecksScreen.testIds';

import generateTestId from '../../../../wdio/utils/generateTestId';
import { EnableAutomaticSecurityChecksIDs } from '../../../../e2e/selectors/Modals/EnableAutomaticSecurityChecks.selectors';
import generateDeviceAnalyticsMetaData from '../../../util/metrics';
import { useMetrics } from '../../../components/hooks/useMetrics';

Expand Down Expand Up @@ -92,10 +87,7 @@ const EnableAutomaticSecurityChecksModal = () => {
<ScrollView contentContainerStyle={styles.content}>
<View
style={styles.images}
{...generateTestId(
Platform,
ENABLE_AUTOMATIC_SECURITY_CHECK_CONTAINER_ID,
)}
testID={EnableAutomaticSecurityChecksIDs.CONTAINER}
>
<Image source={onboardingDeviceImage} />
</View>
Expand All @@ -122,10 +114,7 @@ const EnableAutomaticSecurityChecksModal = () => {
label={strings(
'enable_automatic_security_check_modal.secondary_action',
)}
{...generateTestId(
Platform,
ENABLE_AUTOMATIC_SECURITY_CHECK_NO_THANKS_BUTTON_ID,
)}
testID={EnableAutomaticSecurityChecksIDs.NO_THANKS_BUTTON}
size={ButtonSize.Md}
onPress={triggerCloseAndDisableAutomaticSecurityChecks}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ jest.mock('@react-navigation/native', () => {
jest.mock('../../hooks/usePoolStakedDeposit', () => ({
__esModule: true,
default: () => ({
poolStakingContract: {},
estimateDepositGas: jest.fn(),
attemptDepositTransaction: jest.fn(),
}),
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useStyles } from '../../../../hooks/useStyles';
import { getStakingNavbar } from '../../../Navbar';
import styleSheet from './StakeConfirmationView.styles';
import TokenValueStack from '../../components/StakingConfirmation/TokenValueStack/TokenValueStack';
import AccountHeaderCard from '../../components/StakingConfirmation/AccountHeaderCard/AccountHeaderCard';
import AccountCard from '../../components/StakingConfirmation/AccountCard/AccountCard';
import RewardsCard from '../../components/StakingConfirmation/RewardsCard/RewardsCard';
import ConfirmationFooter from '../../components/StakingConfirmation/ConfirmationFooter/ConfirmationFooter';
import { StakeConfirmationViewProps } from './StakeConfirmationView.types';
Expand Down Expand Up @@ -37,7 +37,11 @@ const StakeConfirmationView = ({ route }: StakeConfirmationViewProps) => {
tokenSymbol="ETH"
/>
<View style={styles.cardsContainer}>
<AccountHeaderCard contractName={MOCK_STAKING_CONTRACT_NAME} />
<AccountCard
contractName={MOCK_STAKING_CONTRACT_NAME}
primaryLabel={strings('stake.staking_from')}
secondaryLabel={strings('stake.interacting_with')}
/>
<RewardsCard
rewardRate={route.params.annualRewardRate}
rewardsEth={route.params.annualRewardsETH}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { StyleSheet } from 'react-native';
import { Theme } from '../../../../../util/theme/models';

const styleSheet = (params: { theme: Theme }) => {
const { theme } = params;
const { colors } = theme;

return StyleSheet.create({
mainContainer: {
paddingTop: 8,
paddingHorizontal: 16,
backgroundColor: colors.background.alternative,
height: '100%',
justifyContent: 'space-between',
},
cardsContainer: {
paddingTop: 8,
gap: 8,
},
});
};

export default styleSheet;
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import React from 'react';
import UnstakeConfirmationView from './UnstakeConfirmationView';
import renderWithProvider from '../../../../../util/test/renderWithProvider';
import { Image } from 'react-native';
import { createMockAccountsControllerState } from '../../../../../util/test/accountsControllerTestUtils';
import { backgroundState } from '../../../../../util/test/initial-root-state';
import { UnstakeConfirmationViewProps } from './UnstakeConfirmationView.types';

const MOCK_ADDRESS_1 = '0x0';
const MOCK_ADDRESS_2 = '0x1';

const MOCK_ACCOUNTS_CONTROLLER_STATE = createMockAccountsControllerState([
MOCK_ADDRESS_1,
MOCK_ADDRESS_2,
]);

const mockInitialState = {
settings: {},
engine: {
backgroundState: {
...backgroundState,
AccountsController: MOCK_ACCOUNTS_CONTROLLER_STATE,
},
},
};

jest.mock('../../../../hooks/useIpfsGateway', () => jest.fn());

Image.getSize = jest.fn((_uri, success) => {
success(100, 100); // Mock successful response for ETH native Icon Image
});

const mockNavigate = jest.fn();
const mockSetOptions = jest.fn();

jest.mock('@react-navigation/native', () => {
const actualReactNavigation = jest.requireActual('@react-navigation/native');
return {
...actualReactNavigation,
useNavigation: () => ({
navigate: mockNavigate,
setOptions: mockSetOptions,
}),
};
});

jest.mock('../../hooks/usePoolStakedDeposit', () => ({
__esModule: true,
default: () => ({
attemptDepositTransaction: jest.fn(),
}),
}));

jest.mock('../../hooks/usePooledStakes', () => ({
__esModule: true,
default: () => ({
refreshPooledStakes: jest.fn(),
}),
}));

describe('UnstakeConfirmationView', () => {
it('render matches snapshot', () => {
const props: UnstakeConfirmationViewProps = {
route: {
key: '1',
name: 'params',
params: {
amountWei: '4999820000000000000',
amountFiat: '12894.52',
},
},
};

const { toJSON } = renderWithProvider(
<UnstakeConfirmationView {...props} />,
{ state: mockInitialState },
);

expect(toJSON()).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { View } from 'react-native';
import React, { useEffect } from 'react';
import { useNavigation } from '@react-navigation/native';
import styleSheet from './UnstakeConfirmationView.styles';
import { useStyles } from '../../../../hooks/useStyles';
import { getStakingNavbar } from '../../../Navbar';
import { strings } from '../../../../../../locales/i18n';
import YouReceiveCard from '../../components/StakingConfirmation/YouReceiveCard/YouReceiveCard';
import UnstakingTimeCard from '../../components/StakingConfirmation/UnstakeTimeCard/UnstakeTimeCard';
import { UnstakeConfirmationViewProps } from './UnstakeConfirmationView.types';
import TokenValueStack from '../../components/StakingConfirmation/TokenValueStack/TokenValueStack';
import AccountCard from '../../components/StakingConfirmation/AccountCard/AccountCard';
import ConfirmationFooter from '../../components/StakingConfirmation/ConfirmationFooter/ConfirmationFooter';
import { FooterButtonGroupActions } from '../../components/StakingConfirmation/ConfirmationFooter/FooterButtonGroup/FooterButtonGroup.types';

const MOCK_STAKING_CONTRACT_NAME = 'MM Pooled Staking';

const UnstakeConfirmationView = ({ route }: UnstakeConfirmationViewProps) => {
const { styles, theme } = useStyles(styleSheet, {});

const navigation = useNavigation();

useEffect(() => {
navigation.setOptions(
getStakingNavbar(strings('stake.unstake'), navigation, theme.colors, {
backgroundColor: theme.colors.background.alternative,
hasCancelButton: false,
}),
);
}, [navigation, theme.colors]);

return (
<View style={styles.mainContainer}>
<View>
<TokenValueStack
amountWei={route.params.amountWei}
amountFiat={`$${route.params.amountFiat}`}
tokenSymbol="ETH"
/>
<View style={styles.cardsContainer}>
<YouReceiveCard
amountWei={route.params.amountWei}
amountFiat={route.params.amountFiat}
/>
<AccountCard
contractName={MOCK_STAKING_CONTRACT_NAME}
primaryLabel={strings('stake.unstaking_to')}
secondaryLabel={strings('stake.interacting_with')}
/>
<UnstakingTimeCard />
</View>
</View>
<ConfirmationFooter
valueWei={route.params.amountWei}
action={FooterButtonGroupActions.UNSTAKE}
/>
</View>
);
};

export default UnstakeConfirmationView;
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { RouteProp } from '@react-navigation/native';

interface UnstakeConfirmationViewRouteParams {
amountWei: string;
amountFiat: string;
}

export interface UnstakeConfirmationViewProps {
route: RouteProp<{ params: UnstakeConfirmationViewRouteParams }, 'params'>;
}
Loading

0 comments on commit 2e9b675

Please sign in to comment.