feat: add-campaign-duration#972
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Collaborator
|
@ONEONUORA pls fix build |
Contributor
Author
|
@Olowodarey Pls build pass |
Olowodarey
approved these changes
Jun 16, 2026
Olowodarey
left a comment
Collaborator
There was a problem hiding this comment.
@ONEONUORA nice work thank you for your contribution
9 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.
closes #965
Summary
Implements comprehensive time-based event management functionality, allowing creators to define campaign start and end times with robust validation. This addresses Issue by enabling bounded match scheduling and automated prize pool payouts.
What Changed
_ Core Features
Event Timing Fields: Added start_time and end_time (Unix timestamps) to Event struct
Duration Limits: Added MAX_EVENT_DURATION_SECONDS constant (90 days = 7,776,000 seconds)
Time Validation: Comprehensive validation for time ranges during event creation
Helper Methods: Added has_ended() and is_within_window() methods for time-based queries
_ API Changes
// Before
pub fn create_event( env: Env, creator: Address, title: String, description: String, max_participants: u32, ) -> (u64, Symbol) // After pub fn create_event( env: Env, creator: Address, title: String, description: String, max_participants: u32, start_time: u64, // NEW: Event start timestamp end_time: u64, // NEW: Event end timestamp ) -> (u64, Symbol) New Error Handling InvalidTimeRange = 10 — end_time ≤ start_time EventStartInPast = 11 — start_time < current timestamp EventDurationTooLong = 12 — duration exceeds 90-day limitFiles Modified
storage_types.rs
Added start_time and end_time fields to Event struct
Added MAX_EVENT_DURATION_SECONDS constant
Added has_ended() and is_within_window() helper methods
Fixed clippy warnings (len() == 0 → is_empty())
event.rs
Updated create_event() signature and validation logic
Added comprehensive time range validation
Extended EventError enum with new time-related variants
Fixed clippy warnings
lib.rs
Updated contract interface to accept new time parameters
Added panic handling for new error types
event_tests.rs
Updated all existing tests for new function signature
Added comprehensive test suite for time validation:
test_create_event_with_valid_duration
test_create_event_end_before_start_rejected
test_create_event_end_equals_start_rejected
test_create_event_start_in_past_rejected
test_create_event_duration_too_long_rejected
test_event_has_ended_helper
test_event_is_within_window_helper
Code Quality
Multiple files: Added #[allow(dead_code)] annotations for future-use code
oracle.rs
: Fixed unnecessary cast warning with proper annotation
All files: Applied cargo fmt formatting
Acceptance Criteria Met
create_event requires and stores start_time/end_time
Invalid ranges rejected with documented errors
Event::has_ended / Event::is_within_window exist and unit tested
All validation edge cases covered in comprehensive test suite
Code passes cargo clippy with zero warnings
Code properly formatted with cargo fmt