From b5b0297ae4e6fd21bbea922ac663156434f92e6e Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 11 Jan 2022 19:05:07 +0000 Subject: [PATCH] refactor for new ocean.js, make the build work --- src/@context/Asset.tsx | 14 +- src/@context/Web3.tsx | 6 +- src/@hooks/useNetworkMetadata/constants.ts | 1 - src/@types/Compute.d.ts | 2 +- src/@utils/purgatory.ts | 8 +- src/components/@shared/ExplorerLink/index.tsx | 8 +- .../@shared/TokenApproval/index.tsx | 31 ++-- .../Compute/FormComputeDataset.tsx | 11 +- .../Asset/AssetActions/Compute/index.tsx | 32 ++-- .../Asset/AssetActions/Pool/Actions.tsx | 6 +- .../Asset/AssetActions/Pool/Add/FormAdd.tsx | 66 +++---- .../Asset/AssetActions/Pool/Add/index.tsx | 71 ++++---- .../Asset/AssetActions/Pool/Remove.tsx | 83 +++++---- .../Asset/AssetActions/Pool/utils.ts | 43 +++-- .../Asset/AssetActions/Trade/FormTrade.tsx | 44 +++-- .../Asset/AssetActions/Trade/Output.tsx | 20 +-- .../Asset/AssetActions/Trade/Swap.tsx | 167 +++++++++--------- .../Asset/AssetActions/Trade/TradeInput.tsx | 5 +- .../Asset/AssetActions/Trade/index.tsx | 61 +++---- src/components/Asset/AssetActions/index.tsx | 19 +- .../Asset/Edit/DebugEditCompute.tsx | 25 +-- .../Asset/Edit/EditComputeDataset.tsx | 6 +- src/components/Asset/Edit/FormActions.tsx | 6 +- .../Asset/Edit/FormEditComputeDataset.tsx | 2 +- src/components/Asset/Edit/_constants.ts | 4 +- src/components/Asset/Edit/_types.ts | 4 +- src/components/Asset/Edit/index.tsx | 20 +-- .../Profile/History/ComputeJobs/Details.tsx | 4 +- .../Profile/History/ComputeJobs/Results.tsx | 36 ++-- .../Profile/History/ComputeJobs/index.tsx | 30 ++-- 30 files changed, 387 insertions(+), 448 deletions(-) diff --git a/src/@context/Asset.tsx b/src/@context/Asset.tsx index 68deea2b7..18f694660 100644 --- a/src/@context/Asset.tsx +++ b/src/@context/Asset.tsx @@ -7,7 +7,7 @@ import React, { useCallback, ReactNode } from 'react' -import { LoggerInstance } from '@oceanprotocol/lib' +import { LoggerInstance, Purgatory } from '@oceanprotocol/lib' import getAssetPurgatoryData from '@utils/purgatory' import { CancelToken } from 'axios' import { retrieveDDO } from '@utils/aquarius' @@ -18,7 +18,7 @@ import { useCancelToken } from '@hooks/useCancelToken' interface AssetProviderValue { isInPurgatory: boolean - purgatoryData: PurgatoryData + purgatoryData: Purgatory ddo: Asset title: string owner: string @@ -30,12 +30,6 @@ interface AssetProviderValue { refreshDdo: (token?: CancelToken) => Promise } -// temp, just to get rid of the error -export interface PurgatoryData { - did: string - reason: string -} - const AssetContext = createContext({} as AssetProviderValue) const refreshInterval = 10000 // 10 sec. @@ -51,7 +45,7 @@ function AssetProvider({ const { networkId } = useWeb3() const [isInPurgatory, setIsInPurgatory] = useState(false) - const [purgatoryData, setPurgatoryData] = useState() + const [purgatoryData, setPurgatoryData] = useState() const [ddo, setDDO] = useState() const [did, setDID] = useState() const [title, setTitle] = useState() @@ -92,7 +86,7 @@ function AssetProvider({ try { const result = await getAssetPurgatoryData(did) - const isInPurgatory = result?.did !== undefined + const isInPurgatory = result?.state === true setIsInPurgatory(isInPurgatory) isInPurgatory && setPurgatoryData(result) } catch (error) { diff --git a/src/@context/Web3.tsx b/src/@context/Web3.tsx index 45be584a1..e1d432315 100644 --- a/src/@context/Web3.tsx +++ b/src/@context/Web3.tsx @@ -261,9 +261,9 @@ function Web3Provider({ children }: { children: ReactNode }): ReactElement { setNetworkDisplayName(networkDisplayName) // Figure out if we're on a chain's testnet, or not - setIsTestnet( - networkData?.network !== 'mainnet' && networkData.network !== 'moonriver' - ) + // setIsTestnet( + // networkData?.network !== 'mainnet' && networkData.network !== 'moonriver' + // ) LoggerInstance.log( `[web3] Network display name set to: ${networkDisplayName}` diff --git a/src/@hooks/useNetworkMetadata/constants.ts b/src/@hooks/useNetworkMetadata/constants.ts index 02b663fc0..db6a0b8f6 100644 --- a/src/@hooks/useNetworkMetadata/constants.ts +++ b/src/@hooks/useNetworkMetadata/constants.ts @@ -7,7 +7,6 @@ export const networkDataGaiaX: EthereumListsChain = { chainId: 2021000, shortName: 'GAIA-X', chain: 'GAIA-X', - network: 'testnet', networkId: 2021000, nativeCurrency: { name: 'Gaia-X', symbol: 'GX', decimals: 18 }, rpc: [configGaiaX.nodeUri], diff --git a/src/@types/Compute.d.ts b/src/@types/Compute.d.ts index 80110bec7..93df8670f 100644 --- a/src/@types/Compute.d.ts +++ b/src/@types/Compute.d.ts @@ -1,4 +1,4 @@ -import { ComputeJob } from '@oceanprotocol/lib/dist/node/ocean/interfaces/Compute' +import { ComputeJob } from '@oceanprotocol/lib' import { OrdersData_tokenOrders_datatokenId as OrdersDatatoken } from './apollo/OrdersData' // declaring into global scope to be able to use this as diff --git a/src/@utils/purgatory.ts b/src/@utils/purgatory.ts index ae4a5fe68..c54ace6fb 100644 --- a/src/@utils/purgatory.ts +++ b/src/@utils/purgatory.ts @@ -1,4 +1,4 @@ -import { PurgatoryData as PurgatoryDataAsset } from '@oceanprotocol/lib' +import { Purgatory } from '@oceanprotocol/lib' import { fetchData } from './fetch' const purgatoryUrl = 'https://market-purgatory.oceanprotocol.com/api/' @@ -10,12 +10,12 @@ export interface PurgatoryDataAccount { export default async function getAssetPurgatoryData( did: string -): Promise { +): Promise { const data = (await fetchData( `${purgatoryUrl}asset?did=${did}` - )) as PurgatoryDataAsset[] + )) as Purgatory[] - return { did: data[0]?.did, reason: data[0]?.reason } + return { state: data[0]?.state, reason: data[0]?.reason } } export async function getAccountPurgatoryData( diff --git a/src/components/@shared/ExplorerLink/index.tsx b/src/components/@shared/ExplorerLink/index.tsx index 8baf1321c..5852485f9 100644 --- a/src/components/@shared/ExplorerLink/index.tsx +++ b/src/components/@shared/ExplorerLink/index.tsx @@ -1,7 +1,7 @@ import React, { ReactElement, ReactNode, useEffect, useState } from 'react' import External from '@images/external.svg' import classNames from 'classnames/bind' -import { ConfigHelperConfig } from '@oceanprotocol/lib' +import { Config } from '@oceanprotocol/lib' import { useOcean } from '@context/Ocean' import styles from './index.module.css' import { getOceanConfig } from '@utils/ocean' @@ -19,9 +19,9 @@ export default function ExplorerLink({ children: ReactNode className?: string }): ReactElement { - const { config, ocean } = useOcean() + const { config } = useOcean() const [url, setUrl] = useState() - const [oceanConfig, setOceanConfig] = useState() + const [oceanConfig, setOceanConfig] = useState() const styleClasses = cx({ link: true, [className]: className @@ -38,7 +38,7 @@ export default function ExplorerLink({ if (oceanConfig === undefined) { initOcean() } - }, [config, oceanConfig, networkId, ocean]) + }, [config, oceanConfig, networkId]) return ( { - if (!ocean || !tokenAddress || !spender || !isAssetNetwork || !amount) - return - - const allowance = await ocean.datatokens.allowance( - tokenAddress, - accountId, - spender - ) - - amount && - new Decimal(amount).greaterThan(new Decimal('0')) && - setTokenApproved( - new Decimal(allowance).greaterThanOrEqualTo(new Decimal(amount)) - ) - }, [ocean, tokenAddress, spender, accountId, amount, isAssetNetwork]) + // if (!tokenAddress || !spender || !isAssetNetwork || !amount) return + // const allowance = await ocean.datatokens.allowance( + // tokenAddress, + // accountId, + // spender + // ) + // amount && + // new Decimal(amount).greaterThan(new Decimal('0')) && + // setTokenApproved( + // new Decimal(allowance).greaterThanOrEqualTo(new Decimal(amount)) + // ) + }, [tokenAddress, spender, accountId, amount, isAssetNetwork]) useEffect(() => { checkTokenApproval() @@ -56,7 +51,7 @@ export default function TokenApproval({ setLoading(true) try { - await ocean.datatokens.approve(tokenAddress, spender, amount, accountId) + // await ocean.datatokens.approve(tokenAddress, spender, amount, accountId) } catch (error) { setLoading(false) } diff --git a/src/components/Asset/AssetActions/Compute/FormComputeDataset.tsx b/src/components/Asset/AssetActions/Compute/FormComputeDataset.tsx index fa03c013d..c1ce14849 100644 --- a/src/components/Asset/AssetActions/Compute/FormComputeDataset.tsx +++ b/src/components/Asset/AssetActions/Compute/FormComputeDataset.tsx @@ -66,7 +66,6 @@ export default function FormStartCompute({ const [totalPrice, setTotalPrice] = useState(price?.value) const [isBalanceSufficient, setIsBalanceSufficient] = useState(false) const { accountId, balance } = useWeb3() - const { ocean } = useOcean() const [algorithmConsumableStatus, setAlgorithmConsumableStatus] = useState() @@ -85,11 +84,11 @@ export default function FormStartCompute({ if (!accountId || !isConsumable) return async function checkIsConsumable() { - const consumable = await ocean.assets.isConsumable( - algorithmDDO as any, - accountId.toLowerCase() - ) - if (consumable) setAlgorithmConsumableStatus(consumable.status) + // const consumable = await ocean.assets.isConsumable( + // algorithmDDO as any, + // accountId.toLowerCase() + // ) + // if (consumable) setAlgorithmConsumableStatus(consumable.status) } checkIsConsumable() }, [values.algorithm, accountId, isConsumable]) diff --git a/src/components/Asset/AssetActions/Compute/index.tsx b/src/components/Asset/AssetActions/Compute/index.tsx index aabcf9528..9efcc5161 100644 --- a/src/components/Asset/AssetActions/Compute/index.tsx +++ b/src/components/Asset/AssetActions/Compute/index.tsx @@ -1,5 +1,9 @@ import React, { useState, ReactElement, useEffect, useCallback } from 'react' -import { LoggerInstance } from '@oceanprotocol/lib' +import { + LoggerInstance, + ComputeAlgorithm, + ComputeOutput +} from '@oceanprotocol/lib' import { toast } from 'react-toastify' import Price from '@shared/Price' import FileIcon from '@shared/FileIcon' @@ -17,10 +21,6 @@ import { } from '@utils/aquarius' import { Formik } from 'formik' import { getInitialValues, validationSchema } from './_constants' -import { - ComputeAlgorithm, - ComputeOutput -} from '@oceanprotocol/lib/dist/node/ocean/interfaces/Compute' import axios from 'axios' import FormStartComputeDataset from './FormComputeDataset' import styles from './index.module.css' @@ -55,7 +55,6 @@ export default function Compute({ }): ReactElement { const { appConfig } = useSiteMetadata() const { accountId } = useWeb3() - const { ocean } = useOcean() const { buyDT, pricingError, pricingStepText } = usePricing() const [isJobStarting, setIsJobStarting] = useState(false) const [error, setError] = useState() @@ -83,7 +82,6 @@ export default function Compute({ const isComputeButtonDisabled = isJobStarting === true || file === null || - !ocean || (!hasPreviousDatasetOrder && !hasDatatoken && !isConsumablePrice) || (!hasPreviousAlgorithmOrder && !hasAlgoAssetDatatoken && @@ -111,12 +109,12 @@ export default function Compute({ } async function checkAssetDTBalance(asset: DDO) { - const AssetDtBalance = await ocean.datatokens.balance( - asset.services[0].datatokenAddress, - accountId - ) - setalgorithmDTBalance(AssetDtBalance) - setHasAlgoAssetDatatoken(Number(AssetDtBalance) >= 1) + // const AssetDtBalance = await ocean.datatokens.balance( + // asset.services[0].datatokenAddress, + // accountId + // ) + // setalgorithmDTBalance(AssetDtBalance) + // setHasAlgoAssetDatatoken(Number(AssetDtBalance) >= 1) } function getQuerryString( @@ -204,9 +202,9 @@ export default function Compute({ }, [ddo]) useEffect(() => { - if (!ocean || !accountId) return + if (!accountId) return checkPreviousOrders(ddo) - }, [ocean, ddo, accountId]) + }, [ddo, accountId]) useEffect(() => { if (!selectedAlgorithmAsset) return @@ -231,8 +229,8 @@ export default function Compute({ checkPreviousOrders(selectedAlgorithmAsset) } } - ocean && checkAssetDTBalance(selectedAlgorithmAsset) - }, [ddo, selectedAlgorithmAsset, ocean, accountId, hasPreviousAlgorithmOrder]) + // ocean && checkAssetDTBalance(selectedAlgorithmAsset) + }, [ddo, selectedAlgorithmAsset, accountId, hasPreviousAlgorithmOrder]) // Output errors in toast UI useEffect(() => { diff --git a/src/components/Asset/AssetActions/Pool/Actions.tsx b/src/components/Asset/AssetActions/Pool/Actions.tsx index 700dbbf27..50c8b549b 100644 --- a/src/components/Asset/AssetActions/Pool/Actions.tsx +++ b/src/components/Asset/AssetActions/Pool/Actions.tsx @@ -4,7 +4,6 @@ import Button from '@shared/atoms/Button' import styles from './Actions.module.css' import ExplorerLink from '@shared/ExplorerLink' import SuccessConfetti from '@shared/SuccessConfetti' -import { useOcean } from '@context/Ocean' import { useWeb3 } from '@context/Web3' import TokenApproval from '@shared/TokenApproval' @@ -30,14 +29,13 @@ export default function Actions({ isDisabled?: boolean }): ReactElement { const { networkId } = useWeb3() - const { ocean } = useOcean() const actionButton = ( @@ -53,7 +51,7 @@ export default function Actions({ actionButton={actionButton} amount={amount} coin={coin} - disabled={!ocean || isDisabled} + disabled={isDisabled} /> ) : ( actionButton diff --git a/src/components/Asset/AssetActions/Pool/Add/FormAdd.tsx b/src/components/Asset/AssetActions/Pool/Add/FormAdd.tsx index 550b628d2..a6fa4df35 100644 --- a/src/components/Asset/AssetActions/Pool/Add/FormAdd.tsx +++ b/src/components/Asset/AssetActions/Pool/Add/FormAdd.tsx @@ -11,7 +11,6 @@ import Button from '@shared/atoms/Button' import CoinSelect from '../CoinSelect' import { FormAddLiquidity } from '.' import UserLiquidity from '../../UserLiquidity' -import { useOcean } from '@context/Ocean' import { useWeb3 } from '@context/Web3' import { isValidNumber } from '@utils/numbers' @@ -43,8 +42,7 @@ export default function FormAdd({ setNewPoolTokens: (value: string) => void setNewPoolShare: (value: string) => void }): ReactElement { - const { balance } = useWeb3() - const { ocean } = useOcean() + const { balance, web3 } = useWeb3() const { isAssetNetwork } = useAsset() // Connect with form @@ -69,36 +67,31 @@ export default function FormAdd({ useEffect(() => { async function calculatePoolShares() { - if (!ocean) return - const tokenInAddress = - coin === 'OCEAN' ? ocean.pool.oceanAddress : ocean.pool.dtAddress - if (!values.amount || !tokenInAddress) { - setNewPoolTokens('0') - setNewPoolShare('0') - return - } - - if (Number(values.amount) > Number(amountMax)) return - - const poolTokens = await ocean.pool.calcPoolOutGivenSingleIn( - poolAddress, - tokenInAddress, - `${values.amount}` - ) - - setNewPoolTokens(poolTokens) - - const newPoolShareDecimal = - isValidNumber(poolTokens) && isValidNumber(totalPoolTokens) - ? new Decimal(poolTokens) - .dividedBy( - new Decimal(totalPoolTokens).plus(new Decimal(poolTokens)) - ) - .mul(100) - .toString() - : '0' - - totalBalance && setNewPoolShare(newPoolShareDecimal) + // if (!web3) return + // const tokenInAddress = + // coin === 'OCEAN' ? ocean.pool.oceanAddress : ocean.pool.dtAddress + // if (!values.amount || !tokenInAddress) { + // setNewPoolTokens('0') + // setNewPoolShare('0') + // return + // } + // if (Number(values.amount) > Number(amountMax)) return + // const poolTokens = await ocean.pool.calcPoolOutGivenSingleIn( + // poolAddress, + // tokenInAddress, + // `${values.amount}` + // ) + // setNewPoolTokens(poolTokens) + // const newPoolShareDecimal = + // isValidNumber(poolTokens) && isValidNumber(totalPoolTokens) + // ? new Decimal(poolTokens) + // .dividedBy( + // new Decimal(totalPoolTokens).plus(new Decimal(poolTokens)) + // ) + // .mul(100) + // .toString() + // : '0' + // totalBalance && setNewPoolShare(newPoolShareDecimal) } calculatePoolShares() }, [ @@ -108,7 +101,6 @@ export default function FormAdd({ amountMax, coin, poolAddress, - ocean?.pool, setNewPoolTokens, setNewPoolShare ]) @@ -144,14 +136,14 @@ export default function FormAdd({ } placeholder="0" field={field} form={form} onChange={handleFieldChange} - disabled={!ocean || !isAssetNetwork} + disabled={!isAssetNetwork} /> )} @@ -161,7 +153,7 @@ export default function FormAdd({ className={styles.buttonMax} style="text" size="small" - disabled={!ocean} + disabled={!web3} onClick={() => { setAmount(amountMax) setFieldValue('amount', amountMax) diff --git a/src/components/Asset/AssetActions/Pool/Add/index.tsx b/src/components/Asset/AssetActions/Pool/Add/index.tsx index 275cfa99b..e54eccad2 100644 --- a/src/components/Asset/AssetActions/Pool/Add/index.tsx +++ b/src/components/Asset/AssetActions/Pool/Add/index.tsx @@ -10,7 +10,6 @@ import Alert from '@shared/atoms/Alert' import { useUserPreferences } from '@context/UserPreferences' import Output from './Output' import DebugOutput from '@shared/DebugOutput' -import { useOcean } from '@context/Ocean' import { useWeb3 } from '@context/Web3' import { useAsset } from '@context/Asset' import content from '../../../../../../content/price.json' @@ -43,7 +42,6 @@ export default function Add({ dtAddress: string }): ReactElement { const { accountId, balance } = useWeb3() - const { ocean } = useOcean() const { isAssetNetwork } = useAsset() const { debug } = useUserPreferences() const [txId, setTxId] = useState() @@ -69,53 +67,50 @@ export default function Add({ // Get datatoken balance when datatoken selected useEffect(() => { - if (!ocean || !isAssetNetwork || coin === 'OCEAN') return - - async function getDtBalance() { - const dtBalance = await ocean.datatokens.balance(dtAddress, accountId) - setDtBalance(dtBalance) - } - getDtBalance() - }, [ocean, accountId, dtAddress, coin]) + // if (!accountId || !isAssetNetwork || coin === 'OCEAN') return + // async function getDtBalance() { + // const dtBalance = await ocean.datatokens.balance(dtAddress, accountId) + // setDtBalance(dtBalance) + // } + // getDtBalance() + }, [accountId, dtAddress, coin]) // Get maximum amount for either OCEAN or datatoken useEffect(() => { - if (!ocean || !isAssetNetwork || !poolAddress) return + if (!accountId || !isAssetNetwork || !poolAddress) return async function getMaximum() { - const amountMaxPool = - coin === 'OCEAN' - ? await ocean.pool.getOceanMaxAddLiquidity(poolAddress) - : await ocean.pool.getDTMaxAddLiquidity(poolAddress) - - const amountMax = - coin === 'OCEAN' - ? Number(balance.ocean) > Number(amountMaxPool) - ? amountMaxPool - : balance.ocean - : Number(dtBalance) > Number(amountMaxPool) - ? amountMaxPool - : dtBalance - setAmountMax(Number(amountMax).toFixed(3)) + // const amountMaxPool = + // coin === 'OCEAN' + // ? await ocean.pool.getOceanMaxAddLiquidity(poolAddress) + // : await ocean.pool.getDTMaxAddLiquidity(poolAddress) + // const amountMax = + // coin === 'OCEAN' + // ? Number(balance.ocean) > Number(amountMaxPool) + // ? amountMaxPool + // : balance.ocean + // : Number(dtBalance) > Number(amountMaxPool) + // ? amountMaxPool + // : dtBalance + // setAmountMax(Number(amountMax).toFixed(3)) } getMaximum() - }, [ocean, poolAddress, coin, dtBalance, balance.ocean]) + }, [accountId, isAssetNetwork, poolAddress, coin, dtBalance, balance.ocean]) // Submit async function handleAddLiquidity(amount: number, resetForm: () => void) { try { - const result = - coin === 'OCEAN' - ? await ocean.pool.addOceanLiquidity( - accountId, - poolAddress, - `${amount}` - ) - : await ocean.pool.addDTLiquidity(accountId, poolAddress, `${amount}`) - - setTxId(result?.transactionHash) - resetForm() - refreshInfo() + // const result = + // coin === 'OCEAN' + // ? await ocean.pool.addOceanLiquidity( + // accountId, + // poolAddress, + // `${amount}` + // ) + // : await ocean.pool.addDTLiquidity(accountId, poolAddress, `${amount}`) + // setTxId(result?.transactionHash) + // resetForm() + // refreshInfo() } catch (error) { console.error(error.message) toast.error(error.message) diff --git a/src/components/Asset/AssetActions/Pool/Remove.tsx b/src/components/Asset/AssetActions/Pool/Remove.tsx index ac42d66ea..1c7fb0d2c 100644 --- a/src/components/Asset/AssetActions/Pool/Remove.tsx +++ b/src/components/Asset/AssetActions/Pool/Remove.tsx @@ -41,7 +41,6 @@ export default function Remove({ }): ReactElement { const slippagePresets = ['5', '10', '15', '25', '50'] const { accountId } = useWeb3() - const { ocean } = useOcean() const { isAssetNetwork } = useAsset() const [amountPercent, setAmountPercent] = useState('0') const [amountMaxPercent, setAmountMaxPercent] = useState('100') @@ -60,24 +59,23 @@ export default function Remove({ async function handleRemoveLiquidity() { setIsLoading(true) try { - const result = - isAdvanced === true - ? await ocean.pool.removePoolLiquidity( - accountId, - poolAddress, - amountPoolShares, - minDatatokenAmount, - minOceanAmount - ) - : await ocean.pool.removeOceanLiquidityWithMinimum( - accountId, - poolAddress, - amountPoolShares, - minOceanAmount - ) - - setTxId(result?.transactionHash) - refreshInfo() + // const result = + // isAdvanced === true + // ? await ocean.pool.removePoolLiquidity( + // accountId, + // poolAddress, + // amountPoolShares, + // minDatatokenAmount, + // minOceanAmount + // ) + // : await ocean.pool.removeOceanLiquidityWithMinimum( + // accountId, + // poolAddress, + // amountPoolShares, + // minOceanAmount + // ) + // setTxId(result?.transactionHash) + // refreshInfo() } catch (error) { LoggerInstance.error(error.message) toast.error(error.message) @@ -88,45 +86,44 @@ export default function Remove({ // Get and set max percentage useEffect(() => { - if (!ocean || !poolTokens) return + if (!accountId || !poolTokens) return async function getMax() { - const amountMaxPercent = - isAdvanced === true - ? '100' - : await getMaxPercentRemove(ocean, poolAddress, poolTokens) - setAmountMaxPercent(amountMaxPercent) + // const amountMaxPercent = + // isAdvanced === true + // ? '100' + // : await getMaxPercentRemove(poolAddress, poolTokens) + // setAmountMaxPercent(amountMaxPercent) } getMax() - }, [ocean, isAdvanced, poolAddress, poolTokens]) + }, [accountId, isAdvanced, poolAddress, poolTokens]) const getValues = useRef( debounce(async (newAmountPoolShares, isAdvanced) => { - if (isAdvanced === true) { - const tokens = await ocean.pool.getTokensRemovedforPoolShares( - poolAddress, - `${newAmountPoolShares}` - ) - setAmountOcean(tokens?.oceanAmount) - setAmountDatatoken(tokens?.dtAmount) - return - } - - const amountOcean = await ocean.pool.getOceanRemovedforPoolShares( - poolAddress, - newAmountPoolShares - ) - setAmountOcean(amountOcean) + // if (isAdvanced === true) { + // const tokens = await ocean.pool.getTokensRemovedforPoolShares( + // poolAddress, + // `${newAmountPoolShares}` + // ) + // setAmountOcean(tokens?.oceanAmount) + // setAmountDatatoken(tokens?.dtAmount) + // return + // } + // const amountOcean = await ocean.pool.getOceanRemovedforPoolShares( + // poolAddress, + // newAmountPoolShares + // ) + // setAmountOcean(amountOcean) }, 150) ) // Check and set outputs when amountPoolShares changes useEffect(() => { - if (!ocean || !poolTokens) return + if (!accountId || !poolTokens) return getValues.current(amountPoolShares, isAdvanced) }, [ amountPoolShares, isAdvanced, - ocean, + accountId, poolTokens, poolAddress, totalPoolTokens diff --git a/src/components/Asset/AssetActions/Pool/utils.ts b/src/components/Asset/AssetActions/Pool/utils.ts index 2d9ed813b..e3fe55d77 100644 --- a/src/components/Asset/AssetActions/Pool/utils.ts +++ b/src/components/Asset/AssetActions/Pool/utils.ts @@ -1,36 +1,35 @@ -import { Ocean } from '@oceanprotocol/lib' import { isValidNumber } from '@utils/numbers' import Decimal from 'decimal.js' Decimal.set({ toExpNeg: -18, precision: 18, rounding: 1 }) export async function getMaxPercentRemove( - ocean: Ocean, poolAddress: string, poolTokens: string ): Promise { - const amountMaxOcean = await ocean.pool.getOceanMaxRemoveLiquidity( - poolAddress - ) + // const amountMaxOcean = await ocean.pool.getOceanMaxRemoveLiquidity( + // poolAddress + // ) - const amountMaxPoolShares = - await ocean.pool.getPoolSharesRequiredToRemoveOcean( - poolAddress, - amountMaxOcean - ) + // const amountMaxPoolShares = + // await ocean.pool.getPoolSharesRequiredToRemoveOcean( + // poolAddress, + // amountMaxOcean + // ) - let amountMaxPercent = - isValidNumber(amountMaxPoolShares) && isValidNumber(poolTokens) - ? new Decimal(amountMaxPoolShares) - .dividedBy(new Decimal(poolTokens)) - .mul(100) - .floor() - .toString() - : '0' + // let amountMaxPercent = + // isValidNumber(amountMaxPoolShares) && isValidNumber(poolTokens) + // ? new Decimal(amountMaxPoolShares) + // .dividedBy(new Decimal(poolTokens)) + // .mul(100) + // .floor() + // .toString() + // : '0' - if (Number(amountMaxPercent) > 100) { - amountMaxPercent = '100' - } + // if (Number(amountMaxPercent) > 100) { + // amountMaxPercent = '100' + // } - return amountMaxPercent + // return amountMaxPercent + return '0' } diff --git a/src/components/Asset/AssetActions/Trade/FormTrade.tsx b/src/components/Asset/AssetActions/Trade/FormTrade.tsx index 0f23d71e8..127fc6e38 100644 --- a/src/components/Asset/AssetActions/Trade/FormTrade.tsx +++ b/src/components/Asset/AssetActions/Trade/FormTrade.tsx @@ -9,7 +9,6 @@ import Swap from './Swap' import Alert from '@shared/atoms/Alert' import styles from './FormTrade.module.css' import Decimal from 'decimal.js' -import { useOcean } from '@context/Ocean' import { useWeb3 } from '@context/Web3' import { useAsset } from '@context/Asset' import { FormTradeData } from './_types' @@ -30,7 +29,6 @@ export default function FormTrade({ price: BestPrice }): ReactElement { const { accountId } = useWeb3() - const { ocean } = useOcean() const { isAssetNetwork } = useAsset() const { debug } = useUserPreferences() const [txId, setTxId] = useState() @@ -69,27 +67,27 @@ export default function FormTrade({ new Decimal(100).sub(new Decimal(values.slippage)) ).div(100) const precision = 15 - const tx = - values.type === 'buy' - ? await ocean.pool.buyDTWithExactOcean( - accountId, - price.address, - new Decimal(values.datatoken) - .mul(impact) - .toFixed(precision) - .toString(), - new Decimal(values.ocean).toFixed(precision).toString() - ) - : await ocean.pool.sellDT( - accountId, - price.address, - new Decimal(values.datatoken).toFixed(precision).toString(), - new Decimal(values.ocean) - .mul(impact) - .toFixed(precision) - .toString() - ) - setTxId(tx?.transactionHash) + // const tx = + // values.type === 'buy' + // ? await ocean.pool.buyDTWithExactOcean( + // accountId, + // price.address, + // new Decimal(values.datatoken) + // .mul(impact) + // .toFixed(precision) + // .toString(), + // new Decimal(values.ocean).toFixed(precision).toString() + // ) + // : await ocean.pool.sellDT( + // accountId, + // price.address, + // new Decimal(values.datatoken).toFixed(precision).toString(), + // new Decimal(values.ocean) + // .mul(impact) + // .toFixed(precision) + // .toString() + // ) + // setTxId(tx?.transactionHash) } catch (error) { LoggerInstance.error(error.message) toast.error(error.message) diff --git a/src/components/Asset/AssetActions/Trade/Output.tsx b/src/components/Asset/AssetActions/Trade/Output.tsx index 6d1a4dee5..006c3d8a2 100644 --- a/src/components/Asset/AssetActions/Trade/Output.tsx +++ b/src/components/Asset/AssetActions/Trade/Output.tsx @@ -1,7 +1,6 @@ import { FormikContextType, useFormikContext } from 'formik' import React, { ReactElement, useEffect, useState } from 'react' import { useAsset } from '@context/Asset' -import { useOcean } from '@context/Ocean' import Token from '../Pool/Token' import styles from './Output.module.css' @@ -21,7 +20,6 @@ export default function Output({ poolAddress: string }): ReactElement { const { isAssetNetwork } = useAsset() - const { ocean } = useOcean() const [maxOutput, setMaxOutput] = useState() const [swapFee, setSwapFee] = useState() const [swapFeeValue, setSwapFeeValue] = useState() @@ -30,15 +28,15 @@ export default function Output({ // Get swap fee useEffect(() => { - if (!ocean || !poolAddress || !isAssetNetwork) return + if (!poolAddress || !isAssetNetwork) return async function getSwapFee() { - const swapFee = await ocean.pool.getSwapFee(poolAddress) + // const swapFee = await ocean.pool.getSwapFee(poolAddress) - // swapFee is tricky: to get 0.1% you need to convert from 0.001 - setSwapFee( - isValidNumber(swapFee) ? new Decimal(swapFee).mul(100).toString() : '0' - ) + // // swapFee is tricky: to get 0.1% you need to convert from 0.001 + // setSwapFee( + // isValidNumber(swapFee) ? new Decimal(swapFee).mul(100).toString() : '0' + // ) const value = values.type === 'buy' @@ -51,11 +49,11 @@ export default function Output({ setSwapFeeValue(value.toString()) } getSwapFee() - }, [ocean, poolAddress, values, isAssetNetwork]) + }, [poolAddress, values, isAssetNetwork]) // Get output values useEffect(() => { - if (!ocean || !poolAddress || !isAssetNetwork) return + if (!poolAddress || !isAssetNetwork) return async function getOutput() { // Minimum received @@ -75,7 +73,7 @@ export default function Output({ setMaxOutput(maxPrice) } getOutput() - }, [ocean, poolAddress, values, isAssetNetwork]) + }, [poolAddress, values, isAssetNetwork]) return (
diff --git a/src/components/Asset/AssetActions/Trade/Swap.tsx b/src/components/Asset/AssetActions/Trade/Swap.tsx index a28f44927..221123df5 100644 --- a/src/components/Asset/AssetActions/Trade/Swap.tsx +++ b/src/components/Asset/AssetActions/Trade/Swap.tsx @@ -4,7 +4,6 @@ import TradeInput from './TradeInput' import Button from '@shared/atoms/Button' import Arrow from '@images/arrow.svg' import { FormikContextType, useFormikContext } from 'formik' -import { useOcean } from '@context/Ocean' import Output from './Output' import Slippage from './Slippage' import PriceImpact from './PriceImpact' @@ -34,7 +33,6 @@ export default function Swap({ setMaximumOcean: (value: string) => void setCoin: (value: string) => void }): ReactElement { - const { ocean } = useOcean() const { isAssetNetwork } = useAsset() const [oceanItem, setOceanItem] = useState({ amount: '0', @@ -72,47 +70,47 @@ export default function Swap({ ? new Decimal(balance.ocean) : new Decimal(maxOcean) - const maxBuyOcean = await ocean.pool.getOceanReceived( - price.address, - `${amountDataToken.toString()}` - ) - const maxBuyDt = await ocean.pool.getDTReceived( - price.address, - `${amountOcean.toString()}` - ) + // const maxBuyOcean = await ocean.pool.getOceanReceived( + // price.address, + // `${amountDataToken.toString()}` + // ) + // const maxBuyDt = await ocean.pool.getDTReceived( + // price.address, + // `${amountOcean.toString()}` + // ) - const maximumDt = - values.type === 'buy' - ? amountDataToken.greaterThan(new Decimal(maxBuyDt)) - ? maxBuyDt - : amountDataToken - : amountDataToken.greaterThan(new Decimal(balance.datatoken)) - ? balance.datatoken - : amountDataToken + // const maximumDt = + // values.type === 'buy' + // ? amountDataToken.greaterThan(new Decimal(maxBuyDt)) + // ? maxBuyDt + // : amountDataToken + // : amountDataToken.greaterThan(new Decimal(balance.datatoken)) + // ? balance.datatoken + // : amountDataToken - const maximumOcean = - values.type === 'sell' - ? amountOcean.greaterThan(new Decimal(maxBuyOcean)) - ? maxBuyOcean - : amountOcean - : amountOcean.greaterThan(new Decimal(balance.ocean)) - ? balance.ocean - : amountOcean + // const maximumOcean = + // values.type === 'sell' + // ? amountOcean.greaterThan(new Decimal(maxBuyOcean)) + // ? maxBuyOcean + // : amountOcean + // : amountOcean.greaterThan(new Decimal(balance.ocean)) + // ? balance.ocean + // : amountOcean - setMaximumDt(maximumDt.toString()) - setMaximumOcean(maximumOcean.toString()) + // setMaximumDt(maximumDt.toString()) + // setMaximumOcean(maximumOcean.toString()) - setOceanItem((prevState) => ({ - ...prevState, - amount: amountOcean.toString(), - maxAmount: maximumOcean.toString() - })) + // setOceanItem((prevState) => ({ + // ...prevState, + // amount: amountOcean.toString(), + // maxAmount: maximumOcean.toString() + // })) - setDtItem((prevState) => ({ - ...prevState, - amount: amountDataToken.toString(), - maxAmount: maximumDt.toString() - })) + // setDtItem((prevState) => ({ + // ...prevState, + // amount: amountDataToken.toString(), + // maxAmount: maximumDt.toString() + // })) } calculateMaximum() }, [ @@ -122,7 +120,6 @@ export default function Swap({ balance, price, values?.type, - ocean, setMaximumDt, setMaximumOcean ]) @@ -137,63 +134,63 @@ export default function Swap({ } const handleValueChange = async (name: string, value: number) => { - let tokenIn = '' - let tokenOut = '' + const tokenIn = '' + const tokenOut = '' let newValue - if (name === 'ocean') { - if (values.type === 'sell') { - newValue = await ocean.pool.getDTNeeded(price.address, value.toString()) + // if (name === 'ocean') { + // if (values.type === 'sell') { + // newValue = await ocean.pool.getDTNeeded(price.address, value.toString()) - setTotalValue(newValue) - setTokenAmount(value.toString()) + // setTotalValue(newValue) + // setTokenAmount(value.toString()) - tokenIn = ddo.services[0].datatokenAddress - tokenOut = ocean.pool.oceanAddress - } else { - newValue = await ocean.pool.getDTReceived( - price.address, - value.toString() - ) + // tokenIn = ddo.services[0].datatokenAddress + // tokenOut = ocean.pool.oceanAddress + // } else { + // newValue = await ocean.pool.getDTReceived( + // price.address, + // value.toString() + // ) - setTotalValue(value.toString()) - setTokenAmount(newValue) - tokenIn = ocean.pool.oceanAddress - tokenOut = ddo.services[0].datatokenAddress - } - } else { - if (values.type === 'sell') { - newValue = await ocean.pool.getOceanReceived( - price.address, - value.toString() - ) + // setTotalValue(value.toString()) + // setTokenAmount(newValue) + // tokenIn = ocean.pool.oceanAddress + // tokenOut = ddo.services[0].datatokenAddress + // } + // } else { + // if (values.type === 'sell') { + // newValue = await ocean.pool.getOceanReceived( + // price.address, + // value.toString() + // ) - setTotalValue(value.toString()) - setTokenAmount(newValue) - tokenIn = ddo.services[0].datatokenAddress - tokenOut = ocean.pool.oceanAddress - } else { - newValue = await ocean.pool.getOceanNeeded( - price.address, - value.toString() - ) + // setTotalValue(value.toString()) + // setTokenAmount(newValue) + // tokenIn = ddo.services[0].datatokenAddress + // tokenOut = ocean.pool.oceanAddress + // } else { + // newValue = await ocean.pool.getOceanNeeded( + // price.address, + // value.toString() + // ) - setTotalValue(newValue) - setTokenAmount(value.toString()) - tokenIn = ocean.pool.oceanAddress - tokenOut = ddo.services[0].datatokenAddress - } - } + // setTotalValue(newValue) + // setTokenAmount(value.toString()) + // tokenIn = ocean.pool.oceanAddress + // tokenOut = ddo.services[0].datatokenAddress + // } + // } await setFieldValue(name === 'ocean' ? 'datatoken' : 'ocean', newValue) - const spotPrice = await ocean.pool.getSpotPrice( - price.address, - tokenIn, - tokenOut - ) + // const spotPrice = await ocean.pool.getSpotPrice( + // price.address, + // tokenIn, + // tokenOut + // ) - setSpotPrice(spotPrice) + // setSpotPrice(spotPrice) validateForm() } diff --git a/src/components/Asset/AssetActions/Trade/TradeInput.tsx b/src/components/Asset/AssetActions/Trade/TradeInput.tsx index 81cad1dfd..c5a04a41a 100644 --- a/src/components/Asset/AssetActions/Trade/TradeInput.tsx +++ b/src/components/Asset/AssetActions/Trade/TradeInput.tsx @@ -11,6 +11,7 @@ import Button from '@shared/atoms/Button' import { useOcean } from '@context/Ocean' import { FormTradeData, TradeItem } from './_types' import UserLiquidity from '../UserLiquidity' +import { useWeb3 } from '@context/Web3' export default function TradeInput({ name, @@ -23,7 +24,7 @@ export default function TradeInput({ disabled: boolean handleValueChange: (name: string, value: number) => void }): ReactElement { - const { ocean } = useOcean() + const { accountId } = useWeb3() // Connect with form const { @@ -64,7 +65,7 @@ export default function TradeInput({ validateForm() handleChange(e) }} - disabled={!ocean || disabled} + disabled={!accountId || disabled} /> )} diff --git a/src/components/Asset/AssetActions/Trade/index.tsx b/src/components/Asset/AssetActions/Trade/index.tsx index bd7ac32a7..7403c5716 100644 --- a/src/components/Asset/AssetActions/Trade/index.tsx +++ b/src/components/Asset/AssetActions/Trade/index.tsx @@ -1,7 +1,6 @@ import React, { ReactElement, useEffect, useState } from 'react' import FormTrade from './FormTrade' import { useAsset } from '@context/Asset' -import { useOcean } from '@context/Ocean' import { useWeb3 } from '@context/Web3' import { isValidNumber } from '@utils/numbers' @@ -11,7 +10,6 @@ Decimal.set({ toExpNeg: -18, precision: 18, rounding: 1 }) export default function Trade(): ReactElement { const { accountId, balance } = useWeb3() - const { ocean } = useOcean() const { isAssetNetwork } = useAsset() const [tokenBalance, setTokenBalance] = useState() const { price, ddo } = useAsset() @@ -21,7 +19,7 @@ export default function Trade(): ReactElement { // Get datatoken balance, and combine with OCEAN balance from hooks into one object useEffect(() => { if ( - !ocean || + !accountId || !isAssetNetwork || !balance?.ocean || !accountId || @@ -30,45 +28,42 @@ export default function Trade(): ReactElement { return async function getTokenBalance() { - const dtBalance = await ocean.datatokens.balance( - ddo.services[0].datatokenAddress, - accountId - ) - setTokenBalance({ - ocean: new Decimal(balance.ocean).toString(), - datatoken: new Decimal(dtBalance).toString() - }) + // const dtBalance = await ocean.datatokens.balance( + // ddo.services[0].datatokenAddress, + // accountId + // ) + // setTokenBalance({ + // ocean: new Decimal(balance.ocean).toString(), + // datatoken: new Decimal(dtBalance).toString() + // }) } getTokenBalance() - }, [balance.ocean, ocean, accountId, ddo, isAssetNetwork]) + }, [balance.ocean, accountId, ddo, isAssetNetwork]) // Get maximum amount for either OCEAN or datatoken useEffect(() => { - if (!ocean || !isAssetNetwork || !price || price.value === 0) return + if (!isAssetNetwork || !price || price.value === 0) return async function getMaximum() { - const maxTokensInPool = await ocean.pool.getDTMaxBuyQuantity( - price.address - ) - - setMaxDt( - isValidNumber(maxTokensInPool) - ? new Decimal(maxTokensInPool).toString() - : '0' - ) - - const maxOceanInPool = await ocean.pool.getOceanMaxBuyQuantity( - price.address - ) - - setMaxOcean( - isValidNumber(maxOceanInPool) - ? new Decimal(maxOceanInPool).toString() - : '0' - ) + // const maxTokensInPool = await ocean.pool.getDTMaxBuyQuantity( + // price.address + // ) + // setMaxDt( + // isValidNumber(maxTokensInPool) + // ? new Decimal(maxTokensInPool).toString() + // : '0' + // ) + // const maxOceanInPool = await ocean.pool.getOceanMaxBuyQuantity( + // price.address + // ) + // setMaxOcean( + // isValidNumber(maxOceanInPool) + // ? new Decimal(maxOceanInPool).toString() + // : '0' + // ) } getMaximum() - }, [ocean, balance.ocean, price]) + }, [isAssetNetwork, balance.ocean, price]) return ( () @@ -87,25 +86,25 @@ export default function AssetActions({ // Get and set user DT balance useEffect(() => { - if (!ocean || !accountId || !isAssetNetwork) return + if (!accountId || !isAssetNetwork) return async function init() { try { - const dtBalance = await ocean.datatokens.balance( - ddo.services[0].datatokenAddress, - accountId - ) - setDtBalance(dtBalance) + // const dtBalance = await ocean.datatokens.balance( + // ddo.services[0].datatokenAddress, + // accountId + // ) + // setDtBalance(dtBalance) } catch (e) { LoggerInstance.error(e.message) } } init() - }, [ocean, accountId, ddo, isAssetNetwork]) + }, [accountId, ddo, isAssetNetwork]) // Check user balance against price useEffect(() => { if (price?.type === 'free') setIsBalanceSufficient(true) - if (!price?.value || !account || !balance?.ocean || !dtBalance) return + if (!price?.value || !accountId || !balance?.ocean || !dtBalance) return setIsBalanceSufficient( compareAsBN(balance.ocean, `${price.value}`) || Number(dtBalance) >= 1 @@ -114,7 +113,7 @@ export default function AssetActions({ return () => { setIsBalanceSufficient(false) } - }, [balance, account, price, dtBalance]) + }, [balance, accountId, price, dtBalance]) const UseContent = isCompute ? ( () + useState() useEffect(() => { - if (!ocean) return - - async function transformValues() { - const privacy = await transformComputeFormToServiceComputePrivacy( - values, - ocean - ) - setFormTransformed(privacy) - } - transformValues() - }, [values, ddo, ocean]) + // async function transformValues() { + // const privacy = await transformComputeFormToServiceComputePrivacy(values) + // setFormTransformed(privacy) + // } + // transformValues() + }, [values, ddo]) return ( <> diff --git a/src/components/Asset/Edit/EditComputeDataset.tsx b/src/components/Asset/Edit/EditComputeDataset.tsx index 2560f205b..d75c8791c 100644 --- a/src/components/Asset/Edit/EditComputeDataset.tsx +++ b/src/components/Asset/Edit/EditComputeDataset.tsx @@ -1,14 +1,13 @@ -import { useOcean } from '@context/Ocean' import { useWeb3 } from '@context/Web3' import { Formik } from 'formik' import React, { ReactElement, useState } from 'react' import { useAsset } from '@context/Asset' import FormEditComputeDataset from './FormEditComputeDataset' -import { LoggerInstance, ServiceComputePrivacy } from '@oceanprotocol/lib' +import { LoggerInstance, ServiceComputeOptions } from '@oceanprotocol/lib' import { useUserPreferences } from '@context/UserPreferences' import DebugEditCompute from './DebugEditCompute' import styles from './index.module.css' -import { transformComputeFormToServiceComputePrivacy } from '@utils/compute' +// import { transformComputeFormToServiceComputePrivacy } from '@utils/compute' import { setMinterToDispenser, setMinterToPublisher } from '@utils/freePrice' import Web3Feedback from '@shared/Web3Feedback' import { getInitialValues, validationSchema } from './_constants' @@ -20,7 +19,6 @@ export default function EditComputeDataset({ setShowEdit: (show: boolean) => void }): ReactElement { const { debug } = useUserPreferences() - const { ocean } = useOcean() const { accountId } = useWeb3() const { ddo, price, isAssetNetwork, refreshDdo } = useAsset() const [success, setSuccess] = useState() diff --git a/src/components/Asset/Edit/FormActions.tsx b/src/components/Asset/Edit/FormActions.tsx index 61173634d..c08a7a0e8 100644 --- a/src/components/Asset/Edit/FormActions.tsx +++ b/src/components/Asset/Edit/FormActions.tsx @@ -1,8 +1,6 @@ import { FormikContextType, useFormikContext } from 'formik' import React, { ReactElement } from 'react' import { useAsset } from '@context/Asset' -import { useOcean } from '@context/Ocean' -import { useWeb3 } from '@context/Web3' import Button from '@shared/atoms/Button' import styles from './FormActions.module.css' @@ -13,8 +11,6 @@ export default function FormActions({ setShowEdit: (show: boolean) => void handleClick?: () => void }): ReactElement { - const { accountId } = useWeb3() - const { ocean } = useOcean() const { isAssetNetwork } = useAsset() const { isValid }: FormikContextType> = useFormikContext() @@ -22,7 +18,7 @@ export default function FormActions({
diff --git a/src/components/Profile/History/ComputeJobs/Results.tsx b/src/components/Profile/History/ComputeJobs/Results.tsx index 2a07e6554..6231aae48 100644 --- a/src/components/Profile/History/ComputeJobs/Results.tsx +++ b/src/components/Profile/History/ComputeJobs/Results.tsx @@ -3,37 +3,37 @@ import React, { ReactElement, useState } from 'react' import Loader from '@shared/atoms/Loader' import { ListItem } from '@shared/atoms/Lists' import Button from '@shared/atoms/Button' -import { useOcean } from '@context/Ocean' import styles from './Results.module.css' import FormHelp from '@shared/FormInput/Help' import content from '../../../../../content/pages/history.json' +import { useWeb3 } from '@context/Web3' export default function Results({ job }: { job: ComputeJobMetaData }): ReactElement { - const { ocean, account } = useOcean() + const { accountId } = useWeb3() const [isLoading, setIsLoading] = useState(false) const [hasFetched, setHasFetched] = useState(false) const isFinished = job.dateFinished !== null async function getResults() { - if (!account || !ocean || !job) return + if (!accountId || !job) return try { setIsLoading(true) - const jobStatus = await ocean.compute.status( - account, - job.did, - undefined, - undefined, - job.jobId - ) - if (jobStatus?.length > 0) { - job.algorithmLogUrl = jobStatus[0].algorithmLogUrl - job.resultsUrl = jobStatus[0].resultsUrl - } + // const jobStatus = await ocean.compute.status( + // account, + // job.did, + // undefined, + // undefined, + // job.jobId + // ) + // if (jobStatus?.length > 0) { + // job.algorithmLogUrl = jobStatus[0].algorithmLogUrl + // job.resultsUrl = jobStatus[0].resultsUrl + // } } catch (error) { LoggerInstance.error(error.message) } finally { @@ -47,16 +47,16 @@ export default function Results({ {hasFetched ? (
) : (