File tree 2 files changed +13
-11
lines changed
wormhole-connect/src/hooks
2 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -3,10 +3,6 @@ import { coalesceChainName } from '@certusone/wormhole-sdk';
3
3
import config from 'config' ;
4
4
import { useEffect , useState } from 'react' ;
5
5
6
- const VALID_CHAINS = config . chainsArr
7
- . filter ( ( chain ) => chain . key !== 'wormchain' )
8
- . map ( ( chain ) => chain . key ) ;
9
-
10
6
type ExternalSearch = {
11
7
hasExternalSearch : boolean ;
12
8
txHash ?: string ;
@@ -25,7 +21,12 @@ export function useExternalSearch(): ExternalSearch {
25
21
// eslint-disable-next-line @typescript-eslint/no-explicit-any
26
22
config . searchTx . chainName as any ,
27
23
) as ChainName ;
28
- if ( VALID_CHAINS . includes ( chainName ) ) {
24
+
25
+ const validChains = config . chainsArr
26
+ . filter ( ( chain ) => chain . key !== 'wormchain' )
27
+ . map ( ( chain ) => chain . key ) ;
28
+
29
+ if ( validChains . includes ( chainName ) ) {
29
30
setHasExternalSearchtate ( true ) ;
30
31
setTxHash ( config . searchTx . txHash ) ;
31
32
setChainName ( chainName ) ;
Original file line number Diff line number Diff line change @@ -8,17 +8,18 @@ const PRICES_FETCH_INTERVAL = 60000 * 5; // 5 mins
8
8
const COINGECKO_URL = 'https://api.coingecko.com/' ;
9
9
const COINGECKO_URL_PRO = 'https://pro-api.coingecko.com/' ;
10
10
11
- const COINGECKO_IDS = Object . values ( config . tokens )
12
- . filter ( ( config ) => ! ! config . coinGeckoId )
13
- . map ( ( { coinGeckoId } ) => coinGeckoId )
14
- . join ( ',' ) ;
15
-
16
11
export const useFetchTokenPrices = ( ) : void => {
17
12
const dispatch = useDispatch ( ) ;
18
13
useEffect ( ( ) => {
19
14
let cancelled = false ;
20
15
const controller = new AbortController ( ) ;
21
16
const signal = controller . signal ;
17
+
18
+ const coingeckoIds = Object . values ( config . tokens )
19
+ . filter ( ( config ) => ! ! config . coinGeckoId )
20
+ . map ( ( { coinGeckoId } ) => coinGeckoId )
21
+ . join ( ',' ) ;
22
+
22
23
const headers = new Headers ( {
23
24
'Content-Type' : 'application/json' ,
24
25
...( config . coinGeckoApiKey
@@ -33,7 +34,7 @@ export const useFetchTokenPrices = (): void => {
33
34
const res = await fetch (
34
35
`${
35
36
! config . coinGeckoApiKey ? COINGECKO_URL : COINGECKO_URL_PRO
36
- } api/v3/simple/price?ids=${ COINGECKO_IDS } &vs_currencies=usd${
37
+ } api/v3/simple/price?ids=${ coingeckoIds } &vs_currencies=usd${
37
38
! config . coinGeckoApiKey
38
39
? ''
39
40
: `?x_cg_pro_api_key=${ config . coinGeckoApiKey } `
You can’t perform that action at this time.
0 commit comments