GivingThanks

First Flight #28
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

[L-1] `CharityRegistry::isVerified` Should Indicate Unverified Status

Description:
The CharityRegistry::isVerified function allows users to check if a charity is verified, but it does not provide feedback when the charity is unverified. As a result, users may be left uncertain when no verification status is returned.

Impact:
This lack of feedback can lead to poor user experience. Users currently only know a charity is verified if CharityRegistry::isVerified returns true. In the absence of a response, users may have to guess, creating uncertainty about the charity’s status.

Proof of Code:
The following test code illustrates that CharityRegistry::isVerified currently returns output only for verified charities, leaving unverified ones ambiguous:

function test_isVerified() public {
address charity_address = address(1);
registryContract.registerCharity(charity_address);
bool is_Charity_Registered = registryContract.isVerified(charity_address);
assertTrue(is_Charity_Registered, "Expected to verify after registration");
address charity_address_two = address(2);
bool is_Charity_NotRegistered = registryContract.isVerified(charity_address_two);
assertFalse(is_Charity_NotRegistered, "Charity expected to be unverified");
}

Since the test passed, CharityRegistry::isVerified function is correctly distinguishing between registered and unregistered addresses without throwing errors. This is important for user experience, as it lets users check if an address is verified without triggering reverts. The test ensures the contract logic aligns with your intended behavior.


Tools Used:
Foundry

Recommended Mitigation:
Implement a require statement in isVerified to notify users when a charity is not verified:

function isVerified(address charity) public view returns (bool) {
require(registeredCharities[charity], "Charity is not verified");
return registeredCharities[charity];
}
Updates

Lead Judging Commences

n0kto Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.