Skip to content

feat(react): add hooks for contract events, account sequence, contract TTL, and rate limit status - #1281

Open
maccoder374-sudo wants to merge 1 commit into
BCPathway:mainfrom
maccoder374-sudo:feat/batch-1195-1196-1197-1199
Open

maccoder374-sudo wants to merge 1 commit into
BCPathway:mainfrom
maccoder374-sudo:feat/batch-1195-1196-1197-1199

Conversation

@maccoder374-sudo

Copy link
Copy Markdown

Summary of Changes

This PR introduces four React hooks for interacting with and monitoring Soroban contracts and account status on Stellar, closing Phase 3 issues:

  1. useContractEvents (Closes [Phase 3] Build useContractEvents Hook for Event Topics #1195):

    • Hook to query, normalize, and filter contract event topics (transfer, mint, burn, role_granted, or custom topic strings).
    • Supports pagination limits, start ledger filtering, configurable polling intervals, and manual refetching.
  2. useAccountSequence (Closes [Phase 3] Build useAccountSequence Hook for Nonce Tracking #1196):

    • Hook to retrieve and track current account sequence numbers and compute nextSequence (sequence + 1n).
    • Supports optimistic sequence incrementing (incrementSequence) for chaining transactions without awaiting immediate ledger confirmation, and sequence mismatch recovery (handleSequenceMismatch).
  3. useContractTtl (Closes [Phase 3] Build useContractTtl Hook to Monitor Expiration #1197):

    • Hook to inspect contract instance and storage entry time-to-live metrics (currentLedger, liveUntilLedgerSeq, ledgersRemaining).
    • Flags low-TTL renewal warnings (isLowTtl) based on configurable threshold ledgers (default 50 ledgers).
  4. useRateLimitStatus (Closes [Phase 3] Build useRateLimitStatus Hook for Guard State #1199):

    • Hook to read rate limit guard state for an account and operation.
    • Monitors window limits, volume usage, remaining quota, cooldown intervals, and active throttling status (isThrottled).

SDK Support

  • Added getAccountSequence, getContractTtl, and getRateLimitStatus to bcForgeClient and MockBcForgeClient in @bc-forge/sdk.

Verification

  • Full test suite passed: 16 test suites, 180 tests in @bc-forge/react (npm test --workspace @bc-forge/react).
  • Clean build across packages (npm run build --workspace @bc-forge/sdk && npm run build --workspace @bc-forge/react).

…t TTL, and rate limit status

- Implement useContractEvents hook with topic filtering, pagination limits, and polling (Closes BCPathway#1195)
- Implement useAccountSequence hook with optimistic sequence increments and mismatch recovery (Closes BCPathway#1196)
- Implement useContractTtl hook with expiration warning threshold monitoring (Closes BCPathway#1197)
- Implement useRateLimitStatus hook with quota, cooldown, and throttling status (Closes BCPathway#1199)
- Add supporting client and mockClient methods across @bc-forge/sdk
- Add comprehensive test coverage in @bc-forge/react
@drips-wave

drips-wave Bot commented Oct 18, 2026

Copy link
Copy Markdown

@maccoder374-sudo 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

This branch has not been deployed

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

Labels

None yet

Projects

None yet

1 participant