diff --git a/packages/app/src/components/Header/ConnectedAccountDisplay.tsx b/packages/app/src/components/Header/ConnectedAccountDisplay.tsx index 9584294b..9f65613d 100644 --- a/packages/app/src/components/Header/ConnectedAccountDisplay.tsx +++ b/packages/app/src/components/Header/ConnectedAccountDisplay.tsx @@ -1,11 +1,13 @@ import { Image, StyleSheet, Text, View } from 'react-native'; +import { useEnsName, useNetwork } from 'wagmi'; + import { InterRegular } from '../../utils/webFonts'; import { formatAddress } from '../../lib/formatAddress'; -import { useEnsName, useNetwork } from 'wagmi'; import { Colors } from '../../utils/colors'; import { PlaceholderAvatar } from '../../assets'; import { useGetTokenBalance } from '../../hooks/useGetTokenBalance'; import { formatNumberWithCommas } from '../../lib/formatFiatCurrency'; +import { SupportedNetwork } from '../../models/constants'; interface ConnectedAccountDisplayProps { isDesktopResolution: boolean; @@ -17,8 +19,9 @@ export const ConnectedAccountDisplay = (props: ConnectedAccountDisplayProps) => const { chain } = useNetwork(); let chainName = chain?.name.replace(/\d+|\s/g, ''); - if (chainName !== 'Celo') { - chainName = 'None'; + console.log('chainName', { chainName, chain: chain }); + if (!(chainName && chainName.toUpperCase() in SupportedNetwork)) { + chainName = 'Unsupported Network'; } const tokenBalance = useGetTokenBalance('G$', address, chain?.id, true); @@ -33,7 +36,7 @@ export const ConnectedAccountDisplay = (props: ConnectedAccountDisplayProps) => {chainName} diff --git a/packages/app/src/hooks/useSwapRoute.tsx b/packages/app/src/hooks/useSwapRoute.tsx index 8da3c913..f4697dc7 100644 --- a/packages/app/src/hooks/useSwapRoute.tsx +++ b/packages/app/src/hooks/useSwapRoute.tsx @@ -1,7 +1,7 @@ import { AlphaRouter, SwapRoute, SwapType, V3Route } from '@uniswap/smart-order-router'; import { CurrencyAmount, Percent, TradeType } from '@uniswap/sdk-core'; import { useAccount, useNetwork } from 'wagmi'; -import { GDToken } from '../models/constants'; +import { GDToken, SupportedNetwork } from '../models/constants'; import { useEthersSigner } from './useEthersSigner'; import { calculateRawTotalDonation } from '../lib/calculateRawTotalDonation'; import Decimal from 'decimal.js'; @@ -37,13 +37,13 @@ export function useSwapRoute( const [route, setRoute] = useState(undefined); useEffect(() => { - if (!address || !chain?.id || !signer?.provider || tokenIn.symbol === 'G$') { + if (!address || !chain?.id || chain.id !== SupportedNetwork.CELO || !signer?.provider || tokenIn.symbol === 'G$') { setRoute(undefined); return; } const router = new AlphaRouter({ - chainId: chain.id, + chainId: chain.id as number, provider: signer.provider, });