mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
removed price querry from compute
This commit is contained in:
parent
7b653c46ba
commit
4aae5fe6c1
@ -3,7 +3,6 @@ import {
|
|||||||
DDO,
|
DDO,
|
||||||
File as FileMetadata,
|
File as FileMetadata,
|
||||||
Logger,
|
Logger,
|
||||||
ServiceType,
|
|
||||||
publisherTrustedAlgorithm,
|
publisherTrustedAlgorithm,
|
||||||
BestPrice
|
BestPrice
|
||||||
} from '@oceanprotocol/lib'
|
} from '@oceanprotocol/lib'
|
||||||
@ -34,11 +33,8 @@ import FormStartComputeDataset from './FormComputeDataset'
|
|||||||
import styles from './index.module.css'
|
import styles from './index.module.css'
|
||||||
import SuccessConfetti from '../../../atoms/SuccessConfetti'
|
import SuccessConfetti from '../../../atoms/SuccessConfetti'
|
||||||
import Button from '../../../atoms/Button'
|
import Button from '../../../atoms/Button'
|
||||||
import { gql, useQuery } from '@apollo/client'
|
|
||||||
import { FrePrice } from '../../../../@types/apollo/FrePrice'
|
|
||||||
import { PoolPrice } from '../../../../@types/apollo/PoolPrice'
|
|
||||||
import { secondsToString } from '../../../../utils/metadata'
|
import { secondsToString } from '../../../../utils/metadata'
|
||||||
import { getPreviousOrders } from '../../../../utils/subgraph'
|
import { getPreviousOrders, getPrice } from '../../../../utils/subgraph'
|
||||||
|
|
||||||
const SuccessAction = () => (
|
const SuccessAction = () => (
|
||||||
<Button style="text" to="/history" size="small">
|
<Button style="text" to="/history" size="small">
|
||||||
@ -46,22 +42,6 @@ const SuccessAction = () => (
|
|||||||
</Button>
|
</Button>
|
||||||
)
|
)
|
||||||
|
|
||||||
const freQuery = gql`
|
|
||||||
query AlgorithmFrePrice($datatoken: String) {
|
|
||||||
fixedRateExchanges(orderBy: id, where: { datatoken: $datatoken }) {
|
|
||||||
rate
|
|
||||||
id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
const poolQuery = gql`
|
|
||||||
query AlgorithmPoolPrice($datatoken: String) {
|
|
||||||
pools(where: { datatokenAddress: $datatoken }) {
|
|
||||||
spotPrice
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
export default function Compute({
|
export default function Compute({
|
||||||
isBalanceSufficient,
|
isBalanceSufficient,
|
||||||
dtBalance,
|
dtBalance,
|
||||||
@ -91,7 +71,6 @@ export default function Compute({
|
|||||||
)
|
)
|
||||||
const [algorithmDTBalance, setalgorithmDTBalance] = useState<string>()
|
const [algorithmDTBalance, setalgorithmDTBalance] = useState<string>()
|
||||||
const [algorithmPrice, setAlgorithmPrice] = useState<BestPrice>()
|
const [algorithmPrice, setAlgorithmPrice] = useState<BestPrice>()
|
||||||
const [variables, setVariables] = useState({})
|
|
||||||
const [
|
const [
|
||||||
previousAlgorithmOrderId,
|
previousAlgorithmOrderId,
|
||||||
setPreviousAlgorithmOrderId
|
setPreviousAlgorithmOrderId
|
||||||
@ -99,25 +78,6 @@ export default function Compute({
|
|||||||
const [datasetTimeout, setDatasetTimeout] = useState<string>()
|
const [datasetTimeout, setDatasetTimeout] = useState<string>()
|
||||||
const [algorithmTimeout, setAlgorithmTimeout] = useState<string>()
|
const [algorithmTimeout, setAlgorithmTimeout] = useState<string>()
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
||||||
const {
|
|
||||||
refetch: refetchFre,
|
|
||||||
startPolling: startPollingFre,
|
|
||||||
data: frePrice
|
|
||||||
} = useQuery<FrePrice>(freQuery, {
|
|
||||||
variables,
|
|
||||||
skip: false
|
|
||||||
})
|
|
||||||
const {
|
|
||||||
refetch: refetchPool,
|
|
||||||
startPolling: startPollingPool,
|
|
||||||
data: poolPrice
|
|
||||||
} = useQuery<PoolPrice>(poolQuery, {
|
|
||||||
variables,
|
|
||||||
skip: false
|
|
||||||
})
|
|
||||||
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
||||||
|
|
||||||
const isComputeButtonDisabled =
|
const isComputeButtonDisabled =
|
||||||
isJobStarting === true || file === null || !ocean || !isBalanceSufficient
|
isJobStarting === true || file === null || !ocean || !isBalanceSufficient
|
||||||
const hasDatatoken = Number(dtBalance) >= 1
|
const hasDatatoken = Number(dtBalance) >= 1
|
||||||
@ -211,37 +171,10 @@ export default function Compute({
|
|||||||
setDatasetTimeout(secondsToString(timeout))
|
setDatasetTimeout(secondsToString(timeout))
|
||||||
}, [ddo])
|
}, [ddo])
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (
|
|
||||||
!frePrice ||
|
|
||||||
frePrice.fixedRateExchanges.length === 0 ||
|
|
||||||
algorithmPrice.type !== 'exchange'
|
|
||||||
)
|
|
||||||
return
|
|
||||||
setAlgorithmPrice((prevState) => ({
|
|
||||||
...prevState,
|
|
||||||
value: frePrice.fixedRateExchanges[0].rate,
|
|
||||||
address: frePrice.fixedRateExchanges[0].id
|
|
||||||
}))
|
|
||||||
}, [frePrice])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (
|
|
||||||
!poolPrice ||
|
|
||||||
poolPrice.pools.length === 0 ||
|
|
||||||
algorithmPrice.type !== 'pool'
|
|
||||||
)
|
|
||||||
return
|
|
||||||
setAlgorithmPrice((prevState) => ({
|
|
||||||
...prevState,
|
|
||||||
value: poolPrice.pools[0].spotPrice
|
|
||||||
}))
|
|
||||||
}, [poolPrice])
|
|
||||||
|
|
||||||
const initMetadata = useCallback(async (ddo: DDO): Promise<void> => {
|
const initMetadata = useCallback(async (ddo: DDO): Promise<void> => {
|
||||||
if (!ddo) return
|
if (!ddo) return
|
||||||
setAlgorithmPrice(ddo.price)
|
const price = await getPrice(ddo)
|
||||||
setVariables({ datatoken: ddo?.dataToken.toLowerCase() })
|
setAlgorithmPrice(price)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user