Feat/four sdk improvements - #570
Open
petermuazu wants to merge 4 commits into
Open
Conversation
- Add src/invoiceHashVerifier.ts with hashInvoice() and verifyInvoiceHash() - Produce deterministic SHA-256 hashes of canonically serialised invoices - Add InvoiceIntegrityError to src/errors.ts - Integrate with client.ts submitPayment() for pre-payment hash verification - Add verifyInvoice() convenience method to StellarSplitClient - Export new module and types from src/index.ts - Add 9 unit tests covering identical objects, mutated fields, and mismatch detection
- Add src/currencyNormalizer.ts with normalizeAmount() and toOnChainAmount() - Handle asset-specific decimal precisions (XLM native + custom tokens) - Throw PrecisionError when conversion would lose sub-unit precision - Add registerAssetPrecision() for custom token decimals - Add verifyRoundTrip() for safe display↔on-chain round-trip checking - Export all normalizer functions from src/index.ts - Add 11 unit tests including round-trip property tests
- Add src/feeBumpBuilder.ts with buildFeeBump() for fee bump envelopes - Validate v1 transaction type with InvalidTransactionTypeError - Support optional surge multiplier config - Add validateFeeSourceReadiness() via preflightChecker integration - Add submitWithFeeBump() convenience method to StellarSplitClient - Export buildFeeBump, feeBumpToXDR, and FeeBumpConfig from index.ts - Add 4 integration tests for fee bump construction and XDR validation
- Extend src/poller.ts with InvoiceStatusPoller class - Emit invoiceStatusChanged events via typed event emitter - Auto-stop on terminal states (Released, Refunded, Cancelled) - Coalesce concurrent polls for the same invoice ID - Support onSettled callback and maxAttempts limit - Add static stopAll() to cancel all active pollers - First poll fires immediately, subsequent at configurable interval - Export InvoiceStatusPoller and related types from src/index.ts - Add 8 unit tests for polling lifecycle and coalescing
|
@petermuazu 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 #492
Closes #493
Closes #503
Closes #505
The SDK lacks a dedicated manager that polls Horizon for invoice-linked transaction status at configurable intervals and emits typed state-change events. Callers currently implement ad-hoc polling loops that drift, overlap, or silently stall when a tab loses focus. A centralized polling manager should debounce concurrent polls, honour a per-invoice TTL, and stop automatically once a terminal state (paid, expired, cancelled) is reached.
Technical Context
Primary implementation lives in src/poller.ts (extend or subclass the existing poller). Publishes status events through src/events.ts. Uses InvoiceStatus and InvoiceRecord from src/types.ts. Integrates with src/client.ts getInvoice() and Horizon's TransactionRecord via @stellar/stellar-sdk Server.transactions(). Poll state should persist across tab visibility changes via src/tabSync.ts.