mirror of
https://github.com/oceanprotocol/react.git
synced 2024-12-22 17:23:32 +01:00
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import React from 'react'
|
|
import { useOcean } from '@oceanprotocol/react'
|
|
import { DDO } from '@oceanprotocol/lib'
|
|
import { useState } from 'react'
|
|
import { useEffect } from 'react'
|
|
import shortid from 'shortid'
|
|
import { MetadataExample } from './MetadataExample'
|
|
|
|
export function AllDdos() {
|
|
const { networkId, account, accountId, ocean } = useOcean()
|
|
|
|
const [ddos, setDdos] = useState<DDO[]>()
|
|
|
|
useEffect(() => {
|
|
async function init() {
|
|
if (!ocean || !accountId || !accountId) return
|
|
|
|
//const assets = await ocean.assets.ownerAssets(accountId)
|
|
const assets = await ocean.assets.query({
|
|
page: 1,
|
|
offset: 10,
|
|
query: {},
|
|
sort: { created: -1 }
|
|
})
|
|
console.log('assets', assets.results)
|
|
setDdos(assets.results.slice(0, 4))
|
|
}
|
|
init()
|
|
}, [ocean, account, networkId, accountId])
|
|
|
|
return (
|
|
<>
|
|
<div>Assets</div> <br />
|
|
<div style={{ flexDirection: 'column' }}>
|
|
{ddos?.map((ddo) => {
|
|
return (
|
|
<div key={shortid.generate()}>
|
|
<MetadataExample ddo={ddo} />
|
|
<br />
|
|
</div>
|
|
)
|
|
})}
|
|
</div>
|
|
</>
|
|
)
|
|
}
|