From 21026e07aee0da4f13a60a59af3d451c1b7f4c49 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sun, 20 May 2018 09:15:28 -0400 Subject: [PATCH] remove unnecessary passing of params around --- lib/contracts/deploy_manager.js | 40 ++++++++++++++++----------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/lib/contracts/deploy_manager.js b/lib/contracts/deploy_manager.js index db469ee8f..1c526b014 100644 --- a/lib/contracts/deploy_manager.js +++ b/lib/contracts/deploy_manager.js @@ -32,34 +32,36 @@ class DeployManager { async.waterfall([ function buildContracts(callback) { self.contractsManager.deployOnlyOnConfig = self.deployOnlyOnConfig; // temporary, should refactor - self.contractsManager.build(callback); + self.contractsManager.build(() => { + callback(); + }); }, - function checkCompileOnly(contractsManager, callback){ + function checkCompileOnly(callback){ if(self.onlyCompile){ - self.events.emit('contractsDeployed', contractsManager); + self.events.emit('contractsDeployed', self.contractsManager); return done(); } - return callback(null, contractsManager); + return callback(); }, // TODO: could be implemented as an event (beforeDeployAll) - function checkIsConnectedToBlockchain(contractsManager, callback) { + function checkIsConnectedToBlockchain(callback) { self.blockchain.assertNodeConnection((err) => { - callback(err, contractsManager); + callback(err); }); }, // TODO: this can be done on the fly or as part of the initialization - function determineDefaultAccount(contractsManager, callback) { + function determineDefaultAccount(callback) { self.blockchain.determineDefaultAccount((err) => { - callback(err, contractsManager); + callback(err); }); }, - function deployAllContracts(contractsManager, callback) { + function deployAllContracts(callback) { let deploy = new Deploy({ blockchain: self.blockchain, - contractsManager: contractsManager, + contractsManager: self.contractsManager, logger: self.logger, events: self.events, chainConfig: self.chainConfig, @@ -70,15 +72,15 @@ class DeployManager { deploy.deployAll(function (err) { if (!err) { - self.events.emit('contractsDeployed', contractsManager); + self.events.emit('contractsDeployed', self.contractsManager); } if (err && self.fatalErrors) { return callback(err); } - callback(null, contractsManager); + callback(); }); }, - function runAfterDeployCommands(contractsManager, callback) { + function runAfterDeployCommands(callback) { // TODO: should instead emit a afterDeploy event and/or run a afterDeploy plugin let afterDeployCmds = self.config.contractsConfig.afterDeploy || []; @@ -87,7 +89,7 @@ class DeployManager { let onDeployCode = afterDeployCmds.map((cmd) => { let realCmd = cmd.replace(regex, (match) => { let referedContractName = match.slice(1); - let referedContract = contractsManager.getContract(referedContractName); + let referedContract = self.contractsManager.getContract(referedContractName); if (!referedContract) { self.logger.error(referedContractName + ' does not exist'); self.logger.error(__("error running afterDeploy: ") + cmd); @@ -128,14 +130,10 @@ class DeployManager { } } - callback(null, contractsManager); - } - ], function (err, result) { - if (err) { - done(err, null); - } else { - done(null, result); + callback(); } + ], function (err, _result) { + done(err); }); }