diff --git a/package-lock.json b/package-lock.json index cb49b17b2..c719f4f7a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3850,9 +3850,9 @@ "integrity": "sha512-p0oOHXr60hXZuLNsQ/PsOQtCfia79thm7MjPxTrnnBvD+csJoHzARYMB0IFj/KTw6U5vLXODgjJAn8x6QksLwg==" }, "@oceanprotocol/lib": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.8.0.tgz", - "integrity": "sha512-FZALOw3LMAPo2US+YjJv5Fkz7IDS9m89PZzF7uKZKYT8V3xB/m0PV91vV1pEPC0eVWk3Sl1IXyT0L3ASFEUjvg==", + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.9.0.tgz", + "integrity": "sha512-BI00ZXTdGXJZNTJhwtqsnXjKtlcl1PXB18e26aCo5g1VT9S19urPLT04k9Zkz4k+3HepSc5QdOu+yo47MS1I7g==", "requires": { "@ethereum-navigator/navigator": "^0.5.0", "@oceanprotocol/contracts": "^0.5.7", @@ -3867,12 +3867,12 @@ } }, "@oceanprotocol/react": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/@oceanprotocol/react/-/react-0.3.8.tgz", - "integrity": "sha512-cbijintJy5Cg5/FFhLNfgIgmxRHCDZnv9zoMOeQJE28fwG/jOAkU+r3G4OK0EvFm9BXDsBxqoZxOO6Eb1EpV6w==", + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@oceanprotocol/react/-/react-0.3.9.tgz", + "integrity": "sha512-qsaQVSQtHL+5QoknrVuJOdRr2mQ+2An368yNYzsMbxaAKp6HJ7b3p9bfqV0WQqaMA10GqTyfUi1GUJq630h9DA==", "requires": { - "@oceanprotocol/lib": "^0.8.0", - "axios": "^0.20.0", + "@oceanprotocol/lib": "^0.9.0", + "axios": "^0.21.0", "decimal.js": "^10.2.1", "web3": "^1.3.0", "web3modal": "^1.9.1" @@ -9105,9 +9105,9 @@ "integrity": "sha512-5P0QZ6J5xGikH780pghEdbEKijCTrruK9KxtPZCFWUpef0f6GipO+xEZ5GKCb020mmqgbiNO6TcA55CriL784Q==" }, "axios": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.20.0.tgz", - "integrity": "sha512-ANA4rr2BDcmmAQLOKft2fufrtuvlqR+cXNNinUmvfeSNCOF98PZL+7M/v1zIdGo7OLjEA9J2gXJL+j4zGsl0bA==", + "version": "0.21.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.0.tgz", + "integrity": "sha512-fmkJBknJKoZwem3/IKSSLpkdNXZeBu5Q7GA/aRsr2btgrptmSCxi2oFjZHqGdK9DoTil9PIHlPIZw2EcRJXRvw==", "requires": { "follow-redirects": "^1.10.0" } @@ -17246,6 +17246,14 @@ "color-convert": "^2.0.1" } }, + "axios": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.20.0.tgz", + "integrity": "sha512-ANA4rr2BDcmmAQLOKft2fufrtuvlqR+cXNNinUmvfeSNCOF98PZL+7M/v1zIdGo7OLjEA9J2gXJL+j4zGsl0bA==", + "requires": { + "follow-redirects": "^1.10.0" + } + }, "cacheable-request": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-2.1.4.tgz", @@ -34833,9 +34841,9 @@ }, "dependencies": { "@types/node": { - "version": "12.19.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.19.0.tgz", - "integrity": "sha512-4BVAE9yp5DU3ISqBInsaRp9J474HWNaNVs8eZ1Far3dI1MwS3Wk0EvBRMM4xBh3Oz+c05hUgJmcbtAVmG8bv7w==" + "version": "12.19.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.19.1.tgz", + "integrity": "sha512-/xaVmBBjOGh55WCqumLAHXU9VhjGtmyTGqJzFBXRWZzByOXI5JAJNx9xPVGEsNizrNwcec92fQMj458MWfjN1A==" } } }, @@ -35033,9 +35041,9 @@ }, "dependencies": { "@types/node": { - "version": "12.19.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.19.0.tgz", - "integrity": "sha512-4BVAE9yp5DU3ISqBInsaRp9J474HWNaNVs8eZ1Far3dI1MwS3Wk0EvBRMM4xBh3Oz+c05hUgJmcbtAVmG8bv7w==" + "version": "12.19.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.19.1.tgz", + "integrity": "sha512-/xaVmBBjOGh55WCqumLAHXU9VhjGtmyTGqJzFBXRWZzByOXI5JAJNx9xPVGEsNizrNwcec92fQMj458MWfjN1A==" } } }, diff --git a/package.json b/package.json index 3a0c1f7ca..ecab63a4c 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.8.0", - "@oceanprotocol/react": "^0.3.8", + "@oceanprotocol/lib": "^0.9.0", + "@oceanprotocol/react": "^0.3.9", "@oceanprotocol/typographies": "^0.1.0", "@sindresorhus/slugify": "^1.0.0", "@tippyjs/react": "^4.2.0", @@ -31,7 +31,7 @@ "@types/classnames": "^2.2.10", "@vercel/node": "^1.8.4", "@walletconnect/web3-provider": "^1.3.1", - "axios": "^0.20.0", + "axios": "^0.21.0", "classnames": "^2.2.6", "date-fns": "^2.16.1", "decimal.js": "^10.2.1", diff --git a/src/@types/MetaData.d.ts b/src/@types/MetaData.d.ts index 8c3ef5567..0c550d974 100644 --- a/src/@types/MetaData.d.ts +++ b/src/@types/MetaData.d.ts @@ -21,7 +21,6 @@ export interface MetadataMarket extends Metadata { export interface PriceOptionsMarket extends PriceOptions { // easier to keep this as number for Yup input validation swapFee: number - oceanAmount: number } export interface MetadataPublishForm { diff --git a/src/components/organisms/AssetContent/Pricing/FormPricing/index.tsx b/src/components/organisms/AssetContent/Pricing/FormPricing/index.tsx index 287a5c2bb..ab774600d 100644 --- a/src/components/organisms/AssetContent/Pricing/FormPricing/index.tsx +++ b/src/components/organisms/AssetContent/Pricing/FormPricing/index.tsx @@ -23,7 +23,12 @@ export default function FormPricing({ // Connect with form const { values, setFieldValue, submitForm } = useFormikContext() - const { oceanAmount, weightOnDataToken, type } = values as PriceOptionsMarket + const { + price, + oceanAmount, + weightOnDataToken, + type + } = values as PriceOptionsMarket // Switch type value upon tab change function handleTabChange(tabName: string) { @@ -33,7 +38,10 @@ export default function FormPricing({ // Always update everything when price value changes useEffect(() => { - const dtAmount = Number(oceanAmount) * Number(weightOnDataToken) + const dtAmount = + (Number(oceanAmount) / Number(weightOnOcean) / price) * + Number(weightOnDataToken) + setFieldValue('dtAmount', dtAmount) }, [oceanAmount, weightOnDataToken])