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
content/publish
src
@ -128,7 +128,7 @@
|
|||||||
"label": "Access Type",
|
"label": "Access Type",
|
||||||
"help": "Choose how you want your files to be accessible for the specified price.",
|
"help": "Choose how you want your files to be accessible for the specified price.",
|
||||||
"type": "boxSelection",
|
"type": "boxSelection",
|
||||||
"options": ["Download", "Compute"],
|
"options": ["Access", "Compute"],
|
||||||
"required": true,
|
"required": true,
|
||||||
"disclaimer": "Please do not provide downloadable personal data without the consent of the data subjects.",
|
"disclaimer": "Please do not provide downloadable personal data without the consent of the data subjects.",
|
||||||
"disclaimerValues": ["Download"]
|
"disclaimerValues": ["Download"]
|
||||||
|
@ -14,16 +14,12 @@ export interface FileInfo {
|
|||||||
|
|
||||||
export async function getEncryptedFiles(
|
export async function getEncryptedFiles(
|
||||||
files: FileMetadata[],
|
files: FileMetadata[],
|
||||||
providerUrl: string,
|
providerUrl: string
|
||||||
did: string,
|
|
||||||
accountId: string
|
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
try {
|
try {
|
||||||
// https://github.com/oceanprotocol/provider/blob/v4main/API.md#encrypt-endpoint
|
// https://github.com/oceanprotocol/provider/blob/v4main/API.md#encrypt-endpoint
|
||||||
console.log('start encr')
|
console.log('start encr')
|
||||||
const response = await ProviderInstance.encrypt(
|
const response = await ProviderInstance.encrypt(
|
||||||
did,
|
|
||||||
accountId,
|
|
||||||
files,
|
files,
|
||||||
providerUrl,
|
providerUrl,
|
||||||
(url: string, body: string) => {
|
(url: string, body: string) => {
|
||||||
|
@ -19,10 +19,11 @@ export default function ServicesFields(): ReactElement {
|
|||||||
const { values, setFieldValue, touched, setTouched } =
|
const { values, setFieldValue, touched, setTouched } =
|
||||||
useFormikContext<FormPublishData>()
|
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 = [
|
const accessTypeOptions = [
|
||||||
{
|
{
|
||||||
name: accessTypeOptionsTitles[0].toLowerCase(),
|
name: 'download',
|
||||||
title: accessTypeOptionsTitles[0],
|
title: 'Download',
|
||||||
icon: <IconDownload />,
|
icon: <IconDownload />,
|
||||||
// BoxSelection component is not a Formik component
|
// BoxSelection component is not a Formik component
|
||||||
// so we need to handle checked state manually.
|
// so we need to handle checked state manually.
|
||||||
@ -55,7 +56,7 @@ export default function ServicesFields(): ReactElement {
|
|||||||
|
|
||||||
setFieldValue(
|
setFieldValue(
|
||||||
'services[0].access',
|
'services[0].access',
|
||||||
values.services[0].algorithmPrivacy === true ? 'compute' : 'download'
|
values.services[0].algorithmPrivacy === true ? 'compute' : 'access'
|
||||||
)
|
)
|
||||||
}, [values.services[0].algorithmPrivacy, setFieldValue])
|
}, [values.services[0].algorithmPrivacy, setFieldValue])
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ export async function transformPublishFormToDdo(
|
|||||||
!isPreview &&
|
!isPreview &&
|
||||||
files?.length &&
|
files?.length &&
|
||||||
files[0].valid &&
|
files[0].valid &&
|
||||||
(await getEncryptedFiles(file, providerUrl.url, did, accountId))
|
(await getEncryptedFiles(file, providerUrl.url))
|
||||||
|
|
||||||
const newService: Service = {
|
const newService: Service = {
|
||||||
id: 'notAnId',
|
id: 'notAnId',
|
||||||
|
@ -46,7 +46,7 @@ const validationService = {
|
|||||||
}),
|
}),
|
||||||
timeout: Yup.string().required('Required'),
|
timeout: Yup.string().required('Required'),
|
||||||
access: Yup.string()
|
access: Yup.string()
|
||||||
.matches(/compute|download/g)
|
.matches(/compute|access/g)
|
||||||
.required('Required'),
|
.required('Required'),
|
||||||
providerUrl: Yup.object().shape({
|
providerUrl: Yup.object().shape({
|
||||||
url: Yup.string().url('Must be a valid URL.').required('Required'),
|
url: Yup.string().url('Must be a valid URL.').required('Required'),
|
||||||
|
@ -59,7 +59,7 @@ export default function PublishPage({
|
|||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
const config = getOceanConfig(chainId)
|
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
|
// 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 = {
|
const nftCreateData: NftCreateData = {
|
||||||
name: values.metadata.nft.name,
|
name: values.metadata.nft.name,
|
||||||
@ -186,10 +186,8 @@ export default function PublishPage({
|
|||||||
)
|
)
|
||||||
|
|
||||||
const encryptedResponse = await ProviderInstance.encrypt(
|
const encryptedResponse = await ProviderInstance.encrypt(
|
||||||
ddo.id,
|
|
||||||
accountId,
|
|
||||||
ddo,
|
ddo,
|
||||||
config.providerAddress,
|
config.providerUri,
|
||||||
(url: string, body: string) => {
|
(url: string, body: string) => {
|
||||||
return axios.post(url, body, {
|
return axios.post(url, body, {
|
||||||
headers: { 'Content-Type': 'application/octet-stream' },
|
headers: { 'Content-Type': 'application/octet-stream' },
|
||||||
@ -199,9 +197,11 @@ export default function PublishPage({
|
|||||||
)
|
)
|
||||||
const encryptedDddo = encryptedResponse.data
|
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: 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
|
// 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)
|
const nft = new Nft(web3)
|
||||||
|
|
||||||
// theoretically used by aquarius or provider, not implemented yet, will remain hardcoded
|
// theoretically used by aquarius or provider, not implemented yet, will remain hardcoded
|
||||||
@ -211,13 +211,15 @@ export default function PublishPage({
|
|||||||
erc721Address,
|
erc721Address,
|
||||||
accountId,
|
accountId,
|
||||||
0,
|
0,
|
||||||
config.providerAddress,
|
config.providerUri,
|
||||||
'',
|
'',
|
||||||
flags,
|
flags,
|
||||||
encryptedDddo,
|
encryptedDddo,
|
||||||
'0x' + metadataHash
|
'0x' + metadataHash
|
||||||
)
|
)
|
||||||
|
|
||||||
|
console.log('result', res)
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// 3. Integrity check of DDO before & after publishing
|
// 3. Integrity check of DDO before & after publishing
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user