feat: Sequence Cache, Path Router, Offer Tracker & Claimable Balance Lifecycle - #574
Open
micmusjnr20 wants to merge 5 commits into
Open
feat: Sequence Cache, Path Router, Offer Tracker & Claimable Balance Lifecycle#574micmusjnr20 wants to merge 5 commits into
micmusjnr20 wants to merge 5 commits into
Conversation
…nce numbers - Add src/sequenceCache.ts: wraps Horizon loadAccount() with local sequence-number incrementing to eliminate round-trip latency per payment operation under high-frequency split invoice submissions. - Inject SimpleCache for TTL-based eviction of stale entries. - Add isSequenceTooOld() helper to detect SEQUENCE_NUMBER_TOO_OLD submission errors and trigger cache invalidation. - Integrate with txBuilder.ts via submitWithSequence() and buildWithSequence() to skip loadAccount() when cached. - Add SequenceCacheError and SequenceNumberTooOldError to errors.ts. - Add SplitConfig and RecipientShare types. - Export SequenceCache and isSequenceTooOld from index.ts.
…e balances - Extend src/claimableBalanceFallback.ts with ClaimableBalanceLifecycle class that tracks the create-to-claim lifecycle of claimable balances. - Polls Horizon for status changes and emits balanceClaimed and balanceExpired typed events via TypedEventEmitter. - Exposes claimBalance() to submit claimClaimableBalance operations. - Exposes queryByClaimant() to list all pending balances for a claimant. - Add ClaimableBalanceRecord and ClaimableBalanceStatus to types.ts. - Add ClaimableBalanceLifecycleError to errors.ts. - Export ClaimableBalanceLifecycle and related types from index.ts.
- Add src/pathRouter.ts: queries Horizon strictSendPaths and strictReceivePaths to find optimal DEX conversion paths when payer and recipients use different Stellar assets. - Caches path results via SimpleCache to avoid redundant queries. - Exposes buildPathPaymentStrictSend/buildPathPaymentStrictReceive helpers to construct path-payment operations. - Integrates with txBuilder.ts via addPathPaymentStrictSend and addPathPaymentStrictReceive methods. - Add PathNotFoundError and PathRouterError to errors.ts. - Export PathRouter, PathResult, PathHop, PathRequest, PathRouterConfig from index.ts.
- Add src/offerTracker.ts: monitors outstanding DEX offers placed during split-payment conversions, detects fill progress via Horizon polling, and emits typed events (offerFilled, offerPartiallyFilled, offerCancelled). - Auto-detects stale offers past a configurable threshold. - Exposes cancelOffer() to submit cancellation transactions. - Uses TypedEventEmitter for strongly-typed event dispatch. - Add OfferRecord and OfferStatus to types.ts. - Add OfferTrackingError to errors.ts. - Export OfferTracker, OfferTrackerConfig, OfferTrackerEventMap from index.ts.
…able feat: Sequence Cache, Path Router, Offer Tracker & Claimable Balance Lifecycle
|
@micmusjnr20 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! 🚀 |
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.
Closes #498
Closes #499
Closes #500
Closes #501
Summary
This PR adds four new SDK modules that improve transaction throughput, enable cross-asset payments, track DEX offer lifecycles, and manage claimable balance lifecycles.
1. Sequence Cache (
src/sequenceCache.ts)Prefetches account sequence numbers from Horizon, increments them locally, and eliminates a round-trip latency per payment under high-frequency split invoice submissions.
SequenceCache.getSequence(accountId)returns the next sequence number without a Horizon callSEQUENCE_NUMBER_TOO_OLDerrors viaisSequenceTooOld()txBuilder.submitWithSequence()andtxBuilder.buildWithSequence()SimpleCachefor TTL-based eviction2. Path Router (
src/pathRouter.ts)Routes cross-asset payments through Stellar's DEX by querying Horizon
strictSendPaths/strictReceivePathsto find optimal conversion paths.findStrictSendPath()/findStrictReceivePath()return the cheapest path with estimated amountsSimpleCachewith per-asset-pair TTLPathPaymentStrictSend/PathPaymentStrictReceiveoperationstxBuilderviaaddPathPaymentStrictSend/addPathPaymentStrictReceive3. Offer Tracker (
src/offerTracker.ts)Monitors outstanding DEX offers, detects fill progress via Horizon polling, and emits typed lifecycle events.
offerFilled,offerPartiallyFilled,offerCancelledevents viaTypedEventEmittercancelOffer()submits cancellation transactionsOfferRecordandOfferStatustypes4. Claimable Balance Lifecycle (extended
src/claimableBalanceFallback.ts)Tracks claimable balances from creation through claim/expiry with Horizon polling and typed event emission.
ClaimableBalanceLifecycleclass withstart()/stop()pollingbalanceClaimedandbalanceExpiredtyped eventsclaimBalance()submitsclaimClaimableBalanceoperationsqueryByClaimant()lists all pending balances for a claimantClaimableBalanceRecordandClaimableBalanceStatustypesFiles Changed
src/sequenceCache.tssrc/pathRouter.tssrc/offerTracker.tssrc/claimableBalanceFallback.tssrc/txBuilder.tssrc/types.tssrc/errors.tssrc/index.tssrc/client.ts