Reward Controller & Routes#38
Merged
Merged
Conversation
Contributor
Author
|
conflict resolved |
Contributor
Author
|
Lint errors fixed |
Contributor
Author
|
ok lint error fixed |
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.
Implementation of Reward Controller & Routes
Files Created:
src/controllers/reward.controller.ts
src/routes/v1/rewards.routes.ts Route definitions
tests/unit/reward.service.test.ts
tests/unit/reward.controller.test.ts
Files Enhanced:
src/services/reward.service.ts - Added balance, history, withdrawal methods
src/routes/index.ts - Registered reward routes
🎯 Three Main Endpoints
1️⃣ GET /api/v1/rewards/balance
json
{
"available": 15.5,
"pending": 0,
"lifetime": 25.0
}
2️⃣ GET /api/v1/rewards/history
Filter by type, status, date range
Pagination support (limit/offset)
Sorted newest first
3️⃣ POST /api/v1/rewards/withdraw
Validates Stellar wallet address
Checks sufficient balance
Processes via Stellar blockchain
Tracks transaction status
🧪 Test Results
Reward calculation
Balance tracking
Transaction history
Withdrawal processing
Validation
✨ Key Features
✅ Real-time balance calculation
✅ Transaction status tracking (pending/completed/failed)
✅ Comprehensive input validation
✅ Stellar payment integration
✅ Error handling & logging
✅ Authentication required
✅ Pagination & filtering
Acceptance Criteria
✅ Balance reflects completed module rewards
✅ History shows all transactions with details
✅ Withdrawals recorded with proper status
✅ Sufficient balance validation
✅ Pagination works
✅ Date/type filtering works
close #7