The RockPaperScissors
contract repeats the require(msg.sender == adminAddress, ...)
check in multiple functions (setAdminAddress
, withdrawTokens
, setGameTimeout
), reducing code maintainability. A custom modifier would centralize this logic.
The RockPaperScissors
contract uses the require(msg.sender == adminAddress, "Only admin can set new admin")
check (or similar variations) in at least three functions: setAdminAddress
, withdrawTokens
, and setGameTimeout
. This repetition of admin access control logic increases the risk of inconsistency if the admin address or error message needs to change. For example, updating the admin check would require modifying each instance individually, which is error-prone and violates the DRY (Don’t Repeat Yourself) principle. Centralizing the logic in a modifier would improve readability and maintainability.
Reduced code readability due to repeated admin check logic across multiple functions.
Increased maintenance burden, as changes to the admin address or error message require updating at least three function instances, risking inconsistencies.
Potential for bugs if one instance is overlooked during updates (e.g., using a different error message or condition).
No security impact, but violates best practices for clean, maintainable smart contract code, justifying low severity.
Manual Code Review
Introduce a custom onlyAdmin modifier to centralize the admin access check, replacing repeated require(msg.sender == adminAddress, ...) statements. Apply the modifier to all admin-only functions to improve readability and maintainability.
Code suggestions or observations that do not pose a direct security risk.
Code suggestions or observations that do not pose a direct security risk.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.