Skip to content

Commit

Permalink
fix optional params - revisit
Browse files Browse the repository at this point in the history
  • Loading branch information
alissacrane-cb committed Dec 16, 2024
1 parent 947b6b8 commit 036a58a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/core/api/getSwapLiteQuote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type GetSwapLiteQuoteResponse = {
};

type GetSwapLiteQuoteParams = Omit<GetSwapQuoteParams, 'from'> & {
fromSwapUnit: SwapUnit;
fromSwapUnit?: SwapUnit;
from?: Token;
};

Expand Down Expand Up @@ -48,7 +48,7 @@ export async function getSwapLiteQuote({
}

let formattedFromAmount = '';
if (response && !isSwapError(response)) {
if (response && !isSwapError(response) && fromSwapUnit) {
formattedFromAmount = formatTokenAmount(
response.fromAmount,
response.from.decimals,
Expand Down
10 changes: 5 additions & 5 deletions src/swap/components/SwapLiteProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,13 @@ export function SwapLiteProvider({
to.setAmountUSD('');
fromETH.setAmountUSD('');
fromUSDC.setAmountUSD('');
from.setAmountUSD('');
from?.setAmountUSD('');
return;
}

fromETH.setLoading(true);
fromUSDC.setLoading(true);
from.setLoading(true);
from?.setLoading(true);

updateLifecycleStatus({
statusName: 'amountChange',
Expand All @@ -276,7 +276,7 @@ export function SwapLiteProvider({
amountFrom: '',
tokenFromETH: fromETH.token,
tokenFromUSDC: fromUSDC.token,
tokenFrom: from.token,
tokenFrom: from?.token,
tokenTo: to.token,
// when fetching quote, the destination
// amount is missing
Expand Down Expand Up @@ -353,7 +353,7 @@ export function SwapLiteProvider({
amountTo: amount,
tokenFromETH: fromETH.token,
tokenFromUSDC: fromUSDC.token,
tokenFrom: from.token,
tokenFrom: from?.token,
tokenTo: to.token,
// if quote was fetched successfully, we
// have all required fields
Expand All @@ -373,7 +373,7 @@ export function SwapLiteProvider({
// reset loading state when quote request resolves
fromETH.setLoading(false);
fromUSDC.setLoading(false);
from.setLoading(false);
from?.setLoading(false);
}
},
[
Expand Down

0 comments on commit 036a58a

Please sign in to comment.