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

Support sepolia network #5458

Merged
merged 27 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
aa4d370
sepolia support
tommasini Jan 6, 2023
950006d
clean code with deprecated test networks
tommasini Jan 6, 2023
dbb87a1
update snapshots
tommasini Jan 6, 2023
bbfc14a
remove unused code
tommasini Jan 10, 2023
46e99da
update snapshot
tommasini Jan 11, 2023
a874df8
Update controllers to match core release v39
Gudahtt Apr 5, 2023
924680e
Update assets-controllers patch
Gudahtt Apr 5, 2023
e63b1d4
resolve conflicts
tommasini Apr 5, 2023
efb8a9d
fix tests and en file
tommasini Apr 5, 2023
04cc8f4
remove unused supported networks const
tommasini Apr 5, 2023
715c6e8
update test file
tommasini Apr 6, 2023
3858075
miss snapshot on last commit
tommasini Apr 6, 2023
74c156d
Merge branch 'update-controllers-v39' into implement/5406-sepolia-sup…
tommasini Apr 6, 2023
8fe302b
merge main
tommasini Apr 7, 2023
ef4c397
address review
tommasini Apr 7, 2023
fa64a30
update yarn.lock
tommasini Apr 7, 2023
5fb0517
yran lock updated
tommasini Apr 7, 2023
64ba7ee
remove unused image icons
tommasini Apr 7, 2023
140f9b2
UI more accurate with the other networks
tommasini Apr 7, 2023
fd8912f
update snapshot
tommasini Apr 7, 2023
38769a2
merge main
tommasini Apr 9, 2023
41d6785
update sepolia icon
tommasini Apr 11, 2023
5f0a68d
Merge branch 'main' into implement/5406-sepolia-support
tommasini Apr 11, 2023
e8e8c2e
fix snapshot, rollback to linea testnet const
tommasini Apr 13, 2023
dab127c
add test ids to sepolia
tommasini Apr 13, 2023
a97017c
merge main
tommasini Apr 13, 2023
35854b6
merge main
tommasini Apr 18, 2023
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
48 changes: 1 addition & 47 deletions app/components/Nav/Main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
AppState,
StyleSheet,
View,
Linking,
PushNotificationIOS, // eslint-disable-line react-native/split-platform-components
} from 'react-native';
import NetInfo from '@react-native-community/netinfo';
Expand Down Expand Up @@ -54,9 +53,6 @@ import { useTheme } from '../../../util/theme';
import RootRPCMethodsUI from './RootRPCMethodsUI';
import usePrevious from '../../hooks/usePrevious';
import { colors as importedColors } from '../../../styles/common';
import WarningAlert from '../../../components/UI/WarningAlert';
import { KOVAN, RINKEBY, ROPSTEN } from '../../../constants/network';
import { MM_DEPRECATED_NETWORKS } from '../../../constants/urls';
import {
getNetworkImageSource,
getNetworkNameFromProvider,
Expand Down Expand Up @@ -93,7 +89,6 @@ const Main = (props) => {
const [forceReload, setForceReload] = useState(false);
const [showRemindLaterModal, setShowRemindLaterModal] = useState(false);
const [skipCheckbox, setSkipCheckbox] = useState(false);
const [showDeprecatedAlert, setShowDeprecatedAlert] = useState(true);
const { colors } = useTheme();
const styles = createStyles(colors);

Expand Down Expand Up @@ -332,29 +327,6 @@ const Main = (props) => {
termsOfUse();
}, [termsOfUse]);

const openDeprecatedNetworksArticle = () => {
Linking.openURL(MM_DEPRECATED_NETWORKS);
};

const renderDeprecatedNetworkAlert = (network, backUpSeedphraseVisible) => {
const { wizardStep } = props;
const { type } = network.providerConfig;
if (
(type === ROPSTEN || type === RINKEBY || type === KOVAN) &&
showDeprecatedAlert &&
!wizardStep
) {
return (
<WarningAlert
text={strings('networks.deprecated_network_msg')}
tommasini marked this conversation as resolved.
Show resolved Hide resolved
dismissAlert={() => setShowDeprecatedAlert(false)}
onPressLearnMore={openDeprecatedNetworksArticle}
precedentAlert={backUpSeedphraseVisible}
/>
);
}
};

return (
<React.Fragment>
<View style={styles.flex}>
Expand All @@ -372,10 +344,7 @@ const Main = (props) => {
onDismiss={toggleRemindLater}
navigation={props.navigation}
/>
{renderDeprecatedNetworkAlert(
props.network,
props.backUpSeedphraseVisible,
)}

<SkipAccountSecurityModal
modalVisible={showRemindLaterModal}
onCancel={skipAccountModalSecureNow}
Expand Down Expand Up @@ -438,27 +407,12 @@ Main.propTypes = {
* Object that represents the current route info like params passed to it
*/
route: PropTypes.object,
/**
* Object representing the selected network
*/
network: PropTypes.object,
/**
* redux flag that indicates if the alert should be shown
*/
backUpSeedphraseVisible: PropTypes.bool,
/**
* Onboarding wizard step.
*/
wizardStep: PropTypes.number,
};

const mapStateToProps = (state) => ({
lockTime: state.settings.lockTime,
thirdPartyApiMode: state.privacy.thirdPartyApiMode,
providerType: selectProviderType(state),
network: state.engine.backgroundState.NetworkController,
backUpSeedphraseVisible: state.user.backUpSeedphraseVisible,
wizardStep: state.wizard.step,
});

const mapDispatchToProps = (dispatch) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ exports[`AccountApproval should render correctly 1`] = `
}
}
dispatch={[Function]}
networkType="ropsten"
networkType="sepolia"
selectedAddress="0xe7E125654064EEa56229f273dA586F10DF96B0a1"
tokensLength={0}
/>
Expand Down
4 changes: 2 additions & 2 deletions app/components/UI/AccountApproval/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import AccountApproval from './';
import { shallow } from 'enzyme';
import configureMockStore from 'redux-mock-store';
import { ROPSTEN } from '../../../constants/network';
import { SEPOLIA } from '../../../constants/network';
import { Provider } from 'react-redux';

const mockStore = configureMockStore();
Expand All @@ -14,7 +14,7 @@ const initialState = {
},
NetworkController: {
providerConfig: {
type: ROPSTEN,
type: SEPOLIA,
},
},
TokensController: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ const initialState = {
},
NetworkController: {
providerConfig: {
chainId: '0x1',
type: 'ropsten',
nickname: 'Ropsten',
chainId: '0xaa36a7',
type: 'sepolia',
nickname: 'Sepolia',
},
provider: {
ticker: 'eth',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ exports[`ApproveTransactionHeader should render correctly 1`] = `
resizeMode="contain"
source={
Object {
"testUri": "../../../app/images/ropsten-logo-dark.png",
"testUri": "../../../app/images/sepolia-logo-dark.png",
}
}
style={
Expand Down Expand Up @@ -321,7 +321,7 @@ exports[`ApproveTransactionHeader should render correctly 1`] = `
}
}
>
Ropsten
Sepolia
</Text>
<Text
style={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ exports[`SignatureRequest should render correctly 1`] = `
}
}
dispatch={[Function]}
networkType="ropsten"
networkType="sepolia"
/>
`;
4 changes: 2 additions & 2 deletions app/components/UI/SignatureRequest/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { shallow } from 'enzyme';
import SignatureRequest from './';
import configureMockStore from 'redux-mock-store';
import { ROPSTEN } from '../../../constants/network';
import { SEPOLIA } from '../../../constants/network';
import { Provider } from 'react-redux';

const mockStore = configureMockStore();
Expand All @@ -18,7 +18,7 @@ const initialState = {
},
NetworkController: {
providerConfig: {
type: ROPSTEN,
type: SEPOLIA,
},
},
},
Expand Down
17 changes: 14 additions & 3 deletions app/components/UI/Tokens/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ import NetworkMainAssetLogo from '../NetworkMainAssetLogo';
import { isZero } from '../../../util/lodash';
import { useTheme } from '../../../util/theme';
import NotificationManager from '../../../core/NotificationManager';
import { getDecimalChainId, isMainnetByChainId } from '../../../util/networks';
import {
getDecimalChainId,
getTestNetImageByChainId,
isMainnetByChainId,
isTestNet,
} from '../../../util/networks';
import generateTestId from '../../../../wdio/utils/generateTestId';
import {
IMPORT_TOKEN_BUTTON_ID,
Expand Down Expand Up @@ -220,7 +225,13 @@ const Tokens: React.FC<TokensI> = ({ tokens }) => {

const isMainnet = isMainnetByChainId(chainId);

const NetworkBadgeSource = isMainnet ? images.ETHEREUM : images[ticker];
const NetworkBadgeSource = () => {
if (isTestNet(chainId)) return getTestNetImageByChainId(chainId);

if (isMainnet) return images.ETHEREUM;

return images[ticker];
};

const badgeName = (isMainnet ? providerType : ticker) || '';

Expand All @@ -236,7 +247,7 @@ const Tokens: React.FC<TokensI> = ({ tokens }) => {
badgeProps={{
variant: BadgeVariant.Network,
name: badgeName,
imageSource: NetworkBadgeSource,
imageSource: NetworkBadgeSource(),
}}
>
{asset.isETH ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports[`TransactionHeader should render correctly 1`] = `
}
}
dispatch={[Function]}
networkType="ropsten"
nickname="Ropsten"
networkType="sepolia"
nickname="Sepolia"
/>
`;
6 changes: 3 additions & 3 deletions app/components/UI/TransactionHeader/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { shallow } from 'enzyme';
import TransactionHeader from './';
import configureMockStore from 'redux-mock-store';
import { ROPSTEN } from '../../../constants/network';
import { SEPOLIA } from '../../../constants/network';
import { Provider } from 'react-redux';

const mockStore = configureMockStore();
Expand All @@ -11,8 +11,8 @@ const initialState = {
backgroundState: {
NetworkController: {
providerConfig: {
type: ROPSTEN,
nickname: 'Ropsten',
type: SEPOLIA,
nickname: 'Sepolia',
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

exports[`UrlAutocomplete should render correctly 1`] = `
<Connect(UrlAutocomplete)
network="ropsten"
network="sepolia"
/>
`;
4 changes: 2 additions & 2 deletions app/components/UI/UrlAutocomplete/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { shallow } from 'enzyme';
import UrlAutocomplete from './';
import { Provider } from 'react-redux';
import configureMockStore from 'redux-mock-store';
import { ROPSTEN } from '../../../constants/network';
import { SEPOLIA } from '../../../constants/network';

const mockStore = configureMockStore();
const store = mockStore({});
Expand All @@ -12,7 +12,7 @@ describe('UrlAutocomplete', () => {
it('should render correctly', () => {
const wrapper = shallow(
<Provider store={store}>
<UrlAutocomplete network={ROPSTEN} />
<UrlAutocomplete network={SEPOLIA} />
</Provider>,
);
expect(wrapper).toMatchSnapshot();
Expand Down
4 changes: 2 additions & 2 deletions app/components/UI/WatchAssetRequest/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import WatchAssetRequest from './';
import configureMockStore from 'redux-mock-store';
import { BN } from 'ethereumjs-util';
import { Provider } from 'react-redux';
import { ROPSTEN } from '../../../constants/network';
import { SEPOLIA } from '../../../constants/network';

const mockStore = configureMockStore();
const initialState = {
Expand All @@ -18,7 +18,7 @@ const initialState = {
},
NetworkController: {
providerConfig: {
type: ROPSTEN,
type: SEPOLIA,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exports[`Approval should render correctly 1`] = `
},
}
}
networkType="ropsten"
networkType="sepolia"
resetTransaction={[Function]}
selectedAddress="0x0"
showCustomNonce={false}
Expand Down
4 changes: 2 additions & 2 deletions app/components/Views/Approval/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import Approval from './';
import configureMockStore from 'redux-mock-store';
import { shallow } from 'enzyme';
import { ROPSTEN } from '../../../constants/network';
import { SEPOLIA } from '../../../constants/network';
import { Provider } from 'react-redux';

const mockStore = configureMockStore();
Expand Down Expand Up @@ -30,7 +30,7 @@ const initialState = {
},
NetworkController: {
providerConfig: {
type: ROPSTEN,
type: SEPOLIA,
},
},
PreferencesController: {
Expand Down
4 changes: 2 additions & 2 deletions app/components/Views/Login/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { shallow } from 'enzyme';
import Login from './';
import configureMockStore from 'redux-mock-store';
import { ROPSTEN } from '../../../constants/network';
import { SEPOLIA } from '../../../constants/network';
import { Provider } from 'react-redux';

const mockStore = configureMockStore();
Expand All @@ -14,7 +14,7 @@ const initialState = {
},
NetworkController: {
providerConfig: {
type: ROPSTEN,
type: SEPOLIA,
},
},
TokensController: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ const createStyles = (colors) =>
});

const allNetworks = getAllNetworks();
const allNetworksblockExplorerUrl = `https://api.infura.io/v1/jsonrpc/`;
const allNetworksblockExplorerUrl = (networkName) =>
`https://${networkName}.infura.io/v3/`;
/**
* Main view for app configurations
*/
Expand Down Expand Up @@ -319,7 +320,7 @@ class NetworkSettings extends PureComponent {
nickname = networkInformation.name;
chainId = networkInformation.chainId.toString();
editable = false;
rpcUrl = allNetworksblockExplorerUrl + network;
rpcUrl = allNetworksblockExplorerUrl(network);
ticker = strings('unit.eth');
// Override values if UI is updating custom mainnet RPC URL.
if (isCustomMainnet) {
Expand Down
8 changes: 4 additions & 4 deletions app/components/Views/Settings/NetworksSettings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class NetworksSettings extends PureComponent {

onActionSheetPress = (index) => (index === 0 ? this.removeNetwork() : null);

networkElement(name, image, i, network, isCustomRPC) {
networkElement(name, image, i, network, isCustomRPC, color) {
const colors = this.context.colors || mockTheme.colors;
const styles = createStyles(colors);
return (
Expand Down Expand Up @@ -242,7 +242,7 @@ class NetworksSettings extends PureComponent {
/>
) : (
<View
style={[styles.networkIcon, { backgroundColor: image }]}
style={[styles.networkIcon, { backgroundColor: color }]}
>
<Text style={styles.text}>{name[0]}</Text>
</View>
Expand All @@ -266,8 +266,8 @@ class NetworksSettings extends PureComponent {

renderOtherNetworks() {
return this.getOtherNetworks().map((network, i) => {
const { color, name } = Networks[network];
return this.networkElement(name, color, i, network, false);
const { name, imageSource, color } = Networks[network];
return this.networkElement(name, imageSource, i, network, false, color);
});
}

Expand Down
Loading