feat: add self-healing transactions with resilience module #234
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.
Pull Request: Self-Healing Transactions (Resilience Module)
Summary
This PR introduces a resilience module for self-healing blockchain transactions in the Base Account SDK. The module provides automatic retry mechanisms, intelligent error classification, and recovery actions to dramatically improve transaction success rates and developer experience.
Key Changes
sendUserOpWithResilience()function with configurable retry logicProblem Statement
Currently,
sendUserOpAndWaitin the SDK:Solution
The resilience module wraps transaction execution with:
1. Automatic Retries with Backoff
2. Intelligent Failure Classification
3. Automatic Recovery Actions
4. Progress Callbacks
5. Rich Error Types
Files Changed
New Files
resilience/types.tsresilience/errors.tsMaxRetriesExceededError,UnrecoverableTransactionError)resilience/utils.tsresilience/sendUserOpWithResilience.tsresilience/index.tsresilience/RESILIENCE.mdTest Files
resilience/errors.test.tsresilience/utils.test.tsresilience/sendUserOpWithResilience.test.tsModified Files
interface/payment/index.tsTest Results
Backward Compatibility
This PR is fully backward compatible:
sendUserOpAndWaitremains unchangedsendUserOpAndWaitWithResiliencehas the same signatureUsage Example
Performance Considerations
maxRetriescapped at 10,gasMultipliercapped at 3xDocumentation
Full documentation is available in
RESILIENCE.md.Checklist
Request for Review
This PR is ready for review. Please focus on:
utils.ts- Are the regex patterns comprehensive?types.ts- Are the defaults sensible?sendUserOpWithResilience.ts- Is the decision tree correct?Reviewer Checklist