From c7d661687476b5b7ac416b552fe2c67c6ca1bd46 Mon Sep 17 00:00:00 2001 From: mihaisc Date: Tue, 21 Dec 2021 22:26:08 +0200 Subject: [PATCH] fixes & hacks --- content/publish/form.json | 2 +- src/@utils/provider.ts | 6 +----- src/components/Publish/Services/index.tsx | 7 ++++--- src/components/Publish/_utils.ts | 2 +- src/components/Publish/_validation.ts | 2 +- src/components/Publish/index.tsx | 14 ++++++++------ 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/content/publish/form.json b/content/publish/form.json index 7ddc0c78f..8863c4a85 100644 --- a/content/publish/form.json +++ b/content/publish/form.json @@ -128,7 +128,7 @@ "label": "Access Type", "help": "Choose how you want your files to be accessible for the specified price.", "type": "boxSelection", - "options": ["Download", "Compute"], + "options": ["Access", "Compute"], "required": true, "disclaimer": "Please do not provide downloadable personal data without the consent of the data subjects.", "disclaimerValues": ["Download"] diff --git a/src/@utils/provider.ts b/src/@utils/provider.ts index 3ea2bae98..e874c7d25 100644 --- a/src/@utils/provider.ts +++ b/src/@utils/provider.ts @@ -14,16 +14,12 @@ export interface FileInfo { export async function getEncryptedFiles( files: FileMetadata[], - providerUrl: string, - did: string, - accountId: string + providerUrl: string ): Promise { try { // https://github.com/oceanprotocol/provider/blob/v4main/API.md#encrypt-endpoint console.log('start encr') const response = await ProviderInstance.encrypt( - did, - accountId, files, providerUrl, (url: string, body: string) => { diff --git a/src/components/Publish/Services/index.tsx b/src/components/Publish/Services/index.tsx index 2e09d3b58..7deaf07f3 100644 --- a/src/components/Publish/Services/index.tsx +++ b/src/components/Publish/Services/index.tsx @@ -19,10 +19,11 @@ export default function ServicesFields(): ReactElement { const { values, setFieldValue, touched, setTouched } = useFormikContext() + // name and title should be download, but option value should be access, probably the best way would be to change the component so that option is an object like {name,value} const accessTypeOptions = [ { - name: accessTypeOptionsTitles[0].toLowerCase(), - title: accessTypeOptionsTitles[0], + name: 'download', + title: 'Download', icon: , // BoxSelection component is not a Formik component // so we need to handle checked state manually. @@ -55,7 +56,7 @@ export default function ServicesFields(): ReactElement { setFieldValue( 'services[0].access', - values.services[0].algorithmPrivacy === true ? 'compute' : 'download' + values.services[0].algorithmPrivacy === true ? 'compute' : 'access' ) }, [values.services[0].algorithmPrivacy, setFieldValue]) diff --git a/src/components/Publish/_utils.ts b/src/components/Publish/_utils.ts index c873ecd61..540838721 100644 --- a/src/components/Publish/_utils.ts +++ b/src/components/Publish/_utils.ts @@ -125,7 +125,7 @@ export async function transformPublishFormToDdo( !isPreview && files?.length && files[0].valid && - (await getEncryptedFiles(file, providerUrl.url, did, accountId)) + (await getEncryptedFiles(file, providerUrl.url)) const newService: Service = { id: 'notAnId', diff --git a/src/components/Publish/_validation.ts b/src/components/Publish/_validation.ts index a35404321..7e4e50195 100644 --- a/src/components/Publish/_validation.ts +++ b/src/components/Publish/_validation.ts @@ -46,7 +46,7 @@ const validationService = { }), timeout: Yup.string().required('Required'), access: Yup.string() - .matches(/compute|download/g) + .matches(/compute|access/g) .required('Required'), providerUrl: Yup.object().shape({ url: Yup.string().url('Must be a valid URL.').required('Required'), diff --git a/src/components/Publish/index.tsx b/src/components/Publish/index.tsx index 65f783294..8ada0227a 100644 --- a/src/components/Publish/index.tsx +++ b/src/components/Publish/index.tsx @@ -59,7 +59,7 @@ export default function PublishPage({ // -------------------------------------------------- const config = getOceanConfig(chainId) - + console.log('config', config) // image not included here for gas fees reasons. It is also an issue to reaserch how we add the image in the nft const nftCreateData: NftCreateData = { name: values.metadata.nft.name, @@ -186,10 +186,8 @@ export default function PublishPage({ ) const encryptedResponse = await ProviderInstance.encrypt( - ddo.id, - accountId, ddo, - config.providerAddress, + config.providerUri, (url: string, body: string) => { return axios.post(url, body, { headers: { 'Content-Type': 'application/octet-stream' }, @@ -199,9 +197,11 @@ export default function PublishPage({ ) const encryptedDddo = encryptedResponse.data + console.log('ddo', JSON.stringify(ddo)) + // TODO: this whole setMetadata needs to go in a function ,too many hardcoded/calculated params // TODO: hash generation : this needs to be moved in a function (probably on ocean.js) after we figure out what is going on in provider, leave it here for now - const metadataHash = getHash(Web3.utils.stringToHex(JSON.stringify(ddo))) + const metadataHash = getHash(JSON.stringify(ddo)) const nft = new Nft(web3) // theoretically used by aquarius or provider, not implemented yet, will remain hardcoded @@ -211,13 +211,15 @@ export default function PublishPage({ erc721Address, accountId, 0, - config.providerAddress, + config.providerUri, '', flags, encryptedDddo, '0x' + metadataHash ) + console.log('result', res) + // -------------------------------------------------- // 3. Integrity check of DDO before & after publishing // --------------------------------------------------