mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
Improve Pool Transactions page data fetching (#902)
* use elastic search to get all ddo's at once * fix get ddo's list function and get names in one query * reorder ddo list based on did list order * remove inPurgatory filter * fix broken aquarius query * remove getAssetsFromDidList function and use retrieveDDOListByDIDs * fetch list of ddos * use RegExp * fix broken query on empty did or chainId list
This commit is contained in:
parent
4d232e4b8c
commit
ef70d97ad3
@ -9,7 +9,7 @@ import web3 from 'web3'
|
||||
import { fetchDataForMultipleChains } from '../../../utils/subgraph'
|
||||
import { useSiteMetadata } from '../../../hooks/useSiteMetadata'
|
||||
import NetworkName from '../../atoms/NetworkName'
|
||||
import { retrieveDDO } from '../../../utils/aquarius'
|
||||
import { retrieveDDOListByDIDs } from '../../../utils/aquarius'
|
||||
import axios, { CancelToken } from 'axios'
|
||||
import Title from './Title'
|
||||
import styles from './index.module.css'
|
||||
@ -164,19 +164,27 @@ export default function PoolTransactions({
|
||||
if (!data) return
|
||||
|
||||
const poolTransactions: PoolTransaction[] = []
|
||||
const didList: string[] = []
|
||||
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const { datatokenAddress } = data[i].poolAddress
|
||||
const did = web3.utils
|
||||
.toChecksumAddress(datatokenAddress)
|
||||
.replace('0x', 'did:op:')
|
||||
const ddo = await retrieveDDO(did, cancelToken)
|
||||
ddo &&
|
||||
poolTransactions.push({
|
||||
...data[i],
|
||||
networkId: ddo?.chainId,
|
||||
ddo
|
||||
})
|
||||
didList.push(did)
|
||||
}
|
||||
if (didList.length === 0) return
|
||||
const ddoList = await retrieveDDOListByDIDs(
|
||||
didList,
|
||||
chainIds,
|
||||
cancelToken
|
||||
)
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
poolTransactions.push({
|
||||
...data[i],
|
||||
networkId: ddoList[i]?.chainId,
|
||||
ddo: ddoList[i]
|
||||
})
|
||||
}
|
||||
const sortedTransactions = poolTransactions.sort(
|
||||
(a, b) => b.timestamp - a.timestamp
|
||||
|
@ -243,6 +243,7 @@ export async function retrieveDDOListByDIDs(
|
||||
cancelToken: CancelToken
|
||||
): Promise<DDO[]> {
|
||||
try {
|
||||
if (didList?.length === 0 || chainIds?.length === 0) return []
|
||||
const orderedDDOListByDIDList: DDO[] = []
|
||||
const query = {
|
||||
size: didList.length,
|
||||
|
Loading…
Reference in New Issue
Block a user