Skip to content

Complete the wallet transaction lifecycle (build XDR, sign, submit, confirm) on top of useWallet #208

@greatest0fallt1me

Description

@greatest0fallt1me

Description

hooks/useWallet.hook.ts exposes signTransaction(xdr) via @creit.tech/stellar-wallets-kit (it returns signedTxXdr for the testnet passphrase), but there is no code anywhere that builds an XDR, submits the signed transaction, or confirms it — a repo-wide search finds signTransaction defined and never called. This issue adds the surrounding lifecycle so a signed transaction can actually be broadcast and tracked to confirmation, completing the connect-to-confirm path begun by WalletContext/useWallet.

Requirements and context

  • Add a typed transaction module (e.g. lib/stellar/transaction.ts) with a submitTransaction(signedXdr) step and a pollForConfirmation(hash) step targeting the configured network from lib/config.ts (stellar.network).
  • Extend useWallet (or add a useTransaction hook) to orchestrate build -> signTransaction -> submit -> confirm, surfacing a discriminated status (idle | signing | submitting | confirming | success | failed) and the resulting hash/error.
  • Provide toast feedback via the already-wired sonner toaster and reuse the hook's existing error reporting pattern.
  • Non-functional: handle user-rejected signing, submission failures, and confirmation timeouts distinctly; never block the UI thread; do not hardcode the network passphrase (derive from config rather than the literal WalletNetwork.TESTNET).
  • Keep the change additive — existing connectWallet/disconnectWallet behavior must not regress.

Acceptance criteria

  • A typed submit + confirmation module exists and reads the network from lib/config.ts.
  • The orchestration hook exposes an explicit status state machine and a final hash/error.
  • User-rejected sign, submit failure, and confirmation timeout are handled as distinct outcomes.
  • The network passphrase is derived from config, not hardcoded to testnet.
  • Existing connect/disconnect flows are unchanged.
  • New modules/hooks reach >=85% line coverage.

Suggested execution

1. Fork the repo and create a branchgit checkout -b feature/wallet-tx-lifecycle.

2. Implement changeshooks/useWallet.hook.ts (or new hooks/useTransaction.hook.ts), new lib/stellar/transaction.ts, reuse lib/config.ts and constants/wallet-kits.constant.ts.

3. Write/extend tests — Jest + React Testing Library with pnpm; add tests mocking the kit and the submit/confirm calls, asserting each status transition and failure branch. Follow the hook-testing approach used elsewhere with mocked dependencies.

4. Test and commit

pnpm install
pnpm type-check
pnpm test
pnpm build

Example commit message

feat(wallet): add submit/confirm lifecycle and a status state machine over signTransaction

Guidelines

  • Target >=85% coverage on the new transaction code paths.
  • Document the transaction flow and required network config in docs/; ensure toasts/errors are announced accessibly.
  • Timeframe: 96 hours.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions