don't attempt to link contract if it's not in the code

This commit is contained in:
Iuri Matias 2017-12-19 11:13:27 -05:00
parent a99ee73ef8
commit 9404bfb2cc
1 changed files with 4 additions and 1 deletions

View File

@ -115,11 +115,14 @@ class Deploy {
deployedAddress = deployedAddress.substr(2); deployedAddress = deployedAddress.substr(2);
} }
let linkReference = '__' + filename + ":" + contractObj.className; let linkReference = '__' + filename + ":" + contractObj.className;
if (contractCode.indexOf(linkReference) < 0) {
continue;
}
if (linkReference.length > 40) { if (linkReference.length > 40) {
return callback(new Error(linkReference + " is too long, try reducing the path of the contract (" + filename + ") and/or its name " + contractObj.className)); return callback(new Error(linkReference + " is too long, try reducing the path of the contract (" + filename + ") and/or its name " + contractObj.className));
} }
let toReplace = linkReference + "_".repeat(40 - linkReference.length); let toReplace = linkReference + "_".repeat(40 - linkReference.length);
if (contractCode.indexOf(linkReference) >= 0 && deployedAddress === undefined) { if (deployedAddress === undefined) {
let libraryName = contractObj.className; let libraryName = contractObj.className;
return callback(new Error(contract.className + " needs " + libraryName + " but an address was not found, did you deploy it or configured an address?")); return callback(new Error(contract.className + " needs " + libraryName + " but an address was not found, did you deploy it or configured an address?"));
} }