mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
Fix/old lib dep (#959)
* fixes * change aqua url * update future v4 url
This commit is contained in:
parent
b0adbf8071
commit
4caf72d0c9
@ -7,7 +7,7 @@ module.exports = {
|
||||
// return appConfig.metadataCacheUri
|
||||
metadataCacheUri:
|
||||
process.env.NEXT_PUBLIC_METADATACACHE_URI ||
|
||||
'https://aquarius.oceanprotocol.com',
|
||||
'https://aquariusv4.oceanprotocol.com',
|
||||
|
||||
// List of chainIds which metadata cache queries will return by default.
|
||||
// This preselects the Chains user preferences.
|
||||
|
32683
package-lock.json
generated
32683
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -23,13 +23,14 @@
|
||||
"@coingecko/cryptoformat": "^0.4.4",
|
||||
"@loadable/component": "^5.15.0",
|
||||
"@oceanprotocol/art": "^3.2.0",
|
||||
"@oceanprotocol/lib": "^0.19.2",
|
||||
"@oceanprotocol/lib": "file:../ocean.js",
|
||||
"@oceanprotocol/typographies": "^0.1.0",
|
||||
"@portis/web3": "^4.0.6",
|
||||
"@tippyjs/react": "^4.2.5",
|
||||
"@urql/introspection": "^0.3.0",
|
||||
"@walletconnect/web3-provider": "^1.6.6",
|
||||
"axios": "^0.24.0",
|
||||
"bignumber.js": "^9.0.1",
|
||||
"chart.js": "^2.9.4",
|
||||
"classnames": "^2.3.1",
|
||||
"d3": "^7.1.1",
|
||||
@ -50,6 +51,7 @@
|
||||
"lodash.omit": "^4.5.0",
|
||||
"next": "^12.0.3",
|
||||
"query-string": "^7.0.1",
|
||||
"querystring": "^0.2.1",
|
||||
"react": "^17.0.2",
|
||||
"react-chartjs-2": "^2.11.2",
|
||||
"react-clipboard.js": "^2.0.16",
|
||||
@ -70,6 +72,7 @@
|
||||
"urql": "^2.0.5",
|
||||
"use-dark-mode": "^2.3.1",
|
||||
"web3": "^1.6.0",
|
||||
"web3-utils": "^1.5.3",
|
||||
"web3modal": "^1.9.4",
|
||||
"yup": "^0.32.11"
|
||||
},
|
||||
|
@ -7,8 +7,7 @@ import React, {
|
||||
useCallback,
|
||||
ReactNode
|
||||
} from 'react'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { PurgatoryData } from '@oceanprotocol/lib/dist/node/ddo/interfaces/PurgatoryData'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import getAssetPurgatoryData from '@utils/purgatory'
|
||||
import { CancelToken } from 'axios'
|
||||
import { retrieveDDO } from '@utils/aquarius'
|
||||
@ -31,6 +30,12 @@ interface AssetProviderValue {
|
||||
refreshDdo: (token?: CancelToken) => Promise<void>
|
||||
}
|
||||
|
||||
// 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.
|
||||
@ -59,7 +64,7 @@ function AssetProvider({
|
||||
const newCancelToken = useCancelToken()
|
||||
|
||||
const fetchDdo = async (token?: CancelToken) => {
|
||||
Logger.log('[asset] Init asset, get DDO')
|
||||
LoggerInstance.log('[asset] Init asset, get DDO')
|
||||
setLoading(true)
|
||||
const ddo = await retrieveDDO(asset as string, token)
|
||||
|
||||
@ -77,7 +82,7 @@ function AssetProvider({
|
||||
const refreshDdo = async (token?: CancelToken) => {
|
||||
setLoading(true)
|
||||
const ddo = await fetchDdo(token)
|
||||
Logger.debug('[asset] Got DDO', ddo)
|
||||
LoggerInstance.debug('[asset] Got DDO', ddo)
|
||||
setDDO(ddo)
|
||||
setLoading(false)
|
||||
}
|
||||
@ -91,7 +96,7 @@ function AssetProvider({
|
||||
setIsInPurgatory(isInPurgatory)
|
||||
isInPurgatory && setPurgatoryData(result)
|
||||
} catch (error) {
|
||||
Logger.error(error)
|
||||
LoggerInstance.error(error)
|
||||
}
|
||||
}, [])
|
||||
|
||||
@ -106,7 +111,7 @@ function AssetProvider({
|
||||
async function init() {
|
||||
const ddo = await fetchDdo(newCancelToken())
|
||||
if (!isMounted || !ddo) return
|
||||
Logger.debug('[asset] Got DDO', ddo)
|
||||
LoggerInstance.debug('[asset] Got DDO', ddo)
|
||||
setDDO(ddo)
|
||||
setDID(asset as string)
|
||||
setTitle(ddo.metadata.name)
|
||||
|
@ -7,16 +7,13 @@ import React, {
|
||||
ReactNode,
|
||||
useEffect
|
||||
} from 'react'
|
||||
import { Ocean, Logger, Account, ConfigHelperConfig } from '@oceanprotocol/lib'
|
||||
import { Config, LoggerInstance } from '@oceanprotocol/lib'
|
||||
import { useWeb3 } from './Web3'
|
||||
import { getDevelopmentConfig, getOceanConfig } from '@utils/ocean'
|
||||
import { useAsset } from './Asset'
|
||||
|
||||
interface OceanProviderValue {
|
||||
ocean: Ocean
|
||||
account: Account
|
||||
config: ConfigHelperConfig
|
||||
connect: (config: ConfigHelperConfig) => Promise<void>
|
||||
config: Config
|
||||
}
|
||||
|
||||
const OceanContext = createContext({} as OceanProviderValue)
|
||||
@ -25,30 +22,29 @@ function OceanProvider({ children }: { children: ReactNode }): ReactElement {
|
||||
const { web3, accountId } = useWeb3()
|
||||
const { ddo } = useAsset()
|
||||
|
||||
const [ocean, setOcean] = useState<Ocean>()
|
||||
const [account, setAccount] = useState<Account>()
|
||||
const [config, setConfig] = useState<ConfigHelperConfig>()
|
||||
const [config, setConfig] = useState<Config>()
|
||||
|
||||
// -----------------------------------
|
||||
// Helper: Create Ocean instance
|
||||
// -----------------------------------
|
||||
const connect = useCallback(
|
||||
async (config: ConfigHelperConfig) => {
|
||||
async (config: Config) => {
|
||||
if (!web3) return
|
||||
|
||||
const newConfig: ConfigHelperConfig = {
|
||||
const newConfig: Config = {
|
||||
...config,
|
||||
web3Provider: web3
|
||||
}
|
||||
|
||||
try {
|
||||
Logger.log('[ocean] Connecting Ocean...', newConfig)
|
||||
const newOcean = await Ocean.getInstance(newConfig)
|
||||
setOcean(newOcean)
|
||||
LoggerInstance.log(
|
||||
'[ocean] Connecting Ocean... not anymore ',
|
||||
newConfig
|
||||
)
|
||||
|
||||
setConfig(newConfig)
|
||||
Logger.log('[ocean] Ocean instance created.', newOcean)
|
||||
} catch (error) {
|
||||
Logger.error('[ocean] Error: ', error.message)
|
||||
LoggerInstance.error('[ocean] Error: ', error.message)
|
||||
}
|
||||
},
|
||||
[web3]
|
||||
@ -78,23 +74,21 @@ function OceanProvider({ children }: { children: ReactNode }): ReactElement {
|
||||
// -----------------------------------
|
||||
// Get user info, handle account change from web3
|
||||
// -----------------------------------
|
||||
useEffect(() => {
|
||||
if (!ocean || !accountId || !web3) return
|
||||
// useEffect(() => {
|
||||
// if ( !accountId || !web3) return
|
||||
|
||||
async function getInfo() {
|
||||
const account = (await ocean.accounts.list())[0]
|
||||
Logger.log('[ocean] Account: ', account)
|
||||
setAccount(account)
|
||||
}
|
||||
getInfo()
|
||||
}, [ocean, accountId, web3])
|
||||
// async function getInfo() {
|
||||
// const account = (await ocean.accounts.list())[0]
|
||||
// LoggerInstance.log('[ocean] Account: ', account)
|
||||
// setAccount(account)
|
||||
// }
|
||||
// getInfo()
|
||||
// }, [ocean, accountId, web3])
|
||||
|
||||
return (
|
||||
<OceanContext.Provider
|
||||
value={
|
||||
{
|
||||
ocean,
|
||||
account,
|
||||
connect,
|
||||
config
|
||||
// refreshBalance
|
||||
|
@ -8,7 +8,7 @@ import React, {
|
||||
import { fetchData } from '@utils/fetch'
|
||||
import useSWR from 'swr'
|
||||
import { useSiteMetadata } from '@hooks/useSiteMetadata'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
|
||||
interface PricesValue {
|
||||
[key: string]: number
|
||||
@ -39,7 +39,7 @@ export default function PricesProvider({
|
||||
|
||||
const onSuccess = async (data: { [tokenId]: { [key: string]: number } }) => {
|
||||
if (!data) return
|
||||
Logger.log('[prices] Got new OCEAN spot prices.', data[tokenId])
|
||||
LoggerInstance.log('[prices] Got new OCEAN spot prices.', data[tokenId])
|
||||
setPrices(data[tokenId])
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ import {
|
||||
} from '@utils/subgraph'
|
||||
import { useUserPreferences } from './UserPreferences'
|
||||
import { PoolShares_poolShares as PoolShare } from '../@types/apollo/PoolShares'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import { getDownloadAssets, getPublishedAssets } from '@utils/aquarius'
|
||||
import { useSiteMetadata } from '@hooks/useSiteMetadata'
|
||||
import { accountTruncate } from '@utils/web3'
|
||||
@ -70,7 +70,7 @@ function ProfileProvider({
|
||||
|
||||
useEffect(() => {
|
||||
if (!accountEns) return
|
||||
Logger.log(`[profile] ENS name found for ${accountId}:`, accountEns)
|
||||
LoggerInstance.log(`[profile] ENS name found for ${accountId}:`, accountEns)
|
||||
}, [accountId, accountEns])
|
||||
|
||||
useEffect(() => {
|
||||
@ -109,10 +109,10 @@ function ProfileProvider({
|
||||
...prevState,
|
||||
...newProfile
|
||||
}))
|
||||
Logger.log('[profile] Found and set 3box profile.', newProfile)
|
||||
LoggerInstance.log('[profile] Found and set 3box profile.', newProfile)
|
||||
} else {
|
||||
// setProfile(clearedProfile)
|
||||
Logger.log('[profile] No 3box profile found.')
|
||||
LoggerInstance.log('[profile] No 3box profile found.')
|
||||
}
|
||||
}
|
||||
getInfo()
|
||||
@ -137,12 +137,12 @@ function ProfileProvider({
|
||||
setIsPoolSharesLoading(true)
|
||||
const poolShares = await getPoolSharesData(accountId, chainIds)
|
||||
setPoolShares(poolShares)
|
||||
Logger.log(
|
||||
LoggerInstance.log(
|
||||
`[profile] Fetched ${poolShares.length} pool shares.`,
|
||||
poolShares
|
||||
)
|
||||
} catch (error) {
|
||||
Logger.error('Error fetching pool shares: ', error.message)
|
||||
LoggerInstance.error('Error fetching pool shares: ', error.message)
|
||||
} finally {
|
||||
setIsPoolSharesLoading(false)
|
||||
}
|
||||
@ -188,7 +188,7 @@ function ProfileProvider({
|
||||
)
|
||||
setAssets(result.results)
|
||||
setAssetsTotal(result.totalResults)
|
||||
Logger.log(
|
||||
LoggerInstance.log(
|
||||
`[profile] Fetched ${result.totalResults} assets.`,
|
||||
result.results
|
||||
)
|
||||
@ -199,7 +199,7 @@ function ProfileProvider({
|
||||
// const assetsWithPrices = await getAssetsBestPrices(result.results)
|
||||
// setAssetsWithPrices(assetsWithPrices)
|
||||
} catch (error) {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
}
|
||||
}
|
||||
getAllPublished()
|
||||
@ -239,7 +239,7 @@ function ProfileProvider({
|
||||
)
|
||||
setDownloads(downloads)
|
||||
setDownloadsTotal(downloads.length)
|
||||
Logger.log(
|
||||
LoggerInstance.log(
|
||||
`[profile] Fetched ${downloads.length} download orders.`,
|
||||
downloads
|
||||
)
|
||||
@ -257,7 +257,7 @@ function ProfileProvider({
|
||||
setIsDownloadsLoading(true)
|
||||
await fetchDownloads(cancelTokenSource.token)
|
||||
} catch (err) {
|
||||
Logger.log(err.message)
|
||||
LoggerInstance.log(err.message)
|
||||
} finally {
|
||||
setIsDownloadsLoading(false)
|
||||
}
|
||||
@ -289,9 +289,9 @@ function ProfileProvider({
|
||||
try {
|
||||
const result = await getUserSales(accountId, chainIds)
|
||||
setSales(result)
|
||||
Logger.log(`[profile] Fetched sales number: ${result}.`, result)
|
||||
LoggerInstance.log(`[profile] Fetched sales number: ${result}.`, result)
|
||||
} catch (error) {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
}
|
||||
}
|
||||
getUserSalesNumber()
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { createClient, Provider, Client } from 'urql'
|
||||
import React, { useState, useEffect, ReactNode, ReactElement } from 'react'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import { getOceanConfig } from '@utils/ocean'
|
||||
|
||||
let urqlClient: Client
|
||||
@ -33,7 +33,7 @@ export default function UrqlClientProvider({
|
||||
const oceanConfig = getOceanConfig(1)
|
||||
|
||||
if (!oceanConfig?.subgraphUri) {
|
||||
Logger.error(
|
||||
LoggerInstance.error(
|
||||
'No subgraphUri defined, preventing UrqlProvider from initialization.'
|
||||
)
|
||||
return
|
||||
@ -42,7 +42,7 @@ export default function UrqlClientProvider({
|
||||
const newClient = createUrqlClient(oceanConfig.subgraphUri)
|
||||
urqlClient = newClient
|
||||
setClient(newClient)
|
||||
Logger.log(`[URQL] Client connected to ${oceanConfig.subgraphUri}`)
|
||||
LoggerInstance.log(`[URQL] Client connected to ${oceanConfig.subgraphUri}`)
|
||||
}, [])
|
||||
|
||||
return client ? <Provider value={client}>{children}</Provider> : <></>
|
||||
|
@ -6,7 +6,7 @@ import React, {
|
||||
useState,
|
||||
useEffect
|
||||
} from 'react'
|
||||
import { Logger, LogLevel } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance, LogLevel } from '@oceanprotocol/lib'
|
||||
import { isBrowser } from '@utils/index'
|
||||
import { useSiteMetadata } from '@hooks/useSiteMetadata'
|
||||
|
||||
@ -102,8 +102,8 @@ function UserPreferencesProvider({
|
||||
// Set ocean.js log levels, default: Error
|
||||
useEffect(() => {
|
||||
debug === true
|
||||
? Logger.setLevel(LogLevel.Verbose)
|
||||
: Logger.setLevel(LogLevel.Error)
|
||||
? LoggerInstance.setLevel(LogLevel.Verbose)
|
||||
: LoggerInstance.setLevel(LogLevel.Error)
|
||||
}, [debug])
|
||||
|
||||
// Get locale always from user's browser
|
||||
|
@ -11,7 +11,7 @@ import Web3 from 'web3'
|
||||
import Web3Modal, { getProviderInfo, IProviderInfo } from 'web3modal'
|
||||
import { infuraProjectId as infuraId, portisId } from '../../app.config'
|
||||
import WalletConnectProvider from '@walletconnect/web3-provider'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import { isBrowser } from '@utils/index'
|
||||
import { getEnsName } from '@utils/ens'
|
||||
import { getOceanBalance } from '@utils/ocean'
|
||||
@ -115,28 +115,28 @@ function Web3Provider({ children }: { children: ReactNode }): ReactElement {
|
||||
}
|
||||
try {
|
||||
setWeb3Loading(true)
|
||||
Logger.log('[web3] Connecting Web3...')
|
||||
LoggerInstance.log('[web3] Connecting Web3...')
|
||||
|
||||
const provider = await web3Modal?.connect()
|
||||
setWeb3Provider(provider)
|
||||
|
||||
const web3 = new Web3(provider)
|
||||
setWeb3(web3)
|
||||
Logger.log('[web3] Web3 created.', web3)
|
||||
LoggerInstance.log('[web3] Web3 created.', web3)
|
||||
|
||||
const networkId = await web3.eth.net.getId()
|
||||
setNetworkId(networkId)
|
||||
Logger.log('[web3] network id ', networkId)
|
||||
LoggerInstance.log('[web3] network id ', networkId)
|
||||
|
||||
const chainId = await web3.eth.getChainId()
|
||||
setChainId(chainId)
|
||||
Logger.log('[web3] chain id ', chainId)
|
||||
LoggerInstance.log('[web3] chain id ', chainId)
|
||||
|
||||
const accountId = (await web3.eth.getAccounts())[0]
|
||||
setAccountId(accountId)
|
||||
Logger.log('[web3] account id', accountId)
|
||||
LoggerInstance.log('[web3] account id', accountId)
|
||||
} catch (error) {
|
||||
Logger.error('[web3] Error: ', error.message)
|
||||
LoggerInstance.error('[web3] Error: ', error.message)
|
||||
} finally {
|
||||
setWeb3Loading(false)
|
||||
}
|
||||
@ -154,9 +154,9 @@ function Web3Provider({ children }: { children: ReactNode }): ReactElement {
|
||||
ocean: await getOceanBalance(accountId, networkId, web3)
|
||||
}
|
||||
setBalance(balance)
|
||||
Logger.log('[web3] Balance: ', balance)
|
||||
LoggerInstance.log('[web3] Balance: ', balance)
|
||||
} catch (error) {
|
||||
Logger.error('[web3] Error: ', error.message)
|
||||
LoggerInstance.error('[web3] Error: ', error.message)
|
||||
}
|
||||
}, [accountId, networkId, web3])
|
||||
|
||||
@ -175,9 +175,12 @@ function Web3Provider({ children }: { children: ReactNode }): ReactElement {
|
||||
const accountEns = await getEnsName(accountId)
|
||||
setAccountEns(accountEns)
|
||||
accountEns &&
|
||||
Logger.log(`[web3] ENS name found for ${accountId}:`, accountEns)
|
||||
LoggerInstance.log(
|
||||
`[web3] ENS name found for ${accountId}:`,
|
||||
accountEns
|
||||
)
|
||||
} catch (error) {
|
||||
Logger.error('[web3] Error: ', error.message)
|
||||
LoggerInstance.error('[web3] Error: ', error.message)
|
||||
}
|
||||
}, [accountId])
|
||||
|
||||
@ -194,7 +197,10 @@ function Web3Provider({ children }: { children: ReactNode }): ReactElement {
|
||||
// note: needs artificial await here so the log message is reached and output
|
||||
const web3ModalInstance = await new Web3Modal(web3ModalOpts)
|
||||
setWeb3Modal(web3ModalInstance)
|
||||
Logger.log('[web3] Web3Modal instance created.', web3ModalInstance)
|
||||
LoggerInstance.log(
|
||||
'[web3] Web3Modal instance created.',
|
||||
web3ModalInstance
|
||||
)
|
||||
}
|
||||
init()
|
||||
}, [connect, web3Modal])
|
||||
@ -206,7 +212,7 @@ function Web3Provider({ children }: { children: ReactNode }): ReactElement {
|
||||
if (!web3Modal?.cachedProvider) return
|
||||
|
||||
async function connectCached() {
|
||||
Logger.log(
|
||||
LoggerInstance.log(
|
||||
'[web3] Connecting to cached provider: ',
|
||||
web3Modal.cachedProvider
|
||||
)
|
||||
@ -243,7 +249,7 @@ function Web3Provider({ children }: { children: ReactNode }): ReactElement {
|
||||
if (!networkId) return
|
||||
const networkData = getNetworkDataById(networksList, networkId)
|
||||
setNetworkData(networkData)
|
||||
Logger.log(
|
||||
LoggerInstance.log(
|
||||
networkData
|
||||
? `[web3] Network metadata found.`
|
||||
: `[web3] No network metadata found.`,
|
||||
@ -259,7 +265,9 @@ function Web3Provider({ children }: { children: ReactNode }): ReactElement {
|
||||
networkData?.network !== 'mainnet' && networkData.network !== 'moonriver'
|
||||
)
|
||||
|
||||
Logger.log(`[web3] Network display name set to: ${networkDisplayName}`)
|
||||
LoggerInstance.log(
|
||||
`[web3] Network display name set to: ${networkDisplayName}`
|
||||
)
|
||||
}, [networkId, networksList])
|
||||
|
||||
// -----------------------------------
|
||||
@ -271,7 +279,7 @@ function Web3Provider({ children }: { children: ReactNode }): ReactElement {
|
||||
async function getBlock() {
|
||||
const block = await web3.eth.getBlockNumber()
|
||||
setBlock(block)
|
||||
Logger.log('[web3] Head block: ', block)
|
||||
LoggerInstance.log('[web3] Head block: ', block)
|
||||
}
|
||||
getBlock()
|
||||
}, [web3, networkId])
|
||||
@ -302,21 +310,21 @@ function Web3Provider({ children }: { children: ReactNode }): ReactElement {
|
||||
// Handle change events
|
||||
// -----------------------------------
|
||||
async function handleChainChanged(chainId: string) {
|
||||
Logger.log('[web3] Chain changed', chainId)
|
||||
LoggerInstance.log('[web3] Chain changed', chainId)
|
||||
const networkId = await web3.eth.net.getId()
|
||||
setChainId(Number(chainId))
|
||||
setNetworkId(Number(networkId))
|
||||
}
|
||||
|
||||
async function handleNetworkChanged(networkId: string) {
|
||||
Logger.log('[web3] Network changed', networkId)
|
||||
LoggerInstance.log('[web3] Network changed', networkId)
|
||||
const chainId = await web3.eth.getChainId()
|
||||
setNetworkId(Number(networkId))
|
||||
setChainId(Number(chainId))
|
||||
}
|
||||
|
||||
async function handleAccountsChanged(accounts: string[]) {
|
||||
Logger.log('[web3] Account changed', accounts[0])
|
||||
LoggerInstance.log('[web3] Account changed', accounts[0])
|
||||
setAccountId(accounts[0])
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import { PurgatoryDataAccount, getAccountPurgatoryData } from '@utils/purgatory'
|
||||
|
||||
interface UseAccountPurgatory {
|
||||
@ -24,7 +24,7 @@ function useAccountPurgatory(accountId: string): UseAccountPurgatory {
|
||||
setIsInPurgatory(isInPurgatory)
|
||||
isInPurgatory && setPurgatoryData(result)
|
||||
} catch (error) {
|
||||
Logger.error(error)
|
||||
LoggerInstance.error(error)
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
import { useState } from 'react'
|
||||
import { consumeFeedback } from '@utils/feedback'
|
||||
import { DID, Logger, ServiceType } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import { useOcean } from '@context/Ocean'
|
||||
import { useWeb3 } from '@context/Web3'
|
||||
|
||||
interface UseConsume {
|
||||
consume: (
|
||||
did: DID | string,
|
||||
did: string,
|
||||
dataTokenAddress: string,
|
||||
serviceType: ServiceType,
|
||||
serviceType: string,
|
||||
marketFeeAddress: string,
|
||||
orderId?: string
|
||||
) => Promise<string>
|
||||
@ -20,7 +20,6 @@ interface UseConsume {
|
||||
|
||||
function useConsume(): UseConsume {
|
||||
const { accountId } = useWeb3()
|
||||
const { ocean, account } = useOcean()
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
const [consumeStep, setConsumeStep] = useState<number | undefined>()
|
||||
const [consumeStepText, setConsumeStepText] = useState<string | undefined>()
|
||||
@ -32,13 +31,13 @@ function useConsume(): UseConsume {
|
||||
}
|
||||
|
||||
async function consume(
|
||||
did: DID | string,
|
||||
did: string,
|
||||
dataTokenAddress: string,
|
||||
serviceType: ServiceType = 'access',
|
||||
serviceType = 'access',
|
||||
marketFeeAddress: string,
|
||||
orderId?: string
|
||||
): Promise<string> {
|
||||
if (!ocean || !account || !accountId) return
|
||||
if (!accountId) return
|
||||
|
||||
setIsLoading(true)
|
||||
setConsumeError(undefined)
|
||||
@ -47,47 +46,47 @@ function useConsume(): UseConsume {
|
||||
setStep(0)
|
||||
if (!orderId) {
|
||||
// if we don't have a previous valid order, get one
|
||||
const userOwnedTokens = await ocean.accounts.getTokenBalance(
|
||||
dataTokenAddress,
|
||||
account
|
||||
)
|
||||
if (parseFloat(userOwnedTokens) < 1) {
|
||||
setConsumeError('Not enough datatokens')
|
||||
return 'Not enough datatokens'
|
||||
} else {
|
||||
setStep(1)
|
||||
try {
|
||||
orderId = await ocean.assets.order(
|
||||
did as string,
|
||||
serviceType,
|
||||
accountId,
|
||||
undefined,
|
||||
marketFeeAddress,
|
||||
undefined,
|
||||
null,
|
||||
false
|
||||
)
|
||||
Logger.log('order created', orderId)
|
||||
setStep(2)
|
||||
} catch (error) {
|
||||
setConsumeError(error.message)
|
||||
return error.message
|
||||
}
|
||||
}
|
||||
// const userOwnedTokens = await ocean.accounts.getTokenBalance(
|
||||
// dataTokenAddress,
|
||||
// account
|
||||
// )
|
||||
// if (parseFloat(userOwnedTokens) < 1) {
|
||||
// setConsumeError('Not enough datatokens')
|
||||
// return 'Not enough datatokens'
|
||||
// } else {
|
||||
// setStep(1)
|
||||
// try {
|
||||
// orderId = await ocean.assets.order(
|
||||
// did as string,
|
||||
// serviceType,
|
||||
// accountId,
|
||||
// undefined,
|
||||
// marketFeeAddress,
|
||||
// undefined,
|
||||
// null,
|
||||
// false
|
||||
// )
|
||||
// LoggerInstance.log('order created', orderId)
|
||||
// setStep(2)
|
||||
// } catch (error) {
|
||||
// setConsumeError(error.message)
|
||||
// return error.message
|
||||
// }
|
||||
// }
|
||||
}
|
||||
setStep(3)
|
||||
if (orderId)
|
||||
await ocean.assets.download(
|
||||
did as string,
|
||||
orderId,
|
||||
dataTokenAddress,
|
||||
account,
|
||||
''
|
||||
)
|
||||
// if (orderId)
|
||||
// await ocean.assets.download(
|
||||
// did as string,
|
||||
// orderId,
|
||||
// dataTokenAddress,
|
||||
// account,
|
||||
// ''
|
||||
// )
|
||||
setStep(4)
|
||||
} catch (error) {
|
||||
setConsumeError(error.message)
|
||||
Logger.error(error)
|
||||
LoggerInstance.error(error)
|
||||
return error.message
|
||||
} finally {
|
||||
setConsumeStep(undefined)
|
||||
|
@ -1,9 +1,8 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import { useOcean } from '@context/Ocean'
|
||||
import { useWeb3 } from '@context/Web3'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { Config, LoggerInstance } from '@oceanprotocol/lib'
|
||||
import Web3 from 'web3'
|
||||
import { ConfigHelperConfig } from '@oceanprotocol/lib/dist/node/utils/ConfigHelper'
|
||||
import axios, { AxiosResponse } from 'axios'
|
||||
|
||||
const blockDifferenceThreshold = 30
|
||||
@ -27,11 +26,11 @@ async function fetchGraph(
|
||||
const response = await axios.post(url, { ...JSON.parse(queryBody) })
|
||||
return response
|
||||
} catch (error) {
|
||||
Logger.error('Error parsing json: ' + error.message)
|
||||
LoggerInstance.error('Error parsing json: ' + error.message)
|
||||
}
|
||||
}
|
||||
|
||||
async function getBlockHead(config: ConfigHelperConfig) {
|
||||
async function getBlockHead(config: Config) {
|
||||
// for ETH main, get block from graph fetch
|
||||
if (config.network === 'mainnet') {
|
||||
const response: any = await fetchGraph(ethGraphUrl, ethGraphQuery)
|
||||
@ -68,7 +67,7 @@ export function useGraphSyncStatus(): UseGraphSyncStatus {
|
||||
async function initBlockHead() {
|
||||
const blockHead = block || (await getBlockHead(config))
|
||||
setBlockHead(blockHead)
|
||||
Logger.log('[GraphStatus] Head block: ', blockHead)
|
||||
LoggerInstance.log('[GraphStatus] Head block: ', blockHead)
|
||||
}
|
||||
initBlockHead()
|
||||
}, [web3Loading, block, config])
|
||||
@ -82,7 +81,10 @@ export function useGraphSyncStatus(): UseGraphSyncStatus {
|
||||
const blockGraph = await getBlockSubgraph(config.subgraphUri)
|
||||
setBlockGraph(blockGraph)
|
||||
setSubgraphLoading(false)
|
||||
Logger.log('[GraphStatus] Latest block from subgraph: ', blockGraph)
|
||||
LoggerInstance.log(
|
||||
'[GraphStatus] Latest block from subgraph: ',
|
||||
blockGraph
|
||||
)
|
||||
}
|
||||
initBlockSubgraph()
|
||||
}, [config])
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import { useState } from 'react'
|
||||
import { TransactionReceipt } from 'web3-core'
|
||||
import { Decimal } from 'decimal.js'
|
||||
@ -34,27 +34,29 @@ interface UsePricing {
|
||||
|
||||
function usePricing(): UsePricing {
|
||||
const { accountId } = useWeb3()
|
||||
const { ocean, config } = useOcean()
|
||||
const { config } = useOcean()
|
||||
const [pricingIsLoading, setPricingIsLoading] = useState(false)
|
||||
const [pricingStep, setPricingStep] = useState<number>()
|
||||
const [pricingStepText, setPricingStepText] = useState<string>()
|
||||
const [pricingError, setPricingError] = useState<string>()
|
||||
|
||||
async function getDTSymbol(ddo: Asset): Promise<string> {
|
||||
if (!ocean || !accountId) return
|
||||
if (!accountId) return
|
||||
|
||||
const { dataTokenInfo } = ddo
|
||||
return dataTokenInfo
|
||||
? dataTokenInfo.symbol
|
||||
: await ocean?.datatokens.getSymbol(dataTokenInfo.address)
|
||||
return dataTokenInfo.symbol
|
||||
// return dataTokenInfo
|
||||
// ? dataTokenInfo.symbol
|
||||
// : await ocean?.datatokens.getSymbol(dataTokenInfo.address)
|
||||
}
|
||||
|
||||
async function getDTName(ddo: Asset): Promise<string> {
|
||||
if (!ocean || !accountId) return
|
||||
if (!accountId) return
|
||||
const { dataTokenInfo } = ddo
|
||||
return dataTokenInfo
|
||||
? dataTokenInfo.name
|
||||
: await ocean?.datatokens.getName(dataTokenInfo.address)
|
||||
return dataTokenInfo.name
|
||||
// return dataTokenInfo
|
||||
// ? dataTokenInfo.name
|
||||
// : await ocean?.datatokens.getName(dataTokenInfo.address)
|
||||
}
|
||||
|
||||
// Helper for setting steps & feedback for all flows
|
||||
@ -95,20 +97,20 @@ function usePricing(): UsePricing {
|
||||
ddo: Asset
|
||||
): Promise<TransactionReceipt | void> {
|
||||
const { dataTokenInfo } = ddo
|
||||
Logger.log('mint function', dataTokenInfo.address, accountId)
|
||||
const balance = new Decimal(
|
||||
await ocean.datatokens.balance(dataTokenInfo.address, accountId)
|
||||
)
|
||||
const tokens = new Decimal(tokensToMint)
|
||||
if (tokens.greaterThan(balance)) {
|
||||
const mintAmount = tokens.minus(balance)
|
||||
const tx = await ocean.datatokens.mint(
|
||||
dataTokenInfo.address,
|
||||
accountId,
|
||||
mintAmount.toString()
|
||||
)
|
||||
return tx
|
||||
}
|
||||
LoggerInstance.log('mint function', dataTokenInfo.address, accountId)
|
||||
// const balance = new Decimal(
|
||||
// await ocean.datatokens.balance(dataTokenInfo.address, accountId)
|
||||
// )
|
||||
// const tokens = new Decimal(tokensToMint)
|
||||
// if (tokens.greaterThan(balance)) {
|
||||
// const mintAmount = tokens.minus(balance)
|
||||
// const tx = await ocean.datatokens.mint(
|
||||
// dataTokenInfo.address,
|
||||
// accountId,
|
||||
// mintAmount.toString()
|
||||
// )
|
||||
// return tx
|
||||
// }
|
||||
}
|
||||
|
||||
async function buyDT(
|
||||
@ -116,7 +118,7 @@ function usePricing(): UsePricing {
|
||||
price: BestPrice,
|
||||
ddo: Asset
|
||||
): Promise<TransactionReceipt | void> {
|
||||
if (!ocean || !accountId) return
|
||||
if (!accountId) return
|
||||
|
||||
let tx
|
||||
|
||||
@ -125,7 +127,7 @@ function usePricing(): UsePricing {
|
||||
setPricingError(undefined)
|
||||
setStep(1, 'buy', ddo)
|
||||
|
||||
Logger.log('Price found for buying', price)
|
||||
LoggerInstance.log('Price found for buying', price)
|
||||
Decimal.set({ precision: 18 })
|
||||
|
||||
switch (price?.type) {
|
||||
@ -134,78 +136,78 @@ function usePricing(): UsePricing {
|
||||
const maxPrice = new Decimal(price.value).times(2).toString()
|
||||
|
||||
setStep(2, 'buy', ddo)
|
||||
Logger.log(
|
||||
LoggerInstance.log(
|
||||
'Buying token from pool',
|
||||
price,
|
||||
accountId,
|
||||
oceanAmmount,
|
||||
maxPrice
|
||||
)
|
||||
tx = await ocean.pool.buyDT(
|
||||
accountId,
|
||||
price.address,
|
||||
String(amountDataToken),
|
||||
oceanAmmount,
|
||||
maxPrice
|
||||
)
|
||||
// tx = await ocean.pool.buyDT(
|
||||
// accountId,
|
||||
// price.address,
|
||||
// String(amountDataToken),
|
||||
// oceanAmmount,
|
||||
// maxPrice
|
||||
// )
|
||||
setStep(3, 'buy', ddo)
|
||||
Logger.log('DT buy response', tx)
|
||||
LoggerInstance.log('DT buy response', tx)
|
||||
break
|
||||
}
|
||||
case 'fixed': {
|
||||
if (!config.oceanTokenAddress) {
|
||||
Logger.error(`'oceanTokenAddress' not set in config`)
|
||||
LoggerInstance.error(`'oceanTokenAddress' not set in config`)
|
||||
return
|
||||
}
|
||||
if (!config.fixedRateExchangeAddress) {
|
||||
Logger.error(`'fixedRateExchangeAddress' not set in config`)
|
||||
LoggerInstance.error(`'fixedRateExchangeAddress' not set in config`)
|
||||
return
|
||||
}
|
||||
Logger.log('Buying token from exchange', price, accountId)
|
||||
await ocean.datatokens.approve(
|
||||
config.oceanTokenAddress,
|
||||
config.fixedRateExchangeAddress,
|
||||
`${price.value}`,
|
||||
accountId
|
||||
)
|
||||
LoggerInstance.log('Buying token from exchange', price, accountId)
|
||||
// await ocean.datatokens.approve(
|
||||
// config.oceanTokenAddress,
|
||||
// config.fixedRateExchangeAddress,
|
||||
// `${price.value}`,
|
||||
// accountId
|
||||
// )
|
||||
setStep(2, 'buy', ddo)
|
||||
tx = await ocean.fixedRateExchange.buyDT(
|
||||
price.address,
|
||||
`${amountDataToken}`,
|
||||
accountId
|
||||
)
|
||||
// tx = await ocean.fixedRateExchange.buyDT(
|
||||
// price.address,
|
||||
// `${amountDataToken}`,
|
||||
// accountId
|
||||
// )
|
||||
setStep(3, 'buy', ddo)
|
||||
Logger.log('DT exchange buy response', tx)
|
||||
LoggerInstance.log('DT exchange buy response', tx)
|
||||
break
|
||||
}
|
||||
case 'free': {
|
||||
setStep(1, 'dispense', ddo)
|
||||
const isDispensable = await ocean.OceanDispenser.isDispensable(
|
||||
ddo?.services[0].datatokenAddress,
|
||||
accountId,
|
||||
'1'
|
||||
)
|
||||
// const isDispensable = await ocean.OceanDispenser.isDispensable(
|
||||
// ddo?.services[0].datatokenAddress,
|
||||
// accountId,
|
||||
// '1'
|
||||
// )
|
||||
|
||||
if (!isDispensable) {
|
||||
Logger.error(
|
||||
`Dispenser for ${ddo?.services[0].datatokenAddress} failed to dispense`
|
||||
)
|
||||
return
|
||||
}
|
||||
// if (!isDispensable) {
|
||||
// LoggerInstance.error(
|
||||
// `Dispenser for ${ddo?.services[0].datatokenAddress} failed to dispense`
|
||||
// )
|
||||
// return
|
||||
// }
|
||||
|
||||
tx = await ocean.OceanDispenser.dispense(
|
||||
ddo?.services[0].datatokenAddress,
|
||||
accountId,
|
||||
'1'
|
||||
)
|
||||
// tx = await ocean.OceanDispenser.dispense(
|
||||
// ddo?.services[0].datatokenAddress,
|
||||
// accountId,
|
||||
// '1'
|
||||
// )
|
||||
setStep(2, 'dispense', ddo)
|
||||
Logger.log('DT dispense response', tx)
|
||||
LoggerInstance.log('DT dispense response', tx)
|
||||
break
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
setPricingError(error.message)
|
||||
Logger.error(error)
|
||||
LoggerInstance.error(error)
|
||||
} finally {
|
||||
setStep(0, 'buy', ddo)
|
||||
setPricingStepText(undefined)
|
||||
@ -222,7 +224,7 @@ function usePricing(): UsePricing {
|
||||
const dataToken = ddo?.services[0].datatokenAddress
|
||||
const dtSymbol = await getDTSymbol(ddo)
|
||||
|
||||
if (!ocean || !accountId || !dtSymbol) return
|
||||
if (!accountId || !dtSymbol) return
|
||||
|
||||
const { type, amountOcean, price, weightOnDataToken, swapFee } =
|
||||
priceOptions
|
||||
@ -231,7 +233,7 @@ function usePricing(): UsePricing {
|
||||
const isPool = type === 'dynamic'
|
||||
|
||||
if (!isPool && !config.fixedRateExchangeAddress) {
|
||||
Logger.error(`'fixedRateExchangeAddress' not set in config.`)
|
||||
LoggerInstance.error(`'fixedRateExchangeAddress' not set in config.`)
|
||||
return
|
||||
}
|
||||
|
||||
@ -243,7 +245,7 @@ function usePricing(): UsePricing {
|
||||
try {
|
||||
if (type === 'free') {
|
||||
setStep(99, 'free', ddo)
|
||||
await ocean.OceanDispenser.activate(dataToken, '1', '1', accountId)
|
||||
// await ocean.OceanDispenser.activate(dataToken, '1', '1', accountId)
|
||||
} else {
|
||||
// if fixedPrice set dt to max amount
|
||||
if (!isPool) amountDataToken = 1000
|
||||
@ -251,29 +253,30 @@ function usePricing(): UsePricing {
|
||||
}
|
||||
|
||||
// amountDataToken for fixed price is set to max
|
||||
const tx = isPool
|
||||
? await ocean.pool
|
||||
.create(
|
||||
accountId,
|
||||
dataToken,
|
||||
`${amountDataToken}`,
|
||||
weightOnDataToken,
|
||||
`${amountOcean}`,
|
||||
`${swapFee}`
|
||||
)
|
||||
.next((step: number) => setStep(step, 'pool', ddo))
|
||||
: type === 'fixed'
|
||||
? await ocean.fixedRateExchange
|
||||
.create(dataToken, `${price}`, accountId, `${amountDataToken}`)
|
||||
.next((step: number) => setStep(step, 'exchange', ddo))
|
||||
: await ocean.OceanDispenser.makeMinter(dataToken, accountId).next(
|
||||
(step: number) => setStep(step, 'free', ddo)
|
||||
)
|
||||
await sleep(20000)
|
||||
return tx
|
||||
// const tx = isPool
|
||||
// ? await ocean.pool
|
||||
// .create(
|
||||
// accountId,
|
||||
// dataToken,
|
||||
// `${amountDataToken}`,
|
||||
// weightOnDataToken,
|
||||
// `${amountOcean}`,
|
||||
// `${swapFee}`
|
||||
// )
|
||||
// .next((step: number) => setStep(step, 'pool', ddo))
|
||||
// : type === 'fixed'
|
||||
// ? await ocean.fixedRateExchange
|
||||
// .create(dataToken, `${price}`, accountId, `${amountDataToken}`)
|
||||
// .next((step: number) => setStep(step, 'exchange', ddo))
|
||||
// : await ocean.OceanDispenser.makeMinter(dataToken, accountId).next(
|
||||
// (step: number) => setStep(step, 'free', ddo)
|
||||
// )
|
||||
// we should remove this sleep , why do we have sleep for 20 seconds !?!?!?!?!?!?!!?
|
||||
// await sleep(20000)
|
||||
// return tx
|
||||
} catch (error) {
|
||||
setPricingError(error.message)
|
||||
Logger.error(error)
|
||||
LoggerInstance.error(error)
|
||||
} finally {
|
||||
setPricingStep(0)
|
||||
setPricingStepText(undefined)
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import { AssetSelectionAsset } from '@shared/FormFields/AssetSelection'
|
||||
import { PriceList, getAssetsPriceList } from './subgraph'
|
||||
import axios, { CancelToken, AxiosResponse } from 'axios'
|
||||
@ -99,9 +99,9 @@ export async function queryMetadata(
|
||||
return transformQueryResult(response.data, query.from, query.size)
|
||||
} catch (error) {
|
||||
if (axios.isCancel(error)) {
|
||||
Logger.log(error.message)
|
||||
LoggerInstance.log(error.message)
|
||||
} else {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -121,9 +121,9 @@ export async function retrieveDDO(
|
||||
return data
|
||||
} catch (error) {
|
||||
if (axios.isCancel(error)) {
|
||||
Logger.log(error.message)
|
||||
LoggerInstance.log(error.message)
|
||||
} else {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -142,9 +142,9 @@ export async function getAssetsNames(
|
||||
return response.data
|
||||
} catch (error) {
|
||||
if (axios.isCancel(error)) {
|
||||
Logger.log(error.message)
|
||||
LoggerInstance.log(error.message)
|
||||
} else {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -167,7 +167,7 @@ export async function getAssetsFromDidList(
|
||||
const queryResult = await queryMetadata(query, cancelToken)
|
||||
return queryResult
|
||||
} catch (error) {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ export async function retrieveDDOListByDIDs(
|
||||
})
|
||||
return orderedDDOListByDIDList
|
||||
} catch (error) {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
@ -318,9 +318,9 @@ export async function getPublishedAssets(
|
||||
return result
|
||||
} catch (error) {
|
||||
if (axios.isCancel(error)) {
|
||||
Logger.log(error.message)
|
||||
LoggerInstance.log(error.message)
|
||||
} else {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -361,6 +361,6 @@ export async function getDownloadAssets(
|
||||
|
||||
return downloadedAssets
|
||||
} catch (error) {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +0,0 @@
|
||||
import { Ocean } from '@oceanprotocol/lib'
|
||||
import { getServiceByName } from './ddo'
|
||||
|
||||
export default async function checkPreviousOrder(
|
||||
ocean: Ocean,
|
||||
accountId: string,
|
||||
ddo: Asset,
|
||||
serviceType: 'access' | 'compute'
|
||||
): Promise<string> {
|
||||
if (!ocean) return
|
||||
|
||||
const service = getServiceByName(ddo, serviceType)
|
||||
// apparenlty cost and timeout are not found, even though they are there...
|
||||
// const previousOrder = await ocean.datatokens.getPreviousValidOrders(
|
||||
// ddo?.services[0].datatokenAddress,
|
||||
// service.cost,
|
||||
// service.index,
|
||||
// service.timeout,
|
||||
// accountId
|
||||
// )
|
||||
// return previousOrder
|
||||
return 'dummy'
|
||||
}
|
@ -1,15 +1,14 @@
|
||||
import {
|
||||
ServiceComputePrivacy,
|
||||
publisherTrustedAlgorithm as PublisherTrustedAlgorithm,
|
||||
Service,
|
||||
Logger,
|
||||
Provider,
|
||||
Config,
|
||||
Ocean,
|
||||
Account
|
||||
} from '@oceanprotocol/lib'
|
||||
import web3 from 'web3'
|
||||
import { ComputeJob } from '@oceanprotocol/lib/dist/node/ocean/interfaces/Compute'
|
||||
// import {
|
||||
// ServiceComputePrivacy,
|
||||
// publisherTrustedAlgorithm as PublisherTrustedAlgorithm,
|
||||
// Service,
|
||||
// LoggerInstance,
|
||||
// Provider,
|
||||
// Config,
|
||||
// Ocean,
|
||||
// Account
|
||||
// } from '@oceanprotocol/lib'
|
||||
// import { ComputeJob } from '@oceanprotocol/lib/dist/node/ocean/interfaces/Compute'
|
||||
import { CancelToken } from 'axios'
|
||||
import { gql } from 'urql'
|
||||
import { queryMetadata, getFilterTerm, generateBaseQuery } from './aquarius'
|
||||
@ -98,7 +97,7 @@ function getServiceEndpoints(data: TokenOrder[], assets: Asset[]): string[] {
|
||||
// if (wasProviderQueried) continue
|
||||
// serviceEndpoints.push(providerEndpoint)
|
||||
// } catch (err) {
|
||||
// Logger.error(err.message)
|
||||
// LoggerInstance.error(err.message)
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -107,190 +106,190 @@ function getServiceEndpoints(data: TokenOrder[], assets: Asset[]): string[] {
|
||||
return ['dummy']
|
||||
}
|
||||
|
||||
async function getProviders(
|
||||
serviceEndpoints: string[],
|
||||
config: Config,
|
||||
ocean: Ocean
|
||||
): Promise<Provider[]> {
|
||||
const providers: Provider[] = []
|
||||
// async function getProviders(
|
||||
// serviceEndpoints: string[],
|
||||
// config: Config,
|
||||
// ocean: Ocean
|
||||
// ): Promise<Provider[]> {
|
||||
// const providers: Provider[] = []
|
||||
|
||||
try {
|
||||
for (let i = 0; i < serviceEndpoints?.length; i++) {
|
||||
const instanceConfig = {
|
||||
config,
|
||||
web3: config.web3Provider,
|
||||
logger: Logger,
|
||||
ocean
|
||||
}
|
||||
const provider = await Provider.getInstance(instanceConfig)
|
||||
await provider.setBaseUrl(serviceEndpoints[i])
|
||||
const hasSameCompute =
|
||||
providers.filter((x) => x.computeAddress === provider.computeAddress)
|
||||
.length > 0
|
||||
if (!hasSameCompute) providers.push(provider)
|
||||
}
|
||||
} catch (err) {
|
||||
Logger.error(err.message)
|
||||
}
|
||||
// try {
|
||||
// for (let i = 0; i < serviceEndpoints?.length; i++) {
|
||||
// const instanceConfig = {
|
||||
// config,
|
||||
// web3: config.web3Provider,
|
||||
// logger: LoggerInstance,
|
||||
// ocean
|
||||
// }
|
||||
// const provider = await Provider.getInstance(instanceConfig)
|
||||
// await provider.setBaseUrl(serviceEndpoints[i])
|
||||
// const hasSameCompute =
|
||||
// providers.filter((x) => x.computeAddress === provider.computeAddress)
|
||||
// .length > 0
|
||||
// if (!hasSameCompute) providers.push(provider)
|
||||
// }
|
||||
// } catch (err) {
|
||||
// LoggerInstance.error(err.message)
|
||||
// }
|
||||
|
||||
return providers
|
||||
}
|
||||
// return providers
|
||||
// }
|
||||
|
||||
async function getJobs(
|
||||
providers: Provider[],
|
||||
account: Account,
|
||||
assets: Asset[]
|
||||
): Promise<ComputeJobMetaData[]> {
|
||||
const computeJobs: ComputeJobMetaData[] = []
|
||||
// async function getJobs(
|
||||
// providers: Provider[],
|
||||
// account: Account,
|
||||
// assets: Asset[]
|
||||
// ): Promise<ComputeJobMetaData[]> {
|
||||
// const computeJobs: ComputeJobMetaData[] = []
|
||||
|
||||
for (let i = 0; i < providers.length; i++) {
|
||||
try {
|
||||
const providerComputeJobs = (await providers[i].computeStatus(
|
||||
'',
|
||||
account,
|
||||
undefined,
|
||||
undefined,
|
||||
false
|
||||
)) as ComputeJob[]
|
||||
// for (let i = 0; i < providers.length; i++) {
|
||||
// try {
|
||||
// const providerComputeJobs = (await providers[i].computeStatus(
|
||||
// '',
|
||||
// account,
|
||||
// undefined,
|
||||
// undefined,
|
||||
// false
|
||||
// )) as ComputeJob[]
|
||||
|
||||
// means the provider uri is not good, so we ignore it and move on
|
||||
if (!providerComputeJobs) continue
|
||||
providerComputeJobs.sort((a, b) => {
|
||||
if (a.dateCreated > b.dateCreated) {
|
||||
return -1
|
||||
}
|
||||
if (a.dateCreated < b.dateCreated) {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
})
|
||||
// // means the provider uri is not good, so we ignore it and move on
|
||||
// if (!providerComputeJobs) continue
|
||||
// providerComputeJobs.sort((a, b) => {
|
||||
// if (a.dateCreated > b.dateCreated) {
|
||||
// return -1
|
||||
// }
|
||||
// if (a.dateCreated < b.dateCreated) {
|
||||
// return 1
|
||||
// }
|
||||
// return 0
|
||||
// })
|
||||
|
||||
for (let j = 0; j < providerComputeJobs?.length; j++) {
|
||||
const job = providerComputeJobs[j]
|
||||
const did = job.inputDID[0]
|
||||
const ddo = assets.filter((x) => x.id === did)[0]
|
||||
// for (let j = 0; j < providerComputeJobs?.length; j++) {
|
||||
// const job = providerComputeJobs[j]
|
||||
// const did = job.inputDID[0]
|
||||
// const ddo = assets.filter((x) => x.id === did)[0]
|
||||
|
||||
if (!ddo) continue
|
||||
// if (!ddo) continue
|
||||
|
||||
const compJob: ComputeJobMetaData = {
|
||||
...job,
|
||||
assetName: ddo.metadata.name,
|
||||
assetDtSymbol: ddo.dataTokenInfo.symbol,
|
||||
networkId: ddo.chainId
|
||||
}
|
||||
computeJobs.push(compJob)
|
||||
}
|
||||
} catch (err) {
|
||||
Logger.error(err.message)
|
||||
}
|
||||
}
|
||||
// const compJob: ComputeJobMetaData = {
|
||||
// ...job,
|
||||
// assetName: ddo.metadata.name,
|
||||
// assetDtSymbol: ddo.dataTokenInfo.symbol,
|
||||
// networkId: ddo.chainId
|
||||
// }
|
||||
// computeJobs.push(compJob)
|
||||
// }
|
||||
// } catch (err) {
|
||||
// LoggerInstance.error(err.message)
|
||||
// }
|
||||
// }
|
||||
|
||||
return computeJobs
|
||||
}
|
||||
// return computeJobs
|
||||
// }
|
||||
|
||||
function getDtList(data: TokenOrder[]): string[] {
|
||||
const dtList = []
|
||||
// function getDtList(data: TokenOrder[]): string[] {
|
||||
// const dtList = []
|
||||
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
dtList.push(data[i].datatokenId.address)
|
||||
}
|
||||
// for (let i = 0; i < data.length; i++) {
|
||||
// dtList.push(data[i].datatokenId.address)
|
||||
// }
|
||||
|
||||
return dtList
|
||||
}
|
||||
// return dtList
|
||||
// }
|
||||
|
||||
export async function getComputeJobs(
|
||||
chainIds: number[],
|
||||
config: Config,
|
||||
ocean: Ocean,
|
||||
account: Account,
|
||||
ddo?: Asset,
|
||||
token?: CancelToken
|
||||
): Promise<ComputeResults> {
|
||||
const assetDTAddress = ddo?.dataTokenInfo?.address
|
||||
let computeResult: ComputeResults = {
|
||||
computeJobs: [],
|
||||
isLoaded: false
|
||||
}
|
||||
let isLoading = true
|
||||
const variables = assetDTAddress
|
||||
? {
|
||||
user: account?.getId().toLowerCase(),
|
||||
datatokenAddress: assetDTAddress.toLowerCase()
|
||||
}
|
||||
: {
|
||||
user: account?.getId().toLowerCase()
|
||||
}
|
||||
// export async function getComputeJobs(
|
||||
// chainIds: number[],
|
||||
// config: Config,
|
||||
// ocean: Ocean,
|
||||
// account: Account,
|
||||
// ddo?: Asset,
|
||||
// token?: CancelToken
|
||||
// ): Promise<ComputeResults> {
|
||||
// const assetDTAddress = ddo?.dataTokenInfo?.address
|
||||
// let computeResult: ComputeResults = {
|
||||
// computeJobs: [],
|
||||
// isLoaded: false
|
||||
// }
|
||||
// let isLoading = true
|
||||
// const variables = assetDTAddress
|
||||
// ? {
|
||||
// user: account?.getId().toLowerCase(),
|
||||
// datatokenAddress: assetDTAddress.toLowerCase()
|
||||
// }
|
||||
// : {
|
||||
// user: account?.getId().toLowerCase()
|
||||
// }
|
||||
|
||||
const result = await fetchDataForMultipleChains(
|
||||
assetDTAddress ? getComputeOrdersByDatatokenAddress : getComputeOrders,
|
||||
variables,
|
||||
assetDTAddress ? [ddo?.chainId] : chainIds
|
||||
)
|
||||
let data: TokenOrder[] = []
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
if (!result[i]?.tokenOrders || result[i].tokenOrders.length === 0) continue
|
||||
result[i]?.tokenOrders.forEach((tokenOrder: TokenOrder) => {
|
||||
data.push(tokenOrder)
|
||||
})
|
||||
}
|
||||
if (!ocean || !account || !data) return
|
||||
// const result = await fetchDataForMultipleChains(
|
||||
// assetDTAddress ? getComputeOrdersByDatatokenAddress : getComputeOrders,
|
||||
// variables,
|
||||
// assetDTAddress ? [ddo?.chainId] : chainIds
|
||||
// )
|
||||
// let data: TokenOrder[] = []
|
||||
// for (let i = 0; i < result.length; i++) {
|
||||
// if (!result[i]?.tokenOrders || result[i].tokenOrders.length === 0) continue
|
||||
// result[i]?.tokenOrders.forEach((tokenOrder: TokenOrder) => {
|
||||
// data.push(tokenOrder)
|
||||
// })
|
||||
// }
|
||||
// if (!ocean || !account || !data) return
|
||||
|
||||
if (data.length === 0) {
|
||||
return computeResult
|
||||
}
|
||||
// if (data.length === 0) {
|
||||
// return computeResult
|
||||
// }
|
||||
|
||||
data = data.sort((a, b) => b.timestamp - a.timestamp)
|
||||
const queryDtList = getDtList(data)
|
||||
if (!queryDtList) return
|
||||
// data = data.sort((a, b) => b.timestamp - a.timestamp)
|
||||
// const queryDtList = getDtList(data)
|
||||
// if (!queryDtList) return
|
||||
|
||||
const assets = await getAssetMetadata(queryDtList, token, chainIds)
|
||||
const serviceEndpoints = getServiceEndpoints(data, assets)
|
||||
const providers: Provider[] = await getProviders(
|
||||
serviceEndpoints,
|
||||
config,
|
||||
ocean
|
||||
)
|
||||
const computeJobs = await getJobs(providers, account, assets)
|
||||
isLoading = false
|
||||
computeResult = {
|
||||
computeJobs: computeJobs,
|
||||
isLoaded: isLoading
|
||||
}
|
||||
// const assets = await getAssetMetadata(queryDtList, token, chainIds)
|
||||
// const serviceEndpoints = getServiceEndpoints(data, assets)
|
||||
// const providers: Provider[] = await getProviders(
|
||||
// serviceEndpoints,
|
||||
// config,
|
||||
// ocean
|
||||
// )
|
||||
// const computeJobs = await getJobs(providers, account, assets)
|
||||
// isLoading = false
|
||||
// computeResult = {
|
||||
// computeJobs: computeJobs,
|
||||
// isLoaded: isLoading
|
||||
// }
|
||||
|
||||
return computeResult
|
||||
}
|
||||
// return computeResult
|
||||
// }
|
||||
|
||||
export async function createTrustedAlgorithmList(
|
||||
selectedAlgorithms: string[], // list of DIDs
|
||||
ocean: Ocean
|
||||
): Promise<PublisherTrustedAlgorithm[]> {
|
||||
const trustedAlgorithms = []
|
||||
// export async function createTrustedAlgorithmList(
|
||||
// selectedAlgorithms: string[], // list of DIDs
|
||||
// ocean: Ocean
|
||||
// ): Promise<PublisherTrustedAlgorithm[]> {
|
||||
// const trustedAlgorithms = []
|
||||
|
||||
for (const selectedAlgorithm of selectedAlgorithms) {
|
||||
const trustedAlgorithm =
|
||||
await ocean.compute.createPublisherTrustedAlgorithmfromDID(
|
||||
selectedAlgorithm
|
||||
)
|
||||
trustedAlgorithms.push(trustedAlgorithm)
|
||||
}
|
||||
return trustedAlgorithms
|
||||
}
|
||||
// for (const selectedAlgorithm of selectedAlgorithms) {
|
||||
// const trustedAlgorithm =
|
||||
// await ocean.compute.createPublisherTrustedAlgorithmfromDID(
|
||||
// selectedAlgorithm
|
||||
// )
|
||||
// trustedAlgorithms.push(trustedAlgorithm)
|
||||
// }
|
||||
// return trustedAlgorithms
|
||||
// }
|
||||
|
||||
export async function transformComputeFormToServiceComputePrivacy(
|
||||
values: ComputePrivacyForm,
|
||||
ocean: Ocean
|
||||
): Promise<ServiceComputePrivacy> {
|
||||
const { allowAllPublishedAlgorithms } = values
|
||||
const publisherTrustedAlgorithms = values.allowAllPublishedAlgorithms
|
||||
? []
|
||||
: await createTrustedAlgorithmList(values.publisherTrustedAlgorithms, ocean)
|
||||
// export async function transformComputeFormToServiceComputePrivacy(
|
||||
// values: ComputePrivacyForm,
|
||||
// ocean: Ocean
|
||||
// ): Promise<ServiceComputePrivacy> {
|
||||
// const { allowAllPublishedAlgorithms } = values
|
||||
// const publisherTrustedAlgorithms = values.allowAllPublishedAlgorithms
|
||||
// ? []
|
||||
// : await createTrustedAlgorithmList(values.publisherTrustedAlgorithms, ocean)
|
||||
|
||||
const privacy: ServiceComputePrivacy = {
|
||||
allowNetworkAccess: false,
|
||||
allowRawAlgorithm: false,
|
||||
allowAllPublishedAlgorithms,
|
||||
publisherTrustedAlgorithms
|
||||
}
|
||||
// const privacy: ServiceComputePrivacy = {
|
||||
// allowNetworkAccess: false,
|
||||
// allowRawAlgorithm: false,
|
||||
// allowAllPublishedAlgorithms,
|
||||
// publisherTrustedAlgorithms
|
||||
// }
|
||||
|
||||
return privacy
|
||||
}
|
||||
// return privacy
|
||||
// }
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import axios from 'axios'
|
||||
import isUrl from 'is-url-superb'
|
||||
import { toast } from 'react-toastify'
|
||||
@ -25,7 +25,7 @@ async function isDockerHubImageValid(
|
||||
|
||||
return true
|
||||
} catch (error) {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
toast.error(
|
||||
'Could not fetch docker hub image info. Please check image name and tag and try again'
|
||||
)
|
||||
@ -44,7 +44,7 @@ async function is3rdPartyImageValid(imageURL: string): Promise<boolean> {
|
||||
}
|
||||
return true
|
||||
} catch (error) {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
toast.error(
|
||||
'Could not fetch docker image info. Please check URL and try again'
|
||||
)
|
||||
|
@ -1,41 +1,41 @@
|
||||
import { Logger, Ocean } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import { TransactionReceipt } from 'web3-core'
|
||||
|
||||
export async function setMinterToPublisher(
|
||||
ocean: Ocean,
|
||||
dataTokenAddress: string,
|
||||
accountId: string,
|
||||
setError: (msg: string) => void
|
||||
): Promise<TransactionReceipt> {
|
||||
// free pricing v3 workaround part1
|
||||
const status = await ocean.OceanDispenser.status(dataTokenAddress)
|
||||
if (!status?.minterApproved) return
|
||||
|
||||
const response = await ocean.OceanDispenser.cancelMinter(
|
||||
dataTokenAddress,
|
||||
accountId
|
||||
)
|
||||
if (!response) {
|
||||
setError('Updating DDO failed.')
|
||||
Logger.error('Failed at cancelMinter')
|
||||
}
|
||||
return response
|
||||
// const status = await ocean.OceanDispenser.status(dataTokenAddress)
|
||||
// if (!status?.minterApproved) return
|
||||
// const response = await ocean.OceanDispenser.cancelMinter(
|
||||
// dataTokenAddress,
|
||||
// accountId
|
||||
// )
|
||||
// if (!response) {
|
||||
// setError('Updating DDO failed.')
|
||||
// LoggerInstance.error('Failed at cancelMinter')
|
||||
// }
|
||||
// return response
|
||||
return null
|
||||
}
|
||||
|
||||
export async function setMinterToDispenser(
|
||||
ocean: Ocean,
|
||||
dataTokenAddress: string,
|
||||
accountId: string,
|
||||
setError: (msg: string) => void
|
||||
): Promise<TransactionReceipt> {
|
||||
// free pricing v3 workaround part2
|
||||
const response = await ocean.OceanDispenser.makeMinter(
|
||||
dataTokenAddress,
|
||||
accountId
|
||||
)
|
||||
if (!response) {
|
||||
setError('Updating DDO failed.')
|
||||
Logger.error('Failed at makeMinter')
|
||||
}
|
||||
return response
|
||||
// const response = await ocean.OceanDispenser.makeMinter(
|
||||
// dataTokenAddress,
|
||||
// accountId
|
||||
// )
|
||||
// if (!response) {
|
||||
// setError('Updating DDO failed.')
|
||||
// LoggerInstance.error('Failed at makeMinter')
|
||||
// }
|
||||
// return response
|
||||
|
||||
return null
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { ConfigHelper, ConfigHelperConfig, Logger } from '@oceanprotocol/lib'
|
||||
import contractAddresses from '@oceanprotocol/contracts/artifacts/address.json'
|
||||
import { ConfigHelper, LoggerInstance, Config } from '@oceanprotocol/lib'
|
||||
// import contractAddresses from '@oceanprotocol/contracts/artifacts/address.json'
|
||||
import { AbiItem } from 'web3-utils/types'
|
||||
import Web3 from 'web3'
|
||||
|
||||
export function getOceanConfig(network: string | number): ConfigHelperConfig {
|
||||
export function getOceanConfig(network: string | number): Config {
|
||||
const config = new ConfigHelper().getConfig(
|
||||
network,
|
||||
network === 'polygon' ||
|
||||
@ -15,20 +15,20 @@ export function getOceanConfig(network: string | number): ConfigHelperConfig {
|
||||
network === 2021000
|
||||
? undefined
|
||||
: process.env.NEXT_PUBLIC_INFURA_PROJECT_ID
|
||||
) as ConfigHelperConfig
|
||||
return config as ConfigHelperConfig
|
||||
) as Config
|
||||
return config as Config
|
||||
}
|
||||
|
||||
export function getDevelopmentConfig(): Partial<ConfigHelperConfig> {
|
||||
export function getDevelopmentConfig(): Config {
|
||||
return {
|
||||
factoryAddress: contractAddresses.development?.DTFactory,
|
||||
poolFactoryAddress: contractAddresses.development?.BFactory,
|
||||
fixedRateExchangeAddress: contractAddresses.development?.FixedRateExchange,
|
||||
metadataContractAddress: contractAddresses.development?.Metadata,
|
||||
oceanTokenAddress: contractAddresses.development?.Ocean,
|
||||
// factoryAddress: contractAddresses.development?.DTFactory,
|
||||
// poolFactoryAddress: contractAddresses.development?.BFactory,
|
||||
// fixedRateExchangeAddress: contractAddresses.development?.FixedRateExchange,
|
||||
// metadataContractAddress: contractAddresses.development?.Metadata,
|
||||
// oceanTokenAddress: contractAddresses.development?.Ocean,
|
||||
// There is no subgraph in barge so we hardcode the Rinkeby one for now
|
||||
subgraphUri: 'https://subgraph.rinkeby.oceanprotocol.com'
|
||||
}
|
||||
} as Config
|
||||
}
|
||||
|
||||
export async function getOceanBalance(
|
||||
@ -69,6 +69,6 @@ export async function getOceanBalance(
|
||||
)
|
||||
return result
|
||||
} catch (e) {
|
||||
Logger.error(`ERROR: Failed to get the balance: ${e.message}`)
|
||||
LoggerInstance.error(`ERROR: Failed to get the balance: ${e.message}`)
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ export default async function get3BoxProfile(
|
||||
)
|
||||
return
|
||||
|
||||
// Logger.log(`3Box profile found for ${accountId}`, response.data)
|
||||
// LoggerInstance.log(`3Box profile found for ${accountId}`, response.data)
|
||||
const profile = transformResponse(response.data)
|
||||
return profile
|
||||
// eslint-disable-next-line no-empty
|
||||
|
@ -1,5 +1,5 @@
|
||||
import axios, { CancelToken, AxiosResponse } from 'axios'
|
||||
import { DID, Logger } from '@oceanprotocol/lib'
|
||||
import { DID, LoggerInstance } from '@oceanprotocol/lib'
|
||||
|
||||
export interface FileMetadata {
|
||||
index: number
|
||||
@ -50,9 +50,9 @@ export async function getFileInfo(
|
||||
return response.data
|
||||
} catch (error) {
|
||||
if (axios.isCancel(error)) {
|
||||
Logger.log(error.message)
|
||||
LoggerInstance.log(error.message)
|
||||
} else {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { gql, OperationResult, TypedDocumentNode, OperationContext } from 'urql'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import { getUrqlClientInstance } from '@context/UrqlProvider'
|
||||
import { getOceanConfig } from './ocean'
|
||||
import {
|
||||
@ -702,7 +702,7 @@ export async function getUserTokenOrders(
|
||||
|
||||
return data
|
||||
} catch (error) {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
@ -725,7 +725,7 @@ export async function getUserSales(
|
||||
}
|
||||
return salesSum
|
||||
} catch (error) {
|
||||
Logger.log(error.message)
|
||||
LoggerInstance.log(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { getNetworkDisplayName } from '@hooks/useNetworkMetadata'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import { getOceanConfig } from './ocean'
|
||||
|
||||
export function accountTruncate(account: string): string {
|
||||
@ -41,25 +41,27 @@ export async function addCustomNetwork(
|
||||
},
|
||||
(err: string, added: any) => {
|
||||
if (err || 'error' in added) {
|
||||
Logger.error(
|
||||
LoggerInstance.error(
|
||||
`Couldn't add ${network.name} (0x${
|
||||
network.chainId
|
||||
}) network to MetaMask, error: ${err || added.error}`
|
||||
)
|
||||
} else {
|
||||
Logger.log(
|
||||
LoggerInstance.log(
|
||||
`Added ${network.name} (0x${network.chainId}) network to MetaMask`
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
} else {
|
||||
Logger.error(
|
||||
LoggerInstance.error(
|
||||
`Couldn't add ${network.name} (0x${network.chainId}) network to MetaMask, error: ${switchError}`
|
||||
)
|
||||
}
|
||||
}
|
||||
Logger.log(`Added ${network.name} (0x${network.chainId}) network to MetaMask`)
|
||||
LoggerInstance.log(
|
||||
`Added ${network.name} (0x${network.chainId}) network to MetaMask`
|
||||
)
|
||||
}
|
||||
|
||||
export async function addTokenToWallet(
|
||||
@ -85,13 +87,13 @@ export async function addTokenToWallet(
|
||||
},
|
||||
(err: { code: number; message: string }, added: any) => {
|
||||
if (err || 'error' in added) {
|
||||
Logger.error(
|
||||
LoggerInstance.error(
|
||||
`Couldn't add ${tokenMetadata.options.symbol} (${
|
||||
tokenMetadata.options.address
|
||||
}) to MetaMask, error: ${err.message || added.error}`
|
||||
)
|
||||
} else {
|
||||
Logger.log(
|
||||
LoggerInstance.log(
|
||||
`Added ${tokenMetadata.options.symbol} (${tokenMetadata.options.address}) to MetaMask`
|
||||
)
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import { FormikProps, connect } from 'formik'
|
||||
import debounce from 'lodash.debounce'
|
||||
import omit from 'lodash.omit'
|
||||
import isEqual from 'react-fast-compare'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
|
||||
export interface PersistProps {
|
||||
name: string
|
||||
@ -23,7 +23,7 @@ class PersistImpl extends React.Component<
|
||||
|
||||
saveForm = debounce((data: FormikProps<any>) => {
|
||||
const dataToSave = this.omitIgnoredFields(data)
|
||||
Logger.log('data to save', dataToSave)
|
||||
LoggerInstance.log('data to save', dataToSave)
|
||||
if (this.props.isSessionStorage) {
|
||||
window.sessionStorage.setItem(this.props.name, JSON.stringify(dataToSave))
|
||||
} else {
|
||||
@ -33,10 +33,10 @@ class PersistImpl extends React.Component<
|
||||
|
||||
omitIgnoredFields = (data: FormikProps<any>) => {
|
||||
const { ignoreFields } = this.props
|
||||
Logger.log('omitted fields', ignoreFields)
|
||||
LoggerInstance.log('omitted fields', ignoreFields)
|
||||
const { values, touched, errors } = data
|
||||
|
||||
Logger.log('values', values, omit(values, ignoreFields))
|
||||
LoggerInstance.log('values', values, omit(values, ignoreFields))
|
||||
return ignoreFields
|
||||
? omit(
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ import { retrieveDDOListByDIDs } from '@utils/aquarius'
|
||||
import { CancelToken } from 'axios'
|
||||
import Title from './Title'
|
||||
import styles from './index.module.css'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import { useCancelToken } from '@hooks/useCancelToken'
|
||||
|
||||
const REFETCH_INTERVAL = 20000
|
||||
@ -217,7 +217,10 @@ export default function PoolTransactions({
|
||||
}, REFETCH_INTERVAL)
|
||||
setDataFetchInterval(interval)
|
||||
} catch (error) {
|
||||
Logger.error('Error fetching pool transactions: ', error.message)
|
||||
LoggerInstance.error(
|
||||
'Error fetching pool transactions: ',
|
||||
error.message
|
||||
)
|
||||
}
|
||||
}
|
||||
getTransactions()
|
||||
@ -237,7 +240,10 @@ export default function PoolTransactions({
|
||||
setIsLoading(true)
|
||||
await getPoolTransactions(cancelToken())
|
||||
} catch (error) {
|
||||
Logger.error('Error fetching pool transactions: ', error.message)
|
||||
LoggerInstance.error(
|
||||
'Error fetching pool transactions: ',
|
||||
error.message
|
||||
)
|
||||
}
|
||||
}
|
||||
transformData()
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { useState, ReactElement, useEffect, useCallback } from 'react'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import { toast } from 'react-toastify'
|
||||
import Price from '@shared/Price'
|
||||
import FileIcon from '@shared/FileIcon'
|
||||
@ -264,13 +264,13 @@ export default function Compute({
|
||||
// computeService.index,
|
||||
// computeAlgorithm
|
||||
// )
|
||||
// Logger.log('[compute] Is data set orderable?', allowed)
|
||||
// LoggerInstance.log('[compute] Is data set orderable?', allowed)
|
||||
|
||||
// if (!allowed) {
|
||||
// setError(
|
||||
// 'Data set is not orderable in combination with selected algorithm.'
|
||||
// )
|
||||
// Logger.error(
|
||||
// LoggerInstance.error(
|
||||
// '[compute] Error starting compute job. Dataset is not orderable in combination with selected algorithm.'
|
||||
// )
|
||||
// return
|
||||
@ -280,7 +280,7 @@ export default function Compute({
|
||||
// const tx = await buyDT('1', price, ddo)
|
||||
// if (!tx) {
|
||||
// setError('Error buying datatoken.')
|
||||
// Logger.error('[compute] Error buying datatoken for data set ', ddo.id)
|
||||
// LoggerInstance.error('[compute] Error buying datatoken for data set ', ddo.id)
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
@ -289,7 +289,7 @@ export default function Compute({
|
||||
// const tx = await buyDT('1', algorithmPrice, selectedAlgorithmAsset)
|
||||
// if (!tx) {
|
||||
// setError('Error buying datatoken.')
|
||||
// Logger.error(
|
||||
// LoggerInstance.error(
|
||||
// '[compute] Error buying datatoken for algorithm ',
|
||||
// selectedAlgorithmAsset.id
|
||||
// )
|
||||
@ -318,7 +318,7 @@ export default function Compute({
|
||||
// )
|
||||
|
||||
// assetOrderId &&
|
||||
// Logger.log(
|
||||
// LoggerInstance.log(
|
||||
// `[compute] Got ${
|
||||
// hasPreviousDatasetOrder ? 'existing' : 'new'
|
||||
// } order ID for dataset: `,
|
||||
@ -339,7 +339,7 @@ export default function Compute({
|
||||
// )
|
||||
|
||||
// algorithmAssetOrderId &&
|
||||
// Logger.log(
|
||||
// LoggerInstance.log(
|
||||
// `[compute] Got ${
|
||||
// hasPreviousAlgorithmOrder ? 'existing' : 'new'
|
||||
// } order ID for algorithm: `,
|
||||
@ -352,7 +352,7 @@ export default function Compute({
|
||||
// }
|
||||
|
||||
// computeAlgorithm.transferTxId = algorithmAssetOrderId
|
||||
// Logger.log('[compute] Starting compute job.')
|
||||
// LoggerInstance.log('[compute] Starting compute job.')
|
||||
|
||||
// const output: ComputeOutput = {
|
||||
// publishAlgorithmLog: true,
|
||||
@ -374,7 +374,7 @@ export default function Compute({
|
||||
// return
|
||||
// }
|
||||
|
||||
// Logger.log('[compute] Starting compute job response: ', response)
|
||||
// LoggerInstance.log('[compute] Starting compute job response: ', response)
|
||||
|
||||
// await checkPreviousOrders(selectedAlgorithmAsset)
|
||||
// await checkPreviousOrders(ddo)
|
||||
@ -383,7 +383,7 @@ export default function Compute({
|
||||
// await checkPreviousOrders(selectedAlgorithmAsset)
|
||||
// await checkPreviousOrders(ddo)
|
||||
// setError('Failed to start job!')
|
||||
// Logger.error('[compute] Failed to start job: ', error.message)
|
||||
// LoggerInstance.error('[compute] Failed to start job: ', error.message)
|
||||
// } finally {
|
||||
// setIsJobStarting(false)
|
||||
// }
|
||||
|
@ -14,7 +14,7 @@ import { useUserPreferences } from '@context/UserPreferences'
|
||||
import useDarkMode from 'use-dark-mode'
|
||||
import { darkModeConfig } from '../../../../../app.config'
|
||||
import Button from '@shared/atoms/Button'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import { useAsset } from '@context/Asset'
|
||||
import { gql, OperationResult } from 'urql'
|
||||
import { PoolHistory } from '../../../../@types/apollo/PoolHistory'
|
||||
@ -173,7 +173,7 @@ export default function Graph(): ReactElement {
|
||||
}, [graphFetchInterval])
|
||||
|
||||
useEffect(() => {
|
||||
Logger.log('Fired GraphOptions!')
|
||||
LoggerInstance.log('Fired GraphOptions!')
|
||||
const options = getOptions(locale, darkMode.value)
|
||||
setOptions(options)
|
||||
}, [locale, darkMode.value])
|
||||
@ -189,7 +189,7 @@ export default function Graph(): ReactElement {
|
||||
await getPoolHistory()
|
||||
return
|
||||
}
|
||||
Logger.log('Fired GraphData!')
|
||||
LoggerInstance.log('Fired GraphData!')
|
||||
|
||||
const latestTimestamps = [
|
||||
...timestamps,
|
||||
|
@ -10,7 +10,7 @@ import styles from './Remove.module.css'
|
||||
import Header from './Header'
|
||||
import { toast } from 'react-toastify'
|
||||
import Actions from './Actions'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import Token from './Token'
|
||||
import FormHelp from '@shared/FormInput/Help'
|
||||
import Button from '@shared/atoms/Button'
|
||||
@ -79,7 +79,7 @@ export default function Remove({
|
||||
setTxId(result?.transactionHash)
|
||||
refreshInfo()
|
||||
} catch (error) {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
toast.error(error.message)
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { ReactElement, useEffect, useState } from 'react'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import styles from './index.module.css'
|
||||
import stylesActions from './Actions.module.css'
|
||||
import PriceUnit from '@shared/Price/PriceUnit'
|
||||
@ -334,7 +334,7 @@ export default function Pool(): ReactElement {
|
||||
|
||||
setUserLiquidity(userLiquidity)
|
||||
} catch (error) {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
}
|
||||
}
|
||||
init()
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { ReactElement, useState } from 'react'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import * as Yup from 'yup'
|
||||
import { Formik } from 'formik'
|
||||
import Actions from '../Pool/Actions'
|
||||
@ -91,7 +91,7 @@ export default function FormTrade({
|
||||
)
|
||||
setTxId(tx?.transactionHash)
|
||||
} catch (error) {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
toast.error(error.message)
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React, { ReactElement, useState, useEffect } from 'react'
|
||||
import Compute from './Compute'
|
||||
import Consume from './Consume'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import Tabs, { TabsItem } from '@shared/atoms/Tabs'
|
||||
import { compareAsBN } from '@utils/numbers'
|
||||
import Pool from './Pool'
|
||||
@ -79,7 +79,7 @@ export default function AssetActions({
|
||||
fileInfoResponse && setFileMetadata(fileInfoResponse[0])
|
||||
setFileIsLoading(false)
|
||||
} catch (error) {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
}
|
||||
}
|
||||
initFileInfo()
|
||||
@ -96,7 +96,7 @@ export default function AssetActions({
|
||||
)
|
||||
setDtBalance(dtBalance)
|
||||
} catch (e) {
|
||||
Logger.error(e.message)
|
||||
LoggerInstance.error(e.message)
|
||||
}
|
||||
}
|
||||
init()
|
||||
|
@ -4,7 +4,7 @@ import { Formik } from 'formik'
|
||||
import React, { ReactElement, useState } from 'react'
|
||||
import { useAsset } from '@context/Asset'
|
||||
import FormEditComputeDataset from './FormEditComputeDataset'
|
||||
import { Logger, ServiceComputePrivacy } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance, ServiceComputePrivacy } from '@oceanprotocol/lib'
|
||||
import { useUserPreferences } from '@context/UserPreferences'
|
||||
import DebugEditCompute from './DebugEditCompute'
|
||||
import styles from './index.module.css'
|
||||
@ -53,7 +53,7 @@ export default function EditComputeDataset({
|
||||
// )
|
||||
// if (!ddoEditedComputePrivacy) {
|
||||
// setError(content.form.error)
|
||||
// Logger.error(content.form.error)
|
||||
// LoggerInstance.error(content.form.error)
|
||||
// return
|
||||
// }
|
||||
// const storedddo = await ocean.assets.updateMetadata(
|
||||
@ -62,7 +62,7 @@ export default function EditComputeDataset({
|
||||
// )
|
||||
// if (!storedddo) {
|
||||
// setError(content.form.error)
|
||||
// Logger.error(content.form.error)
|
||||
// LoggerInstance.error(content.form.error)
|
||||
// return
|
||||
// } else {
|
||||
// if (price.type === 'free') {
|
||||
@ -79,7 +79,7 @@ export default function EditComputeDataset({
|
||||
// resetForm()
|
||||
// }
|
||||
// } catch (error) {
|
||||
// Logger.error(error.message)
|
||||
// LoggerInstance.error(error.message)
|
||||
// setError(error.message)
|
||||
// }
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import Web3Feedback from '@shared/Web3Feedback'
|
||||
import FormEditMetadata from './FormEditMetadata'
|
||||
import { getServiceByName, mapTimeoutStringToSeconds } from '@utils/ddo'
|
||||
import styles from './index.module.css'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import { useWeb3 } from '@context/Web3'
|
||||
import { useOcean } from '@context/Ocean'
|
||||
import { setMinterToDispenser, setMinterToPublisher } from '@utils/freePrice'
|
||||
@ -41,7 +41,7 @@ export default function Edit({
|
||||
)
|
||||
if (!setPriceResp) {
|
||||
setError(content.form.error)
|
||||
Logger.error(content.form.error)
|
||||
LoggerInstance.error(content.form.error)
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ export default function Edit({
|
||||
// (await updateFixedPrice(values.price))
|
||||
// if (!ddoEditedMetdata) {
|
||||
// setError(content.form.error)
|
||||
// Logger.error(content.form.error)
|
||||
// LoggerInstance.error(content.form.error)
|
||||
// return
|
||||
// }
|
||||
// let ddoEditedTimeout = ddoEditedMetdata
|
||||
@ -88,7 +88,7 @@ export default function Edit({
|
||||
// }
|
||||
// if (!ddoEditedTimeout) {
|
||||
// setError(content.form.error)
|
||||
// Logger.error(content.form.error)
|
||||
// LoggerInstance.error(content.form.error)
|
||||
// return
|
||||
// }
|
||||
// const storedddo = await ocean.assets.updateMetadata(
|
||||
@ -97,7 +97,7 @@ export default function Edit({
|
||||
// )
|
||||
// if (!storedddo) {
|
||||
// setError(content.form.error)
|
||||
// Logger.error(content.form.error)
|
||||
// LoggerInstance.error(content.form.error)
|
||||
// return
|
||||
// } else {
|
||||
// if (price.type === 'free') {
|
||||
@ -114,7 +114,7 @@ export default function Edit({
|
||||
// resetForm()
|
||||
// }
|
||||
// } catch (error) {
|
||||
// Logger.error(error.message)
|
||||
// LoggerInstance.error(error.message)
|
||||
// setError(error.message)
|
||||
// }
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import { useSiteMetadata } from '@hooks/useSiteMetadata'
|
||||
import useNetworkMetadata, {
|
||||
filterNetworksByType
|
||||
} from '@hooks/useNetworkMetadata'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import styles from './MarketStats.module.css'
|
||||
|
||||
const getTotalPoolsValues = gql`
|
||||
@ -144,7 +144,7 @@ export default function MarketStats(): ReactElement {
|
||||
newTotalOceanLiquiditySum += parseInt(totalOceanLiquidity)
|
||||
newPoolCountSum += parseInt(finalizedPoolCount)
|
||||
} catch (error) {
|
||||
Logger.error('Error fetchData: ', error.message)
|
||||
LoggerInstance.error('Error fetchData: ', error.message)
|
||||
}
|
||||
}
|
||||
setTotalValueLockedSum(`${newTotalValueLockedSum}`)
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { useUserPreferences } from '@context/UserPreferences'
|
||||
import React, { ReactElement, useEffect, useState, useCallback } from 'react'
|
||||
import Table from '@shared/atoms/Table'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import Price from '@shared/Price'
|
||||
import Tooltip from '@shared/atoms/Tooltip'
|
||||
import AssetTitle from '@shared/AssetList/AssetListTitle'
|
||||
@ -64,7 +64,7 @@ export default function Bookmarks(): ReactElement {
|
||||
)
|
||||
return result
|
||||
} catch (error) {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
}
|
||||
},
|
||||
[]
|
||||
@ -92,7 +92,7 @@ export default function Bookmarks(): ReactElement {
|
||||
)
|
||||
setPinned(pinnedAssets)
|
||||
} catch (error) {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
}
|
||||
|
||||
setIsLoading(false)
|
||||
|
@ -8,7 +8,7 @@ import {
|
||||
queryMetadata
|
||||
} from '@utils/aquarius'
|
||||
import { getHighestLiquidityDatatokens } from '@utils/subgraph'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import { useUserPreferences } from '@context/UserPreferences'
|
||||
import styles from './index.module.css'
|
||||
import { useIsMounted } from '@hooks/useIsMounted'
|
||||
@ -82,7 +82,7 @@ function SectionQueryResult({
|
||||
setResult(result)
|
||||
setLoading(false)
|
||||
} catch (error) {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import React, { useEffect, useState, ReactElement } from 'react'
|
||||
import { useUserPreferences } from '@context/UserPreferences'
|
||||
import {
|
||||
@ -63,7 +63,7 @@ export default function Stats({
|
||||
)
|
||||
setPublisherLiquidity(userLiquidity)
|
||||
} catch (error) {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
}
|
||||
}
|
||||
getPublisherLiquidity()
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import React, { ReactElement, useState } from 'react'
|
||||
import Loader from '@shared/atoms/Loader'
|
||||
import { ListItem } from '@shared/atoms/Lists'
|
||||
@ -35,7 +35,7 @@ export default function Results({
|
||||
job.resultsUrl = jobStatus[0].resultsUrl
|
||||
}
|
||||
} catch (error) {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
setHasFetched(true)
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React, { ReactElement, useEffect, useState, useCallback } from 'react'
|
||||
import Time from '@shared/atoms/Time'
|
||||
import Link from 'next/link'
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import Dotdotdot from 'react-dotdotdot'
|
||||
import Table from '@shared/atoms/Table'
|
||||
import Button from '@shared/atoms/Button'
|
||||
@ -107,7 +107,7 @@ export default function ComputeJobs({
|
||||
isMounted() && setJobs(jobs.computeJobs)
|
||||
setIsLoading(jobs.isLoaded)
|
||||
} catch (error) {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
}
|
||||
}, [chainIds, accountId, config, ocean, account, ddo, isMounted])
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import React, { ReactElement, useEffect, useState, useCallback } from 'react'
|
||||
import AssetList from '@shared/AssetList'
|
||||
import { getPublishedAssets } from '@utils/aquarius'
|
||||
@ -37,7 +37,7 @@ export default function PublishedList({
|
||||
)
|
||||
setQueryResult(result)
|
||||
} catch (error) {
|
||||
Logger.error(error.message)
|
||||
LoggerInstance.error(error.message)
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Logger } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import {
|
||||
generateBaseQuery,
|
||||
getFilterTerm,
|
||||
@ -199,7 +199,7 @@ export async function addExistingParamsToUrl(
|
||||
for (const querryParam in parsed) {
|
||||
if (!excludedParams.includes(querryParam)) {
|
||||
if (querryParam === 'page' && excludedParams.includes('text')) {
|
||||
Logger.log('remove page when starting a new search')
|
||||
LoggerInstance.log('remove page when starting a new search')
|
||||
} else {
|
||||
const value = parsed[querryParam]
|
||||
urlLocation = `${urlLocation}${querryParam}=${value}&`
|
||||
|
Loading…
Reference in New Issue
Block a user