From 74075fab08c618e55202fb24ffca8916eeff13a2 Mon Sep 17 00:00:00 2001 From: Jernej Pregelj Date: Tue, 23 Jul 2019 16:02:58 +0200 Subject: [PATCH 1/5] add pricing to publish --- client/.env.local.example | 1 + client/src/config.ts | 1 + client/src/routes/Publish/index.tsx | 17 +++++++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) 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]) From 552d9a90f818049675ecf313ad2a25e19e97f37b Mon Sep 17 00:00:00 2001 From: Jernej Pregelj Date: Wed, 24 Jul 2019 15:49:47 +0200 Subject: [PATCH 2/5] pricing to displays --- .../src/components/molecules/AssetTeaser.tsx | 6 +++++- .../templates/Asset/AssetDetails.tsx | 19 +++++++++++++++++++ client/src/routes/Publish/index.tsx | 18 +++++++++--------- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/client/src/components/molecules/AssetTeaser.tsx b/client/src/components/molecules/AssetTeaser.tsx index 85e91ae..14f6d0d 100644 --- a/client/src/components/molecules/AssetTeaser.tsx +++ b/client/src/components/molecules/AssetTeaser.tsx @@ -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, @@ -41,7 +43,9 @@ const AssetTeaser = ({ )}

{base.name}

- + {allowPricing + ? 'Ọ ' + Web3.utils.fromWei(base.price.toString()) + : null} {!minimal && (
{base.description} diff --git a/client/src/components/templates/Asset/AssetDetails.tsx b/client/src/components/templates/Asset/AssetDetails.tsx index 03ffc49..10db94c 100644 --- a/client/src/components/templates/Asset/AssetDetails.tsx +++ b/client/src/components/templates/Asset/AssetDetails.tsx @@ -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,23 @@ export default class AssetDetails extends PureComponent { {ddo.id} + {allowPricing ? ( +
  • + + Price + + + + Ọ{' '} + {base.price === '0' + ? 0 + : Web3.utils.fromWei( + base.price.toString() + )} + + +
  • + ) : null}
    diff --git a/client/src/routes/Publish/index.tsx b/client/src/routes/Publish/index.tsx index 2aa4347..d3733d0 100644 --- a/client/src/routes/Publish/index.tsx +++ b/client/src/routes/Publish/index.tsx @@ -37,13 +37,13 @@ interface PublishState { validationStatus?: any } -if(allowPricing){ - (steps as any)[0].fields['price'] = { - label: "Price", - placeholder: "Price in Ocean tokens", - type: "string", +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." + help: 'Enter the price of assets in Ocean tokens.' } } @@ -292,14 +292,14 @@ class Publish extends Component<{}, PublishState> { license: this.state.license, copyrightHolder: this.state.copyrightHolder, files, - price: allowPricing ? Web3.utils.toWei(this.state.price, 'ether') : 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]) From 7c59faf4a423195c3eda2c441404e4b036e56eba Mon Sep 17 00:00:00 2001 From: Jernej Pregelj Date: Wed, 24 Jul 2019 16:18:56 +0200 Subject: [PATCH 3/5] config fixes --- client/.env.local.example | 2 +- client/src/config.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/.env.local.example b/client/.env.local.example index c5851cd..11aebb6 100644 --- a/client/.env.local.example +++ b/client/.env.local.example @@ -53,4 +53,4 @@ REACT_APP_BRIZO_ADDRESS="0x0474ed05ba757dde575dfaaaa267d9e7f3643abc" # REACT_APP_BRIZO_ADDRESS="0x00bd138abd70e2f00903268f3db08f2d25677c9e" REACT_APP_REPORT_EMAIL="test@example.com" -REACT_APP_ALLOW_PRICING="true" +# REACT_APP_ALLOW_PRICING=true diff --git a/client/src/config.ts b/client/src/config.ts index 89a9d69..3952878 100644 --- a/client/src/config.ts +++ b/client/src/config.ts @@ -28,4 +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' +export const allowPricing = process.env.REACT_APP_ALLOW_PRICING || false From 09797aed78cb2f20b57eb1aedbc9c624aad01a1e Mon Sep 17 00:00:00 2001 From: Jernej Pregelj Date: Mon, 29 Jul 2019 13:22:25 +0200 Subject: [PATCH 4/5] pacakge fixes --- client/package-lock.json | 72 ++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/client/package-lock.json b/client/package-lock.json index 81ef21c..f35a477 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -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" From a2b8bd64004ed842df9fc03a2600f4dbae42585d Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 1 Aug 2019 14:27:36 +0200 Subject: [PATCH 5/5] price display tweaks --- .../components/molecules/AssetTeaser.module.scss | 14 +++++++++++++- client/src/components/molecules/AssetTeaser.tsx | 12 +++++++++--- .../components/templates/Asset/AssetDetails.tsx | 14 ++++++-------- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/client/src/components/molecules/AssetTeaser.module.scss b/client/src/components/molecules/AssetTeaser.module.scss index 43979aa..212ab2b 100644 --- a/client/src/components/molecules/AssetTeaser.module.scss +++ b/client/src/components/molecules/AssetTeaser.module.scss @@ -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; + } } diff --git a/client/src/components/molecules/AssetTeaser.tsx b/client/src/components/molecules/AssetTeaser.tsx index 14f6d0d..5c322d7 100644 --- a/client/src/components/molecules/AssetTeaser.tsx +++ b/client/src/components/molecules/AssetTeaser.tsx @@ -43,9 +43,7 @@ const AssetTeaser = ({ )}

    {base.name}

    - {allowPricing - ? 'Ọ ' + Web3.utils.fromWei(base.price.toString()) - : null} + {!minimal && (
    {base.description} @@ -53,6 +51,14 @@ const AssetTeaser = ({ )}
    {base.categories &&
    {base.categories[0]}
    } + {allowPricing && ( +
    + + {Web3.utils.fromWei(base.price.toString())} + {' '} + OCEAN +
    + )}
    diff --git a/client/src/components/templates/Asset/AssetDetails.tsx b/client/src/components/templates/Asset/AssetDetails.tsx index 10db94c..371d29e 100644 --- a/client/src/components/templates/Asset/AssetDetails.tsx +++ b/client/src/components/templates/Asset/AssetDetails.tsx @@ -101,14 +101,12 @@ export default class AssetDetails extends PureComponent { Price - - Ọ{' '} - {base.price === '0' - ? 0 - : Web3.utils.fromWei( - base.price.toString() - )} - + {base.price === '0' + ? 0 + : Web3.utils.fromWei( + base.price.toString() + )}{' '} + OCEAN ) : null}