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

Merge pull request #43 from oceanprotocol/feature/consume

Feature/consume
This commit is contained in:
Matthias Kretschmann 2020-08-05 15:15:04 +02:00 committed by GitHub
commit 4ea0b6c6fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 5 deletions

20
package-lock.json generated
View File

@ -3615,6 +3615,26 @@
"decimal.js": "^10.2.0",
"web3": "^1.2.11",
"web3modal": "^1.9.0"
},
"dependencies": {
"@oceanprotocol/lib": {
"version": "0.1.11",
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.1.11.tgz",
"integrity": "sha512-DvsCWOACxNlsNpGWdbHhKsN2Lj+/B0UAp6l2/29fywFZnFp0mjywKFbhVEY25PGaHZIUG+7YZ0Eot615tKpNjw==",
"requires": {
"@ethereum-navigator/navigator": "^0.5.0",
"@oceanprotocol/contracts": "^0.3.1",
"bignumber.js": "^9.0.0",
"decimal.js": "^10.2.0",
"fs": "0.0.1-security",
"node-fetch": "^2.6.0",
"save-file": "^2.3.1",
"uuid": "^8.2.0",
"web3": "^1.2.9",
"web3-eth-contract": "^1.2.9",
"whatwg-url": "^8.0.0"
}
}
}
},
"@oceanprotocol/typographies": {

View File

@ -22,6 +22,7 @@
"@coingecko/cryptoformat": "^0.3.8",
"@loadable/component": "^5.13.1",
"@oceanprotocol/art": "^3.0.0",
"@oceanprotocol/lib": "^0.1.10",
"@oceanprotocol/react": "^0.0.31",
"@oceanprotocol/typographies": "^0.1.0",
"@sindresorhus/slugify": "^1.0.0",

View File

@ -2,21 +2,22 @@ import React, { ReactElement } from 'react'
import { useNavigate } from '@reach/router'
import { toast } from 'react-toastify'
import { Formik } from 'formik'
import { usePublish } from '@oceanprotocol/react'
import { usePublish, useOcean } from '@oceanprotocol/react'
import styles from './index.module.css'
import PublishForm from './PublishForm'
import Web3Feedback from '../../molecules/Wallet/Feedback'
import { FormContent } from '../../../@types/Form'
import { initialValues, validationSchema } from '../../../models/FormPublish'
import { MetadataPublishForm } from '../../../@types/Metadata'
import { transformPublishFormToMetadata } from './utils'
import Preview from './Preview'
import { MetadataPublishForm } from '../../../@types/MetaData'
export default function PublishPage({
content
}: {
content: { form: FormContent }
}): ReactElement {
const { accountId, ocean } = useOcean()
const { publish, publishError } = usePublish()
const navigate = useNavigate()
@ -39,9 +40,26 @@ export default function PublishPage({
`)
try {
const ddo = await publish(metadata as any, tokensToMint.toString(), [
{ serviceType }
])
// mpAddress and mpFee are not yet implemented in ocean js so are not uset
const ddo = await publish(
metadata as any,
tokensToMint.toString(),
serviceType,
'',
''
)
switch (type) {
case 'advanced': {
// weight is hardcoded at 9 (90%) and publisher fee at 0.03(this was a random value set by me)
const pool = await ocean.pool.createDTPool(
accountId,
ddo.dataToken,
tokensToMint.toString(),
'9',
'0.03'
)
}
}
if (publishError) {
toast.error(publishError)