From 250e0b8798895ae601a21ff26da56b880f7dd632 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sun, 20 May 2018 19:59:35 -0400 Subject: [PATCH] adjust contracts events emission --- lib/contracts/deploy.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/contracts/deploy.js b/lib/contracts/deploy.js index 0289ab76..f42514d5 100644 --- a/lib/contracts/deploy.js +++ b/lib/contracts/deploy.js @@ -81,6 +81,7 @@ class Deploy { self.logger.error(__("error deploying %s", contract.className)); self.logger.error(e.message); contract.error = e.message; + self.events.emit("deploy:contract:error", contract); self.events.emit('contractsState', self.contractsManager.contractsState()); return callback(e.message); } @@ -91,10 +92,6 @@ class Deploy { return callback(); } - //if (!this.deployTracker) { - // return self.contractToDeploy(contract, params, callback); - //} - // TODO: this should be a plugin API instead, if not existing, it should by default deploy the contract self.events.request("deploy:contract:shouldDeploy", contract, function(trackedContract) { if (!trackedContract) { @@ -115,6 +112,7 @@ class Deploy { const self = this; self.logger.info(contract.className.bold.cyan + __(" already deployed at ").green + trackedContract.address.bold.cyan); contract.deployedAddress = trackedContract.address; + self.events.emit("deploy:contract:deployed", contract); self.events.emit('contractsState', self.contractsManager.contractsState()); // always run contractCode so other functionality like 'afterDeploy' can also work @@ -131,6 +129,8 @@ class Deploy { this.deployContract(contract, contract.realArgs, function (err, address) { if (err) { + self.events.emit("deploy:contract:error", contract); + self.events.emit('contractsState', self.contractsManager.contractsState()); return callback(new Error(err)); } contract.address = address; @@ -277,13 +277,11 @@ class Deploy { gasPrice: contract.gasPrice }, function(error, receipt) { if (error) { - self.events.emit('contractsState', self.contractsManager.contractsState()); return next(new Error("error deploying =" + contract.className + "= due to error: " + error.message)); } self.logger.info(contract.className.bold.cyan + " " + __("deployed at").green + " " + receipt.contractAddress.bold.cyan); contract.deployedAddress = receipt.contractAddress; contract.transactionHash = receipt.transactionHash; - self.events.emit('contractsState', self.contractsManager.contractsState()); return next(null, receipt.contractAddress); }); }