Skip to content

feat(contracts): CT-05, CT-08, CT-10, CT-12 — document expiry, insurance, reputation tests, bulk registration#938

Open
A6dulmalik wants to merge 1 commit into
CodeGirlsInc:mainfrom
A6dulmalik:feature/ct-05-08-10-12-contracts
Open

feat(contracts): CT-05, CT-08, CT-10, CT-12 — document expiry, insurance, reputation tests, bulk registration#938
A6dulmalik wants to merge 1 commit into
CodeGirlsInc:mainfrom
A6dulmalik:feature/ct-05-08-10-12-contracts

Conversation

@A6dulmalik
Copy link
Copy Markdown
Contributor

Summary

Implements four Stellar smart contract issues assigned to A6dulmalik. All contracts are in contracts/package/ and follow the existing codebase patterns (#![no_std], soroban-sdk 22.0.0, persistent storage with TTL_LEDGERS=6_307_200).


CT-05 — Document Registry with Expiry (contracts/package/document-registry/)

  • register_document accepts optional expires_at: Option<u64> (Unix timestamp)
  • is_valid(doc_id) returns false if past expires_at or revoked
  • get_document_status(doc_id) returns Active, Expired, or Revoked
  • Expired documents are preserved (immutable hash record for audit)
  • Documents with no expires_at are permanently valid unless revoked
  • Tests: future expiry (valid), past expiry (invalid), no expiry (always valid), revoked, hash preserved after expiry

CT-08 — Shipment Insurance Tracking (contracts/package/shipment-insurance/)

  • create_shipment accepts is_insured: bool, insurance_premium: i128, insurance_policy_id: String
  • get_insurance_status(shipment_id) returns { is_insured, premium, policy_id }
  • open_dispute emits InsuranceClaim event with policy ID when shipment is insured
  • Uninsured shipments store is_insured: false and zero values
  • insurance_policy_id max 64 chars; longer returns PolicyIdTooLong
  • Tests: insured creation, uninsured creation, dispute event on insured, policy ID length validation

CT-10 — Reputation Contract Test Suite (contracts/package/tests/reputation/)

  • add_rating: scores 1–5 succeed; scores 0 and 6 return InvalidScore
  • Composite score with known inputs: explicit expected values (not re-computed)
  • Duplicate rating: same caller + same shipment returns DuplicateRating
  • get_reputation: verifies all three score components (rating, on-time, completion)
  • update_stats: on-time percentage updates correctly; unauthorized caller fails

CT-12 — Bulk Document Registration (contracts/package/document-bulk/)

  • register_documents_batch(docs: Vec<DocumentEntry>) where DocumentEntry = { hash, doc_type, ipfs_cid, expires_at }
  • Max 10 documents per batch; exceeding returns BatchLimitExceeded
  • Duplicate hash (on-chain or within-batch) returns HashAlreadyRegistered
  • Atomic: validation runs before any writes; failed batch registers nothing
  • Returns Vec<BytesN<32>> — the list of document IDs (hashes) created
  • Tests: valid batch of 5, batch of exactly 10, batch of 11 fails, duplicate causes full rollback, within-batch duplicate rollback

Closes #913
Closes #916
Closes #918
Closes #920

CT-05 (document-registry): Add document expiry support with optional
expires_at timestamp, is_valid() query, get_document_status() returning
Active/Expired/Revoked, and revoke_document(). Expired records preserved
for audit.

CT-08 (shipment-insurance): Add on-chain insurance metadata to shipments
with is_insured, insurance_premium, insurance_policy_id fields. Emits
InsuranceClaim event on dispute for insured shipments. Policy ID capped
at 64 chars (PolicyIdTooLong error).

CT-10 (tests/reputation): Comprehensive test suite for the reputation
contract covering add_rating (scores 1-5 valid, 0/6 invalid), composite
score with known expected values, duplicate rating rollback,
get_reputation breakdown, and update_stats on-time percentage.

CT-12 (document-bulk): Atomic batch document registration up to 10 docs.
Returns BatchLimitExceeded if >10, HashAlreadyRegistered on any duplicate
(including within-batch). Full rollback if any validation fails.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 30, 2026

@A6dulmalik is attempting to deploy a commit to the Mftee's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 30, 2026

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant