Skip to content

feat: reputation contract#46

Merged
soomtochukwu merged 1 commit into
DXmakers:mainfrom
anonfedora:feature/reputation-conract
Mar 27, 2026
Merged

feat: reputation contract#46
soomtochukwu merged 1 commit into
DXmakers:mainfrom
anonfedora:feature/reputation-conract

Conversation

@anonfedora
Copy link
Copy Markdown
Contributor

@anonfedora anonfedora commented Mar 26, 2026

PR Title

Implement reputation contract admin controls and score clamping

PR Description

Closes #2

Summary

  • Implemented initialize to persist the admin key and reject double-initialization.
  • Implemented update_score with admin authentication, default score bootstrap (5000 bps), clamped score updates (0..10000), and total_jobs incrementing.
  • Implemented slash with admin authentication and fixed 2000 bps penalty (20% of max), clamped at 0.
  • Implemented get_score to return stored values or a default ReputationScore (score=5000, total_jobs=0).
  • Added internal score clamp helper to enforce bounds for all write paths.

Why

This completes the on-chain reputation contract behavior needed for trust signals and future feature gating while ensuring score safety invariants and admin-only mutation paths.

Test Plan

  • Build contract WASM:
    • cargo build -p reputation --target wasm32-unknown-unknown --release
  • Verify initialize rejects second call.
  • Verify unauthenticated calls to update_score and slash fail.
  • Verify update_score starts from default 5000 for unseen (address, role).
  • Verify score never exceeds 10000 or drops below 0 for large positive/negative deltas.
  • Verify slash always deducts exactly 2000 bps, with floor clamp at 0.

If you want, I can also generate a shorter version tailored to your repo’s usual PR style.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Mar 26, 2026

@anonfedora 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

@soomtochukwu
Copy link
Copy Markdown
Contributor

@anonfedora, message me on discord

@soomtochukwu soomtochukwu merged commit 814646c into DXmakers:main Mar 27, 2026
5 checks passed
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.

Reputation Contract Implementation

2 participants