From 38e0fc53adea6ea64fc8d57d4de51c90867f2d5a Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Mon, 18 Aug 2025 13:26:28 -0700 Subject: [PATCH] Update wallet to use welshman's session wallet --- src/app/commands.ts | 19 ++++++----- src/app/components/WalletConnect.svelte | 14 +++++--- src/app/components/WalletDisconnect.svelte | 5 +-- src/app/components/ZapButton.svelte | 5 ++- src/app/state.ts | 37 ---------------------- src/routes/settings/wallet/+page.svelte | 17 +++++----- 6 files changed, 34 insertions(+), 63 deletions(-) diff --git a/src/app/commands.ts b/src/app/commands.ts index 63c2e4f..40fbe4a 100644 --- a/src/app/commands.ts +++ b/src/app/commands.ts @@ -39,6 +39,7 @@ import {Router} from "@welshman/router" import { pubkey, signer, + session, repository, publishThunk, profilesByPubkey, @@ -56,8 +57,6 @@ import { getThunkError, } from "@welshman/app" import { - wallet, - getWebLn, PROTECTED, userMembership, INDEXER_RELAYS, @@ -462,16 +461,20 @@ export const makeAlert = async (params: AlertParams) => { export const publishAlert = async (params: AlertParams) => publishThunk({event: await makeAlert(params), relays: [NOTIFIER_RELAY]}) -export const payInvoice = async (invoice: string) => { - const $wallet = get(wallet) +// Lightning - if (!$wallet) { +export const getWebLn = () => (window as any).webln + +export const payInvoice = async (invoice: string) => { + const $session = session.get() + + if (!$session?.wallet) { throw new Error("No wallet is connected") } - if ($wallet.type === "nwc") { - return new nwc.NWCClient($wallet.info).payInvoice({invoice}) - } else if ($wallet.type === "webln") { + if ($session.wallet.type === "nwc") { + return new nwc.NWCClient($session.wallet.info).payInvoice({invoice}) + } else if ($session.wallet.type === "webln") { return getWebLn() .enable() .then(() => getWebLn().sendPayment(invoice)) diff --git a/src/app/components/WalletConnect.svelte b/src/app/components/WalletConnect.svelte index e94e508..b18f26f 100644 --- a/src/app/components/WalletConnect.svelte +++ b/src/app/components/WalletConnect.svelte @@ -1,7 +1,9 @@