Gökhan Çoban asked in Telegram why there are unused function parameters in unchained inititializers in the Preset contracts:
Other unchained methods take parameters only they use. It would be perfect if two new presets (ERC20PresetMinterPauserUpgradeSafe and ERC721PresetMinterPauserAutoIdUpgradeSafe) be like them. I would like to learn if there is any other reason if its intentional
OpenZeppelin Contracts Ethereum Package contracts were created using a transpiler which took OpenZeppelin Contracts and output contracts with initializers instead of constructors that could be used in upgrades.
This is an automated process, which resulted in the unused function parameters. Its unfortunate that this now causes compiler warnings for these two contracts.
The automated process is much safer than converting OpenZeppelin Contracts manually.
An example contract inheriting from a preset with the compiler warnings is shown below:
MyNFT.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.2;
import "@openzeppelin/contracts-ethereum-package/contracts/Initializable.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/presets/ERC721PresetMinterPauserAutoId.sol";
contract MyNFT is Initializable, ERC721PresetMinterPauserAutoIdUpgradeSafe {
function initialize() public initializer {
ERC721PresetMinterPauserAutoIdUpgradeSafe.initialize(
"MyNFT",
"MYN",
"https://example.com/token/"
);
}
}
Compiler warnings
$ npx oz compile
✓ Compiled contracts with solc 0.6.7 (commit.b8d736ae)
Compilation warnings:
@openzeppelin/contracts-ethereum-package/contracts/presets/ERC721PresetMinterPauserAutoId.sol:57:62: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
function __ERC721PresetMinterPauserAutoId_init_unchained(string memory name, string memory symbol, string memory baseURI) internal initializer {
^----------------^
@openzeppelin/contracts-ethereum-package/contracts/presets/ERC721PresetMinterPauserAutoId.sol:57:82: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
function __ERC721PresetMinterPauserAutoId_init_unchained(string memory name, string memory symbol, string memory baseURI) internal initializer {
^------------------^