mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
refactor for new data structure
This commit is contained in:
parent
d476259d7f
commit
f9735d689d
@ -1,46 +1,47 @@
|
|||||||
import {
|
import { PoolTransaction } from '@oceanprotocol/lib/dist/node/balancer/OceanPool'
|
||||||
PoolAction,
|
|
||||||
PoolLogs
|
|
||||||
} from '@oceanprotocol/lib/dist/node/balancer/OceanPool'
|
|
||||||
import { useOcean } from '@oceanprotocol/react'
|
import { useOcean } from '@oceanprotocol/react'
|
||||||
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'
|
||||||
|
|
||||||
const data: PoolLogs = {
|
const data: PoolTransaction[] = [
|
||||||
joins: [
|
{
|
||||||
{
|
poolAddress: '0xxxxx',
|
||||||
poolAddress: '0xxxxx',
|
dtAddress: '0xxxxx',
|
||||||
caller: '',
|
caller: '0xxxxx',
|
||||||
transactionHash: '0xxxxx',
|
transactionHash: '0xxxxx',
|
||||||
blockNumber: 2,
|
blockNumber: 2,
|
||||||
tokenIn: 'OCEAN',
|
timestamp: 1,
|
||||||
tokenAmountIn: '10'
|
tokenIn: 'OCEAN',
|
||||||
}
|
tokenAmountIn: '10',
|
||||||
],
|
type: 'join'
|
||||||
exits: [],
|
}
|
||||||
swaps: []
|
]
|
||||||
}
|
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
name: 'Title',
|
name: 'Title',
|
||||||
selector: (row: PoolAction) => `Add ${row.tokenAmountIn} ${row.tokenIn}`
|
selector: (row: PoolTransaction) =>
|
||||||
|
`Add ${row.tokenAmountIn} ${row.tokenIn}`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Pool',
|
name: 'Pool',
|
||||||
selector: 'poolAddress'
|
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<PoolLogs>()
|
const [logs, setLogs] = useState<PoolTransaction[]>()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function getLogs() {
|
async function getLogs() {
|
||||||
if (!ocean || !accountId) return
|
if (!ocean || !accountId) return
|
||||||
|
|
||||||
const logs = await ocean.pool.getAllPoolLogs(accountId, true, true, true)
|
const logs = await ocean.pool.getAllPoolLogs(accountId)
|
||||||
setLogs(logs)
|
setLogs(logs)
|
||||||
}
|
}
|
||||||
getLogs()
|
getLogs()
|
||||||
@ -48,7 +49,7 @@ export default function PoolTransactions(): ReactElement {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<DataTable columns={columns} data={data.joins} />
|
<DataTable columns={columns} data={data} />
|
||||||
<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