Add type guard utils to wallet utils

This commit is contained in:
Jon Staab
2025-09-29 09:50:51 -07:00
parent 728140c77c
commit d4cafb0cb7
2 changed files with 83 additions and 38 deletions
+17 -10
View File
@@ -16,16 +16,23 @@ export type NWCInfo = {
}
export enum WalletType {
WebLn = "webln",
WebLN = "webln",
NWC = "nwc",
}
export type Wallet =
| {
type: WalletType.WebLn
info: WebLNInfo
}
| {
type: WalletType.NWC
info: NWCInfo
}
export type WebLNWallet = {
type: WalletType.WebLN
info: WebLNInfo
}
export type NWCWallet = {
type: WalletType.NWC
info: NWCInfo
}
export type Wallet = WebLNWallet | NWCWallet
export const isWebLNWallet = (wallet: Wallet): wallet is WebLNWallet =>
wallet.type === WalletType.WebLN
export const isNWCWallet = (wallet: Wallet): wallet is NWCWallet => wallet.type === WalletType.NWC