diff --git a/src/aquarius/Aquarius.ts b/src/aquarius/Aquarius.ts index 1718322..0ece540 100644 --- a/src/aquarius/Aquarius.ts +++ b/src/aquarius/Aquarius.ts @@ -169,7 +169,7 @@ export class Aquarius extends Instantiable { } public getServiceEndpoint(did: DID) { - return `${this.url}/api/v1/aquarius/assets/metadata/${did.getId()}` + return `${this.url}/api/v1/aquarius/assets/ddo/did:op:${did.getId()}` } private transformResult( diff --git a/src/ddo/DDO.ts b/src/ddo/DDO.ts index 909757b..8798e33 100644 --- a/src/ddo/DDO.ts +++ b/src/ddo/DDO.ts @@ -33,7 +33,7 @@ export class DDO { return new DDO(ddo) } - public "@context": string = "https://w3id.org/future-method/v1" + public "@context": string = "https://w3id.org/did/v1" /** * DID, descentralized ID. @@ -102,7 +102,7 @@ export class DDO { this.id, ] - return Web3Provider.getWeb3().utils.sha3(values.join("")).replace(/^0x([a-f0-9]{32}).+$/i, "$1") + return Web3Provider.getWeb3().utils.sha3(values.join("")).replace(/^0x([a-f0-9]{64})(:!.+)?$/i, "$1") } /** @@ -118,7 +118,7 @@ export class DDO { const signature = await ocean.utils.signature.signText(checksum, publicKey, password) return { - created: (new Date()).toISOString(), + created: new Date().toISOString().replace(/\.[0-9]{3}/, ""), creator: publicKey, type: "DDOIntegritySignature", signatureValue: signature, diff --git a/src/ddo/MetaData.ts b/src/ddo/MetaData.ts index 2a8e2b1..2402df4 100644 --- a/src/ddo/MetaData.ts +++ b/src/ddo/MetaData.ts @@ -240,7 +240,7 @@ export interface AdditionalInformation { } export interface MetaData { - additionalInformation: AdditionalInformation + additionalInformation?: AdditionalInformation base: MetaDataBase - curation: Curation + curation?: Curation } diff --git a/src/ddo/PublicKey.ts b/src/ddo/PublicKey.ts index d459490..f911057 100644 --- a/src/ddo/PublicKey.ts +++ b/src/ddo/PublicKey.ts @@ -13,7 +13,7 @@ export interface PublicKey { * Type of key. * @type {string} */ - type: "Ed25519VerificationKey2018" | "RsaVerificationKey2018" | "EdDsaSAPublicKeySecp256k1" + type: "Ed25519VerificationKey2018" | "RsaVerificationKey2018" | "EdDsaSAPublicKeySecp256k1" | "EthereumECDSAKey" /** * Key owner. diff --git a/src/keeper/contracts/DIDRegistry.ts b/src/keeper/contracts/DIDRegistry.ts index 8627e77..c0c6686 100644 --- a/src/keeper/contracts/DIDRegistry.ts +++ b/src/keeper/contracts/DIDRegistry.ts @@ -15,7 +15,7 @@ export default class DIDRegistry extends ContractBase { return this.send( "registerAttribute", ownerAddress, - [zeroX(did), Web3Provider.getWeb3().utils.fromAscii(checksum), providers.map(zeroX), value], + [zeroX(did), zeroX(checksum), providers.map(zeroX), value], ) } diff --git a/src/keeper/contracts/templates/EscrowAccessSecretStoreTemplate.ts b/src/keeper/contracts/templates/EscrowAccessSecretStoreTemplate.ts index 3c9c982..0652adc 100644 --- a/src/keeper/contracts/templates/EscrowAccessSecretStoreTemplate.ts +++ b/src/keeper/contracts/templates/EscrowAccessSecretStoreTemplate.ts @@ -1,6 +1,4 @@ import { AgreementTemplate } from "./AgreementTemplate.abstract" -import { LockRewardCondition, EscrowReward, AccessSecretStoreCondition } from "../conditions" -import DIDRegistry from "../DIDRegistry" import { DDO } from "../../../ddo/DDO" import { generateId, zeroX } from "../../../utils" import { InstantiableConfig } from "../../../Instantiable.abstract" diff --git a/src/ocean/OceanAssets.ts b/src/ocean/OceanAssets.ts index 67c4884..14b9302 100644 --- a/src/ocean/OceanAssets.ts +++ b/src/ocean/OceanAssets.ts @@ -66,56 +66,45 @@ export class OceanAssets extends Instantiable { id: did.getDid(), authentication: [{ type: "RsaSignatureAuthentication2018", - publicKey: did.getDid() + "#keys-1", + publicKey: did.getDid(), }], publicKey: [ { - id: did.getDid() + "#keys-1", - type: "Ed25519VerificationKey2018", - owner: did.getDid(), - publicKeyBase58: await publisher.getPublicKey(), + id: did.getDid(), + type: "EthereumECDSAKey", + owner: publisher.getId(), }, ], service: [ { type: "Access", + creator: "", purchaseEndpoint: this.ocean.brizo.getPurchaseEndpoint(), serviceEndpoint: this.ocean.brizo.getConsumeEndpoint(), - serviceDefinitionId: String(serviceDefinitionIdCount++), + name: "dataAssetAccessServiceAgreement", templateId: templates.escrowAccessSecretStoreTemplate.getAddress(), serviceAgreementTemplate, }, - { - type: "Compute", - serviceEndpoint: this.ocean.brizo.getComputeEndpoint(publisher.getId(), String(serviceDefinitionIdCount), "xxx", "xxx"), - serviceDefinitionId: String(serviceDefinitionIdCount++), - }, { type: "Authorization", - services: "SecretStore", + service: "SecretStore", serviceEndpoint: secretStoreUri, - serviceDefinitionId: String(serviceDefinitionIdCount++), }, { type: "Metadata", serviceEndpoint, - serviceDefinitionId: String(serviceDefinitionIdCount++), metadata: { // Default values curation: { rating: 0, numVotes: 0, }, - additionalInformation: { - updateFrecuency: "yearly", - structuredMarkup: [], - }, // Overwrites defaults ...metadata, // Cleaning not needed information base: { ...metadata.base, - contentUrls: [], + contentUrls: undefined, encryptedFiles, files: metadata.base.files .map((file, index) => ({ @@ -126,13 +115,14 @@ export class OceanAssets extends Instantiable { } as any, }, }, - ...services - .map((_) => ({..._, serviceDefinitionId: String(serviceDefinitionIdCount++)})), + ...services, ] // Remove duplications .reverse() .filter(({type}, i, list) => list.findIndex(({type: t}) => t === type) === i) - .reverse() as Service[], + .reverse() + // Adding ID + .map((_) => ({..._, serviceDefinitionId: String(serviceDefinitionIdCount++)})) as Service[], }) // Overwritte initial service agreement conditions diff --git a/src/utils/DDOHelpers.ts b/src/utils/DDOHelpers.ts index bc9917a..1f41c2c 100644 --- a/src/utils/DDOHelpers.ts +++ b/src/utils/DDOHelpers.ts @@ -11,6 +11,8 @@ function fillParameterWithDDO(parameter: ServiceAgreementTemplateParameter, ddo: case "documentId": case "documentKeyId": return ddo.shortId() + case "rewardAddress": + return ddo.publicKey[0].owner } return "" diff --git a/test/ddo/DDO.test.ts b/test/ddo/DDO.test.ts index 1459913..fa7f98f 100644 --- a/test/ddo/DDO.test.ts +++ b/test/ddo/DDO.test.ts @@ -247,7 +247,7 @@ describe("DDO", () => { const ddo = new DDO(testDDO) const checksum = ddo.getChecksum() - assert.equal(checksum, "15f27a7a3c7b15d2b06dec7347c6b8da") + assert.equal(checksum, "15f27a7a3c7b15d2b06dec7347c6b8da168adddd7df51a8ebbbe87b59b80049b") }) })