Silent already deployed

This commit is contained in:
Anthony Laibe 2018-08-29 11:23:24 +01:00
parent c84cb34527
commit c94b5574cf
1 changed files with 8 additions and 5 deletions

View File

@ -135,7 +135,7 @@ class ContractDeployer {
return next(e.message); return next(e.message);
} }
contract.deployedAddress = contract.address; 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); self.events.emit("deploy:contract:deployed", contract);
return next(); return next();
} }
@ -163,7 +163,7 @@ class ContractDeployer {
contractAlreadyDeployed(contract, trackedContract, callback) { contractAlreadyDeployed(contract, trackedContract, callback) {
const self = this; 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; contract.deployedAddress = trackedContract.address;
self.events.emit("deploy:contract:deployed", contract); 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) { deployContract(contract, callback) {
let self = this; let self = this;
let contractParams = (contract.realArgs || contract.args).slice(); let contractParams = (contract.realArgs || contract.args).slice();
let deployObject; let deployObject;
const logFunction = contract.silent ? self.logger.trace.bind(self.logger) : self.logger.info.bind(self.logger);
async.waterfall([ async.waterfall([
function doLinking(next) { function doLinking(next) {
@ -252,7 +255,7 @@ class ContractDeployer {
}, },
function deployTheContract(next) { function deployTheContract(next) {
let estimatedCost = contract.gas * contract.gasPrice; 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, { self.blockchain.deployContractFromObject(deployObject, {
@ -265,7 +268,7 @@ class ContractDeployer {
self.events.emit("deploy:contract:error", contract); self.events.emit("deploy:contract:error", contract);
return next(new Error("error deploying =" + contract.className + "= due to error: " + error.message)); 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.deployedAddress = receipt.contractAddress;
contract.transactionHash = receipt.transactionHash; contract.transactionHash = receipt.transactionHash;
receipt.className = contract.className; receipt.className = contract.className;