mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
jsdocs updates
This commit is contained in:
parent
5c2cef618e
commit
195f6c311f
@ -1,13 +1,7 @@
|
|||||||
import { SearchQuery, QueryResult } from '../metadatastore/MetadataStore'
|
import { SearchQuery, QueryResult } 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 {
|
import { Service, ServiceAccess, ServiceComputePrivacy } from '../ddo/interfaces/Service'
|
||||||
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'
|
||||||
@ -17,6 +11,7 @@ import { WebServiceConnector } from './utils/WebServiceConnector'
|
|||||||
import BigNumber from 'bignumber.js'
|
import BigNumber from 'bignumber.js'
|
||||||
import { Provider } from '../provider/Provider'
|
import { Provider } from '../provider/Provider'
|
||||||
import { isAddress } from 'web3-utils'
|
import { isAddress } from 'web3-utils'
|
||||||
|
import { MetadataMain } from '../ddo/interfaces'
|
||||||
|
|
||||||
export enum CreateProgressStep {
|
export enum CreateProgressStep {
|
||||||
CreatingDataToken,
|
CreatingDataToken,
|
||||||
@ -124,7 +119,8 @@ export class Assets extends Instantiable {
|
|||||||
|
|
||||||
this.logger.log('Encrypting files')
|
this.logger.log('Encrypting files')
|
||||||
observer.next(CreateProgressStep.EncryptingFiles)
|
observer.next(CreateProgressStep.EncryptingFiles)
|
||||||
let provider
|
let provider: Provider
|
||||||
|
|
||||||
if (providerUri) {
|
if (providerUri) {
|
||||||
provider = new Provider(this.instanceConfig)
|
provider = new Provider(this.instanceConfig)
|
||||||
provider.setBaseUrl(providerUri)
|
provider.setBaseUrl(providerUri)
|
||||||
@ -175,7 +171,7 @@ export class Assets extends Instantiable {
|
|||||||
index,
|
index,
|
||||||
url: undefined
|
url: undefined
|
||||||
}))
|
}))
|
||||||
} as any
|
} as MetadataMain
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
...services
|
...services
|
||||||
@ -263,7 +259,8 @@ export class Assets extends Instantiable {
|
|||||||
account: Account
|
account: Account
|
||||||
): Promise<DDO> {
|
): Promise<DDO> {
|
||||||
const oldDdo = await this.ocean.metadatastore.retrieveDDO(did)
|
const oldDdo = await this.ocean.metadatastore.retrieveDDO(did)
|
||||||
let i
|
let i: number
|
||||||
|
|
||||||
for (i = 0; i < oldDdo.service.length; i++) {
|
for (i = 0; i < oldDdo.service.length; i++) {
|
||||||
if (oldDdo.service[i].type === 'metadata') {
|
if (oldDdo.service[i].type === 'metadata') {
|
||||||
if (newMetadata.title) oldDdo.service[i].attributes.main.name = newMetadata.title
|
if (newMetadata.title) oldDdo.service[i].attributes.main.name = newMetadata.title
|
||||||
@ -375,12 +372,10 @@ export class Assets extends Instantiable {
|
|||||||
} as SearchQuery)
|
} as SearchQuery)
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getServiceByType(
|
public async getServiceByType(did: string, serviceType: string): Promise<Service> {
|
||||||
did: string,
|
let service: Service
|
||||||
serviceType: string
|
const services: Service[] = (await this.resolve(did)).service
|
||||||
): Promise<ServiceCommon> {
|
|
||||||
const services: ServiceCommon[] = (await this.resolve(did)).service
|
|
||||||
let service
|
|
||||||
services.forEach((serv) => {
|
services.forEach((serv) => {
|
||||||
if (serv.type.toString() === serviceType) {
|
if (serv.type.toString() === serviceType) {
|
||||||
service = serv
|
service = serv
|
||||||
@ -389,12 +384,10 @@ export class Assets extends Instantiable {
|
|||||||
return service
|
return service
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getServiceByIndex(
|
public async getServiceByIndex(did: string, serviceIndex: number): Promise<Service> {
|
||||||
did: string,
|
let service: Service
|
||||||
serviceIndex: number
|
const services: Service[] = (await this.resolve(did)).service
|
||||||
): Promise<ServiceCommon> {
|
|
||||||
const services: ServiceCommon[] = (await this.resolve(did)).service
|
|
||||||
let service
|
|
||||||
services.forEach((serv) => {
|
services.forEach((serv) => {
|
||||||
if (serv.index === serviceIndex) {
|
if (serv.index === serviceIndex) {
|
||||||
service = serv
|
service = serv
|
||||||
@ -441,8 +434,7 @@ export class Assets extends Instantiable {
|
|||||||
* @param {String} serviceType
|
* @param {String} serviceType
|
||||||
* @param {String} consumerAddress
|
* @param {String} consumerAddress
|
||||||
* @param {Number} serviceIndex
|
* @param {Number} serviceIndex
|
||||||
* @param {String} mpFeePercent will be converted to Wei
|
* @param {String} serviceEndpoint
|
||||||
* @param {String} mpAddress mp fee collector address
|
|
||||||
* @return {Promise<any>} Order details
|
* @return {Promise<any>} Order details
|
||||||
*/
|
*/
|
||||||
public async initialize(
|
public async initialize(
|
||||||
@ -466,7 +458,7 @@ export class Assets extends Instantiable {
|
|||||||
* @param {String} serviceType
|
* @param {String} serviceType
|
||||||
* @param {String} payerAddress
|
* @param {String} payerAddress
|
||||||
* @param {Number} serviceIndex
|
* @param {Number} serviceIndex
|
||||||
* @param {String} mpAddress mp fee collector address
|
* @param {String} mpAddress Marketplace fee collector address
|
||||||
* @param {String} consumerAddress Optionally, if the consumer is another address than payer
|
* @param {String} consumerAddress Optionally, if the consumer is another address than payer
|
||||||
* @return {Promise<String>} transactionHash of the payment
|
* @return {Promise<String>} transactionHash of the payment
|
||||||
*/
|
*/
|
||||||
@ -478,7 +470,8 @@ export class Assets extends Instantiable {
|
|||||||
mpAddress?: string,
|
mpAddress?: string,
|
||||||
consumerAddress?: string
|
consumerAddress?: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let service
|
let service: Service
|
||||||
|
|
||||||
if (!consumerAddress) consumerAddress = payerAddress
|
if (!consumerAddress) consumerAddress = payerAddress
|
||||||
if (serviceIndex === -1) {
|
if (serviceIndex === -1) {
|
||||||
service = await this.getServiceByType(did, serviceType)
|
service = await this.getServiceByType(did, serviceType)
|
||||||
|
@ -7,6 +7,7 @@ import { Output } from '../ocean/interfaces/ComputeOutput'
|
|||||||
import { MetadataAlgorithm } from '../ddo/interfaces/MetadataAlgorithm'
|
import { MetadataAlgorithm } from '../ddo/interfaces/MetadataAlgorithm'
|
||||||
import { Versions } from '../ocean/Versions'
|
import { Versions } from '../ocean/Versions'
|
||||||
import { Response } from 'node-fetch'
|
import { Response } from 'node-fetch'
|
||||||
|
import { DDO } from '../ddo/DDO'
|
||||||
|
|
||||||
const apiPath = '/api/v1/services'
|
const apiPath = '/api/v1/services'
|
||||||
|
|
||||||
@ -101,7 +102,8 @@ export class Provider extends Instantiable {
|
|||||||
serviceType: string,
|
serviceType: string,
|
||||||
consumerAddress: string
|
consumerAddress: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let DDO
|
let DDO: DDO
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DDO = await this.ocean.assets.resolve(did)
|
DDO = await this.ocean.assets.resolve(did)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user