Unable to extend ERC1155Upgradeable `_update` function - Compiler Error

Hello,

I'm encountering an issue when trying to invoke the _update function in order to extend its functionality. The problem lies in the fact that the function appears to be inaccessible or cannot be located using super , and it doesn't override anything when employing the override keyword.

Steps taken to debug:

  • compiler version matches the pragma statement

  • Utilized Remix for testing.

  • Attempted to compile other contracts that invoke the same function, such as ERC1155SupplyUpgradeable . Unfortunately, this resulted in the same issue, as the supply contract, when used as a standalone contract with no inheritance, couldn't be compiled for the same reasons.

Given that updating or overriding _updateWithAcceptanceCheck is not recommended, my remaining options are to work with the _update and _mint functions.

I would greatly appreciate any assistance or insights.

For fellow developers: kindly focus on the errors I'm running into & disregard the function logic and incorrect tech terminologies.

Thank you in advance.

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.20;

import { ERC1155Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol";
import { Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";


contract Venue is Initializable, ERC1155Upgradeable {

    //TODO: check response compilation errors
    function _update
    (
        address from, 
        address to, 
        uint256[] memory _zones, 
        uint256[] memory seats
    ) internal virtual override {
        super._update(from, to, _zones, seats);
        for(uint256 i = 0; i < _zones.length; i ++) {
            uint256 zone = _zones[i];
            uint256 seat = seats[i];

            if(from == address(0)) {
                uint256 unsold = _checkUnsold(zone);
                if(seat > unsold) {
                    revert VenueExceedUnsold(unsold, seat);
                }
                zones[zone].seats = seat;
                zones[zone].ravers.push(to);
            }
        }
    }
}

Here is the error I got inheriting ERC1155Upgradeable

Here are the exact same errors compiling ERC1155SupplyUpgradebale as a single contract from OZ

:computer: Environment

I'm using dappTools erc1155 upgrades Review Wanted

Hello @sasha, thanks for reporting. Let me give some context first:

In the recent 5.0 release, we removed the interfaces and libraries from the upgradeable contracts (@openzeppelin/contracts-upgradeable) and instead, we now import them from the main repository (@openzeppelin/contracts). You can learn more about this decision here.

If you take a look at the ERC1155Upgradeable in Remix and you'll notice some relative imports and some absolute ones following this change:

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

pragma solidity ^0.8.20;

import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
...
import {ContextUpgradeable} from "../../utils/ContextUpgradeable.sol";
...

Now, regarding your problem, if you've been using Remix previously, it's likely some 4.9.3 contracts were cached in Remix and these import changes are messing up at some point. You can solve this by either one of the following options:

  1. Delete the .deps folder in Remix, this will clear and redownload the packages, avoiding any cached version mismatch
  2. Since libraries and dependencies are cached by workspaced, you can create a new workspace and migrate your contracts there to freshly download all versions

Another alternative is to specify the Contracts version with:

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

But it won't likely work because of the internal absolute imports inside ERC1155Upgradeable.sol.

By the way, is this also happening in Dapptools or only in Remix?

Hi

Thanks for clarifying the confusion, I didn't catch the change you employed in the new version, your suggestion worked on Remix after deleting old OZ package.

For DappTools I tried to compile the contracts but ran into a compiler version issue I'm using 0.8.20 in my contracts but current compiler is 0.8.6

To debug:

  • solc --version
    solc, the solidity compiler commandline interface
    Version: 0.8.6+commit.11564f7e.Linux.g++

  • I installed latest solc from docs and confirm installation by running $ nix-env -q --profile /nix/var/nix/profiles/per-user/$(whoami)/profile
    dapp-0.35.0
    ethsign-0.17.1
    hevm-0.49.0
    nix-2.18.1
    seth-0.12.0
    solc
    solc-static-0.8.20

  • In Makefile in ds-test directory & root: I tried build :; dapp --use solc:0.8.20 build but didn't solve the compiler incompatibility.

  • In Makefile in root: all :; dapp --use solc:/home/sasha/.nix-profile/bin/solc-0.8.20 build because which solc => /home/sasha/.nix-profile/bin/solc

  • $ nix-env -i solc:0.8.20 error: selector 'solc:0.8.20' matches no derivations.

  • $ nix-env -iA nixos.solc_0_80_20 error: attribute 'nixos' in selection path 'nixos.solc_0_80_20' not found

  • in .dapprc: export DAPP_SOLC_VERSION=0.8.20

And still get below error???

I'm new to Linux and DappTools; Hardhat user, so accept my apologizes if what I did to debug looks naive or dumb. I liked this framework and want to use it but if you want to recommend another dev framework please feel free to do so.

your input and help is greatly appreciated.

I'm not familiar with Haskell or Nix environments, but the error doesn't seem to be related to using solc 0.8.6. The logs seem to be "temporarily installing solc:0.8.20".

The error reason seems to do with a dependency build failure, likely solc:0.8.20.
Not sure if that may be solved by replacing a dependency or other configuration, but Dapptools is recommending taking a look at Foundry as an alternative because it's better maintained. (See Dapptools development status).

1 Like