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; 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) { generateStorageInitialization(useEmbarkJS) {
let self = this; let self = this;
let result = "\n"; let result = "\n";

View File

@ -77,16 +77,11 @@ class Deploy {
if (contract.onDeploy !== undefined) { if (contract.onDeploy !== undefined) {
self.logger.info('executing onDeploy commands'); self.logger.info('executing onDeploy commands');
let codeGenerator = new CodeGenerator({contractsManager: self.contractsManager}); 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 = ""; let cmds = "";
_cmds += "__mainContext.__loadManagerInstance.execWhenReady(function() {"; cmds += codeGenerator.generateContractCode(contract);
_cmds += cmds; cmds += contract.onDeploy.join(';\n');
_cmds += "});"; RunCode.doEval(cmds, self.web3);
RunCode.doEval(context + "\n" + code + "\n" + _cmds, self.web3);
} }
callback(); callback();

View File

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