diff --git a/client/.env.local.example b/client/.env.local.example index c71d925..c5851cd 100644 --- a/client/.env.local.example +++ b/client/.env.local.example @@ -53,3 +53,4 @@ REACT_APP_BRIZO_ADDRESS="0x0474ed05ba757dde575dfaaaa267d9e7f3643abc" # REACT_APP_BRIZO_ADDRESS="0x00bd138abd70e2f00903268f3db08f2d25677c9e" REACT_APP_REPORT_EMAIL="test@example.com" +REACT_APP_ALLOW_PRICING="true" diff --git a/client/src/config.ts b/client/src/config.ts index 46f0479..89a9d69 100644 --- a/client/src/config.ts +++ b/client/src/config.ts @@ -28,3 +28,4 @@ export const faucetUri = // export const verbose = true export const analyticsId = 'UA-60614729-11' +export const allowPricing = process.env.REACT_APP_ALLOW_PRICING || 'false' diff --git a/client/src/routes/Publish/index.tsx b/client/src/routes/Publish/index.tsx index 2c6bf3d..2aa4347 100644 --- a/client/src/routes/Publish/index.tsx +++ b/client/src/routes/Publish/index.tsx @@ -1,5 +1,6 @@ import React, { ChangeEvent, Component, FormEvent } from 'react' import { Logger } from '@oceanprotocol/squid' +import Web3 from 'web3' import Route from '../../components/templates/Route' import Form from '../../components/atoms/Form/Form' import AssetModel from '../../models/AssetModel' @@ -7,7 +8,7 @@ import { User, Market } from '../../context' import Step from './Step' import Progress from './Progress' import ReactGA from 'react-ga' - +import { allowPricing } from '../../config' import { steps } from '../../data/form-publish.json' import Content from '../../components/atoms/Content' import { File } from './Files' @@ -36,6 +37,16 @@ interface PublishState { validationStatus?: any } +if(allowPricing){ + (steps as any)[0].fields['price'] = { + label: "Price", + placeholder: "Price in Ocean tokens", + type: "string", + required: true, + help: "Enter the price of assets in Ocean tokens." + } +} + class Publish extends Component<{}, PublishState> { public static contextType = User @@ -281,12 +292,14 @@ class Publish extends Component<{}, PublishState> { license: this.state.license, copyrightHolder: this.state.copyrightHolder, files, - price: this.state.price, + price: allowPricing ? Web3.utils.toWei(this.state.price, 'ether') : this.state.price, type: this.state.type, categories: [this.state.categories] }) } + console.log(newAsset) + try { const asset = await this.context.ocean.assets .create(newAsset, account[0])