mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-02 14:15:06 +01:00
8dddf48904
Update changelog file
56 lines
1.5 KiB
JavaScript
56 lines
1.5 KiB
JavaScript
import React, { Component } from 'react'
|
|
import PropTypes from 'prop-types'
|
|
import copyToClipboard from 'copy-to-clipboard'
|
|
import { addressSlicer, checksumAddress } from '../../util'
|
|
|
|
const Tooltip = require('../tooltip-v2.js').default
|
|
|
|
class SelectedAccount extends Component {
|
|
state = {
|
|
copied: false,
|
|
}
|
|
|
|
static contextTypes = {
|
|
t: PropTypes.func,
|
|
}
|
|
|
|
static propTypes = {
|
|
selectedAddress: PropTypes.string,
|
|
selectedIdentity: PropTypes.object,
|
|
network: PropTypes.string,
|
|
}
|
|
|
|
render () {
|
|
const { t } = this.context
|
|
const { selectedAddress, selectedIdentity, network } = this.props
|
|
const checksummedAddress = checksumAddress(selectedAddress, network)
|
|
|
|
return (
|
|
<div className="selected-account">
|
|
<Tooltip
|
|
position="bottom"
|
|
title={this.state.copied ? t('copiedExclamation') : t('copyToClipboard')}
|
|
>
|
|
<div
|
|
className="selected-account__clickable"
|
|
onClick={() => {
|
|
this.setState({ copied: true })
|
|
setTimeout(() => this.setState({ copied: false }), 3000)
|
|
copyToClipboard(checksummedAddress)
|
|
}}
|
|
>
|
|
<div className="selected-account__name">
|
|
{ selectedIdentity.name }
|
|
</div>
|
|
<div className="selected-account__address">
|
|
{ addressSlicer(checksummedAddress) }
|
|
</div>
|
|
</div>
|
|
</Tooltip>
|
|
</div>
|
|
)
|
|
}
|
|
}
|
|
|
|
export default SelectedAccount
|