feat: paginated active markets + three indexer event handlers - #1159
Merged
Ehonrie merged 5 commits intoJul 27, 2026
Merged
Conversation
- Enforce MAX_PAGE_SIZE (100) in getAllMarkets - Return PaginatedResult with total count alongside data for frontend pagination UI - Sort markets by createdAt descending (most-recent-first) - Clean up duplicate imports and consolidate on db client - Update controller to pass pageSize and return PaginatedResult directly
- Add MarketCancelled case to processLedger event routing - Implement handleMarketCancelledEvent to update market status to Cancelled - Covered by unit test with mock event payload
- Add markBetClaimedByMarketAndBettor in bet.service.ts using atomic updateMany - Split handleWinnersClaimedEvent into handleWinningsClaimedEvent and handleRefundClaimedEvent - Match correct bet row via (marketId, bettor) from event body - Include comprehensive unit tests for all four event handlers: MarketCancelled, WinningsClaimed, RefundClaimed, and DisputeRaised
- Add marketService.updateMarketStatus call in DisputeRaised handler - Set market status to Disputed when a dispute is raised - Store dispute reason for admin review via Dispute table - Covered by unit test with mock event payload
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 #1069
Closes #1070
Closes #1071
Closes #1072
Summary
This PR implements four backend features for the BOXMEOUT platform:
1. Paginated Active Markets (d04af0b)
Returns active markets from DB, paginated, most-recent-first.
MAX_PAGE_SIZEconstantPaginatedResult<T>)createdAtdescending (most-recent-first)dbclientpageSizeparam and returnPaginatedResultdirectly2. Decode market_cancelled Events (c810b41)
Decodes
market_cancelledevents and sets market status to cancelled.MarketCancelledcase inprocessLedgerevent routinghandleMarketCancelledEventto callupdateMarketStatus(id, "Cancelled")3. Decode winnings_claimed Events (b6b14f0)
Decodes
winnings_claimedandrefund_claimedevents, markingBetModel.claimed = true.markBetClaimedByMarketAndBettorinbet.service.tsusing atomicupdateManyhandleWinnersClaimedEventinto separatehandleWinningsClaimedEventandhandleRefundClaimedEvent4. Decode resolution_disputed Events (4077ba8)
Decodes
resolution_disputedevents, sets market status to disputed.updateMarketStatus(id, "Disputed")call inhandleDisputeEventforDisputeRaisedDisputetable for admin review UIFiles Changed
backend/src/services/market.service.tsbackend/src/api/controllers/market.controller.tspageSize+PaginatedResultbackend/src/services/bet.service.tsmarkBetClaimedByMarketAndBettor(atomic)backend/src/services/indexer.service.tsbackend/src/services/__tests__/indexer.service.test.tsbackend/src/services/indexer.service.test.tsTesting
All 50 tests pass across both test suites.