Skip to content

Commit

Permalink
cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Aug 14, 2024
1 parent 5a5ce15 commit da1ddeb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 37 deletions.
3 changes: 2 additions & 1 deletion src/components/SettingsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@
<div class="col-12">
<q-input outlined v-model="npcAddress" dense rounded readonly>
<template v-slot:append>
<q-spinner-hourglass size="sm" v-if="npcLoading" />
<q-icon
name="content_copy"
@click="copyText(npcAddress)"
Expand Down Expand Up @@ -847,7 +848,7 @@ export default defineComponent({
"activeProofs",
"proofs",
]),
...mapState(useNPCStore, ["npcAddress"]),
...mapState(useNPCStore, ["npcAddress", "npcLoading"]),
...mapState(useNostrStore, ["pubkey", "mintRecommendations", "signerType"]),
...mapState(useWalletStore, ["mnemonic"]),
...mapWritableState(useNPCStore, ["npcEnabled", "automaticClaim"]),
Expand Down
4 changes: 2 additions & 2 deletions src/stores/nostr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const useNostrStore = defineStore("nostr", {
initNip46Signer: async function (nip46Token?: string) {
const ndk = new NDK({ explicitRelayUrls: this.relays });
if (!nip46Token && !this.nip46Token.length) {
nip46Token = await prompt("enter your nip-46 token") as string;
nip46Token = await prompt("Enter your NIP-46 connection string") as string;
if (!nip46Token) {
return;
}
Expand All @@ -127,7 +127,7 @@ export const useNostrStore = defineStore("nostr", {
},
initPrivateKeySigner: async function (nsec?: string) {
if (!nsec && !this.privateKeySignerPrivateKey.length) {
nsec = await prompt("enter your nsec") as string;
nsec = await prompt("Enter your nsec") as string;
if (!nsec) {
return;
}
Expand Down
58 changes: 24 additions & 34 deletions src/stores/npubcash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const useNPCStore = defineStore("npc", {
npcAddress: useLocalStorage<string>("cashu.npc.address", ""),
npcDomain: useLocalStorage<string>("cashu.npc.domain", "npub.cash"),
baseURL: useLocalStorage<string>("cashu.npc.baseURL", "https://npub.cash"),
npcLoading: false,
// ndk: new NDK(),
// signer: {} as NDKPrivateKeySigner,
}),
Expand All @@ -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<string> {
const nostrStore = useNostrStore()
Expand Down Expand Up @@ -237,28 +250,5 @@ export const useNPCStore = defineStore("npc", {
return ""
}
},
// getWithdraw: async function (): Promise<string> {
// 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 ""
// }
// }
}
});

0 comments on commit da1ddeb

Please sign in to comment.