Merge pull request #227 from grant-project/fix-missing-contract-build
Fix contract build on yarn dev
This commit is contained in:
commit
cb11ba16b3
|
@ -76,10 +76,7 @@ const getGanacheNetworkId = (module.exports.getGanacheNetworkId = () => {
|
||||||
.catch(() => -1);
|
.catch(() => -1);
|
||||||
});
|
});
|
||||||
|
|
||||||
const checkContractsNetworkIds = (module.exports.checkContractsNetworkIds = (
|
const checkContractsNetworkIds = (id) =>
|
||||||
id,
|
|
||||||
retry = false,
|
|
||||||
) =>
|
|
||||||
new Promise((res, rej) => {
|
new Promise((res, rej) => {
|
||||||
const buildDir = paths.contractsBuild;
|
const buildDir = paths.contractsBuild;
|
||||||
fs.readdir(buildDir, (err) => {
|
fs.readdir(buildDir, (err) => {
|
||||||
|
@ -88,20 +85,15 @@ const checkContractsNetworkIds = (module.exports.checkContractsNetworkIds = (
|
||||||
res(false);
|
res(false);
|
||||||
} else {
|
} else {
|
||||||
const allHaveId = CHECK_CONTRACT_IDS.reduce((ok, name) => {
|
const allHaveId = CHECK_CONTRACT_IDS.reduce((ok, name) => {
|
||||||
const contract = require(path.join(buildDir, name));
|
const contractPath = path.join(buildDir, name);
|
||||||
|
if (!fs.existsSync(contractPath)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const contract = require(contractPath);
|
||||||
const contractHasKeys = Object.keys(contract.networks).length > 0;
|
const contractHasKeys = Object.keys(contract.networks).length > 0;
|
||||||
if (!contractHasKeys) {
|
if (!contractHasKeys) {
|
||||||
if (retry) {
|
logMessage('Contract does not contain network keys.', 'error');
|
||||||
logMessage(
|
return false;
|
||||||
'Contract does not contain network keys after retry. Exiting. Please manually debug Contract JSON.',
|
|
||||||
'error',
|
|
||||||
);
|
|
||||||
process.exit(1);
|
|
||||||
} else {
|
|
||||||
logMessage('Contract does not contain any keys. Will migrate.');
|
|
||||||
migrate();
|
|
||||||
return checkContractsNetworkIds(id, true);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (contractHasKeys && !contract.networks[id]) {
|
if (contractHasKeys && !contract.networks[id]) {
|
||||||
const actual = Object.keys(contract.networks).join(', ');
|
const actual = Object.keys(contract.networks).join(', ');
|
||||||
|
@ -118,6 +110,7 @@ const checkContractsNetworkIds = (module.exports.checkContractsNetworkIds = (
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
module.exports.checkContractsNetworkIds = checkContractsNetworkIds;
|
||||||
|
|
||||||
const fundWeb3v1 = (module.exports.fundWeb3v1 = () => {
|
const fundWeb3v1 = (module.exports.fundWeb3v1 = () => {
|
||||||
// Fund ETH accounts
|
// Fund ETH accounts
|
||||||
|
|
Loading…
Reference in New Issue