Move wallet to util
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {derived, writable} from "svelte/store"
|
||||
import {cached, randomId, append, omit, equals, assoc} from "@welshman/lib"
|
||||
import {withGetter} from "@welshman/store"
|
||||
import {Wallet} from "@welshman/util"
|
||||
import {
|
||||
WrappedSigner,
|
||||
Nip46Broker,
|
||||
@@ -59,7 +60,7 @@ export type SessionAnyMethod =
|
||||
| SessionNip55
|
||||
| SessionPubkey
|
||||
|
||||
export type Session = SessionAnyMethod & Record<string, any>
|
||||
export type Session = SessionAnyMethod & {wallet?: Wallet} & Record<string, any>
|
||||
|
||||
export const pubkey = withGetter(writable<string | undefined>(undefined))
|
||||
|
||||
|
||||
@@ -80,6 +80,16 @@ export const {
|
||||
}),
|
||||
})
|
||||
|
||||
export const loadZapperForPubkey = async (pubkey: string, relays: string[] = []) => {
|
||||
const $profile = await loadProfile(pubkey, relays)
|
||||
|
||||
if (!$profile?.lnurl) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return loadZapper($profile.lnurl)
|
||||
}
|
||||
|
||||
export const deriveZapperForPubkey = (pubkey: string, relays: string[] = []) =>
|
||||
derived([zappersByLnurl, deriveProfile(pubkey, relays)], ([$zappersByLnurl, $profile]) => {
|
||||
if (!$profile?.lnurl) {
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
export type WebLNInfo = {
|
||||
methods?: string[]
|
||||
supports?: string[]
|
||||
version?: string
|
||||
node?: {
|
||||
alias: string
|
||||
}
|
||||
}
|
||||
|
||||
export type NWCInfo = {
|
||||
lud16: string
|
||||
secret: string
|
||||
relayUrl: string
|
||||
walletPubkey: string
|
||||
nostrWalletConnectUrl: string
|
||||
}
|
||||
|
||||
export enum WalletType {
|
||||
WebLn = "webln",
|
||||
NWC = "nwc",
|
||||
}
|
||||
|
||||
export type Wallet =
|
||||
| {
|
||||
type: WalletType.WebLn
|
||||
info: WebLNInfo
|
||||
}
|
||||
| {
|
||||
type: WalletType.NWC
|
||||
info: NWCInfo
|
||||
}
|
||||
@@ -14,4 +14,5 @@ export * from "./Profile.js"
|
||||
export * from "./Relay.js"
|
||||
export * from "./Room.js"
|
||||
export * from "./Tags.js"
|
||||
export * from "./Wallet.js"
|
||||
export * from "./Zaps.js"
|
||||
|
||||
Reference in New Issue
Block a user