refactor: change verification registry getters to return Option and u…#396
Open
ABEEGOLD wants to merge 1 commit into
Open
refactor: change verification registry getters to return Option and u…#396ABEEGOLD wants to merge 1 commit into
ABEEGOLD wants to merge 1 commit into
Conversation
…pdate dependent tests to handle results explicitly
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.
Closes #349
##Summary
Context & Problem
Single-entity read-only query getters across the contract inconsistently handled "not found" scenarios:
ProjectRegistry::get_project,ReviewRegistry::get_review,DisputeRegistry::get_duplicate_dispute,TimelockManager::get_action, andAdminManager::get_proposalreturnedOption<T>(returningNonefor missing entities).CollectionRegistry::get_collectionandVerificationRegistry::get_verification,get_verification_record,get_renewal_request, andget_assigned_adminreturnedResult<T, ContractError>(returningErr(ContractError::...)for missing entities).This inconsistency forced SDK/client consumers and frontend indexers to handle different lookup semantics for each single-entity query method.
Solution
Standardized all single-entity getters exposed via
lib.rsand their module implementations to useOption<T>:Some(entity)None(without throwing an on-chain contract error)Detailed Changes
1. Smart Contract Core Logic
collection_registry.rs:CollectionRegistry::get_collectionnow returnsOption<Collection>.verification_registry.rs:VerificationRegistry::get_verification->Option<VerificationRecord>VerificationRegistry::get_verification_record->Option<VerificationRecord>VerificationRegistry::get_renewal_request->Option<VerificationRenewalRecord>VerificationRegistry::get_assigned_admin->Option<Address>approve_verification,reject_verification,revoke_verification,assign_verification,update_verification_evidence,approve_renewal,reject_renewal,is_verification_expired) updated to use.ok_or(ContractError::VerificationNotFound)when fetching records internally.admin_manager.rs:Option<VerificationRecord>with.ok_or(...).lib.rs:get_collection,get_verification,get_verification_record,get_renewal_request, andget_assigned_adminto matchOption<T>return signatures.2. Test Suite Updates
Updated unit test assertions to match
Option<T>(unwrap(),Some(...),None) across test suites:src/tests/collections.rssrc/tests/renewal.rssrc/tests/verification.rssrc/tests/verification_features.rssrc/tests/verification_assignment.rssrc/tests/invariants.rssrc/tests/multisig_and_history.rssrc/tests/auth_matrix.rssrc/tests/atomicity.rs3. Documentation
CONTRACT_INTERFACE.md:Option<T>semantics across all single-entity lookups.get_collection,get_verification,get_verification_record,get_renewal_request, andget_assigned_admin.Breaking Changes Notice
Warning
API Signature Change for SDK Clients:
Query getters
get_collection,get_verification,get_verification_record,get_renewal_request, andget_assigned_adminnow returnOption<T>instead ofResult<T, ContractError>. When querying non-existent entities, clients will receivenull/Noneinstead of a contract error response.Verification & Testing
Automated Test Execution
Run the unit test suite:
Results:
WASM Build Verification
Build WASM contract target: