1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

allow editable author (#936)

This commit is contained in:
Alex Coseru 2021-07-29 10:44:51 +03:00 committed by GitHub
parent c4aea91373
commit 9925cc9d95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 0 deletions

View File

@ -3,6 +3,7 @@ import { Status } from './Status'
export interface EditableMetadata {
description?: string
author?: string
title?: string
links?: EditableMetadataLinks[]
status?: Status

View File

@ -268,6 +268,7 @@ export class Assets extends Instantiable {
for (let i = 0; i < ddo.service.length; i++) {
if (ddo.service[i].type !== 'metadata') continue
if (newMetadata.title) ddo.service[i].attributes.main.name = newMetadata.title
if (newMetadata.author) ddo.service[i].attributes.main.author = newMetadata.author
if (!ddo.service[i].attributes.additionalInformation)
ddo.service[i].attributes.additionalInformation = Object()
if (newMetadata.description)

View File

@ -554,6 +554,19 @@ describe('Marketplace flow', () => {
assert.deepEqual(metaData.attributes.additionalInformation.links, [])
})
it('Alice updates the author', async () => {
const newMetaData: EditableMetadata = {
author: 'SuperAlice'
}
const newDdo = await ocean.assets.editMetadata(ddo, newMetaData)
assert(newDdo !== null)
const txid = await ocean.onChainMetadata.update(newDdo.id, newDdo, alice.getId())
assert(txid !== null)
await sleep(60000)
const metaData = await ocean.assets.getServiceByType(ddo.id, 'metadata')
assert(metaData.attributes.main.author, newMetaData.author)
})
it('Alice updates metadata and removes sample links with encrypted ddo', async () => {
const newMetaData: EditableMetadata = {
description: 'new description no links',