From 7b5b110cec16c4575c0e2168db0ea913dd40376c Mon Sep 17 00:00:00 2001 From: ssallam Date: Fri, 17 Jan 2020 16:39:44 +0100 Subject: [PATCH] Fix lint errors. --- src/keeper/Keeper.ts | 2 +- .../managers/AgreementStoreManager.ts | 1 - .../managers/TemplateStoreManager.ts | 19 ++++----- .../templates/AgreementTemplateBase.ts | 39 ++++++++++++------- .../EscrowAccessSecretStoreTemplate.ts | 8 +--- .../EscrowComputeExecutionTemplate.ts | 7 +--- test/keeper/TestContractHandler.ts | 10 ++--- 7 files changed, 39 insertions(+), 47 deletions(-) diff --git a/src/keeper/Keeper.ts b/src/keeper/Keeper.ts index 247744c..e1e37e5 100644 --- a/src/keeper/Keeper.ts +++ b/src/keeper/Keeper.ts @@ -24,7 +24,7 @@ import { objectPromiseAll } from '../utils' import { EventHandler } from './EventHandler' import { Instantiable, InstantiableConfig } from '../Instantiable.abstract' -import { AgreementTemplateBase } from "./contracts/templates/AgreementTemplateBase"; +import { AgreementTemplateBase } from './contracts/templates/AgreementTemplateBase' /** * Interface with Ocean Keeper contracts. diff --git a/src/keeper/contracts/managers/AgreementStoreManager.ts b/src/keeper/contracts/managers/AgreementStoreManager.ts index 948e70c..2ee321f 100644 --- a/src/keeper/contracts/managers/AgreementStoreManager.ts +++ b/src/keeper/contracts/managers/AgreementStoreManager.ts @@ -93,5 +93,4 @@ export class AgreementStoreManager extends ContractBase { agreementId: zeroX(agreementId) }) } - } diff --git a/src/keeper/contracts/managers/TemplateStoreManager.ts b/src/keeper/contracts/managers/TemplateStoreManager.ts index 5b19026..9efbea2 100644 --- a/src/keeper/contracts/managers/TemplateStoreManager.ts +++ b/src/keeper/contracts/managers/TemplateStoreManager.ts @@ -30,10 +30,7 @@ export class TemplateStoreManager extends ContractBase { } public generateId(templateName: string) { - const args: any = [ - { type: 'string', value: templateName }, - ] - + const args: any = [{ type: 'string', value: templateName }] return this.web3.utils.soliditySha3(...args) } @@ -41,7 +38,11 @@ export class TemplateStoreManager extends ContractBase { return this.call('owner', []) } - public async proposeTemplate(templateId: string, from?: string, ignoreExists?: boolean) { + public async proposeTemplate( + templateId: string, + from?: string, + ignoreExists?: boolean + ) { const template = await this.getTemplate(templateId) if (template.blockNumberUpdated !== 0) { this.logger.warn(`Template "${templateId}" already exist.`) @@ -73,7 +74,7 @@ export class TemplateStoreManager extends ContractBase { return this.sendFrom('revokeTemplate', [zeroX(templateId)], from) } - public async getConditionTypes(templateId: string): Promise { + public async getConditionTypes(templateId: string): Promise { const { conditionTypes } = await this.getTemplate(templateId) return conditionTypes } @@ -85,10 +86,7 @@ export class TemplateStoreManager extends ContractBase { } public async getActorTypeValue(actorTypeId: string) { - const typeValue = await this.call( - "getTemplateActorTypeValue", - [actorTypeId] - ) + const typeValue = await this.call('getTemplateActorTypeValue', [actorTypeId]) return typeValue } @@ -108,7 +106,6 @@ export class TemplateStoreManager extends ContractBase { blockNumberUpdated: +blockNumberUpdated, conditionTypes, actorTypeIds - } as TemplateMetadata } } diff --git a/src/keeper/contracts/templates/AgreementTemplateBase.ts b/src/keeper/contracts/templates/AgreementTemplateBase.ts index 4777ded..6203fe7 100644 --- a/src/keeper/contracts/templates/AgreementTemplateBase.ts +++ b/src/keeper/contracts/templates/AgreementTemplateBase.ts @@ -1,14 +1,21 @@ -import { escrowAccessServiceAgreementTemplate } from './EscrowAccess.serviceAgreementTemplate' -import {TemplateStoreManager, AgreementStoreManager, ConditionStoreManager} from '../managers' +import { + TemplateStoreManager, + AgreementStoreManager, + ConditionStoreManager +} from '../managers' import DIDRegistry from '../DIDRegistry' import { LockRewardCondition } from '../conditions/LockRewardCondition' import { AccessSecretStoreCondition } from '../conditions/AccessSecretStoreCondition' import { EscrowReward } from '../conditions/EscrowReward' import { DDO } from '../../../ddo/DDO' -import {generateId, LoggerInstance, Logger, zeroX} from '../../../utils' - -import {ComputeExecutionCondition, Condition, ConditionState, conditionStateNames} from '../conditions' +import { generateId, LoggerInstance, Logger, zeroX } from '../../../utils' +import { + ComputeExecutionCondition, + Condition, + ConditionState, + conditionStateNames +} from '../conditions' export interface Conditions { lockRewardCondition: LockRewardCondition @@ -17,7 +24,6 @@ export interface Conditions { escrowReward: EscrowReward } - export interface AgreementConditionsStatus { [condition: string]: { condition: string @@ -28,7 +34,6 @@ export interface AgreementConditionsStatus { } } - export class AgreementTemplateBase { public templateName: string @@ -77,7 +82,7 @@ export class AgreementTemplateBase { consumer: string, from?: string ) { - return await this.createFullAgreementData( + return this.createFullAgreementData( agreementId, ddo.shortId(), ddo.findServiceByType('metadata').attributes.main.price, @@ -145,7 +150,7 @@ export class AgreementTemplateBase { * @return {Promise} Conditions address. */ public async getConditionTypes(): Promise { - return await this.templateManager.getConditionTypes(this.getId()) + return this.templateManager.getConditionTypes(this.getId()) } /** @@ -186,12 +191,13 @@ export class AgreementTemplateBase { * @return {Promise} Conditions status. */ public async getAgreementStatus( - agreementId: string, conditionStoreManager: ConditionStoreManager + agreementId: string, + conditionStoreManager: ConditionStoreManager ): Promise { - const dependencies = await this.getServiceAgreementTemplateDependencies() - const { conditionIds } = await this.agreementStoreManager.getAgreement(agreementId) - + const { conditionIds } = await this.agreementStoreManager.getAgreement( + agreementId + ) if (!conditionIds.length) { // this.logger.error(`Agreement not creeated yet: "${agreementId}"`) return false @@ -241,9 +247,12 @@ export class AgreementTemplateBase { /** * Prints the agreement status. * @param {string} agreementId Agreement ID. - * @param {ConditionStoreManager} conditionStoreManager + * @param {ConditionStoreManager} conditionStoreManager */ - public async printAgreementStatus(agreementId: string, conditionStoreManager: ConditionStoreManager) { + public async printAgreementStatus( + agreementId: string, + conditionStoreManager: ConditionStoreManager + ) { const status = await this.getAgreementStatus(agreementId, conditionStoreManager) this.logger.bypass('-'.repeat(80)) diff --git a/src/keeper/contracts/templates/EscrowAccessSecretStoreTemplate.ts b/src/keeper/contracts/templates/EscrowAccessSecretStoreTemplate.ts index 4665266..6acb7b5 100644 --- a/src/keeper/contracts/templates/EscrowAccessSecretStoreTemplate.ts +++ b/src/keeper/contracts/templates/EscrowAccessSecretStoreTemplate.ts @@ -21,7 +21,6 @@ export class EscrowAccessSecretStoreTemplate extends AgreementTemplateBase { } = this.conditions const publisher = await this.didRegistry.getDIDOwner(did) - const lockRewardConditionId = await lockRewardCondition.generateIdHash( agreementId, await escrowReward.getAddress(), @@ -40,11 +39,6 @@ export class EscrowAccessSecretStoreTemplate extends AgreementTemplateBase { lockRewardConditionId, accessSecretStoreConditionId ) - - return [ - lockRewardConditionId, - accessSecretStoreConditionId, - escrowRewardId - ] + return [lockRewardConditionId, accessSecretStoreConditionId, escrowRewardId] } } diff --git a/src/keeper/contracts/templates/EscrowComputeExecutionTemplate.ts b/src/keeper/contracts/templates/EscrowComputeExecutionTemplate.ts index d41ef44..5a82ea4 100644 --- a/src/keeper/contracts/templates/EscrowComputeExecutionTemplate.ts +++ b/src/keeper/contracts/templates/EscrowComputeExecutionTemplate.ts @@ -40,11 +40,6 @@ export class EscrowComputeExecutionTemplate extends AgreementTemplateBase { lockRewardConditionId, computeExecutionConditionId ) - - return [ - lockRewardConditionId, - computeExecutionConditionId, - escrowRewardId - ] + return [lockRewardConditionId, computeExecutionConditionId, escrowRewardId] } } diff --git a/test/keeper/TestContractHandler.ts b/test/keeper/TestContractHandler.ts index 5272d47..5487204 100644 --- a/test/keeper/TestContractHandler.ts +++ b/test/keeper/TestContractHandler.ts @@ -87,9 +87,8 @@ export default class TestContractHandler extends ContractHandler { didRegistry.options.address ] ) - // Conditions - await TestContractHandler.deployContract( + const lockCondition = await TestContractHandler.deployContract( 'LockRewardCondition', deployerAddress, [ @@ -98,7 +97,7 @@ export default class TestContractHandler extends ContractHandler { token.options.address ] ) - await TestContractHandler.deployContract( + const accessCondition = await TestContractHandler.deployContract( 'AccessSecretStoreCondition', deployerAddress, [ @@ -107,9 +106,8 @@ export default class TestContractHandler extends ContractHandler { agreementStoreManager.options.address ] ) - // Conditions rewards - await TestContractHandler.deployContract( + const escrowCondition = await TestContractHandler.deployContract( 'EscrowReward', deployerAddress, [ @@ -118,7 +116,7 @@ export default class TestContractHandler extends ContractHandler { token.options.address ] ) - + Logger.log(lockCondition, accessCondition, escrowCondition) } private static async deployContract(