From 232e2935a3c390ef78f670d978ff98e934693526 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 1 Aug 2026 22:49:26 -0700 Subject: Restore two helpers an earlier edit deleted, and guard the class of bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A bulk replacement removed lookupMine() and the flag along with the block it was rewriting, so names setup threw at runtime — the kind of break every existing test happily passed over because nothing ever constructed a feature and started it. tools/features-smoke-test.js does exactly that: builds every feature against a stubbed wallet with the network cut, runs init/render/stop, and fails on undefined identifiers. It caught the second missing helper immediately. Co-Authored-By: Claude Fable 5 --- src/features/names.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/features/names.js') diff --git a/src/features/names.js b/src/features/names.js index ec422be..4e4f704 100644 --- a/src/features/names.js +++ b/src/features/names.js @@ -85,10 +85,24 @@ export function namesFeature(ctx) { save({}); } + // An imported seed (or a new browser) doesn't know its username — the + // registrar does. Ask by the wallet's nostr pubkey and adopt the answer + // before deciding whether anything needs claiming. + async function lookupMine() { + try { + const pk = wallet.nostrPubkey && wallet.nostrPubkey(); + if (!pk) return; + const r = await withTimeout( + fetch(`${REGISTRAR}/pubkey/${pk}`).then((x) => x.json()), 12000, 'registrar'); + if (r && r.name) save({ ...load(), name: r.name, domain: r.domain || DOMAIN, uri: r.uri }); + } catch (e) { console.warn('names: lookup failed —', e.message); } + } + // Everyone gets an address without being asked: the default username is a // prefix of the wallet's npub — unique, boring, and free. Custom names are // an optional change (and may cost something one day, to keep squatters // out), so nothing here ever blocks the wallet. + let checked = false; // setup finished (the pane waits on this) let retryTimer = null; let deadline = null; let lastError = null; -- cgit v1.2.3