Skip to content

Commit

Permalink
remove error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
abcrane123 committed Jun 12, 2024
1 parent 9e0a929 commit 34fc7f4
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/swap/components/Swap.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
import { useCallback, useMemo, useState } from 'react';
import { cn } from '../../lib/utils';
import { SwapContext } from '../context';
import type { SwapError, SwapReact } from '../types';
import type { Token } from '../../token';
import { useGetSwapQuote } from '../hooks/useGetSwapQuote';
import type { SwapReact } from '../types';
import type { Token } from '../../token';

export function Swap({ account, children, onError }: SwapReact) {
const [fromAmount, setFromAmount] = useState('');
const [fromToken, setFromToken] = useState<Token>();
const [toAmount, setToAmount] = useState('');
const [toToken, setToToken] = useState<Token>();
const [swapQuoteError, setSwapQuoteError] = useState('');
const [swapTransactionError, setSwapTransactionError] = useState('');
const [lastTokenAmountUpdated, setLastTokenAmountUpdated] = useState<'to' | 'from' | undefined>();

useGetSwapQuote({
amountReference: lastTokenAmountUpdated,
fromAmount,
fromToken,
onError: (response: SwapError) => {
onError?.(response);
setSwapQuoteError(response?.error);
},
onError,
onSuccess: () => setLastTokenAmountUpdated(undefined),
setToAmount,
setFromAmount,
Expand Down Expand Up @@ -84,11 +79,6 @@ export function Swap({ account, children, onError }: SwapReact) {
>
Swap
</label>
{(swapQuoteError || swapTransactionError) && (
<p className={cn('p-4 text-center text-[14px] text-[red]')}>
{swapQuoteError || swapTransactionError}
</p>
)}
{children}
</div>
</SwapContext.Provider>
Expand Down

0 comments on commit 34fc7f4

Please sign in to comment.