From 55297eeaae86fee264f6fc05c95bfc703be1056f Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 16 Sep 2024 16:07:43 -0700 Subject: nwc --- src/lib/nostr.ts | 6 --- src/locales/en.json | 1 + .../(app)/[username]/(profile)/+layout.svelte | 51 ++++++++++++++++++---- 3 files changed, 43 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/lib/nostr.ts b/src/lib/nostr.ts index fce09d30..1a02114d 100644 --- a/src/lib/nostr.ts +++ b/src/lib/nostr.ts @@ -22,9 +22,6 @@ import wordlist from "$lib/english"; import { bech32m } from "@scure/base"; import { generateSeedWords, privateKeyFromSeedWords } from "nostr-tools/nip06"; -import { PUBLIC_COINOS_PUBKEY } from "$env/static/public"; - -let damus = "wss://relay.damus.io"; type User = { [key: string]: any; @@ -178,6 +175,3 @@ export let reEncryptEntropy = async (user: User, newPassword: string) => { return encode("en", toWords(bytes), 180); }; - -export let nwc = (user: User) => - `nostr+walletconnect://${PUBLIC_COINOS_PUBKEY}?relay=${damus}&secret=${user.nwc}`; diff --git a/src/locales/en.json b/src/locales/en.json index f1d96157..29929c6b 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -159,6 +159,7 @@ "moreDetails": "Profile details", "noMessages": "You have not sent or received any messages", "profilePage": "Profile page", + "nwc": "Nostr wallet connect", "nostrPubkey": "Nostr pubkey", "requestPayment": "Request Payment", "welcome": "Welcome! Your account balance is empty. You can start by making a deposit or by asking someone to pay you.", diff --git a/src/routes/(app)/[username]/(profile)/+layout.svelte b/src/routes/(app)/[username]/(profile)/+layout.svelte index 3a1dee56..c4750581 100644 --- a/src/routes/(app)/[username]/(profile)/+layout.svelte +++ b/src/routes/(app)/[username]/(profile)/+layout.svelte @@ -6,6 +6,10 @@ import { sign, send } from "$lib/nostr"; import { bech32m } from "@scure/base"; import { page } from "$app/stores"; + import { + PUBLIC_COINOS_PUBKEY as pk, + PUBLIC_COINOS_RELAY as relay, + } from "$env/static/public"; export let data; @@ -15,7 +19,7 @@ $: ({ events, user, subject, src, rates, text } = data); $: ({ currency, username: n, display } = subject); - $: stripped = n.replace(/\s/g, "") + $: stripped = n.replace(/\s/g, ""); $: username = n.length > 60 ? n.substr(0, 6) : display || stripped; $: npub = subject.pubkey && @@ -23,13 +27,12 @@ $: lnaddr = `${stripped}@${$page.url.host}`; $: profile = `${$page.url.host}/${stripped}`; + $: nwc = `nostr+walletconnect://${pk}?relay=${encodeURIComponent( + relay + )}&secret=${user.nwc}`; + let follow = async () => { - user.follows.push([ - "p", - subject.pubkey, - "wss://nostr.coinos.io", - stripped, - ]); + user.follows.push(["p", subject.pubkey, "wss://nostr.coinos.io", stripped]); update(); }; @@ -118,7 +121,11 @@
{$t("user.moreDetails")}
-
+
@@ -136,7 +143,12 @@ - +
@@ -174,6 +186,27 @@ + {#if user.id === subject.id} +
+
{$t("user.nwc")}
+
+
+ {nwc} +
+
+ + + + +
+
+
+ {/if} {/if} -- cgit v1.2.3