fix on deploy

This commit is contained in:
Iuri Matias 2017-12-20 11:32:11 -05:00
parent 7e4429b342
commit d005d3f668
3 changed files with 14 additions and 9 deletions

View File

@ -194,6 +194,14 @@ class CodeGenerator {
return result;
}
generateContractCode(contract) {
let abi = JSON.stringify(contract.abiDefinition);
let block = "";
block += Templates.vanilla_contract({className: contract.className, abi: abi, contract: contract});
return block;
}
generateStorageInitialization(useEmbarkJS) {
let self = this;
let result = "\n";

View File

@ -77,16 +77,11 @@ 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');
let _cmds = "";
_cmds += "__mainContext.__loadManagerInstance.execWhenReady(function() {";
_cmds += cmds;
_cmds += "});";
RunCode.doEval(context + "\n" + code + "\n" + _cmds, self.web3);
let cmds = "";
cmds += codeGenerator.generateContractCode(contract);
cmds += contract.onDeploy.join(';\n');
RunCode.doEval(cmds, self.web3);
}
callback();

View File

@ -7,9 +7,11 @@ import 'bootstrap/dist/css/bootstrap.min.css';
//import 'bootstrap/dist/js/bootstrap.min.js';
import EmbarkJS from 'Embark/EmbarkJS';
import SimpleStorage from 'Embark/contracts/SimpleStorage';
import Test from 'Embark/contracts/Test';
window.EmbarkJS = EmbarkJS;
window.SimpleStorage = SimpleStorage;
window.Test = Test;
import './foo.css';