mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
fixes & hacks
This commit is contained in:
parent
695011fe8b
commit
c7d6616874
@ -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"]
|
||||
|
@ -14,16 +14,12 @@ export interface FileInfo {
|
||||
|
||||
export async function getEncryptedFiles(
|
||||
files: FileMetadata[],
|
||||
providerUrl: string,
|
||||
did: string,
|
||||
accountId: string
|
||||
providerUrl: string
|
||||
): Promise<string> {
|
||||
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) => {
|
||||
|
@ -19,10 +19,11 @@ export default function ServicesFields(): ReactElement {
|
||||
const { values, setFieldValue, touched, setTouched } =
|
||||
useFormikContext<FormPublishData>()
|
||||
|
||||
// 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: <IconDownload />,
|
||||
// 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])
|
||||
|
||||
|
@ -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',
|
||||
|
@ -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'),
|
||||
|
@ -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
|
||||
// --------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user