embark-area-51/lib/index.js

45 lines
1.3 KiB
JavaScript
Raw Normal View History

2016-08-13 14:48:00 +00:00
var async = require('async');
2016-08-14 12:04:34 +00:00
var Web3 = require('web3');
var Deploy = require('./deploy.js');
var ContractsManager = require('./contracts.js');
var ABIGenerator = require('./abi.js');
2015-06-15 10:07:40 +00:00
2016-08-13 14:48:00 +00:00
var Embark = {
2016-08-14 12:04:34 +00:00
initConfig: function(configDir, files, env) {
this.contractsManager = new ContractsManager(configDir, files, env);
this.contractsManager.init();
return this.contractsManager;
}
2016-08-13 14:48:00 +00:00
};
2015-07-03 11:59:35 +00:00
2016-08-14 12:04:34 +00:00
//module.exports = Embark;
async.waterfall([
function loadConfig(callback) {
var contractsManager = Embark.initConfig('config/', 'app/contracts/**/*.sol', 'development');
callback(null, contractsManager);
},
function buildContracts(contractsManager, callback) {
contractsManager.build();
callback(null, contractsManager);
},
function deployContracts(contractsManager, callback) {
var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8101'));
var deploy = new Deploy(web3, contractsManager);
deploy.deployAll(function() {
callback(null, contractsManager);
});
},
function generateABI(contractsManager, callback) {
var abiGenerator = new ABIGenerator(contractsManager);
console.log(abiGenerator.generateProvider());
console.log(abiGenerator.generateContracts());
callback(null, 'done');
},
], function(err, result) {
console.log(arguments);
});