mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
fix connection and networks calculations
This commit is contained in:
parent
8c88d512bf
commit
589963e368
@ -119,28 +119,29 @@ export default function FormStartCompute({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!asset?.accessDetails || !selectedAlgorithmAsset?.accessDetails) return
|
if (!asset?.accessDetails || !selectedAlgorithmAsset?.accessDetails) return
|
||||||
|
|
||||||
setDatasetOrderPrice(
|
|
||||||
datasetOrderPriceAndFees?.price || asset.accessDetails.price
|
|
||||||
)
|
|
||||||
|
|
||||||
setAlgoOrderPrice(
|
|
||||||
algoOrderPriceAndFees?.price ||
|
|
||||||
selectedAlgorithmAsset?.accessDetails.price
|
|
||||||
)
|
|
||||||
const priceDataset = new Decimal(
|
const priceDataset = new Decimal(
|
||||||
hasPreviousOrder || hasDatatoken
|
isAssetNetwork
|
||||||
|
? hasPreviousOrder || hasDatatoken
|
||||||
? 0
|
? 0
|
||||||
: datasetOrderPriceAndFees?.price || asset.accessDetails.price
|
: datasetOrderPriceAndFees?.price || asset.accessDetails.price
|
||||||
|
: datasetOrderPriceAndFees?.price || asset.accessDetails.price
|
||||||
).toDecimalPlaces(MAX_DECIMALS)
|
).toDecimalPlaces(MAX_DECIMALS)
|
||||||
|
|
||||||
const priceAlgo =
|
setDatasetOrderPrice(priceDataset.toString())
|
||||||
hasPreviousOrderSelectedComputeAsset || hasDatatokenSelectedComputeAsset
|
|
||||||
? new Decimal(0)
|
const priceAlgo = new Decimal(
|
||||||
: new Decimal(
|
isAssetNetwork
|
||||||
algoOrderPriceAndFees?.price ||
|
? hasPreviousOrderSelectedComputeAsset ||
|
||||||
|
hasDatatokenSelectedComputeAsset
|
||||||
|
? 0
|
||||||
|
: algoOrderPriceAndFees?.price ||
|
||||||
|
selectedAlgorithmAsset.accessDetails.price
|
||||||
|
: algoOrderPriceAndFees?.price ||
|
||||||
selectedAlgorithmAsset.accessDetails.price
|
selectedAlgorithmAsset.accessDetails.price
|
||||||
).toDecimalPlaces(MAX_DECIMALS)
|
).toDecimalPlaces(MAX_DECIMALS)
|
||||||
|
|
||||||
|
setAlgoOrderPrice(priceAlgo.toString())
|
||||||
|
|
||||||
const providerFees = providerFeeAmount
|
const providerFees = providerFeeAmount
|
||||||
? new Decimal(providerFeeAmount).toDecimalPlaces(MAX_DECIMALS)
|
? new Decimal(providerFeeAmount).toDecimalPlaces(MAX_DECIMALS)
|
||||||
: new Decimal(0)
|
: new Decimal(0)
|
||||||
@ -160,7 +161,8 @@ export default function FormStartCompute({
|
|||||||
hasDatatokenSelectedComputeAsset,
|
hasDatatokenSelectedComputeAsset,
|
||||||
datasetOrderPriceAndFees,
|
datasetOrderPriceAndFees,
|
||||||
algoOrderPriceAndFees,
|
algoOrderPriceAndFees,
|
||||||
providerFeeAmount
|
providerFeeAmount,
|
||||||
|
isAssetNetwork
|
||||||
])
|
])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -175,6 +177,8 @@ export default function FormStartCompute({
|
|||||||
)
|
)
|
||||||
}, [totalPrice, balance, dtBalance, asset?.accessDetails?.baseToken?.symbol])
|
}, [totalPrice, balance, dtBalance, asset?.accessDetails?.baseToken?.symbol])
|
||||||
|
|
||||||
|
console.log(totalPrice, datasetOrderPrice, algoOrderPrice)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form className={styles.form}>
|
<Form className={styles.form}>
|
||||||
<Alert
|
<Alert
|
||||||
|
@ -5,6 +5,7 @@ import Tooltip from '@shared/atoms/Tooltip'
|
|||||||
import styles from './PriceOutput.module.css'
|
import styles from './PriceOutput.module.css'
|
||||||
import { MAX_DECIMALS } from '@utils/constants'
|
import { MAX_DECIMALS } from '@utils/constants'
|
||||||
import Decimal from 'decimal.js'
|
import Decimal from 'decimal.js'
|
||||||
|
import { useWeb3 } from '@context/Web3'
|
||||||
|
|
||||||
interface PriceOutputProps {
|
interface PriceOutputProps {
|
||||||
totalPrice: string
|
totalPrice: string
|
||||||
@ -39,13 +40,21 @@ function Row({
|
|||||||
sign?: string
|
sign?: string
|
||||||
type?: string
|
type?: string
|
||||||
}) {
|
}) {
|
||||||
|
const { isSupportedOceanNetwork } = useWeb3()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.priceRow}>
|
<div className={styles.priceRow}>
|
||||||
<div className={styles.sign}>{sign}</div>
|
<div className={styles.sign}>{sign}</div>
|
||||||
<div className={styles.type}>{type}</div>
|
<div className={styles.type}>{type}</div>
|
||||||
<div>
|
<div>
|
||||||
<PriceUnit
|
<PriceUnit
|
||||||
price={hasPreviousOrder || hasDatatoken ? 0 : Number(price)}
|
price={
|
||||||
|
!isSupportedOceanNetwork
|
||||||
|
? hasPreviousOrder || hasDatatoken
|
||||||
|
? 0
|
||||||
|
: Number(price)
|
||||||
|
: Number(price)
|
||||||
|
}
|
||||||
symbol={symbol}
|
symbol={symbol}
|
||||||
size="small"
|
size="small"
|
||||||
className={styles.price}
|
className={styles.price}
|
||||||
|
@ -45,6 +45,7 @@ import { getComputeFeedback } from '@utils/feedback'
|
|||||||
import { getDummyWeb3 } from '@utils/web3'
|
import { getDummyWeb3 } from '@utils/web3'
|
||||||
import { initializeProviderForCompute } from '@utils/provider'
|
import { initializeProviderForCompute } from '@utils/provider'
|
||||||
import { useUserPreferences } from '@context/UserPreferences'
|
import { useUserPreferences } from '@context/UserPreferences'
|
||||||
|
import { useAsset } from '@context/Asset'
|
||||||
|
|
||||||
const refreshInterval = 10000 // 10 sec.
|
const refreshInterval = 10000 // 10 sec.
|
||||||
export default function Compute({
|
export default function Compute({
|
||||||
@ -62,6 +63,8 @@ export default function Compute({
|
|||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const { accountId, web3, isSupportedOceanNetwork } = useWeb3()
|
const { accountId, web3, isSupportedOceanNetwork } = useWeb3()
|
||||||
const { chainIds } = useUserPreferences()
|
const { chainIds } = useUserPreferences()
|
||||||
|
const { isAssetNetwork } = useAsset()
|
||||||
|
|
||||||
const newAbortController = useAbortController()
|
const newAbortController = useAbortController()
|
||||||
const newCancelToken = useCancelToken()
|
const newCancelToken = useCancelToken()
|
||||||
|
|
||||||
@ -146,8 +149,12 @@ export default function Compute({
|
|||||||
|
|
||||||
setInitializedProviderResponse(initializedProvider)
|
setInitializedProviderResponse(initializedProvider)
|
||||||
|
|
||||||
|
console.log('here')
|
||||||
|
|
||||||
const feeAmount = await unitsToAmount(
|
const feeAmount = await unitsToAmount(
|
||||||
!isSupportedOceanNetwork ? await getDummyWeb3(asset?.chainId) : web3,
|
!isSupportedOceanNetwork || !isAssetNetwork
|
||||||
|
? await getDummyWeb3(asset?.chainId)
|
||||||
|
: web3,
|
||||||
initializedProvider?.datasets?.[0]?.providerFee?.providerFeeToken,
|
initializedProvider?.datasets?.[0]?.providerFee?.providerFeeToken,
|
||||||
initializedProvider?.datasets?.[0]?.providerFee?.providerFeeAmount
|
initializedProvider?.datasets?.[0]?.providerFee?.providerFeeAmount
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user