Files
solisting/app/src/hooks/useEscrow.ts
2026-06-26 20:01:36 +02:00

22 lines
656 B
TypeScript

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<typeof fetchEscrowAccount>[0],
pda,
).catch(() => null)
},
enabled: !!cluster && !!pda,
refetchInterval: 15_000,
})
}