import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import Button from '../../ui/button'; import LoadingScreen from '../../ui/loading-screen'; import { SECOND } from '../../../../shared/constants/time'; import { NETWORK_TYPES } from '../../../../shared/constants/network'; export default class LoadingNetworkScreen extends PureComponent { state = { showErrorScreen: false, }; static contextTypes = { t: PropTypes.func, }; static propTypes = { loadingMessage: PropTypes.string, cancelTime: PropTypes.number, provider: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), providerId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), showNetworkDropdown: PropTypes.func, setProviderArgs: PropTypes.array, setProviderType: PropTypes.func, rollbackToPreviousProvider: PropTypes.func, isNetworkLoading: PropTypes.bool, }; componentDidMount = () => { this.cancelCallTimeout = setTimeout( this.cancelCall, this.props.cancelTime || SECOND * 15, ); }; getConnectingLabel = function (loadingMessage) { if (loadingMessage) { return loadingMessage; } const { provider, providerId } = this.props; const providerName = provider.type; const { t } = this.context; switch (providerName) { case NETWORK_TYPES.MAINNET: return t('connectingToMainnet'); case NETWORK_TYPES.ROPSTEN: return t('connectingToRopsten'); case NETWORK_TYPES.KOVAN: return t('connectingToKovan'); case NETWORK_TYPES.RINKEBY: return t('connectingToRinkeby'); case NETWORK_TYPES.GOERLI: return t('connectingToGoerli'); case NETWORK_TYPES.SEPOLIA: return t('connectingToSepolia'); default: return t('connectingTo', [providerId]); } }; renderErrorScreenContent = () => { const { showNetworkDropdown, setProviderArgs, setProviderType } = this.props; return (