Description
Stellar federation allows users to pay to human-readable addresses like alice*example.com instead of raw public keys. The SDK's formatAmount and related helpers work with public keys directly but have no support for resolving federation addresses before payment, requiring consumers to implement this outside the SDK. This issue adds a FederationResolver that looks up *-format addresses via SEP-2 federation servers with response caching to reduce redundant DNS and HTTP calls.
Technical Context
- New file:
src/federation/FederationResolver.ts; uses @stellar/stellar-sdk's StellarSdk.FederationServer.resolve() under the hood
- Resolved entries are cached with a TTL (default: 300 000 ms) in the standard SDK storage abstraction keyed as
fed:{address}
FederationResolver.resolve(address: string): Promise<FederationRecord> accepts both federation format (*) and raw public keys (passed through as-is)
FederationRecord: { stellarAddress: string; accountId: string; memoType?: string; memoValue?: string }
SplitClient.createInvoice() and addRecipient() accept federation addresses and resolve them transparently before writing to the invoice
Acceptance Criteria
Description
Stellar federation allows users to pay to human-readable addresses like
alice*example.cominstead of raw public keys. The SDK'sformatAmountand related helpers work with public keys directly but have no support for resolving federation addresses before payment, requiring consumers to implement this outside the SDK. This issue adds aFederationResolverthat looks up*-format addresses via SEP-2 federation servers with response caching to reduce redundant DNS and HTTP calls.Technical Context
src/federation/FederationResolver.ts; uses@stellar/stellar-sdk'sStellarSdk.FederationServer.resolve()under the hoodfed:{address}FederationResolver.resolve(address: string): Promise<FederationRecord>accepts both federation format (*) and raw public keys (passed through as-is)FederationRecord:{ stellarAddress: string; accountId: string; memoType?: string; memoValue?: string }SplitClient.createInvoice()andaddRecipient()accept federation addresses and resolve them transparently before writing to the invoiceAcceptance Criteria
resolve('alice*example.com')returns the correctaccountIdfrom a mocked federation HTTP responseG...) are returned as-is without an HTTP call being maderesolve('alice*example.com')within the TTL window uses the cache and makes zero HTTP requestscreateInvoice()with a federation address recipient resolves to the underlying public key before writing theInvoiceobject