Skip to content

Commit 44d5d8b

Browse files
committed
refactor: remove redundant PrizeClaimed storage flag, use paid_at as sole guard
1 parent 3d7f510 commit 44d5d8b

3 files changed

Lines changed: 0 additions & 32 deletions

File tree

contracts/events/src/event_ops.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -737,11 +737,6 @@ pub fn claim_prize(
737737

738738
recipient.require_auth();
739739

740-
// Prevent double-claim for this (event, recipient, position).
741-
if storage::is_prize_claimed(env, event_id, &recipient, position) {
742-
return Err(Error::PrizeAlreadyClaimed);
743-
}
744-
745740
// Look up the anchor index stored at selection time (O(1) instead of
746741
// a linear scan). Returns NoSubmissions if no winner matches or the
747742
// prize has already been claimed (canonical guard: paid_at).
@@ -768,9 +763,6 @@ pub fn claim_prize(
768763
escrow::release(env, &event.token, &recipient, amount);
769764
event.remaining_escrow = event.remaining_escrow.saturating_sub(amount);
770765

771-
// Mark prize claimed (prevents replay for this recipient + position).
772-
storage::mark_prize_claimed(env, event_id, &recipient, position);
773-
774766
// Update the anchor row in-place with the paid timestamp instead of
775767
// appending a duplicate row. This keeps winner_count == selected count.
776768
storage::set_winner_at(

contracts/events/src/storage.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -648,27 +648,6 @@ pub fn set_crowdfunding_milestones_claimed(env: &Env, id: u64, count: u32) {
648648
touch_event_persistent(env, &key);
649649
}
650650

651-
// ============================================================
652-
// PRIZE CLAIMS (persistent; per-(event, recipient, position))
653-
//
654-
// Tracks which winners have claimed their prize in the pull-model flow for
655-
// Single-release events (bounties, hackathons). Written by claim_prize.
656-
// ============================================================
657-
pub fn is_prize_claimed(env: &Env, id: u64, recipient: &Address, position: u32) -> bool {
658-
let key = DataKey::PrizeClaimed(id, recipient.clone(), position);
659-
let claimed: Option<bool> = env.storage().persistent().get(&key);
660-
if claimed.is_some() {
661-
touch_event_persistent(env, &key);
662-
}
663-
claimed.unwrap_or(false)
664-
}
665-
666-
pub fn mark_prize_claimed(env: &Env, id: u64, recipient: &Address, position: u32) {
667-
let key = DataKey::PrizeClaimed(id, recipient.clone(), position);
668-
env.storage().persistent().set(&key, &true);
669-
touch_event_persistent(env, &key);
670-
}
671-
672651
// ============================================================
673652
// CANCELLATION STATE (persistent; present only while Cancelling)
674653
// ============================================================

contracts/events/src/types.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,6 @@ pub enum DataKey {
197197
// Appended in 1.2.0 to preserve existing key discriminants.
198198
NonOwnerContributionTotal(u64),
199199

200-
// Added last so earlier variant discriminants remain stable on upgrade.
201-
PrizeClaimed(u64, Address, u32),
202-
203200
// Winner anchor index for O(1) claim_prize lookup (added 2026-07).
204201
WinnerIndex(u64, Address, u32),
205202

0 commit comments

Comments
 (0)