compile contracts and request correct contract to proxy

This commit is contained in:
Iuri Matias 2015-06-13 16:57:44 -04:00
parent bda4267fa2
commit 55cdf4c878

View File

@ -3,6 +3,7 @@ var web3 = require('web3');
var fs = require('fs');
var mm = require('methodmissing');
var sync = require('sync-me');
var grunt = require('grunt');
py_exec = function(cmd) {
console.log("python: " + cmd);
@ -58,12 +59,24 @@ TestContract = function(contract, className) {
return Obj;
}
request = function(className) {
filename = './app/contracts/simple_storage.sol'
source = fs.readFileSync(filename).toString()
//TODO: get the files from the config
contractFiles = grunt.file.expand("./app/contracts/**/*.sol")
contractDB = {}
var i;
for (i = 0, len = contractFiles.length; i < len; i++) {
var contractFile = contractFiles[i];
var source = fs.readFileSync(contractFile).toString()
compiled_contracts = web3.eth.compile.solidity(source)
contract = compiled_contracts[className]
for (className in compiled_contracts) {
var contract = compiled_contracts[className];
contractDB[className] = contract;
}
}
request = function(className) {
var contract = contractDB[className];
return TestContract(contract, className)
}