feat: four SDK improvements — split ratio validator, trustline checker, XDR parser, fee surge detector - #573
Open
Prasiejames wants to merge 6 commits into
Open
feat: four SDK improvements — split ratio validator, trustline checker, XDR parser, fee surge detector#573Prasiejames wants to merge 6 commits into
Prasiejames wants to merge 6 commits into
Conversation
Adds src/validators/splitRatioValidator.ts to catch ratio-sum violations, negative shares, duplicate recipient addresses, and zero-weight entries early with structured error objects, before Horizon submission. Integrates into createInvoice() in client.ts, splitPreview.ts, and exports from index.ts with new types in types.ts.
Adds src/trustlineChecker.ts to verify every recipient in a split invoice has the required trustline before building the payment transaction. Uses Horizon Server.loadAccount() to inspect balances for matching asset_code/asset_issuer, surfacing a per-recipient report. Integrates into client.validatePayment() as an additional check.
Adds src/xdrParser.ts to decode any base64-encoded TransactionEnvelope into a structured, human-readable ParsedEnvelope with operations, signers, memo, fee, and time bounds. Integrates into client.ts as parseXdrEnvelope() debug helper, gated behind config.debug flag.
Adds src/feeSurgeDetector.ts to monitor real-time ledger fee statistics via Horizon and automatically recommend adjusted fee multipliers during network congestion. Uses Horizon Server.feeStats() for p10/p50/p95 percentiles. Integrates into txBuilder.ts for surge-adjusted fees before signing. Re-exported from feeEstimator.ts.
- Add new types (RecipientShare, SplitConfig, TrustlineEntry, TrustlineCheckResult, ParsedEnvelope, ParsedTransaction, ParsedOperation, ParsedMemo, ParsedSignature, ParsedTimeBounds, FeeSurgeConfig, FeeRecommendation, CongestionLevel) to types.ts - Wire split ratio validation into client.createInvoice() - Wire trustline check into client.validatePayment() - Add debug flag and parseXdrEnvelope() to client config - Add fee surge config option to StellarSplitClientConfig - Enable surge detection in StellarSplitTxBuilder.submit() - Export all new modules from index.ts - Re-export surge detector from feeEstimator.ts
feat: four SDK improvements — split ratio validator, trustline checker, XDR parser, fee surge detector
|
@Prasiejames 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 #494
Closes #495
Closes #496
Closes #497
Summary
This PR adds four new SDK features:
1. Pre-submission Split Ratio Validator (
src/validators/splitRatioValidator.ts)Catches ratio-sum violations, negative shares, duplicate recipient addresses, and zero-weight entries early with structured error objects, before Horizon submission. Integrated into
client.createInvoice()andsplitPreview.ts.2. Proactive Trustline Checker (
src/trustlineChecker.ts)Verifies every recipient in a split invoice has the required trustline before building the payment transaction. Uses Horizon
Server.loadAccount()to inspect balances for matchingasset_code/asset_issuer, surfacing a per-recipient report. Integrated intoclient.validatePayment().3. Typed XDR Envelope Parser (
src/xdrParser.ts)Decodes any base64-encoded
TransactionEnvelopeinto a structured, human-readableParsedEnvelopewith operations, signers, memo, fee, and time bounds. Integrated as a debug helperclient.parseXdrEnvelope(), gated behindconfig.debug.4. Fee Surge Detector (
src/feeSurgeDetector.ts)Monitors real-time ledger fee statistics via Horizon and automatically recommends adjusted fee multipliers during network congestion. Uses
Horizon.Server.feeStats()for p10/p50/p95 percentiles. Integrated intoStellarSplitTxBuilder.submit()for surge-adjusted fees before signing.Commits
89c70fffeat: add pre-submission split ratio validator60ac9a5feat: add proactive trustline checker for non-XLM asset payments1a815bafeat: add typed XDR envelope parser for debugging and audit logging28ce026feat: add fee surge detector with Horizon fee-stats monitoringadad0bdchore: integrate all four new modules into SDK surface