From 510c45fcfe02436cc9d744bddfbae33ce8ab6530 Mon Sep 17 00:00:00 2001 From: Skylar Barrera Date: Sun, 28 Jan 2024 21:38:04 -0500 Subject: [PATCH] chore: fix zero eth check (#5361) * chore: fix zero eth check * cleaner * lint --- src/hooks/useOnAvatarPress.ts | 2 +- src/hooks/usePriceImpactDetails.ts | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/hooks/useOnAvatarPress.ts b/src/hooks/useOnAvatarPress.ts index 735d8e8d9f3..f4f05fedf11 100644 --- a/src/hooks/useOnAvatarPress.ts +++ b/src/hooks/useOnAvatarPress.ts @@ -172,7 +172,7 @@ export default ({ screenType = 'transaction' }: UseOnAvatarPressProps = {}) => { const isReadOnly = isReadOnlyWallet && !enableActionsOnReadOnlyWallet; const isENSProfile = profilesEnabled && profileEnabled && isOwner; - const isZeroETH = isZero(accountAsset.balance.amount); + const isZeroETH = isZero(accountAsset?.balance?.amount); const callback = useCallback( async (buttonIndex: number) => { diff --git a/src/hooks/usePriceImpactDetails.ts b/src/hooks/usePriceImpactDetails.ts index 1bd4f947fe0..eef66c72e0a 100644 --- a/src/hooks/usePriceImpactDetails.ts +++ b/src/hooks/usePriceImpactDetails.ts @@ -65,8 +65,9 @@ export default function usePriceImpactDetails( const inputNativeAmount = useMemo(() => { if (isWrapOrUnwrap) { - if (!tradeDetails?.sellAmount || !inputCurrency?.price?.value) - return null; + if (!tradeDetails?.sellAmount || !inputCurrency?.price?.value) { + return ''; + } return convertRawAmountToNativeDisplay( tradeDetails?.sellAmount?.toString(), @@ -95,7 +96,9 @@ export default function usePriceImpactDetails( const outputNativeAmount = useMemo(() => { if (isWrapOrUnwrap) { - if (!tradeDetails?.buyAmount || !inputCurrency?.price?.value) return null; + if (!tradeDetails?.buyAmount || !inputCurrency?.price?.value) { + return ''; + } return convertRawAmountToNativeDisplay( tradeDetails?.buyAmount?.toString(), inputCurrency?.decimals || 18, @@ -146,7 +149,6 @@ export default function usePriceImpactDetails( outputNativeAmount, }; } else if (greaterThanOrEqualTo(priceImpact, PriceImpactWarningThreshold)) { - console.log({ inputNativeAmount, outputNativeAmount }); return { priceImpact: { type: SwapPriceImpactType.high,