Commit 191c5207 authored by Iuri Matias's avatar Iuri Matias

use compiler from remix-solidity

parent 2ee0f599
......@@ -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();
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"
}
}
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,15 +4,17 @@ 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;
let abi = contract.abi;
let code = contract.evm.bytecode.object;
compiledObject[className] = {};
compiledObject[className].abi = abi;
......@@ -20,6 +22,7 @@ function deployAll(compileResult, web3, accounts, callback) {
compiledObject[className].filename = filename;
compiledObject[className].className = className;
}
}
async.eachOfLimit(compiledObject, 1, function(contract, contractName, next) {
let contractObject = new web3.eth.Contract(contract.abi);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment