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

Overriding IERC721A in later solidity version breaks compile #31

Open
DLzer opened this issue Feb 22, 2023 · 2 comments
Open

Overriding IERC721A in later solidity version breaks compile #31

DLzer opened this issue Feb 22, 2023 · 2 comments

Comments

@DLzer
Copy link

DLzer commented Feb 22, 2023

When implementing the OperatorFilterer.sol on a base ERC721A the compiler ran into an issue referencing the override of the IERC721A interface. My solution was to remove the reference to IERC721A in the OperatorFilterer methods considering in later solidity versions overriding interfaces is not necessary for functions that override a single interface function.

Issue

The implemented setApprovalForAll function:

    function setApprovalForAll(address operator, bool approved)
        public
        override(IERC721A,ERC721A)
        onlyAllowedOperatorApproval(operator)
    {
        super.setApprovalForAll(operator, approved);
    }

Error received:

TypeError: Invalid contract specified in override list: "IERC721A".
   --> contracts/721AToken.sol:169:9:
    |
169 |         override(IERC721A, ERC721A)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Note: This contract: 
  --> erc721a/contracts/IERC721A.sol:10:1:
   |
10 | interface IERC721A {
   | ^ (Relevant source part starts here and spans across multiple lines).

My Solution

Implement OperatorFilterer methods without overriding the ERC721 Interface

    function setApprovalForAll(address operator, bool approved)
        public
        override(ERC721A)
        onlyAllowedOperatorApproval(operator)
    {
        super.setApprovalForAll(operator, approved);
    }

If this fix goes against the grain please let me know, or if there is a better proposed solution that I could implement.

@ItsCuzzo
Copy link

What do your import statements look like when importing ERC721A in the parent contract, are you using specified imports? E.g.

import { ERC721A } from "erc721a/contracts/ERC721A.sol";

@DLzer
Copy link
Author

DLzer commented Feb 22, 2023

What do your import statements look like when importing ERC721A in the parent contract, are you using specified imports? E.g.

import { ERC721A } from "erc721a/contracts/ERC721A.sol";

Using named imports exactly like you've shared.

Edit: Here's my import list:

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {ERC721AQueryable} from "erc721a/contracts/extensions/ERC721AQueryable.sol";
import {IERC721A, ERC721A} from "erc721a/contracts/ERC721A.sol";
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
import {MerkleProof} from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import {IERC2981, ERC2981} from "@openzeppelin/contracts/token/common/ERC2981.sol";
import {OperatorFilterer} from "../OperatorFilterer.sol";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants