Repository navigation
Conversation
Added distinct errors for missing accounts, resource or fee limits, and archived entries. Added opt-in restore: true for invoke() and documented the restore flow. Closes Dione-b#240
|
@deslawson Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Dione-b
left a comment
There was a problem hiding this comment.
Thanks for this! The restore: true plumbing works with stellar-sdk 16 (method options override client options, so restoreFootprint picks up the signer), and ACCOUNT_NOT_FOUND is classified correctly. A few things need fixing before merge. I ran the suites locally, since you mentioned you couldn't:
Blocking
-
Tests fail: 2 failures in
invoke-args.test.ts.splitInvokeArgsAndOptionsnow returnsrestore: falseand thetoEqualassertions weren't updated. -
Conflicts with
main(#267,assertWalletNetwork). When rebasing, keepassertWalletNetworkbeforecreateTransaction. Withrestore: truethe RestoreFootprint tx is signed insidecallMethod, so the wrong order lets the wallet sign on the wrong network. -
Archived and resource-limit errors aren't classified in the real SDK flow.
AssembledTransactionhas noprepare(), and itssimulate()doesn't throw on simulation or restore errors. They surface when the.resultgetter is read (ExpiredStateError/SimulationFailedError) insidereadSimulationResult, which isn't wrapped. Oninvoke()they surface insidesignAndSend, which becomesXDR_SUBMIT_FAILED. I reproduced aread()on archived state rejecting with a rawExpiredStateError. Please classify those paths too, and test with a fake whosesimulate()resolves and whoseresultgetter throws, not only a rejectingprepare(). -
False positives in the classifier (reproduced):
"...status code 429: rate limit exceeded"→SIMULATION_RESOURCE_LIMIT(/LIMIT.?EXCEEDED/is too broad).{ error: "boom", restorePreamble: null }→SIMULATION_ENTRY_ARCHIVED, becausecollectErrorTextpushes the field names into the text it matches against.
Please drop field names, check
restorePreamble != nulldirectly, and anchor the patterns to known Soroban/RPC strings. The whole-objectJSON.stringifymakes the loose patterns riskier.
Should fix
- A contract arg literally named
restore(invoke("set_flag", { restore: true })) is now treated as options. Document this or tighten the heuristic. - Wrapping
callMethodchanges existing behavior: any non-Caatinga error (e.g. arg conversion) now becomesXDR_PREPARE_FAILED"Failed to simulate", including inread(). Please note this in the changeset / Release Impact. - The hint and docs say
restorePreambleis kept onerror.cause. That isn't true for SDK bindings:ExpiredStateErrorcarries only a message.
Nits
- Run
pnpm format:docs/errors.mdandpackages/client/src/xdr/build-xdr.tsfail Prettier. xdr/build-xdr.tsnow imports fromclient/. Consider moving the classifier to a neutral module.- Please add tests for the restore signer's
XDR_SIGN_FAILEDpaths (empty result or rejection). - Please open PRs from a feature branch rather than your fork's
main.
Dione-b
left a comment
There was a problem hiding this comment.
Thanks for sticking with this. I checked out deslawson:main locally. The two "Merge branch 'main'" commits since the last review resolved the conflicts incorrectly, and the branch no longer builds:
1. Typecheck fails (blocking). pnpm typecheck reports 8 errors in packages/client/src/client/caatinga-contract-client.ts. The createClient/callMethod block from createTransaction ended up inside resolveWalletPublicKey (around lines 265-285), where contractId, method, args and methodOptions are not in scope, and options is undefined around lines 220-221. pnpm test fails across createCaatingaClient and splitInvokeArgsAndOptions (for example ReferenceError: options is not defined).
2. The wallet network check is gone. assertWalletNetwork (#267) no longer exists on this branch, and invoke() doesn't call it. With restore: true, the RestoreFootprint transaction could then be signed for the wrong network. It must run before createTransaction, as on main.
3. Previous review points are still open: the invoke-args tests for the new restore option, classifying errors thrown from the .result getter (readSimulationResult / signAndSend), the /LIMIT.?EXCEEDED/ false positives and matching on field names such as restorePreamble, and a contract argument named restore being taken as options.
4. Compatibility note. Failures that used to surface as CAATINGA_XDR_PREPARE_FAILED now come out as SIMULATION_ACCOUNT_NOT_FOUND, SIMULATION_RESOURCE_LIMIT or SIMULATION_ENTRY_ARCHIVED. Adding codes is fine, but please say in the changeset that callers branching on the old code will see the new ones.
Suggested path: open a fresh branch from current main (not your fork's main), re-apply the feature commits on top, and run pnpm typecheck && pnpm test before pushing. Happy to re-review after that.
|
Thanks for this work, @deslawson. Since the branch stopped building after the merges from |
…estoration Rebuilds Dione-b#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 Dione-b#240 Co-authored-by: Lex0865 <destinylawson007@gmail.com>
Added distinct errors for missing accounts, resource or fee limits, and archived entries. Added opt-in restore: true for invoke() and documented the restore flow.
Motivation
Mainnet simulation failures for unfunded accounts, resource or fee limits, and archived entries were surfaced as generic errors with little recovery guidance.
Behavior
Added distinct CAATINGA_* error codes and actionable hints. invoke() now supports opt-in { restore: true }, forwarding the restore option and wallet signer to compatible bindings. Updated client docs with automatic and manual restore guidance.
Tests
Added tests for error classification, account lookup failures, and restore option forwarding. Could not run tests or typecheck: pnpm is unavailable, and Corepack could not initialize its cache in the restricted environment.
Release Impact
Checklist
CAATINGA_*errors added or updated when public failures change.--sourceexamples use a local Stellar CLI identity, not a publicG...address.Closes #240
.