Skip to content

Commit

Permalink
Merge branch 'test/mobile-staking-uat' into stake-805-to-uat
Browse files Browse the repository at this point in the history
  • Loading branch information
siibars committed Oct 21, 2024
2 parents a0dcd7a + ced542a commit aeb9d74
Show file tree
Hide file tree
Showing 73 changed files with 3,218 additions and 977 deletions.
7 changes: 5 additions & 2 deletions .js.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ export MM_ENABLE_SETTINGS_PAGE_DEV_OPTIONS="true"
# The endpoint used to submit errors and tracing data to Sentry for dev environment.
# export MM_SENTRY_DSN_DEV=

# Multichain Feature flag
export MULTICHAIN_V1=""
# Per dapp selected network (Amon Hen) feature flag
export MM_PER_DAPP_SELECTED_NETWORK=""

export MM_CHAIN_PERMISSIONS=""

#Multichain feature flag specific to UI changes
export MM_MULTICHAIN_V1_ENABLED=""
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1450
versionName "7.32.0"
versionName "7.33.0"
testBuildType System.getProperty('testBuildType', 'debug')
missingDimensionStrategy 'react-native-camera', 'general'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
6 changes: 4 additions & 2 deletions app/components/UI/AssetOverview/Balance/Balance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface BalanceProps {
secondaryBalance?: string;
}

const NetworkBadgeSource = (chainId: string, ticker: string) => {
export const NetworkBadgeSource = (chainId: string, ticker: string) => {
const isMainnet = isMainnetByChainId(chainId);
const isLineaMainnet = isLineaMainnetByChainId(chainId);

Expand Down Expand Up @@ -88,7 +88,9 @@ const Balance = ({ asset, mainBalance, secondaryBalance }: BalanceProps) => {
{asset.name || asset.symbol}
</Text>
</AssetElement>
{isPooledStakingFeatureEnabled() && asset?.isETH && <StakingBalance />}
{isPooledStakingFeatureEnabled() && asset?.isETH && (
<StakingBalance asset={asset} />
)}
</View>
);
};
Expand Down
18 changes: 6 additions & 12 deletions app/components/UI/AssetOverview/TokenDetails/TokenDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { zeroAddress } from 'ethereumjs-util';
import React, { useState } from 'react';
import React from 'react';
import { View } from 'react-native';
import { useSelector } from 'react-redux';
import i18n from '../../../../../locales/i18n';
import { useStyles } from '../../../../component-library/hooks';
import styleSheet from './TokenDetails.styles';
import { formatAddress, safeToChecksumAddress } from '../../../../util/address';
import { safeToChecksumAddress } from '../../../../util/address';
import { selectTokenList } from '../../../../selectors/tokenListController';
import { selectContractExchangeRates } from '../../../../selectors/tokenRatesController';
import {
Expand All @@ -21,8 +21,8 @@ import Logger from '../../../../util/Logger';
import TokenDetailsList from './TokenDetailsList';
import MarketDetailsList from './MarketDetailsList';
import { TokenI } from '../../Tokens/types';
import StakingEarnings from '../StakingEarnings';
import { isPooledStakingFeatureEnabled } from '../../Stake/constants';
import StakingEarnings from '../../Stake/components/StakingEarnings';

export interface TokenDetails {
contractAddress: string | null;
Expand Down Expand Up @@ -52,9 +52,6 @@ const TokenDetails: React.FC<TokenDetailsProps> = ({ asset }) => {
const currentCurrency = useSelector(selectCurrentCurrency);
const tokenContractAddress = safeToChecksumAddress(asset.address);

// TEMP: Remove once component has been implemented.
const [hasStakingPositions] = useState(true);

let tokenMetadata;
let marketData;

Expand All @@ -75,13 +72,12 @@ const TokenDetails: React.FC<TokenDetailsProps> = ({ asset }) => {

const tokenDetails: TokenDetails = asset.isETH
? {
contractAddress: formatAddress(zeroAddress(), 'short'),
contractAddress: zeroAddress(),
tokenDecimal: 18,
tokenList: '',
}
: {
contractAddress:
formatAddress(tokenContractAddress as string, 'short') || null,
contractAddress: tokenContractAddress || null,
tokenDecimal: tokenMetadata?.decimals || null,
tokenList: tokenMetadata?.aggregators.join(', ') || null,
};
Expand Down Expand Up @@ -127,9 +123,7 @@ const TokenDetails: React.FC<TokenDetailsProps> = ({ asset }) => {

return (
<View style={styles.tokenDetailsContainer}>
{asset.isETH &&
hasStakingPositions &&
isPooledStakingFeatureEnabled() && <StakingEarnings />}
{asset.isETH && isPooledStakingFeatureEnabled() && <StakingEarnings />}
{(asset.isETH || tokenMetadata) && (
<TokenDetailsList tokenDetails={tokenDetails} />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import Icon, {
import ClipboardManager from '../../../../../core/ClipboardManager';
import { TokenDetails } from '../TokenDetails';
import TokenDetailsListItem from '../TokenDetailsListItem';
import { formatAddress } from '../../../../../util/address';

interface TokenDetailsListProps {
tokenDetails: TokenDetails;
Expand Down Expand Up @@ -62,7 +63,7 @@ const TokenDetailsList: React.FC<TokenDetailsListProps> = ({
onPress={copyAccountToClipboard}
>
<Text color={TextColor.Primary} variant={TextVariant.BodySM}>
{tokenDetails.contractAddress}
{formatAddress(tokenDetails.contractAddress, 'short')}
</Text>
<Icon
name={IconName.Copy}
Expand Down
18 changes: 18 additions & 0 deletions app/components/UI/PermissionsSummary/PermissionsSummary.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,24 @@ const mockInitialState = {
};

describe('PermissionsSummary', () => {
it('should render correctly for network switch', () => {
const { toJSON } = renderWithProvider(
<PermissionsSummary
currentPageInformation={{
currentEnsName: '',
icon: '',
url: 'https://app.uniswap.org/',
}}
customNetworkInformation={{
chainName: 'Sepolia',
chainId: '0x1',
}}
isNetworkSwitch
/>,
{ state: mockInitialState },
);
expect(toJSON()).toMatchSnapshot();
});
it('should render correctly', () => {
const { toJSON } = renderWithProvider(
<PermissionsSummary
Expand Down
70 changes: 51 additions & 19 deletions app/components/UI/PermissionsSummary/PermissionsSummary.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import React, { useCallback } from 'react';
import StyledButton from '../StyledButton';
import { SafeAreaView, TouchableOpacity, View } from 'react-native';
import {
ImageSourcePropType,
SafeAreaView,
TouchableOpacity,
View,
} from 'react-native';
import { useNavigation } from '@react-navigation/native';
import { strings } from '../../../../locales/i18n';
import { useTheme } from '../../../util/theme';
Expand Down Expand Up @@ -30,19 +35,21 @@ import useSelectedAccount from '../Tabs/TabThumbnail/useSelectedAccount';
import styleSheet from './PermissionsSummary.styles';
import { useStyles } from '../../../component-library/hooks';
import { PermissionsSummaryProps } from './PermissionsSummary.types';
import { useSelector } from 'react-redux';
import { selectNetworkName } from '../../../selectors/networkInfos';
import { USER_INTENT } from '../../../constants/permissions';
import Routes from '../../../constants/navigation/Routes';
import ButtonIcon, {
ButtonIconSizes,
} from '../../../component-library/components/Buttons/ButtonIcon';
import { getNetworkImageSource } from '../../../util/networks';

const PermissionsSummary = ({
currentPageInformation,
customNetworkInformation,
onEdit,
onEditNetworks,
onBack,
onCancel,
onConfirm,
onUserAction,
showActionButtons = true,
isAlreadyConnected = true,
Expand All @@ -54,14 +61,26 @@ const PermissionsSummary = ({
const { styles } = useStyles(styleSheet, { isRenderedAsBottomSheet });
const { navigate } = useNavigation();
const selectedAccount = useSelectedAccount();
const networkName = useSelector(selectNetworkName);

// if network switch, we get the chain name from the customNetworkInformation
let chainName = '';
let chainImage: ImageSourcePropType;
if (isNetworkSwitch && customNetworkInformation?.chainId) {
chainName = customNetworkInformation?.chainName;
// @ts-expect-error getNetworkImageSource is not implemented in typescript
chainImage = getNetworkImageSource({
chainId: customNetworkInformation?.chainId,
});
}

const confirm = () => {
onUserAction?.(USER_INTENT.Confirm);
onConfirm?.();
};

const cancel = () => {
onUserAction?.(USER_INTENT.Cancel);
onCancel?.();
};

const handleEditAccountsButtonPress = () => {
Expand Down Expand Up @@ -208,21 +227,33 @@ const PermissionsSummary = ({
{strings('permissions.use_enabled_networks')}
</TextComponent>
<View style={styles.permissionRequestNetworkInfo}>
<View style={styles.permissionRequestNetworkName}>
<TextComponent numberOfLines={1} ellipsizeMode="tail">
<TextComponent variant={TextVariant.BodySM}>
{strings('permissions.requesting_for')}
</TextComponent>
<TextComponent variant={TextVariant.BodySMMedium}>
{networkName}
</TextComponent>
</TextComponent>
</View>
<View style={styles.avatarGroup}>
<AvatarGroup
avatarPropsList={SAMPLE_AVATARGROUP_PROPS.avatarPropsList}
/>
</View>
{isNetworkSwitch && (
<>
<View style={styles.permissionRequestNetworkName}>
<TextComponent numberOfLines={1} ellipsizeMode="tail">
<TextComponent variant={TextVariant.BodySM}>
{strings('permissions.requesting_for')}
</TextComponent>
<TextComponent variant={TextVariant.BodySMMedium}>
{chainName}
</TextComponent>
</TextComponent>
</View>
<Avatar
variant={AvatarVariant.Network}
size={AvatarSize.Xs}
name={chainName}
imageSource={chainImage}
/>
</>
)}
{!isNetworkSwitch && (
<View style={styles.avatarGroup}>
<AvatarGroup
avatarPropsList={SAMPLE_AVATARGROUP_PROPS.avatarPropsList}
/>
</View>
)}
</View>
</View>
{!isNetworkSwitch && renderEndAccessory()}
Expand All @@ -247,6 +278,7 @@ const PermissionsSummary = ({
})}
</TextComponent>
</View>
{/*TODO These should be conditional upon which permissions are being requested*/}
{!isNetworkSwitch && renderAccountPermissionsRequestInfoCard()}
{renderNetworkPermissionsRequestInfoCard()}
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ export interface PermissionsSummaryProps {
onEdit?: () => void;
onEditNetworks?: () => void;
onBack?: () => void;
onCancel?: () => void;
onConfirm?: () => void;
onUserAction?: React.Dispatch<React.SetStateAction<USER_INTENT>>;
showActionButtons?: boolean;
isAlreadyConnected?: boolean;
isRenderedAsBottomSheet?: boolean;
isDisconnectAllShown?: boolean;
isNetworkSwitch?: boolean;
customNetworkInformation?: {
chainName: string;
chainId: string;
};
}
Loading

0 comments on commit aeb9d74

Please sign in to comment.