mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
Merge pull request #129 from oceanprotocol/fix/computePreviousOrder
fix compute previous order
This commit is contained in:
commit
ea41505c7d
@ -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)
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
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)
|
||||||
|
// apparenlty cost and timeout are not found, even though they are there...
|
||||||
const previousOrder = await ocean.datatokens.getPreviousValidOrders(
|
const previousOrder = await ocean.datatokens.getPreviousValidOrders(
|
||||||
ddo.dataToken,
|
ddo.dataToken,
|
||||||
service.attributes.main.cost,
|
(service.attributes.main as any).cost,
|
||||||
service.index,
|
service.index,
|
||||||
service.attributes.main.timeout,
|
(service.attributes.main as any).timeout,
|
||||||
accountId
|
accountId
|
||||||
)
|
)
|
||||||
return previousOrder
|
return previousOrder
|
||||||
|
Loading…
x
Reference in New Issue
Block a user