Skip to content

feat(stellar): SEP-0002 federation address resolver#111

Open
AJtheManager wants to merge 1 commit into
wraith-protocol:developfrom
AJtheManager:addd
Open

feat(stellar): SEP-0002 federation address resolver#111
AJtheManager wants to merge 1 commit into
wraith-protocol:developfrom
AJtheManager:addd

Conversation

@AJtheManager

Copy link
Copy Markdown

Implementation complete.

Added sdk/src/chains/stellar/federation.ts (~300 lines) implementing SEP-0002 federation resolution:

  • resolveStellarFederation(input, options?) — splits name*domain.tld, fetches https:///.well-known/stellar.toml (SEP-0001), extracts FEDERATION_SERVER, queries it, validates account_id with StrKey, returns { accountId, stellarAddress, memo?, resolvedAt }. Pass-through for valid G… / M… inputs.
  • In-memory cache keyed by federation address with a configurable TTL (default 1h). clearFederationCache, setFederationDefaultTtl, getFederationDefaultTtl exposed.
  • FederationResolutionError with discriminated code: INVALID_ADDRESS, TOML_FETCH_FAILED, FEDERATION_SERVER_MISSING, FEDERATION_SERVER_FAILED, INVALID_RESPONSE, TIMEOUT, INSECURE_PROTOCOL.
  • AbortController-based timeout (default 10s). HTTPS enforced unless allowInsecureHttp: true. Injectable fetchImpl for tests/proxies.

Tests sdk/test/chains/stellar/federation.test.ts:

  • 19 unit tests with mocked fetch covering happy path, memo handling, cache hit/miss/TTL expiry/noCache/cacheTtlMs: 0, G-address passthrough, every error code, timeout via signal abort, and the error class itself. All pass.
  • Opt-in integration test gated on FEDERATION_INTEGRATION=1 + FEDERATION_ADDRESS= (optional FEDERATION_EXPECTED_ACCOUNT). Skipped by default — same pattern used by multisig.integration.test.ts / swap.integration.test.ts.

closes #78

resolveStellarFederation() lets stealth payment senders accept
name*domain.tld addresses by fetching .well-known/stellar.toml,
querying FEDERATION_SERVER, validating the response, and caching
the result. HTTPS-only by default, configurable TTL, injectable
fetch for tests.
@truthixify

Copy link
Copy Markdown
Contributor

Conflict on pnpm-lock.yaml after #110 (TypeDoc) just landed. Quick rebase:

git fetch origin
git rebase origin/develop
pnpm install
git add pnpm-lock.yaml
git rebase --continue
git push --force-with-lease

Federation code itself looks clean — just the lockfile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stellar federation address resolution helper

2 participants