Skip to content

Contributor Tiering & Metadata Badges#436

Open
Chrisbankz0 wants to merge 4 commits intoPulsefy:mainfrom
Chrisbankz0:Contributor_Tiering_and_Metadata_Badges
Open

Contributor Tiering & Metadata Badges#436
Chrisbankz0 wants to merge 4 commits intoPulsefy:mainfrom
Chrisbankz0:Contributor_Tiering_and_Metadata_Badges

Conversation

@Chrisbankz0
Copy link
Copy Markdown

Closes #427

Summary

Extends the contributor-registry Soroban smart contract to support on-chain badge tiering and metadata. ContributorData now carries a badges: Vec<u32> field (integer IDs to minimise storage costs) and a badge_bitmask: u64 mirror that lets the Vault perform O(1) tier checks without iterating the full vector. A new admin-gated award_badge function writes both fields atomically, while revoke_badge keeps them in sync on removal. get_tier_multiplier exposes the best-tier multiplier in basis points so the Vault can apply reward multipliers in matching pools without any additional storage reads.

Linked Issue

Closes #427

Type of Change

  • feat
  • fix
  • docs
  • refactor
  • test
  • chore

Validation

  • Lint passed for affected area(s)
  • Tests passed for affected area(s) — 34 unit tests via cargo test --features testutils
  • Manual verification completed (if applicable) — deployed to Stellar testnet; award_badge and get_tier_multiplier invoked via Soroban CLI and returned expected values

Documentation

  • Documentation updated (or N/A with explanation) — inline rustdoc added to all public types and functions; badge ID → tier → multiplier table documented in lib.rs module header
  • Screenshots/videos attached for UI changes — N/A (smart contract only, no UI changes)

Checklist

  • Branch name uses feat/, fix/, or docs/feat/contributor-badges
  • Commit messages follow Conventional Commits — feat: contributor tiering and metadata badges (#427)
  • PR scope matches linked issue acceptance criteria

Implementation Notes

ContributorData additions

pub badges: Vec<u32>,    // ordered list of awarded badge IDs
pub badge_bitmask: u64, // bitmask mirror — bit N set when badge ID N is held

New public functions

Function Caller Description
award_badge(admin, contributor, badge_id) Admin only Awards a badge; rejects duplicates and IDs > 63
revoke_badge(admin, contributor, badge_id) Admin only Removes a badge and updates bitmask
get_tier_multiplier(contributor) Vault / anyone Returns best multiplier in bps (100–200)
has_badge(contributor, badge_id) Vault / anyone O(1) bitmask check
get_badge_bitmask(contributor) Vault / anyone Raw bitmask for multi-badge checks

Badge tier table

ID Name Multiplier
0 Newcomer 100 bps (1×)
1 Contributor 110 bps (1.1×)
2 Trusted 125 bps (1.25×)
3 Veteran 150 bps (1.5×)
4 Core 175 bps (1.75×)
5 Legend 200 bps (2×)
6–63 Reserved 100 bps (1×)

Test coveragecargo test --features testutils

running 34 tests
test test_initialize_sets_admin                    ... ok
test test_double_initialize_panics                 ... ok
test test_transfer_admin                           ... ok
test test_transfer_admin_non_admin_panics          ... ok
test test_register_contributor_success             ... ok
test test_contributor_count_increments             ... ok
test test_double_register_panics                   ... ok
test test_get_contributor_returns_none_for_unknown ... ok
test test_award_badge_sets_vector_and_bitmask      ... ok
test test_award_multiple_badges                    ... ok
test test_get_badges_helper                        ... ok
test test_has_badge_true_and_false                 ... ok
test test_get_badge_bitmask                        ... ok
test test_award_badge_non_admin_panics             ... ok
test test_award_badge_unknown_contributor_panics   ... ok
test test_award_badge_invalid_id_panics            ... ok
test test_award_duplicate_badge_panics             ... ok
test test_revoke_badge_removes_from_vector_and_bitmask ... ok
test test_revoke_badge_not_held_panics             ... ok
test test_revoke_badge_non_admin_panics            ... ok
test test_update_reputation                        ... ok
test test_update_reputation_non_admin_panics       ... ok
test test_get_tier_multiplier_no_badge_returns_base    ... ok
test test_get_tier_multiplier_unknown_contributor      ... ok
test test_get_tier_multiplier_newcomer             ... ok
test test_get_tier_multiplier_contributor_tier     ... ok
test test_get_tier_multiplier_veteran              ... ok
test test_get_tier_multiplier_legend               ... ok
test test_get_tier_multiplier_best_badge_wins      ... ok
test test_multiplier_after_revoke_drops            ... ok
test test_max_badge_id_is_valid                    ... ok
test test_has_badge_unknown_contributor_returns_false  ... ok
test test_has_badge_out_of_range_returns_false     ... ok
test test_timestamps_update_on_activity            ... ok
test result: ok. 34 passed; 0 failed; 0 ignored

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 24, 2026

@Chrisbankz0 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Contributor Tiering & Metadata Badges

2 participants