Skip to content

Commit fc761a6

Browse files
authored
Merge branch 'main' into fix/btc_fees_order
2 parents aef9855 + 5138211 commit fc761a6

File tree

81 files changed

+4574
-1224
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+4574
-1224
lines changed

.detoxrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = {
2222
$0: 'jest',
2323
config: 'e2e/jest.e2e.config.js',
2424
},
25-
detached: true,
25+
detached: process.env.CI ? true : false,
2626
jest: {
2727
setupTimeout: 220000,
2828
teardownTimeout: 60000, // Increase teardown timeout from default 30s to 60s

android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ android {
187187
applicationId "io.metamask"
188188
minSdkVersion rootProject.ext.minSdkVersion
189189
targetSdkVersion rootProject.ext.targetSdkVersion
190-
versionName "7.59.0"
190+
versionName "7.60.0"
191191
versionCode 2818
192192
testBuildType System.getProperty('testBuildType', 'debug')
193193
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

app/component-library/components-temp/MultichainAccounts/AccountCell/AccountCell.tsx

Lines changed: 75 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { AccountGroupObject } from '@metamask/account-tree-controller';
22
import React, { useCallback, useMemo } from 'react';
3-
import { TouchableOpacity, View } from 'react-native';
3+
import { type ImageSourcePropType, TouchableOpacity, View } from 'react-native';
44
import { useSelector } from 'react-redux';
55
import { useNavigation } from '@react-navigation/native';
66
import { useStyles } from '../../../hooks';
@@ -36,18 +36,24 @@ interface AccountCellProps {
3636
avatarAccountType: AvatarAccountType;
3737
hideMenu?: boolean;
3838
startAccessory?: React.ReactNode;
39+
endContainer?: React.ReactNode;
3940
chainId?: string;
4041
onSelectAccount?: () => void;
4142
}
4243

43-
const AccountCell = ({
44+
type BalanceEndContainerProps = Pick<
45+
AccountCellProps,
46+
'accountGroup' | 'hideMenu' | 'onSelectAccount'
47+
> & {
48+
networkImageSource?: ImageSourcePropType;
49+
};
50+
51+
const BalanceEndContainer = ({
4452
accountGroup,
45-
avatarAccountType,
46-
hideMenu = false,
47-
startAccessory,
48-
chainId,
53+
hideMenu,
4954
onSelectAccount,
50-
}: AccountCellProps) => {
55+
networkImageSource,
56+
}: BalanceEndContainerProps) => {
5157
const { styles } = useStyles(styleSheet, {});
5258
const { navigate } = useNavigation();
5359

@@ -63,12 +69,6 @@ const AccountCell = ({
6369
const totalBalance = groupBalance?.totalBalanceInUserCurrency;
6470
const userCurrency = groupBalance?.userCurrency;
6571

66-
const selectEvmAddress = useMemo(
67-
() => selectIconSeedAddressByAccountGroupId(accountGroup.id),
68-
[accountGroup.id],
69-
);
70-
const evmAddress = useSelector(selectEvmAddress);
71-
7272
const displayBalance = useMemo(() => {
7373
if (totalBalance == null || !userCurrency) {
7474
return undefined;
@@ -79,6 +79,61 @@ const AccountCell = ({
7979
});
8080
}, [totalBalance, userCurrency]);
8181

82+
return (
83+
<>
84+
<TouchableOpacity onPress={onSelectAccount}>
85+
<View style={styles.balanceContainer}>
86+
<Text
87+
variant={TextVariant.BodyMDMedium}
88+
color={TextColor.Default}
89+
testID={AccountCellIds.BALANCE}
90+
>
91+
{totalBalance ? displayBalance : null}
92+
</Text>
93+
{networkImageSource && (
94+
<Avatar
95+
variant={AvatarVariant.Network}
96+
size={AvatarSize.Xs}
97+
style={styles.networkBadge}
98+
imageSource={networkImageSource}
99+
/>
100+
)}
101+
</View>
102+
</TouchableOpacity>
103+
{!hideMenu && (
104+
<TouchableOpacity
105+
testID={AccountCellIds.MENU}
106+
style={styles.menuButton}
107+
onPress={handleMenuPress}
108+
>
109+
<Icon
110+
name={IconName.MoreVertical}
111+
size={IconSize.Md}
112+
color={TextColor.Alternative}
113+
/>
114+
</TouchableOpacity>
115+
)}
116+
</>
117+
);
118+
};
119+
120+
const AccountCell = ({
121+
accountGroup,
122+
avatarAccountType,
123+
hideMenu = false,
124+
startAccessory,
125+
endContainer,
126+
chainId,
127+
onSelectAccount,
128+
}: AccountCellProps) => {
129+
const { styles } = useStyles(styleSheet, {});
130+
131+
const selectEvmAddress = useMemo(
132+
() => selectIconSeedAddressByAccountGroupId(accountGroup.id),
133+
[accountGroup.id],
134+
);
135+
const evmAddress = useSelector(selectEvmAddress);
136+
82137
// Determine which account address and network avatar to display based on the chainId
83138
let networkAccountAddress;
84139
let networkImageSource;
@@ -138,37 +193,13 @@ const AccountCell = ({
138193
</View>
139194
</TouchableOpacity>
140195
<View style={styles.endContainer}>
141-
<TouchableOpacity onPress={onSelectAccount}>
142-
<View style={styles.balanceContainer}>
143-
<Text
144-
variant={TextVariant.BodyMDMedium}
145-
color={TextColor.Default}
146-
testID={AccountCellIds.BALANCE}
147-
>
148-
{totalBalance ? displayBalance : null}
149-
</Text>
150-
{networkImageSource && (
151-
<Avatar
152-
variant={AvatarVariant.Network}
153-
size={AvatarSize.Xs}
154-
style={styles.networkBadge}
155-
imageSource={networkImageSource}
156-
/>
157-
)}
158-
</View>
159-
</TouchableOpacity>
160-
{!hideMenu && (
161-
<TouchableOpacity
162-
testID={AccountCellIds.MENU}
163-
style={styles.menuButton}
164-
onPress={handleMenuPress}
165-
>
166-
<Icon
167-
name={IconName.MoreVertical}
168-
size={IconSize.Md}
169-
color={TextColor.Alternative}
170-
/>
171-
</TouchableOpacity>
196+
{endContainer || (
197+
<BalanceEndContainer
198+
accountGroup={accountGroup}
199+
hideMenu={hideMenu}
200+
onSelectAccount={onSelectAccount}
201+
networkImageSource={networkImageSource}
202+
/>
172203
)}
173204
</View>
174205
</Box>

app/component-library/components-temp/MultichainAccounts/MultichainAccountSelectorList/AccountListHeader/AccountListHeader.tsx

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,23 @@ import Text, {
99
import createStyles from '../MultichainAccountSelectorList.styles';
1010
import { AccountListHeaderProps } from './AccountListHeader.types';
1111

12-
const AccountListHeader = memo(({ title }: AccountListHeaderProps) => {
13-
const { styles } = useStyles(createStyles, {});
12+
const AccountListHeader = memo(
13+
({ title, containerStyle }: AccountListHeaderProps) => {
14+
const { styles } = useStyles(createStyles, {});
1415

15-
return (
16-
<View style={styles.sectionHeader}>
17-
<Text
18-
variant={TextVariant.BodyMDMedium}
19-
color={TextColor.Alternative}
20-
style={styles.sectionHeaderText}
21-
>
22-
{title}
23-
</Text>
24-
</View>
25-
);
26-
});
16+
return (
17+
<View style={[styles.sectionHeader, containerStyle]}>
18+
<Text
19+
variant={TextVariant.BodyMDMedium}
20+
color={TextColor.Alternative}
21+
style={styles.sectionHeaderText}
22+
>
23+
{title}
24+
</Text>
25+
</View>
26+
);
27+
},
28+
);
2729

2830
AccountListHeader.displayName = 'AccountListHeader';
2931

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { ViewStyle } from 'react-native';
2+
13
export interface AccountListHeaderProps {
24
title: string;
5+
containerStyle?: ViewStyle;
36
}

app/components/Nav/Main/MainNavigator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect, useMemo, useCallback } from 'react';
1+
import React, { useState, useEffect, useMemo } from 'react';
22
import { Image, StyleSheet, Keyboard, Platform } from 'react-native';
33
import { createStackNavigator } from '@react-navigation/stack';
44
import { useSelector } from 'react-redux';
@@ -1192,7 +1192,7 @@ const MainNavigator = () => {
11921192
...GeneralSettings.navigationOptions,
11931193
}}
11941194
/>
1195-
{process.env.NODE_ENV !== 'production' && (
1195+
{process.env.METAMASK_ENVIRONMENT !== 'production' && (
11961196
<Stack.Screen
11971197
name={Routes.FEATURE_FLAG_OVERRIDE}
11981198
component={FeatureFlagOverride}

app/components/Nav/Main/MainNavigator.test.tsx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@ jest.mock('@react-navigation/stack', () => ({
1313
}));
1414

1515
describe('MainNavigator', () => {
16+
const originalEnv = process.env.METAMASK_ENVIRONMENT;
17+
1618
beforeEach(() => {
1719
jest.clearAllMocks();
1820
});
1921

22+
afterEach(() => {
23+
process.env.METAMASK_ENVIRONMENT = originalEnv;
24+
});
25+
2026
it('matches rendered snapshot', () => {
2127
// Given the initial app state
2228
// When rendering the MainNavigator
@@ -60,4 +66,41 @@ describe('MainNavigator', () => {
6066
expect(sampleFeatureScreen).toBeDefined();
6167
expect(sampleFeatureScreen?.component.name).toBe('SampleFeatureFlow');
6268
});
69+
70+
it('includes FeatureFlagOverride screen when METAMASK_ENVIRONMENT is not production', () => {
71+
// Given a non-production environment
72+
process.env.METAMASK_ENVIRONMENT = 'dev';
73+
74+
// When rendering the MainNavigator
75+
const container = renderWithProvider(<MainNavigator />, {
76+
state: initialRootState,
77+
});
78+
79+
// Then it should contain the FeatureFlagOverride screen
80+
interface ScreenChild {
81+
name: string;
82+
component: { name: string };
83+
}
84+
const screenProps: ScreenChild[] = container.root.children
85+
.filter(
86+
(child): child is ReactTestInstance =>
87+
typeof child === 'object' &&
88+
'type' in child &&
89+
'props' in child &&
90+
child.type?.toString() === 'Screen',
91+
)
92+
.map((child) => ({
93+
name: child.props.name,
94+
component: child.props.component,
95+
}));
96+
97+
const featureFlagOverrideScreen = screenProps?.find(
98+
(screen) => screen?.name === Routes.FEATURE_FLAG_OVERRIDE,
99+
);
100+
101+
expect(featureFlagOverrideScreen).toBeDefined();
102+
expect(featureFlagOverrideScreen?.component.name).toBe(
103+
'FeatureFlagOverride',
104+
);
105+
});
63106
});

0 commit comments

Comments
 (0)