From da1ddebcc9cb83026b88496d9e415ccea3fc9687 Mon Sep 17 00:00:00 2001
From: callebtc <93376500+callebtc@users.noreply.github.com>
Date: Wed, 14 Aug 2024 16:23:20 +0200
Subject: [PATCH] cleanups
---
src/components/SettingsView.vue | 3 +-
src/stores/nostr.ts | 4 +--
src/stores/npubcash.ts | 58 ++++++++++++++-------------------
3 files changed, 28 insertions(+), 37 deletions(-)
diff --git a/src/components/SettingsView.vue b/src/components/SettingsView.vue
index c980c178..b98b326c 100644
--- a/src/components/SettingsView.vue
+++ b/src/components/SettingsView.vue
@@ -264,6 +264,7 @@
+
("cashu.npc.address", ""),
npcDomain: useLocalStorage("cashu.npc.domain", "npub.cash"),
baseURL: useLocalStorage("cashu.npc.baseURL", "https://npub.cash"),
+ npcLoading: false,
// ndk: new NDK(),
// signer: {} as NDKPrivateKeySigner,
}),
@@ -75,22 +76,34 @@ export const useNPCStore = defineStore("npc", {
console.log('Lightning address for wallet:', nip19.npubEncode(walletPublicKeyHex) + '@' + this.npcDomain)
console.log('npub:', nip19.npubEncode(walletPublicKeyHex))
this.baseURL = `https://${this.npcDomain}`
+ this.npcAddress = nip19.npubEncode(walletPublicKeyHex) + '@' + this.npcDomain
if (!this.npcEnabled) {
return
}
// get info
- const info = await this.getInfo()
- if (info.error) {
- notifyError(info.error)
- return
- }
- // log info
- console.log(info)
- if (info.username) {
- this.npcAddress = info.username + '@' + this.npcDomain
- } else {
- this.npcAddress = nip19.npubEncode(walletPublicKeyHex) + '@' + this.npcDomain
+ this.npcLoading = true;
+ try {
+ const info = await this.getInfo()
+ if (info.error) {
+ notifyError(info.error)
+ return
+ }
+ // log info
+ console.log(info)
+ if (info.username) {
+ const usernameAddress = info.username + '@' + this.npcDomain
+ if (this.npcAddress !== usernameAddress) {
+ notifySuccess(`Logged in as ${info.username}`)
+ this.npcAddress = usernameAddress
+ }
+ }
+ } catch (e) {
+ notifyApiError(e)
+ } finally {
+ this.npcLoading = false;
}
+
+
},
generateNip98Event: async function (url: string, method: string, body: string): Promise {
const nostrStore = useNostrStore()
@@ -237,28 +250,5 @@ export const useNPCStore = defineStore("npc", {
return ""
}
},
- // getWithdraw: async function (): Promise {
- // const authHeader = await this.generateNip98Event(
- // `${this.baseURL}/api/v1/withdrawals`,
- // "POST",
- // );
- // try {
- // const response = await fetch(`${this.baseURL}/api/v1/withdraw`, {
- // method: "GET",
- // headers: {
- // Authorization: `Nostr ${authHeader}`,
- // },
- // })
- // // deserialize the response to NPCClaim
- // const claim: NPCClaim = await response.json()
- // if (claim.error) {
- // return ""
- // }
- // return claim.data.token
- // } catch (e) {
- // console.error(e)
- // return ""
- // }
- // }
}
});