Skip to content

feat: add-campaign-duration#972

Merged
Olowodarey merged 4 commits into
Arena1X:mainfrom
ONEONUORA:Add-campaign-duration
Jun 16, 2026
Merged

feat: add-campaign-duration#972
Olowodarey merged 4 commits into
Arena1X:mainfrom
ONEONUORA:Add-campaign-duration

Conversation

@ONEONUORA

@ONEONUORA ONEONUORA commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

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 limit

Files Modified

  • Core Implementation

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

  • Testing

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

@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
insight-arena-4rll Ready Ready Preview, Comment Jun 16, 2026 11:08am

@Olowodarey

Copy link
Copy Markdown
Collaborator

@ONEONUORA pls fix build

@ONEONUORA

ONEONUORA commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

@Olowodarey Pls build pass
Pls review

@Olowodarey Olowodarey left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ONEONUORA nice work thank you for your contribution

@Olowodarey Olowodarey merged commit 74b0d6f into Arena1X:main Jun 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Contract] Add campaign duration (start_time / end_time) to events

2 participants