mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
effect dependency fixes
This commit is contained in:
parent
3e4b79fc42
commit
40f9170eb4
@ -76,9 +76,11 @@ export default function FormStartCompute({
|
||||
validUntil?: string
|
||||
}): ReactElement {
|
||||
const { siteContent } = useMarketMetadata()
|
||||
const { accountId, balance } = useWeb3()
|
||||
const { isValid, values }: FormikContextType<{ algorithm: string }> =
|
||||
useFormikContext()
|
||||
const { asset, isAssetNetwork } = useAsset()
|
||||
|
||||
const [totalPrice, setTotalPrice] = useState('0')
|
||||
const [datasetOrderPrice, setDatasetOrderPrice] = useState(
|
||||
asset?.accessDetails?.price
|
||||
@ -87,7 +89,6 @@ export default function FormStartCompute({
|
||||
selectedAlgorithmAsset?.accessDetails?.price
|
||||
)
|
||||
const [isBalanceSufficient, setIsBalanceSufficient] = useState<boolean>(false)
|
||||
const { accountId, balance } = useWeb3()
|
||||
|
||||
function getAlgorithmAsset(algorithmId: string): Asset {
|
||||
let assetDdo = null
|
||||
@ -99,6 +100,7 @@ export default function FormStartCompute({
|
||||
|
||||
useEffect(() => {
|
||||
if (!values.algorithm || !accountId || !isConsumable) return
|
||||
|
||||
async function fetchAlgorithmAssetExtended() {
|
||||
const algorithmAsset = getAlgorithmAsset(values.algorithm)
|
||||
const accessDetails = await getAccessDetails(
|
||||
@ -159,15 +161,17 @@ export default function FormStartCompute({
|
||||
hasPreviousOrderSelectedComputeAsset,
|
||||
hasDatatokenSelectedComputeAsset,
|
||||
datasetOrderPriceAndFees,
|
||||
algoOrderPriceAndFees
|
||||
algoOrderPriceAndFees,
|
||||
providerFeeAmount
|
||||
])
|
||||
|
||||
useEffect(() => {
|
||||
if (!totalPrice) return
|
||||
if (!totalPrice || !balance?.ocean || !dtBalance) return
|
||||
|
||||
setIsBalanceSufficient(
|
||||
compareAsBN(balance.ocean, `${totalPrice}`) || Number(dtBalance) >= 1
|
||||
)
|
||||
}, [totalPrice])
|
||||
}, [totalPrice, balance?.ocean, dtBalance])
|
||||
|
||||
return (
|
||||
<Form className={styles.form}>
|
||||
|
Loading…
Reference in New Issue
Block a user