mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
Add initial condition and agreement store managers.
This commit is contained in:
parent
6a4df9768a
commit
0ffa0e4204
31
src/keeper/contracts/managers/AgreementStoreManager.ts
Normal file
31
src/keeper/contracts/managers/AgreementStoreManager.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import Logger from "../../../utils/Logger"
|
||||
import ContractBase from "../ContractBase"
|
||||
import { zeroX } from "../../../utils"
|
||||
|
||||
export interface AgreementData {
|
||||
did: string
|
||||
didOwner: string
|
||||
templateId: string
|
||||
conditionIds: string[]
|
||||
lastUpdatedBy: string
|
||||
blockNumberUpdated: number
|
||||
}
|
||||
|
||||
export class AgreementStoreManager extends ContractBase {
|
||||
|
||||
public static async getInstance(): Promise<AgreementStoreManager> {
|
||||
const templateStoreManeger: AgreementStoreManager = new AgreementStoreManager("AgreementStoreManager")
|
||||
await templateStoreManeger.init()
|
||||
return templateStoreManeger
|
||||
}
|
||||
|
||||
getOwner(): Promise<string> {
|
||||
return this.call("owner", [])
|
||||
}
|
||||
|
||||
public async getAgreement(agreementId: string) {
|
||||
const {did, didOwner, templateId, conditionIds, lastUpdatedBy, blockNumberUpdated} =
|
||||
await this.call("getAgreement", [zeroX(agreementId)])
|
||||
return {did, didOwner, templateId, conditionIds, lastUpdatedBy, blockNumberUpdated: +blockNumberUpdated} as AgreementData
|
||||
}
|
||||
}
|
41
src/keeper/contracts/managers/ConditionStoreManager.ts
Normal file
41
src/keeper/contracts/managers/ConditionStoreManager.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import Logger from "../../../utils/Logger"
|
||||
import ContractBase from "../ContractBase"
|
||||
import { ConditionState } from "../conditions/Condition.abstract"
|
||||
import { zeroX } from "../../../utils"
|
||||
|
||||
export interface ConditionData {
|
||||
typeRef: string
|
||||
state: ConditionState
|
||||
timeLock: number
|
||||
timeOut: number
|
||||
blockNumber: number
|
||||
lastUpdatedBy: string
|
||||
blockNumberUpdated: number
|
||||
}
|
||||
|
||||
export class ConditionStoreManager extends ContractBase {
|
||||
|
||||
public static async getInstance(): Promise<ConditionStoreManager> {
|
||||
const templateStoreManeger: ConditionStoreManager = new ConditionStoreManager("ConditionStoreManager")
|
||||
await templateStoreManeger.init()
|
||||
return templateStoreManeger
|
||||
}
|
||||
|
||||
getOwner(): Promise<string> {
|
||||
return this.call("owner", [])
|
||||
}
|
||||
|
||||
public async getCondition(conditionId: string) {
|
||||
const {typeRef, state, timeLock, timeOut, blockNumber, lastUpdatedBy, blockNumberUpdated} =
|
||||
await this.call("getCondition", [zeroX(conditionId)])
|
||||
return {
|
||||
typeRef,
|
||||
state: +state,
|
||||
timeLock: +timeLock,
|
||||
timeOut: +timeOut,
|
||||
blockNumber: +blockNumber,
|
||||
lastUpdatedBy,
|
||||
blockNumberUpdated: +blockNumberUpdated,
|
||||
} as ConditionData
|
||||
}
|
||||
}
|
@ -1 +1,3 @@
|
||||
export * from './AgreementStoreManager'
|
||||
export * from './ConditionStoreManager'
|
||||
export * from './TemplateStoreManager'
|
||||
|
Loading…
Reference in New Issue
Block a user