Validating contract SolidityContract Cannot read property 'forEach' of undefined


#1

When trying to deploy an existing contract with ZeppelinOS, I get the following error.

Validating contract SolidityContract
Cannot read property ‘forEach’ of undefined

I followed the setup manual, installed zos-lib, zos add SolidityContract, ran ganache, but when I deploy I get this error. Contracts compile fine but when migrating, every other time contracts won’t deploy when using truffle

Any help would be appreciated, I really want to make some upgradeable smart contracts


#2

Hey @elliot! Thanks for posting on here!

Any relevant code you can show us that’ll help provide some clues?


#3

Here is my zos.json file:

{
  "zosversion": "2.2",
  "name": "my-project",
  "version": "0.1.0",
  "publish": "true",
  "contracts": {
    "Metadata": "Metadata",
    "721Metadata": "721Metadata"
  }
}

Here is a zos dev file that gets created every time I run the command “npx zos push”:

{
  "contracts": {},
  "solidityLibs": {},
  "proxies": {},
  "zosversion": "2.2"
}

“Metadata” contract relies on two external libraries that are linked in the truffle migration script.

here is that script

async function doDeploy(deployer, network) {
	await deployer.deploy(IToABase);
	await deployer.deploy(StringUtils);

	await deployer.link(IToABase, Metadata);
	await deployer.link(StringUtils, Metadata);

	await deployer.deploy(SafeMath);
	await deployer.deploy(Address);
	await deployer.deploy(Counters);

	await deployer.link(SafeMath, 721Metadata);
	await deployer.link(Address, 721Metadata);
	await deployer.link(Counters, 721Metadata);
	
	await deployer.deploy(Metadata);
	await deployer.deploy(721Metadata, "t", "a",Metadata.address);
}

module.exports = function(deployer) {
	deployer.then(async () => {
        await doDeploy(deployer);
    });

Here is Metadata contract:

import "zos-lib/contracts/Initializable.sol";

contract Metadata is Initializable {
	//OZos constructor
  	function initialize() initializer public {}
}

#4

Hello Elliot! Apologies for the late response, still having trouble with this error?


#5

Hey @elliot! Please take a look at this issue. If you are using both flavours of OpenZeppelin (-solidity and -eth) in the same project, or have two contracts with the same name, you will hit this issue. We are working on a fix, but in the meantime, make sure you don’t have any contracts with repeated names (note that this includes any contracts from your dependencies as well).