mirror of https://github.com/embarklabs/embark.git
always define contract code so ondeploy cmds work
This commit is contained in:
parent
33adaf360b
commit
750eace6ce
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue