diff --git a/app/utils/coingecko.tsx b/app/utils/coingecko.tsx index b4aa64ab..59863dc9 100644 --- a/app/utils/coingecko.tsx +++ b/app/utils/coingecko.tsx @@ -1,6 +1,9 @@ import React from 'react'; import useTabVisibility from 'use-tab-visibility'; +import { useCluster } from '../providers/cluster'; +import { Cluster } from './cluster'; + const PRICE_REFRESH = 10000; export enum CoingeckoStatus { @@ -43,6 +46,7 @@ export type CoinGeckoResult = { }; export function useCoinGecko(coinId?: string): CoinGeckoResult | undefined { + const { cluster } = useCluster() const [coinInfo, setCoinInfo] = React.useState(); const { visible: isTabVisible } = useTabVisibility(); React.useEffect(() => { @@ -52,6 +56,9 @@ export function useCoinGecko(coinId?: string): CoinGeckoResult | undefined { if (!isTabVisible) { return; } + if (cluster !== Cluster.MainnetBeta) { + return; + } let interval: NodeJS.Timeout | undefined; let stale = false; if (coinId) { @@ -64,14 +71,14 @@ export function useCoinGecko(coinId?: string): CoinGeckoResult | undefined { try { const response = await fetch( `https://api.coingecko.com/api/v3/coins/${coinId}?` + - [ - 'community_data=false', - 'developer_data=false', - 'localization=false', - 'market_data=true', - 'sparkline=false', - 'tickers=false', - ].join('&') + [ + 'community_data=false', + 'developer_data=false', + 'localization=false', + 'market_data=true', + 'sparkline=false', + 'tickers=false', + ].join('&') ); if (stale) { return; @@ -106,7 +113,7 @@ export function useCoinGecko(coinId?: string): CoinGeckoResult | undefined { } stale = true; }; - }, [coinId, isTabVisible]); + }, [coinId, isTabVisible, cluster]); return coinInfo; }