diff --git a/lib/contracts/deploy.js b/lib/contracts/deploy.js index beedfa829..be4207d42 100644 --- a/lib/contracts/deploy.js +++ b/lib/contracts/deploy.js @@ -61,6 +61,12 @@ class Deploy { self.logger.info(contract.className.bold.cyan + " already deployed at ".green + trackedContract.address.bold.cyan); contract.deployedAddress = trackedContract.address; self.logger.contractsState(self.contractsManager.contractsState()); + + // always run contractCode so other functionality like 'afterDeploy' can also work + let codeGenerator = new CodeGenerator({contractsManager: self.contractsManager}); + let contractCode = codeGenerator.generateContractCode(contract); + RunCode.doEval(contractCode, self.web3); + return callback(); } else { @@ -74,9 +80,13 @@ class Deploy { self.deployTracker.save(); self.logger.contractsState(self.contractsManager.contractsState()); + // always run contractCode so other functionality like 'afterDeploy' can also work + let codeGenerator = new CodeGenerator({contractsManager: self.contractsManager}); + let contractCode = codeGenerator.generateContractCode(contract); + RunCode.doEval(contractCode, self.web3); + if (contract.onDeploy !== undefined) { self.logger.info('executing onDeploy commands'); - let codeGenerator = new CodeGenerator({contractsManager: self.contractsManager}); let cmds = ""; cmds += codeGenerator.generateContractCode(contract); diff --git a/lib/contracts/deploy_manager.js b/lib/contracts/deploy_manager.js index b6297489a..3f9990c6b 100644 --- a/lib/contracts/deploy_manager.js +++ b/lib/contracts/deploy_manager.js @@ -117,7 +117,10 @@ class DeployManager { return callback(new Error("error running afterDeploy")); } - RunCode.doEval(onDeployCode.join(';\n'), web3); + onDeployCode.forEach((cmd) => { + self.logger.info("executing: " + cmd); + RunCode.doEval(cmd, web3); + }); callback(null, contractsManager); } diff --git a/lib/core/runCode.js b/lib/core/runCode.js index 43bf4ea89..414776374 100644 --- a/lib/core/runCode.js +++ b/lib/core/runCode.js @@ -14,6 +14,7 @@ function doEval(code, _web3) { } try { + // TODO: add trace log here return eval(code); // jshint ignore:line } catch(e) { throw new Error(e + "\n" + code);