1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

Merge pull request #182 from oceanprotocol/feature/optional-prices

Optional pricing
This commit is contained in:
Jernej Pregelj 2019-08-01 15:11:42 +02:00 committed by GitHub
commit 52ec23628f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 93 additions and 39 deletions

View File

@ -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

View File

@ -1079,9 +1079,9 @@
},
"dependencies": {
"@hapi/hoek": {
"version": "8.0.2",
"resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.0.2.tgz",
"integrity": "sha512-O6o6mrV4P65vVccxymuruucb+GhP2zl9NLCG8OdoFRS8BEGw3vwpPp20wpAtpbQQxz1CEUtmxJGgWhjq1XA3qw==",
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.1.0.tgz",
"integrity": "sha512-b1J4jxYnW+n6lC91V6Pqg9imP9BZq0HNCeM+3sbXg05rQsE9cGYrKFpZjyztVesGmNRE6R+QaEoWGATeIiUVjA==",
"dev": true
}
}
@ -3642,9 +3642,9 @@
}
},
"caniuse-lite": {
"version": "1.0.30000985",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000985.tgz",
"integrity": "sha512-1ngiwkgqAYPG0JSSUp3PUDGPKKY59EK7NrGGX+VOxaKCNzRbNc7uXMny+c3VJfZxtoK3wSImTvG9T9sXiTw2+w==",
"version": "1.0.30000986",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000986.tgz",
"integrity": "sha512-pM+LnkoAX0+QnIH3tpW5EnkmfpEoqOD8FAcoBvsl3Xh6DXkgctiCxeCbXphP/k3XJtJzm+zOAJbi6U6IVkpWZQ==",
"dev": true
},
"capture-exit": {
@ -4201,9 +4201,9 @@
},
"dependencies": {
"semver": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.2.0.tgz",
"integrity": "sha512-jdFC1VdUGT/2Scgbimf7FSx9iJLXoqfglSF+gJeuNWVpiE37OIbc1jywR/GJyFdz3mnkz2/id0L0J/cr0izR5A==",
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
"dev": true
}
}
@ -4672,9 +4672,9 @@
}
},
"date-fns": {
"version": "2.0.0-beta.2",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.0.0-beta.2.tgz",
"integrity": "sha512-4cicZF707RNerr3/Q3CcdLo+3OHMCfrRXE7h5iFgn7AMvX07sqKLxSf8Yp+WJW5bvKr2cy9/PkctXLv4iFtOaA=="
"version": "2.0.0-beta.3",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.0.0-beta.3.tgz",
"integrity": "sha512-z5O262BvHPhwUvA1weXH+AZodygnZUcORERw8hjwBUrRPGrAo2e/rjXfC8Ykf1OGJZGDuLnK/WXbEZBIc0exGQ=="
},
"date-now": {
"version": "0.1.4",
@ -5209,9 +5209,9 @@
"dev": true
},
"electron-to-chromium": {
"version": "1.3.199",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.199.tgz",
"integrity": "sha512-gachlDdHSK47s0N2e58GH9HMC6Z4ip0SfmYUa5iEbE50AKaOUXysaJnXMfKj0xB245jWbYcyFSH+th3rqsF8hA==",
"version": "1.3.203",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.203.tgz",
"integrity": "sha512-Z1FjJKEBhYrCNmnususVk8khiBabVI/bSJB/295V4ghVt4MFmtbP+mXgRZLQZinEBI469U6FtiGgpXnlLs6qiQ==",
"dev": true
},
"elliptic": {
@ -8677,9 +8677,9 @@
},
"dependencies": {
"semver": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.2.0.tgz",
"integrity": "sha512-jdFC1VdUGT/2Scgbimf7FSx9iJLXoqfglSF+gJeuNWVpiE37OIbc1jywR/GJyFdz3mnkz2/id0L0J/cr0izR5A==",
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
"dev": true
}
}
@ -10940,9 +10940,9 @@
}
},
"node-releases": {
"version": "1.1.25",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.25.tgz",
"integrity": "sha512-fI5BXuk83lKEoZDdH3gRhtsNgh05/wZacuXkgbiYkceE7+QIMXOg98n9ZV7mz27B+kFHnqHcUpscZZlGRSmTpQ==",
"version": "1.1.26",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.26.tgz",
"integrity": "sha512-fZPsuhhUHMTlfkhDLGtfY80DSJTjOcx+qD1j5pqPkuhUHVS7xHZIg9EE4DHK8O3f0zTxXHX5VIkDG8pu98/wfQ==",
"dev": true,
"requires": {
"semver": "^5.3.0"
@ -12770,9 +12770,9 @@
"integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw="
},
"pretty-bytes": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.2.0.tgz",
"integrity": "sha512-ujANBhiUsl9AhREUDUEY1GPOharMGm8x8juS7qOHybcLi7XsKfrYQ88hSly1l2i0klXHTDYrlL8ihMCG55Dc3w==",
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.3.0.tgz",
"integrity": "sha512-hjGrh+P926p4R4WbaB6OckyRtO0F0/lQBiT+0gnxjV+5kjPBrfVBFCsCLbMqVQeydvIoouYTCmmEURiH3R1Bdg==",
"dev": true
},
"pretty-error": {
@ -15265,13 +15265,13 @@
}
},
"string.prototype.trim": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz",
"integrity": "sha1-0E3iyJ4Tf019IG8Ia17S+ua+jOo=",
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.0.tgz",
"integrity": "sha512-9EIjYD/WdlvLpn987+ctkLf0FfvBefOCuiEr2henD8X+7jfwPnyvTdmW8OJhj5p+M0/96mBdynLWkxUr+rHlpg==",
"requires": {
"define-properties": "^1.1.2",
"es-abstract": "^1.5.0",
"function-bind": "^1.0.2"
"define-properties": "^1.1.3",
"es-abstract": "^1.13.0",
"function-bind": "^1.1.1"
}
},
"string_decoder": {
@ -15416,9 +15416,9 @@
}
},
"svg-parser": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/svg-parser/-/svg-parser-2.0.1.tgz",
"integrity": "sha512-8eUnCsU2sc2hyfvjK++zi5u24a2UQIB2DK9GY/cprGlaDr7SIhm9F0m9CkGYOnOgrK3iTUSnJ7M1DTLqqZt96g==",
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/svg-parser/-/svg-parser-2.0.2.tgz",
"integrity": "sha512-1gtApepKFweigFZj3sGO8KT8LvVZK8io146EzXrpVuWCDAbISz/yMucco3hWTkpZNoPabM+dnMOpy6Swue68Zg==",
"dev": true
},
"svgo": {
@ -16031,9 +16031,9 @@
"dev": true
},
"tsutils": {
"version": "3.14.0",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.14.0.tgz",
"integrity": "sha512-SmzGbB0l+8I0QwsPgjooFRaRvHLBLNYM8SeQ0k6rtNDru5sCGeLJcZdwilNndN+GysuFjF5EIYgN8GfFG6UeUw==",
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.14.1.tgz",
"integrity": "sha512-kiuZzD1uUA5DxGj/uxbde+ymp6VVdAxdzOIlAFbYKrPyla8/uiJ9JLBm1QsPhOm4Muj0/+cWEDP99yoCUcSl6Q==",
"dev": true,
"requires": {
"tslib": "^1.8.1"

View File

@ -32,6 +32,7 @@
h1 {
font-size: $font-size-large;
margin-top: 0;
margin-bottom: $spacer / 4;
}
}
@ -89,7 +90,18 @@
}
.assetFooter {
margin-top: $spacer / 2;
margin-top: $spacer;
font-size: $font-size-small;
color: $brand-grey-light;
display: flex;
justify-content: space-between;
}
.price {
font-size: $font-size-mini;
span {
color: $brand-grey;
font-size: $font-size-small;
}
}

View File

@ -5,6 +5,8 @@ import Dotdotdot from 'react-dotdotdot'
import cx from 'classnames'
import styles from './AssetTeaser.module.scss'
import CategoryImage from '../atoms/CategoryImage'
import { allowPricing } from '../../config'
import Web3 from 'web3'
const AssetTeaser = ({
asset,
@ -49,6 +51,14 @@ const AssetTeaser = ({
)}
<footer className={styles.assetFooter}>
{base.categories && <div>{base.categories[0]}</div>}
{allowPricing && (
<div className={styles.price}>
<span>
{Web3.utils.fromWei(base.price.toString())}
</span>{' '}
OCEAN
</div>
)}
</footer>
</Link>
</article>

View File

@ -6,6 +6,8 @@ import CategoryLink from '../../atoms/CategoryLink'
import styles from './AssetDetails.module.scss'
import AssetFilesDetails from './AssetFilesDetails'
import Report from './Report'
import { allowPricing } from '../../../config'
import Web3 from 'web3'
interface AssetDetailsProps {
metadata: MetaData
@ -93,6 +95,21 @@ export default class AssetDetails extends PureComponent<AssetDetailsProps> {
<code>{ddo.id}</code>
</span>
</li>
{allowPricing ? (
<li>
<span className={styles.metaLabel}>
<strong>Price</strong>
</span>
<span className={styles.metaValue}>
{base.price === '0'
? 0
: Web3.utils.fromWei(
base.price.toString()
)}{' '}
OCEAN
</span>
</li>
) : null}
</ul>
</div>

View File

@ -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

View File

@ -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,7 +292,9 @@ 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]
})