mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
updates for new @oceanprotocol/react price model
This commit is contained in:
parent
cda52aef1c
commit
a4510459f1
47
package-lock.json
generated
47
package-lock.json
generated
@ -1704,10 +1704,7 @@
|
||||
"cross-fetch": {
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.0.5.tgz",
|
||||
"integrity": "sha512-FFLcLtraisj5eteosnX1gf01qYDCOc4fDy0+euOt8Kn9YBY2NtXL/pCoYPavw24NIQkQqm5ZOLsGD5Zzj0gyew==",
|
||||
"requires": {
|
||||
"node-fetch": "2.6.0"
|
||||
}
|
||||
"integrity": "sha512-FFLcLtraisj5eteosnX1gf01qYDCOc4fDy0+euOt8Kn9YBY2NtXL/pCoYPavw24NIQkQqm5ZOLsGD5Zzj0gyew=="
|
||||
},
|
||||
"form-data": {
|
||||
"version": "3.0.0",
|
||||
@ -3351,11 +3348,11 @@
|
||||
}
|
||||
},
|
||||
"@oceanprotocol/react": {
|
||||
"version": "0.0.42",
|
||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/react/-/react-0.0.42.tgz",
|
||||
"integrity": "sha512-7CBE4utcoZrK1aLTV3bxUBE6LisbImYS2gTmRBbylL00RUwWHlLqQBzkdIOkw8VYFUi72kcDvEuZkHQDiMDacg==",
|
||||
"version": "0.0.43",
|
||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/react/-/react-0.0.43.tgz",
|
||||
"integrity": "sha512-dkhz+olYmCjYsZHvXxzbZry5d37JL+Hevgg1Iwsqkc94Qb3FfvjiRSv1zEHs2ZVimGXPlp3z5a2ChVFr/sjjsA==",
|
||||
"requires": {
|
||||
"@oceanprotocol/lib": "^0.2.3",
|
||||
"@oceanprotocol/lib": "^0.2.4",
|
||||
"axios": "^0.20.0",
|
||||
"decimal.js": "^10.2.0",
|
||||
"web3": "^1.2.11",
|
||||
@ -5429,9 +5426,9 @@
|
||||
}
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "14.6.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.6.4.tgz",
|
||||
"integrity": "sha512-Wk7nG1JSaMfMpoMJDKUsWYugliB2Vy55pdjLpmLixeyMi7HizW2I/9QoxsPCkXl3dO+ZOVqPumKaDUv5zJu2uQ=="
|
||||
"version": "14.10.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.10.0.tgz",
|
||||
"integrity": "sha512-SOIyrdADB4cq6eY1F+9iU48iIomFAPltu11LCvA9PKcyEwHadjCFzNVPotAR+oEJA0bCP4Xvvgy+vwu1ZjVh8g=="
|
||||
},
|
||||
"@types/node-fetch": {
|
||||
"version": "2.5.7",
|
||||
@ -13243,20 +13240,20 @@
|
||||
}
|
||||
},
|
||||
"eth-json-rpc-infura": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/eth-json-rpc-infura/-/eth-json-rpc-infura-4.0.2.tgz",
|
||||
"integrity": "sha512-dvgOrci9lZqpjpp0hoC3Zfedhg3aIpLFVDH0TdlKxRlkhR75hTrKTwxghDrQwE0bn3eKrC8RsN1m/JdnIWltpw==",
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/eth-json-rpc-infura/-/eth-json-rpc-infura-4.1.0.tgz",
|
||||
"integrity": "sha512-DFYitKovzVlCdUulEccdm4g6k/vnvyByuw7rd5OoWDBSIiaeinI8Z/SntLjSIs2c+YvE20DGwk/GLwZGCWDN1Q==",
|
||||
"requires": {
|
||||
"cross-fetch": "^2.1.1",
|
||||
"eth-json-rpc-errors": "^1.0.1",
|
||||
"eth-json-rpc-middleware": "^4.1.4",
|
||||
"json-rpc-engine": "^5.1.3"
|
||||
"eth-json-rpc-middleware": "^4.4.0",
|
||||
"eth-rpc-errors": "^3.0.0",
|
||||
"json-rpc-engine": "^5.1.3",
|
||||
"node-fetch": "^2.6.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"eth-json-rpc-errors": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/eth-json-rpc-errors/-/eth-json-rpc-errors-1.1.1.tgz",
|
||||
"integrity": "sha512-WT5shJ5KfNqHi9jOZD+ID8I1kuYWNrigtZat7GOQkvwo99f8SzAVaEcWhJUv656WiZOAg3P1RiJQANtUmDmbIg==",
|
||||
"eth-rpc-errors": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/eth-rpc-errors/-/eth-rpc-errors-3.0.0.tgz",
|
||||
"integrity": "sha512-iPPNHPrLwUlR9xCSYm7HHQjWBasor3+KZfRvwEWxMz3ca0yqnlBeJrnyphkGIXZ4J7AMAaOLmwy4AWhnxOiLxg==",
|
||||
"requires": {
|
||||
"fast-safe-stringify": "^2.0.6"
|
||||
}
|
||||
@ -25492,9 +25489,9 @@
|
||||
"integrity": "sha1-n7CwmbzSoCGUDmA8ZCVNwAPZp6g="
|
||||
},
|
||||
"node-fetch": {
|
||||
"version": "2.6.0",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz",
|
||||
"integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA=="
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
|
||||
},
|
||||
"node-forge": {
|
||||
"version": "0.9.0",
|
||||
|
@ -23,7 +23,7 @@
|
||||
"@loadable/component": "^5.13.1",
|
||||
"@oceanprotocol/art": "^3.0.0",
|
||||
"@oceanprotocol/lib": "^0.2.4",
|
||||
"@oceanprotocol/react": "^0.0.42",
|
||||
"@oceanprotocol/react": "^0.0.43",
|
||||
"@oceanprotocol/typographies": "^0.1.0",
|
||||
"@sindresorhus/slugify": "^1.0.0",
|
||||
"@tippyjs/react": "^4.1.0",
|
||||
@ -88,7 +88,7 @@
|
||||
"@types/loadable__component": "^5.13.0",
|
||||
"@types/lodash.debounce": "^4.0.3",
|
||||
"@types/lodash.omit": "^4.5.6",
|
||||
"@types/node": "^14.6.4",
|
||||
"@types/node": "^14.10.0",
|
||||
"@types/react": "^16.9.49",
|
||||
"@types/react-datepicker": "^3.1.1",
|
||||
"@types/react-helmet": "^6.1.0",
|
||||
|
@ -22,14 +22,14 @@ export default function Price({
|
||||
|
||||
return !ocean ? (
|
||||
<div className={styles.empty}>Connect your wallet to view price</div>
|
||||
) : price ? (
|
||||
) : price && price.value ? (
|
||||
<PriceUnit
|
||||
price={price}
|
||||
price={price.value}
|
||||
className={className}
|
||||
small={small}
|
||||
conversion={conversion}
|
||||
/>
|
||||
) : price === '' ? (
|
||||
) : price && price.value === '' ? (
|
||||
<div className={styles.empty}>
|
||||
No price found{' '}
|
||||
<Tooltip content="We could not find a pool for this data set, which can have multiple reasons. Is your wallet connected to the correct network?" />
|
||||
|
@ -26,7 +26,7 @@ export interface Balance {
|
||||
export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
|
||||
const { debug } = useUserPreferences()
|
||||
const { ocean, accountId } = useOcean()
|
||||
const { price, poolAddress } = useMetadata(ddo)
|
||||
const { price } = useMetadata(ddo)
|
||||
|
||||
const [poolTokens, setPoolTokens] = useState<string>()
|
||||
const [totalPoolTokens, setTotalPoolTokens] = useState<string>()
|
||||
@ -47,7 +47,7 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
|
||||
((Number(poolTokens) / Number(totalPoolTokens)) * 100).toFixed(2)
|
||||
|
||||
useEffect(() => {
|
||||
if (!ocean || !accountId || !poolAddress || !price) return
|
||||
if (!ocean || !accountId || !price || !price.value) return
|
||||
|
||||
async function init() {
|
||||
setIsLoading(true)
|
||||
@ -67,15 +67,18 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
|
||||
//
|
||||
const oceanReserve = await ocean.pool.getOceanReserve(
|
||||
accountId,
|
||||
poolAddress
|
||||
price.address
|
||||
)
|
||||
const dtReserve = await ocean.pool.getDTReserve(
|
||||
accountId,
|
||||
price.address
|
||||
)
|
||||
const dtReserve = await ocean.pool.getDTReserve(accountId, poolAddress)
|
||||
setTotalBalance({
|
||||
ocean: oceanReserve,
|
||||
dt: dtReserve
|
||||
})
|
||||
|
||||
const totalPoolTokens = await ocean.pool.totalSupply(poolAddress)
|
||||
const totalPoolTokens = await ocean.pool.totalSupply(price.address)
|
||||
setTotalPoolTokens(totalPoolTokens)
|
||||
|
||||
//
|
||||
@ -83,7 +86,7 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
|
||||
//
|
||||
const poolTokens = await ocean.pool.sharesBalance(
|
||||
accountId,
|
||||
poolAddress
|
||||
price.address
|
||||
)
|
||||
setPoolTokens(poolTokens)
|
||||
|
||||
@ -107,7 +110,7 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
|
||||
}
|
||||
}
|
||||
init()
|
||||
}, [ocean, accountId, price, poolAddress])
|
||||
}, [ocean, accountId, price])
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -116,25 +119,28 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
|
||||
) : showAdd ? (
|
||||
<Add
|
||||
setShowAdd={setShowAdd}
|
||||
poolAddress={poolAddress}
|
||||
poolAddress={price.address}
|
||||
totalPoolTokens={totalPoolTokens}
|
||||
totalBalance={totalBalance}
|
||||
/>
|
||||
) : showRemove ? (
|
||||
<Remove
|
||||
setShowRemove={setShowRemove}
|
||||
poolAddress={poolAddress}
|
||||
poolAddress={price.address}
|
||||
totalPoolTokens={totalPoolTokens}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<div className={styles.dataToken}>
|
||||
<PriceUnit price="1" symbol={dtSymbol} /> ={' '}
|
||||
<PriceUnit price={price} />
|
||||
<Conversion price={price} />
|
||||
<PriceUnit price={price.value} />
|
||||
<Conversion price={price.value} />
|
||||
<Tooltip content="Explain how this price is determined..." />
|
||||
<div className={styles.dataTokenLinks}>
|
||||
<EtherscanLink network="rinkeby" path={`address/${poolAddress}`}>
|
||||
<EtherscanLink
|
||||
network="rinkeby"
|
||||
path={`address/${price.address}`}
|
||||
>
|
||||
Pool
|
||||
</EtherscanLink>
|
||||
<EtherscanLink network="rinkeby" path={`token/${ddo.dataToken}`}>
|
||||
|
@ -19,10 +19,13 @@ export default function AssetActions({ ddo }: { ddo: DDO }): ReactElement {
|
||||
|
||||
// Check user balance against price
|
||||
useEffect(() => {
|
||||
if (!price || !balance || !balance.ocean) return
|
||||
if (!price || !price.value || !balance || !balance.ocean) return
|
||||
|
||||
const isFree = price === '0'
|
||||
setIsBalanceSufficient(isFree ? true : compareAsBN(balance.ocean, price))
|
||||
const isFree = price.value === '0'
|
||||
|
||||
setIsBalanceSufficient(
|
||||
isFree ? true : compareAsBN(balance.ocean, price.value)
|
||||
)
|
||||
|
||||
return () => {
|
||||
setIsBalanceSufficient(false)
|
||||
|
Loading…
Reference in New Issue
Block a user