Merge pull request #184 from almindor/develop

fix lint errors
This commit is contained in:
Iuri Matias 2016-10-22 17:20:57 -04:00 committed by GitHub
commit 6ef1414b5c
4 changed files with 40 additions and 35 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/env node #!/usr/bin/env node
var Embark = require('..'); var Embark = require('..');
Embark.process(process.argv) Embark.process(process.argv);

View File

@ -16,7 +16,7 @@
In the meantime, just set an empty config object. In the meantime, just set an empty config object.
*/ */
config = {} config = {};
defaults = { defaults = {
interval_ms: 15000, interval_ms: 15000,
@ -25,9 +25,9 @@
mine_periodically: false, mine_periodically: false,
mine_normally: false, mine_normally: false,
threads: 1 threads: 1
} };
for (key in defaults) { for (var key in defaults) {
if (config[key] === undefined) { if (config[key] === undefined) {
config[key] = defaults[key]; config[key] = defaults[key];
} }
@ -54,7 +54,7 @@
var fundAccount = function (config, miner_obj, cb) { var fundAccount = function (config, miner_obj, cb) {
var accountFunded = function () { var accountFunded = function () {
return (eth.getBalance(eth.coinbase) >= config.initial_ether); return (eth.getBalance(eth.coinbase) >= config.initial_ether);
} };
if (accountFunded()) { if (accountFunded()) {
return cb(); return cb();

View File

@ -19,10 +19,12 @@ ContractsManager.prototype.compileContracts = function() {
ContractsManager.prototype.build = function() { ContractsManager.prototype.build = function() {
this.compiledContracts = this.compileContracts(); this.compiledContracts = this.compileContracts();
var className;
var contract;
// go through config file first // go through config file first
for(var className in this.contractsConfig.contracts) { for(className in this.contractsConfig.contracts) {
var contract = this.contractsConfig.contracts[className]; contract = this.contractsConfig.contracts[className];
contract.className = className; contract.className = className;
contract.args = contract.args || []; contract.args = contract.args || [];
@ -31,11 +33,11 @@ ContractsManager.prototype.build = function() {
} }
// compile contracts // compile contracts
for(var className in this.compiledContracts) { for(className in this.compiledContracts) {
var compiledContract = this.compiledContracts[className]; var compiledContract = this.compiledContracts[className];
var contractConfig = this.contractsConfig.contracts[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.code = compiledContract.code;
contract.runtimeBytecode = compiledContract.runtimeBytecode; contract.runtimeBytecode = compiledContract.runtimeBytecode;
@ -67,8 +69,8 @@ ContractsManager.prototype.build = function() {
} }
// deal with special configs // deal with special configs
for(var className in this.contracts) { for(className in this.contracts) {
var contract = this.contracts[className]; contract = this.contracts[className];
// if deploy intention is not specified default is true // if deploy intention is not specified default is true
if (contract.deploy === undefined) { if (contract.deploy === undefined) {
@ -109,8 +111,8 @@ ContractsManager.prototype.build = function() {
} }
// remove contracts that don't have code // remove contracts that don't have code
for(var className in this.contracts) { for(className in this.contracts) {
var contract = this.contracts[className]; contract = this.contracts[className];
if (contract.code === undefined) { if (contract.code === undefined) {
this.logger.error(className + " has no code associated"); this.logger.error(className + " has no code associated");
@ -121,8 +123,8 @@ ContractsManager.prototype.build = function() {
this.logger.trace(this.contracts); this.logger.trace(this.contracts);
// determine dependencies // determine dependencies
for(var className in this.contracts) { for(className in this.contracts) {
var contract = this.contracts[className]; contract = this.contracts[className];
if (contract.args === []) continue; if (contract.args === []) continue;
@ -149,7 +151,7 @@ ContractsManager.prototype.sortContracts = function(contractList) {
for(var contract in this.contractDependencies) { for(var contract in this.contractDependencies) {
var dependencies = this.contractDependencies[contract]; 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]]); converted_dependencies.push([contract, dependencies[i]]);
} }
} }
@ -188,19 +190,19 @@ ContractsManager.prototype.contractsState = function() {
className.green, className.green,
'Interface or set to not deploy'.green, 'Interface or set to not deploy'.green,
"\t\tn/a".green "\t\tn/a".green
] ];
} else if (contract.error) { } else if (contract.error) {
contractData = [ contractData = [
className.green, className.green,
(contract.error).red, (contract.error).red,
'\t\tError'.red '\t\tError'.red
] ];
} else { } else {
contractData = [ contractData = [
className.green, className.green,
(contract.deployedAddress || '...').green, (contract.deployedAddress || '...').green,
((contract.deployedAddress !== undefined) ? "\t\tDeployed".green : "\t\tPending".magenta) ((contract.deployedAddress !== undefined) ? "\t\tDeployed".green : "\t\tPending".magenta)
] ];
} }
data.push(contractData); data.push(contractData);
@ -210,4 +212,3 @@ ContractsManager.prototype.contractsState = function() {
}; };
module.exports = ContractsManager; module.exports = ContractsManager;

View File

@ -17,7 +17,12 @@ var Deploy = function(options) {
Deploy.prototype.checkAndDeployContract = function(contract, params, callback) { Deploy.prototype.checkAndDeployContract = function(contract, params, callback) {
var self = this; var self = this;
var suppliedArgs;
var realArgs;
var arg;
var l;
var contractName;
var referedContract;
contract.error = false; contract.error = false;
if (contract.deploy === false) { if (contract.deploy === false) {
@ -28,14 +33,14 @@ Deploy.prototype.checkAndDeployContract = function(contract, params, callback) {
if (contract.address !== undefined) { if (contract.address !== undefined) {
// determine arguments // determine arguments
var suppliedArgs = (params || contract.args); suppliedArgs = (params || contract.args);
var realArgs = []; realArgs = [];
for (var l = 0; l < suppliedArgs.length; l++) { for (l = 0; l < suppliedArgs.length; l++) {
var arg = suppliedArgs[l]; arg = suppliedArgs[l];
if (arg[0] === "$") { if (arg[0] === "$") {
var contractName = arg.substr(1); contractName = arg.substr(1);
var referedContract = this.contractsManager.getContract(contractName); referedContract = this.contractsManager.getContract(contractName);
realArgs.push(referedContract.deployedAddress); realArgs.push(referedContract.deployedAddress);
} else { } else {
realArgs.push(arg); realArgs.push(arg);
@ -59,14 +64,14 @@ Deploy.prototype.checkAndDeployContract = function(contract, params, callback) {
} else { } else {
// determine arguments // determine arguments
var suppliedArgs = (params || contract.args); suppliedArgs = (params || contract.args);
var realArgs = []; realArgs = [];
for (var l = 0; l < suppliedArgs.length; l++) { for (l = 0; l < suppliedArgs.length; l++) {
var arg = suppliedArgs[l]; arg = suppliedArgs[l];
if (arg[0] === "$") { if (arg[0] === "$") {
var contractName = arg.substr(1); contractName = arg.substr(1);
var referedContract = this.contractsManager.getContract(contractName); referedContract = this.contractsManager.getContract(contractName);
realArgs.push(referedContract.deployedAddress); realArgs.push(referedContract.deployedAddress);
} else { } else {
realArgs.push(arg); realArgs.push(arg);
@ -161,4 +166,3 @@ Deploy.prototype.deployAll = function(done) {
}; };
module.exports = Deploy; module.exports = Deploy;