mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
first data output in table
This commit is contained in:
parent
f9735d689d
commit
69c329ceb6
@ -1,42 +1,50 @@
|
|||||||
import { PoolTransaction } from '@oceanprotocol/lib/dist/node/balancer/OceanPool'
|
import { PoolTransaction } from '@oceanprotocol/lib/dist/node/balancer/OceanPool'
|
||||||
import { useOcean } from '@oceanprotocol/react'
|
import { useOcean } from '@oceanprotocol/react'
|
||||||
|
import { Link } from 'gatsby'
|
||||||
import React, { ReactElement, useEffect, useState } from 'react'
|
import React, { ReactElement, useEffect, useState } from 'react'
|
||||||
import DataTable from 'react-data-table-component'
|
import DataTable from 'react-data-table-component'
|
||||||
|
import EtherscanLink from '../../atoms/EtherscanLink'
|
||||||
const data: PoolTransaction[] = [
|
import Time from '../../atoms/Time'
|
||||||
{
|
|
||||||
poolAddress: '0xxxxx',
|
|
||||||
dtAddress: '0xxxxx',
|
|
||||||
caller: '0xxxxx',
|
|
||||||
transactionHash: '0xxxxx',
|
|
||||||
blockNumber: 2,
|
|
||||||
timestamp: 1,
|
|
||||||
tokenIn: 'OCEAN',
|
|
||||||
tokenAmountIn: '10',
|
|
||||||
type: 'join'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
const columns = [
|
|
||||||
{
|
|
||||||
name: 'Title',
|
|
||||||
selector: (row: PoolTransaction) =>
|
|
||||||
`Add ${row.tokenAmountIn} ${row.tokenIn}`
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Pool',
|
|
||||||
selector: 'poolAddress'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Account',
|
|
||||||
selector: 'caller'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
export default function PoolTransactions(): ReactElement {
|
export default function PoolTransactions(): ReactElement {
|
||||||
const { ocean, accountId } = useOcean()
|
const { ocean, accountId } = useOcean()
|
||||||
const [logs, setLogs] = useState<PoolTransaction[]>()
|
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(() => {
|
useEffect(() => {
|
||||||
async function getLogs() {
|
async function getLogs() {
|
||||||
if (!ocean || !accountId) return
|
if (!ocean || !accountId) return
|
||||||
@ -49,7 +57,7 @@ export default function PoolTransactions(): ReactElement {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<DataTable columns={columns} data={data} />
|
<DataTable columns={columns} data={logs} />
|
||||||
<pre>
|
<pre>
|
||||||
<code>{JSON.stringify(logs, null, 2)}</code>
|
<code>{JSON.stringify(logs, null, 2)}</code>
|
||||||
</pre>
|
</pre>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user