Skip to content

Feat/giveaway claim timeout - #418

Merged
3m1n3nc3 merged 2 commits into
geevapp:mainfrom
Cybermaxi7:feat/giveaway-claim-timeout
Jul 26, 2026
Merged

Feat/giveaway claim timeout#418
3m1n3nc3 merged 2 commits into
geevapp:mainfrom
Cybermaxi7:feat/giveaway-claim-timeout

Conversation

@Cybermaxi7

@Cybermaxi7 Cybermaxi7 commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

closes #406

Implements #406 — adds a claim deadline and creator recovery path for unclaimed giveaway prizes.

This also absorbs the stated dependency, "Replace public distribution with winner claim lifecycle," since it hadn't landed yet in this repo — there was no per-winner claim step to attach a timeout to, so this PR builds both in one pass.

  • Replaces the push-based distribute_prize (which paid every winner in one call) with a pull-based claim_prize(giveaway_id, winner) that each winner calls individually for their own share
  • Giveaway gains claim_deadline (set once, 7 days after the giveaway becomes Claimable) and claimed_count
  • New recover_unclaimed_prize(giveaway_id, caller) — callable by the creator or admin once claim_deadline has passed — sweeps any still-unclaimed shares back to the creator and finalizes the giveaway; shares already claimed by other winners are untouched
  • Fee (fee_bps) is now deducted per-claim, on the claiming winner's share only; recovered/unclaimed funds return to the creator at full value since they were never distributed
  • Giveaway auto-completes once every winner has claimed, without waiting for the deadline

Requirements addressed

  • Track a claim deadline after winner selection (claim_deadline, fixed 7-day window)
  • Recovery entrypoint for expired unclaimed giveaways (recover_unclaimed_prize)
  • Fallback outcome defined: refund to creator
  • Claim deadline enforced in the payout path (claim_prize rejects claims after expiry)

Acceptance criteria

  • Claimable giveaways cannot remain indefinitely unresolved without a timeout policy
  • Expired unclaimed prizes follow a deterministic recovery path (refund to creator)
  • Tests cover both successful claims and timed-out claims

Test plan

  • cargo test — 71/71 passing, including new coverage: claim before/after expiry, double-claim rejection, non-winner claim rejection, recovery before/after expiry, unauthorized recovery rejection, and partial-claim recovery (one winner claims, one doesn't — only the unclaimed share is recovered, claimed funds untouched)
  • cargo fmt --check — clean
  • cargo clippy --all-targets — clean (no new warnings)

Closes #406
Fixes #406

…vapp#406)

Replaces the push-based distribute_prize with a pull-based claim
lifecycle: winners call claim_prize individually while Claimable and
before a 7-day claim_deadline set at winner selection. After expiry,
the creator or admin can call recover_unclaimed_prize to sweep any
still-unclaimed shares back to the creator, finalizing the giveaway.
Already-claimed shares are untouched by recovery.
@3m1n3nc3
3m1n3nc3 merged commit 6eeb601 into geevapp:main Jul 26, 2026
2 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.

[Giveaway] Add unclaimed prize timeout and creator recovery

2 participants