fix escrow handling and fetching
This commit is contained in:
18
app/src/hooks/useOrderByEscrow.ts
Normal file
18
app/src/hooks/useOrderByEscrow.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { useCluster } from '@solana/connector/react'
|
||||
import { createSolanaRpc } from '@solana/kit'
|
||||
import { fetchOrderByEscrow } from '@solisting/sdk'
|
||||
import type { Address } from '@solana/kit'
|
||||
|
||||
export function useOrderByEscrow(escrowPda: Address) {
|
||||
const { cluster } = useCluster()
|
||||
return useQuery({
|
||||
queryKey: ['orderByEscrow', escrowPda, cluster?.id],
|
||||
queryFn: () => {
|
||||
const rpc = createSolanaRpc(cluster!.url)
|
||||
return fetchOrderByEscrow(rpc, escrowPda)
|
||||
},
|
||||
enabled: !!cluster && !!escrowPda,
|
||||
refetchInterval: 30_000,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user