1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00
* remove commented out code
* remove unused state
* removed unused imports
* typos in comments, variables, props
This commit is contained in:
Matthias Kretschmann 2022-06-22 11:32:59 +01:00
parent b37c85908d
commit db23ed6ada
Signed by: m
GPG Key ID: 606EEEF3C479A91F
16 changed files with 22 additions and 62 deletions

2
package-lock.json generated
View File

@ -44925,6 +44925,7 @@
"cross-fetch": "^3.1.5",
"crypto-js": "^4.1.1",
"decimal.js": "^10.3.1",
"web3": "^1.7.3",
"web3-core": "^1.7.1",
"web3-eth-contract": "^1.7.1"
}
@ -44976,6 +44977,7 @@
"integrity": "sha512-rmVKYEsKzurfRU0xJz+iHelbi1LGlihIWZ7Qvmb/CBz1EkhL7nOkW4SVXmG2dA5Ce0si2gr88i6q4eBOMRNJ1w==",
"dev": true,
"requires": {
"@oclif/config": "^1.18.2",
"@oclif/errors": "^1.3.5",
"@oclif/help": "^1.0.1",
"@oclif/parser": "^3.8.6",

View File

@ -12,8 +12,7 @@ import {
Asset,
LoggerInstance,
ProviderFees,
ProviderInstance,
unitsToAmount
ProviderInstance
} from '@oceanprotocol/lib'
import { AssetExtended } from 'src/@types/AssetExtended'
import { calcInGivenOut } from './pool'

View File

@ -180,7 +180,7 @@ export async function getAssetsFromDidList(
didList: string[],
chainIds: number[],
cancelToken: CancelToken
): Promise<any> {
): Promise<PagedAssets> {
try {
if (!(didList.length > 0)) return

View File

@ -21,7 +21,6 @@ import {
} from './aquarius'
import { fetchDataForMultipleChains } from './subgraph'
import { getServiceById, getServiceByName } from './ddo'
import { getOceanConfig } from './ocean'
import { SortTermOptions } from 'src/@types/aquarius/SearchQuery'
import { AssetSelectionAsset } from '@shared/FormFields/AssetSelection'
import { transformAssetToAssetSelection } from './assetConvertor'
@ -149,7 +148,7 @@ export async function getComputeEnviroment(
}
}
export function getQuerryString(
export function getQueryString(
trustedAlgorithmList: PublisherTrustedAlgorithm[],
chainId?: number
): SearchQuery {
@ -182,7 +181,7 @@ export async function getAlgorithmsForAsset(
algorithms = []
} else {
const gueryResults = await queryMetadata(
getQuerryString(publisherTrustedAlgorithms, asset.chainId),
getQueryString(publisherTrustedAlgorithms, asset.chainId),
token
)
algorithms = gueryResults?.results

View File

@ -1,9 +1,4 @@
import { Asset, DDO, Service } from '@oceanprotocol/lib'
interface Consumable {
status: number
message: string
result: boolean
}
export function getServiceByName(
ddo: Asset | DDO,

View File

@ -3,7 +3,6 @@ import { AccessDetails } from 'src/@types/Price'
import Web3 from 'web3'
import { getOceanConfig } from './ocean'
import { consumeMarketPoolSwapFee } from '../../app.config'
import { getDummyWeb3 } from './web3'
/**

View File

@ -112,17 +112,6 @@ export async function setNftMetadata(
// theoretically used by aquarius or provider, not implemented yet, will remain hardcoded
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(
asset.nftAddress,
accountId,

View File

@ -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
* @param web3
* @param asset
* @param orderPriceAndFees
* @param accountId
* @param computeEnv
* @param computeValidUntil
* @param providerFees
* @param computeConsumerAddress
* @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
* @param web3
* @param asset
* @param orderPriceAndFees
* @param accountId
* @param computeEnv
* @param computeValidUntil
* @param hasDatatoken
* @param initializeData
* @param computeConsumerAddress
* @returns {Promise<string>} tx id
*/

View File

@ -8,7 +8,6 @@ import {
ProviderComputeInitializeResults,
ProviderInstance
} from '@oceanprotocol/lib'
import { toast } from 'react-toastify'
import { AssetExtended } from 'src/@types/AssetExtended'
import Web3 from 'web3'
import { getValidUntilTime } from './compute'

View File

@ -15,7 +15,7 @@ import {
import { OrdersData_orders as OrdersData } from '../@types/subgraph/OrdersData'
import { UserSalesQuery as UsersSalesList } from '../@types/subgraph/UserSalesQuery'
import { OpcFeesQuery as OpcFeesData } from '../@types/subgraph/OpcFeesQuery'
import { calcSingleOutGivenPoolIn, getLiquidityByShares } from './pool'
import { calcSingleOutGivenPoolIn } from './pool'
import Decimal from 'decimal.js'
import { MAX_DECIMALS } from './constants'

View File

@ -211,7 +211,7 @@ export default function FormStartCompute({
!isValid ||
!isBalanceSufficient ||
!isAssetNetwork ||
!selectedAlgorithmAsset?.accessDetails.isPurchasable
!selectedAlgorithmAsset?.accessDetails?.isPurchasable
}
hasPreviousOrder={hasPreviousOrder}
hasDatatoken={hasDatatoken}

View File

@ -39,7 +39,6 @@
display: grid;
grid-template-columns: 5% 1fr auto;
column-gap: calc(var(--spacer) / 10);
/* justify-content: space-between; */
}
.priceRow:last-child {

View File

@ -1,4 +1,4 @@
import React, { useState, ReactElement, useEffect, useCallback } from 'react'
import React, { useState, ReactElement, useEffect } from 'react'
import {
Asset,
DDO,
@ -36,7 +36,6 @@ import AlgorithmDatasetsListForCompute from './AlgorithmDatasetsListForCompute'
import AssetActionHistoryTable from '../AssetActionHistoryTable'
import ComputeJobs from '../../../Profile/History/ComputeJobs'
import { useCancelToken } from '@hooks/useCancelToken'
// import { useIsMounted } from '@hooks/useIsMounted'
import { Decimal } from 'decimal.js'
import { useAbortController } from '@hooks/useAbortController'
import { getOrderPriceAndFees } from '@utils/accessDetailsAndPricing'
@ -55,14 +54,12 @@ export default function Compute({
dtBalance,
file,
fileIsLoading,
isConsumable,
consumableFeedback
}: {
asset: AssetExtended
dtBalance: string
file: FileInfo
fileIsLoading?: boolean
isConsumable?: boolean
consumableFeedback?: string
}): ReactElement {
const { accountId, web3 } = useWeb3()
@ -78,18 +75,14 @@ export default function Compute({
const [isPublished, setIsPublished] = useState(false)
const [algorithmDTBalance, setAlgorithmDTBalance] = useState<string>()
// const [isOwned, setIsOwned] = useState(false)
const [validOrderTx, setValidOrderTx] = useState('')
// const [isAlgorithmOwned, setIsAlgorithmOwned] = useState(false)
const [validAlgorithmOrderTx, setValidAlgorithmOrderTx] = useState('')
const hasDatatoken = Number(dtBalance) >= 1
// const isMounted = useIsMounted()
const { getOpcFeeForToken } = useMarketMetadata()
const { poolData } = usePool()
const newCancelToken = useCancelToken()
const [isConsumablePrice, setIsConsumablePrice] = useState(true)
const [isAlgoConsumablePrice, setIsAlgoConsumablePrice] = useState(true)
const [computeStatusText, setComputeStatusText] = useState('')
const [computeEnv, setComputeEnv] = useState<ComputeEnvironment>()
const [initializedProviderResponse, setInitializedProviderResponse] =
@ -98,19 +91,16 @@ export default function Compute({
const [computeValidUntil, setComputeValidUntil] = useState<string>('0')
const [datasetOrderPriceAndFees, setDatasetOrderPriceAndFees] =
useState<OrderPriceAndFees>()
const [isRequestingDataseOrderPrice, setIsRequestingDataseOrderPrice] =
useState(false)
const [algoOrderPriceAndFees, setAlgoOrderPriceAndFees] =
useState<OrderPriceAndFees>()
const [isRequestingAlgoOrderPrice, setIsRequestingAlgoOrderPrice] =
useState(false)
const [refatchJobs, setRefatchJobs] = useState(false)
// const [isProviderFeeValid, setIsProviderFeeValid] = useState(false)
const [refetchJobs, setRefatchJobs] = useState(false)
const isComputeButtonDisabled =
isJobStarting === true ||
file === null ||
(!validOrderTx && !hasDatatoken && !isConsumablePrice) ||
(!validAlgorithmOrderTx && !hasAlgoAssetDatatoken && !isAlgoConsumablePrice)
(!validAlgorithmOrderTx && !hasAlgoAssetDatatoken)
async function checkAssetDTBalance(asset: DDO): Promise<boolean> {
if (!asset?.services[0].datatokenAddress) return
@ -411,7 +401,7 @@ export default function Compute({
}
LoggerInstance.log('[compute] Starting compute job response: ', response)
setIsPublished(true)
setRefatchJobs(!refatchJobs)
setRefatchJobs(!refetchJobs)
initPriceAndFees()
} catch (error) {
setError('Failed to start job!')
@ -454,11 +444,7 @@ export default function Compute({
ddoListAlgorithms={ddoAlgorithmList}
selectedAlgorithmAsset={selectedAlgorithmAsset}
setSelectedAlgorithm={setSelectedAlgorithmAsset}
isLoading={
isJobStarting ||
isRequestingDataseOrderPrice ||
isRequestingAlgoOrderPrice
}
isLoading={isJobStarting || isRequestingAlgoOrderPrice}
isComputeButtonDisabled={isComputeButtonDisabled}
hasPreviousOrder={validOrderTx !== undefined}
hasDatatoken={hasDatatoken}
@ -479,7 +465,6 @@ export default function Compute({
selectedAlgorithmAsset?.datatokens[0]?.symbol
}
dtBalanceSelectedComputeAsset={algorithmDTBalance}
selectedComputeAssetLowPoolLiquidity={!isAlgoConsumablePrice}
selectedComputeAssetType="algorithm"
selectedComputeAssetTimeout={secondsToString(
selectedAlgorithmAsset?.services[0]?.timeout
@ -506,7 +491,7 @@ export default function Compute({
<ComputeJobs
minimal
assetChainId={[asset?.chainId]}
refatchJobs={refatchJobs}
refetchJobs={refetchJobs}
/>
</AssetActionHistoryTable>
)}

View File

@ -1,5 +1,4 @@
import React, { ReactElement, useState, useEffect } from 'react'
import { LoggerInstance } from '@oceanprotocol/lib'
import { useAsset } from '@context/Asset'
import styles from './index.module.css'
import Tabs from '@shared/atoms/Tabs'

View File

@ -98,12 +98,6 @@ export default function Details({
/>
)}
<MetaItem title="Job ID" content={<code>{job.jobId}</code>} />
{/* {job.results[0]. && (
<MetaItem
title="Published Results DID"
content={<code>{job.resultsDid}</code>}
/>
)} */}
</div>
</Modal>
</>

View File

@ -72,11 +72,11 @@ const columns = [
export default function ComputeJobs({
minimal,
assetChainId,
refatchJobs
refetchJobs
}: {
minimal?: boolean
assetChainId?: number[]
refatchJobs?: boolean
refetchJobs?: boolean
}): ReactElement {
const { accountId } = useWeb3()
const { asset } = useAsset()
@ -114,7 +114,7 @@ export default function ComputeJobs({
useEffect(() => {
fetchJobs()
}, [refatchJobs])
}, [refetchJobs])
return accountId ? (
<>