Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Nostr Wallet Connect functionality #212

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/components/SettingsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@
>
<q-item-label title>Use your nsec</q-item-label>
<q-item-label caption
>Enter your nostr private key
>This method is dangerous and not recommended
</q-item-label>
</q-item-section>
<q-item-section side v-if="signerType === 'PRIVATEKEY'">
Expand Down Expand Up @@ -445,20 +445,16 @@

<q-item>
<q-item-section>
<q-item-label overline>Link wallet</q-item-label>
<q-item-label overline>Nostr Wallet Connect (NWC)</q-item-label>
<q-item-label caption
>Use Nostr Wallet Connect (NWC) to control your wallet from any
other application.</q-item-label
>Use NWC to control your wallet from any other
application.</q-item-label
>
</q-item-section>
</q-item>
<!-- use a q-toggle to turn nwc on and off -->
<q-item>
<q-toggle
v-model="enableNwc"
label="Enable Nostr Wallet Connect"
color="primary"
/>
<q-toggle v-model="enableNwc" label="Enable NWC" color="primary" />
</q-item>
<!-- <q-item>
<q-btn
Expand Down
6 changes: 6 additions & 0 deletions src/stores/nostr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ export const useNostrStore = defineStore("nostr", {
this.ndk.connect();
this.connected = true;
},
initSignerIfNotSet: async function () {
if (!this.signer) {
await this.initSigner();
}
},
initSigner: async function () {
if (this.signerType === SignerType.NIP07) {
await this.initNip07Signer();
Expand Down Expand Up @@ -141,6 +146,7 @@ export const useNostrStore = defineStore("nostr", {
}
}
this.privateKeySigner = new NDKPrivateKeySigner(this.privateKeySignerPrivateKey);
this.privateKeySignerPrivateKey = bytesToHex(privateKeyBytes);
this.signerType = SignerType.PRIVATEKEY;
await this.setSigner(this.privateKeySigner);
const publicKeyHex = getPublicKey(privateKeyBytes);
Expand Down
2 changes: 1 addition & 1 deletion src/stores/npubcash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const useNPCStore = defineStore("npc", {
},
generateNip98Event: async function (url: string, method: string, body: string): Promise<string> {
const nostrStore = useNostrStore()
await nostrStore.initSigner()
await nostrStore.initSignerIfNotSet()
const nip98Event = new NDKEvent(new NDK());
nip98Event.kind = NIP98Kind;
nip98Event.content = '';
Expand Down
Loading