New ERC1155SupplyUpgradeable is throwing errors

Hi

My parent contract inherits ERC1155Upgradeable & ERC1155SupplyUpgradeable with other contracts from OZ, the problem is the supply contract is throwing 3 errors. I even tried OZ Wizard and errors persist still.

contract Example is Initializable, OwnableUpgradeable, ERC1155Upgradeable, ERC1155SupplyUpgradeable {


    function initialize(address initialOwner) initializer public {
        __ERC1155_init("");
        __Ownable_init(initialOwner);
        __ERC1155Supply_init();
    }

  function _update(address from, address to, uint256[] memory ids, uint256[] memory values)
          internal
          override(ERC1155Upgradeable, ERC1155SupplyUpgradeable)
      {
          super._update(from, to, ids, values);
      }
}

errors are:

  • Function has override specified but does not override anything.

  • Invalid contract specified in override list: "ERC1155Upgradeable".

  • Member "_update" not found or not visible after argument-dependent lookup in type(contract super ERC1155SupplyUpgradeable).

even ERC1155Supply standalone contract isn't compiling!!

Thanks in advance

2 Likes

Semantic:

Throwing an error is a term typically associated with runtime behavior, for example, a transaction-revert.

In your case, these are compilation errors (I guess you could claim that the compiler throws an error, but the typical terminology in this case does not involve 'throwing').


As to your actual problem:

The ERC1155SupplyUpgradeable contract already inherits the ERC1155Upgradeable contract, and it already overrides the _update function of that contract.

So your contract needs to inherit only the ERC1155SupplyUpgradeable contract, and it needs to override the _update function only of that contract.

Thanks for your input @barakman they are indeed compilation errors. But ERC1155SupplyUpgradeable as a contract isn't compiling before any inheritance (screenshot below). The wizard was used to debug before asking for support and the code I posted above was the wizard code.

@frangio can you please take a quick look and advise. Thanks


Note: tried to change the header to compilation errors but couldn't

Is it possible that your remix instances has old version of the dependency cached ? (4.x).

Please check the relevant .deps/npm/@openzeppelin/contracts-upgradeable/... files in your remix workspace, and check that they start with

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (...)

If that is not he case, you'll need to either reset the cache (by deleting the old files) or force using a new version by doing

import "@openzeppelin/contracts-upgradeable@5.0.0/...";