From 70caeb5d804e80d7cb062cc40024eb6d6914b04b Mon Sep 17 00:00:00 2001 From: mihaisc Date: Tue, 27 Oct 2020 19:56:14 +0200 Subject: [PATCH 1/2] fixed price and gas estimate Signed-off-by: mihaisc --- package-lock.json | 26 +++++++++---------- package.json | 4 +-- .../Pricing/FormPricing/index.tsx | 4 ++- .../organisms/AssetContent/index.tsx | 2 +- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index cd2d92e5a..31f380b5a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3850,9 +3850,9 @@ "integrity": "sha512-p0oOHXr60hXZuLNsQ/PsOQtCfia79thm7MjPxTrnnBvD+csJoHzARYMB0IFj/KTw6U5vLXODgjJAn8x6QksLwg==" }, "@oceanprotocol/lib": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.9.0.tgz", - "integrity": "sha512-BI00ZXTdGXJZNTJhwtqsnXjKtlcl1PXB18e26aCo5g1VT9S19urPLT04k9Zkz4k+3HepSc5QdOu+yo47MS1I7g==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.9.3.tgz", + "integrity": "sha512-eUTM5D5AZ1eDfzAYSqML1fELXOTXy0Zj7y8NuSlyN9Ersg7e9G8lIWCAA49pcBNCJ41niG/lpAuIpiUPd2eFpA==", "requires": { "@ethereum-navigator/navigator": "^0.5.0", "@oceanprotocol/contracts": "^0.5.7", @@ -3867,11 +3867,11 @@ } }, "@oceanprotocol/react": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@oceanprotocol/react/-/react-0.3.9.tgz", - "integrity": "sha512-qsaQVSQtHL+5QoknrVuJOdRr2mQ+2An368yNYzsMbxaAKp6HJ7b3p9bfqV0WQqaMA10GqTyfUi1GUJq630h9DA==", + "version": "0.3.10", + "resolved": "https://registry.npmjs.org/@oceanprotocol/react/-/react-0.3.10.tgz", + "integrity": "sha512-NlnWq/AxhtdfjeVAxKboODHUnlJT0kAcB4KAJEC4boDvPW6pWVhJlyEwt1+JiJuefq/YyppxqnY21yrTkUE3wA==", "requires": { - "@oceanprotocol/lib": "^0.9.0", + "@oceanprotocol/lib": "^0.9.3", "axios": "^0.21.0", "decimal.js": "^10.2.1", "web3": "^1.3.0", @@ -34850,9 +34850,9 @@ }, "dependencies": { "@types/node": { - "version": "12.19.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.19.1.tgz", - "integrity": "sha512-/xaVmBBjOGh55WCqumLAHXU9VhjGtmyTGqJzFBXRWZzByOXI5JAJNx9xPVGEsNizrNwcec92fQMj458MWfjN1A==" + "version": "12.19.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.19.2.tgz", + "integrity": "sha512-SRH6QM0IMOBBFmDiJ75vlhcbUEYEquvSuhsVW9ijG20JvdFTfOrB1p6ddZxz5y/JNnbf+9HoHhjhOVSX2hsJyA==" } } }, @@ -35050,9 +35050,9 @@ }, "dependencies": { "@types/node": { - "version": "12.19.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.19.1.tgz", - "integrity": "sha512-/xaVmBBjOGh55WCqumLAHXU9VhjGtmyTGqJzFBXRWZzByOXI5JAJNx9xPVGEsNizrNwcec92fQMj458MWfjN1A==" + "version": "12.19.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.19.2.tgz", + "integrity": "sha512-SRH6QM0IMOBBFmDiJ75vlhcbUEYEquvSuhsVW9ijG20JvdFTfOrB1p6ddZxz5y/JNnbf+9HoHhjhOVSX2hsJyA==" } } }, diff --git a/package.json b/package.json index 730c517ca..97b973fa2 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,8 @@ "@coingecko/cryptoformat": "^0.4.2", "@loadable/component": "5.13.1", "@oceanprotocol/art": "^3.0.0", - "@oceanprotocol/lib": "^0.9.0", - "@oceanprotocol/react": "^0.3.9", + "@oceanprotocol/lib": "^0.9.3", + "@oceanprotocol/react": "^0.3.10", "@oceanprotocol/typographies": "^0.1.0", "@sindresorhus/slugify": "^1.0.0", "@tippyjs/react": "^4.2.0", diff --git a/src/components/organisms/AssetContent/Pricing/FormPricing/index.tsx b/src/components/organisms/AssetContent/Pricing/FormPricing/index.tsx index b5f46707a..4497655b8 100644 --- a/src/components/organisms/AssetContent/Pricing/FormPricing/index.tsx +++ b/src/components/organisms/AssetContent/Pricing/FormPricing/index.tsx @@ -35,16 +35,18 @@ export default function FormPricing({ function handleTabChange(tabName: string) { const type = tabName.toLowerCase() setFieldValue('type', type) + type == 'fixed' && setFieldValue('dtAmount', 1000) } // Always update everything when price value changes useEffect(() => { + if (type === 'fixed') return const dtAmount = (Number(oceanAmount) / Number(weightOnOcean) / price) * Number(weightOnDataToken) setFieldValue('dtAmount', dtAmount) - }, [price, oceanAmount, weightOnOcean, weightOnDataToken]) + }, [price, oceanAmount, weightOnOcean, weightOnDataToken, type]) const tabs = [ { diff --git a/src/components/organisms/AssetContent/index.tsx b/src/components/organisms/AssetContent/index.tsx index 63178ff73..cd122462a 100644 --- a/src/components/organisms/AssetContent/index.tsx +++ b/src/components/organisms/AssetContent/index.tsx @@ -29,7 +29,7 @@ export default function AssetContent({ const { dtSymbol, dtName } = usePricing(ddo) const isOwner = accountId === ddo.publicKey[0].owner - const hasNoPrice = ddo.price.type === '' + const hasNoPrice = ddo.price.datatoken == 0 && ddo.price.value == 0 const showPricing = isOwner && hasNoPrice return ( From ae84db194ce4b77b39dc64ff95fc665f1d0d0f34 Mon Sep 17 00:00:00 2001 From: mihaisc Date: Tue, 27 Oct 2020 20:03:19 +0200 Subject: [PATCH 2/2] fix Signed-off-by: mihaisc --- .../organisms/AssetContent/Pricing/FormPricing/index.tsx | 2 +- src/components/organisms/AssetContent/index.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/organisms/AssetContent/Pricing/FormPricing/index.tsx b/src/components/organisms/AssetContent/Pricing/FormPricing/index.tsx index 4497655b8..e9e64a28e 100644 --- a/src/components/organisms/AssetContent/Pricing/FormPricing/index.tsx +++ b/src/components/organisms/AssetContent/Pricing/FormPricing/index.tsx @@ -35,7 +35,7 @@ export default function FormPricing({ function handleTabChange(tabName: string) { const type = tabName.toLowerCase() setFieldValue('type', type) - type == 'fixed' && setFieldValue('dtAmount', 1000) + type === 'fixed' && setFieldValue('dtAmount', 1000) } // Always update everything when price value changes diff --git a/src/components/organisms/AssetContent/index.tsx b/src/components/organisms/AssetContent/index.tsx index cd122462a..5e08ef182 100644 --- a/src/components/organisms/AssetContent/index.tsx +++ b/src/components/organisms/AssetContent/index.tsx @@ -29,7 +29,7 @@ export default function AssetContent({ const { dtSymbol, dtName } = usePricing(ddo) const isOwner = accountId === ddo.publicKey[0].owner - const hasNoPrice = ddo.price.datatoken == 0 && ddo.price.value == 0 + const hasNoPrice = ddo.price.datatoken === 0 && ddo.price.value === 0 const showPricing = isOwner && hasNoPrice return (