Skip to content

feat: StellarNetworkSwitcher, OwnershipChainValidator, document detail & verify pages - #1072

Open
khaadish wants to merge 1 commit into
CodeGirlsInc:mainfrom
khaadish:feat/ct-11-ct-22-fe-18-fe-20
Open

feat: StellarNetworkSwitcher, OwnershipChainValidator, document detail & verify pages#1072
khaadish wants to merge 1 commit into
CodeGirlsInc:mainfrom
khaadish:feat/ct-11-ct-22-fe-18-fe-20

Conversation

@khaadish

Copy link
Copy Markdown
Contributor

Summary

This PR implements four assigned issues in a single batch:


CT-11 — StellarNetworkSwitcher (contract/src/module/network/)

  • StellarNetwork enum (Testnet / Mainnet)
  • parse_network(value: &str) — case-insensitive, returns descriptive Err for unknown values
  • network_from_env() — reads STELLAR_NETWORK env var; startup fails with a clear error on unrecognised values
  • GET /module/network — returns current network name and Horizon URL as JSON
  • 8 unit tests covering: testnet lowercase, mainnet lowercase, mixed-case inputs (Testnet, MAINNET, TestNet), invalid string, empty string

CT-22 — OwnershipChainValidator (contract/src/module/ownership_chain/)

  • ValidationResult enum: Valid, Invalid { gap_at_index, expected_owner, found_owner }, Empty
  • validate_chain(document_hash, cache) — fetches TransferRecords from Redis and checks each from_owner == previous.to_owner
  • GET /module/chain/:document_hash — returns ValidationResult as JSON
  • 5 unit tests: empty history, single transfer, valid two-step chain, gap at index 1, gap at last transfer

FE-18 — Document detail page (frontend/app/(protected)/documents/[id]/page.tsx)

  • Fetches GET /api/documents/:id and GET /api/documents/:id/risk in parallel
  • Circular SVG risk gauge (colour-coded: green < 30, amber < 60, red ≥ 60)
  • Flag breakdown cards: name, weight, detected ✓/✗, contribution
  • Vertical status timeline: PENDING → ANALYZING → VERIFIED / FLAGGED / REJECTED
  • Skeleton loader while data is fetching
  • Real-time status updates via WebSocket (reconnects on drop)
  • Actions: Verify on Stellar (only when PENDING or FLAGGED), Download Report, File Dispute, Share modal

FE-20 — Verify / Stellar anchoring page (frontend/app/(protected)/documents/[id]/verify/page.tsx)

  • Redirects to document detail if the document is already VERIFIED
  • Pre-verification state: anchoring explanation, document hash (SHA-256 preview), estimated cost note, "Anchor on Stellar" button → calls POST /api/documents/:id/verify
  • Processing state: animated progress bar + real-time status messages via WebSocket (with polling fallback)
  • Post-verification state: green checkmark, copyable Stellar tx hash linking to Stellar Explorer, anchor timestamp, ledger number, QR code (server-generated or placeholder), "Download Verification Certificate" button (print)

Testing

  • TypeScript: tsc --noEmit passes with zero errors on the frontend
  • Rust unit tests are co-located in each module file and run with cargo test

closes #543
closes #554
closes #830
closes #832

CT-11 — StellarNetworkSwitcher (contract/src/module/network/mod.rs)
- StellarNetwork enum with Testnet and Mainnet variants
- parse_network() with case-insensitive matching and descriptive errors
- network_from_env() validates STELLAR_NETWORK at startup
- GET /module/network handler returning current network + Horizon URL
- 8 unit tests covering all acceptance criteria

CT-22 — OwnershipChainValidator (contract/src/module/ownership_chain/mod.rs)
- ValidationResult enum: Valid, Invalid { gap_at_index, expected_owner, found_owner }, Empty
- validate_chain() fetches TransferRecords from cache and checks continuity
- GET /module/chain/:document_hash handler returning result as JSON
- 5 unit tests: empty history, single transfer, valid two-step chain, gap at index 1, gap at last transfer

FE-18 — Document detail page (frontend/app/(protected)/documents/[id]/page.tsx)
- Fetches GET /api/documents/:id and GET /api/documents/:id/risk in parallel
- Circular SVG risk gauge (colour-coded 0-100)
- Flag breakdown cards (detected/not-detected, weight, contribution)
- Vertical status timeline: PENDING → ANALYZING → VERIFIED/FLAGGED/REJECTED
- Skeleton loader while fetching
- Real-time status updates via WebSocket
- Actions: Verify on Stellar, Download Report, File Dispute, Share modal

FE-20 — Verify page (frontend/app/(protected)/documents/[id]/verify/page.tsx)
- Redirects to detail page if document is already VERIFIED
- Pre-verification: document hash preview, cost note, Anchor on Stellar button
- Processing: animated progress bar + WebSocket real-time progress messages
- Post-verification: green checkmark, copyable tx hash with Stellar explorer link, ledger number, QR code, Download Verification Certificate (print)

Wiring: lib.rs exports pub mod module, imports network_handler + chain_handler,
routes /module/network and /module/chain/:document_hash added to app() router.
@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

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

drips-wave Bot commented Jul 27, 2026

Copy link
Copy Markdown

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