Added duplicated contract warning

This commit is contained in:
Richard Ramos 2018-07-24 13:37:59 -04:00
parent 98890beb46
commit f852bf3da0
1 changed files with 7 additions and 3 deletions

View File

@ -59,16 +59,20 @@ function compileSolc(embark, contractFiles, cb) {
for (let contractFile in json.contracts) { for (let contractFile in json.contracts) {
let className = contractFile.substr( contractFile.indexOf(":") + 1); let className = contractFile.substr( contractFile.indexOf(":") + 1);
let fileName = contractFile.substr(0, contractFile.indexOf(":")); let filename = contractFile.substr(0, contractFile.indexOf(":"));
let contract = json.contracts[contractFile]; let contract = json.contracts[contractFile];
if(compiled_object[className] && compiled_object[className].filename != filename){
logger.warn(`Duplicated contract '${className}' found. Using '${compiled_object[className].filename}' instead of '${file.filename}'`);
continue;
}
compiled_object[className] = {}; compiled_object[className] = {};
compiled_object[className].code = contract.bin compiled_object[className].code = contract.bin
compiled_object[className].runtimeBytecode = contract["bin-runtime"]; compiled_object[className].runtimeBytecode = contract["bin-runtime"];
compiled_object[className].functionHashes = contract.hashes; compiled_object[className].functionHashes = contract.hashes;
compiled_object[className].abiDefinition = JSON.parse(contract.abi); compiled_object[className].abiDefinition = JSON.parse(contract.abi);
compiled_object[className].filename = fileName; compiled_object[className].filename = filename;
} }
fileCb(); fileCb();