feat: backend API endpoints — admin market ops, users, bets, and market filters - #1158
Merged
Ehonrie merged 7 commits intoJul 27, 2026
Merged
Conversation
- Add resolveMarket: updates market status to Resolved + AdminLog entry - Add cancelMarket: cancels market with optional reason + AdminLog entry - Add resolveMarketDispute: resolves disputed market with override + AdminLog entry - All actions write AdminLog entries for audit trail
- Add POST /admin/markets/:marketId/resolve with outcome/source validation - Add POST /admin/markets/:marketId/cancel with optional reason - Add POST /admin/markets/:marketId/dispute-resolve with overrideOutcome validation - Implement getMarketBetsHandler supporting ?outcome=yes|no filter - All admin routes gated by requireAdmin middleware - All handlers validate required fields before calling service layer
- Implement getBetsByAddress: query all bets by bettor address with optional marketId filter - Implement getBetsByMarket: query bets by market with ?outcome=yes|no side filter - Yes maps to FighterA, No maps to FighterB - Implement getBetsByAddressHandler in controller with error handling - Indexed on bettor for efficient wallet-level queries
- Add GET /api/users/:address to fetch user profile by wallet address - Add PUT /api/users/:address gated by requireWalletAuth middleware - requireWalletAuth verifies Stellar wallet signature via x-wallet-signature/x-wallet-message headers - Includes replay protection with 5-minute timestamp expiry - User service aggregates profile data from existing bet records
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.
Closes #1077
Closes #1078
Closes #1089
Closes #1090
Summary
This PR implements 4 backend API endpoint groups for the BOXMEOUT prediction market:
1. Admin Market Resolution Endpoints
POST /api/admin/markets/:marketId/resolve,/cancel,/dispute-resolverequireAdminmiddleware (x-admin-api-key header)AdminLogentry for audit trail2. User Profile Endpoints
GET /api/users/:address,PUT /api/users/:addressrequireWalletAuthmiddlewarex-wallet-signatureandx-wallet-messageheaders with 5-min timestamp replay protection3. Bets by Wallet Address
GET /api/bets/:address?marketIdfilter4. Market Bets with Outcome Filter
GET /api/markets/:id/bets?outcome=yes|nofilterFiles Changed
backend/src/api/middleware/auth.tsrequireWalletAuthmiddlewarebackend/src/api/routes/market.routes.tsbackend/src/api/routes/user.routes.tsbackend/src/api/controllers/market.controller.tsbackend/src/api/controllers/bet.controller.tsbackend/src/api/controllers/user.controller.tsbackend/src/services/market.service.tsbackend/src/services/bet.service.tsbackend/src/services/user.service.tsCommits
aacf0ddfeat: implement admin market service functions with audit loggingb34716efeat: wire admin market resolution endpoints with input validation3c557fffeat: implement bets-by-address and market-bets endpoints92cf285feat: add user profile endpoints with wallet-signature authentication