diff --git a/lib/contracts/deploy.js b/lib/contracts/deploy.js index da20f957..25b95c9e 100644 --- a/lib/contracts/deploy.js +++ b/lib/contracts/deploy.js @@ -262,12 +262,7 @@ class Deploy { // just need to figure out the gasLimit coupling issue self.events.request('code-generator:contract:vanilla', contract, self.gasLimit, (contractCode) => { self.events.request('runcode:eval', contractCode); - - let onDeployPlugins = self.plugins.getPluginsProperty('onDeployActions', 'onDeployActions'); - - async.eachLimit(onDeployPlugins, 1, function(plugin, nextEach) { - plugin.call(plugin, contract, nextEach); - }, () => { + self.plugins.runActionsForEvent('deploy:contract:deployed', {contract: contract}, () => { return next(null, receipt); }); }); diff --git a/lib/core/plugins.js b/lib/core/plugins.js index 8efa8442..d3479f58 100644 --- a/lib/core/plugins.js +++ b/lib/core/plugins.js @@ -116,13 +116,23 @@ Plugins.prototype.getPluginsProperty = function(pluginType, property, sub_proper return matchingProperties.reduce((a,b) => { return a.concat(b); }) || []; }; -//Plugins.prototype.runActionsForEvent = function(eventName, args, cb) { -Plugins.prototype.runActionsForEvent = function(eventName, cb) { +Plugins.prototype.runActionsForEvent = function(eventName, args, cb) { + if (typeof(args) === 'function') { + cb = args; + } let actionPlugins = this.getPluginsProperty('eventActions', 'eventActions', eventName); + if (actionPlugins.length === 0) { + return cb(); + } + async.eachLimit(actionPlugins, 1, function(plugin, nextEach) { - //plugin.call(plugin, ...args, nextEach); - plugin.call(plugin, nextEach); + if (typeof(args) === 'function') { + plugin.call(plugin, nextEach); + } else { + //plugin.call(plugin, ...args, nextEach); + plugin.call(plugin, args, nextEach); + } }, cb); }; diff --git a/lib/modules/specialconfigs/index.js b/lib/modules/specialconfigs/index.js index 0ffe15e1..bd8dca71 100644 --- a/lib/modules/specialconfigs/index.js +++ b/lib/modules/specialconfigs/index.js @@ -80,7 +80,9 @@ class SpecialConfigs { registerOnDeployAction() { const self = this; - this.embark.registerOnDeployContracts((contract, cb) => { + this.embark.registerActionForEvent("deploy:contract:deployed", (params, cb) => { + let contract = params.contract; + if (!contract.onDeploy) { return cb(); }