use compiler from remix-solidity

pull/7/head
Iuri Matias 7 years ago
parent 2ee0f59955
commit 191c5207ef
  1. 6
      examples/simple_storage_test.sol
  2. 6
      index.js
  3. 2
      package.json
  4. 53
      src/compiler.js
  5. 27
      src/deployer.js

@ -10,11 +10,13 @@ contract MyTest {
}
function initialValueShouldBe100() public constant returns (bool) {
return Assert.equal(foo.get(), 100, "initial value is not correct");
//return Assert.equal(foo.get(), 100, "initial value is not correct");
return true;
}
function initialValueShouldBe200() public constant returns (bool) {
return Assert.equal(foo.get(), 200, "initial value is not correct");
//return Assert.equal(foo.get(), 200, "initial value is not correct");
return false;
}
}

@ -11,8 +11,10 @@ var runTest = function(filename) {
async.waterfall([
function compile(next) {
result = Compiler.compileAll();
next();
Compiler.compileAll(function(err, compilationResult) {
result = compilationResult;
next();
});
},
function initWeb3(next) {
web3 = web3Instance();

@ -22,7 +22,7 @@
"commander": "^2.13.0",
"ethereumjs-vm": "^2.3.2",
"remix-lib": "^0.1.2",
"solc": "^0.4.17",
"remix-solidity": "../remix/remix-solidity",
"web3": "^1.0.0-beta.27"
}
}

@ -1,18 +1,53 @@
let fs = require('fs');
let solc = require('solc');
//let compiler = require('solc');
var async = require('async');
let remixLib = require('remix-lib');
let compilerInput = remixLib.helpers.compiler;
let RemixCompiler = require('remix-solidity').Compiler;
// TODO: replace this with remix's own compiler code
function compileAll() {
const input = {
"simple_storage.sol": fs.readFileSync("examples/simple_storage.sol").toString(),
"tests.sol": fs.readFileSync("examples/tests.sol").toString(),
"simple_storage_test.sol": fs.readFileSync("examples/simple_storage_test.sol").toString()
function compileAll(cb) {
//const input = {
// "simple_storage.sol": fs.readFileSync("examples/simple_storage.sol").toString(),
// "tests.sol": fs.readFileSync("examples/tests.sol").toString(),
// "simple_storage_test.sol": fs.readFileSync("examples/simple_storage_test.sol").toString()
//};
//const optimize = 1;
//result = compiler.compileStandardWrapper({sources: input}, optimize);
//cb(null, result.contracts);
console.log("compile all");
let compiler;
const sources = {
"simple_storage.sol": {content: fs.readFileSync("examples/simple_storage.sol").toString()},
"tests.sol": {content: fs.readFileSync("examples/tests.sol").toString()},
"simple_storage_test.sol": {content: fs.readFileSync("examples/simple_storage_test.sol").toString()}
};
const optimize = 1;
result = solc.compile({sources: input}, optimize);
async.waterfall([
function loadCompiler(next) {
console.log("loadCompiler");
compiler = new RemixCompiler();
compiler.onInternalCompilerLoaded();
//compiler.event.register('compilerLoaded', this, function (version) {
next();
//});
},
function doCompilation(next) {
compiler.event.register('compilationFinished', this, function (success, data, source) {
next(null, data);
});
console.log("doCompilation");
compiler.compile(sources, "examples/");
}
], function(err, result) {
console.dir("==== result ====");
console.dir(result);
cb(null, result.contracts);
});
return result.contracts;
}
module.exports = {

@ -4,21 +4,24 @@ var async = require('async');
function deployAll(compileResult, web3, accounts, callback) {
let compiledObject = {}, contracts = {};
for (let contractName in compileResult) {
let contract = compileResult[contractName];
const regex = /(.*):(.*)/;
const className = contractName.match(regex)[2];
const filename = contractName.match(regex)[1];
for (let contractFile in compileResult) {
for (let contractName in compileResult[contractFile]) {
let contract = compileResult[contractFile][contractName];
let abi = JSON.parse(contract.interface);
let code = contract.bytecode;
const className = contractName;
const filename = contractFile;
compiledObject[className] = {};
compiledObject[className].abi = abi;
compiledObject[className].code = code;
compiledObject[className].filename = filename;
compiledObject[className].className = className;
let abi = contract.abi;
let code = contract.evm.bytecode.object;
compiledObject[className] = {};
compiledObject[className].abi = abi;
compiledObject[className].code = code;
compiledObject[className].filename = filename;
compiledObject[className].className = className;
}
}
async.eachOfLimit(compiledObject, 1, function(contract, contractName, next) {

Loading…
Cancel
Save