Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: The app no longer crashes when connected to networks that are not supported by uniswap and selecting non-G$ token on donate screen #164

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/app/src/hooks/useSwapRoute.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -37,13 +37,13 @@ export function useSwapRoute(
const [route, setRoute] = useState<SwapRoute | undefined>(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,
});

Expand Down
Loading