Skip to content

Commit fd46b02

Browse files
committed
support for both solc 0.1.1 and 0.1.2
1 parent 775b043 commit fd46b02

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

lib/compiler.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,20 @@ Compiler.prototype.init = function(env) {
2121
};
2222

2323
Compiler.prototype.compile_solidity = function(contractFile) {
24-
var cmd, result, output, json, compiled_object;
24+
var cmd, result, output, version, json, compiled_object;
25+
26+
cmd = "solc --version";
27+
28+
result = exec(cmd, {silent: true});
29+
output = result.output;
30+
version = output.split('\n')[1].split(' ')[1].slice(0,5);
2531

26-
cmd = "solc --input-file " + contractFile + " --combined-json bin,abi";
32+
if (version == '0.1.1') {
33+
cmd = "solc --input-file " + contractFile + " --combined-json binary,json-abi";
34+
}
35+
else {
36+
cmd = "solc --input-file " + contractFile + " --combined-json bin,abi";
37+
}
2738

2839
result = exec(cmd, {silent: true});
2940
output = result.output;
@@ -41,7 +52,7 @@ Compiler.prototype.compile_solidity = function(contractFile) {
4152
compiled_object[className] = {};
4253
compiled_object[className].code = contract.binary;
4354
compiled_object[className].info = {};
44-
compiled_object[className].info.abiDefinition = JSON.parse(contract["abi"]);
55+
compiled_object[className].info.abiDefinition = JSON.parse(contract["abi"] || contract["json-abi"]);
4556
}
4657

4758
return compiled_object;

0 commit comments

Comments
 (0)