mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
Fetching publisher orders from subgraph
This commit is contained in:
parent
b58cb36e00
commit
65df504f02
38214
package-lock.json
generated
38214
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -19,6 +19,7 @@ import axios, { CancelToken } from 'axios'
|
||||
import web3 from 'web3'
|
||||
import { useMarketMetadata } from '../MarketMetadata'
|
||||
import { getEnsProfile } from '@utils/ens'
|
||||
import { getPublisherOrders } from '../../@utils/subgraph'
|
||||
|
||||
interface ProfileProviderValue {
|
||||
profile: Profile
|
||||
@ -223,7 +224,12 @@ function ProfileProvider({
|
||||
try {
|
||||
const result = await getUserSales(accountId, chainIds)
|
||||
setSales(result)
|
||||
LoggerInstance.log(`[profile] Fetched sales number: ${result}.`, result)
|
||||
const graphData = await getPublisherOrders(137, accountId)
|
||||
LoggerInstance.log(`[profile] Fetched sales number:`, result)
|
||||
LoggerInstance.log(
|
||||
`[profile] Fetched sales Data: ${graphData}.`,
|
||||
graphData
|
||||
)
|
||||
} catch (error) {
|
||||
LoggerInstance.error(error.message)
|
||||
}
|
||||
|
@ -55,6 +55,17 @@ const OpcsApprovedTokensQuery = gql`
|
||||
}
|
||||
`
|
||||
|
||||
const publisherOrdersQuery = gql`
|
||||
query publisherOrdersQuery($user: ID!) {
|
||||
user(id: $user) {
|
||||
orders {
|
||||
lastPriceToken
|
||||
lastPriceValue
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export function getSubgraphUri(chainId: number): string {
|
||||
const config = getOceanConfig(chainId)
|
||||
return config.subgraphUri
|
||||
@ -172,3 +183,19 @@ export async function getOpcsApprovedTokens(
|
||||
throw Error(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
export async function getPublisherOrders(
|
||||
chainId: number,
|
||||
accountId: string
|
||||
): Promise<TokenInfo[]> {
|
||||
const context = getQueryContext(chainId)
|
||||
const variables = { user: accountId?.toLowerCase() }
|
||||
|
||||
try {
|
||||
const response = await fetchData(publisherOrdersQuery, variables, context)
|
||||
return response.data.user.orders
|
||||
} catch (error) {
|
||||
LoggerInstance.error('Error getOpcsApprovedTokens: ', error.message)
|
||||
throw Error(error.message)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user