1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-11-15 01:34:57 +01:00

fix compute previous order

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>
This commit is contained in:
mihaisc 2020-10-23 18:33:39 +03:00
parent 8635236d02
commit ec28ef546c
No known key found for this signature in database
GPG Key ID: 4FB0C2329B4C6E29
3 changed files with 6 additions and 5 deletions

View File

@ -58,7 +58,7 @@ export default function Compute({
useEffect(() => { useEffect(() => {
async function checkPreviousOrders() { async function checkPreviousOrders() {
const orderId = await checkPreviousOrder(ocean, accountId, ddo) const orderId = await checkPreviousOrder(ocean, accountId, ddo, 'compute')
setPreviousOrderId(orderId) setPreviousOrderId(orderId)
setHasPreviousOrder(!!orderId) setHasPreviousOrder(!!orderId)
} }

View File

@ -44,7 +44,7 @@ export default function Consume({
useEffect(() => { useEffect(() => {
async function checkOrders() { async function checkOrders() {
const orderId = await checkPreviousOrder(ocean, accountId, ddo) const orderId = await checkPreviousOrder(ocean, accountId, ddo, 'access')
setPreviousOrderId(orderId) setPreviousOrderId(orderId)
setHasPreviousOrder(!!orderId) setHasPreviousOrder(!!orderId)
} }

View File

@ -1,11 +1,12 @@
import { DDO, Ocean } from '@oceanprotocol/lib' import { DDO, Ocean, ServiceType } from '@oceanprotocol/lib'
export default async function checkPreviousOrder( export default async function checkPreviousOrder(
ocean: Ocean, ocean: Ocean,
accountId: string, accountId: string,
ddo: DDO ddo: DDO,
serviceType: ServiceType
) { ) {
const service = ddo.findServiceByType('access') const service = ddo.findServiceByType(serviceType)
const previousOrder = await ocean.datatokens.getPreviousValidOrders( const previousOrder = await ocean.datatokens.getPreviousValidOrders(
ddo.dataToken, ddo.dataToken,
service.attributes.main.cost, service.attributes.main.cost,