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

Unable publish source code with solidity version >= 0.8.0 with some imports #1221

Closed
maxsiz opened this issue Aug 28, 2021 · 3 comments
Closed

Comments

@maxsiz
Copy link

maxsiz commented Aug 28, 2021

Environment information

  • brownie Version: 1.16.2
  • ganache-cli Version: 0.8.4
  • solc Version: 0.8.7
  • Python Version: 3.6.9
  • OS: linux-mint

What was wrong?

Example contract:

// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

import "OpenZeppelin/openzeppelin-contracts@4.3.1/contracts/token/ERC721/ERC721.sol";

contract TestImport is ERC721 {

    constructor(string memory name_,
        string memory symbol_) ERC721(name_, symbol_)  {
    }

    
    function mint() external {
        require(balanceOf(msg.sender) == 0, "Only one");
        _mint(msg.sender, block.number);
    }
    
}

TestImport.get_verification_info() fail:

~/projects/temp/erc721$ brownie console
Brownie v1.16.2 - Python development framework for Ethereum

Compiling contracts...
  Solc version: 0.8.7
  Optimizer: Enabled  Runs: 200
  EVM Version: Istanbul
Generating build data...
 - OpenZeppelin/openzeppelin-contracts@4.3.1/ERC721
 - OpenZeppelin/openzeppelin-contracts@4.3.1/IERC721
 - OpenZeppelin/openzeppelin-contracts@4.3.1/IERC721Receiver
 - OpenZeppelin/openzeppelin-contracts@4.3.1/IERC721Metadata
 - OpenZeppelin/openzeppelin-contracts@4.3.1/Address
 - OpenZeppelin/openzeppelin-contracts@4.3.1/Context
 - OpenZeppelin/openzeppelin-contracts@4.3.1/Strings
 - OpenZeppelin/openzeppelin-contracts@4.3.1/ERC165
 - OpenZeppelin/openzeppelin-contracts@4.3.1/IERC165
 - TestImport

ErcProject is the active project.

Launching 'ganache-cli --accounts 10 --hardfork istanbul --gasLimit 12000000 --mnemonic brownie --port 8545'...
Brownie environment is ready.
>>> TestImport.get_verification_info()
  File "<console>", line 1, in <module>
  File "brownie/network/contract.py", line 315, in get_verification_info
    build_json = self._project._build.get(name)
  File "brownie/project/build.py", line 124, in get
    return self._interfaces[key]
KeyError: 'OpenZeppelin/openzeppelin-contracts@4.3.1/IERC721Receiver'
>>> interface.
  File "<console>", line 1,
    interface.
              ^
SyntaxError: invalid syntax

So I can compile and deploy this contract and it's work well. But I can't publish source.
When I use olidity >=0.6.0 <0.8.0; and /openzeppelin-contracts@3.4.0 - all is OK And TestImport.get_verification_info() work well

I think that problem is occur when we use import from package files that include import directives with not inherited code. Let's look at OpenZeppelin ERC721.sol:
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol
We can notice that IERC721Receiver is not ininheriting but still used in contract code:

...
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
...
 function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) private returns (bool) {
        if (to.isContract()) {
            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
                return retval == IERC721Receiver.onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else   ##{
            return true;
        }
    }
....

Assume that issue #1114 was part of this problem.

Console screenshot
http://i.imgur.com/wAVKnRx.png

@ImportNN
Copy link

I am having the same error. I believe problem comes from importing contracts. Tried deploying simple contracts with no imports and worked with no probs.

@maxsiz maxsiz closed this as completed Nov 7, 2021
@rodriguesmvinicius
Copy link

I am still having this issue even with brownie 1.18

@SolomanDev
Copy link

How do I convert uint256 type to address type in Solidity?
Thank you if very for letting me know.

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

4 participants