Skip to content

Commit

Permalink
Re-adding optional chaining for sellAsset and buyAsset on quote respo…
Browse files Browse the repository at this point in the history
…nse (#1673)
  • Loading branch information
jinchung authored Aug 21, 2024
1 parent 45ee933 commit 5d7ed14
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/entries/popup/hooks/swap/useSwapNativeAmounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ export const useSwapNativeAmounts = ({
let nativeDisplay = null;
if (isWrapOrUnwrapEth) {
nativeDisplay =
!quote?.sellAmount || !quote.sellTokenAsset.price.value
!quote?.sellAmount || !quote?.sellTokenAsset?.price?.value
? null
: convertRawAmountToNativeDisplay(
quote?.sellAmount?.toString(),
quote.sellTokenAsset.decimals || 18,
quote.sellTokenAsset.price.value,
quote?.sellTokenAsset?.decimals || 18,
quote?.sellTokenAsset?.price?.value,
currentCurrency,
);
} else if (assetToSell?.native?.price?.amount && assetToSellValue) {
Expand All @@ -47,12 +47,12 @@ export const useSwapNativeAmounts = ({
);
} else {
nativeDisplay =
!quote?.sellAmountInEth || !quote.sellTokenAsset.price.value
!quote?.sellAmountInEth || !quote?.sellTokenAsset?.price?.value
? null
: convertRawAmountToNativeDisplay(
quote?.sellAmountInEth.toString(),
quote.sellTokenAsset.decimals || 18,
quote.sellTokenAsset.price?.value,
quote?.sellAmountInEth?.toString(),
quote?.sellTokenAsset?.decimals || 18,
quote?.sellTokenAsset?.price?.value,
currentCurrency,
);
}
Expand All @@ -72,8 +72,8 @@ export const useSwapNativeAmounts = ({
assetToSellValue,
currentCurrency,
quote?.sellAmount,
quote?.sellTokenAsset.price.value,
quote?.sellTokenAsset.decimals,
quote?.sellTokenAsset?.price?.value,
quote?.sellTokenAsset?.decimals,
quote?.sellAmountInEth,
]);

Expand All @@ -97,12 +97,12 @@ export const useSwapNativeAmounts = ({
);
} else {
nativeDisplay =
!quote?.buyAmountInEth || !quote.buyTokenAsset.price?.value
!quote?.buyAmountInEth || !quote?.buyTokenAsset?.price?.value
? null
: convertRawAmountToNativeDisplay(
quote?.buyAmountInEth.toString(),
quote.buyTokenAsset.decimals || 18,
quote.buyTokenAsset.price?.value,
quote?.buyAmountInEth?.toString(),
quote?.buyTokenAsset?.decimals || 18,
quote?.buyTokenAsset?.price?.value,
currentCurrency,
);
}
Expand All @@ -124,8 +124,8 @@ export const useSwapNativeAmounts = ({
quote?.buyAmount,
quote?.buyAmountInEth,
currentCurrency,
quote?.buyTokenAsset.price?.value,
quote?.buyTokenAsset.decimals,
quote?.buyTokenAsset?.price?.value,
quote?.buyTokenAsset?.decimals,
]);

return {
Expand Down

0 comments on commit 5d7ed14

Please sign in to comment.