From 460f78cc553d50a549876fc06ec4fd738b741d43 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 17 Oct 2017 07:03:13 -0400 Subject: [PATCH] update events name for code generation --- lib/contracts/code_generator.js | 34 ++++++++++++++++++++++++++++++++- lib/core/engine.js | 2 +- lib/core/test.js | 13 +------------ lib/index.js | 2 +- 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/lib/contracts/code_generator.js b/lib/contracts/code_generator.js index ac973eb42..54850098e 100644 --- a/lib/contracts/code_generator.js +++ b/lib/contracts/code_generator.js @@ -11,7 +11,7 @@ const Templates = { web3_connector: require('./code_templates/web3-connector.js.ejs'), do_when_loaded: require('./code_templates/do-when-loaded.js.ejs'), exec_when_env_loaded: require('./code_templates/exec-when-env-loaded.js.ejs') -} +}; class CodeGenerator { constructor(options) { @@ -27,6 +27,7 @@ class CodeGenerator { listenToCommands() { let self = this; + // deprecated events; to remove in embark 2.7.0 this.events.setCommandHandler('abi-vanila', function(cb) { let vanillaABI = self.generateABI({useEmbarkJS: false}); let contractsJSON = self.generateContractsJSON(); @@ -54,6 +55,37 @@ class CodeGenerator { cb(vanillaABI, contractsJSON); }); + + // new events + this.events.setCommandHandler('code-vanila', function(cb) { + let vanillaABI = self.generateABI({useEmbarkJS: false}); + let contractsJSON = self.generateContractsJSON(); + + cb(vanillaABI, contractsJSON); + }); + + this.events.setCommandHandler('code', function(cb) { + let embarkJSABI = self.generateABI({useEmbarkJS: true}); + let contractsJSON = self.generateContractsJSON(); + + cb(embarkJSABI, contractsJSON); + }); + + this.events.setCommandHandler('code-contracts-vanila', function(cb) { + let vanillaContractsABI = self.generateContracts(false, true, false); + let contractsJSON = self.generateContractsJSON(); + + cb(vanillaContractsABI, contractsJSON); + }); + + this.events.setCommandHandler('code-vanila-deployment', function(cb) { + let vanillaABI = self.generateABI({useEmbarkJS: false, deployment: true}); + let contractsJSON = self.generateContractsJSON(); + + cb(vanillaABI, contractsJSON); + }); + + } generateProvider(isDeployment) { diff --git a/lib/core/engine.js b/lib/core/engine.js index 181b129d3..04bc17297 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -81,7 +81,7 @@ class Engine { plugins: this.plugins }); this.events.on('code-generator-ready', function () { - self.events.request('abi', function (abi, contractsJSON) { + self.events.request('code', function (abi, contractsJSON) { self.currentAbi = abi; self.contractsJSON = contractsJSON; pipeline.build(abi, contractsJSON, null, function() { diff --git a/lib/core/test.js b/lib/core/test.js index 949348658..6173f87be 100644 --- a/lib/core/test.js +++ b/lib/core/test.js @@ -71,21 +71,10 @@ Test.prototype.deployAll = function(contractsConfig, cb) { callback(); }, function deploy(callback) { - //self.engine.events.setHandler('abi-contracts-vanila', function(vanillaABI) { - //elf.engine.events.on('abi-contracts-vanila', function(vanillaABI) { self.engine.events.on('code-generator-ready', function () { - self.engine.events.request('abi-contracts-vanila', function(vanillaABI) { - console.log("got abi-contracts-vanila request"); + self.engine.events.request('code-contracts-vanila', function(vanillaABI) { callback(null, vanillaABI); }); - //self.engine.events.on('abi-contracts-vanila', function(vanillaABI) { - // console.log("got abi-contracts-vanila"); - // callback(null, vanillaABI); - //}); - //self.engine.events.request('abi', function(vanillaABI) { - // console.log("got abi"); - // callback(null, vanillaABI); - //}); }); self.engine.deployManager.deployContracts(function(err, result) { diff --git a/lib/index.js b/lib/index.js index 88498f09d..c0ca02ad7 100644 --- a/lib/index.js +++ b/lib/index.js @@ -81,7 +81,7 @@ class Embark { }); dashboard.start(function () { engine.events.on('code-generator-ready', function () { - engine.events.request('abi-vanila-deployment', function (abi) { + engine.events.request('code-vanila-deployment', function (abi) { dashboard.console.runCode(abi); }); });