Skip to content

fix(error): add submit-time decodeContractError for on-chain error surfacing#39

Merged
AquiGorka merged 2 commits into
mainfrom
fix/error-bubbling
Jul 6, 2026
Merged

fix(error): add submit-time decodeContractError for on-chain error surfacing#39
AquiGorka merged 2 commits into
mainfrom
fix/error-bubbling

Conversation

@AquiGorka

Copy link
Copy Markdown
Contributor

Part of the mid-flight error-bubbling fix (ClickUp 86c8t0zux, half 2). Anchor PR — the four consumer PRs pin the version this publishes.

What

Adds decodeContractError(err) — a submit-time decoder that recovers the soroban contract code (catalog 1000/2000/3000 ranges) from a caught colibri contract-error-matcher payload (meta.data.match.code, walking the cause chain) or the rendered Contract error: <Variant> message, and maps it via the existing MoonlightContractError catalog. Returns null for non-contract (transient) errors so callers can distinguish deterministic reverts from retryable failures.

This is the single decoder the whole chain uses to turn an opaque thrown error into a stable code that provider-platform persists to failureDetail and the API boundary translates to the user (hole #1).

Tests

src/error/decode-contract-error.unit.test.ts (direct match, cause-chain walk, message fallback, network-error null, catalog-drift null). Full suite: 20 passed / 0 failed (incl. testnet integration).

Consumers: only provider-platform imports this new export; it pins ^0.11.1.

AquiGorka added 2 commits July 2, 2026 09:58
Decodes a caught error's colibri contract-error-matcher payload
(meta.data.match.code, walking the cause chain) into the soroban
catalog identity {code,name,details,source}. This is the single
submit-time decoder that the provider populates failureDetail from and
the API boundary translates into a StructuredError. Returns null for
non-contract (transient/network) errors so callers can distinguish
deterministic reverts from retryable failures.
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.23810% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/error/decode-contract-error.ts 95.12% 0 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@AquiGorka AquiGorka requested a review from pselle July 2, 2026 20:11
@AquiGorka AquiGorka merged commit 4f92040 into main Jul 6, 2026
2 checks passed
@AquiGorka AquiGorka deleted the fix/error-bubbling branch July 6, 2026 12:25
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