Skip to content

feat: Stellar Name Service (SNS) integration — closes #112, closes #79 - #371

Merged
Emmy123222 merged 2 commits into
Emmy123222:mainfrom
udeachudivine-spec:task/stellar-name-service
Jul 28, 2026
Merged

feat: Stellar Name Service (SNS) integration — closes #112, closes #79#371
Emmy123222 merged 2 commits into
Emmy123222:mainfrom
udeachudivine-spec:task/stellar-name-service

Conversation

@udeachudivine-spec

Copy link
Copy Markdown
Contributor

What

Adds human-readable Stellar name resolution (.xlm / federation) so users can type e.g. alice.xlm in the Send Payment form instead of a raw G... address.

Implementation

Protocol choice

Uses the built-in Stellar Federation protocol (SEP-0002) via the @stellar/stellar-sdk FederationServer already in the project. No new runtime dependency added. .xlm shorthand names are translated to alice*stellarnames.org federation lookups (documented in the code so the mapping is easy to swap).

frontend/lib/stellar.ts

  • Added ResolvedName interface (name, address, resolvedAt) for the cache
  • Replaced the previous opaque cache shape with ResolvedName entries
  • Rewrote resolveStellarName with full JSDoc: .xlm -> federation mapping explained, raw G... bypass, TTL cache using resolvedAt timestamp
  • Exported clearNameCache() helper for tests
  • Added full JSDoc to isStellarName

frontend/components/SendPaymentForm.tsx

  • Imports isStellarName and resolveStellarName from lib/stellar
  • New snsResolvedAddress / snsResolving state for the destination field
  • useEffect with 400ms debounce triggers resolveStellarName whenever the destination matches isStellarName(); cancels on cleanup
  • Inline spinner (aria-live) shown while resolving
  • 'Resolves to: GABC...XYZ' confirmation line shown on success
  • Inline red error shown on failure; submit blocked until fixed
  • canSubmit gates on !snsResolving and requires snsResolvedAddress for SNS names so raw name strings are never submitted
  • resolveDestinationForPayment prefers the already-resolved snsResolvedAddress to avoid a redundant second lookup at submit time
  • SNS state cleared on destination change, contact select, and form reset

frontend/pages/settings.tsx

  • Fixed bug: SNS card was accidentally nested inside the Mainnet Warning Modal div — moved it out as a standalone settings card
  • Card explains .xlm names, Federation protocol, StellarNames provider, 10-min cache TTL, and the stellar.toml limitation
  • Links directly to stellarnames.org registration (opens in new tab)

Tests (frontend/tests/)

  • resolveStellarName.test.ts — isStellarName, resolveStellarName: raw bypass, successful .xlm and federation resolution, cache hit/miss, TTL expiry, clearNameCache, error propagation, no caching of failures
  • SendPaymentFormSNS.test.tsx — spinner during resolution, resolved address shown, error shown + submit blocked, submit uses resolved address not typed name, raw G... skips resolution
  • settingsSNS.test.tsx — section renders, .xlm copy present, link to stellarnames.org with target=_blank, limitation disclaimer visible, card is not inside the modal

Limitations

Resolution depends on the recipient's domain publishing a valid stellar.toml; names not registered with a federation server will fail to resolve (documented in the UI).

Summary

Type of change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor / chore
  • Smart contract change

Related issue

Closes #

Changes

Testing

  • Tested locally on Testnet
  • Added/updated unit tests
  • Manually tested UI flow

Screenshots (if UI change)

Checklist

  • My code follows the project style
  • I've updated docs if needed
  • No console errors or warnings
  • I've rebased on latest main

## What

Adds human-readable Stellar name resolution (.xlm / federation) so users
can type e.g. alice.xlm in the Send Payment form instead of a raw G...
address.

## Implementation

### Protocol choice
Uses the built-in Stellar Federation protocol (SEP-0002) via the
@stellar/stellar-sdk FederationServer already in the project. No new
runtime dependency added. .xlm shorthand names are translated to
alice*stellarnames.org federation lookups (documented in the code so
the mapping is easy to swap).

### frontend/lib/stellar.ts
- Added ResolvedName interface (name, address, resolvedAt) for the cache
- Replaced the previous opaque cache shape with ResolvedName entries
- Rewrote resolveStellarName with full JSDoc: .xlm -> federation mapping
  explained, raw G... bypass, TTL cache using resolvedAt timestamp
- Exported clearNameCache() helper for tests
- Added full JSDoc to isStellarName

### frontend/components/SendPaymentForm.tsx
- Imports isStellarName and resolveStellarName from lib/stellar
- New snsResolvedAddress / snsResolving state for the destination field
- useEffect with 400ms debounce triggers resolveStellarName whenever the
  destination matches isStellarName(); cancels on cleanup
- Inline spinner (aria-live) shown while resolving
- 'Resolves to: GABC...XYZ' confirmation line shown on success
- Inline red error shown on failure; submit blocked until fixed
- canSubmit gates on !snsResolving and requires snsResolvedAddress for
  SNS names so raw name strings are never submitted
- resolveDestinationForPayment prefers the already-resolved snsResolvedAddress
  to avoid a redundant second lookup at submit time
- SNS state cleared on destination change, contact select, and form reset

### frontend/pages/settings.tsx
- Fixed bug: SNS card was accidentally nested inside the Mainnet Warning
  Modal div — moved it out as a standalone settings card
- Card explains .xlm names, Federation protocol, StellarNames provider,
  10-min cache TTL, and the stellar.toml limitation
- Links directly to stellarnames.org registration (opens in new tab)

### Tests (frontend/__tests__/)
- resolveStellarName.test.ts — isStellarName, resolveStellarName:
  raw bypass, successful .xlm and federation resolution, cache hit/miss,
  TTL expiry, clearNameCache, error propagation, no caching of failures
- SendPaymentFormSNS.test.tsx — spinner during resolution, resolved
  address shown, error shown + submit blocked, submit uses resolved
  address not typed name, raw G... skips resolution
- settingsSNS.test.tsx — section renders, .xlm copy present, link to
  stellarnames.org with target=_blank, limitation disclaimer visible,
  card is not inside the modal

## Limitations
Resolution depends on the recipient's domain publishing a valid
stellar.toml; names not registered with a federation server will fail
to resolve (documented in the UI).
@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

@udeachudivine-spec is attempting to deploy a commit to the Emmanuel's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Emmy123222
Emmy123222 merged commit 0d6bcb9 into Emmy123222:main Jul 28, 2026
6 of 15 checks passed
render(<SettingsPage {...defaultProps} />);
const links = screen
.getAllByRole("link")
.filter((el) => el.getAttribute("href")?.includes("stellarnames.org"));
render(<SettingsPage {...defaultProps} />);
const link = screen
.getAllByRole("link")
.find((el) => el.getAttribute("href")?.includes("stellarnames.org") && el.textContent?.includes("Register"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants