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 { fetchDataForMultipleChains } from '../../../utils/subgraph'
|
||||||
import { useSiteMetadata } from '../../../hooks/useSiteMetadata'
|
import { useSiteMetadata } from '../../../hooks/useSiteMetadata'
|
||||||
import NetworkName from '../../atoms/NetworkName'
|
import NetworkName from '../../atoms/NetworkName'
|
||||||
import { retrieveDDO } from '../../../utils/aquarius'
|
import { retrieveDDOListByDIDs } from '../../../utils/aquarius'
|
||||||
import axios, { CancelToken } from 'axios'
|
import axios, { CancelToken } from 'axios'
|
||||||
import Title from './Title'
|
import Title from './Title'
|
||||||
import styles from './index.module.css'
|
import styles from './index.module.css'
|
||||||
@ -164,19 +164,27 @@ export default function PoolTransactions({
|
|||||||
if (!data) return
|
if (!data) return
|
||||||
|
|
||||||
const poolTransactions: PoolTransaction[] = []
|
const poolTransactions: PoolTransaction[] = []
|
||||||
|
const didList: string[] = []
|
||||||
|
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
const { datatokenAddress } = data[i].poolAddress
|
const { datatokenAddress } = data[i].poolAddress
|
||||||
const did = web3.utils
|
const did = web3.utils
|
||||||
.toChecksumAddress(datatokenAddress)
|
.toChecksumAddress(datatokenAddress)
|
||||||
.replace('0x', 'did:op:')
|
.replace('0x', 'did:op:')
|
||||||
const ddo = await retrieveDDO(did, cancelToken)
|
didList.push(did)
|
||||||
ddo &&
|
}
|
||||||
poolTransactions.push({
|
if (didList.length === 0) return
|
||||||
...data[i],
|
const ddoList = await retrieveDDOListByDIDs(
|
||||||
networkId: ddo?.chainId,
|
didList,
|
||||||
ddo
|
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(
|
const sortedTransactions = poolTransactions.sort(
|
||||||
(a, b) => b.timestamp - a.timestamp
|
(a, b) => b.timestamp - a.timestamp
|
||||||
|
@ -243,6 +243,7 @@ export async function retrieveDDOListByDIDs(
|
|||||||
cancelToken: CancelToken
|
cancelToken: CancelToken
|
||||||
): Promise<DDO[]> {
|
): Promise<DDO[]> {
|
||||||
try {
|
try {
|
||||||
|
if (didList?.length === 0 || chainIds?.length === 0) return []
|
||||||
const orderedDDOListByDIDList: DDO[] = []
|
const orderedDDOListByDIDList: DDO[] = []
|
||||||
const query = {
|
const query = {
|
||||||
size: didList.length,
|
size: didList.length,
|
||||||
|
Loading…
Reference in New Issue
Block a user