mirror of
https://github.com/hanzoai/etherplate.git
synced 2026-10-30 18:37:10 +00:00
* added 'Ownable' concept for contract (the address who deploys the contract is the owner * clean up the getToken() info by collapsing the data from 2 calls into 1, which means only 1 call to the contract instead of 2 for each piece of data (would be huge if there were say 12 pieces of data, 1 `view` call instead of 12 to the contract
50 lines
1.1 KiB
React
50 lines
1.1 KiB
React
import React, {
|
|
Component
|
|
} from 'react'
|
|
import { Link } from 'react-router-dom'
|
|
import PropTypes from 'prop-types'
|
|
|
|
import getToken from '@/services/get-token'
|
|
import nfTokenTypeImageUrl from '@/services/nfToken-type-image-url'
|
|
|
|
const TokenRow = class extends Component {
|
|
constructor (props) {
|
|
super(props)
|
|
this.state = {}
|
|
}
|
|
|
|
componentDidMount () {
|
|
getToken(this.props.tokenId, window.web3).then((values) => {
|
|
this.setState({
|
|
type: values[0],
|
|
title: values[1]
|
|
})
|
|
}).catch((error) => {
|
|
console.error(error)
|
|
})
|
|
}
|
|
|
|
render () {
|
|
let tokenLinkUrl = `/tokens/${this.props.tokenId}`
|
|
|
|
return (
|
|
<tr className='token-row'>
|
|
<td>
|
|
<Link to={tokenLinkUrl}>
|
|
<img src={nfTokenTypeImageUrl(this.state.type, 'small')} className='token-row__token-img' />
|
|
</Link>
|
|
</td>
|
|
<td>
|
|
<Link to={tokenLinkUrl}>{this.state.title}</Link>
|
|
</td>
|
|
</tr>
|
|
)
|
|
}
|
|
}
|
|
|
|
TokenRow.propTypes = {
|
|
tokenId: PropTypes.number.isRequired
|
|
}
|
|
|
|
export default TokenRow;
|