import React, { Component } from 'react' import PropTypes from 'prop-types' import copyToClipboard from 'copy-to-clipboard' const Tooltip = require('../tooltip-v2.js') const addressStripper = (address = '') => { if (address.length < 11) { return address } return `${address.slice(0, 6)}...${address.slice(-4)}` } class SelectedAccount extends Component { state = { copied: false, } static contextTypes = { t: PropTypes.func, } static propTypes = { selectedAddress: PropTypes.string, selectedIdentity: PropTypes.object, } render () { const { t } = this.context const { selectedAddress, selectedIdentity } = this.props return (
{ this.setState({ copied: true }) setTimeout(() => this.setState({ copied: false }), 3000) copyToClipboard(selectedAddress) }} >
{ selectedIdentity.name }
{ addressStripper(selectedAddress) }
) } } export default SelectedAccount