GivingThanks

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

no event emission for state changes in CharityRegistry.sol

Summary

It is standard practice and good user experience to emit events to indicate state change. But there wasn't any case like that in CharityRegistry.sol contract

Vulnerability Details

All functions in the CharityRegistry.sol contract save isVerified all modified a state but no event was emitted to capture the state change.

Impact

Events allow users and external interfaces to monitor what’s happening inside a contract, without events, tracking these actions on-chain becomes challenging, leading to reduced transparency.

Tools Used

Manual Review

Recommendations

The CharityRegistry.sol contract can be modified to show state changes using events:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract CharityRegistry {
address public admin;
mapping(address => bool) public verifiedCharities;
mapping(address => bool) public registeredCharities;
event CharityRegistered(address indexed charity);
event CharityVerified(address indexed charity);
event AdminChangedSuccessfully(address indexed newAdmin);
constructor() {
admin = msg.sender;
}
function registerCharity(address charity) public {
registeredCharities[charity] = true;
emit CharityRegistered(charity);
}
function verifyCharity(address charity) public {
require(msg.sender == admin, "Only admin can verify");
require(registeredCharities[charity], "Charity not registered");
verifiedCharities[charity] = true;
emit CharityVerified(charity);
}
function isVerified(address charity) public view returns (bool) {
return registeredCharities[charity];
}
function changeAdmin(address newAdmin) public {
require(msg.sender == admin, "Only admin can change admin");
admin = newAdmin;
emit AdminChangedSuccessfully(newAdmin);
}
}
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.