Oz deploy: missing contract to be deployed

Hi, I’m not able to deploy a factory contract using a regular deploy

:computer: Environment
oz version: 2.8.2, solidity 0.5.9

:memo:Details
I want to deploy a factory contract using a regular oz deployment but when it comes to pick which contract to deploy I can see all my contracts except the factory. I’m not sure if it makes any difference nut my factory contract extends Initializable and GSNRecipient.

pragma solidity ^0.5.9;
import "@openzeppelin/contracts-ethereum-package/contracts/ownership/Ownable.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/GSN/GSNRecipientSignature.sol";
import "@openzeppelin/upgrades/contracts/Initializable.sol";

import "./interfaces/IMyFactory.sol";

import "./Child.sol";

contract MyFactory is Initializable, Ownable, IMyFactory, Initializable {
  
   mapping(uint => address) public children;
   uint256 childrenCount;

   function initialize(address _signer) public initializer {
        GSNRecipientSignature.initialize(_signer);
        Ownable.initialize(_signer);
   }

   function deployNewChild() external {
        Child _child = new Child();
        children[childrenCount] = address(_child);
        childrenCount++;
   }
}

When running oz deploy I’m just able to deploy the Child contract but not the Factory.
I’ve tried to make some changes in the project.json but with no result.

{
     "manifestVersion": "2.2",
     "contracts": {},
     "dependencies": {
         "@openzeppelin/contracts-ethereum-package": "^2.5.0"
      },
     "name": "dapp-contracts",
     "version": "1.0.0",
     "compiler": {
     "compilerSettings": {
        "optimizer": {
        "enabled": true,
        "runs": "200"
        }
    },
    "typechain": {
        "enabled": true,
        "target": "web3-v1",
        "outDir": "typechain-build"
    },
   "manager": "openzeppelin",
   "solcVersion": "0.5.9",
   "artifactsDir": "build/contracts",
   "contractsDir": "contracts"
    },
   "telemetryOptIn": true
}
1 Like

Hi @marcellobardus,

Welcome to the community :wave:

When I tried compiling, I got the following error:

s$ npx oz compile
✖ Compiling contracts with solc 0.5.17 (commit.d19bba13)
Compilation errors:
contracts/MyFactory.sol:12:1: TypeError: Linearization of inheritance graph impossible
contract MyFactory is Initializable, Ownable, IMyFactory, Initializable {
^ (Relevant source part starts here and spans across multiple lines).

I removed the inheritance of the duplicate Initializable and added inheritance of GSNRecipientSignature to get it to compile.

I was then able to deploy as a regular contract:

$ npx oz deploy
✓ Compiled contracts with solc 0.5.17 (commit.d19bba13)
? Choose the kind of deployment regular
? Pick a network development
? Pick a contract to deploy MyFactory
✓ Deployed instance of MyFactory
0xDb56f2e9369E0D7bD191099125a3f6C370F8ed15

MyFactory.sol

pragma solidity ^0.5.9;


import "@openzeppelin/contracts-ethereum-package/contracts/ownership/Ownable.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/GSN/GSNRecipientSignature.sol";
import "@openzeppelin/upgrades/contracts/Initializable.sol";

import "./interfaces/IMyFactory.sol";

import "./Child.sol";

contract MyFactory is Initializable, Ownable, IMyFactory, GSNRecipientSignature {
  
   mapping(uint => address) public children;
   uint256 childrenCount;

   function initialize(address _signer) public initializer {
        GSNRecipientSignature.initialize(_signer);
        Ownable.initialize(_signer);
   }

   function deployNewChild() external {
        Child _child = new Child();
        children[childrenCount] = address(_child);
        childrenCount++;
   }
}

IMyFactory.sol

pragma solidity ^0.5.0;

interface IMyFactory {
    
}

Child.sol

pragma solidity ^0.5.0;

contract Child {
    
}

Hi @marcellobardus,

Checking if you still had issues with this? Please ask all the questions that you need.

Hi, @abcoathup unfortunately I wasn’t able to deploy it.
The code that I posted above was just an example.

Let me post here some a screenshot.
I should see a contract called LosoviRegistry.sol which’s role is to be a factory and does exactly the same what MyFactory.

1 Like

Hi @marcellobardus,

I assume that LosoviRegistry.sol compiles?
I assume that you have used up and down arrows to scroll through the available contracts in case the factory contract is not displayed on the first screen.

Are you able to share your repository (if it’s open source?)

Hi, yes it compiles.
Sure I scrolled it.
That’s the repo

1 Like

Hi @marcellobardus,

The reason why LosoviMatchesRegistry isn’t displayed is because LosoviMatchesRegistry doesn’t implement function getEntropySupplyDepositTokenAddress defined in the interface ILosoviMatchesRegistry

    function getEntropySupplyDepositTokenAddress()
        external
        view
        returns (address);

I reproduced using a new project with the following interface and contract and it doesn’t show as a contract that we can deploy with oz deploy

When I tried to deploy the contract in Remix it gives an error: This contract may be abstract, not implement an abstract parent's methods completely or not invoke an inherited contract's constructor correctly.

IMyContract.sol

pragma solidity ^0.5.0;


interface IMyContract {
    function doStuff()
        external
        view
        returns (address);
}

MyContract.sol

pragma solidity ^0.5.0;

import "./IMyContract.sol";


contract MyContract is IMyContract {}

Hi @marcellobardus,

As an aside, I noticed in your repo that you are currently compiling with Solidity 0.5.9 rather than the latest Solidity 0.5 version (0.5.17).

Also that your .gitignore doesn’t ignore build so all of the .json artifacts are in version control.

Hi @abcoathup thank you some much, that solved my problem but I wonder why oz compile didn’t throw any message that an interface is implemented incorrectly. Regarding the .gitignore you’re also right thanks for that I missed it.

1 Like

Without implementing all the interface functions it is treated as an abstract contract.

So it can be compiled but can’t be deployed. Though that makes it tricky to find the issue.