Skip to content

Feat/four sdk improvements - #570

Open
petermuazu wants to merge 4 commits into
Stellar-split:mainfrom
petermuazu:feat/four-sdk-improvements
Open

Feat/four sdk improvements#570
petermuazu wants to merge 4 commits into
Stellar-split:mainfrom
petermuazu:feat/four-sdk-improvements

Conversation

@petermuazu

Copy link
Copy Markdown

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.

- 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
@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invoice Content Hash Verifier Fee Bump Transaction Wrapper Multi-Currency Amount Normalizer Invoice Status Polling Manager

1 participant