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

fixes & todo

This commit is contained in:
Matthias Kretschmann 2021-11-26 10:35:41 +00:00
parent 11412c2d66
commit 362e404110
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 20 additions and 7 deletions

View File

@ -35,8 +35,6 @@ export async function transformPublishFormToDdo(
): Promise<DDO> { ): Promise<DDO> {
const { metadata, services, user } = values const { metadata, services, user } = values
const { chainId, accountId } = user const { chainId, accountId } = user
const did = nftAddress ? `0x${sha256(`${nftAddress}${chainId}`)}` : '0x...'
const currentTime = dateToStringNoMS(new Date())
const { const {
type, type,
name, name,
@ -50,6 +48,9 @@ export async function transformPublishFormToDdo(
} = metadata } = metadata
const { access, files, links, providerUrl, timeout } = services[0] const { access, files, links, providerUrl, timeout } = services[0]
const did = nftAddress ? `0x${sha256(`${nftAddress}${chainId}`)}` : '0x...'
const currentTime = dateToStringNoMS(new Date())
// Transform from files[0].url to string[] assuming only 1 file // Transform from files[0].url to string[] assuming only 1 file
const filesTransformed = files?.length && files[0].valid && [files[0].url] const filesTransformed = files?.length && files[0].valid && [files[0].url]
const linksTransformed = links?.length && links[0].valid && [links[0].url] const linksTransformed = links?.length && links[0].valid && [links[0].url]
@ -68,6 +69,8 @@ export async function transformPublishFormToDdo(
termsAndConditions termsAndConditions
}, },
...(type === 'algorithm' && { ...(type === 'algorithm' && {
// TODO: This needs some set of predefined values for `container`,
// depending on user selection in the form.
algorithm: { algorithm: {
language: files?.length ? getUrlFileExtension(filesTransformed[0]) : '', language: files?.length ? getUrlFileExtension(filesTransformed[0]) : '',
version: '0.1', version: '0.1',
@ -81,7 +84,7 @@ export async function transformPublishFormToDdo(
}) })
} }
// Encypt just created string[] of urls // Encrypt just created string[] of urls
const filesEncrypted = const filesEncrypted =
files?.length && files?.length &&
files[0].valid && files[0].valid &&
@ -99,6 +102,7 @@ export async function transformPublishFormToDdo(
serviceEndpoint: providerUrl.url, serviceEndpoint: providerUrl.url,
timeout: mapTimeoutStringToSeconds(timeout), timeout: mapTimeoutStringToSeconds(timeout),
...(access === 'compute' && { ...(access === 'compute' && {
// TODO: get all the default values we want to send here.
compute: { compute: {
namespace: 'ocean-compute', namespace: 'ocean-compute',
cpu: 1, cpu: 1,
@ -121,7 +125,9 @@ export async function transformPublishFormToDdo(
chainId, chainId,
metadata: newMetadata, metadata: newMetadata,
services: [newService], services: [newService],
// only added for DDO preview, reflecting Asset response // Only added for DDO preview, reflecting Asset response,
// again, we can assume if `datatokenAddress` is not passed,
// we are on preview.
...(!datatokenAddress && { ...(!datatokenAddress && {
dataTokenInfo: { dataTokenInfo: {
name: values.services[0].dataTokenOptions.name, name: values.services[0].dataTokenOptions.name,

View File

@ -28,6 +28,9 @@ export default function PublishPage({
const { debug } = useUserPreferences() const { debug } = useUserPreferences()
const { accountId, chainId } = useWeb3() const { accountId, chainId } = useWeb3()
const { isInPurgatory, purgatoryData } = useAccountPurgatory(accountId) const { isInPurgatory, purgatoryData } = useAccountPurgatory(accountId)
// TODO: success & error states need to be handled for each step we want to display
// most likely with a nested data structure.
const [success, setSuccess] = useState<string>() const [success, setSuccess] = useState<string>()
const [error, setError] = useState<string>() const [error, setError] = useState<string>()
const scrollToRef = useRef() const scrollToRef = useRef()
@ -39,14 +42,19 @@ export default function PublishPage({
// -------------------------------------------------- // --------------------------------------------------
// const nftOptions = values.metadata.nft // const nftOptions = values.metadata.nft
// const nftCreateData = generateNftCreateData(nftOptions) // const nftCreateData = generateNftCreateData(nftOptions)
// TODO: figure out syntax of ercParams we most likely need to pass
// to createNftWithErc() as we need to pass options for the datatoken.
// const ercParams = {} // const ercParams = {}
// const priceOptions = { // const priceOptions = {
// ...values,
// // swapFee is tricky: to get 0.1% you need to send 0.001 as value // // swapFee is tricky: to get 0.1% you need to send 0.001 as value
// swapFee: `${values.swapFee / 100}` // swapFee: `${values.pricing.swapFee / 100}`
// } // }
// const txMint = await createNftWithErc(accountId, nftCreateData) // const txMint = await createNftWithErc(accountId, nftCreateData)
// TODO: figure out how to get nftAddress & datatokenAddress from tx log.
// const { nftAddress, datatokenAddress } = txMint.logs[0].args // const { nftAddress, datatokenAddress } = txMint.logs[0].args
// if (!nftAddress || !datatokenAddress) { throw new Error() }
// //
// -------------------------------------------------- // --------------------------------------------------
// 2. Construct and publish DDO // 2. Construct and publish DDO
@ -66,7 +74,6 @@ export default function PublishPage({
// if (checksumBefore !== checksumAfter) { // if (checksumBefore !== checksumAfter) {
// throw new Error('DDO integrity check failed!') // throw new Error('DDO integrity check failed!')
// } // }
setSuccess('Your DDO was published successfully!') setSuccess('Your DDO was published successfully!')
} catch (error) { } catch (error) {
setError(error.message) setError(error.message)