remove direct reference to contracts manager, use a request instead
This commit is contained in:
parent
98c5b2dd06
commit
3fb2b6fa60
|
@ -8,6 +8,7 @@ const constants = require('../constants');
|
||||||
|
|
||||||
class ContractsManager {
|
class ContractsManager {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
|
const self = this;
|
||||||
this.contractFiles = options.contractFiles;
|
this.contractFiles = options.contractFiles;
|
||||||
this.contractsConfig = options.contractsConfig;
|
this.contractsConfig = options.contractsConfig;
|
||||||
this.contracts = {};
|
this.contracts = {};
|
||||||
|
@ -18,14 +19,13 @@ class ContractsManager {
|
||||||
this.deployOnlyOnConfig = false;
|
this.deployOnlyOnConfig = false;
|
||||||
this.events = options.events;
|
this.events = options.events;
|
||||||
|
|
||||||
this.events.on(constants.events.contractFilesChanged, (newContractFiles) => {
|
self.events.on(constants.events.contractFilesChanged, (newContractFiles) => {
|
||||||
this.contractFiles = newContractFiles;
|
self.contractFiles = newContractFiles;
|
||||||
});
|
});
|
||||||
this.events.on(constants.events.contractConfigChanged, (newContracts) => {
|
self.events.on(constants.events.contractConfigChanged, (newContracts) => {
|
||||||
this.contractsConfig = newContracts;
|
self.contractsConfig = newContracts;
|
||||||
});
|
});
|
||||||
|
|
||||||
const self = this;
|
|
||||||
self.events.setCommandHandler('contracts:list', (cb) => {
|
self.events.setCommandHandler('contracts:list', (cb) => {
|
||||||
cb(self.listContracts());
|
cb(self.listContracts());
|
||||||
});
|
});
|
||||||
|
|
|
@ -181,9 +181,8 @@ class Deploy {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function doLinking(next) {
|
function doLinking(next) {
|
||||||
// Applying linked contracts
|
self.events.request('contracts:list', (contracts) => {
|
||||||
let contractsList = self.contractsManager.listContracts();
|
for (let contractObj of contracts) {
|
||||||
for (let contractObj of contractsList) {
|
|
||||||
let filename = contractObj.filename;
|
let filename = contractObj.filename;
|
||||||
let deployedAddress = contractObj.deployedAddress;
|
let deployedAddress = contractObj.deployedAddress;
|
||||||
if (deployedAddress) {
|
if (deployedAddress) {
|
||||||
|
@ -206,6 +205,7 @@ class Deploy {
|
||||||
// saving code changes back to contract object
|
// saving code changes back to contract object
|
||||||
contract.code = contractCode;
|
contract.code = contractCode;
|
||||||
next();
|
next();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
function applyBeforeDeploy(next) {
|
function applyBeforeDeploy(next) {
|
||||||
let beforeDeployPlugins = self.plugins.getPluginsFor('beforeDeploy');
|
let beforeDeployPlugins = self.plugins.getPluginsFor('beforeDeploy');
|
||||||
|
@ -284,9 +284,9 @@ class Deploy {
|
||||||
deployAll(done) {
|
deployAll(done) {
|
||||||
let self = this;
|
let self = this;
|
||||||
this.logger.info(__("deploying contracts"));
|
this.logger.info(__("deploying contracts"));
|
||||||
let contracts = this.contractsManager.listContracts();
|
|
||||||
this.events.emit("deploy:beforeAll");
|
this.events.emit("deploy:beforeAll");
|
||||||
|
|
||||||
|
self.events.request('contracts:list', (contracts) => {
|
||||||
async.eachOfSeries(contracts,
|
async.eachOfSeries(contracts,
|
||||||
function (contract, key, callback) {
|
function (contract, key, callback) {
|
||||||
self.logger.trace(arguments);
|
self.logger.trace(arguments);
|
||||||
|
@ -307,6 +307,7 @@ class Deploy {
|
||||||
done(err);
|
done(err);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue