diff --git a/lib/config/blockchain.js b/lib/config/blockchain.js index 7b872691e..ca2e0f080 100644 --- a/lib/config/blockchain.js +++ b/lib/config/blockchain.js @@ -9,12 +9,12 @@ BlockchainConfig.prototype.loadConfigFile = function(filename) { throw new Error("error reading " + filename); } return this; -} +}; BlockchainConfig.prototype.loadConfig = function(config) { this.blockchainConfig = config; return this; -} +}; BlockchainConfig.prototype.config = function(env) { if (this.blockchainConfig === null) { @@ -25,10 +25,10 @@ BlockchainConfig.prototype.config = function(env) { var networkId; if (config.network_id === undefined) { - networkId = Math.floor((Math.random() * 100000) + 1000) + networkId = Math.floor((Math.random() * 100000) + 1000); } else { - networkId = config.network_id + networkId = config.network_id; } config = { @@ -47,7 +47,7 @@ BlockchainConfig.prototype.config = function(env) { } return config; -} +}; -module.exports = BlockchainConfig +module.exports = BlockchainConfig; diff --git a/lib/config/contracts.js b/lib/config/contracts.js index db7a76a5a..4ec407b16 100644 --- a/lib/config/contracts.js +++ b/lib/config/contracts.js @@ -1,7 +1,5 @@ -indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; var readYaml = require('read-yaml'); var fs = require('fs'); -var Blockchain = require('./blockchain.js'); var toposort = require('toposort'); ContractsConfig = function(blockchainConfig, web3) { @@ -39,16 +37,16 @@ ContractsConfig.prototype.loadConfigFile = function(filename) { throw new Error("error reading " + filename); } return this; -} +}; ContractsConfig.prototype.loadConfig = function(config) { this.contractConfig = config; return this; -} +}; ContractsConfig.prototype.config = function(env) { return this.contractConfig[env]; -} +}; ContractsConfig.prototype.compileContracts = function(env) { var contractFile, source, j; @@ -86,7 +84,7 @@ ContractsConfig.prototype.compileContracts = function(env) { } this.sortContracts(); -} +}; ContractsConfig.prototype.sortContracts = function() { var converted_dependencies = [], i; @@ -105,7 +103,7 @@ ContractsConfig.prototype.sortContracts = function() { var order_b = orderedDependencies.indexOf(b); return order_a - order_b; });; -} +}; -module.exports = ContractsConfig +module.exports = ContractsConfig; diff --git a/lib/deploy.js b/lib/deploy.js index b1d4cfa04..e29204835 100644 --- a/lib/deploy.js +++ b/lib/deploy.js @@ -17,14 +17,12 @@ Deploy = function(env, contractFiles, blockchainConfig, contractsConfig) { web3.setProvider(new web3.providers.HttpProvider("http://" + this.blockchainConfig.rpcHost + ":" + this.blockchainConfig.rpcPort)); primaryAddress = web3.eth.coinbase; web3.eth.defaultAccount = primaryAddress; - } catch (_error) { - e = _error; - console.log("==== can't connect to " + this.blockchainConfig.rpcHost + ":" + this.blockchainConfig.rpcPort + " check if an ethereum node is running"); - exit; + } catch (e) { + throw new Error("==== can't connect to " + this.blockchainConfig.rpcHost + ":" + this.blockchainConfig.rpcPort + " check if an ethereum node is running"); } console.log("address is : " + primaryAddress); -} +}; Deploy.prototype.deploy_contracts = function(env) { this.contractsManager.compileContracts(env); @@ -70,7 +68,7 @@ Deploy.prototype.deploy_contracts = function(env) { console.log("deployed " + className + " at " + contractAddress); } -} +}; Deploy.prototype.generate_abi_file = function() { var result; @@ -90,12 +88,12 @@ Deploy.prototype.generate_abi_file = function() { } return result; -} +}; Deploy.prototype.generate_and_write_abi_file = function(destFile) { var result = this.generate_abi_file(); grunt.file.write(destFile, result); -} +}; -module.exports = Deploy +module.exports = Deploy; diff --git a/lib/test.js b/lib/test.js index 36df868f3..b8ed4600a 100644 --- a/lib/test.js +++ b/lib/test.js @@ -1,13 +1,10 @@ var python = require('python').shell; -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) { return sync(python, cmd)[1].trim(); -} +}; TestContractWrapper = (function() { function TestContractWrapper(contract, className, args) { @@ -18,28 +15,28 @@ TestContractWrapper = (function() { } TestContractWrapper.prototype.initializeContract = function() { - example_abi = JSON.stringify(this.contract.info.abiDefinition) - example_binary = this.contract.code.slice(2) + example_abi = JSON.stringify(this.contract.info.abiDefinition); + example_binary = this.contract.code.slice(2); - py_exec("example_abi = '" + example_abi + "'") - py_exec("example_abi") - py_exec("example_binary = '" + example_binary + "'.decode('hex')") - py_exec("example_binary") + py_exec("example_abi = '" + example_abi + "'"); + py_exec("example_abi"); + py_exec("example_binary = '" + example_binary + "'.decode('hex')"); + py_exec("example_binary"); - if (this.args == undefined) { - py_exec(this.className + "_contract = EvmContract(example_abi, example_binary, '" + this.className + "')") + if (this.args === undefined) { + py_exec(this.className + "_contract = EvmContract(example_abi, example_binary, '" + this.className + "')"); } else { - py_exec(this.className + "_contract = EvmContract(example_abi, example_binary, '" + this.className + "', [" + this.args.join(",") + "])") + py_exec(this.className + "_contract = EvmContract(example_abi, example_binary, '" + this.className + "', [" + this.args.join(",") + "])"); } - this.contractVariable = this.className + "_contract" + this.contractVariable = this.className + "_contract"; }; TestContractWrapper.prototype.execCmd = function(method, args) { - arg_list = []; - for (key in args) { - value = args[key]; + var arg_list = []; + for (var key in args) { + var value = args[key]; arg_list.push(value); } @@ -68,8 +65,8 @@ test = function(contractsConfig, contractFiles) { test.prototype.request = function(className, args) { var contract = this.contractDB[className]; - py_exec("from ethertdd import EvmContract") - return TestContract(contract, className, args) + py_exec("from ethertdd import EvmContract"); + return TestContract(contract, className, args); } module.exports = test;