Skip to content

feat(react): implement useTransactionSubmission lifecycle hook (#1193) - #1277

Open
Ariyagold wants to merge 2 commits into
BCPathway:mainfrom
Ariyagold:feature/1193-build-usetransactionsubmission-hook-with-retry-and-status-tracking
Open

Ariyagold wants to merge 2 commits into
BCPathway:mainfrom
Ariyagold:feature/1193-build-usetransactionsubmission-hook-with-retry-and-status-tracking

Conversation

@Ariyagold

Copy link
Copy Markdown

Summary

Implements the useTransactionSubmission lifecycle hook to manage Soroban smart contract transaction states (idle -> simulating -> signing -> submitting -> confirmed | failed), including automatic and manual retries, ledger inclusion polling, Soroban contract error decoding, and unmount cleanup.

Closes #1193
Closes #1192
Closes #1191
Closes #1190

Changes Made

  • Transaction Lifecycle Hook (react/src/hooks.ts):
    • Implemented useTransactionSubmission with granular status tracking: 'idle' | 'simulating' | 'signing' | 'submitting' | 'confirmed' | 'failed'.
    • Added support for both callback-based execution (with markSimulating, markSigning, markSubmitting lifecycle markers) and staged descriptors (simulate, sign, send, pollStatus).
    • Integrated with BcForgeProvider (useOptionalBcForgeClient) and WalletProvider (useWallet), enforcing wallet connection checks, hardware wallet signature timeouts (signWithTimeout), and client cache invalidation (clearCache) on confirmation.
    • Added decodeTransactionError to map Soroban token and admin contract numeric errors (Error(Contract, #N)) and wallet signature rejections into clear, user-friendly error messages.
    • Implemented automatic retry logic for transient RPC/network errors, manual retry(), manual refetch() for ledger confirmation polling, reset(), and safe timer/state cleanup on unmount.
  • Unit Tests (react/src/hooks.test.tsx):
    • Added comprehensive unit test coverage for useTransactionSubmission and decodeTransactionError, covering status transitions, ledger polling, wallet connection guards, contract error decoding, user signature rejection, automatic/manual retries, and unmount cleanup.
  • Documentation (react/README.md):
    • Added useTransactionSubmission and decodeTransactionError to the exported hooks list.

Acceptance Criteria Checklist

  • Tracks status transitions: 'idle' -> 'simulating' -> 'signing' -> 'submitting' -> 'confirmed' | 'failed'.
  • Fully typed interfaces and exports with strict TypeScript compliance (noImplicitAny, strict null checks).
  • Edge cases (unauthenticated states, network errors, rejected transactions, Soroban contract errors) trigger helpful UI alert messages rather than unhandled exceptions.
  • Clean code documentation with JSDoc comments explaining props, state transitions, and hooks.
  • Unit tests added and

@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@Ariyagold 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

@Ariyagold

Copy link
Copy Markdown
Author

@p3ris0n , pls review pr

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