replace beforeAction plugin api with event action api

This commit is contained in:
Iuri Matias 2018-05-29 09:37:16 -04:00
parent 8458acd207
commit 69e5af2308
2 changed files with 7 additions and 31 deletions

View File

@ -186,34 +186,7 @@ class Deploy {
}); });
}, },
function applyBeforeDeploy(next) { function applyBeforeDeploy(next) {
let beforeDeployPlugins = self.plugins.getPluginsFor('beforeDeploy'); self.plugins.runActionsForEvent('deploy:contract:beforeDeploy', {contract: contract}, next);
//self.logger.info("applying beforeDeploy plugins...", beforeDeployPlugins.length);
async.eachSeries(beforeDeployPlugins, (plugin, eachPluginCb) => {
self.logger.info(__("running beforeDeploy plugin %s .", plugin.name));
// calling each beforeDeploy handler declared by the plugin
async.eachSeries(plugin.beforeDeploy, (beforeDeployFn, eachCb) => {
function beforeDeployCb(resObj){
contract.code = resObj.contractCode;
eachCb();
}
beforeDeployFn({
embarkDeploy: self,
pluginConfig: plugin.pluginConfig,
deploymentAccount: deploymentAccount,
contract: contract,
callback: beforeDeployCb
}, beforeDeployCb);
}, () => {
//self.logger.info('All beforeDeploy handlers of the plugin has processed.');
eachPluginCb();
});
}, () => {
//self.logger.info('All beforeDeploy plugins has been processed.');
contractCode = contract.code;
next();
});
}, },
function createDeployObject(next) { function createDeployObject(next) {
let contractObject = self.blockchain.ContractObject({abi: contract.abiDefinition}); let contractObject = self.blockchain.ContractObject({abi: contract.abiDefinition});

View File

@ -23,9 +23,12 @@ module.exports = function (embark) {
embark.addFileToPipeline('./fileInPipeline.js'); embark.addFileToPipeline('./fileInPipeline.js');
embark.addFileToPipeline('./fileInPipeline.js', 'js/fileInPipeline.js'); embark.addFileToPipeline('./fileInPipeline.js', 'js/fileInPipeline.js');
embark.registerBeforeDeploy(function (options, callback) { embark.registerActionForEvent("deploy:contract:beforeDeploy", (params, cb) => {
// Just calling register to prove it works. We don't actually want to change the contracts embark.logger.info("applying beforeDeploy plugin...");
callback({contractCode: options.contract.code}); //console.dir(params);
//console.dir(cb);
//console.dir('------------------');
cb();
}); });
// NOTE: uncommenting this will make dappConnection stop working // NOTE: uncommenting this will make dappConnection stop working