Skip to content

Commit

Permalink
chore: Remove warnings and deprecated info graphql components
Browse files Browse the repository at this point in the history
  • Loading branch information
memoyil committed Jan 9, 2025
1 parent 0c91ab9 commit 15871ac
Show file tree
Hide file tree
Showing 14 changed files with 10 additions and 711 deletions.
20 changes: 1 addition & 19 deletions apps/web/src/config/constants/endpoints.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BLOCKS_SUBGRAPHS, ChainId, STABLESWAP_SUBGRAPHS, V2_SUBGRAPHS, V3_SUBGRAPHS } from '@pancakeswap/chains'
import { ChainId, V2_SUBGRAPHS, V3_SUBGRAPHS } from '@pancakeswap/chains'

export const THE_GRAPH_PROXY_API = 'https://thegraph.pancakeswap.com'

Expand All @@ -21,15 +21,6 @@ export const NOTIFICATION_HUB_BASE_URL = 'https://notification-hub.pancakeswap.c
*/
export const GRAPH_API_PREDICTION_V1 = `${THE_GRAPH_PROXY_API}/prediction-v1-bsc`

export const V3_BSC_INFO_CLIENT = `https://open-platform.nodereal.io/${
process.env.NEXT_PUBLIC_NODE_REAL_API_INFO || process.env.NEXT_PUBLIC_NODE_REAL_API_ETH
}/pancakeswap-v3/graphql`

const BLOCKS_SUBGRAPH_URLS = {
...BLOCKS_SUBGRAPHS,
[ChainId.OPBNB]: `${THE_GRAPH_PROXY_API}/blocks-opbnb`,
}

export const GRAPH_API_NFTMARKET = `${THE_GRAPH_PROXY_API}/nft-marketplace-bsc`
export const GRAPH_HEALTH = 'https://api.thegraph.com/index-node/graphql'

Expand All @@ -55,8 +46,6 @@ export const V2_SUBGRAPH_URLS = {
}
export const INFO_CLIENT_ETH = V2_SUBGRAPH_URLS[ChainId.ETHEREUM]

export const BLOCKS_CLIENT_WITH_CHAIN = BLOCKS_SUBGRAPH_URLS

export const ASSET_CDN = 'https://assets.pancakeswap.finance'

export const V3_SUBGRAPH_URLS = {
Expand All @@ -71,13 +60,6 @@ export const V3_SUBGRAPH_URLS = {
[ChainId.OPBNB]: `${THE_GRAPH_PROXY_API}/exchange-v3-opbnb`,
}

export const STABLESWAP_SUBGRAPHS_URLS = {
...STABLESWAP_SUBGRAPHS,
[ChainId.BSC]: `${THE_GRAPH_PROXY_API}/exchange-stableswap-bsc`,
[ChainId.ARBITRUM_ONE]: `${THE_GRAPH_PROXY_API}/exchange-stableswap-arb`,
[ChainId.ETHEREUM]: `${THE_GRAPH_PROXY_API}/exchange-stableswap-eth`,
}

export const TRADING_REWARD_API = 'https://trading-reward.pancakeswap.com/api/v1'

export const X_API_ENDPOINT = process.env.NEXT_PUBLIC_QUOTING_API
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/pages/v2/pair/[[...currency]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { useRouter } from 'next/router'
import { useAccount } from 'wagmi'
import { useAccountPositionDetailByPool } from 'state/farmsV4/state/accountPositions/hooks'
import { usePoolInfo } from 'state/farmsV4/state/extendPools/hooks'
import React, { useMemo } from 'react'
import { useMemo } from 'react'
import { formatFiatNumber } from '@pancakeswap/utils/formatFiatNumber'
import { useTotalPriceUSD } from 'hooks/useTotalPriceUSD'
import { useLPApr } from 'state/swap/useLPApr'
Expand Down
21 changes: 1 addition & 20 deletions apps/web/src/state/info/constant.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { GraphQLClient } from 'graphql-request'
import { infoStableSwapClients, v2Clients } from 'utils/graphql'

import { ChainId, isTestnetChainId } from '@pancakeswap/chains'
import { STABLE_SUPPORTED_CHAIN_IDS } from '@pancakeswap/stable-swap-sdk'
import { ChainId } from '@pancakeswap/chains'
import { BSC_TOKEN_WHITELIST, ETH_TOKEN_BLACKLIST, ETH_TOKEN_WHITELIST, TOKEN_BLACKLIST } from 'config/constants/info'
import mapValues from 'lodash/mapValues'
import { arbitrum, base, bsc, linea, mainnet, opBNB, polygonZkEvm, zkSync } from 'wagmi/chains'
Expand Down Expand Up @@ -60,11 +56,6 @@ export const multiChainPaths = {
[ChainId.OPBNB]: '/opbnb',
}

export const multiChainQueryStableClient = STABLE_SUPPORTED_CHAIN_IDS.reduce((acc, chainId) => {
if (isTestnetChainId(chainId)) return acc
return { ...acc, [multiChainName[chainId]]: infoStableSwapClients[chainId] }
}, {} as Record<MultiChainName, GraphQLClient>)

export const infoChainNameToExplorerChainName = {
BSC: 'bsc',
ETH: 'ethereum',
Expand All @@ -76,10 +67,6 @@ export const infoChainNameToExplorerChainName = {
OPBNB: 'opbnb',
} as const

export const STABLESWAP_SUBGRAPHS_START_BLOCK = {
ARB: 169319653,
}

export const multiChainScan: Record<MultiChainName, string> = {
BSC: bsc.blockExplorers.default.name,
ETH: mainnet.blockExplorers.default.name,
Expand Down Expand Up @@ -127,12 +114,6 @@ export const multiChainTokenWhiteList: Record<MultiChainName, string[]> = mapVal
(val) => val.map((address) => address.toLowerCase()),
)

export const getMultiChainQueryEndPointWithStableSwap = (chainName: MultiChainNameExtend): GraphQLClient => {
const isStableSwap = checkIsStableSwap()
if (isStableSwap) return multiChainQueryStableClient[chainName]
return v2Clients[multiChainId[chainName]]
}

export const subgraphTokenName = {
[ChainId.BSC]: {
'0x738d96Caf7096659DB4C1aFbf1E1BDFD281f388C': 'Ankr Staked MATIC',
Expand Down
16 changes: 2 additions & 14 deletions apps/web/src/state/info/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import { useCallback, useEffect, useMemo, useState } from 'react'
import { STABLE_SUPPORTED_CHAIN_IDS } from '@pancakeswap/stable-swap-sdk'
import { keepPreviousData, useQuery } from '@tanstack/react-query'
import BigNumber from 'bignumber.js'
import { fetchAllTokenDataByAddresses } from 'state/info/queries/tokens/tokenData'
import { Block, Transaction, TransactionType, TvlChartEntry, VolumeChartEntry } from 'state/info/types'
import { Transaction, TransactionType, TvlChartEntry, VolumeChartEntry } from 'state/info/types'
import { getAprsForStableFarm } from 'utils/getAprsForStableFarm'
import { getLpFeesAndApr } from 'utils/getLpFeesAndApr'
import { getPercentChange } from 'utils/infoDataHelpers'
import { explorerApiClient } from './api/client'
import { useExplorerChainNameByQuery } from './api/hooks'
import { operations } from './api/schema'
import { checkIsStableSwap, multiChainId, MultiChainName, MultiChainNameExtend } from './constant'
import { checkIsStableSwap, multiChainId, MultiChainName } from './constant'
import { PoolData, PriceChartEntry, ProtocolData, TokenData } from './types'

dayjs.extend(duration)
Expand Down Expand Up @@ -631,17 +630,6 @@ export const useAllTokenDataQuery = (): {
return data ?? {}
}

const graphPerPage = 50

const fetcher = (addresses: string[], chainName: MultiChainName, blocks: Block[]) => {
const times = Math.ceil(addresses.length / graphPerPage)
const addressGroup: Array<string[]> = []
for (let i = 0; i < times; i++) {
addressGroup.push(addresses.slice(i * graphPerPage, (i + 1) * graphPerPage))
}
return Promise.all(addressGroup.map((d) => fetchAllTokenDataByAddresses(chainName, blocks, d)))
}

export const useTokenDataQuery = (address: string | undefined): TokenData | undefined => {
const chainName = useExplorerChainNameByQuery()
const chainId = useChainIdByQuery()
Expand Down
215 changes: 0 additions & 215 deletions apps/web/src/state/info/queries/tokens/tokenData.ts

This file was deleted.

Loading

0 comments on commit 15871ac

Please sign in to comment.