feat: add event archive and historical query functionality #273
+579
−30
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.
Summary
Implements event archive and historical query support for resolved/cancelled markets and fixes three existing payout tests that were failing because
resolve_market_manualalready callsdistribute_payoutsinternally.Changes
Test fixes (existing failures)
resolve_market_manualcallsdistribute_payoutsinternally, so a second call saw all winners as claimed and returned 0.test_automatic_payout_distribution,test_market_state_after_claim, andtest_integration_full_market_lifecycle_with_payouts:distribute_payoutscall.market.state == Resolvedandmarket.claimedfor winners/losers.Event archive and historical query (#271)
Types
EventHistoryEntryintypes.rs: public metadata only (no votes, stakes, or addresses) —market_id,question,outcomes,end_time,created_at,state,winning_outcome,total_staked,archived_at,category.New module:
event_archive.rsarchive_event(env, admin, market_id)— Admin-only; archives a resolved or cancelled market. UsesError::InvalidState/Error::AlreadyClaimed(no new error variants to stay within#[contracterror]limit).is_archived(env, market_id)— Returns whether a market is archived.query_events_history(env, from_ts, to_ts, cursor, limit)— Events by creation time range; paginated; limit capped at 30.query_events_by_resolution_status(env, status, cursor, limit)— Events byMarketState(e.g. Resolved, Cancelled).query_events_by_category(env, category, cursor, limit)— Events by oraclefeed_id(category).Public API in
lib.rsarchive_event(env, admin, market_id) -> Result<(), Error>query_events_history(env, from_ts, to_ts, cursor, limit) -> (Vec<EventHistoryEntry>, u32)query_events_by_status(env, status, cursor, limit) -> (Vec<EventHistoryEntry>, u32)(name kept ≤ 32 chars)query_events_by_category(env, category, cursor, limit) -> (Vec<EventHistoryEntry>, u32)Security / design
MAX_QUERY_LIMIT = 30.Tests
EventHistoryEntrycontains only public fields.Testing
cargo build— successcargo test -p predictify-hybrid— 398 tests passed (including 3 fixed payout tests and 10 new archive/query tests)Closes #271