Skip to content

Commit

Permalink
Merge pull request #997 from oraichain/hotfix/validate-coingecko-ids
Browse files Browse the repository at this point in the history
fix: validate coingecko token
  • Loading branch information
haunv3 authored Sep 17, 2024
2 parents e6d86cd + 0c3415c commit 3f38967
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export const buildCoinGeckoPricesURL = tokens =>
`https://price.market.orai.io/simple/price?ids=${tokens.join("%2C")}&vs_currencies=usd`;

export const getCoingeckoPrices = async (tokens, cancelToken) => {
const coingeckoPricesURL = buildCoinGeckoPricesURL(tokens);
const uniqueTokens = [...new Set(tokens)];
const coingeckoPricesURL = buildCoinGeckoPricesURL(uniqueTokens);
return await axios.get(coingeckoPricesURL, { cancelToken });
};

Expand Down Expand Up @@ -106,8 +107,9 @@ export const getListOWContract = (address, page) => {

export const getGeckoMarketBalance = async (ids = "", currency = "usd") => {
// remove undefined
ids = ids.replace(new RegExp(",undefined", "gm"), "");
return ids ? await axios(`${consts.API_COINGECKO.PRICE(ids, currency)}`) : { data: {} };
let coingeckoIds = ids.replace(new RegExp(",undefined", "gm"), "");
coingeckoIds = [...new Set(coingeckoIds.split(","))].join(",");
return ids ? await axios(`${consts.API_COINGECKO.PRICE(coingeckoIds, currency)}`) : { data: {} };
};

export const getImagesValidator = async address => {
Expand Down

0 comments on commit 3f38967

Please sign in to comment.