From c94b5574cf8d7b215834fd046262f601fd61ffa3 Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Wed, 29 Aug 2018 11:23:24 +0100 Subject: [PATCH] Silent already deployed --- lib/modules/deployment/contract_deployer.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/modules/deployment/contract_deployer.js b/lib/modules/deployment/contract_deployer.js index e1b01e7e4..de935fa73 100644 --- a/lib/modules/deployment/contract_deployer.js +++ b/lib/modules/deployment/contract_deployer.js @@ -135,7 +135,7 @@ class ContractDeployer { return next(e.message); } contract.deployedAddress = contract.address; - self.logger.info(contract.className.bold.cyan + __(" already deployed at ").green + contract.address.bold.cyan); + self.logFunction(contract)(contract.className.bold.cyan + __(" already deployed at ").green + contract.address.bold.cyan); self.events.emit("deploy:contract:deployed", contract); return next(); } @@ -163,7 +163,7 @@ class ContractDeployer { contractAlreadyDeployed(contract, trackedContract, callback) { const self = this; - self.logger.info(contract.className.bold.cyan + __(" already deployed at ").green + trackedContract.address.bold.cyan); + this.logFunction(contract)(contract.className.bold.cyan + __(" already deployed at ").green + trackedContract.address.bold.cyan); contract.deployedAddress = trackedContract.address; self.events.emit("deploy:contract:deployed", contract); @@ -175,11 +175,14 @@ class ContractDeployer { }); } + logFunction(contract) { + return contract.silent ? this.logger.trace.bind(this.logger) : this.logger.info.bind(this.logger); + } + deployContract(contract, callback) { let self = this; let contractParams = (contract.realArgs || contract.args).slice(); let deployObject; - const logFunction = contract.silent ? self.logger.trace.bind(self.logger) : self.logger.info.bind(self.logger); async.waterfall([ function doLinking(next) { @@ -252,7 +255,7 @@ class ContractDeployer { }, function deployTheContract(next) { let estimatedCost = contract.gas * contract.gasPrice; - logFunction(__("deploying") + " " + contract.className.bold.cyan + " " + __("with").green + " " + contract.gas + " " + __("gas at the price of").green + " " + contract.gasPrice + " " + __("Wei, estimated cost:").green + " " + estimatedCost + " Wei".green); + self.logFunction(contract)(__("deploying") + " " + contract.className.bold.cyan + " " + __("with").green + " " + contract.gas + " " + __("gas at the price of").green + " " + contract.gasPrice + " " + __("Wei, estimated cost:").green + " " + estimatedCost + " Wei".green); self.blockchain.deployContractFromObject(deployObject, { @@ -265,7 +268,7 @@ class ContractDeployer { self.events.emit("deploy:contract:error", contract); return next(new Error("error deploying =" + contract.className + "= due to error: " + error.message)); } - logFunction(contract.className.bold.cyan + " " + __("deployed at").green + " " + receipt.contractAddress.bold.cyan + " " + __("using").green + " " + receipt.gasUsed + " " + __("gas").green); + self.logFunction(contract)(contract.className.bold.cyan + " " + __("deployed at").green + " " + receipt.contractAddress.bold.cyan + " " + __("using").green + " " + receipt.gasUsed + " " + __("gas").green); contract.deployedAddress = receipt.contractAddress; contract.transactionHash = receipt.transactionHash; receipt.className = contract.className;