diff --git a/lib/contracts/code_generator.js b/lib/contracts/code_generator.js index 4d5d8467e..6204086ad 100644 --- a/lib/contracts/code_generator.js +++ b/lib/contracts/code_generator.js @@ -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"; diff --git a/lib/contracts/deploy.js b/lib/contracts/deploy.js index d80a987c7..4b07e2c2a 100644 --- a/lib/contracts/deploy.js +++ b/lib/contracts/deploy.js @@ -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(); diff --git a/test_app/app/js/index.js b/test_app/app/js/index.js index bbae71d65..0c75cfdc4 100644 --- a/test_app/app/js/index.js +++ b/test_app/app/js/index.js @@ -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';