Skip to content

[Giveaway] Add read-only view functions for giveaway state #433

Description

@3m1n3nc3

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

  • 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

  1. added theissue type on Aug 27, 2026
  2. abdulrahamza commented on Aug 27, 2026

    @abdulrahamza

    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.

  3. Carlys17 commented on Aug 27, 2026

    @Carlys17

    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.

  4. SaintSammi commented on Aug 28, 2026

    @SaintSammi
    Contributor

    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.

  5. grantfox-oss commented on Aug 29, 2026

    @grantfox-oss

    🦊 GrantFox — @SaintSammi has been assigned to this issue as part of the Third Campaign campaign!

    Next steps:

    1. Open a Pull Request referencing this issue (e.g., Closes #433)
    2. Your PR will be reviewed by the geevapp maintainers

    Good luck! Track your progress on GrantFox.

  6. grantfox-oss commented on Aug 31, 2026

    @grantfox-oss

    🎉 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions