feat(sc-001): implement on-chain claim registry - #325
Open
Charity5654 wants to merge 1 commit into
Open
Conversation
Add the foundational ClaimRegistry contract for TruthBounty V2.
Every claim must originate from this registry, making it the
canonical on-chain source of truth for all protocol state.
Changes:
- contracts/interfaces/IClaimRegistry.sol — clean interface for all
downstream modules (Verification Engine, Settlement Engine, etc.)
Defines ClaimStatus enum, Claim struct, events, custom errors, and
all required view/write function signatures.
- contracts/ClaimRegistry.sol — full implementation:
* permissionless createClaim() with strict input validation
* sequential, monotonic, never-reused claim IDs starting at 1
* immutable claim metadata (creator, statement, evidenceCID, createdAt)
* updateClaimStatus() gated by REGISTRY_UPDATER_ROLE
* view functions: getClaim, claimExists, totalClaims, getClaimCreator,
getClaimStatus
* ClaimCreated and ClaimStatusUpdated events for off-chain indexing
* custom errors: InvalidStatement, InvalidCID, InvalidDeadline,
ClaimNotFound, UnauthorisedStatusTransition, InvalidStatusTransition
* packed struct layout for gas efficiency
* AccessControl (OZ v5) for role management
- test/ClaimRegistry.test.ts — 54 tests:
* deployment, success cases, statement/CID/deadline validation,
registry behaviour, getClaim, getClaimCreator, getClaimStatus,
updateClaimStatus, immutability, access control, gas benchmarks
- docs/gas-benchmarks-claim-registry.md — gas benchmark documentation
createClaim: 255,308 gas | getClaim: 45,155 gas
- .gas-snapshots.json — updated with ClaimRegistry baseline figures
Pre-existing compilation fixes (unblocked our tests):
- contracts/TruthBounty.sol: add missing ERC20 import
- contracts/bootstrap/BootstrapController.sol: add PAUSER_ROLE,
GOVERNANCE_ROLE() to ITruthBountyWeighted interface, remove
erroneous 'view' modifier from _validateConfiguration
- contracts/deployment/MigrationManager.sol: add PAUSER_ROLE
- hardhat.config.ts: add viaIR:true to fix RewardEngine stack-too-deep
Test results: 54/54 ClaimRegistry tests pass
365 total passing | 28 pre-existing failures (unrelated modules)
Closes DigiNodes#281
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add the foundational ClaimRegistry contract for TruthBounty V2. Every claim must originate from this registry, making it the canonical on-chain source of truth for all protocol state.
Changes:
contracts/interfaces/IClaimRegistry.sol — clean interface for all downstream modules (Verification Engine, Settlement Engine, etc.) Defines ClaimStatus enum, Claim struct, events, custom errors, and all required view/write function signatures.
contracts/ClaimRegistry.sol — full implementation:
test/ClaimRegistry.test.ts — 54 tests:
docs/gas-benchmarks-claim-registry.md — gas benchmark documentation createClaim: 255,308 gas | getClaim: 45,155 gas
.gas-snapshots.json — updated with ClaimRegistry baseline figures
Pre-existing compilation fixes (unblocked our tests):
Test results: 54/54 ClaimRegistry tests pass
365 total passing | 28 pre-existing failures (unrelated modules)
Closes #281