Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solidity Scripting Tutorial code incompatible with v5 OpenZeppelin Ownable class #1119

Closed
frankmullenger opened this issue Feb 15, 2024 · 3 comments · Fixed by #1121
Closed
Assignees

Comments

@frankmullenger
Copy link
Contributor

The Solidity Scripting Tutorial example code doesn't compile when the latest version of the OpenZeppelin library is used.

Installing OpenZeppelin library using the instructions: forge install transmissions11/solmate Openzeppelin/openzeppelin-contracts seems to install the latest version of the OpenZeppelin library (v5), possibly because the ref defaults to "master"?

The function signature of the OpenZeppelin Ownable class has changed in v5 from v4, the constructor now requires an "initialOwner" parameter.

So the example code in the Tutorial is missing a call to the base constructor in Ownable.

The compilation error (using Solc 0.8.22) is:

Error: 
Compiler run failed:
Error (3415): No arguments passed to the base constructor. Specify the arguments or mark "NFT" as abstract.
  --> src/NFT.sol:13:1:
   |
13 | contract NFT is ERC721, Ownable {
   | ^ (Relevant source part starts here and spans across multiple lines).
Note: Base constructor parameters:
  --> lib/openzeppelin-contracts/contracts/access/Ownable.sol:38:16:
   |
38 |     constructor(address initialOwner) {
   |   

Possibly the NFT constructor could call the base constructor?

constructor(
    string memory _name,
    string memory _symbol,
    string memory _baseURI
) ERC721(_name, _symbol) Ownable(msg.sender) {
    baseURI = _baseURI;
}

Or possibly the dependency could specify a version?

forge install transmissions11/solmate Openzeppelin/[email protected]
@Evalir
Copy link
Member

Evalir commented Feb 15, 2024

We could also update the tutorial—would you be up for it @frankmullenger ?

@frankmullenger
Copy link
Contributor Author

@Evalir Yeah I'd be happy to open a pull request for this 😃

@Evalir
Copy link
Member

Evalir commented Feb 15, 2024

awesome! will assign to you @frankmullenger

frankmullenger added a commit to frankmullenger/foundry-rs_book that referenced this issue Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants