1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

merge main into v4-c2d and fixed conflicts

This commit is contained in:
Bogdan Fazakas 2022-06-17 07:18:43 +03:00
commit a8ca31f02e
12 changed files with 64 additions and 33 deletions

View File

@ -30,13 +30,22 @@
"required": true
},
{
"name": "links",
"label": "Sample file",
"placeholder": "e.g. https://file.com/samplefile.json",
"help": "Please provide a URL to a sample of your data set file. This file should reveal the data structure of your data set, e.g. by including the header and one line of a CSV file. This file URL will be publicly available after publishing. **Please make sure that the endpoint is accessible over the internet and is not protected by a firewall or by credentials.**",
"name": "files",
"label": "New file",
"placeholder": "e.g. https://file.com/file.json",
"help": "This URL will be stored encrypted after publishing. **Please make sure that the endpoint is accessible over the internet and is not protected by a firewall or by credentials.** For a compute data set, your file should match the file type required by the algorithm, and should not exceed 1 GB in file size. Leaving this field empty will not remove the current value.",
"prominentHelp": true,
"type": "files"
},
{
"name": "links",
"label": "New sample file",
"placeholder": "e.g. https://file.com/samplefile.json",
"help": "Please provide a URL to a sample of your data set file. This file should reveal the data structure of your data set, e.g. by including the header and one line of a CSV file. This file URL will be publicly available after publishing. **Please make sure that the endpoint is accessible over the internet and is not protected by a firewall or by credentials.** Leaving this field empty will not remove the current value.",
"prominentHelp": true,
"type": "files"
},
{
"name": "timeout",
"label": "Timeout",

View File

@ -3,7 +3,7 @@ import {
ComputeAsset,
ComputeEnvironment,
downloadFileBrowser,
FileInfo as FileInfoData,
FileInfo,
LoggerInstance,
ProviderComputeInitializeResults,
ProviderInstance
@ -69,7 +69,7 @@ export async function getFileDidInfo(
did: string,
serviceId: string,
providerUrl: string
): Promise<FileInfoData[]> {
): Promise<FileInfo[]> {
try {
const response = await ProviderInstance.checkDidFiles(
did,
@ -85,7 +85,7 @@ export async function getFileDidInfo(
export async function getFileUrlInfo(
url: string,
providerUrl: string
): Promise<FileInfoData[]> {
): Promise<FileInfo[]> {
try {
const response = await ProviderInstance.checkFileUrl(url, providerUrl)
return response

View File

@ -4,7 +4,7 @@ import classNames from 'classnames/bind'
import cleanupContentType from '@utils/cleanupContentType'
import styles from './index.module.css'
import Loader from '@shared/atoms/Loader'
import { FileInfo as FileInfoData } from '@oceanprotocol/lib'
import { FileInfo } from '@oceanprotocol/lib'
const cx = classNames.bind(styles)
@ -22,7 +22,7 @@ export default function FileIcon({
small,
isLoading
}: {
file: FileInfoData
file: FileInfo
className?: string
small?: boolean
isLoading?: boolean

View File

@ -2,7 +2,7 @@ import React, { useState, ReactElement, useEffect, useCallback } from 'react'
import {
Asset,
DDO,
FileInfo as FileInfoData,
FileInfo,
Datatoken,
ProviderInstance,
ComputeAsset,
@ -60,7 +60,7 @@ export default function Compute({
}: {
asset: AssetExtended
dtBalance: string
file: FileInfoData
file: FileInfo
fileIsLoading?: boolean
isConsumable?: boolean
consumableFeedback?: string

View File

@ -7,11 +7,7 @@ import ButtonBuy from '@shared/ButtonBuy'
import { secondsToString } from '@utils/ddo'
import AlgorithmDatasetsListForCompute from './Compute/AlgorithmDatasetsListForCompute'
import styles from './Download.module.css'
import {
FileInfo as FileInfoData,
LoggerInstance,
ZERO_ADDRESS
} from '@oceanprotocol/lib'
import { FileInfo, LoggerInstance, ZERO_ADDRESS } from '@oceanprotocol/lib'
import { order } from '@utils/order'
import { AssetExtended } from 'src/@types/AssetExtended'
import { buyDtFromPool } from '@utils/pool'
@ -33,7 +29,7 @@ export default function Download({
consumableFeedback
}: {
asset: AssetExtended
file: FileInfoData
file: FileInfo
isBalanceSufficient: boolean
dtBalance: string
fileIsLoading?: boolean

View File

@ -1,11 +1,7 @@
import React, { ReactElement, useState, useEffect } from 'react'
import Compute from './Compute'
import Consume from './Download'
import {
FileInfo as FileInfoData,
LoggerInstance,
Datatoken
} from '@oceanprotocol/lib'
import { FileInfo, LoggerInstance, Datatoken } from '@oceanprotocol/lib'
import Tabs, { TabsItem } from '@shared/atoms/Tabs'
import { compareAsBN } from '@utils/numbers'
import Pool from './Pool'
@ -41,7 +37,7 @@ export default function AssetActions({
const [isBalanceSufficient, setIsBalanceSufficient] = useState<boolean>()
const [dtBalance, setDtBalance] = useState<string>()
const [fileMetadata, setFileMetadata] = useState<FileInfoData>()
const [fileMetadata, setFileMetadata] = useState<FileInfo>()
const [fileIsLoading, setFileIsLoading] = useState<boolean>(false)
const isCompute = Boolean(
asset?.services.filter((service) => service.type === 'compute')[0]

View File

@ -24,6 +24,7 @@ import EditFeedback from './EditFeedback'
import { useAsset } from '@context/Asset'
import { setNftMetadata } from '@utils/nft'
import { sanitizeUrl } from '@utils/url'
import { getEncryptedFiles } from '@utils/provider'
export default function Edit({
asset
@ -64,6 +65,7 @@ export default function Edit({
resetForm: () => void
) {
try {
let updatedFiles = asset.services[0].files
const linksTransformed = values.links?.length &&
values.links[0].valid && [sanitizeUrl(values.links[0].url)]
const updatedMetadata: Metadata = {
@ -78,17 +80,43 @@ export default function Edit({
values.price !== asset.accessDetails.price &&
(await updateFixedPrice(values.price))
if (values.files[0]?.url) {
const file = {
nftAddress: asset.nftAddress,
datatokenAddress: asset.services[0].datatokenAddress,
files: [
{
type: 'url',
index: 0,
url: values.files[0].url,
method: 'GET'
}
]
}
const filesEncrypted = await getEncryptedFiles(
file,
asset.services[0].serviceEndpoint
)
updatedFiles = filesEncrypted
}
const updatedService: Service = {
...asset.services[0],
timeout: mapTimeoutStringToSeconds(values.timeout)
timeout: mapTimeoutStringToSeconds(values.timeout),
files: updatedFiles
}
// TODO: remove version update at a later time
const updatedAsset: Asset = {
...asset,
...(asset as Asset),
version: '4.1.0',
metadata: updatedMetadata,
services: [updatedService]
}
// delete custom helper properties injected in the market so we don't write them on chain
delete (updatedAsset as AssetExtended).accessDetails
delete (updatedAsset as AssetExtended).datatokens
delete (updatedAsset as AssetExtended).stats
const setMetadataTx = await setNftMetadata(
updatedAsset,
accountId,

View File

@ -1,9 +1,8 @@
import React, { ChangeEvent, ReactElement, useState } from 'react'
import React, { ChangeEvent, ReactElement } from 'react'
import { Field, Form, FormikContextType, useFormikContext } from 'formik'
import Input, { InputProps } from '@shared/FormInput'
import FormActions from './FormActions'
import styles from './FormEdit.module.css'
import { FormPublishData } from '../../Publish/_types'
import { useAsset } from '@context/Asset'
import { MetadataEditForm } from './_types'

View File

@ -1,4 +1,4 @@
import { Metadata, ServiceComputeOptions } from '@oceanprotocol/lib'
import { FileInfo, Metadata, ServiceComputeOptions } from '@oceanprotocol/lib'
import { secondsToString } from '@utils/ddo'
import * as Yup from 'yup'
import { MetadataEditForm } from './_types'
@ -10,6 +10,7 @@ export const validationSchema = Yup.object().shape({
description: Yup.string().required('Required').min(10),
price: Yup.number().required('Required'),
links: Yup.array<any[]>().nullable(),
files: Yup.array<FileInfo[]>().nullable(),
timeout: Yup.string().required('Required'),
author: Yup.string().nullable()
})
@ -24,6 +25,7 @@ export function getInitialValues(
description: metadata?.description,
price,
links: metadata?.links,
files: '',
timeout: secondsToString(timeout),
author: metadata?.author
}

View File

@ -6,5 +6,6 @@ export interface MetadataEditForm {
timeout: string
price?: string
links?: string | any[]
files: string | any[]
author?: string
}

View File

@ -3,7 +3,7 @@ import { NftMetadata } from '@utils/nft'
import { ReactElement } from 'react'
import { PriceOptions } from 'src/@types/Price'
interface FileMetadata {
interface FileInfo {
url: string
valid?: boolean
contentLength?: string
@ -11,8 +11,8 @@ interface FileMetadata {
}
export interface FormPublishService {
files: FileMetadata[]
links?: FileMetadata[]
files: FileInfo[]
links?: FileInfo[]
timeout: string
dataTokenOptions: { name: string; symbol: string }
access: 'Download' | 'Compute' | string

View File

@ -146,7 +146,7 @@ export const validationSchema: Yup.SchemaOf<any> = Yup.object().shape({
// .min(4, (param) => `Title must be at least ${param.min} characters`)
// .required('Required'),
// description: Yup.string().min(10).required('Required'),
// files: Yup.array<FileMetadata>().required('Required').nullable(),
// files: Yup.array<FileInfo>().required('Required').nullable(),
// timeout: Yup.string().required('Required'),
// dataTokenOptions: Yup.object()
// .shape({
@ -167,6 +167,6 @@ export const validationSchema: Yup.SchemaOf<any> = Yup.object().shape({
// // ---- optional fields ----
// algorithmPrivacy: Yup.boolean().nullable(),
// tags: Yup.string().nullable(),
// links: Yup.array<FileMetadata[]>().nullable()
// links: Yup.array<FileInfo[]>().nullable()
// })
// .defined()