Skip to content

feat(sc-001): implement on-chain claim registry - #325

Open
Charity5654 wants to merge 1 commit into
DigiNodes:mainfrom
Charity5654:feat/sc-001-on-chain-claim-registry
Open

feat(sc-001): implement on-chain claim registry#325
Charity5654 wants to merge 1 commit into
DigiNodes:mainfrom
Charity5654:feat/sc-001-on-chain-claim-registry

Conversation

@Charity5654

Copy link
Copy Markdown

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 #281

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

SC-001 — Implement On-Chain Claim Registry

1 participant