From cd2a35d951e6db472e9fd36b496de8748e340376 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 14 May 2024 12:20:36 -0500 Subject: [PATCH] ConnectSigner: make getPublicKey used the stored value instead of actually hitting the relay --- src/signers/ConnectSigner.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/signers/ConnectSigner.ts b/src/signers/ConnectSigner.ts index e7d61a8..4dda0b1 100644 --- a/src/signers/ConnectSigner.ts +++ b/src/signers/ConnectSigner.ts @@ -1,3 +1,4 @@ +// deno-lint-ignore-file require-await import { NConnectSigner } from '@nostrify/nostrify'; import { AdminSigner } from '@/signers/AdminSigner.ts'; @@ -9,18 +10,26 @@ import { Storages } from '@/storages.ts'; * Simple extension of nostrify's `NConnectSigner`, with our options to keep it DRY. */ export class ConnectSigner extends NConnectSigner { + private _pubkey: string; + constructor(pubkey: string, private relays?: string[]) { super({ pubkey, - // TODO: use a remote relay for `nprofile` signing, if present and Conf.relay isn't already in the list + // TODO: use a remote relay for `nprofile` signing (if present and `Conf.relay` isn't already in the list) relay: Storages.pubsub, signer: new AdminSigner(), timeout: 60000, }); + + this._pubkey = pubkey; + } + + // Prevent unnecessary NIP-46 round-trips. + async getPublicKey(): Promise { + return this._pubkey; } /** Get the user's relays if they passed in an `nprofile` auth token. */ - // deno-lint-ignore require-await async getRelays(): Promise> { return this.relays?.reduce>((acc, relay) => { acc[relay] = { read: true, write: true };