diff --git a/src/aquarius/Aquarius.ts b/src/aquarius/Aquarius.ts index fd619a2..1af11e8 100644 --- a/src/aquarius/Aquarius.ts +++ b/src/aquarius/Aquarius.ts @@ -274,16 +274,7 @@ export class Aquarius { if (newMetadata.title != null) data.title = newMetadata.title if (newMetadata.servicePrices != null) data.servicePrices = newMetadata.servicePrices - if (newMetadata.links != null) { - data.links = [] - for (const [name, url] of Object.entries(newMetadata.links)) { - const asample = Object() - asample.name = name - asample.url = url - asample.type = 'sample' - data.links.push(asample) - } - } + if (newMetadata.links != null) data.links = newMetadata.links data.updated = updated data.signature = signature const result = await this.fetch @@ -293,7 +284,7 @@ export class Aquarius { return response.text } this.logger.log( - 'transferownership failed:', + 'editMetaData failed:', response.status, response.statusText ) @@ -327,11 +318,7 @@ export class Aquarius { if (response.ok) { return response.text } - this.logger.log( - 'transferownership failed:', - response.status, - response.statusText - ) + this.logger.log('retire failed:', response.status, response.statusText) return null }) diff --git a/src/ddo/MetaData.ts b/src/ddo/MetaData.ts index 6654eae..228ebbb 100644 --- a/src/ddo/MetaData.ts +++ b/src/ddo/MetaData.ts @@ -282,9 +282,15 @@ export interface ServicePrices { price: string } +export interface EditableMetaDataLinks { + name: string + url: string + type: string +} + export interface EditableMetaData { description?: string title?: string - links?: { [name: string]: string }[] + links?: EditableMetaDataLinks[] servicePrices?: ServicePrices[] } diff --git a/test/integration/ocean/AssetOwners.test.ts b/test/integration/ocean/AssetOwners.test.ts index 2a9eda3..23b9398 100644 --- a/test/integration/ocean/AssetOwners.test.ts +++ b/test/integration/ocean/AssetOwners.test.ts @@ -114,8 +114,35 @@ describe('Asset Owners', () => { it('should be able to update metadata', async () => { const { id } = await ocean.assets.create(metadata as any, account1) + const links = [ + { + name: 'Sample1', + url: 'http://www.example.com', + type: 'sample' + }, + { + name: 'Sample2', + url: 'http://www.example.net', + type: 'sample' + } + ] + const newPrices = [ + { + serviceIndex: 0, + price: '31000000000000000000' + }, + { + serviceIndex: 2, + price: '31000000000000000000' + } + ] - const newMetaData = { title: 'New title', description: 'New description' } + const newMetaData = { + title: 'New title', + description: 'New description', + links: links, + servicePrices: newPrices + } await ocean.assets.editMetadata(id, newMetaData, account1) const newDDO = await ocean.assets.resolve(id) @@ -125,6 +152,24 @@ describe('Asset Owners', () => { newDDO.service[0].attributes.additionalInformation.description, 'New description' ) + assert.equal(newDDO.service[0].attributes.main.price, '31000000000000000000') + assert.equal(newDDO.service[2].attributes.main.price, '31000000000000000000') + assert.equal( + newDDO.service[0].attributes.additionalInformation.links[0].name, + 'Sample1' + ) + assert.equal( + newDDO.service[0].attributes.additionalInformation.links[0].url, + 'http://www.example.com' + ) + assert.equal( + newDDO.service[0].attributes.additionalInformation.links[1].name, + 'Sample2' + ) + assert.equal( + newDDO.service[0].attributes.additionalInformation.links[1].url, + 'http://www.example.net' + ) }) it('should be able to retire metadata', async () => {