Skip to content

Commit

Permalink
move two more eval-time consts
Browse files Browse the repository at this point in the history
  • Loading branch information
artursapek committed Mar 11, 2024
1 parent 0a27ad1 commit 22cac09
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
11 changes: 6 additions & 5 deletions wormhole-connect/src/hooks/useExternalSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import { coalesceChainName } from '@certusone/wormhole-sdk';
import config from 'config';
import { useEffect, useState } from 'react';

const VALID_CHAINS = config.chainsArr
.filter((chain) => chain.key !== 'wormchain')
.map((chain) => chain.key);

type ExternalSearch = {
hasExternalSearch: boolean;
txHash?: string;
Expand All @@ -25,7 +21,12 @@ export function useExternalSearch(): ExternalSearch {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
config.searchTx.chainName as any,
) as ChainName;
if (VALID_CHAINS.includes(chainName)) {

const validChains = config.chainsArr
.filter((chain) => chain.key !== 'wormchain')
.map((chain) => chain.key);

if (validChains.includes(chainName)) {
setHasExternalSearchtate(true);
setTxHash(config.searchTx.txHash);
setChainName(chainName);
Expand Down
13 changes: 7 additions & 6 deletions wormhole-connect/src/hooks/useFetchTokenPrices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ const PRICES_FETCH_INTERVAL = 60000 * 5; // 5 mins
const COINGECKO_URL = 'https://api.coingecko.com/';
const COINGECKO_URL_PRO = 'https://pro-api.coingecko.com/';

const COINGECKO_IDS = Object.values(config.tokens)
.filter((config) => !!config.coinGeckoId)
.map(({ coinGeckoId }) => coinGeckoId)
.join(',');

export const useFetchTokenPrices = (): void => {
const dispatch = useDispatch();
useEffect(() => {
let cancelled = false;
const controller = new AbortController();
const signal = controller.signal;

const coingeckoIds = Object.values(config.tokens)
.filter((config) => !!config.coinGeckoId)
.map(({ coinGeckoId }) => coinGeckoId)
.join(',');

const headers = new Headers({
'Content-Type': 'application/json',
...(config.coinGeckoApiKey
Expand All @@ -33,7 +34,7 @@ export const useFetchTokenPrices = (): void => {
const res = await fetch(
`${
!config.coinGeckoApiKey ? COINGECKO_URL : COINGECKO_URL_PRO
}api/v3/simple/price?ids=${COINGECKO_IDS}&vs_currencies=usd${
}api/v3/simple/price?ids=${coingeckoIds}&vs_currencies=usd${
!config.coinGeckoApiKey
? ''
: `?x_cg_pro_api_key=${config.coinGeckoApiKey}`
Expand Down

0 comments on commit 22cac09

Please sign in to comment.