Skip to content

feat(transactions): implement monitorTransaction polling loop#136

Open
ExcelDsigN-tech wants to merge 1 commit intoamina69:mainfrom
ExcelDsigN-tech:feat/tx-monitor-transaction-polling
Open

feat(transactions): implement monitorTransaction polling loop#136
ExcelDsigN-tech wants to merge 1 commit intoamina69:mainfrom
ExcelDsigN-tech:feat/tx-monitor-transaction-polling

Conversation

@ExcelDsigN-tech
Copy link
Copy Markdown

[Feat] Implement monitorTransaction polling loop for transaction builders (Closes #121)

Overview

This PR introduces the monitorTransaction utility within the SDK, providing a robust mechanism for polling the Horizon network until a transaction reaches a terminal state (confirmed, failed, or timed out). This is a core component of the Transaction Builders epic, ensuring reliable feedback for asynchronous Stellar operations.

Feature Summary

  • Polling Engine: Implemented monitorTransaction with configurable maxAttempts and intervalMs to track transaction lifecycle.
  • Smart Backoff: Added exponential backoff logic that triggers after 5 consecutive "not found" responses to optimize network overhead.
  • Status Resolution: Calculates ledger confirmations (currentLedger - txLedger) and returns standardized TransactionStatus objects.
  • Error Handling: Introduced MonitorTimeoutError for exceeded attempts and explicit failure states for rejected transactions.

Technical Implementation

The implementation centers on a polling loop that leverages a new internal fetchTransactionOnce helper. The loop manages state transition from "not found" to "terminal" while respecting the exponential backoff window. It is designed to be CI-friendly and integrates directly into the package entrypoint for consumer accessibility.

Test Coverage

  • Resilience Testing: Verified successful resolution on the 3rd attempt after initial "not found" states.
  • Exception Handling: Confirmed MonitorTimeoutError triggers correctly using Jest fake timers.
  • Logic Validation: Validated confirmation count math and failure state mapping for rejected transactions.

Checklists

  • Implement monitorTransaction with configurable retry options
  • Add fetchTransactionOnce for atomic Horizon lookups
  • Integrate exponential backoff for persistent "not found" scenarios
  • Export transaction monitoring utilities from the SDK entrypoint
  • Pass lint, type-check, and unit-test suites

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 29, 2026

@ExcelDsigN-tech 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

@amina69
Copy link
Copy Markdown
Owner

amina69 commented Mar 30, 2026

@ExcelDsigN-tech you are making pr to the wrong branch, read the conributing.md

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.

[SDK · Transaction builders] Implement monitorTransaction() — polling loop

2 participants