UNPKG

applesauce-wallet-connect

Version:

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

56 lines (55 loc) 2.8 kB
/** NIP-47 error codes as defined in the specification */ export type WalletErrorCode = "RATE_LIMITED" | "NOT_IMPLEMENTED" | "INSUFFICIENT_BALANCE" | "QUOTA_EXCEEDED" | "RESTRICTED" | "UNAUTHORIZED" | "INTERNAL" | "UNSUPPORTED_ENCRYPTION" | "PAYMENT_FAILED" | "NOT_FOUND" | "OTHER"; /** Base class for all NIP-47 wallet connect errors */ export declare abstract class WalletBaseError extends Error { abstract readonly code: WalletErrorCode; constructor(message: string); } /** The client is sending commands too fast. It should retry in a few seconds. */ export declare class RateLimitedError extends WalletBaseError { readonly code: "RATE_LIMITED"; } /** The command is not known or is intentionally not implemented. */ export declare class NotImplementedError extends WalletBaseError { readonly code: "NOT_IMPLEMENTED"; } /** The wallet does not have enough funds to cover a fee reserve or the payment amount. */ export declare class InsufficientBalanceError extends WalletBaseError { readonly code: "INSUFFICIENT_BALANCE"; } /** The wallet has exceeded its spending quota. */ export declare class QuotaExceededError extends WalletBaseError { readonly code: "QUOTA_EXCEEDED"; } /** This public key is not allowed to do this operation. */ export declare class RestrictedError extends WalletBaseError { readonly code: "RESTRICTED"; } /** This public key has no wallet connected. */ export declare class UnauthorizedError extends WalletBaseError { readonly code: "UNAUTHORIZED"; } /** An internal error. */ export declare class InternalError extends WalletBaseError { readonly code: "INTERNAL"; } /** The encryption type of the request is not supported by the wallet service. */ export declare class UnsupportedEncryptionError extends WalletBaseError { readonly code: "UNSUPPORTED_ENCRYPTION"; } /** The payment failed. This may be due to a timeout, exhausting all routes, insufficient capacity or similar. */ export declare class PaymentFailedError extends WalletBaseError { readonly code: "PAYMENT_FAILED"; } /** The invoice could not be found by the given parameters. */ export declare class NotFoundError extends WalletBaseError { readonly code: "NOT_FOUND"; } /** Other error. */ export declare class OtherError extends WalletBaseError { readonly code: "OTHER"; } /** Union type of all NIP-47 error classes */ export type WalletErrorClass = RateLimitedError | NotImplementedError | InsufficientBalanceError | QuotaExceededError | RestrictedError | UnauthorizedError | InternalError | UnsupportedEncryptionError | PaymentFailedError | NotFoundError | OtherError; /** Factory function to create NWC error instances from error code and message */ export declare function createWalletError(code: WalletErrorCode, message: string): WalletErrorClass;