mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
ddo updates
This commit is contained in:
parent
a865556394
commit
4e985ba633
@ -81,7 +81,7 @@ function usePublish(): UsePublish {
|
||||
new Date(Date.now()).toISOString().split('.')[0] + 'Z'
|
||||
const services: Service[] = []
|
||||
const price = '1'
|
||||
asset.created = publishedDate
|
||||
asset.metadata.created = publishedDate
|
||||
|
||||
switch (serviceType) {
|
||||
case 'access': {
|
||||
|
2
src/@types/DDO/Metadata.d.ts
vendored
2
src/@types/DDO/Metadata.d.ts
vendored
@ -10,6 +10,8 @@ interface MetadataAlgorithm {
|
||||
}
|
||||
|
||||
interface Metadata {
|
||||
created: string
|
||||
updated: string
|
||||
name: string
|
||||
description: string
|
||||
type: 'dataset' | 'algorithm'
|
||||
|
10
src/@types/DDO/Services.d.ts
vendored
10
src/@types/DDO/Services.d.ts
vendored
@ -4,7 +4,13 @@ interface PublisherTrustedAlgorithm {
|
||||
containerSectionChecksum: string
|
||||
}
|
||||
|
||||
interface ServiceComputePrivacy {
|
||||
interface ServiceComputeOptions {
|
||||
namespace: string
|
||||
cpu?: number
|
||||
gpu?: number
|
||||
gpuType?: string
|
||||
memory?: string
|
||||
volumeSize?: string
|
||||
allowRawAlgorithm: boolean
|
||||
allowNetworkAccess: boolean
|
||||
publisherTrustedAlgorithmPublishers: string[]
|
||||
@ -19,5 +25,5 @@ interface Service {
|
||||
timeout: string
|
||||
name?: string
|
||||
description?: string
|
||||
privacy?: ServiceComputePrivacy
|
||||
compute?: ServiceComputeOptions
|
||||
}
|
||||
|
2
src/@types/DDO/index.d.ts
vendored
2
src/@types/DDO/index.d.ts
vendored
@ -4,8 +4,6 @@ interface DDO {
|
||||
id: string
|
||||
version: string
|
||||
chainId: number
|
||||
created: string
|
||||
updated?: string
|
||||
metadata: Metadata
|
||||
services: Service[]
|
||||
credentials?: Credentials
|
||||
|
@ -1,5 +1,4 @@
|
||||
import slugify from 'slugify'
|
||||
import { MetadataAlgorithm } from '@oceanprotocol/lib'
|
||||
|
||||
export function getServiceByName(
|
||||
ddo: Asset | DDO,
|
||||
@ -80,25 +79,7 @@ export function checkIfTimeoutInPredefinedValues(
|
||||
return false
|
||||
}
|
||||
|
||||
export function getAlgorithmComponent(
|
||||
image: string,
|
||||
containerTag: string,
|
||||
entrypoint: string,
|
||||
algorithmLanguage: string
|
||||
): MetadataAlgorithm {
|
||||
return {
|
||||
language: algorithmLanguage,
|
||||
format: 'docker-image',
|
||||
version: '0.1',
|
||||
container: {
|
||||
entrypoint: entrypoint,
|
||||
image: image,
|
||||
tag: containerTag
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getAlgorithmFileExtension(fileUrl: string): string {
|
||||
export function getUrlFileExtension(fileUrl: string): string {
|
||||
const splitedFileUrl = fileUrl.split('.')
|
||||
return splitedFileUrl[splitedFileUrl.length - 1]
|
||||
}
|
||||
|
@ -139,15 +139,15 @@ export default function Compute({
|
||||
const computeService = ddo.services[0]
|
||||
let algorithmSelectionList: AssetSelectionAsset[]
|
||||
if (
|
||||
!computeService.privacy ||
|
||||
!computeService.privacy.publisherTrustedAlgorithms ||
|
||||
computeService.privacy.publisherTrustedAlgorithms.length === 0
|
||||
!computeService.compute ||
|
||||
!computeService.compute.publisherTrustedAlgorithms ||
|
||||
computeService.compute.publisherTrustedAlgorithms.length === 0
|
||||
) {
|
||||
algorithmSelectionList = []
|
||||
} else {
|
||||
const gueryResults = await queryMetadata(
|
||||
getQuerryString(
|
||||
computeService.privacy.publisherTrustedAlgorithms,
|
||||
computeService.compute.publisherTrustedAlgorithms,
|
||||
ddo.chainId
|
||||
),
|
||||
source.token
|
||||
|
@ -35,7 +35,7 @@ export default function FormEditComputeDataset({
|
||||
const { publisherTrustedAlgorithms } = getServiceByName(
|
||||
ddo,
|
||||
'compute'
|
||||
).privacy
|
||||
).compute
|
||||
|
||||
async function getAlgorithmList(
|
||||
publisherTrustedAlgorithms: PublisherTrustedAlgorithm[]
|
||||
|
@ -75,7 +75,7 @@ export default function EditHistory(): ReactElement {
|
||||
))}
|
||||
<li className={styles.item}>
|
||||
<ExplorerLink networkId={ddo.chainId} path={`/tx/${creationTx}`}>
|
||||
published <Time date={ddo.created} relative />
|
||||
published <Time date={ddo.metadata.created} relative />
|
||||
</ExplorerLink>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -55,12 +55,12 @@ export default function MetaMain(): ReactElement {
|
||||
<div className={styles.byline}>
|
||||
Published By <Publisher account={owner} />
|
||||
<p>
|
||||
<Time date={ddo?.created} relative />
|
||||
{ddo?.created !== ddo?.updated && (
|
||||
<Time date={ddo?.metadata.created} relative />
|
||||
{ddo?.metadata.created !== ddo?.metadata.updated && (
|
||||
<>
|
||||
{' — '}
|
||||
<span className={styles.updated}>
|
||||
updated <Time date={ddo?.updated} relative />
|
||||
updated <Time date={ddo?.metadata.updated} relative />
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
|
@ -1,8 +1,7 @@
|
||||
import {
|
||||
dateToStringNoMS,
|
||||
transformTags,
|
||||
getAlgorithmComponent,
|
||||
getAlgorithmFileExtension
|
||||
getUrlFileExtension
|
||||
} from '@utils/ddo'
|
||||
import { FormPublishData } from './_types'
|
||||
|
||||
@ -19,8 +18,8 @@ export function getFieldContent(
|
||||
|
||||
export function transformPublishFormToDdo(data: Partial<FormPublishData>): DDO {
|
||||
const currentTime = dateToStringNoMS(new Date())
|
||||
const { type } = data.metadata
|
||||
const { name, description, tags, author, termsAndConditions } = data.metadata
|
||||
const { type, name, description, tags, author, termsAndConditions } =
|
||||
data.metadata
|
||||
const {
|
||||
access,
|
||||
files,
|
||||
@ -33,43 +32,62 @@ export function transformPublishFormToDdo(data: Partial<FormPublishData>): DDO {
|
||||
} = data.services[0]
|
||||
|
||||
const fileUrl = typeof files !== 'string' && files[0].url
|
||||
const filesEncrypted = encryptMe(files)
|
||||
|
||||
const metadata: Metadata = {
|
||||
created: currentTime,
|
||||
updated: currentTime,
|
||||
type,
|
||||
name,
|
||||
description,
|
||||
tags: transformTags(tags),
|
||||
author,
|
||||
license: 'https://market.oceanprotocol.com/terms',
|
||||
links,
|
||||
additionalInformation: {
|
||||
termsAndConditions
|
||||
},
|
||||
...(type === 'algorithm' && {
|
||||
algorithm: {
|
||||
language: getUrlFileExtension(fileUrl),
|
||||
version: '0.1',
|
||||
container: {
|
||||
entrypoint: entrypoint,
|
||||
image: image,
|
||||
tag: containerTag,
|
||||
checksum: ''
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const service: Service = {
|
||||
type: access,
|
||||
files: filesEncrypted,
|
||||
files: encryptMe(files),
|
||||
datatokenAddress: '', // how to get before publish?
|
||||
serviceEndpoint: providerUrl,
|
||||
timeout
|
||||
timeout,
|
||||
...(access === 'compute' && {
|
||||
compute: {
|
||||
namespace: '',
|
||||
cpu: 1,
|
||||
gpu: 1,
|
||||
gpuType: '',
|
||||
memory: '',
|
||||
volumeSize: '',
|
||||
allowRawAlgorithm: false,
|
||||
allowNetworkAccess: false,
|
||||
publisherTrustedAlgorithmPublishers: null,
|
||||
publisherTrustedAlgorithms: null
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const newDdo: DDO = {
|
||||
'@context': ['https://w3id.org/did/v1'],
|
||||
id: '', // how to get before publish? sha256(address of ERC721 contract + data.chainId)
|
||||
version: '4.0.0',
|
||||
created: currentTime,
|
||||
updated: currentTime,
|
||||
chainId: data.chainId,
|
||||
metadata: {
|
||||
type,
|
||||
name,
|
||||
description,
|
||||
tags: transformTags(tags),
|
||||
author,
|
||||
license: 'https://market.oceanprotocol.com/terms',
|
||||
links,
|
||||
additionalInformation: {
|
||||
termsAndConditions
|
||||
},
|
||||
...(type === 'algorithm' && {
|
||||
...getAlgorithmComponent(
|
||||
image,
|
||||
containerTag,
|
||||
entrypoint,
|
||||
getAlgorithmFileExtension(fileUrl)
|
||||
)
|
||||
})
|
||||
},
|
||||
metadata,
|
||||
services: [service]
|
||||
}
|
||||
|
||||
|
@ -93,18 +93,16 @@ export default function PublishPage({
|
||||
// await handleSubmit(values, resetForm)
|
||||
}}
|
||||
>
|
||||
{({ values }) => {
|
||||
return (
|
||||
<>
|
||||
<Form className={styles.form} ref={scrollToRef}>
|
||||
<Navigation />
|
||||
<Steps step={values.step} />
|
||||
<Actions scrollToRef={scrollToRef} />
|
||||
</Form>
|
||||
<Debug values={values} />
|
||||
</>
|
||||
)
|
||||
}}
|
||||
{({ values }) => (
|
||||
<>
|
||||
<Form className={styles.form} ref={scrollToRef}>
|
||||
<Navigation />
|
||||
<Steps step={values.step} />
|
||||
<Actions scrollToRef={scrollToRef} />
|
||||
</Form>
|
||||
<Debug values={values} />
|
||||
</>
|
||||
)}
|
||||
</Formik>
|
||||
)}
|
||||
</>
|
||||
|
Loading…
Reference in New Issue
Block a user