update events name for code generation

This commit is contained in:
Iuri Matias 2017-10-17 07:03:13 -04:00
parent 6157968c5e
commit 460f78cc55
4 changed files with 36 additions and 15 deletions

View File

@ -11,7 +11,7 @@ const Templates = {
web3_connector: require('./code_templates/web3-connector.js.ejs'), web3_connector: require('./code_templates/web3-connector.js.ejs'),
do_when_loaded: require('./code_templates/do-when-loaded.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') exec_when_env_loaded: require('./code_templates/exec-when-env-loaded.js.ejs')
} };
class CodeGenerator { class CodeGenerator {
constructor(options) { constructor(options) {
@ -27,6 +27,7 @@ class CodeGenerator {
listenToCommands() { listenToCommands() {
let self = this; let self = this;
// deprecated events; to remove in embark 2.7.0
this.events.setCommandHandler('abi-vanila', function(cb) { this.events.setCommandHandler('abi-vanila', function(cb) {
let vanillaABI = self.generateABI({useEmbarkJS: false}); let vanillaABI = self.generateABI({useEmbarkJS: false});
let contractsJSON = self.generateContractsJSON(); let contractsJSON = self.generateContractsJSON();
@ -54,6 +55,37 @@ class CodeGenerator {
cb(vanillaABI, contractsJSON); 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) { generateProvider(isDeployment) {

View File

@ -81,7 +81,7 @@ class Engine {
plugins: this.plugins plugins: this.plugins
}); });
this.events.on('code-generator-ready', function () { 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.currentAbi = abi;
self.contractsJSON = contractsJSON; self.contractsJSON = contractsJSON;
pipeline.build(abi, contractsJSON, null, function() { pipeline.build(abi, contractsJSON, null, function() {

View File

@ -71,21 +71,10 @@ Test.prototype.deployAll = function(contractsConfig, cb) {
callback(); callback();
}, },
function deploy(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.on('code-generator-ready', function () {
self.engine.events.request('abi-contracts-vanila', function(vanillaABI) { self.engine.events.request('code-contracts-vanila', function(vanillaABI) {
console.log("got abi-contracts-vanila request");
callback(null, 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) { self.engine.deployManager.deployContracts(function(err, result) {

View File

@ -81,7 +81,7 @@ class Embark {
}); });
dashboard.start(function () { dashboard.start(function () {
engine.events.on('code-generator-ready', 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); dashboard.console.runCode(abi);
}); });
}); });