Refactor signers
This commit is contained in:
@ -134,7 +134,7 @@ export default function SendSats(props: SendSatsProps) {
|
||||
const randomKey = generateRandomKey();
|
||||
console.debug("Generated new key for zap: ", randomKey);
|
||||
|
||||
const publisher = new EventPublisher(randomKey.publicKey, randomKey.privateKey);
|
||||
const publisher = EventPublisher.privateKey(randomKey.privateKey);
|
||||
zap = await publisher.zap(amount * 1000, author, relays, note, comment, eb => eb.tag(["anon", ""]));
|
||||
} else {
|
||||
zap = await publisher.zap(amount * 1000, author, relays, note, comment);
|
||||
|
@ -1,12 +1,15 @@
|
||||
import { useMemo } from "react";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
import { EventPublisher } from "@snort/system";
|
||||
import { EventPublisher, Nip7Signer } from "@snort/system";
|
||||
|
||||
export default function useEventPublisher() {
|
||||
const { publicKey, privateKey } = useLogin();
|
||||
return useMemo(() => {
|
||||
if (privateKey) {
|
||||
return EventPublisher.privateKey(privateKey);
|
||||
}
|
||||
if (publicKey) {
|
||||
return new EventPublisher(publicKey, privateKey);
|
||||
return new EventPublisher(new Nip7Signer(), publicKey);
|
||||
}
|
||||
}, [publicKey, privateKey]);
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ export async function generateNewLogin() {
|
||||
}
|
||||
|
||||
const publicKey = utils.bytesToHex(secp.schnorr.getPublicKey(privateKey));
|
||||
const publisher = new EventPublisher(publicKey, privateKey);
|
||||
const publisher = EventPublisher.privateKey(privateKey);
|
||||
const ev = await publisher.contactList([bech32ToHex(SnortPubKey), publicKey], newRelays);
|
||||
System.BroadcastEvent(ev);
|
||||
|
||||
|
@ -6,7 +6,7 @@ import { StrictMode } from "react";
|
||||
import * as ReactDOM from "react-dom/client";
|
||||
import { Provider } from "react-redux";
|
||||
import { createBrowserRouter, RouterProvider } from "react-router-dom";
|
||||
import { EventPublisher, NostrSystem, ProfileLoaderService } from "@snort/system";
|
||||
import { EventPublisher, NostrSystem, ProfileLoaderService, Nip7Signer } from "@snort/system";
|
||||
|
||||
import * as serviceWorkerRegistration from "serviceWorkerRegistration";
|
||||
import { IntlProvider } from "IntlProvider";
|
||||
@ -46,8 +46,12 @@ export const System = new NostrSystem({
|
||||
relayMetrics: RelayMetrics,
|
||||
authHandler: async (c, r) => {
|
||||
const { publicKey, privateKey } = LoginStore.snapshot();
|
||||
if (privateKey) {
|
||||
const pub = EventPublisher.privateKey(privateKey);
|
||||
return await pub.nip42Auth(c, r);
|
||||
}
|
||||
if (publicKey) {
|
||||
const pub = new EventPublisher(publicKey, privateKey);
|
||||
const pub = new EventPublisher(new Nip7Signer(), publicKey);
|
||||
return await pub.nip42Auth(c, r);
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user