fix onDeploy cmds

This commit is contained in:
Iuri Matias 2017-12-15 15:50:42 -05:00
parent 0a4a757af8
commit 7c33720c98
2 changed files with 14 additions and 1 deletions

View File

@ -96,6 +96,13 @@ class CodeGenerator {
}
generateContext() {
let result = "";
result += Templates.main_context();
result += Templates.load_manager();
return result;
}
generateProvider(isDeployment) {
let self = this;
let result = "";

View File

@ -77,10 +77,16 @@ class Deploy {
if (contract.onDeploy !== undefined) {
self.logger.info('executing onDeploy commands');
let codeGenerator = new CodeGenerator({contractsManager: self.contractsManager});
let context = codeGenerator.generateContext();
let code = codeGenerator.generateContracts(false, true, true);
let cmds = contract.onDeploy.join(';\n');
RunCode.doEval(code + "\n" + cmds, self.web3);
let _cmds = ""
_cmds += "__mainContext.__loadManagerInstance.execWhenReady(function() {"
_cmds += cmds;
_cmds += "});"
RunCode.doEval(context + "\n" + code + "\n" + _cmds, self.web3);
}
callback();