diff --git a/src/aquarius/Aquarius.ts b/src/aquarius/Aquarius.ts index a96b3211..8f1fe74e 100644 --- a/src/aquarius/Aquarius.ts +++ b/src/aquarius/Aquarius.ts @@ -1,7 +1,7 @@ import { URL } from 'whatwg-url' import { DDO } from '../ddo/DDO' import DID from '../ocean/DID' -import { EditableMetaData } from '../ddo/MetaData' +import { EditableMetadata } from '../ddo/interfaces/EditableMetadata' import { Logger } from '../utils' import { WebServiceConnector } from '../ocean/utils/WebServiceConnector' @@ -64,7 +64,7 @@ export class Aquarius { this.logger.error('Success accessing consume endpoint: ', consumptionUrl) return consumptionUrl }) - .catch(error => { + .catch((error) => { this.logger.error( 'Error fetching the data asset consumption url: ', error @@ -94,10 +94,10 @@ export class Aquarius { ) return this.transformResult() }) - .then(results => { + .then((results) => { return this.transformResult(results) }) - .catch(error => { + .catch((error) => { this.logger.error('Error fetching querying metadata: ', error) return this.transformResult() }) @@ -133,10 +133,10 @@ export class Aquarius { ) return this.transformResult() }) - .then(results => { + .then((results) => { return this.transformResult(results) }) - .catch(error => { + .catch((error) => { this.logger.error('Error fetching querying metadata by text: ', error) return this.transformResult() }) @@ -168,7 +168,7 @@ export class Aquarius { .then((response: DDO) => { return new DDO(response) as DDO }) - .catch(error => { + .catch((error) => { this.logger.error('Error fetching querying metadata: ', error) return null as DDO }) @@ -204,7 +204,7 @@ export class Aquarius { .then((response: DDO) => { return new DDO(response) as DDO }) - .catch(error => { + .catch((error) => { this.logger.error('Error fetching querying metadata: ', error) return null as DDO }) @@ -253,7 +253,7 @@ export class Aquarius { return null }) - .catch(error => { + .catch((error) => { this.logger.error('Error transfering ownership metadata: ', error) return null }) @@ -307,7 +307,7 @@ export class Aquarius { return null }) - .catch(error => { + .catch((error) => { this.logger.error('Error updating compute privacy: ', error) return null }) @@ -318,14 +318,14 @@ export class Aquarius { /** * Edit Metadata for a DDO. * @param {did} string DID. - * @param {newMetadata} EditableMetaData Metadata fields & new values. + * @param {newMetadata} EditableMetadata Metadata fields & new values. * @param {String} updated Updated field of the DDO * @param {String} signature Signature using updated field to verify that the consumer has rights * @return {Promise} Result. */ public async editMetadata( did: DID | string, - newMetadata: EditableMetaData, + newMetadata: EditableMetadata, updated: string, signature: string ): Promise { @@ -353,7 +353,7 @@ export class Aquarius { return null }) - .catch(error => { + .catch((error) => { this.logger.error('Error transfering ownership metadata: ', error) return null }) @@ -391,7 +391,7 @@ export class Aquarius { return null }) - .catch(error => { + .catch((error) => { this.logger.error('Error transfering ownership metadata: ', error) return null }) @@ -416,7 +416,7 @@ export class Aquarius { } ): QueryResult { return { - results: (results || []).map(ddo => new DDO(ddo as DDO)), + results: (results || []).map((ddo) => new DDO(ddo as DDO)), page, totalPages, totalResults diff --git a/src/brizo/Brizo.ts b/src/brizo/Brizo.ts index fbd7433f..6dc55aa0 100644 --- a/src/brizo/Brizo.ts +++ b/src/brizo/Brizo.ts @@ -1,15 +1,14 @@ -import { File, MetaDataAlgorithm } from '../ddo/MetaData' import Account from '../ocean/Account' -import { noZeroX, noDidPrefixed } from '../utils' +import { noZeroX } from '../utils' import { Instantiable, InstantiableConfig } from '../Instantiable.abstract' -import { DDO } from '../ddo/DDO' -import { ServiceType } from '../ddo/Service' const apiPath = '/api/v1/brizo/services' /** - * Provides a interface with Brizo. - * Brizo is the technical component executed by the Publishers allowing to them to provide extended data services. + * Provides an interface for provider service. + * Provider service is the technical component executed + * by the Publishers allowing to them to provide extended + * data services. */ export class Brizo extends Instantiable { private get url() { diff --git a/src/datatokens/Datatokens.ts b/src/datatokens/Datatokens.ts index b150bafa..30e6f4ae 100644 --- a/src/datatokens/Datatokens.ts +++ b/src/datatokens/Datatokens.ts @@ -1,6 +1,7 @@ import Account from '../ocean/Account' -const defaultFactoryABI = require('@oceanprotocol/artifacts/development/Factory.json') -const defaultDatatokensABI = require('@oceanprotocol/artifacts/development/DatatokenTemplate.json') + +import * as defaultFactoryABI from '@oceanprotocol/contracts/artifacts/development/Factory.json' +import * as defaultDatatokensABI from '@oceanprotocol/contracts/artifacts/development/DataTokenTemplate.json' /** * Provides a interface to DataTokens diff --git a/src/ddo/DDO.ts b/src/ddo/DDO.ts index 2427e1dd..5840db7c 100644 --- a/src/ddo/DDO.ts +++ b/src/ddo/DDO.ts @@ -1,8 +1,8 @@ import { Ocean } from '../ocean/Ocean' -import { Authentication } from './Authentication' -import { Proof } from './Proof' -import { PublicKey } from './PublicKey' -import { Service, ServiceType } from './Service' +import { Authentication } from './interfaces/Authentication' +import { Proof } from './interfaces/Proof' +import { PublicKey } from './interfaces/PublicKey' +import { Service, ServiceType } from './interfaces/Service' /** * DID Descriptor Object. @@ -72,7 +72,7 @@ export class DDO { throw new Error('index is not set') } - const service = this.service.find(s => s.index === index) + const service = this.service.find((s) => s.index === index) return service as Service } @@ -87,7 +87,7 @@ export class DDO { throw new Error('serviceType not set') } - return this.service.find(s => s.type === serviceType) as Service + return this.service.find((s) => s.type === serviceType) as Service } /** @@ -100,7 +100,7 @@ export class DDO { const { files, name, author, license } = attributes.main const values = [ - ...(files || []).map(({ checksum }) => checksum).filter(_ => !!_), + ...(files || []).map(({ checksum }) => checksum).filter((_) => !!_), name, author, license, diff --git a/src/ddo/MetaData.ts b/src/ddo/MetaData.ts deleted file mode 100644 index f2690d89..00000000 --- a/src/ddo/MetaData.ts +++ /dev/null @@ -1,303 +0,0 @@ -export interface File { - /** - * File name. - * @type {string} - */ - name?: string - - /** - * File URL. - * @type {string} - */ - url: string - - /** - * File index. - * @type {number} - */ - index?: number - - /** - * File format, if applicable. - * @type {string} - * @example "text/csv" - */ - contentType: string - - /** - * File checksum. - * @type {[type]} - */ - checksum?: string - - /** - * Checksum hash algorithm. - * @type {[type]} - */ - checksumType?: string - - /** - * File content length. - * @type {[type]} - */ - contentLength?: string - - /** - * Resource ID (depending on the source). - * @type {[type]} - */ - resourceId?: string - - /** - * File encoding. - * @type {string} - * @example "UTF-8" - */ - encoding?: string - - /** - * File compression (e.g. no, gzip, bzip2, etc). - * @type {string} - * @example "zip" - */ - compression?: string -} - -export interface MetaDataAlgorithm { - url?: string - rawcode?: string - language?: string - format?: string - version?: string - container: { - entrypoint: string - image: string - tag: string - } -} - -/** - * Main attributes of assets metadata. - * @see https://github.com/oceanprotocol/OEPs/tree/master/8 - */ -export interface MetaDataMain { - /** - * Descriptive name of the Asset. - * @type {string} - * @example "UK Weather information 2011" - */ - name: string - - /** - * Type of the Asset. Helps to filter by the type of asset ("dataset" or "algorithm"). - * @type {string} - * @example "dataset" - */ - type: 'dataset' | 'algorithm' - - /** - * The date on which the asset was created by the originator in - * ISO 8601 format, Coordinated Universal Time. - * @type {string} - * @example "2019-01-31T08:38:32Z" - */ - dateCreated: string - - /** - * The date on which the asset DDO was registered into the metadata store. - * This value is created automatically by Aquarius upon registering, - * so this value can't be set. - * @type {string} - * @example "2019-01-31T08:38:32Z" - */ - datePublished?: string - - /** - * Name of the entity generating this data (e.g. Tfl, Disney Corp, etc.). - * @type {string} - * @example "Met Office" - */ - author: string - - /** - * Short name referencing the license of the asset (e.g. Public Domain, CC-0, CC-BY, No License Specified, etc. ). - * If it's not specified, the following value will be added: "No License Specified". - * @type {string} - * @example "CC-BY" - */ - license: string - - /** - * Price of the asset in vodka (attoOCEAN). It must be an integer encoded as a string. - * @type {string} - * @example "1000000000000000000" - */ - price: string - - /** - * Array of File objects including the encrypted file urls and some additional information. - * @type {File[]} - */ - files: File[] - - /** - * Metadata used only for assets with type `algorithm`. - * @type {MetaDataAlgorithm} - */ - algorithm?: MetaDataAlgorithm -} - -/** - * Curation attributes of Assets Metadata. - * @see https://github.com/oceanprotocol/OEPs/tree/master/8 - */ -export interface Curation { - /** - * Decimal value between 0 and 1. 0 is the default value. - * @type {number} - * @example 0.93 - */ - rating: number - - /** - * Number of votes. 0 is the default value. - * @type {number} - * @example 123 - */ - numVotes: number - - /** - * Schema applied to calculate the rating. - * @type {string} - * @example "Binary Voting" - */ - schema?: string - - /** - * Flag unsuitable content. - * @type {boolean} - * @example true - */ - isListed?: boolean -} - -/** - * Additional Information of Assets Metadata. - * @see https://github.com/oceanprotocol/OEPs/tree/master/8#additional-information - */ -export interface AdditionalInformation { - /** - * Details of what the resource is. For a dataset, this attribute - * explains what the data represents and what it can be used for. - * @type {string} - * @example "Weather information of UK including temperature and humidity" - */ - description?: string - - /** - * The party holding the legal copyright. Empty by default. - * @type {string} - * @example "Met Office" - */ - copyrightHolder?: string - - /** - * Example of the concept of this asset. This example is part - * of the metadata, not an external link. - * @type {string} - * @example "423432fsd,51.509865,-0.118092,2011-01-01T10:55:11+00:00,7.2,68" - */ - workExample?: string - - /** - * Mapping of links for data samples, or links to find out more information. - * Links may be to either a URL or another Asset. We expect marketplaces to - * converge on agreements of typical formats for linked data: The Ocean Protocol - * itself does not mandate any specific formats as these requirements are likely - * to be domain-specific. - * @type {any[]} - * @example - * [ - * { - * anotherSample: "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs-daily/", - * }, - * { - * fieldsDescription: "http://data.ceda.ac.uk/badc/ukcp09/", - * }, - * ] - */ - links?: { [name: string]: string }[] - - /** - * The language of the content. Please use one of the language - * codes from the {@link https://tools.ietf.org/html/bcp47 IETF BCP 47 standard}. - * @type {String} - * @example "en" - */ - inLanguage?: string - - /** - * Categories used to describe this content. Empty by default. - * @type {string[]} - * @example ["Economy", "Data Science"] - */ - categories?: string[] - - /** - * Keywords or tags used to describe this content. Empty by default. - * @type {string[]} - * @example ["weather", "uk", "2011", "temperature", "humidity"] - */ - tags?: string[] - - /** - * An indication of update latency - i.e. How often are updates expected (seldom, - * annually, quarterly, etc.), or is the resource static that is never expected - * to get updated. - * @type {string} - * @example "yearly" - */ - updateFrequency?: string - - /** - * A link to machine-readable structured markup (such as ttl/json-ld/rdf) - * describing the dataset. - * @type {StructuredMarkup[]} - */ - structuredMarkup?: { - uri: string - mediaType: string - }[] -} - -export interface MetaData { - main: MetaDataMain - encryptedFiles?: string - additionalInformation?: AdditionalInformation - curation?: Curation -} -/** Warning. serviceIndex is the index of a services in Services array, and not service.index attribute. -Let's assume that you have the following services array: -[ - {"index":1,"type":"access","main":{"price":3}}, - {"index":0,"type":"compute","main":{"price":1}} -] -then calling update with { serviceIndex:1,price:2} will update the 'compute' service, and not the access one -**/ -export interface ServicePrices { - serviceIndex: number - price: string -} - -export interface EditableMetaDataLinks { - name: string - url: string - type: string -} - -export interface EditableMetaData { - description?: string - title?: string - links?: EditableMetaDataLinks[] - servicePrices?: ServicePrices[] -} diff --git a/src/ddo/interfaces/AdditionalInformation.ts b/src/ddo/interfaces/AdditionalInformation.ts new file mode 100644 index 00000000..98be0988 --- /dev/null +++ b/src/ddo/interfaces/AdditionalInformation.ts @@ -0,0 +1,88 @@ +/** + * Additional Information of Assets Metadata. + * @see https://github.com/oceanprotocol/OEPs/tree/master/8#additional-information + */ +export interface AdditionalInformation { + /** + * Details of what the resource is. For a dataset, this attribute + * explains what the data represents and what it can be used for. + * @type {string} + * @example "Weather information of UK including temperature and humidity" + */ + description?: string + + /** + * The party holding the legal copyright. Empty by default. + * @type {string} + * @example "Met Office" + */ + copyrightHolder?: string + + /** + * Example of the concept of this asset. This example is part + * of the metadata, not an external link. + * @type {string} + * @example "423432fsd,51.509865,-0.118092,2011-01-01T10:55:11+00:00,7.2,68" + */ + workExample?: string + + /** + * Mapping of links for data samples, or links to find out more information. + * Links may be to either a URL or another Asset. We expect marketplaces to + * converge on agreements of typical formats for linked data: The Ocean Protocol + * itself does not mandate any specific formats as these requirements are likely + * to be domain-specific. + * @type {any[]} + * @example + * [ + * { + * anotherSample: "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs-daily/", + * }, + * { + * fieldsDescription: "http://data.ceda.ac.uk/badc/ukcp09/", + * }, + * ] + */ + links?: { [name: string]: string }[] + + /** + * The language of the content. Please use one of the language + * codes from the {@link https://tools.ietf.org/html/bcp47 IETF BCP 47 standard}. + * @type {String} + * @example "en" + */ + inLanguage?: string + + /** + * Categories used to describe this content. Empty by default. + * @type {string[]} + * @example ["Economy", "Data Science"] + */ + categories?: string[] + + /** + * Keywords or tags used to describe this content. Empty by default. + * @type {string[]} + * @example ["weather", "uk", "2011", "temperature", "humidity"] + */ + tags?: string[] + + /** + * An indication of update latency - i.e. How often are updates expected (seldom, + * annually, quarterly, etc.), or is the resource static that is never expected + * to get updated. + * @type {string} + * @example "yearly" + */ + updateFrequency?: string + + /** + * A link to machine-readable structured markup (such as ttl/json-ld/rdf) + * describing the dataset. + * @type {StructuredMarkup[]} + */ + structuredMarkup?: { + uri: string + mediaType: string + }[] +} diff --git a/src/ddo/Authentication.ts b/src/ddo/interfaces/Authentication.ts similarity index 100% rename from src/ddo/Authentication.ts rename to src/ddo/interfaces/Authentication.ts diff --git a/src/ddo/interfaces/Curation.ts b/src/ddo/interfaces/Curation.ts new file mode 100644 index 00000000..31e36bff --- /dev/null +++ b/src/ddo/interfaces/Curation.ts @@ -0,0 +1,33 @@ +/** + * Curation attributes of Assets Metadata. + * @see https://github.com/oceanprotocol/OEPs/tree/master/8 + */ +export interface Curation { + /** + * Decimal value between 0 and 1. 0 is the default value. + * @type {number} + * @example 0.93 + */ + rating: number + + /** + * Number of votes. 0 is the default value. + * @type {number} + * @example 123 + */ + numVotes: number + + /** + * Schema applied to calculate the rating. + * @type {string} + * @example "Binary Voting" + */ + schema?: string + + /** + * Flag unsuitable content. + * @type {boolean} + * @example true + */ + isListed?: boolean +} diff --git a/src/ddo/interfaces/EditableMetadata.ts b/src/ddo/interfaces/EditableMetadata.ts new file mode 100644 index 00000000..edfebda1 --- /dev/null +++ b/src/ddo/interfaces/EditableMetadata.ts @@ -0,0 +1,9 @@ +import { EditableMetadataLinks } from './EditableMetadataLinks' +import { ServicePrices } from './ServicePrices' + +export interface EditableMetadata { + description?: string + title?: string + links?: EditableMetadataLinks[] + servicePrices?: ServicePrices[] +} diff --git a/src/ddo/interfaces/EditableMetadataLinks.ts b/src/ddo/interfaces/EditableMetadataLinks.ts new file mode 100644 index 00000000..d0365185 --- /dev/null +++ b/src/ddo/interfaces/EditableMetadataLinks.ts @@ -0,0 +1,5 @@ +export interface EditableMetadataLinks { + name: string + url: string + type: string +} diff --git a/src/ddo/interfaces/File.ts b/src/ddo/interfaces/File.ts new file mode 100644 index 00000000..90ed24e2 --- /dev/null +++ b/src/ddo/interfaces/File.ts @@ -0,0 +1,64 @@ +export interface File { + /** + * File name. + * @type {string} + */ + name?: string + + /** + * File URL. + * @type {string} + */ + url: string + + /** + * File index. + * @type {number} + */ + index?: number + + /** + * File format, if applicable. + * @type {string} + * @example "text/csv" + */ + contentType: string + + /** + * File checksum. + * @type {[type]} + */ + checksum?: string + + /** + * Checksum hash algorithm. + * @type {[type]} + */ + checksumType?: string + + /** + * File content length. + * @type {[type]} + */ + contentLength?: string + + /** + * Resource ID (depending on the source). + * @type {[type]} + */ + resourceId?: string + + /** + * File encoding. + * @type {string} + * @example "UTF-8" + */ + encoding?: string + + /** + * File compression (e.g. no, gzip, bzip2, etc). + * @type {string} + * @example "zip" + */ + compression?: string +} diff --git a/src/ddo/interfaces/Metadata.ts b/src/ddo/interfaces/Metadata.ts new file mode 100644 index 00000000..bb6c814a --- /dev/null +++ b/src/ddo/interfaces/Metadata.ts @@ -0,0 +1,10 @@ +import { MetadataMain } from './MetadataMain' +import { AdditionalInformation } from './AdditionalInformation' +import { Curation } from './Curation' + +export interface Metadata { + main: MetadataMain + encryptedFiles?: string + additionalInformation?: AdditionalInformation + curation?: Curation +} diff --git a/src/ddo/interfaces/MetadataAlgorithm.ts b/src/ddo/interfaces/MetadataAlgorithm.ts new file mode 100644 index 00000000..c5b5a9ef --- /dev/null +++ b/src/ddo/interfaces/MetadataAlgorithm.ts @@ -0,0 +1,12 @@ +export interface MetadataAlgorithm { + url?: string + rawcode?: string + language?: string + format?: string + version?: string + container: { + entrypoint: string + image: string + tag: string + } +} diff --git a/src/ddo/interfaces/MetadataMain.ts b/src/ddo/interfaces/MetadataMain.ts new file mode 100644 index 00000000..c567dacc --- /dev/null +++ b/src/ddo/interfaces/MetadataMain.ts @@ -0,0 +1,73 @@ +import { MetadataAlgorithm } from './MetadataAlgorithm' +import { File } from './File' + +/** + * Main attributes of assets metadata. + * @see https://github.com/oceanprotocol/OEPs/tree/master/8 + */ +export interface MetadataMain { + /** + * Descriptive name of the Asset. + * @type {string} + * @example "UK Weather information 2011" + */ + name: string + + /** + * Type of the Asset. Helps to filter by the type of asset ("dataset" or "algorithm"). + * @type {string} + * @example "dataset" + */ + type: 'dataset' | 'algorithm' + + /** + * The date on which the asset was created by the originator in + * ISO 8601 format, Coordinated Universal Time. + * @type {string} + * @example "2019-01-31T08:38:32Z" + */ + dateCreated: string + + /** + * The date on which the asset DDO was registered into the metadata store. + * This value is created automatically by Aquarius upon registering, + * so this value can't be set. + * @type {string} + * @example "2019-01-31T08:38:32Z" + */ + datePublished?: string + + /** + * Name of the entity generating this data (e.g. Tfl, Disney Corp, etc.). + * @type {string} + * @example "Met Office" + */ + author: string + + /** + * Short name referencing the license of the asset (e.g. Public Domain, CC-0, CC-BY, No License Specified, etc. ). + * If it's not specified, the following value will be added: "No License Specified". + * @type {string} + * @example "CC-BY" + */ + license: string + + /** + * Price of the asset in vodka (attoOCEAN). It must be an integer encoded as a string. + * @type {string} + * @example "1000000000000000000" + */ + price: string + + /** + * Array of File objects including the encrypted file urls and some additional information. + * @type {File[]} + */ + files: File[] + + /** + * Metadata used only for assets with type `algorithm`. + * @type {MetaDataAlgorithm} + */ + algorithm?: MetadataAlgorithm +} diff --git a/src/ddo/Proof.ts b/src/ddo/interfaces/Proof.ts similarity index 100% rename from src/ddo/Proof.ts rename to src/ddo/interfaces/Proof.ts diff --git a/src/ddo/PublicKey.ts b/src/ddo/interfaces/PublicKey.ts similarity index 100% rename from src/ddo/PublicKey.ts rename to src/ddo/interfaces/PublicKey.ts diff --git a/src/ddo/Service.ts b/src/ddo/interfaces/Service.ts similarity index 97% rename from src/ddo/Service.ts rename to src/ddo/interfaces/Service.ts index 7f2479da..0f94f0bf 100644 --- a/src/ddo/Service.ts +++ b/src/ddo/interfaces/Service.ts @@ -1,4 +1,4 @@ -import { MetaData } from './MetaData' +import { Metadata } from './Metadata' export type ServiceType = 'authorization' | 'metadata' | 'access' | 'compute' @@ -69,7 +69,7 @@ export interface ServiceComputeProvider { export interface ServiceMetadata extends ServiceCommon { type: 'metadata' - attributes: MetaData + attributes: Metadata } export interface ServiceAccess extends ServiceCommon { diff --git a/src/ddo/interfaces/ServicePrices.ts b/src/ddo/interfaces/ServicePrices.ts new file mode 100644 index 00000000..afef8b22 --- /dev/null +++ b/src/ddo/interfaces/ServicePrices.ts @@ -0,0 +1,4 @@ +export interface ServicePrices { + serviceIndex: number + price: string +} diff --git a/src/lib.ts b/src/lib.ts index 418080e3..11bd17dd 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -11,7 +11,7 @@ import * as utils from './utils' // Exports export * from './ddo/DDO' -export * from './ddo/MetaData' +export * from './ddo/interfaces/Metadata' export { CreateProgressStep, OrderProgressStep } from './ocean/Assets' diff --git a/src/ocean/Accounts.ts b/src/ocean/Accounts.ts index 8ff6a731..041a69ba 100644 --- a/src/ocean/Accounts.ts +++ b/src/ocean/Accounts.ts @@ -25,7 +25,7 @@ export class Accounts extends Instantiable { const ethAccounts: string[] = await this.web3.eth.getAccounts() const accountPromises = ethAccounts.map( - address => new Account(address, this.instanceConfig) + (address) => new Account(address, this.instanceConfig) ) return Promise.all(accountPromises) } diff --git a/src/ocean/Assets.ts b/src/ocean/Assets.ts index c6d2d964..076a94df 100644 --- a/src/ocean/Assets.ts +++ b/src/ocean/Assets.ts @@ -1,8 +1,8 @@ import { TransactionReceipt } from 'web3-core' import { SearchQuery } from '../aquarius/Aquarius' import { DDO } from '../ddo/DDO' -import { MetaData, EditableMetaData } from '../ddo/MetaData' -import { Service, ServiceAccess, ServiceComputePrivacy } from '../ddo/Service' +import { Metadata } from '../ddo/interfaces/Metadata' +import { Service } from '../ddo/interfaces/Service' import Account from './Account' import DID from './DID' import { SubscribablePromise, didZeroX } from '../utils' @@ -63,13 +63,13 @@ export class Assets extends Instantiable { * @return {Promise} */ public create( - metadata: MetaData, + metadata: Metadata, publisher: Account, services: Service[] = [], dtAddress?: string ): SubscribablePromise { this.logger.log('Creating asset') - return new SubscribablePromise(async observer => { + return new SubscribablePromise(async (observer) => { if (services.length === 0) { this.logger.log('You have no services. Are you sure about this?') } @@ -148,7 +148,7 @@ export class Assets extends Instantiable { ) .reverse() // Adding index - .map(_ => ({ + .map((_) => ({ ..._, index: indexCount++ })) as Service[] diff --git a/src/utils/ConfigHelper.ts b/src/utils/ConfigHelper.ts index c2129a8a..69b5afcc 100644 --- a/src/utils/ConfigHelper.ts +++ b/src/utils/ConfigHelper.ts @@ -25,7 +25,7 @@ export class ConfigHelper { confighelp.factoryAddress = null confighelp.url = null confighelp.network = network - const knownconfig = configs.find(c => c.network === network) + const knownconfig = configs.find((c) => c.network === network) if (knownconfig) { confighelp.factoryAddress = knownconfig.factoryAddress confighelp.url = knownconfig.url diff --git a/src/utils/SubscribableObserver.ts b/src/utils/SubscribableObserver.ts index efeb4116..9e916054 100644 --- a/src/utils/SubscribableObserver.ts +++ b/src/utils/SubscribableObserver.ts @@ -39,7 +39,7 @@ export class SubscribableObserver { private emit(type: 'onNext' | 'onComplete' | 'onError', value: any) { Array.from(this.subscriptions) - .map(subscription => subscription[type]) + .map((subscription) => subscription[type]) .filter((callback: any) => callback && typeof callback === 'function') .forEach((callback: any) => callback(value)) } diff --git a/src/utils/SubscribablePromise.ts b/src/utils/SubscribablePromise.ts index 1ff71fb1..ee4b0acb 100644 --- a/src/utils/SubscribablePromise.ts +++ b/src/utils/SubscribablePromise.ts @@ -42,12 +42,12 @@ export class SubscribablePromise { const execution = executor(this.observer) Promise.resolve(execution as any) - .then(result => { + .then((result) => { if (typeof (execution as any).then === 'function') { this.observer.complete(result) } }) - .catch(result => { + .catch((result) => { if (typeof (execution as any).then === 'function') { this.observer.error(result) }