From 99ddff97bc0b89e7ef5598a719ebf2ed225249e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Guti=C3=A9rrez?= Date: Tue, 30 Apr 2019 15:31:24 +0200 Subject: [PATCH] Update order flow using Brizo. --- .travis.yml | 4 ++-- integration/ocean/ConsumeAssetBrizo.test.ts | 2 +- src/ocean/OceanAssets.ts | 21 +++++++-------------- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index 36e70aa..1f3f4fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,8 +22,8 @@ before_script: - git clone https://github.com/oceanprotocol/barge - cd barge - export AQUARIUS_VERSION=v0.2.2 - - export BRIZO_VERSION=v0.3.5 - - export KEEPER_VERSION=v0.9.1 + - export BRIZO_VERSION=v0.3.6 + - export KEEPER_VERSION=v0.9.7 - export KEEPER_OWNER_ROLE_ADDRESS="0xe2DD09d719Da89e5a3D0F2549c7E24566e947260" - bash -x start_ocean.sh --latest --no-pleuston --local-spree-node 2>&1 > start_ocean.log & - cd .. diff --git a/integration/ocean/ConsumeAssetBrizo.test.ts b/integration/ocean/ConsumeAssetBrizo.test.ts index 83ff9b9..6f50886 100644 --- a/integration/ocean/ConsumeAssetBrizo.test.ts +++ b/integration/ocean/ConsumeAssetBrizo.test.ts @@ -41,7 +41,7 @@ describe("Consume Asset (Brizo)", () => { .next((step) => steps.push(step)) assert.isDefined(agreementId) - assert.deepEqual(steps, [0, 1, 2, 3, 4, 5]) + assert.deepEqual(steps, [0, 1, 2, 3]) }) it("should consume and store the assets", async () => { diff --git a/src/ocean/OceanAssets.ts b/src/ocean/OceanAssets.ts index 14b9302..3da627c 100644 --- a/src/ocean/OceanAssets.ts +++ b/src/ocean/OceanAssets.ts @@ -4,13 +4,11 @@ import { MetaData } from "../ddo/MetaData" import { Service } from "../ddo/Service" import Account from "./Account" import DID from "./DID" -import { fillConditionsWithDDO, noZeroX, SubscribablePromise } from "../utils" +import { fillConditionsWithDDO, SubscribablePromise, generateId, zeroX } from "../utils" import { Instantiable, InstantiableConfig } from "../Instantiable.abstract" export enum OrderProgressStep { - Preparing, - Prepared, - SendingAgreement, + CreatingAgreement, AgreementInitialized, LockingPayment, LockedPayment, @@ -207,12 +205,7 @@ export class OceanAssets extends Instantiable { return new SubscribablePromise(async (observer) => { const oceanAgreements = this.ocean.agreements - observer.next(OrderProgressStep.Preparing) - this.logger.log("Asking for agreement signature") - const {agreementId, signature} = await oceanAgreements.prepare(did, serviceDefinitionId, consumer) - this.logger.log(`Agreement ${agreementId} signed`) - observer.next(OrderProgressStep.Prepared) - + const agreementId = zeroX(generateId()) const ddo = await this.resolve(did) const keeper = this.ocean.keeper @@ -251,10 +244,10 @@ export class OceanAssets extends Instantiable { resolve() }) - observer.next(OrderProgressStep.SendingAgreement) - this.logger.log("Sending agreement request") - await oceanAgreements.send(did, agreementId, serviceDefinitionId, signature, consumer) - this.logger.log("Agreement request sent") + observer.next(OrderProgressStep.CreatingAgreement) + this.logger.log("Creating agreement") + await oceanAgreements.create(did, agreementId, serviceDefinitionId, undefined, consumer, consumer) + this.logger.log("Agreement created") try { await paymentFlow