Skip to content

Commit

Permalink
bug/usd-amount-for-custom-tokens (#2416)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielisaacgeslin authored Aug 21, 2024
1 parent b859301 commit c5cefe3
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions wormhole-connect/src/hooks/useFetchTokenPrices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@ export const useFetchTokenPrices = (): void => {
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
? { 'x-cg-pro-api-key': config.coinGeckoApiKey }
: {}),
});
const fetchTokenPrices = async () => {
while (!cancelled) {
try {
/** arbitrary delay to read from config mutable object after all sync and react's async processes affecting config have been queued */
await sleep(10);
const headers = new Headers({
'Content-Type': 'application/json',
...(config.coinGeckoApiKey
? { 'x-cg-pro-api-key': config.coinGeckoApiKey }
: {}),
});
const coingeckoIds = Object.values(config.tokens)
.filter((config) => !!config.coinGeckoId)
.map(({ coinGeckoId }) => coinGeckoId)
.join(',');
// Make API call to fetch token prices
// In the case the user https://apiguide.coingecko.com/getting-started/getting-started#id-2.-making-api-request
const res = await fetch(
Expand Down

0 comments on commit c5cefe3

Please sign in to comment.