import { useQuery } from '@tanstack/react-query' import { useCluster } from '@solana/connector/react' import { createSolanaRpc } from '@solana/kit' import { fetchEscrowAccount } from '@descro/sdk' import type { Address } from '@solana/kit' export function useEscrow(pda: Address) { const { cluster } = useCluster() return useQuery({ queryKey: ['escrow', pda, cluster?.id], queryFn: () => { const rpc = createSolanaRpc(cluster!.url) return fetchEscrowAccount( rpc as Parameters[0], pda, ).catch(() => null) }, enabled: !!cluster && !!pda, refetchInterval: 15_000, }) }