Repository navigation
feat(client): classify Soroban simulation failures and opt-in state restoration - #311
Merged
Merged
Conversation
…estoration Rebuilds #255 by @deslawson on current main. - New public codes: CAATINGA_SIMULATION_ACCOUNT_NOT_FOUND, CAATINGA_SIMULATION_RESOURCE_LIMIT, CAATINGA_SIMULATION_ENTRY_ARCHIVED. - Classifier lives in packages/client/src/errors/simulation-error.ts and matches only field values (never field names) against strings Soroban RPC, stellar-core and stellar-sdk emit, plus a non-null restorePreamble, so "429: rate limit exceeded" is no longer a resource limit. - Errors thrown by the binding's result getter (read/simulate) and inside signAndSend (invoke) are classified; unknown errors raised while the binding builds the method propagate unchanged. - invoke(method, args, { restore: true }) forwards restore and a wallet signer to the binding; assertWalletNetwork still runs before createTransaction, and restore signing failures map to XDR_SIGN_FAILED. - Changeset documents the code changes for callers that branched on XDR_PREPARE_FAILED / XDR_SUBMIT_FAILED. Closes #240 Co-authored-by: Lex0865 <destinylawson007@gmail.com>
4 tasks done
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.
Supersedes #255 by @deslawson (credited as co-author). That branch no longer built after two merges from
main, and the author did not respond to the review, so this PR rebuilds the same feature on currentmainwith the review points addressed. Closes #240.Motivation
Soroban simulation failures such as an unfunded source account, budget or fee limits, and archived contract state all surfaced as generic
CAATINGA_XDR_PREPARE_FAILED/CAATINGA_XDR_SUBMIT_FAILEDerrors, or as raw SDK errors, with no way to restore archived state through the client.Behavior
CAATINGA_SIMULATION_ACCOUNT_NOT_FOUND,CAATINGA_SIMULATION_RESOURCE_LIMIT,CAATINGA_SIMULATION_ENTRY_ARCHIVED.invoke(method, args, { restore: true })forwardsrestoreand a wallet signer to the generated binding, which submits a RestoreFootprint transaction first.read()/simulate(), including errors thrown by the binding'sresultgetter (stellar-sdkSimulationFailedError/ExpiredStateError);invoke(), including errors raised insidesignAndSend;Changes from #255 (review points)
assertWalletNetworkstill runs beforecreateTransaction, so a restore is never signed on the wrong network. There is a test for this.packages/client/src/errors/simulation-error.ts):restorePreambledirectly;Error(Budget, ExceededLimit),txNO_ACCOUNT,ENTRY_ARCHIVEDand stellar-sdk's "You need to restore some contract state";"…429: rate limit exceeded"and{ restorePreamble: null }no longer match; both cases are tested.XDR_PREPARE_FAILED.restorePreambleis kept onerror.cause.restoreoption key: an object is read as options only when every key is an option key (main's heuristic). An argument object with other keys is kept, and docs explain how to pass a contract arg namedrestore.invoke-args, the result getter,signAndSend, the restore signer'sXDR_SIGN_FAILEDpaths (rejection and empty result), and classifier false positives.Tests
pnpm typecheck,pnpm lint,pnpm format, andpnpm testall pass locally:Release impact
Minor for
@caatinga/coreand@caatinga/client; see.changeset/soroban-simulation-restore.md.Compatibility: callers that branch on
XDR_PREPARE_FAILED/XDR_SUBMIT_FAILEDfor these specific failures now receive the new codes. Other errors are unchanged.Rollback: revert this PR. No artifacts or persisted data are affected.