Skip to content

feat(event): implement cancel_event function with authorization check… #1019#1072

Merged
Olowodarey merged 1 commit into
Arena1X:mainfrom
Awointa:feat/1019-cancel-event
Jun 23, 2026
Merged

feat(event): implement cancel_event function with authorization check… #1019#1072
Olowodarey merged 1 commit into
Arena1X:mainfrom
Awointa:feat/1019-cancel-event

Conversation

@Awointa

@Awointa Awointa commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

closes #1019

Summary

Adds cancel_event(env, caller, event_id) to the creator-event-manager
contract, allowing the event creator to irreversibly cancel an event before it
is finalized.

Changes

src/event.rs

  • Added EventError::Unauthorized = 21 for non-creator callers.
  • Implemented cancel_event — requires creator auth, rejects if already
    finalized or already cancelled, calls the existing Event::cancel() method,
    persists the updated event, and emits ("event", "cancelled").

src/lib.rs

  • Wired cancel_event(env, caller, event_id) as a public contract entrypoint,
    mapping all error variants to panic strings consistent with the rest of the
    contract.

tests/cancel_event_tests.rs (new file)

  • test_cancel_event_success — creator cancels; is_cancelled = true, is_active
    = false.
  • test_cancel_event_non_creator_rejected — panics "unauthorized".
  • test_cancel_event_already_cancelled — panics "event_cancelled" on second
    call.
  • test_join_cancelled_event_rejected — panics "event_cancelled" on join_event.
  • test_create_match_on_cancelled_event_rejected — panics "event_cancelled" on
    create_match.
  • test_cancel_event_not_found — panics "event_not_found" for unknown ID.

Acceptance criteria

┌──────────────────────────────────┬──────────────────────────────────────┐
│ Criterion │ Covered by │
├──────────────────────────────────┼──────────────────────────────────────┤
│ Only creator can cancel │ test_cancel_event_non_creator_r │
│ │ ejected │
├──────────────────────────────────┼──────────────────────────────────────┤
│ Cancellation is irreversible │ test_cancel_event_already_cancelled │
├──────────────────────────────────┼──────────────────────────────────────┤
│ Cancelled events block │ test_join_cancelled_event_rejected │
│ join_event │ │
├──────────────────────────────────┼──────────────────────────────────────┤
│ Cancelled events block │ test_create_match_on_cancelled_ │
│ create_match │ event_rejected │
├──────────────────────────────────┼──────────────────────────────────────┤
│ ("event", "cancelled") emitted │ cancel_event impl │
│ on success │ │
└──────────────────────────────────┴──────────────────────────────────────┘

Notes

AlreadyFinalized (error code 18) was already present in EventError — no new
variant needed for that case. The Unauthorized variant (21) is the only
addition to the error enum.

@vercel

vercel Bot commented Jun 23, 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 23, 2026 2:59pm

@drips-wave

drips-wave Bot commented Jun 23, 2026

Copy link
Copy Markdown

@Awointa Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Olowodarey Olowodarey merged commit d22d361 into Arena1X:main Jun 23, 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] — Feature: Add cancel_event entrypoint (creator-only)

2 participants