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

[5.4] Feature/3157 token detection v2 merge #4388

Merged
merged 47 commits into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
6ba0846
Reapply all token detection v2 changes on top of main
Cal-L May 24, 2022
2234a2c
Update unit tests
Cal-L May 24, 2022
607fdc4
Add missing what's new images
Cal-L May 24, 2022
67bcf4a
Fix tests
Cal-L May 24, 2022
bb42b6d
Update add tokens method call
Cal-L May 24, 2022
a60c848
Remove unnecessary align items on modals
Cal-L May 24, 2022
47bcd43
Clean up code. Write documentation for what's new.
Cal-L May 26, 2022
d66c12d
Update controllers package
Cal-L May 29, 2022
dab645e
Update isTokenDetectionSupportedForNetwork
Cal-L May 31, 2022
47908ca
Update search in receive flow to support TD networks
Cal-L Jun 1, 2022
bd941c0
Fix search in receive flow
Cal-L Jun 2, 2022
bf9df29
Resolve new token detection controller updates
Cal-L Jun 2, 2022
352c83a
Merge with main
Cal-L Jun 2, 2022
03d4b02
Fix Android Boolean cast error
Cal-L Jun 3, 2022
20a2a30
Fix detected tokens checkbox layout on Android. Add token hidden anal…
Cal-L Jun 6, 2022
095032c
Update to latest controller changes
Cal-L Jun 7, 2022
8945100
Merge with main
Cal-L Jun 7, 2022
eeec064
Fix scrolling issue on detected tokens sheet for Android
Cal-L Jun 8, 2022
e5996e0
Update to use latest controller release
Cal-L Jun 9, 2022
9807052
Merge with main
Cal-L Jun 9, 2022
a9181f2
Fix missing nav bar for adding network
Cal-L Jun 10, 2022
197e13b
Anchor token detection toggle when accessing from advanced settings
Cal-L Jun 14, 2022
b206e7f
Merge branch 'main' of https://github.com/MetaMask/metamask-mobile in…
Cal-L Jun 14, 2022
9f41355
Update detected tokens confirmation copy
Cal-L Jun 28, 2022
ef91d19
Merge with main
Cal-L Jun 28, 2022
f321c83
Update controller version
Cal-L Jun 28, 2022
2979ed9
Merge branch 'main' of https://github.com/MetaMask/metamask-mobile in…
Cal-L Jun 28, 2022
c44df56
Merge branch 'main' of https://github.com/MetaMask/metamask-mobile in…
Cal-L Jun 28, 2022
6862520
Merge branch 'main' into feature/3157-token-detection-v2-merge
gantunesr Jun 28, 2022
f5e9235
updated url for reporting invalid phishing site (#4485)
sethkfman Jun 29, 2022
5b08559
Merge branch 'main' into feature/3157-token-detection-v2-merge
Cal-L Jun 29, 2022
fcfb2d9
Fix setting default account while reopening app after first session
Cal-L Jun 30, 2022
1c06a66
Update whats new modal with current version (5.2.0) to show
Cal-L Jun 30, 2022
14f0a8e
Update token detection whats new image
Cal-L Jun 30, 2022
78abcf2
Update whats new copy
Cal-L Jun 30, 2022
3bc3aa4
Change whats new to upgrade only
Cal-L Jul 5, 2022
347e8b7
Up whats new version 5.2.0
Cal-L Jul 5, 2022
e68a894
Fix frozen state caused by whats new modal
Cal-L Jul 6, 2022
c44ed2d
Update version to 5.4.0
Cal-L Jul 6, 2022
d27086e
Merge branch 'feature/3157-token-detection-v2-merge' of https://githu…
Cal-L Jul 6, 2022
469fab8
Update iOS version
Cal-L Jul 6, 2022
7add98e
Merge branch 'feature/3157-token-detection-v2-merge' of https://githu…
Cal-L Jul 6, 2022
2994041
Refactor Whats New modal to be part of React Navigation. Remove confl…
Cal-L Jul 7, 2022
cf7e783
Fix highlighted wallet tab in drawer
Cal-L Jul 7, 2022
84f1b5a
Merge from main. WIP - Fix whats new modal
Cal-L Jul 7, 2022
181366a
Merge in whats new modal fix
Cal-L Jul 7, 2022
1271757
Merge branch 'main' of https://github.com/MetaMask/metamask-mobile in…
Cal-L Jul 11, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

exports[`RemoteImage should render ipfs sources 1`] = `
<Image
onError={[Function]}
source={
Object {
"uri": "https://cloudflare-ipfs.com/ipfs/QmeE94srcYV9WwJb1p42eM4zncdLUai2N9zmMxxukoEQ23",
Expand All @@ -12,6 +13,7 @@ exports[`RemoteImage should render ipfs sources 1`] = `

exports[`RemoteImage should render static sources 1`] = `
<Image
onError={[Function]}
source={
Object {
"uri": "https://s3.amazonaws.com/airswap-token-images/OXT.png",
Expand Down
18 changes: 15 additions & 3 deletions app/components/Base/RemoteImage/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo } from 'react';
import React, { useMemo, useState } from 'react';
import PropTypes from 'prop-types';
import { Image, ViewPropTypes, View, StyleSheet } from 'react-native';
import FadeIn from 'react-native-fade-in-image';
Expand All @@ -9,6 +9,7 @@ import isUrl from 'is-url';
import ComponentErrorBoundary from '../../UI/ComponentErrorBoundary';
import useIpfsGateway from '../../hooks/useIpfsGateway';
import { util } from '@metamask/controllers';
import Identicon from '../../UI/Identicon';

const createStyles = () =>
StyleSheet.create({
Expand All @@ -18,6 +19,7 @@ const createStyles = () =>
});

const RemoteImage = (props) => {
const [error, setError] = useState(undefined);
// Avoid using this component with animated SVG
const source = resolveAssetSource(props.source);
const isImageUrl = isUrl(props?.source?.uri);
Expand All @@ -40,6 +42,12 @@ const RemoteImage = (props) => {

const uri = resolvedIpfsUrl || source.uri;

const onError = ({ nativeEvent: { error } }) => setError(error);

if (error && props.address) {
return <Identicon address={props.address} customStyle={props.style} />;
}

if (
source &&
source.uri &&
Expand Down Expand Up @@ -71,11 +79,11 @@ const RemoteImage = (props) => {
if (props.fadeIn) {
return (
<FadeIn placeholderStyle={props.placeholderStyle}>
<Image {...props} source={{ uri }} />
<Image {...props} source={{ uri }} onError={onError} />
</FadeIn>
);
}
return <Image {...props} source={{ uri }} />;
return <Image {...props} source={{ uri }} onError={onError} />;
};

RemoteImage.propTypes = {
Expand Down Expand Up @@ -103,6 +111,10 @@ RemoteImage.propTypes = {
* This is set if we know that an image is remote
*/
isUrl: PropTypes.bool,
/**
* Token address
*/
address: PropTypes.string,
};

export default RemoteImage;
119 changes: 97 additions & 22 deletions app/components/Nav/Main/MainNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ import AppInformation from '../../Views/Settings/AppInformation';
import Contacts from '../../Views/Settings/Contacts';
import Wallet from '../../Views/Wallet';
import Asset from '../../Views/Asset';
import AssetOptions from '../../Views/AssetOptions';
import AssetDetails from '../../Views/AssetDetails';
import AddAsset from '../../Views/AddAsset';
import AssetHideConfirmation from '../../Views/AssetHideConfirmation';
import DetectedTokens from '../../Views/DetectedTokens';
import DetectedTokensConfirmation from '../../Views/DetectedTokensConfirmation';
import Collectible from '../../Views/Collectible';
import Send from '../../Views/Send';
import SendTo from '../../Views/SendFlow/SendTo';
Expand Down Expand Up @@ -77,18 +82,92 @@ const styles = StyleSheet.create({
opacity: 0,
},
});
/**
* Navigator component that wraps
* the 2 main sections: Browser, Wallet
*/

const WalletTabHome = () => (
const clearStackNavigatorOptions = {
headerShown: false,
cardStyle: {
backgroundColor: 'transparent',
cardStyleInterpolator: () => ({
overlayStyle: {
opacity: 0,
},
}),
},
animationEnabled: false,
};

const DetectedTokensFlow = () => (
<Stack.Navigator
mode={'modal'}
screenOptions={clearStackNavigatorOptions}
initialRouteName={'DetectedTokens'}
>
<Stack.Screen name={'DetectedTokens'} component={DetectedTokens} />
<Stack.Screen
name={'DetectedTokensConfirmation'}
component={DetectedTokensConfirmation}
/>
</Stack.Navigator>
);

const WalletModalFlow = () => (
<Stack.Navigator mode={'modal'} screenOptions={clearStackNavigatorOptions}>
<Stack.Screen
name={'Wallet'}
component={Wallet}
options={{ headerShown: true, animationEnabled: false }}
/>
<Stack.Screen name={'DetectedTokens'} component={DetectedTokensFlow} />
</Stack.Navigator>
);

/* eslint-disable react/prop-types */
const AssetStackFlow = (props) => (
<Stack.Navigator>
<Stack.Screen
name={'Asset'}
component={Asset}
initialParams={props.route.params}
/>
<Stack.Screen
name={'AssetDetails'}
component={AssetDetails}
initialParams={{ address: props.route.params?.address }}
/>
</Stack.Navigator>
);

const AssetModalFlow = (props) => (
<Stack.Navigator
mode={'modal'}
initialRouteName={'AssetStackFlow'}
screenOptions={clearStackNavigatorOptions}
>
<Stack.Screen
name={'AssetStackFlow'}
component={AssetStackFlow}
initialParams={props.route.params}
/>
<Stack.Screen
name={'AssetOptions'}
component={AssetOptions}
initialParams={{ address: props.route.params?.address }}
/>
</Stack.Navigator>
);
/* eslint-enable react/prop-types */

const WalletTabStackFlow = () => (
<Stack.Navigator initialRouteName={'WalletView'}>
<Stack.Screen name="WalletView" component={Wallet} />
<Stack.Screen
name="WalletView"
component={WalletModalFlow}
options={{ headerShown: false }}
/>
<Stack.Screen
name="Asset"
component={Asset}
options={Asset.navigationOptions}
component={AssetModalFlow}
options={{ headerShown: false }}
/>
<Stack.Screen
name="AddAsset"
Expand All @@ -105,15 +184,15 @@ const WalletTabHome = () => (
component={RevealPrivateCredential}
options={RevealPrivateCredential.navigationOptions}
/>
</Stack.Navigator>
);

const WalletTabModalFlow = () => (
<Stack.Navigator mode={'modal'} screenOptions={clearStackNavigatorOptions}>
<Stack.Screen name={'WalletTabStackFlow'} component={WalletTabStackFlow} />
<Stack.Screen
name="ExperimentalSettings"
component={ExperimentalSettings}
options={ExperimentalSettings.navigationOptions}
/>
<Stack.Screen
name="NetworkSettings"
component={NetworkSettings}
options={NetworkSettings.navigationOptions}
name={'AssetHideConfirmation'}
component={AssetHideConfirmation}
/>
</Stack.Navigator>
);
Expand Down Expand Up @@ -160,7 +239,7 @@ const HomeTabs = () => {
>
<Tab.Screen
name="WalletTabHome"
component={WalletTabHome}
component={WalletTabModalFlow}
options={{ tabBarVisible: false }}
/>
<Tab.Screen
Expand Down Expand Up @@ -222,11 +301,7 @@ const SettingsFlow = () => (
component={NetworksSettings}
options={NetworksSettings.navigationOptions}
/>
<Stack.Screen
name="NetworkSettings"
component={NetworkSettings}
options={NetworkSettings.navigationOptions}
/>
<Stack.Screen name="NetworkSettings" component={NetworkSettings} />
<Stack.Screen
name="CompanySettings"
component={AppInformation}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,37 @@ exports[`AddCustomToken should render correctly 1`] = `
testID="add-asset-cancel-button"
>
<View>
<WarningMessage
<Alert
renderIcon={[Function]}
style={
Object {
"marginHorizontal": 20,
"marginTop": 20,
"paddingRight": 0,
}
}
warningMessage={
<React.Fragment>
Anyone can create a token, including creating fake versions of existing tokens. Learn more about
<Text
onPress={[Function]}
style={
Object {
"color": "#037DD6",
}
}
suppressHighlighting={true}
testID="add-asset-warning-message"
>
scams and security risks.
</Text>
</React.Fragment>
}
/>
type="Info"
>
<Text
style={
Object {
"color": "#24272A",
}
}
>
Token detection is not available on this network yet. Please import token manually and make sure you trust it. Learn about
</Text>
<Text
onPress={[Function]}
style={
Object {
"color": "#037DD6",
}
}
suppressHighlighting={true}
>
token scams and security risks.
</Text>
</Alert>
<View
style={
Object {
Expand All @@ -67,7 +72,7 @@ exports[`AddCustomToken should render correctly 1`] = `
}
}
>
Token Address
Token address
</Text>
<TextInput
keyboardAppearance="light"
Expand Down Expand Up @@ -119,7 +124,7 @@ exports[`AddCustomToken should render correctly 1`] = `
}
}
>
Token Symbol
Token symbol
</Text>
<TextInput
keyboardAppearance="light"
Expand Down Expand Up @@ -170,7 +175,7 @@ exports[`AddCustomToken should render correctly 1`] = `
}
}
>
Token of Precision
Token decimal
</Text>
<TextInput
keyboardAppearance="light"
Expand Down
Loading