mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
Getting orders from all networks
This commit is contained in:
parent
65df504f02
commit
343913663f
@ -20,6 +20,7 @@ import web3 from 'web3'
|
|||||||
import { useMarketMetadata } from '../MarketMetadata'
|
import { useMarketMetadata } from '../MarketMetadata'
|
||||||
import { getEnsProfile } from '@utils/ens'
|
import { getEnsProfile } from '@utils/ens'
|
||||||
import { getPublisherOrders } from '../../@utils/subgraph'
|
import { getPublisherOrders } from '../../@utils/subgraph'
|
||||||
|
import { PublisherOrders } from 'src/@types/subgraph/OrdersData'
|
||||||
|
|
||||||
interface ProfileProviderValue {
|
interface ProfileProviderValue {
|
||||||
profile: Profile
|
profile: Profile
|
||||||
@ -224,12 +225,17 @@ function ProfileProvider({
|
|||||||
try {
|
try {
|
||||||
const result = await getUserSales(accountId, chainIds)
|
const result = await getUserSales(accountId, chainIds)
|
||||||
setSales(result)
|
setSales(result)
|
||||||
const graphData = await getPublisherOrders(137, accountId)
|
const graphData = await getPublisherOrders(accountId)
|
||||||
LoggerInstance.log(`[profile] Fetched sales number:`, result)
|
let orderValue = 0
|
||||||
|
graphData.forEach((order) => {
|
||||||
|
orderValue += Number(order.lastPriceValue)
|
||||||
|
})
|
||||||
LoggerInstance.log(
|
LoggerInstance.log(
|
||||||
`[profile] Fetched sales Data: ${graphData}.`,
|
`[profile] Fetched sales number: ${result}.`,
|
||||||
graphData
|
result,
|
||||||
|
graphData.length
|
||||||
)
|
)
|
||||||
|
LoggerInstance.log(`[profile] Fetched sales orderValue:`, orderValue)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
LoggerInstance.error(error.message)
|
LoggerInstance.error(error.message)
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,10 @@ import { gql, OperationResult, TypedDocumentNode, OperationContext } from 'urql'
|
|||||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||||
import { getUrqlClientInstance } from '@context/UrqlProvider'
|
import { getUrqlClientInstance } from '@context/UrqlProvider'
|
||||||
import { getOceanConfig } from './ocean'
|
import { getOceanConfig } from './ocean'
|
||||||
import { OrdersData_orders as OrdersData } from '../@types/subgraph/OrdersData'
|
import {
|
||||||
|
OrdersData_orders as OrdersData,
|
||||||
|
PublisherOrders
|
||||||
|
} from '../@types/subgraph/OrdersData'
|
||||||
import { OpcFeesQuery as OpcFeesData } from '../@types/subgraph/OpcFeesQuery'
|
import { OpcFeesQuery as OpcFeesData } from '../@types/subgraph/OpcFeesQuery'
|
||||||
import appConfig from '../../app.config'
|
import appConfig from '../../app.config'
|
||||||
|
|
||||||
@ -185,15 +188,22 @@ export async function getOpcsApprovedTokens(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getPublisherOrders(
|
export async function getPublisherOrders(
|
||||||
chainId: number,
|
|
||||||
accountId: string
|
accountId: string
|
||||||
): Promise<TokenInfo[]> {
|
): Promise<PublisherOrders[]> {
|
||||||
const context = getQueryContext(chainId)
|
|
||||||
const variables = { user: accountId?.toLowerCase() }
|
const variables = { user: accountId?.toLowerCase() }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetchData(publisherOrdersQuery, variables, context)
|
const response = await fetchDataForMultipleChains(
|
||||||
return response.data.user.orders
|
publisherOrdersQuery,
|
||||||
|
variables,
|
||||||
|
[1, 137, 56, 246, 1285]
|
||||||
|
)
|
||||||
|
let data: PublisherOrders[] = []
|
||||||
|
response.forEach((element) => {
|
||||||
|
if (element.user.orders) {
|
||||||
|
data = data.concat(element.user.orders)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
LoggerInstance.error('Error getOpcsApprovedTokens: ', error.message)
|
LoggerInstance.error('Error getOpcsApprovedTokens: ', error.message)
|
||||||
throw Error(error.message)
|
throw Error(error.message)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user