Skip to content

fix(hooks): add tx confirmation + signature validation to useCreateMarket#155

Open
6figpsolseeker wants to merge 1 commit intodcccrypto:mainfrom
6figpsolseeker:fix/create-market-tx-confirmation
Open

fix(hooks): add tx confirmation + signature validation to useCreateMarket#155
6figpsolseeker wants to merge 1 commit intodcccrypto:mainfrom
6figpsolseeker:fix/create-market-tx-confirmation

Conversation

@6figpsolseeker
Copy link
Copy Markdown

Summary

  • All 5 market creation transactions were sent via MWA but none were confirmed on-chain. The app showed "Market deployed!" without verifying any transaction landed — risking half-initialized markets when transactions are dropped due to congestion or expired blockhashes.
  • Fetches lastValidBlockHeight once before the send loop (all 5 txs share the same blockhash window)
  • Confirms each transaction on-chain before sending the next (critical since each tx builds on state from the previous)
  • Validates each MWA signature is non-null before proceeding
  • Uses the baked-in recentBlockhash from each decoded Transaction for confirmation (no extra RPC call per tx)

What changed

File Change
src/hooks/useCreateMarket.ts Import confirmTransactionSafe, fetch lastValidBlockHeight, add signature null-check + sequential confirmation in send loop
__tests__/hooks/useCreateMarket.test.ts New file — 21 tests covering happy path (8), wallet/server errors (4), confirmation failure abort (1), empty signatures (2), input validation (2), simulation failure (1), untrusted program detection (1), reset (1), non-fatal registration failure (1)

Why this matters

Market creation involves 5 sequential transactions where each depends on state from the previous one. Without confirmation:

  • If TX3 gets dropped but TX4/TX5 land, the market is half-initialized on-chain
  • The server-generated slab keypair is already "used" — re-deploying fails with "account already exists"
  • The user sees success and may attempt to trade on a broken market

Test plan

  • All 21 useCreateMarket tests pass
  • All 158 hook tests pass (13 suites)
  • Manual test: deploy market on devnet, verify each TX is confirmed before proceeding
  • Manual test: simulate TX failure mid-deploy, verify error surfaces and deployment aborts

🤖 Generated with Claude Code

…rket

All 5 market creation transactions were sent via MWA but none were
confirmed on-chain. The app showed "Market deployed!" without verifying
any transaction actually landed, risking half-initialized markets if
transactions were dropped due to congestion or expired blockhashes.

Changes:
- Import confirmTransactionSafe from lib/confirmTransaction
- Fetch lastValidBlockHeight once before the send loop (all 5 txs
  share the same blockhash window)
- Validate each MWA signature is non-null before proceeding
- Confirm each transaction on-chain before sending the next one
  (critical since each tx builds on state from the previous)
- Use the baked-in recentBlockhash from each decoded transaction
  for confirmation (no extra RPC call per tx)
- Add comprehensive test suite (21 tests) covering happy path,
  server errors, confirmation failures, empty signatures, input
  validation, simulation failure, untrusted programs, and reset

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 6, 2026

Warning

Rate limit exceeded

@6figpsolseeker has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 11 minutes and 14 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 11 minutes and 14 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ecf0d4e2-7080-4203-8244-366fb6b6d81c

📥 Commits

Reviewing files that changed from the base of the PR and between df5b0fd and 7db2272.

📒 Files selected for processing (2)
  • __tests__/hooks/useCreateMarket.test.ts
  • src/hooks/useCreateMarket.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant