UNPKG

applesauce-wallet-connect

Version:

NIP-47 Nostr Wallet Connect implementation for both clients and services.

37 lines (36 loc) 2.05 kB
import { NostrEvent } from "applesauce-core/helpers/event"; import { Filter } from "applesauce-core/helpers/filter"; import { ObservableInput } from "rxjs"; /** A method used to subscribe to events on a set of relays */ export type NostrSubscriptionMethod = (relays: string[], filters: Filter[]) => ObservableInput<NostrEvent | string>; /** A method used for publishing an event, can return a Promise that completes when published or an Observable that completes when published*/ export type NostrPublishMethod = (relays: string[], event: NostrEvent) => Promise<any> | ObservableInput<any>; /** A simple pool type that combines the subscription and publish methods */ export type NostrPool = { subscription: NostrSubscriptionMethod; publish: NostrPublishMethod; }; /** Options for setting the subscription and publish methods */ export type NostrConnectionMethodsOptions = { /** An optional method for subscribing to relays */ subscriptionMethod?: NostrSubscriptionMethod; /** An optional method for publishing events */ publishMethod?: NostrPublishMethod; /** An optional pool for connection methods */ pool?: NostrPool; }; /** A class that implements has global fallback methods for subscription and publish methods */ export interface NostrConnectionClassMethods { new (...args: any[]): any; /** A fallback method to use for subscriptionMethod if none is passed in when creating the client */ subscriptionMethod: NostrSubscriptionMethod | undefined; /** A fallback method to use for publishMethod if none is passed in when creating the client */ publishMethod: NostrPublishMethod | undefined; /** A fallback pool to use if none is pass in when creating the signer */ pool: NostrPool | undefined; } /** Get the subscription and publish methods for a NostrConnect class */ export declare function getConnectionMethods(options: NostrConnectionMethodsOptions, cls?: NostrConnectionClassMethods): { subscriptionMethod: NostrSubscriptionMethod; publishMethod: NostrPublishMethod; };