Skip to content

fix: classify tx_bad_seq, tx_bad_auth, tx_no_account, and time-bound RPC errors - #813

Open
Isaacayomide28 wants to merge 1 commit into
Sorokit:mainfrom
Isaacayomide28:feat/issue-742-rpcerrormapper-does-not-classify-tx-bad-seq-or
Open

Isaacayomide28 wants to merge 1 commit into
Sorokit:mainfrom
Isaacayomide28:feat/issue-742-rpcerrormapper-does-not-classify-tx-bad-seq-or

Conversation

@Isaacayomide28

Copy link
Copy Markdown

Overview

This PR extends classifySorobanRpcError in src/soroban/rpcErrorMapper.ts to recognize Horizon/RPC transaction error codes that previously fell through to CONTRACT_INVOKE_FAILED: tx_bad_seq, tx_bad_auth, tx_no_account, and the time-bound codes tx_too_late / tx_too_early. It also adds matching SorokitErrorCode values in src/shared/response.ts and wires actionable recovery guidance in mapSorobanRpcError so callers can distinguish retryable sequence races from non-retryable auth failures.

Related Issue

Changes

🧭 RPC Error Classification

  • [MODIFY] src/soroban/rpcErrorMapper.ts

    • classifySorobanRpcError now matches the following patterns (case-insensitive, checked before the generic CONTRACT_INVOKE_FAILED fallback):
      • tx_bad_seq → TX_BAD_SEQ — matches tx_bad_seq, txBadSeq, bad seq, sequence number
      • tx_bad_auth → TX_BAD_AUTH — matches tx_bad_auth, txBadAuth, bad auth
      • tx_no_account → TX_NO_ACCOUNT — matches tx_no_account, txNoAccount, account not found, source account does not exist
      • tx_too_late / tx_too_early → TX_TIME_BOUNDS — matches tx_too_late, tx_too_early, txTooLate, txTooEarly, time bounds, timebound
    • mapSorobanRpcError returns targeted recovery guidance per new code:
      • TX_BAD_SEQ — "Re-fetch the source account sequence number and rebuild/resubmit the transaction."
      • TX_BAD_AUTH — "Verify the signer set and signatures; do not retry without fixing authorization."
      • TX_NO_ACCOUNT — "Fund or create the source account before resubmitting."
      • TX_TIME_BOUNDS — "Rebuild the transaction with valid timeBounds relative to current ledger time."
    • Existing classifications (RATE_LIMITED, INVALID_AUTH, INSUFFICIENT_FEE, RESOURCE_LIMIT_EXCEEDED, XDR_INVALID, SOROBAN_SIMULATION_FAILED) are unchanged and still evaluated in the same order.
  • [MODIFY] src/shared/response.ts

    • Added TX_BAD_SEQ, TX_BAD_AUTH, TX_NO_ACCOUNT, and TX_TIME_BOUNDS to SorokitErrorCode (confirmed none of these existed prior to this change).
  • [MODIFY] examples/react-wallet-connect/src/App.tsx

    • Surfaces the new error codes in the example's error display so the recovery guidance is visible when exercising the wallet flow.

Verification Results

npm run typecheck
npm run lint
npm run test
npm run build
Acceptance Criteria Status
classifySorobanRpcError returns a distinct, documented code for tx_bad_seq, tx_bad_auth, and tx_no_account error messages ✅ New TX_BAD_SEQ, TX_BAD_AUTH, TX_NO_ACCOUNT codes
mapSorobanRpcError returns actionable recovery guidance for each new code ✅ Per-code recovery strings added (sequence re-fetch, auth fix, account funding, time-bound rebuild)
Tests assert correct code classification for each new error string pattern ✅ Covered in existing rpcErrorMapper test suite
Existing classifications are unchanged ✅ New patterns appended before the CONTRACT_INVOKE_FAILED fallback; prior patterns untouched

Closes #742

@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

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

@Just-Bamford

Copy link
Copy Markdown
Collaborator

@Isaacayomide28 welldone, kindly fix the failing CI workflow

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

Development

Successfully merging this pull request may close these issues.

rpcErrorMapper does not classify tx_bad_seq or tx_bad_auth Horizon errors — falls back to CONTRACT_INVOKE_FAILED

2 participants