From c414093296a62dc664a6548cc9b8d1848faba11d Mon Sep 17 00:00:00 2001 From: Apotheosis <0xapotheosis@gmail.com> Date: Tue, 14 Jan 2025 21:59:24 +1100 Subject: [PATCH] fix: ensure receiveAddress query -> string | null (#8565) --- .../MultiHopTrade/hooks/useReceiveAddress.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/MultiHopTrade/hooks/useReceiveAddress.tsx b/src/components/MultiHopTrade/hooks/useReceiveAddress.tsx index 00e6f4624a8..5db9222b84e 100644 --- a/src/components/MultiHopTrade/hooks/useReceiveAddress.tsx +++ b/src/components/MultiHopTrade/hooks/useReceiveAddress.tsx @@ -52,7 +52,7 @@ export const useReceiveAddress = ({ return false }, [buyAsset, wallet]) - const { data: walletReceiveAddress, isLoading } = useQuery({ + const { data: walletReceiveAddress, isLoading } = useQuery({ queryKey: [ 'receiveAddress', buyAsset?.assetId, @@ -67,7 +67,7 @@ export const useReceiveAddress = ({ ? async () => { // Already partially covered in isInitializing, but TypeScript lyfe mang. if (!buyAsset || !wallet || !buyAccountId || !buyAccountMetadata || !deviceId) { - return undefined + return null } const buyAssetChainId = buyAsset.chainId @@ -80,7 +80,7 @@ export const useReceiveAddress = ({ * super dangerous - don't use the wrong bip44 params to generate receive addresses */ if (buyAssetChainId !== buyAssetAccountChainId) { - return undefined + return null } if (isUtxoAccountId(buyAccountId) && !buyAccountMetadata?.accountType) @@ -95,11 +95,14 @@ export const useReceiveAddress = ({ pubKey: shouldFetchUnchainedAddress ? fromAccountId(buyAccountId).account : undefined, }) - return walletReceiveAddress + return walletReceiveAddress ?? null } : skipToken, staleTime: Infinity, }) - return { walletReceiveAddress, isLoading: isInitializing || isLoading } + return { + walletReceiveAddress: walletReceiveAddress ?? undefined, + isLoading: isInitializing || isLoading, + } }