Repository navigation
feat: offline tx building, batch operations, currency conversion, and request retry - #1155
Open
orsar-rita wants to merge 1 commit into
Open
orsar-rita wants to merge 1 commit into
orsar-rita wants to merge 1 commit into
Conversation
…and request retry - Implement configurable request timeout and exponential backoff retry logic with jitter and error classification (Stellar-split#1030) - Implement currency conversion utilities with exchange rate providers, validation, and TTL caching (Stellar-split#1031) - Add batch operation support with fluent builder, validation, executor, and atomic transaction guarantees (Stellar-split#1032) - Implement offline transaction building, signing support, and sound round-trip serialization (Stellar-split#1033) - Export new features in SDK entry point and add comprehensive unit test suites
|
@orsar-rita 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 branch has not been deployed
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.
What this fixes
This pull request resolves four related core SDK capabilities:
Network calls to Soroban RPC or Horizon endpoints lacked unified configurable timeout deadlines and exponential backoff retry policies. Transient hiccups, 429 rate limits, and 503 service unavailable responses could fail requests immediately without automatic recovery.
Display and invoice calculation components lacked a robust, general-purpose currency conversion engine supporting external exchange rate providers, inverse rate derivation, cross-currency triangulation (e.g. through USD or XLM), rigorous input validation, and TTL-based caching.
Submitting multiple transactions sequentially caused excessive latency, non-atomic partial execution risks, and elevated transaction fees. Batching multiple operations into a single atomic Stellar transaction envelope was not systematically supported with validation and fee aggregation.
Cold-storage, air-gapped devices, and offline signing workflows require constructing, validating, and signing transactions without network connectivity, along with lossless serialization for transport.
What changed
1. Request Timeout & Exponential Backoff Retry (#1030)
src/requestRetry.tsimplementingRequestRetryManager,executeWithTimeoutAndRetry, andcalculateBackoffDelay.AbortController, aborting requests that exceed deadlines and throwingRequestTimeoutError.baseDelayMs,maxDelayMs,backoffMultiplier, and proportional or full random jitter.maxRetries/maxAttempts), throwingMaxRetriesExceededErrorwith context when attempts are exhausted.2. Currency Conversion Utilities (#1031)
src/currencyConverter.tswith theCurrencyConverterclass andconvertCurrencyfunctional helper.ExchangeRateProviderfunctions andPriceOracleAdapterinstances.1 / rate) and multi-hop cross-currency triangulation via base currencies (e.g.USD).PriceOracleAdapterinterface definition incurrencyConverter.ts.3. Batch Operation Support (#1032)
src/batchOperations.tsimplementingBatchOperationBuilderandBatchExecutor.manageData), trustlines (changeTrust), and custom contract operations into a single batch.Transactionwith automated base fee scaling (BASE_FEE * opCount).4. Offline Transaction Building (#1033)
src/offlineTransaction.tsimplementingOfflineTransactionBuilderrequiring zero network access.Keypairor secret seed strings, supporting multi-signature collection and cryptographic signature verification against the transaction hash.OfflineTxPackageJSON packages for air-gapped transport.5. SDK Entry Point & Tests
src/index.ts.test/requestRetry.test.ts,test/currencyConverter.test.ts,test/batchOperations.test.ts, andtest/offlineTransaction.test.ts.Testing
All tests were executed and passed cleanly:
test/requestRetry.test.ts(15 tests passed)test/currencyConverter.test.ts(20 tests passed)test/batchOperations.test.ts(12 tests passed)test/offlineTransaction.test.ts(13 tests passed)npm run test(110 tests passed)test/timeout.test.ts,test/retryPolicy.test.ts,test/currencyNormalizer.test.ts(55 tests passed)Issues
closes #1030
closes #1031
closes #1032
closes #1033