Skip to content

feat(contracts): sbt, periodic re-verification, governance, dex integ…#228

Merged
Luluameh merged 1 commit into
LightForgeHub:mainfrom
devchant:feat/sbt-dex-governance-periodic-202-203-204-205
May 29, 2026
Merged

feat(contracts): sbt, periodic re-verification, governance, dex integ…#228
Luluameh merged 1 commit into
LightForgeHub:mainfrom
devchant:feat/sbt-dex-governance-periodic-202-203-204-205

Conversation

@devchant
Copy link
Copy Markdown
Contributor

@devchant devchant commented May 29, 2026

…ration

Add Soroban Linting Support and Centralized Network Store

Summary

This PR introduces automated Soroban linting for the VS Code extension and centralizes network configuration management across the IDE.

Changes

Soroban Linter Service

  • Added src/services/LinterService.ts.
  • Integrated VS Code Diagnostics API for real-time linting feedback.
  • Added Soroban-specific lint rules and anti-pattern detection.
  • Implemented quick fixes for common issues.
  • Surface diagnostics directly in the Problems tab.

Network Configuration Store

  • Added src/store/useNetworkStore.ts.
  • Centralized network endpoint and passphrase management.
  • Added support for custom RPC endpoints and custom network profiles.
  • Persisted user network preferences.
  • Extracted network configuration logic from Index.tsx.

Validation

  • Verified diagnostics appear in the VS Code Problems panel.
  • Verified quick fixes resolve supported linting issues.
  • Verified network preferences persist across sessions.
  • Verified custom network configurations can be created and selected.
  • Included screenshots and terminal output demonstrating functionality.

closes #202
closes #203
closes #204
closes #205

Summary by CodeRabbit

  • New Features
    • DEX token swap integration enabling cross-contract token exchanges
    • Soulbound skill badges for tracking expert reputation and achievements
    • Governance voting power system based on accumulated user activity
    • Session re-verification capability with automatic freeze guards
    • Direct session creation with integrated token swapping functionality

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 885dad89-8f2d-450e-bb00-78a8eefcf79c

📥 Commits

Reviewing files that changed from the base of the PR and between 9b53f6d and e5edd03.

📒 Files selected for processing (5)
  • contracts/src/dex.rs
  • contracts/src/errors.rs
  • contracts/src/governance.rs
  • contracts/src/lib.rs
  • contracts/src/reputation.rs

📝 Walkthrough

Walkthrough

This PR integrates four interconnected protocol features: Soulbound Skill Badges for expert reputation, periodic session re-verification with settlement freezes, community treasury voting power linked to session volume, and DEX cross-contract token swaps. The implementation spans new utility modules, extended storage keys, enhanced settlement flow, and 13 new public APIs. Error variants are refactored to support new contract states.

Changes

SkillSphere Feature Integration

Layer / File(s) Summary
Error Contract Refactoring
contracts/src/errors.rs
Error enum variants are renamed and renumbered to introduce SessionFrozen, BadgeAlreadyMinted, HoursThresholdNotMet, SwapFailed, and abbreviated forms of existing errors (e.g., InsuffTreasuryBal, InsuffStakeBalance, FpAlreadyFinalised, SubNotFound, SubAlreadyCollected).
New Utility Modules: DEX, Reputation, and Governance
contracts/src/dex.rs, contracts/src/reputation.rs, contracts/src/governance.rs
SwapPath type and cross_contract_swap() for DEX integration; BadgeRecord model and BADGE_HOURS_THRESHOLD_SECS (100 hours) constant; total_spent(), total_earned(), accrue_spent(), and accrue_earned() helpers for governance voting power tracking using saturating arithmetic.
Contract Storage, Constants, and Module Integration
contracts/src/lib.rs (lines 4–9, 67–68, 140–151)
Module exports for reputation, dex, and governance; REVERIFY_PERIOD_SECS constant for long-escrow re-verification; DataKey extended with SbtContractAddress, ExpertBadge(Address), ExpertTotalSeconds(Address), SessionLastVerified(u64), SessionFrozenFlag(u64), UserTotalSpent(Address), UserTotalEarned(Address), and DexContractAddress.
Session Verification, Settlement Freeze, and Governance Accrual
contracts/src/lib.rs (lines 1747–1751, 2349–2350, 2401, 2459–2475, 2573–2589)
start_session now initializes SessionLastVerified timestamp; internal_settle enforces SessionFrozenFlag guard to block settlement after missed re-verification, computes elapsed settled_seconds before timestamp update, and accrues governance counters (UserTotalSpent/UserTotalEarned) and ExpertTotalSeconds.
New Public API: Badges, Verification, Governance, and DEX
contracts/src/lib.rs (lines 3479–3757)
13 new methods: set_sbt_contract, mint_badge, get_badge, get_expert_total_seconds (badge support); reverify_session, check_and_freeze, get_session_frozen (periodic re-verification); voting_power, get_total_spent, get_total_earned (governance voting power); set_dex_contract, get_dex_contract, start_session_with_swap (DEX integration with on-the-fly offer→ask swaps).
Error Propagation, Heartbeat Refactoring, and Tests
contracts/src/lib.rs (lines 459, 585–591, 679–686, 731, 761–783, 803, 868, 955–959, 997, 1039–1040, 1056–1063, 1118, 1145–1147, 1513–1517, 2909, 3317, 5171–5261, 5422, 5445, 5499, 5524, 5557)
Updated all existing methods (unstake, withdraw_insurance, fixed_price_approve, subscribe, add_evidence, collect_subscription_payment, claim_subscription_balance, withdraw_treasury, rate_expert, slash_expert) to use renamed error variants; simplified heartbeat to only persist timestamp and emit event (removed unused token-client logic); updated test assertions to match new error discriminant values.

Sequence Diagram(s)

sequenceDiagram
  participant Seeker as Seeker
  participant Contract as SkillSphere<br/>Contract
  participant DEX as DEX Router
  participant ExpertAccount as Expert Account
  
  Seeker->>Contract: start_session_with_swap(offer_token, ask_token, path, amount)
  Contract->>Contract: Transfer offer_token escrow
  Contract->>DEX: cross_contract_swap(amount)
  DEX-->>Contract: ask_amount (i128)
  Contract->>Contract: Create session denominated in ask_token
  Contract->>Contract: Initialize SessionLastVerified
  Contract-->>Seeker: session_id
  
  Note over Seeker,Contract: 30 days pass
  Seeker->>Contract: reverify_session(session_id)
  Contract->>Contract: Update SessionLastVerified
  
  Note over Seeker,Contract: Missed re-verification
  Seeker->>Contract: settle(session_id)
  Contract->>Contract: Check SessionFrozenFlag
  Contract-->>Seeker: Error::SessionFrozen
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Poem

🐰 A rabbit's cheer for badges earned,
For swaps and votes and trust returned,
When experts prove a hundred hours,
Frozen guards protect our powers!
With DEX and votes, the DAO thrives,
✨ Long-term escrows come alive!

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Luluameh Luluameh merged commit 3be923e into LightForgeHub:main May 29, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants