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:
parent
1c6dcf2d1e
commit
1e94e27f81
@ -47,7 +47,7 @@ describe("Consume Asset", () => {
|
|||||||
serviceAgreementSignatureResult = await ocean.agreements.prepare(ddo.id, accessService.serviceDefinitionId, consumer)
|
serviceAgreementSignatureResult = await ocean.agreements.prepare(ddo.id, accessService.serviceDefinitionId, consumer)
|
||||||
|
|
||||||
const {agreementId, signature} = serviceAgreementSignatureResult
|
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")
|
assert.match(signature, /^0x[a-f0-9]{130}$/, "Service agreement signature seems not valid")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ import save = require("save-file")
|
|||||||
|
|
||||||
import { File } from "../ddo/MetaData"
|
import { File } from "../ddo/MetaData"
|
||||||
import Account from "../ocean/Account"
|
import Account from "../ocean/Account"
|
||||||
|
import { noZeroX } from "../utils"
|
||||||
import WebServiceConnectorProvider from "../utils/WebServiceConnectorProvider"
|
import WebServiceConnectorProvider from "../utils/WebServiceConnectorProvider"
|
||||||
import { Instantiable, InstantiableConfig } from "../Instantiable.abstract"
|
import { Instantiable, InstantiableConfig } from "../Instantiable.abstract"
|
||||||
|
|
||||||
@ -76,13 +77,13 @@ export class Brizo extends Instantiable {
|
|||||||
destination: string,
|
destination: string,
|
||||||
index: number = -1,
|
index: number = -1,
|
||||||
): Promise<string> {
|
): 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
|
const filesPromises = files
|
||||||
.filter(({}, i) => index === -1 || i === index)
|
.filter(({}, i) => index === -1 || i === index)
|
||||||
.map(async ({index: i}) => {
|
.map(async ({index: i}) => {
|
||||||
let consumeUrl = serviceEndpoint
|
let consumeUrl = serviceEndpoint
|
||||||
consumeUrl += `?index=${i}`
|
consumeUrl += `?index=${i}`
|
||||||
consumeUrl += `&serviceAgreementId=${agreementId}`
|
consumeUrl += `&serviceAgreementId=${noZeroX(agreementId)}`
|
||||||
consumeUrl += `&consumerAddress=${account.getId()}`
|
consumeUrl += `&consumerAddress=${account.getId()}`
|
||||||
consumeUrl += `&signature=${agreementIdSignature}`
|
consumeUrl += `&signature=${agreementIdSignature}`
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ export class OceanAgreements extends Instantiable {
|
|||||||
|
|
||||||
const d: DID = DID.parse(did as string)
|
const d: DID = DID.parse(did as string)
|
||||||
const ddo = await this.ocean.aquarius.retrieveDDO(d)
|
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 templateName = ddo.findServiceByType("Access").serviceAgreementTemplate.contractName
|
||||||
const agreementConditionsIds = await this.ocean.keeper
|
const agreementConditionsIds = await this.ocean.keeper
|
||||||
|
@ -4,7 +4,7 @@ import { MetaData } from "../ddo/MetaData"
|
|||||||
import { Service } from "../ddo/Service"
|
import { Service } from "../ddo/Service"
|
||||||
import Account from "./Account"
|
import Account from "./Account"
|
||||||
import DID from "./DID"
|
import DID from "./DID"
|
||||||
import { fillConditionsWithDDO } from "../utils"
|
import { fillConditionsWithDDO, noZeroX } from "../utils"
|
||||||
import { Instantiable, InstantiableConfig } from "../Instantiable.abstract"
|
import { Instantiable, InstantiableConfig } from "../Instantiable.abstract"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -174,7 +174,7 @@ export class OceanAssets extends Instantiable {
|
|||||||
|
|
||||||
this.logger.log("Consuming files")
|
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(
|
await this.ocean.brizo.consumeService(
|
||||||
agreementId,
|
agreementId,
|
||||||
serviceEndpoint,
|
serviceEndpoint,
|
||||||
|
Loading…
Reference in New Issue
Block a user