Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure receiveAddress query -> string | null #8565

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>({
gomesalexandre marked this conversation as resolved.
Show resolved Hide resolved
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,
gomesalexandre marked this conversation as resolved.
Show resolved Hide resolved
isLoading: isInitializing || isLoading,
}
}