docs(contracts): add Rust doc comments to all public contract functions#3
Open
pauljacobb wants to merge 90 commits into
Open
docs(contracts): add Rust doc comments to all public contract functions#3pauljacobb wants to merge 90 commits into
pauljacobb wants to merge 90 commits into
Conversation
- docs/runbooks/contract-deployment.md: testnet/mainnet deploy, verify, rollback - docs/runbooks/meter-key-rotation.md: scheduled and emergency key rotation - docs/runbooks/failed-mint-investigation.md: diagnose and retry failed mints - docs/runbooks/incident-response.md: triage, containment, resolution, postmortem - docs/runbooks/README.md: index of all runbooks Closes AnnabelJoe#315
…nnabelJoe#260) - WebSocket connection established on dashboard load - Chart updates automatically when new meter readings arrive - Graceful fallback to polling (30s interval) if WebSocket unavailable - Connection status indicator: Live / Polling / Offline / Connecting Closes AnnabelJoe#260
AnnabelJoe#319) - energy_token: enhanced balance() and total_supply() with examples - audit_registry: enhanced anchor(), verify(), api_signer(), admin() with full Arguments/Errors/Example sections - community_governance: enhanced set_quorum_bps, get_quorum_bps, set_threshold_bps, get_threshold_bps, pending_upgrade, get_execution_timelock, proposal_count with Panics/Arguments/Examples All public functions now have /// doc comments with Panics, Arguments, Authorization, and example invocations where applicable. Closes AnnabelJoe#319
- Add docs/USER_GUIDE.md covering all acceptance criteria: wallet connection, dashboard overview, meter readings, certificates (view + retire), governance (view/vote/create), and the public verifier - Include screenshot placeholders for each step - Link guide from dashboard page header via BookOpen icon
…oe#274) - Enable RLS on cooperatives, meters, readings, certificates - Members can only read rows belonging to their cooperative (cooperative_id sourced from JWT app_metadata) - Readings isolated via meter → cooperative join - Admin JWT role bypasses all policies for support operations - Policy tester SQL covers member isolation + admin bypass cases
- Add CertificateListSkeleton component to skeleton.tsx - Create /certificates page with skeleton loader during data fetch - Add GET /api/certificates list endpoint - Dashboard and verify pages already had skeletons (StatCardSkeleton, ChartSkeleton, TableRowSkeleton, SectionSkeleton) Closes AnnabelJoe#255
- Runs cargo fmt, clippy, and cargo test --all on every PR - Scoped to apps/contracts/** path changes - Uses Swatinem/rust-cache for faster Rust compilation - Fails PR merge if any check fails Closes AnnabelJoe#287
…es (AnnabelJoe#331) - Add cargo-mutants config targeting audit_registry and energy_token with 70% minimum score threshold - Add Stryker config for packages/stellar with vitest runner and 70% break threshold - Add vitest setup and unit tests for kwhToStroops, stroopsToKwh, NETWORKS, CONTRACT_IDS - Add weekly scheduled GH Actions workflow (Sunday 02:00 UTC) with manual dispatch and per-target filtering - Add docs/MUTATION_TESTING.md with local run instructions, thresholds, scope, and result interpretation guide Closes AnnabelJoe#331
- POST /api/certificates/:id/retire calls energy_token burn on Soroban - Records retirement timestamp, beneficiary, and retire_tx_hash in certificates table - Returns 409 if certificate already retired - Emits retirement_events record for audit log - Add migration 005: retire_tx_hash column + retirement_events table - Update database.types.ts with new fields Closes AnnabelJoe#270
…edge-case tests - initialize() now stores the passed quorum param instead of hardcoded default - set_quorum_bps / set_threshold_bps now verify caller == stored admin - Added tests: initialize configures quorum, zero quorum rejected, exactly-at-quorum passes, one-below-quorum expires, admin update paths, non-admin rejection
- Export verifyReadingSignature() from crypto.ts (wraps @noble/ed25519 verifyAsync, never throws — returns false on malformed input) - Tests cover: valid sig, invalid sig, tampered payload, wrong key, malformed sig bytes, malformed pubkey, hash determinism, hash sensitivity
…ersion header - middleware: change unversioned redirect from 308 to 301 (Moved Permanently) - middleware: inject API-Version: v1 header on all /api/* responses - openapi.yaml: document /api/v1/ canonical paths, legacy 301 redirect paths, API-Version response header component, and versioning policy in description
- ci.yml: add image-scan job (runs after web job) - builds Docker image from apps/web/Dockerfile - scans with aquasecurity/trivy-action@0.28.0 - exit-code 1 blocks image promotion on CRITICAL CVEs - uploads SARIF as CI artifact (30-day retention) - uploads SARIF to GitHub Security tab - Dockerfile: add comment guiding digest pinning procedure
- Composite index on readings(meter_id, timestamp) - Composite index on certificates(status, created_at) - Index on audit_anchors(tx_hash) - Rollback script included
- deploy-production.yml: deploys to Vercel on every main merge only after CI (lint/type-check/test/build/contracts) passes - preview.yml: gate PR preview deploys on CI passing - Deployment URL written to job summary and GitHub environment
dashboard/page.tsx:
- Remove 3 stray </SectionErrorBoundary> closing tags with no opening match
- Fix 2 unclosed JSX comments {/* ... */} missing closing brace
verify/page.tsx:
- Remove duplicate Row function fragment dangling after closing brace
- Add missing Section component
- Import and wire useToast hook to replace undefined pushToast calls
- Guard result?.meter_proof null access
- Add 'action' field to FormState and EMPTY defaults - Validate proposed_action is required - Render Proposed action input above voting deadline - Matches acceptance criteria: title, description, voting deadline, proposed action
…#340) - X-Frame-Options: DENY - X-Content-Type-Options: nosniff - Referrer-Policy: strict-origin-when-cross-origin - Permissions-Policy restricts camera, mic, geolocation, payment, usb
- license-checker runs in CI on every push/PR - Approved license list in .license-checker.json (MIT, Apache-2.0, BSD, ISC, etc.) - CI fails on any unapproved license (GPL and other copyleft blocked)
…belJoe#341) - audit_logs table: id, timestamp, actor, action, resource, resource_id, ip, metadata - Append-only: UPDATE/DELETE revoked at DB level - writeAuditLog() utility in src/lib/audit.ts - readings route logs: reading.submitted, reading.anchored, certificate.minted - Admin API: GET /api/admin/audit-logs (paginated, service_role only) - Supabase migration: supabase/migrations/20260601000000_create_audit_logs.sql
- POST /api/certificates/:id/transfer with Stellar address validation - transferCertificate() in stellar.ts using SEP-41 transfer call - Audit log entry for certificate.transfer action - TransferModal component matching RetireModal pattern - Transfer button added to certificates dashboard table - v1 redirect at /api/v1/certificates/:id/transfer
- createMockFreighter() / installMockFreighter() / uninstallMockFreighter() utilities in src/tests/mock-freighter.ts - Supports connection, signing, disconnection, requiresAccess flag - wallet.test.ts covers connect, disconnect, session restore, revoked session, missing extension, and production isolation - vitest config updated to run wallet tests in jsdom environment
- Failed mint triggers tracer-sim diagnosis via /replay endpoint - Diagnosis result stored on reading record and matches returned value - TRACER_SIM_URL unset returns TRACER_SIM_UNAVAILABLE stub gracefully - HTTP error (503), network failure (ECONNREFUSED), and timeout all return REPLAY_ERROR without throwing - Partial tracer-sim responses filled with sensible defaults - Mock tracer-sim via vi.fn() — no real service required in CI
- buildIRecXml() in src/lib/irec-xml.ts maps certificate fields to I-REC Standard v3 XML including on-chain AnchorProof extension - GET /api/certificates/:id/irec-export returns XML with Content-Disposition: attachment for direct download - v1 redirect at /api/v1/certificates/:id/irec-export - I-REC export button added to certificates dashboard table - XML escaping prevents injection via certificate/meter data
…d public verifier - dashboard.spec.ts: wallet-connected and connect-prompt flows via Freighter mock - certificate.spec.ts: certificate detail page with Supabase route interception + 404 case - playwright.yml: CI workflow running against staging, uploads screenshots on failure - playwright.config.ts: support BASE_URL env var for staging; skip local server when remote
- supabase/config.toml: jwt_expiry 3600→900 (15 min access tokens) - refresh_token_rotation_enabled=true, reuse_interval=10s - migration: revoked_tokens table with JTI primary key + auto-expiry - auth.ts: revokeToken() helper + revocation-list check in requireAuth() - logout route: revokes access token JTI before signing out
- middleware.ts: 301 redirect HTTP→HTTPS in production (x-forwarded-proto check) - middleware matcher: expanded to all routes (excl. static assets) so redirect fires on page requests, not just API calls - next.config.ts: Strict-Transport-Security max-age=31536000; includeSubDomains; preload plus X-Content-Type-Options, X-Frame-Options, Referrer-Policy on all routes - Submit domain to HSTS preload list at https://hstspreload.org after deploy
- GET /api/v1/verify/:certificateId returns full chain of custody - No authentication required (security: []) - Response includes meter ID, reading, signature, anchor tx, certificate, retirement status - Rate limited (60 req/min per IP via middleware) - Documented in OpenAPI spec with 200/400/404/429 responses - v1 route re-exports from existing /api/verify/[id] handler Closes AnnabelJoe#352
- docs/security/pentest-scope.md: defines in-scope targets (web app, API, auth, webhooks), out-of-scope (Stellar network), methodology (OWASP Top 10 + API Security Top 10), tester requirements, and timeline - docs/security/pentest-report-2026-07.md: placeholder for final report to be filled after engagement Closes AnnabelJoe#342
feat: add pentest scope and report placeholder (AnnabelJoe#342)
…ic-verify-api feat: add public v1 verify API and OpenAPI spec (AnnabelJoe#352)
…fer-wallet-tracer-irec Feature/issues transfer wallet tracer irec
fix(security): implement audit logging for sensitive operations
…pliance fix(ci): add dependency license compliance check
fix(security): implement CSP headers for Next.js web app
…aders fix(security): add security headers to all HTTP responses
…-retirement feat: implement certificate retirement API endpoint
feat(security): add RLS policies for multi-tenant isolation (AnnabelJoe#274)
…n-testing feat(testing): add mutation testing for Rust contracts and TS utiliti…
docs: add user guide for web dashboard (closes AnnabelJoe#317)
…s-ci ci: add dedicated Contracts CI workflow (AnnabelJoe#287)
…letons feat: add loading skeletons for async data fetches (AnnabelJoe#255)
…nbooks-315 docs: add operational runbooks
…hart-websocket feat(web): real-time energy chart with WebSocket + polling fallback
|
|
||
| const withNextIntl = createNextIntlPlugin('./src/i18n.ts') | ||
|
|
||
| const securityHeaders = [ |
| }, | ||
| ] | ||
|
|
||
| const securityHeaders = [ |
| * Tests for useWallet hook using the mock Freighter wallet. | ||
| * Runs headlessly in CI — no browser extension required. | ||
| */ | ||
| import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest' |
✅ cargo audit |
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.
Summary
Ensures every public function across all three Soroban contracts has complete
///doc comments covering arguments, authorization, panics, errors, and example invocations.Changes
apps/contracts/energy_token/src/lib.rs— enhancedbalance(),total_supply()apps/contracts/audit_registry/src/lib.rs— enhancedanchor(),verify(),api_signer(),admin()apps/contracts/community_governance/src/lib.rs— enhancedset_quorum_bps(),get_quorum_bps(),set_threshold_bps(),get_threshold_bps(),pending_upgrade(),get_execution_timelock(),proposal_count()Acceptance criteria
///doc commentscargo docgenerates without warnings (no undocumented public items)Closes AnnabelJoe#319