UNPKG

applesauce-wallet-connect

Version:

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

37 lines (36 loc) 2.31 kB
import { HiddenContentSigner, KnownEvent, UnlockedHiddenContent } from "applesauce-core/helpers"; import { NostrEvent } from "applesauce-core/helpers/event"; import { Transaction } from "./methods.js"; export declare const WALLET_NOTIFICATION_KIND = 23197; export declare const WALLET_LEGACY_NOTIFICATION_KIND = 23196; /** A type for validated wallet notification events */ export type WalletNotificationEvent = KnownEvent<typeof WALLET_NOTIFICATION_KIND> | KnownEvent<typeof WALLET_LEGACY_NOTIFICATION_KIND>; /** A symbol used to cache the wallet notification on the event */ export declare const WalletNotificationSymbol: unique symbol; /** A type for unlocked notifications events */ export type UnlockedWalletNotification = UnlockedHiddenContent & { [WalletNotificationSymbol]: WalletNotification; }; /** Supported notification types */ export type NotificationType = "payment_received" | "payment_sent"; /** Base notification structure */ export interface BaseNotification<TNotificationType extends NotificationType, TNotification> { /** Indicates the structure of the notification field */ notification_type: TNotificationType; /** Notification data */ notification: TNotification; } /** Payment received notification */ export type PaymentReceivedNotification = BaseNotification<"payment_received", Transaction>; /** Payment sent notification */ export type PaymentSentNotification = BaseNotification<"payment_sent", Transaction>; /** Union type for all NIP-47 notification types */ export type WalletNotification = PaymentReceivedNotification | PaymentSentNotification; /** Checks if a kind 23196 or 23197 event is locked */ export declare function isWalletNotificationUnlocked(notification: any): notification is UnlockedWalletNotification; /** Unlocks a kind 23196 or 23197 event */ export declare function unlockWalletNotification(notification: NostrEvent, signer: HiddenContentSigner): Promise<WalletNotification | undefined>; /** Gets the wallet notification from a kind 23196 or 23197 event */ export declare function getWalletNotification(notification: NostrEvent): WalletNotification | undefined; /** Checks if an event is a valid wallet notification event */ export declare function isValidWalletNotification(notification: NostrEvent): notification is WalletNotificationEvent;