Merge pull request #752 from embark-framework/feature/silent-already-deployed

Silent already deployed
This commit is contained in:
Iuri Matias 2018-08-29 17:37:54 -04:00 committed by GitHub
commit bd49e3672c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 5 deletions

View File

@ -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;