mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
add assets.order by index
This commit is contained in:
parent
61786ce532
commit
2deca53cc7
@ -347,6 +347,20 @@ export class Assets extends Instantiable {
|
|||||||
return service
|
return service
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getServiceByIndex(
|
||||||
|
did: string,
|
||||||
|
serviceIndex: number
|
||||||
|
): Promise<ServiceCommon> {
|
||||||
|
const services: ServiceCommon[] = (await this.resolve(did)).service
|
||||||
|
let service
|
||||||
|
services.forEach((serv) => {
|
||||||
|
if (serv.index === serviceIndex) {
|
||||||
|
service = serv
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return service
|
||||||
|
}
|
||||||
|
|
||||||
public async createAccessServiceAttributes(
|
public async createAccessServiceAttributes(
|
||||||
creator: Account,
|
creator: Account,
|
||||||
dtCost: number,
|
dtCost: number,
|
||||||
@ -372,12 +386,19 @@ export class Assets extends Instantiable {
|
|||||||
public async order(
|
public async order(
|
||||||
did: string,
|
did: string,
|
||||||
serviceType: string,
|
serviceType: string,
|
||||||
consumerAddress: string
|
consumerAddress: string,
|
||||||
|
serviceIndex: number = -1
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const service = await this.getServiceByType(did, serviceType)
|
if (serviceIndex === -1) {
|
||||||
|
const service = await this.getServiceByType(did, serviceType)
|
||||||
|
serviceIndex = service.index
|
||||||
|
} else {
|
||||||
|
const service = await this.getServiceByIndex(did, serviceIndex)
|
||||||
|
serviceType = service.type
|
||||||
|
}
|
||||||
return await this.ocean.provider.initialize(
|
return await this.ocean.provider.initialize(
|
||||||
did,
|
did,
|
||||||
service.index,
|
serviceIndex,
|
||||||
serviceType,
|
serviceType,
|
||||||
consumerAddress
|
consumerAddress
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user