diff --git a/src/components/organisms/AssetActions/Compute.tsx b/src/components/organisms/AssetActions/Compute.tsx index e10841ac0..0394c62f4 100644 --- a/src/components/organisms/AssetActions/Compute.tsx +++ b/src/components/organisms/AssetActions/Compute.tsx @@ -58,7 +58,7 @@ export default function Compute({ useEffect(() => { async function checkPreviousOrders() { - const orderId = await checkPreviousOrder(ocean, accountId, ddo) + const orderId = await checkPreviousOrder(ocean, accountId, ddo, 'compute') setPreviousOrderId(orderId) setHasPreviousOrder(!!orderId) } diff --git a/src/components/organisms/AssetActions/Consume.tsx b/src/components/organisms/AssetActions/Consume.tsx index 420a46b65..60cf2a225 100644 --- a/src/components/organisms/AssetActions/Consume.tsx +++ b/src/components/organisms/AssetActions/Consume.tsx @@ -44,7 +44,7 @@ export default function Consume({ useEffect(() => { async function checkOrders() { - const orderId = await checkPreviousOrder(ocean, accountId, ddo) + const orderId = await checkPreviousOrder(ocean, accountId, ddo, 'access') setPreviousOrderId(orderId) setHasPreviousOrder(!!orderId) } diff --git a/src/utils/checkPreviousOrder.ts b/src/utils/checkPreviousOrder.ts index af27d7a97..a0e09314c 100644 --- a/src/utils/checkPreviousOrder.ts +++ b/src/utils/checkPreviousOrder.ts @@ -1,11 +1,12 @@ -import { DDO, Ocean } from '@oceanprotocol/lib' +import { DDO, Ocean, ServiceType } from '@oceanprotocol/lib' export default async function checkPreviousOrder( ocean: Ocean, accountId: string, - ddo: DDO + ddo: DDO, + serviceType: ServiceType ) { - const service = ddo.findServiceByType('access') + const service = ddo.findServiceByType(serviceType) const previousOrder = await ocean.datatokens.getPreviousValidOrders( ddo.dataToken, service.attributes.main.cost,