Skip to content

Commit

Permalink
Merge branch 'hotfix/validate-coingecko-ids' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
trungbach committed Sep 12, 2024
2 parents b2d604c + 0c3415c commit 34a8405
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 34a8405

Please sign in to comment.