mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
lint
This commit is contained in:
parent
5289443cde
commit
8bfa7ba593
@ -5,7 +5,6 @@ import { EditableMetaData } from '../ddo/MetaData'
|
||||
import { Logger } from '../utils'
|
||||
import { WebServiceConnector } from '../ocean/utils/WebServiceConnector'
|
||||
|
||||
|
||||
const apiPath = '/api/v1/aquarius/assets/ddo'
|
||||
|
||||
export interface QueryResult {
|
||||
@ -262,7 +261,6 @@ export class Aquarius {
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
public async editMetadata(
|
||||
did: DID | string,
|
||||
newMetadata: EditableMetaData,
|
||||
@ -271,17 +269,15 @@ export class Aquarius {
|
||||
): Promise<string> {
|
||||
did = did && DID.parse(did)
|
||||
const fullUrl = `${this.url}${apiPath}/metadata/update/${did.getDid()}`
|
||||
let data = Object()
|
||||
if (newMetadata.description != null)
|
||||
data.description = newMetadata.description
|
||||
if (newMetadata.title != null)
|
||||
data.title = newMetadata.title
|
||||
const data = Object()
|
||||
if (newMetadata.description != null) data.description = newMetadata.description
|
||||
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)) {
|
||||
let asample = Object()
|
||||
const asample = Object()
|
||||
asample.name = name
|
||||
asample.url = url
|
||||
asample.type = 'sample'
|
||||
@ -291,10 +287,7 @@ export class Aquarius {
|
||||
data.updated = updated
|
||||
data.signature = signature
|
||||
const result = await this.fetch
|
||||
.put(
|
||||
fullUrl,
|
||||
JSON.stringify(data)
|
||||
)
|
||||
.put(fullUrl, JSON.stringify(data))
|
||||
.then((response: any) => {
|
||||
if (response.ok) {
|
||||
return response.text
|
||||
@ -350,7 +343,6 @@ export class Aquarius {
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
public getServiceEndpoint(did: DID) {
|
||||
return `${this.url}/api/v1/aquarius/assets/ddo/did:op:${did.getId()}`
|
||||
}
|
||||
|
@ -278,13 +278,13 @@ export interface MetaData {
|
||||
}
|
||||
|
||||
export interface ServicePrices {
|
||||
serviceIndex: number,
|
||||
serviceIndex: number
|
||||
price: string
|
||||
}
|
||||
|
||||
export interface EditableMetaData {
|
||||
description?: string,
|
||||
title?: string,
|
||||
links?: { [name: string]: string }[],
|
||||
description?: string
|
||||
title?: string
|
||||
links?: { [name: string]: string }[]
|
||||
servicePrices?: ServicePrices[]
|
||||
}
|
||||
|
@ -407,10 +407,7 @@ export class OceanAssets extends Instantiable {
|
||||
return result
|
||||
}
|
||||
|
||||
public async retire(
|
||||
did: string,
|
||||
account: Account
|
||||
): Promise<string> {
|
||||
public async retire(did: string, account: Account): Promise<string> {
|
||||
const oldDdo = await this.ocean.aquarius.retrieveDDO(did)
|
||||
// get a signature
|
||||
const signature = await this.ocean.utils.signature.signForAquarius(
|
||||
|
@ -52,8 +52,7 @@ export class WebServiceConnector {
|
||||
'Content-type': 'application/json'
|
||||
}
|
||||
})
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return this.fetch(url, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
@ -61,7 +60,6 @@ export class WebServiceConnector {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async downloadFile(
|
||||
|
@ -115,13 +115,16 @@ describe('Asset Owners', () => {
|
||||
it('should be able to update metadata', async () => {
|
||||
const { id } = await ocean.assets.create(metadata as any, account1)
|
||||
|
||||
let newMetaData = {title: "New title", description: "New description"};
|
||||
const newMetaData = { title: 'New title', description: 'New description' }
|
||||
await ocean.assets.editMetadata(id, newMetaData, account1)
|
||||
|
||||
const newDDO = await ocean.assets.resolve(id)
|
||||
|
||||
assert.equal(newDDO['service'][0]['attributes']['main']['name'], "New title")
|
||||
assert.equal(newDDO['service'][0]['attributes']['additionalInformation']['description'], "New description")
|
||||
assert.equal(newDDO.service[0].attributes.main.name, 'New title')
|
||||
assert.equal(
|
||||
newDDO.service[0].attributes.additionalInformation.description,
|
||||
'New description'
|
||||
)
|
||||
})
|
||||
|
||||
it('should be able to retire metadata', async () => {
|
||||
@ -132,6 +135,5 @@ describe('Asset Owners', () => {
|
||||
const newDDO = await ocean.assets.resolve(id)
|
||||
|
||||
assert.equal(newDDO, null)
|
||||
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user