Track entry fees in UserJoinedEvent and surface them in prize pool#990
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Collaborator
|
clean job |
3 tasks
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.
The contract's
join_event(contract Issue 7) chargesevent.entry_fee(ifnon-zero) from the joining user and adds it to
event.prize_pool. The indexer'sUserJoinedEventhandling previously only trackedparticipant_count, so thecached
creator_events.prize_pooldid not reflect entry fees collected as usersjoined.
This PR captures the entry fee paid in each
UserJoinedEvent, adds it to thecached
prize_pool, and maintains a running total of fees collected(
total_entry_fees_collected) for transparency. The new totals are exposed viathe event stats endpoint.
Changes
src/indexer/indexer.service.ts)extractEventData()'UserJoinedEvent'case now readsentry_fee_paidusing
readUnsignedBigInt(defaults to"0"for free events / missingfields).
src/matches/entities/creator-event.entity.ts,src/creator-events/entities/creator-event.entity.ts)total_entry_fees_collected: string(bigint, default'0'). Bothentities map to the
creator_eventstable, so the column is added to bothfor consistency.
src/indexer/indexer.service.ts)handleUserJoinedEvent()now, after incrementingparticipant_count, addsthe paid fee (only when non-zero) using BigInt arithmetic:
src/creator-events/dto/event-stats-response.dto.ts,src/creator-events/creator-events.service.ts)EventStatsResponseDtogainsprizePoolandtotalEntryFeesCollected,populated in
getEventStats()from the cachedCreatorEvent(default"0"when no cache row exists).
src/migrations/1775900000000-AddTotalEntryFeesCollected.ts)total_entry_fees_collectedcolumn (BIGINT DEFAULT '0'),backfills existing rows, and sets it
NOT NULL. Reversibledown.Acceptance Criteria
UserJoinedEventwithentry_fee_paid: "10000000"(1 XLM in stroops)adds
10000000to bothprize_poolandtotal_entry_fees_collected(e.g.
5000000000→5010000000).UserJoinedEventwith noentry_fee_paid(free event) leavesprize_poolandtotal_entry_fees_collectedunchanged.prize_poolarithmetic uses BigInt and is correct for large stroopvalues.
Tests
entry_fee_paidfrom the payload,"0"for free events,prize_poolandtotal_entry_fees_collected,EventStatsResponseDtoconsumers and added assertions for the newprizePool/totalEntryFeesCollectedfields (including the default-to-"0"path).
All affected suites pass (44 tests) and the production build typechecks clean.
Notes / Follow-ups
entry_fee_paidinUserJoinedEvent(contract Issue 7). If the deployed contract uses a different field name, the
indexer will read
"0"; the field name should be confirmed against theon-chain event.
closes #959