Updated npm package.

pull/1/head
chriseth 9 years ago
parent ef674daa28
commit 8b9a212d56
  1. 15
      README.md
  2. 22
      index.js
  3. 2
      package.json

@ -15,4 +15,17 @@ And then use it like so:
var input = "contract x { function g() {} }"; var input = "contract x { function g() {} }";
var output = solc.compile(input, 1); // 1 activates the optimiser var output = solc.compile(input, 1); // 1 activates the optimiser
for (var contractName in output.contracts) for (var contractName in output.contracts)
console.log(contractName + ': ' + output.contracts[contractName].bytecode); console.log(contractName + ': ' + output.contracts[contractName].bytecode);
Starting from version 0.1.6, multiple files are supported with automatic import resolution by the compiler as follows:
var solc = require('solc');
var input = {
'lib.sol': 'library L { function f() returns (uint) { return 7; } }',
'cont.sol': 'import "lib.sol"; contract x { function g() { L.f(); } }'
};
var output = solc.compile({sources: input}, 1);
for (var contractName in output.contracts)
console.log(contractName + ': ' + output.contracts[contractName].bytecode);
Note that all input files that are imported have to be supplied, the compiler will not load any additional files on its own.

@ -1,11 +1,23 @@
var soljson = require('./bin/soljson-latest.js'); var soljson = require('./bin/soljson-latest.js');
compileJSON = soljson.cwrap("compileJSON", "string", ["string", "number"]); var compileJSON = soljson.cwrap("compileJSON", "string", ["string", "number"]);
var compileJSONMulti =
'_compileJSONMulti' in soljson ?
soljson.cwrap("compileJSONMulti", "string", ["string", "number"]) :
null;
var compile = function(input, optimise) {
var result = '';
if (typeof(input) != typeof('') && compileJSONMulti !== null)
result = compileJSONMulti(JSON.stringify(input), optimise);
else
result = compileJSON(input, optimise);
return JSON.parse(result);
}
module.exports = { module.exports = {
compile: function(input, optimise){ compile: compile,
return JSON.parse( compileJSON(input, optimise) );
},
version: soljson.cwrap("version", "string", []) version: soljson.cwrap("version", "string", [])
} }

@ -1,6 +1,6 @@
{ {
"name": "solc", "name": "solc",
"version": "0.1.5", "version": "0.1.5-multi",
"description": "Solidity compiler", "description": "Solidity compiler",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

Loading…
Cancel
Save