Skip to content

Fix storage API gaps and compilation errors (issues #922-925) - #1

Open
owennashdev-ctrl wants to merge 4 commits into
mainfrom
fix/issue-925-924-923-922
Open

Fix storage API gaps and compilation errors (issues #922-925)#1
owennashdev-ctrl wants to merge 4 commits into
mainfrom
fix/issue-925-924-923-922

Conversation

@owennashdev-ctrl

Copy link
Copy Markdown
Owner

Summary

Fixes four related issues by implementing missing storage functions and fixing compilation errors.

Changes

Issue Haroldwonder#925: Remove duplicate type definitions and fix orphaned code

  • Removes duplicate IssuerStats, ContractConfig, MultiSigProposal, and ExpirationHook definitions
  • Cleans up malformed code in lib.rs

Issue Haroldwonder#922: Implement Storage::get_claim_type_constraints()

  • Retrieves constraint configurations for specific claim types
  • Enables validate_claim_constraints() validation code path
  • Includes test coverage

Issue Haroldwonder#924: Implement Storage::increment_issuer_stats()

  • Atomically updates issuer statistics counters
  • Uses saturation arithmetic to prevent overflow
  • Includes test coverage

Issue Haroldwonder#923: Implement Storage::remove_issuer_attestation()

  • Properly removes attestations from issuer indexes
  • Delegates to ChunkedIndex::remove_issuer()
  • Includes test coverage

Closes Haroldwonder#925 Haroldwonder#924 Haroldwonder#923 Haroldwonder#922

… compilation errors

- Remove duplicate IssuerStats struct definition
- Remove duplicate ContractConfig struct definition
- Remove duplicate MultiSigProposal struct definition
- Remove duplicate ExpirationHook struct definition
- Remove orphaned code fragment in lib.rs
- Add missing type imports to lib.rs

Resolves type mismatch and duplicate definition compiler errors, enabling
subsequent validation and constraint checks to compile correctly.
…im_type_constraints

Add Storage::get_claim_type_constraints() to retrieve constraint configurations
for specific claim types. This mirrors the existing set_claim_type_constraints()
setter and enables the validate_claim_constraints() validation code path.

Test verifies that:
- Constraints can be stored and retrieved correctly
- min_metadata_len, max_metadata_len, and require_metadata fields persist
- Nonexistent claim types return None

The function handles the None case gracefully, allowing validation to proceed
when no constraints are configured for a claim type.

Closes Haroldwonder#922
…ment_issuer_stats

Add Storage::increment_issuer_stats() to atomically update issuer statistics
counters on attestation operations. The function retrieves the current stats,
increments the total_issued count, and stores the updated stats back to persistent
storage using saturation arithmetic to prevent overflow.

Test verifies that:
- Initial stats start at 0
- Multiple calls increment correctly
- Zero increments don't cause issues
- Saturation arithmetic prevents overflow

This function is called from attestation creation paths to track issuance counts
per issuer, enabling confidence score calculations and reputation tracking.

Closes Haroldwonder#924
…e_issuer_attestation

Add Storage::remove_issuer_attestation() to properly remove attestations from an
issuer's index when they are revoked, transferred, or deleted. The implementation
delegates to ChunkedIndex::remove_issuer() to handle the chunked index maintenance,
ensuring that transferred attestations are correctly purged from the old issuer's
index and don't silently accumulate.

Test verifies that:
- Attestations are created for an issuer
- Calling remove_issuer_attestation removes the attestation from the index
- The attestation no longer appears in get_issuer_attestations results
- Other attestations remain in the index

This fixes the naming drift where transfer_attestation and other operations
called a nonexistent function instead of using the correct ChunkedIndex API.

Closes Haroldwonder#923
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.

validation.rs: claim-type constraint checks compare usize length against u32 bounds (E0308)

1 participant