diff --git a/src/components/Asset/AssetActions/Compute/FormComputeDataset.tsx b/src/components/Asset/AssetActions/Compute/FormComputeDataset.tsx index 4919e633f..e991f02bb 100644 --- a/src/components/Asset/AssetActions/Compute/FormComputeDataset.tsx +++ b/src/components/Asset/AssetActions/Compute/FormComputeDataset.tsx @@ -74,6 +74,12 @@ export default function FormStartCompute({ useFormikContext() const { asset, isAssetNetwork } = useAsset() const [totalPrice, setTotalPrice] = useState(asset?.accessDetails?.price) + const [datasetOrderPrice, setDatasetOrderPrice] = useState( + asset?.accessDetails?.price + ) + const [algoOrderPrice, setAlgoOrderPrice] = useState( + selectedAlgorithmAsset?.accessDetails?.price + ) const [isBalanceSufficient, setIsBalanceSufficient] = useState(false) const { accountId, balance } = useWeb3() @@ -110,6 +116,13 @@ export default function FormStartCompute({ useEffect(() => { if (!asset?.accessDetails || !selectedAlgorithmAsset?.accessDetails) return + setDatasetOrderPrice( + datasetOrderPriceAndFees?.price || asset.accessDetails.price + ) + setAlgoOrderPrice( + algoOrderPriceAndFees?.price || + selectedAlgorithmAsset?.accessDetails.price + ) const priceDataset = hasPreviousOrder || hasDatatoken ? 0 @@ -164,6 +177,8 @@ export default function FormStartCompute({ algorithmConsumeDetails={selectedAlgorithmAsset?.accessDetails} symbol={oceanSymbol} totalPrice={Number.parseFloat(totalPrice)} + datasetOrderPrice={datasetOrderPrice} + algoOrderPrice={algoOrderPrice} /> () + const [isRequestingDataseOrderPrice, setIsRequestingDataseOrderPrice] = + useState(false) const [algoOrderPriceAndFees, setAlgoOrderPriceAndFees] = useState() + const [isRequestingAlgoOrderPrice, setIsRequestingAlgoOrderPrice] = + useState(false) const isComputeButtonDisabled = isJobStarting === true || file === null || @@ -119,8 +123,12 @@ export default function Compute({ asset?.accessDetails?.type === 'free' ) return + + setIsRequestingDataseOrderPrice(true) + setComputeStatusText('Calculating price including fees.') const orderPriceAndFees = await getOrderPriceAndFees(asset, accountId) setDatasetOrderPriceAndFees(orderPriceAndFees) + setIsRequestingDataseOrderPrice(false) } initDatasetPriceAndFees() @@ -141,11 +149,15 @@ export default function Compute({ selectedAlgorithmAsset?.accessDetails?.type === 'free' ) return + + setIsRequestingAlgoOrderPrice(true) + setComputeStatusText('Calculating price including fees.') const orderPriceAndFees = await getOrderPriceAndFees( selectedAlgorithmAsset, accountId ) setAlgoOrderPriceAndFees(orderPriceAndFees) + setIsRequestingAlgoOrderPrice(false) } async function initSelectedAlgo() { @@ -444,7 +456,11 @@ export default function Compute({ ddoListAlgorithms={ddoAlgorithmList} selectedAlgorithmAsset={selectedAlgorithmAsset} setSelectedAlgorithm={setSelectedAlgorithmAsset} - isLoading={isJobStarting} + isLoading={ + isJobStarting || + isRequestingDataseOrderPrice || + isRequestingAlgoOrderPrice + } isComputeButtonDisabled={isComputeButtonDisabled} hasPreviousOrder={validOrderTx !== undefined} hasDatatoken={hasDatatoken}