mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Remove unused token cell methods and props (#8238)
The `network` prop was being passed to the Identicon despite that not being an Identicon prop, and the `userAddress` prop was being passed down by the container but was unused. The methods removed were not called anywhere.
This commit is contained in:
parent
2965eba1dd
commit
4328db78d7
@ -13,7 +13,6 @@ describe('Token Cell', function () {
|
|||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
metamask: {
|
metamask: {
|
||||||
network: 'test',
|
|
||||||
currentCurrency: 'usd',
|
currentCurrency: 'usd',
|
||||||
selectedTokenAddress: '0xToken',
|
selectedTokenAddress: '0xToken',
|
||||||
selectedAddress: '0xAddress',
|
selectedAddress: '0xAddress',
|
||||||
@ -40,7 +39,6 @@ describe('Token Cell', function () {
|
|||||||
address="0xAnotherToken"
|
address="0xAnotherToken"
|
||||||
symbol="TEST"
|
symbol="TEST"
|
||||||
string="5.000"
|
string="5.000"
|
||||||
network={22}
|
|
||||||
currentCurrency="usd"
|
currentCurrency="usd"
|
||||||
image="./test-image"
|
image="./test-image"
|
||||||
/>
|
/>
|
||||||
@ -50,7 +48,6 @@ describe('Token Cell', function () {
|
|||||||
|
|
||||||
it('renders Identicon with props from token cell', function () {
|
it('renders Identicon with props from token cell', function () {
|
||||||
assert.equal(wrapper.find(Identicon).prop('address'), '0xAnotherToken')
|
assert.equal(wrapper.find(Identicon).prop('address'), '0xAnotherToken')
|
||||||
assert.equal(wrapper.find(Identicon).prop('network'), 'test')
|
|
||||||
assert.equal(wrapper.find(Identicon).prop('image'), './test-image')
|
assert.equal(wrapper.find(Identicon).prop('image'), './test-image')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ import classnames from 'classnames'
|
|||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import Identicon from '../../ui/identicon'
|
import Identicon from '../../ui/identicon'
|
||||||
import prefixForNetwork from '../../../../lib/etherscan-prefix-for-network'
|
|
||||||
import { conversionUtil, multiplyCurrencies } from '../../../helpers/utils/conversion-util'
|
import { conversionUtil, multiplyCurrencies } from '../../../helpers/utils/conversion-util'
|
||||||
import TokenMenuDropdown from '../dropdowns/token-menu-dropdown.js'
|
import TokenMenuDropdown from '../dropdowns/token-menu-dropdown.js'
|
||||||
|
|
||||||
@ -15,7 +14,6 @@ export default class TokenCell extends Component {
|
|||||||
address: PropTypes.string,
|
address: PropTypes.string,
|
||||||
symbol: PropTypes.string,
|
symbol: PropTypes.string,
|
||||||
string: PropTypes.string,
|
string: PropTypes.string,
|
||||||
network: PropTypes.string,
|
|
||||||
setSelectedToken: PropTypes.func.isRequired,
|
setSelectedToken: PropTypes.func.isRequired,
|
||||||
selectedTokenAddress: PropTypes.string,
|
selectedTokenAddress: PropTypes.string,
|
||||||
contractExchangeRates: PropTypes.object,
|
contractExchangeRates: PropTypes.object,
|
||||||
@ -30,29 +28,12 @@ export default class TokenCell extends Component {
|
|||||||
tokenMenuOpen: false,
|
tokenMenuOpen: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
send (address, event) {
|
|
||||||
event.preventDefault()
|
|
||||||
event.stopPropagation()
|
|
||||||
const url = tokenFactoryFor(address)
|
|
||||||
if (url) {
|
|
||||||
navigateTo(url)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
view (address, userAddress, network) {
|
|
||||||
const url = etherscanLinkFor(address, userAddress, network)
|
|
||||||
if (url) {
|
|
||||||
navigateTo(url)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { tokenMenuOpen } = this.state
|
const { tokenMenuOpen } = this.state
|
||||||
const {
|
const {
|
||||||
address,
|
address,
|
||||||
symbol,
|
symbol,
|
||||||
string,
|
string,
|
||||||
network,
|
|
||||||
setSelectedToken,
|
setSelectedToken,
|
||||||
selectedTokenAddress,
|
selectedTokenAddress,
|
||||||
contractExchangeRates,
|
contractExchangeRates,
|
||||||
@ -106,7 +87,6 @@ export default class TokenCell extends Component {
|
|||||||
className="token-list-item__identicon"
|
className="token-list-item__identicon"
|
||||||
diameter={50}
|
diameter={50}
|
||||||
address={address}
|
address={address}
|
||||||
network={network}
|
|
||||||
image={image}
|
image={image}
|
||||||
/>
|
/>
|
||||||
<div className="token-list-item__balance-ellipsis">
|
<div className="token-list-item__balance-ellipsis">
|
||||||
@ -137,17 +117,3 @@ export default class TokenCell extends Component {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function navigateTo (url) {
|
|
||||||
global.platform.openWindow({ url })
|
|
||||||
}
|
|
||||||
|
|
||||||
function etherscanLinkFor (tokenAddress, address, network) {
|
|
||||||
const prefix = prefixForNetwork(network)
|
|
||||||
return `https://${prefix}etherscan.io/token/${tokenAddress}?a=${address}`
|
|
||||||
}
|
|
||||||
|
|
||||||
function tokenFactoryFor (tokenAddress) {
|
|
||||||
return `https://tokenfactory.surge.sh/#/token/${tokenAddress}`
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { setSelectedToken, hideSidebar } from '../../../store/actions'
|
import { setSelectedToken, hideSidebar } from '../../../store/actions'
|
||||||
import { getSelectedAddress } from '../../../selectors/selectors'
|
|
||||||
import TokenCell from './token-cell.component'
|
import TokenCell from './token-cell.component'
|
||||||
|
|
||||||
function mapStateToProps (state) {
|
function mapStateToProps (state) {
|
||||||
return {
|
return {
|
||||||
network: state.metamask.network,
|
|
||||||
currentCurrency: state.metamask.currentCurrency,
|
|
||||||
selectedTokenAddress: state.metamask.selectedTokenAddress,
|
|
||||||
userAddress: getSelectedAddress(state),
|
|
||||||
contractExchangeRates: state.metamask.contractExchangeRates,
|
contractExchangeRates: state.metamask.contractExchangeRates,
|
||||||
conversionRate: state.metamask.conversionRate,
|
conversionRate: state.metamask.conversionRate,
|
||||||
|
currentCurrency: state.metamask.currentCurrency,
|
||||||
|
selectedTokenAddress: state.metamask.selectedTokenAddress,
|
||||||
sidebarOpen: state.appState.sidebar.isOpen,
|
sidebarOpen: state.appState.sidebar.isOpen,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user