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); }); }