kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
fix: remove nostr Nostr Wallet Connect (NWC)
rodzic
7fd9f4ae85
commit
87cd6c0cb6
|
@ -3,7 +3,6 @@ import { useEffect, useState } from 'react';
|
||||||
import { WebsocketEvent } from 'websocket-ts';
|
import { WebsocketEvent } from 'websocket-ts';
|
||||||
|
|
||||||
import { useNostr } from 'soapbox/contexts/nostr-context';
|
import { useNostr } from 'soapbox/contexts/nostr-context';
|
||||||
import { nwcRequestSchema } from 'soapbox/schemas/nostr';
|
|
||||||
|
|
||||||
function useSignerStream() {
|
function useSignerStream() {
|
||||||
const { relay, pubkey, signer } = useNostr();
|
const { relay, pubkey, signer } = useNostr();
|
||||||
|
@ -92,30 +91,11 @@ function useSignerStream() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleWalletEvent(event: NostrEvent) {
|
|
||||||
if (!relay || !pubkey || !signer) return;
|
|
||||||
|
|
||||||
const decrypted = await signer.nip04!.decrypt(pubkey, event.content);
|
|
||||||
|
|
||||||
const reqMsg = n.json().pipe(nwcRequestSchema).safeParse(decrypted);
|
|
||||||
if (!reqMsg.success) {
|
|
||||||
console.warn(decrypted);
|
|
||||||
console.warn(reqMsg.error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await window.webln?.enable();
|
|
||||||
await window.webln?.sendPayment(reqMsg.data.params.invoice);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleEvent(event: NostrEvent) {
|
async function handleEvent(event: NostrEvent) {
|
||||||
switch (event.kind) {
|
switch (event.kind) {
|
||||||
case 24133:
|
case 24133:
|
||||||
await handleConnectEvent(event);
|
await handleConnectEvent(event);
|
||||||
break;
|
break;
|
||||||
case 23194:
|
|
||||||
await handleWalletEvent(event);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +129,7 @@ function useSignerStream() {
|
||||||
const signal = controller.signal;
|
const signal = controller.signal;
|
||||||
|
|
||||||
(async() => {
|
(async() => {
|
||||||
for await (const msg of relay.req([{ kinds: [24133, 23194], authors: [pubkey], limit: 0 }], { signal })) {
|
for await (const msg of relay.req([{ kinds: [24133], authors: [pubkey], limit: 0 }], { signal })) {
|
||||||
if (msg[0] === 'EVENT') handleEvent(msg[2]);
|
if (msg[0] === 'EVENT') handleEvent(msg[2]);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
Ładowanie…
Reference in New Issue