applesauce-wallet-connect
Version:
NIP-47 Nostr Wallet Connect implementation for both clients and services.
35 lines (34 loc) • 2.39 kB
TypeScript
import { NostrEvent } from "applesauce-core/helpers/event";
import { WalletConnectEncryptionMethod } from "./encryption.js";
import { TWalletMethod } from "./methods.js";
import { NotificationType } from "./notification.js";
export declare const WALLET_INFO_KIND = 13194;
/** A symbol used to cache the wallet info on the event */
export declare const WalletInfoSymbol: unique symbol;
/** Wallet service capabilities and information */
export interface WalletSupport<Methods extends TWalletMethod = TWalletMethod> {
/** List of supported methods for this wallet service */
methods: Array<Methods["method"]>;
/** List of supported encryption methods */
encryption: WalletConnectEncryptionMethod[];
/** List of supported notifications, optional */
notifications?: NotificationType[];
}
/** Gets the wallet info from a kind 13194 event */
export declare function getWalletSupport<Methods extends TWalletMethod = TWalletMethod>(info: NostrEvent): WalletSupport<Methods> | null;
/** Gets the encryption methods from a wallet info event */
export declare function getEncryptionMethods(info: NostrEvent | WalletSupport): WalletConnectEncryptionMethod[];
/** Checks if the wallet service supports a specific encryption method */
export declare function supportsEncryption(info: NostrEvent | WalletSupport, encryption: WalletConnectEncryptionMethod): boolean;
/** Gets the preferred encryption method (nip44_v2 preferred over nip04) */
export declare function getPreferredEncryption(info: NostrEvent | WalletSupport): WalletConnectEncryptionMethod;
/** Checks if the wallet service supports a specific method */
export declare function supportsMethod(info: NostrEvent | WalletSupport, method: string): boolean;
/** Checks if the wallet service supports notifications */
export declare function supportsNotifications(info: NostrEvent | WalletSupport): boolean;
/** Checks if the wallet service supports a specific notification type */
export declare function supportsNotificationType(info: NostrEvent | WalletSupport, notificationType: NotificationType): boolean;
/** Gets all supported methods from the wallet info */
export declare function getSupportedMethods(info: NostrEvent | WalletSupport): string[];
/** Gets all supported notifications from the wallet info */
export declare function getSupportedNotifications(info: NostrEvent | WalletSupport): NotificationType[];