Skip to content

Commit

Permalink
Merge pull request deltaDAO#485 from deltaDAO/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
moritzkirstein committed Nov 29, 2023
2 parents 8ae7799 + e2a49f6 commit c92d901
Show file tree
Hide file tree
Showing 10 changed files with 218 additions and 44,047 deletions.
44,174 changes: 157 additions & 44,017 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/@utils/assetConvertor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { PublisherTrustedAlgorithm, Asset } from '@oceanprotocol/lib'
import { AssetSelectionAsset } from '@shared/FormInput/InputElement/AssetSelection'
import { getServiceByName, isAddressWhitelisted } from './ddo'
import normalizeUrl from 'normalize-url'

export async function transformAssetToAssetSelection(
datasetProviderEndpoint: string,
Expand All @@ -16,7 +17,8 @@ export async function transformAssetToAssetSelection(

if (
asset?.stats?.price?.value >= 0 &&
algoService?.serviceEndpoint === datasetProviderEndpoint
normalizeUrl(algoService?.serviceEndpoint) ===
normalizeUrl(datasetProviderEndpoint)
) {
let selected = false
selectedAlgorithms?.forEach((algorithm: PublisherTrustedAlgorithm) => {
Expand Down
6 changes: 4 additions & 2 deletions src/@utils/compute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ export function getQueryString(
const baseParams = {
chainIds: [chainId],
sort: { sortBy: SortTermOptions.Created },
filters: [getFilterTerm('metadata.type', 'algorithm')]
filters: [getFilterTerm('metadata.type', 'algorithm')],
esPaginationOptions: {
size: 3000
}
} as BaseQueryParams
algorithmDidList?.length > 0 &&
baseParams.filters.push(getFilterTerm('_id', algorithmDidList))
Expand Down Expand Up @@ -209,7 +212,6 @@ export async function getAlgorithmsForAsset(
),
token
)

const algorithms: Asset[] = gueryResults?.results
return algorithms
}
Expand Down
1 change: 1 addition & 0 deletions src/components/Asset/AssetActions/Compute/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ export default function Compute({
asset.metadata.type
)[0]
)

await setDatasetPrice(initializedProvider?.datasets?.[0]?.providerFee)
setComputeStatusText(
getComputeFeedback(
Expand Down
6 changes: 5 additions & 1 deletion src/components/Asset/AssetActions/Download/_validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ export function getDownloadValidationSchema(
parameters: ConsumerParameter[]
): Yup.SchemaOf<{
dataServiceParams: any
termsAndConditions: boolean
}> {
return Yup.object().shape({
dataServiceParams: getUserCustomParameterValidationSchema(parameters)
dataServiceParams: getUserCustomParameterValidationSchema(parameters),
termsAndConditions: Yup.boolean()
.required('Required')
.isTrue('Please agree to the Terms and Conditions.')
})
}
9 changes: 9 additions & 0 deletions src/components/Asset/AssetActions/Download/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,19 @@
justify-content: flex-start;
}

.priceWrapper > div:last-of-type {
margin-bottom: 0;
}

.filewrapper {
flex-shrink: 0;
}

.consumerParameters > div {
margin-top: var(--spacer);
border-bottom: none;
}

.price {
align-self: center;
}
Expand Down
24 changes: 19 additions & 5 deletions src/components/Asset/AssetActions/Download/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ import useNetworkMetadata from '@hooks/useNetworkMetadata'
import ConsumerParameters, {
parseConsumerParameterValues
} from '../ConsumerParameters'
import { Form, Formik, useFormikContext } from 'formik'
import { Field, Form, Formik, useFormikContext } from 'formik'
import { getDownloadValidationSchema } from './_validation'
import { getDefaultValues } from '../ConsumerParameters/FormConsumerParameters'
import WhitelistIndicator from '../Compute/WhitelistIndicator'
import { Signer } from 'ethers'
import SuccessConfetti from '@components/@shared/SuccessConfetti'
import Input from '@components/@shared/FormInput'

export default function Download({
accountId,
Expand Down Expand Up @@ -283,10 +284,16 @@ export default function Download({
size="large"
/>
)}
{asset && (
<ConsumerParameters asset={asset} isLoading={isLoading} />
)}
{!isInPurgatory && <PurchaseButton isValid={isValid} />}
<Field
component={Input}
name="termsAndConditions"
type="checkbox"
options={['Terms and Conditions']}
prefixes={['I agree to the']}
actions={['/terms']}
disabled={isLoading}
/>
</div>
)}
</>
Expand All @@ -300,8 +307,10 @@ export default function Download({
initialValues={{
dataServiceParams: getDefaultValues(
asset?.services[0].consumerParameters
)
),
termsAndConditions: false
}}
validateOnMount
validationSchema={getDownloadValidationSchema(
asset?.services[0].consumerParameters
)}
Expand All @@ -327,6 +336,11 @@ export default function Download({
</div>
<AssetAction asset={asset} />
</div>
<div className={styles.consumerParameters}>
{asset && (
<ConsumerParameters asset={asset} isLoading={isLoading} />
)}
</div>
{isOwned && (
<div className={styles.confettiContainer}>
<SuccessConfetti
Expand Down
10 changes: 0 additions & 10 deletions src/components/Asset/Edit/FormEditMetadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,6 @@ export default function FormEditMetadata({
}

useEffect(() => {
// let's initiate files with empty url (we can't access the asset url) with type hidden (for UI frontend)
setTimeout(() => {
setFieldValue('files', [
{
url: '',
type: 'hidden'
}
])
}, 500)

const providerUrl = values?.services
? values?.services[0].providerUrl.url
: asset.services[0].serviceEndpoint
Expand Down
2 changes: 1 addition & 1 deletion src/components/Asset/Edit/_constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function getInitialValues(
description: metadata?.description,
price,
links: [{ url: '', type: 'url' }],
files: [{ url: '', type: 'ipfs' }],
files: [{ url: '', type: 'hidden' }],
timeout: secondsToString(service?.timeout),
author: metadata?.author,
tags: metadata?.tags,
Expand Down
29 changes: 19 additions & 10 deletions src/components/Publish/_validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,33 @@ const validationMetadata = {
}),
dockerImageCustomChecksum: Yup.string().when('type', {
is: 'algorithm',
then: Yup.string().required('Required')
then: Yup.string().when('dockerImage', {
is: 'custom',
then: Yup.string().required('Required')
})
}),
dockerImageCustomEntrypoint: Yup.string().when('type', {
is: 'algorithm',
then: Yup.string().required('Required')
then: Yup.string().when('dockerImage', {
is: 'custom',
then: Yup.string().required('Required')
})
}),
termsAndConditions: Yup.boolean()
.required('Required')
.isTrue('Please agree to the Terms and Conditions.'),
usesConsumerParameters: Yup.boolean(),
consumerParameters: Yup.array().when('usesConsumerParameters', {
is: true,
then: Yup.array()
.of(Yup.object().shape(validationConsumerParameters))
.required('Required'),
otherwise: Yup.array()
.nullable()
.transform((value) => value || null)
consumerParameters: Yup.array().when('type', {
is: 'algorithm',
then: Yup.array().when('usesConsumerParameters', {
is: true,
then: Yup.array()
.of(Yup.object().shape(validationConsumerParameters))
.required('Required'),
otherwise: Yup.array()
.nullable()
.transform((value) => value || null)
})
})
}

Expand Down

0 comments on commit c92d901

Please sign in to comment.