feat: implement Pre-Billing Health Check (3-Day Warning) #142#186
Merged
elizabetheonoja-art merged 3 commits intoApr 22, 2026
Merged
Conversation
…otocol#142) - Add SorobanBalanceChecker service for RPC balance and authorization verification - Implement PreBillingHealthCheck service with database schema enhancements - Create PreBillingHealthWorker with node-cron daily scheduling (2 AM UTC) - Add PreBillingEmailService with professional warning email templates - Build comprehensive API endpoints for management and monitoring - Create standalone runner script with CLI interface - Add database schema: next_billing_date, warning_sent_at, required_amount columns - Implement RPC rate limiting (1 req/min per wallet) and caching (30s) - Add batch processing for efficient large dataset handling - Create comprehensive test suite with mocked RPC calls - Include complete documentation and deployment guide - Support multiple deployment modes: daemon, cron, Docker - Add performance metrics and monitoring endpoints - Implement graceful shutdown and error recovery Acceptance Criteria: - Users receive proactive warnings 3 days before payment failures - Merchants experience lower churn and save gas on failed transactions - System efficiently handles large datasets without RPC rate limit hits Resolves SubStream-Protocol#142
|
@KarenZita01 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! 🚀 |
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.
Overview
This PR implements a proactive "Health Check" cron job designed to identify failing subscriptions before the billing date. This reduces gas waste for merchants and churn for users.ChangesCron Job: Added a daily worker that scans for subscriptions due in$T+3$ days.On-Chain Verification: Integrated Soroban RPC calls to check real-time balance and allowance.Anti-Spam: Updated the Subscription schema with warning_sent_at to ensure users only receive one warning per cycle.Gas Optimization: By identifying "doomed" transactions early, merchants can skip execution for underfunded wallets, saving gas.Acceptance Criteria[x] Users with insufficient funds receive email alerts 3 days prior.[x] RPC checks correctly identify revoked allowances.[x] Database queries are optimized for large datasets.Testing[x] Mocked SorobanClient to return 0 balance; verified email triggers.[x] Verified warning_sent_at prevents duplicate emails on subsequent cron runs. Fixes #142