1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

Fix wrong prepare output.

This commit is contained in:
Pedro Gutiérrez 2019-04-15 17:45:06 +02:00 committed by Pedro Gutiérrez
parent 1c6dcf2d1e
commit 1e94e27f81
4 changed files with 7 additions and 6 deletions

View File

@ -47,7 +47,7 @@ describe("Consume Asset", () => {
serviceAgreementSignatureResult = await ocean.agreements.prepare(ddo.id, accessService.serviceDefinitionId, consumer)
const {agreementId, signature} = serviceAgreementSignatureResult
assert.match(agreementId, /^[a-f0-9]{64}$/, "Service agreement ID seems not valid")
assert.match(agreementId, /^0x[a-f0-9]{64}$/, "Service agreement ID seems not valid")
assert.match(signature, /^0x[a-f0-9]{130}$/, "Service agreement signature seems not valid")
})

View File

@ -3,6 +3,7 @@ import save = require("save-file")
import { File } from "../ddo/MetaData"
import Account from "../ocean/Account"
import { noZeroX } from "../utils"
import WebServiceConnectorProvider from "../utils/WebServiceConnectorProvider"
import { Instantiable, InstantiableConfig } from "../Instantiable.abstract"
@ -76,13 +77,13 @@ export class Brizo extends Instantiable {
destination: string,
index: number = -1,
): Promise<string> {
const agreementIdSignature = await this.ocean.utils.signature.signText(agreementId, account.getId())
const agreementIdSignature = await this.ocean.utils.signature.signText(noZeroX(agreementId), account.getId())
const filesPromises = files
.filter(({}, i) => index === -1 || i === index)
.map(async ({index: i}) => {
let consumeUrl = serviceEndpoint
consumeUrl += `?index=${i}`
consumeUrl += `&serviceAgreementId=${agreementId}`
consumeUrl += `&serviceAgreementId=${noZeroX(agreementId)}`
consumeUrl += `&consumerAddress=${account.getId()}`
consumeUrl += `&signature=${agreementIdSignature}`

View File

@ -49,7 +49,7 @@ export class OceanAgreements extends Instantiable {
const d: DID = DID.parse(did as string)
const ddo = await this.ocean.aquarius.retrieveDDO(d)
const agreementId: string = generateId()
const agreementId: string = zeroX(generateId())
const templateName = ddo.findServiceByType("Access").serviceAgreementTemplate.contractName
const agreementConditionsIds = await this.ocean.keeper

View File

@ -4,7 +4,7 @@ import { MetaData } from "../ddo/MetaData"
import { Service } from "../ddo/Service"
import Account from "./Account"
import DID from "./DID"
import { fillConditionsWithDDO } from "../utils"
import { fillConditionsWithDDO, noZeroX } from "../utils"
import { Instantiable, InstantiableConfig } from "../Instantiable.abstract"
/**
@ -174,7 +174,7 @@ export class OceanAssets extends Instantiable {
this.logger.log("Consuming files")
resultPath = resultPath ? `${resultPath}/datafile.${ddo.shortId()}.${agreementId}/` : undefined
resultPath = resultPath ? `${resultPath}/datafile.${ddo.shortId()}.${noZeroX(agreementId)}/` : undefined
await this.ocean.brizo.consumeService(
agreementId,
serviceEndpoint,