From 865c4d7b9d38f80d052297982111deeda0bf9c3c Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 16 Sep 2020 11:57:02 +0200 Subject: [PATCH 01/15] make liquidityProviderFee editable --- src/components/atoms/Input/index.tsx | 1 + .../molecules/FormFields/Price/Dynamic.tsx | 8 +++++++- .../molecules/FormFields/Price/index.tsx | 19 +++++++++++++++++-- src/models/FormPublish.ts | 4 ++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/components/atoms/Input/index.tsx b/src/components/atoms/Input/index.tsx index 7ff57eb36..9b6002df2 100644 --- a/src/components/atoms/Input/index.tsx +++ b/src/components/atoms/Input/index.tsx @@ -30,6 +30,7 @@ export interface InputProps { multiple?: boolean pattern?: string min?: string + max?: string disabled?: boolean readOnly?: boolean field?: any diff --git a/src/components/molecules/FormFields/Price/Dynamic.tsx b/src/components/molecules/FormFields/Price/Dynamic.tsx index a53c01994..bfa7d1054 100644 --- a/src/components/molecules/FormFields/Price/Dynamic.tsx +++ b/src/components/molecules/FormFields/Price/Dynamic.tsx @@ -17,6 +17,7 @@ export default function Dynamic({ priceOptions, datatokenOptions, onOceanChange, + onLiquidityProviderFeeChange, generateName, content }: { @@ -24,6 +25,7 @@ export default function Dynamic({ priceOptions: PriceOptions datatokenOptions: DataTokenOptions onOceanChange: (event: ChangeEvent) => void + onLiquidityProviderFeeChange: (event: ChangeEvent) => void generateName: () => void content: any }): ReactElement { @@ -104,10 +106,14 @@ export default function Dynamic({ diff --git a/src/components/molecules/FormFields/Price/index.tsx b/src/components/molecules/FormFields/Price/index.tsx index 89cafa62b..86b3b7cbb 100644 --- a/src/components/molecules/FormFields/Price/index.tsx +++ b/src/components/molecules/FormFields/Price/index.tsx @@ -48,12 +48,22 @@ export default function Price(props: InputProps): ReactElement { const [amountOcean, setAmountOcean] = useState('1') const [tokensToMint, setTokensToMint] = useState() const [datatokenOptions, setDatatokenOptions] = useState() + const [liquidityProviderFee, setLiquidityProviderFee] = useState( + priceOptions.liquidityProviderFee + ) function handleOceanChange(event: ChangeEvent) { setAmountOcean(event.target.value) helpers.setValue({ ...field.value, price: event.target.value }) } + // TODO: trigger Yup inline validation + function handleLiquidityProviderFeeChange( + event: ChangeEvent + ) { + setLiquidityProviderFee(event.target.value) + } + function handleTabChange(tabName: string) { const type = tabName.toLowerCase() helpers.setValue({ ...field.value, type }) @@ -73,6 +83,10 @@ export default function Price(props: InputProps): ReactElement { helpers.setValue({ ...field.value, tokensToMint }) }, [amountOcean]) + useEffect(() => { + helpers.setValue({ ...field.value, liquidityProviderFee }) + }, [liquidityProviderFee]) + // Generate new DT name & symbol useEffect(() => { generateName() @@ -96,9 +110,10 @@ export default function Price(props: InputProps): ReactElement { content: ( @@ -111,7 +126,7 @@ export default function Price(props: InputProps): ReactElement { {debug === true && (
-          {JSON.stringify(field.value)}
+          {JSON.stringify(field.value, null, 2)}
         
)} diff --git a/src/models/FormPublish.ts b/src/models/FormPublish.ts index 66bba0bb0..c31432443 100644 --- a/src/models/FormPublish.ts +++ b/src/models/FormPublish.ts @@ -13,6 +13,10 @@ export const validationSchema = Yup.object().shape({ .required('Required'), weightOnDataToken: Yup.string().required('Required'), liquidityProviderFee: Yup.string() + .length(3) + .min(0.1) + .max(0.9) + .required('Required') }), files: Yup.array().required('Required').nullable(), description: Yup.string().required('Required'), From a1da02b8e42481baadd938450cf494c3c38a10e4 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 16 Sep 2020 15:55:40 +0200 Subject: [PATCH 02/15] output fees in dynamic price UI --- content/pages/publish.json | 6 +- .../atoms/Input/InputElement.module.css | 6 ++ src/components/atoms/Input/InputElement.tsx | 32 ++++++++-- .../FormFields/Price/Dynamic.module.css | 22 +++++-- .../molecules/FormFields/Price/Dynamic.tsx | 61 ++++++++++++++----- .../molecules/FormFields/Price/index.tsx | 2 + 6 files changed, 104 insertions(+), 25 deletions(-) diff --git a/content/pages/publish.json b/content/pages/publish.json index 11300e99d..9825b0a1d 100644 --- a/content/pages/publish.json +++ b/content/pages/publish.json @@ -106,8 +106,10 @@ "title": "Dynamic", "info": "Let's create a decentralized, automated market for your data set. A Data Token for this data set, worth the entered amount of OCEAN, will be created. Additionally, you will provide liquidity into a Data Token/OCEAN liquidity pool with Balancer.", "tooltips": { - "poolInfo": "Help me", - "liquidityProviderFee": "Help me" + "poolInfo": "Explain what is going on here...", + "liquidityProviderFee": "Explain liquidity provider fee...", + "communityFee": "Explain community fee...", + "marketplaceFee": "Explain marketplace fee..." } } } diff --git a/src/components/atoms/Input/InputElement.module.css b/src/components/atoms/Input/InputElement.module.css index 132db0897..37045d189 100644 --- a/src/components/atoms/Input/InputElement.module.css +++ b/src/components/atoms/Input/InputElement.module.css @@ -207,6 +207,12 @@ font-size: var(--font-size-small); } +.prefix.small, +.postfix.small { + min-height: 34px; + font-size: var(--font-size-mini); +} + .selectSmall { composes: small; height: 34px; diff --git a/src/components/atoms/Input/InputElement.tsx b/src/components/atoms/Input/InputElement.tsx index eeb986242..6a4e4487b 100644 --- a/src/components/atoms/Input/InputElement.tsx +++ b/src/components/atoms/Input/InputElement.tsx @@ -7,7 +7,11 @@ import Terms from '../../molecules/FormFields/Terms' import Price from '../../molecules/FormFields/Price' const DefaultInput = (props: InputProps) => ( - + ) export default function InputElement({ @@ -75,12 +79,30 @@ export default function InputElement({ default: return prefix || postfix ? (
- {prefix &&
{prefix}
} - - {postfix &&
{postfix}
} + {prefix && ( +
+ {prefix} +
+ )} + + {postfix && ( +
+ {postfix} +
+ )}
) : ( - + ) } } diff --git a/src/components/molecules/FormFields/Price/Dynamic.module.css b/src/components/molecules/FormFields/Price/Dynamic.module.css index bc493ef6b..4c530312f 100644 --- a/src/components/molecules/FormFields/Price/Dynamic.module.css +++ b/src/components/molecules/FormFields/Price/Dynamic.module.css @@ -34,7 +34,8 @@ padding-bottom: calc(var(--spacer) / 3); } -.tokens { +.tokens, +.fees { display: grid; margin-left: -2rem; @@ -48,15 +49,28 @@ } } -.summary { - text-align: center; +.fees { margin-top: var(--spacer); + padding: var(--spacer); + padding-top: 0; + gap: var(--spacer); + grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); + align-items: center; + border-bottom: 1px solid var(--brand-grey-lighter); } -.summary input { +.fees label { + white-space: nowrap; +} + +.fees input { max-width: 5rem; } +.summary { + margin-top: var(--spacer); +} + .alertArea { margin-left: -2rem; margin-right: -2rem; diff --git a/src/components/molecules/FormFields/Price/Dynamic.tsx b/src/components/molecules/FormFields/Price/Dynamic.tsx index bfa7d1054..bf3e4d9c5 100644 --- a/src/components/molecules/FormFields/Price/Dynamic.tsx +++ b/src/components/molecules/FormFields/Price/Dynamic.tsx @@ -100,21 +100,54 @@ export default function Dynamic({ /> +
+
+ + +
+
+ + +
+
+ + +
+
+
- - + You will get:
+ 100% share of pool
{error && ( diff --git a/src/components/molecules/FormFields/Price/index.tsx b/src/components/molecules/FormFields/Price/index.tsx index 86b3b7cbb..dff92356f 100644 --- a/src/components/molecules/FormFields/Price/index.tsx +++ b/src/components/molecules/FormFields/Price/index.tsx @@ -26,6 +26,8 @@ const query = graphql` tooltips { poolInfo liquidityProviderFee + communityFee + marketplaceFee } } } From 053717ac9513688415f35518095628ba270437b9 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sat, 19 Sep 2020 10:50:28 +0000 Subject: [PATCH 03/15] refactoring --- src/@types/MetaData.d.ts | 5 +- .../FormFields/Price/Dynamic.module.css | 21 +----- .../molecules/FormFields/Price/Dynamic.tsx | 56 +++------------- .../FormFields/Price/Fees.module.css | 22 +++++++ .../molecules/FormFields/Price/Fees.tsx | 64 +++++++++++++++++++ .../molecules/FormFields/Price/index.tsx | 3 +- src/models/FormPublish.ts | 2 + 7 files changed, 102 insertions(+), 71 deletions(-) create mode 100644 src/components/molecules/FormFields/Price/Fees.module.css create mode 100644 src/components/molecules/FormFields/Price/Fees.tsx diff --git a/src/@types/MetaData.d.ts b/src/@types/MetaData.d.ts index df787238c..023101e30 100644 --- a/src/@types/MetaData.d.ts +++ b/src/@types/MetaData.d.ts @@ -13,7 +13,10 @@ export interface AdditionalInformationMarket extends AdditionalInformation { } export interface MetadataMarket extends Metadata { - additionalInformation: AdditionalInformationMarket + // While required for this market, Aquarius/Plecos will keep this as optional + // allowing external pushes of assets without `additionalInformation`. + // Making it optional here helps safeguarding against those assets. + additionalInformation?: AdditionalInformationMarket } export interface MetadataPublishForm { diff --git a/src/components/molecules/FormFields/Price/Dynamic.module.css b/src/components/molecules/FormFields/Price/Dynamic.module.css index 4c530312f..9eb4d843b 100644 --- a/src/components/molecules/FormFields/Price/Dynamic.module.css +++ b/src/components/molecules/FormFields/Price/Dynamic.module.css @@ -34,8 +34,7 @@ padding-bottom: calc(var(--spacer) / 3); } -.tokens, -.fees { +.tokens { display: grid; margin-left: -2rem; @@ -49,24 +48,6 @@ } } -.fees { - margin-top: var(--spacer); - padding: var(--spacer); - padding-top: 0; - gap: var(--spacer); - grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); - align-items: center; - border-bottom: 1px solid var(--brand-grey-lighter); -} - -.fees label { - white-space: nowrap; -} - -.fees input { - max-width: 5rem; -} - .summary { margin-top: var(--spacer); } diff --git a/src/components/molecules/FormFields/Price/Dynamic.tsx b/src/components/molecules/FormFields/Price/Dynamic.tsx index bf3e4d9c5..c82030e97 100644 --- a/src/components/molecules/FormFields/Price/Dynamic.tsx +++ b/src/components/molecules/FormFields/Price/Dynamic.tsx @@ -8,9 +8,8 @@ import Alert from '../../../atoms/Alert' import Coin from './Coin' import { isCorrectNetwork } from '../../../../utils/wallet' import { useSiteMetadata } from '../../../../hooks/useSiteMetadata' -import InputElement from '../../../atoms/Input/InputElement' -import Label from '../../../atoms/Input/Label' import Tooltip from '../../../atoms/Tooltip' +import Fees from './Fees' export default function Dynamic({ ocean, @@ -39,14 +38,14 @@ export default function Dynamic({ c.toUpperCase() ) - // Check: account, network & insuffciant balance + // Check: account, network & insufficient balance useEffect(() => { if (!account) { setError(`No account connected. Please connect your Web3 wallet.`) } else if (!correctNetwork) { setError(`Wrong Network. Please connect to ${desiredNetworkName}.`) } else if (Number(balance.ocean) < Number(ocean)) { - setError(`Insufficiant balance. You need at least ${ocean} OCEAN`) + setError(`Insufficient balance. You need at least ${ocean} OCEAN`) } else { setError(undefined) } @@ -100,50 +99,11 @@ export default function Dynamic({ /> -
-
- - -
-
- - -
-
- - -
-
+