mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
cleanup
* remove commented out code * remove unused state * removed unused imports * typos in comments, variables, props
This commit is contained in:
parent
b37c85908d
commit
db23ed6ada
2
package-lock.json
generated
2
package-lock.json
generated
@ -44925,6 +44925,7 @@
|
|||||||
"cross-fetch": "^3.1.5",
|
"cross-fetch": "^3.1.5",
|
||||||
"crypto-js": "^4.1.1",
|
"crypto-js": "^4.1.1",
|
||||||
"decimal.js": "^10.3.1",
|
"decimal.js": "^10.3.1",
|
||||||
|
"web3": "^1.7.3",
|
||||||
"web3-core": "^1.7.1",
|
"web3-core": "^1.7.1",
|
||||||
"web3-eth-contract": "^1.7.1"
|
"web3-eth-contract": "^1.7.1"
|
||||||
}
|
}
|
||||||
@ -44976,6 +44977,7 @@
|
|||||||
"integrity": "sha512-rmVKYEsKzurfRU0xJz+iHelbi1LGlihIWZ7Qvmb/CBz1EkhL7nOkW4SVXmG2dA5Ce0si2gr88i6q4eBOMRNJ1w==",
|
"integrity": "sha512-rmVKYEsKzurfRU0xJz+iHelbi1LGlihIWZ7Qvmb/CBz1EkhL7nOkW4SVXmG2dA5Ce0si2gr88i6q4eBOMRNJ1w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
|
"@oclif/config": "^1.18.2",
|
||||||
"@oclif/errors": "^1.3.5",
|
"@oclif/errors": "^1.3.5",
|
||||||
"@oclif/help": "^1.0.1",
|
"@oclif/help": "^1.0.1",
|
||||||
"@oclif/parser": "^3.8.6",
|
"@oclif/parser": "^3.8.6",
|
||||||
|
@ -12,8 +12,7 @@ import {
|
|||||||
Asset,
|
Asset,
|
||||||
LoggerInstance,
|
LoggerInstance,
|
||||||
ProviderFees,
|
ProviderFees,
|
||||||
ProviderInstance,
|
ProviderInstance
|
||||||
unitsToAmount
|
|
||||||
} from '@oceanprotocol/lib'
|
} from '@oceanprotocol/lib'
|
||||||
import { AssetExtended } from 'src/@types/AssetExtended'
|
import { AssetExtended } from 'src/@types/AssetExtended'
|
||||||
import { calcInGivenOut } from './pool'
|
import { calcInGivenOut } from './pool'
|
||||||
|
@ -180,7 +180,7 @@ export async function getAssetsFromDidList(
|
|||||||
didList: string[],
|
didList: string[],
|
||||||
chainIds: number[],
|
chainIds: number[],
|
||||||
cancelToken: CancelToken
|
cancelToken: CancelToken
|
||||||
): Promise<any> {
|
): Promise<PagedAssets> {
|
||||||
try {
|
try {
|
||||||
if (!(didList.length > 0)) return
|
if (!(didList.length > 0)) return
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ import {
|
|||||||
} from './aquarius'
|
} from './aquarius'
|
||||||
import { fetchDataForMultipleChains } from './subgraph'
|
import { fetchDataForMultipleChains } from './subgraph'
|
||||||
import { getServiceById, getServiceByName } from './ddo'
|
import { getServiceById, getServiceByName } from './ddo'
|
||||||
import { getOceanConfig } from './ocean'
|
|
||||||
import { SortTermOptions } from 'src/@types/aquarius/SearchQuery'
|
import { SortTermOptions } from 'src/@types/aquarius/SearchQuery'
|
||||||
import { AssetSelectionAsset } from '@shared/FormFields/AssetSelection'
|
import { AssetSelectionAsset } from '@shared/FormFields/AssetSelection'
|
||||||
import { transformAssetToAssetSelection } from './assetConvertor'
|
import { transformAssetToAssetSelection } from './assetConvertor'
|
||||||
@ -149,7 +148,7 @@ export async function getComputeEnviroment(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getQuerryString(
|
export function getQueryString(
|
||||||
trustedAlgorithmList: PublisherTrustedAlgorithm[],
|
trustedAlgorithmList: PublisherTrustedAlgorithm[],
|
||||||
chainId?: number
|
chainId?: number
|
||||||
): SearchQuery {
|
): SearchQuery {
|
||||||
@ -182,7 +181,7 @@ export async function getAlgorithmsForAsset(
|
|||||||
algorithms = []
|
algorithms = []
|
||||||
} else {
|
} else {
|
||||||
const gueryResults = await queryMetadata(
|
const gueryResults = await queryMetadata(
|
||||||
getQuerryString(publisherTrustedAlgorithms, asset.chainId),
|
getQueryString(publisherTrustedAlgorithms, asset.chainId),
|
||||||
token
|
token
|
||||||
)
|
)
|
||||||
algorithms = gueryResults?.results
|
algorithms = gueryResults?.results
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
import { Asset, DDO, Service } from '@oceanprotocol/lib'
|
import { Asset, DDO, Service } from '@oceanprotocol/lib'
|
||||||
interface Consumable {
|
|
||||||
status: number
|
|
||||||
message: string
|
|
||||||
result: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getServiceByName(
|
export function getServiceByName(
|
||||||
ddo: Asset | DDO,
|
ddo: Asset | DDO,
|
||||||
|
@ -3,7 +3,6 @@ import { AccessDetails } from 'src/@types/Price'
|
|||||||
import Web3 from 'web3'
|
import Web3 from 'web3'
|
||||||
import { getOceanConfig } from './ocean'
|
import { getOceanConfig } from './ocean'
|
||||||
import { consumeMarketPoolSwapFee } from '../../app.config'
|
import { consumeMarketPoolSwapFee } from '../../app.config'
|
||||||
|
|
||||||
import { getDummyWeb3 } from './web3'
|
import { getDummyWeb3 } from './web3'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,17 +112,6 @@ export async function setNftMetadata(
|
|||||||
// theoretically used by aquarius or provider, not implemented yet, will remain hardcoded
|
// theoretically used by aquarius or provider, not implemented yet, will remain hardcoded
|
||||||
const flags = '0x2'
|
const flags = '0x2'
|
||||||
|
|
||||||
const estGasSetMetadata = await nft.estGasSetMetadata(
|
|
||||||
asset.nftAddress,
|
|
||||||
accountId,
|
|
||||||
0,
|
|
||||||
asset.services[0].serviceEndpoint,
|
|
||||||
'',
|
|
||||||
flags,
|
|
||||||
encryptedDdo,
|
|
||||||
'0x' + metadataHash,
|
|
||||||
[]
|
|
||||||
)
|
|
||||||
const setMetadataTx = await nft.setMetadata(
|
const setMetadataTx = await nft.setMetadata(
|
||||||
asset.nftAddress,
|
asset.nftAddress,
|
||||||
accountId,
|
accountId,
|
||||||
|
@ -26,9 +26,9 @@ import { toast } from 'react-toastify'
|
|||||||
* For pool you need to buy the datatoken beforehand, this always assumes you want to order the first service
|
* For pool you need to buy the datatoken beforehand, this always assumes you want to order the first service
|
||||||
* @param web3
|
* @param web3
|
||||||
* @param asset
|
* @param asset
|
||||||
|
* @param orderPriceAndFees
|
||||||
* @param accountId
|
* @param accountId
|
||||||
* @param computeEnv
|
* @param providerFees
|
||||||
* @param computeValidUntil
|
|
||||||
* @param computeConsumerAddress
|
* @param computeConsumerAddress
|
||||||
* @returns {TransactionReceipt} receipt of the order
|
* @returns {TransactionReceipt} receipt of the order
|
||||||
*/
|
*/
|
||||||
@ -162,9 +162,10 @@ export async function reuseOrder(
|
|||||||
* - no validOrder -> we need to call order, to pay 1 DT & providerFees
|
* - no validOrder -> we need to call order, to pay 1 DT & providerFees
|
||||||
* @param web3
|
* @param web3
|
||||||
* @param asset
|
* @param asset
|
||||||
|
* @param orderPriceAndFees
|
||||||
* @param accountId
|
* @param accountId
|
||||||
* @param computeEnv
|
* @param hasDatatoken
|
||||||
* @param computeValidUntil
|
* @param initializeData
|
||||||
* @param computeConsumerAddress
|
* @param computeConsumerAddress
|
||||||
* @returns {Promise<string>} tx id
|
* @returns {Promise<string>} tx id
|
||||||
*/
|
*/
|
||||||
|
@ -8,7 +8,6 @@ import {
|
|||||||
ProviderComputeInitializeResults,
|
ProviderComputeInitializeResults,
|
||||||
ProviderInstance
|
ProviderInstance
|
||||||
} from '@oceanprotocol/lib'
|
} from '@oceanprotocol/lib'
|
||||||
import { toast } from 'react-toastify'
|
|
||||||
import { AssetExtended } from 'src/@types/AssetExtended'
|
import { AssetExtended } from 'src/@types/AssetExtended'
|
||||||
import Web3 from 'web3'
|
import Web3 from 'web3'
|
||||||
import { getValidUntilTime } from './compute'
|
import { getValidUntilTime } from './compute'
|
||||||
|
@ -15,7 +15,7 @@ import {
|
|||||||
import { OrdersData_orders as OrdersData } from '../@types/subgraph/OrdersData'
|
import { OrdersData_orders as OrdersData } from '../@types/subgraph/OrdersData'
|
||||||
import { UserSalesQuery as UsersSalesList } from '../@types/subgraph/UserSalesQuery'
|
import { UserSalesQuery as UsersSalesList } from '../@types/subgraph/UserSalesQuery'
|
||||||
import { OpcFeesQuery as OpcFeesData } from '../@types/subgraph/OpcFeesQuery'
|
import { OpcFeesQuery as OpcFeesData } from '../@types/subgraph/OpcFeesQuery'
|
||||||
import { calcSingleOutGivenPoolIn, getLiquidityByShares } from './pool'
|
import { calcSingleOutGivenPoolIn } from './pool'
|
||||||
import Decimal from 'decimal.js'
|
import Decimal from 'decimal.js'
|
||||||
import { MAX_DECIMALS } from './constants'
|
import { MAX_DECIMALS } from './constants'
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ export default function FormStartCompute({
|
|||||||
!isValid ||
|
!isValid ||
|
||||||
!isBalanceSufficient ||
|
!isBalanceSufficient ||
|
||||||
!isAssetNetwork ||
|
!isAssetNetwork ||
|
||||||
!selectedAlgorithmAsset?.accessDetails.isPurchasable
|
!selectedAlgorithmAsset?.accessDetails?.isPurchasable
|
||||||
}
|
}
|
||||||
hasPreviousOrder={hasPreviousOrder}
|
hasPreviousOrder={hasPreviousOrder}
|
||||||
hasDatatoken={hasDatatoken}
|
hasDatatoken={hasDatatoken}
|
||||||
|
@ -39,7 +39,6 @@
|
|||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 5% 1fr auto;
|
grid-template-columns: 5% 1fr auto;
|
||||||
column-gap: calc(var(--spacer) / 10);
|
column-gap: calc(var(--spacer) / 10);
|
||||||
/* justify-content: space-between; */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.priceRow:last-child {
|
.priceRow:last-child {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useState, ReactElement, useEffect, useCallback } from 'react'
|
import React, { useState, ReactElement, useEffect } from 'react'
|
||||||
import {
|
import {
|
||||||
Asset,
|
Asset,
|
||||||
DDO,
|
DDO,
|
||||||
@ -36,7 +36,6 @@ import AlgorithmDatasetsListForCompute from './AlgorithmDatasetsListForCompute'
|
|||||||
import AssetActionHistoryTable from '../AssetActionHistoryTable'
|
import AssetActionHistoryTable from '../AssetActionHistoryTable'
|
||||||
import ComputeJobs from '../../../Profile/History/ComputeJobs'
|
import ComputeJobs from '../../../Profile/History/ComputeJobs'
|
||||||
import { useCancelToken } from '@hooks/useCancelToken'
|
import { useCancelToken } from '@hooks/useCancelToken'
|
||||||
// import { useIsMounted } from '@hooks/useIsMounted'
|
|
||||||
import { Decimal } from 'decimal.js'
|
import { Decimal } from 'decimal.js'
|
||||||
import { useAbortController } from '@hooks/useAbortController'
|
import { useAbortController } from '@hooks/useAbortController'
|
||||||
import { getOrderPriceAndFees } from '@utils/accessDetailsAndPricing'
|
import { getOrderPriceAndFees } from '@utils/accessDetailsAndPricing'
|
||||||
@ -55,14 +54,12 @@ export default function Compute({
|
|||||||
dtBalance,
|
dtBalance,
|
||||||
file,
|
file,
|
||||||
fileIsLoading,
|
fileIsLoading,
|
||||||
isConsumable,
|
|
||||||
consumableFeedback
|
consumableFeedback
|
||||||
}: {
|
}: {
|
||||||
asset: AssetExtended
|
asset: AssetExtended
|
||||||
dtBalance: string
|
dtBalance: string
|
||||||
file: FileInfo
|
file: FileInfo
|
||||||
fileIsLoading?: boolean
|
fileIsLoading?: boolean
|
||||||
isConsumable?: boolean
|
|
||||||
consumableFeedback?: string
|
consumableFeedback?: string
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const { accountId, web3 } = useWeb3()
|
const { accountId, web3 } = useWeb3()
|
||||||
@ -78,18 +75,14 @@ export default function Compute({
|
|||||||
const [isPublished, setIsPublished] = useState(false)
|
const [isPublished, setIsPublished] = useState(false)
|
||||||
const [algorithmDTBalance, setAlgorithmDTBalance] = useState<string>()
|
const [algorithmDTBalance, setAlgorithmDTBalance] = useState<string>()
|
||||||
|
|
||||||
// const [isOwned, setIsOwned] = useState(false)
|
|
||||||
const [validOrderTx, setValidOrderTx] = useState('')
|
const [validOrderTx, setValidOrderTx] = useState('')
|
||||||
// const [isAlgorithmOwned, setIsAlgorithmOwned] = useState(false)
|
|
||||||
const [validAlgorithmOrderTx, setValidAlgorithmOrderTx] = useState('')
|
const [validAlgorithmOrderTx, setValidAlgorithmOrderTx] = useState('')
|
||||||
|
|
||||||
const hasDatatoken = Number(dtBalance) >= 1
|
const hasDatatoken = Number(dtBalance) >= 1
|
||||||
// const isMounted = useIsMounted()
|
|
||||||
const { getOpcFeeForToken } = useMarketMetadata()
|
const { getOpcFeeForToken } = useMarketMetadata()
|
||||||
const { poolData } = usePool()
|
const { poolData } = usePool()
|
||||||
const newCancelToken = useCancelToken()
|
const newCancelToken = useCancelToken()
|
||||||
const [isConsumablePrice, setIsConsumablePrice] = useState(true)
|
const [isConsumablePrice, setIsConsumablePrice] = useState(true)
|
||||||
const [isAlgoConsumablePrice, setIsAlgoConsumablePrice] = useState(true)
|
|
||||||
const [computeStatusText, setComputeStatusText] = useState('')
|
const [computeStatusText, setComputeStatusText] = useState('')
|
||||||
const [computeEnv, setComputeEnv] = useState<ComputeEnvironment>()
|
const [computeEnv, setComputeEnv] = useState<ComputeEnvironment>()
|
||||||
const [initializedProviderResponse, setInitializedProviderResponse] =
|
const [initializedProviderResponse, setInitializedProviderResponse] =
|
||||||
@ -98,19 +91,16 @@ export default function Compute({
|
|||||||
const [computeValidUntil, setComputeValidUntil] = useState<string>('0')
|
const [computeValidUntil, setComputeValidUntil] = useState<string>('0')
|
||||||
const [datasetOrderPriceAndFees, setDatasetOrderPriceAndFees] =
|
const [datasetOrderPriceAndFees, setDatasetOrderPriceAndFees] =
|
||||||
useState<OrderPriceAndFees>()
|
useState<OrderPriceAndFees>()
|
||||||
const [isRequestingDataseOrderPrice, setIsRequestingDataseOrderPrice] =
|
|
||||||
useState(false)
|
|
||||||
const [algoOrderPriceAndFees, setAlgoOrderPriceAndFees] =
|
const [algoOrderPriceAndFees, setAlgoOrderPriceAndFees] =
|
||||||
useState<OrderPriceAndFees>()
|
useState<OrderPriceAndFees>()
|
||||||
const [isRequestingAlgoOrderPrice, setIsRequestingAlgoOrderPrice] =
|
const [isRequestingAlgoOrderPrice, setIsRequestingAlgoOrderPrice] =
|
||||||
useState(false)
|
useState(false)
|
||||||
const [refatchJobs, setRefatchJobs] = useState(false)
|
const [refetchJobs, setRefatchJobs] = useState(false)
|
||||||
// const [isProviderFeeValid, setIsProviderFeeValid] = useState(false)
|
|
||||||
const isComputeButtonDisabled =
|
const isComputeButtonDisabled =
|
||||||
isJobStarting === true ||
|
isJobStarting === true ||
|
||||||
file === null ||
|
file === null ||
|
||||||
(!validOrderTx && !hasDatatoken && !isConsumablePrice) ||
|
(!validOrderTx && !hasDatatoken && !isConsumablePrice) ||
|
||||||
(!validAlgorithmOrderTx && !hasAlgoAssetDatatoken && !isAlgoConsumablePrice)
|
(!validAlgorithmOrderTx && !hasAlgoAssetDatatoken)
|
||||||
|
|
||||||
async function checkAssetDTBalance(asset: DDO): Promise<boolean> {
|
async function checkAssetDTBalance(asset: DDO): Promise<boolean> {
|
||||||
if (!asset?.services[0].datatokenAddress) return
|
if (!asset?.services[0].datatokenAddress) return
|
||||||
@ -411,7 +401,7 @@ export default function Compute({
|
|||||||
}
|
}
|
||||||
LoggerInstance.log('[compute] Starting compute job response: ', response)
|
LoggerInstance.log('[compute] Starting compute job response: ', response)
|
||||||
setIsPublished(true)
|
setIsPublished(true)
|
||||||
setRefatchJobs(!refatchJobs)
|
setRefatchJobs(!refetchJobs)
|
||||||
initPriceAndFees()
|
initPriceAndFees()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setError('Failed to start job!')
|
setError('Failed to start job!')
|
||||||
@ -454,11 +444,7 @@ export default function Compute({
|
|||||||
ddoListAlgorithms={ddoAlgorithmList}
|
ddoListAlgorithms={ddoAlgorithmList}
|
||||||
selectedAlgorithmAsset={selectedAlgorithmAsset}
|
selectedAlgorithmAsset={selectedAlgorithmAsset}
|
||||||
setSelectedAlgorithm={setSelectedAlgorithmAsset}
|
setSelectedAlgorithm={setSelectedAlgorithmAsset}
|
||||||
isLoading={
|
isLoading={isJobStarting || isRequestingAlgoOrderPrice}
|
||||||
isJobStarting ||
|
|
||||||
isRequestingDataseOrderPrice ||
|
|
||||||
isRequestingAlgoOrderPrice
|
|
||||||
}
|
|
||||||
isComputeButtonDisabled={isComputeButtonDisabled}
|
isComputeButtonDisabled={isComputeButtonDisabled}
|
||||||
hasPreviousOrder={validOrderTx !== undefined}
|
hasPreviousOrder={validOrderTx !== undefined}
|
||||||
hasDatatoken={hasDatatoken}
|
hasDatatoken={hasDatatoken}
|
||||||
@ -479,7 +465,6 @@ export default function Compute({
|
|||||||
selectedAlgorithmAsset?.datatokens[0]?.symbol
|
selectedAlgorithmAsset?.datatokens[0]?.symbol
|
||||||
}
|
}
|
||||||
dtBalanceSelectedComputeAsset={algorithmDTBalance}
|
dtBalanceSelectedComputeAsset={algorithmDTBalance}
|
||||||
selectedComputeAssetLowPoolLiquidity={!isAlgoConsumablePrice}
|
|
||||||
selectedComputeAssetType="algorithm"
|
selectedComputeAssetType="algorithm"
|
||||||
selectedComputeAssetTimeout={secondsToString(
|
selectedComputeAssetTimeout={secondsToString(
|
||||||
selectedAlgorithmAsset?.services[0]?.timeout
|
selectedAlgorithmAsset?.services[0]?.timeout
|
||||||
@ -506,7 +491,7 @@ export default function Compute({
|
|||||||
<ComputeJobs
|
<ComputeJobs
|
||||||
minimal
|
minimal
|
||||||
assetChainId={[asset?.chainId]}
|
assetChainId={[asset?.chainId]}
|
||||||
refatchJobs={refatchJobs}
|
refetchJobs={refetchJobs}
|
||||||
/>
|
/>
|
||||||
</AssetActionHistoryTable>
|
</AssetActionHistoryTable>
|
||||||
)}
|
)}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import React, { ReactElement, useState, useEffect } from 'react'
|
import React, { ReactElement, useState, useEffect } from 'react'
|
||||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
|
||||||
import { useAsset } from '@context/Asset'
|
import { useAsset } from '@context/Asset'
|
||||||
import styles from './index.module.css'
|
import styles from './index.module.css'
|
||||||
import Tabs from '@shared/atoms/Tabs'
|
import Tabs from '@shared/atoms/Tabs'
|
||||||
|
@ -98,12 +98,6 @@ export default function Details({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<MetaItem title="Job ID" content={<code>{job.jobId}</code>} />
|
<MetaItem title="Job ID" content={<code>{job.jobId}</code>} />
|
||||||
{/* {job.results[0]. && (
|
|
||||||
<MetaItem
|
|
||||||
title="Published Results DID"
|
|
||||||
content={<code>{job.resultsDid}</code>}
|
|
||||||
/>
|
|
||||||
)} */}
|
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
</>
|
</>
|
||||||
|
@ -72,11 +72,11 @@ const columns = [
|
|||||||
export default function ComputeJobs({
|
export default function ComputeJobs({
|
||||||
minimal,
|
minimal,
|
||||||
assetChainId,
|
assetChainId,
|
||||||
refatchJobs
|
refetchJobs
|
||||||
}: {
|
}: {
|
||||||
minimal?: boolean
|
minimal?: boolean
|
||||||
assetChainId?: number[]
|
assetChainId?: number[]
|
||||||
refatchJobs?: boolean
|
refetchJobs?: boolean
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const { accountId } = useWeb3()
|
const { accountId } = useWeb3()
|
||||||
const { asset } = useAsset()
|
const { asset } = useAsset()
|
||||||
@ -114,7 +114,7 @@ export default function ComputeJobs({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchJobs()
|
fetchJobs()
|
||||||
}, [refatchJobs])
|
}, [refetchJobs])
|
||||||
|
|
||||||
return accountId ? (
|
return accountId ? (
|
||||||
<>
|
<>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user