Import in contract Upgradeable

[UPDATE]

I solved this issue importing from contracts-upgradeable, but now there's a new issue since the previous inheritance is not working:

contract CUpgrade is ERC721URIStorageUpgradeable, ERC721EnumerableUpgradeable, OwnableUpgradeable, RoyaltiesV2Impl, ReentrancyGuardUpgradeable, 
Initializable

with error

Linearization of inheritance graph impossible

Hi everyone, I'm trying to make a contract upgradeable, when I'm importing openzeppelin contracts I get these errors:

Error HH606: The project cannot be compiled, see reasons below.

The Solidity version pragma statement in these files don't match any of the configured compilers in your config. Change the pragma or configure additional compiler versions in your hardhat config.

  • @openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol (^0.6.0)
  • @openzeppelin/contracts-ethereum-package/contracts/Initializable.sol (>=0.4.24 <0.7.0)
    etc...

with these imports

pragma solidity ^0.8.2;

import "@openzeppelin/contracts/utils/Strings.sol";

import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC721/ERC721.sol";

import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";

import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";

import "@openzeppelin/contracts-ethereum-package/contracts/utils/Counters.sol";

import "@openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol";

import "@openzeppelin/contracts/utils/math/SafeMath.sol";

import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

How can I import these contracts to be suitable for upgrades, and also to initialize them in the initializer function as ERC721.initialize() etc, (being able to cut the constructor)?

Thank you

1 Like