Reduce coupling by using action for event

This commit is contained in:
Anthony Laibe 2018-09-22 15:08:50 +01:00
parent e20d7bfc6a
commit 1dfd2e980f
2 changed files with 16 additions and 17 deletions

View File

@ -41,20 +41,19 @@ class DeployManager {
deployAll(done) {
let self = this;
async.waterfall([
function loadTracker(next) {
self.events.request("deployTracker:load", next);
},
function doDeployAll() {
self.events.request('contracts:dependencies', (err, contractDependencies) => {
self.events.request('contracts:list', (err, contracts) => {
if (err) {
return done(err);
}
self.logger.info(__("deploying contracts"));
self.events.emit("deploy:beforeAll");
self.events.request('contracts:dependencies', (err, contractDependencies) => {
self.events.request('contracts:list', (err, contracts) => {
if (err) {
return done(err);
}
self.logger.info(__("deploying contracts"));
async.waterfall([
function (next) {
self.plugins.emitAndRunActionsForEvent("deploy:beforeAll", next);
},
function () {
const contractDeploys = {};
const errors = [];
contracts.forEach(contract => {
@ -100,10 +99,10 @@ class DeployManager {
self.logger.error(e.message || e);
done(__('Error deploying'));
}
});
});
}
]);
}
]);
});
});
}
deployContracts(done) {

View File

@ -19,7 +19,7 @@ class DeployTracker {
registerEvents() {
const self = this;
this.events.setCommandHandler("deployTracker:load", this.setCurrentChain.bind(this));
this.embark.registerActionForEvent("deploy:beforeAll", this.setCurrentChain.bind(this));
this.events.on("deploy:contract:deployed", (contract) => {
self.trackContract(contract.className, contract.realRuntimeBytecode, contract.realArgs, contract.deployedAddress);