1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

add back balance check for all use actions (#166)

This commit is contained in:
Matthias Kretschmann 2020-10-29 21:34:53 +01:00 committed by GitHub
parent 9d681fc594
commit 551f4ab7ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,10 +10,8 @@ import Pool from './Pool'
export default function AssetActions({ ddo }: { ddo: DDO }): ReactElement { export default function AssetActions({ ddo }: { ddo: DDO }): ReactElement {
const { ocean, balance, accountId } = useOcean() const { ocean, balance, accountId } = useOcean()
// const { price } = useMetadata(ddo) const { price } = useMetadata(ddo)
// TODO: quick hack for const [isBalanceSufficient, setIsBalanceSufficient] = useState<boolean>()
// https://github.com/oceanprotocol/market/issues/145
const [isBalanceSufficient, setIsBalanceSufficient] = useState<boolean>(true)
const [dtBalance, setDtBalance] = useState<string>() const [dtBalance, setDtBalance] = useState<string>()
const isCompute = Boolean(ddo.findServiceByType('compute')) const isCompute = Boolean(ddo.findServiceByType('compute'))
@ -37,22 +35,19 @@ export default function AssetActions({ ddo }: { ddo: DDO }): ReactElement {
init() init()
}, [ocean, accountId, ddo.dataToken]) }, [ocean, accountId, ddo.dataToken])
// TODO: quick hack for
// https://github.com/oceanprotocol/market/issues/145
// Check user balance against price // Check user balance against price
// useEffect(() => { useEffect(() => {
// if (!price || !price.value || !balance || !balance.ocean || !dtBalance) if (!price || !price.value || !balance || !balance.ocean || !dtBalance)
// return return
// setIsBalanceSufficient( setIsBalanceSufficient(
// compareAsBN(balance.ocean, `${price.value}`) || Number(dtBalance) >= 1 compareAsBN(balance.ocean, `${price.value}`) || Number(dtBalance) >= 1
// ) )
// return () => { return () => {
// setIsBalanceSufficient(false) setIsBalanceSufficient(false)
// } }
// }, [balance, price, dtBalance]) }, [balance, price, dtBalance])
const UseContent = isCompute ? ( const UseContent = isCompute ? (
<Compute <Compute