mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
cleanup subgraph.ts code
This commit is contained in:
parent
ff06d91898
commit
120af82e18
@ -2,24 +2,9 @@ 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 { AssetPreviousOrder } from '../@types/subgraph/AssetPreviousOrder'
|
|
||||||
import { OrdersData_orders as OrdersData } from '../@types/subgraph/OrdersData'
|
import { OrdersData_orders as OrdersData } from '../@types/subgraph/OrdersData'
|
||||||
import { OpcFeesQuery as OpcFeesData } from '../@types/subgraph/OpcFeesQuery'
|
import { OpcFeesQuery as OpcFeesData } from '../@types/subgraph/OpcFeesQuery'
|
||||||
import { chainIdsSupported } from 'app.config'
|
import appConfig from 'app.config'
|
||||||
|
|
||||||
const PreviousOrderQuery = gql`
|
|
||||||
query AssetPreviousOrder($id: String!, $account: String!) {
|
|
||||||
orders(
|
|
||||||
first: 1
|
|
||||||
where: { datatoken: $id, payer: $account }
|
|
||||||
orderBy: createdTimestamp
|
|
||||||
orderDirection: desc
|
|
||||||
) {
|
|
||||||
createdTimestamp
|
|
||||||
tx
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
const UserTokenOrders = gql`
|
const UserTokenOrders = gql`
|
||||||
query OrdersData($user: String!) {
|
query OrdersData($user: String!) {
|
||||||
@ -77,8 +62,7 @@ export function getSubgraphUri(chainId: number): string {
|
|||||||
|
|
||||||
export function getQueryContext(chainId: number): OperationContext {
|
export function getQueryContext(chainId: number): OperationContext {
|
||||||
try {
|
try {
|
||||||
const isNetworkSupported = chainIdsSupported.includes(chainId)
|
if (!appConfig.chainIdsSupported.includes(chainId))
|
||||||
if (!isNetworkSupported)
|
|
||||||
throw Object.assign(
|
throw Object.assign(
|
||||||
new Error('network not supported, query context cancelled')
|
new Error('network not supported, query context cancelled')
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user