Skip to content

Commit

Permalink
fix: ensure receiveAddress query -> string | null
Browse files Browse the repository at this point in the history
  • Loading branch information
0xApotheosis committed Jan 14, 2025
1 parent 20edb47 commit 0160098
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/components/MultiHopTrade/hooks/useReceiveAddress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const useReceiveAddress = ({
return false
}, [buyAsset, wallet])

const { data: walletReceiveAddress, isLoading } = useQuery({
const { data: walletReceiveAddress, isLoading } = useQuery<string | null>({
queryKey: [
'receiveAddress',
buyAsset?.assetId,
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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,
}
}

0 comments on commit 0160098

Please sign in to comment.