move @snort/nostr code into System

This commit is contained in:
2023-05-30 14:48:38 +01:00
parent baec8d6904
commit f86053c14f
119 changed files with 1071 additions and 163 deletions

View File

@ -1,4 +1,4 @@
import { HexKey, RelaySettings } from "@snort/nostr";
import { HexKey, RelaySettings } from "System";
import * as secp from "@noble/curves/secp256k1";
import * as utils from "@noble/curves/abstract/utils";
@ -8,6 +8,7 @@ import { generateBip39Entropy, entropyToPrivateKey } from "nip6";
import { bech32ToHex, dedupeById, randomSample, sanitizeRelayUrl, unixNowMs, unwrap } from "SnortUtils";
import { SubscriptionEvent } from "Subscription";
import { EventPublisher } from "System/EventPublisher";
import { System } from "index";
export function setRelays(state: LoginSession, relays: Record<string, RelaySettings>, createdAt: number) {
if (state.relays.timestamp >= createdAt) {
@ -78,7 +79,7 @@ export async function generateNewLogin() {
}
const publicKey = utils.bytesToHex(secp.schnorr.getPublicKey(privateKey));
const publisher = new EventPublisher(publicKey, privateKey);
const publisher = new EventPublisher(System, publicKey, privateKey);
const ev = await publisher.contactList([bech32ToHex(SnortPubKey), publicKey], newRelays);
publisher.broadcast(ev);