import { SimplePool } from 'nostr-tools' import type { Filter } from 'nostr-tools' import type { Event } from 'nostr-tools' /** * Subscription interface matching nostr-tools 2.x API */ export interface Subscription { on(event: 'event', callback: (event: Event) => void): void on(event: 'eose', callback: () => void): void unsub(): void } /** * Alias for SimplePool with typed sub method from nostr-tools definitions. * In nostr-tools 2.x, SimplePool has a sub method but it's not properly typed. */ export interface SimplePoolWithSub extends SimplePool { sub(relays: string[], filters: Filter[]): Subscription } export function hasSubMethod(pool: SimplePool): pool is SimplePoolWithSub { return typeof (pool as any).sub === 'function' }