Skip to content

Commit

Permalink
jsdocs updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kremalicious committed Oct 12, 2020
1 parent ede62ee commit f086d59
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 27 deletions.
45 changes: 19 additions & 26 deletions src/ocean/Assets.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import { SearchQuery, QueryResult } from '../metadatastore/MetadataStore'
import { DDO } from '../ddo/DDO'
import { Metadata } from '../ddo/interfaces/Metadata'
import {
Service,
ServiceAccess,
ServiceComputePrivacy,
ServiceCommon
} from '../ddo/interfaces/Service'

import { Service, ServiceAccess, ServiceComputePrivacy } from '../ddo/interfaces/Service'
import { EditableMetadata } from '../ddo/interfaces/EditableMetadata'
import Account from './Account'
import DID from './DID'
Expand All @@ -17,6 +11,7 @@ import { WebServiceConnector } from './utils/WebServiceConnector'
import BigNumber from 'bignumber.js'
import { Provider } from '../provider/Provider'
import { isAddress } from 'web3-utils'
import { MetadataMain } from '../ddo/interfaces'

export enum CreateProgressStep {
CreatingDataToken,
Expand Down Expand Up @@ -124,7 +119,8 @@ export class Assets extends Instantiable {

this.logger.log('Encrypting files')
observer.next(CreateProgressStep.EncryptingFiles)
let provider
let provider: Provider

if (providerUri) {
provider = new Provider(this.instanceConfig)
provider.setBaseUrl(providerUri)
Expand Down Expand Up @@ -175,7 +171,7 @@ export class Assets extends Instantiable {
index,
url: undefined
}))
} as any
} as MetadataMain
}
},
...services
Expand Down Expand Up @@ -263,7 +259,8 @@ export class Assets extends Instantiable {
account: Account
): Promise<DDO> {
const oldDdo = await this.ocean.metadatastore.retrieveDDO(did)
let i
let i: number

for (i = 0; i < oldDdo.service.length; i++) {
if (oldDdo.service[i].type === 'metadata') {
if (newMetadata.title) oldDdo.service[i].attributes.main.name = newMetadata.title
Expand Down Expand Up @@ -375,12 +372,10 @@ export class Assets extends Instantiable {
} as SearchQuery)
}

public async getServiceByType(
did: string,
serviceType: string
): Promise<ServiceCommon> {
const services: ServiceCommon[] = (await this.resolve(did)).service
let service
public async getServiceByType(did: string, serviceType: string): Promise<Service> {
let service: Service
const services: Service[] = (await this.resolve(did)).service

services.forEach((serv) => {
if (serv.type.toString() === serviceType) {
service = serv
Expand All @@ -389,12 +384,10 @@ export class Assets extends Instantiable {
return service
}

public async getServiceByIndex(
did: string,
serviceIndex: number
): Promise<ServiceCommon> {
const services: ServiceCommon[] = (await this.resolve(did)).service
let service
public async getServiceByIndex(did: string, serviceIndex: number): Promise<Service> {
let service: Service
const services: Service[] = (await this.resolve(did)).service

services.forEach((serv) => {
if (serv.index === serviceIndex) {
service = serv
Expand Down Expand Up @@ -441,8 +434,7 @@ export class Assets extends Instantiable {
* @param {String} serviceType
* @param {String} consumerAddress
* @param {Number} serviceIndex
* @param {String} mpFeePercent will be converted to Wei
* @param {String} mpAddress mp fee collector address
* @param {String} serviceEndpoint
* @return {Promise<any>} Order details
*/
public async initialize(
Expand All @@ -466,7 +458,7 @@ export class Assets extends Instantiable {
* @param {String} serviceType
* @param {String} payerAddress
* @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
* @return {Promise<String>} transactionHash of the payment
*/
Expand All @@ -478,7 +470,8 @@ export class Assets extends Instantiable {
mpAddress?: string,
consumerAddress?: string
): Promise<string> {
let service
let service: Service

if (!consumerAddress) consumerAddress = payerAddress
if (serviceIndex === -1) {
service = await this.getServiceByType(did, serviceType)
Expand Down
4 changes: 3 additions & 1 deletion src/provider/Provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Output } from '../ocean/interfaces/ComputeOutput'
import { MetadataAlgorithm } from '../ddo/interfaces/MetadataAlgorithm'
import { Versions } from '../ocean/Versions'
import { Response } from 'node-fetch'
import { DDO } from '../ddo/DDO'

const apiPath = '/api/v1/services'

Expand Down Expand Up @@ -101,7 +102,8 @@ export class Provider extends Instantiable {
serviceType: string,
consumerAddress: string
): Promise<string> {
let DDO
let DDO: DDO

try {
DDO = await this.ocean.assets.resolve(did)
} catch (e) {
Expand Down

0 comments on commit f086d59

Please sign in to comment.