1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

channel all the contract trough the keeper

This commit is contained in:
Sebastian Gerske 2018-11-07 11:21:17 +01:00
parent 20377f5aa3
commit 8e3a30990b
3 changed files with 11 additions and 9 deletions

View File

@ -1,4 +1,5 @@
import OceanAuth from "./contracts/Auth" import OceanAuth from "./contracts/Auth"
import AccessConditions from "./contracts/conditions/AccessConditions"
import OceanMarket from "./contracts/Market" import OceanMarket from "./contracts/Market"
import ServiceAgreement from "./contracts/ServiceAgreement" import ServiceAgreement from "./contracts/ServiceAgreement"
import OceanToken from "./contracts/Token" import OceanToken from "./contracts/Token"
@ -15,6 +16,7 @@ export default class Keeper {
Keeper.instance.auth = await OceanAuth.getInstance() Keeper.instance.auth = await OceanAuth.getInstance()
Keeper.instance.token = await OceanToken.getInstance() Keeper.instance.token = await OceanToken.getInstance()
Keeper.instance.serviceAgreement = await ServiceAgreement.getInstance() Keeper.instance.serviceAgreement = await ServiceAgreement.getInstance()
Keeper.instance.accessConditions = await AccessConditions.getInstance()
} }
return Keeper.instance return Keeper.instance
} }
@ -25,6 +27,7 @@ export default class Keeper {
public market: OceanMarket public market: OceanMarket
public auth: OceanAuth public auth: OceanAuth
public serviceAgreement: ServiceAgreement public serviceAgreement: ServiceAgreement
public accessConditions: AccessConditions
public async getNetworkName(): Promise<string> { public async getNetworkName(): Promise<string> {
return Web3Provider.getWeb3().eth.net.getId() return Web3Provider.getWeb3().eth.net.getId()

View File

@ -1,7 +1,6 @@
import Condition from "../../ddo/Condition" import Condition from "../../ddo/Condition"
import DDO from "../../ddo/DDO" import DDO from "../../ddo/DDO"
import AccessConditions from "../../keeper/contracts/conditions/AccessConditions" import Keeper from "../../keeper/Keeper"
import ServiceAgreementContract from "../../keeper/contracts/ServiceAgreement"
import Web3Provider from "../../keeper/Web3Provider" import Web3Provider from "../../keeper/Web3Provider"
import ValuePair from "../../models/ValuePair" import ValuePair from "../../models/ValuePair"
import Account from "../Account" import Account from "../Account"
@ -48,7 +47,7 @@ export default class ServiceAgreement extends OceanBase {
serviceAgreementHashSignature: string, consumer: Account, serviceAgreementHashSignature: string, consumer: Account,
publisher: Account): Promise<ServiceAgreement> { publisher: Account): Promise<ServiceAgreement> {
const serviceAgreement: ServiceAgreementContract = await ServiceAgreementContract.getInstance() const {serviceAgreement} = await Keeper.getInstance()
const executeAgreementReceipt = await serviceAgreement.executeAgreement( const executeAgreementReceipt = await serviceAgreement.executeAgreement(
ddo.service[0].templateId, serviceAgreementHashSignature, consumer.getId(), valueHashes, ddo.service[0].templateId, serviceAgreementHashSignature, consumer.getId(), valueHashes,
timeoutValues, serviceAgreementId, ddo.id, publisher.getId()) timeoutValues, serviceAgreementId, ddo.id, publisher.getId())
@ -117,7 +116,7 @@ export default class ServiceAgreement extends OceanBase {
} }
public async grantAccess(assetId: string, documentId: string): Promise<boolean> { public async grantAccess(assetId: string, documentId: string): Promise<boolean> {
const accessConditions: AccessConditions = await AccessConditions.getInstance() const {accessConditions} = await Keeper.getInstance()
const grantAccessReceipt = const grantAccessReceipt =
await accessConditions.grantAccess(this.getId(), assetId, documentId, await accessConditions.grantAccess(this.getId(), assetId, documentId,
@ -127,7 +126,7 @@ export default class ServiceAgreement extends OceanBase {
} }
public async getStatus() { public async getStatus() {
const serviceAgreement = await ServiceAgreementContract.getInstance() const {serviceAgreement} = await Keeper.getInstance()
return serviceAgreement.getAgreementStatus(this.getId()) return serviceAgreement.getAgreementStatus(this.getId())
} }
} }

View File

@ -1,5 +1,5 @@
import ContractReflector from "../../keeper/ContractReflector" import ContractReflector from "../../keeper/ContractReflector"
import ServiceAgreement from "../../keeper/contracts/ServiceAgreement" import Keeper from "../../keeper/Keeper"
import Web3Provider from "../../keeper/Web3Provider" import Web3Provider from "../../keeper/Web3Provider"
import MethodReflection from "../../models/MethodReflection" import MethodReflection from "../../models/MethodReflection"
import ValuePair from "../../models/ValuePair" import ValuePair from "../../models/ValuePair"
@ -21,7 +21,7 @@ export default class ServiceAgreementTemplate extends OceanBase {
return method.dependency | method.timeout return method.dependency | method.timeout
})) }))
const serviceAgreement: ServiceAgreement = await ServiceAgreement.getInstance() const {serviceAgreement} = await Keeper.getInstance()
const methodReflections = await this.getMethodReflections() const methodReflections = await this.getMethodReflections()
@ -68,12 +68,12 @@ export default class ServiceAgreementTemplate extends OceanBase {
* gets the status of a service agreement template * gets the status of a service agreement template
*/ */
public async getStatus(): Promise<boolean> { public async getStatus(): Promise<boolean> {
const serviceAgreement: ServiceAgreement = await ServiceAgreement.getInstance() const {serviceAgreement} = await Keeper.getInstance()
return serviceAgreement.getTemplateStatus(this.getId()) return serviceAgreement.getTemplateStatus(this.getId())
} }
public async getOwner(): Promise<Account> { public async getOwner(): Promise<Account> {
const serviceAgreement: ServiceAgreement = await ServiceAgreement.getInstance() const {serviceAgreement} = await Keeper.getInstance()
return new Account(await serviceAgreement.getTemplateOwner(this.id)) return new Account(await serviceAgreement.getTemplateOwner(this.id))
} }