Skip to content

Conversation

@Josue19-08
Copy link
Contributor

@Josue19-08 Josue19-08 commented Jan 23, 2026

🧠 SkillSphere Pull Request 🌐

Mark with an x all the checkboxes that apply (like [x])


📌 Type of Change

  • 📚 Documentation (updates to README, docs, or comments)
  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ Enhancement (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 🏗️ Refactor (code improvement/cleanup without logical changes)

📝 Changes Description

Add read-only public getter functions to allow external contracts (like Payment Vault) and Frontend to check expert verification status without Admin permissions:

  • contract.rs: Add is_verified(env, expert) -> bool helper function
  • lib.rs: Expose is_verified as public function (no authentication required)
  • test.rs: Add test_getters covering unverified, verified, and banned states

📸 Evidence

running 14 tests
test test::test_ban_before_contract_initialized ... ok
test test::test_batch_verification_no_admin - should panic ... ok
test test::test_add_expert_unauthorized - should panic ... ok
test test::test_batch_verification_max_vec - should panic ... ok
test test::test_ban_expert_unauthorized - should panic ... ok
test test::test_ban_unverified_expert ... ok
test test::test_initialization ... ok
test test::test_add_expert ... ok
test test::test_expert_status_changed_event ... ok
test test::test_ban_expert ... ok
test test::test_complete_expert_lifecycle ... ok
test test::test_batch_verification_check_status ... ok
test test::test_getters ... ok
test test::test_ban_expert_workflow ... ok

test result: ok. 14 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

🌌 Comments

  • is_verified returns true only for ExpertStatus::Verified, false for Unverified or Banned
  • Both get_status and is_verified can be called without providing a signature

Thank you for contributing to SkillSphere! 🌍

We are glad you have chosen to help us democratize access to knowledge on the Stellar network. Your contribution brings us one step closer to a trustless, peer-to-peer consulting economy. Let's build the future together! 🚀

Summary by CodeRabbit

  • New Features

    • Added a new method to check whether an expert's verification status is verified.
  • Tests

    • Added comprehensive test coverage for expert verification status checking across verified, unverified, and banned states.

✏️ Tip: You can customize this high-level summary in your review settings.

Josue19-08 and others added 3 commits January 22, 2026 21:31
Add helper function to check if an expert's status is Verified.
Returns true only for Verified status, false for Unverified or Banned.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Expose is_verified as a public contract function that can be called
without authentication, allowing external contracts and frontend
to check expert verification status.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Test is_verified and get_status functions:
- Verify is_verified returns false for random/unverified addresses
- Verify is_verified returns true for verified experts
- Verify is_verified returns false for banned experts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Jan 23, 2026

📝 Walkthrough

Walkthrough

This PR adds a read-only public getter is_verified(env, expert) -> bool that enables external contracts and frontends to check if an expert has Verified status without requiring authentication. The function is implemented at the contract helper level and exposed through the public interface.

Changes

Cohort / File(s) Summary
Contract Logic
contracts/identity-registry-contract/src/contract.rs
Added is_verified(env: &Env, expert: &Address) -> bool helper function that returns true when expert status equals ExpertStatus::Verified.
Public Interface
contracts/identity-registry-contract/src/lib.rs
Added is_verified(env: Env, expert: Address) -> bool method on IdentityRegistryContract that delegates to the contract helper function.
Test Coverage
contracts/identity-registry-contract/src/test.rs
Added test_getters function that verifies is_verified returns false for unregistered addresses, true for verified experts, and false for banned experts.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A getter springs forth, no auth in sight,
Experts verified, their status in light,
Read-only and fair, no secrets to keep,
While hopping through contracts, our code runs deep! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The PR description follows the template, includes all required sections, and documents the changes, test results, and behavior notes comprehensively.
Linked Issues check ✅ Passed All requirements from issue #3 are met: is_verified and get_status helper functions implemented in contract.rs, exposed as public unauthenticated functions in lib.rs, and test_getters added with comprehensive test coverage.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing public getters as specified in issue #3; no out-of-scope modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title 'Feat: Public getters' directly and clearly summarizes the main change—adding public getter functions for read-only access to expert verification status.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@contracts/identity-registry-contract/src/test.rs`:
- Around line 334-359: The test currently calls env.mock_all_auths() up front
which hides whether getters require auth; update test_getters to perform the
unauthenticated checks first (call client.is_verified and client.get_status for
random_address and for expert before any mocking), then call
env.mock_all_auths() only when performing admin actions (wrap/mock only around
client.add_expert(&expert) and client.ban_expert(&expert) or call it immediately
before those calls), keeping admin initialization (client.init(&admin)) as
needed; ensure references to IdentityRegistryContractClient methods
client.is_verified, client.get_status, client.add_expert, and client.ban_expert
are used in that order so the test asserts no signature is required for getters.

Comment on lines +334 to +359
#[test]
fn test_getters() {
let env = Env::default();
env.mock_all_auths();

let contract_id = env.register(IdentityRegistryContract, ());
let client = IdentityRegistryContractClient::new(&env, &contract_id);

let admin = Address::generate(&env);
client.init(&admin);

// Test 1: Check is_verified on a random address (should be false)
let random_address = Address::generate(&env);
assert_eq!(client.is_verified(&random_address), false);
assert_eq!(client.get_status(&random_address), ExpertStatus::Unverified);

// Test 2: Verify an expert and check is_verified (should be true)
let expert = Address::generate(&env);
client.add_expert(&expert);
assert_eq!(client.is_verified(&expert), true);
assert_eq!(client.get_status(&expert), ExpertStatus::Verified);

// Test 3: Ban the expert and check is_verified (should be false)
client.ban_expert(&expert);
assert_eq!(client.is_verified(&expert), false);
assert_eq!(client.get_status(&expert), ExpertStatus::Banned);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Verify unauthenticated access explicitly in test_getters.

env.mock_all_auths() at the top can mask accidental auth requirements. To assert the “no signature required” behavior, run the getter checks before mocking auth, then mock only for admin calls.

🔧 Suggested test tweak
 fn test_getters() {
     let env = Env::default();
-    env.mock_all_auths();
 
     let contract_id = env.register(IdentityRegistryContract, ());
     let client = IdentityRegistryContractClient::new(&env, &contract_id);
 
     let admin = Address::generate(&env);
     client.init(&admin);
 
     // Test 1: Check is_verified on a random address (should be false)
     let random_address = Address::generate(&env);
     assert_eq!(client.is_verified(&random_address), false);
     assert_eq!(client.get_status(&random_address), ExpertStatus::Unverified);
 
     // Test 2: Verify an expert and check is_verified (should be true)
     let expert = Address::generate(&env);
+    env.mock_all_auths();
     client.add_expert(&expert);
     assert_eq!(client.is_verified(&expert), true);
     assert_eq!(client.get_status(&expert), ExpertStatus::Verified);
 
     // Test 3: Ban the expert and check is_verified (should be false)
     client.ban_expert(&expert);
     assert_eq!(client.is_verified(&expert), false);
     assert_eq!(client.get_status(&expert), ExpertStatus::Banned);
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#[test]
fn test_getters() {
let env = Env::default();
env.mock_all_auths();
let contract_id = env.register(IdentityRegistryContract, ());
let client = IdentityRegistryContractClient::new(&env, &contract_id);
let admin = Address::generate(&env);
client.init(&admin);
// Test 1: Check is_verified on a random address (should be false)
let random_address = Address::generate(&env);
assert_eq!(client.is_verified(&random_address), false);
assert_eq!(client.get_status(&random_address), ExpertStatus::Unverified);
// Test 2: Verify an expert and check is_verified (should be true)
let expert = Address::generate(&env);
client.add_expert(&expert);
assert_eq!(client.is_verified(&expert), true);
assert_eq!(client.get_status(&expert), ExpertStatus::Verified);
// Test 3: Ban the expert and check is_verified (should be false)
client.ban_expert(&expert);
assert_eq!(client.is_verified(&expert), false);
assert_eq!(client.get_status(&expert), ExpertStatus::Banned);
#[test]
fn test_getters() {
let env = Env::default();
let contract_id = env.register(IdentityRegistryContract, ());
let client = IdentityRegistryContractClient::new(&env, &contract_id);
let admin = Address::generate(&env);
env.mock_all_auths();
client.init(&admin);
env.unmock_all_auths();
// Test 1: Check is_verified on a random address (should be false)
let random_address = Address::generate(&env);
assert_eq!(client.is_verified(&random_address), false);
assert_eq!(client.get_status(&random_address), ExpertStatus::Unverified);
// Test 2: Verify an expert and check is_verified (should be true)
let expert = Address::generate(&env);
env.mock_all_auths();
client.add_expert(&expert);
env.unmock_all_auths();
assert_eq!(client.is_verified(&expert), true);
assert_eq!(client.get_status(&expert), ExpertStatus::Verified);
// Test 3: Ban the expert and check is_verified (should be false)
env.mock_all_auths();
client.ban_expert(&expert);
env.unmock_all_auths();
assert_eq!(client.is_verified(&expert), false);
assert_eq!(client.get_status(&expert), ExpertStatus::Banned);
}
🤖 Prompt for AI Agents
In `@contracts/identity-registry-contract/src/test.rs` around lines 334 - 359, The
test currently calls env.mock_all_auths() up front which hides whether getters
require auth; update test_getters to perform the unauthenticated checks first
(call client.is_verified and client.get_status for random_address and for expert
before any mocking), then call env.mock_all_auths() only when performing admin
actions (wrap/mock only around client.add_expert(&expert) and
client.ban_expert(&expert) or call it immediately before those calls), keeping
admin initialization (client.init(&admin)) as needed; ensure references to
IdentityRegistryContractClient methods client.is_verified, client.get_status,
client.add_expert, and client.ban_expert are used in that order so the test
asserts no signature is required for getters.

@Josue19-08 Josue19-08 changed the title Feat/public getters Feat: Public getters Jan 23, 2026
@Bosun-Josh121 Bosun-Josh121 merged commit 1260e13 into LightForgeHub:main Jan 23, 2026
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

Development

Successfully merging this pull request may close these issues.

Implement Read-Only Public Getters

2 participants