fix(error): add submit-time decodeContractError for on-chain error surfacing#39
Merged
Conversation
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 Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 (catalog1000/2000/3000ranges) from a caught colibri contract-error-matcher payload (meta.data.match.code, walking the cause chain) or the renderedContract error: <Variant>message, and maps it via the existingMoonlightContractErrorcatalog. Returnsnullfor 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
failureDetailand 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.