Skip to content

fix(wallet): decode vault contract errors from simulation - #1362

Merged
greatest0fallt1me merged 3 commits into
CalloraOrg:mainfrom
Adejoke46:fix/issue-1314
Oct 24, 2026
Merged

greatest0fallt1me merged 3 commits into
CalloraOrg:mainfrom
Adejoke46:fix/issue-1314

Conversation

@Adejoke46

Copy link
Copy Markdown
Contributor

Closes #1314

Problem

When the vault rejects a deposit during simulation (paused, below minimum, or wallet not on the allowlist), the user was told Stellar RPC could not be reached. Every prepareTransaction error went through mapRpcError.

Change

  • Simulate explicitly with server.simulateTransaction, then branch on rpc.Api.isSimulationError. Contract rejections become CONTRACT_REJECTED with contractErrorCode, and are thrown before any signature request.
  • decodeVaultError (src/services/vaultErrors.ts) reads the Error(Contract, #n) code from the simulation error or diagnostic events, and maps known codes to specific messages. Raw host errors and XDR are never shown or logged.
  • Local assembly failures are classified as CONTRACT_REJECTED, not as transport errors.
  • Timeout and unreachable-RPC messages are unchanged and pinned by tests.
  • The deposit modal shows the decoded message with its code and offers Retry. Contract rejections never set requiresReconciliation.
  • docs/Deposit-Flow.md has the error mapping table.

Validation

  • npx tsc -p tsconfig.json --noEmit: passed.
  • npm run build: passed.
  • npx vitest run src/services/walletService.test.ts src/services/vaultErrors.test.ts src/App.deposit.test.tsx: 3 files, 105 tests passed.
  • npx vitest run (full suite): 153 files, 2305 tests passed.

Limits

Not run against a live testnet RPC; Soroban simulation is mocked in tests.

🤖 Generated with Claude Code

Adejoke46 and others added 3 commits October 23, 2026 06:27
Deposit simulation failures were reported as a network failure. Simulate
explicitly, classify contract rejections as CONTRACT_REJECTED before any
signature request, and decode the vault error code into a specific message.
Transport and timeout errors keep their existing messages.

Closes CalloraOrg#1314

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	src/api/catalogApi.ts
#	src/data/mockApis.ts
@greatest0fallt1me
greatest0fallt1me merged commit 483f9cb into CalloraOrg:main Oct 24, 2026
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.

Surface vault contract errors from deposit simulation instead of reporting a network failure

2 participants