Trick or Treat

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

Inheritance issue with `Ownable` contract in `SpookySwap` Contract causing a compiler error

Relevant Github Link: https://github.com/Cyfrin/2024-10-trick-or-treat/blob/9cb3955058cad9dd28a24eb5162a96d759bfa842/src/TrickOrTreat.sol#L9

Description: The Ownable contract from OpenZeppelin was inherited incorrectly as shown below:

@> contract SpookySwap is ERC721URIStorage, Ownable(msg.sender), ReentrancyGuard {

causing the compiler error:

Compiler run failed:
Error (7927): Wrong argument count for constructor call: 1 arguments given but expected 0
--> src/TrickOrTreat.sol:9:42:
|
9 | contract SpookySwap is ERC721URIStorage, Ownable(msg.sender), ReentrancyGuard {
|

The error occurs because Ownable does not require any arguments when inherited. Instead, OpenZeppelin’s Ownable automatically sets msg.sender as the contract owner upon deployment.

Impact:

  1. This issue causes deployment failure leading to delay in project timelines.

  2. It could result in misconfigured access control if not fixed properly before deployment.

Recommended Mitigation:
The recommended fix is to remove msg.sender from the inheritance line, as follows:

- contract SpookySwap is ERC721URIStorage, Ownable(msg.sender), ReentrancyGuard {
+ contract SpookySwap is ERC721URIStorage, Ownable, ReentrancyGuard {

This corrects the inheritance, allowing Ownable to initialize msg.sender as the owner upon deployment without requiring additional parameters.

Updates

Appeal created

bube Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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