support for both solc 0.1.1 and 0.1.2
This commit is contained in:
parent
775b043209
commit
fd46b0217d
|
@ -21,9 +21,20 @@ Compiler.prototype.init = function(env) {
|
|||
};
|
||||
|
||||
Compiler.prototype.compile_solidity = function(contractFile) {
|
||||
var cmd, result, output, json, compiled_object;
|
||||
var cmd, result, output, version, json, compiled_object;
|
||||
|
||||
cmd = "solc --input-file " + contractFile + " --combined-json bin,abi";
|
||||
cmd = "solc --version";
|
||||
|
||||
result = exec(cmd, {silent: true});
|
||||
output = result.output;
|
||||
version = output.split('\n')[1].split(' ')[1].slice(0,5);
|
||||
|
||||
if (version == '0.1.1') {
|
||||
cmd = "solc --input-file " + contractFile + " --combined-json binary,json-abi";
|
||||
}
|
||||
else {
|
||||
cmd = "solc --input-file " + contractFile + " --combined-json bin,abi";
|
||||
}
|
||||
|
||||
result = exec(cmd, {silent: true});
|
||||
output = result.output;
|
||||
|
@ -41,7 +52,7 @@ Compiler.prototype.compile_solidity = function(contractFile) {
|
|||
compiled_object[className] = {};
|
||||
compiled_object[className].code = contract.binary;
|
||||
compiled_object[className].info = {};
|
||||
compiled_object[className].info.abiDefinition = JSON.parse(contract["abi"]);
|
||||
compiled_object[className].info.abiDefinition = JSON.parse(contract["abi"] || contract["json-abi"]);
|
||||
}
|
||||
|
||||
return compiled_object;
|
||||
|
|
Loading…
Reference in New Issue