diff --git a/src/components/molecules/PoolTransactions/index.tsx b/src/components/molecules/PoolTransactions/index.tsx index 2ba87f53f..19068d829 100644 --- a/src/components/molecules/PoolTransactions/index.tsx +++ b/src/components/molecules/PoolTransactions/index.tsx @@ -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 diff --git a/src/utils/aquarius.ts b/src/utils/aquarius.ts index c2b739be6..af5c3cc3d 100644 --- a/src/utils/aquarius.ts +++ b/src/utils/aquarius.ts @@ -243,6 +243,7 @@ export async function retrieveDDOListByDIDs( cancelToken: CancelToken ): Promise { try { + if (didList?.length === 0 || chainIds?.length === 0) return [] const orderedDDOListByDIDList: DDO[] = [] const query = { size: didList.length,