2017-11-14 08:04:23 -08:00
|
|
|
const Component = require('react').Component
|
|
|
|
const h = require('react-hyperscript')
|
|
|
|
const inherits = require('util').inherits
|
|
|
|
const Identicon = require('./identicon')
|
2018-08-13 04:03:31 -07:00
|
|
|
const ethNetProps = require('eth-net-props')
|
2017-11-14 08:04:23 -08:00
|
|
|
|
|
|
|
module.exports = TokenCell
|
|
|
|
|
|
|
|
inherits(TokenCell, Component)
|
|
|
|
function TokenCell () {
|
|
|
|
Component.call(this)
|
|
|
|
}
|
|
|
|
|
|
|
|
TokenCell.prototype.render = function () {
|
|
|
|
const props = this.props
|
|
|
|
const { address, symbol, string, network, userAddress } = props
|
|
|
|
|
|
|
|
return (
|
|
|
|
h('li.token-cell', {
|
2018-07-27 09:54:23 -07:00
|
|
|
style: {
|
2018-07-26 13:45:52 -07:00
|
|
|
cursor: network === '1' ? 'pointer' : 'default',
|
|
|
|
borderBottom: props.isLastTokenCell ? 'none' : '1px solid #e2e2e2',
|
|
|
|
padding: '20px 0',
|
2018-08-07 08:41:50 -07:00
|
|
|
margin: '0 30px',
|
2018-07-26 13:45:52 -07:00
|
|
|
},
|
2017-11-14 08:04:23 -08:00
|
|
|
onClick: this.view.bind(this, address, userAddress, network),
|
|
|
|
}, [
|
|
|
|
|
|
|
|
h(Identicon, {
|
|
|
|
diameter: 50,
|
|
|
|
address,
|
|
|
|
network,
|
|
|
|
}),
|
|
|
|
|
2018-07-26 13:45:52 -07:00
|
|
|
h('h3', {
|
|
|
|
style: {
|
|
|
|
fontFamily: 'Nunito Bold',
|
|
|
|
fontSize: '14px',
|
2018-07-27 09:54:23 -07:00
|
|
|
},
|
2018-07-26 13:45:52 -07:00
|
|
|
}, `${string || 0} ${symbol}`),
|
2017-11-14 08:04:23 -08:00
|
|
|
|
|
|
|
h('span', { style: { flex: '1 0 auto' } }),
|
|
|
|
|
2018-08-01 08:57:48 -07:00
|
|
|
h('span.trash', {
|
2018-07-24 04:59:24 -07:00
|
|
|
style: { cursor: 'pointer' },
|
|
|
|
onClick: (event) => {
|
|
|
|
event.stopPropagation()
|
|
|
|
this.props.removeToken({ address, symbol, string, network, userAddress })
|
|
|
|
},
|
|
|
|
}, ''),
|
|
|
|
|
2017-11-14 08:04:23 -08:00
|
|
|
/*
|
|
|
|
h('button', {
|
|
|
|
onClick: this.send.bind(this, address),
|
|
|
|
}, 'SEND'),
|
|
|
|
*/
|
|
|
|
|
|
|
|
])
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
TokenCell.prototype.send = function (address, event) {
|
|
|
|
event.preventDefault()
|
|
|
|
event.stopPropagation()
|
|
|
|
const url = tokenFactoryFor(address)
|
|
|
|
if (url) {
|
|
|
|
navigateTo(url)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TokenCell.prototype.view = function (address, userAddress, network, event) {
|
2018-08-13 04:03:31 -07:00
|
|
|
const url = ethNetProps.explorerLinks.getExplorerTokenLinkFor(address, userAddress, network)
|
2017-11-14 08:04:23 -08:00
|
|
|
if (url) {
|
|
|
|
navigateTo(url)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function navigateTo (url) {
|
|
|
|
global.platform.openWindow({ url })
|
|
|
|
}
|
|
|
|
|
|
|
|
function tokenFactoryFor (tokenAddress) {
|
|
|
|
return `https://tokenfactory.surge.sh/#/token/${tokenAddress}`
|
|
|
|
}
|
|
|
|
|