1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-11-15 01:34:57 +01:00
This commit is contained in:
Matthias Kretschmann 2020-09-30 18:38:36 +02:00
parent fcc8bc2896
commit 9911c458a7
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -7,67 +7,63 @@ import EtherscanLink from '../../atoms/EtherscanLink'
import Time from '../../atoms/Time'
import styles from './PoolTransactions.module.css'
const columns = [
{
name: 'Title',
selector: function getTitleRow(row: PoolTransaction) {
// TODO: replace hardcoded symbol with symbol fetching based
// on row.tonenIn & row.tokenOut
const title = row.tokenAmountIn
? `Add ${row.tokenAmountIn} OCEAN`
: `Remove ${row.tokenAmountOut} OCEAN`
return (
<EtherscanLink network="rinkeby" path={`/tx/${row.transactionHash}`}>
{title}
</EtherscanLink>
)
}
},
{
name: 'Asset',
selector: function getAssetRow(row: PoolTransaction) {
const did = row.dtAddress.replace('0x', 'did:op:')
return <Link to={`/asset/${did}`}>{did}</Link>
}
},
{
name: 'Time',
selector: function getTimeRow(row: PoolTransaction) {
return (
<Time date={new Date(row.timestamp * 1000).toUTCString()} relative />
)
}
}
]
export default function PoolTransactions(): ReactElement {
const { ocean, accountId } = useOcean()
const [logs, setLogs] = useState<PoolTransaction[]>()
const columns = [
{
name: 'Title',
selector: function getTitleRow(row: PoolTransaction) {
// TODO: replace hardcoded symbol with symbol fetching based
// on row.tonenIn & row.tokenOut
const title = row.tokenAmountIn
? `Add ${row.tokenAmountIn} OCEAN`
: `Remove ${row.tokenAmountOut} OCEAN`
return (
<EtherscanLink network="rinkeby" path={`/tx/${row.transactionHash}`}>
{title}
</EtherscanLink>
)
}
},
{
name: 'Asset',
selector: function getAssetRow(row: PoolTransaction) {
const did = row.dtAddress.replace('0x', 'did:op:')
return <Link to={`/asset/${did}`}>{did}</Link>
}
},
{
name: 'Time',
selector: function getTimeRow(row: PoolTransaction) {
return (
<Time date={new Date(row.timestamp * 1000).toUTCString()} relative />
)
}
}
]
useEffect(() => {
async function getLogs() {
if (!ocean || !accountId) return
const logs = await ocean.pool.getAllPoolLogs(
'0xe08A1dAe983BC701D05E492DB80e0144f8f4b909'
)
// limit to 20 latest transactions for now
setLogs(logs.slice(0, 19))
const logs = await ocean.pool.getAllPoolLogs(accountId)
// limit to 100 latest transactions for now
setLogs(logs.slice(0, 99))
}
getLogs()
}, [ocean, accountId])
return (
<div>
<DataTable
columns={columns}
data={logs}
className={styles.table}
noHeader
pagination
/>
</div>
<DataTable
columns={columns}
data={logs}
className={styles.table}
noHeader
pagination
/>
)
}