mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
add getService
This commit is contained in:
parent
2f5025a659
commit
d5b6bb3221
@ -1,7 +1,12 @@
|
|||||||
import { SearchQuery } from '../metadatastore/MetadataStore'
|
import { SearchQuery } from '../metadatastore/MetadataStore'
|
||||||
import { DDO } from '../ddo/DDO'
|
import { DDO } from '../ddo/DDO'
|
||||||
import { Metadata } from '../ddo/interfaces/Metadata'
|
import { Metadata } from '../ddo/interfaces/Metadata'
|
||||||
import { Service, ServiceAccess, ServiceComputePrivacy } from '../ddo/interfaces/Service'
|
import {
|
||||||
|
Service,
|
||||||
|
ServiceAccess,
|
||||||
|
ServiceComputePrivacy,
|
||||||
|
ServiceCommon
|
||||||
|
} from '../ddo/interfaces/Service'
|
||||||
import { EditableMetadata } from '../ddo/interfaces/EditableMetadata'
|
import { EditableMetadata } from '../ddo/interfaces/EditableMetadata'
|
||||||
import Account from './Account'
|
import Account from './Account'
|
||||||
import DID from './DID'
|
import DID from './DID'
|
||||||
@ -352,6 +357,17 @@ export class Assets extends Instantiable {
|
|||||||
} as SearchQuery)
|
} as SearchQuery)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getService(did: string, serviceType: string): Promise<ServiceCommon> {
|
||||||
|
const services: ServiceCommon[] = (await this.resolve(did)).service
|
||||||
|
let service
|
||||||
|
services.forEach((serv) => {
|
||||||
|
if (serv.type.toString() === serviceType) {
|
||||||
|
service = serv
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return service
|
||||||
|
}
|
||||||
|
|
||||||
public async createAccessServiceAttributes(
|
public async createAccessServiceAttributes(
|
||||||
creator: Account,
|
creator: Account,
|
||||||
dtCost: number,
|
dtCost: number,
|
||||||
|
@ -147,7 +147,9 @@ describe('Marketplace flow', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('Marketplace posts asset for sale', async () => {
|
it('Marketplace posts asset for sale', async () => {
|
||||||
// const downloadService = await ocean.assets.getService(ddo.id, 'download')
|
const accessService = await ocean.assets.getService(ddo.id, 'access')
|
||||||
|
const price = 20
|
||||||
|
assert(accessService.attributes.main.dtCost * price === 200)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Bob gets datatokens', async () => {
|
it('Bob gets datatokens', async () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user