mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Using NETWORK_TYPES constants where applicable (Refactor) (#15930)
This commit is contained in:
parent
da0e2f92b9
commit
2623fedd16
@ -212,28 +212,26 @@ class NetworkDropdown extends Component {
|
|||||||
getNetworkName() {
|
getNetworkName() {
|
||||||
const { provider } = this.props;
|
const { provider } = this.props;
|
||||||
const providerName = provider.type;
|
const providerName = provider.type;
|
||||||
|
const { t } = this.context;
|
||||||
|
|
||||||
let name;
|
switch (providerName) {
|
||||||
|
case NETWORK_TYPES.MAINNET:
|
||||||
if (providerName === 'mainnet') {
|
return t('mainnet');
|
||||||
name = this.context.t('mainnet');
|
case NETWORK_TYPES.ROPSTEN:
|
||||||
} else if (providerName === 'ropsten') {
|
return t('ropsten');
|
||||||
name = this.context.t('ropsten');
|
case NETWORK_TYPES.KOVAN:
|
||||||
} else if (providerName === 'kovan') {
|
return t('kovan');
|
||||||
name = this.context.t('kovan');
|
case NETWORK_TYPES.RINKEBY:
|
||||||
} else if (providerName === 'rinkeby') {
|
return t('rinkeby');
|
||||||
name = this.context.t('rinkeby');
|
case NETWORK_TYPES.GOERLI:
|
||||||
} else if (providerName === 'goerli') {
|
return t('goerli');
|
||||||
name = this.context.t('goerli');
|
case NETWORK_TYPES.SEPOLIA:
|
||||||
} else if (providerName === 'sepolia') {
|
return t('sepolia');
|
||||||
name = this.context.t('sepolia');
|
case NETWORK_TYPES.LOCALHOST:
|
||||||
} else if (providerName === 'localhost') {
|
return t('localhost');
|
||||||
name = this.context.t('localhost');
|
default:
|
||||||
} else {
|
return provider.nickname || t('unknownNetwork');
|
||||||
name = provider.nickname || this.context.t('unknownNetwork');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
renderNetworkEntry(network) {
|
renderNetworkEntry(network) {
|
||||||
@ -347,7 +345,7 @@ class NetworkDropdown extends Component {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="network-dropdown-list">
|
<div className="network-dropdown-list">
|
||||||
{this.renderNetworkEntry('mainnet')}
|
{this.renderNetworkEntry(NETWORK_TYPES.MAINNET)}
|
||||||
|
|
||||||
{this.renderCustomRpcList(
|
{this.renderCustomRpcList(
|
||||||
rpcListDetailWithoutLocalHost,
|
rpcListDetailWithoutLocalHost,
|
||||||
@ -356,11 +354,11 @@ class NetworkDropdown extends Component {
|
|||||||
|
|
||||||
{shouldShowTestNetworks && (
|
{shouldShowTestNetworks && (
|
||||||
<>
|
<>
|
||||||
{this.renderNetworkEntry('ropsten')}
|
{this.renderNetworkEntry(NETWORK_TYPES.ROPSTEN)}
|
||||||
{this.renderNetworkEntry('kovan')}
|
{this.renderNetworkEntry(NETWORK_TYPES.KOVAN)}
|
||||||
{this.renderNetworkEntry('rinkeby')}
|
{this.renderNetworkEntry(NETWORK_TYPES.RINKEBY)}
|
||||||
{this.renderNetworkEntry('goerli')}
|
{this.renderNetworkEntry(NETWORK_TYPES.GOERLI)}
|
||||||
{this.renderNetworkEntry('sepolia')}
|
{this.renderNetworkEntry(NETWORK_TYPES.SEPOLIA)}
|
||||||
{this.renderCustomRpcList(
|
{this.renderCustomRpcList(
|
||||||
rpcListDetailForLocalHost,
|
rpcListDetailForLocalHost,
|
||||||
this.props.provider,
|
this.props.provider,
|
||||||
|
@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
|
|||||||
import Button from '../../ui/button';
|
import Button from '../../ui/button';
|
||||||
import LoadingScreen from '../../ui/loading-screen';
|
import LoadingScreen from '../../ui/loading-screen';
|
||||||
import { SECOND } from '../../../../shared/constants/time';
|
import { SECOND } from '../../../../shared/constants/time';
|
||||||
|
import { NETWORK_TYPES } from '../../../../shared/constants/network';
|
||||||
|
|
||||||
export default class LoadingNetworkScreen extends PureComponent {
|
export default class LoadingNetworkScreen extends PureComponent {
|
||||||
state = {
|
state = {
|
||||||
@ -38,26 +39,24 @@ export default class LoadingNetworkScreen extends PureComponent {
|
|||||||
}
|
}
|
||||||
const { provider, providerId } = this.props;
|
const { provider, providerId } = this.props;
|
||||||
const providerName = provider.type;
|
const providerName = provider.type;
|
||||||
|
const { t } = this.context;
|
||||||
|
|
||||||
let name;
|
switch (providerName) {
|
||||||
|
case NETWORK_TYPES.MAINNET:
|
||||||
if (providerName === 'mainnet') {
|
return t('connectingToMainnet');
|
||||||
name = this.context.t('connectingToMainnet');
|
case NETWORK_TYPES.ROPSTEN:
|
||||||
} else if (providerName === 'ropsten') {
|
return t('connectingToRopsten');
|
||||||
name = this.context.t('connectingToRopsten');
|
case NETWORK_TYPES.KOVAN:
|
||||||
} else if (providerName === 'kovan') {
|
return t('connectingToKovan');
|
||||||
name = this.context.t('connectingToKovan');
|
case NETWORK_TYPES.RINKEBY:
|
||||||
} else if (providerName === 'rinkeby') {
|
return t('connectingToRinkeby');
|
||||||
name = this.context.t('connectingToRinkeby');
|
case NETWORK_TYPES.GOERLI:
|
||||||
} else if (providerName === 'goerli') {
|
return t('connectingToGoerli');
|
||||||
name = this.context.t('connectingToGoerli');
|
case NETWORK_TYPES.SEPOLIA:
|
||||||
} else if (providerName === 'sepolia') {
|
return t('connectingToSepolia');
|
||||||
name = this.context.t('connectingToSepolia');
|
default:
|
||||||
} else {
|
return t('connectingTo', [providerId]);
|
||||||
name = this.context.t('connectingTo', [providerId]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
renderErrorScreenContent = () => {
|
renderErrorScreenContent = () => {
|
||||||
|
@ -71,6 +71,7 @@ import {
|
|||||||
ENVIRONMENT_TYPE_NOTIFICATION,
|
ENVIRONMENT_TYPE_NOTIFICATION,
|
||||||
ENVIRONMENT_TYPE_POPUP,
|
ENVIRONMENT_TYPE_POPUP,
|
||||||
} from '../../../shared/constants/app';
|
} from '../../../shared/constants/app';
|
||||||
|
import { NETWORK_TYPES } from '../../../shared/constants/network';
|
||||||
import { getEnvironmentType } from '../../../app/scripts/lib/util';
|
import { getEnvironmentType } from '../../../app/scripts/lib/util';
|
||||||
import ConfirmationPage from '../confirmation';
|
import ConfirmationPage from '../confirmation';
|
||||||
import OnboardingFlow from '../onboarding-flow/onboarding-flow';
|
import OnboardingFlow from '../onboarding-flow/onboarding-flow';
|
||||||
@ -459,22 +460,23 @@ export default class Routes extends Component {
|
|||||||
return loadingMessage;
|
return loadingMessage;
|
||||||
}
|
}
|
||||||
const { providerType, providerId } = this.props;
|
const { providerType, providerId } = this.props;
|
||||||
|
const { t } = this.context;
|
||||||
|
|
||||||
switch (providerType) {
|
switch (providerType) {
|
||||||
case 'mainnet':
|
case NETWORK_TYPES.MAINNET:
|
||||||
return this.context.t('connectingToMainnet');
|
return t('connectingToMainnet');
|
||||||
case 'ropsten':
|
case NETWORK_TYPES.ROPSTEN:
|
||||||
return this.context.t('connectingToRopsten');
|
return t('connectingToRopsten');
|
||||||
case 'kovan':
|
case NETWORK_TYPES.KOVAN:
|
||||||
return this.context.t('connectingToKovan');
|
return t('connectingToKovan');
|
||||||
case 'rinkeby':
|
case NETWORK_TYPES.RINKEBY:
|
||||||
return this.context.t('connectingToRinkeby');
|
return t('connectingToRinkeby');
|
||||||
case 'goerli':
|
case NETWORK_TYPES.GOERLI:
|
||||||
return this.context.t('connectingToGoerli');
|
return t('connectingToGoerli');
|
||||||
case 'sepolia':
|
case NETWORK_TYPES.SEPOLIA:
|
||||||
return this.context.t('connectingToSepolia');
|
return t('connectingToSepolia');
|
||||||
default:
|
default:
|
||||||
return this.context.t('connectingTo', [providerId]);
|
return t('connectingTo', [providerId]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user