diff options
| author | Adam Soltys <[email protected]> | 2026-08-01 22:49:26 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-08-01 22:49:26 -0700 |
| commit | 232e2935a3c390ef78f670d978ff98e934693526 (patch) | |
| tree | 5060df4554bbcef7f15f2a1f7289545b773781e0 /src | |
| parent | c8e6de17311e3eaa18a73c2aa0688c80e89db254 (diff) | |
| download | coinosv3-232e2935a3c390ef78f670d978ff98e934693526.tar.gz coinosv3-232e2935a3c390ef78f670d978ff98e934693526.zip | |
Restore two helpers an earlier edit deleted, and guard the class of bug
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 <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/features/names.js | 14 |
1 files changed, 14 insertions, 0 deletions
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; |
