Skip to content

Commit

Permalink
Only show CoinGecko information on Mainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
mcintyre94 committed Sep 19, 2023
1 parent b91b274 commit 326407e
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions app/utils/coingecko.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';
import useTabVisibility from 'use-tab-visibility';
import { useCluster } from '../providers/cluster';
import { Cluster } from './cluster';

const PRICE_REFRESH = 10000;

Expand Down Expand Up @@ -43,6 +45,7 @@ export type CoinGeckoResult = {
};

export function useCoinGecko(coinId?: string): CoinGeckoResult | undefined {
const { cluster } = useCluster()
const [coinInfo, setCoinInfo] = React.useState<CoinGeckoResult>();
const { visible: isTabVisible } = useTabVisibility();
React.useEffect(() => {
Expand All @@ -52,6 +55,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) {
Expand All @@ -64,14 +70,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;
Expand Down

0 comments on commit 326407e

Please sign in to comment.