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:
parent
20377f5aa3
commit
8e3a30990b
@ -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<string> {
|
||||
return Web3Provider.getWeb3().eth.net.getId()
|
||||
|
@ -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<ServiceAgreement> {
|
||||
|
||||
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<boolean> {
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
@ -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<boolean> {
|
||||
const serviceAgreement: ServiceAgreement = await ServiceAgreement.getInstance()
|
||||
const {serviceAgreement} = await Keeper.getInstance()
|
||||
return serviceAgreement.getTemplateStatus(this.getId())
|
||||
}
|
||||
|
||||
public async getOwner(): Promise<Account> {
|
||||
const serviceAgreement: ServiceAgreement = await ServiceAgreement.getInstance()
|
||||
const {serviceAgreement} = await Keeper.getInstance()
|
||||
|
||||
return new Account(await serviceAgreement.getTemplateOwner(this.id))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user