mirror of https://github.com/embarklabs/embark.git
Merge branch 'develop' of github.com:iurimatias/embark-framework into develop
This commit is contained in:
commit
fff31d6995
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
var Embark = require('..');
|
||||
Embark.process(process.argv)
|
||||
Embark.process(process.argv);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
In the meantime, just set an empty config object.
|
||||
*/
|
||||
config = {}
|
||||
config = {};
|
||||
|
||||
defaults = {
|
||||
interval_ms: 15000,
|
||||
|
@ -25,9 +25,9 @@
|
|||
mine_periodically: false,
|
||||
mine_normally: false,
|
||||
threads: 1
|
||||
}
|
||||
};
|
||||
|
||||
for (key in defaults) {
|
||||
for (var key in defaults) {
|
||||
if (config[key] === undefined) {
|
||||
config[key] = defaults[key];
|
||||
}
|
||||
|
@ -54,7 +54,7 @@
|
|||
var fundAccount = function (config, miner_obj, cb) {
|
||||
var accountFunded = function () {
|
||||
return (eth.getBalance(eth.coinbase) >= config.initial_ether);
|
||||
}
|
||||
};
|
||||
|
||||
if (accountFunded()) {
|
||||
return cb();
|
||||
|
|
|
@ -19,10 +19,12 @@ ContractsManager.prototype.compileContracts = function() {
|
|||
|
||||
ContractsManager.prototype.build = function() {
|
||||
this.compiledContracts = this.compileContracts();
|
||||
var className;
|
||||
var contract;
|
||||
|
||||
// go through config file first
|
||||
for(var className in this.contractsConfig.contracts) {
|
||||
var contract = this.contractsConfig.contracts[className];
|
||||
for(className in this.contractsConfig.contracts) {
|
||||
contract = this.contractsConfig.contracts[className];
|
||||
|
||||
contract.className = className;
|
||||
contract.args = contract.args || [];
|
||||
|
@ -31,11 +33,11 @@ ContractsManager.prototype.build = function() {
|
|||
}
|
||||
|
||||
// compile contracts
|
||||
for(var className in this.compiledContracts) {
|
||||
for(className in this.compiledContracts) {
|
||||
var compiledContract = this.compiledContracts[className];
|
||||
var contractConfig = this.contractsConfig.contracts[className];
|
||||
|
||||
var contract = this.contracts[className] || {className: className, args: []};
|
||||
contract = this.contracts[className] || {className: className, args: []};
|
||||
|
||||
contract.code = compiledContract.code;
|
||||
contract.runtimeBytecode = compiledContract.runtimeBytecode;
|
||||
|
@ -67,8 +69,8 @@ ContractsManager.prototype.build = function() {
|
|||
}
|
||||
|
||||
// deal with special configs
|
||||
for(var className in this.contracts) {
|
||||
var contract = this.contracts[className];
|
||||
for(className in this.contracts) {
|
||||
contract = this.contracts[className];
|
||||
|
||||
// if deploy intention is not specified default is true
|
||||
if (contract.deploy === undefined) {
|
||||
|
@ -109,8 +111,8 @@ ContractsManager.prototype.build = function() {
|
|||
}
|
||||
|
||||
// remove contracts that don't have code
|
||||
for(var className in this.contracts) {
|
||||
var contract = this.contracts[className];
|
||||
for(className in this.contracts) {
|
||||
contract = this.contracts[className];
|
||||
|
||||
if (contract.code === undefined) {
|
||||
this.logger.error(className + " has no code associated");
|
||||
|
@ -121,8 +123,8 @@ ContractsManager.prototype.build = function() {
|
|||
this.logger.trace(this.contracts);
|
||||
|
||||
// determine dependencies
|
||||
for(var className in this.contracts) {
|
||||
var contract = this.contracts[className];
|
||||
for(className in this.contracts) {
|
||||
contract = this.contracts[className];
|
||||
|
||||
if (contract.args === []) continue;
|
||||
|
||||
|
@ -149,7 +151,7 @@ ContractsManager.prototype.sortContracts = function(contractList) {
|
|||
|
||||
for(var contract in this.contractDependencies) {
|
||||
var dependencies = this.contractDependencies[contract];
|
||||
for(var i=0; i < dependencies.length; i++) {
|
||||
for(i=0; i < dependencies.length; i++) {
|
||||
converted_dependencies.push([contract, dependencies[i]]);
|
||||
}
|
||||
}
|
||||
|
@ -188,19 +190,19 @@ ContractsManager.prototype.contractsState = function() {
|
|||
className.green,
|
||||
'Interface or set to not deploy'.green,
|
||||
"\t\tn/a".green
|
||||
]
|
||||
];
|
||||
} else if (contract.error) {
|
||||
contractData = [
|
||||
className.green,
|
||||
(contract.error).red,
|
||||
'\t\tError'.red
|
||||
]
|
||||
];
|
||||
} else {
|
||||
contractData = [
|
||||
className.green,
|
||||
(contract.deployedAddress || '...').green,
|
||||
((contract.deployedAddress !== undefined) ? "\t\tDeployed".green : "\t\tPending".magenta)
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
data.push(contractData);
|
||||
|
@ -210,4 +212,3 @@ ContractsManager.prototype.contractsState = function() {
|
|||
};
|
||||
|
||||
module.exports = ContractsManager;
|
||||
|
||||
|
|
|
@ -17,7 +17,12 @@ var Deploy = function(options) {
|
|||
|
||||
Deploy.prototype.checkAndDeployContract = function(contract, params, callback) {
|
||||
var self = this;
|
||||
|
||||
var suppliedArgs;
|
||||
var realArgs;
|
||||
var arg;
|
||||
var l;
|
||||
var contractName;
|
||||
var referedContract;
|
||||
contract.error = false;
|
||||
|
||||
if (contract.deploy === false) {
|
||||
|
@ -28,14 +33,14 @@ Deploy.prototype.checkAndDeployContract = function(contract, params, callback) {
|
|||
if (contract.address !== undefined) {
|
||||
|
||||
// determine arguments
|
||||
var suppliedArgs = (params || contract.args);
|
||||
var realArgs = [];
|
||||
suppliedArgs = (params || contract.args);
|
||||
realArgs = [];
|
||||
|
||||
for (var l = 0; l < suppliedArgs.length; l++) {
|
||||
var arg = suppliedArgs[l];
|
||||
for (l = 0; l < suppliedArgs.length; l++) {
|
||||
arg = suppliedArgs[l];
|
||||
if (arg[0] === "$") {
|
||||
var contractName = arg.substr(1);
|
||||
var referedContract = this.contractsManager.getContract(contractName);
|
||||
contractName = arg.substr(1);
|
||||
referedContract = this.contractsManager.getContract(contractName);
|
||||
realArgs.push(referedContract.deployedAddress);
|
||||
} else {
|
||||
realArgs.push(arg);
|
||||
|
@ -59,14 +64,14 @@ Deploy.prototype.checkAndDeployContract = function(contract, params, callback) {
|
|||
} else {
|
||||
|
||||
// determine arguments
|
||||
var suppliedArgs = (params || contract.args);
|
||||
var realArgs = [];
|
||||
suppliedArgs = (params || contract.args);
|
||||
realArgs = [];
|
||||
|
||||
for (var l = 0; l < suppliedArgs.length; l++) {
|
||||
var arg = suppliedArgs[l];
|
||||
for (l = 0; l < suppliedArgs.length; l++) {
|
||||
arg = suppliedArgs[l];
|
||||
if (arg[0] === "$") {
|
||||
var contractName = arg.substr(1);
|
||||
var referedContract = this.contractsManager.getContract(contractName);
|
||||
contractName = arg.substr(1);
|
||||
referedContract = this.contractsManager.getContract(contractName);
|
||||
realArgs.push(referedContract.deployedAddress);
|
||||
} else {
|
||||
realArgs.push(arg);
|
||||
|
@ -103,7 +108,7 @@ Deploy.prototype.deployContract = function(contract, params, callback) {
|
|||
|
||||
var contractParams = (params || contract.args).slice();
|
||||
|
||||
this.web3.eth.getAccounts(function(err, accounts) {
|
||||
this.web3.eth.getAccounts(function(err, accounts) {
|
||||
//console.log("using address" + this.web3.eth.accounts[0]);
|
||||
|
||||
// TODO: probably needs to be defaultAccount
|
||||
|
@ -161,4 +166,3 @@ Deploy.prototype.deployAll = function(done) {
|
|||
};
|
||||
|
||||
module.exports = Deploy;
|
||||
|
||||
|
|
Loading…
Reference in New Issue