feat(stellar): federation address resolution via SEP-0002#104
Open
AJtheManager wants to merge 1 commit into
Open
feat(stellar): federation address resolution via SEP-0002#104AJtheManager wants to merge 1 commit into
AJtheManager wants to merge 1 commit into
Conversation
Add resolveStellarFederation() and FederationResolver implementing Stellar federation (SEP-0002): two-step stellar.toml discovery + federation server query, typed FederationError codes, 1-hour in-memory cache with invalidate/clear, injectable fetch for testing, and * force-encoded as %2A. Fix pre-existing build blockers: add missing computeAnnouncementViewTag() to stealth.ts, repair corrupted fetchAnnouncementsStream body and parseAnnouncementEvent dispatcher in announcements.ts, remove duplicate exports from index.ts, update fee-estimation.ts to use rpc.Api / Horizon.HorizonApi namespaces from stellar-sdk v13, fix btoaPolyfill bit-manipulation bug, and format all files with Prettier.
|
@AJtheManager Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
The actual federation work (SEP-2 resolution for sdk #78) is in there, but this PR has the same agent-generated cruft files that have been blocking #95, #97, and #99:
Plus there are now real merge conflicts because audit changes landed in develop while this branch was open. git fetch origin
git rebase origin/develop
git rm BENCHMARK_IMPLEMENTATION.md CONTEXT_BENCHMARKS_COMPLETE.md docs/fee-estimation.md
git rm -r bench/ examples/react-native-stellar/
git rm .github/workflows/benchmark.yml
git rm src/chains/stellar/fee-estimation.ts src/compat/react-native.ts
# Resolve announcements.ts / index.ts conflicts by keeping develop's version and re-applying your federation work
git push --force-with-leaseThe actual federation resolution code in announcements.ts + the SEP-2 implementation is what we want — just drop the rest. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolveStellarFederation()andFederationResolverimplementing the two-step SEP-0002 lookup (stellar.toml → federation server query)New: Federation Helper (
src/chains/stellar/federation.ts)Resolves human-readable Stellar addresses (
name*domain.com) to account IDs and optional memos.API surface
Resolution flow (SEP-0002)
name*domain.comformatGET https://<domain>/.well-known/stellar.toml→ extractFEDERATION_SERVERGET <FEDERATION_SERVER>?q=<address>&type=name→ parseaccount_id+ optionalmemoDate.now() + cacheTtlKey design decisions
*is force-encoded as%2Ain the query string (encodeURIComponentleaves it unencoded)Alice*Example.comandalice*example.comhit the same cache slotFEDERATION_SERVERmust behttps://; non-HTTPS URLs throwTOML_PARSE_FAILED?version=2&q=…)globalThis.fetchby defaultTyped error codes
INVALID_ADDRESS*, multiple*, no.in domain, whitespaceTOML_FETCH_FAILEDTOML_PARSE_FAILEDFEDERATION_SERVERmissing, invalid URL, or non-HTTPSNO_FEDERATION_SERVERNOT_FOUNDFEDERATION_FETCH_FAILEDINVALID_RESPONSEaccount_id, unknownmemo_type, non-JSON bodyExports added to
@wraith-protocol/sdk/chains/stellarTests
test/chains/stellar/federation.test.ts— 36 unit tests, all HTTP mocked%2Aencoding, cache hit/miss,invalidate,clear, case normalisation,cacheTtl: 0text,id,hash), partial memo (only one field present → no memo)test/chains/stellar/federation.integration.test.ts— skipped by default, opt-in withINTEGRATION=1demo*testanchor.stellar.orgagainst live testnetNOT_FOUNDfor a non-existent addressPre-existing bug fixes
These were all latent defects on the branch before this PR — none introduced by the federation work. They were fixed because the pre-commit hook (
format:check && build && test) blocked the commit.src/chains/stellar/stealth.ts— added missingcomputeAnnouncementViewTagThe v2 view tag function was called in both
stealth.tsandscan.tsbut never defined, causing aReferenceErrorthat broke every stealth/scan/e2e test. The function hashes the ephemeral and viewing public keys with awraith:stellar:view-tag:v2:domain prefix so senders and recipients derive the same tag without exposing the ECDH shared secret.src/chains/stellar/announcements.ts— repaired two corruption sitesFetchAnnouncementsOptionsinterface and an incompletefetchAnnouncementsfunction body (from an old refactor) left a JSDoc comment orphaned inside a function body — Prettier could not parse the file at all.fetchAnnouncementsStreamcontained an unclosedif (!bypassCache) {block that referenced undefined variables (bypassCache,cache,network), causingfetchRange,getSorobanLedgerWindow, and all helpers below it to be silently nested inside the generator rather than defined at module scope. Reconstructed a clean streaming implementation.parseAnnouncementEventhad its old inline body followed by unreachable dispatcher code (if (topics.length === 3) …) after areturnstatement. Replaced with the correct v1/v2 dispatcher.src/chains/stellar/index.ts— removed duplicate exportsDuplicate
fetchAnnouncementsandFetchAnnouncementsOptionsexports caused TypeScriptDuplicate identifiererrors that blocked the DTS build entirely.src/chains/stellar/fee-estimation.ts— updated SDK namespace referencesSoroban.Api.*→rpc.Api.*andHorizon.FeeStatsResponse→Horizon.HorizonApi.FeeStatsResponseto match the@stellar/stellar-sdk@13export structure. Also replaced theSorobanRpcdynamic import withrpc.src/compat/react-native.ts— fixedbtoaPolyfillThe original bit-manipulation loop produced wrong output (
btoa('hello')→'AAAGVsb'instead of'aGVsbG8='). Replaced with a standard 3-byte-group → 4-char encoding loop.test/chains/stellar/scan.test.ts— added missing importscomputeAnnouncementViewTag,computeSharedSecret,computeViewTag(from./stealth) andscanAnnouncementsLegacySharedSecretTag(from./scan) were called in the test file but never imported.Test results
All tests green. Integration tests skipped by default (require
INTEGRATION=1).closes #78