From af7233d32ebf1ce9d08ea7f5ad65bfb941785af1 Mon Sep 17 00:00:00 2001 From: Anukul Pandey Date: Sun, 29 Sep 2024 23:13:06 +0530 Subject: [PATCH 1/2] fix: pools icon --- src/hooks/usePoolLists.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/hooks/usePoolLists.ts b/src/hooks/usePoolLists.ts index 05fbe98..729bf9f 100644 --- a/src/hooks/usePoolLists.ts +++ b/src/hooks/usePoolLists.ts @@ -142,6 +142,14 @@ export const usePoolsList = ({ handleResp(); }, [limit, offset,search,signerAddress]); + const getReefInfuraUrl = (url:string)=>{ + if(!url)return url; + if(url.includes("cloudflare-ipfs.com")){ + return url.replace("cloudflare-ipfs.com","reef.infura-ipfs.io") + } + return url; + } + const userPoolCountQry = getUserPoolCountQry(queryType, search, signerAddress); useEffect(() => { const handleResp = async (): Promise => { @@ -188,12 +196,12 @@ export const usePoolsList = ({ const mappedPools = poolsList.map((pool) => ({ address: pool.id, token1: { - image: !pool.iconUrl1 ? mergedTokenIconsMap[pool.token1]??getIconUrl(pool.token1) : pool.iconUrl1, + image: !pool.iconUrl1 ? getReefInfuraUrl(mergedTokenIconsMap[pool.token1])??getReefInfuraUrl(getIconUrl(pool.token1)) : getReefInfuraUrl(pool.iconUrl1), name: pool.name1, address:pool.token1 }, token2: { - image: !pool.iconUrl2 ? mergedTokenIconsMap[pool.token2]??getIconUrl(pool.token2) : pool.iconUrl2, + image: !pool.iconUrl2 ? getReefInfuraUrl(mergedTokenIconsMap[pool.token2])??getReefInfuraUrl(getIconUrl(pool.token2)) : getReefInfuraUrl(pool.iconUrl2), name: pool.name2, address:pool.token2 }, @@ -203,11 +211,14 @@ export const usePoolsList = ({ myLiquidity: calculateUserLiquidity(pool, tokenPrices), })); + return queryType === 'User' ? mappedPools.filter(pool => pool.myLiquidity && new BigNumber(pool.myLiquidity).isGreaterThan(0.1)) : mappedPools; + }, [dataPoolsList,tokenIconsMap]); + let count = 0; if (dataPoolsCount) { From 37ed521d5eccefa0625b317f52e07c8b994dbf1d Mon Sep 17 00:00:00 2001 From: Anukul Pandey Date: Mon, 30 Sep 2024 00:07:16 +0530 Subject: [PATCH 2/2] feat: get reef-infura io --- src/hooks/usePoolLists.ts | 20 ++++++++++---------- src/hooks/usePoolStats.ts | 5 +++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/hooks/usePoolLists.ts b/src/hooks/usePoolLists.ts index 729bf9f..b7a3a5f 100644 --- a/src/hooks/usePoolLists.ts +++ b/src/hooks/usePoolLists.ts @@ -77,6 +77,14 @@ const calculateVolumeChange = (pool: PoolListItem, tokenPrices: TokenPrices): nu return res.toNumber(); }; +export const getReefInfuraUrl = (url:string)=>{ + if(!url)return url; + if(url.includes("cloudflare-ipfs.com")){ + return url.replace("cloudflare-ipfs.com","reef.infura-ipfs.io") + } + return url; +} + const calculateUSDTVL = ({ reserved1, reserved2, @@ -142,14 +150,6 @@ export const usePoolsList = ({ handleResp(); }, [limit, offset,search,signerAddress]); - const getReefInfuraUrl = (url:string)=>{ - if(!url)return url; - if(url.includes("cloudflare-ipfs.com")){ - return url.replace("cloudflare-ipfs.com","reef.infura-ipfs.io") - } - return url; - } - const userPoolCountQry = getUserPoolCountQry(queryType, search, signerAddress); useEffect(() => { const handleResp = async (): Promise => { @@ -196,12 +196,12 @@ export const usePoolsList = ({ const mappedPools = poolsList.map((pool) => ({ address: pool.id, token1: { - image: !pool.iconUrl1 ? getReefInfuraUrl(mergedTokenIconsMap[pool.token1])??getReefInfuraUrl(getIconUrl(pool.token1)) : getReefInfuraUrl(pool.iconUrl1), + image: getReefInfuraUrl(!pool.iconUrl1 ? mergedTokenIconsMap[pool.token1]??getIconUrl(pool.token1) : pool.iconUrl1), name: pool.name1, address:pool.token1 }, token2: { - image: !pool.iconUrl2 ? getReefInfuraUrl(mergedTokenIconsMap[pool.token2])??getReefInfuraUrl(getIconUrl(pool.token2)) : getReefInfuraUrl(pool.iconUrl2), + image: getReefInfuraUrl(!pool.iconUrl2 ? mergedTokenIconsMap[pool.token2]??getIconUrl(pool.token2) : pool.iconUrl2), name: pool.name2, address:pool.token2 }, diff --git a/src/hooks/usePoolStats.ts b/src/hooks/usePoolStats.ts index 5c6ebea..d8535b7 100644 --- a/src/hooks/usePoolStats.ts +++ b/src/hooks/usePoolStats.ts @@ -19,6 +19,7 @@ import { graphqlRequest } from '../graphql/utils'; import { getIconUrl } from '../components/common/Icons'; import { useAsyncEffect } from './useAsyncEffect'; import { useObservableState } from './useObservableState'; +import { getReefInfuraUrl } from './usePoolLists'; const getPoolTotalValueLockedQry = (toTime: string): PoolQueryObject => ({ query: POOLS_TOTAL_VALUE_LOCKED, @@ -266,7 +267,7 @@ export const usePoolInfo = (address: string, signerAddress: string, tokenPrices: return { firstToken: { address: token1.id, - icon: token1.iconUrl === '' ? tokenIconsMap? tokenIconsMap[token1.id]: getIconUrl(token1.id) : token1.iconUrl, + icon: getReefInfuraUrl(token1.iconUrl === '' ? tokenIconsMap? tokenIconsMap[token1.id]: getIconUrl(token1.id) : token1.iconUrl), name: token1.name, symbol: token1.symbol, decimals: token1.decimals, @@ -282,7 +283,7 @@ export const usePoolInfo = (address: string, signerAddress: string, tokenPrices: }, secondToken: { address: token2.id, - icon: token2.iconUrl === '' ? tokenIconsMap? tokenIconsMap[token2.id]: getIconUrl(token2.id) : token2.iconUrl, + icon: getReefInfuraUrl(token2.iconUrl === '' ? tokenIconsMap? tokenIconsMap[token2.id]: getIconUrl(token2.id) : token2.iconUrl), name: token2.name, symbol: token2.symbol, decimals: token2.decimals,