mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
compute and display checksummed hash in selected-account component (#5255)
This commit is contained in:
parent
cd28dbb1d5
commit
2f14f978e3
@ -1,7 +1,7 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import copyToClipboard from 'copy-to-clipboard'
|
import copyToClipboard from 'copy-to-clipboard'
|
||||||
import { addressSlicer } from '../../util'
|
import { addressSlicer, checksumAddress } from '../../util'
|
||||||
|
|
||||||
const Tooltip = require('../tooltip-v2.js').default
|
const Tooltip = require('../tooltip-v2.js').default
|
||||||
|
|
||||||
@ -22,6 +22,7 @@ class SelectedAccount extends Component {
|
|||||||
render () {
|
render () {
|
||||||
const { t } = this.context
|
const { t } = this.context
|
||||||
const { selectedAddress, selectedIdentity } = this.props
|
const { selectedAddress, selectedIdentity } = this.props
|
||||||
|
const checksummedAddress = checksumAddress(selectedAddress)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="selected-account">
|
<div className="selected-account">
|
||||||
@ -34,14 +35,14 @@ class SelectedAccount extends Component {
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
this.setState({ copied: true })
|
this.setState({ copied: true })
|
||||||
setTimeout(() => this.setState({ copied: false }), 3000)
|
setTimeout(() => this.setState({ copied: false }), 3000)
|
||||||
copyToClipboard(selectedAddress)
|
copyToClipboard(checksummedAddress)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className="selected-account__name">
|
<div className="selected-account__name">
|
||||||
{ selectedIdentity.name }
|
{ selectedIdentity.name }
|
||||||
</div>
|
</div>
|
||||||
<div className="selected-account__address">
|
<div className="selected-account__address">
|
||||||
{ addressSlicer(selectedAddress) }
|
{ addressSlicer(checksummedAddress) }
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import assert from 'assert'
|
||||||
|
import { render } from 'enzyme'
|
||||||
|
import SelectedAccount from '../selected-account.component'
|
||||||
|
|
||||||
|
describe('SelectedAccount Component', () => {
|
||||||
|
it('should render checksummed address', () => {
|
||||||
|
const wrapper = render(<SelectedAccount
|
||||||
|
selectedAddress="0x1b82543566f41a7db9a9a75fc933c340ffb55c9d"
|
||||||
|
selectedIdentity={{ name: 'testName' }}
|
||||||
|
/>, { context: { t: () => {}}})
|
||||||
|
// Checksummed version of address is displayed
|
||||||
|
assert.equal(wrapper.find('.selected-account__address').text(), '0x1B82...5C9D')
|
||||||
|
assert.equal(wrapper.find('.selected-account__name').text(), 'testName')
|
||||||
|
})
|
||||||
|
})
|
Loading…
x
Reference in New Issue
Block a user