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>, mirroring MutualAidContract::get_request
- Add
get_winners(giveaway_id) -> Vec<Address> and get_participants(giveaway_id) -> Vec<Address>
- Add
has_claimed(giveaway_id, winner) -> bool reading DataKey::Claimed(id, winner)
- All getters must be read-only: no
require_auth, no storage writes, and return Option / empty Vec instead 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
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.
Description
contracts/geev-core/src/giveaway.rsexposes no read-only view functions. Every other module offers at least one getter —mutual_aid.rshasget_request(line 53),profile.rshasget_profile/resolve_username/get_reputation,governance.rshasget_flag_count/has_flagged— but a client that wants to read a giveaway must decode rawDataKey::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
DataKeyor theGiveawaystruct 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
contracts/geev-core/src/giveaway.rs,contracts/geev-core/src/test.rs,contracts/README.mdget_giveaway(giveaway_id) -> Option<Giveaway>, mirroringMutualAidContract::get_requestget_winners(giveaway_id) -> Vec<Address>andget_participants(giveaway_id) -> Vec<Address>has_claimed(giveaway_id, winner) -> boolreadingDataKey::Claimed(id, winner)require_auth, no storage writes, and returnOption/ emptyVecinstead of panicking on a missing idSuggested Implementation
Acceptance Criteria
Submission Guidelines
feat/giveaway-view-functionsfeat(giveaway): add read-only view functionsGap verified against
origin/mainat87de441on 2026-08-27; line references above are from that commit.