Skip to content

feat: add on-chain streak counter for daily puzzle check-ins - #377

Open
jamz-dev wants to merge 1 commit into
MindFlowInteractive:mainfrom
jamz-dev:feat/issue-365-on-chain-streak-counter
Open

jamz-dev wants to merge 1 commit into
MindFlowInteractive:mainfrom
jamz-dev:feat/issue-365-on-chain-streak-counter

Conversation

@jamz-dev

Copy link
Copy Markdown

Overview

This PR adds a Soroban contract in contracts/streak_counter that tracks per-player consecutive-day puzzle completion streaks. A check-in records a completed day using ledger time for day boundaries, increments the streak on consecutive days, resets it when a day is missed, and ignores repeat check-ins within the same day.

Related Issue

Changes

🔥 Streak Counter Contract

  • [MODIFY] contracts/streak_counter/src/lib.rs
    • Defines per-player streak state (current streak, last completed day).
    • Adds a check-in function that records a completed day for the calling player.
    • Derives the current day index from ledger timestamp so day boundaries follow chain time.
    • Increments the streak when the check-in lands on the day after the last completed day.
    • Resets the streak to 1 when one or more days were missed.
    • Treats a same-day repeat check-in as a no-op so it does not double count.
    • Includes unit tests covering consecutive increments, missed-day resets, and same-day repeats.

Verification Results

cargo test -p streak_counter
Acceptance Criteria Status
Streak increments on consecutive days ✅ Covered by unit tests
Missed day resets streak ✅ Covered by unit tests
Same-day repeat check-ins do not double count ✅ Covered by unit tests
All tests pass ✅ Contract unit tests

Closes #365

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.

On-Chain Streak Counter

1 participant