Skip to content

feat: map Soroban simulation failures to human-readable BetModal errors (#406) - #499

Open
meem08 wants to merge 1 commit into
TevaLabs:mainfrom
meem08:feat/406-soroban-error-mapping
Open

feat: map Soroban simulation failures to human-readable BetModal errors (#406)#499
meem08 wants to merge 1 commit into
TevaLabs:mainfrom
meem08:feat/406-soroban-error-mapping

Conversation

@meem08

@meem08 meem08 commented Aug 26, 2026

Copy link
Copy Markdown

Closes #406

Summary

Translates common Soroban simulation and Freighter signing errors into player-friendly copy shown in the BetModal — both the fee-estimate failure panel and the transaction failure timeline — so players see actionable messages instead of raw SDK / HostError internals. The raw error is always kept in the console for debugging.

Changes

  • src/lib/xelma-contract.ts — new exported humanizeContractError(error, context?):
    • 9 mapped error cases: insufficient balance, Soroban budget/resource exceeded, closed round, user-cancelled Freighter signature, signing failure, authentication failure, unfunded account, network/timeout, plus a generic contract-rejection catch-all.
    • Unknown errors fall back to a safe generic message (CONTRACT_ERROR_FALLBACK).
    • Raw error (message + stack) is logged to the console with a [xelma-contract:<context>] prefix for debugging.
  • src/components/BetModal.tsx — uses humanizeContractError for both the fee-estimate failure message and the transaction failure timeline (tx.fail(...)).
  • Tests — added a humanizeContractError unit-test suite in src/lib/__tests__/xelma-contract.test.ts (mapped cases, fallback for unknown/null errors, raw-error console logging) and updated the two BetModal test files' mocks/assertions to expect the friendly copy.

Acceptance criteria

  • At least 5 mapped error cases (9 mapping rules implemented)
  • Unknown errors show a safe fallback message
  • Raw error kept in console for debugging

Verification

  • pnpm exec tsc -b — passes
  • pnpm build — passes
  • pnpm test:unit — 791 tests pass
  • ESLint clean on all changed files (pre-existing react-hooks/set-state-in-effect errors in PredictionHistory.tsx / PriceChart.tsx / Dashboard.tsx / Learn.tsx are unrelated to this change)

…l errors

Translate common Soroban simulation and Freighter signing errors into
human-readable copy in the BetModal (fee estimate + submit flows) so
players see actionable messages instead of raw SDK internals. The raw
error is kept in the console for debugging, and unknown errors fall back
to a safe generic message.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

@meem08 is attempting to deploy a commit to the josephchimebuka's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Map Soroban simulation failures to human-readable BetModal errors

1 participant