Repository navigation
[Giveaway] Add read-only view functions for giveaway state #433
Description
Description
contracts/geev-core/src/giveaway.rs exposes no read-only view functions. Every other module offers at least one getter — mutual_aid.rs has get_request (line 53), profile.rs has get_profile / resolve_username / get_reputation, governance.rs has get_flag_count / has_flagged — but a client that wants to read a giveaway must decode raw DataKey::Giveaway(id) / DataKey::ParticipantIndex(id, index) storage entries itself. The only lookup helper that exists, find_winner_index (line 317), is private.
This forces the off-chain indexer and the frontend to duplicate the contract's storage layout, which then silently breaks whenever DataKey or the Giveaway struct changes.
User Story
As an Indexer / Frontend Developer,
I want to read giveaway state through contract view functions,
so that I do not have to reimplement the contract's storage layout off-chain.
Requirements and Context
- Files / refs:
contracts/geev-core/src/giveaway.rs,contracts/geev-core/src/test.rs,contracts/README.md - Add
get_giveaway(giveaway_id) -> Option<Giveaway>, mirroringMutualAidContract::get_request - Add
get_winners(giveaway_id) -> Vec<Address>andget_participants(giveaway_id) -> Vec<Address> - Add
has_claimed(giveaway_id, winner) -> boolreadingDataKey::Claimed(id, winner) - All getters must be read-only: no
require_auth, no storage writes, and returnOption/ emptyVecinstead of panicking on a missing id
Suggested Implementation
1. Add get_giveaway returning Option<Giveaway> from DataKey::Giveaway
2. Add get_winners reading giveaway.winners, empty Vec when absent
3. Add get_participants walking DataKey::ParticipantIndex 0..participant_count
4. Add has_claimed reading DataKey::Claimed(id, winner)
5. Add tests covering populated, empty, and non-existent giveaway ids
Acceptance Criteria
- Giveaway state is readable without decoding raw storage keys
- Getters never panic for unknown ids and never mutate state
- Tests cover populated, empty, and missing-id cases
Submission Guidelines
- Branch:
feat/giveaway-view-functions - Depends on: None
- PR:
feat(giveaway): add read-only view functions
Gap verified against origin/main at 87de441 on 2026-08-27; line references above are from that commit.
Activity
abdulrahamza commentedon Aug 27, 2026
Hi maintainer, I'll like to get assigned into this and I believe I'll deliver a quality and productive PR within a short period of time.
Carlys17 commentedon Aug 27, 2026
I'd like to work on this. I'll add read-only getters to giveaway.rs — get_giveaway, get_winners, get_participants, and has_claimed — that never panic or mutate state, with tests covering populated, empty, and missing-id cases.
SaintSammi commentedon Aug 28, 2026
Hi team, I'd like to be assigned this issue.
Adding read-only view functions to contracts/geev-core/src/giveaway.rs: get_giveaway, get_winners, get_participants, and has_claimed, mirroring the getter patterns already used in mutual_aid.rs and profile.rs. I'll make sure each one is truly read-only (no require_auth, no storage writes) and returns Option/empty Vec rather than panicking on unknown ids, plus tests covering populated, empty, and missing-id cases.
I'll work off branch feat/giveaway-view-functions and open the PR as feat(giveaway): add read-only view functions once ready. Let me know if it's free to take.
grantfox-oss commentedon Aug 29, 2026
🦊 GrantFox — @SaintSammi has been assigned to this issue as part of the Third Campaign campaign!
Next steps:
Closes #433)Good luck! Track your progress on GrantFox.
grantfox-oss commentedon Aug 31, 2026
🎉 This issue has been marked as completed on GrantFox!
@SaintSammi's PR #446 was approved and merged by @3m1n3nc3.
🏆 @SaintSammi: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (351 total points). Track your full progress on GrantFox.
👏 Great work, @SaintSammi! Keep contributing to geevapp.