Problem
The reputation contract only stores the current score (storage.rs lines 27-46). Historical score changes are only emitted as events (off-chain), not stored on-chain. There is no function to query score history or past score changes.
Contract impact: Users cannot query their score history from the contract. The off-chain indexer must track all events to build a history, which may have gaps if the indexer was down.
Before Starting
Read: context/architecture-context.md
Root Cause
Score history storage was deferred during initial implementation.
What To Build
- Add
ScoreChange struct with score, timestamp, reason
- Store score changes in persistent storage with Vec or similar
- Add
get_score_history(env, address, page, limit) -> Vec<ScoreChange> function
- Ensure TTL extension on each append
- Cap history at 100 entries per user (FIFO eviction)
Files To Touch
contracts/reputation-contract/src/storage.rs — add history storage
contracts/reputation-contract/src/types.rs — add ScoreChange struct
contracts/reputation-contract/src/lib.rs — add get_score_history
contracts/reputation-contract/src/events.rs — ensure events include reason
Acceptance Criteria
Mandatory Checks
Problem
The reputation contract only stores the current score (storage.rs lines 27-46). Historical score changes are only emitted as events (off-chain), not stored on-chain. There is no function to query score history or past score changes.
Contract impact: Users cannot query their score history from the contract. The off-chain indexer must track all events to build a history, which may have gaps if the indexer was down.
Before Starting
Read: context/architecture-context.md
Root Cause
Score history storage was deferred during initial implementation.
What To Build
ScoreChangestruct with score, timestamp, reasonget_score_history(env, address, page, limit) -> Vec<ScoreChange>functionFiles To Touch
contracts/reputation-contract/src/storage.rs— add history storagecontracts/reputation-contract/src/types.rs— add ScoreChange structcontracts/reputation-contract/src/lib.rs— add get_score_historycontracts/reputation-contract/src/events.rs— ensure events include reasonAcceptance Criteria
Mandatory Checks