diff --git a/src/keeper/Keeper.ts b/src/keeper/Keeper.ts index 26383e9..04afa19 100644 --- a/src/keeper/Keeper.ts +++ b/src/keeper/Keeper.ts @@ -1,4 +1,5 @@ import OceanAuth from "./contracts/Auth" +import AccessConditions from "./contracts/conditions/AccessConditions" import OceanMarket from "./contracts/Market" import ServiceAgreement from "./contracts/ServiceAgreement" import OceanToken from "./contracts/Token" @@ -15,6 +16,7 @@ export default class Keeper { Keeper.instance.auth = await OceanAuth.getInstance() Keeper.instance.token = await OceanToken.getInstance() Keeper.instance.serviceAgreement = await ServiceAgreement.getInstance() + Keeper.instance.accessConditions = await AccessConditions.getInstance() } return Keeper.instance } @@ -25,6 +27,7 @@ export default class Keeper { public market: OceanMarket public auth: OceanAuth public serviceAgreement: ServiceAgreement + public accessConditions: AccessConditions public async getNetworkName(): Promise { return Web3Provider.getWeb3().eth.net.getId() diff --git a/src/ocean/ServiceAgreements/ServiceAgreement.ts b/src/ocean/ServiceAgreements/ServiceAgreement.ts index 1049e16..09d4c29 100644 --- a/src/ocean/ServiceAgreements/ServiceAgreement.ts +++ b/src/ocean/ServiceAgreements/ServiceAgreement.ts @@ -1,7 +1,6 @@ import Condition from "../../ddo/Condition" import DDO from "../../ddo/DDO" -import AccessConditions from "../../keeper/contracts/conditions/AccessConditions" -import ServiceAgreementContract from "../../keeper/contracts/ServiceAgreement" +import Keeper from "../../keeper/Keeper" import Web3Provider from "../../keeper/Web3Provider" import ValuePair from "../../models/ValuePair" import Account from "../Account" @@ -48,7 +47,7 @@ export default class ServiceAgreement extends OceanBase { serviceAgreementHashSignature: string, consumer: Account, publisher: Account): Promise { - const serviceAgreement: ServiceAgreementContract = await ServiceAgreementContract.getInstance() + const {serviceAgreement} = await Keeper.getInstance() const executeAgreementReceipt = await serviceAgreement.executeAgreement( ddo.service[0].templateId, serviceAgreementHashSignature, consumer.getId(), valueHashes, timeoutValues, serviceAgreementId, ddo.id, publisher.getId()) @@ -117,7 +116,7 @@ export default class ServiceAgreement extends OceanBase { } public async grantAccess(assetId: string, documentId: string): Promise { - const accessConditions: AccessConditions = await AccessConditions.getInstance() + const {accessConditions} = await Keeper.getInstance() const grantAccessReceipt = await accessConditions.grantAccess(this.getId(), assetId, documentId, @@ -127,7 +126,7 @@ export default class ServiceAgreement extends OceanBase { } public async getStatus() { - const serviceAgreement = await ServiceAgreementContract.getInstance() + const {serviceAgreement} = await Keeper.getInstance() return serviceAgreement.getAgreementStatus(this.getId()) } } diff --git a/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts b/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts index 7ac4880..1bba708 100644 --- a/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts +++ b/src/ocean/ServiceAgreements/ServiceAgreementTemplate.ts @@ -1,5 +1,5 @@ import ContractReflector from "../../keeper/ContractReflector" -import ServiceAgreement from "../../keeper/contracts/ServiceAgreement" +import Keeper from "../../keeper/Keeper" import Web3Provider from "../../keeper/Web3Provider" import MethodReflection from "../../models/MethodReflection" import ValuePair from "../../models/ValuePair" @@ -21,7 +21,7 @@ export default class ServiceAgreementTemplate extends OceanBase { return method.dependency | method.timeout })) - const serviceAgreement: ServiceAgreement = await ServiceAgreement.getInstance() + const {serviceAgreement} = await Keeper.getInstance() const methodReflections = await this.getMethodReflections() @@ -68,12 +68,12 @@ export default class ServiceAgreementTemplate extends OceanBase { * gets the status of a service agreement template */ public async getStatus(): Promise { - const serviceAgreement: ServiceAgreement = await ServiceAgreement.getInstance() + const {serviceAgreement} = await Keeper.getInstance() return serviceAgreement.getTemplateStatus(this.getId()) } public async getOwner(): Promise { - const serviceAgreement: ServiceAgreement = await ServiceAgreement.getInstance() + const {serviceAgreement} = await Keeper.getInstance() return new Account(await serviceAgreement.getTemplateOwner(this.id)) }