diff --git a/package-lock.json b/package-lock.json index d87db0a..4506141 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9605,9 +9605,9 @@ "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=" }, "prettier": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", - "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.5.tgz", + "integrity": "sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==", "dev": true }, "prettier-linter-helpers": { diff --git a/package.json b/package.json index 49d3a44..e1a8ee8 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "mock-local-storage": "^1.1.11", "nyc": "^15.0.0", "ora": "^4.0.2", - "prettier": "^1.19.1", + "prettier": "^2.0.5", "sinon": "^9.0.1", "source-map-support": "^0.5.16", "ts-node": "^8.6.2", diff --git a/scripts/get-metadata.js b/scripts/get-metadata.js index a9844e8..8b0fa2a 100755 --- a/scripts/get-metadata.js +++ b/scripts/get-metadata.js @@ -9,9 +9,7 @@ process.stdout.write( JSON.stringify( { version: require('../package.json').version, - commit: execSync(`git rev-parse HEAD`) - .toString() - .trim() + commit: execSync(`git rev-parse HEAD`).toString().trim() }, null, ' ' diff --git a/src/aquarius/Aquarius.ts b/src/aquarius/Aquarius.ts index 14d4fa0..4ba338d 100644 --- a/src/aquarius/Aquarius.ts +++ b/src/aquarius/Aquarius.ts @@ -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 }) @@ -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 }) @@ -412,7 +412,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/ddo/DDO.ts b/src/ddo/DDO.ts index 8f56cb7..3f510d7 100644 --- a/src/ddo/DDO.ts +++ b/src/ddo/DDO.ts @@ -71,7 +71,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 } @@ -86,7 +86,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 } /** @@ -98,7 +98,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/keeper/ContractEvent.ts b/src/keeper/ContractEvent.ts index 048f1c0..caa643b 100644 --- a/src/keeper/ContractEvent.ts +++ b/src/keeper/ContractEvent.ts @@ -36,8 +36,8 @@ export class ContractEvent { } public once(callback?: (events: any[]) => void) { - return new Promise(resolve => { - const subscription = this.subscribe(events => { + return new Promise((resolve) => { + const subscription = this.subscribe((events) => { subscription.unsubscribe() if (callback) { callback(events) diff --git a/src/keeper/EventHandler.ts b/src/keeper/EventHandler.ts index add7efd..668cd9a 100644 --- a/src/keeper/EventHandler.ts +++ b/src/keeper/EventHandler.ts @@ -62,7 +62,7 @@ export class EventHandler extends Instantiable { } if (this.lastBlock !== blockNumber) { - this.events.forEach(fn => fn(this.lastBlock + 1)) + this.events.forEach((fn) => fn(this.lastBlock + 1)) this.lastBlock = blockNumber } this.lastTimeout = global.setTimeout( diff --git a/src/keeper/Keeper.ts b/src/keeper/Keeper.ts index 75f26d3..346b05c 100644 --- a/src/keeper/Keeper.ts +++ b/src/keeper/Keeper.ts @@ -192,7 +192,7 @@ export class Keeper extends Instantiable { */ public getConditionByAddress(address: string): Condition { return Object.values(this.conditions).find( - condition => condition.getAddress() === address + (condition) => condition.getAddress() === address ) } @@ -203,7 +203,7 @@ export class Keeper extends Instantiable { */ public getTemplateByName(name: string): AgreementTemplateBase { return Object.values(this.templates).find( - template => template.templateName === name + (template) => template.templateName === name ) } @@ -214,7 +214,7 @@ export class Keeper extends Instantiable { */ public getTemplateById(templateId: string): AgreementTemplateBase { return Object.values(this.templates).find( - template => template.getId() === templateId + (template) => template.getId() === templateId ) } diff --git a/src/keeper/contracts/ContractBase.ts b/src/keeper/contracts/ContractBase.ts index 8a4f107..80c9ed0 100644 --- a/src/keeper/contracts/ContractBase.ts +++ b/src/keeper/contracts/ContractBase.ts @@ -146,7 +146,7 @@ export abstract class ContractBase extends Instantiable { private searchMethod(methodName: string, args: any[] = []) { const methods = this.contract.options.jsonInterface - .map(method => ({ + .map((method) => ({ ...method, signature: (method as any).signature })) diff --git a/src/keeper/contracts/managers/TemplateStoreManager.ts b/src/keeper/contracts/managers/TemplateStoreManager.ts index 9efbea2..cc0f710 100644 --- a/src/keeper/contracts/managers/TemplateStoreManager.ts +++ b/src/keeper/contracts/managers/TemplateStoreManager.ts @@ -80,7 +80,7 @@ export class TemplateStoreManager extends ContractBase { } public getConditions(conditionTypes: string[]) { - return conditionTypes.map(address => + return conditionTypes.map((address) => this.ocean.keeper.getConditionByAddress(address) ) } diff --git a/src/keeper/contracts/templates/AgreementTemplateBase.ts b/src/keeper/contracts/templates/AgreementTemplateBase.ts index 202c73b..18d5245 100644 --- a/src/keeper/contracts/templates/AgreementTemplateBase.ts +++ b/src/keeper/contracts/templates/AgreementTemplateBase.ts @@ -183,7 +183,7 @@ export class AgreementTemplateBase { ({ name: conditionRef }) => conditionRef === ref ).contractName return (await this.getConditions()).find( - condition => condition.contractName === name + (condition) => condition.contractName === name ) } @@ -237,8 +237,8 @@ export class AgreementTemplateBase { return states.reduce((acc, { contractName, ref, state }) => { const blockers = dependencies[ref] - .map(dependency => states.find(_ => _.ref === dependency)) - .filter(condition => condition.state !== ConditionState.Fulfilled) + .map((dependency) => states.find((_) => _.ref === dependency)) + .filter((condition) => condition.state !== ConditionState.Fulfilled) return { ...acc, [ref]: { @@ -246,7 +246,7 @@ export class AgreementTemplateBase { contractName, state, blocked: !!blockers.length, - blockedBy: blockers.map(_ => _.ref) + blockedBy: blockers.map((_) => _.ref) } } }, {}) @@ -309,6 +309,8 @@ export class AgreementTemplateBase { */ public async getActorTypes() { const actorTypeIds = await this.getActorTypeIds() - return actorTypeIds.map(typeId => this.templateManager.getActorTypeValue(typeId)) + return actorTypeIds.map((typeId) => + this.templateManager.getActorTypeValue(typeId) + ) } } diff --git a/src/ocean/OceanAccounts.ts b/src/ocean/OceanAccounts.ts index e346551..88fea47 100644 --- a/src/ocean/OceanAccounts.ts +++ b/src/ocean/OceanAccounts.ts @@ -26,7 +26,7 @@ export class OceanAccounts 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/OceanAssets.ts b/src/ocean/OceanAssets.ts index ebb5069..ea888c4 100644 --- a/src/ocean/OceanAssets.ts +++ b/src/ocean/OceanAssets.ts @@ -60,7 +60,7 @@ export class OceanAssets extends Instantiable { services: Service[] = [] ): SubscribablePromise { this.logger.log('Creating asset') - return new SubscribablePromise(async observer => { + return new SubscribablePromise(async (observer) => { const { secretStoreUri } = this.config const { didRegistry, templates } = this.ocean.keeper @@ -147,7 +147,7 @@ export class OceanAssets extends Instantiable { ) .reverse() // Adding index - .map(_ => ({ + .map((_) => ({ ..._, index: indexCount++ })) as Service[] @@ -287,7 +287,7 @@ export class OceanAssets extends Instantiable { consumerAccount: Account, provider?: string ): SubscribablePromise { - return new SubscribablePromise(async observer => { + return new SubscribablePromise(async (observer) => { const { keeper, utils } = this.ocean const ddo: DDO = await this.resolve(did) const condition = keeper.conditions.accessSecretStoreCondition diff --git a/src/ocean/OceanCompute.ts b/src/ocean/OceanCompute.ts index 694b805..78b61ee 100644 --- a/src/ocean/OceanCompute.ts +++ b/src/ocean/OceanCompute.ts @@ -81,7 +81,7 @@ export class OceanCompute extends Instantiable { algorithmMeta?: MetaDataAlgorithm, provider?: string ): SubscribablePromise { - return new SubscribablePromise(async observer => { + return new SubscribablePromise(async (observer) => { const { assets, keeper, utils } = this.ocean const ddo: DDO = await assets.resolve(datasetDid) const service: Service = ddo.findServiceByType('compute') diff --git a/src/ocean/OceanVersions.ts b/src/ocean/OceanVersions.ts index 9c1f048..5c9a2aa 100644 --- a/src/ocean/OceanVersions.ts +++ b/src/ocean/OceanVersions.ts @@ -61,7 +61,7 @@ export class OceanVersions extends Instantiable { network: (await this.ocean.keeper.getNetworkName()).toLowerCase(), keeperVersion: keeperPackageJson.version, contracts: Object.values(await this.ocean.keeper.getAllInstances()) - .filter(_ => !!_) + .filter((_) => !!_) .reduce( (acc, { contractName, address }) => ({ ...acc, @@ -115,19 +115,19 @@ export class OceanVersions extends Instantiable { const networks = techs .map(({ network }) => network) - .filter(_ => !!_) + .filter((_) => !!_) .reduce((acc, network) => ({ ...acc, [network]: true }), {}) let contractStatus = true - const contractList = techs.map(({ contracts }) => contracts).filter(_ => !!_) + const contractList = techs.map(({ contracts }) => contracts).filter((_) => !!_) Array.from(contractList.map(Object.keys)) .reduce((acc, _) => [...acc, ..._], []) .filter((_, i, list) => list.indexOf(_) === i) - .forEach(name => { + .forEach((name) => { let address contractList - .map(_ => _[name]) - .forEach(_ => { + .map((_) => _[name]) + .forEach((_) => { if (!address) { address = _ return diff --git a/src/utils/DDOHelpers.ts b/src/utils/DDOHelpers.ts index 327be5f..dfc71a3 100644 --- a/src/utils/DDOHelpers.ts +++ b/src/utils/DDOHelpers.ts @@ -8,7 +8,7 @@ function fillParameterWithDDO( parameter: ServiceAgreementTemplateParameter, ddo: DDO ): ServiceAgreementTemplateParameter { - const getValue = name => { + const getValue = (name) => { switch (name) { case 'amount': case 'price': @@ -38,9 +38,9 @@ export function fillConditionsWithDDO( conditions: ServiceAgreementTemplateCondition[], ddo: DDO ): ServiceAgreementTemplateCondition[] { - return conditions.map(condition => ({ + return conditions.map((condition) => ({ ...condition, - parameters: condition.parameters.map(parameter => ({ + parameters: condition.parameters.map((parameter) => ({ ...fillParameterWithDDO(parameter, ddo) })) })) diff --git a/src/utils/SubscribableObserver.ts b/src/utils/SubscribableObserver.ts index efeb411..9e91605 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 1ff71fb..ee4b0ac 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) } diff --git a/test/integration/ocean/Compute.test.ts b/test/integration/ocean/Compute.test.ts index 9723748..c40cd42 100644 --- a/test/integration/ocean/Compute.test.ts +++ b/test/integration/ocean/Compute.test.ts @@ -66,7 +66,7 @@ describe('Compute', () => { ) dataset = await ocean.assets .create(metadataAsset as MetaData, account, [computeService]) - .next(step => stepsAsset.push(step)) + .next((step) => stepsAsset.push(step)) assert.instanceOf(dataset, DDO) assert.isDefined( @@ -92,7 +92,7 @@ describe('Compute', () => { ) datasetNoRawAlgo = await ocean.assets .create(metadataAsset as MetaData, account, [computeService]) - .next(step => stepsAsset.push(step)) + .next((step) => stepsAsset.push(step)) assert.instanceOf(datasetNoRawAlgo, DDO) assert.isDefined( @@ -118,7 +118,7 @@ describe('Compute', () => { ) datasetWithTrustedAlgo = await ocean.assets .create(metadataAsset as MetaData, account, [computeService]) - .next(step => stepsAsset.push(step)) + .next((step) => stepsAsset.push(step)) assert.instanceOf(datasetWithTrustedAlgo, DDO) assert.isDefined( @@ -132,7 +132,7 @@ describe('Compute', () => { const stepsAlgorithm = [] algorithm = await ocean.assets .create(metadataAlgorithm as MetaData, account) - .next(step => stepsAlgorithm.push(step)) + .next((step) => stepsAlgorithm.push(step)) assert.instanceOf(algorithm, DDO) assert.deepEqual(stepsAlgorithm, [0, 1, 2, 3, 4, 5, 6, 7]) @@ -143,7 +143,7 @@ describe('Compute', () => { agreementId = await ocean.compute .order(account, datasetNoRawAlgo.id, null, rawAlgoMeta) - .next(step => steps.push(step)) + .next((step) => steps.push(step)) assert.equal(agreementId, null) }) @@ -153,7 +153,7 @@ describe('Compute', () => { agreementId = await ocean.compute .order(account, datasetWithTrustedAlgo.id, 'did:op:233454', null) - .next(step => steps.push(step)) + .next((step) => steps.push(step)) assert.equal(agreementId, null) }) @@ -172,7 +172,7 @@ describe('Compute', () => { agreementId = await ocean.compute .order(account, dataset.id) - .next(step => steps.push(step)) + .next((step) => steps.push(step)) console.log(agreementId) assert.isDefined(agreementId) diff --git a/test/integration/ocean/ConsumeAsset.test.ts b/test/integration/ocean/ConsumeAsset.test.ts index 6d11835..3cdc009 100644 --- a/test/integration/ocean/ConsumeAsset.test.ts +++ b/test/integration/ocean/ConsumeAsset.test.ts @@ -170,7 +170,7 @@ describe('Consume Asset', () => { assert.include(path, folder, 'The storage path is not correct.') - const files = await new Promise(resolve => { + const files = await new Promise((resolve) => { fs.readdir(path, (e, fileList) => { resolve(fileList) }) @@ -195,7 +195,7 @@ describe('Consume Asset', () => { assert.include(path, folder, 'The storage path is not correct.') - const files = await new Promise(resolve => { + const files = await new Promise((resolve) => { fs.readdir(path, (e, fileList) => { resolve(fileList) }) diff --git a/test/integration/ocean/ConsumeAssetBrizo.test.ts b/test/integration/ocean/ConsumeAssetBrizo.test.ts index b87407a..b7e00c4 100644 --- a/test/integration/ocean/ConsumeAssetBrizo.test.ts +++ b/test/integration/ocean/ConsumeAssetBrizo.test.ts @@ -43,7 +43,7 @@ describe('Consume Asset (Brizo)', () => { const steps = [] ddo = await ocean.assets .create(metadata as any, publisher) - .next(step => steps.push(step)) + .next((step) => steps.push(step)) assert.instanceOf(ddo, DDO) assert.deepEqual(steps, [0, 1, 2, 3, 4, 5, 6, 7]) @@ -64,7 +64,7 @@ describe('Consume Asset (Brizo)', () => { agreementId = await ocean.assets .order(ddo.id, consumer) - .next(step => steps.push(step)) + .next((step) => steps.push(step)) } catch {} assert.isDefined(agreementId) @@ -77,7 +77,7 @@ describe('Consume Asset (Brizo)', () => { assert.include(path, folder, 'The storage path is not correct.') - const files = await new Promise(resolve => { + const files = await new Promise((resolve) => { fs.readdir(path, (e, fileList) => { resolve(fileList) }) diff --git a/test/integration/ocean/ConsumeBigAsset.test.ts b/test/integration/ocean/ConsumeBigAsset.test.ts index a2e0567..9460577 100644 --- a/test/integration/ocean/ConsumeBigAsset.test.ts +++ b/test/integration/ocean/ConsumeBigAsset.test.ts @@ -72,7 +72,7 @@ xdescribe('Consume Asset (Large size)', () => { assert.include(path, folder, 'The storage path is not correct.') - const files = await new Promise(resolve => { + const files = await new Promise((resolve) => { fs.readdir(path, (e, fileList) => { resolve(fileList) }) diff --git a/test/integration/ocean/RegisterEscrowAccessSecretStoreTemplate.test.ts b/test/integration/ocean/RegisterEscrowAccessSecretStoreTemplate.test.ts index 53ea58b..b270044 100644 --- a/test/integration/ocean/RegisterEscrowAccessSecretStoreTemplate.test.ts +++ b/test/integration/ocean/RegisterEscrowAccessSecretStoreTemplate.test.ts @@ -53,7 +53,7 @@ describe('Register Escrow Access Secret Store Template', () => { true ) // TODO: Use a event to detect template mined - await new Promise(resolve => setTimeout(resolve, 2 * 1000)) + await new Promise((resolve) => setTimeout(resolve, 2 * 1000)) }) it('should approve the template', async () => { @@ -63,7 +63,7 @@ describe('Register Escrow Access Secret Store Template', () => { true ) // TODO: Use a event to detect template mined - await new Promise(resolve => setTimeout(resolve, 2 * 1000)) + await new Promise((resolve) => setTimeout(resolve, 2 * 1000)) }) }) @@ -122,9 +122,9 @@ describe('Register Escrow Access Secret Store Template', () => { }) it('should have condition instances asociated', async () => { - const conditionInstances = (await template.getConditionTypes()).map(address => - keeper.getConditionByAddress(address) - ) + const conditionInstances = ( + await template.getConditionTypes() + ).map((address) => keeper.getConditionByAddress(address)) assert.equal(conditionInstances.length, 3, 'Expected 3 conditions.') @@ -133,10 +133,10 @@ describe('Register Escrow Access Secret Store Template', () => { EscrowReward, LockRewardCondition ] - conditionClasses.forEach(conditionClass => { + conditionClasses.forEach((conditionClass) => { if ( !conditionInstances.find( - condition => condition instanceof conditionClass + (condition) => condition instanceof conditionClass ) ) { throw new Error( diff --git a/test/integration/ocean/RegisterEscrowComputeExecutionTemplate.test.ts b/test/integration/ocean/RegisterEscrowComputeExecutionTemplate.test.ts index 5c5dde3..cecd1ed 100644 --- a/test/integration/ocean/RegisterEscrowComputeExecutionTemplate.test.ts +++ b/test/integration/ocean/RegisterEscrowComputeExecutionTemplate.test.ts @@ -55,7 +55,7 @@ describe('Register Escrow Compute Execution Template', () => { true ) // TODO: Use a event to detect template mined - await new Promise(resolve => setTimeout(resolve, 2 * 1000)) + await new Promise((resolve) => setTimeout(resolve, 2 * 1000)) }) it('should approve the template', async () => { @@ -65,7 +65,7 @@ describe('Register Escrow Compute Execution Template', () => { true ) // TODO: Use a event to detect template mined - await new Promise(resolve => setTimeout(resolve, 2 * 1000)) + await new Promise((resolve) => setTimeout(resolve, 2 * 1000)) }) }) @@ -133,10 +133,10 @@ describe('Register Escrow Compute Execution Template', () => { EscrowReward, LockRewardCondition ] - conditionClasses.forEach(conditionClass => { + conditionClasses.forEach((conditionClass) => { if ( !conditionInstances.find( - condition => condition instanceof conditionClass + (condition) => condition instanceof conditionClass ) ) { throw new Error( diff --git a/test/integration/ocean/SearchAsset.test.ts b/test/integration/ocean/SearchAsset.test.ts index 7e8ba4d..1277bca 100644 --- a/test/integration/ocean/SearchAsset.test.ts +++ b/test/integration/ocean/SearchAsset.test.ts @@ -11,9 +11,7 @@ describe('Search Asset', () => { let publisher: Account - const testHash = Math.random() - .toString(36) - .substr(2) + const testHash = Math.random().toString(36).substr(2) let price const metadataGenerator = (name: string) => generateMetadata(`${name}${testHash}`, price) @@ -83,7 +81,7 @@ describe('Search Asset', () => { 1, 'Something was wrong searching the assets' ) - ddos.map(ddo => + ddos.map((ddo) => assert.instanceOf(ddo, DDO, 'The DDO is not an instance of a DDO') ) }) @@ -101,7 +99,7 @@ describe('Search Asset', () => { }) assert.equal(ddos.length, 1, 'Something was wrong searching the assets') - ddos.map(ddo => + ddos.map((ddo) => assert.instanceOf(ddo, DDO, 'The DDO is not an instance of a DDO') ) }) diff --git a/test/unit/aquarius/Aquarius.test.ts b/test/unit/aquarius/Aquarius.test.ts index e9ff8f9..f5d2938 100644 --- a/test/unit/aquarius/Aquarius.test.ts +++ b/test/unit/aquarius/Aquarius.test.ts @@ -9,7 +9,7 @@ import { LoggerInstance } from '../../../src/utils' use(spies) -const reponsify = async data => ({ +const reponsify = async (data) => ({ ok: true, json: () => Promise.resolve(data) }) diff --git a/test/unit/keeper/ContractBase.test.ts b/test/unit/keeper/ContractBase.test.ts index 43e9e2a..d89d41c 100644 --- a/test/unit/keeper/ContractBase.test.ts +++ b/test/unit/keeper/ContractBase.test.ts @@ -17,25 +17,25 @@ describe('ContractWrapperBase', () => { }) describe('#call()', () => { - it('should fail to call on an unknown contract function', done => { + it('should fail to call on an unknown contract function', (done) => { wrappedContract.callMock('balanceOfxxx', []).catch(() => { done() }) }) - it('should fail to call on an contract function with wrong set of parameters', done => { + it('should fail to call on an contract function with wrong set of parameters', (done) => { wrappedContract.callMock('balanceOf', []).catch(() => { done() }) }) - it('should fail to call on an unknown contract function', done => { + it('should fail to call on an unknown contract function', (done) => { wrappedContract.sendMock('balanceOfxxx', '0x00', ['0x00']).catch(() => { done() }) }) - it('should fail to call on an contract function with wrong set of parameters', done => { + it('should fail to call on an contract function with wrong set of parameters', (done) => { wrappedContract.sendMock('approve', '0x000', []).catch(() => { done() }) @@ -43,7 +43,7 @@ describe('ContractWrapperBase', () => { }) describe('#send()', () => { - it('should fail to call on an unknown contract function', done => { + it('should fail to call on an unknown contract function', (done) => { wrappedContract.sendMock('transferxxx', accounts[0].getId(), []).catch(() => { done() }) @@ -60,7 +60,7 @@ describe('ContractWrapperBase', () => { }) describe('#getEventData()', () => { - it('should fail on unknown event', done => { + it('should fail on unknown event', (done) => { wrappedContract.getEventData('crazyevent', {}).catch(() => { done() }) diff --git a/test/unit/keeper/ContractEvent.test.ts b/test/unit/keeper/ContractEvent.test.ts index 6529dd0..f037e52 100644 --- a/test/unit/keeper/ContractEvent.test.ts +++ b/test/unit/keeper/ContractEvent.test.ts @@ -28,8 +28,8 @@ describe('ContractEvent', () => { let validResolve = false let subscription: ContractEventSubscription - const waitUntilEvent = new Promise(resolve => { - subscription = event.subscribe(events => { + const waitUntilEvent = new Promise((resolve) => { + subscription = event.subscribe((events) => { assert.isDefined(events) assert.lengthOf(events, 2) if (validResolve) { @@ -40,7 +40,7 @@ describe('ContractEvent', () => { await Promise.all([executeTransaction(), executeTransaction()]) - await new Promise(resolve => setTimeout(resolve, 2000)) + await new Promise((resolve) => setTimeout(resolve, 2000)) validResolve = true await Promise.all([executeTransaction(), executeTransaction()]) @@ -68,7 +68,7 @@ describe('ContractEvent', () => { await executeTransaction() - await new Promise(resolve => setTimeout(resolve, 2000)) + await new Promise((resolve) => setTimeout(resolve, 2000)) canBeRejected = true await executeTransaction() @@ -82,7 +82,7 @@ describe('ContractEvent', () => { const waitUntilEvent = event.once() - await new Promise(resolve => setTimeout(resolve, 400)) + await new Promise((resolve) => setTimeout(resolve, 400)) await executeTransaction() diff --git a/test/unit/keeper/ContractHandler.test.ts b/test/unit/keeper/ContractHandler.test.ts index 754211e..92c3037 100644 --- a/test/unit/keeper/ContractHandler.test.ts +++ b/test/unit/keeper/ContractHandler.test.ts @@ -17,7 +17,7 @@ describe('ContractHandler', () => { assert(await contractHandler.get('OceanToken')) }) - it('should fail to load an unknown contract', done => { + it('should fail to load an unknown contract', (done) => { contractHandler.get('OceanXXX').catch(() => { done() }) diff --git a/test/unit/keeper/EventHandler.test.ts b/test/unit/keeper/EventHandler.test.ts index f4ed8f6..a32ef09 100644 --- a/test/unit/keeper/EventHandler.test.ts +++ b/test/unit/keeper/EventHandler.test.ts @@ -67,12 +67,12 @@ describe('EventHandler', () => { const subscription = eventHandler.subscribe(callbackSpy) - await new Promise(resolve => setTimeout(resolve, 300)) + await new Promise((resolve) => setTimeout(resolve, 300)) expect(callbackSpy).not.to.has.been.called() blockNumber++ - await new Promise(resolve => setTimeout(resolve, 300)) + await new Promise((resolve) => setTimeout(resolve, 300)) expect(callbackSpy).to.has.been.called.with(blockNumber) diff --git a/test/unit/ocean/DID.test.ts b/test/unit/ocean/DID.test.ts index 2107806..330013c 100644 --- a/test/unit/ocean/DID.test.ts +++ b/test/unit/ocean/DID.test.ts @@ -18,7 +18,7 @@ describe('DID', () => { assert(did.getId() === id, did.getId()) }) - it('should throw if prefix does not match', done => { + it('should throw if prefix does not match', (done) => { const id = '1234' try { const did: DID = DID.parse(`did:xxx:${id}`) @@ -28,7 +28,7 @@ describe('DID', () => { } }) - it('should throw if id does not match', done => { + it('should throw if id does not match', (done) => { const id = 'xyz' try { const did: DID = DID.parse(`did:op:${id}`) diff --git a/test/unit/ocean/OceanAccounts.test.ts b/test/unit/ocean/OceanAccounts.test.ts index ea19e8a..f9db008 100644 --- a/test/unit/ocean/OceanAccounts.test.ts +++ b/test/unit/ocean/OceanAccounts.test.ts @@ -23,7 +23,7 @@ describe('OceanAccounts', () => { it('should return the list of accounts', async () => { const accounts = await oceanAccounts.list() - accounts.map(account => assert.instanceOf(account, Account)) + accounts.map((account) => assert.instanceOf(account, Account)) }) }) diff --git a/test/unit/utils/SubscribablePromise.test.ts b/test/unit/utils/SubscribablePromise.test.ts index 5f7d8bd..15672f3 100644 --- a/test/unit/utils/SubscribablePromise.test.ts +++ b/test/unit/utils/SubscribablePromise.test.ts @@ -22,9 +22,9 @@ describe('SubscribablePromise', () => { assert.typeOf(subscription.unsubscribe, 'function') }) - it('should listen the next values', done => { + it('should listen the next values', (done) => { const onNextSpy = spy() - const subscribable = new SubscribablePromise(observer => { + const subscribable = new SubscribablePromise((observer) => { setTimeout(() => observer.next('test'), 10) setTimeout(() => observer.next('test'), 20) }) @@ -39,10 +39,10 @@ describe('SubscribablePromise', () => { }) describe('#then()', () => { - it('should resolve', done => { + it('should resolve', (done) => { const onCompleteSpy = spy() const onFinallySpy = spy() - const subscribable = new SubscribablePromise(observer => { + const subscribable = new SubscribablePromise((observer) => { setTimeout(() => observer.next('test'), 10) setTimeout(() => observer.complete('test'), 20) }) @@ -59,10 +59,10 @@ describe('SubscribablePromise', () => { }) describe('#error()', () => { - it('should catch the error', done => { + it('should catch the error', (done) => { const onErrorSpy = spy() const onFinallySpy = spy() - const subscribable = new SubscribablePromise(observer => { + const subscribable = new SubscribablePromise((observer) => { setTimeout(() => observer.next('test'), 10) setTimeout(() => observer.error('test'), 20) }) @@ -80,7 +80,7 @@ describe('SubscribablePromise', () => { it('should be able to subscribe and wait for a promise', async () => { const onNextSpy = spy() - const subscribable = new SubscribablePromise(observer => { + const subscribable = new SubscribablePromise((observer) => { setTimeout(() => observer.next('test'), 10) setTimeout(() => observer.next('test'), 20) setTimeout(() => observer.complete('completed'), 30) @@ -96,12 +96,12 @@ describe('SubscribablePromise', () => { it('should use the result of a the promise as executor to complete the observer', async () => { const onNextSpy = spy() - const subscribable = new SubscribablePromise(async observer => { - await new Promise(resolve => setTimeout(resolve, 10)) + const subscribable = new SubscribablePromise(async (observer) => { + await new Promise((resolve) => setTimeout(resolve, 10)) observer.next('test') - await new Promise(resolve => setTimeout(resolve, 10)) + await new Promise((resolve) => setTimeout(resolve, 10)) observer.next('test') - await new Promise(resolve => setTimeout(resolve, 10)) + await new Promise((resolve) => setTimeout(resolve, 10)) return 'completed' })