|
|
@ -1,21 +1,7 @@ |
|
|
|
import React, { Component } from 'react' |
|
|
|
import React, { Component } from 'react' |
|
|
|
import PropTypes from 'prop-types' |
|
|
|
import PropTypes from 'prop-types' |
|
|
|
import classnames from 'classnames' |
|
|
|
import classnames from 'classnames' |
|
|
|
import { |
|
|
|
import { NETWORK_TYPE_RPC } from '../../../../../shared/constants/network' |
|
|
|
MAINNET_NETWORK_ID, |
|
|
|
|
|
|
|
ROPSTEN_NETWORK_ID, |
|
|
|
|
|
|
|
RINKEBY_NETWORK_ID, |
|
|
|
|
|
|
|
KOVAN_NETWORK_ID, |
|
|
|
|
|
|
|
GOERLI_NETWORK_ID, |
|
|
|
|
|
|
|
} from '../../../../../shared/constants/network' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const networkIdToTypeMap = { |
|
|
|
|
|
|
|
[MAINNET_NETWORK_ID]: 'mainnet', |
|
|
|
|
|
|
|
[ROPSTEN_NETWORK_ID]: 'ropsten', |
|
|
|
|
|
|
|
[RINKEBY_NETWORK_ID]: 'rinkeby', |
|
|
|
|
|
|
|
[GOERLI_NETWORK_ID]: 'goerli', |
|
|
|
|
|
|
|
[KOVAN_NETWORK_ID]: 'kovan', |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default class NetworkDisplay extends Component { |
|
|
|
export default class NetworkDisplay extends Component { |
|
|
|
static defaultProps = { |
|
|
|
static defaultProps = { |
|
|
@ -23,9 +9,9 @@ export default class NetworkDisplay extends Component { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static propTypes = { |
|
|
|
static propTypes = { |
|
|
|
|
|
|
|
networkNickname: PropTypes.string.isRequired, |
|
|
|
|
|
|
|
networkType: PropTypes.string.isRequired, |
|
|
|
colored: PropTypes.bool, |
|
|
|
colored: PropTypes.bool, |
|
|
|
network: PropTypes.string, |
|
|
|
|
|
|
|
provider: PropTypes.object, |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static contextTypes = { |
|
|
|
static contextTypes = { |
|
|
@ -33,12 +19,11 @@ export default class NetworkDisplay extends Component { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
renderNetworkIcon() { |
|
|
|
renderNetworkIcon() { |
|
|
|
const { network } = this.props |
|
|
|
const { networkType } = this.props |
|
|
|
const networkClass = networkIdToTypeMap[network] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return networkClass ? ( |
|
|
|
return networkType ? ( |
|
|
|
<div |
|
|
|
<div |
|
|
|
className={`network-display__icon network-display__icon--${networkClass}`} |
|
|
|
className={`network-display__icon network-display__icon--${networkType}`} |
|
|
|
/> |
|
|
|
/> |
|
|
|
) : ( |
|
|
|
) : ( |
|
|
|
<div |
|
|
|
<div |
|
|
@ -52,24 +37,19 @@ export default class NetworkDisplay extends Component { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
render() { |
|
|
|
const { |
|
|
|
const { colored, networkNickname, networkType } = this.props |
|
|
|
colored, |
|
|
|
|
|
|
|
network, |
|
|
|
|
|
|
|
provider: { type, nickname }, |
|
|
|
|
|
|
|
} = this.props |
|
|
|
|
|
|
|
const networkClass = networkIdToTypeMap[network] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div |
|
|
|
<div |
|
|
|
className={classnames('network-display__container', { |
|
|
|
className={classnames('network-display__container', { |
|
|
|
'network-display__container--colored': colored, |
|
|
|
'network-display__container--colored': colored, |
|
|
|
[`network-display__container--${networkClass}`]: |
|
|
|
[`network-display__container--${networkType}`]: |
|
|
|
colored && networkClass, |
|
|
|
colored && networkType, |
|
|
|
})} |
|
|
|
})} |
|
|
|
> |
|
|
|
> |
|
|
|
{networkClass ? ( |
|
|
|
{networkType ? ( |
|
|
|
<div |
|
|
|
<div |
|
|
|
className={`network-display__icon network-display__icon--${networkClass}`} |
|
|
|
className={`network-display__icon network-display__icon--${networkType}`} |
|
|
|
/> |
|
|
|
/> |
|
|
|
) : ( |
|
|
|
) : ( |
|
|
|
<div |
|
|
|
<div |
|
|
@ -81,7 +61,9 @@ export default class NetworkDisplay extends Component { |
|
|
|
/> |
|
|
|
/> |
|
|
|
)} |
|
|
|
)} |
|
|
|
<div className="network-display__name"> |
|
|
|
<div className="network-display__name"> |
|
|
|
{type === 'rpc' && nickname ? nickname : this.context.t(type)} |
|
|
|
{networkType === NETWORK_TYPE_RPC && networkNickname |
|
|
|
|
|
|
|
? networkNickname |
|
|
|
|
|
|
|
: this.context.t(networkType)} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
) |
|
|
|
) |
|
|
|