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 () => {
|
it("should get the agreement conditions status not fulfilled", async () => {
|
||||||
const accessService = ddo.findServiceByType("Access")
|
const status = await ocean.agreements.status(serviceAgreementSignatureResult.agreementId)
|
||||||
|
|
||||||
const status = await ocean.agreements.status(
|
|
||||||
ddo.id,
|
|
||||||
serviceAgreementSignatureResult.agreementId,
|
|
||||||
accessService.serviceDefinitionId,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert.deepEqual(status, {
|
assert.deepEqual(status, {
|
||||||
lockReward: ConditionState.Unfulfilled,
|
lockReward: ConditionState.Unfulfilled,
|
||||||
@ -107,13 +101,7 @@ describe("Consume Asset", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it("should get the agreement conditions status fulfilled", async () => {
|
it("should get the agreement conditions status fulfilled", async () => {
|
||||||
const accessService = ddo.findServiceByType("Access")
|
const status = await ocean.agreements.status(serviceAgreementSignatureResult.agreementId)
|
||||||
|
|
||||||
const status = await ocean.agreements.status(
|
|
||||||
ddo.id,
|
|
||||||
serviceAgreementSignatureResult.agreementId,
|
|
||||||
accessService.serviceDefinitionId,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert.deepEqual(status, {
|
assert.deepEqual(status, {
|
||||||
lockReward: ConditionState.Fulfilled,
|
lockReward: ConditionState.Fulfilled,
|
||||||
|
@ -142,11 +142,26 @@ export class Keeper extends Instantiable {
|
|||||||
.find((condition) => condition.getAddress() === address)
|
.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 {
|
public getTemplateByName(name: string): AgreementTemplate {
|
||||||
return Object.values(this.templates)
|
return Object.values(this.templates)
|
||||||
.find((template) => template.contractName === name)
|
.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.
|
* Returns network id.
|
||||||
* @return {Promise<number>} 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.
|
* @param {boolean} extended Returns a complete status with dependencies.
|
||||||
* @return {Promise<any>}
|
* @return {Promise<any>}
|
||||||
*/
|
*/
|
||||||
// tslint:disable-next-line
|
public async status(agreementId: string, extended?: false): Promise<{[condition: string]: ConditionState}>
|
||||||
public async status(did: string, agreementId: string, serviceDefinitionId: string, extended?: false): Promise<{[condition: string]: ConditionState}>
|
public async status(agreementId: string, extended: true): Promise<AgreementConditionsStatus>
|
||||||
// tslint:disable-next-line
|
|
||||||
public async status(did: string, agreementId: string, serviceDefinitionId: string, extended: true): Promise<AgreementConditionsStatus>
|
|
||||||
public async status(
|
public async status(
|
||||||
did: string,
|
|
||||||
agreementId: string,
|
agreementId: string,
|
||||||
serviceDefinitionId: string,
|
|
||||||
extended: boolean = false,
|
extended: boolean = false,
|
||||||
) {
|
) {
|
||||||
const d: DID = DID.parse(did)
|
const {templateId} = await this.ocean.keeper.agreementStoreManager.getAgreement(agreementId)
|
||||||
const ddo = await this.ocean.aquarius.retrieveDDO(d)
|
|
||||||
|
|
||||||
const templateName = ddo.findServiceById<"Access">(serviceDefinitionId).serviceAgreementTemplate.contractName
|
|
||||||
const fullStatus = await this.ocean.keeper
|
const fullStatus = await this.ocean.keeper
|
||||||
.getTemplateByName(templateName)
|
.getTemplateByAddress(templateId)
|
||||||
.getAgreementStatus(agreementId)
|
.getAgreementStatus(agreementId)
|
||||||
|
|
||||||
if (!fullStatus) {
|
if (!fullStatus) {
|
||||||
|
Loading…
Reference in New Issue
Block a user