feat: negentropy

This commit is contained in:
2024-01-25 15:21:42 +00:00
parent 9a0bbb8b74
commit d7460651c8
31 changed files with 924 additions and 266 deletions

View File

@ -23,9 +23,9 @@ import { SubscriptionEvent } from "@/Utils/Subscription";
import { Nip7OsSigner } from "./Nip7OsSigner";
export function setRelays(state: LoginSession, relays: Record<string, RelaySettings>, createdAt: number) {
if (SINGLE_RELAY) {
if (import.meta.env.VITE_SINGLE_RELAY) {
state.relays.item = {
[SINGLE_RELAY]: { read: true, write: true },
[import.meta.env.VITE_SINGLE_RELAY]: { read: true, write: true },
};
state.relays.timestamp = 100;
LoginStore.updateSession(state);

View File

@ -183,7 +183,7 @@ export class MultiAccountStore extends ExternalStore<LoginSession> {
}
decideInitRelays(relays: Record<string, RelaySettings> | undefined): Record<string, RelaySettings> {
if (SINGLE_RELAY) return { [SINGLE_RELAY]: { read: true, write: true } };
if (import.meta.env.VITE_SINGLE_RELAY) return { [import.meta.env.VITE_SINGLE_RELAY]: { read: true, write: true } };
if (relays && Object.keys(relays).length > 0) {
return relays;
}

View File

@ -104,7 +104,7 @@ export class Zapper {
if (!svc) {
throw new Error(`Failed to get invoice from ${t.value}`);
}
const relays = this.system.Sockets.filter(a => !a.ephemeral).map(v => v.address);
const relays = [...this.system.pool].filter(([, v]) => !v.Ephemeral).map(([k]) => k);
const pub = t.zap?.anon ?? false ? EventPublisher.privateKey(generateRandomKey().privateKey) : this.publisher;
const zap =
t.zap && svc.canZap
@ -199,7 +199,7 @@ export class Zapper {
await svc.load();
return svc;
} else if (t.type === "pubkey") {
const profile = await this.system.ProfileLoader.fetchProfile(t.value);
const profile = await this.system.profileLoader.fetch(t.value);
if (profile) {
const svc = new LNURL(profile.lud16 ?? profile.lud06 ?? "");
await svc.load();