diff --git a/src/components/AccountDrawer/MiniPortfolio/Pools/hooks.ts b/src/components/AccountDrawer/MiniPortfolio/Pools/hooks.ts index 2a42682b072..5d13cc59e45 100644 --- a/src/components/AccountDrawer/MiniPortfolio/Pools/hooks.ts +++ b/src/components/AccountDrawer/MiniPortfolio/Pools/hooks.ts @@ -12,7 +12,7 @@ import { isSupportedChain } from 'constants/chains' import { RPC_PROVIDERS } from 'constants/providers' import { BaseContract } from 'ethers/lib/ethers' import { useBaseEnabledChains } from 'featureFlags/flags/baseEnabled' -import { ContractInput, useUniswapPricesQuery } from 'graphql/data/__generated__/types-and-hooks' +import { ContractInput, UniswapPricesQuery } from 'graphql/data/__generated__/types-and-hooks' import { toContractInput } from 'graphql/data/util' import useStablecoinPrice from 'hooks/useStablecoinPrice' import { useMemo } from 'react' @@ -76,8 +76,10 @@ export function usePoolPriceMap(positions: PositionInfo[] | undefined) { return Object.values(contractMap) }, [positions]) - const { data, loading } = useUniswapPricesQuery({ variables: { contracts }, skip: !contracts.length }) - + //Update, until GQL chain support returning empty data + // const { data, loading } = useUniswapPricesQuery({ variables: { contracts }, skip: !contracts.length }) + const data: UniswapPricesQuery | undefined = {} + const loading = false const priceMap = useMemo( () => data?.tokens?.reduce((acc: PriceMap, current) => { diff --git a/src/components/AccountDrawer/PrefetchBalancesWrapper.tsx b/src/components/AccountDrawer/PrefetchBalancesWrapper.tsx index 87c38be7681..c86c507006c 100644 --- a/src/components/AccountDrawer/PrefetchBalancesWrapper.tsx +++ b/src/components/AccountDrawer/PrefetchBalancesWrapper.tsx @@ -1,6 +1,5 @@ import { useWeb3React } from '@web3-react/core' -import { usePortfolioBalancesLazyQuery, usePortfolioBalancesQuery } from 'graphql/data/__generated__/types-and-hooks' -import { GQL_MAINNET_CHAINS } from 'graphql/data/util' +import { PortfolioBalancesQuery, usePortfolioBalancesLazyQuery } from 'graphql/data/__generated__/types-and-hooks' import usePrevious from 'hooks/usePrevious' import { atom, useAtom } from 'jotai' import { PropsWithChildren, useCallback, useEffect, useMemo } from 'react' @@ -34,14 +33,17 @@ function useHasUpdatedTx(account: string | undefined) { ) }, [account, currentChainTxs, previousPendingTxs]) } - +// UPDATE: until GQL data support - returning empty object export function useCachedPortfolioBalancesQuery({ account }: { account?: string }) { - return usePortfolioBalancesQuery({ - skip: !account, - variables: { ownerAddress: account ?? '', chains: GQL_MAINNET_CHAINS }, - fetchPolicy: 'cache-only', // PrefetchBalancesWrapper handles balance fetching/staleness; this component only reads from cache - errorPolicy: 'all', - }) + const data: PortfolioBalancesQuery | undefined = {} + const loading = false + return { data, loading } + // return usePortfolioBalancesQuery({ + // skip: !account, + // variables: { ownerAddress: account ?? '', chains: GQL_MAINNET_CHAINS }, + // fetchPolicy: 'cache-only', // PrefetchBalancesWrapper handles balance fetching/staleness; this component only reads from cache + // errorPolicy: 'all', + // }) } const hasUnfetchedBalancesAtom = atom(true) @@ -58,7 +60,8 @@ export default function PrefetchBalancesWrapper({ const [hasUnfetchedBalances, setHasUnfetchedBalances] = useAtom(hasUnfetchedBalancesAtom) const fetchBalances = useCallback(() => { if (account) { - prefetchPortfolioBalances({ variables: { ownerAddress: account, chains: GQL_MAINNET_CHAINS } }) + // UPDATE: removing prefecth option until GQL chain support + // prefetchPortfolioBalances({ variables: { ownerAddress: account, chains: GQL_MAINNET_CHAINS } }) setHasUnfetchedBalances(false) } }, [account, prefetchPortfolioBalances, setHasUnfetchedBalances]) diff --git a/src/graphql/data/util.tsx b/src/graphql/data/util.tsx index 9cecfc76223..70508740767 100644 --- a/src/graphql/data/util.tsx +++ b/src/graphql/data/util.tsx @@ -90,7 +90,7 @@ export const CHAIN_ID_TO_BACKEND_NAME: { [key: number]: InterfaceGqlChain } = { export function chainIdToBackendName(chainId: number | undefined) { return chainId && CHAIN_ID_TO_BACKEND_NAME[chainId] ? CHAIN_ID_TO_BACKEND_NAME[chainId] - : CHAIN_ID_TO_BACKEND_NAME[ChainId.MAINNET] + : CHAIN_ID_TO_BACKEND_NAME[ChainId.HARMONY] } const GQL_CHAINS = [ChainId.MAINNET, ChainId.OPTIMISM, ChainId.POLYGON, ChainId.ARBITRUM_ONE, ChainId.CELO] as const @@ -184,7 +184,12 @@ export const BACKEND_SUPPORTED_CHAINS = [ Chain.Optimism, Chain.Celo, ] as const -export const BACKEND_NOT_YET_SUPPORTED_CHAIN_IDS = [ChainId.BNB, ChainId.AVALANCHE, ChainId.BASE, ChainId.HARMONY] as const +export const BACKEND_NOT_YET_SUPPORTED_CHAIN_IDS = [ + ChainId.BNB, + ChainId.AVALANCHE, + ChainId.BASE, + ChainId.HARMONY, +] as const export function getTokenDetailsURL({ address,