mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
Use only the agreementId on status method of agreements module.
This commit is contained in:
parent
398ec203c1
commit
b6af27a523
@ -67,13 +67,7 @@ describe("Consume Asset", () => {
|
||||
})
|
||||
|
||||
it("should get the agreement conditions status not fulfilled", async () => {
|
||||
const accessService = ddo.findServiceByType("Access")
|
||||
|
||||
const status = await ocean.agreements.status(
|
||||
ddo.id,
|
||||
serviceAgreementSignatureResult.agreementId,
|
||||
accessService.serviceDefinitionId,
|
||||
)
|
||||
const status = await ocean.agreements.status(serviceAgreementSignatureResult.agreementId)
|
||||
|
||||
assert.deepEqual(status, {
|
||||
lockReward: ConditionState.Unfulfilled,
|
||||
@ -107,13 +101,7 @@ describe("Consume Asset", () => {
|
||||
})
|
||||
|
||||
it("should get the agreement conditions status fulfilled", async () => {
|
||||
const accessService = ddo.findServiceByType("Access")
|
||||
|
||||
const status = await ocean.agreements.status(
|
||||
ddo.id,
|
||||
serviceAgreementSignatureResult.agreementId,
|
||||
accessService.serviceDefinitionId,
|
||||
)
|
||||
const status = await ocean.agreements.status(serviceAgreementSignatureResult.agreementId)
|
||||
|
||||
assert.deepEqual(status, {
|
||||
lockReward: ConditionState.Fulfilled,
|
||||
|
@ -134,19 +134,34 @@ export class Keeper extends Instantiable {
|
||||
|
||||
/**
|
||||
* Returns a condition by address.
|
||||
* @param {string} address Address of deployed condition.
|
||||
* @return {Condition} Condition instance.
|
||||
* @param {string} address Address of deployed condition.
|
||||
* @return {Condition} Condition instance.
|
||||
*/
|
||||
public getConditionByAddress(address: string): Condition {
|
||||
return Object.values(this.conditions)
|
||||
.find((condition) => condition.getAddress() === address)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a template by name.
|
||||
* @param {string} name Template name.
|
||||
* @return {AgreementTemplate} Agreement template instance.
|
||||
*/
|
||||
public getTemplateByName(name: string): AgreementTemplate {
|
||||
return Object.values(this.templates)
|
||||
.find((template) => template.contractName === name)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a template by address.
|
||||
* @param {string} address Template address.
|
||||
* @return {AgreementTemplate} Agreement template instance.
|
||||
*/
|
||||
public getTemplateByAddress(address: string): AgreementTemplate {
|
||||
return Object.values(this.templates)
|
||||
.find((template) => template.getAddress() === address)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns network id.
|
||||
* @return {Promise<number>} Network ID.
|
||||
|
@ -137,22 +137,15 @@ export class OceanAgreements extends Instantiable {
|
||||
* @param {boolean} extended Returns a complete status with dependencies.
|
||||
* @return {Promise<any>}
|
||||
*/
|
||||
// tslint:disable-next-line
|
||||
public async status(did: string, agreementId: string, serviceDefinitionId: string, extended?: false): Promise<{[condition: string]: ConditionState}>
|
||||
// tslint:disable-next-line
|
||||
public async status(did: string, agreementId: string, serviceDefinitionId: string, extended: true): Promise<AgreementConditionsStatus>
|
||||
public async status(agreementId: string, extended?: false): Promise<{[condition: string]: ConditionState}>
|
||||
public async status(agreementId: string, extended: true): Promise<AgreementConditionsStatus>
|
||||
public async status(
|
||||
did: string,
|
||||
agreementId: string,
|
||||
serviceDefinitionId: string,
|
||||
extended: boolean = false,
|
||||
) {
|
||||
const d: DID = DID.parse(did)
|
||||
const ddo = await this.ocean.aquarius.retrieveDDO(d)
|
||||
|
||||
const templateName = ddo.findServiceById<"Access">(serviceDefinitionId).serviceAgreementTemplate.contractName
|
||||
const {templateId} = await this.ocean.keeper.agreementStoreManager.getAgreement(agreementId)
|
||||
const fullStatus = await this.ocean.keeper
|
||||
.getTemplateByName(templateName)
|
||||
.getTemplateByAddress(templateId)
|
||||
.getAgreementStatus(agreementId)
|
||||
|
||||
if (!fullStatus) {
|
||||
|
Loading…
Reference in New Issue
Block a user